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); }
private static void LoadFromFile() { if (File.Exists(filenameEMDTurnTable)) { Console.WriteLine("Loading turn cluster index from file {0}", filenameEMDTurnTable); turnIndices = FileHandler.LoadFromFileIndex(filenameEMDTurnTable); } if (File.Exists(filenameEMDFlopTable)) { Console.WriteLine("Loading flop cluster index from file {0}", filenameEMDFlopTable); flopIndices = FileHandler.LoadFromFileIndex(filenameEMDFlopTable); } if (flopIndices == null && File.Exists(filenameEMDFlopHistogram)) { Console.WriteLine("Loading flop histograms from file {0}", filenameEMDFlopHistogram); histogramsFlop = FileHandler.LoadFromFile(filenameEMDFlopHistogram); } if (turnIndices == null && File.Exists(filenameEMDTurnHistogram)) { Console.WriteLine("Loading turn histograms from file {0}", filenameEMDTurnHistogram); histogramsTurn = FileHandler.LoadFromFile(filenameEMDTurnHistogram); } }
private static void LoadFromFile() { if (File.Exists(filenameRiverClusters)) { riverIndices = FileHandler.LoadFromFileIndex(filenameRiverClusters); } else { if (File.Exists(filenameRiverHistograms)) { Console.WriteLine("Loading river histograms from file {0}", filenameRiverHistograms); BinaryReader binR = new BinaryReader(File.OpenRead(filenameRiverHistograms)); int dim1 = binR.ReadInt32(); int dim2 = binR.ReadInt32(); histogramsRiver = new float[dim1][]; for (int i = 0; i < dim1; ++i) { histogramsRiver[i] = new float[dim2]; } for (int i = 0; i < dim1; ++i) { for (int j = 0; j < dim2; ++j) { histogramsRiver[i][j] = binR.ReadSingle(); } } } if (File.Exists(filenameOppClusters)) { Console.WriteLine("Loading flop opponent clusters from file {0}", filenameOppClusters); using var fileStream = File.OpenRead(filenameOppClusters); var binForm = new BinaryFormatter(); preflopIndices = (int[])binForm.Deserialize(fileStream); } } }