forked from LoveDaisy/tetris_game
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathblock_controller.py
47 lines (37 loc) · 1.32 KB
/
block_controller.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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from datetime import datetime
import pprint
import random
class Block_Controller(object):
# init parameter
board_backboard = 0
board_data_width = 0
board_data_height = 0
ShapeNone_index = 0
CurrentShape_class = 0
NextShape_class = 0
# GetNextMove is main function.
# input
# GameStatus : this data include all field status,
# in detail see the internal GameStatus data.
# output
# nextMove : this data include next shape position and the other,
# if return None, do nothing to nextMove.
def GetNextMove(self, nextMove, GameStatus):
t1 = datetime.now()
# print GameStatus
print("=================================================>")
pprint.pprint(GameStatus, width = 61, compact = True)
# search best nextMove -->
# random sample
nextMove["strategy"]["direction"] = random.randint(0,4)
nextMove["strategy"]["x"] = random.randint(0,9)
nextMove["strategy"]["y_operation"] = 1
nextMove["strategy"]["y_moveblocknum"] = random.randint(1,8)
# search best nextMove <--
# return nextMove
print("===", datetime.now() - t1)
print(nextMove)
return nextMove
BLOCK_CONTROLLER = Block_Controller()