# How should I organise classes for a space simulator?

I have pretty much taught myself everything I know about programming, so while I know how to teach myself (books, internet and reading API's), I'm finding that there hasn't been a whole lot in the way of good programming.

I am finishing up learning the basics of XNA and I want to create a space simulator to test my knowledge. This isn't a full scale simulator, but just something that covers everything I learned. It's also going to be modular so I can build on it, after I get the basics down. One of the early features I want to implement is AI. And I want to take this into account as I'm designing my classes so I can minimize rewriting code.

So my question: How should I design ship classes so that both the player and AI can use them?

The only idea I have so far is:

Create a ship class that contains stats, models, textures, collision data etc. The player and AI would then have the data for position, rotation, health, etc and would base their status off of the ship stats.

• You seem to have it all figured out. Are you asking if you did it right? Have you tried if it works? The best way to learn to program is to program. – Anko Dec 8 '12 at 12:15
• This is how I've done it - using component based approach, but there are many ways, and you're seems ok too. depositfiles.com/files/fbvti6id9 – Kikaimaru Dec 8 '12 at 17:31

I did a very similar thing in a very simple 2 player snake game with optional AI, when i created a new Snake, I passed it a Controller in the constructor, I had two children of the Controller parent class, a PlayerController that could handle keyboard input and an AIController that had a timer that allowed it to fire certain behavior every X seconds to change its direction and such. It meant that at run time I could decide what sort of controller to make and give to a snake based on player input/setting. This had other benefits too, reusing the same entities but dynamically changing their behavior is obviously favorable.