/
threes.py
executable file
·76 lines (65 loc) · 1.78 KB
/
threes.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import sys
from company import Board, Player
def main():
players = [Player(), Player()]
try:
width = int(input("How wide of a board would you like?\r\n"))
except ValueError:
print("Please enter a valid number")
try:
height = int(input("How tall of a board would you like?\r\n"))
except ValueError:
print("Please enter a valid number")
board = Board(players, width, height)
board.print_board()
turn = 0
game = True
while turn < 50:
played = False
while not played:
try:
tile = int(input("What tile do you want to play, %s (0-%s)?\r\n" %
(board.players[turn % 2].name, board.total_tiles)))
played = board.play_tile(tile, board.players[turn % 2], True)
except ValueError:
print("Please enter a valid number")
turn += 1
print("Game over!")
sys.exit()
main()
'''
Some optional code to run to test stuff.
board.print_board()
#Get a 2 in the top right
board.play_tile(1, True)
board.play_tile(2, True)
board.play_tile(3, True)
#Get a two to the left
board.play_tile(1, True)
board.play_tile(6, True)
board.play_tile(2, True)
#Get a two below the corner spot
board.play_tile(6, True)
board.play_tile(11, True)
board.play_tile(7, True)
#Get another 3
board.play_tile(1, True)
board.play_tile(5, True)
board.play_tile(9, True)
board.play_tile(2, True)
board.play_tile(6, True)
board.play_tile(10, True)
board.play_tile(1, True)
board.play_tile(5, True)
board.play_tile(6, True)
#Third 3
board.play_tile(0, True)
board.play_tile(4, True)
board.play_tile(8, True)
board.play_tile(1, True)
board.play_tile(5, True)
board.play_tile(9, True)
board.play_tile(0, True)
board.play_tile(4, True)
board.play_tile(5, True)
'''