diff options
author | rsiddharth <s@ricketyspace.net> | 2019-11-14 20:46:53 -0500 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2019-11-14 20:46:53 -0500 |
commit | da4e220f0b068cfeefadaa1f5920cf776e57ad59 (patch) | |
tree | bba00cedb59c12cff0562cc5a09000bfe7498e86 /net/ricketyspace | |
parent | 5ea836999215248ab66376a8c121ef7825e92607 (diff) |
net/ricketyspace/ror/ten/source.rkt: Add add-winning-probability.
Diffstat (limited to 'net/ricketyspace')
-rw-r--r-- | net/ricketyspace/ror/ten/source.rkt | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/net/ricketyspace/ror/ten/source.rkt b/net/ricketyspace/ror/ten/source.rkt index 0b2fcca..cf89642 100644 --- a/net/ricketyspace/ror/ten/source.rkt +++ b/net/ricketyspace/ror/ten/source.rkt @@ -667,6 +667,29 @@ (define txt (text str TEXT-SIZE TEXT-COLOR)) (place-image txt (- WIDTH INFO-X-OFFSET) INFO-Y-OFFSET s)) +(define (add-winning-probability w s) + (define board (dice-world-board w)) + (define source (dice-world-src w)) + (define target (territory-index (first board))) + (define feasible (game-moves (dice-world-gt w))) + (define attack (list source target)) + (define next (find-move feasible attack)) + + (define (find-territory index) + (findf (lambda (t) (= (territory-index t) index)) + (dice-world-board w))) + + (if (and source next) + (place-image + (text (string-append + "Winning Probability " + (number->string + (probability-of-winning (find-territory source) + (find-territory target)))) + TEXT-SIZE TEXT-COLOR) + (- WIDTH 150) 100 s) + s)) + ;; DiceWorld Scene -> Scene ;; folds through the board and creates an image representation of it (define (add-board-to-scene w s) |