A simple version of the game Tic-Tac-Toe. It is a 2 human players version.
Adapted from My c version: https://github.com/padawin/Tic-tac-toe.
Not minified:
function p(a,board,playedcell,t)
{
if (a >= 0 & a <9) {
a = board | (playedcell = 1 << a);
for (t = 7; ~t && (w[--t] & (c=c|playedcell)) ^ w[t];);
return (a==511||a==board)?a:~t;
}
}
See the 140byt.es site for a showcase of entries (built itself using 140-byte entries!), and follow @140bytes on Twitter.
To learn about byte-saving hacks for your own code, or to contribute what you've learned, head to the wiki.
140byt.es is brought to you by Jed Schmidt, with help from Alex Kloss. It was inspired by work from Thomas Fuchs and Dustin Diaz.
Thanks to malko and adriengibrat for their tips and help during the minifying process.
Ok it's updated, I didn't change the if, because the test was not good, I test if the typed value is a cell of the board (1 to 9), not a winning move.
The part ?3:4 was a remaining, not working, it's been removed as well.