Remove this.events from AIs

`this.events` is only valid during one turn. When it is used in the next
turnn it might be outdated. So it makes no sense to keep it alive untill
the next turn.
This commit is contained in:
phosit 2025-09-07 14:53:56 +02:00
parent cbce748b8c
commit babe9e5c18
No known key found for this signature in database
GPG key ID: C9430B600671C268
2 changed files with 3 additions and 4 deletions

View file

@ -49,7 +49,6 @@ BaseAI.prototype.CustomInit = function()
BaseAI.prototype.HandleMessage = function(state, playerID, sharedAI) BaseAI.prototype.HandleMessage = function(state, playerID, sharedAI)
{ {
PlayerID = playerID; PlayerID = playerID;
this.events = sharedAI.events;
this.territoryMap = sharedAI.territoryMap; this.territoryMap = sharedAI.territoryMap;
if (this.isDeserialized) if (this.isDeserialized)

View file

@ -92,14 +92,14 @@ PetraBot.prototype.OnUpdate = function(sharedScript)
if (this.gameFinished || this.gameState.playerData.state == "defeated") if (this.gameFinished || this.gameState.playerData.state == "defeated")
return; return;
for (const i in this.events) for (const i in sharedScript.events)
{ {
if (i == "AIMetadata") // not used inside petra if (i == "AIMetadata") // not used inside petra
continue; continue;
if (this.savedEvents[i] !== undefined) if (this.savedEvents[i] !== undefined)
this.savedEvents[i] = this.savedEvents[i].concat(this.events[i]); this.savedEvents[i] = this.savedEvents[i].concat(sharedScript.events[i]);
else else
this.savedEvents[i] = this.events[i]; this.savedEvents[i] = sharedScript.events[i];
} }
// Run the update every n turns, offset depending on player ID to balance the load // Run the update every n turns, offset depending on player ID to balance the load