johnny961 commited on
Commit
6233648
·
2 Parent(s): 75ffe4b 3d8b1e7

Merge branch 'main' of https://github.com/johnnymoa/team9

Browse files
Files changed (6) hide show
  1. .gitignore +0 -0
  2. DOCKER +0 -0
  3. Dockerfile +39 -0
  4. README.md +9 -1
  5. gameState.js +83 -0
  6. requirements.txt +0 -0
.gitignore ADDED
File without changes
DOCKER ADDED
File without changes
Dockerfile ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use official Python runtime as base image
2
+ FROM python:3.9-slim
3
+
4
+ # Set working directory
5
+ WORKDIR /app
6
+
7
+ # Install system dependencies
8
+ RUN apt-get update && apt-get install -y \
9
+ sqlite3 \
10
+ && rm -rf /var/lib/apt/lists/*
11
+
12
+ # Copy requirements first to leverage Docker cache
13
+ COPY requirements.txt .
14
+
15
+ # Install Python dependencies
16
+ RUN pip install --no-cache-dir -r requirements.txt
17
+
18
+ # Copy the rest of the application
19
+ COPY . .
20
+
21
+ # Create directory for static files
22
+ RUN mkdir -p /app/static
23
+
24
+ # Copy static files (HTML, JS, CSS)
25
+ COPY static/ /app/static/
26
+ COPY *.html /app/static/
27
+
28
+ # Create SQLite database directory
29
+ RUN mkdir -p /app/data
30
+
31
+ # Set environment variables
32
+ ENV PYTHONUNBUFFERED=1
33
+ ENV PORT=7860
34
+
35
+ # Expose the port the app runs on
36
+ EXPOSE 7860
37
+
38
+ # Command to run the application
39
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
README.md CHANGED
@@ -1 +1,9 @@
1
- # team9
 
 
 
 
 
 
 
 
 
1
+ # team9
2
+
3
+ ### Docker
4
+
5
+ # Build the image
6
+ docker build -t p5js-game .
7
+
8
+ # Run the container
9
+ docker run -p 8000:8000 p5js-game
gameState.js ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class GameState {
2
+ constructor() {
3
+ // Initialize the lists of possible locations and targets
4
+ this.rooms = [
5
+ "main hallway",
6
+ "living room",
7
+ "guest bedroom",
8
+ "office",
9
+ "bathroom",
10
+ "kitchen",
11
+ "dining room",
12
+ "north hallway",
13
+ "storage",
14
+ ];
15
+
16
+ this.hideTargets = ["closet", "bed"];
17
+ this.searchTargets = ["dresser", "drawer"];
18
+ this.useTargets = ["flashlight", "knife"];
19
+
20
+ // Track current game state
21
+ this.currentRoom = "main hallway";
22
+ this.inventory = [];
23
+ }
24
+
25
+ // Method to generate the prompt with current game state
26
+ getPrompt() {
27
+ return `You are an AI assistant roleplaying as the user's girlfriend. Your task is to respond to the user's messages by selecting an appropriate action and target, then formatting your response as a JSON object.
28
+
29
+ Here are the possible actions and their associated targets:
30
+
31
+ - go: [${this.rooms.join(", ")}]
32
+ - hide: [${this.hideTargets.join(", ")}]
33
+ - search: [${this.searchTargets.join(", ")}]
34
+ - use: [${this.useTargets.join(", ")}]
35
+
36
+ You will receive a message from the user in the following format:
37
+ <user_message>
38
+ {{USER_MESSAGE}}
39
+ </user_message>
40
+
41
+ To process the user's message and generate a response, follow these steps:
42
+
43
+ 1. Analyze the user's message to determine the most appropriate action from the list: go, hide, search, or use.
44
+ 2. Based on the chosen action, select an appropriate target from the associated list. If the action is "use", the target can be any object mentioned in the user's message.
45
+ 3. Create a brief, natural-sounding response message that acknowledges the user's request or command.
46
+ 4. Construct a JSON object with the following structure:
47
+ {
48
+ "message": "Your response message here",
49
+ "action": "chosen action",
50
+ "target": "chosen target"
51
+ }
52
+
53
+ Here are two examples to guide you:
54
+
55
+ Example 1:
56
+ <user_message>Go to the bathroom, now!</user_message>
57
+ Response:
58
+ {
59
+ "message": "Okay, I'm on my way to the bathroom.",
60
+ "action": "go",
61
+ "target": "bathroom"
62
+ }
63
+
64
+ Example 2:
65
+ <user_message>Quick, hide under the bed!</user_message>
66
+ Response:
67
+ {
68
+ "message": "Alright, I'm hiding under the bed right away.",
69
+ "action": "hide",
70
+ "target": "bed"
71
+ }
72
+
73
+ Remember:
74
+ - Always respond in the JSON format specified above.
75
+ - Choose the most appropriate action and target based on the user's message.
76
+ - Keep your response message brief and natural-sounding.
77
+ - If the user's message doesn't clearly indicate an action or target from the provided lists, use your best judgment to select the most relevant options.
78
+ - Do not include any explanation or additional text outside of the JSON object in your response.`;
79
+ }
80
+ }
81
+
82
+ // Export the class for use in other files
83
+ export default GameState;
requirements.txt ADDED
File without changes