//*************************************************************+ // sdyn.sce // // AUTHOR: G.Doeben-Henisch // First: Dec-10, 2013 // Last: Dec-11, 2013 // //********************************************* // IDEA // // while the structures SSTR define the Parameters of the structures of a system like // Input 'I', output 'O' or internal states 'IS', contains the file SDYN // the behavior functions phi() of a system. There can be more than one behavior // function phi(). // //************************************************* // RANDOM Actions // Generates random actionsa based on uniform random numbers from 0 ... 12 // with {0,...,8} for movements ans {9,...,12} for eating. // // NACT := new action function [NACT] =actRand() NACT=floor(13*rand()) //printf("action:RANDOM NUMBER NACT= %d\n\n",NACT) endfunction //************************************************* // phiRND() // // Computes the behavior for a random system. Here it computes only eitheer some move // or a nonmove as 'eating' for output // // MINMAL ASSUMPTIONS // // ACTION-NEW := either a move (0,...,8) or an eat (9,...,12) // function [SSTR]=phiRND(POP,SSTR) [r,c]=size(POP) //assumes that POP and WIB have the same systems //in the same order ! for i=1:r //for every element of the list POP ENERGY=SSTR(i,1) if (ENERGY>0) then //Update ENERGY-STATUS NEWENERGY=SSTR(i,2) //Use collected energy ENERGYCONSUMPTION=SSTR(i,3) SSTR(i,1)=SSTR(i,1)+NEWENERGY-ENERGYCONSUMPTION SSTR(i,2)=0 //Set energy input back to zero //Generate new action [NACT]=actRand() if NACT >8 then SSTR(i,5)=9 //case non-move SSTR(i,4)=0 //set move to zero else SSTR(i,4)=NACT //case move SSTR(i,5)=0 //set nmove to zero end end end endfunction