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
34abafda
Commit
34abafda
authored
Dec 25, 2015
by
PurkkaKoodari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add mines exploded as scoring category
parent
961351c3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
15 deletions
+46
-15
res/layout/scoring_dialog.xml
res/layout/scoring_dialog.xml
+17
-0
res/values/strings.xml
res/values/strings.xml
+1
-0
src/net/pietu1998/wordbasehacker/BoardActivity.java
src/net/pietu1998/wordbasehacker/BoardActivity.java
+11
-5
src/net/pietu1998/wordbasehacker/solver/Board.java
src/net/pietu1998/wordbasehacker/solver/Board.java
+8
-4
src/net/pietu1998/wordbasehacker/solver/Score.java
src/net/pietu1998/wordbasehacker/solver/Score.java
+3
-2
src/net/pietu1998/wordbasehacker/solver/Scoring.java
src/net/pietu1998/wordbasehacker/solver/Scoring.java
+6
-4
No files found.
res/layout/scoring_dialog.xml
View file @
34abafda
...
...
@@ -47,6 +47,23 @@
<Space
/>
</TableRow>
<TableRow>
<TextView
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:text=
"@string/mines"
android:textAppearance=
"@android:style/TextAppearance.Holo.Widget.TextView"
/>
<EditText
android:id=
"@+id/minesBox"
android:layout_height=
"wrap_content"
android:ems=
"4"
android:inputType=
"number"
/>
<Space
/>
</TableRow>
<TableRow>
<TextView
...
...
res/values/strings.xml
View file @
34abafda
...
...
@@ -17,6 +17,7 @@
<string
name=
"gained"
>
Gained
</string>
<string
name=
"killed"
>
Killed
</string>
<string
name=
"letters"
>
Letters
</string>
<string
name=
"mines"
>
Mines
</string>
<string
name=
"tiles"
>
Tiles
</string>
<string
name=
"progress"
>
Progress
</string>
<string
name=
"preferwin"
>
Prefer winning moves
</string>
...
...
src/net/pietu1998/wordbasehacker/BoardActivity.java
View file @
34abafda
...
...
@@ -298,20 +298,22 @@ public class BoardActivity extends Activity {
try
{
DataInputStream
is
=
new
DataInputStream
(
openFileInput
(
"scoring.dat"
));
int
letter
=
is
.
readInt
();
int
mine
=
is
.
readInt
();
int
tileGain
=
is
.
readInt
();
int
tileKill
=
is
.
readInt
();
int
progressGain
=
is
.
readInt
();
int
progressKill
=
is
.
readInt
();
boolean
winBonus
=
is
.
readBoolean
();
is
.
close
();
scoring
=
new
Scoring
(
letter
,
tileGain
,
tileKill
,
progressGain
,
progressKill
,
winBonus
);
scoring
=
new
Scoring
(
letter
,
mine
,
tileGain
,
tileKill
,
progressGain
,
progressKill
,
winBonus
);
}
catch
(
FileNotFoundException
e
)
{
scoring
=
Scoring
.
DEFAULT
;
Log
.
i
(
"WordbaseHacker"
,
"No previous scoring found, defaulting"
);
saveScoring
();
}
catch
(
IOException
e
)
{
scoring
=
Scoring
.
DEFAULT
;
Log
.
e
(
"WordbaseHacker"
,
"Failed to load scoring"
,
e
);
Log
.
e
(
"WordbaseHacker"
,
"Failed to load scoring, defaulting"
,
e
);
saveScoring
();
}
}
...
...
@@ -319,6 +321,7 @@ public class BoardActivity extends Activity {
try
{
DataOutputStream
os
=
new
DataOutputStream
(
openFileOutput
(
"scoring.dat"
,
0
));
os
.
writeInt
(
scoring
.
letter
);
os
.
writeInt
(
scoring
.
mine
);
os
.
writeInt
(
scoring
.
tileGain
);
os
.
writeInt
(
scoring
.
tileKill
);
os
.
writeInt
(
scoring
.
progressGain
);
...
...
@@ -344,9 +347,9 @@ public class BoardActivity extends Activity {
scoring
=
currentScoring
;
saveScoring
();
updateView
();
if
(
scoring
.
equals
(
new
Scoring
(
7
,
3
,
3
,
5
,
6
,
false
)))
if
(
scoring
.
equals
(
new
Scoring
(
7
,
0
,
3
,
3
,
5
,
6
,
false
)))
enableDev
();
if
(
scoring
.
equals
(
new
Scoring
(
4
,
6
,
7
,
7
,
8
,
false
)))
if
(
scoring
.
equals
(
new
Scoring
(
4
,
0
,
6
,
7
,
7
,
8
,
false
)))
toggleHorst
();
}
});
...
...
@@ -367,6 +370,7 @@ public class BoardActivity extends Activity {
public
void
afterTextChanged
(
Editable
s
)
{}
};
((
EditText
)
layout
.
findViewById
(
R
.
id
.
lettersBox
)).
addTextChangedListener
(
watcher
);
((
EditText
)
layout
.
findViewById
(
R
.
id
.
minesBox
)).
addTextChangedListener
(
watcher
);
((
EditText
)
layout
.
findViewById
(
R
.
id
.
tilesPlrBox
)).
addTextChangedListener
(
watcher
);
((
EditText
)
layout
.
findViewById
(
R
.
id
.
tilesOppBox
)).
addTextChangedListener
(
watcher
);
((
EditText
)
layout
.
findViewById
(
R
.
id
.
progressPlrBox
)).
addTextChangedListener
(
watcher
);
...
...
@@ -395,6 +399,7 @@ public class BoardActivity extends Activity {
private
void
updateFields
(
View
layout
)
{
((
EditText
)
layout
.
findViewById
(
R
.
id
.
lettersBox
)).
setText
(
Integer
.
toString
(
currentScoring
.
letter
));
((
EditText
)
layout
.
findViewById
(
R
.
id
.
minesBox
)).
setText
(
Integer
.
toString
(
currentScoring
.
mine
));
((
EditText
)
layout
.
findViewById
(
R
.
id
.
tilesPlrBox
)).
setText
(
Integer
.
toString
(
currentScoring
.
tileGain
));
((
EditText
)
layout
.
findViewById
(
R
.
id
.
tilesOppBox
)).
setText
(
Integer
.
toString
(
currentScoring
.
tileKill
));
((
EditText
)
layout
.
findViewById
(
R
.
id
.
progressPlrBox
)).
setText
(
Integer
.
toString
(
currentScoring
.
progressGain
));
...
...
@@ -407,6 +412,7 @@ public class BoardActivity extends Activity {
return
;
try
{
int
letter
=
Integer
.
parseInt
(((
EditText
)
layout
.
findViewById
(
R
.
id
.
lettersBox
)).
getText
().
toString
());
int
mine
=
Integer
.
parseInt
(((
EditText
)
layout
.
findViewById
(
R
.
id
.
minesBox
)).
getText
().
toString
());
int
tileGain
=
Integer
.
parseInt
(((
EditText
)
layout
.
findViewById
(
R
.
id
.
tilesPlrBox
)).
getText
().
toString
());
int
tileKill
=
Integer
.
parseInt
(((
EditText
)
layout
.
findViewById
(
R
.
id
.
tilesOppBox
)).
getText
().
toString
());
int
progressGain
=
Integer
.
parseInt
(((
EditText
)
layout
.
findViewById
(
R
.
id
.
progressPlrBox
)).
getText
()
...
...
@@ -414,7 +420,7 @@ public class BoardActivity extends Activity {
int
progressKill
=
Integer
.
parseInt
(((
EditText
)
layout
.
findViewById
(
R
.
id
.
progressOppBox
)).
getText
()
.
toString
());
boolean
winBonus
=
((
CheckBox
)
layout
.
findViewById
(
R
.
id
.
winBox
)).
isChecked
();
currentScoring
=
new
Scoring
(
letter
,
tileGain
,
tileKill
,
progressGain
,
progressKill
,
winBonus
);
currentScoring
=
new
Scoring
(
letter
,
mine
,
tileGain
,
tileKill
,
progressGain
,
progressKill
,
winBonus
);
shown
.
getButton
(
AlertDialog
.
BUTTON_POSITIVE
).
setEnabled
(
true
);
}
catch
(
NumberFormatException
e
)
{
shown
.
getButton
(
AlertDialog
.
BUTTON_POSITIVE
).
setEnabled
(
false
);
...
...
src/net/pietu1998/wordbasehacker/solver/Board.java
View file @
34abafda
...
...
@@ -23,7 +23,7 @@ public class Board {
public
void
score
(
Possibility
pos
,
boolean
flipped
)
{
Tile
[][]
newTiles
=
new
Tile
[
10
][
13
];
int
oldPlayer
=
0
,
oldOpponent
=
0
,
oldDistP
=
0
,
oldDistO
=
0
;
int
old
Mines
=
0
,
old
Player
=
0
,
oldOpponent
=
0
,
oldDistP
=
0
,
oldDistO
=
0
;
for
(
int
x
=
0
;
x
<
10
;
x
++)
{
for
(
int
y
=
0
;
y
<
13
;
y
++)
{
newTiles
[
x
][
y
]
=
tiles
[
x
][
y
];
...
...
@@ -33,6 +33,8 @@ public class Board {
}
else
if
(
newTiles
[
x
][
y
].
isSet
(
Tile
.
OPPONENT
))
{
oldOpponent
++;
oldDistO
=
max
(
oldDistO
,
flipped
?
y
:
12
-
y
);
}
else
if
(
newTiles
[
x
][
y
].
isSet
(
Tile
.
MINE
|
Tile
.
SUPER_MINE
))
{
oldMines
++;
}
}
}
...
...
@@ -51,7 +53,7 @@ public class Board {
}
}
int
newPlayer
=
0
,
newOpponent
=
0
,
newDistP
=
0
,
newDistO
=
0
;
int
new
Mines
=
0
,
new
Player
=
0
,
newOpponent
=
0
,
newDistP
=
0
,
newDistO
=
0
;
for
(
int
x
=
0
;
x
<
10
;
x
++)
{
for
(
int
y
=
0
;
y
<
13
;
y
++)
{
if
(
newTiles
[
x
][
y
].
isSet
(
Tile
.
PLAYER
))
{
...
...
@@ -60,11 +62,13 @@ public class Board {
}
else
if
(
newTiles
[
x
][
y
].
isSet
(
Tile
.
OPPONENT
))
{
newOpponent
++;
newDistO
=
max
(
newDistO
,
flipped
?
y
:
12
-
y
);
}
else
if
(
newTiles
[
x
][
y
].
isSet
(
Tile
.
MINE
|
Tile
.
SUPER_MINE
))
{
newMines
++;
}
}
}
pos
.
setScore
(
new
Score
(
pos
.
getCoordinates
().
length
,
newPlayer
-
oldPlayer
,
oldOpponent
-
newOpponent
,
newDistP
-
oldDistP
,
oldDistO
-
newDistO
,
newDistP
==
12
));
pos
.
setScore
(
new
Score
(
pos
.
getCoordinates
().
length
,
oldMines
-
newMines
,
newPlayer
-
oldPlayer
,
oldOpponent
-
newOpponent
,
newDistP
-
oldDistP
,
oldDistO
-
newDistO
,
newDistP
==
12
));
pos
.
setResult
(
new
Board
(
newTiles
,
words
));
}
...
...
src/net/pietu1998/wordbasehacker/solver/Score.java
View file @
34abafda
...
...
@@ -2,11 +2,12 @@ package net.pietu1998.wordbasehacker.solver;
public
class
Score
{
public
final
int
wordLength
,
tilesGained
,
tilesKilled
,
progressGained
,
progressKilled
;
public
final
int
wordLength
,
minesExploded
,
tilesGained
,
tilesKilled
,
progressGained
,
progressKilled
;
public
final
boolean
gameWon
;
public
Score
(
int
wordLength
,
int
tilesGained
,
int
tilesKilled
,
int
progressGained
,
int
progressKilled
,
boolean
gameWon
)
{
public
Score
(
int
wordLength
,
int
minesExploded
,
int
tilesGained
,
int
tilesKilled
,
int
progressGained
,
int
progressKilled
,
boolean
gameWon
)
{
this
.
wordLength
=
wordLength
;
this
.
minesExploded
=
minesExploded
;
this
.
tilesGained
=
tilesGained
;
this
.
tilesKilled
=
tilesKilled
;
this
.
progressGained
=
progressGained
;
...
...
src/net/pietu1998/wordbasehacker/solver/Scoring.java
View file @
34abafda
...
...
@@ -2,11 +2,12 @@ package net.pietu1998.wordbasehacker.solver;
public
class
Scoring
{
public
final
int
letter
,
tileGain
,
tileKill
,
progressGain
,
progressKill
;
public
final
int
letter
,
mine
,
tileGain
,
tileKill
,
progressGain
,
progressKill
;
public
final
boolean
winBonus
;
public
Scoring
(
int
letter
,
int
tileGain
,
int
tileKill
,
int
progressGain
,
int
progressKill
,
boolean
winBonus
)
{
public
Scoring
(
int
letter
,
int
mine
,
int
tileGain
,
int
tileKill
,
int
progressGain
,
int
progressKill
,
boolean
winBonus
)
{
this
.
letter
=
letter
;
this
.
mine
=
mine
;
this
.
tileGain
=
tileGain
;
this
.
tileKill
=
tileKill
;
this
.
progressGain
=
progressGain
;
...
...
@@ -14,11 +15,12 @@ public class Scoring {
this
.
winBonus
=
winBonus
;
}
public
static
final
Scoring
DEFAULT
=
new
Scoring
(
1
,
10
,
40
,
100
,
300
,
true
);
public
static
final
Scoring
DEFAULT
=
new
Scoring
(
1
,
0
,
10
,
40
,
100
,
300
,
true
);
public
int
calculateScore
(
Score
score
)
{
int
result
=
0
;
result
+=
score
.
wordLength
*
letter
;
result
+=
score
.
minesExploded
*
mine
;
result
+=
score
.
tilesGained
*
tileGain
;
result
+=
score
.
tilesKilled
*
tileKill
;
result
+=
score
.
progressGained
*
progressGain
;
...
...
@@ -33,7 +35,7 @@ public class Scoring {
if
(!(
o
instanceof
Scoring
))
return
false
;
Scoring
other
=
(
Scoring
)
o
;
return
letter
==
other
.
letter
&&
tileGain
==
other
.
tileGain
&&
tileKill
==
other
.
tileKill
return
letter
==
other
.
letter
&&
mine
==
other
.
mine
&&
tileGain
==
other
.
tileGain
&&
tileKill
==
other
.
tileKill
&&
progressGain
==
other
.
progressGain
&&
progressKill
==
other
.
progressKill
&&
winBonus
==
other
.
winBonus
;
}
...
...
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