4
Contributors
6
Replies
41
Views
11 Months
Discussion Span
Last Post by Brandon Hatch
0

The design was already there I just don't know how to come up with a code. If I start the game and you are allowed only one turn. I just don't where to begin.

0

What is your level of expertise? If you are at a beginner level then I suggest you start with something simpler. If you have the chops for this project and are just stuck then I suggest you post the code you are having trouble with so that we have something concrete to work with in offering suggestions. Based on your comment

The design was already there I just don't know how to come up with a code.

I think that you are perhaps biting off more than you can chew at this point.

Edited by Reverend Jim

0

As to the design was already there, you posted code and not the design. There are some that write "read the code" but at some point when the app is big enough there needs to be a design document. Even if it's just a few pages to tell the next maintainer a mile high view of how it works without getting down to methods.

0

I have issues soming up with a unique code. This is an example but I don't know how to design a battleship game with one turn I've been told to follow something like this.

mode_ = false

def turn():
    # Do stuff for turn
    # When turn is complete flip the switch and run function again for
    # other player
    mode_ = false if mode_ else true
    # The above is called a ternary function, easy to use to flip switches


win = false
turn_ = 0

def turn():
    # Do stuff
    turn_ += 1
    # add 1 to turn count after done with turn

while not win:
    if turn_ % 2 == 0:
        # player 1 goes
    else:
        # Player 2
2

Might I suggest the course over at codecademy.com they literally have an assignment that is to create a battleship game.

Comments
Good idea. Learn as you code.
This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.