我正在用gui制作N * N皇后问题。 我想让gui停止每个女王的每一次移动x秒,问题是,程序只是将所有的等待堆叠在一起,然后以一定的速度运行一切。 我在这里给代码:http://pastebin.com/s2VT0E49睡眠块整个程序(Smalltalk Squeak)
编辑: 这是我的工作区:
board := MyBoard new initializeWithStart: 8.
Transcript show:'something'.
3 seconds asDelay wait.
board solve.
3 seconds asDelay wait.
board closeBoard.
这就是我要等待发生
canAttack: testRow x: testColumn
| columnDifference squareMark |
columnDifference := testColumn - column.
((row = testRow
or: [row + columnDifference = testRow])
or: [row - columnDifference = testRow]) ifTrue: [
squareDraw := squareDraw
color: Color red.
0.2 seconds asDelay wait.
^true ].
squareDraw := squareDraw color: Color black.
^neighbor canAttack: testRow x: testColumn
下次请尝试发布代码的相关部分和尽可能少的代码。链接到代码不被视为SO上的良好实践。同时显示您尝试解决问题的方法。 –
现在@MaxLeske – Infested
现在好多了。我提高了可读性。 –