Battleship github

GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. If nothing happens, download GitHub Desktop and try again. If nothing happens, download Xcode and try again. If nothing happens, download the GitHub extension for Visual Studio and try again. Battleship game using C and WPF.

Currently, this version is for a player VS computer game only. See wiki for more details on how the game is being made. The game is played on four grids, two for each player. On one grid the player arranges ships and records the shots by the opponent. Each ship occupies a number of consecutive squares on the grid, arranged either horizontally or vertically.

The number of squares for each ship is determined by the type of the ship. The ships cannot overlap i. The types and numbers of ships allowed are the same for each player. These may vary depending on the rules. After the ships have been positioned, the game proceeds in a series of rounds. In each round, each player takes a turn to announce a target square in the opponent's grid which is to be shot at. The opponent announces whether or not the square is occupied by a ship, and if it is a "miss", the player marks their primary grid with a white peg; if a "hit" they mark this on their own primary grid with a red peg.

The attacking player notes the hit or miss on their own "tracking" grid with the appropriate color peg red for "hit", white for "miss"in order to build up a picture of the opponent's fleet. When all of the squares of a ship have been hit, the ship is sunk, and the ship's owner announces this e. If all of a player's ships have been sunk, the game is over and their opponent wins.

Skip to content. Dismiss Join GitHub today GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. Sign up. Battleship game made in C and WPF.

C Branch: master. Find file. Sign in Sign up. Go back. Launching Xcode If nothing happens, download Xcode and try again. Latest commit. Latest commit 3fda Dec 11, BattleShips If not executing from Main Window, might experience louder volume.Skip to content. Instantly share code, notes, and snippets.

Code Revisions 1. Embed What would you like to do? Embed Embed this gist in your website. Share Copy sharable link for this gist.

battleship github

Learn more about clone URLs. Download ZIP. Battleships Code in Python. Fire your missiles into one of the coordinates on the map. Code will need to loop until the user quits.

Loop created to ensure valid input entered. Code will need to loop until the user runs out of guesses or wins. If not ships remain end the game. You have destroyed the enemy fleet! Modify the missile count then check if the user has shots remaining. You had better get your crew in order Admiral! Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment. You signed in with another tab or window.

Reload to refresh your session. You signed out in another tab or window. Will take in the size of the map to be made and produce an empty starting map for the game.

Will take in a string of a letter and number and return a list of two numbers. Will take in shotCoordinateList and shipMap and return whether the shot hit or missed. Takes in the current map and the last shot results and returns an updated map. Will check the ship layout to check which ships have been sunk.GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

If nothing happens, download GitHub Desktop and try again. If nothing happens, download Xcode and try again. If nothing happens, download the GitHub extension for Visual Studio and try again.

It was assigned and coded during our third week of class. There were the projects possible, a personal finance app, a flash cards app, and this battleship app. I began working through possible rspec tests and pseudo-code, then started writing the Ruby code based on using ActiveRecord classes. I created a one-dimensional array for the grid, that would populate each time the game started and appear on screen broken into a neat board for players.

I then created arrays for the ships and began to implement the game process. The original question of how to configure and populate the grid was the major issue, as there are various ways to go about doing it.

Two dimensional arrays and an array of hashes were also options. Working with ActiveRecord in Ruby, and not Rails, was also an interesting experience. Loading old games, multi-player functionality, and more randomized ships would be added with more time.

battleship-game

Skip to content. Dismiss Join GitHub today GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. Sign up. Battleship Project. Ruby Branch: master. Find file. Sign in Sign up. Go back. Launching Xcode If nothing happens, download Xcode and try again. Latest commit Fetching latest commit…. Battleship Find current edits in Stage 2. Setup CreateBattleShip. Then run the game outside of pry. Development I began working through possible rspec tests and pseudo-code, then started writing the Ruby code based on using ActiveRecord classes.

Icebox Loading old games, multi-player functionality, and more randomized ships would be added with more time. You signed in with another tab or window. Reload to refresh your session.

You signed out in another tab or window. Last minute notes. Apr 3, More minor changes towards a final version. First day of Battleship work, set up basic game and methods, attempte…. Apr 2, Update readme.And they're using a loop to have it print out with format of one row per print line instead of [[0,0,0,0,0],[0,0,0,0,0] Your last if statement is wrong, according to your comment, you state that if the user has had four attempts, it is game over.

Currently, your if statement will print game over on the user third try and each try there after. Even though this is from Codecademy, I've made a new version for the people rocking V3. Skip to content. Instantly share code, notes, and snippets. Code Revisions 3 Stars 1 Forks 3.

Embed What would you like to do? Embed Embed this gist in your website. Share Copy sharable link for this gist. Learn more about clone URLs. Download ZIP. This is a simple battleship game, made with lists on python. This is the first game I ever made. You sunk my battleship! This comment has been minimized. Sign in to view. Copy link Quote reply. Also don't get the for loop. This is from codecademy python course xD. The code doesn't work for me lmao. Sign up for free to join this conversation on GitHub.

Already have an account? Sign in to comment. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It only takes a minute to sign up. This question is majorly focused on design, please help me figure out, how can I make it decoupled and apply suitable design patterns. Rules 1. Player1 will fire first. Battleships will be placed horizontally. Type-Q ship requires 2 missiles hit to get destroyed. Type-P ship requires 1 missile hit to get destroyed. Input First line of the input contains dimensions of battle area having width and height separated by space.

Second line will have number B of battleships each player has. Class name for your StartGame is not helpful, rename it into a more matching name, i think like BattleShipGame and start the game instead from your controller.

NOTE: the init method could be shortenend far more, but i think i point out in a good way what init should really do I think it was a very good idea to use a class Coordinate which looks good at first glance. But you don't use it consequencically.

And don't use a char for your shiptype, use a enum instead. But let's be honest, you don't have a 'position and width and height' what you really have is an rectangle - so use an rectangle!

The BattleArea is now far more easy to use, think about how simple you can placeShips now:. To decouple you have to make sure that your functions don't need to call each other to do their work.

If possible, the only functions that should call others are the driver functions of each subsystem that are intended to be called like the API interface. Think about how you would need to port a lot of code just for adding an useful function if that function calls other functions or uses variables from other big subsystems. If you make additional effort to implement that function in a way that it doesn't depend on anything else, even if it looks like duplicated code, you will be able to individually port it to another program, and even more if you don't make it depend on language features or library features that are not present on every single compiler and programming language you use to make it possible to port any code you write to any environment you needthat's what's called decoupling.

As you can see, decoupling can be appplied at the compiler, language, system environment, functions and subsystem levels.

It might involve duplicating code and rewriting to have stand-alone, dependency-less routines.

battleship github

If you want to make your code highly reusable and if you want it to last for decades, you could use the low level approach of CPU assembly programming. Think about a task or microtask you want to perform in a way that will always take the same type of parameters and that will always return a result in the exact same way.

Then give it a VERY specific name to this routine. This way of designing the code is highly reusable and stable. If you want a variation in what to do, you just add a new opcode function instead of destroying the previous valid functionality. Applying this throughout the program as the main design approach can make the code more strictly structured yet easier to follow.

battleship github

Sign up to join this community. The best answers are voted up and rise to the top. Home Questions Tags Users Unanswered.

Battleship ~ Mohammad Daraghmeh (Java)

Java Battleship game Ask Question. Asked 2 years, 1 month ago. Active 2 years, 1 month ago. Viewed 6k times. You could also move those critical parts of the code to subroutines to make the code much more readable, although calling so many functions would make the code slower, but at least it will become much more readable for others so they can later maintain better the updates.

StartGame reads the input from a file, does validation and creates BattleArea and BattleShips for each player.GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. If nothing happens, download GitHub Desktop and try again. If nothing happens, download Xcode and try again. If nothing happens, download the GitHub extension for Visual Studio and try again. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

battleship github

Skip to content. Dismiss Join GitHub today GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Sign up. Java Branch: master. Find file.

Subscribe to RSS

Sign in Sign up. Go back. Launching Xcode If nothing happens, download Xcode and try again. Latest commit. Latest commit 2ad Feb 19, Java-Battleship The game, Battleship, written in Java. When the application starts, you, the player, sets up your board by typing in the on-screen coordinates. Then, the computer makes its own board and you play against it by guessing its ships' locations. NOTE: The computer's board is printed on screen, just so the game can go faster.

The program ends when one side beats the other. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Added Battleship project. Feb 19, This is a simplified single player version of the popular board game, Battleship. Battleship is in two words is a guessing game. In a nutshell, the object of the game is to sink all of the ships on the board.

As mentioned the objective of Battleship is to sink all of the ships on the board. With each click turna player is given a grid and must decide where to fire on the grid. The result of this decision can either be that the spot fired on was a hit or miss. A hit being that part of a ship on the grid was hit or a miss being that water was at that spot. The standard setup of the game is for one player with unlimited turns and ammunition.

When all ships on the board are sunk then the game is over and the player has won. This project was written in Java using the Eclipse platform of course from stretch. What was to be learned from creating this project was the following:. For in this project my GUI and Model were differently separated yet worked hand in hand to accomplish a fully functional battleship game. However, it does not stop there for the same method of MVC is applied in the world of engineering in form of Model,User Interface, and Controller.

A separation of the model game functionality from the view and controller GUI as much as possible following the design pattern of MVC. This example is a 6x6 board with the first ship a 2-section horizontal ship in the second row starting in the second position from the left.

The second ship a 6-section ship that completely occupies the rightmost column of the board.

Play Battleship in Excel!

Overview of Battleship This is a simplified single player version of the popular board game, Battleship. In-Depth view of Battleship As mentioned the objective of Battleship is to sink all of the ships on the board. What was to be learned from creating this project was the following: To apply the Model-View-Control MVC design pattern to a specific application.

Ship Rules Program performs a check for all rules below. Breakdown of Format This example is a 6x6 board with the first ship a 2-section horizontal ship in the second row starting in the second position from the left.


thoughts on “Battleship github

Leave a Reply

Your email address will not be published. Required fields are marked *