Skip to content

Commit

Permalink
Updated the PoV
Browse files Browse the repository at this point in the history
  • Loading branch information
olekscode committed Sep 5, 2024
1 parent 2a5265a commit c1c7154
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 23 deletions.
27 changes: 17 additions & 10 deletions src/ECEC-Model/ECECForager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Class {
#classInstVars : [
'catabolicRate',
'fertilityThreshold',
'harvestRate'
'harvestRate',
'initialEnergy'
],
#category : 'ECEC-Model',
#package : 'ECEC-Model'
Expand Down Expand Up @@ -51,12 +52,25 @@ ECECForager class >> harvestRate: aNumber [
harvestRate := aNumber
]

{ #category : 'accessing' }
ECECForager class >> initialEnergy [

^ initialEnergy
]

{ #category : 'accessing' }
ECECForager class >> initialEnergy: aNumber [

initialEnergy := aNumber
]

{ #category : 'initialization' }
ECECForager class >> initializeParameters [

super initializeParameters.
fertilityThreshold := 100.
catabolicRate := 2.
initialEnergy := 50.
harvestRate := nil.
]

Expand Down Expand Up @@ -95,7 +109,7 @@ ECECForager >> energy: anObject [
ECECForager >> initialize [

super initialize.
energy := 50.
energy := self class initialEnergy.
]

{ #category : 'printing' }
Expand Down Expand Up @@ -131,14 +145,7 @@ ECECForager >> move [
ECECForager >> pov [

<pov>
self subclassResponsibility
]

{ #category : 'pov' }
ECECForager >> povEnergy [

<pov>
self subclassResponsibility
^ CMPointOfView size: self sizeOfPOV
]

{ #category : 'biology' }
Expand Down
12 changes: 8 additions & 4 deletions src/ECEC-Model/ECECRestrainedForager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ ECECRestrainedForager class >> initializeParameters [
ECECRestrainedForager >> pov [

<pov>
^ Color blue
^ super pov
color: Color blue;
yourself
]

{ #category : 'pov' }
ECECRestrainedForager >> povEnergy [

<pov>
^ self
povAttribute: #energy
^ super pov
color: (self
colorAttribute: #energy
min: 0
max: 180
color: Color blue
color: Color blue);
yourself
]
12 changes: 8 additions & 4 deletions src/ECEC-Model/ECECUnrestrainedForager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ ECECUnrestrainedForager class >> initializeParameters [
ECECUnrestrainedForager >> pov [

<pov>
^ Color red
^ super pov
color: Color red;
yourself
]

{ #category : 'pov' }
ECECUnrestrainedForager >> povEnergy [

<pov>
^ self
povAttribute: #energy
^ super pov
color: (self
colorAttribute: #energy
min: 0
max: 180
color: Color red
color: Color red);
yourself
]
15 changes: 10 additions & 5 deletions src/ECEC-Model/ECECVegetationUnit.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ ECECVegetationUnit >> biomass: anObject [
biomass := anObject
]

{ #category : 'as yet unclassified' }
ECECVegetationUnit >> hello [
^ 'world'
]

{ #category : 'initialization' }
ECECVegetationUnit >> initialize [

Expand Down Expand Up @@ -102,19 +107,19 @@ ECECVegetationUnit >> logisticGrowth [
ECECVegetationUnit >> povBiomass [

<pov>
^ self
povAttribute: #biomass
^ CMPointOfView color: (self
colorAttribute: #biomass
min: 0
max: self class k
color: Color green
color: Color green)
]

{ #category : 'pov' }
ECECVegetationUnit >> povBiomassForager [

<pov>
^ self biomass < ECECForager catabolicRate
ifTrue: [ Color white ]
ifTrue: [ CMPointOfView color: Color white ]
ifFalse: [ self povBiomass ]
]

Expand All @@ -128,7 +133,7 @@ ECECVegetationUnit >> povForagersVision [
(self neighbourhood anySatisfy: [ :each | each hasOccupantsOfClass: ECECForager ])
ifTrue: [ ^ self povBiomassForager ].

^ Color black
^ CMPointOfView color: Color black
]

{ #category : 'stepping' }
Expand Down

0 comments on commit c1c7154

Please sign in to comment.