//static AutoItX3 _autoit = new AutoItX3(); static void Main(string[] args) { Console.WriteLine("Hello world!"); //Needle needle = new Needle("C:\\#GitHub\\TobiSharp\\TobiSharp\\_TestBilder\\02needleLeftTopRed.png"); //Needle needle = new Needle("C:\\#GitHub\\TobiSharp\\TobiSharp\\_TestBilder\\02needleRightBottomYellow.png"); //Needle needle = new Needle("C:\\#GitHub\\TobiSharp\\TobiSharp\\_TestBilder\\02needleOneOne.png"); //Needle needle = new Needle("C:\\#GitHub\\TobiSharp\\TobiSharp\\_TestBilder\\02needleFalse.png"); Needle needle = new Needle("C:\\#GitHub\\TobiSharp\\TobiSharp\\_TestBilder\\04needle40kF.png"); string cout = "Needle:"; cout += " a" + needle.StrongestPixel.A; cout += " r" + needle.StrongestPixel.R; cout += " g" + needle.StrongestPixel.G; cout += " b" + needle.StrongestPixel.B; cout += " x" + needle.StrongestPoint.X; cout += " y" + needle.StrongestPoint.Y; cout += " x" + needle.StrongestRearPoint.X; cout += " y" + needle.StrongestRearPoint.Y; cout += " w" + needle.Size.Width; cout += " h" + needle.Size.Height; cout += " l" + needle.Pixels.Length; Console.WriteLine(cout); Haystack haystack = new Haystack("C:\\#GitHub\\TobiSharp\\TobiSharp\\_TestBilder\\04haystackPexelF.png"); Point test = haystack.Locate(needle); Console.WriteLine("x" + test.X + " y" + test.Y); Console.ReadLine(); //_autoit.WinActivate("Untitled - Notepad2"); //_autoit.Send("Hello World"); }
private void HarvestHay(Haystack haystack) { GetComponent <Rigidbody>().velocity = Vector3.zero; GetComponent <Rigidbody>().angularVelocity = Vector3.zero; if (state != TractorState.HasHayAndPlayer) { if (timeHarvestHay >= haystack.timeHarvestRequired) { state = TractorState.HasHayAndPlayer; gameObject.GetComponent <PUN2_TractorSync>().callChangeState(3); timeHarvestHay = 0f; haystack.DecreaseHay(); gameObject.GetComponent <PUN2_TractorSync>().callChangeStats(timeMove, false, timeHarvestHay); gameObject.GetComponent <PUN2_TractorSync>().callStopHarvestHaySound(); } else { if (timeHarvestHay == 0) { gameObject.GetComponent <PUN2_TractorSync>().callPlayHarvestHaySoundContinuous(); } timeHarvestHay += Time.fixedDeltaTime; gameObject.GetComponent <PUN2_TractorSync>().callChangeStats(timeMove, true, timeHarvestHay); timeHarvestRequired = haystack.timeHarvestRequired; } } }
// Use this for initialization void Start() { Haystack hay = (Haystack)localScripts[0]; hayAmountLeft = hay.hayAmountLeft; hayAmountInitial = hay.hayAmountInitial; }
static void Main(string[] args) { Haystack haystack = new Haystack(); Utilities util = new Utilities(); IHaystackOrganizer hay_organizer = new Haystack(); var sorted_stack = hay_organizer.SortByColor(haystack); //foreach(var straw_piece in sorted_stack.Reds) //{ // Console.WriteLine("S:{0}", straw_piece.LengthInCm.ToString()); //} Console.ReadKey(); //HayStackOrganizer organizer = new HayStackOrganizer(); //var test_stack_result = hay_organizer.SortByColor(haystack); //var test_green_duplicates = test_stack_result.Greens.GroupBy(x => x).Where(x => x.Count() > 1).Select(x => x.Key); //var test_blue_duplicates = test_stack_result.Blues.GroupBy(x => x).Where(x => x.Count() > 1).Select(x => x.Key); //var test_red_duplicates = test_stack_result.Reds.GroupBy(x => x).Where(x => x.Count() > 1).Select(x => x.Key); //var test_gray_duplicates = test_stack_result.Grays.GroupBy(x => x).Where(x => x.Count() > 1).Select(x => x.Key); //Console.WriteLine("Blue count {0}", test_blue_duplicates.Count()); //Console.WriteLine("Red count {0}", test_red_duplicates.Count()); //Console.WriteLine("Green count {0}", test_green_duplicates.Count()); //Console.WriteLine("Gray count {0}", test_gray_duplicates.Count()); }
public void Correct_Pile_test() { Haystack haystack = new Haystack(); IHaystackOrganizer hay_organizer = new SortingTree(); SortByColorResult sorted_stack = hay_organizer.SortByColor(haystack); foreach (var x in sorted_stack.Blues) { int max_number = Math.Max(x.ColorBlue, Math.Max(x.ColorGreen, x.ColorRed)); Assert.AreEqual(x.ColorBlue, max_number, "Failed: Blue stack has color that does not belong"); } foreach (var x in sorted_stack.Greens) { int max_number = Math.Max(x.ColorBlue, Math.Max(x.ColorGreen, x.ColorRed)); Assert.AreEqual(x.ColorGreen, max_number, "Failed: Green stack has color that does not belong"); } foreach (var x in sorted_stack.Reds) { int max_number = Math.Max(x.ColorBlue, Math.Max(x.ColorGreen, x.ColorRed)); Assert.AreEqual(x.ColorRed, max_number, "Failed: Red stack has color that does not belong"); } foreach (var x in sorted_stack.Grays) { Assert.AreEqual(x.ColorBlue, x.ColorGreen, "Failed: Gray stack has straw that does not have equal green/blue/red values "); Assert.AreEqual(x.ColorBlue, x.ColorRed, "Failed: Gray stack has straw that does not have equal green/blue/red values "); } }
public void No_Repeates_test() { Haystack haystack = new Haystack(); IHaystackOrganizer hay_organizer = new SortingTree(); var sorted_stack = hay_organizer.SortByColor(haystack); var green_list = sorted_stack.Greens; var blue_list = sorted_stack.Blues; var red_list = sorted_stack.Reds; var gray_list = sorted_stack.Grays; // Fill the list if (green_list.Count != green_list.Distinct().Count()) { // Duplicates exist Assert.Fail("Fail: Green list does not increment from smallest straw length to largest strawa length"); } if (blue_list.Count != blue_list.Distinct().Count()) { // Duplicates exist Assert.Fail("Fail: Blue list does not increment from smallest straw length to largest strawa length"); } if (red_list.Count != red_list.Distinct().Count()) { // Duplicates exist Assert.Fail("Fail: Red list does not increment from smallest straw length to largest strawa length"); } if (gray_list.Count != gray_list.Distinct().Count()) { // Duplicates exist Assert.Fail("Fail: Gray list does not increment from smallest straw length to largest strawa length"); } }
private void InitializeGrid() { //TODO: Random rand = new Random(DateTime.Now.Millisecond + DateTime.Now.Second * 1337); //Determine our needle cordinates before hand. List <Coordinate> needleCordinates = new List <Coordinate>(); List <int> randomValues = new List <int>(); for (int i = 0; i < settings.numOfNeedles; i++) { Coordinate buffer = new Coordinate(rand.Next(1, 6), rand.Next(1, 9)); while (needleCordinates.Find(x => x.CompareTo(buffer) == 1) != null) { buffer = new Coordinate(rand.Next(1, 6), rand.Next(1, 9)); } needleCordinates.Add(buffer); if (settings.allowRepeats) { randomValues.Add(rand.Next(1, 10)); } } if (!settings.allowRepeats) { for (int i = 1; i < 10; i++) { randomValues.Add(i); } randomValues.Shuffle(); randomValues = randomValues.GetRange(0, settings.numOfNeedles); } for (int row = 1; row < 6; row++) { for (int col = 1; col < 9; col++) { //Initialize a new Cell object with the random value and the current row,col Cell cell = new Cell(randomValues.Count > 0 ? randomValues.Last() : 0); cell.coord = new Coordinate(row, col); if (needleCordinates.Find(x => x.CompareTo(cell.coord) == 1) != null) { cell.cellType = Cell.CellType.NEEDLE; if (randomValues.Count > 0) { randomValues.RemoveAt(randomValues.Count - 1); } } else { cell.cellType = Cell.CellType.HAYSTACK; } //Add the cell to its respected list. if (cell.cellType == Cell.CellType.HAYSTACK) { if (settings.difficulty == GameSettings.Difficulty.EASY || settings.difficulty == GameSettings.Difficulty.NORMAL) { continue; } Haystack.Add(cell); } else { Needles.Add(cell); } cell.num.Click += CellBtn_Click; cell.num.Tag = cell; //Add the Cell to the GameGrid UI. Grid.SetRow(cell, row - 1); Grid.SetColumn(cell, col - 1); this.grid.Children.Add(cell); } } //Sort the Needles Needles.Sort(delegate(Cell x, Cell y) { if (x == null && y == null) { return(0); } else if (x.value == y.value) { return(0); } else if (x == null) { return(-1); } else if (y == null) { return(1); } else { int retVal = x.value.CompareTo(y.value); if (retVal == 0) { return(x.coord.CompareTo(y.coord)); } else { return(retVal); } } }); }
public void Incrementing_Values_test() { Haystack haystack = new Haystack(); IHaystackOrganizer hay_organizer = new SortingTree(); var sorted_stack = hay_organizer.SortByColor(haystack); decimal less_than = 0; foreach (var x in sorted_stack.Greens) { if (less_than == 0) { less_than = x.LengthInCm; continue; } if (less_than >= x.LengthInCm) { Assert.Fail("Fail: Green list does not increment from smallest to largest straw length"); } if (x == sorted_stack.Greens.Last()) { less_than = 0; } } foreach (var x in sorted_stack.Blues) { if (less_than == 0) { less_than = x.LengthInCm; continue; } if (less_than >= x.LengthInCm) { Assert.Fail("Fail: Blue list does not increment from smallest straw length to largest strawa length"); } if (x == sorted_stack.Blues.Last()) { less_than = 0; } } foreach (var x in sorted_stack.Reds) { if (less_than == 0) { less_than = x.LengthInCm; continue; } if (less_than >= x.LengthInCm) { Assert.Fail("Fail: Red list does notincrement from smallest straw length to largest straw length"); } if (x == sorted_stack.Reds.Last()) { less_than = 0; } } foreach (var x in sorted_stack.Grays) { if (less_than == 0) { less_than = x.LengthInCm; continue; } if (less_than >= x.LengthInCm) { Assert.Fail("Fail: Gray list does not increment from smallest straw length to largest strawa length"); } if (x == sorted_stack.Grays.Last()) { less_than = 0; } } }