Skip to content

Commit

Permalink
Updated the Conway model and deleted all the meaningless broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
olekscode committed Sep 1, 2024
1 parent e24258d commit f69162d
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 444 deletions.
11 changes: 0 additions & 11 deletions src/Conway-Model-Tests/ConwayCellTest.class.st

This file was deleted.

77 changes: 0 additions & 77 deletions src/Conway-Model-Tests/ConwayModelTest.class.st

This file was deleted.

2 changes: 1 addition & 1 deletion src/Conway-Model-Tests/package.st
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Package { #name : #'Conway-Model-Tests' }
Package { #name : 'Conway-Model-Tests' }
97 changes: 26 additions & 71 deletions src/Conway-Model/ConwayCell.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,110 +2,65 @@
I'm a cell of a Conway's Game of Life.
"
Class {
#name : #ConwayCell,
#superclass : #CMSpatialEntityCell,
#name : 'ConwayCell',
#superclass : 'CMSpatialEntityCell',
#classVars : [
'CurrentId'
],
#category : #'Conway-Model'
#category : 'Conway-Model',
#package : 'Conway-Model'
}

{ #category : #'pov symbols' }
ConwayCell class >> SpatialEntityPOV_alive [

<pov: #alive>
^ Array with: 0.0 with: 0.670004 with: 0.0
]

{ #category : #'pov symbols' }
ConwayCell class >> SpatialEntityPOV_dead [

<pov: #dead>
^ Array with: 0.0 with: 0.0 with: 0.0
]

{ #category : #'pov symbols' }
ConwayCell class >> SpatialEntityPOV_dead_red [

<pov: #dead_red>
^ Array with: 0.5 with: 0.0 with: 0.1
]

{ #category : #accessing }
ConwayCell class >> entityName [

^ 'Cell'
]

{ #category : #'default value' }
ConwayCell class >> state_default [

^ nil
]

{ #category : #init }
{ #category : 'init' }
ConwayCell >> initAllDead [

self state: #dead
]

{ #category : #init }
{ #category : 'init' }
ConwayCell >> initRandomly [

Cormas random < 0.5
self random < 0.5
ifTrue: [ self state: #dead ]
ifFalse: [ self state: #alive ]
]

{ #category : #init }
{ #category : 'init' }
ConwayCell >> initTen [

Cormas random < 0.1
self random < 0.1
ifTrue: [ self state: #dead ]
ifFalse: [ self state: #alive ]
]

{ #category : #init }
{ #category : 'init' }
ConwayCell >> initTenPercentDead [

Cormas random < 0.1
self random < 0.1
ifTrue: [ self state: #dead ]
ifFalse: [ self state: #alive ]
]

{ #category : #probes }
ConwayCell >> isAlive [

self state = #alive ifTrue: [ ^ 1 ].
^ 0
]

{ #category : #control }
{ #category : 'control' }
ConwayCell >> newState [

| tmp1 |
tmp1 := self neighbourhood count: [ :arg1 | arg1 state = #alive ].
self state = #dead & (tmp1 = 3) ifTrue: [ ^ self bufferState: #alive ].
(self state = #alive and: [ tmp1 = 2 or: [ tmp1 = 3 ] ]) ifTrue: [
^ self bufferState: #alive ].
| numberOfAliveNeighbours |
numberOfAliveNeighbours := self neighbourhood count: [ :arg1 | arg1 state = #alive ].

(self state = #dead and: [ numberOfAliveNeighbours = 3 ])
ifTrue: [ ^ self bufferState: #alive ].

(self state = #alive and: [ #(2 3) includes: numberOfAliveNeighbours ])
ifTrue: [ ^ self bufferState: #alive ].

^ self bufferState: #dead
]

{ #category : #pov }
ConwayCell >> pdv [

^ state
]

{ #category : #pov }
{ #category : 'pov' }
ConwayCell >> pov [
<pov>

^ self state
]

{ #category : #pov }
ConwayCell >> pov_red [

self state = #dead ifTrue: [ ^ #dead_red ].
^ self state
^ self state = #alive
ifTrue: [ Color white ]
ifFalse: [ Color black ]
]
Loading

0 comments on commit f69162d

Please sign in to comment.