private void NextGame_Click(object sender, EventArgs e) { WindowOfGame wog = new WindowOfGame(playersForm, hra, wops); wog.Show(); this.Close(); }
private static void OnTimedEvent(object source, ElapsedEventArgs e) { ticks++; if (ticks == 2) { WindowOfGame.CreatingBorders(); for (int i = 0; i < players.Length; i++) { Thread.Sleep(20); players[i].CreatePosition(new Random()); } } if (ticks > 2) { for (int i = 0; i < players.Length; i++) { if (!players[i].IsDead()) { if (ticks % rotateRadius == 0) { if (players[i] is Human) { ((Human)players[i]).SetFalseToTurning(); } else { ((PC)players[i]).ExecuteTurning(); } } players[i].Move(); } } WindowOfGame.Draw(); } }
public bool CanIGoThere() { Vector v = SetFirstField(); Vector v1 = new Vector(); Vector v2 = new Vector(); Vector u = new Vector(); int i = 4; u.x = positionAPCBig.x + i * (v.y - positionAPC.y); //prehozeny direction u.y = positionAPCBig.y + i * (v.x - positionAPC.x); //prehozeny direction v1 = FixIndexesForTurning(u); i = 1; u.x = positionAPCBig.x + i * (v.y - positionAPC.y); //prehozeny direction u.y = positionAPCBig.y + i * (v.x - positionAPC.x); //prehozeny direction v2 = FixIndexesForTurning(u); WindowOfGame.Log("My values: " + positionAPCBig.x + ", " + positionAPCBig.y); if (WindowOfGame.GetApcMapBig().GetFieldValue((int)v1.x, (int)v1.y) == 1 || WindowOfGame.GetApcMapBig().GetFieldValue((int)v2.x, (int)v2.y) == 1) { WindowOfGame.Log("false"); return(false); } return(true); }
private void Start_Click(object sender, EventArgs e) { SetPlayers(); Game hra = new Game(players); WindowOfGame wog = new WindowOfGame(players, hra, this); wog.Show(); this.Hide(); }
private void SaveTrainingData(Neuron[] neurs, Output[] outs) { TrainingValues tv = new TrainingValues(); tv.y = new double[outs.Length]; for (int i = 0; i < outs.Length; i++) { tv.y[i] = outs[i].z; } tv.neurons = neurs; tv.t = WindowOfGame.GetTrainingValues(tv.y); DataSet.Add(tv); }
private void FindNextStepAI() { MapAPC map = WindowOfGame.GetApcMap(); MapAPCBig mapBig = WindowOfGame.GetApcMapBig(); GetInputReady(map, mapBig); so.SetSoftmaxOutput(neurons[0].W.Length, neurons); /* * pouze pokud chci trenovat neurnovou sit: * TrainingCounter++; * if (TrainingCounter%5 == 0) * { * TrainWs(so.GetDeltaWs()); * }*/ if (!CanIGoThereRunning) { CanIGoThereRunning = true; WindowOfGame.Log("FindNextStepAI, can i go there?"); if (!CanIGoThere()) { WindowOfGame.Log("FindNextStepAI, i cant go there"); if (!CanIGoToRight()) { TurningState = 1; } else { TurningState = -1; } TurningCounter = 10; } else { switch (so.GetTheHighestOutput()) { case 0: //nonturning, puvodne "hodne doleva" TurningState = 0; TurningCounter = 5; break; case 1: //nonturning, puvodne "stredne doleva" TurningState = 0; TurningCounter = 5; break; case 2: //short left TurningState = -1; TurningCounter = 4; break; case 3: //nonturning TurningState = 0; TurningCounter = 5; break; case 4: //short right TurningState = 1; TurningCounter = 4; break; case 5: //nonturning, puvodne "stredne doprava" TurningState = 0; TurningCounter = 5; break; case 6: //nonturning, puvodne "hodne doprava" TurningState = 0; TurningCounter = 5; break; } } } recalculationRunning = false; CanIGoThereRunning = false; }