So I was getting like really, terribly bored and thus I decided to make this game that any kid could have possibly build (may be better). Note - This game, in no dimension points out to my coding or development capabilities.
Also I needed to take of a 6 year old cousin of mine :'( :'( So I developed this to keep him busy and divert my attention from getting bored. I don't know, the BattleShip idea just came into my mind (I thought it to be the perfect game to keep the kid busy) ... He actually hated it... :3 And started irritating me more and more :'( :'(
The objective was to guess in which row and col was the ship hidden on the board.
Below is the code for the game (Reminder: It is CRAP!! And was coded in around 15 mins!)
The game is coded in Python as you can see.
Below are some screenshots of me playing it in cmd! :P
As you can see it is very unattractive :D :D ...
However I puzzled my cousin by winning everytime (by printing the ship coordinated!! Yes I cheated :v Marked in red bracket.)
My cousin shouted on me too for me forcing him to play this crappy game in a Green-Black terminal window.
Any ideas on how to get rid of your cousins by making them busy with other things?
What would you do if you were in this situation?
Tagged as : Back Home
Also I needed to take of a 6 year old cousin of mine :'( :'( So I developed this to keep him busy and divert my attention from getting bored. I don't know, the BattleShip idea just came into my mind (I thought it to be the perfect game to keep the kid busy) ... He actually hated it... :3 And started irritating me more and more :'( :'(
The objective was to guess in which row and col was the ship hidden on the board.
Below is the code for the game (Reminder: It is CRAP!! And was coded in around 15 mins!)
from random import randint#Our BattleShip Game Boardboard = []#Generating a 8 x 8 Game Boardfor x in range(8):board.append(["O"] * 8)#Joining list items with SPACE as separatordef print_board(board):for row in board:print "--".join(row)#Game Instructions and Introductionprint "Let's play Battleship!"print "You will get 4 Turns to guess the location of my BattleShip!"print "Your guesses will be marked by an X"#Priting our Board!print_board(board)#Hiding our Shipdef random_row(board):return randint(0, len(board) - 1)def random_col(board):return randint(0, len(board[0]) - 1)#ship_row = random_row(board)#ship_col = random_col(board)#Ship hiddenfor turn in range(4): #Giving the User 4 Turnsprint "Turn: ", turn + 1guess_row = int(raw_input("Guess Row:")) #Taking row guess input.guess_col = int(raw_input("Guess Col:")) #Taking col guess input.if guess_row == ship_row and guess_col == ship_col: #Winning Conditions Verifiedprint "Congratulations! You sunk my battleship!" # Congrats!if turn == 0: #Scoring!print "Score = 100"elif turn == 1:print "Score = 75"elif turn == 2:print "Score = 50"else:print "Score = 25"break #Ending game.else: #Conditions for wrong input, Game Over, and same guesses.if (guess_row < 0 or guess_row > 8) or (guess_col < 0 or guess_col > 8):print "Oops, that's not even in the ocean(Board Size Limit Exceeded!!! Board is 8 x 8!!!)"elif(board[guess_row][guess_col] == "X"):print "You guessed that one already!!!"else:print "You missed my battleship!!!"board[guess_row][guess_col] = "X"if turn == 3:print "Game Over"print "Score = 0"print_board(board) #printing the board again.print "<--------------------------------->"
The game is coded in Python as you can see.
Below are some screenshots of me playing it in cmd! :P
As you can see it is very unattractive :D :D ...
However I puzzled my cousin by winning everytime (by printing the ship coordinated!! Yes I cheated :v Marked in red bracket.)
My cousin shouted on me too for me forcing him to play this crappy game in a Green-Black terminal window.
Any ideas on how to get rid of your cousins by making them busy with other things?
What would you do if you were in this situation?
3 comments:
It's Not Cheating—It's Debugging! :D
> "What would you do if you were in this situation?"
I would pop up jsfiddle.net and mix some html, css and js and cook a nice graphical battleship game in < 20 mins ;)
(@Varun) Haha, yes you could say that! :D
Post a Comment