- Edited
outdated ...
Nice Guess ;) you obviously understand its concept without looking @ its code, there is sleep time indeed, so that it would look more human like ;), you know the core never take time to think for such an algorithm.arithma wroteThe AI thinks quite a lot. I think you put in a sleep command? It surely doesn't need to think at all..
Have you tried to abuse the symmetry of the game in writing the rules or was it all just hard coded.
Kudo's for finishing something you started - I follow a similar pattern when I am bored, just create something simple.
you are absolutely right, thank you for the notice =],i just set it to reset the labels but didn't actually reset the counters =]Yorgi wroteHey Nader.Sleiman
I downloaded your game and played it couple of times. And that was interesting. The AI is smart :P
but i found a bug in the game. It's the reset button. Once i reset the scores, the displayed score is 0 | 0. and when you play again, and lose/win, the displayed score in the previous one that i already reset.
I didn't have time to check the code, but i'll do so later on this day.
Good Job again.
Hey Xtermxterm wroteHi Nader,
There's a much simpler way (which reduces your code alot) to check whether someone won.
You have a 3x3 grid with 8 possible ways of winning. We mark each cell in the grid with 2^[index] and thus we will have:
1 2 4
8 16 32
64 128 256
The winning combination are:
1 + 2 + 4 = 7
8 + 16 + 32 = 56
1 + 8 + 64 = 73
4 + 16 + 64 = 84
2 + 16 + 128 = 146
1 + 16 + 256 = 273
4 + 32 + 256 = 292
64 + 128 + 256 = 448
Thus the winning array is: int win[8] = {7,56,73,84,146,273,292,448}
Everytime X makes a move, add the value in the grid to an xcounter
Everytime Y makes a move, add the value in the grid to an ocounter
Everytime a move takes place check for every entry in the win array, whether xcounter & entry == entry
If so, X won.
That should do it, nevertheless, well done.click event:
gridLoc = findGridLocationClicked(e);
xcounter += Math.pow(2,gridLoc);
checkWin(xcounter)
static boolean checkWin(int counter){
int win[8] = {7,56,73,84,146,273,292,448}
for(int entry: win)
if(counter & entry == entry)
return true;
return false;
}
well Thanks =], i'd stick to the array of Enums though =p , but i also like your suggestion ;) !xterm wroteThat should do it, nevertheless, well done.click event:
gridLoc = findGridLocationClicked(e);
xcounter += Math.pow(2,gridLoc);
checkWin(xcounter)
static boolean checkWin(int counter){
int win[8] = {7,56,73,84,146,273,292,448}
for(int entry: win)
if(counter & entry == entry)
return true;
return false;
}
Hehe 7obbi, you told me to post it last time, so i did now xD, im nerdy again woohoo <3 it, well but this game is ridiculous i guess =p, i should post one of ma 3d ones, but then again it will require the JME (Jmonkey Engine) and phys3d Libraries , so it'll be huge in size =/jadberro wroteTaybe la sleiman ;)