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 GameState(ABC): | |
@abstractmethod | |
def is_terminal(self) -> bool: | |
pass | |
@abstractmethod | |
def get_payoffs(self) -> List[int]: | |
pass | |
@abstractmethod |
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
def get_representation(self) -> str: | |
player_index = self.get_index(self.get_active_player()) | |
player_card_rank = self.deck[player_index][0] | |
actions_as_string = "/".join([str(x) for x in self.history]) | |
if self.round == Round.pre_flop: | |
community_card_rank = '' | |
else: | |
community_card_rank = self.deck[-1][0] | |
return f'{player_card_rank}/{community_card_rank}-{actions_as_string}' |
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
def handle_action( | |
self, | |
player: LeducPlayer, | |
action: LeducAction) -> LeducGameState: | |
next_state = copy.deepcopy(self) |
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
def rank(hand: List[str]) -> int: | |
ranks = { | |
'KK': 1, | |
'QQ': 2, | |
'JJ': 3, | |
'KQ': 4, 'QK': 4, | |
'KJ': 5, 'JK': 5, | |
'QJ': 6, 'JQ': 6 | |
} | |
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
from typing import List, Dict | |
import random | |
import numpy as np | |
import sys | |
Actions = ['B', 'C'] # bet/call vs check/fold | |
class InformationSet(): | |
def __init__(self): | |
self.cumulative_regrets = np.zeros(shape=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
# Install JDK 8 | |
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.rpm | |
sudo yum install -y jdk-8u141-linux-x64.rpm | |
# Download and unzip Scala and Kafka | |
wget http://www.scala-lang.org/files/archive/scala-2.12.6.tgz | |
tar xvf scala-2.12.6.tgz | |
wget https://archive.apache.org/dist/kafka/0.8.1/kafka_2.12-2.0.0.tgz | |
tar zxvf kafka_2.12-2.0.0.tgz |