Risk-style map
Author |
Message |
Raknarg
|
Posted: Sat Jan 14, 2012 11:38 pm Post subject: Risk-style map |
|
|
I recently played a board game called Pandemic. The tiles are arranged basically the same way. You have a bunch of seemingly random points, cennected in a seemingly random way. I wanted to try and make a program for it, but I hit a big roadblock. I was wondering, is there an elegant solution for defining the connection of an ordered array in an apparently random order without having to define every one of the connections seperately?
If that doesnt make sense, I think about it this way: Lets say you have a 2d array. Now the connection between those point would be simple: x + 1, y; x - 1, y; x, y + 1; x, y - 1. Those would be all the blocks touching it. However, this doesnt work on a risk board, because element 3 could be connected to element 24 for no apparent reason, and it changes with the element you're looking at. The only way I can think of to define each connection is to tell the computer exactly what connection you're doing. ex if its country 3, its touching country 24 and country 17; if its country 24, its touching county 3 and country 32.
Any ideas? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
|
|
|
|
RandomLetters
|
Posted: Sun Jan 15, 2012 12:07 am Post subject: RE:Risk-style map |
|
|
If it's a graphical game, you will have to draw the map manually.
It would be possible to draw the map and then flood fill each region, which would hit adjacent regions.
But, just doing it manually will only take a few minutes anyways. |
|
|
|
|
|
Zren
|
Posted: Sun Jan 15, 2012 3:01 am Post subject: RE:Risk-style map |
|
|
Is the following, nodes have position. Distances (dx) are actually ranges (d +- fluctuation).
Randomly generate nodes d1 far apart to seed continents. Then generate nodes d2 far apart to build the continents (and probably connect some of the continent seeds). You're not connecting them yet, just generating the positions. Now connect all nodes d3 far apart. Any node with >1 connector rolls a dice to attach another connector. Finally, use a few connectors between each closed system (Australia -> Asia; Newfoundland -> Iceland -> Europe). Once it's just one system, you can worry about looping over the borders.
After generating all the nodes, you could can use Voronoi diagram to generate the map. Basically you generate a whole lot more points to make the contours of the conentents. I found this article when I was checking it out before:
http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/
Just make sure that when you run the relaxation method, that your node positions are also updated properly (Node inherit Point?).
Actually, you should probably reverse that logic. Generate the map first, then change 'randomly select points' to 'randomly select polygon'. |
|
|
|
|
|
Raknarg
|
Posted: Sun Jan 15, 2012 4:04 pm Post subject: RE:Risk-style map |
|
|
Well, the map itself isnt the problem. Lets say that it doesnt exsist: the only thing that exist are a bunch of points on the screen. The connections arent actually based off of what country is touching what, it's based off of what city is connected to what. Do I think I'll just stick with Tony's suggestion. Thanks anyways. |
|
|
|
|
|
|
|