Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (ozgur, AbrahamR, wdlmaster, 7th_zorro), 839 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
The RTS ai... #171814
12/08/07 16:59
12/08/07 16:59
Joined: Jan 2007
Posts: 110
USA East Coast
K
KojaK Offline OP
Member
KojaK  Offline OP
Member
K

Joined: Jan 2007
Posts: 110
USA East Coast
Okay, I'm making an RTS, and it'll be a simple RTS. You have a mission, you control only one type of unit, and so does your enemy. You only have one objective, and so does your enemy. Now, the maps are reletively small, and I was wondering, what is a good algorithm for my AI? What processes should it go through to acheive it's goal?

The first mission you have to defend your bunker from the AI, who is attacking you. The goal is simple, the AI wants to kill you. The ai sends waves of troops in increasing number. What is a good algorithm here?


Lead programmer for Two Screws Loose Click here for our forums, and downloads for our games
Re: The RTS ai... [Re: KojaK] #171815
12/08/07 18:44
12/08/07 18:44
Joined: Mar 2003
Posts: 4,264
Wellington
Nems Offline

.
Nems  Offline

.

Joined: Mar 2003
Posts: 4,264
Wellington
I think your methodology should be simple point and click with vec_dist calls for 'attack, defend, retreat, reingage' coupled with simple path finding to avoid lock-ups when a team mate gets in the way.

Maybe state machines should be employed here.

I have had a few tests with rts and never completed any so am not sufficiently competent to give a definitive reply, only the above guess .

Re: The RTS ai... [Re: Nems] #171816
12/08/07 18:53
12/08/07 18:53
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
My suggestion is , make your (all of your) units 'universal'. I mean , if a certain skill (for interraction) is for example 1 , the unit will go to a certain place. This way , you could script player interraction (when I press LMB , change skill to 1) and AI interraction (when Finite State Machine decides , change skill to 1 , to make the unit move.) This way you could use the same actions for player & AI.


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Re: The RTS ai... [Re: KojaK] #171817
12/09/07 10:53
12/09/07 10:53
Joined: Feb 2004
Posts: 217
Wennigsen, Germany
Gordon_Shumway Offline
Member
Gordon_Shumway  Offline
Member

Joined: Feb 2004
Posts: 217
Wennigsen, Germany
Hi Kojak,

I will give you some advices, like I do the RTS-AI, which is nearly finished, in "2662 - The Year of the Conflict".
In my opinion the AI consists of two important parts.
1. Multi-tiered-AI
2. Influence-Map

A Multi-Tiered-AI is similar to the ranking in the army. There are units which can fight, but they are all working by their own (just use Finite-State-Machines like WAIT,ATTACK, MOVE, RETREAT....what ever you want), there are sergeants who control a group and tell the units to attack someone or scout (you need FSMs for the groups ..... and finally their is a commander who tell the sergeants what to do.

An Influece-Map is an extra layer on your terrain. Use an array for example 20x20.
Now, you can get lots of informations:
1. Is the tile unexplored, belongs to the player or AI or is it a conflict area? (This is important for scouting)
2. You can give each tile a weight by simply checking in which tile the entity is and adding f.e. the health points of the units to the tile value. Then you can also calculate the influence to neighboring cells (long distances to units are contribute less to the influence map then short distances to the unit). This gives you the power to get lots of informations like weak spots or best path....and you can make lots of other influence maps, too.

I hope this will help, you.

Bye G.S.


***Neue Webseite!! Mit vielen neuen Infos! http://www.2662-thegame.de.vu***
Re: The RTS ai... [Re: Gordon_Shumway] #171818
12/09/07 18:37
12/09/07 18:37
Joined: Jan 2007
Posts: 110
USA East Coast
K
KojaK Offline OP
Member
KojaK  Offline OP
Member
K

Joined: Jan 2007
Posts: 110
USA East Coast
I like that influence map thing. But how would you set that up? How big would each tile be? Would every unit have to check where he is? These are all problems that need to be explained, as this is my first run with an RTS. The soldiers were the easy part, the AI is a toughy.

Yeah, I already have all the units set up. See, they work based on animations. The units do what you tell them. They handle their own methods of attacking, moving, etc. Lets say that we have a soldier(you), and to make him move:

you.anim = anim_move;
you.gox = target.x;
you.goy = target.y;
you.goz = target.z;

or to make him attack:

you.attack = on;
you.attackhandle = handle(enemy_guy);
(all of the anim_ are defined as 1, 2, 3, and .anim is declared as a skill)

See? All my ai is going to do is simulate an actual player. I already have the player's controls hooked up to the mouse.

What I was needing was a good process that the AI can go through to figure out what the best strategy is, where the weak spots are, etc. I'm going to make my maps bigger later on, with more objectives such as to take over a building, secure and defend a power plant, etc. I was just wondering how to make my AI smart-ish enough for it to be fun.

One more important thing, this game will be small, so there is only one type of unit, but they have special abilities. One side can bring back enemy soldiers to fight for them, and one side can crouch, to snipe the enemies. Of course, both of these have thier drawbacks, such as crouching takes time to set up(which is handled by the soldier), and the ressurecting takes half of the unit's life and speed(which can be recovered by killing, and is also handled by the unit). So, you know, the AI needs to use these abilities.

Last, do you know of a good auto-setup pathfind system that sets the nodes for you? I really don't want to have to set up the nodes for every map. I also want to incorperate a "map-builder" once you complete the game.

Last edited by KojaK; 12/09/07 18:40.

Lead programmer for Two Screws Loose Click here for our forums, and downloads for our games
Re: The RTS ai... [Re: KojaK] #171819
12/09/07 20:24
12/09/07 20:24
Joined: Feb 2004
Posts: 217
Wennigsen, Germany
Gordon_Shumway Offline
Member
Gordon_Shumway  Offline
Member

Joined: Feb 2004
Posts: 217
Wennigsen, Germany
Lots of questions....ok I will give my very best to explain:
1. How big is each tile ? This depends on you and your memory. I use for a large area a square by 20x20 tiles. All I have to do is to devide the areasize by 20 and then I know how big is each tile. One hint for you, if you use 20x20=400 tiles and you save 5 informations in each tile your array is of scale[2000]...be carefull with you resources.
2. For update the influence map - updating takes time and your game will slow down. But you don't have to update this that often. I'm using a master AI, which is update every few seconds and the group AI is update every second and the unit AI is update every time. During the update you have to check every unit and its contribution to the map tiles.
3. I think it is easier to use just one skill for the units status....
you.status=status_move or you.status=status_Attack
then just use define
define status_move=1;
define status_attack=2;.....
4. For getting informations like weak spots:
use the influence-map, check all tiles with tile_status=enemy(belongs to the enemy) the one with the smallest value and f.e. shortest distance is the next attackgoal.
5. To decide what a unit should do...use a formular, f.e., a big tank is coming and a single soldier is waiting just in front of him, what to do retreat or fight? Formular: decision = enemy.hp+enemy.attack_power - my.hp - my.attack_power. So if decision is < a special value retreat else attack the enemy.
6. Pathfinding is also very important in an AI, in some cases obstacle avoidance algorithm are good enough, but sometimes A*-Algortihm or similar are very important, too. But be carfull using them very often takes lots of resources (150 entities calculating a new path at one time).

So, I hope this will help you.
If you have any question please ask again.

Bye G.S.


***Neue Webseite!! Mit vielen neuen Infos! http://www.2662-thegame.de.vu***
Re: The RTS ai... [Re: Gordon_Shumway] #171820
12/10/07 20:58
12/10/07 20:58
Joined: Jan 2007
Posts: 110
USA East Coast
K
KojaK Offline OP
Member
KojaK  Offline OP
Member
K

Joined: Jan 2007
Posts: 110
USA East Coast
There's only one problem, it is a command & conquer type game where the troops move freely, so that no tiles are used.

Is there any way you can combine a self-creating, chart pathfinding system(where a chart is made at the very beginning telling where to go from your location to get to where you're going) with your influence map? That way the nodes of the pathfinding system could be your influence map, and the AI would know where the troops are, and based on some if statements and some formulas, know how to attack. I could also allow the AI and player to follow footprints to find the enemies. I can also set up an AI "unknown" factor, where they have no idea where they're going, or where the players are. This can make a "search and Destroy" mission even more fun.

I just need to know how to set up this self-creating pathfinding system. I can handle the charts, and the influence map, I understand how those work. I just need to know how make the nodes space themselves apart, and fall into place on the terrain. Then once they are in place, I can code them to scan eachother, delete the ones that are too high, or on top of buildings, etc. A little help would be appreciated on the actual pathinding part, where I generate the chart.


Lead programmer for Two Screws Loose Click here for our forums, and downloads for our games
Re: The RTS ai... [Re: KojaK] #171821
12/12/07 09:55
12/12/07 09:55
Joined: Feb 2004
Posts: 217
Wennigsen, Germany
Gordon_Shumway Offline
Member
Gordon_Shumway  Offline
Member

Joined: Feb 2004
Posts: 217
Wennigsen, Germany
I'n not quite sure, if I understand your question correctly. Your problem is the making of the nodes on your terrain?
So, you can use the influence map and the center of each tile could be a possible node position.


***Neue Webseite!! Mit vielen neuen Infos! http://www.2662-thegame.de.vu***
Re: The RTS ai... [Re: Gordon_Shumway] #171822
12/12/07 20:32
12/12/07 20:32
Joined: Jan 2007
Posts: 110
USA East Coast
K
KojaK Offline OP
Member
KojaK  Offline OP
Member
K

Joined: Jan 2007
Posts: 110
USA East Coast
I understand that much. I'm just asking HOW do I make the nodes do that? I need a specific description. I don't need the code, but I do need to know how to code it.

After the pathfinding system set itself up, I was going to make each node a part of the influence map with a skill and some defines such as "player_control", or "neutral_control" etc. I was going to make each node a part of the influence map, and therefore make it easier to code the AI.

Now that I know how to code good AI(thanks to all of your help), what I really need to know now is how to code a pathfinding system that positions the nodes on the terrain.


Lead programmer for Two Screws Loose Click here for our forums, and downloads for our games
Re: The RTS ai... [Re: KojaK] #171823
12/13/07 12:45
12/13/07 12:45
Joined: Feb 2004
Posts: 217
Wennigsen, Germany
Gordon_Shumway Offline
Member
Gordon_Shumway  Offline
Member

Joined: Feb 2004
Posts: 217
Wennigsen, Germany
Ok, you're thinking of nodes as used in the WED, aren't you?
But if it is so, forget about that. Just use in extra layer (you can combine it with the influence map) or use your influence map as the layer for the nodes.
You should have something like this (for 5x5 tiles)
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
All you have to do is to find out in which tile is your unit and in which tile is your goal, then start the pathfindingsysteme and erverything should work.
The tile is your node or in an extra layer some nodes belong to one tile.
Is this your problem? If it is not, please make an example.
Bye G.S.


***Neue Webseite!! Mit vielen neuen Infos! http://www.2662-thegame.de.vu***
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1