Jump to content

Battleships Project - Please take a look :)

- - - - -

  • Please log in to reply
4 replies to this topic

#1
emmachallis

emmachallis

    Newbie

  • Members
  • Pip
  • 3 posts
Hi guys!

I'm a newbie C# but reasonably experienced with SQL and VB, or at least as reasonably experienced as a 19 year old can get :D

Anyway we have been asked to create a Battleships game using the Console of Visual Studio. This I have done and I have one final thing to do... make the ships of various lengths. This I cannot get my head around. I know i'm going to need to use a struct containing the data for each ship but it is beyond me on how to do it!

I don't want you to write the code for me, I would however appreciate tips to help guide me in the right direction. As this is for extra marks I cannot ask tutors. I have an idea how to do it, as mentioned but before I spend hours (that i don't really have) struggling with it I would be grateful if you could give me some tips?

Thanks in advance,

Emma Challis :)

Emma Challis - Home :pinguin:

#2
sam_coder

sam_coder

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 372 posts
Thats a great project. try to think of it modeled in your head first, before you write code. Do you have a battleship board? (its been years since I played)

I cant remember how large the grid is,

but anyways, your question was how to model boats.

if it were me, and I chose to model the boats with structures, it might have a position, a length and an orientation (horizontal or vertical), it might also have a name

the real trick will be how you organize the board. I mean you not only have to either randomize where/how the boats are placed, or allow user to place them; but also remember where shots were fired. (and the opponent must be able to review where they previously shot, and if the hit was successful or not)

interesting question... do you also need to build a computer opponent? Or is this intended on being multi-player?

#3
emmachallis

emmachallis

    Newbie

  • Members
  • Pip
  • 3 posts
Firstly, thank you so much for your reply!

The grid size is 10 x 10 and I have built an entire working version of the program, a Player Vs Player mode and a Player Vs Computer mode. However, the only boat i have is one of that displays a value of one when placed.

I have researched exhaustively and the idea of having a struct containing the position, length, orientation and name is seeming to be the best idea.

As mentioned it is an improvement more than anything and in my opinion it would be a fantastic and highly marked improvement to make :)

I am happy to send my program if you would like to view (or even play it :) ) I just don't want to post all of the code as it is a very popular project.

Emma :)

#4
sam_coder

sam_coder

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 372 posts
I'd love to have a look!
I'll PM you my email address.

#5
Combinu

Combinu

    Newbie

  • Members
  • Pip
  • 9 posts
I am having the same project i.e. to create a battle ship game in console c#.. i have managed to do your problem somehow. The only problem that i cannot get to my mind is how to make the pc shoot intelligently... i.e. if the pc hits it should manage to carry out and hit vertically or horizontal to find the whole ship. this is artificial intelligence shooting its really hard to do.. Have you managed to do something?

Btw .. my thread about this issue is here http://forum.codecal...battleship.html if you can find any help in it!

Edited by Combinu, 31 December 2010 - 02:49 AM.
Linking...





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users