add 84 (WIP)

This commit is contained in:
Dr. Matthias Ratajczak
2022-09-27 14:33:24 +02:00
parent b3d791a966
commit 6e3fd96169
3 changed files with 101 additions and 0 deletions
+9
View File
@@ -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"
+89
View File
@@ -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();
}
}
+3
View File
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}