Camel Up is a game of chance.
Since probability questions are often very hard. This crate provides an oracle to answer questions concerning which camel will come out ahead in the race.
To determine who has the better winning chance of two camels, where one camel has fallen two behind one could use the following code.
use camel_up::prelude::*; let race = "r,,w".parse::<Race>().expect("to parse"); let dice = "rw".parse::<Dice>().expect("to parse"); let result = project(&race, &dice); let red_chance = result.winner[&Camel::Red]; let white_chance = result.winner[&Camel::White]; assert!(white_chance > red_chance);
As the above example shows one can parse a string and get a
Race. The following table describes each symbol.alloc
As per the rules of the game, camels can not be in a oasis or a fata morgana, nor can either of those be next to each other. So the following strings all fail to parse.
use camel_up::camel::*; assert_eq!("r|y".parse::<Race>(), Err(RaceParseError::NotAMarker(NotAMarker::But("|".to_owned())))); assert_eq!("+r,y".parse::<Race>(), Err(RaceParseError::CamelInOasis)); assert_eq!("-r,y".parse::<Race>(), Err(RaceParseError::CamelInFataMorgana)); assert_eq!("r,-+,y".parse::<Race>(), Err(RaceParseError::ToManyAdjustmentsInOnePosition)); assert_eq!("r,-,+,y".parse::<Race>(), Err(RaceParseError::ConsecutiveAdjustments));
Dice can be similarly parsed. The only allowed symbols are the ones for the camels.
The camel module models Camel Up.
provides a means to calculate with fractions.
An oracle is
Easy access to a good combination of camel up related concepts.