Skip to content

Commit

Permalink
Added possibility to print board by 'language'.
Browse files Browse the repository at this point in the history
  • Loading branch information
carschno committed Jan 18, 2015
1 parent ac875de commit 847b502
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
23 changes: 23 additions & 0 deletions src/com/schnobosoft/learningAgents/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,29 @@ public void printBoard()
}
}

/**
* Print the board encoded by 'language': marks each agent by a symbol representing its
* 'language'.
*/
public void printLanguages()
{
char[] symbols = new char[] { 'X', 'O' };

assert Game.getEvents() == 1 && Game.getSignals() <= 2;

int event = 0;

for (int y = 0; y < getBoardSize(); y++) {
for (int x = 0; x < getBoardSize(); x++) {
Agent agent = board[x][y].getAgent();
int signal = agent.getSignal(event, Rule.MAX);
char symbol = symbols[signal];
System.out.print(symbol + " ");
}
System.out.println();
}
}

/**
* For each field, print the agent's average similarity to all its neighbours.
*/
Expand Down
13 changes: 8 additions & 5 deletions src/com/schnobosoft/learningAgents/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ public class Game
{
private enum Output
{
AGENTS, SIMILARITIES, EVENT
AGENTS, SIMILARITIES, EVENT, LANGUAGES
}

private static final int N_PRINTS = 100;
private static final int DEFAULT_FIELD_DIMENSIONALITY = 10; // field dimensionality
private static final Output output = Output.AGENTS;
private static final int N_EVENTS = 4;
private static final int N_SIGNALS = 4;
private static final Output output = Output.LANGUAGES;
private static final int N_EVENTS = 1;
private static final int N_SIGNALS = 2;

private Board board;
private int rounds;
Expand Down Expand Up @@ -66,6 +66,9 @@ private void printOutput(int round)
case EVENT:
board.printBoard(0);
break;
case LANGUAGES:
board.printLanguages();
break;
}
System.out.println();
}
Expand All @@ -75,7 +78,7 @@ private void printOutput(int round)
*/
public static void main(String[] args)
{
Game game = new Game(1000);
Game game = new Game(10000);
game.run();
}

Expand Down

0 comments on commit 847b502

Please sign in to comment.