Python instead of python3

This commit is contained in:
Thomas Forgione 2019-03-13 21:02:43 +01:00
parent e14866950e
commit 926d177267
No known key found for this signature in database
GPG Key ID: BFD17A2D71B3B5E7
1 changed files with 12 additions and 12 deletions

View File

@ -16,22 +16,22 @@ The first step is to clone the repository:
git clone https://gitea.tforgione.fr/tforgione/pytron
```
Then, ensure you have `python3` and `pygame` installed. You can test you have
Then, ensure you have `python` and `pygame` installed. You can test you have
everything by executing the following command:
```
python3 -c "import pygame"
python -c "import pygame"
```
- if you get a `python3: command not found`, it means you don't have
`python3`, you can install it on ubuntu like so:
- if you get a `python: command not found`, it means you don't have
`python`, you can install it on ubuntu like so:
``` sh
sudo apt install python3
sudo apt install python
```
- if you get a `ImportError: No module named 'pygame'`, it means you don't
have `pygame`, you can install it on ubuntu like so:
``` sh
sudo apt install python3-pip
sudo apt install python-pip
sudo pip3 install pygame
```
@ -112,7 +112,7 @@ It contains an `np.array` of two dimensions containing two rows and two columns
more that what specify, because is automatically adds border to your map. This
means that when you run
``` python3
``` python
my_map = Map(5, 5, Case.EMPTY, Case.WALL)
```
@ -127,7 +127,7 @@ modify the border with the getters.
To use the getters, you can do like this:
``` python3
``` python
my_map = Map(5, 5, Case.EMPTY, Case.WALL)
# Sets the top left corner of the map to PLAYER_ONE_HEAD
@ -136,14 +136,14 @@ my_map[0, 0] = Case.PLAYER_ONE_HEAD
```
You can easily clone a map:
``` python3
``` python
my_map = Map(5, 5, Case.EMPTY, Case.WALL)
my_second_map = my_map.clone() # Clones the whole map
```
If you want to clone the array of a map and apply a function to it at the same
time, you can do like this:
``` python3
``` python
def my_function(x):
return x + 1
@ -156,7 +156,7 @@ my_map.apply(my_function)
At any moment, you can get a reference to the `np.array` of the map by using
the `array` method:
``` python3
``` python
my_map = Map(5, 5, Case.EMPTY, Case.WALL)
my_array = my_map.array()
my_array[0][0] = ... # Modifies the top left tile of the border of the map
@ -173,7 +173,7 @@ Be careful: when you get a reference to an np-array, you need to remember:
If you wan to modify an np-array without modifying the map, you can use the
`clone_array` method:
``` python3
``` python
my_map = Map(5, 5, Case.EMPTY, Case.WALL)
my_array = my_map.clone_array()
# Modifying my_array won't modify my_map