Correction to default probability calculation.
More tweaking of the profj grammars svn: r7032
This commit is contained in:
parent
aa871e90bd
commit
dbe82ab7d7
|
@ -391,14 +391,12 @@
|
||||||
#;(when (pair? look-back)
|
#;(when (pair? look-back)
|
||||||
(printf "look-back is a pair~n"))
|
(printf "look-back is a pair~n"))
|
||||||
#;(when (res? look-back)
|
#;(when (res? look-back)
|
||||||
(printf "lookbac is a res, ~a~n" (fail-type? (res-possible-error look-back))))
|
(printf "lookback is a res, ~a~n" (fail-type? (res-possible-error look-back))))
|
||||||
(let* ([seq-fail-maker
|
(let* ([seq-fail-maker
|
||||||
(lambda (fail)
|
(lambda (fail)
|
||||||
(let-values ([(kind expected found) (get-fail-info fail)])
|
(let-values ([(kind expected found) (get-fail-info fail)])
|
||||||
(make-sequence-fail
|
(make-sequence-fail
|
||||||
(cond
|
(compute-chance len seen-len used alts (fail-type-chance fail))
|
||||||
[(= 0 used) (fail-type-chance fail)]
|
|
||||||
[else (compute-chance len seen-len used alts (fail-type-chance fail))])
|
|
||||||
(fail-type-src fail)
|
(fail-type-src fail)
|
||||||
name used
|
name used
|
||||||
(+ used (fail-type-may-use fail) next-used)
|
(+ used (fail-type-may-use fail) next-used)
|
||||||
|
@ -419,18 +417,20 @@
|
||||||
seq-fail))))]))))
|
seq-fail))))]))))
|
||||||
|
|
||||||
(define (compute-chance expected-length seen-length used-toks num-alts sub-chance)
|
(define (compute-chance expected-length seen-length used-toks num-alts sub-chance)
|
||||||
(let* ([revised-expectation (+ (- used-toks seen-length) expected-length)]
|
(if (zero? used-toks)
|
||||||
[probability-with-sub (* (/ (add1 used-toks) revised-expectation) (/ 1 num-alts))]
|
(* (* (/ 1 expected-length) (/ 1 num-alts)) sub-chance)
|
||||||
[probability-without-sub (* (/ used-toks revised-expectation) (/ 1 num-alts))]
|
(let* ([revised-expectation (+ (- used-toks seen-length) expected-length)]
|
||||||
[expected-sub probability-with-sub]
|
[probability-with-sub (* (/ (add1 used-toks) revised-expectation) (/ 1 num-alts))]
|
||||||
[expected-no-sub probability-without-sub]
|
[probability-without-sub (* (/ used-toks revised-expectation) (/ 1 num-alts))]
|
||||||
[probability (/ (* expected-sub sub-chance) (+ (* expected-sub sub-chance)
|
[expected-sub probability-with-sub]
|
||||||
(* expected-no-sub (- 1 sub-chance))))])
|
[expected-no-sub probability-without-sub]
|
||||||
#;(printf "compute-chance: args ~a ~a ~a ~a ~a~n"
|
[probability (/ (* expected-sub sub-chance) (+ (* expected-sub sub-chance)
|
||||||
expected-length seen-length used-toks num-alts sub-chance)
|
(* expected-no-sub (- 1 sub-chance))))])
|
||||||
#;(printf "compute-chance: intermediate values: ~a ~a ~a ~a ~a~n"
|
#;(printf "compute-chance: args ~a ~a ~a ~a ~a~n"
|
||||||
revised-expectation probability-with-sub probability-without-sub expected-sub expected-no-sub)
|
expected-length seen-length used-toks num-alts sub-chance)
|
||||||
probability))
|
#;(printf "compute-chance: intermediate values: ~a ~a ~a ~a ~a~n"
|
||||||
|
revised-expectation probability-with-sub probability-without-sub expected-sub expected-no-sub)
|
||||||
|
probability)))
|
||||||
|
|
||||||
;greedy-repeat: (list 'a) -> result -> (list 'a) -> result
|
;greedy-repeat: (list 'a) -> result -> (list 'a) -> result
|
||||||
(define (repeat-greedy sub)
|
(define (repeat-greedy sub)
|
||||||
|
|
|
@ -777,7 +777,15 @@
|
||||||
(repeat-greedy (choose (class interface) "class or interface"))))
|
(repeat-greedy (choose (class interface) "class or interface"))))
|
||||||
|
|
||||||
(define interact
|
(define interact
|
||||||
(choose (field (statement-c #t) expression) "interactive program"))
|
(choose (field
|
||||||
|
(if-s (block #t) #f)
|
||||||
|
(return-s #t)
|
||||||
|
(assignment
|
||||||
|
(choose (identifier
|
||||||
|
(sequence (unique-base (repeat unique-end) field-access-end) id))
|
||||||
|
"assignee") EQUAL)
|
||||||
|
(block #t)
|
||||||
|
expression) "interactive program"))
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user