.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

BCT Commander- Save $7.00
winSPWW2- Save $5.00

   







Go Back   .com.unity Forums > Illwinter Game Design > Dominions 2: The Ascension Wars

Reply
 
Thread Tools Display Modes
  #1  
Old March 31st, 2005, 01:20 PM
Endoperez's Avatar

Endoperez Endoperez is offline
National Security Advisor
 
Join Date: Sep 2003
Location: Eastern Finland
Posts: 7,110
Thanks: 145
Thanked 153 Times in 101 Posts
Endoperez is on a distinguished road
Default Reading maps from .map files

How can I define an "area" using only the .map file?

I have thought of something like this:

1. Choose a province.
2. Choose one of its neightbours.
3. Choose a province that is next to two provinces that were chosen before it. Skip over provinces already chosen. Abort if no suitable province is found.
4. Repeat 3 until you have X provinces, generally 5-8 is enough.

Take the one with most inter-connections inside the area. This is the capital of the area. It will get suitable poptype (e.g. barbarians) and map-added defenders (barbarians, tribal warriors, few horse brother commanders, Barbarian Lord with randomequip 3...). The other provinces of the area have poptypes that suite the "theme" of the area, e.g. Tribal Warriors, Tribal Cavalry, Horse Brothers & Horse's Vale, Barbarians with normal defenders), possibly with some special commanders (Barbarian Chief with randomequip 1) added in for fun.

Could a Java program working among these lines work? Any suggestions for better-working definitions of "the area", that could be a kingdom, a tribal nation, something along those lines.
Is there any easy way to discover "areas" with the same terrain type, e.g. 5 Wastes next to each other, or 8 mainly Forest and/or Mountain provinces?

Would it unbalance the game to have "areas" with similar defender types, where someone would start near barbarians/tribals inhabiting waste/plains and someone else near HI&X-bow, Knights&Longbow (only capital) etc. on plains/farmlands? Would this possibly screw someone over, while giving another easy start?

If you could add more provinces, area types, special things etc. with "script language" that would be map editing commands with few additions, would you do that? How many special provinces, area types, special things etc. would there have to be for a "random map" to be interesting?
The additions would be fairly simple, adding '#if Nbr' (Nbr is possibility of few following map commands, in %) and commands for choosing different defender types for poptypes. Like: Militia and Light Infantry with Javelins from 1-15, some Shortbows and some Heavy Infantry from 10-25, then a Knight commander with few longbows and more bows & HI with 2:1 relation from that point on.

I wonder what Gandalf, High Priest of the Random Map Cult, will say about this post...
Don't have your hopes too high. This is just an idea, and I might be able to get it to work, but I won't start it for a week, atleast. I have three exams left, and will start playing Morrowind after that. And I'm going to Germany in a Month. And then there is always school and life and little things like that.
Reply With Quote
  #2  
Old March 31st, 2005, 08:36 PM
Gandalf Parker's Avatar

Gandalf Parker Gandalf Parker is offline
Shrapnel Fanatic
 
Join Date: Oct 2003
Location: Vacaville, CA, USA
Posts: 13,736
Thanks: 341
Thanked 479 Times in 326 Posts
Gandalf Parker is on a distinguished road
Default Re: Reading maps from .map files

Any programming language could probably do it. Afraid I cant help you with the Java thing, I do mine in Basic.

I think you would be working with an array. Read in all of the #neighbor lines as a starting point.

The problem with "areas" is the same problem that we had with DomMap working with terrain. If an area is too large then you have people landing somewhere on the map which might be fantastic all around them, or horrible all around them. Of course some of that is going to happen but you might want to make sure that its not TOO far for a player to reach for something else.
__________________
-- DISCLAIMER:
This game is NOT suitable for students, interns, apprentices, or anyone else who is expected to pass tests on a regular basis. Do not think about strategies while operating heavy machinery. Before beginning this game make arrangements for someone to check on you daily. If you find that your game has continued for more than 36 hours straight then you should consult a physician immediately (Do NOT show him the game!)
Reply With Quote
  #3  
Old April 1st, 2005, 12:21 AM

alexti alexti is offline
First Lieutenant
 
Join Date: Dec 2003
Location: Calgary, Canada
Posts: 762
Thanks: 0
Thanked 0 Times in 0 Posts
alexti is on a distinguished road
Default Re: Reading maps from .map files

Your algorithm looks reasonable, but sometimes it will fail. Consider a small map with a chokepoint that splits map in 2. If you need to allocate 2 somewhat equal areas your algorithm will fail is the first province will be at the chokepoint. You can also fail on step 3 before finding 5-8 provinces. I think your algorithm will work well on open wraparound maps with few impasses, but not on highly segmented maps.

Generally, this kind of tasks is considered in graph theory. I would suggest some modification to your algorithm:
- the first step is to build a graph. Initially you have connected graph (at least usually)
- find simple chokepoints (nodes, which if removed would make the graph unconnected). This is easy to do by iterating through all nodes and checking if the graph is still connected or not if all incoming edges to this node are removed.
- or optionally find complex chokepoints (pair of nodes, which if removed would make the graph disconnected). This is similar to the previous step.
- Now consider graphs produced by removal of chokepoints. Each of those graphs is a "mega-area". Those are suitable for area placement. Count number of provinces in each mega-area (number of nodes) and see if there's a reasonable way to divide them in required number of area. There's no need for exact match, because some of the areas can overflow through chokepoints. This step may fail. For example, if you have 2 equal areas connected through the chokepoint, you can't make 3 "equal" areas. So you have to decide something. (see more in the following step).
- Now you have number of areas to create out of each "mega-area". Start from the most densely populated "mega-area"
(one that have least provinces per required area). Start from the most remote point from any of chokepoints. Use your original algorithm, but in step 2,3 give more preference to the province further from the chokepoint. Degree of preference should depend on density of "mega-area" population. More densely it is populated, the more preference you should give to the outward provinces.
This will let the last area overflow through the chokepoint, if necessary.
- Update the graphs to take into account possible overflow, and repeat previous step for the next densest "mega-area".

If you have larger map and fewer required areas, you may want to execute this algorithm for the size of the area approaching to total of "mega-area" areas divided by number of required areas, and after it is complete, remove outward provinces from each of the areas to reach your original target size.

Concerning implementation, I don't see any problems implementing it in Java, but this algorithm may be resource intensive (I have no idea actually), so it may be better to do it in C++. Besides you'll probably have easier time finding libraries to use (like for graph handling).
Reply With Quote
  #4  
Old April 1st, 2005, 02:38 AM
Arralen's Avatar

Arralen Arralen is offline
Major General
 
Join Date: Nov 2000
Location: 500km from Ulm
Posts: 2,279
Thanks: 9
Thanked 18 Times in 12 Posts
Arralen is on a distinguished road
Default Re: Reading maps from .map files

programming language
At first -considering the fact that you ask if something like your pseudocode could be implemented in Java- let me say, that if you start learning Java now it will be quite a long time before you actually can do what you want. Are you thinking about taking Java courses at University? That would make time less of an factor as far a learning is concerned, but they're not known for starting with the "practical side" of things.

I would wholeheartedly suggest using (and learning) a scripting language - Ruby, Pearl, Tcl. Those are freely available, have bindings to GUI-Toolkits (like TK) which make building a graphical interface a matter of tens of lines of code and are usuable cross-plattform. What is a thing to consider as DOM is, too. And the scripts can be "wrapped" into standalone .EXEs which you can distribute.

I don't think they would pose too much of a performance problem in the time of 3 Ghz processors.

If you're interested in details, PM me. I could supply you with links etc. to a good bunch of free ressources on the net, trainers and manuals included.

algorithm
As alexti already pointed out, there are some "flaws" in your algorithm. His, on the other hand, looks overly complex to me. Something I would expect from a C++ programmer Think he overlooked the fact that some -how do you call it?- "boundary conditions"? are already know at start:
E.g. you could can the map file for all provinces which have only 1 or 2 neighbours - those are the choke points. A "capital" must have at least 3, better 4 land neighbours, so if the number of desired "capitals" is known, you can simply compare it ot the number of "4"s and if those are sufficient, I think you needn't do much more besides checking for duplicates among the neighbours.
Don't have the time to go into further detail now, will look into it later...
__________________
As for AI the most effective work around to this problem so far is to simply use an American instead, they tend to put up a bit more of a fight than your average Artificial Idiot.
... James McGuigan on rec.games.computer.stars somewhen back in 1998 ...
Reply With Quote
  #5  
Old April 1st, 2005, 03:43 AM

alexti alexti is offline
First Lieutenant
 
Join Date: Dec 2003
Location: Calgary, Canada
Posts: 762
Thanks: 0
Thanked 0 Times in 0 Posts
alexti is on a distinguished road
Default Re: Reading maps from .map files

I suspect that this is kind of problem where it is easier to find some available bike with round wheels rather than invent your own with rectangular ones If you take something like Goblin, probably you'd get most of the code you need. You can also look at http://www.kurnikov.org/links/math_links.htm in the Graph Theory section. Or just google
Reply With Quote
  #6  
Old April 1st, 2005, 04:33 AM
Arralen's Avatar

Arralen Arralen is offline
Major General
 
Join Date: Nov 2000
Location: 500km from Ulm
Posts: 2,279
Thanks: 9
Thanked 18 Times in 12 Posts
Arralen is on a distinguished road
Default Re: Reading maps from .map files

Alexti, I think you're missing the point. Someone who is an experienced programmer, maybe software engineer or with an degree in computer science or something, will have little trouble understanding what those libraries do, and how to use them.

Then think of a novice:
He still has to learn the basic syntax of the language.
He can barely do a command line programm, I/O will be a major obstacle.
The concept of OO-programming (C++, Java) is new to him, integrating pre-made libraries into his programm is quite a task for him.
He'll have to delve into the mathematical background of solving problems using computer algorithms, and that of the suggested theorems in particular.

So, it seems to me, you suppose someone should learn how to operate a particle accelerator to poke a hole into a sheet of paper. May work, but won't be the most effective way unless he's going for a degree or two in atomic physics anyway

And we're talking about a real thin sheet of paper: 100-300 provinces (nodes) at best, with less than 750 interconnects.
A short script will really do. If you're fancy, you may implement a graph algorithm in that script language, too (haven't checked if it's already available, but it might be)
__________________
As for AI the most effective work around to this problem so far is to simply use an American instead, they tend to put up a bit more of a fight than your average Artificial Idiot.
... James McGuigan on rec.games.computer.stars somewhen back in 1998 ...
Reply With Quote
  #7  
Old April 1st, 2005, 05:50 AM
Endoperez's Avatar

Endoperez Endoperez is offline
National Security Advisor
 
Join Date: Sep 2003
Location: Eastern Finland
Posts: 7,110
Thanks: 145
Thanked 153 Times in 101 Posts
Endoperez is on a distinguished road
Default Re: Reading maps from .map files

That "Could a Java program using this work" line: it was originally "Would this (algorithm) work". I changed the line to make clear I'm going to make a program utilizing this, not change maps by hand, and managed to translate it to Gibberish. Confusing language, that.

I have already made a working program, ModConverter, which has a GUI and can handles Dominions's mod (text) files. However, I don't have much programming experience besides that and school stuff, and while ModConverter works without crashes it has some annoying input/output bugs, and I'm not going to reuse much code from it. So it seems I didn't plan/implement it properly.


I'm not sure if I understand that "graph" stuff, but hopefully it is just a term I don't know in English. I'll check that.
Okay, I have heard of that. I have to ask my Math teacher a few things, but I think it's doable.
Reply With Quote
  #8  
Old April 1st, 2005, 06:26 AM
Arralen's Avatar

Arralen Arralen is offline
Major General
 
Join Date: Nov 2000
Location: 500km from Ulm
Posts: 2,279
Thanks: 9
Thanked 18 Times in 12 Posts
Arralen is on a distinguished road
Default Re: Reading maps from .map files

Doing a fast scan through the ressources, this is what I found what may be a good starting point:
http://www.cs.sunysb.edu/~algorith/info/view.html
In the 7th line, there's something called "edge-vertex-connectivity" what resembles our problem to some extent.
http://www.cs.sunysb.edu/~algorith/f...ectivity.shtml
__________________
As for AI the most effective work around to this problem so far is to simply use an American instead, they tend to put up a bit more of a fight than your average Artificial Idiot.
... James McGuigan on rec.games.computer.stars somewhen back in 1998 ...
Reply With Quote
  #9  
Old April 1st, 2005, 01:16 PM

alexti alexti is offline
First Lieutenant
 
Join Date: Dec 2003
Location: Calgary, Canada
Posts: 762
Thanks: 0
Thanked 0 Times in 0 Posts
alexti is on a distinguished road
Default Re: Reading maps from .map files

Quote:
Endoperez said:
I'm not sure if I understand that "graph" stuff, but hopefully it is just a term I don't know in English. I'll check that.
Okay, I have heard of that. I have to ask my Math teacher a few things, but I think it's doable.
You can get some basic info at MathWorld: http://mathworld.wolfram.com/Graph.html But if you aren't familiar with graphs at all, you may be for a hard time. Either you implement your own algorithm (like the one you originally suggested) which will work on one maps, but not on others (and ti will keep you puzzled why it didn't work on a particular map). Or you have to go through some learning to find existing algorithm you could use. Your problem is more of a mathematical problem than a programming one. There isn't much to program there if you've figured out the right algorithm. But you can be proud of finding yet another interesting Dominions-related problem Good luck!
Reply With Quote
  #10  
Old April 1st, 2005, 01:17 PM
BigDaddy's Avatar

BigDaddy BigDaddy is offline
Second Lieutenant
 
Join Date: Feb 2005
Location: Central Illinois
Posts: 434
Thanks: 7
Thanked 3 Times in 3 Posts
BigDaddy is an unknown quantity at this point
Default Re: Reading maps from .map files

Guys,

Mike Milchior has done a program similar to that one for another program. You can find a link to it at this site:

http://www.slooflirpa.com
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 09:05 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.