Page 1 of 1

Write code that (1) reads data from files corresponding to an online video game (2) processes the data in Lists to answe

Posted: Tue Jul 12, 2022 8:16 am
by answerhappygod
Write Code That 1 Reads Data From Files Corresponding To An Online Video Game 2 Processes The Data In Lists To Answe 1
Write Code That 1 Reads Data From Files Corresponding To An Online Video Game 2 Processes The Data In Lists To Answe 1 (188.52 KiB) Viewed 33 times
adventurerData.txt
u92240,Harlynie Haldalle,wizard,2
u80266,Skarinna Darkpike,wizard,3
....
u59441,Bilviss Mountainmail,ranger,2
u13009,Alvangr Strongblaze,wizard,1
battleData.txt
u43994,m85246,7,921,Moonsea
u77969,m68716,5,898,Tethyr
...
u33453,m34080,3,971,Moonsea
u42576,m10872,5,632,SwordCoast
monsterData.txt
m44069,goblins,2269,3000
m33741,bandits,1851,6300
...
m82955,beasts,1705,2900
m82726,mages,3105,5600
Please Use PYTHON
Write code that (1) reads data from files corresponding to an online video game (2) processes the data in Lists to answer related questions. Moreover, you'll create plots that show statistics about the data. Task 1: implement readAdventurerData, readBattleData, readMonsterData In this task, you will write the functions that read data from files and append the data into lists. This task is often called data preprocessing. def readAdventurerData (fileName) : The function reads the adventurer data from a file and returns a list of lists. You need to convert the final column i.e., tier into an integer Parameters: filename (String) Return value: List of Lists where each sublist represents one line from the file def readMonsterData (fileName) : The function reads the monster data from a file and returns a list. You need to convert the gold and xp i.e., last two columns to integer type Parameters: filename (String) Return value: List of Lists where each sublist represents one line from the file def readBattleData (fileName) : The function reads the battle data from a file and returns a list. You need to convert the # turns and DPS i.e., last third and fourth columns to integer type Parameters: filename (String) Return value: List of Lists where each sublist represents one line from the file Task 2: implement the count Heroes function The count Heroes function uses the passed class and tier parameters to return the number of adventurers who meet the given criteria (class and tier). In order to access the adventurers' data, this function uses the adventurer's list returned from task 1 as a parameter. def countHeroes (adventurerList, class, tier): Parameters: adventurerList (List), char_class (String), char_tier (int) Return value: Integer that represents the count of adventurers who met the criteria explained earlier Task 3: implement the LevelUp function The Level Up function returns a list of adventurers' names who have earned over 250000 XP points across all their battles. The formula for calculating the XP points from a particular battle is given below: XP points = DPS Character tier x 100 X (XP Value of the Monster) Implementing this function could be challenging at the first attempt since the pieces of the needed information are stored in three lists:Character tier from adventurerList, DPS from battleList, and XP value from monsterList. The returned list must be sorted ascendingly. Hints: to sort a list, you may use Python's sorted function. XP points earned in each transaction can be obtained by using the given formula whereas different elements of the formula are obtained from different lists Note that a single adventurer can have multiple battles. When computing the XP eamed by an adventurer, you must add the amounts from all the battles the adventurer is involved in. While the battleList will help you find the user ids, you still need the adventurerList to find the character names def LevelUp (adventurerList, monsterList, battleList): Parameters: adventurerList (List), monsterList (List), battleList (List) Return value: List of Strings that represent the adventurers who met the XP criteria sorted ascendingly Task 4: implement the GoldHoarded function The GoldHoarded function returns the overall amount of gold (rounded to the integer value i.e., 0 decimal points) earned across all the battles in a given area (passed as a parameter to the function). The formula for computing the amount of gold earned in a single battle is given below:
Hints: Gold earned = 10-number of turns 10 Gold earned in each battle can be obtained using the given formula whereas the number of turns can be found in the battleList and the gold value can be found in the monsterList Use int () to round the amount to the integer value def GoldHoarded (battleList, monsterList, area) : Parameters: battleList (List), monsterList (List), area (String) Return value: Float that represents the overall gold won from a given area x (Gold value of the Monster) Task 5: implement the battlestatistics function The battleStatistics function collects statistics about the number of monsters defeated of each type filtered by character class. The function returns a list of lists where each sublist represents the monster type and number of monsters defeated by adventurers of a given character class (passed as a parameter). The returned list should be sorted ascendingly by the monster type. Hint: to sort a list of lists based on one of the entries, you may use Python's sorted function with a lambda expression def battleStatistics (adventurerList, battleList, monsterList, char_class): Parameters: adventurerList (List), battleList (List), monsterList (List), char_class (String) Return value: List of Lists where each sublist represents a monster type and number of monsters of this type defeated by characters from the given class. Task 6: implement the plot Pie Chart, plotBarChart functions Part 1: The plotPie Chart function creates a pie chart that summarizes the overall gold earned from each area. Hints: You can use the GoldHoarded function implemented in Task 4 (Hint: Use the function with all three areas i.e., SwordCoast, Tethyr, Moonsea) Save the chart as plotPie Chart.pdf def plotPieChart (battleList, monsterList): plot.pie parameters: 1- autopet-'1.1f add percentages to the pie chart sections 2-startangle-90 colors ['red', 'green', 'gold' ] Parameters: battleList (List), monsterList (List) No returned value Part 2: The plotBarChart function creates a bar chart for the monster types and the number of monsters defeated filtered by the character class "Ranger". (Hint: Use the function defined in Task 5 with "ranger" as parameter) Save the chart as plotBarChart.pdf def plotBarChart (monsterCountList): Parameters: monsterCountList (List) No returned value Task 7: implement the main function Write the appropriate code to test the functions you implemented. Submission: please use if name __main___" method to call main()