OGame Automizer Development Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome on the OGame Automizer Development/Support Forum

If this is your first visit, be sure to check out the
http://ogameautomizer.com/doc/manual.html : A guide written by OA users with consultation of OA author (En)

http://ogameautomizer.com/doc/manual_de.html : A guide written by OA users with consultation of OA author (Benutzerschnittstellenhandbuch) (GE)

http://ogameautomizer.com/doc/scripting_manual.html : OA Scripting Manual (En)

Pages: [1] 2 3

Author Topic: Search Colonizable Space in Galaxy ** UPDATE V1.1 **  (Read 13618 times)

0 Members and 1 Guest are viewing this topic.

chronos001

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 71
    • View Profile
Search Colonizable Space in Galaxy ** UPDATE V1.1 **
« on: June 05, 2012, 04:07:11 PM »

Hi,
This is a very very little script based on OA DB for rapid search a free space for colonization.
Is a rudimental script and need to be optimized ;D by new function or best code! ;D
You need to set:
- Galaxy and System of your planet or another coordinate for calculate radius
- System radius from the planet (if insert a biggest number the script search in all System)
- The space you want to search between 1 and 15 in a system

The script is based on data in OA DataBase, this is very fast, but if Galaxy Scan was old, the output can be fake. ::)

UPDATED CODE HERE:
http://forum.ogameautomizer.com/index.php/topic,2063.msg7256.html#msg7256

Code: [Select]
//-------------- CONFIGURATION BY USER -----------------------------------------------
def GalaxyPlanet = 1 // Galaxy of your favorite planet, or starting coordinate
def SystemPlanet = 214 // System of your favorite planet, or starting coordinate
def delta = 150 // System Radius + and - from configured System Planet
def limitColonyUp = 5 // Search Free Space between this position in a System .....
def limitColonyDown = 10 // .... and this position!
//-------------- END CONFIG ----------------------------------------------------------

def searchFrom = SystemPlanet - delta // Calculate start from System
def searchTo = SystemPlanet + delta // Calculate end to System
def SystemCheck = [1..15] //Auto Setted Value 0 --> FREE SPACE / 1 --> BUSY / 2 --> IGNORE

def IArray = { -> //Inizialize Position Array
  for (i in 1..15){
    if (i <= limitColonyDown && i >= limitColonyUp){
      SystemCheck[i] = 0
    }else{SystemCheck[i] = 2}
  }
}

if (limitColonyUp > limitColonyDown){
  printOut "Attention: limitColonyUp can not be major then limitColonyDonw! \n Script Aborted!"
}else{
if (searchFrom <= 0) searchFrom = 1
if (searchTo >= 500) searchTo = 499
def actSystem = searchFrom

conn = getDBConn()
statement = conn.createStatement();
printOut "Start Searching Colonizzation position in Galaxy " + GalaxyPlanet + " From System " + searchFrom + " To System " + searchTo
result = statement.executeQuery("SELECT Galaxy, System, Planet FROM PLANET WHERE Galaxy=" + GalaxyPlanet + "AND (System BETWEEN " + searchFrom + " AND " + searchTo + ") order by System, Planet");
IArray()

while(result.next()){
  dbSystem = result.getInt("System")
  if (dbSystem == actSystem){
    SystemCheck[result.getInt("Planet")] = 1
  }else{
    for (i in 1..15){
      if (SystemCheck[i] == 0){
        printOut "This PLANET can be Colonized: " + GalaxyPlanet + ":" + (dbSystem - 1) + ":" + i
      }
    }
    actSystem = dbSystem
    IArray()
    SystemCheck[result.getInt("Planet")] = 1
  }
}
printOut "Search completed!"
statement.close()
result.close()
closeDBConn(conn)
}

This is a simple output:

Quote
16:00:29 : Start Searching Colonizzation position in Galaxy 1 From System 64 To System 364
16:00:29 : This PLANET can be Colonized: 1:97:6
16:00:29 : This PLANET can be Colonized: 1:107:5
16:00:29 : This PLANET can be Colonized: 1:164:7
16:00:29 : This PLANET can be Colonized: 1:170:5
16:00:29 : This PLANET can be Colonized: 1:193:7
16:00:29 : This PLANET can be Colonized: 1:318:5
16:00:29 : This PLANET can be Colonized: 1:320:10
16:00:29 : Search completed!

Sorry for the poor english  :-X ;D

Byeeeeeeeeeeeeee

« Last Edit: June 07, 2012, 10:43:29 AM by chronos001 »
Logged

wulf3010

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 447
    • View Profile
Re: Search Colonizable Space in Galaxy
« Reply #1 on: June 05, 2012, 10:33:49 PM »

you are an genius, please keep it up this good work.
Logged

chronos001

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Search Colonizable Space in Galaxy
« Reply #2 on: June 06, 2012, 08:59:20 AM »

Thx for the compliment ;D
Now with DH help we add options for send colonization and scan galaxy before get planet list!

Byz!! ::)
Logged

anonymous19

  • Newbie
  • *
  • Offline Offline
  • Posts: 24
    • View Profile
Re: Search Colonizable Space in Galaxy
« Reply #3 on: June 06, 2012, 10:18:10 AM »

Good job!

You could easily add a feature to keep the db up to date, if a specific config variable is set by the user (f.ex. boolean "prescan"), then the script will scann the galaxy in range before connecting to the db and getting the result. An example is given in Devils "standart" Scripts.

chronos001

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Search Colonizable Space in Galaxy
« Reply #4 on: June 06, 2012, 10:31:30 AM »

yep...  ;D already added  :P

I need to test it first!
Logged

chronos001

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Search Colonizable Space in Galaxy
« Reply #5 on: June 06, 2012, 11:44:19 AM »

There is a little error in original script, if a System have all free planet, the script skip to show coordinate... i'm going to correct him!
Dhoooo ::)
Logged

chronos001

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Search Colonizable Space in Galaxy ** UPDATE V1.1 **
« Reply #6 on: June 07, 2012, 10:42:11 AM »

Hi,
I have update the script, many thanks to DH for help!

1. Added Galaxy Scan (You can activate or not by set scanGalaxy TRUE or FALSE
2. Added Send Colony Ship directly (read config section, need to test)
3. Correct bug: no free space printout if no planet in galaxy
4. More readable and semplifyed code.

Have fun, stay tuned! ;D

Code: [Select]
//-------------- CONFIGURATION BY USER -----------------------------------------------
def GalaxyPlanet = 2 // Galaxy of your favorite planet, or starting coordinate
def SystemPlanet = 303 // System of your favorite planet, or starting coordinate
def delta = 15 // System Radius + and - from configured System Planet || IF SET GALAXY SCAN TRUE AN HIGH NUMBER CAN TAKE SEVERAL MINUTE
def limitColonyUp = 5 // Search Free Space between this position in a System .....
def limitColonyDown = 10 // .... and this position!
def scanGalaxy = true // Scan Galaxy before searching for free places || TRUE = SCAN GALAXY FIRST // FALSE = NEVER SCAN GALAXY, READ ONLY DB
def sendColonyShipFrom = "" // Insert Like This --> "[5:35:5]" // Optional, Planet from witch you want Colony Ship to be sent
//-------------- END CONFIG ----------------------------------------------------------

def searchFrom = SystemPlanet - delta // Calculate start from System
def searchTo = SystemPlanet + delta // Calculate end to System
def SystemCheck = new int[500][16]; //SYSTEM AND PLANET POSITION -> Auto Setted Value 0 --> FREE SPACE / 1 --> BUSY / 2 --> IGNORE

def MatrixArray = { -> //Inizialize Position Array
  for (k in searchFrom..searchTo){
    for (i in 1..15){
      if (i <= limitColonyDown && i >= limitColonyUp){
        SystemCheck[k][i] = 0
      } else{SystemCheck[k][i] = 2}
    }
  }
}

if (limitColonyUp < limitColonyDown){
  if (searchFrom <= 0) searchFrom = 1
  if (searchTo >= 500) searchTo = 499
  def actSystem = searchFrom
 
  if(scanGalaxy){
    printOut "Starting Galaxy scanning..."
    for(s in searchFrom..searchTo){
      startSyncGalaxyScan GalaxyPlanet, s
      printOut "Scanned: "+GalaxyPlanet+":"+s
    }
  }

  conn = getDBConn()
  statement = conn.createStatement();
  printOut "Start Searching Colonizzation position in Galaxy " + GalaxyPlanet + " From System " + searchFrom + " To System " + searchTo
  result = statement.executeQuery("SELECT Galaxy, System, Planet FROM PLANET WHERE Galaxy=" + GalaxyPlanet + "AND (System BETWEEN " + searchFrom + " AND " + searchTo + ") order by System, Planet");
 
  def freeSlots = [:]
  def count = 0
  def IndexCounter = 0
  MatrixArray()
 
  while(result.next()){ //Fill Array with Busy position
    SystemCheck[result.getInt("System")][result.getInt("Planet")] = 1
  }

  for (SCount in searchFrom..searchTo){ //Printout only Free Planet
    for (i in 1..15){
      if (SystemCheck[SCount][i] == 0){
         printOut "This PLANET can be Colonized: " + GalaxyPlanet + ":" + SCount + ":" + i
         freeSlots.put count++, Coordinates.getCoordinates(GalaxyPlanet + ":" + SCount + ":" + i)
      }
    }
  }
  printOut "Search completed!"
  statement.close()
  result.close()
  closeDBConn(conn)

  if(Coordinates.isCoordinates(sendColonyShipFrom)){
    def selectList = ""
    for(i in 0..(freeSlots.size()-1)){selectList += i+": "+freeSlots.get(i).toString()+"\n"}
    def input = getInput "Select the Planet to be colonized [0-"+(freeSlots.size()-1)+"]\n"+selectList
    if(input != null && !input.isEmpty() && input ==~ "[0-9]*" && Integer.parseInt(input) < freeSlots.size()) {
      if(getNumberOf('COLONYSHIP', sendColonyShipFrom) != 0) {
        printOut getPlanet(sendColonyShipFrom).toString()+" -> "+freeSlots.get(Integer.parseInt(input)).toString()+" COLONIZATION MISSION "+[COLONYSHIP : 1]
        sendFleet getPlanet(sendColonyShipFrom),freeSlots.get(Integer.parseInt(input)),FleetMission.COLONIZATION_MISSION,100,[COLONYSHIP : 1]
      } else printOut "There is no any COLONY SHIP on "+sendColonyShipFrom
    }
  }
} else printOut "Attention: limitColonyUp can not be major then limitColonyDonw! \n Script Aborted!"
Logged

banthex

  • Newbie
  • *
  • Offline Offline
  • Posts: 21
    • View Profile
Re: Search Colonizable Space in Galaxy ** UPDATE V1.1 **
« Reply #7 on: June 07, 2012, 12:17:26 PM »

Thanks guys. This script is awsome!
Logged

bohne

  • Newbie
  • *
  • Offline Offline
  • Posts: 44
    • View Profile
Re: Search Colonizable Space in Galaxy ** UPDATE V1.1 **
« Reply #8 on: September 22, 2012, 01:53:32 AM »

Does it only fail At me?
It prints planets, which are in use already..
Logged

killerlol

  • Newbie
  • *
  • Offline Offline
  • Posts: 11
    • View Profile
Re: Search Colonizable Space in Galaxy ** UPDATE V1.1 **
« Reply #9 on: September 22, 2012, 08:16:07 PM »

Does it only fail At me?
It prints planets, which are in use already..
Uncheck Disable Scanning? Script works fine for me.
Logged

treibsand

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 56
    • View Profile
Re: Search Colonizable Space in Galaxy ** UPDATE V1.1 **
« Reply #10 on: November 05, 2012, 10:10:05 PM »

Does it only fail At me?
It prints planets, which are in use already..
Uncheck Disable Scanning? Script works fine for me.

There is still a bug. From systems above 255 the script always prints planets as colonizable!
Logged

treibsand

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 56
    • View Profile
Re: Search Colonizable Space in Galaxy ** UPDATE V1.1 **
« Reply #11 on: March 18, 2013, 12:19:44 PM »

Another bug in the script or maybe in the database-design:
Planets with name "..." always shown as colonizable.

(some really funny people named all the planets and their playernames like "...")
Logged

nuhll

  • Full Member
  • ***
  • Offline Offline
  • Posts: 151
    • View Profile
Re: Search Colonizable Space in Galaxy ** UPDATE V1.1 **
« Reply #12 on: March 21, 2013, 11:56:29 PM »

absolut useless. printing inactives, noobs, and many other players... none of the printed planets were colonizeable.
« Last Edit: March 22, 2013, 12:04:22 AM by nuhll »
Logged

Devil's Hand

  • Administrator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 2,523
    • View Profile
Re: Search Colonizable Space in Galaxy ** UPDATE V1.1 **
« Reply #13 on: March 22, 2013, 01:29:39 AM »

absolut useless. printing inactives, noobs, and many other players... none of the printed planets were colonizeable.
1. Not be so disrespectful visa-vie a user who wants contribute to !
2. As this script is based on OA Database, you should update the target galaxy within OA before using that script.
By the way it's written on first line:
Quote
This is a very very little script based on OA DB for rapid search a free space for colonization.

@chronos001: maybe you can update your script based on OGame API instead on OA DB, an example in 'OGame API' built-in script and another here: http://forum.ogameautomizer.com/index.php/topic,2462.0.html
In case you need some reference documentation, do not hesitate.

Best Regards,
« Last Edit: March 22, 2013, 01:34:09 AM by Devil's Hand »
Logged

nuhll

  • Full Member
  • ***
  • Offline Offline
  • Posts: 151
    • View Profile
Re: Search Colonizable Space in Galaxy ** UPDATE V1.1 **
« Reply #14 on: March 22, 2013, 10:19:07 PM »

Hello,
sorry, i dont want to be unthankfull! I thank everyone and even you rfor your bot.

But i tried like 3h to get this working without success. I thought when i startet raid bot, he will update the DB, but it doesnt seem. With scan it gives some colonizable planets but also players with ... and destroyed planets. But atleast this helps alot!


Edit:
new idea, when i look manual for free colonization i go FAST thru the galaxy bc i just need to look wheres no player name, maybe OA could also go FASTER?
« Last Edit: March 22, 2013, 10:21:38 PM by nuhll »
Logged
Pages: [1] 2 3
 

Page created in 0.034 seconds with 20 queries.