git.ucc.asn.au
/
progcomp2013.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Trying to fix bug with fifo and network players
[progcomp2013.git]
/
qchess
/
src
/
player.py
diff --git
a/qchess/src/player.py
b/qchess/src/player.py
index
346674b
..
37cca67
100644
(file)
--- a/
qchess/src/player.py
+++ b/
qchess/src/player.py
@@
-97,7
+97,15
@@
class FifoPlayer(Player):
Player.__init__(self, name, colour)
os.mkfifo(self.name+".in")
os.mkfifo(self.name+".out")
Player.__init__(self, name, colour)
os.mkfifo(self.name+".in")
os.mkfifo(self.name+".out")
-
+
+ try:
+ self.fifo_out = open_fifo(self.name+".out","w", FifoPlayer.timeout)
+ except:
+ raise Exception("FIFO_TIMEOUT")
+ else:
+ self.fifo_out.write("START "+colour+"\n")
+ self.fifo_out.close()
+
@@
-265,9
+273,11
@@
class HumanPlayer(Player):
sys.stdout.write("SELECTION?\n")
try:
p = map(int, sys.stdin.readline().strip("\r\n ").split(" "))
sys.stdout.write("SELECTION?\n")
try:
p = map(int, sys.stdin.readline().strip("\r\n ").split(" "))
+ return p
except:
sys.stderr.write("ILLEGAL GIBBERISH\n")
continue
except:
sys.stderr.write("ILLEGAL GIBBERISH\n")
continue
+
# It's your move captain
def get_move(self):
if isinstance(graphics, GraphicsThread):
# It's your move captain
def get_move(self):
if isinstance(graphics, GraphicsThread):
@@
-283,6
+293,7
@@
class HumanPlayer(Player):
sys.stdout.write("MOVE?\n")
try:
p = map(int, sys.stdin.readline().strip("\r\n ").split(" "))
sys.stdout.write("MOVE?\n")
try:
p = map(int, sys.stdin.readline().strip("\r\n ").split(" "))
+ return p
except:
sys.stderr.write("ILLEGAL GIBBERISH\n")
continue
except:
sys.stderr.write("ILLEGAL GIBBERISH\n")
continue
UCC
git Repository :: git.ucc.asn.au