Please give it a try and let me know what you think. One glaring problem I already am aware of is that the AI is really dumb (It just picks a random square.) I implemented the minmax AI algorithm but it is not working properly so I need to investigate further. In the mean time this atleast works.
Cool, nice job.
The one thing I might do is have it default to one player and have a default for the elves or orcs selection (that could be random).
Having it default to 0 players, it kind of jumps and for a second I thought I was supposed to choose again. Most people choose one player, why not default with that. And defaulting for orcs or elves would allow people to start quicker if they don’t care.
But still - nice job.
Thanks. I’ve changed the default to one player. You still have to choose between orcs and elves though.
Also I’ve fixed the AI. It should play a perfect game every time now.
Cool, that works.
Digging a little deeper now, I notice that if I click really fast, I can click extra squares.
I can’t remember. I think I handled that by having a boolean variable for if it was the players turn. Then I checked it in the click handlers and exited if it was not the player’s turn.
Fixed. This bug really perplexed me at first because I have the once: true option set when I create my click event handler which I assumed would prevent the handler from being called more than…once.
Then I figured it out. I actually have up to nine click event handlers, one for each empty square. So if you click on one square, that handler does get disabled but the others are still active. I changed the code to have only one handler listening to the entire game area and then within the handler to look at exactly what got clicked. This means I also had to check that the player is not clicking on an already occupied space.
Looks good! Have fun with the next one!