import java.util.*;

/**
 * This implements the game of Six Nimmt with a human versus up to 9 randomly
 * behaving computer players.
 */
public class SixNimmt {

    /** Static Scanner for talking to the user */
    public static final Scanner INPUT = new Scanner(System.in);

    /** Data Members for the SixNimmt game */
    private ArrayList<NimmtCard>[] hands;
    private ArrayList<NimmtCard>[] scores;
    private ArrayStack<NimmtCard>[] rows;

    /** 
     * The constructor creates the player's hands, the initial rows, and 
     * a place for scoring piles
     */
    public SixNimmt(int players) {

	// Create lists for the players hands and score piles
	hands = new ArrayList[players];
	scores = new ArrayList[players];
	for (int i = 0; i < players; i++) {
	    hands[i] = new ArrayList<NimmtCard>();
	    scores[i] = new ArrayList<NimmtCard>();
	}

	// Create the deck of cards and shuffle
	ArrayList<NimmtCard> deck = new ArrayList<NimmtCard>();
	for (int i = 0; i < 104; i++) {
	    deck.add(new NimmtCard(i + 1));
	}
	Collections.shuffle(deck);
	NimmtComparator<NimmtCard> nc = new NimmtComparator<NimmtCard>();

	// Deal out 10 cards to each player and sort them
	for (int i = 0; i < players; i++) {
	    for (int j = 0; j < 10; j++) {
		hands[i].add(deck.remove(0));
	    }
	    Collections.sort(hands[i], nc);
	}

	// Deal 4 cards for the initial rows
	rows = new ArrayStack[4];
	for (int i = 0; i < 4; i++) {
	    rows[i] = new ArrayStack<NimmtCard>();
	    rows[i].push(deck.remove(0));
	}
    }

    /**
     * The play method should implement the bulk of the Six Nimmt! game.
     * While players still have cards in their hands, each player chooses
     * a card to play.  Once all players have chosen cards, the cards are
     * revealed and placed on the appropriate row, starting with the smallest
     * card played.  If a row would have 6 cards after adding the new card,
     * the row is cleared and added to the player's score pile, and then the
     * card is added.  If the card is smaller than any row, the player chooses
     * what pile to take, adds these cards to their score pile, and
     * plays their card in the appropriate spot. When all cards have been played,
     * The player with the least BullHeads in their score pile is the winner.
     */
    public void play() {

	// WRITE ME

    }

    /** 
     * The toString method should print out a list of scores for the players
     * followed by the rows of cards, how many cards are in each row and the
     * total number of bullheads for that row. Finally, show the hand of
     * the Human player.
     */
    public String toString() {

	// WRITE ME

	return "";
    }

    /** Creates a SixNimmt game with 4 players, then plays the game*/
    public static void main(String[] args) {
	SixNimmt game = new SixNimmt(4);
	game.play();
    }
}
