Click here to Skip to main content
15,887,175 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: get the a 2days time dif fromcurrent time. Pin
Jochen Arndt11-Oct-15 21:23
professionalJochen Arndt11-Oct-15 21:23 
GeneralRe: get the a 2days time dif fromcurrent time. Pin
Peter_in_278011-Oct-15 21:31
professionalPeter_in_278011-Oct-15 21:31 
GeneralRe: get the a 2days time dif fromcurrent time. Pin
Jochen Arndt11-Oct-15 21:33
professionalJochen Arndt11-Oct-15 21:33 
AnswerRe: get the a 2days time dif fromcurrent time. Pin
CPallini11-Oct-15 21:35
mveCPallini11-Oct-15 21:35 
GeneralRe: get the a 2days time dif fromcurrent time. Pin
Daniel Pfeffer12-Oct-15 3:51
professionalDaniel Pfeffer12-Oct-15 3:51 
Questionhow to implement alpha-beta pruning (tic tac toe) Pin
cristianpff9-Oct-15 23:36
cristianpff9-Oct-15 23:36 
AnswerRe: how to implement alpha-beta pruning (tic tac toe) Pin
CPallini11-Oct-15 4:42
mveCPallini11-Oct-15 4:42 
GeneralRe: how to implement alpha-beta pruning (tic tac toe) Pin
cristianpff12-Oct-15 3:01
cristianpff12-Oct-15 3:01 
hi, i read the article on wikipedia and i understand it but the problem is that i don't know how to implement it to my minimax Cry | :((
here is my minimax if want to give me an idea .. Wink | ;)

C++
int miniMax(char wnr, int deep)//Minimax
{
	if (controlloVincita(2))//control win
		return INT_MAX;
	if (endgame())
		return INT_MIN;
	int i, j, res, tmp;
	
	if (wnr == 1)//se giocatore massimizzante
	{
		res = 1;
		for (i = 0;i<M;i++)
			for (j = 0;j<N;j++)
			{
				if (BOARD[i][j]==0)
				{
					BOARD[i][j] = 1;
					if (controlloVincita(1))
						if (deep == 20)
						{
							BOARD[i][j] = 0;
							return INT_MIN;
						}
						else
							res -= 2;
					else if ((tmp = miniMax(2, deep - 1))<res || (tmp == INT_MIN))
						res = tmp;
					BOARD[i][j] = 0;
				}
			}
	}
	else
	{
		res = -1;
		for (i = 0;i<M;i++)
			for (j = 0;j<N;j++)
			{
				if (BOARD[i][j]==0)
				{
					BOARD[i][j] = 2;
					if (controlloVincita(2))
						res += 2;
					else if ((tmp = miniMax(1, deep - 1))>res || (tmp == INT_MAX))
						res = tmp;
					BOARD[i][j] = 0;
				}
			}
	}
	return res;
}

int get_next_move(unsigned int *i, unsigned int *j)
{
	int max = INT_MIN, mi = 1, mj = 1, t;
	int alfa = INT_MIN, beta = INT_MAX;
	for (*i = 0;*i<M;(*i)++)
		for (*j = 0;*j<N;(*j)++)
			if (BOARD[*i][*j]==0)//matrix empty
			{
				BOARD[*i][*j] = 2;//first player 
				t = miniMax(1, 20);//recursive minimax
				if (t>max)//
				{
					max = t;
					mi = *i;
					mj = *j;
				}
				BOARD[*i][*j] = 0;
			}
	
	BOARD[mi][mj] = 2;//save the computer move
	*i = mi;
	*j = mj;
	return 1;
}

QuestionSet whole Data to a struct with BitFields Pin
FrankStar896-Oct-15 4:10
FrankStar896-Oct-15 4:10 
AnswerRe: Set whole Data to a struct with BitFields Pin
Albert Holguin6-Oct-15 4:50
professionalAlbert Holguin6-Oct-15 4:50 
AnswerRe: Set whole Data to a struct with BitFields PinPopular
Richard MacCutchan6-Oct-15 4:54
mveRichard MacCutchan6-Oct-15 4:54 
Questionhow to parse html code in c language Pin
Member 118352695-Oct-15 21:04
Member 118352695-Oct-15 21:04 
AnswerRe: how to parse html code in c language Pin
Richard MacCutchan5-Oct-15 22:00
mveRichard MacCutchan5-Oct-15 22:00 
QuestionC: Book recommendations Pin
Member 114893145-Oct-15 6:58
Member 114893145-Oct-15 6:58 
AnswerRe: C: Book recommendations Pin
Richard MacCutchan5-Oct-15 7:06
mveRichard MacCutchan5-Oct-15 7:06 
AnswerRe: C: Book recommendations Pin
Richard Andrew x645-Oct-15 12:09
professionalRichard Andrew x645-Oct-15 12:09 
GeneralRe: C: Book recommendations Pin
Albert Holguin6-Oct-15 4:59
professionalAlbert Holguin6-Oct-15 4:59 
QuestionWindows message for changing color scheme Pin
_Flaviu5-Oct-15 2:15
_Flaviu5-Oct-15 2:15 
AnswerRe: Windows message for changing color scheme Pin
_Flaviu5-Oct-15 3:07
_Flaviu5-Oct-15 3:07 
QuestionRe: Windows message for changing color scheme Pin
Richard MacCutchan5-Oct-15 3:47
mveRichard MacCutchan5-Oct-15 3:47 
AnswerRe: Windows message for changing color scheme Pin
_Flaviu5-Oct-15 20:18
_Flaviu5-Oct-15 20:18 
AnswerRe: Windows message for changing color scheme Pin
_Flaviu7-Oct-15 0:46
_Flaviu7-Oct-15 0:46 
Questionuploadig adobe reader file in local host in c language Pin
sunycity4-Oct-15 22:31
sunycity4-Oct-15 22:31 
AnswerRe: uploadig adobe reader file in local host in c language Pin
Jochen Arndt4-Oct-15 22:54
professionalJochen Arndt4-Oct-15 22:54 
QuestionCFileDialog OnTypeChange issue Pin
_Flaviu1-Oct-15 20:59
_Flaviu1-Oct-15 20:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.