Auto Updating Maps

darkaniken2

Guest
The top tribes and recent conquers should be separate, imo. Nickjer counted the number of villages and the points they were worth and ranked the tribes that way(by points) for the recent conquers, showing who was nobling more, which isn't always obvious from the map(nobling clusters, for example). This can't be done if the maps are combined, since the top ranked tribe in the world may not noble the most villages(and displaying the conquer stats would be difficult on the size allowed). Since you have to know which villages were taken recently to mark them on the map, making those stats shouldn't be too hard.

With some text resizing, would it be possible to just display the actual point value on the maps? On the players, the number already displays below, so doing the same on the tribes shouldn't be too hard, and as long as no one hits a billion points, it should work out. As for the black on the side, would a white background with black-outlined text work? I wish I could find an old map of nickjer's that showed how he did the side area, but I don't seem to have any saved anywhere.
 

DeletedUser61336

Guest
The top tribes and recent conquers should be separate, imo. Nickjer counted the number of villages and the points they were worth and ranked the tribes that way(by points) for the recent conquers, showing who was nobling more, which isn't always obvious from the map(nobling clusters, for example). This can't be done if the maps are combined, since the top ranked tribe in the world may not noble the most villages(and displaying the conquer stats would be difficult on the size allowed). Since you have to know which villages were taken recently to mark them on the map, making those stats shouldn't be too hard.

No, that isn't entirely true. He seperates them both, yes, but for the background villages he uses the toptribes image, but he uses an alpha channel for the toptribe villages, and no-alpha channel for the nobling.

With some text resizing, would it be possible to just display the actual point value on the maps? On the players, the number already displays below, so doing the same on the tribes shouldn't be too hard, and as long as no one hits a billion points, it should work out. As for the black on the side, would a white background with black-outlined text work? I wish I could find an old map of nickjer's that showed how he did the side area, but I don't seem to have any saved anywhere.

He uses a white box on the side, with a 30-pixel height box on top for the details of the map(date, time, what map, etc.). the box itself is 250 x 1000 pixels(widthxheight). As for the spacing he used...

[spoil]
PHP
$font1 = 10;
for ($i=0; $i<$numtribes; $i++) {
$xword = $nump + 90;
$yword = 25 + $i*55;
$xcolor = $nump + 15;
$ycolor = 20 + $i*55;
$width = $xcolor + 60;
$height = $ycolor + 30;
$number = number_format($points[$i]);
imagefilledrectangle($image,$xcolor-1,$ycolor-1,$width+1,$height+1,$charcoal);
imagefilledrectangle($image,$xcolor,$ycolor,$width,$height,$color[$toptribe[$i]]);
imagettftext($image, $font1, 0, $xword, $yword, $black, $fontfile2, $toptribe[$i]);
imagettftext($image, $font1, 0, $xword, $yword+15, $black, $fontfile2, $number." pts");
imagettftext($image, $font1, 0, $xword, $yword+30, $black, $fontfile2, $numvills[$i]." vills");
#imagettfstroketext($image,$font1,0,$xword,$yword,$white,$black,$fontfile,$toptribe[$i],1);
}
[/spoil]

For village outlines the outline gets villageX - 1, villageY - 1, villageX2 + 1, villageY2 + 1. To fix the zoom issue, I would recommend using your own zoom feature, rather than a function one. For example, what I did...

Calculate the lowest possible x coordinate from the village file and calculate: worldSize = (500 - (lowX / 100) * 100) * 2; You don't care about single village issues. You can set what the zoom is based upon the outcome of that. Personally I just use 100% for 500, 200% for 300, and 400% for anything else.

After that comes the fun stuff, first is figuring out the village's new coordinates, which goes like this:

[spoil]
C++
if (villageX.at(villages[topIndex].at(counter)) < 500)
xCoord = 500 - ((500 - ((villageX.at(villages[topIndex].at(counter)) / 100) * 100)) * zoom);
else
xCoord = 500 + ((((villageX.at(villages[topIndex].at(counter)) / 100) * 100) - 500) * zoom);
if (villageY.at(villages[topIndex].at(counter)) < 500)
yCoord = 500 - ((500 - ((villageY.at(villages[topIndex].at(counter)) / 100) * 100)) * zoom);
else
yCoord = 500 + ((((villageY.at(villages[topIndex].at(counter)) / 100) * 100) - 500) * zoom);


gdImageFilledRectangle(image, xCoord - 1, yCoord - 1, xCoord + zoom + 1, yCoord + zoom + 1, charcoal);
gdImageFilledRectangle(image, xCoord, yCoord, xCoord + zoom, yCoord + zoom, playerColors[count]);
[/spoil]

EDIT: After re-reading some old PHP code of mine, I understand that for a clearer image of the outlines on the villages, you first need to handle all the outlines for the first tribe, THEN do the color marker for each village after all outlines are done, to entire there are no strange outlines randomly running through markers, etc. Best way would probably be to run through and do the outlines and store the x and y of what you use in an array/vector(if you so choose to do it similar to myself).

Next is the k lines:

[spoil]
C++
for (int count = 0; count <= kLength * floor(worldLength); count += kLength)
{


gdImageLine(image, partialK * kLength + count, 30, partialK * kLength + count, kLength * worldLength + 30, kNumber);
gdImageLine(image, 0, partialK * worldLength + count + 30, kLength * worldLength, partialK * worldLength + count + 30, kNumber);




}
[/spoil]

And of course the k numbers themselves:

[spoil]
C++
for (unsigned _int8 xLine = floor((10 - worldLength - 1) / 2); xLine < 10 - ceil((10 - worldLength) / 10); xLine++) {


for (unsigned _int8 yLine = floor((10 - worldLength - 1) / 2); yLine < 10 - ceil((10 - worldLength) / 10); yLine++) {


itoa(yLine, kNum, 10);
itoa(xLine, kNum, 10);
x = 82 + (xLine - floor((10 - worldLength) / 2)) * kLength;
y = 98 + (yLine - floor((10 - worldLength) / 2)) * kLength;
gdImageStringFT(image, &brect[0], 0, "Arial-Black.ttf", 10, 0, x, y, kNum);


}


}
[/spoil]

And the calculation for most of the variables used are as such:

[spoil]
C++
float worldLength = 10 / zoom;
int wholeK, numK = 100, kLength = 100 * zoom, worldLengthFloor = floor(worldLength = 10 / zoom);


if (worldLengthFloor % 2 == 1)
wholeK = worldLengthFloor - 1;
else
wholeK = worldLengthFloor;


float partialK = (worldLength - wholeK) / 2;
[/spoil]

This should be able to handle all the zoom you should want to do, even different amounts then what I stated. Of course, you'd still get partial Ks as to what you have already, but it seems like people don't fully care about that anyways.

EDIT: The reason for the disappearing K lines is because of the resize function. It does not handle such thin lines nearly as well, and will ultimately cut some out.
 
Last edited by a moderator:

Chickencatch

Active Member
Reaction score
16
The top tribes and recent conquers should be separate, imo. Nickjer counted the number of villages and the points they were worth and ranked the tribes that way(by points) for the recent conquers, showing who was nobling more, which isn't always obvious from the map(nobling clusters, for example). This can't be done if the maps are combined, since the top ranked tribe in the world may not noble the most villages(and displaying the conquer stats would be difficult on the size allowed). Since you have to know which villages were taken recently to mark them on the map, making those stats shouldn't be too hard.

Hmm. I did consider this but couldn't think of a good way to do it before. It will not be possible (with the current code) to do it based on points, but thinking about it I can do it on #villages nobled.

The code currently works by calculating the tribe/player Ids that should be coloured for each map, along with the rank (and hence colour) from the player, ally, kill_all, kill_att and conquer files then going through the village file and drawing the maps as it does that, so that no village info needs to be saved except the Ids of conquered villages.

Since the info on village points is only stored in the village file, I can't actually total the points before I start drawing them without looping though the village file twice, or saving the data from it and drawing after. I do know how many villages have been conquered though, so can rank players based on that. I will change the map to this.

With some text resizing, would it be possible to just display the actual point value on the maps? On the players, the number already displays below, so doing the same on the tribes shouldn't be too hard, and as long as no one hits a billion points, it should work out. As for the black on the side, would a white background with black-outlined text work? I wish I could find an old map of nickjer's that showed how he did the side area, but I don't seem to have any saved anywhere.

Changed it to display the entire points.
A quick google search finds some maps of his on the previews - if people think that style is better, I can change it.
[spoil]
download.jpg
[/spoil]

Otherwise, I will have another play with the colours at some point and try to find 15 good ones that don't include black - it doesn't really matter which colours they are, as long as they stand out well. I think the current list is mostly good to tell apart, except for the blues and greens in the bottom 5.

He uses a white box on the side, with a 30-pixel height box on top for the details of the map(date, time, what map, etc.). the box itself is 250 x 1000 pixels(widthxheight). As for the spacing he used...

How does that work with the final image fitting on the forums? Does he make 2 copies, one smaller, or just shrink the final image?

EDIT: After re-reading some old PHP code of mine, I understand that for a clearer image of the outlines on the villages, you first need to handle all the outlines for the first tribe, THEN do the color marker for each village after all outlines are done, to entire there are no strange outlines randomly running through markers, etc. Best way would probably be to run through and do the outlines and store the x and y of what you use in an array/vector(if you so choose to do it similar to myself).

Yes, that would work better - I will change that when I change the map to rank them by #villages nobled.

In terms of the zoom function, I'm not sure how well that will work for my case - I'm doing the drawing as I go through the village.txt to avoid needing to save any village data, so I don't actually know how much to zoom by until after the image is drawn. I had it storing the data then doing the drawing but was running into memory issues with that - the Raspberry Pi doesn't have much RAM. It happily had enough to do one at a time, but that was too slow to go through all ~320 active servers one at a time - I changed it to do 4 simultaneously (quad core RPi 2) and it was running out of memory. Might just have been bad code at the time though.

To be honest, I'm not entirely sure it would look better with the markers being that small on the tiny worlds - it would look like the world was really spread out imo. The K numbers are too large, but since they are translucent it's not that big an issue.

It would be possible to draw the K lines/numbers on smaller after, but I am currently generating a single image of that and overlaying it on every map for every server. I am reluctant right now to make it generate one overlay per server on the correct zoom, I think that would make it take longer than 2 hours to update all the servers, especially once I add the dominance maps.

I could make it zoom in discrete steps (whole Ks) and then have 5 different versions of the K grid, that would work.
 
Last edited:

DeletedUser61336

Guest
For nickjer's maps, they were 1250/1000x1030, no resizing. The full image was displayed, and similar happened when I started hosting mine as well. I'm not sure if this is an issue of hosting site vs direct linking or what, idk(dropbox being a host for it, and nickjer's maps.k-io.com being direct). Would be worth having a spare computer or something act as the server itself too(but this could fix other issues as well).

For the issue of resizing and village drawing, this will be a big issue for you. I'm assuming you are feeding/scraping who's leader/top/most nobles/whatever either via url or file. Or you're just going through the data first, finding the correct data, storing what's needed, and then moving onto the villages themselves. In either case, what about storing the village data for an individual player one at a time? Assuming it's not as crazy as W19 ever was, then you should hopefully be able to store the data, just make sure the variables you are using are the correct size.

For the discrete zooming, I guess in your own way, it could work. Just make sure it matches with your markers, which would have to be corrected for the zoom in the first place to match the K lines. :pI personally don't see a significant difference in performance calculating the new position of the markers, but that might be a difference in hardware(running multithreaded 8-core stuff for it).


I would also like to thank you for bringing the kill_all file to my attention, I never noticed it in nickjer's code nor listed as an actual file anywhere. Any others? :D
 

Chickencatch

Active Member
Reaction score
16
For nickjer's maps, they were 1250/1000x1030, no resizing. The full image was displayed, and similar happened when I started hosting mine as well. I'm not sure if this is an issue of hosting site vs direct linking or what, idk(dropbox being a host for it, and nickjer's maps.k-io.com being direct). Would be worth having a spare computer or something act as the server itself too(but this could fix other issues as well).

When they were too big to start with they were not displaying full size, it was just they weren't shrunk enough to fit.

For the issue of resizing and village drawing, this will be a big issue for you. I'm assuming you are feeding/scraping who's leader/top/most nobles/whatever either via url or file. Or you're just going through the data first, finding the correct data, storing what's needed, and then moving onto the villages themselves. In either case, what about storing the village data for an individual player one at a time? Assuming it's not as crazy as W19 ever was, then you should hopefully be able to store the data, just make sure the variables you are using are the correct size.

Yes - I go through all the files that aren't the village file and end up with a sparse array (one per map) indexed by player/tribe id to a struct containing the name/tag, points/conquer rate etc, and rank on the map (colour), for only the player/tribes that should be shown on that map - so each array has 15 entries. I also get a mapping of player id -> tribe id. After that it's just loop through the village file and draw the village in the appropriate colour if that player/tribe is in the array for that map.

Storing the village data for an individual player one at a time meaning going through the village data once per player? That would take too long. In terms of variables being the correct size, I was probably using default int (int32) instead of int16 for the village x/y. Thinking about it, I was also creating two copies of the data for each village, one for the player and one for the tribe, which wouldn't have helped.

Still, memory issues aside, I also got the code to be 3x faster by doing the drawing while parsing the village.txt, and since it takes ~1h 45 to run then I would need to do significant testing before trying drawing after again.

For the discrete zooming, I guess in your own way, it could work. Just make sure it matches with your markers, which would have to be corrected for the zoom in the first place to match the K lines. :pI personally don't see a significant difference in performance calculating the new position of the markers, but that might be a difference in hardware(running multithreaded 8-core stuff for it).

Easy enough to handle the zoom, here's how I do it currently:[spoil]int width = Math.Min(Convert.ToInt32((maxX - 500) * 1.2), 500);
int topLeft = 500 - width;
Rectangle cropArea = new Rectangle(topLeft, topLeft, width * 2, width * 2);
...
g.DrawImage(topTribesMap, mapArea, cropArea, GraphicsUnit.Pixel);
Where mapArea is the green area on the final image and topTribesMap contains the markers.

So it zooms in with a 20% gap around the edge. The Math.Min is so that it doesn't zoom out on full worlds.
Easy enough to change to round up to the nearest 100 instead of multiply by 1.2[/spoil]
I am doing the grid/numbers by creating a mostly transparent image of it and then placing that over the top of each of the maps - it could well be faster to simply draw the lines/text directly onto the final image.

I would also like to thank you for bringing the kill_all file to my attention, I never noticed it in nickjer's code nor listed as an actual file anywhere. Any others? :D

https://forum.tribalwars.us/showthread.php?5996-World-Data
Thats what I've been using as a reference. Only others given are kill_def and tribe versions of them, kill_all_tribe etc.
 

DeletedUser61336

Guest
I wasn't talking about if the image was big enough, but a possible host issue. Because I know nickjer's was hosted at full size, but not cropped off on the forums here. But again, I don't know enough about webhosting or any of that, so I couldn't give a very detailed answer even if I wanted to.

And having the correct variable sizes might help a bit. :p It might be a bit much to do a pass for EVERY player, but who knows, maybe if you upgrade the hardware at some point. For now, the on-the-fly processing might be best for you anyways. The resizing itself seems decent enough as well, so I guess you can't do too much more about that either.

And thank you for that list, I have some more data to go through. :p
 

Chickencatch

Active Member
Reaction score
16
Yes - what I was trying to say was that even when they were on dropbox at 1250x1030 px, that is not the size they were displayed on the forums - something caused them to display smaller on here, it just wasn't small enough. I don't know what might have caused that, but it's probably related to them being on dropbox as you say.
 

DeletedUser92753

Guest
When will the new maps be included on the world threads?
 

darkaniken2

Guest
The code currently works by calculating the tribe/player Ids that should be coloured for each map, along with the rank (and hence colour) from the player, ally, kill_all, kill_att and conquer files then going through the village file and drawing the maps as it does that, so that no village info needs to be saved except the Ids of conquered villages.

If you're reading the village file anyway and saving something from it, and the points are stored on that page, surely it would be fairly simple to just pull the points out at the same time as you pull our the village ID. It may require a bit of trickery, but since you're already storing the village IDs that were conquered and the tribe IDs to make sure they're the right color, surely it shouldn't be too hard to set up an array of tribes that have taken villages(I'm assuming you may already do this, since worlds with hundreds of semi-active tribes would be a nightmare to draw, thus you'd need to limit the number allowed before drawing), and simply add the points as part of a multi-dimensional array. Then you can just get the sum of the points(and count the number of villages, for that matter) that each of the top 15 tribes took. I mostly use java, but C# works mostly the same way from what I recall, so this should be possible.

As for the look, I think the colored box with a white background and black text is easier to read personally, but that may just be because I have relatively bad eyesight.
 

DeletedUser61336

Guest
The points array wouldn't even need to be multidimensional. A simple 2d array for players should work just fine. playerPoints[playerID] += villagePoints; However, making an array would mean knowing the number of players before declaring the array. A vector, or c#'s equivalent to a vector would be better. But he also has the issue of memory. So who knows.
 

DeletedUser

Guest
Any chance to put family tribes under 1 color? Or would that be hard because it would have to be edited for each world separately
 

Chickencatch

Active Member
Reaction score
16
If you're reading the village file anyway and saving something from it, and the points are stored on that page, surely it would be fairly simple to just pull the points out at the same time as you pull our the village ID. It may require a bit of trickery, but since you're already storing the village IDs that were conquered and the tribe IDs to make sure they're the right color, surely it shouldn't be too hard to set up an array of tribes that have taken villages(I'm assuming you may already do this, since worlds with hundreds of semi-active tribes would be a nightmare to draw, thus you'd need to limit the number allowed before drawing), and simply add the points as part of a multi-dimensional array. Then you can just get the sum of the points(and count the number of villages, for that matter) that each of the top 15 tribes took. I mostly use java, but C# works mostly the same way from what I recall, so this should be possible.

I am not saving anything from the village file (except points for dominance), the village IDs are pulled out of the conquer.txt which doesn't contain the points info.

The problem is not in totalling the points, it is that the background map is being drawn simultaneously so the colours (and hence ranks) are fixed. The points needs to be totalled while going through the village.txt, but that is also where the drawing occurs so the colours must be decided before I start on the village.txt.

Once I have changed it to rank based on #villages (the current ranking is simply the same as the top tribes) I can make it display both the number conquered and the total points of the conquered villages at the side.

As for the look, I think the colored box with a white background and black text is easier to read personally, but that may just be because I have relatively bad eyesight.

I will change it, probably tomorrow.

Any chance to put family tribes under 1 color? Or would that be hard because it would have to be edited for each world separately

That will be coming at some point, but is not available yet, sorry. Once I have made it possible, someone from each world that wants it will need to get in touch with me and it will be up to them to keep the list up to date.
 

Chickencatch

Active Member
Reaction score
16
Just a warning: Automatic updates have been temporarily stopped so I can update the version of mono I'm running on the raspberry pi, which will hopefully fix several issues I've run into recently. Updates should be resuming tomorrow.

Dominance maps have been completed, but need the updated mono to run properly.
 

DeletedUser100206

Guest
Any chance of changing the style of the dots for villages? They just look very ugly on the small maps which only show a few K's, they are too large and it's very very difficult to see the map.
[spoil]
TopTribes.png
[/spoil]


Great work however and am pleased to see the auto-updating maps again.
 

Chickencatch

Active Member
Reaction score
16
With the current code, no, it isn't possible unfortunately.

However, there have been enough issues with it now that I am going to redo it a different way, which will be able to. This may take a while, but it shouldn't be too long - a few days/weeks.


Update:
Mono finished compiling, maps are back updating and the dominance maps are done. I'm going through and adding them to the world threads now.
There are some interesting effects on the text on the dominance maps, mainly around characters like W, M, N etc - I'm not entirely sure how to fix this though.
Also, I feel the text might be a little large on the player names, it's hard to see the map behind. However, it's just the top players map in the background, so do people think it's needed to see it? Would like opinions on that.
 
Last edited:

darkaniken2

Guest
I think the text on both dominance maps is a wee bit too big. Longer names get utterly crushed by shorter names in bigger fonts next to them, because your eyes are drawn to the bigger text.

As for the effects, it looks like a shadow problem. Maybe it's the font?

Also, as for the player dominance map, the way nickjer did it was get the number of points(he used points since that's how the ingame rankings are sorted), then displayed the players that had the most points in a single K. For example, if Player A had 20m in 1 K out of 25m total, and player B had 18m out of 31m total, and player C had 7m out of 28m total, player A would be the top ranked person on the dominance maps, but the third on the top players map. Obviously, this won't work if you're just recycling the top player map, and would require new code to be written.
 

DeletedUser108587

Guest
Forgive me if my question is kind unrelated but after we get to the link (with raw=1) all we have to do is link it in the thread or we have to download the picture and "instert image" in the thread?
 

Chickencatch

Active Member
Reaction score
16
I think the text on both dominance maps is a wee bit too big. Longer names get utterly crushed by shorter names in bigger fonts next to them, because your eyes are drawn to the bigger text.

As for the effects, it looks like a shadow problem. Maybe it's the font?

Yes, will shrink it on both. I'm having various issues with the fonts, I also need to look into finding one that the RPi can use to render the Korean player names since they mostly show up as squares. Strangely, they display fine on a windows PC I'm also using, and the font is embedded into the project so I'm not sure what's going on there.

Also, as for the player dominance map, the way nickjer did it was get the number of points(he used points since that's how the ingame rankings are sorted), then displayed the players that had the most points in a single K. For example, if Player A had 20m in 1 K out of 25m total, and player B had 18m out of 31m total, and player C had 7m out of 28m total, player A would be the top ranked person on the dominance maps, but the third on the top players map. Obviously, this won't work if you're just recycling the top player map, and would require new code to be written.

What I was thinking was to rank people based on how many K's they own - people/tribes get 2 'points' for being rank 1 in a K, 1 'point' for being rank 2 and then its ranked on 'points'. I feel that would give a better idea of how much of a world someone owns than simply ranking them based on their largest K. This requires the entire code change I will be doing at some point, probably this weekend.

Forgive me if my question is kind unrelated but after we get to the link (with raw=1) all we have to do is link it in the thread or we have to download the picture and "instert image" in the thread?

You should be able to wrap that link in IMG tags, like this but without the stars:
[*IMG]https://www.dropbox.com/sh/grr3a12j71fr0h7/AADxLNeQOqttBnpwNqkHnM16a/tribalwars.net/en70/TopTribes.png?raw=1[*/IMG]
 

DeletedUser108587

Guest
Can you tell me how to merge 2 tribes in one (Like a family tribe)?
 
Top