Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
6
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
W
wordbase-hacker
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PurkkaKoodari
wordbase-hacker
Commits
5321181c
Commit
5321181c
authored
Sep 09, 2017
by
PurkkaKoodari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slight performance improvement, remove performance tests
parent
d326e41c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
25 deletions
+16
-25
app/src/main/java/net/pietu1998/wordbasehacker/solver/Board.java
.../main/java/net/pietu1998/wordbasehacker/solver/Board.java
+14
-23
app/src/main/java/net/pietu1998/wordbasehacker/solver/Possibility.java
...java/net/pietu1998/wordbasehacker/solver/Possibility.java
+2
-2
No files found.
app/src/main/java/net/pietu1998/wordbasehacker/solver/Board.java
View file @
5321181c
...
...
@@ -65,18 +65,12 @@ public class Board {
}
public
void
findWords
()
{
long
start
=
System
.
currentTimeMillis
();
for
(
int
iteration
=
0
;
iteration
<
500
;
iteration
++)
{
boolean
positions
[]
=
new
boolean
[
130
];
byte
coords
[]
=
new
byte
[
24
];
for
(
int
y
=
0
,
index
=
0
;
y
<
13
;
y
++)
for
(
int
x
=
0
;
x
<
10
;
x
++,
index
++)
if
((
tileStates
[
index
]
&
Tile
.
PLAYER
)
!=
0
)
findWordsRecursive
(
tileMappedLetters
,
0
,
x
,
y
,
index
,
coords
,
positions
,
root
,
results
);
if
(
iteration
<
499
)
results
.
clear
();
}
long
end
=
System
.
currentTimeMillis
();
Log
.
d
(
"WordbaseHacker"
,
"Finding took "
+
(
end
-
start
)
+
"ms"
);
boolean
positions
[]
=
new
boolean
[
130
];
byte
coords
[]
=
new
byte
[
24
];
for
(
int
y
=
0
,
index
=
0
;
y
<
13
;
y
++)
for
(
int
x
=
0
;
x
<
10
;
x
++,
index
++)
if
((
tileStates
[
index
]
&
Tile
.
PLAYER
)
!=
0
)
findWordsRecursive
(
tileMappedLetters
,
0
,
x
,
y
,
index
,
coords
,
positions
,
root
,
results
);
}
private
void
findWordsRecursive
(
short
[]
tiles
,
int
length
,
int
x
,
int
y
,
int
index
,
byte
[]
coords
,
boolean
[]
positions
,
TrieNode
node
,
List
<
Possibility
>
results
)
{
...
...
@@ -105,21 +99,19 @@ public class Board {
}
public
void
scoreWords
(
boolean
flipped
)
{
long
start
=
System
.
currentTimeMillis
();
for
(
int
iteration
=
0
;
iteration
<
100
;
iteration
++)
for
(
Possibility
pos
:
results
)
{
scoreWord
(
pos
,
flipped
);
pos
.
setTileLetters
(
tileLetters
);
}
long
end
=
System
.
currentTimeMillis
();
Log
.
d
(
"WordbaseHacker"
,
"Scoring took "
+
(
end
-
start
)
+
"ms"
);
int
[]
newStates
=
new
int
[
130
];
boolean
[]
connected
=
new
boolean
[
130
];
for
(
Possibility
pos
:
results
)
{
scoreWord
(
pos
,
newStates
,
connected
,
flipped
);
pos
.
setTileLetters
(
tileLetters
);
}
}
private
void
scoreWord
(
Possibility
pos
,
boolean
flipped
)
{
int
[]
newStates
=
new
int
[
130
];
private
void
scoreWord
(
Possibility
pos
,
int
[]
newStates
,
boolean
[]
connected
,
boolean
flipped
)
{
int
oldMines
=
0
,
oldPlayer
=
0
,
oldOpponent
=
0
,
oldDistPlayer
=
0
,
oldDistOpponent
=
0
;
for
(
int
y
=
0
,
index
=
0
;
y
<
13
;
y
++)
{
for
(
int
x
=
0
;
x
<
10
;
x
++,
index
++)
{
connected
[
index
]
=
false
;
int
state
=
newStates
[
index
]
=
tileStates
[
index
];
if
((
state
&
Tile
.
PLAYER
)
!=
0
)
{
oldPlayer
++;
...
...
@@ -140,7 +132,6 @@ public class Board {
takeTile
(
newStates
,
x
,
y
,
x
+
10
*
y
);
}
boolean
[]
connected
=
new
boolean
[
130
];
int
baseY
=
flipped
?
0
:
12
;
int
offset
=
10
*
baseY
;
for
(
int
x
=
0
;
x
<
10
;
x
++)
...
...
app/src/main/java/net/pietu1998/wordbasehacker/solver/Possibility.java
View file @
5321181c
...
...
@@ -9,7 +9,7 @@ public class Possibility {
@NonNull
private
String
word
;
private
Score
score
;
private
int
[]
result
;
private
int
[]
result
=
new
int
[
130
]
;
private
char
[]
tileLetters
;
public
Possibility
(
@NonNull
byte
[]
coordinates
,
@NonNull
String
word
)
{
...
...
@@ -30,7 +30,7 @@ public class Possibility {
}
public
void
setResult
(
int
[]
result
)
{
this
.
result
=
result
;
System
.
arraycopy
(
result
,
0
,
this
.
result
,
0
,
130
)
;
}
public
char
[]
getTileLetters
()
{
...
...
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