Hỏi đáp

Chia sẻ kiến thức, cùng nhau phát triển

Python - Orientation Object and Parameter Sweep

19:10 21-04-2022 440 lượt xem 0 bình luận

Em có một assignment ở trường thế này nhưng lại không biết làm sao ạ, các cao nhân có thể cho em hướng giải quyết được không ạ ?

Project như sau:

Overview

Deep in the jungles of Africa, a rare bat virus was transmitted to a group of people causing them to live forever without needing food or water. The minor side effect of this virus is that the infected people live with a continual desire to bite humans and drink their blood. Those bitten then join the world’s new biting force (also known as vampires).

This program is to simulate a vampire takeover and report on the findings.

Specifications

We will be simulating the infection of humans by vampires on a 2D map of a size of your choosing. The simulation will show a scatter plot containing humans, vampires, food, water and garlic. On each timestep, the vampires and humans will move and interact with each other as well as with the food, water and garlic.

Timesteps (5%)

The heart of your program will be a loop that controls how many timesteps the program runs for. This loop will control all the other functionality (such as movement).

Your program should accept 3 command line parameters but default to reasonable options in the case of their absence. The command line parameters are as follows:

  • ●  Initial number of humans

  • ●  Initial number of vampires

  • ●  Number of timesteps in the simulation

    Objects (10%)

    Both humans and vampires should be represented in the code as objects. Humans should have health and age variables and vampires only a health variable. They should also have methods for their various actions, such as moving, attacking, biting etc. The methods you have are up to you.

  • Humans start with a health of 100 at the beginning of the simulation and lose 1 health point
    for every step they move (see the movement section). Humans also start with a random age between 10 and 50 and at every timestep they age by 1. Humans don’t live past 70 timesteps. Vampires start with the health that they had as a human before becoming infected. They don’t have an age and only lose health by being bitten by other vampires (see the interaction section).

    Food, water and garlic could also be represented using objects but don’t have to be. The initial locations of food, water and garlic are up to you.

    Movement (10%)

    Humans and vampires both move randomly. Humans can move up to 4 spaces (steps) in any direction. Vampires can move up to 8 spaces (steps) in any direction. Neither humans nor vampires should be able to go off the map. Food, water and garlic don’t move.

    Interactions (20%)

    Humans and vampires should interact with each other as well as items on the map (food, water and garlic). An interaction occurs when a human or vampire is on any of the 8 squares next to something else (e.g. a human, a vampire, food, water or garlic). When an interaction occurs you should print the interaction and the result to the terminal (i.e. a vampire was killed by a human, a human just drank water etc).

    The human and vampire interactions types are as follows:

  • ●  Human and human interaction: some people are selfish and others are helpful. When two humans interact there is a 40% chance that one human uses the other to gain 20 health, which means the other loses 20 health. There is also a 60% that the humans help each other and both gain 10 health.

  • ●  Human and vampire interaction: vampires like biting. When a human and vampire meet the human has a 70% chance of being bitten by a vampire and becoming a vampire. The vampire has a 30% chance of being killed by the human.

  • ●  Vampire and vampire interaction: vampires like biting, so much so, they can’t help but sneak in a cheeky bite at any opportunity they get. As a result, when vampires come into contact they bite each other, with the result being that both vampires lose 20 health.

  • The water, food and garlic interactions types are as follows:

  • ●  Human water interaction: gains 50 health (no effect on vampires)

  • ●  Human food interaction: gains 30 health (no effect on vampires)

  • ●  Human garlic interaction: gains 100 health (no effect on vampires)

    Visualisation of results (5%)

    Your program should display a scatter plot for each timestep with the current positions of all the humans and vampires. The items on the map should vary in colour, shape and size. For example, humans could be red circles, vampires black circles, food brown squares, water large blue squares and garlic grey triangles. It is up to you what colours, shapes and sizes you use.

    Parameter sweeps (10%)

    Create a parameter sweep to run the program with an initial human population of 10 to 40 with an initial vampire population of 1 to 5. Save the final plot of each simulation run by the parameter sweep. Also, save the initial and final human and initial and final vampire populations (4 values) of each simulation as one row in a CSV file (running the parameter sweep bash file should just produce one CSV file). You can use this data in your report.

Bình luận

Để bình luận, bạn cần đăng nhập bằng tài khoản Howkteam.

Đăng nhập

Câu hỏi mới nhất