Jump to content


Photo

Inline Script Converter (Algorithm Project)


  • Please log in to reply
17 replies to this topic

#1 wnsrn3436

wnsrn3436

    GMC Member

  • GMC Member
  • 133 posts
  • Version:GM8

Posted 26 February 2012 - 09:38 AM

Posted Image

Inline Script : Is the function to put the script into your code.

If you use it, the game is much faster.
But that does not exist yet.

Speed ​​Comparison

I have finally found gmk extractor! GmkSplitter : http://gmc.yoyogames...7
This project is now running. :laugh:
The algorithm was completed, the program was commissioned to Medo42.

The algorithm.

* First, the void script.
Spoiler


* And the return script.
Spoiler


* And the return script (while).
Spoiler


* And, the exit.
Spoiler


* And, the var.
Spoiler


* And, the argument*.
Once the problem is certainly the argument*.
Currently in my opinion, It is good to use an array. ;)
But, what about this way? ds_list you may want to use.
Spoiler

What do you think? :happy:

Posted Image

And it is my hope. :laugh:

Edited by wnsrn3436, 08 March 2012 - 12:05 PM.

  • 0

#2 iam1me

iam1me

    GMC Member

  • GMC Member
  • 380 posts
  • Version:GM8

Posted 27 February 2012 - 06:04 AM

Please revise the OP and elaborate your idea further. You're a bit cryptic.

Edited by iam1me, 27 February 2012 - 06:04 AM.

  • 0

#3 wnsrn3436

wnsrn3436

    GMC Member

  • GMC Member
  • 133 posts
  • Version:GM8

Posted 27 February 2012 - 09:16 AM

Please revise the OP and elaborate your idea further. You're a bit cryptic.


v0.1 version is a version of the test.
This is will be completed soon.

If you use this script, the script calls are lost.
As a result, the game will become faster.
Also, your script, GUI API is the same.

The use of scripts slow down the game, but this is, we will solve.

v0.1 version is convert the return.
The current support.
a=script0()
script0()

Ps. Thank you for your valuable ripple.
I'd like to use your script, English is difficult.

Edited by wnsrn3436, 27 February 2012 - 09:28 AM.

  • 0

#4 iam1me

iam1me

    GMC Member

  • GMC Member
  • 380 posts
  • Version:GM8

Posted 27 February 2012 - 03:43 PM

I'll keep an eye for when you finish V1 and make sure to test it when I get the chance :)
  • 0

#5 DanRedux

DanRedux

    GMC Member

  • GMC Member
  • 1332 posts
  • Version:GM:Studio

Posted 28 February 2012 - 07:08 AM

So it's line C++'s inline operator, puts the script inline into the code.

function add(a,B) { return a+b }
x = add(4,5)

Would become

x=(4+5)

Clearly much faster. I like it, but I don't know how you're implementing it.
  • 0

#6 wnsrn3436

wnsrn3436

    GMC Member

  • GMC Member
  • 133 posts
  • Version:GM8

Posted 28 February 2012 - 07:23 AM

So it's line C++'s inline operator, puts the script inline into the code.

function add(a,B) { return a+b }
x = add(4,5)

Would become

x=(4+5)

Clearly much faster. I like it, but I don't know how you're implementing it.


Yeah. That I would want to create. :smile:
And some work has been completed. (v0.5)

In version v0.5, vold script, retuen script support.
However, retuen a -> return a; must be changed to.

The argument does not yet support.

And now I'm trying to extract the object's resources.
  • 0

#7 wnsrn3436

wnsrn3436

    GMC Member

  • GMC Member
  • 133 posts
  • Version:GM8

Posted 29 February 2012 - 12:03 PM

I have new ideas for Return Script inline.

* First, the void script.
Script0 :
show_message("void")
Call :
script0()
Inline Conversion :
show_message("void")
As above, this is copy, paste.

* And the return script.
Script0 :
var a;
a=choose(0, 1)
if a{return 0}
else{return 1}
Call :
my_var=script0()
Inline Conversion :
var return_var;
while(1)
{
var a
a=choose(0, 1)
if a{return_var=0; break}
else{return_var=1; break}
}
my_var=return_var
What do you think? :happy:

Edited by wnsrn3436, 29 February 2012 - 12:10 PM.

  • 0

#8 cookie

cookie

    GMC Member

  • New Member
  • 137 posts

Posted 29 February 2012 - 02:03 PM

I have new ideas for Return Script inline.

* First, the void script.
Script0 :

show_message("void")
Call :
script0()
Inline Conversion :
show_message("void")
As above, this is copy, paste.

* And the return script.
Script0 :
var a;
a=choose(0, 1)
if a{return 0}
else{return 1}
Call :
my_var=script0()
Inline Conversion :
var return_var;
while(1)
{
var a
a=choose(0, 1)
if a{return_var=0; break}
else{return_var=1; break}
}
my_var=return_var
What do you think? :happy:



He's requesting that the developers of game-maker make the "compiler" of the code insert all code contained within a script that's selected as inline (as seen in another picture on one of his posts), essentially copy and paste what's written in the script directly into the caller (i.e - The object). The reason for this is because calling a script from an object is slower than directly running code from an object.


i.e.

non-inline = I ask you to ask Dave (Who only speaks German) to touch a piece of cheese.

inline = I ask you before going to see Dave that you give me the phrase in which I can use to ask Dave to touch the cheese, from then on I just re-cite this phrase directly without having to ask you.

Edited by cookie, 29 February 2012 - 02:05 PM.

  • 0

#9 wnsrn3436

wnsrn3436

    GMC Member

  • GMC Member
  • 133 posts
  • Version:GM8

Posted 01 March 2012 - 07:53 AM

He's requesting that the developers of game-maker make the "compiler" of the code insert all code contained within a script that's selected as inline (as seen in another picture on one of his posts), essentially copy and paste what's written in the script directly into the caller (i.e - The object). The reason for this is because calling a script from an object is slower than directly running code from an object.


i.e.

non-inline = I ask you to ask Dave (Who only speaks German) to touch a piece of cheese.

inline = I ask you before going to see Dave that you give me the phrase in which I can use to ask Dave to touch the cheese, from then on I just re-cite this phrase directly without having to ask you.


Is a good analogy. ;)
GAME MAKER maker have made ​​a direct inline script function right is my hope.
But now we do not have this feature, someone must create it.
So, I will present the algorithm. :)

Posted Image

finally, it is my hope. :laugh:

Edited by wnsrn3436, 01 March 2012 - 07:55 AM.

  • 0

#10 DanRedux

DanRedux

    GMC Member

  • GMC Member
  • 1332 posts
  • Version:GM:Studio

Posted 01 March 2012 - 03:58 PM

The hard part is nesting.

This is a function add(a,B)
return a+b

This is a function multi(a,B)
return a*b

Now what happens when I do this:
x = add( multi( 4,3 ), add( 2, 3 ) )

It's very hard to convert that to inline when they're nested. Doable, but a lot harder.
_inline[0] = 4*3
_inline[1] = 2+3
_inline[2] = _inline[0] + _inline[1]
x = _inline[2]

Edited by time4dan, 01 March 2012 - 03:59 PM.

  • 0

#11 iam1me

iam1me

    GMC Member

  • GMC Member
  • 380 posts
  • Version:GM8

Posted 01 March 2012 - 06:55 PM

The hard part is nesting.

This is a function add(a,B)

return a+b

This is a function multi(a,B)
return a*b

Now what happens when I do this:
x = add( multi( 4,3 ), add( 2, 3 ) )

It's very hard to convert that to inline when they're nested. Doable, but a lot harder.
_inline[0] = 4*3
_inline[1] = 2+3
_inline[2] = _inline[0] + _inline[1]
x = _inline[2]


All you would do is evaluate and replace the innermost inline functions first. So your example would go like so:

x = add(multi(4,3),add(2,3));
x = add(4*3,add(2,3));
x = add(4*3,2+3);
x = 4*3+2+3;

You wouldn't need to use an array for this - you could simply use the replace string function.
  • 0

#12 DanRedux

DanRedux

    GMC Member

  • GMC Member
  • 1332 posts
  • Version:GM:Studio

Posted 02 March 2012 - 02:28 AM

Yes but it was an example. The functions could be much more complex than just an equation.

function move(x,y) {
    move_towards_point(x,y,5)
    return point_distance(x,y,xprevious,yprevious) }

Now inline that into this:

move(move(4,5),move(6,4))

The code makes no logical sense here, but you can see how it can not be inlined without a stack (which is what my previous array was).
  • 0

#13 iam1me

iam1me

    GMC Member

  • GMC Member
  • 380 posts
  • Version:GM8

Posted 02 March 2012 - 02:42 AM

Yes but it was an example. The functions could be much more complex than just an equation.

function move(x,y) {
    move_towards_point(x,y,5)
    return point_distance(x,y,xprevious,yprevious) }

Now inline that into this:

move(move(4,5),move(6,4))

The code makes no logical sense here, but you can see how it can not be inlined without a stack (which is what my previous array was).


Ah ok, I see your point   :thumbsup:

In that case the resulting code should be something like so:

move_towards_point(4,5,5)
var v1;
v1 = point_distance(4,5,xprevious,yprevious)

move_towards_point(6,4,5)
var v2;
v2 = point_distance(6,4,xprevious,yprevious)

move_towards_point(v1,v2,5)
ret = point_distance(v1,v2,xprevious,yprevious) //ret is whatever variable was specified by the user

The trick would then be coming up with a naming convention for the variables so that they don't overlap with user variables and don't overlap each other
  • 0

#14 DanRedux

DanRedux

    GMC Member

  • GMC Member
  • 1332 posts
  • Version:GM:Studio

Posted 02 March 2012 - 02:43 AM

Which is why I suggested an array. :)

__inline[0-...]
  • 0

#15 wnsrn3436

wnsrn3436

    GMC Member

  • GMC Member
  • 133 posts
  • Version:GM8

Posted 02 March 2012 - 03:55 AM

Once the problem is certainly the argument*.
Currently in my opinion, It is good to use an array. ;)
(However, rather than temporary variables may be slow)

So, what about this way? ds_list you may want to use.
Spoiler


but then again ... ds_list than, the array will be faster I think. :sweat:
array, it's a good thing.

Is there another way?

Ps. Someone with this algorithm is capable of producing tool?

Edited by wnsrn3436, 02 March 2012 - 05:07 AM.

  • 0

#16 iam1me

iam1me

    GMC Member

  • GMC Member
  • 380 posts
  • Version:GM8

Posted 02 March 2012 - 08:45 AM

Which is why I suggested an array. :)

__inline[0-...]


You could... I try to avoid GM arrays though - I don't like their uncontrolled size. A ds_list would be more preferable. Or better yet - a ds_stack or ds_queue, since you only need to use each argument 1x and then it can disappear.

****

As far as the possibility of implementing the inline feature, you would need to essentially make a preprocessor which could pipe its output to the GM compiler. Is the GM compiler a separate .exe?
  • 0

#17 wnsrn3436

wnsrn3436

    GMC Member

  • GMC Member
  • 133 posts
  • Version:GM8

Posted 02 March 2012 - 08:46 AM

I have finally found gmk extractor!
GmkSplitter : http://gmc.yoyogames...7
This project is now running!!! :laugh:

Medo42 He is a good guy!

Edited by wnsrn3436, 02 March 2012 - 09:37 AM.

  • 0

#18 wnsrn3436

wnsrn3436

    GMC Member

  • GMC Member
  • 133 posts
  • Version:GM8

Posted 02 March 2012 - 10:05 AM


Which is why I suggested an array. :)

__inline[0-...]


You could... I try to avoid GM arrays though - I don't like their uncontrolled size. A ds_list would be more preferable. Or better yet - a ds_stack or ds_queue, since you only need to use each argument 1x and then it can disappear.

****

As far as the possibility of implementing the inline feature, you would need to essentially make a preprocessor which could pipe its output to the GM compiler. Is the GM compiler a separate .exe?


Is that right?
The array is quite unstable.
However, ds_list did slower than the array.
Anyway, So Let's use ds_*.
The algorithm was completed, the program was commissioned to Medo42.

The discovery of this GmkSplitter, has opened the possibility of an inline script.

Edited by wnsrn3436, 04 August 2012 - 04:29 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users