id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
42171389-7a04-45fd-a1a3-e8776135c3ba | public static void main(String[] args)
{
;
} |
8b9467ea-230f-478f-8ffc-b3dfe0aa9947 | public ComputerPlayerUct()
{
throw new RuntimeException("Not ready yet.");
} |
cdf9a10d-93ee-4877-8dec-261f53c2cc14 | public String computerMove(NeutronBoard nb,int level,boolean pbem) {
return new String();
} |
17570ff8-0874-4911-b5f9-62a79cd692f5 | public String computerMove(NeutronBoard nb) {
return computerMove(nb,3,false);
} |
728c5903-83fe-4cbd-95cb-c02f4ad7d8af | public TranspositionEntry(NeutronBoard position,int depth, int value, int valueType) {
this.position=position;
this.depth=depth;
this.value=value;
this.valueType=valueType;
} |
25ddb206-5a42-4e3d-b37a-369fb0a702f7 | public NeutronBoard getPosition() { return position; } |
c3deb0bd-15c2-43d6-8948-437d1439d116 | public int getDepth() { return depth; } |
1965871e-0fc3-447f-b916-3a59083bc510 | public int getValue() { return value; } |
55b7dcc5-bbac-4007-88ad-400b3b6f5776 | public int getValueType() { return valueType; } |
cec7ecfa-6855-48b4-8b4f-8ab9a84d4775 | public ComputerPlayerMinimax()
{
System.out.println("Using Minimax");
} |
77de20b8-5f18-49e6-92dd-234a287b8af1 | public String computerMove(NeutronBoard nb) {
return computerMove(nb,3,false);
} |
de6ad6c9-3500-4bff-a0a0-19f77b4ea8ed | public String computerMove(NeutronBoard nb,int level,boolean pbem) {
String best_move=new String();
int value,best_value=3000;
boolean DEBUG=false;
NeutronBoard nb_copy;
if (nb.whoToMove()==NeutronBoard.WHITE) {
best_value=-best_value;
if (DEBUG) System.out.println("wtm=WHITE");
}
else {
if (DEB... |
18855c73-4fa4-4cc6-b359-5c922f67eb70 | private int minimax(NeutronBoard nb, int depth)
{
NeutronBoard n_copy;
int best_value=-3000;
if (nb.whoToMove()==NeutronBoard.BLACK) {
best_value=3000;
}
if ((depth==0) || (nb.isGameOver()!=NeutronBoard.NOPLAYER)) {
return NeutronUtil.evaluation(nb);
}
for (String AM... |
33ba4042-ba0c-4c57-826e-8d0cd72708d0 | public static int getRandom(int limit) {
return random_generator.nextInt (limit);
} |
5f832f9b-3940-423d-b14f-72e61e85a671 | public static String getRandomMove (NeutronBoard t) throws IllegalMoveException {
String move;
int losingMoves = 0;
if (t.isGameOver()!=NeutronBoard.NOPLAYER) {
if (DEBUG) {
throw new RuntimeException("(010)");
}
return new String ("");
}
ArrayList <String> moves=t.uniqueMoves();
... |
0b52c1dd-993f-48af-b0a5-91819e100d8a | public static ArrayList <String> getInput() {
ArrayList < String > result = new ArrayList < String > (10);
String line;
try {
line=new BufferedReader (new InputStreamReader (System.in)).readLine
();
if (line!=null) {
StringTokenizer st = new StringTokenizer (line);
while (st.hasMoreTokens ()) result.a... |
b7be47fe-41be-4646-97b6-959f3b5e409f | public static void main(String[] args)
{
NeutronBoard nb=new NeutronBoard();
System.out.println(nb);
try {
System.out.println(getRandomMove(nb));
}
catch (IllegalMoveException e) {
throw new RuntimeException();
}
} |
b9746cbe-2df8-4c84-ae0c-4cece2083de4 | public static int evaluation(NeutronBoard nb)
{
/* +1000 is win for white
-1000 is win for black
*/
int result=0;
if (nb.isGameOver()!=NeutronBoard.NOPLAYER) {
return (nb.isGameOver()==NeutronBoard.WHITE?1000:-1000);
}
for (int col=1; col<=5; col++) {
switch (nb.getAt(1,col)... |
9ceafc53-a29d-4fc6-a4f2-b097ae7ec852 | public boolean blank (int piece) { return (piece == EMPTY); } |
10e41a18-9c7a-4c40-b899-5d00b6e42626 | public NeutronBoard ()
{
int i, j;
wtm = WHITE;
gameover = NOPLAYER;
firstMove = true;
board = new int[7][7];
for (i=1; i<=5; i++)
for (j=1; j<=5; j++)
board[i][j] = EMPTY;
board[3][3]=NEUTRON;
for (j=1; j<=5; j++) {
board[1][j]=BLACK;
board[5][j]=WHITE;
board... |
7a37ab64-c018-4410-835c-eb8dff9d3492 | public int getAt(int row, int col) { return board[row][col]; } |
c115a8b2-947f-4df3-aac4-5bb25a0a9b42 | public boolean isFirstMove() { return firstMove; } |
175dd013-cfc8-4208-a87f-5be31a1c1214 | public NeutronBoard (NeutronBoard org)
{
int i, j;
wtm = org.wtm;
firstMove = org.firstMove;
neutron_x=org.neutron_x; neutron_y=org.neutron_y;
board = new int[7][7];
gameover=org.gameover;
for (i=0; i<7; i++)
for (j=0; j<7; j++)
this.board[i][j] = org.board[i][j];
} |
4415d280-2d27-4d6b-8cc5-4126b4cbafca | public int NeutronFreeSpaces()
{
int result=0;
if (board[neutron_x-1][neutron_y-1]==EMPTY) result++;
if (board[neutron_x-1][neutron_y ]==EMPTY) result++;
if (board[neutron_x-1][neutron_y+1]==EMPTY) result++;
if (board[neutron_x ][neutron_y ]==EMPTY) result++;
if (board[neutron_x ... |
4457eeab-f692-4585-986a-c683cb79174d | private boolean legalMove(int from_x,int from_y,int to_x, int to_y)
{
int dir_x, dir_y;
int dist;
dir_x=(int)Math.signum(to_x-from_x);
dir_y=(int)Math.signum(to_y-from_y);
if ((dir_x==0) && (dir_y==0)) return false;
dist=computeDistance(from_x,from_y,dir_x,dir_y);
if (dir_x==0) re... |
bd8d1ce0-793d-4f30-9063-866ef075644e | private int computeDistance(int x,int y,int dir_x,int dir_y)
{
int result=1;
while (board[x+result*dir_x][y+result*dir_y]==EMPTY) {
result++;
}
return result-1;
} |
fc904a91-b62b-4bcd-ab1c-c7f4474aa186 | private boolean isLeftRightMirror()
{
for (int x=1; x<3; x++) {
for (int y=1; y<3; y++) {
if (board[x][y]!=board[x][5-y]) return false;
}
}
return true;
} |
cc0614ee-aba4-4cf7-9790-7db01389bbe7 | @Override public String toString ()
{
StringBuffer result = new StringBuffer (500);
int i, j;
String cols = " A B C D E\n";
String space= " +---+---+---+---+---+\n";
result.append(cols);
for (i=1; i<=5; i++) {
result.append(space);
result.append(" "+i+" ");
for ... |
034ca284-8269-4abe-a19b-c05d46709db5 | public void makeMove (String move) throws IllegalMoveException
{
if (gameover != NOPLAYER)
throw new IllegalMoveException ("Game is over. gameover="+gameover);
String theMove=move.toUpperCase().replaceAll("[^A-E1-5]","");
int p_from_x,p_from_y,p_to_x,p_to_y;
int n_to_x=0,n_to_y=0;
int n_dir... |
b1a562a3-e44d-4c40-b2de-e8c46f93aa3e | public int whoToMove() { return wtm; } |
3040c8f3-0b9e-4342-bb3f-b4da575bbb1f | public void switchPlayer ()
{
switch (wtm)
{
case WHITE:
wtm = BLACK;
break;
case BLACK:
wtm = WHITE;
break;
default:
/* This should never happen */
assert (false);
break;
}
} |
5b14c388-b7fd-4606-90cc-42b50f037d7d | private boolean canNeutronMove()
{
for (int x=neutron_x-1; x<=neutron_x+1; x++) {
for (int y=neutron_y-1; y<=neutron_y+1; y++) {
if (board[x][y]==EMPTY) return true;
}
}
return false;
} |
a93ef3f8-4f6f-4ffb-8bb3-a8e39ff72a2c | public int isGameOver ()
{
if (gameover!=NOPLAYER) return gameover; // cached value
switch (neutron_x) {
case 1: gameover=BLACK; break;
case 5: gameover=WHITE; break;
default:
if (!canNeutronMove()) {
gameover=whoDidLastMove();
break;
}
gameover=NO... |
9ddb1748-4c03-4a7e-82b9-77d9af811108 | public ArrayList<String> uniqueMoves()
{
// throws away all equal moves
int p_distance,n_distance;
if (firstMove) {
ArrayList<String> Moves = new ArrayList<String>(7);
Moves.add(new String("A5-A2"));
Moves.add(new String("B5-B2"));
Moves.add(new String("C5-C4"));
Moves.add(... |
0f5c7459-fba6-4dd6-821e-0cc1605855c7 | public int whoDidLastMove ()
{
if (firstMove==true) return NOPLAYER;
switch (wtm)
{
case WHITE: return BLACK;
case BLACK: return WHITE;
default:
// This should never happen
assert (false);
break;
}
return 0; // To make the compiler happy
} |
4f1f02d6-8377-429e-8206-c187f9e21749 | public static void main (String[] args)
{
NeutronBoard n;
ArrayList<String> moves;
ArrayList<String> aMove;
boolean result;
result = true;
try
{
n = new NeutronBoard();
System.out.println(n);
moves = n.uniqueMoves ();
System.out.println(moves.size());
if (mo... |
a0dbd7e2-0ecf-4399-acae-a5cb04e514f5 | public abstract String computerMove (NeutronBoard nb); |
f9182281-7df3-40cf-968c-6d8a13848ef4 | public abstract String computerMove (NeutronBoard nb,int level,boolean pbem); |
d611b6bc-f26b-4edc-a83f-dcf5df9e6065 | public void setPBEM(boolean value) { pbem=value; } |
bc0c4db8-dfed-40ba-b262-7ad286f8ef59 | public boolean getPBEM() { return pbem; } |
a45a8927-16ce-467a-81bd-08e9f2d9c2eb | public String computerMove (NeutronBoard nb,int level) {
return computerMove(nb,level,false);
} |
163eefde-ad2e-42ca-b76b-a6fb401b7bc0 | public ComputerPlayerSimple()
{
;
} |
d03aa0d9-ce16-4338-b513-1b42d3eb1381 | public String computerMove(NeutronBoard nb) {
return computerMove(nb,3,false);
} |
fb0d2f06-6a23-4d6c-a891-4bc115017660 | public String computerMove (NeutronBoard nb,int level,boolean pbem)
{
int best_value,eval;
String best_move=new String();
NeutronBoard nb_copy;
ArrayList <String> moves=nb.uniqueMoves();
best_value=2000;
if (nb.whoToMove()==NeutronBoard.WHITE) best_value=-2000;
for (String AMove : moves) ... |
eb8b54ac-9f6c-4241-8b86-73058109b243 | public ComputerPlayerAlphaBeta()
{ ; } |
3c05a81b-a5ff-4d47-bb67-56900671168a | public String computerMove(NeutronBoard nb) {
return computerMove(nb,3,pbem);
} |
70a99582-d78d-4cb7-83b4-95ae5aa2b1b7 | public String computerMove(NeutronBoard nb,int level,boolean pbem) {
String best_move=new String();
int value,best_value=3000;
boolean DEBUG=false;
NeutronBoard nb_copy;
if (nb.whoToMove()==NeutronBoard.WHITE) {
best_value=-best_value;
if (DEBUG) System.out.println("wtm=WHITE");
}
else {
if (DEB... |
c8f2f43f-7c7d-4efe-8c0d-c66cda618c3a | private int alphabeta(NeutronBoard nb, int depth,int alpha, int beta)
{
NeutronBoard n_copy;
if ((depth==0) || (nb.isGameOver()!=NeutronBoard.NOPLAYER)) {
return NeutronUtil.evaluation(nb);
}
for (String AMove : nb.uniqueMoves()) {
n_copy=new NeutronBoard(nb);
try {
n_copy... |
35f5f201-f6a8-446f-80cf-dff0df94c7f8 | public IllegalMoveException(String message) {
super(message);
} |
eea29579-eb05-4c82-ba28-a2ea618137d4 | public TranspositionTable() { ; } |
202fa8c2-222e-4d3f-a2d0-466e8db9ffd7 | public long getId(); |
b886b292-0e59-4534-b6fa-8d01164984c9 | public String getTitle(); |
9d3df017-0cf9-4506-ac27-522f0ed9be9e | public String getAbstractText(); |
d1f178dd-1359-46c1-92d4-950bf16ea224 | public Date getPublicationDate(); |
a5f6af18-340f-4c60-ad7b-52cd2e27803e | public long getId() {
return id;
} |
992847de-523c-4599-b672-dec54c6b7301 | public void setId(long id) {
this.id = id;
} |
74e33697-26c7-4403-9460-ee99335c9fec | public String getLastName() {
return lastName;
} |
00b222b9-549f-4ed7-ae29-3c1e7da2afd1 | public void setLastName(String lastName) {
this.lastName = lastName;
} |
2fbd8d1d-d48d-4508-abce-375f34344778 | public String getForeName() {
return foreName;
} |
03085a6a-f441-41e4-9b74-bb23b53b5d99 | public void setForeName(String foreName) {
this.foreName = foreName;
} |
981777f5-f50d-4467-ba21-4ac54fb1babd | public long getId() {
return id;
} |
c73402e5-fe45-4593-a274-a3feb2170dec | public void setId(long id) {
this.id = id;
} |
9ba591be-15a8-4b36-a51f-68e34394511f | public String getTitle() {
return title;
} |
50b4da51-c55e-48d0-b521-013599acec62 | public void setTitle(String title) {
this.title = title;
} |
78385846-b1ca-4847-9068-08196a5f96a8 | public String getAbstractText() {
return abstractText;
} |
054a6f2a-f120-47cc-853c-bc3222380435 | public void setAbstractText(String abstractText) {
this.abstractText = abstractText;
} |
628eb56c-ab08-4341-b2cd-9956d12269f1 | public Date getPublicationDate() {
return publicationDate;
} |
f7f57b8a-575f-4e25-b6ac-cc11ff654d12 | public void setPublicationDate(Date publicationDate) {
this.publicationDate = publicationDate;
} |
31a0aafa-a66d-461d-a802-5305a94183fa | public Publication mapRow(ResultSet resultSet, int row) throws SQLException {
// Need to use a mapper, but it is not so bad if we don't want to use reflection since the database may use different names
PublicationImpl publication = new PublicationImpl();
publication.setId(resultSet.getLong("resource_id"));
... |
e335bf88-759e-4995-b70b-9ac238e94a79 | public Publication getPublicationById(long id) {
String sql = sqlHeader + "where resource_id = :resource_id";
// Spring advantages: No need to open / close connection or to worry about result set...
// We can use named parameters which are less error prone
SqlParameterSource namedParameters = new MapSqlParam... |
16ed90a7-6656-425e-9046-5363dfc4fa72 | public List<Publication> getPublicationByTitle(String title) {
String sql = sqlHeader + "where lower(title) like lower(:title)";
SqlParameterSource namedParameters = new MapSqlParameterSource("title", title);
return new NamedParameterJdbcTemplate(datasource).query(sql, namedParameters, new PublicationRowMapp... |
2efdcafc-3b7d-4af4-b24b-54fe3947d653 | public List<Long> getPublicationIdsByAuthor(String authorLastName) {
String sql = "SELECT pubs.resource_id from nextprot.publications pubs inner join nextprot.pubauthors authors on (pubs.resource_id = authors.publication_id) where lower(authors.last_name) = lower(:author_name)";
SqlParameterSource namedParameters... |
07971862-8c45-4b08-b7ed-e62594a7241e | public Author mapRow(ResultSet resultSet, int row) throws SQLException {
// Need to use a mapper, but it is not so bad if we don't want to use reflection since the database may use different names
Author author = new Author();
author.setId(resultSet.getLong("pubauthor_id"));
author.setLastName(resultSet.ge... |
7ddd5d44-1bf8-4a08-8dc9-01c2bd70b1cf | public List<Author> getAuthorByPublicationId(long publicationId) {
String sql = sqlHeader + "where publication_id = :publication_id";
SqlParameterSource namedParameters = new MapSqlParameterSource("publication_id", publicationId);
return new NamedParameterJdbcTemplate(datasource).query(sql, namedParameters, new... |
b505eea7-1e5c-44d3-93f1-413f0c61f679 | public Publication getPublicationById(@Value("id") long id) {
return publicationDAO.getPublicationById(id);
} |
27d9b179-85d5-49c0-a955-a1940e725c54 | @Override
public List<Publication> getPublicationByTitle(String title) {
return publicationDAO.getPublicationByTitle(title);
} |
116635e9-1dc7-4a61-9520-5ef9bb41decc | @Override
@Cacheable(value="publications")
public List<Long> getPublicationIdsByAuthor(String authorLastName) {
return publicationDAO.getPublicationIdsByAuthor(authorLastName);
} |
c8f46f19-b52a-4a0b-a816-3baa22c1440a | public List<Author> getAuthorByPublicationId(long publicationId); |
46317a95-ac71-4374-bb64-cf23029caa1c | public Publication getPublicationById(long id); |
eadf6600-534e-4df3-ae9c-d69a243453e9 | public List<Publication> getPublicationByTitle(String title); |
e9665d23-30b8-445e-9acf-52f85cd66f18 | public List<Long> getPublicationIdsByAuthor(String authorLastName); |
931041be-67bd-4b78-bba8-a76b2945ef7c | @Override
public List<Author> getAuthorByPublicationId(long id) {
return authorDAO.getAuthorByPublicationId(id);
} |
af9b3bbe-b69c-436b-8299-c8a3de1982d2 | public Void mapRow(ResultSet resultSet, int row) throws SQLException {
if(row % 1000 == 0){
//System.out.println("Do some stuff");
}
return null;
} |
f71607f9-6775-4584-a8ea-37f7c4673bea | @Test
public void getAuthorByPublicationId() {
JdbcTemplate temp = new JdbcTemplate(datasource);
temp.setFetchSize(100); //Don't forget to set the fecth size
temp.query(sql, new StringMapper());
} |
67609b29-d212-4ef5-8e90-02446fdf7eaf | @Test
public void shouldGetPublicationById() {
assertEquals(publicationService.getPublicationById(6634104).getId(), 6634104);
} |
5a999241-4e05-48fa-b45c-18cbd4b2a8b5 | @Test
public void shouldGetPublicationByTitle() {
List<Publication> pubs = publicationService.getPublicationByTitle("%Correction%");
assertEquals(pubs.size(), 90);
} |
21fc597a-73e9-47dc-a8a1-b3297b71868c | @Test(expected=IllegalArgumentException.class)
public void shouldThrowAnIllegalArgumentException() {
publicationService.getPublicationByTitle(null);
} |
7bcf268f-c06b-4836-a670-b5ae490ea75e | @Test
public void shouldFireCache() {
long startTime = System.currentTimeMillis();
publicationService.getPublicationIdsByAuthor("%");
long endTime = System.currentTimeMillis();
System.out.println("Took " + (endTime - startTime));
// should be in cache now
startTime = System.currentTimeMillis();
publica... |
3eb733f1-c400-44cb-9a48-1238f99c4707 | public Long getIdGaragem() {
return idGaragem;
} |
3721b5bb-e128-4e84-84d4-0ad5cb8582a0 | public void setIdGaragem(Long idGaragem) {
this.idGaragem = idGaragem;
} |
dba63ad7-6ff2-470a-9e1b-8990721edf2e | public Integer getNumero() {
return numero;
} |
3652ad63-e0fc-4007-8983-0c3f2d62135a | public void setNumero(Integer numero) {
this.numero = numero;
} |
13fb0ab8-df12-421c-a9b6-bb26aa219134 | public Boolean getStatus() {
return status;
} |
9645bcec-0a4e-4b8c-8213-b687b64790e5 | public void setStatus(Boolean status) {
this.status = status;
} |
eed3f2ca-8c49-4d42-b863-f901021ad524 | public static long getSerialversionuid() {
return serialVersionUID;
} |
42e064f1-8ed5-4554-8bc8-c30c0a714182 | @Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((idGaragem == null) ? 0 : idGaragem.hashCode());
result = prime * result + ((numero == null) ? 0 : numero.hashCode());
result = prime * result + ((status == null) ? 0 : status.hashCode());
return result;
... |
eb86b3a9-7dc3-47b0-9412-7bd6c31d85ca | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Garagem other = (Garagem) obj;
if (idGaragem == null) {
if (other.idGaragem != null)
return false;
} else if (!idGaragem.equals(other.id... |
fbb36627-04f2-494a-8792-bad5c39056da | public Long getIdVeiculo() {
return idVeiculo;
} |
1e9ab990-0ffd-48c9-b9d8-a93320a3d478 | public void setIdVeiculo(Long idVeiculo) {
this.idVeiculo = idVeiculo;
} |
dab78061-2fc2-40b7-bc84-cce64ad168f2 | public String getMarca() {
return marca;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.