Skip to content

Commit

Permalink
Removed some dead methods and improved allOccupants
Browse files Browse the repository at this point in the history
  • Loading branch information
olekscode committed Dec 8, 2024
1 parent fe398e0 commit 59d4ab6
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 55 deletions.
16 changes: 0 additions & 16 deletions src/Cormas-Core/CMAbstractModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -243,22 +243,6 @@ CMAbstractModel >> allTheSituatedEntities [
^ self allTheEntities select: #isSituated
]

{ #category : 'accessing - entities' }
CMAbstractModel >> allTheSituatedEntities: aClass [
"Purpose: Returns a collection of all the situated instances of aClass (and sub classes) collected by cormasModel. Usefull for abstract classes
Example: (self allTheSituatedEntities: Forager) is returning all the instances of restrained and unrestrained foragers that are situated on the space"

| coll |
coll := OrderedCollection new.
aClass withAllSubclasses
do:
[:cl |
cl isAbstract
ifFalse:
[coll addAll: ((self entitiesOfClass: cl) select: [:e | e isSituated])]].
^coll
]

{ #category : 'control' }
CMAbstractModel >> ask: aCollectionOrClass toDo: aBlock [
"Purpose: To ask a collection of instances or all the instances of a class to execute a method named by aSymbol. In case aCollecOrClass is a class, the entities are ordered according to their id. In case aCollecOrClass is a collection of instances, the order of the collection is kept.
Expand Down
18 changes: 0 additions & 18 deletions src/Cormas-Core/CMSpaceModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,6 @@ CMSpaceModel class >> forModel: aCormasModel [
yourself
]

{ #category : 'accessing' }
CMSpaceModel >> allOccupants [
" Answer a <Collection> of all the located entities"

^ self cormasModel allTheEntities select: #isSituated
]

{ #category : 'accessing' }
CMSpaceModel >> allTheEntities: aClass [
^ self cormasModel allTheEntities: aClass
]

{ #category : 'accessing' }
CMSpaceModel >> allTheSituatedEntities: aClass [

^self cormasModel allTheSituatedEntities: aClass
]

{ #category : 'ESE (regular) - special locations' }
CMSpaceModel >> cellAt: aRowIndex at: aColumnIndex [

Expand Down
15 changes: 2 additions & 13 deletions src/Cormas-Core/CMSpatialEntity.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,7 @@ ex: collResult =
{ #category : 'environment - sensing - agents' }
CMSpatialEntity >> allOccupants [

"Purpose: returns all the entities located there
Return value: <Collection(AgentLocation & ObjectLocation)>"

| collec |
collec := OrderedCollection new.
self theOccupants valuesDo: [ :v | collec addAll: v ].
^ collec
^ self theOccupants values flattened
]

{ #category : 'testing' }
Expand Down Expand Up @@ -261,12 +255,7 @@ Example: self hasOccupantType: #Tree"
{ #category : 'initialize-release' }
CMSpatialEntity >> initOccupants [

self allOccupants do: [:a | a leave] "self spaceModel cormasModel class occupantClasses isEmpty
ifFalse:
[self allOccupants do: [:a | a leave].
theOccupants := Dictionary new.
self spaceModel cormasModel class occupantClasses
do: [:e | theOccupants at: (e name) put: OrderedCollection new]]"
self allOccupants do: [:a | a leave]
]

{ #category : 'initialization' }
Expand Down
7 changes: 0 additions & 7 deletions src/Cormas-Tests/CMSpaceModelTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ CMSpaceModelTest >> spaceModel: anObject [
spaceModel := anObject
]

{ #category : 'tests' }
CMSpaceModelTest >> testAllOccupants [

self assert: self spaceModel allOccupants size equals: 2.

]

{ #category : 'tests' }
CMSpaceModelTest >> testCellAtAt [

Expand Down
2 changes: 1 addition & 1 deletion src/Cormas-Tests/CMSpatialEntityTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ CMSpatialEntityTest >> testAllOccupants [

self
assert: cellWithTwoAgentsOfDifferentClasses allOccupants
equals: { cowJudy . goatBob } asOrderedCollection
equals: { cowJudy . goatBob }
]

{ #category : 'tests' }
Expand Down

0 comments on commit 59d4ab6

Please sign in to comment.