Skip to content

Instantly share code, notes, and snippets.

@heiner
heiner / hist.svg
Last active July 21, 2021 14:00
244906 nethack roles chosen with `-@`
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
class MemoryEnv:
# Max return per episode: 17.
def __init__(self):
self.q = []
def reset(self):
del self.q[:]
self.obs = torch.randn(4)
self.q.append(self.obs)
class HardCartPole:
def __init__(self):
self._env = gym.make("CartPole-v0")
self._reward = 0.0
def reset(self):
self._reward = 0.0
return self._env.reset()
def step(self, action):
BRIGHT = 8
def color(s, fg, bg):
return "\033[%d;3%d;4%dm%s\033[0m" % (
bool(fg & BRIGHT),
fg & ~BRIGHT,
bg & ~BRIGHT,
s,
)
[1/3] Linking CXX shared module moolib.cpython-38-x86_64-linux-gnu.so
FAILED: moolib.cpython-38-x86_64-linux-gnu.so
: && /usr/bin/c++ -fPIC -Wfatal-errors -march=native -ftemplate-backtrace-limit=0 -Bsymbolic -D_GLIBCXX_USE_CXX11_ABI=0 -flto -shared -o moolib.cpython-38-x86_64-linux-gnu.so CMakeFiles/moolib.dir/src/moolib.cc.o -Wl,-rpath,/private/home/hnr/.conda/envs/nle2021/lib/python3.8/site-packages/torch/lib:/public/apps/cuda/10.1/lib64:/public/apps/cudnn/v7.6.5.32-cuda.10.1/cuda/lib64:/public/apps/cuda/10.1/lib64/stubs libmoorpc.a /private/home/hnr/.conda/envs/nle2021/lib/python3.8/site-packages/torch/lib/libtorch_python.so src/fmt/libfmt.a src/tensorpipe/tensorpipe/libtensorpipe.a src/tensorpipe/tensorpipe/libtensorpipe_uv.a -lpthread -ldl -lrt /private/home/hnr/.conda/envs/nle2021/lib/python3.8/site-packages/torch/lib/libtorch.so -Wl,--no-as-needed,/private/home/hnr/.conda/envs/nle2021/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so -Wl,--as-needed -lpthread -Wl,--no-as-needed,/pr
import collections
import re
import sys
ifs = ["#ifndef", "#ifdef", "#if"]
SLASHAST = re.compile(r"/\*.*?\*/", re.DOTALL)
DOUBLESLASH = re.compile(r"//.*?\n")
@heiner
heiner / CMakeLists.txt
Last active July 30, 2020 19:10
dlreload
cmake_minimum_required(VERSION 3.10)
project(dlreload)
add_library(inner SHARED inner.c)
add_library(outer SHARED outer.c)
add_executable(test test.c)
target_link_libraries(test PUBLIC outer)
@heiner
heiner / welford_test.py
Last active November 4, 2021 23:41
Various equivalent implementations of Welford's Algorithm, including its "parallel" version
#
# pytest -svx welford_test.py
#
"""
Cf. Sutton-Barto
http://www.incompleteideas.net/book/first/ebook/node19.html
and
https://math.stackexchange.com/a/103025/5051
as well as
https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm
# Essentials ###########################################################
unbind C-b
set -g prefix C-q
# Reload config
bind R source-file ~/.tmux.conf \; display-message "Tmux configuration reloaded"
# Basic terminal defaults
setw -g mode-keys vi
cmake_minimum_required(VERSION 3.10)
project(cppgen VERSION 0.0.1 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(remapping remapping.cc)
target_link_libraries(remapping stdc++ "-framework Foundation" "-framework IOKit" objc)