Created simple random selection bot.
This commit is contained in:
parent
2c70e99cc1
commit
1910094e27
@ -7,6 +7,7 @@ string apiAuthorization = "HTI Thanks You [OZL]";
|
||||
string baseUrl = @"https://maze.hightechict.nl/";
|
||||
|
||||
string username = "Hi Hightech!";
|
||||
string mazeName = "Example Maze";
|
||||
|
||||
Console.WriteLine("Starting bot...");
|
||||
|
||||
@ -34,15 +35,42 @@ if (!registered)
|
||||
|
||||
Console.WriteLine($"Player '{username}' registered");
|
||||
|
||||
PossibleActionsAndCurrentScore result = await mazeClient.EnterMaze("Test");
|
||||
Random random = new Random();
|
||||
|
||||
Console.WriteLine($"Entering maze '{mazeName}'");
|
||||
PossibleActionsAndCurrentScore result = await mazeClient.EnterMaze(mazeName);
|
||||
|
||||
ConsoleKeyInfo input;
|
||||
do
|
||||
{
|
||||
input = Console.ReadKey();
|
||||
input.
|
||||
}
|
||||
while (result != null);
|
||||
await Task.Delay(100);
|
||||
// select a way to go
|
||||
MoveAction[] moves = result.PossibleMoveActions.ToArray();
|
||||
MoveAction[] notExploredMoves = moves.Any(m => !m.HasBeenVisited) ? moves.Where(m => !m.HasBeenVisited).ToArray() : moves;
|
||||
|
||||
if (moves.All(m => m.HasBeenVisited))
|
||||
{
|
||||
Console.WriteLine("All adjacent tiles have been visited! Selecting next path random.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"{string.Join(", ", notExploredMoves.Select(m => m.Direction.ToString()))} have not been visited, selecting next move.");
|
||||
}
|
||||
|
||||
int selected = random.Next(notExploredMoves.Length - 1);
|
||||
|
||||
MoveAction moveAction = notExploredMoves[selected];
|
||||
|
||||
Console.WriteLine($"Moving {moveAction.Direction}, I have {(!moveAction.HasBeenVisited ? "not" : string.Empty)} been here.");
|
||||
|
||||
result = await mazeClient.Move(moveAction.Direction);
|
||||
|
||||
Console.WriteLine($"New tile has {(!result.CanExitMazeHere ? "no" : string.Empty)} exit.");
|
||||
|
||||
} while (!result.CanExitMazeHere);
|
||||
|
||||
await mazeClient.ExitMaze();
|
||||
|
||||
Console.WriteLine($"Exited the maze!");
|
||||
|
||||
async Task<bool> RegisterPlayer(string username, bool reset = false)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user