Skip to content

Instantly share code, notes, and snippets.

Created March 24, 2014 21:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
My implementation in Scheme of the game Kinema, that was published in BASIC Computer Games in 1978.
(use srfi-13 extras)
(printf #<<EOF
Adaption of BASIC computer game from 1978
(define correct-count)
(define (prompt-and-evaluate-answer question answer)
(display question)
(display "? ")
(let ((G (read)))
(if (> .15 (abs (/ (- G answer) answer)))
(display "Close enough.")
(set! correct-count (+ correct-count 1)))
(display "Not even close...."))
(printf "Correct answer is ~A\n" answer)))
(define (main)
(newline) (newline)
(let* ((velocity (+ 5 (random 35)))
(time (/ (+ 1 (* 2 (random velocity))) 10)))
(set! correct-count 0)
"A ball is thrown upwars at ~A meters per second.\n\n"
"How high will it go (in meters)"
(* .05 (* velocity velocity)))
"How long until it returns (in seconds)"
(/ velocity 5))
(sprintf "What will its velocity be after ~A seconds" time)
(- velocity (* 10 time)))
(printf "\n~A right out of 3." correct-count)
(when (> correct-count 2) (display " not bad!"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment