Workshop › Connect Four › Step 33 of 38
Yellow is now the computer. When the turn passes to it, it waits half a second (30 frames), so you can see what happened,
then plays computerMove(). thinking counts the frames down in update.
```js
let thinking // frames until the computer moves
thinking = 0
turn = 3 - turn
if (turn === 2) thinking = 30
return
}
if (!winner && turn === 2) {
thinking -= 1
if (thinking <= 0) play(computerMove())
}
```land starts the countdown when the turn passes to the computer.update, return after the falling disc means the countdown waits while a disc falls.thinking goes down by 1 each frame; at 0 the computer plays.let hoverCol write let thinking; in reset, under falling = null, write thinking = 0.land, under turn = 3 - turn, start the countdown.update, add return at the end of the falling block and the countdown after it.Skills: Game states, The game loop
← Prefer the middle Only on your turn →