private void _UpdateUI(IterationData data) { Console.WriteLine(_users.Count); Console.Write(data.uIteration + "\t"); Console.Write(data.uThreshold + "\t"); foreach (Team team in Enum.GetValues(typeof(Team))) { foreach (UserState state in Enum.GetValues(typeof(UserState))) { Console.Write(data.GetData(team, state) + "\t"); } } Console.WriteLine(); }
// ITimeControlledObject public void Trigger() { IterationData data = new IterationData(); data.uIteration = _cIterations; data.uThreshold = _uThreshold; _AddUsers(); foreach (User user in _users) { UserState state = user.GetState(_uLottery); Team team = user.GetTeam(); data.SetData(team, state); } _UpdateUI(data); _UpdateLottery(data); _cIterations++; }
private void _UpdateLottery(IterationData data) { bool fLossCondition = false; // Here we'll assume there's two teams. bool fBlueLoss = data.GetData(Team.Blue, UserState.Clicked) < _uThreshold; bool fRedLoss = data.GetData(Team.Red, UserState.Clicked) < _uThreshold; if (fBlueLoss && fRedLoss) { // Both teams lose // Grow the lottery even more, keep the threshold the same _uLottery = (uint)(_uLottery * c_dLotteryGrowth); } else if (fRedLoss) { // Blue wins _uBlueScore += _uLottery; _ResetGame(); } else if (fBlueLoss) { // Red wins _uRedScore += _uLottery; _ResetGame(); } else { // No winner _uThreshold = (uint) Math.Ceiling(_uThreshold * c_dThresholdGrowth); } // Update the total lottery _uLotteryTotal += _uLottery; }