On this page:
Instructions
1 Overview
2 Gameplay Mechanics
3 Details and Requirements
3.1 Pre-Game Setup (CLI Phase)
3.2 Puzzle Initialization (Model)
3.3 GUI Interaction (Big-Bang Phase)
3.4 Azure Integration (Service Layer)
4 Implementation order
4.1 Part 1 (Model and Testing)
4.2 Part 2 (Integration and GUI)
5 Extra Credit (Optional)
6 Testing and Submission
7 Scheduling
8.13

Assignment 8: Image Puzzle Game with Azure Integration🔗

Goals: Design a game with mutable world state, mutable data structures, that integrates external services, and has GUI interaction. You will:
  • Interact with the Azure DALLE image generation API from the command line to generate a puzzle image.

  • Use a custom data structure to represent and manage puzzle pieces.

  • Implement GUI gameplay (using the big-bang style library) to let the player unscramble a scrambled image by rotating and swapping pieces until they match their correct orientation and position.

Instructions🔗

Due Date: Both parts due Tuesday, December 17 18, 10:00 pm

1 Overview🔗

Putting together puzzles is a great pasttime. You get to put together a picture, presumably of something that interests you. The unfortunate thing is, you always know exactly what the picture is supposed to look like—it’s always on the front of the box. There hasn’t been a way for someone to get a puzzle image of something they’re interested in, but without seeing what the final picture is supposed to look like—until now!

In this project, you will create a simple puzzle game. This game should be launched from the command line. You should invoke ./puzzle (or ./puzzle.exe on Windows for those who wish) to execute your program, and that alone should do everything necessary.

The user will be prompted to enter a text description (prompt) of an image. The user can type until entering a newline, which signals the end of the prompt. The system will send this prompt to the Azure image generation service DALL·E to obtain a corresponding image (I do, specifically mean Azure this time). If the system call rejects the prompt or does not return an image, your program should tell the user and ask again for another image generation prompt.

Once the image is successfully generated, the program transition to a graphical mode (using the big-bang library).

The user will see a scrambled version of the generated image. The goal is to reassemble the image into its correct configuration. Note the image must be a square for this to work, so somehow crop your generated image to a square, or pad the sides.

2 Gameplay Mechanics🔗

Initially, the puzzle is scrambled:

The player must restore the original image by:
  • Selecting a piece with a mouse click.

  • Pressing a key to rotate that piece left (L), right (R), or flip it (F), adjusting its orientation by 90°, 270°, or 180° as appropriate.

  • Alternatively, if a piece is already selected, the player can click on a second piece to swap their positions.

The puzzle is solved when all pieces are in their correct original position and orientation.

3 Details and Requirements🔗
3.1 Pre-Game Setup (CLI Phase)🔗

The program begins in the command line (no GUI yet). The user will be repeatedly asked to enter a textual prompt describing an image. For example, they might type:

"a serene landscape with mountains and a small house"

Your program sends this prompt to the Azure image generation API. If the call fails or no image is returned, the program prompts the user again. Once a valid image is obtained, it is stored locally and loaded into the game.

3.2 Puzzle Initialization (Model)🔗

You must come up with your own design to store and manage the puzzle pieces. For example, you might use a 2D array or a list of lists representing each grid position, or a HashMap. Perhaps each cell contains a Piece object. Regardless, the pieces need to know

You must write code to:

Your data structure and model code should be thoroughly tested. You will also implement a method to check whether the puzzle is solved.

3.3 GUI Interaction (Big-Bang Phase)🔗

After preparing the puzzle, the command-line phase ends and the big-bang GUI starts. The GUI should:

3.4 Azure Integration (Service Layer)🔗

You will need to perform the following:

You should handle potential errors gracefully, and prompt the user again if image generation fails.

4 Implementation order🔗
4.1 Part 1 (Model and Testing)🔗

For Part 1, you should:

4.2 Part 2 (Integration and GUI)🔗

For Part 2, you will:

5 Extra Credit (Optional)🔗

Consider adding features such as:

6 Testing and Submission🔗

Submit your code, tests, and instructions to the Assignment 8 Dropbox by the due date and time, and then you (and your partner, if you have one) should schedule a meeting with me. You should be prepared to demonstrate to me that you can invoke ./puzzle (or ./puzzle.exe on Windows for those who wish) to execute your program, and that alone should do everything necessary, and to demonstrate to me your knowledge of the program you have written and show me your tests and project infrastructure. As always, be very careful with your naming conventions.

7 Scheduling🔗

You can go ahead and schedule your code walk with me using the following: