-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.scm
67 lines (53 loc) · 1.69 KB
/
main.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
(c-declare #<<c-declare-end
#include "struct.h"
c-declare-end
)
(define (bla msg)
(print msg))
(c-define (doinc a) (int) int "doinc" ""
(print "doinc\n")
(+ a 1))
(define (make-bottle capacity filling towin)
(define (get-capacity) capacity)
(define (get-filling) filling)
(define (get-towin) towin)
(define (self message)
(case message
((capacity) get-capacity)
((filling) get-filling)
((towin) get-towin)
(else (error "unknown message for bottle"))))
self)
;(define-structure bottle capacity filling towin)
(define (find-towin bottle)
(let* ((minn 1)
(maxx ((bottle 'capacity)))
(fill ((bottle 'filling)))
(candidate (+ minn (random-integer (- maxx minn)))))
(if (= candidate fill)
(find-towin bottle)
candidate)))
(define (make-random-bottle maxcapacity iswinningbottle)
(let* ((capacity (+ 2 (random-integer (- maxcapacity 1))))
(filling (+ 1 (random-integer (- capacity 1)))))
(if iswinningbottle
(let ((find-towin (lambda ()
(make-bottle capacity filling -1)))
(define (make-random-bottles maxbottles maxcapacity howmanytowin)
(letrec ((subfunc (lambda (curbottles)
(if (< (length curbottles) maxbottles)
(subfunc (cons (make-random-bottle maxcapacity) curbottles))
curbottles))))
(subfunc '())))
(define (tag-bottles-towin howmany bottles)
(letrec ((subfunc (lambda (howmany bottles togo)
(let ((bottle (car bottles)))
(if (= togo 0)
(
(define (make-random-game difficulty)
(define-structure mystruct a b)
;(c-define-type mystruct "mystruct")
(c-define (makestruct a b) (int int) () "makestruct" ""
(println "makestruct")
(make-mystruct (+ a 11) (+ b 22)))
;(bla "wurst\n")