cjbottaro

cjbottaro

That’s why I store the “board” separately from the “genes”. That way I can do something like…

genes = Enum.shuffle(genes) |> Map.new()

My Problem behaviour does that!

2
Post #45
stevensonmt

stevensonmt

After you shuffle the genes to a new map do you then merge the “board” map to overwrite the values at the fixed positions provided by the input?

1
Post #46
cjbottaro

cjbottaro

No, the genes don’t have the fixed positions at all. It’s part of the fitness calculation that (kinda) merges the the two:

  def score_row(%Chromosome{} = c, i) do
    Enum.map(0..8, fn x ->
      Map.get(c.genes, {x, i}) || Map.get(c.extra.board, {x, i})
    end)
    |> score()
  end

It’s just iterates over (x, y) points and looks in the genes, but falls back to the board.

This is probably a not a good way to do it, but it was just the first thing that came to mind, and I wanted to code up something quickly cuz I was excited to see if it would work… :slight_smile:

Keeping the board separate lets me easily shuffle genes (for mutation), or do that random crossover point technique.

2
Post #47
stevensonmt

stevensonmt

Just a gentle push to ask those who have started the book to weigh in with their thoughts if they haven’t already. If the thread is analogous to an evolutionary algorithm deriving interesting insights, we need diversity of thoughts to drive the discussion. And I have too many posts here, convergence on the least fit individual is not ideal :lol:

3
Post #48
code-shoily

code-shoily

Last weekend was crazy for me. I’ll read from tomorrow and post chapters 3 and 4 over the following few days. I skimmed throff if h the third chapter. Seems like it’s going to get better quickly

1
Post #49
AstonJ

AstonJ OP

This thread is making me want to read the book - I just wish I had time to move it up my reading list! :upside_down_face:

That’s good to hear - I quite like having little refreshers in books like these as I’m a huge fan of the repeat-reinforce style of learning :003:

2
Post #50
stevensonmt

stevensonmt

I’m trying to only post about one chapter at a time, mostly to keep from running out of ways to keep the thread going when I get behind in reading, but I have to say chapter 5 is where things are getting really really interesting to me. Super excited for the rest of the book. I wish there were more books like this that were both language specific and problem-space/algorithm-type specific. Like the Exploring Graphs with Elixir book was great for getting familiar with graphs broadly and Elixir/Erlang libs for working with them, but I’d love a book that was really about graph algorithms (BFS, DFS, union-find, etc) in Elixir.

2
Post #51
code-shoily

code-shoily

I hold the same sentiment about Elixir book on graphs. And also regarding these types of books in general. We do need more of these.

As for chapters 3/4. Got Good Friday weekend this one so will work on those during that time. Excited for it (as well as rest of the book)

2
Post #52
rvirding

rvirding

Creator of Erlang

I am a bit behind :wink: but I have finally been able to start looking at the book. Yay! :smile:

I do have one question: is there an errata for the book? Just directly entering the code in the first chapter gives me runtime errors, it complains about the _ in the initial for loops. And my elixir is not yet upto correcting it. :anguished: I mean for loops? :smile:

3
Post #53
nulltree

nulltree

There is an errata.


I’m a bit late due to me prioritizing ramping up my OTP skills first.
Two observations after reading the first 4 chapters and skimming the rest a bit:

  1. I love how approachable the author lays out both Elixir and the topic itself.
  2. Working everything through it in my editor and also comparing with the provided code, I stumble over some things that are likely errors. So far they actually forced me to better understand the language - will try to collect them for errata :blush:
2
Post #54