Example #1
0
 private void OilValueCalc(clsOilBalanceLoopArgs Args)
 {
     double num;
     int num7;
     clsOilPossibilities.clsPossibility possibility = new clsOilPossibilities.clsPossibility();
     double[] numArray = new double[(this.TopLeftPlayerCount - 1) + 1];
     possibility.PlayerOilScoreAddition = new double[(this.TopLeftPlayerCount - 1) + 1];
     double maxValue = double.MaxValue;
     int num16 = this.TopLeftPlayerCount - 1;
     int index = 0;
     while (index <= num16)
     {
         possibility.PlayerOilScoreAddition[index] = 0.0;
         index++;
     }
     int num17 = this.OilAtATime - 1;
     for (num7 = 0; num7 <= num17; num7++)
     {
         double num8;
         int num10;
         int num13;
         double[] playerOilScoreAddition;
         int num25;
         int num6 = Args.OilNodes[num7].Num;
         int num18 = this.OilAtATime - 1;
         int num11 = num7 + 1;
         while (num11 <= num18)
         {
             num10 = Args.OilNodes[num11].Num;
             num8 = 4.0 * this.PassageNodeDists[0, num6, 0, num10];
             if (num8 < maxValue)
             {
                 maxValue = num8;
             }
             num11++;
         }
         int num19 = this.OilAtATime - 1;
         for (num11 = 0; num11 <= num19; num11++)
         {
             num10 = Args.OilNodes[num11].Num;
             int num20 = this.SymmetryBlockCount - 1;
             num13 = 1;
             while (num13 <= num20)
             {
                 num8 = 4.0 * this.PassageNodeDists[0, num6, num13, num10];
                 if (num8 < maxValue)
                 {
                     maxValue = num8;
                 }
                 num13++;
             }
         }
         int num21 = this.PassageNodeCount - 1;
         for (int i = 0; i <= num21; i++)
         {
             int num22 = this.SymmetryBlockCount - 1;
             num13 = 0;
             while (num13 <= num22)
             {
                 if (this.PassageNodes[num13, i].OilCount > 0)
                 {
                     double num9;
                     num8 = (4.0 * num9) / ((double) this.PassageNodeDists[0, num6, num13, i]);
                     if (num8 < maxValue)
                     {
                         maxValue = num8;
                     }
                 }
                 num13++;
             }
         }
         int num23 = this.TopLeftPlayerCount - 1;
         index = 0;
         while (index <= num23)
         {
             numArray[index] = 0.0;
             int num24 = this.SymmetryBlockCount - 1;
             for (num13 = 0; num13 <= num24; num13++)
             {
                 modMath.sXY_int _int = this.PlayerBases[index].Nodes[0].Pos - this.PassageNodes[num13, num6].Pos;
                 num = (this.PassageNodeDists[0, this.PlayerBases[index].Nodes[0].Num, num13, num6] * 2.0) + _int.ToDoubles().GetMagnitude();
                 playerOilScoreAddition = numArray;
                 num25 = index;
                 playerOilScoreAddition[num25] += 100.0 / num;
             }
             index++;
         }
         int num26 = this.TopLeftPlayerCount - 1;
         index = 0;
         while (index <= num26)
         {
             playerOilScoreAddition = possibility.PlayerOilScoreAddition;
             num25 = index;
             playerOilScoreAddition[num25] += Args.OilClusterSizes[num7] * numArray[index];
             index++;
         }
     }
     double num3 = double.MaxValue;
     double minValue = double.MinValue;
     int num27 = this.TopLeftPlayerCount - 1;
     for (index = 0; index <= num27; index++)
     {
         num = Args.PlayerOilScore[index] + possibility.PlayerOilScoreAddition[index];
         if (num < num3)
         {
             num3 = num;
         }
         if (num > minValue)
         {
             minValue = num;
         }
     }
     double num14 = minValue - num3;
     if (maxValue == double.MaxValue)
     {
         maxValue = 0.0;
     }
     else
     {
         maxValue = 10.0 / maxValue;
     }
     double num15 = (this.OilDispersion * maxValue) + num14;
     possibility.Score = num15;
     possibility.Nodes = new clsPassageNode[(this.OilAtATime - 1) + 1];
     int num28 = this.OilAtATime - 1;
     for (num7 = 0; num7 <= num28; num7++)
     {
         possibility.Nodes[num7] = Args.OilNodes[num7];
     }
     Args.OilPossibilities.NewPossibility(possibility);
 }
Example #2
0
        private void OilValueCalc(clsOilBalanceLoopArgs Args)
        {
            //Dim OilDistScore As Double
            //Dim OilStraightDistScore As Double
            double LowestScore = 0;
            double HighestScore = 0;
            //Dim TotalOilScore As Double
            double UnbalancedScore = 0;
            double dblTemp = 0;
            double Value = 0;
            clsOilPossibilities.clsPossibility NewPossibility = new clsOilPossibilities.clsPossibility();
            double[] BaseOilScore = new double[TopLeftPlayerCount];

            NewPossibility.PlayerOilScoreAddition = new double[TopLeftPlayerCount];

            int NewOilNum = 0;
            int OtherOilNum = 0;
            int NewOilNodeNum = 0;
            int OtherOilNodeNum = 0;
            int SymmetryBlockNum = 0;
            int MapNodeNum = 0;
            int PlayerNum = 0;
            //Dim NewOilCount As Integer
            double OilMassMultiplier = 0;
            double OilDistValue = 0;
            double NearestOilValue = double.MaxValue;

            //OilDistScore = 0.0#
            //OilStraightDistScore = 0.0#
            for ( PlayerNum = 0; PlayerNum <= TopLeftPlayerCount - 1; PlayerNum++ )
            {
                NewPossibility.PlayerOilScoreAddition[PlayerNum] = 0.0D;
            }
            for ( NewOilNum = 0; NewOilNum <= OilAtATime - 1; NewOilNum++ )
            {
                NewOilNodeNum = Args.OilNodes[NewOilNum].Num;
                //other oil to be placed in the first area
                for ( OtherOilNum = NewOilNum + 1; OtherOilNum <= OilAtATime - 1; OtherOilNum++ )
                {
                    OtherOilNodeNum = Args.OilNodes[OtherOilNum].Num;
                    //OilMassMultiplier = Args.OilClusterSizes(NewOilNum) * Args.OilClusterSizes(OtherOilNum)
                    //OilDistScore += OilMassMultiplier / PassageNodeDists(0, NewOilNodeNum, 0, OtherOilNodeNum)
                    //OilStraightDistScore += OilMassMultiplier / GetDist_XY_int(PassageNodes(0, NewOilNodeNum).Pos, PassageNodes(0, OtherOilNodeNum).Pos)
                    OilDistValue = 4.0D * PassageNodeDists[0, NewOilNodeNum, 0, OtherOilNodeNum];
                    //+ GetDist_XY_int(PassageNodes(0, NewOilNodeNum).Pos, PassageNodes(0, OtherOilNodeNum).Pos))
                    if ( OilDistValue < NearestOilValue )
                    {
                        NearestOilValue = OilDistValue;
                    }
                }
                //other oil to be placed in symmetrical areas
                for ( OtherOilNum = 0; OtherOilNum <= OilAtATime - 1; OtherOilNum++ )
                {
                    OtherOilNodeNum = Args.OilNodes[OtherOilNum].Num;
                    //OilMassMultiplier = Args.OilClusterSizes(NewOilNum) * Args.OilClusterSizes(OtherOilNum)
                    for ( SymmetryBlockNum = 1; SymmetryBlockNum <= SymmetryBlockCount - 1; SymmetryBlockNum++ )
                    {
                        //OilDistScore += OilMassMultiplier / PassageNodeDists(0, NewOilNodeNum, SymmetryBlockNum, OtherOilNodeNum)
                        //OilStraightDistScore += OilMassMultiplier / GetDist_XY_int(PassageNodes(0, NewOilNodeNum).Pos, PassageNodes(SymmetryBlockNum, OtherOilNodeNum).Pos)
                        OilDistValue = 4.0D * PassageNodeDists[0, NewOilNodeNum, SymmetryBlockNum, OtherOilNodeNum];
                        // + GetDist_XY_int(PassageNodes(0, NewOilNodeNum).Pos, PassageNodes(SymmetryBlockNum, OtherOilNodeNum).Pos))
                        if ( OilDistValue < NearestOilValue )
                        {
                            NearestOilValue = OilDistValue;
                        }
                    }
                }
                //oil on the map
                for ( MapNodeNum = 0; MapNodeNum <= PassageNodeCount - 1; MapNodeNum++ )
                {
                    for ( SymmetryBlockNum = 0; SymmetryBlockNum <= SymmetryBlockCount - 1; SymmetryBlockNum++ )
                    {
                        if ( PassageNodes[SymmetryBlockNum, MapNodeNum].OilCount > 0 )
                        {
                            //OilMassMultiplier = Args.OilClusterSizes(NewOilNum) * PassageNodes(SymmetryBlockNum, MapNodeNum).OilCount
                            //OilDistScore += OilMassMultiplier / PassageNodeDists(0, NewOilNodeNum, SymmetryBlockNum, MapNodeNum)
                            //OilStraightDistScore += OilMassMultiplier / GetDist_XY_int(PassageNodes(0, NewOilNodeNum).Pos, PassageNodes(SymmetryBlockNum, MapNodeNum).Pos)
                            OilDistValue = 4.0D * OilMassMultiplier / PassageNodeDists[0, NewOilNodeNum, SymmetryBlockNum, MapNodeNum];
                            // + GetDist_XY_int(PassageNodes(0, NewOilNodeNum).Pos, PassageNodes(SymmetryBlockNum, MapNodeNum).Pos))
                            if ( OilDistValue < NearestOilValue )
                            {
                                NearestOilValue = OilDistValue;
                            }
                        }
                    }
                }
                //extra oil score for players
                for ( PlayerNum = 0; PlayerNum <= TopLeftPlayerCount - 1; PlayerNum++ )
                {
                    BaseOilScore[PlayerNum] = 0.0D;
                    for ( SymmetryBlockNum = 0; SymmetryBlockNum <= SymmetryBlockCount - 1; SymmetryBlockNum++ )
                    {
                        dblTemp =
                            Convert.ToDouble(PassageNodeDists[0, PlayerBases[PlayerNum].Nodes[0].Num, SymmetryBlockNum, NewOilNodeNum] * 2.0D +
                                                    (PlayerBases[PlayerNum].Nodes[0].Pos - PassageNodes[SymmetryBlockNum, NewOilNodeNum].Pos).ToDoubles().GetMagnitude());
                        BaseOilScore[PlayerNum] += 100.0D / dblTemp;
                    }
                }
                //TotalOilScore = 0.0#
                //For PlayerNum = 0 To PlayerCount - 1
                //    TotalOilScore += BaseOilScore(PlayerNum)
                //Next
                for ( PlayerNum = 0; PlayerNum <= TopLeftPlayerCount - 1; PlayerNum++ )
                {
                    NewPossibility.PlayerOilScoreAddition[PlayerNum] += Args.OilClusterSizes[NewOilNum] * BaseOilScore[PlayerNum];
                }
            }

            LowestScore = double.MaxValue;
            HighestScore = double.MinValue;
            for ( PlayerNum = 0; PlayerNum <= TopLeftPlayerCount - 1; PlayerNum++ )
            {
                dblTemp = Args.PlayerOilScore[PlayerNum] + NewPossibility.PlayerOilScoreAddition[PlayerNum];
                if ( dblTemp < LowestScore )
                {
                    LowestScore = dblTemp;
                }
                if ( dblTemp > HighestScore )
                {
                    HighestScore = dblTemp;
                }
            }
            UnbalancedScore = HighestScore - LowestScore;

            //NewOilCount = 0
            //For NewOilNum = 0 To OilAtATime - 1
            //    NewOilCount += Args.OilClusterSizes(NewOilNum)
            //Next
            //divide all dists by the number of oil resources placed. does not include other symmetries, since they were never added in, and are exactly the same.
            if ( NearestOilValue == double.MaxValue )
            {
                NearestOilValue = 0.0D;
            }
            else
            {
                NearestOilValue = 10.0D / NearestOilValue;
            }
            //Value = OilDispersion * (OilDistScore * 4.0# + OilStraightDistScore) + UnbalancedScore
            Value = OilDispersion * NearestOilValue + UnbalancedScore;
            NewPossibility.Score = Value;
            NewPossibility.Nodes = new clsPassageNode[OilAtATime];
            for ( NewOilNum = 0; NewOilNum <= OilAtATime - 1; NewOilNum++ )
            {
                NewPossibility.Nodes[NewOilNum] = Args.OilNodes[NewOilNum];
            }
            Args.OilPossibilities.NewPossibility(NewPossibility);
        }