2023年2月1日 星期三

OPENAI 生成式AI 協助寫的詩 很有趣的紀錄

 有個人冬天騎單車很累可是的風景很美 你可以幫忙寫首詩 來描述他的心情嗎?

好的,這是一首描述冬天騎單車的詩:


冬天的風景美麗無比

騎著單車前進的他

疲憊的身體不停顫抖

但心中充滿著冒險欲望


空氣清新,風呼呼吹過

周圍的景色不斷變化

山巒高耸,河流潺潺流

他沉浸在這份美景中


騎著單車,心情自由自在

越過長山,穿過密林

他感到自己像是天使

在這個冬天,他得到了生命的力量


他知道,即使很累

他還是想繼續前進

因為這樣的經歷,令他更加明白

生命中有多麼美麗的事物可以去探索。





tt Web

有個叫作家豪的人 他在冬天騎單車去風景美麗的山區 但是他體力崩潰 腳一直抽筋 你能寫個詩描述他的心情嗎?

好的,這是一首描述家豪在冬天騎單車的詩:


家豪騎著他的單車

前往風景美麗的山區

他充滿了活力和信心

卻不知道前面會發生什麼事


冷風刺骨,他的身體不停顫抖

他努力地推著踏板

但他的腳卻不停地抽筋

他感到沮喪和無力


他停下來,坐在單車旁

抬起頭,望著景色

他發現那裡的風景是如此美麗

令他的心情得到了安慰


他告訴自己:「不要放棄!」

他再次踩著踏板,繼續前進

他知道,雖然今天有困難

但明天會更好,會有更多的成就


家豪騎著單車,穿過風景美麗的山區

他知道自己可以做到,因為他是堅強的

他是一位勇敢的旅人,在尋找夢想的道路上前進。





tt Web

你能用後悔的心境再寫一次這首詩嗎?

!

Hmm...something seems to have gone wrong. Maybe try me again in a little bit.


好的,這是一首描述家豪後悔騎單車的詩:


家豪曾經騎著他的單車

前往風景美麗的山區

但是他的體力不足

腳卻一直抽筋


他不應該冒險去那裡

他想到了太多的因素

冷風刺骨,他的身體不停顫抖

他的心情很不好


他停下來,坐在單車旁

抬起頭,望著景色

他發現那裡的風景是如此美麗

但他卻沒有享受到


他後悔自己的決定

他想著:「我不應該這樣做!」

他現在想回去,但已經太遲了

他只能繼續前進,承受自己的選擇帶來的痛苦


家豪騎著單車,穿過風景美麗的山區

他知道自己犯了一個錯誤

他希望有一天,他能重新享受到這樣的美景

他是一位後悔的旅人,在尋找自己的過錯。





tt Web

請寫出家豪被騙去冬天騎單車的悔恨心情

好的,這是一首描述家豪被騙去騎單車並感到悔恨的詩:


家豪被騙去騎單車

冬天的風吹著他的臉

他的身體冷得像冰一樣

他想知道為什麼他在這裡


他想起了那個騙他的人

他的心充滿了悔恨和怒氣

他想到自己被騙去這裡

冰冷的風使他的身體顫抖


他想起了自己的家人

他以為他們將永遠在他身邊

但是現在他卻在這裡

冰冷的山區裡


他想起了他的朋友

他們在家裡享受著溫暖

但他卻在這裡

冰冷的山區裡


家豪感到很悔恨

他被騙去這裡

他希望能回到家

他希望他不曾被騙

他是一位悔恨的旅人

在尋找自己的家。

python for pypoker 專案 普克遊戲範例4

 class Game:

    def __init__(self, player1, player2):
        self.board = Board()
        self.player1 = player1
        self.player2 = player2
        self.current_player = player1

class Board:
    def __init__(self):
        self.board = [[' ' for j in range(3)] for i in range(3)]
       
    def display(self):
        for row in self.board:
            print("|".join(row))
           
    def update(self, row, col, symbol):
        self.board[row][col] = symbol
       
    def winner(self):
        # Check rows
        for row in self.board:
            if row[0] == row[1] == row[2] and row[0] != ' ':
                return row[0]
       
        # Check columns
        for col in range(3):
            if self.board[0][col] == self.board[1][col] == self.board[2][col] and self.board[0][col] != ' ':
                return self.board[0][col]
       
        # Check diagonals
        if self.board[0][0] == self.board[1][1] == self.board[2][2] and self.board[0][0] != ' ':
            return self.board[0][0]
        if self.board[0][2] == self.board[1][1] == self.board[2][0] and self.board[0][2] != ' ':
            return self.board[0][2]
       
        return None

class Player:
    def __init__(self, name, symbol):
        self.name = name
        self.symbol = symbol
       
    def move(self, board):
        # Get player's move
        row, col = input("Enter your move (row col): ").split()
        row, col = int(row), int(col)
       
        # Update the board
        board.update(row, col, self.symbol)

python for pypoker 專案 普克遊戲範例3

 


class Card():
    def __init__(self, suit, rank):
        self.suit = suit
        self.rank = rank
   
    def __repr__(self):
        return f"{self.rank} of {self.suit}"

class Deck():
    def __init__(self):
        suits = ["Hearts", "Diamonds", "Spades", "Clubs"]
        ranks = ["Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"]
        self.cards = [Card(suit, rank) for suit in suits for rank in ranks]
   
    def __repr__(self):
        return f"Deck of {self.count()} cards"
   
    def count(self):
        return len(self.cards)
   
    def _deal(self, count):
        count = min(count, self.count())
        return [self.cards.pop() for _ in range(count)]
   
    def deal_card(self):
        return self._deal(1)[0]
   
    def deal_hand(self, hand_size):
        return self._deal(hand_size)
   
    def shuffle(self):
        if self.count() < 52:
            raise ValueError("Only full decks can be shuffled")
       
        #self.shuffle(self.cards)
        return self

def main():
    deck = Deck()
    deck.shuffle()

    hand = deck.deal_hand(5)
    print(hand)
    hand = deck.deal_hand(5)
    print(hand)


if __name__ == '__main__':
    main()

如何 使用 JSON 定義 poker Gmae 之企劃構想

#原始發想 將一個 poker Game 相關所有  參數規範 以 JSON 定義 使狀態物件化

#針對這些物件化  Poker Game JSON 開發驅動程式 或  操作引擎

#打造 可以 相容 這些 資料物件 及 執行程式 之平台 server 

EXT::

PKGAMEJSON = {

    "pkgametype":"A001",   << 暫定 排7
    "table": {
        "cardbuffer":[[],[],[],[]],
        "waittime":20,
        "activeplay":"u1"
        "playloop":["u1","u2","u3","u4"],
        "cardsetobj":cardobj
    },
    "user":{
   
        "u1": {
            "type":"man",
            "credit":1000,
            "handcard":[0x01,0x10,0x1a,0x2b],
            "hcardshowflag":[0,1,2,1]
            "offcard":[0x18]
        },
   
        "u2": {
            "type":"AI",
            "credit":1000,
            "handcard":[0x01,0x10,0x1a,0x2b],
            "hcardshowflag":[0,1,2,1]
            "offcard":[0x18]
        },
   
        "u3": {
            "type":"AI",
            "credit":1000,
            "handcard":[0x01,0x10,0x1a,0x2b],
            "hcardshowflag":[0,1,2,1]
            "offcard":[0x18]
        },
   
        "u4": {
            "type":"AI",
            "credit":1000,
            "handcard":[0x01,0x10,0x1a,0x2b],
            "hcardshowflag":[0,1,2,1]
            "offcard":[0x18]
        }
   
    },
    "playlog":[[time,u1count,u2count,u3count,u4count,win,loos]]
}

python for pypoker 專案 普克遊戲範例2

 


#定義牌的類別:

class Card:

    def __init__(self, suit, rank):

        self.suit = suit

        self.rank = rank


#定義牌堆的類別:

import random


class Deck:

    def __init__(self):

        self.deck = []

        suits = ['Hearts', 'Diamonds', 'Spades', 'Clubs']

        ranks = ['Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 

                 'Eight', 'Nine', 'Ten', 'Jack', 'Queen', 'King', 'Ace']

        for suit in suits:

            for rank in ranks:

                card = Card(suit, rank)

                self.deck.append(card)


    def shuffle(self):

        random.shuffle(self.deck)

        

    def deal(self):

        return self.deck.pop()


#定義玩家的類別:

class Player:

    def __init__(self, name):

        self.name = name

        self.hand = []


    def add_card(self, card):

        self.hand.append(card)

        

    def show_hand(self):

        print(f"{self.name}'s hand:")

        for card in self.hand:

            print(f"{card.rank} of {card.suit}")


#在主程式中創建牌堆和玩家,並進行遊戲:

deck = Deck()

deck.shuffle()


player1 = Player("Player 1")

player2 = Player("Player 2")


for i in range(5):

    player1.add_card(deck.deal())

    player2.add_card(deck.deal())

    

player1.show_hand()

player2.show_hand()


#這只是一個非常簡單的範例,可以根據你的需求進行擴展。

python for pypoker 普克遊戲設計 範例1

 


class Card():

    def __init__(self, suit, rank):

        self.suit = suit

        self.rank = rank

    

    def __repr__(self):

        return f"{self.rank} of {self.suit}"


class Deck():

    def __init__(self):

        suits = ["Hearts", "Diamonds", "Spades", "Clubs"]

        ranks = ["Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"]

        self.cards = [Card(suit, rank) for suit in suits for rank in ranks]

    

    def __repr__(self):

        return f"Deck of {self.count()} cards"

    

    def count(self):

        return len(self.cards)

    

    def _deal(self, count):

        count = min(count, self.count())

        return [self.cards.pop() for _ in range(count)]

    

    def deal_card(self):

        return self._deal(1)[0]

    

    def deal_hand(self, hand_size):

        return self._deal(hand_size)

    

    def shuffle(self):

        if self.count() < 52:

            raise ValueError("Only full decks can be shuffled")

        

        #self.shuffle(self.cards)

        return self


def main():

    deck = Deck()

    deck.shuffle()


    hand = deck.deal_hand(5)

    print(hand)

    hand = deck.deal_hand(5)

    print(hand)



if __name__ == '__main__':

    main()

python for MYSQL CUDA 操作套件 範例

#python demo code for MySQL drive 

#使用 pymysql 套件

import pymysql

#############################################################

class Database:

    def __init__(self, host, user, password, database, charset='utf8mb4'):

        self.conn = pymysql.connect(

            host=host,

            user=user,

            password=password,

            database=database,

            charset=charset

        )

        self.cursor = self.conn.cursor()


    def insert(self, table, data):

        # Build the INSERT statement

        columns = ', '.join(data.keys())

        values = ', '.join("'" + str(value) + "'" for value in data.values())

        sql = f"INSERT INTO {table} ({columns}) VALUES ({values})"


        # Execute the INSERT statement

        self.cursor.execute(sql)

        self.conn.commit()


    def select(self, table, conditions=None):

        # Build the SELECT statement

        sql = f"SELECT * FROM {table}"

        if conditions:

            sql += " WHERE " + " AND ".join([f"{key}='{value}'" for key, value in conditions.items()])


        # Execute the SELECT statement

        self.cursor.execute(sql)

        rows = self.cursor.fetchall()


        return rows


    def update(self, table, data, conditions):

        # Build the UPDATE statement

        set_values = ', '.join([f"{key}='{value}'" for key, value in data.items()])

        where_conditions = " AND ".join([f"{key}='{value}'" for key, value in conditions.items()])

        sql = f"UPDATE {table} SET {set_values} WHERE {where_conditions}"


        # Execute the UPDATE statement

        self.cursor.execute(sql)

        self.conn.commit()


    def delete(self, table, conditions):

        # Build the DELETE statement

        where_conditions = " AND ".join([f"{key}='{value}'" for key, value in conditions.items()])

        sql = f"DELETE FROM {table} WHERE {where_conditions}"


        # Execute the DELETE statement

        self.cursor.execute(sql)

        self.conn.commit()


    def close(self):

        self.cursor.close()

        self.conn.close()


########################################################

python class 使用範例

# Create an instance of the Database class

db = Database(host='hostname', user='username', password='password', database='database_name')


# Insert data into the database

data = {

    'column1': 'value1',

    'column2': 'value2',

    'column3': 'value3'

}

db.insert('table_name', data)


# Select data from the database

rows = db.select('table_name')

for row in rows:

    print(row)


# Update data in the database

data = {

    'column2':