Esempio n. 1
0
 //Create new instance of the class
 public Observation(Obs_Area p_area, Obs_Position p_position, Obs_Finance p_finance)
 {
     this.area = p_area; this.finance = p_finance; this.position = p_position;
 }
Esempio n. 2
0
 //Create new instance of the class
 public Observation(Obs_Area p_area, Obs_Position p_position, Obs_Finance p_finance)
 {
     this.area = p_area; this.finance = p_finance; this.position = p_position;
 }
Esempio n. 3
0
        //create a new area instance based on the current game's data
        private Obs_Area createArea()
        {
            Obs_Area area = new Obs_Area();

            #region GameGroupInfo

            double[,] groupInfo = new double[gameCardsGroup.Length, 2];
            for (int i = 0; i < gameCardsGroup.Length; i++)
            {
                //Group isn't completed
                if (completedGroups[i].Equals(-1))
                {
                    double cPlayer = 0;
                    double oPlayers = 0;

                    string[] tmp = gameCardsGroup[i].Split(',');
                    for (int j = 0; j < tmp.Length; j++)
                    {
                        if (properties[Int32.Parse(tmp[j])].Equals(currentPlayer))
                        {
                            if (gamePlayers[currentPlayer].mortgagedProperties[getIndexFromPosition(Int32.Parse(tmp[j]))].Equals(0))
                                cPlayer++;
                        }

                        else if (!properties[Int32.Parse(tmp[j])].Equals(-1))
                            oPlayers++;
                    }

                    groupInfo[i, 0] = (int)(12 / gameCardsGroup[i].Split(',').Length * cPlayer);
                    groupInfo[i, 1] = (int)(12 / gameCardsGroup[i].Split(',').Length * oPlayers);

                    if (groupInfo[i, 1].Equals(12))
                    {
                        int alivePlayers = 0;
                        for (int k = 0; k < currentPlayers; k++)
                        {
                            if (gamePlayers[k].isAlive && (!k.Equals(currentPlayer)))
                                alivePlayers++;
                        }

                        groupInfo[i, 1] = (int)groupInfo[i, 1] / alivePlayers;
                    }
                }

                //If the group is completed
                else
                {
                    string[] gr = gameCardsGroup[i].Split(',');
                    int mortCounter = 0;

                    int tmp = buildings[Int32.Parse(gameCardsGroup[i].Split(',')[gameCardsGroup[i].Split(',').Length - 1])];

                    if (completedGroups[i].Equals(currentPlayer))
                    {
                        for (int j = 0; j < gr.Length; j++)
                        {
                            if (gamePlayers[currentPlayer].mortgagedProperties[getIndexFromPosition(Int32.Parse(gr[j].ToString()))].Equals(1))
                            {
                                mortCounter++;
                            }
                        }

                        groupInfo[i, 1] = 0;
                        groupInfo[i, 0] = 12 + tmp;
                        if (mortCounter > 0)
                            groupInfo[i, 0] = 12 - (int)(12 / gameCardsGroup[i].Split(',').Length * mortCounter);

                    }

                    else
                    {
                        groupInfo[i, 0] = 0;
                        groupInfo[i, 1] = 12 + tmp;
                    }
                }
            }

            for (int i = 0; i < groupInfo.GetLength(0); i++)
            {
                for (int j = 0; j < groupInfo.GetLength(1); j++)
                {
                    groupInfo[i, j] = (double)((double)groupInfo[i, j] / 17);
                }
            }

            area.gameGroupInfo = groupInfo;

            #endregion GameGroupInfo

            #region DeletedParams

            /*

            #region CurrentPropertyOwner

            //Current's area owner
            //-1 if an opponent has it
            // 0 if none
            // 1 if the current player has it
            int cPO = 0;
            if (board.typeId[currentPlayer].Equals(0))
            {
                if (properties[currentPosition].Equals(currentPlayer))
                    cPO = 1;
                else if (properties[currentPlayer].Equals(-1))
                    cPO = 0;
                else
                    cPO = -1;
            }

            area.currentPropertyOwner = cPO;

            #endregion CurrentPropertyOwner

            #region RelativeNumberOfPropertiesFromDifferentGroups

            //Create new list of int represanting the groups that the player has properties from
            List<int> groups = new List<int>();

            for (int i = 0; i < gameCards.Count; i++)
            {
                //If the current player has this card then add it's group to the list and increase the counter only if it doesn't already exist
                if (gamePlayers[currentPlayer].propertiesPurchased[i].Equals(1))
                {
                    if (!groups.Contains(gameCards[i].getGroup()))
                    {
                        groups.Add(gameCards[i].getGroup());
                    }
                }
            }

            //Store the number
            area.relativeNumberOfPropertiesFromDifferentGroups = (double)((double)groups.Count / 10);

            #endregion RelativeNumberOfPropertiesFromDifferentGroups

             */
            #endregion DeletedParams

            return area;
        }