Ash goes looking for pokemons in bi-dimensional field. Each position around him has one single pokemon.
To run this program you need to have Python 3.6 installed (or the most recently available).
The first step is to clone the repository into your desired location.
- Clone this repo to your local machine as follows
git clone https://github.com/MPBaptista/pokemon.git
Run python file (use local Python version accordingly to requirements).
python3 pokemon.pyor run and display time benchmark.
python3 pokemon.py -b- Tests get_position() in initial position;
- Tests get_pokemons() in initial position;
- Tests move() with 1 million successive moves;
- Tests get_position() after moves;
- Tests get_pokemon() after moves;
python3 -m unittest --v test_pokemon.py - Tests parse_input() with string "E";
- Tests parse_input() with string "NESO";
- Tests parse_input() with string "EQ";
- Tests parse_input() with string "QE";
- Tests parse_input() with string "1";
python3 -m unittest --v test_utils.py python3 pokemon.py -b
Bem-vindo Ash!
Introduz a sequência de movimentos desejada(N/S/E/O):
--> NNEESSO
Total de pokemons apanhados: 8
Tempo de execução: 0.0006053420001990162 segundos
Continuar(s/n): n
Adeus Ash!
In regards to the definition of the bi-dimensional field a set proved to be the best way. Python set allows the addition of a new value, a numpy array has to create a new array for each new value, so the set proves to be vastly faster and simpler.
Comparatively to a list a set still proves its advantages, being that the set only allows adding unique values the complexity of adding a value is only O(1), to add a new value to a list the list has to be checked for the value if x not in list: add raising the complexity to O(N).
- Due to limitations of all POSIX compilant command-lines the max input the program will behave correctly to is 4095 moves, to bypass this simply input successive move sequences of up to 4095 moves each.
- Miguel Baptista