public int[] SetStep(Map m, Token.PlayerColor color, int[] p, int check, Control contrl, List<int[]> taken) { int[] pos = ChooseToken(m, color, taken); int[,] help; if (m.Field[pos[0], pos[1]].Tok == "stone"){ Token.PlayerColor c = m.Field[pos[0], pos[1]].Color; help = new Stone(c).nextStep(m, pos);//field of information where you can move, or have to move a stone } else{ Token.PlayerColor c = m.Field[pos[0], pos[1]].Color; help = new Draught(c).nextStep(m, pos);//field of information where you can move, or have to move a draught } return new int[]{-1,-1}; }
public World(int priority, int size, Draught.Control control, Map map) : base(priority) { this.control = control; this.map = map; map.addListener(this); tokens = new Token[size, size]; board = new Board3D(boardBase, size); atMouse = Token.empty; atMousePos[0] = -1; atMousePos[1] = -1; this.refresh(); }
//returns the field the Player wants to visit public int[] SetStep(Map m, Token.PlayerColor color, int[] pos, int check, Control contrl, List<int[]> taken) { int[,] help; Random r = new Random(); int r1; List<int[]> priority = new List<int[]>(); List<int[]> visitable = new List<int[]>(); if (m.Field[pos[0], pos[1]].Tok == "stone") { Token.PlayerColor c = m.Field[pos[0], pos[1]].Color; help = new Stone(c).nextStep(m, pos);//field of information where you can move, or have to move a stone } else { Token.PlayerColor c = m.Field[pos[0], pos[1]].Color; help = new Draught(c).nextStep(m, pos);//field of information where you can move, or have to move a draught } for (int a = 0; a < help.GetLength(1); ++a) { for (int b = 0; b < help.GetLength(1); ++b) { if (help[a, b] == 1) priority.Add(new int[] { a, b }); //builds a list of field with priority if (help[a, b] == 0) visitable.Add(new int[] { a, b });//builds a list of field which are visitable } } int[] temp; Token[,] field = m.Field; if (priority.Count != 0) {//if there are fields with higher priority for(int i=0; i<priority.Count; i++) { temp = new int[] { priority[i][0], priority[i][1] }; contrl.temp = new int[] { pos[0], pos[1], temp[0], temp[1] }; return temp; } } else { for(int i=0; i<visitable.Count; i++) { temp = new int[] { visitable[i][0], visitable[i][1] }; if (!removeTokens(field, color, temp, m)) { contrl.temp = new int[] { pos[0], pos[1], temp[0], temp[1] }; return temp; } } } if (check < 80) { taken.Add(pos); return SetStep(m, color, ChooseToken(m, color, taken), check + 1, contrl, taken); } else { if (priority.Count != 0) {//if there are fields with higher priority r1 = r.Next(0, priority.Count); temp = new int[] { priority[r1][0], priority[r1][1] };//choose a random field } else { r1 = r.Next(0, visitable.Count); temp = new int[] { visitable[r1][0], visitable[r1][1] };//choose a random field } contrl.temp = new int[] { pos[0], pos[1], temp[0], temp[1] }; return temp; } }
internal void startGame(int size, Draught.Intelligence p1, Draught.Intelligence p2) { map = new Map(size); control = new Draught.Control(map, p1, p2, this); world = new World(1, size, control, map); world.setVisible(true); drawManager.addDrawable(world); f.registerMouseListener(world); guiManager.closeActiveGui(); }