This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Opened 3 years ago

Last modified 19 months ago

#6385 new defect

[PetraAI] Errors/warnings for A25b — at Initial Version

Reported by: Langbart Owned by:
Priority: Must Have Milestone: Alpha 27
Component: AI Keywords: Petra
Cc: Patch:

Description

Playing A25b [25860], some errors and warnings were displayed and even when viewing the replay with and without mods, the errors and warnings remain the same.

The errors start to appear around the 21min:10sec mark.

ERROR: JavaScript error: simulation/ai/common-api/utils.js line 27 b is undefined API3</m.SquareVectorDistance@simulation/ai/common-api/utils.js:27:2 
PETRA.AttackPlan.prototype.getNearestTarget@simulation/ai/petra/attackPlan.js:915:19 
PETRA.AttackPlan.prototype.UpdateTarget@simulation/ai/petra/attackPlan.js:1935:22 
PETRA.AttackPlan.prototype.update@simulation/ai/petra/attackPlan.js:1312:13 
PETRA.AttackManager.prototype.update@simulation/ai/petra/attackManager.js:308:27 
PETRA.HQ.prototype.update@simulation/ai/petra/headquarters.js:2768:22 
PETRA.PetraBot.prototype.OnUpdate@simulation/ai/petra/_petrabot.js:118:11 
m.BaseAI.prototype.HandleMessage@simulation/ai/common-api/baseAI.js:64:7

The referenced lines are listed below:

Line 27 in simulation/ai/common-api/utils.js at [25860]

Line 
25m.SquareVectorDistance = function(a, b)
26{
27 return Math.euclidDistance2DSquared(a[0], a[1], b[0], b[1]);
28};

Line 915 in simulation/ai/petra/attackPlan.js at [25860]

Line 
912 // Do not bother with some pointless targets
913 if (!this.isValidTarget(ent))
914 continue;
915 let dist = API3.SquareVectorDistance(ent.position(), position);
916 // In normal attacks, disfavor fields
917 if (this.type != "Rush" && this.type != "Raid" && ent.hasClass("Field"))
918 dist += 100000;

Line 1935 in simulation/ai/petra/attackPlan.js at [25860]

Line 
1932 if (this.Config.debug > 1)
1933 API3.warn("Seems like our target for plan " + this.name + " has been destroyed or captured. Switching.");
1934 let accessIndex = this.getAttackAccess(gameState);
1935 this.target = this.getNearestTarget(gameState, this.position, accessIndex);
1936 if (!this.target)
1937 {
1938 if (this.uniqueTargetId)

Line 1312 in simulation/ai/petra/attackPlan.js at [25860]

Line 
1309 if (this.state == "")
1310 {
1311 // First update the target and/or its position if needed
1312 if (!this.UpdateTarget(gameState))
1313 {
1314 Engine.ProfileStop();
1315 return false;

Line 308 in simulation/ai/petra/attackManager.js at [25860]

Line 
305 // okay so then we'll update the attack.
306 if (attack.isPaused())
307 continue;
308 let remaining = attack.update(gameState, events);
309 if (!remaining)
310 {
311 if (this.Config.debug > 1)

Line 2768 in simulation/ai/petra/headquarters.js at [25860]

Line 
2765 this.navalManager.update(gameState, queues, events);
2766
2767 if (this.Config.difficulty > 0 && (this.numActiveBases() > 0 || !this.canBuildUnits))
2768 this.attackManager.update(gameState, queues, events);
2769
2770 this.diplomacyManager.update(gameState, events);
2771

Line 118 in simulation/ai/petra/_petrabot.js at [25860]

Line 
115 return; // With no entities to control the AI cannot do anything
116 }
117
118 this.HQ.update(this.gameState, this.queues, this.savedEvents);
119
120 this.queueManager.update(this.gameState);
121

Line 64 in simulation/ai/common-api/baseAI.js at [25860]

Line 
61 this.Init(state, playerID, sharedAI);
62 this.isDeserialized = false;
63 }
64 this.OnUpdate(sharedAI);
65};
66
67/** AIs override this function */

The warnings start to appear ~30seconds after the errors.

WARNING: PlayerID 3 | Petra error in incrementBuilderCounters for structures/gaul/civil_centre with count < 0
WARNING: PlayerID 3 | Petra error in incrementBuilderCounters for structures/gaul/crannog with count < 0
WARNING: PlayerID 3 | Petra error in incrementBuilderCounters for structures/gaul/military_colony with count < 0
WARNING: PlayerID 3 | Petra error in incrementBuilderCounters for structures/gaul/house with count < 0
WARNING: PlayerID 3 | Petra error in incrementBuilderCounters for structures/gaul/apartment with count < 0
WARNING: PlayerID 3 | Petra error in incrementBuilderCounters for structures/gaul/storehouse with count < 0
WARNING: PlayerID 3 | Petra error in incrementBuilderCounters for structures/gaul/farmstead with count < 0
...

Line 33 in simulation/ai/petra/buildManager.js at [25860]

Line 
30 let count = this.builderCounters.get(buildable) + increment;
31 if (count < 0)
32 {
33 API3.warn(" Petra error in incrementBuilderCounters for " + buildable + " with count < 0");
34 continue;
35 }
36 this.builderCounters.set(buildable, count);

Errors/warnings stop around the 23min mark.

I will attach:

  • the replay as a zip file and
  • the entire logs folder (including interestinglog.html, mainlog.html, system_info.txt and userreport_hwdetect.txt)

Change History (3)

by Langbart, 3 years ago

Attachment: AI_errors_warnings.jpg added

by Langbart, 3 years ago

Attachment: replay_folder.zip added

by Langbart, 3 years ago

Attachment: logs_folder.zip added
Note: See TracTickets for help on using tickets.