Code Monkey home page Code Monkey logo

Comments (9)

fsmosca avatar fsmosca commented on September 28, 2024

Does gensfen always generate random moves? If so then pos.is_draw() is just random and it is better not to use it.

I thought about an option where at certain ply limit, moves will be based on search - no more random. In this case applying pos.is_draw() is reasonable.

from stockfish.

Sopel97 avatar Sopel97 commented on September 28, 2024

gensfen does random moves but only up to some ply (see the docs, I don't remember exactly what governs it, but random moves stop pretty quick)

The problem here is that it also thinks 2-fold is a draw, due to how is_draw is implemented

from stockfish.

fsmosca avatar fsmosca commented on September 28, 2024

According to the doc if random_multi_pv is not specified then all moves will be random except when there is only one legal move. If specified, then a random move from multi_pv value will be selected. If user sets random_multi_pv to 1 then this is not random as multipv 1 is a normal search. Above 1 it is random except when there is only one legal move.

Generally there is no issue with 2-fold repetition, assuming that moves are coming from normal search - not from some random moves. In normal search if the engine cannot find a better move it may go for repetition if there is one. The use of pos.is_draw(ply) is good because we terminate the game early as we are not waiting for the engines (on self-play) to execute the 3-fold repetition.

from stockfish.

Sopel97 avatar Sopel97 commented on September 28, 2024

random_move_minply - the minimal ply at which a random move may be executed instead of a move chosen by search. Default: 1.

random_move_maxply - the maximal ply at which a random move may be executed instead of a move chosen by search. Default: 24.

random_move_count - maximum number of random moves in a single self-play game. Default: 5.

Generally there is no issue with 2-fold repetition, assuming that moves are coming from normal search - not from some random moves. In normal search if the engine cannot find a better move it may go for repetition if there is one. The use of pos.is_draw(ply) is good because we terminate the game early as we are not waiting for the engines (on self-play) to execute the 3-fold repetition.

you might be right

from stockfish.

fsmosca avatar fsmosca commented on September 28, 2024

This random_move_count looks interesting. Does it mean that after 5 random moves are already in the game, no more random moves will be executed. If that is so then pos.is_draw(ply) can be used then.

from stockfish.

Sopel97 avatar Sopel97 commented on September 28, 2024

yes that is true

from stockfish.

fsmosca avatar fsmosca commented on September 28, 2024

To erase any doubt I have a revision to end the game by 3-fold repetition.

Tested to work with the following command.

gensfen random_multi_pv 3 random_multi_pv_diff 200 set_recommended_uci_options book noob_3moves.epd depth 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024

Fixed by #317

from stockfish.

Related Issues (20)

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.