This commit is contained in:
2025-11-06 10:13:30 -08:00
parent 7f6e33242c
commit 5d9b2ca2d0
9 changed files with 71 additions and 73 deletions

View File

@@ -42,28 +42,6 @@ fn step_max(board) {
const AGENTS = {
// special-cased below
Self: undefined,
Random: `fn random_action(board) {
let symb = rand_symb();
let pos = rand_int(0, 10);
let action = Action(symb, pos);
while !board.can_play(action) {
let symb = rand_symb();
let pos = rand_int(0, 10);
action = Action(symb, pos);
}
return action;
}
fn step_min(board) {
return random_action(board);
}
fn step_max(board) {
return random_action(board);
}`,
};
export default function Playground() {
@@ -71,7 +49,7 @@ export default function Playground() {
const [isEditorReady, setIsEditorReady] = useState(false);
const [fontSize, setFontSize] = useState(14);
const [bulkRounds, setBulkRounds] = useState(1000);
const [selectedAgent, setSelectedAgent] = useState("Random");
const [selectedAgent, setSelectedAgent] = useState("Self");
const [isHelpOpen, setIsHelpOpen] = useState(false);
const [scriptName, setScriptName] = useState("");
const [saveSecret, setSaveSecret] = useState("");
@@ -126,10 +104,7 @@ export default function Playground() {
// Combine hardcoded agents with saved scripts, ensuring Self and Random are first
const combinedAgents = [
"Self",
"Random",
...Object.keys(AGENTS).filter(
(key) => key !== "Self" && key !== "Random"
),
...Object.keys(AGENTS).filter((key) => key !== "Self"),
...scripts,
];
@@ -265,7 +240,7 @@ export default function Playground() {
}
if (!saveSecret.trim()) {
alert("Please enter the save secret");
alert("Please enter a secret");
return;
}
@@ -323,6 +298,11 @@ export default function Playground() {
return;
}
if (scriptContent.trim().startsWith("// SECRET")) {
alert("This script is hidden :)");
return;
}
// Warn user about losing current content
const confirmed = confirm(
`This will replace your current script with "${selectedAgent}". Your current work will be lost. Continue?`
@@ -433,11 +413,11 @@ export default function Playground() {
</div>
<div className={styles.configField}>
<label>Save secret</label>
<label>Secret</label>
<input
type="password"
className={styles.saveInput}
placeholder="Enter save secret..."
placeholder="Enter secret..."
value={saveSecret}
onChange={(e) =>
setSaveSecret(