AI improvements.

master
Thomas Hintz 5 years ago
parent 802a0efcbb
commit 9160fdc92a

@ -1629,9 +1629,17 @@
(define (round-down-1000 val)
(- val (remainder val 1000)))
(define (pct-complete net-worth game)
(/ (min net-worth (game-setting 'audit-threshold game))
(game-setting 'audit-threshold game)))
(define (ai-buy player game)
(print "ai attempting to buy")
(let ((room (+ (- (game-setting 'max-debt game) (player-debt player)) (round-down-1000 (player-cash player))))
(let* ((net-worth (player-net-worth player))
(pct-complete (pct-complete net-worth game))
(room (if (< pct-complete 0.7)
1000000 ;; basically infinite
(+ (- (game-setting 'max-debt game) (player-debt player)) (round-down-1000 (player-cash player)))))
(crops (map (lambda (card)
(string->symbol (alist-ref 'crop card)))
(player-otbs player))))
@ -1650,7 +1658,8 @@
(= (player-asset 'harvester player) 0))
'(harvester 1 10000))
((and (member 'tractor crops) (>= room 10000)
(= (player-asset 'tractor player) 0))
(= (player-asset 'tractor player) 0)
(<= (player-asset 'cows player) 40))
'(tractor 1 10000))
((and (member 'ridge4 crops) (>= room 50000)
(not (find (lambda (p)
@ -1677,10 +1686,14 @@
(if to-buy
(begin
(print (conc "buying crop: " (first to-buy)))
(when (< (round-down-1000 (player-cash player)) (third to-buy))
(process-message player game "loan" `((amount . ,(/ (- (third to-buy)
(round-down-1000 (player-cash player)))
1000)))))
(if (eq? (buy-crop (normalize-crop (first to-buy))
(first to-buy)
(second to-buy)
(min (third to-buy) (round-down-1000 (player-cash player)))
(third to-buy)
player
game)
#t)
@ -1741,7 +1754,9 @@
(process-message player game "loan" `((amount . ,(/ (+ (abs (player-cash player))
(remainder (abs (player-cash player)) 1000))
1000)))))
(when (>= (player-cash player) 1000)
(when (and (>= (player-cash player) 1000)
(or (<= (player-debt player) 40000)
(>= (player-cash player) 75000)))
(print "repaying loan")
(process-message player game "loan" `((amount . ,(* (/ (- (player-cash player)
(remainder (player-cash player) 1000))

Loading…
Cancel
Save