summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hintz <t@thintz.com>2020-05-01 09:42:49 -0700
committerThomas Hintz <t@thintz.com>2020-05-01 09:42:49 -0700
commitdd644387f10c85f798ce6faf56b40c55dba17369 (patch)
treeb962f0aaf6a3509673cf39750e13372ad6a658c8
parent4cbfe0b3948f6aa3f0de03d9f075fb1bde2ad5e1 (diff)
downloadfarm-dd644387f10c85f798ce6faf56b40c55dba17369.tar.gz
AI buying improvements.
-rw-r--r--src/server/farm.scm22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/server/farm.scm b/src/server/farm.scm
index c415d8a..eb3e261 100644
--- a/src/server/farm.scm
+++ b/src/server/farm.scm
@@ -1640,9 +1640,14 @@
(print "ai attempting to buy")
(let* ((net-worth (player-net-worth player))
(pct-complete (pct-complete net-worth game))
- (room (if (< pct-complete 0.55)
- 1000000 ;; basically infinite
- (+ (- (game-setting 'max-debt game) (player-debt player)) (round-down-1000 (player-cash player)))))
+ (max-normal-room (+ (- (game-setting 'max-debt game) (player-debt player)) (round-down-1000 (player-cash player))))
+ (room (cond ((< pct-complete 0.55)
+ 1000000) ;; basically infinite
+ ((and (> (player-cash player) 30000)
+ (> (player-debt player) (game-setting 'max-debt game)))
+ (round-down-1000 (player-cash player)))
+ (else
+ max-normal-room)))
(crops (map (lambda (card)
(string->symbol (alist-ref 'crop card)))
(player-otbs player))))
@@ -1669,21 +1674,29 @@
(<= (player-asset 'cows player) 40))
'(tractor 1 10000))
((and (member 'ridge4 crops) (>= room 50000)
+ (< pct-complete 0.55)
+ (>= max-normal-room 40000)
(not (find (lambda (p)
(> (player-asset 'ridge4 p) 0))
(game-players game))))
'(ridge4 50 50000))
((and (member 'ridge3 crops) (>= room 40000)
+ (< pct-complete 0.55)
+ (>= max-normal-room 30000)
(not (find (lambda (p)
(> (player-asset 'ridge3 p) 0))
(game-players game))))
'(ridge3 40 40000))
((and (member 'ridge2 crops) (>= room 30000)
+ (< pct-complete 0.55)
+ (>= max-normal-room 20000)
(not (find (lambda (p)
(> (player-asset 'ridge2 p) 0))
(game-players game))))
'(ridge2 30 30000))
((and (member 'ridge1 crops) (>= room 20000)
+ (< pct-complete 0.55)
+ (>= max-normal-room 10000)
(not (find (lambda (p)
(> (player-asset 'ridge1 p) 0))
(game-players game))))
@@ -1747,7 +1760,8 @@
(begin (set! (player-processing-turn player) #t)
;; time to buy
(when (and (>= (player-space player) 9) (<= (player-space player) 14)
- (< (player-debt player) 125000))
+ ;; (< (player-debt player) 125000)
+ )
(let loop ((cont (ai-buy player game)))
(when cont (loop (ai-buy player game)))))
(let ((res (process-message player game "roll" '((type . "roll")))))