Skip to content

Instantly share code, notes, and snippets.

View edward3h's full-sized avatar

Edward Harman edward3h

View GitHub Profile
seq 100|perl -lpe'$r="";$_%3||($r.="Fizz");$_%5||($r.="Buzz");$_=$r||$_'
@edward3h
edward3h / shoot40k_6.rb
Created January 31, 2014 17:46
ruby script for super 40k mathhammer
#!/usr/bin/env ruby
$template_hits = 4
$blast_hits = 2
$large_blast_hits = 5
class Dice
def self.d6
Proc.new { rand(6) + 1 }
end
@edward3h
edward3h / EntryTest.java
Created September 9, 2014 16:49
I'm getting a confusing compile error relating to Map.entrySet()
package org.ethelred.test;
import java.util.Map;
import java.util.HashMap;
public class EntryTest
{
public static void main(String[] args)
{
@edward3h
edward3h / PriorityQueueTest.java
Created September 24, 2014 15:43
Demonstrate that the iterator of a PriorityQueue does not return results in total order.
package org.ethelred.test;
import java.util.*;
public class PriorityQueueTest
{
public static void main(String[] args)
{
int times = 20;
if(args.length > 0)
@edward3h
edward3h / harlequin_cc.coffee
Created April 10, 2015 17:30
harlequin close combat weapons
choose = require 'choose'
pad = require 'pad'
ZERO = 0
ONE = 1
Number::inverse = () ->
ONE - this
Number::toPercentage = () ->
@edward3h
edward3h / fleet_helper.rb
Created April 30, 2015 13:41
Figure out which dice to reroll for Fleet charge
#!/usr/bin/env ruby
def evaltarget(target)
puts target
lowest = []
both = []
1.upto(6) do |a|
1.upto(6) do |b|
unless a+b >= target
l = [a,b].min
@edward3h
edward3h / CSM_vs_CSM.rb
Created July 11, 2017 18:27
Simple example of 40k unit simulation. See https://www.reddit.com/r/Warhammer/comments/6mn9t7/mathhammer_csm_vs_csm/ for inspiration.
#!/usr/bin/env ruby
$experiments = 10000
# distance fudging - assume distance X is "within X" for rules purposes
$startRange = 24
$range = $startRange
$attemptChargeRange = 10
$rounds = 5
@edward3h
edward3h / CSM_vs_CSM.rb
Created July 11, 2017 18:27
Simple example of 40k unit simulation. See https://www.reddit.com/r/Warhammer/comments/6mn9t7/mathhammer_csm_vs_csm/ for inspiration.
#!/usr/bin/env ruby
$experiments = 10000
# distance fudging - assume distance X is "within X" for rules purposes
$startRange = 24
$range = $startRange
$attemptChargeRange = 10
$rounds = 5
@edward3h
edward3h / localviz.bash
Last active August 21, 2020 13:42
Glue script for Mac OS X - find latest Minecraft (mcpelauncher) world, generate bedrock-viz map, open it in browser
#!/bin/bash
# Homebrew dependencies for Mac:
# brew tap bedrock-viz/tap
# brew install coreutils findutils bedrock-viz
#
# Also depends on docker
# lazy error handling :-P
set -e
@edward3h
edward3h / fusion_vs_quantum.rb
Created October 6, 2020 18:41
compare damage output of old/new fusion/melta vs old/new Quantum Shielding rules
#!/usr/bin/env ruby
require_relative 'stats'
def run_test(ndice)
acc = []
0.upto((6 ** ndice) - 1) do |dscore|
ds = dscore.to_s(6).rjust(ndice,'0').split(//).map{|s| s.to_i + 1}
v = yield(ds)
acc << v
end