-
Notifications
You must be signed in to change notification settings - Fork 6
/
test16.ss
135 lines (121 loc) · 3.34 KB
/
test16.ss
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!r6rs
(import (rnrs)
(QobiScheme)
(nondeterministic-scheme)
(games7a))
(define (test1)
(for-each (lambda (words)
(write words)
(newline)
(write (length (domain (a-top-down-parse (parse-type *s*) words))))
(newline)
(newline))
(append *tic-tac-toe* *hexapawn*)))
(define *tic-tac-toe-initital-state*
(make-state
'#(#(#f #f #f) #(#f #f #f) #(#f #f #f)) '#(x x x x x) '#(o o o o o) 'x))
(define *hexapawn-initital-state*
(make-state
'#(#(x x x) #(#f #f #f) #(o o o)) '#(#f #f #f #f #f) '#(#f #f #f #f #f) 'x))
(define *state*
(make-state '#(#(x x x) #(x x x) #(x x o)) '#(x x x x x) '#(o o o o o) 'x))
(define (test2)
(possibly-true? (first *tic-tac-toe*) (things) *tic-tac-toe-initital-state*))
;;; erroneously yields #t
(define (test3)
(possibly-true? (first *tic-tac-toe*) (things) *hexapawn-initital-state*))
(define (test4)
(possibly-true? (first *hexapawn*) (things) *tic-tac-toe-initital-state*))
;;; erroneously yields #f
(define (test5)
(possibly-true? (first *hexapawn*) (things) *hexapawn-initital-state*))
(define (test6)
(possibly-true? '(some cache square has some piece)
(things)
*tic-tac-toe-initital-state*))
(define (test7)
(let ((some
(evaluate
(parse-expression
'(rlambda (noun1) (lambda (noun2) (some noun1 noun2)))
(parse-type *d*))
'()
(things)
*tic-tac-toe-initital-state*))
(cache
(evaluate
(parse-expression
'(rlambda (noun)
(lambda (thing1)
(and (noun thing1 (-> thing boolean))
(some
(lambda (thing2) (player? thing2))
(lambda (thing2)
(some
(lambda (thing3) (cache? thing3 thing2))
(lambda (thing3) (square? thing1 thing3))))))))
(parse-type *a*))
'()
(things)
*tic-tac-toe-initital-state*))
(square
(evaluate
(parse-expression
'(lambda (thing1)
(some (lambda (thing2)
(or (row? thing2)
(column? thing2)
(diagonal? thing2)
(some (lambda (thing3) (player? thing3))
(lambda (thing3) (cache? thing2 thing3)))))
(lambda (thing2) (square? thing1 thing2))))
(parse-type *n*))
'()
(things)
*tic-tac-toe-initital-state*))
(has
(evaluate
(parse-expression
'(rlambda (np2)
(llambda (np1)
(np2 (lambda (thing2)
(np1 (lambda (thing1) (has? thing1 thing2))
(-> (-> thing boolean) boolean)))
(-> (-> thing boolean) boolean))))
(parse-type *v-np*))
'()
(things)
*tic-tac-toe-initital-state*))
(piece
(evaluate
(parse-expression
'(lambda (thing1)
(some (lambda (thing2) (player? thing2))
(lambda (thing2) (piece? thing1 thing2))))
(parse-type *n*))
'()
(things)
*tic-tac-toe-initital-state*)))
(call (call has
(call some piece (things) *tic-tac-toe-initital-state*)
(things)
*tic-tac-toe-initital-state*)
(call some
(call cache square (things) *tic-tac-toe-initital-state*)
(things)
*tic-tac-toe-initital-state*)
(things)
*tic-tac-toe-initital-state*)))
(define (test8)
(possibly-true? '(every square has some piece) (things) *state*))
(define (test9)
(domain
(begin (write (a-phrase-of-value #t (parse-type *s*) (things) *state* 1))
(newline)
(fail))))
(define (test10)
(domain (begin (let ((words (a-phrase-of-type (parse-type *s*) 5)))
(unless (possibly-true? words (things) *state*) (fail))
(write words)
(newline))
(fail))))