Recent Donations

eVoMITcH

Server: Bunny Hop

Amount: $5.00 - Total: $50.00

Date: Sep 20, 2019 - 10:39 am

Broiler

Server: Course

Amount: $5.00 - Total: $10.00

Date: Sep 18, 2019 - 08:36 pm

Moneybrick

Server: Website

Amount: $10.00 - Total: $15.00

Date: Sep 18, 2019 - 12:06 am

Hotdoggy

Server: Bunny Hop

Amount: $5.00 - Total: $20.00

Date: Sep 17, 2019 - 02:12 am

Moneybrick

Server: Course

Amount: $5.00 - Total: $15.00

Date: Sep 17, 2019 - 12:18 am

jgfcool

Server: Jailbreak

Amount: $5.00 - Total: $100.00

Date: Sep 13, 2019 - 11:29 am

jgfcool

Server: Website

Amount: $10.00 - Total: $100.00

Date: Sep 13, 2019 - 10:02 am

Smoove

Server: Course

Amount: $5.00 - Total: $5.00

Date: Sep 13, 2019 - 12:51 am

jgfcool

Server: Course

Amount: $5.00 - Total: $100.00

Date: Sep 12, 2019 - 10:36 am

Alex

Server: Course

Amount: $5.00 - Total: $5.00

Date: Sep 12, 2019 - 06:11 am

 bean saucé 

Server: Website

Amount: $10.00 - Total: $95.00

Date: Sep 11, 2019 - 12:12 pm

 Yota_Ninja 

Server: Website

Amount: $10.00 - Total: $2,899.44

Date: Sep 10, 2019 - 10:25 am

Jinx

Server: Course

Amount: $5.00 - Total: $5.00

Date: Sep 9, 2019 - 01:30 am

Riga

Server: Course

Amount: $5.00 - Total: $5.00

Date: Sep 9, 2019 - 01:27 am

Zzuby

Server: Website

Amount: $10.00 - Total: $120.00

Date: Sep 8, 2019 - 02:54 am

my first big program!

#1
its in java, its a project for a class im taking. not all the features ive tried to add work but it works barebones.

its texas hold em! its 1389 lines, 78 in the classes and 1311 in the thing  i wrote it in eclipse.

sorry for the weird tabs it didnt paste well. i promise i spaced things to the best of my ability when writing.

Code:
import java.util.Scanner;
import java.util.Random;

public class holdClasses {

public int mag;
public int suit;
public int power;

public holdClasses() {
this.mag=0;
this.suit=0;
}

public holdClasses(int m, int s) {
this.mag=m;
this.suit=s;
}

public void holdClassesMulti(int p) {
this.power=p;
}

public String getSuit() {
if (suit==1) {
return "Hearts";
} else if (suit==2) {
return "Diamonds";
} else if (suit==3) {
return "Spades";
} else if (suit==4) {
return "Clubs";
}
else {
return null;
}
}

public int getMagInt() {
return this.mag;
}

public int getSuitInt() {
return this.suit;
}

public String getMag() {
if (mag==2) {
return "Two";
} else if (mag==3) {
return "Three";
} else if (mag==4) {
return "Four";
} else if (mag==5) {
return "Five";
} else if (mag==6) {
return "Six";
} else if (mag==7) {
return "Seven";
} else if (mag==8) {
return "Eight";
} else if (mag==9) {
return "Nine";
} else if (mag==10) {
return "Ten";
} else if (mag==11) {
return "Jack";
} else if (mag==12) {
return "Queen";
} else if (mag==13) {
return "King";
} else if (mag==14) {
return "Ace";
} else {
return null;
}
}
}
Code:
import java.util.Random;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class holdRun {

//function for flushes and royal flushes
public static int checkCFlush(holdClasses draws[], int cardNum) {
int varianceCounter=0;
int currentSuit=0;
int encounteredSuits[] = new int[4];
int rf = 100000;
boolean royalFlushC = false;
boolean flushC = false;
for(int q = 2; q<cardNum+1; q++) {
if(draws[q].getMagInt()<10) {
rf = 0;
royalFlushC = true;
}
if(varianceCounter>2) {
return 0;
}else {
flushC = true;
}
if(currentSuit==0) {
currentSuit=draws[q].getSuitInt();
encounteredSuits[0]=currentSuit;
continue;
}
if(Arrays.asList(encounteredSuits).contains(currentSuit)){
continue;
} else {
varianceCounter+=1;
encounteredSuits[varianceCounter]=draws[q].getSuitInt();
}

}
return 20-5*varianceCounter + rf;
}

//function for straight
public static int checkCStraight(holdClasses draws[], int cardNum) {
int varianceCounterInv=5;
int currentMag=0;
int encounteredMags[] = new int[7];
int encounteredMagsSet[];
int min=15;
int max=0;
boolean straightC = false;
for(int z=2; z<cardNum+1; z++) {

if(currentMag<min) {
min=currentMag;
}

if(currentMag>max) {
max=currentMag;
}

if(varianceCounterInv<3) {
return 0;
}
if(currentMag==0) {
currentMag=draws[z].getMagInt();
encounteredMags[0]=currentMag;
continue;
}
encounteredMags[z]=currentMag;
if(Arrays.asList(encounteredMags).contains(currentMag)) {
continue;
}

}
if(max-min>7) {
varianceCounterInv-=3;
}
if(max-min==4) {
straightC = true;
}

return 10+2*varianceCounterInv;
}

//function for n of a kind
public static int checkCNOfKind(holdClasses draws[], int cardNum) {
int currentMag=0;
boolean fourOfAKindC=false;
boolean threeOfAKindC=false;
boolean twoOfAKindC=false;
boolean twoPairC=false;
int counter=0;
int[] encounteredMags = {-1,-1,-1,-1,-1,-1,-1};
for(int r=2; r<cardNum+1; r++) {

if(currentMag==0) {
currentMag=draws[r].getMagInt();
encounteredMags[0]=currentMag;
continue;
}
encounteredMags[r]=currentMag;
}
//work on making booleans work. more mags same = less array filling

for (int i = 0;  i < 6; i++) {
for (int j = i+1; j < 7; j++) {
if (encounteredMags[i] == encounteredMags[j] && encounteredMags[i] != -1) {
counter++;
}
}
}

boolean twoOFAKindC = false;
if (counter == 2) {
twoOFAKindC =  true;
} else if (counter == 3) {
threeOfAKindC = true;
} else if (counter == 4) {
boolean fourOFAKindC = true;
}

if(threeOfAKindC && twoOfAKindC) {

} else if(encounteredMags[4]!=-1 && twoOFAKindC) {
twoPairC=true;
}


if(threeOfAKindC && twoOfAKindC) {
return 10;
} else if(twoPairC) {
return 7;
}else if(threeOfAKindC) {
return 4;
}
if(twoOfAKindC) {
return 2;
}else {
return 0;
}
}

//player hand functions (make all booleans)

public static int checkPFlush(holdClasses draws[], int cardNum) {
int varianceCounter=0;
int currentSuit=0;
int encounteredSuits[] = new int[4];
int rf = 100000;
boolean royalFlushP = false;
boolean flushP = false;
for(int q = 2; q<cardNum+1; q++) {
if(draws[q].getMagInt()<10) {
rf = 0;
royalFlushP = true;
}
if(varianceCounter>2) {
return 0;
}else {
flushP = true;
}
if(currentSuit==0) {
currentSuit=draws[q].getSuitInt();
encounteredSuits[0]=currentSuit;
continue;
}
if(Arrays.asList(encounteredSuits).contains(currentSuit)){
continue;
} else {
varianceCounter+=1;
encounteredSuits[varianceCounter]=draws[q].getSuitInt();
}

}
return 20-5*varianceCounter + rf;
}

//function for straight
public static int checkPStraight(holdClasses draws[], int cardNum) {
int varianceCounterInv=5;
int currentMag=0;
int encounteredMags[] = new int[7];
int encounteredMagsSet[];
int min=15;
int max=0;
boolean straightP = false;
for(int z=2; z<cardNum+1; z++) {

if(currentMag<min) {
min=currentMag;
}

if(currentMag>max) {
max=currentMag;
}

if(varianceCounterInv<3) {
return 0;
}
if(currentMag==0) {
currentMag=draws[z].getMagInt();
encounteredMags[0]=currentMag;
continue;
}
encounteredMags[z]=currentMag;
if(Arrays.asList(encounteredMags).contains(currentMag)) {
continue;
}

}
if(max-min>7) {
varianceCounterInv-=3;
}
if(max-min==4) {
straightP = true;
}

return 10+2*varianceCounterInv;
}

//function for n of a kind
public static int checkPNOfKind(holdClasses draws[], int cardNum) {
int currentMag=0;
boolean fourOfAKindP=false;
boolean threeOfAKindP=false;
boolean twoOfAKindP=false;
boolean twoPairP=false;
int counter=0;
int[] encounteredMags = {-1,-1,-1,-1,-1,-1,-1};
for(int r=2; r<cardNum+1; r++) {

if(currentMag==0) {
currentMag=draws[r].getMagInt();
encounteredMags[0]=currentMag;
continue;
}
encounteredMags[r]=currentMag;
}
//work on making booleans work. more mags same = less array filling

for (int i = 0;  i < 6; i++) {
for (int j = i+1; j < 7; j++) {
if (encounteredMags[i] == encounteredMags[j] && encounteredMags[i] != -1) {
counter++;
}
}
}

boolean twoOFAKindP = false;
if (counter == 2) {
twoOFAKindP =  true;
} else if (counter == 3) {
threeOfAKindP = true;
} else if (counter == 4) {
boolean fourOFAKindP = true;
}

if(threeOfAKindP && twoOfAKindP) {

} else if(encounteredMags[4]!=-1 && twoOFAKindP) {
twoPairP=true;
}


if(threeOfAKindP && twoOfAKindP) {
return 10;
} else if(twoPairP) {
return 7;
}else if(threeOfAKindP) {
return 4;
}
if(twoOfAKindP) {
return 2;
}else {
return 0;
}
}


public static int highCard(holdClasses draws[]) {
int max = 0;
for(int i=0; i<10; i++) {
if(draws[i].getMagInt()>max) {
max = draws[i].getMagInt();
}

}
if (max==draws[0].getMagInt()||max==draws[1].getMagInt()) {
return 1;
}
if (max==draws[2].getMagInt()||max==draws[3].getMagInt()) {
return -1;
}
return 0;
}

public static void main(String[] args) {

boolean royalFlushC=false;
boolean straightFlushC=false;
boolean fullHouseC=false;
boolean flushC=false;
boolean straightC=false;
boolean fourOfAKindC=false;
boolean threeOfAKindC=false;
boolean twoPairC=false;
boolean twoOfAKindC=false;

boolean royalFlushP=false;
boolean straightFlushP=false;
boolean fullHouseP=false;
boolean flushP=false;
boolean straightP=false;
boolean fourOfAKindP=false;
boolean threeOfAKindP=false;
boolean twoPairP=false;
boolean twoOfAKindP=false;



System.out.println("Welcome to two player Texas Hold Em. The player goes first and computer will go second. First player to lose all 10,000 starting coins loses the game. Good luck!");
int userPool = 10000;
int compPool = 10000;
int midPool = 0;
while(true) {
holdClasses draws[] = new holdClasses[9];
List<holdClasses> deck = new ArrayList<holdClasses>();
Random drawMain = new Random();
//makes deck with magnitude and suit
int a = 0;
for (int i = 1; i < 5; i++) {
for (int j = 2; j < 15; j++) {
holdClasses card = new holdClasses(j,i);
deck.add(a, card);
a++;
}
}

//player draw and shuffle (first 2 cards in deck, 0 and 1)
Collections.shuffle(deck);
for(int k=0; k<2; k++) {
draws[k] = deck.get(k);
deck.remove(draws[k]);
System.out.println("You have the "+deck.get(k).getMag()+" of "+deck.get(k).getSuit());
}

//computer draw (next 2 cards in deck, 2 and 3)
for(int l=2; l<4; l++) {
draws[l] = deck.get(l);
deck.remove(draws[l]);
}
int r1RaiseChoice=0;
int r2RaiseChoice=0;
int r3RaiseChoice=0;
int r4RaiseChoice=0;
//round 1 computer betting (power is a way to do it or specific number bets per possible hand) (do power for early rounds when full hands cannot be determined)
while(true) {

int r1CBetRand = 0;
while(true) {
int r1CPower = 0;
if(r1RaiseChoice>0&&r1RaiseChoice<2001) {
r1CPower=r1CPower+(r1RaiseChoice/100);
}
if(deck.get(2).getSuit()==deck.get(3).getSuit()) {
r1CPower=r1CPower+1;
}

if((deck.get(2).getMag().equals("Five")||deck.get(2).getMag().equals("Five")||deck.get(2).getMag().equals("Five")||deck.get(2).getMag().equals("Five")||deck.get(2).getMag().equals("Five"))&&(deck.get(3).getMag().equals("Five")||deck.get(3).getMag().equals("Five")||deck.get(3).getMag().equals("Five")||deck.get(3).getMag().equals("Five")||deck.get(3).getMag().equals("Five"))) {
r1CPower=r1CPower+1;
}

if((deck.get(2).getMag()==deck.get(3).getMag())||(deck.get(2).getMag().equals("Ten")||deck.get(2).getMag().equals("Jack")||deck.get(2).getMag().equals("Queen")||deck.get(2).getMag().equals("King")||deck.get(2).getMag().equals("Ace"))&&(deck.get(3).getMag().equals("Ten")||deck.get(3).getMag().equals("Jack")||deck.get(3).getMag().equals("Queen")||deck.get(3).getMag().equals("King")||deck.get(3).getMag().equals("Ace"))) {
r1CPower=r1CPower+2;
}
if((deck.get(2).getMag().equals("King")||deck.get(2).getMag().equals("Ace"))&&(deck.get(3).getMag().equals("King")||deck.get(3).getMag().equals("Ace"))) {
r1CPower=r1CPower+2;
}

if((deck.get(2).getMag()=="Ace"&&deck.get(3).getMag()=="Ace")){
r1CPower=r1CPower+4;
}

if(r1CPower>=13) {
Random random = new Random();
r1CBetRand = random.nextInt(5000 + 1 - 500) + 500;
} else if(r1CPower==12) {
Random random = new Random();
r1CBetRand = random.nextInt(4000 + 1 - 500) + 500;
} else if(r1CPower==11) {
Random random = new Random();
r1CBetRand = random.nextInt(3000 + 1 - 500) + 500;
} if(r1CPower>=10) {
Random random = new Random();
r1CBetRand = random.nextInt(2000 + 1 - 500) + 500;
} else if(r1CPower==9) {
Random random = new Random();
r1CBetRand = random.nextInt(1500 + 1 - 750) + 750;
}else if(r1CPower==8) {
Random random = new Random();
r1CBetRand = random.nextInt(1000 + 1 - 500) + 500;

}else if(r1CPower==7) {
Random random = new Random();
r1CBetRand = random.nextInt(800 + 1 - 300) + 300;

}else if(r1CPower==6) {
Random random = new Random();
r1CBetRand = random.nextInt(600 + 1 - 300) + 300;

}else if(r1CPower==5) {
Random random = new Random();
r1CBetRand = random.nextInt(600 + 1 - 100) + 100;

}else if(r1CPower==4) {
Random random = new Random();
r1CBetRand = random.nextInt(500 + 1 - 50) + 50;

}else if(r1CPower==3) {
Random random = new Random();
r1CBetRand = random.nextInt(500 + 1 - 50) + 50;

}else if(r1CPower==2) {
Random random = new Random();
r1CBetRand = random.nextInt(250 + 1 - 50) + 50;

}else if(r1CPower==1) {
Random random = new Random();
r1CBetRand = random.nextInt(100 + 1 - 50) + 50;
}else if(r1CPower==0) {
Random random = new Random();
r1CBetRand = random.nextInt(100 + 1 - 50) + 50;
}else {
Random random = new Random();
r1CBetRand = random.nextInt(100 + 1 - 50) + 50;
}


if(r1CBetRand>=r1RaiseChoice) {
break;
}else {
continue;
}
}
r1CBetRand=5*r1CBetRand;
if(r1CBetRand>compPool) {
r1CBetRand=compPool;
}
compPool=compPool-r1CBetRand;
midPool=midPool+r1CBetRand;

System.out.println("The computer bet "+r1CBetRand+" coins it now has "+compPool+" coins.");

//round 1 player betting (make sure they can't bet more than they have)
System.out.println("Would you like to 'raise', 'match' the computer or 'fold'?");
String r1BetChoice;
Scanner userInput = new Scanner(System.in);
while(true) {

r1BetChoice = userInput.nextLine();

if(r1BetChoice.equals("fold")||r1BetChoice.equals("match")||r1BetChoice.equals("raise")) {
break;
}else {
System.out.println("'raise', 'match' or 'fold' try again");
continue;
}
}
if(r1BetChoice.equals("fold")) {
System.out.println("Player has folded, moving on.");
compPool=compPool+midPool;
midPool=0;
break;
}else if(r1BetChoice.equals("match")){
System.out.println("Player has matched the computer");
userPool=userPool-r1CBetRand;
midPool=midPool+r1CBetRand;
System.out.println("Computer has matched, moving on.");
}else if(r1BetChoice.equals("raise")) {
System.out.println("How many coins would you like to raise");

while(true) {
r1RaiseChoice = userInput.nextInt();
if(r1RaiseChoice>0) {
break;
}else {
System.out.println("Must be positive, try again");
}
}
userPool=userPool-r1RaiseChoice;
midPool=midPool+r1RaiseChoice;
System.out.print("Player raised "+r1RaiseChoice+" coins.");
if(r1RaiseChoice>0&&r1RaiseChoice<2001) {
int compMatchRaiseChance;
Random random = new Random();
compMatchRaiseChance = random.nextInt(3);
if(compMatchRaiseChance==0||compMatchRaiseChance==1||compMatchRaiseChance==2) {
compPool=compPool-r1RaiseChoice;
midPool=midPool+r1RaiseChoice;
System.out.println("The computer has matched your raise, moving on.");
continue;
}
}else if(r1RaiseChoice>2000&&r1RaiseChoice<5001) {
int compMatchRaiseChance;
Random random = new Random();
compMatchRaiseChance = random.nextInt(3);
if(compMatchRaiseChance==0) {
compPool=compPool-r1RaiseChoice;
midPool=midPool+r1RaiseChoice;
System.out.println("The computer has matched your raise, moving on.");
continue;
} else if(r1RaiseChoice>2000) {
userPool=userPool+midPool;
midPool=0;
System.out.println("Computer has folded, moving on.");
break;
}
}
}



//say how much money person has, computer has, and cards of player.
System.out.println("Reminders:");
System.out.println("You have the "+deck.get(0).getMag()+" of "+deck.get(0).getSuit());
System.out.println("You have the "+deck.get(1).getMag()+" of "+deck.get(1).getSuit());
System.out.println("You have "+userPool+" coins left.");
System.out.println("Computer has "+compPool+" coins left.");
System.out.println("There are "+midPool+" in the middle.");
System.out.println("");
int qaz=0;
System.out.println("type anything to continue");
Scanner slow4 = new Scanner(System.in);
String Slow4 = slow4.nextLine();
if(Slow4.equals("hahaha")) {
qaz+=1;
}


//first 3 community card draw (next 3 cards in deck, 4, 5 and 6)
System.out.println("The first 3 community cards will now be drawn.");
for(int m=4; m<7; m++) {
draws[m] = deck.get(m);
deck.remove(draws[m]);
System.out.println("The "+deck.get(m).getMag()+" of "+deck.get(m).getSuit()+" was drawn.");
}




//round 2 computer betting

int r2CBetRand = 0;
while(true) {
int r2CPower = 0;
if(r2RaiseChoice>0&&r2RaiseChoice<2001) {
r2CPower=r2CPower+(r2RaiseChoice/100);
}

//functions statements to increase r2CPower.

r2CPower+=checkCFlush(draws, 5);
r2CPower+=checkCStraight(draws, 5);
r2CPower+=checkCNOfKind(draws, 5);

if(r2CPower>=15 && r2CPower<1000) {
Random random = new Random();
r2CBetRand = random.nextInt(5000 + 1 - 500) + 500;
} else if(r2CPower==14) {
Random random = new Random();
r2CBetRand = random.nextInt(5000 + 1 - 500) + 500;
} else if(r2CPower==13) {
Random random = new Random();
r2CBetRand = random.nextInt(5000 + 1 - 500) + 500;
} else if(r2CPower==12) {
Random random = new Random();
r2CBetRand = random.nextInt(4000 + 1 - 500) + 500;
} else if(r2CPower==11) {
Random random = new Random();
r2CBetRand = random.nextInt(3000 + 1 - 500) + 500;
} if(r2CPower>=10) {
Random random = new Random();
r2CBetRand = random.nextInt(2000 + 1 - 500) + 500;
} else if(r2CPower==9) {
Random random = new Random();
r2CBetRand = random.nextInt(1500 + 1 - 750) + 750;
}else if(r2CPower==8) {
Random random = new Random();
r2CBetRand = random.nextInt(1000 + 1 - 500) + 500;

}else if(r2CPower==7) {
Random random = new Random();
r2CBetRand = random.nextInt(800 + 1 - 300) + 300;

}else if(r2CPower==6) {
Random random = new Random();
r2CBetRand = random.nextInt(600 + 1 - 300) + 300;

}else if(r2CPower==5) {
Random random = new Random();
r2CBetRand = random.nextInt(600 + 1 - 100) + 100;

}else if(r2CPower==4) {
Random random = new Random();
r2CBetRand = random.nextInt(500 + 1 - 50) + 50;

}else if(r2CPower==3) {
Random random = new Random();
r2CBetRand = random.nextInt(500 + 1);

}else if(r2CPower==2) {
Random random = new Random();
r2CBetRand = random.nextInt(250 + 1);

}else if(r2CPower==1) {
Random random = new Random();
r2CBetRand = random.nextInt(100 + 1);
}else if(r2CPower==0) {
Random random = new Random();
r2CBetRand = random.nextInt(1);
}else {
Random random = new Random();
r2CBetRand = random.nextInt(1);
}

if(r2CBetRand>compPool) {
r2CBetRand=compPool;
}
if(r2CBetRand>=r2RaiseChoice) {
break;
}else {
continue;
}
}
r2CBetRand=5*r2CBetRand;
if(r2CBetRand>compPool) {
r2CBetRand=compPool;
}


compPool=compPool-r2CBetRand;
midPool=midPool+r2CBetRand;

System.out.println("The computer bet "+r2CBetRand+" coins it now has "+compPool+" coins.");


//round 2 player betting


System.out.println("Would you like to 'raise', 'match' the computer or 'fold'?");
String r2BetChoice;
Scanner userInput2 = new Scanner(System.in);
while(true) {

r2BetChoice = userInput2.nextLine();

if(r2BetChoice.equals("fold")||r2BetChoice.equals("match")||r2BetChoice.equals("raise")) {
break;
}else {
System.out.println("'raise', 'match' or 'fold' try again");
continue;
}
}
if(r2BetChoice.equals("fold")) {
System.out.println("Player has folded, moving on.");
compPool=compPool+midPool;
midPool=0;
break;
}else if(r2BetChoice.equals("match")){
System.out.println("Player has matched the computer");
userPool=userPool-r2CBetRand;
midPool=midPool+r2CBetRand;
System.out.println("Computer has matched, moving on.");
}else if(r2BetChoice.equals("raise")) {
System.out.println("How many coins would you like to raise");

while(true) {
r2RaiseChoice = userInput.nextInt();
if(r2RaiseChoice>0) {
break;
}else {
System.out.println("Must be positive, try again");
}
}
userPool=userPool-r2RaiseChoice;
midPool=midPool+r2RaiseChoice;
System.out.print("Player raised "+r2RaiseChoice+" coins.");
if(r2RaiseChoice>0&&r2RaiseChoice<2001) {
int compMatchRaiseChance;
Random random = new Random();
compMatchRaiseChance = random.nextInt(3);
if(compMatchRaiseChance==0||compMatchRaiseChance==1||compMatchRaiseChance==2) {
compPool=compPool-r2RaiseChoice;
midPool=midPool+r2RaiseChoice;
System.out.println("The computer has matched your raise, moving on.");
continue;
}
}else if(r2RaiseChoice>2000&&r2RaiseChoice<7501) {
int compMatchRaiseChance;
Random random = new Random();
compMatchRaiseChance = random.nextInt(3);
if(compMatchRaiseChance==0) {
compPool=compPool-r2RaiseChoice;
midPool=midPool+r2RaiseChoice;
System.out.println("The computer has matched your raise, moving on.");
continue;
} else if(r2RaiseChoice>7500) {
userPool=userPool+midPool;
midPool=0;
System.out.println("Computer has folded, moving on.");
break;
}
}
}

if(userPool<=0) {
System.out.println("You lost!");
break;
} else if (compPool<=0) {
System.out.println("You win!");
break;
}

//say how much money person has, computer has, and cards of player.
System.out.println("Reminders:");
System.out.println("You have the "+deck.get(0).getMag()+" of "+deck.get(0).getSuit());
System.out.println("You have the "+deck.get(1).getMag()+" of "+deck.get(1).getSuit());
System.out.println("");
System.out.println("The "+deck.get(4).getMag()+" of "+deck.get(4).getSuit()+" is in the middle");
System.out.println("The "+deck.get(5).getMag()+" of "+deck.get(5).getSuit()+" is in the middle");
System.out.println("The "+deck.get(6).getMag()+" of "+deck.get(6).getSuit()+" is in the middle");
System.out.println("");
System.out.println("You have "+userPool+" coins left.");
System.out.println("Computer has "+compPool+" coins left.");
System.out.println("There are "+midPool+" in the middle.");
System.out.println("");
System.out.println("type anything to continue");
Scanner slow2 = new Scanner(System.in);
String Slow2 = slow2.nextLine();

//4th community card draw (next card in deck, 7)
System.out.println("The 4th community card will now be drawn.");
draws[7] = deck.get(7);
deck.remove(draws[7]);
System.out.println("The "+deck.get(7).getMag()+" of "+deck.get(7).getSuit()+" was drawn.");

//round 3 computer betting


int r3CBetRand = 0;
while(true) {
int r3CPower = 0;
if(r3RaiseChoice>0&&r3RaiseChoice<2001) {
r3CPower=r3CPower+(r3RaiseChoice/100);
}

//functions statements to increase r3CPower.

r3CPower+=checkCFlush(draws, 6);
r3CPower+=checkCStraight(draws, 6);
r3CPower+=checkCNOfKind(draws, 6);

if(r3CPower>=15 && r3CPower<1000) {
Random random = new Random();
r3CBetRand = random.nextInt(10000 + 1 - 3000) + 3000;
} else if(r3CPower==14) {
Random random = new Random();
r3CBetRand = random.nextInt(7500 + 1 - 1000) + 1000;
} else if(r3CPower==13) {
Random random = new Random();
r3CBetRand = random.nextInt(5000 + 1 - 500) + 500;
} else if(r3CPower==12) {
Random random = new Random();
r2CBetRand = random.nextInt(4000 + 1 - 500) + 500;
} else if(r3CPower==11) {
Random random = new Random();
r3CBetRand = random.nextInt(3000 + 1 - 500) + 500;
} if(r3CPower>=10) {
Random random = new Random();
r3CBetRand = random.nextInt(2000 + 1 - 500) + 500;
} else if(r3CPower==9) {
Random random = new Random();
r3CBetRand = random.nextInt(1500 + 1 - 750) + 750;
}else if(r3CPower==8) {
Random random = new Random();
r2CBetRand = random.nextInt(1000 + 1 - 500) + 500;

}else if(r3CPower==7) {
Random random = new Random();
r2CBetRand = random.nextInt(800 + 1 - 300) + 300;

}else if(r3CPower==6) {
Random random = new Random();
r2CBetRand = random.nextInt(600 + 1 - 300) + 300;

}else if(r3CPower==5) {
Random random = new Random();
r3CBetRand = random.nextInt(600 + 1 - 100) + 100;

}else if(r3CPower==4) {
Random random = new Random();
r3CBetRand = random.nextInt(500 + 1 - 50) + 50;

}else if(r3CPower==3) {
Random random = new Random();
r3CBetRand = random.nextInt(500 + 1);

}else if(r3CPower==2) {
Random random = new Random();
r3CBetRand = random.nextInt(250 + 1);

}else if(r3CPower==1) {
Random random = new Random();
r3CBetRand = random.nextInt(100 + 1);
}else if(r3CPower==0) {
Random random = new Random();
r3CBetRand = random.nextInt(1);
}else {
Random random = new Random();
r3CBetRand = random.nextInt(1);
}

if(r3CBetRand>compPool) {
r3CBetRand=compPool;
}
if(r3CBetRand>=r3RaiseChoice) {
break;
}else {
continue;
}
}
r3CBetRand=3*r3CBetRand;

if(r3CBetRand>compPool) {
r3CBetRand=compPool;
}

compPool=compPool-r3CBetRand;
midPool=midPool+r3CBetRand;


System.out.println("The computer bet "+r3CBetRand+" coins it now has "+compPool+" coins.");



//round 3 player betting


System.out.println("Would you like to 'raise', 'match' the computer or 'fold'?");
String r3BetChoice;
while(true) {

Scanner userInput3 = new Scanner(System.in);
r3BetChoice = userInput3.nextLine();

if(r3BetChoice.equals("fold")||r3BetChoice.equals("match")||r3BetChoice.equals("raise")) {
break;
}else {
System.out.println("'raise', 'match' or 'fold' try again");
continue;
}
}
if(r3BetChoice.equals("fold")) {
System.out.println("Player has folded, moving on.");
compPool=compPool+midPool;
midPool=0;
break;
}else if(r3BetChoice.equals("match")){
System.out.println("Player has matched the computer");
userPool=userPool-r3CBetRand;
midPool=midPool+r3CBetRand;
System.out.println("Computer has matched, moving on.");
break;
}else if(r3BetChoice.equals("raise")) {
System.out.println("How many coins would you like to raise");

while(true) {
r3RaiseChoice = userInput.nextInt();
if(r3RaiseChoice>0) {
break;
}else {
System.out.println("Must be positive, try again");
}
}
userPool=userPool-r3RaiseChoice;
midPool=midPool+r3RaiseChoice;
System.out.print("Player raised "+r3RaiseChoice+" coins.");
if(r3RaiseChoice>0&&r3RaiseChoice<7501) {
int compMatchRaiseChance;
Random random = new Random();
compMatchRaiseChance = random.nextInt(3);
if(compMatchRaiseChance==0||compMatchRaiseChance==1||compMatchRaiseChance==2) {
compPool=compPool-r3RaiseChoice;
midPool=midPool+r3RaiseChoice;
System.out.println("The computer has matched your raise, moving on.");
continue;
}
} else if(r3RaiseChoice>7500) {
userPool=userPool+midPool;
midPool=0;
System.out.println("Computer has folded, moving on.");
break;
}
}
}



if(userPool<=0) {
System.out.println("You lost!");
break;
} else if (compPool<=0) {
System.out.println("You win!");
break;
}

//reminders


System.out.println("Reminders:");
System.out.println("You have the "+deck.get(0).getMag()+" of "+deck.get(0).getSuit());
System.out.println("You have the "+deck.get(1).getMag()+" of "+deck.get(1).getSuit());
System.out.println("");
System.out.println("The "+deck.get(4).getMag()+" of "+deck.get(4).getSuit()+" is in the middle");
System.out.println("The "+deck.get(5).getMag()+" of "+deck.get(5).getSuit()+" is in the middle");
System.out.println("The "+deck.get(6).getMag()+" of "+deck.get(6).getSuit()+" is in the middle");
System.out.println("The "+deck.get(7).getMag()+" of "+deck.get(7).getSuit()+" is in the middle");
System.out.println("You have "+userPool+" coins left.");
System.out.println("");
System.out.println("Computer has "+compPool+" coins left.");
System.out.println("There are "+midPool+" in the middle.");
System.out.println("");
System.out.println("type anything to continue");
Scanner slow3 = new Scanner(System.in);
String Slow3 = slow3.nextLine();

//final community card draw (next card in deck, 8)
System.out.println("The 5th community card will now be drawn.");
draws[8] = deck.get(8);
deck.remove(draws[8]);
System.out.println("The "+deck.get(8).getMag()+" of "+deck.get(8).getSuit()+" was drawn.");


//final comp betting

int r4CBetRand = 0;
while(true) {
int r4CPower = 0;
if(r4RaiseChoice>0&&r3RaiseChoice<2001) {
r4CPower=r4CPower+(r4RaiseChoice/100);
}

//functions statements to increase r4CPower.

r4CPower+=checkCFlush(draws, 6);
r4CPower+=checkCStraight(draws, 6);
r4CPower+=checkCNOfKind(draws, 6);

if(r4CPower>=24 && r4CPower<1000) {
Random random = new Random();
r4CBetRand = random.nextInt(10000 + 1 - 3000) + 300;
} else if(r4CPower==23) {
Random random = new Random();
r4CBetRand = random.nextInt(7500 + 1 - 1000) + 1000;
} else if(r4CPower==22) {
Random random = new Random();
r4CBetRand = random.nextInt(5000 + 1 - 500) + 500;
} else if(r4CPower==21) {
Random random = new Random();
r4CBetRand = random.nextInt(4000 + 1 - 500) + 500;
} else if(r4CPower==20) {
Random random = new Random();
r4CBetRand = random.nextInt(3000 + 1 - 500) + 500;
} if(r4CPower>=19) {
Random random = new Random();
r4CBetRand = random.nextInt(2000 + 1 - 500) + 500;
} else if(r4CPower==18) {
Random random = new Random();
r4CBetRand = random.nextInt(1500 + 1 - 750) + 750;
}else if(r4CPower==17) {
Random random = new Random();
r4CBetRand = random.nextInt(1000 + 1 - 500) + 500;

}else if(r4CPower==16) {
Random random = new Random();
r4CBetRand = random.nextInt(800 + 1 - 300) + 300;

}else if(r4CPower==15) {
Random random = new Random();
r4CBetRand = random.nextInt(600 + 1 - 300) + 300;

}else if(r4CPower==14) {
Random random = new Random();
r4CBetRand = random.nextInt(600 + 1 - 100) + 100;

}else if(r4CPower==13) {
Random random = new Random();
r4CBetRand = random.nextInt(500 + 1 - 50) + 50;

}else if(r4CPower==11) {
Random random = new Random();
r4CBetRand = random.nextInt(500 + 1);

}else if(r4CPower==10) {
Random random = new Random();
r4CBetRand = random.nextInt(250 + 1);

}else if(r4CPower>=1) {
Random random = new Random();
r4CBetRand = random.nextInt(100 + 1);
}else if(r4CPower==0) {
Random random = new Random();
r4CBetRand = random.nextInt(1);
}else {
Random random = new Random();
r4CBetRand = random.nextInt(1);
}

if(r4CBetRand>compPool) {
r4CBetRand=compPool;
}
if(r4CBetRand>=r4RaiseChoice) {
break;
}else {
continue;
}
}
r4CBetRand=3*r4CBetRand;
if(r4CBetRand>compPool) {
r4CBetRand=compPool;
}
compPool=compPool-r4CBetRand;
midPool=midPool+r4CBetRand;

System.out.println("The computer bet "+r4CBetRand+" coins it now has "+compPool+" coins.");

//final player betting

System.out.println("Would you like to 'raise', 'match' the computer or 'fold'?");
String r3BetChoice;
Scanner userInput4 = new Scanner(System.in);
userInput4 = new Scanner(System.in);
String r4BetChoice = userInput4.nextLine();

while(true) {





if(r4BetChoice.equals("fold")||r4BetChoice.equals("match")||r4BetChoice.equals("raise")) {
break;
}else {
System.out.println("'raise', 'match' or 'fold' try again");
continue;
}
}
if(r4BetChoice.equals("fold")) {
System.out.println("Player has folded, moving on.");
compPool=compPool+midPool;
midPool=0;
break;

}else if(r4BetChoice.equals("match")){
System.out.println("Player has matched the computer");
userPool=userPool-r4CBetRand;
midPool=midPool+r4CBetRand;
System.out.println("Computer has matched, moving on.");
}else if(r4BetChoice.equals("raise")) {
System.out.println("How many coins would you like to raise");

while(true) {
r4RaiseChoice = userInput4.nextInt();
if(r4RaiseChoice>0) {
break;
}else {
System.out.println("Must be positive, try again");
}
}
userPool=userPool-r4RaiseChoice;
midPool=midPool+r4RaiseChoice;
System.out.print("Player raised "+r4RaiseChoice+" coins.");
if(r4RaiseChoice>0&&r4RaiseChoice<7501) {
int compMatchRaiseChance;
Random random = new Random();
compMatchRaiseChance = random.nextInt(3);
if(compMatchRaiseChance==0||compMatchRaiseChance==1||compMatchRaiseChance==2) {
compPool=compPool-r4RaiseChoice;
midPool=midPool+r4RaiseChoice;
System.out.println("The computer has matched your raise, moving on.");
continue;
}
} else if(r4RaiseChoice>10000) {
userPool=userPool+midPool;
midPool=0;
System.out.println("Computer has folded, moving on.");
break;
}
}



//round win conditions
if(straightC && flushC) {
straightFlushC=true;
}
if(threeOfAKindC && twoOfAKindC) {
fullHouseC=true;

}

if(royalFlushC || royalFlushP) {
if(royalFlushC && royalFlushP) {
compPool+=midPool/2;
userPool+=midPool/2;
midPool=0;
System.out.println("You tied with a royal flush.");
}
if(royalFlushC) {
compPool+=midPool;
System.out.println("You lost against a royal flush.");
}
if(royalFlushP) {
userPool+=midPool;
System.out.println("You won with a royal flush.");
}
midPool=0;
}else if(straightFlushC || straightFlushP) {
if(straightFlushC && straightFlushP) {
compPool+=midPool/2;
userPool+=midPool/2;
midPool=0;
System.out.println("You tied with a straight flush.");
}
if(straightFlushC) {
compPool+=midPool;
System.out.println("You lost against a straigt flush.");
}
if(straightFlushP) {
userPool+=midPool;
System.out.println("You won with a straight flush.");
}
midPool=0;
}else if(fourOfAKindC || fourOfAKindP) {
if(fourOfAKindC && fourOfAKindP) {
compPool+=midPool/2;
userPool+=midPool/2;
midPool=0;
System.out.println("You tied with four of a kind.");
}
if(fourOfAKindC) {
compPool+=midPool;
System.out.println("You lost against four of a kind.");
}
if(fourOfAKindP) {
userPool+=midPool;
System.out.println("You won with four of a kind.");
}
midPool=0;
}else if(fullHouseC || fullHouseP) {
if(fullHouseC && fullHouseP) {
compPool+=midPool/2;
userPool+=midPool/2;
midPool=0;
System.out.println("You tied with a full house.");
}
if(fullHouseC) {
compPool+=midPool;
System.out.println("You lost against a full house.");
}
if(fullHouseP) {
userPool+=midPool;
System.out.println("You won with a full house.");
}
midPool=0;
}else if(flushC || flushP) {
if(flushC && flushP) {
compPool+=midPool/2;
userPool+=midPool/2;
midPool=0;
System.out.println("You tied with a flush.");
}
if(flushC) {
compPool+=midPool;
System.out.println("You lost against a flush.");
}
if(flushP) {
userPool+=midPool;
System.out.println("You won with a flush.");
}
midPool=0;
}else if(straightC || straightP) {
if(straightC && straightP) {
compPool+=midPool/2;
userPool+=midPool/2;
midPool=0;
System.out.println("You tied with a straight.");
}
if(straightC) {
compPool+=midPool;
System.out.println("You lost against a straight.");
}
if(straightP) {
userPool+=midPool;
System.out.println("You won with a straight.");
}
midPool=0;
}else if(threeOfAKindC || threeOfAKindP) {
if(threeOfAKindC && threeOfAKindP) {
compPool+=midPool/2;
userPool+=midPool/2;
midPool=0;
System.out.println("You tied with three of a kind.");
}
if(threeOfAKindC) {
compPool+=midPool;
System.out.println("You lost against three of a kind.");
}
if(threeOfAKindP) {
userPool+=midPool;
System.out.println("You won with three of a kind.");
}
midPool=0;
}else if(twoPairC || twoPairP) {
if(twoPairC && twoPairP) {
compPool+=midPool/2;
userPool+=midPool/2;
midPool=0;
System.out.println("You tied with two pair");
}
if(twoPairC) {

compPool+=midPool;
System.out.println("You lost against two pair.");
}

if(twoPairP) {
userPool+=midPool;
System.out.println("You won with two pair.");
}

midPool=0;

}else if(twoOfAKindC || twoOfAKindP) {
if(twoOfAKindC && twoOfAKindP) {
compPool+=midPool/2;
userPool+=midPool/2;
midPool=0;
System.out.println("You tied with a pair");
}

if(twoOfAKindC) {
compPool+=midPool;
System.out.println("You lost against a pair.");
}

if(twoOfAKindP) {
userPool+=midPool;
System.out.println("You won with a pair.");
}

midPool=0;
}else if(highCard(draws)>0) {
userPool+=midPool;
midPool=0;
System.out.println("You won with a high card.");
}else if(highCard(draws)<0) {
compPool+=midPool;
midPool=0;
System.out.println("You lost against a high card.");
}else if(highCard(draws)==0) {
compPool+=midPool/2;
userPool+=midPool/2;
midPool=0;
System.out.println("You tied with a high card.");
}else {
System.out.println("HAHAHA");
}


System.out.println("type anything to continue");
Scanner slow5 = new Scanner(System.in);
String Slow5 = slow5.nextLine();


System.out.println("Round has ended.");
System.out.println("");
System.out.println("Player had "+deck.get(0).getMag()+" of "+deck.get(0).getMag());
System.out.println("Player had "+deck.get(1).getMag()+" of "+deck.get(1).getMag());
System.out.println("");
System.out.println("Computer had "+deck.get(2).getMag()+" of "+deck.get(2).getMag());
System.out.println("Computer had "+deck.get(3).getMag()+" of "+deck.get(3).getMag());
System.out.println("");
System.out.println("Player has "+userPool+" coins while Computer has "+compPool+" coins.");
System.out.println("");
System.out.println("Would you like to 'keep playing'?");

//game win conditions
if(userPool<=0) {
System.out.println("You lost!");
break;
} else if (compPool<=0) {
System.out.println("You win!");
break;
}
}
}
}
[Image: eG5bfTp.gif]
5th | jimvitational gang
[Image: 0loD30b.png]

https://imgur.com/AwgcYdo.png
Reply
#2
Just when everyone in swoobles was wondering why you hadn’t shitposted in a few days.


Good job I guess I can’t read it
Reply
#3
Interesting - what class are you taking?
Reply
#4
It's hard to read code like this without the proper indentation. Also your naming of variables and classes is kind of confusing.
Reply
#5
in getMag() you should consider using a switch statement, much easier than writing a wall of if statements
Reply
#6
Rainbow 
I had Eclipse installed on one of my computer so I actually tried your program. It's pretty good for your first program since Texas Hold em is a pretty complicated process and you made an AI as an opponent. However, I have few tips on how to improve your code:

  • Like Hymns said, your naming is pretty confusing and some variables were useless. For instance, you can just use the same scanner for each round.
  • Your main is way too long. You need to add more functions, like the checkSomething() functions at the top, because you have a lot of repetition in your code and it's really hard to read. You get lost and it's probably the reason why not all your features work.
    Every single process or complex calculation should be a function (or a method). Then, in your main, you should only be calling the functions in the right order. This will also help you for debugging since you will know exactly which function isn't working properly. 
    I remember that my teacher made us do 3 times the same program. First time: all the code in the main, second time: main + functions and third time: main + functions + methods in objects. This helped us so much to understand why functions and methods are so important (even more if you do event-driven programming).

  • When you do a while(true) {}, you shouldn't use continue; or break; because you can simply put your condition inside the while which will, again, make your code easier to read
    This is an exemple directly taken from your code: 


String r2BetChoice;
Scanner userInput2 = new Scanner(System.in);
while(true) {
    r2BetChoice = userInput2.nextLine();

    if(r2BetChoice.equals("fold")||r2BetChoice.equals("match")||r2BetChoice.equals("raise")) {
         break;
    }else {
        System.out.println("'raise', 'match' or 'fold' try again");
        continue;
    }
}


String r2BetChoice = "";
Scanner userInput2 = new Scanner(System.in);
while(!(r2BetChoice.equals("fold")||r2BetChoice.equals("match")||r2BetChoice.equals("raise"))) {
    r2BetChoice = userInput2.nextLine();

    if(!(r2BetChoice.equals("fold")||r2BetChoice.equals("match")||r2BetChoice.equals("raise"))) {
        System.out.println("'raise', 'match' or 'fold' try again");
    }
}




These are the few things that I noticed right away, I didn't check your algorithms, but keep going and you will improve!
Reply
#7
Thanks for the tips guys. Yea sorry for it being hard to read i just started. I only learned how to make functions half way through writing it!

Thanks for the switch statement pavlo looks very useful.

Chickens yea lmao i know the main is way 2 long thats the first thing monster said when he saw this.

Hymns i tried to name the variables and stuff sensibly but yea its all pretty weird. Lol

I know you can but stuff like that in the while loops chickens, my teacher just taught us to do it that way. In all fairness he only had like 3 days to teach us java. And hes a junior in college.

In the future i shall endeavor to make shorter mains and make readable programs. Thanks everyone
[Image: eG5bfTp.gif]
5th | jimvitational gang
[Image: 0loD30b.png]

https://imgur.com/AwgcYdo.png
Reply
#8
Just a tip for class names, they generally should always be a singular noun. Any object is a singular thing. Even if it is a container, like an ArrayList, the object in question is the container itself, not its contents, therefore the name is singular. And especially in Java it is convention to name the class starting with a capital letter. Finally, the class name almost certainly shouldn't have the word "class" in it. Firstly because the objects instantiated from that class are not "classes" in themselves, and secondly because you should always try to avoid using protected keywords in identifiers. For example you wouldn't name a variable "void" or "if". If it doesn't cause an error, it is still considered bad form.
Reply
#9
https://bpaste.net/

copy paste your code here, and before you do that, in eclipse do ctrl-a then ctrl-i.

hymn already said this but convention is:
fields(class variables) - lower case first letter
classes - upper case fire letter
methods - lower case fire letter

you should look into using methods(functions) to simplify your code. 

Also comments, I like to include java docs, regular comments and bookmarks of sorts. Also never delete test cases, always comment them out, but I also recommend making another class to test unlike the bottom of this paste.
https://bpaste.net/show/46b88951c252
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)