eGospodarka.pl
eGospodarka.pl poleca

eGospodarka.plGrupypl.comp.programmingprocedural -> modular -> agent based
Ilość wypowiedzi w tym wątku: 1

  • 1. Data: 2017-11-23 16:20:55
    Temat: procedural -> modular -> agent based
    Od: fir <p...@g...com>

    I once wrote on this, but maybe i will
    repeat

    Im like 'fighting' for 15 years with OOP crap by saying sporadically that it is
    stupid and bad, I also often say that procedural is solid and cool (hovever probably
    there could be invented something other here too) modular is cool (l love windows
    dll-s greatly) and agent based is expected to me to be very cool too

    agent bbased paradigm is somewhat researched by some but it is not
    presented to much clear and practical afaik, I also on my side research it
    a bit (though i dont spend many tme on it i was writing some texts on it)

    I once find and wrote here on this group that agent based paradigm can be in fact
    realized (made) by normal c coding by using dll-s (his was not quite clear before)

    I also was describing how it can be done and show basic elements of that
    realisation

    i also wrote a basic runing example (though im not sure if i posted it then, now i
    slightlt revrite it and may post it to download and see or test - sorry it is much
    ugly and basic
    but as emmet brown says ;c i got no
    time to much improve it (yet))

    the basic elements are

    1) you code host.exe

    this is environment that link to your agents (whose are dll's - each dll is not agent
    per sef but it is code for a
    group of agents of such type; ho0st will call this agent.dll as many times as he
    wants instantiating N agents of given type )

    2) you code agent.dll (or more for separate types)

    agent.dll has one entry point (i think it may be called Update() though i call i
    Run() in my code) this function/method is called in cyclic giving life to given agent
    - this is
    one and only routine that is called on that agent

    agent cyclically pools his environment
    (methods for that are provoided by host.exe (it showed fortunatelly that exe can
    export functions too, though to be able to link it from agent dlls i need to build
    import library for the exe in mingw/gcc)

    in my example the api provided are only two functions

    __declspec(dllimport) int Move(int dx, int dy);

    __declspec(dllimport) int LookAt(int dx, int dy);

    one moves agents to adjacent cell on map the second gives info what is on adjacent
    tile

    yhe host has a controll on that methods, for example if one agent
    would like to jump more that to +-1,+-1 position form his current
    position host can cut it off - this is very important as it provides hard
    interface for agents 'abilities',
    environment/hosts limits them and that
    makes it really fully work at an agent
    paradigm rules (it fully provides them, and thats why its so nice imo)

    i wrote ugly and simple host (dorry i got no time but i will wrote more good lokking
    and cool in future i hope)
    tthat is 2d soccer field

    http://minddetonator.htw.pl/uglyhost.png

    throwed a lot of 'balls' here (ball symbols more)

    and i also coded two agents blacks and whites (each one in 10 instances) and
    code them very simple behaviour, blacks walk in random,


    int RunAgentBlack()
    {
    int dx = rand()%3 - 1;
    int dy = rand()%3 - 1;

    Move(dx, dy);

    return 0;
    }


    whites look right for a bol if there is ball here they move on that ball pushing it,
    if no ball at right they are also walk in random


    int RunAgentWhite()
    {


    int dx = rand()%3 - 1;
    int dy = rand()%3 - 1;

    if(LookAt(1, 0)=='b')
    Move(1, 0);
    else
    Move(dx, dy);


    return 0;
    }


    the app is ugly etc but my purpose was to ilustrate that agent paradigm can be done
    in c with dlls , can be well done in c with dll and how can be done in c with dlls

    this is this app (can be tested on win32, probably will work in wine)

    minddetonator.htw.pl/ag.zip

    there is compile bat script there
    so if someone only have mingw installed it can edit click and compile its own agent
    behaviours

    (that could be used to play in some
    agents/bot coding, compare the results
    and make some agents science and experience, though i sadly know how lazy people are
    and do not expect to much from them)

    (this post is btw an introduction to tis topic i hope to write more on this after)

strony : [ 1 ]


Szukaj w grupach

Szukaj w grupach

Eksperci egospodarka.pl

1 1 1

Wpisz nazwę miasta, dla którego chcesz znaleźć jednostkę ZUS.

Wzory dokumentów

Bezpłatne wzory dokumentów i formularzy.
Wyszukaj i pobierz za darmo: