Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View DataWraith's full-sized avatar

Johannes Holzfuß DataWraith

View GitHub Profile
@DataWraith
DataWraith / ll-cma.py
Created July 22, 2020 21:27
Solve LunarLander-v2 using CMA-ES
#!/usr/bin/env python3
"""
ll-cma.py: Solve LunarLander-v2 using CMA-ES.
This code solves the LunarLander-v2 environment from the OpenAI gym using CMA-ES.
You need to pip-install the packages numpy, gym[box2d] and cma in order for it to work.
It doesn't seem to solve the environment in every run, but if it does, it
@DataWraith
DataWraith / WraithBot.md
Created January 23, 2019 18:55
A high-level description of my Halite III bot.

WraithBot

This is a high-level description of my Halite III bot. At the time of writing, a few days before the end of the competition, it has a rating of slightly over 74, which puts it at rank ~115.

Bot description

The bot is based on Value Iteration and Uniform Cost Search for mining halite and returning it to the nearest dropoff. Dropoffs are not pre-planned -- a ship

@DataWraith
DataWraith / FizzBuzz.exs
Created August 6, 2017 08:10
Flexible FizzBuzz implementation using Streams in Elixir
defmodule FizzBuzz do
@moduledoc """
FizzBuzz outputs integers interspersed with configurable words
at configurable intervals.
"""
def fizzbuzz(count, words \\ [{3, "Fizz"}, {5, "Buzz"}]) do
words
|> Enum.map(&make_word_stream/1)
|> Stream.zip
@DataWraith
DataWraith / fizzbuzz.clj
Created March 3, 2017 22:31
FizzBuzz using lazy seqs in Clojure.
(ns clj-fizzbuzz.core
(:gen-class))
(defn hitword
[word n]
(cycle (cons word (repeat (dec n) nil))))
(defn fizzbuzz
[x]
(let [fizzes (hitword "Fizz" 3)
@DataWraith
DataWraith / Main.elm
Last active February 22, 2017 15:55
Simple two-player Go-Moku game written in Elm https://elm-gomoku.neocities.org
{-
"dependencies": {
"eeue56/elm-flat-matrix": "3.0.2 <= v < 4.0.0",
"elm-lang/core": "5.1.1 <= v < 6.0.0",
"elm-lang/html": "2.0.0 <= v < 3.0.0",
"elm-lang/svg": "2.0.0 <= v < 3.0.0"
},
"elm-version": "0.18.0 <= v < 0.19.0"
-}
@DataWraith
DataWraith / imr.py
Created February 8, 2017 17:38
Simple image regression using Tensorflow and an ad hoc network that turned out to work well
import math
import tensorflow as tf
import numpy as np
import tensorflow.contrib.slim as slim
from scipy import misc
class IMR(object):
def __init__(self, sess, channels = 3):
self.sess = sess
self.num_channels= channels
@DataWraith
DataWraith / frozen_lake.py
Created December 11, 2016 21:53
SARSA implementation for the OpenAI gym Frozen Lake environment
import gym
import numpy as np
# This is a straightforwad implementation of SARSA for the FrozenLake OpenAI
# Gym testbed. I wrote it mostly to make myself familiar with the OpenAI gym;
# the SARSA algorithm was implemented pretty much from the Wikipedia page alone.
env = gym.make("FrozenLake-v0")
def choose_action(observation):
package main
// This program takes a .zim-file and dumps all contained articles below the
// current directory. I tested it with a Wikipedia snapshot; that did not
// contain deleted articles or LinkTargetEntrys, so I'm unsure how to handle
// those, for now I'm ignoring them.
//
// Redirects are handled by simply writing out the page pointed to by the
// redirect. IPFS deduplication should take care of it, so I think this is the
// most economical solution, even better than writing out small HTML files with
@DataWraith
DataWraith / koremutake
Created February 7, 2014 19:50
A simple passwort generator based on koremutake
#!/usr/bin/env ruby
require 'securerandom'
# Generates a random password made up of NUM_SYLLABLES koremutake syllables.
# See http://shorl.com/koremutake for more on koremutake.
NUM_SYLLABLES=14
SYLLABLES = %w{
@DataWraith
DataWraith / ppm32d.py
Created April 5, 2013 14:11
A rock-paper-scissors player written in Python for rpscontest.com. As of April 2013 it was ranked 85th out of 1318 contestants.
# This entry is based on Prediction by Partial Matching, a method that is used
# in data compression.
import random
from collections import defaultdict
CONTEXT_SIZE=32
if input == "":
# Initialize data structure