Who owns the island?

DeletedUser

Guest
This is the basic question if you want to make for instance an alliance top 12 map.

In world delta (here) i have presented what I think is the best approach to deciding who is the owner of an island, so what colour an island should be. I took this discussion to here because it might be of interest to other prorammers.

It comes down to this algorithm:

1) Check each island. If an island has a member of the top 12 allies present then remember the island. This gets rid of the islands where top 12 alliance members have no cities.

2) check each island in memory again. calculate the total points of all cities, not counting the cities lower than 1000 points. This makes total city count=100% per island.

3) Calculate the sum of all cities > 1000 for each alliance present on the island.

4) Calculate the relative presence per alliance based on city points expressed in % of total city count.

5) Assign the colour of the island to the alliance that has a presence of 50% or higher.

In addition it would be feasible to calculate some sort of a "world domination factor" based on the presence on islands.
 

DeletedUser

Guest
This algorithm requires a lot of calculation, and to maintain speed it is required to loop through the data as efficient as possible. So I did some counting and this is what I got (data based on world gamma, approximate):

total alliances: 2000, of which 12 in the top 12 (duh...)
total players: 30.000 of which 785 in the top 12 alliances
total towns 57.000 of which 15.000 owned by players in the top 12
total islands 100.000 of which 5000 have a presence of a top 12 alliance player

Now the fun part is to process this data as efficient as possible...
 

DeletedUser5

Guest
How are you storing the world data?

because obviously, you need to be storing that in the most accessible way, where the data can easily be put into arrays and trimmed that way.
 

DeletedUser

Guest
I store the world data in lists, and the processing is incredibly fast in python (I cant compare to other languages).

For instance to do the following:
- loop through the alliance list to find the top 10 alliances (2000 checks).
- for each top 10 alliance loop through the players list to find the players (adds 10x30.000 checks)
- for each player loop through the cities list to find the cities of that player (adds 800x57000 checks)

this makes 2000 + 300.000 + 45.600.000 = 45.9002.000 checks
and this takes 15.7 seconds (!) on my PC.

But the next step is to decide on island color. Finding the largest city is relatively easy but if there is a time-consuming algorithm that has to be performed 45M times it will take a while...
 

DeletedUser

Guest
Hmm after a sunday of puzzling I end up with no way doing this properly. I think i'm going to have a beer of 2, 3, 4.. maybe that helps....

Problem is that the only way to link players to islands is via the x-y coordinates in the towns file and in the islands file. these data files are the two largest files, which means you either have to loop through the islands x/y coordinates for all cities(100M x 100M x 60k loops), or you have to loop through all city x/y coordinates for all islands (60k x 60k x 100M loops). Both take too much processing time. But there's no other way to find out who lives where...
 

DeletedUser5

Guest
Another way you could think about doing it (I can think of ways using php and mysql, but I don't know python), is by making your own data files from the data files, including the information that you need. This could all be done behind the scenes when storing the data in your lists. Then you could call the information from these new data files, and not have to do that ridiculous amount of loops.
 

DeletedUser

Guest
Yeah thanks ac, I guess your right. This is what usually happens to me when I am eager to solve a problem. I get too involved and cant stand I cant get it right. It is time to take a break and take some distance to the problem, look at it in broader perspective.

You're absolutely right that it should not be necessary to do millions of loops...
Maybe there is an easy way to have python make a little database...
 

DeletedUser

Guest
Yeah, it seems unavoidable. So far I could work with a single .exe file which did all the data handling without a database. I have to figure out how to set-up a database for users of the program. I guess this means an installer like msi...

More things to figure out lol

Oh meanwhile i did upload version 4.1 in case your interested...
 

DeletedUser5

Guest
I don't have the pygame thingy downloaded for python at the moment, I'll do so later on tonight, and I'll give you some CnC
 

DeletedUser5

Guest
Seems to me, an installer would be necessary, could install xampp onto their computer, and then incorporate it into there. As I say, I don't have a lot of knowledge about python and it's compatibility with apache etc, so I'm assuming that this is all possible. Alternatively, get yourself some webhosting, and maintain the database online. Then connect to it from the client's application. This will mean that everyone will use the same data, and wouldn't therefore need to update the databases, as you could do it automatically.
 

DeletedUser

Guest
its a stand-alone program, an .exe so you can just download ans use...

No, I appreciate your advice but I have decided that an online database is not the way to go. maybe later...

I found out about pytables and gadfly, and I will look into this later.
 
Last edited by a moderator:

DeletedUser

Guest
yall are talking really technachical thats really cool beacouse then tht tells me yall are really good at this stuff

:)
 

DeletedUser

Guest
The pytables looks promising. I have re-edited the program to use the pytables, and I can now download world data and store it in a database. Next step is to figure out how exactly I need to build the database.
 

DeletedUser

Guest
I've used Python+MySQL for my version of the tools. There isn't a python-mysql module for python 3.0 tho (as far as I know, it's been a while...) and that's part of why I've stick with 2.5+

PHP would be just as good, but page loads (if you're using php in a webserver, even a local one) would be really slow...if anyone is doing it in PHP, I suggest running it in the command line, and maybe set cron jobs (or whatever non-unix systems use for scheduled tasks) to run the script and update your maps/data a few times through the day.

My way of doing it was to set up an interactive console to consult data (recent conquests in a specific ocean, top alliance-less and abandoned towns in an ocean...etc) and generate the world/ocean maps.
 
Top