Skip to content
Tim Erickson edited this page Sep 26, 2018 · 2 revisions

Fish

This is a commons game. You are a fisherperson, making a living on the sea. Every year, you decide how many fish (could be "tons of fish" if we were more realistic) you want to catch. Then, the next year, you do the same.

The trouble is, there is a finite population of fish. They do reproduce, but if you take a lot of fish, your stocks will decline and eventually you won't be able to keep your business going.

And if other people are also playing, you might be prudent but some other person could ruin things.

So there are social/ecological/economic lessons to be learned. From a plugin/software point of view, the innovation here is that we have multiple players interacting in the same game world. That means we need a persistent and accessible game state; we do that with a mySQL database (ideally upgraded to Firebase by someone better than Tim!).

Some notes on how this works from the user's POV:

  • At the beginning, you can choose whether to join a game or create one. If you choose to create one, you get a code — three words separated by dots, e.g., have.light.wombat — that you can share with others, and which they can enter to join your game.
  • You enter a name to identify yourself, but that is not checked, Tim thinks, for uniqueness within the game. This is a prototype!
  • There is a limit to the number of fish you can take. You can find that out by experience.
  • You are told how many fish you saw each year. You can't catch more than that. And you can use that as an indicator of the total fish population.
  • It costs you some money every year to survive. That, too, you can learn from experience. Tim prefers it this way; after all, the whole point of a commons game is to play it repeatedly. This gives users (students) the chance to make discoveries, and have something they can do better the next time.
  • When you tell the game how many to catch, your catch button disappears. It reappears when the creator of the game presses a button that, of course, doesn't appear until all players have played. (This is how a turn ends for the group and a new turn begins.)
  • By the way: This means that if a player walks away, everyone else is stuck. Again, this is a prototype: we have not implemented some kind of override mechanism.
  • You don't know how much money you get for your fish until the end of the turn. The idea is that all players participate in the fish market. Supply and demand? Yes, at higher levels.
  • If you know what you want your move to be, you can automate the pressing of that button. Similarly, the game creator (the "chair") can automate that button, in which case the next turn begins whenever everyone has finished their turn.
  • The game ends (as you will discover) when either you get to a particular year (2060) or someone goes broke. If the latter, everybody loses. If the former, we look at the fish population. If it is deemed "sufficient," everybody wins; otherwise everybody loses. That is, individuals do not win or lose. Ooooooh. This suggests a group goal: win the game with the most money possible.
  • When you're playing, you get CODAP data on your work only. At the end of a game, you get the same records for all players in a separate table (Historical Fishing Records).

Files

  • fish.html: The html file. Contains the basic structure of the UI, paths to all the javascript code, and a link to fish.initialize().
  • fish.css: Styles the UI.
  • fish.js: The root controller, defines the global fish, includes fish.initialize(). IMPORTANT: this file also runs a timer. Every 700 ms (in 2018-09) it polls the database to find out if anything important has changed, such as the end of a turn or the end of the game.
  • fishModel.js: Defines fish.model, which is primarily responsible for taking the fishing data and updating the fish population
  • fishStrings.js: An attempt at localization. Defines as many strings as possible in (Sept 2018) English and Spanish.
  • fishUI.js:
  • fishUserActions.js: Defines fish.userActions, a singleton with methods that get called when users take specific actions such as joining a game or catching fish.
  • fishCODAPConnector.js: responsible for outputting fishing data to CODAP. This includes updating records when a turn ends (to include unit pricing and revenue) and supplying records from all players to the "historical" table at the end of each game.
  • fishphpConnector.js: this file assembles commands (POST variables) for the php and sends them using the Fetch API.
  • fishGameConfigurations.js: This is a JSON variable that holds the specifications (parameters) for each level of the game. At this writing, they are fish species, arranged alphabetically by difficulty.
  • fishHistoricalData.js: responsible for assembling historical data (the data from all players) for each game.
  • php/fish.php: The main php that receives the commands from fishPhpconnector.js and makes calls — reading and writing — to the mySQL database, using the PDO API.
  • php/establishCredentials.php: Contains the path to the secret, un-checked-in credentials file that has passwords, etc. Defines $user, $pass, etc.
  • php/words.php: A long list of words used to construct the three-word-code for each new game.

mySQL Tables

  • games: one record per game; contains the game code, but also the current "year" of the game and the current population of fish.
  • players: one record per player per game. Keyed to games via the game code. Includes the current bank balance for the player and the year they are in. So when you catch fish, you advance to the next year (e.g., 2020 to 2021). That's how the system knows you have made your move. When all players in the game are at 2021, the "chair" is permitted to advance the game itself. At that point (in fishModel.js) we calculate the total fish caught, the price of the fish, and the new fish population. Then the games table gets updated with that information and the new year, 2021.
  • turns: one record for every turn for every player. This tells how many fish you caught, and what your bank balance was before and after.
Clone this wiki locally