def iterateTransitions() : #2529 insterting into flop trans transitions = {} conn = db.Conn("localhost") street = 'river' len_street = 5 #permutations v combinations is important for transitions because the #way in which you go from 3 to 4 card board matters for i, board_prime in enumerate( permutations( range(52), len_street ) ): #12508.pts-1.genomequery if i < 0 or i >= 60000000 : continue #10866.pts-1.genomequery #if i < 60000000 or i >= 120000000: continue #12481.pts-3.genomequery #if i < 120000000 or i >= 180000000: continue #finished #12526.pts-3.genomequery #if i < 180000000 or i >= 240000000: continue #12635.pts-3.genomequery #if i < 240000000 : continue #print i #deprecated if street == 'flop' : cboards = cboard_prime else : board = board_prime[:-1] cboard = collapseBoard(board) cboard_prime = collapseBoard(board_prime) cboards = "%s|%s" % (cboard, cboard_prime) #print board_prime #better but untested in this context cboard,cboardp = board2cboards( board_prime, globles.streetname2Int(street) ) cboards = canonicalizeCboards( cboard, cboardp ) ##until tested #assert False if cboards not in transitions : transitions[cboards] = True q = "select count(*) from TRANSITIONS_%s where cboards = '%s'" % \ (street.upper(),cboards) count = conn.queryScalar(q, int) if count == 0 : print "missing: ", cboards computeBucketTransitions( conn, cboard, cboard_prime ) else : print "skipping:", cboards print len(transitions)
def setupEvidence( board, actions ) : #derive street_cboards = {} for street in range(4) : if street == 0 : street_cboards[0] = "n/a" else : (cboard,cboardp) = deck.board2cboards( board, street ) cboards = deck.canonicalizeCboards( cboard,cboardp ) street_cboards[street] = cboards evidence = [street_cboards, actions] return evidence
q = "select count(*) from TRANSITIONS_%s where cboards = '%s'" % \ (street.upper(),cboards) count = conn.queryScalar(q, int) if count == 0 : print "missing: ", cboards computeBucketTransitions( conn, cboard, cboard_prime ) else : print "skipping:", cboards print len(transitions) if __name__ == '__main__' : board = ['9h','3h','6h','5c'] #'As', 'Ac', '3s', 'Jc', '4s'] print canonicalizeCboards( *board2cboards( board, 2 ) ) print makeMachine( board ) #assert False #conn = db.Conn("localhost") #iterateTransitions() assert False #testSymmetric() #getTransitionProbs_DB( conn, \ #['2h','2c','2d','2s'], 'turn', \ #['2h','2c','2d','2s','As'], 'river' ) ##['2h','4h','7d'], 'flop', \ ##['2h','4h','7d','Td'], 'turn' ) #sampleTransitionProbs( "flop", 5, globles.BUCKET_PERCENTILES )