Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Hexagon or Squares - What to go for in maps

Discussion in 'Game Design' started by Reloque, Sep 3, 2018.

  1. Reloque

    Reloque

    Joined:
    Apr 28, 2015
    Posts:
    74
    So, I am building a hobby project, bit of Civ type game. It's coming along nicely, well swimmingly anyways. But I am currently playing with a few ways to get the overland map done, hexagons or squares.

    The original Civ games, up till Civ V all had square maps based maps. Most of the derived games of those, Call to Power, Master of Magic and Colonization also did. Some of them tilted, some of them straight. Then there is Civ V and it's hexagons. They seem to work a bit different and some other games, such as Age of Wonders have used them to great effect.

    I am doubting and thinking about how to ahead and basically I've come to about 4 options, no preference for any of them, and I've done some work in all of them. Also, the game is Isometrical, I've mad an endless looping camera system that stitches the edges of the maps together, as if the game world is mounted on a flat cylinder.

    1. Square tiles, rotated
    upload_2018-9-3_21-18-9.png

    This is the first option I explored, the grid is layed out in a staggered X-Y system, rotated 45 degrees so the camera can be rotated for a flat isometric view. The major drawback is it's complex to map a coordinate system on that that's easy for a human to understand. There are also some drawbacks in converting a real map to a set of tiles.

    2. Square tiles, straight
    upload_2018-9-3_21-29-34.png
    The second option, much easier to code, but not as good to look at. Figuring out how to improve it so that the advantages of this would be in option 1 or 3 would be a good idea. This is the simplified map I used to program basic Dijkstra pathfinding. But while it's good for limited maps with clear borders, it doesn't lend it self to much else. It could be projected as this, but then it can't really be a wrap around map.
    upload_2018-9-3_21-32-42.png

    3. Hexagons
    upload_2018-9-3_21-37-39.png

    Circles with edges basically. Some of the same advantages of rotated tiles and some of the same disadvantages of straight tiles. But, it seems to be more the standard in today's 4X game genre. Same math problems, maybe more straightforward solutions.

    4. Forget about tiles
    And make the game much more granular, like say Starcraft or Command and Conquer. I am not enitrly sure if this would be a good idea for Civ type game. Much of the mechanics of those games work with quite strict borders, but they were build that way because tiling was feasible and 'real world' coordinates weren't really.

    So, what would be the mapping of choice for such a game, and why. I am interested in viewpoints and discussions.
     
  2. YBtheS

    YBtheS

    Joined:
    Feb 22, 2016
    Posts:
    82
    Things to consider:
    • The shape (or lack thereof) of a tile affects how many directions a thing can move. This may change people's strategies and the way they go about tasks.
    • The shape and orientation of a tile affects the efficiency of movement. A square, on average, offers the least efficient route. If I want to move diagonally towards the top left, I must go first up 1 tile and then left 1 tile whilst with a hexagon I can end up (approximately) in the same location by simply moving to the tile on its top left face. Using no tiles is even more efficient.
    • Your target audience may already be used to one of these systems. It seems you are already familiar with what other strategy games use. If you are worried about a player being confused, note that many who are interested in strategy games probably have already used some. The more used the system, the easier it will be for strategy gamers. Also note that you don't want to alienate people who are newer to these kinds of strategy games so you still should strive to make it as easy as possible.
    • The AI may have more difficulty dealing with one system than another. Figure out how you're going to code the AI to navigate and any potential downfalls it may have.
    • Hearts of Iron has a great system. It doesn't use any regular shapes for its tiles. Every shape is made by the map designer I'd assume although I'm not quite sure. This allows different strategic points (like rivers and choke points) to be hand crafted for gameplay purposes. It also makes the screen look less monotone, rivers less squiggly, and the coastlines less jagged which is a problem with squares and rectangles.
     
  3. Unknown33

    Unknown33

    Joined:
    Aug 18, 2018
    Posts:
    170
    Tiles are dead. My $0.02
     
  4. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    3,578
    You know what? I ACTUALLY agree with @Unknown33. I just do range checks instead these days.
     
    Unknown33 likes this.
  5. Reloque

    Reloque

    Joined:
    Apr 28, 2015
    Posts:
    74
    I've done the AI bit for navigation and distance already. Dijkstra implementation works well in this case, for all 3 tile implementations in fact. It's in essence just graph. So it works for all tile implementations.

    I've never considered a target audience really, as at this point it's mostly POC and hobby work. But it's a good point, what are people accustomed to, what works well in games. If you look at evolution, it went from top down sqaures, to tilted and isometric and lately to hexagons. Voronoid could be next, it does make for more interesting map structures. I wonder how hard it would be to create a voronoid based map.

    To say tiles are dead, without much explanation, seems a bit easy. Also not quite right as well, Civilization 6 sold over a million copies. X-Com and X-Com 2 were huge successes. Then there are games like Factorio and the in my eyes masterwork of Bastion. Two Point Hospital just went live. All more or less tile based, all very much alive. To say that tile based gaming is dead, seems a bit of an overstatement.
     
    YBtheS likes this.
  6. YBtheS

    YBtheS

    Joined:
    Feb 22, 2016
    Posts:
    82
    Perhaps you should elaborate a bit... Those were pretty vague and useless comments. I've only played one grand strategy game that doesn't utilize tiles and that was Napoleon: Total War. That's not to say that there are no tileless grand strategies. I just have no reason to believe that tiles are dead nor that tiles are inherently bad.

    Cool. I'm not familiar with Dijkstra's implementation. How does your system work? Do you just feed in a waypoint to the AI and it just calculates the best route and goes there?
     
  7. Reloque

    Reloque

    Joined:
    Apr 28, 2015
    Posts:
    74
    Dijkstra was a Dutch computer scientist and mathematician. The algorithm is explained here on Wikipedia: https://en.wikipedia.org/wiki/Dijkstra's_algorithm but is in essence this;

    Code (CSharp):
    1.  1  function Dijkstra(Graph, source):
    2. 2
    3. 3      create vertex set Q
    4. 4
    5. 5      for each vertex v in Graph:             // Initialization
    6. 6          dist[v] ← INFINITY                  // Unknown distance from source to v
    7. 7          prev[v] ← UNDEFINED                 // Previous node in optimal path from source
    8. 8          add v to Q                          // All nodes initially in Q (unvisited nodes)
    9. 9
    10. 10      dist[source]0                        // Distance from source to source
    11. 11  
    12. 12      while Q is not empty:
    13. 13          u ← vertex in Q with min dist[u]    // Node with the least distance
    14. 14                                              // will be selected first
    15. 15          remove u from Q
    16. 16      
    17. 17          for each neighbor v of u:           // where v is still in Q.
    18. 18              alt ← dist[u] + length(u, v)
    19. 19              if alt < dist[v]:               // A shorter path to v has been found
    20. 20                  dist[v] ← alt
    21. 21                  prev[v] ← u
    22. 22
    23. 23      return dist[], prev[]
    I've made a Graph, Node and Edge object in C# implementing Dijkstra. For any sort of travel on a map that can be expressed as a Graph, that works. So all tile based maps, but also maps that feature height or different costs for paths.

    I feed it a start point, and then the algo calculates the shortest path to all other nodes.
     
  8. YBtheS

    YBtheS

    Joined:
    Feb 22, 2016
    Posts:
    82
  9. Reloque

    Reloque

    Joined:
    Apr 28, 2015
    Posts:
    74
    Yes. In fact, A* is informed Dijkstra as some say. The benefits of using better algorithms are small in my case, as I am only doing a relatively small graph. But, path finding isn't my issue here, that's pretty well defined for my type of use case.

    This person has a nice write up on Voronoi map and world generation that I am going to look into.
    http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/
    Oh, and also a Unity project for that: https://squeakyspacebar.github.io/2017/07/12/Procedural-Map-Generation-With-Voronoi-Diagrams.html


    I wonder if the world is ready for Voronoi based Civ games. It does make it more complex. But it might make it more believable.
     
  10. YBtheS

    YBtheS

    Joined:
    Feb 22, 2016
    Posts:
    82
    I'll save those sources and keep them handy in case I ever want to do something like that.

    I guess we'll have to wait and see. Personally I like the sound of that.
     
  11. Unknown33

    Unknown33

    Joined:
    Aug 18, 2018
    Posts:
    170
    The debate between tile systems goes as such: Squares or hexagons? Iso?

    Which is an important discussion to have if it's 1995 and you don't have enough resources for every entity on the screen to re-path each update. Or if you're building an open world adventure and its 1993 and you need to make use of tiling to paint the world because no feasible alternative can be found.

    But it's nearly 2020 and we can have each pixel on the screen repaint itself based on complex logic encoded into shaders. We can fit your favorite tile-based epic strategy game physically on the tip of a pen. Literally.

    That thing that people were simulating with tiles was real war... which we now have games where you can have real war with moving, animated characters.

    I can accept that it's a niche, like table top gaming, but this is also the Unity 3D game design forum and you asked me to elaborate.
     
  12. YBtheS

    YBtheS

    Joined:
    Feb 22, 2016
    Posts:
    82
    I don't think that having the resources to do something justifies doing it.

    Tiles have their pros. Can you imagine playing Hearts of Iron without them? It wouldn't be too fun. Moving a 100 units around without leaving any gaps for enemies to go through. It is as simple as covering every tile with a division. No need to check every spacing to see if it's big enough to allow an enemy to fit through.

    I don't see why a tileless system would be objectively better. It seems that what is best varies from game to game and from audience to audience. If it was, I must wonder why so many modern (AAA) games use them.
     
  13. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    2,805
    I like hexes. I play a lot of board games with hexes.

    Square tiles are great if you're really lazy though, and there's nothing stopping you from allowing diagonal movement for 8 directions. Yes, it might be ugly. So use those hexagonal tiles if it looks unpleasant, you lazy git!

    If you aren't using tile movement at all, you're probably also building the map through some other means than simple tile shapes. If it's clearly hexagonal people would also expect to be following some sort of movement constraint related to the territory transitions. Plain squares might be better at masking the composition, actually.

    But Unity terrains and stitching can work just fine. I think there is at least one node-based generator which would be perfect for generating terrains to spec, but with variation (unless the Voronoi example above turns out decent). There's also example code out there for terrain stitching, which could be helpful.

    Using a fancy generator and some triplanar texturing shaders and tools gives you realistic ground/seabed to mountain texturing and transitions though (two or three great terrain texture tools are on the UAS). Then physics or reading the heightmaps should also give you the data you need to alter free-form movement costs.
     
  14. Unknown33

    Unknown33

    Joined:
    Aug 18, 2018
    Posts:
    170
    For the same reason they still sell old people hard candy at the store. People who don't know that better things exist still buy it.

    Edit: Now I got a craving for old people hard candy.
     
    Last edited: Sep 5, 2018
  15. YBtheS

    YBtheS

    Joined:
    Feb 22, 2016
    Posts:
    82
    Since when did hard candy brands actively pursue old people? o_O I would think that they would target children. Children are to hard candy as strategy gamers are to tiled strategy games. They like them. They keep getting them. It works well enough to keep people playing.

    But even if we assume it is because gamers know no other way, you still haven't proved that tileless games are objectively better.
     
    RavenOfCode likes this.
  16. Unknown33

    Unknown33

    Joined:
    Aug 18, 2018
    Posts:
    170
    Real life isn't debate team.

    Gummy candy is better than hard candy.

    3D is better than 2D.

    Floating point positioning with pathing is better than tiles.
     
  17. Reloque

    Reloque

    Joined:
    Apr 28, 2015
    Posts:
    74
    You do know that those are opinions right? Not facts. Well, accept the real life not being a debate team.

    I am not really looking for tiles to create the map perse, I am using them, will use them, for gameplay purposes. The tiles in Civ 6 are a far cry from the ones in Civ 1, but in essence they are both tiles. I am not building an exploratory open world, first or third person kind of game. I am building a Civ type game.

    Using tiles, or tile based, or tile derived, seems appropriate for that. You could call them nodes instead of tiles, because we are not that technology constrained anymore. One could argue that a game like Crusader Kings II has a strong node based component to it's gameplay. Each and every county and water space is a node. With different travel costs and neighbours. Generating such a map, for a Civ type game, that might be interesting.
     
    RavenOfCode, YBtheS and orb like this.
  18. YBtheS

    YBtheS

    Joined:
    Feb 22, 2016
    Posts:
    82
    Are you aware that those are all... opinions?

    I prefer mints to gum. Change my mind :p

    So Hotline Miami should've really been a 3D third person shooter.

    But why? You still have yet to explain that.
     
  19. christoph_r

    christoph_r

    Joined:
    May 20, 2013
    Posts:
    374
    Why not have very simple prototypes for both square & hex tiles, then play around and test what works best with your specific gameplay mechanics?
     
    RavenOfCode and YBtheS like this.
  20. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    12,156
    He was temporarily banned from the forums. If you're expecting a response from him you might have to wait a while.
     
  21. YBtheS

    YBtheS

    Joined:
    Feb 22, 2016
    Posts:
    82
    Oh my... okay then.
     
  22. Reloque

    Reloque

    Joined:
    Apr 28, 2015
    Posts:
    74
    In any case, using Voronoi math to create tiles has proved a bit to much at this moment. I've settled on a Voronoi created world mapped to Hexagons. Now working to get that camera working with that as well. Thanks for the tips and insights.
     
  23. YBtheS

    YBtheS

    Joined:
    Feb 22, 2016
    Posts:
    82
    You mean like visually it looks voronoid but actually uses hexagonal tiles? If so, how does that work? Wouldn't that be confusing for the player?
     
  24. Reloque

    Reloque

    Joined:
    Apr 28, 2015
    Posts:
    74
    No, I mean the world is created based on Voronoi diagrams and that created world is converted to hexagons. Visually it looks like hexes.
     
  25. Owen-Reynolds

    Owen-Reynolds

    Joined:
    Feb 15, 2012
    Posts:
    348
    In the 1980's Avalon Hill made the best, most realistic war board games, like Squad Leader or The Arab-Isreali Wars (playing that game once is like reading 3 books). They all used hexes. Later Metagaming (Steve Jackson) made small, cheap games like Ogre/GEV and Car Wars, also using hexes. Even the fantasy game (Melee, which became GURPs) has 3-hex giants and scary-looking long 7-hex dragons. The rep is that serious war games use hexes. Squares are for total casuals.

    I think that's still true a little -- changing from squares to hexes could attract a more hard-core crowd. But for Settlers of Catan, I think it's just because 6 routes out of each hub seems better.
     
    orb likes this.
  26. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    2,805
    Yeah, hexes are definitely coming back again lately. One of the major self-contained board game releases, Scythe, uses hexes (and My Little Scythe too). Even Games Workshop have made hex-based skirmish games now, and those guys love their rulers.

    I never could get into miniature war games proper because of having to measure movement, but on a computer you don't have to work hard to support free-form movement. Point-baed or distance-based doesn't matter as long as it's internally consistent. Voronoi landscapes with a hexagonal overlay is perfectly fine if you can make it happen - mountains could either be impassable features, or you could tweak the algorithm to make paths. I'd go with flatter landscape if doing hexes though, and make each hex its own little biome.
     
  27. Reloque

    Reloque

    Joined:
    Apr 28, 2015
    Posts:
    74
    Perhaps I could illustrate what I did with a few screenshots, to show the process;

    First, generate an empty hex field, this one is 66 by 42. All tiles are white and empty. Screen Shot 2018-09-14 at 12.42.48.png

    Next, place a number of random point throughout the map, these 'tectonic points' are focal points for the map. The map is build around them. For a map this size, I've done 24 points.
    Screen Shot 2018-09-14 at 12.49.53.png
    Now, do a wrap-around Voronoi diagram of those, ie, for each hexcell mark it with the point it's closes to, looks like this;
    Screen Shot 2018-09-14 at 12.51.16.png Of coures, that shows that not all points are divided equally, so we do a variation of Lloyd's algorithm to average them out. After 3 pases, of that, it looks like this;
    Screen Shot 2018-09-14 at 12.52.39.png
     

    Attached Files:

    Last edited: Sep 14, 2018
  28. Reloque

    Reloque

    Joined:
    Apr 28, 2015
    Posts:
    74
    Then, we consider that all borders between the Voronoi regions should be ocean trenches, and all other tiles should be land. Also, all tiles in the upper North or lower South have chance of becoming ice. The most North and most South are ice. Also, one continent or more are randomly forced to be below sea level. Coming to this;
    Screen Shot 2018-09-14 at 12.55.11.png Now this is starting to look like a map, but seems way to artificial still. The last past is iterating across the coast lines en creating bays and irregular shapes by randomly changing land to water based on the neighbouring water tiles. Also, continents can randomly be turned archipelago style. This leads to this;
    Screen Shot 2018-09-14 at 12.58.49.png
    This particular iteration created a earth like world with a few sizeable continents and lots of small islands. Different map sizes, different number of starting tectonic points or different chances to turn in to water produced other maps. But, all in all I am kind of pleased with how it turned out.
     
  29. Reloque

    Reloque

    Joined:
    Apr 28, 2015
    Posts:
    74
    For instance, this is with 6 tectonic points, leading to a huge continent dominating the map. A slightly smaller but still large continent to the West of it. A somewhat of a South Asian type Ocean littered with islands towards the North and an Australia kinda of placed continent in the Southern hemisphere.
    Screen Shot 2018-09-14 at 13.04.00.png .
     
  30. Owen-Reynolds

    Owen-Reynolds

    Joined:
    Feb 15, 2012
    Posts:
    348
    Ah -- procedural generation is a whole nother topic. Clearly a grid is better for that (tiles or hexes) -- too hard to get the computer to draw something free-form that also looks nice.

    But computer-made maps seem best for quick levels -- an infinite runner stage you'll be through in 20 seconds, or a single dungeon level. Otherwise it's too easy to get an ugly, unfair, boring map; and be stuck with it for way too long.
     
  31. Reloque

    Reloque

    Joined:
    Apr 28, 2015
    Posts:
    74
    Yeah, I suppose the discussion did drift a bit form squares vs. hexes. But, the voronoi thing as basis for fair generation was a useful train of thought I wouldn't have followed otherwise.
     
  32. YBtheS

    YBtheS

    Joined:
    Feb 22, 2016
    Posts:
    82
    That's really cool. It can allow for lots of replayability if you don't have the maps set and allow for them to be randomly generated allowing for new experiences every playthrough.
     
  33. Reloque

    Reloque

    Joined:
    Apr 28, 2015
    Posts:
    74
    YBtheS likes this.
  34. LurkingNinjaDev

    LurkingNinjaDev

    Joined:
    Jan 20, 2015
    Posts:
    635
  35. YBtheS

    YBtheS

    Joined:
    Feb 22, 2016
    Posts:
    82