Battleship... On command line!

Hi everyone!
I finally finished my first project. I would love to get some feedback on readibility of the code :slight_smile:
The code will run if you follow the instructions. I know that some inputs will cause the code to crash, and will fix it. I just wanted to keep on learning.

Github’s repo: GitHub - guachilimbo/battleship

Article link: Battleship!... On Command Line - DEV Community

1 Like

Hi @ignacioballesterosru
Thanks for sharing your project. I did a Battleship Terminal Game as well and was really curious how you set about to tackle the task. The way your code looks shows me that you have understood way more of the a bit more advanced concepts of CS101, like classes, than me. That is definitely something you inspired me to use in my project as well.
I downloaded your game and tried to play it (I really LOVE battleship :heart_eyes:), but after giving the initial coordinate the program always terminated with a TraceBack error whenever I tried to enter H or V for the distribution direction of the ship.
I would still love to play it once it works, so please keep me posted. Then I’d be happy to give you my feedback on player experience.

If you’d like to check out mine, you can find it here:

BTW, I really enjoyed reading your article. Neat, the way you explained the game in general! :+1:t2:

Thanks for trying it out hahaha! Were you trying to enter lower case h or v? It was one of the points for me to fix in the future because the project was taking too much time and wanted to keep going.

However, I have now fixed it. The solution was simple, just add .upper() on the user input (line 54 & 68) to force the user input to be read as upper case (so that you dont get the key error when the program tries to look for a lower case key).

It should work now… let me know if it doesnt! I’ll have a look at yours during the weekend :slight_smile:

1 Like

HI there.
Cool - I tried it again. Maybe it is my mistake.

Anyways, here is a picture of the TraceBack error I get. Maybe it helps you. I cannot figure out what’s wrong. That’s clearly above my current skill level ;-).
Cheers :slight_smile:

That is weird… I have never come accross this error. I’ll try and find what is causing it. If I run that same code on my laptop I get this: