parent
2360986a96
commit
c64908621d
18
src/azul.rs
18
src/azul.rs
|
@ -1,4 +1,4 @@
|
||||||
use std::{hash::{Hash, Hasher}, ops::{Deref, DerefMut}};
|
use std::{hash::Hash, ops::{Deref, DerefMut}};
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use rand::distributions::WeightedIndex;
|
use rand::distributions::WeightedIndex;
|
||||||
//use smallvec::{SmallVec, smallvec};
|
//use smallvec::{SmallVec, smallvec};
|
||||||
|
@ -402,8 +402,8 @@ impl Board {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(packed)]
|
//#[repr(align(16))]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
pub struct Game {
|
pub struct Game {
|
||||||
turn: u32,
|
turn: u32,
|
||||||
player: u8,
|
player: u8,
|
||||||
|
@ -660,18 +660,6 @@ impl Game {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn any_as_u8_slice<T: Sized>(p: &T) -> &[u8] {
|
|
||||||
::std::slice::from_raw_parts(
|
|
||||||
(p as *const T) as *const u8,
|
|
||||||
::std::mem::size_of::<T>(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
impl Hash for Game {
|
|
||||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
|
||||||
unsafe{any_as_u8_slice(self).deref().hash(state)}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tests
|
// Tests
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ fn calculate_options() -> Result<(), &'static str> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cached(size=10_000_000, key = "Game", convert = r#"{ _game }"#)]
|
#[cached(size=45_000_000, key = "Game", convert = r#"{ _game }"#)]
|
||||||
fn count_options(_game: Game, depth: u8, treshold: u8) -> u128 {
|
fn count_options(_game: Game, depth: u8, treshold: u8) -> u128 {
|
||||||
let before = std::time::Instant::now();
|
let before = std::time::Instant::now();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue