Page 2 of 2

Re: Tic Tac Toe - AI (efficient algorithm?)

Posted: Wed May 09, 2012 7:32 pm
by Roland_Yonaba
Petunien wrote: But it's a good feel, that I could come back with more questions. :)
(I'm sure.)
No problem.
Petunien wrote:Yeah, exactly how I meant it. This would be possible with a few of variables and values. Sounds easy. ^^
Well, I'm not that sure. But at first, try to focus on writing the game itself. Once done, you can come back to the network support.

Re: Tic Tac Toe - AI (efficient algorithm?)

Posted: Wed May 09, 2012 7:44 pm
by Petunien
According to my knowledge, network works basically like:

1) Player X choose a field. The new values (selected field and maybe other values like gametime) will be sent.
2) Player Y receive the new values, the program works accordingly and waits for Player Y's selection.

And so on, or?

Basically...

Re: Tic Tac Toe - AI (efficient algorithm?)

Posted: Wed May 09, 2012 8:27 pm
by Xgoff
Roland_Yonaba wrote:Check for Minimax algorithm, it can be used for AI in a Tic Tac Toe game.
But it'll need some skills to be implemented in Lua, though.
minimax can't be that hard to implement in lua, considering there's an implementation of it on that wiki page

Re: Tic Tac Toe - AI (efficient algorithm?)

Posted: Wed May 09, 2012 9:28 pm
by Robin
So to add to what Roland said:
Petunien wrote:2) Robin, you wrote it in Python, is it difficult to "translate" it bzw. write it in Lua/LÖVE?
It is not really difficult, but it will take certainly more effort than just writing it again for your specific purpose.

Minimax isn't complicated: you either choose the highest value or the lowest value, and that for every option you have.
Petunien wrote:3) Are all 255,168 (Wikipedia) game-situations covered with Minimax?
Yes. Minimax finds all possible games and evaluates them. That's why you shouldn't use Minimax for chess, which has something like 10^70 possible games...
Petunien wrote:4) How does it work with network?
Are there "normal" values like numbers, true/false and so on, that can be sent and further processed to/by another PC as well?
Not sure what you mean here, Roland probably wrote a better answer than I would write here.

Re: Tic Tac Toe - AI (efficient algorithm?)

Posted: Thu May 10, 2012 1:38 am
by Jasoco
Man, I wish I still had the code for the TTT game I built in Visual Basic way back in the day. I was extremely proud of the AI system I built in. I had three skills. Easy, which just picked random blocks. Hard, which actually used the most logical move to block your move. And Medium which was a hybrid and randomly chose between random and logical. I can't remember how I made it so smart. I was new to programming so for me back then figuring out how to do it by myself was pretty big. So sad that back then we didn't have the luxury of cheap USB backup hard drives or Internet cloud-based file hosting sites. I lost so much cool stuff I wish I had at least copied to a floppy disk or something.

Re: Tic Tac Toe - AI (efficient algorithm?)

Posted: Thu May 10, 2012 5:57 am
by Adamantos
Here is the optimal solution for this game :)
http://xkcd.com/832/

Re: Tic Tac Toe - AI (efficient algorithm?)

Posted: Thu May 10, 2012 1:39 pm
by Roland_Yonaba
Adamantos wrote:Here is the optimal solution for this game :)
http://xkcd.com/832/
Lol. :awesome:
I had a clue when I first saw "xkcd" in the url...

EDIT:
Another algorithm that can be used for solving a Tic-Tac-Toe is Backtracking.
Useful resources can be found on SiteExperts, csStanford and Duke.

Re: Tic Tac Toe - AI (efficient algorithm?)

Posted: Sun May 13, 2012 11:11 am
by Petunien
I'm trying and reading a lot of stuff. Only so you don't think I gave up. :)
But many of the examples are written in Java, so I have to understand the basic of that language before I can understand anything.
Bad.

@Roland
Thanks for the other links, I saw them just now.
It looks easier than Minimax, at least in my opinion.