Opened 2 years ago
Last modified 15 months ago
#6385 new defect
[PetraAI] Errors/warnings because undefined position
Reported by: | Langbart | Owned by: | Freagarach |
---|---|---|---|
Priority: | Must Have | Milestone: | Alpha 27 |
Component: | AI | Keywords: | Petra |
Cc: | Patch: | Phab:D4936 |
Description (last modified by )
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 | |
---|---|
25 | m.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
anduserreport_hwdetect.txt
)
EDIT (11/Jun/22)
- Adding a 2nd replay (
rP26935.zip
) with not exactly the same issue, but very similar to this one. This time for [26935]. Errors come at ~27min. See error logs below:
ERROR: JavaScript error: simulation/ai/common-api/utils.js line 27 undefined has no properties API3</m.SquareVectorDistance@simulation/ai/common-api/utils.js:27:2 PETRA.TransportPlan.prototype.onSailing@simulation/ai/petra/transportPlan.js:638:19 PETRA.TransportPlan.prototype.update@simulation/ai/petra/transportPlan.js:292:8 PETRA.NavalManager.prototype.update@simulation/ai/petra/navalManager.js:832:42 PETRA.HQ.prototype.update@simulation/ai/petra/headquarters.js:2282:20 PETRA.PetraBot.prototype.OnUpdate@simulation/ai/petra/_petrabot.js:118:11 m.BaseAI.prototype.HandleMessage@simulation/ai/common-api/baseAI.js:64:7
Related/ similar issue
- AI Naval Error (27/Jul/14)
- Ticket #2690 fixed with [15574]
Attachments (5)
Change History (18)
by , 2 years ago
Attachment: | AI_errors_warnings.jpg added |
---|
by , 2 years ago
Attachment: | replay_folder.zip added |
---|
by , 2 years ago
Attachment: | logs_folder.zip added |
---|
comment:2 by , 2 years ago
Replying to Freagarach:
Following the trail leads to the conclusion that the attack plan had no entities, probably. Since
this.position
is set at construction and can be set to undefined when the plan is entityless.
this.position will be undefined even when attack plan has entities but all are garisoned
comment:3 by , 2 years ago
Component: | Core engine → AI |
---|---|
Keywords: | Petra added |
Priority: | Should Have → Must Have |
comment:4 by , 2 years ago
At that moment there are two entites in attackplan, while both are without position and one is triggering also garrison error:
WARNING: 7328 : true WARNING: 7153 : true WARNING: PlayerID 3 | unknown type in garrisonManager undefined for Spearman id 7328 inside Civic Center id 150}}}
comment:5 by , 2 years ago
Milestone: | Alpha 26 → Alpha 27 |
---|
comment:6 by , 23 months ago
Description: | modified (diff) |
---|---|
Summary: | [PetraAI] Errors/warnings for A25b → [PetraAI] Errors/warnings because undefined position |
Adding a replay where a similar problem occurred in the latest GIT version [26935].
by , 23 months ago
Attachment: | rP26935.zip added |
---|
comment:7 by , 21 months ago
Similar sounding issue reported by andy5995
through the forum
- Alpha 26 Pre-release/Release Candidate Build Testing (27/Jul/22)
Got a lot of scripting errors playing git version
comment:10 by , 15 months ago
I just triggered this issue on [27531] with Phab:D4933 and Phab:D4934 being applied.
- attachment:commands_27531_D4933_D4934.txt (occurred ~12th min)
Executing turn 3540 of 3867 ERROR: JavaScript error: simulation/ai/common-api/utils.js line 27 a is undefined API3</m.SquareVectorDistance@simulation/ai/common-api/utils.js:27:2 PETRA.AttackPlan.prototype.UpdateWalking@simulation/ai/petra/attackPlan.js:1851:11 PETRA.AttackPlan.prototype.update@simulation/ai/petra/attackPlan.js:1306:39 PETRA.AttackManager.prototype.update@simulation/ai/petra/attackManager.js:322:27 PETRA.HQ.prototype.update@simulation/ai/petra/headquarters.js:2288:22 PETRA.PetraBot.prototype.OnUpdate@simulation/ai/petra/_petrabot.js:118:11 m.BaseAI.prototype.HandleMessage@simulation/ai/common-api/baseAI.js:64:7 Executing turn 3541 of 3867
by , 15 months ago
Attachment: | commands_27531_D4933_D4934.txt added |
---|
comment:11 by , 15 months ago
Milestone: | Backlog → Alpha 27 |
---|---|
Owner: | set to |
Patch: | → Phab:D4936 |
From the last replay, on [27533]:
Executing turn 3540 of 3867 WARNING: ({properties:{name:15, type:"Raid", state:"walking", forced:true, rallyPoint:[294.5, 300.5], overseas:0, paused:false, maxCompletingTime:0, neededShips:1, unitStat:{FastMoving:{priority:1, minSize:0, targetSize:0, batchSize:2, classes:["FastMoving+CitizenSoldier"], interests:[["strength", 1]]}}, siegeState:0, position5TurnsAgo:[287.8659896850586, 289.0021743774414], lastPosition:[263.6951599121094, 271.1994171142578], position:(void 0), isBlocked:false, targetPlayer:0, target:1043, targetPos:[408.88328552246094, 124.9111328125], uniqueTargetId:(void 0), path:[[297.5, 223.5], [308.5, 196.5], [310.5, 194.5], [338.5, 175.5], [389.5, 134.5], [395.5, 131.5], [401.5, 125.5], [408.88328552246094, 124.9111328125], [408.88328552246094, 124.9111328125]]}})
The attack plan only has entities that are garrisoned. I'll make a patch.
Following the trail leads to the conclusion that the attack plan had no entities, probably. Since
this.position
is set at construction and can be set to undefined when the plan is entityless.