Docsity

UMass Amherst CS Dept. Programming: Tic-Tac-Toe in Assembly - Prof. Kevin Fu, Assignments of Computer Science

Toggle sidebar
bg1
UMass Amherst Department of Computer Science Handout 11
CMPSCI 201: Architecture and Assembly Language April 16, 2009
Instructor: Prof. Kevin Fu
Programming Assignment 2
This programming assignmen t set is due on Friday, April 24, 2009 by your discussion section. You must
hand in your programming assignment in your Edlab account before your assigned discuss ion section
begins. Please contact your TA well ahead of the deadline if you have a quest ion about these procedures.
This is an individual programming assign ment. See Handout 1 (Course Information) for our policy on
collaboration, p lagiarism, and late po lices. P lagiarism w ill result in severe penalties. Please mark the top of
the programming assignment with your name, CS201 , and the date. Points may be deducted if your TA
has problems understanding your solution or if your solution is not legible.
This ass ignment is worth 10 po ints.
In this assignment, you will use the principles of subroutines and I/O. You will
implement an ASCII Tic-Tac-Toe game for the LC-3!
Tic-Tac-Toe is a two-player game with two symbols denoting the two players: X and O.
The playing board is a 3x3 grid.
The rules are as follows:
• Each player takes a turn placing their symbol (X or O) into one of the nine locations.
• A player cannot place a symbol in a location that is already occupied by a symbol.
• The game ends when a player creates a winning combination of their symbols or when
there are no empty squares remaining.
• A winning combination is defined as three horizontally adjacent, three vertically
adjacent, or three diagonally adjacent symbols.
• If neither player creates a winning combination when all nine locations are occupied,
the game is a tie.
The game board locations are defined as follows:
0 | 1 | 2
3 | 4 | 5
6 | 7 | 8
The requirements for this assignment:
• Ask the player where they would like to place their symbol (location 0-8)
• Echo this location identifier so the players know which locations are taken
• After every turn, check to see if there is a winner. If so, report who won
and exit the game
• If there is no winner and spots remain on the board, then let the next
player choose a symbol location
pf3

Partial preview of the text

Download UMass Amherst CS Dept. Programming: Tic-Tac-Toe in Assembly - Prof. Kevin Fu and more Assignments Computer Science in PDF only on Docsity!

UMass Amherst Department of Computer Science Handout 11 CMPSCI 201: Architecture and Assembly Language April 16, 2009 Instructor: Prof. Kevin Fu

Programming Assignment 2

This programming assignment set is due on Friday, April 24, 2009 by your discussion section. You must hand in your programming assignment in your Edlab account before your assigned discussion section begins. Please contact your TA well ahead of the deadline if you have a question about these procedures. This is an individual programming assignment. See Handout 1 (Course Information) for our policy on collaboration, plagiarism, and late polices. Plagiarism will result in severe penalties. Please mark the top of the programming assignment with your name, CS201, and the date. Points may be deducted if your TA has problems understanding your solution or if your solution is not legible. This assignment is worth 10 points. In this assignment, you will use the principles of subroutines and I/O. You will implement an ASCII Tic-Tac-Toe game for the LC-3! Tic-Tac-Toe is a two-player game with two symbols denoting the two players: X and O. The playing board is a 3x3 grid. The rules are as follows:

  • Each player takes a turn placing their symbol (X or O) into one of the nine locations.
  • A player cannot place a symbol in a location that is already occupied by a symbol.
  • The game ends when a player creates a winning combination of their symbols or when there are no empty squares remaining.
  • A winning combination is defined as three horizontally adjacent, three vertically adjacent, or three diagonally adjacent symbols.
  • If neither player creates a winning combination when all nine locations are occupied, the game is a tie. The game board locations are defined as follows: 0 | 1 | 2 3 | 4 | 5 6 | 7 | 8 The requirements for this assignment:
    • Ask the player where they would like to place their symbol (location 0-8)
    • Echo this location identifier so the players know which locations are taken
    • After every turn, check to see if there is a winner. If so, report who won and exit the game
    • If there is no winner and spots remain on the board, then let the next player choose a symbol location

Sample Output with a description of what action a player takes for I/O in italics: Welcome to Tic-Tac-Toe X – Which square? [0-8] > (user X enters in 0) X is in spot: 0 O – Which square? [0-8] > (user O enters in 3) O is in spot: 3 X – Which square? [0-8] > (user X enters in 0) That square is already taken. X – Which square? [0-8] > (user X enters in 4) X is in spot: 4 O – Which square? [0-8] > (user O enters in 2) O is in spot: 2 X – Which square? [0-8] > (user X enters in 8) X is in spot: 8 X is the winner! Thanks for playing Tic-Tac-Toe We suggest that you first write a program flow chart before you translate the problem into sequential, iterative, and conditional LC-3 code. Submit your well-documented code and a sample output of the game. Comments should conform to the philosophy discussed in lecture. Make sure to comment at the top of your program the role each register plays in your program. Each major piece of code/subroutine (e.g., sequential, conditional, iterative) should have comments descriptive enough for the reader to understand the purpose of the code, its assumptions, and its result. Avoid redundant single instruction comments when it’s obvious. (e.g., “ADD R0, R0, #1 ; Increment R0” has a redundant comment.) We have zero tolerance for plagiarism. You may not use any resources other than your book, the LC-3 simulator, and the course staff. You may not share code with your peers, borrow code from past students, the Web, e-Bay, the Interwebz, etc. You may borrow code from the book if you document the borrowing. (Hint: Chapter 10 has lots of example code.) Keep in mind that your course staff specialize in fraud detection, pattern matching, and cryptanalysis. We have automated tools to encourage students to “stay honest” about avoiding plagiarism. See Handout 1 for how we handle cases of suspected plagiarism. The long process of prosecuting plagiarism is no fun for anyone— be it students or staff. We thank you for coding and playing with honor. If you have any questions or concerns about the plagiarism policy, contact [email protected].