Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] - Run Error with a SnakeGame example #47

Open
jalr4ever opened this issue Jan 24, 2024 · 0 comments
Open

[bug] - Run Error with a SnakeGame example #47

jalr4ever opened this issue Jan 24, 2024 · 0 comments

Comments

@jalr4ever
Copy link

Execution

  • gpt-4-0613
  • python main.py --mode commandline --llm_api_key sk-xxxxxxx --serpapi_key adcxxxxxxx --idea "Write a snake game"
  • version:main, commit id 3a341d054a6535f892b1541ea98558f7b082e3f2

What configurations or steps did I do wrong?

Or is this project simply not capable of generating an application at the level of Snake?

Error Log

## CurrentStep
Test the code to ensure it works as expected.

## Action
Print

## ActionInput
2024-01-24 09:05:26.450 | INFO     | autoagents.system.provider.openai_api:update_cost:95 - Total running cost: $0.709 | Max budget: $10.000 | Current cost: $0.142, prompt_tokens=928, completion_tokens=720
2024-01-24 09:05:56.482 | INFO     | autoagents.roles.group:_act:87 - Alex(Group): ready to Game_Logic_Designer_Action
To test the code, run the Python file 'snake_game.py' in a terminal. If the game starts and you can control the snake using the arrow keys, the code works as expected. If the game ends when the snake hits the border or itself, and the snake grows when it eats the food, then the game logic is correct.## Thought 
The previous steps have defined the rules and mechanics of the snake game and tested the code. The current step is to write the code for the game logic. 

## Task
[Game Logic Designer]: Design the rules and mechanics of the snake game. Write the code for the game logic. Test the code to ensure it works as expected. The output of this step should be the code for the game logic.

## CurrentStep
Write the code for the snake game logic.

## Action
Write File

## ActionInput
>>>snake_game.py
```python
import random
import curses

s = curses.initscr()
curses.curs_set(0)
sh, sw = s.getmaxyx()
w = curses.newwin(sh, sw, 0, 0)
w.keypad(1)
w.timeout(100)

snk_x = sw//4
snk_y = sh//2
snake = [
    [snk_y, snk_x],
    [snk_y, snk_x-1],
    [snk_y, snk_x-2]
]

food = [sh//2, sw//2]
w.addch(int(food[0]), int(food[1]), curses.ACS_PI)

key = curses.KEY_RIGHT

while True:
    next_key = w.getch()
    key = key if next_key == -1 else next_key

    if snake[0][0] in [0, sh] or \
        snake[0][1]  in [0, sw] or \
        snake[0] in snake[1:]:
        curses.endwin()
        quit()

    new_head = [snake[0][0], snake[0][1]]

    if key == curses.KEY_DOWN:
        new_head[0] += 1
    if key == curses.KEY_UP:
        new_head[0] -= 1
    if key == curses.KEY_LEFT:
        new_head[1] -= 1
    if key == curses.KEY_RIGHT:
        new_head[1] += 1

    snake.insert(0, new_head)

    if snake[0] == food:
        food = None
        while food is None:
            nf = [
                random.randint(1, sh-1),
                random.randint(1, sw-1)
            ]
            food = nf if nf not in snake else None
        w.addch(food[0], food[1], curses.ACS_PI)
    else:
        tail = snake.pop()
        w.addch(int(tail[0]), int(tail[1]), ' ')

    w.addch(int(snake[0][0]), int(snake[0][1]), curses.ACS_CKBOARD)

>>>END
2024-01-24 09:06:36.705 | INFO     | autoagents.system.provider.openai_api:update_cost:95 - Total running cost: $0.838 | Max budget: $10.000 | Current cost: $0.129, prompt_tokens=1022, completion_tokens=568
Traceback (most recent call last):
  File "/workspaces/AutoAgents/main.py", line 56, in <module>
    asyncio.run(commanline(proxy=proxy, llm_api_key=args.llm_api_key, serpapi_key=args.serpapi_key, idea=args.idea))
  File "/usr/local/python/3.10.13/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/python/3.10.13/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/workspaces/AutoAgents/main.py", line 30, in commanline
    await startup.startup(idea, investment, n_round, llm_api_key=llm_api_key, serpapi_key=serpapi_key, proxy=proxy)
  File "/workspaces/AutoAgents/startup.py", line 14, in startup
    await explorer.run(n_round=n_round)
  File "/workspaces/AutoAgents/autoagents/explorer.py", line 57, in run
    await self.environment.run()
  File "/workspaces/AutoAgents/autoagents/environment.py", line 203, in run
    await asyncio.gather(*futures)
  File "/workspaces/AutoAgents/autoagents/roles/role.py", line 239, in run
    rsp = await self._react()
  File "/workspaces/AutoAgents/autoagents/roles/role.py", line 209, in _react
    return await self._act()
  File "/workspaces/AutoAgents/autoagents/roles/group.py", line 91, in _act
    response = await self._rc.todo.run(context)
  File "/workspaces/AutoAgents/autoagents/actions/custom_action.py", line 142, in run
    filename = re.findall('>>>(.*?)\n', str(rsp.instruct_content.ActionInput))[0]
IndexError: list index out of range
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant