Skip to content

Commit

Permalink
Separate ui and core
Browse files Browse the repository at this point in the history
  • Loading branch information
ParthPant committed Mar 29, 2023
1 parent 948a0fc commit 9dd3856
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 52 deletions.
63 changes: 36 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["chrs-core", "chrs-perft"]
members = ["chrs-core", "chrs-perft", "chrs-ui"]
resolver = "2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ chess-rs is a Chess Engine written from scratch in Rust.

### Features

This section should list any major features of chess-rs

- [x] Move Generation using BitBoards (~17s perft results at depth 6 for starting position)
- [x] Supports all moves including en-passant, pawn promotion and castling
- [x] GUI gameplay
Expand All @@ -20,7 +18,6 @@ This section should list any major features of chess-rs
- [x] Transposition Tables
- [x] Incremental Search Deepening
- [ ] Opening Book
- [ ] Separate UI from Core


## Getting Started
Expand All @@ -43,7 +40,7 @@ cargo build

```
# You can either start the Chess Engine with
cargo run -p chrs-core
cargo run -p chrs-ui
# Or you can run perft analysis
cargo run -p chrs-perft -- 5 "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
Expand Down
7 changes: 0 additions & 7 deletions chrs-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ log = "0.4.17"
pretty_env_logger = "0.4.0"
# TODO: Is lazy_static really needed?
lazy_static = "1.4.0"
winit = "0.27.5"
pixels = "0.11.0"
resvg = "0.29.0"
egui = "0.20.0"
egui-winit = "0.20.1"
egui-wgpu = "0.20.0"
fontdue = "0.7.2"
rand = "0.8.5"
strum = "0.24"
strum_macros = "0.24"
Expand Down
4 changes: 0 additions & 4 deletions chrs-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
pub mod ai;
pub mod app;
pub mod board;
pub mod data;
pub mod generator;
pub mod zobrist;

mod cache;
mod prng;
mod ui;
17 changes: 17 additions & 0 deletions chrs-ui/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "chrs-ui"
version = "0.1.0"
edition = "2021"

[dependencies]
chrs-core = {path = "../chrs-core"}

log = "0.4.17"
pretty_env_logger = "0.4.0"
winit = "0.27.5"
pixels = "0.11.0"
resvg = "0.29.0"
egui = "0.20.0"
egui-winit = "0.20.1"
egui-wgpu = "0.20.0"
fontdue = "0.7.2"
6 changes: 3 additions & 3 deletions chrs-core/src/app.rs → chrs-ui/src/app.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::ai::{NegaMaxAI, AI};
use crate::board::{events::BoardEvent, Board};
use crate::data::{BoardConfig, Color, MoveList, Square};
use crate::generator::MoveGenerator;
use crate::ui::GuiFramework;
use chrs_core::ai::{NegaMaxAI, AI};
use chrs_core::data::{BoardConfig, Color, MoveList, Square};
use chrs_core::generator::MoveGenerator;

use log;
use pixels::{Error, Pixels, SurfaceTexture};
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions chrs-core/src/board/mod.rs → chrs-ui/src/board/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pub mod events;

use crate::cache::Cache;
use crate::data::{BoardConfig, BoardPiece, Color, Move, MoveList, Square};
use crate::generator::MoveGenerator;
use chrs_core::data::{BoardConfig, BoardPiece, Color, Move, MoveList, Square};
use chrs_core::generator::MoveGenerator;
use events::{BoardEvent, ElementState, MouseButton, MouseState};
use fontdue::{
layout::{CoordinateSystem, HorizontalAlign, Layout, LayoutSettings, TextStyle},
Expand Down
File renamed without changes.
6 changes: 5 additions & 1 deletion chrs-core/src/main.rs → chrs-ui/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#![allow(warnings, unused)]
mod app;
mod board;
mod cache;
mod ui;

use pixels::Error;
use pretty_env_logger;

use chrs_core::app::App;
use app::App;

fn main() -> Result<(), Error> {
std::env::set_var("RUST_BACKTRACE", "1");
Expand Down
4 changes: 2 additions & 2 deletions chrs-core/src/ui/gui.rs → chrs-ui/src/ui/gui.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::cell::RefCell;
use std::rc::Rc;

use crate::data::BoardConfig;
use crate::data::Color;
use chrs_core::data::BoardConfig;
use chrs_core::data::Color;
use egui::{Color32, Context};

pub(super) struct Gui {
Expand Down
2 changes: 1 addition & 1 deletion chrs-core/src/ui/mod.rs → chrs-ui/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::rc::Rc;
use winit::event_loop::EventLoopWindowTarget;
use winit::window::Window;

use crate::data::BoardConfig;
use chrs_core::data::BoardConfig;

/// Manages all state required for rendering egui over `Pixels`.
pub struct GuiFramework {
Expand Down

0 comments on commit 9dd3856

Please sign in to comment.