Ejemplo n.º 1
0
        name = 'Player ' + str(i + 1)
        p = BasicPlayer(name=name,
                        reg=r,
                        bankroll=10000,
                        nRaises=4,
                        rFactor=.7,
                        memory=10**5)
        p.stopTraining()
        players.append(p)

    for p in players:
        t.addPlayer(p)

    #train Player 1 for 1000 hands, training once
    players[0].startTraining()
    simulate(t, nHands=2000, nTrain=100, nBuyIn=10)
    players[0].stopTraining()

    #for p in players: p.setBankroll(10**6)

    #simulate 20,000 hands and save bankroll history
    #bankrolls = simulate(t, nHands=20, nTrain=0, nBuyIn=10)

    #plot bankroll history of each player
    '''
    for i in range(6):
        bankroll = bankrolls[i]
        plt.plot(range(len(bankroll)), bankroll, label=players[i].getName())
    plt.title('Player bankroll vs Hands played')        
    plt.xlabel('Hands played')
    plt.ylabel('Player bankroll/wealth')
Ejemplo n.º 2
0
from pklearn.templates import simulate, BasicPlayer
from sklearn.ensemble import GradientBoostingRegressor

if __name__ == '__main__':

    t = Table(smallBlind=1, bigBlind=2, maxBuyIn=200)

    players = []
    for i in range(6):
        
        #create BasicPlayer that uses GradientBoostingRegressor as machine learning model
        #with wealth of 1 million and 10 discrete choices for raising,
        #with each raise choice .7 times the next largest raise choice
        #Player forgets training samples older than 100,000
        r = GradientBoostingRegressor()
        name = 'Player ' + str(i+1)
        p = BasicPlayer(name=name, reg=r, bankroll=10**6, nRaises=10, rFactor=.7, memory=10**5)
        players.append(p)

    for p in players: t.addPlayer(p)

    #simulate 'nHands' hands
    #begin training after 'firstTrain' hands
    #before which players take random actions and explore state space
    #players train every 'nTrain' hands after 'firstTrain'
    #players cash out/ buy in every 'nBuyIn' hands
    #table narrates each hands if 'vocal' is True
    simulate(t, nHands=10000, firstTrain=2000, nTrain=1000, nBuyIn=10)
    simulate(t, nHands=20, nBuyIn=10, vocal=True)

    
Ejemplo n.º 3
0
        name = 'Player ' + str(i + 1)
        p = BasicPlayer(name=name,
                        reg=r,
                        bankroll=10**6,
                        nRaises=10,
                        rFactor=.7,
                        memory=10**5)
        p.stopTraining()
        players.append(p)

    for p in players:
        t.addPlayer(p)

    #train Player 1 for 1000 hands, training once
    players[0].startTraining()
    simulate(t, nHands=5000, nTrain=1000, nBuyIn=10)
    players[0].stopTraining()

    #train Player 2 for 10000 hands, training every 1000 hands
    players[1].startTraining()
    simulate(t, nHands=50000, nTrain=1000, nBuyIn=10)
    players[1].stopTraining()

    for p in players:
        p.setBankroll(10**6)

    #simulate 20,000 hands and save bankroll history
    bankrolls = simulate(t, nHands=20000, nTrain=0, nBuyIn=10)

    #plot bankroll history of each player
    for i in range(6):
Ejemplo n.º 4
0
        #with wealth of 1 million and 10 discrete choices for raising,
        #with each raise choice .7 times the next largest raise choice
        #Player forgets training samples older than 100,000
        name = 'Player ' + str(i + 1)
        p = BasicPlayer(name=name,
                        bankroll=10**6,
                        nRaises=10,
                        rFactor=.7,
                        memory=10**5)
        players.append(p)

    for p in players:
        t.addPlayer(p)

    #simulate 1,000 hands, cashing out/buying in every 10 hands, without training or narrating
    simulate(t, nHands=1000, nBuyIn=10, nTrain=0, vocal=False)

    features = []
    labels = []

    for p in players:
        features.extend(p.getFeatures())
        labels.extend(p.getLabels())

    features = np.array(features)
    labels = np.array(labels)

    #shuffle features/labels
    index = np.arange(len(labels))
    np.random.shuffle(index)
    features = features[index]
Ejemplo n.º 5
0
    t = Table(smallBlind=1, bigBlind=2, maxBuyIn=200)

    players = []
    for i in range(6):
        # create BasicPlayer that uses GradientBoostingRegressor as machine learning model
        # with wealth of 1 million and 10 discrete choices for raising,
        # with each raise choice .7 times the next largest raise choice
        # Player forgets training samples older than 100,000
        r = GradientBoostingRegressor()
        name = 'Player ' + str(i + 1)
        p = BasicPlayer(name=name,
                        reg=r,
                        bankroll=10**6,
                        nRaises=10,
                        rFactor=.7,
                        memory=10**5)
        players.append(p)

    for p in players:
        t.addPlayer(p)

    # simulate 'nHands' hands
    # begin training after 'firstTrain' hands
    # before which players take random actions and explore state space
    # players train every 'nTrain' hands after 'firstTrain'
    # players cash out/ buy in every 'nBuyIn' hands
    # table narrates each hands if 'vocal' is True
    simulate(t, nHands=10000, firstTrain=2000, nTrain=1000, nBuyIn=10)
    simulate(t, nHands=20, nBuyIn=10, vocal=True)
Ejemplo n.º 6
0
    players = []
    for i in range(6):
        
        #create BasicPlayer without a machine learning model
        #with wealth of 1 million and 10 discrete choices for raising,
        #with each raise choice .7 times the next largest raise choice 
        #Player forgets training samples older than 100,000
        name = 'Player ' + str(i+1)
        p = BasicPlayer(name=name, bankroll=10**6, nRaises=10, rFactor=.7, memory=10**5)
        players.append(p)

    for p in players: t.addPlayer(p)

    #simulate 1,000 hands, cashing out/buying in every 10 hands, without training or narrating
    simulate(t, nHands=1000, nBuyIn=10, nTrain=0, vocal=False)

    features = []
    labels = []

    for p in players:
        features.extend(p.getFeatures())
        labels.extend(p.getLabels())

    features = np.array(features)
    labels = np.array(labels)

    #shuffle features/labels
    index = np.arange(len(labels))
    np.random.shuffle(index)
    features = features[index]
Ejemplo n.º 7
0
        
        #create BasicPlayer that uses GradientBoostingRegressor as machine learning model
        #with wealth of 1 million and 10 discrete choices for raising,
        #with each raise choice .7 times the next largest raise choice
        #Player forgets training samples older than 100,000
        r = GradientBoostingRegressor()
        name = 'Player ' + str(i+1)
        p = BasicPlayer(name=name, reg=r, bankroll=10**6, nRaises=10, rFactor=.7, memory=10**5)
        p.stopTraining()
        players.append(p)

    for p in players: t.addPlayer(p)

    #train Player 1 for 1000 hands, training once
    players[0].startTraining()
    simulate(t, nHands=1000, nTrain=1000, nBuyIn=10)   
    players[0].stopTraining()
    
    #train Player 2 for 10000 hands, training every 1000 hands
    players[1].startTraining()
    simulate(t, nHands=10000, nTrain=1000, nBuyIn=10)   
    players[1].stopTraining()

    for p in players: p.setBankroll(10**6)

    #simulate 20,000 hands and save bankroll history
    bankrolls = simulate(t, nHands=20000, nTrain=0, nBuyIn=10)

    #plot bankroll history of each player
    for i in range(6):
        bankroll = bankrolls[i]