GithubHelp home page GithubHelp logo

Comments (7)

rbtying avatar rbtying commented on May 27, 2024

Interesting -- it shouldn't matter that Lincoln has 4 cards, in this case. Most likely there is a bug where the three-deck KKQQ vs. AA throw detection isn't working right... will look into it

from shengji.

rbtying avatar rbtying commented on May 27, 2024
    fn test_play_throw_tractor_extra_cards() {
        let mut hands = Hands::new(vec![P1, P2, P3, P4], Number::Four);
        hands.add(P1, vec![S_Q, S_Q, S_K, S_K, S_A]).unwrap();
        hands.add(P2, vec![S_2, S_3, S_3, S_5, S_3]).unwrap();
        hands.add(P3, vec![S_A, S_A, H_3, H_3, H_3]).unwrap();
        hands.add(P4, vec![H_3, H_3, H_3, H_3, H_3]).unwrap();
        let mut trick = Trick::new(TRUMP, vec![P1, P2, P3, P4]);
        trick
            .play_cards(P1, &mut hands, &[S_Q, S_Q, S_K, S_K, S_A])
            .unwrap();
        trick.play_cards(P2, &mut hands, &[S_2, S_3, S_3, S_5, S_3]).unwrap();
        trick.play_cards(P3, &mut hands, &[S_A, S_A, H_3, H_3, H_3]).unwrap();
        trick.play_cards(P4, &mut hands, &[H_3, H_3, H_3, H_3, H_3]).unwrap();
        let TrickEnded {
            winner: winner_id,
            points,
            largest_trick_unit_size,
            failed_throw_size,
            ..
        } = trick.complete().unwrap();
        assert_eq!(largest_trick_unit_size, 5);
        assert_eq!(winner_id, P1);
        assert_eq!(points, vec![]);
        assert_eq!(failed_throw_size, 0);
    }

-edit

Actually, it doesn't look like this repros?

from shengji.

alex-fung avatar alex-fung commented on May 27, 2024

Hm...
What would happen if P4 had four spades and a heart?

from shengji.

alex-fung avatar alex-fung commented on May 27, 2024

And if P3 had more spades besides the pair aces

from shengji.

rbtying avatar rbtying commented on May 27, 2024
    fn test_play_throw_tractor_extra_cards() {
        use crate::types::cards::*;
        let trump = Trump::Standard {
            number: Number::Four,
            suit: Suit::Hearts,
        };

        let mut hands = Hands::new(vec![P1, P2, P3, P4], Number::Four);
        let p1_hand = vec![S_Q, S_Q, S_K, S_K, S_A];
        let p2_hand = vec![S_2, S_3, S_3, S_5, S_3];
        let p3_hand = vec![S_A, S_A, S_3, S_3, S_3];
        let p4_hand = vec![S_3, S_3, S_3, S_3, S_3];

        hands.add(P1, p1_hand.clone()).unwrap();
        hands.add(P2, p2_hand.clone()).unwrap();
        hands.add(P3, p3_hand.clone()).unwrap();
        hands.add(P4, p4_hand.clone()).unwrap();
        let mut trick = Trick::new(trump, vec![P1, P2, P3, P4]);
        trick
            .play_cards(P1, &mut hands, &p1_hand)
            .unwrap();
        trick.play_cards(P2, &mut hands, &p2_hand).unwrap();
        trick.play_cards(P3, &mut hands, &p3_hand).unwrap();
        trick.play_cards(P4, &mut hands, &p4_hand).unwrap();
        let TrickEnded {
            winner: winner_id,
            points,
            largest_trick_unit_size,
            failed_throw_size,
            ..
        } = trick.complete().unwrap();
        assert_eq!(largest_trick_unit_size, 4);
        assert_eq!(winner_id, P1);
        assert_eq!(points, vec![S_K, S_K, S_5]);
        assert_eq!(failed_throw_size, 0);
    }

this test also passes?

What's weird here is, if p1 was forced to play the tractor (and not the spare A), that would imply that somebody else had a higher tractor... but the only higher available tractor is potentially AAKK in 4 decks, since this isn't the trump suit?

Unfortunately, this kind of thing is hard to fix without being able to reproduce it somehow :(

from shengji.

rbtying avatar rbtying commented on May 27, 2024

OK I figured this out.

diff --git a/core/src/trick.rs b/core/src/trick.rs
index f248e98..bed6c21 100644
--- a/core/src/trick.rs
+++ b/core/src/trick.rs
@@ -381,9 +381,11 @@ impl Trick {
                                     ..
                                 } in find_tractors(self.trump, hands.get(*player)?)
                                 {
-                                    if self.trump.effective_suit(members[0]) == tf.suit
+                                    if self.trump.effective_suit(found_members[0]) == tf.suit
                                         && found_count >= *count
                                         && found_members.len() >= members.len()
+                                        && self.trump.compare(found_members[0], members[0])
+                                            == Ordering::Greater
                                     {
                                         invalid = Some((player, unit.clone()));
                                         break 'search;

The code is incorrectly treating any other tractor as a bigger tractor.

from shengji.

alex-fung avatar alex-fung commented on May 27, 2024

Thank you @rbtying!

from shengji.

Related Issues (20)

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.