本文整理汇总了Java中ec.util.MersenneTwisterFast.nextBoolean方法的典型用法代码示例。如果您正苦于以下问题:Java MersenneTwisterFast.nextBoolean方法的具体用法?Java MersenneTwisterFast.nextBoolean怎么用?Java MersenneTwisterFast.nextBoolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ec.util.MersenneTwisterFast
的用法示例。
在下文中一共展示了MersenneTwisterFast.nextBoolean方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DEFAULT_RANDOM_STEP
import ec.util.MersenneTwisterFast; //导入方法依赖的package包/类
final public static RandomStep<SeaTile> DEFAULT_RANDOM_STEP(int maxStep,int attempts){
return new RandomStep<SeaTile>() {
@Override
public SeaTile randomStep(
FishState state, MersenneTwisterFast random, Fisher fisher, SeaTile current)
{
for(int i=0; i<attempts; i++)
{
int x = current.getGridX() + (random.nextBoolean() ? random.nextInt(maxStep+1) : -random.nextInt(maxStep+1));
int y = current.getGridY() + (random.nextBoolean() ? random.nextInt(maxStep+1) : -random.nextInt(maxStep+1));
SeaTile candidate = state.getMap().getSeaTile(x,y);
if(candidate!=null && current!= candidate && candidate.getAltitude()<0
&&!fisher.getHomePort().getLocation().equals(candidate) )
return candidate;
}
//stay where you are
return current;
}
};
}
示例2: shouldFisherLeavePort
import ec.util.MersenneTwisterFast; //导入方法依赖的package包/类
/**
* The fisher asks himself if he wants to leave the warm comfort of his bed.
*
* @param fisher
* @param model the model. Not used @return true if the fisherman wants to leave port.
* @param random */
@Override
public boolean shouldFisherLeavePort(
Fisher fisher, FishState model, MersenneTwisterFast random) {
if(checkOnlyOnceADay && model.getDay()==dayLastCheck) //if you already checked don't bother
return false;
dayLastCheck = model.getDay();
return random.nextBoolean(probabilityToLeavePort);
}
示例3: test
import ec.util.MersenneTwisterFast; //导入方法依赖的package包/类
/**
* returns true or false with probability given by the logistic
* @param agent the agent making the choice
* @param testTime the hours since start of simulation at which point we want the test to be made
* @param model the model being used
* @param tile the tile we are considering (can be null)
* @param random the randomizer
* @return true or false
*/
public boolean test(
Fisher agent, final double testTime, FishState model, SeaTile tile, MersenneTwisterFast random){
return random.nextBoolean(getProbability(agent, testTime, model, tile));
}