Git Product home page Git Product logo

golangchessai's Introduction

recursion

Hi, I'm Vadim!

golangchessai's People

Contributors

alexander-lee avatar dependabot[bot] avatar triki97 avatar vadman97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

golangchessai's Issues

Left castle is broken

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 

Time vs Depth based AI limits

Create two params in Player - DepthSearch, TimeSearch, use goroutine to track time and allow iterative mtdf to function to certain time limits.

Fix TestBoardAI()

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.

stalemate

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

Discover Check logic

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

Check logic

If the king is in check, the only moves allowed should be moving out of check.

Initial WebSocket Interface

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

Optimize Checkmate, Stalemate

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

AI never wants to offer draw

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.

Pawn en passant

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

Game over logic / Game tie logic

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.

King does not want to castle

Ensure King CAN castle
Why does AI not want to castle? Is this an issue with castling heuristic or the actual castle move?

Create a way to compare evaluation functions

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.

Game over logic

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.

willMoveLeaveKingInCheck optimization by avoiding recalculating AttackableBoard

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

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.