-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExploration.cs
More file actions
92 lines (73 loc) · 2.62 KB
/
Exploration.cs
File metadata and controls
92 lines (73 loc) · 2.62 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
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System.Collections;
public abstract class Exploration {
protected int numberOfRows;
protected int numberOfColumns;
protected int numberOfActions = -1;
protected int millisecondsToWait = 2000;
protected int numberOfIterationsToLearn = 3;
public Exploration(int numberOfRows, int numberOfColumns){
this.numberOfRows = numberOfRows;
this.numberOfColumns = numberOfColumns;
}
public abstract ArrayList Explore(ArrayList cellsToCollect, ArrayList cellsToSuck, int [] cell);
//for a cell given, return its neighbours
public ArrayList Neighbour(int [] cell){
ArrayList neighbourList = new ArrayList();
if(cell[0]>0){
int [] neighbour = new int[2];
neighbour[0] = cell[0] - 1;
neighbour[1] = cell[1];
neighbourList.Add(neighbour);
}
if(cell[1]>0){
int [] neighbour = new int[2];
neighbour[0] = cell[0];
neighbour[1] = cell[1] - 1;
neighbourList.Add(neighbour);
}
if(cell[0] < numberOfRows - 1){
int [] neighbour = new int[2];
neighbour[0] = cell[0] + 1;
neighbour[1] = cell[1];
neighbourList.Add(neighbour);
}
if(cell[1] < numberOfColumns - 1){
int [] neighbour = new int[2];
neighbour[0] = cell[0];
neighbour[1] = cell[1] + 1;
neighbourList.Add(neighbour);
}
return neighbourList;
}
//return the last cell of an array
public int [] LastCell(ArrayList arrayList){
int index = 0;
int [] lastCell = new int [2];
foreach(int [] cell in arrayList){
if(index==arrayList.Count-1){
lastCell = cell;
//Console.WriteLine("last cell " + lastCell[0] + lastCell[1]);
}
index ++;
}
return lastCell;
}
public int GetNumberOfActions(){
return numberOfActions;
}
public void SetNumberOfActions(int numberOfActions){
this.numberOfActions = numberOfActions;
}
public int GetMillisecondsToWait(){
return millisecondsToWait;
}
public void SetMillisecondsToWait(int millisecondsToWait){
this.millisecondsToWait = millisecondsToWait;
}
public int GetNumberOfIterationsToLearn(){
return numberOfIterationsToLearn;
}
public void SetNumberOfIterationsToLearn(int numberOfIterationsToLearn){
this.numberOfIterationsToLearn = numberOfIterationsToLearn;
}
}