You must be logged in to post messages.
Please login or register

The University

Hop to:    
loginhomeregisterhelprules
Bottom
Topic Subject: RMS Tutorials: Unequal Player Starts (Approved)
posted 08-17-15 06:40 PM CT (US)   
This article has been approved and can also be read at the University. - Leif Ericson

RMS Tutorials: Unequal Player Starts - part 1

By: Zetnus

************************************************************
Preface

This tutorial assumes that you are familiar with the basic concepts of RM scripting – ie. you understand what all the parts of a standard ES map script do, and you are able to write your own basic scripts. If this is not the case, I suggest you read my Updated New RMS Guide or otherwise familiarize yourself with the basics of RM scripting.

************************************************************
Introduction

To begin with, I will quote part of the original RMSG by Ensemble Studios:

Random Map scripts place the same starting terrain and resources for every player. It is not possible to start different players with different resources. Thus, all scripts in theory will be fair to all players. However, knowledge of a map script can still help a player when playing on that map. Perhaps the player knows that there is a lot of gold generated in the center of the map (as in Gold Rush). When you play on someone else’s Random Map script, you are placing some trust in that person that the map is going to be interesting and fair.

As you might have guessed from the title of this tutorial, it is in fact possible to start different players with different resources and on different starting terrains. We will get to it in a moment.

First however, I would like to draw your attention to the rest of what I have quoted:
When you play on someone else’s Random Map script, you are placing some trust in that person that the map is going to be interesting and fair.
This applies especially if you are creating map with unequal starting positions; people playing your map are trusting you to have designed something that is balanced and fair, and that is fun to play. Furthermore, by giving you the information to create unequal player starts, I am trusting you to use it appropriately.

So why might you want to design a map with unequal player starts?

>To create an AI-friendly single-player version of map that AIs would otherwise have a lot of trouble with. For example, you could create a land nomad map where only player 1 has a nomad start and any other players (ie. computer players) start with a TC. This is the example I will be using in this tutorial.

>To create a map for human players where different players have different resources and must actively trade and cooperate with each other to obtain the resources that they lack in their starting position. Such a map requires you to carefully consider the balance so that it is fair and fun to play for all the players.

>To create a map that allows players of different skill levels to play on somewhat equal footing. Once again, this requires play-testing and careful consideration of balance.

>To create an RPG using RM scripting. Be creative! There are all kinds of things you could try.

>To cheat your friends or random players online. Don’t do it. Let me tell you why: games are normally recorded and people will be able to quickly determine that you are using a cheat map. Furthermore, the map script is transferred to every player at the beginning of the game. People will be able to look at it and determine that you made an unfair map. You will very quickly ruin your reputation and people won’t want to play with you anymore – is that really what you want?

************************************************************
Lands

If you use the create_player_lands command, each player will get equal starting positions. However, there is a way to get around this by using the create_land command with the assign_to_player (1-8) attribute. This attribute lets you assign a single land to a specific player. The number corresponds to the order in which the player slots are filled in the lobby, rather than the player color/number selected. Whoever is in the first slot will always be player 1 for the purpose of this attribute. Note that if some players are not playing, their lands won't be created at all and that you can't assign the same land to more than one player.
So let’s see how this works:


<LAND_GENERATION>
base_terrain WATER
create_land
{
terrain_type GRASS2
land_percent 15
assign_to_player 1
}
create_land
{
terrain_type DESERT
number_of_tiles 150
assign_to_player 2
}
create_land
{
terrain_type DIRT
number_of_tiles 300
assign_to_player 2
}
create_land
{
terrain_type LEAVES
number_of_tiles 300
assign_to_player 4
}

<OBJECTS_GENERATION>
create_object CASTLE
{
set_place_for_every_player
}


If you place this into a blank random map script and then start up a 3 player game you will note the following: Player 1 gets a Castle on a massive grassy island. Player 2 gets a Castle on a small desert island and another Castle on a small dirt island. We did not create any lands for player 3, so player 3 gets the standard TC, villagers, and scout placed at random somewhere on the map (probably on the grassy island because it’s nice and big). Player 4 is not playing, so there is no leafy island.
We’ve already managed to establish some basic asymmetry between the player lands.

What else can we do?
The create_land command can have the following attributes:


terrain_type TYPE
land_percent % / number_of_tiles N
base_size N
base_elevation N(1-7) (requires UP/HD)
left_border %, right_border %, top_border %, bottom_border %
land_position %(0-100) %(0-99)
border_fuzziness %
clumping_factor %
zone N / set_zone_randomly
other_zone_avoidance_distance N
land_id N
assign_to_player N(1-8)


However, if you use assign_to_player, then land_position will not work. Furthermore, the border attributes (top, left, right, bottom) will apply globally to ALL lands that belong to players. So you CANNOT create unequal positioning of the lands that belong to players – they will always be in a circle/oval and the border attributes will shift the entire oval.

This still leaves you with many options to create unequal starts in terms of land size, shape, zone, avoidance distance, and most importantly, terrain (the focus of this guide). Part 2 of this guide discusses using land_id instead.

************************************************************
Terrains

One of the best ways to give players unequal starting resources/buildings/units is to make sure the players have different terrains in their starting lands. In the above example, I used GRASS2 and DESERT to make the differences abundantly clear; however you can be much more subtle about it too.
Let’s create an AI-friendly single-player version of land nomad to illustrate how to do this:


<LAND_GENERATION>
base_terrain GRASS
/* for the human player */
create_land
{
terrain_type GRASS2
land_percent 10
base_size 15
other_zone_avoidance_distance 5
assign_to_player 1
}
/* for the computer players */
create_land
{
terrain_type GRASS
land_percent 10
base_size 15
other_zone_avoidance_distance 5
assign_to_player 2
}
create_land
{
terrain_type GRASS
land_percent 10
base_size 15
other_zone_avoidance_distance 5
assign_to_player 3
}
/* repeat for players 4-8 */


How is this going to let us create unequal starts if they look almost the same? That is where we need to move to the objects section.

************************************************************
Objects

While you could theoretically use differences in the sizes of lands to unequally place objects, the easiest way is to create and use differences in the terrains of the lands. You can use terrain_to_place_on to specifically place objects on to certain terrains. For example, If you specify that every player gets a TC, but the TC needs to be placed on GRASS, then any player who doesn’t have GRASS in their land won’t get a TC.

Let's take our previous example of creating an AI-friendly land nomad and add an objects section after the land_generation from above.


<OBJECTS_GENERATION>
create_object TOWN_CENTER
{
terrain_to_place_on GRASS
set_place_for_every_player
group_placement_radius 18
min_distance_to_players 0
max_distance_to_players 0
}
create_object VILLAGER
{
set_place_for_every_player
min_distance_to_players 6
max_distance_to_players 21
}


What this will do is place a TC for players 2-7 because they have GRASS in the center of their lands. Player 1 will not get a TC, because player 1 has GRASS2 instead of GRASS. All players will get their villagers as usual.

Thus we have a basic script that shows how you can use unequal player starts to make an AI-friendly Single-player version of a map. Of course you would still need to add in all the other objects and terrains from the land nomad map in order to make it complete, but that is simply a matter of copy-and-paste for the most part.

************************************************************
Examples

Above, I’ve used a simple example to illustrate this concept, but once you’ve got a grasp of it you can make some quite impressive maps:

Frontier and Lake Nomad
For both of these maps I created AI-friendly single-player versions.

Specialists
In this map Bultro gives the players randomized unequal starting positions to provide for some unusual yet surprisingly balanced gameplay.

PTC15 - Tortuga
In this one, I’ve made extensive use of unequal player starts to create an entry for the Pretty Town Contest. It’s a showcase map rather than something you actually play a match on.

The Overlord
It will generate great 1vX games (with X from 2 to 5), where the Overlord (P1) is alone versus everyone else but he has as many TCs as opponents.

There are other things you can try too. For example, you can use can create 2 set of player lands – one using create_player_lands and one using create_land and assign_to_player. Player objects would not necessarily have to be placed on both of them, instead you could use the second set to scale the number of unoccupied lands in the map to the number of players.
Be creative!

************************************************************
Concluding Thoughts

Since writing this, I have been told that land_id is also useful for creating unequal player starts. If you are interested in learning about this, you can read RMS Tutorials: Unequal Player Starts - part 2

This is my first University submission and I hope you learned something from it. Let me know if you have any questions or find any mistakes or need clarification about something.

......../\
......./ / / \ Check out my Blacksmith submissions as well as my Random Map Scripts.
....../ / /\\ \
...../ /_/_\\ \ Proud guardian of the Definitive Random Map Scripting Guide
..../_____\\\ \
....\\\\\\\\\\\\\/ and the Random Map Scripting Links and FAQ thread.

[This message has been edited by Leif Ericson (edited 02-19-2017 @ 06:01 PM).]

Replies:
posted 08-17-15 09:13 PM CT (US)     1 / 10  
Looks great! Approved.

~`o´~|\  Join the fresh and exciting AI Ladder for its fourth season!
´ `  |_\
       |    Learn the joy of AI scripting in my guide: The World of AI Scripting
______|______
 \        /
   .....Hinga Dinga Durgen! - SpongeBob
  `-=<.__.>=-´
posted 08-20-15 09:22 AM CT (US)     2 / 10  
I found this map Overlord which has recently been published in the Steam Workshop. It's a 1v2-5 map that gives one player lots of lands and everyone else a single land. Another example of all the cool stuff you can do.

......../\
......./ / / \ Check out my Blacksmith submissions as well as my Random Map Scripts.
....../ / /\\ \
...../ /_/_\\ \ Proud guardian of the Definitive Random Map Scripting Guide
..../_____\\\ \
....\\\\\\\\\\\\\/ and the Random Map Scripting Links and FAQ thread.
posted 12-28-15 04:59 PM CT (US)     3 / 10  
There seems to be a maximum of six different terrain types used in assign_to_player statements. Any more than that can cause crashes and problems generating some areas.

AoK: Realms
Adds Armenians, Balts, Bamars, Bohemians, Bulgars, Burgundians, Chimus, Dutch, Helvetians, Jurchens, Khmers, Malays, Mandinkas, Moors, Muisca, Tamils, Tufans, Turcomans, and Viets

Proteus and Genie Converter - AKX installers for modern times
posted 12-31-15 08:25 AM CT (US)     4 / 10  
Can you post an example of a script that crashes or causes problems?

I wasn't able to replicate your findings with a test script I made. It has 10 different terrains and they all function as expected.



<PLAYER_SETUP>
random_placement

<LAND_GENERATION>

base_terrain WATER

create_land
{
terrain_type GRASS
number_of_tiles 30
base_size 4
assign_to_player 1
}
create_land
{
terrain_type GRASS2
number_of_tiles 30
base_size 4
assign_to_player 2
}
create_land
{
terrain_type GRASS3
number_of_tiles 30
base_size 4
assign_to_player 3
}
create_land
{
terrain_type DIRT
number_of_tiles 30
base_size 4
assign_to_player 4
}
create_land
{
terrain_type DIRT2
number_of_tiles 30
base_size 4
assign_to_player 5
}
create_land
{
terrain_type DIRT3
number_of_tiles 30
base_size 4
assign_to_player 6
}
create_land
{
terrain_type DESERT
number_of_tiles 30
base_size 4
assign_to_player 7
}
create_land
{
terrain_type DIRT_SNOW
number_of_tiles 30
base_size 4
assign_to_player 8
}
create_land
{
terrain_type GRASS_SNOW
number_of_tiles 30
base_size 4
assign_to_player 1
}
create_land
{
terrain_type SNOW
number_of_tiles 30
base_size 4
assign_to_player 2
}

/* ****************************************************** */
<OBJECTS_GENERATION>
create_object ARCHER
{
set_place_for_every_player
terrain_to_place_on GRASS
}
create_object ARCHER
{
set_place_for_every_player
terrain_to_place_on GRASS2
}
create_object ARCHER
{
set_place_for_every_player
terrain_to_place_on GRASS3
}
create_object ARCHER
{
set_place_for_every_player
terrain_to_place_on DIRT
}
create_object ARCHER
{
set_place_for_every_player
terrain_to_place_on DIRT2
}
create_object ARCHER
{
set_place_for_every_player
terrain_to_place_on DIRT3
}
create_object ARCHER
{
set_place_for_every_player
terrain_to_place_on DESERT
}
create_object ARCHER
{
set_place_for_every_player
terrain_to_place_on DIRT_SNOW
}
create_object ARCHER
{
set_place_for_every_player
terrain_to_place_on GRASS_SNOW
}
create_object ARCHER
{
set_place_for_every_player
terrain_to_place_on SNOW
}


......../\
......./ / / \ Check out my Blacksmith submissions as well as my Random Map Scripts.
....../ / /\\ \
...../ /_/_\\ \ Proud guardian of the Definitive Random Map Scripting Guide
..../_____\\\ \
....\\\\\\\\\\\\\/ and the Random Map Scripting Links and FAQ thread.
posted 12-31-15 03:26 PM CT (US)     5 / 10  
Hmm. Maybe it has something to do with the complexity of the script, or placing objects on terrains that don't exist.

Here's what the map is supposed to look like (uses only six different terrains in assign statements)

And this can happen when seven different terrains are used. There should be three P1 towns, but two spawned no units at all, while one has gaia units instead.

It also seems to crash more often, though I haven't tested that rigorously. Also, from the header of specialists:
Note for map designers: to obtain this result i combined assign_to_player and
terrain_to_place_on. Every player starts on a different terrain, hence different units.
Using this trick too much can cause crashes, so the possibilities were limited to 6.
The script is over 2000 lines, so I'll email to you rather than post it here.

AoK: Realms
Adds Armenians, Balts, Bamars, Bohemians, Bulgars, Burgundians, Chimus, Dutch, Helvetians, Jurchens, Khmers, Malays, Mandinkas, Moors, Muisca, Tamils, Tufans, Turcomans, and Viets

Proteus and Genie Converter - AKX installers for modern times
posted 12-31-15 03:56 PM CT (US)     6 / 10  
I got your email and I'll take a look at it when I have time.
Complexity could certainly be the issue. Having more than 99 distinct create_object commands active in a script can problems, for example.

......../\
......./ / / \ Check out my Blacksmith submissions as well as my Random Map Scripts.
....../ / /\\ \
...../ /_/_\\ \ Proud guardian of the Definitive Random Map Scripting Guide
..../_____\\\ \
....\\\\\\\\\\\\\/ and the Random Map Scripting Links and FAQ thread.
posted 12-31-15 06:16 PM CT (US)     7 / 10  
Ah. Well, I have 138, so there's a good chance that's the problem.

AoK: Realms
Adds Armenians, Balts, Bamars, Bohemians, Bulgars, Burgundians, Chimus, Dutch, Helvetians, Jurchens, Khmers, Malays, Mandinkas, Moors, Muisca, Tamils, Tufans, Turcomans, and Viets

Proteus and Genie Converter - AKX installers for modern times
posted 12-31-15 08:34 PM CT (US)     8 / 10  
Yes, that probably explains it.

In my experience, when you have more than 99 create_object commands, objects start not appearing when they should and gaia objects may appear when they shouldn't (the gaia objects could be a separate issue too - I might have to look in to that.)

Maps using assign_to_player with different base_terrains will be especially vulnerable because they intrinsically require more create_object commands, so you are much more likely to hit the limit.

If I recall correctly, this only happens when the rm generator actually sees 100 create_object commands - what I mean is that those that are excluded due to if statements don't count towards the total. You're probably still over 99 even if you take that in to account however, so you will need to remove or consolidate some of the eye-candy in your map to see if that solves the issues.

......../\
......./ / / \ Check out my Blacksmith submissions as well as my Random Map Scripts.
....../ / /\\ \
...../ /_/_\\ \ Proud guardian of the Definitive Random Map Scripting Guide
..../_____\\\ \
....\\\\\\\\\\\\\/ and the Random Map Scripting Links and FAQ thread.
posted 10-22-16 11:12 PM CT (US)     9 / 10  
Hmm... I've been thinking about a map where you have two town centers on two different continents. Is that possible using this? Or where the AI starts with units on multiple continents in Archipelago, Migration, Island or maps like that?
posted 11-09-16 06:23 PM CT (US)     10 / 10  
That kind of stuff should generally be possible. You can pick the zones of the lands such that some of them bunch up into continents. The one limitation to keep in mind is that players still end up being placed in circle or oval shape around the map.

......../\
......./ / / \ Check out my Blacksmith submissions as well as my Random Map Scripts.
....../ / /\\ \
...../ /_/_\\ \ Proud guardian of the Definitive Random Map Scripting Guide
..../_____\\\ \
....\\\\\\\\\\\\\/ and the Random Map Scripting Links and FAQ thread.
Age of Kings Heaven » Forums » The University » RMS Tutorials: Unequal Player Starts (Approved)
Top
You must be logged in to post messages.
Please login or register
Hop to:    
Age of Kings Heaven | HeavenGames