diff --git a/dlgr/griduniverse/experiment.py b/dlgr/griduniverse/experiment.py index e5bbdb13..e66e30b0 100644 --- a/dlgr/griduniverse/experiment.py +++ b/dlgr/griduniverse/experiment.py @@ -593,171 +593,12 @@ def deserialize(self, state): self.item_locations[tuple(obj.position)] = obj def instructions(self): - color_costs = "" - order = "" - text = """

The objective of the game is to maximize your final payoff. - The game is played on a {g.columns} x {g.rows} grid, where each - player occupies one block.

""" - if self.window_columns < self.columns or self.window_rows < self.rows: - text += """ The grid is viewed through a - {g.window_columns} x {g.window_rows} window - that moves along with your player.""" - if self.walls_density > 0: - text += """ There are walls throughout the grid, which the players - cannot pass through.""" - if not self.walls_visible: - text += " However, the walls are not visible." - if self.build_walls: - text += """ Players can build walls at their current position using - the 'w' key. The wall will not appear until the player has moved - away from that position.""" - if self.wall_building_cost > 0: - text += """ Building a wall has a cost of {g.wall_building_cost} - points.""" - if self.num_rounds > 1: - text += """ The game has {g.num_rounds} rounds, each lasting - {g.time_per_round} seconds.

""" - else: - text += ( - " The game duration is {g.time_per_round} seconds.

" - ) - if self.num_players > 1: - text += """

There are {g.num_players} players participating - in the game.""" - if not self.others_visible: - text += """ However, players cannot see each other on the - grid.""" - if self.num_colors > 1: - text += """ Each player will be one of {g.num_colors} available - colors ({color_list}).""" - if self.mutable_colors: - text += " Players can change color using the 'c' key." - if self.costly_colors: - costs = [ - "{c}, {p} points".format(c=c, p=p) - for p, c in zip( - self.color_costs, self.limited_player_color_names - ) - ] - color_costs = "; ".join(costs) - text += """ Changing color has a different cost in - points for each color: {color_costs}.""" - if self.contagion > 0: - text += """ If a player enters a region of the grid where a - plurality of the surrounding players within {g.contagion} - blocks are of a different color, that player will take - on the color of the plurality.""" - if self.contagion_hierarchy: - order = ", ".join( - [ - self.limited_player_color_names[h] - for h in self.contagion_hierarchy - ] - ) - text += """ However, there is a hierarchy of colors, so - that only players of some colors are susceptible to - changing color in this way. The hierarchy, from - lowest to highest, is: {order}. Colors lower in the - hierarchy can be affected only by higher colors.""" - if self.frequency_dependence > 0: - text += """ Players will get more points if their - color is in the majority.""" - if self.frequency_dependence < 0: - text += """ Players will get more points if their - color is in the minority.""" - text += """

Players move around the grid using the arrow keys. -

""" - if self.player_overlap: - text += " More than one player can occupy a block at the same time." - else: - text += """ A player cannot occupy a block where a player is - already present.""" - if self.visibility < max(self.rows, self.columns): - text += """ Players cannot see the whole grid, but only an area - approximately {g.visibility} blocks around their current - position.""" - text += """

Press the 'h' key to toggle highlighting of your player. -

""" - if self.motion_auto: - text += """ Once a player presses a key to move, the player will - continue to move in the same direction automatically until - another key is pressed.""" - if self.motion_cost > 0: - text += """ Each movement costs the player {g.motion_cost} - {g.motion_cost:plural, point, points}.""" - if self.motion_tremble_rate > 0 and self.motion_tremble_rate < 0.4: - text += """ Some of the time, movement will not be in the chosen - direction, but random.""" - if self.motion_tremble_rate >= 0.4 and self.motion_tremble_rate < 0.7: - text += """ Movement will not be in the chosen direction most of the - time, but random.""" - if self.motion_tremble_rate >= 0.7: - text += """ Movement commands will be ignored almost all of the time, - and the player will move in a random direction instead.""" - text += """

Players gain points by getting to squares that have - food on them. Each piece of food is worth x - points. When the game starts there - are n pieces - of food on the grid. Food is represented by a green""" - - text += " or brown" - text += " square: " - text += " " - text += "
Food can be respawned after it is consumed." - - text += """It will appear immediately, but may not be consumable for - some time if it has a maturation period. It will show - up as brown initially, and then as green when it matures.""" - text += """
The location where the food will appear after respawning is - is determined by the configured - probability distribution for each item type.""" - text += " Players may be able to plant more food by pressing the spacebar." - text += "

" - if self.alternate_consumption_donation and self.num_rounds > 1: - text += """

Rounds will alternate between consumption and - donation rounds. Consumption rounds will allow for free movement - on the grid. Donation rounds will disable movement and allow you to donate points.

- """ - if self.donation_amount > 0: - text += """
-

It can be helpful to donate points to others. - """ - if self.donation_individual: - text += """ You can donate {g.donation_amount} - {g.donation_amount:plural, point, points} to any player by clicking on - , then clicking on their block on the grid. - """ - if self.donation_group: - text += """ To donate to a group, click on the - - button, then click on any player with the color of the team - you want to donate to. - """ - if self.donation_public: - text += """ The button splits your donation amongst - every player in the game (including yourself). - """ - text += "

" - if self.show_chatroom: - text += """

A chatroom is available to send messages to the other - players.""" - if self.pseudonyms: - text += """ Player names shown on the chat window are pseudonyms. -
""" - text += "

" - if self.dollars_per_point > 0: - text += """

You will receive ${g.dollars_per_point} for each point - that you score at the end of the game.

""" - return formatter.format( - text, - g=self, - order=order, - color_costs=color_costs, - color_list=", ".join(self.limited_player_color_names), + instructions_file_path = os.path.join( + os.path.dirname(__file__), "templates/instructions/instruct-ready.html" ) + with open(instructions_file_path) as instructions_file: + instructions_html = instructions_file.read() + return instructions_html def consume(self): """Players consume the non-interactive items""" diff --git a/dlgr/griduniverse/game_config.yml b/dlgr/griduniverse/game_config.yml index 34ee9d03..e3e4fc7c 100644 --- a/dlgr/griduniverse/game_config.yml +++ b/dlgr/griduniverse/game_config.yml @@ -176,39 +176,6 @@ transition_defaults: modify_uses: [0, 0] items: - # Legacy GU Food item - - item_id: food - calories: 5 - crossable: true - interactive: false - maturation_speed: 0.1 - maturation_threshold: 0.5 - n_uses: 1 - name: Food - plantable: false - planting_cost: 1 - portable: true - respawn: true - item_count: 8 - limit_quantity: true - sprite: "color:#8a9b0f,#7a6b54" - - - item_id: food2 - calories: 3 - crossable: true - interactive: false - item_count: 50 - maturation_speed: 0.2 - maturation_threshold: 0.5 - n_uses: 1 - name: Food2 - plantable: false - planting_cost: 1 - portable: true - respawn: true - limit_quantity: true - sprite: "image:sprites/food.png" - # One Hour, One Life items - crossable: true interactive: true diff --git a/dlgr/griduniverse/static/images/gameplay.gif b/dlgr/griduniverse/static/images/gameplay.gif deleted file mode 100644 index 22443f3d..00000000 Binary files a/dlgr/griduniverse/static/images/gameplay.gif and /dev/null differ diff --git a/dlgr/griduniverse/static/images/gameplay.png b/dlgr/griduniverse/static/images/gameplay.png new file mode 100644 index 00000000..c188996b Binary files /dev/null and b/dlgr/griduniverse/static/images/gameplay.png differ diff --git a/dlgr/griduniverse/static/images/h-toggle.gif b/dlgr/griduniverse/static/images/h-toggle.gif deleted file mode 100644 index 0056717c..00000000 Binary files a/dlgr/griduniverse/static/images/h-toggle.gif and /dev/null differ diff --git a/dlgr/griduniverse/static/images/h-toggle.png b/dlgr/griduniverse/static/images/h-toggle.png new file mode 100644 index 00000000..98f64555 Binary files /dev/null and b/dlgr/griduniverse/static/images/h-toggle.png differ diff --git a/dlgr/griduniverse/static/images/stone.png b/dlgr/griduniverse/static/images/stone.png new file mode 100644 index 00000000..2e56d2a0 Binary files /dev/null and b/dlgr/griduniverse/static/images/stone.png differ diff --git a/dlgr/griduniverse/templates/instructions/instruct-ready.html b/dlgr/griduniverse/templates/instructions/instruct-ready.html new file mode 100644 index 00000000..2c1e4af7 --- /dev/null +++ b/dlgr/griduniverse/templates/instructions/instruct-ready.html @@ -0,0 +1,58 @@ +

+ The objective of the game is to maximize your final payoff. + The game is played on a 200 x 100 grid, where each + player occupies one block.
+
+ The grid is viewed through a 20 x 20 window + that moves along with your player. The game has 3 rounds, each lasting + 45.0 seconds. +

+

+ Players move around the grid using the arrow keys.
+
+ A player cannot occupy a block where a player is + already present. Players cannot see the whole grid, but only an area + approximately 40 blocks around their current position. +

+

+ Press the 'h' key to toggle highlighting of your player.
+ +

+

+ Players gain points by picking up and eating edible items: +

+ Once a food item is being carried, pressing the spacebar causes + it to be eaten, which awards the points to the player. +

+

+ The edible items do not exist on the board at the start of play. + Players must produce them by picking up other objects and carrying out + "transitions" to transform them, or by reaching a specific object and + triggering the transition. +

+ It is possible for the players to transform some items into food + in various ways: + +

+

+ A chatroom is available to send messages to the other + players. Player names shown on the chat window are pseudonyms.
+ +

+

+ You will receive $0.02 for each point + that you score at the end of the game. +

diff --git a/test/test_griduniverse.py b/test/test_griduniverse.py index c09abf9f..9eb3559d 100755 --- a/test/test_griduniverse.py +++ b/test/test_griduniverse.py @@ -125,8 +125,8 @@ def test_new_experiment_has_item_config_with_defaults(self, exp): item_config = exp.item_config assert isinstance(item_config, dict) # We define a Food item, and pull the null public good multiplier from the default - assert item_config["food"]["name"] == "Food" - assert item_config["food"]["public_good_multiplier"] == 0.0 + assert item_config["stone"]["name"] == "Stone" + assert item_config["stone"]["public_good_multiplier"] == 0.0 def test_new_experiment_has_transition_config_with_defaults(self, exp): transition_config = exp.transition_config diff --git a/test/test_gridworld.py b/test/test_gridworld.py index aca6823b..5a0c9726 100644 --- a/test/test_gridworld.py +++ b/test/test_gridworld.py @@ -115,7 +115,4 @@ class TestInstructions(object): def test_instructions(self, gridworld): # Just test something basic html = gridworld.instructions() - assert ( - f"game duration is {gridworld.time_per_round} seconds" - in html - ) + assert "🫐 Gooseberry (3 points)" in html