Skip to content

Commit

Permalink
Remove public_good as an item config variable
Browse files Browse the repository at this point in the history
  • Loading branch information
jessesnyder committed Aug 14, 2023
1 parent 1649fe2 commit 0cfa2e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
15 changes: 5 additions & 10 deletions dlgr/griduniverse/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,16 +321,11 @@ def __init__(self, **kwargs):
item_type.get("probability_distribution", "")
)

# static version of public good
public_good = item_type.get("public_good", 0.0)
# alternate version which interacts with calories
public_good_multiplier = item_type.get("public_good_multiplier", 0.0)

if public_good == 0.0 and public_good_multiplier != 0.0:
# Overwrite public_good with value derived from multiplier and calories:
item_type["public_good"] = (
item_type["calories"] * public_good_multiplier / self.num_players
)
item_type["public_good"] = (
item_type["calories"]
* item_type.get("public_good_multiplier", 0.0)
/ self.num_players
)

# Player probability distribution
(
Expand Down
11 changes: 2 additions & 9 deletions dlgr/griduniverse/game_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ item_defaults:
# How many calories does a single instance provide when a player consumes it?
# In the simple case, the consuming player will get all the caloric benefit from
# items they consume, but there are also options for dividing this benefit among
# other players (see public_good and public_good_multiplier, below)
# other players (see public_good_multiplier, below).
calories: 0

# Can a player occupy the grid block this item is sitting on?
Expand Down Expand Up @@ -85,16 +85,9 @@ item_defaults:
# See the distributions.py module for their implementations
probability_distribution: "random"

# The number of calories to be given to all *other players* when a player consumes
# an instance of this item.
# If this value is non-zero, public_good_multiplier will be ignored.
public_good: 0.0

# Basis from computing calories credited to all *other players* when a player
# consumes an instance of this item. The credit will be equal to:
# calories * public_good_multiplier / number of players
#
# Note that unless public_good is 0, this value will be ignored.
public_good_multiplier: 0.0

# Should a replacement of this same item type be immediately added to the gridworld
Expand All @@ -115,7 +108,7 @@ item_defaults:

# At what rate should additional instances of this item be added to the gridworld?
# A rate of 1.0 means that the target number of items (item_count) will not grow over
# time, but a large value will result in a steadily growing item_count.
# time, but a value greater than 1.0 will result in a steadily growing item_count.
spawn_rate: 1.0

# Visual representation of this item in the UI.
Expand Down

0 comments on commit 0cfa2e9

Please sign in to comment.