- This project was generated with JAVAFX, playing Connect-4 with "the computer" or "two players."
-
First home screen :
- The user chooses to play with
computer
ortwo players
- The user chooses to play with
-
Second Game scene :
-
The user defines the number of
levels
for the minimax algorithm max level for without pruning 8 and with pruning 10 -
Choose to play with
pruning
orwithout pruning
-
-
Third Game Scene :
-
The
score
of the computer and the player score are shown -
The
Restart
button -
Reset
the game and start with the same initial conditions -
The
Back
button go back to home
- The
showTree
button view the tree of the evaluation of the minimax algorithm where the red arrow indicates the chosen column
With pruning the **X** means the this branche is cut off
-
-
our game the player continue playing until the board is full
-
The cpu is red player
-
Consider overlapping as points (if there is five piecies beside each othermeans 2 points)
-
Check every group of 4 in the whole board (horizontally, vertically, in the positive diagonal, int the negative diagonal) and certain combinations of the 4 group has a weight:
-
4 computer pieces (point) -> 100
-
3 computer pieces and an empty place (candidate point)-> 20
-
2 computer pieces and an empty place (candidate point)-> 6
-
4 opponent pieces (point) -> -150
-
3 opponent pieces and an empty place (candidate point)-> -60
-
2 opponent pieces and an empty place (candidate point) -> -6
-
middle column -> 2 for every piece
-
2 columns beside middle column left and right of it -> 1 for every piece (as the middle col increase the chance for the cpu to win more points)
-
-
Algorithm is defensive
-
The evaluation called at the
terminal nodes
. When the terminal state is reached, we call theevaluateScore
method from theEvaluation class
. This method evaluates the whole heuristic.