Jump to content
  • Advertisement
  • entries
    707
  • comments
    1173
  • views
    435844

Updated AI code

Sign in to follow this  
Programmer16

365 views

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?
Sign in to follow this  


3 Comments


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

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{};


TPOperator(State)

TPOperator(Object)

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!