Giter Site home page Giter Site logo

sporkfish's People

Contributors

ccjeremylo avatar claudiayip avatar kwngggg avatar kylchiu avatar michelle-lai-swl avatar richardhunghhw avatar yibeili avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sporkfish's Issues

[Design] Searcher switching

  • Design a switching interface that allows switching between different searchers, e.g. searcher could be single process or use a different algorithm completely - could be inheritance or factory pattern
  • Refactor the single and multi-process negamax searchers as different classes, putting these under the (newly created) Searcher folder

[Feature] Endgame Syzygy tablebases

Requirements:

You can download databases for testing on: https://syzygy-tables.info/?fen=4k3/8/8/8/8/8/8/4K3_w_-_-_0_1

[Design] Decouple engine and board

Engine currently makes the move for the board, but this isn't ideal as engine does not own the board. Making a move should be moved to the UCIClient level instead.

[Investigate] Board switching -slow

ncalls tottime percall cumtime percall filename:lineno(function)
254103 8.220 0.000 22.513 0.000 evaluator.py:873(evaluate)
17411446 5.067 0.000 9.103 0.000 init.py:725(piece_at)
17411318 4.558 0.000 14.572 0.000 board_py_chess.py:109(piece_at)

18221628 3.290 0.000 3.290 0.000 init.py:735(piece_type_at)
270052 1.188 0.000 2.835 0.000 init.py:2200(push)
1576589 1.115 0.000 2.544 0.000 init.py:1706(generate_pseudo_legal_moves)
6840750 0.911 0.000 0.911 0.000 piece.py:14(init)
12264738 0.864 0.000 0.864 0.000 evaluator.py:897()
3063713 0.691 0.000 0.806 0.000 init.py:314(scan_reversed)
1510784 0.689 0.000 4.759 0.000 init.py:3582(generate_legal_moves)

Notice that piece wrapping id 4.5 seconds itself. The code is just

       def piece_at(self, square: Square) -> Optional[Piece]:
      """
      Get the piece at the specified square.

      :param square: The target square.
      :type square: int
      :return: The piece at the specified square, or None if the square is empty.
      :rtype: Optional[Piece]
      """

      return (
          Piece(piece.piece_type, piece.color)
          if (piece := self.board.piece_at(square))
          else None
      )

but due to sheer amount of calls, this becomes a problem.

[Feature] Principal variation search / Negascout

Requirements:

  1. Create a new class called PrincipalVariationSearch inheriting from NegamaxSP. Implement the pseudocode here, https://en.wikipedia.org/wiki/Principal_variation_search
  2. Any attempts to avoid duplication with NegamaxSP will be much appreciated.
  3. It should be completely identical to NegamaxSP in move ordering, pruning, quiescent, ID, aspiration window and transposition functionality, only the search algorithm should be different.
  4. Add relevant tests

Comments:

  • As usual, this turns out to be a more tedious task than I originally envisioned. For 1. I think (?) we cannot inherit from NegamaxSP and just use _negamax in PrincipalVariationSearcher.start_search_from_root, because then you only get null window searches at the root.
  • Let's add a comment that there is an issue but leave handling it to a later PR: https://www.chessprogramming.org/PVS_and_Aspiration

[Design] Configuration refactoring

Currently engine creation is hardcoded in UCIClient. Engine creation should be far more flexible, i.e. we should be able to pass in config from the main function. Easiest way to do this is serialised config via yml file, or if you think of a better option please suggest. This should include:

  • Config for the engine, e.g. depth for searcher, opening book etc.
  • Config for the UCI parts, i.e. time management.
  • [Consider] Additional config - e.g. for logging

[Feature] Lichess bot to accept challenges from other players

Requirements:

  • Accept challenges from other players.

Tips:

[Feature] Numbafy evaluator

ncalls tottime percall cumtime percall filename:lineno(function)
254103 7.704 0.000 17.060 0.000 evaluator.py:877(evaluate)

For a depth 6 call, we have 7 seconds spent in evaluate alone (excluding outgoing function calls). This could potentially be sped up by using numba.

[Feature] Iterative Deepening

Add iterative deepening: https://www.chessprogramming.org/Iterative_Deepening. The benefits are:

  • If we reach a depth but run out of time, the best move at the previous depth can be returned instead.
  • Transposition tables (cache) can be populated at higher depths and re-used, allowing for more aggressive pruning of the search tree.

To do it:

  • See the search function at: https://github.com/KYLChiu/sporkfish/blob/master/sporkfish/searcher.py. It needs to run search through depths from 1 to max_depth instead of running it only at max_depth.
  • Additionally you need to pass in the time string from the UCI "go" command down to the searcher class. In the search function, compare against it, breaking early and returning the previous best move if it exceeds the time limit.
  • Please play around with the multi-processing implemented in _negamax_mp, i.e. you may send some processes to depth + k for k={1,2,3...} to populate transpositions table in parallel and see what works best.

[Feature] Null-move Pruning

Null-move pruning is a method to reduce the alpha-beta negamax search tree. It refers passing to your turn (i.e. making a "null" move) and dynamically evaluating the position. If the evaluated score after the null move is "too good" (above beta). The assumption is that the opponent wouldn't allow such a favourable position, so the search can be pruned (beta-cutoff).

Requirements:

  • Implement this in searcher.py, in a separate function. Call it in _negamax.

See:

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.