What is the best data-structure to represent a checkers board when speed is the primary concern?

后端 未结 6 1752
陌清茗
陌清茗 2020-12-31 18:23

I am currently implementing something quite similar to checkers. So, I have this table game and there are both white and black pieces. Where there are neither white or black

6条回答
  •  情歌与酒
    2020-12-31 19:10

    Consider using a bitmap: two 64-bit unsigned ints, one for white and one for black. Then you can represent moves and board positions as a function from (W x B) -> (W x B) where W, B represent the set of possible white and possible black positions respectively.

    Then most of the board position stuff can be done with integer arithmetic, which is about as fast as you can get.

提交回复
热议问题