We now have a great way to create files regarding the Robot’s brain, along with loading files of previous brains created!
We wanted to be able to store into text files the number of altControls a random brain used, the number of processes the brain used, the constants that each Above or Below Threshold was using, and all the variables (the left turn, right turn, and amount of time), for each MotorControl each random brain used.
Now, there is a savetofile() process which allows us to write a file line by line including all of the above methods. The BufferedWriter() and FileWriter() methods were called to create a new file for each individual random brain. This way we can keep track of what a robot did and run the robot again if we were happy with the brain it used.
In order to run the robot’s brain again, we needed to create a loadfromfile() process. This process takes in a file already created, and breaks it down line by line. The Scanner() method was called in order to read in a file that is given. Again, like above, each line has a different meaning regarding the robots brain (such as the constants it used). This allows for an easy way to see what the robot’s brain created, along with running the brain again to see if it was a worthwhile brain!








