Lurker News
After years of solo development I'm presenting: Angeldust, an omni-compatible action RPG and building game!

Website: http://angeldu.st
My single server hosts 250+K active players in one giant, dynamic fantasy world. Angeldust's game server is pervasively multithreaded, implementing John Carmack's dream of processing an immutable world state each tick.
Both world handling and network traffic routing uses any number of threads. For networking, a typical game session only uses ~3Kbps of bandwidth, enabling decent play even over 2G/EDGE networks.
The client is programmed in C++ with bits of C, Objective-C, Java and PHP. It runs really well on very low-end and obsolete hardware, all the way up to modern systems with fast GPUs.
Angeldust works perfectly on Windows XP+, even without hardware OpenGL; Mac OS X 10.6+, even on the first 2006 32-bit Intel GMA945 MacBook1,1; Linux 64-bit glibc 2.17+; Android v2.2.3+, supporting Bluetooth game controllers; and iOS 6+, though iTunes App Store forces iOS 8+ (any way around this?).
I live stream weekly on YouTube and Twitch, even right now! Come ask me your development questions! I often see developers playing together with their kids.
YouTube channel: https://www.youtube.com/AngeldustLive
One more thing: the Angeldust website ( https://angeldu.st ) uses plain HTML and CSS to offer interactive, game-related actions. It's fully functional even without JavaScript enabled.

Comments (193) 42 threads

suby3 replies#
This looks impressive. Can you go into how you implemented the immutable world state each tick a bit more?

I'm developing a game myself, and figuring out a good method of multithreading it took a lot of work. While I am content with the results, I wouldn't say I arrived at a good solution.
It sounds like you went with a purely functional approach? Did you rebuild the entire gamestate each tick, or keep a list of changes you needed to make to the relevant data?

ItsFirefly#
I'll reply more in depth after my livestream, but it's a very good question. You can hop on YouTube right now to discuss it if you want. There's a bit of banter going on, but I might be able to squeeze in some useful replies in between.
ItsFirefly2 replies#
This question was the most asked one during my livestream. It's a good one! Even though it's 01:33 right now after a 7 hour livestream, I'll try to answer it as clearly as possible, building from the foundation up to the high level.

The Angeldust game world is tracked in an "active chunk set". A chunk is a 2D part of the world, 32x32x64 in-game blocks (meters). The active chunk set tracks only the chunks that contain, or are near, players. This chunk set is processed in parallel on any number of threads/cores configured in the server settings file.
Angeldust tracks two states for the data contained in each chunk, kind of like an array of size 2. Each tick, one state in the array is the immutable "read"-state and the other is the mutable "write"-state. Every tick these states ping-pong between the roles.
During processing the server processes the read state and copies over unchanged entity/world data by simply pushing pointers to that data into std::vector<>s in the write state. For things that did change I push a new pointer into the write state and clear up the old pointer in the next tick. Pushing pointers saves memory bandwidth since you don't have to copy all entity data for every tick. And still you can guarantee that the "read"-state will be unmodified so that other CPUs/cores/threads can freely access all of the data and pointers.
On the livestream I discussed a few cases where I do use (largely uncontested) mutexes for data synchronization: for friend chat and private chat I do a lookup of destination hero pointers in the "hero map" and then lock/unlock the hero's mutex for pushing chat messages into a vector.
Does this make sense? Let me know if I should elaborate. I will probably take a nap now, but I'll answer you (and others) tomorrow.
I'll also do another livestream tomorrow, because I feel everyone on HN has very useful questions, feedback and ideas.

suby#
Thanks for the explanation. It makes perfect sense. I did something very similar, except your system sounds better in that you only copy data that has been changed. I have a double buffer system where I'm copying almost all of the data each tick, and swapping the stacks when the next tick is due.
dreamingincode1 reply#
Thanks for the explanation! I happened to be thinking of similar multithreading ideas (chunks and ping-ponging states) recently, but was stuck on what happens when computation happens across chunks in multiple threads. e.g. an object move across chunk border, or an object interaction affecting two objects in different chunks. Could you elavorate on your approach about these? I'm really curious
ItsFirefly5 replies#
Good follow-up question! As for the read state, you're already golden in the sense that you only read data and don't update it. If a chunk needs world or entity data from a neighboring chunk—or even halfway across the world—you can just follow pointers there and you know the data is available and accurate.

For the write state, you're absolutely right that entities will need to transition between chunks. The server looks up the destination in the "active chunk set" I mentioned and then uses per-chunk std::vector<>s guarded by a mutex to push "migrating" entities. This requires a mutex since multiple CPUs/cores/threads/chunks can be pushing entities to the same destination chunk. These mutexes largely have zero to little contention.
Does that answer your question in an acceptable way?

Continue this thread — 5 replies

echelon2 replies#
How did you afford taking off years of work to develop this? Did you have a lot of capital / runway? Low cost of living?

Kudos for this extremely well polished project. This is the dream many of us have but can't or won't embark upon. This is very inspirational.

ItsFirefly2 replies#
Good question. I started working right after what we call "middle school" in the Netherlands which translates to high school I think. During the daytime I would work my job and in the evening self-study for the "Open University" we have here.

I lived with my parents during this time and could save up money as a buffer. Thanks to that support I could financially bridge these past years of development without worrying too much. Also: keeping expenses as low as possible. My product is old school and so are my computers.

smadurange#
Inspiring! Looks awesome. Hope this will go on to become a huge success. All the best!
echelon1 reply#
You're killing it!

Great choices, fantastic execution.
You're going to go far. Keep it up!

ItsFirefly1 reply#
Thanks! A slight word of warning though, something that also came up during yesterday's livestream:

I've been really lucky to be able to successfully fulfill my childhood dream by making this game. But like Freddie Mercury sung: it's [not always] been a bed of roses or a pleasure cruise. I've sacrificed progress in other areas of my life to see this through to the end. I hope to catch up there starting as early as next year. Nonetheless I definitely wouldn't be the same without having taken on this adventure. I've grown so much as a developer, an entertainer and even as a person by creating Angeldust.

Continue this thread — 1 reply

ItsFirefly2 replies#
Thanks so much everyone for all the positivity so far! I'm still streaming right now. After the stream I'll catch up with all questions and comments here, I've had a blast talking about my work so far.

And if any of you can get me in touch with John Carmack that'd be very awesome ;)!

Exuma#
Hes quite active on his facebook
jheriko1 reply#
send him e-mail!! worked for me :)
ItsFirefly#
Both you and Exuma: thanks for the down to earth answers! I'll give it my best shot.
shamelessApathy4 replies#
For the senior citizens viewing this they might relate the term "AngelDust" with the dissociative PCP, let me assure them though, it hasn't been called AngelDust since the 70s. You'd be much more likely to hear it referred to as "wet" or "sherm". IF you went to the ghetto and tried t buy Angel Dust they'd think you were a cop. It's like calling weed "dope". Just a little disambiguation from a drug name etymologist :)
i_am_nomad#
But that’s my favorite drug name, despite its antiquity. There’s just such a goofy mismatch between something that sounds like magical fairy sparkles from heaven, and a drug that lets you fight six cops at the same time and win.
LeftHandPath1 reply#
> For the senior citizens viewing this they might relate the term "AngelDust" with the dissociative PCP, let me assure them though, it hasn't been called AngelDust since the 70s.

I don't see that connection as an issue with the game or your post. It certainly isn't doing anyone any harm, despite what others suggested in earlier comments.
That said... I'm 21 years old, and I still associate "angel dust" with PCP. The name is still used by popular rappers including Mac Miller [0] and Run the Jewels [1]. It is still defined as PCP in 6 of the top 7 results, vs 5 of the top 7 for "sherm" and 0.3/7 for "wet" on Urban Dictionary [2,8,9]. Angel dust is the most common synonym for PCP on Urban Dictionary [10]. The name "angel dust" was used to refer to PCP in a 2011 episode of Its Always Sunny in Philadelphia [3]. The name is still in common parlance on Reddit [4,5,6]. However, the drug seems to have experienced a decline in popularity, accounting for less than 0.1% of all documented hallucinogenic drug use in the United States in 2017 [7] - suggesting that the term "angel dust" is not well known simply because the drug isn't commonly used, and not because the term has been abandoned.
I just don't want anyone to get into trouble thinking that they can use the phrase "Angel Dust" without it being seen as a reference to hard drugs by the general public.
I am also surprised that this association is being rejected, considering that the creator of the game is going by "Frank Lucas" [11], which is the name of a famous drug trafficker [12].
[0]: https://www.youtube.com/watch?v=rIQqzTNRmoc
[1]: https://www.youtube.com/watch?v=R_esHn4X03U
[2]: https://www.urbandictionary.com/define.php?term=Angel%20Dust
[3]: https://itsalwayssunny.fandom.com/wiki/The_Gang_Goes_to_the_...
[4]: https://www.reddit.com/r/PCP/comments/ba1754/two_dimes_of_pc...
[5]: https://www.reddit.com/r/Drugs/comments/5tru38/what_is_angel...
[6]: https://www.reddit.com/r/serialpodcast/comments/2qove1/how_l...
[7]: https://www.drugabuse.gov/drugs-abuse/hallucinogens
[8]: https://www.urbandictionary.com/define.php?term=sherm
[9]: https://www.urbandictionary.com/define.php?term=Wet
[10]: https://www.urbandictionary.com/define.php?term=PCP
[11]: https://angeldu.st/en/game#play-now-button-3
[12]: https://en.wikipedia.org/wiki/Frank_Lucas

lostgame1 reply#
I love your username. Do you follow any particular current of Western Ceremonial Magick?
LeftHandPath#
I do not! (Sorry to disappoint - I’m a run of the mill atheist).

My name was inspired by a Gilfoyle line in Silicon Valley, which references Magick:
https://getyarn.io/yarn-clip/9481dd82-17de-4791-b110-0e58434...
(Since you’re on HN there is a good chance you’re familiar with the show - but if you’re not, the Gilfoyle character is a self-proclaimed LaVeyan Satanist)

chachachoney#
Your time scale and etymology are wildly off, or else your experience is confined to a very limited geographic region.
yojex#
I don't know if "drug name etymologist" is an official profession or your hobby, but if it's the former I would suggest you seriously reconsider and re-research your conclusion on this term! Just a friendly suggestion :-)

Load more comments