;my-count:a function, which counts the number of elements in the list,
;which begin with L and end with F, where x is an wildcard
(define (my-count X L F)
(accumulate +
(every (lambda (t) (if (and (or (equal? L
(first t)
)
(equal? L
'x
)
)
(or (equal? F
(butfirst t)
)
(equal? F
'x
)
)
)
1
0
)
)
X
)
)
)
;point: a funtion which returns the points to which the hand X is
;evaluated by using the given point system
(define (point X) (+ (accumulate +
(every (lambda (t)
(cond ((equal? (butfirst t) 'A)
4
)
((and (equal? (butfirst t) 'K)
(> (my-count X (first t) 'x)
1
)
)
3
)
((and (equal? (butfirst t) 'Q)
(> (my-count X (first t) 'x)
2
)
)
2
)
((and (equal? (butfirst t) 'J)
(> (my-count X (first t) 'x)
3
)
)
1
)
(#t 0)
)
)
X
)
)
(+ (void X)
(singleton X)
)
)
)
;void:a functions which returns the the points gained by void`s in the
;hand X
(define (void X) (* 3
(accumulate +
(every (lambda (r) (if (= (my-count X r 'x) 0)
1
0
)
)
'(S H D C)
)
)
)
)
;singleton:a functions which returns the the points gained by
;singletons`s in the hand X
(define (singleton X) (* 2
(accumulate +
(every (lambda (r) (if (= (my-count X r 'x) 1)
1
0
)
)
'(S H D C)
)
)
)
)
;balanced:a function which returns #t, if the hand X is balanced, #f
;otherwise
(define (balanced X) (and (>= (my-count X 'S 'x) 3)
(>= (my-count X 'H 'x) 3)
(>= (my-count X 'D 'x) 3)
(>= (my-count X 'C 'x) 3)
)
)
;stopper:a function which returns #t, if the hand X has stoppers, #f
;otherwise
(define (stopper X) (equal? (accumulate *
(every (lambda (t)
(if (or (and (or (> (my-count X t 'A) 0)
(> (my-count X t 'K) 0)
)
(> (my-count X t 'x) 1)
)
(and (> (my-count X t 'Q) 0)
(> (my-count X t 'x) 2)
)
)
1
0
)
)
'(S H D C)
)
)
1
)
)
;longest:a function which returns a word comprised of two parts of which the last letter is the letter representing the longest suit and the rest the length of this longest suit
(define (longest X) (accumulate (lambda (x y) (cond ((< (first x)
(first y)
)
y
)
(#t x)
)
)
(every (lambda (t)
(word (my-count X t 'x) t)
)
'(C D H S)) ;se yerine word??
)
)
;OPENBID:
(define (OPENBID X) (cond ((and (< (point X) 13)
(< (butlast (longest X)) 7)
)
'PASS
)
((and (> (point X) 12)
(< (point X) 16)
)
(se 1 (last (longest X)))
)
((and (> (point X) 15)
(< (point X) 20)
(or (not (balanced X))
(not (stopper X))
)
)
(se 1 (last (longest X)))
)
((and (> (point X) 15)
(< (point X) 20)
)
'(1 NO TRUMP)
)
((and (>= (point X) 20)
(or (not (balanced X))
(not (stopper X))
)
)
(se 2 (last (longest X)))
)
((>= (point X) 20)
'(2 NO TRUMP)
)
((and (> (point X) 6)
(< (point X) 13)
(> (butlast (longest X)) 6)
)
(se 3 (last (longest X)))
)
(#t 'PASS)
)
)