-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha1_support.py
50 lines (41 loc) · 1.33 KB
/
a1_support.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import random
ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
UP = "up"
DOWN = "down"
LEFT = "left"
RIGHT = "right"
DIRECTIONS = (UP, DOWN, LEFT, RIGHT,
f"{UP}-{LEFT}", f"{UP}-{RIGHT}",
f"{DOWN}-{LEFT}", f"{DOWN}-{RIGHT}")
WALL_VERTICAL = "|"
WALL_HORIZONTAL = "-"
POKEMON = "☺"
FLAG = "♥"
UNEXPOSED = "~"
EXPOSED = "0"
INVALID = "That ain't a valid action buddy."
HELP_TEXT = """h - Help.
<Uppercase Letter><number> - Selecting a cell (e.g. 'A1')
f <Uppercase Letter><number> - Placing flag at cell (e.g. 'f A1')
:) - Restart game.
q - Quit.
"""
def generate_pokemons(grid_size, number_of_pokemons):
"""Pokemons will be generated and given a random index within the game.
Parameters:
grid_size (int): The grid size of the game.
number_of_pokemons (int): The number of pokemons that the game will have.
Returns:
(tuple<int>): A tuple containing indexes where the pokemons are
created for the game string.
"""
cell_count = grid_size ** 2
pokemon_locations = ()
for _ in range(number_of_pokemons):
if len(pokemon_locations) >= cell_count:
break
index = random.randint(0, cell_count-1)
while index in pokemon_locations:
index = random.randint(0, cell_count-1)
pokemon_locations += (index,)
return pokemon_locations