-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomBot.cs
More file actions
37 lines (30 loc) · 1 KB
/
RandomBot.cs
File metadata and controls
37 lines (30 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Collections.Generic;
using System.Linq;
public class MyBot
{
public const string RandomBotName = "RandomC#Bot";
public static void Main(string[] args) {
Console.SetIn(Console.In);
Console.SetOut(Console.Out);
ushort myID;
var map = Networking.getInit(out myID);
Networking.SendInit(RandomBotName);
var random = new Random();
while (true) {
Networking.getFrame(ref map);
var moves = new List<Move>();
for (ushort x = 0; x < map.Width; x++) {
for (ushort y = 0; y < map.Height; y++) {
if (map[x, y].Owner == myID) {
moves.Add(new Move {
Location = new Location {X = x, Y = y},
Direction = (Direction)random.Next(5)
});
}
}
}
Networking.SendMoves(moves); // Send moves
}
}
}