Fuzzy Code



  • I mentioned a programming assignment in the Med School Malpractice thread, and figured that further details (not so relevant to that thread) are worth mentioning.

    My current assignment for Soft Computing at uni is to fix/improve the AI on a game called which is similar to Worms but has witchetty grubs instead of worms. The AI uses Fuzzy Logic (it's a demo of the fuzzy logic system) and the game and framework were written as a student project last year. The whole game is written in Lua, and the graphics are done with DirectX (not that you touch it at this level of the the framework). Anyhow, one of the things I need to do is make the AI check to see how far off it was and make corrections accordingly. Plus I need to improve the fuzzy sets and rules a bit so it's not so far out in some cases.

    The code is interestingly convoluted. Between the occasional unexplained commented-out lines, and explanatory comments that merely reflect what the code does - I mean used to do before changes were made - I even found a function which takes no parameters, sets some local variables (using the values of globals), and returns nothing. Thus useless function is not called. Seems to be a partial algorithm that was never finished.

    Yesterday I removed the following two functions, each of which was called twice.

    [code] -----------------------------------YDiff------------------------------------------------
    ----------------------------------------------------------------------------------------
    function YDiff(y1,y2)
    return y1-y2
    end
    -----------------------------------XDiff------------------------------------------------
    ----------------------------------------------------------------------------------------
    function XDiff(x1,x2)
    return x1-x2
    end [/code]

    I think all functions have a 'title' comment like those two did.  A few even say what the function does, on a third line.  There's also some comments which seem to say hasn't been done, or express doubts about what is being done
     

    All the fuzzy rule functions contain the following cryptic comment, which was in the original sample code for fuzzy rules, which pertains to a specific example that has nothing to do with the game: 

    -- mebership amount of poor skill goes into temp 

    Oh, and the sideways movement of the grubs (your grubs can walk - I also have the task of making the AI walk) seems to occur only at the end of the FallingCheck function and the beginning of the ClimbingCheck function.



  • Hooray for useless functions and meaningless comments!  Trust me, without them your day would get really boring really quickly.

    I especially like "mebership amount of poor skill goes into temp".  That just about rivals the "pig go, go is to the fountain" bit that was posted here a while back.
     



  • @Eternal Density said:

    There's also some comments which seem to say hasn't been done, or express doubts about what is being done

    What did you expect from a project demonstrating fuzzy logic?



  • You clearly see all of this wrong. The whole project is in fact of [i]another[/i] AI engine which uses self-writing code and evolutionary algorithms. What you are seeing are in fact dead branches of evolution in progress. And you are part of the engine too. You should feel excited.



  • First time I looked at this, I read "function Yiff(y1, y2)", which is that much more disturbing.



  • They also seem to think that paste > functions

     I've just replaced 32 clusters of lines like:
      Fuzzy_newFS("windHighToward", -100, 100);
      Fuzzy_addVal("windHighToward", -100,0);
      Fuzzy_addVal("windHighToward", 70,0);
      Fuzzy_addVal("windHighToward", 80,1);
      Fuzzy_addVal("windHighToward", 100,1);

     each with a single line like

    makeFS("windHighToward", -100, 100,{[-100]=0,[70]=0,[80]=1,[100]=1})

     



  • @Eternal Density said:

    makeFS("windHighToward", -100, 100,{[-100]=0,[70]=0,[80]=1,[100]=1})

    It's neat that even though I've got no idea what this means, I still know that "windHighToward" is a completely incomprehensible label.


Log in to reply