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

View File

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

View File

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