This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static List<Move> getMoves(List<Point> matches, Point source) | |
{ | |
List<Move> moves = new List<Move>(); | |
foreach (Point pt in matches) | |
{ | |
if (pt.X < source.X) | |
{ | |
moves.Add(new Move(pt, Direction.DOWN)); | |
} | |
else if (pt.X > source.X) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace BejeweledBot | |
{ | |
public static class ArrExtension | |
{ | |
public static int TryGetValue(this int[,] arr, int row, int col) | |
{ | |
bool widthOK = false; | |
bool heightOK = false; | |
if (row >= 0 && row < arr.GetLength(0)) | |
widthOK = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static List<Point> getHorizontalMatch(int[,] arr, int row, int col, int distance, int targetValue) | |
{ | |
int height = arr.GetLength(0); | |
int width = arr.GetLength(1); | |
if (width != height) | |
throw new ArgumentException("Provided array was not square"); | |
List<Point> pointList = new List<Point>(); | |
for (int j = col - distance; j <= col + distance; j++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Drawing; | |
namespace BejeweledBot | |
{ | |
public enum Direction | |
{ | |
UP, | |
RIGHT, | |
DOWN, | |
LEFT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void SimplifyColors(Color[,] colors) | |
{ | |
CurrentColorList = new List<Color>(); | |
int width = colors.GetLength(0); | |
int height = colors.GetLength(1); | |
int threshold = 15; | |
for(int row = 0; row < width; row ++) | |
for(int col = 0; col < height; col++) | |
{ | |
Color selectedColor = colors[row, col]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static class ScreenCap | |
{ | |
public static Bitmap Grab(Rectangle rect) | |
{ | |
Bitmap bmp = new Bitmap(rect.Width, rect.Height); | |
using (Graphics g = Graphics.FromImage(bmp)) | |
{ | |
g.CopyFromScreen(rect.X, | |
rect.Y, | |
0, 0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void setTilesColors(Bitmap bmp) | |
{ | |
int offset = TileWidth / 3; | |
for (int row = 0; row < boardRows; row++) | |
for(int col = 0; col < boardColumns; col++) | |
{ | |
int x = corner.X + row * TileWidth + offset; | |
int y = corner.Y + col * TileWidth + offset; | |
Rectangle cloneRect = new Rectangle(x, y, TileWidth - 2 * offset, TileWidth - 2 * offset); | |
PixelFormat format = bmp.PixelFormat; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Drawing; | |
using System.Windows.Forms; | |
namespace BejeweledBot | |
{ | |
class OverlayForm : Form | |
{ | |
private int X { get; set; } | |
private int Y { get; set; } | |
private bool isDragged = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Windows.Forms; | |
namespace testAdvanced | |
{ | |
class Program | |
{ | |
static void Main(string[] args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import time | |
caseCounter = 0 | |
randomInt = random.randint(0,100) | |
randomNormalized = random.random() | |
caseLessThenHalf = (randomNormalized < 0.5) | |
caseEven = ((randomInt % 2) == 0) | |
caseMoreThanTen = (randomInt > 10) |