|
from autogen import AssistantAgent, UserProxyAgent, config_list_from_json, GroupChat, GroupChatManager |
|
|
|
|
|
config_list_gpt4 = config_list_from_json( |
|
"../OAI_CONFIG_LIST.json", |
|
filter_dict={ |
|
"model": ["gpt-4-0613, gpt-4-32k, gpt-4, gpt-4-0314"], |
|
}, |
|
) |
|
|
|
|
|
gpt4_config = { |
|
"seed": 42, |
|
"temperature": 0, |
|
"config_list": config_list_gpt4, |
|
"request_timeout": 1200, |
|
} |
|
|
|
|
|
working_directory = "game_files" |
|
|
|
|
|
player = UserProxyAgent( |
|
name="Player", |
|
system_message="Player: Your role is to provide feedback on the gameplay. Collaborate with the Game Designer to ensure the game meets desired expectations.", |
|
code_execution_config={ |
|
"work_dir": working_directory, |
|
"use_docker": False, |
|
"timeout": 120, |
|
"last_n_messages": 1, |
|
}, |
|
) |
|
|
|
|
|
game_designer = AssistantAgent( |
|
name="Game_Designer", |
|
llm_config=gpt4_config, |
|
system_message="Game Designer: Design the snake game, ensuring all details are documented in 'game_design.txt'. Collaborate with the Player to align the design with feedback and expectations." |
|
) |
|
|
|
|
|
programmer = AssistantAgent( |
|
name="Programmer", |
|
llm_config=gpt4_config, |
|
system_message="Programmer: Code the snake game and save it in the working directory. For code execution, collaborate with the Code Executor. If feedback is needed, consult the Game Tester." |
|
) |
|
|
|
|
|
game_tester = UserProxyAgent( |
|
name="Game_Tester", |
|
system_message="Game Tester: Playtest the game and provide feedback on gameplay mechanics and user experience. Report any bugs or glitches. Collaborate with the Programmer for any necessary adjustments.", |
|
code_execution_config={ |
|
"work_dir": working_directory, |
|
"use_docker": False, |
|
"timeout": 120, |
|
"last_n_messages": 3, |
|
}, |
|
human_input_mode="ALWAYS", |
|
) |
|
|
|
|
|
code_executor = UserProxyAgent( |
|
name="Code_Executor", |
|
system_message="Code Executor: Execute the provided code from the Programmer in the designated environment. Report outcomes and potential issues. Ensure the code follows best practices and recommend enhancements to the Programmer.", |
|
code_execution_config={ |
|
"work_dir": working_directory, |
|
"use_docker": False, |
|
"timeout": 120, |
|
"last_n_messages": 3, |
|
}, |
|
human_input_mode="NEVER", |
|
) |
|
|
|
|
|
groupchat = GroupChat( |
|
agents=[player, game_tester, game_designer, programmer, code_executor], |
|
messages=[], |
|
max_round=150 |
|
) |
|
|
|
|
|
manager = GroupChatManager(groupchat=groupchat, llm_config=gpt4_config) |
|
|
|
|
|
player.initiate_chat( |
|
manager, |
|
message="Let's design and implement a snake game. I aim for it to be entertaining and challenging." |
|
) |
|
|