Show us yer programming projects!
My view is there should be no such thing as cheating.KlaxonCow wrote:Yes. As is often the case, the "advantage" of a physics engine is simultaneously its "disadvantage" too._TinOmen_ wrote:As you say, a good physics engine give the potential for unexpected things to happen. Perhaps that could be seen as a problem in Zelda because of its very linear nature. The game designers wants to have exact control of what the player can do.
"Unexpected things happening" is good from a "varied gameplay" perspective but it's not so good from a level designer's perspective, who now has to take extra care to ensure they don't unintentionally create either an impossible situation or an accidental "cheat"..
If it can be done with the physics of the game, then you should be able to do it. Its not cheating, its merely another solution.
Creative thinking should be rewarded.
So yes, I agree, trigger events should be made more genic/robust.
Purhapes avoided completely in some situations if the designers are really brave.
(that is, the very fact the player has the objects means they can go to the next bit, the very landscape and layout dictates the events with a minimum of scripted/triggered events)
I think it should be the level designers job to give at least one possible solution, as well as ensure theres no obviously easier ways to do something.
Of course, you always need a safty net for if all else fails.
In Zelda, this could be an item called "Wand of Reset", which simply resets a room to its starting position. (save for anything already collected).
It would be a bit nicer then a sucided button, and could be used in puzzles itself too.
-
want to read eye-wateringly bad stories? No? Ok.
want to read eye-wateringly bad stories? No? Ok.
- teamonkey
- Sheepie Whore

- Posts: 12082
- Joined: Thu Jun 13, 2002 1:07 am 0
- XBL Gamertag: itsthetaste
- PSN: teamonkey_ca
- Contact:
Most physics algorithms produce different results when played backward (I can't remember what that effect is called at this time in the morning). It's actually really hard to reverse the state of a physics engine properly, because it's not just a case of entering a negative time step. If you want it to have some kind of deterministic outcome (like going back to the state things were in a few seconds ago) you not only have to call all the physics procedures in reverse order, the procedures themselves have to be written backwards with the inverse mathematical functions. The games that do it effectively like Sands of Time cheat massively.failrate wrote:If you build your game with a deterministic replay system, then rewinding it should be a piece of piss.
This is true. You can reverse pure newtonian mechanics quite easily, but as soon as you have things like damping terms then things get quite hairy.
For example: The inverse of a damping term is often an exponential increase in velocity over time. It doesn't take many time steps for minor numerical errors to lead to major differences in outcome.
And that is before you even think about things like random events and fudge factors...
For example: The inverse of a damping term is often an exponential increase in velocity over time. It doesn't take many time steps for minor numerical errors to lead to major differences in outcome.
And that is before you even think about things like random events and fudge factors...
Don't forget to factor things like rounding errors into the mix too.
Mathematics is defined with theoretically infinite precision. But in all practical situations - be that on computer or even on paper - that's impossible to achieve because you don't have infinite time and infinite storage at your disposal.
Rather you have a far more modest 32-bits for a "float" and 64-bits for a "double" (or something equivalent to that, as I'm just using "typical" examples from what your average 32-bit Intel-based C compiler tends to default to using. Although, technically, C does not actually rigidly define what size a "float" or "double" is, except that a "double" can't be less than a "float". Interestingly, though, this definition does allow to be the same size).
Now, to give you an example why finite precision arithmetic can cause you issues, we'll take a very simple decimal-based "on paper" example.
Dividing 1.0 by 3.0 produces 0.333333333... (where the "..." means that those 3s are theoretically recurring for infinity).
Well, I don't have infinite room to write that down, so I've got to round it to the finite room I do actually have (which, simply for illustration purposes, we'll assume to be 5 decimal places).
This gives me 0.33333 (and, this time, it stops right there and is not infinitely recurring anymore because it's been rounded into the available space).
So now let's try to reverse what we just did.
We divided by 3, so multiplying by 3 will, "of course", get us back to the original value (except, in fact, you've already worked out, no doubt, that it won't).
0.33333 * 3 = 0.99999
As the saying goes:"Close. But no cigar".
Note that as you increase precision, you get closer and closer to the correct answer of "1.0" but it's never exactly 1.0 unless you're working with infinite precision (which, in practice, cannot ever be achieved).
The proverbial "butterfly" just flapped his wings.
And if we're already encountering issues reversing something so simple and mundane as dividing a number by 3 (which is hardly "complex number differential calculus") then, yes, these little butterflies flapping their wings will accumulate and accumulate error upon error until, eventually, we're reaping a tornado.
Worse, it's all implementation-dependent too because you'll notice that what number base you're using to represent your values actually makes a big difference. While base 10 and base 2 both find it a total bugger to store "one third", base 3 has no problems at all representing it (e.g. it's just "0.1" in base 3).
A floating point value you enter into your program which looks quite "neat" or "round" in decimal could be an absolute nightmare to represent in binary (which is, of course, the number base it will be stored and manipulated in by the actual computer).
Worse still, the order of operations can also make a big difference. If you swap the order around and multiply by 3 first then divide by 3 instead, then that's basic integer maths which need not go near a single fractional digit and suffers no such problem.
Depending on the numbers and operations involved, you might find that if you do things in one particular order you get an overflow / underflow and lose precsion in your answers. But just changing the order the operations are performed in, the overflow / underflow is avoided and you get not only a very slightly different answer but one with more precision than the other.
The bottom line being that all finite precision mathematics is actually inherently "lossy".
And, looking at your typical 3D engine, using floating-point for vertices, using floating point for translations, rotations and scaling, using floating-point for physics calculations, etc. and normally applying its operations cumulatively (so the creeping "error" is magnified by constant iteration) then you've got yourself a recipe for "butterfly soup" right there.
No, don't try to "reverse physics". Not least because, in addition to all that above, reversing a long series of events backwards is going to take some time and what are you going to do? Print "Please wait. Currently reversing time" with a progress bar underneath it?
If you need to go backwards then the far simpler implementation is to take a "snapshot" at that earlier time - recording where everything was and what state it was in somewhere - and then just "jump" to the snapshot by simply overwriting the current situation with whatever's in the snapshot. A cold, hard overwrite.
This requires more storage space for these "snapshots", admittedly, but it guarantees you that you can jump back to an earlier time exactly how it was (because that was exactly how it was. You recorded it!).
Much easier with guaranteed results.
Mathematics is defined with theoretically infinite precision. But in all practical situations - be that on computer or even on paper - that's impossible to achieve because you don't have infinite time and infinite storage at your disposal.
Rather you have a far more modest 32-bits for a "float" and 64-bits for a "double" (or something equivalent to that, as I'm just using "typical" examples from what your average 32-bit Intel-based C compiler tends to default to using. Although, technically, C does not actually rigidly define what size a "float" or "double" is, except that a "double" can't be less than a "float". Interestingly, though, this definition does allow to be the same size).
Now, to give you an example why finite precision arithmetic can cause you issues, we'll take a very simple decimal-based "on paper" example.
Dividing 1.0 by 3.0 produces 0.333333333... (where the "..." means that those 3s are theoretically recurring for infinity).
Well, I don't have infinite room to write that down, so I've got to round it to the finite room I do actually have (which, simply for illustration purposes, we'll assume to be 5 decimal places).
This gives me 0.33333 (and, this time, it stops right there and is not infinitely recurring anymore because it's been rounded into the available space).
So now let's try to reverse what we just did.
We divided by 3, so multiplying by 3 will, "of course", get us back to the original value (except, in fact, you've already worked out, no doubt, that it won't).
0.33333 * 3 = 0.99999
As the saying goes:"Close. But no cigar".
Note that as you increase precision, you get closer and closer to the correct answer of "1.0" but it's never exactly 1.0 unless you're working with infinite precision (which, in practice, cannot ever be achieved).
The proverbial "butterfly" just flapped his wings.
And if we're already encountering issues reversing something so simple and mundane as dividing a number by 3 (which is hardly "complex number differential calculus") then, yes, these little butterflies flapping their wings will accumulate and accumulate error upon error until, eventually, we're reaping a tornado.
Worse, it's all implementation-dependent too because you'll notice that what number base you're using to represent your values actually makes a big difference. While base 10 and base 2 both find it a total bugger to store "one third", base 3 has no problems at all representing it (e.g. it's just "0.1" in base 3).
A floating point value you enter into your program which looks quite "neat" or "round" in decimal could be an absolute nightmare to represent in binary (which is, of course, the number base it will be stored and manipulated in by the actual computer).
Worse still, the order of operations can also make a big difference. If you swap the order around and multiply by 3 first then divide by 3 instead, then that's basic integer maths which need not go near a single fractional digit and suffers no such problem.
Depending on the numbers and operations involved, you might find that if you do things in one particular order you get an overflow / underflow and lose precsion in your answers. But just changing the order the operations are performed in, the overflow / underflow is avoided and you get not only a very slightly different answer but one with more precision than the other.
The bottom line being that all finite precision mathematics is actually inherently "lossy".
And, looking at your typical 3D engine, using floating-point for vertices, using floating point for translations, rotations and scaling, using floating-point for physics calculations, etc. and normally applying its operations cumulatively (so the creeping "error" is magnified by constant iteration) then you've got yourself a recipe for "butterfly soup" right there.
No, don't try to "reverse physics". Not least because, in addition to all that above, reversing a long series of events backwards is going to take some time and what are you going to do? Print "Please wait. Currently reversing time" with a progress bar underneath it?
If you need to go backwards then the far simpler implementation is to take a "snapshot" at that earlier time - recording where everything was and what state it was in somewhere - and then just "jump" to the snapshot by simply overwriting the current situation with whatever's in the snapshot. A cold, hard overwrite.
This requires more storage space for these "snapshots", admittedly, but it guarantees you that you can jump back to an earlier time exactly how it was (because that was exactly how it was. You recorded it!).
Much easier with guaranteed results.
"Words ought to be a little wild - for they are assaults of thought on the unthinking."
- John Maynard Keynes
- John Maynard Keynes
I think you're referring to "entropy", yes?teamonkey wrote:Most physics algorithms produce different results when played backward (I can't remember what that effect is called at this time in the morning).
If they've got any sense then they don't "reverse" a single thing.teamonkey wrote:It's actually really hard to reverse the state of a physics engine properly, because it's not just a case of entering a negative time step. If you want it to have some kind of deterministic outcome (like going back to the state things were in a few seconds ago) you not only have to call all the physics procedures in reverse order, the procedures themselves have to be written backwards with the inverse mathematical functions. The games that do it effectively like Sands of Time cheat massively.
The easier implementation is just to record "snapshots" of everything that happens as it happens and then if you need to "go back in time" then just play the snapshots in reverse.
Note that you don't necessarily have to record every single little thing either. You could have "sparse snapshots" that only bother to take a record when something significant happens to a particular entity. If an object just sits there then there's no need to constantly record it doing nothing.
Take an initial "snapshot" of it sitting there (and time-stamp it) and then only bother adding more "snapshots" to that entity's "history" should it move.
The player's character will likely consume the most to record its history but, even there, you can take the "snapshots" only at points where something specifically changes (e.g. the player presses the jump button, the player releases the jump bitton, etc.) and record the history of all the various entities in the game using an "event-based" approach.
If the player walks in a straight line then you only need record the starting point and the ending point. You can interpolate all the rest from that.
What with entropy, chaos theory, numerical precision / rounding errors and probably a few other things I haven't even thought of yet, the basic idea of genuinely "reversing physics" and expecting to get yourself back to exactly the point you started from is, well, probably not the best way to go about the problem.
Note that, due to creeping "error", that even a wholly deterministic system following simple rules cannot necessarily be easily "reversed".
In fact, if you want absolutely 100% precision to return to an absolutely identical situation as you started from (without employing "cheats", "snapshots" or "corrections" or some similar device) with such a method, then entropy, chaos theory and rounding errors all line up and sing "it's impossible!" in perfect sweet harmony with each other.
The classic illustration of entropy with physicists tends to be the china plate example. You can drop a china plate, letting it fall crashing to the ground, where it shatters into a million pieces.
But you can't unsmash that plate simply by feeding a negative number into your "gravity" equations.
If you take two shattered pieces of the plate and push them together then they will not simply "fuse" back together. Atomic and chemical bonds were broken. Permanently.
Some of the energy from the fall was translated into sound - the smashing sound itself - which has long since echoed and decayed itself out of existence. How are you going to recover what it exactly sounded like to restore its exact energy signature in order to put it back into the energy equation to ensure that you're not losing a single piece of it, so that it correctly adds up to 100% of the original energy that was present?
The point with entropy is basically that the whole universe is inherently "lossy". They like to measure a system in terms of its "information" and then can prove that "information is lost" in the system in a permanently unrecoverable way.
"This is the way the world ends
Not with a bang but a whimper."
- T.S. Eliot
Basically, time really does have a "directionality" to it. The "wood grain" runs in a particular direction. Not all processes are necessarily symmetrical or reversible (or even if they theoretically are then it may still be practically impossible, due to such things as mentioned earlier about maths only being completely accurate when used with infinite precision, which is not physically achievable).
It might work for Doctor Who to simply "reverse the polarity of the Tachyon flow", in order to "undo" anything he likes. But, in the real world, "some mistakes are built to last".
After all, according to evolutionary theory, we are all the result of a long series of copying mistakes (e.g. "mutations") that has accumulated over a few billions of years. So maybe a small amount of "error" from time to time isn't always necessarily a bad thing.
"Words ought to be a little wild - for they are assaults of thought on the unthinking."
- John Maynard Keynes
- John Maynard Keynes
- teamonkey
- Sheepie Whore

- Posts: 12082
- Joined: Thu Jun 13, 2002 1:07 am 0
- XBL Gamertag: itsthetaste
- PSN: teamonkey_ca
- Contact:
I was thinking of "directionality" which you used later.KlaxonCow wrote:I think you're referring to "entropy", yes?teamonkey wrote:Most physics algorithms produce different results when played backward (I can't remember what that effect is called at this time in the morning).
Entropy's not really a problem. Chaotic effects are, mainly as a side effect of fixed numerical accuracy, but they're not necessarily down to entropy. In fact, since you have complete control over the simulation you can happily add or remove energy into the system as required.
The biggest problem is none of these factors. The biggest problem is that the non-linear equations used in the simulation are not mathematically identical with time running forward and with time running backward, in fact they'll often be quite different. So even if chaotic effects are nil, accuracy is perfect and all that, then if you run the equations forward and then back by the same amount of time you'll still end up in a completely different spot to where you started.KlaxonCow wrote:In fact, if you want absolutely 100% precision to return to an absolutely identical situation as you started from (without employing "cheats", "snapshots" or "corrections" or some similar device) with such a method, then entropy, chaos theory and rounding errors all line up and sing "it's impossible!" in perfect sweet harmony with each other.
"NesDS" emulator on the DS does this amazingly well, and can rewind upto a few minutes.
The easier implementation is just to record "snapshots" of everything that happens as it happens and then if you need to "go back in time" then just play the snapshots in reverse.
However, Its going to be heavily based on ram requirements.
===
hmz."This is the way the world ends
Not with a bang but a whimper."
- T.S. Eliot
What if we cover the universe in Dyson spheres, and convert the energy generated to mass.
Assuming gravity doesn't "run out", would this not force a big crunch situation?
[/random idea]
Seeing as Multivac hasnt come up with an answer yet, its the only idea Ive got
-
want to read eye-wateringly bad stories? No? Ok.
want to read eye-wateringly bad stories? No? Ok.
Yeah, well, it's all relative, isn't it?GoatFoam wrote:Time isn't really directional. It appears to be because our perception is based on entropic processes, and entropy seems to be directional.
Maybe time goes backwards and the universe is anti-entropic but because our perception is backwards, we see it the other way around.
Or you could say that time doesn't go anywhere - all of spacetime is a multi-dimensional solid - and our perception is just a series of cross-sections of this solid.
Or maybe...or maybe...or maybe...
That's relativity for you. It all depends on your "frame of reference".
Is the glass half full or is it half empty? Is "a smile just a frown that's been turned upside-down" or is that a really annoying saying and you're going to punch the next bastard who says it in the face?
It's all relative, ain't it?
"Words ought to be a little wild - for they are assaults of thought on the unthinking."
- John Maynard Keynes
- John Maynard Keynes
First off, I only work with Jakobsen physics. I don't have the time or patience for springs, dampening, etc.
Secondly, snapshots are too expensive unless you make the gameplay work in discrete slices. In that case, you can just capture the state of the ego and that one room.
Third, a deterministic replay system does not assume that you are just winding the tape backwards. It is much more akin to an Undo function. Given a vector of instructions, you can rebuild the state from the last checkpoint to the requested position in time.
Don't take my word for it, though:
http://www.gamasutra.com/features/20040 ... r_01.shtml
This article sums it up much more elegantly than I could.
Secondly, snapshots are too expensive unless you make the gameplay work in discrete slices. In that case, you can just capture the state of the ego and that one room.
Third, a deterministic replay system does not assume that you are just winding the tape backwards. It is much more akin to an Undo function. Given a vector of instructions, you can rebuild the state from the last checkpoint to the requested position in time.
Don't take my word for it, though:
http://www.gamasutra.com/features/20040 ... r_01.shtml
This article sums it up much more elegantly than I could.
Well, that's what I was getting at with the "event-based approach" part I was talking about to reduce the storage requirements. Though, admittedly, your term "discrete slices" is probably the eloquently concise way of describing it.failrate wrote:Secondly, snapshots are too expensive unless you make the gameplay work in discrete slices.
Yes, if you were going to use the "snapshot" approach then, as a naive approach of just constantly saving the state of everything all the time would eat through RAM like it was going out of fashion, you should use every approach to reduce the storage requirements.failrate wrote:In that case, you can just capture the state of the ego and that one room.
The "event-based" approach I was talking about is to only bother to record significant actual changes. As presumably nothing (or, at least, very little) happens in rooms that the player isn't currently in then what I was suggesting implicitly only records what's going on in that particular room anyway (because no "events" - or, at least, very little "events" - would be happening elsewhere).
It depends on how you want to structure your engine, really.
"Words ought to be a little wild - for they are assaults of thought on the unthinking."
- John Maynard Keynes
- John Maynard Keynes
Which of course all depends on the game.
One situation that could work in many games would be just to look for "critial states" and "undo" to them, but use simple low res jpeg/frame grabs with a spiffy special effect to make it look like its rewinding.
Seeing as the time forward/backward amounts to exactly the same thing in terms of what we experience, it seems more helpful to view space time as a solid containing all possible states.
What we observe, our consciousness, merely experiences a cross sectional volume of the multidimensionally higher object.
One situation that could work in many games would be just to look for "critial states" and "undo" to them, but use simple low res jpeg/frame grabs with a spiffy special effect to make it look like its rewinding.
This is my preferance.
Or you could say that time doesn't go anywhere - all of spacetime is a multi-dimensional solid - and our perception is just a series of cross-sections of this solid.
Seeing as the time forward/backward amounts to exactly the same thing in terms of what we experience, it seems more helpful to view space time as a solid containing all possible states.
What we observe, our consciousness, merely experiences a cross sectional volume of the multidimensionally higher object.
-
want to read eye-wateringly bad stories? No? Ok.
want to read eye-wateringly bad stories? No? Ok.
Yes. Entropy is a meatspace thing, not a cyberspace thing.teamonkey wrote:Entropy's not really a problem. Chaotic effects are, mainly as a side effect of fixed numerical accuracy, but they're not necessarily down to entropy.
It's real world physics rather than game engine physics.
In hindsight, maybe I shouldn't have mentioned it at all, lest cause confusions.
Because though entropy has nothing to do with a game engine, chaos is something you do need to be wary of (as chaos is an inescapable mathematical reality and effects meatspace and cyberspace - and, quite frankly, any kind of space - equally).
And maybe mentioning them both so close together might be confusing that I might have been implying a connection from their nearby juxtapositioning. But no connection was intended to be implied.
Entropy is one thing and has nothing to do with game engine physics. While chaos is something completely different and can have an effect on your game engine if you're not wary of it.
I did mention them in two separate posts, you'll notice, but they were one directly after the other that the mental separation I had in my brain about it might not have come through on the page here.
Just to clear that up, in case there was a confusion about it.
"Words ought to be a little wild - for they are assaults of thought on the unthinking."
- John Maynard Keynes
- John Maynard Keynes



