Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
qwgame
Project
Overview
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
赵国君
qwgame
Commits
2d109468
Commit
2d109468
authored
Nov 28, 2018
by
李进峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
neighbour matrix implement question
parent
20b6149a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
21 deletions
+29
-21
GameEnv.java
src/GameEnvironment/GameEnv.java
+29
-21
No files found.
src/GameEnvironment/GameEnv.java
View file @
2d109468
...
@@ -68,36 +68,43 @@ public class GameEnv implements Serializable{
...
@@ -68,36 +68,43 @@ public class GameEnv implements Serializable{
int
x
=
this
.
mapNames
.
get
(
placeMapTmp
.
get
(
tmp
));
int
x
=
this
.
mapNames
.
get
(
placeMapTmp
.
get
(
tmp
));
int
y
=
this
.
mapNames
.
get
(
placeMapTmp
.
get
(
idName
));
int
y
=
this
.
mapNames
.
get
(
placeMapTmp
.
get
(
idName
));
this
.
mapGraph
[
x
][
y
]
=
1
;
this
.
mapGraph
[
x
][
y
]
=
1
;
// 有方向的添加
// this.mapGraph[y][x] = 1;
}
}
placeIndex
.
get
(
placeMapTmp
.
get
(
tmp
)).
setAbleGo
(
ableGos
);
placeIndex
.
get
(
placeMapTmp
.
get
(
tmp
)).
setAbleGo
(
ableGos
);
}
}
// 映射index -> map name
this
.
mapIndexName
=
new
String
[
mapGraph
.
length
];
for
(
i
=
0
;
i
<
mapGraph
.
length
;
i
++)
{
for
(
i
=
0
;
i
<
mapGraph
.
length
;
i
++)
{
for
(
String
mapName:
mapNames
.
keySet
())
{
for
(
String
mapName:
mapNames
.
keySet
())
{
if
(
mapNames
.
get
(
mapName
).
equals
(
i
))
{
if
(
mapNames
.
get
(
mapName
).
equals
(
i
))
{
System
.
out
.
print
(
mapName
+
"\t"
)
;
mapIndexName
[
i
]
=
mapName
;
}
}
}
}
}
}
// 映射index -> map name
this
.
mapIndexName
=
new
String
[
mapGraph
.
length
];
System
.
out
.
println
(
"\n"
);
System
.
out
.
print
(
"\t"
);
for
(
i
=
0
;
i
<
mapGraph
.
length
;
i
++)
{
for
(
i
=
0
;
i
<
mapGraph
.
length
;
i
++)
{
for
(
String
mapName:
mapNames
.
keySet
())
{
for
(
String
mapName:
mapNames
.
keySet
())
{
if
(
mapNames
.
get
(
mapName
).
equals
(
i
))
{
if
(
mapNames
.
get
(
mapName
).
equals
(
i
))
{
mapIndexName
[
i
]
=
mapName
;
System
.
out
.
print
(
mapName
+
"\t"
)
;
}
}
}
}
}
}
// for(i=0; i<this.mapGraph.length; i++) {
System
.
out
.
print
(
"\n"
);
// for(String mapName:mapNames.keySet()) {
for
(
i
=
0
;
i
<
this
.
mapGraph
.
length
;
i
++)
{
// if(mapNames.get(mapName).equals(i)) {
for
(
String
mapName:
mapNames
.
keySet
())
{
// System.out.print(mapName+"\t");
if
(
mapNames
.
get
(
mapName
).
equals
(
i
))
{
// }
System
.
out
.
print
(
mapName
+
"\t"
);
// }
}
// for(int j=0; j<this.mapGraph[i].length; j++) {
}
// System.out.print(this.mapGraph[i][j]+"\t");
for
(
int
j
=
0
;
j
<
this
.
mapGraph
[
i
].
length
;
j
++)
{
// }
System
.
out
.
print
(
this
.
mapGraph
[
i
][
j
]+
"\t"
);
// System.out.print("\n\n");
}
// }
System
.
out
.
print
(
"\n\n"
);
}
}
}
// npc
// npc
// npc class
// npc class
...
@@ -282,10 +289,11 @@ public class GameEnv implements Serializable{
...
@@ -282,10 +289,11 @@ public class GameEnv implements Serializable{
// 我现在能去哪
// 我现在能去哪
public
List
<
String
>
queryCanGoBySite
(
String
site
){
public
List
<
String
>
queryCanGoBySite
(
String
site
){
List
<
String
>
ableGoString
=
new
ArrayList
<
String
>();
List
<
String
>
ableGoString
=
new
ArrayList
<
String
>();
Place
place
=
this
.
placeIndex
.
get
(
site
);
int
x
=
this
.
mapNames
.
get
(
site
);
List
<
Place
>
ableGos
=
place
.
getAbleGo
();
for
(
int
i
=
0
;
i
<
this
.
mapGraph
[
x
].
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
ableGos
.
size
();
i
++)
{
if
(
this
.
mapGraph
[
x
][
i
]==
1
)
{
ableGoString
.
add
(
ableGos
.
get
(
i
).
getName
());
ableGoString
.
add
(
this
.
mapIndexName
[
i
]);
}
}
}
return
ableGoString
;
return
ableGoString
;
}
}
...
@@ -297,9 +305,9 @@ public class GameEnv implements Serializable{
...
@@ -297,9 +305,9 @@ public class GameEnv implements Serializable{
int
x
=
this
.
mapNames
.
get
(
placeA
);
int
x
=
this
.
mapNames
.
get
(
placeA
);
int
y
=
this
.
mapNames
.
get
(
placeB
);
int
y
=
this
.
mapNames
.
get
(
placeB
);
if
(
this
.
mapGraph
[
x
][
y
]
==
1
)
{
if
(
this
.
mapGraph
[
x
][
y
]
==
1
)
{
return
2
;
}
else
{
return
1
;
return
1
;
}
else
{
return
2
;
}
}
}
}
}
}
...
...
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