625 karma · joined September 8, 2010
Intelligent caching is possible but I think it would be difficult for me to implement and I'm not certain that it would yield much benefit.
Actually, the procedure for identifying all the possible player moves is very fast already and I think making it prioritise "easier" moves would slow it down. In particular, ruling out or de-prioritising simple things like "tucking" a piece under another is very counterproductive.
Why not just use 4 bits to represent the whole column? That's (2^4)^10 = 2^40, exactly where we started.
In fact, look at rows instead. With 10 columns and 4 rows there are, to be more precise, (2^10 - 1)^4 possible states.
And the majority of which have "floating" (disconnected) sections which, while reachable with the rules of Tetris, cannot be reached without making at least one line.
In case you didn't read the article, Tetris has been solved for width 10 height 4: the AI wins. The same is true for width 10 height 5. We need to go further.
who_wins(well W) {
for each piece P {
for each landing state of piece P in well W {
well W2 = result
if(that_makes_a_line(W2)) {
next piece
}
if(who_wins(W2) == PLAYERWINS) {
next piece
}
}
// AI wins every landing state
return AIWINS
}
// Player wins every piece
return PLAYERWINS
}
print who_wins(empty_well)A better approach is to either (1) add a mysql_prepare() function to the PHP MySQL extension, or (2) deprecate the extension in favour of one which forces or at least encourages or at least supports the use of prepared statements.
sub escape {
my $arg = shift;
$arg =~ s/([^a-zA-Z0-9_])/\\$1/g;
return $arg;
}However, no regular grammar (not even a recursive regular grammar) can describe a recursive language.
Of course, most modern "regex" engines provide features which go beyond the strictly regular languages.
"It's 10:00 here in London. I need to call someone in New York, what time is it there?" "10:00, same as it is everywhere in the world." "So... is now a good time to call them?" "I have no idea."
I disagree with this statement in the strongest terms.
You can go down the route of text editing as art, like that Vi Golf concept that was floating around. And a well-made tool is indeed valuable and beautiful to behold. Nevertheless, I maintain that a text editor is strictly as important as the text it is used to create.
Just because it used to be extremely painful to become a towering expert at text editing doesn't mean it should continue to be so. It's not like riding a bicycle-- text editing actually is easy. Or at least, it can be made easy, and there is no argument for keeping it difficult.
Remember, text editing in and of itself is of no value. Tools should get the hell out of the way of their users.
It's okay to intend a tool for a specific purpose! It's okay to do one thing well.
We are wrong now, as well.
But to say that we are as wrong as Socrates is ridiculous. We are much, much, much closer to the truth now than we have ever been.