private static void ClusterPreflopHands() { // k-means clustering Kmeans kmeans = new Kmeans(); preflopIndices = kmeans.ClusterEMD(histogramsPreflop, Global.nofOpponentClusters, 100, null); Console.WriteLine("Created the following cluster for starting hands: "); List <Hand> startingHands = Utilities.GetStartingHandChart(); for (int i = 0; i < 169; ++i) { long index = Global.indexer_2.indexLast(new int[] { startingHands[i].Cards[0].GetIndex(), startingHands[i].Cards[1].GetIndex() }); var nofConsoleColors = Enum.GetNames(typeof(ConsoleColor)).Length; if (nofConsoleColors <= Global.nofOpponentClusters) { Console.ForegroundColor = (ConsoleColor)preflopIndices[index]; Console.Write("X "); Console.ResetColor(); } else { Console.Write(preflopIndices[index] + " "); } if (i % 13 == 12) { Console.WriteLine(); } } Console.WriteLine(); }
private static void ClusterFlop() { // k-means clustering DateTime start = DateTime.UtcNow; Kmeans kmeans = new Kmeans(); int[] indices = FileHandler.LoadFromFileIndex("EMDTableFlop_temp.txt"); flopIndices = kmeans.ClusterEMD(histogramsFlop, Global.nofFlopBuckets, 1, indices); TimeSpan elapsed = DateTime.UtcNow - start; Console.WriteLine("Flop clustering completed in {0}d {1}h {2}m {3}s", elapsed.Days, elapsed.Hours, elapsed.Minutes, elapsed.Seconds); Console.WriteLine("Created the following clusters for the Flop (extract of one cluster): "); int nofEntriesToDisplay = 20; for (int i = 0; i < Global.indexer_2_3.roundSize[1] && nofEntriesToDisplay > 0; ++i) { if (turnIndices[i] == 0) { int[] cards = new int[5]; Global.indexer_2_3.unindex(Global.indexer_2_3.rounds - 1, i, cards); Hand hand = new Hand(); hand.Cards = new List <Card>() { new Card(cards[0]), new Card(cards[1]), new Card(cards[2]), new Card(cards[3]), new Card(cards[4]) }; hand.PrintColoredCards("\n"); nofEntriesToDisplay--; } } if (nofEntriesToDisplay == 0) { Console.WriteLine("..."); } }
private static void ClusterRiver() { // k-means clustering DateTime start = DateTime.UtcNow; Kmeans kmeans = new Kmeans(); int[] indices = FileHandler.LoadFromFileIndex("OCHSRiverClusters_temp.txt"); riverIndices = kmeans.ClusterL2(histogramsRiver, Global.nofRiverBuckets, 1, indices); Console.WriteLine("Created the following clusters for the River: "); int nofExamplesToPrint = 10; for (int i = 0; i < Global.indexer_2_5.roundSize[1]; ++i) { if (riverIndices[i] == 0 && nofExamplesToPrint > 0) { int[] cards = new int[7]; Global.indexer_2_5.unindex(Global.indexer_2_5.rounds - 1, i, cards); Hand hand = new Hand(); hand.Cards.Add(new Card(cards[0])); hand.Cards.Add(new Card(cards[1])); hand.Cards.Add(new Card(cards[2])); hand.Cards.Add(new Card(cards[3])); hand.Cards.Add(new Card(cards[4])); hand.Cards.Add(new Card(cards[5])); hand.Cards.Add(new Card(cards[6])); hand.PrintColoredCards(); Console.WriteLine(); nofExamplesToPrint--; } } TimeSpan elapsed = DateTime.UtcNow - start; Console.WriteLine("River clustering completed in {0}d {1}h {2}m {3}s", elapsed.Days, elapsed.Hours, elapsed.Minutes, elapsed.Seconds); }