ok, I have a new problem, this time it's a bit more complex. The issue isn't so much of getting it to work, because it works fine, but an issue of space.
I got through the player ship placement and drawing section, but then i started work on the computer's ships and after doing the first ship things started getting really, really long. Here's the code for the first and second ships, you'll see what I mean.
So I've arranged all the values into lists called "L BSHIP, L CARIR, L DSRYR, L SUB, L PTB" whose values are arranged {X1, X2, X3,X4, X5, Y1, Y2, etc}
randInt (0,9)-> A X Coordinate on 10x10 grid starting at 0
randInt (0,9)-> B Y Coordinate
randInt (1,2)-> C Whether it's oriented up or down
If A>8 and C=1:Then So that the ships don't go off grid
A->L BSHIP (4)
A-1 -> L BSHIP (3)
A-2 -> L BSHIP (2)
A-3 -> L BSHIP (1)
End
If A<2 and C=1:Then
A-> L BSHIP (1)
A+1 -> L BSHIP (2)
A+2 -> L BSHIP (3)
A+3 -> L BSHIP (4)
End
If A=/<8 and A=/>2 and C= 1:Then
A -> L BSHIP (3)
A+1 -> L BSHIP (4)
A-1 -> L BSHIP (2)
A-2 -> L BSHIP (1)
End
This is repeated substituting B for A and making the list value 4+ the value listed here and making the conditionals require C=2 instead of C=1
If C=1:Then
For (E,1,4)
B-> L BSHIP (E+4) So that when it's oriented on the X-Axis the Y values are all the same and vice versa
End:End
If C=2: Then
For (E,1,4)
A-> L BSHIP (E)
End:End
Here's the fun part, the second ship- everything works perfectly fine btw, I just need a slimmer way of managing this next bit of code
1->D
randInt(1,2)->C
Repeat D=5
randInt (0,9)-> A
For (E,1,4)
If A<8 and A>1:Then
If A= L BSHIP (E) xor A+1= L BSHIP (E) xor A+2= L BSHIP (E) xor A-1= L BSHIP(E) xor A-2= L BSHIP (E)
Then
1-> D Tells it to select another random integer and run this check again
Else
5->D
End:End
If A>7:Then
If A= L BSHIP (E) xor A-1= L BSHIP (E) xor A-2= L BSHIP (E) xor A-3= L BSHIP(E) xor A-4= L BSHIP (E)
Then
1->D
Else
5->D
End:End
If A<2:Then
If A= L BSHIP (E) xor A+1= L BSHIP (E) xor A+2= L BSHIP (E) xor A+3= L BSHIP(E) xor A+4= L BSHIP (E)
Then
1->D
Else
5-> D
End:End
End
1->D
Now it selects the Y Coordinate
Repeat D=5
randInt (0,9)-> B
For (E,1,4)
If B<8 and B>1:Then
If B= L BSHIP (E+4) xor B+1= L BSHIP (E+4) xor B+2= L BSHIP (E+4) xor B-1= L BSHIP(E+4) xor B-2= L BSHIP (E+4)
Then
1-> D
Else
5->D
End:End
If B>7:Then
If B= L BSHIP (E+4) xor B-3= L BSHIP (E+4) xor B-4= L BSHIP (E+4) xor B-1= L BSHIP(E+4) xor B-2= L BSHIP (E+4)
Then
1->D
Else
5->D
End:End
If B<2:Then
If B= L BSHIP (E+4) xor B+1= L BSHIP (E+4) xor B+2= L BSHIP (E+4) xor B+3= L BSHIP(E+4) xor B+4= L BSHIP (E+4)
Then
1->D
Else
5-> D
End:End
End
Now it sets the values of L CARIR
If A>7 and C=1:Then
A-> L CARIR (5)
A-1-> L CARIR (4)…..
A-4-> L CARIR (1)
End
If A<2 and C=1:Then
A-> L CARIR (1)
A+1-> L CARIR (2)……
A+4-> L CARIR (5)
End
If A<8 and A>1 and C=1:Then
A-> L CARIR (3)
A+1/2-> L CARIR (4/5)
A-1/2-> L CARIR (2/1)
End
Repeats for B, exactly the same except L CARIR is values between 6-10
For (E,1,5)
If D=1
B->L CARIR (E+5)
If D=2
A->L CARIR (E)
End
Hence my problem. The secton where it actually selects the coordinate is the main problem, as when I add third, fourth and fifth ships I will have to check each and every value with xor conditionals, which will be a real pain in the ass and take up loads of memory, and make the code difficult to debug. Any thoughts on how to do this with For loops, Repeats, whatever, would be greatly appreciated