;;; Scheme Recursive Art Contest Entry ;;; ;;; Please do not include your name or personal info in this file. ;;; ;;; Title: ;;; ;;; Description: ;;; (define (get_axes shape) (let ((first (car shape))) (define (helper shape) (if (null? (cdr shape)) (list(get_normal (list (car shape) first))) (append(list (get_normal (list(car shape)(car (cdr shape))))) (helper (cdr shape))) ) ) (helper shape) ) ) (define (get_normal pair) (list (*(-(car (cdr (car (cdr pair)))) (car(cdr(car pair))))-1) (-(car (car (cdr pair))) (car(car pair))) ) ) (define (get_projection axis shape) (extreme (map (lambda (vec) (dot axis vec)) shape)) ) (define (get_projections axises shape) (map (lambda (axis) (extreme (map (lambda (vec) (dot axis vec)) shape)) ) axises) ) (define (extreme lst) (define (helper lst store proc) (if (null? lst) store (if (proc (car lst) store) (helper (cdr lst) (car lst) proc) (helper (cdr lst) store proc) ) ) ) (list (helper lst (car lst) >) (helper lst (car lst) <) ) ) (define (dot a b) (+ (* (car a) (car b)) (*(car (cdr a))(car (cdr b)) )) ) (define (intersect a b) (define (test_projections x y) (if (null? x) nil (cons (overlap (car x) (car y)) (test_projections (cdr x) (cdr y))) ) ) (all(test_projections (get_projections (append (get_axes a) (get_axes b)) a) (get_projections (append (get_axes a) (get_axes b)) b))) ) (define (all lst) (if (null? lst) #t (if (not (car lst)) #f (all (cdr lst)) ) ) ) (define (overlap x y) (let ( (x1 (car (cdr (extreme x)))) (x2 (car (extreme x))) (y1 (car (cdr (extreme y)))) (y2 (car (extreme y))) ) (and (> x2 y1) (>= y2 x1)) ) ) (define start (modulo 888888 2147483647)) (define (random seed) (let ( (next_seed (modulo(* seed 16807)2147483647) ) (return_value (/ (- (modulo(* seed 16807)2147483647)1) 2147483646) ) ) (list next_seed return_value) ) ) (define (real_random) (let ( (pair (random start)) ) (set! start (car pair)) (car (cdr pair)) ) ) (define (to_list num) (if (< num 1000) (list num) (append (to_list (quotient num 1000)) (list(modulo num 1000))))) (define (to_pairs num_list scale transx transy) (if (null? (or (cdr (cdr num_list)))) (list (list (+(*(- (car num_list) 250) scale)transx) (* (+(*(- (car (cdr num_list)) 250) scale)transy) -1) )) (cons (list (+(* (-(car num_list)250) scale)transx) (* (+(*(- (car (cdr num_list)) 250) scale)transy) -1)) (to_pairs (cdr (cdr num_list)) scale transx transy)))) (define (spam tries hitbox) (if (< tries 20) (let ((scale (real_random)) (transx (- ( *(real_random) 1000) 500)) (transy (- (* (real_random) 1000) 500)) (angle (*(real_random) 2 3.14))) (define (helper hitboxes) (if (null? hitboxes) (begin (draw_denero scale transx transy angle) (spam (+ 1 tries) (cons (generate_hitbox scale transx transy angle) hitbox)) ) (if (intersect (car hitboxes) (generate_hitbox scale transx transy angle)) (spam tries hitbox) (helper (cdr hitboxes)) ) ) ) (helper hitbox) ) ) ) (define (generate_hitbox scale transx transy angle) (let ((coords (+ (* (expt 10 83) 3791533420732730152130241450000) (* (expt 10 42) 24080000220007286011317054407075442135502) 197549268541326483354396374346371240))) (rotated_list (to_pairs (to_list coords) scale transx transy) angle) ) ) (define (draw_denero scale transx transy angle) (let ((coords '(068288021281007286011317054407078399068288 046309040330056375068382063324046309 336271345236371240374346351375336271 348281363298354341347348342309348281 197549268541326483135502197549 311109041148075442135502326483354396311109 098306119282129279168284177304175305109305098306 109305122313153313175305154288129291109305 321284283259244271235290244295310283321284 244295253278279271310283286295262298244295 233279241265287246329257284262233279 175290129279079294123268160274175290 131423192437259427297412263462195473131423 155434192444257434286422253451194460155434 204300172378185396191390249383255390259362204300 185288195306202392224407241389216306221284185288 323400283369310404323400 109419139393120421109419 176440175447155434176440 267430268438286422267430 273015213024145000220135342073273015 342073220135306179332251342309379153342073 145000024080094179220135145000 001220028293063332063246094179024080000220 133290129295129306136313150289133290 150289136313149313156306156295150289 139293135297135303139308145293139293 145293139308145308150303150297145293 147294145296145299147301150294147294 150294147301150301152299152296150294 279271263275260279260290287279279271 260290267297281296287290287279260290 266281266287270292276292270277266281 276277270277276292281287281281276277 280279277286280286283284283281280279 277279275281275284277286280279277279)) (colors (list "#DC8C81" "#D68074" "#DC8C81" "#D68074" "#EEBCB3" "#EEBCB3" "#DC8C81" "#FFFFFF" "#DC8C81" "#FFFFFF" "#392A23" "#392A23" "#DD9599" "#FFFFFF" "#DC8C81" "#ECCFC9" "#DC8C81" "#DC8C81" "#000000" "#000000" "#392A23" "#392A23" "#392A23" "#392A23" "#6F4D32" "#6F4D32" "#000000" "#000000" "#FFFFFF" "#FFFFFF" "#6F4D32" "#6F4D32" "#000000" "#000000" "#FFFFFF" "#FFFFFF")) ) (full_draw (map (lambda (x) (rotated_list x angle)) (map (lambda (x) (to_pairs x scale transx transy)) (map to_list coords))) colors))) ;;; (define (rotated_list lst angle) (if (null? (cdr lst)) (list (rotation (car lst) angle)) (cons (rotation (car lst) angle) (rotated_list (cdr lst) angle))) ) (define (rotation pair angle) (list (- (* (car pair) (cos angle)) (*(car (cdr pair)) (sin angle))) (+ (* (car pair) (sin angle)) (*(car (cdr pair)) (cos angle)))) ) (define (full_draw nested_list colors) (if (not (null? nested_list)) (begin (draw_shape (car nested_list) (car colors)) (full_draw (cdr nested_list) (cdr colors))))) (define (draw_shape pairs colors) (pu) (color colors) (setposition (car (car pairs)) (car (cdr (car pairs)))) (pd) (begin_fill) (define (helper pairs) (if (null? pairs) (begin (pu) (end_fill) ) (begin (setposition (car (car pairs)) (car (cdr (car pairs))) ) (helper (cdr pairs)) ) ) ) (helper (cdr pairs)) ) (speed 0)(screen_width)(screen_height)(hideturtle) (bgcolor "#f3e3d2") (define (draw) (color "#9f6934") (spam 0 ()) (exitonclick)) ; Please leave this last line alone. You may add additional procedures above ; this line. (draw)