Skip to content

Instantly share code, notes, and snippets.

@akira093
Created November 3, 2014 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akira093/66b3c6e711ed8ce4b602 to your computer and use it in GitHub Desktop.
Save akira093/66b3c6e711ed8ce4b602 to your computer and use it in GitHub Desktop.
package main
import (
"code.google.com/p/plotinum/plot"
"code.google.com/p/plotinum/plotter"
"code.google.com/p/plotinum/plotutil"
"code.google.com/p/plotinum/vg"
"fmt"
"math"
)
var coefficient = map[string]float64{
"A": 0.5, //潜水艦
"B": 1.0, //駆逐艦・軽巡洋艦・重雷装巡洋艦・水上機母艦・潜水空母・揚陸艦
"C": 1.5, //重巡洋艦・航空巡洋艦・金剛型戦艦・軽空母・潜水母艦
"D": 2.0, //戦艦・航空戦艦・正規空母・装甲空母・工作艦
}
func dockTime(class string, lv, hp int) float64 {
if lv < 12 {
return float64(lv*10*hp)*coefficient[class] + 30
} else {
a := func(lv int) int {
return int(math.Sqrt(float64(lv-11)))*10 + 50
}
return float64((lv*5+a(lv))*hp)*coefficient[class] + 30
}
}
func dockTimes(class string) plotter.XYs {
pts := make(plotter.XYs, 30)
for i := range pts {
pts[i].X = float64(i*5 + 1)
pts[i].Y = dockTime(class, i*5+1, 1)
}
return pts
}
func tickFor50(min, max float64) []plot.Tick {
var tks []plot.Tick
for i := float64(0); i < 151; i += 10 {
if int(i)%50 == 0 {
tks = append(tks, plot.Tick{i, fmt.Sprint(i)})
} else {
tks = append(tks, plot.Tick{i, ""})
}
}
return tks
}
func main() {
p, err := plot.New()
if err != nil {
panic(err)
}
p.Title.Text = "Dock Time for Kan Colle"
p.X.Label.Text = "lv"
p.X.Max = 150.1
p.X.Min = -0.1
p.X.Tick.Marker = tickFor50
p.Y.Label.Text = "second / hp"
p.Add(plotter.NewGrid())
a, err := plotter.NewScatter(dockTimes("A"))
a.Color = plotutil.Color(1)
a.Radius = vg.Length(3.5)
b, err := plotter.NewScatter(dockTimes("B"))
b.Color = plotutil.Color(2)
b.Radius = vg.Length(3.5)
c, err := plotter.NewScatter(dockTimes("C"))
c.Color = plotutil.Color(3)
c.Radius = vg.Length(3.5)
d, err := plotter.NewScatter(dockTimes("D"))
d.Color = plotutil.Color(4)
d.Radius = vg.Length(3.5)
p.Add(a, b, c, d)
p.Legend.Add("Submarine", a)
p.Legend.Add("DD, Light CL, etc", b)
p.Legend.Add("Heavy CL, Light Carrier etc", c)
p.Legend.Add("BS, Carrier, etc", d)
if err := p.Save(8, 6, "res.png"); err != nil {
panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment