As you can see (albeit somewhat blurrily), the program creates two grids, one for the player (you) and one for the computer (that, honestly, fires randomly because I'd already spent an entire programming and figured that making intelligent AI could wait for another day.) You fire with the typical Letter-Number pattern, which triggers the spot you're firing at to change to either an X (miss) or a ~ (hit). The program spawns the ship placements for both sides randomly, but won't have them overlap, and once all ships on one side are destroyed you (or the computer, somehow) win! I had planned to program the computer to fire in a 3x3 around any ship it managed to hit, but the following logistics sounded like it would take me deeper into the night than I was willing to go. I might return to this program and add that function if I can decipher what I'd written after the fact. Anyways, hope you enjoy this! It took me an entire day, like seven or eight solid hours of coding. Have a gander at the code if you like, and have a lovely day! See you at eight AM. ![]()
|
Yes, you read that title correct. Not only is it suffixed with a G instead of an A or P, but it also shares the name with a popular maritime game that had a terrible, terrible movie. Due to the growing number of 'games' that I'm messing around and trying to make, I'm opening up the bounds of organization from 'Automated Processes' and 'Presentations' (I might be bad at naming) to also have one for 'Games'. This program, in the Java command prompt, allows you to play Battleship against the computer against a randomly placed fleet of ships, and shows the both of you... Y'know what? Look below. Leave a Reply. |
AuthorName: Ada Archives
November 2019
Categories
All
|