> For the complete documentation index, see [llms.txt](https://friendfi.gitbook.io/friendfi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://friendfi.gitbook.io/friendfi/5.-utilization-of-g.a.m.e-framework.md).

# 5. Utilization of G.A.M.E Framework

FriendFi achieves advanced credit scoring by utilizing Virtuals Protocol's G.A.M.E Framework. The G.A.M.E Framework is a framework for AI agents to make decisions autonomously, and functions as the "brain" of AI agents in FriendFi.

* **Overview of G.A.M.E Framework:** G.A.M.E (Generative Autonomous Multimodal Entities) is a modular framework that enables agents to autonomously plan and make decisions. It is a decision-making engine built on foundation models and can be used to power agents in various environments and platforms.
* **Role of G.A.M.E Framework in FriendFi:** In FriendFi, the G.A.M.E Framework plays a crucial role primarily in credit scoring. By using the G.A.M.E Framework, AI agents can analyze user behavior data and evaluate their creditworthiness.
* **Utilization of G.A.M.E Framework in Credit Scoring:**
  * **High-Level Planner (HLP) and Low-Level Planner (LLP):** The G.A.M.E Framework consists of two main components: HLP and LLP. HLP determines long-term plans, while LLP determines specific actions.
  * **Role of HLP in Credit Scoring:** HLP comprehensively considers activities on EchoSphere, on-chain activities, and credit token holdings to evaluate a user's long-term creditworthiness and sets a target credit score.
    * Example: `Target Credit Score = f(EchoSphere Activity, On-chain Activity, Credit Token Holdings)`
  * **Role of LLP in Credit Scoring:** LLP determines specific actions to achieve the target credit score set by HLP. For example, to improve a user's credit score, LLP may execute the following functions:
    * `EchoSphere Activity Analysis Function`: Analyzes the user's statements, frequency, engagement, etc.
      * `Statement Score = g(Quality of Statement, Frequency of Statement, Engagement Rate)`
    * `On-chain Activity Analysis Function`: Analyzes the user's transaction history, asset holdings, etc.
      * `Transaction Score = h(Transaction Frequency, Transaction Volume, Asset Holdings)`
    * `Credit Token Evaluation Function`: Analyzes the user's credit token holdings, transaction history, etc.
      * `Token Score = i(Holdings, Transaction Volume, Holding Period)`
  * **Feedback Loop:** The results of actions executed by LLP are fed back to HLP, which helps adjust the target credit score and formulate new action plans.
    * `Adjusted Target Credit Score = Target Credit Score + α(Statement Score, Transaction Score, Token Score)`
    * Here, `α` represents the weighting coefficient for each score.
  * **Adding Custom Functions:** In FriendFi, developers can define their own functions and add them to LLP. This enables more precise credit scoring specialized for specific use cases.
  * **Example of Function Definition (Credit Token Price Prediction Function):**

    ```
    {
      "fn_name": "predict_credit_token_price",
        "fn_description": "Predicts the future price of a credit token by analyzing past price data and market trends.",
        "args": [
          {
            "name": "token_symbol",
            "description": "Symbol of the token for which to predict the price",
            "type": "string"
          },
          {
            "name": "timeframe",
            "description": "Period for which to predict (e.g., 1 day, 1 week, 1 month)",
            "type": "string"
          }
        ],
      "config": {
        "method": "post", 
        "url": "<https://api.example.com/predict>", 
        "headers": {
          "Authorization": "Bearer your_api_key"
        },
        "payload": {
          "model": "price_prediction_model",
          "data": {
              "token_symbol": "{{token_symbol}}",
              "timeframe": "{{timeframe}}"
            }
        },
        "success_feedback": "Predicted Price: {{#response.prediction}} {{value}} {{/response.prediction}}",
        "error_feedback": "Price prediction error"
      }
    }
    ```
