Contents of the page


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 pip3

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 Pygame

Pygame is the only dependency of PyRat. You can now install it using Pip as follows:

pip3 install pygame

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.

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 Pygame

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 Puython 3 as described above, Pip should already be available.

Pygame is the only dependency of PyRat. First of all, make sure you have your Conda environment activated. Then, type the following command:

pip install pygame

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.

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 Pygame

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

python -m pip install -U pygame --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.