0001
0002
0003 function [roadNo,cost_this, pxNo] = findClosestRoad(roadPoints, positionRoad_no, point, costMap, oponent_pos)
0004
0005
0006
0007
0008
0009
0010
0011 roadNo = 0; pxNo = []; noChildren = 0;path = []; markedNodes = zeros(size(costMap)); val = 0; predList =[];
0012 markedNodes = zeros(size(costMap));
0013
0014
0015 nodeList = [point];
0016 idx = 1;
0017
0018 [sx1, sy1] = size(nodeList);
0019
0020 while (roadNo == 0) && (sx1 > 0)
0021 [val, idx] = min(nodeList(:,3));
0022 if val == inf
0023 disp('ERROR: PATH NOT FOUND', oponent_pos)
0024 return;
0025 end;
0026 nodeToExpand = nodeList(idx, :);
0027 [nodeList] = removeElem(idx, nodeList);
0028 [newNode,cost_this, roadNo, pxNo, markedNodes] = getFieldCandiadte(roadPoints, positionRoad_no, nodeToExpand, costMap, markedNodes, oponent_pos);
0029 roadNo = roadNo; newNode = newNode; noChildren = noChildren; pxNo = pxNo; markedNodes = markedNodes;
0030 nodeList = [nodeList; newNode];
0031
0032 [sx1, sy1] = size(nodeList);
0033 end;
0034
0035 if (roadNo == 0)
0036 disp('Road not found')
0037 end;
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052 roadPoints = roadPoints;