Search
Příkad:
player.py
self.board
self.name
self.text
self.which
-self.which
self.stones
print()
getScore(which)
player.move()
Player
player.update( other )
other
BasePlayer
update()
move()
[ [0,0], [1,0], [2,0], [1,1] ]
[ [2,0], [1,1], [0,0], [1,0] ]
loadStones(filename
base.py
example.py
import base import player as P stones = base.loadStones("stones9.txt") size = 10; #create two players (here as two instances of Player class defined in player.py) p1 = P.Player("DogFishDead",size, size, 1, stones); #1 means player 1 p2 = P.Player("FatTire",size, size, -1, stones); #-1 is for player 2 while(True): p1.print(); r1 = p1.move(); p2.update(r1); r2 = p2.move(); p1.update(r2); p2.print(); s1 = p1.getScore(1); s2 = p1.getScore(-1); if (len(r1) == 0 and len(r2) == 0): print("No answer, end, r1=",r1, "r2=",r2); break; s1 = p1.getScore(1); s2 = p1.getScore(-1); if (s1 < s2): print("Player 1 wins (", s1, s2,")"); elif (s1 > s2): print("Player 2 wins (", s1, s2,")"); else: print("No winner, draw! ", s1,s2); print("End of game");
p2
self.isUsed
self.isUsed[i]=1