public void Join(string name) { int x = 0; int y = 0; string clientId = Context.ConnectionId; MazeGame game = this.mazeModel.JoinGame(name, clientId); string hostId = game.Host; MazeLib.Maze maze = game.Maze; string jsonedMaze = game.GameToString(); MazeParam partialMaze = new MazeParam(); partialMaze.Name = maze.Name; partialMaze.Rows = maze.Rows; partialMaze.Cols = maze.Cols; partialMaze.GoalPos = maze.GoalPos.ToString(); Converters.PositionConverter.ConvertPos(ref x, ref y, partialMaze.GoalPos); partialMaze.GoalPosRow = x; partialMaze.GoalPosCol = y; partialMaze.InitialPos = maze.InitialPos.ToString(); Converters.PositionConverter.ConvertPos(ref x, ref y, partialMaze.InitialPos); partialMaze.InitialPosRow = x; partialMaze.InitialPosCol = y; JObject jmaze = JObject.Parse(maze.ToJSON()); partialMaze.AsString = jmaze.GetValue("Maze").ToString(); Clients.Client(clientId).joinGame(partialMaze); Clients.Client(hostId).joinGame(partialMaze); }
public string Execute(string[] args, TcpClient client) { string name = args[1]; MazeLib.Maze m = model.JoinGame(name, client); return(m.ToJSON()); }
public static void CompareSolvers() { MazeGeneratorLib.DFSMazeGenerator generator = new MazeGeneratorLib.DFSMazeGenerator(); MazeLib.Maze maze = generator.Generate(10, 10); // Console.WriteLine(maze.ToString()); string a = maze.ToJSON(); Console.WriteLine(a); MazeAdapter adapter = new MazeAdapter(maze); SearchAlgorithmsLib.Solution <MazeLib.Position> solBFS = new SearchAlgorithmsLib.Solution <MazeLib.Position>(); SearchAlgorithmsLib.BFS <MazeLib.Position> bfs = new SearchAlgorithmsLib.BFS <MazeLib.Position>(); solBFS = bfs.search(adapter); SearchAlgorithmsLib.DFS <MazeLib.Position> dfs = new SearchAlgorithmsLib.DFS <MazeLib.Position>(); SearchAlgorithmsLib.Solution <MazeLib.Position> solDFS = new SearchAlgorithmsLib.Solution <MazeLib.Position>(); solDFS = dfs.search(adapter); Console.WriteLine("in BFS: {0}, in DFS: {1}", bfs.getNumberOfNodesEvaluated(), dfs.getNumberOfNodesEvaluated()); /* Console.WriteLine("Start: {0}, end: {1}", maze.InitialPos,maze.GoalPos); * Console.WriteLine("BFS solution: "); * solBFS.printSolution(); * Console.WriteLine("DFS solution: "); * solDFS.printSolution();*/ }