Jump to content

[AI] creating a unit by event/random


Recommended Posts

Hi,

I would like to write a small AI. Instead of having an AI who collects resources to build unist&structures, I would like to create some units&structures by event/time

Examples:

  • Harresment : I would like to generate 10 skirmishers near the limit of the visibility of the human, and give to them the order to attack all workers. For this one, I read how to send an attack in the tutorial bot. For creating unit I didn't saw how to spawn somewhere on the map (for now I consider the human doesn't build wall).
  • Creating a challenging city : instead of building a functionnal city, I would like to build a blob,(remeber it's an example) 10 houses + a temple + a barracks + a trade center, surronded by a wall. For this one I want to create the structure by script (for now I consider a full flat map).
  • Creating a small fortress : building somewhere on the map a new civic center + 2 fortresses (full garisonned), surounded by walls and towers (full garisonned). The aim of that small fortress are just to occupy some terrain. Can also used to beseiged the human player by creating a small fortress near the limit of visibility of the player.
  • burn ouposts : since this AI needs fog to create these small fortress, some cavalry unit would be spawn out of the field of view of an oupost, and attack it.

Do you think it would be possible to create a such AI with the present API ? there is somewhere a full documentation of all functions present in the AI API ?

  • Like 1
Link to comment
Share on other sites

Do you think it would be possible to create a such AI with the present API ? there is somewhere a full documentation of all functions present in the AI API ?

The AIs receive lots of updates about the gamestate, but not everything. However, they are designed to run asynchronously to the simulation, so they don't directly modify it, but send commands instead. Currently, AIs are restricted to the same commands that a human player could send, with most of the same checks in place. They can't arbitrarily place units and buildings, though I think this would be a useful feature for some AIs.

The available commands aren't really documented anywhere, but they are handled in the big switch block in /binaries/data/mods/public/simulation/helpers/Commands.js.

  • Like 1
Link to comment
Share on other sites

I had already read all helpers files, saddly there is not all the commands I would need... if the AI was coded in C++ I would be able to implement by myself what I need. But I don't know how to make C++ interacting with javascript...

about the Commands.js, I see it's a big switch, I don't know how js works, but it would maybe a good thing to rearange all cases from the most used (I guess walk) to the less used case.

in few words... my AI will not for tomorrow.

Link to comment
Share on other sites

I don't know the code, so take my words with more than a grain of salt, but shouldn't the AI be able to generate units (and possibly buildings as well?) the same way a human can use cheats? And I certainly recall reading about the AI doing things after a set amount of time, so that should at least be possible.

Link to comment
Share on other sites

you can spwan unit and kill by script, but for what I know you have to select a building to spawn. So you can't spawn on the map far of a building (maybe I'm wrong). And I didn't found a way to spawn a building.

I don't want to kill the unit, I want to remove it. Killing means corpse on the ground and maybe (i didin't check this) change the number of lost units...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...