From 037f614976310ae7ca888418f2d7ce92272844ae Mon Sep 17 00:00:00 2001 From: Jesse Snyder Date: Mon, 14 Aug 2023 12:42:11 -0700 Subject: [PATCH 01/11] Support static public_good, and make it take precedence over public_good_multiplier --- dlgr/griduniverse/experiment.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/dlgr/griduniverse/experiment.py b/dlgr/griduniverse/experiment.py index f64a2e71..bf7c6e97 100644 --- a/dlgr/griduniverse/experiment.py +++ b/dlgr/griduniverse/experiment.py @@ -321,11 +321,16 @@ def __init__(self, **kwargs): item_type.get("probability_distribution", "") ) - item_type["public_good"] = ( - item_type["calories"] - * item_type.get("public_good_multiplier", 0.0) - / self.num_players - ) + # 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 + ) # Player probability distribution ( From 0a8bac6540d52291a7995493a4047de13f3daed7 Mon Sep 17 00:00:00 2001 From: Jesse Snyder Date: Mon, 14 Aug 2023 13:42:32 -0700 Subject: [PATCH 02/11] Update main README to include introduction to configurable item concept --- README.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5fc2b95f..2dcc88bf 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![codecov](https://codecov.io/gh/Dallinger/Griduniverse/branch/master/graph/badge.svg)](https://codecov.io/gh/Dallinger/Griduniverse) -Reinforcement learning is an area of machine learning that considers the problem faced by a decision-maker in a setting partly under control of the environment. To illustrate the complexities of learning in even simple scenarios, researchers often turn to so-called “Gridworlds”, toy problems that nonetheless capture the rich difficulties that arise when learning in an uncertain world. By adjusting the state space (i.e., the grid), the set of actions available to the decision maker, the reward function, and the mapping between actions and states, a richly structured array of reinforcement learning problems can be generated — a Griduniverse, one might say. To design a successful reinforcement learning AI system, then, is to develop an algorithm that learns well across many such Gridworlds. Indeed, state-of-the-art reinforcement learning algorithms such as deep Q-networks, for example, have achieved professional-level performance across tens of video games from raw pixel input. +Reinforcement learning is an area of machine learning that considers the problem faced by a decision-maker in a setting partly under control of the environment. To illustrate the complexities of learning in even simple scenarios, researchers often turn to so-called “Gridworlds”, toy problems that nonetheless capture the rich difficulties that arise when learning in an uncertain world. By adjusting the state space (i.e., the grid), the set of actions available to the decision maker, the reward function, and the mapping between actions and states, a richly structured array of reinforcement learning problems can be generated — a Griduniverse, one might say. To design a successful reinforcement learning AI system, then, is to develop an algorithm that learns well across many such Gridworlds. Indeed, state-of-the-art reinforcement learning algorithms such as deep Q-networks, for example, have achieved professional-level performance across tens of video games from raw pixel input. Fig. 1. A small Gridworld, reprinted from Sutton & Barto (1998). At each time step, the agent selects a move (up, down, left, right) and receives the reward specified in the grid. @@ -29,9 +29,23 @@ Players take on one of some number of distinguishable identities (NUM_IDENTITIES Fig. 3. Sample colors that could serve as distinguishable identities. -### Objects +### Other Grid Objects -The world may contain non-player objects that are immovable (e.g., walls) or movable (e.g., blocks). +The world may contain various other non-player objects, some of which may be interactive, provide "calories" or "points", or enable players to progress through the +game in various ways, and some of which are inert and non-interactive (walls). Points contribute to the players overall score in the game. + +#### Walls + +Walls are labyrinth of immovable obstacles added to the grid when it's initially constructed. The density and contiguity of the labyrinth can by configured +via configuration parameters (see below). + +#### Items + +Griduniverse provides a rich system for defining interactive and/or nutrition-providing "items" which will also be added to the world. In addition to defining +properties of the items themselves like their caloric value, whether than can be carried by players, and whether the respawn automatically, experiment authors +can also define transitions that are activated when players interact with the item on the block they currently occupy, potentially in combination with an item +they are carrying. For example, a player carrying a stone might be able to transform the stone into a more useful "sharp stone" by sharpening against a +"large rock" that exists in the block they currently occupy. ### Chatroom From 1649fe2a95f9a1f809ff46f71dc0e6b4f6af0bb8 Mon Sep 17 00:00:00 2001 From: Jesse Snyder Date: Mon, 14 Aug 2023 13:43:03 -0700 Subject: [PATCH 03/11] Add detailed documentation of item config variables --- dlgr/griduniverse/game_config.yml | 96 +++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/dlgr/griduniverse/game_config.yml b/dlgr/griduniverse/game_config.yml index ed478ad8..1e95c4b5 100644 --- a/dlgr/griduniverse/game_config.yml +++ b/dlgr/griduniverse/game_config.yml @@ -1,6 +1,18 @@ --- player_config: + # The distribution model used when spawning players on the grid. + # Griduniverse provides a pre-defined set of distribution options: + # - random + # - sinusoidal + # - horizontal + # - vertical + # - edge_bias + # - center_bias + # + # See the distributions.py module for their implementations probability_distribution: "random" + + # Griduniverse uses different colors to represent player groups or teams available_colors: BLUE: [0.50, 0.86, 1.00] YELLOW: [1.00, 0.86, 0.50] @@ -9,26 +21,110 @@ player_config: PURPLE: [0.85, 0.60, 0.85] TEAL: [0.77, 0.96, 0.90] + item_defaults: + # Each item definition must include a unique item_id. This actual value doesn't matter, + # though an easily identifiable label can be helpful in developing and + # debugging your experiment item_id: default + + # How many instances of this item should the world initially include? If "respawn" is true + # the world will regenerate replacements for consumed instances to maintain this + # number of instances. item_count: 8 + + # 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) calories: 0 + + # Can a player occupy the grid block this item is sitting on? crossable: true + + # Does a player need to explicitly interact with this item via the action button + # when they co-occupy its grid block, or do the immediately consume the item + # without needing to take any explicit action? interactive: false + + # How rapidly does this item progress through its maturation lifecycle in + # WHAT UNITS??? maturation_speed: 0.0 + + # At what level of maturity ("ripeness") is this item ready for consumption? + # Prior to reaching this threshold, a player may be able to co-occupy the same + # grid block, but not consume the item. maturation_threshold: 0.0 + + # Some items can be consumed (or otherwise used) more than once; for example + # a berry bush that provides multiple "servings" of berries before it's exhausted. n_uses: 1 + + # Friendly name of the item that may be displayed to the player. name: Food + + # Can this item be "planted" (added to the gridworld) by the players themselves? plantable: false + + # If this item is plantable (see above), how many points/calories are deducted from + # the player's score for each planting event they trigger? planting_cost: 1 + + # Can this item be picked up and carried to another location by the player? portable: true + + # The distribution model used when spawning instances of this item on the grid. + # Griduniverse provides a pre-defined set of distribution options: + # - random + # - sinusoidal + # - horizontal + # - vertical + # - edge_bias + # - center_bias + # + # 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 + # when an instance is consumed? respawn: false + + # If the current number of instances of this item in the gridworld exceeds the + # configured item_count, should we prune items to limit the total to item_count? + # + # Note that item_count is potentially dynamic, changing over time based on + # seasonal_growth_rate and spawn_rate (see below). limit_quantity: false + + # Degree to which the quantity of this item should fluctuate based on "seasons" + # (expressed as alternating rounds of the game, so there are just two seasons). + # This value is an *exponential* multiplier. seasonal_growth_rate: 1.0 + + # 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. spawn_rate: 1.0 + + # Visual representation of this item in the UI. + # This value can be any of: + # - A single hex color value + # - A comma-separated pair of hex colors representing the items immature and mature + # states + # - A unicode emoji "🍓" + # - The path of an image in within the images/ folder ("sprites/strawberry.png") sprite: "#8a9b0f,#7a6b54" transition_defaults: From 0cfa2e954c687eee6132e0c685e71fe882bb5689 Mon Sep 17 00:00:00 2001 From: Jesse Snyder Date: Mon, 14 Aug 2023 14:43:43 -0700 Subject: [PATCH 04/11] Remove public_good as an item config variable --- dlgr/griduniverse/experiment.py | 15 +++++---------- dlgr/griduniverse/game_config.yml | 11 ++--------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/dlgr/griduniverse/experiment.py b/dlgr/griduniverse/experiment.py index bf7c6e97..f64a2e71 100644 --- a/dlgr/griduniverse/experiment.py +++ b/dlgr/griduniverse/experiment.py @@ -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 ( diff --git a/dlgr/griduniverse/game_config.yml b/dlgr/griduniverse/game_config.yml index 1e95c4b5..6dd2b115 100644 --- a/dlgr/griduniverse/game_config.yml +++ b/dlgr/griduniverse/game_config.yml @@ -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? @@ -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 @@ -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. From 3369ac45844f3e566b264acd74d18de3dcb6ce9f Mon Sep 17 00:00:00 2001 From: Jesse Snyder Date: Mon, 14 Aug 2023 15:01:37 -0700 Subject: [PATCH 05/11] Document transition defaults --- dlgr/griduniverse/game_config.yml | 38 +++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/dlgr/griduniverse/game_config.yml b/dlgr/griduniverse/game_config.yml index 6dd2b115..f241b863 100644 --- a/dlgr/griduniverse/game_config.yml +++ b/dlgr/griduniverse/game_config.yml @@ -91,7 +91,7 @@ item_defaults: public_good_multiplier: 0.0 # Should a replacement of this same item type be immediately added to the gridworld - # when an instance is consumed? + # when an existing item is consumed? respawn: false # If the current number of instances of this item in the gridworld exceeds the @@ -108,28 +108,52 @@ 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 value greater than 1.0 will result in a steadily growing item_count. + # time, but a value greater than 1.0 will result in a steadily growing number of items + # of this type. spawn_rate: 1.0 # Visual representation of this item in the UI. # This value can be any of: # - A single hex color value # - A comma-separated pair of hex colors representing the items immature and mature - # states + # states (rendered color will be along a continuum between these colors based on + # current maturity) # - A unicode emoji "🍓" # - The path of an image in within the images/ folder ("sprites/strawberry.png") sprite: "#8a9b0f,#7a6b54" transition_defaults: - visible: seen # Can be set to "never", "always", or "seen" for transitions that become - # visible to a player after they have been executed for the first time + # Can be set to "never", "always", or "seen" for transitions that become + # visible to a player after they have been executed for the first time + visible: seen + + # item_id for the item that will exist in the player's hand after the transition + # has executed actor_end: null + + # item_id for the item that must be in the player's position in order to execute + # the transition actor_start: null + + # item_id for the item that will exist in the player's grid block after the transition + # has executed target_end: null + + # item_id for the item that must exist at the player's current position in order + # to execute the transition target_start: null + + # For items that have an n_uses value greater than 1, if last_use is true, + # the transition will be executed when the final use is exhausted. For example, + # a gooseberry bush with 5 uses could be transitioned to an empty bush when the + # last serving of berries has been harvested. In this case, the target_start + # would be the item_id of the gooseberry bush, and the target_end would be the + # item_id of the item representing the empty bush. last_use: false - modify_uses: [0, 0] # How should the number of uses for the actor and target - # be changed by the transition. + + # How should the number of uses for the actor and target be changed by the transition. + # These can be positive or negative integers. + modify_uses: [0, 0] items: # Legacy GU Food item From b8b05693622c0bd726bad126866c912accb5dba8 Mon Sep 17 00:00:00 2001 From: Jesse Snyder Date: Mon, 14 Aug 2023 15:13:23 -0700 Subject: [PATCH 06/11] Tweaks --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2dcc88bf..f7333311 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,8 @@ via configuration parameters (see below). #### Items Griduniverse provides a rich system for defining interactive and/or nutrition-providing "items" which will also be added to the world. In addition to defining -properties of the items themselves like their caloric value, whether than can be carried by players, and whether the respawn automatically, experiment authors -can also define transitions that are activated when players interact with the item on the block they currently occupy, potentially in combination with an item +properties of the items themselves (caloric value, whether than can be carried by players, whether the respawn automatically, etc.), experiment authors +can also define transitions that execute when players interact with the item on the block they currently occupy, potentially in combination with an item they are carrying. For example, a player carrying a stone might be able to transform the stone into a more useful "sharp stone" by sharpening against a "large rock" that exists in the block they currently occupy. @@ -495,6 +495,10 @@ Default is False. Which Bot class to run. Default: `RandomBot`. +## Item and Item Transition Configuration + +See detailed explanations for each value for items and transitions on the item_defaults +and transition_defaults definitions in game_config.yml. ## Griduniverse bots From cf23eb690e795cf2699952f37f9e89e51057e26c Mon Sep 17 00:00:00 2001 From: Jesse Snyder Date: Tue, 15 Aug 2023 14:45:03 -0700 Subject: [PATCH 07/11] Tweaks --- dlgr/griduniverse/game_config.yml | 54 ++++++++++++++++++------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/dlgr/griduniverse/game_config.yml b/dlgr/griduniverse/game_config.yml index f241b863..6a792671 100644 --- a/dlgr/griduniverse/game_config.yml +++ b/dlgr/griduniverse/game_config.yml @@ -25,12 +25,13 @@ player_config: item_defaults: # Each item definition must include a unique item_id. This actual value doesn't matter, # though an easily identifiable label can be helpful in developing and - # debugging your experiment + # debugging your experiment. item_id: default - # How many instances of this item should the world initially include? If "respawn" is true - # the world will regenerate replacements for consumed instances to maintain this - # number of instances. + # How many instances of this item should the world initially include? + # If "respawn" (see below) is true, consumed items will be replaced to maintain + # this number of instances. Note that this value may increase over the course + # of a game depending on the values of seasonal_growth_rate and spawn_rate (see below). item_count: 8 # How many calories does a single instance provide when a player consumes it? @@ -39,7 +40,7 @@ item_defaults: # other players (see public_good_multiplier, below). calories: 0 - # Can a player occupy the grid block this item is sitting on? + # Can a player co-occupy the grid block this item is sitting on? crossable: true # Does a player need to explicitly interact with this item via the action button @@ -47,30 +48,35 @@ item_defaults: # without needing to take any explicit action? interactive: false - # How rapidly does this item progress through its maturation lifecycle in - # WHAT UNITS??? + # How rapidly this item progresses through its maturation lifecycle maturation_speed: 0.0 - # At what level of maturity ("ripeness") is this item ready for consumption? + # Level of maturity ("ripeness") at which this item ready for consumption. # Prior to reaching this threshold, a player may be able to co-occupy the same # grid block, but not consume the item. maturation_threshold: 0.0 - # Some items can be consumed (or otherwise used) more than once; for example - # a berry bush that provides multiple "servings" of berries before it's exhausted. + # Some items can be consumed (or otherwise used) more than once; for example, + # a berry bush might provide multiple "servings" of berries before it's exhausted. + # On the last use, a special transition may be triggered (see note on last_use + # in transition_defaults configuration below), which may transform this item into + # another. For example, a berry bush may be transformed into an empty berry bush, + # which might have different properties (different sprint, perhaps non-crossable, + # etc.) n_uses: 1 - # Friendly name of the item that may be displayed to the player. + # Friendly name of the item that may be displayed to players. name: Food - # Can this item be "planted" (added to the gridworld) by the players themselves? + # Controls whether this item be "planted" (added to the gridworld) by the players + # themselves. plantable: false - # If this item is plantable (see above), how many points/calories are deducted from - # the player's score for each planting event they trigger? + # If this item is plantable (see above), specifies how many points/calories are + # deducted from the player's score each time they plant one. planting_cost: 1 - # Can this item be picked up and carried to another location by the player? + # Controls whether this item be picked up and carried to another location by the player. portable: true # The distribution model used when spawning instances of this item on the grid. @@ -90,12 +96,13 @@ item_defaults: # calories * public_good_multiplier / number of players public_good_multiplier: 0.0 - # Should a replacement of this same item type be immediately added to the gridworld - # when an existing item is consumed? + # Controls whether a replacement of this same item should be immediately added to the + # gridworld when an existing item is consumed. respawn: false # If the current number of instances of this item in the gridworld exceeds the - # configured item_count, should we prune items to limit the total to item_count? + # configured item_count (because players are planting additional instances, for example), + # should we prune items to limit the total to item_count? # # Note that item_count is potentially dynamic, changing over time based on # seasonal_growth_rate and spawn_rate (see below). @@ -114,13 +121,14 @@ item_defaults: # Visual representation of this item in the UI. # This value can be any of: - # - A single hex color value + # - A single hex color value, prefixed with "color:". Example: "color:#8a9b0f" # - A comma-separated pair of hex colors representing the items immature and mature # states (rendered color will be along a continuum between these colors based on - # current maturity) - # - A unicode emoji "🍓" - # - The path of an image in within the images/ folder ("sprites/strawberry.png") - sprite: "#8a9b0f,#7a6b54" + # current maturity), also prefixed with "color:#8a9b0f,#7a6b54" + # - A unicode emoji, prefixed with "emoji". Example: "emoji:🍓" + # - The path of an image in within the images/ folder, prefixed with "image:". + # Example ("image:sprites/strawberry.png") + sprite: "color:#8a9b0f,#7a6b54" transition_defaults: # Can be set to "never", "always", or "seen" for transitions that become From e1315b6ce5479f2c7eccb321c259e747d7d4d09d Mon Sep 17 00:00:00 2001 From: Jesse Snyder Date: Tue, 15 Aug 2023 15:22:08 -0700 Subject: [PATCH 08/11] Stab at item/transition overview --- README.md | 40 +++++++++++++++++++++++++++---- dlgr/griduniverse/game_config.yml | 4 ++-- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f7333311..6eed6b75 100644 --- a/README.md +++ b/README.md @@ -42,10 +42,10 @@ via configuration parameters (see below). #### Items Griduniverse provides a rich system for defining interactive and/or nutrition-providing "items" which will also be added to the world. In addition to defining -properties of the items themselves (caloric value, whether than can be carried by players, whether the respawn automatically, etc.), experiment authors +properties of the items themselves (caloric value, whether than can be carried by players, whether they respawn automatically, etc.), experiment authors can also define transitions that execute when players interact with the item on the block they currently occupy, potentially in combination with an item they are carrying. For example, a player carrying a stone might be able to transform the stone into a more useful "sharp stone" by sharpening against a -"large rock" that exists in the block they currently occupy. +"large rock" that exists in the block they currently occupy. For more details, see [Items and Transitions](#items-and-transitions) below. ### Chatroom @@ -495,10 +495,42 @@ Default is False. Which Bot class to run. Default: `RandomBot`. -## Item and Item Transition Configuration +## Items and Transitions + +Griduniverse provides a configuration syntax +(see [game_config.yml](./dlgr/griduniverse/game_config.yml)) for defining custom +objects that will be added to the grid world, and transitions that can be triggered by +players, either independently or in cooperation, that extract some value from the items +they're interacting with, and transform items of one type into another type. This makes +it possible for the experiment author to create pathways for techological evolution in +the game. For example, a `wild_carrot_plant` may only yield a `wild_carrot` if the +`wild_carrot` can be cut from the tree using a `sharpened_stone`, and only unsharpened +`stone`s exist in the grid world's intial state. Two players might need to collaborate +to sharpen a plain `stone` against a `big_hard_rock` to transition the `stone` into +a `sharpened_stone`, which can then be used to harvest a `wild_carrot` from the `wild_carrot_plant`. + +Transitions are modeled as a pair of states: prior to the transition execution, and after +the transition has finished. Each state has two sub-componenents: the item +in the possesion of the player executing the transtion, and the item in the grid block +they are currently occupy during the transition. + +Prior to transition execution: + - `actor_start` - the ID of the item the player must be holding for the transition to be available + - `target_start` - the ID of the item that must exist on the player's current grid block for the + transition to be available + +After transition execution: + - `actor_end` - the ID of the item that will exist in the player's hand after the transition + has executed + - `target_end` - the ID of the item left in the player's grid block after the transition executes + +Note that any of these values may be `null`. For example, a transition may result in the item +in the player's current grid block to be consumed, leaving nothing behind. + +### Configuration See detailed explanations for each value for items and transitions on the item_defaults -and transition_defaults definitions in game_config.yml. +and transition_defaults definitions in [game_config.yml](./dlgr/griduniverse/game_config.yml). ## Griduniverse bots diff --git a/dlgr/griduniverse/game_config.yml b/dlgr/griduniverse/game_config.yml index 6a792671..522a8ca3 100644 --- a/dlgr/griduniverse/game_config.yml +++ b/dlgr/griduniverse/game_config.yml @@ -124,8 +124,8 @@ item_defaults: # - A single hex color value, prefixed with "color:". Example: "color:#8a9b0f" # - A comma-separated pair of hex colors representing the items immature and mature # states (rendered color will be along a continuum between these colors based on - # current maturity), also prefixed with "color:#8a9b0f,#7a6b54" - # - A unicode emoji, prefixed with "emoji". Example: "emoji:🍓" + # current maturity), also prefixed with "color:" Example: "color:#8a9b0f,#7a6b54" + # - A unicode emoji, prefixed with "emoji:". Example: "emoji:🍓" # - The path of an image in within the images/ folder, prefixed with "image:". # Example ("image:sprites/strawberry.png") sprite: "color:#8a9b0f,#7a6b54" From e901532d21a1e06d91695756837f7800ab286946 Mon Sep 17 00:00:00 2001 From: Jesse Snyder Date: Tue, 15 Aug 2023 15:45:00 -0700 Subject: [PATCH 09/11] Clarify modify_uses --- dlgr/griduniverse/game_config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dlgr/griduniverse/game_config.yml b/dlgr/griduniverse/game_config.yml index 522a8ca3..ef807715 100644 --- a/dlgr/griduniverse/game_config.yml +++ b/dlgr/griduniverse/game_config.yml @@ -160,7 +160,8 @@ transition_defaults: last_use: false # How should the number of uses for the actor and target be changed by the transition. - # These can be positive or negative integers. + # These can be positive or negative integers: -1 would decrement n_uses, 1 would add + # an additional use. modify_uses: [0, 0] items: From b0d4a9f8354f295df47c88e8eee83eca7ea565fb Mon Sep 17 00:00:00 2001 From: Jesse Snyder Date: Tue, 15 Aug 2023 16:05:44 -0700 Subject: [PATCH 10/11] Improvements based on PR review --- dlgr/griduniverse/game_config.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/dlgr/griduniverse/game_config.yml b/dlgr/griduniverse/game_config.yml index ef807715..ea3dc5c9 100644 --- a/dlgr/griduniverse/game_config.yml +++ b/dlgr/griduniverse/game_config.yml @@ -46,7 +46,7 @@ item_defaults: # Does a player need to explicitly interact with this item via the action button # when they co-occupy its grid block, or do the immediately consume the item # without needing to take any explicit action? - interactive: false + interactive: true # How rapidly this item progresses through its maturation lifecycle maturation_speed: 0.0 @@ -66,7 +66,7 @@ item_defaults: n_uses: 1 # Friendly name of the item that may be displayed to players. - name: Food + name: Generic Item # Controls whether this item be "planted" (added to the gridworld) by the players # themselves. @@ -88,7 +88,16 @@ item_defaults: # - edge_bias # - center_bias # - # See the distributions.py module for their implementations + # See the distributions.py module for their implementations. + # + # To implement a custom distribution option, add a function to distributions.py, + # with a name following the pattern [some_name]_probability_distribution(), with + # a signature matching the other functions in the module (rows, columns, *args), + # and returning an two-item array of integers representing a [row, column] grid position. + # + # To use your custom distibution for an item, specify only the prefix portion as the + # configuration value here (if your function name is "amazing_probability_distribution", + # the value to use here would be "amazing"). probability_distribution: "random" # Basis from computing calories credited to all *other players* when a player @@ -139,7 +148,7 @@ transition_defaults: # has executed actor_end: null - # item_id for the item that must be in the player's position in order to execute + # item_id for the item that must be in the player's hand in order to execute # the transition actor_start: null From e524d66f5eeaa17ee4608a725f6ff415f7268547 Mon Sep 17 00:00:00 2001 From: Jesse Snyder Date: Tue, 15 Aug 2023 16:14:58 -0700 Subject: [PATCH 11/11] The position we find to place items is not necessarily random --- dlgr/griduniverse/experiment.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dlgr/griduniverse/experiment.py b/dlgr/griduniverse/experiment.py index f64a2e71..02e7b943 100644 --- a/dlgr/griduniverse/experiment.py +++ b/dlgr/griduniverse/experiment.py @@ -806,7 +806,7 @@ def spawn_item(self, position=None, item_id=None): item_id = obj.get("item_id", 1) if not position: - position = self._random_empty_position(item_id) + position = self._find_empty_position(item_id) item_props = self.item_config[item_id] new_item = Item( @@ -894,7 +894,7 @@ def spawn_player(self, id=None, **kwargs): """Spawn a player.""" player = Player( id=id, - position=self._random_empty_position(player=True), + position=self._find_empty_position(player=True), num_possible_colors=self.num_colors, motion_speed_limit=self.motion_speed_limit, motion_cost=self.motion_cost, @@ -912,9 +912,8 @@ def spawn_player(self, id=None, **kwargs): self._start_if_ready() return player - def _random_empty_position(self, item_id=None, player=False): - """Select an empty cell at random, using the configured probability - distribution.""" + def _find_empty_position(self, item_id=None, player=False): + """Select an empty cell, using the configured probability distribution.""" rows = self.rows columns = self.columns empty_cell = False