From 8a5df29df3dcdc9f6896031ecee6f69da6f31735 Mon Sep 17 00:00:00 2001 From: deuce <> Date: Sat, 30 Aug 2008 19:01:59 +0000 Subject: [PATCH] Add new UltraParanoid mode for Deep Blue. Deep Blue should not suck at the start. :-) --- xtrn/dicewarz/ai.ini | 2 +- xtrn/dicewarz/ai.js | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/xtrn/dicewarz/ai.ini b/xtrn/dicewarz/ai.ini index 33813cfaae..e1c093df38 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 ecef5d2fc6..5c2a10d841 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}; -- GitLab