public string gridToString(int playerNumber) { string saida = ""; for (int y = gridSizeY - 1; y >= 0; --y) { for (int x = 0; x < gridSizeX; ++x) { BinaryNode node = grid[x, y]; StateType nodeStateType = adjustAgentStateTypeForBinaryNode(node, playerNumber); if (gridViewType == GridViewType.GVT_Binary) { saida += StateTypeExtension.getIntBinaryString(nodeStateType) + " | "; } else if (gridViewType == GridViewType.GVT_Hybrid) { string hybridString = convertBinaryToHybridString(nodeStateType); saida += hybridString; } } saida += "\n"; } return(saida); }
private void AddVectorObsForGrid() { if (myGridViewType == GridViewType.GVT_Hybrid) { for (int y = grid.GetGridSizeY() - 1; y >= 0; --y) { for (int x = 0; x < grid.GetGridSizeX(); ++x) { BinaryNode node = grid.NodeFromPos(x, y); StateType nodeStateType = grid.adjustAgentStateTypeForBinaryNode(node, playerNumber); float[] temp = StateTypeExtension.convertStateTypeToHybrid(nodeStateType); AddVectorObs(temp); } } } else if (myGridViewType == GridViewType.GVT_Binary) { for (int y = grid.GetGridSizeY() - 1; y >= 0; --y) { for (int x = 0; x < grid.GetGridSizeX(); ++x) { BinaryNode node = grid.NodeFromPos(x, y); StateType nodeStateType = grid.adjustAgentStateTypeForBinaryNode(node, playerNumber); int cell = (int)nodeStateType; AddVectorObs(cell); } } } else if (myGridViewType == GridViewType.GVT_ICAART) { List <float> freeBreakableObstructedCells = new List <float>(); List <float> positionAgentCells = new List <float>(); List <float> positionEnemyCells = new List <float>(); List <float> dangerLevelOfPositionsCells = new List <float>(); for (int y = grid.GetGridSizeY() - 1; y >= 0; --y) { for (int x = 0; x < grid.GetGridSizeX(); ++x) { BinaryNode node = grid.NodeFromPos(x, y); StateType nodeStateType = grid.adjustAgentStateTypeForBinaryNode(node, playerNumber); //enviar grid que representa posições livres, com blocos ou com paredes freeBreakableObstructedCells.Add(node.getFreeBreakableObstructedCell()); //enviar grid que representa posição do agente int hasAgent = StateTypeExtension.stateTypeHasFlag(nodeStateType, StateType.ST_Agent) ? 1 : 0; positionAgentCells.Add(hasAgent); //enviar grid que representa posição dos inimigos hasAgent = StateTypeExtension.stateTypeHasFlag(nodeStateType, StateType.ST_EnemyAgent) ? 1 : 0; positionEnemyCells.Add(hasAgent); //enviar grid que representa áreas de perigo bool hasDanger = grid.NodeFromPos(x, y).getDangerPosition(); if (!hasDanger) { dangerLevelOfPositionsCells.Add(0.0f); } else { float dangerLevel = myBombManager.getDanger(x, y, this); dangerLevelOfPositionsCells.Add(dangerLevel); } } } AddVectorObs(freeBreakableObstructedCells); AddVectorObs(positionAgentCells); AddVectorObs(positionEnemyCells); AddVectorObs(dangerLevelOfPositionsCells); freeBreakableObstructedCells.Clear(); positionAgentCells.Clear(); positionEnemyCells.Clear(); dangerLevelOfPositionsCells.Clear(); } else if (myGridViewType == GridViewType.GVT_BinaryDecimal) { for (int y = grid.GetGridSizeY() - 1; y >= 0; --y) { for (int x = 0; x < grid.GetGridSizeX(); ++x) { BinaryNode node = grid.NodeFromPos(x, y); StateType nodeStateType = grid.adjustAgentStateTypeForBinaryNode(node, playerNumber); string cellString = StateTypeExtension.getIntBinaryString(nodeStateType); int cell = Convert.ToInt32(cellString); AddVectorObs(cell); } } } else if (myGridViewType == GridViewType.GVT_BinaryNormalized) { for (int y = grid.GetGridSizeY() - 1; y >= 0; --y) { for (int x = 0; x < grid.GetGridSizeX(); ++x) { BinaryNode node = grid.NodeFromPos(x, y); StateType nodeStateType = grid.adjustAgentStateTypeForBinaryNode(node, playerNumber); float cell = StateTypeExtension.normalizeBinaryFlag(nodeStateType); AddVectorObs(cell); } } } else if (myGridViewType == GridViewType.GVT_ZeroOrOneForeachStateType) { List <float> freeCells = new List <float>(); List <float> destructibleCells = new List <float>(); List <float> positionAgentCells = new List <float>(); List <float> positionEnemyCells = new List <float>(); List <float> bombCells = new List <float>(); List <float> dangerCells = new List <float>(); List <float> fireCells = new List <float>(); for (int y = grid.GetGridSizeY() - 1; y >= 0; --y) { for (int x = 0; x < grid.GetGridSizeX(); ++x) { BinaryNode node = grid.NodeFromPos(x, y); StateType nodeStateType = grid.adjustAgentStateTypeForBinaryNode(node, playerNumber); freeCells.Add(node.getFreeCell()); int hasThis = StateTypeExtension.stateTypeHasFlag(nodeStateType, StateType.ST_Block) ? 1 : 0; destructibleCells.Add(hasThis); hasThis = StateTypeExtension.stateTypeHasFlag(nodeStateType, StateType.ST_Agent) ? 1 : 0; positionAgentCells.Add(hasThis); hasThis = StateTypeExtension.stateTypeHasFlag(nodeStateType, StateType.ST_EnemyAgent) ? 1 : 0; positionEnemyCells.Add(hasThis); hasThis = StateTypeExtension.stateTypeHasFlag(nodeStateType, StateType.ST_Bomb) ? 1 : 0; bombCells.Add(hasThis); hasThis = StateTypeExtension.stateTypeHasFlag(nodeStateType, StateType.ST_Danger) ? 1 : 0; dangerCells.Add(hasThis); hasThis = StateTypeExtension.stateTypeHasFlag(nodeStateType, StateType.ST_Fire) ? 1 : 0; fireCells.Add(hasThis); } } AddVectorObs(freeCells); AddVectorObs(destructibleCells); AddVectorObs(positionAgentCells); AddVectorObs(positionEnemyCells); AddVectorObs(bombCells); AddVectorObs(dangerCells); AddVectorObs(fireCells); freeCells.Clear(); destructibleCells.Clear(); positionAgentCells.Clear(); positionEnemyCells.Clear(); bombCells.Clear(); dangerCells.Clear(); fireCells.Clear(); } }
public string getStringBinaryArray() { string s = StateTypeExtension.getIntBinaryString(binary); return(s); }