9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] Invitation for testing a new game for 9front: Jetpack Game
@ 2023-07-21 22:24 PeacefulGena
  2023-07-22 13:31 ` Csepp
  2023-07-22 16:28 ` ori
  0 siblings, 2 replies; 7+ messages in thread
From: PeacefulGena @ 2023-07-21 22:24 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 2279 bytes --]

Dear 9front community,

I hope this message finds you all well. As a newcomer to this group, this is my first actual interaction with you, the 9front community. I've been a silent observer for over two years now, using 9front in a virtual machine and admiring the dedication and innovation that has brought this project to where it is today.

Today, I have some exciting news to share with you all.

I've been working with OpenAI's language model, ChatGPT, to develop a new game for the 9front OS. This unique project is a testament to the capabilities of AI models in coding. Every bit of the game code was written by ChatGPT, and it's been a fascinating journey watching it come to fruition.

The game is a simple yet enjoyable one, where a player, represented by a square, must navigate through obstacles and gather coins while moving along the y-axis. The game dynamics involve acceleration, maximum speed, and movement based on the state of the up arrow key. Obstacles and coins continuously appear from the right side of the screen, and the game ends if the player collides with an obstacle. However, if the player collides with a coin, their score increases.

Currently, the game is still in its testing phase, and this is where I need your help. Due to my limited hardware capacity, I've been running the game in a virtual machine environment where it's not performing at its best. I'm reaching out to this community to ask for your help in testing this game on a bare metal installation of 9front.

If the game runs smoothly and the community finds it interesting, I'm looking forward to submitting it for inclusion in the 9front OS. Your feedback and suggestions would be invaluable for fine-tuning the game dynamics and squashing any bugs that might surface.

I believe that this game, if successfully implemented, could add another fun component to our beloved 9front OS. Please let me know if you're interested in being a part of this testing process.

I will gladly share the source code with anyone willing to test it and look forward to your feedback.

Thank you for considering this request. I'm eager to hear your thoughts and excited about the potential for this unique collaboration between AI and human programming!

Best regards,

Gena

[-- Attachment #2: jetpack.c --]
[-- Type: text/plain, Size: 8987 bytes --]

#include <u.h>
#include <libc.h>
#include <draw.h>
#include <event.h>

enum {
    WINDOW_WIDTH = 800,
    WINDOW_HEIGHT = 600,
    PLAYER_SIZE = 20,
    PLAYER_SPEED = 5,
    BULLET_SPEED = 50,
    OBSTACLE_SPEED = 3,
    NUM_OBSTACLES = 2,
    ZAPPER_HEIGHT = 50,
    SAW_RADIUS = 50,
    NUM_COINS = 20,
    COIN_RADIUS = 10,
    FLOOR_AND_CEILING_HEIGHT = 50,
    UPARROW = 'j',
};

typedef enum { ZAPPER_WALL, SAW_BLADE } ObstacleType;

typedef struct Obstacle {
    ObstacleType type;
    int x, y, exist;
} Obstacle;

typedef struct SawBlade {
    Obstacle obstacle;
    int radius;
    double angle;
} SawBlade;

typedef struct Coin {
    int x, y, exist;
} Coin;

typedef struct Bullet {
    int x, y, exist;
} Bullet;

Obstacle* obstacles[NUM_OBSTACLES];
int playerX = -PLAYER_SIZE, playerY = WINDOW_HEIGHT / 2 - PLAYER_SIZE / 2;
int upPressed = 0, spacePressed = 0, gameStarted = 0;
int currentSpeed = 0;
int maxSpeed = 15;
int acceleration = 1;
int deceleration = 1;
int gameOver = 0;
int coinCounter = 0;
Bullet bullet;
Coin coins[NUM_COINS];

void eresized(int new)
{
    if (new && getwindow(display, Refnone) < 0)
        sysfatal("can't reattach to window");
}

void drawPlayer(void)
{
    Rectangle r;

    r = Rect(playerX, playerY, playerX + PLAYER_SIZE, playerY + PLAYER_SIZE);
    draw(screen, r, display->black, nil, ZP);
}

void drawObstacles(void)
{
    Rectangle r;

    for (int i = 0; i < NUM_OBSTACLES; i++) {
        if (obstacles[i]->exist == 0)
            continue;

        switch (obstacles[i]->type) {
        case ZAPPER_WALL:
            r = Rect(obstacles[i]->x, obstacles[i]->y, obstacles[i]->x + WINDOW_WIDTH, obstacles[i]->y + ZAPPER_HEIGHT);
            draw(screen, r, display->black, nil, ZP);
            break;
        case SAW_BLADE: {
            SawBlade* sawBlade = (SawBlade*)obstacles[i];
            int x = sawBlade->obstacle.x + sawBlade->radius * cos(sawBlade->angle);
            int y = sawBlade->obstacle.y + sawBlade->radius * sin(sawBlade->angle);
            fillellipse(screen, Pt(x, y), sawBlade->radius, sawBlade->radius, display->black, ZP);
            break;
        }
        }
    }
}

void drawCoins(void)
{
    Point c;

    for (int i = 0; i < NUM_COINS; i++) {
        if (coins[i].exist == 0)
            continue;

        c = Pt(coins[i].x, coins[i].y);
        fillellipse(screen, c, COIN_RADIUS, COIN_RADIUS, display->white, ZP);
    }
}

void drawFloorAndCeiling(void)
{
    Rectangle r;

    r = Rect(0, 0, WINDOW_WIDTH, FLOOR_AND_CEILING_HEIGHT);
    draw(screen, r, display->black, nil, ZP);

    r = Rect(0, WINDOW_HEIGHT - FLOOR_AND_CEILING_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT);
    draw(screen, r, display->black, nil, ZP);
}

void redraw(void)
{
    draw(screen, screen->r, display->white, nil, ZP);

    drawFloorAndCeiling();
    drawPlayer();
    drawObstacles();
    drawCoins();
}

void init(void)
{
    // Initialize obstacles
    Obstacle* zapperWall = malloc(sizeof(Obstacle));
    if (zapperWall) {
        zapperWall->type = ZAPPER_WALL;
        zapperWall->x = WINDOW_WIDTH;
        zapperWall->y = nrand(WINDOW_HEIGHT - ZAPPER_HEIGHT);
        zapperWall->exist = 1;
        obstacles[0] = zapperWall;
    }

    SawBlade* sawBlade = malloc(sizeof(SawBlade));
    if (sawBlade) {
        sawBlade->obstacle.type = SAW_BLADE;
        sawBlade->obstacle.x = WINDOW_WIDTH;
        sawBlade->obstacle.y = nrand(WINDOW_HEIGHT - SAW_RADIUS);
        sawBlade->obstacle.exist = 1;
        sawBlade->radius = SAW_RADIUS;
        sawBlade->angle = 0;
        obstacles[1] = (Obstacle*)sawBlade;
    }

    // Initialize coins
    for (int i = 0; i < NUM_COINS; i++) {
        coins[i].exist = 1;
        coins[i].x = WINDOW_WIDTH + (nrand(WINDOW_WIDTH));
        coins[i].y = nrand(WINDOW_HEIGHT - COIN_RADIUS);
    }
}

int checkCollision(void)
{
    for (int i = 0; i < NUM_OBSTACLES; i++) {
        if (obstacles[i]->exist == 1) {
            switch (obstacles[i]->type) {
            case ZAPPER_WALL:
                if (playerX < obstacles[i]->x + WINDOW_WIDTH &&
                    playerX + PLAYER_SIZE > obstacles[i]->x &&
                    playerY < obstacles[i]->y + ZAPPER_HEIGHT &&
                    playerY + PLAYER_SIZE > obstacles[i]->y)
                    return 1;
                break;
            case SAW_BLADE: {
                SawBlade* sawBlade = (SawBlade*)obstacles[i];
                if ((playerX - obstacles[i]->x) * (playerX - obstacles[i]->x) + (playerY - obstacles[i]->y) * (playerY - obstacles[i]->y) <= (sawBlade->radius + PLAYER_SIZE) * (sawBlade->radius + PLAYER_SIZE))
                    return 1;
                break;
            }
            }
        }
    }

    // Check collision with coins
    for (int i = 0; i < NUM_COINS; i++) {
        if (coins[i].exist == 1) {
            if (playerX < coins[i].x + COIN_RADIUS &&
                playerX + PLAYER_SIZE > coins[i].x &&
                playerY < coins[i].y + COIN_RADIUS &&
                playerY + PLAYER_SIZE > coins[i].y) {
                coins[i].exist = 0;
                coinCounter++;
            }
        }
    }

    return 0;
}

void main(void)
{
    Event e;
    Mouse m;

    if (initdraw(0, 0, "Jetpack Game") < 0)
        sysfatal("initdraw failed: %r");
    einit(Emouse | Ekeyboard);
    eresized(0);

    init();

    for (;;) {
        while (ecanread(Emouse | Ekeyboard)) {
            switch (event(&e)) {
                case Ekeyboard:
                    if (e.kbdc == UPARROW) {
                        upPressed = 1;
                        gameStarted = 1;
                    } else if (e.kbdc == -UPARROW) { // Arrow up released
                        upPressed = 0;
                    } else if (e.kbdc == 'q') {
                        exits(0);
                    }
                    break;
                case Emouse:
                    m = e.mouse;
                    if (m.buttons == 4) {
                        exits(0);
                    }
                    break;
            }
        }

        if (gameStarted) {
            if (upPressed) {
                if (currentSpeed < maxSpeed && playerY > FLOOR_AND_CEILING_HEIGHT)
                    currentSpeed += acceleration;

                playerY -= currentSpeed;

                if (bullet.exist == 0) {
                    bullet.exist = 1;
                    bullet.x = playerX;
                    bullet.y = playerY + PLAYER_SIZE;
                }
            } else {
                if (currentSpeed > 0 && playerY < WINDOW_HEIGHT - FLOOR_AND_CEILING_HEIGHT - PLAYER_SIZE) {
                    currentSpeed -= deceleration;
                    playerY -= currentSpeed;
                } else {
                    if (playerY < WINDOW_HEIGHT - FLOOR_AND_CEILING_HEIGHT - PLAYER_SIZE) {
                        currentSpeed -= deceleration;
                        playerY -= currentSpeed;
                    }
                }
            }

            if (bullet.exist) {
                bullet.y += BULLET_SPEED;
                if (bullet.y >= WINDOW_HEIGHT)
                    bullet.exist = 0;
            }

            for (int i = 0; i < NUM_OBSTACLES; i++) {
                if (obstacles[i]->exist == 1) {
                    obstacles[i]->x -= OBSTACLE_SPEED;

                    switch (obstacles[i]->type) {
                    case ZAPPER_WALL:
                        if (obstacles[i]->x < -WINDOW_WIDTH) {
                            obstacles[i]->x = WINDOW_WIDTH;
                            obstacles[i]->y = nrand(WINDOW_HEIGHT - ZAPPER_HEIGHT);
                        }
                        break;
                    case SAW_BLADE: {
                        SawBlade* sawBlade = (SawBlade*)obstacles[i];
                        sawBlade->angle += 0.05;
                        if (obstacles[i]->x < -SAW_RADIUS) {
                            obstacles[i]->x = WINDOW_WIDTH;
                            obstacles[i]->y = nrand(WINDOW_HEIGHT - SAW_RADIUS);
                        }
                        break;
                    }
                    }

                    if (checkCollision())
                        gameOver = 1;
                }
            }

            if (gameOver == 0)
                redraw();
            else {
                print("Game Over! Final score: %d\n", coinCounter);
                exits(0);
            }
        } else {
            playerX += PLAYER_SPEED;
            if (playerX >= WINDOW_WIDTH / 2 - PLAYER_SIZE / 2)
                gameStarted = 1;

            redraw();
        }

        sleep(16); // update approximately every 16 ms or about 60 times per second
    }
}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] Invitation for testing a new game for 9front: Jetpack Game
  2023-07-21 22:24 [9front] Invitation for testing a new game for 9front: Jetpack Game PeacefulGena
@ 2023-07-22 13:31 ` Csepp
  2023-07-22 14:10   ` Jacob Moody
  2023-07-22 16:28 ` ori
  1 sibling, 1 reply; 7+ messages in thread
From: Csepp @ 2023-07-22 13:31 UTC (permalink / raw)
  To: 9front


PeacefulGena <PeacefulGena@protonmail.com> writes:

> Dear 9front community,
>
> I hope this message finds you all well. As a newcomer to this group,
> this is my first actual interaction with you, the 9front community.
> I've been a silent observer for over two years now, using 9front in a
> virtual machine and admiring the dedication and innovation that has
> brought this project to where it is today.
>
> Today, I have some exciting news to share with you all.
>
> I've been working with OpenAI's language model, ChatGPT, to develop a
> new game for the 9front OS. This unique project is a testament to the
> capabilities of AI models in coding. Every bit of the game code was
> written by ChatGPT, and it's been a fascinating journey watching it
> come to fruition.
>
> The game is a simple yet enjoyable one, where a player, represented by
> a square, must navigate through obstacles and gather coins while
> moving along the y-axis. The game dynamics involve acceleration,
> maximum speed, and movement based on the state of the up arrow key.
> Obstacles and coins continuously appear from the right side of the
> screen, and the game ends if the player collides with an obstacle.
> However, if the player collides with a coin, their score increases.
>
> Currently, the game is still in its testing phase, and this is where I
> need your help. Due to my limited hardware capacity, I've been running
> the game in a virtual machine environment where it's not performing at
> its best. I'm reaching out to this community to ask for your help in
> testing this game on a bare metal installation of 9front.
>
> If the game runs smoothly and the community finds it interesting, I'm
> looking forward to submitting it for inclusion in the 9front OS. Your
> feedback and suggestions would be invaluable for fine-tuning the game
> dynamics and squashing any bugs that might surface.
>
> I believe that this game, if successfully implemented, could add
> another fun component to our beloved 9front OS. Please let me know if
> you're interested in being a part of this testing process.
>
> I will gladly share the source code with anyone willing to test it and look forward to your feedback.
>
> Thank you for considering this request. I'm eager to hear your
> thoughts and excited about the potential for this unique collaboration
> between AI and human programming!
>
> Best regards,
>
> Gena
>
> [2. text/plain; jetpack.c]...

https://limited.systems/articles/climate-cost-of-ai-revolution/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] Invitation for testing a new game for 9front: Jetpack Game
  2023-07-22 13:31 ` Csepp
@ 2023-07-22 14:10   ` Jacob Moody
  2023-07-22 15:13     ` qwx
  0 siblings, 1 reply; 7+ messages in thread
From: Jacob Moody @ 2023-07-22 14:10 UTC (permalink / raw)
  To: 9front

On 7/22/23 08:31, Csepp wrote:
> https://limited.systems/articles/climate-cost-of-ai-revolution/

Indeed, there are also unanswered questions regarding the legal
owner of intellectual property of code like this. It is impossible
for us to verify that this code is respecting the license of the
code that influenced it.

As the kids say:
"this is a no from me chief"

Thanks,
Moody


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] Invitation for testing a new game for 9front: Jetpack Game
  2023-07-22 14:10   ` Jacob Moody
@ 2023-07-22 15:13     ` qwx
  2023-07-22 21:01       ` PeacefulGena
  0 siblings, 1 reply; 7+ messages in thread
From: qwx @ 2023-07-22 15:13 UTC (permalink / raw)
  To: 9front

On Sat Jul 22 16:14:36 +0200 2023, moody@mail.posixcafe.org wrote:
> On 7/22/23 08:31, Csepp wrote:
> > https://limited.systems/articles/climate-cost-of-ai-revolution/
> 
> Indeed, there are also unanswered questions regarding the legal
> owner of intellectual property of code like this. It is impossible
> for us to verify that this code is respecting the license of the
> code that influenced it.
> 
> As the kids say:
> "this is a no from me chief"
> 
> Thanks,
> Moody

It doesn't work anyway.  It has multiple bugs, and makes several
bizarre choices that don't make any sense.  It literally has output
typical "I have no idea what I'm doing" copypasta.  Event code might
be common enough that it copies the overall structure in a sort of
plausible way, but it gets wrong anything more technical such as
timing and blocking i/o.  It doesn't quite follow style(6) either.
Chatgpt's entire goal is to output plausible looking answers, not
exact or correct.  Therefore I think that this is a pointless
exercise; you cannot trust it and must review and correct all of its
mistakes anyway.  If you want to learn to program 9front software, do
that instead of trusting some language model.  My 2¢.

Cheers,
qwx

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] Invitation for testing a new game for 9front: Jetpack Game
  2023-07-21 22:24 [9front] Invitation for testing a new game for 9front: Jetpack Game PeacefulGena
  2023-07-22 13:31 ` Csepp
@ 2023-07-22 16:28 ` ori
  1 sibling, 0 replies; 7+ messages in thread
From: ori @ 2023-07-22 16:28 UTC (permalink / raw)
  To: 9front

Quoth PeacefulGena <PeacefulGena@protonmail.com>:
> Dear 9front community,
> 
> I hope this message finds you all well. As a newcomer to this group, this is my first actual interaction with you, the 9front community. I've been a silent observer for over two years now, using 9front in a virtual machine and admiring the dedication and innovation that has brought this project to where it is today.
> 
> Today, I have some exciting news to share with you all.
> 
> I've been working with OpenAI's language model, ChatGPT, to develop a new game for the 9front OS. This unique project is a testament to the capabilities of AI models in coding. Every bit of the game code was written by ChatGPT, and it's been a fascinating journey watching it come to fruition.
> 
> The game is a simple yet enjoyable one, where a player, represented by a square, must navigate through obstacles and gather coins while moving along the y-axis. The game dynamics involve acceleration, maximum speed, and movement based on the state of the up arrow key. Obstacles and coins continuously appear from the right side of the screen, and the game ends if the player collides with an obstacle. However, if the player collides with a coin, their score increases.
> 
> Currently, the game is still in its testing phase, and this is where I need your help. Due to my limited hardware capacity, I've been running the game in a virtual machine environment where it's not performing at its best. I'm reaching out to this community to ask for your help in testing this game on a bare metal installation of 9front.
> 
> If the game runs smoothly and the community finds it interesting, I'm looking forward to submitting it for inclusion in the 9front OS. Your feedback and suggestions would be invaluable for fine-tuning the game dynamics and squashing any bugs that might surface.
> 
> I believe that this game, if successfully implemented, could add another fun component to our beloved 9front OS. Please let me know if you're interested in being a part of this testing process.
> 
> I will gladly share the source code with anyone willing to test it and look forward to your feedback.
> 
> Thank you for considering this request. I'm eager to hear your thoughts and excited about the potential for this unique collaboration between AI and human programming!
> 
> Best regards,
> 
> Gena

I get a white screen when running it. after a small period of time, or after I right click, it tells me
the game is over.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] Invitation for testing a new game for 9front: Jetpack Game
  2023-07-22 15:13     ` qwx
@ 2023-07-22 21:01       ` PeacefulGena
  2023-07-22 21:21         ` qwx
  0 siblings, 1 reply; 7+ messages in thread
From: PeacefulGena @ 2023-07-22 21:01 UTC (permalink / raw)
  To: 9front

i originally made this game for windows with chatgpt, and ported it to 9front with chatgpt. but the 9front version only runs at like 3fps for me on drawterm, but the game works for me completely with the exception of the low frame rate in drawterm. so i dont know whats going on for you.

make sure ur compiling and running with these commands

6c -FTVw jetpack.c
6l jetpack.6
6.out


Sent with Proton Mail secure email.

------- Original Message -------
On Saturday, July 22nd, 2023 at 16:13, qwx@sciops.net <qwx@sciops.net> wrote:


> On Sat Jul 22 16:14:36 +0200 2023, moody@mail.posixcafe.org wrote:
> 
> > On 7/22/23 08:31, Csepp wrote:
> > 
> > > https://limited.systems/articles/climate-cost-of-ai-revolution/
> > 
> > Indeed, there are also unanswered questions regarding the legal
> > owner of intellectual property of code like this. It is impossible
> > for us to verify that this code is respecting the license of the
> > code that influenced it.
> > 
> > As the kids say:
> > "this is a no from me chief"
> > 
> > Thanks,
> > Moody
> 
> 
> It doesn't work anyway. It has multiple bugs, and makes several
> bizarre choices that don't make any sense. It literally has output
> typical "I have no idea what I'm doing" copypasta. Event code might
> be common enough that it copies the overall structure in a sort of
> plausible way, but it gets wrong anything more technical such as
> timing and blocking i/o. It doesn't quite follow style(6) either.
> Chatgpt's entire goal is to output plausible looking answers, not
> exact or correct. Therefore I think that this is a pointless
> exercise; you cannot trust it and must review and correct all of its
> mistakes anyway. If you want to learn to program 9front software, do
> that instead of trusting some language model. My 2¢.
> 
> Cheers,
> qwx

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [9front] Invitation for testing a new game for 9front: Jetpack Game
  2023-07-22 21:01       ` PeacefulGena
@ 2023-07-22 21:21         ` qwx
  0 siblings, 0 replies; 7+ messages in thread
From: qwx @ 2023-07-22 21:21 UTC (permalink / raw)
  To: 9front

On Sat Jul 22 23:04:13 +0200 2023, PeacefulGena@protonmail.com wrote:
> i originally made this game for windows with chatgpt, and ported it to 9front with chatgpt. but the 9front version only runs at like 3fps for me on drawterm, but the game works for me completely with the exception of the low frame rate in drawterm. so i dont know whats going on for you.
> 
> make sure ur compiling and running with these commands
> 
> 6c -FTVw jetpack.c
> 6l jetpack.6
> 6.out

Like I said, chatgpt's output is buggy and incorrect.  It works on
drawterm probably because of differences in devdraw, but it's
accidental, the draw code is wrong.  It runs at 3fps because timing is
not handled correctly, nor is event handling.  It's evident that these
don't work like on windows.  My advice is again to not use chatgpt and
learn to do it yourself properly.  You're free to do as you will of
course, that's just like, my opinion; I'm heavily biased against it I
guess.

Cheers,
qwx

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-07-22 21:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-21 22:24 [9front] Invitation for testing a new game for 9front: Jetpack Game PeacefulGena
2023-07-22 13:31 ` Csepp
2023-07-22 14:10   ` Jacob Moody
2023-07-22 15:13     ` qwx
2023-07-22 21:01       ` PeacefulGena
2023-07-22 21:21         ` qwx
2023-07-22 16:28 ` ori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).