Professional Documents
Culture Documents
Arrays;
import java.util.BitSet;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
static BitSet allowedCardsRam = new BitSet(13); //this will hold the set of
allowed cards for Ram.
static BitSet allowedCardsShyam = new BitSet(13); //this will hold the set of
allowed cards for Shyam.
static BitSet allowedCardsHari = new BitSet(13); //this will hold the set of
allowed cards for Hari.
static BitSet allowedCardsSubash = new BitSet(13); //this will hold the set
of allowed cards for Subash.
static BitSet thrownCardsRam = new BitSet (13); //this will hold the set of
thrown cards for Ram.
static BitSet thrownCardsShyam = new BitSet (13); //this will hold the set of
thrown cards for Ram.
static BitSet thrownCardsHari = new BitSet (13); //this will hold the set of
thrown cards for Ram.
static BitSet thrownCardsSubash = new BitSet (13); //this will hold the set
of thrown cards for Ram.
static BitSet firstPlayer = new BitSet(4); //the bitset for storing the info
of the first player
static int RAMf=0;//for accessing the BitSet object
static int SHYAMf=1;
static int HARIf=2;
static int SUBASHf=3;
static Vector currentGame = new Vector(4); //this will hold the set of cards
currently thrown
System.out.println("--Beginning of main()--");
System.out.println("allowedCardsRam");
printBitSet(allowedCardsRam);
System.out.println("allowedCardsShyam");
printBitSet(allowedCardsShyam);
System.out.println("allowedCardsHari");
printBitSet(allowedCardsHari);
System.out.println("allowedCardsSubash");
printBitSet(allowedCardsSubash);
System.out.println("thrownCardsRam");
printBitSet(thrownCardsRam);
System.out.println("thrownCardsShyam");
printBitSet(thrownCardsShyam);
System.out.println("thrownCardsHari");
printBitSet(thrownCardsHari);
System.out.println("thrownCardsSubash");
printBitSet(thrownCardsSubash);
populateCards();
shuffleCards(); //to shuffle the global variable deck
giveCards();//to give 13 cards each to the 4 players
System.out.println("----After giving-----");
System.out.println("-----RAM-----");
printDeck(Ram);
System.out.println("");
System.out.println("-----SHYAM-----");
printDeck(Shyam);
System.out.println("");
System.out.println("-----HARI-----");
printDeck(Hari);
System.out.println("");
System.out.println("-----SUBASH-----");
printDeck(Subash);
currentGame.add(trialCard);
currentGame.add(trialCard);
currentGame.add(trialCard);
currentGame.add(trialCard);
System.out.println("thrownCardsRam");
printBitSet(thrownCardsRam);
System.out.println("thrownCardsShyam");
printBitSet(thrownCardsShyam);
System.out.println("thrownCardsHari");
printBitSet(thrownCardsHari);
System.out.println("thrownCardsSubash");
printBitSet(thrownCardsSubash);
System.out.println("--------------------------End of for loop of the
main() -----------------------");
}// end of the the game loop for
}//end of main
System.out.println("");
System.out.println("Now showing the allowed cards");
System.out.println("$$"+allowedCardsRam+"$$");
System.out.println("$$"+allowedCardsShyam+"$$");
System.out.println("$$"+allowedCardsHari+"$$");
System.out.println("$$"+allowedCardsSubash+"$$");
System.out.println("");
currentGame.clear();
System.out.println("CURRENT GAME VECTOR SIZE:"+currentGame.size());
printDeck(currentGame);
firstPlayer.clear();
firstPlayer.set(indexMax,true);
System.out.println("");
System.out.println("Now printing the first player bitset");
printBitSet(firstPlayer);
System.out.println("");
} //end of calculate first player
Card currentCard;
int firstPlayerSuit = 0;
if (suitList[i] == 1) {
//if there is a club, we add 20 to indicate that it is from
another league.
scoreList[i]+=20;
} //end of if
//Now we want to decrease the score of the player who has thrown a card which
is neither a club, nor of a suite thrown
// by the first player. This player gets -1.
if (isFirst(RAMf)){
firstPlayerSuit = suitList[0];
}
if (isFirst(SHYAMf)){
firstPlayerSuit = suitList[1];
}
if (isFirst(HARIf)){
firstPlayerSuit = suitList[2];
}
if (isFirst(SUBASHf)){
firstPlayerSuit = suitList[3];
}
System.out.println("");
System.out.println("Now Printing the Scores");
for (int i =0; i<4; i++){
System.out.println(scoreList[i]);
}
//Now we have the set of allowed cards for Ram, we call the strategy
function
//which takes in the bit set of allowed cards for this player and
(maybe later)
//considers what other players have thrown and returns a card object
that should be the best card to throw.
currentGame.set(0,strategy(allowedCardsRam,1)); //so the first card in
the currentGame vector will be the
//card from Ram considering his strategy
//Now once the card has been thrown, we want to remove that from the
allowed cards of Ram
pruneCard(currentGame,1);
System.out.println("");
System.out.println("CURRENT GAME");
System.out.println("");
printDeck(currentGame);
prepareCard(currentGame, allowedCardsShyam,2);
currentGame.set(1,strategy(allowedCardsShyam,2)); //call shyam strategy
pruneCard(currentGame,2); //to remove the already thrown card i.e.
modify the list of allowed cards
System.out.println("");
System.out.println("CURRENT GAME");
System.out.println("");
printDeck(currentGame);
prepareCard(currentGame, allowedCardsHari,3);
currentGame.set(2,strategy(allowedCardsHari,3)); //call hari strategy
pruneCard(currentGame,3); //to remove the already thrown card i.e.
modify the list of allowed cards
System.out.println("");
System.out.println("CURRENT GAME");
System.out.println("");
printDeck(currentGame);
prepareCard(currentGame, allowedCardsSubash,4);
currentGame.set(3,strategy(allowedCardsSubash,4)); //call subash
strategy
pruneCard(currentGame,4); //to remove the already thrown card i.e.
modify the list of allowed cards
System.out.println("");
System.out.println("Result of this game");
System.out.println("");
printDeck(currentGame);
}//end of the case where ram is the first player
if (isFirst(SHYAMf)){
//What to do if Shyam is the first player
System.out.println("");
System.out.println("CURRENT GAME");
System.out.println("");
printDeck(currentGame);
prepareCard(currentGame, allowedCardsHari,3);
currentGame.set(2,strategy(allowedCardsHari,3)); //call hari strategy
pruneCard(currentGame,3); //to remove the already thrown card i.e.
modify the list of allowed cards
System.out.println("");
System.out.println("CURRENT GAME");
System.out.println("");
printDeck(currentGame);
prepareCard(currentGame, allowedCardsSubash,4);
currentGame.set(3,strategy(allowedCardsSubash,4)); //call subash
strategy
pruneCard(currentGame,4); //to remove the already thrown card i.e.
modify the list of allowed cards
System.out.println("");
System.out.println("CURRENT GAME");
System.out.println("");
printDeck(currentGame);
prepareCard(currentGame, allowedCardsRam,1);
currentGame.set(0,strategy(allowedCardsRam,1));
pruneCard(currentGame,1);
System.out.println("");
System.out.println("Result of this game");
System.out.println("");
printDeck(currentGame);
if (isFirst(HARIf)){
//What to do if Hari is the first player
currentGame.set(2,strategy(allowedCardsHari,3)); //call hari strategy
pruneCard(currentGame,3); //to remove the already thrown card i.e.
modify the list of allowed cards
System.out.println("");
System.out.println("CURRENT GAME");
System.out.println("");
printDeck(currentGame);
prepareCard(currentGame, allowedCardsSubash,4);
currentGame.set(3,strategy(allowedCardsSubash,4)); //call subash
strategy
pruneCard(currentGame,4); //to remove the already thrown card i.e.
modify the list of allowed cards
System.out.println("");
System.out.println("CURRENT GAME");
System.out.println("");
printDeck(currentGame);
prepareCard(currentGame, allowedCardsRam,1);
currentGame.set(0,strategy(allowedCardsRam,1));
pruneCard(currentGame,1);
System.out.println("");
System.out.println("CURRENT GAME");
System.out.println("");
printDeck(currentGame);
prepareCard(currentGame, allowedCardsShyam,2);
currentGame.set(1,strategy(allowedCardsShyam,2));
pruneCard(currentGame,2);
System.out.println("");
System.out.println("Result of this game");
System.out.println("");
printDeck(currentGame);
}//end of the case where Hari is the first player
if (isFirst(SUBASHf)){
//What to do if Subash is the first player
currentGame.set(3,strategy(allowedCardsSubash,4)); //call subash
strategy
pruneCard(currentGame,4); //to remove the already thrown card i.e.
modify the list of allowed cards
System.out.println("");
System.out.println("CURRENT GAME");
System.out.println("");
printDeck(currentGame);
prepareCard(currentGame, allowedCardsRam,1);
currentGame.set(0,strategy(allowedCardsRam,1));
pruneCard(currentGame,1);
System.out.println("");
System.out.println("CURRENT GAME");
System.out.println("");
printDeck(currentGame);
prepareCard(currentGame, allowedCardsShyam,2);
currentGame.set(1,strategy(allowedCardsShyam,2));
pruneCard(currentGame,2);
System.out.println("");
System.out.println("CURRENT GAME");
System.out.println("");
printDeck(currentGame);
prepareCard(currentGame, allowedCardsHari,3);
currentGame.set(2,strategy(allowedCardsHari,3));
pruneCard(currentGame,3);
System.out.println("");
System.out.println("Result of this game");
System.out.println("");
printDeck(currentGame);
}//end of the case where Subash is the first player
//Make sure to include after game housekeeping chores here. THINK if there
are any.
return currentGame;
allowedCardsRam.set(indexThrown,false);
thrownCardsRam.set(indexThrown,true);
System.out.println("");
System.out.println("---From pruneCard()------");
System.out.println("##allowedCardsRam##"+allowedCardsRam);
System.out.println("##thrownCardsRam##"+thrownCardsRam);
System.out.println("---From pruneCard()------");
} //end of if
if (i == 2){
indexThrown = Shyam.indexOf(currentGame2.get(i-1));
//Now we have the index of the thrown card, we want to mark it in the
thrown card and restrict it.
allowedCardsShyam.set(indexThrown,false);
thrownCardsShyam.set(indexThrown,true);
System.out.println("");
System.out.println("---From pruneCard()------");
System.out.println("##allowedCardsShyam##"+allowedCardsShyam);
System.out.println("##thrownCardsShyam##"+thrownCardsShyam);
System.out.println("---From pruneCard()------");
} //end of if
if (i == 3){
indexThrown = Hari.indexOf(currentGame2.get(i-1));
//Now we have the index of the thrown card, we want to mark it in the
thrown card and restrict it.
allowedCardsHari.set(indexThrown,false);
thrownCardsHari.set(indexThrown,true);
System.out.println("");
System.out.println("---From pruneCard()------");
System.out.println("##allowedCardsHari##"+allowedCardsHari);
System.out.println("##thrownCardsHari##"+thrownCardsHari);
System.out.println("---From pruneCard()------");
} //end of if
if (i == 4){
indexThrown = Subash.indexOf(currentGame2.get(i-1));
//Now we have the index of the thrown card, we want to mark it in the
thrown card and restrict it.
allowedCardsSubash.set(indexThrown,false);
thrownCardsSubash.set(indexThrown,true);
System.out.println("");
System.out.println("---From pruneCard()------");
System.out.println("##allowedCardsSubash##"+allowedCardsSubash);
System.out.println("##thrownCardsSubash##"+thrownCardsSubash);
System.out.println("---From pruneCard()------");
} //end of if
System.out.println(input);
//If the suit of club is also not available, then the player can throw any
card in that case, other suits are allowed.
int indexOfCard;
Card currentCard = new Card();
Card compareCard = new Card();
Vector currentPlayer = new Vector();
BitSet currentAllowed = new BitSet(13);
BitSet tempCard = new BitSet(13); //for the and operation of the flip of
thrown cards
BitSet currentThrown = new BitSet(13);
BitSet higherRanks = new BitSet(13);
currentAllowed.set(0,13,false);
boolean containsNoSuite; //to flag whether the current card set contains the
card of same suite as that of the first player
boolean containsNoClub; //to flag whether the current card set contains any
club.
if (playerNumber == 1){
currentPlayer = Ram;
currentThrown = (BitSet) thrownCardsRam.clone();
}
if (playerNumber == 2){
currentPlayer = Shyam;
currentThrown = (BitSet) thrownCardsShyam.clone();
}
if (playerNumber == 3){
currentPlayer = Hari;
currentThrown = (BitSet) thrownCardsHari.clone();
}
if (playerNumber == 4){
currentPlayer = Subash;
currentThrown = (BitSet) thrownCardsSubash.clone();
}
if (isFirst(RAMf)) {
System.out.println("");
System.out.println("Since Ram is the first player");
//if Ram is the first player here, we want to look at index 0 of the
current game vector.
compareCard = (Card) currentGame2.get(0); // hold the current card to
compare to. 0 for the first player.
containsNoSuite = true; //initially set this to true and if there are
no cards of the same suite we proceed to
//allow clubs and if there are no clubs, we allow remaining cards.
for (int i =0; i<currentPlayer.size(); i++){
currentCard = (Card) currentPlayer.get(i);
try {
if ((currentCard.suit == compareCard.suit)&&(!
currentThrown.get(i))){ //if the suits are equal and the card is not thrown right
now
System.out.println("");
System.out.println("--From isFirst(RAMf)--");
printCurrentCompare(currentCard.suit,
compareCard.suit);
System.out.println("--");
indexOfCard = currentPlayer.indexOf(currentCard);
System.out.println("--indexOfCard--"+indexOfCard);
//we have the index of the card with the same suit as
the compare card
//Now we want to enable that card in the allowed card
currentAllowed.set(indexOfCard,true);
containsNoSuite = false;
} //end of if
} catch(IndexOutOfBoundsException e){
System.out.println("");
System.out.println("There is no suit of the card
thrown by first player.");
System.out.println("Going to check for Club, if
any...");
}//end of catch
}// end of for
//If the search through the loop has found no card with the same suit
as that of the first player, then
//this player should be allowed to throw a card of club. So we will be
allowing the clubs for this player.
containsNoClub = true;
if (containsNoSuite) {
for (int i=0; i<currentPlayer.size(); i++){
currentCard = (Card) currentPlayer.get(i);
try{
if ((currentCard.suit == 1)&&(!currentThrown.get(i)))
{
//we have found a club
indexOfCard =
currentPlayer.indexOf(currentCard);
currentAllowed.set(indexOfCard,true);
containsNoClub = false;
} //end of inner if
} catch (IndexOutOfBoundsException e){
System.out.println("");
System.out.println("There is neither the suit
of the card thrown by first player.Nor the Club");
System.out.println("Going to check for other
cards, if any...");
}//end of catch
}//end of for
} //end of outer if
//Now if there is no suit and no club card, the player can throw any of
the card, so we allow all of the cards
//provided containsNoSuite and containsNoClub are both true.
if ((containsNoSuite) && (containsNoClub)) {
System.out.println("");
System.out.println("Allowing other cards because no same suit and
no club either.");
System.out.println("...");
for (int i=0; i < currentPlayer.size(); i++){
if (!currentThrown.get(i)){
currentAllowed.set(i,true);
}//end of inner if
}//end of for
}//end of if
}//end of isFirst
if (isFirst(SHYAMf)) {
System.out.println("");
System.out.println("Since Shyam is the first player");
//if Shyam is the first player here, we want to look at index 1 of the
current game vector.
compareCard = (Card) currentGame2.get(1); // hold the current card to
compare to. 1 for the second player.
containsNoSuite = true; //initially set this to true and if there are
no cards of the same suite we proceed to
//allow clubs and if there are no clubs, we allow remaining cards.
for (int i =0; i<currentPlayer.size(); i++){
currentCard = (Card) currentPlayer.get(i);
try {
if ((currentCard.suit == compareCard.suit)&&(!
currentThrown.get(i))){
System.out.println("");
System.out.println("--From isFirst(SHYAMf)--");
printCurrentCompare(currentCard.suit,
compareCard.suit);
System.out.println("--");
indexOfCard = currentPlayer.indexOf(currentCard);
System.out.println("--indexOfCard--"+indexOfCard);
//we have the index of the card with the same suit as
the compare card
//Now we want to enable that card in the allowed card
currentAllowed.set(indexOfCard,true);
if (currentCard.rank > maxRankUptoNow(currentGame2)){
System.out.println("--");
System.out.println("Higher rank available");
System.out.println("--");
higherRanks.set(indexOfCard,true);
}//end of if for higher ranks
containsNoSuite = false;
}//end of if
}catch(IndexOutOfBoundsException e){
System.out.println("");
System.out.println("There is no suit of the card thrown by
first player.");
System.out.println("Going to check for Club, if any...");
}//end of catch
}// end of for
//If the search through the loop has found no card with the same suit
as that of the first player, then
//this player should be allowed to throw a card of club. So we will be
allowing the clubs for this player.
containsNoClub = true;
if (containsNoSuite) {
for (int i=0; i<currentPlayer.size(); i++){
currentCard = (Card) currentPlayer.get(i);
try{
if ((currentCard.suit == 1)&&(!currentThrown.get(i)))
{
//we have found a club
indexOfCard =
currentPlayer.indexOf(currentCard);
currentAllowed.set(indexOfCard,true);
containsNoClub = false;
} //end of inner if
}catch (IndexOutOfBoundsException e){
System.out.println("");
System.out.println("There is neither the suit of the
card thrown by first player.Nor the Club");
System.out.println("Going to check for other cards,
if any...");
}//end of catch
}//end of for
} //end of outer if
//Now if there is no suit and no club card, the player can throw any of
the card, so we allow all of the cards
//provided containsNoSuite and containsNoClub are both true.
if ((containsNoSuite) && (containsNoClub)) {
System.out.println("");
System.out.println("Allowing other cards because no same suit and
no club either.");
System.out.println("...");
for (int i=0; i < currentPlayer.size(); i++){
if (!currentThrown.get(i)) {
currentAllowed.set(i,true);
}//end of if
}//end of for
}//end of outer if
}//end of isFirst
if (isFirst(HARIf)) {
//if Hari is the first player here, we want to look at index 2 of the
current game vector.
System.out.println("");
System.out.println("Since Hari is the first player");
compareCard = (Card) currentGame2.get(2); // hold the current card to
compare to. 2 for the third player.
containsNoSuite = true; //initially set this to true and if there are
no cards of the same suite we proceed to
//allow clubs and if there are no clubs, we allow remaining cards.
for (int i =0; i<currentPlayer.size(); i++){
currentCard = (Card) currentPlayer.get(i);
try{
if ((currentCard.suit == compareCard.suit)&&(!
currentThrown.get(i))){
System.out.println("");
System.out.println("--From isFirst(HARIf)--");
printCurrentCompare(currentCard.suit,
compareCard.suit);
System.out.println("--");
indexOfCard = currentPlayer.indexOf(currentCard);
System.out.println("--indexOfCard--"+indexOfCard);
//we have the index of the card with the same suit as
the compare card
//Now we want to enable that card in the allowed card
currentAllowed.set(indexOfCard,true);
if (currentCard.rank > maxRankUptoNow(currentGame2)){
System.out.println("--");
System.out.println("Higher rank available");
System.out.println("--");
higherRanks.set(indexOfCard,true);
}//end of if for higher ranks
containsNoSuite = false;
}//end of if
}catch(IndexOutOfBoundsException e){
System.out.println("");
System.out.println("There is no suit of the card thrown by
first player.");
System.out.println("Going to check for Club, if any...");
}//end of catch
}// end of for
//If the search through the loop has found no card with the same suit as that
of the first player, then
//this player should be allowed to throw a card of club. So we will be
allowing the clubs for this player.
containsNoClub = true;
if (containsNoSuite) {
for (int i=0; i<currentPlayer.size(); i++){
currentCard = (Card) currentPlayer.get(i);
try {
if ((currentCard.suit == 1)&&(!currentThrown.get(i)))
{
//we have found a club
indexOfCard =
currentPlayer.indexOf(currentCard);
currentAllowed.set(indexOfCard,true);
containsNoClub = false;
} //end of inner if
}catch (IndexOutOfBoundsException e){
System.out.println("");
System.out.println("There is neither the suit of the
card thrown by first player.Nor the Club");
System.out.println("Going to check for other cards,
if any...");
}//end of catch
}//end of for
} //end of outer if
//Now if there is no suit and no club card, the player can throw any of
the card, so we allow all of the cards
//provided containsNoSuite and containsNoClub are both true.
if ((containsNoSuite) && (containsNoClub)) {
System.out.println("");
System.out.println("Allowing other cards because no same suit and
no club either.");
System.out.println("...");
for (int i=0; i < currentPlayer.size(); i++){
if(!currentThrown.get(i)) {
currentAllowed.set(i,true);
}//end of if
}//end of for
}//end of outer if
}//end of isFirst
if (isFirst(SUBASHf)) {
//if Subash is the first player here, we want to look at index 3 of the
current game vector.
System.out.println("");
System.out.println("Since Subash is the first player");
compareCard = (Card) currentGame2.get(3); // hold the current card to
compare to. 3 for the fourth player.
containsNoSuite = true; //initially set this to true and if there are
no cards of the same suite we proceed to
//allow clubs and if there are no clubs, we allow remaining cards.
for (int i =0; i<currentPlayer.size(); i++){
currentCard = (Card) currentPlayer.get(i);
try{
if ((currentCard.suit == compareCard.suit)&&(!
currentThrown.get(i))){
System.out.println("");
System.out.println("--From isFirst(SUBASHf)--");
printCurrentCompare(currentCard.suit,
compareCard.suit);
System.out.println("--");
indexOfCard = currentPlayer.indexOf(currentCard);
System.out.println("--indexOfCard--"+indexOfCard);
//we have the index of the card with the same suit as
the compare card
//Now we want to enable that card in the allowed card
currentAllowed.set(indexOfCard,true);
if (currentCard.rank > maxRankUptoNow(currentGame2)){
System.out.println("--");
System.out.println("Higher rank available");
System.out.println("--");
higherRanks.set(indexOfCard,true);
}//end of if for higher ranks
containsNoSuite = false;
}//end of if
}catch(IndexOutOfBoundsException e){
System.out.println("");
System.out.println("There is no suit of the card thrown by
first player.");
System.out.println("Going to check for Club, if any...");
}//end of catch
}// end of for
//If the search through the loop has found no card with the same suit as that
of the first player, then
//this player should be allowed to throw a card of club. So we will be
allowing the clubs for this player.
containsNoClub = true;
if (containsNoSuite) {
for (int i=0; i<currentPlayer.size(); i++){
currentCard = (Card) currentPlayer.get(i);
try {
if ((currentCard.suit == 1)&&(!currentThrown.get(i)))
{
//we have found a club
indexOfCard =
currentPlayer.indexOf(currentCard);
currentAllowed.set(indexOfCard,true);
containsNoClub = false;
} //end of inner if
}catch (IndexOutOfBoundsException e){
System.out.println("");
System.out.println("There is neither the suit of the
card thrown by first player.Nor the Club");
System.out.println("Going to check for other cards,
if any...");
}//end of catch
}//end of for
} //end of outer if
//Now if there is no suit and no club card, the player can throw any of
the card, so we allow all of the cards
//provided containsNoSuite and containsNoClub are both true.
if ((containsNoSuite) && (containsNoClub)) {
System.out.println("");
System.out.println("Allowing other cards because no same suit and
no club either.");
System.out.println("...");
for (int i=0; i < currentPlayer.size(); i++){
if(!currentThrown.get(i)) {
currentAllowed.set(i,true);
}
}//end of for
}//end of outer if
}//end of isFirst
//Now we want to further disallow the cards that have already been thrown
if (playerNumber == 1){
allowedCardsRam = currentAllowed;
tempCard = (BitSet) thrownCardsRam.clone();
tempCard.flip(0,13);
allowedCardsRam.and(tempCard);
if (!higherRanks.isEmpty()){
//if we have higher ranks available, we want to throw higher rank
cards
tempCard = (BitSet) higherRanks.clone();
allowedCardsRam.and(tempCard);
}//end of inner if
System.out.println("");
System.out.println("Higher ranks"+higherRanks);
System.out.println("");
}//end of outer if
if (playerNumber == 2){
allowedCardsShyam = currentAllowed;
tempCard = (BitSet) thrownCardsShyam.clone();
tempCard.flip(0,13);
allowedCardsShyam.and(tempCard);
if (!higherRanks.isEmpty()){
//if we have higher ranks available, we want to throw higher rank
cards
tempCard = (BitSet) higherRanks.clone();
allowedCardsShyam.and(tempCard);
}//end of inner if
System.out.println("");
System.out.println("Higher ranks"+higherRanks);
System.out.println("");
}
if (playerNumber == 3){
allowedCardsHari = currentAllowed;
tempCard = (BitSet) thrownCardsHari.clone();
tempCard.flip(0,13);
allowedCardsHari.and(tempCard);
if (!higherRanks.isEmpty()){
//if we have higher ranks available, we want to throw higher rank
cards
tempCard = (BitSet) higherRanks.clone();
allowedCardsHari.and(tempCard);
}//end of inner if
System.out.println("");
System.out.println("Higher ranks"+higherRanks);
System.out.println("");
}
if (playerNumber == 4){
allowedCardsSubash = currentAllowed;
tempCard = (BitSet) thrownCardsSubash.clone();
tempCard.flip(0,13);
allowedCardsSubash.and(tempCard);
if (!higherRanks.isEmpty()){
//if we have higher ranks available, we want to throw higher rank
cards
tempCard = (BitSet) higherRanks.clone();
allowedCardsSubash.and(tempCard);
}//end of inner if
System.out.println("");
System.out.println("Higher ranks"+higherRanks);
System.out.println("");
}
System.out.println("");
System.out.println("--From the prepareCard()--");
System.out.println("allowedCardsRam"+allowedCardsRam);
System.out.println("allowedCardsShyam"+allowedCardsShyam);
System.out.println("allowedCardsHari"+allowedCardsHari);
System.out.println("allowedCardsSubash"+allowedCardsSubash);
System.out.println("");
System.out.println("thrownCardsRam"+thrownCardsRam);
System.out.println("thrownCardsShyam"+thrownCardsShyam);
System.out.println("thrownCardsHari"+thrownCardsHari);
System.out.println("thrownCardsSubash"+thrownCardsSubash);
System.out.println("--End of prepareCard() --");
} //end of allowedCards
if (playerNumber == 2){
for (int i=0; i<=Shyam.size(); i++){
if(isAllowed(i,allowedCardsShyam)){ //this strategy is for Shyam
if (playerNumber == 3){
for (int i=0; i<=Hari.size(); i++){
if(isAllowed(i,allowedCardsHari)){ //this strategy is for Hari
if (playerNumber == 4){
for (int i=0; i<=Subash.size(); i++){
if(isAllowed(i,allowedCardsSubash)){ //this strategy is for
Subash
printCard((Card) deck2.get(i));
}*/
int index = 0;
for (int suit=1; suit<=4; suit++){
for (int rank=1; rank<=13; rank++){
deck.add(index,new Card(suit,rank));
index++;
}
}
}//end of populate cards method
}//end of class