Home   Help Search Login Register  

Author Topic: FSM  (Read 2639 times)

0 Members and 1 Guest are viewing this topic.

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
FSM
« on: 19 Sep 2008, 16:02:02 »
 Hi all ,
 Has anybody got an insight into FSM and how tos , i am basicly trying to write a new fsm for some ambient life and have become stuck on how the Funtion is defined within the CfgFSM, specicaly at this point below :
Code: [Select]
class MoveLand
   {
    name = "MoveLand";
    class Init
    {
     function = "randomMoveLand";
     parameters[] = {2};
     thresholds[] = {};
    };

 1: name = moveland seems logical enough unless i am missing some significance ?

2 : Function , how inside my new addon can i define my own function and more to the point , in the default FSM does anybody know where the functions are so i may take a peek and learn a bit more :).

3 , i am aware off the bikki that functions are using the  sqf syntax but does anbody know how we create  a flow of commands , i,e how we give the AI its brain so to speak via the function .

to the  mods i have placed it hear because its really a question about editing via sqf syntax .

 oh and the criter i am trying to give a brain too is :
http://www.youtube.com/watch?v=uHeHgrY1zdM&fmt=18
« Last Edit: 19 Sep 2008, 16:19:42 by DEANO »
I love ofp

Offline loki72

  • Former Staff
  • ****
    • Loki's Nightmare
Re: FSM
« Reply #1 on: 19 Sep 2008, 20:31:43 »
sharks?! awesome! will they have the ability to do damage?

sorry this isn't an answer to your question.. i couldn't pass up the opportunity to say "cool addon!"

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: FSM
« Reply #2 on: 19 Sep 2008, 21:10:43 »
Well, FSM (finite state machine) files don't allow you to do anything you couldn't do in SQF. It is just conceptually a different way to manage the flow of the script, which is more in keeping with managing artificial intelligence. It might also be more efficient in terms of CPU power too, but the main advantage is in forcing you to think in terms of states and transitions.

I'd suggest you look at some of the FSMs that come with the game (ca\characters.pbo::scripts\*.fsm) or create some with one of the ArmA FSM applications.

I'm afraid I've only made a cursory exploration into how ArmA uses FSMs, but they seemed like a lot more trouble than they were worth (I can already think in terms of FSMs (the broad concept, not .fsm files) without having to use a cumbersome tool/format to do it for me).
« Last Edit: 19 Sep 2008, 21:12:38 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: FSM
« Reply #3 on: 19 Sep 2008, 21:52:08 »
 @ loki the plan is to have them attack but it all depends on if and when i find a suitable fsm /function to attach to the shark .

 @ spooner i see your point  as in sqf already available to define behaviour, which is ok for a man class, but because i am bypassing man actions in my fsm because i am not using the default skeleton for my animations of course and thus i have to define state bite in cfgmovesdboshark = _x as in :

Code: [Select]
class States
 {
  class Bite: Default
  {
   file = "\dbo_shark\anims\sharkbite_1.rtm";
   looped = 0;
   speed = -1.25;
  };

 but first i must tell the shark he needs to be a shark and swim and feed, i have other fish that it will find to eat ,then ultimately he will when he sees a man swimming go for attack.
 in order to do this , i need to know

a, how a function is applied to the shark
b, how to define and apply to  the shark that he needs to enter a state for exampl bite

 the ones you have pointed out are good and i kinda see how it works , but the functions in the configs i cannot find
 its probably these i need to look at so i can see how they are telling the man/ambient wildlife what there object of being is and how they go about it ?

 thanks for pointing the links
 mr fleas fsm editor is down :(

 i actually beta crashdomes lol i should have remembered it .



« Last Edit: 19 Sep 2008, 21:56:06 by DEANO »
I love ofp

Offline Sparticus76

  • Members
  • *
Re: FSM
« Reply #4 on: 21 Sep 2008, 04:04:10 »
Does this help?


Code: [Select]
class FSM
{
fsmName = "moveRandom";
initState = "start";
finalStates[] = {"end"};
class States
{
class start
{
name = "start";
init = "comment ""Notice that this state must be specified"";
 comment ""as init state to be be the active initial state"";
 _dude = _units select 0;
 comment ""hack to get the hummer to move, moveTo"";
 comment ""might be wrong command for the job."";
 if (_dude != vehicle _dude) then {
  _dude = effectiveCommander vehicle _dude;
 };
 server globalChat format [""_dude = %1, STATE: start; _units = %2; _target: %3; _destination: %4"", _dude, _units, _target, _destination];
 comment ""_dude is just the soldier this FSM will refer to"";
 comment ""notice that doFSM can run for a long list of units"";
 comment ""and you can access each one individually from"";
 comment ""within the FSM...I have not done this here, instead I just pick one from"";
 comment ""the list that can move. It's effect on a vehicle is not always as you'd"";
 comment ""expect or desire..."";
 ";
class Links
{
class tr1
{
to = "whereTo";
priority = "0,000000";
condition = "true";
action = "comment ""this is the only transition so priority is"";
 comment ""not important, it has a 'true' condition"";
 comment ""simply because we always want to leave right away"";";
};
};
};
class whereTo
{
name = "whereTo";
init = "comment ""this state runs often so the reporting can be disabled"";
 comment ""to make it less annoying."";
 if (reporting) then{
  server globalChat format [""_dude = %1, STATE: whereTo; _units = %2"", _dude, _units];
 };

I've messed with FSM's a little bit, this is from an example mission from one of the FSM tutorials on the OFPEC site. There's also the FSM editor which makes everything very simple with visual bubbles and conditional links between the bubbles of script with priorities etc.

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: FSM
« Reply #5 on: 21 Sep 2008, 10:57:32 »
 Hey sparticus,
 I was reading the exact same thing yesterday , i had totally forgot about RUNES tutorial and the fsm demo mission .

 do you know if there are any commands we can use  so we might obtain :

 what fsm the unit is "doing" (having used dofsm we should know but we need to know if it has reverted back to some auto fsm).

  and also

can we ask more in depth questions like what stage of the fsm is the unit upto . i.e what class from within the fsm is the unit processing at any moment ?
 i see the global chat above ,but i need to know the fsm is activated .
for example
class whereTo.
class repeat_until_good_pos.

 cheers

DB

EDIT
 I have attached a file below for others to see if they can make sense or even create some kind of tute .
 
 in the dl is configed  man and world class intro , also fsm MYButterfly  in dbo_man config .

 1 bis_civi with attached running anim to p3d dbo_man
 2 island ambient config for intro class island dbo test man
 3 mission where if you click radio alpha a man is created at the soldier pos and thus it would be possible to , [created man] or ds in this case , execute script to achieve infos on him and apply some tests .

 only run @ambient2 in your shortcut on its own and remove after experimenting .
 known bugs =
 no keframe anim in dbo anim and the old bis error trying to create st point .
 
  please only run this if you are interested in the thread ,there is no sharks no gameplay stuff , its merely for people who are wanting to experiment with ambient life and fsms.

 i would appreciate any feedback

cheers DB

« Last Edit: 21 Sep 2008, 14:53:29 by DEANO »
I love ofp

Offline Sparticus76

  • Members
  • *
Re: FSM
« Reply #6 on: 22 Sep 2008, 13:05:37 »
Do you mean what position the FSM is in during testing?...in which case you could use
Code: [Select]
hint "in state: where to" as the first line in the state. If you mean for the script to know what state the FSM is currently in, then I dont know. Not sure what you're wanting there.

As for knowing what FSM the unit is doing for testing purposes(as a unit can only run one FSM at a time), then put a hint in the "start" state, hint "starting FSM: hunt". Other than that I dont know if you can let the system know what FSM is currently running other than using some kind of global variable:
Code: [Select]
_soldierOne doFSM' ["move.fsm", position player, player]; move_fsm = true something like that?

I not to sure, I'm not a great scripter by any means. Alot better people out there than me to answer this, I have just played around with the tutorial and a FSM myself.

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: FSM
« Reply #7 on: 22 Sep 2008, 18:41:07 »
 Hey sparticus , thanks for reply.

 i guess what i am trying to understand is kinda two fold .

1 would be can we ask what function the ai is carrying out without hints ? i.e are there any commands that wil return some values , i though i saw some many moons ago , such as _state or _status , maybe i am dreaming.

2 . in the fsm cfg there is a funtion ="myfunction"  i cannot seem to grasp if this function is a seperate other file that is located outside the fsm or weather it is define within the fsm itself.

 cheers and i am sorry my questions are not very clear, its my noobness on the subject .

 i hope to do some testing tonight on a normal man class ai ,this should then give me an insight how it all works , then i try to apply to ambient life .

 cheers

DB
I love ofp

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: FSM
« Reply #8 on: 22 Sep 2008, 22:41:09 »
I interviewed Crashdome a while ago about FSM's, just for interests you may wish to see what he had to say about them.

Glad someone is exploring FSM hope we can get some documentation and examples together.
« Last Edit: 22 Sep 2008, 22:42:59 by hoz »
Xbox Rocks

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: FSM
« Reply #9 on: 22 Sep 2008, 23:12:53 »
 
nice interview hoz thanks for link.

 what i would like to propose is maybe a few people maybe myself you and spatacus, get together in a teamspeak channel and go through this exaple mission and tutorial of runes and look at the editor by crashdome.anyone else would be welcome of course but i dont see many reply here so i take it theres not much interest at this level .

 The reason i propose this is because in here it would simply flood with questions and it is not instant enough.

 I am GMT +0 ,so if you would like to arrange a  teamspeak or other voice comms get together for next week maybe , let me  know ,that goes for anyone interested .

 cheers

DB
I love ofp

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: FSM
« Reply #10 on: 24 Sep 2008, 23:04:41 »
Check the AI.fsm (formation, danger etc) thats interesting stuff. ;)

One needs a proper editor to be able to make use of the real potential.  :good:

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: FSM
« Reply #11 on: 24 Sep 2008, 23:14:18 »
 hey Q mate .
Do you have any links for Mrfleas editor i cant find one that works ?

 edit my apologies ,for pi## poor grammar , i meant  i could not find a working link to mrfleas editor . link is good for anyone below though still and keeps thread on topic :).
« Last Edit: 25 Sep 2008, 18:48:01 by DEANO »
I love ofp

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: FSM
« Reply #12 on: 25 Sep 2008, 00:56:37 »
Crashdomes editor is in the ED
Xbox Rocks