for passnumber = 1, number of asteroids do
if distantroid is in the North East Quadrant compared to checkedroid then:
summedvectorx = summedvectorx + x[passnumber]
summedvectory = summedvectory - y[passnumber]
end
if distantroid is in the North West Quadrant compared to checkedroid then:
summedvectorx = summedvectorx - x[passnumber]
summedvectory = summedvectory - y[passnumber]
end
if distantroid is in the South East Quadrant compared to checkedroid then:
summedvectorx = summedvectorx + x[passnumber]
summedvectory = summedvectory + y[passnumber]
end
if distantroid is in the South West Quadrant compared to checkedroid then:
summedvectorx = summedvectorx - x[passnumber]
summedvectory = summedvectory + y[passnumber]
end
end
for i = 0,numAsteroids do
for j=i+1,numAsteroids do
ForceMatrix[i][j] = Fg
ForceMatrix[j][i] = Fg
end
end
ForceVector = Fg * NormalizedVector(PosChecked - PosDistant)
Here ForceVector, PosChecked and PosDistant all are 2D vectors (ie. a pair of x-y components) but not Fg.x part of force = Fg * xdiff / sqrt(xdiff^2 + ydiff^2)
y part of force = Fg * ydiff / sqrt(xdiff^2 + ydiff^2)
Code: [Select]x part of force = Fg * xdiff / sqrt(xdiff^2 + ydiff^2)
y part of force = Fg * ydiff / sqrt(xdiff^2 + ydiff^2)
Code: [Select]x part of force = Fg * xdiff / sqrt(xdiff^2 + ydiff^2)
y part of force = Fg * ydiff / sqrt(xdiff^2 + ydiff^2)
This code would erroneously produce a positive number every time. In fact, sometimes the forces should be negative - if the overall force is pulling "south", for example, the value of Y part of Force should be negative. Hence quadrant checking still seems essential.
No, it won't be positive all the time, because xdiff and ydiff are not always positive. If asteroid B is to the left of asteroid A, then xdiff is negative and otherwise positive. Similarly for ydiff. Another important point is that you can't really do it any other way, you have to see how far into the quadrant the asteroid is. That more or less boils down to my equations.
for j = 0,0 do
--COLUMN
for i = 0,roidnumber do
--ROW
for j = (i + 1),roidnumber do
-- calculate!!
end
end
Code: [Select]for i = 0,numAsteroids do
for j=i+1,numAsteroids do
ForceMatrix[i][j] = Fg
ForceMatrix[j][i] = Fg
end
end
-- Asteroid 1 - Mercury
-- gravity variables
AccelerationX[1] = 0
AccelerationY[1] = 0
MomentumX[1] = 5.2
MomentumY[1] = 0
density[1] = 1
CoordX[1] = 0
CoordY[1] = 2700
roidradius[1] = 250
-- Creation
a = AddAsteroidWithAttribs(CoordX[1],CoordY[1],0.5,0.5,0.5)
a.Owner = 1
a.TreeCap = 4
a:SetRadius(roidradius[1])
a:Reveal(1)
-- Asteroid 2 - Venus
-- gravity variables
AccelerationX[2] = 0
AccelerationY[2] = 0
MomentumX[2] = -4.1
MomentumY[2] = 0
density[2] = 1
CoordX[2] = 0
CoordY[2] = -4200
roidradius[2] = 325
-- Creation
a = AddAsteroidWithAttribs(CoordX[2],CoordY[2],0.5,0.5,0.5)
a.Owner = 1
a.TreeCap = 4
a:SetRadius(roidradius[2])
a:Reveal(1)
for pass = 0,roidnumber do
for pass = 1,roidnumber do
wouldnt the best solution, without writing brand new script, to be to slow down the rotation of the roids to the point where all the seeds will plant themselves? this seems the most obivous solution to me. but then, i have no idea how it all really works. i just know that if the planets are going too fast for the seeds to plant, slow it down until they do.
no?! :o
I have plans to add asteroid collision detection in the future. Rather than bounce off each other, I am tempted to make them "merge" into a single, larger asteroid - rather like 2 drops of raining winding their way down a car windscreen, touching, and then "popping" together as the surface tension between them collapses.That would be so AWESOME! It would definitely come up with intriguing new maps to play. ;D
This would then be used in a map where the initial conditions consist of hundreds of tiny asteroids moving in random directions. These tiny asteroids collide with one another, combining to form larger asteroids that fall into a natural orbit around one another.
In my view this approach results in a shortfall of awesomeness.
With regards to slowing the asteroids down so seeds can plant themselves.
I found that in order to get this to work, the asteroids need to slow down to such a degree that it's barely possible to tell they are moving at all, much less work out if they are in a stable orbit or not. In my view this approach results in a shortfall of awesomeness.
That would be so AWESOME! It would definitely come up with intriguing new maps to play. ;D
But, if you do have the mathematics required to make it work, it would still need a LOT of trial-and-error to create a proper, playable map. Here are some of the various problems I've thought of:
1: What will the stats of the resulting asteroid be when 2 smaller ones collide?
2: What will the behaviour of any seedlings/trees be when the roid they're on collides with another?
3: What will happen when an asteroid is flung out of the system (which is extremely likely to occur)?
4: What will happen when roids that belong to different EMPIRES collide and merge?
5: What if you place too many asteroids, and the gravity engine can't cope with hundreds of asteroids colliding and recolliding, and constantly changing size and distances to other asteroids?
What about increasing the speed of the seedlings which are being planted?? :-\
[..]Sounds like a GOOD THING to me ;D
I am having some trouble integrating the AI from Infected Empire into the map. The AI seedlings don't seem to want to expand to their empty asteroids..
[..]
Hmm, maybe I can't check values with == GetAsteroid().TreeCap ...
Will try setting treecap with a declared variable tomorrow...
By the way the level is currently 1600 lines and 42kb making it the largest ever level, again :PWhen will it be realesed ????????????
Tom, you can change THIS HERE if you need to cheat again
;D
Incidentally I have a bet on with my cousin that I wouldn't be able to create a gravity engine and simulate the solar system, without resorting to getting planets to move in predefined circles.
So far I have Mercury, Venus, Earth, Luna, Mars, Jupiter, Io and Europa.
Yeah, he's gonna lose that bet. Heh.
No money... instead he will be forced to eat my proverbial hat, which I threw over a gigantic wall at the beginning of April. :>lol
Wildly unbalanced but the AI just successfully wiped Smokey out, using huge armies carried from distant galaxies;D
594 minimum on interaction 4 at 630 sec
it was about 240 on the wrong side. i increased the density from 75 to 95
reduced it by 2
it was close, but didn't curve round far enough.
increased it by 3... now it's 966, up from 963.
that time it flung it too far round.
was 966, now 9659
that time it was _just_ on the wrong side
uhh..... ok, guess i'll try 9659 again
no change, new variable works good.
trying 96595
no big change.
need to try something drastic to get an idea which direction to push in.
i will try 96610
badly wrong direction.
trying drastic in the opposite direction then. 96580
no big change. trying 96570
still no big change...weak.... trying 96550
STILL no big change... they might be a bit closer together though.
Trying 96350
oooh!! That made them collide!
Just a bit more... trying 96330
Getting there now. Need a little bit more tho.
Trying 96270
looking very good now. but it's still a bit too much.
trying 96220
right, that was good. 4th interaction WORKS!!
after 2 more suns, the asteroid goes spinning up to the north-east asteroid instead of heading to the middle.
i have thought about it and reducing it further should fix this. however, the increments must become small now.
trying 96210
ok that time they went more diagonal instead of straight up, so we are going in the right direction :>
maybe try reducing by roughly the same amount again...
so.... trying 96195
uh... i reduced it too much, i think...
trying 96205
still too much. trying 96201
They collided!
Still too much. 96199?
Nope. 96198?
wrong side now.
trying 96208
correct side, but still far from each other.
trying 96207
still quite far from each other. 699 distance away
trying 96206
like 560 that time. they got closer!
trying 96204
they got even closer that time, it seems. started bending more.
trying 96203
ok they were only 100 or so away from each other that time!
962025
nope, needs to bend further.
96202
dude!! almost there!!!
trying 962015
looking good, that's a successful 5th interaction. good job druids!
it comet is going the wrong way around sun #2 after the transitition, lowering a bit more to curve it around
trying 962005
that was too far - try 962014 next
they basically bounced off each other that time
14 is still bringing them too close together
so gonna try 149
trying 9620149
wrong!"!!! seedingn n00b druid
trying 96201495
trying 1520
stupid druid!!
trying 1510
nope, still landing on the wrong side of sun #2
trying 1503
ok i think i have been going in the wrong direction
now i will try 96201600
yeah i was indeed going in the wrong direction. gradually increase the density to
bring the comets closer and closer to the first sun's corona
trying 96201675
that was good - first time with 5th interaction 2nd sun correct side!!
need to increase it slightly more
trying 96201705
today i will try 96201725
that seemed to work pretty good... but watch this one again when i wake up.
i'm not too sure whether need to increase or decrease at this point...too tired
ok. it's morning now. i have watched the interaction.
it sends it successfully around both suns, and into a 6th interaction! This is
great news. Good job druids.
Now I should set Fish Time to 1150. that should wake me up just before the 2nd sun
prior to interaction 6.
Now, as to the value. That time, they were slightly on the wrong side of each other
96201725 = slightly wrong side
lets try 96201721 and see if decreasing it slightly works well.
ok, that time they collided! so that's going in the right direction, it seems.
Trying 96201713
ok, that was on the right side...but they didn't pass close enough to each other.
So I've gone a little too far.
Trying 96201717
they were close to each other that time... but need to be very slightly closer..
Trying 962017185
that produced a successful interaction. watching the orbits...
ok it flung them a bit hard
they came a bit too close together i think
yeah
Eh, we need a new convention.
17185 before
they were being flung too hard, not getting close enough.
So i need the suns to make them cling closer, to prise them slightly further
apart during the interaction. so i'll increase to 17188
still flings them rather hard. lets see... yeah... he goes WAY round the first sun
he's not coming back anytime soon.
um, it's this counter-intuitive thing again... i need to decrease it
isntead of increasing it...
lets try 17182
this time they come a bit too close to the sun...
going straight through the middle of the corona, very close...
ok so i took it a bit too far.
try 171835
this curve looks more like it :>
went round the first sun nicely. lets see how it lands on the second...
that makes it go all the way around, but they are comets fly on the wrong side
of one another on the next interaction.
lets try decreasing the value very carefully
try 171833
they were still on the wrong side from one another. 782 from the center at y = 0
trying 171838
woah. OK. that time they practically collided. increasing seems the way forward !
still on the wrong side, sligthyl...
uh... setting a new fish timer of 1200
lets try 1718385
they were on the wrong side of each other by about 248
lets 1718405
that time they were over 2000 apart!
but on the right side, i think...
so lets try a much smaller increase...
1718388
ok, they were like 150 on the wrong side.
trying 1718394
ok...that time the interaction BEFORE didnt work... :S
they seemed to come on the right side, but far far too close
trying 1718388 again, just to confirm they have a successful first
interaction and come 150 on the wrong side on the second one
ok...yeah...it worked as described before. hmmmmm....
guess i will try 1718389
that time it was 209 on the RIGHT side...
trying 17183887
was a little way on the wrong side
17183889
they pass close to each other on the right side, but not close enough...
171838885
they got within 206 of each other, in the right side...
ok, so seems like im reducing too slowly.
trying 171838865
that time they were wrong side
ok...
17183879
wrong side, by like 50...
171838881
that time they were on the right side, by like...tons...
so ah... 1718387925
wrong side, by about 50... >.<
171838798
wrong side, by bugger all, again.
giving up for tonight.
read over notes. trying 171838883
also added interaction counter
proved game pausing doesnt affect asteroid orbits
interaction 5 works
interaction 6 seems to work..
interaction 7 fails - they are on the correct side but a bit too far
apart
ok, now should be easier to troubleshoot :> try some new values when i
get back and lets see how we can steer it at interaction 7...
trying 171838888
interaction 6 works fine...
interaction 7
they were on the right side of each other, but 206 apart
need to find the distance after a change
trying 171838898
i have increased it by 10 basically
looking to see whether they are further apart than 206 this time
to figure out which direction to change in
....ok, that time they were 206 apart as well :/
trying 1718389
maybe i can get 1 more interaction to work...
correct side, 206 away...AGAIN
trying 171839
that causes them to be wildly too far apart, on the right side though.
so im guessing if i try 171837, which is the other side of the "most accurate
so far", it's going to be too much on the other side.
ok i haven't actually tried 171837
i guess i should try it, just to see what happens
this appears to be the very limit of the accuracy possible
good job all druids who participated in this project
we're at the end now. lets confirm it.