https://github.com/olekscode/miss-abms-firemen
https://github.com/olekscode/miss-abms-firemen
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/olekscode/miss-abms-firemen
- Owner: olekscode
- License: mit
- Created: 2023-09-14T08:20:38.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-18T21:39:34.000Z (almost 3 years ago)
- Last Synced: 2025-08-01T16:42:23.891Z (11 months ago)
- Language: Smalltalk
- Size: 32.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# miss-abms-firemen
```st
Metacello new
repository: 'github://olekscode/miss-abms-firemen:main';
baseline: 'FiremenModel';
load.
```
```st
followTheGroupSlowlyOrWalkRandomly
| allGroupNeigbourPlots plotsOnFire closestPlotOnFire "closestNeighbour" |
allGroupNeigbourPlots := group flatCollect: [ :firefighter | firefighter patch neighbourhood ].
plotsOnFire := allGroupNeigbourPlots select: [ :plot | plot isFire ].
plotsOnFire ifEmpty: [
self randomWalk.
^ self ].
closestPlotOnFire := plotsOnFire anyOne.
plotsOnFire do: [ :plot |
(self patch distanceTo: plot) < (self patch distanceTo: closestPlotOnFire)
ifTrue: [ closestPlotOnFire := plot ] ].
"closestNeighbour := self patch neighbourhood anyOne.
self patch neighbourhood do: [ :plot |
(closestPlotOnFire distanceTo: plot) < (closestPlotOnFire distanceTo: closestNeighbour)
ifTrue: [ closestNeighbour := plot ] ]."
"self moveTo: closestNeighbour."
self moveTowards: closestPlotOnFire.
```