Sea war game questions

Good day. I have a question about the structure of the program. I’m making a game based on sea battle mechanics. Ships will have various properties such as counterattack or evasion. There will be 4 types of ships with a unique set of properties. Also, ships in certain positions will acquire additional properties (again, unique for their type). And there will be a bonus weapon that opens not one cell, but several.

Please tell me how to implement it correctly. The game will be against AI. At this point, it’s also not clear to me how the switch between the player’s turn and the AI ​​will take place.

I already tried to write this game, but the code was terrible, I had to invent something (patches) on the fly to somehow work. For example, I hung a listener on the cells of the AI ​​​​field, and when I did a tap in the shot processing procedure, I called the player’s firing function.

Your question is too broad for a meaningful response. There are hundreds of interconnected decisions to be made when you program something, but no “correct” way to structure a program. There are best practices, and there are certainly “incorrect” things that don’t work, but if you need help with an overall strategy for structuring your program, you should probably do some tutorials or start off writing something smaller to get a better understanding about how to organize a game.

We can best help you with specific problems- like, “Here’s a function I wrote, I want it to do X, but it doesn’t work. What’s wrong?”

If you haven’t done many tutorials, and are interested in the basic structure of a game, I think this tutorial is a good place to start:

1 Like

Thank you. Ok, I’ll clarify my question. How to make the transfer of the move from the player to the computer opponent? Taking into account the fact that when hitting a unit, a counter-attack is possible, which is not considered as an opponent’s move. A situation is possible: a shot hits the enemy, the enemy makes a counter-strike and also hits the player, the player counter-attacks and only then the move goes to the enemy according to the normal scenario (missed).

What do you advise?

A game loop and a bunch of if/then statements?


You may want to search Google for battleship games. There seems to be many of them with videos and explanations in other languages. It can be useful for you to get a sense on how to design and implement it in Solar.


You can ask ChatGPT to lay the foundations and explain it to you.

(Sorry about that but your question is too broad for us to answer here.)

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.