Yes, although I'd kind of prefer multiple sprites to a single sprite in general.Zeblote wrote:Maybe the smoke sprites themselves are just white and it's possible to re-color them for different things? That'd be fantastic.
Friday Facts #108 - Unexpected Features
-
- Long Handed Inserter
- Posts: 97
- Joined: Tue Oct 28, 2014 3:33 pm
- Contact:
Re: Friday Facts #108 - Unexpected Features
Re: Friday Facts #108 - Unexpected Features
I just wanted to leave this here:
http://www.netlib.org/fp/dtoa.c
If you're going to write your own print formatting (printf replacement), you'll need a way to output floating point values. It probably won't surprise you that this part is harder than everything else put together! I haven't experimented to much with that link, but it is a liberally licensed method for converting floating point values to strings. It is claimed to be (1) fast and (2) accurate. If you do decide to go that way, I hope that this might help you . I have also had to rewrite output code (in my case, I had to rewrite the C++ streams so that they would work across DLL boundaries for incompatible compiler settings), and if I hadn't been able to get sprintf working acceptably, this would have been my next resort. Good luck, those floats are a beast!
http://www.netlib.org/fp/dtoa.c
If you're going to write your own print formatting (printf replacement), you'll need a way to output floating point values. It probably won't surprise you that this part is harder than everything else put together! I haven't experimented to much with that link, but it is a liberally licensed method for converting floating point values to strings. It is claimed to be (1) fast and (2) accurate. If you do decide to go that way, I hope that this might help you . I have also had to rewrite output code (in my case, I had to rewrite the C++ streams so that they would work across DLL boundaries for incompatible compiler settings), and if I hadn't been able to get sprintf working acceptably, this would have been my next resort. Good luck, those floats are a beast!
Re: Friday Facts #108 - Unexpected Features
The new smoke graphics look totally awesome!
By the way... is there anything planned, like making the light sources (furnaces, boilers, ...) "shine through" a bit more?
By the way... is there anything planned, like making the light sources (furnaces, boilers, ...) "shine through" a bit more?
Re: Friday Facts #108 - Unexpected Features
You should be using %f at least... not %g
Though on the other hand, if you use C++ output methods instead of C. you should run into greater compatibility across platforms.
Though on the other hand, if you use C++ output methods instead of C. you should run into greater compatibility across platforms.
Re: Friday Facts #108 - Unexpected Features
Love the smoke! And the blueprint book. Release it noowwww!!1
OS: Linux Mint 19 x64 | desktop: Awesome 4.2 | Intel Core i5 8600k | 16GB DDR4 | NVidia GTX 1050 Ti (driver version: 410.104) (2019-03)
Re: Friday Facts #108 - Unexpected Features
Bah, floats are way overused. Pretty much every relevant number can be best represented with an integer or decimal shifted integer. No rounding errors, no magic glitches, no weirdness at extreme ranges. Just good solid numbers from start to finish. Managing inventory values? Use an integer. Dealing with damage values? Decimal shifted integer. Time values? You bet integers are involved. Want to map out every single millimeter from the core of the sun all the way out to pluto? Yeah. That's a 64 bit integer.
The only reason to use floats is if you have a fetish for debugging that NEW STRANGE thing it's screwing up now. Also there's that whole thing about maximizing CPU registers at the ultra high end, because for some circular reason CPUs keep getting loaded with FPUs because people keep overusing floats.
The only reason to use floats is if you have a fetish for debugging that NEW STRANGE thing it's screwing up now. Also there's that whole thing about maximizing CPU registers at the ultra high end, because for some circular reason CPUs keep getting loaded with FPUs because people keep overusing floats.
Re: Friday Facts #108 - Unexpected Features
That's your opinion.
Mine is, that floats are really practical, if you want to measure something and keep the relative precision small.
For example, measuring distances in millimeter is nice, but when you want to measure the distance to Pluto, I doubt, that it is possible/needed, while when I want to measure the thickness of my hair it is really unpractical.
Integers can be used to COUNT stuff, not to measure.
Mine is, that floats are really practical, if you want to measure something and keep the relative precision small.
For example, measuring distances in millimeter is nice, but when you want to measure the distance to Pluto, I doubt, that it is possible/needed, while when I want to measure the thickness of my hair it is really unpractical.
Integers can be used to COUNT stuff, not to measure.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
-
- Filter Inserter
- Posts: 952
- Joined: Sat May 23, 2015 12:10 pm
- Contact:
Re: Friday Facts #108 - Unexpected Features
The hardest part with fixed point math is choosing your range and avoiding over/underflow in the temporary values. Floats will auto shift to keep as many bits as possiblebobucles wrote:Bah, floats are way overused. Pretty much every relevant number can be best represented with an integer or decimal shifted integer. No rounding errors, no magic glitches, no weirdness at extreme ranges. Just good solid numbers from start to finish. Managing inventory values? Use an integer. Dealing with damage values? Decimal shifted integer. Time values? You bet integers are involved. Want to map out every single millimeter from the core of the sun all the way out to pluto? Yeah. That's a 64 bit integer.
The only reason to use floats is if you have a fetish for debugging that NEW STRANGE thing it's screwing up now. Also there's that whole thing about maximizing CPU registers at the ultra high end, because for some circular reason CPUs keep getting loaded with FPUs because people keep overusing floats.
Re: Friday Facts #108 - Unexpected Features
Deep down floats are two integers (mantissa and exponent). That is not the problem. The problem arises due to strange behavior when using floats. For example when adding three numbers a+b+c is not always equal to b+c+a. Guess what optimizing compilers do? The may change the order of operations if you don't explicitly forbid that. Also there are many different kinds of floats. IEEE754-floats, 32bit (single precision), 64bit (double precision), internal representation in x86 CPUs (80bit long double), denormalized numbers, algorithms of different accuracy (+-1bit doesn't really matter in most calculations).ssilk wrote: ....
Mine is, that floats are really practical, if you want to measure something and keep the relative precision small.
....
Integers can be used to COUNT stuff, not to measure.
Fixed point integers are like floats with a more defined beavior since you use well defined integer operations on all platforms. The downside is that you must think before calculating. How many bits do you need? What is the smallest and biggest number you need to represent? This is inconvenient but in certain situations it's better (faster, more reliable, more precise, less effort when porting to exotic architectures) than using floats.
The problem with printf is similar with fixed and floating point numbers. You are trying to represent a base-2 fractional number in base-10. It would be very easy to write the binary representation 1234*2^-12 (after all it's just two integers) but that's hard to read for humans, so the conversion to m*10^x is needed. It is not possible to do this exactly with a finite number of decimal places. You have to break off at some point (depending on the float precision) and you have to do the conversion right (considering all the rounding effects happening when you calculate the decimal places). Then when reading data you need to reassemble your floating point number from the decimal places also considering all tiny rounding effects so that no bit gets flipped everywhere for any possible number.
-
- Long Handed Inserter
- Posts: 97
- Joined: Tue Oct 28, 2014 3:33 pm
- Contact:
Re: Friday Facts #108 - Unexpected Features
In which case the compiler is buggy. I quote:ske wrote:Guess what optimizing compilers do? The may change the order of operations if you don't explicitly forbid that.
There are many potential pitfalls with floats. That is not one of them (at least with sane languages). It's things like transcendental functions that are generally the problem.5.1.2.3 Program execution
[#1] The semantic descriptions in this International Standard describe the behavior of an abstract machine in which issues of optimization are irrelevant.
[#3] In the abstract machine, all expressions are evaluated as specified by the semantics.
[#13] EXAMPLE 5 Rearrangement for floating-point expressions is often restricted because of limitations in precision as well as range. The implementation cannot generally apply the mathematical associative rules for addition or multiplication, nor the distributive rule, because of roundoff error, even in the absence of overflow and underflow.
Re: Friday Facts #108 - Unexpected Features
Interesting. That would mean that technically, in C++ an expression like:The implementation cannot generally apply the mathematical associative rules for addition
Code: Select all
a+b+c
*Explanation: Strictly speaking, expressions like a+b+c have no meaning, because + is a binary operation, acting on two, and only two terms at a time. The rule of associativity tells us that (a+b)+c = a+(b+c) (This is well defined because each + only acts on two terms), and so a+b+c can be safely assumed to be any of those two options.
Edit: If I understand correctly, either the designers of C++ or the implementers of C++ compilers chose to simply leave this as something the programmer has to keep in mind and deal with. *sigh*.
-
- Long Handed Inserter
- Posts: 97
- Joined: Tue Oct 28, 2014 3:33 pm
- Contact:
Re: Friday Facts #108 - Unexpected Features
It's... complicated:
Of course, you have to be careful about FLT_EVAL_METHOD and FP_CONTRACT. But meh.
The grammar indicates that a*b*c is parsed as (a*b)*c.
6.5 Expressions
943 The grouping of operators and operands is indicated by the syntax.72)
951 72) The syntax specifies the precedence of operators in the evaluation of an expression, which is the same as the order of the major subclauses of this subclause, highest precedence first.
952 Thus, for example, the expressions allowed as the operands of the binary + operator (6.5.6) are those expressions defined in 6.5.1 through 6.5.6.
954 Within each major subclause, the operators have the same precedence.
955 Left- or right-associativity is indicated in each subclause by the syntax for the expressions discussed therein.
6.5.5 Multiplicative operators
1143
multiplicative-expression:
cast-expression
multiplicative-expression * cast-expression
multiplicative-expression / cast-expression
multiplicative-expression % cast-expression
Of course, you have to be careful about FLT_EVAL_METHOD and FP_CONTRACT. But meh.
-
- Filter Inserter
- Posts: 952
- Joined: Sat May 23, 2015 12:10 pm
- Contact:
Re: Friday Facts #108 - Unexpected Features
It's very well defined in the operator priority rules actually (left to right).sillyfly wrote:Interesting. That would mean that technically, in C++ an expression like:The implementation cannot generally apply the mathematical associative rules for addition(where a,b,c are floats or doubles) is undefined*, and therefore should result in a compilation error, but as far as I know this it never the case.Code: Select all
a+b+c
*Explanation: Strictly speaking, expressions like a+b+c have no meaning, because + is a binary operation, acting on two, and only two terms at a time. The rule of associativity tells us that (a+b)+c = a+(b+c) (This is well defined because each + only acts on two terms), and so a+b+c can be safely assumed to be any of those two options.
Edit: If I understand correctly, either the designers of C++ or the implementers of C++ compilers chose to simply leave this as something the programmer has to keep in mind and deal with. *sigh*.
Any optimization that would use floating point associativity is typically opt-in with a -fastmath flag to the compiler.
Re: Friday Facts #108 - Unexpected Features
+1DOSorDIE wrote:...and of course with a option to deactivate.
Re: Friday Facts #108 - Unexpected Features
One thing that came to mind after seeing the "Blueprint Book" was, if you could implement a "Repair Bag" or something alike, where all items go to that you pick up and are damaged, since those cannot (atm) be stacked in an inventory and it is a bit frustrating that "damaged" entities can easily take up a lot of space in your inventory.
-
- Long Handed Inserter
- Posts: 97
- Joined: Tue Oct 28, 2014 3:33 pm
- Contact:
Re: Friday Facts #108 - Unexpected Features
Or just a way to queue repairs for things in your inventory...Jaridan wrote:One thing that came to mind after seeing the "Blueprint Book" was, if you could implement a "Repair Bag" or something alike, where all items go to that you pick up and are damaged, since those cannot (atm) be stacked in an inventory and it is a bit frustrating that "damaged" entities can easily take up a lot of space in your inventory.
- Karosieben
- Long Handed Inserter
- Posts: 58
- Joined: Sun Aug 31, 2014 9:21 pm
- Contact:
Re: Friday Facts #108 - Unexpected Features
I like the new smoke.
Also this blueprint books looks really nice. Would be handy for my Season 2
Keep going, guys. Factorio gets better and better!
Also this blueprint books looks really nice. Would be handy for my Season 2
Keep going, guys. Factorio gets better and better!
My german YouTube Channel: Karosieben
My Factorio Let's Plays: Singleplayer, Multiplayer and Tutorials
My Factorio Let's Plays: Singleplayer, Multiplayer and Tutorials
Re: Friday Facts #108 - Unexpected Features
In this case I stand corrected.ratchetfreak wrote: It's very well defined in the operator priority rules actually (left to right).
Any optimization that would use floating point associativity is typically opt-in with a -fastmath flag to the compiler.
What I remember though is that excess precision may still be an issue and -ffloat-store must be used on x86:
manual page of gcc wrote:Code: Select all
-ffloat-store Do not store floating point variables in registers, and inhibit other options that might change whether a floating point value is taken from a register or memory. This option prevents undesirable excess precision on machines such as the 68000 where the floating registers (of the 68881) keep more precision than a double is supposed to have. Similarly for the x86 architecture. For most programs, the excess precision does only good, but a few programs rely on the precise definition of IEEE floating point. Use -ffloat-store for such programs, after modifying them to store all pertinent intermediate computations into variables.
Re: Friday Facts #108 - Unexpected Features
#betterSmokeInFactorio
Re: Friday Facts #108 - Unexpected Features
I hasn't broken any of the mods i have, (except 1, the clock from bobs mods), but something really annoying is that all the names of stuff say entity:name:name of thing instead of the normal name, can u fix it soon, because its really annoying, and waiting an entire week seems like soooooooo long, also before friday facts came out on friday like at 1 pm, now the come out at like 1 am.... of the next day, Please Fix, thumbs up for the smoke graphics