Initial Commit
[Projects.git] / ai / player.py
blobe4ed077353820af64ba421eb9ed49eca721f7469
1 import sys, os
3 class player:
4 def __init__(self, check):
5 self.check = check
6 if sys.stdin.isatty():
7 import tty
8 oldattr=tty.tcgetattr(sys.stdin)
9 newattr=oldattr[:]
10 newattr[3] &= ~tty.ICANON
11 tty.tcsetattr(sys.stdin, tty.TCSANOW, newattr)
12 def write(self, data):
13 sys.stdout.write("%s" % data)
14 def read(self):
15 while True:
16 s=sys.stdin.read(1)
17 if s!='': return s
18 elif s=='\n': self.clear()
19 def clear(self):
20 os.system('clear')
21 def input(self,data):
22 #self.clear()
23 self.write(data + '\n')
24 def output(self):
25 return self.read()