Code: Select all
\begin{algorithm}[H]
%\SetLine
\SetKwData{OpenList}{openList}
\SetKwData{ClosedList}{closedList}
\SetKwData{Start}{start}
\SetKwData{End}{end}
\SetKwData{BestNode}{bestNode}
\SetKwData{OpenNode}{openNode}
\SetKwData{AdjacentNode}{adjacentNode}
\SetKwData{G}{g}
\SetKwData{H}{h}
\SetKwData{F}{f}
\SetKwData{Parent}{parent}
\SetKwFunction{Empty}{Empty}
\SetKwFunction{IsEmpty}{IsEmpty}
\SetKwFunction{IsTraversable}{IsTraversable}
\SetKwFunction{HeuristicCostTo}{HeuristicCostTo}
\SetKwFunction{CostTo}{CostTo}
\SetKwFunction{PopLowestFScoreNode}{PopLowestFScoreNode}
\SetKwFunction{Push}{Push}
\SetKwFunction{Find}{Find}
\SetKwFunction{Exists}{Exists}
\SetKwInOut{Input}{input}
\SetKwInOut{Output}{output}
\KwIn{Node start}
\KwIn{Node end}
\BlankLine
List \OpenList, \ClosedList\;
\OpenList$\leftarrow$\Empty{}; \ClosedList$\leftarrow$\Empty{}\;
\Start.\F = \Start.\G = \Start.\H = 0\;
\OpenList$\leftarrow$\Push(\Start)\;
\BlankLine
\While{ ! \OpenList$\leftarrow$\IsEmpty{} }
{
\BestNode = \OpenList$\leftarrow$\PopLowestFScoreNode()\;
\If {\BestNode == \End} {
\emph{Iterate from end to start via parents and construct the path}
}
\ClosedList$\leftarrow$\Push(\BestNode)\;
\BlankLine
\Parent = \BestNode\;
\ForEach{\AdjacentNode in \BestNode.\AdjacentNode()}
{
\If {\AdjacentNode$\leftarrow$\IsTraversable()}
{
\If {! \ClosedList$\leftarrow$\Exists {\AdjacentNode}}
{
\If {! \OpenList$\leftarrow$\Exists {\AdjacentNode}}
{
\AdjacentNode.\H = \HeuristicCostTo{\End}\;
\AdjacentNode.\G = \Parent.\G + \CostTo{\AdjacentNode}\;
\AdjacentNode.\F = \AdjacentNode.\G + \AdjacentNode.h\;
\AdjacentNode.\Parent = \Parent\;
\OpenList$\leftarrow$\Push(\AdjacentNode)\;
}
\Else
{
\emph{Edge relaxation}
\BlankLine
\OpenNode = \OpenList$\leftarrow$\Find{\AdjacentNode}\;
\AdjacentNode.\G = \Parent.\G + \CostTo{\AdjacentNode}\;
\If {\AdjacentNode.\G \leftarrow \OpenNode.\G}
{
\OpenNode.\G = \AdjacentNode.\G\;
\OpenNode.\Parent = \Parent\;
}
}
}
}
}
}
\caption{Pseudo Code of the A* Algorithm}
\end{algorithm}
I have included "\usepackage{algorithm2e}" in my code and the .sty file (http://www.ctan.org/tex-archive/macros/ ... gorithm2e/) in the same directory as the project file (which also contains the .tex that contains the code that calls the usepackage). I'm stumped as to what I should do next.
Also, three more small questions regarding TeXnicCenter:
1. Is there a way to quickly comment out (and back in) code that I have highlighted?
2. Is there a way to compile my code without having to go back to the main .tex file? (When I try to do it from one of the \input tex files, I get compiler errors)
3. Is there a way to copy the Build window output so that I can paste it elsewhere (for you guys to see)?
Mainly it's the algorithm thing I would like to know. I really appreciate any help on this. Thanks
