Merge branch 'main' of https://git.cdezselfhosted.pw/cdez/CS470-Projects
This commit is contained in:
commit
7cf4d90336
4 changed files with 43 additions and 0 deletions
34
Boggle/03_test.py
Normal file
34
Boggle/03_test.py
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
def loadBoard(fileName):
|
||||||
|
with open(fileName) as board:
|
||||||
|
boardContents = board.read()
|
||||||
|
boardContents = boardContents.splitlines()
|
||||||
|
for boardIter in range(len(boardContents)):
|
||||||
|
boardContents[boardIter] = list(boardContents[boardIter].split())
|
||||||
|
return boardContents
|
||||||
|
|
||||||
|
def printBoard(boardInput):
|
||||||
|
for boardIter in range(len(boardInput)):
|
||||||
|
for boardIterTwo in range(len(boardInput[boardIter])):
|
||||||
|
print(boardInput[boardIter][boardIterTwo], end=" ")
|
||||||
|
print()
|
||||||
|
|
||||||
|
def possibleMoves(inputCoords, boardInput):
|
||||||
|
maxLen = len(boardInput) - 1
|
||||||
|
moveList = []
|
||||||
|
|
||||||
|
# possible moves: (x+1, y), (x-1, y), (x, y+1), (x, y-1), (x+1, y+1), (x-1, y-1), (x+1, y-1), (x-1, y+1)
|
||||||
|
possibleMoves = [(1, 0), (-1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
|
||||||
|
|
||||||
|
for move in possibleMoves:
|
||||||
|
newX = inputCoords[0] + move[0]
|
||||||
|
newY = inputCoords[1] + move[1]
|
||||||
|
if (0 <= newX <= maxLen) and (0 <= newY <= maxLen):
|
||||||
|
moveList.append((newX, newY))
|
||||||
|
|
||||||
|
print(moveList)
|
||||||
|
# return moveList
|
||||||
|
|
||||||
|
# TODO define runBoard and other functions.
|
||||||
|
runBoard("board2.txt", "twl06.txt")
|
||||||
|
runBoard("board3.txt", "twl06.txt")
|
||||||
|
runBoard("board4.txt", "twl06.txt")
|
||||||
2
Boggle/board2.txt
Normal file
2
Boggle/board2.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
E N
|
||||||
|
J O
|
||||||
3
Boggle/board3.txt
Normal file
3
Boggle/board3.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
Z L B
|
||||||
|
Q M U
|
||||||
|
R F Q
|
||||||
4
Boggle/board4.txt
Normal file
4
Boggle/board4.txt
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
Y W A B
|
||||||
|
Y X I D
|
||||||
|
Q M D J
|
||||||
|
P L N A
|
||||||
Loading…
Add table
Add a link
Reference in a new issue