-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da46b6c
commit faf0ada
Showing
20 changed files
with
202 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
//! #### Authorship | ||
//! - Max Fierro, 2/24/2024 ([email protected]) | ||
use std::fmt::Display; | ||
|
||
use anyhow::Result; | ||
|
||
use crate::database::error::DatabaseError; | ||
|
@@ -123,17 +125,18 @@ impl SchemaBuilder { | |
|
||
/* UTILITY IMPLEMENTATIONS */ | ||
|
||
impl ToString for Datatype { | ||
fn to_string(&self) -> String { | ||
match self { | ||
Datatype::DPFP => "Double-Precision Floating Point".to_string(), | ||
Datatype::SPFP => "Single-Precision Floating Point".to_string(), | ||
Datatype::CSTR => "C-Style ASCII String".to_string(), | ||
Datatype::UINT => "Unsigned Integer".to_string(), | ||
Datatype::SINT => "Signed Integer".to_string(), | ||
Datatype::ENUM => "Enumeration".to_string(), | ||
Datatype::BOOL => "Boolean".to_string(), | ||
} | ||
impl Display for Datatype { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
let content = match self { | ||
Datatype::DPFP => "Double-Precision Floating Point", | ||
Datatype::SPFP => "Single-Precision Floating Point", | ||
Datatype::CSTR => "C-Style ASCII String", | ||
Datatype::UINT => "Unsigned Integer", | ||
Datatype::SINT => "Signed Integer", | ||
Datatype::ENUM => "Enumeration", | ||
Datatype::BOOL => "Boolean", | ||
}; | ||
write!(f, "{}", content) | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,9 +41,9 @@ type Elements = u64; | |
|
||
/* GAME DATA */ | ||
|
||
const NAME: &'static str = "zero-by"; | ||
const AUTHORS: &'static str = "Max Fierro <[email protected]>"; | ||
const ABOUT: &'static str = | ||
const NAME: &str = "zero-by"; | ||
const AUTHORS: &str = "Max Fierro <[email protected]>"; | ||
const ABOUT: &str = | ||
"Many players take turns removing a number of elements from a set of arbitrary \ | ||
size. The game variant determines how many players are in the game, how many \ | ||
elements are in the set to begin with, and the options players have in the \ | ||
|
@@ -193,13 +193,13 @@ impl Bounded for Session { | |
|
||
fn end(&self, state: State) -> bool { | ||
let (_, elements) = self.decode_state(state); | ||
elements <= 0 | ||
elements == 0 | ||
} | ||
} | ||
|
||
impl Codec for Session { | ||
fn decode(&self, string: String) -> Result<State> { | ||
Ok(parse_state(&self, string)?) | ||
Ok(parse_state(self, string)?) | ||
} | ||
|
||
fn encode(&self, state: State) -> Result<String> { | ||
|
@@ -226,8 +226,8 @@ impl<const N: PlayerCount> Extensive<N> for Session { | |
impl<const N: PlayerCount> SimpleUtility<N> for Session { | ||
fn utility(&self, state: State) -> [SUtility; N] { | ||
let (turn, _) = self.decode_state(state); | ||
let mut payoffs = [SUtility::LOSE; N]; | ||
payoffs[turn] = SUtility::WIN; | ||
let mut payoffs = [SUtility::Lose; N]; | ||
payoffs[turn] = SUtility::Win; | ||
payoffs | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.