changed Camelcase error in Code

This commit is contained in:
Falko Victor Habel 2024-04-24 21:28:48 +02:00
parent 83fe41b820
commit a7c1e6d39f
3 changed files with 11 additions and 11 deletions

View File

@ -1,7 +1,7 @@
package game package game
import ( import (
"tictactoe/gamecontrol" "tictactoe/gameControl"
"tictactoe/opponent" "tictactoe/opponent"
"fyne.io/fyne/v2" "fyne.io/fyne/v2"
@ -79,11 +79,11 @@ func Gameloop(row, col int) {
// starting with the human making a move // starting with the human making a move
board[row][col] = PLAYER_X board[row][col] = PLAYER_X
// checking if the game has been won by the human player // checking if the game has been won by the human player
if gamecontrol.PlayerHasWon(board, PLAYER_X) { if gameControl.PlayerHasWon(board, PLAYER_X) {
TextLabel.SetText("X Wins") TextLabel.SetText("X Wins")
} }
// checking if the game is a draw // checking if the game is a draw
if gamecontrol.BoardisFull(board) { if gameControl.BoardisFull(board) {
TextLabel.SetText("Draw") TextLabel.SetText("Draw")
} }
// AI opponent makes a move // AI opponent makes a move
@ -93,12 +93,12 @@ func Gameloop(row, col int) {
ChangeButtonText(bestMove.Row, bestMove.Col) ChangeButtonText(bestMove.Row, bestMove.Col)
// check if AI opponent has won the game // check if AI opponent has won the game
if gamecontrol.PlayerHasWon(board, PLAYER_O) { if gameControl.PlayerHasWon(board, PLAYER_O) {
TextLabel.SetText("O Wins") TextLabel.SetText("O Wins")
DisableAllButtons(gridContainer) DisableAllButtons(gridContainer)
} }
// checking if the game is a draw // checking if the game is a draw
if gamecontrol.BoardisFull(board) { if gameControl.BoardisFull(board) {
TextLabel.SetText("Draw") TextLabel.SetText("Draw")
} }
} }

View File

@ -1,4 +1,4 @@
package gamecontrol package gameControl
// checks if a player has won the game // checks if a player has won the game
func PlayerHasWon(board [3][3]string, player string) bool { func PlayerHasWon(board [3][3]string, player string) bool {

View File

@ -2,7 +2,7 @@ package opponent
import ( import (
"math" "math"
"tictactoe/gamecontrol" "tictactoe/gameControl"
) )
type NextMove struct { type NextMove struct {
@ -13,12 +13,12 @@ type NextMove struct {
// iterative implementation of minimax algorithm // iterative implementation of minimax algorithm
func Minimax(board [3][3]string, depth int, isMaximizingPlayer bool, player string) NextMove { func Minimax(board [3][3]string, depth int, isMaximizingPlayer bool, player string) NextMove {
// check if the game has ended // Evaluate the Board based on who would win the current board
if gamecontrol.PlayerHasWon(board, "X") { if gameControl.PlayerHasWon(board, "X") {
return NextMove{score: -10 + depth} return NextMove{score: -10 + depth}
} else if gamecontrol.PlayerHasWon(board, "O") { } else if gameControl.PlayerHasWon(board, "O") {
return NextMove{score: 10 - depth} return NextMove{score: 10 - depth}
} else if gamecontrol.BoardisFull(board) { } else if gameControl.BoardisFull(board) {
return NextMove{score: 0} return NextMove{score: 0}
} }
// check who's turn it is // check who's turn it is