Updated AI code

posted in Beals Software
Published July 07, 2005
Advertisement
I updated the AI Attempt code, now it uses a much nicer approach. Plus, with this approach I could extend it if I wanted.

-- INACTIVE LINK REMOVED BY AUTHOR --
Any comments?
Next Entry News
0 likes 3 comments

Comments

The Forgotten Mindset
Hey, that's pretty cool, but mabey you could fill me in on this strange code bit:


#define StateImpl(Name)
class Name##Impl : public State
{
public:
   Name##Impl() : State(#Name){}
   State* Process();
};




I'm not familiar with Name##. Is it a compiler directive or something? I think I see how it works in the other files though.
July 11, 2005 01:55 PM
Programmer16
Thats the token pasting operator. It takes what name is and puts it in the macro. Here's a link
Thats from the MSDN. I've tried explaining it before and I didn't do too well.

Name## isn't the operator, ## is. This puts what Name is into the macro:
#define TPOperator(WhatEver, Value) int i##WhatEver = Value;


TPOperator(MyInt, 10)
TPOperator(YourInt, 21)

// These turn into
int iMyInt = 10;
int iYourInt = 21;


Another example:
#define TPOperator(WhatEver) class C##WhatEver##Impl{};


TPOperator(State)
TPOperator(Object)

// These turn into
class CStateImpl{};
class CObjectImpl{};
July 11, 2005 05:27 PM
Programmer16
I just noticed a major flaw in my design. When the person is diseased, if they don't die they just search until they find it (instead of being able to die.) I could fix this by adding more variables or a FatalSearchImpl or something, but I'm too busy working on my entry.

Also, I could replace the entire system with a simple function binding method, but I had plans to extend the functionality of the whole thing. Then I decided to just stick with the simple design and finish it.
July 11, 2005 06:59 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement