Jump to content

new Ai bot: Petra


Recommended Posts

@MIMO: I started a new game, a warning message appears:

<h2>0 A.D. Main log (warnings and errors only)</h2>
<p class="warning">WARNING: JavaScript warning: simulation/components/TechnologyManager.js line 124
reference to undefined property template.requirements</p>
<p class="warning">WARNING: JavaScript warning: simulation/components/Player.js line 385
reference to undefined property this.diplomacy[idx]</p>
<p class="warning">WARNING: JavaScript warning: simulation/components/Player.js line 478
reference to undefined property this.diplomacy[id]</p>
<p class="warning">WARNING: JavaScript warning: simulation/components/ProductionQueue.js line 111
reference to undefined property template.Promotion</p>
<p class="warning">WARNING: JavaScript warning: gui/session/input.js line 1086
reference to undefined property ev.hotkey</p>
<p class="warning">WARNING: JavaScript warning: simulation/ai/petra/queueplan-building.js line 58
reference to undefined property this.buildingsBuilt</p>
<p class="warning">WARNING: JavaScript warning: gui/session/input.js line 487
reference to undefined property entState.unitAI</p>
<p class="warning">WARNING: JavaScript warning: simulation/components/GuiInterface.js line 934
reference to undefined property this.entsRallyPointsDisplayed</p>
<p class="warning">WARNING: JavaScript warning: gui/session/input.js line 422
reference to undefined property entState.resourceGatherRates</p>

Link to comment
Share on other sites

@gameboy

The warnings you reported today aren't related to the new AI.

I've committed the SpiderMonkey upgrade yesterday and it enables some more warnings.

We plan to look at these and solve them properly.

EDIT: well one was... but it looks like mimo fixed it.

Link to comment
Share on other sites

@Yves: But in the game, some of the new warning appears again:
<h2>0 A.D. Main log (warnings and errors only)</h2>
<p class="warning">WARNING: JavaScript warning: simulation/components/TechnologyManager.js line 124
reference to undefined property template.requirements</p>
<p class="warning">WARNING: JavaScript warning: simulation/components/Player.js line 385
reference to undefined property this.diplomacy[idx]</p>
<p class="warning">WARNING: JavaScript warning: simulation/components/Player.js line 478
reference to undefined property this.diplomacy[id]</p>
<p class="warning">WARNING: JavaScript warning: simulation/components/ProductionQueue.js line 111
reference to undefined property template.Promotion</p>
<p class="warning">WARNING: JavaScript warning: gui/session/input.js line 1086
reference to undefined property ev.hotkey</p>
<p class="warning">WARNING: JavaScript warning: gui/session/input.js line 487
reference to undefined property entState.unitAI</p>
<p class="warning">WARNING: JavaScript warning: simulation/components/GuiInterface.js line 934
reference to undefined property this.entsRallyPointsDisplayed</p>
<p class="warning">WARNING: JavaScript warning: gui/session/input.js line 422
reference to undefined property entState.resourceGatherRates</p>
<p class="warning">WARNING: JavaScript warning: simulation/components/GuiInterface.js line 667
reference to undefined property template.icon</p>

s<p class="warning">WARNING: JavaScript warning: simulation/helpers/Commands.js line 222
reference to undefined property cmd.metadata</p>
<p class="warning">WARNING: JavaScript warning: simulation/components/ProductionQueue.js line 540
reference to undefined property data.target</p>

<p class="warning">WARNING: JavaScript warning: gui/session/selection_details.js line 214
reference to undefined property entState.attack</p>
<p class="warning">WARNING: JavaScript warning: gui/session/input.js line 494
reference to undefined property entState.rallyPoint</p>

<p class="warning">WARNING: JavaScript warning: simulation/components/GuiInterface.js line 1724
reference to undefined property waterPoints[start]</p>
<p class="warning">WARNING: JavaScript warning: simulation/components/UnitAI.js line 5392
reference to undefined property this.heldPosition</p>
<p class="warning">WARNING: JavaScript warning: gui/session/messages.js line 357
reference to undefined property msg.guid</p>

Edited by gameboy
Link to comment
Share on other sites

We plan to look at these and solve them properly.

@Yves: But in the game, some of the new warning appears again:

Which is exactly what Yves said. We need to investigate if these warnings are bugs or harmless. This may take a few days.

Now I suggest to get back on topic. Which is discussing the new Petra AI, without the saved-game issue, as that's an issue that's a problem for all AIs.

Link to comment
Share on other sites

Warning again:

<h2>0 A.D. Main log (warnings and errors only)</h2>
<p class="warning">WARNING: JavaScript warning: gui/session/input.js line 1086
reference to undefined property ev.hotkey</p>
<p class="warning">WARNING: JavaScript warning: simulation/ai/common-api/terrain-analysis.js line 137
reference to undefined property this.map[index]</p>
<p class="warning">WARNING: JavaScript warning: simulation/ai/common-api/terrain-analysis-pathfinder.js line 207
reference to undefined property this.widthMap[index]</p>

Link to comment
Share on other sites

  • 2 weeks later...

Got a new error (commands.txt attached) (r14932)

ERROR: JavaScript error: simulation/ai/petra/defenseManager.js line 343 TypeError: target.attackRange(...) is undefined m.DefenseManager.prototype.checkDefenseStructures@simulation/ai/petra/defenseManager.js:343 m.DefenseManager.prototype.update@simulation/ai/petra/defenseManager.js:20 m.HQ.prototype.update@simulation/ai/petra/headquarters.js:1712 m.PetraBot.prototype.OnUpdate@simulation/ai/petra/_petrabot.js:182 m.BaseAI.prototype.HandleMessage@simulation/ai/common-api/baseAI.js:83

commands.txt

Link to comment
Share on other sites

@leper: Today I tested the latest Svn14933, the game appeared a new warning:

<h2>0 A.D. Main log (warnings and errors only)</h2>
<p class="warning">WARNING: JavaScript warning: simulation/helpers/Commands.js line 222
reference to undefined property cmd.metadata</p>

Link to comment
Share on other sites

AI also uses Command.js: It's about training a unit. The Metadata seems missing. But why is not obvious from your error message gameboy. Can you post the commands.txt?

                                var cmpTechnologyManager = QueryOwnerInterface(ent, IID_TechnologyManager);                                if (cmpTechnologyManager.CanProduce(cmd.template))                                {                                        var queue = Engine.QueryInterface(ent, IID_ProductionQueue);                                        // Check if the building can train the unit                                        if (queue && queue.GetEntitiesList().indexOf(cmd.template) != -1)                                                queue.AddBatch(cmd.template, "unit", +cmd.count, cmd.metadata);                                }                                else if (g_DebugCommands)                                {                                        warn("Invalid command: training requires unresearched technology: " + uneval(cmd));                                }
Look for the file:

logs/sim_log/<number>/commands.txt
Edited by Hephaestion
Link to comment
Share on other sites

Got a new error (commands.txt attached) (r14932)

ERROR: JavaScript error: simulation/ai/petra/defenseManager.js line 343 TypeError: target.attackRange(...) is undefined m.DefenseManager.prototype.checkDefenseStructures@simulation/ai/petra/defenseManager.js:343 m.DefenseManager.prototype.update@simulation/ai/petra/defenseManager.js:20 m.HQ.prototype.update@simulation/ai/petra/headquarters.js:1712 m.PetraBot.prototype.OnUpdate@simulation/ai/petra/_petrabot.js:182 m.BaseAI.prototype.HandleMessage@simulation/ai/common-api/baseAI.js:83

Thanks leper for the report and the commands.txt. The error was because Petra was assuming that buildings with an ArrowMultiplier had necessarity a ranged attack. It seems that this is true for all, except colonies (ptol and sele).

I suppose that it is intended for colonies to not have any attack (it is explicitely disabled), but for consistency shouldn't we also remove the ArrowMultiplier for garrisoned units ?

In any case, I will add an additional test on the ranged attack.

Link to comment
Share on other sites

  • 4 weeks later...

A new major upgrade of Petra AI has just been commited in svn. It features a first version of naval support, as well as some bug fixes. Tests (specially that no regression were introducedfor land maps) would be very usefull. In case of errors, please provide the commands.txt file and the version of your svn build.

Concerning naval maps, there are a few known issues
- ship combat is not yet implemented (ship are mainly used for transport of armies in oversea attacks)
- path finding issues with ships blocking themselves
- the placement of defensive structure (tower and fortress) is not adapted for small islands, so the AI rarely built them
- carthage does not yet use shipyard, so does not have war ships
- trade is quite broken in naval maps
- the reaction of the AI to its ennemies actions is still quite dumb

Finally, if anybody want to help and improve this AI, all these issues are a good way to start. I can point you to the right file and piece of code if needed.

  • Like 7
Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

Petra likes to build civ. centers very near my under-construction civ. center. This leads to competition to see who can build their civ. center the fastest, especiallly on maps where the players start out near each other (team oasis). Maybe add a filter to not allow civ. centers to be build within a certain radius of another civ. center that is under construction.

Link to comment
Share on other sites

Do you mean when you are allied with the AI ? or enemy ?

If it happens when allied, there is already a minimum distance with allied cc, but this can be increased.

if it happens when enemy, I guess that's part of the game: it is up to you to prevent this to happen by destroying its foundation :closedeyes: In principle, Petra is not "attracted" by other cc, but by good location, and fighting for a good location is expected.

  • Like 2
Link to comment
Share on other sites

Got an error where the ai couldn't find the path and decided it was going to go into the bottom right corner of the world in a 3 player map(with a river going through the map to separate the 3 players and an upper area that needs ships to access). At first it seemed like it was being really smart and going below my base(thus around my wooden wall I made for defending against it) but then I noticed an error in the top left of 'can't find path'. At first I thought this was related to his other army he had attacked with at the same time(Yes 2 full armies of same unit composition) that I noticed had broken through my gate while I was managing resource gatherers. It wasn't long however before I noticed his whole army on the bottom was trying to go through the bottom left corner of the map as if it were able to use that as a path to get to the enemy in the top right corner. He then continued to add another army to this group at which point I decided to exit since the game was going on for a long time and I didn't feel like playing with a buggy ai that loved attacking me :P

Note: This was using the Mac version of alpha.

Edited by 3FFA
Link to comment
Share on other sites

I was allied with Petra at the time.

Where can it be increased?

It has to be changed in the code. Checking back, the present minimal distance with allied cc is 120 m which is quite small I agree. I will increase it to 200 m.

Is this 120 m what you had ?

Link to comment
Share on other sites

Got an error where the ai couldn't find the path and decided it was going to go into the bottom right corner of the world in a 3 player map(with a river going through the map to separate the 3 players and an upper area that needs ships to access). At first it seemed like it was being really smart and going below my base(thus around my wooden wall I made for defending against it) but then I noticed an error in the top left of 'can't find path'. At first I thought this was related to his other army he had attacked with at the same time(Yes 2 full armies of same unit composition) that I noticed had broken through my gate while I was managing resource gatherers. It wasn't long however before I noticed his whole army on the bottom was trying to go through the bottom left corner of the map as if it were able to use that as a path to get to the enemy in the top right corner. He then continued to add another army to this group at which point I decided to exit since the game was going on for a long time and I didn't feel like playing with a buggy ai that loved attacking me :P

Note: This was using the Mac version of alpha.

Going to the corner like that usually means that its destination is undefined.

If you have the commands.txt file and the revision version that you used, i can have a look at it.

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