Ex­po­nen­tial Idle Guides

Day 4: Fibon­acci Foil, and a Mile­stone

Guide writ­ten by Minh Tea (prop). Con­tri­bu­tions from the Amaz­ing Com­munity.

Feel free to use the gloss­ary as needed.

Top of the moon­ing. It is dawn of the fourth day.

I know you can­not sleep. Across the win­dow, the wind is howl­ing at all the dry­ing lines strewn across the al­ley­way, hung between two ped­es­trian houses. A cricket chirps un­der the speckled in­digo sky. There is no moon for you to see to­night. In­stead, you see vari­ous clouds peek­ing over the ho­ri­zon, flow­ing sharply like blades of grass. Wait, is­n’t that the Ex­po­nen­tial Idle graph?

You wake up from your sleep. You have to find out who did this to your the­ory. Only then could you re­sume power­ing up its pro­gres­sion us­ing a new tool, called mile­stones.

▶︎ Find­ing the cul­prit

's value re­trieval func­tion has at least 3 lines: the level 0 case, the level 1 case, and the gen­eral case. But wait! In the gen­eral case, the func­tion calls it­self at a lower level! This is called , and while it’s a use­ful tac­tic in pro­gram­ming, we can’t ig­nore the ef­fect on per­form­ance if we are re­curs­ing more than once, like we do here. Each func­tion call spawns up to two smal­ler func­tion calls, which means the total num­ber of calls very much ex­ceeds the 3 lines we see… In fact, the higher the level, the num­ber of func­tion calls per­formed grows ex­po­nen­tially? Ac­tu­ally, it is pro­por­tional to the Fibon­acci num­bers them­selves! This is not good. 's level will show as ‘Level: x/​20’. But, is this a good meas­ure? While it may ease the prob­lem some­what, it is still present, and… Would you want to play a game about the Fibon­acci se­quence, if the Fibon­acci se­quence just stops sud­denly at some point?

▶︎ Stop­ping Fibon­ac­ci’s foil

▶︎ A size­able tan­gent

and , as well as the are be­ing clipped. Let’s try to fix that with :

▶︎ Con­tinu­ing with pro­gres­sion

▶︎ Power up with a mile­stone

. Start by map­ping out where mile­stone points are re­war­ded: scale. In this case, where the first point is re­war­ded cor­res­ponds not to 15 tau, but , and the next points’ costs will be mul­tiply by each, start­ing at , , etc. every level, up to 5 levels. For the de­scrip­tion and in­form­a­tion, we use the class to get the strings suit­able for this mile­stone (‘In­creases {0} ex­po­nent by {1}’), and as these strings do not need to be re­freshed, in­stead of as­sign­ing them to and , we as­sign them to and . When we put a point into the mile­stone or take away from it, we should also up­date the primary equa­tion manu­ally with to re­flect the in­form­a­tion shown on screen. But what in­form­a­tion? We haven’t even im­ple­men­ted the power in­crease: 's ex­po­nent is at 1), since dis­play­ing a power of 1 is re­dund­ant. 's ex­po­nent on screen. 's value after the mile­stone when the but­ton is pressed. To do this, let’s modify its : 's ex­po­nent and its value after the mile­stone is ap­plied.

▶︎ Af­ter­math