virtualcommons / port-of-mars

Port of Mars is an online, game-based, social science experiment set on the first human community on the Red Planet. We are now in an open beta where anyone aged 18 and over can participate.
https://portofmars.asu.edu
GNU Affero General Public License v3.0
10 stars 16 forks source link

errors in data export #827

Closed alee closed 10 months ago

alee commented 1 year ago

For tournament round id 11 (first round of the 2022-02 tournament) data export is failing due to an uninitialized gameState.currentEvent

https://github.com/virtualcommons/port-of-mars/blob/34cc5223353c7966a348ad638cac1e3fedb224bc/server/src/rooms/game/events/index.ts#L366

need to see if any changes were made to replay handling / initialization that may have caused this regression

Logs:

[18:03:52.768] DEBUG (274): phase: events
    filename: "/code/server/src/rooms/game/events/index.js"
[18:03:52.768] WARN (274): new mars event 1 of 3: [{"id":"solarFlare","name":"Solar Flare","effect":"Destroy 5 System Health. Skip discussion and trading phases this turn. Players cannot chat or trade Influences.","flavorText":"Solar flares pose a far greater threat on Mars, where a thin atmosphere and non-existent magnetic field leaves settlers more vulnerable. ","clientViewHandler":"DISABLE_CHAT","elapsed":1,"duration":1,"state":{"id":"solarFlare"},"timeDuration":10},{"id":"lifeAsUsual","name":"Life as Usual","effect":"No special effect","flavorText":"As the first human outpost on Mars, having a \"usual\" day is pretty unusual.","clientViewHandler":"NO_CHANGE","elapsed":1,"duration":1,"state":{"id":"lifeAsUsual"},"timeDuration":10},{"id":"murphysLaw","name":"Murphy's Law","effect":"Reveal 2 more events. They're both in effect.","flavorText":"Residents at Port of Mars know better than to ask, \"what ELSE could go wrong?\"","clientViewHandler":"NO_CHANGE","elapsed":1,"duration":1,"state":{"id":"murphysLaw"},"timeDuration":10}]
    filename: "/code/server/src/rooms/game/events/index.js"
[18:03:52.769] WARN (274): new mars event 2 of 3: [{"id":"solarFlare","name":"Solar Flare","effect":"Destroy 5 System Health. Skip discussion and trading phases this turn. Players cannot chat or trade Influences.","flavorText":"Solar flares pose a far greater threat on Mars, where a thin atmosphere and non-existent magnetic field leaves settlers more vulnerable. ","clientViewHandler":"DISABLE_CHAT","elapsed":1,"duration":1,"state":{"id":"solarFlare"},"timeDuration":10},{"id":"lifeAsUsual","name":"Life as Usual","effect":"No special effect","flavorText":"As the first human outpost on Mars, having a \"usual\" day is pretty unusual.","clientViewHandler":"NO_CHANGE","elapsed":1,"duration":1,"state":{"id":"lifeAsUsual"},"timeDuration":10},{"id":"murphysLaw","name":"Murphy's Law","effect":"Reveal 2 more events. They're both in effect.","flavorText":"Residents at Port of Mars know better than to ask, \"what ELSE could go wrong?\"","clientViewHandler":"NO_CHANGE","elapsed":1,"duration":1,"state":{"id":"murphysLaw"},"timeDuration":10}]
    filename: "/code/server/src/rooms/game/events/index.js"
[18:03:52.769] DEBUG (274): phase: invest
    filename: "/code/server/src/rooms/game/events/index.js"
[18:03:52.769] INFO (274): investing {"culture":1,"finance":0,"government":0,"legacy":0,"science":0,"systemHealth":8}
    filename: "/code/server/src/rooms/game/state/index.js"
/code/server/src/rooms/game/events/index.js:277
        game.timeRemaining = game.currentEvent.timeDuration;
                                               ^

TypeError: Cannot read properties of undefined (reading 'timeDuration')
    at ReenteredMarsEventPhase.apply (/code/server/src/rooms/game/events/index.js:277:48)
    at /code/server/src/rooms/game/state/index.js:1397:32
    at Array.forEach (<anonymous>)
    at GameState.applyMany (/code/server/src/rooms/game/state/index.js:1396:15)
    at MarsLogSummarizer._summarizeGame (/code/server/src/services/replay.js:400:18)
    at MarsLogSummarizer.summarize (/code/server/src/services/replay.js:406:38)
    at summarize.next (<anonymous>)
    at MarsLogSummarizer.<anonymous> (/code/server/src/services/replay.js:59:36)
    at Generator.next (<anonymous>)
    at /code/server/src/services/replay.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/code/server/src/services/replay.js:4:12)
    at MarsLogSummarizer.save (/code/server/src/services/replay.js:51:16)
    at /code/server/src/cli.js:86:24
    at Array.map (<anonymous>)
    at /code/server/src/cli.js:86:11
error Command failed with exit code 1.
alee commented 1 year ago

For tournament round 11 this error comes up in 3167f20452251bfb4ee5a1055f91d7d545023c8b but strangely 96b86cb799edd9331e3c1ba3840ead9791357655 works

For tournament round 13, 96b86cb799edd9331e3c1ba3840ead9791357655 also fails

alee commented 1 year ago

as a stopgap will be running data export from the last known good configuration at 8c4027d367f5999e30b4cd6fab1ff94fe8863c0e

alee commented 1 year ago

appears to be fixable by refactoring GameState's currentEvent getter to return the last Event in marsEvents instead of going out of index and returning undefined

needs further data testing / validation though

alee commented 1 year ago

current data export now fails in the R code with an error message Error in -x : invalid argument to unary operator Calls: run_pipeline ... <Anonymous> -> vars_select_eval -> map_if -> map -> .f -> -

More context:

Parsed with column specification:
cols(
  id = col_double(),
  gameId = col_double(),
  type = col_character(),
  payload = col_character(),
  dateCreated = col_character(),
  timeRemaining = col_double(),
  game = col_character(),
  phaseInitialTimeRemaining = col_double(),
  systemHealthInitial = col_double(),
  roundInitial = col_double(),
  phaseInitial = col_character(),
  phaseFinalTimeRemaining = col_double(),
  systemHealthFinal = col_double(),
  roundFinal = col_double(),
  phaseFinal = col_character(),
  role = col_character()
)
Parsed with column specification:
cols(
  id = col_double(),
  gameId = col_double(),
  role = col_character(),
  investment = col_character(),
  name = col_character(),
  availableTimeBlocks = col_double(),
  value = col_double(),
  initialTimeRemaining = col_double(),
  phaseFinalTimeRemaining = col_double(),
  systemHealthFinal = col_double(),
  roundFinal = col_double(),
  phaseFinal = col_character()
)
Error in -x : invalid argument to unary operator
Calls: run_pipeline ... <Anonymous> -> vars_select_eval -> map_if -> map -> .f -> -
Execution halted
sgfost commented 1 year ago

a6ffb23631cdfca2ac375e9355c6a1d0ade141c1 resolves the above issue with the initial export script by handling games without chat messages. Need to investigate if/how this cascades down to the analysis

alee commented 10 months ago

closing for now, re-open if we encounter other issues