Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button } from "@mantine/core"
import {Button } from "@mantine/core"
import React from "react"
import { useNavigate } from "react-router-dom"
import { useLocalStorage } from "../hooks"
Expand Down Expand Up @@ -38,7 +38,10 @@ const ResultStatisticsTable = () => {
if (!roundResults) {
return <></>
}

const uniqueRoundResults = roundResults.filter(
(result: any, index: number, self: any[]) =>
self.findIndex((r) => r.seed === result.seed) === index

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will be better if you use a set of seeds and check every time if it's in the set already, but this is alright aswell

)
return (
<div
style={{
Expand All @@ -52,7 +55,7 @@ const ResultStatisticsTable = () => {
tableName="Results"
data={{
head: ["Seed"].concat(statistics),
body: roundResults.map((result: any) =>
body: uniqueRoundResults.map((result: any) =>
[result.seed].concat(
statistics.map((statistic) =>
(result?.statistics ?? {})[statistic].toString(),
Expand All @@ -64,22 +67,20 @@ const ResultStatisticsTable = () => {
if (columnName === "Seed") {
return (
<Button
component="a"
leftSection={<i className="fa-solid fa-play" />}
onClick={() =>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has the small downside of not using react router which causes page refreshes and delays, but it's ok

navigate(
`/simulation/${round.players.map(encodeURIComponent).join(",")}?seed=${
value
}&${Object.keys(round.parameters)
.map(
(p) =>
`${p}=${encodeURIComponent(round.parameters[p])}`,
)
.join("&")}`,
href={`/simulation/${round.players.map(encodeURIComponent).join(",")}?seed=${
value
}&${Object.keys(round.parameters)
.map(
(p) =>
`${p}=${encodeURIComponent(round.parameters[p])}`,
)
}
.join("&")}`}
>
Play
</Button>

)
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/RoundPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import Block from "../blocks/Block"
import BotSelector from "../blocks/BotSelector"
import TournamentBlock from "../blocks/TournamentBlock"
import ResultStatisticsTable from "../ResultStaticsTable"
import ResultStatisticsTable from "../ResultStatisticsTable"
import ResultWinnerChart from "../ResultWinnerChart"

let currentParameters: Record<string, string>
Expand Down