#For Sensor and brain testbed expiriments @use Braitenberg7. #@use NeuralNetwork3. @use NetworkServer. @define PORT_NUM 2323. @define MASTERHOST "192.168.0.100". @define POP 4. #Maximum population @define STATIC 20. #Maximum number of static blocks. @define NCOUNT 20. #Brain size @define AT_HOME 1. @define LOAD 0. @define SAVE 1. @define TIME_C 10. Controller TestBed. BraitenbergControl2 : TestBed { + variables: block(object). stimuli(object). sensor(object). Size(vector). temp(object). tempShape(object). + to init: super init. block = new BraitenbergVehicle2. Size = (4.0, .75, 3.0). tempShape = (new Cube init-with size Size). temp = new Segment. temp move to (0,6,0). temp set-shape to tempShape of Size. block add-body with temp. sensor = (block add-sensor at (2.0, .4, 1.65) of-kind 1 with-normal (1, 0, 0)). sensor set-start to 1. sensor add-kind of 2. sensor set-direction to (0, -1, 0). Size = (1, 1, 1). tempShape = (new Cube init-with size Size). stimuli = new Segment. stimuli move to ( -6,6, -4). stimuli set-color-integer to 1. stimuli set-shape to tempShape of Size. block init-and-start-brain of NCOUNT. + to iterate: block control at-time (self get-time). #self display-current-driver. super iterate. } Data : Results { + variables: fits (list). + to add-fitness of fit(double) at-trial t (int) of-run r (int) with-data-string stuff (string): tmp(list). push fit onto tmp. push t onto tmp. push r onto tmp. push stuff onto tmp. push tmp onto fits. + to get-total-trials: rtn(int). tmp(list). tmp = fits{|fits| - 1}. rtn = tmp{1}. return rtn. + to get-total-runs: rtn(int). tmp(list). tmp = fits{|fits| - 1}. rtn = tmp{2}. return rtn. + to get-average-fitness over-last trials(int): tot(double). n(int). tmp(list). for n = (|fits| - 1), n > (|fits| - trials), n--:{ tmp = fits{n}. tot += tmp{0}. } return (tot / (trials - 1)). + to set-to fitness obj (list): fits = obj. + to get-fits: return fits. }