Code Monkey home page Code Monkey logo

Comments (9)

MarkZH avatar MarkZH commented on September 2, 2024

This can also be an attempt to do multi-threaded minimax with a thread pool similar to the gene pool structure for starting simultaneous games.

Might also be a good idea to create a Thread_Pool class to handle both these cases.

from genetic_chess.

MarkZH avatar MarkZH commented on September 2, 2024

Not a Thread_Pool, but a Thread_Assembly_Line. A push_back method creates a new std::future which is put into an ordered container. This method blocks if there are no processes available to start it. The function passed to push_back() is run within a lambda that also locks and releases one of a set of mutexes to limit the number of simultaneous threads. Perhaps the mutexes can be put in a queue that blocks when something tries to grab a mutex when it is empty.

from genetic_chess.

MarkZH avatar MarkZH commented on September 2, 2024

For that last bit, use std::counting_semaphore.

Actually, use std::counting_semaphore in the current implementation of the gene pool to see how it simplifies the simultaneous game limit.

from genetic_chess.

MarkZH avatar MarkZH commented on September 2, 2024

Simpler still: create a structure that acts like a ticketing system. Before starting a thread, take a ticket. Have the thread release the ticket when it finishes. This will be implemented in a class that wraps a std::condition_variable for master. In c++20, that class will be deleted and replaced with a std::counting_semaphore.

from genetic_chess.

MarkZH avatar MarkZH commented on September 2, 2024

Thread limiter implemented here: 36dd6fc
Work ongoing in multi-threaded-minimax branch

from genetic_chess.

MarkZH avatar MarkZH commented on September 2, 2024

Full-minimax search on depth 2 moves is very slow due to having to traverse so much more of the game tree. Reduce this to depth one, maybe with a shared Alpha/Beta values.

from genetic_chess.

MarkZH avatar MarkZH commented on September 2, 2024

More importantly, the engine crashes while doing multi-threaded search. The location of the crash is usually random with memory locations indicating destructed data or out-of-bounds access. Investigating ...

from genetic_chess.

MarkZH avatar MarkZH commented on September 2, 2024

All data sent to threads is now copied as of commit 2d4062b

The multi-threading was reduced to depth one moves due to slowness induced by so much searching caused by the lessened effectiveness of alpha-beta pruning due to starting with new windows with every thread. The branch is fully functional and waiting to be merged.

from genetic_chess.

MarkZH avatar MarkZH commented on September 2, 2024

Threads can now be used in gene pools as of eda7239

from genetic_chess.

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.