當前位置: 首頁>>代碼示例>>C#>>正文


C# GameState.isEndofGameByGoal方法代碼示例

本文整理匯總了C#中GameState.isEndofGameByGoal方法的典型用法代碼示例。如果您正苦於以下問題:C# GameState.isEndofGameByGoal方法的具體用法?C# GameState.isEndofGameByGoal怎麽用?C# GameState.isEndofGameByGoal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在GameState的用法示例。


在下文中一共展示了GameState.isEndofGameByGoal方法的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.isEndofGameByGoal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。