Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Trafalgar

Pages: 1 [2]
16
DNA - General / Swapping the top two stack values?
« on: July 14, 2007, 06:46:13 PM »
Has anyone thought of any clever ways to swap the top two stack variables without needing a temporary variable? I haven't been able to come up with anything (yet). (But I'm thinking it may just be impossible)

I'm trying to make branch conditionals, but I can't unless I can swap stack values. That's because I need to keep values on the stack for each conditional, dupe them, and multiply them times the addresses of each store. The problem is that the store command is 'value address store'. If it were 'address value store', I could just dup address mult value store.

This is what it would look like (python-like code on the left, translation and comments on the right after the #) if store commands were 'address value store':
Code: [Select]
    #Branch conditionals:
    if (foo==2):        # *.foo 2 sub sgn abs - ++ (stack holds 1 value now)
        if (bar==3):    # dup *.bar 3 sub sgn abs - ++ & (stack holds 2 values now)
            #Note: The store commands here have the address (variable) and value backwards. It should be 'value address store', and we've written this using 'address value store'. Doing this with the way store really works is probably impossible (without a temporary variable, which would defeat half the point of having conditions on stores).
            sx = 1        # dup .sx mult 1 store (stack holds 2 values)
            up = 1        # dup .up mult 1 store (stack holds 2 values) (if there was no else, this should omit the dup?)
        else:            # - ++ (reverse the topmost stack value) (stack holds 2 values)
            sx = -1        # dup .sx mult -1 store (stack holds 2 values)
            up = -1        # dup .up mult -1 store (stack holds 2 values)
        #end of if/else - pop stack: dup xor inc (stack holds 1 value)
    elif (foo==3):        # dup - ++ dup *.foo 3 sub sgn abs - ++ & (stack holds 3 values - the first is the result of the if, the second is the !if, and the third is the result of this elif): (either TFF, FTF, or FTT)
        sx = 2            # dup .sx mult 2 store (stack holds 3 values)
    elif (foo==4):        # - ++ & (stack TF (if was true), FT (all conditions were false), or FF (a previous condition was true)) dup *.foo 4 sub sgn abs - ++ & (stack TFF, FTT, FTF, or FFF)
        sx = 3            # dup .sx mult 3 store (stack holds 3 values)
    elif (foo==5):        # - ++ & (stack TF (if was true), FF (a previous condition was true), FT (all conditions were false), or FF) dup *.foo 5 sub sgn abs - ++ & (stack TFF, FFF, FTT, FTF, or FFF)
        sx = 4            # dup .sx mult 4 store (stack holds 3 values)
    #end of elif:        # - ++ | - ++ (stack F (a previous condition, or the if, was true), T (all conditions were false))
    else:                # Note that it was "- ++ | - ++" when an elif ends, and "- ++" when an if ends.
        sx = 5            # dup .sx mult 3 store (stack holds 1 value)
    #end of if/else - pop stack: Since nothing else is on the stack: dup xor inc (stack holds 0 values)
    #That's the end of it

17
Bug reports / mydn, mysx, refdn, refsx, and refvelsx always return 0
« on: July 12, 2007, 12:58:38 PM »
I noticed some more bugged/broken sysvars:
Mydn, mysx, refdn, and refsx all return 0 all the time, making them useless for determining if a bot is friendly. Also, refvelsx always reads 0 too, but refveldx works properly (so we don't really NEED refvelsx, since veldx is always equal to -velsx). (refveldn and refvelup both work though) Notably, velsx (getting my own sx velocity) works fine.

Of course, refdn and refsx may not actually be broken - they're just reading from broken mydx and mysx on the target bot.

P.S. Would it be considered a bug that a bot with more than 50 defs causes DarwinBots to crash if you try to start a match with it? (I was dumping a LOT of sysvars to free sysvars which were all together, so that I could see what they all were without having to look up sysvar values and jump around in the memory dump)

18
To test the bot I'm working on, I've been having it go through the F1 league. Since it was taking forever to do 5 matches with each bot, I restarted the program and changed it to only do 3 rounds.

In the first contest, it won all three rounds - but the program proclaimed that a "Statistical Draw" and began a fourth round. And after that one was won too, it began a fifth.  

(After the fifth round was also a win, it decided it wasn't a draw anymore)

Also, if there's ever a statistical draw requiring an extra round, every contest after that has the increased number of rounds too (This happens even when the number of rounds was originally 5, so you could get stuck at 6+ rounds per contest until you eventually lose a contest, for example).

Here's a screenshot from the Contest Results dialog after the third round: http://img457.imageshack.us/img457/4183/3w...tisticalcv2.png

19
refpoison appears to be returning the amount of poison the other bot has, rather than the number of poison commands it has. The wiki and in-game help both say "How many .strpoison commands do you have in your DNA? Returns the number to me".

With a bot species designed to stay at 500 poison, with one member of that species looking at another, the poison variables are:

refpoison: 500
mypoison: 12
poison: 500

20
In short, things with DNA execution disabled have 0,0 for xpos,ypos, which results in refxpos, refypos being 0,0 when looking at them. Bots using "*.refxpos *.refypos angle .setaim store" for aiming go wonky* when they see a bot/veggie with disabled DNA execution.

(My workaround are to only do setaim aiming if both refxpos and refypos are >0)

* = Specifically, they turn to face 0,0.

21
DNA - General / "Invalid procedure call or argument"
« on: July 09, 2007, 12:32:30 PM »
I have a test bot script which has a problem in it somewhere, which I know because when I try to start a new simulation with it, DB says "Invalid procedure call or argument. Path: (the path to that bot) is not a valid robot."

My question is this: Why doesn't it say what's invalid, and what line it's on?

Edit: Wait... What the hell? If I remove all the comments in the .txt, DB accepts the robot. O_o

Edit #2: Seems to be caused by having lines which start with '#, e.g.:
Code: [Select]
'# This foos the bar when it's zorting.
Edit #3: From digging in the source, I tracked the cause to a bit of code which explicitly checks for lines starting with '# and tries to load stuff from them. I seem to have unintentionally ran into an undocumented (at least, it isn't mentioned in the readme anywhere) feature which was going bonkers over my comments.

The reason I had comments starting with '# is because I've made a python script/program which converts semi-python-like robot DNA into DB robot DNA, and when it converted a comment (#) in the pythonish DNA, it wrote out the entire comment (including the #) with a ' before it. (Once I figured out that the '# was causing the error, I changed it to not write out the leading #s)

Pages: 1 [2]