当前位置: 首页>>代码示例>>C#>>正文


C# GameState.getWinner方法代码示例

本文整理汇总了C#中GameState.getWinner方法的典型用法代码示例。如果您正苦于以下问题:C# GameState.getWinner方法的具体用法?C# GameState.getWinner怎么用?C# GameState.getWinner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameState的用法示例。


在下文中一共展示了GameState.getWinner方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: evaluate

    public static int evaluate(GameState gameState)
    {
        int score=0;

        List<Coordinate> coordinateList = gameState.getStoneCoords();

        int
            player = gameState.getTurn(),
            enemy  = (player==1) ? 2 : 1 ,
            pStones=0,
            eStones=0,
            pBlocked=0,
            eBlocked=0,
            pWin=0,
            pDistance=0,
            eDistance=0,
            cellValue=0;

        foreach ( Coordinate coordinate in coordinateList )
        {
            cellValue = gameState.getCell(coordinate);

            if (cellValue == player)
            {
                pStones  += 1;
                pBlocked += gameState.isBlocked(coordinate) ? 1 : 0;
                pDistance += (17 - gameState.deviation(4,16,coordinate.getLine(),coordinate.getColumn()));
            }
            else if (cellValue == enemy)
            {
                eStones  += 1;
                eBlocked += gameState.isBlocked(coordinate) ? 1 : 0;
                eDistance +=  (17 - gameState.deviation(4,0,coordinate.getLine(),coordinate.getColumn()));
            }
        }

        if ( gameState.isEndofGameByGoal() || eStones==eBlocked ) // win
        {
            gameState.setEndGame(true);
            gameState.setWinner(player);
            pWin = 1;
        }

        if (mode == 1 || (mode == 2 && player == 1) || (mode == 2 && player == 2))
        {
            score = (gameState.getWinner()>0) ?
                    (
                        (pWin 		* player_winValue)
                    ) :
                    (
                        (pStones	* player_stoneValue) +
                        (eStones 	* enemy_stoneValue) +

                        (pBlocked	* player_blockedValue) +
                        (eBlocked 	* enemy_blockedValue) +

                        (pDistance	* player_distanceToGoalValue) +
                        (eDistance 	* enemy_distanceToGoalValue)
                        );
        }
        else
        {
            score = (gameState.getWinner()>0) ?
                    (
                        (pWin 		* player_winValue2)
                    ) :
                    (
                        (pStones	* player_stoneValue2) +
                        (eStones 	* enemy_stoneValue2) +

                        (pBlocked	* player_blockedValue2) +
                        (eBlocked 	* enemy_blockedValue2) +

                        (pDistance	* player_distanceToGoalValue2) +
                        (eDistance 	* enemy_distanceToGoalValue2)
                        );
        }

        //Debug.Log ("Player >>"+ player+" "+score +" :: " + pWin + " "+ pStones + " "+ eStones + " "+ pBlocked + " "+ eBlocked + " "+ pDistance + " " + eDistance );

        return score;
    }
开发者ID:RicardoCoutinho,项目名称:Aboyne,代码行数:82,代码来源:Algorithms.cs


注:本文中的GameState.getWinner方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。