Professional Documents
Culture Documents
Requirements:
# Your program is required to do the following:
# 1. Generate 2-dimensional game boards (minimum 10x10 and maximum 35x35).
# 2. Insert text strings within the 2D array (hidden from view).
# 3. Validate game coordinates within the 2D array.
# 4. Uncover individual characters at a specific location in the 2D array.
# 5. Keep track of the player's score, last selection, and update the game
board.
Specifications:
Basic game-play overview:
The game board dimensions will be supplied (minimum of
10 rows x 10 columns and maximum of 35 rows x 35 columns) such that
the rows and columns are to be labeled 1 to 9 and A to up to Z. The rows
are
labeled on the left and the columns at the top.
The game board's left and right boundaries are to be drawn using the '|'
character and the board contents itself drawn using only the '.' character.
Your program will insert words into the game board (2D array) starting at
specific locations and directions (hidden from view).
The words themselves will not be displayed (of course), but must be tracked
internally. The program will then uncover the contents of the board one
coordinate at a time.
Points (5 points for each letter uncovered) are awarded if the
coordinate uncovers one or more of the word's characters.
When this happens, that specific character and ALL characters in the
same row or column that it is connected to are then uncovered (replacing
the '.' with the actual letter in the character).
If a coordinate supplied does NOT uncover a letter in a word, then the '.'
is replaced with '~' character.
After each coordinate that is sent, your program updates the
current score (0000) and last move (with a "FOUND 'X' at '[X,Y]'" or
"NO letter FOUND at '[X,Y]'" message).
This is done by "redrawing" the entire screen.
This assignment MUST code the following functions as specified and will
called appropriately from the main( ) function that will be supplied.
Processing:
You MUST code the following Python functions as specified.
CAUTION: You must take care to not attempt to access an element in the 2D
array that
is out of bounds (i.e. beyond the left/right or top/bottom
indexes of the array).
+ If the coordinate is valid but does not find a word character at that
location, then
the function places the '~' character at that location in the 2D array
'boardMask', and
the "Last Move:" message is updated to add the text: "NO letter FOUND at
'[X,Y]'"
('X' is the row, and 'Y' is the column) is written at the bottom of the
game board next
to the "Current Score: NNNN" message (see below for examples).
Assuming a starting game board data of, with board dimensions below of:
12x26
and coordinates supplies as: "55", "1D", "X2", "B4", "6J"
............N.............
........HELLO WORLD.......
.........X................
.........A................
.........M........A.......
.........I......NORTH.....
.........N........E.......
.........E........A.......
..PYTHON..................
............PUZZLE........
...7-SEAS.....O...........
..............O...........
MAIN PROGRAM:
# Your solution may ONLY use the python modules listed below
# program: A1main.py
# author: danny abesdris
# date: march 12, 2021
# purpose: python main( ) program for PRG550 Winter 2021 Assignment #1
import math
import random
import string
import collections
import datetime
import re
import time
import copy
def main( ) :
score = 0
coords = [ "25", "2A", "XL", "9Q", "1D", "6J", "93", "B4", "AF" ]
lastMove = ""
board = generateGameBoard(20, 26)
mask = generateGameBoard(20, 26)
board = loadWord(board, 20, 26, "29", "HELLO", "H") # loading words onto
game board
board = loadWord(board, 20, 26, "1D", "NO", "V")
board = loadWord(board, 20, 26, "2A", "EXAMINE", "V")
board = loadWord(board, 20, 26, "5J", "AREA", "V")
board = loadWord(board, 20, 26, "6H", "NORTH", "H")
board = loadWord(board, 20, 26, "93", "PYTHON", "H")
board = loadWord(board, 20, 26, "AD", "PUZZLE", "H")
board = loadWord(board, 20, 26, "B4", "7-SEAS", "H")
board = loadWord(board, 20, 26, "AF", "ZOO", "V")
if __name__ == "__main__" :
main( )
# The expected output is listed below. NOTE: You are NOT to clear the
screen
# after each call to
updateGameBoard( )