1import { fetch } from "https://esm.town/v/std/fetch";
2export default async function(req: Request): Promise<Response> {
3const p = Object.fromEntries(new URL(req.url).searchParams);
4if (!p.url) return Response.json("missing url");
connect4_mcts_agentmain.tsx3 matches
9const SIMULATIONS = 10000;
1011function rand_action(state: connect4.State): connect4.Action {
12const player = state.next_player;
13while (true) {
20}
2122function score_action(
23current_state: connect4.State,
24action: connect4.Action,
51}
5253function agent(state: connect4.State): connect4.Action {
54// For each action we could take, simulate multiple random games from the resulting state.
55// Keep track of the number of wins for each action.
49export type Action = z.infer<typeof Action>;
5051export function get(state: State, col: number, row: number): Slot {
52return state.board[col][row];
53}
5455export function set(state: State, col: number, row: number, slot: Slot): void {
56state.board[col][row] = slot;
57}
63| "column_out_of_bounds";
6465export function check_action(state: State, action: Action): ActionCheck {
66if (action.player !== state.next_player) {
67return "wrong_player";
76}
7778function check_slots_eq(a: Slot, b: Slot, c: Slot, d: Slot): Slot {
79if (a === b && b === c && c === d) {
80return a;
83}
8485export function status(state: State): Status {
86// Check Vertical Win
87for (let col = 0; col < COLS; col++) {
150}
151152export function apply_action(state: State, action: Action): Status {
153// Action should be checked before calling this function.
154// We assert that the action is ok.
155let check = check_action(state, action);
twitterWrappermain.tsx1 match
2import { twitterJSON } from "https://esm.town/v/stevekrouse/twitterJSON";
34export default async function(req: Request): Promise<Response> {
5if (req.headers.get("authorization") !== "Bearer " + Deno.env.get("boozedog"))
6return Response.json("Unauthorized", { status: 401 });
1export default function() {
2console.log("hi");
3return "foo";
1import { handler } from "https://esm.town/v/saolsen/example_rust_http_val";
23export default async function(req: Request): Promise<Response> {
4let response = handler(req.method, req.url, await req.text());
5console.log(response);
example_rust_http_valmain.tsx12 matches
17let cachedUint8Memory0 = null;
1819function getUint8Memory0() {
20if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
21cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
24}
2526function getStringFromWasm0(ptr, len) {
27ptr = ptr >>> 0;
28return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
33let cachedTextEncoder = new TextEncoder("utf-8");
3435const encodeString = typeof cachedTextEncoder.encodeInto === "function"
36? function(arg, view) {
37return cachedTextEncoder.encodeInto(arg, view);
38}
39: function(arg, view) {
40const buf = cachedTextEncoder.encode(arg);
41view.set(buf);
46};
4748function passStringToWasm0(arg, malloc, realloc) {
49if (realloc === undefined) {
50const buf = cachedTextEncoder.encode(arg);
85let cachedInt32Memory0 = null;
8687function getInt32Memory0() {
88if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
89cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
96heap.push(undefined, null, true, false);
9798function getObject(idx) {
99return heap[idx];
100}
102let heap_next = heap.length;
103104function dropObject(idx) {
105if (idx < 132) return;
106heap[idx] = heap_next;
108}
109110function takeObject(idx) {
111const ret = getObject(idx);
112dropObject(idx);
119* @returns {string}
120*/
121export const handler = imports.handler = function(method, url, _body) {
122let deferred5_0;
123let deferred5_1;
151};
152153export const __wbg_log_18b11754c5793c04 = imports.__wbg_log_18b11754c5793c04 = function(arg0, arg1) {
154console.log(getStringFromWasm0(arg0, arg1));
155};
valtownGeocitiesmain.tsx3 matches
1import { blob } from "https://esm.town/v/std/blob?v=10";
23function isJSON(input: string | null | undefined) {
4if (!input || input === null) return false;
5try {
11}
1213function processInputHtml(html: string) {
14let output = html;
1521}
2223function formatPage(key: string, data: string) {
24return `
25${data}
example_rust_valmain.tsx5 matches
20let cachedUint8Memory0 = null;
2122function getUint8Memory0() {
23if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
24cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
27}
2829function getStringFromWasm0(ptr, len) {
30ptr = ptr >>> 0;
31return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
32}
33/** */
34export const say_hello = (imports.say_hello = function() {
35wasm.say_hello();
36});
41* @returns {number}
42*/
43export const add = (imports.add = function(x, y) {
44const ret = wasm.add(x, y);
45return ret;
46});
4748export const __wbg_log_08850d6d4d91f4c9 = (imports.__wbg_log_08850d6d4d91f4c9 = function(arg0, arg1) {
49console.log(getStringFromWasm0(arg0, arg1));
50});