home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 11 Learning / 01 Manslow / GPExample / CGPTurnLeftNode.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-09  |  1.2 KB  |  60 lines

  1. //GPExample
  2. //Copyright John Manslow
  3. //29/09/2001
  4.  
  5. ////////////////////////////////////////////////////////////
  6. //Only when compiling under Windows
  7. #include "stdafx.h"
  8. #define new DEBUG_NEW
  9. ////////////////////////////////////////////////////////////
  10.  
  11. #include "math.h"
  12. #include "CGPTurnLeftNode.h"
  13. #include "CGPNode.h"
  14. #include "CGP.h"
  15. #include "assert.h"
  16.  
  17. extern void TurnLeft(void);
  18.  
  19. extern CGPNode **pPrototypeList;
  20. extern unsigned long ulNumberOfPrototypes;
  21.  
  22. CGPTurnLeftNode TurnLeftPrototype;
  23.  
  24. CGPTurnLeftNode::CGPTurnLeftNode()
  25. {
  26.     nType=10;
  27.     pChildren=NULL;
  28.     ulNumberOfChildren=0;
  29.     sprintf(psName,"TurnLeftNode");
  30.     nIsPrototype=1-AddToPrototypeList();
  31.     dPrior=0.1;
  32. }
  33.  
  34. CGPTurnLeftNode::~CGPTurnLeftNode()
  35. {
  36. }
  37.  
  38. CGPNode *CGPTurnLeftNode::pGetCopy(CGP* pGP)
  39. {
  40.     CGPTurnLeftNode *pNewNode=new CGPTurnLeftNode;
  41.     assert(!(pNewNode==NULL));
  42.     return (CGPNode*)pNewNode;
  43. }
  44.  
  45. double CGPTurnLeftNode::dEvaluate(void)
  46. {
  47.     //This function makes the agent turn left 90 degrees
  48.     TurnLeft();
  49.     return 0.0;
  50. }
  51.  
  52. char* CGPTurnLeftNode::psGetString(char* pString)
  53. {
  54.     if(pString!=NULL && strlen(pString)<10000)
  55.     {
  56.         sprintf(pString,"%s TurnLeft()",pString);
  57.     }
  58.     return pString;
  59. }
  60.