Search Unity

RTS Game Creation With AI

Discussion in 'General Discussion' started by Reaper1121, Jul 27, 2015.

Thread Status:
Not open for further replies.
  1. Reaper1121

    Reaper1121

    Joined:
    Nov 3, 2014
    Posts:
    3
    Hello. I want to create a rts game. I love those type of games but its impossible to me sadly i tried it a lot of times. i am intermediate programmer in unity i can do some games but rts is like a wall for me. Can someone please create or tell me easy to understand how to make a rts game? i think i would be able to do a rts with hard thinking but if i do then i would get stuck on ai. I never did anything almost that has to do with AI can someone tell me how i would be able to create ai? i did find 1 tutorial but it wants me to pay but i dont have any money. Please... I just want to somehow create a rts game that has simple ai (ai should be able to build buildings not just send units). I am using Unity 5.1 Pro.
     
  2. 3agle

    3agle

    Joined:
    Jul 9, 2012
    Posts:
    508
    So this is a pretty broad topic, you're unlikely to get anyone giving you a step-by-step guide, as there isn't just one way of doing things. It's very dependant on your game, and there is a lot for you to research.
    Fuzzy Logic and Neural Networks are good places to start. Decision Trees and Pathfinding Algorithms will be useful too.
    This a very large topic so take it slow and try not to be overwhelmed, AI is actually a fairly logical thing once figured out.
    Here's an interesting read that may help, though it is long, it's full of good stuff, so just pick the bits that sound relevant to your game:
    http://www.diva-portal.org/smash/get/diva2:348419/FULLTEXT01.pdf

    Also the references in that document also contain some great info, so definitely do some digging :)
    RTS AI is probably one of the most researched areas of Game AI, so there are incredible amounts of research out there for you to use.
    Good luck with your game!
     
  3. kiriri

    kiriri

    Joined:
    Jan 14, 2011
    Posts:
    107
    Can you give examples on how Fuzzy Logic and NNs are used in RTS games? They are used in the field of "AI" but not as far as I know in "game AI". Eg. NNs would be used to perform tasks that humans can't really comprehend, while games are meant to be easily understandable, so all logic should be written in readable code and for the most part in binary logic.

    But I agree with the rest, we can't really help you if we don't know what kind of tasks your AI needs to do.
     
  4. 3agle

    3agle

    Joined:
    Jul 9, 2012
    Posts:
    508
    So Fuzzy Logic, to start with, is less of a "use" and more of a "thought", it's a way of representing problems to a computer in a way they understand. So think about a soldier on the battlefield, who encounters an enemy soldier. We instinctively know that that soldier should probably attack the other.
    A computer will not, you have to define the problem in a way it can "think" about it. Now, that's simple, you say, just make him attack on a trigger area, or line of sight.
    But what about adding some more factors, like a unit that should retreat from enemies if it is not going to win the fight (it could have low health, or be outmatched)? Now you suddenly need a load of more complicated rules, that might not be just "if (this) do {this}". Fuzzy Logic is a method of presenting all these 'problems' to the computer such that, it can work out what the right action is in a situation.

    Now Neural Networks are super interesting as they take this concept a lot further.
    You want a computer to be able to make decisions based on lots of factors, and maybe have some sort of historical knowledge (hmm, I've fought 2 tanks with 5 soldiers before and lost, maybe I should try something else). Neural Nets can be used to "train" an AI to understand the probable outcomes of different in-game situations.
    Generally you do this by letting 2 AI play each other with lots of different combinations of variables (both sides with 5 soldiers, one side with 2 soldiers, one with a tank, etc etc). They can then store this data in some sort of searchable structure (decision trees), which you can then let them act upon in the game proper.

    So when your AI opponent discovers you created an airport building, it can start building anti-air units because it knows that has worked in it's 'practice'!

    That's a great over-simplification, and there are many AIs that don't use those particular things. As I said, lots of choices when it comes to AI, and RTS in particular.
    Note that Neural Nets are pretty high-level stuff and not necessary for simple AI really (I probably should have mentioned that earlier), but I'm very much of the opinion that a strategy game with simple AI is not worth playing, so bear that in mind and take my thoughts with a pinch of salt. :)
     
  5. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Starting off with neural nets is probably the worst approach for learning AI. They are simple to build, but crazy complex in terms of training. And they are almost impossible to visualise and debug. (Google has just made some rapid strides in visualising neural nets, look up Google dreams. It could be exciting enough to make nets practical for game AI).

    Start off with a simple finite state machine. Work your way up from there.

    No. RTS games are among the most technically difficult to build and execute. There is no easy to understand way.

    That said you could try a tower defence game or an idle game first as a stepping stone.
     
    aer0ace likes this.
  6. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,051
    Indeed. Even the smaller scale ones are very challenging to get right. I would start with mastering spreadsheets and math. ;)
     
    frosted, aer0ace and Kiwasi like this.
  7. 3agle

    3agle

    Joined:
    Jul 9, 2012
    Posts:
    508
    Yes that is true and I shouldn't have said it's a "place to start", they were just the first big bits that popped into my head tbh. That said I rarely make a strategy game AI without a neural net of some sort driving the decision trees, I would argue they are still an important part of AI.
     
    Kiwasi likes this.
  8. Reaper1121

    Reaper1121

    Joined:
    Nov 3, 2014
    Posts:
    3
    Hello. Thank you for helping me i found AI Engine for unity called RAIN it does work and its very advanced almost no programming needed or no programming at all. I think it will be possible with RAIN engine. Thank you a lot guys.
     
  9. jtsmith1287

    jtsmith1287

    Joined:
    Aug 3, 2014
    Posts:
    787
    I don't know what your game development, or just development experience is in general, but if you're even somewhat new to all this I would really take a hard look at your decision to make an RTS game to start. My 2c. Otherwise, what has been stated already is good stuff. :D I might even look into that me-self.
     
  10. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    I think perhaps a big part of the challenge you are having is due to focusing on such a generic thing: RTS AI. A good place to start is breaking that down into concrete objectives.

    Break it down into logical parts. AI for the enemy HQ or whatever is driving the overall decisions over there. Perhaps AI for squad leaders to plan how to go after the goals chosen by the HQ. AI for the individal units to implement the plan. This individual level can even cover the basics such as pathfinding. Although the squad leader may determine the general direction overall route to take.

    Once you get into some specifics then you can ask better questions and get better answers. RTS AI on its own is way too high level. One person may mean how does the enemy command determine its objectives and another may be thinking of units moving around rocks. lol
     
    Kiwasi and jtsmith1287 like this.
  11. codeman_nz

    codeman_nz

    Joined:
    Jul 30, 2015
    Posts:
    11
    I am working through this tutorial which gives you the basics of an RTS game:
    http://stormtek.geek.nz/rts_tutorial

    RTS AI is simply gathering information about the world and making decisions based on that information. Do I attack? Do I wait and gather more forces? Do I build this? Do I harvest this? Do I hold back my forces in defense? When designing the AI just keeping asking yourself 'what would I do?'
     
    GarBenjamin likes this.
  12. jtsmith1287

    jtsmith1287

    Joined:
    Aug 3, 2014
    Posts:
    787
    Uhmm, I think you just defined AI in general. And it's not "simply". It looks logical on the outside and then you start digging. Oh man, it gets deep. It's a black hole of experimentation and performance optimization and the end of the road has yet to be discovered. Most, if not all gaming AI has major flaws. And it's because the processing power just isn't there to do the big stuff, or people go, "It's simply...." and then it falls short of being something amazing.
     
    Kiwasi likes this.
  13. ShilohGames

    ShilohGames

    Joined:
    Mar 24, 2014
    Posts:
    3,021
    Yeah, that is true. There is nothing simple about the game AI in an RTS. It can easily get more complicated than the hardware can handle. And even when the hardware could handle it, sometimes the ideal game AI for the player is one that is not perfect.

    Turn off the fog of war in your favorite RTS game to see what the computer opponent really does. It is often not quite what you think it is doing. Even fantastic games like Warcraft and Starcraft contain levels that fake it many ways. The end goal is to always provide the user with a fun experience, and sometimes an RTS will script certain events instead of implementing all of the AI to completely simulate the behavior of a live person. This can be for the purposes of controlling the story line or it can be for keeping the challenged but not frustrated.

    Sometimes this even means having the computer AI intentionally do non-optimal moves, especially early in an RTS game. A brand new user would prefer to fend off a few small, easy groups of enemy units instead of getting absolutely crushed during the first few minutes playing. This means sometimes the most fun game AI for the player is a game AI that is not especially intelligent.
     
  14. tiggus

    tiggus

    Joined:
    Sep 2, 2010
    Posts:
    1,240
    I've seen a lot of RTS do this, especially where the AI already knows the locations of all the resources on the map and it "unlocks" the ability to send units to them as the game progresses. Faking it can be very effective illusion of intelligence.
     
  15. Slyder

    Slyder

    Joined:
    Oct 17, 2013
    Posts:
    270
Thread Status:
Not open for further replies.