Add docstrings and doctests to pbot.py + Python cleanups.
[poker.git] / p2.py
1 #!/usr/bin/python
2 import sys
3 import os
4
5 IN, OUT = sys.stdin, sys.stdout
6
7 FOUT  = open("test_anyPair.txt",'w')
8 allin = False
9
10 while True:
11    std_in = IN.readline().strip()
12    if std_in:
13         std_in = std_in.split(' ')
14         try   : 
15             tag  = std_in[0]
16             type = std_in[1]
17             data = std_in[2:]
18         except: 
19             FOUT.write(str(std_in))
20             tag  = std_in[0]
21
22         #FOUT.write(tag+' '+type+' '+str(data)+' '+'\n')
23
24         if tag == "MOVE": 
25             # You must return a valid bet here
26             if allin: OUT.write("A\n")
27             else    : OUT.write("f\n")
28             OUT.flush()
29             allin = False
30
31         elif tag == "INFO" and type == "HOLE":
32             # Handle new information
33             # Save info to a file and go all in on any pair
34             h1, h2 = data[-1], data[-2]
35
36             if h1[0] == h2[0] and h1[0]=="A":  allin = True
37
38                 
39             
40
41             
42         
43
44
45
46