Search code examples
c++memorychess

Dynamic storage in C++ for chess move generation


I'm coding a chess engine in C++ and I'm currently working on move generation. I'm confused as to how I should be storing moves as they are generated. I'm relatively new to C++, but is there some some of dynamic object that I can use to store moves as they come (since I cannot know how many there are).


Solution

  • There are many containers in C++, depending of situation you can use an std::vector, or something else.

    As to choose a container would require more information from your chess engine (like how many times would it be resized, does movements can be added at front and back of your container, etc), we cannot give you a direct answer with data that you gave.

    Please take a look at this question to define which one would be the most adapted for your case.