From d311af01feb32550aaae8638d4cc167948f5464c Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Mon, 26 Apr 2021 10:53:43 -0500 Subject: Rebase newer branch --- Board.py | 78 ---------------------------------------------------------------- 1 file changed, 78 deletions(-) delete mode 100644 Board.py (limited to 'Board.py') diff --git a/Board.py b/Board.py deleted file mode 100644 index 405ec23..0000000 --- a/Board.py +++ /dev/null @@ -1,78 +0,0 @@ -from random import * - - -class Game: #A class for managing different situations and states happening in the game and on the board - def __init__(self, Mat, dimX, dimY): - self.Mat = Mat - self.dimX = dimX - self.dimY = dimY - - def Initiate(self): #initiating the game board with X and Y dimensions - for i in range(0, self.dimY): - R = [] - for j in range (0, self.dimX): - if i % 2 == 1 and j % 2 == 1: - R.append(1) # Assigning a random number from 1 to 9 to the spots in the board as the points - elif i % 2 == 0 and j % 2 == 0: - R.append('*') # printing asterisks as the dots in the board - else: - R.append(' ') # adding extra space for actions in the game - self.Mat.append(R) - - def Get_matrix(self): # Board matrix - ans = [] - for i in range(0, self.dimY): - R = [] - for j in range(0, self.dimX): - R.append(self.Mat[i][j]) - ans.append(R) - return ans - - def Draw_mat(self): # Drawing the board marix as dots and lines - - if self.dimX > 9: - print(" ", end='') - print(" ", end='') - for i in range(0, self.dimX): - print(str(i), end=' ') - print() - - if self.dimX > 9: - print(" ", end='') - print(" ", end='') - for i in range(0, self.dimX + 1): - print("___", end='') - print() - for j in range(self.dimY): - if self.dimX > 9 and j < 10: - print(" ", end='') - print(str(j) + "| ", end='') - for z in range(self.dimX): - print(str(self.Mat[j][z]), end=' ') - print() - print(" _________________________\n") - - def Get_currentState(self): - return Game(self.Get_matrix(), self.dimX, self.dimY) - - def action(self, i, j): # Applying the actions made by the human or the computer - Sum = 0 - - if j % 2 == 0 and i % 2 == 1: - self.Mat[j][i] = '-' - if j < self.dimY - 1: - if self.Mat[j+2][i] == '-' and self.Mat[j+1][i+1] == '|' and self.Mat[j+1][i-1] == '|': - Sum += self.Mat[j+1][i] - if j > 0: - if self.Mat[j-2][i] == '-' and self.Mat[j-1][i+1] == '|' and self.Mat[j-1][i-1] == '|': - Sum += self.Mat[j-1][i] - - else: - self.Mat[j][i] = '|' - if i < self.dimX - 1: - if self.Mat[j][i+2] == '|' and self.Mat[j+1][i+1] == '-' and self.Mat[j-1][i+1] == '-': - Sum += self.Mat[j][i+1] - if i > 0: - if self.Mat[j][i-2] == '|' and self.Mat[j+1][i-1] == '-' and self.Mat[j-1][i-1] == '-': - Sum += self.Mat[j][i-1] - return Sum \ No newline at end of file -- cgit v1.2.3