I am making a piece of software that reads a board of difference pieces and then puts them into an array for management. I am at the point where I have got a rectangle around the whole board and am researching what the quickest and most effective way to locate each piece and store it in an array would be. The way in which I find the pieces is through searching a region for a small BMP for each different piece. The whole board it 6x12 and it has 7 different types of pieces.
Method 1: Make a small rectangle for each piece position and then scan then scan them one by one - it would only be scanning a very small area, but would be doing it (6x12) 72 times each time the board had to be refreshed.
Method 2: Scan 6 or 12 times for each column or row picking each piece as it goes along and storing it in an array. This would scan a much bigger area but only have to do it either 6 or 12 times each time it had to be refreshed.
Does anyone have any insight on which was would be the best? or even better have another method that would be even more effective?
The methods you describe are exactly the same in effort, so it doesn't matter which you use. Personally, I'd go with the first one.
What I'd look for is the smallest area I can search that indicates a different piece rather than trying to match the entire piece image. Depending on how long a search takes, you might consider using parallel tasks.
You might also consider building a quad tree and use that to find and match the images.
I have been having a look at this quad tree stuff and it seems like if done properly, it could be a really good way in getting this to run fast. I am struggling to find some good sources on how it all really works though, do you know of any tutorials/guides on how to setup a quad tree and use it?
couldn't you make the different types of pieces properties of the same class? then instead of randomely changing the piece just change the properties of it so it looks different. a typed array or a database could store the different sets of properties. as for finding them you could use the controls collection and linq which allows very specific searches.