astarnode.hpp

Go to the documentation of this file.
00001 /* $Id: astarnode.hpp 23842 2008-02-16 08:47:16Z mordante $ */
00002 /*
00003 Copyright (C) 2003 by David White <dave@whitevine.net>
00004 Copyright (C) 2005 - 2008 by Guillaume Melquiond <guillaume.melquiond@gmail.com>
00005 Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00006 
00007 This program is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License version 2
00009 or at your option any later version.
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY.
00012 
00013 See the COPYING file for more details.
00014 */
00015 
00016 #ifndef ASTARNODE_H_INCLUDED
00017 #define ASTARNODE_H_INCLUDED
00018 
00019 #include "pathutils.hpp"
00020 #include <set>
00021 
00022 struct a_star_node
00023 {
00024 public:
00025     double g, h;  // g: already traveled time, h: estimated time still to travel
00026     gamemap::location loc;
00027     a_star_node* nodeParent;
00028     bool isInCloseList;
00029 
00030     void initNode(gamemap::location const &pos, gamemap::location const &dst,
00031                   double cost, a_star_node *parent, std::set<gamemap::location> const *teleports);
00032 
00033     inline double heuristic(const gamemap::location& src, const gamemap::location& dst)
00034     {
00035         return distance_between(src, dst);
00036     }
00037 };
00038 
00039 class a_star_world
00040 {
00041     class poss_a_star_node;
00042     poss_a_star_node *pool_;
00043     typedef std::vector<a_star_node*> vect_a_star_node;
00044     vect_a_star_node vectAStarNode_;
00045     size_t width_, nbNode_;
00046 
00047 public:
00048     void resize_IFN(size_t parWidth, size_t parHeight);
00049     void clear();
00050     a_star_node* getNodeFromLocation(gamemap::location const &loc, bool& isCreated);
00051     a_star_world();
00052     ~a_star_world();
00053 };
00054 
00055 #endif
00056 

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs