/// <summary> /// Locates a bank booth in the Seers' Village bank /// </summary> /// <param name="bankBooth"></param> /// <returns>true if a bank booth is found</returns> internal bool LocateBankBoothSeersVillage(out Blob bankBooth) { bankBooth = null; List <Blob> possibleBankBooths = Vision.LocateObjects(RGBHSBRangeFactory.BankBoothSeersVillage(), MinBankBoothSize, MaxBankBoothSize); if (possibleBankBooths == null) { return(false); } List <Blob> bankBooths = new List <Blob>(); foreach (Blob booth in possibleBankBooths) { double widthToHeight = booth.Width / (double)booth.Height; if (Numerical.WithinBounds(widthToHeight, 2.3, 3.2)) { bankBooths.Add(booth); } } if (bankBooths.Count != 9) { return(false); } bankBooths.Sort(new BlobHorizontalComparer()); bankBooths.RemoveAt(5); //remove closed bank booths bankBooths.RemoveAt(4); bankBooths.RemoveAt(2); bankBooth = Blob.ClosestBlob(Screen.Center, bankBooths); return(true); }
/// <summary> /// Gets the start parameters specified by the user in the startup form /// </summary> /// <returns></returns> private void CollectStartParams() { CollectGeneralSettings(); if (Numerical.WithinBounds(RotationBotSelection, 0, RunParams.RotationParams.Count - 1)) { RunParams.RotationParams[RotationBotSelection] = CollectRotationSettings(); } if (Numerical.WithinBounds(PhasmatysBotSelection, 0, RunParams.PhasmatysParams.Count - 1)) { RunParams.PhasmatysParams[PhasmatysBotSelection] = CollectPhasmatysSettings(); } }
/// <summary> /// Logs in to for the selected bot on a rotation tab /// </summary> /// <param name="rotationList">rotation tab to use</param> /// <param name="botSelection">selected bot on the rotation tab</param> /// <param name="startButton">reference to the start button used for this tab</param> private void RotationLogIn(RunParamsList rotationList, int botSelection, Button startButton) { CollectStartParams(); if (rotationList == null || !Numerical.WithinBounds(botSelection, 0, RunParams.PhasmatysParams.Count - 1)) { return; } rotationList[botSelection].TaskComplete = new BotResponse(BotDone); RunningBot = new LogInToGame(rotationList[botSelection]); RunningBot.Start(); SetActiveState(startButton); UpdateTimer.Enabled = true; }
/// <summary> /// Finds the closest bank booth in the Port Phasmatys bank /// </summary> /// <returns>True if the bank booths are found</returns> internal bool LocateBankBoothPhasmatys(out Blob bankBooth) { bankBooth = null; const int numberOfBankBooths = 6; const double minBoothWidthToHeightRatio = 2.3667; //ex 2.6667 const double maxBoothWidthToHeightRatio = 3.1333; //ex 2.8333 int left = Screen.Center.X - Screen.ArtifactLength(0.5); int right = Screen.Center.X + Screen.ArtifactLength(0.3); int top = Screen.Center.Y - Screen.ArtifactLength(0.15); int bottom = Screen.Center.Y + Screen.ArtifactLength(0.2); Screen.ReadWindow(); Point offset; bool[,] bankBooths = Vision.ColorFilterPiece(RGBHSBRangeFactory.BankBoothPhasmatys(), left, right, top, bottom, out offset); List <Blob> boothBlobs = new List <Blob>(); List <Blob> possibleBoothBlobs = ImageProcessing.FindBlobs(bankBooths, false, MinBankBoothSize, MaxBankBoothSize); //list of blobs from biggest to smallest possibleBoothBlobs.Sort(new BlobProximityComparer(Screen.Center)); double widthToHeightRatio, rectangularity; //Remove blobs that aren't bank booths foreach (Blob possibleBooth in possibleBoothBlobs) { widthToHeightRatio = (possibleBooth.Width / (double)possibleBooth.Height); rectangularity = Geometry.Rectangularity(possibleBooth); if (Numerical.WithinBounds(widthToHeightRatio, minBoothWidthToHeightRatio, maxBoothWidthToHeightRatio) && rectangularity > 0.75) { boothBlobs.Add(possibleBooth); } } if (boothBlobs.Count != numberOfBankBooths) { return(false); //We either failed to locate all of the booths or identified something that was not actually a booth. } //Reduce the blob list to the bank booths boothBlobs.Sort(new BlobHorizontalComparer()); //sort from left to right boothBlobs.RemoveAt(3); //remove the unusable booths without tellers boothBlobs.RemoveAt(0); bankBooth = Blob.ClosestBlob(new Point(Screen.Center.X - left, Screen.Center.Y - top), boothBlobs); bankBooth.ShiftPixels(offset.X, offset.Y); return(true); }
/// <summary> /// Determines if the furnace floor blob from the minimap is appropriately size /// </summary> /// <param name="furnaceFloorSize">number of pixels in the furnace floor blob</param> /// <returns>true if size is within bounds</returns> protected bool FurnaceFloorSizeCheck(int furnaceFloorSize) { return(Numerical.WithinBounds(furnaceFloorSize, FurnaceFloorMinSize, FurnaceFloorMaxSize)); }
/// <summary> /// Determines if the bank floor blob from the minimap is apropriately size /// </summary> /// <param name="bankFloorSize">number of pixels in the bank floor blob</param> /// <returns>true if bank floor blob is within size bounds</returns> protected bool BankFloorSizeCheck(int bankFloorSize) { return(Numerical.WithinBounds(bankFloorSize, BankFloorMinSize, BankFloorMaxSize)); }
public void WithinBoundsTest(double test, double lowerBound, double upperBound, bool withinBounds) { Assert.AreEqual(Numerical.WithinBounds(test, lowerBound, upperBound), withinBounds); }