Advertisement
Kokujou

Schach Programm

Nov 20th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 57.84 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Text;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8.  
  9. /*
  10.     ToDo:
  11.        - KI-Sonderfall: Bauern Umwandlung
  12.        - Endzustanderkennung: Vorrübergehend auf Schlagen des Königs gesetzt
  13.        - Onselect Rochade überdenken
  14.        - Zustandsbaum: Unrealistische Zeit
  15.        - Wertkalkulation bei Schlagen des Königs prüfen
  16.        - Multithreading Problem gelöst. Nullreferece bei RateState
  17. */
  18.  
  19. namespace ObscuritasSchach
  20. {
  21.     public class Program
  22.     {
  23.         public class Vector2
  24.         {
  25.             public int Y;
  26.             public int X;
  27.             public static float Distance(Vector2 A, Vector2 B)
  28.             {
  29.                 return (float)(Math.Sqrt(Math.Pow(A.X, 2) + Math.Pow(B.Y, 2)));
  30.             }
  31.             public Vector2(int x, int y)
  32.             {
  33.                 X = x;
  34.                 Y = y;
  35.             }
  36.         }
  37.         public class KI
  38.         {
  39.             public static List<List<State>> StateTree = new List<List<State>>();
  40.             public static int[][] Root;
  41.             public static Spieler Player;
  42.             public KI cKI;
  43.             public static bool TreeContainsField(int[][] Field)
  44.             {
  45.                 for (int i = 0; i < StateTree.Count; i++)
  46.                 {
  47.                     for (int j = 0; j < StateTree[i].Count; j++)
  48.                     {
  49.                         for (int k = 0; k < StateTree[i][j].Feld.Length; k++)
  50.                         {
  51.                             for (int l = 0; l < StateTree[i][j].Feld[k].Length; l++)
  52.                             {
  53.                                 if (StateTree[i][j].Feld[k][l] != Field[k][l])
  54.                                     return false;
  55.                             }
  56.                         }
  57.                     }
  58.                 }
  59.                 return true;
  60.             }
  61.             private static object thisLock = new object();
  62.             public static void BuildNode(State node, int pid, bool Turn, int level)
  63.             {
  64.                 List<PFigur>[] FigurSets = new List<PFigur>[2];
  65.                 if (!node.isFinal)
  66.                 {
  67.                     FigurSets[0] = node.wFiguren;
  68.                     FigurSets[1] = node.sFiguren;
  69.                     int activeSet = Convert.ToInt32(((!Convert.ToBoolean(pid) || Turn) && (Convert.ToBoolean(pid) || !Turn)));
  70.                     foreach (PFigur Figur in FigurSets[activeSet])
  71.                     {
  72.                         try
  73.                         {
  74.                             Spieler.OnSelect(FigurSets[activeSet], FigurSets[activeSet].IndexOf(Figur), node.Feld);
  75.                         }
  76.                         catch (Exception)
  77.                         {
  78.                             Console.WriteLine(Figur.Klasse.ToString());
  79.                         }
  80.                         // j=x, i=y; Top Left Corner
  81.                         for (int i = 0; i < Figur.Movement.Field.Length; i++)
  82.                         {
  83.                             for (int j = 0; j < Figur.Movement.Field[i].Length; j++)
  84.                             {
  85.                                 if (Figur.Movement.Field[i][j] != 0 && Figur.Movement.Field[i][j] != 5)
  86.                                 {
  87.                                     State child = new State(new Schachzug(Figur, new PFigur.Position(j, i), Figur.Movement.Field[i][j]), node, node.Feld, Turn == true ? pid : (1 - pid));
  88.                                     if (child.isFinalState())
  89.                                     {
  90.                                         node.isFinal = true;
  91.                                     }
  92.                                     if (!TreeContainsField(child.Feld))
  93.                                     {
  94.                                         StateTree[level + 1].Add(child);
  95.                                         node.Childs.Add(StateTree[level + 1].Last());
  96.                                     }
  97.                                 }
  98.                             }
  99.                         }
  100.                     }
  101.                 }
  102.                 return;
  103.             }
  104.             public static void FillStateTree(object param)
  105.             {
  106.                 object[] args = new object[3];
  107.                 args = (object[])param;
  108.                 int pid = Convert.ToInt32(args[0]);
  109.                 int maxDepth = Convert.ToInt32(args[1]);
  110.                 State root = (State)args[2];
  111.                 StateTree.Add(new List<State> { root });
  112.                 bool Turn = true;
  113.                 List<PFigur>[] FigurSets = new List<PFigur>[2];
  114.                 for (int level = 0; level < maxDepth; level++, Turn = !Turn)
  115.                 {
  116.                     if ((level > 0 && StateTree[level - 1].Count != 0) || level == 0)
  117.                     {
  118.                         StateTree.Add(new List<State>());
  119.                         Task[] threads = new Task[StateTree[level].Count];
  120.                         for (int n = 0; n < threads.Length; n++)
  121.                         {
  122.                             State node = StateTree[level][n];
  123.                             threads[n] = Task.Run(() => BuildNode(node, pid, Turn, level));
  124.                         }
  125.                         try
  126.                         {
  127.                             Task.WaitAll(threads);
  128.                         }
  129.                         catch (AggregateException ae)
  130.                         {
  131.                             throw ae.Flatten();
  132.                         }
  133.                     }
  134.                 }
  135.             }
  136.             public class Schachzug
  137.             {
  138.                 public PFigur Figur;
  139.                 public PFigur.Position newPos;
  140.                 public PFigur.Position oldPos;
  141.                 public int moveType;
  142.                 public Dictionary<PFigur.Position, int> XReplace = new Dictionary<PFigur.Position, int>();
  143.                 public Schachzug(PFigur figur, PFigur.Position pos, int movetype)
  144.                 {
  145.                     Figur = new PFigur(figur.Klasse, figur.position, figur.Color);
  146.                     oldPos = Figur.position;
  147.                     newPos = pos;
  148.                     moveType = movetype;
  149.                     switch (movetype)
  150.                     {
  151.                         case 3:
  152.                             XReplace.Add(new PFigur.Position(newPos.x, Figur.position.y), 0);
  153.                             break;
  154.                         case 4:
  155.                             XReplace.Add(new PFigur.Position(((newPos.x - Figur.position.x) / Math.Abs(newPos.x - Figur.position.x)) + Figur.position.x, Figur.position.y), Figur.ToClassIndex() - 3);
  156.                             break;
  157.                     }
  158.                 }
  159.                 public override string ToString()
  160.                 {
  161.                     int xPos = Convert.ToChar(Figur.position.x) + 65;
  162.                     int newxPos = Convert.ToChar(newPos.x) + 65;
  163.                     //return Figur.Klasse.ToString() + " von " + Convert.ToChar(xPos).ToString() + (8 - Figur.position.y).ToString() + " auf " + Convert.ToChar(newxPos).ToString() + (8 - newPos.y).ToString();
  164.                     return Figur.Klasse.ToString() +" " + Figur.Color.ToString() + " von (" + oldPos.x + ";" + oldPos.y + ") auf (" + newPos.x + ";" + newPos.y + ")";
  165.                 }
  166.             }
  167.             public class State
  168.             {
  169.                 public int[][] Feld = new int[8][];
  170.                 public float Value;
  171.                 public State Parent;
  172.                 public List<State> Childs = new List<State>();
  173.                 public Schachzug Zug;
  174.                 public List<PFigur> wFiguren, sFiguren;
  175.                 public int playerID;
  176.                 public bool isFinal;
  177.                 public bool isFinalState()
  178.                 {
  179.                     if (wFiguren.Exists(x => x.Klasse == PFigur.Typ.König) && sFiguren.Exists(x => x.Klasse == PFigur.Typ.König))
  180.                         return false;
  181.                     else
  182.                         return true;
  183.                 }
  184.                 public State(Schachzug zug, State parent, int[][] prevField, int pid)
  185.                 {
  186.                     playerID = pid;
  187.                     Zug = zug;
  188.                     Parent = parent;
  189.                     wFiguren = parent.wFiguren;
  190.                     sFiguren = parent.sFiguren;
  191.                     for (int i = 0; i < prevField.Length; i++)
  192.                     {
  193.                         Feld[i] = new int[8];
  194.                         prevField[i].CopyTo(Feld[i], 0);
  195.                     }
  196.                     Feld[zug.Figur.position.y][zug.Figur.position.x] = 0;
  197.                     Feld[zug.newPos.y][zug.newPos.x] = zug.Figur.ToClassIndex();
  198.                     PFigur tEnemy = PFigur.IndexToFigur(Feld[zug.newPos.y][zug.newPos.x], zug.newPos);
  199.                     if (tEnemy.Color == PFigur.Farbe.weiß && wFiguren.Contains(tEnemy))
  200.                         wFiguren.Remove(tEnemy);
  201.                     else if (sFiguren.Contains(tEnemy))
  202.                         sFiguren.Remove(tEnemy);
  203.                     zug.Figur.position = zug.newPos;
  204.                     foreach (KeyValuePair<PFigur.Position, int> rep in Zug.XReplace)
  205.                     {
  206.                         Feld[rep.Key.y][rep.Key.x] = rep.Value;
  207.                         if (Feld[rep.Key.y][rep.Key.x] != 0)
  208.                         {
  209.                             tEnemy = PFigur.IndexToFigur(Feld[rep.Key.y][rep.Key.x], rep.Key);
  210.                             if (tEnemy.Color == PFigur.Farbe.weiß)
  211.                                 wFiguren.Remove(tEnemy);
  212.                             else
  213.                                 sFiguren.Remove(tEnemy);
  214.                         }
  215.                     }
  216.                 }
  217.                 public State(Schachzug zug, State parent, int pid, float value, int[][] refField, List<PFigur> wfiguren, List<PFigur> sfiguren)
  218.                 {
  219.                     playerID = pid;
  220.                     Zug = zug;
  221.                     Parent = parent;
  222.                     Value = value;
  223.                     for (int i = 0; i < refField.Length; i++)
  224.                     {
  225.                         Feld[i] = new int[8];
  226.                         refField[i].CopyTo(Feld[i], 0);
  227.                     }
  228.                     wFiguren = wfiguren;
  229.                     sFiguren = sfiguren;
  230.                 }
  231.             }
  232.             public static void WriteTreeCount()
  233.             {
  234.                 while (true)
  235.                 {
  236.                     Console.SetCursorPosition(0, 0);
  237.                     try
  238.                     {
  239.                         Console.Write(System.Diagnostics.Process.GetCurrentProcess().Threads.Count);
  240.                     }
  241.                     catch (Exception) { }
  242.                 }
  243.             }
  244.             public int FigurAsTarget(PFigur Figur, List<PFigur> FigurSet, List<PFigur> OwnFigurSet, int[][] Feld)
  245.             {
  246.                 int count = 0;
  247.                 foreach (PFigur Enemy in FigurSet)
  248.                 {
  249.                     if (FigurSet[0].Color == (PFigur.Farbe)Player.playerID)
  250.                     {
  251.                         if (Enemy.Movement[Figur.position.y, Figur.position.x] == 5)
  252.                             count++;
  253.                     }
  254.                     else
  255.                     {
  256.                         if (Math.Abs(Enemy.Movement[Figur.position.y, Figur.position.x] - 2.5f) == 0.5f)
  257.                             count++;
  258.                     }
  259.                 }
  260.                 return count;
  261.             }
  262.             public float RateState(State current)
  263.             {
  264.                 float result = 0f, matValue = 0f, guarding = 0f, threatening = 0f;
  265.                 List<PFigur>[] FigurSets = new List<PFigur>[2];
  266.                 FigurSets[0] = current.wFiguren;
  267.                 FigurSets[1] = current.sFiguren;
  268.                 float[] FigurGuards = new float[FigurSets[Player.playerID].Count];
  269.                 float[] FigurThreats = new float[FigurSets[1 - Player.playerID].Count];
  270.                 List<PFigur> allFigures = FigurSets[0].Concat(FigurSets[1]).ToList();
  271.                 Task[] tasks = new Task[allFigures.Count];
  272.                 foreach (PFigur Figur in allFigures)
  273.                 {
  274.                     tasks[allFigures.IndexOf(Figur)] = Task.Run(() => Spieler.OnSelect(allFigures, allFigures.IndexOf(Figur), current.Feld));
  275.                 }
  276.                 try
  277.                 {
  278.                     Task.WaitAll(tasks);
  279.                 }
  280.                 catch (AggregateException ae)
  281.                 {
  282.                     throw ae.Flatten();
  283.                 }
  284.                 for (int i = 0; i < FigurSets[Player.playerID].Count; i++)
  285.                 {
  286.                     PFigur Figur = FigurSets[Player.playerID][i];
  287.                     matValue += Figur.Punkte;
  288.                     FigurGuards[i] += FigurAsTarget(Figur, FigurSets[Player.playerID], FigurSets[Player.playerID], current.Feld);
  289.                     FigurGuards[i] -= FigurAsTarget(Figur, FigurSets[1 - Player.playerID], FigurSets[Player.playerID], current.Feld);
  290.                 }
  291.                 for (int i = 0; i < FigurSets[1 - Player.playerID].Count; i++)
  292.                 {
  293.                     PFigur Figur = FigurSets[1 - Player.playerID][i];
  294.                     matValue -= Figur.Punkte;
  295.                     FigurThreats[i] += FigurAsTarget(Figur, FigurSets[1 - Player.playerID], FigurSets[1 - Player.playerID], current.Feld);
  296.                     FigurThreats[i] -= FigurAsTarget(Figur, FigurSets[Player.playerID], FigurSets[1 - Player.playerID], current.Feld);
  297.                 }
  298.                 guarding = FigurGuards.Join(FigurSets[Player.playerID], x => x, y => y.Punkte, (x, y) => ((x < -1) ? -1 : ((x > 1) ? 1 : x)) * y.Punkte).Sum();
  299.                 threatening = FigurThreats.Join(FigurSets[1 - Player.playerID], x => x, y => y.Punkte, (x, y) => ((x < -1) ? -1 : ((x > 1) ? 1 : x)) * y.Punkte).Sum();
  300.                 result = matValue + guarding - threatening;
  301.                 current.Value = result;
  302.                 //Console.WriteLine(guarding + " | " + threatening + " | " + matValue);
  303.                 // Gesamter Materialwert des Spielfeldes (+Eigene -Gegner) + Schutz der eigenen Figuren (+Punkte bei Schutz, -Punkte bei Bedrohung, Sonst 0), - Schutz der gegnerischen Figuren
  304.                 return result;
  305.             }
  306.             public KI(Spieler player)
  307.             {
  308.                 Player = player;
  309.                 Root = new int[8][];
  310.                 for (int i = 0; i < Board.Schachfeld.Length; i++)
  311.                 {
  312.                     Root[i] = new int[8];
  313.                     Board.Schachfeld[i].CopyTo(Root[i], 0);
  314.                 }
  315.                 switch (Player.KITyp)
  316.                 {
  317.                     case Spieler.KIType.DynamicLearning:
  318.                         break;
  319.                     case Spieler.KIType.HardSearch:
  320.                         cKI = Player.assignedKI;
  321.                         Thread th = new Thread(new ParameterizedThreadStart(FillStateTree));
  322.                         //FillStateTree(Player.playerID);
  323.                         Thread th2 = new Thread(WriteTreeCount);
  324.                         th.Start();
  325.                         th2.Start();
  326.                         Console.ReadKey();
  327.                         break;
  328.                     case Spieler.KIType.StaticLearning:
  329.                         cKI = Player.assignedKI;
  330.                         int maxdepth = 1;
  331.                         Task th3 = Task.Run(() => FillStateTree(new object[] { Player.playerID, maxdepth, new State(null, null, Player.playerID, 0f, Root, Board.wFiguren, Board.sFiguren) }));
  332.                         try { th3.Wait(); }
  333.                         catch (AggregateException ae)
  334.                         {
  335.                             throw ae.Flatten();
  336.                         }
  337.                         List<Task> tasks = new List<Task>();
  338.                         List<State> states = new List<State>();
  339.                         for (int i = 0; i < StateTree.Count; i++)
  340.                         {
  341.                             for (int j = 0; j < StateTree[i].Count; j++)
  342.                             {
  343.                                 states.Add(StateTree[i][j]);
  344.                             }
  345.                         }
  346.                         foreach (State state in states)
  347.                             tasks.Add(Task.Run(() => RateState(state)));
  348.                         try
  349.                         {
  350.                             Task.WaitAll(tasks.ToArray());
  351.                         }
  352.                         catch (AggregateException ae)
  353.                         {
  354.                             Console.Write(ae.StackTrace);
  355.                         }
  356.                         for (int i = 0; i < StateTree.Count; i++)
  357.                         {
  358.                             for (int j = 0; j < StateTree[i].Count; j++)
  359.                             {
  360.                                 if (StateTree[i][j].Zug != null)
  361.                                     Console.WriteLine(StateTree[i][j].Zug.ToString() + ": " + StateTree[i][j].Value + "|");
  362.                             }
  363.                         }
  364.                         Console.ReadKey();
  365.                         /*
  366.                          * Bewertungsfunktion:
  367.                          *  - Figuren auf dem Feld
  368.                          *  - Gegnerische Figuren bedroht
  369.                          *  - Eigene Figuren bedroht
  370.                          *  - Sicherung gegnerischer Figuren
  371.                          *  - Sicherung eigener Figuren
  372.                          */
  373.                         break;
  374.                 }
  375.             }
  376.         }
  377.         public class PFigur
  378.         {
  379.             public bool FirstTurn;
  380.             public readonly int Punkte;
  381.             public enum Farbe
  382.             {
  383.                 weiß,
  384.                 schwarz
  385.             }
  386.             public Farbe Color;
  387.             public enum Typ
  388.             {
  389.                 Bauer,
  390.                 Turm,
  391.                 Springer,
  392.                 Läufer,
  393.                 Dame,
  394.                 König
  395.             }
  396.             public readonly Typ Klasse;
  397.             public class Position
  398.             {
  399.                 public int x;
  400.                 public int y;
  401.                 public Position(int X, int Y)
  402.                 {
  403.                     x = X;
  404.                     y = Y;
  405.                 }
  406.             }
  407.             public Position position;
  408.             public class movement
  409.             {
  410.                 public int[][] Field;
  411.                 public List<PFigur.Position> CountValues(int ValueMin, int ValueMax)
  412.                 {
  413.                     List<PFigur.Position> temp = new List<PFigur.Position>();
  414.                     for (int i = 0; i < 8; i++)
  415.                     {
  416.                         for (int j = 0; j < 8; j++)
  417.                         {
  418.                             if (Field[i][j] >= ValueMin && Field[i][j] <= ValueMin)
  419.                             {
  420.                                 temp.Add(new PFigur.Position(j, i));
  421.                             }
  422.                         }
  423.                     }
  424.                     return temp;
  425.                 }
  426.                 public static implicit operator movement(int[][] field)
  427.                 {
  428.                     movement temp = new movement();
  429.                     temp.Field = field;
  430.                     return temp;
  431.                 }
  432.                 public static implicit operator int[][] (movement mov)
  433.                 {
  434.                     return mov.Field;
  435.                 }
  436.                 public int this[int i, int j]
  437.                 {
  438.                     get { return this.Field[i][j]; }
  439.                     set { this.Field[i][j] = (int)value; }
  440.                 }
  441.             }
  442.             public movement Movement;
  443.             public static PFigur IndexToFigur(int index, Position indexPos)
  444.             {
  445.                 Typ tTyp = (Typ)((index - 1) - Convert.ToInt32(index >= 0xA) * 9);
  446.                 Farbe tFarbe = (Farbe)(Convert.ToInt32(index >= 0xA));
  447.                 return new PFigur(tTyp, indexPos, tFarbe);
  448.             }
  449.             public int ToClassIndex()
  450.             {
  451.                 if (Color == Farbe.weiß)
  452.                 {
  453.                     switch (Klasse)
  454.                     {
  455.                         case Typ.Bauer:
  456.                             return 0x1;
  457.                         case Typ.Dame:
  458.                             return 0x5;
  459.                         case Typ.König:
  460.                             return 0x6;
  461.                         case Typ.Läufer:
  462.                             return 0x4;
  463.                         case Typ.Springer:
  464.                             return 0x3;
  465.                         case Typ.Turm:
  466.                             return 0x2;
  467.                         default:
  468.                             return 0x0;
  469.                     }
  470.                 }
  471.                 else
  472.                 {
  473.                     switch (Klasse)
  474.                     {
  475.                         case Typ.Bauer:
  476.                             return 0xA;
  477.                         case Typ.Dame:
  478.                             return 0xE;
  479.                         case Typ.König:
  480.                             return 0xF;
  481.                         case Typ.Läufer:
  482.                             return 0xD;
  483.                         case Typ.Springer:
  484.                             return 0xC;
  485.                         case Typ.Turm:
  486.                             return 0xB;
  487.                         default:
  488.                             return 0x0;
  489.                     }
  490.                 }
  491.             }
  492.             /* INT-Werte für Movement Array:
  493.             0 - Keine Bewegung
  494.             1 - normale Bewegung
  495.             2 - Schlagen einer Figur
  496.             3 - Beiläufiges Schlagen einer Figur
  497.             4 - Rochade
  498.             */
  499.             public PFigur(Typ typ, Position pos, Farbe color)
  500.             {
  501.                 Color = color;
  502.                 Movement = new int[8][] {
  503.                 new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 },
  504.                 new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 },
  505.                 new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 },
  506.                 new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 },
  507.                 new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 },
  508.                 new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 },
  509.                 new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 },
  510.                 new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 }
  511.                 };
  512.                 FirstTurn = true;
  513.                 Klasse = typ;
  514.                 position = pos;
  515.                 switch (typ)
  516.                 {
  517.                     case Typ.Bauer:
  518.                         Punkte = 1;
  519.                         break;
  520.                     case Typ.Turm:
  521.                         Punkte = 5;
  522.                         break;
  523.                     case Typ.Springer:
  524.                         Punkte = 3;
  525.                         break;
  526.                     case Typ.Läufer:
  527.                         Punkte = 3;
  528.                         break;
  529.                     case Typ.Dame:
  530.                         Punkte = 9;
  531.                         break;
  532.                     case Typ.König:
  533.                         Punkte = 100;
  534.                         break;
  535.                     default:
  536.                         throw new System.Exception("Der falsche Typ wurde eingegeben.");
  537.                 }
  538.             }
  539.         }
  540.         public class Spieler
  541.         {
  542.             /* Definition der INT-Werte der Figuren: Hexadezimal
  543.             Weiß:
  544.                 Bauer = 0x1
  545.                 Turm = 0x2
  546.                 Springer = 0x3
  547.                 Läufer = 0x4
  548.                 Königin = 0x5
  549.                 König = 0x6
  550.             Schwarz:
  551.                 Bauer = 0xA
  552.                 Turm = 0xB
  553.                 Springer = 0xC
  554.                 Läufer = 0xD
  555.                 Königin = 0xE
  556.                 König = 0xF
  557.             */
  558.             public int playerID;
  559.             public string Name;
  560.             public KIType KITyp;
  561.             public KI assignedKI;
  562.             public enum KIType
  563.             {
  564.                 HardSearch,
  565.                 StaticLearning,
  566.                 DynamicLearning
  567.             }
  568.             public static bool inCheck()
  569.             {
  570.                 return false;
  571.             }
  572.             public static bool inCheck(PFigur.Position pos)
  573.             {
  574.                 return false;
  575.             }
  576.             public static void OnSelect(List<PFigur> Pool, int selected, int[][] Feld)
  577.             {
  578.                 int Faktor = 0;
  579.                 int[] Enemy = new int[2] { 0x0, 0x0 };
  580.                 if (Pool[0].Color == PFigur.Farbe.weiß)
  581.                 {
  582.                     Faktor = 1;
  583.                     Enemy = new int[] { 0xA, 0xF };
  584.                 }
  585.                 else
  586.                 {
  587.                     Faktor = -1;
  588.                     Enemy = new int[] { 0x1, 0x6 };
  589.                 }
  590.                 if (selected >= 0)
  591.                 {
  592.                     Pool[selected].Movement = new int[8][] {
  593.                         new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 },
  594.                         new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 },
  595.                         new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 },
  596.                         new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 },
  597.                         new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 },
  598.                         new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 },
  599.                         new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 },
  600.                         new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 }
  601.                     };
  602.                     switch (Pool[selected].Klasse)
  603.                     {
  604.                         case PFigur.Typ.Bauer:
  605.                             try
  606.                             {
  607.                                 if (Feld[Pool[selected].position.y - 1 * Faktor][Pool[selected].position.x] == 0x0)
  608.                                 {
  609.                                     Pool[selected].Movement[Pool[selected].position.y - 1 * Faktor, Pool[selected].position.x] = 1;
  610.                                 }
  611.                             }
  612.                             catch (System.IndexOutOfRangeException)
  613.                             { }
  614.                             try
  615.                             {
  616.                                 if (Feld[Pool[selected].position.y - 2 * Faktor][Pool[selected].position.x] == 0x0 && Pool[selected].FirstTurn)
  617.                                 {
  618.                                     Pool[selected].Movement[Pool[selected].position.y - 2 * Faktor, Pool[selected].position.x] = 1;
  619.                                 }
  620.                             }
  621.                             catch (System.IndexOutOfRangeException)
  622.                             { }
  623.                             try
  624.                             {
  625.                                 if (Feld[Pool[selected].position.y][Pool[selected].position.x + 1] >= Enemy[0] && Feld[Pool[selected].position.y][Pool[selected].position.x + 1] <= Enemy[1])
  626.                                 {
  627.                                     Pool[selected].Movement[Pool[selected].position.y - 1 * Faktor, Pool[selected].position.x + 1] = 3;
  628.                                 }
  629.                                 else if (Feld[Pool[selected].position.y][Pool[selected].position.x + 1] != 0x0)
  630.                                 {
  631.                                     Pool[selected].Movement[Pool[selected].position.y - 1 * Faktor, Pool[selected].position.x + 1] = 5;
  632.                                 }
  633.                             }
  634.                             catch (System.IndexOutOfRangeException)
  635.                             { }
  636.                             try
  637.                             {
  638.                                 if (Feld[Pool[selected].position.y][Pool[selected].position.x - 1] >= Enemy[0] && Feld[Pool[selected].position.y][Pool[selected].position.x - 1] <= Enemy[1])
  639.                                 {
  640.                                     Pool[selected].Movement[Pool[selected].position.y - 1 * Faktor, Pool[selected].position.x - 1] = 3;
  641.                                 }
  642.                                 else if (Feld[Pool[selected].position.y][Pool[selected].position.x - 1] != 0x0)
  643.                                 {
  644.                                     Pool[selected].Movement[Pool[selected].position.y - 1 * Faktor, Pool[selected].position.x - 1] = 5;
  645.                                 }
  646.                             }
  647.                             catch (System.IndexOutOfRangeException)
  648.                             { }
  649.                             try
  650.                             {
  651.                                 if (Feld[Pool[selected].position.y - 1 * Faktor][Pool[selected].position.x - 1] >= Enemy[0] && Feld[Pool[selected].position.y - 1 * Faktor][Pool[selected].position.x - 1] <= Enemy[1])
  652.                                 {
  653.                                     Pool[selected].Movement[Pool[selected].position.y - 1 * Faktor, Pool[selected].position.x - 1] = 2;
  654.                                 }
  655.                                 else if (Feld[Pool[selected].position.y - 1 * Faktor][Pool[selected].position.x - 1] != 0x0)
  656.                                 {
  657.                                     Pool[selected].Movement[Pool[selected].position.y - 1 * Faktor, Pool[selected].position.x - 1] = 5;
  658.                                 }
  659.                             }
  660.                             catch (System.IndexOutOfRangeException)
  661.                             { }
  662.                             try
  663.                             {
  664.                                 if (Feld[Pool[selected].position.y - 1 * Faktor][Pool[selected].position.x + 1] >= Enemy[0] && Feld[Pool[selected].position.y - 1 * Faktor][Pool[selected].position.x + 1] <= Enemy[1])
  665.                                 {
  666.                                     Pool[selected].Movement[Pool[selected].position.y - 1 * Faktor, Pool[selected].position.x + 1] = 2;
  667.                                 }
  668.                                 else if (Feld[Pool[selected].position.y - 1 * Faktor][Pool[selected].position.x + 1] != 0x0)
  669.                                 {
  670.                                     Pool[selected].Movement[Pool[selected].position.y - 1 * Faktor, Pool[selected].position.x + 1] = 5;
  671.                                 }
  672.                             }
  673.                             catch (System.IndexOutOfRangeException)
  674.                             { }
  675.                             break;
  676.                         case PFigur.Typ.Dame:
  677.                             try
  678.                             {
  679.                                 for (int i = Pool[selected].position.y + 1; i <= 7; i++)
  680.                                 {
  681.                                     if (Feld[i][Pool[selected].position.x] == 0x0)
  682.                                     {
  683.                                         Pool[selected].Movement[i, Pool[selected].position.x] = 1;
  684.                                     }
  685.                                     else if (Feld[i][Pool[selected].position.x] >= Enemy[0] && Feld[i][Pool[selected].position.x] <= Enemy[1])
  686.                                     {
  687.                                         Pool[selected].Movement[i, Pool[selected].position.x] = 2;
  688.                                         throw new System.Exception();
  689.                                     }
  690.                                     else
  691.                                     {
  692.                                         Pool[selected].Movement[i, Pool[selected].position.x] = 5;
  693.                                         throw new System.Exception();
  694.                                     }
  695.                                 }
  696.                             }
  697.                             catch (System.Exception) { }
  698.                             try
  699.                             {
  700.                                 for (int i = Pool[selected].position.y - 1; i >= 0; i--)
  701.                                 {
  702.                                     if (Feld[i][Pool[selected].position.x] == 0x0)
  703.                                     {
  704.                                         Pool[selected].Movement[i, Pool[selected].position.x] = 1;
  705.                                     }
  706.                                     else if (Feld[i][Pool[selected].position.x] >= Enemy[0] && Feld[i][Pool[selected].position.x] <= Enemy[1])
  707.                                     {
  708.                                         Pool[selected].Movement[i, Pool[selected].position.x] = 2;
  709.                                         throw new System.Exception();
  710.                                     }
  711.                                     else
  712.                                     {
  713.                                         Pool[selected].Movement[i, Pool[selected].position.x] = 5;
  714.                                         throw new System.Exception();
  715.                                     }
  716.                                 }
  717.                             }
  718.                             catch (System.Exception) { }
  719.                             try
  720.                             {
  721.                                 for (int i = Pool[selected].position.x - 1; i >= 0; i--)
  722.                                 {
  723.                                     if (Feld[Pool[selected].position.y][i] == 0x0)
  724.                                     {
  725.                                         Pool[selected].Movement[Pool[selected].position.y, i] = 1;
  726.                                     }
  727.                                     else if (Feld[Pool[selected].position.y][i] >= Enemy[0] && Feld[Pool[selected].position.y][i] <= Enemy[1])
  728.                                     {
  729.                                         Pool[selected].Movement[Pool[selected].position.y, i] = 2;
  730.                                         throw new System.Exception();
  731.                                     }
  732.                                     else
  733.                                     {
  734.                                         Pool[selected].Movement[Pool[selected].position.y, i] = 5;
  735.                                         throw new System.Exception();
  736.                                     }
  737.                                 }
  738.                             }
  739.                             catch (System.Exception) { }
  740.                             try
  741.                             {
  742.                                 for (int i = Pool[selected].position.x + 1; i <= 7; i++)
  743.                                 {
  744.                                     if (Feld[Pool[selected].position.y][i] == 0x0)
  745.                                     {
  746.                                         Pool[selected].Movement[Pool[selected].position.y, i] = 1;
  747.                                     }
  748.                                     else if (Feld[Pool[selected].position.y][i] >= Enemy[0] && Feld[Pool[selected].position.y][i] <= Enemy[1])
  749.                                     {
  750.                                         Pool[selected].Movement[Pool[selected].position.y, i] = 2;
  751.                                         throw new System.Exception();
  752.                                     }
  753.                                     else
  754.                                     {
  755.                                         Pool[selected].Movement[Pool[selected].position.y, i] = 5;
  756.                                         throw new System.Exception();
  757.                                     }
  758.                                 }
  759.                             }
  760.                             catch (System.Exception) { }
  761.                             try
  762.                             {
  763.                                 for (int i = Pool[selected].position.x - 1, j = Pool[selected].position.y + 1; (i >= 0 && j <= 7); i--, j++)
  764.                                 {
  765.                                     if (Feld[j][i] == 0x0)
  766.                                     {
  767.                                         Pool[selected].Movement[j, i] = 1;
  768.                                     }
  769.                                     else if (Feld[j][i] >= Enemy[0] && Feld[j][i] <= Enemy[1])
  770.                                     {
  771.                                         Pool[selected].Movement[j, i] = 2;
  772.                                         throw new System.Exception();
  773.                                     }
  774.                                     else
  775.                                     {
  776.                                         Pool[selected].Movement[j, i] = 5;
  777.                                         throw new System.Exception();
  778.                                     }
  779.                                 }
  780.                             }
  781.                             catch (System.Exception) { }
  782.                             try
  783.                             {
  784.                                 for (int i = Pool[selected].position.x - 1, j = Pool[selected].position.y - 1; (i >= 0 && j >= 0); i--, j--)
  785.                                 {
  786.                                     if (Feld[j][i] == 0x0)
  787.                                     {
  788.                                         Pool[selected].Movement[j, i] = 1;
  789.                                     }
  790.                                     else if (Feld[j][i] >= Enemy[0] && Feld[j][i] <= Enemy[1])
  791.                                     {
  792.                                         Pool[selected].Movement[j, i] = 2;
  793.                                         throw new System.Exception();
  794.                                     }
  795.                                     else
  796.                                     {
  797.                                         Pool[selected].Movement[j, i] = 5;
  798.                                         throw new System.Exception();
  799.                                     }
  800.                                 }
  801.                             }
  802.                             catch (System.Exception) { }
  803.                             try
  804.                             {
  805.                                 for (int i = Pool[selected].position.x + 1, j = Pool[selected].position.y + 1; (i <= 7 && j <= 7); i++, j++)
  806.                                 {
  807.                                     if (Feld[j][i] == 0x0)
  808.                                     {
  809.                                         Pool[selected].Movement[j, i] = 1;
  810.                                     }
  811.                                     else if (Feld[j][i] >= Enemy[0] && Feld[j][i] <= Enemy[1])
  812.                                     {
  813.                                         Pool[selected].Movement[j, i] = 2;
  814.                                         throw new System.Exception();
  815.                                     }
  816.                                     else
  817.                                     {
  818.                                         Pool[selected].Movement[j, i] = 5;
  819.                                         throw new System.Exception();
  820.                                     }
  821.                                 }
  822.                             }
  823.                             catch (System.Exception) { }
  824.                             try
  825.                             {
  826.                                 for (int i = Pool[selected].position.x + 1, j = Pool[selected].position.y - 1; (i <= 7 && j >= 0); i++, j--)
  827.                                 {
  828.                                     if (Feld[j][i] == 0x0)
  829.                                     {
  830.                                         Pool[selected].Movement[j, i] = 1;
  831.                                     }
  832.                                     else if (Feld[j][i] >= Enemy[0] && Feld[j][i] <= Enemy[1])
  833.                                     {
  834.                                         Pool[selected].Movement[j, i] = 2;
  835.                                         throw new System.Exception();
  836.                                     }
  837.                                     else
  838.                                     {
  839.                                         Pool[selected].Movement[j, i] = 5;
  840.                                         throw new System.Exception();
  841.                                     }
  842.                                 }
  843.                             }
  844.                             catch (System.Exception) { }
  845.                             break;
  846.                         case PFigur.Typ.König:
  847.                             for (int i = 0; i < 8; i++)
  848.                             {
  849.                                 for (int j = 0; j < 8; j++)
  850.                                 {
  851.                                     if (Vector2.Distance(new Vector2(Pool[selected].position.y, Pool[selected].position.x), new Vector2(i, j)) < 1.5)
  852.                                     {
  853.                                         if (Feld[i][j] == 0x0)
  854.                                             Pool[selected].Movement[i, j] = 1;
  855.                                         else if (Feld[i][j] >= Enemy[0] && Feld[i][j] <= Enemy[1])
  856.                                             Pool[selected].Movement[i, j] = 2;
  857.                                         else
  858.                                             Pool[selected].Movement[i, j] = 5;
  859.                                     }
  860.                                 }
  861.                             }
  862.                             /* Rochade überdenken
  863.                             if (Pool[selected].FirstTurn)
  864.                             {
  865.                                 for (int i = 0; i < Pool.Count; i++)
  866.                                 {
  867.                                     if (Pool[i].Klasse == PFigur.Typ.Turm && Pool[i].FirstTurn)
  868.                                     {
  869.                                         if (Pool[i].position.x == 0 && !inCheck(new PFigur.Position(Pool[selected].position.x, Pool[selected].position.y)) && !inCheck(new PFigur.Position(Pool[selected].position.x - 1, Pool[selected].position.y)) && !inCheck(new PFigur.Position(Pool[selected].position.x - 2, Pool[selected].position.y)))
  870.                                         {
  871.                                             if (Feld[Pool[selected].position.y][Pool[selected].position.x - 1] + Feld[Pool[selected].position.y][Pool[selected].position.x - 2] + Feld[Pool[selected].position.y][Pool[selected].position.x - 3] == 0x0)
  872.                                             {
  873.                                                 Pool[selected].Movement[Pool[selected].position.y, Pool[selected].position.x - 2] = 4;
  874.                                             }
  875.                                         }
  876.                                         else if (!inCheck(new PFigur.Position(Pool[selected].position.x, Pool[selected].position.y)) && !inCheck(new PFigur.Position(Pool[selected].position.x + 1, Pool[selected].position.y)) && !inCheck(new PFigur.Position(Pool[selected].position.x + 2, Pool[selected].position.y)))
  877.                                         {
  878.                                             if (Feld[Pool[selected].position.y][Pool[selected].position.x + 1] + Feld[Pool[selected].position.y][Pool[selected].position.x + 2] == 0x0)
  879.                                             {
  880.                                                 Pool[selected].Movement[Pool[selected].position.y, Pool[selected].position.x + 2] = 4;
  881.                                             }
  882.                                         }
  883.                                     }
  884.                                 }
  885.                             }*/
  886.                             break;
  887.                         case PFigur.Typ.Läufer:
  888.                             try
  889.                             {
  890.                                 for (int i = Pool[selected].position.x - 1, j = Pool[selected].position.y + 1; (i >= 0 && j <= 7); i--, j++)
  891.                                 {
  892.                                     if (Feld[j][i] == 0x0)
  893.                                     {
  894.                                         Pool[selected].Movement[j, i] = 1;
  895.                                     }
  896.                                     else if (Feld[j][i] >= Enemy[0] && Feld[j][i] <= Enemy[1])
  897.                                     {
  898.                                         Pool[selected].Movement[j, i] = 2;
  899.                                         throw new System.Exception();
  900.                                     }
  901.                                     else
  902.                                     {
  903.                                         Pool[selected].Movement[j, i] = 5;
  904.                                         throw new System.Exception();
  905.                                     }
  906.                                 }
  907.                             }
  908.                             catch (System.Exception) { }
  909.                             try
  910.                             {
  911.                                 for (int i = Pool[selected].position.x - 1, j = Pool[selected].position.y - 1; (i >= 0 && j >= 0); i--, j--)
  912.                                 {
  913.                                     if (Feld[j][i] == 0x0)
  914.                                     {
  915.                                         Pool[selected].Movement[j, i] = 1;
  916.                                     }
  917.                                     else if (Feld[j][i] >= Enemy[0] && Feld[j][i] <= Enemy[1])
  918.                                     {
  919.                                         Pool[selected].Movement[j, i] = 2;
  920.                                         throw new System.Exception();
  921.                                     }
  922.                                     else
  923.                                     {
  924.                                         Pool[selected].Movement[j, i] = 5;
  925.                                         throw new System.Exception();
  926.                                     }
  927.                                 }
  928.                             }
  929.                             catch (System.Exception) { }
  930.                             try
  931.                             {
  932.                                 for (int i = Pool[selected].position.x + 1, j = Pool[selected].position.y + 1; (i <= 7 && j <= 7); i++, j++)
  933.                                 {
  934.                                     if (Feld[j][i] == 0x0)
  935.                                     {
  936.                                         Pool[selected].Movement[j, i] = 1;
  937.                                     }
  938.                                     else if (Feld[j][i] >= Enemy[0] && Feld[j][i] <= Enemy[1])
  939.                                     {
  940.                                         Pool[selected].Movement[j, i] = 2;
  941.                                         throw new System.Exception();
  942.                                     }
  943.                                     else
  944.                                     {
  945.                                         Pool[selected].Movement[j, i] = 5;
  946.                                         throw new System.Exception();
  947.                                     }
  948.                                 }
  949.                             }
  950.                             catch (System.Exception) { }
  951.                             try
  952.                             {
  953.                                 for (int i = Pool[selected].position.x + 1, j = Pool[selected].position.y - 1; (i <= 7 && j >= 0); i++, j--)
  954.                                 {
  955.                                     if (Feld[j][i] == 0x0)
  956.                                     {
  957.                                         Pool[selected].Movement[j, i] = 1;
  958.                                     }
  959.                                     else if (Feld[j][i] >= Enemy[0] && Feld[j][i] <= Enemy[1])
  960.                                     {
  961.                                         Pool[selected].Movement[j, i] = 2;
  962.                                         throw new System.Exception();
  963.                                     }
  964.                                     else
  965.                                     {
  966.                                         Pool[selected].Movement[j, i] = 5;
  967.                                         throw new System.Exception();
  968.                                     }
  969.                                 }
  970.                             }
  971.                             catch (System.Exception) { }
  972.                             break;
  973.                         case PFigur.Typ.Springer:
  974.                             for (int i = 0; i < 8; i++)
  975.                             {
  976.                                 for (int j = 0; j < 8; j++)
  977.                                 {
  978.                                     if (Vector2.Distance(new Vector2(Pool[selected].position.y, Pool[selected].position.x), new Vector2(i, j)) == Math.Sqrt(5))
  979.                                     {
  980.                                         if (Feld[i][j] == 0x0)
  981.                                             Pool[selected].Movement[i, j] = 1;
  982.                                         else if (Feld[i][j] >= Enemy[0] && Feld[i][j] <= Enemy[1])
  983.                                             Pool[selected].Movement[i, j] = 2;
  984.                                         else
  985.                                             Pool[selected].Movement[i, j] = 5;
  986.                                     }
  987.                                 }
  988.                             }
  989.                             break;
  990.                         case PFigur.Typ.Turm:
  991.                             try
  992.                             {
  993.                                 for (int i = Pool[selected].position.y + 1; i <= 7; i++)
  994.                                 {
  995.                                     if (Feld[i][Pool[selected].position.x] == 0x0)
  996.                                     {
  997.                                         Pool[selected].Movement[i, Pool[selected].position.x] = 1;
  998.                                     }
  999.                                     else if (Feld[i][Pool[selected].position.x] >= Enemy[0] && Feld[i][Pool[selected].position.x] <= Enemy[1])
  1000.                                     {
  1001.                                         Pool[selected].Movement[i, Pool[selected].position.x] = 2;
  1002.                                         throw new System.Exception();
  1003.                                     }
  1004.                                     else
  1005.                                     {
  1006.                                         Pool[selected].Movement[i, Pool[selected].position.x] = 5;
  1007.                                         throw new System.Exception();
  1008.                                     }
  1009.                                 }
  1010.                             }
  1011.                             catch (System.Exception) { }
  1012.                             try
  1013.                             {
  1014.                                 for (int i = Pool[selected].position.y - 1; i >= 0; i--)
  1015.                                 {
  1016.                                     if (Feld[i][Pool[selected].position.x] == 0x0)
  1017.                                     {
  1018.                                         Pool[selected].Movement[i, Pool[selected].position.x] = 1;
  1019.                                     }
  1020.                                     else if (Feld[i][Pool[selected].position.x] >= Enemy[0] && Feld[i][Pool[selected].position.x] <= Enemy[1])
  1021.                                     {
  1022.                                         Pool[selected].Movement[i, Pool[selected].position.x] = 2;
  1023.                                         throw new System.Exception();
  1024.                                     }
  1025.                                     else
  1026.                                     {
  1027.                                         Pool[selected].Movement[i, Pool[selected].position.x] = 5;
  1028.                                         throw new System.Exception();
  1029.                                     }
  1030.                                 }
  1031.                             }
  1032.                             catch (System.Exception) { }
  1033.                             try
  1034.                             {
  1035.                                 for (int i = Pool[selected].position.x - 1; i >= 0; i--)
  1036.                                 {
  1037.                                     if (Feld[Pool[selected].position.y][i] == 0x0)
  1038.                                     {
  1039.                                         Pool[selected].Movement[Pool[selected].position.y, i] = 1;
  1040.                                     }
  1041.                                     else if (Feld[Pool[selected].position.y][i] >= Enemy[0] && Feld[Pool[selected].position.y][i] <= Enemy[1])
  1042.                                     {
  1043.                                         Pool[selected].Movement[Pool[selected].position.y, i] = 2;
  1044.                                         throw new System.Exception();
  1045.                                     }
  1046.                                     else
  1047.                                     {
  1048.                                         Pool[selected].Movement[Pool[selected].position.y, i] = 5;
  1049.                                         throw new System.Exception();
  1050.                                     }
  1051.                                 }
  1052.                             }
  1053.                             catch (System.Exception) { }
  1054.                             try
  1055.                             {
  1056.                                 for (int i = Pool[selected].position.x + 1; i <= 7; i++)
  1057.                                 {
  1058.                                     if (Feld[Pool[selected].position.y][i] == 0x0)
  1059.                                     {
  1060.                                         Pool[selected].Movement[Pool[selected].position.y, i] = 1;
  1061.                                     }
  1062.                                     else if (Feld[Pool[selected].position.y][i] >= Enemy[0] && Feld[Pool[selected].position.y][i] <= Enemy[1])
  1063.                                     {
  1064.                                         Pool[selected].Movement[Pool[selected].position.y, i] = 2;
  1065.                                         throw new System.Exception();
  1066.                                     }
  1067.                                     else
  1068.                                     {
  1069.                                         Pool[selected].Movement[Pool[selected].position.y, i] = 5;
  1070.                                         throw new System.Exception();
  1071.                                     }
  1072.                                 }
  1073.                             }
  1074.                             catch (System.Exception) { }
  1075.                             break;
  1076.                     }
  1077.                 }
  1078.             }
  1079.             public static void OnSelect(List<PFigur> Pool, int selected)
  1080.             {
  1081.                 OnSelect(Pool, selected, Board.Schachfeld);
  1082.             }
  1083.             public static void OnSelect(object param)
  1084.             {
  1085.                 object[] args = (object[])param;
  1086.                 OnSelect((List<PFigur>)args[0], (int)args[1], (int[][])args[2]);
  1087.             }
  1088.             public Spieler(int ID, KIType type, string pName)
  1089.             {
  1090.                 Name = pName;
  1091.                 Punkte = 0;
  1092.                 playerID = ID;
  1093.                 KITyp = type;
  1094.                 assignedKI = new KI(this);
  1095.             }
  1096.             public List<PFigur> FigurSet;
  1097.             public int Punkte;
  1098.             public bool Schach;
  1099.         }
  1100.         public class Spielfeld
  1101.         {
  1102.             public Spieler P1, P2;
  1103.             public int activeTurn;
  1104.             public int[][] Schachfeld = new int[8][];
  1105.             public List<PFigur> wFiguren;
  1106.             public List<PFigur> sFiguren;
  1107.             public Spielfeld()
  1108.             {
  1109.                 Schachfeld = new int[8][] {
  1110.                 new int[8] { 0xB, 0xC, 0xD, 0xE, 0xF, 0xD, 0xC, 0xB },
  1111.                 new int[8] { 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA },
  1112.                 new int[8] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  1113.                 new int[8] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  1114.                 new int[8] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  1115.                 new int[8] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
  1116.                 new int[8] { 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1 },
  1117.                 new int[8] { 0x2, 0x3, 0x4, 0x5, 0x6, 0x4, 0x3, 0x2 }
  1118.                 };
  1119.                 wFiguren = new List<PFigur>();
  1120.                 for (int i = 0; i < 8; i++)
  1121.                     wFiguren.Add(new PFigur(PFigur.Typ.Bauer, new PFigur.Position(i, 6), PFigur.Farbe.weiß));
  1122.                 wFiguren.Add(new PFigur(PFigur.Typ.Turm, new PFigur.Position(0, 7), PFigur.Farbe.weiß));
  1123.                 wFiguren.Add(new PFigur(PFigur.Typ.Springer, new PFigur.Position(1, 7), PFigur.Farbe.weiß));
  1124.                 wFiguren.Add(new PFigur(PFigur.Typ.Läufer, new PFigur.Position(2, 7), PFigur.Farbe.weiß));
  1125.                 wFiguren.Add(new PFigur(PFigur.Typ.König, new PFigur.Position(4, 7), PFigur.Farbe.weiß));
  1126.                 wFiguren.Add(new PFigur(PFigur.Typ.Dame, new PFigur.Position(3, 7), PFigur.Farbe.weiß));
  1127.                 wFiguren.Add(new PFigur(PFigur.Typ.Turm, new PFigur.Position(7, 7), PFigur.Farbe.weiß));
  1128.                 wFiguren.Add(new PFigur(PFigur.Typ.Springer, new PFigur.Position(6, 7), PFigur.Farbe.weiß));
  1129.                 wFiguren.Add(new PFigur(PFigur.Typ.Läufer, new PFigur.Position(5, 7), PFigur.Farbe.weiß));
  1130.                 sFiguren = new List<PFigur>();
  1131.                 for (int i = 0; i < 8; i++)
  1132.                     sFiguren.Add(new PFigur(PFigur.Typ.Bauer, new PFigur.Position(i, 1), PFigur.Farbe.schwarz));
  1133.                 sFiguren.Add(new PFigur(PFigur.Typ.Turm, new PFigur.Position(0, 0), PFigur.Farbe.schwarz));
  1134.                 sFiguren.Add(new PFigur(PFigur.Typ.Springer, new PFigur.Position(1, 0), PFigur.Farbe.schwarz));
  1135.                 sFiguren.Add(new PFigur(PFigur.Typ.Läufer, new PFigur.Position(2, 0), PFigur.Farbe.schwarz));
  1136.                 sFiguren.Add(new PFigur(PFigur.Typ.König, new PFigur.Position(4, 0), PFigur.Farbe.schwarz));
  1137.                 sFiguren.Add(new PFigur(PFigur.Typ.Dame, new PFigur.Position(3, 0), PFigur.Farbe.schwarz));
  1138.                 sFiguren.Add(new PFigur(PFigur.Typ.Turm, new PFigur.Position(7, 0), PFigur.Farbe.schwarz));
  1139.                 sFiguren.Add(new PFigur(PFigur.Typ.Springer, new PFigur.Position(6, 0), PFigur.Farbe.schwarz));
  1140.                 sFiguren.Add(new PFigur(PFigur.Typ.Läufer, new PFigur.Position(5, 0), PFigur.Farbe.schwarz));
  1141.             }
  1142.         }
  1143.         public static Spielfeld Board;
  1144.         static void Main(string[] args)
  1145.         {
  1146.             Board = new Spielfeld();
  1147.             Board.activeTurn = 0;
  1148.             Board.P1 = new Spieler(0, Spieler.KIType.StaticLearning, "Player 1");
  1149.             Board.P1 = new Spieler(1, Spieler.KIType.StaticLearning, "Player 2");
  1150.         }
  1151.     }
  1152. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement