Page 1 of 1

New game uploaded: Sea Battle

Posted: Sun Sep 06, 2020 8:23 pm
by CX16UserSteveC



Sea Battle




View File






Sea Battle is a variation on the classical game "Battleship". Sea Battle is a cc65 application currently compatible with revision R38 of the Commander X16 emulator. The graphics and computer targeting could both stand some improvement, but the game is fairly playable in it's current state. I believe computer targeting is strongest when "HIT NOTIFICATION" is configured as "IMMEDIATE" and "SHIP NOTIFICATION" is configured as "SHIP" which are the default settings. I'm at the point where I've had to optimize the code several times to squeeze in more functionality, and adding any significant additional functionality will likely require an investigation into the possibility of taking advantage of memory bank switching.

Configuration Options:


  • The "P" key is used to toggle the player-mode between single-player, two-player, and computer-vs-computer modes. The entity names on the bottom of the left and right grids illustrate the currently selected player-mode. The "S" key is used to toggle the fleet size between 5 and 6 ships. Player-mode and fleet size can only be changed before player-1 accepts configuration of their ships after which the "Q" key must be used to quit the game in order to change player-mode or fleet size.


  • The "F1" key is used to select the number of "TURN GUESSES" which consists of an initial number of guesses for the first turn and also the number of guesses for each subsequent turn. In "1/1" mode each player is allowed one guess per turn including the initial turn. In "n/SHIPS LEFT" mode the entity (player or computer) taking the first turn is allowed "n" guesses, and the number of guesses allowed on each subsequent turn is based on the number of ships left in the attacking entity's fleet. The ability to configure the number of guesses for the entity taking the first turn is intended to be a way to offset the advantage of taking the first turn.


  • The "F2" key is used to toggle the "HIT NOTIFICATION" between "IMMEDIATE" and "END OF TURN". This configuration is only relevant when "TURN GUESSES" is set to the "n/SHIPS LEFT" mode described above (since both "HIT NOTIFICATION" options are equivalent when "TURN GUESSES" is set to the "1/1" mode described above).


  • The "F3" key is used to control the "SHIP NOTIFICATION" related to the sinking of ships. When the "NONE" option is selected there is no notification of sunken ships. The "NONE" option only applies when "TURN GUESSES" is set to "1/1" as described above. When the "COUNT" option is selected the notification is limited to the sinking of a ship. When the "SHIP" option is selected a hidden ship is displayed on the grid when sunk.


Fleet Setup:


  • Two-Player Mode: In two-player mode player-1 selects their ships using the "1-6" keys, moves their ships using the cursor keys, and rotates their ships using the "L" and "R" keys. Ships of odd length are rotated about their center, and ships of even length are rotated about the the first segment behind their center. The currently selected ship is indicated by the cursor. Movements and rotations that result in part of the ship being off-grid are disallowed.The space bar may also be used to generate a random ship configuration. When player-1 presses the "ENTER" key the display of player-1's ships is turned off (assuming a valid ship configuration with no overlap of ships) and then player-2 configures the location of their ships in a likewise manner. When player-2 presses the "ENTER" key the display of player-2's ships is turned off and player-1 then takes the first turn. It is assumed each player looks the other way when their opponent configures the location of their ships.


  • Single-Player Mode: In single-player mode player-1 configures the location of their ships as described in the preceding paragraph. When player-1 presses the "ENTER" key the locations of the computer's ships are randomly generated and hidden. The location of player-1's ships remains visible to player-1 and the referee part of the application but are hidden from the computer opponent part of the application. Game play begins after player-1 chooses whether to take the initial turn or let the computer take the initial turn.


  • Computer-vs-Computer Mode: In computer-vs-computer mode the player configures the location of the ships for both computer opponents. Both ship configurations remain visible to the player and the referee part of the application for the entire game, but each computer's ships remain hidden to the opponent computer part of the application. After accepting both configurations with the "ENTER" key, the left computer takes the first turn. Computer-vs-computer mode is intended as an aid to explore the strengths and weaknesses of the computer targeting system and the effects of "n" on the game outcome when "TURN GUESSES" is configured to "n/SHIPS LEFT".


Game-Play:


  • Player: The cursor may be moved on the opponent's grid using the cursor keys. The "0-9" and "A-J" keys may also be used to select any column or row respectively. The space bar may be used to select a random untested coordinate, and the "T" key may be used to select a coordinate preferred by the computer targeting system. This last option is intended as an aid to explore the strengths and weaknesses of the computer targeting system. When the user presses the enter key the selected coordinate is fired upon. Hits are indicated by red, misses are indicated by white, the last hit that sinks a ship is indicated by orange (assuming "SHIP NOTIFICATION" is not configured to "NONE"), and yellow is used to temporarily indicate selected targets when "TURN GUESSES" is configured to "n/SHIPS LEFT" and "HIT NOTIFICATION" is configured to "END OF TURN".


  • Computer: When the computer takes it's turn the player is prompted to press a key to acknowledge each of the computer's guesses.


Support:

If you encounter a problem that you think is related to a bug in the source code please take and submit a screen shot in a problem report illustrating the configuration where you're having a problem to aid in diagnosis of the problem.

Future Strategic Mode:

My ultimate goal is to develop a game mode with a much deeper strategy than the classical "Battleship" game. The basic concept is to allow each player to see the position of their opponents ships at all times, and also to allow movement of each of a player's ships on their turn. Each ship may be moved one position backward, starboard or port on a single turn, or it may be moved multiple positions forward on a single turn. The number of positions forward is based on the length of the ship (smaller ships which are presumably faster can move further than larger ships). Alternatively a ship can be rotated 90-degrees clockwise or counterclockwise. Movements and rotations that result in part of the ship being off-grid are disallowed.

At the beginning of the game player-1 (who takes the first turn) configures the position of their ships, and then player-2 configures the position of their ships. This is intended to partially offset the advantage of player-1 taking the first turn. This player-1 advantage can be further offset by configuring the number of shells that can be fired on player-1's first turn to be less than the fleet size (which is the maximum number of shells that can be fired on each player's subsequent turn until their first ship is sunk).

Each ship segment is initially loaded with a shell, and each ship with a remaining shell can fire each turn. Shells are only fired horizontally along the same row and limited to a range of 10, so a only a shell fired from the closest column adjacent to the enemy's grid can reach the furthest column of the enemies grid. The probability of a hit can be adjusted such that it decreases with range, and also can be adjusted such that it decreases when a shell is fired after a ship moves (instead of before it moves) on a player's turn.

A ship's shells can be reloaded when part or all of the ship is on the column furthest from the enemy's grid which is considered home base (which is column-0 for player-1 and column-9 for player-2). When a ship segment is damaged that segment can no longer be reloaded, and when all segments are damaged a ship is considered sunk. A player's ship shells are reloaded at the beginning of their turn assuming one or more of the ship segments is on the home-base column. When only a single segment of the ship is on the home-base column a single shell is reloaded to the first undamaged and empty segment of the ship closest to the home-base column. When the entire ship is on the home-base column all undamaged and empty segments of the ship are reloaded in parallel at the beginning of a player's turn.

 I was originally thinking of integrating the future strategic mode into the current Sea Battle application, but due to memory constraints mentioned above I'll probably end up making it a separate application.

 

 I'm planning on implementing two-player mode first since the computer targeting strategy required for single-player mode is much more complicated for the future planned strategic mode than it is for the currently implemented mode which is only a slight variation of the classical "Battleship" game.

Collaboration:

I'm defining an API for the computer targeting function which I'm separating out from the rest of the current Sea Battle application, and I'm planning on taking a similar approach with the future strategic mode application. The intent is to support collaboration on enhancing the computer targeting function of the current Sea Battle application as well as collaboration on the development of the computer targeting and ship movement functions of the future strategic mode application (which I consider to be the most difficult part), so let me know if anyone is interested in collaboration on the computer functions of either of these two applications.

 






 

New game uploaded: Sea Battle

Posted: Mon Sep 07, 2020 4:16 am
by BruceMcF

If this is imagining WWII type ships, the speed from top to bottom would be Destroyers, then Battleships and Cruisers and Aircraft Carriers, slightly different top speeds depending on age and class but often roughly the same speed, then Frigates.

The idea is more to be able to keep the fleet together, with the Destroyers a touch faster to be able to run a submarine screen, and frigates more for missions where there aren't big bad ships from the other side around so they are smaller and more lightly armed and armored ... and don't have enough room to fit the bigger more powerful engines in the destroyers.

Now, often the battleships are between the cruisers and the frigates when fully loaded because they can take a bigger load of armaments, but then again the US "Iowa" class were built fairly fast because the US in the 1930's were envisioning fighting it across the Pacific with Battleship fleets and worried about the Japanese slipping behind the US fleet and raiding the Pacific Coast.

You might not have frigates along for a main sea battle, but if they are, they are more going to be doing anti-submarine duty as a rear guard, behind the fleet to relieve the faster destroyer screen to that task to the side and front of the task force. And if they are, their speed is determining the main cruising speed of the fleet, so one cool scenario would be the two fleets have left their frigate screen behind to rush into battle, and the frigates from either side show up as surprise reinforcements at a random turn.


New game uploaded: Sea Battle

Posted: Tue Sep 08, 2020 3:06 am
by Starsickle

I enjoyed the initial version! I hope you can keep working hard to enrich the game.

It's hard to reinvent the wheel and with such limited means to work with. You might need to make the grid bigger, which would require shrinking all the visual stuff or forcing the game into a mode that won't be compatible between platforms.

You could introduce new mechanics, but will ultimately be stuck with Battleship, unless you so fundamentally change the game that it requires ensuring the user has easy control and visual queues that something is different about what's happening.

Whatever you choose to do - make sure the user can absolutely see it happen and respond every time something novel or unique happens.

Work hard! Keep it up!


New game uploaded: Sea Battle

Posted: Wed Sep 09, 2020 6:31 pm
by CX16UserSteveC

Thanks for the feedback. I'm currently working on implementing the new strategic mode described in the post above, but lately I've been thinking perhaps I should also implement a mode with a single larger shared grid where each player starts on their own side of the grid but can invade the opponent's side of the grid as the game progresses. Also shells could perhaps be fired in more directions than horizontal which is a limitation of the new strategic mode currently under development.