Comments (7)
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.
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.
Hm...
What would happen if P4 had four spades and a heart?
from shengji.
And if P3 had more spades besides the pair aces
from shengji.
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.
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.
Thank you @rbtying!
from shengji.
Related Issues (20)
- Add option to show player's ID in the title bar
- Player may need to bid cards not of his rank HOT 3
- Can 4-of-a-kind or 7/8-of-a-kind be played in single deck-game or double-deck games? HOT 2
- NT rank after A? HOT 1
- Auto play cards when there are no other choices
- can we have option to turn off Joker Bid?
- Request: Add Option to be able to make one player to be "double" friends HOT 1
- Playing Finding Friends - somehow the player didn't play the "friend" card and the player were become the "friend" anyway. HOT 1
- Request: Option to make 4 of a kind (Bomb, e.g.: 8888) bigger then tractor (e.g. KKQQ) in Finding Friend HOT 1
- Re-trumping a trumped single-single-pair throw with two pairs matches the 2nd pair incorrectly. HOT 2
- Option to show symbol for cards in trump suit
- Performance issues with throw evaluation
- table like layout for new users used to play in real world
- Landlord become his own friend HOT 6
- Add a player limit in rooms
- Add ability to sign in and persist stats across devices HOT 1
- Add Chinese Translation HOT 1
- Add option to rotate landlord to next player, regardless of team
- Add option to remove dead zone in scoring settings HOT 1
- Add option to protect both triples and tractors from pairs HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shengji.