Coder Social home page Coder Social logo

thomas-mauran / chess-tui Goto Github PK

View Code? Open in Web Editor NEW
343.0 2.0 19.0 2.52 MB

A chess TUI implementation in rust 🦀

Home Page: https://crates.io/crates/chess-tui

License: MIT License

Rust 99.66% Dockerfile 0.16% Shell 0.18%
chess game linux-game ratatui rust tui

chess-tui's Issues

Movement through history

It would be nice to go back and forward throughout history to look through the moves. This feature would go nicely with #25 to look through a game you have imported.

Takeback

Problem

Sometimes enter gets pressed accidentally, which is kind of annoying.

Solution

A character like backspace could be assigned to takeback.

Additional context

As far as I'm concerned lichess has a feature like this too, so it is useful when lichess integration is done.

ci: add lint

Problem

Currently cargo fmt and clippy are not checked in the ci which is not very clean

Solution

add a job in the ci

fix(historic): line 8 is translated to 0

Description

When moving a piece from the 8th row (black first one) the historic indicates a 0 instead of an 8.

To Reproduce

  • move a piece from the 8th row and check the historic

Expected behavior

display 8 instead of 0

Screenshots

image

Material difference

Problem

Material difference is not shown.

Solution

Display material difference in History.

Additional context

I guess Lichess has support for this too.

3 fold repetition

Description

3 fold repetition only checks moves in a row, it should check if the position repeats regardless of order

To Reproduce

Play a game and repeat the position, outside of the same order

Expected behavior

Draw in all repetition scenarios

Environment

OS: Linux (NixOS)
Terminal Emulator: Alacritty

Additional context

This function just needs to be rewritten

    pub fn draw_by_repetition(&self) -> bool {
        if self.move_history.len() >= 9 {
            let last_ten: Vec<PieceMove> =
                self.move_history.iter().rev().take(9).cloned().collect();

            if (last_ten[0].clone(), last_ten[1].clone())
                == (last_ten[4].clone(), last_ten[5].clone())
                && last_ten[4].clone() == last_ten[8].clone()
                && (last_ten[2].clone(), last_ten[3].clone())
                    == (last_ten[6].clone(), last_ten[7].clone())
            {
                return true;
            }
        }
        false
    }

Keyboard shortcuts for moves

Problem

You have to manually select a square to move a piece, which is a bit tedious.

Solution

It would be good to be able to quickly use the keyboard for this (e.g a5 or Nc3).

How to use chess-tui with gnuchess engine?

I'm trying to run chess-tui bot game with gnuchess engine.

Created script engine.sh:

#!/bin/sh
gnuchess --uci

Gave it execution permissions by chmod +x engine.sh.

Then run:
chess-tui -e /home/alex/script.sh
After selecting "Play against a bot", chess-tui just hangs.

Can you help me, please, what did I did wrong?

Config file storage

Description

As for now, the config file (containing chess-engine path) seems to be stored under $HOME/.chess-tui.

Expected behavior

It would be a lot better to store it under $HOME/.config/chess-tui/chess-engine.toml or something. The dirs crate fits the purpose to resolve this issue I think.

Environment

  • OS: Arch Linux
  • Terminal Emulator: Alacritty
  • Font: Recursive (patched)
  • Crate version: latest git
  • Backend: crossterm

feat: pgn export

Implement a pgn export method

Solution

  • Create a new method to convert move_history into pgn
  • store it into a file

Add "Escape" event to helper menu

Problem

First try, I didn't know how to deselect the piece selected by mistake.

Solution

Add this following line into ui.rs:

Line::from("ESCAPE : Deselect a piece or cancel a move"),
``

feat: board turn

Problem

Be able to play as black

Solution

Implement it and be sure to remove all the hardcoded white values

Wrong path for chess-tui config file

Description

For now the chess-tui config file in which there is the engine path for the bot is created directly at the root of the home directory. (~/.chess-tui)

To Reproduce

Run chess-tui with -e option for the engine path and the configuration file will be created.

Expected behavior

The configuration file should be located in a chess-tui directory in the .config directory as follow : ~/.config/chess-tui/config.toml
Also, it would be better if the configuration file is created whether or not there is an option on launch of chess-tui.

Environment

  • OS: Arch Linux
  • Terminal Emulator: Fish

feat: pgn import

Import a pgn game position

Be able to select a file to import as a new game position

Ascii mode

Problem

Old school ascii mode, just like in gnuchess. The player has uppercase letters and the enemy has lowercase letters.
p = pawn, k = king, q = queen, b = bishop, r = rook, n = knight

image

feat(board): make border transparent

Problem

the boards automatically creates border for the cells to be the same size, but the borders aren´t looking great everytime

Solution

We could use cross term to get the color of the terminal and set in ui the border color to this background color

Error : No such file or directory

Tried to use the docker image, and see this error in the logs.
Are any volume mappings necessary for this to work ?

Am I correct to assume that I will be able to play the game via browser if the container is up and running ?
I dont see a mention of any ports, so I assume its port 80 by default ?

Error: Os { code: 2, kind: NotFound, message: "No such file or directory" }
Error: Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" }
Error: Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" }
Error: Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" }
Error: Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" }

feat: home menu

Home menu

Implement a home menu when starting the game with the following options:

  • New game
  • Play against a bot
  • Import a game

KeyEvents are reported twice Windows

Description

KeyEvents are reported twice Windows as Windows reports a KeyPress and a KeyRelease.
Therefore everything acts strangely, the app is unused.

To Reproduce

You could try this app on Windows 10/11 or maybe anything else, but as it might be impossible, you could believe me.

Expected behavior

Check whether a KeyEvent is a KeyPress and if not, ignore.

Screenshots

Environment

  • OS: Windows 11
  • Terminal Emulator: windows terminal
  • Crate version: git main
  • Backend: crossterm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.