Rewersing directionof stepper motor with limit switch

Try this instead:

#include <AccelStepper.h>

// Define a stepper and the pins it will use
AccelStepper stepper(AccelStepper::FULL4WIRE, 8, 9, 10,11);

#define switchPinA 2
#define switchPinB 3
#define lowestRandomNum -100
#define highestRandomNum 100

void setup()
{
pinMode(switchPinA,INPUT);
pinMode(switchPinB,INPUT);
digitalWrite(switchPinA,HIGH);
digitalWrite(switchPinB,HIGH);
}

void loop()
{
if (stepper.distanceToGo() == 0)
{
// Random change to speed, position and acceleration
// Make sure we dont get 0 speed or accelerations
delay(1000);
long someRandomPosition=random(lowestRandomNum, highestRandomNum);
stepper.setMaxSpeed(random(0, highestRandomNum) + 1);
stepper.setAcceleration(random(1, highestRandomNum) + 1);
if(digitalRead(switchPinA)==HIGH || digitalRead(switchPinB)==HIGH)
{
someRandomPosition=someRandomPosition * -1; // just invert data
}
stepper.moveTo(someRandomPosition);
}
stepper.run();
}