|
|
|
|
 |
|

April 1st, 2005, 03:43 AM
|
|
First Lieutenant
|
|
Join Date: Dec 2003
Location: Calgary, Canada
Posts: 762
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 
|

April 1st, 2005, 04:33 AM
|
 |
Major General
|
|
Join Date: Nov 2000
Location: 500km from Ulm
Posts: 2,279
Thanks: 9
Thanked 18 Times in 12 Posts
|
|
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 ...
|

April 1st, 2005, 05:50 AM
|
 |
National Security Advisor
|
|
Join Date: Sep 2003
Location: Eastern Finland
Posts: 7,110
Thanks: 145
Thanked 153 Times in 101 Posts
|
|
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.
|

April 1st, 2005, 06:26 AM
|
 |
Major General
|
|
Join Date: Nov 2000
Location: 500km from Ulm
Posts: 2,279
Thanks: 9
Thanked 18 Times in 12 Posts
|
|
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 ...
|

April 1st, 2005, 01:17 PM
|
 |
Second Lieutenant
|
|
Join Date: Feb 2005
Location: Central Illinois
Posts: 434
Thanks: 7
Thanked 3 Times in 3 Posts
|
|
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
|

April 1st, 2005, 01:16 PM
|
|
First Lieutenant
|
|
Join Date: Dec 2003
Location: Calgary, Canada
Posts: 762
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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!
|

April 1st, 2005, 01:35 PM
|
|
First Lieutenant
|
|
Join Date: Dec 2003
Location: Calgary, Canada
Posts: 762
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Re: Reading maps from .map files
Quote:
Arralen said:
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 isn't exactly a novice. Didn't he wrote some tools for Dom2? Anyway, if the primary idea is to learn some basics of the language and not to solve the problem of finding the "areas", it doesn't matter which algorithm to use.
Quote:
Arralen said:
The concept of OO-programming (C++, Java) is new to him,
|
I think that concept of OO-programming can be new only to old-school programmers  Meaning that C++ (and Java, to some extent) concepts match modelling languages almost exactly, so the step of converting the model into procedures is effectively removed.
Quote:
Arralen said:
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.
|
I wouldn't be so optimistic. For example, check http://domino.research.ibm.com/Comm/...arch2005.html. Just 6x6x6 cube with 2 possible values in a cell and its way beyond the computing power of modern computers.
Getting back to our particular task, the simple algorithm that would check for chokepoints would apparently have to verify if the graph is connected for each single and pair of nodes, which for province with N=200 nodes gives you about O(N^2)=40000 verifications for graph connectivity. And checking graph connectivity is not particularly fast operation. It may or may not be a problem, it's kind of estimation, where you can't say for sure without actual test. So to avoid frustration of discovering that your nicely written program can't handle large maps in reasonable time it may be better to look up for more efficient solutions from the start.
Of course, all this doesn't matter if the primary goal is to learn programming.
|

April 1st, 2005, 02:28 PM
|
|
First Lieutenant
|
|
Join Date: Mar 2004
Location: Seattle
Posts: 771
Thanks: 0
Thanked 3 Times in 2 Posts
|
|
Re: Reading maps from .map files
Actually I would figure that validating whether a graph is connected or not would be an O(n) operation since you simply walk the graph from any randomly selected node and if the number of nodes in the walk is equal to the number of nodes in the graph then it is connected.
So the whole operation you described would be O(n^3).
|

April 1st, 2005, 02:54 PM
|
|
First Lieutenant
|
|
Join Date: Dec 2003
Location: Calgary, Canada
Posts: 762
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Re: Reading maps from .map files
Imagine graph:
Code:
x-x-x-x-x-x-x-x-x-x
If you start your walk from any node in the middle you'll reach dead-end without passing through all the nodes, even though the graph is connected. So you need to retrace your steps to walk through all graph. I think that establishing if the graph is connected or not is O(m), where m is number of edges (neighbour connections). However it is somewhat bigger O, in sense that each operation is more costly than iterating through the node. We start from random node, mark is as "visited", select any edge outgoing from "visited" node and mark it as "travelled", mark the node it leads to as "visited" and repeat procedure selecting the next "non-travelled" edge outgoing from "visited" node. If all nodes are "visited" at the end, the graph is connected. In this method we need no more that number of edges iterations, but the most efficient implementation of it will probably involve 2 copy of list of edges and list of nodes and moving elements from one to another, which is more costly than just iterations.
|

April 1st, 2005, 03:18 PM
|
|
First Lieutenant
|
|
Join Date: Mar 2004
Location: Seattle
Posts: 771
Thanks: 0
Thanked 3 Times in 2 Posts
|
|
Re: Reading maps from .map files
When you walk the graph you simply do a BFS on the graph and then color each node as you visit it and never revisit a node which is colored.
One easy method of programming this is to take a random node and push all of it's neighbors onto a stack. Then for each element on the stack check to see if the node is colored if so then ignore if not then push all of it's neighbors on the stack, bump the global count and color the node. Repeat. If at the end the global count is equal to the number of nodes in the graph then it is fully connected. A decent interview question.
The order of this is O(m) ( where m is the number of edges ). When I said the order was O(n^3) I was assuming that n~m this may not be a valid assumption. Clearly in a fully connected graph m = n^2. But most maps in dominions do not match that profile.
PS: I used the word "walk" in my 1st post which was incorrect. I should have defined what I meant which I did in this post sorry about being unclear.
|
| Thread Tools |
|
|
| Display Modes |
Hybrid Mode
|
Posting 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
|
|
|
|
|