Skip to content

Latest commit

 

History

47 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cormas Norms

A plugin extending Cormas with norms

"First install Cormas"
Metacello new
    repository: 'github://cormas/cormas';
    baseline: 'Cormas';
    load.

"Then install the norms plugin"
Metacello new
    repository: 'github://cormas/cormas-norms:main';
    baseline: 'CormasNorms';
    load.

Check the examples of norms in package Cormas-Norms-Examples.

Example of adding a norm

Load the RobotForager model by selecting Cormas > Models in this image from the top menu. Open SystemBrowser and navigate into the RobotForager-Model package. Create a new subclass of CMNorm called RFRobotMustNotApproachOtherRobot.

CMNorm << #RFRobotMustNotApproachOtherRobot
	slots: {};
	package: 'RobotForager-Model'

In that class, define an action method specifying the method that will be instrumented:

action

	^ self methodFor: #step in: RFRobot

Specify a condition - in this case, at least one cell in the neighbourhood contains another robot:

condition: agent

	^ agent cell neighbourhood anySatisfy: [ :c | c hasOccupantsOfClass: RFRobot ]

Define a consequence - in this case, robot dies

consequence: agent

	^ agent die

So if a robot comes too close to another robot, it dies.

Open a simulation browser: Cormas > Models in this image, select Robot forager and click on Simulate. Click on the first button in the left toolbar and initialize a model using the initSmallHexagon init method and step control method (it's very important to use step because we have instrumented it.

image

Click on the last button in the left toolbar. Apply the norm.

image

Then run several steps of the simulation. One robot should die as it approaches the other one

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

7 watching

Forks

Releases

Packages

Contributors

Languages