Jump to content
  • Advertisement
  • entries
  • comments
  • views

Updated AI code

Sign in to follow this  


I updated the AI Attempt code, now it uses a much nicer approach. Plus, with this approach I could extend it if I wanted.

Any comments?
Sign in to follow this  


Recommended Comments

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
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.

Share this comment

Link to comment
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{};



// These turn into
class CStateImpl{};
class CObjectImpl{};

Share this comment

Link to comment
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.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!