How n's Demo Data Works (let's Build A Demo)

Talk about the classic version of Metanet Software's amazingly popular freeware platformer right here!
User avatar
Moderator
Moderator
Posts: 1402
Joined: 2008.10.01 (01:36)
NUMA Profile: http://nmaps.net/user/therealone

Postby TheRealOne » 2009.02.05 (00:38)

So, about a week ago I asked kryx if it was possible to build a demo from scratch with just the numbers. I wanted to do this because I suck at FBFing and I wanted to create a demo of my map Stupidly Hard: Redux because I thought it would be great for Ska's next Best of N video. KryX told me that it would ridiculously hard because not all of the numbers in each set in the demo data correspond to an action. So I set out to figure out the data to see if it was possible to build/edit a demo from scratch.

So, here is how the demo data work:

We have all seen a string of data that look like this: 21:365733|52346544|3454364|0

The data is read like so:

Code: Select all

The number at the beginning, in this case 21, is the number of total frames in the demo.

Each set of numbers between the lines, such as |34534532|, are the actions taken in a 7 frame section.

The way this number is created by the sum of values given to each action that takes place in these 7 frames.

The values given to each action (jump, left, right and holding a jump for the next frame) were determined by Metanet. They used simple exponential formulas to make them.
Alright now that you have read that I will do an example because it is kind of confusing and I can't say that even I understand it completely.

Let’s say we want n to go 2 frames to the right then jump and keep holding jump and traveling right for 3 more frames then for the last 2 frames we want to let go of jump and pull back left. Here is how that would be done in the demo data.

First you should figure out what buttons are being held in each frame:
(Note: for a hold of a jump, I am going to denote that as "Hold")

Frame 1: Right
Frame 2: Right
Frame 3: Jump, Right
Frame 4: Hold, Right
Frame 5: Hold, Right
Frame 6: Left
Frame 7: Left

Ok, now that we know what is going on in each frame we would look at my handy dandy excel file that is attached with all of the values in it, and find the values for each of these actions.

Frame 1: A right in the first frame has a value of 2
Frame 2: A right in the second frame has a value of 32
Frame 3: Now jumps with holds are a little different, you must figure out what frame you jumped in and how many frames you held for and that is one specific value. A jump in the 3rd frame and 2 more frames of hold has a value of 281600. A right in the 3rd frame has a value of 512.
Frame 4: since we have already accounted for the jump and holds we need only worry about the right, and a right in the 4th frame has a value of 8192.
Frame 5: same as frame 4 but, a right in the 5th frame has a value of 131072.
Frame 6: A left in the 6th frame has a value of 1048576.
Frame 7: A left in the 7th frame has a value of 16777216.

Now that we have the value of each action in each frame we need to sum the values in each frame.

Frame 1 Total: 2
Frame 2 Total: 32
Frame 3 Total: 282112
Frame 4 Total: 8192
Frame 5: Total: 131072
Frame 6: 1048576
Frame 7: 16777216

Now that we have the total of each frame add it all together for the code for these 7 frames.

Total: 18247202

That is now the code for those 7 frames that will have the ninja run 2 frames right then jump to the right for 3 frames and then pull back left for 2 frames. To actually use this you will put it in to this format.

7: 18247202

The only problem with that is usually the ninja is placed a ½ snap from the bottom so it takes a few frames for him to fall to the ground where he can do stuff. So to make this demo work we would need to do nothing for, let’s say 7 frames to make things easy. Now our demo data would look like this.

14:0|18247202

Now that you know how to make a demo here is some information on how all of this data came to be and works.

Once you look at my tables in the excel doc you will see a bunch of jump tables and a theoretical hold value table and this is just to save you time adding up all of those numbers, but technically even though you can just start holding a jump without jumping the hold value for each frame was implemented in the game.

Metanet gave a base value to each of the 4 actions you can do (Jump, right, left, and hold) in the first frame. Jump = 12, right = 2, left = 1, and hold = 4. Then to calculate the value for each action in the next 6 frames the base number was multiplied by 16 for each frame after the first. So a jump in the 3rd frame is 12*16*16 = 3072

*Key for Excel Chat*
0 - no action/buttons pressed
Jump - Jump key pressed in that frame
Hold - Jump key held from a previous jump
Right - Right movement key pressed
Left - Left movement key pressed
Code - The value for a specific action and frame.

*Disclaimer*
1) I know absolutely nothing about programing, I figured out all of this through trial and error, so if something is wrong please don't freak out. Instead feel free to correct me and I will make the necessary changes.

2) I use Excel 2007 version on Windows XP, and when I save it tell me that some of the formatting may not be compatible with old versions, so if it looks all screwed up to you please tell me and I will try to fix it. Although I don't really know how I would.
Attachments
Demo code.xls
(35.5 KiB) Downloaded 208 times
Last edited by TheRealOne on 2009.02.12 (20:05), edited 1 time in total.
<@Izzy> Holy balls, sweet run.
<@gloomp> Holy sweet, balls run.
<@Izzy> Sweet, balls run holy.
<@gloomp> Run sweet, balls holy.
<@Izzy> Sweet run, ballsy hole.
<@gloomp> All's sweet, holeb run.
<@Izzy> Ballsy nun, sweet mole.
Image

<@Kool> bro no joke, I saw the sexiest swedish chick giving herself anal on one of those pop-up alarm-clocks at my uncle's house

The 700 Club
Posts: 732
Joined: 2008.11.19 (00:59)
NUMA Profile: http://nmaps.net/user/greenblack
Location: In the land of the jabberwocky

Postby blackbelmoral » 2009.02.05 (00:59)

pretty good.
4 ninjas
marked
YAR HAR!
Image
X2
Sigs:
29403|?NicNac?| Kablamo
Atilla wrote:If I offer a position, particularly one that requires a degree of responsibility and maturity, verbally abusing me because you missed the position will only confirm my belief that you were not the best candidate

User avatar
Damn You're Fine
Posts: 384
Joined: 2008.09.19 (01:47)
NUMA Profile: http://nmaps.net/user/littleviking001
MBTI Type: INTP
Location: Southern California
Contact:

Postby LittleViking » 2009.02.05 (01:10)

The real epiphany hits when you convert those numbers to hexadecimal. I'll leave that to you to experiment with.

Python:

Code: Select all

def demo_to_hex(demo):
    return "".join([("%07X" % (int(fragment)))[::-1] for fragment in demo.split(":")[1].split("|")])[:int(demo.split(":")[0])]

print demo_to_hex("60:35791394|1646|17895697|17895697|17895697|35651585|35791394|139810|0")
>>> 2222222E6600001111111111111111111111000022222222222222000000
Image
The last Metroid is in captivity. The galaxy is at peace...

Why Was Six Afraid of Seven? Because...
Posts: 789
Joined: 2008.10.30 (19:35)
NUMA Profile: http://www.nmaps.net/user/999_Springs
Location: In the toilet, flushing down springs, one by one.

Postby 999_Springs » 2009.02.07 (17:58)

Ah, I think I get it!

What you do to create a demo is this:
1) Decide what you want the ninja to do in each frame.
2) Convert that into hexadecimal using this code:
nothing=0
left=1
right=2
left and right=3
hold=4
hold and left=5
hold and right=6
hold and left and right=7
jump=C
jump and left=D
jump and right=E
jump and left and right=F
3) String together all your characters to make one long hexadecimal number.
4) Split this number into groups of 7.
5) Reverse each group.
6) Put the groups back together again, separated by | symbols.
7) Convert the numbers back into base 10.

And there you have it!
Achievements:

Completed N and NReality.
106 N v1.4 highscores.
I used to maintain 1000 NReality Level Top20 Highscores - Ranked 0th
Former Owner of Episode 169, way back when.
I've taken 10 Metanet 0ths. 6 of them lasted <2 days. I don't have any of them anymore. >:(
Third Place in BLUR 4 highscore.
Not highscoring anymore until v2.

EddyMataGallos is an alien.


User avatar
The number of Electoral College votes needed to be President of the US.
Posts: 283
Joined: 2008.09.29 (23:36)
NUMA Profile: http://nmaps.net/user/santa_hat_crusader

Postby Superpok » 2009.02.10 (01:14)

nice, that's pretty cool, i'd try it but i don't have a hex converter

is there a central thread for the no death challenge?

cuz i'm shooting for above 32
Signature Bars

Image
Image
Image
Image
Image
Image


User avatar
Damn You're Fine
Posts: 384
Joined: 2008.09.19 (01:47)
NUMA Profile: http://nmaps.net/user/littleviking001
MBTI Type: INTP
Location: Southern California
Contact:

Postby LittleViking » 2009.02.10 (02:12)

...How can you possibly be on the internet and claim to not have a hex converter?

http://www.easycalculation.com/decimal-converter.php

Windows calculator also has this functionality. Make sure it's in scientific calculator mode, enter a decimla number, and then hit the Hex radio button near the top left.
Image
The last Metroid is in captivity. The galaxy is at peace...

User avatar
Damn You're Fine
Posts: 384
Joined: 2008.09.19 (01:47)
NUMA Profile: http://nmaps.net/user/littleviking001
MBTI Type: INTP
Location: Southern California
Contact:

Postby LittleViking » 2009.02.10 (12:24)

I think a tool similar to this already exists in another fan program somewhere, but here's a webpage to break down the demo data and visualize it a bit.

http://therealn.com/demo.php
Example
Image
The last Metroid is in captivity. The galaxy is at peace...

User avatar
Moderator
Moderator
Posts: 1402
Joined: 2008.10.01 (01:36)
NUMA Profile: http://nmaps.net/user/therealone

Postby TheRealOne » 2009.02.10 (18:56)

LittleViking wrote:I think a tool similar to this already exists in another fan program somewhere, but here's a webpage to break down the demo data and visualize it a bit.

http://therealn.com/demo.php
Example

Well that is good. But I figured I wasn't the first person to figure this out. It wasn't very hard. But I couldn't find anything like this on these forums so i decided to post it.
<@Izzy> Holy balls, sweet run.
<@gloomp> Holy sweet, balls run.
<@Izzy> Sweet, balls run holy.
<@gloomp> Run sweet, balls holy.
<@Izzy> Sweet run, ballsy hole.
<@gloomp> All's sweet, holeb run.
<@Izzy> Ballsy nun, sweet mole.
Image

<@Kool> bro no joke, I saw the sexiest swedish chick giving herself anal on one of those pop-up alarm-clocks at my uncle's house

Why Was Six Afraid of Seven? Because...
Posts: 789
Joined: 2008.10.30 (19:35)
NUMA Profile: http://www.nmaps.net/user/999_Springs
Location: In the toilet, flushing down springs, one by one.

Postby 999_Springs » 2009.02.10 (19:34)

Superpok wrote:nice, that's pretty cool, i'd try it but i don't have a hex converter

is there a central thread for the no death challenge?

cuz i'm shooting for above 32
That was part of my ever-changing sig, not my post. The one life challenge thread is here. It is very old. (Yeah, 32-0 is kind of rubbish.)

Google has a base converter. Just type "107374182 in hexadecimal", or "0x22E6445 in decimal" into Google, for example.
Achievements:

Completed N and NReality.
106 N v1.4 highscores.
I used to maintain 1000 NReality Level Top20 Highscores - Ranked 0th
Former Owner of Episode 169, way back when.
I've taken 10 Metanet 0ths. 6 of them lasted <2 days. I don't have any of them anymore. >:(
Third Place in BLUR 4 highscore.
Not highscoring anymore until v2.

EddyMataGallos is an alien.


User avatar
The number of Electoral College votes needed to be President of the US.
Posts: 283
Joined: 2008.09.29 (23:36)
NUMA Profile: http://nmaps.net/user/santa_hat_crusader

Postby Superpok » 2009.02.10 (23:23)

yeah i know it was though, i just thought i'd post there too

thanks for all the hex converters by the way...i feel so ignorant...
Signature Bars

Image
Image
Image
Image
Image
Image


User avatar
Moderator
Moderator
Posts: 1402
Joined: 2008.10.01 (01:36)
NUMA Profile: http://nmaps.net/user/therealone

Postby TheRealOne » 2009.02.12 (20:04)

If anyone is curious as to what I was able to do with demo data. I was able to create the demo for my map

http://nmaps.net/157307

<@Izzy> Holy balls, sweet run.
<@gloomp> Holy sweet, balls run.
<@Izzy> Sweet, balls run holy.
<@gloomp> Run sweet, balls holy.
<@Izzy> Sweet run, ballsy hole.
<@gloomp> All's sweet, holeb run.
<@Izzy> Ballsy nun, sweet mole.
Image

<@Kool> bro no joke, I saw the sexiest swedish chick giving herself anal on one of those pop-up alarm-clocks at my uncle's house

dreams slip through our fingers like hott slut sexxx
Posts: 3896
Joined: 2009.01.14 (15:41)
NUMA Profile: http://nmaps.net/user/Tunco123
MBTI Type: INTJ
Location: Istanbul

Postby Tunco » 2009.02.13 (19:40)

Very helpful to me to learn the number at the beginning is the number of the frames.... :]
spoiler

Image


Jedi Pimp
Posts: 681
Joined: 2008.11.10 (17:37)
NUMA Profile: http://nmaps.net/user/

Postby Raif » 2009.11.15 (18:24)

I made an excel worksheet which generates demo data instead of just being a reference sheet.
(It only works in Excel 2007 because Excel 2003 does not support formula nesting. I suppose it could be made to work in Excel 2003 by using the LOOKUP function. But I used the IF function here because it is easier for this purpose; multiplication signs work with in an IF function but not a LOOKUP function)

And if anyone was wondering to what I could do with demo data all of these runs are 100% manually built.
Attachments
N Demo Code Generator.xlsx
(12.41 KiB) Downloaded 205 times

User avatar
Moderator
Moderator
Posts: 1402
Joined: 2008.10.01 (01:36)
NUMA Profile: http://nmaps.net/user/therealone

Postby TheRealOne » 2009.11.17 (03:10)

mohamedraif wrote:I made an excel worksheet which generates demo data instead of just being a reference sheet.
(It only works in Excel 2007 because Excel 2003 does not support formula nesting. I suppose it could be made to work in Excel 2003 by using the LOOKUP function. But I used the IF function here because it is easier for this purpose; multiplication signs work with in an IF function but not a LOOKUP function)

And if anyone was wondering to what I could do with demo data all of these runs are 100% manually built.
Awesome! I actually tried to make something like this in the excel sheet I made, but I couldn't get the IF statements right. I was using a reference table of all of the values that this if statement referenced. This is great because it is one step closer to actual TASing. Now we just need rerecording and we could find the true max of lvls.
<@Izzy> Holy balls, sweet run.
<@gloomp> Holy sweet, balls run.
<@Izzy> Sweet, balls run holy.
<@gloomp> Run sweet, balls holy.
<@Izzy> Sweet run, ballsy hole.
<@gloomp> All's sweet, holeb run.
<@Izzy> Ballsy nun, sweet mole.
Image

<@Kool> bro no joke, I saw the sexiest swedish chick giving herself anal on one of those pop-up alarm-clocks at my uncle's house


Who is online

Users browsing this forum: No registered users and 17 guests