Skip to content

Commit

Permalink
heavy refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Leveille authored and Leveille committed Apr 2, 2019
1 parent 01f6c86 commit c76bbfc
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 269 deletions.
26 changes: 0 additions & 26 deletions PioHoldem/Source/AI/FishAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,15 @@ public override int GetAction(Game game)
// Fold[1] Check[2] Bet[4]
action = rng.Next(3);
if (action == 0)
{
// Check
return 0;
}
else
{
// Bet 1/2 pot
if (game.pot / 2 < game.players[game.actingIndex].stack)
{
return game.pot / 2;
}
else
{
return game.players[game.actingIndex].stack;
}
}
}
else if (game.betAmt == game.players[game.actingIndex].inFor)
Expand All @@ -41,66 +35,46 @@ public override int GetAction(Game game)
{
// Raise 3x
if ((3 * game.betAmt) - game.players[game.actingIndex].inFor < game.players[game.actingIndex].stack)
{
return (3 * game.betAmt) - game.players[game.actingIndex].inFor;
}
else
{
return game.players[game.actingIndex].stack;
}
}
else
{
// Check
return 0;
}
}
else if (game.players[game.GetPreviousPosition(game.actingIndex)].stack == 0)
{
// Facing an all-in bet
// Call
if (game.betAmt - game.players[game.actingIndex].inFor >= game.players[game.actingIndex].stack)
{
return game.players[game.actingIndex].stack;
}
else
{
return game.betAmt - game.players[game.actingIndex].inFor;
}
}
else
{
// There is an active bet
// Fold[1] Call[3] Raise[5]
action = rng.Next(10);
if (action < 0)
{
// Fold
return -1;
}
else if (action < 5)
{
// Call
if (game.betAmt - game.players[game.actingIndex].inFor >= game.players[game.actingIndex].stack)
{
return game.players[game.actingIndex].stack;
}
else
{
return game.betAmt - game.players[game.actingIndex].inFor;
}
}
else
{
// Raise 3x
if ((3 * game.betAmt) - game.players[game.actingIndex].inFor >= game.players[game.actingIndex].stack)
{
return game.players[game.actingIndex].stack;
}
else
{
return (3 * game.betAmt) - game.players[game.actingIndex].inFor;
}
}
}
}
Expand Down
10 changes: 0 additions & 10 deletions PioHoldem/Source/Game/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,11 @@ static void Main(string[] args)
Console.WriteLine("[1] Human vs Bot\n[2] Bot vs Bot\n[3] Human vs Human");
int gameMode = SelectGameMode();
if (gameMode == 1)
{
players = new Player[] { new HumanPlayer("Chris", startingStack), new BotPlayer("SharkBot", startingStack, shark) };
}
else if (gameMode == 2)
{
players = new Player[] { new BotPlayer("GreatWhite", startingStack, shark), new BotPlayer("Hammerhead", startingStack, shark) };
}
else
{
players = new Player[] { new HumanPlayer("Chris", startingStack), new HumanPlayer("Aaron", startingStack) };
}

//UnitTests();

Expand Down Expand Up @@ -76,14 +70,10 @@ private static void UnitTests()
Card[] hand = new Card[5] { c1, c2, c3, c4, c5 };
Card[] hand2 = new Card[5] { c8, c9, c10, c11, c12 };
foreach (Card card in hand)
{
Console.Write("|" + card);
}
Console.WriteLine("|");
foreach (Card card in hand2)
{
Console.Write("|" + card);
}
Console.WriteLine("|");

HandEvaluator eval = new HandEvaluator();
Expand Down
6 changes: 0 additions & 6 deletions PioHoldem/Source/Game/Deck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ public Deck()
for (int suit = 0; suit < 4; suit++)
{
for (int value = 0; value < 13; value++)
{
cards[13 * suit + value] = new Card(suit, value);
}
}
topIndex = 0;
rng = new Random();
Expand Down Expand Up @@ -52,9 +50,7 @@ public Card[] Deal(int count)
{
Card[] toReturn = new Card[count];
for (int i = 0; i < count; i++)
{
toReturn[i] = Deal();
}
return toReturn;
}

Expand All @@ -68,9 +64,7 @@ public override string ToString()
{
string toReturn = "";
foreach (Card card in cards)
{
toReturn += "|" + card;
}
return toReturn + "|";
}
}
Expand Down
Loading

0 comments on commit c76bbfc

Please sign in to comment.