// Project 1: simulation of agent which models simple creature clear; correct=0; function x=creature_state() x=floor(2.1*rand())+1; endfunction for trial=1:1000 x=creature_state(); s=x+rand(1,1,'normal'); //// perception model if (s<1.5) x_predict=1; elseif (s<3.65) x_predict=2; else x_predict=3; end //// calculate accuracy if (x==x_predict) correct=correct+1; end end disp('percentage correct: ') (correct/1000)