This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
import pygame.locals as locals | |
def check_adjacency(rect, px): | |
test_rect = pygame.Rect(rect.left-1, rect.top-1, rect.width+2, rect.height+2) | |
return test_rect.collidepoint(px[0], px[1]) | |
def find_groups(groups, px): | |
return [grp for grp in groups if check_adjacency(grp, px)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
import pygame | |
class Grid(object): | |
def __init__(self, size_x, size_y=None): | |
if not size_y: | |
self.size_x = size_x[0] | |
self.size_y = size_y[1] | |
else: | |
self.size_x = size_x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import random | |
import pygame | |
class Astroid: | |
def __init__(self, points=5, radius=50, | |
radius_range=10, angle_range=20): | |
self.points = points | |
self.radius = radius |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defpackage hamt | |
(:use :common-lisp) | |
(:export amt-base-node | |
amt-node | |
make-amt-base-node | |
get-entry | |
put-entry)) | |
(in-package :hamt) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(in-package :cl-user) | |
;; TODO: maybe I should use CLOS | |
(defpackage hamt | |
(:use :common-lisp) | |
(:export put get make-hamt) | |
(:shadow put get)) | |
(in-package :hamt) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(in-package :cl-user) | |
(ql:quickload '("usocket" "cl-who")) | |
(defpackage zebot | |
(:use :cl :usocket :cl-who)) | |
(in-package zebot) | |
(defvar *NICK* "botnick") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(in-package :cl-user) | |
(ql:quickload '("hunchentoot" "cl-who")) | |
(defpackage zebot-web | |
(:use :cl :hunchentoot :cl-who)) | |
(in-package zebot-web) | |
;; TODO: find a way to use symbols from other packages |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(in-package :cl-user) | |
(defpackage pset | |
(:use :cl :hamt) | |
(:export put get make-pset) | |
(:shadow put get)) | |
(in-package pset) | |
(defstruct (pset |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro case-eval (testform &body clauses) | |
"Like case, but the keys are evaluated. (They're still compared with EQL)." | |
(let ((value (gensym))) | |
`(let ((,value ,testform)) | |
(cond | |
,@(mapcar (lambda (clause) | |
(destructuring-bind (keys &body body) clause | |
(if (atom keys) | |
`((eql ,value ,keys) ,@body) | |
`((or ,@(mapcar (lambda (key) `(eql ,value ,key)) keys)) ,@body)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun read-bytes (n &optional (in *standard-input*)) | |
(apply #'+ (loop for i from 0 to (1- n) | |
collect (ash (read-byte in) (* 8 (- n (1+ i))))))) | |
(defmacro remove-keywords (form) | |
(cond ((null form) '()) | |
((integerp form) | |
`(read-bytes ,form stream)) | |
((and (consp form) (keywordp (first form))) | |
(case (first form) |
OlderNewer