Multiplayer Battleships is a game for **playerCount** players, who take turns one after another. The game field is a rectangular grid containing one or more battleships. A battleship of size p is a 1xp or px1 rectangle, where p is between 1 and 4, inclusive. No two battleships share a cell, a side or a vertex. Each cell of a battleship is called a deck.
In one turn, a player selects one unattacked deck of any battleship and attacks it. If this deck is the last unattacked deck of that battleship, the ship drowns and the player gets p points, where p is the original size of the ship (see example 2). Otherwise, if the ship contains more unattacked decks, the player gets 1 point instead. The game is over when all decks of all battleships have been attacked.
All players follow the same strategy, and each player knows that all the other players are also following this strategy. Each player is trying to maximize his score at the end of the game. If there is more than one ship that the player can attack to achieve the highest possible score, he will pick the one among them whose top-left corner is the highest (i.e., in the uppermost row). If there are still multiple such ships, he will choose the one among them whose top-left corner is farthest to the left (i.e., in the leftmost column).
You will be given the game field in a String[], where a '.' represents an empty cell and an uppercase 'X' represents a deck. Each element represents a single row, and the rows are given from top to bottom. The cells in each row are given from left to right. Return the maximal score that can be achieved by the first player. |