Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ineiti/connect-4
How to check if a winning move has been made
https://github.com/ineiti/connect-4
Last synced: 21 days ago
JSON representation
How to check if a winning move has been made
- Host: GitHub
- URL: https://github.com/ineiti/connect-4
- Owner: ineiti
- Created: 2022-10-21T07:23:40.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-21T07:28:39.000Z (about 2 years ago)
- Last Synced: 2024-11-03T08:23:54.587Z (2 months ago)
- Language: C++
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Check connect-4 winning positions
We discussed what is the best and shortest algorithm to check the winning positions in a connect-4 game.
My argument was that it's faster to check the whole board every time.
Stefan's argument was that it's easier to check only each player's turn.
So I wrote this code to see how much different the solutions are.Turns out that with a given set of helper functions, checking only each player's turn is smaller.
But it uses one more helper function than checking the whole board every time.
So there is no clear winner :)The solution here includes test-code for all the 4 patterns, including spaces in all the four directions.
And I _did_ find some errors in my code during testing!