예제 #1
0
파일: MapCSP.cs 프로젝트: langeds/aima
//		private MapCSP(ArrayList variables, Constraint constraints): this(variables, constraints)
//		{
//			//super(variables, constraints);
//			
//		}

		public static CSP getMap() 
		{
			ArrayList variables = new ArrayList();
			variables.Add(WA);
			variables.Add(NT);
			variables.Add(SA);
			variables.Add(Q);
			variables.Add(NSW);
			variables.Add(V);
			variables.Add(T);

			ArrayList colors = new ArrayList();
				colors.Add(RED);
			colors.Add(BLUE);
			colors.Add(GREEN);

			Domain domains = new Domain(variables);
			for (int i = 0; i < variables.Count; i++) 
			{
				string variable = variables[i].ToString();
				domains.addToDomain(variable, colors);
			}

			Hashtable neighbors = new Hashtable();
			addToNeighbors(neighbors, T);
			addToNeighbors(neighbors, WA, NT, SA);
			addToNeighbors(neighbors, NT, WA, SA, Q);
			addToNeighbors(neighbors, SA, WA, NT, Q, NSW, V);
			addToNeighbors(neighbors, Q, NT, SA, NSW);
			addToNeighbors(neighbors, NSW, SA, Q, V);
			addToNeighbors(neighbors, V, SA, NSW);
			Constraint mapConstraints = new MapColoringConstraint(neighbors);

			return new CSP(variables, mapConstraints, domains);
		}
예제 #2
0
//		private MapCSP(ArrayList variables, Constraint constraints): this(variables, constraints)
//		{
//			//super(variables, constraints);
//
//		}

        public static CSP getMap()
        {
            ArrayList variables = new ArrayList();

            variables.Add(WA);
            variables.Add(NT);
            variables.Add(SA);
            variables.Add(Q);
            variables.Add(NSW);
            variables.Add(V);
            variables.Add(T);

            ArrayList colors = new ArrayList();

            colors.Add(RED);
            colors.Add(BLUE);
            colors.Add(GREEN);

            Domain domains = new Domain(variables);

            for (int i = 0; i < variables.Count; i++)
            {
                string variable = variables[i].ToString();
                domains.addToDomain(variable, colors);
            }

            Hashtable neighbors = new Hashtable();

            addToNeighbors(neighbors, T);
            addToNeighbors(neighbors, WA, NT, SA);
            addToNeighbors(neighbors, NT, WA, SA, Q);
            addToNeighbors(neighbors, SA, WA, NT, Q, NSW, V);
            addToNeighbors(neighbors, Q, NT, SA, NSW);
            addToNeighbors(neighbors, NSW, SA, Q, V);
            addToNeighbors(neighbors, V, SA, NSW);
            Constraint mapConstraints = new MapColoringConstraint(neighbors);

            return(new CSP(variables, mapConstraints, domains));
        }