Legacy GM [unsolved] Loops + Arrays = FUN!

D

DyingSilence

Guest
So, I'm writing a genetic algorhitm for learning purposes, its task is to git gud at a fighting game.

I stumbled upon the issue:
The game freezes after meeting the "brain's" reaction conditions.

Here's the brain interpreter:


Code:
///the brain code

i=0;
j=0;
if(fighter!=0)
{
while(i<neurons)
{
    //checking the conditions of neuron
    possitive=1;
    while(network[i,j]!=0)
    {
        //"poss" condition checks if something is someplace
        if(network[i,j]=="poss")
        {
            if(!position_meeting(fighter.x+network[i,j+2],fighter.y+network[i,j+3],network[i,j+1]))
            {
                possitive=0;
                j+=4;
            }
        }//end of possitional checking
    }//end of condition loop
    //bot keypress handling
    j++;
    if(possitive&&j>1)
    {
        while(network[i,j]!=0)
        {
            if(network[i,j]=="left")
            {
                fighter.left=1;
            }
            if(network[i,j]=="right")
            {
                fighter.right=1;
            }
            if(network[i,j]=="attack")
            {
                fighter.attack=1;
            }
            if(network[i,j]=="shoot")
            {
                fighter.shoot=1;
            }
            if(network[i,j]=="shield")
            {
                fighter.shield=1;
            }
            j++;
        }
        idle=0;
    }
    i++;
    j=0;
}//end of brain loop
}//end of checking if fighter exists
idle++;
And here's the single neuron I'm using:


Code:
network[neurons,0]="poss";
network[neurons,1]=obj_solid;
network[neurons,2]=17;
network[neurons,3]=17;
network[neurons,4]=0;
network[neurons,5]="right";
network[neurons,6]=0;

neurons++;
Yet, the game freezes when a fighter sees a floor beneath. Any ideas why?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
One of your while loops is not breaking. Throw some show_debug_message callis into the loops to see exactly what they are actually doing (or run it in the debugger with a breakpoint for that part, then step through the code).
 
Top