private List<BfsTile> InitializeTiles(TerritoryList territories)
        {
            List<BfsTile> tiles = new List<BfsTile>();
            foreach (Territory t in territories)
            {
                BfsTile bfsTile = new BfsTile(t.Name, t);
                bfsTile.Distance = -1;
                bfsTile.Parent = null;

                tiles.Add(bfsTile);    
            }

            return tiles;
        }
Esempio n. 2
0
        private static string IndexToName(int index, TerritoryList territories)
        {
            string name = "";
            int i = 0;
            foreach(Territory t in territories)
            {
                if (i == index)
                {
                    name = t.Name;
                    break;
                }
                else
                    i++;
            }

            return name;
        }
Esempio n. 3
0
        public static void DistributeTerritories(List<Agent> agents, TerritoryList territories, int max_num_territories)
        {
            
            int numAgents = agents.Count;

            // can this loop be optimized?
            while (territories.Count > 0)
            {
                foreach (Agent a in agents)
                {

                    try {
                        int index = (int)GetRandomValue((byte)territories.Count); // get random territory index
                        string toRemove = IndexToName(index, territories);
                        a.GainTerritory(toRemove);
                        territories.Remove(toRemove);
                    } catch (ArgumentOutOfRangeException ex)
                    {
                        break;
                    }
                }
            }

        }
Esempio n. 4
0
 /// <summary>
 /// Creates a new graph class instance based on a list of nodes.
 /// </summary>
 /// <param name="territories">The list of nodes to populate the newly created Board class with.</param>
 public Board(TerritoryList territories, ContinentList continents)
 {
     this.territories = territories;
     this.continents = continents;
     cardBonus = 4;
 }
Esempio n. 5
0
 /// <summary>
 /// Default constructor.  Creates a new Board class instance.
 /// </summary>
 public Board()
 {
     territories = new TerritoryList();
     continents = new ContinentList();
     cardBonus = 4;
 }