summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hintz <t@thintz.com>2020-04-30 21:09:00 -0700
committerThomas Hintz <t@thintz.com>2020-04-30 21:09:00 -0700
commitcb983ae1c98868f38376d9534c00994aceac4ac2 (patch)
tree4c36152dd2ad8ba07cffcd9135ebea3f846e4975
parent99b60b5abae0609c17b257b6c237173c4a44ae22 (diff)
downloadfarm-cb983ae1c98868f38376d9534c00994aceac4ac2.tar.gz
Improving AI buying algorithm.
-rw-r--r--src/server/farm.scm11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/server/farm.scm b/src/server/farm.scm
index 038c848..259ceb7 100644
--- a/src/server/farm.scm
+++ b/src/server/farm.scm
@@ -1640,7 +1640,7 @@
(print "ai attempting to buy")
(let* ((net-worth (player-net-worth player))
(pct-complete (pct-complete net-worth game))
- (room (if (< pct-complete 0.7)
+ (room (if (< pct-complete 0.55)
1000000 ;; basically infinite
(+ (- (game-setting 'max-debt game) (player-debt player)) (round-down-1000 (player-cash player)))))
(crops (map (lambda (card)
@@ -1648,8 +1648,12 @@
(player-otbs player))))
(print (conc "room: " room))
(print (conc "crops: " crops))
+ (print (conc "pct complete: " pct-complete))
(let ((to-buy
- (cond ((and (member 'cows crops) (>= room 5000))
+ (cond ((and (member 'cows crops) (>= room 5000)
+ (< (- (player-asset 'cows player)
+ (fold + 0 (map cdr (player-ridges player))))
+ 20))
'(cows 10 5000))
((and (member 'fruit crops) (>= room 25000))
'(fruit 5 25000))
@@ -1724,7 +1728,8 @@
(not (player-processing-turn player)))
(begin (set! (player-processing-turn player) #t)
;; time to buy
- (when (and (>= (player-space player) 9) (<= (player-space player) 14))
+ (when (and (>= (player-space player) 9) (<= (player-space player) 14)
+ (< (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")))))