# Written by coPilot (GPT-5.5) in Jeff Kinne's account.

import curses

SIZE = 20  # width and height of the square


def main(stdscr):
    curses.curs_set(0)      # hide cursor
    stdscr.keypad(True)     # enable arrow keys

    # Start position
    x = SIZE // 2
    y = SIZE // 2

    while True:
        stdscr.clear()

        # Draw top and bottom borders
        for col in range(SIZE):
            stdscr.addch(0, col, '*')
            stdscr.addch(SIZE - 1, col, '*')

        # Draw left and right borders
        for row in range(SIZE):
            stdscr.addch(row, 0, '*')
            stdscr.addch(row, SIZE - 1, '*')

        # Draw the user
        stdscr.addch(y, x, 'U')

        stdscr.addstr(SIZE + 1, 0, "Use arrow keys to move, q to quit.")
        stdscr.refresh()

        key = stdscr.getch()

        if key == ord('q'):
            break
        elif key == curses.KEY_UP and y > 1:
            y -= 1
        elif key == curses.KEY_DOWN and y < SIZE - 2:
            y += 1
        elif key == curses.KEY_LEFT and x > 1:
            x -= 1
        elif key == curses.KEY_RIGHT and x < SIZE - 2:
            x += 1


curses.wrapper(main)
