pygame is
Python
Simple DirectMedia Layer
 
 
pygame.org is
Site Swing
tic tac toe AI

tic tac toe AI - 1.0

benjamin lee (benjamin)

Tags:

Description

This is an artificial intelligence algorithm that plays tic tac toe. It is not that complicated but it never loses. The algorithm for the AI is based on the priority of different kinds of moves, 1: if the AI has is 2 in a row, win 2: if the player has 2 in a row block them 3: move in the square that gives the most possible wining combos It can tell whether there can be 3 in a row with a list of wining combinations which is probably not the most efficient method but it allows both the AI and the interface to check the status easily. If the player goes first then it is possible to beat it because of a bug involving the way it determines the move for step 3, I will hopefully fix this later.

Links

Home Page: http://dl.dropbox.com/u/851399/source/tictac%20AI.py
Source: http://dl.dropbox.com/u/851399/source/tictac%20AI.py

Screenshot


click to view original size

Releases

tic tac toe AI - 1.0 - Mar 25, 2012

Pygame.org account Comments

If you wish to leave a comment with your pygame.org account, please sign in first.

April 3, 2012 8:02pm - Daniel Petri - nickname: (danielpetri1)
Fine!
Way to win - I started
Me: 1, 3
Computer: middle
Me: 3, 1
Computer: 1,1
Me: 3, 3

All the other ways to win I figured out are the same, just mirrored/flipped.
That's it. I can't beat him if he starts.
March 30, 2012 4:27pm - benjamin lee - nickname: (benjamin)
Could use list all the coordinates that were played when you beat it so that I can figure out what went wrong?
March 29, 2012 8:36pm - Daniel Petri - nickname: (danielpetri1) - 5/5
Good job! But I beated him several times. It's hard, but possible!
March 26, 2012 2:28pm - Michal Rapacz - nickname: (michail)
Nice work!
spotlight

 
our projects
pygame.org welcomes all python game, art, music, sound, video and multimedia projects. If they use pygame or not.
 
recent releases
Sep 29, 2014

Sep 19, 2014

Sep 17, 2014

Sep 9, 2014

Sep 8, 2014

Sep 7, 2014


Sep 5, 2014

Aug 26, 2014

Aug 21, 2014


Aug 18, 2014

... more!
 
for pygame related questions, comments, and suggestions, please see help (lists, irc)