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

checkers rules #3

Open
gilberto85 opened this issue Nov 11, 2022 · 22 comments
Open

checkers rules #3

gilberto85 opened this issue Nov 11, 2022 · 22 comments

Comments

@gilberto85
Copy link

i dont know but i saw your video and this is not american checkers rules

https://www.itsyourturn.com/t_helptopic2030.html

@stillonearth
Copy link
Owner

Those should be English Checkers. Do you need American checkers?

@gilberto85
Copy link
Author

yes

@stillonearth
Copy link
Owner

Check the updated video. Rules as of now:

  • getting an extra turn for a piece if you ate an opponent
  • crowning

@gilberto85
Copy link
Author

Hi there thank you I saw the video but american checkers jumps are mandatory

@stillonearth
Copy link
Owner

They are. Check 16th second on vid

@gilberto85
Copy link
Author

Sorry the only video I see is this
Checkers.on.Bevy.2022-11-16.19-08-04.mp4

And its not jumping according to American checkers rules btw you have a very good skills

@stillonearth
Copy link
Owner

Yeah, that's the one

Where exactly you see an error in this ruleset:

  • piece can move 1 square in advancing forward
  • piece get an extra move if it eaten an opponent's piece
  • after crowning a piece can move diagonally without restriction on number of squares

@gilberto85
Copy link
Author

gilberto85 commented Nov 16, 2022 via email

@stillonearth
Copy link
Owner

Okay, seems I'm getting it now.

@gilberto85
Copy link
Author

Hope that video can help you

@gilberto85
Copy link
Author

Also multiple jumps are mandatory

@gilberto85
Copy link
Author

Is that much to change ? I don't know what kind of checkers is that rules now I don't know if it's Italian rules

@stillonearth
Copy link
Owner

stillonearth commented Nov 18, 2022 via email

@gilberto85
Copy link
Author

gilberto85 commented Nov 18, 2022 via email

@stillonearth
Copy link
Owner

stillonearth commented Nov 18, 2022

This project supports wasm targets so you can depoy on web (though neural AI won't work with wasm, an investigation required). With some adjustments multiplayer is also possible. I'll make an example branch with american rules adjustments.

PRs are welcome if you'll choose to use this codebase.

@stillonearth
Copy link
Owner

stillonearth commented Nov 18, 2022

This branch implements American ruleset (i.e. jump mandatory is possible): https://github.com/stillonearth/CheckersOnBevy/tree/american-ruleset

The changes are in pub fn possible_moves(&self) -> [Vec<Position>; 24]:

  1. Check whether current moveset for a given side contains a 'Take` move:
let mut american_jump_possible: HashMap<Color, bool> = HashMap::new();
for i in 0..24 {
    let p = self.state.pieces.iter().find(|p| p.id == i);
    if p.is_none() {
        continue;
    }

    let color = p.unwrap().color;
    for j in 0..24 {
        let p = self.state.pieces.iter().find(|p| p.id == j);
        if p.is_none() {
            continue;
        }

        let other_color = p.unwrap().color;

        if other_color == color {
            let jump_possible = moveset[j as usize].iter().any(|m| m.1 == MoveType::Take);
            if jump_possible {
                american_jump_possible.insert(color, true);
                break;
            }
        }
    }
}
  1. Filter out regular moves if so.

That's enough to limit AI, and there's another check in Game::step

let moveset = self.possible_moves();
if moveset[piece.id as usize].len() == 0 {
    // self.state.turn.change();
    return (MoveType::Invalid, &self.state, self.check_termination());
}

@gilberto85
Copy link
Author

gilberto85 commented Nov 18, 2022 via email

@gilberto85
Copy link
Author

gilberto85 commented Nov 18, 2022 via email

@gilberto85
Copy link
Author

gilberto85 commented Nov 18, 2022 via email

@stillonearth
Copy link
Owner

You're talking about this vid right? https://github.com/stillonearth/CheckersOnBevy/tree/american-ruleset

In that branches attack moves are mandatory.

@gilberto85
Copy link
Author

gilberto85 commented Nov 18, 2022 via email

@stillonearth
Copy link
Owner

That's probably an animation issue, as they are not queued now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants