This is a web application to play the well-known game of Connect Four. Two players (A is red, B is yellow) are taking turns to fill the board with coins, trying to connect four of one's own coins, either horizontally, vertically or diagonally.

This project was developed by Christian Kollmann as a project in the course “Software Technology Project”, supervised by Oswin Aichholzer, at Graz University of Technology.

The server is written in Java 7, using the Spring framework. The client is written in HTML and JavaScript, using jQuery. Compatibility was tested in Chromium and Mozilla Firefox running on Linux and Android. Nevertheless the application should be compatible with any browser like Microsoft Internet Explorer.

- Either player (A and B) can be controlled by a human or the computer (AI)
- Choose the level of the AI: “Perfect” will always make an optimal move (which might not be unique), “Just win” will randomly choose a winning move (if available, and not necessary optimal), “Random” will randomly pick a column
- Move info: Optionally display the number of half-moves till the end of the game for the possible moves
- Recommend move: Shows the perfect move(s) for the current player (may be more than one move)
- Undo/Redo: Revert the last move(s) made by either player
- Save/Load: Saves the game (in local storage, provided by HTML5) to resume the game later on

The AI of this game is based on an exhaustive evaluation of all possible game positions of up to 23 coins, stored in a large data base. Boards with 24 or more coins are directly evaluated on the server. For each possible board its status (current player win, opponent player win, draw) is known, as well as as the minimum number of half moves needed to force a win from this board. An even number shows in how many further half-moves the game can be won by placing the coin in that column (assuming optimal play of the opponent, otherwise you can win faster). An odd number shows the maximum number of half-moves you can delay the victory of the opponent (again assuming optimal defense play of the opponent). A 'D' indicates a position where the current player can force a draw. So an even number shows a winning move, which guarantees a win for the current player (if she continues to play optimal) in at most this number of half-moves. An optimal winning move is a move which guarantees the shortest available sequence of half-moves till the player wins. In total, the underlying exhaustive data base not only confirms that Connect Four is a first player win. It shows for any possible situation on the board the full information for all possible moves, thus providing perfect information to analyze the whole game.