aboutsummaryrefslogtreecommitdiffstats
path: root/Board.py
diff options
context:
space:
mode:
authorMatt Strapp <strap012@umn.edu>2021-04-26 10:53:43 -0500
committerMatt Strapp <strap012@umn.edu>2021-04-26 15:03:12 -0500
commitd311af01feb32550aaae8638d4cc167948f5464c (patch)
tree3c0b8606a7a5267e3e890a63b8565c5c27f10438 /Board.py
parentactually add files (diff)
downloadcsci4511w-d311af01feb32550aaae8638d4cc167948f5464c.tar
csci4511w-d311af01feb32550aaae8638d4cc167948f5464c.tar.gz
csci4511w-d311af01feb32550aaae8638d4cc167948f5464c.tar.bz2
csci4511w-d311af01feb32550aaae8638d4cc167948f5464c.tar.lz
csci4511w-d311af01feb32550aaae8638d4cc167948f5464c.tar.xz
csci4511w-d311af01feb32550aaae8638d4cc167948f5464c.tar.zst
csci4511w-d311af01feb32550aaae8638d4cc167948f5464c.zip
Rebase newer branch
Diffstat (limited to '')
-rw-r--r--Board.py78
1 files changed, 0 insertions, 78 deletions
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