cleanup BasicBot
This commit is contained in:
parent
0e218f5d4a
commit
c20ae5b16c
|
@ -1162,7 +1162,6 @@
|
||||||
this.Name = "BasicBot";
|
this.Name = "BasicBot";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||||
this.Text = "Basic Bot";
|
this.Text = "Basic Bot";
|
||||||
this.Load += new System.EventHandler(this.BasicBot_Load);
|
|
||||||
this.BotMenu.ResumeLayout(false);
|
this.BotMenu.ResumeLayout(false);
|
||||||
this.BotMenu.PerformLayout();
|
this.BotMenu.PerformLayout();
|
||||||
this.BotStatusStrip.ResumeLayout(false);
|
this.BotStatusStrip.ResumeLayout(false);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -20,37 +21,32 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private string CurrentFileName
|
private string CurrentFileName
|
||||||
{
|
{
|
||||||
get { return _currentFileName; }
|
get => _currentFileName;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_currentFileName = value;
|
_currentFileName = value;
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(_currentFileName))
|
Text = !string.IsNullOrWhiteSpace(_currentFileName)
|
||||||
{
|
? $"{DialogTitle} - {Path.GetFileNameWithoutExtension(_currentFileName)}"
|
||||||
Text = $"{DialogTitle} - {Path.GetFileNameWithoutExtension(_currentFileName)}";
|
: DialogTitle;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Text = DialogTitle;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _isBotting = false;
|
private bool _isBotting;
|
||||||
private long _attempts = 1;
|
private long _attempts = 1;
|
||||||
private long _frames = 0;
|
private long _frames;
|
||||||
private int _targetFrame = 0;
|
private int _targetFrame;
|
||||||
private bool _oldCountingSetting = false;
|
private bool _oldCountingSetting;
|
||||||
private BotAttempt _currentBotAttempt = null;
|
private BotAttempt _currentBotAttempt;
|
||||||
private BotAttempt _bestBotAttempt = null;
|
private BotAttempt _bestBotAttempt;
|
||||||
private BotAttempt _comparisonBotAttempt = null;
|
private readonly BotAttempt _comparisonBotAttempt;
|
||||||
private bool _replayMode = false;
|
private bool _replayMode;
|
||||||
private int _startFrame = 0;
|
private int _startFrame;
|
||||||
private string _lastRom = "";
|
private string _lastRom = "";
|
||||||
private int _lastFrameAdvanced { get; set; }
|
private int _lastFrameAdvanced;
|
||||||
|
|
||||||
private bool _dontUpdateValues = false;
|
private bool _doNotUpdateValues;
|
||||||
|
|
||||||
private MemoryDomain _currentDomain;
|
private MemoryDomain _currentDomain;
|
||||||
private bool _bigEndian;
|
private bool _bigEndian;
|
||||||
|
@ -88,8 +84,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Initialize
|
|
||||||
|
|
||||||
public BasicBot()
|
public BasicBot()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
@ -99,25 +93,13 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_comparisonBotAttempt = new BotAttempt();
|
_comparisonBotAttempt = new BotAttempt();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BasicBot_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region UI Bindings
|
#region UI Bindings
|
||||||
|
|
||||||
private Dictionary<string, double> ControlProbabilities
|
private Dictionary<string, double> ControlProbabilities =>
|
||||||
{
|
ControlProbabilityPanel.Controls
|
||||||
get
|
.OfType<BotControlsRow>()
|
||||||
{
|
.ToDictionary(tkey => tkey.ButtonName, tvalue => tvalue.Probability);
|
||||||
return ControlProbabilityPanel.Controls
|
|
||||||
.OfType<BotControlsRow>()
|
|
||||||
.ToDictionary(tkey => tkey.ButtonName, tvalue => tvalue.Probability);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string SelectedSlot
|
private string SelectedSlot
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -132,7 +114,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private long Attempts
|
private long Attempts
|
||||||
{
|
{
|
||||||
get { return _attempts; }
|
get => _attempts;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_attempts = value;
|
_attempts = value;
|
||||||
|
@ -142,7 +124,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private long Frames
|
private long Frames
|
||||||
{
|
{
|
||||||
get { return _frames; }
|
get => _frames;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_frames = value;
|
_frames = value;
|
||||||
|
@ -152,8 +134,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private int FrameLength
|
private int FrameLength
|
||||||
{
|
{
|
||||||
get { return (int)FrameLengthNumeric.Value; }
|
get => (int)FrameLengthNumeric.Value;
|
||||||
set { FrameLengthNumeric.Value = value; }
|
set => FrameLengthNumeric.Value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int MaximizeAddress
|
public int MaximizeAddress
|
||||||
|
@ -169,10 +151,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set => MaximizeAddressBox.SetFromRawInt(value);
|
||||||
{
|
|
||||||
MaximizeAddressBox.SetFromRawInt(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int MaximizeValue
|
public int MaximizeValue
|
||||||
|
@ -182,7 +161,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
int? addr = MaximizeAddressBox.ToRawInt();
|
int? addr = MaximizeAddressBox.ToRawInt();
|
||||||
if (addr.HasValue)
|
if (addr.HasValue)
|
||||||
{
|
{
|
||||||
return GetRamvalue(addr.Value);
|
return GetRamValue(addr.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -202,10 +181,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set => TieBreaker1Box.SetFromRawInt(value);
|
||||||
{
|
|
||||||
TieBreaker1Box.SetFromRawInt(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int TieBreaker1Value
|
public int TieBreaker1Value
|
||||||
|
@ -215,7 +191,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
int? addr = TieBreaker1Box.ToRawInt();
|
int? addr = TieBreaker1Box.ToRawInt();
|
||||||
if (addr.HasValue)
|
if (addr.HasValue)
|
||||||
{
|
{
|
||||||
return GetRamvalue(addr.Value);
|
return GetRamValue(addr.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -235,10 +211,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set => TieBreaker2Box.SetFromRawInt(value);
|
||||||
{
|
|
||||||
TieBreaker2Box.SetFromRawInt(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int TieBreaker2Value
|
public int TieBreaker2Value
|
||||||
|
@ -248,7 +221,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
int? addr = TieBreaker2Box.ToRawInt();
|
int? addr = TieBreaker2Box.ToRawInt();
|
||||||
if (addr.HasValue)
|
if (addr.HasValue)
|
||||||
{
|
{
|
||||||
return GetRamvalue(addr.Value);
|
return GetRamValue(addr.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -268,10 +241,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set => TieBreaker3Box.SetFromRawInt(value);
|
||||||
{
|
|
||||||
TieBreaker3Box.SetFromRawInt(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int TieBreaker3Value
|
public int TieBreaker3Value
|
||||||
|
@ -281,7 +251,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
int? addr = TieBreaker3Box.ToRawInt();
|
int? addr = TieBreaker3Box.ToRawInt();
|
||||||
if (addr.HasValue)
|
if (addr.HasValue)
|
||||||
{
|
{
|
||||||
return GetRamvalue(addr.Value);
|
return GetRamValue(addr.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -290,10 +260,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public byte MainComparisonType
|
public byte MainComparisonType
|
||||||
{
|
{
|
||||||
get
|
get => (byte)MainOperator.SelectedIndex;
|
||||||
{
|
|
||||||
return (byte)MainOperator.SelectedIndex;
|
|
||||||
}
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value < 5) MainOperator.SelectedIndex = value;
|
if (value < 5) MainOperator.SelectedIndex = value;
|
||||||
|
@ -303,51 +270,27 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public byte Tie1ComparisonType
|
public byte Tie1ComparisonType
|
||||||
{
|
{
|
||||||
get
|
get => (byte)Tiebreak1Operator.SelectedIndex;
|
||||||
{
|
set => Tiebreak1Operator.SelectedIndex = value < 5 ? value : 0;
|
||||||
return (byte)Tiebreak1Operator.SelectedIndex;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value < 5) Tiebreak1Operator.SelectedIndex = value;
|
|
||||||
else Tiebreak1Operator.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte Tie2ComparisonType
|
public byte Tie2ComparisonType
|
||||||
{
|
{
|
||||||
get
|
get => (byte)Tiebreak2Operator.SelectedIndex;
|
||||||
{
|
set => Tiebreak2Operator.SelectedIndex = value < 5 ? value : 0;
|
||||||
return (byte)Tiebreak2Operator.SelectedIndex;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value < 5) Tiebreak2Operator.SelectedIndex = value;
|
|
||||||
else Tiebreak2Operator.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte Tie3ComparisonType
|
public byte Tie3ComparisonType
|
||||||
{
|
{
|
||||||
get
|
get => (byte)Tiebreak3Operator.SelectedIndex;
|
||||||
{
|
set => Tiebreak3Operator.SelectedIndex = value < 5 ? value : 0;
|
||||||
return (byte)Tiebreak3Operator.SelectedIndex;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value < 5) Tiebreak3Operator.SelectedIndex = value;
|
|
||||||
else Tiebreak3Operator.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string FromSlot
|
public string FromSlot
|
||||||
{
|
{
|
||||||
get
|
get => StartFromSlotBox.SelectedItem != null
|
||||||
{
|
? StartFromSlotBox.SelectedItem.ToString()
|
||||||
return StartFromSlotBox.SelectedItem != null
|
: "";
|
||||||
? StartFromSlotBox.SelectedItem.ToString()
|
|
||||||
: "";
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
@ -355,31 +298,23 @@ namespace BizHawk.Client.EmuHawk
|
||||||
.OfType<object>()
|
.OfType<object>()
|
||||||
.FirstOrDefault(o => o.ToString() == value);
|
.FirstOrDefault(o => o.ToString() == value);
|
||||||
|
|
||||||
if (item != null)
|
StartFromSlotBox.SelectedItem = item;
|
||||||
{
|
|
||||||
StartFromSlotBox.SelectedItem = item;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
StartFromSlotBox.SelectedItem = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Upon Load State, TASStudio uses GlobalWin.Tools.UpdateBefore(); as well as GlobalWin.Tools.UpdateAfter();
|
// Upon Load State, TAStudio uses GlobalWin.Tools.UpdateBefore(); as well as GlobalWin.Tools.UpdateAfter();
|
||||||
//Both of which will Call UpdateValues() and Update() which both end up in the Update() function. Calling Update() will cause the Log to add an additional log.
|
// Both of which will Call UpdateValues() and Update() which both end up in the Update() function. Calling Update() will cause the Log to add an additional log.
|
||||||
//By not handling both of those calls the _currentBotAttempt.Log.Count will be 2 more than expected.
|
// By not handling both of those calls the _currentBotAttempt.Log.Count will be 2 more than expected.
|
||||||
//However this also causes a problem with ramwatch not being up to date since that TOO gets called.
|
// However this also causes a problem with RamWatch not being up to date since that TOO gets called.
|
||||||
//Need to find out if having RamWatch open while TasStudio is open causes issues.
|
// Need to find out if having RamWatch open while TasStudio is open causes issues.
|
||||||
//there appears to be "hack"(?) line in ToolManager.UpdateBefore that seems to refresh the RamWatch. Not sure that is causing any issue since it does look like the ramwatch is ahead too much..
|
// there appears to be "hack"(?) line in ToolManager.UpdateBefore that seems to refresh the RamWatch. Not sure that is causing any issue since it does look like the RamWatch is ahead too much..
|
||||||
|
|
||||||
public int LastFrameAdvanced { get; set; }
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IToolForm Implementation
|
#region IToolForm Implementation
|
||||||
|
|
||||||
public bool UpdateBefore { get { return true; } }
|
public bool UpdateBefore => true;
|
||||||
|
|
||||||
public void NewUpdate(ToolFormUpdateType type) { }
|
public void NewUpdate(ToolFormUpdateType type) { }
|
||||||
|
|
||||||
|
@ -388,7 +323,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Update(fast: false);
|
Update(fast: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void FastUpdate()
|
public void FastUpdate()
|
||||||
{
|
{
|
||||||
Update(fast: true);
|
Update(fast: true);
|
||||||
|
@ -414,17 +348,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (_lastRom != GlobalWin.MainForm.CurrentlyOpenRom)
|
if (_lastRom != MainForm.CurrentlyOpenRom)
|
||||||
{
|
{
|
||||||
_lastRom = GlobalWin.MainForm.CurrentlyOpenRom;
|
_lastRom = MainForm.CurrentlyOpenRom;
|
||||||
SetupControlsAndProperties();
|
SetupControlsAndProperties();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AskSaveChanges()
|
public bool AskSaveChanges() => true;
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -596,14 +527,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
StopBot();
|
StopBot();
|
||||||
_replayMode = true;
|
_replayMode = true;
|
||||||
_dontUpdateValues = true;
|
_doNotUpdateValues = true;
|
||||||
GlobalWin.MainForm.LoadQuickSave(SelectedSlot, false, true); // Triggers an UpdateValues call
|
MainForm.LoadQuickSave(SelectedSlot, false, true); // Triggers an UpdateValues call
|
||||||
_dontUpdateValues = false;
|
_doNotUpdateValues = false;
|
||||||
_startFrame = Emulator.Frame;
|
_startFrame = Emulator.Frame;
|
||||||
SetNormalSpeed();
|
SetNormalSpeed();
|
||||||
UpdateBotStatusIcon();
|
UpdateBotStatusIcon();
|
||||||
MessageLabel.Text = "Replaying";
|
MessageLabel.Text = "Replaying";
|
||||||
GlobalWin.MainForm.UnpauseEmulator();
|
MainForm.UnpauseEmulator();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FrameLengthNumeric_ValueChanged(object sender, EventArgs e)
|
private void FrameLengthNumeric_ValueChanged(object sender, EventArgs e)
|
||||||
|
@ -623,11 +554,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private class BotAttempt
|
private class BotAttempt
|
||||||
{
|
{
|
||||||
public BotAttempt()
|
|
||||||
{
|
|
||||||
Log = new List<string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long Attempt { get; set; }
|
public long Attempt { get; set; }
|
||||||
public int Maximize { get; set; }
|
public int Maximize { get; set; }
|
||||||
public int TieBreak1 { get; set; }
|
public int TieBreak1 { get; set; }
|
||||||
|
@ -638,19 +564,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public byte ComparisonTypeTie2 { get; set; }
|
public byte ComparisonTypeTie2 { get; set; }
|
||||||
public byte ComparisonTypeTie3 { get; set; }
|
public byte ComparisonTypeTie3 { get; set; }
|
||||||
|
|
||||||
public List<string> Log { get; set; }
|
public List<string> Log { get; } = new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class BotData
|
private class BotData
|
||||||
{
|
{
|
||||||
public BotData()
|
|
||||||
{
|
|
||||||
MainCompareToBest = true;
|
|
||||||
TieBreaker1CompareToBest = true;
|
|
||||||
TieBreaker2CompareToBest = true;
|
|
||||||
TieBreaker3CompareToBest = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BotAttempt Best { get; set; }
|
public BotAttempt Best { get; set; }
|
||||||
public Dictionary<string, double> ControlProbabilities { get; set; }
|
public Dictionary<string, double> ControlProbabilities { get; set; }
|
||||||
public int Maximize { get; set; }
|
public int Maximize { get; set; }
|
||||||
|
@ -661,10 +579,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public byte ComparisonTypeTie1 { get; set; }
|
public byte ComparisonTypeTie1 { get; set; }
|
||||||
public byte ComparisonTypeTie2 { get; set; }
|
public byte ComparisonTypeTie2 { get; set; }
|
||||||
public byte ComparisonTypeTie3 { get; set; }
|
public byte ComparisonTypeTie3 { get; set; }
|
||||||
public bool MainCompareToBest { get; set; }
|
public bool MainCompareToBest { get; set; } = true;
|
||||||
public bool TieBreaker1CompareToBest { get; set; }
|
public bool TieBreaker1CompareToBest { get; set; } = true;
|
||||||
public bool TieBreaker2CompareToBest { get; set; }
|
public bool TieBreaker2CompareToBest { get; set; } = true;
|
||||||
public bool TieBreaker3CompareToBest { get; set; }
|
public bool TieBreaker3CompareToBest { get; set; } = true;
|
||||||
public int MainCompareToValue { get; set; }
|
public int MainCompareToValue { get; set; }
|
||||||
public int TieBreaker1CompareToValue { get; set; }
|
public int TieBreaker1CompareToValue { get; set; }
|
||||||
public int TieBreaker2CompareToValue { get; set; }
|
public int TieBreaker2CompareToValue { get; set; }
|
||||||
|
@ -845,10 +763,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
StartFromSlotBox.SelectedIndex = 0;
|
StartFromSlotBox.SelectedIndex = 0;
|
||||||
|
|
||||||
const int starty = 0;
|
const int startY = 0;
|
||||||
const int lineHeight = 30;
|
const int lineHeight = 30;
|
||||||
const int marginLeft = 15;
|
const int marginLeft = 15;
|
||||||
int accumulatedy = 0;
|
int accumulatedY = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
ControlProbabilityPanel.SuspendLayout();
|
ControlProbabilityPanel.SuspendLayout();
|
||||||
|
@ -859,16 +777,17 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
ButtonName = button,
|
ButtonName = button,
|
||||||
Probability = 0.0,
|
Probability = 0.0,
|
||||||
Location = new Point(marginLeft, starty + accumulatedy),
|
Location = new Point(marginLeft, startY + accumulatedY),
|
||||||
TabIndex = count + 1,
|
TabIndex = count + 1,
|
||||||
ProbabilityChangedCallback = AssessRunButtonStatus
|
ProbabilityChangedCallback = AssessRunButtonStatus
|
||||||
};
|
};
|
||||||
control.Scale(UIHelper.AutoScaleFactor);
|
control.Scale(UIHelper.AutoScaleFactor);
|
||||||
|
|
||||||
ControlProbabilityPanel.Controls.Add(control);
|
ControlProbabilityPanel.Controls.Add(control);
|
||||||
accumulatedy += lineHeight;
|
accumulatedY += lineHeight;
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlProbabilityPanel.ResumeLayout();
|
ControlProbabilityPanel.ResumeLayout();
|
||||||
|
|
||||||
if (Settings.RecentBotFiles.AutoLoad)
|
if (Settings.RecentBotFiles.AutoLoad)
|
||||||
|
@ -890,7 +809,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
TieBreaker3Box.SetHexProperties(_currentDomain.Size);
|
TieBreaker3Box.SetHexProperties(_currentDomain.Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetRamvalue(int addr)
|
private int GetRamValue(int addr)
|
||||||
{
|
{
|
||||||
int val;
|
int val;
|
||||||
switch (_dataSize)
|
switch (_dataSize)
|
||||||
|
@ -912,7 +831,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void Update(bool fast)
|
private void Update(bool fast)
|
||||||
{
|
{
|
||||||
if (_dontUpdateValues)
|
if (_doNotUpdateValues)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -964,9 +883,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentBotAttempt = new BotAttempt { Attempt = Attempts };
|
_currentBotAttempt = new BotAttempt { Attempt = Attempts };
|
||||||
GlobalWin.MainForm.LoadQuickSave(SelectedSlot, false, true);
|
MainForm.LoadQuickSave(SelectedSlot, false, true);
|
||||||
}
|
}
|
||||||
//Before this would have 2 additional hits before the frame even advanced, making the amount of inputs greater than the number of frames to test.
|
|
||||||
|
// Before this would have 2 additional hits before the frame even advanced, making the amount of inputs greater than the number of frames to test.
|
||||||
if (_currentBotAttempt.Log.Count < FrameLength) //aka do not Add more inputs than there are Frames to test
|
if (_currentBotAttempt.Log.Count < FrameLength) //aka do not Add more inputs than there are Frames to test
|
||||||
{
|
{
|
||||||
PressButtons();
|
PressButtons();
|
||||||
|
@ -977,7 +897,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void FinishReplay()
|
private void FinishReplay()
|
||||||
{
|
{
|
||||||
GlobalWin.MainForm.PauseEmulator();
|
MainForm.PauseEmulator();
|
||||||
_startFrame = 0;
|
_startFrame = 0;
|
||||||
_replayMode = false;
|
_replayMode = false;
|
||||||
UpdateBotStatusIcon();
|
UpdateBotStatusIcon();
|
||||||
|
@ -990,19 +910,22 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (current.Maximize == comparison.Maximize)
|
|
||||||
|
if (current.Maximize == comparison.Maximize)
|
||||||
{
|
{
|
||||||
if (!TestValue(Tie1ComparisonType, current.TieBreak1, comparison.TieBreak1))
|
if (!TestValue(Tie1ComparisonType, current.TieBreak1, comparison.TieBreak1))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (current.TieBreak1 == comparison.TieBreak1)
|
|
||||||
|
if (current.TieBreak1 == comparison.TieBreak1)
|
||||||
{
|
{
|
||||||
if (!TestValue(Tie2ComparisonType, current.TieBreak2, comparison.TieBreak2))
|
if (!TestValue(Tie2ComparisonType, current.TieBreak2, comparison.TieBreak2))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (current.TieBreak2 == comparison.TieBreak2)
|
|
||||||
|
if (current.TieBreak2 == comparison.TieBreak2)
|
||||||
{
|
{
|
||||||
if (!TestValue(Tie3ComparisonType, current.TieBreak3, current.TieBreak3))
|
if (!TestValue(Tie3ComparisonType, current.TieBreak3, current.TieBreak3))
|
||||||
{
|
{
|
||||||
|
@ -1069,14 +992,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
var rand = new Random((int)DateTime.Now.Ticks);
|
var rand = new Random((int)DateTime.Now.Ticks);
|
||||||
|
|
||||||
var buttonLog = new Dictionary<string, bool>();
|
|
||||||
|
|
||||||
foreach (var button in Emulator.ControllerDefinition.BoolButtons)
|
foreach (var button in Emulator.ControllerDefinition.BoolButtons)
|
||||||
{
|
{
|
||||||
double probability = _cachedControlProbabilities[button];
|
double probability = _cachedControlProbabilities[button];
|
||||||
bool pressed = !(rand.Next(100) < probability);
|
bool pressed = !(rand.Next(100) < probability);
|
||||||
|
|
||||||
buttonLog.Add(button, pressed);
|
|
||||||
Global.ClickyVirtualPadController.SetBool(button, pressed);
|
Global.ClickyVirtualPadController.SetBool(button, pressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1105,13 +1025,13 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Global.MovieSession.Movie.IsCountingRerecords = false;
|
Global.MovieSession.Movie.IsCountingRerecords = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_dontUpdateValues = true;
|
_doNotUpdateValues = true;
|
||||||
GlobalWin.MainForm.LoadQuickSave(SelectedSlot, false, true); // Triggers an UpdateValues call
|
MainForm.LoadQuickSave(SelectedSlot, false, true); // Triggers an UpdateValues call
|
||||||
_dontUpdateValues = false;
|
_doNotUpdateValues = false;
|
||||||
|
|
||||||
_targetFrame = Emulator.Frame + (int)FrameLengthNumeric.Value;
|
_targetFrame = Emulator.Frame + (int)FrameLengthNumeric.Value;
|
||||||
|
|
||||||
GlobalWin.MainForm.UnpauseEmulator();
|
MainForm.UnpauseEmulator();
|
||||||
if (Settings.TurboWhenBotting)
|
if (Settings.TurboWhenBotting)
|
||||||
{
|
{
|
||||||
SetMaxSpeed();
|
SetMaxSpeed();
|
||||||
|
@ -1161,7 +1081,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Global.MovieSession.Movie.IsCountingRerecords = _oldCountingSetting;
|
Global.MovieSession.Movie.IsCountingRerecords = _oldCountingSetting;
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalWin.MainForm.PauseEmulator();
|
MainForm.PauseEmulator();
|
||||||
SetNormalSpeed();
|
SetNormalSpeed();
|
||||||
UpdateBotStatusIcon();
|
UpdateBotStatusIcon();
|
||||||
MessageLabel.Text = "Bot stopped";
|
MessageLabel.Text = "Bot stopped";
|
||||||
|
@ -1188,12 +1108,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void SetMaxSpeed()
|
private void SetMaxSpeed()
|
||||||
{
|
{
|
||||||
GlobalWin.MainForm.Unthrottle();
|
MainForm.Unthrottle();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetNormalSpeed()
|
private void SetNormalSpeed()
|
||||||
{
|
{
|
||||||
GlobalWin.MainForm.Throttle();
|
MainForm.Throttle();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AssessRunButtonStatus()
|
private void AssessRunButtonStatus()
|
||||||
|
@ -1260,8 +1180,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
RadioButton radioButton = (RadioButton)sender;
|
RadioButton radioButton = (RadioButton)sender;
|
||||||
if (radioButton.Checked)
|
if (radioButton.Checked)
|
||||||
{
|
{
|
||||||
this.MainValueNumeric.Enabled = false;
|
MainValueNumeric.Enabled = false;
|
||||||
_comparisonBotAttempt.Maximize = _bestBotAttempt == null ? 0 : _bestBotAttempt.Maximize;
|
_comparisonBotAttempt.Maximize = _bestBotAttempt?.Maximize ?? 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1270,8 +1190,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
RadioButton radioButton = (RadioButton)sender;
|
RadioButton radioButton = (RadioButton)sender;
|
||||||
if (radioButton.Checked)
|
if (radioButton.Checked)
|
||||||
{
|
{
|
||||||
this.TieBreak1Numeric.Enabled = false;
|
TieBreak1Numeric.Enabled = false;
|
||||||
_comparisonBotAttempt.TieBreak1 = _bestBotAttempt == null ? 0 : _bestBotAttempt.TieBreak1;
|
_comparisonBotAttempt.TieBreak1 = _bestBotAttempt?.TieBreak1 ?? 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1280,8 +1200,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
RadioButton radioButton = (RadioButton)sender;
|
RadioButton radioButton = (RadioButton)sender;
|
||||||
if (radioButton.Checked)
|
if (radioButton.Checked)
|
||||||
{
|
{
|
||||||
this.TieBreak2Numeric.Enabled = false;
|
TieBreak2Numeric.Enabled = false;
|
||||||
_comparisonBotAttempt.TieBreak2 = _bestBotAttempt == null ? 0 : _bestBotAttempt.TieBreak2;
|
_comparisonBotAttempt.TieBreak2 = _bestBotAttempt?.TieBreak2 ?? 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1290,8 +1210,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
RadioButton radioButton = (RadioButton)sender;
|
RadioButton radioButton = (RadioButton)sender;
|
||||||
if (radioButton.Checked)
|
if (radioButton.Checked)
|
||||||
{
|
{
|
||||||
this.TieBreak3Numeric.Enabled = false;
|
TieBreak3Numeric.Enabled = false;
|
||||||
_comparisonBotAttempt.TieBreak3 = _bestBotAttempt == null ? 0 : _bestBotAttempt.TieBreak3;
|
_comparisonBotAttempt.TieBreak3 = _bestBotAttempt?.TieBreak3 ?? 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1300,8 +1220,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
RadioButton radioButton = (RadioButton)sender;
|
RadioButton radioButton = (RadioButton)sender;
|
||||||
if (radioButton.Checked)
|
if (radioButton.Checked)
|
||||||
{
|
{
|
||||||
this.MainValueNumeric.Enabled = true;
|
MainValueNumeric.Enabled = true;
|
||||||
_comparisonBotAttempt.Maximize = (int)this.MainValueNumeric.Value;
|
_comparisonBotAttempt.Maximize = (int)MainValueNumeric.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1310,8 +1230,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
RadioButton radioButton = (RadioButton)sender;
|
RadioButton radioButton = (RadioButton)sender;
|
||||||
if (radioButton.Checked)
|
if (radioButton.Checked)
|
||||||
{
|
{
|
||||||
this.TieBreak1Numeric.Enabled = true;
|
TieBreak1Numeric.Enabled = true;
|
||||||
_comparisonBotAttempt.TieBreak1 = (int)this.TieBreak1Numeric.Value;
|
_comparisonBotAttempt.TieBreak1 = (int)TieBreak1Numeric.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1320,8 +1240,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
RadioButton radioButton = (RadioButton)sender;
|
RadioButton radioButton = (RadioButton)sender;
|
||||||
if (radioButton.Checked)
|
if (radioButton.Checked)
|
||||||
{
|
{
|
||||||
this.TieBreak2Numeric.Enabled = true;
|
TieBreak2Numeric.Enabled = true;
|
||||||
_comparisonBotAttempt.TieBreak2 = (int)this.TieBreak2Numeric.Value;
|
_comparisonBotAttempt.TieBreak2 = (int)TieBreak2Numeric.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1330,45 +1250,44 @@ namespace BizHawk.Client.EmuHawk
|
||||||
RadioButton radioButton = (RadioButton)sender;
|
RadioButton radioButton = (RadioButton)sender;
|
||||||
if (radioButton.Checked)
|
if (radioButton.Checked)
|
||||||
{
|
{
|
||||||
this.TieBreak3Numeric.Enabled = true;
|
TieBreak3Numeric.Enabled = true;
|
||||||
_comparisonBotAttempt.TieBreak3 = (int)this.TieBreak3Numeric.Value;
|
_comparisonBotAttempt.TieBreak3 = (int)TieBreak3Numeric.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainValueNumeric_ValueChanged(object sender, EventArgs e)
|
private void MainValueNumeric_ValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
NumericUpDown numericUpDown = (NumericUpDown)sender;
|
NumericUpDown numericUpDown = (NumericUpDown)sender;
|
||||||
this._comparisonBotAttempt.Maximize = (int)numericUpDown.Value;
|
_comparisonBotAttempt.Maximize = (int)numericUpDown.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TieBreak1Numeric_ValueChanged(object sender, EventArgs e)
|
private void TieBreak1Numeric_ValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
NumericUpDown numericUpDown = (NumericUpDown)sender;
|
NumericUpDown numericUpDown = (NumericUpDown)sender;
|
||||||
this._comparisonBotAttempt.TieBreak1 = (int)numericUpDown.Value;
|
_comparisonBotAttempt.TieBreak1 = (int)numericUpDown.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TieBreak2Numeric_ValueChanged(object sender, EventArgs e)
|
private void TieBreak2Numeric_ValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
NumericUpDown numericUpDown = (NumericUpDown)sender;
|
NumericUpDown numericUpDown = (NumericUpDown)sender;
|
||||||
this._comparisonBotAttempt.TieBreak2 = (int)numericUpDown.Value;
|
_comparisonBotAttempt.TieBreak2 = (int)numericUpDown.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TieBreak3Numeric_ValueChanged(object sender, EventArgs e)
|
private void TieBreak3Numeric_ValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
NumericUpDown numericUpDown = (NumericUpDown)sender;
|
NumericUpDown numericUpDown = (NumericUpDown)sender;
|
||||||
this._comparisonBotAttempt.TieBreak3 = (int)numericUpDown.Value;
|
_comparisonBotAttempt.TieBreak3 = (int)numericUpDown.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Copy to Clipboard
|
//Copy to Clipboard
|
||||||
private void btnCopyBestInput_Click(object sender, EventArgs e)
|
private void btnCopyBestInput_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Clipboard.SetText(BestAttemptLogLabel.Text);
|
Clipboard.SetText(BestAttemptLogLabel.Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HelpToolStripMenuItem_Click(object sender, EventArgs e)
|
private void HelpToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Process.Start("http://tasvideos.org/Bizhawk/BasicBot.html");
|
Process.Start("http://tasvideos.org/Bizhawk/BasicBot.html");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1677,7 +1677,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void SetColorsMenuItem_Click(object sender, EventArgs e)
|
private void SetColorsMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
using var form = new HexColorsForm();
|
using var form = new HexColorsForm(this, Config);
|
||||||
form.ShowHawkDialog();
|
form.ShowHawkDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue