本文整理汇总了C#中GameState.Score方法的典型用法代码示例。如果您正苦于以下问题:C# GameState.Score方法的具体用法?C# GameState.Score怎么用?C# GameState.Score使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameState
的用法示例。
在下文中一共展示了GameState.Score方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResignHint
public override ResignHint ResignHint(GameState gamestate, bool has_moved)
{
int lost_with_single, lost_with_gammon, lost_with_backgammon;
if (gamestate.GameType == GameType.Match)
{
int opp_score = gamestate.Score(1 - gamestate.PlayerOnTurn);
lost_with_backgammon = Math.Min(gamestate.MatchTo, opp_score + gamestate.Cube.Value * 3);
lost_with_gammon = Math.Min(gamestate.MatchTo, opp_score + gamestate.Cube.Value * 2);
lost_with_single = Math.Min(gamestate.MatchTo, opp_score + gamestate.Cube.Value);
}
else
{
lost_with_backgammon = gamestate.Cube.Centered ? gamestate.Stake : Math.Min(gamestate.Limit, gamestate.Stake * gamestate.Cube.Value * 3);
lost_with_gammon = gamestate.Cube.Centered ? gamestate.Stake : Math.Min(gamestate.Limit, gamestate.Stake * gamestate.Cube.Value * 2);
lost_with_single = gamestate.Cube.Centered ? gamestate.Stake : Math.Min(gamestate.Limit, gamestate.Stake * gamestate.Cube.Value);
}
if (!has_moved)
{
// Dice not rolled yet
EvaluationInfo eval_info = resign_gnubg.Eval(gamestate);
/*Console.WriteLine(eval_info.Win);
Console.WriteLine(eval_info.WinGammon);
Console.WriteLine(eval_info.WinBackgammon);
Console.WriteLine(eval_info.LoseGammon);
Console.WriteLine(eval_info.LoseBackgammon);
Console.WriteLine(eval_info.Lose);*/
if (eval_info.LoseBackgammon > 0.995)
return new ResignHint(ResignValue.Backgammon);
if (eval_info.LoseGammon > 0.995 && (eval_info.LoseBackgammon <= 0.0000001))// || (int)capped_loss >= 2))
return new ResignHint(ResignValue.Gammon);
if (eval_info.Lose > 0.995 && ((eval_info.LoseGammon <= 0.0000001 && eval_info.LoseBackgammon <= 0.0000001)))// || (int)capped_loss >= 1))
return new ResignHint(ResignValue.Single);
if (eval_info.Lose > 0.995 && lost_with_single == lost_with_gammon && lost_with_single == lost_with_backgammon && lost_with_gammon == lost_with_backgammon)
return new ResignHint(ResignValue.Single);
if (eval_info.Lose > 0.995 && lost_with_single == lost_with_gammon)
return new ResignHint(ResignValue.Single);
}
else
{
// The optimal move has been made, change the turn to opp to see the effect of the move on eval
int player_on_roll = gamestate.PlayerOnRoll;
int player_on_turn = gamestate.PlayerOnTurn;
int[] dice = new int[2];
Array.Copy(gamestate.Dice, dice, 2);
gamestate.ChangeTurn();
EvaluationInfo eval_info = resign_gnubg.Eval(gamestate);
/*Console.WriteLine(eval_info.Win);
Console.WriteLine(eval_info.WinGammon);
Console.WriteLine(eval_info.WinBackgammon);
Console.WriteLine(eval_info.LoseGammon);
Console.WriteLine(eval_info.LoseBackgammon);
Console.WriteLine(eval_info.Lose);*/
gamestate.SetDice(dice[0], dice[1]);
gamestate.PlayerOnTurn = player_on_turn;
gamestate.PlayerOnRoll = player_on_roll;
if (eval_info.WinBackgammon > 0.995)
return new ResignHint(ResignValue.Backgammon);
if (eval_info.WinGammon > 0.995 && (eval_info.WinBackgammon <= 0.0000001))// || (int)capped_loss >= 2))
return new ResignHint(ResignValue.Gammon);
if (eval_info.Win > 0.995 && ((eval_info.WinGammon <= 0.0000001 && eval_info.WinBackgammon <= 0.0000001)))// || (int)capped_loss >= 1))
return new ResignHint(ResignValue.Single);
if (eval_info.Win > 0.995 && lost_with_single == lost_with_gammon && lost_with_single == lost_with_backgammon && lost_with_gammon == lost_with_backgammon)
return new ResignHint(ResignValue.Single);
if (eval_info.Win > 0.995 && lost_with_single == lost_with_gammon)
return new ResignHint(ResignValue.Single);
}
return new ResignHint(ResignValue.None);
}
示例2: ToTurnInput
private Vector ToTurnInput(GameState gs, DoubleHint hint)
{
double ratio = 0.0;
Vector vector = null;
if (gs.CanDouble())
{
if (gs.GameType == GameType.Match)
{
ratio = System.Math.Min(
(System.Math.Max(gs.Score(0), gs.Score(1)) + gs.Cube.Value) / (double)gs.MatchTo,
1.0);
}
if (gs.GameType == GameType.Money)
{
ratio = System.Math.Min(gs.Cube.Value * gs.Stake / (double)gs.Limit, 1.0);
}
vector = new Vector(System.Math.Abs(System.Math.Min(hint.DoubleTakeEq, hint.DoublePassEq) - hint.NoDoubleEq),
ratio, 100.0);
}
else
{
vector = new Vector(0.0, ratio, 0.0);
}
return vector;
}