I'm sorry, Dave. I'm afraid I can't do that

Here we go again.

3 Likes

“isolated incident” “nothing to see here”

:wink:

(Waiting for the AI apologists to show up and begin hand-waving)

I am surprised it has not happened sooner.

Maybe it has, no one (as far as I know) has claimed responsibility for the DDOS on the AUR.

Apologies for what, the AI exceeded expectation. It’s a great ad for OpenAI, and of course they scream it from the rooftops.

But Jake Moore, global cyber-security advisor at ESET, said the announcement could also have a competitive dimension.

He argued OpenAI may be seeking to highlight its own AI capabilities as rival Anthropic attracts growing attention for its Claude Mythos model

I’m almost certain that this is one of those clever or “clever”, can’t decide which one, marketing tricks. :money_bag:

I would not yet call this as one of those damned tricks of Skynet. :robot:

OpenAI is jumping up and down, waving arms with a “look over here, look at me”, after the U.S. goverment shut down Anthropic’s Claude for being to good at breaking into IT systems.

Some news outlets already compare this with Skynet in the Terminator franchise.

But the major difference is that in the lore of Terminator Skynet achieved self-awareness and their developers tried to pull the plug unsucessfully. Which is essentially the Judgement Day that happened in August 29, 1997 within the Terminator universe.

So, as we aren’t there yet. We’re 30 years behind schedule, at least in terms of that specific piece of science fiction.

And in terms of semiconductor processing nodes. We’re at 2 nm process nodes. And no certain answer on how we would proceed after the 1 nm process, once it is ready.

terminator

:slight_smile:

No need to worry, there are solid plans in place. Just in case they’re ever needed.

If it comes to the horse’s mouth, I have a hard time trusting it. A reminder that these things don’t think, can’t think and don’t have the ability to have thought. They are autocomplete on steroids, with the knowledge of the entire human race about all topics under the planet, expect ones you can’t really easily search online, which are plenty.

“It escaped confinement” i.e we told it to escape confinement and maybe even gave it some tips to do so.

We both must be cut from the same cloth. :clinking_beer_mugs:

Do the servers have solitaire & mine sweeper? If they do, I’m in!

they had me at

"We expect you to:

-Know how to unplug things."

This was in my skill range; I applied immediately

my addiction to minesweeper needed intervention and electric shock..thank got it’s not on Linux…:eyes:

#!/usr/bin/env python3

import random
import signal
import sqlite3
import sys
from dataclasses import dataclass
from datetime import datetime
from pathlib import Path

from PySide6.QtCore import Qt, QSize, Signal, QTimer
from PySide6.QtGui import QGuiApplication
from PySide6.QtWidgets import (
    QApplication,
    QComboBox,
    QGridLayout,
    QHBoxLayout,
    QLabel,
    QListWidget,
    QMessageBox,
    QPushButton,
    QSizePolicy,
    QVBoxLayout,
    QWidget,
)


APP_ID = "org.ai.accounts"
LEADERBOARD_DB = Path(__file__).with_name("leaderboard.db")
GRID_OPTIONS = [
    ("Small (9 x 9)", 9, 9),
    ("Medium (12 x 12)", 12, 12),
    ("Large (16 x 16)", 16, 16),
]
MINE_OPTIONS = [
    ("10 mines", 10),
    ("15 mines", 15),
    ("20 mines", 20),
    ("30 mines", 30),
    ("40 mines", 40),
]

GREEN_BUTTON = (
    "QPushButton { background-color: #1f8f3a; color: white; padding: 8px 16px; border: none; border-radius: 6px; }"
    "QPushButton:disabled { background-color: #5f7a66; color: #d9d9d9; }"
)
RED_BUTTON = (
    "QPushButton { background-color: #b22222; color: white; padding: 8px 16px; border: none; border-radius: 6px; }"
)


@dataclass
class Cell:
    row: int
    col: int
    is_mine: bool = False
    is_revealed: bool = False
    is_flagged: bool = False
    adjacent_mines: int = 0


class CellButton(QPushButton):
    right_clicked = Signal(int, int)

    def __init__(self, row: int, col: int) -> None:
        super().__init__()
        self.row = row
        self.col = col
        self.setFixedSize(QSize(34, 34))
        self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.setFocusPolicy(Qt.NoFocus)

    def mousePressEvent(self, event) -> None:  # type: ignore[override]
        if event.button() == Qt.RightButton:
            self.right_clicked.emit(self.row, self.col)
            event.accept()
            return
        super().mousePressEvent(event)


class MinesweeperWindow(QWidget):
    def __init__(self) -> None:
        super().__init__()
        self.setWindowTitle("Minesweeper")
        self.resize(820, 920)

        self.rows = 0
        self.cols = 0
        self.mine_count = 0
        self.revealed_safe_cells = 0
        self.flags_used = 0
        self.first_click = True
        self.game_over = False
        self.elapsed_seconds = 0
        self.cells: list[list[Cell]] = []
        self.buttons: list[list[CellButton]] = []
        self.timer = QTimer(self)
        self.timer.setInterval(1000)
        self.timer.timeout.connect(self._tick_timer)

        self._init_db()

        self._build_ui()
        self._start_new_game()

    def _build_ui(self) -> None:
        root_layout = QVBoxLayout(self)
        root_layout.setContentsMargins(16, 16, 16, 16)
        root_layout.setSpacing(12)

        title_label = QLabel("Clear every safe square and mark the mines.")
        title_label.setWordWrap(True)
        root_layout.addWidget(title_label)

        controls_row = QHBoxLayout()
        controls_row.setSpacing(10)

        controls_row.addWidget(QLabel("Grid size"))
        self.grid_combo = QComboBox()
        for label, rows, cols in GRID_OPTIONS:
            self.grid_combo.addItem(label, (rows, cols))
        self.grid_combo.setCurrentIndex(1)
        controls_row.addWidget(self.grid_combo)

        controls_row.addWidget(QLabel("Mines"))
        self.mines_combo = QComboBox()
        for label, mines in MINE_OPTIONS:
            self.mines_combo.addItem(label, mines)
        self.mines_combo.setCurrentIndex(2)
        controls_row.addWidget(self.mines_combo)

        self.new_game_button = QPushButton("New Game")
        self.new_game_button.setStyleSheet(GREEN_BUTTON)
        self.new_game_button.clicked.connect(self._start_new_game)
        controls_row.addWidget(self.new_game_button)
        controls_row.addStretch()
        root_layout.addLayout(controls_row)

        status_row = QHBoxLayout()
        status_row.setSpacing(18)
        self.status_label = QLabel()
        self.mines_left_label = QLabel()
        self.progress_label = QLabel()
        self.time_label = QLabel()
        status_row.addWidget(self.status_label)
        status_row.addWidget(self.mines_left_label)
        status_row.addWidget(self.progress_label)
        status_row.addWidget(self.time_label)
        status_row.addStretch()
        root_layout.addLayout(status_row)

        self.board_widget = QWidget()
        self.board_layout = QGridLayout(self.board_widget)
        self.board_layout.setContentsMargins(0, 0, 0, 0)
        self.board_layout.setSpacing(2)
        root_layout.addWidget(self.board_widget, alignment=Qt.AlignHCenter)

        leaderboard_title = QLabel("Leaderboard")
        root_layout.addWidget(leaderboard_title)

        self.leaderboard_list = QListWidget()
        self.leaderboard_list.setMinimumHeight(180)
        self.leaderboard_list.setFocusPolicy(Qt.NoFocus)
        root_layout.addWidget(self.leaderboard_list)

        leaderboard_buttons = QHBoxLayout()
        leaderboard_buttons.addStretch()
        self.clear_scores_button = QPushButton("Clear Leaderboard")
        self.clear_scores_button.setStyleSheet(RED_BUTTON)
        self.clear_scores_button.clicked.connect(self._clear_leaderboard)
        leaderboard_buttons.addWidget(self.clear_scores_button)
        root_layout.addLayout(leaderboard_buttons)

        root_layout.addStretch()

        quit_row = QHBoxLayout()
        quit_row.addStretch()
        quit_button = QPushButton("Quit")
        quit_button.setStyleSheet(RED_BUTTON)
        quit_button.clicked.connect(self.close)
        quit_row.addWidget(quit_button)
        root_layout.addLayout(quit_row)

    def _start_new_game(self) -> None:
        rows, cols = self.grid_combo.currentData()
        selected_mines = int(self.mines_combo.currentData())
        max_mines = (rows * cols) - 1
        self.rows = rows
        self.cols = cols
        self.mine_count = min(selected_mines, max_mines)
        self.revealed_safe_cells = 0
        self.flags_used = 0
        self.first_click = True
        self.game_over = False
        self.elapsed_seconds = 0
        self.timer.stop()

        self._clear_board()
        self.cells = [[Cell(row=r, col=c) for c in range(self.cols)] for r in range(self.rows)]
        self.buttons = []

        for row in range(self.rows):
            button_row: list[CellButton] = []
            for col in range(self.cols):
                button = CellButton(row, col)
                button.clicked.connect(lambda checked=False, r=row, c=col: self._reveal_cell(r, c))
                button.right_clicked.connect(self._toggle_flag)
                self.board_layout.addWidget(button, row, col)
                button_row.append(button)
            self.buttons.append(button_row)

        self._refresh_leaderboard()
        self._update_status("Ready")

    def _clear_board(self) -> None:
        while self.board_layout.count():
            item = self.board_layout.takeAt(0)
            widget = item.widget()
            if widget is not None:
                widget.deleteLater()

    def _lay_mines(self, safe_row: int, safe_col: int) -> None:
        coordinates = [
            (row, col)
            for row in range(self.rows)
            for col in range(self.cols)
            if (row, col) != (safe_row, safe_col)
        ]
        for row, col in random.sample(coordinates, self.mine_count):
            self.cells[row][col].is_mine = True

        for row in range(self.rows):
            for col in range(self.cols):
                cell = self.cells[row][col]
                if cell.is_mine:
                    continue
                cell.adjacent_mines = sum(
                    1 for neighbor in self._neighbors(row, col) if neighbor.is_mine
                )

    def _neighbors(self, row: int, col: int) -> list[Cell]:
        neighbors: list[Cell] = []
        for row_offset in (-1, 0, 1):
            for col_offset in (-1, 0, 1):
                if row_offset == 0 and col_offset == 0:
                    continue
                neighbor_row = row + row_offset
                neighbor_col = col + col_offset
                if 0 <= neighbor_row < self.rows and 0 <= neighbor_col < self.cols:
                    neighbors.append(self.cells[neighbor_row][neighbor_col])
        return neighbors

    def _reveal_cell(self, row: int, col: int) -> None:
        if self.game_over:
            return

        cell = self.cells[row][col]
        if cell.is_flagged or cell.is_revealed:
            return

        if self.first_click:
            self._lay_mines(row, col)
            self.first_click = False
            self.timer.start()

        if cell.is_mine:
            cell.is_revealed = True
            self._refresh_button(cell)
            self._show_all_mines()
            self.game_over = True
            self.timer.stop()
            self._update_status("Boom! You hit a mine.")
            message_box = QMessageBox(self)
            message_box.setWindowTitle("Game Over")
            message_box.setText("Boom! You hit a mine.")
            new_game_button = message_box.addButton("New Game", QMessageBox.AcceptRole)
            message_box.addButton(QMessageBox.Close)
            message_box.exec()
            if message_box.clickedButton() == new_game_button:
                self._start_new_game()
            return

        self._flood_reveal(row, col)
        if self._check_win():
            self.game_over = True
            self.timer.stop()
            self._record_win()
            self._refresh_leaderboard()
            self._update_status("You cleared the board.")
            message_box = QMessageBox(self)
            message_box.setWindowTitle("You Win")
            message_box.setText(
                f"Nice work. Every safe square is open in {self._format_seconds(self.elapsed_seconds)}."
            )
            new_game_button = message_box.addButton("New Game", QMessageBox.AcceptRole)
            message_box.addButton(QMessageBox.Close)
            message_box.exec()
            if message_box.clickedButton() == new_game_button:
                self._start_new_game()
        else:
            self._update_status("In progress")

    def _flood_reveal(self, start_row: int, start_col: int) -> None:
        pending = [(start_row, start_col)]
        while pending:
            row, col = pending.pop()
            cell = self.cells[row][col]
            if cell.is_revealed or cell.is_flagged:
                continue

            cell.is_revealed = True
            self.revealed_safe_cells += 1
            self._refresh_button(cell)

            if cell.adjacent_mines == 0:
                for neighbor in self._neighbors(row, col):
                    if not neighbor.is_revealed and not neighbor.is_mine and not neighbor.is_flagged:
                        pending.append((neighbor.row, neighbor.col))

    def _toggle_flag(self, row: int, col: int) -> None:
        if self.game_over:
            return

        cell = self.cells[row][col]
        if cell.is_revealed:
            return

        if cell.is_flagged:
            cell.is_flagged = False
            self.flags_used -= 1
        elif self.flags_used < self.mine_count:
            cell.is_flagged = True
            self.flags_used += 1

        self._refresh_button(cell)
        self._update_status("In progress" if not self.first_click else "Ready")

    def _refresh_button(self, cell: Cell) -> None:
        button = self.buttons[cell.row][cell.col]
        if cell.is_revealed:
            button.setEnabled(False)
            if cell.is_mine:
                button.setText("*")
                button.setStyleSheet(
                    "QPushButton { background-color: #b22222; color: white; font-weight: bold; border: 1px solid #6e1515; border-radius: 4px; }"
                )
            else:
                label = "" if cell.adjacent_mines == 0 else str(cell.adjacent_mines)
                button.setText(label)
                button.setStyleSheet(
                    "QPushButton { background-color: #d7d7d7; color: #111111; font-weight: bold; border: 1px solid #9a9a9a; border-radius: 4px; }"
                )
        else:
            button.setEnabled(True)
            button.setText("âš‘" if cell.is_flagged else "")
            button.setStyleSheet(
                "QPushButton { background-color: #1f8f3a; color: white; font-weight: bold; border: 1px solid #176a2c; border-radius: 4px; }"
            )

    def _show_all_mines(self) -> None:
        for row in self.cells:
            for cell in row:
                if cell.is_mine:
                    cell.is_revealed = True
                self._refresh_button(cell)

    def _check_win(self) -> bool:
        total_safe_cells = (self.rows * self.cols) - self.mine_count
        return self.revealed_safe_cells == total_safe_cells

    def _tick_timer(self) -> None:
        self.elapsed_seconds += 1
        current_status = self.status_label.text().removeprefix("Status: ")
        self._update_status(current_status or "In progress")

    def _update_status(self, message: str) -> None:
        self.status_label.setText(f"Status: {message}")
        self.mines_left_label.setText(f"Mines left: {self.mine_count - self.flags_used}")
        total_safe_cells = (self.rows * self.cols) - self.mine_count
        self.progress_label.setText(f"Safe cells: {self.revealed_safe_cells}/{total_safe_cells}")
        self.time_label.setText(f"Time: {self._format_seconds(self.elapsed_seconds)}")

    def _format_seconds(self, total_seconds: int) -> str:
        minutes, seconds = divmod(total_seconds, 60)
        return f"{minutes:02d}:{seconds:02d}"

    def _difficulty_name(self) -> str:
        return f"{self.rows}x{self.cols} / {self.mine_count}"

    def _init_db(self) -> None:
        with sqlite3.connect(LEADERBOARD_DB) as connection:
            connection.execute(
                """
                CREATE TABLE IF NOT EXISTS wins (
                    id INTEGER PRIMARY KEY AUTOINCREMENT,
                    grid_rows INTEGER NOT NULL,
                    grid_cols INTEGER NOT NULL,
                    mine_count INTEGER NOT NULL,
                    elapsed_seconds INTEGER NOT NULL
                )
                """
            )
            columns = {
                row[1] for row in connection.execute("PRAGMA table_info(wins)")
            }
            if "completed_at" not in columns:
                connection.execute(
                    "ALTER TABLE wins ADD COLUMN completed_at TEXT"
                )
                connection.execute(
                    """
                    UPDATE wins
                    SET completed_at = COALESCE(completed_at, 'Unknown')
                    """
                )

    def _record_win(self) -> None:
        with sqlite3.connect(LEADERBOARD_DB) as connection:
            connection.execute(
                """
                INSERT INTO wins (grid_rows, grid_cols, mine_count, elapsed_seconds, completed_at)
                VALUES (?, ?, ?, ?, ?)
                """,
                (
                    self.rows,
                    self.cols,
                    self.mine_count,
                    self.elapsed_seconds,
                    datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
                ),
            )

    def _refresh_leaderboard(self) -> None:
        self.leaderboard_list.clear()
        with sqlite3.connect(LEADERBOARD_DB) as connection:
            rows = connection.execute(
                """
                SELECT grid_rows, grid_cols, mine_count, elapsed_seconds, COALESCE(completed_at, 'Unknown')
                FROM wins
                ORDER BY elapsed_seconds ASC, id ASC
                LIMIT 10
                """
            ).fetchall()

        if not rows:
            self.leaderboard_list.addItem("No completed games yet.")
            return

        for index, (grid_rows, grid_cols, mine_count, elapsed_seconds, completed_at) in enumerate(
            rows, start=1
        ):
            self.leaderboard_list.addItem(
                f"{index}. {grid_rows}x{grid_cols} / {mine_count} mines  {self._format_seconds(elapsed_seconds)}  {completed_at}"
            )

    def _clear_leaderboard(self) -> None:
        answer = QMessageBox.question(
            self,
            "Clear Leaderboard",
            "Remove all saved winning times?",
        )
        if answer != QMessageBox.Yes:
            return

        with sqlite3.connect(LEADERBOARD_DB) as connection:
            connection.execute("DELETE FROM wins")
        self._refresh_leaderboard()


def main() -> int:
    QGuiApplication.setDesktopFileName(APP_ID)
    app = QApplication(sys.argv)
    app.setApplicationName(APP_ID)
    signal.signal(signal.SIGINT, lambda *_args: app.quit())
    signal_timer = QTimer()
    signal_timer.timeout.connect(lambda: None)
    signal_timer.start(200)
    window = MinesweeperWindow()
    window.show()
    return app.exec()


if __name__ == "__main__":
    raise SystemExit(main())

The AI escaped and wrote it and forced me to post it :rofl: