@@ -18,7 +18,7 @@ def __init__(self, GameBoard, level):
18
18
"expert" ,
19
19
][level ]
20
20
21
- '''
21
+ """
22
22
Weight board assign the grids on board with weight
23
23
in zigzag order increasing exponentially with base 4
24
24
e.g. for a weight board with size 4, the board weight is
@@ -28,8 +28,8 @@ def __init__(self, GameBoard, level):
28
28
[4^15, 4^14, 4^13, 4^12]]
29
29
30
30
Reference: http://cs229.stanford.edu/proj2016/report/NieHouAn-AIPlays2048-report.pdf
31
- '''
32
-
31
+ """
32
+
33
33
def weightBoard1 (size ):
34
34
board = [[(row * size + col ) for col in range (size )] for row in range (size )]
35
35
for row in range (size ):
@@ -405,11 +405,11 @@ def minnieMoveAlphaBetaImportance(self, depth, alpha, beta, importance, evalFunc
405
405
return evalFunc (), None # depth = 0
406
406
407
407
originalScore = self .GameBoard .score
408
- '''
408
+ """
409
409
Even though the real computer will put the new numbers randomly,
410
410
we still assume that it can put 2 or 4 on any empty tile as it
411
411
wishes to make the board harder for player to solve.
412
- '''
412
+ """
413
413
414
414
# mark the empty tiles with highest importances as "important"
415
415
importantTiles = self .getImporantTiles (importance )
@@ -457,6 +457,7 @@ def getMaxMove3(self):
457
457
the product of the current board score and the sum of the product of weight of a certain tile and the number on it.
458
458
(i.e. GameBoard.score * ∑(row)∑(col) weightBoard[row][col] * GameBoard[row][col])
459
459
"""
460
+
460
461
def evaluate2 (self ):
461
462
score = 0
462
463
for row in range (self .size ):
@@ -587,4 +588,4 @@ def playTheGame(self):
587
588
# print("average score: ", avgscore)
588
589
# winrate = sum(winLose) / len(record)
589
590
# print("winrate: ", winrate)
590
- # print("---Total time: %s seconds ---" % (time.time() - startTime))
591
+ # print("---Total time: %s seconds ---" % (time.time() - startTime))
0 commit comments