Skip to content

Commit 9ae2277

Browse files
committed
clap integration for feature flagging
1 parent b2cf46b commit 9ae2277

File tree

4 files changed

+47
-15
lines changed

4 files changed

+47
-15
lines changed

src/clustering/layer.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ impl Layer {
3636
#[cfg(feature = "native")]
3737
pub fn learn() {
3838
use crate::save::disk::Disk;
39+
Street::all()
40+
.into_iter()
41+
.rev()
42+
.filter(|&&s| Self::done(s))
43+
.for_each(|_| log::info!("{:<32}{:<32}", "using kmeans layer", Self::name()));
3944
Street::all()
4045
.into_iter()
4146
.rev()
@@ -238,7 +243,12 @@ impl Layer {
238243
#[cfg(feature = "native")]
239244
impl crate::save::disk::Disk for Layer {
240245
fn name() -> String {
241-
unimplemented!()
246+
format!(
247+
"{:<16}{:<16}{:<16}",
248+
Lookup::name(),
249+
Decomp::name(),
250+
Metric::name()
251+
)
242252
}
243253
fn done(street: Street) -> bool {
244254
Lookup::done(street) && Decomp::done(street) && Metric::done(street)

src/lib.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ pub use gameplay::*;
1818
pub use mccfr::*;
1919
pub use transport::*;
2020
pub use wasm::*;
21-
2221
/// dimensional analysis types
2322
type Chips = i16;
2423
type Equity = f32;
@@ -65,6 +64,25 @@ const SAMPLING_EXPLORATION: Probability = 0.01;
6564
const POLICY_MIN: Probability = Probability::MIN_POSITIVE;
6665
const REGRET_MIN: Utility = -3e5;
6766

67+
#[derive(clap::Parser, Debug)]
68+
#[command(author, version, about, long_about = None)]
69+
#[cfg(feature = "native")]
70+
/// Simple program to run robopoker routines
71+
pub struct Args {
72+
/// Run the clustering algorithm
73+
#[arg(long)]
74+
pub cluster: bool,
75+
/// Run the MCCFR training
76+
#[arg(long)]
77+
pub solve: bool,
78+
/// Publish results to the database
79+
#[arg(long)]
80+
pub publish: bool,
81+
/// Run the analysis server
82+
#[arg(long)]
83+
pub analyze: bool,
84+
}
85+
6886
/// trait for random generation, mainly (strictly?) for testing
6987
pub trait Arbitrary {
7088
fn random() -> Self;

src/main.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
use clap::Parser;
12
use robopoker::*;
23

34
#[tokio::main]
45
async fn main() {
5-
// Behold!
66
crate::init();
7-
// The k-means earth mover's distance hand-clustering algorithm.
8-
crate::clustering::Layer::learn();
9-
// Monte Carlo counter-factual regret minimization. External sampling, alternating regret updates, linear weighting schedules.
10-
crate::mccfr::NLHE::train();
11-
// Let's upload the data to the database.
12-
crate::save::Writer::publish().await.unwrap();
13-
// Let's support our api.
14-
crate::analysis::Server::run().await.unwrap();
7+
if crate::Args::parse().cluster {
8+
crate::clustering::Layer::learn();
9+
}
10+
if crate::Args::parse().solve {
11+
crate::mccfr::NLHE::train();
12+
}
13+
if crate::Args::parse().publish {
14+
crate::save::Writer::publish().await.unwrap();
15+
}
16+
if crate::Args::parse().analyze {
17+
crate::analysis::Server::run().await.unwrap();
18+
}
1519
}
1620

1721
/*
@@ -44,12 +48,12 @@ async fn main() {
4448
2015. Simultaneous Abstraction and Equilibrium Finding in Games. (http://www.cs.cmu.edu/~sandholm/simultaneous.ijcai15.pdf) In IJCAI.
4549
2015. Limited Lookahead in Imperfect-Information Games. (http://www.cs.cmu.edu/~sandholm/limited-look-ahead.ijcai15.pdf) IJCAI.
4650
2015. Faster First-Order Methods for Extensive-Form Game Solving. (http://www.cs.cmu.edu/~sandholm/faster.ec15.pdf) In EC.
47-
2015. Hierarchical Abstraction, Distributed Equilibrium Computation, and Post-Processing, with Application to a Champion No-Limit Texas Holdem Agent. (http://www.cs.cmu.edu/~sandholm/hierarchical.aamas15.pdf) In AAMAS.
51+
2015. Hierarchical Abstraction, Distributed Equilibrium Computation, and Post-Processing, with Application to a Champion No-Limit Texas Hold'em Agent. (http://www.cs.cmu.edu/~sandholm/hierarchical.aamas15.pdf) In AAMAS.
4852
2015. Discretization of Continuous Action Spaces in Extensive-Form Games. (http://www.cs.cmu.edu/~sandholm/discretization.aamas15.fromACM.pdf) In AAMAS.
4953
2015. Endgame Solving in Large Imperfect-Information Games. (http://www.cs.cmu.edu/~sandholm/endgame.aamas15.fromACM.pdf) In AAMAS.
5054
2014. Extensive-Form Game Abstraction With Bounds. (http://www.cs.cmu.edu/~sandholm/extensiveGameAbstraction.ec14.pdf) In EC.
5155
2014. Regret Transfer and Parameter Optimization. (http://www.cs.cmu.edu/~sandholm/regret_transfer.aaai14.pdf) In AAAI.
52-
+ 2014. Potential-Aware Imperfect-Recall Abstraction with Earth Movers Distance in Imperfect-Information Games. (http://www.cs.cmu.edu/~sandholm/potential-aware_imperfect-recall.aaai14.pdf) In AAAI.
56+
+ 2014. Potential-Aware Imperfect-Recall Abstraction with Earth Mover's Distance in Imperfect-Information Games. (http://www.cs.cmu.edu/~sandholm/potential-aware_imperfect-recall.aaai14.pdf) In AAAI.
5357
+ 2013. Action Translation in Extensive-Form Games with Large Action Spaces: Axioms, Paradoxes, and the Pseudo-Harmonic Mapping. (http://www.cs.cmu.edu/~sandholm/reverse%20mapping.ijcai13.pdf) In IJCAI.
5458
+ 2013. A Fast and Optimal Hand Isomorphism Algorithm. (https://www.cs.cmu.edu/~waugh/publications/isomorphism13.pdf). In AAAI.
5559
2012. Lossy Stochastic Game Abstraction with Bounds. (http://www.cs.cmu.edu/~sandholm/lossyStochasticGameAbstractionWBounds.ec12.pdf) In EC.

src/mccfr/traits/profile.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ pub trait Profile {
234234
.inspect(|r| assert!(*r >= 0.))
235235
.map(|r| r.max(crate::POLICY_MIN))
236236
.sum::<crate::Probability>();
237-
let numer = self.activation() + self.threshold() * numer;
238237
let denom = self.activation() + denom;
238+
let numer = self.activation() + numer * self.threshold();
239239
(numer / denom).max(self.exploration())
240240
}
241241

@@ -260,7 +260,7 @@ pub trait Profile {
260260
leaf: &Node<Self::T, Self::E, Self::G, Self::I>,
261261
) -> crate::Probability {
262262
leaf.into_iter()
263-
.take_while(|(parent, _)| parent != root)
263+
.take_while(|(parent, _)| parent != root) // parent.index() > root.index()
264264
.map(|(parent, incoming)| self.outgoing_reach(&parent, &incoming))
265265
.product::<crate::Probability>()
266266
}

0 commit comments

Comments
 (0)