Last active
July 18, 2018 13:48
-
-
Save tyhi/fc14e1adbdf559aab7b7ec70bf19fedf to your computer and use it in GitHub Desktop.
Simulate getting 25* on MapleStory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math" | |
"math/rand" | |
"time" | |
"github.com/dustin/go-humanize" | |
) | |
/* | |
This is a simple simulation written in Go for testing the rates to get 25* in MapleStory.true | |
This is based off data from KMS, should be the same for GMS | |
This also assumes doing star catcher above 12* | |
There are some settings you can set below. | |
This could be changed to use more than one thread, however I'm too lazy. | |
*/ | |
var ( | |
/* You are able to change these settings here. */ | |
safeguard = true // if true this will always safe guard below 17* | |
simcount int64 = 100 // how many times to run sim | |
eqpl float64 = 150 // This is the level of the starforced item. | |
/* There are no settings past here. */ | |
csf float64 //this is the current star force level | |
sfhc float64 // this is the current star force attemps | |
cfs float64 // this is the current star force fail stacks | |
fsa bool // if this is true, next attempt will +1 | |
meso float64 // This is how much meso it cost. | |
tra float64 // this is how many time it took to get to 25 | |
sgc bool // this is too keep track | |
totalattamps int64 | |
totalmeso float64 | |
totalbooms float64 | |
currentsim int64 | |
tooLate = make(chan struct{}) | |
) | |
func init() { | |
rand.Seed(time.Now().UTC().UnixNano()) | |
} | |
func main() { | |
csf = 0 | |
go simwatcher() | |
Start: | |
if csf < 0 { | |
csf = 0 | |
} | |
mesocalc() // This will calc the amount of mesos it cost to do this rank. | |
sfhc++ // This will add one attempt | |
if fsa == true { // This will check if the fsa flag is tripped, if true add one starforce. | |
csf++ | |
fsa = false | |
goto Start | |
} | |
switch csf { | |
case 0: | |
chance := random(0, 100) | |
if chance <= 95 { | |
csf++ | |
} else { | |
} | |
case 1: | |
chance := random(0, 100) | |
if chance <= 90 { | |
csf++ | |
} else { | |
} | |
case 2: | |
chance := random(0, 100) | |
if chance <= 85 { | |
csf++ | |
} else { | |
} | |
case 3: | |
chance := random(0, 100) | |
if chance <= 85 { | |
csf++ | |
} else { | |
} | |
case 4: | |
chance := random(0, 100) | |
if chance <= 80 { | |
csf++ | |
} else { | |
} | |
case 5: | |
chance := random(0, 100) | |
if chance <= 75 { | |
csf++ | |
} else { | |
addfailstack() | |
} | |
case 6: | |
chance := random(0, 100) | |
if chance <= 70 { | |
csf++ | |
} else { | |
addfailstack() | |
} | |
case 7: | |
chance := random(0, 100) | |
if chance <= 65 { | |
csf++ | |
} else { | |
addfailstack() | |
} | |
case 8: | |
chance := random(0, 100) | |
if chance <= 60 { | |
csf++ | |
} else { | |
addfailstack() | |
} | |
case 9: | |
chance := random(0, 100) | |
if chance <= 55 { | |
csf++ | |
} else { | |
addfailstack() | |
} | |
case 10: | |
chance := random(0, 100) | |
if chance <= 45 { | |
csf++ | |
} else { | |
addfailstack() | |
} | |
case 11: | |
chance := random(0, 100) | |
if chance <= 35 { | |
csf++ | |
} else { | |
addfailstack() | |
} | |
case 12: | |
chance := random(0, 100) | |
if chance <= 34.5 { | |
csf++ | |
} else { | |
checkboom(0.7) | |
addfailstack() | |
} | |
case 13: | |
chance := random(0, 100) | |
if chance <= 34.5 { | |
csf++ | |
} else { | |
checkboom(1.4) | |
addfailstack() | |
} | |
case 14: | |
chance := random(0, 100) | |
if chance <= 34.5 { | |
csf++ | |
} else { | |
checkboom(1.4) | |
addfailstack() | |
} | |
case 15: | |
chance := random(0, 100) | |
if chance <= 34.5 { | |
csf++ | |
} else { | |
checkboom(2.1) | |
addfailstack() | |
} | |
case 16: | |
chance := random(0, 100) | |
if chance <= 34.5 { | |
csf++ | |
} else { | |
checkboom(2.1) | |
addfailstack() | |
} | |
case 17: | |
chance := random(0, 100) | |
if chance <= 34.5 { | |
csf++ | |
} else { | |
checkboom(2.1) | |
addfailstack() | |
} | |
case 18: | |
chance := random(0, 100) | |
if chance <= 34.5 { | |
csf++ | |
} else { | |
checkboom(2.8) | |
addfailstack() | |
} | |
case 19: | |
chance := random(0, 100) | |
if chance <= 34.5 { | |
csf++ | |
} else { | |
checkboom(2.8) | |
addfailstack() | |
} | |
case 20: | |
chance := random(0, 100) | |
if chance <= 34.5 { | |
csf++ | |
} else { | |
checkboom(7) | |
addfailstack() | |
} | |
case 21: | |
chance := random(0, 100) | |
if chance <= 34.5 { | |
csf++ | |
} else { | |
checkboom(7) | |
addfailstack() | |
} | |
case 22: | |
chance := random(0, 100) | |
if chance <= 7.5 { | |
csf++ | |
} else { | |
checkboom(19.4) | |
addfailstack() | |
} | |
case 23: | |
chance := random(0, 100) | |
if chance <= 6.5 { | |
csf++ | |
} else { | |
checkboom(29.4) | |
addfailstack() | |
} | |
case 24: | |
chance := random(0, 100) | |
if chance <= 5.5 { | |
csf++ | |
} else { | |
checkboom(39.6) | |
addfailstack() | |
} | |
case 25: | |
//fmt.Println("Starforce:", csf, "\nAttempts:", humanize.Commaf(sfhc), "\nMeso cost:", humanize.Commaf(meso), "\nTries taken:", humanize.Commaf(tra)) | |
totalattamps = totalattamps + int64(sfhc) | |
totalbooms = totalbooms + tra | |
totalmeso = totalmeso + meso | |
sfhc = 0 | |
tra = 0 | |
meso = 0 | |
cfs = 0 | |
csf = 0 | |
currentsim++ | |
if currentsim == simcount { | |
time.Sleep(250 * time.Millisecond) | |
close(tooLate) | |
fmt.Println("\rTotal Simulations:", simcount, "\nAverage Attempts:", humanize.Comma(totalattamps/simcount), "\nAverage Mesos:", humanize.Commaf(totalmeso/float64(simcount)), "\nAverage Booms:", humanize.Commaf(totalbooms/float64(simcount))) | |
return | |
} | |
} | |
goto Start | |
} | |
func random(min, max float64) float64 { | |
return min + rand.Float64()*(max-min) | |
} | |
func addfailstack() { | |
// Reduce csf by one | |
csf-- | |
// Add a fail stack | |
cfs++ | |
if csf == 5 && cfs == 2 { | |
cfs++ | |
fsa = true | |
cfs = 0 | |
return | |
} | |
if csf == 5 && cfs != 2 { | |
cfs++ | |
cfs = 0 | |
return | |
} | |
if csf == 15 && cfs == 2 { | |
csf++ | |
fsa = true | |
cfs = 0 | |
return | |
} | |
if csf == 15 && cfs != 2 { | |
csf++ | |
cfs = 0 | |
return | |
} | |
if csf == 20 && cfs == 2 { | |
csf++ | |
fsa = true | |
cfs = 0 | |
return | |
} | |
if csf == 20 && cfs != 2 { | |
csf++ | |
cfs = 0 | |
return | |
} | |
if cfs == 2 { | |
fsa = true | |
cfs = 0 | |
} | |
} | |
func checkboom(percent float64) { | |
chance := random(0, 100) | |
if chance <= percent { | |
//fmt.Println("Boomed at:", csf, "\nAttempts:", sfhc, "\nMeso Spent:", humanize.Commaf(meso)) | |
if csf == 13 || csf == 14 || csf == 15 || csf == 16 || csf == 17 && safeguard == true { | |
sgc = true | |
return | |
} | |
csf = 0 | |
tra++ | |
return | |
} | |
} | |
func mesocalc() { | |
if sgc == true { | |
meso = meso + math.Round(2*(1000+(math.Pow(eqpl, 3))*math.Pow((csf+1), 2.6)/200)) | |
sgc = false | |
} | |
if csf > 14 { | |
meso = meso + math.Round((1000 + (math.Pow(eqpl, 3))*math.Pow((csf+1), 2.6)/200)) | |
return | |
} | |
if csf < 9 { | |
meso = meso + math.Round((1000 + (math.Pow(eqpl, 3))*(csf+1)/25)) | |
return | |
} | |
if csf > 9 { | |
meso = meso + math.Round((1000 + (math.Pow(eqpl, 3))*math.Pow((csf+1), 2.6)/400)) | |
return | |
} | |
} | |
func simwatcher() { | |
for { | |
fmt.Printf("\r%d/%d", currentsim, simcount) | |
time.Sleep(250 * time.Millisecond) | |
select { | |
case <-tooLate: | |
return | |
default: // adding default will make it not block | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment