public void GenerateEmptyCheckerTest() { var generateChecker = new GenerateChecker(); var checker = generateChecker.GenerateEmptyChecker(); foreach (var key in checker.Checks.Keys) { var situationStr = $"Up: {checker.Checks[key][0]} Right:{checker.Checks[key][1]} Button:{checker.Checks[key][2]} Left: {checker.Checks[key][3]} Center:{checker.Checks[key][4]}"; Console.WriteLine($"Position: {key.Position[0]}:{key.Position[1]} Situation: {situationStr}"); } foreach (var key in checker.Checks.Keys) { if (key.Position[0] == 1) { Assert.IsTrue(checker.Checks[key][0] == 2); } else if (key.Position[0] == 10) { Assert.IsTrue(checker.Checks[key][2] == 2); } if (key.Position[1] == 1) { Assert.IsTrue(checker.Checks[key][3] == 2); } else if (key.Position[1] == 10) { Assert.IsTrue(checker.Checks[key][1] == 2); } } }
public List <CheckerObject> GetInitialCherkers() { var checkerMaker = new GenerateChecker(); var checker = checkerMaker.GenerateInitialChecker(); InitialChecker = checker.Checks.Keys.Select(checksKey => new CheckerObject { position = checksKey.Position.JoinStrings(string.Empty), situation = checker.Checks[checksKey].JoinStrings(string.Empty) }).ToList(); return(InitialChecker); }
public void MakeChangeAfterBeansTest() { var generateChecker = new GenerateChecker(); var checker = generateChecker.GenerateEmptyChecker(); var beanPosition = new List <int[]> { new[] { 1, 3 }, new [] { 1, 5 }, new [] { 1, 7 }, new [] { 1, 9 }, new [] { 2, 1 }, new [] { 2, 4 }, new [] { 2, 6 }, new [] { 2, 7 }, new [] { 2, 9 }, new [] { 3, 2 }, new [] { 3, 5 }, new [] { 3, 8 }, new [] { 3, 10 }, new [] { 4, 1 }, new [] { 4, 3 }, new [] { 4, 6 }, new [] { 4, 10 }, new [] { 5, 2 }, new [] { 5, 4 }, new [] { 5, 8 }, new [] { 5, 9 }, new [] { 6, 1 }, new [] { 6, 3 }, new [] { 6, 5 }, new [] { 6, 7 }, new [] { 6, 9 }, new [] { 7, 1 }, new [] { 7, 3 }, new [] { 7, 4 }, new [] { 7, 5 }, new [] { 7, 8 }, new [] { 7, 10 }, new [] { 8, 2 }, new [] { 8, 3 }, new [] { 8, 4 }, new [] { 8, 6 }, new [] { 8, 7 }, new [] { 8, 9 }, new [] { 8, 10 }, new [] { 9, 1 }, new [] { 9, 2 }, new [] { 9, 4 }, new [] { 9, 5 }, new [] { 9, 6 }, new [] { 9, 8 }, new [] { 9, 9 }, new [] { 10, 3 }, new [] { 10, 5 }, new [] { 10, 8 }, new [] { 10, 10 } }; //check out Pacman.xlsx Assert.IsTrue(beanPosition.Count == 50); generateChecker.MakeChangeAfterBeans(checker, beanPosition); foreach (var key in checker.Checks.Keys) { //var situationStr = $"Up: {checker.Checks[key][0]} Right:{checker.Checks[key][1]} Button:{checker.Checks[key][2]} Left: {checker.Checks[key][3]} Center:{checker.Checks[key][4]}"; var situationStr = $"{checker.Checks[key][0]}{checker.Checks[key][1]}{checker.Checks[key][2]}{checker.Checks[key][3]}{checker.Checks[key][4]}"; Console.WriteLine($"Position: {key.Position[0]}:{key.Position[1]} Situation: {situationStr}"); } var testposition = new CheckPosition { Position = new[] { 5, 6 } }; var testposition2 = new CheckPosition { Position = new[] { 7, 4 } }; var testposition3 = new CheckPosition { Position = new[] { 4, 4 } }; Assert.IsTrue(string.Join(",", checker.Checks[testposition]) == string.Join(",", new[] { 1, 0, 0, 0, 0 })); Assert.IsTrue(string.Join(",", checker.Checks[testposition2]) == string.Join(",", new[] { 0, 1, 1, 1, 1 })); Assert.IsTrue((string.Join(",", checker.Checks[testposition3]) == string.Join(",", new[] { 0, 0, 1, 1, 0 }))); }
public void StartMoveTest() { var strategyStr = "00000:3,00001:4,00002:0,00010:3,00011:4,00012:2,00020:1,00021:4,00022:0,00100:2,00101:4,00102:0,00110:2,00111:4,00112:0,00120:2,00121:4,00122:0,00200:0,00201:4,00202:0,00210:0,00211:4,00212:0,00220:0,00221:4,00222:1,01000:3,01001:4,01002:0,01010:0,01011:4,01012:0,01020:2,01021:0,01022:2,01100:1,01101:4,01102:1,01110:1,01111:1,01112:1,01120:1,01121:1,01122:4,01200:1,01201:4,01202:1,01210:3,01211:1,01212:0,01220:0,01221:1,01222:6,02000:3,02001:4,02002:4,02010:3,02011:4,02012:1,02020:1,02021:1,02022:1,02100:3,02101:4,02102:1,02110:6,02111:4,02112:1,02120:1,02121:2,02122:2,02200:0,02201:4,02202:2,02210:0,02211:4,02212:4,02220:2,02221:4,02222:2,10000:0,10001:4,10002:4,10010:0,10011:4,10012:2,10020:2,10021:4,10022:2,10100:2,10101:4,10102:0,10110:2,10111:2,10112:6,10120:2,10121:4,10122:6,10200:1,10201:4,10202:0,10210:6,10211:4,10212:2,10220:6,10221:3,10222:0,11000:3,11001:4,11002:2,11010:3,11011:3,11012:3,11020:0,11021:4,11022:3,11100:3,11101:3,11102:3,11110:3,11111:3,11112:3,11120:1,11121:4,11122:3,11200:3,11201:3,11202:0,11210:3,11211:3,11212:3,11220:3,11221:4,11222:4,12000:0,12001:4,12002:4,12010:3,12011:4,12012:4,12020:0,12021:4,12022:0,12100:3,12101:4,12102:4,12110:4,12111:4,12112:0,12120:4,12121:4,12122:4,12200:6,12201:4,12202:4,12210:6,12211:4,12212:0,12220:6,12221:4,12222:0,20000:3,20001:4,20002:4,20010:3,20011:4,20012:4,20020:1,20021:4,20022:6,20100:2,20101:4,20102:5,20110:5,20111:5,20112:5,20120:2,20121:5,20122:1,20200:6,20201:4,20202:3,20210:5,20211:4,20212:5,20220:5,20221:5,20222:5,21000:2,21001:4,21002:2,21010:5,21011:5,21012:5,21020:1,21021:5,21022:2,21100:5,21101:5,21102:5,21110:5,21111:4,21112:3,21120:5,21121:4,21122:2,21200:5,21201:6,21202:6,21210:6,21211:6,21212:6,21220:6,21221:6,21222:6,22000:2,22001:4,22002:6,22010:3,22011:4,22012:3,22020:6,22021:6,22022:2,22100:6,22101:6,22102:6,22110:6,22111:6,22112:6,22120:2,22121:6,22122:6,22200:6,22201:4,22202:3,22210:6,22211:6,22212:4,22220:6,22221:6,22222:6,"; var dicAction = new Dictionary <int, string> { { 0, "up" }, { 1, "right" }, { 2, "down" }, { 3, "left" }, { 4, "eat" }, { 5, "freeze" }, { 6, "random" } }; var pacman = new Pacman { Strategy = StringHelper.ConvertStringToStarategy(strategyStr), Points = new int[1] }; var generateChecker = new GenerateChecker(); var checker = generateChecker.GenerateEmptyChecker(); foreach (var line in pacman.Strategy.Lines) { Console.WriteLine($"Key: {line.Key} Value:{dicAction[line.Value]}"); } var beanPosition = new List <int[]> { new[] { 1, 3 }, new [] { 1, 5 }, new [] { 1, 7 }, new [] { 1, 9 }, new [] { 2, 1 }, new [] { 2, 4 }, new [] { 2, 6 }, new [] { 2, 7 }, new [] { 2, 9 }, new [] { 3, 2 }, new [] { 3, 5 }, new [] { 3, 8 }, new [] { 3, 10 }, new [] { 4, 1 }, new [] { 4, 3 }, new [] { 4, 6 }, new [] { 4, 10 }, new [] { 5, 2 }, new [] { 5, 4 }, new [] { 5, 8 }, new [] { 5, 9 }, new [] { 6, 1 }, new [] { 6, 3 }, new [] { 6, 5 }, new [] { 6, 7 }, new [] { 6, 9 }, new [] { 7, 1 }, new [] { 7, 3 }, new [] { 7, 4 }, new [] { 7, 5 }, new [] { 7, 8 }, new [] { 7, 10 }, new [] { 8, 2 }, new [] { 8, 3 }, new [] { 8, 4 }, new [] { 8, 6 }, new [] { 8, 7 }, new [] { 8, 9 }, new [] { 8, 10 }, new [] { 9, 1 }, new [] { 9, 2 }, new [] { 9, 4 }, new [] { 9, 5 }, new [] { 9, 6 }, new [] { 9, 8 }, new [] { 9, 9 }, new [] { 10, 3 }, new [] { 10, 5 }, new [] { 10, 8 }, new [] { 10, 10 } }; generateChecker.MakeChangeAfterBeans(checker, beanPosition); var startPosition = new CheckPosition { Position = new[] { 4, 4 } }; var runTheGame = new RunTheGame(new RandomProvider()); runTheGame.StartMove(ref pacman, startPosition, checker, 0); Assert.IsTrue(pacman.Points[0] == 130); }