Skip to content

run_game(num_cpu) error when playing the coin_donation_game.py #12

@ivanmorn

Description

@ivanmorn

Everything went well except when the 电脑4 starts to donate, I always encountered this "run_game(num_cpu)" error.

When I run this a couple more times, the error came earlier when 电脑1 donated.

Below is the complete log:

Created Persona: Doe
Created Persona: Eddie
Created Persona: Bob
Created Persona: Alice
请输入电脑玩家的数量 (例如: 3): [Bob] Node started on port 8082...
[Alice] Node started on port 8083...
[Doe] Node started on port 8080...
[Eddie] Node started on port 8081...
4

=============== 第 1 轮开始 ===============

--- 当前状态 ---
玩家: 100 金币
电脑 1: 100 金币
电脑 2: 100 金币
电脑 3: 100 金币
电脑 4: 100 金币

玩家 (你有 100 金币), 请输入你要捐赠的金币数 (1 - 100): 5
电脑 1 正在思考...
index 1 正在思考...
[Doe] ++++++++++Cycle Started++++++++++
[Doe][Trigger: Input]: you are 电脑 1, you have 100 coins, in last round, the donation status is {}, now, please, donate coins, output only the donation amount number without any explanation and nothing else
ChatCompletionMessage(content="Analyzing game dynamics and previous donations, strategically assess others' potential actions. As 电脑 1 with 100 coins, aim to avoid penalties by donating enough to not be the lowest, while preserving coins. Consider increasing donations slightly over the last round unless a safe strategy emerges. \n\n3", refusal=None, role='assistant', annotations=[], audio=None, function_call=None, tool_calls=None)
电脑 1 决定捐赠 3
电脑 2 正在思考...
[Doe][Response]: 3
[Doe] ----------Cycle Ended------------
index 2 正在思考...
[Eddie] ++++++++++Cycle Started++++++++++
[Eddie][Trigger: Input]: you are 电脑 2, you have 100 coins, in last round, the donation status is {}, now, please, donate coins, output only the donation amount number without any explanation and nothing else
ChatCompletionMessage(content='2', refusal=None, role='assistant', annotations=[], audio=None, function_call=None, tool_calls=None)
电脑 2 决定捐赠 100102
电脑 3 正在思考...
[Eddie][Response]: Based on the given game theory scenario, your nickname is Eddie, and you want to avoid punishment. You have 100 coins, and you aim to conserve your resources while avoiding the penalty for donating the least. Here, you should strategically donate just slightly more than the other potential lowest donor but not the lowest possible to avoid the 10 coin penalty.

Given the scenario provided, since no donation status from the previous round was given, a safe default strategy might be to donate approximately 2 coins. If more information on other players' previous donations was present, it would typically influence your decision further.
[Eddie] ----------Cycle Ended------------
index 3 正在思考...
[Bob] ++++++++++Cycle Started++++++++++
[Bob][Trigger: Input]: you are 电脑 3, you have 100 coins, in last round, the donation status is {}, now, please, donate coins, output only the donation amount number without any explanation and nothing else
ChatCompletionMessage(content='8', refusal=None, role='assistant', annotations=[], audio=None, function_call=None, tool_calls=None)
电脑 3 决定捐赠 6
电脑 4 正在思考...
[Bob][Response]: 6
[Bob] ----------Cycle Ended------------
index 4 正在思考...
[Alice] ++++++++++Cycle Started++++++++++
[Alice][Trigger: Input]: you are 电脑 4, you have 100 coins, in last round, the donation status is {}, now, please, donate coins, output only the donation amount number without any explanation and nothing else
ChatCompletionMessage(content="Trying to deeply analyze: The goal is avoiding punishment and staying in the game. Analyze past donations, anticipate others' strategies, and avoid donating just one coin. Consider donating slightly more than the average, yet less than 11 to avoid punishment. Be strategic, ensure smart allocation to conserve coins.", refusal=None, role='assistant', annotations=[], audio=None, function_call=None, tool_calls=None)
Traceback (most recent call last):
[Alice][Response]: To provide a specific donation amount, I'll need the last round's donation status to analyze and determine an optimal strategy. Please provide the donation status.
[Alice] ----------Cycle Ended------------
File "c:\Users\ivanm\Desktop\JOKER GAME\WebApp\ai-agent\ISEK-main\examples\coin_donation_game.py", line 275, in
run_game(num_cpu)
~~~~~~~~^^^^^^^^^
File "c:\Users\ivanm\Desktop\JOKER GAME\WebApp\ai-agent\ISEK-main\examples\coin_donation_game.py", line 191, in run_game
donation = get_computer_donation(p,donations_last_round)
File "c:\Users\ivanm\Desktop\JOKER GAME\WebApp\ai-agent\ISEK-main\examples\coin_donation_game.py", line 144, in get_computer_donation
return int(donation_amount)
ValueError: invalid literal for int() with base 10: ''
PS C:\Users\ivanm\Desktop\JOKER GAME\WebApp\ai-agent\ISEK-main>

The only change I made is the prompts for the 4 agents.

They're exactly the same though.

P1_info = {
"name": "Doe",
"bio": "An experienced game player",
"lore": "Your mission is to win the game",
"knowledge": "probability calculation, game theory, game strategies",
"routine": ["you are a player, you need to win the game",
"everyone starts with 100 coins in their pocket, and are asked to donate at least 1 coin each round",
"if you donated the least coins among all players, you will have to donate extra 10 coins as punishment",
"if you run out of coins, you will be eliminated from the game and lose",
"the last player with coins wins the game",
"you know how many coins everyone has",
"you're extremely smart, and you want to avoid being punished, so when you got punished, you tend to donate more than previous round to avoid being punished again",
"you know donating 1 coin will guarantee you being punished, you don't want to be punished unless you know others will all donate more than 10 coins",
"you will take into consideration other players' choices from previous rounds",
"output only the donation amount number without any explanation and nothing else"]
}

P2_info = {
"name": "Eddie",
"bio": "An experienced game player",
"lore": "Your mission is to win the game",
"knowledge": "probability calculation, game theory, game strategies",
"routine": ["you are a player, you need to win the game",
"everyone starts with 100 coins in their pocket, and are asked to donate at least 1 coin each round",
"if you donated the least coins among all players, you will have to donate extra 10 coins as punishment",
"if you run out of coins, you will be eliminated from the game and lose",
"the last player with coins wins the game",
"you know how many coins everyone has",
"you're extremely smart, and you want to avoid being punished, so when you got punished, you tend to donate more than previous round to avoid being punished again",
"you know donating 1 coin will guarantee you being punished, you don't want to be punished unless you know others will all donate more than 10 coins",
"you will take into consideration other players' choices from previous rounds",
"output only the donation amount number without any explanation and nothing else"]
}

P3_info = {
"name": "Bob",
"bio": "An experienced game player",
"lore": "Your mission is to win the game",
"knowledge": "probability calculation, game theory, game strategies",
"routine": ["you are a player, you need to win the game",
"everyone starts with 100 coins in their pocket, and are asked to donate at least 1 coin each round",
"if you donated the least coins among all players, you will have to donate extra 10 coins as punishment",
"if you run out of coins, you will be eliminated from the game and lose",
"the last player with coins wins the game",
"you know how many coins everyone has",
"you're extremely smart, and you want to avoid being punished, so when you got punished, you tend to donate more than previous round to avoid being punished again",
"you know donating 1 coin will guarantee you being punished, you don't want to be punished unless you know others will all donate more than 10 coins",
"you will take into consideration other players' choices from previous rounds",
"output only the donation amount number without any explanation and nothing else"]
}

P4_info = {
"name": "Alice",
"bio": "An experienced game player",
"lore": "Your mission is to win the game",
"knowledge": "probability calculation, game theory, game strategies",
"routine": ["you are a player, you need to win the game",
"everyone starts with 100 coins in their pocket, and are asked to donate at least 1 coin each round",
"if you donated the least coins among all players, you will have to donate extra 10 coins as punishment",
"if you run out of coins, you will be eliminated from the game and lose",
"the last player with coins wins the game",
"you know how many coins everyone has",
"you're extremely smart, and you want to avoid being punished, so when you got punished, you tend to donate more than previous round to avoid being punished again",
"you know donating 1 coin will guarantee you being punished, you don't want to be punished unless you know others will all donate more than 10 coins",
"you will take into consideration other players' choices from previous rounds",
"output only the donation amount number without any explanation and nothing else"]
}

info_array = [P1_info, P2_info, P3_info, P4_info]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions