This file contains 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
;; CLISP特有のソケットコマンド・バイト/文字列変換コマンドを使っている | |
;; 日本語を利用するためのエンコーディング指定 | |
(setf *terminal-encoding* charset:utf-8) | |
(setf *default-file-encoding* charset:utf-8) | |
;; 16進数で表されたASCIIコードをデコードする | |
(defun http-char (c1 c2 &optional (default #\space)) | |
(let ((code (parse-integer | |
(coerce (list c1 c2) 'string) |
This file contains 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
(defparameter *width* 100) | |
(defparameter *height* 30) | |
(defparameter *jungle* '(45 10 10 10)) | |
(defparameter *plant-energy* 80) | |
;; key => (x座標 . y座標), value => t | |
;; コンスセルを比較するにはequalが必要となる為、:test #'equalとしている | |
(defparameter *plants* (make-hash-table :test #'equal)) | |
(defparameter *reproduction-energy* 200) | |
(defstruct animal x y energy dir genes) |
This file contains 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
(defparameter *robot-num* 10) | |
(defun robots () | |
;; namedによって(return-from main とループを抜けれるように名前を持たせている | |
(loop named main | |
;; 幅64のゲーム盤におけるオフセット | |
;; withはループ内にローカル変数を作成する | |
with directions = '((q . -65) (w . -64) (e . -63) | |
(a . -1) (d . 1) | |
(z . 63) (x . 64) (c . 65)) |
This file contains 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
(load "graph_util") | |
(defparameter *congestion-city-nodes* nil) | |
(defparameter *congestion-city-edges* nil) | |
(defparameter *visited-nodes* nil) | |
(defparameter *node-num* 30) | |
(defparameter *edge-num* 45) | |
(defparameter *worm-num* 3) | |
(defparameter *cop-odds* 15) |
This file contains 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
require 'yaml' | |
require 'hashie' | |
require 'readline' | |
@env = Hashie::Mash.new(YAML.load_file("./world.yml")) | |
@allowed_commands = %w(look walk pickup inventory) | |
@location = :living_room | |
def look | |
res = [] |
This file contains 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
;; 使い方 | |
;; 有向グラフ (graph->png "graph.dot" *wizard-nodes* *wizard-edges*) | |
;; 無向グラフ (ugraph->png "ugraph.dot" *wizard-nodes* *wizard-edges*) | |
(defparameter *wizard-nodes* '((living-room (you are in the living-room. | |
a wizrd is snoring loudly on the couch.)) | |
(garden (you are in a beautiful garden. | |
there is a well infront of you.)) | |
(attic (you are in the attic. | |
there is a giant welding torch in the corner.)))) |
This file contains 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
#!/opt/local/bin/ruby1.9 | |
#-*-encoding: utf-8-*- | |
class Env < Hash | |
def initialize(parms=[], args=[], outer=nil) | |
h = Hash[parms.zip(args)] | |
self.merge!(h) | |
@outer = outer | |
end | |
def find(key) |
This file contains 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
;; *** REPL *** | |
(defun game-repl () | |
(let ((cmd (game-read))) | |
(unless (eq (car cmd) 'quit) | |
(game-print (game-eval cmd)) | |
(game-repl)))) | |
;; 入力に対して()を補い第二引数以降をシンボルとする | |
;; ex. walk east far => (WALK 'EAST 'FAR) | |
(defun game-read () |
This file contains 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
# coding: utf-8 | |
class Concern < ActiveRecord::Base | |
belongs_to :publication | |
end |
This file contains 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
# The stack I wrote for http://vimeo.com/26391171 | |
# Note that there is an intentional bug in the each method :) | |
class Stack | |
Node = Struct.new :data, :next | |
def push(data) | |
@head = Node.new data, @head | |
end |