Opened 8 years ago
Last modified 20 months ago
#3858 new defect
Make AI serialization fully "reproducible"
Reported by: | Imarok | Owned by: | |
---|---|---|---|
Priority: | Must Have | Milestone: | Backlog |
Component: | AI | Keywords: | AI, Serialization, beta |
Cc: | Andy Alt | Patch: | Phab:D2573 |
Description (last modified by )
This would allow rejoining multiplayer games with AI without having an OOS. As said in this posthttps://wildfiregames.com/forum/index.php?/topic/20592-out-of-sync-error-still-a-known-issue/&do=findComment&comment=314691 the state of the AI after serialization is not exactly the same state as before.
Attachments (5)
Change History (24)
by , 8 years ago
Attachment: | AITerritory.patch added |
---|
by , 8 years ago
Attachment: | AITerritory-v2.patch added |
---|
fixed version taking DiplomacyChanged events into account
comment:2 by , 8 years ago
Milestone: | Alpha 21 → Backlog |
---|
Correct me if you are planning to work on this in the near future.
comment:4 by , 8 years ago
Keywords: | beta added |
---|
comment:5 by , 7 years ago
Description: | modified (diff) |
---|
https://code.wildfiregames.com/D105 introduces a hint that MP games with AI are not supported. This string should be removed once this ticket becomes fixed.
comment:8 by , 4 years ago
Milestone: | Backlog → Work In Progress |
---|---|
Owner: | set to |
So far I located this:
AttackManager:
this.bombingAttacks is not serialised nor restored properly
comment:9 by , 4 years ago
From last oos test done with bb and Stan, ai playing as ptolemy player id = 4:
"resourceCount": { "food": 240, "wood": 210, "stone": 306, "metal": 302 },
vs
"resourceCount": { "food": 290, "wood": 210, "stone": 306, "metal": 252 },
"resourcesUsed": { "food": 250, "wood": 100, "stone": 0, "metal": 0 }
VS
"resourcesUsed": { "food": 200, "wood": 100, "stone": 0, "metal": 50 },
reason why it differs: here is production queue from cc
"queue": [ { "id": 4, "player": 4, "unitTemplate": "units/ptol_infantry_pikeman_b", "count": 2, "metadata": { "role": "worker", "base": 2 }, "resources": { "food": 50, "metal": 0, "stone": 0, "wood": 50 },
vs
"queue": [ { "id": 4, "player": 4, "unitTemplate": "units/ptol_infantry_javelinist_b", "count": 2, "metadata": { "role": "worker", "base": 2 }, "resources": { "food": 25, "metal": 25, "stone": 0, "wood": 50 },
comment:10 by , 4 years ago
Another difference is with rng number in AIManager and one ai has one extra key in metadata with empty object
by , 4 years ago
comment:11 by , 4 years ago
pyrogenesis -replay="/home/user/.local/share/0ad/replays/0.0.24/2020-01-14_0023/commands.txt" -mod=public -rejointest=1
Initializing the secondary simulation WARNING: JavaScript warning: simulation/ai/petra/_petrabot.js line 157 reference to undefined property this.queueManager ERROR: JavaScript error: simulation/ai/petra/_petrabot.js line 157 TypeError: this.queueManager is undefined PETRA.PetraBot.prototype.Serialize@simulation/ai/petra/_petrabot.js:157:3 ERROR: AI script Serialize call failed ERROR: JavaScript error: simulation/ai/petra/_petrabot.js line 157 TypeError: this.queueManager is undefined PETRA.PetraBot.prototype.Serialize@simulation/ai/petra/_petrabot.js:157:3 ERROR: AI script Serialize call failed Writing serializationtest-data to serializationtest/2020-01-14_0001 Simulation2.cpp(337): Assertion failed: "0 && (L"Serialization test failure")" Assertion failed: "0 && (L"Serialization test failure")" Location: Simulation2.cpp:337 (ReportSerializationFailure)
comment:12 by , 4 years ago
From another test: Rng codes from serialisation and deserialisation:
WARNING: Seserialise rngString 67211753696534 WARNING: Seserialise rngString 67211753696534 WARNING: Deserialise rngString 67211753696534 WARNING: Seserialise rngString 270851547002234 WARNING: Seserialise rngString 270851547002234 WARNING: Seserialise rngString 270851547002234 WARNING: Seserialise rngString 270851547002234 ERROR: Out-Of-Sync on turn 80 Players: Angen Dumping state to C:\Users\Slavomír\AppData\Local\0ad\logs\oos_dump.txt WARNING: Seserialise rngString 270851547002234
but when comparing oos dumps from bb:
AIManager: num ais: 2 rng: "67211753696534" turn: 0 useSharedScript: true sharedData: { "players": [ 3, 4 ],
from me:
AIManager: num ais: 2 rng: "270851547002234" turn: 0 useSharedScript: true sharedData: { "players": [ 3, 4 ],
Notice that I have newer rng than he does.That would explain problem with units in queue because ai picks units at random.
comment:13 by , 4 years ago
Possibly all this calls are causing change of rng for aimanager when deserialising and making matches incompatible.
L131 // Put some randomness on the attack size var variation = 0.8 + 0.4*Math.random();
L34 this.sentDiplomacyRequestLapseTime = 120 + randFloat(10, 100);
common-api gamestate
L47 techName = pickRandom([techData._template.top, techData._template.bottom].filter(tech => !this.playerData.disabledTechnologies[tech])) || techData._template.top;
comment:14 by , 4 years ago
Patch: | → Phab:D2573 |
---|
comment:15 by , 4 years ago
After loading saved game: WARNING: PlayerID 2 | Petra: HugeAttack 5 has an inaccessible target with indices 3 1 from units/ptol_support_female_citizen
Reported on forum by gameboy: https://wildfiregames.com/forum/index.php?/topic/27524-warning/
Edit: Map issue
comment:16 by , 4 years ago
if (this._entitiesModifications.has(evt.entity) && !this._entities.has(evt.entity))
error("entity is in modifications but not in entities");
at L254 in shared.js triggers
ERROR: entity is in modifications but not int entities
what means entity is not removed from this._entitesModifications.
this._entities is rebuilt from state.entities and not serialised like this._entitiesModifications, so state.entities contains different data than it should.
entity.js L562 is adding starting entities to this._entitiesModifications
comment:17 by , 4 years ago
Entity without position is assigned to transport plan but not onboard https://wildfiregames.com/forum/index.php?/topic/27948-petra-javascript-errors/
comment:18 by , 20 months ago
Cc: | added |
---|
comment:19 by , 20 months ago
Milestone: | Work In Progress → Backlog |
---|---|
Owner: | removed |
Backlogging due to lack of progress and Silier retiring.
let the AI recomputes territories only when receiving TerritoriesChanged events, to cure one of the nonreproducibilities