-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bot.cs
63 lines (57 loc) · 1.48 KB
/
Bot.cs
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace cSharpbot
{
class Bot
{
private char letter = ' ';
private int x;
private int y;
private String[][] map;
public Bot(char letter)
{
this.letter = letter;
}
public void updateMap(string mapa)
{
string[] rows = Regex.Split(mapa, "\n");
map = new String[rows.Length][];
for (int i = 0; i < rows.Length; i++)
{
map[i] = Regex.Split(rows[i], ",");
}
int pos = mapa.IndexOf(this.letter) / 2;
this.y = pos / rows.Length;
this.x = pos % rows.Length;
}
public String move()
{
Random random = new Random();
int mov = random.Next(0, 7);
Console.WriteLine("mov " + mov);
switch (mov)
{
case 0:
return "N";
case 1:
return "E";
case 2:
return "S";
case 3:
return "O";
case 4:
return "BN";
case 5:
return "BE";
case 6:
return "BS";
case 7:
return "BO";
}
return "P";
}
}
}