Exemple #1
0
func (s *State) Reset(initialBugCount int) {
	s.BugList = list.New()

	for i := 0; i < s.GridWidth; i++ {
		for j := 0; j < s.GridHeight; j++ {
			s.BugGrid[i][j] = nil
		}
	}

	s.BugTree = rtreego.NewTree(2, 25, 50)

	for i := 0; i < initialBugCount; i++ {
		x := rand.Intn(s.GridWidth)
		y := rand.Intn(s.GridHeight)
		b := NewRandomBug(x, y)
		s.PlaceNewBug(b, Pos{x, y})
	}
}
Exemple #2
0
func NewState(gridWidth, gridHeight int) *State {
	bl := list.New()

	bg := make([][]*Bug, gridWidth)
	for i, _ := range bg {
		bg[i] = make([]*Bug, gridHeight)
	}

	bt := rtreego.NewTree(2, 25, 50)

	return &State{
		BugList:    bl,
		BugGrid:    bg,
		BugTree:    bt,
		GridWidth:  gridWidth,
		GridHeight: gridHeight,
	}
}