Skip to content

Instantly share code, notes, and snippets.

View Metapyziks's full-sized avatar
🏡
Working from home

James King Metapyziks

🏡
Working from home
View GitHub Profile
@Metapyziks
Metapyziks / trafficjam.cs
Created March 15, 2012 16:32
Traffic jam puzzle solver (6x6 grid)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace TrafficJamSolver
{
class Car
@Metapyziks
Metapyziks / listaddrrange.cs
Created April 26, 2012 13:03
Adding a range to List and LinkedList speed comparison
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace ListTest
{
static class Program
{
public static void AppendMany<T>( this LinkedList<T> collection, params T[] elements )
{
@Metapyziks
Metapyziks / FramedStream.cs
Created May 19, 2012 12:32
FramedStream class to make reading hierarchy based files cleaner and safer
public class FramedStream : Stream
{
private struct Frame
{
public readonly long Offset;
public readonly long Size;
public Frame( long offset, long size )
{
Offset = offset;
@Metapyziks
Metapyziks / Component.cs
Created May 28, 2012 09:17
Component based Entity
public abstract class Component
{
public static T Create<T>( Entity ent )
where T : Component
{
Type t = typeof( T );
ConstructorInfo c = t.GetConstructor( new Type[] { typeof( Entity ) } );
if ( c == null )
throw new MissingMethodException( "Type " + t.FullName + " is missing a valid constructor." );
using OpenTK;
using Zombles.Geometry;
using Zombles.Entities;
namespace Zombles.Scripts
{
public class CorePlugin : Plugin
{
private Entity myEnt;
private bool InRange( District district )
{
float xdiff = 0.0f, ydiff = 0.0f;
if ( Center.X < district.Bounds.Left )
xdiff = Math.Min( district.Bounds.Left - Center.X, Center.X - district.Bounds.Right + City.Width );
else if ( Center.X > district.Bounds.Right )
xdiff = Math.Min( Center.X - district.Bounds.Right, district.Bounds.Left - Center.X + City.Width );
if ( Center.Y < district.Bounds.Top )
ydiff = Math.Min( district.Bounds.Top - Center.Y, Center.Y - district.Bounds.Bottom + City.Height );
else if ( Center.Y > district.Bounds.Bottom )
@Metapyziks
Metapyziks / game.log
Created June 9, 2012 16:48
AI Challenge game log
# new game staring with properties:
turns 500
seed 148810562
fow true
timeout 1000
vrange 5
# loading map
teams 2
width 16
height 16
import java.security.*;
public class HashTest
{
public static void main(String[] args)
throws Exception
{
System.out.println(hash("testing"));
}
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
namespace FoobarControlServer
{
class Program
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Xml.Linq;
public abstract class Fetchable
{
protected static String BuildURL(String baseURL, params Object[] pairs)
{