if (MathUtils.randomBoolean()) { // So we see when they are drawn on top of each other (which should be always). renderer.setColor(Color.GREEN); renderer.circle(group1.toScreenCoordinates.x, Gdx.graphics.getHeight() - group1.toScreenCoordinates.y, 5);
/** * 随机真假 */ public boolean RandomTF() { return MathUtils.randomBoolean(); }
/** * 随机正负 */ public int RandomAB() { return MathUtils.randomBoolean() ? 1 : -1; }
@Override public void processPackage(PackProcessingNode node) { try { System.out.println("start processing"); Thread.sleep(MathUtils.random(500, 2500)); if (MathUtils.randomBoolean()) throw new RuntimeException(); System.out.println("finish processing"); } catch (InterruptedException e) { Exceptions.throwRuntimeException(e); } } }
@Override public void update(Caveman caveman) { // 1 in 1000 if (MathUtils.randomBoolean(0.001f) && !caveman.getFSM().isInState(PEEING)) { caveman.say("OH! Gotta pee"); caveman.getFSM().changeState(PEEING); } }
@Override public void update(Caveman caveman) { caveman.increaseHungry(.01f); caveman.decreaseEnergy(.05f); // 1 in 250 if (MathUtils.randomBoolean(0.004f)) { caveman.say("Hey! I got a rabbit, I better go home to cook it"); caveman.food = MathUtils.random(20, 100); caveman.getFSM().changeState(RUN_TO_HOME); } }
@Override public void update(Dinosaur dinosaur) { dinosaur.decreaseEnergy(.05f); // 1 in 1000 if (MathUtils.randomBoolean(0.001f) && dinosaur.cavemanInState(CavemanState.HUNTING)) { MessageManager.getInstance().dispatchMessage( 0.0f, // no delay dinosaur, dinosaur.caveman, MessageType.GRRRRRRRR, null); dinosaur.say("GRRRRRRRRR"); } if(dinosaur.energy == 0) { dinosaur.say("Enough for today"); dinosaur.getFSM().changeState(GO_HOME); } }
float g = 0.8f; float b = 1f; if (MathUtils.randomBoolean()) { r = 0.7f;
boolean chooseActor = MathUtils.randomBoolean(.75f); boolean chooseSceneActor = MathUtils.randomBoolean(); } else if (MathUtils.randomBoolean(0.33f)) { if (w.getInventory().getNumItems() > 1 && MathUtils.randomBoolean(0.33f)) {
group.addAction(Actions.delay(1.5f, Actions.run(() -> { for(int i = 0; i < pointsCount; i ++){ boolean left = MathUtils.randomBoolean(), top = MathUtils.randomBoolean(); int leftOffset = MathUtils.random(50, 300), topOffset = MathUtils.random(50, 200), size = MathUtils.random(10, 40); float animated = (float)MathUtils.random(1800, 2800) / 1000f;