Battleship: BAT2F on the TI-83

The Battleship game presented here is available as the file BAT2F.83p from this web location. This is the TI-83 version of the BAT2F program. There are other versions of the same program, BAT2F.85p for the TI-85, BAT2F.86p for the TI-86, BAT2F.89p for the TI-89, mand BAT2F.92p for the TI-92. All of these are played in all four quadrants and on the axes, using only integer points between (– 10,10), (10,– 10), (10,10), and (– 10,10). A graph of that region is given below.
The game starts with the calculator selecting a hidden location for the battleship. It is our job to find that location by guessing coordinates of possible points. (Note that there is a more simple version of the game, BAT1F, that is explained on the a different web page. Some of the strategy explained below is given a more extensive treatment on that page.)
Figure 1
In Figure 1 we have started the program. The calculator has placed the ship and it has asked for our guess.
Figure 2
In Figure 2 we have made our guess at the point (5,5), and the calculator has informed us that the distance from our guess to the ship is approximately 12.1655 units. That means that the ship is located somewhere on a circle with center at (5,5) and with a radius of 12.1655 units. We have graphed part of such a circle below.
We look at the possible locations for the battleship. The point (– 7,5) is not on the arc drawn above, but it is close. For the purpose of this exercise we will use that point as our next guess.
Figure 3
Figure 3 shows that next guess and the calculator response that (– 7,5) is about 15.62 units away from the ship. We can draw a new part of a circle with center at (– 7,5) and radius 15.62. Now the graph appears as:
It is clear from the graph above that the ship must be at the point (3,– 7). Of course, we could try some other point just to check the system.
Figure 4
In Figure 4 the player has used an unnecessary guess, at (7,– 7). This guess is off from the battleship by exactly 4 units. The graph above has been modified to add the circle with center at (7,– 7) and radius equal to 4 to give:
This graph makes it even more clear that the ship is at the point where all three circles intersect, namely, (3,– 7).
Figure 5
Figure 5 confirms our computed answer.

As in the earlier web page describing the BAT1F program, we would like to be able to compute an answer without having to draw the graphs. In that earlier page we noted that if we make a guess at the lower left of the playing field, that is, at (– 10,– 10), then we have estricted the location of the ship to a quarter circle with center at that lower left corner. For example, if the distance from our guess to the ship is about 19.6468 then the graph would appear as:

We know that the ship is somewhere on that arc. Let us call the location of the ship (p,q). For now we will place (p,q) at an arbitrary point of the arc, just so that we can look at the consequences of having (p,q) on the arc. We draw the line segment from the lower left corner, (– 10,– 10) to the point (p,q), and the line segment from (p,q) to the bottom of the playing field, and the line segment from there back to the left corner. Remember that the point (p,q) has integer coordinates, because the ship is at a point with integer coordinates. That means that the the vertical line segment is an integer number of units long: we will call that distance b. In addition, the horizontal line segment is an integer number of units long: we will call that distance a. If we call the distance from our guess, (– 10,– 10), to the ship, (p,q), the distance r then we have a right triangle as shown below.
Then we return to the Pythagorean Theorem to see that
a2 + b2 = r2
We know that a and b are integers. Therefore, a2 + b2 is an integer, and, as a result we know that r2 must be an integer. We will use this knowledge, along with the following table of squares, to compute possible locations for the ship.
number 012345678910 11121314151617181920
number2 0149162536496481100 121144169196225256289324361400

Figure 6
Figure 6 shows the start of a new game. The first guess is at the lower left corner of the playing field, (– 10,10).
Figure 7
Our guess turns out to be 19.64688 units away from the ship. That is the value of r is approximately, 19.64688 units. We can computer 19.646882 and we find that it is approximately 385.999. We know that r2 is an integer. Thus, we recognize that r2=386. We need to find two perfect squares of integers that add to give 386. We can look at the second row of the table above and find that 386=25+361. That is,
r2=52+192
The sides of our triangle could be 5 and 19. Starting from (– 10,10) we can move to the right 5 units (so that x=– 5) and then up 19 units to the point (9,– 5), or we could start at (– 10,10) and move 19 units to the right and then move 5 units up, arriving at the point (9,– 5). Either point will be the correct distance from the original guess. The grid and the two possible triangles are shown below.
Figure 8
The next guess is at (10,10). The distance from the ship to this point is about 24.207 units. Again, we could construct a right triangel from (10,10) to the ship and then down to the bottom of the playing field, and then back to the point at the lower right. This would be a right triangle with the hypotenuse about 24.207 units long. We calculate
24.2072 = 585.978849
which means that the square of the hypotenuse will be the integer 586. We need to find two perfect square integers that add to 586. Examining the table above we see that
225 + 361 = 586
or
152 + 192 = 586
Therefore we can have the sides of the triangle be 15 and 19. Starting from (10,10) we could go back 19 (so x=– 9) and then up 15 to get to the point (– 9,5). However, that was not a possible solution from Figure 8. Alternatively, we could start at (10,10) and go back 15 and then up 19 to end at the point (– 5,9). This is one of the points that we found before. Therefore, this is the location of the battleship.
Figure 9
Here is a confirmtion of our calculation.
Figure 10
As usual, to get out of the program, press the key. This will bring up the screen shown in Figure 10. Press the key to quit and return to normal calculator operation.

©Roger M. Palay
Saline, MI 48176
May, 2001