Paul Crowley (
ciphergoth) wrote2005-11-01 03:53 pm
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Whitby goodness
I had a lovely Whitby - a little more muted than usual, partly because of colds at our end and partly because of colds very sadly keeping
ergotia and
lilithmagna from joining us, but very nice all the same. My Friday night outfit was particularly well received, and will no doubt be reprised.
Now I'm obsessing with trying to get a paper ready by November 25 for FSE 2006. I have to keep a little quiet about what I'm doing until January 27th, since submissions are anonymous, but, it's cool.
Update with a geek puzzle: here's a simple game. I lay out a set of tiles that say Y or N; say I lay out
NYYNYNN
You lay the same number of tiles underneath:
NYYNYNN
NNYYNNN
The rules are: (1) if a tile is the same as the one above, you have to lay the same tile to the right. So you're not allowed to lay
NYYNYNN
NYYYNNN
-^- not allowed: because the first column is N N, you must lay N as your second tile.
(2) you get a point every time you lay a tile which is the same as the one above.
NYYNYNN
NNYYNNN
1010011 - four points
The least you can score is always zero: it's always a legal move to lay tiles which differ in every place from the ones above. What's the best you can score for NYYNYN, and how many ways can you do it? Can anyone give an algorithm which determines the highest you can score, or which generates all of the possibilities which give you a given score?
![[livejournal.com profile]](https://www.dreamwidth.org/img/external/lj-userinfo.gif)
![[livejournal.com profile]](https://www.dreamwidth.org/img/external/lj-userinfo.gif)
Now I'm obsessing with trying to get a paper ready by November 25 for FSE 2006. I have to keep a little quiet about what I'm doing until January 27th, since submissions are anonymous, but, it's cool.
Update with a geek puzzle: here's a simple game. I lay out a set of tiles that say Y or N; say I lay out
NYYNYNN
You lay the same number of tiles underneath:
NYYNYNN
NNYYNNN
The rules are: (1) if a tile is the same as the one above, you have to lay the same tile to the right. So you're not allowed to lay
NYYNYNN
NYYYNNN
-^- not allowed: because the first column is N N, you must lay N as your second tile.
(2) you get a point every time you lay a tile which is the same as the one above.
NYYNYNN
NNYYNNN
1010011 - four points
The least you can score is always zero: it's always a legal move to lay tiles which differ in every place from the ones above. What's the best you can score for NYYNYN, and how many ways can you do it? Can anyone give an algorithm which determines the highest you can score, or which generates all of the possibilities which give you a given score?
Yay!
Did
Re: Yay!
I take it that it's you that has started adding useful tags, btw? Thanks!
Re: Yay!
Re: Yay!
Re: Yay!
no subject
The least you can score is always zero: it's always a legal move to lay tiles which differ in every place from the ones above
Err ... isn't it always one? You can always score one by laying tiles which differ in every place but the right-hand one.
It looks like the problem ought to be related to adding but I can't make the connection.
If the number of tiles we play with is always seven (or even just small), my first choice for an algorithm to find the highest score would be simple brute force, sad to say! With only a little bit-twiddling for each instance it's not going to take long, and I'm usually more confident in the completeness of brute force algorithms than more subtle ones.
no subject
You can always score zero with the strategy I describe; you can always score 1 with the strategy you describe. Actually I think you can always score at least ceil(n/2): choose the letter which appears most often above, and lay that down in every place below. If the tiles are alternating then that's the best you can do.
There is a connection with adding, but it's pretty longwinded.
no subject
Shame.
You can always score zero with the strategy I describe; you can always score 1 with the strategy you describe.
Agreed.
Actually I think you can always score at least ceil(n/2): choose the letter which appears most often above, and lay that down in every place below. If the tiles are alternating then that's the best you can do.
Reckon so. That's a nice strategy - it does well in lots of circumstances. Presumably you want a solution that'll outperform that when possible? I'm not finding any immediately to hand.
no subject
NNNNNNNNNNYYYYYYYYYY
NNNNNNNNNNnYYYYYYYYY
(using a lowercase "n" to mark a choice where you don't score a point)
I think a greedy strategy (if you're forced to put a letter, put that, else put what's above) does pretty well - it may even be optimal. But I haven't proven it yet, and even if it is, it only finds one best solution, not all of them.
no subject
My reasoning was to break the sequence up into blocks of "one or more Ys followed by an N", and "one or more Ns followed by a Y" (any remaining Ys or Ns treat as a special case), and then show that in the first case an optimal sequence for that block is all Ys, and similarly therefore for the second case an optimal sequence is all Ns. Since you've ended with a different letter, you are free to choose the first letter for the next block, so it should be possible to treat the blocks independently. Though I may have missed something or made some assumptions.
The only time an alternative solution is possible if the block is either NY or YN - we can try YY or NN, but that constrains us to keep the same letter for the next choice ... So it can be seen that a block of NYY can have YYY as a solution instead of NNY (and similarly YNN can have NNN instead of YYN). I think that
I'm not sure how to prove that these are the only possible substitutions. If they are, then it ought to be possible to find all possible solutions by spotting sequences of NYY and YNN and writing all possible combinations with each of these sequences having either of the two solutions?
So for NYYNYNN, the best would be NNYYYYN (score 4). There is 1 sequence of NYY and 1 of YNN given 3 other solutions: YYYYYYN, NNYYNNN and YYYYNNN.
And you were looking very beautiful at Whitby!
no subject
no subject
no subject
I have also fixed the code (hence the repost) so it deals correctly with the degenerate cases (short sequences, end of sequence) correctly! All lines after the blank line deal with degenerate cases, and can be handled as special cases in the proof.
no subject
no subject
no subject
no subject
Compute, for the first k tiles, the optimal solution that DOES and the optimal solution that DOES NOT have a match in the last position.
From those two solutions it's easy to compute a similar pair of solutions for the first k+1 tiles.
Repeat until you've done all the tiles, then keep whichever of the two solutions you have, is better.
The big advantage: you can prove the above correct without needing to prove that a (potentially long and complicated) list of pattern-matching templates is correct and complete.
no subject
no subject
You can easily generalize this to any game played on an FSM where transitions score points and you know your opponent's moves in advance.
no subject
Nim, in other words?
no subject
First, Nim's not really an FSM: there are infinitely many possible Nim boards.
Second, you don't score points for the transitions - the game is decided at the end.
Third, you don't know your opponent's moves in advance!
But maybe there's a clever way of thinking about Nim that turns it into a problem fitting the above constraints?
“Apart from that, Mrs. Licoln, how was the play?”
Second - ah, you formally score points at the end, it's true, but you can regard a game of Nim for a player as a set of transitions in and out of Nim numbers - the player gains a point when he gets to a Nim number and loses a point when he strays off it - then whoever has "more points" (although there's only one) at the end of the game wins.
I misunderstood what you meant by "know your opponents moves in advance" - I though you meant in the sense of chess vs. roshambo rather than in the sense of your game (did you give it a name?) vs. chess. I suppose in an optimally played game of Nim, one *does* know one's opponent's moves, in effect, because they'll either be a move to a Nim number or a move that will let one get to a Nim number, and the Nim number that one will get to is known, but that's clutching at straws rather.
I'm not certain, though, that there isn't some kind of relationship between the two - if it becomes more apparent to me I'll let you know, if you like.
Re: “Apart from that, Mrs. Licoln, how was the play?”
(for X substitute polynomial, linear, subquadratic, or whatever)
no subject