Set up OpenSpiel on a MacBook with a Ubuntu Docker image

The Dueling House
theduelinghouse
Published in
2 min readSep 16, 2019

To set up OpenSpiel on a MackBook, we would build a Docker image of Ubuntu 18.04 which we would further run commands against.

The code in this post is available here: https://github.com/theduelinghouse/open_spiel-docker

Image Credit: DeepMind, Docker

Build a docker image with a tag open_spiel.

docker build -t open_spiel .

Run commands on the built Docker image

docker run open_spiel examples/example --game=tic_tac_toe

The output would look like this.

For whom doesn’t have Docker installed on their MacBook, you can instead use a cloud Ubuntu instance. Here are notes on how to set up OpenSpiel on Ubuntu 18.04 with a DigitalOcean Droplet.

Walkthrough of the Dockfile

# Start with an updated Ubuntu 18.04 with sudo installed
FROM ubuntu:18.04
RUN apt-get update && apt-get -y install sudo
# Copy requirements of what OpenSpiel depends on, provided by
# OpenSpiel
WORKDIR /
RUN mkdir open_spiel
COPY open_spiel/install.sh /open_spiel
COPY open_spiel/requirements.txt /open_spiel
WORKDIR /open_spiel
# Turn off apt-get interactions during installation
RUN sed -i -e 's/apt-get install/apt-get install -y/g' ./install.sh
RUN ./install.sh
RUN virtualenv -p python3 venv
RUN /bin/bash -c "source venv/bin/activate"
RUN pip3 install -r requirements.txt
# Install CMake with verion higher than 3.12
RUN pip3 install cmake
# Copy the directory with OpenSpiel source code
COPY open_spiel/open_spiel open_spiel
RUN ./open_spiel/scripts/build_and_run_tests.sh
# Set WORKDIR as the output of the build
WORKDIR /open_spiel/build_python_3

--

--