public void simulate(short[,] a_CopsMove, short[,] a_ThiefMove) { for (int a = 0; a < kClock; ++a) { if (m_32CurrentIteration < m_32MaxNumberOfIterations && m_bIfGameOver == false) { if (m_bIfGameOver == false) { for (int i = 0; i < m_listOfWalls.Count; ++i) { m_listOfWalls[i].Move(); for (int j = 0; j < m_16SizeOfWall; ++j) { boardPositions.WallsPos[m_32CurrentIteration % kClock, i, j, 0] = m_listOfWalls[i].m_16WallPosition[j, 0]; boardPositions.WallsPos[m_32CurrentIteration % kClock, i, j, 1] = m_listOfWalls[i].m_16WallPosition[j, 1]; } } for (int i = 0; i < m_listOfGates.Count; ++i) { m_listOfGates[i].Move(); for (int j = 0; j < m_16SizeOfGate; ++j) { boardPositions.GatesPos[m_32CurrentIteration % kClock, i, j, 0] = m_listOfGates[i].m_16GatePosition[j, 0]; boardPositions.GatesPos[m_32CurrentIteration % kClock, i, j, 1] = m_listOfGates[i].m_16GatePosition[j, 1]; } } for (int i = 0; i < m_listOfCops.Count; ++i) { m_listOfCops[i].Move(a_CopsMove[a, i]); boardPositions.CopsPos[m_32CurrentIteration % kClock, i, 0] = m_listOfCops[i].m_16CopPosition[0]; boardPositions.CopsPos[m_32CurrentIteration % kClock, i, 1] = m_listOfCops[i].m_16CopPosition[1]; } m_Thief.Move(a_ThiefMove[a, 0]); boardPositions.ThiefPos[m_32CurrentIteration % kClock, 0] = m_Thief.m_16ThiefPosition[0]; boardPositions.ThiefPos[m_32CurrentIteration % kClock, 1] = m_Thief.m_16ThiefPosition[1]; } for (int i = 0; i < m_listOfGates.Count; ++i) { for (int j = 0; j < m_listOfGates[i].m_16GatePosition.GetLength(0); ++j) { if (m_Thief.m_16ThiefPosition[0] == m_listOfGates[i].m_16GatePosition[j, 0] && m_Thief.m_16ThiefPosition[1] == m_listOfGates[i].m_16GatePosition[j, 1]) { m_bIfGameOver = true; m_32ThiefPayment = 2 * m_32MaxNumberOfIterations - m_32CurrentIteration - 1; m_32CopsPayment = -m_32ThiefPayment; winner = "Thief"; } } } for (int i = 0; i < m_listOfCops.Count; ++i) { if ((m_listOfCops[i].m_16CopPosition[0] + 1 == m_Thief.m_16ThiefPosition[0] && m_listOfCops[i].m_16CopPosition[1] == m_Thief.m_16ThiefPosition[1]) || (m_listOfCops[i].m_16CopPosition[0] - 1 == m_Thief.m_16ThiefPosition[0] && m_listOfCops[i].m_16CopPosition[1] == m_Thief.m_16ThiefPosition[1]) || (m_listOfCops[i].m_16CopPosition[1] + 1 == m_Thief.m_16ThiefPosition[1] && m_listOfCops[i].m_16CopPosition[0] == m_Thief.m_16ThiefPosition[0]) || (m_listOfCops[i].m_16CopPosition[1] - 1 == m_Thief.m_16ThiefPosition[1] && m_listOfCops[i].m_16CopPosition[0] == m_Thief.m_16ThiefPosition[0]) || (m_listOfCops[i].m_16CopPosition[1] == m_Thief.m_16ThiefPosition[1] && m_listOfCops[i].m_16CopPosition[0] == m_Thief.m_16ThiefPosition[0])) { m_bIfGameOver = true; winner = "COP"; m_32ThiefPayment = m_32CurrentIteration; m_32CopsPayment = -m_32ThiefPayment; } } mapBoard(); Console.Clear(); PrintBoard(); System.Threading.Thread.Sleep(200); ++m_32CurrentIteration; } else if (m_32CurrentIteration >= m_32MaxNumberOfIterations && m_bIfGameOver == true) { m_32ThiefPayment = m_32MaxNumberOfIterations; m_32CopsPayment = -m_32ThiefPayment; m_bIfGameOver = true; winner = "Thief"; } else if (m_32CurrentIteration >= m_32MaxNumberOfIterations && m_bIfGameOver == false) { m_32ThiefPayment = m_32MaxNumberOfIterations; m_32CopsPayment = -m_32ThiefPayment; m_bIfGameOver = true; winner = "Thief"; } } }
public void simulate(short[] a_CopsMove, short a_ThiefMove) { if (m_32CurrentIteration < m_32MaxNumberOfIterations) { if (m_bIfGameOver == false) { for (int i = 0; i < m_listOfWalls.Count; ++i) { m_listOfWalls[i].Move(); for (int j = 0; j < m_16SizeOfWall; ++j) { boardPositions.WallsPos[m_32CurrentIteration % kClock, i, j, 0] = m_listOfWalls[i].m_16WallPosition[j, 0]; boardPositions.WallsPos[m_32CurrentIteration % kClock, i, j, 1] = m_listOfWalls[i].m_16WallPosition[j, 1]; } } for (int i = 0; i < m_listOfGates.Count; ++i) { m_listOfGates[i].Move(); for (int j = 0; j < m_16SizeOfGate; ++j) { boardPositions.GatesPos[m_32CurrentIteration % kClock, i, j, 0] = m_listOfGates[i].m_16GatePosition[j, 0]; boardPositions.GatesPos[m_32CurrentIteration % kClock, i, j, 1] = m_listOfGates[i].m_16GatePosition[j, 1]; } } for (int i = 0; i < m_listOfCops.Count; ++i) { m_listOfCops[i].Move(a_CopsMove[i]); boardPositions.CopsPos[m_32CurrentIteration % kClock, i, 0] = m_listOfCops[i].m_16CopPosition[0]; boardPositions.CopsPos[m_32CurrentIteration % kClock, i, 1] = m_listOfCops[i].m_16CopPosition[1]; } m_Thief.Move(a_ThiefMove); boardPositions.ThiefPos[m_32CurrentIteration % kClock, 0] = m_Thief.m_16ThiefPosition[0]; boardPositions.ThiefPos[m_32CurrentIteration % kClock, 1] = m_Thief.m_16ThiefPosition[1]; } for (int i = 0; i < m_listOfGates.Count; ++i) { for (int j = 0; j < m_listOfGates[i].m_16GatePosition.GetLength(0); ++j) { if (m_Thief.m_16ThiefPosition[0] == m_listOfGates[i].m_16GatePosition[j, 0] && m_Thief.m_16ThiefPosition[1] == m_listOfGates[i].m_16GatePosition[j, 1]) { m_bIfGameOver = true; m_32ThiefPayment = 2 * m_32MaxNumberOfIterations - m_32CurrentIteration - 1; m_32CopsPayment = -m_32ThiefPayment; winner = "Thief"; } } } for (int i = 0; i < m_listOfCops.Count; ++i) { if ((m_listOfCops[i].m_16CopPosition[0] + 1 == m_Thief.m_16ThiefPosition[0] && m_listOfCops[i].m_16CopPosition[1] == m_Thief.m_16ThiefPosition[1]) || (m_listOfCops[i].m_16CopPosition[0] - 1 == m_Thief.m_16ThiefPosition[0] && m_listOfCops[i].m_16CopPosition[1] == m_Thief.m_16ThiefPosition[1]) || (m_listOfCops[i].m_16CopPosition[1] + 1 == m_Thief.m_16ThiefPosition[1] && m_listOfCops[i].m_16CopPosition[0] == m_Thief.m_16ThiefPosition[0]) || (m_listOfCops[i].m_16CopPosition[1] - 1 == m_Thief.m_16ThiefPosition[1] && m_listOfCops[i].m_16CopPosition[0] == m_Thief.m_16ThiefPosition[0]) || (m_listOfCops[i].m_16CopPosition[1] == m_Thief.m_16ThiefPosition[1] && m_listOfCops[i].m_16CopPosition[0] == m_Thief.m_16ThiefPosition[0])) { m_bIfGameOver = true; winner = "COP"; m_32ThiefPayment = m_32CurrentIteration; m_32CopsPayment = -m_32ThiefPayment; } } ++m_32CurrentIteration; } else { m_32ThiefPayment = m_32MaxNumberOfIterations; m_32CopsPayment = -m_32ThiefPayment; m_bIfGameOver = true; winner = "Thief"; } }