我正在做一个 8 Puzzle 求解器,它最终将每个节点(元素 0-8 的 int[])存储在路径中,以便将块按顺序放入堆栈中。我有一个显示 int[,] 的 WPF GUI
foreach (var node in stack)
{
int[,] unstrung = node.unstringNode(node); // turns node of int[] into board of int[,]
blocks.setBoard(unstrung); // sets the board to pass in to the GUI
DrawBoard(); // Takes the board (int[,]) and sets the squares on the GUI to match it.
Thread.Sleep(500);
}
GUI 显示初始板,然后单击解决后,最终(按顺序)板正确显示。我想要做的是在板上显示每个节点一段时间,最终到达有序板上。使用 Thread.Sleep,GUI 将在显示最终节点之前暂停设定的时间。关于为什么此代码不会每 500 毫秒在每个节点上显示板的任何想法?
作为参考,以下是 Console.Write 节点的示例输出:
4,2,3,6,1,0,7,5,8
4,2,0,6,1,3,7,5,8
4 ,0,2,6,1,3,7,5,8
4,1,2,6,0,3,7,5,8
4,1,2,0,6,3,7,5,8
0,1,2,4,6,3,7,5,8 1,0,2,4,6,3,7,5,8
1,2,0,4,6,3,7,5
, 8
1,2,3,4,6,0,7,5,8
1,2,3,4,0,6,7,5,8
1,2,3,4,5,6,7,0 ,8
1,2,3,4,5,6,7,8,0