How to use my_action method in Sure

Best Python code snippet using sure_python

basebot8.py

Source:basebot8.py Github

copy

Full Screen

1from pokerbots.engine.game import Raise, Check, Call, Bet, Fold2from pokerbots.player.ourbot import CHECK, BET, RAISE, FOLD, CALL, DEAL, SHOW, WON, POST, PREFLOP, FLOP, TURN, RIVER, DEBUG3from random import randint4#class TheDerbs8(TheBostonDerby):5# def __init__(self):6# TheBostonDerby.__init__(self)7# self.name = "TheDerbs8"8# self.bot = basebot8()9class basebot8:10 def __init__(self):11 """This is a very simple player that demonstrates the API and is a good12 template for getting started13 """14 self.hand = None15 self.stack = None16 self.pip = None17 self.button = None18 self.opponent = None19 self.bb = None20 self.sb = None21 self.hands_played = None22 self.board = None23 self.legal = None24 self.actions = None25 self.last = None26 self.pot = None27 # my name28 self.name = "basebot"29 30 self.pfeq = 0 #value between 0 and 4 to indicate what range31 # our preflop equity was in. 0 = 0-20%, 1=20-40%, etc32 self.my_last_action = {'action':FOLD, 'first':False, 'reraise':False, 'street':PREFLOP, 'betfromaf':False, 'amount':0}33 34 self.eq_ranges = [20, 40, 50, 60]35 def parameterize(self, equity):36 #return min(int(equity*100)/20,4)37 ev = equity*10038 for i,eq in enumerate(self.eq_ranges):39 if ev < eq:40 return i41 return i+142 43 def hand_confidence(self,brain):44 stack_size = brain.stack + brain.pip45 brain.bound = stack_size46 if not brain.board.flop():47 if stack_size < 30*brain.bb:48 if brain.ev < .7: #if small stack, and not one of best hands49 brain.bound = 0 # fold50 else:51 brain.bound = -152 else:53 if brain.ev > .9:# or (brain.stats['pfhb'] > 0.25 and brain.hands_played > 12):54 brain.bound = stack_size55 elif brain.ev > .8:56 brain.bound = int(HIGH * stack_size)57 elif brain.ev > .5:58 brain.bound = 5 * brain.bb59 else:60 brain.bound = brain.bb61 else:62 if brain.ev < .33:63 brain.bound = min(int(max(brain.pot*brain.ev/(1-3*brain.ev),0)),stack_size)64 def respond(self, brain):65 """Based on your game state variables (see the __init__), make a66 decision and return an action. If you return an illegal action, the67 engine will automatically fold you68 """69 self.min_bet = max(2*brain.opponent['pip'],self.bb)70 if not brain.board.flop():71 self.pfeq = self.parameterize(brain.ev)72 my_action = self.preflop(brain)73 self.my_last_action['street'] = PREFLOP74 if DEBUG: print "taking action",my_action, "from the preflop"75 elif not brain.board.turn():76 my_action = self.flop(brain)77 self.my_last_action['street'] = FLOP78 if DEBUG: print "taking action",my_action, "from the flop"79 elif not brain.board.river():80 my_action = self.turn(brain)81 self.my_last_action['street'] = TURN82 if DEBUG: print "taking action",my_action, "from the turn"83 else:84 my_action = self.river(brain)85 self.my_last_action['street'] = RIVER86 if DEBUG: print "taking action",my_action, "from the river"87 88 # Check that our action is legal89 for action in brain.legal:90 if isinstance(action,type(my_action)):91 break92 else:93 if isinstance(my_action, Raise):94 for action in brain.legal:95 if isinstance(action,Call):96 my_action = Call()97 break98 else:99 my_action = None100 else:101 my_action = None102 # check fold if we selected no action103 if my_action == None:104 for action in brain.legal:105 if isinstance(action, Check):106 my_action = action107 break108 else:109 my_action = Fold()110 self.hand_confidence(brain)111 self.my_last_action['first'] = self.first112 action = brain.classify(my_action)113 if action in [RAISE,BET]:114 if brain.bound == -1:115 my_action.amount = brain.pip+brain.stack116 else:117 my_action.amount = int(min(my_action.amount, brain.bound))118 if my_action.amount < self.min_bet:119 for action in brain.legal:120 if isinstance(action, Call):121 my_action = action122 self.my_last_action['amount'] = brain.opponent['pip']123 break124 else:125 my_action = Check()126 127 else:128 self.my_last_action['amount'] = my_action.amount129 if isinstance(my_action, Call): #should we really call here?130 bet = brain.opponent['pip']131 if (bet-brain.pip)/float(brain.pot + 2*bet) >= brain.ev: #pot odds greater than ev, so fold132 my_action = Fold()133 #print "was going to call!"134 else:135 self.my_last_action['amount'] = brain.opponent['pip']136 self.my_last_action['action'] = brain.classify(my_action)137 if DEBUG: print "taking action",my_action138 return my_action139 140 def new_hand(self):141 self.my_last_action = {'action':FOLD, 'first':False, 'reraise':False, 'street':PREFLOP, 'betfromaf':False, 'amount':0}142 143 def preflop(self, brain):144 #it's preflop, tell me how to play145 last_act = brain.actions[-1]146 last_action = brain.classify(last_act[1])147 if DEBUG: print "opp last action was",last_act, "and pfeq is", self.pfeq148 if DEBUG: print "legal actions:", brain.legal149 self.first = last_action == POST150 stack_size = brain.pip+brain.stack151 my_action = None152 153 if self.pfeq == 0:154 if self.first:155 my_action = Call()156 if last_action == RAISE:157 my_action = Fold()158 else:159 my_action = Check()160 elif self.pfeq == 1:161 if self.first:162 my_action = Call()163 elif last_action == CALL:164 my_action = Raise(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size))) #low-mid165 elif last_action == RAISE:166 if self.my_last_action['action'] == CHECK or last_act[1].amount/float(stack_size) > brain.LOW: #TODO: this should be pot odds!167 my_action = Fold()168 else:169 my_action = Call()170 elif self.pfeq == 2:171 if self.first:172 my_action = Raise(brain.LOW*stack_size)173 elif last_action == CALL:174 my_action = Raise(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size))) #low to mid175 elif last_action == RAISE:176 if self.my_last_action['action'] == CHECK or last_act[1].amount/float(stack_size) > brain.MID:177 my_action = Fold()178 else:179 my_action = Call()180 elif self.pfeq == 3:181 if self.first:182 my_action = Raise(brain.LOW*stack_size)183 elif last_action == CALL:184 my_action = Raise(brain.MID*stack_size)185 elif last_action == RAISE:186 if self.my_last_action['action'] == CHECK or last_act[1].amount/float(stack_size) > brain.MID:187 my_action = Fold()188 else:189 my_action = Call()190 elif self.pfeq == 4:191 if self.first or last_action == RAISE:192 if self.my_last_action['action'] == RAISE:193 if self.my_last_action['reraise']:194 my_action = Raise(stack_size)195 else:196 my_action = Raise(self.min_bet)197 self.my_last_action['reraise'] = True198 else:199 my_action = Raise(brain.MID*stack_size)200 elif last_action == CALL:201 my_action = Raise(brain.LOW*stack_size)202 else:203 print "preflop: umm...", self.pfeq, brain.ev204 if DEBUG: print "and action",my_action205 return my_action206 207 def flop(self, brain):208 #it's the flop, tell me how to play209 last_act = brain.actions[-1]210 last_action = brain.classify(last_act[1])211 if DEBUG: print "opp last action was",last_act, "and pfeq is", self.pfeq212 if DEBUG: print "legal actions:", brain.legal213 self.first = last_action == DEAL214 stack_size = brain.pip+brain.stack215 my_action = None216 eq = self.parameterize(brain.ev)217 if self.pfeq == 0:218 if eq == 0:219 if self.first or last_action == CHECK:220 my_action = Check()221 elif last_action in [BET, RAISE]:222 my_action = Fold()223 elif eq == 1:224 if self.first:225 if randint(0,99) < 50:226 my_action = Check()227 else:228 my_action = Bet(self.min_bet)229 elif last_action == CHECK:230 my_action = Check()231 elif last_action in [BET, RAISE]:232 if last_act[1].amount/float(stack_size) <= brain.LOW:233 my_action = Call()234 else:235 my_action = Fold()236 elif eq == 2:237 if brain.opp_stats['AF'] < .5:238 for action in brain.legal:239 if isinstance(action,Raise) or isinstance(action,Bet):240 my_action = action241 self.my_last_action['betfromaf'] = True242 break243 elif self.first:244 my_action = Bet(brain.LOW*stack_size)245 elif last_action == CHECK:246 if randint(0,99) < 50:247 my_action = Check()248 else:249 my_action = Bet(brain.LOW*stack_size)250 elif last_action == BET:251 if last_act[1].amount/float(stack_size) <= brain.LOW:252 my_action = Call()253 else:254 my_action = Fold()255 elif last_action == RAISE:256 if self.my_last_action['first']:257 if last_act[1].amount/float(stack_size) <= brain.LOW:258 my_act = Call()259 elif last_act[1].amount/float(stack_size) <= brain.HIGH:260 if brain.opp_stats['INCR'] < .2 : #or brain.opp_stats['CHBR'] < .4261 my_action = Fold()262 else:263 my_action = Call()264 else:265 my_action = Fold()266 elif self.my_last_action['betfromaf']:267 my_action = Fold()268 elif self.my_last_action['action'] == BET:269 if last_act[1].amount == 2*self.my_last_action['amount']:270 my_action = Call()271 else:272 my_action = Fold()273 elif eq == 3:274 if self.first or last_action == CHECK:275 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size))) #low-mid276 elif last_action == BET:277 if last_act[1].amount/float(stack_size) <= brain.MID:278 my_action = Call()279 else:280 my_action = Fold()281 elif last_action == RAISE:282 if self.my_last_action['first']:283 if last_act[1].amount/float(stack_size) <= brain.MID:284 my_action = Call()285 else:286 my_action = Fold()287 else: #then I must have bet288 if last_act[1].amount == 2*self.my_last_action['amount']:289 my_action = Call()290 else:291 my_action = Fold()292 elif eq == 4:293 if self.first:294 my_action = Bet(randint(int(brain.MID*stack_size),int(brain.HIGH*stack_size))) #mid_high295 elif last_action == CHECK:296 my_action = Bet(int(brain.LOW*stack_size))297 elif last_action == BET:298 my_action = Raise(int(brain.MID*stack_size))299 elif last_action == RAISE:300 if self.my_last_action['first']:301 if last_act[1].amount/float(stack_size) <= brain.MID:302 my_action = Call()303 else:304 my_action = Raise(stack_size)305 elif self.my_last_action['action'] == BET:306 my_action = Raise(int(brain.MID*stack_size))307 elif self.my_last_action['action'] == RAISE:308 my_action = Raise(stack_size)309 elif self.pfeq == 1:310 if eq == 0:311 if self.first or last_action == CHECK:312 my_action = Check()313 elif last_action in [BET, RAISE]:314 my_action = Fold()315 elif eq == 1:316 if self.first:317 if randint(0,99) < 50:318 my_action = Check()319 else:320 my_action = Bet(randint(self.min_bet,int(brain.LOW*stack_size)))321 elif last_action == CHECK:322 my_action = Check()323 elif last_action in [BET, RAISE]:324 if last_act[1].amount/float(stack_size) <= brain.LOW:325 my_action = Call()326 else:327 my_action = Fold()328 elif eq == 2:329 if brain.opp_stats['AF'] < .5:330 for action in brain.legal:331 if isinstance(action,Raise) or isinstance(action,Bet):332 my_action = action333 self.my_last_action['betfromaf'] = True334 break335 elif self.first:336 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))337 elif last_action == CHECK:338 if randint(0,99) < 50:339 my_action = Check()340 else:341 my_action = Bet(brain.LOW*stack_size)342 elif last_action == BET:343 if last_act[1].amount/float(stack_size) <= brain.MID:344 my_action = Call()345 else:346 my_action = Fold()347 elif last_action == RAISE:348 if self.my_last_action['first']:349 if last_act[1].amount/float(stack_size) <= brain.LOW:350 my_act = Call()351 elif last_act[1].amount/float(stack_size) <= brain.HIGH:352 if brain.opp_stats['INCR'] < .2 : #or brain.opp_stats['CHBR'] < .4353 my_action = Fold()354 else:355 my_action = Call()356 else:357 my_action = Fold()358 elif self.my_last_action['betfromaf']:359 if last_act[1].amount/float(stack_size) <= brain.LOW:360 my_act = Call()361 else:362 my_action = Fold()363 elif self.my_last_action['action'] == BET:364 if last_act[1].amount/float(stack_size) <= brain.MID:365 my_action = Call()366 else:367 my_action = Fold()368 elif eq == 3:369 if self.first or last_action == CHECK:370 my_action = Bet(int(brain.MID*stack_size))371 elif last_action == BET:372 if last_act[1].amount/float(stack_size) <= brain.LOW:373 my_action = Raise(int(brain.MID*stack_size))374 elif last_act[1].amount/float(stack_size) <= brain.HIGH:375 my_action = Call()376 else:377 my_action = Fold()378 elif last_action == RAISE:379 if self.my_last_action['first']:380 if last_act[1].amount/float(stack_size) <= brain.MID:381 my_action = Call()382 else:383 my_action = Fold()384 else: #then I must have bet385 if last_act[1].amount == 2*self.my_last_action['amount']:386 my_action = Call()387 else:388 my_action = Fold()389 elif eq == 4:390 if self.first:391 my_action = Bet(randint(int(brain.MID*stack_size),int(brain.HIGH*stack_size))) #mid_high392 elif last_action == CHECK:393 my_action = Bet(int(brain.LOW*stack_size))394 elif last_action == BET:395 my_action = Raise(int(brain.MID*stack_size))396 elif last_action == RAISE:397 if self.my_last_action['first']:398 if last_act[1].amount/float(stack_size) <= brain.MID:399 my_action = Call()400 else:401 my_action = Raise(stack_size)402 elif self.my_last_action['action'] == BET:403 my_action = Raise(int(brain.MID*stack_size))404 elif self.my_last_action['action'] == RAISE:405 my_action = Raise(stack_size)406 elif self.pfeq == 2:407 if eq == 0:408 if self.first:409 if brain.opp_stats['AF'] < .5:410 my_action = Bet(int(brain.MID*stack_size))411 else:412 my_action = Check()413 elif last_action == CHECK:414 my_action = Bet(brain.MID*stack_size)415 elif last_action in [BET, RAISE]:416 my_action = Fold()417 elif eq == 1:418 if self.first:419 if randint(0,99) < 50:420 my_action = Check()421 else:422 my_action = Bet(randint(self.min_bet,int(brain.LOW*stack_size)))423 elif last_action == CHECK:424 my_action = Check()425 elif last_action == BET:426 if last_act[1].amount/float(stack_size) <= brain.MID:427 my_action = Call()428 else:429 my_action = Fold()430 elif last_action == RAISE:431 if last_act[1].amount/float(stack_size) <= brain.LOW:432 my_action = Call()433 else:434 my_action = Fold()435 elif eq == 2:436 if self.first:437 if brain.opp_stats['AF'] < .5:438 my_action = Bet(int(brain.MID*stack_size))439 self.my_last_action['betfromaf'] = True440 else:441 my_action = Check()442 elif last_action == CHECK:443 my_action = Check()444 elif last_action == BET:445 if last_act[1].amount/float(stack_size) <= brain.MID:446 my_action = Call()447 else:448 my_action = Fold()449 elif last_action == RAISE:450 if last_act[1].amount/float(stack_size) <= brain.LOW:451 my_action = Call()452 else:453 my_action = Fold()454 elif eq == 3:455 if self.first or last_action == Check:456 my_action = Bet(int(brain.MID*stack_size))457 elif last_action == BET:458 if last_act[1].amount/float(stack_size) <= brain.LOW:459 my_action = Raise(int(brain.MID*stack_size))460 elif last_act[1].amount/float(stack_size) <= brain.HIGH:461 my_action = Call()462 else:463 my_action = Fold()464 elif last_action == RAISE:465 if self.my_last_action['first']:466 if last_act[1].amount/float(stack_size) <= brain.HIGH:467 my_action = Call()468 else:469 my_action = Fold()470 elif self.my_last_action['action'] == BET:471 if last_act[1].amount == 2*self.my_last_action['amount']:472 my_action = Call()473 else:474 my_action = Fold()475 else:476 my_action == Call()477 elif eq == 4:478 if self.first:479 my_action = Bet(randint(int(brain.MID*stack_size),int(brain.HIGH*stack_size)))480 elif last_action == CHECK:481 my_action = Bet(int(brain.MID*stack_size))482 elif last_action == BET:483 my_action = Raise(int(brain.MID*stack_size))484 elif last_action == RAISE:485 if self.my_last_action['first']:486 if last_act[1].amount/float(stack_size) <= brain.MID:487 my_action = Call()488 else:489 my_action = Raise(stack_size)490 elif self.my_last_action['action'] == RAISE:491 my_action = Raise(stack_size)492 else:493 my_action = Raise(int(brain.MID*stack_size))494 elif self.pfeq == 3:495 if eq == 0:496 if self.first:497 if brain.opp_stats['AF'] < .5:498 my_action = Bet(int(brain.MID*stack_size))499 else:500 my_action = Check()501 elif last_action == CHECK:502 my_action = Bet(int(brain.MID*stack_size))503 elif last_action == BET:504 if last_act[1].amount/float(stack_size) <= brain.LOW:505 my_action = Call()506 else:507 my_action = Fold()508 elif last_action == RAISE:509 my_action = Fold()510 elif eq == 1:511 if self.first:512 if randint(0,99) < 50:513 my_action = Check()514 else:515 my_action = Bet(randint(self.min_bet,int(brain.LOW*stack_size)))516 elif last_action == CHECK:517 my_action = Bet(int(brain.LOW*stack_size))518 elif last_action == BET:519 if last_act[1].amount/float(stack_size) <= brain.MID:520 my_action = Call()521 else:522 my_action = Fold()523 elif last_action == RAISE:524 if last_act[1].amount/float(stack_size) <= brain.LOW:525 my_action = Call()526 else:527 my_action = Fold()528 elif eq == 2:529 if self.first:530 if brain.opp_stats['AF'] < .5:531 my_action = Bet(int(brain.MID*stack_size))532 self.my_last_action['betfromaf'] = True533 else:534 my_action = Bet(int(brain.LOW*stack_size))535 elif last_action == CHECK:536 my_action = Check()537 elif last_action == BET:538 if last_act[1].amount/float(stack_size) <= brain.MID:539 my_action = Call()540 else:541 my_action = Fold()542 elif last_action == RAISE:543 if last_act[1].amount/float(stack_size) <= brain.MID:544 my_action = Call()545 else:546 my_action = Fold()547 elif eq == 3:548 if self.first or last_action == Check:549 my_action = Bet(int(brain.MID*stack_size))550 elif last_action == BET:551 if last_act[1].amount/float(stack_size) <= brain.LOW:552 my_action = Raise(int(brain.MID*stack_size))553 elif last_act[1].amount/float(stack_size) <= brain.HIGH:554 my_action = Call()555 else:556 my_action = Fold()557 elif last_action == RAISE:558 if self.my_last_action['first']:559 if last_act[1].amount/float(stack_size) <= brain.MID:560 my_action = Raise(self.min_bet)561 elif last_act[1].amount/float(stack_size) <= brain.HIGH:562 my_action = Call()563 else:564 my_action = Fold()565 elif self.my_last_action['action'] == BET:566 if last_act[1].amount == 2*self.my_last_action['amount']:567 my_action = Call()568 else:569 my_action = Fold()570 else:571 my_action = Call()572 elif eq == 4:573 if self.first:574 my_action = Check()575 elif last_action == CHECK:576 my_action = Bet(int(brain.LOW*stack_size))577 elif last_action == BET:578 my_action = Call()579 elif last_action == RAISE:580 if self.my_last_action['first']:581 if last_act[1].amount/float(stack_size) <= brain.MID:582 my_action = Call()583 else:584 my_action = Raise(stack_size)585 elif self.my_last_action['action'] == BET:586 my_action = Raise(int(brain.MID*stack_size))587 elif self.my_last_action['action'] == RAISE:588 my_action = Raise(stack_size)589 elif self.pfeq == 4:590 if eq == 0:591 if self.first or last_action == CHECK:592 my_action = Check()593 elif last_action in [BET, RAISE]:594 my_action = Fold()595 elif eq == 1:596 if self.first or last_action == CHECK:597 my_action = Bet(int(brain.MID*stack_size))598 elif last_action == BET:599 if last_act[1].amount/float(stack_size) <= brain.LOW:600 my_action = Call()601 else:602 my_action = Fold()603 elif last_action == RAISE:604 if last_act[1].amount == 2*self.my_last_action['amount']:605 my_action = Call()606 else:607 my_action = Fold()608 elif eq == 2:609 if self.first or last_action == CHECK:610 my_action = Bet(int(brain.MID*stack_size))611 elif last_action == BET:612 if last_act[1].amount/float(stack_size) <= brain.MID:613 my_action = Raise(int(brain.MID*stack_size))614 elif last_act[1].amount/float(stack_size) <= brain.HIGH:615 my_action = Call()616 else:617 my_action = Fold()618 elif last_action == RAISE:619 if self.my_last_action['first']:620 if last_act[1].amount/float(stack_size) <= brain.MID:621 my_action = Raise(self.min_bet)622 self.my_last_action['reraise'] = True623 else:624 my_action = Fold()625 elif self.my_last_action['action'] == BET:626 if last_act[1].amount/float(stack_size) <= brain.LOW:627 my_action = Call()628 else:629 my_action = Fold()630 elif self.my_last_action['reraise']:631 if last_act[1].amount/float(stack_size) <= brain.MID:632 my_action = Call()633 else:634 my_action = Fold()635 else:636 my_action = Call()637 elif eq == 3:638 if self.first:639 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))640 elif last_action == CHECK:641 my_action = Bet(int(brain.MID*stack_size))642 elif last_action == BET:643 if last_act[1].amount/float(stack_size) <= brain.MID:644 my_action = Raise(2*self.min_bet)645 elif last_act[1].amount/float(stack_size) <= brain.HIGH:646 my_action = Call()647 else:648 my_action = Fold()649 elif last_action == RAISE:650 if self.my_last_action['first']:651 if last_act[1].amount/float(stack_size) <= brain.HIGH:652 my_action = Call()653 else:654 my_action = Fold()655 elif self.my_last_action['action'] == BET:656 if last_act[1].amount == 2*self.my_last_action['amount']:657 my_action = Call()658 else:659 my_action = Fold()660 else:661 my_action = Call()662 elif eq == 4:663 if self.first:664 my_action = Bet(randint(int(brain.MID*stack_size),int(brain.HIGH*stack_size)))665 elif last_action == CHECK:666 my_action = Bet(int(brain.LOW*stack_size))667 elif last_action == BET:668 my_action = Raise(int(brain.MID*stack_size))669 elif last_action == RAISE:670 if self.my_last_action['first']:671 if last_act[1].amount/float(stack_size) <= brain.MID:672 my_action = Call()673 else:674 my_action = Raise(stack_size)675 elif self.my_last_action['action'] == BET:676 my_action = Raise(int(brain.MID*stack_size))677 else:678 my_action = Raise(stack_size)679 else:680 print "flop: umm...", self.pfeq, brain.ev681 return my_action682 def turn(self, brain):683 #it's the turn, tell me how to play684 last_act = brain.actions[-1]685 last_action = brain.classify(last_act[1])686 if DEBUG: print "opp last action was",last_act, "and pfeq is", self.pfeq687 if DEBUG: print "legal actions:", brain.legal688 self.first = last_action == DEAL689 stack_size = brain.pip+brain.stack690 my_action = None691 eq = self.parameterize(brain.ev)692 if self.pfeq == 0:693 if eq == 0:694 if self.first:695 return Check()696 elif last_action == BET:697 if last_act[1].amount == 2*self.my_last_action['amount']:698 my_action = Call()699 else:700 my_action = Fold()701 elif last_action == CHECK:702 #ignoring condition on previous betting703 if randint(0,99) < 50:704 my_action = Check()705 else:706 my_action = Bet(brain.MID*stack_size)707 elif last_action == RAISE:708 my_action = Fold()709 elif eq == 1:710 if brain.opp_stats['AF'] < .5:711 for action in brain.legal:712 if isinstance(action,Raise):713 my_action = Raise(brain.MID*stack_size)714 self.my_last_action['betfromaf'] = True715 break716 elif isinstance(action,Bet):717 my_action = Bet(brain.MID*stack_size)718 self.my_last_action['betfromaf'] = True719 break720 elif self.first:721 if randint(0,99) < 50:722 my_action = Check()723 else:724 my_action = Bet(randint(self.min_bet,int(brain.LOW*stack_size)))725 elif last_action == CHECK:726 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))727 elif last_action == BET:728 if last_act[1].amount/float(stack_size) <= brain.LOW:729 my_action = Call()730 else:731 my_action = Fold()732 elif last_action == RAISE:733 if self.my_last_action['first']:734 if last_act[1].amount == 2*self.my_last_action['amount']:735 my_action = Call()736 else:737 my_action = Fold()738 else:739 my_action = Fold()740 elif eq == 2:741 if brain.opp_stats['AF'] < .5:742 for action in brain.legal:743 if isinstance(action,Raise):744 my_action = Raise(brain.MID*stack_size)745 self.my_last_action['betfromaf'] = True746 break747 elif isinstance(action,Bet):748 my_action = Bet(brain.MID*stack_size)749 self.my_last_action['betfromaf'] = True750 break751 elif self.first:752 my_action = Bet(brain.LOW*stack_size)753 elif last_action == CHECK:754 if randint(0,99) < 50:755 my_action = Check()756 else:757 my_action = Bet(brain.LOW*stack_size)758 elif last_action == BET:759 if last_act[1].amount/float(stack_size) <= brain.LOW:760 my_action = Call()761 elif last_act[1].amount/float(stack_size) <= brain.MID:762 if brain.opp_stats['AF'] > 1.5:763 my_action = Call()764 else:765 my_action = Fold()766 else:767 my_action = Fold()768 elif last_action == RAISE:769 if self.my_last_action['first']:770 if last_act[1].amount/float(stack_size) <= brain.LOW:771 my_action = Call()772 elif last_act[1].amount/float(stack_size) <= brain.MID:773 if brain.opp_stats['INCR'] < .2 : #or brain.opp_stats['CHBR'] < .4 or this is a continutation bet774 my_action = Fold()775 else:776 my_action = Call()777 else:778 my_action = Fold()779 elif self.my_last_action['betfromaf']:780 my_action = Fold()781 elif eq == 3:782 if self.first or last_action == CHECK:783 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))784 elif last_action == BET:785 if last_act[1].amount/float(stack_size) <= brain.MID:786 my_action = Call()787 else:788 my_action = Fold()789 elif last_action == RAISE:790 if self.my_last_action['first']:791 if brain.opp_stats['AF'] < .5:792 my_action = Fold()793 else:794 if last_act[1].amount/float(stack_size) <= brain.MID:795 my_action = Call()796 else:797 my_action = Fold()798 elif self.my_last_action['action'] == BET:799 #if opp never bet/raised: fold800 my_action = Call()801 elif eq == 4:802 if self.first:803 my_action = Bet(randint(int(brain.MID*stack_size),int(brain.HIGH*stack_size)))804 elif last_action == CHECK:805 my_action = Bet(brain.LOW*stack_size)806 elif last_action == BET:807 my_action = Bet(brain.MID*stack_size)808 elif last_action == RAISE:809 if self.my_last_action['first']:810 if last_act[1].amount/float(stack_size) <= brain.MID:811 my_action = Call()812 else:813 my_action = Raise(stack_size)814 elif self.my_last_action['action'] == BET:815 my_action = Raise(brain.MID*stack_size)816 elif self.my_last_action['action'] == RAISE:817 my_action = Raise(stack_size)818 elif self.pfeq == 1:819 if eq == 0:820 if self.first:821 return Check()822 elif last_action == BET:823 if last_act[1].amount == 2*self.my_last_action['amount']:824 my_action = Call()825 else:826 my_action = Fold()827 elif last_action == CHECK:828 #ignoring condition on previous betting829 if randint(0,99) < 50:830 my_action = Check()831 else:832 my_action = Bet(brain.MID*stack_size)833 elif last_action == RAISE:834 my_action = Fold()835 elif eq == 1:836 if self.first:837 if brain.opp_stats['AF'] < .5:838 for action in brain.legal:839 if isinstance(action,Raise):840 my_action = Raise(brain.MID*stack_size)841 self.my_last_action['betfromaf'] = True842 break843 elif isinstance(action,Bet):844 my_action = Bet(brain.MID*stack_size)845 self.my_last_action['betfromaf'] = True846 break847 else:848 if randint(0,99) < 50:849 my_action = Check()850 else:851 my_action = Bet(randint(self.min_bet,int(brain.LOW*stack_size)))852 elif last_action == CHECK:853 my_action = Check()854 elif last_action == BET:855 if last_act[1].amount/float(stack_size) <= brain.LOW:856 my_action = Call()857 else:858 my_action = Fold()859 elif eq == 2:860 if self.first:861 if brain.opp_stats['AF'] < .5:862 for action in brain.legal:863 if isinstance(action,Raise):864 my_action = Raise(brain.MID*stack_size)865 self.my_last_action['betfromaf'] = True866 break867 elif isinstance(action,Bet):868 my_action = Bet(brain.MID*stack_size)869 self.my_last_action['betfromaf'] = True870 break871 else:872 my_action = Bet(brain.LOW*stack_size)873 elif last_action == CHECK:874 if randint(0,99) < 50:875 my_action = Check()876 else:877 my_action = Bet(brain.LOW*stack_size)878 elif last_action == BET:879 if last_act[1].amount/float(stack_size) <= brain.LOW:880 my_action = Call()881 elif last_act[1].amount/float(stack_size) <= brain.MID:882 if brain.opp_stats['AF'] > 1.5:883 my_action = Call()884 else:885 my_action = Fold()886 else:887 my_action = Fold()888 elif last_action == RAISE:889 if self.my_last_action['first']:890 if self.my_last_action['betfromaf']:891 if last_act[1].amount/float(stack_size) <= brain.MID:892 my_action = Call()893 else:894 my_action = Fold()895 else:896 if last_act[1].amount/float(stack_size) <= brain.LOW:897 my_action = Call()898 elif last_act[1].amount/float(stack_size) <= brain.HIGH:899 if brain.opp_stats['INCR'] < .2 : #or brain.opp_stats['CHBR'] < .4 or this is a continutation bet900 my_action = Fold()901 else:902 my_action = Call()903 else:904 my_action = Fold()905 elif self.my_last_action['action'] == BET:906 if last_act[1].amount == 2*self.my_last_action['amount']:907 my_action = Call()908 else:909 my_action = Fold()910 elif eq == 3:911 if self.first:912 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))913 elif last_action == CHECK:914 if stack_size > 1.7*400:915 my_action = Bet(stack_size)916 else:917 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))918 elif last_action == BET:919 if last_act[1].amount/float(stack_size) <= brain.MID:920 my_action = Call()921 elif last_act[1].amount/float(stack_size) <= brain.HIGH:922 if randint(0,99) < 50:923 my_action = Call()924 else:925 my_action = Fold()926 else:927 my_action = Fold()928 elif last_action == RAISE:929 if self.my_last_action['first']:930 if brain.opp_stats['AF'] < .5:931 my_action = Fold()932 else:933 if last_act[1].amount/float(stack_size) <= brain.MID:934 my_action = Call()935 else:936 my_action = Fold()937 else:938 #if opp has not raised/bet this hand: fold939 my_action = Call()940 elif eq == 4:941 if self.first:942 my_action = Bet(randint(int(brain.MID*stack_size),int(brain.HIGH*stack_size)))943 elif last_action == CHECK:944 my_action = Bet(brain.LOW*stack_size)945 elif last_action == BET:946 my_action = Raise(brain.MID*stack_size)947 elif last_action == RAISE:948 if self.my_last_action['first']:949 if last_act[1].amount/float(stack_size) <= brain.MID:950 my_action = Call()951 else:952 my_action = Raise(stack_size)953 elif self.my_last_action['action'] == BET:954 my_action = Raise(brain.MID*stack_size)955 elif self.my_last_action['action'] == RAISE:956 my_action = Raise(stack_size)957 elif self.pfeq == 2:958 if eq == 0:959 if self.first:960 my_action = Check()961 elif last_action == CHECK:962 if randint(0,99) < 50:963 my_action = Bet(brain.MID*stack_size)964 else:965 my_action = Check()966 elif last_action == BET:967 if last_act[1].amount == 2*self.my_last_action['amount']:968 my_action = Call()969 else:970 my_action = Fold()971 elif last_action == RAISE:972 my_action = Fold()973 elif eq == 1:974 if self.first:975 if brain.opp_stats['AF'] < .5:976 for action in brain.legal:977 if isinstance(action,Raise):978 my_action = Raise(brain.MID*stack_size)979 self.my_last_action['betfromaf'] = True980 break981 elif isinstance(action,Bet):982 my_action = Bet(brain.MID*stack_size)983 self.my_last_action['betfromaf'] = True984 break985 else:986 if randint(0,99) < 50:987 my_action = Check()988 else:989 my_action = Bet(randint(self.min_bet,int(brain.LOW*stack_size)))990 elif last_action == CHECK:991 my_action = Check()992 elif last_action == BET:993 if last_act[1].amount/float(stack_size) <= brain.LOW:994 my_action = Call()995 elif last_act[1].amount/float(stack_size) <= brain.MID:996 if randint(0,99) < 50:997 my_action = Call()998 else:999 my_action = Fold()1000 else:1001 my_action = Fold()1002 elif last_action == RAISE:1003 if self.my_last_action['first']:1004 if self.my_last_action['betfromaf']:1005 my_action = Fold()1006 else:1007 if last_act[1].amount/float(stack_size) <= brain.LOW:1008 my_action = Call()1009 else:1010 my_action = Fold()1011 elif eq == 2:1012 if self.first:1013 my_action = Bet(brain.MID*stack_size)1014 elif last_action == CHECK:1015 my_action = Check()1016 elif last_action == BET:1017 if last_act[1].amount/float(stack_size) <= brain.LOW:1018 my_action = Call()1019 elif last_act[1].amount/float(stack_size) <= brain.MID:1020 if brain.opp_stats['AF'] > 1.5:1021 my_action = Call()1022 else:1023 my_action = Fold()1024 else:1025 my_action = Fold()1026 elif last_action == RAISE:1027 if self.my_last_action['first']:1028 if last_act[1].amount/float(stack_size) <= brain.LOW:1029 my_action = Call()1030 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1031 if brain.opp_stats['INCR'] < .2 : #or brain.opp_stats['CHBR'] < .4 or this is a continutation bet1032 my_action = Fold()1033 else:1034 my_action = Call()1035 else:1036 my_action = Fold()1037 elif eq == 3:1038 if self.first:1039 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))1040 elif last_action == CHECK:1041 if stack_size > 1.7*400:1042 my_action = Bet(stack_size)1043 else:1044 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))1045 elif last_action == BET:1046 if last_act[1].amount/float(stack_size) <= brain.MID:1047 my_action = Call()1048 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1049 if randint(0,99) < 50:1050 my_action = Call()1051 else:1052 my_action = Fold()1053 else:1054 my_action = Fold()1055 elif last_action == RAISE:1056 if self.my_last_action['first']:1057 if brain.opp_stats['AF'] < .5:1058 my_action = Fold()1059 else:1060 if last_act[1].amount/float(stack_size) <= brain.MID:1061 my_action = Call()1062 else:1063 my_action = Fold()1064 elif self.my_last_action['action'] == BET:1065 #if opp has not raised/bet this hand: fold1066 if last_act[1].amount/float(stack_size) <= brain.MID:1067 my_action = Call()1068 else:1069 my_action = Fold()1070 elif eq == 4:1071 if self.first:1072 my_action = Bet(randint(int(brain.MID*stack_size),int(brain.HIGH*stack_size)))1073 elif last_action == CHECK:1074 my_action = Bet(brain.LOW*stack_size)1075 elif last_action == BET:1076 my_action = Raise(brain.MID*stack_size)1077 elif last_action == RAISE:1078 if self.my_last_action['first']:1079 if last_act[1].amount/float(stack_size) <= brain.MID:1080 my_action = Call()1081 else:1082 my_action = Raise(stack_size)1083 elif self.my_last_action['action'] == BET:1084 my_action = Raise(brain.MID*stack_size)1085 elif self.my_last_action['action'] == RAISE:1086 my_action = Raise(stack_size)1087 elif self.pfeq == 3:1088 if eq == 0:1089 if self.first:1090 my_action = Bet(brain.MID*stack_size)1091 elif last_action == CHECK:1092 if randint(0,99) < 50:1093 my_action = Bet(brain.MID*stack_size)1094 else:1095 my_action = Check()1096 elif last_action == BET:1097 if last_act[1].amount == 2*self.my_last_action['amount']:1098 my_action = Call()1099 else:1100 my_action = Fold()1101 elif last_action == RAISE:1102 if self.my_last_action['first']:1103 if last_act[1].amount/float(stack_size) <= brain.LOW:1104 my_action = Call()1105 else:1106 my_action = Fold()1107 elif self.my_last_action['action'] == BET:1108 my_action = Fold()1109 elif eq == 1:1110 if self.first:1111 if brain.opp_stats['AF'] < .5:1112 for action in brain.legal:1113 if isinstance(action,Raise):1114 my_action = Raise(brain.MID*stack_size)1115 self.my_last_action['betfromaf'] = True1116 break1117 elif isinstance(action,Bet):1118 my_action = Bet(brain.MID*stack_size)1119 self.my_last_action['betfromaf'] = True1120 break1121 else:1122 if randint(0,99) < 50:1123 my_action = Check()1124 else:1125 my_action = Bet(brain.LOW*stack_size)1126 elif last_action == CHECK:1127 my_action = Bet(brain.MID*stack_size)1128 elif last_action == BET:1129 if last_act[1].amount/float(stack_size) <= brain.LOW:1130 my_action = Call()1131 else:1132 my_action = Fold()1133 elif last_action == RAISE:1134 if self.my_last_action['first']:1135 if self.my_last_action['betfromaf']:1136 my_action = Fold()1137 else:1138 if last_act[1].amount/float(stack_size) <= brain.LOW:1139 my_action = Call()1140 else:1141 my_action = Fold()1142 elif self.my_last_action['action'] == BET:1143 if last_act[1].amount/float(stack_size) <= brain.LOW:1144 my_action = Call()1145 else:1146 my_action = Fold()1147 elif eq == 2:1148 if self.first:1149 if stack_size <= .6 * 400:1150 my_action = Check()1151 else:1152 my_action = Bet(brain.MID*stack_size)1153 elif last_action == CHECK:1154 my_action = Bet(brain.MID*stack_size)1155 elif last_action == BET:1156 if last_act[1].amount/float(stack_size) <= brain.LOW:1157 my_action = Raise(brain.MID*stack_size)1158 elif last_act[1].amount/float(stack_size) <= brain.MID:1159 if brain.opp_stats['AF'] < .5:1160 my_action = Call()1161 else:1162 my_action = Fold()1163 else:1164 my_action = Fold()1165 elif last_action == RAISE:1166 if self.my_last_action['first']:1167 if last_act[1].amount/float(stack_size) <= brain.LOW:1168 my_action = Call()1169 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1170 if brain.opp_stats['INCR'] < .2 : #or brain.opp_stats['CHBR'] < .4 or this is a continutation bet1171 my_action = Fold()1172 else:1173 my_action = Call()1174 else:1175 my_action = Fold()1176 elif self.my_last_action['action'] == BET:1177 if last_act[1].amount/float(stack_size) <= brain.LOW:1178 my_action = Call()1179 elif last_act[1].amount/float(stack_size) <= brain.MID:1180 if stack_size <= .6 * 400:1181 my_action = Fold()1182 else:1183 my_action = Call()1184 else:1185 my_action = Fold()1186 elif eq == 3:1187 if self.first:1188 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))1189 elif last_action == CHECK:1190 if stack_size > 1.7*400:1191 my_action = Bet(stack_size)1192 else:1193 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))1194 elif last_action == BET:1195 if last_act[1].amount/float(stack_size) <= brain.MID:1196 my_action = Raise(brain.HIGH*stack_size)1197 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1198 my_action = Call()1199 else:1200 my_action = Fold()1201 elif last_action == RAISE:1202 if self.my_last_action['first']:1203 if last_act[1].amount/float(stack_size) <= brain.MID:1204 my_action = Call()1205 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1206 if brain.opp_stats['AF'] < .5:1207 my_action = Fold()1208 else:1209 my_action = Call()1210 else:1211 my_action = Fold()1212 elif self.my_last_action['action'] == BET:1213 #if opp has not raised/bet this hand: fold1214 if last_act[1].amount/float(stack_size) <= brain.MID:1215 my_action = Call()1216 else:1217 my_action = Fold()1218 elif self.my_last_action['action'] == RAISE: 1219 my_action = Call()1220 elif eq == 4:1221 if self.first:1222 my_action = Bet(randint(int(brain.MID*stack_size),int(brain.HIGH*stack_size)))1223 elif last_action == CHECK:1224 my_action = Bet(brain.LOW*stack_size)1225 elif last_action == BET:1226 my_action = Raise(brain.MID*stack_size)1227 elif last_action == RAISE:1228 if self.my_last_action['first']:1229 if last_act[1].amount/float(stack_size) <= brain.MID:1230 my_action = Call()1231 else:1232 my_action = Raise(stack_size)1233 elif self.my_last_action['action'] == BET:1234 my_action = Raise(brain.MID*stack_size)1235 elif self.my_last_action['action'] == RAISE:1236 my_action = Raise(stack_size)1237 elif self.pfeq == 4:1238 if eq == 0:1239 if self.first or last_action == CHECK:1240 my_action = Check()1241 elif last_action == BET:1242 if last_act[1].amount/float(stack_size) <= brain.LOW:1243 my_action = Call()1244 else:1245 my_action = Fold()1246 elif eq == 1:1247 if self.first:1248 if brain.opp_stats['AF'] < .5:1249 for action in brain.legal:1250 if isinstance(action,Raise):1251 my_action = Raise(brain.MID*stack_size)1252 self.my_last_action['betfromaf'] = True1253 break1254 elif isinstance(action,Bet):1255 my_action = Bet(brain.MID*stack_size)1256 self.my_last_action['betfromaf'] = True1257 break1258 else:1259 if randint(0,99) < 50:1260 my_action = Check()1261 else:1262 my_action = Bet(randint(int(self.min_bet),int(brain.LOW*stack_size)))1263 elif last_action == CHECK:1264 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))1265 elif last_action == BET:1266 if last_act[1].amount/float(stack_size) <= brain.LOW:1267 my_action = Call()1268 else:1269 my_action = Fold()1270 elif last_action == RAISE:1271 if self.my_last_action['first']:1272 if self.my_last_action['betfromaf']:1273 my_action = Fold()1274 else:1275 if last_act[1].amount/float(stack_size) <= brain.LOW:1276 my_action = Call()1277 else:1278 my_action = Fold()1279 elif self.my_last_action['action'] == BET:1280 if last_act[1].amount/float(stack_size) <= brain.LOW:1281 my_action = Call()1282 else:1283 my_action = Fold()1284 elif eq == 2:1285 if self.first:1286 my_action = Bet(brain.MID*stack_size)1287 if brain.opp_stats['AF'] < .5:1288 self.my_last_action['betfromaf'] = True1289 elif last_action == CHECK:1290 if randint(0,99) < 50:1291 my_action = Check()1292 else:1293 my_action = Bet(brain.MID*stack_size)1294 elif last_action == BET:1295 if last_act[1].amount/float(stack_size) <= brain.MID:1296 my_action = Call()1297 else:1298 my_action = Fold()1299 elif last_action == RAISE:1300 if self.my_last_action['first']:1301 if self.my_last_action['betfromaf']:1302 if last_act[1].amount/float(stack_size) <= brain.MID:1303 my_action = Call()1304 else:1305 my_action = Fold()1306 else:1307 if last_act[1].amount/float(stack_size) <= brain.MID:1308 my_action = Call()1309 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1310 if brain.opp_stats['AF'] < .5:1311 my_action = Fold()1312 else:1313 my_action = Call()1314 else:1315 my_action = Fold()1316 elif self.my_last_action['action'] == BET:1317 if last_act[1].amount/float(stack_size) <= brain.LOW:1318 my_action = Call()1319 else:1320 my_action = Fold()1321 elif eq == 3:1322 if self.first:1323 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))1324 elif last_action == CHECK:1325 my_action = Bet(brain.MID*stack_size)1326 elif last_action == BET:1327 if last_act[1].amount/float(stack_size) <= brain.LOW:1328 my_action = Raise(brain.LOW*stack_size)1329 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1330 my_action = Call()1331 else:1332 my_action = Fold()1333 elif last_action == RAISE:1334 if self.my_last_action['first']:1335 if brain.opp_stats['AF'] < .5:1336 my_action = Fold()1337 elif last_act[1].amount/float(stack_size) <= brain.MID:1338 my_action = Call()1339 else:1340 my_action = Fold()1341 elif self.my_last_action['action'] == BET:1342 if last_act[1].amount/float(stack_size) <= brain.HIGH:1343 my_action = Call()1344 else:1345 my_action = Fold()1346 elif self.my_last_action['action'] == RAISE: 1347 my_action = Call()1348 elif eq == 4:1349 if self.first:1350 my_action = Bet(randint(int(brain.MID*stack_size),int(brain.HIGH*stack_size)))1351 elif last_action == CHECK:1352 my_action = Bet(brain.MID*stack_size)1353 elif last_action == BET:1354 my_action = Raise(brain.MID*stack_size)1355 elif last_action == RAISE:1356 if self.my_last_action['first']:1357 if last_act[1].amount/float(stack_size) <= brain.MID:1358 my_action = Call()1359 else:1360 my_action = Raise(stack_size)1361 elif self.my_last_action['action'] == BET:1362 my_action = Call()1363 elif self.my_last_action['action'] == RAISE:1364 my_action = Raise(stack_size)1365 else:1366 print "turn: umm...", self.pfeq, brain.ev1367 return my_action1368 def river(self, brain):1369 #it's the river, tell me how to play1370 last_act = brain.actions[-1]1371 last_action = brain.classify(last_act[1])1372 if DEBUG: print "opp last action was",last_act, "and pfeq is", self.pfeq1373 if DEBUG: print "legal actions:", brain.legal1374 self.first = last_action == DEAL1375 stack_size = brain.pip+brain.stack1376 my_action = None1377 eq = self.parameterize(brain.ev)1378 if eq == 2:1379 if self.first or last_action == CHECK:1380 my_action = Bet(brain.MID*stack_size)1381 elif last_action == BET:1382 if last_act[1].amount/float(stack_size) <= brain.MID:1383 my_action = Call()1384 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1385 if brain.opp_stats['AF'] > 1.5:1386 my_action = Call()1387 else:1388 my_action = Fold()1389 else:1390 my_action = Fold()1391 elif last_action == RAISE:1392 if self.my_last_action['action'] == BET:1393 if last_act[1].amount/float(stack_size) <= brain.LOW:1394 my_act = Call()1395 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1396 if brain.opp_stats['INCR'] < .2 : #or brain.opp_stats['CHBR'] < .4 or cb1397 my_action = Fold()1398 else:1399 my_action = Call()1400 else:1401 my_action = Fold()1402 elif eq == 3:1403 if self.first or last_action == CHECK:1404 my_action = Bet(brain.MID*stack_size)1405 elif last_action == BET:1406 if last_act[1].amount/float(stack_size) <= brain.MID:1407 my_action = Raise(brain.MID*stack_size)1408 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1409 #if opp never raised b4: fold1410 my_action = Call()1411 else:1412 my_action = Fold()1413 elif last_action == RAISE:1414 if self.my_last_action['first']:1415 if brain.opp_stats['AF'] < .5:1416 my_action = Fold()1417 else:1418 if last_act[1].amount/float(stack_size) <= brain.MID:1419 my_action = Call()1420 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1421 #if op never raised in this hand: Fold1422 my_action = Call()1423 else:1424 my_action = Fold()1425 if self.my_last_action['action'] == BET:1426 #if opp has not raised this hand: Fold1427 my_action = Call()1428 elif eq == 4:1429 if self.first:1430 if stack_size < 200 or stack_size > 600:1431 my_action = Bet(stack_size)1432 else:1433 if randint(0,99) < 50:1434 my_action = Bet(brain.HIGH*stack_size)1435 else:1436 my_action = Bet(brain.MID*stack_size)1437 elif last_action == CHECK:1438 my_action = Bet(brain.MID*stack_size)1439 elif last_action == BET:1440 my_action = Raise(brain.MID*stack_size)1441 elif last_action == RAISE:1442 my_action = Raise(stack_size)...

Full Screen

Full Screen

basebot.py

Source:basebot.py Github

copy

Full Screen

1from pokerbots.engine.game import Raise, Check, Call, Bet, Fold2from pokerbots.player.ourbot import CHECK, BET, RAISE, FOLD, CALL, DEAL, SHOW, WON, POST, PREFLOP, FLOP, TURN, RIVER, DEBUG3from random import randint4class BaseBot:5 def __init__(self):6 """This is a very simple player that demonstrates the API and is a good7 template for getting started8 """9 self.hand = None10 self.stack = None11 self.pip = None12 self.button = None13 self.opponent = None14 self.bb = None15 self.sb = None16 self.hands_played = None17 self.board = None18 self.legal = None19 self.actions = None20 self.last = None21 self.pot = None22 # my name23 self.name = "basebot"24 25 self.pfeq = 0 #value between 0 and 4 to indicate what range26 # our preflop equity was in. 0 = 0-20%, 1=20-40%, etc27 self.my_last_action = {'action':FOLD, 'first':False, 'reraise':False, 'street':PREFLOP, 'betfromaf':False, 'amount':0}28 29 self.eq_ranges = [20, 40, 50, 60]30 def parameterize(self, equity):31 #return min(int(equity*100)/20,4)32 ev = equity*10033 for i,eq in enumerate(self.eq_ranges):34 if ev < eq:35 return i36 return i+137 38 def respond(self, brain):39 """Based on your game state variables (see the __init__), make a40 decision and return an action. If you return an illegal action, the41 engine will automatically fold you42 """43 self.min_bet = max(2*brain.opponent['pip'],self.bb)44 if not brain.board.flop():45 self.pfeq = self.parameterize(brain.ev)46 my_action = self.preflop(brain)47 self.my_last_action['street'] = PREFLOP48 if DEBUG: print "taking action",my_action, "from the preflop"49 elif not brain.board.turn():50 my_action = self.flop(brain)51 self.my_last_action['street'] = FLOP52 if DEBUG: print "taking action",my_action, "from the flop"53 elif not brain.board.river():54 my_action = self.turn(brain)55 self.my_last_action['street'] = TURN56 if DEBUG: print "taking action",my_action, "from the turn"57 else:58 my_action = self.river(brain)59 self.my_last_action['street'] = RIVER60 if DEBUG: print "taking action",my_action, "from the river"61 62 # Check that our action is legal63 for action in brain.legal:64 if isinstance(action,type(my_action)):65 break66 else:67 if isinstance(my_action, Raise):68 for action in brain.legal:69 if isinstance(action,Call):70 my_action = Call()71 break72 else:73 my_action = None74 else:75 my_action = None76 # check fold if we selected no action77 if my_action == None:78 for action in brain.legal:79 if isinstance(action, Check):80 my_action = action81 break82 else:83 my_action = Fold()84 self.my_last_action['first'] = self.first85 action = brain.classify(my_action)86 if action in [RAISE,BET]:87 if brain.bound == -1:88 my_action.amount = brain.pip+brain.stack89 else:90 my_action.amount = int(min(my_action.amount, brain.bound))91 if my_action.amount < self.min_bet:92 for action in brain.legal:93 if isinstance(action, Call):94 my_action = action95 self.my_last_action['amount'] = brain.opponent['pip']96 break97 else:98 my_action = Check()99 100 else:101 self.my_last_action['amount'] = my_action.amount102 if isinstance(my_action, Call): #should we really call here?103 bet = brain.opponent['pip']104 if (bet-brain.pip)/float(brain.pot + 2*bet) >= brain.ev: #pot odds greater than ev, so fold105 my_action = Fold()106 #print "was going to call!"107 else:108 self.my_last_action['amount'] = brain.opponent['pip']109 self.my_last_action['action'] = brain.classify(my_action)110 if DEBUG: print "taking action",my_action111 return my_action112 113 def new_hand(self):114 self.my_last_action = {'action':FOLD, 'first':False, 'reraise':False, 'street':PREFLOP, 'betfromaf':False, 'amount':0}115 116 def preflop(self, brain):117 #it's preflop, tell me how to play118 last_act = brain.actions[-1]119 last_action = brain.classify(last_act[1])120 if DEBUG: print "opp last action was",last_act, "and pfeq is", self.pfeq121 if DEBUG: print "legal actions:", brain.legal122 self.first = last_action == POST123 stack_size = brain.pip+brain.stack124 my_action = None125 126 if self.pfeq == 0:127 if self.first:128 my_action = Call()129 if last_action == RAISE:130 my_action = Fold()131 else:132 my_action = Check()133 elif self.pfeq == 1:134 if self.first:135 my_action = Call()136 elif last_action == CALL:137 my_action = Raise(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size))) #low-mid138 elif last_action == RAISE:139 if self.my_last_action['action'] == CHECK or last_act[1].amount/float(stack_size) > brain.LOW: #TODO: this should be pot odds!140 my_action = Fold()141 else:142 my_action = Call()143 elif self.pfeq == 2:144 if self.first:145 my_action = Raise(brain.LOW*stack_size)146 elif last_action == CALL:147 my_action = Raise(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size))) #low to mid148 elif last_action == RAISE:149 if self.my_last_action['action'] == CHECK or last_act[1].amount/float(stack_size) > brain.MID:150 my_action = Fold()151 else:152 my_action = Call()153 elif self.pfeq == 3:154 if self.first:155 my_action = Raise(brain.LOW*stack_size)156 elif last_action == CALL:157 my_action = Raise(brain.MID*stack_size)158 elif last_action == RAISE:159 if self.my_last_action['action'] == CHECK or last_act[1].amount/float(stack_size) > brain.MID:160 my_action = Fold()161 else:162 my_action = Call()163 elif self.pfeq == 4:164 if self.first or last_action == RAISE:165 if self.my_last_action['action'] == RAISE:166 if self.my_last_action['reraise']:167 my_action = Raise(stack_size)168 else:169 my_action = Raise(self.min_bet)170 self.my_last_action['reraise'] = True171 else:172 my_action = Raise(brain.MID*stack_size)173 elif last_action == CALL:174 my_action = Raise(brain.LOW*stack_size)175 else:176 print "preflop: umm...", self.pfeq, brain.ev177 if DEBUG: print "and action",my_action178 return my_action179 180 def flop(self, brain):181 #it's the flop, tell me how to play182 last_act = brain.actions[-1]183 last_action = brain.classify(last_act[1])184 if DEBUG: print "opp last action was",last_act, "and pfeq is", self.pfeq185 if DEBUG: print "legal actions:", brain.legal186 self.first = last_action == DEAL187 stack_size = brain.pip+brain.stack188 my_action = None189 eq = self.parameterize(brain.ev)190 if self.pfeq == 0:191 if eq == 0:192 if self.first or last_action == CHECK:193 my_action = Check()194 elif last_action in [BET, RAISE]:195 my_action = Fold()196 elif eq == 1:197 if self.first:198 if randint(0,99) < 50:199 my_action = Check()200 else:201 my_action = Bet(self.min_bet)202 elif last_action == CHECK:203 my_action = Check()204 elif last_action in [BET, RAISE]:205 if last_act[1].amount/float(stack_size) <= brain.LOW:206 my_action = Call()207 else:208 my_action = Fold()209 elif eq == 2:210 if brain.opp_stats['AF'] < .5:211 for action in brain.legal:212 if isinstance(action,Raise) or isinstance(action,Bet):213 my_action = action214 self.my_last_action['betfromaf'] = True215 break216 elif self.first:217 my_action = Bet(brain.LOW*stack_size)218 elif last_action == CHECK:219 if randint(0,99) < 50:220 my_action = Check()221 else:222 my_action = Bet(brain.LOW*stack_size)223 elif last_action == BET:224 if last_act[1].amount/float(stack_size) <= brain.LOW:225 my_action = Call()226 else:227 my_action = Fold()228 elif last_action == RAISE:229 if self.my_last_action['first']:230 if last_act[1].amount/float(stack_size) <= brain.LOW:231 my_act = Call()232 elif last_act[1].amount/float(stack_size) <= brain.HIGH:233 if brain.opp_stats['INCR'] < .2 : #or brain.opp_stats['CHBR'] < .4234 my_action = Fold()235 else:236 my_action = Call()237 else:238 my_action = Fold()239 elif self.my_last_action['betfromaf']:240 my_action = Fold()241 elif self.my_last_action['action'] == BET:242 if last_act[1].amount == 2*self.my_last_action['amount']:243 my_action = Call()244 else:245 my_action = Fold()246 elif eq == 3:247 if self.first or last_action == CHECK:248 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size))) #low-mid249 elif last_action == BET:250 if last_act[1].amount/float(stack_size) <= brain.MID:251 my_action = Call()252 else:253 my_action = Fold()254 elif last_action == RAISE:255 if self.my_last_action['first']:256 if last_act[1].amount/float(stack_size) <= brain.MID:257 my_action = Call()258 else:259 my_action = Fold()260 else: #then I must have bet261 if last_act[1].amount == 2*self.my_last_action['amount']:262 my_action = Call()263 else:264 my_action = Fold()265 elif eq == 4:266 if self.first:267 my_action = Bet(randint(int(brain.MID*stack_size),int(brain.HIGH*stack_size))) #mid_high268 elif last_action == CHECK:269 my_action = Bet(int(brain.LOW*stack_size))270 elif last_action == BET:271 my_action = Raise(int(brain.MID*stack_size))272 elif last_action == RAISE:273 if self.my_last_action['first']:274 if last_act[1].amount/float(stack_size) <= brain.MID:275 my_action = Call()276 else:277 my_action = Raise(stack_size)278 elif self.my_last_action['action'] == BET:279 my_action = Raise(int(brain.MID*stack_size))280 elif self.my_last_action['action'] == RAISE:281 my_action = Raise(stack_size)282 elif self.pfeq == 1:283 if eq == 0:284 if self.first or last_action == CHECK:285 my_action = Check()286 elif last_action in [BET, RAISE]:287 my_action = Fold()288 elif eq == 1:289 if self.first:290 if randint(0,99) < 50:291 my_action = Check()292 else:293 my_action = Bet(randint(self.min_bet,int(brain.LOW*stack_size)))294 elif last_action == CHECK:295 my_action = Check()296 elif last_action in [BET, RAISE]:297 if last_act[1].amount/float(stack_size) <= brain.LOW:298 my_action = Call()299 else:300 my_action = Fold()301 elif eq == 2:302 if brain.opp_stats['AF'] < .5:303 for action in brain.legal:304 if isinstance(action,Raise) or isinstance(action,Bet):305 my_action = action306 self.my_last_action['betfromaf'] = True307 break308 elif self.first:309 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))310 elif last_action == CHECK:311 if randint(0,99) < 50:312 my_action = Check()313 else:314 my_action = Bet(brain.LOW*stack_size)315 elif last_action == BET:316 if last_act[1].amount/float(stack_size) <= brain.MID:317 my_action = Call()318 else:319 my_action = Fold()320 elif last_action == RAISE:321 if self.my_last_action['first']:322 if last_act[1].amount/float(stack_size) <= brain.LOW:323 my_act = Call()324 elif last_act[1].amount/float(stack_size) <= brain.HIGH:325 if brain.opp_stats['INCR'] < .2 : #or brain.opp_stats['CHBR'] < .4326 my_action = Fold()327 else:328 my_action = Call()329 else:330 my_action = Fold()331 elif self.my_last_action['betfromaf']:332 if last_act[1].amount/float(stack_size) <= brain.LOW:333 my_act = Call()334 else:335 my_action = Fold()336 elif self.my_last_action['action'] == BET:337 if last_act[1].amount/float(stack_size) <= brain.MID:338 my_action = Call()339 else:340 my_action = Fold()341 elif eq == 3:342 if self.first or last_action == CHECK:343 my_action = Bet(int(brain.MID*stack_size))344 elif last_action == BET:345 if last_act[1].amount/float(stack_size) <= brain.LOW:346 my_action = Raise(int(brain.MID*stack_size))347 elif last_act[1].amount/float(stack_size) <= brain.HIGH:348 my_action = Call()349 else:350 my_action = Fold()351 elif last_action == RAISE:352 if self.my_last_action['first']:353 if last_act[1].amount/float(stack_size) <= brain.MID:354 my_action = Call()355 else:356 my_action = Fold()357 else: #then I must have bet358 if last_act[1].amount == 2*self.my_last_action['amount']:359 my_action = Call()360 else:361 my_action = Fold()362 elif eq == 4:363 if self.first:364 my_action = Bet(randint(int(brain.MID*stack_size),int(brain.HIGH*stack_size))) #mid_high365 elif last_action == CHECK:366 my_action = Bet(int(brain.LOW*stack_size))367 elif last_action == BET:368 my_action = Raise(int(brain.MID*stack_size))369 elif last_action == RAISE:370 if self.my_last_action['first']:371 if last_act[1].amount/float(stack_size) <= brain.MID:372 my_action = Call()373 else:374 my_action = Raise(stack_size)375 elif self.my_last_action['action'] == BET:376 my_action = Raise(int(brain.MID*stack_size))377 elif self.my_last_action['action'] == RAISE:378 my_action = Raise(stack_size)379 elif self.pfeq == 2:380 if eq == 0:381 if self.first:382 if brain.opp_stats['AF'] < .5:383 my_action = Bet(int(brain.MID*stack_size))384 else:385 my_action = Check()386 elif last_action == CHECK:387 my_action = Bet(brain.MID*stack_size)388 elif last_action in [BET, RAISE]:389 my_action = Fold()390 elif eq == 1:391 if self.first:392 if randint(0,99) < 50:393 my_action = Check()394 else:395 my_action = Bet(randint(self.min_bet,int(brain.LOW*stack_size)))396 elif last_action == CHECK:397 my_action = Check()398 elif last_action == BET:399 if last_act[1].amount/float(stack_size) <= brain.MID:400 my_action = Call()401 else:402 my_action = Fold()403 elif last_action == RAISE:404 if last_act[1].amount/float(stack_size) <= brain.LOW:405 my_action = Call()406 else:407 my_action = Fold()408 elif eq == 2:409 if self.first:410 if brain.opp_stats['AF'] < .5:411 my_action = Bet(int(brain.MID*stack_size))412 self.my_last_action['betfromaf'] = True413 else:414 my_action = Check()415 elif last_action == CHECK:416 my_action = Check()417 elif last_action == BET:418 if last_act[1].amount/float(stack_size) <= brain.MID:419 my_action = Call()420 else:421 my_action = Fold()422 elif last_action == RAISE:423 if last_act[1].amount/float(stack_size) <= brain.LOW:424 my_action = Call()425 else:426 my_action = Fold()427 elif eq == 3:428 if self.first or last_action == Check:429 my_action = Bet(int(brain.MID*stack_size))430 elif last_action == BET:431 if last_act[1].amount/float(stack_size) <= brain.LOW:432 my_action = Raise(int(brain.MID*stack_size))433 elif last_act[1].amount/float(stack_size) <= brain.HIGH:434 my_action = Call()435 else:436 my_action = Fold()437 elif last_action == RAISE:438 if self.my_last_action['first']:439 if last_act[1].amount/float(stack_size) <= brain.HIGH:440 my_action = Call()441 else:442 my_action = Fold()443 elif self.my_last_action['action'] == BET:444 if last_act[1].amount == 2*self.my_last_action['amount']:445 my_action = Call()446 else:447 my_action = Fold()448 else:449 my_action == Call()450 elif eq == 4:451 if self.first:452 my_action = Bet(randint(int(brain.MID*stack_size),int(brain.HIGH*stack_size)))453 elif last_action == CHECK:454 my_action = Bet(int(brain.MID*stack_size))455 elif last_action == BET:456 my_action = Raise(int(brain.MID*stack_size))457 elif last_action == RAISE:458 if self.my_last_action['first']:459 if last_act[1].amount/float(stack_size) <= brain.MID:460 my_action = Call()461 else:462 my_action = Raise(stack_size)463 elif self.my_last_action['action'] == RAISE:464 my_action = Raise(stack_size)465 else:466 my_action = Raise(int(brain.MID*stack_size))467 elif self.pfeq == 3:468 if eq == 0:469 if self.first:470 if brain.opp_stats['AF'] < .5:471 my_action = Bet(int(brain.MID*stack_size))472 else:473 my_action = Check()474 elif last_action == CHECK:475 my_action = Bet(int(brain.MID*stack_size))476 elif last_action == BET:477 if last_act[1].amount/float(stack_size) <= brain.LOW:478 my_action = Call()479 else:480 my_action = Fold()481 elif last_action == RAISE:482 my_action = Fold()483 elif eq == 1:484 if self.first:485 if randint(0,99) < 50:486 my_action = Check()487 else:488 my_action = Bet(randint(self.min_bet,int(brain.LOW*stack_size)))489 elif last_action == CHECK:490 my_action = Bet(int(brain.LOW*stack_size))491 elif last_action == BET:492 if last_act[1].amount/float(stack_size) <= brain.MID:493 my_action = Call()494 else:495 my_action = Fold()496 elif last_action == RAISE:497 if last_act[1].amount/float(stack_size) <= brain.LOW:498 my_action = Call()499 else:500 my_action = Fold()501 elif eq == 2:502 if self.first:503 if brain.opp_stats['AF'] < .5:504 my_action = Bet(int(brain.MID*stack_size))505 self.my_last_action['betfromaf'] = True506 else:507 my_action = Bet(int(brain.LOW*stack_size))508 elif last_action == CHECK:509 my_action = Check()510 elif last_action == BET:511 if last_act[1].amount/float(stack_size) <= brain.MID:512 my_action = Call()513 else:514 my_action = Fold()515 elif last_action == RAISE:516 if last_act[1].amount/float(stack_size) <= brain.MID:517 my_action = Call()518 else:519 my_action = Fold()520 elif eq == 3:521 if self.first or last_action == Check:522 my_action = Bet(int(brain.MID*stack_size))523 elif last_action == BET:524 if last_act[1].amount/float(stack_size) <= brain.LOW:525 my_action = Raise(int(brain.MID*stack_size))526 elif last_act[1].amount/float(stack_size) <= brain.HIGH:527 my_action = Call()528 else:529 my_action = Fold()530 elif last_action == RAISE:531 if self.my_last_action['first']:532 if last_act[1].amount/float(stack_size) <= brain.MID:533 my_action = Raise(self.min_bet)534 elif last_act[1].amount/float(stack_size) <= brain.HIGH:535 my_action = Call()536 else:537 my_action = Fold()538 elif self.my_last_action['action'] == BET:539 if last_act[1].amount == 2*self.my_last_action['amount']:540 my_action = Call()541 else:542 my_action = Fold()543 else:544 my_action = Call()545 elif eq == 4:546 if self.first:547 my_action = Check()548 elif last_action == CHECK:549 my_action = Bet(int(brain.LOW*stack_size))550 elif last_action == BET:551 my_action = Call()552 elif last_action == RAISE:553 if self.my_last_action['first']:554 if last_act[1].amount/float(stack_size) <= brain.MID:555 my_action = Call()556 else:557 my_action = Raise(stack_size)558 elif self.my_last_action['action'] == BET:559 my_action = Raise(int(brain.MID*stack_size))560 elif self.my_last_action['action'] == RAISE:561 my_action = Raise(stack_size)562 elif self.pfeq == 4:563 if eq == 0:564 if self.first or last_action == CHECK:565 my_action = Check()566 elif last_action in [BET, RAISE]:567 my_action = Fold()568 elif eq == 1:569 if self.first or last_action == CHECK:570 my_action = Bet(int(brain.MID*stack_size))571 elif last_action == BET:572 if last_act[1].amount/float(stack_size) <= brain.LOW:573 my_action = Call()574 else:575 my_action = Fold()576 elif last_action == RAISE:577 if last_act[1].amount == 2*self.my_last_action['amount']:578 my_action = Call()579 else:580 my_action = Fold()581 elif eq == 2:582 if self.first or last_action == CHECK:583 my_action = Bet(int(brain.MID*stack_size))584 elif last_action == BET:585 if last_act[1].amount/float(stack_size) <= brain.MID:586 my_action = Raise(int(brain.MID*stack_size))587 elif last_act[1].amount/float(stack_size) <= brain.HIGH:588 my_action = Call()589 else:590 my_action = Fold()591 elif last_action == RAISE:592 if self.my_last_action['first']:593 if last_act[1].amount/float(stack_size) <= brain.MID:594 my_action = Raise(self.min_bet)595 self.my_last_action['reraise'] = True596 else:597 my_action = Fold()598 elif self.my_last_action['action'] == BET:599 if last_act[1].amount/float(stack_size) <= brain.LOW:600 my_action = Call()601 else:602 my_action = Fold()603 elif self.my_last_action['reraise']:604 if last_act[1].amount/float(stack_size) <= brain.MID:605 my_action = Call()606 else:607 my_action = Fold()608 else:609 my_action = Call()610 elif eq == 3:611 if self.first:612 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))613 elif last_action == CHECK:614 my_action = Bet(int(brain.MID*stack_size))615 elif last_action == BET:616 if last_act[1].amount/float(stack_size) <= brain.MID:617 my_action = Raise(2*self.min_bet)618 elif last_act[1].amount/float(stack_size) <= brain.HIGH:619 my_action = Call()620 else:621 my_action = Fold()622 elif last_action == RAISE:623 if self.my_last_action['first']:624 if last_act[1].amount/float(stack_size) <= brain.HIGH:625 my_action = Call()626 else:627 my_action = Fold()628 elif self.my_last_action['action'] == BET:629 if last_act[1].amount == 2*self.my_last_action['amount']:630 my_action = Call()631 else:632 my_action = Fold()633 else:634 my_action = Call()635 elif eq == 4:636 if self.first:637 my_action = Bet(randint(int(brain.MID*stack_size),int(brain.HIGH*stack_size)))638 elif last_action == CHECK:639 my_action = Bet(int(brain.LOW*stack_size))640 elif last_action == BET:641 my_action = Raise(int(brain.MID*stack_size))642 elif last_action == RAISE:643 if self.my_last_action['first']:644 if last_act[1].amount/float(stack_size) <= brain.MID:645 my_action = Call()646 else:647 my_action = Raise(stack_size)648 elif self.my_last_action['action'] == BET:649 my_action = Raise(int(brain.MID*stack_size))650 else:651 my_action = Raise(stack_size)652 else:653 print "flop: umm...", self.pfeq, brain.ev654 return my_action655 def turn(self, brain):656 #it's the turn, tell me how to play657 last_act = brain.actions[-1]658 last_action = brain.classify(last_act[1])659 if DEBUG: print "opp last action was",last_act, "and pfeq is", self.pfeq660 if DEBUG: print "legal actions:", brain.legal661 self.first = last_action == DEAL662 stack_size = brain.pip+brain.stack663 my_action = None664 eq = self.parameterize(brain.ev)665 if self.pfeq == 0:666 if eq == 0:667 if self.first:668 return Check()669 elif last_action == BET:670 if last_act[1].amount == 2*self.my_last_action['amount']:671 my_action = Call()672 else:673 my_action = Fold()674 elif last_action == CHECK:675 #ignoring condition on previous betting676 if randint(0,99) < 50:677 my_action = Check()678 else:679 my_action = Bet(brain.MID*stack_size)680 elif last_action == RAISE:681 my_action = Fold()682 elif eq == 1:683 if brain.opp_stats['AF'] < .5:684 for action in brain.legal:685 if isinstance(action,Raise):686 my_action = Raise(brain.MID*stack_size)687 self.my_last_action['betfromaf'] = True688 break689 elif isinstance(action,Bet):690 my_action = Bet(brain.MID*stack_size)691 self.my_last_action['betfromaf'] = True692 break693 elif self.first:694 if randint(0,99) < 50:695 my_action = Check()696 else:697 my_action = Bet(randint(self.min_bet,int(brain.LOW*stack_size)))698 elif last_action == CHECK:699 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))700 elif last_action == BET:701 if last_act[1].amount/float(stack_size) <= brain.LOW:702 my_action = Call()703 else:704 my_action = Fold()705 elif last_action == RAISE:706 if self.my_last_action['first']:707 if last_act[1].amount == 2*self.my_last_action['amount']:708 my_action = Call()709 else:710 my_action = Fold()711 else:712 my_action = Fold()713 elif eq == 2:714 if brain.opp_stats['AF'] < .5:715 for action in brain.legal:716 if isinstance(action,Raise):717 my_action = Raise(brain.MID*stack_size)718 self.my_last_action['betfromaf'] = True719 break720 elif isinstance(action,Bet):721 my_action = Bet(brain.MID*stack_size)722 self.my_last_action['betfromaf'] = True723 break724 elif self.first:725 my_action = Bet(brain.LOW*stack_size)726 elif last_action == CHECK:727 if randint(0,99) < 50:728 my_action = Check()729 else:730 my_action = Bet(brain.LOW*stack_size)731 elif last_action == BET:732 if last_act[1].amount/float(stack_size) <= brain.LOW:733 my_action = Call()734 elif last_act[1].amount/float(stack_size) <= brain.MID:735 if brain.opp_stats['AF'] > 1.5:736 my_action = Call()737 else:738 my_action = Fold()739 else:740 my_action = Fold()741 elif last_action == RAISE:742 if self.my_last_action['first']:743 if last_act[1].amount/float(stack_size) <= brain.LOW:744 my_action = Call()745 elif last_act[1].amount/float(stack_size) <= brain.MID:746 if brain.opp_stats['INCR'] < .2 : #or brain.opp_stats['CHBR'] < .4 or this is a continutation bet747 my_action = Fold()748 else:749 my_action = Call()750 else:751 my_action = Fold()752 elif self.my_last_action['betfromaf']:753 my_action = Fold()754 elif eq == 3:755 if self.first or last_action == CHECK:756 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))757 elif last_action == BET:758 if last_act[1].amount/float(stack_size) <= brain.MID:759 my_action = Call()760 else:761 my_action = Fold()762 elif last_action == RAISE:763 if self.my_last_action['first']:764 if brain.opp_stats['AF'] < .5:765 my_action = Fold()766 else:767 if last_act[1].amount/float(stack_size) <= brain.MID:768 my_action = Call()769 else:770 my_action = Fold()771 elif self.my_last_action['action'] == BET:772 #if opp never bet/raised: fold773 my_action = Call()774 elif eq == 4:775 if self.first:776 my_action = Bet(randint(int(brain.MID*stack_size),int(brain.HIGH*stack_size)))777 elif last_action == CHECK:778 my_action = Bet(brain.LOW*stack_size)779 elif last_action == BET:780 my_action = Bet(brain.MID*stack_size)781 elif last_action == RAISE:782 if self.my_last_action['first']:783 if last_act[1].amount/float(stack_size) <= brain.MID:784 my_action = Call()785 else:786 my_action = Raise(stack_size)787 elif self.my_last_action['action'] == BET:788 my_action = Raise(brain.MID*stack_size)789 elif self.my_last_action['action'] == RAISE:790 my_action = Raise(stack_size)791 elif self.pfeq == 1:792 if eq == 0:793 if self.first:794 return Check()795 elif last_action == BET:796 if last_act[1].amount == 2*self.my_last_action['amount']:797 my_action = Call()798 else:799 my_action = Fold()800 elif last_action == CHECK:801 #ignoring condition on previous betting802 if randint(0,99) < 50:803 my_action = Check()804 else:805 my_action = Bet(brain.MID*stack_size)806 elif last_action == RAISE:807 my_action = Fold()808 elif eq == 1:809 if self.first:810 if brain.opp_stats['AF'] < .5:811 for action in brain.legal:812 if isinstance(action,Raise):813 my_action = Raise(brain.MID*stack_size)814 self.my_last_action['betfromaf'] = True815 break816 elif isinstance(action,Bet):817 my_action = Bet(brain.MID*stack_size)818 self.my_last_action['betfromaf'] = True819 break820 else:821 if randint(0,99) < 50:822 my_action = Check()823 else:824 my_action = Bet(randint(self.min_bet,int(brain.LOW*stack_size)))825 elif last_action == CHECK:826 my_action = Check()827 elif last_action == BET:828 if last_act[1].amount/float(stack_size) <= brain.LOW:829 my_action = Call()830 else:831 my_action = Fold()832 elif eq == 2:833 if self.first:834 if brain.opp_stats['AF'] < .5:835 for action in brain.legal:836 if isinstance(action,Raise):837 my_action = Raise(brain.MID*stack_size)838 self.my_last_action['betfromaf'] = True839 break840 elif isinstance(action,Bet):841 my_action = Bet(brain.MID*stack_size)842 self.my_last_action['betfromaf'] = True843 break844 else:845 my_action = Bet(brain.LOW*stack_size)846 elif last_action == CHECK:847 if randint(0,99) < 50:848 my_action = Check()849 else:850 my_action = Bet(brain.LOW*stack_size)851 elif last_action == BET:852 if last_act[1].amount/float(stack_size) <= brain.LOW:853 my_action = Call()854 elif last_act[1].amount/float(stack_size) <= brain.MID:855 if brain.opp_stats['AF'] > 1.5:856 my_action = Call()857 else:858 my_action = Fold()859 else:860 my_action = Fold()861 elif last_action == RAISE:862 if self.my_last_action['first']:863 if self.my_last_action['betfromaf']:864 if last_act[1].amount/float(stack_size) <= brain.MID:865 my_action = Call()866 else:867 my_action = Fold()868 else:869 if last_act[1].amount/float(stack_size) <= brain.LOW:870 my_action = Call()871 elif last_act[1].amount/float(stack_size) <= brain.HIGH:872 if brain.opp_stats['INCR'] < .2 : #or brain.opp_stats['CHBR'] < .4 or this is a continutation bet873 my_action = Fold()874 else:875 my_action = Call()876 else:877 my_action = Fold()878 elif self.my_last_action['action'] == BET:879 if last_act[1].amount == 2*self.my_last_action['amount']:880 my_action = Call()881 else:882 my_action = Fold()883 elif eq == 3:884 if self.first:885 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))886 elif last_action == CHECK:887 if stack_size > 1.7*400:888 my_action = Bet(stack_size)889 else:890 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))891 elif last_action == BET:892 if last_act[1].amount/float(stack_size) <= brain.MID:893 my_action = Call()894 elif last_act[1].amount/float(stack_size) <= brain.HIGH:895 if randint(0,99) < 50:896 my_action = Call()897 else:898 my_action = Fold()899 else:900 my_action = Fold()901 elif last_action == RAISE:902 if self.my_last_action['first']:903 if brain.opp_stats['AF'] < .5:904 my_action = Fold()905 else:906 if last_act[1].amount/float(stack_size) <= brain.MID:907 my_action = Call()908 else:909 my_action = Fold()910 else:911 #if opp has not raised/bet this hand: fold912 my_action = Call()913 elif eq == 4:914 if self.first:915 my_action = Bet(randint(int(brain.MID*stack_size),int(brain.HIGH*stack_size)))916 elif last_action == CHECK:917 my_action = Bet(brain.LOW*stack_size)918 elif last_action == BET:919 my_action = Raise(brain.MID*stack_size)920 elif last_action == RAISE:921 if self.my_last_action['first']:922 if last_act[1].amount/float(stack_size) <= brain.MID:923 my_action = Call()924 else:925 my_action = Raise(stack_size)926 elif self.my_last_action['action'] == BET:927 my_action = Raise(brain.MID*stack_size)928 elif self.my_last_action['action'] == RAISE:929 my_action = Raise(stack_size)930 elif self.pfeq == 2:931 if eq == 0:932 if self.first:933 my_action = Check()934 elif last_action == CHECK:935 if randint(0,99) < 50:936 my_action = Bet(brain.MID*stack_size)937 else:938 my_action = Check()939 elif last_action == BET:940 if last_act[1].amount == 2*self.my_last_action['amount']:941 my_action = Call()942 else:943 my_action = Fold()944 elif last_action == RAISE:945 my_action = Fold()946 elif eq == 1:947 if self.first:948 if brain.opp_stats['AF'] < .5:949 for action in brain.legal:950 if isinstance(action,Raise):951 my_action = Raise(brain.MID*stack_size)952 self.my_last_action['betfromaf'] = True953 break954 elif isinstance(action,Bet):955 my_action = Bet(brain.MID*stack_size)956 self.my_last_action['betfromaf'] = True957 break958 else:959 if randint(0,99) < 50:960 my_action = Check()961 else:962 my_action = Bet(randint(self.min_bet,int(brain.LOW*stack_size)))963 elif last_action == CHECK:964 my_action = Check()965 elif last_action == BET:966 if last_act[1].amount/float(stack_size) <= brain.LOW:967 my_action = Call()968 elif last_act[1].amount/float(stack_size) <= brain.MID:969 if randint(0,99) < 50:970 my_action = Call()971 else:972 my_action = Fold()973 else:974 my_action = Fold()975 elif last_action == RAISE:976 if self.my_last_action['first']:977 if self.my_last_action['betfromaf']:978 my_action = Fold()979 else:980 if last_act[1].amount/float(stack_size) <= brain.LOW:981 my_action = Call()982 else:983 my_action = Fold()984 elif eq == 2:985 if self.first:986 my_action = Bet(brain.MID*stack_size)987 elif last_action == CHECK:988 my_action = Check()989 elif last_action == BET:990 if last_act[1].amount/float(stack_size) <= brain.LOW:991 my_action = Call()992 elif last_act[1].amount/float(stack_size) <= brain.MID:993 if brain.opp_stats['AF'] > 1.5:994 my_action = Call()995 else:996 my_action = Fold()997 else:998 my_action = Fold()999 elif last_action == RAISE:1000 if self.my_last_action['first']:1001 if last_act[1].amount/float(stack_size) <= brain.LOW:1002 my_action = Call()1003 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1004 if brain.opp_stats['INCR'] < .2 : #or brain.opp_stats['CHBR'] < .4 or this is a continutation bet1005 my_action = Fold()1006 else:1007 my_action = Call()1008 else:1009 my_action = Fold()1010 elif eq == 3:1011 if self.first:1012 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))1013 elif last_action == CHECK:1014 if stack_size > 1.7*400:1015 my_action = Bet(stack_size)1016 else:1017 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))1018 elif last_action == BET:1019 if last_act[1].amount/float(stack_size) <= brain.MID:1020 my_action = Call()1021 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1022 if randint(0,99) < 50:1023 my_action = Call()1024 else:1025 my_action = Fold()1026 else:1027 my_action = Fold()1028 elif last_action == RAISE:1029 if self.my_last_action['first']:1030 if brain.opp_stats['AF'] < .5:1031 my_action = Fold()1032 else:1033 if last_act[1].amount/float(stack_size) <= brain.MID:1034 my_action = Call()1035 else:1036 my_action = Fold()1037 elif self.my_last_action['action'] == BET:1038 #if opp has not raised/bet this hand: fold1039 if last_act[1].amount/float(stack_size) <= brain.MID:1040 my_action = Call()1041 else:1042 my_action = Fold()1043 elif eq == 4:1044 if self.first:1045 my_action = Bet(randint(int(brain.MID*stack_size),int(brain.HIGH*stack_size)))1046 elif last_action == CHECK:1047 my_action = Bet(brain.LOW*stack_size)1048 elif last_action == BET:1049 my_action = Raise(brain.MID*stack_size)1050 elif last_action == RAISE:1051 if self.my_last_action['first']:1052 if last_act[1].amount/float(stack_size) <= brain.MID:1053 my_action = Call()1054 else:1055 my_action = Raise(stack_size)1056 elif self.my_last_action['action'] == BET:1057 my_action = Raise(brain.MID*stack_size)1058 elif self.my_last_action['action'] == RAISE:1059 my_action = Raise(stack_size)1060 elif self.pfeq == 3:1061 if eq == 0:1062 if self.first:1063 my_action = Bet(brain.MID*stack_size)1064 elif last_action == CHECK:1065 if randint(0,99) < 50:1066 my_action = Bet(brain.MID*stack_size)1067 else:1068 my_action = Check()1069 elif last_action == BET:1070 if last_act[1].amount == 2*self.my_last_action['amount']:1071 my_action = Call()1072 else:1073 my_action = Fold()1074 elif last_action == RAISE:1075 if self.my_last_action['first']:1076 if last_act[1].amount/float(stack_size) <= brain.LOW:1077 my_action = Call()1078 else:1079 my_action = Fold()1080 elif self.my_last_action['action'] == BET:1081 my_action = Fold()1082 elif eq == 1:1083 if self.first:1084 if brain.opp_stats['AF'] < .5:1085 for action in brain.legal:1086 if isinstance(action,Raise):1087 my_action = Raise(brain.MID*stack_size)1088 self.my_last_action['betfromaf'] = True1089 break1090 elif isinstance(action,Bet):1091 my_action = Bet(brain.MID*stack_size)1092 self.my_last_action['betfromaf'] = True1093 break1094 else:1095 if randint(0,99) < 50:1096 my_action = Check()1097 else:1098 my_action = Bet(brain.LOW*stack_size)1099 elif last_action == CHECK:1100 my_action = Bet(brain.MID*stack_size)1101 elif last_action == BET:1102 if last_act[1].amount/float(stack_size) <= brain.LOW:1103 my_action = Call()1104 else:1105 my_action = Fold()1106 elif last_action == RAISE:1107 if self.my_last_action['first']:1108 if self.my_last_action['betfromaf']:1109 my_action = Fold()1110 else:1111 if last_act[1].amount/float(stack_size) <= brain.LOW:1112 my_action = Call()1113 else:1114 my_action = Fold()1115 elif self.my_last_action['action'] == BET:1116 if last_act[1].amount/float(stack_size) <= brain.LOW:1117 my_action = Call()1118 else:1119 my_action = Fold()1120 elif eq == 2:1121 if self.first:1122 if stack_size <= .6 * 400:1123 my_action = Check()1124 else:1125 my_action = Bet(brain.MID*stack_size)1126 elif last_action == CHECK:1127 my_action = Bet(brain.MID*stack_size)1128 elif last_action == BET:1129 if last_act[1].amount/float(stack_size) <= brain.LOW:1130 my_action = Raise(brain.MID*stack_size)1131 elif last_act[1].amount/float(stack_size) <= brain.MID:1132 if brain.opp_stats['AF'] < .5:1133 my_action = Call()1134 else:1135 my_action = Fold()1136 else:1137 my_action = Fold()1138 elif last_action == RAISE:1139 if self.my_last_action['first']:1140 if last_act[1].amount/float(stack_size) <= brain.LOW:1141 my_action = Call()1142 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1143 if brain.opp_stats['INCR'] < .2 : #or brain.opp_stats['CHBR'] < .4 or this is a continutation bet1144 my_action = Fold()1145 else:1146 my_action = Call()1147 else:1148 my_action = Fold()1149 elif self.my_last_action['action'] == BET:1150 if last_act[1].amount/float(stack_size) <= brain.LOW:1151 my_action = Call()1152 elif last_act[1].amount/float(stack_size) <= brain.MID:1153 if stack_size <= .6 * 400:1154 my_action = Fold()1155 else:1156 my_action = Call()1157 else:1158 my_action = Fold()1159 elif eq == 3:1160 if self.first:1161 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))1162 elif last_action == CHECK:1163 if stack_size > 1.7*400:1164 my_action = Bet(stack_size)1165 else:1166 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))1167 elif last_action == BET:1168 if last_act[1].amount/float(stack_size) <= brain.MID:1169 my_action = Raise(brain.HIGH*stack_size)1170 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1171 my_action = Call()1172 else:1173 my_action = Fold()1174 elif last_action == RAISE:1175 if self.my_last_action['first']:1176 if last_act[1].amount/float(stack_size) <= brain.MID:1177 my_action = Call()1178 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1179 if brain.opp_stats['AF'] < .5:1180 my_action = Fold()1181 else:1182 my_action = Call()1183 else:1184 my_action = Fold()1185 elif self.my_last_action['action'] == BET:1186 #if opp has not raised/bet this hand: fold1187 if last_act[1].amount/float(stack_size) <= brain.MID:1188 my_action = Call()1189 else:1190 my_action = Fold()1191 elif self.my_last_action['action'] == RAISE: 1192 my_action = Call()1193 elif eq == 4:1194 if self.first:1195 my_action = Bet(randint(int(brain.MID*stack_size),int(brain.HIGH*stack_size)))1196 elif last_action == CHECK:1197 my_action = Bet(brain.LOW*stack_size)1198 elif last_action == BET:1199 my_action = Raise(brain.MID*stack_size)1200 elif last_action == RAISE:1201 if self.my_last_action['first']:1202 if last_act[1].amount/float(stack_size) <= brain.MID:1203 my_action = Call()1204 else:1205 my_action = Raise(stack_size)1206 elif self.my_last_action['action'] == BET:1207 my_action = Raise(brain.MID*stack_size)1208 elif self.my_last_action['action'] == RAISE:1209 my_action = Raise(stack_size)1210 elif self.pfeq == 4:1211 if eq == 0:1212 if self.first or last_action == CHECK:1213 my_action = Check()1214 elif last_action == BET:1215 if last_act[1].amount/float(stack_size) <= brain.LOW:1216 my_action = Call()1217 else:1218 my_action = Fold()1219 elif eq == 1:1220 if self.first:1221 if brain.opp_stats['AF'] < .5:1222 for action in brain.legal:1223 if isinstance(action,Raise):1224 my_action = Raise(brain.MID*stack_size)1225 self.my_last_action['betfromaf'] = True1226 break1227 elif isinstance(action,Bet):1228 my_action = Bet(brain.MID*stack_size)1229 self.my_last_action['betfromaf'] = True1230 break1231 else:1232 if randint(0,99) < 50:1233 my_action = Check()1234 else:1235 my_action = Bet(randint(int(self.min_bet),int(brain.LOW*stack_size)))1236 elif last_action == CHECK:1237 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))1238 elif last_action == BET:1239 if last_act[1].amount/float(stack_size) <= brain.LOW:1240 my_action = Call()1241 else:1242 my_action = Fold()1243 elif last_action == RAISE:1244 if self.my_last_action['first']:1245 if self.my_last_action['betfromaf']:1246 my_action = Fold()1247 else:1248 if last_act[1].amount/float(stack_size) <= brain.LOW:1249 my_action = Call()1250 else:1251 my_action = Fold()1252 elif self.my_last_action['action'] == BET:1253 if last_act[1].amount/float(stack_size) <= brain.LOW:1254 my_action = Call()1255 else:1256 my_action = Fold()1257 elif eq == 2:1258 if self.first:1259 my_action = Bet(brain.MID*stack_size)1260 if brain.opp_stats['AF'] < .5:1261 self.my_last_action['betfromaf'] = True1262 elif last_action == CHECK:1263 if randint(0,99) < 50:1264 my_action = Check()1265 else:1266 my_action = Bet(brain.MID*stack_size)1267 elif last_action == BET:1268 if last_act[1].amount/float(stack_size) <= brain.MID:1269 my_action = Call()1270 else:1271 my_action = Fold()1272 elif last_action == RAISE:1273 if self.my_last_action['first']:1274 if self.my_last_action['betfromaf']:1275 if last_act[1].amount/float(stack_size) <= brain.MID:1276 my_action = Call()1277 else:1278 my_action = Fold()1279 else:1280 if last_act[1].amount/float(stack_size) <= brain.MID:1281 my_action = Call()1282 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1283 if brain.opp_stats['AF'] < .5:1284 my_action = Fold()1285 else:1286 my_action = Call()1287 else:1288 my_action = Fold()1289 elif self.my_last_action['action'] == BET:1290 if last_act[1].amount/float(stack_size) <= brain.LOW:1291 my_action = Call()1292 else:1293 my_action = Fold()1294 elif eq == 3:1295 if self.first:1296 my_action = Bet(randint(int(brain.LOW*stack_size),int(brain.MID*stack_size)))1297 elif last_action == CHECK:1298 my_action = Bet(brain.MID*stack_size)1299 elif last_action == BET:1300 if last_act[1].amount/float(stack_size) <= brain.LOW:1301 my_action = Raise(brain.LOW*stack_size)1302 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1303 my_action = Call()1304 else:1305 my_action = Fold()1306 elif last_action == RAISE:1307 if self.my_last_action['first']:1308 if brain.opp_stats['AF'] < .5:1309 my_action = Fold()1310 elif last_act[1].amount/float(stack_size) <= brain.MID:1311 my_action = Call()1312 else:1313 my_action = Fold()1314 elif self.my_last_action['action'] == BET:1315 if last_act[1].amount/float(stack_size) <= brain.HIGH:1316 my_action = Call()1317 else:1318 my_action = Fold()1319 elif self.my_last_action['action'] == RAISE: 1320 my_action = Call()1321 elif eq == 4:1322 if self.first:1323 my_action = Bet(randint(int(brain.MID*stack_size),int(brain.HIGH*stack_size)))1324 elif last_action == CHECK:1325 my_action = Bet(brain.MID*stack_size)1326 elif last_action == BET:1327 my_action = Raise(brain.MID*stack_size)1328 elif last_action == RAISE:1329 if self.my_last_action['first']:1330 if last_act[1].amount/float(stack_size) <= brain.MID:1331 my_action = Call()1332 else:1333 my_action = Raise(stack_size)1334 elif self.my_last_action['action'] == BET:1335 my_action = Call()1336 elif self.my_last_action['action'] == RAISE:1337 my_action = Raise(stack_size)1338 else:1339 print "turn: umm...", self.pfeq, brain.ev1340 return my_action1341 def river(self, brain):1342 #it's the river, tell me how to play1343 last_act = brain.actions[-1]1344 last_action = brain.classify(last_act[1])1345 if DEBUG: print "opp last action was",last_act, "and pfeq is", self.pfeq1346 if DEBUG: print "legal actions:", brain.legal1347 self.first = last_action == DEAL1348 stack_size = brain.pip+brain.stack1349 my_action = None1350 eq = self.parameterize(brain.ev)1351 if eq == 2:1352 if self.first or last_action == CHECK:1353 my_action = Bet(brain.MID*stack_size)1354 elif last_action == BET:1355 if last_act[1].amount/float(stack_size) <= brain.MID:1356 my_action = Call()1357 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1358 if brain.opp_stats['AF'] > 1.5:1359 my_action = Call()1360 else:1361 my_action = Fold()1362 else:1363 my_action = Fold()1364 elif last_action == RAISE:1365 if self.my_last_action['action'] == BET:1366 if last_act[1].amount/float(stack_size) <= brain.LOW:1367 my_act = Call()1368 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1369 if brain.opp_stats['INCR'] < .2 : #or brain.opp_stats['CHBR'] < .4 or cb1370 my_action = Fold()1371 else:1372 my_action = Call()1373 else:1374 my_action = Fold()1375 elif eq == 3:1376 if self.first or last_action == CHECK:1377 my_action = Bet(brain.MID*stack_size)1378 elif last_action == BET:1379 if last_act[1].amount/float(stack_size) <= brain.MID:1380 my_action = Raise(brain.MID*stack_size)1381 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1382 #if opp never raised b4: fold1383 my_action = Call()1384 else:1385 my_action = Fold()1386 elif last_action == RAISE:1387 if self.my_last_action['first']:1388 if brain.opp_stats['AF'] < .5:1389 my_action = Fold()1390 else:1391 if last_act[1].amount/float(stack_size) <= brain.MID:1392 my_action = Call()1393 elif last_act[1].amount/float(stack_size) <= brain.HIGH:1394 #if op never raised in this hand: Fold1395 my_action = Call()1396 else:1397 my_action = Fold()1398 if self.my_last_action['action'] == BET:1399 #if opp has not raised this hand: Fold1400 my_action = Call()1401 elif eq == 4:1402 if self.first:1403 if stack_size < 200 or stack_size > 600:1404 my_action = Bet(stack_size)1405 else:1406 if randint(0,99) < 50:1407 my_action = Bet(brain.HIGH*stack_size)1408 else:1409 my_action = Bet(brain.MID*stack_size)1410 elif last_action == CHECK:1411 my_action = Bet(brain.MID*stack_size)1412 elif last_action == BET:1413 my_action = Raise(brain.MID*stack_size)1414 elif last_action == RAISE:1415 my_action = Raise(stack_size)...

Full Screen

Full Screen

TheBostonDerbyA.py

Source:TheBostonDerbyA.py Github

copy

Full Screen

1# 6.912 Pokerbots AI Competition 20112# Team: The Boston Derby3# Members: Owen Derby, Luke Mooney, Gregory Pusczko, Cory Kays4from random import randint5from pokerbots.engine.game import Raise, Check, Call, Bet, Fold, Deal, Show, Won, Post6from collections import deque7from pokereval import PokerEval8from pokerbots.player.ourbot import *9LOW = .0210MID = .0811HIGH = .1512CHECK, BET, RAISE, FOLD, CALL, DEAL, SHOW, WON, POST = range(9)13PREFLOP, FLOP, TURN, RIVER = range(4)14DEBUG = False15class TheDerbs(TheBostonDerby):16 def __init__(self):17 TheBostonDerby.__init__(self)18 self.name = "TheDerbs"19 self.bot = thebostonderbya()20class thebostonderbya:21 def __init__(self):22 """This is a very simple player that demonstrates the API and is a good23 template for getting started24 """25 self.hand = None26 self.stack = None27 self.pip = None28 self.button = None29 self.opponent = None30 self.bb = None31 self.sb = None32 self.hands_played = None33 self.board = None34 self.legal = None35 self.actions = None36 self.last = None37 self.pot = None38 # my name39 self.name = "thebostonderbya"40 41 self.pfeq = 0 #value between 0 and 4 to indicate what range42 # our preflop equity was in. 0 = 0-20%, 1=20-40%, etc43 self.my_last_action = {'action':FOLD, 'first':False, 'reraise':False, 'street':PREFLOP, 'betfromaf':False, 'amount':0}44 def parameterize(self, equity):45 #return min(int(equity*100)/20,4)46 ev = equity*10047 if ev < 20:48 return 049 elif ev < 40:50 return 151 elif ev < 50:52 return 253 elif ev < 60:54 return 355 return 456 57 def hand_confidence(self,brain):58 stack_size = brain.stack + brain.pip59 brain.bound = stack_size60 if not brain.board.flop():61 if stack_size < 30*brain.bb:62 if brain.ev < .7: #if small stack, and not one of best hands63 brain.bound = 0 # fold64 else:65 brain.bound = -166 else:67 if brain.ev > .9:# or (brain.stats['pfhb'] > 0.25 and brain.hands_played > 12):68 brain.bound = stack_size69 elif brain.ev > .8:70 brain.bound = int(HIGH * stack_size)71 elif brain.ev > .5:72 brain.bound = 5 * brain.bb73 else:74 brain.bound = brain.bb75 else:76 if brain.ev < .33:77 brain.bound = min(int(max(brain.pot*brain.ev/(1-3*brain.ev),0)),stack_size)78 def respond(self, brain):79 """Based on your game state variables (see the __init__), make a80 decision and return an action. If you return an illegal action, the81 engine will automatically fold you82 """83 self.min_bet = max(2*brain.opponent['pip'],self.bb)84 if not brain.board.flop():85 self.pfeq = self.parameterize(brain.ev)86 my_action = self.preflop(brain)87 self.my_last_action['street'] = PREFLOP88 if DEBUG: print "taking action",my_action, "from the preflop"89 elif not brain.board.turn():90 my_action = self.flop(brain)91 self.my_last_action['street'] = FLOP92 if DEBUG: print "taking action",my_action, "from the flop"93 elif not brain.board.river():94 my_action = self.turn(brain)95 self.my_last_action['street'] = TURN96 if DEBUG: print "taking action",my_action, "from the turn"97 else:98 my_action = self.river(brain)99 self.my_last_action['street'] = RIVER100 if DEBUG: print "taking action",my_action, "from the river"101 102 # Check that our action is legal103 for action in brain.legal:104 if isinstance(action,type(my_action)):105 break106 else:107 if isinstance(my_action, Raise):108 for action in brain.legal:109 if isinstance(action,Call):110 my_action = Call()111 break112 else:113 my_action = None114 else:115 my_action = None116 # check fold if we selected no action117 if my_action == None:118 for action in brain.legal:119 if isinstance(action, Check):120 my_action = action121 break122 else:123 my_action = Fold()124 self.hand_confidence(brain)125 self.my_last_action['first'] = self.first126 action = brain.classify(my_action)127 if action in [RAISE,BET]:128 if brain.bound == -1:129 my_action.amount = brain.pip+brain.stack130 else:131 my_action.amount = int(min(my_action.amount, brain.bound))132 if my_action.amount < self.min_bet:133 for action in brain.legal:134 if isinstance(action, Call):135 my_action = action136 self.my_last_action['amount'] = brain.opponent['pip']137 break138 else:139 my_action = Check()140 141 else:142 self.my_last_action['amount'] = my_action.amount143 self.my_last_action['action'] = brain.classify(my_action)144 if DEBUG: print "taking action",my_action145 return my_action146 147 def new_hand(self):148 self.my_last_action = {'action':FOLD, 'first':False, 'reraise':False, 'street':PREFLOP, 'betfromaf':False, 'amount':0}149 150 def preflop(self, brain):151 #it's preflop, tell me how to play152 last_act = brain.actions[-1]153 last_action = brain.classify(last_act[1])154 if DEBUG: print "opp last action was",last_act, "and pfeq is", self.pfeq155 if DEBUG: print "legal actions:", brain.legal156 self.first = last_action == POST157 stack_size = brain.pip+brain.stack158 my_action = None159 160 if self.pfeq == 0:161 if self.first:162 my_action = Call()163 if last_action == RAISE:164 my_action = Fold()165 else:166 my_action = Check()167 elif self.pfeq == 1:168 if self.first:169 my_action = Call()170 elif last_action == CALL:171 my_action = Raise(randint(int(LOW*stack_size),int(MID*stack_size))) #low-mid172 elif last_action == RAISE:173 if self.my_last_action['action'] == CHECK or last_act[1].amount/float(stack_size) > LOW: #TODO: this should be pot odds!174 my_action = Fold()175 else:176 my_action = Call()177 elif self.pfeq == 2:178 if self.first:179 my_action = Raise(LOW*stack_size)180 elif last_action == CALL:181 my_action = Raise(randint(int(LOW*stack_size),int(MID*stack_size))) #low to mid182 elif last_action == RAISE:183 if self.my_last_action['action'] == CHECK or last_act[1].amount/float(stack_size) > MID:184 my_action = Fold()185 else:186 my_action = Call()187 elif self.pfeq == 3:188 if self.first:189 my_action = Raise(LOW*stack_size)190 elif last_action == CALL:191 my_action = Raise(MID*stack_size)192 elif last_action == RAISE:193 if self.my_last_action['action'] == CHECK or last_act[1].amount/float(stack_size) > MID:194 my_action = Fold()195 else:196 my_action = Call()197 elif self.pfeq == 4:198 if self.first or last_action == RAISE:199 if self.my_last_action['action'] == RAISE:200 if self.my_last_action['reraise']:201 my_action = Raise(stack_size)202 else:203 my_action = Raise(self.min_bet)204 self.my_last_action['reraise'] = True205 else:206 my_action = Raise(MID*stack_size)207 elif last_action == CALL:208 my_action = Raise(LOW*stack_size)209 else:210 print "preflop: umm...", self.pfeq, brain.ev211 if DEBUG: print "and action",my_action212 return my_action213 214 def flop(self, brain):215 #it's the flop, tell me how to play216 last_act = brain.actions[-1]217 last_action = brain.classify(last_act[1])218 if DEBUG: print "opp last action was",last_act, "and pfeq is", self.pfeq219 if DEBUG: print "legal actions:", brain.legal220 self.first = last_action == DEAL221 stack_size = brain.pip+brain.stack222 my_action = None223 eq = self.parameterize(brain.ev)224 if self.pfeq == 0:225 if eq == 0:226 if self.first or last_action == CHECK:227 my_action = Check()228 elif last_action in [BET, RAISE]:229 my_action = Fold()230 elif eq == 1:231 if self.first:232 if randint(0,99) < 50:233 my_action = Check()234 else:235 my_action = Bet(self.min_bet)236 elif last_action == CHECK:237 my_action = Check()238 elif last_action in [BET, RAISE]:239 if last_act[1].amount/float(stack_size) <= LOW:240 my_action = Call()241 else:242 my_action = Fold()243 elif eq == 2:244 if brain.opp_stats['AF'] < .5:245 for action in brain.legal:246 if isinstance(action,Raise) or isinstance(action,Bet):247 my_action = action248 self.my_last_action['betfromaf'] = True249 break250 elif self.first:251 my_action = Bet(LOW*stack_size)252 elif last_action == CHECK:253 if randint(0,99) < 50:254 my_action = Check()255 else:256 my_action = Bet(LOW*stack_size)257 elif last_action == BET:258 if last_act[1].amount/float(stack_size) <= LOW:259 my_action = Call()260 else:261 my_action = Fold()262 elif last_action == RAISE:263 if self.my_last_action['first']:264 if last_act[1].amount/float(stack_size) <= LOW:265 my_act = Call()266 elif last_act[1].amount/float(stack_size) <= HIGH:267 if brain.opp_stats['INCR'][0] < .2 : #or brain.opp_stats['cr'] < .4268 my_action = Fold()269 else:270 my_action = Call()271 else:272 my_action = Fold()273 elif self.my_last_action['betfromaf']:274 my_action = Fold()275 elif self.my_last_action['action'] == BET:276 if last_act[1].amount == 2*self.my_last_action['amount']:277 my_action = Call()278 else:279 my_action = Fold()280 elif eq == 3:281 if self.first or last_action == CHECK:282 my_action = Bet(randint(int(LOW*stack_size),int(MID*stack_size))) #low-mid283 elif last_action == BET:284 if last_act[1].amount/float(stack_size) <= MID:285 my_action = Call()286 else:287 my_action = Fold()288 elif last_action == RAISE:289 if self.my_last_action['first']:290 if last_act[1].amount/float(stack_size) <= MID:291 my_action = Call()292 else:293 my_action = Fold()294 else: #then I must have bet295 if last_act[1].amount == 2*self.my_last_action['amount']:296 my_action = Call()297 else:298 my_action = Fold()299 elif eq == 4:300 if self.first:301 my_action = Bet(randint(int(MID*stack_size),int(HIGH*stack_size))) #mid_high302 elif last_action == CHECK:303 my_action = Bet(int(LOW*stack_size))304 elif last_action == BET:305 my_action = Raise(int(MID*stack_size))306 elif last_action == RAISE:307 if self.my_last_action['first']:308 if last_act[1].amount/float(stack_size) <= MID:309 my_action = Call()310 else:311 my_action = Raise(stack_size)312 elif self.my_last_action['action'] == BET:313 my_action = Raise(int(MID*stack_size))314 elif self.my_last_action['action'] == RAISE:315 my_action = Raise(stack_size)316 elif self.pfeq == 1:317 if eq == 0:318 if self.first or last_action == CHECK:319 my_action = Check()320 elif last_action in [BET, RAISE]:321 my_action = Fold()322 elif eq == 1:323 if self.first:324 if randint(0,99) < 50:325 my_action = Check()326 else:327 my_action = Bet(randint(self.min_bet,int(LOW*stack_size)))328 elif last_action == CHECK:329 my_action = Check()330 elif last_action in [BET, RAISE]:331 if last_act[1].amount/float(stack_size) <= LOW:332 my_action = Call()333 else:334 my_action = Fold()335 elif eq == 2:336 if brain.opp_stats['AF'] < .5:337 for action in brain.legal:338 if isinstance(action,Raise) or isinstance(action,Bet):339 my_action = action340 self.my_last_action['betfromaf'] = True341 break342 elif self.first:343 my_action = Bet(randint(int(LOW*stack_size),int(MID*stack_size)))344 elif last_action == CHECK:345 if randint(0,99) < 50:346 my_action = Check()347 else:348 my_action = Bet(LOW*stack_size)349 elif last_action == BET:350 if last_act[1].amount/float(stack_size) <= MID:351 my_action = Call()352 else:353 my_action = Fold()354 elif last_action == RAISE:355 if self.my_last_action['first']:356 if last_act[1].amount/float(stack_size) <= LOW:357 my_act = Call()358 elif last_act[1].amount/float(stack_size) <= HIGH:359 if brain.opp_stats['INCR'][0] < .2 : #or brain.opp_stats['cr'] < .4360 my_action = Fold()361 else:362 my_action = Call()363 else:364 my_action = Fold()365 elif self.my_last_action['betfromaf']:366 if last_act[1].amount/float(stack_size) <= LOW:367 my_act = Call()368 else:369 my_action = Fold()370 elif self.my_last_action['action'] == BET:371 if last_act[1].amount/float(stack_size) <= MID:372 my_action = Call()373 else:374 my_action = Fold()375 elif eq == 3:376 if self.first or last_action == CHECK:377 my_action = Bet(int(MID*stack_size))378 elif last_action == BET:379 if last_act[1].amount/float(stack_size) <= LOW:380 my_action = Raise(int(MID*stack_size))381 elif last_act[1].amount/float(stack_size) <= HIGH:382 my_action = Call()383 else:384 my_action = Fold()385 elif last_action == RAISE:386 if self.my_last_action['first']:387 if last_act[1].amount/float(stack_size) <= MID:388 my_action = Call()389 else:390 my_action = Fold()391 else: #then I must have bet392 if last_act[1].amount == 2*self.my_last_action['amount']:393 my_action = Call()394 else:395 my_action = Fold()396 elif eq == 4:397 if self.first:398 my_action = Bet(randint(int(MID*stack_size),int(HIGH*stack_size))) #mid_high399 elif last_action == CHECK:400 my_action = Bet(int(LOW*stack_size))401 elif last_action == BET:402 my_action = Raise(int(MID*stack_size))403 elif last_action == RAISE:404 if self.my_last_action['first']:405 if last_act[1].amount/float(stack_size) <= MID:406 my_action = Call()407 else:408 my_action = Raise(stack_size)409 elif self.my_last_action['action'] == BET:410 my_action = Raise(int(MID*stack_size))411 elif self.my_last_action['action'] == RAISE:412 my_action = Raise(stack_size)413 elif self.pfeq == 2:414 if eq == 0:415 if self.first:416 if brain.opp_stats['AF'] < .5:417 my_action = Bet(int(MID*stack_size))418 else:419 my_action = Check()420 elif last_action == CHECK:421 my_action = Bet(MID*stack_size)422 elif last_action in [BET, RAISE]:423 my_action = Fold()424 elif eq == 1:425 if self.first:426 if randint(0,99) < 50:427 my_action = Check()428 else:429 my_action = Bet(randint(self.min_bet,int(LOW*stack_size)))430 elif last_action == CHECK:431 my_action = Check()432 elif last_action == BET:433 if last_act[1].amount/float(stack_size) <= MID:434 my_action = Call()435 else:436 my_action = Fold()437 elif last_action == RAISE:438 if last_act[1].amount/float(stack_size) <= LOW:439 my_action = Call()440 else:441 my_action = Fold()442 elif eq == 2:443 if self.first:444 if brain.opp_stats['AF'] < .5:445 my_action = Bet(int(MID*stack_size))446 self.my_last_action['betfromaf'] = True447 else:448 my_action = Check()449 elif last_action == CHECK:450 my_action = Check()451 elif last_action == BET:452 if last_act[1].amount/float(stack_size) <= MID:453 my_action = Call()454 else:455 my_action = Fold()456 elif last_action == RAISE:457 if last_act[1].amount/float(stack_size) <= LOW:458 my_action = Call()459 else:460 my_action = Fold()461 elif eq == 3:462 if self.first or last_action == Check:463 my_action = Bet(int(MID*stack_size))464 elif last_action == BET:465 if last_act[1].amount/float(stack_size) <= LOW:466 my_action = Raise(int(MID*stack_size))467 elif last_act[1].amount/float(stack_size) <= HIGH:468 my_action = Call()469 else:470 my_action = Fold()471 elif last_action == RAISE:472 if self.my_last_action['first']:473 if last_act[1].amount/float(stack_size) <= HIGH:474 my_action = Call()475 else:476 my_action = Fold()477 elif self.my_last_action['action'] == BET:478 if last_act[1].amount == 2*self.my_last_action['amount']:479 my_action = Call()480 else:481 my_action = Fold()482 else:483 my_action == Call()484 elif eq == 4:485 if self.first:486 my_action = Bet(randint(int(MID*stack_size),int(HIGH*stack_size)))487 elif last_action == CHECK:488 my_action = Bet(int(MID*stack_size))489 elif last_action == BET:490 my_action = Raise(int(MID*stack_size))491 elif last_action == RAISE:492 if self.my_last_action['first']:493 if last_act[1].amount/float(stack_size) <= MID:494 my_action = Call()495 else:496 my_action = Raise(stack_size)497 elif self.my_last_action['action'] == RAISE:498 my_action = Raise(stack_size)499 else:500 my_action = Raise(int(MID*stack_size))501 elif self.pfeq == 3:502 if eq == 0:503 if self.first:504 if brain.opp_stats['AF'] < .5:505 my_action = Bet(int(MID*stack_size))506 else:507 my_action = Check()508 elif last_action == CHECK:509 my_action = Bet(int(MID*stack_size))510 elif last_action == BET:511 if last_act[1].amount/float(stack_size) <= LOW:512 my_action = Call()513 else:514 my_action = Fold()515 elif last_action == RAISE:516 my_action = Fold()517 elif eq == 1:518 if self.first:519 if randint(0,99) < 50:520 my_action = Check()521 else:522 my_action = Bet(randint(self.min_bet,int(LOW*stack_size)))523 elif last_action == CHECK:524 my_action = Bet(int(LOW*stack_size))525 elif last_action == BET:526 if last_act[1].amount/float(stack_size) <= MID:527 my_action = Call()528 else:529 my_action = Fold()530 elif last_action == RAISE:531 if last_act[1].amount/float(stack_size) <= LOW:532 my_action = Call()533 else:534 my_action = Fold()535 elif eq == 2:536 if self.first:537 if brain.opp_stats['AF'] < .5:538 my_action = Bet(int(MID*stack_size))539 self.my_last_action['betfromaf'] = True540 else:541 my_action = Bet(int(LOW*stack_size))542 elif last_action == CHECK:543 my_action = Check()544 elif last_action == BET:545 if last_act[1].amount/float(stack_size) <= MID:546 my_action = Call()547 else:548 my_action = Fold()549 elif last_action == RAISE:550 if last_act[1].amount/float(stack_size) <= MID:551 my_action = Call()552 else:553 my_action = Fold()554 elif eq == 3:555 if self.first or last_action == Check:556 my_action = Bet(int(MID*stack_size))557 elif last_action == BET:558 if last_act[1].amount/float(stack_size) <= LOW:559 my_action = Raise(int(MID*stack_size))560 elif last_act[1].amount/float(stack_size) <= HIGH:561 my_action = Call()562 else:563 my_action = Fold()564 elif last_action == RAISE:565 if self.my_last_action['first']:566 if last_act[1].amount/float(stack_size) <= MID:567 my_action = Raise(self.min_bet)568 elif last_act[1].amount/float(stack_size) <= HIGH:569 my_action = Call()570 else:571 my_action = Fold()572 elif self.my_last_action['action'] == BET:573 if last_act[1].amount == 2*self.my_last_action['amount']:574 my_action = Call()575 else:576 my_action = Fold()577 else:578 my_action = Call()579 elif eq == 4:580 if self.first:581 my_action = Check()582 elif last_action == CHECK:583 my_action = Bet(int(LOW*stack_size))584 elif last_action == BET:585 my_action = Call()586 elif last_action == RAISE:587 if self.my_last_action['first']:588 if last_act[1].amount/float(stack_size) <= MID:589 my_action = Call()590 else:591 my_action = Raise(stack_size)592 elif self.my_last_action['action'] == BET:593 my_action = Raise(int(MID*stack_size))594 elif self.my_last_action['action'] == RAISE:595 my_action = Raise(stack_size)596 elif self.pfeq == 4:597 if eq == 0:598 if self.first or last_action == CHECK:599 my_action = Check()600 elif last_action in [BET, RAISE]:601 my_action = Fold()602 elif eq == 1:603 if self.first or last_action == CHECK:604 my_action = Bet(int(MID*stack_size))605 elif last_action == BET:606 if last_act[1].amount/float(stack_size) <= LOW:607 my_action = Call()608 else:609 my_action = Fold()610 elif last_action == RAISE:611 if last_act[1].amount == 2*self.my_last_action['amount']:612 my_action = Call()613 else:614 my_action = Fold()615 elif eq == 2:616 if self.first or last_action == CHECK:617 my_action = Bet(int(MID*stack_size))618 elif last_action == BET:619 if last_act[1].amount/float(stack_size) <= MID:620 my_action = Raise(int(MID*stack_size))621 elif last_act[1].amount/float(stack_size) <= HIGH:622 my_action = Call()623 else:624 my_action = Fold()625 elif last_action == RAISE:626 if self.my_last_action['first']:627 if last_act[1].amount/float(stack_size) <= MID:628 my_action = Raise(self.min_bet)629 self.my_last_action['reraise'] = True630 else:631 my_action = Fold()632 elif self.my_last_action['action'] == BET:633 if last_act[1].amount/float(stack_size) <= LOW:634 my_action = Call()635 else:636 my_action = Fold()637 elif self.my_last_action['reraise']:638 if last_act[1].amount/float(stack_size) <= MID:639 my_action = Call()640 else:641 my_action = Fold()642 else:643 my_action = Call()644 elif eq == 3:645 if self.first:646 my_action = Bet(randint(int(LOW*stack_size),int(MID*stack_size)))647 elif last_action == CHECK:648 my_action = Bet(int(MID*stack_size))649 elif last_action == BET:650 if last_act[1].amount/float(stack_size) <= MID:651 my_action = Raise(2*self.min_bet)652 elif last_act[1].amount/float(stack_size) <= HIGH:653 my_action = Call()654 else:655 my_action = Fold()656 elif last_action == RAISE:657 if self.my_last_action['first']:658 if last_act[1].amount/float(stack_size) <= HIGH:659 my_action = Call()660 else:661 my_action = Fold()662 elif self.my_last_action['action'] == BET:663 if last_act[1].amount == 2*self.my_last_action['amount']:664 my_action = Call()665 else:666 my_action = Fold()667 else:668 my_action = Call()669 elif eq == 4:670 if self.first:671 my_action = Bet(randint(int(MID*stack_size),int(HIGH*stack_size)))672 elif last_action == CHECK:673 my_action = Bet(int(LOW*stack_size))674 elif last_action == BET:675 my_action = Raise(int(MID*stack_size))676 elif last_action == RAISE:677 if self.my_last_action['first']:678 if last_act[1].amount/float(stack_size) <= MID:679 my_action = Call()680 else:681 my_action = Raise(stack_size)682 elif self.my_last_action['action'] == BET:683 my_action = Raise(int(MID*stack_size))684 else:685 my_action = Raise(stack_size)686 else:687 print "flop: umm...", self.pfeq, brain.ev688 return my_action689 def turn(self, brain):690 #it's the turn, tell me how to play691 last_act = brain.actions[-1]692 last_action = brain.classify(last_act[1])693 if DEBUG: print "opp last action was",last_act, "and pfeq is", self.pfeq694 if DEBUG: print "legal actions:", brain.legal695 self.first = last_action == DEAL696 stack_size = brain.pip+brain.stack697 my_action = None698 eq = self.parameterize(brain.ev)699 if self.pfeq == 0:700 if eq == 0:701 if self.first:702 return Check()703 elif last_action == BET:704 if last_act[1].amount == 2*self.my_last_action['amount']:705 my_action = Call()706 else:707 my_action = Fold()708 elif last_action == CHECK:709 #ignoring condition on previous betting710 if randint(0,99) < 50:711 my_action = Check()712 else:713 my_action = Bet(MID*stack_size)714 elif last_action == RAISE:715 my_action = Fold()716 elif eq == 1:717 if brain.opp_stats['AF'] < .5:718 for action in brain.legal:719 if isinstance(action,Raise):720 my_action = Raise(MID*stack_size)721 self.my_last_action['betfromaf'] = True722 break723 elif isinstance(action,Bet):724 my_action = Bet(MID*stack_size)725 self.my_last_action['betfromaf'] = True726 break727 elif self.first:728 if randint(0,99) < 50:729 my_action = Check()730 else:731 my_action = Bet(randint(self.min_bet,int(LOW*stack_size)))732 elif last_action == CHECK:733 my_action = Bet(randint(int(LOW*stack_size),int(MID*stack_size)))734 elif last_action == BET:735 if last_act[1].amount/float(stack_size) <= LOW:736 my_action = Call()737 else:738 my_action = Fold()739 elif last_action == RAISE:740 if self.my_last_action['first']:741 if last_act[1].amount == 2*self.my_last_action['amount']:742 my_action = Call()743 else:744 my_action = Fold()745 else:746 my_action = Fold()747 elif eq == 2:748 if brain.opp_stats['AF'] < .5:749 for action in brain.legal:750 if isinstance(action,Raise):751 my_action = Raise(MID*stack_size)752 self.my_last_action['betfromaf'] = True753 break754 elif isinstance(action,Bet):755 my_action = Bet(MID*stack_size)756 self.my_last_action['betfromaf'] = True757 break758 elif self.first:759 my_action = Bet(LOW*stack_size)760 elif last_action == CHECK:761 if randint(0,99) < 50:762 my_action = Check()763 else:764 my_action = Bet(LOW*stack_size)765 elif last_action == BET:766 if last_act[1].amount/float(stack_size) <= LOW:767 my_action = Call()768 elif last_act[1].amount/float(stack_size) <= MID:769 if brain.opp_stats['AF'] > 1.5:770 my_action = Call()771 else:772 my_action = Fold()773 else:774 my_action = Fold()775 elif last_action == RAISE:776 if self.my_last_action['first']:777 if last_act[1].amount/float(stack_size) <= LOW:778 my_action = Call()779 elif last_act[1].amount/float(stack_size) <= MID:780 if brain.opp_stats['INCR'][0] < .2 : #or brain.opp_stats['cr'] < .4 or this is a continutation bet781 my_action = Fold()782 else:783 my_action = Call()784 else:785 my_action = Fold()786 elif self.my_last_action['betfromaf']:787 my_action = Fold()788 elif eq == 3:789 if self.first or last_action == CHECK:790 my_action = Bet(randint(int(LOW*stack_size),int(MID*stack_size)))791 elif last_action == BET:792 if last_act[1].amount/float(stack_size) <= MID:793 my_action = Call()794 else:795 my_action = Fold()796 elif last_action == RAISE:797 if self.my_last_action['first']:798 if brain.opp_stats['AF'] < .5:799 my_action = Fold()800 else:801 if last_act[1].amount/float(stack_size) <= MID:802 my_action = Call()803 else:804 my_action = Fold()805 elif self.my_last_action['action'] == BET:806 #if opp never bet/raised: fold807 my_action = Call()808 elif eq == 4:809 if self.first:810 my_action = Bet(randint(int(MID*stack_size),int(HIGH*stack_size)))811 elif last_action == CHECK:812 my_action = Bet(LOW*stack_size)813 elif last_action == BET:814 my_action = Bet(MID*stack_size)815 elif last_action == RAISE:816 if self.my_last_action['first']:817 if last_act[1].amount/float(stack_size) <= MID:818 my_action = Call()819 else:820 my_action = Raise(stack_size)821 elif self.my_last_action['action'] == BET:822 my_action = Raise(MID*stack_size)823 elif self.my_last_action['action'] == RAISE:824 my_action = Raise(stack_size)825 elif self.pfeq == 1:826 if eq == 0:827 if self.first:828 return Check()829 elif last_action == BET:830 if last_act[1].amount == 2*self.my_last_action['amount']:831 my_action = Call()832 else:833 my_action = Fold()834 elif last_action == CHECK:835 #ignoring condition on previous betting836 if randint(0,99) < 50:837 my_action = Check()838 else:839 my_action = Bet(MID*stack_size)840 elif last_action == RAISE:841 my_action = Fold()842 elif eq == 1:843 if self.first:844 if brain.opp_stats['AF'] < .5:845 for action in brain.legal:846 if isinstance(action,Raise):847 my_action = Raise(MID*stack_size)848 self.my_last_action['betfromaf'] = True849 break850 elif isinstance(action,Bet):851 my_action = Bet(MID*stack_size)852 self.my_last_action['betfromaf'] = True853 break854 else:855 if randint(0,99) < 50:856 my_action = Check()857 else:858 my_action = Bet(randint(self.min_bet,int(LOW*stack_size)))859 elif last_action == CHECK:860 my_action = Check()861 elif last_action == BET:862 if last_act[1].amount/float(stack_size) <= LOW:863 my_action = Call()864 else:865 my_action = Fold()866 elif eq == 2:867 if self.first:868 if brain.opp_stats['AF'] < .5:869 for action in brain.legal:870 if isinstance(action,Raise):871 my_action = Raise(MID*stack_size)872 self.my_last_action['betfromaf'] = True873 break874 elif isinstance(action,Bet):875 my_action = Bet(MID*stack_size)876 self.my_last_action['betfromaf'] = True877 break878 else:879 my_action = Bet(LOW*stack_size)880 elif last_action == CHECK:881 if randint(0,99) < 50:882 my_action = Check()883 else:884 my_action = Bet(LOW*stack_size)885 elif last_action == BET:886 if last_act[1].amount/float(stack_size) <= LOW:887 my_action = Call()888 elif last_act[1].amount/float(stack_size) <= MID:889 if brain.opp_stats['AF'] > 1.5:890 my_action = Call()891 else:892 my_action = Fold()893 else:894 my_action = Fold()895 elif last_action == RAISE:896 if self.my_last_action['first']:897 if self.my_last_action['betfromaf']:898 if last_act[1].amount/float(stack_size) <= MID:899 my_action = Call()900 else:901 my_action = Fold()902 else:903 if last_act[1].amount/float(stack_size) <= LOW:904 my_action = Call()905 elif last_act[1].amount/float(stack_size) <= HIGH:906 if brain.opp_stats['INCR'][0] < .2 : #or brain.opp_stats['cr'] < .4 or this is a continutation bet907 my_action = Fold()908 else:909 my_action = Call()910 else:911 my_action = Fold()912 elif self.my_last_action['action'] == BET:913 if last_act[1].amount == 2*self.my_last_action['amount']:914 my_action = Call()915 else:916 my_action = Fold()917 elif eq == 3:918 if self.first:919 my_action = Bet(randint(int(LOW*stack_size),int(MID*stack_size)))920 elif last_action == CHECK:921 if stack_size > 1.7*400:922 my_action = Bet(stack_size)923 else:924 my_action = Bet(randint(int(LOW*stack_size),int(MID*stack_size)))925 elif last_action == BET:926 if last_act[1].amount/float(stack_size) <= MID:927 my_action = Call()928 elif last_act[1].amount/float(stack_size) <= HIGH:929 if randint(0,99) < 50:930 my_action = Call()931 else:932 my_action = Fold()933 else:934 my_action = Fold()935 elif last_action == RAISE:936 if self.my_last_action['first']:937 if brain.opp_stats['AF'] < .5:938 my_action = Fold()939 else:940 if last_act[1].amount/float(stack_size) <= MID:941 my_action = Call()942 else:943 my_action = Fold()944 else:945 #if opp has not raised/bet this hand: fold946 my_action = Call()947 elif eq == 4:948 if self.first:949 my_action = Bet(randint(int(MID*stack_size),int(HIGH*stack_size)))950 elif last_action == CHECK:951 my_action = Bet(LOW*stack_size)952 elif last_action == BET:953 my_action = Raise(MID*stack_size)954 elif last_action == RAISE:955 if self.my_last_action['first']:956 if last_act[1].amount/float(stack_size) <= MID:957 my_action = Call()958 else:959 my_action = Raise(stack_size)960 elif self.my_last_action['action'] == BET:961 my_action = Raise(MID*stack_size)962 elif self.my_last_action['action'] == RAISE:963 my_action = Raise(stack_size)964 elif self.pfeq == 2:965 if eq == 0:966 if self.first:967 my_action = Check()968 elif last_action == CHECK:969 if randint(0,99) < 50:970 my_action = Bet(MID*stack_size)971 else:972 my_action = Check()973 elif last_action == BET:974 if last_act[1].amount == 2*self.my_last_action['amount']:975 my_action = Call()976 else:977 my_action = Fold()978 elif last_action == RAISE:979 my_action = Fold()980 elif eq == 1:981 if self.first:982 if brain.opp_stats['AF'] < .5:983 for action in brain.legal:984 if isinstance(action,Raise):985 my_action = Raise(MID*stack_size)986 self.my_last_action['betfromaf'] = True987 break988 elif isinstance(action,Bet):989 my_action = Bet(MID*stack_size)990 self.my_last_action['betfromaf'] = True991 break992 else:993 if randint(0,99) < 50:994 my_action = Check()995 else:996 my_action = Bet(randint(self.min_bet,int(LOW*stack_size)))997 elif last_action == CHECK:998 my_action = Check()999 elif last_action == BET:1000 if last_act[1].amount/float(stack_size) <= LOW:1001 my_action = Call()1002 elif last_act[1].amount/float(stack_size) <= MID:1003 if randint(0,99) < 50:1004 my_action = Call()1005 else:1006 my_action = Fold()1007 else:1008 my_action = Fold()1009 elif last_action == RAISE:1010 if self.my_last_action['first']:1011 if self.my_last_action['betfromaf']:1012 my_action = Fold()1013 else:1014 if last_act[1].amount/float(stack_size) <= LOW:1015 my_action = Call()1016 else:1017 my_action = Fold()1018 elif eq == 2:1019 if self.first:1020 my_action = Bet(MID*stack_size)1021 elif last_action == CHECK:1022 my_action = Check()1023 elif last_action == BET:1024 if last_act[1].amount/float(stack_size) <= LOW:1025 my_action = Call()1026 elif last_act[1].amount/float(stack_size) <= MID:1027 if brain.opp_stats['AF'] > 1.5:1028 my_action = Call()1029 else:1030 my_action = Fold()1031 else:1032 my_action = Fold()1033 elif last_action == RAISE:1034 if self.my_last_action['first']:1035 if last_act[1].amount/float(stack_size) <= LOW:1036 my_action = Call()1037 elif last_act[1].amount/float(stack_size) <= HIGH:1038 if brain.opp_stats['INCR'][0] < .2 : #or brain.opp_stats['cr'] < .4 or this is a continutation bet1039 my_action = Fold()1040 else:1041 my_action = Call()1042 else:1043 my_action = Fold()1044 elif eq == 3:1045 if self.first:1046 my_action = Bet(randint(int(LOW*stack_size),int(MID*stack_size)))1047 elif last_action == CHECK:1048 if stack_size > 1.7*400:1049 my_action = Bet(stack_size)1050 else:1051 my_action = Bet(randint(int(LOW*stack_size),int(MID*stack_size)))1052 elif last_action == BET:1053 if last_act[1].amount/float(stack_size) <= MID:1054 my_action = Call()1055 elif last_act[1].amount/float(stack_size) <= HIGH:1056 if randint(0,99) < 50:1057 my_action = Call()1058 else:1059 my_action = Fold()1060 else:1061 my_action = Fold()1062 elif last_action == RAISE:1063 if self.my_last_action['first']:1064 if brain.opp_stats['AF'] < .5:1065 my_action = Fold()1066 else:1067 if last_act[1].amount/float(stack_size) <= MID:1068 my_action = Call()1069 else:1070 my_action = Fold()1071 elif self.my_last_action['action'] == BET:1072 #if opp has not raised/bet this hand: fold1073 if last_act[1].amount/float(stack_size) <= MID:1074 my_action = Call()1075 else:1076 my_action = Fold()1077 elif eq == 4:1078 if self.first:1079 my_action = Bet(randint(int(MID*stack_size),int(HIGH*stack_size)))1080 elif last_action == CHECK:1081 my_action = Bet(LOW*stack_size)1082 elif last_action == BET:1083 my_action = Raise(MID*stack_size)1084 elif last_action == RAISE:1085 if self.my_last_action['first']:1086 if last_act[1].amount/float(stack_size) <= MID:1087 my_action = Call()1088 else:1089 my_action = Raise(stack_size)1090 elif self.my_last_action['action'] == BET:1091 my_action = Raise(MID*stack_size)1092 elif self.my_last_action['action'] == RAISE:1093 my_action = Raise(stack_size)1094 elif self.pfeq == 3:1095 if eq == 0:1096 if self.first:1097 my_action = Bet(MID*stack_size)1098 elif last_action == CHECK:1099 if randint(0,99) < 50:1100 my_action = Bet(MID*stack_size)1101 else:1102 my_action = Check()1103 elif last_action == BET:1104 if last_act[1].amount == 2*self.my_last_action['amount']:1105 my_action = Call()1106 else:1107 my_action = Fold()1108 elif last_action == RAISE:1109 if self.my_last_action['first']:1110 if last_act[1].amount/float(stack_size) <= LOW:1111 my_action = Call()1112 else:1113 my_action = Fold()1114 elif self.my_last_action['action'] == BET:1115 my_action = Fold()1116 elif eq == 1:1117 if self.first:1118 if brain.opp_stats['AF'] < .5:1119 for action in brain.legal:1120 if isinstance(action,Raise):1121 my_action = Raise(MID*stack_size)1122 self.my_last_action['betfromaf'] = True1123 break1124 elif isinstance(action,Bet):1125 my_action = Bet(MID*stack_size)1126 self.my_last_action['betfromaf'] = True1127 break1128 else:1129 if randint(0,99) < 50:1130 my_action = Check()1131 else:1132 my_action = Bet(LOW*stack_size)1133 elif last_action == CHECK:1134 my_action = Bet(MID*stack_size)1135 elif last_action == BET:1136 if last_act[1].amount/float(stack_size) <= LOW:1137 my_action = Call()1138 else:1139 my_action = Fold()1140 elif last_action == RAISE:1141 if self.my_last_action['first']:1142 if self.my_last_action['betfromaf']:1143 my_action = Fold()1144 else:1145 if last_act[1].amount/float(stack_size) <= LOW:1146 my_action = Call()1147 else:1148 my_action = Fold()1149 elif self.my_last_action['action'] == BET:1150 if last_act[1].amount/float(stack_size) <= LOW:1151 my_action = Call()1152 else:1153 my_action = Fold()1154 elif eq == 2:1155 if self.first:1156 if stack_size <= .6 * 400:1157 my_action = Check()1158 else:1159 my_action = Bet(MID*stack_size)1160 elif last_action == CHECK:1161 my_action = Bet(MID*stack_size)1162 elif last_action == BET:1163 if last_act[1].amount/float(stack_size) <= LOW:1164 my_action = Raise(MID*stack_size)1165 elif last_act[1].amount/float(stack_size) <= MID:1166 if brain.opp_stats['AF'] < .5:1167 my_action = Call()1168 else:1169 my_action = Fold()1170 else:1171 my_action = Fold()1172 elif last_action == RAISE:1173 if self.my_last_action['first']:1174 if last_act[1].amount/float(stack_size) <= LOW:1175 my_action = Call()1176 elif last_act[1].amount/float(stack_size) <= HIGH:1177 if brain.opp_stats['INCR'][0] < .2 : #or brain.opp_stats['cr'] < .4 or this is a continutation bet1178 my_action = Fold()1179 else:1180 my_action = Call()1181 else:1182 my_action = Fold()1183 elif self.my_last_action['action'] == BET:1184 if last_act[1].amount/float(stack_size) <= LOW:1185 my_action = Call()1186 elif last_act[1].amount/float(stack_size) <= MID:1187 if stack_size <= .6 * 400:1188 my_action = Fold()1189 else:1190 my_action = Call()1191 else:1192 my_action = Fold()1193 elif eq == 3:1194 if self.first:1195 my_action = Bet(randint(int(LOW*stack_size),int(MID*stack_size)))1196 elif last_action == CHECK:1197 if stack_size > 1.7*400:1198 my_action = Bet(stack_size)1199 else:1200 my_action = Bet(randint(int(LOW*stack_size),int(MID*stack_size)))1201 elif last_action == BET:1202 if last_act[1].amount/float(stack_size) <= MID:1203 my_action = Raise(HIGH*stack_size)1204 elif last_act[1].amount/float(stack_size) <= HIGH:1205 my_action = Call()1206 else:1207 my_action = Fold()1208 elif last_action == RAISE:1209 if self.my_last_action['first']:1210 if last_act[1].amount/float(stack_size) <= MID:1211 my_action = Call()1212 elif last_act[1].amount/float(stack_size) <= HIGH:1213 if brain.opp_stats['AF'] < .5:1214 my_action = Fold()1215 else:1216 my_action = Call()1217 else:1218 my_action = Fold()1219 elif self.my_last_action['action'] == BET:1220 #if opp has not raised/bet this hand: fold1221 if last_act[1].amount/float(stack_size) <= MID:1222 my_action = Call()1223 else:1224 my_action = Fold()1225 elif self.my_last_action['action'] == RAISE: 1226 my_action = Call()1227 elif eq == 4:1228 if self.first:1229 my_action = Bet(randint(int(MID*stack_size),int(HIGH*stack_size)))1230 elif last_action == CHECK:1231 my_action = Bet(LOW*stack_size)1232 elif last_action == BET:1233 my_action = Raise(MID*stack_size)1234 elif last_action == RAISE:1235 if self.my_last_action['first']:1236 if last_act[1].amount/float(stack_size) <= MID:1237 my_action = Call()1238 else:1239 my_action = Raise(stack_size)1240 elif self.my_last_action['action'] == BET:1241 my_action = Raise(MID*stack_size)1242 elif self.my_last_action['action'] == RAISE:1243 my_action = Raise(stack_size)1244 elif self.pfeq == 4:1245 if eq == 0:1246 if self.first or last_action == CHECK:1247 my_action = Check()1248 elif last_action == BET:1249 if last_act[1].amount/float(stack_size) <= LOW:1250 my_action = Call()1251 else:1252 my_action = Fold()1253 elif eq == 1:1254 if self.first:1255 if brain.opp_stats['AF'] < .5:1256 for action in brain.legal:1257 if isinstance(action,Raise):1258 my_action = Raise(MID*stack_size)1259 self.my_last_action['betfromaf'] = True1260 break1261 elif isinstance(action,Bet):1262 my_action = Bet(MID*stack_size)1263 self.my_last_action['betfromaf'] = True1264 break1265 else:1266 if randint(0,99) < 50:1267 my_action = Check()1268 else:1269 my_action = Bet(randint(int(self.min_bet),int(LOW*stack_size)))1270 elif last_action == CHECK:1271 my_action = Bet(randint(int(LOW*stack_size),int(MID*stack_size)))1272 elif last_action == BET:1273 if last_act[1].amount/float(stack_size) <= LOW:1274 my_action = Call()1275 else:1276 my_action = Fold()1277 elif last_action == RAISE:1278 if self.my_last_action['first']:1279 if self.my_last_action['betfromaf']:1280 my_action = Fold()1281 else:1282 if last_act[1].amount/float(stack_size) <= LOW:1283 my_action = Call()1284 else:1285 my_action = Fold()1286 elif self.my_last_action['action'] == BET:1287 if last_act[1].amount/float(stack_size) <= LOW:1288 my_action = Call()1289 else:1290 my_action = Fold()1291 elif eq == 2:1292 if self.first:1293 my_action = Bet(MID*stack_size)1294 if brain.opp_stats['AF'] < .5:1295 self.my_last_action['betfromaf'] = True1296 elif last_action == CHECK:1297 if randint(0,99) < 50:1298 my_action = Check()1299 else:1300 my_action = Bet(MID*stack_size)1301 elif last_action == BET:1302 if last_act[1].amount/float(stack_size) <= MID:1303 my_action = Call()1304 else:1305 my_action = Fold()1306 elif last_action == RAISE:1307 if self.my_last_action['first']:1308 if self.my_last_action['betfromaf']:1309 if last_act[1].amount/float(stack_size) <= MID:1310 my_action = Call()1311 else:1312 my_action = Fold()1313 else:1314 if last_act[1].amount/float(stack_size) <= MID:1315 my_action = Call()1316 elif last_act[1].amount/float(stack_size) <= HIGH:1317 if brain.opp_stats['AF'] < .5:1318 my_action = Fold()1319 else:1320 my_action = Call()1321 else:1322 my_action = Fold()1323 elif self.my_last_action['action'] == BET:1324 if last_act[1].amount/float(stack_size) <= LOW:1325 my_action = Call()1326 else:1327 my_action = Fold()1328 elif eq == 3:1329 if self.first:1330 my_action = Bet(randint(int(LOW*stack_size),int(MID*stack_size)))1331 elif last_action == CHECK:1332 my_action = Bet(MID*stack_size)1333 elif last_action == BET:1334 if last_act[1].amount/float(stack_size) <= LOW:1335 my_action = Raise(LOW*stack_size)1336 elif last_act[1].amount/float(stack_size) <= HIGH:1337 my_action = Call()1338 else:1339 my_action = Fold()1340 elif last_action == RAISE:1341 if self.my_last_action['first']:1342 if brain.opp_stats['AF'] < .5:1343 my_action = Fold()1344 elif last_act[1].amount/float(stack_size) <= MID:1345 my_action = Call()1346 else:1347 my_action = Fold()1348 elif self.my_last_action['action'] == BET:1349 if last_act[1].amount/float(stack_size) <= HIGH:1350 my_action = Call()1351 else:1352 my_action = Fold()1353 elif self.my_last_action['action'] == RAISE: 1354 my_action = Call()1355 elif eq == 4:1356 if self.first:1357 my_action = Bet(randint(int(MID*stack_size),int(HIGH*stack_size)))1358 elif last_action == CHECK:1359 my_action = Bet(MID*stack_size)1360 elif last_action == BET:1361 my_action = Raise(MID*stack_size)1362 elif last_action == RAISE:1363 if self.my_last_action['first']:1364 if last_act[1].amount/float(stack_size) <= MID:1365 my_action = Call()1366 else:1367 my_action = Raise(stack_size)1368 elif self.my_last_action['action'] == BET:1369 my_action = Call()1370 elif self.my_last_action['action'] == RAISE:1371 my_action = Raise(stack_size)1372 else:1373 print "turn: umm...", self.pfeq, brain.ev1374 return my_action1375 def river(self, brain):1376 #it's the river, tell me how to play1377 last_act = brain.actions[-1]1378 last_action = brain.classify(last_act[1])1379 if DEBUG: print "opp last action was",last_act, "and pfeq is", self.pfeq1380 if DEBUG: print "legal actions:", brain.legal1381 self.first = last_action == DEAL1382 stack_size = brain.pip+brain.stack1383 my_action = None1384 eq = self.parameterize(brain.ev)1385 if eq == 2:1386 if self.first or last_action == CHECK:1387 my_action = Bet(MID*stack_size)1388 elif last_action == BET:1389 if last_act[1].amount/float(stack_size) <= MID:1390 my_action = Call()1391 elif last_act[1].amount/float(stack_size) <= HIGH:1392 if brain.opp_stats['AF'] > 1.5:1393 my_action = Call()1394 else:1395 my_action = Fold()1396 else:1397 my_action = Fold()1398 elif last_action == RAISE:1399 if self.my_last_action['action'] == BET:1400 if last_act[1].amount/float(stack_size) <= LOW:1401 my_act = Call()1402 elif last_act[1].amount/float(stack_size) <= HIGH:1403 if brain.opp_stats['INCR'][0] < .2 : #or brain.opp_stats['cr'] < .4 or cb1404 my_action = Fold()1405 else:1406 my_action = Call()1407 else:1408 my_action = Fold()1409 elif eq == 3:1410 if self.first or last_action == CHECK:1411 my_action = Bet(MID*stack_size)1412 elif last_action == BET:1413 if last_act[1].amount/float(stack_size) <= MID:1414 my_action = Raise(MID*stack_size)1415 elif last_act[1].amount/float(stack_size) <= HIGH:1416 #if opp never raised b4: fold1417 my_action = Call()1418 else:1419 my_action = Fold()1420 elif last_action == RAISE:1421 if self.my_last_action['first']:1422 if brain.opp_stats['AF'] < .5:1423 my_action = Fold()1424 else:1425 if last_act[1].amount/float(stack_size) <= MID:1426 my_action = Call()1427 elif last_act[1].amount/float(stack_size) <= HIGH:1428 #if op never raised in this hand: Fold1429 my_action = Call()1430 else:1431 my_action = Fold()1432 if self.my_last_action['action'] == BET:1433 #if opp has not raised this hand: Fold1434 my_action = Call()1435 elif eq == 4:1436 if self.first:1437 if stack_size < 200 or stack_size > 600:1438 my_action = Bet(stack_size)1439 else:1440 if randint(0,99) < 50:1441 my_action = Bet(HIGH*stack_size)1442 else:1443 my_action = Bet(MID*stack_size)1444 elif last_action == CHECK:1445 my_action = Bet(MID*stack_size)1446 elif last_action == BET:1447 my_action = Raise(MID*stack_size)1448 elif last_action == RAISE:1449 my_action = Raise(stack_size)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Sure automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful