Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: AI creation challenge: Design an AI!  (Read 4149 times)

Octobomb

  • Bay Watcher
  • I like pens
    • View Profile
AI creation challenge: Design an AI!
« on: July 16, 2013, 07:57:28 pm »

So here's the idea. I drop your player character(s) into a situation, and you have to design an AI using a simplified version of psuedocode to create an AI for it. I then take some time to track actions until either the objective is completed, your character(s) killed or stuck in an infinite loop. I post the results and you either try again or move on. Challenges will range from 'Kill this goblin' to 'Fortify and hold this position' right up to 'Diagnose and fix a wide range of medical stuff' and even 'Build a 6 member rpg party'.

What is psuedocode?
A literal version of code - an example might be: 'If enemy is in Line of Sight: Shoot with gun.' In python (probably the simplest language) code that would be 'if enemyLoS == true: gun.shoot()' with half a page of setup. In fact, I can write it into psuedocode for you if I can understand it.

Coding things to know: if I talk about variables I mean things that can change eg. LoS to an enemy. If I talk about calling something, I mean using a command which has already been setup (I will provide a list), in this case gun.shoot(). I will add more as it needs to be added/ is asked, but for now, an example:

Example: A goblin stands next to you. Kill it. You have a gun.
Things you can call: CheckLoS, CheckEnemyHealth(when in LOS only), shootEnemy.
Variables: GoblinHealth
Code: while GoblinHealth is above 0: gun.shootenemy(goblin), then goblinCheckEnemyHealth(goblin)

A note on the brackets at dots: Using gun.shootenemy(goblin) as an example, we are calling shootEnemy with the gun, on the goblin.
I've probably way over complicated things, so don't hesitate to ask questions.

A very easy scenario to start you off:Land on the moon. Objects: Lunar Lander
Things you can call:
Spoiler (click to show/hide)
Variables:
Spoiler (click to show/hide)
Well, I've finished derping... For now... What do you think?
Logged
I saw 5 people with fedoras in my town yesterday.
They're the special biohazard containment agent, out to deal with m'laria.
Sig
Bay12's resident tea drinkers

b_boy_212

  • Bay Watcher
    • View Profile
Re: AI creation challenge: Design an AI!
« Reply #1 on: July 16, 2013, 08:11:10 pm »

if height > 1: decreaseheight()

I think thats the right format.
Logged
Dwarf Fortress doesn't mean to do it... I just can't behave sometimes so it has to correct me.

Kashyyk

  • Bay Watcher
  • One letter short of a wookie
    • View Profile
Re: AI creation challenge: Design an AI!
« Reply #2 on: July 16, 2013, 08:13:59 pm »

Software Engineer Undergrad here. I accept your challenge.

While height > 12: LunarLander.decreaseheight().

Edit: If you ever want help coming up with challenges, decyphering code or whatever, feel free to ask.
« Last Edit: July 16, 2013, 08:19:34 pm by Kashyyk »
Logged

Remuthra

  • Bay Watcher
  • I live once more...
    • View Profile
Re: AI creation challenge: Design an AI!
« Reply #3 on: July 16, 2013, 08:21:32 pm »

I'll join this, although I don't really know Python.

Octobomb

  • Bay Watcher
  • I like pens
    • View Profile
Re: AI creation challenge: Design an AI!
« Reply #4 on: July 16, 2013, 08:26:33 pm »

Wow... Just read what I posted... Too tired to fix it... But so far so good. The format is technically decrease height(Lunar Lander) but that's why I'm here.

*Mission Report*
The lander drifts slowly towards the surface of the moon. The lunar lander safely touches down at height 12.

Thanks very much for the offer. I'll be sure to pm you sometime.

There are 4 levers in front of you. Flipping the correct 2 reveals the treasure.
Things you can call:
Spoiler (click to show/hide)
Variables:
Spoiler (click to show/hide)
This one is harder, by quite a way, cos I'm tired.
Don't worry, Rethmura, hopefully it is relatively simple when later I tidy up the bombshell of an OP
« Last Edit: July 16, 2013, 08:39:12 pm by Octobomb »
Logged
I saw 5 people with fedoras in my town yesterday.
They're the special biohazard containment agent, out to deal with m'laria.
Sig
Bay12's resident tea drinkers

Remuthra

  • Bay Watcher
  • I live once more...
    • View Profile
Re: AI creation challenge: Design an AI!
« Reply #5 on: July 16, 2013, 08:32:41 pm »

Pickrandom(1,2,3,4)->x
Pickrandom(1,2,3,4)->y
If x==y, go to top
Pulllever(x)
Pullever(y)
If treasureopen=false, go to top
Else, end

EDIT: Random numbers aren't allowed :(.
« Last Edit: July 16, 2013, 08:38:54 pm by Remuthra »
Logged

Octobomb

  • Bay Watcher
  • I like pens
    • View Profile
Re: AI creation challenge: Design an AI!
« Reply #6 on: July 16, 2013, 08:38:02 pm »

Nope. I would suggest doing it sequentially - pull l1, then 2, check, 3, check etc. you can do addition and stuff. I'll demonstrate a rather convoluted way of doing it as a lesson for later challenges though once you are done. Also, I (will have) added a new thing you can call.
Edit: Wow! But it runs the risk of getting stuck in a loop
« Last Edit: July 16, 2013, 08:40:00 pm by Octobomb »
Logged
I saw 5 people with fedoras in my town yesterday.
They're the special biohazard containment agent, out to deal with m'laria.
Sig
Bay12's resident tea drinkers

b_boy_212

  • Bay Watcher
    • View Profile
Re: AI creation challenge: Design an AI!
« Reply #7 on: July 16, 2013, 08:43:22 pm »

wait did I type a 1? I meant 12. (facepalm)
Logged
Dwarf Fortress doesn't mean to do it... I just can't behave sometimes so it has to correct me.

LordBucket

  • Bay Watcher
    • View Profile
Re: AI creation challenge: Design an AI!
« Reply #8 on: July 16, 2013, 08:47:19 pm »

There are 4 levers in front of you. Flipping the correct 2 reveals the treasure.

Note that as you've phrased this there are only 6 valid combinations, not 16.

Quote
Things you can call:
Leverstatus(1,2,3,4) - gives you whether the lever is pulled or not


Variables:
l1 - gives you true for on false for off
l2, l3, l4 follow the same pattern

I'm uncertain what you mean by this. Are l1-4 assignable variables, or functions that return the value you describe? If they're variables...why are you describing them as such? If they're functions, what's the difference between l1 and Leverstatus(1) ?

Kashyyk

  • Bay Watcher
  • One letter short of a wookie
    • View Profile
Re: AI creation challenge: Design an AI!
« Reply #9 on: July 16, 2013, 08:50:10 pm »

int i = 0.
int j = 1.

while (i<5 and not treasureopen):
{
   
   while (j<5 and not treasureopen):
   {
      pulllever(i).
      pulllever(j).
      if not treasureopen: pulllever(j).
      j=j+1.
   }
   if not treasureopen: pulllever(i).
   i=i+1.
   j=i+1;
}
Collecttreasure(treasure).
« Last Edit: July 16, 2013, 09:08:38 pm by Kashyyk »
Logged

Octobomb

  • Bay Watcher
  • I like pens
    • View Profile
Re: AI creation challenge: Design an AI!
« Reply #10 on: July 16, 2013, 09:09:26 pm »

-snip-
Note that as you've phrased this there are only 6 valid combinations, not 16.

Quote
Things you can call:
Leverstatus(1,2,3,4) - gives you whether the lever is pulled or not


Variables:
l1 - gives you true for on false for off
l2, l3, l4 follow the same pattern

I'm uncertain what you mean by this. Are l1-4 assignable variables, or functions that return the value you describe? If they're variables...why are you describing them as such? If they're functions, what's the difference between l1 and Leverstatus(1) ?
1. Yup
2. Similarities facepalm... Oookaaaaay... l1 stands for lever 1 and is indicative of whether lever one is in a flipped state or not. It is not reassign able, and Leverstatus updates the info as it is not part of the AI itself. Got my head jammed in python habits I'm afraid.
-snip-

You are very clever, you. Have a box o cookies.

Challenge: 3 Goblins. 1 is wielding a 'Box o choc chip cookies'. Find out which one he is and steal it. The oter two carry fish heads. Punch them, and steal the cookies last.
Things you can call
Spoiler (click to show/hide)
You can add your own variables. Also, Kashyyk, you can dole out a couple test if you want.
Logged
I saw 5 people with fedoras in my town yesterday.
They're the special biohazard containment agent, out to deal with m'laria.
Sig
Bay12's resident tea drinkers

Kashyyk

  • Bay Watcher
  • One letter short of a wookie
    • View Profile
Re: AI creation challenge: Design an AI!
« Reply #11 on: July 16, 2013, 09:12:44 pm »

You are very clever, you. Have a box o cookies.

^.^ As I said, Software Engineer. I'll come up with some, but I'm gonna try to sleep first, what with it being 3am. That also means other people will get a chance at solving some of these.
Logged

Remuthra

  • Bay Watcher
  • I live once more...
    • View Profile
Re: AI creation challenge: Design an AI!
« Reply #12 on: July 16, 2013, 09:19:12 pm »

This one seems really easy.

Getweapon(Goblin 1)

If Goblin1cookies==true, 1->x
Else, punch(Goblin 1)

Getweapon (Goblin 2)

If Goblin2cookies==true, 2->x
Else, punch(Goblin 2)

Getweapon (Goblin 3)

If Goblin3cookies==true, 3->x
Else, punch(Goblin 3)

If x=1, Steal(Goblin 1), Endprogram
Else,
If x=2, Steal(Goblin 2), Endprogram
Else,
If x=3, Steal(Goblin 3), Endprogram
Else,
Endprogram

Grek

  • Bay Watcher
    • View Profile
Re: AI creation challenge: Design an AI!
« Reply #13 on: July 16, 2013, 10:05:10 pm »

short i=nothing

if getWeapon(Goblin1) == 'Box o choc chip cookies':
i=Goblin1
elseif getWeapon(Goblin2) == 'Box o choc chip cookies':
i=Goblin2
elseif getWeapon(Goblin3) == 'Box o choc chip cookies':
i=Goblin3
else
print 'Error, cookies not found.'
endif

//It doesn't say not to punch the goblin with the cookies. So let's do that.
Punch(Goblin1)
Punch(Goblin2)
Punch(Goblin3)
Steal(i)
« Last Edit: July 16, 2013, 10:07:15 pm by Grek »
Logged

Octobomb

  • Bay Watcher
  • I like pens
    • View Profile
Re: AI creation challenge: Design an AI!
« Reply #14 on: July 17, 2013, 03:28:20 am »

Rethmura has it dead on. Well done. Sadly, Grek, you end up punching the goblin with the cookies and mangling them. Sooooo, on with the show!

Challenge: You are in a house. With zombies coming in from the front. Your mission is to hold it. There are 3 types of zombies: Normal, Fast and Heavy. You do 2x 2hp shot/turn (can be directed separately). You are 60 units away from the zombies and their numbers will be randomly generated (each wave will be larger though. I mean the number of each type of zombie) and have 10hp but no regeneration. Survive for as many waves as possible.
Zombie types:
Spoiler (click to show/hide)
Things you can call:
Spoiler (click to show/hide)
Variables:
Spoiler (click to show/hide)

This oughta keep you busy for a bit. It's more open ended, hopefully like many of the rest will be.
Logged
I saw 5 people with fedoras in my town yesterday.
They're the special biohazard containment agent, out to deal with m'laria.
Sig
Bay12's resident tea drinkers
Pages: [1] 2