Official Everybody Edits Forums

Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?

You are not logged in.

#1 2015-03-19 17:28:10, last edited by Processor (2015-03-19 17:30:49)

Processor
Member
Joined: 2015-02-15
Posts: 2,246

[Tool] The (best) World Deserializer!

Insprired by stilltoolazytomakeanacc's post:

stilltoolazytomakeanacc wrote:

Let's just keep making more deserializers.
[...]
The real winner is to make one that doesn't break down when new specials are made.

So I decided to take up the challenge and created... InitParse!

InitParse dynamically detects special blocks and their parameters (and it does not have any special block ids hardcoded). Therefore, it will not break when new blocks are introduced in the game.
It has been optimized for performance and parsing "init" messages of semi-full 200x200 worlds took ~475µs (about 1/2000th second) on average.

How to use:
Visit the github page and copy paste the file contents of InitParse.cs into your own project.


I have never thought of programming for reputation and honor. What I have in my heart must come out. That is the reason why I code.

Offline

#2 2015-03-19 18:00:19

DarkDragon4900
Member
Joined: 2015-03-17
Posts: 251

Re: [Tool] The (best) World Deserializer!

Sounds pretty cool.

Offline

#3 2015-03-19 18:29:47

madiik
Member
From: floor above Yuuta
Joined: 2015-02-26
Posts: 514

Re: [Tool] The (best) World Deserializer!

There's a problem here:

if (m.Type != "init" && e.Type != "reset")

e does not exist in current context. It should be m.


shh i have returned

Offline

#4 2015-03-19 18:32:23

Jabatheblob1
Member
Joined: 2015-03-01
Posts: 856

Re: [Tool] The (best) World Deserializer!

madiik wrote:

There's a problem here:

if (m.Type != "init" && e.Type != "reset")

e does not exist in current context. It should be m.

It's whatever you name your PlayerIoClient.Message, you can name it banana, everyone just uses 'm' for 'message'


If you would like me to make a bot for you, go here.

Offline

#5 2015-03-19 18:46:30

Psychocrysma
Member
Joined: 2015-02-26
Posts: 46

Re: [Tool] The (best) World Deserializer!

Processor wrote:

Insprired by stilltoolazytomakeanacc's post:

stilltoolazytomakeanacc wrote:

Let's just keep making more deserializers.
[...]
The real winner is to make one that doesn't break down when new specials are made.

So I decided to take up the challenge and created... InitParse!

InitParse dynamically detects special blocks and their parameters (and it does not have any special block ids hardcoded). Therefore, it will not break when new blocks are introduced in the game.
It has been optimized for performance and parsing "init" messages of semi-full 200x200 worlds took ~475µs (about 1/2000th second) on average.

How to use:
Visit the github page and copy paste the file contents of InitParse.cs into your own project.

Sorry if I sound ignorant, but how do I pass the roomData variable (uint[*.*.*]) to a variable that I can use from m.Type == "say"?
This is of course from the example. I am new to world deserializers. Anyway, since I need to verify a block in the m.Type == "say" message, I'd kinda like to know how to have this variable declared at the start. I can't seem to be able to create such a uint variable.

Offline

#6 2015-03-19 18:57:23

madiik
Member
From: floor above Yuuta
Joined: 2015-02-26
Posts: 514

Re: [Tool] The (best) World Deserializer!

Jabatheblob1 wrote:
madiik wrote:

There's a problem here:

if (m.Type != "init" && e.Type != "reset")

e does not exist in current context. It should be m.

It's whatever you name your PlayerIoClient.Message, you can name it banana, everyone just uses 'm' for 'message'

If he made his Message parameter to "m", it should be "m" not "e"


shh i have returned

Offline

#7 2015-03-19 19:01:25, last edited by Processor (2015-03-19 22:08:01)

Processor
Member
Joined: 2015-02-15
Posts: 2,246

Re: [Tool] The (best) World Deserializer!

My bad -_- Has been fixed, thanks madiik for pointing it out.

---

Psychocrysma: First create a variable outside your function:

static uint[,,] world;

Then set it in your code, so you have something like this:

static uint[,,] world;
static void Connection_OnMessage(object sender, Message e)
{
    switch (e.Type)
    {
        case "init":
            var roomData = new uint[2, e.GetInt(12), e.GetInt(13)];
            var chunks = InitParse.Parse(e);
            foreach (var chunk in chunks)
                foreach (var pos in chunk.Locations)
                    roomData[chunk.Layer, pos.X, pos.Y] = chunk.Type;

            // Set the world
            world = roomData;
            break;

        case "say":
            if (world[0, 0, 0] == 44) { // If top left corner is fully black...
                // TODO: Do something here
            }
            break;
    }
}

I have never thought of programming for reputation and honor. What I have in my heart must come out. That is the reason why I code.

Offline

Wooted by:

#8 2015-03-19 19:06:46, last edited by Psychocrysma (2015-03-19 19:13:09)

Psychocrysma
Member
Joined: 2015-02-26
Posts: 46

Re: [Tool] The (best) World Deserializer!

Processor wrote:

My bad -_- Has been fixed, thanks madiik for pointing it out.

---

Psychocrysma: First create a variable outside your function:

static uint[,,] world;

Then set it in your code, so you have something like this:

static uint[,,] world;
static void Connection_OnMessage(object sender, Message e)
{
    switch (e.Type)
    {
        case "init":
            var roomData = new uint[1, e.GetInt(12) - 1, e.GetInt(13) - 1];
            var chunks = InitParse.Parse(e);
            foreach (var chunk in chunks)
                foreach (var pos in chunk.Locations)
                    roomData[chunk.Layer, pos.X, pos.Y] = chunk.Type;

            // Set the world
            world = roomData;
            break;

         case "say":
             if (world[0, 0, 0] == 44) { // If top left corner is fully black...
                  // TODO: Do something here
             }
             break;
    }
}

EDIT: He fixed it. Thanks~

Offline

#9 2015-03-19 19:07:27

madiik
Member
From: floor above Yuuta
Joined: 2015-02-26
Posts: 514

Re: [Tool] The (best) World Deserializer!

He fixed it. Re-copy the source. Note how his previous version has "static uint[] world;" instead of "static uint[,,] world;"


shh i have returned

Offline

Wooted by: (3)

#10 2015-03-19 19:42:26, last edited by Psychocrysma (2015-03-19 19:55:25)

Psychocrysma
Member
Joined: 2015-02-26
Posts: 46

Re: [Tool] The (best) World Deserializer!

So, I got this error:
Translation: Index is out of the limits of the table. Well, it's too big.
EDIT: My world is the biggest size you can have in the shop. Dunno how it was called~
nZCsMy7.png
I also get this error that makes me think that there's probably something very wrong in there:
isPLs5i.png

Offline

#11 2015-03-19 19:55:22

madiik
Member
From: floor above Yuuta
Joined: 2015-02-26
Posts: 514

Re: [Tool] The (best) World Deserializer!

I can't even seem to assign the "world" variable, BUT I NEED IT. It's just like...

var roomData = new uint[1, m.GetInt(12) - 1, m.GetInt(13) - 1];
                var chunks = InitParse.Parse(m);
                foreach (var chunk in chunks)
                    foreach (var pos in chunk.Locations)
                        roomData[chunk.Layer, pos.X, pos.Y] = chunk.Type;
                // oh let's stop here and not let madiik assign this variable :) :) :) :)
                world = roomData;

shh i have returned

Offline

Wooted by:

#12 2015-03-19 22:09:33, last edited by Processor (2015-03-19 22:10:37)

Processor
Member
Joined: 2015-02-15
Posts: 2,246

Re: [Tool] The (best) World Deserializer!

Oh come on people, learn to debug. Everyone makes off-by-one errors //forums.everybodyedits.com/img/smilies/tongue

I've fixed the error in examples.

Must be

var roomData = new uint[2, e.GetInt(12), e.GetInt(13)];

instead of

var roomData = new uint[1, e.GetInt(12) - 1, e.GetInt(13) - 1];

Note to self: Next time, make sure to debug your code before posting it here...

EDIT:

madiik wrote:

I can't even seem to assign the "world" variable, BUT I NEED IT. It's just like...

var roomData = new uint[1, m.GetInt(12) - 1, m.GetInt(13) - 1];
                var chunks = InitParse.Parse(m);
                foreach (var chunk in chunks)
                    foreach (var pos in chunk.Locations)
                        roomData[chunk.Layer, pos.X, pos.Y] = chunk.Type;
                // oh let's stop here and not let madiik assign this variable :) :) :) :)
                world = roomData;

Yeah that's because its crashing before it can set the variable, try the fix I posted above.


I have never thought of programming for reputation and honor. What I have in my heart must come out. That is the reason why I code.

Offline

Wooted by: (2)

#13 2015-03-19 22:26:40, last edited by madiik (2015-03-19 22:39:34)

madiik
Member
From: floor above Yuuta
Joined: 2015-02-26
Posts: 514

Re: [Tool] The (best) World Deserializer!

Then again... Your github readme says "0, m.GetInt(12), m.GetInt(13)"

Are we sure that even Processor knows how to handle this?

I don't see how this "chunk" system works.

MOAR EDIT:

I don't believe you know how your own deserializer works. Tried the fix above //forums.everybodyedits.com/img/smilies/tongue
gHfoj.png


shh i have returned

Offline

Wooted by:

#14 2015-03-19 22:48:25

Psychocrysma
Member
Joined: 2015-02-26
Posts: 46

Re: [Tool] The (best) World Deserializer!

Processor wrote:

Oh come on people, learn to debug. Everyone makes off-by-one errors //forums.everybodyedits.com/img/smilies/tongue

I've fixed the error in examples.

Must be

var roomData = new uint[2, e.GetInt(12), e.GetInt(13)];

instead of

var roomData = new uint[1, e.GetInt(12) - 1, e.GetInt(13) - 1];

Note to self: Next time, make sure to debug your code before posting it here...

EDIT:

madiik wrote:

I can't even seem to assign the "world" variable, BUT I NEED IT. It's just like...

var roomData = new uint[1, m.GetInt(12) - 1, m.GetInt(13) - 1];
                var chunks = InitParse.Parse(m);
                foreach (var chunk in chunks)
                    foreach (var pos in chunk.Locations)
                        roomData[chunk.Layer, pos.X, pos.Y] = chunk.Type;
                // oh let's stop here and not let madiik assign this variable :) :) :) :)
                world = roomData;

Yeah that's because its crashing before it can set the variable, try the fix I posted above.

Well, still not working for me. I'm not sure what's wrong. Your code is way too advanced for me (in the class, I mean). Well, I'm going to guess that there is still a lot to be done on this. I have the same problem as madiik BTW

Offline

Wooted by:

#15 2015-03-20 17:37:21

realmaster42
Formerly marcoantonimsantos
From: ̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍
Joined: 2015-02-20
Posts: 1,380
Website

Re: [Tool] The (best) World Deserializer!

Console: No Errors.
Output: No Errors.
ME: Cool , let's try.
*some minutes later*
ME: FFFFFFFUUUUUUUUUUUU. CODE RUIINED. FFFFFUUUUUUUUUUUUU!
No seriously, index was outside of array? oh mah gosh...
Variables.blockIDs = new uint[2, m.GetInt(12), m.GetInt(13)];
                        var chunks = InitParse.Parse(m);
                        foreach (var chunk in chunks)
                        {
                            foreach (var pos in chunk.Locations)
                            {
                                Variables.blockIDs[chunk.Layer, pos.X, pos.Y] = chunk.Type;
                            }
                        }
Variables.blockIDs is same as roomData. EXACTLY EQUAL (except not a var and yes an uint[,,]).
It's supposed to work, but even with normal roomData it did the same.


http://i.imgur.com/bjvgH5L.png?1

Offline

#16 2015-03-20 17:38:47

realmaster42
Formerly marcoantonimsantos
From: ̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍
Joined: 2015-02-20
Posts: 1,380
Website

Re: [Tool] The (best) World Deserializer!

Psychocrysma wrote:
Processor wrote:

Oh come on people, learn to debug. Everyone makes off-by-one errors //forums.everybodyedits.com/img/smilies/tongue

I've fixed the error in examples.

Must be

var roomData = new uint[2, e.GetInt(12), e.GetInt(13)];

instead of

var roomData = new uint[1, e.GetInt(12) - 1, e.GetInt(13) - 1];

Note to self: Next time, make sure to debug your code before posting it here...

EDIT:

madiik wrote:

I can't even seem to assign the "world" variable, BUT I NEED IT. It's just like...

var roomData = new uint[1, m.GetInt(12) - 1, m.GetInt(13) - 1];
                var chunks = InitParse.Parse(m);
                foreach (var chunk in chunks)
                    foreach (var pos in chunk.Locations)
                        roomData[chunk.Layer, pos.X, pos.Y] = chunk.Type;
                // oh let's stop here and not let madiik assign this variable :) :) :) :)
                world = roomData;

Yeah that's because its crashing before it can set the variable, try the fix I posted above.

Well, still not working for me. I'm not sure what's wrong. Your code is way too advanced for me (in the class, I mean). Well, I'm going to guess that there is still a lot to be done on this. I have the same problem as madiik BTW

+1


http://i.imgur.com/bjvgH5L.png?1

Offline

#17 2015-03-20 20:41:12

madiik
Member
From: floor above Yuuta
Joined: 2015-02-26
Posts: 514

Re: [Tool] The (best) World Deserializer!

I want answers Processor qq
I'M DIEING TO MAKE SOMETHING FUN D:

https://wiki.everybodyedits.com/images/e/ea/089_bruce does not liek this.


shh i have returned

Offline

Wooted by: (2)

#18 2015-03-20 21:31:27

Processor
Member
Joined: 2015-02-15
Posts: 2,246

Re: [Tool] The (best) World Deserializer!

I still didn't test it even once. Q_Q

Okay so, my bad, I got owned by operator precedence. Use the newer version of the gist, I promise it works now (because I actually tested it once!!)

https://gist.github.com/Yonom/3c9ebfe69b1432452f9b


I have never thought of programming for reputation and honor. What I have in my heart must come out. That is the reason why I code.

Offline

Wooted by:

#19 2015-03-20 21:49:47

Psychocrysma
Member
Joined: 2015-02-26
Posts: 46

Re: [Tool] The (best) World Deserializer!

Processor wrote:

I still didn't test it even once. Q_Q

Okay so, my bad, I got owned by operator precedence. Use the newer version of the gist, I promise it works now (because I actually tested it once!!)

https://gist.github.com/Yonom/3c9ebfe69b1432452f9b

Works fine for me!!! Thanks~

Offline

#20 2015-03-21 00:14:47

DarkDragon4900
Member
Joined: 2015-03-17
Posts: 251

Re: [Tool] The (best) World Deserializer!

"A world deserializer that never breaks!"
> Breaks 4 times before it's fixed.
Dammit processor.

Offline

#21 2015-03-21 00:33:49

Jabatheblob1
Member
Joined: 2015-03-01
Posts: 856

Re: [Tool] The (best) World Deserializer!

lol processor is too good to test, no time for that
Very nice tho


If you would like me to make a bot for you, go here.

Offline

#22 2015-03-21 00:38:16

0176
Member
From: Brazil
Joined: 2021-09-05
Posts: 3,174

Re: [Tool] The (best) World Deserializer!

Argh, I'm probably misguided but seeing quantum physics stuff this like just for a Flash game makes me give up all my hope of actually learning programming someday.

Offline

#23 2015-03-21 00:54:29, last edited by DarkDragon4900 (2015-03-21 01:36:32)

DarkDragon4900
Member
Joined: 2015-03-17
Posts: 251

Re: [Tool] The (best) World Deserializer!

Jabatheblob1 wrote:

lol processor is too good to test, no time for that
Very nice tho

e65.gif

And agreed, nice work

[Edit] Just tried it. Awesome, works well.

Offline

#24 2015-03-21 14:17:16

realmaster42
Formerly marcoantonimsantos
From: ̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍̍
Joined: 2015-02-20
Posts: 1,380
Website

Re: [Tool] The (best) World Deserializer!

Processor wrote:

I still didn't test it even once. Q_Q

Okay so, my bad, I got owned by operator precedence. Use the newer version of the gist, I promise it works now (because I actually tested it once!!)

https://gist.github.com/Yonom/3c9ebfe69b1432452f9b

It's fixed now.
Also processor,

'The (best)','Therefore, it will not break when new blocks are introduced in the game.'
>= Breaks 4 times

kkkkk i beliv u omg give me siganutre
(no srs, breaks 4 times before works at once)


http://i.imgur.com/bjvgH5L.png?1

Offline

#25 2015-03-21 14:37:25

skullz17
Member
Joined: 2015-02-15
Posts: 6,699

Re: [Tool] The (best) World Deserializer!

marcoantonimsantos wrote:

'The (best)','Therefore, it will not break when new blocks are introduced in the game.'
>= Breaks 4 times
kkkkk i beliv u omg give me siganutre
(no srs, breaks 4 times before works at once)

plsgo someone already made this joke


m3gPDRb.png

thx for sig bobithan

Offline

SirJosh39171458770132590512

Board footer

Powered by FluxBB

[ Started around 1732233658.2044 - Generated in 2.228 seconds, 13 queries executed - Memory usage: 1.87 MiB (Peak: 2.16 MiB) ]