joffrey-bion / idle-planet-miner-helper

MIT License
3 stars 0 forks source link

Idle Planet Miner helper

This project is a WIP, please don't try to use it yet.

The goal of this project is to help choosing the most optimal steps in the Idle Planet Miner game.

The algorithm will choose the "best" next step depending on its return on investment (ROI). The ROI depends on the state of the galaxy, which includes all aspects of the game, from long-term bonuses, to Galaxy-specific bonuses.

Input

In order for the algorithm to give relevant results, the whole current state of the galaxy needs to be given as input:

Also some "configuration" inputs are necessary:

Algorithm

  1. define a set of possible actions from the current state:
    • buy an unlocked planet
    • upgrade a planet's mine (only for bought planets)
    • upgrade a planet's ship (only for bought planets)
    • upgrade a planet's cargo (only for bought planets)
    • research an unlocked project (only if resource constraints are met - see dedicated section below)
    • unlock the next smelting recipe (only if the SMELTER project is unlocked)
    • unlock the next crafting recipe (only if the CRAFTER project is unlocked)
    • build a new smelter (only if the SMELTER project is unlocked)
    • build a new crafter (only if the CRAFTER project is unlocked)
  2. for each available action:
    • calculate its cost in money/resources and the equivalent time it takes
      • if it requires cash
        • compute the time to get that money based on the current income rate
      • if it requires resources
        • compute the time it takes to smelt/craft all the resources (recursively)
          • it is roughly ore gathering time + max(craft time, smelt time) (because they run in parallel)
          • each of craft time and smelt time can be roughly divided by the number of smelters/crafters available
          • accurate calculation of this may not be necessary, estimates will be easier to implement
    • compute the galaxy's state if the action is taken (if this step turns out to be slow -which is yet to be shown-, the states can be cached because the action order doesn't affect the resulting galaxy)
      • cash income is calculated by converting the total ore production into money using the current market
    • compute the difference between the current galaxy's income and the target galaxy's income
      • find the time at which we get back the investment made (ROI=1 time) from the difference alone (remember to add the time taken to perform the actions)
      • note that the diff may be 0 (in case the action just unlocks something without improving revenue directly), hence the need for considering more actions from here (even for non-0 diffs, because combined actions can yield more)
      • recursively search further states by exploring more actions (up to the given max DEPTH)
      • sum the cost & time of all of the steps along the way (this does depend on the actions' order)
  3. for each of the explored states (even intermediate ones), select the one with earliest "ROI=1" time (as "next" state)
  4. compact the action sequence to reach that state (upgrade a level multiple times can be done as a single action)
  5. output the compacted actions to take
  6. set the current state to that next state
  7. repeat N_STEPS times (given as parameter)

Things to consider:

About resource constraints

Some actions require resources, like researching projects or colonizing a planet. The algorithm does not track stocks for these products, but there are still a bunch of constraints that can rule out these actions for the search: