input stringlengths 10 828 | output stringlengths 5 107 |
|---|---|
public void add step steps | adds one to current step count |
public void reset steps steps 0 | resets the current step count to 0 |
public imap convert image to map file image file int map height imap builder mb new wop factory create map builder mb parse map convert image to map string image file map height return mb get current map | converts an image file into a map using |
private buffered image scale image buffered image src image double scale factor int new width int math round double src image get width scale factor int new height int math round double src image get height scale factor buffered image scaled image new buffered image new width new height src image get type graphics2 d g scaled image create graphics affine transform transform affine transform get scale instance scale factor scale factor g set rendering hint rendering hints key interpolation rendering hints value interpolation bicubic g draw rendered image src image transform g dispose return scaled image | helper method which scales a |
public void save map to image file imap map file image file boolean succ false try string ext image file get path substring image file get path last index of 1 succ image io write convert map to image map ext image file catch ioexception e see finally finally if succ throw new illegal argument exception could not save image | saves a map as an image file |
public imap generate random map int width int height int chance wop map builder mb create empty rectangle map width height for int x 1 x width x for int y 1 y height y if r next int 100 chance mb place wall x y if wop map mb get current map has no disconnected cells wop map mb get current map is valid map mb place free cell x y imap map mb get current map return map | generates a valid map randomly |
public string get previous map if pointer 0 if we are not at the first slot pointer return history get pointer | getter for the previous map |
public string get subsequent map if pointer size 1 if there is at least one more slot above pointer return history get pointer | getter for the subsequent map |
public void add new map string newmap if pointer size 1 if there is at least one more slot above pointer for int i pointer i history size i delete every subsequent map i e clear redo undo redo usually works this way history remove i history add pointer newmap else if pointer size 1 history list is full history remove 0 history add newmap | adds a new map to the history |
public boolean undo available if pointer 0 return true else return false | checks if undos are possible |
public boolean redo available if pointer history size 1 return true else return false | checks if redos are possible |
public void create empty rectangle map int dim x int dim y if dim x 3 dim y 3 throw new illegal argument exception else boolean map new boolean dim y dim y create new array with correct size for int y 0 y dim y y for int x 0 x dim x x if y 0 y dim y 1 x 0 x dim x 1 map y x true else map y x false hand the array over directly to the constructor this currentmap new wop map map currentmap compute number of walls slow update | creates an empty rectangle map of the given size |
private void place cell int x int y string to be set if x 0 y 0 throw new illegal argument exception while x currentmap get width 1 this currentmap add column while y currentmap get height 1 this currentmap add row to top if to be set equals wop rule wall this currentmap set wall to x y else if to be set equals wop rule free this currentmap set free to x y | helper that combines several check procedures for both place wall and |
public void fix border for int y 0 y this currentmap get height y for int x 0 x this currentmap get width x if y 0 y this currentmap get height 1 x 0 x this currentmap get width 1 this place wall x y currentmap compute number of walls slow update | borders the given map saves time for the user |
public void load picobot without random location ipicobot bot this bot bot wop bot bot set state 0 this traversed cells new linked hash set vector2i | loads a picobot into simulator without setting it to random location |
private void set bot to random location int i wop map map find free cell bot set initial position i 0 i 1 | sets the bots location to a new random location somewhere on the map |
public void reset at position int x int y this traversed cells new linked hash set vector2i if bot null wop bot bot set state 0 if map null bot set initial position x y | resets the simulation and places the picobot at the specified position |
private string remove comment string raw data int comment pos raw data index of check if there is any comment in the string at all if comment pos 1 return raw data trim else return raw data substring 0 comment pos trim | removes possibly existing comments from an unparsed rule |
public void test a ipicobot p bootstrap f create picobot assert equals 0 p get xcoordinate assert equals 0 p get ycoordinate assert equals 0 p get state assert equals 0 p get rules size | creates a simple picobot and tests the result of to string |
public void test a imap builder mb bootstrap f create map builder mb place wall 0 0 mb place wall 1 0 mb place wall 2 0 mb place wall 0 1 mb place wall 2 1 mb place wall 0 2 mb place wall 1 2 mb place wall 2 2 system out println mb get current map to string assert equals 3 mb get current map get height assert equals 3 mb get current map get width assert equals 8 mb get current map get number of walls | this method tests a programmatically built map |
private void action rules changed javax swing event caret event evt btn reload rules set enabled true | enables the rule reload button when editing rules in the text area |
private void action reload rules java awt event action event evt apply rules | loads the rules into bot when clicking on the rule reload button |
private void action undo java awt event action event evt imap builder mb wop map builder fact create map builder mb parse map history get previous map map mb get current map sim load map map p map reset sim p map repaint meni undo set enabled history undo available meni redo set enabled history redo available | reverts changes made to the map when clicking on the undo button |
private void action redo java awt event action event evt imap builder mb wop map builder fact create map builder mb parse map history get subsequent map map mb get current map sim load map map p map reset sim p map repaint meni undo set enabled history undo available meni redo set enabled history redo available | redoes changes made to the map when clicking on the redo button |
private void action zoom btn java awt event action event evt set correct view and scrollbar | resets the zoom level when clicking on the magnifier symbol |
private void action rule chart java awt event action event evt jdialog chart frame new jdialog this true rule visualizer rv pane new rule visualizer bot get rules jscroll pane scroll pane new jscroll pane rv pane chart frame get content pane add scroll pane chart frame set size 400 400 chart frame set title internationalization get string rule chart chart frame set location relative to null chart frame set visible true | shows a rule chart when clicking on the button |
private void toggle debug mode java awt event action event evt if debug null debug new debug dialog this false sim bot timer else debug reset sim bot timer debug set visible tbtn debug dialog is selected | opens a new window showing a debug screen when the button is disabled |
private void action new map java awt event action event evt history flush history if timer null timer reset steps generate map dialog gmd new generate map dialog this sim p map gmd set visible true set the right zoom level set correct view and scrollbar p map repaint | creates a new map when clicking on new map |
private void action save rules java awt event action event evt jfile chooser fc give new file chooser internationalization get string rules rules rules if fc show save dialog this jfile chooser approve option string rule file fc get selected file get path if rule file to lower case ends with rules rule file rules my io save to file new file rule file txt rule editor get text | shows a save dialog when clicking on save rules button to save the |
private void action fix border java awt event action event evt history add new map map to string move current map to history meni undo set enabled history undo available meni redo set enabled history redo available wop map builder mb wop map builder fact create map builder mb modify map mb fix border p map repaint | calls the fix border method of the mapbuilder to fix the border when |
private void action add row java awt event action event evt history add new map map to string move current map to history meni undo set enabled history undo available meni redo set enabled history redo available wop map map add row to top set correct view and scrollbar | adds a row to the current map when clicking on the button |
private void action add column java awt event action event evt history add new map map to string move current map to meni undo set enabled history undo available meni redo set enabled history redo available history action add column wop map map add column set correct view and scrollbar | adds a column to the current map when clicking on the button |
private void action remove row java awt event action event evt history add new map map to string move current map to history meni undo set enabled history undo available meni redo set enabled history redo available bot can not be removed from map when editing if bot get ycoordinate map get height 1 wop map map remove row from top set correct view and scrollbar | removes a row from the current map when clicking on the button |
private void action remove column java awt event action event evt history add new map map to string move current map to history meni undo set enabled history undo available meni redo set enabled history redo available bot can not be removed from map when editing if bot get xcoordinate map get width 1 wop map map remove column set correct view and scrollbar | removes a column from the current map when clicking on the button |
private void toggle map editor2 java awt event action event evt tbtn map editor set selected tbtn map editor is selected toggle map editor evt | enables or disables the map editor button depending on if it was pressed |
private void sld speed state changed javax swing event change event evt if timer null double spd math pow 2 sld speed get value 10 0 timer set speed int spd | when changing the speedlevel with the slider the intern variables get |
private void sld zoom state changed javax swing event change event evt if p map null p map set zoom level sld zoom get value p map repaint scrl map set preferred size p map get preferred size scrl map get viewport set view p map scrl map revalidate | when changing the zoomlevel with the slider the intern variables get |
private void action settings java awt event action event evt settings dialog sd new settings dialog this true settings blocking sd set visible true this settings sd get settings get changed settings send new settings to the correct classes p map set skin settings get skin p map set effects settings is effects p map set autofollow settings is autofollow p map repaint internationalization set language settings get lang update language if debug null debug update language | shows the settings dialog when clicking on the button and proceeds the |
private void action help java awt event action event evt desktop desktop desktop get desktop try uri uri new uri new file system get property user dir to uri help internationalization get help file desktop browse uri catch exception ex joption pane show message dialog null internationalization get string filenotfound | opens the computers default browser when pressing f1 or when clicking on |
private void set correct view and scrollbar set panel size to map size to show scroll bars scrl map set preferred size p map get preferred size scrl map get viewport set view p map scrl map revalidate set the view to whole map p map set zoom level math min scrl map get viewport get width map get width scrl map get viewport get height map get height sld zoom set value p map get zoom p map repaint | resizes the map panel and the scrollbars |
private void action analyze java awt event action event evt if apply rules analyze map amd new analyze map this true p map map bot get rules amd set visible true | shows the analyze window when clicking on the button |
private void action close java awt event action event evt dispose | disposes the application |
private string str list to string list string str list string builder builder new string builder for string s str list builder append s builder append n return builder to string | converts a string list to a single string |
private boolean apply rules try irule builder rb fact create rule builder bot load rules rb parse rules txt rule editor get text btn reload rules set enabled false return true catch invalid rule exception e string title internationalization get string invalid rules lbl app status set text title string message e get line number 1 internationalization get string invalid rules msg internationalization get string invalid rules line e get line number joption pane show message dialog this message title joption pane error message return false | reparses the current rules and applies them to the picobot |
protected void disable run buttons boolean running btn stop set enabled running meni stop set enabled running btn step set enabled running meni step set enabled running btn reset set enabled running meni reset set enabled running btn go set enabled running meni go set enabled running txt rule editor set enabled running btn left set enabled running btn right set enabled running btn up set enabled running btn down set enabled running | disables or enables a bunch of buttons while running the simulation |
private void action stop java awt event action event evt timer stop this try timer join catch interrupted exception e p map repaint | forces the bot to stop discovering the map when clicking on the button |
private void action reset java awt event action event evt sim reset sets camera position to the bot s coordinates if settings is autofollow scrl map get vertical scroll bar set value p map conv y bot get ycoordinate p map get zoom scrl map get horizontal scroll bar set value bot get xcoordinate p map get zoom if timer null timer reset steps p map reset marker p map repaint | resets the simulation when clicking on the button |
private void action about java awt event action event evt about dialog ad new about dialog this true ad set visible true | displays the about window |
private void action left java awt event action event evt int new x bot get xcoordinate 1 int new y bot get ycoordinate if new x 0 map get cell kind new x new y equals wop rule free wop simulator sim reset at position new x new y if timer null timer reset steps wop bot bot set facedir wop rule west p map repaint | move the bot one cell to the left when clicking the button |
private void action down java awt event action event evt int new x bot get xcoordinate int new y bot get ycoordinate 1 if new y 0 map get cell kind new x new y equals wop rule free wop simulator sim reset at position new x new y if timer null timer reset steps wop bot bot set facedir wop rule south p map repaint | move the bot one cell down when clicking the button |
private void action right java awt event action event evt int new x bot get xcoordinate 1 int new y bot get ycoordinate if new x map get width map get cell kind new x new y equals wop rule free wop simulator sim reset at position new x new y if timer null timer reset steps wop bot bot set facedir wop rule east p map repaint | move the bot one cell to the right when clicking the button |
private void action up java awt event action event evt int new x bot get xcoordinate int new y bot get ycoordinate 1 if new y map get height map get cell kind new x new y equals wop rule free wop simulator sim reset at position new x new y if timer null timer reset steps wop bot bot set facedir wop rule north p map repaint | move the bot one cell up when clicking the button |
public void set undo btn state boolean state meni undo set enabled state | enable or disable undo button |
public void set redo btn state boolean state meni redo set enabled state | enable or disable redo button |
public void set map imap map this map map | sets the new map |
public void set debug switch boolean swtch tbtn debug dialog set selected swtch | enables or disables the debug dialog button |
protected xymultiple series renderer build renderer int colors point style styles xymultiple series renderer renderer new xymultiple series renderer int length colors length for int i 0 i length i xyseries renderer r new xyseries renderer r set color colors i r set point style styles i renderer add series renderer r return renderer | builds an xy multiple series renderer |
protected default renderer build category renderer int colors default renderer renderer new default renderer for int color colors simple series renderer r new simple series renderer r set color color renderer add series renderer r return renderer | builds a category renderer to use the provided colors |
public void component hidden final component event e | not used but required by java |
public double distance final int i final int j final int c1 this path i this path length final int c2 this path j this path length return this cities c1 proximity this cities c2 | called to get the distance between two cities |
public void component moved final component event e | not used but required by java |
public void component resized final component event e | not used but required by java |
public void start create the initial chromosomes start up the background thread this started true this map update this map get graphics this epoc 0 if this worker null this worker null this worker new thread this worker set priority thread min priority this worker start | start the background thread |
public void action performed final action event e if e get source this btn quit system exit 0 else if e get source this btn train train else if e get source this btn run evaluate else if e get source this btn prune prune | called when the user clicks one of the three buttons |
protected void evaluate final double xor data get grid for int i 0 i 4 i final number format nf number format get instance final double d this network compute outputs xor data i this data i 3 set text nf format d 0 | called when the user clicks the run button |
public void prune final double xor data get grid final double xor ideal get ideal final prune prune new prune this network xor data xor ideal 0 05 final int count prune prune selective this network prune get current network this status set text prune removed count neurons this btn train set enabled false | called when the user clicks the prune button |
public void run final double xor data get grid final double xor ideal get ideal int update 0 final train train new backpropagation this network xor data xor ideal 0 7 0 9 final int max 10000 for int i 0 i max i train iteration update if update 100 this status set text cycles left max i error train get error update 0 this btn run set enabled true this btn prune set enabled true | the thread worker used for training |
protected void train if this worker null this worker null this worker new thread this this worker set priority thread min priority this worker start | called when the user clicks the train button |
public void action performed final action event e if e get source this btn quit system exit 0 else if e get source this btn train train else if e get source this btn run evaluate | called when the user clicks one of the three buttons |
public void run final double xor data get grid final double xor ideal get ideal int update 0 final prune prune new prune 0 7 0 5 xor data xor ideal 0 05 prune start incremental while prune get done prune prune incramental update if update 10 this status set text cycles prune get cycles hidden neurons prune get hidden neuron count current error prune get error update 0 this status set text best network found prune get hidden neuron count error prune get error this network prune get current network this btn run set enabled true | the thread worker used for training |
public int get result int result 1 int max count 0 final set integer set this results key set for final int year set final int count this results get year if count max count result year max count count return result | get birth year that occurred the largest number of times |
public void process final string name throws ioexception search new yahoo search if year born bot log system out println getting search results form yahoo final collection url c search search name int i 0 if year born bot log system out println scanning url s from yahoo for final url u c try i text check url this u null catch final ioexception e final int result year get result if result year 1 system out println could not determine when name was born else system out println name was born in result year | this method is called to determine the birth year for a person |
public move get move final byte board final move prev final byte color this player color final node root new node board prev byte max byte min value node child node best node null while child root get child null final byte val minimax ab child true byte min value byte max value if val max max val best node child return best node move | gets the next move of this player |
public move get move final byte board final move prev final byte color board print board board ask for move system out println you are playing tic tac toe resolve piece color select your move system out print x position final byte x get coord system out print y position final byte y get coord return new move x y color | gets the next move of this player |
public boolean is leaf if this leaf null return board is full this board board is winner this board tic tac toe noughts board is winner this board tic tac toe crosses return this leaf boolean value | determines if this node is a leaf on the game tree |
public move move return this move | gets the last move taken to reach this node on the game tree |
public move get move final byte board final move prev final byte player for final byte x byte math random 3 0 final byte y byte math random 3 0 final move m new move x y player if board is empty board m return m | gets this players next move |
public byte value final byte player if board is winner this board player return byte max value if they ve lost this node has minimum value else if board is winner this board tic tac toe reverse player return byte min value else return 0 | determines the value of this node to the specified player |
public move get move final byte board final move prev final byte player for byte x 0 x board length x for byte y 0 y board 0 length y final move m new move x y player if board is empty board m return m throw new illegal state exception i m just looking for the first empty square and i can t move | gets this players next move |
public player play return play null | called to begin a code game code |
public byte color return this color | gets the type of piece placed by this move |
public void start create the initial chromosomes start up the background thread this started true this map update this map get graphics this generation 0 if this worker null this worker null this worker new thread this worker set priority thread min priority this worker start | start the background thread |
public void iteration throws neural network error unit type best array set error determine error best array this get array copy this temperature this get start temperature for int i 0 i this cycles i double cur error randomize cur error determine error if cur error get error best array this get array copy set error cur error this put array best array final double ratio math exp math log get stop temperature get start temperature get cycles 1 this temperature ratio | called to perform one cycle of the annealing process |
public matrix get matrix return this weight matrix | get the weight matrix for this neural network |
protected feedforward network clip hidden neuron final int neuron final feedforward network result feedforward network this current network clone final collection feedforward layer c result get hidden layers final object layers c to array feedforward layer layers 0 prune neuron return result | internal method used to clip the hidden neurons |
public int compare to final chromosome gene type ga type other if get cost other get cost return 1 else return 1 | used to compare two chromosomes |
public int get size return this weight matrix get rows | get the size of this neural network |
public chromosome type get chromosome final int i return this chromosomes i | get a specific chromosome |
protected double determine error final feedforward network network return network calculate error this train this ideal | internal method to determine the error for a neural network |
public gene type get gene final int gene return this genes gene | get the specified gene |
protected boolean find neuron for int i 0 i this current network get hidden layer count i final feedforward network trial this clip hidden neuron i final double e2 determine error trial if e2 this max error this current network trial return true return false | internal method that will loop through all hidden neurons and prune them |
public int get cut length return this cut length | get the cut length |
public double get mating population return this mating population | get the mating population |
public feedforward network get current network return this current network | get the current neural network |
public double activation function final double d return d | a threshold function for a neural network |
public double calculate rms final double err math sqrt this global error this set size return err | returns the root mean square error for a complete training set |
public double get mutation percent return this mutation percent | get the mutation percent |
public double activation function final double d return 1 0 1 bound numbers exp 1 0 d | a threshold function for a neural network |
public double activation function double d final double result bound numbers exp d 2 0 1 0 bound numbers exp d 2 0 1 0 return result | a threshold function for a neural network |
public void reset this global error 0 this set size 0 | reset the error accumulation to zero |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.