Skip to content

Commit

Permalink
Merge pull request #1172 from zizhang-qiu:fix_bridge_observation_tensor
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 606230032
Change-Id: Ia765dbfd3b84d80fec43d5896b3a125b8e8fb42e
  • Loading branch information
lanctot committed Feb 12, 2024
2 parents 468a004 + f25125e commit 931e39a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion open_spiel/games/bridge/bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 931e39a

Please sign in to comment.