Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
chess
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9731075
chess
Commits
ae8e9955
Commit
ae8e9955
authored
Apr 26, 2019
by
hosein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playground -> ifMoveWillCheck added
parent
947240a2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
20 deletions
+20
-20
PlayGround.java
src/pack/PlayGround.java
+20
-20
No files found.
src/pack/PlayGround.java
View file @
ae8e9955
...
...
@@ -120,17 +120,8 @@ public class PlayGround {
return
2
;
Nut
j
=
null
;
//4 check
for
(
Nut
i
:
nutsID
.
keySet
())
{
if
(
nutsID
.
get
(
i
)
==
id1
)
{
j
=
i
;
i
.
move
(
getDestination
(
string
[
1
].
charAt
(
0
),
(
short
)
(
string
[
1
].
charAt
(
1
))),
ground
);
break
;
}
}
isCheck
(
turn
);
j
.
move
(
getDestination
(
string
[
0
].
charAt
(
0
),
(
short
)
(
string
[
0
].
charAt
(
1
))),
ground
);
//4 check
ifMoveWillCheck
(
getDestination
((
string
[
0
].
charAt
(
0
))
,
(
short
)
(
string
[
0
].
charAt
(
1
))),
getDestination
(
string
[
1
].
charAt
(
0
),
(
short
)
(
string
[
1
].
charAt
(
1
))),
turn
);
if
(
getCheck
())
return
4
;
...
...
@@ -158,6 +149,16 @@ public class PlayGround {
return
1
;
//1 can move
}
private
void
ifMoveWillCheck
(
int
[]
origin
,
int
[]
destination
,
int
turn
)
{
int
id1
=
ground
[
origin
[
0
]][
origin
[
1
]],
id2
=
ground
[
destination
[
0
]][
destination
[
1
]];
ground
[
origin
[
0
]][
origin
[
1
]]
=
0
;
ground
[
destination
[
0
]][
destination
[
1
]]
=
id1
;
isCheck
(
turn
);
getCheck
();
ground
[
origin
[
0
]][
origin
[
1
]]
=
id1
;
ground
[
destination
[
0
]][
destination
[
1
]]
=
id2
;
}
public
void
moveNut
(
String
[]
string
)
{
int
id2
=
getNutID
(
string
[
1
].
charAt
(
0
),
(
short
)
string
[
1
].
charAt
(
1
)),
id1
=
getNutID
(
string
[
0
].
charAt
(
0
),
(
short
)
string
[
0
].
charAt
(
1
));
if
(
id2
!=
0
)
...
...
@@ -204,11 +205,10 @@ public class PlayGround {
if
((
bQueen
.
canMove
(
wKing
.
getXY
())
&&
bQueen
.
canRoute
(
wKing
.
getXY
(),
ground
))
||
(
bRooks
[
0
].
canMove
(
wKing
.
getXY
())
&&
bRooks
[
0
].
canRoute
(
wKing
.
getXY
(),
ground
))
||
(
bRooks
[
1
].
canMove
(
wKing
.
getXY
())
&&
bRooks
[
1
].
canRoute
(
wKing
.
getXY
(),
ground
))
||
(
bKnights
[
0
].
canMove
(
wKing
.
getXY
())
&&
bKnights
[
0
].
canRoute
(
wKing
.
getXY
(),
ground
)
)
||
(
bKnights
[
1
].
canMove
(
wKing
.
getXY
())
&&
bKnights
[
1
].
canRoute
(
wKing
.
getXY
(),
ground
)
)
||
(
bKnights
[
0
].
canMove
(
wKing
.
getXY
()))
||
(
bKnights
[
1
].
canMove
(
wKing
.
getXY
()))
||
(
bBishops
[
0
].
canMove
(
wKing
.
getXY
())
&&
bBishops
[
0
].
canRoute
(
wKing
.
getXY
(),
ground
))
||
(
bBishops
[
1
].
canMove
(
wKing
.
getXY
())
&&
bBishops
[
1
].
canRoute
(
wKing
.
getXY
(),
ground
))
)
{
(
bBishops
[
1
].
canMove
(
wKing
.
getXY
())
&&
bBishops
[
1
].
canRoute
(
wKing
.
getXY
(),
ground
)))
{
check
=
true
;
return
;
}
...
...
@@ -221,16 +221,15 @@ public class PlayGround {
if
((
wQueen
.
canMove
(
bKing
.
getXY
())
&&
wQueen
.
canRoute
(
bKing
.
getXY
(),
ground
))
||
(
wRooks
[
0
].
canMove
(
bKing
.
getXY
())
&&
wRooks
[
0
].
canRoute
(
bKing
.
getXY
(),
ground
))
||
(
wRooks
[
1
].
canMove
(
bKing
.
getXY
())
&&
wRooks
[
1
].
canRoute
(
bKing
.
getXY
(),
ground
))
||
(
wKnights
[
0
].
canMove
(
bKing
.
getXY
())
&&
wKnights
[
0
].
canRoute
(
bKing
.
getXY
(),
ground
)
)
||
(
wKnights
[
1
].
canMove
(
bKing
.
getXY
())
&&
wKnights
[
1
].
canRoute
(
bKing
.
getXY
(),
ground
)
)
||
(
wKnights
[
0
].
canMove
(
bKing
.
getXY
()))
||
(
wKnights
[
1
].
canMove
(
bKing
.
getXY
()))
||
(
wBishops
[
0
].
canMove
(
bKing
.
getXY
())
&&
wBishops
[
0
].
canRoute
(
bKing
.
getXY
(),
ground
))
||
(
wBishops
[
1
].
canMove
(
bKing
.
getXY
())
&&
wBishops
[
1
].
canRoute
(
bKing
.
getXY
(),
ground
))
)
{
(
wBishops
[
1
].
canMove
(
bKing
.
getXY
())
&&
(
wBishops
[
1
].
canRoute
(
bKing
.
getXY
(),
ground
))))
{
check
=
true
;
return
;
}
check
=
false
;
}
check
=
false
;
}
public
boolean
getCheck
()
{
...
...
@@ -321,4 +320,5 @@ public class PlayGround {
System
.
out
.
println
(
" ¯ ¯ ¯ ¯ ¯ ¯ ¯ ¯ "
);
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment