Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: FindMagma0.2a  (Read 2467 times)

Ziusudra

  • Bay Watcher
    • View Profile
FindMagma0.2a
« on: December 17, 2007, 12:16:00 am »

A newer version is available here.

FindMagma0.2a.zip - 202.85 KB - Includes stand alone executable for those without AutoHotKey installed.

FindMagma0.2a_s.zip - 10.61 KB - For those who do have AHK installed.

No installation required, just unzip to where ever and double click the FindMagma file.

DF must be set to the following: windowed 640x300, 'text' mode, default color scheme and default font/tile set. ([WINDOWED:YES], [WINDOWEDX:640], [WINDOWEDY:300], [FONT:curses_640x300.bmp], [GRAPHICS:NO])

With DF at the Choose Fortress Location screen, press f to start the search.  The DF window must remain the active window at all times during the search.  Searching the entire world will take about 4 hours.  Found regions will be output to log.txt in the script's folder with the coordinates and any features found.

Once you have the coordinates you can press g (once again at the Choose Fortress Location screen) to go to a region. Just enter the coordinates from the log.txt into the windows.  Again, the DF window must remain the active window at all times.

Both downloads include a change log, but basically the script now only reports regions that are embarkable and have magma and at least one other feature.  Other features currently are mountains and named features (peak, volcano, stream or brook.)  It also reports on neighbors and highest cliffs.

This release outputs debug information to debug.txt, also in the script's folder.  If you have problems please feel free to send me that file, an Alt-PrintScreen of DF at the Choose Fortress Location screen and a description of the problem, including seed if possible.  The debug.txt file includes regions that didn't make the cut among other things, for the curious.

[ December 18, 2007: Message edited by: Ziusudra ]

Logged
Ironblood didn't use an axe because he needed it. He used it to be kind. And right now he wasn't being kind.

BurnedToast

  • Bay Watcher
  • Personal Text
    • View Profile
Re: FindMagma0.2a
« Reply #1 on: December 17, 2007, 02:30:00 am »

The only thing I can think of is to suggest a 'quick search' option that only checks the tiles around a volcano on the middle map (maybe 2 or 3 out?). You won't find all the magma that way, but it should be ALOT faster and you will get most of it.
Logged
An ambush! curse all friends of nature!

Chariot

  • Bay Watcher
  • Turtle Trainer
    • View Profile
Re: FindMagma0.2a
« Reply #2 on: December 17, 2007, 03:13:00 am »

quote:
Originally posted by BurnedToast:
<STRONG>The only thing I can think of is to suggest a 'quick search' option that only checks the tiles around a volcano on the middle map (maybe 2 or 3 out?). You won't find all the magma that way, but it should be ALOT faster and you will get most of it.</STRONG>


ive found far more magma nowhere near volcanoes compared to next to em. just searching 2-3 tiles out from volcanoes will only find a tiny fraction of the total, not most of it

Logged

ein Syndication

  • Bay Watcher
    • View Profile
Re: FindMagma0.2a
« Reply #3 on: December 17, 2007, 05:33:00 am »

I can't seem to get this to give me anything other than the wrong screen error. Started with 33f, but I've also fresh installed 33c, 33d, and another copy of 33f and still that error. I've had default init, I've tried turning off the movie and the windowed prompt, nothing seems to work. Also tried both the script itself and the exe, just in case.
Logged

Ziusudra

  • Bay Watcher
    • View Profile
Re: FindMagma0.2a
« Reply #4 on: December 17, 2007, 11:09:00 am »

quote:
Originally posted by ein Syndication:
<STRONG>I can't seem to get this to give me anything other than the wrong screen error. Started with 33f, but I've also fresh installed 33c, 33d, and another copy of 33f and still that error. I've had default init, I've tried turning off the movie and the windowed prompt, nothing seems to work. Also tried both the script itself and the exe, just in case.</STRONG>

That's really weird, default init.txt should work if you choose windowed.  Movies shouldn't make a difference since they've long since played once you're at the Choose Fortress Location screen.  You are at that screen, right?

Can you send me the debug.txt and log.txt if they exist and a screen shot of the DF window? (Maybe your computer renders the screen different than mine?)

 

quote:
Originally posted by BurnedToast:
<STRONG>The only thing I can think of is to suggest a 'quick search' option that only checks the tiles around a volcano on the middle map (maybe 2 or 3 out?). You won't find all the magma that way, but it should be ALOT faster and you will get most of it.</STRONG>

No, it wouldn't be faster, the script would still have to look at every region to find the volcanoes.  In fact it would be slower as it would have to look for features in surrounding regions it's already checked for volcanos.

And, like Chariot said, most of the magma vents are actually not within 2-3 regions of volcanoes.  And flux seems to be rare near volcanoes.

Edit: Wait, you're saying the user finds the volcanoes, or what ever feature, and the script would just search the area around what ever region is currently selected.  I've thought of that and will probably add it after I get the layer checks coded.

[ December 17, 2007: Message edited by: Ziusudra ]

Logged
Ironblood didn't use an axe because he needed it. He used it to be kind. And right now he wasn't being kind.

Quarthinos

  • Bay Watcher
    • View Profile
Re: FindMagma0.2a
« Reply #5 on: December 17, 2007, 01:38:00 pm »

I looked at your code, and it seems to be failing to find CFL.bmp in the correct location.  Part of the reason is that I'm not using the default XP desktop, as I prefer the NT look.  Could I suggest running a loop to find CFL.bmp (go from say 25 to 35 in X and from 220 to 230 in Y), and then using that to determine how to modify MainTop, MainBottom, etc?

I'm going to try and do it myself right now, but I'm not sure there isn't some other problem. (To say nothing about never programming in AHK before...)

edit..

So I made it work on my machine.  I had to make some changes to the script.  Here's the result of FC:

Comparing files Original FindMagma.ahk and FINDMAGMA.AHK
***** Original FindMagma.ahk
FindImage(ImageX, ImageY
       , 226, 28, 417, 38
       , "CFL.bmp")
If ErrorLevel
***** FINDMAGMA.AHK
FindImage(ImageX, ImageY
    , 220, 20, 451, 40
    , "CFL.bmp")
If ErrorLevel
*****
I added some extra space so that some movement of CFL.bmp can happen (like using a "Windows Classic" Theme...)


***** Original FindMagma.ahk
}
Start := A_Now
***** FINDMAGMA.AHK
}
XOff := ImageX - 226
YOff := ImageY - 28
Start := A_Now
*****
Then I determine how much different this window is from the normal.

***** Original FindMagma.ahk
   Found = Found Magma in Region %RegionX%,%RegionY%
   FindImage(ImageX, ImageY, 178, 304, 232, 314, "Embark.bmp")
   If ErrorLevel
***** FINDMAGMA.AHK
   Found = Found Magma in Region %RegionX%,%RegionY%
   FindImage(ImageX, ImageY, 178 + XOff, 304 + YOff, 232 + XOff, 314 + YOff, "Embark.bmp")
   If ErrorLevel
*****
And then use those offsets to move some of the search boxes a bit:

***** Original FindMagma.ahk
      , RegionXLeft, RegionXTop, RegionXRight, RegionXBottom
 Loop
***** FINDMAGMA.AHK
      , RegionXLeft, RegionXTop, RegionXRight, RegionXBottom
      , XOff, YOff
 Loop
*****
This is the declarations for GoToCorner

***** Original FindMagma.ahk
   FindBlinkingX(ImageX, ImageY
               , LocalRight, MainTop, RegionRight, MainBottom)
   If ErrorLevel
***** FINDMAGMA.AHK
   FindBlinkingX(ImageX, ImageY
               , LocalRight + XOff, MainTop + YOff, RegionRight + XOff, MainBottom + YOff)
   If ErrorLevel
*****
Also in GoToCorner

***** Original FindMagma.ahk
   Else If (Corner = "TopLeft")
           AND (ImageX = RegionXLeft)
           AND (ImageY = RegionXTop)
     Break
***** FINDMAGMA.AHK
   Else If (Corner = "TopLeft")
           AND (ImageX = RegionXLeft + XOff)
           AND (ImageY = RegionXTop + YOff)
     Break
*****
Note that if the planned NearestCorner is done, the other Corners will need to get the offsets, too.

I haven't done a full run on this very sloooow computer at work, but it's a good start.

[ December 17, 2007: Message edited by: Quarthinos ]

Logged

Ziusudra

  • Bay Watcher
    • View Profile
Re: FindMagma0.2a
« Reply #6 on: December 17, 2007, 01:58:00 pm »

It might be better to just increase the search area, it doesn't need to be as tight as I have it.  Although if the CFL text is in a different place everything else could be.

If anyone gets this error, please send an Alt-PrintScreen of the DF window to ziusudra@gmail.com.  (Close the error first or you'll end up sending a picture of it.)  The error will begin with:

code:
DF needs to be in the windowed 640x300 text (not
GFX) mode with the default colors and at the
Choose Fortress Location screen.

Logged
Ironblood didn't use an axe because he needed it. He used it to be kind. And right now he wasn't being kind.

Quarthinos

  • Bay Watcher
    • View Profile
Re: FindMagma0.2a
« Reply #7 on: December 17, 2007, 02:25:00 pm »

Looks like you said something while I was editting..  I'll go ahead and send you a capture.
Logged

Ziusudra

  • Bay Watcher
    • View Profile
Re: FindMagma0.2a
« Reply #8 on: December 17, 2007, 02:41:00 pm »

Thanks, I should be able to get a bug fix release out tonight.
Logged
Ironblood didn't use an axe because he needed it. He used it to be kind. And right now he wasn't being kind.

ein Syndication

  • Bay Watcher
    • View Profile
Re: FindMagma0.2a
« Reply #9 on: December 17, 2007, 03:55:00 pm »

I tried making the changes Quarthinos posted, and it appeared to work. However, I scanned the top two rows of my world about five times, four of which I got different numbers for what appeared to be the same spots. Not sure if it was because of the original or the modifications. I also was playing around with that sleep 250 with the comment, and I'm curious as to whether the G_FPS in init would make it more accurate if you put it at a very high number. That may have caused the errors, as well, but then again, as I said, it was always the first three rows and it appeared to always find the same two spots. Though occasionally it also showed a third ...

Also, those changes obviously didn't also fix the Go To Location, so I can't really check the wierd listed numbers. I tried basically copying over the same fixes, but GoToCorner("TopLeft") always stopped anywhere from one to four regions short of the top left.

Logged

Ziusudra

  • Bay Watcher
    • View Profile
Re: FindMagma0.2a
« Reply #10 on: December 17, 2007, 04:09:00 pm »

quote:
Originally posted by Quarthinos:
<STRONG>I looked at your code, and it seems to be failing to find CFL.bmp in the correct location.  Part of the reason is that I'm not using the default XP desktop, as I prefer the NT look.  Could I suggest running a loop to find CFL.bmp (go from say 25 to 35 in X and from 220 to 230 in Y), and then using that to determine how to modify MainTop, MainBottom, etc?

I'm going to try and do it myself right now, but I'm not sure there isn't some other problem. (To say nothing about never programming in AHK before...)</STRONG>


Actually, if I add the offsets to the FindImage function then I only need to add them to one line in the main loop and those 8 lines in GoToCorner.

I'd never programmed in AHK before this, either.

Logged
Ironblood didn't use an axe because he needed it. He used it to be kind. And right now he wasn't being kind.

Ziusudra

  • Bay Watcher
    • View Profile
Re: FindMagma0.2a
« Reply #11 on: December 17, 2007, 04:20:00 pm »

quote:
Originally posted by ein Syndication:
<STRONG>I tried making the changes Quarthinos posted, and it appeared to work. However, I scanned the top two rows of my world about five times, four of which I got different numbers for what appeared to be the same spots. Not sure if it was because of the original or the modifications. I also was playing around with that sleep 250 with the comment, and I'm curious as to whether the G_FPS in init would make it more accurate if you put it at a very high number. That may have caused the errors, as well, but then again, as I said, it was always the first three rows and it appeared to always find the same two spots. Though occasionally it also showed a third ...

Also, those changes obviously didn't also fix the Go To Location, so I can't really check the wierd listed numbers. I tried basically copying over the same fixes, but GoToCorner("TopLeft") always stopped anywhere from one to four regions short of the top left.</STRONG>


Quarthinos missed a few lines that might throw things off.  I can't run DF at work so I can't know for sure.

I think G_FPS only affects the graphics mode.  I get 20-40 FPS during a search and even if it was hitting the limit that might just leave more time to update the window.

My system can usually do Sleep 150 without losing accuracy.  Too low a number and the script starts checking the next region while DF is still showing the previous.

Anyway, I better go do some actual work while I'm here.

Are you the other that emailed your PrintScreen?

[ December 17, 2007: Message edited by: Ziusudra ]

Logged
Ironblood didn't use an axe because he needed it. He used it to be kind. And right now he wasn't being kind.

Ziusudra

  • Bay Watcher
    • View Profile
Re: FindMagma0.2a
« Reply #12 on: December 17, 2007, 04:46:00 pm »

Here's the changes I'm making from my original released code:
code:
f::
If Debug
 IfExist debug.txt
   FileDelete, debug.txt
XOffset = 0 ; It would probably work without these
YOffset = 0

FindImage(ImageX, ImageY
       , 0, 0, FeaturesRight, MainTop
       , "CFL.bmp")
If ErrorLevel
{
 MsgBox %WrongScreenMessage% search.
 Return
}
XOffset := ImageX - 226
YOffset := ImageY - 28
If Debug
 FileAppend, Offsets are %XOffset%`,%YOffset%.`n
           , debug.txt

Start := A_Now

code:
    Else If (ImageX = RegionXRight + XOffset) AND (ImageY = RegionXBottom + YOffset)

code:
g::
If Debug
 IfExist debug.txt
   FileDelete, debug.txt
XOffset = 0 ; It would probably work without these
YOffset = 0

FindImage(ImageX, ImageY
       , 0, 0, FeaturesRight, MainTop
       , "CFL.bmp")
If ErrorLevel
{
 MsgBox %WrongScreenMessage% Go To Coordinates.
 Return
}
XOffset := ImageX - 226
YOffset := ImageY - 28
If Debug
 FileAppend, Offsets are %XOffset%`,%YOffset%.`n ; Edit: D'oh, forgot the %'s
           , debug.txt

InputBox, X, Go to coordinate, Enter X Coordinate,,200,120,,,,,0

code:
FindImage(ByRef X, ByRef Y, Left, Top, Right, Bottom, File)
{
 global Debug, XOffset, YOffset
 global SearchErrorMessage
 ImageSearch, X, Y, Left + XOffset, Top + YOffset, Right + XOffset, Bottom + YOffset, %File%
 If ErrorLevel = 2

code:
GoToCorner(Corner)
{ ; Corner can be TopLeft, TopRight, BottomLeft, BottomRight
 global Debug, XOffset, YOffset
      , LocalRight, MainTop, RegionRight, MainBottom

code:
    Else If (Corner = "TopLeft")
           AND (ImageX = RegionXLeft + XOffset)
           AND (ImageY = RegionXTop + YOffset)
     Break
   Else If (Corner = "TopRight")
           AND (ImageX = RegionXRight + XOffset)
           AND (ImageY = RegionXTop + YOffset)
     Break
   Else If (Corner = "BottomLeft")
           AND (ImageX = RegionXLeft + XOffset)
           AND (ImageY = RegionXBottom + YOffset)
     Break
   Else If (Corner = "BottomRight")
           AND (ImageX = RegionXRight + XOffset)
           AND (ImageY = RegionXBottom + YOffset)
     Break

In about 4 hours I should have it tested and released.

[ December 17, 2007: Message edited by: Ziusudra ]

Logged
Ironblood didn't use an axe because he needed it. He used it to be kind. And right now he wasn't being kind.

ein Syndication

  • Bay Watcher
    • View Profile
Re: FindMagma0.2a
« Reply #13 on: December 17, 2007, 05:05:00 pm »

Just checked, set G_FPS to 1 with GRAPHICS:OFF. The game updates like normal, but yes, the screen only updates once a second.

Also yes that was my screenshot. I'm rather absent-minded about such things.

Logged

Ziusudra

  • Bay Watcher
    • View Profile
Re: FindMagma0.2a
« Reply #14 on: December 17, 2007, 05:09:00 pm »

quote:
Originally posted by ein Syndication:
<STRONG>Just checked, set G_FPS to 1 with GRAPHICS:OFF. The game updates like normal, but yes, the screen only updates once a second.

Also yes that was my screenshot. I'm rather absent-minded about such things.</STRONG>


O RLY?  I'll have to play that setting.
Logged
Ironblood didn't use an axe because he needed it. He used it to be kind. And right now he wasn't being kind.
Pages: [1] 2