From VisualWorks® NonCommercial, 7.3 of December 3, 2004 on March 6, 2006 at 7:07:33 am
CormasNS.Kernel.CormasModel entities - new
setRandomlyLocatedObjects: aClass n: aNumber initMethod: aSymbol constrainedBy: aBlock
"Return a collection of aNumber of entities of aClass for wich the init method 'aSymbol' with a set of arguments 'aCollec' has been send.
The new objects are randomly located on the grid.
ex: self setRandomlyLocatedObjects: Ore n: 10 initMethod: #init constrainedBy: [:c | c isLand] "
^self setRandomlyLocatedObjects: aClass n: aNumber initMethod: aSymbol arguments: #() constrainedBy: aBlock
CormasNS.Kernel.CormasModel entities - new
setRandomlyLocatedObjects: aClass n: aNumber initMethod: aSymbol arguments: aCollec constrainedBy: aBlock
"Return a collection of aNumber of entities of aClass for wich the init method 'aSymbol' with a set of arguments 'aCollec' has been send.
The new objects are randomly located on the grid.
ex: self setRandomlyLocatedObjects: Ore n: 10 initMethod: #initQuantity: arguments: #(50) constrainedBy: [:c | c isLand] "
| a targetCell |
aNumber timesRepeat:
[targetCell := self randomCellConstrainedBy: aBlock.
targetCell isNil
ifTrue:
[Dialog warn: 'No available cell for the constraint. The simulation will stop'.
self halt].
a := self newEntity: aClass.
a perform: aSymbol withArguments: aCollec.
a isMovedTo: targetCell].
^self theEntities: aClass
CormasNS.Kernel.CormasModel entities - new
setRandomlyLocatedObjects: aClass n: aNumber constrainedBy: aBlock
"Return a collection of aNumber of entities of aClass for wich the init method 'aSymbol' with a set of arguments 'aCollec' has been send.
The new objects are randomly located on the grid.
ex: self setRandomlyLocatedObjects: Ore n: 10 constrainedBy: [:c | c isLand] "
^self setRandomlyLocatedObjects: aClass n: aNumber initMethod: #init arguments: #() constrainedBy: aBlock
CormasNS.Kernel.CormasModel entities - new
setRandomlyLocatedAgents: aClass n: aNumber initMethod: aSymbol constraintBy: aBlock
"Return a collection of aNumber of entities of aClass for wich the init method 'aSymbol' has been send.
The new agents are randomly located on the grid on cells that verify the constraint.
ex: self setRandomlyLocatedAgents: Predator n: 10 initMethod: #initAge constrainedBy: [:c | c noOccupant and: [c energy > 1]]"
^self setRandomlyLocatedAgents: aClass n: aNumber initMethod: aSymbol arguments: #() constrainedBy: aBlock
CormasNS.Kernel.CormasModel entities - new
setRandomlyLocatedAgents: aClass n: aNumber initMethod: aSymbol arguments: aCollec constrainedBy: aBlock
"Return a collection of aNumber of entities of aClass for wich the init method 'aSymbol' with a set of arguments 'aCollec' has been send.
The new agents are randomly located on the free cells of the grid.
ex: self setRandomlyLocatedAgents: Predator n: 10 initMethod: #initAge constrainedBy: [:cell | cell energy > 1] "
| a targetCell |
aNumber timesRepeat:
[targetCell := self randomCellConstrainedBy: aBlock.
targetCell isNil
ifTrue:
[Dialog warn: 'No available cell for the constraint. The simulation will stop'.
self halt].
a := self newEntity: aClass.
a perform: aSymbol withArguments: aCollec.
a moveTo: targetCell].
^self theEntities: aClass
CormasNS.Kernel.CormasModel entities - new
setRandomlyLocatedAgents: aClass n: aNumber constrainedBy: aBlock
"Return a collection of aNumber of entities of aClass for wich the init method 'aSymbol' has been send.
The new agents are randomly located on the grid on cells that verify the constraint.
ex: self setRandomlyLocatedAgents: Predator n: 10 constrainedBy: [:c | c noOccupant and: [c energy > 1]]"
^self setRandomlyLocatedAgents: aClass n: aNumber initMethod: #init arguments: #() constrainedBy: aBlock