TetrisBot: Make ShotCooldownFrames configurable.
This commit is contained in:
@@ -28,12 +28,14 @@ namespace VAR.ScreenAutomation.Bots
|
|||||||
|
|
||||||
private const int DefaultGridWidth = 10;
|
private const int DefaultGridWidth = 10;
|
||||||
private const int DefaultGridHeight = 20;
|
private const int DefaultGridHeight = 20;
|
||||||
|
private const int DefaultShotCooldownFrames = 2;
|
||||||
|
|
||||||
public IConfiguration GetDefaultConfiguration()
|
public IConfiguration GetDefaultConfiguration()
|
||||||
{
|
{
|
||||||
var defaultConfiguration = new MemoryBackedConfiguration();
|
var defaultConfiguration = new MemoryBackedConfiguration();
|
||||||
defaultConfiguration.Set("GridWidth", DefaultGridWidth);
|
defaultConfiguration.Set("GridWidth", DefaultGridWidth);
|
||||||
defaultConfiguration.Set("GridHeight", DefaultGridHeight);
|
defaultConfiguration.Set("GridHeight", DefaultGridHeight);
|
||||||
|
defaultConfiguration.Set("ShotCooldownFrames", DefaultShotCooldownFrames);
|
||||||
return defaultConfiguration;
|
return defaultConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,6 +43,7 @@ namespace VAR.ScreenAutomation.Bots
|
|||||||
{
|
{
|
||||||
int gridWidth = config.Get("GridWidth", DefaultGridWidth);
|
int gridWidth = config.Get("GridWidth", DefaultGridWidth);
|
||||||
int gridHeight = config.Get("GridHeight", DefaultGridHeight);
|
int gridHeight = config.Get("GridHeight", DefaultGridHeight);
|
||||||
|
_shotCooldownFrames = config.Get("ShotCooldownFrames", DefaultShotCooldownFrames);
|
||||||
|
|
||||||
_grid = new TetrisGrid(gridWidth, gridHeight);
|
_grid = new TetrisGrid(gridWidth, gridHeight);
|
||||||
_workGrid0 = new TetrisGrid(gridWidth, gridHeight);
|
_workGrid0 = new TetrisGrid(gridWidth, gridHeight);
|
||||||
@@ -162,8 +165,8 @@ namespace VAR.ScreenAutomation.Bots
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private const int ShotCooldownFrames = 2;
|
private int _shotCooldownFrames = 0;
|
||||||
private int _shotCooldown = ShotCooldownFrames;
|
private int _shotCooldown = 0;
|
||||||
|
|
||||||
public string ResponseKeys()
|
public string ResponseKeys()
|
||||||
{
|
{
|
||||||
@@ -173,7 +176,7 @@ namespace VAR.ScreenAutomation.Bots
|
|||||||
{
|
{
|
||||||
if (_shotCooldown <= 0)
|
if (_shotCooldown <= 0)
|
||||||
{
|
{
|
||||||
_shotCooldown = ShotCooldownFrames;
|
_shotCooldown = _shotCooldownFrames;
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -183,7 +186,7 @@ namespace VAR.ScreenAutomation.Bots
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_shotCooldown = ShotCooldownFrames;
|
_shotCooldown = _shotCooldownFrames;
|
||||||
|
|
||||||
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}"; }
|
||||||
@@ -837,6 +840,5 @@ namespace VAR.ScreenAutomation.Bots
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user