forked from mitpokerbots/engine-2025
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathengine.py
583 lines (532 loc) · 26.3 KB
/
engine.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
'''
6.9630 MIT POKERBOTS GAME ENGINE
DO NOT REMOVE, RENAME, OR EDIT THIS FILE
'''
from collections import namedtuple
from threading import Thread
from queue import Queue
import time
import math
import json
import subprocess
import socket
import eval7
import sys
import os
import random
sys.path.append(os.getcwd())
from config import *
FoldAction = namedtuple('FoldAction', [])
CallAction = namedtuple('CallAction', [])
CheckAction = namedtuple('CheckAction', [])
# we coalesce BetAction and RaiseAction for convenience
RaiseAction = namedtuple('RaiseAction', ['amount'])
TerminalState = namedtuple('TerminalState', ['deltas', 'bounty_hits', 'previous_state'])
STREET_NAMES = ['Flop', 'Turn', 'River']
DECODE = {'F': FoldAction, 'C': CallAction, 'K': CheckAction, 'R': RaiseAction}
CCARDS = lambda cards: ','.join(map(str, cards))
PCARDS = lambda cards: '[{}]'.format(' '.join(map(str, cards)))
PVALUE = lambda name, value: ', {} ({})'.format(name, value)
STATUS = lambda players: ''.join([PVALUE(p.name, p.bankroll) for p in players])
# Socket encoding scheme:
#
# T#.### the player's game clock
# P# the- player's index
# H**,** the player's hand in common format
# F a fold action in the round history
# C a call action in the round history
# K a check action in the round history
# R### a raise action in the round history
# B**,**,**,**,** the board cards in common format
# O**,** the opponent's hand in common format
# D### the player's bankroll delta from the round
# Y## (both numbers 0 or 1 (or # which means masked): first is player hit bounty, second is opponent hit bounty)
# Note: only winning player bounty hit is revealed (or both if split pot)
# Q game over
#
# Clauses are separated by spaces
# Messages end with '\n'
# The engine expects a response of K at the end of the round as an ack,
# otherwise a response which encodes the player's action
# Action history is sent once, including the player's actions
class RoundState(namedtuple('_RoundState', ['button', 'street', 'pips', 'stacks', 'hands', 'deck', 'bounties', 'previous_state'])):
'''
Encodes the game tree for one round of poker.
'''
def get_bounty_hits(self):
'''
Determines if each player hit their bounty card during the round.
A bounty is hit if the player's bounty card rank appears in either:
- Their hole cards
- The community cards dealt so far
Returns:
tuple[bool, bool]: A tuple containing two booleans where:
- First boolean indicates if Player 1's bounty was hit
- Second boolean indicates if Player 2's bounty was hit
'''
cards0 = self.hands[0] + ([] if self.street == 0 else self.deck.peek(self.street))
cards1 = self.hands[1] + ([] if self.street == 0 else self.deck.peek(self.street))
cardNames = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']
return (self.bounties[0] in [cardNames[card.rank] for card in cards0],
self.bounties[1] in [cardNames[card.rank] for card in cards1])
def get_delta(self, winner_index: int) -> int:
'''Returns the delta after bounty rules are applied.
Args:
winner_index (int): Index of the winning player. Must be 0 (player A),
1 (player B), or 2 (split pot).
Returns:
int: The delta value after applying bounty rules.
'''
assert winner_index in [0, 1, 2]
bounty_hit_0, bounty_hit_1 = self.get_bounty_hits()
delta = 0
if winner_index == 2:
# Case of split pots
assert(self.stacks[0] == self.stacks[1]) # split pots only happen on the river + equal stacks
delta = STARTING_STACK - self.stacks[0]
if bounty_hit_0 and not bounty_hit_1:
delta = delta * (BOUNTY_RATIO - 1) / 2 + BOUNTY_CONSTANT
elif not bounty_hit_0 and bounty_hit_1:
delta = -(delta * (BOUNTY_RATIO - 1) / 2 + BOUNTY_CONSTANT)
else:
delta = 0
else:
# Case of one player winning
if winner_index == 0:
delta = STARTING_STACK - self.stacks[1]
if bounty_hit_0:
delta = delta * BOUNTY_RATIO + BOUNTY_CONSTANT
else:
delta = self.stacks[0] - STARTING_STACK
if bounty_hit_1:
delta = delta * BOUNTY_RATIO - BOUNTY_CONSTANT
# if delta is not an integer, round it down or up depending on who's in position
if abs(delta - math.floor(delta)) > 1e-6:
delta = math.floor(delta) if self.button % 2 == 0 else math.ceil(delta)
return int(delta)
def showdown(self) -> TerminalState:
'''
Compares the players' hands and computes the final payoffs at showdown.
Evaluates both players' hands (hole cards + community cards) and determines
the winner. The payoff (delta) is calculated based on:
- The winner of the hand
- Whether any bounties were hit
- The current pot size
Returns:
TerminalState: A terminal state object containing:
- List of deltas (positive for winner, negative for loser)
- Tuple of bounty hit results for both players
- Reference to the previous game state
Note:
This method assumes both players have equal stacks when reaching showdown,
which is enforced by an assertion.
'''
score0 = eval7.evaluate(self.deck.peek(5) + self.hands[0])
score1 = eval7.evaluate(self.deck.peek(5) + self.hands[1])
assert(self.stacks[0] == self.stacks[1])
if score0 > score1:
delta = self.get_delta(0)
elif score0 < score1:
delta = self.get_delta(1)
else:
# split the pot
delta = self.get_delta(2)
return TerminalState([int(delta), -int(delta)], self.get_bounty_hits(), self)
def legal_actions(self):
'''
Returns a set which corresponds to the active player's legal moves.
'''
active = self.button % 2
continue_cost = self.pips[1-active] - self.pips[active]
if continue_cost == 0:
# we can only raise the stakes if both players can afford it
bets_forbidden = (self.stacks[0] == 0 or self.stacks[1] == 0)
return {CheckAction} if bets_forbidden else {CheckAction, RaiseAction}
# continue_cost > 0
# similarly, re-raising is only allowed if both players can afford it
raises_forbidden = (continue_cost == self.stacks[active] or self.stacks[1-active] == 0)
return {FoldAction, CallAction} if raises_forbidden else {FoldAction, CallAction, RaiseAction}
def raise_bounds(self):
'''
Returns a tuple of the minimum and maximum legal raises.
'''
active = self.button % 2
continue_cost = self.pips[1-active] - self.pips[active]
max_contribution = min(self.stacks[active], self.stacks[1-active] + continue_cost)
min_contribution = min(max_contribution, continue_cost + max(continue_cost, BIG_BLIND))
return (self.pips[active] + min_contribution, self.pips[active] + max_contribution)
def proceed_street(self):
'''
Resets the players' pips and advances the game tree to the next round of betting.
'''
if self.street == 5:
return self.showdown()
new_street = 3 if self.street == 0 else self.street + 1
return RoundState(1, new_street, [0, 0], self.stacks, self.hands, self.deck, self.bounties, self)
def proceed(self, action):
'''
Advances the game tree by one action performed by the active player.
Args:
action: The action being performed. Must be one of:
- FoldAction: Player forfeits the hand
- CallAction: Player matches the current bet
- CheckAction: Player passes when no bet to match
- RaiseAction: Player increases the current bet
Returns:
Either:
- RoundState: The new state after the action is performed
- TerminalState: If the action ends the hand (e.g., fold or final call)
Note:
The button value is incremented after each action to track whose turn it is.
For FoldAction, the inactive player is awarded the pot.
For CallAction on button 0, both players post blinds.
For CheckAction, advances to next street if both players have acted.
For RaiseAction, updates pips and stacks based on raise amount.
'''
active = self.button % 2
if isinstance(action, FoldAction):
delta = self.get_delta((1 - active) % 2) # if active folds, the other player (1 - active) wins
return TerminalState([delta, -delta], self.get_bounty_hits(), self)
if isinstance(action, CallAction):
if self.button == 0: # sb calls bb
return RoundState(1, 0, [BIG_BLIND] * 2, [STARTING_STACK - BIG_BLIND] * 2, self.hands, self.deck, self.bounties, self)
# both players acted
new_pips = list(self.pips)
new_stacks = list(self.stacks)
contribution = new_pips[1-active] - new_pips[active]
new_stacks[active] -= contribution
new_pips[active] += contribution
state = RoundState(self.button + 1, self.street, new_pips, new_stacks, self.hands, self.deck, self.bounties, self)
return state.proceed_street()
if isinstance(action, CheckAction):
if (self.street == 0 and self.button > 0) or self.button > 1: # both players acted
return self.proceed_street()
# let opponent act
return RoundState(self.button + 1, self.street, self.pips, self.stacks, self.hands, self.deck, self.bounties, self)
# isinstance(action, RaiseAction)
new_pips = list(self.pips)
new_stacks = list(self.stacks)
contribution = action.amount - new_pips[active]
new_stacks[active] -= contribution
new_pips[active] += contribution
return RoundState(self.button + 1, self.street, new_pips, new_stacks, self.hands, self.deck, self.bounties, self)
class Player():
'''
Handles subprocess and socket interactions with one player's pokerbot.
'''
def __init__(self, name, path):
self.name = name
self.path = path
self.game_clock = STARTING_GAME_CLOCK
self.bankroll = 0
self.commands = None
self.bot_subprocess = None
self.socketfile = None
self.bytes_queue = Queue()
def build(self):
'''
Loads the commands file and builds the pokerbot.
'''
try:
with open(self.path + '/commands.json', 'r') as json_file:
commands = json.load(json_file)
if ('build' in commands and 'run' in commands and
isinstance(commands['build'], list) and
isinstance(commands['run'], list)):
self.commands = commands
else:
print(self.name, 'commands.json missing command')
except FileNotFoundError:
print(self.name, 'commands.json not found - check PLAYER_PATH')
except json.decoder.JSONDecodeError:
print(self.name, 'commands.json misformatted')
if self.commands is not None and len(self.commands['build']) > 0:
try:
proc = subprocess.run(self.commands['build'],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
cwd=self.path, timeout=BUILD_TIMEOUT, check=False)
self.bytes_queue.put(proc.stdout)
except subprocess.TimeoutExpired as timeout_expired:
error_message = 'Timed out waiting for ' + self.name + ' to build'
print(error_message)
self.bytes_queue.put(timeout_expired.stdout)
self.bytes_queue.put(error_message.encode())
except (TypeError, ValueError):
print(self.name, 'build command misformatted')
except OSError:
print(self.name, 'build failed - check "build" in commands.json')
def run(self):
'''
Runs the pokerbot and establishes the socket connection.
'''
if self.commands is not None and len(self.commands['run']) > 0:
try:
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
with server_socket:
server_socket.bind(('', 0))
server_socket.settimeout(CONNECT_TIMEOUT)
server_socket.listen()
port = server_socket.getsockname()[1]
proc = subprocess.Popen(self.commands['run'] + [str(port)],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
cwd=self.path)
self.bot_subprocess = proc
# function for bot listening
def enqueue_output(out, queue):
try:
for line in out:
if self.path == r"./player_chatbot":
print(line.strip().decode("utf-8"))
else:
queue.put(line)
except ValueError:
pass
# start a separate bot listening thread which dies with the program
Thread(target=enqueue_output, args=(proc.stdout, self.bytes_queue), daemon=True).start()
# block until we timeout or the player connects
client_socket, _ = server_socket.accept()
with client_socket:
if self.path == r"./player_chatbot":
client_socket.settimeout(PLAYER_TIMEOUT)
else:
client_socket.settimeout(CONNECT_TIMEOUT)
sock = client_socket.makefile('rw')
self.socketfile = sock
print(self.name, 'connected successfully')
except (TypeError, ValueError):
print(self.name, 'run command misformatted')
except OSError:
print(self.name, 'run failed - check "run" in commands.json')
except socket.timeout:
print('Timed out waiting for', self.name, 'to connect')
def stop(self):
'''
Closes the socket connection and stops the pokerbot.
'''
if self.socketfile is not None:
try:
self.socketfile.write('Q\n')
self.socketfile.close()
except socket.timeout:
print('Timed out waiting for', self.name, 'to disconnect')
except OSError:
print('Could not close socket connection with', self.name)
if self.bot_subprocess is not None:
try:
if self.path == r"./player_chatbot":
outs, _ = self.bot_subprocess.communicate(timeout=PLAYER_TIMEOUT)
else:
outs, _ = self.bot_subprocess.communicate(timeout=CONNECT_TIMEOUT)
self.bytes_queue.put(outs)
except subprocess.TimeoutExpired:
print('Timed out waiting for', self.name, 'to quit')
self.bot_subprocess.kill()
outs, _ = self.bot_subprocess.communicate()
self.bytes_queue.put(outs)
with open(self.name + '.txt', 'wb') as log_file:
bytes_written = 0
for output in self.bytes_queue.queue:
try:
bytes_written += log_file.write(output)
if bytes_written >= PLAYER_LOG_SIZE_LIMIT:
break
except TypeError:
pass
def query(self, round_state, player_message, game_log):
'''
Requests one action from the pokerbot over the socket connection.
This method handles communication with the bot, sending the current game state
and receiving the bot's chosen action. It enforces game clock constraints and
validates that the received action is legal.
Args:
round_state (RoundState or TerminalState): The current state of the game.
player_message (list): Messages to be sent to the player bot, including game state
information like time remaining, player position, and cards.
game_log (list): A list to store game events and error messages.
Returns:
Action: One of FoldAction, CallAction, CheckAction, or RaiseAction representing
the bot's chosen action. If the bot fails to provide a valid action, returns:
- CheckAction if it's a legal move
- FoldAction if check is not legal
Notes:
- The game clock is decremented by the time taken to receive a response
- Invalid or illegal actions are logged but not executed
- Bot disconnections or timeouts result in game clock being set to 0
- At the end of a round, only CheckAction is considered legal
'''
legal_actions = round_state.legal_actions() if isinstance(round_state, RoundState) else {CheckAction}
if self.socketfile is not None and self.game_clock > 0.:
clause = ''
try:
player_message[0] = 'T{:.3f}'.format(self.game_clock)
message = ' '.join(player_message) + '\n'
del player_message[1:] # do not send redundant action history
start_time = time.perf_counter()
self.socketfile.write(message)
self.socketfile.flush()
clause = self.socketfile.readline().strip()
end_time = time.perf_counter()
if ENFORCE_GAME_CLOCK and self.path != r"./player_chatbot":
self.game_clock -= end_time - start_time
if self.game_clock <= 0.:
raise socket.timeout
action = DECODE[clause[0]]
if action in legal_actions:
if clause[0] == 'R':
amount = int(clause[1:])
min_raise, max_raise = round_state.raise_bounds()
if min_raise <= amount <= max_raise:
return action(amount)
else:
return action()
game_log.append(self.name + ' attempted illegal ' + action.__name__)
except socket.timeout:
error_message = self.name + ' ran out of time'
game_log.append(error_message)
print(error_message)
self.game_clock = 0.
except OSError:
error_message = self.name + ' disconnected'
game_log.append(error_message)
print(error_message)
self.game_clock = 0.
except (IndexError, KeyError, ValueError):
game_log.append(self.name + ' response misformatted: ' + str(clause))
return CheckAction() if CheckAction in legal_actions else FoldAction()
class Game():
'''
Manages logging and the high-level game procedure.
'''
def __init__(self):
self.log = ['6.9630 MIT Pokerbots - ' + PLAYER_1_NAME + ' vs ' + PLAYER_2_NAME]
self.player_messages = [[], []]
def log_round_state(self, players, round_state):
'''
Incorporates RoundState information into the game log and player messages.
'''
if round_state.street == 0 and round_state.button == 0:
self.log.append('{} posts the blind of {}'.format(players[0].name, SMALL_BLIND))
self.log.append('{} posts the blind of {}'.format(players[1].name, BIG_BLIND))
self.log.append('{} dealt {}'.format(players[0].name, PCARDS(round_state.hands[0])))
self.log.append('{} dealt {}'.format(players[1].name, PCARDS(round_state.hands[1])))
self.player_messages[0] = ['T0.', 'P0', 'H' + CCARDS(round_state.hands[0]), 'G' + round_state.bounties[0]]
self.player_messages[1] = ['T0.', 'P1', 'H' + CCARDS(round_state.hands[1]), 'G' + round_state.bounties[1]]
elif round_state.street > 0 and round_state.button == 1:
board = round_state.deck.peek(round_state.street)
self.log.append(STREET_NAMES[round_state.street - 3] + ' ' + PCARDS(board) +
PVALUE(players[0].name, STARTING_STACK-round_state.stacks[0]) +
PVALUE(players[1].name, STARTING_STACK-round_state.stacks[1]))
self.log.append(f"Current stacks: {round_state.stacks[0]}, {round_state.stacks[1]}")
compressed_board = 'B' + CCARDS(board)
self.player_messages[0].append(compressed_board)
self.player_messages[1].append(compressed_board)
def log_action(self, name, action, bet_override):
'''
Incorporates action information into the game log and player messages.
'''
if isinstance(action, FoldAction):
phrasing = ' folds'
code = 'F'
elif isinstance(action, CallAction):
phrasing = ' calls'
code = 'C'
elif isinstance(action, CheckAction):
phrasing = ' checks'
code = 'K'
else: # isinstance(action, RaiseAction)
phrasing = (' bets ' if bet_override else ' raises to ') + str(action.amount)
code = 'R' + str(action.amount)
self.log.append(name + phrasing)
self.player_messages[0].append(code)
self.player_messages[1].append(code)
def log_terminal_state(self, players, round_state):
'''
Incorporates TerminalState information into the game log and player messages.
'''
previous_state = round_state.previous_state
if FoldAction not in previous_state.legal_actions():
self.log.append('{} shows {}'.format(players[0].name, PCARDS(previous_state.hands[0])))
self.log.append('{} shows {}'.format(players[1].name, PCARDS(previous_state.hands[1])))
self.player_messages[0].append('O' + CCARDS(previous_state.hands[1]))
self.player_messages[1].append('O' + CCARDS(previous_state.hands[0]))
self.log.append('{} awarded {}'.format(players[0].name, round_state.deltas[0]))
self.log.append('{} awarded {}'.format(players[1].name, round_state.deltas[1]))
self.player_messages[0].append('D' + str(round_state.deltas[0]))
self.player_messages[1].append('D' + str(round_state.deltas[1]))
# figure out win/chop, bounty hit, and update logs accordingly
# if round_state.bounty_hits[0]:
# self.log.append('{} hits their bounty'.format(players[0].name))
# if round_state.bounty_hits[1]:
# self.log.append('{} hits their bounty'.format(players[1].name))
hit_chars = ['0', '0']
if round_state.bounty_hits[0]:
hit_chars[0] = '1'
if round_state.bounty_hits[1]:
hit_chars[1] = '1'
if round_state.deltas[0] > 0: # mask out the losing player's hit
hit_chars[1] = '#'
elif round_state.deltas[1] > 0:
hit_chars[0] = '#'
self.player_messages[0].append('Y' + hit_chars[0] + hit_chars[1])
self.player_messages[1].append('Y' + hit_chars[1] + hit_chars[0])
def run_round(self, players, bounties):
'''
Runs one round of poker.
'''
deck = eval7.Deck()
deck.shuffle()
hands = [deck.deal(2), deck.deal(2)]
pips = [SMALL_BLIND, BIG_BLIND]
stacks = [STARTING_STACK - SMALL_BLIND, STARTING_STACK - BIG_BLIND]
round_state = RoundState(0, 0, pips, stacks, hands, deck, bounties, None)
while not isinstance(round_state, TerminalState):
self.log_round_state(players, round_state)
active = round_state.button % 2
player = players[active]
action = player.query(round_state, self.player_messages[active], self.log)
bet_override = (round_state.pips == [0, 0])
self.log_action(player.name, action, bet_override)
round_state = round_state.proceed(action)
self.log_terminal_state(players, round_state)
for player, player_message, delta in zip(players, self.player_messages, round_state.deltas):
player.query(round_state, player_message, self.log)
player.bankroll += delta
def run(self):
'''
Runs one game of poker.
'''
print(' __ _____________ ___ __ __ __ ')
print(' / |/ / _/_ __/ / _ \\___ / /_____ ____/ / ___ / /____')
print(' / /|_/ // / / / / ___/ _ \\/ \'_/ -_) __/ _ \\/ _ \\/ __(_-<')
print('/_/ /_/___/ /_/ /_/ \\___/_/\\_\\\\__/_/ /_.__/\\___/\\__/___/')
print()
print('Starting the Pokerbots engine...')
players = [
Player(PLAYER_1_NAME, PLAYER_1_PATH),
Player(PLAYER_2_NAME, PLAYER_2_PATH)
]
bounties = [-1, -1]
for player in players:
player.build()
player.run()
for round_num in range(1, NUM_ROUNDS + 1):
self.log.append('')
self.log.append('Round #' + str(round_num) + STATUS(players))
if round_num % ROUNDS_PER_BOUNTY == 1:
cardNames = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']
bounties = [cardNames[random.randint(0, 12)], cardNames[random.randint(0, 12)]]
self.log.append(f"Bounties reset to {bounties[0]} for player {players[0].name} and {bounties[1]} for player {players[1].name}")
self.run_round(players, bounties)
self.log.append('Winning counts at the end of the round: ' + STATUS(players))
players = players[::-1]
bounties = bounties[::-1]
self.log.append('')
self.log.append('Final' + STATUS(players))
for player in players:
player.stop()
name = GAME_LOG_FILENAME + '.txt'
print('Writing', name)
with open(name, 'w') as log_file:
log_file.write('\n'.join(self.log))
if __name__ == '__main__':
Game().run()