Author Topic: Pie Factory Strategy: Using the Flashing 1up to Your Advantage  (Read 9203 times)

0 Members and 1 Guest are viewing this topic.

Jeffw

  • Guest
Pie Factory Strategy: Using the Flashing 1up to Your Advantage
« on: October 25, 2013, 08:06:03 pm »
Are you trying to squeeze more points out of Donkey Kong? Are you willing to start doing silly things like timing your completion of the barrel screen with the flashing 1up in the upper left? If so, then this topic is for YOU!

So I was reading some DK code recently and I learned some pretty interesting things about pie factory. Firstly, here's some background on how fireball spawning at the start of the screen works on pie factory. Note that his applies to L5+ pie factory, I haven't looked into how this stuff works for L3 or L4 pie factory yet. Fireballs are spawned from two different places in the code that act independently at the start of pie factory. The first place spawns fireballs at regular intervals, specifically it spawns a fireball every 32 frames (On L4 it is 64 frames and on L3 it is 128 frames). The second place spawns one fireball after a certain amount of time on the screen has passed. The time that it spawns is fixed and never changes for different screens and ends up being around the time that the 4th fireball of the first code area is spawned. So in summary, 4 fireballs get spawned at regular intervals from the first code area and 1 fireball gets spawned from the second code area around the time of the 4th fireball from the first code area. This is why you sometimes see two fireballs spawn nearly together; it's because they were spawned from separate areas of the code.

Now, the time at which the first fireball of the 4 intervaled fireballs spawns can vary, and since the time of the next 3 intervaled fireballs depends on the time of the first, the point in time of all 4 intervaled fireballs can vary. In fact, there are a total of 32 different alignments in time for these 4 fireballs because of the fact that the fireballs spawn 32 frames apart. You may have noticed that very rarely on pie factory the final fireball appears to be delayed. This happens when the 4 intervaled fireballs are aligned in time such that the 4th fireball is spawned on the same frame that the second code are wants to spawn a fireball. Instead of spawning two fireballs on the same frame, what happens is only 1 fireball gets spawned and so the second code area essentially does nothing and all 5 fireballs end up getting spawned at regular intervals from the first code area. This will happen with probability 1/32 if you don't try to time things to avoid it, which I will show is possible to do.

So it turns out that it is possible to control to a certain degree which of the 32 possible alignments in time the 4 intervaled fireballs have. This is where the flashing 1up in the upper left of the screen comes in. This flashing 1up actually uses the same frame counter to flash itself that the fireballs use to spawn. It will appear for 16 frames, then disappear for 16 frames, so in total it has a period of 32 frames, which conveniently is the same as the interval between fireballs. This means that there will be a one-to-one correspondence between the frame in the flashing 1up cycle in which you finish the previous barrel board and the alignment in time of the 4 intervaled fireballs.

To make things more precise, I will number the 32 frames of the 1up cycle in hexadecimal as follows: The first frame in which the 1up appears will be frame 0x0, the frame number will count downwards modulo 32 so that the next frame will be 0x1f, then 0x1e all the way down to 0x11, which will be the last frame that the 1up is on screen. Frame 0x10 will be the first frame in which the 1up is off screen and will count down all the way down to 0x1 which is the last frame that the 1up is off screen at which point the 1up will appear again and we end up back at frame 0x0. I am using this numbering so that the lowest 5 bits of the frame counter, which has RAM address 0x601A, is equal to the frame number in the 1up cycle. So you can always tell which frame you are on if you look at address 0x601A in RAM watch.

As mentioned before, the frame number in the 1up cycle on which you finish the previous barrel board determines which of the 32 possible alignments in time the 4 intervaled fireballs will have. For reference, here are a few frame numbers on which you can finish the screen and resulting fireball timing on the next screen:
0x19 - This will cause the 4 fireballs to spawn at the latest possible time
0x1A - This will cause the 4 fireballs to spawn at the earliest possible time
0x14 - This is the special case described above where the two code areas both want to spawn a fireball on the same frame which causes the last fireball to be delayed

So an example of a way that you can use this to your advantage is to finish the previous barrel screen somewhere during frames 0x1 to 0x10, or in other words, while the 1up is off screen. This would avoid finishing on frame 0x17 hitting the special case where the last fireball gets delayed. Now, this may not seem too important since you are avoiding something that only would happen with probability 1/32 anyway, and isn't even that bad if it does happen either, but there are actually more significant consequences of the timing of the 4 intervaled fireballs.

The time at which the first pie comes on screen is determined by the time at which the first fireball spawns. So by controlling when the first fireball comes on screen you are also controlling when the first pie comes on screen, and in fact you are controlling the timing of all remaining pies as well since after the first pie, the rest of them spawn at regular intervals. The timing of the pies is actually important. The 5th pie to spawn on the screen spawns around the time that the lower conveyor reverses direction. This pie is actually a very common pie to smash with the bottom hammer. If it spawns to early, while the lower conveyor is still moving left, then you will never be able to smash it. Actually, my current pie factory strategy involves getting that pie to spawn while the middle conveyor is moving outwards so that the pie is guaranteed to spawn on the bottom and give me smash (read this post and a few others I made after for more details on this). So, if the pie spawns before the lower conveyor reverses direction it is costing what would be a 525 point (on average) smash.

After some testing I found that if you finish the previous barrel screen on 1up frames 0x1a to 0x1f or 0x0 to 0x2 the first pie will spawn too early and you will get screwed out the pie smash. This is a total of 9 out of 32 frames which will happen with probability 28% if you don't actively try to time the completion of the barrel screen. So timing your completion with the flashing 1up can actually amount to a difference of a fair amount of points throughout an entire game (I estimate around maybe 2k point difference on average, considering I go for the bottom hammer quite frequently).

Besides that, I also looked into other ways to exploit your ability to control the pie timings. One thing I looked for is methods of setting up the timing so that you can get a guaranteed 4 smashes with the bottom hammer while the middle conveyor is moving outwards instead of the typical 3 (again, read through some posts here or none of this will make any sense). I found that if you finish the barrel screen on 1up frames 0x8 to 0x10 (not sure if these bounds are totally right) and then you jump exactly 4 times on the lower conveyor before grabbing the bottom hammer the timing will work out so that you will get 4 guaranteed smashes with the bottom hammer while the middle conveyor is moving outwards, plus a possible 5th smash. I'm not sure how useful this is since it's very hard to execute (not to mention dangerous if there are fireball threats) unless there are no pies on the bottom conveyor (the major problem with pies being there is that they can waste your time and cause you to grab the bottom hammer too late, after the middle conveyor has already reversed direction).

As far as timing the completion of the barrel screen with the flashing 1up, it may be easier to get the timing right if you instead try to time the moment you mount the final ladder instead of trying to time your completion of the screen. If you do this you will have to convert the frames I talked about above on screen completion to frames at the time of mounting the final ladder.

Anyway, I'm curious if other people can come up with any pie techniques involving manipulating the pie timings and the middle conveyor direction to maximize the smashes with the bottom hammer.

Offline Bliss1083

  • Elite Member
  • *
  • Posts: 291
    • Awards
Re: Pie Factory Strategy: Using the Flashing 1up to Your Advantage
« Reply #1 on: December 17, 2013, 12:20:32 am »
That's awesome to know. I figured the flashing 1 up had it's purpose with other things incorporated with the game. Is a free pass maybe more predictable with ending the previous barrel stage on a 1up do you think?
Donkey kong  arcade 867,000 kill screen
Donkey kong arcade 1-1 12,800 12,200 12,100 and 12,000
Donkey kong end of level 4 132k
working on my hello kitty island adventure skills
Member for 11 Years DKJR Killscreener DK Killscreener Blogger Twitch Streamer

lakeman421

  • Guest
Re: Pie Factory Strategy: Using the Flashing 1up to Your Advantage
« Reply #2 on: December 17, 2013, 10:52:14 am »
Jeff, theoretically could this same type of strategy be applied to the rivet stages?  There should be numerous possibilities of how the fireballs come out based on the same concept.  Or is it based on a different code?

Jeffw

  • Guest
Re: Pie Factory Strategy: Using the Flashing 1up to Your Advantage
« Reply #3 on: December 18, 2013, 09:25:34 pm »
Yes, to a certain degree you can adjust the timing at which the first fireball on rivets comes out. The problem is that on rivets L5+ fireballs come out every 64 frames instead of ever 32 frames. So timing just according to the flashing 1-up will result in the fireball spawning at 2 possible times, 32 frames apart, and you won't know which one you will get. You could theoretically count from the moment the 1up starts flashing weather the 1up has flashed an even or odd number of times, for the entire game, and then you could control precisely the time at which the first fireball comes out like you can on pie factory, but I'm not sure anyone wants to count flashes of the 1up non-stop for an entire game, that would be pretty hardcore.

Offline up2ng

  • Senior Member
  • *
  • Posts: 242
    • Awards
Re: Pie Factory Strategy: Using the Flashing 1up to Your Advantage
« Reply #4 on: November 22, 2014, 02:24:16 pm »
As far as timing the completion of the barrel screen with the flashing 1up, it may be easier to get the timing right if you instead try to time the moment you mount the final ladder instead of trying to time your completion of the screen. If you do this you will have to convert the frames I talked about above on screen completion to frames at the time of mounting the final ladder.

Ok, when you say "mount the final ladder" are you talking about when you just begin climbing the ladder?  When I first read through this I started to think that "completion of the screen" actually meant after Kong's climbing animation and the point at which the screen turns black and moves into the intermission.  But now I think you mean just comparing the starting point of climbing up the ladder and when you finish climbing the ladder ...

So, has anyone done this conversion?  How many frames does it take to climb this ladder?

Also, just so that we don't end up misinterpreting the data, when would you say is the "best" time to complete the screen with respect to producing the most favorable fireball AND pie spawns?  Both in terms of frame numbers and the state of the 1UP text?

My other question is that there is also a point pressing technique at the end of the barrel screens for trying to get "The Extra 100".  This involves jumping over barrels until a pause in Kong's deployment animation is detected and then trying to climb the final ladder before the Timer ticks down, which if I remember correctly this should succeed something like 18% of the time (hopefully there's still a thread somewhere here at DKF which goes into the technicals of how that works).  It seems to me that there's very little room for error when trying to go for this extra 100 -- is there any way to reconcile this so that we can ALSO use the flashing 1UP while trying to set up for the pie factory AND still go for the extra 100? 
Donkey Kong:  1,206,800  Kill Screen
Donkey Kong:  898,600     16-5
D2K:                 380,200     L=9
Donkey Kong Junior:  In Progress
Member for 11 Years DK 1.2M Point Scorer Wildcard Rematch Champion Blogger Former DK Level 1-1 World Record Holder Former DK No-Hammer World Record Holder DK 1.1M Point Scorer DK Killscreener Individual Board Record Holder DK 1M Point Scorer Former DK World Record Holder - MAME Twitch Streamer