public void SetSingle(int counting, int dealer, int player, Situation_Info value) { situations[counting + MAX_CCN, dealer, player] = value; totalCount += value.total_Hit; totalCount += value.total_Stand; totalCount += value.total_DoubleDown; totalCount += value.total_Split; totalCount += value.total_Insurance; }
public void Init(int p_Hand, int d_Hand, Situation_Info info) { playerCard = p_Hand; dealerCard = d_Hand; information = info; // 베스트 초이스 출력 GetComponent <UISprite>().spriteName = info.bestChoice; }
ChoiceKind GetBestChoice() { Dictionary <ChoiceKind, float> choiceWinningRates = new Dictionary <ChoiceKind, float>(); Situation_Info info = DB_Manager.Instance.GetSingle(ccn, dealer.GetIndexOfOpen, aiOpponent.GetCurrentHand.GetSituationIndex); if (aiOpponent.GetCurrentHand.CanHit) { choiceWinningRates.Add(ChoiceKind.Hit, info.rate_Hit); } if (aiOpponent.GetCurrentHand.CanStand) { choiceWinningRates.Add(ChoiceKind.Stand, info.rate_Stand); } if (aiOpponent.GetCurrentHand.CanDoubleDown && aiOpponent.EnoughBetToDouble) { choiceWinningRates.Add(ChoiceKind.DoubleDown, info.rate_DoubleDown); } if (aiOpponent.GetCurrentHand.CanSplit && aiOpponent.EnoughBetToSplit) { choiceWinningRates.Add(ChoiceKind.Split, info.rate_Split); } if (aiOpponent.GetCurrentHand.CanSurrender) { choiceWinningRates.Add(ChoiceKind.Surrender, -0.5f); } ChoiceKind best = ChoiceKind.NotDetermined; float bestRate = float.MinValue; foreach (ChoiceKind kind in choiceWinningRates.Keys) { if (bestRate < choiceWinningRates[kind]) { best = kind; bestRate = choiceWinningRates[kind]; } } if (best == ChoiceKind.NotDetermined) { Debug.LogError("Stand is base choice, so whatever else should be determined in this stage"); } //Debug.Log("-------ccn:"+ ccn+"-------dealer:"+ dealer.GetIndexOfOpen+"--------ai:"+ aiOpponent.GetCurrentHand.GetSituationIndex + "---------------------"); //foreach(var item in choiceWinningRates) //{ // Debug.Log(item.Key + " = "+item.Value); //} //Debug.Log("** " + best + " **"); return(best); }
public void AddResultInfo(ResultInfo sampleInfo) { if (sampleInfo.countingNumber < MIN_CCN || sampleInfo.countingNumber > MAX_CCN) { return; } Situation_Info situation = GetSingle(sampleInfo.countingNumber, sampleInfo.dealerIdx, sampleInfo.playerIdx); switch (sampleInfo.firstChoice) { case ChoiceKind.Hit: situation.rate_Hit = (situation.total_Hit * situation.rate_Hit + sampleInfo.winningRate) / (situation.total_Hit + 1); ++(situation.total_Hit); break; case ChoiceKind.Stand: situation.rate_Stand = (situation.total_Stand * situation.rate_Stand + sampleInfo.winningRate) / (situation.total_Stand + 1); ++(situation.total_Stand); break; case ChoiceKind.DoubleDown: situation.rate_DoubleDown = (situation.total_DoubleDown * situation.rate_DoubleDown + sampleInfo.winningRate) / (situation.total_DoubleDown + 1); ++(situation.total_DoubleDown); break; case ChoiceKind.Split: situation.rate_Split = (situation.total_Split * situation.rate_Split + sampleInfo.winningRate) / (situation.total_Split + 1); ++(situation.total_Split); break; case ChoiceKind.Insurance: situation.rate_Insurance = (situation.total_Insurance * situation.rate_Insurance + sampleInfo.winningRate) / (situation.total_Insurance + 1); ++(situation.total_Insurance); break; case ChoiceKind.NotInsurance: if (sampleInfo.playerIdx == (int)SITUATION_KIND.BLACKJACK) { situation.rate_Stand = (situation.total_Stand * situation.rate_Stand + sampleInfo.winningRate) / (situation.total_Stand + 1); ++(situation.total_Stand); } break; default: break; } totalCount++; }
public void OnEndDrag() { clickPoint = Input.mousePosition; float sqrDist = (clickPoint - Input.mousePosition).sqrMagnitude; if (sqrDist < 0.01f) { clickPoint = UICamera.mainCamera.ScreenToWorldPoint(clickPoint); // 클리핑 영역 검사 if (clippingMinimum.position.x < clickPoint.x && clickPoint.x < clippingMaximum.position.x) { if (clippingMinimum.position.y < clickPoint.y && clickPoint.y < clippingMaximum.position.y) { clickPoint -= situationMinimum.position; // 월드 //clickPoint += worldOfScreenMinimum; //clickPoint = UICamera.mainCamera.WorldToScreenPoint(clickPoint); // 인덱스 계산 int d_Idx = Mathf.FloorToInt((clickPoint.x / situationSize.x) * 10); int p_Idx = 33 - Mathf.FloorToInt((clickPoint.y / situationSize.y) * 34); Situation_Info curSitu = DB_Manager.Instance.GetSingle(currentUIIndex - 20, d_Idx, p_Idx); if (p_Idx == 23 && d_Idx != 0) // 빈공간 { return; } // 명령 전달 - How? popUpUI.gameObject.SetActive(true); popUpUI.Setting(curSitu, d_Idx, p_Idx); // 하이라이트 curHighlight = UICountings[currentUIIndex].situations[d_Idx * 34 + p_Idx].gameObject.AddComponent <TweenScale>(); curHighlight.from = new Vector3(0.9f, 0.9f, 0.9f); curHighlight.to = new Vector3(1.3f, 1.3f, 1.3f); curHighlight.duration = 0.75f; curHighlight.style = UITweener.Style.PingPong; } } } }
ChoiceKind GetBestChoice(int dealer_idx) { Dictionary <ChoiceKind, float> choiceWinningRates = new Dictionary <ChoiceKind, float>(); AI_PlayerHand playerHand = player.GetCurrentHand; Situation_Info info = DB_Manager.Instance.GetSingle(player.CCNumber, dealer_idx, player.GetCurrentHand.GetSituationIndex); if (playerHand.CanHit) { choiceWinningRates.Add(ChoiceKind.Hit, info.rate_Hit); } if (playerHand.CanStand) { choiceWinningRates.Add(ChoiceKind.Stand, info.rate_Stand); } if (playerHand.CanDoubleDown) { choiceWinningRates.Add(ChoiceKind.DoubleDown, info.rate_DoubleDown); } if (playerHand.CanSplit) { choiceWinningRates.Add(ChoiceKind.Split, info.rate_Split); } if (playerHand.CanSurrender) { choiceWinningRates.Add(ChoiceKind.Surrender, -0.5f); } ChoiceKind best = ChoiceKind.NotDetermined; float bestRate = float.MinValue; foreach (ChoiceKind kind in choiceWinningRates.Keys) { if (bestRate < choiceWinningRates[kind]) { best = kind; bestRate = choiceWinningRates[kind]; } } if (best == ChoiceKind.NotDetermined) { Debug.LogError("should be determined for best choice"); } return(best); }
//_______________________________Pop Up___________________________________________ public void Setting(Situation_Info situation, int d_card, int p_card) { dealerCardLabel.text = (d_card + 1).ToString(); playerCardLabel.text = ((SITUATION_KIND)p_card).ToString(); for (int i = 0; i < UIChoiceInfo.Length; ++i) { UIChoiceInfo[i].window.alpha = 1f; } SetUIChoice(UIChoiceInfo[0], situation.total_Hit, situation.rate_Hit); SetUIChoice(UIChoiceInfo[1], situation.total_Stand, situation.rate_Stand); SetUIChoice(UIChoiceInfo[2], situation.total_DoubleDown, situation.rate_DoubleDown); if (p_card < 24) // Nope { UIChoiceInfo[3].window.alpha = 0.15f; } else // 스플릿 { SetUIChoice(UIChoiceInfo[3], situation.total_Split, situation.rate_Split); } if (d_card != 0) // Nope { UIChoiceInfo[4].window.alpha = 0.15f; } else // 인슈어런스 { if (p_card == (int)SITUATION_KIND.BLACKJACK) { UIChoiceInfo[0].window.alpha = 0.15f; UIChoiceInfo[2].window.alpha = 0.15f; UIChoiceInfo[5].window.alpha = 0.15f; } SetUIChoice(UIChoiceInfo[4], situation.total_Insurance, situation.rate_Insurance); } }