Basic Bot - make the UpdateValues call much much faster

This commit is contained in:
adelikat 2015-09-07 10:29:40 -04:00
parent eaaac167f1
commit e3c40ea2ef
1 changed files with 9 additions and 5 deletions

View File

@ -54,6 +54,9 @@ namespace BizHawk.Client.EmuHawk
private bool _bigEndian;
private int _dataSize;
private Dictionary<string, double> _cachedControlProbabilities;
private ILogEntryGenerator _logGenerator;
#region Services and Settings
[RequiredService]
@ -867,16 +870,14 @@ namespace BizHawk.Client.EmuHawk
foreach (var button in Emulator.ControllerDefinition.BoolButtons)
{
double probability = ControlProbabilities[button];
double probability = _cachedControlProbabilities[button];
bool pressed = !(rand.Next(100) < probability);
buttonLog.Add(button, pressed);
Global.ClickyVirtualPadController.SetBool(button, pressed);
}
var lg = Global.MovieSession.LogGeneratorInstance();
lg.SetSource(Global.ClickyVirtualPadController);
_currentBotAttempt.Log.Add(lg.GenerateLogEntry());
_currentBotAttempt.Log.Add(_logGenerator.GenerateLogEntry());
}
private void StartBot()
@ -915,7 +916,10 @@ namespace BizHawk.Client.EmuHawk
UpdateBotStatusIcon();
MessageLabel.Text = "Running...";
}
_cachedControlProbabilities = ControlProbabilities;
_logGenerator = Global.MovieSession.LogGeneratorInstance();
_logGenerator.SetSource(Global.ClickyVirtualPadController);
}
private bool CanStart()
{