Skip to content

Game Robot Collection (v5) #31

@AppOfficer

Description

@AppOfficer

For robot contributions dedicated to v6, please see the docs/bot contributions.md and src/bots/README.md under the master brench for details.


The post below takes effect if and only if this issue remains open.


We are now allowing contributing robots to the project LocalGen!

Your robot must:

  1. Always obey the game rules.
  2. Be written in C/C++.
  3. Be implemented in a single .hpp file with the file name same as the robot name.
  4. Be written in a namespace of which name is the same as the robot's name. (for example, the robot smartRandomBot is written in namespace smartRandomBot.)
  5. Have a main function in the following format:
    namespace botName {
        moveS calcNextMove (int playerId, coordS playerFocus);
    }
    returning a moveS with two parameters int and coordS.
    Refer to project code for how move/game map data is stored. (Try to look at implementations of existing bots.)

Robot submission instructions:

  1. Fork a copy of the project to write your own robot.
  2. Create a pull request on branch v5.0.
  3. Robot tested by the LocalGen development team.
  4. Your robot appears in the next version of LocalGen.

Example Robot: (in file exampleBot.hpp)

#ifndef BOT_EXAMPLE
#define BOT_EXAMPLE

#include "../LGdef.hpp"

namespace exampleBot {
    constexpr coordS delta[4] = { coordS(-1, 0), coordS(0, -1), coordS(1, 0), coordS(0, 1) };
    std::mt19937 rand_gen(std::random_device{}());

    bool invalid(coordS coord) {
        return coord.x < 1 || coord.x > mapH || coord.y < 1 || coord.y > mapW;
    }

    moveS calcNextMove(int id, coordS coo) {
        if (gmp(coo) != id) coo = LGgame::genCoo[id];
        coordS next;
        while (invalid(next = coo + delta[rand_gen() % 4]));
        return moveS{ id, false, coo, next };
    }
} // namespace exampleBot

#endif // BOT_EXAMPLE

Any problems? Feel free to leave a comment below!

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is neededver. 5For LG version 5 (EGE)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions