Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions src/games/writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,35 @@ std::string WriteHTMLFile(const Game &p_game, const GamePlayer &p_rowPlayer,

theHtml += "<table>";
theHtml += "<tr>";
theHtml += "<td></td>";
theHtml += R"(<td colspan="2" rowspan="2"></td>)";
theHtml += R"(<td colspan=")" + std::to_string(p_colPlayer->GetStrategies().size()) +
R"(" align="center"><b>)";
theHtml += p_colPlayer->GetLabel();
theHtml += "</b></td>";
theHtml += "</tr>";
theHtml += "<tr>";
for (const auto &strategy : p_colPlayer->GetStrategies()) {
theHtml += "<td align=center><b>";
theHtml += R"(<td align="center"><b>)";
theHtml += strategy->GetLabel();
theHtml += "</b></td>";
}
theHtml += "</tr>";

bool first_row_strategy = true;
for (const auto &row_strategy : p_rowPlayer->GetStrategies()) {
const PureStrategyProfile profile = iter;
profile->SetStrategy(row_strategy);
theHtml += "<tr>";
theHtml += "<td align=center><b>";

if (first_row_strategy) {
theHtml += R"(<td rowspan=")" + std::to_string(p_rowPlayer->GetStrategies().size()) +
R"(" align="center" valign="middle"><b>)";
theHtml += p_rowPlayer->GetLabel();
theHtml += "</b></td>";
first_row_strategy = false;
}

theHtml += R"(<td align="center"><b>)";
theHtml += row_strategy->GetLabel();
theHtml += "</b></td>";
for (const auto &col_strategy : p_colPlayer->GetStrategies()) {
Expand Down
4 changes: 4 additions & 0 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,12 @@ def test_write_efg_as_nfg():

def test_write_html():
game = gbt.Game.new_table([2, 2])
game.players[0].label = "Alice"
game.players[1].label = "Bob"
serialized_game = game.to_html()
assert isinstance(serialized_game, str)
assert "Alice" in serialized_game
assert "Bob" in serialized_game


def test_write_latex():
Expand Down
Loading