代写ENGG1110 Problem Solving by Programming 2024-2025 Term 1代做Statistics统计

ENGG1110 Problem Solving by Programming

2024-2025 Term 1

Project

Due Date: 2024/12/06 (Fri) 23:59


1. Introduction

Candy Crush is a popular match-three puzzle game in the world, originally released in

2012 for Facebook and later adapted for mobile platforms.

In the basic gameplay, the gameboard consists of a grid filled with various types of candies, each represented by different shapes and colors. The player’s goal is to create matches of three or more identical candies by swapping adjacent one. When a match is made, the matched candies are cleared from the gameboard, and new candies will fall  down to fill the empty spaces. This sometimes leads to “chain reactions”, where new matches are automatically created as the board refills.

In this project, you will develop a Candy Crush game using the C programming language. The project is structured in two phases: Part I focuses on implementing the basic version of the game, while Part II builds upon the first part by adding advanced features and additional gameplay mechanics.

You are required to complete the given source code main.c without modifying any existing code (except otherwise specified) or introducing new libraries. Marks will be deducted from every modification.



2. Program Flow

Part I

Part II

 


3. Suggested Project Schedule

Part I (60%)

 

Week 10

InitGameBoard(), printGameBoard()

Week 11

AskForSwap()- Input/Validation, swap()

Week 12

FindAndRemoveMatch(), isGameOver()

Part II (40%)

 

Week 13/14

File I/O, applyGravity, fillEmpty(),Cascade

Week 14

Cascade

4. Sample Runs for Part I

The following shows several examples of inputs and the resulting candy clearings. User inputs are indicated by bold, highlighted underlined text. The matches found by the function are in red font.

===== New Round: ===== | 0 | 1 | 2 | 3 | 4 | 5 | 0| # | % | @ | * | # | * | 1| @ | @ | * | # | # | % | 2| # | % | % | @ | % | * | 3| % | * | @ | # | * | @ | 4| # | * | @ | % | % | @ | 5| % | @ | # | * | % | % | Enter the coordinate (row, column) of the candy:5 2 Enter the direction to swap (U for Up, D for Down, L for Left, R for Right):L Vertical Match found at column 2! ===== | 0 | 1 | 2 | 3 | 4 | 5 | 0| # | % | @ | * | # | * | 1| @ | @ | * | # | # | % | 2| # | % | % | @ | % | * | 3| % | * | | # | * | @ | 4| # | * | | % | % | @ | 5| % | # | | * | % | % | ===== New Round: ===== | 0 | 1 | 2 | 3 | 4 | 5 | 0| # | % | @ | * | # | * | 1| @ | @ | * | # | # | % | 2| # | % | % | @ | % | * | 3| % | * | | # | * | @ | 4| # | * | | % | % | @ | 5| % | # | | * | % | % | Enter the coordinate (row, column) of the candy:0 2 Enter the direction to swap (U for Up, D for Down, L for Left, R for Right):D Horizontal Match found at row 1! ===== | 0 | 1 | 2 | 3 | 4 | 5 | 0| # | % | * | * | # | * | 1| | | | # | # | % | 2| # | % | % | @ | % | * | 3| % | * | | # | * | @ | 4| # | * | | % | % | @ |


5| % | # | | * | % | % | ===== New Round: ===== | 0 | 1 | 2 | 3 | 4 | 5 | 0| # | % | * | * | # | * | 1| | | | # | # | % | 2| # | % | % | @ | % | * | 3| % | * | | # | * | @ | 4| # | * | | % | % | @ | 5| % | # | | * | % | % | Enter the coordinate (row, column) of the candy:0 0 Enter the direction to swap (U for Up, D for Down, L for Left, R for Right):L Move Out of Bound. Please try again. ===== New Round: ===== | 0 | 1 | 2 | 3 | 4 | 5 | 0| # | % | * | * | # | * | 1| | | | # | # | % | 2| # | % | % | @ | % | * | 3| % | * | | # | * | @ | 4| # | * | | % | % | @ | 5| % | # | | * | % | % | Enter the coordinate (row, column) of the candy:1 2 Empty Cell Selected. Please try again. ===== New Round: ===== | 0 | 1 | 2 | 3 | 4 | 5 | 0| # | % | * | * | # | * | 1| | | | # | # | % | 2| # | % | % | @ | % | * | 3| % | * | | # | * | @ | 4| # | * | | % | % | @ | 5| % | # | | * | % | % | Enter the coordinate (row, column) of the candy:4 5 Enter the direction to swap (U for Up, D for Down, L for Left, R for Right):D Horizontal Match found at row 4! ===== | 0 | 1 | 2 | 3 | 4 | 5 | 0| # | % | * | * | # | * | 1| | | | # | # | % | 2| # | % | % | @ | % | * | 3| % | * | | # | * | @ |



4| # | * | | | | | 5| % | # | | * | % | @ | ===== New Round: ===== | 0 | 1 | 2 | 3 | 4 | 5 | 0| # | % | * | * | # | * | 1| | | | # | # | % | 2| # | % | % | @ | % | * | 3| % | * | | # | * | @ | 4| # | * | | | | | 5| % | # | | * | % | @ | Enter the coordinate (row, column) of the candy:2 3 Enter the direction to swap (U for Up, D for Down, L for Left, R for Right):R Horizontal Match found at row 2! ===== | 0 | 1 | 2 | 3 | 4 | 5 | 0| # | % | * | * | # | * | 1| | | | # | # | % | 2| # | | | | @ | * | 3| % | * | | # | * | @ | 4| # | * | | | | | 5| % | # | | * | % | @ | ===== New Round: ===== | 0 | 1 | 2 | 3 | 4 | 5 | 0| # | % | * | * | # | * | 1| | | | # | # | % | 2| # | | | | @ | * | 3| % | * | | # | * | @ | 4| # | * | | | | | 5| % | # | | * | % | @ | Enter the coordinate (row, column) of the candy:0 4 Enter the direction to swap (U for Up, D for Down, L for Left, R for Right):R Horizontal Match found at row 0! ===== | 0 | 1 | 2 | 3 | 4 | 5 | 0| # | % | | | | # | 1| | | | # | # | % | 2| # | | | | @ | * | 3| % | * | | # | * | @ | 4| # | * | | | | | 5| % | # | | * | % | @ | ===== New Round: =====



| 0 | 1 | 2 | 3 | 4 | 5 | 0| # | % | | | | # | 1| | | | # | # | % | 2| # | | | | @ | * | 3| % | * | | # | * | @ | 4| # | * | | | | | 5| % | # | | * | % | @ | Enter the coordinate (row, column) of the candy:1 5 Enter the direction to swap (U for Up, D for Down, L for Left, R for Right):U Horizontal Match found at row 1! ===== | 0 | 1 | 2 | 3 | 4 | 5 | 0| # | % | | | | % | 1| | | | | | | 2| # | | | | @ | * | 3| % | * | | # | * | @ | 4| # | * | | | | | 5| % | # | | * | % | @ | Game Over! No more possible moves.



5. Detailed Program Design Flow – Part I

In this project,you are required to follow exactly the output format specified. Using other output formats will jeopardize your mark.

This program will

1.  Read and initialize the game board from source

2.  Display the game board

3.  Allow the player to select a candy to swap

a.  The player can only swap two candies at a time

b.  The player will choose a candy by entering the coordinates (row, column)

c.  The player will also input a direction (U for Up, D for Down, L for Left, R for

Right) to specify where to swap the selected candy.

4.  Find and remove matches

a.  After each swap, check for matches of three or more identical candies in a row or column.

b.  If a match is found, display a message indicating the match’s location, remove the matched candies, and update the game board.

5.  Check for a game-over condition

a.  Check if no further matches are possible on the gameboard.

b.  If the board has no possible moves left, display the message and end the game.

5.1.       Header files, Functions, and Variable Declarations

At  the  beginning  of  the  main.c file,  we  include  two  headers,  <stdio.h>  and

<stdlib.h>.

No other header files or library are allowed in the project.

We define several  macros  after the  header  line.  Macros  are  identifiers  defined  by #define, which are replaced by their value before compilation. The first two are H and W.

#define H 6  // height

#define W 6  // width

H is the height of the game board, while W is its width. Therefore, our Candy Crush game board is a 6x6 square. In our test cases, we do not have any test cases with varying board size. You may try it if you are interested.

Each cell on the game board stores a candy, with different types of candies represented by numbers. To assist in converting these numbers into their corresponding candy representations, the following global variable is provided.

char candies[] = {'*', '#', '@', '%'};


No other global variables are permitted. All variables you define must be declared within functions and passed as parameters or return values as necessary. Violations of this rule will result in a deduction of marks.

Also, there are a number of helper functions declared in the project. You can add new functions to aid your work, but you CANNOT modify (function signatures – function    names, return type, parameters), or delete the given functions.

5.2.       Main Function

The main function is given to control the game flow.

There are some local variables already declared for you. You can declare your own local variables for your use.

Variables

Usages

int board[H][W]

Stores the candies on the game board.

The main function controls the gameplay as follows:

1.  Call initGameBoard() to load the initial game board.

2.  Enter the main game loop. The loop should continue until the game is over. Here are the tasks in the loop.

a.  The loop should start by printing five equal signs (=====) as a separator for each round, as follows:

=====

New Round:

b.  Then, call printGameBoard()to display the current game board.

=====

| 0 | 1 | 2 | 3 | 4 | 5 | 0| # | % | @ | * | # | * | 1| @ | @ | * | # | # | % | 2| # | % | % | @ | % | * | 3| % | * | @ | # | * | @ | 4| # | * | @ | % | % | @ | 5| % | @ | # | * | % | % |

c.  Call askForSwap() to execute the swapping logic. If the askForSwap()  returns zero (0), indicating the swapping is unsuccessful. In this case, print the following error message:

Please try again.\n

d.  Call isGameOver()to check if any moves are possible. If no valid moves   remain, display a game over message and exit the game loop. In this case, print the following error message:

Game Over! No more possible moves.\n

5.3.       Initializing Game Board

The main() function will first call the initGameBoard()function, which initializes the board[] array for the later gameplay. In Part I, the content of the array should be read from another hard-coded arrays – board_samples[].

5.4.       Print Game Board

The given printGameBoard() is useful throughout the program to show the current game board status to the user. You are required to implement this function and print the game board on the screen based on the following format, where ␣ represents a space character that should appear as an actual space in the program output.

First, print a line of five equal signs (=====) as a separator. Then, display the game board with row and column numbers labeled. Each cell should be separated by spaces and vertical bars to clearly distinguish rows and columns.

=====

␣␣|0|1|2|3|4|5| 0|#|%|@|*|#|*| 1|@|@|*|#|#|%| 2|#|%|%|@|%|*| 3|%|*|@|#|*|@| 4|#|*|@|%|%|@| 5|%|@|#|*|%|%|

There are two types of elements displayed on the grid:

•    Candies: Use the candies[] character array to convert the numerical values stored in board[][] into the corresponding candy symbols.

•    Empty Space: Display the space character (' '), which is stored in board[][] as ASCII 32 (space).

It is crucial that your output format follows the example exactly, including the number of spaces and any other formatting details, as the program will be graded using an autograder. Any deviation in the format could result in a loss of marks.



热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图