예제 #1
0
파일: Form1.cs 프로젝트: langeds/aima
		private void btnAStarMan_Click(object sender, System.EventArgs e)
		{
			this.textBox1.Text = "EightPuzzleDemo AStar Search (ManhattanHeursitic)-->" + System.Environment.NewLine;
			Problem problem = new Problem(random1,
				new EightPuzzleSuccessorFunction(),
				new EightPuzzleGoalTest(), new ManhattanHeuristicFunction());
			Search search = new AStarSearch(new GraphSearch());
			SearchAgent agent = new SearchAgent(problem, search);
			printActions(agent.getActions());
			printInstrumentation(agent.getInstrumentation());
		}
예제 #2
0
파일: Form1.cs 프로젝트: langeds/aima
		private void btnDoDemo_Click(object sender, System.EventArgs e)
		{
			this.textBox1.Text = (System.Environment.NewLine + "Romania Lugoj To Bucharest Puzzle -->");
        
			Q4State initialState = new Q4State("Lugoj");
			try 
			{
				Problem problem = new Problem(initialState, 
					new Q4SuccessorFunction(),
					new Q4GoalTest(),
					new Q4StepCostFunction(),
					new Q4HeuristicFunction());
            
				//Search search = new BreadthFirstSearch(new TreeSearch());
				//Search search = new DepthFirstSearch(new TreeSearch());
				//Search search = new DepthFirstSearch(new GraphSearch());
				//Search search = new DepthLimitedSearch(9);
				//Search search = new IterativeDeepeningSearch();
				Search search = new AStarSearch(new TreeSearch());
            
				ArrayList solution = search.search(problem);
            
				if (solution.Count == 0) 
				{ //empty list means failure
					this.textBox1.Text+=(System.Environment.NewLine + "No Solution" + System.Environment.NewLine);
				}
				for (int i = 0; i < solution.Count; i++)
				{
					this.textBox1.Text += solution[i].ToString() + System.Environment.NewLine;
				}
            
				//Printing metrics
				Metrics searchMetrics = search.getMetrics();
				IEnumerator iter = searchMetrics.keySet().GetEnumerator();
				while (iter.MoveNext()) 
				{
					String key = (String) iter.Current;
					String value = searchMetrics.get(key);
					this.textBox1.Text+=(System.Environment.NewLine + key +": " + value);
				}
            
			} 
			catch (Exception ex) 
			{
				this.textBox1.Text+=ex.Message;
			}
		}