SpelunkBots – Getting Started – Adding New Bots

For the current version of the API (20/5/15 at time of writing) there are 2 ways of creating bots, each with a different means to be included and selected by Gamemaker. At 13 pages these exact means are somewhat obscured in the documentation so here we aim to create a simple step by step introduction for where to head first.

GameMaker SpelunkBots

To begin writing a bot in GML a new script for the bot should be created in the AIToolset -> BOTSCRIPTS -> Scripts location.SpelunkBotsFileTree The file PlayerChoice now solely contains a switch statement that chooses the right script, a new case should be added onto the end of this referencing it.

bot = X;

switch(bot)
{
case 0:
GettingStartedBot();
break;
case 1:
JamesBot();
break;
...
///add new script here///
case X:
EXAMPLE();
break;
/////////////////////////
default:
JordanBot();
break;
}

With this set up EXAMPLE.script can now be written with all the logic for the bot.

C++ SpelunkBots

The first step of creating a C++ SpelunkBot is exactly the same as above. After these steps the script file should contain the following lines of code.

Update(global.playerPositionXNode, global.playerPositionYNode);
UpdateCppBotVariables();

The call to the update function in the Bot DLL is what will happen every frame. The second ensures information is consistent between both platforms.

Creating a C++ bot involves 2 separate parts. Firstly the bot logic itself is put in the Bot.sln file (SpelunkBots -> DLL Solution -> Bot) insideĀ Bot.cpp and should be contained to only inside the Update() function.

After writing a SpelunkBots script, building the Bot project will place a library inside the Spelunky_1_1 folder. In order to have more than one bot on the go, rename the project before building so the old doesn’t get overwritten.SpelunkBotsRenameSolution

Finally Gamemaker needs to be directed to the correct DLL. Inside SpelunkBots.gmk navigate to AIToolset -> DLL -> initializeDLL and change the dll to the new project name.SpelunkBotsDLL

Advertisements