Skip to content

Commit

Permalink
UI Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ThorvaldAagaard committed Jun 2, 2024
1 parent d22047f commit a77507d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 36 deletions.
20 changes: 10 additions & 10 deletions demo/viz.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,36 +449,36 @@ class PlayInfo {
html += '</div>'
}
else {
// LHO
// RHO
if (this.player == 0) {
html += '<div>East: ' + this.data['hcp'][0] + ' hcp, shape: '
html += '<div>West: ' + this.data['hcp'][0] + ' hcp, shape: '
}
if (this.player == 1) {
html += '<div>South: ' + this.data['hcp'][0] + ' hcp, shape: '
html += '<div>North: ' + this.data['hcp'][0] + ' hcp, shape: '
}
if (this.player == 2) {
html += '<div>West: ' + this.data['hcp'][0] + ' hcp, shape: '
html += '<div>East: ' + this.data['hcp'][0] + ' hcp, shape: '
}
if (this.player == 3) {
html += '<div>North: ' + this.data['hcp'][0] + ' hcp, shape: '
html += '<div>South: ' + this.data['hcp'][0] + ' hcp, shape: '
}

for (let i = 0; i < 4; i++) {
html += shape[i] + " "
}
html += '</div>'
// RHO
// LHO
if (this.player == 0) {
html += '<div>West: ' + this.data['hcp'][1] + ' hcp, shape: '
html += '<div>East: ' + this.data['hcp'][1] + ' hcp, shape: '
}
if (this.player == 1) {
html += '<div>North: ' + this.data['hcp'][1] + ' hcp, shape: '
html += '<div>South: ' + this.data['hcp'][1] + ' hcp, shape: '
}
if (this.player == 2) {
html += '<div>East: ' + this.data['hcp'][1] + ' hcp, shape: '
html += '<div>West: ' + this.data['hcp'][1] + ' hcp, shape: '
}
if (this.player == 3) {
html += '<div>South: ' + this.data['hcp'][1] + ' hcp, shape: '
html += '<div>North: ' + this.data['hcp'][1] + ' hcp, shape: '
}
for (let i = 0; i < 4; i++) {
html += shape[i + 4] + " "
Expand Down
4 changes: 2 additions & 2 deletions scripts/data/epbot/html/viz.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ class PlayInfo {
html += '</div>'
}
else {
// LHO
// RHO
if (this.player == 0) {
html += '<div>West: ' + this.data['hcp'][0] + ' hcp, shape: '
}
Expand All @@ -462,7 +462,7 @@ class PlayInfo {
html += shape[i] + " "
}
html += '</div>'
// RHO
// LHO
if (this.player == 0) {
html += '<div>East: ' + this.data['hcp'][1] + ' hcp, shape: '
}
Expand Down
16 changes: 8 additions & 8 deletions scripts/training/bidding/html/viz.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,16 +446,16 @@ class PlayInfo {
else {
// RHO
if (this.player == 0) {
html += '<div>East: ' + this.data['hcp'][0] + ' hcp, shape: '
html += '<div>West: ' + this.data['hcp'][0] + ' hcp, shape: '
}
if (this.player == 1) {
html += '<div>South: ' + this.data['hcp'][0] + ' hcp, shape: '
html += '<div>North: ' + this.data['hcp'][0] + ' hcp, shape: '
}
if (this.player == 2) {
html += '<div>West: ' + this.data['hcp'][0] + ' hcp, shape: '
html += '<div>East: ' + this.data['hcp'][0] + ' hcp, shape: '
}
if (this.player == 3) {
html += '<div>North: ' + this.data['hcp'][0] + ' hcp, shape: '
html += '<div>South: ' + this.data['hcp'][0] + ' hcp, shape: '
}

for (let i = 0; i < 4; i++) {
Expand All @@ -464,16 +464,16 @@ class PlayInfo {
html += '</div>'
// LHO
if (this.player == 0) {
html += '<div>West: ' + this.data['hcp'][1] + ' hcp, shape: '
html += '<div>East: ' + this.data['hcp'][1] + ' hcp, shape: '
}
if (this.player == 1) {
html += '<div>North: ' + this.data['hcp'][1] + ' hcp, shape: '
html += '<div>South: ' + this.data['hcp'][1] + ' hcp, shape: '
}
if (this.player == 2) {
html += '<div>East: ' + this.data['hcp'][1] + ' hcp, shape: '
html += '<div>West: ' + this.data['hcp'][1] + ' hcp, shape: '
}
if (this.player == 3) {
html += '<div>South: ' + this.data['hcp'][1] + ' hcp, shape: '
html += '<div>North: ' + this.data['hcp'][1] + ' hcp, shape: '
}
for (let i = 0; i < 4; i++) {
html += shape[i + 4] + " "
Expand Down
28 changes: 16 additions & 12 deletions src/frontend/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,11 @@ <h3 class="samples" onclick="toggleSamples('sampleLines${bids}')"><strong>Sampl

}

function displayPlay(data, player, declarer) {
function displayPlay(data, player, declarer, actual_hand) {
if (actual_hand == 1) {
// We lead from dummy
player = (player + 2) % 4
}
let html = "<h3>Play</h3><br> " + data["card"] + " selected by " + data["who"] + "<br/><br/>"

if ("candidates" in data && data.candidates.length > 0) {
Expand Down Expand Up @@ -710,36 +714,36 @@ <h3 class="samples" onclick="toggleSamples('sampleLines${bids}')"><strong>Sampl
html += '</div>'
}
else {
// LHO
// RHO
if (player == 0) {
html += '<div>East: ' + data['hcp'][0] + ' hcp, shape: '
html += '<div>West: ' + data['hcp'][0] + ' hcp, shape: '
}
if (player == 1) {
html += '<div>South: ' + data['hcp'][0] + ' hcp, shape: '
html += '<div>North: ' + data['hcp'][0] + ' hcp, shape: '
}
if (player == 2) {
html += '<div>West: ' + data['hcp'][0] + ' hcp, shape: '
html += '<div>East: ' + data['hcp'][0] + ' hcp, shape: '
}
if (player == 3) {
html += '<div>North: ' + data['hcp'][0] + ' hcp, shape: '
html += '<div>Southth: ' + data['hcp'][0] + ' hcp, shape: '
}

for (let i = 0; i < 4; i++) {
html += shape[i] + " "
}
html += '</div>'
// RHO
// LHO
if (player == 0) {
html += '<div>West: ' + data['hcp'][1] + ' hcp, shape: '
html += '<div>East: ' + data['hcp'][1] + ' hcp, shape: '
}
if (player == 1) {
html += '<div>North: ' + data['hcp'][1] + ' hcp, shape: '
html += '<div>South: ' + data['hcp'][1] + ' hcp, shape: '
}
if (player == 2) {
html += '<div>East: ' + data['hcp'][1] + ' hcp, shape: '
html += '<div>West: ' + data['hcp'][1] + ' hcp, shape: '
}
if (player == 3) {
html += '<div>South: ' + data['hcp'][1] + ' hcp, shape: '
html += '<div>North: ' + data['hcp'][1] + ' hcp, shape: '
}
for (let i = 0; i < 4; i++) {
html += shape[i + 4] + " "
Expand Down Expand Up @@ -895,7 +899,7 @@ <h3 class="samples" onclick="toggleSamples('sampleLines${bids}')"><strong>Sampl
if ((action == 'play') || (action == 'lead')) {
const declarer = findDeclarer(bidding)
document.getElementById('result').innerText = `BEN Suggest: ${data.card}`;
displayPlay(data, player, declarer);
displayPlay(data, player, declarer, data["player"]);
}
} catch (error) {
document.querySelector("#loader").style.visibility = "hidden";
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/viz.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ class PlayInfo {
html += '</div>'
}
else {
// LHO
// RHO
if (this.player == 0) {
html += '<div>West: ' + this.data['hcp'][0] + ' hcp, shape: '
}
Expand All @@ -457,7 +457,7 @@ class PlayInfo {
html += shape[i] + " "
}
html += '</div>'
// RHO
// LHO
if (this.player == 0) {
html += '<div>East: ' + this.data['hcp'][1] + ' hcp, shape: '
}
Expand Down
5 changes: 3 additions & 2 deletions src/gameapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def play_api(dealer_i, vuln_ns, vuln_ew, hands, models, sampler, contract, strai
if verbose:
pprint.pprint(card_resp.to_dict(), width=200)

return card_resp
return card_resp, player_i

card52 = Card.from_symbol(play[card_i]).code()
#print(play[card_i], card52, card_i, player_i, cardplayer_i)
Expand Down Expand Up @@ -491,9 +491,10 @@ def play():
cardplayer = 2
#print("cardplayer:",cardplayer)
#print(hands)
card_resp = play_api(dealer_i, vuln[0], vuln[1], hands, models, sampler, contract, strain_i, decl_i, auction, cards, cardplayer, verbose)
card_resp, player_i = play_api(dealer_i, vuln[0], vuln[1], hands, models, sampler, contract, strain_i, decl_i, auction, cards, cardplayer, verbose)
print("Playing:", card_resp.card.symbol())
result = card_resp.to_dict()
result["player"] = player_i
if record:
with shelve.open(f"{base_path}/gameapiplaydb{dealno}") as db:
db[uuid.uuid4().hex] = {"hand":hand_str, "dummy":dummy_str, "vuln":vuln, "dealer":dealer, "seat":seat, "auction":auction, "play":result}
Expand Down

0 comments on commit a77507d

Please sign in to comment.