Is there a network server that plays Scrabble-like word games against programs, for word-game programmers...
references/software/scrabble.move.server New
New entry, edited from material collected for the archive and not yet in a released version.
Problem
Is there a network server that plays Scrabble-like word games against programs, for word-game programmers to test against? [ Editor: problem statement reconstructed from a January 1995 mail to the word-game-programmers mailing list announcing "Move". ]
Show solution
I have devoted some time recently to constructing a version of Move.
Actually, I've constructed three, with slightly different playing
rules. They share a common interface, and just listen to different
ports.
The enclosed program doesn't actually play, but it does talk to my
Move, and it's a SMOP to get from there to something a little more
user-friendly.
Move's restrictions, intended to go away when I get the chance:
15x15 boards only (though with any pattern of premium squares).
OSW3 only.
The program does not yet challenge illegal last moves.
O, S, and T lines aren't parsed, still less any action taken.
The whole thing is probably full of bugs. It also shows up the fact that
although we've discussed the format of messages from Int to Move, messages
the other way are free-format. I do not pretend that my solution is
even close to right, but it's not bad for an evening's work.
Anyway, feel free to try it out.
-----------------------------------------------------------
#include <ctype.h>
#include <sys/errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/time.h>
#include <time.h>
#include <stdio.h>
main()
{
int s = socket (AF_INET, SOCK_STREAM, 0);
struct sockaddr_in server;
struct hostent *hp;
int n, t;
char buf[1000];
server.sin_family = AF_INET;
hp = gethostbyname("game.specialix.co.uk"); /* 192.65.144.94 */
if (hp == NULL) {
fprintf (stderr, "can't get host\n");
exit (0);
}
memcpy (&server.sin_addr, hp->h_addr, hp->h_length);
server.sin_port = htons(7777); /* or 8888 or 9999 */
t = connect (s, (struct sockaddr *)&server, sizeof(server));
if (t < 0) {
fprintf (stderr, "can't connect\n");
exit(0);
}
#define WRITE(str) write (s, (str), sizeof(str)-1)
WRITE("D OSW_3\n");
WRITE("A A91B23C23D42EC1F24G23H24I91J18K15L41M23N61O81P23Q1AR61S41T61U41V24W24X18Y24Z1A?20\n");
WRITE("B =..'...=...'..= "
".-...\"...\"...-. "
"..-...'.'...-.. "
"'..-...'...-..' "
"....-.....-.... "
".\"...\"...\"...\". "
"..'...'.'...'.. "
"=..'...-...'..= "
"..'...'.'...'.. "
".\"...\"...\"...\". "
"....-.....-.... "
"'..-...'...-..' "
"..-...'.'...-.. "
".-...\"...\"...-. "
"=..'...=...'..=\n");
WRITE("R AEIRNST\n");
WRITE("G 1\n");
while ((n = read (s, buf, 1000)) > 0)
write (1, buf, n);
exit (0);
}
-- Steve Thomas <sthomas@specialix.co.uk> (word-game-programmers, January 1995)
[ Editor: the server address dates from 1995. ]