Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
police
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
9611046
police
Commits
92929a35
Commit
92929a35
authored
Apr 21, 2019
by
9611046
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
smartMove adds
parent
1b0bf0d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
1 deletion
+76
-1
Move.java
src/Move.java
+76
-1
No files found.
src/Move.java
View file @
92929a35
...
...
@@ -3,6 +3,8 @@ import java.util.Random;
public
class
Move
{
private
int
x
;
private
int
y
;
private
int
w
;
private
int
z
;
private
Land
moveLand
;
public
Move
(
int
x
,
int
y
,
Land
land
){
...
...
@@ -10,7 +12,14 @@ public class Move {
this
.
y
=
y
;
moveLand
=
land
;
}
public
Move
(
int
x
,
int
y
,
int
w
,
int
z
,
Land
land
){
this
.
x
=
x
;
this
.
y
=
y
;
this
.
w
=
w
;
this
.
z
=
z
;
moveLand
=
land
;
}
//Random Move
public
void
moveXY
(){
Random
rand
=
new
Random
();
int
a
=
rand
.
nextInt
(
8
);
...
...
@@ -91,10 +100,76 @@ public class Move {
}
}
public
void
smartMove
(){
// Random random = new Random();
//This is the smart move of police and thief x,y are PoliceX, PoliceY and w, z are thiefX, thiefY
if
(
x
>
w
){
if
(
y
>
z
){
y
-=
1
;
x
-=
1
;
if
(
w
>
0
)
{
w
-=
1
;}
if
(
z
>
0
){
z
-=
1
;}
}
else
if
(
y
<
z
){
x
-=
1
;
y
+=
1
;
if
(
w
>
0
)
w
-=
1
;
if
(
z
+
1
<
moveLand
.
getLength
())
z
+=
1
;
}
else
{
x
-=
1
;
if
(
w
>
0
)
w
-=
1
;
}
}
else
if
(
x
<
w
){
if
(
y
>
z
){
y
-=
1
;
x
+=
1
;
if
(
w
+
1
<
moveLand
.
getWidth
())
w
+=
1
;
if
(
z
>
0
)
z
-=
1
;
}
else
if
(
y
<
z
){
x
+=
1
;
y
+=
1
;
if
(
w
+
1
<
moveLand
.
getWidth
())
w
++;
if
(
z
+
1
<
moveLand
.
getLength
())
z
++;
}
else
{
x
++;
if
(
w
+
1
<
moveLand
.
getWidth
())
w
++;
}
}
else
{
if
(
y
>
z
){
y
--;
if
(
z
>
0
)
z
--;
}
else
if
(
y
<
z
){
y
++;
if
(
z
+
1
<
moveLand
.
getLength
())
z
++;
}
}
}
public
int
getX
(){
return
x
;
}
public
int
getY
(){
return
y
;
}
public
int
getW
(){
return
w
;
}
public
int
getZ
(){
return
z
;
}
}
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