This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from poker import POKER_BOX, Hand, Card | |
#poker.py can be found at https://gist.github.com/shahradj/1761a6a521c2649bdcc54996d2bb73ec | |
from gametree import GameTree, ACTIONS | |
#gametree.py can be found at https://gist.github.com/shahradj/ab6e2ea5ab8cb17ed287dda0c4796ed2 | |
import numpy as np | |
import pandas as pd | |
import itertools | |
import copy | |
from collections import Counter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
ACTIONS = ['r', 'c', 'f'] # RAISE or CALL/CHECK or FOLD | |
class GameNode: | |
def __init__(self, info_set): | |
self.info_set = info_set | |
self.strategy_sum, self.regret_sum = np.zeros((2, len(ACTIONS))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
from collections import Counter | |
# example string representation of card '8 Diamond': '8D' | |
RANKS = [str(i) for i in range(2, 11)] + ['J', 'Q', 'K', 'A'] | |
SUITS = ['C', 'D', 'H', 'S'] | |
POKER_BOX = [r+s for r,s in itertools.product(RANKS, SUITS)] | |
class Card: | |
def __init__(self, card): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from scipy.cluster.hierarchy import fclusterdata | |
from pymongo import MongoClient | |
import numpy as np | |
from datetime import * | |
import json | |
def saveToRelational(jsonPacket): | |
""" | |
save the received json packet to a relational database |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Game: | |
def __init__(self, max_game=100): | |
self.p1 = Player('Agent A') | |
self.p2 = Player('Agent B') | |
self.max_game = max_game | |
def play(self, avg_regret_matching=False): | |
def play_regret_matching(): | |
for i in xrange(0, self.max_game): | |
self.p1.update_strategy() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Prisoners: | |
actions = ['SILENCE', 'SNITCH'] | |
n_actions = 2 | |
utilities = pd.DataFrame([ | |
# SILENCE SNITCH | |
[ -2, -5], # SILENCE | |
[ -1, -3] # SNITCH | |
], columns=actions, index=actions) |