public string Execute(string[] args, TcpClient client) { string name = args[1]; MazeLib.Maze m = model.JoinGame(name, client); return(m.ToJSON()); }
public GameMaze(MazeLib.Maze maze, TcpClient host, int maxPlayers) { this.maze = maze; this.host = host; this.maxPlayers = maxPlayers; this.currentPlayers = 1; }
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); }
/// <summary> /// Executes the specified arguments. /// </summary> /// <param name="args">The arguments.</param> /// <param name="client">The client.</param> /// <param name="closeConnection">The close connection.</param> /// <param name="keepOpen">The keep open.</param> /// <returns></returns> public string Execute(string[] args, TcpClient client, string closeConnection, string keepOpen) { string name = args[0]; int rows = int.Parse(args[1]); int cols = int.Parse(args[2]); MazeLib.Maze maze = this.model.GetMaze(name, rows, cols); Game game = new Game(client, maze); model.AddStartGame(game, name); //Thread.Sleep(200); model.StartAndPlayingMutexRealese(); return(keepOpen); }
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();*/ }
public ISearchable <T> CreateMaze(string name, int rows, int cols) { MazeLib.Maze maze = this.generator.Generate(rows, cols); maze.Name = name; return((ISearchable <T>) new MazeAdapter(maze)); }
/// <summary> /// Initializes a new instance of the <see cref="MazeGame"/> class. /// </summary> /// <param name="maze">The maze.</param> /// <param name="host">The host.</param> public MazeGame(MazeLib.Maze maze, string hostId) { this.maze = maze; this.host = hostId; this.activePlayers = 1; }
/// <summary> /// Initializes a new instance of the <see cref="MazeAdapter"/> class. /// </summary> /// <param name="maze">The maze.</param> public MazeAdapter(MazeLib.Maze maze) { this.maze = maze; }