private bool CanHitOpponentWithThis(List <typeDepthData> acceptableTypes, columnData me) { for (int x = 0; x < acceptableTypes.Count; x++) { if (beats(me.type, acceptableTypes[x].type) && me.height >= acceptableTypes[x].depth) { return(true); } } return(false); }
public object GetChartDataSourse(string BTime, string ETime, DataTable dt) { columnChart retChart_column = new columnChart(); retChart_column.Tittle = "HWDLineFailReport"; retChart_column.ChartTitle = "HWD" + BTime + "-" + ETime + "生產投入統計圖"; retChart_column.ChartSubTitle = "線別/機種產出趨勢圖"; XAxis _XAxis = new XAxis(); _XAxis.Title = "機種"; //_XAxis.Categories = new List<string> { "B32S1","B32S2","B32S3","B32S4"}; //_XAxis.XAxisType = XAxisType.datetime; retChart_column.XAxis = _XAxis; retChart_column.Tooltip = "Pic"; Yaxis _YAxis = new Yaxis(); _YAxis.Title = "投入數"; retChart_column.YAxis = _YAxis; ChartData ChartData1 = new ChartData(); ChartData1.name = "HWD 產出統計"; ChartData1.type = ChartType.column.ToString(); ChartData1.colorByPoint = true; List <object> chartDataSourse = new List <object>(); for (int i = 0; i < dt.Rows.Count; i++) { columnData columnData = new columnData(); columnData.name = dt.Rows[i]["料號"].ToString(); columnData.y = Convert.ToInt32(dt.Rows[i]["投入"]); chartDataSourse.Add(columnData); } ChartData1.data = chartDataSourse; List <ChartData> _ChartDatas = new List <ChartData> { ChartData1 }; retChart_column.ChartDatas = _ChartDatas; return(retChart_column); }
private AIAction s0_0() // SEE IF ANYTHING EXISTING WORKS { if (repeats0++ > repeatTheshold) { state = 3; return(s0_3()); } List <typeDepthData> acceptableTypes = GetAcceptableTypesAndTheirMinimumDepths(); List <columnData> res = new List <columnData>(); int cx = c.getX(); for (int x = 0; x < myBoard.width; x++) { int topYAtX = myBoard.GetHighestYAtX(x); if (topYAtX <= 0) { continue; } int typeAtPos = myBoard.GetValueAtXY(x, topYAtX).GetColorVal(); int height = 1; for (int y = topYAtX - 1; y >= 0; y--) { if (myBoard.GetValueAtXY(x, y).GetColorVal() != typeAtPos) { break; } height++; } if (height == 1) { continue; } columnData cda = new columnData(x, typeAtPos, height, GetDistanceBetweenPoints(cx, x)); if (CanHitOpponentWithThis(acceptableTypes, cda)) { res.Add(cda); } } if (res.Count == 0) { state = 3; return(s0_3()); } state = 1; res.Sort((a, b) => Mathf.Abs(a.dx).CompareTo(Mathf.Abs(b.dx))); int choice = Random.Range(0, Mathf.FloorToInt(paddingForPathetic * res.Count)); int chances = 0; List <distXData> res2 = new List <distXData>(); columnData chosenOne = res[choice]; yourX = chosenOne.x; yourType = chosenOne.type; while (chances++ < 3 && choice < res.Count) { res2.Clear(); for (int x = 0; x < acceptableTypes.Count; x++) { if (!beats(yourType, acceptableTypes[x].type)) { continue; } res2.Add(new distXData(x, GetDistanceBetweenPoints(chosenOne.x, myBoard.width - 1 - x))); } if (res2.Count != 0) { break; } } if (res2.Count == 0) { state = 3; return(s0_3()); } res2.Sort((a, b) => Mathf.Abs(a.dx).CompareTo(Mathf.Abs(b.dx))); distXData chosenOne2 = res2[Random.Range(0, Mathf.FloorToInt(paddingForPathetic * res2.Count))]; theirInvertedX = myBoard.width - 1 - chosenOne2.x; theirType = whatIsBeatenWhat(yourType); dxdir = chosenOne.dx == 0 ? 0 : chosenOne.dx / Mathf.Abs(chosenOne.dx); shiftdir = chosenOne2.dx == 0 ? 0 : chosenOne2.dx / Mathf.Abs(chosenOne2.dx); return(s0_1(yourX, theirInvertedX, yourType, theirType, dxdir, shiftdir)); }
private AIAction s2_0() // FIND SOMETHING TO CREATE { int cy = c.getY(); List <int> types = new List <int>(); for (int x = 0; x < myBoard.width; x++) { int type = myBoard.GetValueAtXY(x, cy).GetColorVal(); if (types.Contains(type)) { continue; } types.Add(type); } if (types.Count == 1 && types[0] == myBoard.deathTile) { y_row--; if (cy == 0) { state = 999; return(sOhFuckLetsGoRandom()); } else { return(new AIAction(0, -1)); } } List <int> beatableXs = new List <int>(); List <int> winningTypes = new List <int>(); for (int x = 0; x < enemyBoard.width; x++) { int type = enemyBoard.GetTopValueAtX(x); for (int i = 0; i < types.Count; i++) { if (types[i] != myBoard.deathTile && beats(types[i], type)) { int wintype = whatBeatsWhat(type); beatableXs.Add(enemyBoard.width - 1 - x); if (!winningTypes.Contains(wintype)) { winningTypes.Add(wintype); } } } } if (beatableXs.Count == 0) { if (types.Contains(myBoard.deathTile)) { y_row--; if (cy == 0) { state = 999; return(sOhFuckLetsGoRandom()); } else { return(new AIAction(0, -1)); } } else { state = 30; return(s3_0()); } } int cx = c.getX(); List <columnData> res = new List <columnData>(); for (int x = 0; x < myBoard.width; x++) { int t = myBoard.GetValueAtXY(x, cy).GetColorVal(); if (winningTypes.Contains(t)) { res.Add(new columnData(x, t, 0, GetDistanceBetweenPoints(cx, x))); } } if (res.Count > 0) { res.Sort((a, b) => Mathf.Abs(a.dx).CompareTo(Mathf.Abs(b.dx))); columnData chosenOne = res[Random.Range(0, Mathf.FloorToInt(paddingForPathetic * (res.Count - 1)))]; yourType = chosenOne.type; yourX = chosenOne.x; dxdir = chosenOne.dx == 0 ? 0 : chosenOne.dx / Mathf.Abs(chosenOne.dx); if (cy == (myBoard.height - myBoard.topoffset)) { state = 21; } else { state = 22; } } return(new AIAction(0, 0)); }