表示四象限平面(一堆正方形)最基本的方法是使用二维数组。
在C#中,我们声明为int[,]
,可以使我们的平面任意大:
string[3,3] => tic-tac-toe board (or similar)
string[8,8] => chess or checkers board
要在平面上“移动”一个物品,我们只需将其分配到新的“位置”即可。
//using our tic-tac-toe board:
string[0,0] = "x"; //top-left
string[1,1] = "o"; //middle-middle
//to move
string[0,1] = bN; //Black Knight's starting positon
string[2,2] = bN; //Black Knight moves
string[0,1] = String.Empty;
那么,如何表示一个六边形平面(一堆六边形),并且如何处理从一个位置到另一个位置的移动?
注意:这不是纯理论,因为我脑海中有一个需要这种移动的小游戏的想法,但我无法理解如何完成。我查看了其他问题,但没有找到一个好的匹配......