public override bool run() { // Arrange var b = new Board(); var trueProp = new Agents.PieceStatement(true, Pieces.Rook, Coord.fromString("A1")); var falseProp = new Agents.PieceStatement(true, Pieces.Rook, Coord.fromString("A2")); String[] results = { "TTTT", "TTTF", "TTFT", "TTFF", "TFTT", "TFTF", "TFFT", "TFFF", "FTTT", "FTTF", "FTFT", "FTFF", "FFTT", "FFTF", "FFFT", "FFFF" }; int successes = 0; // Act for (int x = 0; x < 16; x++) { string outcome = ""; var props = new List <Agents.TwoTermExpression>(); props.Add(new Agents.TwoTermExpression(trueProp.output() + (char)x + trueProp.output())); props.Add(new Agents.TwoTermExpression(trueProp.output() + (char)x + falseProp.output())); props.Add(new Agents.TwoTermExpression(falseProp.output() + (char)x + trueProp.output())); props.Add(new Agents.TwoTermExpression(falseProp.output() + (char)x + falseProp.output())); foreach (Agents.TwoTermExpression expression in props) { outcome += expression.resolve(b, Color.Black) ? "T" : "F"; } if (outcome == results[x]) { successes += 1; } } // Assert return(successes == 16); }
public override bool run() { // Arrange var b = new Board(false); b.clear(); b.set("black king e4"); var ML = new Agents.ML("placeholder", new Random()); ML.b = b; ML.playerColor = Color.Black; var p = new Agents.PieceStatement(true, Pieces.King, Coord.fromString("e5").flip()); var r = new Agents.Rule(p, 0, 0); ML.mind.rules.Add(r); bool foundMove = false; while (!foundMove) { var m = ML.chooseMove(b.availableMoves(Color.Black)); if (m.Item2.row == Coord.fromString("e5").row&& m.Item2.col == Coord.fromString("e5").col) { foundMove = true; } //b.display(); //Console.ReadKey(); } b.clear(); b.set("black king e5"); b.state = GameState.BlackVictory; ML.finish(); b.state = GameState.Active; b.clear(); b.set("black king e4"); // Act int count = 0; int target = 10; for (int x = 0; x < target; x++) { var m = ML.chooseMove(b.availableMoves(Color.Black)); if (m.Item2.row == Coord.fromString("e5").row&& m.Item2.col == Coord.fromString("e5").col) { count++; } } // Assert return(count == target); }
public override bool run() { // Arrange var b = new Board(); var and1 = new Agents.PieceStatement(true, Pieces.Rook, Coord.fromString("A1")); var and2 = new Agents.PieceStatement(true, Pieces.Knight, Coord.fromString("B1")); var proposition = new Agents.TwoTermExpression(and1.output() + (char)Agents.Operators.AND + and2.output()); var part2 = new Agents.PieceStatement(true, Pieces.Rook, Coord.fromString("B1")); var nextProposition = new Agents.TwoTermExpression(proposition.output() + (char)Agents.Operators.XOR + part2.output()); // Assert return(proposition.resolve(b, Color.Black) && nextProposition.resolve(b, Color.Black)); }