Demo
If you'd like to demo the code yourself, clone the repo and run shadow-cljs watch app
at the command line (which of course implies you've installed shadow-cljs). If you're more of a figwheel type, it should be straightforward to modify the project to work with figwheel.
For this article, we'll show some videos. Let's start with the game as initially defined, smart AI and no help for the user. We've set the AI latency to 800ms demo purposes, so it looks like the computer is actually having to work hard.
When a square is white, it is selectable. We see how the ::MoveRequest
's change as the game progresses. When it's the AI's turn, nothing is selectable, and of course I can't select any square that's already been marked.
The AI proves pretty invincible, I rather less so. Let's turn on Teaching mode.
We can see the effect of the new ::move-request!
rule, as only a subset of the squares turns white. I certainly fare better here, at least achieving a tie in every game. But my bruised ego needs some balm, phony as it may be, so I turn on dumb AI mode:
That's more like it, just win baby (at least some times).