Pre-configured virtual machine

In order to simplify PyRat installation, we have prepared a virtual machine with it already installed. You can access it through the « Important resources » menu item, or by clicking here.

If you choose to use the pre-configured virtual machine, you can reading this page here. On the contrary, if you prefer to have PyRat installed on your own computer (which will be faster), please read the following section.

Install PyRat on your computer

The PyRat software on which the course is based can be installed on Linux, MacOS and Windows. Based on you choice (which should be Linux 😉 ), follow the instructions in the corresponding section below.

Linux

The following instructions have been written for Ubuntu (18.04 LTS). Still, they should work for most distributions (adapting the package manager, obviously).

Getting Python 3

Normally, Python 3 should already be installed on your computer. You can check the version by writing the following command in a terminal:

python --version

If the command indicates that Python is not installed, try again using the following command instead:

python3 --version

If this works, we are going to create an alias so that python is recognized as python3:

echo "alias python='python3'" >> ~/.bashrc
source ~/.bashrc

If this still doesn’t work, you can install Python 3 using the following command:

apt-get install python3

Then, create an alias as explained above.

Installing Pip

Pip is a library that allows an easy installation of most Python libraries. We are going to use it to install PyRat dependencies. In order to install Pip, run the following command:

apt-get install python3-pip

You can check that Pip is properly installed by typing:

pip3 -V

You should see a line of text indicating which version of Pip is installed. Make sure the Python version that is indicated is Python 3.

Installing dependencies

There are a few dependencies for PyRat. You can now install them using Pip as follows:

pip3 install ipynb-py-convert pygame gdown

If PyGame fails installing, please install the dependencies detailed here, and relaunch the command above.

Getting PyRat

Now that everything is set, you can get the PyRat software on this GitHub repository. Just click on the green button on the right and download the archive.

All you have to do now is to unzip the archive you just downloaded somewhere on your computer. This will be your workspace for the entire course.

Is everything right?

Open a terminal and navigate (use the cd command) to your PyRat workspace. Then, you can start a PyRat game by running the following command:

python pyrat.py --rat AIs/random.py

You should see the PyRat window, in which the rat is moving randomly.

Remark: You can replace AIs/random.py above by a link to a Jupyter notebook, either located on your computer, or stored on your Google Drive account. Do use the latter option, just allow sharing by link for the file on Google Colab, and use this link as an argument for --rat. You can find more info on the PyRat template Google Colab file.

MacOS

Getting Python 3

By default, MacOS uses Python 2. There are several solutions for intalling Python 3, for instance downloading it here or using Homebrew.

Here, we choose to use a solution based on Miniconda, which is a small version of Anaconda, an environment to have a local install of Python 3 that doesn’t interfere with the system.

First, download Miniconda (bash installer, Python 3.7, macOS, 64 bits) here, and place wherever you want on your computer.

Open a terminal and navigate to that location (use the cd command). Then run the following command to install Miniconda:

bash Miniconda3-latest-MacOSX-x86_64.sh -b -p $HOME/miniconda

We then need to create a Conda environment from your home directory. To do that, run the following commands:

cd ~
miniconda/bin/conda create -n pyrat_env python=3.7

You will be asked to confirm installation of some packages, do so. Now that Conda is set, you should activate it as follows:

source miniconda/bin/activate pyrat_env

Important! You have to activate Conda everytime you start a new terminal, as it will only activate Python 3 in the current terminal.

Now, you can check that Python 3 is properly installed using the following command:

python --version

Installing dependencies

Pip is a library that allows an easy installation of most Python libraries. We are going to use it to install PyRat dependencies. If you installed Python 3 as described above, Pip should already be available.

There are a few dependencies for PyRat. First of all, make sure you have your Conda environment activated. Then, type the following command:

pip install ipynb-py-convert pygame gdown

Getting PyRat

Now that everything is set, you can get the PyRat software on this GitHub repository. Just click on the green button on the right and download the archive.

All you have to do now is to unzip the archive you just downloaded somewhere on your computer. This will be your workspace for the entire course.

Is everything right?

Open a terminal, activate Conda, and navigate to your PyRat workspace. Then, you can start a PyRat game by running the following command:

python pyrat.py --rat AIs/random.py

You should see the PyRat window, in which the rat is moving randomly.

Remark: You can replace AIs/random.py above by a link to a Jupyter notebook, either located on your computer, or stored on your Google Drive account. Do use the latter option, just allow sharing by link for the file on Google Colab, and use this link as an argument for --rat. You can find more info on the PyRat template Google Colab file.

Windows

Getting Python 3

First, check your version of Python. To do so, open a terminal (cmd) and run the following command:

python --version

There are three possible cases:

  • Python is not found.
  • Python version is higher than or equal to 3.5.
  • Python version is lower than 3.5.

If you are in the third situation, uninstall any previous version of Python you might have. To do so, open you configuration panel, go to the installed software section, and uninstall the Python programs there.

Now, if you do not have Python ≥ 3.5 installed, we are going to install it (otherwise, you can jump to the next section).

Download Python 3 here (get the 32 or 64 bits based on your system architecture, see here for info). You should get a file called Windows x86 executable installer or Windows x86-64 executable installer.

Just run the executable to install Python 3. Do not forget to check the box Add Python 3.x to Path.

You can now check your install with the following command:

python --version

Installing dependencies

Pip is a library that allows an easy installation of most Python libraries. We are going to use it to install PyRat dependencies. You can now install them using Pip by running the following command in a terminal:

python -m pip install -U ipynb-py-convert pygame gdown --user

Getting PyRat

Now that everything is set, you can get the PyRat software on this GitHub repository. Just click on the green button on the right and download the archive.

All you have to do now is to unzip the archive you just downloaded somewhere on your computer. This will be your workspace for the entire course.

Is everything right?

Open a terminal and navigate (use the cd command) to your PyRat workspace. Then, you can start a PyRat game by running the following command:

python pyrat.py --rat AIs\random.py

You should see the PyRat window, in which the rat is moving randomly.

Remark: You can replace AIs\random.py above by a link to a Jupyter notebook, either located on your computer, or stored on your Google Drive account. Do use the latter option, just allow sharing by link for the file on Google Colab, and use this link as an argument for --rat. You can find more info on the PyRat template Google Colab file.