import { createUtilityValue , ScoringDirection } from "@shoki/engine" ; import { PlayerActions , PlayerState , PlayerStateSelectors } from "@creature-chess/gamemode" ; import { BotPersonality } from "@creature-chess/data" ; import { BrainAction } from "../../brain" ; import { shouldBuyXp } from "../shouldBuyXp" ; export const createBuyXpAction = ( state , personality ) : BrainAction | null => { if ( ! shouldBuyXp ( state ) ) { return null ; } const health = PlayerStateSelectors . getPlayerHealth ( state ) ; const money = PlayerStateSelectors . getPlayerMoney ( state ) ; return { name : "buy xp" , action : PlayerActions . buyXpPlayerAction , value : createUtilityValue ( [ { value : money , range : [ 1 , 20 ] , direction : ScoringDirection . High , weighting : { value : personality . ambition , direction : ScoringDirection . High } } , { value : health , range : [ 1 , 100 ] , direction : ScoringDirection . Low , weighting : { value : personality . composure , direction : ScoringDirection . Low } } ] ) } ; } ;