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
1d44fbd4
Commit
1d44fbd4
authored
Apr 27, 2019
by
hosein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playground -> ifMoveWillCheck added
parent
ae8e9955
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
40 deletions
+11
-40
Bishop.java
src/pack/Nuts/Bishop.java
+2
-8
King.java
src/pack/Nuts/King.java
+2
-7
Knight.java
src/pack/Nuts/Knight.java
+2
-5
Pawn.java
src/pack/Nuts/Pawn.java
+0
-5
Queen.java
src/pack/Nuts/Queen.java
+3
-8
Rook.java
src/pack/Nuts/Rook.java
+2
-7
No files found.
src/pack/Nuts/Bishop.java
View file @
1d44fbd4
...
...
@@ -32,13 +32,7 @@ public class Bishop extends Nut {
@Override
public
boolean
canMove
(
int
[]
destination
)
{
if
(
x
==
destination
[
0
])
return
false
;
else
return
Math
.
abs
((
y
-
destination
[
1
])
/
(
x
-
destination
[
0
]))
==
1
;
}
@Override
public
void
changeAlive
()
{
isAlive
=
false
;
else
return
Math
.
abs
((
float
)
(
y
-
destination
[
1
])
/
(
float
)
(
x
-
destination
[
0
]))
==
1.0
;
}
@Override
...
...
@@ -51,7 +45,7 @@ public class Bishop extends Nut {
if
(
destination
[
1
]
<
y
)
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
>
-
1
&&
i
!=
destination
[
0
]
&&
j
>
-
1
&&
j
!=
destination
[
1
];
i
+=
X
,
j
+=
Y
)
if
(
ground
[
i
][
j
]
!=
0
)
return
false
;
...
...
src/pack/Nuts/King.java
View file @
1d44fbd4
...
...
@@ -10,7 +10,7 @@ public class King extends Nut {
y
=
4
;
}
else
{
x
=
0
;
y
=
3
;
y
=
4
;
}
}
...
...
@@ -31,12 +31,7 @@ public class King extends Nut {
return
r
;
}
@Override
public
void
changeAlive
()
{
isAlive
=
false
;
}
@Override
@Override
public
boolean
canRoute
(
int
[]
destination
,
int
[][]
ground
)
{
return
true
;
}
...
...
src/pack/Nuts/Knight.java
View file @
1d44fbd4
...
...
@@ -37,13 +37,10 @@ public class Knight extends Nut {
return
Math
.
pow
(
destination
[
0
]
-
x
,
2
)
+
Math
.
pow
(
destination
[
1
]
-
y
,
2
)
==
5
;
}
@Override
public
void
changeAlive
()
{
isAlive
=
false
;
}
@Override
public
boolean
canRoute
(
int
[]
destination
,
int
[][]
ground
)
{
return
true
;
}
}
src/pack/Nuts/Pawn.java
View file @
1d44fbd4
...
...
@@ -31,11 +31,6 @@ public class Pawn extends Nut {
}
}
@Override
public
void
changeAlive
()
{
isAlive
=
false
;
}
@Override
public
boolean
canRoute
(
int
[]
destination
,
int
[][]
ground
)
{
if
(
Math
.
abs
(
destination
[
0
]
-
x
)
==
2
&&
ground
[(
x
+
destination
[
0
])
/
2
][
y
]
!=
0
)
return
false
;
...
...
src/pack/Nuts/Queen.java
View file @
1d44fbd4
...
...
@@ -30,25 +30,20 @@ public class Queen extends Nut {
}
}
@Override
public
void
changeAlive
()
{
isAlive
=
false
;
}
@Override
public
boolean
canRoute
(
int
[]
destination
,
int
[][]
ground
)
{
if
(
destination
[
0
]
==
x
)
{
int
t
;
if
(
destination
[
1
]
-
y
>
0
)
t
=
1
;
else
t
=
-
1
;
for
(
int
i
=
y
+
t
;
i
!=
destination
[
1
];
i
+=
t
)
for
(
int
i
=
y
;
i
!=
destination
[
1
];
i
+=
t
)
if
(
ground
[
x
][
i
]
!=
0
)
return
false
;
}
else
if
(
destination
[
1
]
==
y
)
{
int
t
;
if
(
destination
[
0
]
-
x
>
0
)
t
=
1
;
else
t
=
-
1
;
for
(
int
i
=
x
+
t
;
i
!=
destination
[
0
];
i
+=
t
)
for
(
int
i
=
x
;
i
!=
destination
[
0
];
i
+=
t
)
if
(
ground
[
i
][
y
]
!=
0
)
return
false
;
}
...
...
@@ -61,7 +56,7 @@ public class Queen extends Nut {
if
(
destination
[
1
]
<
y
)
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
>
-
1
&&
i
!=
destination
[
0
]
&&
j
>
-
1
&&
j
!=
destination
[
1
];
i
+=
X
,
j
+=
Y
)
if
(
ground
[
i
][
j
]
!=
0
)
return
false
;
...
...
src/pack/Nuts/Rook.java
View file @
1d44fbd4
...
...
@@ -35,25 +35,20 @@ public class Rook extends Nut {
return
x
==
destination
[
0
]
||
y
==
destination
[
1
];
}
@Override
public
void
changeAlive
()
{
isAlive
=
false
;
}
@Override
public
boolean
canRoute
(
int
[]
destination
,
int
[][]
ground
)
{
if
(
destination
[
0
]
==
x
)
{
int
t
;
if
(
destination
[
1
]
-
y
>
0
)
t
=
1
;
else
t
=
-
1
;
for
(
int
i
=
y
+
t
;
i
!=
destination
[
1
];
i
+=
t
)
for
(
int
i
=
y
;
i
!=
destination
[
1
];
i
+=
t
)
if
(
ground
[
x
][
i
]
!=
0
)
return
false
;
}
else
{
int
t
;
if
(
destination
[
0
]
-
x
>
0
)
t
=
1
;
else
t
=
-
1
;
for
(
int
i
=
x
+
t
;
i
!=
destination
[
0
];
i
+=
t
)
for
(
int
i
=
x
;
i
!=
destination
[
0
];
i
+=
t
)
if
(
ground
[
i
][
y
]
!=
0
)
return
false
;
}
...
...
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