//*************************************************
// EXPERIMENT V2
//
// AUTHOR: G.Doeben-Henisch
// First: 18.Nov.2013
// Last: 11.Dec.2013
//*************************************************
//
// IDEA
//
// Selects a GRIDSPC , a set of learning semiotic systems POP,
// an world input buffer WIB,
// an interface INTERFACE with ainp() and aout(),
// a set of structures SSTR for systems building a population
// and a set of system functions SDYN describing the behavior
// of the systems, their 'dynamics'.
// Then you start an experiment.
//******************************************************************************
// experimentRND()
//
// Running a simple experiment with with purely random systems for some number RUN of cycles
//
// The WORLD consists of
//-----------------------
// -GRIDSPC := a certain prespecified grid
// -POP := a certain lis of systems inside the world
// -WIB := a world input buffer
//
// The systems are represented by
//-------------------------------
//SSTR := list of structures
// SDYN := list of system functions
function [GRIDSPC,POP,SSTR,WIB,k]=experimentRND2(GRIDSPC, POP, WIB, SSTR, RUN,SHOW)
//Insert systems into GRIDSPC
[GRIDSPC]=insertPOP(GRIDSPC,POP)
k=1
while k < RUN
//Map world onto the systems
//ainp: POP ---> SSTR
[SSTR]=ainp(POP,SSTR)
if SHOW==2 then disp(SSTR),end
//Compute reactions of systems to ainp()
//phiRND: RND ---> SSTR
[SSTR]=phiRND(POP,SSTR)
if SHOW==2 then disp(SSTR),end
//Map Output in WIB
[WIB]=aout(POP,SSTR,WIB)
if SHOW==2 then disp(WIB),end
//Compute possible new positions
[POP] =newPOS(POP, WIB)
if SHOW==2 then disp(POP),end
//Realize new moves if possible
[POP,GRIDSPC] =newPOSPOS(POP,GRIDSPC,SHOW)
disp('####################################################################')
printf('k = %d\n',k)
disp(GRIDSPC), disp(SSTR)
disp('####################################################################')
k=k+1
end
endfunction
//******************************************************************************
// experimentRND2REP()
//
// Repeating a certain experiment
//
// REPEAT := Number of repetitions
// HISTORY := Counting success and summing up collected energy
// HISTORY := [[ID, SUCCESS, SUMENERGY,REP]; ...]
function [HISTORY]=experimentRND2REP(GRIDSPC, POP, WIB, SSTR, RUN, REPEAT, SHOW)
[r,c]=size(POP)
HISTORY=zeros(r,4) //Set HISTORY to zeros
for i=1:r
HISTORY(i,1)=eval(POP(i,1)) //Get the System-IDs of POP
end
//Start loop for repetitions
for i=1:REPEAT
//Store the original values for repetitions
GRID=GRIDSPC,
P=POP,
WB=WIB,
SSR=SSTR,
//Start with a copy of original values
[GRID,P,SSR,WB,k]=experimentRND2(GRID,P,WB, SSR,RUN, SHOW)
//Update HISTORY
for j=1:r
if SSR(j,1) > 0 then HISTORY(j,2)=HISTORY(j,2)+1, end
HISTORY(j,3)=HISTORY(j,3)+ SSR(j,1)
HISTORY(j,4)=HISTORY(j,4)+1
end //End update HISTORY
end //End loop repetitions
clf()
xdel()
x=1:1:r
plot2d3(x,HISTORY(:,2),rect=[0,0,r,REPEAT])
endfunction
Gerd Doeben-Henisch
2014-01-14