- This project was generated with JAVAFX, playing Connect-4 with "the computer" or "two players."
-
First home screen :
- The user chooses to play with
computerortwo players
- The user chooses to play with
-
Second Game scene :
-
The user defines the number of
levelsfor the minimax algorithm max level for without pruning 8 and with pruning 10 -
Choose to play with
pruningorwithout pruning
-
-
Third Game Scene :
-
The
scoreof the computer and the player score are shown -
The
Restartbutton -
Resetthe game and start with the same initial conditions -
The
Backbutton go back to home
- The
showTreebutton 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 theevaluateScoremethod from theEvaluation class. This method evaluates the whole heuristic.





