Skip to content

Commit

Permalink
Turned off the Best of tournament output added some more documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bradford Winfrey committed Dec 2, 2009
1 parent d11300a commit 8ccb211
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ You pick (at random) this many (TOURNAMENT_SIZE) individuals from your populatio

This is just the name of the ets table that I store a counter in. In time, there will be more counters (and in theory stats see TODO)

MORE EXPLANATION
See code, there are more explanations in there (via comments that is).

TODO

Print print best of EACH GENERATION (not tournament like it is now).
Expand Down
10 changes: 6 additions & 4 deletions src/ea.erl
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ seed_tournament(OrigPop,AccPop,N) ->
%% otherwise, we will use the one passed in (the children we just generated)
run_tournament(Individuals) ->
Results = population_fitness(Individuals), % How fit is our population
{Winner,WinningScore} = hd(Results), % Get the alpha of our population
{Winner,_WinningScore} = hd(Results), % Get the alpha of our population
{RunnerUp,_RunnerUpScore} = lists:nth(2,Results), % Get the second alpha
io:format("Best of Tournament: ~p Score: ~p~n",[Winner,WinningScore]),
% io:format("Best of Tournament: ~p Score: ~p~n",[Winner,WinningScore]),
[{a,ChildA},{b,ChildB}] = crossover(Winner,RunnerUp), % Breed them together
[MutatedChildA, MutatedChildB] = [mutate(ChildA),mutate(ChildB)],
case criteria_check(MutatedChildA, MutatedChildB) of
Expand Down Expand Up @@ -151,9 +151,11 @@ mutate(Child) ->

%% Criteria Check to halt on.
%% Here we check to see if we've hit what we think of as "complete".
%% You'll notice on the AlphaLimit that it is set to 15.
%% You'll notice on the AlphaLimit that it is set to the size of ?CORRECT.
%% We finish if either Child A or Child B are good enough for us to stop.
%% So if they are 15 or better, we'll stop and see what our near-perfect genome is.
%% So if they are 26 (assuming you haven't changed ?CORRECT) or better,
%% we'll stop and see what our near-perfect genome is.
%% fool around with this (set it lower).
criteria_check(ChildA,ChildB) -> %%This could be a lot better!!!
{CA,ChildAFitness} = fit(ChildA),
{CB,ChildBFitness} = fit(ChildB),
Expand Down

1 comment on commit 8ccb211

@bradfordw
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

God, I should clean up the nomenclature...that's the problem with 3 hours of sleep...what the hell was I thinking?

Please sign in to comment.