diff --git a/src/ComputationalArt/CACellMorph.class.st b/src/ComputationalArt/CACellMorph.class.st index 4408679..8b4e4ff 100644 --- a/src/ComputationalArt/CACellMorph.class.st +++ b/src/ComputationalArt/CACellMorph.class.st @@ -47,23 +47,23 @@ CACellMorph >> handlesMouseOver: anEvent [ { #category : #handling, - #'squeak_changestamp' : 'KoPa 7/12/2024 18:38' + #'squeak_changestamp' : 'KoPa 7/12/2024 20:29' } CACellMorph >> mouseDown: anEvent [ anEvent redButtonPressed - ifTrue: [game putCellAtRow: row andCol: col] - ifFalse: [game toggleBrushActive]. + ifTrue: [game putCellAtRow: row andCol: col.] + ifFalse: [game toggleBrushActive.]. ] { #category : #handling, - #'squeak_changestamp' : 'KoPa 7/12/2024 18:39' + #'squeak_changestamp' : 'KoPa 7/12/2024 20:29' } CACellMorph >> mouseEnter: anEvent [ game brushActive - ifTrue: [game putCellAtRow: row andCol: col]. + ifTrue: [game putCellAtRow: row andCol: col.]. ] diff --git a/src/ComputationalArt/CADisplay.class.st b/src/ComputationalArt/CADisplay.class.st index 7c42593..f7cfa6e 100644 --- a/src/ComputationalArt/CADisplay.class.st +++ b/src/ComputationalArt/CADisplay.class.st @@ -114,7 +114,7 @@ CADisplay >> initialize [ { #category : #accessing, - #'squeak_changestamp' : 'KoPa 7/12/2024 18:58' + #'squeak_changestamp' : 'KoPa 7/12/2024 20:30' } CADisplay >> showGrid: aGrid [ @@ -130,8 +130,8 @@ CADisplay >> showGrid: aGrid [ self wipeCells. - 1 to: rows do: [ :rowIndex | - 1 to: cols do: [ :colIndex | + 1 to: rows do: [:rowIndex | + 1 to: cols do: [:colIndex | cell := aGrid getCellAtRow: rowIndex andCol: colIndex. cellMorph := Morph new extent: size @ size; @@ -140,12 +140,12 @@ CADisplay >> showGrid: aGrid [ borderWidth: border; position: (((colIndex-1) * (size+gap)) @ ((rowIndex-1) * (size+gap)) + origin). viewMorph addMorph: cellMorph. - cells add: cellMorph. ]]. + cells add: cellMorph.]]. ] { #category : #functional, - #'squeak_changestamp' : 'KoPa 7/12/2024 18:58' + #'squeak_changestamp' : 'KoPa 7/12/2024 20:31' } CADisplay >> step [ @@ -163,29 +163,29 @@ CADisplay >> step [ cells isEmpty ifTrue: [ (1 to: rows) - do: [ :rowIndex | (1 to: cols) - do: [ :colIndex | + do: [:rowIndex | + (1 to: cols) + do: [:colIndex | cell := aGrid getCellAtRow: rowIndex andCol: colIndex. cellMorph := CACellMorph new extent: size @ size; borderColor: Color gray; - - color: (blockLookup colorAt: cell); + color: (blockLookup colorAt: cell); borderWidth: border; position: colIndex - 1 * (size + gap) @ (rowIndex - 1 * (size + gap)) + origin; - row: rowIndex; - col: colIndex; - game: attachedGame. + row: rowIndex; + col: colIndex; + game: attachedGame. viewMorph addMorph: cellMorph. - cells add: cellMorph. ]]]. + cells add: cellMorph.]]]. cells isEmpty - ifFalse: [ - (1 to: rows) - do: [ :rowIndex | (1 to: cols) - do: [ :colIndex | + ifFalse: [(1 to: rows) + do: [:rowIndex | + (1 to: cols) + do: [:colIndex | cell := aGrid getCellAtRow: rowIndex andCol: colIndex. cellMorph := cells at: rowIndex - 1 * rows + colIndex. cellMorph - color: (blockLookup colorAt: cell). ]]]. + color: (blockLookup colorAt: cell).]]]. ] { @@ -199,12 +199,12 @@ CADisplay >> viewMorph [ { #category : #functional, - #'squeak_changestamp' : 'KoPa 7/12/2024 18:11' + #'squeak_changestamp' : 'KoPa 7/12/2024 20:32' } CADisplay >> wipeCells [ - cells do: [ :eachMorph | - eachMorph delete. ]. + cells do: [:eachMorph | + eachMorph delete.]. cells removeAll. ] diff --git a/src/ComputationalArt/CAGame.class.st b/src/ComputationalArt/CAGame.class.st index fa068df..39effb9 100644 --- a/src/ComputationalArt/CAGame.class.st +++ b/src/ComputationalArt/CAGame.class.st @@ -115,16 +115,9 @@ CAGame >> frameDelay: aSecondCount [ ] -{ - #category : #'initialize-release', - #'squeak_changestamp' : 'KoPa 7/12/2024 19:27' -} -CAGame >> initialize [ -] - { #category : #functional, - #'squeak_changestamp' : 'KoPa 7/12/2024 19:13' + #'squeak_changestamp' : 'KoPa 7/12/2024 20:33' } CAGame >> putCellAtRow: aRow andCol: aCol [ @@ -132,19 +125,19 @@ CAGame >> putCellAtRow: aRow andCol: aCol [ originRow := aRow - brushSize. originCol := aCol - brushSize. 1 to: brushSize * 2 - 1 - do: [ :rowIndex | 1 - to: brushSize * 2 - 1 - do: [ :colIndex | + do: [:rowIndex | + 1 to: brushSize * 2 - 1 + do: [:colIndex | placeRow := originRow + rowIndex. placeCol := originCol + colIndex. (placeRow > 0 - and: placeRow < 101 - and: placeCol > 0 - and: placeCol < 101) - ifTrue: [ grid + and: placeRow < 101 + and: placeCol > 0 + and: placeCol < 101) + ifTrue: [grid putCell: activeCellType atRow: placeRow - andCol: placeCol. ]]]. + andCol: placeCol.]]]. screen step. ] @@ -159,17 +152,17 @@ CAGame >> setActiveCellTypeTo: aType [ { #category : #functional, - #'squeak_changestamp' : 'KoPa 7/12/2024 19:14' + #'squeak_changestamp' : 'KoPa 7/12/2024 20:33' } CAGame >> skipAhead: aStepCount [ - aStepCount timesRepeat: [ ruler applyRules: ruleSet to: grid. ]. + aStepCount timesRepeat: [ruler applyRules: ruleSet to: grid.]. screen step. ] { #category : #'initialize-release', - #'squeak_changestamp' : 'KoPa 7/12/2024 19:27' + #'squeak_changestamp' : 'KoPa 7/12/2024 20:36' } CAGame >> start [ @@ -195,13 +188,12 @@ CAGame >> start [ maxIterations := 100. iterationCount := 0. gameloop := [[iterationCount < maxIterations] - whileTrue: [(Delay forSeconds: frameDelay) wait. - isRunning - ifTrue: [ruler applyRules: ruleSet to: grid. + whileTrue: [ + (Delay forSeconds: frameDelay) wait. + isRunning ifTrue: [ + ruler applyRules: ruleSet to: grid. screen step. - iterationCount := iterationCount + 1]]. - Transcript show: 'Game loop terminated after ' , maxIterations printString , ' iterations.'; - cr] fork + iterationCount := iterationCount + 1.]]] fork. ] { diff --git a/src/ComputationalArt/CAGrid.class.st b/src/ComputationalArt/CAGrid.class.st index a87b118..c5d75e2 100644 --- a/src/ComputationalArt/CAGrid.class.st +++ b/src/ComputationalArt/CAGrid.class.st @@ -11,7 +11,7 @@ Class { { #category : #functional, - #'squeak_changestamp' : 'KoPa 7/12/2024 19:18' + #'squeak_changestamp' : 'KoPa 7/12/2024 19:33' } CAGrid class >> clear: aGrid [ @@ -20,72 +20,48 @@ CAGrid class >> clear: aGrid [ numRows := aGrid numRows. col := #(0 0). 1 to: numRows - do: [:rowIndex | 1 + do: [ :rowIndex | 1 to: numCols - do: [:colIndex | aGrid + do: [ :colIndex | aGrid putCell: col atRandom atRow: rowIndex - andCol: colIndex]] + andCol: colIndex. ]]. ] { #category : #functional, - #'squeak_changestamp' : 'Sars 6/16/2024 20:45' + #'squeak_changestamp' : 'KoPa 7/12/2024 19:33' } -CAGrid class >> fill: aGrid [ - | rand numCols numRows | - numCols := aGrid numCols. - numRows := aGrid numRows. - rand := #(1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 7 7 6 6 6 5 5 5 5 5 9 8 8). - 1 - to: numRows - do: [:rowIndex | 1 - to: numCols - do: [:colIndex | rowIndex < 45 - ifTrue: [aGrid - putCell: rand atRandom - atRow: rowIndex - andCol: colIndex] - ifFalse: [aGrid - putCell: 0 - atRow: rowIndex - andCol: colIndex]]] -] +CAGrid class >> fillStone: aGrid [ -{ - #category : #functional, - #'squeak_changestamp' : 'HaMa 6/20/2024 11:14' -} -CAGrid class >> fillStone: aGrid [ | numCols numRows | numCols := aGrid numCols. numRows := aGrid numRows. - 1 - to: numRows - do: [:rowIndex | 1 + 1 to: numRows + do: [ :rowIndex | 1 to: numCols - do: [:colIndex | aGrid + do: [ :colIndex | aGrid putCell: CABlocks stone atRow: rowIndex - andCol: colIndex]] + andCol: colIndex. ]]. ] { #category : #functional, - #'squeak_changestamp' : 'HaMa 6/20/2024 11:14' + #'squeak_changestamp' : 'KoPa 7/12/2024 19:33' } -CAGrid class >> fillTNT: aGrid [ +CAGrid class >> fillTNT: aGrid [ + | numCols numRows | numCols := aGrid numCols. numRows := aGrid numRows. - 1 - to: numRows - do: [:rowIndex | 1 + 1 to: numRows + do: [ :rowIndex | 1 to: numCols - do: [:colIndex | aGrid + do: [ :colIndex | aGrid putCell: CABlocks tnt atRow: rowIndex - andCol: colIndex]] + andCol: colIndex. ]]. ] { diff --git a/src/ComputationalArtTests/CABlocksTest.class.st b/src/ComputationalArtTests/CABlocksTest.class.st index 4ce498a..d2c7889 100644 --- a/src/ComputationalArtTests/CABlocksTest.class.st +++ b/src/ComputationalArtTests/CABlocksTest.class.st @@ -8,34 +8,38 @@ Class { } { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 10:28' + #category : #'initialize-release', + #'squeak_changestamp' : 'KoPa 7/12/2024 20:00' } CABlocksTest >> expectedFailures [ - ^ {#testWrongIndexFail} + + ^ {#testWrongIndexFail}. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 10:07' + #category : #'initialize-release', + #'squeak_changestamp' : 'KoPa 7/12/2024 19:57' } CABlocksTest >> setUp [ + blocks := CABlocks new. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 10:07' + #category : #functional, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:57' } CABlocksTest >> tearDown [ + blocks := nil. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'KoPa 7/12/2024 18:03' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:58' } CABlocksTest >> testColors [ + self assert: Color white equals: (blocks colorAt: CABlocks air). self assert: Color blue equals: (blocks colorAt: CABlocks water). self assert: Color yellow equals: (blocks colorAt: CABlocks sand). @@ -49,10 +53,11 @@ CABlocksTest >> testColors [ ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 10:11' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:58' } CABlocksTest >> testIndexMethods [ + self assert: 0 equals: CABlocks air. self assert: 1 equals: CABlocks water. self assert: 2 equals: CABlocks sand. @@ -66,10 +71,11 @@ CABlocksTest >> testIndexMethods [ ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'KoPa 7/12/2024 18:03' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:58' } CABlocksTest >> testNames [ + self assert: 'air' equals: (blocks nameAt: CABlocks air). self assert: 'water' equals: (blocks nameAt: CABlocks water). self assert: 'sand' equals: (blocks nameAt: CABlocks sand). @@ -83,9 +89,10 @@ CABlocksTest >> testNames [ ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'KoPa 7/12/2024 18:03' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:58' } CABlocksTest >> testWrongIndexFail [ + self assert: 'wall' equals: (blocks nameAt: -1). ] diff --git a/src/ComputationalArtTests/CAGridTest.class.st b/src/ComputationalArtTests/CAGridTest.class.st index 78997a0..22d818b 100644 --- a/src/ComputationalArtTests/CAGridTest.class.st +++ b/src/ComputationalArtTests/CAGridTest.class.st @@ -8,115 +8,145 @@ Class { } { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 10:52' + #category : #'initialize-release', + #'squeak_changestamp' : 'KoPa 7/12/2024 20:00' } CAGridTest >> expectedFailures [ - ^ {#testFillEmptyFail} + + ^ {#testFillEmptyFail}. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 10:37' + #category : #'initialize-release', + #'squeak_changestamp' : 'KoPa 7/12/2024 19:44' } CAGridTest >> setUp [ + grid := CAGrid new. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 10:37' + #category : #functional, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:45' } CAGridTest >> tearDown [ + grid := nil. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 10:58' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:55' } -CAGridTest >> testDeepCopy [ - | numCols numRows copiedGrid| +CAGridTest >> testClear [ + + | numCols numRows | numCols := grid numCols. numRows := grid numRows. - CAGrid fill: grid. - copiedGrid := grid deepcopy. + CAGrid fillStone: grid. + CAGrid clear: grid. 1 to: numRows do: [:rowIndex | 1 to: numCols - do: [:colIndex | self assert: (copiedGrid getCellAtRow: rowIndex andCol: colIndex) equals: (grid getCellAtRow: rowIndex andCol: colIndex)]]. + do: [:colIndex | + self assert: CABlocks air equals: (grid getCellAtRow: rowIndex andCol: colIndex).]]. +] + +{ + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:55' +} +CAGridTest >> testDeepCopy [ + + | numCols numRows copiedGrid | + numCols := grid numCols. + numRows := grid numRows. + CAGrid fillStone: grid. + copiedGrid := grid deepcopy. + 1 to: numRows + do: [:rowIndex | + 1 to: numCols + do: [:colIndex | + self assert: + (copiedGrid getCellAtRow: rowIndex andCol: colIndex) + equals: + (grid getCellAtRow: rowIndex andCol: colIndex).]]. copiedGrid putCell:-1 atRow: 1 andCol: 1. self assert: -1 < (grid getCellAtRow: 1 andCol: 1). CAGrid clear: grid. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 10:53' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:55' } CAGridTest >> testFillEmptyFail [ + | numCols numRows | numCols := grid numCols. numRows := grid numRows. - CAGrid fill: grid. - 1 - to: numRows - do: [:rowIndex | 1 - to: numCols - do: [:colIndex | self assert: CABlocks air equals: (grid getCellAtRow: rowIndex andCol: colIndex)]]. + CAGrid fillStone: grid. + 1 to: numRows + do: [:rowIndex | + 1 to: numCols + do: [:colIndex | + self assert: CABlocks air equals: (grid getCellAtRow: rowIndex andCol: colIndex).]]. CAGrid clear: grid. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 11:14' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:55' } CAGridTest >> testFillStone [ + | numCols numRows | numCols := grid numCols. numRows := grid numRows. CAGrid fillStone: grid. - 1 - to: numRows - do: [:rowIndex | 1 - to: numCols - do: [:colIndex | self assert: CABlocks stone equals: (grid getCellAtRow: rowIndex andCol: colIndex)]]. + 1 to: numRows + do: [:rowIndex | + 1 to: numCols + do: [:colIndex | + self assert: CABlocks stone equals: (grid getCellAtRow: rowIndex andCol: colIndex).]]. CAGrid clear: grid. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 11:15' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:57' } CAGridTest >> testFillTNT [ + | numCols numRows | numCols := grid numCols. numRows := grid numRows. CAGrid fillTNT: grid. - 1 - to: numRows - do: [:rowIndex | 1 - to: numCols - do: [:colIndex | self assert: CABlocks tnt equals: (grid getCellAtRow: rowIndex andCol: colIndex)]]. + 1 to: numRows + do: [:rowIndex | + 1 to: numCols + do: [:colIndex | + self assert: CABlocks tnt equals: (grid getCellAtRow: rowIndex andCol: colIndex).]]. CAGrid clear: grid. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 11:05' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:57' } CAGridTest >> testGetNeighbors [ - | numCols numRows neighbors| + + | numCols numRows neighbors | numCols := 3. numRows := 3. CAGrid clear: grid. neighbors := grid getNeighborsOfCellAtRow: 2 andCol: 2. - 1 - to: numRows - do: [:rowIndex | 1 - to: numCols - do: [:colIndex | self assert: CABlocks air equals: (neighbors at: rowIndex at: colIndex)]]. + 1 to: numRows + do: [:rowIndex | + 1 to: numCols + do: [:colIndex | + self assert: CABlocks air equals: (neighbors at: rowIndex at: colIndex).]]. grid putCell: 1 atRow: 2 andCol: 2. neighbors := grid getNeighborsOfCellAtRow: 2 andCol: 2. self assert: 1 equals: (neighbors at: 2 at: 2). @@ -124,11 +154,12 @@ CAGridTest >> testGetNeighbors [ ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 11:17' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:48' } CAGridTest >> testGrid [ - |gridMatrix| + + | gridMatrix | CAGrid clear: grid. grid putCell: 1 atRow: 1 andCol: 1. gridMatrix := grid grid. @@ -136,44 +167,30 @@ CAGridTest >> testGrid [ ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 11:07' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:48' } CAGridTest >> testNumCols [ + self assert: 100 equals: grid numCols. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 11:07' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:48' } CAGridTest >> testNumRows [ + self assert: 100 equals: grid numRows. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 11:02' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:48' } CAGridTest >> testPutCellGetCell [ + grid putCell: 1 atRow: 1 andCol: 1. self assert: 1 equals: (grid getCellAtRow: 1 andCol: 1). CAGrid clear: grid. ] - -{ - #category : #'as yet unclassified', - #'squeak_changestamp' : 'HaMa 6/20/2024 11:13' -} -CAGridTest >> testclear [ - | numCols numRows | - numCols := grid numCols. - numRows := grid numRows. - CAGrid fillStone: grid. - CAGrid clear: grid. - 1 - to: numRows - do: [:rowIndex | 1 - to: numCols - do: [:colIndex | self assert: CABlocks air equals: (grid getCellAtRow: rowIndex andCol: colIndex)]]. -] diff --git a/src/ComputationalArtTests/CAOverlayTest.class.st b/src/ComputationalArtTests/CAOverlayTest.class.st index 80e523b..f7da102 100644 --- a/src/ComputationalArtTests/CAOverlayTest.class.st +++ b/src/ComputationalArtTests/CAOverlayTest.class.st @@ -9,41 +9,45 @@ Class { } { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'JAL 6/23/2024 17:31' + #category : #'initialize-release', + #'squeak_changestamp' : 'KoPa 7/12/2024 19:58' } CAOverlayTest >> expectedFailures [ - ^ {#testFillEmptyFail} + + ^ {#testFillEmptyFail}. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'JAL 6/23/2024 17:48' + #category : #'initialize-release', + #'squeak_changestamp' : 'KoPa 7/12/2024 19:58' } CAOverlayTest >> setUp [ + game := CAGame new. overlay := CAOverlay new. overlay game: game. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'JAL 6/23/2024 17:35' + #category : #functional, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:58' } CAOverlayTest >> tearDown [ + game := nil. overlay := nil. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'KoPa 7/12/2024 18:03' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:57' } CAOverlayTest >> testBlockMenu [ + | list blocks | blocks := CABlocks new. list := (overlay submorphOfClass: CAOverlayBlockMenu) submorphOfClass: CAOverlayList. list submorphsDo: [:s | s click. - self assert: (blocks nameAt: (game activeCellType)) equals: s contents asLowercase]. + self assert: (blocks nameAt: (game activeCellType)) equals: s contents asLowercase.]. ] diff --git a/src/ComputationalArtTests/CARulesTest.class.st b/src/ComputationalArtTests/CARulesTest.class.st index 521e02b..a35df74 100644 --- a/src/ComputationalArtTests/CARulesTest.class.st +++ b/src/ComputationalArtTests/CARulesTest.class.st @@ -10,30 +10,33 @@ Class { } { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/23/2024 17:33' + #category : #'initialize-release', + #'squeak_changestamp' : 'KoPa 7/12/2024 19:59' } CARulesTest >> setUp [ + grid := CAGrid new. ruler := CARuler new. ruleSet := OrderedCollection new. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/24/2024 10:49' + #category : #functional, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:59' } CARulesTest >> tearDown [ + grid := nil. ruler := nil. - ruleSet := nil + ruleSet := nil. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 7/10/2024 16:37' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 20:00' } CARulesTest >> testRuleFallDown [ + ruleSet add: CARuleFallDown new. grid putCell: CABlocks water @@ -77,14 +80,15 @@ CARulesTest >> testRuleFallDown [ assert: (grid getCellAtRow: 11 andCol: 40) equals: CABlocks fish. ruleSet removeAll. - CAGrid clear: grid + CAGrid clear: grid. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 7/10/2024 16:34' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:59' } CARulesTest >> testRuleRise [ + ruleSet add: CARuleRise new. grid putCell: CABlocks smoke @@ -98,14 +102,15 @@ CARulesTest >> testRuleRise [ assert: (grid getCellAtRow: 9 andCol: 10) equals: CABlocks smoke. ruleSet removeAll. - CAGrid clear: grid + CAGrid clear: grid. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 7/10/2024 16:33' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 19:59' } CARulesTest >> testRuleSink [ + ruleSet add: CARuleSink new. grid putCell: CABlocks sand @@ -137,14 +142,15 @@ CARulesTest >> testRuleSink [ assert: (grid getCellAtRow: 11 andCol: 20) equals: CABlocks sand. ruleSet removeAll. - CAGrid clear: grid + CAGrid clear: grid. ] { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Sars 6/24/2024 11:25' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 20:01' } CARulesTest >> testRulesFluids [ + | newGrid airCount waterCount | airCount := 0. waterCount := 0. @@ -164,20 +170,18 @@ CARulesTest >> testRulesFluids [ putCell: CABlocks water atRow: 10 andCol: 30. - 10 - timesRepeat: [newGrid := ruler applyRules: ruleSet to: grid]. - 1 - to: 100 - do: [:rowIndex | 1 - to: 100 + 10 timesRepeat: [newGrid := ruler applyRules: ruleSet to: grid.]. + 1 to: 100 + do: [:rowIndex | + 1 to: 100 do: [:colIndex | (grid getCellAtRow: rowIndex andCol: colIndex) = CABlocks air - ifTrue: [airCount := airCount + 1]. + ifTrue: [airCount := airCount + 1.]. (grid getCellAtRow: rowIndex andCol: colIndex) = CABlocks water - ifTrue: [waterCount := waterCount + 1]]]. + ifTrue: [waterCount := waterCount + 1.]]]. self assert: waterCount equals: 3. self assert: airCount equals: (10000 - 3). ruleSet removeAll. - CAGrid clear: grid + CAGrid clear: grid. ] diff --git a/src/ComputationalArtTests/ExampleTest.class.st b/src/ComputationalArtTests/ExampleTest.class.st index 3ddfdd2..eca6f0e 100644 --- a/src/ComputationalArtTests/ExampleTest.class.st +++ b/src/ComputationalArtTests/ExampleTest.class.st @@ -5,9 +5,10 @@ Class { } { - #category : #'as yet unclassified', - #'squeak_changestamp' : 'Pepe Simon 6/19/2024 17:11' + #category : #testing, + #'squeak_changestamp' : 'KoPa 7/12/2024 20:02' } ExampleTest >> testWorking [ + self assert: 1 equals: 1. ]