public List <List <SWIPrologServiceLibrary.SolutionVariable> > GetSolutionVariables(string query) { PlEngine.PlThreadAttachEngine(); var outerList = new List <List <SolutionVariable> >(); using (PlQuery q = new PlQuery(query)) { foreach (PlQueryVariables plQueryVariable in q.SolutionVariables) { var innerList = new List <SolutionVariable>(); foreach (string variableName in q.VariableNames) { innerList.Add(new SolutionVariable() { Variable = variableName, Value = plQueryVariable[variableName].ToString() }); } outerList.Add(innerList); } } return(outerList); }
/// <summary> /// Make the computer move on the board /// </summary> public void PlayComputer() { PlEngine.PlThreadAttachEngine(); string board = StringBoard(mBoard); string query = string.Format(@"alphabeta({0}/{1}, -100, 100, NewBoard, Temp, {2})", mComputerSign, board, mDifficulty); using (PlQuery q = new PlQuery(query)) { PlTerm newBoard = q.SolutionVariables.First()["NewBoard"]; string result = newBoard[0].ToString(); string next = result.Substring(0, 1); string b = result.Substring(2); mBoard = BoardString(b); } PlEngine.PlThreadDestroyEngine(); }
public bool ExecuteClause(string clause) { PlEngine.PlThreadAttachEngine(); return(PlQuery.PlCall(clause)); }
public bool Assert(string clause) { PlEngine.PlThreadAttachEngine(); return(PlQuery.PlCall("assert(" + clause + ")")); }