15523880959e
Add loom 3
author | Steve Losh <steve@stevelosh.com> |
---|---|
date | Tue, 06 Feb 2018 20:52:03 -0500 |
parents | 099a7c07ba2a |
children | 3e57244fd53c |
branches/tags | (none) |
files | src/main.lisp src/robots/bit-loom.lisp |
Changes
--- a/src/main.lisp Tue Feb 06 19:08:04 2018 -0500 +++ b/src/main.lisp Tue Feb 06 20:52:03 2018 -0500 @@ -40,19 +40,19 @@ (* h 60)) -(defun generate-tweet (generator) +(defun generate-tweet (generator args) (do-repeat 100 - (multiple-value-bind (text media) (funcall generator) + (multiple-value-bind (text media) (apply generator args) (when (tt-tweetable-p text) (return (values text media)))))) -(defun run-bot (bot &key (force nil) (dry t)) +(defun run-bot (bot &key (force nil) (dry t) bot-args) (with-bot (bot) (format t "Running ~S~%" name) (when (or force (not (db-tweeted-since-p name (hours-to-minutes hours)))) - (multiple-value-bind (tweet media) (generate-tweet generator) + (multiple-value-bind (tweet media) (generate-tweet generator bot-args) (if (null tweet) (format t "Could not generate a suitable tweet for ~S~%" name) (progn
--- a/src/robots/bit-loom.lisp Tue Feb 06 19:08:04 2018 -0500 +++ b/src/robots/bit-loom.lisp Tue Feb 06 20:52:03 2018 -0500 @@ -16,20 +16,28 @@ (flax.looms.002-wobbly-lines:loom seed ticks "out.png" 2000 400) (format nil "~R ticks" ticks))) -(defparameter *looms* '(loom-1 loom-2)) +(defun loom-3 (seed) + (flax.looms.003-basic-l-systems::loom-anabaena-catenula seed "out.png" 2000 2000) + (format nil "variety: anabaena catenula")) + +(defparameter *looms* '(loom-1 loom-2 loom-3)) -(defun generate-image (seed) +(defun generate-image (seed &key force-loom) (let* ((loom-index (random (length *looms*))) + (loom-index (if force-loom + (1- force-loom) + loom-index)) (loom (elt *looms* loom-index))) - (pr 'running loom) + (format t "Running ~A~%" loom) + (force-output) (let ((extra (funcall loom seed))) (resize "out.png" 1200) (values (1+ loom-index) extra)))) -(defun random-tweet () +(defun random-tweet (&key force-loom) (let ((seed (random (expt 2 32)))) (multiple-value-bind (loom-number extra-information) - (generate-image seed) + (generate-image seed :force-loom force-loom) (values (string-upcase (format nil "loom ~R, seed ~D~A" loom-number seed