kripke: add daily and random challenges (2)
This commit is contained in:
@@ -1,7 +1,21 @@
|
|||||||
import type { SeoProps } from "$components/seo";
|
import type { SeoProps } from "$components/seo";
|
||||||
|
import { randomSeed } from "../system.js";
|
||||||
|
|
||||||
|
export async function load({ url }) {
|
||||||
|
const seedStr = url.searchParams.get("seed");
|
||||||
|
const seed = (() => {
|
||||||
|
try {
|
||||||
|
if (!seedStr) return randomSeed();
|
||||||
|
const seed = Number.parseInt(seedStr);
|
||||||
|
if (!Number.isSafeInteger(seed)) return randomSeed();
|
||||||
|
return seed;
|
||||||
|
} catch {
|
||||||
|
return randomSeed();
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
export async function load() {
|
|
||||||
return {
|
return {
|
||||||
|
seed,
|
||||||
seo: {
|
seo: {
|
||||||
title: "KRIPKE (random challenge) - cannorin.net",
|
title: "KRIPKE (random challenge) - cannorin.net",
|
||||||
description: "KRIPKE - WORDLE, but for Kripke frames!",
|
description: "KRIPKE - WORDLE, but for Kripke frames!",
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from "$app/state";
|
|
||||||
import { Button } from "$lib/components/ui/button";
|
import { Button } from "$lib/components/ui/button";
|
||||||
import * as Dialog from "$lib/components/ui/dialog";
|
import * as Dialog from "$lib/components/ui/dialog";
|
||||||
import { type Formula, isomorphic, validWorlds } from "@cannorin/kripke";
|
import { type Formula, isomorphic, validWorlds } from "@cannorin/kripke";
|
||||||
@@ -8,17 +7,10 @@ import LuX from "lucide-svelte/icons/x";
|
|||||||
import FrameInput from "../frame-input.svelte";
|
import FrameInput from "../frame-input.svelte";
|
||||||
import Game, { type GameStatus, type Move } from "../game.svelte";
|
import Game, { type GameStatus, type Move } from "../game.svelte";
|
||||||
import Rules from "../rules.svelte";
|
import Rules from "../rules.svelte";
|
||||||
import { getRandomFrame, randomSeed } from "../system";
|
import { getRandomFrame } from "../system";
|
||||||
|
|
||||||
const seed = (() => {
|
|
||||||
const seedStr = page.url.searchParams.get("seed");
|
|
||||||
if (seedStr) {
|
|
||||||
const seed = Math.floor(Number.parseInt(seedStr));
|
|
||||||
return seed;
|
|
||||||
}
|
|
||||||
return randomSeed();
|
|
||||||
})();
|
|
||||||
|
|
||||||
|
let { data } = $props();
|
||||||
|
const seed = data.seed;
|
||||||
const { id, frame } = getRandomFrame(seed);
|
const { id, frame } = getRandomFrame(seed);
|
||||||
const guess = (frameId: number) => isomorphic[frameId] === id;
|
const guess = (frameId: number) => isomorphic[frameId] === id;
|
||||||
const check = (formula: Formula) => validWorlds(frame, formula).length;
|
const check = (formula: Formula) => validWorlds(frame, formula).length;
|
||||||
|
|||||||
Reference in New Issue
Block a user