7 ms·
Show HN: Open-source shooter which made it to AC: Valhalla and Skydio drones
So just for fun, I wrote a complete multiplayer game in pure C++. I even wrote my own texture atlas packer, which is now used by Assassin's Creed, 2 scientific publications as well as a drone manufacturing company - each of these basically mentions the name of my game. There is even a claim that Unity patented some of the ECS ideas that originate from this project. See https://github.com/TeamHypersomnia/Hypersomnia#tech-highlights https://github.com/TeamHypersomnia/Hypersomnia#tech-highligh... for details.
By the way the game is pretty darn good. 10 people connected yesterday to test a new map:
https://www.youtube.com/watch?v=CHLPzZqANlM https://www.youtube.com/watch?v=CHLPzZqANlM
It took me well over 10 years to code it all by hand, but the journey was truly worth it.
- deleted 3y ago[deleted]
- harel 3y agoI just love these posts and projects and am very grateful that they are provided open sourced. I'd love to do something like that one day when I have the time (i.e., when I retire), and it's these projects that will most likely be my schooling in this world.
- numlocked 3y agoRebuilding the physics state on client connect is a cool solution to synchronization!
- juancn 3y agoHeck! I just realized I've been following some of your posts over the years without intending to. Specially about ECS and networking. It's nice to see it so advanced. Congrats!
- geneotech 3y agoThank you! That's interesting, I did write an article on SE about ECS back in 2013, but I think it's the first I ever published a proper piece on networking - I do link to an important Glenn Fiedler's blogpost when describing my deterministic architecture in README but just in case I'm not him, I hope I wasn't too misleading :)
- schemescape 3y agoI didn’t realize that getting 100% deterministic behavior for floats would require using the same compiler, even when using the same math functions. Is floating point arithmetic not fully specified or something? Edit: should have searched the web first: https://stackoverflow.com/questions/49471943/floating-point-arithmetic-varies-between-g-and-clang https://stackoverflow.com/questions/49471943/floating-point-...
- vlovich123 3y agoI think it’s just about Intel’s intermediate 80bit precision. Anything else?
- kevingadd 3y agoAny reorderings or optimizations of floating point code could potentially change the results even without 80-bit precision active.
- vlovich123 3y agoAFAIK only if you have -ffast-math enabled. Otherwise IEE754 very specifically lays out all the optimizations the compiler is and isn't allowed to do.
- nwallin 3y agoThere are lots of different ways floating point determinism can get lost. The obvious one, as you mentioned, is the 80 bit x87 unit. Lots of 32 bit compilers will compile to doing floating point math on the x87, which is slow, but the same compiler compiling in 64 bit mode will use SSE2 instructions. Floating point arithmetic is not associative. That is, (a+b)+c != a+(b+c) and (a*b)*c != a*(b*\c). Multiplying by the reciprocal is not equal to dividing by the value. That is, x*(1/y) != x/y. An optimizing compiler may, when you attempt to divide by a constant, will optimize that to multiplying the reciprocal instead, that is, if you have code that divides by the constant 3 it will multiply by 0.33333333333333333, because it's a lot faster. FMA (fused multiply-add) instructions are more precise and therefore not equal to the same calculation without FMA. That is, a*b+c != a*b+c if one compiler will output FMA instructions and the other one does not. (this will be true even in the same compiler with different flags) Special functions are fucky. sqrt, sin, cos etc might not always give equal values. Or even in the same compiler if minor alterations to the code are made. A compiler might use one algorithm to compute sin(x), but a different algorithm if it needs to compute both sin(x) and cos(x) at the same time. Floating point rounding mode is a thing. Sometimes a plugin changes your floating point rounding mode. Sometimes this plugin will be inserted into your runtime without your knowledge, such as an antivirus program, or malware that hijacks your browser to give "better"/"customized" shopping/search recommendations. There was a bug writeup about a crash in Chrome several years back, but I can't find it. Basically you should assume that floating point math is non-deterministic. If you think you need deterministic floating point math, try to reformulate the problem so that you don't need deterministic floating point math. If you really* need deterministic floating point math, understand that you're signing up for a lot of pain.
- theogravity 3y agoThe gameplay reminds me of this this old top down multilayer shooter from the early 2000s called Infantry Online https://www.freeinfantry.com/ https://www.freeinfantry.com/ https://en.m.wikipedia.org/wiki/Infantry_(video_game) https://en.m.wikipedia.org/wiki/Infantry_(video_game)
- barryp123 3y agoThis looks rad! Reminds me of ARC (Attack Retrieve Capture) back in the late 90s -- now on life support as Armor Critical https://en.wikipedia.org/wiki/Attack_Retrieve_Capture https://en.wikipedia.org/wiki/Attack_Retrieve_Capture http://armorcritical.com http://armorcritical.com
- andybak 3y agoThis looks fascinating but - by god, was your post title hard to parse!
- teamonkey 3y agoSame here. I still find it a bit misleading too. The game didn’t make it to AC:Valhalla, a texture-packing library that was made during its creation did[1] (not wanting to downplay that achievement, it’s worthy of a post in its own right, IMO). It’s also a bit of a stretch to claim it was the source of the ECS system used in Unity. I was using a game engine which used ECS prior to 2010. In the game engine world it seems to originate with Operation Flashpoint[2] (post from 2007). [1] https://github.com/TeamHypersomnia/rectpack2D https://github.com/TeamHypersomnia/rectpack2D [2] https://t-machine.org/index.php/2007/09/03/entity-systems-are-the-future-of-mmog-development-part-1/ https://t-machine.org/index.php/2007/09/03/entity-systems-ar...
- geneotech 3y agoHey there, a little clarification - I don't claim that I came up with ECS itself, only a particular implementation of it that is very memory efficient, and Unity's patent concerns a specific implementation as well - sorry if that was a bit misleading. As for the title, I just couldn't resist making the pun, maybe you're right though that the packer should be talked about separately.
- lionkor 3y agoAm I crazy or is your approach to ECS similar to a data oriented ECS? In a fully, brutally data-oriented ECS, you would allocate all components of the same type in the same memory block, so you'd effectively end up with a std::vector<TransformComponent> and a std::vector<PhysicsComponent>, etc. Each entity then holds ids, such as a pair of `what` component and `index` into the respective vector. This ensures that, like your approach, the cache is used well, and that memory fragmentation is minimal. I find your project(s) very, very inspiring as I love working on similar problems among others (github.com/lionkor), thank you for sharing!
- baq 3y ago> Networking is based on cross-platform simulation determinism. Springrts[0] has been doing all that has been described here for the same reasons in late 2000s and I guess countless RTS games also, they just weren't open source. Not to say it isn't an achievement because it is indeed damn hard. [0] https://springrts.com/ https://springrts.com/
- DiabloD3 3y agoOh man, I put so many hours into Spring via Balanced Annihilation. Filled that missing part of my soul that TA and SupCom left, but SupCom 2 (an otherwise really good, but casual and much smaller RTS) didn't. Also, we don't speak about PA. BAR looks really promising, also: https://www.beyondallreason.info https://www.beyondallreason.info
- Pannoniae 3y agoZero-K is the ultimate TA-like, IMO. BAR is really good but much less ambitious and much closer to the original TA gameplay, Zero-K has really cool terrain deformation stuff and interesting units
- jevogel 3y agoThat is mentioned in the details below the heading you quoted. The difference here is that RTS games don't use deterministic floating-point physics, so Hypersomnia requires a novel solution.
- baq 3y agoThat's exactly what it's doing, though - deterministic floats, down to having exact same gcc version for all supported OSes. (Well, used to, haven't checked in a while.)
- teruakohatu 3y agoIncredible achievement. The games looks great. To the author: What else have you been working on commercially to support the project? Do you plan to release it in steam? How does the persistent world effect gameplay? With your clever rebuild physics when a new player joins technique, what does that functionality look like for existing players? Do bullets shift position for example?
- geneotech 3y agoHey there, thank you so much for the kind words! - I have done various gamedev jobs over the years, the most recent being gameplay programming for this minigame in PUBG: https://www.youtube.com/watch?v=tSP5P0QGWa4 https://www.youtube.com/watch?v=tSP5P0QGWa4 I managed to successfully invest my savings too which let me focus entirely on Hypersomnia. - Yes, I'd love to release on Steam before 2024. - For now there is no persistent world at all, I just mentioned it as a teaser for where the game might be heading if it becomes successful. - Rebuilding the physics should not at all shift positions. What is rebuilt is merely the "hot state" like contacts and trees - the only moment where hot state matters is during the process of advancing the simulation from one state to the next, it does not influence how state is later rendered etc. The only impact on the existing players could be a single framerate drop in case the physics world to be rebuilt is massive, but in practice all our maps are still rather small, best suited for 3v3 matches.
- teruakohatu 3y agoThanks for the answers. You are an inspiration!
- stephenpassero 3y agoThis looks really cool - however, the MacOS build guide seems to be a dead link...
- geneotech 3y agoOh, thanks a lot for the catch! Fixed it immediately.
- annix 3y agoFirstly, this looks absolutely unreal, things like this make me really appreciate how little I actually know about CS. Secondly, I've caught a big ol' bug for you on MacOS. When on the pause screen/settings, mouse input is offset significantly. It's to the point that the main menu options aren't even clickable. I've gathered screen capture of the problem here for you, with the logs and a System Report. https://youtu.be/O4OoMdeFAt0 https://youtu.be/O4OoMdeFAt0
- geneotech 3y agoLove to hear it! Sorry about the MacOS incident, I haven't launched it in ages as we play on Windows and Linux pretty much 100% of the time, I'll see what I can do to fix it :)
- annix 3y agoPfft! No apologies necessary. I think I speak for everyone with a pulse and more than 2 tired but functioning brain cells when I say: thanks for supporting MacOS in the first place, cheers for your absolute galaxybrain efforts.