0% found this document useful (0 votes)
22 views3 pages

Data Structures Lab Project: Crystal Quest

Uploaded by

soumendhar393
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views3 pages

Data Structures Lab Project: Crystal Quest

Uploaded by

soumendhar393
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

National University of Computer and Emerging Sciences

School of Computing Spring 2023 Islamabad Campus


CL2001: Data Structures
2022 Lab (Spring
2023)
Semester Project
(Deadline: 7th May 2023, 11:59 PM)
Project groups: This project can be done within a group of three (3) students. There is no restriction
on the selection of group members. Students are allowed to make groups according to their
preferences. However, the group members must belong to the same data structure lab section.
Submission: All submissions MUST be made using the google form. Solutions sent to the emails will
not be graded. To avoid last minute problems (unavailability of Internet, load shedding, Internet down
etc.), you are strongly advised to start working on the project from day one.
Combine all your work (solution folder) in one .zip file after performing “Clean Solution”. Submit zip
file on Google Form within given deadline. If only .cpp file is submitted, it will not be considered for
evaluation. The naming convention for the zip file is rollno1_rollno2_rollno3.zip
Deadline: Deadline to submit project is 7th May 2023, 11:59 PM. No submission will be considered
for grading outside Google Form or after 7th May 2023, 11:59 PM. Correct and timely submission of
project is responsibility of every group; hence no relaxation will be given to anyone.
Plagiarism: -100% marks in the project if any significant part of project is found plagiarized. A code
is considered plagiarized if more than 20% code is not your own work.

Project Title: "The Quest for the Crystal Kingdom"


Scenario:
The player is on a quest to retrieve a legendary crystal from a dangerous and enchanted forest. The forest
is filled with enemies and obstacles, and the player must navigate through it to find the crystal. The player
has a map of the forest, which shows the location of the crystal and the player's current location (always
(0,0)). However, the map is not detailed, and the player must explore the forest to find the best route to
the crystal.

In the forest, the player must defeat enemies and overcome obstacles to progress through the journey. The
player can also collect reward items that will help them on their journey.

Tasks:
 Implement an AVL tree to store the player's inventory of item scores. The AVL tree should allow
the player to add and remove item scores (based on rewards). The first generated id should be 100.
The rest of ids will be generated randomly (0-200). All nodes beside the root should be inserted
based on the value of id.

o The node class/structure should be maintained as follows:


class Node
{
int id; //generated randomly
int reward_score; //score of a particular reward you obtained
int count; //to avoid duplicate id nodes (maintain count of the id)
Node *next;
Page 1 of 4
National University of Computer and Emerging Sciences
School of Computing Spring 2023 Islamabad Campus
2022
}

 Implement Floyd's algorithm to calculate. the shortest path between any two areas in the forest.
The algorithm should take into account the locations of enemies and obstacles

 Implement Prim's algorithm to find the minimum spanning tree of the forest. The algorithm should
take into account the locations of enemies and obstacles.

 Implement Kruskal's algorithm to find the minimum spanning tree of the forest. The algorithm
should take into account the locations of enemies and obstacles.

 Implement Dijkstra's algorithm to find the shortest path from the player's current location to the
crystal. The algorithm should take into account the locations of enemies and obstacles.

Note: You can specify the weights of the edges towards the obstacles as 100, all other edges have a
weight of 1.

Details of the Game Map:


The game map is built with alphabets and special characters specified in the key given below. A sample
map is given in figure 1.

C: Clear path
J: Jewel
P: Potion
W: Weapon
%: Death point
#: Obstacle
&: Dragon
$: Goblin
@: Werewolf
*: Crystal (goal point)

Figure 1: A sample Game Map

Page 2 of 4
National University of Computer and Emerging Sciences
School of Computing Spring 2023 Islamabad Campus
The map has the following entities: 2022

i. Safe paths: These are the nodes where you (the character) can move without any restriction.
ii. Obstacles: These are the nodes from where you should not move any further since the weights
of their edges are costly. The player should choose an alternate path on encountering an
obstacle.
iii. Rewards: These are the nodes on which you visit to collect items such as Jewels, Weapons,
and Potions. On collecting a jewel, weapon, or a potion, you will get +50, +30, and +70,
respectively in your score.
iv. Enemies: These are the nodes that if you visit them, one of your reward item will be removed
from the item inventory based on the following three enemies:
a. If you visit the node with a Werewolf, you will lose a weapon.
b. If you visit the node with a Goblin, you will lose a potion.
c. If you visit the node with a Dragon, you will lose a Jewel.
Note: Losing a reward will decrement the score for that reward as well.
v. Death points: These are the nodes that if you visit on them, you will die. You will have to
restart the game from the starting point.

Expected Outcomes:

1. The shortest path between any two areas in the forest.


2. The shortest path from current location.
3. The minimum spanning tree of the forest by both algorithms.
4. The score increased/decreased at every step, and the final score at the end.
5. The menu must have these features but is not limited to

 Shortest path using default location (0,0) by Floyd/ Dijkstra.


 Shortest path using custom location (coordinates entered by the user) by Floyd/ Dijkstra.
 Minimum Spanning Tree by Prims and Kruskal.

Restrictions:
 The algorithms should be implemented from scratch, without using any pre-built libraries or APIs.
 The program should be written in C++ and should be well-documented and easy to understand.

Page 3 of 4

Common questions

Powered by AI

The tasks required include implementing an AVL tree to manage the player's inventory of item scores, implementing Floyd's algorithm to calculate the shortest path between areas in the forest, implementing Prim's and Kruskal's algorithms to find the minimum spanning tree, and implementing Dijkstra's algorithm to find the shortest path from the player's current location to the crystal. Each algorithm must account for the presence of enemies and obstacles .

Dijkstra's algorithm is significant in finding the shortest path from the player's current location to the crystal. The game map handles obstacles by assigning them a weight of 100 to penalize paths passing through them, whereas other paths have a weight of 1. This weighting mechanism ensures the algorithm prefers clearer paths over obstacles. Enemy locations also need to be considered to avoid loss of inventory items, thus influencing path selection strategically .

Losing specific inventory items affects the gameplay score by decrementing the collected rewards, aligning with defeated enemies—Werewolves, Goblins, and Dragons reduce weapons, potions, and jewels respectively. This impacts strategy, making players cautious about enemy nodes and potentially dictating path choices to guard valuable inventory or necessitate item replenishment before critical encounters, thereby influencing overall gameplay dynamics and final scores .

Custom implementation is important as it enforces an understanding of the underlying algorithm mechanics, allowing tailored optimization and specific adaptations for the problem context, such as handling obstacles and varying path weights in the game map. Pre-built libraries may not provide the needed flexibility or insight into performance adjustments necessary for specialized game constraints, thereby diminishing learning opportunities and problem-solving skills .

The project requires submission as a single .zip file through the specified Google Form by the deadline. Emails or submissions past the deadline will not be considered. Group members must ensure the inclusion of mandatory elements in their submission and address potential internet issues by starting early. Proper naming conventions for the .zip file, adherence to guidelines, and a full ‘Clean Solution’ execution before the final packaging are also critical. These measures ensure the submission is complete and eligible for evaluation .

Prim's and Kruskal's algorithms should be implemented by evaluating paths that consider the weight attributed to obstacle locations and integrate enemy presence impacts. Prim's algorithm, which grows the minimum spanning tree using edge weights, requires careful selection of initial points to minimize traversal cost. Kruskal's algorithm necessitates a sort of all edges initially, requiring efficient handling of obstacles to avoid costly paths, thus minimizing total weight while encapsulating essential game pathways .

The project is subject to a strict plagiarism policy where any substantive section found plagiarized results in a -100% mark penalty. A code is considered plagiarized if over 20% is not original. Students are advised to start work early to prevent rush-induced plagiarism and ensure their work is original and compliant with academic integrity requirements. Effective collaboration within the group can also mitigate plagiarism risks .

The AVL tree is utilized to store and manage the player's inventory of item scores efficiently. It facilitates the operations of adding and removing items based on their reward scores. Each node in the AVL tree, beyond the root, is inserted based on the randomly generated id values. This ensures balanced and optimal search, insertion, and deletion operations, which is critical for maintaining a dynamic inventory during gameplay .

Different node types influence game strategy by affecting player movement and score. Safe paths allow unrestricted movement. Obstacles have high traversal costs, encouraging strategic detours. Rewards increase scores when collected but can be lost upon encountering specific enemies. Different enemies cause the loss of associated rewards (jewels, weapons, potions), affecting scores and future combats. Death points require complete avoidance to prevent game restarts. The understanding and integration of these node types are essential to optimizing paths and maximizing inventory and score .

The random id generation affects the AVL tree structure by diversifying insertion points, leading to balanced trees that optimize search efficiency critically required for real-time inventory management. This randomness encourages a balanced workload and prevents severe node clustering, enhancing performance by distributing node loads uniformly, which is important in maintaining the efficiency of dynamic insertion and deletion operations during gameplay .

You might also like