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: Def Calc v1.2  (Read 9816 times)

0 Members and 1 Guest are viewing this topic.

Holz1692

  • Newbie
  • *
  • Offline Offline
  • Posts: 31
    • View Profile
Def Calc v1.2
« on: September 19, 2014, 12:05:08 AM »

Hey!
This is my new Script.
Calculate the "perfect" Def. Based on http://www.ogame-wissen.de/3088-die-perfekte-verteidigungs-kombination.html



Code: [Select]
/*
Def Calc. based on http://www.ogame-wissen.de/3088-die-perfekte-verteidigungs-kombination.html#post65023
Version 1.0
by Holz

*/

//Config
//Exchange Rate/Wechselkurs
double met = 2.5
double kris = 1.5
double deut = 1

double tf = 0.7 // 70% DF = 0.7 | 50% = 0.5 | 30% = 0.3
double loot = 0.75 // normal = 0.5 | honor = 0.75 | bandit = 1
double dayprod = 1.0 // daily production -> 1 = 1day | 2 = 2 days and so on

//I recommend 75rocket:150LL:40HL:8Gaus:1Plasma
int rak = 75
int ll = 150
int sl = 40
int gaus = 8
int plasma = 1
int klschild = 1 //can only be 1
int grschild = 1 //same here.
//Config End

printOut "Invest in s.Shield -> g. Shield -> Plasma -> Gaus -> SL -> LL -> Rak"

for(planet in getPlanets()){

printOut "-----------" + planet + "------------"

Planet p = getPlanetFromName(planet)
if(p.coordinates.isMoon()){"-----------Moon-----------"}
else{
updatePlanet(planet)

//temp Variablen
int tfmet = 0
int tfkris = 0
int lootmet = 0
int lootkris = 0
int lootdeut = 0
double gesMSE = 0
double verviel = 0
int rakneed = 0
int llneed = 0
int slneed = 0
int gausneed = 0
int plasmaneed = 0
int klschildneed = 0
int grschildneed = 0
int rakakt = 0
int llakt = 0
int slakt = 0
int gausakt = 0
int plasmaakt = 0
int rakneu = 0
int llneu = 0
int slneu = 0
int gausneu = 0
int plasmaneu = 0

//TF ausrechnen.
for(ship in ships)
{

if (getNumberOf(ship,planet) == 0){}
else{
tfmet = tfmet + getPrice(ship, planet).getMetalValue()*getNumberOf(ship,planet)
tfkris = tfkris + getPrice(ship, planet).getCrystalValue()*getNumberOf(ship,planet)*(met/kris)
}
}

tfkris = tfkris + getNumberOf(SOLARSATELLITE,planet)*getPrice(SOLARSATELLITE,planet).getCrystalValue()*(met/kris)
tfmet = tfmet*tf
tfkris = tfkris*tf
//printOut "-------------TF---------------"
//printOut tfmet + " Met " + tfkris + " Kris"

//Loot berechnen.
lootmet = planet.getMetalProduction()*loot*(24*dayprod)
lootkris = planet.getCrystalProduction()*loot*(met/kris)*(24*dayprod)
lootdeut = planet.getDeuteriumProduction()*loot*met*(24*dayprod)
//printOut "-------------LOOT-------------"
//printOut lootmet + " Met " + lootkris + " Kris " + lootdeut + " Deut"

gesMSE = tfmet + tfkris + lootmet + lootkris + lootdeut
verviel = gesMSE/135000
printOut "Verviel " + verviel
printOut "-------------DEFneeded--------"
rakneu = rak*verviel
llneu = ll*verviel
slneu = sl*verviel
gausneu = gaus*verviel
plasmaneu = plasma*verviel

 rakakt = getNumberOf(ROCKETLAUNCHER,planet)
 llakt = getNumberOf(LIGHTLASER,planet)
 slakt = getNumberOf(HEAVYLASER,planet)
 gausakt = getNumberOf(GAUSSCANNON ,planet)
 plasmaakt = getNumberOf(PLASMATURRET,planet)
 rakneed = rakneu-rakakt
 llneed = llneu-llakt
 slneed = slneu-slakt
 gausneed = gausneu-gausakt
 plasmaneed = plasmaneu-plasmaakt

if(getNumberOf(SMALLSHIELDDOME,planet)==1){klschildneed = 0}
else {klschildneed = 1}
if(getNumberOf(LARGESHIELDDOME,planet)==1){grschildneed = 0}
else {grschildneed = 1}
if(rakneed<=0){rakneed=0}
if(llneed<=0){llneed=0}
if(slneed<=0){slneed=0}
if(gausneed<=0){gausneed=0}
if(plasmaneed<=0){plasmaneed=0}
printOut "Raketenwerfer: " + rakneed
printOut "Leichter Laser: " + llneed
printOut "Schwere Laser: " + slneed
printOut "Gauskanonen: " + gausneed
printOut "Plasmawerfer: " + plasmaneed
printOut "Kleine Schildkuppel: " + klschildneed
printOut "Grosse Schildkuppel: " + grschildneed

def investDef = [
SMALLSHIELDDOME: klschildneed,
LARGESHIELDDOME: grschildneed,
PLASMATURRET: plasmaneed,
GAUSSCANNON: gausneed,
HEAVYLASER: slneed,
LIGHTLASER: llneed,
ROCKETLAUNCHER: rakneed,
]

if(klschildneed == 0 && grschildneed == 0 && plasmaneed == 0 && gausneed == 0 && slneed == 0 && llneed == 0 && rakneed == 0){}
else{
investInShipsDefences(investDef, planet)
}
printOut "-----------------------------"
}
}





EDIT v1.1: no SolSat needed anymore... thanks troniac for your help :)
EDIT v1.2: included Heavy Laser. If there are a lot of Light Fighter in your uni.

Q: Now i´m using:
Code: [Select]
def investDef = [
SMALLSHIELDDOME: klschildneed,
LARGESHIELDDOME: grschildneed,
PLASMATURRET: plasmaneed,
GAUSSCANNON: gausneed,
HEAVYLASER: slneed,
LIGHTLASER: llneed,
ROCKETLAUNCHER: rakneed,
]
investInShipsDefences(investDef, planet)
Is it more effective to use:
Code: [Select]
if(klschildneed==0){} else{investInShipsDefences(SMALLSHIELDDOME: klschildneed, planet)
if(grschildneed==0){} else{investInShipsDefences(LARGESHIELDDOME: grschildneed, planet)
...
...
« Last Edit: January 15, 2015, 09:58:58 AM by Holz1692 »
Logged

troniac

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 358
  • Rue de Bruxelles, 5000 Namur, Belgium
    • View Profile
Re: Def Calc
« Reply #1 on: September 19, 2014, 10:08:51 AM »

This is defenetly an great Idea! I appreciate this! *thumbs up*
Logged
Je'sui Brussels

anonymous19

  • Newbie
  • *
  • Offline Offline
  • Posts: 24
    • View Profile
Re: Def Calc
« Reply #2 on: September 19, 2014, 07:24:11 PM »

Good script!

Little advice for you: To determine whether the iterated Planet is a Moon or a normal Planet, building a Solarsatellite only for the script is a weak argument. I know players who dont build any Satelitte.

I would recommend the Coordinates Structure, where you have a kind of flag "IsMoon()".

This should allow you to determine the type of Planet smartly.

http://ogameautomizer.com/doc/scripting_manual.html#_coordinates

Holz1692

  • Newbie
  • *
  • Offline Offline
  • Posts: 31
    • View Profile
Re: Def Calc
« Reply #3 on: September 20, 2014, 04:17:47 PM »

Hey!

thanks for the feedback :)

i can't figure out how "isMoon()" works.
Till now... -> I´ve updated the script! :)


holz
Logged

nuhll

  • Full Member
  • ***
  • Offline Offline
  • Posts: 151
    • View Profile
Re: Def Calc
« Reply #4 on: September 20, 2014, 05:37:51 PM »

What does it do? Does it build auto def?
Logged

Holz1692

  • Newbie
  • *
  • Offline Offline
  • Posts: 31
    • View Profile
Re: Def Calc
« Reply #5 on: September 20, 2014, 08:05:26 PM »

It calculate your df and the loot.
print out the defense you should build.
and invest in the needed defense. (in this order "Invest in s.Shield -> g. Shield -> Plasma -> Gaus -> LL -> Rak"
Logged

nuhll

  • Full Member
  • ***
  • Offline Offline
  • Posts: 151
    • View Profile
Re: Def Calc
« Reply #6 on: September 20, 2014, 09:10:34 PM »

Yea. But do i have to run this manual or can i make it "run on startup". So i get res from planet and build...
Logged

Holz1692

  • Newbie
  • *
  • Offline Offline
  • Posts: 31
    • View Profile
Re: Def Calc
« Reply #7 on: September 23, 2014, 10:02:14 PM »

you can run on startup.
Logged

troniac

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 358
  • Rue de Bruxelles, 5000 Namur, Belgium
    • View Profile
Re: Def Calc
« Reply #8 on: September 23, 2014, 11:40:00 PM »

As I said before.

The Coordinates Properties contains the isMoon(); Flag it returns Boolean true or false.

get more information out of the Script Manual: http://ogameautomizer.com/doc/scripting_manual.html#_coordinates

Code: [Select]
Planet p = getPlanetFromName("Mond")
printOut p.coordinates.isMoon();
Logged
Je'sui Brussels

Holz1692

  • Newbie
  • *
  • Offline Offline
  • Posts: 31
    • View Profile
Re: Def Calc
« Reply #9 on: September 24, 2014, 07:13:55 PM »

Quote
Code: [Select]
...
...
...
Planet p = getPlanetFromName(planet)
if(p.coordinates.isMoon()){"-----------Moon-----------"}
else{
updatePlanet(planet)
...
...
...

edited.
Logged

nuhll

  • Full Member
  • ***
  • Offline Offline
  • Posts: 151
    • View Profile
Re: Def Calc
« Reply #10 on: September 24, 2014, 08:53:56 PM »

COuld u edit this so it calc like every day?
Logged

Holz1692

  • Newbie
  • *
  • Offline Offline
  • Posts: 31
    • View Profile
Re: Def Calc
« Reply #11 on: September 25, 2014, 09:15:42 AM »

New script:
Code: [Select]
def cron = "${new Random().nextInt(59)}, 14, *, *, *" // will start everyday between 14:00-14:59 change 14 to 12 and it will start between 12:00-12:59 or 22 -> 22:00-22:59 and so on...

printOut "Will execute at : "+cron
  addCronExec cron, {
 def DEFCALC = "Scriptname" // for example "DefCalc"
 startScript(DEFCALC)
 printOut "Def Calc starts!"
 sleep 3000

}

Or instead of the script:
Code: [Select]
/*
Def Calc. based on http://www.ogame-wissen.de/3088-die-perfekte-verteidigungs-kombination.html#post65023
Version 1.0
by Holz

*/

def cron = "${new Random().nextInt(59)}, 14, *, *, *" // will start everyday between 14:00-14:59 change 14 to 12 and it will start between 12:00-12:59 or 22 -> 22:00-22:59 and so on...

printOut "Will execute at : "+cron
  addCronExec cron, {


//Config
//Exchange Rate/Wechselkurs
double met = 2.5
double kris = 1.5
double deut = 1

double tf = 0.7 // 70% DF = 0.7 | 50% = 0.5 | 30% = 0.3
double loot = 0.75 // normal = 0.5 | honor = 0.75 | bandit = 1
double dayprod = 1.0 // daily production -> 1 = 1day | 2 = 2 days and so on

//I recommend 75rocket:150LL:8Gaus:1Plasma
int rak = 75
int ll = 150
int gaus = 8
int plasma = 1
int klschild = 1 //can only be 1
int grschild = 1 //same here.
//Config End

printOut "Invest in s.Shield -> g. Shield -> Plasma -> Gaus -> LL -> Rak"

for(planet in getPlanets()){

printOut "-----------" + planet + "------------"

Planet p = getPlanetFromName(planet)
if(p.coordinates.isMoon()){"-----------Moon-----------"}
else{
updatePlanet(planet)

//temp Variablen
int tfmet = 0
int tfkris = 0
int lootmet = 0
int lootkris = 0
int lootdeut = 0
double gesMSE = 0
double verviel = 0
int rakneed = 0
int llneed = 0
int gausneed = 0
int plasmaneed = 0
int klschildneed = 0
int grschildneed = 0
int rakakt = 0
int llakt = 0
int gausakt = 0
int plasmaakt = 0
int rakneu = 0
int llneu = 0
int gausneu = 0
int plasmaneu = 0

//TF ausrechnen.
for(ship in ships)
{

if (getNumberOf(ship,planet) == 0){}
else{
tfmet = tfmet + getPrice(ship, planet).getMetalValue()*getNumberOf(ship,planet)
tfkris = tfkris + getPrice(ship, planet).getCrystalValue()*getNumberOf(ship,planet)*(met/kris)
}
}

tfkris = tfkris + getNumberOf(SOLARSATELLITE,planet)*getPrice(SOLARSATELLITE,planet).getCrystalValue()*(met/kris)
tfmet = tfmet*tf
tfkris = tfkris*tf
//printOut "-------------TF---------------"
//printOut tfmet + " Met " + tfkris + " Kris"

//Loot berechnen.
lootmet = planet.getMetalProduction()*loot*(24*dayprod)
lootkris = planet.getCrystalProduction()*loot*(met/kris)*(24*dayprod)
lootdeut = planet.getDeuteriumProduction()*loot*met*(24*dayprod)
//printOut "-------------LOOT-------------"
//printOut lootmet + " Met " + lootkris + " Kris " + lootdeut + " Deut"

gesMSE = tfmet + tfkris + lootmet + lootkris + lootdeut
verviel = gesMSE/135000
printOut "Verviel " + verviel
printOut "-------------DEFneeded--------"
rakneu = rak*verviel
llneu = ll*verviel
gausneu = gaus*verviel
plasmaneu = plasma*verviel

 rakakt = getNumberOf(ROCKETLAUNCHER,planet)
 llakt = getNumberOf(LIGHTLASER,planet)
 gausakt = getNumberOf(GAUSSCANNON ,planet)
 plasmaakt = getNumberOf(PLASMATURRET,planet)
 rakneed = rakneu-rakakt
 llneed = llneu-llakt
 gausneed = gausneu-gausakt
 plasmaneed = plasmaneu-plasmaakt

if(getNumberOf(SMALLSHIELDDOME,planet)==1){klschildneed = 0}
else {klschildneed = 1}
if(getNumberOf(LARGESHIELDDOME,planet)==1){grschildneed = 0}
else {grschildneed = 1}
if(rakneed<=0){rakneed=0}
if(llneed<=0){llneed=0}
if(gausneed<=0){gausneed=0}
if(plasmaneed<=0){plasmaneed=0}
printOut "Raketenwerfer: " + rakneed
printOut "Leichter Laser: " + llneed
printOut "Gauskanonen: " + gausneed
printOut "Plasmawerfer: " + plasmaneed
printOut "Kleine Schildkuppel: " + klschildneed
printOut "Grosse Schildkuppel: " + grschildneed

def investDef = [
SMALLSHIELDDOME: klschildneed,
LARGESHIELDDOME: grschildneed,
PLASMATURRET: plasmaneed,
GAUSSCANNON: gausneed,
LIGHTLASER: llneed,
ROCKETLAUNCHER: rakneed,
]

if(klschildneed == 0 && grschildneed == 0 && plasmaneed == 0 && gausneed == 0 && llneed == 0 && rakneed == 0){}
else{
investInShipsDefences(investDef, planet)
}
printOut "-----------------------------"
}
}

}
« Last Edit: September 25, 2014, 09:20:18 AM by Holz1692 »
Logged

nuhll

  • Full Member
  • ***
  • Offline Offline
  • Posts: 151
    • View Profile
Re: Def Calc
« Reply #12 on: September 26, 2014, 06:31:46 PM »

Does it build it as "Maintain Quality"?
Logged

Holz1692

  • Newbie
  • *
  • Offline Offline
  • Posts: 31
    • View Profile
Re: Def Calc
« Reply #13 on: September 27, 2014, 04:34:09 PM »

nope.
Logged

nuhll

  • Full Member
  • ***
  • Offline Offline
  • Posts: 151
    • View Profile
Re: Def Calc
« Reply #14 on: September 29, 2014, 10:14:49 PM »

works perfect, great to reduce res on planets. THANK you very much.

1. I would like to see that he looks at the builder quene like, oh next building need 1mio met, so i will let 1mio there.

OR

2. Is there a way to let it only run every 2. day?

3. I found a bug btw, u cant start it on 24 == 0

4. Why so much ll btw? (http://ogame.wikia.com/wiki/Defense_Build_Strategies) is your strategy better?

5. Could u add these missles which you need to protect and maybe a way to (re) build it faster when someone attacks you. Like check every 5 min if you could build some missles.

6. do i understand it correct, if i have always the same amount of res on planet it wont build infinite def?
« Last Edit: September 29, 2014, 10:28:44 PM by nuhll »
Logged
Pages: [1] 2 3
 

Page created in 0.033 seconds with 21 queries.