+
Skip to content

Rename isabstract method #803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img alt="CORMAS" src="docs/_media/logo.png" style="width: 25%; height: 25%">
<p align="center"><img alt="CORMAS" src="./img/CormasLogo.png" style="width: 25%; height: 25%">
<h1 align="center">CORMAS</h1>
<p align="center">
<b>CO</b>mmon pool <b>R</b>essources and <b>M</b>ulti-<b>A</b>gent <b>S</b>imulations
Expand Down Expand Up @@ -57,7 +57,7 @@ Metacello new
```

All packages load into the Cormas-* package names:
<p><img alt="Loading..." src="assets/images/loadingCormas.jpg" style="width: 40%; height: 40%">
<p><img alt="Loading..." src="./img/loadingCormas.jpg" style="width: 40%; height: 40%">

## CLI Installation

Expand Down Expand Up @@ -91,10 +91,10 @@ As you use Cormas, you should always save your image (the state of your environm
For that, select `Save` from the Pharo menu.

Alternatively, if you want to save your image in a custom location, select `Save As...`:
<p><img alt="SaveAs" src="assets/images/saveAs.jpg" style="width: 12%; height: 12%">
<p><img alt="SaveAs" src="./img/saveAs.jpg" style="width: 12%; height: 12%">

Then write the name of your choice (e.g.: `CormasPharo.image`):
<p><img alt="Loading..." src="assets/images/saveImage.jpg" style="width: 40%; height: 40%">
<p><img alt="Loading..." src="./img/saveImage.jpg" style="width: 40%; height: 40%">

# Contributors ✨

Expand Down
Binary file added img/CormasLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/loadingCormas.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/saveAs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/saveImage.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 4 additions & 9 deletions src/Cormas-Core/CMAbstractModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,11 @@ CMAbstractModel >> allTheEntities [

{ #category : 'accessing - entities' }
CMAbstractModel >> allTheEntities: aClass [
" Answer a <Collection> of all the instances of aClass (and sub classes) collected by cormasModel.
Usefull for abstract classes

Example: (self allTheEntities: Forager) is returning all the instances of restrained and unrestrained foragers "
"Purpose: This method returns a collection of all instances of aClass and of the instances of all its subclasses"

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

Expand Down Expand Up @@ -616,11 +613,9 @@ Example: self dominance: #groupNumber"

{ #category : 'accessing - entities' }
CMAbstractModel >> entitiesOfClass: aClass [
"Returns a collection of all the instances of aClass"

| getter |

aClass isAbstract ifTrue: [ ^ OrderedCollection new ].
aClass hasSubclasses ifTrue: [ ^ OrderedCollection new ].

getter := self getterForEntityClass: aClass.

Expand Down Expand Up @@ -714,7 +709,7 @@ CMAbstractModel >> initialize [
{ #category : 'accessing' }
CMAbstractModel >> initializeAgentsOfClass: aClass [

(aClass isAbstract not and: [ aClass isLocated ]) ifTrue: [
(aClass hasSubclasses not and: [ aClass isLocated ]) ifTrue: [
(self entitiesOfClass: aClass) do: [ :each | each leave ] ].

self resetEntities: aClass
Expand Down
11 changes: 10 additions & 1 deletion src/Cormas-Core/CMEntity.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,21 @@ CMEntity class >> initializeParameters [
]

{ #category : 'testing' }
CMEntity class >> isAbstract [
CMEntity class >> hasSubclasses [
"Purpose: to test the existence of subclasses"

^self subclasses notEmpty
]

{ #category : 'testing' }
CMEntity class >> isAbstract [
"This method is deprecated as it conflicts with Pharo's standard meaning of 'isAbstract'.
Please use #hasSubclasses instead."

self deprecated: 'Use #hasSubclasses instead' transformWith: '`@receiver isAbstract' -> '`@receiver hasSubclasses'.
^self hasSubclasses
]

{ #category : 'testing' }
CMEntity class >> isLocated [

Expand Down
32 changes: 16 additions & 16 deletions src/Cormas-Core/CMSpaceModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ CMSpaceModel class >> forModel: aCormasModel [
yourself
]

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

^ cormasModel cells at: ((aRowIndex - 1) * numberOfColumns + aColumnIndex)
Expand All @@ -77,7 +77,7 @@ CMSpaceModel >> cells [
^ cormasModel cells
]

{ #category : 'ESE (regular) - special locations' }
{ #category : 'accessing cell' }
CMSpaceModel >> cellsBetweenColumn: colNumber1 andColumn: colNumber2 [
"Return the cells between the colNumber1 and the colNumber2 of the spatial grid.
colNumber1 <Integer> lineNumber = Positive Integer
Expand All @@ -92,7 +92,7 @@ colNumber2 <Integer> colNumber = Positive Integer"
^ cells
]

{ #category : 'ESE (regular) - special locations' }
{ #category : 'accessing cell' }
CMSpaceModel >> cellsBetweenRow: lineNumber1 andRow: lineNumber2 [
"Return the cells between the lineNumber1 and the lineNumber2 of the spatial grid.
lineNumber1 <Integer> lineNumber = Positive Integer
Expand All @@ -107,7 +107,7 @@ lineNumber2 <Integer> colNumber = Positive Integer"
^ cells
]

{ #category : 'ESE (regular) - special locations' }
{ #category : 'accessing cell' }
CMSpaceModel >> cellsBetweenRow: aRowNumber1 andRow: aRowNumber2 column: aColumnNumber1 andColumn: aColumnNumber2 [

| topRowNumber bottomRowNumber leftColumnNumber rightColumnNumber result |
Expand All @@ -124,7 +124,7 @@ CMSpaceModel >> cellsBetweenRow: aRowNumber1 andRow: aRowNumber2 column: aColumn
select: [ :cell | result includes: cell ]
]

{ #category : 'ESE (regular) - special locations' }
{ #category : 'accessing cell' }
CMSpaceModel >> cellsInRectangleFrom: cell1 to: cell2 [
"Return the cells between the lineNumber and the colNumber of the spatial grid. The Cells are ordered from cell1 to cell2.
cell1 <SpatialEntityElement>
Expand Down Expand Up @@ -160,21 +160,21 @@ cell2 <SpatialEntityElement> "
^cells
]

{ #category : 'ESE (regular) - special locations' }
{ #category : 'accessing cell' }
CMSpaceModel >> cellsOfColumn: colNumber [
"Return the cells in the colNumber of the spatial grid.
colNumber <Integer> colNumber = Positive Integer"

^ cormasModel cells select: [ :cell | cell columnNumber = colNumber ]
]

{ #category : 'ESE (regular) - special locations' }
{ #category : 'accessing cell' }
CMSpaceModel >> cellsOfRow: aRowNumber [

^ cormasModel cells select: [ :cell | cell rowNumber = aRowNumber ]
]

{ #category : 'ESE (regular) - special locations' }
{ #category : 'accessing cell' }
CMSpaceModel >> centralCell [
(numberOfRows even or: [ numberOfColumns even ])
ifTrue: [ ^ self error: 'Grid dimensions is not odd' ].
Expand Down Expand Up @@ -250,7 +250,7 @@ The aggregates will occupy the whole grid.

]

{ #category : 'ESE initialize-release' }
{ #category : 'initialization' }
CMSpaceModel >> createCells [

1 to: self gridSize do: [ :i |
Expand Down Expand Up @@ -393,7 +393,7 @@ CMSpaceModel >> initialize [
isClosedEnvironment := true
]

{ #category : 'ESE initialize-release' }
{ #category : 'initialization' }
CMSpaceModel >> initializeRegularNumberOfRows: aNumberOfRows numberOfColumns: aNumberOfColumns neighbourhood: aNumber closed: aBoolean [
" Private - Create a grid of regular cells."

Expand Down Expand Up @@ -426,12 +426,12 @@ CMSpaceModel >> isIrregular [
^gridCellShape = #irregular
]

{ #category : 'ESE (regular) - special locations' }
{ #category : 'accessing cell' }
CMSpaceModel >> lowerLeftCell [
^ cormasModel cells at: numberOfColumns * (numberOfRows - 1) + 1
]

{ #category : 'ESE (regular) - special locations' }
{ #category : 'accessing cell' }
CMSpaceModel >> lowerRightCell [
^ cormasModel cells at: numberOfColumns * numberOfRows
]
Expand Down Expand Up @@ -488,7 +488,7 @@ CMSpaceModel >> numberOfNeighbours [
^ self neighbourhoodConfiguration numberOfNeighbours
]

{ #category : 'ESE initialize-release' }
{ #category : 'initialization' }
CMSpaceModel >> numberOfNeighbours: anIntegerOrSymbol [
" Create the grid.
Set the receiver's neighbourhood configuration to contain anIntegerOrSymbol neighbours "
Expand Down Expand Up @@ -532,19 +532,19 @@ CMSpaceModel >> printOn: aStream [

]

{ #category : 'ESE (regular) - special locations' }
{ #category : 'accessing cell' }
CMSpaceModel >> randomCell [
"Return a spatialEntityElement (aCell) picked randomly from the spatial grid."

^ self selectRandomlyFrom: cormasModel cells
]

{ #category : 'ESE (regular) - special locations' }
{ #category : 'accessing cell' }
CMSpaceModel >> upperLeftCell [
^ cormasModel cells first
]

{ #category : 'ESE (regular) - special locations' }
{ #category : 'accessing cell' }
CMSpaceModel >> upperRightCell [
^ cormasModel cells at: numberOfColumns
]
Expand Down

This file was deleted.

6 changes: 6 additions & 0 deletions src/Cormas-Tests/CMEntityTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ CMEntityTest >> testColorOfNumber [
self assert: (CMEntity colorOfNumber: 65) equals: Color purple
]

{ #category : 'tests' }
CMEntityTest >> testCormasEntityHasSubclasses [
self assert: CMEntity hasSubclasses
]

{ #category : 'tests' }
CMEntityTest >> testCormasEntityIsAbstract [
"This test is deprecated, use testCormasEntityHasSubclasses instead"
self assert: CMEntity isAbstract
]

Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载