home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 05 Tactical Issues / 04 vanderSterren / Listing1.cpp
Encoding:
Text File  |  2001-12-09  |  1.1 KB  |  26 lines

  1. /* Copyright (C) William van der Sterren, 2001. 
  2.  * All rights reserved worldwide.
  3.  *
  4.  * This software is provided "as is" without express or implied
  5.  * warranties. You may freely copy and compile this source into
  6.  * applications you distribute provided that the copyright text
  7.  * below is included in the resulting source code, for example:
  8.  * "Portions Copyright (C) William van der Sterren, 2001"
  9.  */
  10.  
  11. // To construct a path according to our pullback requirements, 
  12. // the maneuver can use a cost function to evaluate the next 
  13. // node on the path such as:
  14.  
  15. float CostsForNextNode(node next, const vector<node>& pathsegment) const 
  16. {
  17.   float traveltimecosts, lackofcovercosts, nobypasscosts, unsafecosts;
  18.   traveltimecosts  = TravelTime(pathsegment.back(), next);
  19.   lackofcovercosts = NumberOfNodesAbleToFireAtNode(pathsegment, next);
  20.   nobypasscosts    = LackOfByPassAtNodeToNode(pathsegment.back(), next);
  21.   unsafecosts      = TacticallyBadPosition(next);
  22.  
  23.   return   kDuration   * traveltimecosts + kCover * lackofcovercosts
  24.          + kAmpleSpace * nobypasscosts   + kSafe  * unsafecosts;
  25. }
  26.