up:: Game
up:: Programming
up:: Scope

自然言語でゲーム作ろう

概要

Bingにマークダウンでのドキュメント雛形作ってもらう(Bardのドキュメントは読みにくい&コピーできない)
codegen2にProcessingコードに翻訳してもらう
Processingで実行し、都度エラーをCodegenに投げ、解決してもらう

コードが完成したら、逆にドキュメントを作成してもらい、コードにしてもらうためのコツを聞く
一個前の作業と組み合わせ、エラーをBingに投げつつドキュメントを修正、もう一度Codegen2に生成してもらうというイテレーション組んだ方が治りそう。
何度か試したが、infillサンプリングがうまく動かないのでやめた。全部Bardでいく。

実践

以下がBingに作ってもらったドキュメントとBardに対する指示。

Below is the development documentation for a game called PONG. Please follow the instructions below to generate working Python pygame code. pygame version is 2.4.0. Please split the process into classes as appropriate.

# PONG Game Documentation

## Overview
PONG is a two-dimensional sports game that simulates table tennis. Each player controls a paddle in the game by moving it vertically across the left or right side of the screen. Players use their paddles to strike a ball back and forth.

## Objects

### Ball
The ball is the main object in the game. It bounces off the paddles and walls of the game screen. The ball's movement is determined by its speed and direction. The ball will also bounce off the top and bottom screen edges.

### Paddles
Each player has a paddle that they can move up and down to hit the ball. The paddle's movement is controlled by the player. The direction in which the paddle bounces the ball changes depending on where the ball hits.

### Walls
The walls are the boundaries of the game screen. The ball bounces off the walls when it hits them.

## Functions

### Move Ball
This function moves the ball across the screen based on its speed and direction.

### Move Paddle
This function moves a player's paddle up or down based on the player's input.

### Check Collision
This function checks if the ball has collided with a paddle or wall and changes its direction accordingly. If the ball collides with a paddle, its direction will change depending on where it hits.

### Update Score
This function updates the score when a player scores a point.

## How to Play

1. Two players can play the game.
2. Each player controls a paddle.
3. Players use their paddles to hit the ball back and forth.
4. The first player to score 10 points wins the game.

## Additional Information
- The version of pygame used is 2.4.0.
- The process should be split into classes as appropriate.

どうなったかというと、まあうまくいかなかった。
ボールがパドルすり抜けるし、真っ直ぐにしか弾飛ばないし。試しに使ったGPT3.5-Turboの方がPONGらしくなったレベル。
2、3回のエラーはご愛敬。

当たり前だが、ゲームはある程度は人間が可能なレベルまで落とし込みつつ、興味をひかないと意味がないわけで。
AIはその辺知らないので手加減無し、遊び無しのコードを作ってしまう。

そもそも遊びの部分はパラメータをちまちま変えながら調整することになる以上、内部処理が分かってないと作れない。けどAIに任せるとその内部処理が分からないのでガチャになる。
大半のコード生成がGitHubコードでありゲームのコードじゃないので、この辺の調整は難しいんだろう。実際にAIに面白いゲームを作らせたいなら、面白い範囲に値を制限してから作らせるのがいい。人間はこの面白い範囲を知ってるけどAIはそうじゃないんで。これを自然言語で指定するのは容易なもんじゃないが。

というか無視してたけど、ここまで詳細なドキュメント作れるなら自分で実装したほうが早いぞ。