public Environment(string mapFileName)
{
string[] lines;
using (TextReader reader = new StreamReader(mapFileName))
{
lines = reader.ReadToEnd().Replace("\r", "").Split('\n');
}
string[] vals = lines[1].Split(' ');
mazeSize_ = int.Parse(vals[0]);
if (mazeSize_ < 1)
throw new Exception("Maze size < 1");
agentPosX_ = int.Parse(vals[1]);
agentPosY_ = int.Parse(vals[2]);
dirtyProb_ = double.Parse(vals[3], System.Globalization.CultureInfo.InvariantCulture);
randomSeed_ = int.Parse(vals[4]);
maze_ = new List<List<int>>(mazeSize_);
for (int i = 0; i < mazeSize_; ++i)
{
maze_.Add(new List<int>(mazeSize_));
vals = lines[i + 2].Split(' ');
for (int j = 0; j < mazeSize_; ++j)
{
if (vals[j] == MAP_ROAD)
maze_[i].Add(0);
else
if (vals[j] == MAP_OBSTACLE)
maze_[i].Add(OBSTACLE);
else
throw new Exception("Wrong map description!");
}
}
bump_ = false;
preAction_ = ActionType.actIDLE;
cleanedDirty_ = 0;
newDirty_ = 0;
}