Author Topic: What are you working on? :D  (Read 36331 times)

0 Members and 2 Guests are viewing this topic.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 21
  • Posts: 1,492
  • They'll eat you next!
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #450 on: August 15, 2011, 02:37:56 PM »
I know what I wanna do!

Make two "circles" then make them scan if the touch eachother, I'll add a lua file soon to show what I mean :)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: What are you working on? :D
« Reply #451 on: August 15, 2011, 06:44:31 PM »
If the distance between their centres (pythagoras) is greater than the sum of their radiuses (just add them), they are not touching.  :>

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 21
  • Posts: 1,492
  • They'll eat you next!
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #452 on: August 15, 2011, 07:21:09 PM »
No, thats not what I've been making, I made a "planet"(to explain it simply) with one orbiting "asteroid", when two planets asteroids collide, they'll merge into one, and then, when they shouln't be colliding(the orbits aren't colliding) they separate. If you still don't understand, I'll show in the upcoming file :)

Though, I'm watching 2 1/2 men, so it'll take a little while :P

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 17
  • Posts: 904
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #453 on: August 15, 2011, 10:21:40 PM »
I just realised why my AI was exploring so well after only one time writing the explore code...

NONE OF MY CODE WAS RUNNING! IT WAS ALL THE BASIC AI!

...

...

...

...

...

I may be scavenging other AI codes.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 21
  • Posts: 1,492
  • They'll eat you next!
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #454 on: August 15, 2011, 10:33:06 PM »
Need help? Ask if you want :)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: What are you working on? :D
« Reply #455 on: August 16, 2011, 08:01:58 AM »
Bummer dude.  Need to set the grace timer to 99999 for all asteroids or something.  :>  Otherwise it's impossible to see if your AI is doing anything.


My overall advice for writing an AI is to make sure you have a good concept, preferably written down/in diagram form, of how the AI will make decisions on what to do.  It's not an easy thing to write, but hugely satisfying when you finally see it working.  :>

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 17
  • Posts: 904
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #456 on: August 16, 2011, 09:26:08 AM »
Is there any way of turning of AI for less than all of the empires?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: What are you working on? :D
« Reply #457 on: August 16, 2011, 09:33:42 AM »
In pseudo code:


Code: [Select]
-- empires 0 through 5 have default AI turned off

While Gamerunning do


for i = 0, number of asteroids do

-- AI is on by default
GetAsteroid(i).GraceTimer = 0

for j = 0, 5
if GetAsteroid(i).owner = j then
-- Asteroid belongs to a non-default-AI empire, so turn the default AI off
GetAsteroid(i).GraceTimer = 99999
end
end
end
coroutine.yield()
end

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 17
  • Posts: 904
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #458 on: August 17, 2011, 05:38:44 PM »
Is there any way of getting the number of asteroids in a map programmatically? My usual approach (infinite for loop) seems not to work...

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 21
  • Posts: 1,492
  • They'll eat you next!
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #459 on: August 17, 2011, 05:41:55 PM »
Do the for loop, then check is the GetAsteroid(id) ISN'T nil and then add one the the amount, if it is nil, do a break.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 17
  • Posts: 904
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #460 on: August 17, 2011, 05:42:46 PM »
That's what I usually do. Isn't working today.

EDIT: THis code should give a value to highroidID of 9. Instead it gives -1. If you change thae starting point of the for loop, it gives start-1.

Code: [Select]
function LevelSetup()
Globals.G.Asteroids = 10

for i = 0, math.huge do
    if GetAsteroid(i) == nil then
      highroidID = i - 1
  break
    end
  coroutine.yield()
  end
end

function LevelLogic()
MessageBox(highroidID)
end

Orion63

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 73
  • We are the Knights who say... NI!
Re: What are you working on? :D
« Reply #461 on: August 17, 2011, 05:47:49 PM »
Not tested:

Code: [Select]
numberOfRoids = 0
for empireID = 0, GetNumFactions() do

    numberOfRoids = numberOfRoids + GetEmpire(empireID):GetNumOwnedAsteroids()

end

That should work. But I am still kind of a newb in lua, so test it first.
« Last Edit: August 17, 2011, 05:51:25 PM by Orion63 »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 21
  • Posts: 1,492
  • They'll eat you next!
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #462 on: August 17, 2011, 05:48:42 PM »
Try set highroid to -1 before the loop then make it add one to itself each time a roid is spotted :)

See if it works atleast, worth a shot :)

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 1
  • -Receive: 21
  • Posts: 1,492
  • They'll eat you next!
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #463 on: August 17, 2011, 05:50:14 PM »
Not tested:

Code: [Select]
numberOfRoids = 0
for empireID = 0, GetNumFactions() do

numberOfRoids = numberOfRoids + GetEmpire(empireID):GetNumOwnedAsteroids()

end

That should work. But I am still kind of a newb in lua, so test it first.

Won't work, didn't even test to see the result!

This is because it's so visible in the math of computers :)
Pre set the variable to -1 not 0, cause if it's 0 you count human wise: -1 it's computer wise(computers love starting at 0 :))

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 17
  • Posts: 904
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #464 on: August 17, 2011, 05:52:38 PM »
Try set highroid to -1 before the loop then make it add one to itself each time a roid is spotted :)

See if it works atleast, worth a shot :)

Tried that, no luck. I even tried setting it to some massive arbitrary number, to see if that worked. Also no, if you were wondering.

[...]
Won't work, didn't even test to see the result!

This is because it's so visible in the math of computers :)
Pre set the variable to -1 not 0, cause if it's 0 you count human wise: -1 it's computer wise(computers love starting at 0 :))

Also, it won't work, but for a different reason. That code requires that every empire is checked, regardless of its existence. When a non-existend empire is searched, it returns nil and so tries to call a method on a nil value.
« Last Edit: August 17, 2011, 05:58:35 PM by Pilchard123 »