Kronoruler
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # PPA Coursework 3 - Teyvat Ecosystem **Authors** ###### Kaushik Chinta - 20029311 ###### Aaron Patrick Monte - 20059926 ## Project Information This project is a simulator of the world of Teyvat, based on the game Genshin Impact by MiHoYo: https://en.wikipedia.org/wiki/Genshin_Impact The project simulates different organisms and their behaviour. Organisms in this project include: Slimes, Boars, Wolves, Hilichurls and Humans. The values of the organisms can be found in the `Portfolio` class and has been adjusted to maintain a relatively stable population under clear weather conditions. In a normal long simulation, the wolves die out at ~1200 steps and the Hilichurls die out at ~700 steps because they can not compete with humans who eat their prey. To start this application, create an instance of class `Simulator` and call either its `simulate()` method, `runLongSimulation()` method or their overloaded variants. Running the `startInfection()` method will start an infection but this will only be visible on the next step. ## Functionality The simulation consists of five organisms, of which three are predators and two are prey. Plants are assumed to be always available. The prey consist of: - Slimes - Boars The predators are: - Hilichurls - which eat slimes. - Wolves - which eat boars. - Humans - which eat both slimes and boars. <div style="page-break-after: always;"></div> **Class Diagram** ![](https://i.imgur.com/nxudEua.png) **Food Chain** ![](https://mermaid.ink/img/eyJjb2RlIjoiZ3JhcGggQlRcbiAgICBTbGltZSgoU2xpbWUpKSAtLT4gSGlsaWNodXJsKChIaWxpY2h1cmwpKSBcbiAgICBCb2FyKChCb2FyKSkgLS0-IFdvbGYoKFdvbGYpKVxuICAgIFNsaW1lIC0tPiBIdW1hbigoSHVtYW4pKVxuICAgIEJvYXIgLS0-IEh1bWFuIiwibWVybWFpZCI6e30sInVwZGF0ZUVkaXRvciI6ZmFsc2V9) All organisms can eat, give birth and fall asleep as well as be infected and spread their infection. Some organisms have varying behaviour, depending on the weather. This is explained further in the challenge tasks section of this document. ## Completed tasks All the base tasks have been successfully completed. We also implemented different weather types which cause some of the organism's behaviour to vary as well as infections that can spread between different organisms. We then modified the GUI so that we can add an extra 2 labels displaying the current weather and whether an infection has occurred yet or not. <div style="page-break-after: always;"></div> ### Base Tasks - We have five different species which are: Slimes, Boars, Hilichurls, Wolves and Humans. - Humans compete for their food with Hilichurls and Wolves. It is interesting to note that because of this competition, Hilichurls and Wolves eventually go extinct after a certain number of steps. - All organisms have a boolean `isFemale` attribute, in other words, its sex. We then modified the `canBreed()` method so that for an organism to be able to give birth, the organism has to: - be of the right age - be female - be adjacent to a male organism of the same type - not infected by the disease - The field contains an `isDay` attribute which determines whether or not the field is in day time or night time. Organisms will become inactive during the night but they will still age. We switch between day and night every two steps (the default value for `DAY_NIGHT_CYCLE`) by using the `toggleDay()` method from the `Simulator` class when the total steps modulo divided by the `DAY_NIGHT_CYCLE` constant equals 0. ### Challenge tasks - The different weathers of Teyvat are kept in an enumerated data type. Then we added overloaded versions of the `simulate()` and `runLongSimulation()` methods which take in a string to allow the user to make use of this weather system. Depending on this string, we choose a corresponding state in the `Weather` enumeration and assign it to `weather` attribute in the `Field` class. We then make a use of this attribute to implement changes in some of the organism's behaviour. By default the weather is clear and has no effects on organism behaviour. Currently we have 3 different weather effects which are as follows: - When the weather is snowy, slimes will be unable to move. - When the weather is rainy, slimes will move twice per step. - When the weather is sunny, predators have a chance of becoming hungrier. - To implement diseases, we added a boolean attribute called `isInfected` in the `Organism` class. We then used this to determine whether the mark drawn from the `SimulatorView` should be of their own respective class colours or red (if they are infected). This means that all infected organisms will show up as a red square regardless of their type. We then used a few more variables in the `Field` class to store the duration and the spread rate of the disease. In the current implementation only one infection can be simulated per field. Finally in the `Organism` class we made the disease kill the organism when the `activationTime` reaches 0. This activation time is initialised to the disease's `duration` and is decremented every step. We also made it so that organisms with the disease will try to infect their adjacent neighbours. In our implementation we made it so that organisms that are infected also cannot breed. - The base program used AWT and Swing to create its graphical user interface. To modify the interface to display the field's current weather and whether or not the infection has started, we created two new `JLabels`: `weatherLabel` and `infectionLabel`. The base program's interface uses a `BorderLayout`, where all but the `EAST` direction of the interface are occupied. Therefore, we had to wrap these labels with a parent node. We chose to use a `JPanel` for this. We then modified the enumerated type for the `weather` to take in an associated string in its constructor. We then override the `toString()` method in the `Whether` enumeration so that it could easily be appended to the label. ## Code limitations At the beginning of the project there was a lot of duplicated code that could be shared, however each class had its own constants. To enable more code sharing we added a `Portfolio` class which in conjunction with the `Entry` class enables the sharing of the constants. This is done by using a `HashMap` that makes use of the class names for the keys. However, one main issue that we came across while refactoring the code was that there had to be a direct call to the current class' constructor in the `giveBirth()` method. For example, the `Slime` class had to call the `Slime`'s constructor whereas the `Boar` class had to call its own constructor. We could not find a solution to this problem and therefore we had no choice but to override the `giveBirth()` method in every sub class.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully