public static FloorTile getTileByIndex(FloorPlan fp, string index) { string[] outPoint1 = Regex.Split(index, "_"); return(fp.getTile( System.Convert.ToInt32(outPoint1[0]), System.Convert.ToInt32(outPoint1[1]))); }
public static FloorTile getTileByIndex(FloorPlan fp, string index) { string[] outPoint1 = Regex.Split(index, "_"); return fp.getTile( System.Convert.ToInt32(outPoint1[0]), System.Convert.ToInt32(outPoint1[1])); }
private void drawFloorPlan(FloorPlan fp) { for (int i = 0; i < fp.getXTileNum(); i++) { for (int j = 0; j < fp.getYTileNum(); j++) { drawTile(fp.getTile(i, j)); } } }
public void ResetWalkableNeighbors() { FloorTile tile1 = m_floorPlan.getTile(this.m_location.X - 1, this.m_location.Y); if ((tile1 != null) && (tile1.Iswalkable())) { m_neighbours.Add(tile1); } tile1 = m_floorPlan.getTile(this.m_location.X + 1, this.m_location.Y); if ((tile1 != null) && (tile1.Iswalkable())) { m_neighbours.Add(tile1); } tile1 = m_floorPlan.getTile(this.m_location.X, this.m_location.Y - 1); if ((tile1 != null) && (tile1.Iswalkable())) { m_neighbours.Add(tile1); } tile1 = m_floorPlan.getTile(this.m_location.X, this.m_location.Y + 1); if ((tile1 != null) && (tile1.Iswalkable())) { m_neighbours.Add(tile1); } }
public AdjacencyGraph <string, Edge <string> > buildGraph() { this.messages += "- Building Graph...\n"; // Add some vertices to the graph for (int i = 0; i < fp.getXTileNum(); i++) { for (int j = 0; j < fp.getYTileNum(); j++) { if (fp.getWalkableValue(i, j) == 0) { graph.AddVertex(fp.getTile(i, j).Position.X + "_" + fp.getTile(i, j).Position.Y); } if (fp.getTile(i, j).endPoint) { this.targetPoint = i + "_" + j; } } } this.messages += " There are " + graph.VertexCount + " vertices.\n"; edges = new List <Edge <string> >(); neighbors = new List <FloorTile>(); for (int i = 0; i < fp.getXTileNum(); i++) { for (int j = 0; j < fp.getYTileNum(); j++) { if (fp.getWalkableValue(i, j) == 0) { neighbors = fp.getTile(i, j).getNeighbours(); for (int k = 0; k < neighbors.Count; k++) { Edge <string> myedge = new Edge <string>( fp.getTile(i, j).Position.X + "_" + fp.getTile(i, j).Position.Y, neighbors[k].Position.X + "_" + neighbors[k].Position.Y); edges.Add(myedge); graph.AddEdge(myedge); edgeCost.Add(myedge, 1); } } } } this.messages += " There are " + graph.EdgeCount + " edges.\n"; return(graph); }
public void TestTargetTileWalkable() { FloorPlan image1 = new FloorPlan(new Bitmap("../../testImage.jpg"), 5); bool result = image1.setTargetTile(4, 4); FloorTile tile = image1.getTile(4, 4); bool t_res = tile.IsStart(); bool t_res2 = tile.IsTarget(); Assert.AreEqual(true, result); System.Diagnostics.Debug.WriteLine("Start:" + t_res); System.Diagnostics.Debug.WriteLine("Target:" + t_res2); }
public void TestGetTile() { FloorPlan image1 = new FloorPlan(new Bitmap("../../testImage.jpg"), 5); FloorTile tile = image1.getTile(10,12); System.Diagnostics.Debug.WriteLine(tile.Position.X); System.Diagnostics.Debug.WriteLine(tile.Position.Y); System.Diagnostics.Debug.WriteLine(tile.Iswalkable()); Assert.IsTrue((tile.ToString().Equals("1")), "Incorret Tile Returned!"); }
public void TestConnectBlockFive() { FloorPlan image1 = new FloorPlan(new Bitmap("../../testImage.jpg")); int width = image1.getXTileNum(); int height = image1.getYTileNum(); System.Diagnostics.Debug.WriteLine("Height " + height + " Width " + width); FloorTile tile = image1.getTile(2, 4); FloorTile n1,n2,n3,n4; System.Diagnostics.Debug.WriteLine(""); List<FloorTile> neighbour = tile.getNeighbours(); if (neighbour.Count > 3) { n1 = neighbour[0]; n2 = neighbour[1]; n3 = neighbour[2]; n4 = neighbour[3]; System.Diagnostics.Debug.WriteLine("1st \t" + n1.Position.X + "\t" + n1.Position.Y + "\t" + n1.Iswalkable()); System.Diagnostics.Debug.WriteLine("2nd \t" + n2.Position.X + "\t" + n2.Position.Y + "\t" + n2.Iswalkable()); System.Diagnostics.Debug.WriteLine("3rd \t" + n3.Position.X + "\t" + n3.Position.Y + "\t" + n3.Iswalkable()); System.Diagnostics.Debug.WriteLine("4th \t" + n4.Position.X + "\t" + n4.Position.Y + "\t" + n4.Iswalkable()); } else if (neighbour.Count == 3) { n1 = neighbour[0]; n2 = neighbour[1]; n3 = neighbour[2]; System.Diagnostics.Debug.WriteLine("1st \t" + n1.Position.X + "\t" + n1.Position.Y + "\t" + n1.Iswalkable()); System.Diagnostics.Debug.WriteLine("2nd \t" + n2.Position.X + "\t" + n2.Position.Y + "\t" + n2.Iswalkable()); System.Diagnostics.Debug.WriteLine("3rd \t" + n3.Position.X + "\t" + n3.Position.Y + "\t" + n3.Iswalkable()); } else if (neighbour.Count == 2) { n1 = neighbour[0]; n2 = neighbour[1]; System.Diagnostics.Debug.WriteLine("1st \t" + n1.Position.X + "\t" + n1.Position.Y + "\t" + n1.Iswalkable()); System.Diagnostics.Debug.WriteLine("2nd \t" + n2.Position.X + "\t" + n2.Position.Y + "\t" + n2.Iswalkable()); } else if (neighbour.Count == 1) { n1 = neighbour[0]; System.Diagnostics.Debug.WriteLine("1st \t" + n1.Position.X + "\t" + n1.Position.Y + "\t" + n1.Iswalkable()); } else System.Diagnostics.Debug.WriteLine("No Walkable Neighbours"); }
public void getTileByIndexTest() { Image myimage = new Bitmap("../../testImage.jpg"); FloorPlan floorPlan = new FloorPlan(myimage, 5); // TODO: Initialize to an appropriate value String index = "1_1"; // TODO: Initialize to an appropriate value FloorTile expected = floorPlan.getTile(1, 1); // TODO: Initialize to an appropriate value FloorTile actual; actual = QGPathFinder.getTileByIndex(floorPlan, index); Assert.AreEqual(expected, actual); }