में मैं पुनरावृत्ति अल्फा-बीटा prunning, का उपयोग कर टिक टैक पैर की अंगुली खेलने के लिए कोशिश कर रहा हूँ मैं एक चाल के लिए एक दूसरे की सीमा है, लेकिन यह does not को अच्छी तरह से काम किसी कारण से।टिक टैक पैर की अंगुली अल्फा का उपयोग कर बीटा prunning जावा
मैं नियमित रूप से अल्फा बीटा कोड तो बजाय अल्फा या बीटा लौटने संशोधित, यह एक राज्य रिटर्न
हर बार जब मैं मैं उनकी गहराई को अद्यतन बच्चों बनाने (जो अगली चाल के साथ बोर्ड है)।
लेकिन फिर से किसी कारण से मैं हार रहा हूं और मुझे लगता है कि मेरा अल्फा बीटा बनाने के लिए सबसे अच्छा कदम नहीं देखता है।
बाहरी पाश:
while (watch.get_ElapsedMilliseconds() < 900 && d <= board.length * board[0].length - 1)
{
s = maxiMin(beginSt, d, watch);
if (s.getNextMove().getIsWin() == true)
{
break;
}
d++;
}
return new location(s.getNextMove().getRow(), s.getNextMove().getCol());
अल्फा बीटा:
public State maxiMin(State s, int depth, Stopwatch timer)
{
if (s.getDepth() == 7)
{
Console.WriteLine();
}
if (timer.get_ElapsedMilliseconds() > 850 || s.getDepth() == depth || goalTest(s.getBoard()) != 0)
{
s.evaluationFunc(line_length, PlayerShape);
s.setAlpha(s.getEvaluation());
s.setBeta(s.getEvaluation());
return s;
}
LinkedList<State> children = createChildren(s, true);
// No winner, the board is full
if (children.get_Count() == 0)
{
s.evaluationFunc(line_length, PlayerShape);
s.setAlpha(s.getEvaluation());
s.setBeta(s.getEvaluation());
return s;
}
while (children.get_Count() > 0)
{
State firstChild = children.get_First().get_Value();
children.RemoveFirst();
State tmp = miniMax(firstChild, depth, timer);
int value = tmp.getBeta();
if (value > s.getAlpha())
{
s.setAlpha(value);
s.setNextMove(tmp);
}
if (s.getAlpha() >= s.getBeta())
{
return s;
}
}
return s;
}
public State miniMax(State s, int depth, Stopwatch timer)
{
if (s.getDepth() == 7)
{
Console.WriteLine();
}
if (timer.get_ElapsedMilliseconds() > 850 || s.getDepth() == depth || goalTest(s.getBoard()) != 0)
{
s.evaluationFunc(line_length, PlayerShape);
s.setAlpha(s.getEvaluation());
s.setBeta(s.getEvaluation());
return s;
}
LinkedList<State> children = createChildren(s, false);
// No winner, the board is full
if (children.get_Count() == 0)
{
s.evaluationFunc(line_length, PlayerShape);
s.setAlpha(s.getEvaluation());
s.setBeta(s.getEvaluation());
return s;
}
while (children.get_Count() > 0)
{
State firstChild = children.get_First().get_Value();
children.RemoveFirst();
State tmp = maxiMin(firstChild, depth, timer);
int value = tmp.getAlpha();
if (value < s.getBeta())
{
s.setBeta(value);
s.setNextMove(tmp);
}
if (s.getAlpha() >= s.getBeta())
{
return s;
}
}
return s;
}
बहुत appriciate होगा अगर किसी को भी मुझे बता सकते हैं अगर कुछ गलत है
यहाँ मेरी कोड है। मैं शायद संदेह कि के साथ क्या करना यह कुछ मैं लौट रहा हूँ "एस" नियमित रूप से अल्फा बीटा जो मूल्यांकन रिटर्न लेकिन मैं त्रुटि खोजने के लिए प्रबंधन फ्लॉप के बजाय।
अग्रिम धन्यवाद,
लीना
मुझे लगता है कि आपको मिनीमैक्स (http://en.wikipedia.org/wiki/Minimax) से शुरू करना चाहिए, तब जब आप अल्फा बीटा में उस काम को जोड़ते हैं। इससे डीबग करना बहुत आसान हो जाएगा। Minimax अनिवार्य रूप से छंटनी के बिना अल्फा बीटा है। Minimax कुछ सेकंड के भीतर आसानी से टिक टैक पैर की अंगुली हल करेगा। – theycallhimtom