Author Topic: Invers Notation  (Read 2760 times)

Offline Boreas

  • Bot Neophyte
  • *
  • Posts: 2
    • View Profile
Invers Notation
« on: December 30, 2005, 08:38:49 PM »
Hi,

I have a small problem to express myself in the right way  ^_^ with the db language.  I wanted to modify a simple "move-forward"-gene so that it depends on the distance to the next object, seen with the fifth eye. For example, if eye5 gives a 0 back (nothing in sight), the bot will throttle up with 100% and if eye5 gives a 100 back (a object is VERY close to me), the bot will throttle up with 0%. So I thought about something simple like this:

(100 - *.eye5) / 100 * (*.maxvel - *.vel) = will be stored in .up

One idea to write it down in DB was:

cond
  *.vel *.maxvel !%=
  *.fixpos 0 =
  *.robage 0 >
start
  100 *.eye5 sub 100 div *.maxvel *.vel sub mult .up store
stop

The bot still moves, but I canĀ“t recognize if it really works the way I want to. Is there any documentation that could help me with the invers notation or can anyone else help me?


Thx Boreas
« Last Edit: December 30, 2005, 08:43:22 PM by Boreas »

Offline PurpleYouko

  • Bot God
  • *****
  • Posts: 2556
    • View Profile
Invers Notation
« Reply #1 on: December 30, 2005, 09:06:39 PM »
I will work through your gene with you.

Code: [Select]
cond
*.vel *.maxvel !%=
*.fixpos 0 =
*.robage 0 >
start
100 *.eye5 sub 100 div *.maxvel *.vel sub mult .up store
stop

First line
*.vel *.maxvel !%=
compares current velocity with maximum velocity and returns true if they are NOT ALMOST (within 10%) equal. Should work fine.

line 2
*.fixpos 0 =
This line returns true if the value currently in memory location fixpos is zero. Unfortunately, this will always be zero unles the robot actively stores a different value into it. Fixpos is a command location, not a readback. You should use *.fixed to find the current state.

line 3
*.robage 0 >
true if robot age is greater than zero. This works just fine.

Action step.
100 *.eye5 sub 100 div *.maxvel *.vel sub mult .up store
 Let's go through it step by step to see if it works.

100 *.eye5 sub
places 100 on the stack. Places *.eye5 on the stack. Removes them both and places the result of 100 - *.eye5 onto the stack. This result is now the only value on the stack.
100 div
places 100 onto the stack then removes the top 2 values (first result and the new 100), performs the division and puts the result back on. Now only one value again.
*.maxvel *.vel sub
Places 2 more values onto the stack (now there are 3) removes the last 2 and performs the subtraction. Places the result back on. (now two values on the stack)
mult
removes the two values from the stack, multiplies them and puts the result on the stack (now only one value again.)
.up store
Puts the value already on the stack into the .up location.

Your reverse polish notation appears to be flawless. I think the gene is doing exactly what you want it to. only your fixpos condition is at fault. You could also use *.vel *.maxvel < instead of *.vel *.maxvel !%=
There are 10 kinds of people in the world
Those who understand binary.
and those who don't

:D PY :D