TetrisBot: Better shot heuristics.
This commit is contained in:
@@ -171,30 +171,29 @@ namespace VAR.ScreenAutomation.Bots
|
|||||||
maxHeightWeight: -0.25);
|
maxHeightWeight: -0.25);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _canShot = true;
|
private const int ShowCooldownFrames = 2;
|
||||||
private int _lastShotShapeY = 0;
|
private int _shotCooldown = ShowCooldownFrames;
|
||||||
private DateTime _lastShotDateTime;
|
|
||||||
|
|
||||||
public string ResponseKeys()
|
public string ResponseKeys()
|
||||||
{
|
{
|
||||||
if (_shapeFound == false) { return string.Empty; }
|
if (_shapeFound == false) { return string.Empty; }
|
||||||
|
|
||||||
if (_canShot == false && (_shapeY < _lastShotShapeY || _lastShotDateTime.AddMilliseconds(500) < DateTime.UtcNow))
|
|
||||||
{
|
|
||||||
_canShot = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_bestRotation == 0 && _bestXOffset == 0 && _bestEvaluation > double.MinValue)
|
if (_bestRotation == 0 && _bestXOffset == 0 && _bestEvaluation > double.MinValue)
|
||||||
{
|
{
|
||||||
if (_canShot)
|
if (_shotCooldown <= 0)
|
||||||
{
|
{
|
||||||
_canShot = false;
|
_shotCooldown = ShowCooldownFrames;
|
||||||
_lastShotShapeY = _shapeY;
|
|
||||||
_lastShotDateTime = DateTime.UtcNow;
|
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_shotCooldown--;
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_shotCooldown = ShowCooldownFrames;
|
||||||
|
|
||||||
if (_bestRotation != 0 && _bestXOffset < 0) { return "{UP}{LEFT}"; }
|
if (_bestRotation != 0 && _bestXOffset < 0) { return "{UP}{LEFT}"; }
|
||||||
if (_bestRotation != 0 && _bestXOffset > 0) { return "{UP}{RIGHT}"; }
|
if (_bestRotation != 0 && _bestXOffset > 0) { return "{UP}{RIGHT}"; }
|
||||||
if (_bestRotation != 0) { return "{UP}"; }
|
if (_bestRotation != 0) { return "{UP}"; }
|
||||||
|
|||||||
Reference in New Issue
Block a user