Skip to content

Commit c01c03f

Browse files
Merge pull request #2744 from avinashkranjan/deepsource-transform-4f100d09
format code with autopep8
2 parents a5dd182 + 7087af7 commit c01c03f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

AI-driven 2048(New game)/2048.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import random
22
import copy
33

4+
45
class AI2048:
56
def __init__(self, board):
67
self.board = board
@@ -83,8 +84,10 @@ def calculate_monotonicity(self):
8384
next += 1
8485
if next >= 4:
8586
next -= 1
86-
current_value = 0 if self.board[i][current] == 0 else math.log2(self.board[i][current])
87-
next_value = 0 if self.board[i][next] == 0 else math.log2(self.board[i][next])
87+
current_value = 0 if self.board[i][current] == 0 else math.log2(
88+
self.board[i][current])
89+
next_value = 0 if self.board[i][next] == 0 else math.log2(
90+
self.board[i][next])
8891
if current_value > next_value:
8992
monotonicity[0] += next_value - current_value
9093
elif next_value > current_value:
@@ -100,8 +103,10 @@ def calculate_monotonicity(self):
100103
next += 1
101104
if next >= 4:
102105
next -= 1
103-
current_value = 0 if self.board[current][j] == 0 else math.log2(self.board[current][j])
104-
next_value = 0 if self.board[next][j] == 0 else math.log2(self.board[next][j])
106+
current_value = 0 if self.board[current][j] == 0 else math.log2(
107+
self.board[current][j])
108+
next_value = 0 if self.board[next][j] == 0 else math.log2(
109+
self.board[next][j])
105110
if current_value > next_value:
106111
monotonicity[2] += next_value - current_value
107112
elif next_value > current_value:
@@ -209,11 +214,13 @@ def flip_board(self, board):
209214
def transpose_board(self, board):
210215
board[:] = [list(i) for i in zip(*board)]
211216

217+
212218
def print_board(board):
213219
for row in board:
214220
print(row)
215221
print()
216222

223+
217224
if __name__ == "__main__":
218225
board = [
219226
[0, 2, 2, 4],

0 commit comments

Comments
 (0)