A solution to all your troubles: Mega Units

Flare, your players have a lot of complaints at the higher levels. The over-abundance of units causes glitches. Your waves are limited to 8 units despite the greater morale. Etc. People say that the game stopped being fun after the 3,500 trophy range, when everyone had about 20 morale per wave.

So here’s the solution: Mega units. Units which have (2^0.5)x Atk, (2^0.5)x HP, and cost twice as much morale.

  • Why twice as much morale?

This allows you to squeeze more units into each space. So for example, if you have one space left, but two morale left, then you can fill that space with a Mega Knight. This also allows you to have less units on the screen at once, as defenders may have more less units per wave and attackers’ armies may only be half as large.

  • Why (2^0.5)x HP?

I wanted to make if 1x HP so that spells be equally as effective, but then I thought… You know, Spells scale up over time. Furthermore, what good is the boost to attack if something has a higher range and kills the unit before it can do anything? Your knights could have 10000000x Atk, but it won’t mean a Hell of beans if they get slaughtered by a trap Firebolt Tower. So the increase in HP would definitely be necessary.

  • Why (2^0.5)x HP?

Like I said, my original thought was simply to double attack, but that wouldn’t do much if the units died too early. For example, a Mega Ogre would have more damage, but it wouldn’t even be able to touch a Mega Archer because it’d die too early. To have /just/ double the Atk, you’d also have to double the speed of everything.

No matter how you proportional use the new stats, Mega Units would reduce the amount of units at the field at a time and would give people greater options for how to fill their waves.

2^0.5 = 1.414 but costs 2x moral… well, maybe it’s fair, AoE spells…

But why a weird number like this? why not just 1.5? float points like this will slow down the game.

Because 2^0.5 x 2^0.5 = 2. I base it on the assumption that HP x Atk = usefulness

Err, nope… why would they? 

If we should double everything to get mega units i don’t raid anymore since all waves could have lot of defense or attack or health and become more difficult to raid bases with these overpowered waves. 42 morale points now are complicated, let’s not add more complications.

… are you … sure? 

I believe the idea would have to be modified to fit better and not make the units too overpowered but I like the idea or more simply extend the amount of troops the player can have in their waves.

Though, basically the mega units were above suggested for reducing the amount of troops in a wave, not for increasing it… 

 

Of course, there’s *some* precision loss with floats…

But first of all, 9.000000000000014 really is not much different from 9. And this is so little it usually will be completely irrelevant.

Also, above you said floating point numbers slow down the game, now you say you lose precision, which is a completely different statement.

Thirdly, there are already floating point numbers in the game. Look how many units (troops, towers) as well as spells have a range of 2.4 or 5.5, for example. And also for those numbers that are displayed as integers (e.g. health values), it might very well be the case that floating point numbers are used for calculations, e.g. for damage over time… 

 

Also, the thing is, square root of 2 is a number with infinitely many digits, so obviously you always use an approximation of it, be it 1.4142135623730950488016887242097, 1.414 or 1.4 only. And then, the 1.4 is a non-integer number just as well as 1.414… is, so for the computer it makes no real difference.

Also, the value “square root of 2” is a value based on mathematical calculations that were used to reason about a useful / appropriate value… now arguing about how approximately flaregames should internally represent that for maximum efficiency or accuracy is nothing we should discuss here. Rather, if the mega unit approach is viable at all, and if the suggested model is appropriate or not. 

 

Alright, I am not very sure how the game treat variables, but when I check the game’s installation folder, I found a lot of .json files, JSON stands for JavaScript Object Notation and is stored like .txt files. I’m not sure how the game use these files, but none of the file contain number with more than 1 decimal place.

Some languages will slow down if there is too many float points, I am not sure in what language the game is written so I cannot confirm that it will slow down, but I believe it is likely to (slow down). 

Also, 1.4 is 1.01% different from root 2, 1.01% per unit, this will stack up to a lot, in a close game, this might determine win or lose. 

So, they contain numbers with at least 1 decimal place? Then, it’s already no integer anymore :grinning:

 

Again, whether you take 1.4 or 1.41 or 1.414… is not the important thing to discuss here, as this is a tiny detail that is part of implementing, and implementing things is flaregames’ job. The thing to discuss here is really whether such a 1.4(14…) value would be supposed to make sense at all, or if the overall concept of mega units would make sense at all, not what number formats to use. And, really having 1 or 5 decimal spaces is INDIFFERENT COMPLETELY for the computer, so they can get close enough to “exact precision” for it not to matter at all in practice. Especially as numerical inaccuracy might then make sth like 0.0001% difference, while non-numerical effects such as “area damage vs single target damage”, spells, group dynamics etc etc can make a difference of like 100%. 

And concerning the speed thing… on modern hardware, the speed difference between int and float is hardly your concern when programming a game, really… and on some hardware, float even may be faster than int, but anyway, the differences there depend on many different things and are so little that many other things are many magnitudes bigger and more important for performance. Also, seeing what problems most commonly arise when playing RR2 - too few memory on low-end phones, connection problems, general bugs that affect anyone independent of his hardware specs and speed the game runs at on the hardware - it’s definitely nothing to worry about. And, as mentioned above, they most likely use float anyway already… 

 

Back to original topic, any further opinions on the original suggestions rather than on premature optimization? 

Just saying, defining new data types means the computer either can’t use his inbuilt optimization stuff for the standard data types (e.g. int, float), or you only construct a wrapper around existing types, and each wrap costs performance… and a float operation takes as long as it takes, no matter how many decimal places you have in the human-readable number. 

 

I don’t know RR2’s source code, but seeing they reduce visual quality of some parts of the game (e.g. hero item shaders, animation of troops in academy, …) for lower-end devices, the memory consumption and graphics rendering stuff is probably the most performance-heavy part, and not doing a few single float number calculations :grinning:

 

And again, that’s not the topic even. 

 

If you have nothing reliable at all, and nothing on topic, don’t reply… or at some point I might just start to be a good mod and remove all your offtopic posts. 

Again, you just say it costs you speed and precision, but even a large portion of the content of the sources you link state that there’s no significant/relevant performance loss, except if you play on your toaster (which you probably don’t do nor want) or on 5 year old, very cheap non-smart cellphones - where you can’t even play RR2 nor other modern apps at all. 

 

And true, float multiplication is likely a bit slower than int.

But on the other hand, integer division is damn slow, slower than floats. In some cases, even converting the int to float, then doing float division, then converting back, is faster. Plus, with int you lose the remainder, obviously, and thus precision. 

 

Also, just saying again, any int vs float differences are generally in by far the most cases not the thing that ruins your performance.

Also, if you want pure efficience, you better program all your code in assembler directly, instead of using additional layers of more abstracted programming languages on top of that, not even to speak of things like using a complex engine that is not specifically built and optimized for your concrete game… 

 

 

And, most important, you’re missing the whole point of this topic, which is NOT whether square root of 2 is better or worse than 1.4, but whether or not stronger, “mega units” make sense. So, if you want, open a topic on some other forum, or here on the offtopic section that discusses “float vs int” but not discuss that here. Next offtopic post will be deleted.