include c:\cxpl\codes; \intrinsic 'code' declarations char New(53,40), Old(53,40); proc Block(X0, Y0, C); \Display a colored block int X0, Y0, C; \big (6x5) coordinates, char int X, Y; [case C of \convert char to color ^H: C:= $9; \blue ^t: C:= $C; \red ^.: C:= $E \yellow other C:= 0; \black for Y:= Y0*5 to Y0*5+4 do \make square blocks by correcting aspect ratio for X:= X0*6 to X0*6+5 do \ (6x5 = square) Point(X,Y,C); ]; int X, Y, C; [SetVid($13); \set 320x200 graphics display for Y:= 0 to 40-1 do \initialize New with space (empty) characters for X:= 0 to 53-1 do New(X, Y):= ^ ; X:= 1; Y:= 1; \read file from command line, skipping borders loop [C:= ChIn(1); case C of $0D: X:= 1; \carriage return $0A: Y:= Y+1; \line feed $1A: quit \end of file other [New(X,Y):= C; X:= X+1]; ]; repeat C:= Old; Old:= New; New:= C; \swap arrays, by swapping their pointers for Y:= 1 to 39-1 do \generate New array from Old for X:= 1 to 52-1 do \ (skipping borders) [case Old(X,Y) of ^ : New(X,Y):= ^ ; \copy empty to empty ^H: New(X,Y):= ^t; \convert head to tail ^t: New(X,Y):= ^. \convert tail to conductor other [C:= (Old(X-1,Y-1)=^H) + (Old(X+0,Y-1)=^H) + \head count (Old(X+1,Y-1)=^H) + (Old(X-1,Y+0)=^H) + \ in neigh- (Old(X+1,Y+0)=^H) + (Old(X-1,Y+1)=^H) + \ boring (Old(X+0,Y+1)=^H) + (Old(X+1,Y+1)=^H); \ cells New(X,Y):= if C=-1 or C=-2 then ^H else ^.; \ (true=-1) ]; Block(X, Y, New(X,Y)); \display result ]; Sound(0, 6, 1); \delay about 1/3 second until KeyHit; \keystroke terminates program SetVid(3); \restore normal text mode ]