Advertisement
SpiritFryer

Untitled

Jun 28th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.76 KB | None | 0 0
  1. Hello,
  2. I'm trying to figure out optimal round 1 openings for this game: http://generals.io/
  3.  
  4. For the purposes of this, I've simplified some of the rules and mechanics of the game, and I assume that there are no opponents.
  5.  
  6. Here are the basic rules/mechanics/assumptions:
  7. - The game is played on a board of size `m * n`, `16 <= m, n <= 20`.
  8. - A tile on the board can be one of:
  9. - City: You start the game owning 1 City, containing 1 Unit. The City generates 1 Unit every 2 turns (on even-numbered turns). For the purposes of this, assume that there are no other Cities on the board.
  10. - Land: You can occupy a Land tile by moving at least 1 Unit onto it.
  11. - Mountain: Impassable tile.
  12. - Assume that about a third of the tiles are Mountains at random locations, but all Lands are orthogonally connected to at least one Land or City (and so are reachable).
  13. - Every turn, you can do one of two actions:
  14. - Idle: You do nothing on this turn.
  15. - Move: You choose a tile where you have at least 2 Units. You then choose an orthogonally adjacent tile, which cannot be a Mountain, to move the Units to. All but 1 of the Units will be transferred to this new tile. You can only issue one Move action on each turn.
  16.  
  17. Each round consists of 50 turns. At the start of each round, all Lands generate 1 Unit.
  18.  
  19. Since our City generates 1 Unit every 2 turns, by turn 48 it will have generated 24 Units. So the theoretical maximum number of Lands that could be occupied by turn 50 is 24.
  20.  
  21. **And so, the goal is to figure out an approach that can be used to find a set of actions (or whether any even exist) that would allow us to occupy 24 Lands by turn 50, given a starting configuration of the game board.** Ideally this would be an approach that a human could quickly use to calculate what the actions have to be, since the game is played in semi-realtime (each turn lasts about 1 second, during which you can issue a Move action or not do anything and just Idle).
  22.  
  23. ---
  24.  
  25. I was trying to write myself a "cheatsheet" to achieve the above. Here's what I have so far:
  26. Basic observations:
  27. - In order to have 24 Lands by turn 50, we must have spent 24 of the 50 turns Moving units onto unoccupied Lands.
  28. - Therefore, we have 26 turns left that we can use to either Idle or Move units onto occupied Lands.
  29. - Knowing this, we could generate some "action plans" and see if one of them fits our game board starting configuration.
  30.  
  31. Here's the template/strategy that these "action plans" follow:
  32. - Begin by idling for `I` turns, `I <= 26, I divisble by 2`. (`I divisible by 2` as the purpose of Idling at the start is to build up a sizeable number of Units in your City before Moving out with them to occupy Lands in a chain.)
  33. - You will now have `floor(I / 2) + 1` Units in your City. Move out with these Units and occupy `floor(I / 2)` Lands over the next `floor(I / 2)` turns.
  34. - Since you've idled for `I` turns, you now only have `26 - I` turns left during which you can Idle or Move over occupied lands. The rest of the turns must all be used to Move over (and so occupy) unoccupied Lands. The "action plan" lists the permutations in which you could utilize these `26 - I` turns, given `I`.
  35.  
  36. So here are some explained "action plan" examples of the easiest cases, that seem to allow one to find a solution for quite a few starting board configuartions. Once one is familiar with how these work, more concise/readable versions can be utilized as a "cheatsheet".
  37. `I##` = "Idle". Idle for `##` turns.
  38. `M##` = "Move". Move all (but 1) Units (from your City) over `##` occupied Lands, over the next `##` turns.
  39. `O##` = "Occupy". Move all (but 1) Units (from your City or from an occupied Land) over `##` unoccupied Lands (thereby occupying them), over the next `##` turns.
  40. `@##` = One of the above three actions will prefix this `@##` notation. Here, `##` indicates the turn at which you start executing the prefixed action.
  41.  
  42. I = 26: You Idle for 26 turns, and thereafter you cannot Idle or Move over occupied Lands.
  43. - I26@0, O13@26, O6@39, O3@45, O2@48.
  44. - This plan requires your City to be adjacent to 4 separate Land chains, of minimum lengths of 13, 6, 3 and 2.
  45. - It is easy enough to manually identify whether your starting City location satisfies the above.
  46.  
  47. I = 24: You Idle for 24 turns, and thereafter you have the following set of options for your last 2 `I`|`M` actions:
  48. - {{2}, {1, 1}}. (Meaning you could either do 2x `I1`|`M1` actions, or 1x `I2`|`M2` action.)
  49. - I've found that in general, one will rarely Idle after the initial long Idling phase. Mostly the above options would be used for `M` actions.
  50. - So one possible way of playing out this plan would be: I24@0, O12@24, O6@36, M1@42, O3@43, M1@46, O2@47, O1@49.
  51. - This plan could be used to get 24 Lands if your City spawns with one orthogonal side blocked by a Mountain, for instance. The other three sides would need to have the following separate chains of Lands: 13, 6, 1, 3 connected to the 13 or 6 chain at a distance of 1 from the City, and 2 connected to the 13 or 6 chain at a distance of 1 from the City.
  52.  
  53. Here is the concise "cheatsheet" version I've been using:
  54. - I24:
  55. - {2}
  56. - {1, 1}
  57. - I22
  58. - {4}
  59. - {3, 1}
  60. - {2, 2}
  61. - {2, 1, 1}
  62. - {1, 1, 1, 1}
  63. - I20:
  64. - {6}
  65. - {5, 1}
  66. - {4, 2}
  67. - {4, 1, 1}
  68. - {3, 3}
  69. - {3, 2, 1}
  70. - {3, 1, 1, 1}
  71. - {2, 2, 2}
  72. - {2, 2, 1, 1}
  73. - {2, 1, 1, 1, 1}
  74. - {1, 1, 1, 1, 1, 1}
  75.  
  76. Before explaining my approach at using the cheatsheet, there's another important observation:
  77. - In order to have occupied 24 Lands by turn 50, the Unit that is generated by the City on turn 48 must Move to occupy a new Land. It only has 2 turns to do so. I assume that by this point, all 26 non-Occupy turns have been used. And so, both of these turns would be used for new Land Occupation (using the Units generated on turns 46 and 48).
  78. - This requires that at turn 48 your City would still have either an adjacent size 2 unoccupied Land chain or two separate adjacent (to the City) unoccupied Lands.
  79. - This helps narrow down the possiblities I look at in using the cheatsheet.
  80.  
  81. So, here is how I use the cheatsheet (keep in mind that all of the below has to be planned out within ~20 seconds):
  82. - I identify the 2 Lands I will Occupy using the Units generated on turns 46 and 48. (As mentioned above, these 2 Land tiles have to either be in a chain adjacent to the City, or be both separately adjacent to the City.)
  83. - These 2 Land tiles cannot be occupied before turn 46, narrowing down our occupation paths at the start.
  84. - I then identify the path that the initial (biggest) set of Units will take. Primarily, I try to choose a path that can scout towards the center of the board, without blocking potential future occupation paths.
  85. - For the remainder of the occupation paths, I repeat the following:
  86. - I note the minimum number of occupied Lands that Units would have to Move through from the City in order to occupy a new Land chain.
  87. - Using the above, I plan out a simple path that would obstruct further occupation paths as little as possible.
  88. - Finally, I check the cheatsheet for a set of Move counts that satisfy the list of "minimum number of occupied Lands to move through".
  89. - If I find a matching set, then by following its initial Idle time, I should be able to execute the plan I made and get 24 Lands by turn 50.
  90. - If I don't find an exactly matching set, I will try to find one that matches the list as much as possible, and go with that one. That should probably still give me a good, albeit not optimal result.
  91.  
  92. I realize that some of the options on the cheatsheet are fairly useless (such as `I20: {1, 1, 1, 1, 1, 1}`) and that the list of possible permutations would start to get too large for human use for smaller initial Idle lengths. This is why I am asking this question, in hopes of learning of a better method.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement