So I've heard, you can run cpp files directly into lux-ai-2021. However, when I try to run it with my own bot, I get this error. https://pastebin.com/CQDev0Kw error in its entirety.
diego@adhoc:~/Desktop/LuxBot$ sudo lux-ai-2021 src/main.cpp src/main.cpp
-=-=-=-=-=-=-=-=-=-=-=-| [INFO] match_QiUDBKVEPU7A |-=-=-=-=-=-=-=-=-=-=-=-
[INFO] (match_QiUDBKVEPU7A) - Design: lux_ai_2021 | Initializing match - ID: QiUDBKVEPU7A, Name: match_QiUDBKVEPU7A
Error: spawn ETXTBSY
at ChildProcess.spawn (internal/child_process.js:403:11)
at spawn (child_process.js:580:9)
at Object.spawnWithSignal [as spawn] (child_process.js:717:17)
at Object.spawn [as default] (/usr/local/lib/node_modules/@lux-ai/2021-challenge/node_modules/cross-spawn/index.js:12:24)
at /usr/local/lib/node_modules/@lux-ai/2021-challenge/node_modules/dimensions-ai/lib/main/Agent/index.js:653:46
at new Promise (<anonymous>)
at Agent._spawnProcess (/usr/local/lib/node_modules/@lux-ai/2021-challenge/node_modules/dimensions-ai/lib/main/Agent/index.js:646:16)
at Agent.<anonymous> (/usr/local/lib/node_modules/@lux-ai/2021-challenge/node_modules/dimensions-ai/lib/main/Agent/index.js:628:56)
at step (/usr/local/lib/node_modules/@lux-ai/2021-challenge/node_modules/dimensions-ai/lib/main/Agent/index.js:46:23)
at Object.next (/usr/local/lib/node_modules/@lux-ai/2021-challenge/node_modules/dimensions-ai/lib/main/Agent/index.js:27:53) {
errno: -26,
code: 'ETXTBSY',
syscall: 'spawn'
}
I get this error when trying to run the v1.1.x branch of the cpp kit as well; Not sure what is causing it. It works fine when transpiled into JS. I've tried running the lux-ai-2021 command as sudo and not sudo, though it doesn't make a difference. Here's the exact main.cpp code I tried to run in simple/:
#include "lux/kit.hpp"
#include "lux/define.cpp"
#include <string.h>
#include <vector>
#include <set>
#include <stdio.h>
using namespace std;
using namespace lux;
int main()
{
kit::Agent gameState = kit::Agent();
gameState.initialize();
while (true)
{
gameState.update();
vector<string> actions = vector<string>();
Player player = gameState.players[gameState.id];
Player opponent = gameState.players[(gameState.id + 1) % 2];
GameMap gameMap = gameState.map;
vector<Cell *> resourceTiles = vector<Cell *>();
for (int y = 0; y < gameMap.height; y++)
{
for (int x = 0; x < gameMap.width; x++)
{
Cell *cell = gameMap.getCell(x, y);
if (cell->hasResource())
{
resourceTiles.push_back(cell);
}
}
}
int citiesToBuild = 0;
for (auto it : player.cities)
{
City *city = it.second;
if (city->fuel > city->getLightUpkeep() * (int) GAME_CONSTANTS["PARAMETERS"]["NIGHT_LENGTH"] + 1000)
{
citiesToBuild += 1;
}
for (auto citytile : city->citytiles)
{
if (citytile->canAct()) {
// you can use the following to get the citytile to research or build a worker
// actions.push_back(citytile.research());
// actions.push_back(citytile.buildWorker());
}
}
}
for (int i = 0; i < player.units.size(); i++)
{
Unit unit = player.units[i];
if (unit.isWorker() && unit.canAct())
{
if (unit.getCargoSpaceLeft() > 0)
{
// if the unit is a worker and we have space in cargo, lets find the nearest resource tile and try to mine it
Cell *closestResourceTile;
float closestDist = 9999999;
for (auto it = resourceTiles.begin(); it != resourceTiles.end(); it++)
{
auto cell = *it;
if (cell->resource.type == ResourceType::coal && !player.researchedCoal()) continue;
if (cell->resource.type == ResourceType::uranium && !player.researchedUranium()) continue;
float dist = cell->pos.distanceTo(unit.pos);
if (dist < closestDist)
{
closestDist = dist;
closestResourceTile = cell;
}
}
if (closestResourceTile != nullptr)
{
auto dir = unit.pos.directionTo(closestResourceTile->pos);
actions.push_back(unit.move(dir));
}
}
else
{
if (player.cities.size() > 0)
{
auto city_iter = player.cities.begin();
auto city = city_iter->second;
float closestDist = 999999;
CityTile *closestCityTile;
for (auto citytile : city->citytiles)
{
float dist = citytile->pos.distanceTo(unit.pos);
if (dist < closestDist)
{
closestCityTile = citytile;
closestDist = dist;
}
}
if (closestCityTile != nullptr)
{
auto dir = unit.pos.directionTo(closestCityTile->pos);
if (citiesToBuild > 0 && unit.pos.isAdjacent(closestCityTile->pos) && unit.canBuild(gameMap))
{
actions.push_back(unit.buildCity());
}
else
{
actions.push_back(unit.move(dir));
}
}
}
}
}
}
for (int i = 0; i < actions.size(); i++)
{
if (i != 0)
cout << ",";
cout << actions[i];
}
cout << endl;
gameState.end_turn();
}
return 0;
}
So I've heard, you can run cpp files directly into lux-ai-2021. However, when I try to run it with my own bot, I get this error. https://pastebin.com/CQDev0Kw error in its entirety.
I get this error when trying to run the v1.1.x branch of the cpp kit as well; Not sure what is causing it. It works fine when transpiled into JS. I've tried running the
lux-ai-2021command assudoand notsudo, though it doesn't make a difference. Here's the exactmain.cppcode I tried to run in simple/: