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

后端 未结 6 1749
陌清茗
陌清茗 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:09

    First of all, it's worth noting that in checkers, half the squares on the boards can never be used, so you really only need an array of 32 items, not 64. Taking kings into account, you get possibilities from 0 to 4 instead of 0 to 2 (though when I did it, I found it easier to use -3 to +3 instead, so the values for red and black have the same magnitude and opposite signs).

提交回复
热议问题