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
;; adapted to lisp from the python code found here: | |
;; http://www.mcts.ai/?q=code/python | |
(defgeneric do-move (state move)) | |
(defgeneric get-random-move (state)) | |
(defgeneric get-moves (state)) | |
(defgeneric get-result (state player-just-moved)) | |
(defgeneric clone (state)) | |
(defgeneric print-state (state)) | |
(defgeneric player-just-moved (state)) |
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
#include "lapis.h" | |
#include <math.h> | |
#define DIAMETER 30 | |
#define PI 3.1415926 | |
struct los | |
{ | |
float default_mina, default_maxa; |
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 *valid-chars* '(#\a #\b #\c #\d #\e #\f #\g #\h #\i #\j #\k #\l #\m #\n #\o #\p #\q #\r #\s #\t #\u #\v #\w #\x #\y #\z)) | |
(defparameter *table* nil) | |
(defparameter *norm-table* nil) | |
(defun build-table () | |
(setf *table* (make-hash-table)) | |
(with-open-file (in #p"corpus.txt" :direction :input) | |
(loop with lower-c with c with p while (not (eql c :eof)) do | |
(setf c (read-char in nil :eof) |
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
(defun classify (means data dist-func) | |
(let ((sets (loop for m in means collect '()))) | |
(loop for d in data do | |
(let ((min 0) | |
(dist (funcall dist-func d (car means)))) | |
(loop for m in (cdr means) for n from 1 do | |
(when (< (funcall dist-func d m) dist) | |
(setf min n | |
dist (funcall dist-func d m)))) | |
(push d (nth min sets)))) |
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
class Perlin (object): | |
def __init__(self, seed=0): | |
self.seed = seed | |
self.hash = [208,34,231,213,32,248,233,56,161,78,24,140,71,48,140,254,245,255,247,247,40, | |
185,248,251,245,28,124,204,204,76,36,1,107,28,234,163,202,224,245,128,167,204, | |
9,92,217,54,239,174,173,102,193,189,190,121,100,108,167,44,43,77,180,204,8,81, | |
70,223,11,38,24,254,210,210,177,32,81,195,243,125,8,169,112,32,97,53,195,13, | |
203,9,47,104,125,117,114,124,165,203,181,235,193,206,70,180,174,0,167,181,41, | |
164,30,116,127,198,245,146,87,224,149,206,57,4,192,210,65,210,129,240,178,105, | |
228,108,245,148,140,40,35,195,38,58,65,207,215,253,65,85,208,76,62,3,237,55,89, |
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
#include <gtk/gtk.h> | |
static gboolean | |
menu_close_program(GtkWidget *widget, | |
GdkEvent *event, | |
gpointer data) | |
{ | |
gtk_main_quit(); | |
return TRUE; |
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
static void | |
write_header(FILE *out, int width, int height, int max_color_val) | |
{ | |
fprintf(out, "P3\n%d %d\n%d\n", height, width, max_color_val); | |
} | |
static void | |
write_color_val(FILE *out, int red, int green, int blue) | |
{ |
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
(defpackage #:perlin | |
(:use #:cl) | |
(:export #:perlin2d | |
#:*seed*)) | |
(in-package #:perlin) | |
(declaim (optimize (speed 3) (safety 0) (debug 0))) | |
(defparameter *seed* 0) |
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
#include <stdio.h> | |
static int SEED = 0; | |
static int hash[] = {208,34,231,213,32,248,233,56,161,78,24,140,71,48,140,254,245,255,247,247,40, | |
185,248,251,245,28,124,204,204,76,36,1,107,28,234,163,202,224,245,128,167,204, | |
9,92,217,54,239,174,173,102,193,189,190,121,100,108,167,44,43,77,180,204,8,81, | |
70,223,11,38,24,254,210,210,177,32,81,195,243,125,8,169,112,32,97,53,195,13, | |
203,9,47,104,125,117,114,124,165,203,181,235,193,206,70,180,174,0,167,181,41, | |
164,30,116,127,198,245,146,87,224,149,206,57,4,192,210,65,210,129,240,178,105, |
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 *world* | |
(append | |
(loop for count below 50 collect | |
(let* ((r (random 256)) | |
(g (random 256)) | |
(b (random 256)) | |
(angle (/ (* 6 3.14159 count) 50)) | |
(rad (- 2 (* 2 (/ count 50.0)))) | |
(x (* rad (sin angle))) | |
(z (* rad (cos angle))) |
NewerOlder