diff --git a/src/Cormas-Core/CMAbstractModel.class.st b/src/Cormas-Core/CMAbstractModel.class.st index 90d7a691..2c8e4ce4 100644 --- a/src/Cormas-Core/CMAbstractModel.class.st +++ b/src/Cormas-Core/CMAbstractModel.class.st @@ -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. diff --git a/src/Cormas-Core/CMSpaceModel.class.st b/src/Cormas-Core/CMSpaceModel.class.st index dde173a7..eef076bb 100644 --- a/src/Cormas-Core/CMSpaceModel.class.st +++ b/src/Cormas-Core/CMSpaceModel.class.st @@ -65,24 +65,6 @@ CMSpaceModel class >> forModel: aCormasModel [ yourself ] -{ #category : 'accessing' } -CMSpaceModel >> allOccupants [ - " Answer a 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 [ diff --git a/src/Cormas-Core/CMSpatialEntity.class.st b/src/Cormas-Core/CMSpatialEntity.class.st index 6a79507a..58d6aab3 100644 --- a/src/Cormas-Core/CMSpatialEntity.class.st +++ b/src/Cormas-Core/CMSpatialEntity.class.st @@ -126,13 +126,7 @@ ex: collResult = { #category : 'environment - sensing - agents' } CMSpatialEntity >> allOccupants [ - "Purpose: returns all the entities located there -Return value: " - - | collec | - collec := OrderedCollection new. - self theOccupants valuesDo: [ :v | collec addAll: v ]. - ^ collec + ^ self theOccupants values flattened ] { #category : 'testing' } @@ -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' } diff --git a/src/Cormas-Tests/CMSpaceModelTest.class.st b/src/Cormas-Tests/CMSpaceModelTest.class.st index a78c7b35..c9c01861 100644 --- a/src/Cormas-Tests/CMSpaceModelTest.class.st +++ b/src/Cormas-Tests/CMSpaceModelTest.class.st @@ -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 [ diff --git a/src/Cormas-Tests/CMSpatialEntityTest.class.st b/src/Cormas-Tests/CMSpatialEntityTest.class.st index 1ef3ba76..510df3cc 100644 --- a/src/Cormas-Tests/CMSpatialEntityTest.class.st +++ b/src/Cormas-Tests/CMSpatialEntityTest.class.st @@ -48,7 +48,7 @@ CMSpatialEntityTest >> testAllOccupants [ self assert: cellWithTwoAgentsOfDifferentClasses allOccupants - equals: { cowJudy . goatBob } asOrderedCollection + equals: { cowJudy . goatBob } ] { #category : 'tests' }