Package com.neven.ticTacToeGame.model
Class PlayerVsAlgorithmGame
- java.lang.Object
-
- com.neven.ticTacToeGame.model.Game
-
- com.neven.ticTacToeGame.model.PlayerVsAlgorithmGame
-
public class PlayerVsAlgorithmGame extends Game
ClassPlayerVsAlgorithmGame
extendGame
class and implement his two abstract methods for game with an Algorithm MiniMax(MiniMaxAlgorithm
).- Author:
- Arterm Koliushko, https://www.linkedin.com/in/artem-koliushko/
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
PLAYER_2_NAME
Constant with a name of the player2(in this case an Algorithm MiniMax).
-
Constructor Summary
Constructors Constructor Description PlayerVsAlgorithmGame()
Constructor for classPlayerVsAlgorithmGame
.
Initialize parent(Game
class) constructor with a name of second player.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Game
makeFirstMove()
This method overrides parentGame.makeFirstMove()
method.protected void
makeMove()
This method overrides parentGame.makeMove()
method.-
Methods inherited from class com.neven.ticTacToeGame.model.Game
isPlayerWin, switchCurrentPlayer, winningCheckAndMakingMove
-
-
-
-
Field Detail
-
PLAYER_2_NAME
private static final java.lang.String PLAYER_2_NAME
Constant with a name of the player2(in this case an Algorithm MiniMax). Used in constructor for creation an object of theGame
.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PlayerVsAlgorithmGame
public PlayerVsAlgorithmGame()
Constructor for classPlayerVsAlgorithmGame
.
Initialize parent(Game
class) constructor with a name of second player.
-
-
Method Detail
-
makeFirstMove
public Game makeFirstMove()
This method overrides parentGame.makeFirstMove()
method.
According to theMiniMaxAlgorithm
specific, it is always return asMiniMaxAlgorithm.findBestMove()
result first positive value of theMiniMaxAlgorithm
move, if theMiniMaxAlgorithm
will be make a move in an empty game field it is always will be first cell. So for making first move more variable, this method returns randomly chosen one of the 4 starting positions(corners of the game field).- Specified by:
makeFirstMove
in classGame
- Returns:
PlayerVsPlayerGame
with a first move of the algorithm.
-
makeMove
protected void makeMove()
This method overrides parentGame.makeMove()
method.
Method create an object of theMiniMaxAlgorithm
class, and call hisMiniMaxAlgorithm.findBestMove()
method to receive number of game field cell to which put the algorithm name value. This cell will be aMiniMaxAlgorithm
move in the game.
-
-