Ex­po­nen­tial Idle Guides

Ap­pendix A: Sim­u­lat­ing a The­ory

Guide writ­ten by prop. Con­tri­bu­tions from Mathis for the draft, and then the Amaz­ing Com­munity.

Feel free to use the gloss­ary as needed.

Hello. Wel­come to the evol­u­tion­ary rem­nants of my stom­ach for this week.

Today, we are go­ing to use the The­ory Sim­u­lator to test out our the­ory. The The­ory Sim­u­lator is a web-based tool cre­ated and main­tained by the Ex­po­nen­tial Idle com­munity that al­lows users to sim­u­late and pro­gram strategies for vari­ous the­or­ies.

Note: The The­ory Sim­u­lator is un­der­go­ing con­stant changes. As such, this ap­pendix’s con­tents are also un­der con­struc­tion.

Pre­requis­ites #

  1. Node.js & npm

Node.js is a JavaS­cript runtime en­vir­on­ment for serv­ers and web ap­plic­a­tions. Its in­stall­a­tion is needed to run the sim­u­lator loc­ally and im­ple­ment our the­ory.

npm is the pack­age man­ager for Node.js. It should be already in­stalled along with Node.js.

  1. TypeScript

TypeScript is a vari­ant of JavaS­cript that en­forces types on vari­ables to pre­vent bugs re­lated to type mis­match or con­ver­sion. It is avail­able as an npm pack­age.

For a bet­ter ex­per­i­ence, in­stall the TypeScript ex­ten­sion/​add-on (if avail­able) for your ed­itor.

In­stall­a­tion #

Head to your com­mand line in­ter­face (ter­minal), head to the de­sired dir­ect­ory us­ing cd or a sim­ilar com­mand, then type in this line:

git clone https://github.com/exponential-developers/sim-3.0.git

This will down­load the The­ory Sim­u­lator for local us­age. If git is not in­stalled, you can also visit the re­pos­it­ory, press the Code but­ton, then down­load it as a ZIP file.

After the down­load is fin­ished, head into the folder with your ter­minal. Open the folder in your ed­itor as a pro­ject, in case that fea­ture is sup­por­ted. Then, after check­ing that the ter­minal is at the pro­ject folder, run these com­mands in suc­ces­sion:

npm install
npm audit fix
npm run build

The first com­mand in­stalls the needed pack­ages for the pro­ject. The second com­mand fixes vari­ous is­sues after in­stalling them. Fi­nally, the third com­mand builds the pro­ject.

Host­ing the sim­u­lator #

We’ve man­aged to build the pro­ject. However, as it is a web ap­plic­a­tion, to be able to run it, we need a way to host a server loc­ally. We can use an npm pack­age for this:

npm install -g http-server

The -g op­tion will in­stall the http-server pack­age glob­ally on our ma­chine, so that re­gard­less of what pro­ject we’re work­ing on, we can host a server. To do so, use this simple com­mand (while the ter­minal is at the pro­ject folder, of course):

http-server

Upon us­ing this com­mand, one or more links will be out­put. Simply copy this link onto a browser to open the The­ory Sim­u­lator. The first thing to do after it’s opened is to open the set­tings menu (cog icon), then tick on the op­tion ‘Show un­of­fi­cial CTs’. This will al­low us to sim­u­late un­of­fi­cial cus­tom the­or­ies, in­clud­ing our the­ory, after we have im­ple­men­ted it.

Im­ple­ment­ing a the­ory #

All con­tents be­low are work in pro­gress.

In­tro­duc­tion to the num­ber sys­tem used by the sim #

In the sim, there is no BigNum­ber class. In­stead, to rep­res­ent large num­bers such as 1e800, we work with log val­ues.
For ex­ample, 1e800 will be rep­res­en­ted as 800, and 2e25 will be rep­res­en­ted as lo­g10(2e25) = 25 + lo­g10(2). 1 is rep­res­en­ted as 0.
Since we work with log val­ues, you may use + for mul­ti­plic­a­tion and * to raise to a power.
For ad­di­tion and sub­trac­tion, the sim has the func­tions add(a, b)for a+b and sub­tract(a, b) for a-b.
Since you may need to use Math.lo­g10 many times, it is shortened to l10.
It is im­port­ant to keep track of what value is a nor­mal value and what value is a log value.

Re­gister your the­ory and its strats #

First, you need to edit src/​Data/​data.json to add your new the­ory.
You need to add a new key in the­or­ies, named with the ini­tials of your CT, with the same model as other the­or­ies.
Here is what each item does:

Cre­ate the sim file #

To add your new cus­tom the­ory to the sim, you need to cre­ate a .ts sim file for it. It should use the CT’s ini­tials. For ex­ample: FS.ts.
It should be put in src/​The­or­ies/​Un­of­fi­cial-CTs. I sug­gest to copy BT.ts to get a tem­plate.
Now it’s time to edit this file to im­ple­ment your CT.

In the sim class, you may add at­trib­utes for any­thing the sim may need, like q for ex­ample.

You fill find sev­eral meth­ods in the class. Here is what they are for and how should you edit them.

De­fault at­trib­utes of the sim class #

There are the main de­fault at­trib­utes of the sim class you want to know about.

The con­structor #

The role of the con­structor is to ini­tial­ize the at­trib­utes of the sim class.

The main part you need to change is the de­clar­a­tion of the vari­ables and vari­able names.

The sim has a Vari­able class to handle up­grades. Each vari­able is ini­tial­ized with a cost and a val­ueS­cal­ing.
The sim provides easy-to-use classes for the main cost and value mod­els. The val­ues you pass in them should­n’t be logged.

Im­port­ant no­tice for Ex­po­nen­tial Cost:

get­Buy­ing­Con­di­tions() #

This func­tion re­turns the con­di­tions that must be met for the sim to buy vari­ables.
con­di­tions must have a key for every strat you defined in data.json.
To each strat is as­so­ci­ated an ar­ray of con­di­tions for each vari­able.

Con­di­tions can be a boolean or a func­tion that re­turns a boolean. Use the lat­ter if you want a dy­namic con­di­tion.

If you want a full idle strat, you can fill the ar­ray with true.

get­Mile­stone­Con­di­tions() #

This func­tion re­turns whether a vari­able is avail­able to pur­chase or not, de­pend­ing on mile­stones for ex­ample.
Same as get­Buy­ing­Con­di­tions, con­di­tions can be a boolean or a func­tion that re­turns a boolean.
It does not de­pend on the strat.

getTot­Mult() #

This func­tion should re­turn the pub­lic­a­tion mul­ti­plier as a log value. It is the equi­val­ent of get­Pub­lic­a­tion­Mul­ti­plier in the CT code.

up­dateMile­stones() #

This func­tion should up­date this.mile­stones to match the mile­stones a player would have at this point.

sim­u­late() #

This func­tion con­tains the sim­u­la­tion loop and the pub­lic­a­tion con­di­tions.
You don’t need to edit it un­less you want to change the pub­lic­a­tion con­di­tions.

tick() #

This is the equi­val­ent of the tick() func­tion of the CT. Only edit the part be­fore this.t += this.dt / 1.5.

buyVari­ables() #

This func­tion makes the sim buy vari­ables.
You don’t need to edit it un­less you are work­ing with mul­tiples cur­ren­cies or need to do cer­tain ac­tions when a vari­able is bought.

Re­gis­ter­ing the sim file #

Now that your sim file is ready, go to src/​Sim/​main.ts.

Add a new im­port to im­port the ex­port func­tion of your sim file.

Now, find the singleSim func­tion and add a new case in the switch state­ment fol­low­ing the same model as other the­or­ies.

The sim should now have your CT cor­rectly re­gistered.

Com­pile and test #

Any time you want to test your changes, com­pile by run­ning npm run build.