archethic-node icon indicating copy to clipboard operation
archethic-node copied to clipboard

gamification_reward

Open internet-zero opened this issue 1 year ago • 1 comments

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

internet-zero avatar Jul 10 '23 10:07 internet-zero

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

bchamagne avatar Jul 10 '23 10:07 bchamagne