Apolyton Archive  |  Preserved copy of the Apolyton Civilization Site and its forums as they stood in September 2005. Read-only; nothing here can be posted to or replied to.  |  Forum index |  About this archive |  The 1998–2001 UBB forums
Today on Apolyton WARDELL INTERVIEW PROMO A.C.S. HISTORY CHAPTER 4 GET CIV4 /w FREE PLUS! A.C.S. PHOTO GALLERY GET A.O.M. V1.1
Apolyton Civilization Forums
main| civ2| civ3| civ4| smac| ctp2| ron| moo3| galciv| galciv2| alt| about|
ApolytonPLUS | register | search | faq | new posts | pm (-/-) | upload | members
hall of fame new! | civgroups | civgroups news | interviews | the column | radio | chat | directory | news | store | PLUS
Apolyton Civilization Forums : Powered by vBulletin version 2.0.3 Apolyton Civilization Forums > Call To Power II > CtP2-Source Code Project > DESIGN: Barbarian placement
Show a Printable Version | Email This Page to Someone! | Receive updates to this thread | Report this to Apolyton news!
CivGroups
CTP2 Source Code Project (59): Not a Member - Join

bottom of page
  
What method should be used for barbarian placement? (Time out:0 days after 01-10-2004, 00:34)
Use the current method
Scrap the SP algorithm, and use the MP algorithm in SP games too
Do something else (please post details)
Don't know
Banana
View Results [Edit Poll (moderators only)]
Author
Thread    < Last Thread     Next Thread > Post New Thread     Post A Reply
J Bytheway is offline J Bytheway
Emperor
England
Jul 2001
time: 05:22
  Old Post 01-10-2004 00:32 Visit J Bytheway's homepage!
Edit/Delete Message Reply w/Quote
#1 Report this post to a moderator
DESIGN: Barbarian placement Browse Apolyton AD-FREE

I've been researching the way the location of barbarian spawns is chosen.

The way this is performed is really bizarre (and I found at least two bugs in the code ).

If there is exactly one human player, then they are placed as follows (I call this the SP algorithm):

A human city is selected at random, and then neighbours of this are selected at random repeatedly (essentially this generates a random walk around the map) for at most 4000 steps until it finds a land square not visible to the human player which is at least as far from the nearest human city as a given minimum distance, and then places the barbs there.

If there are zero or more than one human players, then they are placed as follows (I call this the MP algorithm):

Random squares on the map are chosen (for at most 400 attempts) until a land square is found which no player can see, and the barbs are placed there.

There are several problems with the SP algorithm:

Barbs will always be placed "just out of sight" for the human player, and whether other players can see the square is ignored (although this is a bug - it isn't supposed to be ignored). This is very unfair, and strange.

This method is likely to produce barbs on the borders between the human player and the AIs, exactly in the warzones where all the troops will be and so the barbs will probably be easily dealt with.

If that doesn't happen, then they will be placed just inside the neigbouring AI civs, possibly right next to their cities (in fact, it might try to place them inside their cities!) which is also not good.

The way in which the code randomly walks around in the SP algorithm is quite silly, and could easily result in it getting stuck and no barbs being produced when a large portion of the map is visible to the human player. This is particularly true on a map with much water.

Because of these problems, I suggest we strip out the SP algorithm and use the MP algorithm for all games - it seems sensible. It's implementation could probably be improved, but it's sufficient for the moment.

Some people have put forward more suggestions for barbarian camps, etc., but for the moment I'm primarily interested in what we should do in the short term.

Last edited by J Bytheway on 01-10-2004 at 00:57

J Bytheway is offline J Bytheway
Emperor
England
Jul 2001
time: 05:22
  Old Post 01-10-2004 00:36 Visit J Bytheway's homepage!
Edit/Delete Message Reply w/Quote
#2 Report this post to a moderator
Tired of ads?

Blast! Wrong forum...

Ah... Right forum. Thanks very much .

Last edited by J Bytheway on 01-10-2004 at 01:28

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:22
  Old Post 01-10-2004 00:52 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#3 Report this post to a moderator
Support Apolyton buy from Amazon

quote:
Originally posted by The Big Mc
I have just drafted an idea for a much more complicated barbarian model.

Four types of barbarians creation types

Random

Barbarians appear randomly on the map

Regional
A region is specified which has a lot of barbarians often being only 5 or 6 tiles big.

Leader

A random barbarian leader is generated which changes with age.

Camp

A barbarian camp works similar to the leader


The hard bit is going to be to get the barbarian unit DB to add and remove units depending on age

There will also be an option to allow you to attack barbarian leaders and camps to steel gold of the barbarians.


is there a way to implement BigMCs model (without too much work?)

J Bytheway is offline J Bytheway
Emperor
England
Jul 2001
time: 05:22
  Old Post 01-10-2004 01:42 Visit J Bytheway's homepage!
Edit/Delete Message Reply w/Quote
#4 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations: Deluxe Edition

quote:
Originally posted by E
is there a way to implement BigMCs model (without too much work?)


Well...

quote:
Originally posted by The Big Mc
Random

Barbarians appear randomly on the map


Well, obviously this is easy, because it already exists.

quote:
Regional
A region is specified which has a lot of barbarians often being only 5 or 6 tiles big.


This is not so easy. How do you choose the region? What if it turns out to be a small island - then that island will be swarming with barbs when someone finds it. What happens when this region is built over by a player?

quote:
Leader

A random barbarian leader is generated which changes with age.

Camp

A barbarian camp works similar to the leader


This should be relatively easy, but I don't really understand the purpose. I think the way the game chooses which units to spawn for the barbs is somewhat silly anyway, and should probably be altered...

quote:
The hard bit is going to be to get the barbarian unit DB to add and remove units depending on age


...using age to decide what units to use is another way, but I still don't think it's right.

At present any land unit with a non-zero attack value can appear, and which one does is chosen at random from the top few units available to any player (sorted by attack value). It seems to me that it might make more sense to, for example, allow units.txt to specify which units can be barbs, and prehaps sort by the sum of attack and defense, rather than just attack.

quote:
There will also be an option to allow you to attack barbarian leaders and camps to steel gold of the barbarians.


This would probably be most easily done with SLIC...

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:22
  Old Post 01-10-2004 01:59 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#5 Report this post to a moderator
Get a bigger avatar today!

Ok then I'll go with the MP fix and just have SLIC for the niceties,

but I think have a standard list of what barbs appear during different ages should be in the main game, not just a modified unit.txt I dont want to see barbarian tanks or something just warriors, gerrillas, horseman

Tamerlin is offline Tamerlin
King
Toulouse (South-western France)
Apr 2002
time: 06:22
  Old Post 01-10-2004 03:50
Edit/Delete Message Reply w/Quote
#6 Report this post to a moderator
Lose 30 kilos (of popups)

The MP algorithm appears better than the SP one. Though I am against Barbarians camps, at least the way they are implemented in Civ3 (I am mostly against all things inspired from Civ3 actually) I think that Barbarians should sometimes (not always) be allowed to create a new AI civ when they manage to take a City from a player and to keep it for a while.

Unspeakable Horror is offline Unspeakable Horror
Emperor

Oct 1999
time: 02:22
  Old Post 01-10-2004 16:45
Edit/Delete Message Reply w/Quote
#7 Report this post to a moderator
Full PM-box? Change here!

quote:
This is not so easy. How do you choose the region? What if it turns out to be a small island - then that island will be swarming with barbs when someone finds it.

What´s so bad about it? Imagine they are very agressive natives
It would be nice to have some opposition to settle on the island, for example in my current game I have a big island just in front of my own, it would be natural to have some population that got away from my empire (criminals, smugglers?) in a place where law that´s not exists

quote:

What happens when this region is built over by a player?

Err? What do you mean? When the player borders extends over the island?
Well, I don´t know

Solver is offline Solver
Apolyton Duke Of Something
Latvia, Riga
Sep 2000
time: 07:22
  Old Post 01-10-2004 18:40 Visit Solver<br><img src=/forums/images/staff-icon.gif>'s homepage!
Edit/Delete Message Reply w/Quote
#8 Report this post to a moderator
Increase the size of your Attachments

MP algorithm seems better.

As for other ideas... nothing wrong with lots of Barbs on an isle! As it is, I can feel pretty secure colonizing an island and only sending one all-around good unit, like Cavalry there. Ideally, I'd also like to see Barbarians tougher, with better units in later ages (terrorists, sorta), and the ability to spawn unconventional units. For instance, Barb Slavers could stand for some small roaming slaver groups that don't care whom they enslave.

Flinx is offline Flinx
Prince
Toronto, ON CANADA
Nov 2001
time: 00:22
  Old Post 01-10-2004 22:16 Visit Flinx's homepage!
Edit/Delete Message Reply w/Quote
#9 Report this post to a moderator
Re: DESIGN: Barbarian placement Support Apolyton, buy Call to Power 2

I've been researching the way the location of barbarian spawns is chosen.
The way this is performed is really bizarre (and I found at least two bugs in the code ).
If there is exactly one human player, then they are placed as follows (I call this the SP algorithm):
A human city is selected at random, and then neighbours of this are selected at random repeatedly (essentially this generates a random walk around the map) for at most 4000 steps until it finds a land square not visible to the human player which is at least as far from the nearest human city as a given minimum distance, and then places the barbs there.


IIRC the minimum distance is from the text files and varies/can vary with barbarian difficulty.

If there are zero or more than one human players, then they are placed as follows (I call this the MP algorithm):
Random squares on the map are chosen (for at most 400 attempts) until a land square is found which no player can see, and the barbs are placed there.
There are several problems with the SP algorithm:
Barbs will always be placed "just out of sight" for the human player, and whether other players can see the square is ignored (although this is a bug - it isn't supposed to be ignored). This is very unfair, and strange.


I do not view the preferential placement of the random barbarians near human players as a problem. The AI knows not to walk through goody huts which spawn barbarians, so the preferential placement can be thought of as the same thing. Conceptually, barbarians should not appear within the vision of any military unit (AI or Human).

This method is likely to produce barbs on the borders between the human player and the AIs, exactly in the warzones where all the troops will be and so the barbs will probably be easily dealt with.
If that doesn't happen, then they will be placed just inside the neigbouring AI civs, possibly right next to their cities (in fact, it might try to place them inside their cities!) which is also not good.


The no-man’s-land between civs is conceptually where I would most likely expect to find barbarians, provided that there is no military unit to see them appear, other than another barbarian.

The way in which the code randomly walks around in the SP algorithm is quite silly, and could easily result in it getting stuck and no barbs being produced when a large portion of the map is visible to the human player. This is particularly true on a map with much water.

The random walk around does seem somewhat non-optimal. Having the number of barbarians that appear decrease as the map (land tiles) becomes increasingly visible to everyone makes sense to me. The MP algorithm achieves this by requiring the tile be not currently visible to any player (AI or Human) and so is no different than the SP algorithm in this respect.

Because of these problems, I suggest we strip out the SP algorithm and use the MP algorithm for all games - it seems sensible. It's implementation could probably be improved, but it's sufficient for the moment.
Some people have put forward more suggestions for barbarian camps, etc., but for the moment I'm primarily interested in what we should do in the short term.


I think we should come up with a new algorithm for placing barbarians. With one human player, I think the AIs may be worse off by switching to the MP algorithm.

The Big Mc is offline The Big Mc
King
Of the universe / England
Oct 2001
time: 05:22
  Old Post 01-10-2004 22:44 Visit The Big Mc's homepage!
Edit/Delete Message Reply w/Quote
#10 Report this post to a moderator
Remove this text

Well I have been working hard on this planning at the moment.

What we could do id multiples of these as apposed to just one barbarian algorithm.

For example an option to add algorithms to deal with barbarian camps could be that the camp take could gain things that the barb took

E.g. money slaves or pw



Oh and to answer the question


quote:
What happens when this region is built over by a player?


The barbarian’s spawn chance goes down by 10% for every tile making the barbarian chance 10% when you take all tiles (based on a 9 tile region).

J Bytheway is offline J Bytheway
Emperor
England
Jul 2001
time: 05:22
  Old Post 02-10-2004 01:25 Visit J Bytheway's homepage!
Edit/Delete Message Reply w/Quote
#11 Report this post to a moderator
Support Apolyton, buy Civilization 2

quote:
Originally posted by Flinx
IIRC the minimum distance is from the text files and varies/can vary with barbarian difficulty.


Yes, that's where the value comes from.

quote:
I do not view the preferential placement of the random barbarians near human players as a problem.


Perhaps not. It goes against my grain to be biased in this way, but it might give better gameplay, provided the other problems are dealt with.

quote:
The random walk around does seem somewhat non-optimal. Having the number of barbarians that appear decrease as the map (land tiles) becomes increasingly visible to everyone makes sense to me. The MP algorithm achieves this by requiring the tile be not currently visible to any player (AI or Human) and so is no different than the SP algorithm in this respect.


Well, it is different in that it is likely to place barbs if there is non-visible land anywhere, rather than just near the human player, and it is more likely to find somewhere to put the barbs - it will have a 50% chance when less than 0.2% of the map is unseen land - this might in itself become a problem because the barbs will become denser and denser as the amount of unseen land decreases.

quote:
I think we should come up with a new algorithm for placing barbarians.


I can't think of a good one...

quote:
With one human player, I think the AIs may be worse off by switching to the MP algorithm.


I'm not so sure - in the buggy SP algorithm they might get barbs on their very doorstep once the human civ borders theirs. Certainly in the early game the AIs will be worse off, but once most of the land is covered in cities it depends how densely the AIs units/cities are packed compared to the human, and thus how much unseen land there is in or near their civ...

Last edited by J Bytheway on 01-01-2005 at 03:43

star mouse is offline star mouse
Prince
of the Barbarians
Aug 2001
time: 16:22
  Old Post 26-10-2004 12:44
Edit/Delete Message Reply w/Quote
#12 Report this post to a moderator
Re: DESIGN: Barbarian placement Tired of ads?

quote:
Originally posted by J Bytheway Because of these problems, I suggest we strip out the SP algorithm and use the MP algorithm for all games - it seems sensible. It's implementation could probably be improved, but it's sufficient for the moment.

To spawn barbarians, we should use the MP code always.

We can also do barbarians in the following manner:

1. Count how many tiles on the map are outside all player's fog of war. (Could take a while? If it does then we should not use this method).
2. If no tiles are outside the fog of war for every player, then stop here (because we cannot spawn barbaraians).
3. Randomly choose one of these tiles and place the barbarians there. The number of barbarians to place is inversely proportional to the number of tiles where the barbarians can be spawned.

So if there's a lot of free space on the map, we spawn a few barbarians, but if there's just a few tiles we spawn a horde.

star mouse is offline star mouse
Prince
of the Barbarians
Aug 2001
time: 16:22
  Old Post 27-10-2004 07:38
Edit/Delete Message Reply w/Quote
#13 Report this post to a moderator
Re: DESIGN: Barbarian placement Lose 30 kilos (of popups)

quote:
Originally posted by J Bytheway
I've been researching the way the location of barbarian spawns is chosen.

The way this is performed is really bizarre (and I found at least two bugs in the code ).

If there is exactly one human player, then they are placed as follows (I call this the SP algorithm):

A human city is selected at random, and then neighbours of this are selected at random repeatedly (essentially this generates a random walk around the map) for at most 4000 steps until it finds a land square not visible to the human player which is at least as far from the nearest human city as a given minimum distance, and then places the barbs there.

If for some reason you wanted to keep the SP algorithm, you could improve it by doing the following:
1. Select a city at random. (Could be a human city or an AI city)
2. Select a random direction (360 degrees).
3. Move in that direction, and use Bresenham's algorithm to choose the squares.
4. Stop when you find a square outside the view of all empires. Place the barbarians there.
5. If you go right around the map in either direction, then stop.

The random walk is eliminated.

J Bytheway is offline J Bytheway
Emperor
England
Jul 2001
time: 05:22
  Old Post 01-01-2005 03:43 Visit J Bytheway's homepage!
Edit/Delete Message Reply w/Quote
#14 Report this post to a moderator
Support Apolyton, buy Civilization III: Complete

For the record, as per popular request, I've implemented the change I first suggested (source here).

This change is in the newest playtest, so feel free to test and comment .

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:22
  Old Post 25-01-2005 04:37 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#15 Report this post to a moderator
Support Apolyton, buy Civilization III: Complete

J bytheway,

Did this code at new Unit Flags that prevented some units being used as barbarians...just checking...

code:
if(rec->GetCantBuild()) continue; if(!rec->GetMovementTypeLand()) continue; if(rec->GetAttack() < 1) continue; if(g_exclusions && g_exclusions->IsUnitExcluded(i)) continue; if(SomeoneCanHave(rec)) { for(j = 0; j < num_best_units; j++) { if(rec->GetAttack() > best[j].attack) { for(k = num_best_units - 1; k >= j+1; k--) { best[k] = best[k-1]; } best[j].index = i; best[j].attack = (sint32)rec->GetAttack(); count++; break;

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:22
Post  Old Post 25-01-2005 19:31 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#16 Report this post to a moderator
Support Apolyton or Terrorists Win

Actual this means units that cannot be build, that aren't land units, that cannot attack, aren't excluded (given by the MP options) and noone can have, because noone has the required advance yet, cannot be used for random appearing Barbs.

That means you never see Barbarian spies, slavers, etc. And they also forgot to implement something for pirates, like in Civ2.

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:22
  Old Post 26-01-2005 11:22 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#17 Report this post to a moderator
Support Apolyton buy from Amazon

hmmmm...

that leads to yet another project I'll attempt sea pirates and creating a unit flag such as BarbarianOnly

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:22
  Old Post 11-02-2005 01:18 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#18 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations: Deluxe Edition

I had another thought. I looked for how UnitBuildList.txt works. Got a little lost, but I think it might be useful to set up a buildlist that is for barbarians only. This way instead of using the player buildlist a modder can control a more preferred list of barbarians...

maybe in here?
C3cmdline.cpp

code:
delete g_theUnitBuildListDB; g_theUnitBuildListDB= new CTPDatabase(); Assert(g_theUnitBuildListDB); if (g_theUnitBuildListDB) { lex = new DBLexer(C3DIR_AIDATA, g_unit_buildlist_db_filename); if (!g_theUnitBuildListDB->Parse(lex)) { Assert(FALSE); return; } delete lex; } else { return; }

The Big Mc is offline The Big Mc
King
Of the universe / England
Oct 2001
time: 05:22
  Old Post 11-02-2005 02:10 Visit The Big Mc's homepage!
Edit/Delete Message Reply w/Quote
#19 Report this post to a moderator
Support Apolyton

E this looks a good idea barbes.txt

We might want to add a flag for this file (can find in ruins ) and then make a slic hybrid file with ruins related finds in. an a header in this file or another could give the ruin types eg (ruin 1 = tile index 123) but this is another project.

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:22
Post  Old Post 11-02-2005 19:17 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#20 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations

E what do you want with the lexer, if you just want that the Barbs get there units from a build list, just take the list that use the Barbs to decide which units to build. I don't see here the need for an additional file, maybe we could add this list to risk.txt, but that should it be. But actual I prefer the way it is. Using the technology that is in the world anyway.

-Martin

E is offline E
King
July 24,2005 Ctp2 Tiles in sig!
May 1999
time: 21:22
  Old Post 11-02-2005 20:57 Visit E's homepage!
Edit/Delete Message Reply w/Quote
#21 Report this post to a moderator
Support Apolyton, buy GURPS/ Alpha Centauri

I was thinking of adding a build list that was just barbarians in the UnitBuildList. I figured it would give modders better options like in a Rome scenario only barbarian like units would be made instead of legions or in an epic game barbarians would use guerrillas instead of modern infantry.

Mirimunchkin is offline Mirimunchkin

Chieftain

Jan 2005
time: 05:22
  Old Post 11-02-2005 21:16
Edit/Delete Message Reply w/Quote
#22 Report this post to a moderator
Increase the size of your Attachments

I know that it's a bit late in the day for any additional thoughts on this subject, but...

Why not reverse the game logic so that Barbarians are "discovered" by the human player(s)? Then all that's required is an algorithm which checks newly discovered (and none-AI controlled) Tiles for the possibility of Barbarian placement. That's usually, at least in the early game a max of 5 Tiles (10 if travelling along a river). There would also, I assume, need to be check to limit the number of Barbarians that a single unit/stack could encounter each turn (or not, if you want to be swamped).

Just seems a simpler method to me.

Mirimunchkin is offline Mirimunchkin

Chieftain

Jan 2005
time: 05:22
  Old Post 11-02-2005 21:46
Edit/Delete Message Reply w/Quote
#23 Report this post to a moderator
Support Apolyton, buy Civilization 2

PS
I agree with E regarding upgrading Barb units. It adds no pleasure to the game when a stack of Tanks is attacked by a lone Hoplite. Waste of processor usage.

  < Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 05:22.
Apolyton Time is 00:22.
    top of page
Rate This Thread:
Forum Jump:
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
 




Contact Us - Apolyton Civilization Site - Support Us!

Building a better Apolyton through better information. Click here and take our poll!
Non-US visitors, click here!

Powered by: vBulletin Version 2.0.3
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Page generated in 0.0725 seconds (92.62% PHP - 7.38% MySQL) with 39 queries
Page Loading Time:

Support Apolyton: Amazon USA | Amazon UK | Amazon DE | Amazon FR |
Support Apolyton and get FREE PLUS, Buy from Chips&Bits: Galactic Civilizations | Galactic Civilizations: Deluxe Edition | Call to Power 2 | Civilization: The Boardgame | GURPS/ Alpha Centauri | Alpha Centauri | Civilization IV | Civilization III: Complete |


Front Page | Civilization IV | Civilization III | Civilization II | Call to Power II | Alpha Centauri | Master of Orion III
Rise of Nations | Galactic Civilizations | Galactic Civilizations II | Misc
Alt.Civs | Civ I | C:CtP I | About | News | Directory | Apolyton Store | Forums | Chat | Columns | Interviews | Newsletter
Scenario League | CSC | Clash of Civs | Spanish Site | CtP Maps | Cradle of Civ | WesW's Ctp1/2 Site | Civ3 Haven

apolyton.net | apolyton.com | civilization2.net | civilization3.net | civilization4.net | civilizationiv.info | calltopower.net | galciv.net | galciv2.net | moo3.net