Revisit 3

Web log of development issues.

Revisit 3

Postby adamsderk » Tue Jun 02, 2009 4:29 pm

Greetings,

Today it is all about A*

The river code as mentioned before is actually the same as any pathfinding algorithm. Since A* (pronounced A-star) is the pack leader for most applications, I decided to implement it. There are some good sites on the Net explaining it, but translating words into code for a process I didn't completely understand was difficult. It really came down to one misinterpretation on my part. Once I discovered that, the code flew through the terrain. And by "flew," I mean taking around 12 seconds to calculate the path. Ugh.

I was starting easy and much of my terrain is flat. Since the height of the terrain is used in the calculation, it made most of the map the same difficulty to move across and therefore, more of it had to be calculated. But I was always planning to add an illusionary height to the flat areas to make the river wind through the flat areas instead of jut making straight lines. Once I added that, the computing time dropped to around 4 seconds. Whew, much better.

I'm still working on making the river various widths, depending on the desired depth of the water, but it is coming along nicely.

Another idea I have to speed it up is to use a 128x128 grid instead of a 256x256 grid with each point being an average of four points in the original grid. This should make the code even faster, and faster is important because I need to make multiple runs. Not more rivers, more paths.

I am trying to get as many of the terrain types from CBT into BTS. Roads have always been important, I just didn't know how to make them programmatically. Hello pathfinding. I'm planing on having roads between the three defending nav points. The attacker nav point is off the beaten path (and hopefully player selectable).

Having roads also makes another of my problems go away. The missions where you have to guard (or attack) a transport... I can have them follow a road instead of striking off into the wilderness.

In the process of making the new terrain, I have also created a terrain type map that the system can use. That means I can have AI stay on or off certain terrain types.

And for those of you who haven't been paying attention... what happens when a river and a road intersect? Thats right, bridges. It's going to be tricky, but now I can programmatically figure out where bridges should go and what their orientation should be (to connect the two road segments).

So a question for you, how should the AI behave if they have to cross a river and some bad person blows up the bridge? And assume that the river is continuous (because it is) and there aren't other ways across. Do they hang around where the bridge used to be? Do they go home? Do I have to include a "bridge making" unit to be called out? Do I add "natural" bridges that can't be destroyed along the river, but not on the road? Other suggestions?

Thanks.
Image
adamsderk
Site Admin
 
Posts: 1404
Joined: Tue Apr 19, 2005 11:52 pm
Location: Western Washington

Re: Revisit 3

Postby Hana Yuriko » Tue Jun 02, 2009 7:39 pm

adamsderk wrote:So a question for you, how should the AI behave if they have to cross a river and some bad person blows up the bridge? And assume that the river is continuous (because it is) and there aren't other ways across. Do they hang around where the bridge used to be? Do they go home? Do I have to include a "bridge making" unit to be called out? Do I add "natural" bridges that can't be destroyed along the river, but not on the road? Other suggestions?.


I think it would depend on a few factors. Is the unit equipped with long range weapons? If so, have the AI follow the player on the other side of the river. Mirroring movements. If the player comes into range, the AI would try to fire.

Does the AI unit have Jumpjets? If they can jump the river from bank to bank, then I would imagine that they would.

Can the river be crossed by going under water? If it can, I don't see why a 'mech wouldn't wade through.

The whole point of a BattleMech is that it's a mobile weapons platform. Able to traverse terrain that no other ground unit could.
Hana Yuriko
 
Posts: 274
Joined: Sat Apr 23, 2005 4:18 am

Postby adamsderk » Tue Jun 02, 2009 8:28 pm

Hana,

Sorry, I realize I didn't describe the situation sufficiently.

A caravan is traveling from nav A to nav C. There is a river with a bridge between A and C. If the attacker gets to the bridge first and destroys it, what should the caravan do? Assuming that the caravan is one or more ground vehicles that can't go around, over, or through the river.

You are absolutely right that a combat unit would do all of the things you described.

Thanks.

P.S. Glad you are still around :)
Image
adamsderk
Site Admin
 
Posts: 1404
Joined: Tue Apr 19, 2005 11:52 pm
Location: Western Washington

Postby Hana Yuriko » Tue Jun 02, 2009 11:55 pm

That makes more sense. Can you program the AI to locate secondary and tertiary routes through the terrain?

The Bridge Layer option is an interesting one. It could lead to further scenarios and "impromptu" missions within an overall scenario. You not only have to continue to defend the convoy, but maybe even locate and protect the bridge layer, set up a temporary base camp while the bridge is repaired or a new one is set up, or whatever.

And while all of that is going on, the player could have the option to recon down the river for another crossing point. After that, you'd have to convey a way for the convoy to continue it's journey (an event tag after you locate another crosing?).
Hana Yuriko
 
Posts: 274
Joined: Sat Apr 23, 2005 4:18 am

Postby adamsderk » Wed Jun 03, 2009 4:50 pm

Hana,

Interesting...

So, I could have other "natural" bridges that a unit would have to "identify" to have the convoy move to the new "bridge."

So the defending units would have to split up with some looking for another route, while the rest, rounded up the convoy and defend it from any attackers.

I like it. Of course bridges will be of various strengths, so it will be up to the attacker to determine if they should destroy the bridge to round up the convoy, or just hit the convoy directly.

Thanks.
Image
adamsderk
Site Admin
 
Posts: 1404
Joined: Tue Apr 19, 2005 11:52 pm
Location: Western Washington

Postby Stormwolf » Thu Jun 04, 2009 9:32 am

adamsderk wrote:I like it. Of course bridges will be of various strengths, so it will be up to the attacker to determine if they should destroy the bridge to round up the convoy, or just hit the convoy directly.

Thanks.


You could include weak bridges that can't hold the weight of a mech :idea:

It would give Infantry/battlearmor a slight advantage.
Image
Stormwolf
 
Posts: 374
Joined: Sat Aug 13, 2005 12:22 pm
Location: The Netherlands


Return to Development Blog

Who is online

Users browsing this forum: No registered users and 4 guests

cron