Skip to content

Instantly share code, notes, and snippets.

View mrdmnd's full-sized avatar

Matthew Redmond mrdmnd

View GitHub Profile
paste into bottom of auto run code in details
Details.SpellsToIgnore[328351] = true; -- spear
Details.SpellsToIgnore[344421] = true; -- anima exhaust from kyrian goliath
Details.SpellsToIgnore[328128] = true; -- hammer
Details.SpellsToIgnore[328406] = true; -- Discharged Anima orb
@mrdmnd
mrdmnd / outlaw_agent.py
Created January 23, 2024 21:28
outlaw rogue DQN toy problem
import numpy as np
from outlaw_environment import OutlawEnvironment
from stable_baselines3 import PPO
from stable_baselines3 import DQN
from stable_baselines3.common.callbacks import BaseCallback
from stable_baselines3.common.env_checker import check_env
from stable_baselines3.common.evaluation import evaluate_policy
env = OutlawEnvironment()
check_env(env, warn=True)
# heinous zen koan: solve problem with as few indents as possible
import sys
import numpy as np
import itertools
def solve(puzzle):
other_sides = [set(puzzle[(i+1)%4] + puzzle[(i+2)%4] + puzzle[(i+3)%4]) for i in range(4)]
letter_neighbors = {letter: other_sides[index] for (index, side_string) in enumerate(puzzle) for letter in side_string}
constructible = lambda word: len(word) >= 3 and all([(first in letter_neighbors) and (second in letter_neighbors[first]) for (first, second) in zip(word, word[1:])])
constructible_words = set(filter(constructible, map(lambda x: x.rstrip(), open('dictionary.txt', 'r'))))
@mrdmnd
mrdmnd / silence.py
Created November 14, 2024 06:18
Decorator to asynchronously shut off STDOUT and STDERR while executing code.
import asyncio
import contextlib
import io
import sys
import threading
from functools import wraps
from typing import Any, Callable, TypeVar, Union, AsyncIterator
T = TypeVar('T')