Author Topic: Jumping Fireballs Safely/Fireball Behavior  (Read 5613 times)

0 Members and 1 Guest are viewing this topic.

Offline marinomitch13

  • Moderator
  • Spring Jumper
  • *
  • Posts: 1792
    • How to Play DK
Jumping Fireballs Safely/Fireball Behavior
« on: July 11, 2013, 10:04:09 PM »
So, here is my theory on fireballs that I came up with partially on my own (but also partially due to Dean Saglio explaining to me how it might work with the code and confirming that he had similar suspicions). Hopefully the code, once examined, proves us correct! :D

1) Fireballs have variable speed -this is due probably to something having to do with the different graphic animations during specific frames, but it also might just be simply due to a RNG with a small range of possibilities- but the main point is that they can travel at ever-changing speeds in either direction. However, there may be something in the code that triggers either a longer lasting 'slow' mode or 'fast' mode (ever seen those fireballs that just seem to immediately speed up and hunt you down in the exact same spot every almost every time they do ;) )

2) Fireballs generally travel faster to the right (just somethin to keep in mind)

3) Fireballs must travel for a certain number of frames before they can turn around. At the point at which they can turn around, a RNG determines if they actually do. I'll call these 'decision points'.

4) Since there is a usually only a very small variation in the speed for fireballs, it is usually the case that these 'decision points' are correlated with a pretty standard distance -I haven't measured this exactly, but I think it is about the distance of 1.5-2 girder sub-sections on the barrel board. For my own sake, I like to judge by distance (even though it is slightly less accurate) simply because it seems more manageable to my senses than trying to calculate the result of changing speed over time.

5) Since fireballs can only turn around at these 'decision points', one has to jump them in between these points for the highest chance of survival. I think that the safest time to jump fireballs is, as fast as you can, immediately after they turn around.

6) However, the longer a fireball remains traveling in the same direction without turning around, the harder it will become to judge when you should jump them (because, if you are thinking about their 'decision points' in terms of a general distance with a little bit of variable range, the farther out from their last turn around, the 'variable range' -which is ultimately due to their inconstant speed- gets added to itself for each added length before the next 'decision point'. Hence, the certainly-safe-area-to-jump-them becomes smaller and smaller (as far as the player can be certain).

Text-picture example (X= a decision point, in terms of distance, with a little range of variance due to lack of precise knowledge):

_______X______XX_____XXX____XXXX___XXXXX__XXXXXX_XXXXXXXXXXXXXXXX.....

7) Cautions: There do see to be certain places where fireballs do this quick 'turn around'. I'm not sure what causes this, but I think it is more frequent when a fireball either immediately lands after coming out of the oil can, hits a ledge/end of a girder/platform, or finishes climbing or descending a ladder. However, it may be possible that there are actually certain fireballs that have a sort of 'frisky' mode activated -much like some fireballs can become 'freezers'. Of this last possibility, I am not all that certain; it is something to look into further.

Feel free to shred my theory apart! :D



Lastly, as an example of what I mean (and also to show of that I at least know what I am talking about in some sense -and also to show 'what I'm packin' ;) ), here's a video of me doing 24/29 successful fireball jumps! I didn't count one jump, 'cause I purposely just did it for last second points while the timer was at 000. Also, I believe two of the attempted jumps were simply my fault in the sense that I reacted poorly or had bad spacing from the fireball when I jumped. Another one I think was merely forced to attempt -I had no other decent option but to try.

http://www.twitch.tv/marinomitch13/c/2563578
« Last Edit: July 12, 2013, 06:50:58 PM by marinomitch13 »
“Thou hast made us for Thyself, and our heart is restless until it finds its rest in Thee.” -Augustine, Confessions.
Twitch TV  Streamer DKF Blogger DK Killscreener

Offline up2ng

  • Senior Member
  • *
  • Posts: 243
Re: Jumping Fireballs Safely/Fireball Behavior
« Reply #1 on: July 15, 2013, 10:42:14 AM »
Hey Mitch, it's good to see someone writing this up -- it's something I had also meant to post about but never got around to it.  I know you and I have chatted about this a few times on Twitch, and your description breaks down pretty accurately how I also view fireball behavior.  This contrasts quite a bit with the ideas of some other excellent players such as Ross and Phil and it would be interesting to hear how they reconsile their ideas against ours.

some responses to your specific points:

Point 1: 
Quote
Fireballs have variable speed -this is due probably to something having to do with the different graphic animations during specific frames, but it also might just be simply due to a RNG with a small range of possibilities . . .

This description is sort of correct, but is also pretty vague.  I think you're referring to a thread that I had started over at cagdc about a year or so ago -- if I happen to find it I'll link to it here.  Basically, I had some suspicions about the fireballs which I posted about and it was later confirmed in that thread by Don Hodges through code analysis.  Since I can't locate the thread right now I don't remember the exact details, but it was something like this:  Every frame, each fireball is processed, where it decides if it should be updating it's location and where it should be updated to and whether or not to change its animation.  First, an RNG check is made based on the internal difficulty.  So, for example, on Level 1 (internal difficulty 1) a fireball may only have a 4/8 chance to continue to the next block of code but on Level 5 it has a 7/8 chance to continue to the next block of code (if it does NOT continue to the next block of code, the fireball does NOT move or update its animation during this frame).  Next, there is another RNG check related to whether or not it's time to change animations which results in a number between 0 and 2 -- but the wrong block of memory is used (a bug in the code), and every time the value is 0 a totally seperate block of code that is also run during this frame is looking at that same spot in memory where a value of 0 has some other meaning (which I think results in the fireball NOT updating when it actually should be updating).  Anyways, I'm probably getting the details slightly wrong, but the point is there are a couple of different places where RNG values are used to determine if a fireball should move.  Remember, these decisions are happening A LOT -- there are 60 frames every second after all -- so over a perceptable amount of time this movement will generally average out to yield "a rate of speed" for a fireball at a certain internal difficulty level.  It's NOT exactly constant speed, but it's pretty close -- variations in speed will not be very noticable.  In fact, almost every time that you notice a fireball all of a sudden speeding up to chase you down it's because you just jumped up into the next internal difficulty level which DOES have a significant impact on overall fireball speed.  So, for example, over 3 seconds (180 frames), assuming the fireball never reverses or climbs, I think you'll find that there is a small range of values for the number of pixels travelled (further, this range probably has a bell curve distribution).  In this example, a fireball might travel an average of 117 pixels with a standard deviation of just 3 or 4 pixels (about 68% of the time the fireball travels between 114 and 121 pixels perhaps) -- so the differences in speeds will be very minor.  I don't know this for sure by the way but it's my current theory.

Quote
However, there may be something in the code that triggers either a longer lasting 'slow' mode or 'fast' mode . . .

I'm pretty confident that this is wrong.  I think there are minor variations in speed, but I don't think anything in the code explicitly controls this -- I think it's purely RNG related.

Point 3:
This is the critical point for understanding fireball behavior IMO, and I agree with your description here.  If I had to guess, I believe that this decision point occurs once every 45 frames or so (3/4 of a second).  I would guess that it's the same on all levels, but since Level 5 fireballs travel faster than Level 1 fireballs they will travel a longer distance between decision points.  I'm not sure about that point though.  This is one of those things that could be hunted down in the code within a matter of minutes (and may already be know, posted in another thread somewhere), but I haven't done it yet.  This is probably worth finding in the code.

Point 7:
Quote
However, it may be possible that there are actually certain fireballs that have a sort of 'frisky' mode activated . . .

Again, I'm pretty confident that this is wrong.  I think reversals out in the open are purely based on the decision points and the RNG.
Donkey Kong:  1,206,800  Kill Screen
Donkey Kong:  898,600     16-5
D2K:                 380,200     L=9
Donkey Kong Junior:  In Progress
Twitch TV  Streamer DK Killscreener MAME DK WR Holder DK 1 Million Point Scorer DK 1.1 Million Point Scorer Wildcard Rematch Champion DKF Blogger DK 1.2 Million Point Scorer

Offline VON

  • Elite Member
  • *
  • Posts: 451
Re: Jumping Fireballs Safely/Fireball Behavior
« Reply #2 on: July 15, 2013, 03:07:49 PM »
This contrasts quite a bit with the ideas of some other excellent players such as Ross and Phil and it would be interesting to hear how they reconsile their ideas against ours.

As I see it, whatever the factors are that govern fireball behavior, they do not prohibit fireballs from falling into certain patterned routines.  In other words, whatever the magnitude of variance in the source of a fireball's decision input, there is a limit to the actual variance it can induce in fireball behavior, and so much so, that certain fireballs will exhibit totally predictable behavior throughout a small window in time.

But here's where stuff gets weird...
Fireballs can be both "free-roaming" and "routined" and may switch from "free-roaming" to "routined" on the basis of... I don't know what, probably the RNG. 

A "free-roaming" fireball would be one that seems almost to react to the movements of Jumpman, chasing him around with some measure of deliberateness despite demonstrating notably unpredictable behavior.  It may even be possible to force these fireballs to react to certain Jumpman actions, to influence them (I certainly believe this, but that's a topic for another discussion).  These free-roamers, or this free-roaming mode, constitutes the majority of fireball behavior.

To the contrary, the actions of a "routined" fireball, or a fireball in "routine" mode, are completely predictable.  Furthermore, the majority of these routines, once initiated, will be carried out regardless of any actions taken by Jumpman (think of certain freezer fireball behavior or dopey fireballs which become permanently stuck in a routine).

And so, your explanation of fireball behavior does not actually disagree with my personal observations, but neither does it fully explain them.   

Offline up2ng

  • Senior Member
  • *
  • Posts: 243
Re: Jumping Fireballs Safely/Fireball Behavior
« Reply #3 on: July 15, 2013, 05:02:29 PM »
It's great to have your input on this topic Ross.  Keep in mind that my (and Mitch' s) description above regarding the randomness and unpredictability of fireballs does not apply to Freezers in a freeze mode.  That type of fireball is basically 100% predictable and generally 100% jumpable.  However, the movement of the dopey freezers that get stuck can be explained by our description.  The fireball can travel a certain distance before reaching a decision point, then, because of a bug in the code it must freeze or turn right, the ability to run left at a decision point is lost.

I just realized that my range description above is likely wrong due to what happens with dopey freezers.  It's common for a freezer to begin one pixel to the right of a ladder, and yet it will keep getting back to this exact same point to the right of the ladder without reaching it.  If the number of pixels travelled can vary, this freezer would eventually climb this ladder due to variance between decision points.  But it never does.  So the speed can vary slightly, but the distance between the decision points must be fixed.
Donkey Kong:  1,206,800  Kill Screen
Donkey Kong:  898,600     16-5
D2K:                 380,200     L=9
Donkey Kong Junior:  In Progress
Twitch TV  Streamer DK Killscreener MAME DK WR Holder DK 1 Million Point Scorer DK 1.1 Million Point Scorer Wildcard Rematch Champion DKF Blogger DK 1.2 Million Point Scorer

Offline Jeffw

  • Full Member
  • *
  • Posts: 72
Re: Jumping Fireballs Safely/Fireball Behavior
« Reply #4 on: July 15, 2013, 05:19:41 PM »
The fireball algorithm in the code begins at 0x30ED if anyone is interested in reading it. I read through it a while back and understood most of it. I remember at a high level all the important parts of how the algorithm works, but I don't remember very well how stuff is organized in the code. I know that the fireball algorithm was very confusing at first because there was a ton of jumping around across different blocks of code. Some of the comments in that routine are also misleading and may add to the confusion. I was going to go through that routine adding more comments and replace some of the existing comments to make it easier to read, but I haven't gotten around to it yet.

Quote from: up2ng
Every frame, each fireball is processed, where it decides if it should be updating it's location and where it should be updated to and whether or not to change its animation.  First, an RNG check is made based on the internal difficulty.  So, for example, on Level 1 (internal difficulty 1) a fireball may only have a 4/8 chance to continue to the next block of code but on Level 5 it has a 7/8 chance to continue to the next block of code (if it does NOT continue to the next block of code, the fireball does NOT move or update its animation during this frame).

This is almost right, except for one important detail: this decision is NOT based on RNG, instead it just uses the frame counter, which counts down from FF to 00 over and over again. So, for example, L1 fireballs will always alternate: update, don't update, update, don't update, update, don't update, etc. with no randomness.

Quote from: up2ng
Next, there is another RNG check related to whether or not it's time to change animations which results in a number between 0 and 2 -- but the wrong block of memory is used (a bug in the code), and every time the value is 0 a totally seperate block of code that is also run during this frame is looking at that same spot in memory where a value of 0 has some other meaning (which I think results in the fireball NOT updating when it actually should be updating). 

Hmm, I'm not sure I've heard of this. Are you talking about the bug that causes you to always be awarded 300 points from a hammer smash on a certain animation frame of the fireball? I didn't think that bug had anything to do with fireball speed. What I do remember is that when a fireball is moving left, and it falls into the "update" case of the first check described above, then there is a 25% chance (based on RNG) that the fireball will not move on that frame regardless, but this only happens when it's moving left and not when it's moving right.

Overall, this means that, as far as I know, fireball speed to the right is 100% deterministic and fireball speed to the left is random but averages 75% of the speed to the right. A quick check in mame using frame advance confirms that fireball speed right is constant (i.e., on L1 you will always see a fireball move right one pixel every two frames).

Now, about the "decision points" for reversing direction, the way it works is each fireball has an internal "direction reverse counter". When this counter reaches 0, and only when it reaches 0, will the fireball make a decision about whether or not to reverse direction (and when a fireball does make such a decision the counter gets reset back to some predefined value and required to count down again before the next decision point). The first important property about this counter is that it does NOT get updated when a fireball fails the first check (the deterministic one described above based on the frame counter). This means that internal difficulty does not affect the distance a fireball travels between decision points, because failing the first check causes neither the direction reverse counter or the fireball's position to be updated. Internal difficulty does, however, affect the time between decision points since it will take longer on lower internal difficulties for the direction reverse counter to reach 0.

Next, when a left-moving fireball fails the second check (the RNG check described above with 25% probability) the direction reverse counter does still get updated. This means that on a given internal difficulty the time between decision points will be the same (and purely deterministic) regardless of whether the fireball is moving left or right, but the distance the fireball travels will be smaller if it is moving left (and the distance while moving left will also be random).

So in summary, the distance between decision points of a right-moving fireball is the same across all internal difficulties and is totally deterministic. For a left-moving fireball, the average distance will be the same across all internal difficulties, but will vary based on how fast the fireball was moving.

When a fireball is forced to reverse direction due to hitting the edge of a girder, the direction reverse counter does not change. So this makes it possible, as pointed out by Mitch, for a fireball to go back and forth more quickly when near the edge of a girder.

Finally, when a fireball is on a ladder the direction reverse counter is frozen until the fireball reaches the other end of the ladder. So if a fireball reversed direction then immediately climbed down a ladder it might be possible to sneak past it and up the ladder because when it reaches the bottom it will go left and won't be able to reverse back to the right for a while.

As far as jumping fireballs, on L1 it is often possible to jump them immediately after they reverse direction and before the next decision point, but on L5 they will usually be moving too fast and you won't be close enough to them to safely jump them before the next decision point, however, it can still be safe to jump them after that decision point but before the following one. This requires either very accurately knowing the distance between decision points if the fireball is moving right, or if it's moving left, then distance is an unreliable measure and you have to have a good sense of the time between decision points.
Twitch TV  Streamer DK Killscreener Kong-Off 2 Champion DK 1 Million Point Scorer DK 1.1 Million Point Scorer Kong-Off 3 Champion

Offline up2ng

  • Senior Member
  • *
  • Posts: 243
Re: Jumping Fireballs Safely/Fireball Behavior
« Reply #5 on: July 15, 2013, 05:50:04 PM »
Thanks for clarifying the details Jeff.  I remembered it was a two step process but got my algorithms mixed up. 

Given your description of variable distances while moving left, how do you explain the dopey fireball that I  described in the previous post?  Are fireballs that are moving right and then bounce off an edge still behaving as if they are still moving right, ie, still moving at 100% speed and not 75% speed?
Donkey Kong:  1,206,800  Kill Screen
Donkey Kong:  898,600     16-5
D2K:                 380,200     L=9
Donkey Kong Junior:  In Progress
Twitch TV  Streamer DK Killscreener MAME DK WR Holder DK 1 Million Point Scorer DK 1.1 Million Point Scorer Wildcard Rematch Champion DKF Blogger DK 1.2 Million Point Scorer

Offline Jeffw

  • Full Member
  • *
  • Posts: 72
Re: Jumping Fireballs Safely/Fireball Behavior
« Reply #6 on: July 15, 2013, 06:12:25 PM »
Thanks for clarifying the details Jeff.  I remembered it was a two step process but got my algorithms mixed up. 

Given your description of variable distances while moving left, how do you explain the dopey fireball that I  described in the previous post?  Are fireballs that are moving right and then bounce off an edge still behaving as if they are still moving right, ie, still moving at 100% speed and not 75% speed?

Yes, a special case happens immediately after a fireball hits the right edge of a girder: instead of acting like a normal left-moving fireball it will skip the second check (the 25% probability RNG check) and thus will temporarily move with a deterministic speed that is the same speed at which it moves right. This lasts until the next decision point at which point it will either return to normal while continuing to move left or it will reverse direction and head right. For dopey freezers this translates to either freezing once it reaches the decision point or darting back to the right without freezing.
Twitch TV  Streamer DK Killscreener Kong-Off 2 Champion DK 1 Million Point Scorer DK 1.1 Million Point Scorer Kong-Off 3 Champion

giv

  • Guest
Re: Jumping Fireballs Safely/Fireball Behavior
« Reply #7 on: July 15, 2013, 06:25:54 PM »
This is an excellent thread. It is actually helping to clarify my thought process on another game I'm working on totally unrelated to DK.

Just wanted to express my appreciation.

Offline marinomitch13

  • Moderator
  • Spring Jumper
  • *
  • Posts: 1792
    • How to Play DK
Re: Jumping Fireballs Safely/Fireball Behavior
« Reply #8 on: July 15, 2013, 07:46:17 PM »
Wow! This is incredible input! I need some time to digest some of this stuff and think of more pertinent questions that it would be helpful to know the answer to.

Also... I need to get my butt in gear and take a serious look at that code for myself!
“Thou hast made us for Thyself, and our heart is restless until it finds its rest in Thee.” -Augustine, Confessions.
Twitch TV  Streamer DKF Blogger DK Killscreener

Offline marinomitch13

  • Moderator
  • Spring Jumper
  • *
  • Posts: 1792
    • How to Play DK
Re: Jumping Fireballs Safely/Fireball Behavior
« Reply #9 on: July 16, 2013, 03:31:02 PM »
I just realized something cool with this new knowledge about fireball behaviors. I'll have to do some math and watching fireballs for a while, but I think I can pull off something cool with enough practice. I'll add it to my list of DK things to work on. I wanna keep it secret for now, though, so I'm not telling what it is! ;)
“Thou hast made us for Thyself, and our heart is restless until it finds its rest in Thee.” -Augustine, Confessions.
Twitch TV  Streamer DKF Blogger DK Killscreener

Offline ChrisP

  • Spring Jumper
  • *
  • Posts: 1690
  • I'm going to jump next to your leg.
    • Donkey Blog
Re: Jumping Fireballs Safely/Fireball Behavior
« Reply #10 on: July 16, 2013, 03:39:19 PM »
sandbagger...
http://donkeykongblog.blogspot.com

4 Quarters :-* - 800K Avg. Per Qtr. :o - No Restarts 8) - No Proof :'(

7/26/2013   Coin 35,946   710,800   18-1
7/28/2013   Coin 35,947   903,700   22-1
8/16/2013   Coin 35,948   694,100   17-6
8/17/2013   Coin 35,949   893,100   22-1

3,201,700: the $1 World Record?
Twitch TV  Streamer DK Killscreener Crazy Kong Killscreener DKF Blogger DK Jr. Killscreener

Online LMDAVE

  • Spring Jumper
  • *
  • Posts: 623
Re: Jumping Fireballs Safely/Fireball Behavior
« Reply #11 on: July 16, 2013, 03:41:14 PM »
When a fireball is forced to reverse direction due to hitting the edge of a girder, the direction reverse counter does not change. So this makes it possible, as pointed out by Mitch, for a fireball to go back and forth more quickly when near the edge of a girder.


And this is really seen when a fireball is stuck in a rivet hole!
Donkey Kong (Arcade): 1,108,100

Donkey Kong 1-1: 12,900

http://twitch.tv/LMDAVE
Twitch TV  Streamer DK Killscreener DK 1 Million Point Scorer DKF Blogger DK Online Open #1 Winner DK 1.1 Million Point Scorer

Offline VON

  • Elite Member
  • *
  • Posts: 451
Re: Jumping Fireballs Safely/Fireball Behavior
« Reply #12 on: July 16, 2013, 04:05:07 PM »
Thanks for clarifying the details Jeff.  I remembered it was a two step process but got my algorithms mixed up. 

Given your description of variable distances while moving left, how do you explain the dopey fireball that I  described in the previous post?  Are fireballs that are moving right and then bounce off an edge still behaving as if they are still moving right, ie, still moving at 100% speed and not 75% speed?

Yes, a special case happens immediately after a fireball hits the right edge of a girder: instead of acting like a normal left-moving fireball it will skip the second check (the 25% probability RNG check) and thus will temporarily move with a deterministic speed that is the same speed at which it moves right. This lasts until the next decision point at which point it will either return to normal while continuing to move left or it will reverse direction and head right. For dopey freezers this translates to either freezing once it reaches the decision point or darting back to the right without freezing.

Beautiful.  This agrees with my observation that freezers only go dopey when they're near a right wall (or any obstruction to the right, such as a rivet hole).
« Last Edit: July 16, 2013, 04:21:11 PM by VON »
Twitch TV  Streamer DK Killscreener Wildcard Rematch Champion DKF Blogger DK 1 Million Point Scorer DK 1.1 Million Point Scorer DK Online Open #2 Winner

Offline marinomitch13

  • Moderator
  • Spring Jumper
  • *
  • Posts: 1792
    • How to Play DK
Re: Jumping Fireballs Safely/Fireball Behavior
« Reply #13 on: August 29, 2013, 08:55:00 AM »
Ok, now here's something I've noticed, and I would like to know for certain if it is just pure coincidence or if there's something in the programing that would bring about this effect quite regularly.

Ever since I've started to really focus on the fireball's decision points, I've started to get a fuller knowledge of the beginning 'decision tree' of fireballs on the bottom girders on 1-1. I've discovered a lot of If-Then relationships between various fireball direction-changes such as: 'If the fireball turned around here, then its next two possible turn around locations are roughly here and here'. However, one thing I've noticed is that there is a particular action of the fireballs that actually does seem to be more akin to a determinate phase (meaning, once it starts, it'll do the whole process before it stops). This phase basically consists of a fireball hitting a decision point while it is traveling left, then speeding up when it turns around (such that you can't out run it; some people call this the fireball's 'charging' at Jumpman), then the fireball will bypass at least the next 2 decision points (even accounting for the increased speed) without turning around, before it finally turns around again.

One thing I've noticed about this 'phase', is that it seems to often happen around 3300 on the timer (when the internal difficulty increases)- which would make sense of the fireball's increased speed, but it wouldn't make sense of why the fireball skips over two decision point so frequently. This makes me wonder if this same sort of phenomena happens regularly at each specific internal difficulty change, since I've seen this same sort of thing happen on almost every girder on the barrel screens, as well as on the rivet stages.

Maybe I can search my archives and try to come up with some videos of this happening, as I know I've commented on it while streaming before on several occasions. I'd like to hear what other people think. Is it just my mind seeing patterns? Is it actual an attribute of fireballs/internal difficulty timer change? Am I attributing more frequency to it in my mind than is actual?
“Thou hast made us for Thyself, and our heart is restless until it finds its rest in Thee.” -Augustine, Confessions.
Twitch TV  Streamer DKF Blogger DK Killscreener

Offline up2ng

  • Senior Member
  • *
  • Posts: 243
Re: Jumping Fireballs Safely/Fireball Behavior
« Reply #14 on: August 29, 2013, 09:14:06 AM »
I'm pretty sure this is an example of our mind seeing patterns when it is actually just random.  Because the fireball occasionally charges us at a time that is bad for us we feel like this is happening "all the time", when in fact it just happens "sometimes".  After all, TWO decision points SHOULD be skipped 25% of the time, which definitely isn't rare, but it's not all the time either -- it's just random.
Donkey Kong:  1,206,800  Kill Screen
Donkey Kong:  898,600     16-5
D2K:                 380,200     L=9
Donkey Kong Junior:  In Progress
Twitch TV  Streamer DK Killscreener MAME DK WR Holder DK 1 Million Point Scorer DK 1.1 Million Point Scorer Wildcard Rematch Champion DKF Blogger DK 1.2 Million Point Scorer