유 니 티 개발 두 지주 알고리즘 - AI 제시 (카드 제시)
21610 단어 unity3d
다음은 코드.
#region
public static Dictionary> FindPromptCards(List myCards,
List lastCards, DDZ_POKER_TYPE lastCardType) {
Dictionary> PromptCards = new Dictionary>();
Hashtable tempMyCardHash = SortCardUseHash1(myCards);
//
int prevSize = lastCards.Count;
int mySize = myCards.Count;
// ,
if (prevSize == 0 && mySize != 0)
{
//
Debug.Log(" ");
List myCardsHashKey = new List();
foreach (int key in tempMyCardHash.Keys)
{
myCardsHashKey.Add(key);
}
myCardsHashKey.Sort();
for (int i = 0; i < myCardsHashKey.Count; i++) {
List tempIntList = new List();
tempIntList.Add(myCardsHashKey[i]);
PromptCards.Add(i, tempIntList);
}
}
// ,
if (lastCardType == DDZ_POKER_TYPE.KingBomb)
{
Debug.Log(" , 。");
}
int prevGrade = 0;
if (prevSize > 0) {
prevGrade = lastCards[0];
Debug.Log("prevGrade" + prevGrade);
}
// 2 , 2 ,1. , ;
// 2. , ,
//
//
if (lastCardType == DDZ_POKER_TYPE.Single)
{
int tempCount = 0;
List myCardsHashKey = new List();
foreach (int key in tempMyCardHash.Keys)
{
myCardsHashKey.Add(key);
}
myCardsHashKey.Sort();
for (int i = 0; i < myCardsHashKey.Count; i++)
{
if (myCardsHashKey[i] > prevGrade){
List tempIntList = new List();
tempIntList.Add(myCardsHashKey[i]);
PromptCards.Add(tempCount, tempIntList);
tempCount++;
}
}
}
//
else if (lastCardType == DDZ_POKER_TYPE.Twin)
{
int tempCount = 0;
List myCardsHashKey = new List();
foreach (int key in tempMyCardHash.Keys)
{
myCardsHashKey.Add(key);
}
myCardsHashKey.Sort();
for (int i = 0; i < myCardsHashKey.Count; i++)
{
if (myCardsHashKey[i] > prevGrade&& (int)tempMyCardHash[myCardsHashKey[i]]>=2)
{
List tempIntList = new List();
tempIntList.Add(myCardsHashKey[i]);
tempIntList.Add(myCardsHashKey[i]);
PromptCards.Add(tempCount, tempIntList);
tempCount++;
}
}
}
// 3
else if (lastCardType == DDZ_POKER_TYPE.Triple)
{
int tempCount = 0;
List myCardsHashKey = new List();
foreach (int key in tempMyCardHash.Keys)
{
myCardsHashKey.Add(key);
}
myCardsHashKey.Sort();
for (int i = 0; i < myCardsHashKey.Count; i++)
{
if (myCardsHashKey[i] > prevGrade && (int)tempMyCardHash[myCardsHashKey[i]] >= 3)
{
List tempIntList = new List();
tempIntList.Add(myCardsHashKey[i]);
tempIntList.Add(myCardsHashKey[i]);
tempIntList.Add(myCardsHashKey[i]);
PromptCards.Add(tempCount, tempIntList);
tempCount++;
}
}
}
// 3 1
else if (lastCardType == DDZ_POKER_TYPE.TripleWithSingle)
{
// 3 1 3
if (mySize < 4)
{
}
int grade3=0;
foreach (int key in tempMyCardHash.Keys)
{
if (int.Parse(tempMyCardHash[key].ToString()) == 1) {
grade3 = key;
break;
}
}
int tempCount = 0;
List myCardsHashKey = new List();
foreach (int key in tempMyCardHash.Keys)
{
myCardsHashKey.Add(key);
}
myCardsHashKey.Sort();
for (int i = 0; i < myCardsHashKey.Count; i++)
{
if (myCardsHashKey[i] > prevGrade && (int)tempMyCardHash[myCardsHashKey[i]] >= 3)
{
List tempIntList = new List();
tempIntList.Add(myCardsHashKey[i]);
tempIntList.Add(myCardsHashKey[i]);
tempIntList.Add(myCardsHashKey[i]);
tempIntList.Add(grade3);
PromptCards.Add(tempCount, tempIntList);
tempCount++;
}
}
}
// 3 2
else if (lastCardType == DDZ_POKER_TYPE.TripleWithTwin)
{
// 3 1 3
if (mySize < 5)
{
}
int grade3 = 0;
int grade4 = 0;
foreach (int key in tempMyCardHash.Keys)
{
if (int.Parse(tempMyCardHash[key].ToString()) == 2)
{
grade3 = key;
grade4 = key;
break;
}
}
int tempCount = 0;
List myCardsHashKey = new List();
foreach (int key in tempMyCardHash.Keys)
{
myCardsHashKey.Add(key);
}
myCardsHashKey.Sort();
for (int i = 0; i < myCardsHashKey.Count; i++)
{
if (myCardsHashKey[i] > prevGrade && (int)tempMyCardHash[myCardsHashKey[i]] >= 3)
{
List tempIntList = new List();
tempIntList.Add(myCardsHashKey[i]);
tempIntList.Add(myCardsHashKey[i]);
tempIntList.Add(myCardsHashKey[i]);
tempIntList.Add(grade3);
tempIntList.Add(grade4);
PromptCards.Add(tempCount, tempIntList);
tempCount++;
}
}
}
//
else if (lastCardType == DDZ_POKER_TYPE.FourBomb)
{
int tempCount = 0;
// 4
for (int i = mySize - 1; i >= 3; i--)
{
int grade0 = myCards[i];
int grade1 = myCards[i - 1];
int grade2 = myCards[i - 2];
int grade3 = myCards[i - 3];
if (grade0 == grade1 && grade0 == grade2 && grade0 == grade3)
{
if (grade0 > prevGrade)
{
//
List tempIntList = new List();
tempIntList.Add(grade0);
tempIntList.Add(grade1);
tempIntList.Add(grade2);
tempIntList.Add(grade3);
PromptCards.Add(tempCount, tempIntList);
tempCount++;
}
}
}
}
// 4 2
else if (lastCardType == DDZ_POKER_TYPE.FourWithSingle)
{
// 4
for (int i = mySize - 1; i >= 3; i--)
{
int grade0 = myCards[i];
int grade1 = myCards[i - 1];
int grade2 = myCards[i - 2];
int grade3 = myCards[i - 3];
if (grade0 == grade1 && grade0 == grade2 && grade0 == grade3)
{
// , true
}
}
}
// 4 2
else if (lastCardType == DDZ_POKER_TYPE.FourWithSingle)
{
// 4
for (int i = mySize - 1; i >= 3; i--)
{
int grade0 = myCards[i];
int grade1 = myCards[i - 1];
int grade2 = myCards[i - 2];
int grade3 = myCards[i - 3];
if (grade0 == grade1 && grade0 == grade2 && grade0 == grade3)
{
// , true
}
}
}
//
else if (lastCardType == DDZ_POKER_TYPE.StraightSingle)
{
if (mySize < prevSize)
{
}
else
{
List tempMyCards = new List();
tempMyCards = myCards;
Hashtable myCardsHash = SortCardUseHash(tempMyCards);
if (myCardsHash.Count < prevSize)
{
Debug.Log("hash count fales");
}
List myCardsHashKey = new List();
foreach (int key in myCardsHash.Keys)
{
myCardsHashKey.Add(key);
}
myCardsHashKey.Sort();
int tempCount = 0;
for (int i = myCardsHashKey.Count - 1; i >= prevSize - 1; i--)
{
List cards = new List();
for (int j = 0; j < prevSize; j++)
{
cards.Add(myCardsHashKey[myCardsHashKey.Count - 1 - i + j]);
}
DDZ_POKER_TYPE myCardType = DDZ_POKER_TYPE.DdzPass;
bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
if (myCardType == DDZ_POKER_TYPE.StraightSingle)
{
int myGrade2 = cards[cards.Count - 1];//
int prevGrade2 = lastCards[prevSize - 1];//
if (myGrade2 > prevGrade2)
{
// PromptCards
PromptCards.Add(tempCount, cards);
tempCount++;
}
}
}
}
}
//
else if (lastCardType == DDZ_POKER_TYPE.StraightTwin)
{
if (mySize < prevSize)
{
}
else
{
List tempMyCards = new List();
tempMyCards = myCards;
Hashtable myCardsHash = SortCardUseHash(tempMyCards);
if (myCardsHash.Count < prevSize)
{
Debug.Log("hash count fales");
}
List myCardsHashKey = new List();
foreach (int key in myCardsHash.Keys)
{
myCardsHashKey.Add(key);
}
myCardsHashKey.Sort();
int tempCount = 0;
for (int i = myCardsHashKey.Count - 1; i >= prevSize - 1; i--)
{
List cards = new List();
for (int j = 0; j < prevSize; j++)
{
cards.Add(myCardsHashKey[myCardsHashKey.Count - 1 - i + j]);
}
DDZ_POKER_TYPE myCardType = DDZ_POKER_TYPE.DdzPass;
bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
if (myCardType == DDZ_POKER_TYPE.StraightSingle)
{
int myGrade2 = cards[cards.Count - 1];//
int prevGrade2 = lastCards[prevSize - 1];//
if (myGrade2 > prevGrade2)
{
for (int ii = 0; ii < cards.Count; ii++)
{
if ((int)myCardsHash[cards[ii]] < 2)
{
Debug.Log(" ");
return PromptCards;
}
else
{
for (int iii = 0; iii < cards.Count; iii++) {
cards.Add(cards[iii]);
}
// PromptCards
PromptCards.Add(tempCount, cards);
tempCount++;
}
}
}
}
}
}
}
//
else if (lastCardType == DDZ_POKER_TYPE.PlanePure)
{
if (mySize < prevSize)
{
}
else
{
int tempCount = 0;
for (int i = 0; i <= mySize - prevSize; i++)
{
List cards = new List();
for (int j = 0; j < prevSize; j++)
{
cards.Add(myCards[i+ j]);
}
DDZ_POKER_TYPE myCardType = DDZ_POKER_TYPE.DdzPass;
bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
if (myCardType == DDZ_POKER_TYPE.PlanePure)
{
int myGrade4 = cards[4];//
int prevGrade4 = lastCards[4];//
if (myGrade4 > prevGrade4)
{
// PromptCards
PromptCards.Add(tempCount, cards);
tempCount++;
}
}
}
}
}
//
else if (lastCardType == DDZ_POKER_TYPE.PlaneWithSingle)
{
if (mySize < prevSize)
{
}
else
{
int tempCount = 0;
for (int i = 0; i <= mySize - prevSize; i++)
{
List cards = new List();
for (int j = 0; j < prevSize- prevSize/4; j++)
{
cards.Add(myCards[i +j]);
}
DDZ_POKER_TYPE myCardType = DDZ_POKER_TYPE.DdzPass;
bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
if (myCardType == DDZ_POKER_TYPE.PlanePure)
{
int myGrade4 = cards[4];//
int prevGrade4 = lastCards[4];//
if (myGrade4 > prevGrade4)
{
int ii = 0;
// PromptCards
foreach (int key in tempMyCardHash.Keys)
{
if (int.Parse(tempMyCardHash[key].ToString()) == 1)
{
cards.Add(key);
ii++;
if (ii == prevSize/4) {
break;
}
}
}
PromptCards.Add(tempCount, cards);
tempCount++;
}
}
}
}
}
//
else if (lastCardType == DDZ_POKER_TYPE.PlaneWithTwin)
{
if (mySize < prevSize)
{
}
else
{
int tempCount = 0;
for (int i = 0; i <= mySize - prevSize; i++)
{
List cards = new List();
for (int j = 0; j < prevSize- prevSize/5; j++)
{
cards.Add(myCards[i + j]);
}
DDZ_POKER_TYPE myCardType = DDZ_POKER_TYPE.DdzPass;
bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
if (myCardType == DDZ_POKER_TYPE.PlanePure)
{
int myGrade4 = cards[4];//
int prevGrade4 = lastCards[4];//
if (myGrade4 > prevGrade4)
{
List tempTwoList = new List();
for (int ii = 0; ii < cards.Count; ii++)
{
int tempInt = 0;
for (int j = 0; j < cards.Count; j++)
{
if (cards[ii] == cards[j])
{
tempInt++;
}
}
if (tempInt == 2)
{
tempTwoList.Add(cards[ii]);
}
}
if (tempTwoList.Count / 2 < prevSize / 5)
{
}
else
{
//
int iii = 0;
// PromptCards
foreach (int key in tempMyCardHash.Keys)
{
if (int.Parse(tempMyCardHash[key].ToString()) == 2)
{
cards.Add(key);
cards.Add(key);
iii++;
if (iii == prevSize /5)
{
break;
}
}
}
PromptCards.Add(tempCount, cards);
tempCount++;
}
}
}
}
}
}
// ,
if (lastCardType != DDZ_POKER_TYPE.FourBomb)
{
List myCardsHashKey = new List();
foreach (int key in tempMyCardHash.Keys)
{
myCardsHashKey.Add(key);
}
myCardsHashKey.Sort();
for (int i = 0; i < myCardsHashKey.Count; i++)
{
if ( (int)tempMyCardHash[myCardsHashKey[i]] == 4)
{
List tempIntList = new List();
tempIntList.Add(myCardsHashKey[i]);
tempIntList.Add(myCardsHashKey[i]);
tempIntList.Add(myCardsHashKey[i]);
tempIntList.Add(myCardsHashKey[i]);
Debug.Log("PromptCards.Count"+PromptCards.Count);
PromptCards.Add(PromptCards.Count, tempIntList);
}
}
}
if (mySize >= 2)
{
List myCardsHashKey = new List();
foreach (int key in tempMyCardHash.Keys)
{
myCardsHashKey.Add(key);
}
if (myCardsHashKey.Contains(53) && myCardsHashKey.Contains(54)) {
List tempIntList = new List();
tempIntList.Add(53);
tempIntList.Add(54);
PromptCards.Add(PromptCards.Count, tempIntList);
}
}
return PromptCards;
}
#endregion
/ / 패 번호: 1 ~ 54 부터 흑 홍 매 방 순 으로 1 은 블랙 3, 2 는 블랙 4, 12 는 블랙 1, 13 은 블랙 2, 14 는 레 드 4,..., 53 은 작은 털, 54 큰 털.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Unity용 VLC 소개 - Android 에디션숙련된 Unity 개발자는 유명한 Big Buck Bunny 비디오를 재생하는 VLC 플러그인을 보여주기 위해 편집된 유명한 Unity 장면 을 인식할 것입니다. 이 Unity 플러그인을 사용하면 Unity 기반 A...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.