'From Squeak6.0 of 5 July 2022 [latest update: #22104] on 19 January 2023 at 1:01:45 pm'! !Form methodsFor: 'processing' stamp: 'spfa 1/19/2023 13:01'! nextGeneration "Dan Ingalls Game of Life in BitBlt from Byte81 issue, see https://archive.org/details/byte-magazine-1981-08/page/n181/mode/2up and the following pages. " " |life| life := Form extent: 200@200. 10000 timesRepeat: [life colorAt: 200 atRandom @ 200 atRandom put: Color black]. [Sensor noButtonPressed] whileTrue: [ life nextGeneration. (life magnifyBy: 4) displayAt: 10@50]. Display restore. " | ext carry2 carry4 nbr1 nbr2 nbr4 zp np | ext := self extent + (4@4). nbr1 := Form extent: ext. "ones bit of count" nbr2 := Form extent: ext. "twos bit of count" nbr4 := Form extent: ext. "fours bit of count" carry2 := Form extent: ext. "carry ones overflow into twos" carry4 := Form extent: ext. "carry twos overflow into fours" zp := 0@0. np := -1 @ -1. nbr1 copyAllFrom: zp in: self rule: Form reverse. {2@0 . 0@2} do: [:offset | "c2 := 1s & self" carry2 copyAllFrom: zp in: nbr1 rule: Form over. carry2 copyAllFrom: offset in: self rule: Form and. "1s ^= self" nbr1 copyAllFrom: offset in: self rule: Form reverse. "2s ^= c2" nbr2 copyAllFrom: zp in: carry2 rule: Form reverse. ]. {1@0 . 0@1 . 2@1 . 1@2 . 2@2} do: [:offset | "c2 := 1s & self" carry2 copyAllFrom: zp in: nbr1 rule: Form over. carry2 copyAllFrom: offset in: self rule: Form and. "c4 := 2s & c2" carry4 copyAllFrom: zp in: nbr2 rule: Form over. carry4 copyAllFrom: zp in: carry2 rule: Form and. "1s ^= self" nbr1 copyAllFrom: offset in: self rule: Form reverse. "2s ^= c2" nbr2 copyAllFrom: zp in: carry2 rule: Form reverse. "4s ^= c4" nbr4 copyAllFrom: zp in: carry4 rule: Form reverse. ]. "1s &= 2s" nbr1 copyAllFrom: zp in: nbr2 rule: Form and. "self &= 2s" self copyAllFrom: np in: nbr2 rule: Form and. "self |= (1s & 2s)" self copyAllFrom: np in: nbr1 rule: Form under. "self &= !!4s" self copyAllFrom: np in: nbr4 rule: 4. ! !