r/btd6 • OBJECTION! • 4d ago

Discussion Before asking for multithread support, learn what multithreading is and decide whethever it's worth it or not (image semi-related)

Post image

here's some links

Multithreading (computer architecture) - Wikipedia)

Pros and Cons of Multithreading: Advantages and Disadvantages

I'm pretty sure ninja kiwi considered multithread support but i could be wrong

15 Upvotes

29 comments sorted by

6

u/Asgoreismyhubby 4d ago

Now im not very great at coding,im too low iq to even learn python , but if im not wrong they'd need to rewrite the whole game from scratch to support multi thread

25

u/maenwhile 4d ago

Main problem with multi threading is consistency. Right now as an example having multiple snipers with the same attack speed would result in each sniper having its unique target thanks to the single core of the CPU calculating each attack separately. Meanwhile multi threading would require syncing between all cores so 5 snipers don't attack the same red bloom and placing dart monkeys in a chimps start would result in the same outcome(win/lose)

5

u/PenguinPero 4d ago

that's where synchronisation comes in and you would definitely not use parallel programming for early game where there are tiny amount of projectiles anyways

and I agree there are difficulties and debugging parallel threads is hard etc., but if there are no optimisations left to implement then that would be the required for improvement

that said I have no idea how btd6 is actually coded and if this is an optimisation issue or at some point you have too many calculations and they need to be split around on multiple workers
and the benefit depends on the amount of work that can actually be split without requiring sync

so whether it's worth it or not depends on the team and if they want to do it, how much would it cost and how big of the benefit it would be etc..
it may be hard to accomplish, but it's not impossible to be done properly

-3

u/Stunning-Bid3174 OBJECTION! 4d ago edited 3d ago

if you are into reverse engineering, then you could look at the code directly

5

u/Jakkilip 3d ago

We don't have access to the btd6 source code

-10

u/Stunning-Bid3174 OBJECTION! 3d ago

Do not underestimate reverse engineering

11

u/RetroPixelate 3d ago

That… is not how that works. Reverse engineering a closed-source game involves effectively rebuilding it from the ground up with new code that does (roughly) the same thing. At no point do you get the opportunity to look at NK’s code. If you wanted multithreading in your reverse engineered BTD6, you would just… add it. Even in an actual decompilation, it’s not that easy.

2

u/Spiderfffun average bad player 2d ago

Isn't the game in C#? Which is much easier to decomp tham traditional languages like C++

Though OP doesn't have any idea what they're talking about either (it would be close to impossible to mod this well, and even then, it would not be consistent)

-2

u/Stunning-Bid3174 OBJECTION! 2d ago

Made with unity, which uses c# for scripting. And unity modding community is not small

Also I never said it would be easy

-7

u/Stunning-Bid3174 OBJECTION! 3d ago

i never specified it has to be original source code that NK coders wrote, rather something we can do ourselfs

i agree about difficulty

6

u/Fun_Two6648 3d ago

So, you want to illegally without permission, recreate someones IP? good idea

-3

u/Stunning-Bid3174 OBJECTION! 3d ago

No need to be toxic about it

3

u/Fun_Two6648 3d ago

not toxic, im stating what this would look like. The reason why people are not rebuilding pokemon games like crazy.

3

u/Catkook 2d ago

thats called making a clone

4

u/Jakkilip 3d ago

Multithreading wouldn't solve anything. You need to optimize the game and not brute force running awful code.

4

u/Stunning-Bid3174 OBJECTION! 3d ago

This post was made in response to some people asking multithread support without any idea what issues could arise

1

u/AD007xD 3d ago

I might be speaking out of my ass here but can NK use make use of the GPU by utilising compute shaders to crunch calculations?

1

u/Stunning-Bid3174 OBJECTION! 3d ago

Has any game done that before?

1

u/JamieDrone Glaive Lord, the love of my life❤️ 22h ago

Family time I think does this for the baby wolf ai

1

u/RichRoof7927 3d ago

If I have a good understanding; they could, but GPUs are excellent at doing many, many things at once, not just a couple. They are slow at sequential calculations, and they also need to render the game, which albeit, is not graphically intensive, but still. I believe that the amount of calculations for it to be better would be >10,000, something that frankly, doesn't happen, given the constraints of map space and such.

0

u/Leather-Distance2296 3d ago edited 3d ago

Hello! I am currently working on rewriting all of BTD6 into rust. (it is still early)
rusttd6.com

I have reached a point where my version can run up to 5 times faster, and the bottleneck is never the graphics, it is always the CPU and the fact it is all running on one thread.

I tried getting multithreading to work, and it would significantly increase performance. But it is just not really possible to make the game run the exact same with multithreading because the order in which calculations are done.
there is some logic which can be spread out, but not enough for a meaningful impact. It definitely is possible, but then you could be using even more CPU to just make sure all the threads are perfectly in sync, and would have little gain.

Definitely possible to do it right, but requires Alot of work.

Even though multithreading is hard, I was able to make the code more effecient especially for late game rounds and heavier calculations. Before NK should attempt something like this, they should optimize their logic.

4

u/Stunning-Bid3174 OBJECTION! 3d ago

Is your project vibe coded? (I assume yes)

1

u/Jakkilip 2d ago

Only 5x faster xDDDD

0

u/xsrvmy 1d ago

C# isn't that slow to begin with.

It's the javascript and python to rust conversions that are faster by orders of magnitude. Those languages allow any variable to be any type, so everything requires checking the type of variables, slowing things down a lot.

1

u/Jakkilip 1d ago

Btd6 uses IL2CPP and there is no python or js at all so i dont know what you're talking about

1

u/elmage78 1d ago

What tf did they intend on multithreading ? What is there to do asynchronously ? Unless it is like visual effects i am stumped

1

u/Good-Competition-129 1d ago

Claude add multithread support and make no mistakes

0

u/MrRuckusRCRC 2d ago edited 2d ago

AI slop or not, this gives the reasoning behind no multithreading currently.

"While the underlying Unity engine handles some minor background tasks (like audio, rendering, or OS-level scheduling) across different threads, all of the heavy lifting—tower targeting, projectile physics, damage calculations, and bloon movement—runs sequentially on a single CPU thread.

Because of this, late-game Freeplay rounds (Round 100+) rely entirely on your CPU's single-core clock speed and cache rather than its total core count. Even high-end multi-core processors will bottleneck once one core hits 100% utilization from thousands of overlapping projectiles and damage checks.

Why Ninja Kiwi Hasn't Multithreaded Gameplay

  • Strict Determinism: BTD6 requires exact, repeatable outcomes—especially for modes like CHIMPS and Races. Every frame's state depends directly on the calculations of the previous frame.
  • Shared State & Race Conditions: Every tower interacts with the same pool of bloons simultaneously. If two towers were processed on separate CPU threads at the exact same moment, they wouldn't know the other had already popped or damaged a bloon without constant synchronization.
  • Sync Overhead: Keeping threads locked in sync so projectiles don't double-count damage or waste shots on already-popped bloons introduces heavy CPU overhead that often cancels out the speed gains of using multiple cores.
  • Codebase Overhaul: Converting a tightly coupled, single-threaded Unity game loop into a parallelized architecture would require rewriting the game's core simulation engine from the ground up."

EDIT: But I agree. They really should go the route of rebuilding it from the ground up for the next version of Bloons. In the old days of coolmathgames.com with the older versions, it was ok, but they are now too popular to continue with a single threaded game. It would make late game so much more enjoyable if it wasn't a slide show.