Author Topic: Logic map for a level I'm working on...  (Read 21403 times)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Logic map for a level I'm working on...
« on: March 15, 2010, 08:59:29 AM »


Embedded in a while GameRunning() loop, each game "cycle" an asteroid belonging to the AI is selected at random, and a series of logical checks are made as shown in the flow chart above, ultimately resulting in action or inaction.

The code for this is about 50% complete.  The code must be 100% complete before a significant testing and adjustment period will begin.

Hope to have a new map with a brand new AI ready within the next few weeks.. :>

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Logic map for a level I'm working on...
« Reply #1 on: March 15, 2010, 08:58:02 PM »
Good luck with this, I am going to get back on the wagon soon hopefully and maybe some of the functions you've asked for will go in and help you with this.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Logic map for a level I'm working on...
« Reply #2 on: March 16, 2010, 05:58:21 PM »
Awesome :>  Really looking forward to being able to create a solar system, I have the maths for it all figured out already.  :>  I am also quite tempted to try to create a reusable mathematical model of gravity.  Technically it's already possible to calculate gravitational forces acting on each asteroid, but moving asteroids would be needed in order to reflect it.


Anyway, for now I am still working on this new AI.  Last night I finished off the extremely complicated metric calculation section, which is responsible for identifying which paths the AI might like to send a given asteroid's seeds along.  It has a lot of similarities with computer networks, actually..

In terms of coding the actions, I've covered every possible branch up to the "Elligible for reinforcing other roids!  Is my torch metric nil?" part.  So currently the AI is still pretty useless - it will make its asteroids "call for help" if attacked, but it won't send seedlings to assist neighbouring asteroids when they call for help.  It will build the maximum number of trees on its starting asteroid(s), but it will never send seeds out to colonise a new asteroid.  Neither will it send an army to defend an asteroid attacked by the player.  Neither will it hold elections to set a gather point, or attack any of the player's asteroids.

I also realised the AI is vulnerable to having its empire split.  If one part of the empire has no way of reaching the other half, whichever half has the gather point will be the only half used for attacks against the player.  This gets to be a real problem if one AI asteroid is left on its own.  It could potentially win a gather election and become the new gather point, but with no friendly neighbours it will be inaccessible to the seedlings in the rest of the AI's empire, and they will simply wait at their asteroid of birth until the player tries to attack, at which point they will respond.
The point is that the attack-the-player functionality will be severely compromised if this situation arises.  I will need to think of a good way to figure out whether a split has occurred, and which side of the split is largest.  Quite tricky when the code is designed to only analyse one asteroid at a time..



I don't really expect anyone to read this by the way, but I need to type this out so I remember all this stuff tonight :P

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Logic map for a level I'm working on...
« Reply #3 on: March 17, 2010, 06:13:53 PM »
Finished the initial coding last night.  I'm using a previous level I made as a test bed for the AI code, which is now over 500 lines.  Fired the level up and it didn't load at all due to syntax errors.  :P

So I fixed all the syntax errors, and then the level loaded, and predictably the AI did nothing at all.  Absolutely squat.   :>

So I spent some time bugfixing and then the AI built 3 trees on his asteroid, but for some reason would not build a 4th.

After a bit more time messing about with it I've managed to get them to build 4 trees....not sure what was wrong with it before but at least there is the expected behaviour now.  Unfortunatley after it has built 4 trees, the AI does nothing.  This is most likely because of 2 key sections I have had to comment out because they were causing the While loop to break.


So currently the AI is not really working... maybe tonight I will figure out how to make the other sections work and then with any luck I will be left with an AI that is merely very stupid.  :D
Then for some tuning, and hopefully stupidity level will decrease...

lecutus88

  • Shoot
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
Re: Logic map for a level I'm working on...
« Reply #4 on: March 17, 2010, 07:48:46 PM »
Can I ask what you do for a living, please?  Your coding knowledge and logical approach does you massive credit, not to mention your creativity and tenacity!   I dabble in code myself and know it can be addictive, but struggle for time to engage in anything has heavy as Eufloria levels!

Koss

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
Re: Logic map for a level I'm working on...
« Reply #5 on: March 17, 2010, 10:13:15 PM »
I don't really expect anyone to read this by the way, but I need to type this out so I remember all this stuff tonight :P
Thanks for you work. You levels are awesome ! Look forward for next level.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Logic map for a level I'm working on...
« Reply #6 on: March 18, 2010, 12:54:03 AM »
Can I ask what you do for a living, please?  Your coding knowledge and logical approach does you massive credit, not to mention your creativity and tenacity!

Thanks for the kind words :>  I am half Independent Computer Consultant, half Network Administrator and System Administrator.  The arrangement is a little complicated but to put it simply, I fix and maintain computers for my day job.


Quote
I dabble in code myself and know it can be addictive, but struggle for time to engage in anything has heavy as Eufloria levels!

Eufloria level design is only heavy going if you want it to be.  :>  One of the things that attracts me to Eufloria as a means of creative expression is the enormous and often very visual effect a single line of code can have.  For that reason, it's extremely satisfying to code a level.

If you check out the sticky guide on this subforum, you can learn how to make basic levels in under an hour.  Some really dramatic effects like changing the colour of the background, are actually incredibly simple.

If you've coded anything in any language before, even if it was "hello world!" in BASIC, you will have no problems whatsoever with coding Eufloria levels.  And besides, if you have any problems, you can come ask us here and with any luck we'll be able to help.  :>

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Logic map for a level I'm working on...
« Reply #7 on: March 27, 2010, 07:10:54 AM »
w00t, just got the AI to send seedlings to neighbouring asteroids that need seeds.  Unfortunately the AI still doesn't actually attack, but it's a lot smarter than it was before.. :>

Rudolf

  • Administrator
  • Old Oak
  • *****
  • Thank You
  • -Given: 5
  • -Receive: 13
  • Posts: 669
  • Eufloria: Yes
Re: Logic map for a level I'm working on...
« Reply #8 on: March 27, 2010, 07:12:43 PM »
Can I ask what you do for a living, please?  Your coding knowledge and logical approach does you massive credit, not to mention your creativity and tenacity!

Thanks for the kind words :>  I am half Independent Computer Consultant, half Network Administrator and System Administrator.  The arrangement is a little complicated but to put it simply, I fix and maintain computers for my day job.


Quote
I dabble in code myself and know it can be addictive, but struggle for time to engage in anything has heavy as Eufloria levels!

Eufloria level design is only heavy going if you want it to be.  :>  One of the things that attracts me to Eufloria as a means of creative expression is the enormous and often very visual effect a single line of code can have.  For that reason, it's extremely satisfying to code a level.

If you check out the sticky guide on this subforum, you can learn how to make basic levels in under an hour.  Some really dramatic effects like changing the colour of the background, are actually incredibly simple.

If you've coded anything in any language before, even if it was "hello world!" in BASIC, you will have no problems whatsoever with coding Eufloria levels.  And besides, if you have any problems, you can come ask us here and with any luck we'll be able to help.  :>

That is the idea behind the inclusion of LUA. There is so much you can do with it that you won't run out of possibilities anythime soon, yet if you want to make something low on code it is still easy to just change some parameters and add a novel win/lose scenenario and you have a whole new level or level concept.

We will start talking about a modding competition soon, so I expect that this wwill see some very original entries :-)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Logic map for a level I'm working on...
« Reply #9 on: March 27, 2010, 10:14:34 PM »
Fixed another major bug in the AI code, AI is getting smarter..
Still won't attack, but is extremely efficient at expanding its empire now.

Bonobo

  • Achiever
  • Old Oak
  • ****
  • Thank You
  • -Given: 139
  • -Receive: 12
  • Posts: 670
  • Eufloria: Yes
Re: Logic map for a level I'm working on...
« Reply #10 on: March 27, 2010, 10:40:47 PM »
OMG I think I won't be able to win ANY of your future levels ;)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Logic map for a level I'm working on...
« Reply #11 on: March 28, 2010, 04:29:20 AM »
Now the AI expands super-efficiently, and has a limited response from neighbouring asteroids if attacked.  Getting there...

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Logic map for a level I'm working on...
« Reply #12 on: March 28, 2010, 05:34:04 AM »
Sweet!  Now the AI responds very promptly and intelligently galaxy-wide when one of its asteroids is attacked :>


Still to fix is the attacking-the-player code, and I also want to implement some crazy maths in the path detection section to prevent paths that involve flying through player asteroids from being considered as valid paths.

This AI should work on any map, by the way... the only precondition is that the AI must own all the "empty" asteroids at the start of the game.  Any asteroids that are owned by nobody (or "player 0") will be ignored.
The map I am testing it on is the Day & Night map, and I can adjust the number of asteroids in the spiral galaxy simply by changing 1 variable.  The AI works equally well on a galaxy of 20 asteroids as it does in a galaxy of 80 asteroids.  :>

Bonobo

  • Achiever
  • Old Oak
  • ****
  • Thank You
  • -Given: 139
  • -Receive: 12
  • Posts: 670
  • Eufloria: Yes
Re: Logic map for a level I'm working on...
« Reply #13 on: March 28, 2010, 06:11:04 AM »
Annik, you continue to amaze me.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Logic map for a level I'm working on...
« Reply #14 on: March 28, 2010, 06:24:22 AM »
Check this out guys !


Bonobo

  • Achiever
  • Old Oak
  • ****
  • Thank You
  • -Given: 139
  • -Receive: 12
  • Posts: 670
  • Eufloria: Yes
Re: Logic map for a level I'm working on...
« Reply #15 on: March 28, 2010, 06:31:33 AM »
Graaaaaaah, I'll never be able to win of your coming levels :o here's hoping that you'll also some goodies for kids and senior gamers then  ::)

<edit>

But to be serious: This looks grandious, and it makes me fear your AIs.

</edit>

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Logic map for a level I'm working on...
« Reply #16 on: March 28, 2010, 07:41:51 AM »
My levels will have a range of difficulties... :>

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Logic map for a level I'm working on...
« Reply #17 on: March 28, 2010, 10:09:48 AM »
AI now gathers seedlings on a nearby asteroid and, when it has a swarm of sufficient size, attacks.

Need to fix a pathing bug, and substantial extra testing for bugs needed... and then I need to implement that don't-run-through-player-asteroids thingy...
almost there.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Logic map for a level I'm working on...
« Reply #18 on: March 28, 2010, 10:47:49 AM »
Pathing bug corrected.  The AI also now sets a new gather point when the old one is no longer relevant.

The AI still sometimes sends seedlings on paths that take them past the player's asteroid, resulting in all the AIs seedlings being killed.
Also, the AI sometimes doesn't send all its seedlings to a particular gather point.

Once these two problems are fixed, it should be pretty deadly :>

Bonobo

  • Achiever
  • Old Oak
  • ****
  • Thank You
  • -Given: 139
  • -Receive: 12
  • Posts: 670
  • Eufloria: Yes
Re: Logic map for a level I'm working on...
« Reply #19 on: March 28, 2010, 11:13:39 AM »
Annik-Sensei, would it be possible to sort of "attach" some of this artificial intelligence to a human player, so I could perhaps "delegate" tasks like gathering somewhere? Otherwise it seems that the AI could have this advantage of your automatizations which the human player doesn't have. Or do I misunderstand something?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Logic map for a level I'm working on...
« Reply #20 on: March 28, 2010, 12:47:10 PM »
Yes it would be possible to instruct the player's seedlings to do things too.  You would need some way to trigger it, though... and that's not easy.

One thing I did consider was having the player's seedlings always rally to whichever asteroid contains the highest number of player seeds.  That way the player's seedlings would naturally congregate wherever the largest player swarm was.  I'm not sure how fun that would be though...  If you don't spend any time gathering up seedlings, what are you going to spend your time on, exactly ?  Eufloria is designed to involve constant micromanagement of your asteroids, if you want a game with rally points and the ability to select all your troops at once then Warcraft 3/Starcraft/Command & Conquer is going to be more your thing.  Just my 2c there..



The AI doesn't react quite instantly... it takes about half a second or so.  Reaction times go up a little when the level has a lot of asteroids.  The AI gets the advantage of being able to reorganise all its seedlings very quickly, and being able to react very fast.  The human player gets the advantage of being able to see seedlings as they fly between asteroids (something the AI is not capable of), and in theory should be better equipped to make good tactical decisions.

If my AI consistently beats human players when the human and the AI start with the same number of seedlings, that will be a great success.  If the AI only needs 2-3 times as many seedlings at the start in order to defeat the player, that's a moderate success.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Logic map for a level I'm working on...
« Reply #21 on: March 29, 2010, 02:22:26 AM »
My flatmate is beta testing the AI now.  He starts with 1 dyson tree, 1 defence tree, and 80 seedlings on one asteroid near the center.  The AI starts with 248 seedlings scattered on the 8 periphery asteroids in the spiral galaxy, which numbers 25 asteroids in all.

So far it's pretty even...  only 15 mins into the game though.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Logic map for a level I'm working on...
« Reply #22 on: March 29, 2010, 02:26:45 AM »
List of stupid things my new AI does:

1.  Allows a player mine to orbit one of his asteroids, happily zapping all seeds that are born there.  Better behaviour would be to set a torch metric of 0 to attract help from elligible nearby asteroids.
fixed.  I sorted this with a very simple method in the end.  The AI now responds thoroughly to mine attacks, which should be infrequent anyhow seeing as the flower chance is only 1.5%.

2.  Seriously vulnerable to having his empire split up.  If the gather point is in the smaller split, the larger split will simply not gather.
Fixed.  Seems to work good now.

3.  Uselessly continues to send seeds to a gather point when the player has a massive army nearby, resulting in a stupid cold war situation.  A better behaviour would be to detect this situation and hold a new gather point election, so that the AI moves his swarm to a different - hopefully less-well-defended location.
fixed. changes gather points often now, looking for weak spots.

4.  Sends seedlings on paths that take them past a player asteroid, resulting in their deaths.  Better behaviour would be to detect the presence of a player asteroid within the right range and direction (angle), and to use this information to prevent these types of routes from being added to the list of available paths.

5.  Lone, seperated "Orphan" asteroids become inactive.  The AI requires at least 2 asteroids within send distance of one another in order to create a functioning metric network.  Need to add some code to force orphans to do something with their seedlings.
fixed.  Orphans will now judge their situation and either send their seedlings to bolt towards a friendly asteroid by bouncing off a convenient player asteroid, or attack the nearest player asteroid and try to capture it to create a new metric network.  The AI can now be knocked all the way back to 1 asteroid, and if then left to recover can still come back to take over the entire galaxy.

6.  The AI stupidly uses all his seedlings to build trees, even if the player has a large number of seedlings on a neighbouring asteroid ready to take the AI's asteroid as soon as he's done building 4 trees.  Up until last night this was the only way to beat the test map that I am aware of.
fixed.  The AI now detects this situation and stops building trees until he has more seedings, so he can keep some for defence.  The player must move their swarm away from the AI's asteroid for at least 90 seconds before he will stop being ultra-conservative and start building normally again - by which time the player's tactic is going downhill as this has given the rest of the AI's asteroids time to build up lots of trees.  Only threatened asteroids will display this behaviour - others will continue to build as normal unless they too are threatened by a nearby player swarm.

7.  Tries to take out an asteroid with 0 seedlings and 4 defense trees, using only 50 seedlings.
fixed.  AI now takes the number and type of trees on the target planet into account when deciding how long to wait and build up a bigger swarm before attacking.
« Last Edit: April 01, 2010, 06:40:15 AM by annikk.exe »

njursten

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 31
Re: Logic map for a level I'm working on...
« Reply #23 on: March 29, 2010, 06:03:49 AM »
No. 1 is probably hard to fix. You'd want to set up a temporary gather point at a neighbouring asteroid to overwhelm the mine in one go.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Logic map for a level I'm working on...
« Reply #24 on: March 29, 2010, 06:29:31 AM »
Actually with the way the torch metric works, its such an absolute flood of seedlings that comes to the stricken asteroid's aid that i dont think a seperate pre-mine-attack gather point would be necessary.  I've not tried fixing that yet though...  I guess I'll see what it's like once I have, and then decide :>


This AI is fairly scary now..

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Logic map for a level I'm working on...
« Reply #25 on: March 30, 2010, 08:04:55 AM »
I am having second thoughts about my solution for mines now.  Maybe gathering up on an adjacent asteroid would be a good idea....  I think I could probably hitch that onto the torch metric, and tell seedlings to go as far as the metric 1 asteroids but no further...until they are of suffient number to safely wipe out a mine.  I can check that when the asteroid with the mine on it is selected, by checking the pathsavailable array and counting the seedlings ready to fly in and take out the mine.  If the mined asteroid sees, say, > 80 seedlings orbiting its neighbours asteroids, it can give the signal to each of them to gogo and they will all come at once.

This thread is kind of turning into a development blog...  but at the moment I'm just sort of writing good solutions down whenver I think of them.  The beta test map I'm currently working with gives the AI with almost 4 times as many seedlings at the start as the player.  I really want to get that figure down and still make it hard..

lecutus88

  • Shoot
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
Re: Logic map for a level I'm working on...
« Reply #26 on: April 01, 2010, 08:19:43 PM »
Hi!

Without wanting to come over all impatient, do you have any idea when your next level will be released into the wild?  (Deliberate choice of words here!   :-)     )

Thanks in advance!


Neil

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Logic map for a level I'm working on...
« Reply #27 on: April 02, 2010, 12:39:38 AM »
Looking like Saturday at the moment :>

Rudolf

  • Administrator
  • Old Oak
  • *****
  • Thank You
  • -Given: 5
  • -Receive: 13
  • Posts: 669
  • Eufloria: Yes
Re: Logic map for a level I'm working on...
« Reply #28 on: April 03, 2010, 09:50:27 PM »
This thread is kind of turning into a development blog... 

That is a good thing I think. Basically you are doing an "advanced AI mod", which is a process that is interesting in its own right, beyond the endproduct. (which is highly anticipated :-)  )

Blog away dude!

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Logic map for a level I'm working on...
« Reply #29 on: April 03, 2010, 10:57:34 PM »
Going public this evening :>