Skip to content

Latest commit

 

History

History
73 lines (48 loc) · 2.48 KB

README.md

File metadata and controls

73 lines (48 loc) · 2.48 KB

Primer game environments

This is a repository with environments for simulating and interacting with the game from Coin Flip Cheaters: A game from Primer.

game.py includes the class CoinGame that inherits from the openai gym.Env base class to set up the environment.

game_simulation.py includes the class CoinGameSimulation that implements a simulation of the game to test out the your strategies or models.

game_browser.py includes the class CoinGameBrowser that iteracts with the online game at primerlearning.org.

Strategies

My strategies can be found in the strategies directory. The most succestful one was the simple bayesian strategy.

How to use

To get exactly the same dependencies as I used, create the conda environment using:

conda env create -f environment.yml

Here is an example of how to use the simulation that uses the gym API:

from game_simulation import CoinGameSimulation

def strategy(n_heads, n_tails, flips_left):
    # define your strategy here
    # see game.py for more details
    return action

env = CoinGameSimulation()

(n_heads, n_tails, flips_left) = env.reset()

done = False
while not done:
    action = strategy(n_heads, n_tails, flips_left)
    (n_heads, n_tails, flips_left), reward, done, info = env.step(action)

To use the browser interaction environment you first need to install FireFox, geckodriver. You then change the file paths in game_browser.py to use your files by changing geckodriver_path.

The browser interaction environment can then be used with the same gym API:

from game_browser import CoinGameBrowser

def strategy(n_heads, n_tails, flips_left):
    # define your strategy here
    # see game.py for more details
    return action

env = CoinGameBrowser()

(n_heads, n_tails, flips_left) = env.reset()

done = False
while not done:
    action = strategy(n_heads, n_tails, flips_left)
    (n_heads, n_tails, flips_left), reward, done, info = env.step(action)

My highscore

The highest score I have achieved was a 10+ hours overnight run with the following score: