Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
微笑面对bug
ddz
提交
a85357f9
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 搜索 >>
提交
a85357f9
编写于
9月 25, 2020
作者:
微笑面对bug
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
AI 接牌
上级
8d9fe39c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
324 addition
and
1 deletion
+324
-1
src/doudizhu/AI.js
src/doudizhu/AI.js
+324
-1
未找到文件。
src/doudizhu/AI.js
浏览文件 @
a85357f9
...
...
@@ -298,9 +298,80 @@ class AI{
};
}
//接牌1
getByObj1
(
lastObj
){
let
obj
;
obj
=
getSmallestObjByObj
(
lastObj
);
}
//接牌2
getByObj2
(
lastObj
){
}
//接牌4
getByObj4
(
lastObj
){
let
obj
;
if
(
lastObj
.
type
===
'
one
'
){
obj
=
this
.
getByObj5
(
lastObj
);
}
else
{
obj
=
this
.
getByObj2
(
lastObj
);
}
return
obj
;
}
//接牌5
getByObj5
(
lastObj
){
let
classifyObj
=
this
.
player
.
classifyObj
;
let
obj
;
let
poker
;
if
(
classifyObj
.
four
.
length
>
0
){
poker
=
classifyObj
.
four
[
0
];
}
else
if
(
classifyObj
.
poker15
.
length
===
4
){
poker
=
classifyObj
.
poker15
;
}
if
(
poker
){
obj
=
{
type
:
'
four
'
,
poker
:
poker
,
four
:
poker
,
};
}
else
{
if
(
classifyObj
.
poker16
.
length
>
0
&&
classifyObj
.
poker17
.
length
>
0
){
obj
=
{
type
:
'
sx
'
,
poker
:
classifyObj
.
poker16
.
concat
(
classifyObj
.
poker17
),
sx
:
classifyObj
.
poker16
.
concat
(
classifyObj
.
poker17
),
}
}
}
if
(
!
poker
){
obj
=
{
type
:
'
one
'
,
poker
:
[
this
.
player
.
pokerList
[
this
.
player
.
pokerList
.
length
-
1
]],
one
:
[
this
.
player
.
pokerList
[
this
.
player
.
pokerList
.
length
-
1
]],
};
}
return
obj
;
}
//接牌
playByObj
(
lastObj
){
let
obj
;
if
(
this
.
player
.
type
===
'
dizhu
'
){
if
(
this
.
player
.
next
.
pokerList
.
length
===
1
||
this
.
player
.
last
.
pokerList
.
length
===
1
){
obj
=
this
.
getByObj4
(
lastObj
);
}
else
{
obj
=
this
.
getByObj1
(
lastObj
);
}
}
else
{
}
}
//出牌1
...
...
@@ -321,6 +392,16 @@ class AI{
}
}
//出牌 最小一张
playSmallestOne
(){
let
obj
=
{
type
:
'
one
'
,
poker
:
[
this
.
player
.
pokerList
[
0
]],
one
:
[
this
.
player
.
pokerList
[
0
]],
};
this
.
player
.
deleteFromPokerListAndSendByObj
(
obj
);
}
//出牌
playByAllType
(){
...
...
@@ -330,12 +411,254 @@ class AI{
}
else
{
this
.
playByTypys1
();
}
}
else
{
if
(
this
.
player
.
next
.
type
===
'
nongmin
'
){
if
(
this
.
player
.
next
.
pokerList
.
length
===
1
){
this
.
playSmallestOne
();
}
else
{
this
.
playByTypys1
();
}
}
else
{
if
(
this
.
player
.
next
.
pokerList
.
length
===
1
){
this
.
playByTypys2
();
}
else
{
this
.
playByTypys1
();
}
}
}
}
getSmallestObjByType
(
type
,
oneBigToSmall
){
//最小接 不拆
getSmallestObjByObj
(
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
[
0
];
break
;
}
}
}
if
(
!
poker
){
if
(
lastObj
.
one
[
0
].
number
<
15
&&
classifyObj
.
poker15
.
length
>
0
){
poker
=
classifyObj
.
poker15
[
0
];
}
else
{
if
(
classifyObj
.
poker17
.
length
<
0
||
classifyObj
.
poker16
.
length
<
0
){
if
(
lastObj
.
one
[
0
].
number
<
16
&&
classifyObj
.
poker16
.
length
>
0
){
poker
=
classifyObj
.
poker16
;
}
else
if
(
lastObj
.
one
[
0
].
number
<
17
&&
classifyObj
.
poker17
.
length
>
0
){
poker
=
classifyObj
.
poker17
;
}
}
}
}
if
(
poker
){
obj
=
{
type
:
type
,
poker
:
poker
,
one
:
poker
,
};
}
}
else
if
(
type
===
'
two
'
){
let
poker
;
if
(
classifyObj
.
two
.
length
>
0
){
poker
=
classifyObj
.
two
[
0
];
}
else
{
if
(
classifyObj
.
poker15
.
length
>
1
){
poker
=
classifyObj
.
poker15
.
slice
(
0
,
2
);
}
}
if
(
poker
){
obj
=
{
type
:
type
,
poker
:
poker
,
two
:
poker
,
};
}
}
else
if
(
type
===
'
three
'
){
let
poker
;
if
(
classifyObj
.
three
.
length
>
0
){
poker
=
classifyObj
.
three
[
0
];
}
else
{
if
(
classifyObj
.
poker15
.
length
===
3
){
poker
=
classifyObj
.
poker15
;
}
}
if
(
poker
){
obj
=
{
type
:
type
,
poker
:
poker
,
three
:
poker
,
};
}
}
else
if
(
type
===
'
threeWithOne
'
){
let
pokerThree
;
let
one
;
if
(
classifyObj
.
three
.
length
>
0
){
pokerThree
=
classifyObj
.
three
[
0
];
}
if
(
classifyObj
.
one
.
length
>
0
){
one
=
classifyObj
.
one
[
0
];
}
if
(
!
pokerThree
&&
classifyObj
.
poker15
.
length
===
3
){
pokerThree
=
classifyObj
.
poker15
;
}
if
(
!
one
&&
classifyObj
.
poker15
.
length
>
0
){
one
=
classifyObj
.
poker15
.
slice
(
0
,
1
);
}
if
(
pokerThree
&&
one
){
obj
=
{
type
:
type
,
poker
:
pokerThree
.
concat
(
one
),
three
:
pokerThree
,
one
:
one
,
};
}
}
else
if
(
type
===
'
four
'
){
let
poker
;
if
(
classifyObj
.
four
.
length
>
0
){
poker
=
classifyObj
.
four
[
0
];
}
else
{
if
(
classifyObj
.
poker15
.
length
===
4
){
poker
=
classifyObj
.
poker15
;
}
}
if
(
poker
){
obj
=
{
type
:
type
,
poker
:
poker
,
four
:
poker
,
};
}
}
else
if
(
type
===
'
threeWithTwo
'
){
let
pokerThree
;
let
two
;
if
(
classifyObj
.
three
.
length
>
0
){
pokerThree
=
classifyObj
.
three
[
0
];
}
if
(
classifyObj
.
two
.
length
>
0
){
two
=
classifyObj
.
two
[
0
];
}
if
(
!
pokerThree
&&
classifyObj
.
poker15
.
length
===
3
){
pokerThree
=
classifyObj
.
poker15
;
}
if
(
!
two
&&
classifyObj
.
poker15
.
length
>
1
){
two
=
classifyObj
.
poker15
.
slice
(
0
,
2
);
}
if
(
pokerThree
&&
two
){
obj
=
{
type
:
type
,
poker
:
pokerThree
.
concat
(
two
),
three
:
pokerThree
,
two
:
two
,
};
}
}
else
if
(
type
===
'
threeWithOneList
'
){
if
(
classifyObj
.
threeList
.
length
>
0
){
if
(
classifyObj
.
one
.
length
>=
classifyObj
.
threeList
[
0
].
length
){
let
pokerThree
=
classifyObj
.
threeList
[
0
].
flat
(
1
);
let
pokerOne
=
classifyObj
.
one
.
slice
(
0
,
classifyObj
.
threeList
[
0
].
length
).
flat
(
1
);
obj
=
{
type
:
type
,
poker
:
pokerThree
.
concat
(
pokerOne
),
list
:
classifyObj
.
threeList
[
0
].
map
(
function
(
item
)
{
return
{
three
:
item
};
}),
};
}
}
}
else
if
(
type
===
'
threeWithTwoList
'
){
if
(
classifyObj
.
threeList
.
length
>
0
){
if
(
classifyObj
.
two
.
length
>=
classifyObj
.
threeList
[
0
].
length
){
let
pokerThree
=
classifyObj
.
threeList
[
0
].
flat
(
1
);
let
pokerTwo
=
classifyObj
.
two
.
slice
(
0
,
classifyObj
.
threeList
[
0
].
length
).
flat
(
1
);
obj
=
{
type
:
type
,
poker
:
pokerThree
.
concat
(
pokerTwo
),
list
:
classifyObj
.
threeList
[
0
].
map
(
function
(
item
)
{
return
{
three
:
item
};
}),
};
}
}
}
else
if
(
type
===
'
oneList
'
){
if
(
classifyObj
.
oneList
.
length
>
0
){
obj
=
{
type
:
type
,
poker
:
classifyObj
.
oneList
[
0
].
flat
(
1
),
list
:
classifyObj
.
oneList
[
0
].
map
(
function
(
item
)
{
return
{
one
:
item
,
}
}),
};
}
}
else
if
(
type
===
'
twoList
'
){
if
(
classifyObj
.
twoList
.
length
>
0
){
obj
=
{
type
:
type
,
poker
:
classifyObj
.
twoList
[
0
].
flat
(
1
),
list
:
classifyObj
.
twoList
[
0
].
map
(
function
(
item
)
{
return
{
two
:
item
,
}
}),
};
}
}
else
if
(
type
===
'
threeList
'
){
if
(
classifyObj
.
threeList
.
length
>
0
){
obj
=
{
type
:
type
,
poker
:
classifyObj
.
threeList
[
0
].
flat
(
1
),
list
:
classifyObj
.
threeList
[
0
].
map
(
function
(
item
)
{
return
{
three
:
item
,
}
}),
};
}
}
else
if
(
type
===
'
sx
'
){
if
(
classifyObj
.
poker16
.
length
>
0
&&
classifyObj
.
poker17
.
length
>
0
){
return
{
type
:
type
,
poker
:
classifyObj
.
poker16
.
concat
(
classifyObj
.
poker17
),
sx
:
classifyObj
.
poker16
.
concat
(
classifyObj
.
poker17
),
}
}
}
return
obj
;
}
getSmallestObjByType
(
type
,
oneBigToSmall
){
let
classifyObj
=
this
.
player
.
classifyObj
;
let
obj
=
null
;
if
(
type
===
'
one
'
){
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录