Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gamification_reward #1166

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft

gamification_reward #1166

wants to merge 1 commit into from

Conversation

internet-zero
Copy link
Member

import numpy as np

gamification_wallet = 34400000

def list_of_active_patches(node_list, current_date):
    active_node_list = []
    for node in node_list:
        date_of_joining = node[3]
        average_availability = node[1]
        
        days_since_joining = (current_date - date_of_joining).days
        if days_since_joining >= 45 and average_availability >= 0.75:
            active_node_list.append(node)
    return active_node_list


def organize_by_patch_id(node_list):
    sorted_node_list = sorted(node_list, key=lambda x: x[2])
    grouped_node_list = []
    current_patch_id = None
    current_group = []
    for node in sorted_node_list:
        patch_id = node[2]
        if patch_id != current_patch_id:
            if current_group:
                grouped_node_list.append(current_group)
            current_patch_id = patch_id
            current_group = [node]
        else:
            current_group.append(node)
    if current_group:
        grouped_node_list.append(current_group)
    return grouped_node_list


def gamification_reward(gamification_node_list, current_date):
    reward_list = []
    earliest_date_of_joining = min(node[3] for node in gamification_node_list)
    gamification_reward_duration = 10  # The gamification reward is designed for 10 years
    years = [i for i in range(1, gamification_reward_duration + 1)]
    rewards_per_year_in_percentage = np.array([0.1 * year ** 2 for year in years])
    for node in gamification_node_list:
        node_id = node[0]
        patch_id = node[2]
        date_of_joining = node[3]
        average_availability = node[1]
        if (current_date - earliest_date_of_joining).days % 365 == 0:
            number_of_years = (current_date - earliest_date_of_joining).days // 365
            gamification_reward_patch = (gamification_wallet / (50 * sum(rewards_per_year_in_percentage))) * (
                        0.1 * number_of_years ** 2)
            gamification_reward_unit = average_availability * (current_date - date_of_joining).days
            node_reward = gamification_reward_unit * average_availability * (current_date - date_of_joining).days
            reward_list.append([node_id, patch_id, node_reward])
    return reward_list

@bchamagne
Copy link
Member

as discussed, we'll plan some pair programming to integrate this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants