Ejemplo n.º 1
0
func ordered(db *db.DB, a *assignment.Assignment) (l *cnf.Lit) {
	// find the first in-order unassigned literal
	for i := uint(1); i <= a.Len(); i++ {
		if p, _ := a.Get(i); p == guess.Unassigned {
			return &cnf.Lit{i, cnf.Pos}
		}
	}
	return &cnf.Lit{0, 0}
}
Ejemplo n.º 2
0
func random(db *db.DB, a *assignment.Assignment) (l *cnf.Lit) {
	sign := byte((rand.Int() % 2) + 1)
	val := uint((rand.Int() % int(a.Len())) + 1)
	for i := val; i <= a.Len(); i++ {
		if v, _ := a.Get(i); v == guess.Unassigned {
			return &cnf.Lit{i, sign}
		}
	}
	for i := uint(1); i < val; i++ {
		if v, _ := a.Get(i); v == guess.Unassigned {
			return &cnf.Lit{i, sign}
		}
	}
	return &cnf.Lit{0, 0}
}