vadman97 / golangchessai Goto Github PK
View Code? Open in Web Editor NEWGo Chess AI - Exploring Parallel Search Techniques with a Novel Golang Chess Engine
License: GNU General Public License v3.0
Go Chess AI - Exploring Parallel Search Techniques with a Novel Golang Chess Engine
License: GNU General Public License v3.0
Left castle moves king but does not put rook right of king
Average move time:
White: 6.025332s
Black: 5.452923s
Game state: Active
Alloc = 2923 MiB | NumGC = 48
Player AI (MiniMax,depth:3 - White) thinking...
W_R to B_B
move from (7, 0) to (5, 0)
B_K to _
move from (0, 4) to (0, 2)
W_R to B_P
move from (5, 0) to (3, 0)
Move 33 by White
0 1 2 3 4 5 6 7
0 B_R| | | |B_K| |B_N|B_R 0
1 |B_P| |B_B| |B_P| |B_P 1
2 | |B_P| |B_P|B_Q|B_P| 2
3 B_P| | | | | | | 3
4 | | |W_P| |W_P| | 4
5 W_R|W_P|W_N| |W_P| | |W_Q 5
6 |W_P|W_P| |W_B|W_K|W_P|W_P 6
7 | |W_B| | |W_R| | 7
0 1 2 3 4 5 6 7
White AI (MiniMax,depth:3 - White) thought for 8.513032s
Game state: Active
Alloc = 4153 MiB | NumGC = 48
Player AI (MTDF,depth:6 - Black) thinking...
B_K to _
move from (0, 4) to (0, 2)
W_Q to _
move from (5, 7) to (4, 6)
B_Q to _
move from (2, 5) to (1, 4)
W_R to _
move from (5, 0) to (7, 0)
B_P to _
move from (1, 1) to (3, 1)
W_Q to _
move from (4, 6) to (3, 6)
Move 34 by Black
0 1 2 3 4 5 6 7
0 B_R| |B_K| | | |B_N|B_R 0
1 |B_P| |B_B| |B_P| |B_P 1
2 | |B_P| |B_P|B_Q|B_P| 2
3 B_P| | | | | | | 3
4 | | |W_P| |W_P| | 4
5 W_R|W_P|W_N| |W_P| | |W_Q 5
6 |W_P|W_P| |W_B|W_K|W_P|W_P 6
7 | |W_B| | |W_R| | 7
0 1 2 3 4 5 6 7
Black AI (MTDF,depth:6 - Black) thought for 436.9795ms
Average move time:
White: 5.921284s
Black: 5.145015s
Game state: Active
Alloc = 4224 MiB | NumGC = 48
Create two params in Player - DepthSearch, TimeSearch, use goroutine to track time and allow iterative mtdf to function to certain time limits.
We have the case where there are no more moves left. In this case, the game should end in a draw and the test should finish. Instead it is attempting to move from (0, 0) to (0, 0), resulting in an error. The reason behind this is we have a best variable (ScoredMove) which gets initialized with default value. I suggest we return nil, pass it up, and at some point declare a draw. This may require some redesign of the functions that are called.
As of now, I have skipped this test so that #29 can be merged.
If there are no moves and the king is not in check, it is a tie. If the same piece moves 3 times or no piece is taken in 50 moves, it is a tie. #12 will track last moves
Shouldn't clear transposition table / evaluation map because they are typically small.
Currently only even depth allowed because evaluation always from perspective of our player. If odd, make evaluation negative
If a check is caused by a piece being moved out of the way that is currently blocking a check, that piece cannot be moved out of the way
AI should try picking different pieces to see optimal in case of promotion
If the king is in check, the only moves allowed should be moving out of check.
Implement the GET/POST routes in the spec: https://docs.google.com/document/d/1PyhBEtEMbtUZWStVOOR8W9UrY8YB0pqUpyivcAdrBvU/edit#heading=h.olwtsxp0dt2t
Create the initial WebSocket interface for allowing the player to make moves. Would be nice to also test if an incoming websocket data would allow a game to be played
looks like miniMax player color gets messed up? one plays optimally for self, the other plays as if it is making the best decision for the other player (optimally for other).
Can we combine them to prevent duplicate work? Would need to invert evaluation... might not even make sense for transposition table.
instead of IsInCheckmate and IsStalemate calling GetAllMoves, write HasMoves function that breaks on first move - most of the time we have a move so it will return much faster
Discuss hash table implementation
Right now, the AI could be in a bad situation. It could attempt to force a draw, but it will never offer one. We need to implement the ability for AI to offer a draw to the opponent.
Cache using ConcurrentHashMap data structure to prevent recomputing
Refactor for separate files
Following https://docs.google.com/document/d/1PyhBEtEMbtUZWStVOOR8W9UrY8YB0pqUpyivcAdrBvU/edit, implement frontend logic to get moves, make player moves and send to backend, display current gameboard state from AI from backend
Currently en passant would work regardless if pawn moved trice by one or once by two from the starting row.
Fix via special data in gameboard representing state of the pawns in the past.
Idea:
Store column index of pawn last double-moved
Clear or update on next boardmove - only 3/4 bits? 0-15 pawn ids - store as 4 extra bits
Transposition table, evaluation should take into account the 50 rule draw counter as part of the hash since it affects the score
Currently only a bug for transposition table where AI will ignore the 50 rule draw in pruning, making low priority
If there are no moves, this is a tie or a loss depending on whether king is in check.
Use this in the heuristic so that the player is incentivized to win, not take the king
King should not be takeable.
cache hits percentages, memory usage etc
Ensure King CAN castle
Why does AI not want to castle? Is this an issue with castling heuristic or the actual castle move?
Use difficult positions that have occurred in grandmaster games to see if we can find them
Use this to time performance of parallel at different depths / at with different cores
Related to @dadhia 's idea of doing a custom fully associated data structure for hash lookup
don't need to recalculate - do all in one pass over the board.
Ensure heuristic evaluation function works correctly 100%
Use more attributes in the scoring, following https://www.quora.com/What-are-some-heuristics-for-quickly-evaluating-chess-positions and https://github.com/Vadman97/ChessGame/blob/master/src/vad/AIPlayer.java#L310.
Lose if you exceed time limit. Some way for AI to know this to allocate time
To improve evaluation function, we need a way to compare changes for playing strength. Create an ELO calculator or some other test bench to play new evaluation against previous.
run two random players, have all the AI get best move for each color and compare to know AI is consistent and actually gets the best move
A team wins if the other king is in check and cannot do anything to get out of check.
Use this in the heuristic so that the player is incentivized to win, not take the king
King should not be takeable.
run when memory low - just clear all caches for now for simplicity
Might be related to #22
RIght now, when we build moves in GetMoves, we try each more and calculate AttackableBoard for each move. This is really slow (O(n^4) wrt. number of squares of board)
If we do #22, this may be much better. Alternatively maybe we can get the AttackableBoard without recalculating, just by somehow applying the attackable positions of a new move and then undoing after trying the move but idk if this is possible
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.