Author Topic: trefnrg returning 0  (Read 4306 times)

Offline Trafalgar

  • Bot Destroyer
  • ***
  • Posts: 122
    • View Profile
trefnrg returning 0
« on: May 14, 2008, 10:29:09 PM »
The problem is that one of these two tied bots is seeing 0 for trefnrg. The other is seeing a correct value. Both bots have energy, aren't corpses, are more than 2 cycles old, etc etc.

Screenshot (I added the yellow arrows to point out the important numbers): http://screencast.com/t/s0xj0fz9iq

The selected robot is the one whose robot dialog is open. (I noticed after I took the screenshot and closed the windows that I had the left bot's console on the right and the right bot's console on the left, oops)

Saved sim: attached to this post

(This is with 2.43.1k)

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
trefnrg returning 0
« Reply #1 on: May 14, 2008, 11:38:40 PM »
This is more of a design issue/question than a bug.

The way the code works now, the trefvars are populated for a single cycle for the bot that creates a tie without it having to set .readtie.  But they are not populated for the tied bot.  The tied bot has to set .reatie to *.tiepres in order to populate the trefvars based on the bot at the other end of that tie.  

The logic behind this is that the target bot may be in the process of doing it's own thing with it's own ties, setting .readtie and so on and it's trefvars shouldn't suddenly change to reflect a tie it didn't create or even know about (it only discovers the tie exists on the cycle following it's creation when *.tiepres changes)  whereas the bot creating the tie presumedly meant to create the tie, knows the tie was created last cycle and is therefor aware that the trefvars will reflect the target on the cycle after the tie is created.

I'm not really inclined to change this behaivour, but as always I'm open to all arguments...





Many beers....

Offline Trafalgar

  • Bot Destroyer
  • ***
  • Posts: 122
    • View Profile
trefnrg returning 0
« Reply #2 on: May 15, 2008, 12:52:54 AM »
Hmm. Tienum is supposed to work too, right? I have it setting that, never ever used readtie (so I'd be pretty confused if neither bot was supposed to have working trefvars).

Maybe there's a mistake in the DNA somewhere. (At the end of the bots DNA is a command to store the value of tienum into memory location 988. They check this again next cycle and compare it to tiepres. I'm looking at the bot which has trefnrg showing as 0, and its tiepres (1) is equal to memory location 988 (also 1), indicating that it had already set tienum to 1. However - it appears that I have it not setting 988 if tienum is 0. As for why it wouldn't be setting tienum...)

The bot is also doing *.tiepres .deltie store (and tiepres was 1), but it is not deleting the tie for some reason. (Maybe that requires tienum to be set also?)

Edit: If I set readtie=1, will it automatically be changed when I set tienum, or when I tie to something? The wiki is extremely vague.
« Last Edit: May 15, 2008, 01:02:45 AM by Trafalgar »

Offline gymsum

  • Bot Destroyer
  • ***
  • Posts: 215
    • View Profile
trefnrg returning 0
« Reply #3 on: May 15, 2008, 06:20:52 AM »
The easiest way to read all ties constantly, unless you want the bot to focus, is to use the following gene:

cond
*.......
start
*.timer mod *.numties *.tiepres add .readtie store
stop

It takes the timer (an infitely expanding number and wraps it around the number of ties a bot has), that means every cycle a new tie is read.

Offline Trafalgar

  • Bot Destroyer
  • ***
  • Posts: 122
    • View Profile
trefnrg returning 0
« Reply #4 on: May 15, 2008, 11:49:53 AM »
Quote from: gymsum
It takes the timer (an infitely expanding number and wraps it around the number of ties a bot has), that means every cycle a new tie is read.

That is most definitely NOT what I want that bot to do.

I want it to always read the last tie to tie to it, basically, since if it IS another bot tying to it, it needs to be able to see if it's friendly and if not, delete the tie before the other bot can do anything nasty (like setting shootval to 31999).
« Last Edit: May 15, 2008, 11:51:53 AM by Trafalgar »

Offline goffrie

  • Bot Builder
  • **
  • Posts: 65
    • View Profile
trefnrg returning 0
« Reply #5 on: May 15, 2008, 06:38:54 PM »
Quote from: gymsum
The easiest way to read all ties constantly, unless you want the bot to focus, is to use the following gene:

cond
*.......
start
*.timer mod *.numties *.tiepres add .readtie store
stop

It takes the timer (an infitely expanding number and wraps it around the number of ties a bot has), that means every cycle a new tie is read.

Eek. '*.timer mod' doesn't quite do anything (I think you meant '*.timer *.numties mod'), and you're assuming that all the ties are in order - but you could have ties numbered 3, 792, and 29674, and your snippet would check 29674, 29675 and 29676.

Offline Peksa

  • Bot Destroyer
  • ***
  • Posts: 118
    • View Profile
trefnrg returning 0
« Reply #6 on: May 15, 2008, 06:57:06 PM »
Quote from: Trafalgar
I want it to always read the last tie to tie to it, basically, since if it IS another bot tying to it, it needs to be able to see if it's friendly and if not, delete the tie before the other bot can do anything nasty (like setting shootval to 31999).

Doesn't *.tiepres .readtie store do that?

Offline Trafalgar

  • Bot Destroyer
  • ***
  • Posts: 122
    • View Profile
trefnrg returning 0
« Reply #7 on: May 15, 2008, 08:49:31 PM »
Quote from: Peksa
Doesn't *.tiepres .readtie store do that?

Does setting .readtie instantly update the trefvars? If not, then not quite.

Probably I should set readtie to 1 before anything ties to the bot, since if there is no tie 1 that should be what tiepres will become when another bot ties to us.
« Last Edit: May 15, 2008, 08:50:34 PM by Trafalgar »

Offline goffrie

  • Bot Builder
  • **
  • Posts: 65
    • View Profile
trefnrg returning 0
« Reply #8 on: May 15, 2008, 10:07:53 PM »
Quote from: Trafalgar
Quote from: Peksa
Doesn't *.tiepres .readtie store do that?

Does setting .readtie instantly update the trefvars? If not, then not quite.  

Probably I should set readtie to 1 before anything ties to the bot, since if there is no tie 1 that should be what tiepres will become when another bot ties to us.
Actually, .tiepres will become what the other bot put into .tie, IIRC.

Correct me if I'm wrong

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
trefnrg returning 0
« Reply #9 on: May 15, 2008, 11:36:00 PM »
Quote from: goffrie
Actually, .tiepres will become what the other bot put into .tie, IIRC.

Correct me if I'm wrong
Your wrong in current versions.  It used to be this way, back in the long long ago, but there was some argument made, perhaps by me, that the target bot should not have insight into the tying bot's tie naming conventions.   So, *.tiepres for the target bot is essentially *.numties.  When that tie gets deleted, it reverts to the previous tie port.  I'm not really happy with this, since if a bot creates it's first tie by doing 2 .tie store and then gets tied to, *.tiepres will still be 2, but at least bots can use higher numbers for the ties they create and distinguish them from those created by others.  Besides, using the tying bot's tie port has similar collision problems.

I've been thinking a nice addition might be a pushties command that pushes all the tie ports onto the stack.

W.r.t. updating trefvars, the trefvars reflect the properties of the bot at the other end of a tie the cycle following when .readtie is set to that tie port.  I.e. the trefvars will be updated the cycle following *.tiepres .readtie store.   This cycle delay is exactly the subject of the recent suggestion I posted regarding in-cycle updating of control sysvars.  Were I to impliment that, the trefvars would be updated immiediatly in-cycle when .readtie changes, allowing subsequent DNA to operate on the trefvars that cycle.

Many beers....