-
Pascal Arrays
I decided to waste my time by writing a script to solve minesweeper. I really have no intentions of this working or being of any use but i need to get my programming skills up again. I've ran into a few problems with my arrays.
Ideally (I think...correct me if i'm wrong) I'll have a two-dimensional array to describe where each of the 64(on beginner) little 15x15 pixel square is. And i'll have an array of 10 elements to hold the information in the square (1..8, empty, filled).
I will have the program look at the 2D array to look through the squares and then use bitmap recognition to decide what information is in the square.
Eventually of course i will have to make some sort of variable system to handle the information in the surrounding 8 squares and act accordingly, but one bite at a time right?
The part where i have trouble with is defining my 2D array. How can i have each element of that be a 15x15 pixel square? I can obviousy make an array by having ('a'..'h',1..8) but how can i define each element by a square? i'm pretty new to arrays (about 36 hours since i learned about them) so any info would be great.
Thanks!
Ransom
-
if your using coordinates and arrays, you can try tpointarrays. a tpoint is a varialble with 2 sets of information
var tp:tpoint;
tp.x:=1
tp.y:=2
so if you have a 2 sets of tpoints, one for the top left, and one for the bottom right, just call to each set for the coordinates of the boxes. so tpointarraytopleft 1-15 has top left coords,and tpointarraybottomright 1-15 has the corresponding bottom right points.
and if you using scar, i believe it is written in delphi, so a site i use is http://www.delphibasics.co.uk/index.html
-
type square=record
a,b,c,d,e,f,g,h:integer;
empty, filled:boolean;
end;
var mysquare:square;
begin
mysquare.a:=blahblah;
mysquare.empty:=true;
end.
----------------------------------------------
Edit: actually it would be
var
mysquare:array of square;
begin
mysquare[0].a
-
If you wanna define a 2D array,
PHP Code:
This: Array of Array of Integer;
This: Array[1..3] of Array[1..6] of Integer;
-
Alright i think I'm getting it a little bit better. I'm working on that script at work and school because it's a lot easier to test and get away with than runescape scripts. I don't really spend much time playing the game mostly just like finding ways to bend and shatter the rules :D While browsing the delphi stuff i ran across the TRect class and i think i'm going to use that one. I can put in the coords using an x,y formula type thing and it will give me the exact coods of the rectangles top, bottom, right and left. That way i can spit them back out when i'm doing FindBitmapToleranceIn() Or something else along those lines that takes 4 points to a rectangle.
I'll post more as i test more but thanks for your help. I hope to have this functioning (probably not working..just finding and clicking) in the next few days so i'll post what i have when i get the chance. Thanks for the prompt help!
Now just to get the coords spit out how i need them........hmmm..... :(h): any takers?
Thanks!
Ransom
-
I don't see that in the supported classes section of SCAR's F1 help, you may need to make it yourself with type record.