All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.keenon.lense.gameplay.players.GamePlayerRandom Maven / Gradle / Ivy

The newest version!
package com.github.keenon.lense.gameplay.players;

import com.github.keenon.lense.gameplay.Game;

import java.util.Random;
import java.util.function.Function;

/**
 * Created by keenon on 9/30/15.
 *
 * This provides a lower bound on the performance of an intelligent gameplaying algorithm, the same way that exhaustive
 * search provides an upper bound on performance.
 *
 * Picks its next move completely at random.
 */
public class GamePlayerRandom extends GamePlayer {
    Random r;

    public GamePlayerRandom(Random r) {
        this.r = r;
    }

    @Override
    public Game.Event getNextMove(Game game, Function utility) {
        Game.Event[] possible = game.getLegalMoves();
        int choice = r.nextInt(possible.length);
        return possible[choice];
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy