[Haskell-beginners] Building a tree

Lyndon Maydwell maydwell at gmail.com
Tue Apr 29 01:09:07 UTC 2014


There are some nice "unfold" style methods available in Data.Tree if
you're looking for a library to help out. I've gotten into the habit
of generating all possibilities lazily and then pruning rather than
doing the pruning during generation, so unfold works well with this.

Is that the kind of thing you're after?

On Tue, Apr 29, 2014 at 1:49 AM, Norbert Melzer <timmelzer at gmail.com> wrote:
> Hi!
>
> I have to implement a solver for the game 2048 and decided to use Haskell
> from the pool of possible languages.
>
> My current implementation has a fixed recursion depth of 5 and simply sums
> up the possible score the best line of moves would give. One problem with
> this implementation is, that in some cases obvious defends are favoured
> because of the points that the dead end grants in the short term.
>
> So I now want to build up a tree of moves and pick that move that has the
> deepest subtree.
>
> My problem now is, that I haven't worked with trees before, so I don't have
> any idea how to build it up recursively. Also, since I don't consider new
> stones that would spawn after doing my move, I might create infinite
> subterranean just swiping left and right or up and down or anything else,
> how would I be able to consider such subtrees as a game over on the first
> repetition?
>
> TIA
> Norbert
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>


More information about the Beginners mailing list