Creator of Territorial.io Posted December 16, 2020 Share Posted December 16, 2020 Hello, I am thinking about to create a Europe map for my game. There are some restrictions: -I don't want to load the map over the internet because I want to keep the network traffic small -I don't want to increase my code significantly. The map should have the size of 1000x1000 pixels. This results in 1 million pixels overall. To save all pixels as black white values would result in 8 million bit. That would increase my game size too much! I am thinking about creating the map by an algorithm. But that seems to be difficult, right? So far I have an algorithm that creates my other maps dynamically. The input of this algorithm is just a pseudo random number. And now I am thinking about a very big number that creates the Europe map "by accident". Can anyone still follow me? Quote Link to comment Share on other sites More sharing options...
b10b Posted December 16, 2020 Share Posted December 16, 2020 (edited) This sounds like a fun challenge - to procedurally generate a map representative of Europe using a seed and some magic / chaos. Slartibartfast would know it immediately. However, I'm skeptical the resulting code would be significantly smaller than a ~1 mega pixel bitmap at load time. For reference an optimized lossless png of Europe (with 2 colors) is approx 6KB - attached. Perhaps you'd save 4KB absolute tops? The expanded video memory would be the same at runtime irrespective of whether the source was procedural or asset, so ... other than for the fun of it, why? Original image source: https://webstockreview.net/explore/europe-clipart-content/ Edit: looking at this map I did wonder how big a similar SVG bezier path would be ... perhaps ~1,000 anchor segments would do it ... each segment needs ~26 characters ... so 1000 x 26 bytes = 26KB? Could be optimized further and compressed, but I don't think it'd beat 6KB for the same level of fidelity, but it might come close? It would scale MUCH better though! A simpler outline (with artificial detail to backfill) could be the start of a procedural approach ... 2.6KB + procedure. Edited December 16, 2020 by b10b added SVG suggestion Quote Link to comment Share on other sites More sharing options...
Creator of Territorial.io Posted December 16, 2020 Author Share Posted December 16, 2020 6 hours ago, b10b said: This sounds like a fun challenge - to procedurally generate a map representative of Europe using a seed and some magic / chaos. Slartibartfast would know it immediately. I think this challenge is too big for me. My players wish a Europe map but I don't know how to fulfill it. I want to keep my game size and network traffic small. One way to describe a picture with two colors is to look at one pixel line and only save the indices where a color starts and where it ends. And then repeat it with all lines. That would cost for the Europe map with a height of 1000 pixel maybe 6*10*1000 Bit = 60 000 bit = 7500 byte. Then I could add the terrain ("skin","surface") with my map generator algorithm. This approach is good. But there is one problem. The problem is that I can't smoothly draw the terrain between ocean and coast... Quote Link to comment Share on other sites More sharing options...
Creator of Territorial.io Posted December 16, 2020 Author Share Posted December 16, 2020 This for example is a smooth transition between ocean and coast. Quote Link to comment Share on other sites More sharing options...
Creator of Territorial.io Posted December 16, 2020 Author Share Posted December 16, 2020 And this is a map with NO smooth transitions: Quote Link to comment Share on other sites More sharing options...
b10b Posted December 16, 2020 Share Posted December 16, 2020 I'm still unsure why bitmaps of this size are a concern to you, especially for a one-off map? A properly compressed 1000x1000 png will likely be less than a few hundred KB (and offer all the shading and smoothing you can think of). Or you can get fancy by overlaying textures based on conditions (e.g. edge glows) and grow the map collection without excessive bloat. I played your game btw, cool! Quote Link to comment Share on other sites More sharing options...
totor Posted December 17, 2020 Share Posted December 17, 2020 maybe you can use a smaller map (256*256) then upscale or you can use a few polygons then noise the result Creator of Territorial.io 1 Quote Link to comment Share on other sites More sharing options...
b10b Posted December 17, 2020 Share Posted December 17, 2020 While playing the game (ok I admit I'm a little hooked now) I had another idea. It looks like the maps are seed generated chaos, with a half dozen having been hand selected, named, and set as presets? If so I assume an ~infinite number of potential maps already exist within the system. Amongst them is "Europe" - waiting to be discovered. So train the routine to recognise how close to Europe each random seed is, e.g. giving a score based on pixel matches to the reference image. Then let it run on loop for a week, and turn over a few quadrillion tries. Keep a record of the top 100 scoring maps. Manually review them at the end of the week and select a winner. Use that seed as "Europe". Total additional filesize: a few bytes. Why not look for other famous maps at the same time - e.g. The World, Westeros, etc ... Creator of Territorial.io 1 Quote Link to comment Share on other sites More sharing options...
Creator of Territorial.io Posted February 16, 2021 Author Share Posted February 16, 2021 "If so I assume an ~infinite number of potential maps already exist within the system. Amongst them is "Europe" - waiting to be discovered." That is a nice idea. But I think that the resulting seed would be as large as the map itself. And the time to find the map would be very long. My solution was to save the Europe map as an image with two colors. In the end it costs me 23 kilo byte. That is ok and as long as the whole game stays under 500 kb everything is fine. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.