⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 antmove.m

📁 The Source of Genetic Programming developed in Matlab
💻 M
字号:
function antmove
%ANTMOVE    Moves the GPLAB artificial ant forward one step.
%   ANTMOVE returns the number of the time step used by the ant after
%   moving. Other variables are returned as global variables.
%
%   See also ANTFITNESS, ANTFOODAHEAD, ANTIF, ANTRIGHT, ANTLEFT, ANTPROGN2, ANTPROGN3
%
%   Copyright (C) 2003-2007 Sara Silva (sara@dei.uc.pt)
%   This file is part of the GPLAB Toolbox

global trail;
global x;
global y;
global direction;
global npellets;
%global maxtime;
global ntime;

global sim;
global path;
    
% new coordinates:
[newx,newy]=antnewpos(x,y,direction,trail);

% if there's food, eat it:
if trail(newx,newy)==1
    trail(newx,newy)=0;
    npellets=npellets+1;
end

x=newx;
y=newy;
ntime=ntime+1;

if sim
   antpath(ntime,x,y,direction,npellets,0);
   % 0 is the setting of "looked ahead", true only if 'antif' is executed
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -