Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
turtledemo.nim.NimModel Class Reference
Inheritance diagram for turtledemo.nim.NimModel:
Inheritance graph
[legend]
Collaboration diagram for turtledemo.nim.NimModel:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def setup
def move
def game_over
def notify_move

Public Attributes

 game
 sticks
 player
 winner
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Detailed Description

Definition at line 53 of file nim.py.


Constructor & Destructor Documentation

def turtledemo.nim.NimModel.__init__ (   self,
  game 
)

Definition at line 54 of file nim.py.

00054 
00055     def __init__(self, game):
00056         self.game = game

Here is the caller graph for this function:


Member Function Documentation

Definition at line 80 of file nim.py.

00080 
00081     def game_over(self):
00082         return self.sticks == [0, 0, 0]

Here is the caller graph for this function:

def turtledemo.nim.NimModel.move (   self,
  row,
  col 
)

Definition at line 66 of file nim.py.

00066 
00067     def move(self, row, col):
00068         maxspalte = self.sticks[row]
00069         self.sticks[row] = col
00070         self.game.view.notify_move(row, col, maxspalte, self.player)
00071         if self.game_over():
00072             self.game.state = Nim.OVER
00073             self.winner = self.player
00074             self.game.view.notify_over()
00075         elif self.player == 0:
00076             self.player = 1
00077             row, col = computerzug(self.sticks)
00078             self.move(row, col)
00079             self.player = 0

Here is the call graph for this function:

Here is the caller graph for this function:

def turtledemo.nim.NimModel.notify_move (   self,
  row,
  col 
)

Definition at line 83 of file nim.py.

00083 
00084     def notify_move(self, row, col):
00085         if self.sticks[row] <= col:
00086             return
00087         self.move(row, col)
00088 

Here is the call graph for this function:

Definition at line 57 of file nim.py.

00057 
00058     def setup(self):
00059         if self.game.state not in [Nim.CREATED, Nim.OVER]:
00060             return
00061         self.sticks = [randomrow(), randomrow(), randomrow()]
00062         self.player = 0
00063         self.winner = None
00064         self.game.view.setup()
00065         self.game.state = Nim.RUNNING


Member Data Documentation

Definition at line 55 of file nim.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

Definition at line 61 of file nim.py.

Definition at line 60 of file nim.py.

Definition at line 62 of file nim.py.


The documentation for this class was generated from the following file: