Conway

Y'know, other stuff, Sinclair related.
Post Reply
dfzx
Manic Miner
Posts: 683
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Conway

Post by dfzx »

Sad to see John Conway died a couple of days back.

I guess it'll only be those of us who started with the Spectrum in the very early days who see the link here. An implementation of his Game of Life appeared on the Horizons tape which came with the 16K/48K machine. I remember finding it quite interesting at the time although I've just loaded it up for the first time in nearly 40 years and now it seems rather dull. :)

When was the last time anyone else loaded something from Horizons?
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
User avatar
Alessandro
Dynamite Dan
Posts: 1910
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Conway

Post by Alessandro »

Yes, now that you mention Life, I remember who he was. RIP.

I last loaded the Horizons tape (well, a TZX image of it to be honest) on the evening of 23 April 2012 to celebrate the 30th anniversary of the Spectrum:

Image
User avatar
Morkin
Bugaboo
Posts: 3277
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Re: Conway

Post by Morkin »

Nice article.

I didn't really understand that Game of Life program when I loaded it up back in the 80s. In fact I thought it was going to be that one with the moving graph depicting the fox/rabbit populations. Thro' the Wall was the only one that stuck in my mind.

Whenever I see anyone described as a 'boffin', I always think of Uncle Clive.. :)
My Speccy site: thirdharmoniser.com
dfzx
Manic Miner
Posts: 683
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: Conway

Post by dfzx »

Alessandro wrote: Tue Apr 14, 2020 10:39 am Yes, now that you mention Life, I remember who he was. RIP.

I last loaded the Horizons tape (well, a TZX image of it to be honest) on the evening of 23 April 2012 to celebrate the 30th anniversary of the Spectrum:

Image
Oh Lordy, that loading screen... I haven't seen it for so many years, but it's so familiar...
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
catmeows
Manic Miner
Posts: 718
Joined: Tue May 28, 2019 12:02 pm
Location: Prague

Re: Conway

Post by catmeows »

Sad news, indeed :(
Proud owner of Didaktik M
Ralf
Rick Dangerous
Posts: 2289
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: Conway

Post by Ralf »

I've read about john Conway recent death in some newspaper already :( It's sad, and I would say a bit ironic that a man who
created mathematical models about multiplications of some simple agents that could represent bacteria or viruses actually
died from a rapidly multiplicating virus himself.

I believe I learnt abouit Game of Life lately, as an adult and already from Internet. I never got sucked much into it but some
guys were really very serious about it, designing with passion structures that cycled, fluctuated or even moved.

It was a bit like Minecraft for 80/90 nerds :)
Firefox

Re: Conway

Post by Firefox »

A strangely moving tribute from XKCD...

Image
catmeows
Manic Miner
Posts: 718
Joined: Tue May 28, 2019 12:02 pm
Location: Prague

Re: Conway

Post by catmeows »

That's a glider - a moving pattern. There is also pattern called "glider gun", it produces gliders.
https://en.m.wikipedia.org/wiki/Glider_(Conway's_Life)
Proud owner of Didaktik M
User avatar
1bvl109
Dizzy
Posts: 98
Joined: Tue Jun 04, 2019 9:00 pm

Re: Conway

Post by 1bvl109 »

There's also a real running BASIC-program on WoS http://www.worldofspectrum.org/infoseek ... id=0025822
"Truth would quickly cease to be stranger than fiction, once we got used to it." - H.L. Mencken
User avatar
MonkZy
Manic Miner
Posts: 279
Joined: Thu Feb 08, 2018 1:01 pm

Re: Conway

Post by MonkZy »

I searched the database for Spectrum LIFE routines and stumbled across a great piece of machine code. It ties in with an earlier thread about female coders, the routine I found was written by Toni Baker.

Macro-Life by Toni Baker

This routine uses the entire screen memory as a cell structure so is very slow generating each iteration. Having a 256x128 playing grid is really good though.

I tested Toni's routine with a very famous pattern, the Gosper Glider Gun from 1970. It works perfectly. Boosting the CPU in an emulator to 5000% gives a good view of the cell changes.

gosper.tap

I may make GUI for this algorythm, reducing the play-grid to increase the speed a little.
User avatar
Packobilly
Drutt
Posts: 36
Joined: Sun Mar 08, 2020 8:16 am

Re: Conway

Post by Packobilly »

RIP Mr. Conway.
User avatar
druellan
Dynamite Dan
Posts: 1475
Joined: Tue Apr 03, 2018 7:19 pm

Re: Conway

Post by druellan »

There is also a very nice version as a freebie on Pete Cooke's Zolyx (https://spectrumcomputing.co.uk/index.p ... 96&id=5862).

Image
User avatar
Alessandro
Dynamite Dan
Posts: 1910
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Conway

Post by Alessandro »

Yesterday I loaded (under emulation) the Life program on side B of the Horizons tape - I believe the last time I did it should have been in 1985 or so. I put some cells at random on the screen and started it. After about 30 seconds the situation came to a stall:

Image

I never experienced it back in the day - as far as I can remember - so I thought to share it here. Bizarre.
User avatar
1bvl109
Dizzy
Posts: 98
Joined: Tue Jun 04, 2019 9:00 pm

Re: Conway

Post by 1bvl109 »

MonkZy wrote: Wed Apr 15, 2020 1:12 pm This routine uses the entire screen memory as a cell structure so is very slow generating each iteration.
Thanks for digging this up.

It seems to use wrap-around screen, so maybe there is a moral here. In a world with limited resources a gun sooner or later shoots itself in the foot.

Image
"Truth would quickly cease to be stranger than fiction, once we got used to it." - H.L. Mencken
User avatar
ZXDunny
Manic Miner
Posts: 498
Joined: Tue Nov 14, 2017 3:45 pm

Re: Conway

Post by ZXDunny »

Efil from Your Spectrum:

https://www.youtube.com/watch?v=Y8haseTVZGM

And the SpecBAS conversion from machine code to BASIC:

https://www.youtube.com/watch?v=d_zW0F_iVno
User avatar
1bvl109
Dizzy
Posts: 98
Joined: Tue Jun 04, 2019 9:00 pm

Re: Conway

Post by 1bvl109 »

MonkZy wrote: Wed Apr 15, 2020 1:12 pm Macro-Life by Toni Baker
The link to archive.org there only has the main text of the article without the source code. So I took the freedom to adapt it to be compilable by zasm

Code: Select all

	ORG $8000	;	
UP:	DEC H	;	Up one pixel (assuming within chr square).
	LD A,H	;	A:= high part of address.
	OR $F8	;	Use only bits 2, 1 and 0.
	INC A	;	
	JR NZ,EXIT	;	Jump if within character square,
	LD A,L	;	A:= low part of address.
	SUB $20	;	
	LD L,A	;	HL:= pix addr, assuming crossed from one
		;	Screen-third to another
	LD A,H	;	A:= high part of address.
	JR C,TEST_TOP	;	Jump if crossed from one third to another.
	ADD A,$08	;	
	LD H,A	;	HL:= pixel address (all remaining cases).
	JR EXIT	;	Jump to exit,
TEST_TOP:	CP $EF	;	
	JR NZ, EXIT	;	Jump unless off top of screen.
	LD H,$D7	;	Point HL to bottom line of screen, Note bit
	JR EXIT	;	7 of H set for all screen addresses here,
DOWN:	INC H	;	Down one pixel (assuming within chr square),
	LD A,H	;	A:= high part of address.
	AND $07	;	Use only bits 2, 1 and 0.
	JR NZ,EXIT	;	Jump if within character square,
	LD A,L	;	A:= low part of address.
	ADD A,$20	;	
	LD L,A	;	A:= low part of address.
	LD A, H	;	A:= high part of address.
	JR C,TEST_BOTTOM	;	Jump if crossed from one third to another,
	SUB $08	;	
	LD H,A	;	HL:= pixel address (all remaining cases).
	JR EXIT	;	Jump to exit.
TEST_BOTTOM:	CP $D8	;	
	JR NZ,EXIT	;	Jump unless off bottom of screen,
	LD H,$C0	;	Point HL to top line of screen,
	JR EXIT	;	Jump to exit.
LEFT:	RLC C	;	Left one pixel (assuming within chr square).
	JR NC,EXIT	;	Jump if within chr square,
	LD A,L	;	A:= low part of address.
	DEC A	;	Decrement (to move left).
	JR L_R	;	
RIGHT:	RRC C	;	Right one pixel (assuming within chr square).
	JR NZ,EXIT	;	Jump if within character square,
RIGHT_1:	LD A,L	;	A:= low part of address.
	INC A	;	Increment (to move right).
L_R:	XOR L	;	Combine A and L by taking bits 7, 6 and 5
	AND $1F	;	of L, and bit 4, 3, 2, 1 and 0 of A.
	XOR L	;	"This has the effect of ""joining"" the"
	LD L,A	;	left and right hand edges of the screen,
EXIT:	LD A,C	;	A:= pixel position within square
	AND (HL)	;	Test the specified screen pixel.
	RET Z	;	Return if the pixel in PAPER colour (reset).
	INC B	;	Otherwise increment count in B register
	RET	;	
		;	
	ORG $804D	;	USR 32845
NEXTGEN:	LD HL,$4000	;	Point HL to screen,
	LD DE,$C000	;	Point DE to screen copy.
	LD BC,$1800	;	BC:=number of bytes in screen.
	PUSH DE	;	Stack start address of screen copy.
	LDIR	;	Make copy of screen,
	POP HL	;	HL points to first byte of screen copy.
	LD C,$80	;	C has leftmost pixel set, thus HL and C
		;	together point to first pixel in the copy.
LOOP:	LD B,$00	;	Initialise cell count as zero,
	PUSH BC	;	Stack pixel position.
	PUSH HL	;	Stack screen-copy address,
	CALL UP;$8000	;	Count, in B, the number of cells which
	CALL RIGHT;$803D	;	surround the given pixel.
	CALL DOWN;$801B	;	
	CALL DOWN;$801B	;	
	CALL LEFT;$8035	;	
	CALL LEFT;$8035	;	
	CALL UP;$8000	;	
	CALL UP;$8000	;	
	LD A,B	;	A:= number of cells surrounding pixel.
	POP HL	;	
	POP BC	;	Restore HL and C to point to given pixel,
	RES 7,H	;	Point HL into screen (rather than copy).
	CP $02	;	
	JR C,NO_CELL	;	Jump if less than two cells surround pixel.
	CP 04	;	
	JR NC,NO_CELL	;	Jump if four or more cells surround pixel.
	CP $03	;	
	JR NZ,CONTINUE	;	Jump if exactly two cells surround pixel
CELL:	LD A,C	;	A:= pixel position,
	OR (HL)	;	Prepare to set pixel to create cell,
	JR PUT	;	
NO_CELL:	LD A,C	;	A:= pixel position,
	CPL	;	
	AND (HL)	;	Prepare to reset pixel to remove cell.
PUT:	LD (HL),A	;	Set or reset pixel as required,
CONTINUE:	SET 7,H	;	Point HL back into screen copy.
	RRC C	;	Right one pixel (assuming within chr square).
	JR NC,LOOP	;	Jump back if within character square.
	CALL RIGHT_1;$8041	;	Right one pixel (otherwise).
	LD A,L	;	A:= low part of address.
	AND $1F	;	
	JR NZ,LOOP	;	Jump back unless off right edge of screen,
	CALL DOWN;$801B	;	Down one pixel.
	LD A,H	;	A:= high part of address.
	XOR $C0	;	
	OR L	;	
	JR NZ,LOOP	;	Jump back unless whole screen done.
	RET	;	
"Truth would quickly cease to be stranger than fiction, once we got used to it." - H.L. Mencken
User avatar
1bvl109
Dizzy
Posts: 98
Joined: Tue Jun 04, 2019 9:00 pm

Re: Conway

Post by 1bvl109 »

Those types of bugs ...
There all seems to work first, but then there arises some ephemeral strange behaviour under certain conditions.

I hope this is correct now.

Code: Select all

	ORG $8000	;	
UP:	DEC H	;	Up one pixel (assuming within chr square).
	LD A,H	;	A:= high part of address.
	OR $F8	;	Use only bits 2, 1 and 0.
	INC A	;	
	JR NZ,EXIT	;	Jump if within character square,
	LD A,L	;	A:= low part of address.
	SUB $20	;	
	LD L,A	;	HL:= pix addr, assuming crossed from one
		;	Screen-third to another
	LD A,H	;	A:= high part of address.
	JR C,TEST_TOP	;	Jump if crossed from one third to another.
	ADD A,$08	;	
	LD H,A	;	HL:= pixel address (all remaining cases).
	JR EXIT	;	Jump to exit.
TEST_TOP:	CP $BF	;	
	JR NZ, EXIT	;	Jump unless off top of screen.
	LD H,$D7	;	Point HL to bottom line of screen, Note bit
	JR EXIT	;	7 of H set for all screen addresses here,
DOWN:	INC H	;	Down one pixel (assuming within chr square),
	LD A,H	;	A:= high part of address.
	AND $07	;	Use only bits 2, 1 and 0.
	JR NZ,EXIT	;	Jump if within character square,
	LD A,L	;	A:= low part of address.
	ADD A,$20	;	
	LD L,A	;	A:= low part of address.
	LD A, H	;	A:= high part of address.
	JR C,TEST_BOTTOM	;	Jump if crossed from one third to another,
	SUB $08	;	
	LD H,A	;	HL:= pixel address (all remaining cases).
	JR EXIT	;	Jump to exit.
TEST_BOTTOM:	CP $D8	;	
	JR NZ,EXIT	;	Jump unless off bottom of screen,
	LD H,$C0	;	Point HL to top line of screen,
	JR EXIT	;	Jump to exit.
LEFT:	RLC C	;	Left one pixel (assuming within chr square).
	JR NC,EXIT	;	Jump if within chr square,
	LD A,L	;	A:= low part of address.
	DEC A	;	Decrement (to move left).
	JR L_R	;	
RIGHT:	RRC C	;	Right one pixel (assuming within chr square).
	JR NC,EXIT	;	Jump if within character square,
RIGHT_1:	LD A,L	;	A:= low part of address.
	INC A	;	Increment (to move right).
L_R:	XOR L	;	Combine A and L by taking bits 7, 6 and 5
	AND $1F	;	of L, and bit 4, 3, 2, 1 and 0 of A.
	XOR L	;	"This has the effect of ""joining"" the"
	LD L,A	;	left and right hand edges of the screen,
EXIT:	LD A,C	;	A:= pixel position within square
	AND (HL)	;	Test the specified screen pixel.
	RET Z	;	Return if the pixel in PAPER colour (reset).
	INC B	;	Otherwise increment count in B register
	RET	;	
		;	
	ORG $804D	;	USR 32845
NEXTGEN:	LD HL,$4000	;	Point HL to screen,
	LD DE,$C000	;	Point DE to screen copy.
	LD BC,$1800	;	BC:=number of bytes in screen.
	PUSH DE	;	Stack start address of screen copy.
	LDIR	;	Make copy of screen,
	POP HL	;	HL points to first byte of screen copy.
	LD C,$80	;	C has leftmost pixel set, thus HL and C
		;	together point to first pixel in the copy.
LOOP:	LD B,$00	;	Initialise cell count as zero,
	PUSH BC	;	Stack pixel position.
	PUSH HL	;	Stack screen-copy address,
	CALL UP;$8000	;	Count, in B, the number of cells which
	CALL RIGHT;$803D	;	surround the given pixel.
	CALL DOWN;$801B	;	
	CALL DOWN;$801B	;	
	CALL LEFT;$8035	;	
	CALL LEFT;$8035	;	
	CALL UP;$8000	;	
	CALL UP;$8000	;	
	LD A,B	;	A:= number of cells surrounding pixel.
	POP HL	;	
	POP BC	;	Restore HL and C to point to given pixel,
	RES 7,H	;	Point HL into screen (rather than copy).
	CP $02	;	
	JR C,NO_CELL	;	Jump if less than two cells surround pixel.
	CP 04	;	
	JR NC,NO_CELL	;	Jump if four or more cells surround pixel.
	CP $03	;	
	JR NZ,CONTINUE	;	Jump if exactly two cells surround pixel
CELL:	LD A,C	;	A:= pixel position,
	OR (HL)	;	Prepare to set pixel to create cell,
	JR PUT	;	
NO_CELL:	LD A,C	;	A:= pixel position,
	CPL	;	
	AND (HL)	;	Prepare to reset pixel to remove cell.
PUT:	LD (HL),A	;	Set or reset pixel as required,
CONTINUE:	SET 7,H	;	Point HL back into screen copy.
	RRC C	;	Right one pixel (assuming within chr square).
	JR NC,LOOP	;	Jump back if within character square.
	CALL RIGHT_1;$8041	;	Right one pixel (otherwise).
	LD A,L	;	A:= low part of address.
	AND $1F	;	
	JR NZ,LOOP	;	Jump back unless off right edge of screen,
	CALL DOWN;$801B	;	Down one pixel.
	LD A,H	;	A:= high part of address.
	XOR $C0	;	
	OR L	;	
	JR NZ,LOOP	;	Jump back unless whole screen done.
	RET	;	


One was a silly typo and the other sort of too.

Image

So this says BF, not EF.

Goes without saying, that I'm in awe of people who go through this viewtopic.php?p=35833#p35833
"Truth would quickly cease to be stranger than fiction, once we got used to it." - H.L. Mencken
Post Reply