Created
August 26, 2009 19:41
-
-
Save vsalbaba/175749 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Tah Najdi_nejlepsi_tah() | |
{ | |
Random rand = new Random (); | |
int i = 0; | |
for (i = 0; i < strom.Count; i++) | |
{ | |
if (strom[i].Ohodnoceni == 5000) | |
{ | |
return strom[i]; | |
} | |
} | |
for (i = 0; i < strom.Count; i++) | |
{ | |
if (strom[i].Ohodnoceni == 1000) | |
{ | |
return strom[i]; | |
} | |
} | |
for (i = 0; i < strom.Count; i++) | |
{ | |
if (strom[i].Ohodnoceni == 900) | |
{ | |
return strom[i]; | |
} | |
} | |
for (i = 0; i < strom.Count; i++) | |
{ | |
if (strom[i].Ohodnoceni == 800) | |
{ | |
return strom[i]; | |
} | |
} | |
for (i = 0; i < strom.Count; i++) | |
{ | |
if (strom[i].Ohodnoceni == 700) | |
{ | |
return strom[i]; | |
} | |
} | |
for (i = 0; i < strom.Count; i++) | |
{ | |
if (strom[i].Ohodnoceni == 600) | |
{ | |
return strom[i]; | |
} | |
} | |
for (i = 0; i < strom.Count; i++) | |
{ | |
if (strom[i].Ohodnoceni == 500) | |
{ | |
return strom[i]; | |
} | |
} | |
for (i = 0; i < strom.Count; i++) | |
{ | |
if (strom[i].Ohodnoceni == 400) | |
{ | |
return strom[i]; | |
} | |
} | |
for (i = 0; i < strom.Count; i++) | |
{ | |
if (strom[i].Ohodnoceni == 300) | |
{ | |
return strom[i]; | |
} | |
} | |
i = rand.Next (0, Strom.Count); | |
return Strom[i]; | |
//List<int> nejmensiPole = new List<int>(20);//bude mit tolik prvku kolik tahu ma strom (tzn. prvni vrstva) | |
//int pruchod = 0; | |
//int indexNejmensiho = 0; | |
//int nej = 0; | |
//int i; | |
////naplnim si nejmensi_pole....pro vsechny tahy ve strome | |
//foreach (Tah n in strom) | |
//{ | |
// //ohodnoceni daneho tahu s ohodnocenim nejspodnejsi vrstvy | |
// if (n.Dalsi_tahy.Count != 0) //pokud jsou tam jeste dalsi tahy | |
// { | |
// nejmensiPole.Add(n.Ohodnoceni + NajdiNejmensi(n.Dalsi_tahy)); | |
// //Console.WriteLine("OHODNOCENI: {0}", n.Ohodnoceni + NajdiNejmensi(n.Dalsi_tahy) + " " + n.ToString()); | |
// } | |
// else //ale pokud tam nejsou, nemuzeme z niceho vybirat dal... | |
// { | |
// nejmensiPole.Add(n.Ohodnoceni); | |
// //Console.WriteLine("OHODNOCENI: {0}", n.Ohodnoceni + " " + n.ToString()); | |
// } | |
// //musim vratit zpet na pocatecni hodnoty aby se vysledky neopakovali, kvuli volani funkce NajdiNejmensi | |
// this.pruchod = false; | |
// this.nejmensi = int.MinValue; // -12345 | |
// this.pocitadlo = 0; | |
//} | |
//i = 0; | |
////najdu nejmensiprvek z toho pole a to bude index nejlepsiho tahu | |
//foreach (int n in nejmensiPole) | |
//{ | |
// if (pruchod == 0) //pro prvni kolo (prvni prvek nejmensihoPole) | |
// { | |
// indexNejmensiho = 0; | |
// nej = n; | |
// pruchod = 1;//aby se dostal uz jen do vetve else.... | |
// } | |
// else | |
// { | |
// if (nej < n) //hledame nejlepsi ohodnoceni | |
// { | |
// nej = n; | |
// indexNejmensiho = i; //zapamatujeme si index | |
// } | |
// } | |
// i++; | |
//} | |
////vrati nejlepsi tah | |
//return strom[indexNejmensiho]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment