diff src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/traverser/DefaultEvaluator.cs @ 0:dec15de2c6ff

first commit
author Kazuma
date Tue, 21 Jun 2016 17:11:12 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/traverser/DefaultEvaluator.cs	Tue Jun 21 17:11:12 2016 +0900
@@ -0,0 +1,35 @@
+using UnityEngine;
+using System.Collections;
+
+public class DefaultEvaluator : Evaluator {
+	private NodePath path;
+
+	public DefaultEvaluator(NodePath _path) {
+		path = _path;
+	}
+
+	public Evaluation evaluate(TreeNode _current, int _pos){
+		Pair<int, NodePath> pop = path.pop ();
+		int head = pop.lefts ();
+
+		if (path.size () == 1) {
+			if (head == _pos) {
+				return new DefaultEvaluation (Result.GOAL, null);
+			}
+		}
+
+		DefaultEvaluator nextEvaluator;
+		Result result;
+		if (head == _pos) {
+			result = Result.ACCEPT;
+			nextEvaluator = new DefaultEvaluator (pop.rights ());
+		} else {
+			result = Result.CONTINUE;
+			nextEvaluator = null;
+		}
+
+		return new DefaultEvaluation (result, nextEvaluator);
+
+	}
+
+}