//Having the ai generate a move without playing it, and then playing on all ais would be the best //but... all ai have to be able to play a move but all don't need to generate one without playing it //so this is more likely to work for now. bool PlayMove(List<SimpleGoPlayer> ais, Ent_move move, int aiExemption) { if (move.vertex == null) //resign { Output(move.color.ToString() + " resigned"); Output("\n"); return false; } if (move.vertex.pass) { Output("PASS" + "\t"); if (lastPassed) return false; lastPassed = true; return true; } board[move.vertex.xPos, move.vertex.yPos] = move.color.ToString() == "b" ? moveNumber : -moveNumber; moveNumber++; Output(move.vertex.ToString() + "\t"); for (int x = 0; x < ais.Count; x++) { if (x != aiExemption) { ais[x].Play(move); lastPassed = false; } } //goodBoardController.Play(move); //It knows if the pieces are empty board[move.vertex.xPos, move.vertex.yPos] = ++turnNumber * (move.color.color == 1 ? 1 : -1); SafeRefresh(); return true; }
public abstract void Play(Ent_move move);
public override void Play(Ent_move move) { Controller.play(move.color.ToString(), move.vertex.xPos, move.vertex.yPos, proc); }
void CommandReader_commandRecieved(object sender, CommandReader.CommandEvent e) { string[] delimitter = { " " }; string[] parts = e.command.Split(delimitter, StringSplitOptions.None); if (parts.Length <= 0) throw new Exception("Recieved an empty string, this is not a command"); Ent_int id = null; //Null if no id was recieved int tempId; int pos = 0; if (Int32.TryParse(parts[0], out tempId)) { id = new Ent_int(tempId); pos++; } string command_name = parts[pos++]; string arguments = e.command.Substring(e.command.IndexOf(command_name) + command_name.Length); command_name = command_name.ToLower(); //Call appropriate events try { e.response = "="; if (id != null) e.response += id.data.ToString(); e.response += " "; switch (command_name) { //case "protocol_version": // e.response += protocol_version(); // break; case "protocol_version": e.response += protocol_version(); break; case "name": e.response += name(); break; case "version": e.response += version(); break; case "known_command": e.response += known_command(arguments); break; case "list_commands": e.response += list_commands(); break; case "quit": quit(); break; case "boardsize": boardsize(new Ent_int(arguments).data); break; case "clear_board": clear_board(); break; case "komi": komi(new Ent_float(arguments).data); break; case "play": Ent_move move = new Ent_move(arguments); play(move.color.ToString(), move.vertex.xPos, move.vertex.yPos); break; case "genmove": e.response += genmove(new Ent_color(arguments).ToString()); break; case "undo": undo(); break; case "showboard": e.response += showboard(); break; case "fixed_handicap": List<Ent_vertex> fixedVertices = fixed_handicap(new Ent_int(arguments).data); foreach (Ent_vertex vertex in fixedVertices) e.response += " " + version.ToString(); break; case "place_free_handicap": List<Ent_vertex> placeFreeVertices = place_free_handicap(new Ent_int(arguments).data); foreach (Ent_vertex vertex in placeFreeVertices) e.response += " " + version.ToString(); break; case "set_free_handicap": List<Ent_vertex> setFreeVertices = new List<Ent_vertex>(); while (pos < parts.Length) setFreeVertices.Add(new Ent_vertex(parts[pos++])); set_free_handicap(setFreeVertices); break; case "time_settings": time_settings(new Ent_int(parts[pos]).data, new Ent_int(parts[pos + 1]).data, new Ent_int(parts[pos + 2]).data); break; case "time_left": time_left(new Ent_color(parts[pos]).ToString(), new Ent_int(parts[pos + 1]).data, new Ent_int(parts[pos + 2]).data); break; case "final_score": e.response += final_score(); break; case "final_status_list": List<Ent_vertex> finalStatusVertices = final_status_list(parts[pos]); foreach (Ent_vertex vertex in finalStatusVertices) e.response += " " + version.ToString(); break; } if (e.response.EndsWith(" ")) e.response = e.response.Substring(0, e.response.Length - 1); e.response += "\n\n"; } catch (Exception error) { e.response = "? "; if (id != null) e.response += id.data.ToString() + " "; //Sort of hackish, but it saves me time in adding a check to every case if (error.Message == "Object reference not set to an instance of an object.") e.response += command_name + " command known, but not handled."; else e.response += error.Message; e.response += "\n\n"; } //fill in e.response //return [id] [response] \n\n }