Author Topic: Newbye question  (Read 5941 times)

Offline duartel

  • Bot Neophyte
  • *
  • Posts: 4
    • View Profile
Newbye question
« on: March 16, 2011, 07:17:12 PM »
Hi! I'm duartel and I'm new to the forums.
I created an account because I want to code a bot but I have absolutely no idea of what does what.
So if anyone knows a good tutorial...
Yes, I tried the official guides.
I just can't understand the conditions and everything...
In case I just wasn't made for it, I'd apreciate if someone coded a bot for me  :happy:
All I want it to be is not really clever, with a bad camp of view but, once it has a target it will go to it at a huge speed. Then kill it and eat it.
It would target anything except its own children for 3 seconds. Then it's back to FFA.
Hope it's not too hard to code, and sorry for my dumbness.
I never learned how to code :s

Offline Billy

  • Bot Destroyer
  • ***
  • Posts: 175
    • View Profile
Re: Newbye question
« Reply #1 on: March 22, 2011, 06:25:00 PM »
Slowly working through the first bot tutorial helps, you will hopefully gradually grasp DNA as you progress through it.
"I cannot persuade myself that a beneficent and omnipotent God would have designedly created parasitic wasps with the express intention of their feeding within the living bodies of Caterpillars."

-Charles Darwin

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: Newbye question
« Reply #2 on: March 23, 2011, 03:57:54 AM »
It's the polish calculation thing...
a * b + c
a b mult c add
but I can't explain it.

Offline duartel

  • Bot Neophyte
  • *
  • Posts: 4
    • View Profile
Re: Newbye question
« Reply #3 on: March 23, 2011, 06:44:54 PM »
What I don't understand is what A, B and C are. Sorry if I'm missing something :s

Offline Billy

  • Bot Destroyer
  • ***
  • Posts: 175
    • View Profile
Re: Newbye question
« Reply #4 on: March 24, 2011, 12:56:51 PM »
They can be constants or memory locations.
"I cannot persuade myself that a beneficent and omnipotent God would have designedly created parasitic wasps with the express intention of their feeding within the living bodies of Caterpillars."

-Charles Darwin

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: Newbye question
« Reply #5 on: March 24, 2011, 01:08:12 PM »
Lets say you want to add 25 and 25 together and then wanted to store it into a memory location .repro

25 + 25 into .repro

25 25 add .repro store

Dunno' if that helps...

Offline duartel

  • Bot Neophyte
  • *
  • Posts: 4
    • View Profile
Re: Newbye question
« Reply #6 on: March 24, 2011, 04:06:43 PM »
Okay, I understood... Nothing :x
Mabye I should try getting coding classes.

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: Newbye question
« Reply #7 on: March 24, 2011, 05:02:22 PM »
I only really knew the bear basics when I first came here, but I just stuck at it. It's weird how everything works. Basically "add" takes the two values before it and adds them together. Like 25 25 add, think of that being replaced by 50... And then if you want to store that in .repro, you use store. and that takes the 1st value, and puts that in the second memory location... like 20 .repro store. will store 20 into .repro.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Newbye question
« Reply #8 on: March 25, 2011, 02:18:28 PM »
The first (implied) step is to be able to convert what you want to do (for instance, fire a -1 feeding shot if you see something in front of you) into a mathematical/coding expression (if central eye sees something closer than 50, then fire -1 shot).  From there you can convert that to DNA code: *.eye5 50 > -1 .shoot store

Sounds like you're having trouble with the first step.  Can you breakdown your description in the first post into steps of pseudocode that would do what you want?  You sort of need to know what sysvars are available, probably, just to know what's possible and what isn't (there's no implementation of digging, so trying to build a bot that digs into shapes is just not possible with the program at present).

Offline duartel

  • Bot Neophyte
  • *
  • Posts: 4
    • View Profile
Re: Newbye question
« Reply #9 on: March 29, 2011, 01:42:44 PM »
Let's see if I can explain...
It would be carnivore and canibal. It would eat any non-vegetable that he'd see.
The exception is it's children, but only for three seconds. This is so it wouldn't eat it's own children right after they were born =p
The rest of the stats would be pretty low. It would have to almost crash with something to see it and would be relatively slow. But once it sees something, it starts running super fast and would strike it's victim really hard. It's atack would take out a lot of health from it's victim. Tough it would take a lot of energy from itself too... Like 30(I don't know if that's a lot tough)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Newbye question
« Reply #10 on: March 29, 2011, 03:27:00 PM »
Let's see if I can explain...
It would be carnivore and canibal. It would eat any non-vegetable that he'd see.

So how do you determine if what you see is a vegetable or not?  There isn't a refvar for autotrophs, so you have to get creative (the default plant doesn't have any eyes, for instance).

Quote
The exception is it's children, but only for three seconds. This is so it wouldn't eat it's own children right after they were born =p

We don't have seconds.  We have cycles (because the simulation slows down sometimes, so 3 seconds might be 300 cycles or only 2).  So sounds like you want to trigger feeding if the refage is greater than 3.

Quote
The rest of the stats would be pretty low.
Stats?

Quote
It would have to almost crash with something to see it

The simulation gives all bots the same view distance, so bots can "see" fairly far.  I guess you could have it ignore objects that are too far away.

Quote
and would be relatively slow. But once it sees something, it starts running super fast

Easy enough if you separate out the logic for "see something I want to eat" from the logic for "randomly wander".

Quote
and would strike it's victim really hard.

How does that translate into actual action?  Are you powering up shots to do more damage?  Are you ramming the other bot (which doesn't actually do damage, but would certainly look aggressive :P)

Quote
It's atack would take out a lot of health from it's victim.

We don't do 'health'.  We have nrg and body, which together would be equivalent to "health".

...

If you're lucky someone might try and write your bot for you, but... probably not.  You'll probably have to open up the manual, read the pages for the different sysvars to get an idea of what sort of sense are available, and then take a crack at writing it.  It does take a bit of effort if you haven't ever programmed before, but if you have any basic ability with algebra you should be able to figure it out with some effort.  Start here and wander around the wiki for tutorials and the like, and if you have any specific questions we'll be glad to help.

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: Newbye question
« Reply #11 on: March 30, 2011, 06:20:55 PM »
I'm actually up to writing a bot! XD With explanations!

Offline PhiNotPi

  • Bot Builder
  • **
  • Posts: 64
    • View Profile
Re: Newbye question
« Reply #12 on: April 20, 2011, 09:15:14 AM »
     Reverse Polish Notation is a system of writing math expressions so that there can be no confusion about the order of operations and no need for parentheses.  Take the expression 2 * 3 + 4, for example.  If you did not know the order of operations (it is surprisingly hard to write a program that uses the order of operations), then it would be impossible to know whether the person meant (2 * 3) + 4 (= 10) or 2 * (3 + 4).  The first one equals 10 and the second equals 14, which are not the same.  Someone could have the program just read from left to right, but this can make simple expressions much more confusing.  Parenthesis are good to avoid in Alife programs, because if the parenthesis mutate to no longer match up correctly, then the math doesn't make sense and this may cause a computer error.

     This is why DB uses Reverse Polish Notation (RPN).  In RPN, the operator (+ - * / or in DB add sub mult div) comes after the operands (the numbers or memory references), instead of in between.  The operator always effects the two operands immediately in front of it, and combines them into one operand.  With these simple rules, any expression can be formed without an order of operations or parenthesis.  (2 * 3) + 4 would be written as 2 3 mult 4 add.  It is clear that mult affects 2 and 3, while add affects the result of (2 3 mult) and 4.  The second expression, 2 * (3 + 4), would be written as 2 3 4 add mult.  It is clear that add affects 3 and 4, while mult affects 2 and (3 4 add).

     I hope that you now better understand RPN.  RPN is very easy to use, but it may take some getting used to.
I am biased neither towards nor against any single mathematical constant.

Offline Panda

  • Global Moderator
  • Bot Destroyer
  • *****
  • Posts: 476
  • Computer Science Undergraduate (nerd)
    • View Profile
Re: Newbye question
« Reply #13 on: April 20, 2011, 12:04:02 PM »
Yeah, it did for me when I first started, but now, extremely easy to use!