Skip to content

Instantly share code, notes, and snippets.

@morgajel
morgajel / moonnames.data
Last active August 29, 2015 13:56
Mass Insertion of data into Redis with Python

I'd like to be able to easily reload data into redis from a data file using only python and redis-py.

Requirements:

  • Data needs to be in a format that is (somewhat) human readable and writable- I have lots of non-technical people willing to assist with adding options to a text file. Previously this was XML, then JSON- how I'm trying straight Redis Commands, like this:
LPUSH starroot j
LPUSH starroot c
LPUSH starroot x
@morgajel
morgajel / Description.md
Last active August 29, 2015 13:56
Skinning a World

I'm considering the options for building my world in three.js

Idea 1: Single Worldmap

My first attempt was to use a single worldmap created with perlin noise, wrapping east/west. Unfortunately that resulted in two problems:

  1. Pinching at the poles - the UV Mapping causes the top and bottom of the map to pinch (documented here: http://stackoverflow.com/questions/21766929/transforming-simplex-map-for-uv-mapping-on-a-sphere)
  2. Defining continents is difficult with a single worldmap of Perlin noise

This led me to consider another approach.

@morgajel
morgajel / gist:9065020
Created February 18, 2014 05:16
Client side map or server-side map?

Calling all Techies; I am in desperate need of guidance for Megacosm Generator; I'm having a crisis determining where maps should be generated. I am still stuck in the mindset that the maps should be generated on the server side with perlin noise and an image, but with three.js, I can do an entire planet with continual zoom on the same object.

Server-Side Pros

  • Server side means all data can be used to generate more content- moisture, terrain, distance from water, etc.

Server-Side Cons

  • Sloooow
  • Needs to be passed back to client anyways
@morgajel
morgajel / human.data
Last active August 29, 2015 13:56
Modeling Psuedo-random NPC Names with Redis data

Each race has different naming conventions, however most are a variation of a given name and a surname.

Raw Data

Each name can be broken into the following structure

[title] [pre][root][post] [trailer]

Each race has not only a distinctive set of parts, but a probability that the part will appear.

@morgajel
morgajel / gist:9166741
Last active August 29, 2015 13:56
Converting NPC Motivations from XML to redis

Megacosm generator works by randomly selecting data and piecing it together into a coherent description.

For this next section, we have motivations for NPCs (Non-Player Characters). Unlike most other NPC features, motivations have two levels; a primary motivation, followed by a motivation detail.

The previous xml data structure looks like this:

<motivation><!-- Bob is a bard who is -->
    <motive name="on a mission">
        <option>from the gods</option>

for diplomacy

@morgajel
morgajel / gist:9181844
Created February 24, 2014 04:10
bad jinja, no donut.
127.0.0.1 - - [23/Feb/2014 23:07:46] "GET /npc HTTP/1.1" 500 -
Traceback (most recent call last):
File "/home/morgajel/megacosm/env/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/home/morgajel/megacosm/env/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/morgajel/megacosm/env/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/morgajel/megacosm/env/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
@morgajel
morgajel / gist:9677595
Last active August 29, 2015 13:57
put these in order (or add more)!

Magnitude - How important is this event?

The attempted raid is _________ to the people in the city.
  • negligible
  • trivial
  • unimportant
  • of minor importance
  • of lesser concern
  • of casual interest
@morgajel
morgajel / gist:9748532
Created March 24, 2014 20:32
Landforms
ait
arête
ayre
badlands
barchan dunes
bay
bayou
beach
bight
blowhole
@morgajel
morgajel / gist:9844231
Last active August 29, 2015 13:57
drawing multiple tiles on a canvas
var geomorphTileSize = 100;
function create_geomorphdungeon(jsonblock,canvas) {
canvas.width = geomorphTileSize*jsonblock[0].length
canvas.height= geomorphTileSize*jsonblock.length
var ctx = canvas.getContext("2d");
ctx.fillStyle = "#A88442";
ctx.fillRect(0,0,jsonblock[0].length*geomorphTileSize, jsonblock.length*geomorphTileSize);