Assignment 6 Play A Game: Minesweeper or Battleship!!! Due: Sunday, December 3rd, :59pm

Similar documents
CSCE 2004 S19 Assignment 5. Halfway checkin: April 6, 2019, 11:59pm. Final version: Apr. 12, 2019, 11:59pm

YourTurnMyTurn.com: Rules Minesweeper. Michael A. Coan Copyright Coan.net

CS Programming Project 1

CPSC 217 Assignment 3 Due Date: Friday March 30, 2018 at 11:59pm

2 Textual Input Language. 1.1 Notation. Project #2 2

CS61B, Fall 2014 Project #2: Jumping Cubes(version 3) P. N. Hilfinger

YEDITEPE UNIVERSITY CSE331 OPERATING SYSTEMS DESIGN FALL2012 ASSIGNMENT III

Mobile Application Programming: Android

Periodic Table Battleship Open Inquiry

Due: Sunday 13 November by 10:59pm Worth: 8%

Spring 06 Assignment 2: Constraint Satisfaction Problems

Lab 7: 3D Tic-Tac-Toe

Project Connect Four (Version 1.1)

Naval Battle! Comp-361 : Naval Battle! Lecture 2. Alexandre Denault Computer Science McGill University Winter 2008

CS Project 1 Fall 2017

CMSC 201 Fall 2018 Project 3 Sudoku


G51PGP: Software Paradigms. Object Oriented Coursework 4

Name. Part 2. Part 2 Swimming 55 minutes

1, 2,, 10. Example game. Pieces and Board: This game is played on a 1 by 10 board. The initial position is an empty board.

MATHEMATICAL RELATIONAL SKILLS AND COUNTING

1 Modified Othello. Assignment 2. Total marks: 100. Out: February 10 Due: March 5 at 14:30

Programming Problems 14 th Annual Computer Science Programming Contest

Spring 06 Assignment 2: Constraint Satisfaction Problems

Assignment 2 (Part 1 of 2), University of Toronto, CSC384 - Intro to AI, Winter

Monte Carlo based battleship agent

Chickenfoot Dominoes Game Rules

Battleship Advance Rules

Final Project: Reversi

Suggested Games and Activities MathShop: Cartesian Coordinate Mat

CS1301 Individual Homework 5 Olympics Due Monday March 7 th, 2016 before 11:55pm Out of 100 Points

CPSC 217 Assignment 3

CSC Curriculum Term One Lesson Plans

The 2015 British Informatics Olympiad

CSE548, AMS542: Analysis of Algorithms, Fall 2016 Date: Sep 25. Homework #1. ( Due: Oct 10 ) Figure 1: The laser game.

Lesson 8 Tic-Tac-Toe (Noughts and Crosses)

Here is a step-by-step guide to playing a basic SCRABBLE game including rules, recommendations and examples of frequently asked questions.

Inside Outside Circles Outside Circles Inside. Regions Circles Inside Regions Outside Regions. Outside Inside Regions Circles Inside Outside

Project 1: Game of Bricks

Introduction to Spring 2009 Artificial Intelligence Final Exam

CSC 110 Lab 4 Algorithms using Functions. Names:

Pay attention to how flipping of pieces is determined with each move.

EXPLORING TIC-TAC-TOE VARIANTS

More Challenges These challenges should only be attempted after difficulty challenges have been successfully completed in all the required objectives.

Name. WPC French Qualifier Part I

3 0 S E C O N D Q U I C K S T A R T To start playing right away, read this page.

A fun way to challenge your math thinking! Grade Levels: 4th - 8th Time: 1 class period. Check out 36 BINGO Snapshot

Version 6.1. Instructional Days: 11-14

Game Playing in Prolog

Axis & Allies Pacific FAQ

We hope you enjoy the set. Good luck for the Indian Puzzle Championship! 3 A B C 4 H D 5 G F E 7 A B 8 H 9 G F

Documentation and Discussion

Assignment 2, University of Toronto, CSC384 - Intro to AI, Winter

select the 4 times tables and then all the number tiles used would be 4 x something

Chess Handbook: Course One

UN DOS TREZ Sudoku Competition. Puzzle Booklet for Preliminary Round. 19-Feb :45PM 75 minutes

ENEE 150: Intermediate Programming Concepts for Engineers Spring 2018 Handout #7. Project #1: Checkers, Due: Feb. 19th, 11:59p.m.

Assignment 12 CSc 210 Fall 2017 Due December 6th, 8:00 pm MST

WORD WINDER Game Play Basics It s As Easy as ABC

Lab Exercise #10. Assignment Overview

Assignment 3: Fortress Defense

MODULE: DESIGNING AND DEVELOPING OBJECT-ORIENTED COMPUTER PROGRAMS ASSIGNMENT TITLE: WORDSEARCH MARCH 2014

DIVISION I (Grades K-1) Common Rules

Battleship Unit 5 Test (Radicals)

Sea Battle Game Recipe

CMPT 310 Assignment 1

Computing Science (CMPUT) 496

COSC 117 Programming Project 2 Page 1 of 6

Let s Make. Math Fun. Volume 19 January/February Dice Challenges. Telling the Time. Printable Games. Mastering Multiplication.

2006 Canadian Computing Competition: Junior Division. Sponsor:

In the game of Chess a queen can move any number of spaces in any linear direction: horizontally, vertically, or along a diagonal.

For slightly more detailed instructions on how to play, visit:

Project 1: A Game of Greed

a b c d e f g h 1 a b c d e f g h C A B B A C C X X C C X X C C A B B A C Diagram 1-2 Square names

ApeZone's Battleship Chess. The side with the most points at the end of the last battle is the winner.

HW4: The Game of Pig Due date: Tuesday, Mar 15 th at 9pm. Late turn-in deadline is Thursday, Mar 17th at 9pm.

CIDM 2315 Final Project: Hunt the Wumpus

Embedded Systems Lab

CMPT 310 Assignment 1

LMI-MONTHLY TEST JUN 2010 'SPEED SIXES'

Plants Review Game. Dana Moore, 2013 All Rights Reserved

Programming Assignment 4

PLAYERS AGES MINS.

Math Estimation and Accurate Computation Whole Numbers Multiplication and Division Page 1 of 5

Games of Skill Lesson 1 of 9, work in pairs

Hidden Image Game. Instructional Booklet CCSS & ISTE Alignment Materials List Introductory Lessons Game Instructions Printables. Story Context Version

The game consists of 3 rounds where you will build a castle in 30 seconds then place catapults and steal wall pieces from your neighbors.

1st Grade Math. Please complete the activity below for the day indicated. Day 1: Double Trouble. Day 2: Greatest Sum. Day 3: Make a Number

OCTAGON 5 IN 1 GAME SET

Counters in a Cup In and Out. The student sets up the cup, drops the counters on it, and records how many landed in and out of the cup.

SUDOKU1 Challenge 2013 TWINS MADNESS

Taffy Tangle. cpsc 231 assignment #5. Due Dates

Coin Cappers. Tic Tac Toe

The first player to construct his or her obelisk is the winner, and if a player has no legal moves, he or she immediately loses the game.

CMPT 125/128 with Dr. Fraser. Assignment 3

CS151 - Assignment 2 Mancala Due: Tuesday March 5 at the beginning of class

Copies of the Color by Pixel template sheets (included in the Resources section). Colored pencils, crayons, markers, or other supplies for coloring.

Create Your Own World

Tic-Tac-Toe and machine learning. David Holmstedt Davho G43

Final Project: Verify a Sudoku Solution Due Fri Apr 29 (2400 hrs)? Wed May 4 (1200 hrs)? 1

Transcription:

Assignment 6 Play A Game: Minesweeper or Battleship!!! Due: Sunday, December 3rd, 2017 11:59pm This will be our last assignment in the class, boohoo Grading: For this assignment, you will be graded traditionally, i.e. TAs will compile and execute your program for a grade without you demoing it. However, you need to make sure you have Assignment #5 demoed/graded by the end of week 10!!!! (90 pts) Problem Statement: For this assignment, you will implement a game. You can pick between minesweeper or battleship. Each game has an extra credit piece!!! Minesweeper This game was made popular by the Windows operating system in the early 1990s, and it has continued to be a pre-installed game until Windows 8. You can watch a video of how to play minesweeper on YouTube or read about it on Wikipedia: https://www.youtube.com/watch?v=z0eaysrlujk https://en.wikipedia.org/wiki/microsoft_minesweeper The game is very simple. The object of the game is to open/reveal every cell on the board without detonating a mine. Every cell contains a number or a mine. The numbers tell you how many mines surround the cell in the horizontal, vertical, and diagonal directions, e.g. at most, 8 possible mines surrounding a cell. You can flag a cell, which helps you remember where you think there is a mine to not detonate. If you select to open/reveal a cell that has a mine, then you automatically lose the game! You will then randomly distribute the mines on the board and setup the numbers describing how many adjacent mines to each cell. After that, you will display a blank board, and ask the user to flag or open a cell on the board until the user selects a cell that contains a mine (losing the game) or selects all cells free of mines (winning the game). After the user wins or loses, you will ask the user if he/she wants to play again. If so, you must get the number of rows, columns, and mines for the new game and create a new board for a new game. BTW, you can display row and column numbers on board to make it easier to read/know which row and column to select!!! Example run of a game: a.out r 9 c 9 m 10

row, col: 0 4 You lose!!! 1 1 0 1 * 1 0 0 0 * 2 1 2 2 2 0 0 0 2 * 2 2 * 1 0 0 0 1 1 3 * 3 1 0 0 0 1 1 3 * 2 0 0 0 0 1 * 3 2 2 0 0 0 0 1 1 2 * 1 0 0 0 0 1 2 3 2 1 0 0 0 0 1 * * 1 0 0 0 0 0 Do you want to play again (1-yes, 2-no): 1 How many rows, cols? 9 9 How many mines? 10 row, col: 0 0 1

row, col: 8 0 1 1 row, col: 5 5 1 1 0 0 0 2 0 0 0 1 0 0 0 3 1 0 0 0 2 0 0 0 0 2 0 0 0 0 1 0 0 0 0 2 1 0 0 0 0 1 1 0 0 0 0 0 Flag(1) or Open(2): 1

row, col: 6 3 1 1 0 0 0 2 0 0 0 1 0 0 0 3 1 0 0 0 2 0 0 0 0 2 0 0 0 0! 1 0 0 0 0 2 1 0 0 0 0 1 1 0 0 0 0 0 row, col: 7 1 1 1 0 1! 1 0 0 0! 2 1 2 2 2 0 0 0 2! 2 2! 1 0 0 0 1 1 3! 3 1 0 0 0 1 1 3! 2 0 0 0 0 1! 3 2 2 0 0 0 0 1 1 2! 1 0 0 0 0 1 2 2 1 0 0 0 0 1!! 1 0 0 0 0 0 row, col: 7 2 Congratulations!!! 1 1 0 1 * 1 0 0 0 * 2 1 2 2 2 0 0 0 2 * 2 2 * 1 0 0 0 1 1 3 * 3 1 0 0 0 1 1 3 * 2 0 0 0 0 1 * 3 2 2 0 0 0 0 1 1 2 * 1 0 0 0 0

1 2 3 2 1 0 0 0 0 1 * * 1 0 0 0 0 0 Do you want to play again (1-yes, 2-no): 2 Requirements for game: You must provide a usage message, if the user enters incorrect command-line arguments, and they can come in any order! You must not have functions over 15-20 lines long (-10 automatically) You must not use global variables (-10 automatically) You must ask the user if he/she wants to play again o If no, then end o If yes, then prompt for rows, cols, and mines for new game. You must not have any memory leaks (-10 automatically) You must detect these errors: o Invalid row or column to flag or open o Opening a cell that has already been opened (10 pts) Extra Credit: Recursively open all cells adjacent to 0 cell If the user selects a cell that has no mines surrounding it, then you will help the user by recursively opening all adjacent cells to empty cells, until you reach cells with a surround mine. Battleship You will write a program that plays the game Battleship. In this program, you will be graded on having functions, as well as the ability to play the game correctly. The one requirement for using functions is that your functions, including main(), must not have over 15 lines of code, this doesn t include comments or blank lines. https://www.hasbro.com/common/instruct/battleship.pdf Some example functions you might want to include are an initialize_board(), which initializes the boards to spaces, a determine_player_choice() that allows players to pick their spot on their opponents grid, fill_board(), which fills the board with the player s choice, a print_board() that prints the board to the screen after each user s turn, a check_for_winner(), which checks to see if there is a winner, and a print_winner_results() that prints the results of the game to the screen. This is traditionally a 2-person game, where each play picks where to put their ships on a 10 x 10 matrix, and the ships can only be arranged horizontally or vertically on the board, and they can't hang over the grid!!! Ships can touch each other, but can't both occupy the same spot. Your computer game will simulate this process by first asking player 1 where he/she wants to put the ships, and then asking player 2. You can clear the screen after each player chooses their positions for their ships by using system( clear ) from #include <stdlib.h>. Each player is given the following ships, and each ship takes up a specific number of spots on the 10 x 10 grid: 1 Aircraft Carrier, 5 spots 1 Battleship, 4 spots 1 Destroyer, 3 spots 1 Submarine, 3 spots 1 Patrol Boat, 2 spots After you determine where each player wants to put their ships, then you can prompt each player to choose a position on the opponent s board. If there is a boat in the corresponding position on the opponent s board, then it was a hit, and you can use whatever you want to symbolize that it was a hit, i.e. X, 1, etc., in your own board.

You can even turn the X s or 1 s red by using the following code: cout << \033[22;31m X \033[01;37m ; \033[22;31m turns your text red, and \033[01;37m turns your text back to white. In the case of a hit, the other player must mark the hit on his setup board containing the ships. Whenever a ship is sunk, you must announce to your opponent that he/she has sunk your ship. If there isn t a boat in the opponent s position, then it is a miss, and you can use whatever you want to symbolize a miss on your board, i.e. 0, N, etc. The player who sinks all of his/her opponent s ships first is the winner!!!! Example Battleship 2 Rounds: A B C D E F G H I J 1 --- 2 --- 3 --- 4 0 --- 5 --- 6 --- 7 0 --- 8 1 0 --- 9 0 --- 10 Player 1: What position do you choose? 8 A Hit!!! You sunk my ship!!! A B C D E F G H I J 1 --- 2 --- 3 0 --- 4 1 1 0 --- 5 0 --- 6 --- 7 --- 8 --- 9 --- 10 Player 2: What position do you choose? 4 C

Hit!!! You sunk my ship!!! A B C D E F G H I J 1 --- 2 --- 3 --- 4 0 --- 5 --- 6 --- 7 0 --- 8 1 1 0 --- 9 0 --- 10 Player 1: What position do you choose? 2 B Miss!!! A B C D E F G H I J 1 --- 2 --- 3 0 --- 4 1 1 1 0 --- 5 0 --- 6 --- 7 --- 8 --- 9 --- 10 Player 2: What position do you choose? 7 H Miss!!! (10 pts) Extra Credit: Play a one player Battleship, where the user can play the computer. The algorithm you use doesn t have to be smart, it just needs to work!!! (10 pts) Program Style/Comments In your implementation, make sure that you include a program header in your program, in addition to proper indentation/spacing and other comments! Below is an example header to include. Make sure you review the style guidelines for this class, and begin trying to follow them, i.e. don t align everything on the left or put everything on one line!

http://classes.engr.oregonstate.edu/eecs/fall2017/cs161-001/161_style_guideline.pdf /****************************************************** ** Program: game.cpp ** Author: Your Name ** Date: 12/03/2017 ** Description: ** Input: ** Output: ******************************************************/ Electronically submit your C++ program (.cpp file, not your executable!!!) by the assignment due date, using TEACH.