# Connect Four Project
## Description
Build a "normal" [Connect Four](https://en.wikipedia.org/wiki/Connect_Four) game with 6 rows and 7 columns that works on PC and Mac OS using C#.
The game will have a competitive AI with different levels of difficulty.
The game will use the C# [Graphics](https://learn.microsoft.com/en-us/dotnet/api/system.drawing.graphics) class.
## Project Success Criteria
- Finish the MVP!
- The game must run and have no known bugs
- The game code will be available on Guy's [github account](https://github.com/luaucode)
- All the members of the Sayfan family must play at least one game to completion
## Team Members
- [Gigi](https://github.com/the-gigi)
- [Guy](https://github.com/luaucode)
- [Saar](https://github.com/Bloblblobl) (honorary member)
## Big Picture Plan
### MVP (Minimal Viable Product)
- Draw the board
- Human player must place a disk in a selected non-full column on their turn
- AI player will place a disk in a selected non-full column on their turn
- When one of the player wins the game ends
- Multiple AI difficulty levels
### Out of scope for MVP (but maybe later)
- Two human players
- Keeping high-score
- Undo functionality
- Disk fall animation
- User registration
- Special rules/modes
## Roadmap
## Meeting Notes
### Debugging EvaluateBoard() - 12-aug-2023
The implementation is too complicated and hard to understand.
Scoring based on sure victory, potential victory and double victory is too barouqe
Decided to switch to the classic [Minimax algorithm](https://en.wikipedia.org/wiki/Minimax)
### Debugging SuperAI - 23-jul-2023
Discovered that FindPotentialColumns() fails for lookup 2 block case.
This is because BoardEvaluator is not looking ahead.
### Kickoff meeting - 22-oct-2022
- Project meetings will be ad hoc as needed
- Establish work session cadence
#### Action items
- [x] [Guy] Download and Install [Visual Studio for Windows](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&channel=Release&version=VS2022&source=VSLandingPage&cid=2030&passive=false)
- [x] [Gigi] Download and Install [Visual Studio for Mac](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio-mac/?sku=communitymac&rel=17)
- [x] [Guy] Create a github repository called `connect-four`
- [ ] [Guy] Implement a C# hello world program
- [x] [Gigi] Implement a C# hello world program
- [x] [Gigi] Schedule weekly work session
### Brief Kitchen Meeting - 16-june-2023
Gigi suggested two micro-projects for Guy.
#### Eliminate IBoard
The IBoard interface doesn't contribute much and just adds complexitiy when we need to convert from IBoard to Board or add methods to the IBoard interface.
Here is what this micro-project is all about.
1. Remove the IBoard interface.
2. Replace all references to IBoard with just Board
3. Update the Board's [copy constructor](https://github.com/luaucode/connect-4/blob/main/connect-4-core/Board.cs#L19) to take another Board instead of an IBoard
4. Remove from GameEngine the GetBoard() method
5. Update the GameEngine to pass a copy of its board (new Board(board) to the active player [here](https://github.com/luaucode/connect-4/blob/main/connect-4-core/GameEngine.cs#L49).
### Use an enum for the player
The C# [enum](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/enum) type allows restricting numeric types to a few values.
Currently the player is a nullable uint. This causes two problems:
1. Dealing with a player that may or may not be null
2. Conversion to/from int
Instead, replace the type of player from `uint?` to the following enum:
```
enum Player : uint
{
Player1,
Player2
None,
}
```
Update the code and there will not be a need to convert types anymore.
## Bugs

AI wins with 3 in a row in rows 1 through 3
Multi-Click bug -> Col full
AI not smart
## Reference
[Using WebSockets for two-way communication in React apps](https://blog.logrocket.com/websockets-two-way-communication-react-app/)
[Code Bullet - Creating the perfect Connect4 AI](https://www.youtube.com/watch?v=XRVA5PMSKKE)
[Parity - Connect4 Strategy](https://www.youtube.com/watch?v=VSTQnPUILfo)
[Perfect connect4 AI in C++ with optimizations](http://blog.gamesolver.org)
[Connect 4 AI - How it works!](https://roadtolarissa.com/connect-4-ai-how-it-works)
[Keith Galli - Minimax Scoring](https://youtu.be/MMLtza3CZFM?si=xuKBjimIytXdnuW7&t=865)