Skip to content

Commit

Permalink
Expose winning card through pybind11.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 511793359
Change-Id: Id56a829a6d45a1d7c0ad7b807ef35035c84324d8
  • Loading branch information
jhtschultz authored and lanctot committed Feb 28, 2023
1 parent 649a5f5 commit 4d674e4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion open_spiel/games/euchre.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ inline std::string CardString(int card) {
}



// State of a single trick.
class Trick {
public:
Trick() : Trick{kInvalidPlayer, Suit::kInvalidSuit, kInvalidAction} {}
Trick(Player leader, Suit trump_suit, int card);
void Play(Player player, int card);
int WinningCard() const { return winning_card_; }
Suit LedSuit() const { return led_suit_; }
Suit TrumpSuit() const { return trump_suit_; }
bool TrumpPlayed() const { return trump_played_; }
Expand Down
1 change: 1 addition & 0 deletions open_spiel/python/pybind11/games_euchre.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ void init_pyspiel_games_euchre(py::module& m) {
}));

py::class_<euchre::Trick>(state_class, "Trick")
.def("winning_card", &euchre::Trick::WinningCard)
.def("led_suit", &euchre::Trick::LedSuit)
.def("trump_suit", &euchre::Trick::TrumpSuit)
.def("trump_played", &euchre::Trick::TrumpPlayed)
Expand Down
1 change: 1 addition & 0 deletions open_spiel/python/tests/games_euchre_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def test_bindings(self):
euchre.Suit.SPADES)
self.assertEqual(euchre.card_string(8), 'CJ')
trick = state.tricks()[state.current_trick_index()]
self.assertEqual(trick.winning_card(), pyspiel.INVALID_ACTION)
self.assertEqual(trick.led_suit(), euchre.Suit.INVALID_SUIT)
self.assertEqual(trick.trump_suit(), euchre.Suit.INVALID_SUIT)
self.assertFalse(trick.trump_played())
Expand Down

0 comments on commit 4d674e4

Please sign in to comment.