From 43c9a8002718a8b98eb911e4b233c64290251bbf Mon Sep 17 00:00:00 2001 From: hanyuu1 <13738325103@126.com> Date: Wed, 31 Jan 2024 21:24:03 +0800 Subject: [PATCH 1/2] Fix bridge observation tensor --- open_spiel/games/bridge/bridge.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/open_spiel/games/bridge/bridge.cc b/open_spiel/games/bridge/bridge.cc index 35cfa47c57..86be844580 100644 --- a/open_spiel/games/bridge/bridge.cc +++ b/open_spiel/games/bridge/bridge.cc @@ -314,7 +314,8 @@ void BridgeState::WriteObservationTensor(Player player, auto ptr = values.begin(); if (num_cards_played_ > 0) { // Observation for play phase - if (phase_ == Phase::kPlay) ptr[2] = 1; + const bool defending = (partnership != Partnership(contract_.declarer)); + if (phase_ == Phase::kPlay) ptr[2 + defending] = 1; ptr += kNumObservationTypes; // Contract From f25125eae0d2b8997d3374ff3687617ca012ba84 Mon Sep 17 00:00:00 2001 From: zizhang-qiu <13738325103@126.com> Date: Fri, 2 Feb 2024 21:28:02 +0800 Subject: [PATCH 2/2] run_script --- .../bridge(use_double_dummy_result=false).txt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/open_spiel/integration_tests/playthroughs/bridge(use_double_dummy_result=false).txt b/open_spiel/integration_tests/playthroughs/bridge(use_double_dummy_result=false).txt index be1edd861f..2d1ddc12f8 100644 --- a/open_spiel/integration_tests/playthroughs/bridge(use_double_dummy_result=false).txt +++ b/open_spiel/integration_tests/playthroughs/bridge(use_double_dummy_result=false).txt @@ -738,9 +738,9 @@ ObservationString(1) = "Vul: None\nS 9\nH QT863\nD A75\nC 982\n\nWest North Eas ObservationString(2) = "Vul: None\nS KQJT2\nH none\nD 82\nC Q7643\n\nWest North East South\n 1S 3H 4S \n5H Dbl Pass 5S \nPass Pass Pass \n\nN E S W N E S\n HK H2 \n\nDeclarer tricks: 0" ObservationString(3) = "Vul: None\nS 76\nH J75\nD KQT9643\nC K\n\nWest North East South\n 1S 3H 4S \n5H Dbl Pass 5S \nPass Pass Pass \n\nN E S W N E S\n HK H2 \n\nDeclarer tricks: 0" ObservationTensor(0): binvec(571, 0x104148804e4004a3002d620221004644000000000000000000000000080800000000000000000000000000000000000000000000000000000000000000000000000000002001000) -ObservationTensor(1): binvec(571, 0x104141a081092a480811620221004644000000000000808000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002001000) +ObservationTensor(1): binvec(571, 0x84141a081092a480811620221004644000000000000808000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002001000) ObservationTensor(2): binvec(571, 0x10414296202210046441620221004644080000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000002001000) -ObservationTensor(3): binvec(571, 0x104144811094c1109301620221004644000000000000000000000000000000000000008080000000000000000000000000000000000000000000000000000000000000002001000) +ObservationTensor(3): binvec(571, 0x84144811094c1109301620221004644000000000000000000000000000000000000008080000000000000000000000000000000000000000000000000000000000000002001000) Rewards() = [0, 0, 0, 0] Returns() = [0, 0, 0, 0] LegalActions() = [14, 22, 38] @@ -831,9 +831,9 @@ ObservationString(1) = "Vul: None\nS none\nH QT86\nD A75\nC 982\n\nWest North E ObservationString(2) = "Vul: None\nS QJ2\nH none\nD 82\nC Q764\n\nWest North East South\n 1S 3H 4S \n5H Dbl Pass 5S \nPass Pass Pass \n\nN E S W N E S\n HK H2 H5 HA \nS3 S9 ST S7 \n SK S6 S5 H3 \n C3 CK \n\nDeclarer tricks: 3" ObservationString(3) = "Vul: None\nS none\nH J7\nD KQT9643\nC none\n\nWest North East South\n 1S 3H 4S \n5H Dbl Pass 5S \nPass Pass Pass \n\nN E S W N E S\n HK H2 H5 HA \nS3 S9 ST S7 \n SK S6 S5 H3 \n C3 CK \n\nDeclarer tricks: 3" ObservationTensor(0): binvec(571, 0x104148800e0004a30025420221000640000000000000000000000000000200000000000000000000002000004000000000080000000000000000000000400000400000000401000) -ObservationTensor(1): binvec(571, 0x104141a001092a080811420221000640000000000000002000000000000000000000020000000000000000800000000000000000000004000004000000000004000000000401000) +ObservationTensor(1): binvec(571, 0x84141a001092a080811420221000640000000000000002000000000000000000000020000000000000000800000000000000000000004000004000000000004000000000401000) ObservationTensor(2): binvec(571, 0x10414294202210006401420221000640020000000000000000000000200000000000000000000000000000000000000040000040000000000040000000000800000000000401000) -ObservationTensor(3): binvec(571, 0x10414481101081109101420221000640000000000002000000000000000000000000000020000000000000000400000000000400000000008000000000000000000000040401000) +ObservationTensor(3): binvec(571, 0x8414481101081109101420221000640000000000002000000000000000000000000000020000000000000000400000000000400000000008000000000000000000000040401000) Rewards() = [0, 0, 0, 0] Returns() = [0, 0, 0, 0] LegalActions() = [12, 32, 36, 48] @@ -940,9 +940,9 @@ ObservationString(1) = "Vul: None\nS none\nH QT8\nD A75\nC none\n\nWest North E ObservationString(2) = "Vul: None\nS QJ2\nH none\nD 82\nC 7\n\nWest North East South\n 1S 3H 4S \n5H Dbl Pass 5S \nPass Pass Pass \n\nN E S W N E S\n HK H2 H5 HA \nS3 S9 ST S7 \n SK S6 S5 H3 \n C3 CK CA C2 \nC5 C8 CQ D3 \n C4 D4 CJ C9 \nCT H6 C6 D6 \nH4 \n\nDeclarer tricks: 7" ObservationString(3) = "Vul: None\nS none\nH J7\nD KQT9\nC none\n\nWest North East South\n 1S 3H 4S \n5H Dbl Pass 5S \nPass Pass Pass \n\nN E S W N E S\n HK H2 H5 HA \nS3 S9 ST S7 \n SK S6 S5 H3 \n C3 CK CA C2 \nC5 C8 CQ D3 \n C4 D4 CJ C9 \nCT H6 C6 D6 \nH4 \n\nDeclarer tricks: 7" ObservationTensor(0): binvec(571, 0x10414880040004810005400021000440000800000000000000000000000000000000000000000000000000000000200000000080000000000020000000000001000000000041000) -ObservationTensor(1): binvec(571, 0x10414180010108080811400021000440000000000000000000000000000000000000000000800000000000000800000000000200000000000010000000000000000200000041000) +ObservationTensor(1): binvec(571, 0x8414180010108080811400021000440000000000000000000000000000000000000000000800000000000000800000000000200000000000010000000000000000200000041000) ObservationTensor(2): binvec(571, 0x10414294000210004401400021000440000000000000000000000000000008000000000000000000000000002000000000000100000000000000002000000000800000000041000) -ObservationTensor(3): binvec(571, 0x10414480000081109101400021000440000000000000000080000000000000000000000000000000000000001000000000000000020000000008000000000002000000000041000) +ObservationTensor(3): binvec(571, 0x8414480000081109101400021000440000000000000000080000000000000000000000000000000000000001000000000000000020000000008000000000002000000000041000) Rewards() = [0, 0, 0, 0] Returns() = [0, 0, 0, 0] LegalActions() = [26, 34, 42] @@ -1006,9 +1006,9 @@ ObservationString(1) = "Vul: None\nS none\nH QT\nD A75\nC none\n\nWest North Ea ObservationString(2) = "Vul: None\nS QJ\nH none\nD 82\nC none\n\nWest North East South\n 1S 3H 4S \n5H Dbl Pass 5S \nPass Pass Pass \n\nN E S W N E S\n HK H2 H5 HA \nS3 S9 ST S7 \n SK S6 S5 H3 \n C3 CK CA C2 \nC5 C8 CQ D3 \n C4 D4 CJ C9 \nCT H6 C6 D6 \nH4 H8 S2 H7 \n C7 \n\nDeclarer tricks: 8" ObservationString(3) = "Vul: None\nS none\nH J\nD KQT9\nC none\n\nWest North East South\n 1S 3H 4S \n5H Dbl Pass 5S \nPass Pass Pass \n\nN E S W N E S\n HK H2 H5 HA \nS3 S9 ST S7 \n SK S6 S5 H3 \n C3 CK CA C2 \nC5 C8 CQ D3 \n C4 D4 CJ C9 \nCT H6 C6 D6 \nH4 H8 S2 H7 \n C7 \n\nDeclarer tricks: 8" ObservationTensor(0): binvec(571, 0x10414880040004810005000001000440000000000000000000000000000000020000000000000000000000080000000000000000800000040000000000000000080000000021000) -ObservationTensor(1): binvec(571, 0x10414180010100080811000001000440000000000000000000200000000000000000000000000000000000000008000000400000000000000000800000000080000000000021000) +ObservationTensor(1): binvec(571, 0x8414180010100080811000001000440000000000000000000200000000000000000000000000000000000000008000000400000000000000000800000000080000000000021000) ObservationTensor(2): binvec(571, 0x10414290000010004401000001000440000002000000000000000000000000000000000000000000000004000000000000000008000000000800000000000000008000000021000) -ObservationTensor(3): binvec(571, 0x10414480000001109101000001000440000000000000000000000000000000000000000000002000000000000080000000008000000000000000080000004000000000000021000) +ObservationTensor(3): binvec(571, 0x8414480000001109101000001000440000000000000000000000000000000000000000000002000000000000080000000008000000000000000080000004000000000000021000) Rewards() = [0, 0, 0, 0] Returns() = [0, 0, 0, 0] LegalActions() = [29, 33, 38, 41, 45] @@ -1060,9 +1060,9 @@ ObservationString(1) = "Vul: None\nS none\nH QT\nD A75\nC none\n\nWest North Ea ObservationString(2) = "Vul: None\nS QJ\nH none\nD 82\nC none\n\nWest North East South\n 1S 3H 4S \n5H Dbl Pass 5S \nPass Pass Pass \n\nN E S W N E S\n HK H2 H5 HA \nS3 S9 ST S7 \n SK S6 S5 H3 \n C3 CK CA C2 \nC5 C8 CQ D3 \n C4 D4 CJ C9 \nCT H6 C6 D6 \nH4 H8 S2 H7 \n C7 D9 \n\nDeclarer tricks: 8" ObservationString(3) = "Vul: None\nS none\nH J\nD KQT\nC none\n\nWest North East South\n 1S 3H 4S \n5H Dbl Pass 5S \nPass Pass Pass \n\nN E S W N E S\n HK H2 H5 HA \nS3 S9 ST S7 \n SK S6 S5 H3 \n C3 CK CA C2 \nC5 C8 CQ D3 \n C4 D4 CJ C9 \nCT H6 C6 D6 \nH4 H8 S2 H7 \n C7 D9 \n\nDeclarer tricks: 8" ObservationTensor(0): binvec(571, 0x10414880040004810005000001000440000000000000000000000000000000020000000000000010000000080000000000000000800000040000000000000000080000000021000) -ObservationTensor(1): binvec(571, 0x10414180010100080811000001000440000000000000000000200000000000000100000000000000000000000008000000400000000000000000800000000080000000000021000) +ObservationTensor(1): binvec(571, 0x8414180010100080811000001000440000000000000000000200000000000000100000000000000000000000008000000400000000000000000800000000080000000000021000) ObservationTensor(2): binvec(571, 0x10414290000010004401000001000440000002000000000000001000000000000000000000000000000004000000000000000008000000000800000000000000008000000021000) -ObservationTensor(3): binvec(571, 0x10414480000000109101000001000440000000010000000000000000000000000000000000002000000000000080000000008000000000000000080000004000000000000021000) +ObservationTensor(3): binvec(571, 0x8414480000000109101000001000440000000010000000000000000000000000000000000002000000000000080000000008000000000000000080000004000000000000021000) Rewards() = [0, 0, 0, 0] Returns() = [0, 0, 0, 0] LegalActions() = [11, 27, 30, 37, 51]