-
Notifications
You must be signed in to change notification settings - Fork 0
/
myio.py
50 lines (42 loc) · 1.13 KB
/
myio.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
def settings():
il = int(input('\n\tInsert an iteration limit: '))
rm = input('\n\t(0) to user mode.\n\t(ANY) to random mode.\n\n\t') != '0'
return il, rm
def banner(it_lim, random_table):
print(\
f"""
Settings
Iteration limit: {it_lim:,}.
Random board: {'YES' if random_table else 'NO'}.
{'-'*25}
""")
return
def helpbanner():
print(\
f"""
In the 8-puzzle, the player needs to move the tiles to sort the board.
This program uses a recursive AI algorithm - A* search with memory bounds - to find a sequence
of moves that set the board to it's proper form.
- Set an iteration limit for the algorithm.
- Choose between entering a board or letting the program generate a random one.
A random board is sure to be solvable whereas a user board may not be so.
- Type '0' where the empty tile goes.
""")
input('\n\tENTER to continue.')
return
def menu():
op = input(\
f"""
Select
(1) to start.
(2) to change settings.
(3) to see help.
(ANY) to quit.
""")
return op
def read():
print('\n\tType each line of the board:\n')
board = []
for i in range(3):
board.append(list(map(int, input('\t').split())))
return board