package com.nullprogram.chess.ai;

import java.util.HashMap;
import java.util.Properties;

/**
 * Represents a particular configuration of an AI player.
 */
public class Config extends HashMap<String, Double> {

    /** List of all currently existing properties. */
    static final String[] PLIST = {
        "depth", "Pawn", "Knight", "Bishop", "Rook", "Queen", "King",
        "Chancellor", "Archbishop", "material", "safety", "mobility"
    };

    /** Version for object serialization. */
    private static final long serialVersionUID = 1L;

    /**
     * Create a new configuration.
     */
    public Config() {
        super();
    }

    /**
     * Create a config from a set of properties.
     *
     * @param props the proprties to derive from
     */
    public Config(final Properties props) {
        for (String prop : PLIST) {
            put(prop, Double.parseDouble(props.getProperty(prop)));
        }
    }

    /**
     * Create a properties object from tihs config.
     *
     * @return the properteies that matches this config
     */
    public final Properties getProperties() {
        Properties props = new Properties();
        for (String prop : PLIST) {
            props.setProperty(prop, "" + get(prop));
        }
        return props;
    }

    @Override
    public final String toString() {
        String str = "";
        for (String prop : PLIST) {
            str += prop + "=" + get(prop) + ",";
        }
        return str;
    }
}

@@ -28,16 +28,48 @@
 ss.ai;%0A%0A
+import java.lang.StringBuilder;%0A
 import j
@@ -1375,17 +1375,41 @@
 ring
- str = %22%22
+Builder str = new StringBuilder()
 ;%0A  
@@ -1461,12 +1461,16 @@
  str
- += 
+.append(
 prop
@@ -1493,16 +1493,17 @@
 p) + %22,%22
+)
 ;%0A      
@@ -1524,16 +1524,27 @@
 turn str
+.toString()
 ;%0A    %7D%0A

Use a StringBuilder in Config's toString().