예제 #1
0
파일: GerryAI.cs 프로젝트: Andarin/LD35
    private float simulateTurnWith(Tuple <int, int> selectedVoterIndex, District selectedDistrict)
    {
        List <District> tempDistrictList = new List <District> (gl.districtList);

        for (int i = 0; i < gl.districtList.Count; i++)
        {
            tempDistrictList[i] = District.copyFrom(gl.districtList[i]);
        }
        VoterGrid tempVotergrid = VoterGrid.copyFrom(gl.voterGrid);

        addVoterToDistrict(selectedVoterIndex, selectedDistrict.index, tempDistrictList, tempVotergrid);

        if (tempVotergrid.freeVoterSet.Count > 0)
        {
            Move enemyMove = selectMove(tempDistrictList, tempVotergrid, (player.index + 1) % 2);
            addVoterToDistrict(enemyMove.voterIndex, enemyMove.district.index, tempDistrictList, tempVotergrid);

            if (tempVotergrid.freeVoterSet.Count > 0)
            {
                Move myMove = selectMove(tempDistrictList, tempVotergrid, player.index);
                return(myMove.score);
            }
            else
            {
                return(1 - enemyMove.score);
            }
        }
        else
        {
            return((float)0.5);
        }
    }
예제 #2
0
    private float scoreThisMove(Tuple <int, int> selVoterIndex, int selDistrict, List <District> districtList, VoterGrid voterGrid, int playerIndex, int depth)
    {
        // 1. Copy game situation:
        List <District> tempDistrictList = new List <District> (districtList);

        for (int i = 0; i < districtList.Count; i++)
        {
            tempDistrictList[i] = District.copyFrom(districtList[i]);
        }
        VoterGrid tempVotergrid = VoterGrid.copyFrom(voterGrid);

        float score;         // score /elem [0,1], 0 = worst Score.

        // 2. Simulate Move:
        addVoterToDistrict(selVoterIndex, selDistrict, tempDistrictList, tempVotergrid);

        if (playerIndex == player.index && depth < this.targetDepth)
        {
            // 3. Select Best Enemy Move:
            Move enemyMove = findBestMove(tempDistrictList, tempVotergrid, (playerIndex + 1) % 2, depth, "My Move is: (" + selVoterIndex.First + "," + selVoterIndex.Second + ", " + selDistrict + ")");

            // 4. Simulate best Enemy Move:
            addVoterToDistrict(enemyMove.voterIndex, enemyMove.district.index, tempDistrictList, tempVotergrid);

            // 5. Select best own Move:
            Move ownMove = findBestMove(tempDistrictList, tempVotergrid, playerIndex, depth);
            score = ownMove.score;
        }
        else
        {
            // 3. Score this situation for the player
            score = scoreSituation(tempDistrictList, tempVotergrid, playerIndex);
        }
        return(score);
    }
예제 #3
0
파일: GerryAI.cs 프로젝트: Andarin/LD35
    private float simulateSecondTurnWith(List <District> districtList, VoterGrid voterGrid, Tuple <int, int> selectedVoterIndex, int selectedDistrict, int playerIndex)
    {
        List <District> tempDistrictList = new List <District> (districtList);

        for (int i = 0; i < districtList.Count; i++)
        {
            tempDistrictList[i] = District.copyFrom(districtList[i]);
        }
        VoterGrid tempVotergrid = VoterGrid.copyFrom(voterGrid);

        addVoterToDistrict(selectedVoterIndex, selectedDistrict, tempDistrictList, tempVotergrid);

        return(score(tempDistrictList, tempVotergrid, playerIndex));
    }