From d4d0806abb965b87e13c82dbd6322c3ea4c2854d Mon Sep 17 00:00:00 2001 From: Jakub Date: Sun, 24 May 2026 17:04:39 +0800 Subject: [PATCH] Make AI prioritize fleeing at low health --- src/arena.scm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/arena.scm b/src/arena.scm index 757fd8b..f7779ca 100644 --- a/src/arena.scm +++ b/src/arena.scm @@ -90,13 +90,15 @@ #f))) (when (< 0.5 (random)) (set-order-stance! o (pick-random '(high mid low)))) - (set-order-atk! - o - (let ((roll (random))) - (cond - ((> 0.6 roll) (unit-hand-pos enemy-unit)) - ((> 0.8 roll) (rotate-pos-cc (unit-hand-pos enemy-unit))) - (else (rotate-pos (unit-hand-pos enemy-unit)))))) + (when (or (< 1 (unit-health enemy-unit)) + (< 0.5 (random))) + (set-order-atk! + o + (let ((roll (random))) + (cond + ((> 0.6 roll) (unit-hand-pos enemy-unit)) + ((> 0.8 roll) (rotate-pos-cc (unit-hand-pos enemy-unit))) + (else (rotate-pos (unit-hand-pos enemy-unit))))))) o)) (define (win)