Pages: 1
Author Topic: A complex maze with one line of code !  (29,972 Views)
Offline (Unknown gender) egofree

Contributor
Joined: Jun 2013
Posts: 601
View profile
Posted on: June 20, 2014, 07:22:10 AM
10 PRINT CHR$(205.5+RND(1)); : GOTO 10

A simple line of code in Basic to make a 2D 'complex' maze on the commodore 64 !  :D

There is a complete book written on this line of code ! : http://10print.org/

You can download on the web site the electronic version of the book for free !

For all the kids who were not born in the early eighties, and don't know what we are talking about  ;) :
http://en.wikipedia.org/wiki/Commodore_64

Commodore 64 was one of the most successful computer in the early eighties. It had astounding graphical and musical skills for his time, and it was much cheaper than Apple ! :P
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #1 Posted on: June 20, 2014, 12:08:04 PM
That prints a complex maze, eh? So by complex, you mean unsolvable to seventeen sigmas of certainty.

I used to love screwing around in MS Paint. I would amaze my classmates by creating semitransparent objects using stippling, even though the displays were 800x600 and you'd have to be blind not to see the pixels. Yeah, Windows 95 was the best. This doesn't make what I did color interpolation, and it doesn't make that line print a maze.

And for the record, the equivalent C is [snip=c]for (;;) printf((rand() & 1)? "╱" : "╲");[/snip], or if you really like, [snip=c]a: printf((rand() & 1)? "╱" : "╲"); goto a;[/snip].

The output looks like this:


An even more unicodey version is [snip=c]for (;;) printf("%s", "┓\0┗\0┛\0┏\0┳\0┻\0┫\0┣\0╋" + ((rand() % 9) << 2));[/snip].

Its output instead looks like this:


tl;dr: Please let BASIC die in peace; programming hasn't gotten more difficult. For anything. It's only gotten easier; we just can't reserve non-ascii characters for box drawing anymore.
Offline (Unknown gender) Rusky

Resident Troll
Joined: Feb 2008
Posts: 954
View profile WWW
Reply #2 Posted on: June 20, 2014, 02:50:07 PM
I think the meme about programming getting more difficult is due to how complex the stack is. If you want to do things at the C64 (or Apple II, or Atari, or TRS-80) level of difficulty, you're on top of an enormous stack that 1) is slightly harder to find in the haystack than boot-your-pc-into-a-basic-interpreter, and 2) often feels like it can shift out from under you because you're missing some detail outside of the nice simple environment. On the other hand, if you want to do things at the C64, etc. level of execution model simplicity, you're dealing with a vast array of semi-standardized interfaces that takes years to get right.

Not sure if that's a good thing or a bad thing, but it's definitely not cut-and-dry easier than pressing the power button and typing
10 PRINT IM AWESOME
20 GOTO 10
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #3 Posted on: June 20, 2014, 08:44:14 PM
For $40 I will sell you a Pi, and you can type this into the first thing you see after you press that exact button:

Code (bash) Select
chars="╱╲"; while :; do printf ${chars:$((RANDOM % 2)):1}; done

Admittedly more verbose, but then, not really a use case of Bash. *shrug*

The redeeming quality is that the other "maze" generator is now a total of seven chars longer:
[snip=bash]chars="┓┗┛┏┳┻┫┣╋"; while :; do printf ${chars:$((RANDOM % 9)):1}; done[/snip]


For an extra $3, I'll set a frontend to Geordi as your scripting environment.
Offline (Unknown gender) Rusky

Resident Troll
Joined: Feb 2008
Posts: 954
View profile WWW
Reply #4 Posted on: June 20, 2014, 08:58:40 PM
The Pi is the exception that proves the rule here- it's created specifically for education. And it's still more complicated, even if only by virtue of running a full-on Linux distribution. It would be nice to simplify the software stack, and maybe even the hardware ecosystem.

Then again, maybe those goals are antithetical to good performance and productivity in all the new (relative to C64 days) things computers are used for today. I don't know if it's possible to simplify hardware interfaces without ditching some performance tricks, or to simplify software internally without crippling it.
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #5 Posted on: June 21, 2014, 12:55:00 AM
The Pi was a cheap example; many Linux distributions, including Arch Linux, ship the same way.  Few people choose to have their computers in that state; a Pi is just an example where you don't have much choice, so it ships that way.

As far as simplifying architectures goes, it happens all the time. In embedded systems. You can't ship one product and have it perfectly simplify everything your users might code. ENIGMA has the slight benefit of assuming you're coding a game. We don't have the ability to tailor to 2D games, or platform games, or RPGs, or 3D shooters.... The best we can do is offer tools to help you with whichever you decide you're making.

In the same way, vendors can't assume you need ASCII, a degree symbol, copyright symbol, trademark symbol, Spanish and French accented characters, and some box art. We used to get away with that, and it made some tasks easier. It just isn't on the table anymore.
Offline (Unknown gender) Rusky

Resident Troll
Joined: Feb 2008
Posts: 954
View profile WWW
Reply #6 Posted on: June 21, 2014, 03:21:43 AM
The fact that users don't choose to have their computers in that state (which in and of itself is rather more complicated than a BASIC interpreter) is pretty much my point. The things we do with computers don't work too well with just a command line at this point.

My vague speculation is whether it's possible to keep the GUI and all the things we use it for while making the stack simpler so you can do something as simple in its runtime and conceptual model as writing a game in BASIC or maybe a simple assembly, without all the obstacles of setting up your environment and keeping it happy. That sort of thing is second nature to developers and power users, but back in the day beginners could do it too.

I and others sat down at an eye-bleedingly colored BASIC prompt with no programming experience and put together crappy games in a day or so with nothing but a manual. We couldn't watch Netflix or chat on IRC, but I guess I just don't see anything about those sorts of things that would force the stack to be so complicated.
Pages: 1