Skip to content

Instantly share code, notes, and snippets.

View shwang's full-sized avatar

Steven H. Wang shwang

  • Zürich, Switzerland
View GitHub Profile
@shwang
shwang / sketch.py
Created September 15, 2022 21:24
Thu Sept 15 Processing
import random
def setup():
size(400, 400)
ellipse(width/2, height/2, 50, 50)
background(255)
stroke(0)
fill(150, 100, 100)
rect(0, 80, 100, 100, 10)
visualize_array(ARRAY)
@shwang
shwang / foreword.txt
Created November 13, 2021 20:00
War and Peace, Inner Sanctum Edition Foreword except
This foreword falls into two sections. The first, immediately following, is an attempt at a discussion of some of the literary qualities of War and Peace. The second draws a few obvious analogies between Napoleons Russian campaign, as described by Tolstóy, and Hitler’s Russian campaign, as it seemed to a nonmilitary observer toward the middle of February, 1942.
[...]
War and Peace has been called the greatest novel ever written. These very words have been used, to my knowledge, by E. M. Forster, Hugh Walpole, John Galsworthy, and Compton Mackenzie; and a similar judgment has been made by many others. Note that it is particularly novelists themselves who hold this opinion. Is not this the book all novelists would like to write? Is it not to the novelist what Hamlet is to the playwright?
That War and Peace is one of the greatest novels ever written is beyond question. But I do not know what is meant by calling it “the greatest”. No calipers exist to measure the relative greatness of great novels. It is more
@shwang
shwang / gist:8f3a337212f682ad91f82c5da3bea936
Created March 17, 2021 00:51
Minecraft item canonical names
MC_ITEM_IDS = [
"minecraft:acacia_boat", "minecraft:acacia_door", "minecraft:acacia_fence", "minecraft:acacia_fence_gate",
"minecraft:acacia_stairs", "minecraft:activator_rail", "minecraft:air", "minecraft:anvil", "minecraft:apple",
"minecraft:armor_stand", "minecraft:arrow", "minecraft:baked_potato", "minecraft:banner", "minecraft:barrier",
"minecraft:beacon", "minecraft:bed", "minecraft:bedrock", "minecraft:beef", "minecraft:beetroot",
"minecraft:beetroot_seeds", "minecraft:beetroot_soup", "minecraft:birch_boat", "minecraft:birch_door",
"minecraft:birch_fence", "minecraft:birch_fence_gate", "minecraft:birch_stairs",
"minecraft:black_glazed_terracotta", "minecraft:black_shulker_box", "minecraft:blaze_powder", "minecraft:blaze_rod",
"minecraft:blue_glazed_terracotta", "minecraft:blue_shulker_box", "minecraft:boat", "minecraft:bone",
"minecraft:bone_block", "minecraft:book", "minecraft:bookshelf", "minecraft:bow", "minecraft:bowl",
@shwang
shwang / 00_explanations.md
Last active January 19, 2021 19:55
argument checking

Automated Argument Checking

Introduction

On Sam's gail branch, I checked whether the following scripts would fail as expected when replacing arbitrary Sacred configuration options with a bad value.

  • pretrain_n_adapt.py (called chain_ex_bc.pkl in results files)
  • run_rep_learner.py (called repl_{algo}.pkl in results files)
  • il_train.py (called il_train_test_ex_{algo}.pkl in the results files)
  • il_test.py (called il_train_test_ex_{algo}.pkl in the results files)

The bad value that I used in particular was ..., which satisfies bool(...) == True and ... is not None.

package io.github.herobraine.experiments;
import java.util.Random;
import org.bukkit.Difficulty;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.block.Block;
import org.bukkit.block.Biome;

Quickstart:

Sacred CLI:

# Train PPO agent on cartpole and collect expert demonstrations
python -m imitation.scripts.expert_demos with cartpole log_dir=quickstart

# Train GAIL from demonstrations
python -m imitation.scripts.train_adversarial with gail cartpole rollout_path=quickstart/rollouts/final.pkl
@shwang
shwang / gist:e1d9d8b508869e3e151d5a4a686f80bd
Created October 19, 2020 23:15
Reproduce caves recording/rendering bug
(Writted by Neel Alex)
1) A number of .yml files had to be changed to accomodate the new experiment:
* mcplugin/src/main/resources/experiments.yml
* mcplugin/src/main/resources/worlds.yml
* mcserver/plugins/HerobrainePlugin/experiments/experiments.yml
* mcserver/plugins/HerobrainePlugin/worlds.yml
2) Additional changes were made to java files
* mcplugin/src/main/java/io/github/herobraine/utils/ExperimentUtils.java
@shwang
shwang / install.notes
Last active October 19, 2020 23:13
MineRL server / Minecraft client install notes.
### Ubuntu install notes without IDE:
# Get our custom mc-unified branch. Contains Minecraft server code.
git clone https://github.com/HumanCompatibleAI/mc-unified
cd mc-unified
git fetch -v
git checkout neel/cavesexperiment
# Building and running the custom Minecraft server plugin.
sudo apt install -y maven
import torch as th
import torch.utils.data as th_data
def main():
x = th.ones([30, 3, 3], requires_grad=True)
y = x * 2
dl = th_data.DataLoader(y)
batch = next(iter(dl))
import torch as th
import torch.utils.data as th_data
def main():
x = th.ones([30, 3, 3], requires_grad=True)
y = x * 2
dl = th_data.DataLoader(y)
batch = next(iter(dl))