12

We have a forest of rooted trees. Two players makes alternating moves according to the following rule: one move is to cut vertex and all its children. Player which makes last move (no vertices remain) wins.

How can we compute Grundy function for the positions in the game?

Suppose we have a trees and we need to say whether current position is winning or losing?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Anton Postnikov
  • 211
  • 1
  • 5
  • 3
    Sounds very difficult homework! – Paul Hadfield Mar 05 '11 at 08:32
  • 2
    I suggest you get a copy of "Winning Ways" http://en.wikipedia.org/wiki/Winning_Ways_for_your_Mathematical_Plays from your local library and work it out for yourself. – Doc Brown Mar 05 '11 at 08:38
  • 1
    I hope this isn't for http://www.codechef.com/MARCH11/problems/SQUAGAME - because thats a currently running contest. – kyun Mar 05 '11 at 10:32
  • 2
    I admit that this problem is computer-sciency, however it falls more in the mathematical-category than in the programming-category. So you might find more help here: > http://math.stackexchange.com/ – Bernd Elkemann Mar 05 '11 at 08:50
  • 6
    Isn't this just a variation of Nim? Each tree can be replaced by a heap with as many stones as the longest path in that tree. – Nick Johnson Mar 08 '11 at 01:59
  • Seeing as it's homework, shouldn't you be working that out yourself? Generally homework is assigned after you're given the proper tools to complete the job. I'm with eznme, though. You should consider asking it in a different forum. – Tass Apr 11 '11 at 18:09
  • Should this be asked in gaming.stackexchange.com? – alexyorke Apr 13 '11 at 13:21

1 Answers1

5

This is the Hackenbush game. I highly recommend this article, which covers Grundy numbers with great clarity and thoroughly discusses hackenbush toward the end.

Daniel Lubarov
  • 7,796
  • 1
  • 37
  • 56