https://github.com/sdiehl/agents-experiment
Toy language
https://github.com/sdiehl/agents-experiment
Last synced: 7 months ago
JSON representation
Toy language
- Host: GitHub
- URL: https://github.com/sdiehl/agents-experiment
- Owner: sdiehl
- Created: 2014-06-08T22:03:05.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-06-12T18:31:22.000Z (over 11 years ago)
- Last Synced: 2025-01-21T21:47:27.616Z (9 months ago)
- Language: Haskell
- Homepage:
- Size: 152 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
agents
======Toy language to simulate beer consumption, derived after too many beers with Stefan.
Usage
-----```bash
$ cabal sandbox init
$ cabal install --only-dependencies
$ cabal configure
``````bash
$ cabal run
Linking dist/build/agents/agents ...
_
| |
__ _ __ _ ___ _ __ | |_ ___
/ _` |/ _` |/ _ \ '_ \| __/ __|
| (_| | (_| | __/ | | | |_\__ \
\__,_|\__, |\___|_| |_|\__|___/
__/ | Version 0.0
|___/ Type :help for helpAgents> :help
:run Run the loaded program
:reload Run the active file
:show Dump the AST of active file
:load Load a program from fileAgents> :load simple.world
Loading simple.worldAgents> :run
[Tick] Start 1
[Entity] station
[Cond] Gte (Var "timer") (Const 10) ==> Fl
[Action] INC: timer 1
[Entity] tourist
[Action] DEC: health 1
[Cond] Eq (Var "health") (Const 0) ==> Fl
[Cond] And (Lt (Var "health") (Const 5)) (Not (Var "thirsty")) ==> Tr
[Action] SET Tag "thirsty"
[Cond] And (Gt (Var "health") (Const 5)) (Var "thirsty") ==> Fl
[Cond] Var "beer" ==> Fl
[Tick] Finished 1
...Agents> :show
[ ObjectDecl
Object
{ _name = "restaurant"
, _measure = [ Measure { _mname = "beer" , _mval = 100 } ]
, _tags = fromList []
, _actuators = []
}
, ObjectDecl
Object
{ _name = "station"
, _measure = [ Measure { _mname = "timer" , _mval = 1 } ]
, _tags = fromList []
, _actuators =
[ Actuator
(If (Gte (Var "timer") (Const 10)))
[ Create "tourist" , Zero "timer" ]
, Actuator Always [ Inc "timer" 1 ]
]
}
...Agents> ^D
Goodbye.
```