Jump to content

AI development questions


Recommended Posts

Hi everyone,

I just started programming AI's, but as I try to understand the working of the currently existing AI's, there are a few questions raising:

1. Which functions in the API are required for the AI to work properly? (e.g. gamestate etc.)

2. All AI's use a plan-queue-system. Are there other systems possible?

3. Why are the AI's stateless and is this required?

Glad there is a forum over here. :stinker:

Regards,

Niek

Edited by niektb
Link to comment
Share on other sites

1. Technically, none. However the common-api (all versions) provide a few custom classes and a few basic functions.

A function called "HandleMessage" will be called every turn (with the game state as a parameter, and optionally the shared component). You can check this in the file base.js in any common-api (though v3 uses the shared component which makes this slightly more complicated).

2.Yes, if you can make one work.

3.Because they weren't designed that way. It isn't required.

Link to comment
Share on other sites

Could someone please rewrite scaredybot for APIv3?

Using APIv3 instead of v1, I tried to make scaredybot train a villager, but it gives me a bunch of errors that sharedAI is not defined in base.js (line 51).

Am I not permitted to upload .js files??? :P

Link to comment
Share on other sites

Okay, I downgraded my AI to v2 but now I get an comparable error, namely that _entities[id] is undefined at line 226 from base.js

This is my current code:

function NiBotAI(settings)
{
BaseAI.call(this, settings);
this.turn = 0;
}

NiBotAI.prototype = new BaseAI();

NiBotAI.prototype.OnUpdate = function() {
if (this.gameFinished){
return;
}
this.turn++;
};

What is wrong?

Second question:

Is there a way to reload scripts, so I don't have to reload the save game every time?

Link to comment
Share on other sites

After updating and rebuilding the solution everything goes fine, though it gives a warning. Where do I find an error log?

Hmm...

When I'm scanning with JSHint through APIv3 I get several errors like the following:

In Shared.js:

- 356,9: 'for each' is only available in Mozilla JavaScript extensions (use moz option).

In map-module.js:

- 5,1: 'const' is only available in JavaScript 1.7.

Is this known?

P.S. How do I send in a patch? (I've fixed several typographic errors in APIv3 like missing semicolons etc.)

Edit: patch attached. Wriattii's patch from APIv3 is also inside.

APIv3.patch

Edited by niektb
Link to comment
Share on other sites

  • 4 weeks later...

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...