Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: getting started, architecture intro and installation guide #111

Merged
merged 7 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 12 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,26 @@
<div align="center">
<h1>chess-tui</h1>
A chess TUI implementation in rust 🦀
</div>

![board](./examples/play_against_white_bot.gif)

![GitHub CI](https://github.com/thomas-mauran/chess-tui/actions/workflows/flow_test_build_push.yml/badge.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![GitHub release](https://img.shields.io/github/v/release/thomas-mauran/chess-tui?color=success)](https://github.com/thomas-mauran/chess-tui/releases/latest)
<div>

### Demo
![GitHub CI](https://github.com/thomas-mauran/chess-tui/actions/workflows/flow_test_build_push.yml/badge.svg)[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)[![GitHub release](https://img.shields.io/github/v/release/thomas-mauran/chess-tui?color=success)](https://github.com/thomas-mauran/chess-tui/releases/latest)
</div>
</div>

**With docker**
### Quick install

```bash
docker run --rm -it ghcr.io/thomas-mauran/chess-tui:main
```

**With Cargo**

```
cargo install chess-tui
chess-tui
```

**With Github**

```
git clone git@github.com:thomas-mauran/chess-tui.git
cd chess-tui
cargo build --release
./target/release/chess-tui
```

**NetBSD**
If you want to install the game with your favorite package manager, you can find the installation guide [here](https://thomas-mauran.github.io/chess-tui/docs/Installation/Packaging%20status).

On NetBSD a pre-compiled binary is available from the official repositories. To install it, simply run:

```
pkgin install chess-tui
```

**Arch Linux**

You can install from official repositories:

```
pacman -S chess-tui
```
### Available on
[![Packaging status](https://repology.org/badge/vertical-allrepos/chess-tui.svg)](https://repology.org/project/chess-tui/versions)

### Features

Expand Down Expand Up @@ -93,6 +66,10 @@ chess-tui -e /your/bin/path
Here I installed stockfish using homebrew and gave chess-tui the path the the engine binary.
This command will store in your home directory the chess engine path so you don't have to relink it everytime !

### Documentation

You can find the documentation of the project [here](https://thomas-mauran.github.io/chess-tui/docs/intro)

### Roadmap

You can find the roadmap of the project [here](https://github.com/users/thomas-mauran/projects/4) if you want to contribute.
Expand Down
3 changes: 3 additions & 0 deletions website/docs/Code Architecture/Game.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Game

todo
11 changes: 11 additions & 0 deletions website/docs/Code Architecture/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
id: Intro
title: Introduction
sidebar_position: 1
---

# Introduction

In this section we will go through the project architecture and the different classes that compose the project.

Hopefully this will help you understand the project better and maybe even contribute to it !
163 changes: 163 additions & 0 deletions website/docs/Code Architecture/pieces.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
---
id: Pieces
title: Pieces
sidebar_position: 2
---

## Project architecture

Let's begin by looking at the pieces in the game.
## Class diagram

### Pieces

```mermaid
classDiagram

class PieceType{
+authorized_positions()
+protected_positions()
+piece_to_utf_enum()
+piece_to_fen_enum()
+piece_type_to_string_enum()
+partial_cmp()
+cmp()
}

class PieceColor {
<<enumeration>>
Black
White
+opposite() PieceColor
}

class Pawn {
+authorized_positions()
+protected_positions()
+to_string()
+piece_move()
}

class Rook {
+authorized_positions()
+protected_positions()
+to_string()
+piece_move()
}

class Knight {
+authorized_positions()
+protected_positions()
+to_string()
+piece_move()
}

class Bishop {
+authorized_positions()
+protected_positions()
+to_string()
+piece_move()
}

class Queen {
+authorized_positions()
+protected_positions()
+to_string()
+piece_move()
}

class King {
+authorized_positions()
+protected_positions()
+to_string()
+piece_move()
}

class Coord {
<<data structure>>
+row: u8
+col: u8
}


class PieceMove {
+piece_type: PieceType
+piece_color: PieceColor
+from: Coord
+to: Coord
}

class Movable {
<<interface>>
+piece_move()
}


class Position {
<<interface>>
+authorized_positions()
+protected_positions()
}

PieceType <|-- Pawn
PieceType <|-- Rook
PieceType <|-- Bishop
PieceType <|-- Knight
PieceType <|-- King
PieceType <|-- Queen

PieceMove --> PieceType
PieceMove --> PieceColor
PieceMove --> Coord

PieceType ..|> Movable
PieceType ..|> Position

Pawn --> Coord
Rook --> Coord
Knight --> Coord
Bishop --> Coord
Queen --> Coord
King --> Coord

Movable <|.. Pawn
Movable <|.. Rook
Movable <|.. Knight
Movable <|.. Bishop
Movable <|.. Queen
Movable <|.. King

Position <|.. Pawn
Position <|.. Rook
Position <|.. Knight
Position <|.. Bishop
Position <|.. Queen
Position <|.. King
```

This schema can be a little bit overwhelming but let's break it apart.

#### PieceType

This class is basically the parent class of all the pieces. It contains the methods that are common to all the pieces. Such as authorized positions, protected positions, etc.

#### PieceColor

This is an enum that contains the two colors of the pieces. Black and White.

#### Pawn, Rook, Knight, Bishop, Queen, King

These are the classes that represent the pieces. They all inherit from PieceType and implement the methods that are specific to their type.

#### Movable and Position

These are rust traits that are implemented by the pieces. Movable is a trait that represents a piece that can move (piece_move method). Position is a trait that shows the authorized and protected positions of a piece.

#### Coord

This is a data structure that represents a position on the board. It contains a row and a column.

#### PieceMove

This is a data structure that represents a move of a piece. It contains the type of the piece, the color of the piece, the starting position, and the ending position. This is mainly used in the board structure that we will see later.

14 changes: 14 additions & 0 deletions website/docs/Installation/Arch Linux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Arch Linux

**Chess-tui** can be directly built from the Arch Linux package manager.


## Installation

```bash
pacman -S chess-tui
```

This package is available on the [official Arch Linux repositories](https://archlinux.org/packages/extra/x86_64/chess-tui/).

A big thank you to [Orhun](https://github.com/orhun) who is taking care of the package maintenance on Arch Linux 🎉
16 changes: 16 additions & 0 deletions website/docs/Installation/Build from source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Build from source

**Chess-tui** can be directly built from the source code.

:::warning Make sure you have [Rust](https://www.rust-lang.org/tools/install) installed on your machine.
:::

## Installation

```bash
git clone https://github.com/thomas-mauran/chess-tui
cd chess-tui
cargo build --release

./target/release/chess-tui
```
17 changes: 17 additions & 0 deletions website/docs/Installation/Cargo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Cargo

**Chess-tui** can be installed with cargo, the Rust package manager.


## Installation

```bash
cargo install chess-tui
```

**Then run the game with:**
```bash
chess-tui
```

The package is available on [crates.io](https://crates.io/crates/chess-tui) :tada:
17 changes: 17 additions & 0 deletions website/docs/Installation/Cargod.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Cargo

**Chess-tui** can be installed with cargo, the Rust package manager.


## Installation

```bash
cargo install chess-tui
```

**Then run the game with:**
```bash
chess-tui
```

The package is available on [crates.io](https://crates.io/crates/chess-tui) :tada:
9 changes: 9 additions & 0 deletions website/docs/Installation/Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Docker

**Chess-tui** can be runned in a Docker container.

## Installation

```bash
docker run --rm -it ghcr.io/thomas-mauran/chess-tui:main
```
14 changes: 14 additions & 0 deletions website/docs/Installation/NetBSD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# NetBSD

**Chess-tui** can be directly installed from pkgsource the NetBSD package manager.


## Installation

```bash
pkgin install chess-tui
```

This package is available on the [official NetBSD repositories](https://pkgsrc.se/games/chess-tui).

A big thank you to [0323pin](https://github.com/0323pin) who is taking care of the package maintenance on NetBSD 🎉
14 changes: 14 additions & 0 deletions website/docs/Installation/NixOS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# NixOS

**Chess-tui** can be directly installed from the NixOS package manager.


## Installation

A nix-shell will temporarily modify your $PATH environment variable. This can be used to try a piece of software before deciding to permanently install it.

```bash
nix-shell -p chess-tui
```

This package is available on the [official NixOS repositories](https://search.nixos.org/packages?channel=24.05&show=chess-tui&from=0&size=50&sort=relevance&type=packages&query=chess-tui).
5 changes: 5 additions & 0 deletions website/docs/Installation/Packaging status.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Packaging status

Thanks to a few awesome people, `chess-tui` is available in a few package managers. Here is a list of the package managers and the current status of the packaging.

[![Packaging status](https://repology.org/badge/vertical-allrepos/chess-tui.svg)](https://repology.org/project/chess-tui/versions)
7 changes: 0 additions & 7 deletions website/docs/intro.md

This file was deleted.

Loading
Loading