diff --git a/README.md b/README.md index fd75d63..b4dc006 100644 --- a/README.md +++ b/README.md @@ -64,11 +64,3 @@ $ sol_cli --solve-board pb......br..p..p There are atleast 1 solutions to this puzzle ``` - -## Heuristics of current algorithm - -1. About 6-7 pieces on the board. -2. Select pieces to place based on its weight. - 3. Eg: Queen is too powerful, so it has lower weightage. - 4. Eg: Knights are confusing. More knights. - diff --git a/cli/src/main.rs b/cli/src/main.rs index bb63a7a..0731106 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -72,7 +72,7 @@ fn generate_puzzle(num_pieces: Option, num_solutions: Option) -> Optio "Generating a puzzle with {} pieces with a maximum of {} solutions", num_pieces, num_solutions ); - let gen_result = generator::generate(num_pieces, num_solutions, &RandRngImpl); + let gen_result = generator::generate_weighted_random(num_pieces, num_solutions, &RandRngImpl); gen_result.print_stats(); let Some(puzzle) = gen_result.puzzle() else { diff --git a/gui/src/game.rs b/gui/src/game.rs index 615ff0b..ac2b75d 100644 --- a/gui/src/game.rs +++ b/gui/src/game.rs @@ -1,55 +1,52 @@ -use std::{ - collections::HashMap, - fmt::{self, Display, Formatter}, - rc::Rc, -}; - -mod button; -mod color; pub mod constants; mod draw; mod logic; -mod shadow; -pub mod sound; -mod texture; -use button::Button; +use crate::{ + resources::Resources, + widgets::{button::Button, id_text_input::IdTextInput}, +}; use macroquad::prelude::*; use sol_lib::{board::Board, generator::Puzzle}; -use sound::Sounds; +use std::fmt::{self, Display, Formatter}; +#[derive(Default)] pub struct Game { - // The generated puzzle. We keep a copy of this to reset the game. + resources: Resources, + + volume: f32, + puzzle: Puzzle, - - // What is shown to the user - current_board: Board, - - // Constants througout the game - texture_res: Texture2D, - sounds: Sounds, - font: Rc, - num_squares: usize, - heading_text: String, - - // Update below on handle input state: GameState, debug: bool, - game_mode: GameMode, - // Update below on window resize - // Used for drawing the state - square_width: f32, window_height: f32, window_width: f32, + + current_board: Board, + square_width: f32, + num_squares: usize, // this is a constant = 4 for now. board_rect: Rect, squares: Vec, + heading_rect: Rect, heading_font_size: f32, - gp_btns: HashMap, - mode_btns: HashMap, - rules: bool, - rules_btn: Option