Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        /// <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();
        }
Exemplo n.º 4
0
 public Entity(PlayerId owner, EntityId id, Position position)
 {
     this.owner    = owner;
     this.id       = id;
     this.position = position;
 }
Exemplo n.º 5
0
 private Player(PlayerId playerId, Shipyard shipyard, int halite = 0)
 {
     this.id       = playerId;
     this.shipyard = shipyard;
     this.halite   = halite;
 }
Exemplo n.º 6
0
 public Ship(PlayerId owner, EntityId id, Position position, int halite) : base(owner, id, position)
 {
     this.halite = halite;
 }