From 7660b9ce886dbeefafe83d604b662105b2be32a5 Mon Sep 17 00:00:00 2001 From: "Valeriano A.R" Date: Sun, 10 Nov 2019 18:36:08 +0100 Subject: [PATCH] TetrisBot: Make ShotCooldownFrames configurable. --- VAR.ScreenAutomation/Bots/TetrisBot.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/VAR.ScreenAutomation/Bots/TetrisBot.cs b/VAR.ScreenAutomation/Bots/TetrisBot.cs index efa2d83..3617898 100644 --- a/VAR.ScreenAutomation/Bots/TetrisBot.cs +++ b/VAR.ScreenAutomation/Bots/TetrisBot.cs @@ -28,12 +28,14 @@ namespace VAR.ScreenAutomation.Bots private const int DefaultGridWidth = 10; private const int DefaultGridHeight = 20; + private const int DefaultShotCooldownFrames = 2; public IConfiguration GetDefaultConfiguration() { var defaultConfiguration = new MemoryBackedConfiguration(); defaultConfiguration.Set("GridWidth", DefaultGridWidth); defaultConfiguration.Set("GridHeight", DefaultGridHeight); + defaultConfiguration.Set("ShotCooldownFrames", DefaultShotCooldownFrames); return defaultConfiguration; } @@ -41,6 +43,7 @@ namespace VAR.ScreenAutomation.Bots { int gridWidth = config.Get("GridWidth", DefaultGridWidth); int gridHeight = config.Get("GridHeight", DefaultGridHeight); + _shotCooldownFrames = config.Get("ShotCooldownFrames", DefaultShotCooldownFrames); _grid = new TetrisGrid(gridWidth, gridHeight); _workGrid0 = new TetrisGrid(gridWidth, gridHeight); @@ -162,8 +165,8 @@ namespace VAR.ScreenAutomation.Bots } } - private const int ShotCooldownFrames = 2; - private int _shotCooldown = ShotCooldownFrames; + private int _shotCooldownFrames = 0; + private int _shotCooldown = 0; public string ResponseKeys() { @@ -173,7 +176,7 @@ namespace VAR.ScreenAutomation.Bots { if (_shotCooldown <= 0) { - _shotCooldown = ShotCooldownFrames; + _shotCooldown = _shotCooldownFrames; return " "; } 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}{RIGHT}"; } @@ -837,6 +840,5 @@ namespace VAR.ScreenAutomation.Bots } } } - } }