Skip to content

vgripon/PyRat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

This repository is for the MOOC version of the PyRat course. For in-class students, please refer to the following link: https://github.com/BastienPasdeloup/PyRat

This is the software of the course PyRat.

Code by Vincent Gripon

Illustrations by Lauren Lefumeur-Pasdeloup and Christina Roberts

See full credits here.

Usage

  1. Open a terminal and navigate to the folder containing pyrat.py

  2. Run 'python3 pyrat.py --help' for a complete list of options. A good start is 'python3 pyrat.py --rat AIs/random.py'

You can play with keyboard (tested on Linux and Windows) with 'python pyrat.py --rat human --python human' (replace with 'python3' if running Ubuntu). The rat is controlled with arrows and the python with keypad.

Install

To be able to run, one should only need python3 and pygame for python3

  • On Ubuntu, a typical installation would be:
sudo apt-get install python3-setuptools
sudo easy_install3 pip
sudo pip3.5 install pygame

On 18.04, users reported using:

sudo apt-get install python3-pip
pip3 -V
# pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
sudo pip3 install pygame

Test your installation. In the pyrat directory, type:

python3 pyrat.py --rat AIs/random.py
  • On Windows:
pip install pygame

With more details:

Install Python 3 from https://www.python.org/downloads/windows/: select the version for your architecture, 32 bits or 64 bits. Download and launch the installer.

Select "Add Python 3.x to Path" in order to be able to launch the Python interpreter from any directory.

Select "Install now": the default option locally installs Python 3 for the current user.

Install the library "pygame". Launch "cmd" and then type:

python -m pip install -U pygame --user

Test your installation. In the pyrat directory, type:

python pyrat.py --rat AIs\random.py
  • On macOS:

macOS ships with Python 2 by default. There is several ways to install Python 3, such as from Python.org or using Homebrew. Here we show how to do it using Anaconda, which cleanly separates Python 3 from the system Python, and can be removed easily.

Download and install Anaconda (Python 3.x version): https://www.anaconda.com/download/#macos.
Then, create a Conda environment and setup the dependencies:

conda create -n pyrat_env python=3.6
source activate pyrat_env
pip install pygame

To run PyRat:

source activate pyrat_env
python pyrat.py

Note that inside the Conda environment, python and python3 link to Python 3, while python2 links to the system Python 2.

python --version
# Python 3.6.5 :: Anaconda, Inc.
python3 --version
# Python 3.6.5 :: Anaconda, Inc.
python2 --version
# Python 2.7.10

If wanted, Anaconda can be removed by running the following:

rm -r /anaconda3 ~/.condarc ~/.conda ~/.continuum

Notes

  • On Windows expect numerous bugs

  • On MacOS, do not expect anything

Releases

No releases published

Packages

No packages published

Languages