public DocumentLibraryPage(IWebDriver driver) { this.driver = driver; PageFactory.InitElements(driver, this); wait = new Waits(driver); actionMethod = new ActionsMethods(driver); em = new ElementMethods(driver); }
private int IntelligentGeneralChoice() { int i = 0; if (this.DestinationCards.Count < 3) { return((int)PlayerAction.DestinationCard); } if (firstloop) { ExtensionMethods.niceLayout("Dijkstra"); double mini = 0; firstloop = false; List <List <Railroad> > shortestpaths = GraphAlgorithms.Dijkstra(AllTracks, citylist, this); List <City> destinations = new List <City>(); ExtensionMethods.niceLayout("Vertaling naar railRoads"); foreach (List <Railroad> path in shortestpaths) { Program.logboek.WriteLine(this.GetDestinationCards()[i].ToString()); int totalamountOfCardsneeded = 0, amountOfStations = 0; foreach (Railroad road in path) { destinations = road.getdestinations(); Program.logboek.WriteLine("\t" + destinations[0].getname() + " - " + destinations[1].getname()); if (!road.isOccupied()) { totalamountOfCardsneeded += road.getAmountOfLocomotives() * 2 + road.getRailLength() + ((road.IsTunnel()) ? 2 : 0); } else { amountOfStations++; } } double trackvalue = (double)(GetDestinationCards()[i].getPoints() + 4 - amountOfStations) / (double)(totalamountOfCardsneeded); // empyrisch, hoe groter hoe beter if (trackvalue > mini) { goalRoute = path; mini = trackvalue; } i++; } i = 1; foreach (Railroad road in goalRoute) { if (road.isOccupied() && road.getPlayer().CompareTo(this) != 0) { if (i / goalRoute.Count > 0.5) { if (road.getdestinations()[0].getStation() == null) { goalStation = road.getdestinations()[0]; return((int)PlayerAction.Station); } else if ((road.getdestinations()[1].getStation() == null)) { goalStation = road.getdestinations()[1]; return((int)PlayerAction.Station); } } } else if (road.isOccupied() == false) { Program.logboek.WriteLine(this.name + " is trying to build a road between: " + road.ToString()); if (ActionsMethods.Pickcards(this, road)) { //goalRoad = road; Maderoad = road; return((int)PlayerAction.Railroad); } } i++; } foreach (Railroad road in goalRoute) { //goalRoad = road; if (!road.isOccupied()) { goalRoad = road; } } } else { return((int)PlayerAction.Traincards); } return((int)PlayerAction.Traincards); }
public virtual int ChoseOption(/*Dictionary<string, int> possibleActions,*/ Possibilities optiontype) { Dictionary <string, int> roundOptions = new Dictionary <string, int>(); int val = 0; string text = null; switch ((int)optiontype) { case (int)Possibilities.General: foreach (PlayerAction action in Enum.GetValues(typeof(PlayerAction))) { roundOptions.Add(action.ToString(), (int)action); } break; case (int)Possibilities.Traincard: foreach (Cardoptions option in Enum.GetValues(typeof(Cardoptions))) { roundOptions.Add(option.ToString(), (int)option); } break; case (int)Possibilities.visibleTraincards: foreach (TrainCard trCard in ActionsMethods.visibleTraincards) { text = trCard.ToString(); val = (int)(trCard.getColor()); List <int> vals = roundOptions.Values.ToList(); if (!vals.Contains(val)) { roundOptions.Add(text, val); } } break; case (int)Possibilities.stationCities: Program.logboek.WriteLine("Building a station: the available cities to build a station are:"); ActionsMethods.citylist.Sort(); foreach (City stad in ActionsMethods.citylist) { /****************************** * Showing the available stationcities *******************************/ if (stad.getStation() == null) { text += stad.getname() + '\t'; roundOptions.Add(stad.getname(), stad.getID()); } } Program.logboek.WriteLine(text); break; case (int)Possibilities.Railroad: City city1, city2 = null; foreach (Railroad road in ActionsMethods.network) { if (!road.isOccupied()) { List <int> IDs = roundOptions.Values.ToList(); city1 = road.getdestinations()[0]; city2 = road.getdestinations()[1]; if (!IDs.Contains(city1.getID())) { roundOptions.Add(city1.getname(), city1.getID()); } if (!IDs.Contains(city2.getID())) { roundOptions.Add(city2.getname(), city2.getID()); } } } break; case (int)Possibilities.Neighbours: City city3 = ActionsMethods.getCity(tempval); foreach (Railroad road in ActionsMethods.network) { if (road.getdestinations().Contains(city3) && !road.isOccupied()) { if (road.getdestinations()[0].getID() == city3.getID()) { if (!roundOptions.Keys.Contains(road.getdestinations()[1].getname())) { roundOptions.Add(road.getdestinations()[1].getname(), road.getdestinations()[1].getID()); } } else { if (!roundOptions.Keys.Contains(road.getdestinations()[0].getname())) { roundOptions.Add(road.getdestinations()[0].getname(), road.getdestinations()[0].getID()); } } } } break; } FormDataObject data = new FormDataObject(); PlayersOptionsForm form = new PlayersOptionsForm(data, Program.form.gamepics, roundOptions, this); form.ShowDialog(); while (data.getData() == null) { form.ShowDialog(); } val = (int)data.getData(); tempval = val; foreach (KeyValuePair <string, int> pair in roundOptions) { if (roundOptions[pair.Key] == val) { Program.logboek.WriteLine(string.Format("the player chose {0}, {1}", pair.Value, pair.Key)); } } return(val); }