func (cmd *ChainReaction) SpawnLevel() { // First resize the num active trigger for the level l := cmd.Levels[cmd.ActiveLevel] cmd.Triggers = cmd.Triggers[0:l.TotalTriggers] cmd.NumExploded = 0 cmd.NumExploding = 0 cmd.GameState = GS_Start cmd.StateChangeTime = time.Nanoseconds() // Spawn triggers in this level for i := 0; i < l.TotalTriggers; i++ { rx := ((rand.Float()-0.01)*2.0 - 1.0) ry := ((rand.Float()-0.01)*2.0 - 1.0) p := &Vector3{Real(rx * PlayArea), Real(ry * PlayArea), -5.0} rx = rand.Float() - 0.5 ry = rand.Float() - 0.5 v := &Vector3{Real(rx), Real(ry), 0.0} v.Normalize().ImulScale(0.02) c := TriggerColors[i%5] cmd.Triggers[i] = trigger{TS_Trig, 0.0, 0.05, *p, *v, c, 0.0, 0} } }
func main() { flag_help := flag.Bool("help", false, "display this help") flag_size := flag.Int("size", 1000, "number of points") flag_k := flag.Float("k", 4.0, "slope of linear function kx + b") flag_b := flag.Float("b", 3.0, "y-intercept of linear function kx + b") flag_width := flag.Float("width", 10.0, "width of each class") flag_d := flag.Float("distance", 5.0, `distance to linear separator. If negative then there isn't separable without errors (two classes are intersept).`) flag_xstart := flag.Float("xstart", -25.0, "x lower bound") flag_xend := flag.Float("xend", 25.0, "x upper bound") flag.Parse() if *flag_help { flag.PrintDefaults() return } size := *flag_size k, b := *flag_k, *flag_b width, d := *flag_width, *flag_d xstart, xend := *flag_xstart, *flag_xend for i := 0; i < size/2; i++ { x := rand.Float()*(xend-xstart) + xstart y := x*k + b + rand.Float()*width + d t := -1.0 fmt.Printf("%v\t%v\t%v\t\n", t, x, y) } for i := size / 2; i < size; i++ { x := rand.Float()*(xend-xstart) + xstart y := x*k + b - rand.Float()*width - d t := 1.0 fmt.Printf("%v\t%v\t%v\t\n", t, x, y) } return }
func (p *LifeGame) Init(row, col int) *LifeGame { //rand.Seed(0) p.row = row p.col = col p.board = make([][]bool, row) for r := 0; r < row; r++ { p.board[r] = make([]bool, col) for c := 0; c < col; c++ { if rand.Float() < 0.3 { p.board[r][c] = true } } } p.time = 0 return p }
func (p *testphyspower) Use() { if MainWorld.InCombat() { a := MainWorld.GetSingleArena() c, ok1 := a.GetCombattant(0) t, ok2 := a.GetCombattant(1) if ok1 && ok2 && c != nil && t != nil { if c.GetSleepRemaining() > t.GetSleepRemaining() { c, t = t, c } if c.GetHp() > 0 { dmg := float(c.GetPhysicalDMG(p.power, t)) * c.GetSTAB(p.elemType) * (0.85 + 0.15*rand.Float()) t.DealDamage(int(dmg), p.elemType) c.SetSleepTime(a, int64(p.cooldown*1e9)) } } } else if MainWorld.InField() { } }