Beginner: simple chess board representation

Code, algorithms, languages, construction...
Post Reply
dada_
Posts: 1
Joined: Thu Aug 02, 2012 12:48 am
Real Name: M S

Beginner: simple chess board representation

Post by dada_ » Thu Aug 02, 2012 1:05 am

Hello there. I'm a beginning chess programmer, and I'm planning to make a small chess website together with a friend of mine. Players will be able to play chess against one another in a minimalist environment. It's sort of an educational experience, mostly.

Of course, any basic chessboard UI needs to be able to tell you whether a move is legal or not. I'd also like to add nice functionalities like showing all attacked pieces, isolated pawns, etc. I'm not looking to build an engine, though.

However, I'm working with a major limitation: since it's a website, I'll be building it in Javascript, and it doesn't have 64-bit numbers. (It does have 64-bit doubles, which are truncated to 32-bits for integer operations.) So a standard bitboard approach would be a bit tedious to make in it. Bitwise operations are still available, but limited to 32-bits (unless I do all shifts in two separate operations, which is a bit troublesome).

What sort of board representation do you think I should go with? Perhaps there are example implementations that I could look at? Thanks very much for your insight!

Richard Vida
Posts: 50
Joined: Thu Jun 10, 2010 12:48 am

Re: Beginner: simple chess board representation

Post by Richard Vida » Thu Aug 02, 2012 2:06 pm

Javascript is quite slow no matter what you do, so I would suggest not going too fancy and stick with the "simpler = better" rule. Given that you do not intend to do any search, speed is not so essential. Just for generating legal moves I would go with the simple "int squares[64]" board representation.

Post Reply