Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
微笑面对bug
ddz
提交
c0b094bb
ddz
项目概览
微笑面对bug
/
ddz
通知
5
Star
2
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ddz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c0b094bb
编写于
9月 26, 2020
作者:
微笑面对bug
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
AI 完成
上级
17935f22
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
237 addition
and
13 deletion
+237
-13
dist/css/app.d8f0477c.css
dist/css/app.d8f0477c.css
+0
-1
dist/index.html
dist/index.html
+1
-1
src/components/Game.vue
src/components/Game.vue
+1
-0
src/doudizhu/AI.js
src/doudizhu/AI.js
+233
-9
src/doudizhu/Game.js
src/doudizhu/Game.js
+2
-2
未找到文件。
dist/css/app.d8f0477c.css
已删除
100644 → 0
浏览文件 @
17935f22
.poker
[
data-v-4dff4871
],
.pokerDesk
[
data-v-4dff4871
]
{
height
:
100%
;
width
:
100px
;
border
:
1px
solid
;
border-radius
:
16px
;
float
:
left
;
margin-left
:
-50px
;
background-color
:
azure
;
font-size
:
30px
}
.poker
[
data-v-4dff4871
]
:hover
{
background-color
:
#faebd7
}
.selected
[
data-v-4dff4871
]
{
margin-top
:
-20px
}
\ No newline at end of file
dist/index.html
浏览文件 @
c0b094bb
<!DOCTYPE html>
<html><head><meta
charset=
utf-8
><meta
http-equiv=
X-UA-Compatible
content=
"IE=edge"
><meta
name=
viewport
content=
"width=device-width,initial-scale=1"
><title>
Vue App
</title><link
href=
css/app.d8f0477c.css
rel=
preload
as=
style
><link
href=
js/app.945dae12.js
rel=
preload
as=
script
><link
href=
js/chunk-vendors.caf18475.js
rel=
preload
as=
script
><link
href=
css/app.d8f0477c.css
rel=
stylesheet
></head><body><div
id=
app
></div><script
src=
js/chunk-vendors.caf18475.js
></script><script
src=
js/app.945dae12.js
></script></body></html>
\ No newline at end of file
<!DOCTYPE html>
<html><head><meta
charset=
utf-8
><meta
http-equiv=
X-UA-Compatible
content=
"IE=edge"
><meta
name=
viewport
content=
"width=device-width,initial-scale=1"
><title>
Vue App
</title><link
href=
css/app.84b425a3.css
rel=
preload
as=
style
><link
href=
js/app.a8686d4f.js
rel=
preload
as=
script
><link
href=
js/chunk-vendors.caf18475.js
rel=
preload
as=
script
><link
href=
css/app.84b425a3.css
rel=
stylesheet
></head><body><div
id=
app
></div><script
src=
js/chunk-vendors.caf18475.js
></script><script
src=
js/app.a8686d4f.js
></script></body></html>
\ No newline at end of file
src/components/Game.vue
浏览文件 @
c0b094bb
...
...
@@ -178,6 +178,7 @@ export default {
},
mounted
()
{
this
.
data
=
this
.
game
.
playerList
[
1
].
name
;
window
.
game
=
this
.
game
;
},
methods
:{
enter
:
function
(
e
,
poker
){
...
...
src/doudizhu/AI.js
浏览文件 @
c0b094bb
...
...
@@ -321,13 +321,8 @@ class AI{
//接牌3 最小接 不拆 不炸 不出王、2、AAA
getByObj3
(
lastObj
){
let
obj
;
obj
=
this
.
getSmallestObjByObj
(
lastObj
);
if
(
obj
){
if
(
lastObj
){
obj
=
this
.
getSmallestObjNoBig
(
lastObj
);
}
}
return
obj
;
}
...
...
@@ -395,7 +390,7 @@ class AI{
//接牌5
getByObj5
(
lastObj
){
let
obj
=
this
.
getByBoom
();
let
obj
=
this
.
getByBoom
(
lastObj
);
if
(
!
obj
){
if
(
this
.
player
.
pokerList
[
this
.
player
.
pokerList
.
length
-
1
].
number
>
lastObj
.
one
[
0
].
number
){
...
...
@@ -411,6 +406,20 @@ class AI{
}
//接牌6
getByObj6
(
lastObj
){
let
obj
;
if
(
lastObj
.
player
.
type
===
'
dizhu
'
){
obj
=
this
.
getByObj1
(
lastObj
);
}
else
{
obj
=
this
.
getByObj3
(
lastObj
);
}
return
obj
;
}
//接牌
playByObj
(
lastObj
){
let
obj
;
...
...
@@ -431,17 +440,103 @@ class AI{
obj
=
this
.
getByObj1
(
lastObj
);
}
}
else
{
if
(
this
.
player
.
next
.
type
===
this
.
player
.
type
){
obj
=
this
.
getByObj6
(
lastObj
);
}
else
{
if
(
this
.
player
.
next
.
pokerList
.
length
===
1
){
if
(
lastObj
.
player
.
type
===
'
dizhu
'
){
obj
=
this
.
getByObj4
(
lastObj
);
}
else
{
if
(
lastObj
.
type
===
'
one
'
){
let
canNotGet
=
this
.
isPlayerCanNotGetOne
(
lastObj
);
if
(
canNotGet
){
//pass
}
else
{
obj
=
this
.
getByObj5
(
lastObj
);
}
}
else
{
//pass
}
}
}
else
{
obj
=
this
.
getByObj6
(
lastObj
);
}
}
}
if
(
!
obj
){
obj
=
{
type
:
'
pass
'
,
poker
:
[
'
pass
'
],
};
}
this
.
player
.
deleteFromPokerListAndSendByObj
(
obj
);
}
isPlayerCanNotGetOne
(
obj
){
let
allPoker
=
{
3
:
0
,
4
:
0
,
5
:
0
,
6
:
0
,
7
:
0
,
8
:
0
,
9
:
0
,
10
:
0
,
11
:
0
,
12
:
0
,
13
:
0
,
14
:
0
,
15
:
0
,
16
:
0
,
17
:
0
,
};
let
oldPokerList
=
this
.
game
.
oldPokerList
;
for
(
let
i
=
0
;
i
<
oldPokerList
.
length
;
i
++
){
for
(
let
j
=
0
;
j
<
oldPokerList
[
i
].
poker
.
length
;
j
++
){
allPoker
[
oldPokerList
[
i
].
poker
[
j
].
number
]
++
;
}
}
let
deskPokerObj
=
this
.
game
.
deskPokerObj
;
for
(
let
j
=
0
;
j
<
deskPokerObj
.
poker
.
length
;
j
++
){
allPoker
[
deskPokerObj
.
poker
[
j
].
number
]
++
;
}
let
pokers
=
this
.
player
.
pokerList
;
for
(
let
j
=
0
;
j
<
pokers
.
length
;
j
++
){
allPoker
[
pokers
[
j
].
number
]
++
;
}
let
num
=
obj
.
one
[
0
].
number
;
let
result
=
true
;
if
(
num
===
16
){
if
(
allPoker
[
17
]
!==
1
){
return
false
;
}
}
else
if
(
num
===
15
){
if
(
allPoker
[
16
]
!==
1
||
allPoker
[
17
]
!==
1
){
return
false
;
}
}
else
{
for
(
let
n
=
num
+
1
;
n
<=
15
;
n
++
){
if
(
allPoker
[
n
]
!==
4
){
return
false
;
}
}
}
return
true
;
}
//出牌1
playByTypys1
(){
let
types
=
[
'
threeWithTwoList
'
,
'
threeWithOneList
'
,
'
threeList
'
,
'
twoList
'
,
'
oneList
'
,
'
threeWithTwo
'
,
'
threeWithOne
'
,
'
three
'
,
'
two
'
,
'
one
'
,
'
four
'
,
'
sx
'
];
for
(
let
i
=
0
;
i
<
types
.
length
;
i
++
){
let
obj
=
this
.
getSmallestObjByType
(
types
[
i
]);
if
(
!
obj
){
continue
;
}
this
.
player
.
deleteFromPokerListAndSendByObj
(
obj
);
break
;
}
}
...
...
@@ -490,6 +585,135 @@ class AI{
}
}
//接 队友
getSmallestObjNoBig
(
lastObj
){
let
classifyObj
=
this
.
player
.
classifyObj
;
let
type
=
lastObj
.
type
;
let
obj
=
null
;
if
(
type
===
'
one
'
){
let
poker
;
if
(
classifyObj
.
one
.
length
>
0
){
for
(
let
i
=
0
;
i
<
classifyObj
.
one
.
length
;
i
++
){
if
(
classifyObj
.
one
[
i
][
0
].
number
>
lastObj
.
one
[
0
].
number
){
poker
=
classifyObj
.
one
[
i
];
break
;
}
}
}
if
(
poker
){
obj
=
{
type
:
type
,
poker
:
poker
,
one
:
poker
,
};
}
}
else
if
(
type
===
'
two
'
){
let
poker
;
if
(
classifyObj
.
two
.
length
>
0
){
for
(
let
i
=
0
;
i
<
classifyObj
.
two
.
length
;
i
++
){
if
(
classifyObj
.
two
[
i
][
0
].
number
>
lastObj
.
two
[
0
].
number
){
poker
=
classifyObj
.
two
[
i
];
break
;
}
}
}
if
(
poker
){
obj
=
{
type
:
type
,
poker
:
poker
,
two
:
poker
,
};
}
}
else
if
(
type
===
'
three
'
){
let
poker
;
if
(
classifyObj
.
three
.
length
>
0
){
for
(
let
i
=
0
;
i
<
classifyObj
.
three
.
length
;
i
++
){
if
(
classifyObj
.
three
[
i
][
0
].
number
>
lastObj
.
three
[
0
].
number
){
if
(
classifyObj
.
three
[
i
][
0
].
number
<=
13
){
poker
=
classifyObj
.
three
[
i
];
}
break
;
}
}
}
if
(
poker
){
obj
=
{
type
:
type
,
poker
:
poker
,
three
:
poker
,
};
}
}
else
if
(
type
===
'
threeWithOne
'
){
let
pokerThree
;
let
one
;
if
(
classifyObj
.
three
.
length
>
0
){
if
(
classifyObj
.
three
.
length
>
0
){
for
(
let
i
=
0
;
i
<
classifyObj
.
three
.
length
;
i
++
){
if
(
classifyObj
.
three
[
i
][
0
].
number
>
lastObj
.
three
[
0
].
number
){
if
(
classifyObj
.
three
[
i
][
0
].
number
<=
13
){
pokerThree
=
classifyObj
.
three
[
i
];
}
break
;
}
}
}
}
if
(
classifyObj
.
one
.
length
>
0
){
one
=
classifyObj
.
one
[
0
];
}
if
(
pokerThree
&&
one
){
obj
=
{
type
:
type
,
poker
:
pokerThree
.
concat
(
one
),
three
:
pokerThree
,
one
:
one
,
};
}
}
else
if
(
type
===
'
threeWithTwo
'
){
let
pokerThree
;
let
two
;
if
(
classifyObj
.
three
.
length
>
0
){
if
(
classifyObj
.
three
.
length
>
0
){
for
(
let
i
=
0
;
i
<
classifyObj
.
three
.
length
;
i
++
){
if
(
classifyObj
.
three
[
i
][
0
].
number
>
lastObj
.
three
[
0
].
number
){
if
(
classifyObj
.
three
[
i
][
0
].
number
<=
13
){
pokerThree
=
classifyObj
.
three
[
i
];
}
break
;
}
}
}
}
if
(
classifyObj
.
two
.
length
>
0
){
two
=
classifyObj
.
two
[
0
];
}
if
(
pokerThree
&&
two
){
obj
=
{
type
:
type
,
poker
:
pokerThree
.
concat
(
two
),
three
:
pokerThree
,
two
:
two
,
};
}
}
return
obj
;
}
//最小接 不拆
getSmallestObjByObj
(
lastObj
){
let
classifyObj
=
this
.
player
.
classifyObj
;
...
...
@@ -510,7 +734,7 @@ class AI{
if
(
!
poker
){
if
(
lastObj
.
one
[
0
].
number
<
15
&&
classifyObj
.
poker15
.
length
>
0
){
poker
=
classifyObj
.
poker15
[
0
]
;
poker
=
classifyObj
.
poker15
.
slice
(
0
,
1
)
;
}
else
{
if
(
classifyObj
.
poker17
.
length
<
0
||
classifyObj
.
poker16
.
length
<
0
){
if
(
lastObj
.
one
[
0
].
number
<
16
&&
classifyObj
.
poker16
.
length
>
0
){
...
...
@@ -851,7 +1075,7 @@ class AI{
}
else
if
(
classifyObj
.
poker16
.
length
>
0
){
poker
=
classifyObj
.
poker16
;
}
else
if
(
classifyObj
.
poker15
.
length
>
0
){
poker
=
classifyObj
.
poker15
[
0
]
;
poker
=
classifyObj
.
poker15
.
slice
(
0
,
1
)
;
}
else
{
poker
=
classifyObj
.
one
[
classifyObj
.
one
.
length
-
1
];
}
...
...
src/doudizhu/Game.js
浏览文件 @
c0b094bb
...
...
@@ -56,7 +56,7 @@ class Game{
this
.
timeLoop
();
this
.
currentPlayer
=
this
.
dizhu
;
if
(
this
.
currentPlayer
.
isRobot
){
this
.
currentPlayer
.
playByAI
();
this
.
currentPlayer
.
playByAI
2
();
}
}
...
...
@@ -69,7 +69,7 @@ class Game{
this
.
resetTime
();
this
.
currentPlayer
=
this
.
currentPlayer
.
next
;
if
(
this
.
currentPlayer
.
isRobot
){
this
.
currentPlayer
.
playByAI
();
this
.
currentPlayer
.
playByAI
2
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录