Giter Club home page Giter Club logo

shogi-rs's People

Contributors

dependabot[bot] avatar gemmaro avatar na2hiro avatar nozaq avatar sugyan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

shogi-rs's Issues

unmake_move with capture doesn't decrement number of pieces in hands

I appreciate that you've been maintaining the great library. I'm trying to write some code to solve tsume shogi with this.

It seems that unmake_move doesn't decrement a piece count of the type which was captured by the move, but it should. Unmaking such moves with captures adds extra piece in the game every time.

Reproduction code

use shogi::{Move, Position, Color, Piece, Square};
use shogi::bitboard::Factory as BBFactory;
use shogi::piece_type::PieceType;

fn main() {
    BBFactory::init();
    let mut pos = Position::new();
    let sfen = "8l/8+R/8k/9/9/9/9/9/9 w r2b4g4s4n3l18p 1";
    pos.set_sfen(sfen).unwrap();
    assert_eq!(1, pos.hand(Piece{piece_type: PieceType::Rook, color: Color::White}), "initial");
    pos.make_move(Move::from_sfen("1a1b").unwrap()).unwrap();
    assert_eq!(2, pos.hand(Piece{piece_type: PieceType::Rook, color: Color::White}), "after make_move");
    pos.unmake_move().unwrap();
    assert_eq!(1, pos.hand(Piece{piece_type: PieceType::Rook, color: Color::White}), "after unmake_move");
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `2`: after unmake_move', src/main.rs:47:5
stack backtrace:

The position used for the example in KIF format:

後手の持駒:飛 角二 金四 銀四 桂四 香三 歩十八 
 9 8 7 6 5 4 3 2 1
+---------------------------+
| ・ ・ ・ ・ ・ ・ ・ ・v香|一
| ・ ・ ・ ・ ・ ・ ・ ・ 龍|二
| ・ ・ ・ ・ ・ ・ ・ ・v王|三
| ・ ・ ・ ・ ・ ・ ・ ・ ・|四
| ・ ・ ・ ・ ・ ・ ・ ・ ・|五
| ・ ・ ・ ・ ・ ・ ・ ・ ・|六
| ・ ・ ・ ・ ・ ・ ・ ・ ・|七
| ・ ・ ・ ・ ・ ・ ・ ・ ・|八
| ・ ・ ・ ・ ・ ・ ・ ・ ・|九
+---------------------------+
先手の持駒:なし

Incorrect parsing of SFEN with 10 or more pieces of the same type in hands

I found that parsing of pieces in hands doesn't properly handle the case when the number of pieces are 10 (2 digit number) or more. In this example, White should have 17 Pawns, but it results in 7:

use shogi::{Move, Position, Color, Piece, Square};
use shogi::bitboard::Factory as BBFactory;
use shogi::piece_type::PieceType;

fn main() {
    BBFactory::init();
    let mut pos = Position::new();

    let sfen = "7k1/9/7P1/9/9/9/9/9/9 b G2r2b3g4s4n4l17p 1";
    pos.set_sfen(sfen).unwrap();
    assert_eq!(pos.hand(Piece{piece_type: PieceType::Pawn, color: Color::White}), 17, "pawn count");
}
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `7`,
 right: `17`: pawn count', src/main.rs:15:5

parse_sfen_hand seems to omit leading digits.

[Security] Workflow lint.yml is using vulnerable action actions/checkout

The workflow lint.yml is referencing action actions/checkout using references v1. However this reference is missing the commit a6747255bd19d7a757dbdda8c654a9f84db19839 which may contain fix to the some vulnerability.
The vulnerability fix that is missing by actions version could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider to update the reference to the action.

Is there any reason why `find_king()` is private?

I appreciate that you've been maintaining the great library. I'm trying to write some code to solve tsume-shogi with this.

I'm looking for an efficient way to generate legal Drop moves. I'm trying to consider the area only around of king's position so that I don't have to try make_move() for useless drop moves.
So I'm happy if the pos.find_king() method is public and available.

https://github.com/sugyan/tsumeshogi-solver/blob/0.1.0/dfpn-solver/src/lib.rs#L190-L263

Is there any reason why this method is currently private?

my blog: https://memo.sugyan.com/entry/2021/11/11/005132

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.