BETA randomised maps

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators, Slitherine Core, BA Moderators

Amaris
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 929
Joined: Fri Jul 23, 2010 11:08 am
Location: France
Contact:

BETA randomised maps

Post by Amaris » Sun May 22, 2011 5:53 pm

My goal is to create a random map with a script.

I advanced a little on this crazy project. There is more work but I think it looks great!

Image

Image

Image

Image

Image

Image

Image

pipfromslitherine
Site Admin
Site Admin
Posts: 8788
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine » Sun May 22, 2011 6:34 pm

Awesome stuff! :) Let us know if you want any testing or help.

Cheers

Pip

gollummen
Corporal - Strongpoint
Corporal - Strongpoint
Posts: 72
Joined: Wed Nov 24, 2010 1:00 pm

Post by gollummen » Sun May 22, 2011 8:20 pm

Random maps would rock!

Looks good so far

IainMcNeil
Site Admin
Site Admin
Posts: 13441
Joined: Fri Apr 01, 2005 10:19 am

Post by IainMcNeil » Mon May 23, 2011 10:26 am

Very cool - it shows how flexible the engine is!

berndN
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 141
Joined: Sat Aug 07, 2010 6:13 pm

Post by berndN » Mon May 23, 2011 10:35 am

Great looking maps. Thanks for the work !

Amaris
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 929
Joined: Fri Jul 23, 2010 11:08 am
Location: France
Contact:

Post by Amaris » Mon May 23, 2011 4:51 pm

I want to complexify the road' system. May be the river's generation also. Because they are very simple. They are the first functions I wrote. At first I had trouble with the lack of data structures. But I found how to have a 2-dimensional array with GetTileData and SetTileData using index = 1 :P

I also have to learn to grow the hills, if possible :wink:

For now, the generation is quite simple, according to an established plan: a river in middle, a road which crosses the entire map, one village on each side, the remainder is composed of forests, fields, small villages and some rough tiles.

I also work to make it more diverse. The goal is to have a generator as complete.

pipfromslitherine
Site Admin
Site Admin
Posts: 8788
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine » Mon May 23, 2011 8:29 pm

I think Merr was working on something similar - so you might be able to exchange ideas!

I'm not sure you can set the height on a tile, so hills might be difficult, but I can always add it to the wishlist for the next update.

I want to add more robust data structures to the scripting, but that's part of the load of improvements I want to make... :)

Let me know if you have any problems.

Cheers

Pip

Amaris
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 929
Joined: Fri Jul 23, 2010 11:08 am
Location: France
Contact:

Post by Amaris » Thu May 26, 2011 5:44 pm

Well I have advanced :D I worked on the variability of maps.

Image

Image

Image

Image


You can notice some more roads. Roads junctions is hell :evil:

I also work to a campaign completely random with carryover system. Each mission is to capture VPs on map. I've already placed some Germans. But all this requires more work before testing :wink:

There are still problems with the roads :evil: I should also add some diversity to the villages. Put some fortifications (there has been in the villages.)

The script is close to 2,000 lines :shock: There are many things to rewrite ...

pipfromslitherine
Site Admin
Site Admin
Posts: 8788
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine » Thu May 26, 2011 7:23 pm

I can imagine the junctions being tough - it's a combinatorial nightmare! The water edging stuff took a lot of tinkering.

Looking very cool though.

Cheers

Pip

Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post by Merr » Thu May 26, 2011 11:30 pm

Amaris,

Your map work looks so much more natural than my "terrain blocks". :)

My scripts are also horribly large ... I've never built so many functions to get something done!

Roads junctions and streams are my worst problem too!

Keep up the good work! I hope we can all enjoy random maps together!

pipfromslitherine
Site Admin
Site Admin
Posts: 8788
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine » Fri May 27, 2011 2:14 am

Perhaps a combo system? Use prebuild junction mega-tiles as your starting point, then grow the roads out from them - saves having to try and fit arbitrary roads together?

Cheers

Pip

Amaris
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 929
Joined: Fri Jul 23, 2010 11:08 am
Location: France
Contact:

Post by Amaris » Fri May 27, 2011 1:26 pm

I found a solution for roads and junctions :P :P :P

First I generate my random roads in a 2-dimensional array. I have a function BuildRoad(x1, y1, x2, y2) that builds a road between points x1, y1 and x2, y2 in my array.

Then when all roads were built, I call another function, DrawRoad(), that will read the array and place the tiles according to their neighbor :D As there is just eleven different cases it's not too complex.

An example (without fields, forest, ...):

Image

Code: Select all

FUNCTION BuildRoad(x1, y1, x2, y2)
{
	int i ;
	int j ;
	int k ;
	int x ;
	int y ;
	int yfinal ;
	int flag ;
	
	flag = 0 ;
	x = Min(x1, x2) ;
	if (x == x1)
	{
		y = y1 ;
		yfinal = y2 ;
	}
	else
	{
		y = y2 ;
		yfinal = y1 ;
	}	
	SetTileData(x, y, 2, 1) ;
	for (k = 0 ; flag == 0 ; k++)
	{
		if ((x == Max(x1, x2)) && (y == yfinal))
		{
			flag = 1 ;
		}
		if ((x == Max(x1, x2)) && (y != yfinal))
		{
			if (y < yfinal)
			{
				y++;
			}
			else
			{
				y--;
			}
		}
		if (( x != Max(x1, x2)) && (y == yfinal))
		{
			x++;
		}
		if ((x != Max(x1, x2)) && ( y != yfinal))
		{
			k = Rand(1,100);
			if (k < 50 )
			{
				x++;
			}
			else
			{
				if (y < yfinal)
				{
					y++;
				}
				else
				{
					y--;
				}
			}
		}
		SetTileData(x, y, 2, 1) ;
	}
}

FUNCTION DrawRoads()
{
	int i ;
	int j ;
	int id ;
	
	for (i = GetGlobal("xmin") ; i < GetGlobal("xmax") ; i++)
	{
		for (j = GetGlobal("ymin") ; j < GetGlobal("ymax") ; j++)
		{
			if (GetTileData(i, j, 2) == 1)
			{
				//Draw road tiles
				if ((GetTileData(i+1, j, 2) == 1) && (GetTileData(i-1, j, 2) == 1) && (GetTileData(i, j+1, 2) == 1) && (GetTileData(i, j-1, 2) == 1))
				{					
					//crossroads
					id = GetTileOnTile(2, 10, 12) ;
					PlaceTile(i, j, id, 2);
					SetTileData(i, j, 1, 1);						
				}
				if ((GetTileData(i+1, j, 2) == 1) && (GetTileData(i-1, j, 2) == 1) && (GetTileData(i, j+1, 2) == 0) && (GetTileData(i, j-1, 2) == 0))
				{
					//line x
					id = GetTileOnTile(2, 10, 10) ;
					PlaceTile(i, j, id, 0);
					SetTileData(i, j, 1, 1);					
				}	
				if ((GetTileData(i+1, j, 2) == 0) && (GetTileData(i-1, j, 2) == 0) && (GetTileData(i, j+1, 2) == 1) && (GetTileData(i, j-1, 2) == 1))
				{
					//line y
					id = GetTileOnTile(2, 10, 10) ;
					PlaceTile(i, j, id, 1);
					SetTileData(i, j, 1, 1);						
				}		
				if ((GetTileData(i+1, j, 2) == 1) && (GetTileData(i-1, j, 2) == 1) && (GetTileData(i, j+1, 2) == 1) && (GetTileData(i, j-1, 2) == 0))
				{
					//T roads UP
					id = GetTileOnTile(2, 10, 13) ;
					PlaceTile(i, j, id, 2);
					SetTileData(i, j, 1, 1);						
					
				}	
				if ((GetTileData(i+1, j, 2) == 1) && (GetTileData(i-1, j, 2) == 1) && (GetTileData(i, j+1, 2) == 0) && (GetTileData(i, j-1, 2) == 1))
				{
					//T roads DOWN
					id = GetTileOnTile(2, 10, 13) ;
					PlaceTile(i, j, id, 0);
					SetTileData(i, j, 1, 1);						
				}		
				if ((GetTileData(i+1, j, 2) == 1) && (GetTileData(i-1, j, 2) == 0) && (GetTileData(i, j+1, 2) == 1) && (GetTileData(i, j-1, 2) == 1))
				{
					//T roads LEFT
					id = GetTileOnTile(2, 10, 13) ;
					PlaceTile(i, j, id, 1);
					SetTileData(i, j, 1, 1);						
				}	
				if ((GetTileData(i+1, j, 2) == 0) && (GetTileData(i-1, j, 2) == 1) && (GetTileData(i, j+1, 2) == 1) && (GetTileData(i, j-1, 2) == 1))
				{
					//T roads RIGHT
					id = GetTileOnTile(2, 10, 13) ;
					PlaceTile(i, j, id, 3);
					SetTileData(i, j, 1, 1);						
				}	
				if ((GetTileData(i+1, j, 2) == 0) && (GetTileData(i-1, j, 2) == 1) && (GetTileData(i, j+1, 2) == 0) && (GetTileData(i, j-1, 2) == 1))
				{
					//Turn Down-right
					id = GetTileOnTile(2, 10, 11) ;
					PlaceTile(i, j, id, 0);
					SetTileData(i, j, 1, 1);						
				}	
				if ((GetTileData(i+1, j, 2) == 1) && (GetTileData(i-1, j, 2) == 0) && (GetTileData(i, j+1, 2) == 0) && (GetTileData(i, j-1, 2) == 1))
				{
					//Turn Down-left
					id = GetTileOnTile(2, 10, 11) ;
					PlaceTile(i, j, id, 1);
					SetTileData(i, j, 1, 1);						
				}
				if ((GetTileData(i+1, j, 2) == 1) && (GetTileData(i-1, j, 2) == 0) && (GetTileData(i, j+1, 2) == 1) && (GetTileData(i, j-1, 2) == 0))
				{
					//Turn Up-left
					id = GetTileOnTile(2, 10, 11) ;
					PlaceTile(i, j, id, 2);
					SetTileData(i, j, 1, 1);						
				}	
				if ((GetTileData(i+1, j, 2) == 0) && (GetTileData(i-1, j, 2) == 1) && (GetTileData(i, j+1, 2) == 1) && (GetTileData(i, j-1, 2) == 0))
				{
					//Turn Up-right
					id = GetTileOnTile(2, 10, 11) ;
					PlaceTile(i, j, id, 3);
					SetTileData(i, j, 1, 1);						
				}				
			}
		}
	}
}

pipfromslitherine
Site Admin
Site Admin
Posts: 8788
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine » Fri May 27, 2011 2:05 pm

Very cool. I guess roads are actually a little simpler as they aren't edged areas, just individual tiles. But it looks like your code handles every case so that's awesome :).

Looking forward to seeing the resulting campaign!

Cheers

Pip

Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post by Merr » Fri May 27, 2011 4:37 pm

Amaris wrote:I found a solution for roads and junctions :P :P :P
Very cool indeed! I've been wondering how to do this ... mind if I borrow? :wink:

Also, you should apply this to building streams .... I built a stream script that "wiggles" but I like your script better!
After I built the stream I used Pip's SLITH_EDGING_WATER function to clean the edges.

I think your script can be adapted to build streams too !

pipfromslitherine
Site Admin
Site Admin
Posts: 8788
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine » Fri May 27, 2011 5:02 pm

Yeah - the edging of streams is a pain - as there isn't always a valid way to edge any combination of tiles. But it looks like you guys are well on the way - I'm incredibly impressed! :)

Cheers

Pip

Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post by Merr » Fri May 27, 2011 5:20 pm

pipfromslitherine wrote:Yeah - the edging of streams is a pain - as there isn't always a valid way to edge any combination of tiles. But it looks like you guys are well on the way - I'm incredibly impressed! :)

Cheers

Pip
Well, your work is much appreciated because it saved me time!
I borrowed it and made variations that edged the water to fit my script ... Merr_Edging_Water .... Merr_Edging_Marsh.
The cool part continues because I'm building "gullies" which are nothing more than my "mud_tiles" replacing the water ... By adding the hedge row object's it makes sneaky little channels that infantry can manuever in where armor cannot !

With Amaris' great script :arrow: It just get's better every day!

tim1966
Administrative Corporal - SdKfz 232 8Rad
Administrative Corporal - SdKfz 232 8Rad
Posts: 161
Joined: Sat Jul 31, 2010 7:15 pm
Location: Brighton, UK
Contact:

Post by tim1966 » Fri May 27, 2011 9:43 pm

:shock: Amazing stuff chaps! This will really help modders and scenario makers and we should see a whole raft of new battles :D
Models from Tim's Surplus Store ... Established 1966 ... Open 24/7 ... closed for TEA TIME

Amaris
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 929
Joined: Fri Jul 23, 2010 11:08 am
Location: France
Contact:

Post by Amaris » Mon May 30, 2011 10:50 am

A playable version will soon be ready:

Selection Force:
Image

Initial Start:
Image

Initial Start with AI forces:
Image

Detail of AI forces:
Image

pipfromslitherine
Site Admin
Site Admin
Posts: 8788
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine » Mon May 30, 2011 3:27 pm

Awesome! It will be very cool to see it up and running!

Cheers

Pip

Amaris
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 929
Joined: Fri Jul 23, 2010 11:08 am
Location: France
Contact:

Post by Amaris » Sun Jun 05, 2011 12:17 pm

This is the first playable version :P

Warning: may remain some bugs :wink: That said the maps should be playable. There may still be some minor problems with the roads but it works pretty well.

This is a three scenarios campaign with carry over system. Each scenario is randomly generated: map, goals, enemy forces and enemy reinforcements.

Download: : https://sites.google.com/site/bbcbaamar ... m-normandy


Image

Image

Image

Image

Image


I mostly need to feedbacks on the difficulty setting and the balance of this campaign with carryover. I am also interested if it generate unplayable maps (screenshoot will be greats.)

Once the generator is validated, it will be easy to change sides, change tileset (desert will require a little more work I think.) A longer campaign also. :P

Post Reply

Return to “Battle Academy : Modders Corner ”