📄 initpos.m
字号:
function initpos% INITPOS Initialize the position of the robots, the object and the goal.% Copyright (c) 1998-2000 Jiming Liu and Jianbing Wuglobal RobotNum WorkArea RobotSize ObjectSize ObjectShape;global ObjectHistory GoalHistory ObjectPosition GoalPosition;global ChromHistory;global RegionNum DirectionNum CurrentPopulations PopulationSize;% CurrentPopulations is the current really robot position and direction. As:% [R1Pos R2Pos ... RnPos R1Dir R2Dir ... RnDir;.......]RobotHistory=[];ChromHistory=[];ObjectHistory=[];GoalHistory=[];ObjectPosition=[20 20];ObjectHistory=[ObjectHistory; ObjectPosition];GoalPosition=[70 90];GoalHistory=[GoalHistory; GoalPosition];% ---- 1st GenerationsCurrentPopulations=[];for loops=1:PopulationSize TempPosition=[]; for loop1=1:RobotNum ThisState=0; while ~ThisState ThisPosition=floor(rand*RegionNum); ThisState=islegal(ThisPosition,TempPosition); end; TempPosition=[TempPosition ThisPosition]; end; [ComparedValue,Sequence]=sort(TempPosition'); ThisPosition=ComparedValue'; ThisDirect=floor(rand(1,RobotNum)*DirectionNum); ThisSample=[ThisPosition ThisDirect]; CurrentPopulations=[CurrentPopulations; ThisSample];end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -