Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
police and thief
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
police and thief
Commits
f576bb2b
Commit
f576bb2b
authored
Apr 19, 2019
by
hosein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
police -> cleaned warnings
parent
663ee50c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
89 deletions
+1
-89
Police.java
src/pack/Police.java
+1
-89
No files found.
src/pack/Police.java
View file @
f576bb2b
...
...
@@ -4,12 +4,10 @@ import java.util.Random;
public
class
Police
{
private
int
x
,
y
;
private
static
boolean
see
;
Police
(
int
x
,
int
y
)
{
this
.
x
=
x
;
this
.
y
=
y
;
see
=
false
;
}
public
void
randomMove
(
int
n
,
int
m
,
PlayGround
playGround
)
{
...
...
@@ -20,13 +18,10 @@ public class Police {
if
(
y
!=
0
)
j
=
true
;
if
(
y
!=
m
-
1
)
J
=
true
;
if
(!
i
&&
!
I
&&
!
j
&&
!
J
)
System
.
out
.
println
(
"truuuuuuuuuuuuuuuuuue nistan // police -> random move"
);
Random
random
=
new
Random
();
boolean
confirm
=
false
;
int
X
=
0
,
Y
=
0
;
System
.
out
.
println
(
"x = "
+
x
+
" y = "
+
y
+
"\n i "
+
i
+
"\n I "
+
I
+
"\n j "
+
j
+
"\n J "
+
J
);
do
{
switch
(
random
.
nextInt
(
8
))
{
case
0
:
...
...
@@ -128,76 +123,9 @@ public class Police {
playGround
.
changeSituation
(
x
,
y
,
newSituation
[
0
][
0
],
newSituation
[
0
][
1
],
1
);
x
=
newSituation
[
0
][
0
];
y
=
newSituation
[
0
][
1
];
int
c
=
0
;
for
(
int
j
,
z
=
0
;
z
<
playGround
.
getNM
()[
0
][
0
];
z
++)
for
(
j
=
0
;
j
<
playGround
.
getNM
()[
0
][
1
];
j
++)
if
(
playGround
.
getGround
()[
z
][
j
]
==
1
)
c
++;
System
.
out
.
println
(
"c2 ============== "
+
c
+
"\n"
);
}
public
void
targetedMove2
(
int
[][]
thiefSituation
,
PlayGround
playGround
)
{
int
X
=
thiefSituation
[
0
][
0
],
Y
=
thiefSituation
[
0
][
1
];
int
[][]
newSituation
=
new
int
[
1
][
2
];
switch
((
int
)
(
1000
*
(
Math
.
sqrt
(
Math
.
pow
(
X
-
x
,
2
)
+
Math
.
pow
(
Y
-
y
,
2
))
-
Math
.
sqrt
(
Math
.
pow
(
X
-
0.3
-
x
,
2
)
+
Math
.
pow
(
Y
-
0.4
-
getY
(),
2
)))))
{
case
493
:
// up, left
case
433
:
case
489
:
case
492
:
newSituation
=
confirmTargetMove
(
x
,
y
,
8
,
playGround
);
break
;
case
193
:
// up
case
253
:
newSituation
=
confirmTargetMove
(
x
,
y
,
7
,
playGround
);
break
;
case
33
:
case
-
112
:
case
-
151
:
case
-
263
:
//up, right
newSituation
=
confirmTargetMove
(
x
,
y
,
6
,
playGround
);
break
;
case
372
:
case
329
:
//left
newSituation
=
confirmTargetMove
(
x
,
y
,
5
,
playGround
);
break
;
case
-
431
:
case
-
418
:
//right
newSituation
=
confirmTargetMove
(
x
,
y
,
4
,
playGround
);
break
;
case
174
:
case
-
17
:
case
-
140
:
case
26
:
//down, left
newSituation
=
confirmTargetMove
(
x
,
y
,
3
,
playGround
);
break
;
case
-
360
:
case
-
334
:
//down
newSituation
=
confirmTargetMove
(
x
,
y
,
2
,
playGround
);
break
;
case
-
496
:
case
-
493
:
case
-
456
:
case
-
495
:
//down, right
newSituation
=
confirmTargetMove
(
x
,
y
,
1
,
playGround
);
}
playGround
.
changeSituation
(
x
,
y
,
newSituation
[
0
][
0
],
newSituation
[
0
][
1
],
1
);
}
public
int
[][]
confirmTargetMove
(
int
x
,
int
y
,
int
destination
,
PlayGround
p
)
{
private
int
[][]
confirmTargetMove
(
int
x
,
int
y
,
int
destination
,
PlayGround
p
)
{
int
[][]
newSituation
=
new
int
[
1
][
2
];
Random
r
=
new
Random
();
...
...
@@ -405,20 +333,4 @@ public class Police {
}
return
newSituation
;
}
public
int
[][]
getSituation
()
{
int
[][]
Return
=
new
int
[
1
][
1
];
Return
[
0
][
0
]
=
x
;
Return
[
0
][
1
]
=
y
;
return
Return
;
}
public
int
getX
()
{
return
x
;
}
public
int
getY
()
{
return
y
;
}
}
\ 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