# Multiple AI's sharing code

I wasn't sure what to call this question I might update it with a more suitable title.

The issue I have here is more conceptual than in-depth code, and as such this might be subject to debate. However it is something I have trouble within my design and architecture so I hope that you will be able to help me :)

Let me set the scene:

In my game I have two sets of AI types:

• Player controlled AI (classic RTS controlling your units around the game world)
• Computer AI (lack of better name) which means the computer enemy controlling his units around the map

These two share a lot of similarities such as:

• Animation controllers
• Being in a group (explanation below)

Groups

All AI units (both player and enemy) are added to a group that "orders" the units to do something collectively

Now, this is where some of the differences appear. The player will control the unit movement and goals by using inputs (click on the screen)

But the enemy AI is using a Goal system that I have created:

The basics of this system are that throughout the map there will be certain points of interest (Goals) each of these goals will have a priority and a Condition method when the Group is choosing a new goal it asks the Planner and it returns the highest priority goal where the condition is met

Using a state machine I can control each individual unit to "obey" the goal of the group usually it looks something like this:

Now the Player controlled units state machine looks really similar:

Because of the different values and the nature of their input, these cannot share the same state machine states as the data a certain state/action is expecting will differ

So my question is: Should Iseparate these types of AI from each other hereby resulting in making code that seems similar but will differ slightly, or should I somehow ensure that actions can be used across the different AI types?

Is there something in my design that I have overlooked? (Is there a better way of doing this)