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
6c6a9e2b
Commit
6c6a9e2b
authored
9 years ago
by
Piers Williams
Browse files
Options
Downloads
Patches
Plain Diff
Moved code into a package for ease
parent
65ec7112
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/battle/controllers/Piers/PiersController.java
+38
-21
38 additions, 21 deletions
src/battle/controllers/Piers/PiersController.java
with
38 additions
and
21 deletions
src/battle/controllers/PiersController.java
→
src/battle/controllers/
Piers/
PiersController.java
+
38
−
21
View file @
6c6a9e2b
package
battle.controllers
;
package
battle.controllers
.Piers
;
import
asteroids.Action
;
import
battle.BattleController
;
import
battle.NeuroShip
;
import
battle.SimpleBattle
;
import
java.util.ArrayList
;
import
java.util.Random
;
/**
* Created by pwillic on 11/06/2015.
*
*
<p>
* Features to use for avoidance
*
*
1. Distance to enemy - 0 very close, 1 very far
*
2. Enemy in FL - 0 no, 1 yes
*
3. Enemy in FR
*
4. Enemy in BL
*
5. Enemy in BR
*
*
Features to use for shooting
*
1. Distance to enemy
*
2. Deviance from dead straight Left - 0.5 no deviance, 0 full left, 1 full right
*
3. Missiles Remaining
*
*
Features to use for aligning
*
1. Distance to enemy
*
2. Deviance from enemy
*
3.
*
<p>
* 1. Distance to enemy - 0 very close, 1 very far
* 2. Enemy in FL - 0 no, 1 yes
* 3. Enemy in FR
* 4. Enemy in BL
* 5. Enemy in BR
*
<p>
* Features to use for shooting
* 1. Distance to enemy
* 2. Deviance from dead straight Left - 0.5 no deviance, 0 full left, 1 full right
* 3. Missiles Remaining
*
<p>
* Features to use for aligning
* 1. Distance to enemy
* 2. Deviance from enemy
* 3.
*/
public
class
PiersController
implements
BattleController
{
Neuron
tinyBrain
;
int
fitness
;
public
PiersController
()
{
tinyBrain
=
new
Neuron
(
10
);
}
public
static
void
main
(
String
[]
args
)
{
int
POPULATION_COUNT
=
20
;
int
TERMINATION_SCORE
=
500
;
// Learn the controllers
SimpleBattle
battle
=
new
SimpleBattle
();
ArrayList
<
PiersController
>
candidates
=
new
ArrayList
<>(
POPULATION_COUNT
);
for
(
int
i
=
0
;
i
<
POPULATION_COUNT
;
i
++)
candidates
.
add
(
new
PiersController
());
// Run the GA?
PiersController
best
=
candidates
.
get
(
0
);
while
(
best
.
fitness
<
TERMINATION_SCORE
){
}
}
@Override
public
Action
getAction
(
SimpleBattle
gameStateCopy
,
int
playerId
)
{
...
...
@@ -43,7 +61,6 @@ public class PiersController implements BattleController {
double
[]
avoidanceTable
=
new
double
[
5
];
double
[]
shootingTable
=
new
double
[
3
];
return
null
;
}
}
...
...
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