diff --git a/src/euler84/Cargo.toml b/src/euler84/Cargo.toml new file mode 100644 index 0000000..1979f36 --- /dev/null +++ b/src/euler84/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "euler84" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +rand = "0.8.5" diff --git a/src/euler84/src/lib.rs b/src/euler84/src/lib.rs new file mode 100644 index 0000000..ba699a2 --- /dev/null +++ b/src/euler84/src/lib.rs @@ -0,0 +1,89 @@ +use rand::prelude::*; +use rand::seq::IteratorRandom; + +enum Squares { + Go = 0, + A1 = 1, + CC1 = 2, + A2 = 3, + T1 = 4, + R1 = 5, + B1 = 6, + Ch1 = 7, + B2 = 8, + B3 = 9, + Jail = 10, + C1 = 11, + U1 = 12, + C2 = 13, + C3 = 14, + R2 = 15, + D1 = 16, + CC2 = 17, + D2 = 18, + D3 = 19, + FP = 20, + E1 = 21, + Ch2 = 22, + E2 = 23, + E3 = 24, + R3 = 25, + F1 = 26, + F2 = 27, + U2 = 28, + F3 = 29, + G2j = 30, + G1 = 31, + G2 = 32, + Cc3 = 33, + G3 = 34, + R4 = 35, + Ch3 = 36, + H1 = 37, + T2 = 38, + H2 = 39, +} + +enum CommunityChest { + AdvanceToGo, + GoToJail, +} + +enum Chance { + AdvanceToGo, + GoToJail, + GoToC1, + GoToE3, + GoToH2, + GoToR1, + GoToNextR, + GoToNextRAgain, + GoToNextU, + GoBack3Squares, +} + +enum Dice { + FourSided = 4, + SixSided = 6, +} + +impl Dice { + fn throw(&self, rng: &mut ThreadRng) -> isize { + match self { + Self::SixSided => (1..=6).choose(rng).unwrap(), + Self::FourSided => (1..=4).choose(rng).unwrap(), + } + } +} + +struct Monopoly { + position: Squares, + dice: Dice, +} + +impl Monopoly { + fn throw_dice(&mut self) { + let mut rng = rand::thread_rng(); + let result: isize = (0..2).map(|_| self.dice.throw(&mut rng)).sum(); + } +} diff --git a/src/euler84/src/main.rs b/src/euler84/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/euler84/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}