Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asteroids
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hexboard-games
asteroids
Commits
9ab8ea10
Commit
9ab8ea10
authored
9 years ago
by
Piers Williams
Browse files
Options
Downloads
Patches
Plain Diff
Modified the timer to work better
parent
4a0b1839
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/battle/controllers/Piers/GameTimer.java
+11
-2
11 additions, 2 deletions
src/battle/controllers/Piers/GameTimer.java
src/battle/controllers/Piers/PiersMCTS.java
+5
-1
5 additions, 1 deletion
src/battle/controllers/Piers/PiersMCTS.java
with
16 additions
and
3 deletions
src/battle/controllers/Piers/GameTimer.java
+
11
−
2
View file @
9ab8ea10
...
...
@@ -5,13 +5,20 @@ package battle.controllers.Piers;
*/
public
class
GameTimer
{
long
startTime
;
long
timeBudget
;
private
long
startTime
;
private
long
timeBudget
;
private
boolean
timeSet
=
false
;
public
GameTimer
()
{
startTime
=
System
.
nanoTime
();
}
public
GameTimer
(
long
budget
)
{
this
();
setTimeBudgetMilliseconds
(
budget
);
}
public
long
elapsed
()
{
return
System
.
nanoTime
()
-
startTime
;
}
...
...
@@ -21,7 +28,9 @@ public class GameTimer {
}
public
void
setTimeBudgetMilliseconds
(
long
budget
)
{
if
(
timeSet
)
throw
new
IllegalAccessError
(
"You shouldn't try to set the time budget now"
);
timeBudget
=
(
long
)
(
budget
*
1.0E6
);
timeSet
=
true
;
}
public
long
remainingTimeMilliseconds
()
{
...
...
This diff is collapsed.
Click to expand it.
src/battle/controllers/Piers/PiersMCTS.java
+
5
−
1
View file @
9ab8ea10
...
...
@@ -9,11 +9,15 @@ import battle.SimpleBattle;
*/
public
class
PiersMCTS
implements
BattleController
{
public
PiersMCTS
()
{
MCTSNode
.
setAllActions
();
}
@Override
public
Action
getAction
(
SimpleBattle
gameStateCopy
,
int
playerId
)
{
MCTSNode
root
=
new
MCTSNode
(
2.0
,
playerId
);
GameTimer
timer
=
new
GameTimer
();
timer
.
setTimeBudgetMilliseconds
(
10
0
);
timer
.
setTimeBudgetMilliseconds
(
4
0
);
while
(
timer
.
remainingTimePercent
()
>
10
)
{
MCTSNode
travel
=
root
.
select
(
gameStateCopy
,
3
);
double
[]
results
=
travel
.
rollout
(
gameStateCopy
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment