Watchperson by Mac Oglesby
Like many others of my age, I encountered Mac Oglesby's Watchperson on the BBC Micro in school. For some reason the concept stuck with me (perhaps because I get my exercise by walking round my local village) so when I found that it was originally a type-in listing for the PET, I couldn't resist porting it to the ZX81. And the Spectrum. And the PC200.
I've put the original and my ports at <https://www.seasip.info/ZX/watchp.html >.
I've put the original and my ports at <https://www.seasip.info/ZX/watchp.html >.
Thanked by 1JianYang
Comments
I didn't look at the code behind it, but it's probably complicated since it needs to do all the steps itself in basic.
Games List 2016 - Games List 2015 - Games List 2014
https://en.wikipedia.org/wiki/Art_gallery_problem
It's a bit spaghetti-ish (I had to use goto in a couple of places in the C port) and writing it in ZX81 BASIC with one statement per line didn't improve readability. But it doesn't attempt to do anything complicated with graph theory or topology; everything works from the map as-drawn. On the PET it does it by accessing video RAM directly; my ports use a big array of characters. The last bit I got my head around was the street-following algorithm. I didn't really get a handle on how that works until I did the C port, where I could use more meaningful variable names and enum types.
No, on the Seven Bridges of Königsberg problem.
The C port as currently written is specific to PCDOS; to move it to a different platform you'd need at the very least to rewrite screen.c / screen.h / font.c for your chosen target system.
Although you can mess up and make yourself have no moves left.
GJKNMCDABEDGHEFILKHI does the job, probably a few other ways, can't be bothered working out a formula for how many though ;) At least 2 cos you can do it backwards.
Any level you make up which has 0 or 2 nodes which have an odd number of edges leaving it will be solvable though. Euler did a simple proof of that and invented topology (although I studied it in combinatorics since topology was more like metric spaces/analysis than graph theory stuff)