Skip to content

Instantly share code, notes, and snippets.

class Node(object):
"""A node in the road graph. Node functionality doesn't matter, we just
need something to refer to by name."""
def __lt__(self, other):
"""Use the object ID Just so we have a canonical way to sort Nodes."""
id(self) < id(other)
class Edge(object):
@ChadSki
ChadSki / MAPMAKER.BAS
Created October 29, 2016 05:37
QBASIC tile-based map
DECLARE SUB clearline ()
DECLARE SUB save ()
DECLARE SUB save1 ()
DECLARE SUB wtile ()
DECLARE SUB tracker ()
DECLARE SUB wlocate ()
DECLARE SUB z014 ()
DECLARE SUB z013 ()
DECLARE SUB z012 ()
DECLARE SUB z011 ()
@ChadSki
ChadSki / ADVENTUR.BAS
Created October 29, 2016 05:31
Battle System
DECLARE SUB spellatk ()
DECLARE SUB Battle ()
DECLARE SUB border ()
DECLARE SUB msattle ()
DECLARE SUB deleteone ()
DECLARE SUB cdisplay ()
DECLARE SUB deletemenu ()
DECLARE SUB delete ()
DECLARE SUB savechar ()
DECLARE SUB charback ()
using System;
using System.Runtime.InteropServices;
namespace CPythonBinding
{
class Program
{
[DllImport("python34.dll")]
public static extern void Py_Initialize();
let rec TakeAction (gs:GameState) : bool =
// -snip-
// Not sure which card to choose, so let's try them all!
// `None` represents not imprinting a card.
// Stop if a possibility wins the game (`List.exists` will short-circuit).
None :: (gs.Hand |> Seq.distinct
|> Seq.map (fun card -> Some card)
|> Seq.toList)
@ChadSki
ChadSki / scores.md
Last active June 4, 2016 12:54
slither.io bot scores

Tested from ~12:30am to ~7:15pm on 6/2/2016 (PST)

improve (74fea5f)

median=4530

[14, 25, 26, 32, 41, 43, 46, 49, 51, 56, 59, 61, 64, 66, 76, 83, 86, 91, 91,
 97, 97, 101, 106, 114, 117, 119, 120, 121, 125, 129, 133, 135, 135, 141,
 143, 148, 149, 154, 155, 158, 159, 161, 163, 165, 166, 166, 175, 197, 211,

212, 218, 218, 240, 242, 245, 247, 248, 249, 254, 254, 260, 263, 265, 270,

window.collisionCheck = function(circle1, circle2) {
distance = Math.sqrt(Math.pow(circle1.x - circle2.x, 2) +
Math.pow(circle1.y - circle2.y, 2));
if (distance > circle1.radius + circle2.radius) {
// Definitely no collision
return false;
}
// Technically circles have two collision points. This seems to be the average or center of the collision.
collisionPointX = ((circle1.x * circle2.radius) + (circle2.x * circle1.radius)) / (circle1.radius + circle2.radius);
# before
if is_solved(square):
print("| {} ".format(solution(square)), end='')
else:
print("| ", end='') # unknown remains empty
# after
fill = str(solution(square)) if is_solved(square) else " "
print("| {} ".format(fill), end='')
# Sudoku! No solving, just getting started.
def init_board(template):
"""Given a template, returns a list of list of sets. The 2D grid
represents the board, and the sets represent remaining possible
values for that square.
Parameters
----------
/*
* Simple Test program for libtcc
*
* libtcc can be useful to use tcc as a "backend" for a code generator.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "libtcc.h"