# Person **File:** `Meesterproef-SNSimulation/js/Person.js` ## Description The `Person` class represents a person node in the network. It extends the `Node` class and includes additional properties and methods specific to a person, such as managing friends, items, info links, and social interactions. ## Variables The function of these variables is to change the behavior of the persons (nodes). ```js acceptanceDisctance = 300; //The distance in px to decide if the person likes or dislikes a post. The bigger it is, the more post get liked stepDistance = 5; // The factor decide the distance that a node travels in a step addInfoLinkThreshold = 3; // The score that is required for an friendLink to become an infoLink removeFriendLinkThreshold = -2; // The score that is required to break the friendship between friends removeInfoLinkThreshold = -5; // The score that is required to break the infoLink between friends defaultRelationshipScore = 1; // Default score between friends ``` ## Methods - `readSocialMediaPost(nodes, links)`: Chooses a random social media post to read, calculates a score for it, and adds it to the person's items. - **Parameters:** - `nodes` (Map): The map of nodes in the network. - `links` (Map): The map of links in the network. - **[View Code](https://github.com/JopMolenaar/Meesterproef-SNSimulation/blob/main/js/Person.js#L25)** - `forwardSocialMediaPost(links)`: Forwards a social media post to the person's friends if the score of the post is positive. - **Parameters:** - `links` (Map): The map of links in the network. - **[View Code](https://github.com/JopMolenaar/Meesterproef-SNSimulation/blob/main/js/Person.js#L62)** - `receiveSocialMediaPost(sender, post, relationshipScore, links)`: Receives a forwarded social media post from a friend or info link and calculates a score for it. - **Parameters:** - `sender` (Person): The person who sent the post. - `post` (Post): The social media post being received. - `relationshipScore` (number): The relationship score between the sender and the receiver. - `links` (Map): The map of links in the network. - **[View Code](https://github.com/JopMolenaar/Meesterproef-SNSimulation/blob/main/js/Person.js#L88)** - `calculateScore(myScore, post)`: Calculates the score of a post for the person based on the distance to the post. - **Parameters:** - `myScore` (number): The initial score of the post. - `post` (Post): The social media post. - **Returns:** number - The calculated score. - **[View Code](https://github.com/JopMolenaar/Meesterproef-SNSimulation/blob/main/js/Person.js#L149)** - `manageRelationships(links)`: Manages relationships with friends and info links, adding or removing links based on scores. - **Parameters:** - `links` (Map): The map of links in the network. - **[View Code](https://github.com/JopMolenaar/Meesterproef-SNSimulation/blob/main/js/Person.js#L159)** - `addFriendThroughContent(links)`: Adds friends through shared content. - **Parameters:** - `links` (Map): The map of links in the network. - **[View Code](https://github.com/JopMolenaar/Meesterproef-SNSimulation/blob/main/js/Person.js#L186)** - `moveNode(links)`: Moves the node to a new position based on the average position of friends, info links, and items. - **Parameters:** - `links` (Map): The map of links in the network. - **[View Code](https://github.com/JopMolenaar/Meesterproef-SNSimulation/blob/main/js/Person.js#L204)** - `moveLinks(links)`: Moves the links connected to this node. - **Parameters:** - `links` (Map): The map of links in the network. - **[View Code](https://github.com/JopMolenaar/Meesterproef-SNSimulation/blob/main/js/Person.js#L229)** - `findLink(node, links)`: Finds the link between this node and another node. - **Parameters:** - `node` (Node): The other node to find the link to. - `links` (Map): The map of links in the network. - **[View Code](https://github.com/JopMolenaar/Meesterproef-SNSimulation/blob/main/js/Person.js#L239)** - `step(nodes, links)`: Performs all behaviors of the agent in one step. - **Parameters:** - `nodes` (Map): The map of nodes in the network. - `links` (Map): The map of links in the network. - **[View Code](https://github.com/JopMolenaar/Meesterproef-SNSimulation/blob/main/js/Person.js#L256)** - `spawnForwardButtons(links, filteredEdges)`: Spawns 'forward' buttons under each read social media post by the currently selected person node. - **Parameters:** - `links` (Map): The map of links in the network. - `filteredEdges` (Array): The list of filtered edges. - **[View Code](https://github.com/JopMolenaar/Meesterproef-SNSimulation/blob/main/js/Person.js#L276)** - `removeForwardButtons()`: Removes all forward buttons from the canvas. - **Parameters:** None - **[View Code](https://github.com/JopMolenaar/Meesterproef-SNSimulation/blob/main/js/Person.js#L298)** - `addFriend(node, links, score = this.defaultRelationshipScore)`: Adds a friend link between the currently selected node and the node with the given id. - **Parameters:** - `node` (Node): The node to add as a friend. - `links` (Map): The map of links in the network. - `score` (number): The initial score of the friendship. - **[View Code](https://github.com/JopMolenaar/Meesterproef-SNSimulation/blob/main/js/Person.js#L307)** - `removeFriend(node, links)`: Removes a friend link between the currently selected node and the node with the given id. - **Parameters:** - `node` (Node): The node to remove as a friend. - `links` (Map): The map of links in the network. - **[View Code](https://github.com/JopMolenaar/Meesterproef-SNSimulation/blob/main/js/Person.js#L325)** - `addItemLink(item, from, links, score = 1)`: Adds an item link between the currently selected node and the node with the given id. - **Parameters:** - `item` (Node): The item to add. - `from` (Node): The node to add the item link from. - `links` (Map): The map of links in the network. - `score` (number): The initial score of the item. - **[View Code](https://github.com/JopMolenaar/Meesterproef-SNSimulation/blob/main/js/Person.js#L344)** - `removeItemLink(item, links)`: Removes an item link between the currently selected node and the node with the given id. - **Parameters:** - `item` (Node): The item to remove. - `links` (Map): The map of links in the network. - **[View Code](https://github.com/JopMolenaar/Meesterproef-SNSimulation/blob/main/js/Person.js#L360)** - `addInfoLink(from, to, links, score = 0)`: Adds an info link between the currently selected node and the node with the given id. - **Parameters:** - `from` (Node): The node to add the info link from. - `to` (Node): The node to add the info link to. - `links` (Map): The map of links in the network. - `score` (number): The initial score of the info link. - **[View Code](https://github.com/JopMolenaar/Meesterproef-SNSimulation/blob/main/js/Person.js#L370)** - `removeInfoLink(from, to, links)`: Removes an info link between the currently selected node and the node with the given id. - **Parameters:** - `from` (Node): The node to remove the info link from. - `to` (Node): The node to remove the info link to. - `links` (Map): The map of links in the network. - **[View Code](https://github.com/JopMolenaar/Meesterproef-SNSimulation/blob/main/js/Person.js#L383)**