Hacker News new | past | comments | ask | show | jobs | submit login
City in a Bottle – A 256 Byte Raycasting System (frankforce.com)
362 points by bubblehack3r 24 days ago | hide | past | favorite | 23 comments



Related:

How [Atari 2600] Pitfall Builds its World:

https://evoniuk.github.io/posts/pitfall.html

Procedural Generation [Elite, early 8-bit game]:

https://procedural-generation.tumblr.com/post/112509130817/e...

Procedural Generation [general article]:

https://en.wikipedia.org/wiki/Procedural_generation

Somewhat related:

Lazy Evaluation [from Functional programming (FP) languages]:

https://en.wikipedia.org/wiki/Lazy_evaluation

Random observation:

If a given raytracing algorithm (https://en.wikipedia.org/wiki/Ray_tracing_(graphics) only evaluates visible points for a 2D image created as a view from a set of 3D data -- then that's sort of similar to the FP concept of Lazy Evaluation, that is, "delay the evaluation of an expression until its value is needed"...

Which in turn, prima facie, seems at least cursorily related to "Observation collapses the wave function":

https://en.wikipedia.org/wiki/Wave_function_collapse


From the same author: 1K Pinball Game in JavaScript https://frankforce.com/lu1ky-pinball-code-deep-dive/


Remnants by Alcatraz - similar 256-byte MS-DOS demo - youtube link included: https://www.pouet.net/prod.php

I think this one is more impressive for being in Javascript, which often has worse density than 16-bit x86 machine code.


I think the correct link is: https://www.pouet.net/prod.php?which=96536 The source code is also included


I'm a moron. Somehow I read "width" and deleted the irrelevant parameter because people have different screen sizes and the site should auto-detect instead of using my one.


'Spongy' does something similar in 128 bytes, half the size.

https://www.pouet.net/prod.php?which=53871

http://www.youtube.com/watch?v=36BPql6Nl_U

The name comes from the 'Menger Sponge' fractal it's based on:

https://en.wikipedia.org/wiki/Menger_sponge


Not necessarily worse density - variables are 1 byte names vs 2+ byte load instructions (often 3).

But the thing that gives JS a huge advantage here is the “standard (dweet) library” which has sin/cos/fill/line etc whereas x86 bios has “switch mode” and then it’s just a pixel array.


that’s spectacular — the information density we perceive is off he charts for such a small amount of code.

Makes me wonder if LLMs aren’t the best way to model the world at all…


obfuscated code with a lot of short cuts is likely also not the best way to model the world :P but this is definitely an impressive feat :D i'd be happy to get it done in like 256 lines of code, likely it would take much more than that! XD...

as for visual stuff. a lot of things man made and natural follow patterns (otherwise it'd be hard to recognize anything). So there's a lot of maths stuff you can use. Different types of noise or other patterns line for the height textures, fractals can be used interestingly, fibbonach/phi ratio for vegetation/trees, size ratio between skeletal elements / bones etc. - don't need any magic guessing machines for any of that.


You’re telling me god didn’t cut corners? /s

Yeah, reacting to so much perceived information being represented in such little code. Versus billions/trillions of weights in LLMs…


i love speedtree tool. its a great example of how relatively simple algorithms can make natural complexity. also a great example on how to visually make things seem real while cutting as much corners as possible is that people used to fake bounced light through a room simply by making the backs of objects emit a fraction of light caught on the light facing side.

as people cant actually at observe arbitrary speeds and bandwith, you can skip most of the universe when visually representing it, to an extreme degree.


Why would you think they are?


Meh I don’t (they’re clearly imperfect) but I’m more wondering if we’re leaving lots of efficiency on the table in approaches to modeling the world.


This is very cool, but it's a bit unfortunate the loop runs continuously the entire time I'm trying to read the article and overheating my laptop.


Oh so that's why my phone felt unusually warm the last few minutes!


Thanks for the heads up, I fixed it! (just removed the live demo for now)


If you like this you'll love #tweetcart on Twitter.

Tweet sized programs for the Pico-8 virtual console.



Oh I like that! That's awesome, nice one man!


This is amazing, both the work and the article


that's a pretty fun read.


This is why I come here.


That was amazing.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: