summaryrefslogtreecommitdiff
path: root/tictactoe.py
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2007-07-24 13:22:23 +0200
committerGuillaume Seguin <guillaume@segu.in>2007-07-24 13:22:23 +0200
commit22a87992c7098b9bd4b68fb4e32c690dc47db14e (patch)
treef3d5081f7a52f1e70f7166d57672d0105cf3110d /tictactoe.py
parentcde1100fb36efa4d11cc84e5b2c23041258be2f5 (diff)
downloadtictactoe-22a87992c7098b9bd4b68fb4e32c690dc47db14e.tar.gz
tictactoe-22a87992c7098b9bd4b68fb4e32c690dc47db14e.tar.bz2
* Improve computer IA
Diffstat (limited to 'tictactoe.py')
-rwxr-xr-xtictactoe.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tictactoe.py b/tictactoe.py
index 12e6c25..e313a82 100755
--- a/tictactoe.py
+++ b/tictactoe.py
@@ -191,6 +191,18 @@ class gtkTicTacToe (gtk.DrawingArea):
and not self._map[0][i]:
self._map[0][i] = COMPUTER_ID
return
+ if not self._map[0][0]:
+ self._map[0][0] = COMPUTER_ID
+ return
+ elif not self._map[0][2]:
+ self._map[0][2] = COMPUTER_ID
+ return
+ elif not self._map[2][2]:
+ self._map[2][2] = COMPUTER_ID
+ return
+ elif not self._map[2][0]:
+ self._map[2][0] = COMPUTER_ID
+ return
cells = self.empty_cells ()
cell = random.randint (1, cells)
for j in range (3):