TicTacToe against artificial intelligence

Hi Inform Lovers ^^
I got another question. Im workin on a project in inform , i try to write a TicTacToe game.
It should look like :
I wanne go through a door, the door is looked. The only way to unlock the door is to play against an artificial intelligence and win a TicTacToe game. The board is a panel on the side of the door.

Got any tips for me?

Thx to everybody how can help :slight_smile:

You’re in luck: TicTacToe came up in a recent thread here, and Chin Kee Yong posted a complete implementation.

I have the feeling that “tic-tac-toe against a locked door” is actually a class project somewhere in the world…

@chinkeeyong another great work, im impressed!
How about to play a tictactoe game wenn the AI random place an X? Should be a lil bit easier or? I mean when the AI only check if an place where empty and place an X.
Got an idea?

Greetz

Tic-tac-toe is a draw with perfect play though. Therefore, I don’t know how good this work?

@sub0: That is very easily accomplished by deleting the “play to win rule” and the “play to not lose rule” from the tic-tac-toe playing rulebook.

@zzo38: I answered that question in the annotations of the source text:

While it is possible to create an algorithm that will never lose, we want the player to be able to defeat the computer, and so we'll create one that is imperfect while still posing a challenge.

@chinkeeyong

Is it not possible to reduce the code to a minimum, if i delete the rules, its not really shorter than before :confused:

The minimum for the code is to strip out all the comments. If you need more word economy, you can also cut all the names of the rules. Everything else is critical.

@chinkeeyong
Can you explain to me how to place a O oder X in you code. No matter what i try it wound work…