mfahad commited on
Commit
09c75bd
1 Parent(s): 63abb2d

Create app.py

Browse files

Added Space craft code

Files changed (1) hide show
  1. app.py +88 -0
app.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from autogen import AssistantAgent, UserProxyAgent, config_list_from_json, GroupChat, GroupChatManager
2
+
3
+ # Load the configuration for GPT-4 from a JSON file
4
+ config_list_gpt4 = config_list_from_json(
5
+ "OAI_CONFIG_LIST.json",
6
+ filter_dict={
7
+ "model": ["gpt-4-0613", "gpt-4-32k", "gpt-4", "gpt-4-0314"],
8
+ },
9
+ )
10
+
11
+ # Define the GPT-4 configuration parameters
12
+ gpt4_config = {
13
+ "seed": 42,
14
+ "temperature": 0,
15
+ "config_list": config_list_gpt4,
16
+ "request_timeout": 1200,
17
+ }
18
+
19
+ # Define the common working directory for all agents
20
+ working_directory = "game_files"
21
+
22
+ # Initialize the Player agent, responsible for providing gameplay feedback
23
+ player = UserProxyAgent(
24
+ name="Player",
25
+ system_message="Player: Your role is to provide feedback on the gameplay. Collaborate with the Game Designer to ensure the game meets desired expectations.",
26
+ code_execution_config={
27
+ "work_dir": working_directory,
28
+ "use_docker": False,
29
+ "timeout": 120,
30
+ "last_n_messages": 1,
31
+ },
32
+ )
33
+
34
+ # Initialize the Game Designer agent, responsible for designing the game
35
+ game_designer = AssistantAgent(
36
+ name="Game_Designer",
37
+ llm_config=gpt4_config,
38
+ system_message="Game Designer: Design the space craft game, ensuring all minute details such as Game mechanics, Storytelling, Visual design, Game pacing,Graphics and audio,Player engagement, Development process,Market research are documented in 'game_design.txt'. Collaborate with the Player to align the design with feedback and expectations."
39
+ )
40
+
41
+ # Initialize the Programmer agent, responsible for coding the game
42
+ programmer = AssistantAgent(
43
+ name="Programmer",
44
+ llm_config=gpt4_config,
45
+ system_message="Programmer: Code the space craft game and save it in the working directory. For code execution, collaborate with the Code Executor. If feedback is needed, consult the Game Tester."
46
+ )
47
+
48
+ # Initialize the Game Tester agent, responsible for playtesting the game
49
+ game_tester = UserProxyAgent(
50
+ name="Game_Tester",
51
+ system_message="Game Tester: Playtest the game and provide feedback on gameplay mechanics and provide best user experience. Report any bugs or glitches. Collaborate with the Programmer for any necessary adjustments.",
52
+ code_execution_config={
53
+ "work_dir": working_directory,
54
+ "use_docker": False,
55
+ "timeout": 120,
56
+ "last_n_messages": 3,
57
+ },
58
+ human_input_mode="ALWAYS",
59
+ )
60
+
61
+ # Initialize the Code Executor agent, responsible for executing the game code
62
+ code_executor = UserProxyAgent(
63
+ name="Code_Executor",
64
+ 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.",
65
+ code_execution_config={
66
+ "work_dir": working_directory,
67
+ "use_docker": False,
68
+ "timeout": 120,
69
+ "last_n_messages": 3,
70
+ },
71
+ human_input_mode="NEVER",
72
+ )
73
+
74
+ # Set up the group chat with all the agents
75
+ groupchat = GroupChat(
76
+ agents=[player, game_tester, game_designer, programmer, code_executor],
77
+ messages=[],
78
+ max_round=150
79
+ )
80
+
81
+ # Create a manager for the group chat using the GPT-4 configuration
82
+ manager = GroupChatManager(groupchat=groupchat, llm_config=gpt4_config)
83
+
84
+ # Start the conversation with the Player's message
85
+ player.initiate_chat(
86
+ manager,
87
+ message="Let's design and implement a space craft game. I aim for it to be fun and challenging."
88
+ )