You are not logged in.

Dear visitor, welcome to OGame.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Beaster

Unregistered

1

Thursday, April 22nd 2010, 7:47pm

Construction time formula

Hey guys i am trying to build a graviton calculator for Electra (Redesign 4X) but i am having a hard time using the time calculation formula ...



$time = $crystal/(2500*(1+$_POST[shipyard])*"2".$_POST[nanite]*$_POST[speed]);



This string is supose to return the time in hours it takes to build solar satelites ... but it returns false data ...



I also tryed



$time = ((($crystal) / 5000) * (2 / (($_POST[shipyard]) + 1)) * (0.5 ^ ($_POST[nanite])))/$_POST[speed];



But it also returns bad data ... a little help would be apretiated thx

LionHTB

There're many behind me...but still some ahead

Posts: 1,290

Date of registration: Dec 4th 2008

  • Send private message

2

Thursday, April 22nd 2010, 7:59pm

Construction times:

Ships and Defense, in hours:
((metal + crystal) / 5'000) * (2 / ((level shipyard) + 1)) * (0.5 ^ (level nanite factory))

EDIT: oh, you have the formula

there's no mention of the number of solar sats?
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are God. Whereas owners of cats are compelled to realise that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods." -Christopher Hitchens

This post has been edited 2 times, last edit by "LionHTB" (Apr 22nd 2010, 8:02pm)


Beaster

Unregistered

3

Thursday, April 22nd 2010, 8:12pm

No from what i guessed it works with the total amount of crystal you spend ...


What i did was :
$crystal = $number_of_sats_needed * 2000;

Knowing 1 sat cost 2k crystall it's easy to get the total amount of crystall once you know how much sats needs to be builded ...

The formula provided looks like this when you enter numbers
(((20000000) / 5000) * (2 / ((10) + 1)) * (0.5 ^ (5)))/4

- Level 10 shipyard
- Level 5 nanite
- 20 million crystal (to build 10.000 solar satelites)
- Redesign 4X uni

It returns:
909.090909091 h

... Easy to see this is fake data lol

This post has been edited 1 times, last edit by "Beaster" (Apr 22nd 2010, 8:12pm)


jobebob

Unregistered

4

Thursday, April 22nd 2010, 8:55pm

you are using it wrong. The crystal used should be for one sat. Then you just multiply that time by the number of sats you need.

Kelder

----------------

Posts: 3,599

Date of registration: Jun 25th 2005

Location: Belgium

  • Send private message

5

Thursday, April 22nd 2010, 9:17pm

The time formula to build a solar sat is ((metal + crystal) / 5'000) * (2 / ((level shipyard) + 1)) * (0.5 ^ (level nanite factory)) (from Formula Thread v3)

From what I remember of PHP it would be something like this:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
// url like http://localhost/test.php?sy=12&n=5&sp=1&c=20

// Check that $_GET[x] or $_POST[x] is a number before using it in production code
$crystal = 2000;
$shipyard = $_GET["sy"];
$nanite = $_GET["n"];
$speed = $_GET["sp"];
$count = $_GET["c"];
$time = ($crystal / 5000) * (2 / ($shipyard +1)) * pow(0.5, $nanite) / $speed;
$time = floor($time * 3600); // maybe you need to round() instead of floor()
//  $time is now in seconds
if ($time < 1) { $time = 1; } // 1second is minimum time for any unit.
$time = $time * $count; // multiply time with number of units
$h = floor($time/3600);
$m = fmod(floor($time / 60),60);
$s = fmod($time,60);
echo "Time: $h h $m m $s s";
?>


The time for 2 sats is twice the time for 1 sat, not the time to make 1 sat of double cost. For small items that can make a big difference.


PS: usually $_POST[whatever] is first sanity checked (only numeric and with reasonable limits) before the relevant parts are copied to variables for use in a php script. Using unchecked user input in code can result in serious security issues.

Crimson King

Suggestion's (evil?) Gunslinger

Posts: 8,042

Date of registration: Nov 13th 2005

Location: The Dark Tower

  • Send private message

6

Thursday, April 22nd 2010, 9:24pm

What programming language are you writing it in?

If it is PHP, you have an error with your formula. You need to use the pow() function to define (0.5 ^ (nanite level). Proper syntax for the function would be pow(0.5,$_POST[nanite].
Your formula should look like:

Source code

1
$time = (($crystal) / 5000) * (2 / (($_POST[shipyard]) + 1)) * (pow(0.5,($_POST[nanite]))/$_POST[speed];

This should return a result of 5.6818181818182 hours

Also note that build time is never less than 1 second, regardless of uni speed, Shipyard, and Nanite levels.
:sniped:

@Jobebob:
You can get a cumulative time by multiplying the metal and crystal cost of the unit by the number of units you want to build. When the values are entered correctly, both come to the same result.
First comes smiles, then lies. Last is gunfire. - Roland Deschain of Gilead

Issues with a closed thread? Questions about a suggestion?
PM me.

Complaint about me or my modding? Contact my SMod, Florence

Co-author of Cumulative Cost, alongside kwinse.

Beaster

Unregistered

7

Thursday, April 22nd 2010, 11:37pm

Thx thats did it works like a charme now :-)

http://dramis.info/index.php?mod=graviton

8

Thursday, April 22nd 2010, 11:41pm

Two questions and a comment about your calculator there:
-What does being in a redesign uni have to do with energy production
-What does the lowest temperature have to do with energy production
-There is no option for engineer, which increases energy production by 10%

This post has been edited 1 times, last edit by "Durr" (Apr 22nd 2010, 11:41pm)


guitarplyr26

Unregistered

9

Friday, April 23rd 2010, 1:21am

durr, the reason the redesign is different is because sat production is calculated differently. and the lowest energy doesn't do anything, i think.

EDIT: btw, it just gave me the wrong info. my solar sats produce 35 energy each, but the calculator is converting the numbers as if they produce 30 each. i've put my info in correctly. i hand-calculated it twice and i'm getting the following info on my own:

Quoted

8.280 sats needed (6.9h total)
16.560.000 crystal
4.140.000 deuterium

and the calculator gives me this info:

Quoted

9.794 sats needed (9.5h total)
19.588.000 crystal
4.897.000 deuterium
(this is, of course, reformatted the way i had my stuff written). anyways i thought i should let you know that so you could make any fixes necessary.

This post has been edited 2 times, last edit by "guitarplyr26" (Apr 23rd 2010, 1:28am)


Kebab

omnomnom

Posts: 9,579

Date of registration: May 25th 2008

Location: England

Occupation: Perpetual Student

  • Send private message

10

Friday, April 23rd 2010, 1:28am

indeed energy from a sat is calculated differently in the redesign - i believe it uses average temperature instead of max temp but i could be wrong

but since beaster's question has been answered...
:qatc:



ty Ath <3

Former: GO, Mod/SGO @ .org| Mod, GO/SGO/GA @ .us | OGame Tech | Origin Admin