Informasi Dokumen
- Mata Pelajaran: Mobile Game Development
- Topik: Implementasi Metode Generate and Test Dalam Penyelesaian Puzzle 2048 Berbasis Mobile
- Tipe: Graduation Project
Ringkasan Dokumen
I. Introduction: Implementasi Metode Generate and Test Dalam Penyelesaian Puzzle 2048 Berbasis Mobile
This document details the implementation of a Generate and Test method for solving the 2048 mobile puzzle. The core functionality involves generating a tree of possible game states and selecting the optimal path to reach the target score of 2048. The document covers the problem analysis, system requirements, software modeling (using use-case and activity diagrams), flowchart representation, pseudocode for the AI, user interface design, implementation details, and testing results. The primary objective is to evaluate the efficiency and success rate of the Generate and Test approach for this specific puzzle.
II. Problem Analysis and System Requirements
The primary challenge is efficiently finding the optimal sequence of moves to reach 2048. A fishbone diagram (Ishikawa diagram) illustrates contributing factors: limited processor capabilities, game mechanics understanding, efficient move selection, and gameplay limitations. Functional requirements include move generation, optimal move selection, and execution. Non-functional requirements focus on performance (fast execution), user-friendliness (simple interface), cost-effectiveness (no extra hardware), accurate documentation (runtime recording), appropriate error handling (success/failure dialogs), and high-quality AI (accurate move generation and runtime calculations).
2.1 Problem Analysis
The core problem is to achieve the highest possible tile value (2048). The Ishikawa diagram identifies constraints such as limited processing power, the need for the AI to understand game mechanics, efficient algorithm design for move selection, and the possibility of running out of moves before reaching the goal. These factors influence the design and implementation of the solution.
2.2 Requirement Analysis (Functional and Non-Functional)
The system must generate and evaluate potential game states to identify the optimal path (functional). Non-functional requirements emphasize performance (fast execution of game moves and calculations), ease of use (intuitive user interface), low cost (no additional hardware), reliable data logging (accurate runtime recording), effective error handling (dialog boxes for game success/failure), and robust AI performance (reliable move generation and runtime calculations).
III. Software Modeling and Design
The system's functionality is modeled using a use-case diagram showing the 'User' interacting with the 'Generate and Test' use case. An activity diagram details the Generate and Test process flow. A sequence diagram illustrates the interactions between the User, the AI, and the game controller. A flowchart provides a visual representation of the Generate and Test algorithm, outlining the move generation, selection, and execution steps. Pseudocode for key AI functions (resetting game state and continuing AI) provides a detailed algorithmic description.
3.1 Use-Case Diagram
The use-case diagram simplifies interaction, showing the User initiating the 'Generate and Test' process without needing detailed knowledge of internal processes. The system manages the process internally.
3.2 Activity Diagram
The activity diagram provides a visual flow of the Generate and Test process, showing the steps involved in generating moves, evaluating them, and selecting the optimal path toward the 2048 goal.
3.3 Sequence Diagram
The sequence diagram illustrates the temporal order of interactions between the system components, showing how the User interacts with the AI and game controller. This clarifies the order of operations and information flow.
3.4 Flowchart and Pseudocode
The flowchart visually maps the Generate and Test algorithm's steps. The provided pseudocode offers a detailed description of the AI's 'resetNode' and 'ContinueAI' functions, which are crucial for the algorithm's functionality. These clarify the algorithmic logic and data structures used in the AI.
3.5 User Interface Design
The UI design focuses on simplicity and informativeness. The main menu features a 'Start' button to initiate the game and displays information about the developers. The game scene includes a title, UI elements for displaying the timer and game score, and the game board itself. The design prioritizes clarity and ease of use.
IV. System Implementation and Testing
The implementation section describes the game's visual representation and its behaviour. Testing involved running the algorithm for both 5 and 6 steps, evaluating success rates and average execution times (using both an Android device and Unity's simulator). Manual calculations were performed to estimate the number of iterations required for different numbers of steps. Results demonstrate that a 6-step generation approach improved the success rate for achieving 2048 compared to a 5-step approach, although the execution time was longer.
4.1 Implementation Details
The implementation section includes screenshots showcasing the game interface (main menu and gameplay scene). It explains the criteria for success (reaching 2048) and failure (running out of moves). Examples of successful and unsuccessful gameplays are shown, highlighting the visual feedback provided to the user.
4.2 Manual Calculation of Iterations
The manual calculations provide an estimate of the computational complexity of the Generate and Test algorithm. It shows how the number of iterations scales with the number of steps generated, underscoring the tradeoff between computational cost and the probability of finding a solution.
4.3 System Testing and Results
The testing phase involved running the algorithm multiple times (10 iterations for both 5 and 6 steps) to gather data on both time taken and the success rate. The results are presented in tables, comparing the average time to reach 1024 and 2048 for each step count. Graphs illustrate the comparison of the average times for both 5 and 6 step approaches. The analysis shows that while 5 steps are faster to reach 1024, 6 steps yield a significantly higher success rate for reaching the 2048 goal. This highlights the algorithm's performance characteristics.