Exemplo n.º 1
0
void begin_game(){
	
 
if(posswin(computer)){
	
  go(posswin(computer));
  flag = 1;
 }
else
if(posswin(player))
  	go(posswin(player));
else
if(make2())
  	go(make2());
else
  	go(make4());
 	draw_board();

if(flag){
	
  	gotoxy(30,20);
  	system("cls");			//clearing screen to displa result 
  	system("COLOR 4F");					//selecting color of panel showing result
  	printf("\t\t\t      Computer wins\n\t\t\t  -----GAME OVER-----");
  	getch();
 }
else
  	player_1();
}
Exemplo n.º 2
0
obj vmake_os_error( const char *fn, int num_args, va_list va )
{
  int i, e = errno;
  obj argv, props;

  argv = alloc( SLOT(num_args), vector_class );

  for (i=0; i<num_args; i++)
    gvec_write_init( argv, SLOT(i), va_arg(va,obj) );

  props = cons( cons( lookup_symbol( "stack" ), 
                      make_exception_stack() ), 
                NIL_OBJ );

  return make4( os_error_class, 
                props,
                int2fx(e), 
                make_string( fn ),
                argv );
}
Exemplo n.º 3
0
int getPossibleWinningPos()
{
	int make2();
	int make4();

	int pos = getWinningPos(comp);
	if (pos)
		return pos;

	pos = getWinningPos(player);
	if (pos)
		return pos;

	pos = make2();
	if (pos)
		return pos;

	pos = make4();
	if (pos)
		return pos;

	return FALSE;
}
Exemplo n.º 4
0
jump_addr gui_call( void )
{
Tcl_Interp *interp;
int rc = 0;

    COUNT_ARGS_AT_LEAST(1);
    if (EQ(REG0,FALSE_OBJ))
      {
	COUNT_ARGS(1);
	interp = Tcl_CreateInterp();
	REG0 = RAW_PTR_TO_OBJ( interp );
      }
    else if (arg_count_reg > 2 && EQ(REG1,int2fx(4)))
      {
	obj info;

	COUNT_ARGS(3);
	interp = (Tcl_Interp *)OBJ_TO_RAW_PTR(REG0);

	/* this hook creates a Scheme procedure 
	   for calling the given Tcl command
	   The arguments to the scheme procedure had
	   better be strings, fixnums, or symbols.
	   */
	info = bvec_alloc( sizeof(Tcl_CmdInfo), byte_vector_class );
	/*printf( "seeking info on `%s'\n", string_text(REG2) );*/
	if (!Tcl_GetCommandInfo( interp, 
				(char *)string_text(REG2),
				(Tcl_CmdInfo *)PTR_TO_DATAPTR(info) ))
	  {
	    REG0 = make_string( "command not found" );
	    REG1 = int2fx(1);
	    RETURN(1);
	  }

	REG0 = make2(closure_class,
		     make4(bindingenvt_class,
			   NIL_OBJ,
			   info,
			   RAW_PTR_TO_OBJ(interp),
			   REG2 ),
		     make2(template_class,
			   JUMP_ADDR_TO_OBJ(tcl_gateway),
			   ZERO));
	RETURN1();
      }
    else
      {
	COUNT_ARGS(2);
	interp = (Tcl_Interp *)OBJ_TO_RAW_PTR(REG0);

	if (EQ(REG1,int2fx(0)))
	  {
	    switch_hw_regs_back_to_os();
	    main_tk_win = Tk_CreateMainWindow( interp, NULL, "rs", "RScheme" );
	    if (!main_tk_win)
	    {
		switch_hw_regs_into_scheme();
		goto tcl_error;
	    }
	    printf( "main window = %#x\n", main_tk_win );
	    /*
	    Tk_GeometryRequest( main_tk_win, 200, 200 );
	    */
	    Tcl_SetVar(interp, "tcl_interactive","0", TCL_GLOBAL_ONLY);
	    Tcl_CreateCommand(interp,
			      "scheme-callback",
	    		      the_callback,
			      (ClientData)0, 
			      NULL);
	    switch_hw_regs_into_scheme();

	    if ((rc = Tcl_Init(interp)) == TCL_ERROR) {
		goto tcl_error;
	    }
	    if ((rc = Tk_Init(interp)) == TCL_ERROR) {
		goto tcl_error;
	    }
	}
	else if (EQ(REG1,int2fx(2)))
	{
	    Tk_MakeWindowExist( main_tk_win );
	    RETURN0();
	}
	else if (EQ(REG1,int2fx(1)))
	  {
	    evts = NIL_OBJ;
	    switch_hw_regs_back_to_os();
	    Tk_DoOneEvent(TK_ALL_EVENTS|TK_DONT_WAIT);
	    switch_hw_regs_into_scheme();
	    REG0 = evts;
	    RETURN(1);
	  }
	else if (EQ(REG1,int2fx(3)))
	{
	    evts = NIL_OBJ;
	    /* flush events */
	    switch_hw_regs_back_to_os();
	    while (Tk_DoOneEvent(TK_ALL_EVENTS|TK_DONT_WAIT));
	    switch_hw_regs_into_scheme();
	    REG0 = evts;
	    RETURN(1);
	}
	else
	  {
	    assert( STRING_P(REG1) );
	    rc = Tcl_Eval( interp, (char *)string_text(REG1) );
	  }
	REG0 = make_string( interp->result );
      }
    RETURN(1);
 tcl_error:
    REG0 = make_string( interp->result ); 
    REG1 = int2fx(rc);
    RETURN(2);
}