Not sure where my error is coming from

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
User avatar
Xaos
Posts: 940
Joined: Wed Jan 11, 2012 4:01 am

Not sure where my error is coming from

Post by Xaos »

Code: Select all

<?php
 
 
/*Strength 0, Speed 1, Hips 2, Agility 3, Tackling 4, Pass Blocking 5, Run Blocking 6, Diagnose 7, Passing Accuracy 8, Arm Power 9, Catching 10, Jumping 11,
Ball Security 12, Pocket Presence 13, Fitness 14, Personality 15, Finesse Move 16, Power Move 17, Punting Power 18, Punting Accuracy 19, Kicking Strength 20,
Kicking Accuracy 21, Clutch 22, Vision 23, Man Coverage 24, Zone Coverage 25, Route Running 26, Power/Finesse Tendency 27*/
 
$gap = ['status','status','status','status','status','status','status','status','status','status'];
 
$c = [99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99  ,"Center"];
$nt = [99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,100,"Nose"];
$rG = [99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,"Right Guard"];
$rDE = [99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,100,"Right Defensive End"];
$lG = [99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,"Left Guard"];
$lDE = [99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,100,"Left Defensive End"];
$lT = [99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,"Left Tackle"];
$dt = [99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,100,"Defensive Tackle"];
$rT = [99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,"Right Tackle"];
//Run Blocking - $oPlayer[0]*8 + $oPlayer[2]*7 + $oPlayer[6]*6 + $oPlayer[7]*5 + $oPlayer[23]*4 + $oPlayer[3]*3 + $oPlayer[1]*2 + $oPlayer[13] 
//Pass Blocking - $oPlayer[2]*8 + $oPlayer[5]*7 + $oPlayer[0]*6 + $oPlayer[3]*5 + $oPlayer[7]*4 + $oPlayer[13]*3 + $oPlayer[1]*2 + $oPlayer[23]
//Rush-Stuffing - $dPlayer[0]*8 + $dPlayer[2]*7 + $dPlayer[3]*6 + $dPlayer[17]*5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[1]*2 + $dPlayer[16]
//Pass-Rushing - $dPlayer[1]*8 + $dPlayer[2]*7 + $dPlayer[3]*6 + $dPlayer[16]*5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[0]*2 + $dPlayer[17]
$tendency1 = rand(1,100);
$play1 = ['run',$gap[2]];

function blocking($play,$tendency,$oPlayer,$dPlayer,$gap){
if($play === 'pass'){
if($tendency >= $dPlayer[27]){
  echo $dPlayer[28] . " Brings the bull-rush</br>";
  $oPower = (($oPlayer[2]*8 + $oPlayer[5]*7 + $oPlayer[0]*6.5 + $oPlayer[3]*5 + $oPlayer[7]*4 + $oPlayer[13]*3 + $oPlayer[1]*2 + $oPlayer[23])/8) + ((($oPlayer[2]*8 + $oPlayer[5]*7 + $oPlayer[0]*6.5 + $oPlayer[3]*5 + $oPlayer[7]*4 + $oPlayer[13]*3 + $oPlayer[1]*2 + $oPlayer[23])/8) * rand());
  $dPower = (($dPlayer[1]*8 + $dPlayer[2]*7 + $dPlayer[3]*6 + $dPlayer[16]*5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[0]*2.5 + $dPlayer[17])/8) + ((($dPlayer[1]*8 + $dPlayer[2]*7 + $dPlayer[3]*6 + $dPlayer[16]*5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[0]*2.5 + $dPlayer[17])/8) * rand());
  if($oPower > $dPower){
    echo $oPlayer[27] . " holds the " . $dPlayer[28] . "</br>";
  }elseif($oPower < $dPower){
    echo $dPlayer[28] . " pushes the pocket</br>";
 
  }elseif($oPower == $dPower){
    echo "The " . $oPlayer[27] . " and " . $dPlayer[28] . " are stood up</br>";
  }
}elseif($tendency < $dPlayer[27]){
  echo $dPlayer[28] . " Brings the finesse</br>";
  $Block =  (($oPlayer[2]*8 + $oPlayer[5]*7 + $oPlayer[0]*6 + $oPlayer[3]*5.5 + $oPlayer[7]*4 + $oPlayer[13]*3.5 + $oPlayer[1]*2.5 + $oPlayer[23])/8) + ((($oPlayer[2]*8 + $oPlayer[5]*7 + $oPlayer[0]*6 + $oPlayer[3]*5.5 + $oPlayer[7]*4 + $oPlayer[13]*3.5 + $oPlayer[1]*2.5 + $oPlayer[23])/8) * rand());
  $Finesse = (($dPlayer[1]*8.5 + $dPlayer[2]*7 + $dPlayer[3]*6.5 + $dPlayer[16]*5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[0]*2 + $dPlayer[17])/8) + ((($dPlayer[1]*8.5 + $dPlayer[2]*7 + $dPlayer[3]*6.5 + $dPlayer[16]*5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[0]*2 + $dPlayer[17])/8) * rand());
  if($Block > $Finesse){
    echo $oPlayer[27] . " rides the " . $dPlayer[28] . " out</br>";
  }elseif($Block < $Finesse){
    echo $dPlayer[28] . " blows by the " . $oPlayer[27] . "</br>";
  }elseif($Block == $Finesse){
    echo $oPlayer[27] . " and " . $dPlayer[28] . " are stood up</br>";
  }
}
 
}elseif($play === 'run'){
    if($tendency >= $dPlayer[27]){
     echo $dPlayer[28] . " brings the power</br>";
     $oPower = (($oPlayer[0]*8.5 + $oPlayer[2]*7 + $oPlayer[6]*6.5 + $oPlayer[7]*5 + $oPlayer[23]*4 + $oPlayer[3]*3 + $oPlayer[1]*2 + $oPlayer[13])/8) + ((($oPlayer[0]*8.5 + $oPlayer[2]*7 + $oPlayer[6]*6.5 + $oPlayer[7]*5 + $oPlayer[23]*4 + $oPlayer[3]*3 + $oPlayer[1]*2 + $oPlayer[13])/8) * rand());
     $dPower = (($dPlayer[0]*8.5 + $dPlayer[2]*7 + $dPlayer[3]*6 + $dPlayer[17]*5.5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[1]*2 + $dPlayer[16])/8) + ((($dPlayer[0]*8.5 + $dPlayer[2]*7 + $dPlayer[3]*6 + $dPlayer[17]*5.5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[1]*2 + $dPlayer[16])/8) * rand());
     if($oPower > $dPower){
         echo $oPlayer[27] . " creates a hole</br>";
         $gap = 'open';
     }elseif($oPower < $dPower){
         echo $dPlayer[28] . " pushes the " . $oPlayer[27] . "into the gap</br>";
         $gap = 'closed';
     }elseif($oPower == $dPower){
         echo $oPlayer[27] . " and " . $dPlayer[28] . " stand up</br>";
         $gap = 'partial';
     }
    }elseif($tendency < $dPlayer[27]){
        echo $dPlayer[28] . " tries to finesse</br>";
        $Block = (($oPlayer[0]*8 + $oPlayer[2]*7.5 + $oPlayer[6]*6 + $oPlayer[7]*5 + $oPlayer[23]*4 + $oPlayer[3]*3.5 + $oPlayer[1]*2.5 + $oPlayer[13])/8) + ((($oPlayer[0]*8 + $oPlayer[2]*7.5 + $oPlayer[6]*6 + $oPlayer[7]*5 + $oPlayer[23]*4 + $oPlayer[3]*3.5 + $oPlayer[1]*2.5 + $oPlayer[13])/8) * rand());
        $Finesse = (($dPlayer[0]*8 + $dPlayer[2]*7.5 + $dPlayer[3]*6.5 + $dPlayer[17]*5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[1]*2.5 + $dPlayer[16]*1.5)/8) + ((($dPlayer[0]*8 + $dPlayer[2]*7.5 + $dPlayer[3]*6.5 + $dPlayer[17]*5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[1]*2.5 + $dPlayer[16]*1.5)/8) * rand());
        if($Block > $Finesse){
            echo $oPlayer[27] . " drives " . $dPlayer[28] . " out of the hole</br>";
            $gap = 'open';
        }elseif($Block < $Finesse){
            echo $dPlayer[28] . " sheds the " . $oPlayer[27] . " and fills the gap</br>";
            $gap = 'closed';
        }elseif($Block == $Finesse){
            echo $oPlayer[27] . " and " . $dPlayer[28] . " are stood up</br>";
            $gap = 'partial';
           
        }
       
    }
}
} 
 
function doubleTeam($play,$tendency,$oPlayer1,$oPlayer2,$dPlayer,$gap){
    $length1 = count($oPlayer1);
    $length2 = count($oPlayer2);
    for($i=0;$i < $length1-1;$i++){
        $oPlayer1[$i] =+ $oPlayer1[$i] * 1.5;
    }
    for($j=0;$j < $length2-1;$j++){
        $oPlayer2[$j] =+ $oPlayer2[$j] *1.5;
    }
    for($i = 0;$i < $length1-1;$i++){
    $oPlayer[$i] = ($oPlayer1[$i] + $oPlayer2[$i]) / 2;
}
$oPlayer[27] = $oPlayer1[27] . " and " . $oPlayer2[27];
 
blocking($play,$tendency,$oPlayer,$dPlayer,$gap);
 
}
 

function running($oPlayer,$gap,$playGap){
$visionCheck = rand(1,100);
if(($oPlayer[23]+ $oPlayer[7])/2 >= $visionCheck){
    if($gap[$playGap] === 'open'){
        $runningGap = $playGap;
        echo $runningGap;
    }elseif($gap[$playGap] == 'partial'){
        $runningGap = $playGap;
        echo $runningGap;
    }elseif($gap[$playGap] == 'closed'){
        
    $gapCount = count($gap);
    $count = 0;
    $count1 = 0;
    for($i=0; $i > $gapCount; $i++){
    if($gap[$i] == 'open'){
        $runningGap = $gap[$i];
        echo $runningGap;
    }else{
        $count++;
    }
    if($count == count($gap)){
        if($gap[$i] == 'partial'){
            $runningGap = $gap[$i];
            echo $runningGap;
        }else{
            $count1++;
        }
    }if($count1 == count($gap)){
        $runningGap = $playGap;
        echo $runningGap;
    }
    } 
    }
}elseif(($oPlayer[23]+ $oPlayer[7])/2 < $visionCheck){
    $failedCheck = rand(1,$gap.length);
    $runningGap = $failedCheck;
    echo $runningGap;
}
 
}
 
 
doubleTeam($play1[0],$tendency1,$lG,$c,$nt,$gap[0]);
blocking($play1[0],$tendency1,$rG,$dt,$gap[1]);
blocking($play1[0],$tendency1,$lT,$rDE,$gap[2]);
blocking($play1[0],$tendency1,$rT,$lDE,$gap[3]);
running($rG,$gap,$gap[0]);
?>
When I try to run the running fuction, I get

Undefined index: status - line 110, 113, 116.

Any help guys? All of the other functions work, and use the same things.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Not sure where my error is coming from

Post by Jackolantern »

You really need to comment your code :| lol

I will try to sit down and see what is going on in just a little bit, but having no comments definitely makes it harder.
The indelible lord of tl;dr
User avatar
Xaos
Posts: 940
Joined: Wed Jan 11, 2012 4:01 am

Re: Not sure where my error is coming from

Post by Xaos »

Jackolantern wrote:You really need to comment your code :| lol

I will try to sit down and see what is going on in just a little bit, but having no comments definitely makes it harder.

I went back and commented it, but that's all on my desktop, and unfortunately, this is all my laptop :'(
User avatar
Xaos
Posts: 940
Joined: Wed Jan 11, 2012 4:01 am

Re: Not sure where my error is coming from

Post by Xaos »

Code: Select all

<?php 
 
 
/*Strength 0, Speed 1, Hips 2, Agility 3, Tackling 4, Pass Blocking 5, Run Blocking 6, Diagnose 7, Passing Accuracy 8, Arm Power 9, Catching 10, Jumping 11,
Ball Security 12, Pocket Presence 13, Fitness 14, Personality 15, Finesse Move 16, Power Move 17, Punting Power 18, Punting Accuracy 19, Kicking Strength 20,
Kicking Accuracy 21, Clutch 22, Vision 23, Man Coverage 24, Zone Coverage 25, Route Running 26, Power/Finesse Tendency 27*/
 
$gap = ['status','status','status','status','status','status','status','status','status','status'];
//Creates the status for each gap. Each index of the gap array is considered a different gap
 
$c = [99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99 ,"Center"];
$nt = [99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,100,"Nose"];
$rG = [99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,"Right Guard"];
$rDE = [99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,100,"Right Defensive End"];
$lG = [99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,"Left Guard"];
$lDE = [99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,100,"Left Defensive End"];
$lT = [99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,"Left Tackle"];
$dt = [99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,100,"Defensive Tackle"];
$rT = [99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,"Right Tackle"];
//Creates players adn their attributes

//Run Blocking - $oPlayer[0]*8 + $oPlayer[2]*7 + $oPlayer[6]*6 + $oPlayer[7]*5 + $oPlayer[23]*4 + $oPlayer[3]*3 + $oPlayer[1]*2 + $oPlayer[13] 
//Pass Blocking - $oPlayer[2]*8 + $oPlayer[5]*7 + $oPlayer[0]*6 + $oPlayer[3]*5 + $oPlayer[7]*4 + $oPlayer[13]*3 + $oPlayer[1]*2 + $oPlayer[23]
//Rush-Stuffing - $dPlayer[0]*8 + $dPlayer[2]*7 + $dPlayer[3]*6 + $dPlayer[17]*5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[1]*2 + $dPlayer[16]
//Pass-Rushing - $dPlayer[1]*8 + $dPlayer[2]*7 + $dPlayer[3]*6 + $dPlayer[16]*5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[0]*2 + $dPlayer[17]
$tendency1 = rand(1,100); //For power/finesse tendency
$play1 = ['run',$gap[1]]; //Creates the play

function blocking($play,$tendency,$oPlayer,$dPlayer,$gap){
if($play === 'pass'){
if($tendency >= $dPlayer[27]){ //If tendency is higher or equal than 27, bull-rush
  echo $dPlayer[28] . " Brings the bull-rush</br>"; 
  $oPower = (($oPlayer[2]*8 + $oPlayer[5]*7 + $oPlayer[0]*6.5 + $oPlayer[3]*5 + $oPlayer[7]*4 + $oPlayer[13]*3 + $oPlayer[1]*2 + $oPlayer[23])/8) + ((($oPlayer[2]*8 + $oPlayer[5]*7 + $oPlayer[0]*6.5 + $oPlayer[3]*5 + $oPlayer[7]*4 + $oPlayer[13]*3 + $oPlayer[1]*2 + $oPlayer[23])/8) * rand());
  $dPower = (($dPlayer[1]*8 + $dPlayer[2]*7 + $dPlayer[3]*6 + $dPlayer[16]*5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[0]*2.5 + $dPlayer[17])/8) + ((($dPlayer[1]*8 + $dPlayer[2]*7 + $dPlayer[3]*6 + $dPlayer[16]*5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[0]*2.5 + $dPlayer[17])/8) * rand());
  if($oPower > $dPower){ //If the offensive player has more power than the defensive
    echo $oPlayer[27] . " holds the " . $dPlayer[28] . "</br>";
  }elseif($oPower < $dPower){ //If the defensive player has more than the offensive
    echo $dPlayer[28] . " pushes the pocket</br>";
 
  }elseif($oPower == $dPower){ //If they are equal....should be very rare
    echo "The " . $oPlayer[27] . " and " . $dPlayer[28] . " are stood up</br>";
  }
}elseif($tendency < $dPlayer[27]){ //If tendency is lower, bring the speed
  echo $dPlayer[28] . " Brings the finesse</br>";
  $Block =  (($oPlayer[2]*8 + $oPlayer[5]*7 + $oPlayer[0]*6 + $oPlayer[3]*5.5 + $oPlayer[7]*4 + $oPlayer[13]*3.5 + $oPlayer[1]*2.5 + $oPlayer[23])/8) + ((($oPlayer[2]*8 + $oPlayer[5]*7 + $oPlayer[0]*6 + $oPlayer[3]*5.5 + $oPlayer[7]*4 + $oPlayer[13]*3.5 + $oPlayer[1]*2.5 + $oPlayer[23])/8) * rand());
  $Finesse = (($dPlayer[1]*8.5 + $dPlayer[2]*7 + $dPlayer[3]*6.5 + $dPlayer[16]*5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[0]*2 + $dPlayer[17])/8) + ((($dPlayer[1]*8.5 + $dPlayer[2]*7 + $dPlayer[3]*6.5 + $dPlayer[16]*5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[0]*2 + $dPlayer[17])/8) * rand());
  if($Block > $Finesse){ //If the O player can block the D player speed
    echo $oPlayer[27] . " rides the " . $dPlayer[28] . " out</br>";
  }elseif($Block < $Finesse){  //If the D player beats the O player
    echo $dPlayer[28] . " blows by the " . $oPlayer[27] . "</br>";
  }elseif($Block == $Finesse){ //If they're equal, should be very rare
    echo $oPlayer[27] . " and " . $dPlayer[28] . " are stood up</br>";
  }
}
 
}elseif($play === 'run'){
    if($tendency >= $dPlayer[27]){ //Same as above, but for run stopping. Bring the power
     echo $dPlayer[28] . " brings the power</br>";
     $oPower = (($oPlayer[0]*8.5 + $oPlayer[2]*7 + $oPlayer[6]*6.5 + $oPlayer[7]*5 + $oPlayer[23]*4 + $oPlayer[3]*3 + $oPlayer[1]*2 + $oPlayer[13])/8) + ((($oPlayer[0]*8.5 + $oPlayer[2]*7 + $oPlayer[6]*6.5 + $oPlayer[7]*5 + $oPlayer[23]*4 + $oPlayer[3]*3 + $oPlayer[1]*2 + $oPlayer[13])/8) * rand());
     $dPower = (($dPlayer[0]*8.5 + $dPlayer[2]*7 + $dPlayer[3]*6 + $dPlayer[17]*5.5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[1]*2 + $dPlayer[16])/8) + ((($dPlayer[0]*8.5 + $dPlayer[2]*7 + $dPlayer[3]*6 + $dPlayer[17]*5.5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[1]*2 + $dPlayer[16])/8) * rand());
     if($oPower > $dPower){
         echo $oPlayer[27] . " creates a hole</br>";
         $gap = 'open';
     }elseif($oPower < $dPower){ 
         echo $dPlayer[28] . " pushes the " . $oPlayer[27] . "into the gap</br>";
         $gap = 'closed';
     }elseif($oPower == $dPower){
         echo $oPlayer[27] . " and " . $dPlayer[28] . " stand up</br>";
         $gap = 'partial';
     }
    }elseif($tendency < $dPlayer[27]){ //Same as above, but for bringing the speed against the run
        echo $dPlayer[28] . " tries to finesse</br>";
        $Block = (($oPlayer[0]*8 + $oPlayer[2]*7.5 + $oPlayer[6]*6 + $oPlayer[7]*5 + $oPlayer[23]*4 + $oPlayer[3]*3.5 + $oPlayer[1]*2.5 + $oPlayer[13])/8) + ((($oPlayer[0]*8 + $oPlayer[2]*7.5 + $oPlayer[6]*6 + $oPlayer[7]*5 + $oPlayer[23]*4 + $oPlayer[3]*3.5 + $oPlayer[1]*2.5 + $oPlayer[13])/8) * rand());
        $Finesse = (($dPlayer[0]*8 + $dPlayer[2]*7.5 + $dPlayer[3]*6.5 + $dPlayer[17]*5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[1]*2.5 + $dPlayer[16]*1.5)/8) + ((($dPlayer[0]*8 + $dPlayer[2]*7.5 + $dPlayer[3]*6.5 + $dPlayer[17]*5 + $dPlayer[7]*4 + $dPlayer[23]*3 + $dPlayer[1]*2.5 + $dPlayer[16]*1.5)/8) * rand());
        if($Block > $Finesse){
            echo $oPlayer[27] . " drives " . $dPlayer[28] . " out of the hole</br>";
            $gap = 'open'; //Makes the gap that the players are fighting in open because the offensive player blocked the defensive
        }elseif($Block < $Finesse){
            echo $dPlayer[28] . " sheds the " . $oPlayer[27] . " and fills the gap</br>";
            $gap = 'closed'; //The defensive player wins, closes the gap
        }elseif($Block == $Finesse){
            echo $oPlayer[27] . " and " . $dPlayer[28] . " are stood up</br>";
            $gap = 'partial'; //If they are equal, the gap is partial open. Very rare
           
        }
       
    }
}
} 
 
function doubleTeam($play,$tendency,$oPlayer1,$oPlayer2,$dPlayer,$gap){ //Two offensive players block one defensive player
    $length1 = count($oPlayer1);
    $length2 = count($oPlayer2);
    for($i=0;$i < $length1-1;$i++){ //Runs a loop for the oPlayer1 array
        $oPlayer1[$i] =+ $oPlayer1[$i] * 1.5; //Adds 150% to each attribute
    }
    for($j=0;$j < $length2-1;$j++){
        $oPlayer2[$j] =+ $oPlayer2[$j] *1.5; //Same as above
    }
    for($i = 0;$i < $length1-1;$i++){
    $oPlayer[$i] = ($oPlayer1[$i] + $oPlayer2[$i]) / 2; // Finds the average of each attribute between the two players
}
$oPlayer[27] = $oPlayer1[27] . " and " . $oPlayer2[27]; //Accounts for the double-team in play-by-play. Adds the two players together basically.
 
blocking($play,$tendency,$oPlayer,$dPlayer,$gap); //Now makes the two players block
 
}
 

function running($oPlayer,$gap,$playGap){ 
$visionCheck = rand(1,100);
if(($oPlayer[23]+ $oPlayer[7])/2 >= $visionCheck){ //If the player's vision is higher than the vision check, they see open holes
    if($gap[$playGap] === 'open'){ //If the play gap, the gap that play is designed to go, is open
        $runningGap = $playGap; //Go there
        echo $runningGap;
    }elseif($gap[$playGap] == 'partial'){ //If the play gap is partially open
        $runningGap = $playGap; //Go there
        echo $runningGap;
    }elseif($gap[$playGap] == 'closed'){ //If the play gap is closed
        
    $gapCount = count($gap);
    $count = 0;
    $count1 = 0;
    for($i=0; $i > $gapCount; $i++){ //Run through the gaps
    if($gap[$i] == 'open'){ //Check if the gaps are open. Run through the order on purpose. The runningback reads inside to outside
        $runningGap = $gap[$i]; //Go to the firs topen gap
        echo $runningGap;
    }else{
        $count++; //For every gap that isn't open, add to this counter.
    }
    if($count == count($gap)){ //If the first counter reaches the number of indexes in gap
        if($gap[$i] == 'partial'){ //Check every gap for a partially open gap
            $runningGap = $gap[$i]; //Go to the first partially open gap
            echo $runningGap;
        }else{
            $count1++; //For every partially open gap, add to this counter.
        }
    }if($count1 == count($gap)){ //If no gaps are partially open,
        $runningGap = $playGap; //Go to the play gap!
        echo $runningGap;
    }
    } 
    }
}elseif(($oPlayer[23]+ $oPlayer[7])/2 < $visionCheck){ //If the player failed the vision check
    $failedCheck = rand(1,count($gap)); //Find a random gap
    $runningGap = $failedCheck; //Go to that gap.
    echo $runningGap;
}
 
}
 
//Call each function. 
doubleTeam($play1[0],$tendency1,$lG,$c,$nt,$gap[0]);
blocking($play1[0],$tendency1,$rG,$dt,$gap[1]);
blocking($play1[0],$tendency1,$lT,$rDE,$gap[2]);
blocking($play1[0],$tendency1,$rT,$lDE,$gap[3]);
running($rG,$gap,$gap[0]);
?>
There, commented it :D
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: Not sure where my error is coming from

Post by hallsofvallhalla »

your issue is here

Code: Select all

function running($oPlayer,$gap,$playGap){ 
$visionCheck = rand(1,100);
if(($oPlayer[23]+ $oPlayer[7])/2 >= $visionCheck){ //If the player's vision is higher than the vision check, they see open holes
    if($gap[$playGap] === 'open'){ //If the play gap, the gap that play is designed to go, is open
        $runningGap = $playGap; //Go there
        echo $runningGap;
    }elseif($gap[$playGap] == 'partial'){ //If the play gap is partially open
        $runningGap = $playGap; //Go there
        echo $runningGap;
    }elseif($gap[$playGap] == 'closed'){ //If the play gap is closed

when you are calling the index of
if($gap[$playGap]

$playgap is equal to 'status' therefore is not an index. $PlayGap should be an index number. echo $playGap and see what it equals and unless I am wrong you will see it equals 'status' which is not an index of $gap
User avatar
Xaos
Posts: 940
Joined: Wed Jan 11, 2012 4:01 am

Re: Not sure where my error is coming from

Post by Xaos »

Okay, playGap does equal status. How do I get $playGap to equal $gap[X] to equal $play1[1] ?

Oddly enough as well, if I just use a number, such as 2, NOTHING happens! It's almost as if the function doesn't run. Even if I make $gap global.


nevermind. I made all $gap global and whatnot, and now I get:

Unintialized string offset: 5 on lines 118, 121 and 124. I just put 5 for $playGap. However, it seems that if the player fails the vision check, he ALWAYS goes to gap 1. That's the only time I can get the echo to work, but not sure why its only going to 1.
User avatar
MikuzA
Posts: 394
Joined: Thu Aug 08, 2013 8:57 am

Re: Not sure where my error is coming from

Post by MikuzA »

Hello,
I didn't analyse the intentions on how you built this to the complete but how about just changing the $gap[0] to 0.
Since if you are using inside the running()-function the $playGap as an index-number, then it should only be the number passed through right?

Code: Select all

running($rG,$gap,$gap[0]);
 

Code: Select all

running($rG,$gap,0);
 
Or am I totally lost here :-D
Why so serious?

Business Intelligence, Data Engineering, Data Mining
PHP, HTML, JavaScript, Bash/KornShell, Python, C#, PL/SQL
MySQL, DB2, Oracle, Snowflake
Pentaho, DataStage, Matillion, Unity3D, Blender
User avatar
Xaos
Posts: 940
Joined: Wed Jan 11, 2012 4:01 am

Re: Not sure where my error is coming from

Post by Xaos »

MikuzA wrote:Hello,
I didn't analyse the intentions on how you built this to the complete but how about just changing the $gap[0] to 0.
Since if you are using inside the running()-function the $playGap as an index-number, then it should only be the number passed through right?

Code: Select all

running($rG,$gap,$gap[0]);

Code: Select all

running($rG,$gap,0);
Or am I totally lost here :-D
The problem is though, I need the gaps to be 'open', 'partial' or 'closed', so just making them numbers would not allow that. And even when I pass just a number for that parameter, I got an uninitialized string offset error.
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: Not sure where my error is coming from

Post by hallsofvallhalla »

it is a lot to look through and figure out what you are doing but you should just be looping through $gap

Code: Select all

for($i=0;$i<count($gap);$i++)
{
echo $gap[$i];
}
User avatar
Xaos
Posts: 940
Joined: Wed Jan 11, 2012 4:01 am

Re: Not sure where my error is coming from

Post by Xaos »

hallsofvallhalla wrote:it is a lot to look through and figure out what you are doing but you should just be looping through $gap

Code: Select all

for($i=0;$i<count($gap);$i++)
{
echo $gap[$i];
}

Well gap is affected by the function blocking() and doubleTeam(). These two functions determine if gaps are 'open', 'partial', or 'closed'. So basically, I check if the playGap, the gap that the play is designed to go to, is open or partial. If it is open or partial, that is the $runningGap, the gap that the runner goes to, and that gap index is assigned to runningGap. IE if the playGap was 4, and gap[4] was open, runningGap would be gap[4]. If the playGap is closed, it loops through $gap, looking for any 'open' gaps. If there is an 'open' gap, that gap becomes $runningGap. Otherwise, for each gap that IS NOT open, $count is added onto. Once count equals the length of gap, it loops through $gap and finds any gaps that are 'partial'. For every gap that is not a partial, it adds onto count1. Once count1 equals the length of gap, it is true that no gaps are open or partial. Because no gaps are open nor partial, the runner goes back to the playGap. Does that make more sense?
Post Reply

Return to “Beginner Help and Support”