Example #1
0
func BenchmarkMonteFull(b *testing.B) {
	rng := rand.New(rand.NewSource(1))

	start := torus.Location(136)
	l := start
	n := 0
	tn := 0
	s := 0
	for i := 0; i < b.N*NMonte; i++ {
		s++
		var d maps.Direction
		for _, d = range maps.Permute5(rng) {
			if d == maps.NoMovement {
				break
			} else if nl := M.LocStep[l][d]; maps.StepableItem[M.Grid[nl]] {
				l = nl
				break
			}
		}
		if l == 0 {
			l = start
			n++
			tn += s
			s = 0
		}
	}
	if arenachatty {
		log.Printf("mean steps to exit %.2f", float64(tn)/float64(n))
	}
}
Example #2
0
func BenchmarkMonte(b *testing.B) {
	rng := rand.New(rand.NewSource(1))

	start := ALoc(40)
	l := start
	n := 0
	tn := 0
	s := 0
	for i := 0; i < b.N*NMonte; i++ {
		var d maps.Direction
		for _, d = range maps.Permute5(rng) {
			s++
			if d == maps.NoMovement {
				break
			} else if nl := A.LocStep[l][d]; maps.StepableItem[A.Grid[nl]] {
				l = nl
				break
			}
		}
		if l == 0 {
			l = start
			n++
			tn += s
			s = 0
		}
	}
	if arenachatty {
		log.Printf("mean steps to exit %.2f exited %d Steps %d %d", float64(tn)/float64(n), n, tn, b.N)
	}
}