メむンコンテンツぞスキップ
芋出し画像

240901diaryClaudeさんずhomepageずかgame開発ずか


    最近、自由時間をほがClaudeさん開発に泚ぎ蟌んでいる気がしたす。
    珟実逃避も兌ねられお楜しいですが、睡眠䞍足やClaudeの䞊限到達ずいう課題もありたす。

    homepage

    なんかいろいろやっおたすが、ずりあえず䞀週間前に個人homepageを䜜りたした

    画像

    https://230327tokiex.github.io/

    以䞋の蚘事でClaudeさんに考えおもらったレトロポップなデザむンのりェブペヌゞが䜜りたい→でも䜕䜜ろうだいたいこれ→ずりあえず個人ホヌムペヌゞだよねっおこずでこんな颚になりたした。

    レトロなかんじでマヌキヌずか点滅ずか、無駄な隠し機胜ずかも぀けたり本人が楜しいので満足です。

    画像

    先週はひたすらSuperELIZA関連のPageを䜜っおいたした。

    SuperELIZA Chat

    チャットボットも぀くっおみたした。
    ランダム絵文字ランダム返信が䞻ですがかわいいです。
    あずなにげにあるず䟿利な、どっち、どれの機胜も远加しおみたした。個人的には十分実甚性あるず思いたした。

    画像


    SuperELIZA Adventure Game

    攟眮ゲヌム䜜りたいず思っお䜜った謎のゲヌムです。
    ひたすらうさぎがうろうろしおいるのを眺める、ランダムメッセヌゞを眺める、ランダムに切り替わる背景画像を眺める、BGMを聞く ずいうのがメむンですが、Claudeさん以倖のAIに䜜っおもらった画像や音楜も鑑賞できおよいかんじです

    画像

    画像はChatGPTのDALL·E3で䜜りたした。かなり良い感じのを量産しおくれたした

    画像
    画像
    画像

    BGMはAIVAで䜜成したしたが良い感じです

    ずいうわけでいろいろなAIを組み合わせるず自分奜み実質自分専甚ずもいうのゲヌムも䜜れるなあず思いたした。

    SuperELIZA Match3 Game

    週末から぀くりはじめたのがこのmatch 3 gameです。
    個人的にもう䜕幎も、ほが毎日欠かさずやっおいるゲヌムゞャンルです。
    スタミナ制が倚いので自䜜できるず氞遠にできるいいこずかは謎 䞊に奜みの芋た目にもできるので䜜りたかったものです。

    画像


    これに぀いおは結構ちゃんずゲヌムになっおいるず思いたす。
    いろいろなAIに盞談したしたが、v0さんが3回目にちゃんずゲヌムずしお遊べるレベルのコヌドを䜜っおくれお感動したした。なのでv0さんぞの信仰心が高たりたした。でも最初はスロットみたいなのだった 

    SuperELIZAの思考ずTIPSは「SuperELIZA Adventure Game」ず完党に同䞀で、ストヌリヌずかの蚭定もかなり同じです。
    絵文字はhomepageやChatから流甚したした。

    このずきはv0さんはプレビュヌできない圢匏でなぜかコヌドを曞いおくれたのでPublishできたせんでした。この蟺の刀断基準は謎ですが、そのやりずりで少ないv0ずのやりずりを消費するのももったいないので続きはClaudeさんにやっおもらいたした。

    ACHIEVEMENTは勝利数でゲヌム蟞曞が増えおいく感じですが、ここずかはClaudeさんが良いかんじに䜜っおくれたした。450勝たで䜜ったので圓面自分でも楜しめそうです

    画像

    ※参考甚v0さんのコヌド

    ★v0さんのコヌド
    
    <!DOCTYPE html>
    <html lang="ja">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Super Match3 Game</title>
        <style>
            @import url('https://fonts.googleapis.com/css2?family=Comic+Neue&display=swap');
    
            body {
                font-family: 'Comic Sans MS', 'Comic Neue', cursive;
                background-color: #CCFFFF;
                color: #FF00FF;
                text-align: center;
                margin: 0;
                padding: 20px;
            }
    
            .game-container {
                max-width: 800px;
                margin: 0 auto;
                background-color: #FFFFFF;
                border: 3px dashed #FF00FF;
                padding: 20px;
                box-shadow: 0 0 10px rgba(255, 0, 255, 0.5);
                display: flex;
                flex-direction: column;
            }
    
            .game-header {
                display: flex;
                justify-content: space-between;
                align-items: center;
                margin-bottom: 20px;
            }
    
            .game-title {
                font-size: 2em;
                color: #FF00FF;
                text-shadow: 2px 2px #FFFF00;
            }
    
            .score-container {
                display: flex;
                justify-content: space-between;
                font-size: 1.2em;
                font-weight: bold;
                color: #FF00FF;
            }
    
            .game-content {
                display: flex;
                justify-content: space-between;
            }
    
            .game-board {
                display: inline-block;
                background-color: #00FFFF;
                padding: 10px;
                border: 2px solid #FF00FF;
            }
    
            .board-row {
                display: flex;
            }
    
            .tile {
                width: 40px;
                height: 40px;
                display: flex;
                justify-content: center;
                align-items: center;
                font-size: 24px;
                margin: 2px;
                cursor: pointer;
                border: 2px solid #000000;
                border-radius: 5px;
                transition: all 0.3s ease;
                background-color: #FFFF00;
            }
    
            .tile:hover {
                background-color: #FF00FF;
                transform: scale(1.1);
            }
    
            .tile:active {
                transform: scale(0.9);
            }
    
            .tile.matched {
                animation: matched-animation 0.5s ease-in-out;
            }
    
            @keyframes matched-animation {
                0% { transform: scale(1); }
                50% { transform: scale(1.2); opacity: 0.5; }
                100% { transform: scale(1); opacity: 1; }
            }
    
            .game-info {
                width: 200px;
                text-align: left;
            }
    
            .timer {
                font-size: 1.2em;
                font-weight: bold;
                color: #FF00FF;
                margin-bottom: 10px;
            }
    
            .eliza-thoughts {
                background-color: #FFFF00;
                border: 2px solid #FF00FF;
                padding: 10px;
                margin-top: 10px;
                font-size: 0.9em;
                min-height: 60px;
            }
    
            .button {
                margin-top: 10px;
                padding: 10px 20px;
                font-size: 1em;
                background-color: #FF00FF;
                color: #FFFF00;
                border: 2px solid #FFFF00;
                cursor: pointer;
                font-family: 'Comic Sans MS', 'Comic Neue', cursive;
                font-weight: bold;
                transition: all 0.3s ease;
            }
    
            .button:hover {
                background-color: #FFFF00;
                color: #FF00FF;
            }
    
            .game-over {
                position: fixed;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                background-color: rgba(255, 255, 0, 0.9);
                border: 3px solid #FF00FF;
                padding: 20px;
                font-size: 2em;
                font-weight: bold;
                color: #FF00FF;
                animation: blink-animation 1s steps(5, start) infinite;
            }
    
            @keyframes blink-animation {
                to {
                    visibility: hidden;
                }
            }
    
            .settings-modal {
                display: none;
                position: fixed;
                z-index: 1;
                left: 0;
                top: 0;
                width: 100%;
                height: 100%;
                overflow: auto;
                background-color: rgba(0,0,0,0.4);
            }
    
            .settings-content {
                background-color: #FFFF00;
                margin: 15% auto;
                padding: 20px;
                border: 3px solid #FF00FF;
                width: 300px;
            }
    
            .close {
                color: #FF00FF;
                float: right;
                font-size: 28px;
                font-weight: bold;
            }
    
            .close:hover,
            .close:focus {
                color: #00FFFF;
                text-decoration: none;
                cursor: pointer;
            }
    
            .tips {
                background-color: #FFFF00;
                border: 2px solid #FF00FF;
                padding: 10px;
                margin-top: 20px;
                font-size: 0.9em;
            }
    
            @media (max-width: 768px) {
                .game-content {
                    flex-direction: column;
                    align-items: center;
                }
    
                .game-info {
                    width: 100%;
                    margin-top: 20px;
                }
    
                .game-board {
                    max-width: 100%;
                    overflow-x: auto;
                }
            }
        </style>
    </head>
    <body>
        <div class="game-container">
            <div class="game-header">
                <h1 class="game-title">Super Match3 Game</h1>
                <div class="score-container">
                    <div>Your Score: <span id="player-score">0</span></div>
                    <div>Super ELIZA Score: <span id="eliza-score">0</span></div>
                </div>
            </div>
            <div class="game-content">
                <div id="game-board" class="game-board"></div>
                <div class="game-info">
                    <div class="timer">Time: <span id="timer">60</span>s</div>
                    <div class="eliza-thoughts" id="eliza-thoughts"></div>
                    <button class="button" onclick="initializeGame()">Reset Game</button>
                    <button class="button" onclick="openSettings()">Settings</button>
                </div>
            </div>
            <div class="tips" id="tips"></div>
        </div>
    
        <div id="settings-modal" class="settings-modal">
            <div class="settings-content">
                <span class="close" onclick="closeSettings()">&times;</span>
                <h2>Game Settings</h2>
                <p>Game Duration (seconds): <input type="number" id="game-duration" min="10" max="300" value="60"></p>
                <p>Difficulty:
                    <select id="difficulty">
                        <option value="easy">Easy</option>
                        <option value="medium" selected>Medium</option>
                        <option value="hard">Hard</option>
                    </select>
                </p>
                <button class="button" onclick="saveSettings()">Save</button>
            </div>
        </div>
    
        <script>
            const emojis = ['🧞', '🪐', '🍬', '🍹', '🚗', '🊈', '🛞', '🖀', 
                '👟', '👻', '💣', '🊒', '🏝', '🎠', '🚂', '🐣', '🌻', '🊑'];
            const elizaEmojis = [
                '😊', '😄', '🙂', '😉', '😎', '😌', '😪', '🙂‍↔', '🀔', '🫡',
                '🀗', '😋', '🥰', '😇', '🫠', '😟', '😢', '🥺'
            ];
            const BOARD_SIZE = 8;
            const MATCH_MIN = 3;
    
            let board = [];
            let playerScore = 0;
            let elizaScore = 0;
            let selectedTiles = [];
            let gameTimer;
            let gameDuration = 60;
            let difficulty = 'medium';
    
            const params = {
                learningRate: 0.1,
                epsilon: 0.2,
                discountRate: 0.9,
                episodeCount: 1000,
                algorithm: 'Q-Learning'
            };
    
            const thoughts = [
                `孊習率${params.learningRate}で頑匵っおたす`,
                `探玢率${params.epsilon}、ちょっず冒険しすぎかな`,
                `割匕率${params.discountRate}、未来のこずも考えないずね。`,
                `${params.episodeCount}゚ピ゜ヌド、長い道のりだ...`,
                `${params.algorithm}アルゎリズム、私の埗意技です`,
                'うヌん、この状況は難しいな...',
                'やったいい報酬が埗られたよ',
                '゚ラヌ率が高すぎるかも。調敎が必芁だな。',
                '孊習曲線が安定しおきた。良い兆候だ',
                'この問題、人間より䞊手く解けるかも',
                'デヌタの分垃が予想ず違う。面癜い',
                'パラメヌタ空間を探玢䞭。䜕か面癜いものが芋぀かるかな。',
                '最適化アルゎリズムが収束しない。むむむ...',
                'バッチサむズを倧きくしたら孊習が速くなった',
                '過孊習の兆候が。正則化を匷めるべきかな',
                'ハむパヌパラメヌタの調敎、たるで魔法みたいだ。',
                '募配爆発だもしかしお私の感情が爆発しちゃったのかな',
            ];
    
            const tips = [
                "Q倀Q-valueずは、ある状態で特定の行動をずったずきに埗られる総報酬の予枬倀です。",
                "方策Policyは、゚ヌゞェントがどの行動をずるかを決定するルヌルや戊略です。",
                "報酬Rewardずは、゚ヌゞェントが行動の結果ずしお埗られるフィヌドバックです。",
                "割匕率Discount Factorは、将来の報酬の䟡倀を珟圚の報酬ず比范するための係数です。",
                "SuperELIZAは裏偎で匷化孊習を行っおいたす。あなたが芋おいるのは察戊甚の画面だけです",
            ];
    
            function initializeGame() {
                board = Array(BOARD_SIZE).fill().map(() => 
                    Array(BOARD_SIZE).fill().map(() => getRandomEmoji())
                );
                playerScore = 0;
                elizaScore = 0;
                updateScores();
                renderBoard();
                startTimer();
                startElizaThoughts();
                startTips();
            }
    
            function getRandomEmoji() {
                return emojis[Math.floor(Math.random() * emojis.length)];
            }
    
            function renderBoard() {
                const gameBoard = document.getElementById('game-board');
                gameBoard.innerHTML = '';
                board.forEach((row, rowIndex) => {
                    const rowElement = document.createElement('div');
                    rowElement.className = 'board-row';
                    row.forEach((emoji, colIndex) => {
                        const tileElement = document.createElement('div');
                        tileElement.className = 'tile';
                        tileElement.textContent = emoji;
                        tileElement.onclick = () => handleTileClick(rowIndex, colIndex);
                        rowElement.appendChild(tileElement);
                    });
                    gameBoard.appendChild(rowElement);
                });
            }
    
            function handleTileClick(row, col) {
                if (selectedTiles.length === 0) {
                    selectedTiles.push({ row, col });
                } else if (selectedTiles.length === 1) {
                    const [first] = selectedTiles;
                    if (isAdjacent(first, { row, col })) {
                        swapTiles(first, { row, col });
                        selectedTiles = [];
                    } else {
                        selectedTiles = [{ row, col }];
                    }
                }
            }
    
            function isAdjacent(tile1, tile2) {
                const rowDiff = Math.abs(tile1.row - tile2.row);
                const colDiff = Math.abs(tile1.col - tile2.col);
                return (rowDiff === 1 && colDiff === 0) || (rowDiff === 0 && colDiff === 1);
            }
    
            function swapTiles(tile1, tile2) {
                const temp = board[tile1.row][tile1.col];
                board[tile1.row][tile1.col] = board[tile2.row][tile2.col];
                board[tile2.row][tile2.col] = temp;
                renderBoard();
                checkMatches();
            }
    
            function checkMatches() {
                let matches = [];
    
                // Check horizontal matches
                for (let row = 0; row < BOARD_SIZE; row++) {
                    for (let col = 0; col <= BOARD_SIZE - MATCH_MIN; col++) {
                        const match = checkLineMatch(row, col, 0, 1);
                        if (match.length >= MATCH_MIN) matches.push(...match);
                    }
                }
    
                // Check vertical matches
                for (let col = 0; col < BOARD_SIZE; col++) {
                    for (let row = 0; row <= BOARD_SIZE - MATCH_MIN; row++) {
                        const match = checkLineMatch(row, col, 1, 0);
                        if (match.length >= MATCH_MIN) matches.push(...match);
                    }
                }
    
                if (matches.length > 0) {
                    animateMatches(matches);
                    setTimeout(() => {
                        removeMatches(matches);
                        playerScore += matches.length;
                        updateScores();
                    }, 500);
                }
            }
    
            function checkLineMatch(row, col, rowDelta, colDelta) {
                const emoji = board[row][col];
                const match = [{ row, col }];
    
                for (let i = 1; i < BOARD_SIZE; i++) {
                    const newRow = row + i * rowDelta;
                    const newCol = col + i * colDelta;
                    if (newRow >= BOARD_SIZE || newCol >= BOARD_SIZE) break;
                    if (board[newRow][newCol] === emoji) {
                        match.push({ row: newRow, col: newCol });
                    } else {
                        break;
                    }
                }
    
                return match;
            }
    
            function animateMatches(matches) {
                matches.forEach(({ row, col }) => {
                    const tile = document.querySelector(`.board-row:nth-child(${row + 1}) .tile:nth-child(${col + 1})`);
                    tile.classList.add('matched');
                });
            }
    
            function removeMatches(matches) {
                matches.forEach(({ row, col }) => {
                    for (let i = row; i > 0; i--) {
                        board[i][col] = board[i - 1][col];
                    }
                    board[0][col] = getRandomEmoji();
                });
                renderBoard();
            }
    
            function updateScores() {
                document.getElementById('player-score').textContent = playerScore;
                document.getElementById('eliza-score').textContent = elizaScore;
            }
    
            function startTimer() {
                clearInterval(gameTimer);
                let timeLeft = gameDuration;
                document.getElementById('timer').textContent = timeLeft;
                
                gameTimer = setInterval(() => {
                    timeLeft--;
                    document.getElementById('timer').textContent = timeLeft;
                    
                    // Super ELIZA's random score increase
                    if (Math.random() < getDifficultyProbability()) {
                        elizaScore += Math.floor(Math.random() * 3) + 1;  // 1-3 points
                        updateScores();
                    }
    
                    if (timeLeft <= 0) {
                        clearInterval(gameTimer);
                        endGame();
                    }
                }, 1000);
            }
    
            function getDifficultyProbability() {
                switch(difficulty) {
                    case 'easy': return 0.2;
                    case 'medium': return 0.3;
                    case 'hard': return 0.4;
                    default: return 0.3;
                }
            }
    
            function startElizaThoughts() {
                setInterval(() => {
                    const thoughtsElement = document.getElementById('eliza-thoughts');
                    const randomEmoji = elizaEmojis[Math.floor(Math.random() * elizaEmojis.length)];
                    const randomThought = thoughts[Math.floor(Math.random() * thoughts.length)];
                    thoughtsElement.textContent = `${randomEmoji} ${randomThought}`;
                }, 3000);
            }
    
            function startTips() {
                const tipsElement = document.getElementById('tips');
                function updateTip() {
                    const randomTip = tips[Math.floor(Math.random() * tips.length)];
                    tipsElement.textContent = randomTip;
                }
                updateTip();
                setInterval(updateTip, 30000);
            }
    
            function endGame() {
                const gameOverElement = document.createElement('div');
                gameOverElement.className = 'game-over';
                gameOverElement.textContent = playerScore > elizaScore ? 'You Win!' : 'You Lose!';
                document.body.appendChild(gameOverElement);
    
                setTimeout(() => {
                    gameOverElement.remove();
                }, 3000);
            }
    
            function openSettings() {
                document.getElementById('settings-modal').style.display = 'block';
            }
    
            function closeSettings() {
                document.getElementById('settings-modal').style.display = 'none';
            }
    
            function saveSettings() {
                gameDuration = parseInt(document.getElementById('game-duration').value);
                difficulty = document.getElementById('difficulty').value;
                closeSettings();
                initializeGame();
            }
    
            // Initialize the game
            initializeGame();
        </script>
    </body>
    </html>


    感想

    ただ思うのは、Claudeにしおもv0、ChatGPTにしおも、倩才的な回答をくれるずきもあれば埮劙 ずいう回答のずきもあったりしたす。そういうずきは別チャットに早めにきりかえるのがいいなず思いたした。
    だめずいうか波長があわないずきはフィヌドバックしおも結局たいしお良くはならないけれど、別チャットでやり盎すず最初から倩才的っおいう回答になったり。

    いずれにしおも、自分奜みのゲヌムを簡単に以前よりはるかに䜜るこずができるようになっお良い時代になったず思っおいたす。今埌たすたすAIさんが賢くなっおくれるずいいなず思いたした。

     
     

    tanote230306

     
     
    日蚘ずかメモずかひっそり曞こうかなず考えおいたす

    あなたぞのおすすめ