當前位置:首頁 » 操作系統 » html5撲克源碼

html5撲克源碼

發布時間: 2022-06-01 20:44:32

㈠ 24點游戲C++程序源代碼

這是個算24點的程序,很像c++的一段代碼#include <iostream>
#include <sys/timeb.h>
#include <vector>
#include <string>
#include <stdio.h>using std::vector;
using std::string;
using namespace std;class Node
{
public:
enum OpType
{
UNARY, PLUS, SUB, SUB2, MUL, DIV, DIV2
}; double& value(){ return value_; }
double value() const { return value_; } bool Add() { op_ = PLUS; value_ = left_->value_ + right_->value_; return true; }
bool Sub() { op_ = SUB; value_ = left_->value_ - right_->value_; return true; }
bool Sub2() { op_ = SUB2; value_ = right_->value_ - left_->value_; return true; }
bool Mul() { op_ = MUL; value_ = left_->value_ * right_->value_; return true; }
bool Div() { if(right_->value_==0)return false; op_ = DIV; value_ = left_->value_ / right_->value_; return true; }
bool Div2() { if(left_->value_==0)return false; op_ = DIV2; value_ = right_->value_ / left_->value_;return true; } Node( double d = 0 )
: left_(0), right_(0), op_(UNARY), value_(d)
{ }
Node( Node* l, Node *r )
: left_(l), right_(r), op_(UNARY), value_(0)
{ } string getExpr()
{
if( op_ == UNARY )
{
char buf[32];
return "";
} string str;
switch( op_ )
{
case PLUS:
case SUB:
case MUL:
case DIV:
str += "(";
str += left_->getExpr();
str += " +--*//"[op_];
str += right_->getExpr();
str += ")";
break;
case SUB2:
case DIV2:
default:
str += "(";
str += right_->getExpr();
str += " +--*//"[op_];
str += left_->getExpr();
str += ")";
}
return str;
} double value_;
OpType op_;
Node *left_;
Node *right_;
};template<unsigned int L>
bool query( double target, Node** cand, string& expr )
{
for( unsigned int k=0; k<L-1; ++k )
{
Node* newcand[L-1];
for( unsigned int j=k+1; j<L; ++j )
{
for( unsigned int i=k+1; i<j; ++i )
{
if( cand[i]->value() == cand[j]->value() )
continue;
} Node node( cand[k], cand[j] );
Node **pNode = newcand;
for( unsigned int i=0; i<L; ++i )
{
if( i!=k && i!=j )
*pNode++ = cand[i];
} newcand[L-2] = &node; if( node.Add() && query<L-1>( target, newcand, expr ) )
return true;
if( node.Sub() && query<L-1>( target, newcand, expr ) )
return true;
if( node.Sub2() && query<L-1>( target, newcand, expr ) )
return true;
if( node.Mul() && query<L-1>( target, newcand, expr ) )
return true;
if( node.Div() && query<L-1>( target, newcand, expr ) )
return true;
if( node.Div2() && query<L-1>( target, newcand, expr ) )
return true;
}
}
return false;
}template<>
bool query<1>( double target, Node** cand, string& expr )
{
double diff = target - cand[0]->value();
if( diff < 0.000001 && diff > -0.000001 )
{
//expr = cand[0]->getExpr();
return true;
}
return false;
}int main( int argc, char** argv)
{
const int LEN = 4;
if( argc != LEN+1 )
{
exit( -1 );
} double target = 24; Node nodes[LEN];
Node *cands[LEN];
for( int k=0; k<LEN; ++k )
{
int i = atoi( argv[k+1] );
if( i == 0 )
{
printf( "I don't like ZERO. Sorry!\n" );
exit( -1 );
}
nodes[k].value() = i;
cands[k] = &nodes[k];
} string expr;
if( query<LEN>( target, cands, expr ) )
printf( "%s\n", expr.c_str() );
else
printf( "fail!\n" ); return 0;
}

㈡ VB/vb.net編程 撲克牌

'以下是我做的圖片拼算24的游戲,可供你參考
Option Explicit
Enum CARD_DRAW
CARD_DRAW_FACE
CARD_DRAW_BACK
CARD_DRAW_INVERT
End Enum
Private Declare Function cdtInit Lib "Cards.dll" ( _
dx As Long, dy As Long) As Long
Private Declare Function cdtDraw Lib "Cards.dll" (ByVal hDC As Long, _
ByVal X As Long, ByVal Y As Long, ByVal iCard As Long, _
ByVal iDraw As Long, ByVal Clr As Long) As Long
Private Declare Function cdtTerm Lib "Cards.dll" () As Long
Dim picDraw As PictureBox
Dim Cwidth&, Cheight&
Dim Card&(52)
Dim bgColor&
Dim strOps$, NumOps&, intCard&, CW&(3), strTag$(10)

'初始化處理
Private Sub Form_Initialize()
Dim i&
Randomize
strTag(7) = "+"
strTag(8) = "-"
strTag(9) = "×"
strTag(10) = "÷"
'動態添加控制項並返回一個對該控制項的引用。
Set picDraw = Controls.Add("VB.PictureBox", "picDraw")
picDraw.AutoRedraw = True
picDraw.BorderStyle = 0
picDraw.ScaleMode = 3
picDraw.BackColor = BackColor
picDraw.Width = 71
picDraw.Height = 96
picDraw.Visible = True
picDraw.Left = 400
'載入撲克牌到控制項
cdtInit Cwidth, Cheight
For i = 0 To 51
Card(i) = i
Load imgCard(i + 4)
cdtDraw picDraw.hDC, 0, 0, Card(i), CARD_DRAW_FACE, bgColor
imgCard(i + 4) = picDraw.Image
Next
Load imgCard(56)
i = Int(Rnd * 15)
Select Case i
Case 0 To 2
cdtDraw picDraw.hDC, 0, 0, 52 - i * i * 0.5 + 2.5 * i, CARD_DRAW_FACE, bgColor
Case 3 To 14
cdtDraw picDraw.hDC, 0, 0, 51 + i, CARD_DRAW_BACK, bgColor
End Select
imgCard(56) = picDraw.Image
cdtTerm
'畫幫助屏幕
picDraw.Width = 375
picDraw.Height = 346
picDraw.Picture = Picture
picDraw.CurrentX = 52
picDraw.CurrentY = 14
picDraw.Print "分步算式 運算符 分步算式"
picDraw.Line (332, 70)-(362, 100), vbWhite, BF
For i = 0 To 3
picDraw.Line (i * 80 + 8, 40)-(i * 80 + 79, 136), , B
Next
picDraw.CurrentX = 24
picDraw.CurrentY = 78
picDraw.Print "撲克牌 撲克牌 撲克牌 撲克牌 發牌"
picDraw.Line (20, 150)-(212, 166), vbWhite, BF
picDraw.CurrentX = 24
picDraw.CurrentY = 153
picDraw.Print "編輯算式或分步算式:數 運算符 數 算式測試"
picDraw.CurrentX = 16
picDraw.CurrentY = 194
picDraw.Print "算式由三個分步算式編輯而成,數包括撲克牌和分步算式."
picDraw.CurrentX = 16
picDraw.CurrentY = 216
picDraw.Print "分步算式參與運算時自動添加括弧,算式編輯後可以測試."
picDraw.CurrentX = 16
picDraw.CurrentY = 238
picDraw.Print "如果你認為沒有算式,則跳過算式編輯直接進行測試即可."
picDraw.Line (4, 320)-(370, 338), vbWhite, BF
picDraw.CurrentX = 16
picDraw.CurrentY = 323
picDraw.Print "圖拼24--你只需用滑鼠操作圖片編輯算式即可,簡單方便,好看好玩."
imgShowHelp = picDraw.Image
picDraw = Nothing
'洗牌
mixCard
ClsExpression
End Sub

'4張撲克牌+-*/算24
Private Sub Count24()
Dim a#(3), i&, b$(3)
List1.Clear
For i = 0 To 3
a(i) = Val(strTag(i))
b(i) = a(i)
Next
If Is24(a, b, 4) Then
Else
List1.AddItem "沒有算式"
End If
End Sub

'取算術運算值
Private Function Sum(n1#, n2#, f) As Double
Select Case f
Case 1: Sum = n1 + n2
Case 2: Sum = n1 - n2
Case 3: Sum = n1 * n2
Case 4: If n2 Then Sum = n1 / n2 Else Sum = 1
End Select
End Function

'列算式
Private Function ShowSum(n1$, n2$, f)
ShowSum = n1 & Mid("+-×÷", f, 1) & n2
End Function

'遞歸算24
Private Function Is24(a#(), b$(), i&) As Boolean
Dim c#(2), ff&, ii&, jj&, kk&, nb&, d$(3), iCount&
If i = 2 Then
For ff = 1 To 4
equal a(0), a(1), ff, b(0), b(1), Is24
equal a(1), a(0), ff, b(1), b(0), Is24
Next
Else
For ii = 0 To i - 2
For jj = ii + 1 To i - 1
nb = 1
For kk = 0 To i - 1
If kk <> ii And kk <> jj Then c(nb) = a(kk): d(nb) = b(kk): nb = nb + 1
Next
For ff = 1 To 4
c(0) = Sum(a(ii), a(jj), ff)
d(0) = "(" & ShowSum(b(ii), b(jj), ff) & ")"
If Is24(c, d, i - 1) Then Is24 = True
c(0) = Sum(a(jj), a(ii), ff)
d(0) = "(" & ShowSum(b(jj), b(ii), ff) & ")"
If Is24(c, d, i - 1) Then Is24 = True
Next
Next
Next
End If
End Function

'兩個數運算是否為24,b0$, b1$分別為Num1#, Num2#的字元串表達式
Private Sub equal(Num1#, Num2#, Ops&, b0$, b1$, Is24 As Boolean)
Dim iCount&
If Sum(Num1, Num2, Ops) = 24 Then
strOps = ShowSum(b0, b1, Ops)
For iCount = 0 To List1.ListCount - 1
If InStr(List1.List(iCount), strOps) Then Exit For
Next
If iCount = List1.ListCount Then List1.AddItem Format((iCount + 1), "@@@@") & ": " & strOps
Is24 = True
End If
End Sub

'洗牌(從52張撲克牌中隨機抽出4張)
Private Sub mixCard()
Dim i&, j&, k&
For i = 0 To 3
j = Fix(Rnd * (52 - i) + i)
k = Card(j)
Card(j) = Card(i)
Card(i) = k
Next
End Sub

'清空算式處理
Sub ClsExpression()
Dim i&, X&, w&
For i = 0 To 3
strTag(i) = Card(i) \ 4 + 1
imgNum(i) = imgNumOps(strTag(i) - 1)
imgCard(i) = imgCard(Card(i) + 4)
CW(i) = 0
Next
strTag(4) = ""
imgExpression(0) = Nothing
strTag(5) = ""
imgExpression(1) = Nothing
strTag(6) = "沒有算式"
imgAnswer = Nothing
picDraw.Visible = False
picDraw.Cls
picDraw.Width = imgAnswer.Width
picDraw.Height = imgAnswer.Height
picDraw.CurrentX = 126
picDraw.CurrentY = 2
picDraw.Print "沒有算式?"
imgAnswer = picDraw.Image
NumOps = 0
List1.Clear
List1.Visible = False
picDraw = Nothing
End Sub

'顯示幫助
Private Sub imgHelp_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgHelp = Nothing
imgShowHelp.Visible = True
List1.Tag = List1.Visible
picDraw.Tag = picDraw.Visible
picDraw.Visible = False
List1.Visible = False
End Sub

Private Sub imgHelp_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgHelp = imgPic(0)
End Sub

Private Sub imgOperator_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
imgOperator(Index).Top = 16
End Sub

'選取運算符列入算式
Private Sub imgOperator_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
imgOperator(Index).Top = 12
If (NumOps Mod 3 - 1) Or NumOps > 8 Then Exit Sub
strTag(6) = strTag(6) & strTag(7 + Index)
NumOps = NumOps + 1
CW(3) = CW(2) + 20
UnitePic imgAnswer, imgOperator(Index), 0
imgAnswer = picDraw.Image
CW(2) = CW(3)
End Sub

'隱藏幫助
Private Sub imgShowHelp_Click()
imgShowHelp.Visible = False
picDraw.Visible = CBool(picDraw.Tag)
List1.Visible = CBool(List1.Tag)
End Sub

'發牌
Private Sub imgShuffle_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgShuffle = Nothing
mixCard
ClsExpression
End Sub

Private Sub imgShuffle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgShuffle = imgPic(1)
End Sub

'清空算式
Private Sub imgCls_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgCls = Nothing
End Sub

Private Sub imgCls_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgCls = imgPic(2)
ClsExpression
End Sub

'顯示所有算式答案
Private Sub imgQuery_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgQuery = Nothing
If NumOps = 9 Or picDraw.Visible = True Then List1.Visible = True
End Sub

Private Sub imgQuery_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgQuery = imgPic(3)
End Sub

'移動指牌器
Private Sub imgNum_Click(Index As Integer)
intCard = Index
imgPoint.Left = imgNum(Index).Left - 11
End Sub

'隨意數字選取牌
Private Sub imgNumOps_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
shpBorder.Visible = True
If Index < 9 Then shpBorder.Left = imgNumOps(Index).Left - 6 Else shpBorder.Left = imgNumOps(Index).Left
strTag(intCard) = Index + 1
imgNum(intCard) = imgNumOps(Index)
imgNum_Change intCard
intCard = (intCard + 1) Mod 4
imgPoint.Left = imgNum(intCard).Left - 11
End Sub

Private Sub imgNumOps_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
shpBorder.Visible = False
End Sub

'選牌後處理
Private Sub imgNum_Change(Index&)
Dim i&
If strTag(Index) = Card(Index) \ 4 + 1 Then Exit Sub
Do
Card(Index) = (strTag(Index) - 1) * 4 + Int(Rnd * 4)
For i = 0 To 3
If Card(Index) = Card(i) And Index <> i Then Exit For
Next
If i = 4 Or (i = 3 And Index = 3) Then Exit Do
Loop
imgCard(Index) = imgCard(Card(Index) + 4)
ClsExpression
End Sub

'選取撲克牌列入算式
Private Sub imgCard_Click(Index As Integer)
If imgCard(Index) = imgCard(56) Then Exit Sub
If strTag(6) = "沒有算式" Then strTag(6) = "": imgAnswer = Nothing: picDraw.Visible = False
If NumOps Mod 3 = 1 Then Exit Sub
strTag(6) = strTag(6) & strTag(Index)
If strTag(Index) < 10 Then CW(3) = CW(2) + 12 Else CW(3) = CW(2) + 24
UnitePic imgAnswer, imgNumOps(strTag(Index) - 1), 0
imgCard(Index) = imgCard(56)
expression
End Sub

'算式結果處理
Private Sub expression()
Dim i&
NumOps = NumOps + 1
If NumOps Mod 3 = 0 Then
If NumOps = 9 Then Exit Sub
If strTag(4) <> "" Then i = 1
strTag(4 + i) = strTag(6)
CW(2) = 0
UnitePic imgExpression(i), imgAnswer, (imgAnswer.Width - CW(3)) \ 2
CW(i) = CW(3)
CW(2) = 0
strTag(6) = ""
imgAnswer = Nothing
picDraw = imgAnswer
End If
End Sub

'選取運算結果列入算式
Private Sub imgExpression_Click(Index As Integer)
If strTag(4 + Index) = "" Then Exit Sub
If NumOps Mod 3 = 1 Then Exit Sub
strTag(6) = strTag(6) & "(" & strTag(4 + Index) & ")"
CW(3) = CW(2) + 12
UnitePic imgAnswer, imgOperator(4), 0
CW(3) = CW(2) + CW(Index)
UnitePic imgAnswer, imgExpression(Index), (imgExpression(Index).Width - CW(Index)) \ 2
CW(3) = CW(2) + 12
UnitePic imgAnswer, imgOperator(5), 0
strTag(4 + Index) = ""
imgExpression(Index) = LoadPicture("")
expression
End Sub

'驗證算式是否正確
Private Sub imgAnswer_Click()
If picDraw.Visible = True Then Exit Sub
If strTag(6) = "沒有算式" Or NumOps = 9 Then Validate strTag(6)
End Sub

'算式驗證
Private Sub Validate(Ops$)
Dim i&
Count24
For i = 0 To List1.ListCount - 1
If InStr(List1.List(i), Ops) Then Exit For
Next
picDraw.Width = 54
picDraw.Height = imgAnswer.Height
picDraw.CurrentX = 2
picDraw.CurrentY = 2
picDraw.ForeColor = vbBlue
If i = List1.ListCount Then
picDraw.Print "再想一想"
Else
picDraw.Print "你算對了"
List1.Selected(i) = True
End If
picDraw.ForeColor = vbBlack
picDraw.Move 260, 150
picDraw.Visible = True
End Sub

'圖片合並居中(img2拼接到img1右邊):img1剪切寬度拼接前CW(2),拼接後CW(3);img2剪切左邊距img2W
Sub UnitePic(img1 As Image, img2 As Image, img2W&)
Dim w1&
w1 = img1.Width
picDraw.Cls
picDraw.Width = w1
picDraw.Height = img1.Height
If img1 Then picDraw.PaintPicture img1, (w1 - CW(3)) \ 2, 0, , , (w1 - CW(2)) \ 2
If img2 Then picDraw.PaintPicture img2, (w1 - CW(3)) \ 2 + CW(2), 0, , , img2W
img1 = picDraw.Image
CW(2) = CW(3)
End Sub

'刪除動態添加的控制項
Private Sub Form_Unload(Cancel As Integer)
Controls.Remove picDraw
End Sub

㈢ 易語言用畫板製作撲克牌游戲手牌

畫板得用兩個 來回復制比較麻煩 建議還是用動畫框吧 動畫框比較方便 可以創建撲克牌物體然後置撲克牌的層次和位置 還可以加上一些動畫效果 比如洗牌 發牌

㈣ 如何用VB做記牌器

轉片貼子,希望會對你有所幫助
「記牌器是怎樣編寫出來的?」
該文章的網址是:http://hi..com/whsangda
作者用VB語言所編寫的最新QQ鬥地主記牌器V9.30在天空軟體站已經被超過四萬五千多人下載使用,記牌器的下載網址是:
http://www2.skycn.com/soft/27872.html

㈤ 54張撲克牌,留5張底牌,其它分給四個人,求代碼實現我圖片上的內容

我這里有個模擬發牌52張的代碼,稍微改改就可以了,供你參考

#include<stdio.h>
#include<time.h>
#include<stdlib.h>
intmain(void)
{
intaim,i;
intpoker[52]={0};/*已發的牌在數組中,初始狀態為0,表示沒發過,置為1表示已發過,避免重復發放*/

srand((unsigned)time(NULL));/*隨機數初始化*/

/*產生一個隨機數0-51,並保存到aim變數中*/
aim=rand()%52;

/*模擬發不含大小王牌的撲克牌,
將生成的隨機數映射為每張撲克牌。
按照花色(梅花、方塊、紅桃、黑桃)和大小(2~10、J、Q、K、A)順序進行映射。
映射規則如下:
梅花:0-12
方塊:13-25
紅桃:26-38
黑桃:39-51
*/


/*以下模擬發52張牌,可以根據需要修改循環次數發任意張*/
for(i=1;i<=52;i++)
{
aim=rand()%52;
/*已發的牌在數組中置為1,避免重復發放*/
while(poker[aim]==1)
{
aim=rand()%52;
}
poker[aim]=1;

printf(" 第%2d張牌:",i);
switch(aim/13)
{
case0:
printf("梅花");
break;
case1:
printf("方塊");
break;
case2:
printf("紅桃");
break;
case3:
printf("黑桃");
break;
default:break;
}
switch(aim%13+1)
{
case2:
case3:
case4:
case5:
case6:
case7:
case8:
case9:
case10:
printf("%2d",aim%13+1);
break;
case1:
printf("A");
break;
case11:
printf("J");
break;
case12:
printf("Q");
break;
case13:
printf("K");
break;
default:break;
}
}
return0;
}

㈥ 求:紙牌游戲源代碼 急需!!

非常簡單的記憶類游戲阿,寫好了個簡單框架,把card類替換為你的素材就可以了,需要的話可以給你發源碼

㈦ 三重德州撲克源碼連不上電腦怎麼辦

會自動連接的

㈧ 求德州撲克伺服器端源碼 或者核心演算法(計算誰的牌大)也行

「完全充電」是指所有剩下的籌碼手柄上的一次賭注。一個人沒有足夠的籌碼跟進時,你可以打賭,所有剩下的籌碼。在「無極限」的游戲,「全」是一種策略。一旦有人推鍋將割讓「一鍋端」。撲克獎金邊緣池,其中包含只有數人開始追隨他的手「」到目前為止,這個時候黃金注入。如果這名男子猛的後向董事會仍在繼續,人走開「一鍋端」的權利,但不能贏得其他玩家的下跌後,他猛的「鍋」獎金。在這種情況下,秒針會贏得一個強大推去後,也就是剩餘的獎金。

熱點內容
dns配置出現錯誤該怎麼辦 發布:2025-01-10 22:13:00 瀏覽:436
雲頂演算法 發布:2025-01-10 22:10:07 瀏覽:988
收件伺服器有什麼作用 發布:2025-01-10 21:50:01 瀏覽:388
安卓70緩存 發布:2025-01-10 21:49:03 瀏覽:682
圖像檢索演算法 發布:2025-01-10 21:43:58 瀏覽:556
plsqlforupdate 發布:2025-01-10 21:43:50 瀏覽:915
如何設置健康碼快捷方式vivo安卓 發布:2025-01-10 21:39:52 瀏覽:502
安卓不兼容怎麼解決 發布:2025-01-10 21:37:02 瀏覽:31
linux字體大小 發布:2025-01-10 21:36:21 瀏覽:494
安卓手機的音量在哪裡調 發布:2025-01-10 21:32:11 瀏覽:615