Esempio n. 1
0
int main ( int argc,char **argv)
    {

    static char  * can_t_open = "Can't open file %s for %c\n";
    char  filename[1000];
    static char * cp ="";

#ifdef DEBUG
    printf("Start\n");
#endif
    if ( argc < 2 ) {
	fprintf(stderr,"ERROR: no net name !\n");
	exit(1);
      }
    sprintf(filename,"%s.net",argv[1]);
    if ( (nfp = fopen( filename, "r")) == NULL ) {
	fprintf(stderr,can_t_open,filename,'r');
	exit(1);
      }
    sprintf(filename,"%s.lp_mark",argv[1]);
    if ( (ofp = fopen( filename, "w")) == NULL ) {
	fprintf(stderr,can_t_open,filename,'w');
	exit(1);
      }
    if ( argc == 2 || (integ_sol = !strcmp(argv[2],"-i"))  ) {
	mark_nam = &cp;
	no_marks = 1;
      }
    else {
	no_marks = argc - 2;
	mark_nam = argv + 2;
      }
    load_net ();
    (void) fclose(nfp);
    produce_lp();
    (void) fclose(ofp);
#ifdef DEBUG
    printf("End\n");
#endif
    return 0;
}
Esempio n. 2
0
/*
 * Initialize AI.
 */
static void ai_initialize(game *g, int who)
{
	char fname[1024], buf[1024];

	/* Create neural net */
	make_learner(&learner[who], NET_INPUT, HIDDEN_NODES, 2);

	/* Set learning rate */
	learner[who].alpha = 0.0001;
	/* learner[who].alpha = 0.0; printf("WARNING: alpha is 0\n"); */

	/* Create network filename */
	sprintf(fname, DATADIR "/networks/bluemoon.net.%s.%s",
	                                     g->p[who].p_ptr->name,
	                                     g->p[!who].p_ptr->name);

	/* Attempt to load net weights from disk */
	if (load_net(&learner[who], fname))
	{
		/* Create warning message */
		sprintf(buf,
		        _("WARNING: Couldn't open %s, expect random play!\n"),
		        fname);

		/* Send message */
		message_add(buf);
	}

	/* Evaluate starting position */
	eval_game(g, who);

	/* Message */
	if (verbose >= 1)
	{
		/* Print win probabilities of starting state */
		printf("%s Start prob: %f %f\n", g->p[who].p_ptr->name,
						 learner[who].win_prob[0],
						 learner[who].win_prob[1]);
	}
}