public void GoodMap() { var map = new HuntTheWumpus.Map(); bool[] b = new bool[30]; b[0] = true; Queue <int> q = new Queue <int>(); q.Enqueue(0); int step = 0; while (q.Count > 0) { int top = q.Dequeue(); int cnt = 0; ++step; for (int i = 0; i < map.graph[i].Count; ++i) { if (map.isActive[top][i]) { ++cnt; if (!b[map.graph[top][i]]) { b[map.graph[top][i]] = true; q.Enqueue(map.graph[top][i]); } } } Assert.True(cnt <= 3, "Degree > 3"); } Assert.True(step == 30, "Graph isn't connected"); }
public void MapTest() { var map = new HuntTheWumpus.Map(); int mem = map.Wumpus; map.WumpusGoAway(); Assert.False(mem == map.Wumpus, "Wumpus come back"); map.WumpusGoAway(1); map.WumpusGoAway(4); for (int i = 0; i < 6; ++i) { map.PushArrow(i); } for (int i = 0; i < 6; ++i) { map.Move(i); } map.Respaw(); Assert.True(map.danger == Danger.Empty, "Don't update map.danger"); for (int i = 0; i < 10; ++i) { var bat = map.GetBat(); var pit = map.GetPit(); Assert.True(bat != pit, "Bat in pit"); } }
public void DrawTest() { var view = new HuntTheWumpus.View(1024, 768); view.Clear(); view.Clear(System.Drawing.Color.Aqua); view.Created(); view.Graphics.FillRectangle(Brushes.Aqua, 0, 0, 10, 10); view.DrawMainMenu(); var map = new HuntTheWumpus.Map(); view.DrawPickCave(map.graph, map.isActive, 0, 1, "112"); view.MainForm.DrawAll(); }