/******************************************************************************* * * Copyright (c) 2006 Javaflair. All Rights Reserved. * ******************************************************************************/ import com.javaflair.pokerprophesier.api.adapter.PokerProphesierAdapter; import com.javaflair.pokerprophesier.api.card.Card; import com.javaflair.pokerprophesier.api.card.CommunityCards; import com.javaflair.pokerprophesier.api.card.HoleCards; import com.javaflair.pokerprophesier.api.exception.SimulatorException; import com.javaflair.pokerprophesier.api.helper.PlayerGameStatsHelper; import com.javaflair.pokerprophesier.api.helper.UpdateHelper; /** * An example of using the Player vs Player simulator. * * @author Javaflair */ public class PlayerSimulatorExample{ /** * Run the example. */ public void runExample(){ // Number of simulations int numSimulations= 100000; // Create an adapter to communicate with the simulator PokerProphesierAdapter adapter= new PokerProphesierAdapter(); // Try the update helper try{ UpdateHelper updateHelper= adapter.getUpdateHelper(); System.out.println("UpdateHelper:\n" + updateHelper); } catch (SimulatorException e){ e.printStackTrace(); } // Create the hole cards for 5 players HoleCards[] holeCards= new HoleCards[5]; // Player #1 holeCards[0]= new HoleCards(new Card(Card.ACE, Card.CLUBS), new Card( Card.KING, Card.CLUBS)); // Player #2 holeCards[1]= new HoleCards(new Card(Card.ACE, Card.HEARTS), new Card( Card.ACE, Card.DIAMONDS)); // Player #3 - empty (leave as null) // Player #4 - folded holeCards[3]= new HoleCards(new Card(Card.NINE, Card.HEARTS), new Card( Card.EIGHT, Card.DIAMONDS)); holeCards[3].setFolded(true); // Player #5 holeCards[4]= new HoleCards(new Card(Card.TEN, Card.SPADES), new Card( Card.JACK, Card.DIAMONDS)); // Create the community cards CommunityCards communityCards= new CommunityCards(new Card[]{ new Card(Card.KING, Card.SPADES), new Card(Card.JACK, Card.HEARTS), new Card(Card.TEN, Card.HEARTS)}); // Set the simulator parameters adapter.setNumSimulations(numSimulations); // Record the time long start= System.currentTimeMillis(); // Run the simulator try{ adapter.runPlayerSimulations(holeCards, communityCards, PokerProphesierAdapter.FLOP_CARDS_DEALT); } catch (SimulatorException e){ e.printStackTrace(); } // Get the time taken long totalTime= System.currentTimeMillis() - start; System.out.println("-\nTime taken to run simulations: " + (totalTime / (float)1000) + " secs"); // Get the PlayerGameStatsHelper PlayerGameStatsHelper playerGameStatsHelper= adapter .getPlayerGameStatsHelper(); System.out .println("-\nplayerGameStatsHelper:\n" + playerGameStatsHelper); } /** * Main. * * @param args */ public static void main(String[] args){ PlayerSimulatorExample inst= new PlayerSimulatorExample(); inst.runExample(); } }