
aima.core.util.MockRandomizer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aima-core Show documentation
Show all versions of aima-core Show documentation
AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.
package aima.core.util;
/**
* Mock implementation of the Randomizer interface so that the set of Random
* numbers returned are in fact predefined.
*
* @author Ravi Mohan
*
*/
public class MockRandomizer implements Randomizer {
private double[] values;
private int index;
/**
*
* @param values
* the set of predetermined random values to loop over.
*/
public MockRandomizer(double[] values) {
this.values = new double[values.length];
System.arraycopy(values, 0, this.values, 0, values.length);
this.index = 0;
}
//
// START-Randomizer
@Override
public double nextDouble() {
if (index == values.length) {
index = 0;
}
return values[index++];
}
// END-Randomizer
//
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy