diff options
author | rsiddharth <s@ricketyspace.net> | 2019-09-26 20:27:52 -0400 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2019-09-26 20:27:52 -0400 |
commit | 70f921d266de4dab51052a7306b7732808428531 (patch) | |
tree | 163e6c83633857e01690f6e512267c7b78ec277c | |
parent | 2348fd34c507844861acc3068edb88fb7074cb8a (diff) |
net: ror/ten/sourc.rkt: Add dice-attack-win.
-rw-r--r-- | net/ricketyspace/ror/ten/source.rkt | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/net/ricketyspace/ror/ten/source.rkt b/net/ricketyspace/ror/ten/source.rkt index 4bffdd0..b4fb6f2 100644 --- a/net/ricketyspace/ror/ten/source.rkt +++ b/net/ricketyspace/ror/ten/source.rkt @@ -534,6 +534,19 @@ (define (no-more-moves? g) (empty? (game-moves g))) +;; Territory Territory -> Boolean +;; attack from src territory to destination territory +;; and see who wins +(define (dice-attack-win src-t dst-t) + (define (roll-dice n) + (for/list ([i n]) + (random 1 7))) + (define (sum l) + (foldl + 0 l)) + (define src-attack (sum (roll-dice (territory-dice src-t)))) + (define dst-defend (sum (roll-dice (territory-dice dst-t)))) + (if (> src-attack dst-defend) #t #f)) + ; ; ; |