cache
This commit is contained in:
parent
f6822b377d
commit
8225206ec5
|
@ -1,5 +1,16 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "ahash"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f200cbb1e856866d9eade941cf3aa0c5d7dd36f74311c4273b494f4ef036957"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"once_cell",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-mutex"
|
||||
version = "1.4.0"
|
||||
|
@ -256,6 +267,7 @@ checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc"
|
|||
name = "mercury"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"cached",
|
||||
"coz",
|
||||
"modular-bitfield",
|
||||
|
@ -419,6 +431,12 @@ version = "0.2.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.9.0+wasi-snapshot-preview1"
|
||||
|
|
|
@ -12,6 +12,7 @@ coz = "0.1"
|
|||
tinyvec = "1.1.0"
|
||||
|
||||
cached = "0.23.0"
|
||||
ahash = "0.7.2"
|
||||
|
||||
modular-bitfield = "0.11.2"
|
||||
|
||||
|
|
27
src/azul.rs
27
src/azul.rs
|
@ -1,4 +1,4 @@
|
|||
use std::ops::{Deref, DerefMut};
|
||||
use std::{hash::Hash, ops::{Deref, DerefMut}};
|
||||
use rand::prelude::*;
|
||||
use rand::distributions::WeightedIndex;
|
||||
//use smallvec::{SmallVec, smallvec};
|
||||
|
@ -23,8 +23,9 @@ pub fn size_of_stuff() {
|
|||
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub enum Tile {
|
||||
// None,
|
||||
Start,
|
||||
Blue,
|
||||
Yellow,
|
||||
|
@ -35,6 +36,7 @@ pub enum Tile {
|
|||
|
||||
impl Default for Tile {
|
||||
fn default() -> Self {
|
||||
// Tile::None
|
||||
Tile::Blue
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +52,15 @@ impl IntoIterator for Tile {
|
|||
}
|
||||
}
|
||||
|
||||
/*impl From<Option<Tile>> for Tile {
|
||||
fn from(option: Option<Tile>) -> Tile {
|
||||
match option {
|
||||
Option::None => Tile::None,
|
||||
Some(tile) => tile
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
pub struct TileIter {
|
||||
current: Tile
|
||||
}
|
||||
|
@ -207,7 +218,7 @@ impl From<tinyvec::ArrayVec<[Tile; 128]>> for Bag {
|
|||
}
|
||||
|
||||
|
||||
#[derive(Default, Debug, Copy, PartialEq, Eq, Hash)]
|
||||
#[derive(Default, Debug, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
struct Factory (tinyvec::ArrayVec<[Tile; 4]>);
|
||||
impl Clone for Factory {
|
||||
//#[no_alloc]
|
||||
|
@ -229,7 +240,6 @@ impl DerefMut for Factory {
|
|||
}
|
||||
|
||||
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
struct Market (tinyvec::ArrayVec<[Tile; 28]>);
|
||||
impl Default for Market {
|
||||
|
@ -418,7 +428,9 @@ impl Game {
|
|||
factory.push(tile);
|
||||
}
|
||||
}
|
||||
factory.sort_unstable();
|
||||
};
|
||||
self.factories.sort_unstable();
|
||||
Ok(())
|
||||
}
|
||||
fn score(&mut self) -> Result<(), &'static str> {
|
||||
|
@ -579,6 +591,13 @@ impl Game {
|
|||
self.player = (self.player + 1) % self.boards.len();
|
||||
}
|
||||
*/
|
||||
|
||||
self.factories.sort_unstable();
|
||||
self.market.sort();
|
||||
for board in &mut self.boards {
|
||||
board.floor.sort_unstable();
|
||||
}
|
||||
|
||||
self.player = (self.player + 1) % self.boards.len() as u8;
|
||||
self.turn += 1;
|
||||
Ok(())
|
||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -27,11 +27,11 @@ fn main() -> Result<(), &'static str> {
|
|||
game.fill(StdRng::from_rng(&mut rng).expect("rng error"))?;
|
||||
//println!("{:#?}", game);
|
||||
|
||||
game.do_move(GameMove(3, Tile::Red, 3))?;
|
||||
game.do_move(GameMove(1, Tile::Yellow, 2))?;
|
||||
game.do_move(GameMove(2, Tile::Red, 3))?;
|
||||
game.do_move(GameMove(5, Tile::Yellow, 2))?;
|
||||
|
||||
game.do_move(GameMove(4, Tile::Blue, 2))?;
|
||||
game.do_move(GameMove(0, Tile::Black, 4))?;
|
||||
game.do_move(GameMove(3, Tile::Blue, 2))?;
|
||||
//game.do_move(GameMove(0, Tile::Black, 4))?;
|
||||
|
||||
//game.do_move(GameMove(5, Tile::Black, 1))?;
|
||||
//game.do_move(GameMove(0, Tile::Blue, 3))?;
|
||||
|
@ -95,7 +95,7 @@ fn calculate_options() -> Result<(), &'static str> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[cached(size=15_000_000, key = "Game", convert = r#"{ _game }"#)]
|
||||
#[cached(size=25_000_000, key = "Game", convert = r#"{ _game }"#)]
|
||||
fn count_options(_game: Game, depth: u8, treshold: u8) -> u128 {
|
||||
let mut sum = 0;
|
||||
let mut all_failed = true;
|
||||
|
|
Loading…
Reference in New Issue