Author Topic: Slam Funk 1.0  (Read 11544 times)

Offline Shasta

  • Administrator
  • Bot Destroyer
  • *****
  • Posts: 231
    • View Profile
Slam Funk 1.0
« Reply #15 on: April 01, 2009, 11:30:46 PM »
Quote from: Ta-183
I got a chance to run a version of Slam Funk 2 a few minutes ago. It didn't work nearly at all. Only the genes retained from Slam funk 1.X seemed to work. I think I narrowed the problem down to my use of custom constants. Now, in the code above, I tried to define constants using 'def constant 2' for example. Now what I thought I was doing was setting .constant to 2. But I think what it really did was set .constant to MEMORY LOCATION 2. Is this accurate?
Yes it is, if you want a memory value to always be the same, what you could do is place a gene/block at the very end and set them all there. But if you are trying to use them for math, find and replace is your friend.

Offline Ta-183

  • Bot Destroyer
  • ***
  • Posts: 105
    • View Profile
Slam Funk 1.0
« Reply #16 on: April 02, 2009, 12:00:37 AM »
Im using them as constants so I can do logical checks. like for example seeing if *.health is equal to *.dying. This way it's easy to put interrupts into my genes so it can decide whether or not to do something. This is going to take a major modification of my current code, but only so far as to add a few dozen lines for constant initialization. The system isn't half bad if I do say so myself. It's just the constants than need work.

EDIT: Arrg, now it's deleting it's genes whenever it reproduces!!
Okay. I'm posting the code now, somebody PLEASE tell me what's going wrong here!


Code: [Select]
'Slam Funk 2.0 (Release Candidate 2)
'Second Generation of Slam Funk
'Vastly improved communication and decision making.
'Can now differentiate between enemy and food
'And effectively relay information.
'Has improved diagnostics routines and retreat capability.


'CHANGELOG
'Ver 2.00
'    Initial Build
'


'Communication
def txpos 50
def typos 51
'Identification Friend Foe or Food
def IFFF 52
def notarget 53
def friend 54
def food 55
def foe 56
'Secure Conspec Constants
def algaminimalis 57
'Situational Awareness
def situation 58
def nothing 59
def eating 60
def fighting 61
'Condition
def health 62
def fine 63
def injured 64
def dying 65
def intox 66

'-------- CONSTANT INITIALIZATION --------

cond
*.robotage 0 =
start
'Communication
0 .txpos store
0 .typos store
'Identification Friend Foe or Food
0 .IFFF store
0 .notarget store
1 .friend store
2 .food store
3 .foe store
'Secure Conspec Constants
1 .algaminimalis store
'Situational Awareness
0 .situation store
0 .nothing store
1 .eating store
2 .fighting store
'Condition
0 .health store
1 .fine store
2 .injured store
3 .dying store
4 .intox store
stop


'-------- MAINTINENCE: Health --------

'Health Indication -Fine
cond
*.nrg 2000 >
*.body 1000 > and
*.pain 300 < and
*.poisoned 0 = and
*.paralyzed 0 = and
start
*.fine .health store
stop

'Health Indication -Injured
cond
*.pain 300 >
*.nrg 1000 > and
*.nrg 2000 < and
*.body 1000 < and
*.poisoned 0 = and
*.paralyzed 0 = and
start
*.injured .health store
stop

'Health Indication -Dying
cond
*.nrg 1000 <
*.body 1000 < and
start
*.dying .health store
stop

'Health Indication - Intoxicated
cond
*.poisoned 1 =
*.paralyzed 1 = or
start
*.intox .health store
stop

'-------- MAINTINENCE: Energy Birthties And Other Constants --------

' Get rid of birth tie

cond
start
 .tie *.robage 1 add mult inc
 .deltie inc
stop

cond
start
339 .memloc store
stop

'Body storage
cond
*.nrg *.body >
start
100 .strbody
stop

'Body feeding
cond
*.nrg *.body <
start
100 .fdbody
stop


'-------- IDENTIFICATION FRIEND FOE OR FOOD --------

'Can't see shit, captian
cond
*.eye1 0 =
*.eye2 0 = and
*.eye3 0 = and
*.eye4 0 = and
*.eye5 0 = and
*.eye6 0 = and
*.eye7 0 = and
*.eye8 0 = and
*.eye9 0 = and
start
*.nothing .situation store
*.notarget .IFFF store
stop

'Friendly Bot
cond
*.eyef 0 >
*.refshoot 0 > and
*.refeye *.myeye = and
*.health *.intox != and
start
*.nothing .situation store
*.friend .IFFF store
stop

'Food
cond
*.memval *.algaminimalis =
*.refeye *.myeye != and
*.IFFF *.friend != and
*.health *.intox != and
start
*.food .IFFF store
*.refxpos .txpos store
*.refypos .typos store
stop

'Foe
cond
*.refshoot 0 >
*.refkills 0 > or
*.eyef 0 > and
*.refeye *.myeye != and
*.IFFF *.friend != and
*.health *.intox != and
start
*.foe .IFFF store
*.refxpos .txpos store
*.refypos .typos store
stop

'-------- VISION --------
'NOTE: Current vision system taken from Slam Funk1.01c.
'To be replaced with better functioning system in future builds.

'Targeting genes. If it spots food, it turns to it. -From Slam Funk1.01c

cond
start
-1 .focuseye store
stop

'Eye4
cond
*.eye4 0 !=
*.refeye *.myeye != and
start
5 .aimsx store
stop

cond
start
1 .focuseye store
stop

'Eye6
cond
*.eye6 0 !=
*.refeye *.myeye != and
start
-5 .aimsx store
stop

cond
start
-2 .focuseye store
stop

'Eye3
cond
*.eye3 0 !=
*.refeye *.myeye != and
start
15 .aimsx store
stop

cond
start
2 .focuseye store
stop

'Eye7
cond
*.eye7 0 !=
*.refeye *.myeye != and
start
-15 .aimsx store
stop

cond
start
-3 .focuseye store
stop

'Eye2
cond
*.eye2 0 !=
*.refeye *.myeye != and
start
35 .aimsx store
stop

cond
start
3 .focuseye store
stop

'Eye8
cond
*.eye8 0 !=
*.refeye *.myeye != and
start
-35 .aimsx store
stop

cond
start
-4 .focuseye store
stop

'Eye1
cond
*.eye1 0 !=
*.refeye *.myeye != and
start
40 .aimsx store
stop


cond
start
4 .focuseye store
stop

'Eye9
cond
*.eye9 0 !=
*.refeye *.myeye != and
start
-40 .aimsx store
stop

cond
start
0 .focuseye store
stop

'-------- MOVEMENT --------

'Follow friends
cond
*.eye5 0 >
*.IFFF *.friend = and
*.situation *.nothing = and
*.health *.intox != and
start
*.refveldx .dx store
*.refvelUp .up store
30 .aimdx store
stop

'Doing nothing
cond
*.situation *.nothing =
*.IFFF *.notarget = and
start
10 .up store
stop

'-------- COMMUNICATION --------

cond
*.IFFF *.food =
*.IFFF *.foe = or
*.health *.intox != and
start
*.IFFF .out1 store
*.txpos .out2 store
*.typos .out3 store
stop

cond
*.IFFF *.notarget =
*.IFFF *.friend = or
start
*.IFFF .out1 store
0 .out2 store
0 .out3 store
stop

'Listen for signs of food, turn towards it if not doing anything more important
cond
*.in1 *.food =
*.situation *.nothing = and
*.health *.intox != and
start
*.in2 *.in3 angle .setaim store
30 .up store
*.eating .situation store
stop

'Listen for signs of trouble. Go fight if there is any and you're not hurt and busy eating.
cond
*.situation *.nothing =
*.situation *.eating = or
*.in1 *.foe = and
*.health *.intox != and
*.health *.dying != and
*.health *.injured = not
*.situation *.eating = not and and
start
*.in2 *.in3 angle .setaim store
30 .up store
*.fighting .situation store
stop

'-------- COMBAT --------

'Retreating gene
cond
*.health *.injured =
*.refnrg 1500 > and
*.health *.dying = or
*.IFFF *.foe = and
start
628 .aimdx store
20 .up store
stop

'Retaliate to shot outside vision
cond
*.shflav 0 !=
*.shflav -2 !=
start
1256 *.shang sub .setaim store
0 .shflav store
stop

'Shooting gene. Accurately targets food/foe and decides what type of shot to use.
cond
*.situation *.eating =
*.situation *.fighting = or
*.eye5 40 > and
*.refeye *.myeye != and
*.IFFF *.friend != and
start
*.refxpos *.refypos dist *.refvelup add *.xpos add
*.ypos *.refvelsx add
angle
*.refxpos *.refypos angle add
.setaim store
*.refxpos *.refypos dist 30 sub 500 div *.maxvel mult *.refvel *.vel *.refeye sgn mult sub 1 mult add .up store
*.refveldx .dx store
*.eyef *.refveldx 400 mult *.refbody div 4 add >
-6 .shoot store
32 .shootval store
*.refnrg *.refbody <
*.refpoison *.refshell < or
-1 .shoot store
1600 *.refvelsx 2 pow sub sqr *.xpos add
*.ypos *.refvelsx add
angle .lead store
*.refvelsx *.velsx <
1256 *.lead sub .lead store
dropbool
*.lead .aimshoot store
stop

'-------- REPRODUCTION --------

cond
*.health *.fine =
*.nrg 2000 > and
start
40 .repro store
314 .aimdx store
stop

'-------- OTHER --------




end




I don't want to spend a week debugging this. It won't shoot, it deletes it's genes, it won't act properly (likely due to it not feeding) and I need to know why. parents are getting pushy, I have to go.

Offline Ta-183

  • Bot Destroyer
  • ***
  • Posts: 105
    • View Profile
Slam Funk 1.0
« Reply #17 on: April 02, 2009, 09:27:40 AM »
Alright, I got back to school this morning and go straight to work. One of the things I suspected was to blame was the situational variables not being set at the proper times. I also assumed that I should simplyfy the requirements for the shooting gene to activate. And though not a fatal flaw, I found a problem with the shooting function I took from gimmick in that I had not copied over a custom variable it uses. It worked fine in all the 1.x builds it was used in, but I am still going to put it in for completeness' sake. Plus, it might even improve the performance of SF1.1 a bit. Once I get back to my computers at home I will be able to test the changes. 1.1 is working fine at the moment and I am fine tuning it for release. Once 2.0 has had the kinks worked out I am going to start coding the F1 version! It should be very deadly with tie feeding and virii/venom.

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
Slam Funk 1.0
« Reply #18 on: April 02, 2009, 10:37:26 AM »
Quote from: Ta-183
One of the things I suspected was to blame was the situational variables not being set at the proper times.
This is a likely candidate. I have glanced over your code, and it uses them a lot. Setting /resetting them, interactions between them and the order in which they are executed are not trivial. You made a very big step at once and I salute you for it, but this makes debugging hard.
I also noticed you use the number of genes for conspec (at least partly). Expanding on this might help you against current mimicking bots
Quote from: Ta-183
Once 2.0 has had the kinks worked out I am going to start coding the F1 version! It should be very deadly with tie feeding and virii/venom.
A capable F2 bot and F3 bot can use the same base. In F1 the logic is different. Some examples:
In F1 you rape veggies, not eat them.
Shot strenght is based on your body tie feeding is not. In F3 the reduction in shot effectiveness serves as a lower bound for body size. This bound is absent in F1. The effect: look at numbers of bots generated in F3 and F1 combat. They are not comparable.
In F2&3 search and destroy tactics work, the top bots in F1 is much more passive

In effect you are programming an entirely different bot with a new strategy for F1 as opposed to F2&3

Offline Moonfisher

  • Bot Overlord
  • ****
  • Posts: 592
    • View Profile
Slam Funk 1.0
« Reply #19 on: April 02, 2009, 10:51:35 AM »
Ok disregard this post. Was explaining about the defines needing propper memmory locations, but hadn't seen there was a page 2 and the second code posted had no issues there so
« Last Edit: April 02, 2009, 10:53:43 AM by Moonfisher »

Offline Ta-183

  • Bot Destroyer
  • ***
  • Posts: 105
    • View Profile
Slam Funk 1.0
« Reply #20 on: April 02, 2009, 12:01:56 PM »
Thanks for the pointers. Yeah it uses a gene based counter to differentiate veggies from other bots. I won't be able to test my fixes till tonigh but most problems should be fixed.


The only thing I'm still worried about was an odd behavior where it would lose a gene every time it reproduced. I don't know if this will fix it or not. Debugging is so much easier on a TI-84... Just go into the code and have it display the variables. Would make nested conditions so much easier to make in DNA.

Offline Moonfisher

  • Bot Overlord
  • ****
  • Posts: 592
    • View Profile
Slam Funk 1.0
« Reply #21 on: April 02, 2009, 12:37:17 PM »
Ok found some stuff that could help :
*.robotage 0 =
should be *.robage

So all your initial values are never set.

Also noticed some of those values are constants... for that you can just define the constant value you need and refer to the var without the *
(You don't actualy need to create a location to save the value in, however if you plan on extracting the code again from inside DB and you defined an existing sysvar then it may have replaced the comand with the name you defined. The code would execute the same way, but may be harder to read, anyway it's only an issue if you're running an evo sim or something.)

This line :
.tie *.robage 1 add mult inc
isn't working as intended I think.
You could write .tie *.robage sgn 1 sub abs mult inc
Or something like that, but right now you will be incrementing a new memmory location each time your age rises (As in every cycle)
At age 1 you will store in location 2, at age 2 you'll increment location 3... asf...
Also all you realy need is the second line (.deltie inc) to get rid of the birth tie, since newborn robots birties have ID 1 in the child. This should also help against tie attacks in F1 and F2 (But it's not foolproof... cheap though, 0.004 nrg per cycle I think)

This line :
339 .memloc store
could be put in your *.robage 0 gene (The value will not be reset at each cycle)
(Just to save 0.04 nrg per cycle )
EDIT: Also you can just write .genes .memloc store, to make the code more readable (*.genes refers to the value stored in location 339, .genes refers to the value 339 itself)
And if you want to be sure it's alga minimalis, then try checking .dnalen instead of .genes, it's dna length is 13.
The reason is that many top bots only have one gene, and you also risk meeting bots with the same amount of genes as your own bot. So the exact length of the dna is much safer to use.


The gene for checking if all eyes are empty could also be done by adding all the eye values together (Use abs on them if you want to be a 100% sure the result is valid, not sure if eyes can have negative values).
Then check if the result is 0 in the end. This would also save 0.004 nrg per cycle times 8
Although optimizing these areas usualy don't make a big difference unless youre dealing with a small bot running on low nrg.


And last but not least :
You can not change eyefocus mid cycle. If you want to know why read the first post I wrote or read the section on code execution and stacks on the wiki. The explanation on the wiki is probably better, but the post is probably more oriented towards what you need to know. Either way I think it would help you understand how the code works (It's not exactly like regular high level languages like C++ and java and such)
Anyway your eyefocus will always be 0... it will never have any other value because this is the last value you push into it in your code.
All the other actions on eyefocus are irelevant, the last one counts... you can not execute several actions on sysvars in the same cycle... again you need to read that post or the wiki to truly understand why.

But to try and put it in a short and simple way:
The actions you bot takes (moving, shooting, changing eye focus, asf) are not executed at the time where you enter the value, the are executed once every cycle after completing ALL your code.
So for instance .shoot is location 7, so if you write -1 .shoot store, the only thing you did was store the value -1 in location 7, and you spendt 0.04 nrg doing it. (Nothing else happened whatsoever, you did not shoot). Then once you reach the end of your code, if nothing happened to change this value then you will shoot in that cycle and the value in the location will be reset to 0 and your code is then run once more in the next cycle.

Understanding how this works will be very important when designing your virus or viral defences when entering F1.
« Last Edit: April 02, 2009, 12:42:05 PM by Moonfisher »

Offline Ta-183

  • Bot Destroyer
  • ***
  • Posts: 105
    • View Profile
Slam Funk 1.0
« Reply #22 on: April 02, 2009, 12:48:46 PM »
Thanks for that. I already know the eye genes don't work as they should. But, they still work a little. The eyes are going to be replaced before I release the bots, but that's the last thing on my list.


And especially thank you for the .robage correction, that might even fix nearly all of it's problems. Only time will tell. (About five hours, give or take.)

Offline Moonfisher

  • Bot Overlord
  • ****
  • Posts: 592
    • View Profile
Slam Funk 1.0
« Reply #23 on: April 02, 2009, 01:23:49 PM »
The
.tie *.robage 1 add mult inc
line will also cause some problems... for instance when your bot reaches an age of 339 it will store 1 in location 340 (.delgene) and delete gene 1. So it's offspring will miss this gene and in their turn delete the next gene in position 1 when they reach age 339. Appart from that it'll generaly mess with memmory locations alle the way up, changing your var values and doing all sorts of anoying things

And the using genes for conspec will also become a problem sooner or later by seing 1G bots as alge, or if you meet a bot with the same amount of genes as yours.

But it definately seemed like the robotage thing was causing the most  problems.


If you need a good eye system you're very welcome to steal the one from EyeBot (I find myself pushin code on people, I feel like I'm trying to sell stolen shooes in a park or something).
I tried to comment it well to make it easy for others to use. It has 2 modes available, either switching the focus eye to the next eye in line that isn't empty or turning to the nearest eye that isn't empty. (It always turns in the same direction to make sure it doesn't get stuck turning back and forth)

Otherwise for a good and simpler system look at Excalibur maybe... and I think theres also a topic on another strong eye system, can't remember where though.

Offline Ta-183

  • Bot Destroyer
  • ***
  • Posts: 105
    • View Profile
Slam Funk 1.0
« Reply #24 on: April 02, 2009, 02:15:36 PM »
That's it! That's what was causing the gene deletions! I would have never realized that. Thank you so much. I took out that line from all versions, and now that you said that, next to every problem will be gone. Including the eyes. Like some of the other concepts I used, I took the eye routine from gimmick. Hope I don't offend.

Offline Moonfisher

  • Bot Overlord
  • ****
  • Posts: 592
    • View Profile
Slam Funk 1.0
« Reply #25 on: April 02, 2009, 05:13:58 PM »
Not at all, took a look at it, it looks a lot like the one in Excalibur which is where I stole the eyes for my first bot
EDIT: Actualy noticed what I wrote wasn't quite right... the robage gets multiplied by .tie which is 330, so I guess the memmory location wraps or something and hits .delgene at times.
« Last Edit: April 02, 2009, 05:22:20 PM by Moonfisher »

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
Slam Funk 1.0
« Reply #26 on: April 03, 2009, 02:37:18 AM »
Quote from: Ta-183
Like some of the other concepts I used, I took the eye routine from gimmick. Hope I don't offend.
Gimmick started out by stealing the unique features (gimmicks) of bots it couldn't defeat. I'm not offended, steal with pride

Offline Ta-183

  • Bot Destroyer
  • ***
  • Posts: 105
    • View Profile
Slam Funk 1.0
« Reply #27 on: April 03, 2009, 09:08:50 AM »
It worked! The issues I was having are gone. Now there are only a few things left to work out before I can do some final tweaking of some of the values and let this baby rip. The only bug left to work out is this odd behavior it has where it will sometimes hover a ways a way from a bot. I tried to fix this by adding an approaching routine, but now they will sometimes orbit veggies. I need to take a deeper look at this. But other than that, the IFFF and situational conditions work like a charm. It still doesn't get past beholder (which is where the current build of 1.1 is stuck) but I'm really thinking about stealing it's eyes. SF2 can fight off beholder pretty good, but it gets swarmed very quickly. How did you get past it, ikke?


Version 1.1 is running stable and effectively. Even though it fails to beat beholder, I finally put in Gimmick's eye system for testing. I'll see how good it does when I get back, and after that all that is left is final tweaking and optimization. SF1.1 will be released for the F3 league in earnest by tuesday at the latest. Version 2.00 will take a while longer, scince I plan on testing out eyebot's system as a replacement. And if I can figure it out, I might try beholder's system, too. Though beholder really only beats me by swarming to death...
« Last Edit: April 03, 2009, 09:41:42 AM by Ta-183 »

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
Slam Funk 1.0
« Reply #28 on: April 03, 2009, 12:08:09 PM »
Quote from: Ta-183
How did you get past it, ikke?
I based Gimmick on Defence, so I had a headstart. In general when advancing I did one of three things (more or less in this order)
1) I stole the code that caused the opponent to be superior.
2) I countered the code that made it superior by inventing my own
3) I stole code of the next bot in the competition.

By stealing I got understanding of genes and the associated sysvars and how they had to be used. I often pitted variants of gimmick (differing in code or parameters) against each other to see which code was superior.

Offline Ta-183

  • Bot Destroyer
  • ***
  • Posts: 105
    • View Profile
Slam Funk 1.0
« Reply #29 on: April 03, 2009, 01:36:39 PM »
Well, it looks like I'm going to have plenty of time to do that now. I f*@^ing got suspended from school because of my computer usage (nothing to due with DB, it's my budding career as a military historian that bought me this little... delight....    ) I have been taking a different route, instead of trying to change it's behavior, I've been trying to improve it's general performance. This mainly has to do with aiming, targeting, reproduction, and other factors. I could beat beholder if I could just get these bots to reproduce faster and better.