Exemplo n.º 1
0
 public void Init(short a_kClock = 5, short a_16NumOfCops = 5, short a_16NumOfWalls = 4, short a_16NumOfGates = 2, short a_16SizeOfWalls = 4, short a_16SizeOfGates = 2,
                  float a_fProbabilityOfWallMove      = 0.75f, float a_fProbabilityOfGateMove = 0.5f, float a_fProbabilityOfWallChangeDir = 0.05f,
                  float a_fProbabilityOfGateChangeDir = 0.01f)
 {
     kClock               = a_kClock;
     m_16SizeOfWall       = a_16SizeOfWalls;
     m_16SizeOfGate       = a_16SizeOfGates;
     m_32ThiefPayment     = 0;
     m_32CopsPayment      = 0;
     m_32CurrentIteration = 0;
     m_bIfGameOver        = false;
     generator            = new Random(1);
     m_cBoardMap          = new char[m_16NumOfRows, m_16NumOfColumns];
     firstBoard.Init(a_16NumOfCops, a_16NumOfWalls, a_16NumOfGates, a_16SizeOfWalls, a_16SizeOfGates);
     boardPositions.Init(kClock, a_16NumOfCops, a_16NumOfWalls, a_16NumOfGates, a_16SizeOfWalls, a_16SizeOfGates);
     m_listOfCops  = new List <Cop>();
     m_listOfGates = new List <Gate>();
     m_listOfWalls = new List <Wall>();
     for (int i = 0; i < m_16NumOfRows; ++i)
     {
         for (int j = 0; j < m_16NumOfColumns; ++j)
         {
             m_cBoardMap[i, j] = '0';
         }
     }
     m_Thief = new Thief(this, ref m_cBoardMap);
     firstBoard.ThiefPos[0] = m_Thief.m_16ThiefPosition[0];
     firstBoard.ThiefPos[0] = m_Thief.m_16ThiefPosition[1];
     for (int i = 0; i < a_16NumOfCops; ++i)
     {
         m_listOfCops.Add(new Cop(this, ref m_cBoardMap));
         firstBoard.CopsPos[i, 0] = m_listOfCops[i].m_16CopPosition[0];
         firstBoard.CopsPos[i, 1] = m_listOfCops[i].m_16CopPosition[1];
     }
     for (int i = 0; i < a_16NumOfWalls; ++i)
     {
         m_listOfWalls.Add(new Wall(this, ref m_cBoardMap, ref generator, Convert.ToBoolean(generator.Next(0, 2)),
                                    a_16NumOfWalls, a_fProbabilityOfWallMove, a_fProbabilityOfWallChangeDir));
         for (int j = 0; j < m_16SizeOfWall; ++j)
         {
             firstBoard.WallsPos[i, j, 0] = m_listOfWalls[i].m_16WallPosition[j, 0];
             firstBoard.WallsPos[i, j, 1] = m_listOfWalls[i].m_16WallPosition[j, 1];
         }
     }
     for (int i = 0; i < a_16NumOfGates; ++i)
     {
         m_listOfGates.Add(new Gate(this, ref m_cBoardMap, ref generator, a_16SizeOfGates, a_fProbabilityOfGateMove, a_fProbabilityOfGateChangeDir));
         for (int j = 0; j < m_16SizeOfGate; ++j)
         {
             firstBoard.GatesPos[i, j, 0] = m_listOfGates[i].m_16GatePosition[j, 0];
             firstBoard.GatesPos[i, j, 1] = m_listOfGates[i].m_16GatePosition[j, 1];
         }
     }
     m_Settings.Init(m_16NumOfRows, m_16NumOfColumns, a_16NumOfCops, a_16NumOfWalls, a_16NumOfGates, a_16SizeOfWalls, a_16SizeOfGates,
                     m_32MaxNumberOfIterations, 5, a_fProbabilityOfWallMove, a_fProbabilityOfWallChangeDir, a_fProbabilityOfGateMove, a_fProbabilityOfGateChangeDir);
 }