Began versioning.
[poker.git] / PBOT.py
1 import popen2
2 from DECK import *
3 from GAMEPLAY import *
4 global GLOBAL_TXT
5 #import psyco; psyco.full()
6
7 start_stack = 1000
8 blinds      = [1,2,4,8,16,25,37,50]
9 hand_clock  = 20
10
11 # Command line arguments
12 import sys
13
14 try   : A = player(sys.argv[1],sys.argv[1]) 
15 except: A = player('Meg')
16 try   : B = player(sys.argv[2], sys.argv[2])
17 except: B = player('Jack')
18 try   : tournament_N = int(sys.argv[3])
19 except: tournament_N = 1
20
21 P = [A,B]
22 for n in xrange(tournament_N):
23     A.cash = start_stack
24     B.cash = start_stack
25
26     hand_count,b = 0, 0
27
28     while A.cash > 0 and B.cash > 0:
29         hand_count += 1
30
31         if hand_count % hand_clock==0: 
32             b = b+1 if b < len(blinds)-1 else len(blinds)-1
33             
34         GLOBAL_TXT = gameplay(DECK, P[0],P[1], blinds[b])
35
36         # Allow the players to view the end result
37         board = [DECK[n] for n in xrange(4,9)]
38         flop,turn,river = board[:3], board[3:4], board[4:5]
39         if not A.FOLD and not B.FOLD:
40             GP("INFO ",A.name, pp_hand(A.hole), pp_score(A), ' ',A.cash)
41             GP("INFO ",B.name, pp_hand(B.hole), pp_score(B), ' ',B.cash)
42         GP("INFO GAMEOVER ", hand_count)
43         for p in P: 
44             if p.brain: 
45                 p.GP_FLUSH(returnGP())
46                 p.GP_BUFFER = []
47           
48         # Human player text
49         if not A.brain or not B.brain: # or True:
50             for g in GLOBAL_TXT: print g
51             print "INFO BOARD ", pp_hand([DECK[n] for n in xrange(4,9)])
52
53         P = [P[-1]] + P[:-1] # Cycle the player order
54
55     if A.cash: print A.name, hand_count
56     else     : print B.name, hand_count
57
58 for p in P: 
59     if p.brain: p.die() # Kill the players!
60
61
62
63