Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
微笑面对bug
ddz
提交
45347a06
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 搜索 >>
提交
45347a06
编写于
9月 25, 2020
作者:
C
changjiuxiong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
AI 地主接牌
上级
a85357f9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
208 addition
and
85 deletion
+208
-85
src/doudizhu/AI.js
src/doudizhu/AI.js
+201
-80
src/doudizhu/Poker.js
src/doudizhu/Poker.js
+7
-5
未找到文件。
src/doudizhu/AI.js
浏览文件 @
45347a06
...
...
@@ -301,7 +301,7 @@ class AI{
//接牌1
getByObj1
(
lastObj
){
let
obj
;
obj
=
getSmallestObjByObj
(
lastObj
);
obj
=
this
.
getSmallestObjByObj
(
lastObj
);
}
//接牌2
...
...
@@ -372,6 +372,7 @@ class AI{
}
else
{
}
this
.
player
.
deleteFromPokerListAndSendByObj
(
obj
);
}
//出牌1
...
...
@@ -439,7 +440,7 @@ class AI{
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
];
poker
=
classifyObj
.
one
[
i
];
break
;
}
}
...
...
@@ -472,12 +473,20 @@ class AI{
let
poker
;
if
(
classifyObj
.
two
.
length
>
0
){
poker
=
classifyObj
.
two
[
0
];
}
else
{
if
(
classifyObj
.
poker15
.
length
>
1
){
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
){
if
(
lastObj
.
two
[
0
].
number
<
15
&&
classifyObj
.
poker15
.
length
>
1
){
poker
=
classifyObj
.
poker15
.
slice
(
0
,
2
);
}
}
if
(
poker
){
obj
=
{
type
:
type
,
...
...
@@ -489,9 +498,16 @@ class AI{
let
poker
;
if
(
classifyObj
.
three
.
length
>
0
){
poker
=
classifyObj
.
three
[
0
];
}
else
{
if
(
classifyObj
.
poker15
.
length
===
3
){
for
(
let
i
=
0
;
i
<
classifyObj
.
three
.
length
;
i
++
){
if
(
classifyObj
.
three
[
i
][
0
].
number
>
lastObj
.
three
[
0
].
number
){
poker
=
classifyObj
.
three
[
i
];
break
;
}
}
}
if
(
!
poker
){
if
(
lastObj
.
three
[
0
].
number
<
15
&&
classifyObj
.
poker15
.
length
===
3
){
poker
=
classifyObj
.
poker15
;
}
}
...
...
@@ -507,14 +523,23 @@ class AI{
let
pokerThree
;
let
one
;
if
(
classifyObj
.
three
.
length
>
0
){
pokerThree
=
classifyObj
.
three
[
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
){
pokerThree
=
classifyObj
.
three
[
i
];
break
;
}
}
}
}
if
(
classifyObj
.
one
.
length
>
0
){
one
=
classifyObj
.
one
[
0
];
if
(
!
pokerThree
){
if
(
lastObj
.
three
[
0
].
number
<
15
&&
classifyObj
.
poker15
.
length
===
3
){
pokerThree
=
classifyObj
.
poker15
;
}
}
if
(
!
pokerThree
&&
classifyObj
.
poker15
.
length
===
3
){
pokerThree
=
classifyObj
.
poker15
;
if
(
classifyObj
.
one
.
length
>
0
){
one
=
classifyObj
.
one
[
0
]
;
}
if
(
!
one
&&
classifyObj
.
poker15
.
length
>
0
){
one
=
classifyObj
.
poker15
.
slice
(
0
,
1
);
...
...
@@ -529,13 +554,57 @@ class AI{
};
}
}
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
){
pokerThree
=
classifyObj
.
three
[
i
];
break
;
}
}
}
}
if
(
!
pokerThree
){
if
(
lastObj
.
three
[
0
].
number
<
15
&&
classifyObj
.
poker15
.
length
===
3
){
pokerThree
=
classifyObj
.
poker15
;
}
}
if
(
classifyObj
.
two
.
length
>
0
){
two
=
classifyObj
.
two
[
0
];
}
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
===
'
four
'
){
let
poker
;
if
(
classifyObj
.
four
.
length
>
0
){
poker
=
classifyObj
.
four
[
0
];
}
else
{
for
(
let
i
=
0
;
i
<
classifyObj
.
four
.
length
;
i
++
){
if
(
classifyObj
.
four
[
i
][
0
].
number
>
lastObj
.
four
[
0
].
number
){
poker
=
classifyObj
.
four
[
i
];
break
;
}
}
}
if
(
!
poker
){
if
(
classifyObj
.
poker15
.
length
===
4
){
poker
=
classifyObj
.
poker15
;
}
...
...
@@ -548,101 +617,153 @@ class AI{
four
:
poker
,
};
}
}
else
if
(
type
===
'
threeWithTwo
'
){
}
else
if
(
type
===
'
fourWithOne
'
){
let
pokerThree
;
let
two
;
if
(
classifyObj
.
three
.
length
>
0
){
pokerThree
=
classifyObj
.
three
[
0
];
let
pokerFour
;
let
one1
;
let
one2
;
if
(
classifyObj
.
four
.
length
>
0
){
for
(
let
i
=
0
;
i
<
classifyObj
.
four
.
length
;
i
++
){
if
(
classifyObj
.
four
[
i
][
0
].
number
>
lastObj
.
four
[
0
].
number
){
pokerFour
=
classifyObj
.
four
[
i
];
break
;
}
}
}
if
(
classifyObj
.
two
.
length
>
0
){
two
=
classifyObj
.
two
[
0
];
if
(
classifyObj
.
one
.
length
>
1
){
one1
=
classifyObj
.
one
[
0
];
one2
=
classifyObj
.
one
[
1
];
}
if
(
!
pokerThree
&&
classifyObj
.
poker15
.
length
===
3
){
pokerThree
=
classifyObj
.
poker15
;
if
(
pokerFour
&&
one1
&&
one2
){
obj
=
{
type
:
type
,
poker
:
pokerFour
.
concat
(
one1
).
concat
(
one2
),
four
:
pokerFour
,
};
}
if
(
!
two
&&
classifyObj
.
poker15
.
length
>
1
){
two
=
classifyObj
.
poker15
.
slice
(
0
,
2
);
}
else
if
(
type
===
'
fourWithTwo
'
){
let
pokerFour
;
let
two1
;
let
two2
;
if
(
classifyObj
.
four
.
length
>
0
){
for
(
let
i
=
0
;
i
<
classifyObj
.
four
.
length
;
i
++
){
if
(
classifyObj
.
four
[
i
][
0
].
number
>
lastObj
.
four
[
0
].
number
){
pokerFour
=
classifyObj
.
four
[
i
];
break
;
}
}
}
if
(
pokerThree
&&
two
){
if
(
classifyObj
.
two
.
length
>
1
){
two1
=
classifyObj
.
two
[
0
];
two2
=
classifyObj
.
two
[
1
];
}
if
(
pokerFour
&&
two1
&&
two2
){
obj
=
{
type
:
type
,
poker
:
pokerThree
.
concat
(
two
),
three
:
pokerThree
,
two
:
two
,
poker
:
pokerFour
.
concat
(
two1
).
concat
(
two2
),
four
:
pokerFour
,
};
}
}
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
for
(
let
i
=
0
;
i
<
classifyObj
.
threeList
.
length
;
i
++
){
if
(
classifyObj
.
threeList
[
i
].
length
===
lastObj
.
list
.
length
&&
classifyObj
.
threeList
[
i
][
0
][
0
].
number
>
lastObj
.
list
[
0
].
three
[
0
].
number
){
if
(
classifyObj
.
one
.
length
>=
classifyObj
.
threeList
[
i
].
length
){
let
pokerThree
=
classifyObj
.
threeList
[
i
].
flat
(
1
);
let
pokerOne
=
classifyObj
.
one
.
slice
(
0
,
classifyObj
.
threeList
[
i
].
length
).
flat
(
1
);
obj
=
{
type
:
type
,
poker
:
pokerThree
.
concat
(
pokerOne
),
list
:
classifyObj
.
threeList
[
i
].
map
(
function
(
item
)
{
return
{
three
:
item
};
}),
};
}),
};
}
break
;
}
}
}
}
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
for
(
let
i
=
0
;
i
<
classifyObj
.
threeList
.
length
;
i
++
){
if
(
classifyObj
.
threeList
[
i
].
length
===
lastObj
.
list
.
length
&&
classifyObj
.
threeList
[
i
][
0
][
0
].
number
>
lastObj
.
list
[
0
].
three
[
0
].
number
){
if
(
classifyObj
.
two
.
length
>=
classifyObj
.
threeList
[
i
].
length
){
let
pokerThree
=
classifyObj
.
threeList
[
i
].
flat
(
1
);
let
pokerTwo
=
classifyObj
.
two
.
slice
(
0
,
classifyObj
.
threeList
[
i
].
length
).
flat
(
1
);
obj
=
{
type
:
type
,
poker
:
pokerThree
.
concat
(
pokerTwo
),
list
:
classifyObj
.
threeList
[
i
].
map
(
function
(
item
)
{
return
{
three
:
item
};
}),
};
}),
};
}
break
;
}
}
}
}
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
,
}
}),
};
for
(
let
i
=
0
;
i
<
classifyObj
.
oneList
.
length
;
i
++
)
{
if
(
classifyObj
.
oneList
[
i
].
length
===
lastObj
.
list
.
length
&&
classifyObj
.
oneList
[
i
][
0
][
0
].
number
>
lastObj
.
list
[
0
].
one
[
0
].
number
)
{
obj
=
{
type
:
type
,
poker
:
classifyObj
.
oneList
[
i
].
flat
(
1
),
list
:
classifyObj
.
oneList
[
i
].
map
(
function
(
item
)
{
return
{
one
:
item
,
}
}),
};
break
;
}
}
}
}
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
,
}
}),
};
for
(
let
i
=
0
;
i
<
classifyObj
.
twoList
.
length
;
i
++
)
{
if
(
classifyObj
.
twoList
[
i
].
length
===
lastObj
.
list
.
length
&&
classifyObj
.
twoList
[
i
][
0
][
0
].
number
>
lastObj
.
list
[
0
].
two
[
0
].
number
)
{
obj
=
{
type
:
type
,
poker
:
classifyObj
.
twoList
[
i
].
flat
(
1
),
list
:
classifyObj
.
twoList
[
i
].
map
(
function
(
item
)
{
return
{
two
:
item
,
}
}),
};
break
;
}
}
}
}
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
,
}
}),
};
for
(
let
i
=
0
;
i
<
classifyObj
.
threeList
.
length
;
i
++
)
{
if
(
classifyObj
.
threeList
[
i
].
length
===
lastObj
.
list
.
length
&&
classifyObj
.
threeList
[
i
][
0
][
0
].
number
>
lastObj
.
list
[
0
].
three
[
0
].
number
)
{
obj
=
{
type
:
type
,
poker
:
classifyObj
.
threeList
[
i
].
flat
(
1
),
list
:
classifyObj
.
threeList
[
i
].
map
(
function
(
item
)
{
return
{
three
:
item
,
}
}),
};
break
;
}
}
}
}
else
if
(
type
===
'
sx
'
){
if
(
classifyObj
.
poker16
.
length
>
0
&&
classifyObj
.
poker17
.
length
>
0
){
...
...
src/doudizhu/Poker.js
浏览文件 @
45347a06
...
...
@@ -167,23 +167,25 @@ class Poker{
three
:
Count3List
[
0
],
two
:
Count2List
[
0
],
};
}
else
if
(
Count4List
.
length
===
1
&&
Count1List
.
length
===
1
){
}
}
else
if
(
pokerList
.
length
===
6
){
if
(
Count4List
.
length
===
1
&&
Count1List
.
length
===
2
){
return
{
type
:
'
fourWithOne
'
,
poker
:
pokerList
,
four
:
Count4List
[
0
],
one
:
Count1List
[
0
],
};
}
}
else
if
(
pokerList
.
length
===
6
){
}
else
if
(
pokerList
.
length
===
8
){
if
(
Count4List
.
length
===
1
&&
Count2List
.
length
===
1
){
if
(
Count4List
.
length
===
1
&&
Count2List
.
length
===
2
){
return
{
type
:
'
fourWithTwo
'
,
poker
:
pokerList
,
four
:
Count4List
[
0
],
two
:
Count2List
[
0
],
};
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录