GithubHelp home page GithubHelp logo

go-alice-chess's Introduction

go-alice-chess (WIP)

Alice chess implementation written in Go

Introduction:

https://en.wikipedia.org/wiki/Alice_chess

“For some minutes Alice stood without speaking, looking out in all directions over the country – and a most curious country it was. There were a number of tiny little brooks running straight across it from side to side, and the ground between was divided up into squares by a number of little green hedges, that reached from brook to brook. ‘I declare it’s marked out just like a large chessboard!’ Alice said at last.” Through the Looking-Glass (1871) - Lewis Carroll

Usage:

go build && ./go-alice-chess

go-alice-chess's People

Contributors

glindsell avatar sachinvarghese avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

sachinvarghese

go-alice-chess's Issues

Engine includes valid moves that leave player in check

Example in this game throughout the final 3 moves shown white king is in check from black knight on board B:

 *--------------*
Move Count: 136
Turn: Black
Moves: [e7f7 e7d8 c7a7 c7b7 c7c8 e5d3 e5f3 e5f7 h7h6 h2g1 h2h1 h2a2 h2b2 h2c2 h2d2 h2e2 h2f2 h2g2 h2h3 c3c1 c3c2 c3b3 c3d3 c3e3 c3f3 c4f1 c4a2 c4e2 c4b3 c4d3 c4b5 g7d4 g7h6 g7h8 g3f1 g3h1 g3e2 g3e4 g3h5 b6b7]
Chosen: c4a2
Board: B

 --- Board A ---

 A B C D E F G H
8- - - - - - - - 
7- - ♜ ♟ ♚ - ♗ ♟ 
6♟ - - - - ♟ - - 
5♙ - - ♙ ♞ ♙ - - 
4- - ♙ - - - - - 
3- - ♕ - - - - - 
2♝ - - - - - - - 
1- - - - - - - - 

 --- Board B ---

 A B C D E F G H
8- - - - ♖ - - - 
7- - - - - - ♝ ♖ 
6- ♟ ♙ ♘ ♟ - ♟ - 
5- - ♟ - - - ♙ ♙ 
4- - - - - ♙ ♗ - 
3- - ♜ - - - ♞ ♘ 
2- - - - - - - ♛ 
1- - - - - - - ♔ 

 *--------------*
Move Count: 137
Turn: White
Moves: [c3a1 c3c1 c3e1 c3b2 c3c2 c3d2 c3a3 c3b3 c3d3 c3e3 c3f3 c3b4 c3d4 c3e5 g7f6 g7h6 g7f8 g7h8 h1g1 h1g2 h1h2 h7h6 h7h8 e8e6 e8a8 e8b8 e8c8 e8d8 e8f8 e8g8 e8h8 g4d1 g4e2 g4f3 g4e6 h3g1 h3f2 d6e4 d6b5 d6b7 d6f7 d6c8 h5g6 h5h6]
Chosen: h5h6
Board: B

 --- Board A ---

 A B C D E F G H
8- - - - - - - - 
7- - ♜ ♟ ♚ - ♗ ♟ 
6♟ - - - - ♟ - ♙ 
5♙ - - ♙ ♞ ♙ - - 
4- - ♙ - - - - - 
3- - ♕ - - - - - 
2♝ - - - - - - - 
1- - - - - - - - 

 --- Board B ---

 A B C D E F G H
8- - - - ♖ - - - 
7- - - - - - ♝ ♖ 
6- ♟ ♙ ♘ ♟ - ♟ - 
5- - ♟ - - - ♙ - 
4- - - - - ♙ ♗ - 
3- - ♜ - - - ♞ ♘ 
2- - - - - - - ♛ 
1- - - - - - - ♔ 

 *--------------*
Move Count: 138
Turn: Black
Moves: [e7f7 e7d8 c7c4 c7a7 c7b7 c7c8 a2b1 a2b3 a2c4 e5d3 e5f3 e5c4 e5f7 h2g1 h2h1 h2b2 h2c2 h2d2 h2e2 h2f2 h2g2 h2h3 c3c1 c3c2 c3b3 c3d3 c3e3 c3f3 g7d4 g7h8 g3f1 g3h1 g3e2 g3e4 g3h5 b6b7]
Chosen: h2g2
Board: B

 --- Board A ---

 A B C D E F G H
8- - - - - - - - 
7- - ♜ ♟ ♚ - ♗ ♟ 
6♟ - - - - ♟ - ♙ 
5♙ - - ♙ ♞ ♙ - - 
4- - ♙ - - - - - 
3- - ♕ - - - - - 
2♝ - - - - - ♛ - 
1- - - - - - - - 

 --- Board B ---

 A B C D E F G H
8- - - - ♖ - - - 
7- - - - - - ♝ ♖ 
6- ♟ ♙ ♘ ♟ - ♟ - 
5- - ♟ - - - ♙ - 
4- - - - - ♙ ♗ - 
3- - ♜ - - - ♞ ♘ 
2- - - - - - - - 
1- - - - - - - ♔ 

 *--------------*
Move Count: 139
Turn: White
panic: No possible moves

Kings can make illegal moves that put it in check

e.g. Move e6e7 puts the black king in check on the board on which it is played, so this move should not be available.

 --- Board A ---
8- - - - - ♔ - -
7- - - - - - - -
6- - - - - - - -
5- - - - - - - -
4- - - - - - - -
3- - - - - - - -
2- - - - - - - -
1- - - - - - - -
 A B C D E F G H

 --- Board B ---
8♙ - - - - - - -
7- - - - - - - -
6- - - - ♚ - - -
5- - - - - - - -
4- - - - - - - -
3- - - - - - - -
2- - - - - - - -
1- - - - - - - -
 A B C D E F G H

 *--------------*
Move Count: 677
Turn: White
Moves A: [f8g7 f8e8 f8g8]
Moves B: []
Chosen: f8e8
Board: A

 --- Board A ---
8- - - - - - - -
7- - - - - - - -
6- - - - - - - -
5- - - - - - - -
4- - - - - - - -
3- - - - - - - -
2- - - - - - - -
1- - - - - - - -
 A B C D E F G H

 --- Board B ---
8♙ - - - ♔ - - -
7- - - - - - - -
6- - - - ♚ - - -
5- - - - - - - -
4- - - - - - - -
3- - - - - - - -
2- - - - - - - -
1- - - - - - - -
 A B C D E F G H

 *--------------*
Move Count: 678
Turn: Black
Moves A: []
Moves B: [e6d5 e6e5 e6f5 e6d6 e6f6 e6d7 e6e7 e6f7]
Chosen: e6e7
Board: B

 --- Board A ---
8- - - - - - - -
7- - - - ♚ - - -
6- - - - - - - -
5- - - - - - - -
4- - - - - - - -
3- - - - - - - -
2- - - - - - - -
1- - - - - - - -
 A B C D E F G H

 --- Board B ---
8♙ - - - ♔ - - -
7- - - - - - - -
6- - - - - - - -
5- - - - - - - -
4- - - - - - - -
3- - - - - - - -
2- - - - - - - -
1- - - - - - - -
 A B C D E F G H

 *--------------*
Move Count: 679
Turn: White
Moves A: []
Moves B: []
No possible moves, stalemate

Stalemate wrongly identified as checkmate

Here a previous check on board B causes a future position to be thought of as checkmate when it is actually stalemate.

I think this is down to the fact that the two boards hold a check flag each, which only gets updated individually per board. A fix for now will be to hold the same check info for both boards, even though the check is only occuring on one board. Perhaps later, check can be moved up a level to the Game abstraction, rather than the Position (or board) abstraction and some more fine-grained logic can be used to discern which board the check is indeed ocurring on.

 --- Board A ---
8- - - - - - - -
7- - - - - - - -
6- - - - - - - -
5- ♜ - - - - - -
4- - - - - - ♛ -
3- - - - - - - -
2- - - - - - - -
1- - - - - - - -
 A B C D E F G H

 --- Board B ---
8- ♔ - - - - - -
7- - - - - - - -
6- ♚ - - - - - -
5- - - - - - - -
4♟ - - - - - - -
3- - - - - - - -
2- - - - - - - -
1- - - - - - - -
 A B C D E F G H

 *--------------*
Move Count: 428
Turn: Black
Moves A: [g4d1 g4g1 g4e2 g4g2 g4f3 g4g3 g4h3 g4b4 g4c4 g4d4 g4e4 g4f4 g4h4 g4f5 g4g5 g4h5 g4e6 g4g6 g4d7 g4g7 g4c8 g4g8 b5b1 b5b2 b5b3 b5b4 b5a5 b5c5 b5d5 b5e5 b5f5 b5g5 b5h5 b5b7]
Moves B: [b6a5 b6c5 b6a6 b6c6 b6a7 b6b7 b6c7 a4a3]
Chosen: g4c8
Board: A

 --- Board A ---
8- - - - - - - -
7- - - - - - - -
6- - - - - - - -
5- ♜ - - - - - -
4- - - - - - - -
3- - - - - - - -
2- - - - - - - -
1- - - - - - - -
 A B C D E F G H

 --- Board B ---
8- ♔ ♛ - - - - -
7- - - - - - - -
6- ♚ - - - - - -
5- - - - - - - -
4♟ - - - - - - -
3- - - - - - - -
2- - - - - - - -
1- - - - - - - -
 A B C D E F G H

 *--------------*
Move Count: 429
Turn: White
Moves A: []
Moves B: [b8a7 b8c7 b8a8 b8c8]
Chosen: b8a7
Board: B

 --- Board A ---
8- - - - - - - -
7♔ - - - - - - -
6- - - - - - - -
5- ♜ - - - - - -
4- - - - - - - -
3- - - - - - - -
2- - - - - - - -
1- - - - - - - -
 A B C D E F G H

 --- Board B ---
8- - ♛ - - - - -
7- - - - - - - -
6- ♚ - - - - - -
5- - - - - - - -
4♟ - - - - - - -
3- - - - - - - -
2- - - - - - - -
1- - - - - - - -
 A B C D E F G H

 *--------------*
Move Count: 430
Turn: Black
Moves A: [b5b1 b5b2 b5b3 b5b4 b5a5 b5c5 b5d5 b5e5 b5f5 b5g5 b5h5 b5b7 b5b8]
Moves B: [b6a5 b6c5 b6c6 b6c7 c8c1 c8c2 c8c3 c8h3 c8c4 c8g4 c8c5 c8f5 c8a6 c8c6 c8e6 c8b7 c8c7 c8d7 c8a8 c8b8 c8d8 c8e8 c8f8 c8g8 c8h8 a4a3]
Chosen: a4a3
Board: B

 --- Board A ---
8- - - - - - - -
7♔ - - - - - - -
6- - - - - - - -
5- ♜ - - - - - -
4- - - - - - - -
3♟ - - - - - - -
2- - - - - - - -
1- - - - - - - -
 A B C D E F G H

 --- Board B ---
8- - ♛ - - - - -
7- - - - - - - -
6- ♚ - - - - - -
5- - - - - - - -
4- - - - - - - -
3- - - - - - - -
2- - - - - - - -
1- - - - - - - -
 A B C D E F G H

 *--------------*
Move Count: 431
Turn: White
Moves A: []
Moves B: []
Checkmate

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.