Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

psuedocode for battleship HELP ME

pseudocode battleship

This topic has been archived. This means that you cannot reply to this topic.
No replies to this topic

#1 ChrisKoester


    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 30 September 2015 - 08:28 PM

Hello, fellow pro-grammers. I am extremely new to programming, and as homework, I need to build BattleShip in psuedocode. I am using Arrays for the X axis (Columns) and Y axis (Rows). The problem is, I need to have user input the ships and make sure the ships are both in the Y and X axis boundaries and that another ship does not contain the same array.In other words, I have to make it so ships cannot be stacked.  Once I get the ship placement done, the rest will be a cinch! But for now, I have absolutely no idea what I'm doing. 


Please, it doesn't have to be in CODE- just psuedocode or flowchart. I can barely understand code at the moment.


//The columns and rows look something like this:


string column[] “A”, “B”, “C”, “D”, “E”, “F”, "G,”,”H”, “I”, “J”;

int row[]            1,     2,    3 ,   4,     5,    6,   7,     8,   9,  10;


//Columns are Xaxis and Rows are Yaxis.



//The example of my ships will look something like this:








//the subscripts or indexes will represent the ship's length. Within each element will contain coordinates.




Before the game actually starts, players will need to position or "input" the position for each ship. This is where I am totally lost. In theory, I may need to use a for loop, a boolean or "flag," and a whole lot of luck. I literally have no idea how to start! If anyone can push me in the right direction, I would be extremely grateful!






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download