public override bool Equals(object obj) { if (this == obj) { return(true); } if (obj == null || this.GetType() != obj.GetType()) { return(false); } PlayerId playerId = (PlayerId)obj; return(id == playerId.id); }
/// <summary> /// Reads in the details of a new ship from the Halite engine. /// </summary> public static Ship _generate(PlayerId playerId, List <Ship> previousShips) { Input input = Input.ReadInput(); EntityId shipId = new EntityId(input.GetInt()); int x = input.GetInt(); int y = input.GetInt(); int halite = input.GetInt(); var previous = previousShips.FirstOrDefault(s => s.Id == shipId.id); var newShip = new Ship(playerId, shipId, new Position(x, y), halite); if (previous != null) { newShip.PreviousPosition = previous.position; } return(newShip); }
/// <summary> /// Initiates a game object collecting all start-state instances for the contained items for pre-game. /// Also sets up basic logging. /// </summary> public Game() { //Grab constants JSON Constants.LoadConstants(Input.ReadLine()); Input inputs = Input.ReadInput(); int numPlayers = inputs.GetInt(); myId = new PlayerId(inputs.GetInt()); Log.Initialize(new StreamWriter(String.Format("bot-{0}.log", myId))); for (int i = 0; i < numPlayers; i++) { players.Add(Player._generate()); } me = players[myId.id]; gameMap = GameMap._generate(); }
public Entity(PlayerId owner, EntityId id, Position position) { this.owner = owner; this.id = id; this.position = position; }
private Player(PlayerId playerId, Shipyard shipyard, int halite = 0) { this.id = playerId; this.shipyard = shipyard; this.halite = halite; }
public Ship(PlayerId owner, EntityId id, Position position, int halite) : base(owner, id, position) { this.halite = halite; }