public RoomData(int i, TeamData g, TeamData o) : this() { index = i; gov = g; opp = o; }
// this is really bad coding. // but it seems to keep the arrays consistent! public void UpdateAllArrays() { // set all to shown foreach (RoundDebater rd in allJudges) { rd.IsShown = true; Debater d = Tournament.I.FindDebater(rd); if (d != null) { d.SetRoom(roundName, RoomData.Dummy()); } } foreach (TeamData td in allTeams) { foreach (RoundDebater rd in td) { rd.IsShown = true; Debater d = Tournament.I.FindDebater(rd); if (d != null) { d.SetRoom(roundName, RoomData.Dummy()); } } } // then set roomMembers to false foreach (RoomData room in rooms) { foreach (RoundDebater rd in room.GetRoomMembers()) { if (rd == null) { continue; } // check both cases if (rd.Role.IsJudge) { RoundDebater judge = allJudges.Find(delegate(RoundDebater rd_) { return(rd_.Equals(rd)); }); // judge should always be found, // is not shown in pool judge.IsShown = false; } else if (rd.Role.IsTeamMember) { // we need to find the reference of rd in allTeams, // set this one to not shown in pool, since it is in room TeamData td = allTeams.Find(delegate(TeamData td_) { return(td_.Contains(rd)); }); foreach (RoundDebater rd_ in td) { if (rd_.Equals(rd)) { rd_.IsShown = false; } } } // update visited rooms Debater d = Tournament.I.FindDebater(rd); if (d != null) { d.SetRoom(roundName, room); } } } }
public static void Prepare(int randomSeed, int mcSteps, RoundData roundData, List <RoundDebater> bestSpeakers) { // copy startConfig from given/current roundData startConfig = new List <RoomData>(); availSpeakers = new List <RoundDebater>(); foreach (RoomData room in roundData.Rooms) { // only consider non-empty if (room.IsEmpty) { continue; } // already set FreeSpeakers are added to // availSpeakers (no ordering by Ranking) foreach (RoundDebater rd in room.FreeSpeakers) { availSpeakers.Add(rd); } // make a hard copy, and clear freespeakers RoomData newRoom = new RoomData(room, true); newRoom.FreeSpeakers.Clear(); startConfig.Add(newRoom); } nRooms = startConfig.Count; if (nRooms == 0) { throw new Exception("No non-empty Rooms found."); } // determine avail teams from roundData, // only the ones completely shown in pool // and ordered by ranking! foreach (RoundDebater rd in bestSpeakers) { TeamData td = roundData.AllTeams.Find(delegate(TeamData td_) { return(td_.Equals(rd.Role.TeamName)); }); if (td == null) { continue; } // check if debater is shown! foreach (RoundDebater rd_ in td) { if (rd.Equals(rd_) && !rd_.IsShown) { goto outer; } } // stop if we have enough free speakers if (availSpeakers.Count == 3 * nRooms) { break; } // debater is shown in pool, so add it availSpeakers.Add(rd); outer :; } if (availSpeakers.Count < 3 * nRooms) { throw new Exception("Found " + availSpeakers.Count + " available Speakers, not enough for " + nRooms + " rooms."); } // sort availSpeakers again by Ranking, since the ones already set in rooms come first in availSpeakers // ByRanking relies on correct ordering in availSpeakers availSpeakers.Sort(delegate(RoundDebater rd1, RoundDebater rd2) { int i1 = bestSpeakers.FindIndex(delegate(RoundDebater rd) { return(rd.Equals(rd1)); }); int i2 = bestSpeakers.FindIndex(delegate(RoundDebater rd) { return(rd.Equals(rd2)); }); return(i1.CompareTo(i2)); }); // some other config, not used by ByRanking steps = mcSteps; random = new Random(randomSeed); }