theRAPTLab / gsgo

GEM-STEP Foundation repo migrated from GitLab June 2023
1 stars 1 forks source link

New `global` agent - [merged] #716

Closed benloh closed 1 year ago

benloh commented 2 years ago

Merges dev-bl/global -> dev-next

In trying to implement support for global properties in the wizard UI, it quickly became clear that the most efficient way to support global properties was to make the global agent a blueprint that can be edited like any other blueprint. Any other solutions involved torturous workarounds.

What this involves:

Conversion

In general, here's what you need to do for any project that is currently using the Global feature.

  1. Open the project and a new global agent will be added.
  2. Remove addFeature Global
  3. Convert any featCall Global.addGlobalProp xxx calls to a new addProp xxx in the global agent.
  4. Convert any featCall Global.globalProp xxx calls to a prop global.xxx in the current agent.
  5. Convert any featCall Global.getGlobalProp xxx calls to a prop global.xxx in the current agent.

Example from decomposition_energy

See art-assets repo, branch global-fix, file decomposition_energy.gemprj for an example of how to do the conversion from use of the Global Feature to using the global agent.

# BLUEPRINT global
addFeature Population
addProp energyReleasedAsHeat number 0
# BLUEPRINT EnergyRepresentation
...
when EnergyRepresentation centerFirstTouches Plant [[
  ...
  // if you have energy from the sun, then give some energy to the plant, but not all of it because some is released into the environment
  // as heat or lost in other ways
  ifExpr {{ EnergyRepresentation.getProp('energyType').value == 'source' }} [[
    ...
    prop Plant.energyLevel add 50
    // we are losing 50 of the hundred, so note that in the global
    // GLOBAL FIX -- ORIG LINE: featCall Global globalProp energyReleasedAsHeat add 50
    prop global.energyReleasedAsHeat add 50
    ...
benloh commented 2 years ago

requested review from @jdanish

benloh commented 2 years ago

marked this merge request as ready

benloh commented 2 years ago

@jdanish I don't think anyone's using this at the moment, but if for some reason a blueprint needs to access the Round's roundTime property, we can implement the round REFEREE_AGENT the same way that we're implementing global. (roundTime used to be in the global agent, but has been moved to a separate REFEREE_AGENT that manages rounds)

benloh commented 2 years ago

added 1 commit

Compare with previous version

benloh commented 2 years ago

In GitLab by @jdanish on Sep 11, 2022, 06:14

I don't actually recall what roundTime was - is that just the count within the round? In which case we can fake it with a global property of some sort? In which case I think we are fine.

benloh commented 2 years ago

In GitLab by @jdanish on Sep 11, 2022, 06:14

This appears to work, by the way - so I am OK with a merge if you are.

benloh commented 2 years ago

mentioned in commit ec608916fb8d53040db10e52086b4b4956edf7cd