Author Topic: refdxpos, refuppos, refsxpos, refdnpos  (Read 4621 times)

Offline abyaly

  • Bot Destroyer
  • ***
  • Posts: 363
    • View Profile
refdxpos, refuppos, refsxpos, refdnpos
« on: April 27, 2006, 10:21:06 PM »
I was looking through the wiki and though I found refvars for x pos and y pos, I was surprised these werent in there. Since there are no trig functions either, I can't find a way to make bots calculate them accurately.  
Lancre operated on the feudal system, which was to say, everyone feuded all
the time and handed on the fight to their descendants.
        -- (Terry Pratchett, Carpe Jugulum)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
refdxpos, refuppos, refsxpos, refdnpos
« Reply #1 on: April 27, 2006, 10:40:37 PM »
there is refxpos, is that what you're looking for?

It is possible to emulate sin and cos using numerical approximations.  I did that way back in the day before there was refvel*.

Offline abyaly

  • Bot Destroyer
  • ***
  • Posts: 363
    • View Profile
refdxpos, refuppos, refsxpos, refdnpos
« Reply #2 on: April 27, 2006, 10:46:45 PM »
refxpos gives the x coordinate
Lancre operated on the feudal system, which was to say, everyone feuded all
the time and handed on the fight to their descendants.
        -- (Terry Pratchett, Carpe Jugulum)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
refdxpos, refuppos, refsxpos, refdnpos
« Reply #3 on: April 27, 2006, 10:49:02 PM »
Yes, and refypos gives the y coordinate.

Is that what you're looking for?

Offline abyaly

  • Bot Destroyer
  • ***
  • Posts: 363
    • View Profile
refdxpos, refuppos, refsxpos, refdnpos
« Reply #4 on: April 27, 2006, 11:07:05 PM »
no. I was looking for the vars in the topic. they dont exist. so I didnt find them
Lancre operated on the feudal system, which was to say, everyone feuded all
the time and handed on the fight to their descendants.
        -- (Terry Pratchett, Carpe Jugulum)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
refdxpos, refuppos, refsxpos, refdnpos
« Reply #5 on: April 28, 2006, 11:15:55 AM »
No, they don't exist.  But neither does .explode or .becomeagod.  

What is it you would expect the vars in your topic to do?
« Last Edit: April 28, 2006, 11:16:54 AM by Numsgil »

Offline abyaly

  • Bot Destroyer
  • ***
  • Posts: 363
    • View Profile
refdxpos, refuppos, refsxpos, refdnpos
« Reply #6 on: April 30, 2006, 05:30:30 PM »
Quote from: Numsgil
No, they don't exist.  But neither does .explode or .becomeagod.  

What is it you would expect the vars in your topic to do?
upon thinking this over, I have found reason for those vars not to exist, so never mind ^^
Lancre operated on the feudal system, which was to say, everyone feuded all
the time and handed on the fight to their descendants.
        -- (Terry Pratchett, Carpe Jugulum)

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
refdxpos, refuppos, refsxpos, refdnpos
« Reply #7 on: April 30, 2006, 11:05:03 PM »
Hey abyaly, pay no attention to Nums.  It's my fault really.  He's a good monkey, but he gets cranky when he's hungry.  I'm supposed to feed him when PY is away, but I forgot....  

The refvars that do exist are mostly just a convienent shortcut to using the memloc/memval pair.  We could add refvars for everything, but that would be a lot of work and double the size of the bot's memory array...
« Last Edit: April 30, 2006, 11:06:19 PM by EricL »
Many beers....

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
refdxpos, refuppos, refsxpos, refdnpos
« Reply #8 on: April 30, 2006, 11:34:52 PM »
I just didn't understand his post.  refdnpos would presumably provide the "down position" of the bot in your eye5.  What is a "down position"?  Is it the distance to the bot expressed as units needed to store in .dn to get to that bot's coordinates?

Anyway, after a little thought, I think you just need to use dist and angle commands.

dist provides the distance to a set of coordinates from where you are now.  angle provides the angle to a set of coordinates from where you are now.

Offline abyaly

  • Bot Destroyer
  • ***
  • Posts: 363
    • View Profile
refdxpos, refuppos, refsxpos, refdnpos
« Reply #9 on: March 26, 2008, 11:26:28 AM »
(warning: old topic)
I propose that the following sysvars be implemented:
.refup - the projection of the distance vector in the direction the bot is facing
.refdx - the "   "    " in the direction 90 degrees to the right
.refdn - the "   "    " in the direction opposite to the one the bot is facing
.refsx - the "   "    " in the direction 90 degrees to the left

Here is an example of how I would like these to work.
I have a bot whose coordinates are (100, 100)
He is looking at a bot that is at (200,200)
My bot is facing direction 0.
.refup would be 100.
.refdx would be 100.
.refdn would be -100
.refsx would be -100

Second example:
I have a bot whose coordinates are (100, 100)
He is looking at a bot that is at (200,200)
He is looking at direction 157.
.refup would be 0.
.refdx would be 141 ~= 100 * root 2
.refdn would be 0.
.refsx would be -141

General case:
I have a bot looking at another bot.
my bot is facing direction a. the angle between my bot and the other bot is b.
z = a - b (the amount of clockwise rotation necessary for my bot to be looking directly at the other bot)
d = the distance between the bots
.refup = d * cos (z)
.refdx = d * sin (z)
.refdn = d * -cos (z)
.refsx = d * -sin (z)
(These figures might not be right; I will check them again when I have more time today)
Lancre operated on the feudal system, which was to say, everyone feuded all
the time and handed on the fight to their descendants.
        -- (Terry Pratchett, Carpe Jugulum)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
refdxpos, refuppos, refsxpos, refdnpos
« Reply #10 on: March 26, 2008, 06:24:18 PM »
These would be a good replacement for the current refxpos and refypos.  Express distances in terms of the bots internal frame of reference.