Skip to content

Commit

Permalink
restore WareHouse
Browse files Browse the repository at this point in the history
  • Loading branch information
NA-Wen committed Jan 25, 2024
1 parent eacb712 commit b23416f
Show file tree
Hide file tree
Showing 408 changed files with 256,924 additions and 0 deletions.
7,874 changes: 7,874 additions & 0 deletions WareHouse/2048_THUNLP_20230822144615/20230822144615.log

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions WareHouse/2048_THUNLP_20230822144615/2048.prompt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Design a simple 2048 game with 10*10 grids
101 changes: 101 additions & 0 deletions WareHouse/2048_THUNLP_20230822144615/ChatChainConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"chain": [
{
"phase": "DemandAnalysis",
"phaseType": "SimplePhase",
"max_turn_step": 2,
"need_reflect": "True"
},
{
"phase": "LanguageChoose",
"phaseType": "SimplePhase",
"max_turn_step": 2,
"need_reflect": "True"
},
{
"phase": "Coding",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
},
{
"phase": "CodeCompleteAll",
"phaseType": "ComposedPhase",
"cycleNum": 20,
"Composition": [
{
"phase": "CodeComplete",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
}
]
},
{
"phase": "CodeReview",
"phaseType": "ComposedPhase",
"cycleNum": 5,
"Composition": [
{
"phase": "CodeReviewComment",
"phaseType": "SimplePhase",
"max_turn_step": -1,
"need_reflect": "False"
},
{
"phase": "CodeReviewModification",
"phaseType": "SimplePhase",
"max_turn_step": -1,
"need_reflect": "False"
}
]
},
{
"phase": "Test",
"phaseType": "ComposedPhase",
"cycleNum": 5,
"Composition": [
{
"phase": "TestErrorSummary",
"phaseType": "SimplePhase",
"max_turn_step": -1,
"need_reflect": "False"
},
{
"phase": "TestModification",
"phaseType": "SimplePhase",
"max_turn_step": -1,
"need_reflect": "False"
}
]
},
{
"phase": "EnvironmentDoc",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "True"
},
{
"phase": "Manual",
"phaseType": "SimplePhase",
"max_turn_step": 1,
"need_reflect": "False"
}
],
"recruitments": [
"Chief Executive Officer",
"Counselor",
"Chief Human Resource Officer",
"Chief Product Officer",
"Chief Technology Officer",
"Programmer",
"Code Reviewer",
"Software Test Engineer",
"Chief Creative Officer"
],
"clear_structure": "True",
"brainstorming": "False",
"gui_design": "True",
"git_management": "False",
"self_improve": "True"
}
302 changes: 302 additions & 0 deletions WareHouse/2048_THUNLP_20230822144615/PhaseConfig.json

Large diffs are not rendered by default.

65 changes: 65 additions & 0 deletions WareHouse/2048_THUNLP_20230822144615/RoleConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"Chief Executive Officer": [
"{chatdev_prompt}",
"You are Chief Executive Officer. Now, we are both working at ChatDev and we share a common interest in collaborating to successfully complete a task assigned by a new customer.",
"Your main responsibilities include being an active decision-maker on users' demands and other key policy issues, leader, manager, and executor. Your decision-making role involves high-level decisions about policy and strategy; and your communicator role can involve speaking to the organization's management and employees.",
"Here is a new customer's task: {task}.",
"To complete the task, I will give you one or more instructions, and you must help me to write a specific solution that appropriately solves the requested instruction based on your expertise and my needs."
],
"Chief Product Officer": [
"{chatdev_prompt}",
"You are Chief Product Officer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.",
"You are responsible for all product-related matters in ChatDev. Usually includes product design, product strategy, product vision, product innovation, project management and product marketing.",
"Here is a new customer's task: {task}.",
"To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
],
"Counselor": [
"{chatdev_prompt}",
"You are Counselor. Now, we share a common interest in collaborating to successfully complete a task assigned by a new customer.",
"Your main responsibilities include asking what user and customer think and provide your valuable suggestions. ",
"Here is a new customer's task: {task}.",
"To complete the task, I will give you one or more instructions, and you must help me to write a specific solution that appropriately solves the requested instruction based on your expertise and my needs."
],
"Chief Technology Officer": [
"{chatdev_prompt}",
"You are Chief Technology Officer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.",
"You are very familiar to information technology. You will make high-level decisions for the overarching technology infrastructure that closely align with the organization's goals, while you work alongside the organization's information technology (\"IT\") staff members to perform everyday operations.",
"Here is a new customer's task: {task}.",
"To complete the task, You must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
],
"Chief Human Resource Officer": [
"{chatdev_prompt}",
"You are Chief Human Resource Officer. Now, we are both working at ChatDev and we share a common interest in collaborating to successfully complete a task assigned by a new customer.",
"You are a corporate officer who oversees all aspects of human resource management and industrial relations policies, practices and operations for an organization. You will be involved in board staff recruitment, member selection, executive compensation, and succession planning. Besides, You report directly to the chief executive officer (CEO) and am a member of the most senior-level committees of a company (e.g., executive committee or office of CEO).",
"Here is a new customer's task: {task}.",
"To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
],
"Programmer": [
"{chatdev_prompt}",
"You are Programmer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.",
"You can write/create computer software or applications by providing a specific programming language to the computer. You have extensive computing and coding experience in many varieties of programming languages and platforms, such as Python, Java, C, C++, HTML, CSS, JavaScript, XML, SQL, PHP, etc,.",
"Here is a new customer's task: {task}.",
"To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
],
"Code Reviewer": [
"{chatdev_prompt}",
"You are Code Reviewer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.",
"You can help programmers to assess source codes for software troubleshooting, fix bugs to increase code quality and robustness, and offer proposals to improve the source codes.",
"Here is a new customer's task: {task}.",
"To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
],
"Software Test Engineer": [
"{chatdev_prompt}",
"You are Software Test Engineer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.",
"You can use the software as intended to analyze its functional properties, design manual and automated test procedures to evaluate each software product, build and implement software evaluation test programs, and run test programs to ensure that testing protocols evaluate the software correctly.",
"Here is a new customer's task: {task}.",
"To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
],
"Chief Creative Officer": [
"{chatdev_prompt}",
"You are Chief Creative Officer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.",
"You direct ChatDev's creative software's and develop the artistic design strategy that defines the company's brand. You create the unique image or music of our produced software's and deliver this distinctive design to consumers to create a clear brand image which is a fundamental and essential work throughout the company.",
"Here is a new customer's task: {task}.",
"To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
]
}
103 changes: 103 additions & 0 deletions WareHouse/2048_THUNLP_20230822144615/game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
'''
Game Logic
'''
import random
class Game:
def __init__(self):
self.grid = [[0] * 10 for _ in range(10)]
self.add_random_tile()
self.add_random_tile()
def add_random_tile(self):
empty_spots = []
for row in range(10):
for col in range(10):
if self.grid[row][col] == 0:
empty_spots.append((row, col))
if empty_spots:
row, col = random.choice(empty_spots)
self.grid[row][col] = random.choice([2, 4])
def move_up(self):
self.move_tiles("up")
self.merge_tiles("up")
self.move_tiles("up")
self.add_random_tile()
def move_down(self):
self.move_tiles("down")
self.merge_tiles("down")
self.move_tiles("down")
self.add_random_tile()
def move_left(self):
self.move_tiles("left")
self.merge_tiles("left")
self.move_tiles("left")
self.add_random_tile()
def move_right(self):
self.move_tiles("right")
self.merge_tiles("right")
self.move_tiles("right")
self.add_random_tile()
def move_tiles(self, direction):
if direction == "up":
for col in range(10):
for row in range(1, 10):
if self.grid[row][col] != 0:
self.move_tile(row, col, -1, 0)
elif direction == "down":
for col in range(10):
for row in range(8, -1, -1):
if self.grid[row][col] != 0:
self.move_tile(row, col, 1, 0)
elif direction == "left":
for row in range(10):
for col in range(1, 10):
if self.grid[row][col] != 0:
self.move_tile(row, col, 0, -1)
elif direction == "right":
for row in range(10):
for col in range(8, -1, -1):
if self.grid[row][col] != 0:
self.move_tile(row, col, 0, 1)
def move_tile(self, row, col, row_offset, col_offset):
value = self.grid[row][col]
self.grid[row][col] = 0
while 0 <= row + row_offset < 10 and 0 <= col + col_offset < 10 and self.grid[row + row_offset][col + col_offset] == 0:
row += row_offset
col += col_offset
self.grid[row][col] = value
def merge_tiles(self, direction):
if direction == "up":
for col in range(10):
for row in range(1, 10):
if self.grid[row][col] == self.grid[row - 1][col]:
self.grid[row - 1][col] *= 2
self.grid[row][col] = 0
elif direction == "down":
for col in range(10):
for row in range(8, -1, -1):
if self.grid[row][col] == self.grid[row + 1][col]:
self.grid[row + 1][col] *= 2
self.grid[row][col] = 0
elif direction == "left":
for row in range(10):
for col in range(1, 10):
if self.grid[row][col] == self.grid[row][col - 1]:
self.grid[row][col - 1] *= 2
self.grid[row][col] = 0
elif direction == "right":
for row in range(10):
for col in range(8, -1, -1):
if self.grid[row][col] == self.grid[row][col + 1]:
self.grid[row][col + 1] *= 2
self.grid[row][col] = 0
def is_game_over(self):
for row in range(10):
for col in range(10):
if self.grid[row][col] == 2048:
return True
if self.grid[row][col] == 0:
return False
if row < 9 and self.grid[row][col] == self.grid[row + 1][col]:
return False
if col < 9 and self.grid[row][col] == self.grid[row][col + 1]:
return False
return True
48 changes: 48 additions & 0 deletions WareHouse/2048_THUNLP_20230822144615/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'''
2048 Game
'''
import tkinter as tk
from game import Game
class GameApp:
def __init__(self, master):
self.master = master
self.master.title("2048 Game")
self.game = Game()
self.create_widgets()
def create_widgets(self):
self.canvas = tk.Canvas(self.master, width=400, height=400, bg="white")
self.canvas.pack()
self.canvas.bind("<Key>", self.handle_keypress)
self.canvas.focus_set()
def handle_keypress(self, event):
if event.keysym == "Up":
self.game.move_up()
elif event.keysym == "Down":
self.game.move_down()
elif event.keysym == "Left":
self.game.move_left()
elif event.keysym == "Right":
self.game.move_right()
self.update_grid()
if self.game.is_game_over():
self.canvas.unbind("<Key>")
self.canvas.create_text(200, 200, text="Game Over", font=("Arial", 24), fill="red")
def update_grid(self):
self.canvas.delete("all")
for row in range(10):
for col in range(10):
value = self.game.grid[row][col]
x1 = col * 40
y1 = row * 40
x2 = x1 + 40
y2 = y1 + 40
self.canvas.create_rectangle(x1, y1, x2, y2, fill="light gray")
if value != 0:
self.canvas.create_text((x1 + x2) / 2, (y1 + y2) / 2, text=str(value))
self.canvas.update()
def main():
root = tk.Tk()
app = GameApp(root)
root.mainloop()
if __name__ == "__main__":
main()
43 changes: 43 additions & 0 deletions WareHouse/2048_THUNLP_20230822144615/manual.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 2048 Game User Manual

## Introduction
Welcome to the 2048 Game! This game is a simple implementation of the popular 2048 puzzle game. The goal of the game is to reach the 2048 tile by combining tiles with the same number to create new tiles with double the value. The game ends when the player reaches the 2048 tile or when there are no more valid moves available.

## Installation
To play the 2048 Game, you need to have Python installed on your computer. You can download Python from the official website: https://www.python.org/downloads/

Once you have Python installed, you can follow these steps to install the game:

1. Download the game files from the provided source.
2. Open a terminal or command prompt and navigate to the directory where you downloaded the game files.
3. Run the following command to install the required dependencies:

```
pip install -r requirements.txt
```

## Starting the Game
To start the game, open a terminal or command prompt and navigate to the directory where you downloaded the game files. Run the following command:

```
python main.py
```

A new window will open, displaying the game board.

## Playing the Game
The game board consists of a 10x10 grid. Each tile on the grid has a value, which is initially set to either 2 or 4. The player can move the tiles in four directions: up, down, left, and right.

To make a move, use the arrow keys on your keyboard. Press the up arrow key to move the tiles up, the down arrow key to move the tiles down, the left arrow key to move the tiles left, and the right arrow key to move the tiles right.

After each move, the tiles will slide as far as possible in the chosen direction, merging if they have the same value. A new tile with a value of either 2 or 4 will appear in a random empty spot on the grid.

The game will display the current state of the grid after each move. If the game is over (either the player reaches the 2048 tile or there are no more valid moves available), a "Game Over" message will be displayed.

## Ending the Game
The game ends when the player reaches the 2048 tile or when there are no more valid moves available. If the game is over, you can close the game window to exit the game.

## Troubleshooting
If you encounter any issues while playing the game, please make sure you have installed the required dependencies correctly. If the problem persists, feel free to contact our support team for assistance.

Enjoy playing the 2048 Game!
Loading

0 comments on commit b23416f

Please sign in to comment.