Skip to content

Commit

Permalink
Merged changes from original gvgai and fixed elitism bug that added o…
Browse files Browse the repository at this point in the history
…nly half of the elite chromosomes
  • Loading branch information
hobogenized committed Dec 12, 2016
2 parents f862201 + 834d4eb commit 2e2fe49
Show file tree
Hide file tree
Showing 13 changed files with 1,564 additions and 1,614 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ src/tools/.DS_Store
.settings/org.eclipse.jdt.core.prefs
*.DS_Store
/bin/

debugLog
.DS_Store
36 changes: 18 additions & 18 deletions examples/2player/mimic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,25 +144,25 @@ BasicGame key_handler=Pulse no_players=2 no_counters=2
blockA9ON hit > transformTo stype=blockA9OFF counter=-1,0 killSecond=True
hit blockA9OFF > transformTo stype=blockA9ON counter=1,0 killSecond=True

blockB1ON hit > transformIfCount stype=blockB1OFF estype=blockB1OFF stypeCount=blockA1ON geq=1 counter=0,-1 killSecond=True
blockB2ON hit > transformIfCount stype=blockB2OFF estype=blockB2OFF stypeCount=blockA2ON geq=1 counter=0,-1 killSecond=True
blockB3ON hit > transformIfCount stype=blockB3OFF estype=blockB3OFF stypeCount=blockA3ON geq=1 counter=0,-1 killSecond=True
blockB4ON hit > transformIfCount stype=blockB4OFF estype=blockB4OFF stypeCount=blockA4ON geq=1 counter=0,-1 killSecond=True
blockB5ON hit > transformIfCount stype=blockB5OFF estype=blockB5OFF stypeCount=blockA5ON geq=1 counter=0,-1 killSecond=True
blockB6ON hit > transformIfCount stype=blockB6OFF estype=blockB6OFF stypeCount=blockA6ON geq=1 counter=0,-1 killSecond=True
blockB7ON hit > transformIfCount stype=blockB7OFF estype=blockB7OFF stypeCount=blockA7ON geq=1 counter=0,-1 killSecond=True
blockB8ON hit > transformIfCount stype=blockB8OFF estype=blockB8OFF stypeCount=blockA8ON geq=1 counter=0,-1 killSecond=True
blockB9ON hit > transformIfCount stype=blockB9OFF estype=blockB9OFF stypeCount=blockA9ON geq=1 counter=0,-1 killSecond=True
blockB1ON hit > transformIfCount stype=blockB1OFF estype=blockB1OFF stypeCount=blockA1ON geq=1 counter=0,-1 counterElse=0,1 killSecond=True
blockB2ON hit > transformIfCount stype=blockB2OFF estype=blockB2OFF stypeCount=blockA2ON geq=1 counter=0,-1 counterElse=0,1 killSecond=True
blockB3ON hit > transformIfCount stype=blockB3OFF estype=blockB3OFF stypeCount=blockA3ON geq=1 counter=0,-1 counterElse=0,1 killSecond=True
blockB4ON hit > transformIfCount stype=blockB4OFF estype=blockB4OFF stypeCount=blockA4ON geq=1 counter=0,-1 counterElse=0,1 killSecond=True
blockB5ON hit > transformIfCount stype=blockB5OFF estype=blockB5OFF stypeCount=blockA5ON geq=1 counter=0,-1 counterElse=0,1 killSecond=True
blockB6ON hit > transformIfCount stype=blockB6OFF estype=blockB6OFF stypeCount=blockA6ON geq=1 counter=0,-1 counterElse=0,1 killSecond=True
blockB7ON hit > transformIfCount stype=blockB7OFF estype=blockB7OFF stypeCount=blockA7ON geq=1 counter=0,-1 counterElse=0,1 killSecond=True
blockB8ON hit > transformIfCount stype=blockB8OFF estype=blockB8OFF stypeCount=blockA8ON geq=1 counter=0,-1 counterElse=0,1 killSecond=True
blockB9ON hit > transformIfCount stype=blockB9OFF estype=blockB9OFF stypeCount=blockA9ON geq=1 counter=0,-1 counterElse=0,1 killSecond=True

hit blockB1OFF > transformIfCount stype=blockB1OK estype=blockB1NOT stypeCount=blockA1ON geq=1 counter=0,1 killSecond=True
hit blockB2OFF > transformIfCount stype=blockB2OK estype=blockB2NOT stypeCount=blockA2ON geq=1 counter=0,1 killSecond=True
hit blockB3OFF > transformIfCount stype=blockB3OK estype=blockB3NOT stypeCount=blockA3ON geq=1 counter=0,1 killSecond=True
hit blockB4OFF > transformIfCount stype=blockB4OK estype=blockB4NOT stypeCount=blockA4ON geq=1 counter=0,1 killSecond=True
hit blockB5OFF > transformIfCount stype=blockB5OK estype=blockB5NOT stypeCount=blockA5ON geq=1 counter=0,1 killSecond=True
hit blockB6OFF > transformIfCount stype=blockB6OK estype=blockB6NOT stypeCount=blockA6ON geq=1 counter=0,1 killSecond=True
hit blockB7OFF > transformIfCount stype=blockB7OK estype=blockB7NOT stypeCount=blockA7ON geq=1 counter=0,1 killSecond=True
hit blockB8OFF > transformIfCount stype=blockB8OK estype=blockB8NOT stypeCount=blockA8ON geq=1 counter=0,1 killSecond=True
hit blockB9OFF > transformIfCount stype=blockB9OK estype=blockB9NOT stypeCount=blockA9ON geq=1 counter=0,1 killSecond=True
hit blockB1OFF > transformIfCount stype=blockB1OK estype=blockB1NOT stypeCount=blockA1ON geq=1 counter=0,1 counterElse=0,-1 killSecond=True
hit blockB2OFF > transformIfCount stype=blockB2OK estype=blockB2NOT stypeCount=blockA2ON geq=1 counter=0,1 counterElse=0,-1 killSecond=True
hit blockB3OFF > transformIfCount stype=blockB3OK estype=blockB3NOT stypeCount=blockA3ON geq=1 counter=0,1 counterElse=0,-1 killSecond=True
hit blockB4OFF > transformIfCount stype=blockB4OK estype=blockB4NOT stypeCount=blockA4ON geq=1 counter=0,1 counterElse=0,-1 killSecond=True
hit blockB5OFF > transformIfCount stype=blockB5OK estype=blockB5NOT stypeCount=blockA5ON geq=1 counter=0,1 counterElse=0,-1 killSecond=True
hit blockB6OFF > transformIfCount stype=blockB6OK estype=blockB6NOT stypeCount=blockA6ON geq=1 counter=0,1 counterElse=0,-1 killSecond=True
hit blockB7OFF > transformIfCount stype=blockB7OK estype=blockB7NOT stypeCount=blockA7ON geq=1 counter=0,1 counterElse=0,-1 killSecond=True
hit blockB8OFF > transformIfCount stype=blockB8OK estype=blockB8NOT stypeCount=blockA8ON geq=1 counter=0,1 counterElse=0,-1 killSecond=True
hit blockB9OFF > transformIfCount stype=blockB9OK estype=blockB9NOT stypeCount=blockA9ON geq=1 counter=0,1 counterElse=0,-1 killSecond=True


TerminationSet
Expand Down
6 changes: 3 additions & 3 deletions examples/gridphysics/tercio.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ BasicGame key_handler=Pulse square_size=50
A > inWhite white
L > inBlue blue

* > crate inBlack
@ > crate inWhite
$ > crate inBlue
* > crate black
@ > crate white
$ > crate blue

t > target black
u > target white
Expand Down
11 changes: 11 additions & 0 deletions gvgai.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
3 changes: 1 addition & 2 deletions src/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ public static void main(String[] args) {
// ArcadeMachine.playOneGame(game, level1, recordActionsFile, seed);

// 2. This plays a game in a level by the controller.
// ArcadeMachine.runOneGame(game, level1, visuals, sampleMCTSController,
// recordActionsFile, seed, 0);
// ArcadeMachine.runOneGame(game, level1, visuals, sampleRandomController, recordActionsFile, seed, 0);

// 3. This replays a game from an action file previously recorded
// String readActionsFile = recordActionsFile;
Expand Down
28 changes: 14 additions & 14 deletions src/controllers/singlePlayer/sampleRandom/Agent.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,19 @@ private void printDebug(ArrayList<Observation>[] positions, String str)
*/
public void draw(Graphics2D g)
{
int half_block = (int) (block_size*0.5);
for(int j = 0; j < grid[0].length; ++j)
{
for(int i = 0; i < grid.length; ++i)
{
if(grid[i][j].size() > 0)
{
Observation firstObs = grid[i][j].get(0); //grid[i][j].size()-1
//Three interesting options:
int print = firstObs.category; //firstObs.itype; //firstObs.obsID;
g.drawString(print + "", i*block_size+half_block,j*block_size+half_block);
}
}
}
// int half_block = (int) (block_size*0.5);
// for(int j = 0; j < grid[0].length; ++j)
// {
// for(int i = 0; i < grid.length; ++i)
// {
// if(grid[i][j].size() > 0)
// {
// Observation firstObs = grid[i][j].get(0); //grid[i][j].size()-1
// //Three interesting options:
// int print = firstObs.category; //firstObs.itype; //firstObs.obsID;
// g.drawString(print + "", i*block_size+half_block,j*block_size+half_block);
// }
// }
// }
}
}
2 changes: 1 addition & 1 deletion src/core/game/ForwardModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ public HashMap<Integer, Integer> getAvatarResources(int playerID) {
*/
public Types.ACTIONS getAvatarLastAction(int playerID) {
if(avatarLastAction[playerID] != null)
return avatarLastAction[0];
return avatarLastAction[playerID];
else return Types.ACTIONS.ACTION_NIL;
}

Expand Down
Loading

0 comments on commit 2e2fe49

Please sign in to comment.