Cookie Clicker is a popular browser game in which the player has to click a cookie to gain... Cookies!
The player can buy upgrades which will automatically farm cookies for you. Sometimes a golden cookie will enter the screen, which will provide a bonus upon clicking it.
This challenge will not be about clicking a cookie. It will be about automating the cookie.
The player starts off with 0 cookies, and will gain cookies on every game tick. The goal of the challenge is to calculate the amount of ticks it takes to reach a certain amount of cookies.
Your program or function will have 2 input parameters.
The first parameter is the goal, which is simply the amount of cookies you need to finish.
The second parameter is a list of upgrades the player can buy. The format of the list will be explained in further detail in the paragraph Upgrades - List format.
For sake of convenience, you may assume that the input is always in the correct format. You don't have to deal with bad input.
Your program or function should print or return the amount of ticks it takes before the player has reached the goal amount of cookies.
Every game-tick will earn the player some cookies. These are based on the upgrades of the player. If a player has no upgrades, the cookie production will be 1 cookie per tick. Once the player reaches enough cookies to buy an upgrade, he will automatically purchase it (before the next tick happens).
When the player has enough cookies after a tick to buy multiple upgrades, he will attempt to buy all possible upgrades, starting with the cheapest.
[[100, '+', 1],[1000, '*', 2],[10000, '*', 10]
This is an unordered list which contains 3 upgrades. The first parameter of an upgrade is the price of the upgrade. The second parameter is the effect of the upgrade and the third parameter is the effect amount.
The input list will contain no upgrades with the same price.
The only possible effects are
+ (addition) and
[100, '+', 1] means that the cookie production will increase by 1 at a cost of 100 cookies.
Every 1000 ticks, the player will find a golden cookie. When this happens, the player will receive a bonus of 10% (rounded down) of his cookie amount. If the player has 1000 cookies at tick 1000, he will have 1100 cookies before tick 1001 happens.
Order of events
After every tick a couple of actions can occur.
- If the player has enough cookies, end the game
- If the player has enough cookies, purchase upgrades
- If the amount of ticks is a multiple of 1000; Golden cookie
Example input + output
(0 , ) -> 0 (100 , ) -> 100 (1 , [[10, '+', 1]]) -> 1 (10 , [[10, '+', 1]]) -> 10 (1000 , [[100, '*', 2], [10, '+', 1]]) -> 310 (10000, [[10, '+', 1], [100, '*', 2]]) -> 2263
(1000 , [[100, '*', 2], [10, '+', 1]]) -> 310 ticks: 8, cookies: 8, production: 1 ticks: 9, cookies: 9, production: 1 ticks: 10, cookies: 0, production: 2 ticks: 11, cookies: 2, production: 2 ticks: 58, cookies: 96, production: 2 ticks: 59, cookies: 98, production: 2 ticks: 60, cookies: 0, production: 4 ticks: 61, cookies: 4, production: 4 ticks: 70, cookies: 40, production: 4 ticks: 80, cookies: 80, production: 4 ticks: 260, cookies: 800, production: 4 ticks: 280, cookies: 880, production: 4 ticks: 300, cookies: 960, production: 4 ticks: 309, cookies: 996, production: 4 ticks: 310, cookies: 1000, production: 4 -- done
I will not be held responsible for any addictions caused by this challenge.