How do I make a good Sport AI?

Get help using Construct 2

Post » Tue Jul 26, 2016 11:48 pm

right now i just use pathfinding to make the AI move to the ball but its not great, has anyone found a good way of doing it?
B
7
S
1
Posts: 54
Reputation: 527

Post » Tue Jul 26, 2016 11:56 pm

This is a very broad question and impossible to answer properly without more information.

What sort of sport game is it? Do the players need to maintain some kind of field position? Is there a field at all? Is your sport game based on a realism, or is it a fantasy sport game?

More information about your game would possibly be beneficial to getting a good answer.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Post » Fri Jul 29, 2016 12:45 am

its like mini golf and football(soccor), with 2 opposing teams of 4 trying to get the ball in the opposing teams goal. The player can move freely and can also fire "bullets" at the ball. Right now my AI all just charge at the ball randomly shooting at it towards the goal.

What im hoping for is to maintain field position,
Shoot more accurately at the goal. (right now im literally just using goal is within x angles then they shoot)

Any help is greatly appreciated, Thank you
B
7
S
1
Posts: 54
Reputation: 527

Post » Fri Jul 29, 2016 2:41 am

This is likely to get very confusing and complicated, but I will try to give you some ideas.

For maintaining field position you could do a check for the distance between the ball and each AI player. If they are too far away from the ball then they will go to their position on the field instead. You can perhaps over-ride this if there is NO player close to the ball, you can pick the AI which is CLOSEST to the ball and make him chase it. Obvioulsy there are a lot more things to take care of regarding this - but this would maybe be a good place to start.

You can also make shooting the ball the same... the AI player must be within a certain distance (use the distance(x1,y1,x2,y2) formula) before he/she will shoot the ball.

Using if goal is within angle is probably a good way to do it - but you could add some accuracy changes using an instance variable for that player so it will maybe go a little bit left or tight when they shoot to give it a little more realism.

You can also try to make the AI dodge around the player if the distance is too close. This would be a fairly complex thing to do since you would need some math to figure out the best direction for the AI to change to from it's current direction.

Everything about a sport game is really easy to make, except for the AI. AI in a sport style game is by far the most complex part of the game - since that's really what makes the game good.

Hopefully some of these ideas might help.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499


Return to How do I....?

Who is online

Users browsing this forum: NN81, pmerineau and 28 guests