public void GetFinalStateTest() { string testingWord = "0101"; string[] alphabetLetters = new string[] { "0", "1" }; string[][] states = new string[][] { new string[]{ "1", "2"}, new string[]{ "2", "1"}, new string[]{ "2", "2" } }; Automaton automaton = new Automaton(alphabetLetters, states); int finalState = automaton.GetFinalState(testingWord); Assert.AreEqual(2, finalState); }
/// <summary> /// This function creates automaton instance from given position and counts number of errors. /// </summary> public static int GetFunctionValue(Position position) { Automaton foundAutomaton = new Automaton(position); int count = 0; foreach (string word in _trainingSet) { if (_secretAutomaton.GetFinalState(word) != foundAutomaton.GetFinalState(word)) count++; } return count; }
public void AutomatonConstructionFromPositionObjectTest() { // Arrange Position position = new Position(2, 3, 0) { OnePositions = new[,] { { 1, 2, 1 }, { 2, 2, 1 } } }; // Act Automaton automaton = new Automaton(position); // Assert Assert.AreEqual(automaton.GetFinalState("101"), 2); }
public void GetGraphTest() { string testingWord = "01212"; string autonatonName = "testowyAutomat"; string[] alphabetLetters = new string[] { "0", "1", "2" }; string[][] states = new string[][] { new string[] { "1", "0", "0" }, new string[] { "1", "1", "2" }, new string[] { "2", "2", "3" }, new string[] { "3", "3", "3"} }; Automaton automaton = new Automaton(alphabetLetters, states); int finalState = automaton.GetFinalState(testingWord); Assert.AreEqual(3, finalState); File.Create(autonatonName).Close(); AdjacencyGraph<int, TaggedEdge<int, string>> graph; automaton.GetGraph(autonatonName, out graph); File.Delete(autonatonName); }
/// <summary> /// This function counts number of errors for given automaton instance. /// </summary> public static int GetFunctionValueForAutomaton(Automaton automaton) { return _testSet.Count(word => _secretAutomaton.GetFinalState(word) != automaton.GetFinalState(word)); }