Skip to content

Examples

leonsillano edited this page Feb 5, 2024 · 3 revisions

Some examples are provided in this code. Here you will find a review of these.

To launch these examples:

  • Launch the middleware & Gama Server (see Launching)
  • Launch the simulation by loading the good model.
  • Create one or several player by going to localhost:app_port/player
  • Add these players using the monitor webpage

Now you can play to the simulation.

Every examples provided consist of two parts: the player side and the gama side. The player side is an application frontend (html file or html/css/js) The Gama side is always a GAML model. This is the model you will have to load if you want to launch this example.

If you want to create you own game, you would have to handle these two parts.

Simple example

This code contains 2 files:

  • simple_example.html, in views/player/simple_example.html, that contains the player side of the game.
  • simple_example.gaml, in models/simple_example.gaml, that contains the GAML file (Gama side) of the project

The principle is simple: when launching and adding to the simulation a player, it creates a dot that displace on the map. On the player side, you will see the dot displacing.

Runny Run Run

This code contains 4 files:

  • runny_run_run.html, in views/player/simple_example.html, that contains the html player side of the game.
  • runny_run_run.js, in views/player/simple_example.js, that contains the js player side of the game.
  • runny_run_run.css, in views/player/simple_example.css, that contains the css player side of the game.
  • simple_example.gaml, in models/simple_example.gaml, that contains the GAML file (Gama side) of the project

This example is more complicated and interesting. Every player will monitor a group of soldier of the game Runny Run Run. Every player will have to choose the strategy and the attack rate of their soldiers.

  • The startegy is the method taken to calculate the direction of every soldiers of the group of the player.
  • The attack rate defines how you want to attack of defend. If it's 1, it means that you don't care of your predators and you want to go towards your preys. If it's 0, it means that you will be focused on you predator and you want to escape from them.

Caution

In order to have a relevant game, you should be 3 players or more (no more than 5). When a player connects, he has to wait to be added to the simulation before setting his name, strategy or attack range.

Gama template unity

If you want to create a VR game, you can see a good template that shows how you can create this. You will find this project here: simple.template.unity