This project currently is waiting for a game developer with some time at hand. See this thread.

View unanswered posts | View active topics It is currently Sun 23. Sep 2018, 20:12



Reply to topic  [ 10 posts ] 
 How does the AI behave in a train fight? 
Author Message
Contributor
User avatar

Joined: Fri 30. Aug 2013, 14:10
Posts: 125
Location: Rostock, GER
So this might be going technically but anyone who played this game might have observed a specific AI behavior when a train fight happens.

- The first thing I noticed was that the AI basically tries to move their engine out of the line of fire by moving their train to the left/right edge of the scene.
- The second thing I noticed was as when you deploy soldiers and they are closing in on the AI train, the AI train starts moving away from your soliders.
- The AI soliders / mammoths usually move in straight lines towards your train (never actually seen them moving diagonal)
- The AI soliders are basically heading towards your engine and drop bombs more or less randomly on their way.

Have you noticed any other AI behavior? I'm asking because I'm still trying to rebuild the train fight engine with JavaScript. As you may know: In the current status the AI can use it's cannons and machine guns. Now I'm onto coding the moving behavior for the AI train and AFAIK the AI train only moves when certain conditions are met (like distance from the next player cannon / solider). I need to check/define these conditions so that the result would be a more or less intelligent behavior.


Tue 23. Sep 2014, 18:19
Profile ICQ
Contributor
User avatar

Joined: Fri 30. Aug 2013, 14:10
Posts: 125
Location: Rostock, GER
Short update:

I think I found a nice & easy solution for the AI train moving behavior that might be close enough to the original. I just need to finetune it for now.

At first I thought about calculating distances. Just some things like "How far away is the nearest player cannon/mammoth/solider" and if there are some of these entities in a certain range, move the AI train away from them. The expected result would have been a barely beatable AI train but with a very intelligent moving behavior. But then I came to the conclusion that calculating positions for maybe 300+ elements simultainously on the fight screen might have been more than computers in the early 90's could handle, besides the original game was not coded in C (It was coded in Modula-3, based on the .IO files in the game folder).

I dropped the calculating idea and focused on the 3 possible moving "directions" for the AI train: Left, Right and Stop. Then I thought the AI has nothing more to do than to "decide" in which direction the AI train should move. So I set up an interval which is fired every 0.25 to 5 seconds to set the moving direction for the AI. And there are also some small influence factors to make the AI train behave like in the original gameplay.

For example: If the player train is moving, the interval for firing the event is set down to 1 second and the AI train will most likely move in the direction the player train moves (noticed this in the original gameplay) and there's only a small chance that the AI train would move in the opposite direction.

I tested this in my train fight sandbox and I was very pleased with the results. Link and code will be published here when I'm done with finetuning (which shouldn't take long) ;)


Thu 25. Sep 2014, 21:38
Profile ICQ
Contributor
User avatar

Joined: Sun 17. Mar 2013, 11:31
Posts: 424
Location: Hajdúszoboszló. Hungary
For a simple remake this could work, though I've notied that the Viking Union train usually moves in the same direction as you, though after a bit delay.

For a new game, I thought that the weapon wagons (Cannon, MG) could fire diagonally to some extent like +/- 15-30-45° in either direction.


Fri 26. Sep 2014, 16:38
Profile WWW
Contributor
User avatar

Joined: Fri 30. Aug 2013, 14:10
Posts: 125
Location: Rostock, GER
Quote:
For a new game, I thought that the weapon wagons (Cannon, MG) could fire diagonally to some extent like +/- 15-30-45° in either direction.

The idea is basically nice but how should someone control this efficiently?

I mean you can of course use the arrow keys to controll ALL machine guns and cannons at once but if you want to be in control of the firing direction for each wagon you have to select it first and then adjust the turret. I don't say that this can't be done but you'd be probably overrun by the AI forces if you focusing on adjusting the turrets.


Sat 27. Sep 2014, 01:05
Profile ICQ
Administrator
User avatar

Joined: Sat 16. Mar 2013, 18:24
Posts: 410
Location: Germany
Scarabaeus wrote:
I mean you can of course use the arrow keys to controll ALL machine guns and cannons at once but if you want to be in control of the firing direction for each wagon you have to select it first and then adjust the turret. I don't say that this can't be done but you'd be probably overrun by the AI forces if you focusing on adjusting the turrets.


And that's why you need a PAUSE - key. :-)
Press Pause, adjust everything like you want, unpause... wait for the turrets to turn to the right angle, press pause again, issue the fire-command. :D
I don't see any other solution to this.

This thread is very nice - I can't really add something to it up to now (so I didn't comment) but keep at it! :)
Maybe one thing: I also think that much has been done just using some random number generator. Like firing a cannon or machine gun.
That would explain that the enemy will fire his weapons even if your train is far off the screen sometimes. :-)

_________________
'Person who say it cannot be done should not interrupt person doing it.' --Chinese Proverb


Sat 27. Sep 2014, 05:16
Profile WWW
Contributor
User avatar

Joined: Sun 17. Mar 2013, 11:31
Posts: 424
Location: Hajdúszoboszló. Hungary
Ever heard of automatic control?
AI can do it and rather easily, checking if there are enemy units in it's line of sight.
And for such I though of why not put some obstacles like Ice, Snow, or Rocks? Maybe even some trees?


Sat 27. Sep 2014, 07:07
Profile WWW
Administrator
User avatar

Joined: Sat 16. Mar 2013, 18:24
Posts: 410
Location: Germany
TZoli wrote:
Ever heard of automatic control?
AI can do it and rather easily, checking if there are enemy units in it's line of sight.
And for such I though of why not put some obstacles like Ice, Snow, or Rocks? Maybe even some trees?


Automatic Control would be very nice too. :D It should nevertheless be customizable.
Do you want your cannons to shoot everything or leave the good wagons intact?
Should they first shoot the locomotive and then the cannons?
How near do enemy soldiers be so that machine guns fire at them instead of focusing on mammoths?

_________________
'Person who say it cannot be done should not interrupt person doing it.' --Chinese Proverb


Sat 27. Sep 2014, 09:34
Profile WWW
Contributor
User avatar

Joined: Fri 30. Aug 2013, 14:10
Posts: 125
Location: Rostock, GER
http://www.christian-wederka.de/transarctica/index.html
Here you can test the AI moving behavior. It would be nice if you could give me some feedback on this. If you encounter a shitty train setup, reload the page.

And here's the code for the AI movements: http://pastebin.com/KgYqAk8W

Quote:
Maybe one thing: I also think that much has been done just using some random number generator. Like firing a cannon or machine gun.
That would explain that the enemy will fire his weapons even if your train is far off the screen sometimes. :-)
That's what I did already. If the AI has intact machine guns and cannons, they will fire randomly even if your train is not in the line of fire. And that's the basic approach for creating an AI. Set up intervals with random interval timing, random numbers everywhere and influence factors the make the AI behave more unpredictable for the player.

Quote:
Ever heard of automatic control?
AI can do it and rather easily, checking if there are enemy units in it's line of sight.
And for such I though of why not put some obstacles like Ice, Snow, or Rocks? Maybe even some trees?
Whoa slow down man.

As both trains move the line of sight has to be calculated on the fly which isn't as easy as it sounds like. Checking the alignment of the turrets, checking the distances between the obstacles and the turrets, checking the dimensions of a specific obstacle (for a corrent line of sight), updating the line of sight for each turret...that's a whole bunch of calculations that needs to be done.

I'd rather prefer getting a stable basic fighting engine at first which is as close as possible to the original gameplay and for future versions (thank god someone invented v1.0, v1.1, v1.2 and so on) we can think of extending to make it more interesting. Trying to put a shitload of features in the first version will mostly end in never getting the first version done. Always step by step and not everything at once.


Sat 27. Sep 2014, 16:22
Profile ICQ
Contributor
User avatar

Joined: Sun 17. Mar 2013, 11:31
Posts: 424
Location: Hajdúszoboszló. Hungary
Isn't there are relative and absolute things in turret control? What you telling us I assume you are doing the absolute calculation like watching as an outsider. But a relative method works well with moving objects. Think how they done this in X-Wing or TIE-Fighter? Though I'm no programmer


Sat 27. Sep 2014, 17:59
Profile WWW
Administrator
User avatar

Joined: Sat 16. Mar 2013, 18:24
Posts: 410
Location: Germany
Scarabaeus wrote:
http://www.christian-wederka.de/transarctica/index.html
Here you can test the AI moving behavior. It would be nice if you could give me some feedback on this. If you encounter a shitty train setup, reload the page.


Wow, that looks nice!
Almost feels like the real deal when it comes to 'AI' :-).

Scarabaeus wrote:
As both trains move the line of sight has to be calculated on the fly which isn't as easy as it sounds like.


Luckily thanks to the 548093 of ego-shooters this line-of-sight calculation (which is needed for nearly every bullet!) this algorithm has been thourougthly researched. Though I don't know how the hell you would implement something that needs to be very fast in JavaScript. (Personally I would use CoffeeScript :-) ).
But also for this there is ES6 and the new JavaScript Interpreters in the modern browsers but I don't know how you would need to write something so that it can be very fast!

_________________
'Person who say it cannot be done should not interrupt person doing it.' --Chinese Proverb


Sat 27. Sep 2014, 18:28
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: Bing [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software for PTF.