cleaning cleaning cleaning.. keep them coders cleaning.. cleaning cleaning cleaning..
This commit is contained in:
parent
23acfbd642
commit
a566d52b9a
|
@ -53,8 +53,9 @@ def checkPositions(positions):
|
||||||
### RHH modified to allow for "position 9" here (pos==9 is when you're a dead hand before the BB
|
### RHH modified to allow for "position 9" here (pos==9 is when you're a dead hand before the BB
|
||||||
### eric - position 8 could be valid - if only one blind is posted, but there's still 10 people, ie a sitout is present, and the small is dead...
|
### eric - position 8 could be valid - if only one blind is posted, but there's still 10 people, ie a sitout is present, and the small is dead...
|
||||||
|
|
||||||
#classifies each line for further processing in later code. Manipulates the passed arrays.
|
|
||||||
def classifyLines(hand, category, lineTypes, lineStreets):
|
def classifyLines(hand, category, lineTypes, lineStreets):
|
||||||
|
""" makes a list of classifications for each line for further processing
|
||||||
|
manipulates passed arrays """
|
||||||
currentStreet = "predeal"
|
currentStreet = "predeal"
|
||||||
done = False #set this to true once we reach the last relevant line (the summary, except rake, is all repeats)
|
done = False #set this to true once we reach the last relevant line (the summary, except rake, is all repeats)
|
||||||
for i, line in enumerate(hand):
|
for i, line in enumerate(hand):
|
||||||
|
@ -114,61 +115,59 @@ def classifyLines(hand, category, lineTypes, lineStreets):
|
||||||
else:
|
else:
|
||||||
raise FpdbError("unrecognised linetype in:"+hand[i])
|
raise FpdbError("unrecognised linetype in:"+hand[i])
|
||||||
lineStreets.append(currentStreet)
|
lineStreets.append(currentStreet)
|
||||||
#end def classifyLines
|
|
||||||
|
|
||||||
def convert3B4B(category, limit_type, actionTypes, actionAmounts):
|
def convert3B4B(category, limit_type, actionTypes, actionAmounts):
|
||||||
"""calculates the actual bet amounts in the given amount array and changes it accordingly."""
|
"""calculates the actual bet amounts in the given amount array and changes it accordingly."""
|
||||||
for i in xrange(len(actionTypes)):
|
for i in xrange(len(actionTypes)):
|
||||||
for j in xrange(len(actionTypes[i])):
|
for j in xrange(len(actionTypes[i])):
|
||||||
bets=[]
|
bets = []
|
||||||
for k in xrange(len(actionTypes[i][j])):
|
for k in xrange(len(actionTypes[i][j])):
|
||||||
if (actionTypes[i][j][k]=="bet"):
|
if (actionTypes[i][j][k] == "bet"):
|
||||||
bets.append((i,j,k))
|
bets.append((i,j,k))
|
||||||
if (len(bets)>=2):
|
if (len(bets)>=2):
|
||||||
#print "len(bets) 2 or higher, need to correct it. bets:",bets,"len:",len(bets)
|
#print "len(bets) 2 or higher, need to correct it. bets:",bets,"len:",len(bets)
|
||||||
for betNo in reversed(xrange (1,len(bets))):
|
for betNo in reversed(xrange (1,len(bets))):
|
||||||
amount2=actionAmounts[bets[betNo][0]][bets[betNo][1]][bets[betNo][2]]
|
amount2 = actionAmounts[bets[betNo][0]][bets[betNo][1]][bets[betNo][2]]
|
||||||
amount1=actionAmounts[bets[betNo-1][0]][bets[betNo-1][1]][bets[betNo-1][2]]
|
amount1 = actionAmounts[bets[betNo-1][0]][bets[betNo-1][1]][bets[betNo-1][2]]
|
||||||
actionAmounts[bets[betNo][0]][bets[betNo][1]][bets[betNo][2]]=amount2-amount1
|
actionAmounts[bets[betNo][0]][bets[betNo][1]][bets[betNo][2]] = amount2 - amount1
|
||||||
#print "actionAmounts postConvert",actionAmounts
|
|
||||||
#end def convert3B4B(actionTypes, actionAmounts)
|
|
||||||
|
|
||||||
#Corrects the bet amount if the player had to pay blinds
|
|
||||||
def convertBlindBet(actionTypes, actionAmounts):
|
def convertBlindBet(actionTypes, actionAmounts):
|
||||||
i=0#setting street to pre-flop
|
""" Corrects the bet amount if the player had to pay blinds """
|
||||||
|
i = 0#setting street to pre-flop
|
||||||
for j in xrange(len(actionTypes[i])):#playerloop
|
for j in xrange(len(actionTypes[i])):#playerloop
|
||||||
blinds=[]
|
blinds = []
|
||||||
bets=[]
|
bets = []
|
||||||
for k in xrange(len(actionTypes[i][j])):
|
for k in xrange(len(actionTypes[i][j])):
|
||||||
if actionTypes[i][j][k] == "blind":
|
if actionTypes[i][j][k] == "blind":
|
||||||
blinds.append((i,j,k))
|
blinds.append((i,j,k))
|
||||||
|
|
||||||
if blinds and actionTypes[i][j][k] == "bet":
|
if blinds and actionTypes[i][j][k] == "bet":
|
||||||
# if (len(blinds)>0 and actionTypes[i][j][k]=="bet"):
|
|
||||||
bets.append((i,j,k))
|
bets.append((i,j,k))
|
||||||
if len(bets) == 1:
|
if len(bets) == 1:
|
||||||
blind_amount=actionAmounts[blinds[0][0]][blinds[0][1]][blinds[0][2]]
|
blind_amount=actionAmounts[blinds[0][0]][blinds[0][1]][blinds[0][2]]
|
||||||
bet_amount=actionAmounts[bets[0][0]][bets[0][1]][bets[0][2]]
|
bet_amount=actionAmounts[bets[0][0]][bets[0][1]][bets[0][2]]
|
||||||
actionAmounts[bets[0][0]][bets[0][1]][bets[0][2]]=bet_amount-blind_amount
|
actionAmounts[bets[0][0]][bets[0][1]][bets[0][2]] = bet_amount - blind_amount
|
||||||
#end def convertBlindBet
|
|
||||||
|
|
||||||
#converts the strings in the given array to ints (changes the passed array, no returning). see table design for conversion details
|
#converts the strings in the given array to ints (changes the passed array, no returning). see table design for conversion details
|
||||||
#todo: make this use convertCardValuesBoard
|
#todo: make this use convertCardValuesBoard
|
||||||
def convertCardValues(arr):
|
def convertCardValues(arr):
|
||||||
map(convertCardValuesBoard, arr)
|
map(convertCardValuesBoard, arr)
|
||||||
#end def convertCardValues
|
|
||||||
|
|
||||||
# a 0-card is one in a stud game that we did not see or was not shown
|
# a 0-card is one in a stud game that we did not see or was not shown
|
||||||
card_map = { 0: 0, "2": 2, "3" : 3, "4" : 4, "5" : 5, "6" : 6, "7" : 7, "8" : 8, "9" : 9, "T" : 10, "J" : 11, "Q" : 12, "K" : 13, "A" : 14}
|
card_map = { 0: 0, "2": 2, "3" : 3, "4" : 4, "5" : 5, "6" : 6, "7" : 7, "8" : 8,
|
||||||
|
"9" : 9, "T" : 10, "J" : 11, "Q" : 12, "K" : 13, "A" : 14}
|
||||||
|
|
||||||
#converts the strings in the given array to ints (changes the passed array, no returning). see table design for conversion details
|
|
||||||
def convertCardValuesBoard(arr):
|
def convertCardValuesBoard(arr):
|
||||||
|
""" converts the strings in the given array to ints
|
||||||
|
(changes the passed array, no returning). see table design for
|
||||||
|
conversion details """
|
||||||
for i in xrange(len(arr)):
|
for i in xrange(len(arr)):
|
||||||
arr[i] = card_map[arr[i]]
|
arr[i] = card_map[arr[i]]
|
||||||
#end def convertCardValuesBoard
|
|
||||||
|
|
||||||
#this creates the 2D/3D arrays. manipulates the passed arrays instead of returning.
|
def createArrays(category, seats, card_values, card_suits, antes, winnings,
|
||||||
def createArrays(category, seats, card_values, card_suits, antes, winnings, rakes, action_types, allIns, action_amounts, actionNos, actionTypeByNo):
|
rakes, action_types, allIns, action_amounts, actionNos,
|
||||||
|
actionTypeByNo):
|
||||||
|
""" this creates the 2D/3D arrays. manipulates the passed arrays instead of returning. """
|
||||||
for i in xrange(seats):#create second dimension arrays
|
for i in xrange(seats):#create second dimension arrays
|
||||||
card_values.append( [] )
|
card_values.append( [] )
|
||||||
card_suits.append( [] )
|
card_suits.append( [] )
|
||||||
|
@ -176,7 +175,8 @@ def createArrays(category, seats, card_values, card_suits, antes, winnings, rake
|
||||||
winnings.append(0)
|
winnings.append(0)
|
||||||
rakes.append(0)
|
rakes.append(0)
|
||||||
|
|
||||||
streetCount = 4 if category == "holdem" or category == "omahahi" or category == "omahahilo" else 5
|
streetCount = 4 if (category == "holdem" or category == "omahahi" or
|
||||||
|
category == "omahahilo") else 5
|
||||||
|
|
||||||
for i in xrange(streetCount): #build the first dimension array, for streets
|
for i in xrange(streetCount): #build the first dimension array, for streets
|
||||||
action_types.append([])
|
action_types.append([])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user