🧹 Last bit of cleaning up before pushing

This commit is contained in:
NikolajDanger
2021-03-31 01:02:32 +02:00
parent b345720468
commit 6c1a1cf626
37 changed files with 125 additions and 118 deletions

View File

@ -88,7 +88,7 @@ class connectFour():
turn = (game["turn"]+1)%2
self.bot.database["connect 4 games"].update_one({"_id":channel},{"$set":{"turn":turn}})
self.bot.log("Checking for win", level = 10)
self.bot.log("Checking for win")
won, winDirection, winCoordinates = self.isWon(board)
if won != 0:
@ -112,7 +112,7 @@ class connectFour():
gwendoTurn = False
if game["players"][turn] == "Gwendolyn":
self.bot.log("It's Gwendolyn's turn", level = 10)
self.bot.log("It's Gwendolyn's turn")
gwendoTurn = True
self.draw.drawImage(channel)
@ -141,10 +141,10 @@ class connectFour():
def parseconnectFour(self, command, channel, user):
commands = command.split()
if command == "" or command == " ":
return "I didn't get that. Use \"!connectFour start [opponent]\" to start a game. To play against the computer, use difficulty 1 through 5 as the [opponent].", False, False, False, False
return "I didn't get that. Use \"/connectFour start [opponent]\" to start a game. To play against the computer, use difficulty 1 through 5 as the [opponent].", False, False, False, False
elif commands[0] == "start":
# Starting a game
if len(commands) == 1: # if the commands is "!connectFour start", the opponent is Gwendolyn
if len(commands) == 1: # if the commands is "/connectFour start", the opponent is Gwendolyn
commands.append("3")
return self.connectFourStart(channel,user,commands[1]) # commands[1] is the opponent
@ -165,7 +165,7 @@ class connectFour():
if user == game["players"][turn]:
piece = turn + 1
else:
self.bot.log("It wasn't their turn", level = 10)
self.bot.log("It wasn't their turn")
return "It's not your turn!", False, False, False, False
column = int(commands[1])-1
else:
@ -173,7 +173,7 @@ class connectFour():
piece = int(commands[1])
return self.placePiece(channel, piece, column)
else:
return "I didn't get that. Use \"!connectFour start [opponent]\" to start a game. To play against the computer, use difficulty 1 through 5 as the [opponent].", False, False, False, False
return "I didn't get that. Use \"/connectFour start [opponent]\" to start a game. To play against the computer, use difficulty 1 through 5 as the [opponent].", False, False, False, False
# Checks if someone has won the game and returns the winner
def isWon(self, board):
@ -235,7 +235,7 @@ class connectFour():
# Plays as the AI
async def connectFourAI(self, channel):
self.bot.log("Figuring out best move", level = 10)
self.bot.log("Figuring out best move")
game = self.bot.database["connect 4 games"].find_one({"_id":channel})
board = game["board"]
@ -248,7 +248,7 @@ class connectFour():
testBoard = self.placeOnBoard(testBoard,player,column)
if testBoard != None:
scores[column] = await self.minimax(testBoard,difficulty,player%2+1,player,-math.inf,math.inf,False)
self.bot.log("Best score for column "+str(column)+" is "+str(scores[column]), level = 10)
self.bot.log("Best score for column "+str(column)+" is "+str(scores[column]))
possibleScores = scores.copy()