-
Notifications
You must be signed in to change notification settings - Fork 1
Person
File: Meesterproef-SNSimulation/js/Person.js
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.
You change the variables. The function of these variables is to change the behavior of the persons.
acceptanceDisctance = 300;
defaultScore = 1;
stepDistance = 5;
addInfoLinkThreshold = 3;
removeFriendLinkThreshold = -2;
removeInfoLinkThreshold = -5;
defaultRelationshipScore = 1;-
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
-
Parameters:
-
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
-
Parameters:
-
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
-
Parameters:
-
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
-
Parameters:
-
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
-
Parameters:
-
addFriendThroughContent(links): Adds friends through shared content.-
Parameters:
-
links(Map): The map of links in the network.
-
- View Code
-
Parameters:
-
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
-
Parameters:
-
moveLinks(links): Moves the links connected to this node.-
Parameters:
-
links(Map): The map of links in the network.
-
- View Code
-
Parameters:
-
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
-
Parameters:
-
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
-
Parameters:
-
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
-
Parameters:
-
removeForwardButtons(): Removes all forward buttons from the canvas.- Parameters: None
- View Code
-
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
-
Parameters:
-
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
-
Parameters:
-
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
-
Parameters:
-
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
-
Parameters:
-
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
-
Parameters:
-
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
-
Parameters:
-
📄 Debrief
-
🧑🎨 Design
-
🧑💻 Solution & Code
- 🎛️ App (main file)
- 🤖 Simulation
- 🔵 Node
- 🙋 Person
- 📰 Post
- 〰️ Edge
↖️ Cursor- 💽 userData
- 📊 WebData
- 📂 Import & Export (FileHandler)
- Onboarding