Little Fighter Empire - Forums
AI script ported to F.LF - Printable Version

+- Little Fighter Empire - Forums (https://lf-empire.de/forum)
+-- Forum: Little Fighter 2 Zone (https://lf-empire.de/forum/forumdisplay.php?fid=7)
+--- Forum: AI Scripting (https://lf-empire.de/forum/forumdisplay.php?fid=56)
+--- Thread: AI script ported to F.LF (/showthread.php?tid=9065)



AI script ported to F.LF - tyt2y3 - 12-28-2013

AI script is now ported to F.LF! The first ported script is Crusher by YinYin.
You can try beating him on F.LF demo by pressing F4 to go to character selection menu.
The ported source of Crusher is available, and you can read the diff to see the difference side by side, where the left is AI angelscript and right is F.LF javascript.

The translation process was semi automatic. There was indeed a translation program being developed to translate from AI angelscript to F.LF javascript. Major differences are simply naming convention (look at the source of the program to know the translation scheme). However there are few semantic and systematic differences to be pointed out, that must be resolved manually:
  1. function overloading is not allowed in javascript, because a function can have any number of parameters
  2. javascript has 1 more primitive type 'undefined' than angelscript, such that undefined!==0, but both undefined and 0 evaluates to false. that means one should NOT do `if( some_var!=0)`, instead, should do `if( some_var)`
  3. F.LF do not use an object number system from 0 to 399. F.LF has a slightly better design by not pre-allocating memory and not imposing a hard limit on max. number of objects (though performance of F.LF at this moment is still bad). Thus, F.LF uses sparse array.
    so, instead of
    Code:
    for (int i=0;i<400;i++){
        if (game.exists[i]) {
            // do something about `game.objects[i]`
        }
    }
    one can simply
    Code:
    for ( var i in game_objects)
    {
         // every element in the sparse array game_objects exists on scene
         // do something about `game_objects[i]`
    }

that's all about it right now, be sure to try it out, and because things are all preliminary, there are lots of bugs, and please report any problem and suggestion to me. I hope this porting effort is going to raise people's interest in AI scripting and F.LF. For more information about F.LF, visit this thread or F.LF Portal.



I am not sure why Crusher acts awkwardly right now. And it does not defend at all. And the zwidth calculation is a little bit wrong.
A tips on debugging: you can use Chrome > Tools > Javascript Console to debug the application. It is a very good tool.

[Image: lVDbjHh.png]



RE: AI script ported to F.LF - YinYin - 12-28-2013

Apart from never defending he also sometimes stopped doing anything at all and resumed later on.


RE: AI script ported to F.LF - Dragon5 - 12-28-2013

.... You removed all functionality of the defend key in this build. No rolling, no special moves, nothing works when I press the defend key.


RE: AI script ported to F.LF - YinYin - 12-28-2013

Yeah. It generally doesn't run as stable as the previous one.


RE: AI script ported to F.LF - Dragon5 - 12-28-2013

Some bugs here.
Besides the AI trying to walk itself upwards to no avail, it tends to just "tap" the direction it wants to go repeatedly. Also, flipping bugs are shown from Deep's Swing.


RE: AI script ported to F.LF - tyt2y3 - 12-29-2013

(12-28-2013, 09:30 PM)Bat Tamer Wrote:  .... You removed all functionality of the defend key in this build. No rolling, no special moves, nothing works when I press the defend key.
that must be a key issue... there should be no problem on defend. try changing all keys again.
(12-28-2013, 10:01 PM)Bat Tamer Wrote:  Some bugs here.
Besides the AI trying to walk itself upwards to no avail, it tends to just "tap" the direction it wants to go repeatedly. Also, flipping bugs are shown from Deep's Swing.
thank you so much for the video capture. The second bug must be a rowing problem that during rowing that allowed the character to flip x velocity. But right now I cannot locate its exact cause.


RE: AI script ported to F.LF - Dragon5 - 12-30-2013

(12-29-2013, 03:00 AM)tyt2y3 Wrote:  that must be a key issue... there should be no problem on defend. try changing all keys again.
It was. My fault.

(12-29-2013, 03:00 AM)tyt2y3 Wrote:  thank you so much for the video capture. The second bug must be a rowing problem that during rowing that allowed the character to flip x velocity. But right now I cannot locate its exact cause.
No problem. I use Camtasia, but it isn't free sadly. It works wonders though!


RE: AI script ported to F.LF - tyt2y3 - 12-31-2013

the flipping during rowing bug solved. thanks for pointing out