Class CheatingAIPlayer

  • All Implemented Interfaces:
    breitband.preset.Player

    public class CheatingAIPlayer
    extends RandomAIPlayer
    Class for cheatingAIPlayer that cheats 50% of the time and acts like randomAI 50% of time
    Author:
    Klara Schöbel
    • Constructor Detail

      • CheatingAIPlayer

        public CheatingAIPlayer​(int id,
                                java.lang.String name,
                                java.io.Reader read,
                                breitband.preset.ImmutableList<java.lang.String> con,
                                int num)
                         throws java.lang.Exception
        Constructs a new cheating AI with and id, a name, a reader, available contracts, and number of players
        Parameters:
        id - id of player (see also SPlayer.getPlayerId())
        name - name of player (see also SPlayer.getName())
        read - XML parser (see also Config)
        con - available Contracts (see also Board.getPlayerContracts())
        num - number of players
        Throws:
        java.lang.Exception - if config is invalid
    • Method Detail

      • request

        public breitband.preset.Move request()
        Overrides request method of RandomAIPlayer randomly deciding (with a 50% chance) to cheat or use the super.request() also deciding the way of cheating randomly the idea is to make the cheating percentage rise continuously in order to give the later cheating attempts a chance of happening (since the game will terminate after every cheating attempt)

        since we check this percentage four times and if the last one fails there is a fifth event to be considered each possibility should be 1/5 we achieve this by starting from 1/5, to 1/4, to 1/3, to 1/2

        Specified by:
        request in interface breitband.preset.Player
        Overrides:
        request in class RandomAIPlayer
        Returns:
        Move created by either cheating or calling super.request
      • randomDecision

        public boolean randomDecision​(int percent)
        Method to make seemingly random decisions at a certain percentage
        Parameters:
        percent - percentage of "true" outcome
        Returns:
        true in ``percent`` of cases