Skip to content

Commit ce80039

Browse files
authored
Merge pull request #8 from bugged84/features/CSharpStandards
Applied C# standards to Node class
2 parents 146c2de + f4161df commit ce80039

28 files changed

+284
-213
lines changed

aima-csharp/aima-csharp.csproj

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
<Compile Include="environment\map\SimplifiedRoadMapOfPartOfRomania.cs" />
9999
<Compile Include="environment\map\StraightLineDistanceHeuristicFunction.cs" />
100100
<Compile Include="environment\wumpusworld\AgentPercept.cs" />
101+
<Compile Include="environment\wumpusworld\AgentPosition.cs" />
101102
<Compile Include="environment\wumpusworld\ManhattanHeuristicFunction.cs" />
102103
<Compile Include="environment\wumpusworld\Room.cs" />
103104
<Compile Include="logic\common\Lexer.cs" />
@@ -191,15 +192,13 @@
191192
<Compile Include="logic\fol\Unifier.cs" />
192193
<Compile Include="logic\fol\VariableCollector.cs" />
193194
<Compile Include="logic\propositional\agent\KBAgent.cs" />
195+
<Compile Include="logic\propositional\kb\KnowledgeBase.cs" />
194196
<Compile Include="logic\propositional\parsing\ast\AtomicSentence.cs" />
195197
<Compile Include="logic\propositional\parsing\ast\ComplexSentence.cs" />
196198
<Compile Include="logic\propositional\parsing\ast\Connective.cs" />
197199
<Compile Include="logic\propositional\parsing\ast\PropositionSymbol.cs" />
198200
<Compile Include="logic\propositional\parsing\ast\Sentence.cs" />
199201
<Compile Include="logic\propositional\parsing\PLVisitor.cs" />
200-
<Compile Include="obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs" />
201-
<Compile Include="obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs" />
202-
<Compile Include="obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs" />
203202
<Compile Include="Program.cs" />
204203
<Compile Include="Properties\AssemblyInfo.cs" />
205204
<Compile Include="search\framework\CutOffIndicatorAction.cs" />
@@ -258,19 +257,9 @@
258257
</ItemGroup>
259258
<ItemGroup>
260259
<None Include="App.config" />
261-
<None Include="bin\Debug\aima-csharp.exe.config" />
262-
<None Include="bin\Debug\aima-csharp.vshost.exe.config" />
263-
<None Include="obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache" />
264260
</ItemGroup>
265261
<ItemGroup>
266-
<Content Include="bin\Debug\aima-csharp.vshost.exe" />
267-
<Content Include="obj\Debug\aima-csharp.csproj.FileListAbsolute.txt" />
268-
</ItemGroup>
269-
<ItemGroup>
270-
<Folder Include="bin\Release\" />
271262
<Folder Include="environment\wumpusworld\action\" />
272-
<Folder Include="logic\propositional\kb\" />
273-
<Folder Include="obj\Debug\TempPE\" />
274263
</ItemGroup>
275264
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
276265
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
3+
namespace aima.core.environment.wumpusworld
4+
{
5+
internal class AgentPosition
6+
{
7+
internal int getX()
8+
{
9+
throw new NotImplementedException();
10+
}
11+
12+
internal int getY()
13+
{
14+
throw new NotImplementedException();
15+
}
16+
}
17+
}

aima-csharp/logic/fol/Unifier.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ namespace aima.core.logic.fol
5151
public class Unifier
5252
{
5353
private static SubstVisitor _substVisitor = new SubstVisitor();
54+
private VariableCollector _variableCollector;
5455

55-
public Unifier()
56+
public Unifier()
5657
{
5758

5859
}

aima-csharp/logic/fol/inference/FOLModelElimination.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ public bool isAnswer(Chain nearParent)
404404
.getSymbolicName()))
405405
{
406406
Dictionary<Variable, Term> answerBindings = new Dictionary<Variable, Term>();
407-
List<FOLNode> answerTerms = nearParent.getHead()
407+
List<Term> answerTerms = nearParent.getHead()
408408
.getAtomicSentence().getArgs();
409409
int idx = 0;
410410
foreach (Variable v in answerLiteralVariables)

aima-csharp/logic/fol/inference/FOLOTTERLikeTheoremProver.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using System.Text;
45
using aima.core.logic.fol.inference.otter;
56
using aima.core.logic.fol.inference.otter.defaultimpl;
@@ -294,7 +295,7 @@ private List<Clause> infer(Clause clause, List<Clause> usable)
294295
}
295296

296297
// * return the resulting clauses after applying filter
297-
return getClauseFilter().filter(resultingClauses);
298+
return getClauseFilter().filter(new HashSet<Clause>(resultingClauses)).ToList();
298299
}
299300

300301
// procedure PROCESS(clauses, sos)
@@ -647,7 +648,7 @@ public bool isAnswer(Clause aClause)
647648
.getSymbolicName()))
648649
{
649650
Dictionary<Variable, Term> answerBindings = new Dictionary<Variable, Term>();
650-
List<FOLNode> answerTerms = aClause.getPositiveLiterals()[
651+
List<Term> answerTerms = aClause.getPositiveLiterals()[
651652
0].getAtomicSentence().getArgs();
652653
int idx = 0;
653654
foreach (Variable v in answerLiteralVariables)

aima-csharp/logic/fol/inference/FOLTFMResolution.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public InferenceResult ask(FOLKnowledgeBase KB, Sentence alpha)
127127
{
128128
if (null != tracer)
129129
{
130-
tracer.stepStartWhile(clauses, clauses.Count, newClauses
130+
tracer.stepStartWhile(new HashSet<Clause>(clauses), clauses.Count, newClauses
131131
.Count);
132132
}
133133

@@ -167,7 +167,7 @@ public InferenceResult ask(FOLKnowledgeBase KB, Sentence alpha)
167167

168168
if (null != tracer)
169169
{
170-
tracer.stepResolved(cI, cJ, toAdd);
170+
tracer.stepResolved(cI, cJ, new HashSet<Clause>(toAdd));
171171
}
172172

173173
ansHandler.checkForPossibleAnswers(toAdd);
@@ -209,7 +209,7 @@ public InferenceResult ask(FOLKnowledgeBase KB, Sentence alpha)
209209

210210
if (null != tracer)
211211
{
212-
tracer.stepFinished(clauses, ansHandler);
212+
tracer.stepFinished(new HashSet<Clause>(clauses), ansHandler);
213213
}
214214

215215
return ansHandler;
@@ -312,7 +312,7 @@ public void checkForPossibleAnswers(List<Clause> resolvents)
312312
.getSymbolicName()))
313313
{
314314
Dictionary<Variable, Term> answerBindings = new Dictionary<Variable, Term>();
315-
List<FOLNode> answerTerms = aClause.getPositiveLiterals()
315+
List<Term> answerTerms = aClause.getPositiveLiterals()
316316
[0].getAtomicSentence().getArgs();
317317
int idx = 0;
318318
foreach (Variable v in answerLiteralVariables)
@@ -321,7 +321,7 @@ public void checkForPossibleAnswers(List<Clause> resolvents)
321321
idx++;
322322
}
323323
bool addNewAnswer = true;
324-
foreach (Proof.Proof p in proofs)
324+
foreach (Proof p in proofs)
325325
{
326326
if (p.getAnswerBindings().Equals(answerBindings))
327327
{

aima-csharp/logic/fol/inference/proof/ProofStepClauseBinaryResolvent.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ public class ProofStepClauseBinaryResolvent : AbstractProofStep
2020
private Clause parent1, parent2 = null;
2121
private Dictionary<Variable, Term> subst = new Dictionary<Variable, Term>();
2222
private Dictionary<Variable, Term> renameSubst = new Dictionary<Variable, Term>();
23+
private Clause c;
24+
private Clause clause;
25+
private Clause othC;
26+
private Dictionary<Variable, Term> copyRBindings;
27+
private Dictionary<Variable, Term> renameSubstitituon;
2328

24-
public ProofStepClauseBinaryResolvent(Clause resolvent, Literal pl,
29+
public ProofStepClauseBinaryResolvent(Clause resolvent, Literal pl,
2530
Literal nl, Clause parent1, Clause parent2,
2631
Dictionary<Variable, Term> subst, Dictionary<Variable, Term> renameSubst)
2732
{
@@ -45,9 +50,18 @@ public ProofStepClauseBinaryResolvent(Clause resolvent, Literal pl,
4550
this.predecessors.Add(parent2.getProofStep());
4651
}
4752

48-
// START-ProofStep
53+
public ProofStepClauseBinaryResolvent(Clause c, Clause clause, Clause othC, Dictionary<Variable, Term> copyRBindings, Dictionary<Variable, Term> renameSubstitituon)
54+
{
55+
this.c = c;
56+
this.clause = clause;
57+
this.othC = othC;
58+
this.copyRBindings = copyRBindings;
59+
this.renameSubstitituon = renameSubstitituon;
60+
}
4961

50-
public override List<ProofStep> getPredecessorSteps()
62+
// START-ProofStep
63+
64+
public override List<ProofStep> getPredecessorSteps()
5165
{
5266
return new ReadOnlyCollection<ProofStep>(predecessors).ToList<ProofStep>();
5367
}

aima-csharp/logic/fol/kb/data/Clause.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ private void calculateFactors(List<Clause> parentFactors)
546546
_standardizeApart.standardizeApart(posLits, negLits,
547547
_saIndexical);
548548
Clause c = new Clause(posLits, negLits);
549-
c.setProofStep(new ProofStepClauseFactor(c, this));
549+
c.setProofStep(new ProofStepClauseFactor(c, this, null, null, null, null));
550550
if (isImmutable())
551551
{
552552
c.setImmutable();
@@ -672,7 +672,7 @@ private bool checkSubsumes(Clause othC,
672672
// Track the terms for this clause
673673
foreach (Literal tl in thisToTry[literalName])
674674
{
675-
List<FOLNode> folNodes = tl.getAtomicSentence().getArgs();
675+
List<Term> folNodes = tl.getAtomicSentence().getArgs();
676676
foreach (FOLNode n in folNodes)
677677
{
678678
thisTerms.Add((Term)n);
@@ -831,7 +831,7 @@ public int Compare(Literal o1, Literal o2)
831831
return rVal;
832832
}
833833

834-
private int compareArgs(List<FOLNode> args1, List<FOLNode> args2)
834+
private int compareArgs(List<Term> args1, List<Term> args2)
835835
{
836836
int rVal = 0;
837837

@@ -869,8 +869,8 @@ private int compareArgs(List<FOLNode> args1, List<FOLNode> args2)
869869
// remaining arguments
870870
if (0 == rVal)
871871
{
872-
rVal = compareArgs(args1.Skip(1).ToList<FOLNode>(), args2
873-
.Skip(1).ToList<FOLNode>());
872+
rVal = compareArgs(args1.Skip(1).ToList<Term>(), args2
873+
.Skip(1).ToList<Term>());
874874
}
875875
}
876876
else

aima-csharp/logic/fol/parsing/AbstractFOLVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public AbstractFOLVisitor()
1616

1717
protected Sentence recreate(Object ast)
1818
{
19-
return ((Sentence)ast).copy();
19+
return ((Sentence)ast).copySentence();
2020
}
2121

2222
public virtual Object visitVariable(Variable variable, Object arg)

aima-csharp/logic/fol/parsing/FOLVisitor.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ namespace aima.core.logic.fol.parsing
1010
*/
1111
public interface FOLVisitor
1212
{
13-
public Object visitPredicate(Predicate p, Object arg);
13+
Object visitPredicate(Predicate p, Object arg);
1414

15-
public Object visitTermEquality(TermEquality equality, Object arg);
15+
Object visitTermEquality(TermEquality equality, Object arg);
1616

17-
public Object visitVariable(Variable variable, Object arg);
17+
Object visitVariable(Variable variable, Object arg);
1818

19-
public Object visitConstant(Constant constant, Object arg);
19+
Object visitConstant(Constant constant, Object arg);
2020

21-
public Object visitFunction(Function function, Object arg);
21+
Object visitFunction(Function function, Object arg);
2222

23-
public Object visitNotSentence(NotSentence sentence, Object arg);
23+
Object visitNotSentence(NotSentence sentence, Object arg);
2424

25-
public Object visitConnectedSentence(ConnectedSentence sentence, Object arg);
25+
Object visitConnectedSentence(ConnectedSentence sentence, Object arg);
2626

27-
public Object visitQuantifiedSentence(QuantifiedSentence sentence,
27+
Object visitQuantifiedSentence(QuantifiedSentence sentence,
2828
Object arg);
2929
}
3030
}

0 commit comments

Comments
 (0)