diff --git a/xtrn/dicewarz/ai.ini b/xtrn/dicewarz/ai.ini index 33813cfaae969aeae7a8671b3004f698b96359a5..e1c093df38e3a79cd79a220eb9b50d4f56a42841 100644 --- a/xtrn/dicewarz/ai.ini +++ b/xtrn/dicewarz/ai.ini @@ -10,7 +10,7 @@ Quantity=Full [Deep Blue] Sort=GroupParanoid -Check=Paranoid +Check=UltraParanoid Quantity=Single [AutoDeuce] diff --git a/xtrn/dicewarz/ai.js b/xtrn/dicewarz/ai.js index ecef5d2fc608a3102eb2201e8e8e2400ec0a263d..5c2a10d841c4ebbc2e9e4e8c852e57d27c0b74ac 100644 --- a/xtrn/dicewarz/ai.js +++ b/xtrn/dicewarz/ai.js @@ -138,6 +138,44 @@ function WildAndCrazyAICheck(gameNumber, playerNumber, base, target) } return(false); } +function UltraParanoidAICheck(gameNumber, playerNumber, base, target) +{ + g=games.gameData[gameNumber]; + computerPlayer=g.players[playerNumber]; + + if(computerPlayer.reserve > 7) + return(ParanoidAICheck(gameNumber, playerNumber, base, target)); + + /* First, check if we would leave ourselves open. If so, + * do not take the risk */ + var dirs=g.LoadDirectional(base); + for(dir in dirs) { + current=dirs[dir]; + if(current==target) + continue; + if(g.grid[current]) { + if(g.grid[current].player!=player && g.grid[current].dice > 1) + return(false); + } + } + + /* Next, check that we have a dice advantage */ + if(g.grid[base].dice <= g.grid[target].dice) + return(false); + + /* Finally, check that we will still be at least equal after the capture */ + dirs=g.LoadDirectional(target); + for(dir in dirs) { + current=dirs[dir]; + if(current==target) + continue; + if(g.grid[current]) { + if(g.grid[current].player!=player && g.grid[current].dice >= g.grid[base].dice) + return(false); + } + } + return(true); +} /* Callbacks for selecting the number of targets to use */ function RandomAttackQuantity(tlen) @@ -158,5 +196,5 @@ function SingleAttackQuantity(tlen) } var AISortFunctions={Random:RandomSort, Wild:WildAndCrazyAISort, KillMost:KillMostDiceAISort, Paranoia:ParanoiaAISort, RandomAI:RandomAISort, GroupParanoid:GroupAndParanoidAISort}; -var AICheckFunctions={Random:RandomAICheck, Paranoid:ParanoidAICheck, Wild:WildAndCrazyAICheck}; +var AICheckFunctions={Random:RandomAICheck, Paranoid:ParanoidAICheck, Wild:WildAndCrazyAICheck, UltraParanoid:UltraParanoidAICheck}; var AIQtyFunctions={Random:RandomAttackQuantity, Full:FullAttackQuantity, Single:SingleAttackQuantity};