This guide explains how to test the AI improvements for the edge/corner blind spot fix.
-
Start a local web server:
python3 -m http.server 8000 # OR npx live-server -
Open your browser to:
http://localhost:8000/test-ai.html -
Click "Run Tests" to execute all 13 test cases
-
Review results:
- ✅ Green = Test passed
- ❌ Red = Test failed
- Tests that AI takes winning moves when available
- Covers horizontal and vertical wins
- Validates win priority over other moves
- Tests that AI blocks opponent's winning moves
- Covers horizontal and vertical blocks
- Validates blocking priority is high
- Tests AI response to column 0 stacking
- Tests AI response to column 6 stacking
- Tests AI blocks 3-stacks on edges
- Validates the fix for the reported vulnerability
- Tests AI creates double threats when possible
- Tests AI blocks opponent double threat setups
- Validates advanced tactical awareness
- Tests AI takes wins over blocks
- Validates priority ordering is correct
- Tests AI prefers center on empty board
- Tests AI contests center appropriately
You can also test manually by playing the game:
- Open
index.htmlin your browser - Select "VS AI" mode
- Try to build a vertical stack on column 0 or 6
- The AI should now contest these edges instead of ignoring them
Turn 1: You play column 0
Turn 2: AI plays column 3 (center)
Turn 3: You play column 0 again
Turn 4: AI should now play column 0 or 1 (not just column 3!)
Turn 1: You play column 6
Turn 2: AI plays column 3 (center)
Turn 3: You play column 6 again
Turn 4: AI should now play column 5 or 6 (not just column 3!)
All 13 tests should pass:
- ✅ AI takes horizontal win
- ✅ AI takes vertical win
- ✅ AI blocks horizontal threat
- ✅ AI blocks vertical threat
- ✅ AI responds to column 0 stacking
- ✅ AI responds to column 6 stacking
- ✅ AI blocks corner 3-stack on column 0
- ✅ AI blocks corner 3-stack on column 6
- ✅ AI creates double threat
- ✅ AI blocks opponent double threat setup
- ✅ AI takes win over block
- ✅ AI prefers center on empty board
- ✅ AI contests center
- Ensure you're using a local web server (not file://)
- Check browser console for errors
- Verify Connect-4.js and ai-tests.js are loaded
- This may indicate the AI needs deeper search
- Try increasing the depth parameter in the test (currently 10)
- Check that all code changes were applied correctly
- AI uses randomness when multiple moves have equal scores
- Try multiple games to see consistent patterns
- The AI should generally contest edges, not always the exact same column
- Each test runs a depth-10 search
- Full test suite takes 10-30 seconds
- Browser may appear frozen during testing (this is normal)
- Results are logged to console for debugging
To verify all changes were applied correctly:
node validate-changes.jsThis checks:
- Move ordering priorities
- Threat prevention function
- Edge threat detection
- Opening book expansion
- Test file existence
- Documentation updates