代做FIT1008 A3帮做Python编程

Important Information, Tips and Tricks

Before you get working on the implementation, please read these instructions and tips to ensure you don't lose any important marks!

Documentation Requirements

Documentation requirements are different when comparing to the previous assignments.

In addition to the

●   required worst case and best case analysis for each function/method,

You are also

● required to include short paragraphs (50-300 words) detailing your approach in detail in the docstring of the associated class.

Approach details in general should include:

●    Data structures and data types used

Small example(s)

●    Explanations/Reasonings/Proofs on your complexity result (i.e., details on why you obtained the specific best case and worst case results)

See the rubric for information on how this is marked.

Common Mistakes

●    [Marking] You are marked on correctness in Ed. It doesn't matter if your code passes locally, it needs to pass in Ed. Please contact us in Ed forum and/or consultation hours if you have any issues.

●    [Tools] Make sure you use an up-to-date Python version.

●    [Tools] As usual, if importing a third-party/external library means you do not need to implement some of/all the assignment tasks, chances are that it is not allowed. As always, follow the latest instructions on Ed Forum.

●    [Tools] If introducing new classes, consider usingdataclasses to simplify this definition.

●    [Clarity/Style/Readability] Write clear and concise docstrings for methods you introduce / edit.

●    [Clarity/Style/Readability] Try to separate your code into small methods of at most 20 to 30 lines. Try to abstract logic if you find lots of duplicated/similar codes.

Initial Setup + Running Tests

To get up and running you want to do a few things:

●    Import the template repository, and

●    Follow the instructions in the Getting Started with Git page.

To run tests, call python run_tests .py. Note that you can restrict which tests are run using a second argument. For example, running python run_tests .py 1.

Assumptions & Tidbits

YOU MAY ASSUME THE DEPTH OF A BST IS ALWAYS BOUND BY O(log(N))O(log(N)) FOR THIS ASSIGNMENT - FOR BOTH SOLUTIONS AND COMPLEXITY ANALYSIS!

USING THE sorted OR THE sort (PYTHON INBUILT) FUNCTIONS ARE BANNED.

dataclasses are used in some of the scaffold code. In short, they do a lot of the

initialisation boilerplate for you by inspecting the type hinting for class variables. You'll be expected to understand at a high level what this does to get started with your tasks. You should read more about ithere .

[TASK] Mode 1 - A dungeon a day keeps the scurvy at bay

Please be aware of the documentation requirements and complexity assumptions touched on in Important Information, Tips and Tricks!

In this task, you've amassed a crew of cc brave adventurers, ready to set the journey and make as much gold as possible. You can assume they are willing to die/perish for whatever reasons!

For every land site, containing gg guardians with holding rr amount of gold, you can decide to send over cici adventures (0≤ci≤c0≤ci≤c).

The reward you'll earn from this is equal to:

min(cirg, r),min(gcir, r),

But the adventurers you send will perish in the process  (as well as an equal amount of guardians).

Assumption: Guardians gg and adventurers cc (including all cici) are positive integers, and gold rr is a positive real number.

Corollary:

●    If you send ci≥gci≥g adventurers to match gg guardians, you can max out rr (as reward).

Assumption: We assume if the land site has been previously plundered/invaded, then: a) there will be no guardians present (g=0g=0), and 2) there will be zero gold left (r=0r=0).

Every day, you will need to decide

the land sites you wish to send the adventurers to and

●    how many adventurers to each of these sites

to maximise the reward.

Assumption: For simplicity, we discount the cost for the loss of adventurers (i.e., you pay $0 for their funerals)

Your task is to implement the Mode1Navigator class. You are required to implement the following methods:

__in it__(self, sites: list[Land], adventurers: int):

○   This method perform initialisation. Input sites holds the initial states of the land sites, input adventurers indicates the total number of adventurers cc you are   going to take with you on your journey.

select_sites(self) -> list[tuple[Land, int]]:

The method shall selects the land sites you desire to attack. It is required to

return a list of pairs (in tuple data type), where each pair containing a land object and the number of adventurers you will be sending to the corresponding land site.

●    select_sites_from_adventure_numbers(self, adventure_numbers: list[int]) -> list[float] :

The method calculates the maximum amount of reward you can make with

different adventurer numbers. Input adventure_numbersis a list indicating the  number of adventurers for each of the configuration. The method must return a list containing the amount of reward you could make for each of the configuration (corresponding to adventure_numbers).

●    update_site(self, land : Land, new_reward : float, new_guardians: int) -> None:

○   The method is used to update the state of the land object. Input new_reward and new_guardians represent the amount of reward and the number of guardians to be updated for the particular land site (land).

○    Note: The method is called whenever an Island needs to be updated.

For this task, you can assume all land sites: a) have unique names, and; b) the ratio of guardians to reward for each site is unique (throughout execution).

For this task, both select_sites and select_sites_from_adventure_numbers methods must not modify the internal states of the land site (land).

For example: If select_sites is called, and your plan is to ransack Site A for all of its gold (i.e., for obtaining the maximum reward), make sure your code:

* Will not modify/change the original adventure number/configuration

* Will not override the states (e.g., number of guardians and golds) of the Site A object.

In other words, if you call select_sites again, the return value should still be the same.

You are allowed to initialize Python in-built List (i.e., []) and use the append method. However, other methods of the in-build List are generally discouraged.

Complexities

Let NN be the number of land sites ( sites), determined by initialisation/marking test cases.

●    __in it__ method are required to have a worst case complexity of O(Nlog(N))O(Nlog(N)) (or less)

●    select_sites method are required to have a worst case complexity of O(N)O(N) (or less), and a best case complexity of O(log(N))O(log(N)) (or less).

●    select_sites_from_adventure_numbers method has a different complexity requirement for 1008/2085 (and 1054 students).

1008/2085: The method is required to have a worst case complexity of O(A × N)O(A × N), where AA is the length of adventure_numbers.

(Bonus [optional]: The method could be done with a worst case complexity of O(N+Alog(A))O(N+Alog(A)), where AA is the length of adventure_numbers.  Try to work on it if you have extra time.)

●    update_site method is required to have a worst case complexity of O(log(N))O(log(N)) (or less).

Final Reminder: For this task, you are suggested to implement in the following order: init,

select_sites, select_sites_from_adventure_numbers, and update_site. Make sure you don't miss the complexity requirements & documentation requirements of the assignment too.

[TASK] Mode 2 - A Fair Fight

Please be aware of the documentation requirements and complexity assumptions touched on in Important Information, Tips and Tricks!

In this mode, your team isn't alone! You're battling it out against other groups and teams of greedy adventurers for treasures!

To make the fight for treasures fair and square, the adventure guild has set up some rules. Your team has to prove yourselves to be the best in a qualifying game!

The game works in the following way:

1.   Every navigator gets a fresh team of adventurers (with the same adventurer team size for fairness).

2.   Each adventurer team then takes turns selecting ONE land site to adventure, with a specific adventurer size. The adventure team can also skip their turn and do nothing.

○    Note: Different teams are also allowed to send adventurers to the same sites!

3.  After each team selected their action (i.e., sending adventurers or do nothing), the day is over and the scores of the day is counted:

The score OO of a particular adventure team on a given day is:

O=2.5 ×c+rO=2.5 ×c+r, where cc is the remaining adventure numbers and rr is the gold (reward) gained on that day.

○    Please refer to Task 1 for the reward descriptions/equations for calculating rr.

4.   The adventure team with the highest scores wins the qualifying game.

All the team leaders surprisingly are perfect logicians! They will always select the site and adventurer numbers that will maximise their total scores for the day.

Your task is to implement Mode2Navigator with the following methods to simulate the game:

__in it__(self, n_teams: int) -> None:

○   The method initialise the object and stores the number of adventurer teams n_teams in the game (i.e., total number of teams).

add_sites(self, sites: list[Land]) -> None:

○   The method stores and adds land sites (sites) to the object. If there are existing land sites already in the object, then this method will append land sites (sites)    to the existing land sites.

●    simulate_day(self, adventurer_size: int) -> list[tuple[Land|None, int]]:

The method simulates a day of the game.

○    Input:adventurer_size is the size of the adventurers for every team.

○   Output: The method must return a list of tuples, where each tuple represents the choices made by the first, second, third, ..., n_teams team leaders in the order.

■    Each tuple should contain the land sites that the team leader chooses (or None object if the team leader decides not to send any adventurers), and how many adventurers onto the land site (or 0 if the team leader decides  not to send any adventurers).

For this task, you can assume that the names of the land sites are unique. However, you cannot assume the scores OO of landsites are unique. Your data structures should support  multiple landsites with the same score. In case of a tie (i.e., there are ≥2≥2 landsites with the highest score), you are free to select either one of the best landsites.

For this task, simulate_day will alter the internal states of the land sites.

For example, if simulate_day is called and an adventure team decides to ransack land site A, then you need to make sure A have the correct amount of remaining gold and gurdians left.

Complexities

Let NN be the number of existing land sites, and KK be the number of adventure teams participating in the game.

●    add_sites is required to have a worst case complexity of at most O(N+S)O(N+S), where SS is the length of the additional land sites (input sites) to be added.

●    simulate_day is required to have a worst case complexity of at most O(N+Klog(N))O(N+Klog(N)).

Tips

●    Method simulate_day is quite a large method to be implemented. In order to

implement simulate_day, you might want to consider breaking it down and implementing it step-by-step, with the help of multiple supporting methods. One possible strategy is to:

1.   Implement a method (e.g., compute_score ) to compute the maximum/potential score OO of a land site, based on the number of adventurers the team currently has. It should also return the remaining adventure numbers cc and the gold (reward) gained rr for the particular score OO. Keep in mind multiple land sites could have the same maximum/potential score.

2.   Implement a method (e.g., construct_score_data_structure) to construct the appropriate data structure(s) to organize the scores of all the land sites, and   their relationships to all the land sites (sites).

●   The worst case complexities of methods are hints to what data structures/types you are expected to use!

●   When populating data into your chosen data structure(s), please check the complexity of the construction method(s). There may be multiple construction

methods/mechanisms for the same data structure, and their complexity can be different!

For simplicity, [ONLY for this task] you are allowed to assume the set item and get item methods for the given hash table data structure to be O(1).




热门主题

课程名

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
站长地图