input
stringlengths 10
828
| output
stringlengths 5
107
|
|---|---|
public string get description return qubic save files sav
|
returns the string description of this type of file
|
public square get move board board set square empty squares board get board player empty list square winning squares new array list square int max 1 for square s empty squares int score check square s if score max winning squares add s else if score max winning squares clear max score winning squares add s returns a random square with the highest value return winning squares get int math random winning squares size
|
returns a random square that represents the most valuable move to make according
|
public string to string return novice
|
returns a string representation of this strategy
|
public square get move board board square win winning move search board if win null return win else return starting strat get move board
|
returns a square that represents the most valuable move to make according
|
public string to string return intermediate
|
returns a string representation of this strategy
|
public string to string return expert
|
returns a string representation of this strategy
|
public rows has simple win board player player board board board row type rtype if player board player computer rtype board row type computer else rtype board row type human set rows rows board get rows rtype for rows r rows if r get piece count player 3 r get row type rtype return r return null
|
gets whether the given player has any 3s in a row
|
public boolean connect try socket new socket nm get address nm get port socket set so timeout nm get timeout in new buffered reader new input stream reader socket get input stream out new print writer socket get output stream true return true catch ioexception e return false
|
connects the client to the specified server
|
public void disconnect try socket close in close out close catch ioexception e throw new runtime exception e to string
|
disconnects the client from the connected server
|
public string get address return socket get inet address to string
|
returns a string representation of the client internet address
|
public void output string s out println s
|
outputs the given string over the network
|
public buffered reader get reader return in
|
gets the current input stream so that information can be read into qubic
|
public void disconnect try server close socket close in close out close catch ioexception e throw new runtime exception e to string
|
disconnects the client from the connected server
|
public void add square s map put s s get player
|
adds a square to the row
|
public int compare to object o return this row number rows o row number
|
compares two rows objects
|
public int get piece count board player player int count 0 for board player p map values if p player count return count
|
gets the number of pieces the given player has in this row
|
public string to string return row number get key set to string
|
gets a string representation of this rows object
|
public boolean update square model map put model model get player rows get type remove this type get row type rows get type add this if type board row type open if type board row type human pieces get piece count board player human else if type board row type computer pieces get piece count board player computer else if type board row type mixed pieces 1 if pieces 4 return true else pieces 0 return false
|
this method updates the row type pieces removes and adds the row from
|
public void add rows rows r list of rows add r
|
adds rows to the list of rows the square is in
|
public boolean equals square o1 if this o1 return true if o1 null return false if get class o1 get class return false square o square o1 return plane o plane row o row col o col
|
the perfect equals method from the book for square objects
|
public int get plane return plane
|
gets the plan this square is in
|
public boolean set player board player player boolean win false this player player for rows r list of rows if r update this true win true return win
|
sets the owning player of this square to the given player
|
public void set redo player board player player redo player player
|
sets the previous owner of this square to the given player
|
public string to string return plane row col
|
returns a string representation of the square
|
public void add listener board listener listener note the following loop can not be a for each loop for each loops use iterators and this will cause qubic to throw concurrent modification exception for int i 0 i listeners size i if listeners get i equals listener listeners remove i listeners add listener
|
adds a listener to the board
|
public boolean check cats game return rows get row type computer is empty rows get row type human is empty rows get row type open is empty
|
checks to see if its a cats game i
|
public boolean computer move if is comp turn boolean flag move strat get move this player computer set comp turn false return flag else return false
|
this move makes the computer make a move
|
public square get hint return new expert player human player computer get move this
|
when tutorial mode is enabled this method highlights a good move
|
public strategy get strat return strat
|
gets the strategy that the board is using
|
public boolean get comp turn return is comp turn
|
gets whether it is the opponents turn or not
|
public void start frame set visible true split set divider location 0 65 output append lang get translation welcome to qubic type commands to see available options n game do click
|
starts the qubic game by making the created jframe visible to the user
|
public boolean is game is done return game is done
|
get whether the game is done or not
|
private boolean is legal square m player player boolean player ok true if player player human get comp turn player ok false return m null game is done player ok
|
determines whether the move specified by the passed square is a legal
|
public boolean move int plane int row int column player player return move find plane row column player
|
makes a move based on the given plane row column and player
|
public boolean move square s player player if is legal s player redo clear redoable false moves push s player squares get player empty remove s player squares get player add s if s set player player game is done true winning player player update occurred if check cats game game is done true is comp turn true return true return false
|
adds a square on the board to the given players list of squares
|
public boolean move again square s player player if is legal s player moves push s player squares get player empty remove s player squares get player add s if s set player player game is done true winning player player update occurred if check cats game game is done true is comp turn is comp turn return true return false
|
adds a square on the board to the given players list of squares
|
private void read object object input stream in throws exception in default read object listeners new array list board listener
|
this is used to read the board in from a saved file
|
public boolean redoable return redoable
|
accessor method for the code redoable code field
|
public void set comp turn boolean is comp turn this is comp turn is comp turn
|
sets whether it is the opponents turn or not with the given boolean
|
public void set strat strategy strat this strat strat
|
sets the strategy for the board to use
|
public void undo if moves is empty undo helper if moves is empty undo helper redoable true game is done false
|
allows the user to undo his or her last move
|
private void update occurred for board listener listener listeners listener update this
|
updates all listeners listening to board
|
public void update board board set board board repaint
|
updates the view with the new board and repaints
|
private void draw squares graphics2 d g2 iterator square iter color color square cur while iter has next cur iter next if cur equals get hint g2 set paint color yellow else g2 set paint color g2 fill new ellipse2 d double loc pt cur get plane cur get row cur get col get x radius loc pt cur get plane cur get row cur get col get y radius 2 radius 2 radius
|
given an iterator over the squares in a given player set it draws
|
private point loc pt int plane int row int col int x 2 5 col 1 2 4 row int y 8 plane 1 2 row x cur grid size y cur grid size x margin left y margin top return new point x y
|
given plane row and column coordinates as well as the current grid
|
public void paint component graphics g super paint component g
|
all views must have a valid paint component method so they can be
|
public void show hint square s this set hint s repaint
|
assigns the hint field to the square passed to it determined by the
|
public string to string return identity
|
returns a string representation of the identity of the view
|
public boolean equals qubic view other return to string equals other to string
|
sees if two qubic view objects are equal to each other
|
public void set human color color human color this human color human color
|
sets the color of the human player
|
public color get human color return human color
|
returns the color of the human player
|
public void set comp color color comp color this comp color comp color
|
sets the color of the opponent player
|
public color get comp color return comp color
|
gets the color of the opponent player
|
public void set hint square hint this hint hint
|
sets the hint to the square that is being hinted at
|
public square get hint return hint
|
returns the hint to the user
|
private void build library string language try scanner data new scanner new file qubic lang language lang utf 8 string current while data has next line current data next line split trans put current 0 current 1 catch ioexception e throw new runtime exception e to string
|
constructs a translation library from an input file in the form
|
public string get translation string s return trans get s
|
returns the translation for the given string by looking it up in the
|
private int save game try if fc show save dialog frame jfile chooser approve option string filename fc get selected file if filename ends with sav filename sav file output stream fos new file output stream filename object output stream output new object output stream fos output write object board save set enabled false return jfile chooser approve option else return jfile chooser cancel option catch ioexception error throw new runtime exception error to string
|
saves the current game to a file of the users choosing
|
private void load game try if fc show open dialog frame jfile chooser approve option file input stream fis new file input stream fc get selected file object input stream input new object input stream fis board board input read object save set enabled false catch exception error error print stack trace update game
|
loads a previously saved qubic game from a file of the users choosing
|
private void build network listener if server null nl new network listener server get reader this else nl new network listener client get reader this
|
builds a new network listener object
|
public void read string string s output append s swing utilities invoke later new runnable public void run output set text output get text
|
reads in a chat string from the network
|
private void update game for qubic view v views v update board board add listener v
|
updates the current game by passing the current board to each view and
|
protected iterator list constructs return get engine list defglobals
|
get a list of the jess constructs
|
protected string get name object o return defglobal o get name
|
get the name of a jess construct
|
public void initialize set tab properties set icon icons get yes icon set label jess set short description jess the java expert system shell if delegate null delegate initialize
|
initialize the protege jess tab jess tab
|
protected iterator list constructs return get engine list functions
|
get a list of the jess constructs
|
protected void view fact fact f open a window that displays the fact jtext area text area new jtext area f to string text area set editable false text area set line wrap true text area set wrap style word true jscroll pane scroll pane new jscroll pane text area scroll pane set preferred size new dimension 600 400 component factory show in frame scroll pane view fact
|
view a fact in a separate window
|
protected instance get instance object val return jess tab system classes get instance defglobal val
|
get the protege instance for a jess construct
|
protected string get name object o if o instanceof userfunction return userfunction o get name return unknown
|
get the name of a jess construct
|
public void add argument string name int type throws jess exception if m has wildcard throw new jess exception defmessagehandler add argument the message handler this already has a wildcard argument name m arguments add new argument name type if type ru multivariable m has wildcard true
|
add a formal argument to this defmessage handler
|
protected string get definition object o if o instanceof deffunction if script lib functions contains deffunction o get name return predefined jess function in scriptlib clp n n super get definition o else return super get definition o if o instanceof userfunction return intrinsic jess function super get definition o return definition unavailable
|
get the definition of a jess construct
|
protected iterator list constructs return protege defmethod list defmethods
|
get a list of the jess constructs
|
public void save if delegate null delegate save
|
called when the kb is about to be saved
|
protected instance get instance object val if val instanceof deffunction return jess tab system classes get instance deffunction val return null
|
get the protege instance for a jess construct
|
protected instance get instance object val if val instanceof defmethod return jess tab system classes get instance defmethod val return null
|
get the protege instance for a jess construct
|
protected void update constructs list list constructs construct list model data model boolean show predef predefined is selected constructs clear try value vector vv get engine execute command list function list value null for int i 0 i vv size i object o get engine find userfunction vv get i string value null if o instanceof deffunction if show predef script lib functions contains deffunction o get name constructs add o else if o instanceof userfunction if show predef constructs add o else constructs add o catch jess exception ex
|
update the list of jess constructs
|
protected iterator list constructs return get engine list defrules
|
get a list of the jess constructs
|
protected string get name object o return has lhs o get name
|
get the name of a jess construct
|
protected instance get instance object val return jess tab system classes get instance has lhs val
|
get the protege instance for a jess construct
|
public jtabbed pane get tabbed pane if delegate null return delegate get tabbed pane else return null
|
get the tabbed pane for jess tab
|
protected iterator list constructs return get engine list deffacts
|
get a list of the jess constructs
|
protected string get name object o return deffacts o get name
|
get the name of a jess construct
|
protected instance get instance object val return jess tab system classes get instance deffacts val
|
get the protege instance for a jess construct
|
public value get object value throws jess exception return get slot value fact mapper object slot name
|
get the value of the protege object that this fact represents
|
public frame get object throws jess exception return frame get object value external address value null
|
get the protege object that this fact represents
|
public void set object frame obj throws jess exception set slot value fact mapper object slot name new value obj
|
set the protege object that this fact represents
|
protected string get definition object o if o instanceof visitable pretty printer pp new jess tab pretty printer visitable o return pp to string else return o to string
|
get the definition of a jess construct
|
protected void update constructs list list constructs construct list model data model constructs clear for iterator e list constructs e has next constructs add e next
|
update the list of jess constructs
|
protected void update display update constructs list constructs data model sort the constructs object ca constructs to array arrays sort ca new comparator public int compare object o1 object o2 return get name o1 compare to get name o2 constructs clear for int i 0 i ca length i constructs add ca i data model fire contents changed this 0 constructs size
|
update the list of displayed constructs
|
protected iterator list constructs return protege defmessage handler list defmessagehandlers
|
get a list of the jess constructs
|
protected jcomponent create construct panel return new jpanel new border layout
|
creates and returns a panel for displaying the construct
|
protected string get name object o defmessagehandler dmh defmessagehandler o string name dmh get name dmh get cls get name if dmh get type defmessagehandler handler type primary name dmh get type name return name
|
get the name of a jess construct
|
protected instance get instance object val if val instanceof defmessagehandler return jess tab system classes get instance defmessagehandler val return null
|
get the protege instance for a jess construct
|
private jtext area create simple form jtext area construct panel new jtext area constructs list set selection mode list selection model single selection construct panel set editable false construct panel set line wrap true construct panel set wrap style word true construct panel set background color light gray return construct panel
|
creates and returns a simple form for displaying constructs
|
private void set selected simple construct object o if o null simple form set text get definition o simple form set background color white else simple form set text simple form set background color light gray
|
show a jess construct in a simple form
|
protected void show selected construct int index constructs list get selected index if index 0 index constructs size set selected construct constructs get index else set selected construct null
|
show the selected jess construct in the panel
|
public void add method defmethod m if m get index 1 m set index get unique index set a default index if not done so before remove similar method m overwrite any old method with the same signature get methods add m
|
add a new method to a generic function
|
protected void view construct object val string construct type if val null return instance inst get instance val if inst null cls widget cls widget inst get knowledge base get project create runtime cls widget inst component factory show in frame jcomponent cls widget view construct type else view simple construct val construct type
|
view a jess construct in a separate window
|
private void remove similar method defmethod m for iterator i get methods iterator i has next defmethod q defmethod i next if m is similar q remove method q return
|
remove an existing method that is similar to a new one
|
private void view simple construct object val string construct type if val null return jtext area text area new jtext area get definition val text area set editable false text area set line wrap true text area set wrap style word true jscroll pane scroll pane new jscroll pane text area scroll pane set preferred size new dimension 600 400 component factory show in frame scroll pane view construct type
|
view a jess construct in a separate window
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.