Package breitband.game.players
Class CheatingAIPlayer
- java.lang.Object
-
- breitband.game.players.SPlayer
-
- breitband.game.players.RandomAIPlayer
-
- breitband.game.players.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 Summary
Constructors Constructor Description CheatingAIPlayer(int id, java.lang.String name, java.io.Reader read, breitband.preset.ImmutableList<java.lang.String> con, int num)
Constructs a new cheating AI with and id, a name, a reader, available contracts, and number of players
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
randomDecision(int percent)
Method to make seemingly random decisions at a certain percentagebreitband.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)-
Methods inherited from class breitband.game.players.RandomAIPlayer
pickedUpCables, randomCable, randomCity, randomContract
-
Methods inherited from class breitband.game.players.SPlayer
cityOnRoute, contractExists, distanceNotPossibleWithAvailableResources, distancePossibleWithType, getBoard, getName, getPlayerId, getScore, illegalBorderCrossing, illegalCableCrossings, init, inSameRegion, routePossible, update, verifyGame
-
-
-
-
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 alsoSPlayer.getPlayerId()
)name
- name of player (see alsoSPlayer.getName()
)read
- XML parser (see alsoConfig
)con
- available Contracts (see alsoBoard.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 interfacebreitband.preset.Player
- Overrides:
request
in classRandomAIPlayer
- 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
-
-