Skip to content

Instantly share code, notes, and snippets.

View tommyettinger's full-sized avatar
⚙️
Keeping the commit streak alive

Tommy Ettinger tommyettinger

⚙️
Keeping the commit streak alive
View GitHub Profile
#[ Written by Tommy Ettinger in 2017, based on work by Melissa O'Neill in 2015:
PCG-Random, http://www.pcg-random.org/
To the extent possible under law, the author has dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.
See <http://creativecommons.org/publicdomain/zero/1.0/>. ]#
var x*: uint64 # The state can be seeded with any value.
package com.carterza.planet.map.generator.pathfind;
import com.badlogic.gdx.ai.pfa.Connection;
import com.badlogic.gdx.ai.pfa.Heuristic;
/**
* Created by zachcarter on 12/20/16.
*/
public class TiledElevationDistance<N extends TiledTerrainNode> implements Heuristic<N> {
private Coord findLowerElevation(Coord currentLocation, GreasedRegion riverBlockages,
GreasedRegion heights, GreasedRegion reuse, GreasedRegion temp) {
heights.refill(heightData.data, Sand, heightData.data[currentLocation.x][currentLocation.y])
.andNot(riverBlockages);
reuse.clear().insert(currentLocation);
temp.remake(reuse).fringe();
int searchDistance = 40;
for(int d = 1; d < searchDistance; d++)
{
@tommyettinger
tommyettinger / FactionMap.java
Last active December 17, 2016 23:41 — forked from zacharycarter/FactionMap.java
Update hoping to fix
private void generateFactionMap(final int factionCount, double controlledFraction) {
MultiSpill spreader = new MultiSpill(new short[WIDTH][HEIGHT], Spill.Measurement.MANHATTAN, CommonRNG.getRng());
OrderedMap<Coord, Double> entries = new OrderedMap<>();
char[][] map = new char[WIDTH][HEIGHT];
short[][] regionMap = new short[WIDTH][HEIGHT];
for(int x = 0; x < WIDTH; x++) {
for(int y = 0; y < HEIGHT; y++) {
if(tiles[x][y].heightValue >= Sand)
(include "globals.clj")
(def c-subj (atom ""))
(def temp1 (atom 0))
(def m1_flag (atom ""))
(def m2_flag (atom ""))
(def temp3 (atom 0))
(def flag (atom 0))
(def temp2 (atom 0))
(def email-c (mailer {:host "smtp.gmail.com"
:port 587
@tommyettinger
tommyettinger / diff.clj
Last active August 29, 2015 14:06 — forked from dagda1/diff.clj
(defn diff [l1 l2]
(let [a (group-by identity l1)
b (group-by identity l2)]
(mapcat #(repeat
(-
(count (second %))
(count (get b (key %))))
(key %))
a)))
(defn multiple-trials [m n]
( loop [m m acc []]
(if (> m 0)
(recur (dec m) (conj acc (compute-winnings-for-a-trial n)))
acc)))
{
"nil": {
"description": "Nothingness (from tiles.yml)",
"glyph": " ",
"day_color": {
"between": [
"black",
"black"
],
"mix": [
(ns opal.dbpedia
(:use [clojure.tools.logging :only [log]])
(:require [clojure.java.io :as io])
(:import [uk.ac.manchester.cs.owl.owlapi.turtle.parser TurtleParser]
[org.neo4j.graphdb Label]
[org.neo4j.index.lucene.unsafe.batchinsert LuceneBatchInserterIndexProvider]
[org.neo4j.unsafe.batchinsert BatchInserters]
[org.neo4j.graphdb DynamicRelationshipType]))
;; PARSING METHODS
(def queen
[:range :no :range :no :range
:no :range :range :range :no
:range :range :self :range :range
:no :range :range :range :no
:range :no :range :no :range
])