Cormas extension adding support for serious games by implementation of serious game: Planet C, play again?
Metacello new
baseline: 'CormasGaming';
repository: 'github://cormas/cormas-gaming:main';
load
Planet C is a serious game implemented in Pharo using the Cormas agent-based modeling framework. It includes a web interface powered by Zinc HTTP Components, allowing players to interact via browser or mobile in real time.
The whole project is still in progress and in implementing and testing phase.
Manages HTTP logic and route dispatching via Zinc.
start2
Starts the Zinc server and maps the following routes:/home
,/game
,/game/harvester
,/game/parkmanager
,/click
,/submit
,/style.css
clientIPAddressFrom:
Extracts the user's IP address.homePageHtml
,roleSelectionPageHtml
,harvesterPageHtml
,parkManagerPageHtml
HTML page templates returned for different routes.gameCss
Returns CSS code used by all frontend pages.
Core logic of the game — handles state, players, rounds, and events.
players
—Dictionary
mapping IP addresses to rolespendingEvents
—OrderedCollection
of player eventssubmittedThisRound
—Set
of IPs that submitted during current roundstate
— instance ofCMState
, holding the round/timer info
assignRole:to:
— Assigns a role (e.g., 'harvester') to a player's IProleFor:
— Returns the role for a given IP
markSubmitted:
— Adds a player's IP to the submitted sethasPlayerSubmitted:
— Checks if IP has already submittedallPlayersSubmitted
— Checks if all active players submittedresetSubmittedPlayers
— Clears submitted set for new round
startNextRound
— Advances to the next round and resets submission stateisGameOver
— Returns true if round limit exceededrestartGame
— Resets all game state to initial
addEvent:
— Adds a newCMClickEvent
to the queueprocessPendingEvents
— Iterates through events and processes them
resetTimer
— Sets timer to 60 secondsdecrementTimer
— Decreases timer by 1isTimerExpired
— Checks if timer reached 0
isPlayerActive:
— Checks if a player (by IP) is currently activecurrentStatus
— Returns string with current round, timer, and number of players
Holds shared state for the current simulation session.
round
— current round number (Integer
)activePlayers
—Set
of IP addressestimer
— countdown value (Integer
, optional)
Encapsulates a player's action during a turn (e.g., selected cells).
ip
— Player’s IP addressrole
—'harvester'
or'parkmanager'
cells
— List of selected grid coordinates
- Created via the
/click
route - Stored in
CMGame >> pendingEvents
- Later processed in
processPendingEvents
- Pharo – Pure object-oriented language and environment
- Cormas – Multi-agent simulation framework
- Zinc HTTP Components – Lightweight HTTP server and dispatcher
- NeoJSON – JSON parsing and generation
- HTML / CSS / JavaScript – Frontend interface
-
Open the Pharo image with all project classes loaded.
-
In a workspace, run:
CMGameHttpServer new start.