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
947240a2
Commit
947240a2
authored
Apr 26, 2019
by
hosein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nuts -> move updated
parent
41971b18
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
14 deletions
+20
-14
Bishop.java
src/pack/Nuts/Bishop.java
+1
-1
Nut.java
src/pack/Nuts/Nut.java
+3
-1
Pawn.java
src/pack/Nuts/Pawn.java
+9
-2
Queen.java
src/pack/Nuts/Queen.java
+4
-4
Rook.java
src/pack/Nuts/Rook.java
+3
-6
No files found.
src/pack/Nuts/Bishop.java
View file @
947240a2
...
@@ -51,7 +51,7 @@ public class Bishop extends Nut {
...
@@ -51,7 +51,7 @@ public class Bishop extends Nut {
if
(
destination
[
1
]
<
y
)
Y
=
-
1
;
if
(
destination
[
1
]
<
y
)
Y
=
-
1
;
else
Y
=
1
;
else
Y
=
1
;
for
(
int
i
=
x
+
X
,
j
=
y
+
Y
;
i
=
=
destination
[
0
];
i
+=
X
,
j
+=
Y
)
for
(
int
i
=
x
+
X
,
j
=
y
+
Y
;
i
!
=
destination
[
0
];
i
+=
X
,
j
+=
Y
)
if
(
ground
[
i
][
j
]
!=
0
)
if
(
ground
[
i
][
j
]
!=
0
)
return
false
;
return
false
;
...
...
src/pack/Nuts/Nut.java
View file @
947240a2
...
@@ -4,9 +4,11 @@ public abstract class Nut {
...
@@ -4,9 +4,11 @@ public abstract class Nut {
protected
int
id
,
x
,
y
;
// 1 means white & -1 means black
protected
int
id
,
x
,
y
;
// 1 means white & -1 means black
protected
boolean
isAlive
;
protected
boolean
isAlive
;
public
void
move
(
int
[]
destination
)
{
public
void
move
(
int
[]
destination
,
int
[][]
g
)
{
g
[
x
][
y
]
=
0
;
x
=
destination
[
0
];
x
=
destination
[
0
];
y
=
destination
[
1
];
y
=
destination
[
1
];
g
[
x
][
y
]
=
id
;
}
}
public
abstract
boolean
canRoute
(
int
[]
destination
,
int
[][]
ground
);
public
abstract
boolean
canRoute
(
int
[]
destination
,
int
[][]
ground
);
...
...
src/pack/Nuts/Pawn.java
View file @
947240a2
...
@@ -23,7 +23,7 @@ public class Pawn extends Nut {
...
@@ -23,7 +23,7 @@ public class Pawn extends Nut {
@Override
@Override
public
boolean
canMove
(
int
[]
destination
)
{
public
boolean
canMove
(
int
[]
destination
)
{
if
(
id
>
0
)
{
if
(
id
>
0
)
{
if
(
x
==
6
&&
destination
[
0
]
-
x
==
2
&&
destination
[
1
]
==
y
)
return
true
;
if
(
x
==
6
&&
destination
[
0
]
-
x
==
-
2
&&
destination
[
1
]
==
y
)
return
true
;
return
destination
[
0
]
<
x
&&
destination
[
0
]
>=
x
-
1
&&
destination
[
1
]
<=
y
+
1
&&
destination
[
1
]
>=
y
-
1
;
return
destination
[
0
]
<
x
&&
destination
[
0
]
>=
x
-
1
&&
destination
[
1
]
<=
y
+
1
&&
destination
[
1
]
>=
y
-
1
;
}
else
{
}
else
{
if
(
x
==
1
&&
destination
[
0
]
-
x
==
2
&&
destination
[
1
]
==
y
)
return
true
;
if
(
x
==
1
&&
destination
[
0
]
-
x
==
2
&&
destination
[
1
]
==
y
)
return
true
;
...
@@ -38,10 +38,17 @@ public class Pawn extends Nut {
...
@@ -38,10 +38,17 @@ public class Pawn extends Nut {
@Override
@Override
public
boolean
canRoute
(
int
[]
destination
,
int
[][]
ground
)
{
public
boolean
canRoute
(
int
[]
destination
,
int
[][]
ground
)
{
if
(
destination
[
0
]
-
x
==
2
&&
ground
[(
x
+
destination
[
0
])/
2
][
y
]
!=
0
)
return
false
;
if
(
Math
.
abs
(
destination
[
0
]
-
x
)
==
2
&&
ground
[(
x
+
destination
[
0
])
/
2
][
y
]
!=
0
)
return
false
;
return
true
;
return
true
;
}
}
public
boolean
canCheck
(
int
[]
k
)
{
if
(
id
>
0
)
return
(
x
-
1
==
k
[
0
]
&&
y
-
1
==
k
[
1
])
||
(
x
-
1
==
k
[
0
]
&&
y
+
1
==
k
[
1
]);
else
return
(
x
+
1
==
k
[
0
]
&&
y
-
1
==
k
[
1
])
||
(
x
+
1
==
k
[
0
]
&&
y
+
1
==
k
[
1
]);
}
}
}
src/pack/Nuts/Queen.java
View file @
947240a2
...
@@ -41,14 +41,14 @@ public class Queen extends Nut {
...
@@ -41,14 +41,14 @@ public class Queen extends Nut {
int
t
;
int
t
;
if
(
destination
[
1
]
-
y
>
0
)
t
=
1
;
if
(
destination
[
1
]
-
y
>
0
)
t
=
1
;
else
t
=
-
1
;
else
t
=
-
1
;
for
(
int
i
=
y
+
t
;
i
<
destination
[
1
];
i
+=
t
)
for
(
int
i
=
y
+
t
;
i
!=
destination
[
1
];
i
+=
t
)
if
(
ground
[
x
][
i
]
!=
0
)
if
(
ground
[
x
][
i
]
!=
0
)
return
false
;
return
false
;
}
else
{
}
else
if
(
destination
[
1
]
==
y
)
{
int
t
;
int
t
;
if
(
destination
[
0
]
-
x
>
0
)
t
=
1
;
if
(
destination
[
0
]
-
x
>
0
)
t
=
1
;
else
t
=
-
1
;
else
t
=
-
1
;
for
(
int
i
=
x
+
t
;
i
<
destination
[
0
];
i
+=
t
)
for
(
int
i
=
x
+
t
;
i
!=
destination
[
0
];
i
+=
t
)
if
(
ground
[
i
][
y
]
!=
0
)
if
(
ground
[
i
][
y
]
!=
0
)
return
false
;
return
false
;
}
}
...
@@ -61,7 +61,7 @@ public class Queen extends Nut {
...
@@ -61,7 +61,7 @@ public class Queen extends Nut {
if
(
destination
[
1
]
<
y
)
Y
=
-
1
;
if
(
destination
[
1
]
<
y
)
Y
=
-
1
;
else
Y
=
1
;
else
Y
=
1
;
for
(
int
i
=
x
+
X
,
j
=
y
+
Y
;
i
=
=
destination
[
0
];
i
+=
X
,
j
+=
Y
)
for
(
int
i
=
x
+
X
,
j
=
y
+
Y
;
i
!
=
destination
[
0
];
i
+=
X
,
j
+=
Y
)
if
(
ground
[
i
][
j
]
!=
0
)
if
(
ground
[
i
][
j
]
!=
0
)
return
false
;
return
false
;
...
...
src/pack/Nuts/Rook.java
View file @
947240a2
...
@@ -46,14 +46,14 @@ public class Rook extends Nut {
...
@@ -46,14 +46,14 @@ public class Rook extends Nut {
int
t
;
int
t
;
if
(
destination
[
1
]
-
y
>
0
)
t
=
1
;
if
(
destination
[
1
]
-
y
>
0
)
t
=
1
;
else
t
=
-
1
;
else
t
=
-
1
;
for
(
int
i
=
y
+
t
;
i
<
destination
[
1
];
i
+=
t
)
for
(
int
i
=
y
+
t
;
i
!=
destination
[
1
];
i
+=
t
)
if
(
ground
[
x
][
i
]
!=
0
)
if
(
ground
[
x
][
i
]
!=
0
)
return
false
;
return
false
;
}
else
{
}
else
{
int
t
;
int
t
;
if
(
destination
[
0
]
-
x
>
0
)
t
=
1
;
if
(
destination
[
0
]
-
x
>
0
)
t
=
1
;
else
t
=
-
1
;
else
t
=
-
1
;
for
(
int
i
=
x
+
t
;
i
<
destination
[
0
];
i
+=
t
)
for
(
int
i
=
x
+
t
;
i
!=
destination
[
0
];
i
+=
t
)
if
(
ground
[
i
][
y
]
!=
0
)
if
(
ground
[
i
][
y
]
!=
0
)
return
false
;
return
false
;
}
}
...
@@ -61,8 +61,5 @@ public class Rook extends Nut {
...
@@ -61,8 +61,5 @@ public class Rook extends Nut {
}
}
}
}
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