query
stringlengths
7
33.1k
document
stringlengths
7
335k
metadata
dict
negatives
listlengths
3
101
negative_scores
listlengths
3
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
method for getting all image and video path from device gallery
private void getGalleryData() { // Get relevant columns for use later. String[] projection = { MediaStore.Files.FileColumns._ID, MediaStore.Files.FileColumns.DATA, MediaStore.Files.FileColumns.DATE_ADDED, MediaStore.Files.FileColumns.MEDIA_TYPE, MediaStore.Files.FileColumns.MIME_TYPE, MediaStore.Files.FileColumns.TITLE }; // Return only video and image metadata. String selection = MediaStore.Files.FileColumns.MEDIA_TYPE + "=" + MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE + Constants.OR_TXT + MediaStore.Files.FileColumns.MEDIA_TYPE + "=" + MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO; Uri queryUri = MediaStore.Files.getContentUri(Constants.EXTERNAL_MEMORY); CursorLoader cursorLoader = new CursorLoader( this, queryUri, projection, selection, null, // Selection args (none). MediaStore.Files.FileColumns.DATE_ADDED + Constants.SORTING_ORDER // Sort order. ); Cursor cursor = cursorLoader.loadInBackground(); //int columnIndex = cursor.getColumnIndex(MediaStore.Video.Thumbnails.DATA); if (cursor.moveToFirst()) { do { // String data = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Thumbnails.DATA)); String image = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA)); //String video = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DATA)); mGalleryData.add(image); // String uri = cursor.getString(columnIndex); } while (cursor.moveToNext()); } cursor.close(); mGalleryData.size(); // add gallery fragment addGalleryFragment(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public ArrayList<DeviceMediaItem> getAllImagesByFolder(String path, Context contx) {\n ArrayList<DeviceMediaItem> media = new ArrayList<>();\n Uri allImagesuri = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;\n String[] projection = {MediaStore.Images.ImageColumns.DATA, MediaStore.Images.Media.DISPLAY_NAME,\n MediaStore.Images.Media.SIZE, MediaStore.Images.Media.DATE_ADDED};\n Cursor cursor = contx.getContentResolver().query(allImagesuri, projection, MediaStore.Images.Media.DATA + \" like ? \", new String[]{\"%\" + path + \"%\"}, null);\n try {\n cursor.moveToFirst();\n do {\n DeviceMediaItem pic = new DeviceMediaItem();\n\n pic.setName(cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DISPLAY_NAME)));\n pic.setPath(cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA)));\n String date = getDate(cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATE_ADDED)));\n pic.setDate(date);\n\n media.add(pic);\n } while (cursor.moveToNext());\n cursor.close();\n } catch (Exception e) {\n e.printStackTrace();\n }\n\n Uri allVideosuri = android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI;\n String[] vidProjection = {MediaStore.Video.VideoColumns.DATA, MediaStore.Video.Media.DISPLAY_NAME,\n MediaStore.Video.Media.SIZE, MediaStore.Video.Media.DATE_ADDED};\n Cursor vidCursor = contx.getContentResolver().query(allVideosuri, vidProjection, MediaStore.Images.Media.DATA + \" like ? \", new String[]{\"%\" + path + \"%\"}, null);\n try {\n vidCursor.moveToFirst();\n do {\n DeviceMediaItem pic = new DeviceMediaItem();\n\n pic.setName(vidCursor.getString(vidCursor.getColumnIndexOrThrow(MediaStore.Video.Media.DISPLAY_NAME)));\n pic.setPath(vidCursor.getString(vidCursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA)));\n String date = getDate(vidCursor.getLong(vidCursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATE_ADDED)));\n pic.setDate(date);\n\n media.add(pic);\n } while (vidCursor.moveToNext());\n vidCursor.close();\n } catch (Exception e) {\n e.printStackTrace();\n }\n return media;\n }", "private List<String> getAllShownImagesPath(Activity context) {\n String[] columns = {MediaStore.Images.Media.DATA, MediaStore.Images.Media.DATE_ADDED};\n\n Cursor cursor = context.getContentResolver().query(\n MediaStore.Images.Media.EXTERNAL_CONTENT_URI, // Specify the provider\n columns, // The columns we're interested in m\n MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME + \" = \" + \"'Camera'\", // A WHERE-filter query\n null, // The arguments for the filter-query\n MediaStore.Images.Media.DATE_ADDED + \" DESC\" // Order the results, newest first\n );\n //\n\n List<String> result = new ArrayList<String>(cursor.getCount());\n\n if (cursor.moveToFirst()) {\n final int image_path_col = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);\n do {\n result.add(cursor.getString(image_path_col));\n } while (cursor.moveToNext());\n }\n cursor.close();\n\n\n return result;\n\n }", "public void getImagesFromFolder() {\n File file = new File(Environment.getExternalStorageDirectory().toString() + \"/saveclick\");\n if (file.isDirectory()) {\n fileList = file.listFiles();\n for (int i = 0; i < fileList.length; i++) {\n files.add(fileList[i].getAbsolutePath());\n Log.i(\"listVideos\", \"file\" + fileList[0]);\n }\n }\n }", "public ArrayList<DeviceMediaItem> getAllImages(Context contx) {\n ArrayList<DeviceMediaItem> images = new ArrayList<>();\n Uri allImagesuri = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;\n String[] projection = {MediaStore.Images.ImageColumns.DATA, MediaStore.Images.Media.DISPLAY_NAME,\n MediaStore.Images.Media.SIZE, MediaStore.Images.Media.DATE_ADDED};\n Cursor cursor = contx.getContentResolver().query(allImagesuri, projection, null, null, null);\n try {\n cursor.moveToFirst();\n do {\n DeviceMediaItem pic = new DeviceMediaItem();\n\n pic.setName(cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DISPLAY_NAME)));\n pic.setPath(cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA)));\n String date = getDate(cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATE_ADDED)));\n pic.setDate(date);\n\n images.add(pic);\n } while (cursor.moveToNext());\n cursor.close();\n } catch (Exception e) {\n e.printStackTrace();\n }\n\n Uri allVideosuri = android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI;\n String[] vidProjection = {MediaStore.Video.VideoColumns.DATA, MediaStore.Video.Media.DISPLAY_NAME,\n MediaStore.Video.Media.SIZE, MediaStore.Video.Media.DATE_ADDED};\n Cursor vidCursor = contx.getContentResolver().query(allVideosuri, vidProjection, null, null, null);\n try {\n vidCursor.moveToFirst();\n do {\n DeviceMediaItem pic = new DeviceMediaItem();\n\n pic.setName(vidCursor.getString(vidCursor.getColumnIndexOrThrow(MediaStore.Video.Media.DISPLAY_NAME)));\n pic.setPath(vidCursor.getString(vidCursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA)));\n String date = getDate(vidCursor.getLong(vidCursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATE_ADDED)));\n pic.setDate(date);\n\n images.add(pic);\n } while (vidCursor.moveToNext());\n vidCursor.close();\n } catch (Exception e) {\n e.printStackTrace();\n }\n return images;\n }", "private ArrayList<String> getAllShownImagesPath(Activity activity) {\n Uri uri;\n Cursor cursor;\n int column_index_data, column_index_folder_name;\n ArrayList<String> listOfAllImages = new ArrayList<String>();\n String absolutePathOfImage = null;\n uri = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;\n\n String[] projection = { MediaStore.MediaColumns.DATA,\n MediaStore.Images.Media.BUCKET_DISPLAY_NAME };\n\n cursor = activity.getContentResolver().query(uri, projection, null,\n null, null);\n\n column_index_data = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);\n column_index_folder_name = cursor\n .getColumnIndexOrThrow(MediaStore.Images.Media.BUCKET_DISPLAY_NAME);\n while (cursor.moveToNext()) {\n absolutePathOfImage = cursor.getString(column_index_data);\n\n listOfAllImages.add(absolutePathOfImage);\n }\n return listOfAllImages;\n }", "private void openGallery(String videoOrImage) {\n if (checkSelfPermission()) {\n if (videoImageRef.equals(\"video\")) {\n videoImageRef = \"\";\n Intent intent;\n if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {\n intent = new Intent(Intent.ACTION_PICK, MediaStore.Video.Media.EXTERNAL_CONTENT_URI);\n } else {\n intent = new Intent(Intent.ACTION_PICK, MediaStore.Video.Media.INTERNAL_CONTENT_URI);\n }\n // In this example we will set the type to video\n intent.setType(\"video/*\");\n intent.setAction(Intent.ACTION_GET_CONTENT);\n intent.putExtra(\"return-data\", true);\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {\n intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);\n }\n intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);\n activityResultLauncher.launch(intent);\n }else{\n videoImageRef = \"\";\n Intent intent;\n if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {\n intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);\n } else {\n intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);\n }\n // In this example we will set the type to video\n intent.setType(\"image/*\");\n intent.setAction(Intent.ACTION_GET_CONTENT);\n intent.putExtra(\"return-data\", true);\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {\n intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);\n }\n intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);\n activityResultLauncher.launch(intent);\n }\n }\n }", "public String[] getGallery() {\n return gallery;\n }", "private ArrayList<String> getImagesPathList() {\n String MEDIA_IMAGES_PATH = \"CuraContents/images\";\n File fileImages = new File(Environment.getExternalStorageDirectory(), MEDIA_IMAGES_PATH);\n if (fileImages.isDirectory()) {\n File[] listImagesFile = fileImages.listFiles();\n ArrayList<String> imageFilesPathList = new ArrayList<>();\n for (File file1 : listImagesFile) {\n imageFilesPathList.add(file1.getAbsolutePath());\n }\n return imageFilesPathList;\n }\n return null;\n }", "private Uri getOutputMediaFileUri(int mediaType) {\n //parvo triabva da se proveri dali ima external storage\n\n if (isExternalStorageAvailable()) {\n\n //sled tova vrashtame directoriata za pictures ili ia sazdavame\n //1.Get external storage directory\n String appName = SendMessage.this.getString(R.string.app_name);\n String environmentDirectory; //\n //ako snimame picture zapismave v papkata za kartiniki, ako ne v papkata za Movies\n\n if(mediaType == MEDIA_TYPE_IMAGE) {\n environmentDirectory = Environment.DIRECTORY_PICTURES;\n } else {\n environmentDirectory = Environment.DIRECTORY_MOVIES;\n }\n File mediaStorageDirectory = new File(\n Environment.getExternalStoragePublicDirectory(environmentDirectory),\n appName);\n\n //2.Create subdirectory if it does not exist\n if (! mediaStorageDirectory.exists()) {\n if (!mediaStorageDirectory.mkdirs()) {\n Log.e(TAG, \"failed to create directory\");\n return null;\n }\n }\n\n //3.Create file name\n String timeStamp = new SimpleDateFormat(\"yyyyMMdd_HHmmss\").format(new Date());\n File mediaFile;\n if (mediaType == MEDIA_TYPE_IMAGE) {\n mediaFile = new File(mediaStorageDirectory.getPath() + File.separator +\n \"IMG_\" + timeStamp + \".jpg\");\n } else if (mediaType == MEDIA_TYPE_VIDEO) {\n mediaFile = new File(mediaStorageDirectory.getPath() + File.separator +\n \"MOV_\" + timeStamp + \".mp4\");\n } else {\n return null;\n }\n //4.Return the file's URI\n Log.d(TAG, \"File path: \" + Uri.fromFile(mediaFile));\n return Uri.fromFile(mediaFile);\n\n } else //ako niama external storage\n Log.d(\"Vic\",\"no external strogage, mediaUri si null\");\n return null;\n\n }", "private void getPhotos(){\n Boolean isSDPresent = android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);\n if(isSDPresent)\n new GetAllImagesAsync().execute(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);\n else\n Toast.makeText(this,\"There is no external storage present\", Toast.LENGTH_SHORT).show();\n }", "public void getPhoto() {\n Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);\n\n //for startActivityForResult, the second parameter, requestCode is used to identify this particular intent\n startActivityForResult(intent, 1);\n }", "public void onImageGalleryClicked(View v){\n //invoke the image gallery using an implicit intent\n Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);\n\n //decides where to store pictures\n File pictureDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);\n String pictureDirectoryPath = pictureDirectory.getPath();\n\n //gets URI representation\n Uri data = Uri.parse(pictureDirectoryPath);\n\n //sets the data and type of media to look for\n photoPickerIntent.setDataAndType(data,\"image/*\");\n startActivityForResult(photoPickerIntent, Image_Gallery_Request);\n }", "public void cargarGaleriaImgs(View view) {\n//Comprobamos el estado de la memoria externa (tarjeta SD)\n String estado = Environment.getExternalStorageState();\n//indica que la memoria externa está disponible y podemos tanto leer como escribir en ella.\n if (estado.equals(Environment.MEDIA_MOUNTED))\n {\n System.out.println(\"Podemos leer y escribir\");\n sdDisponible = true;\n sdAccesoEscritura = true;\n crearIntentGallery();\n }\n else if (estado.equals(Environment.MEDIA_MOUNTED_READ_ONLY))\n {\n System.out.println(\"Podemos SOLO leer\");\n sdDisponible = true;\n sdAccesoEscritura = false;\n }\n else\n {\n System.out.println(\"No Podemos hacer nada\");\n sdDisponible = false;\n sdAccesoEscritura = false;\n }\n }", "public void invokeSelectPhotosAction() {\n\t\tfinal File root = new File(Environment.getExternalStorageDirectory()\n\t\t\t\t+ File.separator + PgrsConstants.DIRECTORY_CAMERA_IMAGE\n\t\t\t\t+ File.separator);\n\t\troot.mkdirs();\n\t\tfinal String fname = PgrsHelper.getInstance()\n\t\t\t\t.getUniqueImageFilename();\n\t\tfinal File sdImageMainDirectory = new File(root, fname);\n\t\toutputFileUri = Uri.fromFile(sdImageMainDirectory);\n\n\t\t// Camera.\n\t\tfinal List<Intent> cameraIntents = new ArrayList<Intent>();\n\t\tfinal Intent captureIntent = new Intent(\n\t\t\t\tandroid.provider.MediaStore.ACTION_IMAGE_CAPTURE);\n\t\tfinal PackageManager packageManager = getPackageManager();\n\t\tfinal List<ResolveInfo> listCam = packageManager.queryIntentActivities(\n\t\t\t\tcaptureIntent, 0);\n\t\tfor (ResolveInfo res : listCam) {\n\t\t\tfinal String packageName = res.activityInfo.packageName;\n\t\t\tfinal Intent intent = new Intent(captureIntent);\n\t\t\tintent.setComponent(new ComponentName(res.activityInfo.packageName,\n\t\t\t\t\tres.activityInfo.name));\n\t\t\tintent.setPackage(packageName);\n\t\t\tintent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);\n\t\t\tcameraIntents.add(intent);\n\t\t}\n\n\t\t// Filesystem.\n\t\tIntent galleryIntent = null;\n\t\tif (Build.VERSION.SDK_INT < 19) {\n\t\t\tgalleryIntent = new Intent();\n\t\t\tgalleryIntent.setType(\"image/*\");\n\t\t\tgalleryIntent.setAction(Intent.ACTION_GET_CONTENT);\n\n\t\t} else {\n\n\t\t\tgalleryIntent = new Intent(\n\t\t\t\t\tIntent.ACTION_PICK,\n\t\t\t\t\tandroid.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);\n\t\t}\n\n\t\t// Set Common Flags to Gallery Intent\n\t\tif (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {\n\t\t\tgalleryIntent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);\n\t\t}\n\t\tgalleryIntent.putExtra(Intent.CATEGORY_OPENABLE, true);\n\n\t\t// Chooser of filesystem options.\n\t\tfinal Intent chooserIntent = Intent.createChooser(galleryIntent,\n\t\t\t\tPgrsConstants.INTENT_TITLE_PICK_PHOTOS);\n\n\t\t// Add the camera options.\n\t\tchooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,\n\t\t\t\tcameraIntents.toArray(new Parcelable[] {}));\n\n\t\tstartActivityForResult(chooserIntent,\n\t\t\t\tPgrsConstants.REQUEST_CODE_PICK_PICTURES_FOR_COMPLAINTS);\n\t}", "String getMedia();", "private Uri getOutputMediaFileUri(int mediaType) {\n\t\t\tFile mediaStorageDir = null;\n\t\t\tif(isExternalStorageAvailable()) {\n\t\t\t\tmediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(\n\t\t\t Environment.DIRECTORY_PICTURES), \"SChat\");\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmediaStorageDir = new File(Environment.DIRECTORY_DCIM);\n\t\t\t\t//Toast.makeText(MainActivity.this, mediaStorageDir.getParent()+\"\", Toast.LENGTH_LONG).show();\n\t\t\t}\n\t\t\t if (! mediaStorageDir.exists()){\n\t\t\t if (! mediaStorageDir.mkdirs()){\n\t\t\t Log.d(\"MyCameraApp\", \"failed to create directory\");\n\t\t\t return null;\n\t\t\t }\n\t\t\t }\n\t\t\t\n\t\t\t String timeStamp = new SimpleDateFormat(\"yyyyMMdd_HHmmss\").format(new Date());\n\t\t\t File mediaFile;\n\t\t\t if (mediaType == MEDIA_TYPE_IMAGE){\n\t\t\t mediaFile = new File(mediaStorageDir.getPath() + File.separator +\n\t\t\t \"IMG_\"+ timeStamp + \".jpg\");\n\t\t\t Log.d(\"MyCameraApp\", mediaFile.toString());\n\t\t\t } else if(mediaType == MEDIA_TYPE_VIDEO) {\n\t\t\t mediaFile = new File(mediaStorageDir.getPath() + File.separator +\n\t\t\t \"VID_\"+ timeStamp + \".mp4\");\n\t\t\t } else {\n\t\t\t return null;\n\t\t\t }\n\t\t\t return Uri.fromFile(mediaFile);\n\t\t}", "public void openGallery(){\n Intent intentImg=new Intent(Intent.ACTION_GET_CONTENT);\n intentImg.setType(\"image/*\");\n startActivityForResult(intentImg,200);\n }", "public void onActivityResult(int requestCode, int resultCode, Intent data) {\n super.onActivityResult(requestCode, resultCode, data);\n if (resultCode == -1 && requestCode == 1) {\n final Uri imageUri = data.getData();\n InputStream imageStream = null;\n try {\n imageStream = getContentResolver().openInputStream(imageUri);\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n final Bitmap selectedImage = BitmapFactory.decodeStream(imageStream);\n Cursor cursor = getContentResolver().query(imageUri, null, null, null, null);\n /*\n * Get the column indexes of the data in the Cursor,\n * move to the first row in the Cursor, get the data,\n * and display it.\n */\n int nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);\n int column_index = cursor.getColumnIndex(MediaStore.Images.Media.DATA);\n cursor.moveToFirst();\n Log.d(\"test\", cursor.getString(nameIndex));\n// Log.d(\"test\", getRealPathFromURI(imageUri));\n // try {\n// String[] proj = { MediaStore.Images.Media.DATA };\n// cursor = getContentResolver().query(imageUri, proj, null, null, null);\n// int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);\n// cursor.moveToFirst();\n// Log.d(\"test\", cursor.getString(column_index) + \"\");\n// } finally {\n// if (cursor != null) {\n// cursor.close();\n// }\n// }\n this.selectedImage = cursor.getString(nameIndex);\n this.currentImageVew.setImageBitmap(selectedImage);\n this.currentImageVew.setContentDescription(imageUri.getPath());\n // CALL THIS METHOD TO GET THE URI FROM THE BITMAP\n Uri tempUri = getImageUri(getApplicationContext(), selectedImage);\n\n // CALL THIS METHOD TO GET THE ACTUAL PATH\n File finalFile = new File(getRealPathFromURI(tempUri));\n\n System.out.println(finalFile.getAbsoluteFile());\n System.out.println(finalFile.getName());\n try {\n System.out.println(finalFile.getCanonicalPath());\n } catch (IOException e) {\n e.printStackTrace();\n }\n this.currentImageVew.setContentDescription(finalFile.getPath());\n this.currentImageVew.setTag(\"0\");\n\n Log.d(\"test\", \"selectedImage \" + selectedImage);\n Log.d(\"test\", \"imageUri.getPath() \" + imageUri.getPath());\n\n }\n }", "private void galleryIntent() {\n Intent intent = new Intent();\n intent.setType(\"image/*\");\n intent.setAction(Intent.ACTION_GET_CONTENT);//\n startActivityForResult(Intent.createChooser(intent, \"Select Photo\"), SELECT_PHOTO);\n }", "public static ArrayList<File> getPhotoAndVideoFromSdCard(ArrayList<File> mAlFiles, File dir) {\n File mFileList[] = dir.listFiles();\n if (mFileList != null && mFileList.length > 0) {\n for (int i = 0; i < mFileList.length; i++) {\n if (mFileList[i].isDirectory() & !mFileList[i].isHidden()) {\n // Add folder if need\n if (!mAlFiles.contains(mFileList[i]))\n mAlFiles.add(mFileList[i]);\n\n // Should skip folder Android before add new files\n getPhotoAndVideoFromSdCard(mAlFiles, mFileList[i]);\n } else if (mFileList[i].isFile() & !mFileList[i].isHidden()) {\n\n /**\n * Check to put only photo, video files to show in Custom Gallery\n */\n if (mFileList[i].getName().toLowerCase().endsWith(Extension.JPEG)\n | mFileList[i].getName().toLowerCase().endsWith(Extension.JPG)\n | mFileList[i].getName().toLowerCase().endsWith(Extension.PNG)\n | mFileList[i].getName().toLowerCase().endsWith(Extension.MP4)) {\n mAlFiles.add(mFileList[i]);\n }\n }\n }\n }\n return mAlFiles;\n }", "private void galleryAddPic() {\n Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);\n mediaScanIntent.setData(currentImageUri);\n this.sendBroadcast(mediaScanIntent);\n }", "private void galleryIntent()\r\n {\r\nIntent gallery=new Intent();\r\ngallery.setType(\"image/*\");\r\ngallery.setAction(Intent.ACTION_GET_CONTENT);\r\n\r\nstartActivityForResult(Intent.createChooser(gallery,\"Select Picture \"),PICK_IMAGE );\r\n }", "public void opengallery() {\n Intent gallery = new Intent();\n gallery.setType(\"image/*\");\n gallery.setAction(Intent.ACTION_GET_CONTENT);\n startActivityForResult(getIntent().createChooser(gallery, \"Choose image\"), PICK_IMAGE);\n\n }", "public void gallery(View view) {\n Intent intent = new Intent();\n intent.setType(\"image/*\");\n intent.setAction(Intent.ACTION_GET_CONTENT);\n startActivityForResult(Intent.createChooser(intent, \"Select Picture\"), REQUEST_IMAGE_GALLERY);\n\n\n }", "public Intent select() {\n final Activity activity = (Activity)getContext();\n try {\n\n final List<Intent> cameraIntents = new ArrayList<>();\n final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);\n final PackageManager packageManager = activity.getPackageManager();\n final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);\n for (ResolveInfo res : listCam) {\n final String packageName = res.activityInfo.packageName;\n final Intent intent = new Intent(captureIntent);\n intent.setPackage(packageName);\n cameraIntents.add(intent);\n }\n Intent galleryIntent;\n\n if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {\n galleryIntent = new Intent();\n galleryIntent.setAction(Intent.ACTION_GET_CONTENT);\n } else {\n galleryIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT);\n galleryIntent.addCategory(Intent.CATEGORY_OPENABLE);\n }\n galleryIntent.setType(\"image/*\");\n\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {\n galleryIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);\n }\n\n final Intent chooserIntent = Intent.createChooser(galleryIntent, \"Select Source\");\n chooserIntent.putExtra(\n Intent.EXTRA_INITIAL_INTENTS,\n cameraIntents.toArray(new Parcelable[]{}));\n\n return chooserIntent;\n } catch (Exception e) {\n Toast.makeText(\n getContext(),\n getResources().getString(R.string.unknown_error),\n Toast.LENGTH_SHORT\n ).show();\n Log.e(getResources().getString(R.string.app_name), \"exception\", e);\n }\n return null;\n }", "private void openGallery() {\n\n Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT);\n galleryIntent.setType(\"image/*\");\n startActivityForResult(galleryIntent, REQUESCODE);\n }", "private void invokeGetPhoto() {\n // invoke the image gallery using an implicit intent.\n Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);\n // Show only images, no videos or anything else\n photoPickerIntent.setType(\"image/*\");\n photoPickerIntent.setAction(Intent.ACTION_GET_CONTENT);\n // Always show the chooser (if there are multiple options available)\n startActivityForResult(Intent.createChooser(photoPickerIntent, \"Choose a picture\"), REQUEST_IMAGE_CAPTURE);\n }", "@SuppressLint(\"Recycle\")\n private synchronized ArrayList<String> retriveSavedImages(Context activity) {\n Uri uri;\n Cursor cursor;\n int column_index_data, column_index_folder_name, column_index_file_name;\n ArrayList<String> listOfAllImages = new ArrayList<>();\n uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;\n String[] projection = {MediaStore.MediaColumns.DATA,\n MediaStore.Images.Media.BUCKET_DISPLAY_NAME,\n MediaStore.MediaColumns.DISPLAY_NAME};\n\n cursor = activity.getApplicationContext().getContentResolver().query(uri, projection, null,\n null, MediaStore.Images.Media.DATE_ADDED);//\n\n assert cursor != null;\n column_index_data = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);\n column_index_folder_name = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.BUCKET_DISPLAY_NAME);\n column_index_file_name = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DISPLAY_NAME);\n\n while (cursor.moveToNext()) {\n\n /*Images from CustomCalender folder only*/\n if (cursor.getString(column_index_folder_name).contains(\"CustomCalender\")) {\n listOfAllImages.add(cursor.getString(column_index_data));\n// Log.v(\"Images: \", cursor.getString(column_index_file_name));\n }\n }\n\n /*Testing Glide cache by making duplicates total 768 images*/\n /*listOfAllImages.addAll(listOfAllImages); //24\n listOfAllImages.addAll(listOfAllImages); //48\n listOfAllImages.addAll(listOfAllImages); //96\n listOfAllImages.addAll(listOfAllImages); //192\n listOfAllImages.addAll(listOfAllImages); //384\n listOfAllImages.addAll(listOfAllImages); //768*/\n\n return listOfAllImages;\n }", "private void openGallery() {\n\n Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT);\n galleryIntent.setType(\"image/*\");\n startActivityForResult(galleryIntent, REQUESCODE);\n }", "private void readFileList(String mediaType){\n Log.v(TAG,\"Context = \" + mContext);\n Uri uri = null;\n if(mediaType.equals(IMAGE)) {\n uri = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;\n }\n else if(mediaType.equals(VIDEO)){\n uri = android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI;\n }\n\n if(uri == null){\n Log.v(TAG, \"ERROR: Media type error\");\n return;\n }\n else {\n String[] projection = {MediaStore.MediaColumns._ID, MediaStore.MediaColumns.DATA\n , MediaStore.MediaColumns.DISPLAY_NAME, MediaStore.MediaColumns.SIZE};\n\n Cursor cursor = mContext.getContentResolver().query(uri, projection, null, null, null);\n while (cursor != null && cursor.moveToNext()) {\n int column_index_data = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);\n String data = cursor.getString(column_index_data);\n int column_index_id = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns._ID);\n int fileId = cursor.getInt(column_index_id);\n String displayName = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DISPLAY_NAME));\n long fileSize = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.SIZE));\n\n //Get information of files in friendsCameraSample folder\n if (data.contains(\"friendsCameraSample\")) {\n HashMap<String, String> info = new HashMap<>();\n info.put(OSCParameterNameMapper.FileInfo.NAME, displayName);\n info.put(OSCParameterNameMapper.FileInfo.URL, data);\n info.put(OSCParameterNameMapper.FileInfo.SIZE, String.valueOf(fileSize));\n adapter.addItem(info, fileId);\n adapter.notifyDataSetChanged();\n }\n }\n }\n }", "public void OpenGallery(){\n Intent gallery = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);\n startActivityForResult(gallery, PICK_IMAGE);\n }", "private void openImageIntent() {\n\t\tfinal File root = new File(Environment.getExternalStorageDirectory()\n\t\t\t\t+ File.separator + \"MyDir\" + File.separator);\n\t\troot.mkdirs();\n\n\t\tfinal File sdImageMainDirectory = new File(root, getUniquePhotoName());\n\t\toutputFileUri = Uri.fromFile(sdImageMainDirectory);\n\n\t\t// Camera.\n\t\tfinal List<Intent> cameraIntents = new ArrayList<Intent>();\n\t\tfinal Intent captureIntent = new Intent(\n\t\t\t\tandroid.provider.MediaStore.ACTION_IMAGE_CAPTURE);\n\t\tfinal PackageManager packageManager = source.getPackageManager();\n\t\tfinal List<ResolveInfo> listCam = packageManager.queryIntentActivities(\n\t\t\t\tcaptureIntent, 0);\n\t\tfor (ResolveInfo res : listCam) {\n\t\t\tfinal String packageName = res.activityInfo.packageName;\n\t\t\tfinal Intent intent = new Intent(captureIntent);\n\t\t\tintent.setComponent(new ComponentName(res.activityInfo.packageName,\n\t\t\t\t\tres.activityInfo.name));\n\t\t\tintent.setPackage(packageName);\n\t\t\tintent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);\n\t\t\tcameraIntents.add(intent);\n\t\t}\n\n\t\t// Filesystem.\n\t\tfinal Intent galleryIntent = new Intent();\n\t\tgalleryIntent.setType(\"*/*\");\n\t\tgalleryIntent.setAction(Intent.ACTION_GET_CONTENT);\n\n\t\t// Chooser of filesystem options.\n\t\tIntent chooserIntent = Intent.createChooser(galleryIntent, \"Select Source\");\n\n\t\t// Add the camera options.\n\t\t//chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,\n\t\t//\t\tcameraIntents.toArray(new Parcelable[] {}));\n\t\t\n\t\tIntent getContentIntent = FileUtils.createGetContentIntent();\n\n\t chooserIntent = Intent.createChooser(getContentIntent, \"Select a file\");\n\n\t\tsource.startActivityForResult(chooserIntent, Constants.QUIZSHOW_DATA);\n\t\t\n\t}", "public Uri getImageFromCamera() {\n String[] projection = {\n MediaStore.Images.Thumbnails._ID, // The columns we want\n MediaStore.Images.Thumbnails.IMAGE_ID,\n MediaStore.Images.Thumbnails.KIND,\n MediaStore.Images.Thumbnails.DATA};\n String selection = MediaStore.Images.Thumbnails.KIND + \"=\" + // Select only mini's\n MediaStore.Images.Thumbnails.MINI_KIND;\n\n String sort = MediaStore.Images.Thumbnails._ID + \" DESC\";\n\n//At the moment, this is a bit of a hack, as I'm returning ALL images, and just taking the latest one. There is a better way to narrow this down I think with a WHERE clause which is currently the selection variable\n Cursor myCursor = getActivity().managedQuery(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, projection, selection, null, sort);\n\n long imageId = 0l;\n long thumbnailImageId = 0l;\n String thumbnailPath = \"\";\n\n try {\n myCursor.moveToFirst();\n imageId = myCursor.getLong(myCursor.getColumnIndexOrThrow(MediaStore.Images.Thumbnails.IMAGE_ID));\n thumbnailImageId = myCursor.getLong(myCursor.getColumnIndexOrThrow(MediaStore.Images.Thumbnails._ID));\n thumbnailPath = myCursor.getString(myCursor.getColumnIndexOrThrow(MediaStore.Images.Thumbnails.DATA));\n } finally {\n myCursor.close();\n }\n\n //Create new Cursor to obtain the file Path for the large image\n\n String[] largeFileProjection = {\n MediaStore.Images.ImageColumns._ID,\n MediaStore.Images.ImageColumns.DATA\n };\n\n String largeFileSort = MediaStore.Images.ImageColumns._ID + \" DESC\";\n myCursor = getActivity().managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, largeFileProjection, null, null, largeFileSort);\n String largeImagePath = \"\";\n\n try {\n myCursor.moveToFirst();\n\n//This will actually give yo uthe file path location of the image.\n largeImagePath = myCursor.getString(myCursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.DATA));\n } finally {\n myCursor.close();\n }\n // These are the two URI's you'll be interested in. They give you a handle to the actual images\n Uri uriLargeImage = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, String.valueOf(imageId));\n Uri uriThumbnailImage = Uri.withAppendedPath(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, String.valueOf(thumbnailImageId));\n\n// I've left out the remaining code, as all I do is assign the URI's to my own objects anyways...\n return uriLargeImage;\n }", "public static String getRealPathFromURI(Context context, Uri contentUri) {\n// Log.i(\"\", \"getRealPathFromURI \" + (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT));\n\n// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {\n// // Will return \"image:x*\"\n// String wholeID = DocumentsContract.getDocumentId(contentUri);\n//\n// // Split at colon, use second item in the array\n// String id = wholeID.split(\":\")[1];\n//\n// String[] column = {MediaStore.Images.Media.DATA};\n//\n// // where id is equal to\n// String sel = MediaStore.Images.Media._ID + \"=?\";\n//\n// Cursor cursor = context.getContentResolver().\n// query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,\n// column, sel, new String[]{id}, null);\n//\n// String filePath = \"\";\n//\n// int columnIndex = cursor.getColumnIndex(column[0]);\n//\n// if (cursor.moveToFirst()) {\n// filePath = cursor.getString(columnIndex);\n//\n// return filePath;\n// }\n//\n// cursor.close();\n//\n// return null;\n// } else {\n Cursor cursor = null;\n try {\n String[] proj = {MediaColumns.DATA};\n cursor = context.getContentResolver().query(contentUri, proj, null,\n null, null);\n\n if (cursor != null) {\n int column_index = cursor.getColumnIndexOrThrow(MediaColumns.DATA);\n cursor.moveToFirst();\n return cursor.getString(column_index);\n } else\n return null;\n } finally {\n if (cursor != null) {\n cursor.close();\n }\n }\n// }\n }", "private void showGalleryChooser() {\n Intent intent = new Intent();\n intent.setType(\"image/*\");\n intent.setAction(Intent.ACTION_GET_CONTENT);\n startActivityForResult(Intent.createChooser(intent, \"Select Picture\"), PICK_IMAGE_REQUEST);\n }", "private void dispatchGetPictureFromGalleryIntent() {\n Intent pickPhoto = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);\n if (pickPhoto.resolveActivity(getContext().getPackageManager()) != null) {\n this.startActivityForResult(pickPhoto, PICK_IMAGE);\n }\n }", "private void openGallery(){\n Intent gallery = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);\n startActivityForResult(gallery, PICK_IMAGE);\n }", "public Intent getPickImageChooserIntent() {\n File f = new File(android.os.Environment.getExternalStorageDirectory(), \"temp.jpg\");\n Uri outputFileUri = Uri.fromFile(f);\n List<Intent> allIntents = new ArrayList<>();\n PackageManager packageManager = mContext.getPackageManager();\n\n // collect all camera intents\n Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);\n List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);\n for (ResolveInfo res : listCam) {\n Intent intent = new Intent(captureIntent);\n intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));\n intent.setPackage(res.activityInfo.packageName);\n if (outputFileUri != null) {\n intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);\n }\n allIntents.add(intent);\n }\n\n // collect all gallery intents\n Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);\n galleryIntent.setType(\"image/*\");\n List<ResolveInfo> listGallery = packageManager.queryIntentActivities(galleryIntent, 0);\n for (ResolveInfo res : listGallery) {\n Intent intent = new Intent(galleryIntent);\n intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));\n intent.setPackage(res.activityInfo.packageName);\n allIntents.add(intent);\n }\n\n // the main intent is the last in the list (fucking android) so pickup the useless one\n Intent mainIntent = allIntents.get(allIntents.size() - 1);\n for (Intent intent : allIntents) {\n if (intent.getComponent().getClassName().equals(\"com.android.documentsui.DocumentsActivity\")) {\n mainIntent = intent;\n break;\n }\n }\n allIntents.remove(mainIntent);\n\n // Create a chooser from the main intent\n Intent chooserIntent = Intent.createChooser(mainIntent, \"Select source\");\n\n // Add all other intents\n chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, allIntents.toArray(new Parcelable[allIntents.size()]));\n\n return chooserIntent;\n }", "private static ArrayList<String> getImagesInFileSystem() {\n\t\t// get file list in database\n\t\tArrayList<String> fileNameList = new ArrayList<String>();\n\t\t\n\t\tFile folder = new File(IMAGE_DIRECTORY);\n\t File[] listOfFiles = folder.listFiles();\n\t \n\t for (File currFile : listOfFiles) {\n\t if (currFile.isFile() && !currFile.getName().startsWith(\".\")) {\n\t \t fileNameList.add(currFile.getName());\n\t }\n\t }\n\t \n\t return fileNameList;\n\t}", "private static String getOutputMediaFile(){\n\n\t File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(\n\t Environment.DIRECTORY_PICTURES), \"MyCameraApp\");\n\t // This location works best if you want the created images to be shared\n\t // between applications and persist after your app has been uninstalled.\n\n\t // Create the storage directory if it does not exist\n\t if (! mediaStorageDir.exists()){\n\t if (! mediaStorageDir.mkdirs()){\n\t Log.d(\"MyCameraApp\", \"failed to create directory\");\n\t return null;\n\t }\n\t }\n\n\t // Create a media file name\n\t String timeStamp = new SimpleDateFormat(\"yyyyMMdd_HHmmss\", Locale.US).format(new Date());\n\t return new File(mediaStorageDir.getPath() + File.separator + \"VID_\"+ timeStamp + \".mp4\").toString();\n\t}", "public void loadImagefromGallery(View view) {\n Intent galleryIntent = new Intent(Intent.ACTION_PICK,\n android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);\n // Start the Intent\n startActivityForResult(galleryIntent, RESULT_LOAD_IMG);\n\n }", "public abstract String getFotoPath();", "private java.io.File getCapturedFile(com.reactnativecommunity.webview.RNCWebViewModule.MimeType r7) throws java.io.IOException {\n /*\n r6 = this;\n int[] r0 = com.reactnativecommunity.webview.RNCWebViewModule.C27492.f1192xcd6a845b\n int r7 = r7.ordinal()\n r7 = r0[r7]\n r0 = 1\n java.lang.String r1 = \"\"\n if (r7 == r0) goto L_0x001a\n r0 = 2\n if (r7 == r0) goto L_0x0013\n r7 = r1\n r0 = r7\n goto L_0x0023\n L_0x0013:\n java.lang.String r1 = android.os.Environment.DIRECTORY_MOVIES\n java.lang.String r7 = \"video-\"\n java.lang.String r0 = \".mp4\"\n goto L_0x0020\n L_0x001a:\n java.lang.String r1 = android.os.Environment.DIRECTORY_PICTURES\n java.lang.String r7 = \"image-\"\n java.lang.String r0 = \".jpg\"\n L_0x0020:\n r5 = r1\n r1 = r7\n r7 = r5\n L_0x0023:\n java.lang.StringBuilder r2 = new java.lang.StringBuilder\n r2.<init>()\n r2.append(r1)\n long r3 = java.lang.System.currentTimeMillis()\n java.lang.String r3 = java.lang.String.valueOf(r3)\n r2.append(r3)\n r2.append(r0)\n java.lang.String r2 = r2.toString()\n int r3 = android.os.Build.VERSION.SDK_INT\n r4 = 23\n if (r3 >= r4) goto L_0x004d\n java.io.File r7 = android.os.Environment.getExternalStoragePublicDirectory(r7)\n java.io.File r0 = new java.io.File\n r0.<init>(r7, r2)\n goto L_0x005a\n L_0x004d:\n com.facebook.react.bridge.ReactApplicationContext r7 = r6.getReactApplicationContext()\n r2 = 0\n java.io.File r7 = r7.getExternalFilesDir(r2)\n java.io.File r0 = java.io.File.createTempFile(r1, r0, r7)\n L_0x005a:\n return r0\n */\n throw new UnsupportedOperationException(\"Method not decompiled: com.reactnativecommunity.webview.RNCWebViewModule.getCapturedFile(com.reactnativecommunity.webview.RNCWebViewModule$MimeType):java.io.File\");\n }", "java.lang.String getPictureUri();", "@Override\n\tpublic List<URL> getPhotos() {\n\t\timages.clear(); //vide la liste des images\n\t\t\n\t\t\n\t\tList<URL> allImagesURL = new ArrayList<URL>();\n\t\t\n\t\t/* On initialise la liste de toutes les images */\n\t\tList<String> filelocations = null;\n\t\t\n\t\t/*Nous allons retrouver les fichiers images présent dans le répertoire et tous ses sous-répertoires*/\n\t\tPath start = Paths.get(path); //détermine le point de départ \n\t\ttry (Stream<Path> stream = Files.walk(start, Integer.MAX_VALUE)) {\n\t\t filelocations = stream\n\t\t .map(String::valueOf) //transforme les Path en string\n\t\t .filter(filename -> filename.contains(\".jpg\") || filename.contains(\".png\")) //ne prend que les images jpg et png\n\t\t .collect(Collectors.toList());\n\t\t \n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\t\n\t\t\n\t\t/* Pour chaque fichier retrouvé, on essaie de retrouver son chemin absolu pour le stocker dans le allImagesURL */\n\t\tfor (String filelocation : filelocations) {\n\t\t\tString relativeLocation = filelocation.replace(path+\"/\", \"\"); // Pour ne pas partir de src mais de la classe courante\n\t\t\trelativeLocation = relativeLocation.replace(windowspath+\"\\\\\", \"\");\n\t\t\tallImagesURL.add(this.getClass().getResource(relativeLocation)); //on ajoute le chemin absolu dans la liste\n\t\t}\n\t\t\n\t\t\n\t\treturn allImagesURL; //on retourne la liste\n\t}", "@Override\n public void onClick(View v) {\n Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);\n //Where do we want to find the data\n File pictureDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);\n //Get the name of the directory\n String pictureDirectoryPath = pictureDirectory.getPath();\n //Get a URI representation of the Path because this is what android needs to deal with\n Uri data = Uri.parse(pictureDirectoryPath);\n //Set the data (where we want to look for this media) and the type (what media do we want to look for).Get all image types\n photoPickerIntent.setDataAndType(data, \"image/*\");\n //We invoke the image gallery and receive something from it\n if (photoPickerIntent.resolveActivity(getPackageManager()) != null) {\n startActivityForResult(photoPickerIntent, IMAGE_GALLERY_REQUEST);\n }\n\n }", "public Uri getImageFileUri()\n {\n imagePath = new File(Environment.getExternalStoragePublicDirectory(\n Environment.DIRECTORY_PICTURES), \"Tuxuri\");\n Log.d(tag, \"Find \" + imagePath.getAbsolutePath());\n\n\n if (! imagePath.exists())\n {\n if (! imagePath.mkdirs())\n {\n Log.d(\"CameraTestIntent\", \"failed to create directory\");\n return null;\n }else{\n Log.d(tag,\"create new Tux folder\");\n }\n }\n\n // Create an image file name\n String timeStamp = new SimpleDateFormat(\"yyyyMMdd_HHmmss\").format(new Date());\n File image = new File(imagePath,\"TUX_\"+ timeStamp + \".jpg\");\n file = image;\n name = file.getName();\n path = imagePath;\n\n\n if(!image.exists())\n {\n try {\n image.createNewFile();\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n }\n return Uri.fromFile(image);\n }", "private void openGallery() {\n Intent gallery = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);\n startActivityForResult(gallery, REQUEST_IMAGE_SELECT);\n }", "@Override\n protected void onActivityResult(int requestCode, int resultCode, Intent data) {\n if (data != null && data.getData() != null && resultCode == RESULT_OK) {\n ParcelFileDescriptor pfd;\n try {\n ImageView image=(ImageView)findViewById(R.id.imgView);\n pfd = getContentResolver().openFileDescriptor(data.getData(), \"r\");\n FileDescriptor fd = pfd.getFileDescriptor();\n Bitmap img = BitmapFactory.decodeFileDescriptor(fd);\n pfd.close();\n image.setImageBitmap(img); //image represent ImageVIew to display picked image\n\n if (android.os.Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {\n int flags = data.getFlags()&(Intent.FLAG_GRANT_READ_URI_PERMISSION|Intent.FLAG_GRANT_WRITE_URI_PERMISSION);\n Uri u = data.getData();\n getContentResolver().takePersistableUriPermission(u,flags);\n String id = u.getLastPathSegment().split(\":\")[1];\n final String[] imageColumns = {MediaStore.Images.Media.DATA};\n final String imageOrderBy = null;\n Uri u1 =Uri.EMPTY;\n String state = Environment.getExternalStorageState();\n if (!state.equalsIgnoreCase(Environment.MEDIA_MOUNTED))\n u1 = MediaStore.Images.Media.INTERNAL_CONTENT_URI;\n else\n u1 = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;\n Cursor c = managedQuery(u1, imageColumns, MediaStore.Images.Media._ID + \"=\" + id, null, imageOrderBy);\n if (c.moveToFirst()) {\n imgPath = c.getString(c.getColumnIndex(MediaStore.Images.Media.DATA)); //imgPath represents string variable to hold the path of image\n }\n } else {\n Uri imgUri = data.getData();\n Cursor c1 = getContentResolver().query(imgUri, null, null, null, null);\n if (c1 == null) {\n imgPath = imgUri.getPath(); //imgPath represents string variable to hold the path of image\n } else {\n c1.moveToFirst();\n int idx = c1.getColumnIndex(MediaStore.Images.ImageColumns.DATA);\n imgPath = c1.getString(idx); //imgPath represents string variable to hold the path of image\n c1.close();\n }\n }\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n } catch (IOException e) {\n e.printStackTrace();\n }catch(Exception ea)\n {}\n }\n super.onActivityResult(requestCode, resultCode, data);\n }", "public String[] getPictureNames() {\r\n\t\tif(!isReady) prepare();\r\n\t\tif(!isReady) {\r\n\t\t\tLog.e(TAG,\"The system was not ready. No external media\");\r\n\t\t\treturn new String[]{};\r\n\t\t}\r\n\t\tFile[] pictureFiles = directory.listFiles(new AlbumFileFilter());\r\n\t\tString[] pictureFileNames = new String[pictureFiles.length];\r\n\t\tfor(int a=0;a<pictureFiles.length;a++) {\r\n\t\t\tpictureFileNames[a] = pictureFiles[a].getName();\r\n\t\t}\r\n\t\treturn pictureFileNames;\r\n\t}", "public void loadImagefromGallery(View view) {\n Intent galleryIntent = new Intent(Intent.ACTION_PICK,\n MediaStore.Images.Media.EXTERNAL_CONTENT_URI);\n // Start the Intent\n startActivityForResult(galleryIntent, RESULT_LOAD_IMG);\n }", "public static ArrayList<File> getPhotoAndVideoFromSdCard(\n boolean isFolderOrFile, ArrayList<File> mAlFiles, File dir) {\n File mFileList[] = dir.listFiles();\n if (mFileList != null && mFileList.length > 0) {\n for (int i = 0; i < mFileList.length; i++) {\n if (mFileList[i].isDirectory() & !mFileList[i].isHidden()) {\n // Add folder if need\n if (isFolderOrFile & !mAlFiles.contains(mFileList[i]))\n mAlFiles.add(mFileList[i]);\n\n// Log.i(\"\", \"mFileList[i] \" + mFileList[i].getAbsolutePath());\n\n // Should skip folder Android before add new files\n getPhotoAndVideoFromSdCard(true, mAlFiles, mFileList[i]);\n } else if (mFileList[i].isFile() & !mFileList[i].isHidden()) {\n\n /**\n * Check to put only photo, video files to show in Custom Gallery\n */\n if (!isFolderOrFile) {\n// Log.i(\"\", \"getName() \" + mFileList[i].getName());\n\n if (mFileList[i].getName().toLowerCase().endsWith(Extension.JPEG)\n | mFileList[i].getName().toLowerCase().endsWith(Extension.JPG)\n | mFileList[i].getName().toLowerCase().endsWith(Extension.PNG)\n | mFileList[i].getName().toLowerCase().endsWith(Extension.MP4)) {\n mAlFiles.add(mFileList[i]);\n }\n }\n }\n }\n }\n return mAlFiles;\n }", "public Uri onSelectFromGalleryResult(Intent data) {\n\n Bitmap bm = null;\n if (data != null) {\n try {\n bm = MediaStore.Images.Media.getBitmap(context.getContentResolver(), data.getData());\n\n// profileImageUri\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n\n Uri imageUri = getImageUri(context, bm);\n Utils.d(\"debug\", \"PROFILE IMAGE URI 12:\" + getImageUri(context, bm));\n return imageUri;\n }", "private void galleryIntent() {\n Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);\n intent.setType(\"image/*\");\n ((MessageActivity) context).startActivityForResult(Intent.createChooser(intent,\n \"Select Picture\"), SELECT_PICTURE);\n\n }", "public void initImage() {\n if (isInited())\n return;\n //获取大图的游标\n Cursor cursor = context.getContentResolver().query(\n MediaStore.Images.Media.EXTERNAL_CONTENT_URI, // 大图URI\n STORE_IMAGES, // 字段\n null, // No where clause\n null, // No where clause\n MediaStore.Images.Media.DATE_TAKEN + \" DESC\"); //根据时间升序\n Log.e(\"eeeeeeeeeeeeeeeeeee\", \"------cursor:\" + cursor);\n if (cursor == null)\n return;\n while (cursor.moveToNext()) {\n int id = cursor.getInt(0);//大图ID\n String path = cursor.getString(1);//大图路径\n LogTool.setLog(\"大图路径1\", path);\n File file = new File(path);\n //判断大图是否存在\n if (file.exists()) {\n //小图URI\n String thumbUri = getThumbnail(id, path);\n //获取大图URI\n String uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI.buildUpon().\n appendPath(Integer.toString(id)).build().toString();\n LogTool.setLog(\"大图路径2\", uri);\n if (Tools.isEmpty(uri))\n continue;\n if (Tools.isEmpty(thumbUri))\n thumbUri = uri;\n //获取目录名\n String folder = file.getParentFile().getName();\n String appFile = context.getResources().getString(R.string.app_name);\n if (!folder.equals(appFile)) {\n LocalFile localFile = new LocalFile();\n localFile.setPath(path);\n localFile.setOriginalUri(uri);\n localFile.setThumbnailUri(thumbUri);\n int degree = cursor.getInt(2);\n if (degree != 0) {\n degree = degree + 180;\n }\n localFile.setOrientation(360 - degree);\n\n\n paths.add(localFile);\n\n\n //判断文件夹是否已经存在\n if (folders.containsKey(folder)) {\n folders.get(folder).add(localFile);\n } else {\n List<LocalFile> files = new ArrayList<>();\n files.add(localFile);\n folders.put(folder, files);\n }\n }\n }\n }\n folders.put(\"所有图片\", paths);\n cursor.close();\n isRunning = false;\n }", "public static String getPath(Context context, Uri uri) {\n String string;\n boolean bl = Build.VERSION.SDK_INT >= 19;\n if (bl && DocumentsContract.isDocumentUri((Context)context, (Uri)uri)) {\n Uri uri2;\n if (BikinFileActivity.isExternalStorageDocument(uri)) {\n String[] arrstring = DocumentsContract.getDocumentId((Uri)uri).split(\":\");\n boolean bl2 = \"primary\".equalsIgnoreCase(arrstring[0]);\n string = null;\n if (!bl2) return string;\n return (Object)Environment.getExternalStorageDirectory() + \"/\" + arrstring[1];\n }\n if (BikinFileActivity.isDownloadsDocument(uri)) {\n String string2 = DocumentsContract.getDocumentId((Uri)uri);\n return BikinFileActivity.getDataColumn(context, ContentUris.withAppendedId((Uri)Uri.parse((String)\"content://downloads/public_downloads\"), (long)Long.valueOf((String)string2)), null, null);\n }\n boolean bl3 = BikinFileActivity.isMediaDocument(uri);\n string = null;\n if (!bl3) return string;\n String[] arrstring = DocumentsContract.getDocumentId((Uri)uri).split(\":\");\n String string3 = arrstring[0];\n if (\"image\".equals((Object)string3)) {\n uri2 = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;\n } else if (\"video\".equals((Object)string3)) {\n uri2 = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;\n } else {\n boolean bl4 = \"audio\".equals((Object)string3);\n uri2 = null;\n if (bl4) {\n uri2 = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;\n }\n }\n String[] arrstring2 = new String[]{arrstring[1]};\n return BikinFileActivity.getDataColumn(context, uri2, \"_id=?\", arrstring2);\n }\n if (\"content\".equalsIgnoreCase(uri.getScheme())) {\n if (!BikinFileActivity.isGooglePhotosUri(uri)) return BikinFileActivity.getDataColumn(context, uri, null, null);\n return uri.getLastPathSegment();\n }\n boolean bl5 = \"file\".equalsIgnoreCase(uri.getScheme());\n string = null;\n if (!bl5) return string;\n return uri.getPath();\n }", "URI getMediaURI();", "private void fetchCameras() {\n\n mCameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);\n String[] cameraInfo = null;\n try {\n cameraInfo = mCameraManager.getCameraIdList();\n if (cameraInfo != null) {\n if (cameraInfo[0] != null) {\n backCamera = Integer.valueOf(cameraInfo[0]);\n isBackCameraSelected = true;\n imgviewCameraSelect.setTag(\"backCamera\");\n mCameraCharactersticsBack = fetchCameraCharacteristics(backCamera);\n hasBackCamera = true;\n }\n if (cameraInfo[1] != null) {\n frontCamera = Integer.valueOf(cameraInfo[1]);\n mCameraCharactersticsFront = fetchCameraCharacteristics(frontCamera);\n hasFrontCamera = true;\n }\n\n }\n } catch (CameraAccessException e) {\n Log.e(TAG, \"CameraAccessException\" + e.getMessage());\n }\n }", "private File getOutputMediaFile() {\n\t\tFile picDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);\n\n\t\t// get the current time\n//\t\tString timeStamp = new SimpleDateFormat(\"yyyyMMdd_HHmmss\").format(new Date());\n\t\t\n\t\tif(mBackCameraCount < 5){\n\t\t\treturn new File(picDir.getPath() + File.separator + \"backimage_\" + mBackCameraCount + \".jpg\");\n\t\t}else {\n\t\t\treturn new File(picDir.getPath() + File.separator + \"frontimage_\" + mFrontCameraCount + \".jpg\");\n\t\t}\n\t}", "@Override\n public void imageFromGallery() {\n Intent intent = new Intent();\n intent.setType(\"image/*\");\n intent.setAction(Intent.ACTION_GET_CONTENT);\n startActivityForResult(Intent.createChooser(intent, \"Select picture\"), PICK_IMAGE);\n }", "private void openImageIntent() {\n File pictureFolder = Environment.getExternalStoragePublicDirectory(\n Environment.DIRECTORY_PICTURES\n );\n final File root = new File(pictureFolder, \"SkilExImages\");\n// final File root = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), \"MyDir\");\n\n if (!root.exists()) {\n if (!root.mkdirs()) {\n Log.d(TAG, \"Failed to create directory for storing images\");\n return;\n }\n }\n Calendar newCalendar = Calendar.getInstance();\n int month = newCalendar.get(Calendar.MONTH) + 1;\n int day = newCalendar.get(Calendar.DAY_OF_MONTH);\n int year = newCalendar.get(Calendar.YEAR);\n int hours = newCalendar.get(Calendar.HOUR_OF_DAY);\n int minutes = newCalendar.get(Calendar.MINUTE);\n int seconds = newCalendar.get(Calendar.SECOND);\n final String fname = PreferenceStorage.getUserMasterId(this) + \"_\" + day + \"_\" + month + \"_\" + year + \"_\" + hours + \"_\" + minutes + \"_\" + seconds + \".png\";\n final File sdImageMainDirectory = new File(root.getPath() + File.separator + fname);\n destFile = sdImageMainDirectory;\n outputFileUri = Uri.fromFile(sdImageMainDirectory);\n Log.d(TAG, \"camera output Uri\" + outputFileUri);\n\n // Camera.\n file = new File(Environment.getExternalStorageDirectory()\n + \"/\" + IMAGE_DIRECTORY);\n if (!file.exists()) {\n file.mkdirs();\n }\n final List<Intent> cameraIntents = new ArrayList<Intent>();\n final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);\n final PackageManager packageManager = getPackageManager();\n final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);\n for (ResolveInfo res : listCam) {\n final String packageName = res.activityInfo.packageName;\n final Intent intent = new Intent(captureIntent);\n intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));\n intent.setPackage(packageName);\n intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);\n cameraIntents.add(intent);\n }\n\n // Filesystem.\n final Intent galleryIntent = new Intent();\n galleryIntent.setType(\"image/*\");\n galleryIntent.setAction(Intent.ACTION_PICK);\n\n // Chooser of filesystem options.\n final Intent chooserIntent = Intent.createChooser(galleryIntent, \"Select Profile Photo\");\n\n // Add the camera options.\n chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[cameraIntents.size()]));\n\n startActivityForResult(chooserIntent, REQUEST_IMAGE_GET);\n }", "public void cargarimagen(){\n Intent intent= new Intent(Intent.ACTION_GET_CONTENT, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);\n intent.setType(\"image/*\");\n startActivityForResult(intent.createChooser(intent,\"Seleccione la imagen\"),69);\n }", "private void OpenGallery() {\n Intent pickImage = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);\n startActivityForResult(pickImage, RequestCode);\n }", "public void getListaArchivos() {\n\n File rutaAudio = new File(Environment.getExternalStorageDirectory() + \"/RecordedAudio/\");\n File[] archivosAudio = rutaAudio.listFiles();\n\n for (int i = 0; i < archivosAudio.length; i++) {\n File file = archivosAudio[i];\n listadoArchivos.add(new Archivo(file.getName()));\n }\n\n File rutaVideos = new File(Environment.getExternalStorageDirectory() + \"/RecordedVideo/\");\n File[] archivosVideo = rutaVideos.listFiles();\n\n for (int i = 0; i < archivosVideo.length; i++) {\n File file = archivosVideo[i];\n listadoArchivos.add(new Archivo(file.getName()));\n }\n }", "private void openImageIntent() {\n File pictureFolder = Environment.getExternalStoragePublicDirectory(\n Environment.DIRECTORY_PICTURES\n );\n final File root = new File(pictureFolder, \"SkilExImages\");\n// final File root = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), \"MyDir\");\n\n if (!root.exists()) {\n if (!root.mkdirs()) {\n d(TAG, \"Failed to create directory for storing images\");\n return;\n }\n }\n Calendar newCalendar = Calendar.getInstance();\n int month = newCalendar.get(Calendar.MONTH) + 1;\n int day = newCalendar.get(Calendar.DAY_OF_MONTH);\n int year = newCalendar.get(Calendar.YEAR);\n int hours = newCalendar.get(Calendar.HOUR_OF_DAY);\n int minutes = newCalendar.get(Calendar.MINUTE);\n int seconds = newCalendar.get(Calendar.SECOND);\n final String fname = PreferenceStorage.getUserMasterId(this) + \"_\" + day + \"_\" + month + \"_\" + year + \"_\" + hours + \"_\" + minutes + \"_\" + seconds + \".png\";\n final File sdImageMainDirectory = new File(root.getPath() + File.separator + fname);\n destFile = sdImageMainDirectory;\n outputFileUri = Uri.fromFile(sdImageMainDirectory);\n d(TAG, \"camera output Uri\" + outputFileUri);\n\n // Camera.\n file = new File(Environment.getExternalStorageDirectory()\n + \"/\" + IMAGE_DIRECTORY);\n if (!file.exists()) {\n file.mkdirs();\n }\n final List<Intent> cameraIntents = new ArrayList<Intent>();\n final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);\n final PackageManager packageManager = getPackageManager();\n final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);\n for (ResolveInfo res : listCam) {\n final String packageName = res.activityInfo.packageName;\n final Intent intent = new Intent(captureIntent);\n intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));\n intent.setPackage(packageName);\n intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);\n cameraIntents.add(intent);\n }\n\n // Filesystem.\n final Intent galleryIntent = new Intent();\n galleryIntent.setType(\"image/*\");\n galleryIntent.setAction(Intent.ACTION_PICK);\n\n // Chooser of filesystem options.\n final Intent chooserIntent = Intent.createChooser(galleryIntent, \"Select Profile Photo\");\n\n // Add the camera options.\n chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[cameraIntents.size()]));\n\n startActivityForResult(chooserIntent, REQUEST_IMAGE_GET);\n }", "private void pickFromGallery() {\n\n Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);\n intent.addCategory(Intent.CATEGORY_OPENABLE);\n intent.setType(\"*/*\");\n\n intent.setType(\"image/*\");\n\n //We pass an extra array with the accepted mime types. This will ensure only components with these MIME types as targeted.\n String[] mimeTypes = {\"image/jpeg\", \"image/png\",\"image/jpg\"};\n intent.putExtra(Intent.EXTRA_MIME_TYPES,mimeTypes);\n // Launching the Intent\n startActivityForResult(intent,GALLERY_REQUEST_CODE);\n }", "private void selectImagesDeviceSerialNubmer() {\n Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);\n startActivityForResult(galleryIntent, GALLERY_DEVICE_SERIAL_NUMBER);\n }", "public static void pickPhotoFromGallery(Context context) {\n try {\n if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {\n Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);\n ((Activity) context).startActivityForResult(intent, PICK_PHOTO_KITKAT);\n } else {\n Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);\n intent.setType(\"image/*\");\n ((Activity) context).startActivityForResult(intent, PICK_PHOTO);\n }\n } catch (ActivityNotFoundException e) {\n e.printStackTrace();\n }\n }", "private File getOutputMediaFile(){\n File mediaStorageDir = new File(Environment.getExternalStorageDirectory()\n + \"/Android/data/\"\n + getApplicationContext().getPackageName()\n + \"/Captures\");\n\n // This location works best if you want the created images to be shared\n // between applications and persist after your app has been uninstalled.\n\n // Create the storage directory if it does not exist\n if (! mediaStorageDir.exists()){\n if (! mediaStorageDir.mkdirs()){\n return null;\n }\n }\n // Create a media file name\n String timeStamp = new SimpleDateFormat(\"ddMMyyyy_HHmm\").format(new Date());\n File mediaFile;\n String mImageName=\"MI_\"+ timeStamp +\".jpg\";\n mediaFile = new File(mediaStorageDir.getPath() + File.separator + mImageName);\n return mediaFile;\n }", "private void selectImageFromGallery() {\n Intent intent = new Intent();\n intent.setType(\"image/*\");\n intent.setAction(Intent.ACTION_GET_CONTENT);\n startActivityForResult(Intent.createChooser(intent, getString(R.string.select_picture)),\n REQUEST_IMAGE_OPEN);\n }", "public void getImageFromCamera() {\n String capturedPath = \"image_\" + System.currentTimeMillis() + \".jpg\";\n File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath()\n + \"/DCIM\", capturedPath);\n file.getParentFile().mkdirs();\n mCapturedImageUri = Uri.fromFile(file);\n\n Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);\n intent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageUri);\n startActivityForResult(intent, CAPTURE_IMAGE_REQUEST_CODE);\n }", "@Override\n\tpublic void onActivityResult(int requestCode, int resultCode, Intent data) {\n\t\tif (resultCode == Activity.RESULT_OK) {\n\t\t\tif (requestCode == SELECT_PICTURE) {\n\t\t\t\tUri selectedImageUri = data.getData();\n\n\t\t\t\t//OI FILE Manager\n\t\t\t\tfilemanagerstring = selectedImageUri.getPath();\n\n\t\t\t\t//MEDIA GALLERY\n\t\t\t\tselectedImagePath = getPath(selectedImageUri);\n\t\t\t\timg2.setImageURI(selectedImageUri);\n\n\n\t\t\t\t//img.setImageURI(selectedImageUri);\n\n\t\t\t\timagePath.getBytes();\n\n\t\t\t\timagePath=(imagePath.toString());\n\t\t\t\tSystem.out.println(\"MY PATH: \"+imagePath);\n\t\t\t\tBitmap bm = BitmapFactory.decodeFile(imagePath);\n\n\t\t\t}\n\n\t\t}\n\n\t}", "private void pickFromGallery(){\n Intent intent=new Intent(Intent.ACTION_PICK);\n // Sets the type as image/*. This ensures only components of type image are selected\n intent.setType(\"image/*\");\n //We pass an extra array with the accepted mime types. This will ensure only components with these MIME types as targeted.\n String[] mimeTypes = {\"image/jpeg\", \"image/png\"};\n intent.putExtra(Intent.EXTRA_MIME_TYPES,mimeTypes);\n // Launching the Intent\n startActivityForResult(intent,1);\n }", "private void pickFromGallery() {\n Intent intent = new Intent(Intent.ACTION_PICK);\r\n // Sets the type as image/*. This ensures only components of type image are selected\r\n intent.setType(\"image/*\");\r\n //We pass an extra array with the accepted mime types. This will ensure only components with these MIME types as targeted.\r\n String[] mimeTypes = {\"image/jpeg\", \"image/png\"};\r\n intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);\r\n // Launching the Intent\r\n startActivityForResult(intent, 0);\r\n }", "private Uri getPicOutputUri(){\n String filePath = getExternalFilesDir(Environment.DIRECTORY_PICTURES) + File.separator + String.valueOf(System.currentTimeMillis())+\".jpg\";\n return Uri.fromFile(new File(filePath));\n }", "public void importImageFromGallery(){\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat.checkSelfPermission(mActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) {\n mActivity.requestPermissions(new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, NoteConstants.WRITE_EXTERNAL_STORAGE_PERMISSION_REQUESTCODE);\n }\n else {\n Intent pickPhoto = new Intent(Intent.ACTION_PICK,\n android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);\n mActivity.startActivityForResult(pickPhoto, NoteConstants.GALLERY_IMPORT_ACTIVITY_REQUESTCODE);\n }\n }", "private void pickFromGallery(){\n Intent intent=new Intent(Intent.ACTION_PICK);\n // Sets the type as image/*. This ensures only components of type image are selected\n intent.setType(\"image/*\");\n //We pass an extra array with the accepted mime types. This will ensure only components with these MIME types as targeted.\n String[] mimeTypes = {\"image/jpeg\", \"image/png\"};\n intent.putExtra(Intent.EXTRA_MIME_TYPES,mimeTypes);\n // Launching the Intent\n startActivityForResult(intent,GALLERY_REQUEST_CODE);\n }", "private void pickFromGallery(){\n Intent intent=new Intent(Intent.ACTION_PICK);\n // Sets the type as image/*. This ensures only components of type image are selected\n intent.setType(\"image/*\");\n //We pass an extra array with the accepted mime types. This will ensure only components with these MIME types as targeted.\n String[] mimeTypes = {\"image/jpeg\", \"image/png\"};\n intent.putExtra(Intent.EXTRA_MIME_TYPES,mimeTypes);\n // Launching the Intent\n startActivityForResult(intent,GALLERY_REQUEST_CODE);\n }", "private void openImageIntent() {\n final File root = new File(Environment.getExternalStorageDirectory() + File.separator + \"MyDir\" + File.separator);\n root.mkdirs();\n final String fname = UUID.randomUUID().toString();\n final File sdImageMainDirectory = new File(root, fname);\n outputFileUri = Uri.fromFile(sdImageMainDirectory);\n\n // Camera.\n final List<Intent> cameraIntents = new ArrayList<Intent>();\n final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);\n final PackageManager packageManager = getPackageManager();\n final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);\n for(ResolveInfo res : listCam) {\n final String packageName = res.activityInfo.packageName;\n final Intent intent = new Intent(captureIntent);\n intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));\n intent.setPackage(packageName);\n intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);\n cameraIntents.add(intent);\n }\n\n // Filesystem.\n final Intent galleryIntent = new Intent();\n galleryIntent.setType(\"image/*\");\n galleryIntent.setAction(Intent.ACTION_GET_CONTENT);\n\n // Chooser of filesystem options.\n final Intent chooserIntent = Intent.createChooser(galleryIntent, \"Select Source\");\n\n // Add the camera options.\n chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[]{}));\n\n startActivityForResult(chooserIntent, SELECT_PICTURE);\n }", "java.lang.String getImagePath();", "public File[] CreateListFiles() {\n\t\tif (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {\n\t\t\tToast.makeText(this, \"Error! No SDCARD Found!\", Toast.LENGTH_LONG).show();\n\t\t} else {\n\t\t\tfile = new File(Environment.getExternalStorageDirectory(), File.separator + \"/MelanomaPics/\" + File.separator + MelanomaActivity.pacientSelected);\n\t\t\tfile.mkdirs();\n\t\t}\n\t\t// pega todas as imagens do diretorio MelanomaPics e coloca dentro de\n\t\t// uma lista\n\t\tif (file.isDirectory()) {\n\t\t\tlistFile = file.listFiles();\n\t\t}\n\t\treturn listFile;\n\t}", "public List<CameraRecord> loadThumbnail();", "public File getOutputMediaFile(int type){\n // To be safe, you should check that the SDCard is mounted\n // using Environment.getExternalStorageState() before doing this.\n\n File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(\n Environment.DIRECTORY_PICTURES), \"MyCameraApp\");\n // This location works best if you want the created images to be shared\n // between applications and persist after your app has been uninstalled.\n\n // Create the storage directory if it does not exist\n if (! mediaStorageDir.exists()){\n if (! mediaStorageDir.mkdirs()){\n Log.d(\"MyCameraApp\", \"failed to create directory\");\n return null;\n }\n }\n Log.d(\"asda\", mediaStorageDir.getPath());\n // Create a media file name\n String timeStamp = new SimpleDateFormat(\"yyyyMMdd_HHmmss\").format(new Date());\n File mediaFile;\n if (type == MEDIA_TYPE_IMAGE){\n mediaFile = new File(mediaStorageDir.getPath() + File.separator +\n \"IMG_\"+ timeStamp + \".jpg\");\n } else if(type == MEDIA_TYPE_VIDEO) {\n mediaFile = new File(mediaStorageDir.getPath() + File.separator +\n \"VID_\"+ timeStamp + \".mp4\");\n } else {\n return null;\n }\n\n return mediaFile;\n }", "private static File getOutputMediaFile(String namex, Context context) {\n\r\n String pathToExternalStorage = context.getFilesDir().toString();\r\n File mediaStorageDir = new File(pathToExternalStorage + \"/\" + \"eKMIS\");\r\n\r\n //if (!appDirectory.isDirectory() || !appDirectory.exists()) //Checks if the directory exists\r\n // appDirectory.mkdir();\r\n\r\n if (!mediaStorageDir.exists()) {\r\n if (!mediaStorageDir.mkdirs()) {\r\n //Log.d(\"surevy\", \"failed to create directory\");\r\n return null;\r\n }\r\n }\r\n // Create a media file name\r\n String timeStamp = new SimpleDateFormat(\"yyyyMMdd_HHmmss\")\r\n .format(new Date());\r\n File mediaFile;\r\n //mediaFile = new File(mediaStorageDir.getPath() + File.separator\r\n // + \"IMG_\" + timeStamp + \".jpg\");\r\n\r\n mediaFile = new File(mediaStorageDir.getPath() + File.separator\r\n + \"IMG_\" + namex + \".jpg\");\r\n\r\n\r\n Log.d(\"Camera activty\", mediaStorageDir.getPath());\r\n\r\n return mediaFile;\r\n }", "public void toGallery() {\n Log.d(TAG, \"toGallery: \");\n Intent pictureFromGalleryIntent = new Intent(Intent.ACTION_PICK);\n pictureFromGalleryIntent.setType(\"image/*\");\n startActivityForResult(pictureFromGalleryIntent, GALLERY_REQ);\n }", "public static String getPhotoPath(Intent data, Context mContext) {\n Uri selectedImage = data.getData();\n String[] filePathColumn = { MediaStore.Images.Media.DATA };\n Cursor cursor = mContext.getContentResolver().query(selectedImage, filePathColumn, null, null, null);\n cursor.moveToFirst();\n int columnIndex = cursor.getColumnIndex(filePathColumn[0]);\n String mCurrentPhotoPath = cursor.getString(columnIndex);\n cursor.close();\n\n return mCurrentPhotoPath;\n }", "private Bitmap getGalleryBitmap(@Nullable Intent data) {\n String imagePath = getImagePath(data);\n Thread askPermissionThread = ThreadFactory.createAskPermissionThread(this);\n\n askPermissionThread.start();\n\n try {\n askPermissionThread.join();\n } catch (InterruptedException e) {\n e.printStackTrace();\n }\n\n return BitmapFactory.decodeFile(imagePath);\n }", "private File imageFile() throws IOException {\n File directory = Environment.getExternalStorageDirectory();\n\n // FileOperations.checkDirectory(directory, false);\n Photopath = directory.getAbsolutePath();\n return new File(directory,\"displaypic.jpg\");\n\n }", "private Uri getMedia(String mediaName) {\n if (URLUtil.isValidUrl(mediaName)) {\n // Media name is an external URL.\n return Uri.parse(mediaName);\n } else {\n\n // you can also put a video file in raw package and get file from there as shown below\n\n return Uri.parse(\"android.resource://\" + getPackageName() +\n \"/raw/\" + mediaName);\n\n\n }\n }", "private static File getOutputMediaFile(){\r\n File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(\r\n Environment.DIRECTORY_PICTURES), \"CameraDemo\");\r\n\r\n if (!mediaStorageDir.exists()){\r\n if (!mediaStorageDir.mkdirs()){\r\n return null;\r\n }\r\n }\r\n\r\n String timeStamp = new SimpleDateFormat(\"yyyyMMdd_HHmmss\").format(new Date());\r\n return new File(mediaStorageDir.getPath() + File.separator +\r\n \"IMG_\"+ timeStamp + \".jpg\");\r\n }", "public String getPath(Uri uri) {\n Cursor cursor = getActivity().getContentResolver().query(uri, null, null, null, null);\n cursor.moveToFirst();\n String document_id = cursor.getString(0);\n document_id = document_id.substring(document_id.lastIndexOf(\":\") + 1);\n cursor.close();\n cursor = getActivity().getContentResolver().query(\n MediaStore.Images.Media.EXTERNAL_CONTENT_URI,\n null, MediaStore.Images.Media._ID + \" = ? \", new String[]{document_id}, null);\n cursor.moveToFirst();\n String path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));\n cursor.close();\n return path;\n }", "public List<String> getimagenames() {\n List<String> arrimg=new ArrayList<String>();\n SQLiteDatabase db = this.getReadableDatabase();\n Cursor cursor = db.rawQuery(\"select * from \" + TABLE_NAME +\" ORDER BY \" + POSITIONNO + \" ASC\" ,null);\n if (cursor.moveToFirst()) {\n while (!cursor.isAfterLast()) {\n String name = cursor.getString(cursor.getColumnIndex(IMGNAME));\n\n arrimg.add(name);\n cursor.moveToNext();\n }\n }\n\n return arrimg;\n }", "public static Uri getPhotoUri() {\n Logger.d(TAG, \"getPhotoUri() entry\");\n Cursor cursor = null;\n int imageId = 0;\n try {\n cursor =\n mContext.getContentResolver().query(\n MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null, null, null, null);\n cursor.moveToFirst();\n imageId = cursor.getInt(cursor.getColumnIndex(MediaStore.Images.ImageColumns._ID));\n } finally {\n if (cursor != null) {\n cursor.close();\n cursor = null;\n }\n }\n Uri photoUri = Uri.parse(PREFER_PHOTO_URI + imageId);\n Logger.d(TAG, \"getPhotoUri() exit with the uri \" + photoUri);\n return photoUri;\n }", "private void pickImageFromGallery() {\n Intent intent = new Intent(Intent.ACTION_PICK);\n intent.setType(\"image/*\");\n startActivityForResult(intent, IMAGE_PICK_CODE);\n\n }", "private String getMediaPathFromUri(final Uri uri) {\n\t\t\tString[] projection = { MediaStore.Images.Media.DATA };\n\t\t\tCursor cursor = managedQuery(uri, projection, null, null, null);\n\t\t\tcursor.moveToFirst();\n\t\t\treturn cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA));\n\t\t}", "private void dispatchGalleryIntent() {\n Intent pickPhoto = new Intent(Intent.ACTION_PICK,\n MediaStore.Images.Media.EXTERNAL_CONTENT_URI);\n pickPhoto.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);\n startActivityForResult(pickPhoto, REQUEST_CHOOSE_PHOTO_NUM);\n }", "String getImagePath();", "String getImagePath();", "private static String getFilesContent() {\n String content = \"\";\n try {\n //cameras.json\n AssetManager am = MarketApplication.getMarketApplication().getAssets();\n InputStream stream = am.open(CAMERAS_FILE_NAME);\n int size = stream.available();\n byte[] buffer = new byte[size];\n stream.read(buffer);\n mJsonCameras = new String(buffer);\n\n //videogames.json\n stream = am.open(VIDEO_GAMES_FILE_NAME);\n size = stream.available();\n buffer = new byte[size];\n stream.read(buffer);\n mJsonVideogames = new String(buffer);\n\n //clothes.json\n stream = am.open(CLOTHES_FILE_NAME);\n size = stream.available();\n buffer = new byte[size];\n stream.read(buffer);\n stream.close();\n mJsonClothesProducts = new String(buffer);\n\n\n } catch (IOException e) {\n Log.e(TAG, \"Couldn't read the file\");\n }\n return content;\n }", "public ArrayList<Group> GetImageStorageMelanoma() {\n\t\tExListViewController selImagens = new ExListViewController();\n\t\treturn selImagens.SelectPicsOnMelanomaDirectory(CreateListFiles());\n\t}" ]
[ "0.72685504", "0.7001072", "0.6978145", "0.68420774", "0.67449653", "0.66172034", "0.6498464", "0.6457198", "0.63861704", "0.63492984", "0.6296857", "0.6284533", "0.6248997", "0.6216437", "0.6200985", "0.6190127", "0.61539626", "0.6101714", "0.607549", "0.6067476", "0.60386205", "0.6034525", "0.5998083", "0.59861845", "0.5985852", "0.59852725", "0.5984755", "0.5907601", "0.58883107", "0.5877846", "0.58738697", "0.5866956", "0.58590955", "0.5842205", "0.5839554", "0.58290863", "0.58224314", "0.58206415", "0.58147013", "0.5808376", "0.58073515", "0.5800259", "0.5799996", "0.5794506", "0.57703197", "0.57700187", "0.5769232", "0.57618845", "0.5752627", "0.5748771", "0.5733388", "0.5727398", "0.572501", "0.57186073", "0.57162154", "0.5696262", "0.56913084", "0.568825", "0.56715167", "0.56688976", "0.56645674", "0.5662005", "0.5660903", "0.5656504", "0.5654269", "0.5651288", "0.5649722", "0.5646697", "0.5639327", "0.5638536", "0.5634097", "0.5633638", "0.5631776", "0.562757", "0.5626267", "0.5613308", "0.5611669", "0.5611669", "0.5600779", "0.55971926", "0.5588886", "0.55860406", "0.55849004", "0.558187", "0.55809057", "0.55779094", "0.5565584", "0.5565064", "0.5563003", "0.55588955", "0.55578834", "0.5544879", "0.5541579", "0.5536695", "0.55362386", "0.5534191", "0.5533706", "0.5533706", "0.5529671", "0.5521256" ]
0.72271436
1
The path to the documents directory.
public static void main(String[] args) throws IOException { String dataDir = Utils.getDataDir(PrimaveraXmlRead.class); readProjectUidsFromXmlFile(dataDir); readLoadPrimaveraXmlProject(dataDir); readProjectUidsFromStream(dataDir); // Display result of conversion. System.out.println("Process completed Successfully"); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public String getDocumentBase() {\n return getServerBase() + getContextPath() + \"/\";\n }", "public String getFileDirectory() {\n String storedDirectory = settings.get(\"fileDirectory\");\n \n // Default to the program files\n if (storedDirectory == null) {\n storedDirectory = System.getenv(\"ProgramFiles\");\n }\n \n return storedDirectory;\n }", "public static Path getWordsDir() {\n\t\treturn Paths.get(prefs.get(Constants.PREF_USERSAVE_DIR, null)).resolve(WORDS_DIR);\n\t}", "public Path getDataDirectory();", "public static String rootDir()\n {\n read_if_needed_();\n \n return _root;\n }", "private String getDicDir() {\n\t\tString wDir = null;\n\n\t\tif (System.getProperties().containsKey(\"root\")) {\n\t\t\twDir = System.getProperty(\"root\");\n\t\t}\n\n\t\tif ((wDir == null || wDir.isEmpty()) && CPlatform.isMacOs())\n\t\t\twDir = new File(CPlatform.getUserHome(), \"Library/Spelling\")\n\t\t\t\t\t.getAbsolutePath();\n\n\t\tif (wDir == null || wDir.isEmpty())\n\t\t\twDir = \"/home/ff/projects/hunspell\";\n\t\treturn wDir;\n\t}", "public String getIndexDirectoryString() {\n File indexDir = this.getIndexDirectory();\n return indexDir != null ? indexDir.getAbsolutePath() : null;\n }", "public String getDir();", "FsPath baseDir();", "public String getPath() {\n\t\treturn this.baseDir.getAbsolutePath();\n\t}", "String getDatabaseDirectoryPath();", "public static String getOutputDir() {\n outputDir = getProperty(\"outputDir\");\n if (outputDir == null) outputDir = \"./\";\n return outputDir;\n }", "String rootPath();", "String getDirectoryPath();", "String getFilepath();", "public String getDirectory() {\n return directoryProperty().get();\n }", "public static Path getTextsDir() {\n\t\treturn Paths.get(prefs.get(Constants.PREF_USERSAVE_DIR, null)).resolve(TEXTS_DIR);\n\t}", "String getDir();", "public String getPath() {\n\t\treturn pfDir.getPath();\n\t}", "public static File getDataDirectory() {\n\t\treturn DATA_DIRECTORY;\n\t}", "public String getDataDirectory() {\n return dataDirectory;\n }", "public String getXLSDirectory() {\n\t\treturn props.getProperty(ARGUMENT_XLS_DIRECTORY);\n\t}", "public static String uploadDir() {\n\n String uploads = stringValue(\"treefs.uploads\");\n if(isNullOrEmpty(uploads)) {\n // default home location\n uploads = home() + File.separator + \"uploads\";\n } else {\n uploads = home() + File.separator + uploads;\n }\n\n System.out.println(\"uploadDir=\" + uploads);\n return uploads;\n }", "Path getBaseInputDir();", "public String getDataDir() {\n\t\treturn dataDir;\n\t}", "public String pathToSave() {\n String path;\n File folder;\n do {\n System.out.print(\"Introduce la ruta en la que quieres guardar el fichero(separando directorios por guiones: directorio1-directorio2-directorio3): \");\n path = Utils.getString();\n path = String.valueOf(System.getProperty(\"user.dir\")).substring(0, 2) + \"\\\\\" + path.replace('-', '\\\\');\n folder = new File(path);\n if (!folder.exists()) {\n System.out.println(\"El directorio introducido no existe intentalo de nuevo...\");\n } else {\n if (!folder.isDirectory()) {\n System.out.println(\"Eso no es un directorio intentalo de nuevo...\");\n }\n }\n } while (!folder.exists() && !folder.isDirectory());\n return path;\n }", "public String getFilepath()\n\t{\n\t\treturn filepath;\n\t}", "public java.lang.String getFilepath()\n {\n return filepath;\n }", "public String getRootPath() {\n return root.getPath();\n }", "public String getPath() {\n\t\treturn file.getPath();\n\t}", "public String path() {\n return filesystem().pathString(path);\n }", "public String getWorkDirectory(){\n String wd = \"\";\n try {\n wd = new File(\"test.txt\").getCanonicalPath().replace(\"/test.txt\",\"\");\n } catch (IOException e) {\n e.printStackTrace();\n }\n return wd;\n }", "public static String getPreferenceDirectory() {\n\t\treturn PREF_DIR;\n\t}", "public String directory () {\n\t\treturn directory;\n\t}", "public String getPath();", "public String getPath();", "public String getPath();", "public String getRootPath() {\r\n return rootPath;\r\n }", "public String workingDirectory() {\n\t\treturn workingDir.getAbsolutePath();\n\t}", "public String inputFileDir() {\n return inputFileDir;\n }", "public String getApplicationPath()\n {\n return getApplicationPath(false);\n }", "public static String downloadDir() {\n\n String downloads = stringValue(\"treefs.downloads\");\n if(isNullOrEmpty(downloads)) {\n // default home location\n downloads = home() + File.separator + \"downloads\";\n } else {\n downloads = home() + File.separator + downloads;\n }\n\n System.out.println(\"downloadDir=\" + downloads);\n return downloads;\n }", "public String getSaveOutputDir() {\n return saveOutputDir;\n }", "@Override\r\n\tpublic String getRootDir() {\t\t\r\n\t\treturn Global.USERROOTDIR;\r\n\t}", "public static Path getUserSaveDir() {\n\t\treturn Paths.get(prefs.get(Constants.PREF_USERSAVE_DIR, null));\n\t}", "public File getRootDir() {\n return rootDir;\n }", "public String get_save_path() {\n\t\treturn _save_path;\n\t}", "public String getFilepath() {\n\t\treturn filepath;\n\t}", "public static File getRootDirectory() {\n\t\treturn ROOT_DIRECTORY;\n\t}", "public String getCurrentPath() {\n\t\treturn DataManager.getCurrentPath();\n\t}", "public static String getCurrentPath() {\n File file = new File(\"\");\n return file.getAbsolutePath();\n }", "String getPath();", "String getPath();", "String getPath();", "String getPath();", "String getPath();", "public String getWorkspacePath() {\n\t\tString workspacePath = userSettingsService.getUserSettings().getWorkspacePath();\n\t\treturn getAbsoluteSubDirectoryPath(workspacePath);\n\t}", "Path getRootPath();", "private String getInitialDirectory() {\n String lastSavedPath = controller.getLastSavePath();\n\n if (lastSavedPath == null) {\n return System.getProperty(Constants.JAVA_USER_HOME);\n }\n\n File lastSavedFile = new File(lastSavedPath);\n\n return lastSavedFile.getAbsoluteFile().getParent();\n }", "public String getIndexDir() { return this.indexDir; }", "public String getDirectoryPath() {\n return EXTERNAL_PATH;\n }", "public String getPathToDefinitionFiles() {\n\treturn msPathToDefinitionFiles;\n }", "public static File getPreferencesDirectory() {\n\t\treturn PREFERENCES_DIRECTORY;\n\t}", "public String outputFileDir() {\n return outputFileDir;\n }", "@Override\n public String getApplicationDirectory() {\n return Comm.getAppHost().getAppLogDirPath();\n }", "public String getOutputPath () \n\t{\n\t\treturn outputPathTextField.getText();\n\t}", "public static File getScriptDirectory() {\n \t\treturn new File(getScriptlerHomeDirectory(), \"scripts\");\n \t}", "String folderPath();", "public String getFilepath() {\n return filepath;\n }", "public String getFilepath() {\n return filepath;\n }", "private String getAbsoluteFilesPath() {\n\n //sdcard/Android/data/cucumber.cukeulator\n //File directory = getTargetContext().getExternalFilesDir(null);\n //return new File(directory,\"reports\").getAbsolutePath();\n return null;\n }", "public File getRootDir() {\r\n\t\treturn rootDir;\r\n\t}", "public static String getDatabaseExportDirectory() {\n\t\tif (xml == null) return \"\";\n\t\treturn databaseExportDir;\n\t}", "private File getDataDir(){\n\t\tFile file = new File(this.configManager.getConfigDirectory() +\n\t\t\t\tFile.separator + \n\t\t\t\tDATA_DIR);\n\t\t\n\t\tif(!file.exists()){\n\t\t\tfile.mkdirs();\n\t\t}\n\t\t\n\t\treturn file;\n\t}", "public File getStoreDir();", "public String getDocumentURI() {\n return this.documentURI;\n }", "public String getPath() {\n return (path == null || path.equals(\"\")) ? \"/\" : path;\n }", "public String getProjectRootDirectory() {\r\n\t\treturn getTextValue(workspaceRootText);\r\n\t}", "public String getDocroot() {\n return docroot;\n }", "public Path outputDir() {\n return dir;\n }", "public String getLocalBasePath() {\n\t\treturn DataManager.getLocalBasePath();\n\t}", "public final String getPath()\n {\n return path;\n }", "public static File getLogDirectory() {\n\t\treturn LOG_DIRECTORY;\n\t}", "public String toPathString() {\n return path();\n }", "public String getCurrentPath() {\n\t\treturn \"\";\n\t}", "public String getDefDir() {\n\n\t\t// String newDefDir = defDir.replaceAll(\"\\\\\\\\\", \"\\\\\\\\\\\\\\\\\");\n\n\t\treturn defDir;\n\n\t}", "private String getDataDirectory() {\n Session session = getSession();\n String dataDirectory;\n try {\n dataDirectory = (String) session.createSQLQuery(DATA_DIRECTORY_QUERY).list().get(0);\n } finally {\n releaseSession(session);\n }\n return dataDirectory;\n }", "public static String getUserDir() {\n return System.getProperty(\"user.dir\");\n }", "public String getFilepath() {\n\t\treturn this.filepath;\n\t}", "private static String getRioHomeDirectory() {\n String rioHome = RioHome.get();\n if(!rioHome.endsWith(File.separator))\n rioHome = rioHome+File.separator;\n return rioHome;\n }", "private String getDataPath()\n {\n Location location = Platform.getInstanceLocation();\n if (location == null) {\n return \"@none\";\n } else {\n return location.getURL().getPath();\n }\n }", "private static String\n\tgetDefaultPrefsDir()\n\t{\n\t\tString homeDir\t= System.getProperty( \"user.home\" );\n\t\tif ( homeDir == null )\n\t\t{\n\t\t\thomeDir\t= \".\";\n\t\t}\n\t\t\n\t\treturn( homeDir );\n\t}", "@Override\r\n\t\tpublic String getDir()\r\n\t\t\t{\n\t\t\t\treturn null;\r\n\t\t\t}", "public static String getDataDir(String path) {\n\t\tFile dir = new File(System.getProperty(\"user.dir\"));\n\t\tif (!(dir.toString().endsWith(\"samples\")))\n\t\t\tdir = dir.getParentFile();\n\t\tdir = new File(dir, \"resources\");\n\t\tdir = new File(dir, path);\n\t\tif (dir.isDirectory() == false)\n\t\t\tdir.mkdir();\n\t\treturn dir.toString();\n\t}", "public static String findCurrentDirectory() {\n\t\tString absolutePath = new File(\"\").getAbsolutePath();\n\t return absolutePath;\n\t}", "public File getDefaultOutputDir() {\n File out = _mkdir(XPreferencesFactory.kDefaultReportsOutputDir.getDir(false));\r\n String dn = NamingConventions.createNiceEnglishDate_for_dirs();\r\n return _mkdir(new File(out, dn));\r\n }", "public static String getBasepath() {\n\t\treturn basepath;\n\t}", "public static String getBasepath() {\n\t\treturn basepath;\n\t}", "public File getDataStoreDir() {\n\t\treturn this.localDataStoreDir;\n\t}", "private File getHomeDirectory() {\n String brunelDir = System.getProperty(\"brunel.home\");\n File home = brunelDir != null ? new File(brunelDir) :\n new File(System.getProperty(\"user.home\"), \"brunel\");\n return ensureWritable(home);\n }", "public static String getPath() { return Objects.requireNonNull(Bukkit.getServer().getPluginManager().getPlugin(\"Catacombs\"))\n .getDataFolder().getAbsolutePath(); }" ]
[ "0.6509751", "0.6431286", "0.6414104", "0.6375497", "0.62918186", "0.6247124", "0.62350005", "0.6228577", "0.62029153", "0.6151866", "0.6135767", "0.6102203", "0.6092187", "0.6092085", "0.60317993", "0.60307044", "0.6001912", "0.5987635", "0.5983709", "0.5972595", "0.59649074", "0.5963893", "0.5942299", "0.59345526", "0.593055", "0.5920037", "0.5914273", "0.590551", "0.5883768", "0.5866325", "0.58518606", "0.5831548", "0.58287203", "0.5819572", "0.5817622", "0.5817622", "0.5817622", "0.58077985", "0.5802076", "0.58003545", "0.579909", "0.5793704", "0.57923776", "0.579169", "0.57841253", "0.57825345", "0.5779593", "0.5778683", "0.57713336", "0.5769745", "0.57668644", "0.57639194", "0.57639194", "0.57639194", "0.57639194", "0.57639194", "0.57590574", "0.5757555", "0.57477605", "0.57450163", "0.5743306", "0.57407475", "0.5738104", "0.573269", "0.571935", "0.57146925", "0.57058907", "0.5704386", "0.5698462", "0.5698462", "0.56979495", "0.56931627", "0.5685827", "0.5684168", "0.5680045", "0.5676382", "0.5667246", "0.56625766", "0.5656495", "0.56406754", "0.5640225", "0.5634668", "0.5633232", "0.56321484", "0.56255925", "0.5622535", "0.56220746", "0.5616641", "0.5612112", "0.5598712", "0.5595477", "0.5595271", "0.5595137", "0.5585866", "0.5578495", "0.557753", "0.55772203", "0.55772203", "0.5575861", "0.55750287", "0.55719465" ]
0.0
-1
Shows how to import a project from a Primavera XML file.
public static void readProjectUidsFromXmlFile(String dataDir) { PrimaveraXmlReader reader = new PrimaveraXmlReader(dataDir + "Primavera.xml"); List<Integer> projectUids = reader.getProjectUids(); for (Integer projectUid : projectUids) { System.out.println("Project UID: " + projectUid); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static void readLoadPrimaveraXmlProject(String dataDir)\n {\n PrimaveraXmlReader reader = new PrimaveraXmlReader(dataDir + \"PrimaveraProject.xml\");\n Project project = reader.loadProject(3882);\n System.out.println(project.getName());\n }", "public void loadTheProject() {\n\t\tProjectHandler.openProject(mFilePath);\n }", "public void loadProject(String arg) throws IOException {\n Project newProject = Project.readProject(arg);\n newProject.setConfiguration(project.getConfiguration());\n project = newProject;\n projectLoadedFromFile = true;\n }", "public static void main(String[] args) throws IOException {\n String dataDir = Utils.getDataDir(PrimaveraXmlRead.class);\n\n readProjectUidsFromXmlFile(dataDir);\n\n readLoadPrimaveraXmlProject(dataDir);\n\n readProjectUidsFromStream(dataDir);\n\n // Display result of conversion.\n System.out.println(\"Process completed Successfully\");\n }", "org.apache.ant.common.model.Project parseXMLBuildFile(java.io.File xmlBuildFile) throws org.apache.ant.common.util.ExecutionException;", "Project createProject();", "Project createProject();", "Project createProject();", "public Project createProjectFromPRJ() {\n\n\t\tSystem.out.println(\"Trying to load prj file with : \" + data_path + \" \" + projectName + \" \" + conceptName + \" \");\n\n\t\tProject project = null;\n\n\t\ttry {\n\n\t\t\tproject = new Project(data_path + projectName);\n\n\t\t\t// Sehr wichtig hier das Warten einzubauen, sonst gibts leere\n\t\t\t// Retrieval Results, weil die Faelle noch nicht geladen sind wenn\n\t\t\t// das\n\t\t\t// Erste Retrieval laueft\n\t\t\twhile (project.isImporting()) {\n\t\t\t\tThread.sleep(1000);\n\t\t\t\tSystem.out.print(\".\");\n\t\t\t}\n\t\t\tSystem.out.print(\"\\n\"); // console pretty print\n\t\t} catch (Exception ex) {\n\n\t\t\tSystem.out.println(\"Error when loading the project\");\n\t\t}\n\t\treturn project;\n\t}", "public SCMLProject load(String xml)\n\t{\n\t\tXmlReader reader = new XmlReader();\n\t\treturn load(reader.parse(xml));\n\t}", "public SCMLProject load(Element root)\n\t{\n\t\tthis.currentProject = new SCMLProject();\n\n\t\tloadAssets(root.getChildrenByName(\"folder\"));\n\t\tloadEntities(root.getChildrenByName(\"entity\"));\n\n\t\treturn currentProject;\n\t}", "public static TargetProject loadProject(String file) throws TargetException\r\n {\r\n TargetProject project = null;\r\n\r\n try\r\n {\r\n DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();\r\n DocumentBuilder docBuilder = factory.newDocumentBuilder();\r\n Document doc = docBuilder.parse(new File(file));\r\n String projectName = doc.getDocumentElement().getAttribute(\"name\");\r\n String rootDir = FileUtil.getFilePath(file);\r\n project = new TargetProject(projectName, rootDir);\r\n }\r\n catch (Exception e)\r\n {\r\n e.printStackTrace();\r\n throw new TargetException(\"The file \" + file + \" is not a valid TaRGeT project.\");\r\n }\r\n\r\n return project;\r\n }", "public static void main(String[] args) {\n\n Project project = new Project();\n project.setId(2L);\n project.setTitle(\"Title\");\n System.out.println(project);\n }", "Project getProject();", "@Test\n\tpublic void testEmptyProject() throws ParserConfigurationException, SAXException, IOException, DrillXMLException {\n\t\tFile testFile = new File(path + \"1-empty-project.pnd\");\n\t\t\n\t\t//create the xml parser\n\t\tXMLParser parser = new XMLParser();\n\t\t\n\t\t//parse the file\n\t\tDrillInfo drillInfo = parser.load(testFile);\n\t\t\n\t\t//test\n\t\tAssert.assertEquals(new DrillInfo(), drillInfo);\n\t}", "public void openProject(File file) {\n\n try {\n if (!file.exists()) {\n JOptionPane.showMessageDialog(Application.getFrame(),\n \"Can't open project - file \\\"\" + file.getPath() + \"\\\" does not exist\",\n \"Can't Open Project\", JOptionPane.OK_OPTION);\n return;\n }\n \n getApplication().getFrameController().addToLastProjListAction(\n file.getAbsolutePath());\n\n Configuration config = buildProjectConfiguration(file);\n Project project = new ApplicationProject(file, config);\n getProjectController().setProject(project);\n\n // if upgrade was canceled\n int upgradeStatus = project.getUpgradeStatus();\n if (upgradeStatus > 0) {\n JOptionPane\n .showMessageDialog(\n Application.getFrame(),\n \"Can't open project - it was created using a newer version of the Modeler\",\n \"Can't Open Project\",\n JOptionPane.OK_OPTION);\n closeProject(false);\n }\n else if (upgradeStatus < 0) {\n if (processUpgrades(project)) {\n getApplication().getFrameController().projectOpenedAction(project);\n }\n else {\n closeProject(false);\n }\n }\n else {\n getApplication().getFrameController().projectOpenedAction(project);\n }\n }\n catch (Exception ex) {\n logObj.warn(\"Error loading project file.\", ex);\n ErrorDebugDialog.guiWarning(ex, \"Error loading project\");\n }\n }", "public void testXML() {\n // check XML Entity Catalogs\n\n // \"Tools\"\n String toolsItem = Bundle.getStringTrimmed(\"org.netbeans.core.ui.resources.Bundle\", \"Menu/Tools\"); // NOI18N\n // \"DTDs and XML Schemas\"\n String dtdsItem = Bundle.getStringTrimmed(\"org.netbeans.modules.xml.catalog.Bundle\", \"LBL_CatalogAction_Name\");\n new Action(toolsItem + \"|\" + dtdsItem, null).perform();\n // \"DTDs and XML Schemas\"\n String dtdsTitle = Bundle.getString(\"org.netbeans.modules.xml.catalog.Bundle\", \"LBL_CatalogPanel_Title\");\n NbDialogOperator dtdsOper = new NbDialogOperator(dtdsTitle);\n\n String publicID = \"-//DTD XMLCatalog//EN\";\n Node catalogNode = new Node(new JTreeOperator(dtdsOper),\n \"NetBeans Catalog|\"\n + publicID);\n // view and close it\n new ViewAction().perform(catalogNode);\n new EditorOperator(publicID).close();\n dtdsOper.close();\n\n // create an XML file\n\n // create xml package\n // select Source Packages to not create xml folder in Test Packages\n new SourcePackagesNode(SAMPLE_PROJECT_NAME).select();\n // \"Java Classes\"\n String javaClassesLabel = Bundle.getString(\"org.netbeans.modules.java.project.Bundle\", \"Templates/Classes\");\n NewJavaFileWizardOperator.create(SAMPLE_PROJECT_NAME, javaClassesLabel, \"Java Package\", null, \"xml\"); // NOI18N\n Node xmlNode = new Node(new SourcePackagesNode(SAMPLE_PROJECT_NAME), \"xml\"); //NOI18N\n // \"XML\"\n String xmlCategory = Bundle.getString(\"org.netbeans.api.xml.resources.Bundle\", \"Templates/XML\");\n // \"XML Document\"\n String xmlDocument = Bundle.getString(\"org.netbeans.modules.xml.resources.Bundle\", \"Templates/XML/XMLDocument.xml\");\n NewFileWizardOperator.invoke(xmlNode, xmlCategory, xmlDocument);\n NewJavaFileNameLocationStepOperator nameStepOper = new NewJavaFileNameLocationStepOperator();\n nameStepOper.setObjectName(\"XMLDocument\"); // NOI18N\n nameStepOper.next();\n nameStepOper.finish();\n // wait node is present\n Node xmlDocumentNode = new Node(xmlNode, \"XMLDocument.xml\"); // NOI18N\n // wait xml document is open in editor\n new EditorOperator(\"XMLDocument.xml\").close(); // NOI18N\n\n // \"Check XML\"\n\n String checkXMLItem = Bundle.getStringTrimmed(\"org.netbeans.modules.xml.tools.actions.Bundle\", \"NAME_Check_XML\");\n // invoke context action to check xml\n new Action(null, checkXMLItem).perform(xmlDocumentNode);\n // \"XML check\"\n String xmlCheckTitle = Bundle.getString(\"org.netbeans.modules.xml.actions.Bundle\", \"TITLE_XML_check_window\");\n // find and close an output with the result of xml check\n new OutputTabOperator(xmlCheckTitle).close();\n\n // \"Validate XML\"\n\n String validateItem = Bundle.getStringTrimmed(\"org.netbeans.modules.xml.tools.actions.Bundle\", \"NAME_Validate_XML\");\n // invoke context action to validate xml\n new Action(null, validateItem).perform(xmlDocumentNode);\n // find and close an output with the result of xml validation\n new OutputTabOperator(xmlCheckTitle).close();\n\n // \"Generate DTD...\"\n\n String generateDTDItem = Bundle.getStringTrimmed(\"org.netbeans.modules.xml.tools.generator.Bundle\", \"PROP_GenerateDTD\");\n new ActionNoBlock(null, generateDTDItem).perform(xmlDocumentNode);\n // \"Select File Name\"\n String selectTitle = Bundle.getString(\"org.netbeans.modules.xml.tools.generator.Bundle\", \"PROP_fileNameTitle\");\n NbDialogOperator selectDialog = new NbDialogOperator(selectTitle);\n // name has to be set because of issue http://www.netbeans.org/issues/show_bug.cgi?id=46049\n new JTextFieldOperator(selectDialog).setText(\"DTD\");\n String oKLabel = Bundle.getString(\"org.netbeans.core.windows.services.Bundle\", \"OK_OPTION_CAPTION\");\n new JButtonOperator(selectDialog, oKLabel).push();\n // wait DTD is open in editor\n new EditorOperator(\"DTD.dtd\").close(); // NOI18N\n Node dtdNode = new Node(xmlNode, \"DTD.dtd\"); // NOI18N\n\n // \"Check DTD\"\n\n String checkDTDItem = Bundle.getStringTrimmed(\"org.netbeans.modules.xml.tools.actions.Bundle\", \"NAME_Validate_DTD\");\n new Action(null, checkDTDItem).perform(dtdNode);\n // find and close an output with the result of dtd check\n new OutputTabOperator(xmlCheckTitle).close();\n\n // \"Generate DOM Tree Scanner\"\n String generateScannerItem = Bundle.getStringTrimmed(\"org.netbeans.modules.xml.tools.generator.Bundle\", \"PROP_GenerateDOMScanner\");\n new ActionNoBlock(null, generateScannerItem).perform(dtdNode);\n selectDialog = new NbDialogOperator(selectTitle);\n new JButtonOperator(selectDialog, oKLabel).push();\n // wait Scanner is open in editor\n new EditorOperator(\"DTDScanner.java\").close(); // NOI18N\n new Node(xmlNode, \"DTDScanner.java\"); // NOI18N\n }", "public void load()\n\t{\n\t\ttry {\n\t\t\tIFile file = project.getFile(PLAM_FILENAME);\n\t\t if (file.exists()) {\n\t\t\t\tInputStream stream= null;\n\t\t\t\ttry {\n\t\t\t\t\tstream = new BufferedInputStream(file.getContents(true));\n\t\t\t\t SAXReader reader = new SAXReader();\n\t\t\t\t Document document = reader.read(stream);\n\t\t\t\t \n\t\t\t\t Element root = document.getRootElement();\n\n\t\t\t\t String url = root.elementTextTrim(\"server-url\");\n\t\t\t\t setServerURL((url != null) ? new URL(url) : null);\n\t\t\t\t \n\t\t\t\t setUserName(root.elementTextTrim(\"username\"));\n\t\t\t\t setPassword(root.elementTextTrim(\"password\"));\n\t\t\t\t setProductlineId(root.elementTextTrim(\"pl-id\"));\n \n\t\t\t\t} catch (CoreException e) {\n\t\t\t\t\t\n\t\t\t\t} finally {\n\t\t\t\t if (stream != null)\n\t\t\t\t stream.close();\n\t\t\t\t}\n\t\t }\n\t\t} catch (DocumentException e) {\n\t\t\tlogger.info(\"Error while parsing PLAM config.\", e);\n\t\t} catch (IOException e) {\n\t\t}\n\t}", "LectureProject createLectureProject();", "private void importAll() {\n\t\tfinal JFileChooser chooser = new JFileChooser(System.getProperty(\"user.home\"));\n\t\tint returnVal = chooser.showOpenDialog(null);\n\t\tif(returnVal == JFileChooser.APPROVE_OPTION) {\n\t\t\tFile file = chooser.getSelectedFile();\n\t\t\tdeserializeFile(file);\n\t\t\t // imported the projects for this application from a file, so update what should be persisted on close\n\t\t\tupdatePersistence();\n\t\t}\n\t}", "void open(IdeaProject project);", "public void openProject(File pfile, FileOpenSelector files) { }", "public static void main(String[] args) {\r\n new ParseVimeoXMLFile();\r\n }", "private void browseProject()\n {\n List<FileFilter> filters = new ArrayList<>();\n filters.add(new FileNameExtensionFilter(\"Bombyx3D project file\", \"yml\"));\n\n File directory = new File(projectPathEdit.getText());\n File selectedFile = FileDialog.chooseOpenFile(this, BROWSE_DIALOG_TITLE, directory, filters);\n if (selectedFile != null) {\n projectDirectory = selectedFile.getParentFile();\n projectPathEdit.setText(projectDirectory.getPath());\n projectPathEdit.selectAll();\n }\n }", "public static void main(String[] args) {\n AddNewProject addNewProject = new AddNewProject();\n addNewProject.setVisible(true);\n }", "public void showLoadXML(Properties p);", "public static void main(String[] args) {\n String dataDir = Utils.getDataDir(ConfigureGanttChartView.class);\n\n Project project = new Project(dataDir + \"project.mpp\");\n\n // Create a new project task\n Task task = project.getRootTask().getChildren().add(\"New Activity\");\n\n // Define new custom attribute\n ExtendedAttributeDefinition text1Definition = ExtendedAttributeDefinition.createTaskDefinition(ExtendedAttributeTask.Text1, null);\n project.getExtendedAttributes().add(text1Definition);\n // Add custom text attribute to created task.\n task.getExtendedAttributes().add(text1Definition.createExtendedAttribute(\"Activity attribute\"));\n\n // Customize table by adding text attribute field\n TableField attrField = new TableField();\n attrField.setField(Field.TaskText1);\n attrField.setWidth(20);\n attrField.setTitle(\"Custom attribute\");\n attrField.setAlignTitle(StringAlignment.Center);\n attrField.setAlignData(StringAlignment.Center);\n\n Table table = project.getTables().toList().get(0);\n table.getTableFields().add(3, attrField);\n\n // The result of opening of saved project in MSP2010 is in attached screenshot\n project.save(\"saved.mpp\", SaveFileFormat.Mpp);\n }", "public SCMLProject load(InputStream stream)\n\t{\n\t\tXmlReader reader = new XmlReader();\n\t\treturn load(reader.parse(stream));\n\t}", "public static void main (String[] args) throws FileNotFoundException\n {\n System.out.println (\"So, you have an idea for a project.\");\n\n DecisionTree expert = new DecisionTree(\"projectplan-input.txt\");\n expert.evaluate();\n }", "private void loadProject()\n\t{\n\t\t\n\t\tint fileChooserReturnValue =\n\t\t\twindowTemplate\n\t\t\t\t.getFileChooser()\n\t\t\t\t.showOpenDialog(windowTemplate);\n\t\t\n\t\tif(fileChooserReturnValue == JFileChooser.APPROVE_OPTION) {\n\t\t\t// Delete the current cards\n\t\t\tdeleteAllCards();\n\t\t\t\n\t\t\t// Get the file that the user selected\n\t\t\tFile file = windowTemplate.getFileChooser().getSelectedFile();\n\t\t\t\n\t\t\ttry {\n\t\t\t\t\n\t\t\t\t// Open the input streams\n\t\t\t\tFileInputStream fileInput = new FileInputStream(file.getAbsolutePath());\n\t\t\t\tObjectInputStream objectInput = new ObjectInputStream(fileInput);\n\t\t\t\t\n\t\t\t\t// Get ready to save the cards\n\t\t\t\tArrayList<Card> newCards = new ArrayList<Card>();\n\t\t\t\t\n\t\t\t\t// Get the objects\n\t\t\t\ttry {\n\t\t\t\t\t\n\t\t\t\t\tObject inputObject = objectInput.readObject();\n\t\t\t\t\t\n\t\t\t\t\twhile(inputObject instanceof Card) {\n\t\t\t\t\t\t\n\t\t\t\t\t\t// Add the card\n\t\t\t\t\t\tnewCards.add((Card) inputObject);\n\t\t\t\t\t\t\n\t\t\t\t\t\t// Read the next object\n\t\t\t\t\t\tinputObject = objectInput.readObject();\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t} catch(EOFException e2) {\n\t\t\t\t\t\n\t\t\t\t\t// We've reached the end of the file, time to add the new project\n\t\t\t\t\taddCards(newCards);\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Close the input streams\n\t\t\t\tobjectInput.close();\n\t\t\t\tfileInput.close();\n\t\t\t\t\n\t\t\t\t// Update the title of the frame to reflect the current project\n\t\t\t\twindowTemplate.setTitle(file.getName());\n\t\t\t\t\n\t\t\t} catch (ClassNotFoundException | IOException e1) {\n\t\t\t\tJOptionPane.showMessageDialog(windowTemplate, \"Could not open the file.\");\n\t\t\t}\n\t\t}\n\t\t\n\t}", "public static Project exampleProject() throws ParseException {\n Person willem = new Person(\"Contractor\", \"Willem du Plessis\", \"074 856 4561\", \"willem@dup.com\",\n \"452 Tugela Avenue\");\n Person rene = new Person(\"Architect\", \"Rene Malan\", \"074 856 4561\", \"rene@malan\", \"452 Tugela Avenue\");\n Person tish = new Person(\"Client\", \"Tish du Plessis\", \"074 856 4561\", \"tish@dup.com\", \"452 Tugela Avenue\");\n Date deadline = dateformat.parse(\"30/03/2021\");\n Project housePlessis = new Project(789, \"House Plessis\", \"House\", \"102 Jasper Avenue\", \"1025\", 20000, 5000,\n deadline, willem, rene, tish);\n ProjectList.add(housePlessis);\n\n return housePlessis;\n }", "public project() {\n\n initComponents();\n }", "private Project(){}", "public Project createProject( File build_file ) throws Exception { // NOPMD\n if ( build_file == null || !build_file.exists() )\n return null;\n\n // load the option settings for this build file\n setPrefs( build_file );\n\n // configure the project\n Project p = new Project();\n\n // set the project helper -- the AntelopeProjectHelper2 is the same as the Ant\n // ProjectHelper2, but has been slightly modified so it does not automatically\n // run the implicit target\n System.setProperty( \"org.apache.tools.ant.ProjectHelper\", \"ise.antelope.common.AntelopeProjectHelper2\" );\n\n try {\n ClassLoader cl = _helper.getAntClassLoader();\n p.setCoreLoader( cl );\n\n /*\n try {\n Log.log(\"loading antlib with _helper classloader\");\n cl.getResource( \"ise/antelope/tasks/antlib.xml\" );\n Log.log(\"loaded antlib with _helper classloader\");\n }\n catch(Exception e) {\n e.printStackTrace();\n }\n */\n\n // add the antelope build logger now so that any output produced by the\n // ProjectHelper is captured\n p.addBuildListener( _build_logger );\n\n // add the progress bar build listener\n p.addBuildListener( _progress );\n\n // optionally add the antelope performance listener\n if ( _settings.getShowPerformanceOutput() ) {\n if ( _performance_listener == null )\n _performance_listener = new AntPerformanceListener();\n p.addBuildListener( _performance_listener );\n }\n\n // add the gui input handler\n setInputHandler( p );\n\n p.init(); // this takes as much as 9 seconds the first time, less than 1/2 second later\n\n p.setUserProperty( \"ant.file\", build_file.getAbsolutePath() );\n p.setProperty( \"ant.version\", Main.getAntVersion() );\n //String ant_home = System.getProperty(\"ant.home\");\n String ant_home = AntUtils.getAntHome();\n if ( ant_home != null ) {\n p.setProperty( \"ant.home\", ant_home );\n }\n String ant_lib_dirs = AntUtils.getAntLibDirs();\n if ( ant_lib_dirs != null )\n p.setProperty( \"ant.library.dir\", ant_lib_dirs );\n\n // add ant.jar to the classpath\n // for Ant 1.6, does ant-launcher.jar need to be added also? --\n // yes -- add all jars in $ant_home/lib and $user.home/.ant/lib, this\n // is what command-line Ant does. Ant also supports a -lib command-line\n // option where the user can specify additional locations. Should\n // Antelope support this? Need a gui in the properties panel if so.\n // 12/22/2004: added AntelopeLauncher, so -lib option is handled for app,\n // but not for plugin\n /// -- should this be done here or in the helper? --\n java.util.List ant_jars = _helper.getAntJarList();\n if ( ant_jars != null ) {\n java.util.List cp_list = new ArrayList();\n String classpath = p.getProperty( \"java.class.path\" );\n StringTokenizer st = new StringTokenizer( classpath, File.pathSeparator );\n while ( st.hasMoreTokens() ) {\n cp_list.add( new File( st.nextToken() ) );\n }\n Iterator it = ant_jars.iterator();\n while ( it.hasNext() ) {\n File f = new File( ( String ) it.next() );\n if ( !cp_list.contains( f ) ) {\n cp_list.add( f );\n }\n }\n StringBuffer sb = new StringBuffer();\n it = cp_list.iterator();\n while ( it.hasNext() ) {\n sb.append( ( ( File ) it.next() ).getAbsolutePath() ).append( File.pathSeparator );\n }\n classpath = sb.toString();\n p.setProperty( \"java.class.path\", classpath );\n System.setProperty( \"java.class.path\", classpath );\n }\n\n // load any saved user properties for this build file. These are properties\n // that the user has set using the properties dialog and in command-line\n // Ant would have been passed on the command line.\n Preferences user_prefs = getPrefs().node( Constants.ANT_USER_PROPS );\n String[] keys = user_prefs.keys();\n for ( int i = 0; i < keys.length; i++ ) {\n p.setUserProperty( keys[ i ], user_prefs.get( keys[ i ], \"\" ) );\n }\n\n //ProjectHelper.configureProject( p, build_file ); // deprecated\n ProjectHelper helper = ProjectHelper.getProjectHelper();\n p.addReference( \"ant.projectHelper\", helper );\n helper.parse( p, build_file );\n\n //for (Iterator it = p.getTargets().keySet().iterator(); it.hasNext(); ) {\n // System.out.println(\"target: \" + it.next());\n //}\n\n /*\n // looks like a recent change for antlib has busted loading custom tasks from\n // an antlib declaration. Need to check if this ever worked, I used to use\n // taskdef exclusively, and have only recently switched to using antlib.\n // Using antlib works when Antelope is running as an application, but not as\n // a plugin. Seems to have something to do with classloading.\n try {\n System.out.println(\"AntelopePanel classloader = \" + getClass().getClassLoader().hashCode());\n Class c = Class.forName(\"org.apache.tools.ant.Main\");\n if (c != null) {\n System.out.println(\"classloader for Main = \" + c.getClassLoader().hashCode());\n System.out.println(\"parent classloader for Main = \" + c.getClassLoader().getParent());\n }\n else\n System.out.println(\"did not find class for Main\");\n c = Class.forName(\"ise.antelope.tasks.Unset\");\n if (c != null){\n System.out.println(\"classloader for Unset = \" + c.getClassLoader().hashCode());\n System.out.println(\"parent classloader for Unset = \" + c.getClassLoader().getParent());\n System.out.println(\"classloader for Unset is a \" + c.getClassLoader().getClass().getName());\n }\n else\n System.out.println(\"did not find class for Unset\");\n c = Class.forName(\"org.apache.tools.ant.taskdefs.optional.EchoProperties\");\n if (c != null){\n System.out.println(\"classloader for EchoProperties = \" + c.getClassLoader().hashCode());\n System.out.println(\"parent classloader for EchoProperties = \" + c.getClassLoader().getParent());\n System.out.println(\"classloader for EchoProperties is a \" + c.getClassLoader().getClass().getName());\n }\n else\n System.out.println(\"did not find class for EchoProperties\");\n }\n catch(Exception e) {\n e.printStackTrace();\n }\n */\n\n\n return p;\n }\n catch ( Exception e ) {\n Log.log( e );\n e.printStackTrace( System.out );\n JOptionPane.showMessageDialog( GUIUtils.getRootJFrame( this ),\n \"<html>Error:<br>\" + e.getMessage(),\n \"Ant Error\",\n JOptionPane.ERROR_MESSAGE );\n throw e;\n }\n catch ( NoClassDefFoundError error ) {\n Log.log( error );\n error.printStackTrace( System.out );\n JOptionPane.showMessageDialog( GUIUtils.getRootJFrame( this ),\n \"<html>Error: No Class Definition Found for<br>\" + error.getMessage() +\n \"<br><p>This is most likely caused by a required third-party<br>\" +\n \"jar file not being in the class path.\",\n \"Ant Error\",\n JOptionPane.ERROR_MESSAGE );\n throw new Exception( error.getMessage() ); // NOPMD\n }\n }", "public static void main(String[] args)\n {\n URL xmlURL = RpgConfMain.class.getResource(\"/baseList.xml\");\n\n if(xmlURL == null)\n {\n System.out.println(\"Failed to read xml file, xmlURL was null\");\n System.exit(-1);\n }\n\n //Getting the xml file\n try(InputStream xmlStream = (InputStream) xmlURL.getContent())\n {\n //Reading the xml file\n xmlReader = new StructXMLReader(xmlStream);\n } catch (IOException | XMLStreamException e)\n {\n System.exit(-1);\n e.printStackTrace();\n }\n\n MainFrame frame = new MainFrame(new ConfigCode(), xmlReader); //Used before initialization is wrong. If the xmlReader\n //variable is wrong, the program will exit\n\n frame.setVisible(true);\n }", "public static void main(String[] args) {\n String dataDir = Utils.getDataDir(HandleExceptions.class);\n\n try {\n new Project(dataDir + \"project.mpp\");\n } catch (TasksReadingException ex) {\n System.out.print(\"Message: \");\n System.out.println(ex.getMessage());\n System.out.print(\"Log: \");\n System.out.println(ex.getLogText());\n\n if (ex.getCause() != null) {\n System.out.print(\"Inner exception message: \");\n System.out.println(ex.getCause().getMessage());\n }\n } catch (Exception e) {\n System.out.println(e.getMessage());\n }\n }", "private ProjectMgr getPmNameTrueLoadActualProject() {\n ProjectMgr pm = null;\n try {\n pm = new ProjectMgr(\"Example\", true);\n\n } catch (ParserConfigurationException e) {\n e.printStackTrace();\n } catch (IOException e) {\n e.printStackTrace();\n } catch (SAXException e) {\n e.printStackTrace();\n }\n\n IOException e;\n return pm;\n }", "public static ElementTreeSelectionDialog createHaxeProjectsDialog(\r\n\t\t\tShell shell) {\r\n\r\n\t\tElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(\r\n\t\t\t\tshell, new HaxeElementsLabelProvider(),\r\n\t\t\t\tnew HaxeElementsContentProvider(new HaxeElementFilter(\r\n\t\t\t\t\t\tShowElement.Project)));\r\n\r\n\t\tdialog.setTitle(\"haXe Project\");\r\n\t\tdialog.setMessage(\"Choose a haXe project:\");\r\n\t\tdialog.setHelpAvailable(false);\r\n\r\n\t\t// Sets haXe workspace as a root of the resource tree\r\n\t\tdialog.setInput(EclihxCore.getDefault().getHaxeWorkspace());\r\n\r\n\t\treturn dialog;\r\n\t}", "public void init() {\n- newProject = new Project();\n- newProject.setDefaultInputStream(getProject().getDefaultInputStream());\n+ newProject = getProject().createSubProject();\n newProject.setJavaVersionProperty();\n }", "private void actionImport() {\n ImportPanel myPanel = new ImportPanel();\n int result = JOptionPane.showConfirmDialog(this, myPanel, \"Import\",\n JOptionPane.OK_CANCEL_OPTION);\n if (result == JOptionPane.OK_OPTION) { // Afirmative\n readNeuronListFromFile(\n myPanel.tfields[ImportPanel.idxInhList].getText(),\n layoutPanel.inhNList, LayoutPanel.INH);\n readNeuronListFromFile(\n myPanel.tfields[ImportPanel.idxActList].getText(),\n layoutPanel.activeNList, LayoutPanel.ACT);\n readNeuronListFromFile(\n myPanel.tfields[ImportPanel.idxPrbList].getText(),\n layoutPanel.probedNList, LayoutPanel.PRB);\n\n Graphics g = layoutPanel.getGraphics();\n layoutPanel.writeToGraphics(g);\n }\n }", "public AddProject() {\n try\n {\n infDB = new InfDB(\"\\\\Users\\\\Oliver\\\\Documents\\\\Skola\\\\Mini_sup\\\\Realisering\\\\MICEDB.FDB\");\n System.out.println(\"Uppkopplingen lyckades\");\n }\n catch(InfException e)\n {\n System.out.println(e.getMessage());\n }\n \n try\n {\n infDB = new InfDB(\"C:\\\\Users\\\\TP300LA-C4034\\\\Desktop\\\\Delkurs 4, Lill-supen\\\\InformatikDB\\\\MICEDB.FDB\");\n System.out.println(\"Uppkopplingen lyckades\");\n }\n catch(InfException e)\n {\n System.out.println(e.getMessage());\n }\n getPlatforms();\n initComponents();\n setLocationRelativeTo(null);\n \n }", "private void parseFile(Project p, File f, ImportSettings settings, int pass)\n throws ImportException {\n\n\n try {\n BufferedInputStream bs = new BufferedInputStream(new FileInputStream(f));\n Lexer l = new Lexer(bs, f.getAbsolutePath());\n TokenCollection toks = l.lex();\n Parser px = new Parser();\n CompilationUnitNode cu = px.parse(toks, l.StringLiterals);\n parsedElements.add(cu);\n } catch (FeatureNotSupportedException e) {\n //throw new ImportException(\"Error parsing file: \" + f.getAbsolutePath() + \" due to: \"+e.getMessage());\n System.out.println(\"Error parsing file: \" + f.getAbsolutePath() + \" due to: \"+e.getMessage());\n } catch (Exception e) {\n// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.\n// throw new ImportException(\"Error parsing file: \" + f.getAbsolutePath());\n System.out.println(\"Error parsing file: \" + f.getAbsolutePath());\n }\n\n }", "public void populate(IProject project) throws InvocationTargetException;", "public Project(File file)\n {\n super(file);\n this.open();\n }", "@XmlElement(name = \"project\")\n public URI getProject() {\n return project;\n }", "public ProjectsPage() {\n\t\tthis.driver = DriverManager.getDriver();\n\t\tElementFactory.initElements(driver, this);\n\t\t// sets the name of the project to add, with a random integer ending for slight\n\t\t// ease on multiple test runs\n\t\tnameOfProject = \"testz2018\" + (int) Math.random() * 500;\n\t}", "public Project() {\n this.name = \"Paper plane\";\n this.description = \" It's made of paper.\";\n }", "public Project getProjectByName(String name);", "public CreateProject() {\n\t\tsuper();\n\t}", "public void load() {\r\n try {\r\n project = ProjectAccessor.findFromTitle(title, conn);\r\n } catch (SQLException e) {\r\n e.printStackTrace();\r\n }\r\n }", "public void importButtonClicked() {\n DialogService dialogService = Injector.instantiateModelOrService(DialogService.class);\n ImportEntriesDialog dialog = new ImportEntriesDialog(databaseContext, BackgroundTask.wrap(() -> new ParserResult(resolverResult.getNewEntries())));\n dialog.setTitle(Localization.lang(\"Import entries from LaTeX files\"));\n dialogService.showCustomDialogAndWait(dialog);\n }", "public ProjectViewController(){\n InputStream request = appController.httpRequest(\"http://localhost:8080/project/getProject\", \"GET\");\n try {\n String result = IOUtils.toString(request, StandardCharsets.UTF_8);\n Gson gson = new Gson();\n this.projectModel = gson.fromJson(result, ProjectModel.class);\n } catch (IOException e) {\n e.printStackTrace();\n }\n }", "public static void main(String args[])\n {\n LoadFileSupport sample = new LoadFileSupport();\n sample.createNewInstance(\"C:/pavan/j2eeWork/ws-studio-ie-workspace/xml-test/HTMLtoXSLProject/IncomingTimber/LoadSampleSample.xml\");\n sample.loadExistingInstance(\"C:/pavan/j2eeWork/ws-studio-ie-workspace/xml-test/HTMLtoXSLProject/IncomingTimber/LoadSampleSample.xml\");\n }", "public void createProject(Project newProject);", "public ProjectModule() {\n packaging = AutomationConstant.PACKAGING_POM;\n }", "public static void main(String[] args) {\r\n\t\tProgProjGUI display = new ProgProjGUI();\r\n\t\tdisplay.setVisible(true);\r\n\t\t\r\n\t\t\r\n\t}", "public IProject getProject();", "public void loadProjectFromPath(final String path) throws IOException\n {\n final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();\n factory.setNamespaceAware(true);\n final DocumentBuilder builder;\n final Document doc;\n try {\n builder = factory.newDocumentBuilder();\n doc = builder.parse(new File(path));\n\n // XXX here, we could be strict and only allow valid documents...\n // validate(doc);\n final Element projectRoot = doc.getDocumentElement();\n //load the canvas (or pages and page blocks if any) blocks from the save file\n //also load drawers, or any custom drawers from file. if no custom drawers\n //are present in root, then the default set of drawers is loaded from\n //langDefRoot\n workspace.loadWorkspaceFrom(projectRoot, langDefRoot);\n workspaceLoaded = true;\n } catch (ParserConfigurationException e) {\n throw new RuntimeException(e);\n } catch (SAXException e) {\n throw new RuntimeException(e);\n }\n }", "public Project(String name){\n\t\tthis.pName = name;\n\t}", "public static void testXmlImport() {\n\n }", "public static void main(String[] args) {\r\n\t\ttry {\r\n\t\t\tDisplay display = Display.getDefault();\r\n\t\t\tShell shell = new Shell(display);\r\n\t\t\tImportDialog inst = new ImportDialog(shell, SWT.NULL);\r\n\t\t\tinst.open();\r\n\t\t} catch (Exception e) {\r\n\t\t\te.printStackTrace();\r\n\t\t}\r\n\t}", "public void readXmlFile() {\r\n try {\r\n ClassLoader classLoader = getClass().getClassLoader();\r\n File credentials = new File(classLoader.getResource(\"credentials_example.xml\").getFile());\r\n DocumentBuilderFactory Factory = DocumentBuilderFactory.newInstance();\r\n DocumentBuilder Builder = Factory.newDocumentBuilder();\r\n Document doc = Builder.parse(credentials);\r\n doc.getDocumentElement().normalize();\r\n username = doc.getElementsByTagName(\"username\").item(0).getTextContent();\r\n password = doc.getElementsByTagName(\"password\").item(0).getTextContent();\r\n url = doc.getElementsByTagName(\"url\").item(0).getTextContent();\r\n setUsername(username);\r\n setPassword(password);\r\n setURL(url);\r\n } catch (Exception error) {\r\n System.out.println(\"Error in parssing the given xml file: \" + error.getMessage());\r\n }\r\n }", "private void newProject()\n\t{\n\t\tnew FenetreCreationProjet();\n\t}", "@SuppressWarnings(\"serial\")\n\tpublic ProjectPage() {\n\t\tagregarForm();\n\t}", "public miniproject() {\n initComponents();\n }", "private void initializeProject() {\n newProject.setInputHandler(getProject().getInputHandler());\n \n Iterator iter = getBuildListeners();\n while (iter.hasNext()) {\n newProject.addBuildListener((BuildListener) iter.next());\n }\n \n if (output != null) {\n File outfile = null;\n if (dir != null) {\n outfile = FILE_UTILS.resolveFile(dir, output);\n } else {\n outfile = getProject().resolveFile(output);\n }\n try {\n out = new PrintStream(new FileOutputStream(outfile));\n DefaultLogger logger = new DefaultLogger();\n logger.setMessageOutputLevel(Project.MSG_INFO);\n logger.setOutputPrintStream(out);\n logger.setErrorPrintStream(out);\n newProject.addBuildListener(logger);\n } catch (IOException ex) {\n log(\"Ant: Can't set output to \" + output);\n }\n }\n-\n- getProject().initSubProject(newProject);\n-\n // set user-defined properties\n getProject().copyUserProperties(newProject);\n \n if (!inheritAll) {\n // set Java built-in properties separately,\n // b/c we won't inherit them.\n newProject.setSystemProperties();\n \n } else {\n // set all properties from calling project\n addAlmostAll(getProject().getProperties());\n }\n \n Enumeration e = propertySets.elements();\n while (e.hasMoreElements()) {\n PropertySet ps = (PropertySet) e.nextElement();\n addAlmostAll(ps.getProperties());\n }\n }", "public ProjectInfoDialog(String project, String dataset, String inputCsv, String transitionsXml, \n\t\t\t\t\tint numberOfSchemas, int numberOfTransitions, int numberOfTables) {\n\t\tsetBounds(100, 100, 479, 276);\n\t\tgetContentPane().setLayout(new BorderLayout());\n\t\tcontentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));\n\t\tgetContentPane().add(contentPanel, BorderLayout.CENTER);\n\t\t\n\t\tJLabel lblSchemas = new JLabel(\"Schemas:\");\n\t\tlblSchemas.setFont(new Font(\"Tahoma\", Font.BOLD, 12));\n\t\t\n\t\tJLabel labelNumberOfSch = new JLabel(\"-\");\n\t\tlabelNumberOfSch.setFont(new Font(\"Tahoma\", Font.PLAIN, 12));\n\t\t\n\t\tlabelNumberOfSch.setText(Integer.toString(numberOfSchemas));\n\t\t\n\t\tJLabel lblTransitions = new JLabel(\"Transitions:\");\n\t\tlblTransitions.setFont(new Font(\"Tahoma\", Font.BOLD, 12));\n\t\t\n\t\tJLabel labelNumberOfTr = new JLabel(\"-\");\n\t\tlabelNumberOfTr.setFont(new Font(\"Tahoma\", Font.PLAIN, 12));\n\t\tlabelNumberOfTr.setText(Integer.toString(numberOfTransitions));\n\n\t\t\n\t\tJLabel lblTables = new JLabel(\"Tables:\");\n\t\tlblTables.setFont(new Font(\"Tahoma\", Font.BOLD, 12));\n\t\t\n\t\tJLabel labelNumberOfTables = new JLabel(\"-\");\n\t\tlabelNumberOfTables.setFont(new Font(\"Tahoma\", Font.PLAIN, 12));\n\t\tlabelNumberOfTables.setText(Integer.toString(numberOfTables));\n\t\t\n\t\tJLabel lblProjectName = new JLabel(\"Project Name\");\n\t\tlblProjectName.setFont(new Font(\"Tahoma\", Font.BOLD, 12));\n\t\t\n\t\tJLabel labelPrName = new JLabel(\"-\");\n\t\tlabelPrName.setFont(new Font(\"Tahoma\", Font.PLAIN, 12));\n\t\tlabelPrName.setText(project);\n\n\t\t\n\t\tJLabel lblDatasetTxt = new JLabel(\"Dataset Txt\");\n\t\tlblDatasetTxt.setFont(new Font(\"Tahoma\", Font.BOLD, 12));\n\t\t\n\t\tJLabel lblDataTxt = new JLabel(\"-\");\n\t\tlblDataTxt.setFont(new Font(\"Tahoma\", Font.PLAIN, 12));\n\t\tlblDataTxt.setText(dataset);\n\n\t\t\n\t\tJLabel lblInput = new JLabel(\"Input Csv\");\n\t\tlblInput.setFont(new Font(\"Tahoma\", Font.BOLD, 12));\n\t\t\n\t\tJLabel labelInCsv = new JLabel(\"-\");\n\t\tlabelInCsv.setFont(new Font(\"Tahoma\", Font.PLAIN, 12));\n\t\tlabelInCsv.setText(inputCsv);\n\n\t\t\n\t\tJLabel lblTransitionsFile = new JLabel(\"Transitions File\");\n\t\tlblTransitionsFile.setFont(new Font(\"Tahoma\", Font.BOLD, 12));\n\t\t\n\t\tJLabel labelTrFile = new JLabel(\"-\");\n\t\tlabelTrFile.setFont(new Font(\"Tahoma\", Font.PLAIN, 12));\n\t\tlabelTrFile.setText(transitionsXml);\n\n\n\t\t\n\t\tGroupLayout gl_contentPanel = new GroupLayout(contentPanel);\n\t\tgl_contentPanel.setHorizontalGroup(\n\t\t\tgl_contentPanel.createParallelGroup(Alignment.LEADING)\n\t\t\t\t.addGroup(gl_contentPanel.createSequentialGroup()\n\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING)\n\t\t\t\t\t\t.addComponent(lblSchemas, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)\n\t\t\t\t\t\t.addGroup(gl_contentPanel.createSequentialGroup()\n\t\t\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)\n\t\t\t\t\t\t\t\t.addGroup(gl_contentPanel.createSequentialGroup()\n\t\t\t\t\t\t\t\t\t.addComponent(lblTables, GroupLayout.PREFERRED_SIZE, 59, GroupLayout.PREFERRED_SIZE)\n\t\t\t\t\t\t\t\t\t.addGap(196))\n\t\t\t\t\t\t\t\t.addGroup(gl_contentPanel.createSequentialGroup()\n\t\t\t\t\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING, false)\n\t\t\t\t\t\t\t\t\t\t.addComponent(lblTransitions, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)\n\t\t\t\t\t\t\t\t\t\t.addComponent(lblProjectName, Alignment.LEADING)\n\t\t\t\t\t\t\t\t\t\t.addComponent(lblDatasetTxt, Alignment.LEADING)\n\t\t\t\t\t\t\t\t\t\t.addComponent(lblInput, Alignment.LEADING)\n\t\t\t\t\t\t\t\t\t\t.addComponent(lblTransitionsFile, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))\n\t\t\t\t\t\t\t\t\t.addGap(13)\n\t\t\t\t\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)\n\t\t\t\t\t\t\t\t\t\t.addComponent(labelPrName, GroupLayout.DEFAULT_SIZE, 207, Short.MAX_VALUE)\n\t\t\t\t\t\t\t\t\t\t.addComponent(lblDataTxt, GroupLayout.DEFAULT_SIZE, 207, Short.MAX_VALUE)\n\t\t\t\t\t\t\t\t\t\t.addGroup(gl_contentPanel.createSequentialGroup()\n\t\t\t\t\t\t\t\t\t\t\t.addPreferredGap(ComponentPlacement.UNRELATED)\n\t\t\t\t\t\t\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)\n\t\t\t\t\t\t\t\t\t\t\t\t.addComponent(labelTrFile, GroupLayout.DEFAULT_SIZE, 207, Short.MAX_VALUE)\n\t\t\t\t\t\t\t\t\t\t\t\t.addComponent(labelInCsv, GroupLayout.DEFAULT_SIZE, 207, Short.MAX_VALUE)\n\t\t\t\t\t\t\t\t\t\t\t\t.addComponent(labelNumberOfSch, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE)\n\t\t\t\t\t\t\t\t\t\t\t\t.addComponent(labelNumberOfTr, GroupLayout.PREFERRED_SIZE, 85, GroupLayout.PREFERRED_SIZE)\n\t\t\t\t\t\t\t\t\t\t\t\t.addComponent(labelNumberOfTables, GroupLayout.PREFERRED_SIZE, 62, GroupLayout.PREFERRED_SIZE))))))\n\t\t\t\t\t\t\t.addPreferredGap(ComponentPlacement.RELATED)))\n\t\t\t\t\t.addGap(0))\n\t\t);\n\t\tgl_contentPanel.setVerticalGroup(\n\t\t\tgl_contentPanel.createParallelGroup(Alignment.TRAILING)\n\t\t\t\t.addGroup(gl_contentPanel.createSequentialGroup()\n\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)\n\t\t\t\t\t\t.addComponent(lblProjectName)\n\t\t\t\t\t\t.addComponent(labelPrName))\n\t\t\t\t\t.addPreferredGap(ComponentPlacement.RELATED)\n\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)\n\t\t\t\t\t\t.addComponent(lblDatasetTxt)\n\t\t\t\t\t\t.addComponent(lblDataTxt))\n\t\t\t\t\t.addPreferredGap(ComponentPlacement.RELATED)\n\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)\n\t\t\t\t\t\t.addComponent(labelInCsv)\n\t\t\t\t\t\t.addComponent(lblInput))\n\t\t\t\t\t.addPreferredGap(ComponentPlacement.RELATED)\n\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)\n\t\t\t\t\t\t.addComponent(labelTrFile)\n\t\t\t\t\t\t.addComponent(lblTransitionsFile))\n\t\t\t\t\t.addPreferredGap(ComponentPlacement.RELATED, 27, Short.MAX_VALUE)\n\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)\n\t\t\t\t\t\t.addComponent(lblSchemas)\n\t\t\t\t\t\t.addComponent(labelNumberOfSch))\n\t\t\t\t\t.addPreferredGap(ComponentPlacement.RELATED)\n\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)\n\t\t\t\t\t\t.addComponent(lblTransitions)\n\t\t\t\t\t\t.addComponent(labelNumberOfTr))\n\t\t\t\t\t.addPreferredGap(ComponentPlacement.UNRELATED)\n\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)\n\t\t\t\t\t\t.addComponent(lblTables)\n\t\t\t\t\t\t.addComponent(labelNumberOfTables))\n\t\t\t\t\t.addGap(27))\n\t\t);\n\t\tcontentPanel.setLayout(gl_contentPanel);\n\t\t{\n\t\t\tJPanel buttonPane = new JPanel();\n\t\t\tbuttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));\n\t\t\tgetContentPane().add(buttonPane, BorderLayout.SOUTH);\n\t\t\t{\n\t\t\t\tJButton okButton = new JButton(\"OK\");\n\t\t\t\tokButton.addActionListener(new ActionListener() {\n\t\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tsetVisible(false);\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tokButton.setActionCommand(\"OK\");\n\t\t\t\tbuttonPane.add(okButton);\n\t\t\t\tgetRootPane().setDefaultButton(okButton);\n\t\t\t}\n\t\t}\n\t}", "public void getProject(){\n\t\n\t String getList[] = clientFacade.GetProjects().split(\"\\n\");\n\t DefaultComboBoxModel addPro = new DefaultComboBoxModel();\n\t\tfor(int i=1; i<getList.length; i+=2) \n\t\t\t addPro.addElement(getList[i]);\n\t\t\t \n\t\tcPro.setModel(addPro);\t\n\t}", "public void open(){\n\t\ttry {\n\t\t\tdocFactory = DocumentBuilderFactory.newInstance();\n\t\t\tdocBuilder = docFactory.newDocumentBuilder();\n\t\t\tdoc = docBuilder.parse(ManipXML.class.getResourceAsStream(path));\n\t\t\t\n\t\t} catch (ParserConfigurationException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (SAXException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}", "public static String startProject(String projectName, String projectRevision) {\n\t\treturn \"<java-project id=\\\"default\\\" name=\\\"\" + projectName + \"\\\" revision=\\\"\" + projectRevision + \"\\\">\" + \"\\n\";\n\t}", "public Project() {\n\t\t\n\t}", "public static void readProjectUidsFromStream(String dataDir) throws IOException\n {\n try (InputStream stream = Files.newInputStream(Paths.get(dataDir + \"Primavera.xml\"), StandardOpenOption.READ)){\n PrimaveraXmlReader reader = new PrimaveraXmlReader(stream);\n List<Integer> projectUids = reader.getProjectUids();\n for (Integer projectUid : projectUids)\n {\n System.out.println(\"Project UID: \" + projectUid);\n }\n }\n }", "public static void main(String args[]) {\n new xml().convert();\n }", "public void loadProjectFromElement(Element elementToLoad) {\n workspace.loadWorkspaceFrom(elementToLoad, langDefRoot);\n workspaceLoaded = true;\n }", "public TpImport(){\r\n\t\t\r\n\t}", "public project_piramide() {\n initComponents();\n }", "HibProject getProject(InternalActionContext ac);", "@Test\n @org.junit.Ignore\n public void testProject_1()\n throws Exception {\n\n Project result = new Project();\n\n assertNotNull(result);\n assertEquals(null, result.getName());\n assertEquals(null, result.getWorkloadNames());\n assertEquals(null, result.getProductName());\n assertEquals(null, result.getComments());\n assertEquals(null, result.getCreator());\n assertEquals(0, result.getId());\n assertEquals(null, result.getModified());\n assertEquals(null, result.getCreated());\n }", "public void importWorkflow() {\n int returnVal = this.graphFileChooser.showOpenDialog(this.engine.getGUI().getFrame());\n if (returnVal == JFileChooser.APPROVE_OPTION) {\n File file = this.graphFileChooser.getSelectedFile();\n try {\n\n String path = file.getPath();\n Workflow importedWorkflow;\n if (path.endsWith(XBayaConstants.GRAPH_FILE_SUFFIX)) {\n WSGraph importedGraph = WSGraphFactory.createGraph(file);\n importedWorkflow = Workflow.graphToWorkflow(importedGraph);\n } else {\n XmlElement importedWorkflowElement = XMLUtil.loadXML(file);\n importedWorkflow = new Workflow(importedWorkflowElement);\n }\n GraphCanvas newGraphCanvas = engine.getGUI().newGraphCanvas(true);\n newGraphCanvas.setWorkflow(importedWorkflow);\n this.engine.getGUI().setWorkflow(importedWorkflow);\n engine.getGUI().getGraphCanvas().setWorkflowFile(file);\n\n } catch (IOException e) {\n this.engine.getGUI().getErrorWindow().error(ErrorMessages.OPEN_FILE_ERROR, e);\n } catch (GraphException e) {\n this.engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);\n } catch (ComponentException e) {\n this.engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);\n } catch (RuntimeException e) {\n this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);\n } catch (Error e) {\n this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);\n }\n }\n }", "public void setupImport() {\r\n\t\tmnuImport.addActionListener(new ActionListener() {\r\n\t\t\tpublic void actionPerformed(ActionEvent e) {\r\n\t\t\t\tnew ImportGUI();\r\n\t\t\t}\r\n\t\t});\r\n\t}", "@Test\n \tpublic void testCreateMindProject() throws Exception {\n \t\tString name = \"Test\" ; //call a generator which compute a new name\n \t\tGTMenu.clickItem(\"File\", \"New\", FRACTAL_MIND_PROJECT);\n \t\tGTShell shell = new GTShell(Messages.MindProjectWizard_window_title);\n \t\t//shell.findTree().selectNode(\"Mind\",FRACTAL_MIND_PROJECT);\n \t\t//shell.findButton(\"Next >\").click();\n \t\tshell.findTextWithLabel(\"Project name:\").typeText(name);\n \t\tshell.close();\n \t\t\n \t\tTestMindProject.assertMindProject(name);\t\t\n \t}", "public Project() {\n\t}", "public Project() {\n\t}", "public static void main(String[] args) {\n\t\t\n\t\tSystem.out.println(\":Hi Hello from Project One\");\n\t\t\n\t}", "public static void main(String[] args) {\n\tArrayList<Dhb> dhb = new ArrayList<Dhb>();\n\tUtilities.load(dhb);\n\t\n\tProjectFrame gui = new ProjectFrame (dhb);\n\tgui.setVisible(true);\n\n\t}", "void setProject(InternalActionContext ac, HibProject project);", "public GantBuilder ( final Project project ) { super ( project ) ; }", "public static Project createAnyProject(File buildFile){\n\t\tProject antProject = new Project();\n\t\tantProject.init();\n\t\tDefaultLogger logger = new DefaultLogger();\n\t\tMessageConsole myConsole = Activator.findConsole();\n\t\tMessageConsoleStream out = myConsole.newMessageStream();\n\t\tlogger.setOutputPrintStream(new PrintStream(out));\n\t\tlogger.setMessageOutputLevel(Project.MSG_VERBOSE);\n\n\t\tActivator.showConsole(myConsole);\n\n\t\tProjectHelper.configureProject(antProject, buildFile);\n\t\tantProject.addBuildListener(logger);\n\t\treturn antProject;\n\t}", "public void loadProject(String projectContents, String langDefContents) {\n final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();\n final DocumentBuilder builder;\n final Document projectDoc;\n final Document langDoc;\n try {\n builder = factory.newDocumentBuilder();\n projectDoc = builder.parse(new InputSource(new StringReader(projectContents)));\n final Element projectRoot = projectDoc.getDocumentElement();\n langDoc = builder.parse(new InputSource(new StringReader(projectContents)));\n final Element langRoot = langDoc.getDocumentElement();\n if (workspaceLoaded) {\n resetWorkspace();\n }\n if (langDefContents == null) {\n loadBlockLanguage(langDefRoot);\n } else {\n loadBlockLanguage(langRoot);\n }\n workspace.loadWorkspaceFrom(projectRoot, langRoot);\n workspaceLoaded = true;\n\n } catch (ParserConfigurationException e) {\n throw new RuntimeException(e);\n } catch (SAXException e) {\n throw new RuntimeException(e);\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }", "protected abstract void processProjectFile(Path path);", "public int openExistingProject(File file) {\n try {\n projectData = projectLoader.openExistingProject(file);\n\n } catch (FileNotFoundException ex) {\n \n return 1; // can not find ini file\n } catch (Exception ex) {\n \n return 2; // can not load project\n }\n\n if (projectData == null) return 2;\n\n return 0;\n }", "public Project() {\n\n }", "private boolean createProject() {\r\n ProjectOverviewerApplication app = (ProjectOverviewerApplication)getApplication();\r\n Projects projects = app.getProjects();\r\n String userHome = System.getProperty(\"user.home\");\r\n // master file for projects management\r\n File projectsFile = new File(userHome + \"/.hackystat/projectoverviewer/projects.xml\");\r\n \r\n // create new project and add it to the projects\r\n Project project = new Project();\r\n project.setProjectName(this.projectName);\r\n project.setOwner(this.ownerName);\r\n project.setPassword(this.password);\r\n project.setSvnUrl(this.svnUrl);\r\n for (Project existingProject : projects.getProject()) {\r\n if (existingProject.getProjectName().equalsIgnoreCase(this.projectName)) {\r\n return false;\r\n }\r\n }\r\n projects.getProject().add(project);\r\n \r\n try {\r\n // create the specific tm3 file and xml file for the new project\r\n File tm3File = new File(userHome + \r\n \"/.hackystat/projectoverviewer/\" + this.projectName + \".tm3\");\r\n File xmlFile = new File(userHome + \r\n \"/.hackystat/projectoverviewer/\" + this.projectName + \".xml\");\r\n tm3File.createNewFile();\r\n \r\n // initialize the data for the file\r\n SensorDataCollector collector = new SensorDataCollector(app.getSensorBaseHost(), \r\n this.ownerName, \r\n this.password);\r\n collector.getRepository(this.svnUrl, this.projectName);\r\n collector.write(tm3File, xmlFile);\r\n } \r\n catch (IOException e) {\r\n e.printStackTrace();\r\n return false;\r\n }\r\n // write the projects.xml file with the new project added\r\n String packageName = \"org.hackystat.iw.projectoverviewer.jaxb.projects\";\r\n return XmlConverter.objectToXml(projects, projectsFile, packageName);\r\n }", "Builder forProjectDirectory(File projectDir);", "public Project(String name) {\n this.name = name;\n }", "public static void main(String[] args) {\r\n\t\tnew CreateDataModelForFile(PROJECT_NAME, RELATIVE_FILE_PATH).execute();\r\n\t}", "private void registerProject(String projectName, String... importNames) {\n Project p = new Project(projectName);\n List<ModelImport<Project>> imps = null;\n if (null != importNames) {\n imps = new ArrayList<ModelImport<Project>>();\n for (int i = 0; i < importNames.length; i++) {\n if (null != importNames[i] && importNames[i].length() > 0) {\n ProjectImport imp = new ProjectImport(importNames[i], null);\n p.addImport(imp);\n imps.add(imp);\n }\n }\n if (imps.isEmpty()) {\n imps = null;\n }\n }\n File file = new File(BASE, projectName + \".ivml\");\n // don't care whether this exists or not\n ModelInfo<Project> info = new ModelInfo<Project>(p.getName(), p.getVersion(), this, file.toURI(), imps);\n data.put(info, p);\n name2Info.put(projectName, info);\n }", "public static void main(String[] args) {\n String s = \"We are testing import statements\";\n System.out.println(s);\n\n // We use simple name because we specified location in the import\n // statement\n VineVegetable.main(args);\n }", "public void displayProject(Project project) {\n\t\tSystem.out.println(project.getID() + \" \"\n\t\t\t\t+ project.getProjectName() + \" \"\n\t\t\t\t+ project.getStartDate() + \" \"\n\t\t\t\t+ project.getEndDate() + \" \"\n\t\t\t\t+ project.getPriority());\n\t}", "Import createImport();" ]
[ "0.7216244", "0.59600896", "0.5924152", "0.5868919", "0.58046675", "0.5745555", "0.5745555", "0.5745555", "0.56815404", "0.5626591", "0.5566298", "0.5565983", "0.5531994", "0.5517575", "0.5516245", "0.5456876", "0.5451294", "0.5426538", "0.5369284", "0.5342035", "0.53381675", "0.5309404", "0.5303827", "0.5280062", "0.5268045", "0.52120167", "0.5199954", "0.5197854", "0.51977175", "0.5192284", "0.5184384", "0.5183758", "0.5180148", "0.51768565", "0.5171388", "0.51590526", "0.5149864", "0.51420563", "0.51409024", "0.5126426", "0.51133883", "0.51041424", "0.5098191", "0.5089162", "0.50865656", "0.505705", "0.50554514", "0.504783", "0.504162", "0.5040323", "0.50396544", "0.5032128", "0.5031266", "0.5022811", "0.5007052", "0.5006179", "0.4989764", "0.49882174", "0.4983844", "0.49837413", "0.49802038", "0.49756557", "0.49327326", "0.49251527", "0.49242246", "0.49223566", "0.49165338", "0.49119988", "0.4893405", "0.48921067", "0.48909506", "0.4889702", "0.48882934", "0.48833779", "0.48824087", "0.48710898", "0.4864905", "0.48609993", "0.48540285", "0.4844468", "0.4842338", "0.4841056", "0.4841056", "0.48198882", "0.48002222", "0.47986963", "0.47874582", "0.47783127", "0.47769573", "0.47728008", "0.47693685", "0.47652104", "0.47599244", "0.47586563", "0.4755413", "0.47533834", "0.47505835", "0.4749462", "0.4748265", "0.4745218" ]
0.53223324
21
Shows how to load a project from a Primavera XML file when project uid is known.
public static void readLoadPrimaveraXmlProject(String dataDir) { PrimaveraXmlReader reader = new PrimaveraXmlReader(dataDir + "PrimaveraProject.xml"); Project project = reader.loadProject(3882); System.out.println(project.getName()); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static void readProjectUidsFromXmlFile(String dataDir)\n {\n PrimaveraXmlReader reader = new PrimaveraXmlReader(dataDir + \"Primavera.xml\");\n List<Integer> projectUids = reader.getProjectUids();\n for (Integer projectUid : projectUids)\n {\n System.out.println(\"Project UID: \" + projectUid);\n }\n }", "public static void readProjectUidsFromStream(String dataDir) throws IOException\n {\n try (InputStream stream = Files.newInputStream(Paths.get(dataDir + \"Primavera.xml\"), StandardOpenOption.READ)){\n PrimaveraXmlReader reader = new PrimaveraXmlReader(stream);\n List<Integer> projectUids = reader.getProjectUids();\n for (Integer projectUid : projectUids)\n {\n System.out.println(\"Project UID: \" + projectUid);\n }\n }\n }", "public void loadTheProject() {\n\t\tProjectHandler.openProject(mFilePath);\n }", "public static void main(String[] args) throws IOException {\n String dataDir = Utils.getDataDir(PrimaveraXmlRead.class);\n\n readProjectUidsFromXmlFile(dataDir);\n\n readLoadPrimaveraXmlProject(dataDir);\n\n readProjectUidsFromStream(dataDir);\n\n // Display result of conversion.\n System.out.println(\"Process completed Successfully\");\n }", "public void loadProject(String arg) throws IOException {\n Project newProject = Project.readProject(arg);\n newProject.setConfiguration(project.getConfiguration());\n project = newProject;\n projectLoadedFromFile = true;\n }", "private ProjectMgr getPmNameTrueLoadActualProject() {\n ProjectMgr pm = null;\n try {\n pm = new ProjectMgr(\"Example\", true);\n\n } catch (ParserConfigurationException e) {\n e.printStackTrace();\n } catch (IOException e) {\n e.printStackTrace();\n } catch (SAXException e) {\n e.printStackTrace();\n }\n\n IOException e;\n return pm;\n }", "public void load()\n\t{\n\t\ttry {\n\t\t\tIFile file = project.getFile(PLAM_FILENAME);\n\t\t if (file.exists()) {\n\t\t\t\tInputStream stream= null;\n\t\t\t\ttry {\n\t\t\t\t\tstream = new BufferedInputStream(file.getContents(true));\n\t\t\t\t SAXReader reader = new SAXReader();\n\t\t\t\t Document document = reader.read(stream);\n\t\t\t\t \n\t\t\t\t Element root = document.getRootElement();\n\n\t\t\t\t String url = root.elementTextTrim(\"server-url\");\n\t\t\t\t setServerURL((url != null) ? new URL(url) : null);\n\t\t\t\t \n\t\t\t\t setUserName(root.elementTextTrim(\"username\"));\n\t\t\t\t setPassword(root.elementTextTrim(\"password\"));\n\t\t\t\t setProductlineId(root.elementTextTrim(\"pl-id\"));\n \n\t\t\t\t} catch (CoreException e) {\n\t\t\t\t\t\n\t\t\t\t} finally {\n\t\t\t\t if (stream != null)\n\t\t\t\t stream.close();\n\t\t\t\t}\n\t\t }\n\t\t} catch (DocumentException e) {\n\t\t\tlogger.info(\"Error while parsing PLAM config.\", e);\n\t\t} catch (IOException e) {\n\t\t}\n\t}", "public void load() {\r\n try {\r\n project = ProjectAccessor.findFromTitle(title, conn);\r\n } catch (SQLException e) {\r\n e.printStackTrace();\r\n }\r\n }", "public SCMLProject load(Element root)\n\t{\n\t\tthis.currentProject = new SCMLProject();\n\n\t\tloadAssets(root.getChildrenByName(\"folder\"));\n\t\tloadEntities(root.getChildrenByName(\"entity\"));\n\n\t\treturn currentProject;\n\t}", "public Project createProjectFromPRJ() {\n\n\t\tSystem.out.println(\"Trying to load prj file with : \" + data_path + \" \" + projectName + \" \" + conceptName + \" \");\n\n\t\tProject project = null;\n\n\t\ttry {\n\n\t\t\tproject = new Project(data_path + projectName);\n\n\t\t\t// Sehr wichtig hier das Warten einzubauen, sonst gibts leere\n\t\t\t// Retrieval Results, weil die Faelle noch nicht geladen sind wenn\n\t\t\t// das\n\t\t\t// Erste Retrieval laueft\n\t\t\twhile (project.isImporting()) {\n\t\t\t\tThread.sleep(1000);\n\t\t\t\tSystem.out.print(\".\");\n\t\t\t}\n\t\t\tSystem.out.print(\"\\n\"); // console pretty print\n\t\t} catch (Exception ex) {\n\n\t\t\tSystem.out.println(\"Error when loading the project\");\n\t\t}\n\t\treturn project;\n\t}", "public static TargetProject loadProject(String file) throws TargetException\r\n {\r\n TargetProject project = null;\r\n\r\n try\r\n {\r\n DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();\r\n DocumentBuilder docBuilder = factory.newDocumentBuilder();\r\n Document doc = docBuilder.parse(new File(file));\r\n String projectName = doc.getDocumentElement().getAttribute(\"name\");\r\n String rootDir = FileUtil.getFilePath(file);\r\n project = new TargetProject(projectName, rootDir);\r\n }\r\n catch (Exception e)\r\n {\r\n e.printStackTrace();\r\n throw new TargetException(\"The file \" + file + \" is not a valid TaRGeT project.\");\r\n }\r\n\r\n return project;\r\n }", "public static void main(String[] args) {\n\n Project project = new Project();\n project.setId(2L);\n project.setTitle(\"Title\");\n System.out.println(project);\n }", "private void loadProject()\n\t{\n\t\t\n\t\tint fileChooserReturnValue =\n\t\t\twindowTemplate\n\t\t\t\t.getFileChooser()\n\t\t\t\t.showOpenDialog(windowTemplate);\n\t\t\n\t\tif(fileChooserReturnValue == JFileChooser.APPROVE_OPTION) {\n\t\t\t// Delete the current cards\n\t\t\tdeleteAllCards();\n\t\t\t\n\t\t\t// Get the file that the user selected\n\t\t\tFile file = windowTemplate.getFileChooser().getSelectedFile();\n\t\t\t\n\t\t\ttry {\n\t\t\t\t\n\t\t\t\t// Open the input streams\n\t\t\t\tFileInputStream fileInput = new FileInputStream(file.getAbsolutePath());\n\t\t\t\tObjectInputStream objectInput = new ObjectInputStream(fileInput);\n\t\t\t\t\n\t\t\t\t// Get ready to save the cards\n\t\t\t\tArrayList<Card> newCards = new ArrayList<Card>();\n\t\t\t\t\n\t\t\t\t// Get the objects\n\t\t\t\ttry {\n\t\t\t\t\t\n\t\t\t\t\tObject inputObject = objectInput.readObject();\n\t\t\t\t\t\n\t\t\t\t\twhile(inputObject instanceof Card) {\n\t\t\t\t\t\t\n\t\t\t\t\t\t// Add the card\n\t\t\t\t\t\tnewCards.add((Card) inputObject);\n\t\t\t\t\t\t\n\t\t\t\t\t\t// Read the next object\n\t\t\t\t\t\tinputObject = objectInput.readObject();\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t} catch(EOFException e2) {\n\t\t\t\t\t\n\t\t\t\t\t// We've reached the end of the file, time to add the new project\n\t\t\t\t\taddCards(newCards);\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Close the input streams\n\t\t\t\tobjectInput.close();\n\t\t\t\tfileInput.close();\n\t\t\t\t\n\t\t\t\t// Update the title of the frame to reflect the current project\n\t\t\t\twindowTemplate.setTitle(file.getName());\n\t\t\t\t\n\t\t\t} catch (ClassNotFoundException | IOException e1) {\n\t\t\t\tJOptionPane.showMessageDialog(windowTemplate, \"Could not open the file.\");\n\t\t\t}\n\t\t}\n\t\t\n\t}", "public void readXmlFile() {\r\n try {\r\n ClassLoader classLoader = getClass().getClassLoader();\r\n File credentials = new File(classLoader.getResource(\"credentials_example.xml\").getFile());\r\n DocumentBuilderFactory Factory = DocumentBuilderFactory.newInstance();\r\n DocumentBuilder Builder = Factory.newDocumentBuilder();\r\n Document doc = Builder.parse(credentials);\r\n doc.getDocumentElement().normalize();\r\n username = doc.getElementsByTagName(\"username\").item(0).getTextContent();\r\n password = doc.getElementsByTagName(\"password\").item(0).getTextContent();\r\n url = doc.getElementsByTagName(\"url\").item(0).getTextContent();\r\n setUsername(username);\r\n setPassword(password);\r\n setURL(url);\r\n } catch (Exception error) {\r\n System.out.println(\"Error in parssing the given xml file: \" + error.getMessage());\r\n }\r\n }", "Project createProject();", "Project createProject();", "Project createProject();", "@XmlElement(name = \"project\")\n public URI getProject() {\n return project;\n }", "org.apache.ant.common.model.Project parseXMLBuildFile(java.io.File xmlBuildFile) throws org.apache.ant.common.util.ExecutionException;", "public SCMLProject load(String xml)\n\t{\n\t\tXmlReader reader = new XmlReader();\n\t\treturn load(reader.parse(xml));\n\t}", "public void openProject(File pfile, FileOpenSelector files) { }", "public void loadProjectFromElement(Element elementToLoad) {\n workspace.loadWorkspaceFrom(elementToLoad, langDefRoot);\n workspaceLoaded = true;\n }", "public SCMLProject load(InputStream stream)\n\t{\n\t\tXmlReader reader = new XmlReader();\n\t\treturn load(reader.parse(stream));\n\t}", "public Project getProject(Long projectId);", "private Project(){}", "LectureProject createLectureProject();", "public ProjectViewController(){\n InputStream request = appController.httpRequest(\"http://localhost:8080/project/getProject\", \"GET\");\n try {\n String result = IOUtils.toString(request, StandardCharsets.UTF_8);\n Gson gson = new Gson();\n this.projectModel = gson.fromJson(result, ProjectModel.class);\n } catch (IOException e) {\n e.printStackTrace();\n }\n }", "public ProjectsPage() {\n\t\tthis.driver = DriverManager.getDriver();\n\t\tElementFactory.initElements(driver, this);\n\t\t// sets the name of the project to add, with a random integer ending for slight\n\t\t// ease on multiple test runs\n\t\tnameOfProject = \"testz2018\" + (int) Math.random() * 500;\n\t}", "public void showProjectContext(@NonNull final Project project) {\n Picasso.with(getApplicationContext()).load(project.photo().full())\n .into(projectPhotoImageView);\n projectNameTextView.setText(project.name());\n creatorNameTextView.setText(project.creator().name());\n }", "public Project getProjectByName(String name);", "public void showLoadXML(Properties p);", "public static ProjectManager retrieveProjects(String userinfo) throws IOException {\r\n\t\t//ProjectManager to be returned after populating with project.\r\n\t\tProjectManager retrieved = new ProjectManager();\r\n\t\tString projectString = \"\";\r\n\t\tFileReader fr;\r\n\t\tBufferedReader br;\r\n\t\t\r\n\t\tFile file = new File(userinfo+\".txt\");\r\n\t\tfr = new FileReader(file);\r\n\t\tbr = new BufferedReader(fr);\r\n\t\t\r\n\t\t//Attributes of projects.\r\n\t\tString projectname;\r\n\t\tString projecttype;\r\n\t\tint projecthour;\r\n\t\tint projectcost;\r\n\t\tString[] tokens; //Array of project attributes.\r\n\t\t\r\n\t\t//Read file, create project accordingly and add to the project manager.\r\n\t\twhile((projectString = br.readLine()) != null) {\r\n\t\t\ttokens = projectString.split(\",\");\r\n\t\t\tprojectname = tokens[0];\r\n\t\t\tprojectcost = Integer.parseInt(tokens[1]);\r\n\t\t\tprojecthour = Integer.parseInt(tokens[2]);\r\n\t\t\tprojecttype = tokens[3];\r\n\t\t\t\r\n\t\t\t//Create the project with found attribute, add.\r\n\t\t\tProject project = new Project(projecttype, projectname, projectcost, projecthour);\r\n\t\t\tretrieved.addProject(project);\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\tfr.close();\r\n\t\tbr.close();\r\n\t\treturn retrieved;\r\n\t}", "public Project getProject(int projectId) throws EmployeeManagementException;", "private void loadProjects() {\n\t\tprojectsList.clear();\n\t\t\n\t\tArrayList<Job> projects = jdbc.getProjects();\n\t\tfor (Job j : projects) {\n\t\t\tprojectsList.addElement(j.jobname);\n\t\t}\n\t}", "Project getProject();", "public Project(String name){\n\t\tthis.pName = name;\n\t}", "public void loadProjectTree(Long id) {\n rootId = id;\n editResourceService.getResources(id, new AsyncCallback<List<VMResource>>() {\n @Override\n public void onFailure(Throwable caught) {\n SC.warn(caught.getMessage());\n }\n\n @Override\n public void onSuccess(List<VMResource> result) {\n if (rootId == id) {\n VMDirectory rootDir = new VMDirectory();\n rootDir.setId(rootId);\n rootDir.setName(\"/\");\n fileTreeNodeFactory.setRootDirectory(rootDir);\n }\n TreeNode[] nodes = fileTreeNodeFactory.getFileTreeNodes(id, result);\n tree = new Tree();\n tree.setDefaultIsFolder(true);\n tree.setShowRoot(true);\n tree.setModelType(TreeModelType.CHILDREN);\n tree.setNameProperty(\"fullName\");\n tree.setData(nodes);\n treeGrid.setData(tree);\n treeGrid.sort();\n }\n });\n }", "private void browseProject()\n {\n List<FileFilter> filters = new ArrayList<>();\n filters.add(new FileNameExtensionFilter(\"Bombyx3D project file\", \"yml\"));\n\n File directory = new File(projectPathEdit.getText());\n File selectedFile = FileDialog.chooseOpenFile(this, BROWSE_DIALOG_TITLE, directory, filters);\n if (selectedFile != null) {\n projectDirectory = selectedFile.getParentFile();\n projectPathEdit.setText(projectDirectory.getPath());\n projectPathEdit.selectAll();\n }\n }", "public static MapList getCurrentUserProjects(Context context, String[] args) throws MatrixException {\n MapList projectList = new MapList();\n try {\n // rp3 : This needs to be tested to make sure the result creates no issue and returns the same set\n projectList = (MapList) JPO.invoke(context, \"emxProjectSpace\", null, \"getAllProjects\", args, MapList.class);\n\n // rp3 : Replace this code with the JPO invoke from the program central API.\n /*\n * com.matrixone.apps.common.Person person = (com.matrixone.apps.common.Person) DomainObject.newInstance(context, DomainConstants.TYPE_PERSON); com.matrixone.apps.program.ProjectSpace\n * project = (com.matrixone.apps.program.ProjectSpace) DomainObject.newInstance(context, DomainConstants.TYPE_PROJECT_SPACE,DomainConstants.PROGRAM);\n * \n * String ctxPersonId = person.getPerson(context).getId(); person.setId(ctxPersonId);\n * \n * //System.out.println(\"the project id is \" + ctxPersonId);\n * \n * StringList busSelects = new StringList(11); busSelects.add(project.SELECT_ID); busSelects.add(project.SELECT_TYPE); busSelects.add(project.SELECT_NAME);\n * busSelects.add(project.SELECT_CURRENT);\n * \n * //projectList = project.getUserProjects(context,person,null,null,null,null); // expand to get project members Pattern typePattern = new Pattern(DomainConstants.TYPE_PROJECT_SPACE);\n * typePattern.addPattern(DomainConstants.TYPE_PROJECT_CONCEPT);\n * \n * projectList = (person.getRelatedObjects( context, // context DomainConstants.RELATIONSHIP_MEMBER, // relationship pattern typePattern.getPattern(), // type filter. busSelects, //\n * business selectables null, // relationship selectables true, // expand to direction false, // expand from direction (short) 1, // level null, // object where clause null)); //\n * relationship where clause\n */\n\n // System.out.println(\"the project list is \" + projectList);\n } catch (Exception ex) {\n throw (new MatrixException(\"emxMsoiPMCUtil:getCurrentUserProjects : \" + ex.toString()));\n }\n return projectList;\n }", "protected void loadAndSetProject() {\n final ApplicationMetadata meta = getSpeedmentApplicationMetadata();\n final Project project;\n \n if (meta != null) {\n project = DocumentTranscoder.load(meta.getMetadata());\n } else {\n final Map<String, Object> data = new ConcurrentHashMap<>();\n data.put(HasName.NAME, \"Project\");\n project = new ProjectImpl(data);\n }\n\n // Apply overidden item (if any) for all ConfigEntities of a given class\n withsAll.forEach(t2 -> {\n final Class<? extends Document> clazz = t2.get0();\n @SuppressWarnings(\"unchecked\")\n final Consumer<Document> consumer = (Consumer<Document>) t2.get1();\n DocumentDbUtil.traverseOver(project)\n .filter(clazz::isInstance)\n .map(Document.class::cast)\n .forEachOrdered(consumer::accept);\n });\n\n // Apply a named overidden item (if any) for all Entities of a given class\n withsNamed.forEach(t3 -> {\n final Class<? extends Document> clazz = t3.get0();\n final String name = t3.get1();\n\n @SuppressWarnings(\"unchecked\")\n final Consumer<Document> consumer = (Consumer<Document>) t3.get2();\n\n DocumentDbUtil.traverseOver(project)\n .filter(clazz::isInstance)\n .filter(HasName.class::isInstance)\n .map(HasName.class::cast)\n .filter(c -> name.equals(relativeName(c, Project.class, DATABASE_NAME)))\n .forEachOrdered(consumer::accept);\n });\n\n speedment.getProjectComponent().setProject(project);\n }", "@Test\n\tpublic void testEmptyProject() throws ParserConfigurationException, SAXException, IOException, DrillXMLException {\n\t\tFile testFile = new File(path + \"1-empty-project.pnd\");\n\t\t\n\t\t//create the xml parser\n\t\tXMLParser parser = new XMLParser();\n\t\t\n\t\t//parse the file\n\t\tDrillInfo drillInfo = parser.load(testFile);\n\t\t\n\t\t//test\n\t\tAssert.assertEquals(new DrillInfo(), drillInfo);\n\t}", "@Override\n\tpublic Project readProjectDetail(Project project) {\n\t\tif (project == null)\n\t\t\treturn null;\n\n\t\t// To do: uncomment\n\t\tif (project.getProjectManager1Id() > 0)\n\t\t\t;\n\t\t\t//project.setProjectManager1Name(employeeDao.getEmployeeNameById(project.getProjectManager1Id()));\n\t\tif (project.getProjectManager2Id() > 0)\n\t\t\t;\n\t\t\t//project.setProjectManager2Name(employeeDao.getEmployeeNameById(project.getProjectManager2Id()));\n\n\t\treturn project;\n\t}", "private void readXML() {\n\t\tSAXParserFactory factory = SAXParserFactory.newInstance();\n\t\tXMLReader handler = new XMLReader();\n\t\tSAXParser parser;\n\t\t\n\t\t//Parsing xml file\n\t\ttry {\n\t\t\tparser = factory.newSAXParser();\n\t\t\tparser.parse(\"src/data/users.xml\", handler);\n\t\t\tgroupsList = handler.getGroupNames();\n\t\t} catch(SAXException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (ParserConfigurationException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t};\n\t}", "@Override\n\tpublic List<ProjectInfo> findProject(ProjectInfo project) {\n\t\treturn sqlSession.selectList(\"cn.sep.samp2.project.findProject\",project);\n\t}", "Project findProjectById(String projectId);", "public void load(Project.NameKey projectName, Repository db)\n throws IOException, ConfigInvalidException {\n Ref ref = db.getRefDatabase().exactRef(getRefName());\n load(projectName, db, ref != null ? ref.getObjectId() : null);\n }", "public void openProject(File file) {\n\n try {\n if (!file.exists()) {\n JOptionPane.showMessageDialog(Application.getFrame(),\n \"Can't open project - file \\\"\" + file.getPath() + \"\\\" does not exist\",\n \"Can't Open Project\", JOptionPane.OK_OPTION);\n return;\n }\n \n getApplication().getFrameController().addToLastProjListAction(\n file.getAbsolutePath());\n\n Configuration config = buildProjectConfiguration(file);\n Project project = new ApplicationProject(file, config);\n getProjectController().setProject(project);\n\n // if upgrade was canceled\n int upgradeStatus = project.getUpgradeStatus();\n if (upgradeStatus > 0) {\n JOptionPane\n .showMessageDialog(\n Application.getFrame(),\n \"Can't open project - it was created using a newer version of the Modeler\",\n \"Can't Open Project\",\n JOptionPane.OK_OPTION);\n closeProject(false);\n }\n else if (upgradeStatus < 0) {\n if (processUpgrades(project)) {\n getApplication().getFrameController().projectOpenedAction(project);\n }\n else {\n closeProject(false);\n }\n }\n else {\n getApplication().getFrameController().projectOpenedAction(project);\n }\n }\n catch (Exception ex) {\n logObj.warn(\"Error loading project file.\", ex);\n ErrorDebugDialog.guiWarning(ex, \"Error loading project\");\n }\n }", "public static void main(String[] args) {\r\n new ParseVimeoXMLFile();\r\n }", "protected abstract void processProjectFile(Path path);", "public void notifyNewProject(URI project) {\n\t\tDebug.log(\"Loading uninitialized project \", project);\n\t\tnotifyNewProjectFiles(new File(project));\n\t}", "public int openExistingProject(File file) {\n try {\n projectData = projectLoader.openExistingProject(file);\n\n } catch (FileNotFoundException ex) {\n \n return 1; // can not find ini file\n } catch (Exception ex) {\n \n return 2; // can not load project\n }\n\n if (projectData == null) return 2;\n\n return 0;\n }", "public static void main(String[] args)\n {\n URL xmlURL = RpgConfMain.class.getResource(\"/baseList.xml\");\n\n if(xmlURL == null)\n {\n System.out.println(\"Failed to read xml file, xmlURL was null\");\n System.exit(-1);\n }\n\n //Getting the xml file\n try(InputStream xmlStream = (InputStream) xmlURL.getContent())\n {\n //Reading the xml file\n xmlReader = new StructXMLReader(xmlStream);\n } catch (IOException | XMLStreamException e)\n {\n System.exit(-1);\n e.printStackTrace();\n }\n\n MainFrame frame = new MainFrame(new ConfigCode(), xmlReader); //Used before initialization is wrong. If the xmlReader\n //variable is wrong, the program will exit\n\n frame.setVisible(true);\n }", "public abstract KenaiProject getKenaiProject(String url, String projectName) throws IOException;", "public IProject getProject();", "public Project(File file)\n {\n super(file);\n this.open();\n }", "public static final String getProject() { return project; }", "public static final String getProject() { return project; }", "private static IProjectConfiguration loadFromPersistence(IProject project)\n throws CheckstylePluginException\n {\n IProjectConfiguration configuration = null;\n \n //\n // Make sure the files exists, it might not.\n //\n IFile file = project.getFile(PROJECT_CONFIGURATION_FILE);\n boolean exists = file.exists();\n if (!exists)\n {\n\n List checkConfigs = CheckConfigurationFactory.getCheckConfigurations();\n FileSet standardFileSet = new FileSet(Messages.SimpleFileSetsEditor_nameAllFileset,\n (ICheckConfiguration) checkConfigs.get(0));\n standardFileSet.getFileMatchPatterns().add(new FileMatchPattern(\".*\"));\n\n List fileSets = Arrays.asList(new Object[] { standardFileSet });\n return new ProjectConfiguration(project, null, fileSets, null, true);\n }\n \n InputStream inStream = null;\n try\n {\n inStream = file.getContents(true);\n \n ProjectConfigFileHandler handler = new ProjectConfigFileHandler(project);\n XMLUtil.parseWithSAX(inStream, handler);\n \n configuration = handler.getConfiguration();\n }\n catch (CoreException ce)\n {\n CheckstylePluginException.rethrow(ce);\n }\n catch (SAXException se)\n {\n Exception ex = se.getException() != null ? se.getException() : se;\n CheckstylePluginException.rethrow(ex);\n }\n catch (ParserConfigurationException pe)\n {\n CheckstylePluginException.rethrow(pe);\n }\n catch (IOException ioe)\n {\n CheckstylePluginException.rethrow(ioe);\n }\n \n finally\n {\n IOUtils.closeQuietly(inStream);\n }\n \n return configuration;\n }", "public void loadProjectFromPath(final String path) throws IOException\n {\n final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();\n factory.setNamespaceAware(true);\n final DocumentBuilder builder;\n final Document doc;\n try {\n builder = factory.newDocumentBuilder();\n doc = builder.parse(new File(path));\n\n // XXX here, we could be strict and only allow valid documents...\n // validate(doc);\n final Element projectRoot = doc.getDocumentElement();\n //load the canvas (or pages and page blocks if any) blocks from the save file\n //also load drawers, or any custom drawers from file. if no custom drawers\n //are present in root, then the default set of drawers is loaded from\n //langDefRoot\n workspace.loadWorkspaceFrom(projectRoot, langDefRoot);\n workspaceLoaded = true;\n } catch (ParserConfigurationException e) {\n throw new RuntimeException(e);\n } catch (SAXException e) {\n throw new RuntimeException(e);\n }\n }", "public void populate(IProject project) throws InvocationTargetException;", "public void testRetrieveProjectsById() throws RetrievalException {\r\n System.out.println(\"Demo 4: Retrieves the projects by id.\");\r\n\r\n // Retrieve a known project\r\n ExternalProject project = defaultDBProjectRetrieval.retrieveProject(2);\r\n System.out.println(project.getId());\r\n\r\n // Outputs its info.\r\n System.out.println(project.getComponentId());\r\n System.out.println(project.getForumId());\r\n System.out.println(project.getName());\r\n System.out.println(project.getVersion());\r\n System.out.println(project.getVersionId());\r\n System.out.println(project.getDescription());\r\n System.out.println(project.getComments());\r\n System.out.println(project.getShortDescription());\r\n System.out.println(project.getFunctionalDescription());\r\n String[] technologies = project.getTechnologies(); // should not be null\r\n for (int t = 0; t < technologies.length; t++) {\r\n System.out.println(\"Uses technology: \" + technologies[t]);\r\n }\r\n\r\n // Not found ĘC should be null which is acceptable\r\n ExternalProject shouldBeNull = defaultDBProjectRetrieval.retrieveProject(Long.MAX_VALUE);\r\n System.out.println(shouldBeNull);\r\n\r\n // Should only have a maximum of 1 entry.\r\n ExternalProject[] projects = defaultDBProjectRetrieval.retrieveProjects(new long[] {1, 100});\r\n System.out.println(projects.length);\r\n System.out.println(projects[0].getName());\r\n\r\n System.out.println();\r\n }", "com.appscode.api.auth.v1beta1.Project getProject();", "public void getProject(){\n\t\n\t String getList[] = clientFacade.GetProjects().split(\"\\n\");\n\t DefaultComboBoxModel addPro = new DefaultComboBoxModel();\n\t\tfor(int i=1; i<getList.length; i+=2) \n\t\t\t addPro.addElement(getList[i]);\n\t\t\t \n\t\tcPro.setModel(addPro);\t\n\t}", "public static Project exampleProject() throws ParseException {\n Person willem = new Person(\"Contractor\", \"Willem du Plessis\", \"074 856 4561\", \"willem@dup.com\",\n \"452 Tugela Avenue\");\n Person rene = new Person(\"Architect\", \"Rene Malan\", \"074 856 4561\", \"rene@malan\", \"452 Tugela Avenue\");\n Person tish = new Person(\"Client\", \"Tish du Plessis\", \"074 856 4561\", \"tish@dup.com\", \"452 Tugela Avenue\");\n Date deadline = dateformat.parse(\"30/03/2021\");\n Project housePlessis = new Project(789, \"House Plessis\", \"House\", \"102 Jasper Avenue\", \"1025\", 20000, 5000,\n deadline, willem, rene, tish);\n ProjectList.add(housePlessis);\n\n return housePlessis;\n }", "public Project() {\n\t\t\n\t}", "@Test\n // Test Load\n public void loadTest() {\n ProjectMgr pmNew = getPmNameFalseLoad();\n try {\n pmNew.load(\"not-gunna-be-a-file\");\n Assertions.fail(\"An io exception should be thrown. This line should not be reached\");\n } catch (ParserConfigurationException e) {\n e.printStackTrace();\n } catch (SAXException e) {\n e.printStackTrace();\n } catch (IOException e) {\n\n }\n\n // Load project\n ProjectMgr pmLoad = getPmNameTrueLoadActualProject();\n try {\n pmLoad.load(\"not-gunna-be-a-file\");\n Assertions.fail(\"An io exception should be thrown. This line should not be reached\");\n } catch (ParserConfigurationException e) {\n e.printStackTrace();\n } catch (SAXException e) {\n e.printStackTrace();\n } catch (IOException e) {\n\n }\n\n // TODO: ParserConfigurationExceptin and SAXException not tested\n }", "private void setProject()\n\t{\n\t\tproject.setName(tf0.getValue().toString());\n \t\tproject.setDescription(tf8.getValue().toString());\n \t\tproject.setEndDate(df4.getValue());\n \t\tif (sf6.getValue().toString().equals(\"yes\"))project.setActive(true);\n \t\telse project.setActive(false);\n \t\tif (!tf7.getValue().toString().equals(\"\"))project.setBudget(Float.parseFloat(tf7.getValue().toString()));\n \t\telse project.setBudget(-1);\n \t\tproject.setNextDeadline(df5.getValue());\n \t\tproject.setStartDate(df3.getValue());\n \t\ttry \n \t\t{\n \t\t\t\tif (sf1.getValue()!=null)\n\t\t\t\tproject.setCustomerID(db.selectCustomerforName( sf1.getValue().toString()));\n\t\t}\n \t\tcatch (SQLException|java.lang.NullPointerException e) \n \t\t{\n \t\t\tErrorWindow wind = new ErrorWindow(e); \n \t UI.getCurrent().addWindow(wind);\t\t\n \t e.printStackTrace();\n\t\t\t}\n \t\tproject.setInserted_by(\"Grigoris\");\n \t\tproject.setModified_by(\"Grigoris\");\n \t\tproject.setRowversion(1);\n \t\tif (sf2.getValue()!=null)project.setProjectType(sf2.getValue().toString());\n \t\telse project.setProjectType(null);\n\t }", "public void loadProject(String jsonString)\n\t{\n\t\ttry\n\t\t{\n\t\t\tJSONObject jsonInput = (JSONObject)JSONValue.parse(jsonString);\n\t\t\tif (jsonInput == null)\n\t\t\t{\n\t\t\t\tview.alert(\"Error: Error loading project\");\n\t\t\t}\n\n\t\t\tif (jsonInput.get(\"project\") != null)\n\t\t\t{\n\t\t\t\tJSONObject jsonProject = (JSONObject)jsonInput.get(\"project\");\n\t\t\t\tstoreViewState();\n\t\t\t\tproject.loadProject(jsonProject.toJSONString());\n\t\t\t\tcheckStatus();\n\t\t\t\t\n\t\t\t\tif (project.getLastCommandStatus())\n\t\t\t\t{\n\t\t\t\t\tview.loadFromJSON(jsonString);\n\t\t\t\t\tview.onUpdate(project.getProjectSnapshot(), false);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tstoreViewState();\n\t\t\t\tproject.loadProject(jsonString);\n\t\t\t\tcheckStatus();\n\t\t\t}\n\t\t}\n\t\tcatch (ClassCastException e)\n\t\t{\n\t\t\tview.alert(\"Error: Error loading project\");\n\t\t}\n\t}", "public static void main(String[] args) {\n String dataDir = Utils.getDataDir(ConfigureGanttChartView.class);\n\n Project project = new Project(dataDir + \"project.mpp\");\n\n // Create a new project task\n Task task = project.getRootTask().getChildren().add(\"New Activity\");\n\n // Define new custom attribute\n ExtendedAttributeDefinition text1Definition = ExtendedAttributeDefinition.createTaskDefinition(ExtendedAttributeTask.Text1, null);\n project.getExtendedAttributes().add(text1Definition);\n // Add custom text attribute to created task.\n task.getExtendedAttributes().add(text1Definition.createExtendedAttribute(\"Activity attribute\"));\n\n // Customize table by adding text attribute field\n TableField attrField = new TableField();\n attrField.setField(Field.TaskText1);\n attrField.setWidth(20);\n attrField.setTitle(\"Custom attribute\");\n attrField.setAlignTitle(StringAlignment.Center);\n attrField.setAlignData(StringAlignment.Center);\n\n Table table = project.getTables().toList().get(0);\n table.getTableFields().add(3, attrField);\n\n // The result of opening of saved project in MSP2010 is in attached screenshot\n project.save(\"saved.mpp\", SaveFileFormat.Mpp);\n }", "public project() {\n\n initComponents();\n }", "Project getByPrjNumber(Integer num);", "public void loadProject(String projectContents, String langDefContents) {\n final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();\n final DocumentBuilder builder;\n final Document projectDoc;\n final Document langDoc;\n try {\n builder = factory.newDocumentBuilder();\n projectDoc = builder.parse(new InputSource(new StringReader(projectContents)));\n final Element projectRoot = projectDoc.getDocumentElement();\n langDoc = builder.parse(new InputSource(new StringReader(projectContents)));\n final Element langRoot = langDoc.getDocumentElement();\n if (workspaceLoaded) {\n resetWorkspace();\n }\n if (langDefContents == null) {\n loadBlockLanguage(langDefRoot);\n } else {\n loadBlockLanguage(langRoot);\n }\n workspace.loadWorkspaceFrom(projectRoot, langRoot);\n workspaceLoaded = true;\n\n } catch (ParserConfigurationException e) {\n throw new RuntimeException(e);\n } catch (SAXException e) {\n throw new RuntimeException(e);\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }", "public Project() {\n this.name = \"Paper plane\";\n this.description = \" It's made of paper.\";\n }", "@SuppressWarnings(\"serial\")\n\tpublic ProjectPage() {\n\t\tagregarForm();\n\t}", "private void importAll() {\n\t\tfinal JFileChooser chooser = new JFileChooser(System.getProperty(\"user.home\"));\n\t\tint returnVal = chooser.showOpenDialog(null);\n\t\tif(returnVal == JFileChooser.APPROVE_OPTION) {\n\t\t\tFile file = chooser.getSelectedFile();\n\t\t\tdeserializeFile(file);\n\t\t\t // imported the projects for this application from a file, so update what should be persisted on close\n\t\t\tupdatePersistence();\n\t\t}\n\t}", "public void displayProject(Project project) {\n\t\tSystem.out.println(project.getID() + \" \"\n\t\t\t\t+ project.getProjectName() + \" \"\n\t\t\t\t+ project.getStartDate() + \" \"\n\t\t\t\t+ project.getEndDate() + \" \"\n\t\t\t\t+ project.getPriority());\n\t}", "public void setProject(Project project) {\n this.project = project;\n }", "public void setProject(Project project) {\n this.project = project;\n }", "public static void main(String[] args) {\n String dataDir = Utils.getDataDir(HandleExceptions.class);\n\n try {\n new Project(dataDir + \"project.mpp\");\n } catch (TasksReadingException ex) {\n System.out.print(\"Message: \");\n System.out.println(ex.getMessage());\n System.out.print(\"Log: \");\n System.out.println(ex.getLogText());\n\n if (ex.getCause() != null) {\n System.out.print(\"Inner exception message: \");\n System.out.println(ex.getCause().getMessage());\n }\n } catch (Exception e) {\n System.out.println(e.getMessage());\n }\n }", "TrackerProjects loadTrackerProjects(final Integer id);", "@GET\n\t@Path(\"getParticularProject/{projectId}\")\n\t@Produces(MediaType.APPLICATION_JSON)\n\tpublic Response getParticularProject(\n\t\t\t@PathParam(\"projectId\") Integer projectId) throws Exception {\n\n\t\tProjectTO projectTO = null;\n\n\t\ttry {\n\t\t\tHashMap<String, Object> queryMap = new HashMap<String, Object>();\n\t\t\tqueryMap.put(\"projectId\", projectId);\n\n\t\t\tProjectMaster project = (ProjectMaster) GenericDaoSingleton\n\t\t\t\t\t.getGenericDao().findUniqueByQuery(\n\t\t\t\t\t\t\tConstantQueries.GET_PARTICULAR_PROJECT_BY_ID,\n\t\t\t\t\t\t\tqueryMap);\n\n\t\t\tif (project == null) {\n\t\t\t\tSystem.out.println(\"Project not found\");\n\t\t\t\tprojectTO = null;\n\t\t\t\treturn Response.status(Response.Status.NOT_FOUND)\n\t\t\t\t\t\t.entity(projectTO).build();\n\t\t\t}\n\n\t\t\tprojectTO = new ProjectTO();\n\t\t\t// projectMaster = (Object[]) projectList.get(i);\n\t\t\tprojectTO.setProject_id(project.getProject_id());\n\t\t\tprojectTO.setProject_name(project.getProject_name());\n\t\t\tprojectTO.setProject_status(project.getProject_status());\n\t\t\tprojectTO.setProject_creation_date(project\n\t\t\t\t\t.getProject_creation_date());\n\t\t\tprojectTO.setAccount_id(project.getAccountMaster().getAccount_id());\n\n\t\t\treturn Response.status(Response.Status.OK).entity(projectTO)\n\t\t\t\t\t.build();\n\t\t} catch (Exception e) {\n\n\t\t\te.printStackTrace();\n\t\t\tprojectTO = null;\n\t\t\tSystem.out\n\t\t\t\t\t.println(\"Error while getting Projects in Project Config service\");\n\t\t\treturn Response.status(Response.Status.INTERNAL_SERVER_ERROR)\n\t\t\t\t\t.entity(projectTO).build();\n\t\t}\n\n\t}", "public Project(Long projectId) {\n this.id = projectId;\n this.groups = new HashSet<>();\n this.nextGroupId = 0L;\n this.symbols = new HashSet<>();\n this.nextSymbolId = 1L;\n\n this.userId = 0L;\n this.mirrorUrls = \"\";\n }", "public void init() {\n- newProject = new Project();\n- newProject.setDefaultInputStream(getProject().getDefaultInputStream());\n+ newProject = getProject().createSubProject();\n newProject.setJavaVersionProperty();\n }", "public void projectOpened(File pfile, FileOpenSelector files) { }", "HibProject getProject(InternalActionContext ac);", "@GetMapping(\"/byName\")\r\n\tpublic List<Project> getProject(Principal principal) {\r\n\t\treturn persistenceService.getProject(AppBuilderUtil.getLoggedInUserId());\r\n\t}", "public Project() {\n\t}", "public Project() {\n\t}", "public Project getProjectWithEmployee(int projectId) throws EmployeeManagementException;", "private void loadFromXml(String fileName) throws IOException {\n\t\tElement root = new XmlReader().parse(Gdx.files.internal(fileName));\n\n\t\tthis.name = root.get(\"name\");\n\t\tGdx.app.log(\"Tactic\", \"Loading \" + this.name + \"...\");\n\n\t\tArray<Element> players = root.getChildrenByName(\"player\");\n\t\tint playerIndex = 0;\n\t\tfor (Element player : players) {\n\t\t\t//int shirt = player.getInt(\"shirt\"); // shirt number\n\t\t\t//Gdx.app.log(\"Tactic\", \"Location for player number \" + shirt);\n\n\t\t\t// regions\n\t\t\tArray<Element> regions = player.getChildrenByName(\"region\");\n\t\t\tfor (Element region : regions) {\n\t\t\t\tString regionName = region.get(\"name\"); // region name\n\n\t\t\t\tthis.locations[playerIndex][Location.valueOf(regionName).ordinal()] = new Vector2(region.getFloat(\"x\"), region.getFloat(\"y\"));\n\n\t\t\t\t//Gdx.app.log(\"Tactic\", locationId + \" read\");\n\t\t\t}\n\t\t\tplayerIndex++;\n\t\t}\t\n\t}", "public project_piramide() {\n initComponents();\n }", "public ProjectFile getProject()\r\n {\r\n return m_project;\r\n }", "public static void loadBioPAX(String filepath, String ownerName, String db) throws Exception{\n\t\tFile f = new File(filepath);\n\t\tString title = f.getName();\n\t\tFileInputStream fin = new FileInputStream(f);\n\t\tBioPAXIOHandler handler = new SimpleIOHandler();\n\t\tModel model = handler.convertFromOWL(fin);\n\t\tloadBioPAXModel(model, title, ownerName, db);\n\t}", "private void parseFile(Project p, File f, ImportSettings settings, int pass)\n throws ImportException {\n\n\n try {\n BufferedInputStream bs = new BufferedInputStream(new FileInputStream(f));\n Lexer l = new Lexer(bs, f.getAbsolutePath());\n TokenCollection toks = l.lex();\n Parser px = new Parser();\n CompilationUnitNode cu = px.parse(toks, l.StringLiterals);\n parsedElements.add(cu);\n } catch (FeatureNotSupportedException e) {\n //throw new ImportException(\"Error parsing file: \" + f.getAbsolutePath() + \" due to: \"+e.getMessage());\n System.out.println(\"Error parsing file: \" + f.getAbsolutePath() + \" due to: \"+e.getMessage());\n } catch (Exception e) {\n// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.\n// throw new ImportException(\"Error parsing file: \" + f.getAbsolutePath());\n System.out.println(\"Error parsing file: \" + f.getAbsolutePath());\n }\n\n }", "private void initializeWithDefaultValues() {\n setProjectFolder(\"projectFolder\");\n setContext(\"context\");\n setGroupId(\"com.company.project\");\n setArtifactId(\"project\");\n setModulePrefix(\"project-\");\n setVersion(\"0.0.1-SNAPSHOT\");\n setName(\"Project Name\");\n setDescription(\"Project Description\");\n setUrl(\"https://www.company-project.com\");\n setInceptionYear(String.valueOf(LocalDateTime.now().getYear()));\n setOrganizationName(\"Your Company Name\");\n setOrganizationUrl(\"https://www.company.com\");\n setLicenseName(\"apache_v2\");\n setLicenseUrl(\"https://www.license-url.com\");\n setScmConnection(\"\");\n setScmDeveloperConnection(\"\");\n setScmUrl(\"\");\n setDistributionProfile(\"\");\n setExtraModules(new LinkedHashSet<>());\n setContextDescriptions(new LinkedHashSet<>());\n setAppConfigLocationType(AppConfigLocationType.INSIDE);\n }", "public void readxml() throws JAXBException, FileNotFoundException {\n Player loadplayer = xml_methods.load();\n logger.info(\"player name: \" + loadplayer.getName());\n if (!item.isEmpty()) {\n logger.trace(loadplayer.getitem(0).getName());\n }\n tfName.setText(loadplayer.getName());\n isset = true;\n player = loadplayer;\n\n }", "public abstract ProjectBean getSystemProject();", "public void setProjectID(Integer projectID) { this.projectID = projectID; }", "public AddProject() {\n try\n {\n infDB = new InfDB(\"\\\\Users\\\\Oliver\\\\Documents\\\\Skola\\\\Mini_sup\\\\Realisering\\\\MICEDB.FDB\");\n System.out.println(\"Uppkopplingen lyckades\");\n }\n catch(InfException e)\n {\n System.out.println(e.getMessage());\n }\n \n try\n {\n infDB = new InfDB(\"C:\\\\Users\\\\TP300LA-C4034\\\\Desktop\\\\Delkurs 4, Lill-supen\\\\InformatikDB\\\\MICEDB.FDB\");\n System.out.println(\"Uppkopplingen lyckades\");\n }\n catch(InfException e)\n {\n System.out.println(e.getMessage());\n }\n getPlatforms();\n initComponents();\n setLocationRelativeTo(null);\n \n }", "public Tbl_Projects getProjectInforFromPMS(String projectName) throws AncestryException\n\t{\n\t\tTbl_Projects project = new Tbl_Projects();\n\t\tConnection con = null;\n\t\tResultSet rs = null;\n\t\tString sql = \"\";\n\t\ttry {\n\t\t\tsql = \"SELECT proj_serverip ,proj_schema , proj_dbname , proj_uid , proj_pwd FROM tbl_projects p WHERE proj_name='\"+projectName+\"'\";\n\t\t\tcon = db.getConPMSByHost(db.host);\n\t\t\trs = JdbcHelper.queryToResultset(con, sql);\n\t\t\tif(rs.next()) {\n\t\t\t\tproject.setProj_serverip(rs.getString(\"proj_serverip\"));\n\t\t\t\tproject.setProj_dbname(rs.getString(\"proj_dbname\"));\n\t\t\t\tproject.setProj_uid(rs.getString(\"proj_uid\"));\n\t\t\t\tproject.setProj_pwd(rs.getString(\"proj_pwd\"));\n\t\t\t\tproject.setProj_schema(rs.getString(\"proj_schema\"));\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tthrow new AncestryException(\"getProjectInforFromPMS : \" + e.toString() ,e);\n\t\t}\n\t\tfinally {\n\t\t\tJdbcHelper.closeRS(rs);\n\t\t\tJdbcHelper.close(con);\n\t\t}\n\t\treturn project;\n\t}" ]
[ "0.6903477", "0.6527997", "0.62628365", "0.618968", "0.6158685", "0.61578786", "0.5967506", "0.5906964", "0.589323", "0.5876012", "0.57615966", "0.55888164", "0.5468985", "0.5463871", "0.542879", "0.542879", "0.542879", "0.5416367", "0.5412763", "0.53603184", "0.5335198", "0.53061855", "0.52859694", "0.52573305", "0.52490777", "0.52256507", "0.52166045", "0.52154535", "0.5203228", "0.5196776", "0.51831615", "0.5179681", "0.5154429", "0.513708", "0.5131895", "0.51056254", "0.50729257", "0.5062756", "0.50564367", "0.50536567", "0.5039549", "0.5030625", "0.5005403", "0.4999703", "0.49974582", "0.49964157", "0.49954158", "0.4994363", "0.49942484", "0.49885458", "0.49883062", "0.49644974", "0.4963297", "0.49601915", "0.4957194", "0.49476886", "0.49476886", "0.49421477", "0.4936087", "0.49253634", "0.49178734", "0.49017653", "0.48982462", "0.48951605", "0.4890518", "0.48863432", "0.48819175", "0.4880073", "0.48786747", "0.48759368", "0.487035", "0.48621348", "0.48615277", "0.4860999", "0.48587996", "0.48511937", "0.4850255", "0.4850255", "0.48449796", "0.48419", "0.48416004", "0.4841379", "0.4839648", "0.48348233", "0.48337576", "0.48262092", "0.48229605", "0.48229605", "0.48215905", "0.48189983", "0.4811682", "0.4800168", "0.47904572", "0.47894463", "0.47887605", "0.47844923", "0.4782914", "0.47785863", "0.47670758", "0.47639108" ]
0.7464808
0
Shows how to import a project from a Primavera XML stream.
public static void readProjectUidsFromStream(String dataDir) throws IOException { try (InputStream stream = Files.newInputStream(Paths.get(dataDir + "Primavera.xml"), StandardOpenOption.READ)){ PrimaveraXmlReader reader = new PrimaveraXmlReader(stream); List<Integer> projectUids = reader.getProjectUids(); for (Integer projectUid : projectUids) { System.out.println("Project UID: " + projectUid); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static void readLoadPrimaveraXmlProject(String dataDir)\n {\n PrimaveraXmlReader reader = new PrimaveraXmlReader(dataDir + \"PrimaveraProject.xml\");\n Project project = reader.loadProject(3882);\n System.out.println(project.getName());\n }", "public SCMLProject load(InputStream stream)\n\t{\n\t\tXmlReader reader = new XmlReader();\n\t\treturn load(reader.parse(stream));\n\t}", "public static void main(String[] args) throws IOException {\n String dataDir = Utils.getDataDir(PrimaveraXmlRead.class);\n\n readProjectUidsFromXmlFile(dataDir);\n\n readLoadPrimaveraXmlProject(dataDir);\n\n readProjectUidsFromStream(dataDir);\n\n // Display result of conversion.\n System.out.println(\"Process completed Successfully\");\n }", "public SCMLProject load(String xml)\n\t{\n\t\tXmlReader reader = new XmlReader();\n\t\treturn load(reader.parse(xml));\n\t}", "public void showLoadXML(Properties p);", "public Project createProjectFromPRJ() {\n\n\t\tSystem.out.println(\"Trying to load prj file with : \" + data_path + \" \" + projectName + \" \" + conceptName + \" \");\n\n\t\tProject project = null;\n\n\t\ttry {\n\n\t\t\tproject = new Project(data_path + projectName);\n\n\t\t\t// Sehr wichtig hier das Warten einzubauen, sonst gibts leere\n\t\t\t// Retrieval Results, weil die Faelle noch nicht geladen sind wenn\n\t\t\t// das\n\t\t\t// Erste Retrieval laueft\n\t\t\twhile (project.isImporting()) {\n\t\t\t\tThread.sleep(1000);\n\t\t\t\tSystem.out.print(\".\");\n\t\t\t}\n\t\t\tSystem.out.print(\"\\n\"); // console pretty print\n\t\t} catch (Exception ex) {\n\n\t\t\tSystem.out.println(\"Error when loading the project\");\n\t\t}\n\t\treturn project;\n\t}", "public void loadProject(String arg) throws IOException {\n Project newProject = Project.readProject(arg);\n newProject.setConfiguration(project.getConfiguration());\n project = newProject;\n projectLoadedFromFile = true;\n }", "public void open(){\n\t\ttry {\n\t\t\tdocFactory = DocumentBuilderFactory.newInstance();\n\t\t\tdocBuilder = docFactory.newDocumentBuilder();\n\t\t\tdoc = docBuilder.parse(ManipXML.class.getResourceAsStream(path));\n\t\t\t\n\t\t} catch (ParserConfigurationException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (SAXException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}", "public void loadTheProject() {\n\t\tProjectHandler.openProject(mFilePath);\n }", "org.apache.ant.common.model.Project parseXMLBuildFile(java.io.File xmlBuildFile) throws org.apache.ant.common.util.ExecutionException;", "public static void main(String[] args) {\n\n Project project = new Project();\n project.setId(2L);\n project.setTitle(\"Title\");\n System.out.println(project);\n }", "Project createProject();", "Project createProject();", "Project createProject();", "public static void main(String[] args) {\r\n new ParseVimeoXMLFile();\r\n }", "public SCMLProject load(Element root)\n\t{\n\t\tthis.currentProject = new SCMLProject();\n\n\t\tloadAssets(root.getChildrenByName(\"folder\"));\n\t\tloadEntities(root.getChildrenByName(\"entity\"));\n\n\t\treturn currentProject;\n\t}", "public void load()\n\t{\n\t\ttry {\n\t\t\tIFile file = project.getFile(PLAM_FILENAME);\n\t\t if (file.exists()) {\n\t\t\t\tInputStream stream= null;\n\t\t\t\ttry {\n\t\t\t\t\tstream = new BufferedInputStream(file.getContents(true));\n\t\t\t\t SAXReader reader = new SAXReader();\n\t\t\t\t Document document = reader.read(stream);\n\t\t\t\t \n\t\t\t\t Element root = document.getRootElement();\n\n\t\t\t\t String url = root.elementTextTrim(\"server-url\");\n\t\t\t\t setServerURL((url != null) ? new URL(url) : null);\n\t\t\t\t \n\t\t\t\t setUserName(root.elementTextTrim(\"username\"));\n\t\t\t\t setPassword(root.elementTextTrim(\"password\"));\n\t\t\t\t setProductlineId(root.elementTextTrim(\"pl-id\"));\n \n\t\t\t\t} catch (CoreException e) {\n\t\t\t\t\t\n\t\t\t\t} finally {\n\t\t\t\t if (stream != null)\n\t\t\t\t stream.close();\n\t\t\t\t}\n\t\t }\n\t\t} catch (DocumentException e) {\n\t\t\tlogger.info(\"Error while parsing PLAM config.\", e);\n\t\t} catch (IOException e) {\n\t\t}\n\t}", "public void testImportXML() throws RepositoryException, IOException{\n String path = \"path\";\n InputStream stream = new ByteArrayInputStream(new byte[0]);\n session.importXML(path, stream, 0);\n \n sessionControl.replay();\n sfControl.replay();\n \n jt.importXML(path, stream, 0);\n }", "@Test\n\tpublic void testEmptyProject() throws ParserConfigurationException, SAXException, IOException, DrillXMLException {\n\t\tFile testFile = new File(path + \"1-empty-project.pnd\");\n\t\t\n\t\t//create the xml parser\n\t\tXMLParser parser = new XMLParser();\n\t\t\n\t\t//parse the file\n\t\tDrillInfo drillInfo = parser.load(testFile);\n\t\t\n\t\t//test\n\t\tAssert.assertEquals(new DrillInfo(), drillInfo);\n\t}", "private static Document parseXML(InputStream stream) throws Exception {\n DocumentBuilderFactory objDocumentBuilderFactory = null;\n DocumentBuilder objDocumentBuilder = null;\n Document doc = null;\n try {\n objDocumentBuilderFactory = DocumentBuilderFactory.newInstance();\n objDocumentBuilder = objDocumentBuilderFactory.newDocumentBuilder();\n doc = objDocumentBuilder.parse(stream);\n } catch (Exception ex) {\n throw ex;\n }\n return doc;\n }", "public ProjectInfoDialog(String project, String dataset, String inputCsv, String transitionsXml, \n\t\t\t\t\tint numberOfSchemas, int numberOfTransitions, int numberOfTables) {\n\t\tsetBounds(100, 100, 479, 276);\n\t\tgetContentPane().setLayout(new BorderLayout());\n\t\tcontentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));\n\t\tgetContentPane().add(contentPanel, BorderLayout.CENTER);\n\t\t\n\t\tJLabel lblSchemas = new JLabel(\"Schemas:\");\n\t\tlblSchemas.setFont(new Font(\"Tahoma\", Font.BOLD, 12));\n\t\t\n\t\tJLabel labelNumberOfSch = new JLabel(\"-\");\n\t\tlabelNumberOfSch.setFont(new Font(\"Tahoma\", Font.PLAIN, 12));\n\t\t\n\t\tlabelNumberOfSch.setText(Integer.toString(numberOfSchemas));\n\t\t\n\t\tJLabel lblTransitions = new JLabel(\"Transitions:\");\n\t\tlblTransitions.setFont(new Font(\"Tahoma\", Font.BOLD, 12));\n\t\t\n\t\tJLabel labelNumberOfTr = new JLabel(\"-\");\n\t\tlabelNumberOfTr.setFont(new Font(\"Tahoma\", Font.PLAIN, 12));\n\t\tlabelNumberOfTr.setText(Integer.toString(numberOfTransitions));\n\n\t\t\n\t\tJLabel lblTables = new JLabel(\"Tables:\");\n\t\tlblTables.setFont(new Font(\"Tahoma\", Font.BOLD, 12));\n\t\t\n\t\tJLabel labelNumberOfTables = new JLabel(\"-\");\n\t\tlabelNumberOfTables.setFont(new Font(\"Tahoma\", Font.PLAIN, 12));\n\t\tlabelNumberOfTables.setText(Integer.toString(numberOfTables));\n\t\t\n\t\tJLabel lblProjectName = new JLabel(\"Project Name\");\n\t\tlblProjectName.setFont(new Font(\"Tahoma\", Font.BOLD, 12));\n\t\t\n\t\tJLabel labelPrName = new JLabel(\"-\");\n\t\tlabelPrName.setFont(new Font(\"Tahoma\", Font.PLAIN, 12));\n\t\tlabelPrName.setText(project);\n\n\t\t\n\t\tJLabel lblDatasetTxt = new JLabel(\"Dataset Txt\");\n\t\tlblDatasetTxt.setFont(new Font(\"Tahoma\", Font.BOLD, 12));\n\t\t\n\t\tJLabel lblDataTxt = new JLabel(\"-\");\n\t\tlblDataTxt.setFont(new Font(\"Tahoma\", Font.PLAIN, 12));\n\t\tlblDataTxt.setText(dataset);\n\n\t\t\n\t\tJLabel lblInput = new JLabel(\"Input Csv\");\n\t\tlblInput.setFont(new Font(\"Tahoma\", Font.BOLD, 12));\n\t\t\n\t\tJLabel labelInCsv = new JLabel(\"-\");\n\t\tlabelInCsv.setFont(new Font(\"Tahoma\", Font.PLAIN, 12));\n\t\tlabelInCsv.setText(inputCsv);\n\n\t\t\n\t\tJLabel lblTransitionsFile = new JLabel(\"Transitions File\");\n\t\tlblTransitionsFile.setFont(new Font(\"Tahoma\", Font.BOLD, 12));\n\t\t\n\t\tJLabel labelTrFile = new JLabel(\"-\");\n\t\tlabelTrFile.setFont(new Font(\"Tahoma\", Font.PLAIN, 12));\n\t\tlabelTrFile.setText(transitionsXml);\n\n\n\t\t\n\t\tGroupLayout gl_contentPanel = new GroupLayout(contentPanel);\n\t\tgl_contentPanel.setHorizontalGroup(\n\t\t\tgl_contentPanel.createParallelGroup(Alignment.LEADING)\n\t\t\t\t.addGroup(gl_contentPanel.createSequentialGroup()\n\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING)\n\t\t\t\t\t\t.addComponent(lblSchemas, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)\n\t\t\t\t\t\t.addGroup(gl_contentPanel.createSequentialGroup()\n\t\t\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)\n\t\t\t\t\t\t\t\t.addGroup(gl_contentPanel.createSequentialGroup()\n\t\t\t\t\t\t\t\t\t.addComponent(lblTables, GroupLayout.PREFERRED_SIZE, 59, GroupLayout.PREFERRED_SIZE)\n\t\t\t\t\t\t\t\t\t.addGap(196))\n\t\t\t\t\t\t\t\t.addGroup(gl_contentPanel.createSequentialGroup()\n\t\t\t\t\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING, false)\n\t\t\t\t\t\t\t\t\t\t.addComponent(lblTransitions, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)\n\t\t\t\t\t\t\t\t\t\t.addComponent(lblProjectName, Alignment.LEADING)\n\t\t\t\t\t\t\t\t\t\t.addComponent(lblDatasetTxt, Alignment.LEADING)\n\t\t\t\t\t\t\t\t\t\t.addComponent(lblInput, Alignment.LEADING)\n\t\t\t\t\t\t\t\t\t\t.addComponent(lblTransitionsFile, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))\n\t\t\t\t\t\t\t\t\t.addGap(13)\n\t\t\t\t\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)\n\t\t\t\t\t\t\t\t\t\t.addComponent(labelPrName, GroupLayout.DEFAULT_SIZE, 207, Short.MAX_VALUE)\n\t\t\t\t\t\t\t\t\t\t.addComponent(lblDataTxt, GroupLayout.DEFAULT_SIZE, 207, Short.MAX_VALUE)\n\t\t\t\t\t\t\t\t\t\t.addGroup(gl_contentPanel.createSequentialGroup()\n\t\t\t\t\t\t\t\t\t\t\t.addPreferredGap(ComponentPlacement.UNRELATED)\n\t\t\t\t\t\t\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)\n\t\t\t\t\t\t\t\t\t\t\t\t.addComponent(labelTrFile, GroupLayout.DEFAULT_SIZE, 207, Short.MAX_VALUE)\n\t\t\t\t\t\t\t\t\t\t\t\t.addComponent(labelInCsv, GroupLayout.DEFAULT_SIZE, 207, Short.MAX_VALUE)\n\t\t\t\t\t\t\t\t\t\t\t\t.addComponent(labelNumberOfSch, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE)\n\t\t\t\t\t\t\t\t\t\t\t\t.addComponent(labelNumberOfTr, GroupLayout.PREFERRED_SIZE, 85, GroupLayout.PREFERRED_SIZE)\n\t\t\t\t\t\t\t\t\t\t\t\t.addComponent(labelNumberOfTables, GroupLayout.PREFERRED_SIZE, 62, GroupLayout.PREFERRED_SIZE))))))\n\t\t\t\t\t\t\t.addPreferredGap(ComponentPlacement.RELATED)))\n\t\t\t\t\t.addGap(0))\n\t\t);\n\t\tgl_contentPanel.setVerticalGroup(\n\t\t\tgl_contentPanel.createParallelGroup(Alignment.TRAILING)\n\t\t\t\t.addGroup(gl_contentPanel.createSequentialGroup()\n\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)\n\t\t\t\t\t\t.addComponent(lblProjectName)\n\t\t\t\t\t\t.addComponent(labelPrName))\n\t\t\t\t\t.addPreferredGap(ComponentPlacement.RELATED)\n\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)\n\t\t\t\t\t\t.addComponent(lblDatasetTxt)\n\t\t\t\t\t\t.addComponent(lblDataTxt))\n\t\t\t\t\t.addPreferredGap(ComponentPlacement.RELATED)\n\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)\n\t\t\t\t\t\t.addComponent(labelInCsv)\n\t\t\t\t\t\t.addComponent(lblInput))\n\t\t\t\t\t.addPreferredGap(ComponentPlacement.RELATED)\n\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)\n\t\t\t\t\t\t.addComponent(labelTrFile)\n\t\t\t\t\t\t.addComponent(lblTransitionsFile))\n\t\t\t\t\t.addPreferredGap(ComponentPlacement.RELATED, 27, Short.MAX_VALUE)\n\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)\n\t\t\t\t\t\t.addComponent(lblSchemas)\n\t\t\t\t\t\t.addComponent(labelNumberOfSch))\n\t\t\t\t\t.addPreferredGap(ComponentPlacement.RELATED)\n\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)\n\t\t\t\t\t\t.addComponent(lblTransitions)\n\t\t\t\t\t\t.addComponent(labelNumberOfTr))\n\t\t\t\t\t.addPreferredGap(ComponentPlacement.UNRELATED)\n\t\t\t\t\t.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)\n\t\t\t\t\t\t.addComponent(lblTables)\n\t\t\t\t\t\t.addComponent(labelNumberOfTables))\n\t\t\t\t\t.addGap(27))\n\t\t);\n\t\tcontentPanel.setLayout(gl_contentPanel);\n\t\t{\n\t\t\tJPanel buttonPane = new JPanel();\n\t\t\tbuttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));\n\t\t\tgetContentPane().add(buttonPane, BorderLayout.SOUTH);\n\t\t\t{\n\t\t\t\tJButton okButton = new JButton(\"OK\");\n\t\t\t\tokButton.addActionListener(new ActionListener() {\n\t\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tsetVisible(false);\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tokButton.setActionCommand(\"OK\");\n\t\t\t\tbuttonPane.add(okButton);\n\t\t\t\tgetRootPane().setDefaultButton(okButton);\n\t\t\t}\n\t\t}\n\t}", "void open(IdeaProject project);", "public void init() {\n- newProject = new Project();\n- newProject.setDefaultInputStream(getProject().getDefaultInputStream());\n+ newProject = getProject().createSubProject();\n newProject.setJavaVersionProperty();\n }", "public void testXML() {\n // check XML Entity Catalogs\n\n // \"Tools\"\n String toolsItem = Bundle.getStringTrimmed(\"org.netbeans.core.ui.resources.Bundle\", \"Menu/Tools\"); // NOI18N\n // \"DTDs and XML Schemas\"\n String dtdsItem = Bundle.getStringTrimmed(\"org.netbeans.modules.xml.catalog.Bundle\", \"LBL_CatalogAction_Name\");\n new Action(toolsItem + \"|\" + dtdsItem, null).perform();\n // \"DTDs and XML Schemas\"\n String dtdsTitle = Bundle.getString(\"org.netbeans.modules.xml.catalog.Bundle\", \"LBL_CatalogPanel_Title\");\n NbDialogOperator dtdsOper = new NbDialogOperator(dtdsTitle);\n\n String publicID = \"-//DTD XMLCatalog//EN\";\n Node catalogNode = new Node(new JTreeOperator(dtdsOper),\n \"NetBeans Catalog|\"\n + publicID);\n // view and close it\n new ViewAction().perform(catalogNode);\n new EditorOperator(publicID).close();\n dtdsOper.close();\n\n // create an XML file\n\n // create xml package\n // select Source Packages to not create xml folder in Test Packages\n new SourcePackagesNode(SAMPLE_PROJECT_NAME).select();\n // \"Java Classes\"\n String javaClassesLabel = Bundle.getString(\"org.netbeans.modules.java.project.Bundle\", \"Templates/Classes\");\n NewJavaFileWizardOperator.create(SAMPLE_PROJECT_NAME, javaClassesLabel, \"Java Package\", null, \"xml\"); // NOI18N\n Node xmlNode = new Node(new SourcePackagesNode(SAMPLE_PROJECT_NAME), \"xml\"); //NOI18N\n // \"XML\"\n String xmlCategory = Bundle.getString(\"org.netbeans.api.xml.resources.Bundle\", \"Templates/XML\");\n // \"XML Document\"\n String xmlDocument = Bundle.getString(\"org.netbeans.modules.xml.resources.Bundle\", \"Templates/XML/XMLDocument.xml\");\n NewFileWizardOperator.invoke(xmlNode, xmlCategory, xmlDocument);\n NewJavaFileNameLocationStepOperator nameStepOper = new NewJavaFileNameLocationStepOperator();\n nameStepOper.setObjectName(\"XMLDocument\"); // NOI18N\n nameStepOper.next();\n nameStepOper.finish();\n // wait node is present\n Node xmlDocumentNode = new Node(xmlNode, \"XMLDocument.xml\"); // NOI18N\n // wait xml document is open in editor\n new EditorOperator(\"XMLDocument.xml\").close(); // NOI18N\n\n // \"Check XML\"\n\n String checkXMLItem = Bundle.getStringTrimmed(\"org.netbeans.modules.xml.tools.actions.Bundle\", \"NAME_Check_XML\");\n // invoke context action to check xml\n new Action(null, checkXMLItem).perform(xmlDocumentNode);\n // \"XML check\"\n String xmlCheckTitle = Bundle.getString(\"org.netbeans.modules.xml.actions.Bundle\", \"TITLE_XML_check_window\");\n // find and close an output with the result of xml check\n new OutputTabOperator(xmlCheckTitle).close();\n\n // \"Validate XML\"\n\n String validateItem = Bundle.getStringTrimmed(\"org.netbeans.modules.xml.tools.actions.Bundle\", \"NAME_Validate_XML\");\n // invoke context action to validate xml\n new Action(null, validateItem).perform(xmlDocumentNode);\n // find and close an output with the result of xml validation\n new OutputTabOperator(xmlCheckTitle).close();\n\n // \"Generate DTD...\"\n\n String generateDTDItem = Bundle.getStringTrimmed(\"org.netbeans.modules.xml.tools.generator.Bundle\", \"PROP_GenerateDTD\");\n new ActionNoBlock(null, generateDTDItem).perform(xmlDocumentNode);\n // \"Select File Name\"\n String selectTitle = Bundle.getString(\"org.netbeans.modules.xml.tools.generator.Bundle\", \"PROP_fileNameTitle\");\n NbDialogOperator selectDialog = new NbDialogOperator(selectTitle);\n // name has to be set because of issue http://www.netbeans.org/issues/show_bug.cgi?id=46049\n new JTextFieldOperator(selectDialog).setText(\"DTD\");\n String oKLabel = Bundle.getString(\"org.netbeans.core.windows.services.Bundle\", \"OK_OPTION_CAPTION\");\n new JButtonOperator(selectDialog, oKLabel).push();\n // wait DTD is open in editor\n new EditorOperator(\"DTD.dtd\").close(); // NOI18N\n Node dtdNode = new Node(xmlNode, \"DTD.dtd\"); // NOI18N\n\n // \"Check DTD\"\n\n String checkDTDItem = Bundle.getStringTrimmed(\"org.netbeans.modules.xml.tools.actions.Bundle\", \"NAME_Validate_DTD\");\n new Action(null, checkDTDItem).perform(dtdNode);\n // find and close an output with the result of dtd check\n new OutputTabOperator(xmlCheckTitle).close();\n\n // \"Generate DOM Tree Scanner\"\n String generateScannerItem = Bundle.getStringTrimmed(\"org.netbeans.modules.xml.tools.generator.Bundle\", \"PROP_GenerateDOMScanner\");\n new ActionNoBlock(null, generateScannerItem).perform(dtdNode);\n selectDialog = new NbDialogOperator(selectTitle);\n new JButtonOperator(selectDialog, oKLabel).push();\n // wait Scanner is open in editor\n new EditorOperator(\"DTDScanner.java\").close(); // NOI18N\n new Node(xmlNode, \"DTDScanner.java\"); // NOI18N\n }", "private void importAll() {\n\t\tfinal JFileChooser chooser = new JFileChooser(System.getProperty(\"user.home\"));\n\t\tint returnVal = chooser.showOpenDialog(null);\n\t\tif(returnVal == JFileChooser.APPROVE_OPTION) {\n\t\t\tFile file = chooser.getSelectedFile();\n\t\t\tdeserializeFile(file);\n\t\t\t // imported the projects for this application from a file, so update what should be persisted on close\n\t\t\tupdatePersistence();\n\t\t}\n\t}", "private Project(){}", "@XmlElement(name = \"project\")\n public URI getProject() {\n return project;\n }", "@Override\n\tpublic void importXML(String nodePath, ByteArrayInputStream bis,\n\t\t\tint typeImport) throws Exception {\n\n\t}", "private void actionImport() {\n ImportPanel myPanel = new ImportPanel();\n int result = JOptionPane.showConfirmDialog(this, myPanel, \"Import\",\n JOptionPane.OK_CANCEL_OPTION);\n if (result == JOptionPane.OK_OPTION) { // Afirmative\n readNeuronListFromFile(\n myPanel.tfields[ImportPanel.idxInhList].getText(),\n layoutPanel.inhNList, LayoutPanel.INH);\n readNeuronListFromFile(\n myPanel.tfields[ImportPanel.idxActList].getText(),\n layoutPanel.activeNList, LayoutPanel.ACT);\n readNeuronListFromFile(\n myPanel.tfields[ImportPanel.idxPrbList].getText(),\n layoutPanel.probedNList, LayoutPanel.PRB);\n\n Graphics g = layoutPanel.getGraphics();\n layoutPanel.writeToGraphics(g);\n }\n }", "public ImportFromURLAction(){\n\t\tsuper();\n\t\tsetText(\"Import from remote OMPL document\");\n\t\tsetImageDescriptor(ImageDescriptor.createFromFile(ImportFromURLAction.class,\"/images/importfromurl.png\"));\n\t\tsetToolTipText(\"Import a group of feeds from a remote OPML file\");\n\t}", "public static void testXmlImport() {\n\n }", "public static void readProjectUidsFromXmlFile(String dataDir)\n {\n PrimaveraXmlReader reader = new PrimaveraXmlReader(dataDir + \"Primavera.xml\");\n List<Integer> projectUids = reader.getProjectUids();\n for (Integer projectUid : projectUids)\n {\n System.out.println(\"Project UID: \" + projectUid);\n }\n }", "public PioneeringMission(AIMain aiMain, XMLStreamReader in)\n throws XMLStreamException {\n super(aiMain);\n readFromXML(in);\n }", "public static void main(String args[])\n {\n LoadFileSupport sample = new LoadFileSupport();\n sample.createNewInstance(\"C:/pavan/j2eeWork/ws-studio-ie-workspace/xml-test/HTMLtoXSLProject/IncomingTimber/LoadSampleSample.xml\");\n sample.loadExistingInstance(\"C:/pavan/j2eeWork/ws-studio-ie-workspace/xml-test/HTMLtoXSLProject/IncomingTimber/LoadSampleSample.xml\");\n }", "public static void main(String[] args) {\n String dataDir = Utils.getDataDir(HandleExceptions.class);\n\n try {\n new Project(dataDir + \"project.mpp\");\n } catch (TasksReadingException ex) {\n System.out.print(\"Message: \");\n System.out.println(ex.getMessage());\n System.out.print(\"Log: \");\n System.out.println(ex.getLogText());\n\n if (ex.getCause() != null) {\n System.out.print(\"Inner exception message: \");\n System.out.println(ex.getCause().getMessage());\n }\n } catch (Exception e) {\n System.out.println(e.getMessage());\n }\n }", "public void importPackage(String pack) throws Exception;", "public TpImport(){\r\n\t\t\r\n\t}", "public static void main(String[] args) {\n new MySaxParserEx(\"ProductCatalog.xml\");\n\n }", "private void importXMLSchema(Import bpelImport) {\n \tString namespace = bpelImport.getNamespace();\n \tString location = bpelImport.getLocation();\n \tif (location == null) {\n mLogger.severe(\"Unable to import schema document, import location is null \" + bpelImport);\n throw new XMLParseVisitorException(\"Unable to import schema document, import location is null \" + bpelImport);\n }\n \t\n \tLazyImportVisitorService vService = (LazyImportVisitorService) getVisitorService();\n \tBPELParseContext bpelParseContext = vService.getBPELParseContext();\n \tIXSDResolver xsdResolver = bpelParseContext.getXSDResolver();\n \t\n \tif(xsdResolver == null) {\n \t\tmLogger.severe(\"Unable to import schema document, must specify XSD Resolver \" + bpelImport);\n throw new XMLParseVisitorException(\"Unable to import schema document, must specify XSD Resolver \" + bpelImport);\n \t}\n \t\n \ttry {\n\t \tXMLSchema xsdDocument = xsdResolver.resolve(namespace, location);\n\t \n\t if(xsdDocument == null) {\n\t \tmLogger.severe(\"Unable to import schema document for import \" + bpelImport);\n\t throw new XMLParseVisitorException(\"Unable to import schema document for import \" + bpelImport);\t\n\t }\n\t \n\t bpelImport.setImportedObject(xsdDocument);\n \n } catch (EInsightModelException e) {\n mLogger.log(Level.SEVERE, \"Unable to import xsd document for import \" + bpelImport, e);\n throw new XMLParseVisitorException(\"Unable to import xsd document for import \" + bpelImport, e);\n }\n \n }", "public ProjectViewController(){\n InputStream request = appController.httpRequest(\"http://localhost:8080/project/getProject\", \"GET\");\n try {\n String result = IOUtils.toString(request, StandardCharsets.UTF_8);\n Gson gson = new Gson();\n this.projectModel = gson.fromJson(result, ProjectModel.class);\n } catch (IOException e) {\n e.printStackTrace();\n }\n }", "private void initializeProject() {\n newProject.setInputHandler(getProject().getInputHandler());\n \n Iterator iter = getBuildListeners();\n while (iter.hasNext()) {\n newProject.addBuildListener((BuildListener) iter.next());\n }\n \n if (output != null) {\n File outfile = null;\n if (dir != null) {\n outfile = FILE_UTILS.resolveFile(dir, output);\n } else {\n outfile = getProject().resolveFile(output);\n }\n try {\n out = new PrintStream(new FileOutputStream(outfile));\n DefaultLogger logger = new DefaultLogger();\n logger.setMessageOutputLevel(Project.MSG_INFO);\n logger.setOutputPrintStream(out);\n logger.setErrorPrintStream(out);\n newProject.addBuildListener(logger);\n } catch (IOException ex) {\n log(\"Ant: Can't set output to \" + output);\n }\n }\n-\n- getProject().initSubProject(newProject);\n-\n // set user-defined properties\n getProject().copyUserProperties(newProject);\n \n if (!inheritAll) {\n // set Java built-in properties separately,\n // b/c we won't inherit them.\n newProject.setSystemProperties();\n \n } else {\n // set all properties from calling project\n addAlmostAll(getProject().getProperties());\n }\n \n Enumeration e = propertySets.elements();\n while (e.hasMoreElements()) {\n PropertySet ps = (PropertySet) e.nextElement();\n addAlmostAll(ps.getProperties());\n }\n }", "public void convertAll() {\n Document dom = null;\n long beginTime = System.currentTimeMillis();\n try {\n log.info(\" ############################### begin import ######################\");\n dom = XMLParser.parseXMLToDOM(context.getResourceAsStream(IMPORT_FILE));\n // XMLParser.DTDValidator(dom);\n Element element = (Element) dom.getElementsByTagName(\"import\").item(0);\n String encoding = element.getAttribute(\"encoding\");\n DataAccessor.encoding = encoding;\n\n NodeList list = element.getChildNodes();\n\n List<Data> clondSources = new ArrayList<Data>();\n for (int i = 0; i < list.getLength(); i++) {\n // datatype node\n Node itemDatatype = list.item(i);\n List<Data> sources = processDatatype(itemDatatype);\n clondSources.addAll(sources);\n }\n NodeService.insertMigrationMappings(clondSources);\n createRelationDataType(clondSources);\n linkRoot(list);\n log.info(String.format(\n \" ---->#######################finished importing [time:%s mins] #############################\",\n (System.currentTimeMillis() - beginTime) / (1000 * 60)));\n NodeService.insertProperties(properties);\n }\n catch (Exception e) {\n log.error(e.getMessage());\n e.printStackTrace();\n }\n }", "public void load() {\r\n try {\r\n project = ProjectAccessor.findFromTitle(title, conn);\r\n } catch (SQLException e) {\r\n e.printStackTrace();\r\n }\r\n }", "public static void main(String[] args) {\n\t\tXStream xstream = new XStreamEx(new DomDriver());\r\n\t\txstream.alias(\"AIPG\", AIPG.class);\r\n\t\txstream.alias(\"INFO\", InfoReq.class);\r\n\t\r\n\t\t\r\n\t\t\r\n\t\txstream.alias(\"RET_DETAIL\", Ret_Detail.class);\r\n \t\txstream.aliasField(\"RET_DETAILS\", Body.class, \"details\");\r\n\t\r\n\r\n\t\t\r\n//\t\txstream.aliasField(\"TRX->CODE1\", Info.class, \"TRX_CODE\");\r\n\t\t\r\n\t\tAIPG g = new AIPG( );\r\n\t\tInfoRsp info = new InfoRsp( );\r\n\t\tinfo.setTRX_CODE(\"-----\");\r\n\t\tinfo.setVERSION(\"03\");\r\n\t\tg.setINFO(info);\r\n\t\t\r\n\t\tBody body = new Body( );\r\n//\t\tTrans_Sum transsum = new Trans_Sum( );\r\n\t\tRet_Detail detail=new Ret_Detail();\r\n\t\tdetail.setSN(\"woshi\");\r\n\t body.addDetail(detail);\r\n\t \r\n\t\t\r\n\t\tg.setBODY(body);\r\n\t\tSystem.out.println(xstream.toXML(g).replaceAll(\"__\", \"_\"));\r\n\t\t\r\n\t\t\r\n\t}", "public static void main(String[] args)\n {\n URL xmlURL = RpgConfMain.class.getResource(\"/baseList.xml\");\n\n if(xmlURL == null)\n {\n System.out.println(\"Failed to read xml file, xmlURL was null\");\n System.exit(-1);\n }\n\n //Getting the xml file\n try(InputStream xmlStream = (InputStream) xmlURL.getContent())\n {\n //Reading the xml file\n xmlReader = new StructXMLReader(xmlStream);\n } catch (IOException | XMLStreamException e)\n {\n System.exit(-1);\n e.printStackTrace();\n }\n\n MainFrame frame = new MainFrame(new ConfigCode(), xmlReader); //Used before initialization is wrong. If the xmlReader\n //variable is wrong, the program will exit\n\n frame.setVisible(true);\n }", "public static ElementTreeSelectionDialog createHaxeProjectsDialog(\r\n\t\t\tShell shell) {\r\n\r\n\t\tElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(\r\n\t\t\t\tshell, new HaxeElementsLabelProvider(),\r\n\t\t\t\tnew HaxeElementsContentProvider(new HaxeElementFilter(\r\n\t\t\t\t\t\tShowElement.Project)));\r\n\r\n\t\tdialog.setTitle(\"haXe Project\");\r\n\t\tdialog.setMessage(\"Choose a haXe project:\");\r\n\t\tdialog.setHelpAvailable(false);\r\n\r\n\t\t// Sets haXe workspace as a root of the resource tree\r\n\t\tdialog.setInput(EclihxCore.getDefault().getHaxeWorkspace());\r\n\r\n\t\treturn dialog;\r\n\t}", "public static void main(String args[]) {\n new xml().convert();\n }", "public project() {\n\n initComponents();\n }", "public ProjectModule() {\n packaging = AutomationConstant.PACKAGING_POM;\n }", "LectureProject createLectureProject();", "public void importButtonClicked() {\n DialogService dialogService = Injector.instantiateModelOrService(DialogService.class);\n ImportEntriesDialog dialog = new ImportEntriesDialog(databaseContext, BackgroundTask.wrap(() -> new ParserResult(resolverResult.getNewEntries())));\n dialog.setTitle(Localization.lang(\"Import entries from LaTeX files\"));\n dialogService.showCustomDialogAndWait(dialog);\n }", "public static Project exampleProject() throws ParseException {\n Person willem = new Person(\"Contractor\", \"Willem du Plessis\", \"074 856 4561\", \"willem@dup.com\",\n \"452 Tugela Avenue\");\n Person rene = new Person(\"Architect\", \"Rene Malan\", \"074 856 4561\", \"rene@malan\", \"452 Tugela Avenue\");\n Person tish = new Person(\"Client\", \"Tish du Plessis\", \"074 856 4561\", \"tish@dup.com\", \"452 Tugela Avenue\");\n Date deadline = dateformat.parse(\"30/03/2021\");\n Project housePlessis = new Project(789, \"House Plessis\", \"House\", \"102 Jasper Avenue\", \"1025\", 20000, 5000,\n deadline, willem, rene, tish);\n ProjectList.add(housePlessis);\n\n return housePlessis;\n }", "public void openProject(File pfile, FileOpenSelector files) { }", "public static void main(String[] args) {\n AddNewProject addNewProject = new AddNewProject();\n addNewProject.setVisible(true);\n }", "Project getProject();", "public Project() {\n inputHandler = new DefaultInputHandler();\n }", "private void loadProject()\n\t{\n\t\t\n\t\tint fileChooserReturnValue =\n\t\t\twindowTemplate\n\t\t\t\t.getFileChooser()\n\t\t\t\t.showOpenDialog(windowTemplate);\n\t\t\n\t\tif(fileChooserReturnValue == JFileChooser.APPROVE_OPTION) {\n\t\t\t// Delete the current cards\n\t\t\tdeleteAllCards();\n\t\t\t\n\t\t\t// Get the file that the user selected\n\t\t\tFile file = windowTemplate.getFileChooser().getSelectedFile();\n\t\t\t\n\t\t\ttry {\n\t\t\t\t\n\t\t\t\t// Open the input streams\n\t\t\t\tFileInputStream fileInput = new FileInputStream(file.getAbsolutePath());\n\t\t\t\tObjectInputStream objectInput = new ObjectInputStream(fileInput);\n\t\t\t\t\n\t\t\t\t// Get ready to save the cards\n\t\t\t\tArrayList<Card> newCards = new ArrayList<Card>();\n\t\t\t\t\n\t\t\t\t// Get the objects\n\t\t\t\ttry {\n\t\t\t\t\t\n\t\t\t\t\tObject inputObject = objectInput.readObject();\n\t\t\t\t\t\n\t\t\t\t\twhile(inputObject instanceof Card) {\n\t\t\t\t\t\t\n\t\t\t\t\t\t// Add the card\n\t\t\t\t\t\tnewCards.add((Card) inputObject);\n\t\t\t\t\t\t\n\t\t\t\t\t\t// Read the next object\n\t\t\t\t\t\tinputObject = objectInput.readObject();\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t} catch(EOFException e2) {\n\t\t\t\t\t\n\t\t\t\t\t// We've reached the end of the file, time to add the new project\n\t\t\t\t\taddCards(newCards);\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Close the input streams\n\t\t\t\tobjectInput.close();\n\t\t\t\tfileInput.close();\n\t\t\t\t\n\t\t\t\t// Update the title of the frame to reflect the current project\n\t\t\t\twindowTemplate.setTitle(file.getName());\n\t\t\t\t\n\t\t\t} catch (ClassNotFoundException | IOException e1) {\n\t\t\t\tJOptionPane.showMessageDialog(windowTemplate, \"Could not open the file.\");\n\t\t\t}\n\t\t}\n\t\t\n\t}", "private ProjectMgr getPmNameTrueLoadActualProject() {\n ProjectMgr pm = null;\n try {\n pm = new ProjectMgr(\"Example\", true);\n\n } catch (ParserConfigurationException e) {\n e.printStackTrace();\n } catch (IOException e) {\n e.printStackTrace();\n } catch (SAXException e) {\n e.printStackTrace();\n }\n\n IOException e;\n return pm;\n }", "public void initializeXMLElements(TOSCAPlan newBuildPlan) {\n\t\tnewBuildPlan.setBpelDocument(this.documentBuilder.newDocument());\n\n\t\t// initialize processElement and append to document\n\t\tnewBuildPlan.setBpelProcessElement(\n\t\t\t\tnewBuildPlan.getBpelDocument().createElementNS(TOSCAPlan.bpelNamespace, \"process\"));\n\t\tnewBuildPlan.getBpelDocument().appendChild(newBuildPlan.getBpelProcessElement());\n\n\t\t// FIXME declare xml schema namespace\n\t\tnewBuildPlan.getBpelProcessElement().setAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns:xsd\",\n\t\t\t\t\"http://www.w3.org/2001/XMLSchema\");\n\n\t\t// init import files list\n\t\tnewBuildPlan.setImportedFiles(new ArrayList<File>());\n\n\t\t// initialize and append extensions element to process\n\t\tnewBuildPlan.setBpelExtensionsElement(\n\t\t\t\tnewBuildPlan.getBpelDocument().createElementNS(TOSCAPlan.bpelNamespace, \"extensions\"));\n\t\tnewBuildPlan.getBpelProcessElement().appendChild(newBuildPlan.getBpelExtensionsElement());\n\n\t\t// init and append imports element\n\t\tnewBuildPlan.setBpelImportElements(new ArrayList<Element>());\n\n\t\t// TODO this is here to not to forget that the imports elements aren't\n\t\t// attached, cause there are none and import elements aren't nested in a\n\t\t// list element\n\t\t//\n\t\t// this.bpelImportsElement = this.bpelProcessDocument.createElementNS(\n\t\t// BuildPlan.bpelNamespace, \"imports\");\n\t\t// this.bpelProcessElement.appendChild(bpelImportsElement);\n\n\t\t// init and append partnerlink element\n\t\tnewBuildPlan.setBpelPartnerLinksElement(\n\t\t\t\tnewBuildPlan.getBpelDocument().createElementNS(TOSCAPlan.bpelNamespace, \"partnerLinks\"));\n\t\tnewBuildPlan.getBpelProcessElement().appendChild(newBuildPlan.getBpelPartnerLinksElement());\n\n\t\t// initialize and append variables element\n\t\tnewBuildPlan.setBpelProcessVariablesElement(\n\t\t\t\tnewBuildPlan.getBpelDocument().createElementNS(TOSCAPlan.bpelNamespace, \"variables\"));\n\t\tnewBuildPlan.getBpelProcessElement().appendChild(newBuildPlan.getBpelProcessVariablesElement());\n\n\t\t// init and append main sequence to process element\n\t\tnewBuildPlan.setBpelMainSequenceElement(\n\t\t\t\tnewBuildPlan.getBpelDocument().createElementNS(TOSCAPlan.bpelNamespace, \"sequence\"));\n\t\tnewBuildPlan.getBpelProcessElement().appendChild(newBuildPlan.getBpelMainSequenceElement());\n\n\t\t// init and append main sequence receive element to main sequence\n\t\t// element\n\t\tnewBuildPlan.setBpelMainSequenceReceiveElement(\n\t\t\t\tnewBuildPlan.getBpelDocument().createElementNS(TOSCAPlan.bpelNamespace, \"receive\"));\n\t\tnewBuildPlan.getBpelMainSequenceElement().appendChild(newBuildPlan.getBpelMainSequenceReceiveElement());\n\n\t\t// init and append main sequence property assign element to main\n\t\t// sequence element\n\t\tnewBuildPlan.setBpelMainSequencePropertyAssignElement(\n\t\t\t\tnewBuildPlan.getBpelDocument().createElementNS(TOSCAPlan.bpelNamespace, \"assign\"));\n\t\tnewBuildPlan.getBpelMainSequenceElement().appendChild(newBuildPlan.getBpelMainSequencePropertyAssignElement());\n\n\t\t// init and append main sequence flow element to main sequence element\n\t\tnewBuildPlan.setBpelMainFlowElement(\n\t\t\t\tnewBuildPlan.getBpelDocument().createElementNS(TOSCAPlan.bpelNamespace, \"flow\"));\n\t\tnewBuildPlan.getBpelMainSequenceElement().appendChild(newBuildPlan.getBpelMainFlowElement());\n\n\t\t// init and append flow links element\n\t\tnewBuildPlan.setBpelMainFlowLinksElement(\n\t\t\t\tnewBuildPlan.getBpelDocument().createElementNS(TOSCAPlan.bpelNamespace, \"links\"));\n\t\tnewBuildPlan.getBpelMainFlowElement().appendChild(newBuildPlan.getBpelMainFlowLinksElement());\n\n\t\t// init and append output assign element\n\t\tnewBuildPlan.setBpelMainSequenceOutputAssignElement(\n\t\t\t\tnewBuildPlan.getBpelDocument().createElementNS(TOSCAPlan.bpelNamespace, \"assign\"));\n\t\tnewBuildPlan.getBpelMainSequenceElement().appendChild(newBuildPlan.getBpelMainSequenceOutputAssignElement());\n\n\t\t// init and append main sequence callback invoke element to main\n\t\t// sequence element\n\t\tnewBuildPlan.setBpelMainSequenceCallbackInvokeElement(\n\t\t\t\tnewBuildPlan.getBpelDocument().createElementNS(TOSCAPlan.bpelNamespace, \"invoke\"));\n\t\tnewBuildPlan.getBpelMainSequenceElement().appendChild(newBuildPlan.getBpelMainSequenceCallbackInvokeElement());\n\t}", "public AddProject() {\n try\n {\n infDB = new InfDB(\"\\\\Users\\\\Oliver\\\\Documents\\\\Skola\\\\Mini_sup\\\\Realisering\\\\MICEDB.FDB\");\n System.out.println(\"Uppkopplingen lyckades\");\n }\n catch(InfException e)\n {\n System.out.println(e.getMessage());\n }\n \n try\n {\n infDB = new InfDB(\"C:\\\\Users\\\\TP300LA-C4034\\\\Desktop\\\\Delkurs 4, Lill-supen\\\\InformatikDB\\\\MICEDB.FDB\");\n System.out.println(\"Uppkopplingen lyckades\");\n }\n catch(InfException e)\n {\n System.out.println(e.getMessage());\n }\n getPlatforms();\n initComponents();\n setLocationRelativeTo(null);\n \n }", "public Project() {\n\t\t\n\t}", "public static void main(String[] args) {\r\n\t\ttry {\r\n\t\t\tDisplay display = Display.getDefault();\r\n\t\t\tShell shell = new Shell(display);\r\n\t\t\tImportDialog inst = new ImportDialog(shell, SWT.NULL);\r\n\t\t\tinst.open();\r\n\t\t} catch (Exception e) {\r\n\t\t\te.printStackTrace();\r\n\t\t}\r\n\t}", "public Project() {\n\t}", "public Project() {\n\t}", "public void importWorkflow() {\n int returnVal = this.graphFileChooser.showOpenDialog(this.engine.getGUI().getFrame());\n if (returnVal == JFileChooser.APPROVE_OPTION) {\n File file = this.graphFileChooser.getSelectedFile();\n try {\n\n String path = file.getPath();\n Workflow importedWorkflow;\n if (path.endsWith(XBayaConstants.GRAPH_FILE_SUFFIX)) {\n WSGraph importedGraph = WSGraphFactory.createGraph(file);\n importedWorkflow = Workflow.graphToWorkflow(importedGraph);\n } else {\n XmlElement importedWorkflowElement = XMLUtil.loadXML(file);\n importedWorkflow = new Workflow(importedWorkflowElement);\n }\n GraphCanvas newGraphCanvas = engine.getGUI().newGraphCanvas(true);\n newGraphCanvas.setWorkflow(importedWorkflow);\n this.engine.getGUI().setWorkflow(importedWorkflow);\n engine.getGUI().getGraphCanvas().setWorkflowFile(file);\n\n } catch (IOException e) {\n this.engine.getGUI().getErrorWindow().error(ErrorMessages.OPEN_FILE_ERROR, e);\n } catch (GraphException e) {\n this.engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);\n } catch (ComponentException e) {\n this.engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);\n } catch (RuntimeException e) {\n this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);\n } catch (Error e) {\n this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);\n }\n }\n }", "private void parseFile(Project p, File f, ImportSettings settings, int pass)\n throws ImportException {\n\n\n try {\n BufferedInputStream bs = new BufferedInputStream(new FileInputStream(f));\n Lexer l = new Lexer(bs, f.getAbsolutePath());\n TokenCollection toks = l.lex();\n Parser px = new Parser();\n CompilationUnitNode cu = px.parse(toks, l.StringLiterals);\n parsedElements.add(cu);\n } catch (FeatureNotSupportedException e) {\n //throw new ImportException(\"Error parsing file: \" + f.getAbsolutePath() + \" due to: \"+e.getMessage());\n System.out.println(\"Error parsing file: \" + f.getAbsolutePath() + \" due to: \"+e.getMessage());\n } catch (Exception e) {\n// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.\n// throw new ImportException(\"Error parsing file: \" + f.getAbsolutePath());\n System.out.println(\"Error parsing file: \" + f.getAbsolutePath());\n }\n\n }", "public Project() {\n\n }", "public void populate(IProject project) throws InvocationTargetException;", "private void initialize() {\n\t\t\n\t\tHashMap<String, Component> componentesImportador = new HashMap<String, Component>();\n\t\t\n\t\t\n\t\tJFrame frame = new JFrame();\n\t\tframe.setBounds(100, 100, 450, 197);\n\t\tframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);\n\t\tframe.getContentPane().setLayout(null);\n\t\tframe.setVisible(true);\n\t\t\n\t\tcomponentesImportador.put(\"frame\", frame);\n\t\t\n\t\tJLabel lblTitulo = new JLabel(\"IMPORTAR\");\n\t\tlblTitulo.setHorizontalAlignment(SwingConstants.CENTER);\n\t\tlblTitulo.setFont(new Font(\"Verdana\", Font.BOLD, 18));\n\t\tlblTitulo.setBounds(0, 11, 434, 33);\n\t\tframe.getContentPane().add(lblTitulo);\n\t\tcomponentesImportador.put(\"lblTitulo\", lblTitulo);\n\t\t\n\t\tJLabel lblRuta = new JLabel(\"Ruta:\");\n\t\tlblRuta.setBounds(10, 79, 46, 14);\n\t\tframe.getContentPane().add(lblRuta);\n\t\tcomponentesImportador.put(\"lblRuta\", lblRuta);\n\t\t\n\t\tJTextField txtRuta = new JTextField();\n\t\ttxtRuta.setText(\"C:\\\\\");\n\t\ttxtRuta.setBounds(69, 76, 323, 20);\n\t\tframe.getContentPane().add(txtRuta);\n\t\ttxtRuta.setColumns(10);\n\t\tcomponentesImportador.put(\"txtRuta\", txtRuta);\n\t\t\n\t\tImportadorController controlador= new ImportadorController(componentesImportador);\n\t\t\n\t\tJLabel lblSuperior = new JLabel(\"\\u00BFD\\u00F3nde se encuentra el XML?\");\n\t\tlblSuperior.setHorizontalAlignment(SwingConstants.CENTER);\n\t\tlblSuperior.setBounds(10, 55, 414, 14);\n\t\tframe.getContentPane().add(lblSuperior);\n\t\tcomponentesImportador.put(\"lblSuperior\", lblSuperior);\n\t\t\t\n\n\t\tJButton btnCancelar = new JButton(\"Cancelar\");\n\t\tbtnCancelar.setBounds(236, 125, 89, 23);\n\t\tcomponentesImportador.put(\"btnCancelar\", btnCancelar);\n\t\t\n\t\tJButton btnAceptar = new JButton(\"Aceptar\");\n\t\tbtnAceptar.setBounds(335, 125, 89, 23);\n\t\tcomponentesImportador.put(\"btnAceptar\", btnAceptar);\n\t\t\n\t\tJButton btnChooser = new JButton(\"...\");\n\t\tbtnChooser.setBounds(402, 76, 22, 21);\n\n\t\tcomponentesImportador.put(\"btnChooser\", btnChooser);\n\t\t\n\t\t\n\t\tframe.getContentPane().add(btnCancelar);\n\t\tframe.getContentPane().add(btnChooser);\n\t\tframe.getContentPane().add(btnAceptar);\n\t\t\n\t\tbtnChooser.setActionCommand(\"Chooser\");\n\t\tbtnCancelar.setActionCommand(\"Cancelar\");\n\t\tbtnAceptar.setActionCommand(\"Aceptar\");\n\t\t\n\t\tbtnChooser.addActionListener(controlador);\n\t\tbtnAceptar.addActionListener(controlador);\n\t\tbtnCancelar.addActionListener(controlador);\n\t\t\t\t\n\t}", "Element loadFrontPageOf(GitHubProject project) throws IOException {\n String url = format(\"https://github.com/%s/%s\", project.organization().name(), project.name());\n return Jsoup.connect(url).get();\n }", "public static void main(String[] args) {\r\n\t\tProgProjGUI display = new ProgProjGUI();\r\n\t\tdisplay.setVisible(true);\r\n\t\t\r\n\t\t\r\n\t}", "public void createProject(Project newProject);", "private void newProject()\n\t{\n\t\tnew FenetreCreationProjet();\n\t}", "private void browseProject()\n {\n List<FileFilter> filters = new ArrayList<>();\n filters.add(new FileNameExtensionFilter(\"Bombyx3D project file\", \"yml\"));\n\n File directory = new File(projectPathEdit.getText());\n File selectedFile = FileDialog.chooseOpenFile(this, BROWSE_DIALOG_TITLE, directory, filters);\n if (selectedFile != null) {\n projectDirectory = selectedFile.getParentFile();\n projectPathEdit.setText(projectDirectory.getPath());\n projectPathEdit.selectAll();\n }\n }", "public void openUpProject(Subproject project) {\n\t\tSubprojectField field=project.setChip(current.removeChip());\n\t\tcurrent.raiseScore(field.getAmountSZT());\n\t}", "public void setupImport() {\r\n\t\tmnuImport.addActionListener(new ActionListener() {\r\n\t\t\tpublic void actionPerformed(ActionEvent e) {\r\n\t\t\t\tnew ImportGUI();\r\n\t\t\t}\r\n\t\t});\r\n\t}", "public miniproject() {\n initComponents();\n }", "public Project(File file)\n {\n super(file);\n this.open();\n }", "public static void main(String[] args) {\n try {\n String url = \"file:///C:/enwiktionary-latest-pages-articles.xml.bz2.xml.bz2.xml\";\n// String url = \"file:///D:/enWikt_Samp.xml\n File file = new File(new URI(url));\n System.out.println(file.toURI());\n\n\n// fileLoader(file);\n staxReader(file);\n// vtdReader(file); vtd is where kittens go to die.\n } catch (Exception e) {\n e.printStackTrace();\n }\n }", "public CreateProject() {\n\t\tsuper();\n\t}", "public Project(String name){\n\t\tthis.pName = name;\n\t}", "Import createImport();", "Import createImport();", "public static String startProject(String projectName, String projectRevision) {\n\t\treturn \"<java-project id=\\\"default\\\" name=\\\"\" + projectName + \"\\\" revision=\\\"\" + projectRevision + \"\\\">\" + \"\\n\";\n\t}", "public void start() {\n\t\tPetriNetView pnmlData = ApplicationSettings.getApplicationView()\n\t\t\t\t.getCurrentPetriNetView();\n\t\t//if (pnmlData.getTokenViews().size() > 1) {\n\t\tif(pnmlData.getEnabledTokenClassNumber() > 1){\n\t\t\tExpander expander = new Expander(pnmlData);\n\t\t\tpnmlData = expander.unfold();\n\t\t\tJOptionPane.showMessageDialog(null, \"This is CGSPN. The analysis will only apply to default color (black)\",\n\t\t\t\t\t\"Information\", JOptionPane.INFORMATION_MESSAGE);\n\t\t}\n\t\t// Build interface\n\t\tEscapableDialog guiDialog = new EscapableDialog(\n\t\t\t\tApplicationSettings.getApplicationView(), MODULE_NAME, true);\n\n\t\t// 1 Set layout\n\t\tContainer contentPane = guiDialog.getContentPane();\n\t\tcontentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));\n\n\t\t// 2 Add file browser\n\t\tsourceFilePanel = new PetriNetChooserPanel(\"Source net\", pnmlData);\n\t\tcontentPane.add(sourceFilePanel);\n\n\t\t// 3 Add results pane\n\t\tresults = new ResultsHTMLPane(pnmlData.getPNMLName());\n\t\tcontentPane.add(results);\n\n\t\t// 4 Add button's\n\t\tcontentPane.add(new ButtonBar(\"Analyse GSPN\", runAnalysis, guiDialog\n\t\t\t\t.getRootPane()));\n\n\t\t// 5 Make window fit contents' preferred size\n\t\tguiDialog.pack();\n\n\t\t// 6 Move window to the middle of the screen\n\t\tguiDialog.setLocationRelativeTo(null);\n\n\t\ttry {\n\t\t\tguiDialog.setVisible(true);\n\t\t} catch (NullPointerException e) {\n\t\t}\n\n\t}", "public ProjectsPage() {\n\t\tthis.driver = DriverManager.getDriver();\n\t\tElementFactory.initElements(driver, this);\n\t\t// sets the name of the project to add, with a random integer ending for slight\n\t\t// ease on multiple test runs\n\t\tnameOfProject = \"testz2018\" + (int) Math.random() * 500;\n\t}", "public void EjecutarXML(String path)\n {\n for(ArrayList<NodoXML> l : listaxml)\n {\n for(NodoXML n : l)\n {\n n.ejecutar(this);\n }\n }\n \n /*Ahora las importaciones*/\n// for(ArrayList<NodoXML> l : singlenton.listaAST)\n for(int cont = 0; cont<singlenton.listaAST.size(); cont++)\n {\n ArrayList<NodoXML> l = singlenton.listaAST.get(cont);\n for(NodoXML n : l)\n {\n n.ejecutar(this);\n }\n } \n \n mostrarTraduccion(path);\n }", "public Project() {\n this.name = \"Paper plane\";\n this.description = \" It's made of paper.\";\n }", "public void setProject(Project project) {\n this.project = project;\n }", "public void setProject(Project project) {\n this.project = project;\n }", "public void fromXml(InputStream is) throws Exception {\r\n\t\tJAXBContext jc = JAXBContext.newInstance(TaskTypes.class);\r\n\t\tUnmarshaller u = jc.createUnmarshaller();\r\n\t\tTaskTypes tt = (TaskTypes) u.unmarshal(is);\r\n\t\tthis.taskTypes = tt.taskTypes;\r\n\t}", "public void readXmlFile() {\r\n try {\r\n ClassLoader classLoader = getClass().getClassLoader();\r\n File credentials = new File(classLoader.getResource(\"credentials_example.xml\").getFile());\r\n DocumentBuilderFactory Factory = DocumentBuilderFactory.newInstance();\r\n DocumentBuilder Builder = Factory.newDocumentBuilder();\r\n Document doc = Builder.parse(credentials);\r\n doc.getDocumentElement().normalize();\r\n username = doc.getElementsByTagName(\"username\").item(0).getTextContent();\r\n password = doc.getElementsByTagName(\"password\").item(0).getTextContent();\r\n url = doc.getElementsByTagName(\"url\").item(0).getTextContent();\r\n setUsername(username);\r\n setPassword(password);\r\n setURL(url);\r\n } catch (Exception error) {\r\n System.out.println(\"Error in parssing the given xml file: \" + error.getMessage());\r\n }\r\n }", "public Project(String name) {\r\n\t\tsuper(name);\r\n\t\tthis.opened = true;\r\n\t\tthis.projectFile = null;\r\n\t}", "public void loadProject(String projectContents, String langDefContents) {\n final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();\n final DocumentBuilder builder;\n final Document projectDoc;\n final Document langDoc;\n try {\n builder = factory.newDocumentBuilder();\n projectDoc = builder.parse(new InputSource(new StringReader(projectContents)));\n final Element projectRoot = projectDoc.getDocumentElement();\n langDoc = builder.parse(new InputSource(new StringReader(projectContents)));\n final Element langRoot = langDoc.getDocumentElement();\n if (workspaceLoaded) {\n resetWorkspace();\n }\n if (langDefContents == null) {\n loadBlockLanguage(langDefRoot);\n } else {\n loadBlockLanguage(langRoot);\n }\n workspace.loadWorkspaceFrom(projectRoot, langRoot);\n workspaceLoaded = true;\n\n } catch (ParserConfigurationException e) {\n throw new RuntimeException(e);\n } catch (SAXException e) {\n throw new RuntimeException(e);\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }", "public void loadProjectFromPath(final String path) throws IOException\n {\n final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();\n factory.setNamespaceAware(true);\n final DocumentBuilder builder;\n final Document doc;\n try {\n builder = factory.newDocumentBuilder();\n doc = builder.parse(new File(path));\n\n // XXX here, we could be strict and only allow valid documents...\n // validate(doc);\n final Element projectRoot = doc.getDocumentElement();\n //load the canvas (or pages and page blocks if any) blocks from the save file\n //also load drawers, or any custom drawers from file. if no custom drawers\n //are present in root, then the default set of drawers is loaded from\n //langDefRoot\n workspace.loadWorkspaceFrom(projectRoot, langDefRoot);\n workspaceLoaded = true;\n } catch (ParserConfigurationException e) {\n throw new RuntimeException(e);\n } catch (SAXException e) {\n throw new RuntimeException(e);\n }\n }", "public void loadXML(){\n new DownloadXmlTask().execute(URL);\n }", "public void xmlInputStream() {\n inputStream = context.getResources().openRawResource(R.raw.flowers_xml);\n //stringInputStream = convertInputStreamToString(inputStream);\n //System.out.println(\"------------ InputStream ------------\\n\" + stringInputStream);\n //------------------------------------------------------------------------------------------\n }", "public void displayProject(Project project) {\n\t\tSystem.out.println(project.getID() + \" \"\n\t\t\t\t+ project.getProjectName() + \" \"\n\t\t\t\t+ project.getStartDate() + \" \"\n\t\t\t\t+ project.getEndDate() + \" \"\n\t\t\t\t+ project.getPriority());\n\t}", "public void parse(InputStream in) throws XmlPullParserException, IOException {\n try {\n XmlPullParser parser = Xml.newPullParser();\n\n parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);\n parser.setInput(in, null);\n readFeed(parser);\n\n } finally {\n in.close();\n }\n }", "@SuppressWarnings(\"serial\")\n\tpublic ProjectPage() {\n\t\tagregarForm();\n\t}" ]
[ "0.6535876", "0.6502193", "0.5849671", "0.540433", "0.5252607", "0.5243436", "0.5236712", "0.5235188", "0.5184507", "0.514473", "0.51262236", "0.51228577", "0.51228577", "0.51228577", "0.51120293", "0.5109488", "0.51081854", "0.5083833", "0.5064876", "0.50258166", "0.5022089", "0.5014968", "0.49906862", "0.49781337", "0.49591056", "0.49438056", "0.49205744", "0.48980892", "0.48489207", "0.48439866", "0.4834181", "0.48326772", "0.48249295", "0.481953", "0.48182994", "0.48162374", "0.4810928", "0.4793721", "0.4785635", "0.477295", "0.4771173", "0.4768052", "0.47630054", "0.47608238", "0.47608063", "0.4756523", "0.47543025", "0.47389615", "0.4734977", "0.47329465", "0.471064", "0.47081894", "0.47026935", "0.46967453", "0.46922407", "0.46894652", "0.46813932", "0.46640936", "0.46518946", "0.46359974", "0.46358478", "0.4621638", "0.4590513", "0.4590513", "0.45794415", "0.45766667", "0.45670515", "0.45648304", "0.45542505", "0.4547979", "0.4545444", "0.45447913", "0.4537335", "0.45361477", "0.45351347", "0.45315954", "0.45256978", "0.4523418", "0.45080912", "0.45067525", "0.4502463", "0.44839627", "0.44839627", "0.4478476", "0.44765794", "0.44746432", "0.44646117", "0.44621852", "0.44585422", "0.44585422", "0.44566077", "0.4456394", "0.44527814", "0.4448277", "0.44481117", "0.44380087", "0.44369707", "0.4436159", "0.44343358", "0.44335464" ]
0.53527457
4
HelperFunctions help = new HelperFunctions();
public static void getLightStatus() { try { ArrayList<NameValuePair> nameValuePairs1 = new ArrayList<NameValuePair>(); nameValuePairs1.add(new BasicNameValuePair("userID",String.valueOf(Thermo_main.userID))); String httpPoststring = "http://"+Thermo_main.ip_addr_server+"/getLightStatus_java.php"; //String httpPostSetString = "http://"+Thermo_main.ip_addr_server+"/setEnergy.php"; //Thermo_main.help.setResult(nameValuePairs1, httpPostSetString); String result = Thermo_main.help.getResult(nameValuePairs1,httpPoststring); JSONArray array = new JSONArray(result); for(int n =0; n< array.length(); n++) { JSONObject objLight = array.getJSONObject(n); room_new.add(objLight.getInt("room")); light_status_new.add(objLight.getString("light_status")); dimmer_status_new.add(objLight.getString("dimmer_status")); } }catch(Exception e) {} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "void help();", "public void help();", "private Helper() {\r\n // empty\r\n }", "Help createHelp();", "public void showHelp();", "private HelperLocation() {}", "void printHelp();", "@Override\n public void help() {\n\n }", "public String getHelp();", "String getHelpString();", "private Helper() {\r\n // do nothing\r\n }", "@Override\n \t\t\t\tpublic void doHelp() {\n \n \t\t\t\t}", "private Helper getHelper() {\r\n return this.helper;\r\n }", "public void helpGenericAction() {\n new Help(getGenericHelpTitle(), getGenericHelp());\n }", "String getHelpText();", "private static void help() {\n\t\t\n\t\tTask[] taskList = createTaskList();\n\t\t\n\t\tSystem.out.println(\"\\n---------------------------------[ HELP ]--------\"\n\t\t\t\t+ \"------------------------------\\n\");\n\t\t\n\t\t// Post1 Display help (Polymorphism)\n\t\tfor (Task task : taskList) {\n\t\t\ttask.displayHelp();\n\t\t}\n\t\t\n\t}", "private Help() {\n // hidden constructor\n }", "public Fun_yet_extremely_useless()\n {\n\n }", "HelpFactory getHelpFactory();", "private void help() {\n usage(0);\n }", "private void someUtilityMethod() {\n }", "private void someUtilityMethod() {\n }", "public static ConsoleHelper getInstance() {\n\treturn helper;\n }", "public abstract String getHelpInfo();", "private void doHelp()\r\n {\r\n Help.showHelp(page, ref, null);\r\n }", "private void printHelp()//Method was given\n {\n System.out.println(\"Your command words are:\");\n parser.showCommands();\n }", "public static void thisDemo() {\n\t}", "public help() {\n initComponents();\n }", "private static void help() {\n\t\tHelpFormatter formater = new HelpFormatter();\n\t\tformater.printHelp(\"Main\", options);\n\t\tSystem.exit(0);\n\t}", "public static void displayHelp() {\n\t\thelp = getInstance();\n\t\tUIMain.popUpHelp(commandList, inputCommand);\t\n\t\tLoggingLogic.logging(HELP_MESSAGE);\n\t}", "private WAPIHelper() { }", "@DISPID(-2147412099)\n @PropGet\n java.lang.Object onhelp();", "@Override\n public void printHelp() {\n\n }", "public HelpCommand()\n {\n }", "private static void LessonInstanceVsStatic() {\n System.out.println(MathHelper.E);\n System.out.println(MathHelper.PI);\n System.out.println(MathHelper.square(5));\n //Three helper methods for StringHelper\n System.out.println(StringHelper.removeLeadingAndTrailingSpaces(\" Hello \"));\n System.out.println(StringHelper.removeAllSpace(\" He ll o !\"));\n System.out.println(StringHelper.yelling(\"hello\"));\n //Three helper methods for MathHelper\n System.out.println(MathHelper.cubed(5));\n System.out.println(MathHelper.areaOfRectangle(2,3));\n System.out.println(MathHelper.perimeterOfRectangle(4, 5));\n\n }", "public interface HelpManager\n{\n /**\n * Add help files to the help system.\n *\n * @param name The name to associate with the help files.\n * @param directory The directory that will be recursively copied over to\n * the help system location.\n * @return True if successful, false otherwise.\n */\n boolean addHelpFiles(String name, File directory);\n\n /**\n * Add the given plugin help information to the help system.\n *\n * @param helpInfo The plugin specific help information.\n * @return True if successful, false otherwise.\n */\n boolean addHelpInfo(PluginHelpInfo helpInfo);\n\n /**\n * Remove the help information associated with the given name from the help\n * system.\n *\n * @param name The name associated with the help information to remove.\n * @return True if successful, false otherwise.\n */\n boolean removeHelpInfo(String name);\n}", "private void helpService() {\n output.println(\"Help command\");\n output.println(\"-calc <number> \\t Calculates the value of pi based on <number> points; quit \\t Exit from program \");\n }", "private static void help() {\n HelpFormatter formater = new HelpFormatter();\n formater.printHelp(\"SGD-SVM\", options);\n System.exit(0);\n }", "void mo22249a();", "@Override\r\n\tprotected String getHelpInfor() {\n\t\treturn \"\";\r\n\t}", "private stendhal() {\n\t}", "public void setHelp (String Help);", "public void openHelp(){\n\n Intent helpIntent = new Intent(this, Help.class);\n startActivity(helpIntent);\n\n }", "private void help() {\n HelpFormatter formater = new HelpFormatter();\n\n formater.printHelp(\"Main\", options);\n System.exit(0);\n }", "void mo2311a();", "Menu getMenuHelp();", "private Utility() {\n\t}", "public static void t(){\n\n\n }", "public static void hehe(){\n \n }", "void pramitiTechTutorials() {\n\t\n}", "public HelperManager() {\r\n\r\n myHelpers = new ArrayList<Helper>();\r\n\r\n //Demo Data\r\n Helper helper01 = new Helper(\"Max\", \"Mustermann\", \"Male\", \"GER\");\r\n Helper helper02 = new Helper(\"Hans\", \"Werner\", \"Female\", \"AUS\");\r\n Helper helper03 = new Helper(\"Maria\", \"Mülller\", \"Divers\", \"SWE\");\r\n myHelpers.add(helper01);\r\n myHelpers.add(helper02);\r\n myHelpers.add(helper03);\r\n }", "static void jhat() {\n\n }", "private TemplateManagerHelper() {\n\n }", "private Utils() {}", "private Utils() {}", "private Utils() {}", "private Utils() {}", "private TempExpressionHelper() {\r\n\t}", "public void helpSpecificAction() {\n new Help(getSpecificHelpTitle(), getSpecificHelp());\n }", "protected String getHelpText() {\n return \"\";\n }", "public String showHelp() {\r\n return ctrlDomain.getHidatoDescription();\r\n }", "void hello();", "void hello();", "void hello();", "public static String _globals() throws Exception{\nmostCurrent._pnloverlay = new anywheresoftware.b4a.objects.PanelWrapper();\n //BA.debugLineNum = 21;BA.debugLine=\"Private txtval As EditText\";\nmostCurrent._txtval = new anywheresoftware.b4a.objects.EditTextWrapper();\n //BA.debugLineNum = 22;BA.debugLine=\"Private btnlogin As Button\";\nmostCurrent._btnlogin = new anywheresoftware.b4a.objects.ButtonWrapper();\n //BA.debugLineNum = 23;BA.debugLine=\"Private btndelete As Button\";\nmostCurrent._btndelete = new anywheresoftware.b4a.objects.ButtonWrapper();\n //BA.debugLineNum = 24;BA.debugLine=\"End Sub\";\nreturn \"\";\n}", "void mo37810a();", "public static void help() {\n\tSystem.out.println(\"-- Avaible options --\");\n\tSystem.out.println(\"-- [arg]: Required argument\");\n\tSystem.out.println(\"-- {arg}: Optional argument\");\n\tSystem.out.println(\"* -s {file} Save the game into a file\");\n\tSystem.out.println(\"* -r {file} Play or Replay a game from a file\");\n\tSystem.out.println(\"* -a [file] Play a binary file or a game file\");\n\tSystem.out.println(\"* -n [file] Create a random game file\");\n\tSystem.out.println(\"* -t [size] Specify the size of the board\");\n\tSystem.out.println(\"* -k Solve the game with the IA solver\");\n\tSystem.out.println(\"* -m Solve the game with the MinMax/AlphaBeta algorithm\");\n\tSystem.out.println(\"----------------------------------------------\");\n\tSystem.out.println(\". Press Enter to Start or Restart\");\n\tSystem.out.println(\". Press Z to Undo the last move\");\n\tSystem.out.println(\"\");\n }", "private FunctionUtils() {\n }", "@Override\n public HelpCtx getHelp() {\n return HelpCtx.DEFAULT_HELP;\n // If you have context help:\n // return new HelpCtx(\"help.key.here\");\n }", "@Override\n public HelpCtx getHelp() {\n return HelpCtx.DEFAULT_HELP;\n // If you have context help:\n // return new HelpCtx(\"help.key.here\");\n }", "private Utils() {\n\t}", "private Utils() {\n\t}", "String getOnlineHelpLocation();", "public void showHelp(CommandSender sender) {\n\t\t\n\t}", "@Test\n public void testCompareTest9a() {\n helperMethoda(\"CompareTest9a.txt\", \"CompareTest9b.txt\");\n }", "@Test\n public void testCompareTest7a() {\n helperMethoda(\"CompareTest7a.txt\", \"CompareTest7b.txt\");\n }", "@Test\n public void testCompareTest12a() {\n helperMethoda(\"CompareTest12a.txt\", \"CompareTest12b.txt\");\n }", "@Override\n public void help(CommandSender sender) {\n \n }", "void mo119581a();", "@Test\n public void testCompareTest10a() {\n helperMethoda(\"CompareTest10a.txt\", \"CompareTest10b.txt\");\n }", "void mo67920a();", "private static void help() {\n System.out.println(USAGE); \n System.exit(0);\n }", "void mo3311a();", "protected String getHelp() {\r\n return UIManager.getInstance().localize(\"renderingHelp\", \"Help description\");\r\n }", "@Test\n public void testCompareTest6a() {\n helperMethoda(\"CompareTest6a.txt\", \"CompareTest6b.txt\");\n }", "private String printHelp()//refactored\n { String result = \"\";\n result += \"\\n\";\n result += \"You are weak if you have to ask me\\n\";\n result += \"Try not to die, while i´am mocking you.\\n\";\n result += \"\\n\";\n result += \"\" + currentRoom.getDescription() + \"\\n\"; //new\n result += \"\\nExits: \" + currentRoom.getExitDescription() + \"\\n\";//new\n result += \"\\nCommand words:\\n\";\n result += ValidAction.getValidCommandWords();\n result += \"\\n\";\n \n return result;\n }", "public interface City56Helper {\n}", "void mo84655a();", "private UtilityKlasse() {\n\n }", "private void help() {\n System.out.println(\"PLACE X,Y,F #Placing the robot in (X,Y) facing F. \\n\" +\n \"\\tX and Y are numbers between 0 AND 5, F is NORTH, EAST, WEST, SOUTH directions\\n\" +\n \"MOVE #Move one position towards the current direction\\n\" +\n \"LEFT #Turn left\\n\" +\n \"RIGHT #Turn right\\n\" +\n \"REPORT #Prints current position and the direction\\n\" +\n \"HELP #Help menu\");\n }", "@Test\n public void testCompareTest4a() {\n helperMethoda(\"CompareTest4a.txt\", \"CompareTest4b.txt\");\n }", "void help() {\n // FIXME\n try {\n FileReader help = new FileReader(\"loa/Help.txt\");\n Scanner helpPls = new Scanner(help);\n while (helpPls.hasNextLine()) {\n System.out.println(helpPls.nextLine());\n }\n } catch (FileNotFoundException e) {\n System.out.println(\"Help file not found.\");\n }\n\n }", "private void showHelp() {\n System.out.println(\"new: \");\n System.out.println(\"new chess and throw the chess bevor away\");\n System.out.println(\"move from to:\");\n System.out.println(\"take the pawn from position from to position to \");\n System.out.println(\"print:\");\n System.out.println(\"print the chess now \");\n System.out.println(\"help:\");\n System.out.println(\"show help\");\n System.out.println(\"quit:\");\n System.out.println(\"quit out\");\n }", "private CommonMethods() {\n }", "private static void DisplayHelp() {\r\n System.out.println();\r\n System.out.println(\"Usage: Consumes messages from a topic/queue\");\r\n System.out.println();\r\n System.out.println(\" SampleConsumerJava [ < response_file ]\");\r\n System.out.println();\r\n return;\r\n }", "private void showHelpDialog() {\n\n view.helpDialog();\n }", "public void sayHi();", "public static void demo() {\n\t\tlab_2_2_5();\n\n\t}", "@Test\n public void testCompareTest5a() {\n helperMethoda(\"CompareTest5a.txt\", \"CompareTest5b.txt\");\n }", "Argument help(String help);", "public void sendeHello();" ]
[ "0.7295403", "0.72744095", "0.6964345", "0.69539684", "0.69121194", "0.6704378", "0.66478425", "0.66306746", "0.65008026", "0.64925206", "0.64499044", "0.64483917", "0.63820237", "0.63507307", "0.63071424", "0.62927353", "0.6269764", "0.62480503", "0.6222987", "0.6218075", "0.6180935", "0.6180935", "0.6179208", "0.6121759", "0.61166084", "0.60845935", "0.60826516", "0.6029357", "0.6025881", "0.60231274", "0.6015541", "0.60109437", "0.60054547", "0.59787595", "0.5952647", "0.59054554", "0.5887459", "0.5876922", "0.5833493", "0.5825176", "0.58171904", "0.58116233", "0.5786078", "0.57845664", "0.57707226", "0.57686365", "0.57651794", "0.5740934", "0.5731293", "0.571848", "0.57144654", "0.57067394", "0.570608", "0.56996816", "0.56996816", "0.56996816", "0.56996816", "0.5677955", "0.5663002", "0.5662335", "0.56592184", "0.56572324", "0.56572324", "0.56572324", "0.56548923", "0.56536734", "0.5649505", "0.5643203", "0.56367207", "0.56365764", "0.56361985", "0.56361985", "0.5631083", "0.5620205", "0.56183016", "0.5616362", "0.56155634", "0.56135124", "0.5611621", "0.55976963", "0.5592752", "0.5590235", "0.5588459", "0.5588092", "0.55868423", "0.5583254", "0.5583197", "0.55806345", "0.5580496", "0.55757874", "0.5575787", "0.557424", "0.5573062", "0.5572487", "0.557096", "0.5570349", "0.5566473", "0.5557291", "0.55529505", "0.5549879", "0.5549875" ]
0.0
-1
The cv returns an absolute time value in milliseconds. This time is only a recommendation; it may be that the distribution policy has set a maximum.
public long cv() { if (this.type == null) { return Long.MAX_VALUE; } else switch (this.type) { case ABS: return this.abs.cv(); case REL: if (this.rel.cv() < Long.MAX_VALUE) { return System.currentTimeMillis() + this.rel.cv(); } else { return Long.MAX_VALUE; } default: return Long.MAX_VALUE; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public double getCV() {\n return getUnbiasedStandardDeviation() / getAverage();\n }", "public double getMaxTimeDiff()\n\t{\n\t\treturn 0;\n\t}", "public float getMaxTimeSeconds() { return getMaxTime()/1000f; }", "public TimeConfidence getTimeConfidence()\n {\n\treturn this.timeConfidence;\n }", "public String getMsCV() {\n return this.msCV;\n }", "public double ProcessArrivalTime()\r\n\t{\r\n\t\tdouble U = Math.random();\r\n\t\t//double lambda = 0.04;\r\n\t\tdouble lambda = 0.01;\r\n\t\tdouble V = ( -1 * (Math.log(1.0 - U)) ) / lambda; \r\n\t\treturn V;\r\n\t}", "protected static double getFPGATime() {\n return (System.currentTimeMillis() - startTime) / 1000.0;\n }", "int getAbsoluteMaximumDelay();", "private long getNow()\n {\n // no need to convert to collection if had an Iterables.max(), but not present in standard toolkit, and not worth adding\n List<SSTableReader> list = new ArrayList<>();\n Iterables.addAll(list, cfs.getSSTables(SSTableSet.LIVE));\n if (list.isEmpty())\n return 0;\n return Collections.max(list, (o1, o2) -> Long.compare(o1.getMaxTimestamp(), o2.getMaxTimestamp()))\n .getMaxTimestamp();\n }", "long getVoteFinalizeDelaySeconds();", "private static float tock(){\n\t\treturn (System.currentTimeMillis() - startTime);\n\t}", "public float getMaxAlturaCM();", "public double maxWait()\r\n {\r\n //find the max value in an arraylist\r\n double maxWait = servedCustomers.get(0).getwaitTime();\r\n for(int i = 1; i < servedCustomers.size(); i++){\r\n if(servedCustomers.get(i).getwaitTime()>maxWait){\r\n maxWait = servedCustomers.get(i).getwaitTime();\r\n }\r\n }\r\n return maxWait;\r\n }", "public double getCBRTime();", "public long getRunMaxMillis()\n {\n return 0L;\n }", "double getCritChance();", "public double gettimetoAchieve(){\n\t\treturn this.timeFrame;\n\t}", "public Double getBestTime() {\n return bestTime;\n }", "public int getMaxTime() { return _maxTime; }", "long ctime() {\n return ctime;\n }", "float getEstimatedTime() {\n return estimated_time;\n }", "public double getTimeFullGcs() {\n return timeFullGcs;\n }", "BusinessCenterTime getValuationTime();", "public float timeBeforeDestruction(){\n\t\tif(destroyTime < Float.MAX_VALUE){\n\t\t\treturn destroyTime - Main.time;\n\t\t}else{\n\t\t\treturn Float.MAX_VALUE;\n\t\t}\n\t}", "@Override\r\n\tpublic float getChannelTime() {\n\t\treturn 4;\r\n\t}", "Double getActualDuration();", "public T getAbsoluteCriticalValue() {\n return absoluteCriticalValue;\n }", "int getMaximumDelay();", "public long getRemainingTime() {\n return (maxTime_ * 1000L)\n - (System.currentTimeMillis() - startTime_);\n }", "int getNominalDelay();", "public double getMaxTimeBetweenCarArrivals() {\n return maxTimeBetweenCarArrivals;\n }", "public String estimatedTime() {\n int m = (int)(getFreeBytes()/500000000);\n return (m <= 1) ? \"a minute\" : m+\" minutes\";\n }", "private double calcuCMetric() {\n\t\treturn (p-1)/fcost;\n\t}", "public double CPUServiceTime()\r\n\t{\r\n\t\treturn Math.random()* (30.0 - 10.0) + 10.0;\r\n\t}", "@DISPID(55)\r\n\t// = 0x37. The runtime will prefer the VTID if present\r\n\t@VTID(53)\r\n\tint actualCPUTime_Seconds();", "public float getChance()\n {\n return 1.0f;\n }", "long getExposureTimePref();", "public long getTimeTaken();", "@DefaultValue(\"0\")\n long getTerminatedPodGcDelayMs();", "double getAbsoluteTime() {\n return absoluteTime;\n }", "public DateTime getCtime() {\r\n return ctime;\r\n }", "private double getMaxThreshold() {\n return maxThreshold;\n }", "@DISPID(61)\r\n\t// = 0x3d. The runtime will prefer the VTID if present\r\n\t@VTID(59)\r\n\tint actualRunTime_Milliseconds();", "@Test(timeout = 4000)\n public void test050() throws Throwable {\n TestInstances testInstances0 = new TestInstances();\n Instances instances0 = testInstances0.generate(\"\");\n Evaluation evaluation0 = new Evaluation(instances0);\n evaluation0.areaUnderPRC((-1));\n assertEquals(0.0, evaluation0.SFPriorEntropy(), 0.01);\n }", "com.google.protobuf.Duration getMaxExperience();", "public java.lang.Long getConsumerTime() {\n return consumer_time;\n }", "@DISPID(56)\r\n\t// = 0x38. The runtime will prefer the VTID if present\r\n\t@VTID(54)\r\n\tint actualCPUTime_Milliseconds();", "public double getStdDeviationTimeBetweenCarArrivals() {\n return Math.abs(getMaxTimeBetweenCarArrivals() - getMeanTimeBetweenCarArrivals());\n }", "public Duration getActualDuration()\r\n {\r\n return (m_actualDuration);\r\n }", "int checkElapsedTime(){\r\n\t\treturn gc.getElapsedTime();\r\n\t}", "public long mo130408c() {\n return System.nanoTime();\n }", "@Override\n\tpublic double getFinalBestTargetValue() {\n\t\treturn 0;\n\t}", "public double getScore() {\n double compositeScore = this.normaliseViewingTime();\n if (this.normalisedRating > 0) {\n compositeScore *= this.normalisedRating;\n }\n else {\n compositeScore *= ((double)RANGE / (double)2) / (double)RANGE;\n }\n return compositeScore;\n }", "public java.lang.Long getConsumerTime() {\n return consumer_time;\n }", "private double normaliseViewingTime() {\n return this.averageViewingTime / (double) this.content.getViewLength();\n }", "@Test(timeout = 4000)\n public void test036() throws Throwable {\n TestInstances testInstances0 = new TestInstances();\n Instances instances0 = testInstances0.generate(\"\");\n Evaluation evaluation0 = new Evaluation(instances0);\n double[] doubleArray0 = evaluation0.makeDistribution(0.95);\n assertNotNull(doubleArray0);\n assertArrayEquals(new double[] {1.0, 0.0}, doubleArray0, 0.01);\n assertEquals(0.0, evaluation0.SFSchemeEntropy(), 0.01);\n }", "public double DrivetrainLimiterWithTimeScale(){\n\t\tif (this.GetAverageTotalCurrent() > this.drivetrainCurrentLimit){\n\t\t\tpresentTime = Timer.getFPGATimestamp();\n\t\t\ttimeError = Math.abs(presentTime - startTime);\n\t\t\t\n\t\t\tcurrentError = Math.abs(this.GetAverageTotalCurrent() - this.drivetrainCurrentLimit);\n\t\t\tlimiter = 1 - (currentError * cKp) - (timeError * tKp);\n\t\t}\n\t\telse{\n\t\t\tstartTime = Timer.getFPGATimestamp();\n\t\t\tlimiter = 1;\n\t\t}\n\t\t\n\t\treturn limiter;\n\t\t\n\t}", "public int getPrefRunTime() {\n return prefRunTime;\n }", "public long maxValue() {\n return 0;\n }", "public int getTimeToComplete() {\n // one level is ten minutes long\n int totalTime = numberOfLevels * 10;\n if (is3D) {\n // if it's 3d then it take twice as long because its harder\n totalTime = totalTime * 2;\n }\n \n return totalTime;\n }", "TimeResource maxDuration();", "@Override\n\tpublic long getExpectedCtc() {\n\t\treturn _candidate.getExpectedCtc();\n\t}", "Double getRemainingTime();", "public static float getCurrentTime(){\n return (float)(System.currentTimeMillis()-t0)/1000.0f;\r\n }", "public Long getMaxDelayTime() {\n return this.MaxDelayTime;\n }", "protected double getElapsedTime() {\n\t\treturn Utilities.getTime() - startTime;\n\t}", "private long remainingTime() {\n final long remainingTime = this.designatedEnd - System.currentTimeMillis();\n return remainingTime >= 0 ? remainingTime : 0L;\n }", "public double finalScore() {\n return dependencyScore;\n }", "@Override\r\n\tpublic int requiredTime() {\n\t\treturn 0;\r\n\t}", "public long getTimeLimit() {\n\t\treturn timeLimit;\n\t}", "public long getBestSolutionTime();", "public Date getCtime() {\r\n return ctime;\r\n }", "public double getTimestamp() {\n switch (randomType) {\n case EXPONENT:\n return forArrive ? (-1d / LAMBDA) * Math.log(Math.random()) : (-1d / NU) * Math.log(Math.random());\n\n default:\n return 0;\n }\n }", "@Override\r\n public Double getValue() {\r\n return Math.random()*Integer.MAX_VALUE;\r\n \r\n }", "public float getMinAlturaCM();", "@DISPID(60)\r\n\t// = 0x3c. The runtime will prefer the VTID if present\r\n\t@VTID(58)\r\n\tint actualRunTime_Seconds();", "public int maximum_heart_rate() {\r\n return (220 - age());\r\n }", "public double nextServiceTime() {\n return (-1 / mu) * Math.log(1 - randomST.nextDouble());\n }", "public double DiskServiceTime()\r\n\t{\r\n\t\tdouble rand = 0.0;\r\n\t\tdouble sum = 0.0;\r\n\t\tfor(int i=0; i<10; i++)\r\n\t\t{\r\n\t\t\tsum += Math.random();\r\n\t\t}\r\n\t\tsum = (sum - 10.0/2.0) / Math.sqrt(10.0/12.0);\r\n\t\trand = 20.0 * sum - 100.0;\r\n\t\trand = Math.abs(rand);\r\n\t\treturn rand;\r\n\t}", "public double getMaximumScore() {\n return 0.9; // TODO: parameter\n }", "public float getGCRatio()\r\n\t{\r\n\t\tint count = 0;\r\n\t\tfor (int i = 0; i < this.sequence.length(); i++)\r\n\t\t{\r\n\t\t\tchar a = this.sequence.charAt(i);\r\n\t\t\tif (a == 'G' || a == 'C')\r\n\t\t\t{\r\n\t\t\t\tcount++;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn (float) count / (float) this.sequence.length();\r\n\t}", "public double getTime() {return _time;}", "public double getChance() {\n return this.chance;\n }", "public static double toc() {\n\t\treturn System.currentTimeMillis() / 1000d - t;\n\t}", "double getReliability();", "private long getAbsMax() {\n return Math.max(Math.abs(Visualizer.getLowerBound().get()),\n Visualizer.getUpperBound().get());\n }", "public Integer getCusTime() {\r\n return cusTime;\r\n }", "private int getCurrentValue()\n {\n return\n // Overall wait time...\n _countdownValue -\n // ...minus the time we waited so far.\n (int)(_clock.currentTime() - _startWait);\n }", "float genChance();", "public double getCumTime() {\n return cumTime;\n }", "@Override\r\n\tpublic void updateCV() {\n\r\n\t}", "public double getTime() { return time; }", "public double getMaximumPositionErrorInArcsec ( ) {\r\n\t\treturn 5.0;\r\n\t}", "public double getMaximumPositionErrorInArcsec ( ) {\r\n\t\treturn 5.0;\r\n\t}", "public double getObjectiveValue() {\n\t\treturn 0;\r\n\t}", "private long getSampleTime() {\n return System.currentTimeMillis();\n\n }", "public double magnitude() {\n return celestialMagnitude;\n }", "public double getTime()\n {\n long l = System.currentTimeMillis()-base;\n return l/1000.0;\n }", "public double nextArrivalTime() {\n return (-1 / lambda) * Math.log(1 - randomAT.nextDouble());\n }", "double getMax() {\n\t\t\treturn value_max;\n\t\t}" ]
[ "0.6231228", "0.5738474", "0.5606859", "0.5587257", "0.55771506", "0.55460984", "0.55440056", "0.5508589", "0.54948664", "0.54938996", "0.5484818", "0.5459471", "0.54098296", "0.5406554", "0.53656775", "0.5364457", "0.5357651", "0.53181565", "0.5313617", "0.5310795", "0.530744", "0.53022075", "0.5287244", "0.5251417", "0.52501327", "0.5246538", "0.5232303", "0.52279085", "0.5226572", "0.5199082", "0.51960105", "0.5192311", "0.51648617", "0.5146018", "0.51417387", "0.513043", "0.51298875", "0.5124022", "0.5105453", "0.5100119", "0.5098726", "0.50977904", "0.5091941", "0.50860244", "0.50825", "0.5077504", "0.50765026", "0.5067201", "0.50628066", "0.5062299", "0.50607437", "0.504549", "0.50453305", "0.5034741", "0.5033772", "0.5032631", "0.50254434", "0.5024572", "0.50205034", "0.50147516", "0.50044477", "0.50026053", "0.5002239", "0.500013", "0.49947175", "0.49927765", "0.4991016", "0.49905577", "0.4985162", "0.49811003", "0.49806923", "0.49795473", "0.4974979", "0.49741092", "0.4969539", "0.4966851", "0.49588093", "0.4956224", "0.4953047", "0.49497357", "0.49482694", "0.49467105", "0.4945445", "0.49418348", "0.49418217", "0.49417943", "0.4940323", "0.49341604", "0.49336234", "0.4933005", "0.4932463", "0.49283582", "0.49275947", "0.49275947", "0.49252716", "0.49218935", "0.49208513", "0.49188322", "0.49184558", "0.49178034" ]
0.69420344
0
check that the two objects are logically equal.
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof TimeTrigger)) return false; final TimeTrigger that = (TimeTrigger) obj; if (AmmoType.differ(this.type, that.type)) return false; switch (this.type) { case ABS: if (AmmoType.differ(this.abs, that.abs)) return false; return true; case REL: if (AmmoType.differ(this.rel, that.rel)) return false; return true; default: return false; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "boolean canEqual(Object obj);", "@Test\n @DisplayName(\"Test should detect inequality between unequal states.\")\n public void testShouldResultInInequality() {\n ObjectBag os1 = new ObjectBag(null, \"Hi\");\n ObjectBag os2 = new ObjectBag(null, \"Goodbye\");\n\n Assertions.assertThat(os1).isNotEqualTo(os2);\n }", "@Test\r\n\tpublic void testEquality(){\n\t\t assertEquals(object1, object2);\r\n\t}", "public void testEqualsObject() {\n\t\t\tTipoNodoLeisure tipo1 = new TipoNodoLeisure(Messages.getString(\"TipoNodoLeisureTest.0\")); //$NON-NLS-1$\n\t\t\tTipoNodoLeisure tipo2= new TipoNodoLeisure(Messages.getString(\"TipoNodoLeisureTest.1\")); //$NON-NLS-1$\n\t\t\tTipoNodoLeisure tipo3= new TipoNodoLeisure(Messages.getString(\"TipoNodoLeisureTest.2\")); //$NON-NLS-1$\n\t\t\tif (tipo1 != tipo1)\n\t\t\t\tfail(Messages.getString(\"TipoNodoLeisureTest.3\")); //$NON-NLS-1$\n\t\t\tif (!tipo1.equals(tipo2))\n\t\t\t\tfail(Messages.getString(\"TipoNodoLeisureTest.4\"));\t\t\t //$NON-NLS-1$\n\t\t\tif (tipo1.equals(tipo3))\n\t\t\t\tfail(Messages.getString(\"TipoNodoLeisureTest.5\"));\t //$NON-NLS-1$\n\t\t}", "@Test\n void testEquals() {\n final boolean expected_boolean = true;\n\n // Properties for the objects\n final String username = \"username\";\n final String name = \"their_name\";\n final String password = \"password\";\n\n // Create two LoginAccount objects\n LoginAccount first_account = new LoginAccount(username, name, password);\n LoginAccount second_account = new LoginAccount(username, name, password);\n\n // Variable to check\n boolean objects_are_equal = first_account.equals(second_account);\n\n // Assert that the two boolean values are the same\n assertEquals(expected_boolean, objects_are_equal);\n }", "private static void checkEqualsAndHashCodeMethods(Object lhs, Object rhs,\n boolean expectedResult) {\n if ((lhs == null) && (rhs == null)) {\n Assert.assertTrue(\n \"Your check is dubious...why would you expect null != null?\",\n expectedResult);\n return;\n }\n\n if ((lhs == null) || (rhs == null)) {\n Assert.assertFalse(\n \"Your check is dubious...why would you expect an object \"\n + \"to be equal to null?\", expectedResult);\n }\n\n if (lhs != null) {\n assertEquals(expectedResult, lhs.equals(rhs));\n }\n if (rhs != null) {\n assertEquals(expectedResult, rhs.equals(lhs));\n }\n\n if (expectedResult) {\n String hashMessage =\n \"hashCode() values for equal objects should be the same\";\n Assert.assertTrue(hashMessage, lhs.hashCode() == rhs.hashCode());\n }\n }", "public void testEqualsObject()\n {\n // Null check\n assertFalse(b1.equals(null));\n // Type mismatch\n assertFalse(b1.equals(\"a\"));\n\n // Reflexive\n assertTrue(b1.equals(b1));\n\n // In general, two empty boards\n assertTrue(b1.equals(b2));\n\n // Different contents\n b1.setCell(0, 0, Cell.RED1);\n assertFalse(b1.equals(b2));\n\n // Same Contents\n b2.setCell(0, 0, Cell.RED1);\n assertTrue(b1.equals(b2));\n\n // Some more complex cases\n b1.fromString(\"RRRBEEBBE\");\n assertFalse(b1.equals(b2));\n b2.fromString(\"RRRBEEBBE\");\n assertTrue(b1.equals(b2));\n\n }", "@NeededForTesting\n public static boolean areObjectsEqual(Object a, Object b) {\n return a == b || (a != null && a.equals(b));\n }", "@Test\n\tpublic void testEqualsObject_True() {\n\t\tbook3 = new Book(DEFAULT_TITLE, DEFAULT_AUTHOR, DEFAULT_YEAR, DEFAULT_ISBN);\n\t\tassertEquals(book1, book3);\n\t}", "@Test\n @DisplayName(\"Test should detect equality between equal states.\")\n public void testShouldResultInEquality() {\n ObjectBag os1 = new ObjectBag(null, \"Hi\");\n ObjectBag os2 = new ObjectBag(null, \"Hi\");\n\n Assertions.assertThat(os1).isEqualTo(os2);\n }", "@Test\n\tpublic void testEqualsObject_False() {\n\t\tassertNotEquals(book1, book2);;\n\t}", "@Override // com.google.common.base.Equivalence\n public boolean doEquivalent(Object a, Object b) {\n return false;\n }", "@Test\n public void testEquals02() {\n System.out.println(\"equals\");\n Object otherObject = new SocialNetwork();\n boolean result = sn10.equals(otherObject);\n assertFalse(result);\n }", "@Test\n public void equals_DifferentObjects_Test() {\n Assert.assertFalse(bq1.equals(ONE));\n }", "protected boolean isEqual( Object lhs, Object rhs ){\r\n\t\tboolean x = lhs==null;\r\n\t\tboolean y = rhs == null;\r\n\t\t//XOR OPERATOR, only one is null\r\n\t\tif ((x || y) && !(x && y))\r\n\t\t\treturn false;\r\n\t\tif (lhs.equals(rhs))\r\n\t\t\treturn true;\r\n\t\treturn false;\r\n\t}", "private static final boolean equal(Object a, Object b) {\n if (a == b)\n return true;\n if (a == null)\n return false;\n if (b == null)\n return false;\n return a.equals(b);\n }", "public boolean isIdentical(Remote obj1, Remote obj2)\n {\n\torg.omg.CORBA.Object corbaObj1 = (org.omg.CORBA.Object)obj1;\n\torg.omg.CORBA.Object corbaObj2 = (org.omg.CORBA.Object)obj2;\n\n\treturn corbaObj1._is_equivalent(corbaObj2);\n }", "@Test\n public void testEquals() {\n System.out.println(\"Animal.equals\");\n Animal newAnimal = new Animal(252, \"Candid Chandelier\", 10, \"Cheetah\", 202);\n assertTrue(animal1.equals(newAnimal));\n assertFalse(animal2.equals(newAnimal));\n }", "@Test\n public void testEquals_2() {\n LOGGER.info(\"testEquals_2\");\n final AtomString atomString = new AtomString(\"Hello\");\n final Atom atom = new AtomString(\"Hej\");\n final boolean actual = atomString.equals(atom);\n assertFalse(actual);\n }", "@Override // com.google.common.base.Equivalence\n public boolean doEquivalent(Object a, Object b) {\n return a.equals(b);\n }", "public void testEquals()\n {\n // test passing null to equals returns false\n // (as specified in the JDK docs for Object)\n EthernetAddress x =\n new EthernetAddress(VALID_ETHERNET_ADDRESS_BYTE_ARRAY);\n assertFalse(\"equals(null) didn't return false\",\n x.equals((Object)null));\n \n // test passing an object which is not a EthernetAddress returns false\n assertFalse(\"x.equals(non_EthernetAddress_object) didn't return false\",\n x.equals(new Object()));\n \n // test a case where two EthernetAddresss are definitly not equal\n EthernetAddress w =\n new EthernetAddress(ANOTHER_VALID_ETHERNET_ADDRESS_BYTE_ARRAY);\n assertFalse(\"x == w didn't return false\",\n x == w);\n assertFalse(\"x.equals(w) didn't return false\",\n x.equals(w));\n\n // test refelexivity\n assertTrue(\"x.equals(x) didn't return true\",\n x.equals(x));\n \n // test symmetry\n EthernetAddress y =\n new EthernetAddress(VALID_ETHERNET_ADDRESS_BYTE_ARRAY);\n assertFalse(\"x == y didn't return false\",\n x == y);\n assertTrue(\"y.equals(x) didn't return true\",\n y.equals(x));\n assertTrue(\"x.equals(y) didn't return true\",\n x.equals(y));\n \n // now we'll test transitivity\n EthernetAddress z =\n new EthernetAddress(VALID_ETHERNET_ADDRESS_BYTE_ARRAY);\n assertFalse(\"x == y didn't return false\",\n x == y);\n assertFalse(\"x == y didn't return false\",\n y == z);\n assertFalse(\"x == y didn't return false\",\n x == z);\n assertTrue(\"x.equals(y) didn't return true\",\n x.equals(y));\n assertTrue(\"y.equals(z) didn't return true\",\n y.equals(z));\n assertTrue(\"x.equals(z) didn't return true\",\n x.equals(z));\n \n // test consistancy (this test is just calling equals multiple times)\n assertFalse(\"x == y didn't return false\",\n x == y);\n assertTrue(\"x.equals(y) didn't return true\",\n x.equals(y));\n assertTrue(\"x.equals(y) didn't return true\",\n x.equals(y));\n assertTrue(\"x.equals(y) didn't return true\",\n x.equals(y));\n }", "public boolean checker(Object primObj, Object equalObj, Object diffObj) {\n logger.log(Level.FINE, \"Primary object:: \" + primObj);\n logger.log(Level.FINE,\n \"Object that is equal to the primary one:: \" + equalObj);\n logger.log(Level.FINE,\n \"Object that is different from the primary one:: \" + diffObj);\n\n if (!primObj.equals(equalObj)) {\n logger.log(Level.FINE, primObj + \" isn't equal to \" + equalObj);\n return false;\n }\n\n if (primObj.equals(diffObj)) {\n logger.log(Level.FINE, primObj + \" is equal to \" + diffObj);\n return false;\n }\n\n /*\n * Check that toString() method invoked twice on the same object\n * produces equal String objects\n */\n logger.log(Level.FINE,\n \"Check that toString() method invoked twice on the same object\"\n + \" produces equal String objects ...\");\n String str1 = primObj.toString();\n String str2 = primObj.toString();\n\n if (!(str1.equals(str2))) {\n logger.log(Level.FINE,\n \"toString() method invoked twice on the same object\"\n + \" produces non-equal String objects:\\n\" + str1 + \"\\n\"\n + str2);\n return false;\n }\n logger.log(Level.FINE, \"\\tpassed\");\n\n /*\n * Check that 2 equal objects have equal string representations\n */\n logger.log(Level.FINE,\n \"Check that 2 equal objects have equal string\"\n + \" representations ...\");\n String primObj_str = primObj.toString();\n String equalObj_str = equalObj.toString();\n\n if (!(primObj_str.equals(equalObj_str))) {\n logger.log(Level.FINE,\n \"2 equal objects have non-equal string representations:\\n\"\n + primObj_str + \"\\n\" + equalObj_str);\n return false;\n }\n logger.log(Level.FINE, \"\\tpassed\");\n return true;\n }", "public static void assertInEqualStrict( Object expected, Object actual ){\r\n\t\tassertInEqual( expected, actual );\r\n\t\tassertTrue( \r\n\t\t\tString.format(\"%s.hashcode() is expected to be inequal to %s.hashcode()\", expected, actual), \r\n\t\t\t!expected.equals(actual) );\t\r\n\t}", "boolean hasSameAs();", "@Test\n public void testEquals01() {\n System.out.println(\"equals\");\n Object otherObject = new SocialNetwork();\n SocialNetwork sn = new SocialNetwork();\n boolean result = sn.equals(otherObject);\n assertTrue(result);\n }", "public boolean isEqual(Object objectname1, Object objectname2, Class<?> voClass) {\n\t\treturn false;\n\t}", "public final void testSameObjectEquals() {\n final Transaction copy = testTransaction1;\n assertTrue(testTransaction1.equals(copy)); // pmd doesn't like either\n // way\n\n }", "@Test\n public void equals2() throws Exception {\n SmartPlayer x = new SmartPlayer(0, 1);\n SmartPlayer y = new SmartPlayer(0, 2);\n assertFalse(x.equals(y));\n }", "@Test\n public void equalsTest() {\n prepareEntitiesForEqualityTest();\n\n assertEquals(entity0, entity1);\n }", "@Test\n\tpublic void testEqualsFalso() {\n\t\t\n\t\tassertFalse(contato1.equals(contato2));\n\t}", "@Test\n public void testEquals_sameParameters() {\n CellIdentityNr cellIdentityNr =\n new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC_STR, MNC_STR, NCI,\n ALPHAL, ALPHAS, Collections.emptyList());\n CellIdentityNr anotherCellIdentityNr =\n new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC_STR, MNC_STR, NCI,\n ALPHAL, ALPHAS, Collections.emptyList());\n\n // THEN this two objects are equivalent\n assertThat(cellIdentityNr).isEqualTo(anotherCellIdentityNr);\n }", "private Comparison checkEquality(SimpleNode node1, SimpleNode node2) {\n // Compare the classes.\n Comparison comparison = compareClasses(node1, node2);\n if (!comparison.isEqual()) {\n return comparison;\n }\n\n // Compare the values.\n comparison = compareValues(node1, node2);\n if (!comparison.isEqual()) {\n return comparison;\n }\n\n // Compare the images.\n comparison = compareImages(node1, node2);\n if (!comparison.isEqual()) {\n return comparison;\n }\n\n // Compare the children.\n return compareChildren(node1, node2);\n }", "@Test\n public void testEquals() {\n System.out.println(\"equals\");\n Receta instance = new Receta();\n instance.setNombre(\"nom1\");\n Receta instance2 = new Receta();\n instance.setNombre(\"nom2\");\n boolean expResult = false;\n boolean result = instance.equals(instance2);\n assertEquals(expResult, result);\n }", "@Test public void equalsTest() throws NegativeValueException {\n PetBunny pb1 = new PetBunny(\"Floppy\", \"Holland Lop\", 3.5);\n PetBunny same = new PetBunny(\"Floppy\", \"Holland Lop\", 3.5);\n PetBunny badName = new PetBunny(\"Flop\", \"Holland Lop\", 3.5);\n PetBunny badBreed = new PetBunny(\"Floppy\", \"Holland Plop\", 3.5);\n PetBunny badWeight = new PetBunny(\"Floppy\", \"Holland Lop\", 5.0);\n String nothing = \"test\";\n \n Assert.assertTrue(pb1.equals(same));\n Assert.assertFalse(pb1.equals(nothing));\n Assert.assertFalse(pb1.equals(badName));\n Assert.assertFalse(pb1.equals(badBreed));\n Assert.assertFalse(pb1.equals(badWeight));\n }", "public final void testDifferentClassEquals() {\n final Account test = new Account(\"Test\");\n assertFalse(testTransaction1.equals(test));\n // pmd doesn't like either way\n }", "@Test\n public void testEquals_differentParameters() {\n CellIdentityNr cellIdentityNr =\n new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC_STR, MNC_STR, NCI,\n ALPHAL, ALPHAS, Collections.emptyList());\n CellIdentityNr anotherCellIdentityNr =\n new CellIdentityNr(PCI, TAC, NRARFCN, BANDS, MCC_STR, MNC_STR, NCI + 1,\n ALPHAL, ALPHAS, Collections.emptyList());\n\n // THEN this two objects are different\n assertThat(cellIdentityNr).isNotEqualTo(anotherCellIdentityNr);\n }", "@Test\r\n public void ObjectsAreNotTheSame() {\n try_scorers = new Try_Scorers(\"Sharief\",\"Roman\",3,9);\r\n Assert.assertNotSame(try_scorers ,try_scorers.updateGamesPlayed(4),\"The Objects are the same\"); \r\n \r\n }", "@SuppressWarnings({\"UnnecessaryLocalVariable\"})\n @Test\n void testEqualsAndHashCode(SoftAssertions softly) {\n SortOrder sortOrder0 = new SortOrder(\"i0\", true, false, true);\n SortOrder sortOrder1 = sortOrder0;\n SortOrder sortOrder2 = new SortOrder(\"i0\", true, false, true);\n\n softly.assertThat(sortOrder0.hashCode()).isEqualTo(sortOrder2.hashCode());\n //noinspection EqualsWithItself\n softly.assertThat(sortOrder0.equals(sortOrder0)).isTrue();\n //noinspection ConstantConditions\n softly.assertThat(sortOrder0.equals(sortOrder1)).isTrue();\n softly.assertThat(sortOrder0.equals(sortOrder2)).isTrue();\n\n SortOrder sortOrder3 = new SortOrder(\"i1\", true, false, true);\n softly.assertThat(sortOrder0.equals(sortOrder3)).isFalse();\n\n //noinspection EqualsBetweenInconvertibleTypes\n softly.assertThat(sortOrder0.equals(new SortOrders())).isFalse();\n }", "@Test\n public void testEquals() {\n System.out.println(\"equals\");\n Commissioner instance = new Commissioner();\n Commissioner instance2 = new Commissioner();\n instance.setLogin(\"genie\");\n instance2.setLogin(\"genie\");\n boolean expResult = true;\n boolean result = instance.equals(instance2);\n assertEquals(expResult, result);\n }", "@Test\n\tpublic void test_TCM__boolean_equals_Object() {\n\t\tfinal Attribute attribute = new Attribute(\"test\", \"value\");\n\n assertFalse(\"attribute equal to null\", attribute.equals(null));\n\n final Object object = attribute;\n assertTrue(\"object not equal to attribute\", attribute.equals(object));\n assertTrue(\"attribute not equal to object\", object.equals(attribute));\n\n // current implementation checks only for identity\n// final Attribute clonedAttribute = (Attribute) attribute.clone();\n// assertTrue(\"attribute not equal to its clone\", attribute.equals(clonedAttribute));\n// assertTrue(\"clone not equal to attribute\", clonedAttribute.equals(attribute));\n\t}", "@Test\n\tpublic void testEquals1() {\n\t\tDistance d1 = new Distance(0, 0);\n\t\tDistance d2 = new Distance();\n\t\tassertEquals(false, d1.equals(d2));\n\t}", "public void testObjEqual()\n {\n assertEquals( true, Util.objEqual(null,null) );\n assertEquals( false,Util.objEqual(this,null) );\n assertEquals( false,Util.objEqual(null,this) );\n assertEquals( true, Util.objEqual(this,this) );\n assertEquals( true, Util.objEqual(\"12\",\"12\") );\n }", "boolean equalTo(ObjectPassDemo o) {\n return (o.a == a && o.b == b);\n }", "@Test\n public void testEquals() {\n assertFalse(jesseOberstein.equals(nathanGoodman));\n assertTrue(kateHutchinson.equals(kateHutchinson));\n }", "@Test\n\tpublic void testEqualsVerdadeiro() {\n\t\t\n\t\tassertTrue(contato1.equals(contato3));\n\t}", "static public boolean areEqual(Object aThis, Object aThat) {\r\n // System.out.println(\"Object\");\r\n return aThis == null ? aThat == null : aThis.equals(aThat);\r\n }", "@Test\n\tpublic void testEquals() {\n\t\tPMUser user = new PMUser(\"Smith\", \"John\", \"jsmith@gmail.com\");\n\t\tPark a = new Park(\"name\", \"address\", user);\n\t\tPark b = new Park(\"name\", \"address\", user);\n\t\tPark c = new Park(\"name\", \"different address\", user);\n\t\tassertEquals(a, a);\n\t\tassertEquals(a, b);\n\t\tassertEquals(b, a);\n\t\tassertFalse(a.equals(c));\n\t}", "@Test\n public void testEqualsTrue() {\n Rectangle r5 = new Rectangle(7, 4, new Color(255, 0, 0), new Position2D(50, 75));\n Rectangle r6 = new Rectangle(0, 4, new Color(255, 255, 255),\n new Position2D(-50, 75));\n Rectangle r7 = new Rectangle(7, 0, new Color(255, 255, 0), new Position2D(50, -75));\n Rectangle r8 = new Rectangle(0, 0, new Color(200, 150, 133),\n new Position2D(-50, -75));\n\n assertEquals(r1, r5);\n assertEquals(r2, r6);\n assertEquals(r3, r7);\n assertEquals(r4, r8);\n }", "@Test \n\tpublic void checkEquality() {\n\t\tassertTrue(testCell.equals(testCell));\n\t\tassertFalse(testCell.equals(new Cell(false)));\n\n\t}", "@Test\n public void equals() throws Exception {\n SmartPlayer x = new SmartPlayer(0, 0);\n SmartPlayer y = new SmartPlayer(0, 0);\n assertTrue(x.equals(y));\n }", "@Test\n void equals1() {\n Student s1=new Student(\"emina\",\"milanovic\",18231);\n Student s2=new Student(\"emina\",\"milanovic\",18231);\n assertEquals(true,s1.equals(s2));\n }", "public void testEquals() throws Exception {\n State state1 = new State();\n state1.setCanJump(1);\n state1.setDirection(1);\n state1.setGotHit(1);\n state1.setHeight(1);\n state1.setMarioMode(1);\n state1.setOnGround(1);\n state1.setEnemiesSmall(new boolean[3]);\n state1.setObstacles(new boolean[4]);\n state1.setDistance(1);\n state1.setStuck(1);\n\n State state2 = new State();\n state2.setCanJump(1);\n state2.setDirection(1);\n state2.setGotHit(1);\n state2.setHeight(1);\n state2.setMarioMode(1);\n state2.setOnGround(1);\n state2.setEnemiesSmall(new boolean[3]);\n state2.setObstacles(new boolean[4]);\n state2.setStuck(1);\n\n State state3 = new State();\n state3.setCanJump(1);\n state3.setDirection(1);\n state3.setGotHit(1);\n state3.setHeight(1);\n state3.setMarioMode(2);\n state3.setOnGround(1);\n state3.setEnemiesSmall(new boolean[3]);\n state3.setObstacles(new boolean[4]);\n assertEquals(state1,state2);\n assertTrue(state1.equals(state2));\n assertFalse(state1.equals(state3));\n Set<State> qTable = new HashSet<State>();\n qTable.add(state1);\n qTable.add(state2);\n assertEquals(1,qTable.size());\n qTable.add(state3);\n assertEquals(2,qTable.size());\n\n }", "public abstract boolean equals(Object other);", "@Test\n public void testEquals_1() {\n LOGGER.info(\"testEquals_1\");\n final AtomString atomString = new AtomString(\"Hello\");\n final Atom atom = new AtomString(\"Hello\");\n final boolean actual = atomString.equals(atom);\n assertTrue(actual);\n }", "static public boolean testEquality(Object a, Object b) {\r\n\t\tif (a == null && b == null) // undefined == undefined\r\n\t\t\treturn true;\r\n\t\tif ((a == null || b == null) && (a instanceof JSNull || b instanceof JSNull)) // undefined or null\r\n\t\t\treturn true;\r\n\t\tif ((a == null && b instanceof JSNull) || (a == null && b instanceof JSNull)) // anything == undefined\r\n\t\t\treturn true;\r\n\t\tif (a == null || b == null) // anything equals null\r\n\t\t\treturn false;\r\n\t\treturn a.equals(b);\r\n\t}", "public boolean equal(Object obj1, Object obj2) {\n\t\treturn obj1.equals(obj2);\r\n\t}", "@Test\n public void testEquals_2()\n throws Exception {\n Project fixture = new Project();\n fixture.setWorkloadNames(\"\");\n fixture.setName(\"\");\n fixture.setScriptDriver(ScriptDriver.SilkPerformer);\n fixture.setWorkloads(new LinkedList());\n fixture.setComments(\"\");\n fixture.setProductName(\"\");\n Object obj = new Project();\n\n boolean result = fixture.equals(obj);\n\n assertEquals(true, result);\n }", "@Test\n\tpublic void testSampleEquals() {\n\n\t\tassertTrue(square.equals(squareRotate));\n\t\t\n\t\tassertTrue(pyr1.equals(pyr5));\n\t\t\n\t\tassertTrue(s.equals(sInitial));\n\t\tassertFalse(stick.equals(stickRotated));\n\t\tassertFalse(s.equals(sRotated));\n\n\n\t}", "@Test\n public void equals() {\n assertTrue(semester.equals(new Semester(1, 0)));\n\n // same object -> returns true\n assertTrue(semester.equals(semester));\n\n // null -> returns false\n assertFalse(semester.equals(null));\n\n // different type -> returns false\n assertFalse(semester.equals(5));\n\n // different year -> returns false\n assertFalse(semester.equals(new Semester(2, 0)));\n\n // different index -> returns false\n assertFalse(semester.equals(new Semester(1, 1)));\n\n // different modules -> returns false\n Semester differentSemester = new Semester(1, 0);\n differentSemester.addModules(getTypicalModules());\n assertFalse(semester.equals(differentSemester));\n }", "public static void assertEqualsStrict(Object expected, Object actual){\r\n\t\tassertEquals( expected, actual );\r\n\t\tassertEquals( \"hashcode() is not equal: \", expected.hashCode(), actual.hashCode());\r\n\t}", "@Test\n\tpublic void test_equals2() {\n\tTennisPlayer c1 = new TennisPlayer(11,\"Joe Tsonga\");\n\tTennisPlayer c2 = new TennisPlayer(521,\"Joe Tsonga\");\n\tassertFalse(c1.equals(c2));\n }", "public boolean mojeEquals(Obj o1, Obj o2) {\r\n\t\t//System.out.println(o1.getName() + \" \" + o2.getName());\r\n\t\tboolean sameRight = true; // 21.06.2020. provera prava pristupa\r\n\t\tboolean sameName = true;\t// 22.06.2020. ako nisu metode ne moraju da imaju isto ime\r\n\t\tboolean sameArrayType = true; //22.6.2020 ako je parametar niz mora isti tip niza da bude\r\n\t\t\r\n\t\tif (o1.getKind() == Obj.Meth && o2.getKind() == Obj.Meth) {\r\n\t\t\tsameRight = o1.getFpPos() == o2.getFpPos()+10; \r\n\t\t\tsameName = o1.getName().equals(o2.getName());\r\n\t\t}\r\n\t\telse {\r\n\t\t\tif (o1.getType().getKind() == Struct.Array && o2.getType().getKind() == Struct.Array) {\r\n\t\t\t\tif (!(o1.getType().getElemType() == o2.getType().getElemType())) { // ZA KLASE MOZDA TREBA equals\r\n\t\t\t\t\tsameArrayType = false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\t// 16.08.2020.\r\n//\t\tif (o1.getType().getKind() == Struct.Class || o1.getType().getKind() == Struct.Interface)\r\n//\t\t\treturn true;\r\n\t\t\r\n\t\t\r\n\t\treturn o1.getKind() == o2.getKind() \r\n\t\t\t\t&& sameName\r\n\t\t\t\t&& o1.getType().equals(o2.getType())\r\n\t\t\t\t&& /*adr == other.adr*/ o1.getLevel() == o2.getLevel()\r\n\t\t\t\t&& equalsCompleteHash(o1.getLocalSymbols(), o2.getLocalSymbols())\r\n\t\t\t\t&& sameRight // 21.06.2020. provera prava pristupa\r\n\t\t\t\t&& sameArrayType; //22.6.2020 ako je parametar niz mora isti tip niza da bude\r\n\t}", "public final void testNullObjectEquals() {\n assertFalse(testTransaction1.equals(null)); // needed for test\n // pmd doesn't like either way\n }", "@Test\n\tpublic void test_equals2() {\n\tTvShow t1 = new TvShow(\"Sherlock\",\"BBC\");\n\tTvShow t2 = new TvShow(\"NotSherlock\",\"BBC\");\n\tassertFalse(t1.equals(t2));\n }", "public static boolean isSameObject(Object a, Object b) {\n return Builtins.isSameObject(a, b);\n }", "@SuppressWarnings(\"unlikely-arg-type\")\n @Test\n public void testEquals() {\n Order order = new Order(\"Test\", LocalTime.NOON, GridCoordinate.ZERO);\n Order same = new Order(\"Test\", LocalTime.NOON, GridCoordinate.ZERO);\n Order other = new Order(\"Test\", LocalTime.MIDNIGHT, GridCoordinate.ZERO);\n Order another = new Order(\"Test\", LocalTime.NOON, GridCoordinate.of(1, 1));\n Order more = new Order(\"Test2\", LocalTime.NOON, GridCoordinate.ZERO);\n\n Assert.assertTrue(\"Two objects with the same addresses should be equal.\", order.equals(order));\n Assert.assertFalse(\"Null check.\", order.equals(null));\n Assert.assertFalse(\"Type check.\", order.equals(\"\"));\n Assert.assertFalse(\"Different order times.\", order.equals(other));\n Assert.assertFalse(\"Different customer locations.\", order.equals(another));\n Assert.assertFalse(\"Different order IDs.\", order.equals(more));\n Assert.assertTrue(\"Same values.\", order.equals(same));\n }", "@Test\n\tpublic void test_equals1() {\n\tTennisPlayer c1 = new TennisPlayer(11,\"Joe Tsonga\");\n\tTennisPlayer c2 = new TennisPlayer(11,\"Joe Tsonga\");\n\tassertTrue(c1.equals(c2));\n }", "@Test\n public void testEquals() {\n \n Beneficiaire instance = ben2;\n Beneficiaire unAutreBeneficiaire = ben3;\n boolean expResult = false;\n boolean result = instance.equals(unAutreBeneficiaire);\n assertEquals(expResult, result);\n\n unAutreBeneficiaire = ben2;\n expResult = true;\n result = instance.equals(unAutreBeneficiaire);\n assertEquals(expResult, result);\n }", "@Test\n public void testEquals() {\n Coctail c1 = new Coctail(\"coctail\", new Ingredient[]{ \n new Ingredient(\"ing1\"), new Ingredient(\"ing2\")});\n Coctail c2 = new Coctail(\"coctail\", new Ingredient[]{ \n new Ingredient(\"ing1\"), new Ingredient(\"ing2\")});\n assertEquals(c1, c2);\n }", "@Test\n public void equalsSameTest() {\n Device device2 = new Device(deviceID, token);\n assertEquals(device, device2);\n }", "public static void main(String[] args) {\n\t\tObjectWithoutEquals noEquals = new ObjectWithoutEquals(1, 10.0);\n\n\t\t// This class includes an implementation of hashCode and equals\n\t\tObjectWithEquals withEquals = new ObjectWithEquals(1, 10.0);\n\n\t\t// Of course, these two instances are not going to be equal because they\n\t\t// are instances of two different classes.\n\t\tSystem.out.println(\"Two instances of difference classes, equal?: \"\n\t\t\t\t+ withEquals.equals(noEquals));\n\t\tSystem.out.println(\"Two instances of difference classes, equal?: \"\n\t\t\t\t+ noEquals.equals(withEquals));\n\t\tSystem.out.println();\n\n\t\t// Now, let's create two more instances of these classes using the same\n\t\t// input parameters.\n\t\tObjectWithoutEquals noEquals2 = new ObjectWithoutEquals(1, 10.0);\n\t\tObjectWithEquals withEquals2 = new ObjectWithEquals(1, 10.0);\n\n\t\tSystem.out.println(\"Two instances of ObjectWithoutEquals, equal?: \"\n\t\t\t\t+ noEquals.equals(noEquals2));\n\t\tSystem.out.println(\"Two instances of ObjectWithEquals, equal?: \"\n\t\t\t\t+ withEquals.equals(withEquals2));\n\t\tSystem.out.println();\n\n\t\t// If you do not implement the equals method, then equals only returns\n\t\t// true if the two variables are referring to the same instance.\n\n\t\tSystem.out.println(\"Same instance of ObjectWithoutEquals, equal?: \"\n\t\t\t\t+ noEquals.equals(noEquals));\n\t\tSystem.out.println(\"Same instance of ObjectWithEquals, equal?: \"\n\t\t\t\t+ withEquals.equals(withEquals));\n\t\tSystem.out.println();\n\n\t\t// Of course, the exact same instance should be equal to itself.\n\n\t\t// Also, the == operator checks if the instance on the left and right of\n\t\t// the operator are referencing the same instance.\n\t\tSystem.out.println(\"Two instances of ObjectWithoutEquals, ==: \"\n\t\t\t\t+ (noEquals == noEquals2));\n\t\tSystem.out.println(\"Two instances of ObjectWithEquals, ==: \"\n\t\t\t\t+ (withEquals == withEquals2));\n\t\tSystem.out.println();\n\t\t// Which in this case, they are not.\n\n\t\t//\n\t\t// How the equals method is used in Collections\n\t\t//\n\n\t\t// The behavior of the equals method can influence how other things work\n\t\t// in Java.\n\t\t// For example, if these instances where included in a Collection:\n\t\tList<ObjectWithoutEquals> noEqualsList = new ArrayList<ObjectWithoutEquals>();\n\t\tList<ObjectWithEquals> withEqualsList = new ArrayList<ObjectWithEquals>();\n\n\t\t// Add the first two instances that we created earlier:\n\t\tnoEqualsList.add(noEquals);\n\t\twithEqualsList.add(withEquals);\n\n\t\t// If we check if the list contains the other instance that we created\n\t\t// earlier:\n\t\tSystem.out.println(\"List of ObjectWithoutEquals, contains?: \"\n\t\t\t\t+ noEqualsList.contains(noEquals2));\n\t\tSystem.out.println(\"List of ObjectWithEquals, contains?: \"\n\t\t\t\t+ withEqualsList.contains(withEquals2));\n\t\tSystem.out.println();\n\n\t\t// The class with no equals method says that it does not contain the\n\t\t// instance even though there is an instance with the same parameters in\n\t\t// the List.\n\n\t\t// The class with an equals method does contain the instance as\n\t\t// expected.\n\n\t\t// So, if you try to use the values as keys in a Map:\n\t\tMap<ObjectWithoutEquals, Double> noEqualsMap = new HashMap<ObjectWithoutEquals, Double>();\n\t\tnoEqualsMap.put(noEquals, 10.0);\n\t\tnoEqualsMap.put(noEquals2, 20.0);\n\n\t\tMap<ObjectWithEquals, Double> withEqualsMap = new HashMap<ObjectWithEquals, Double>();\n\t\twithEqualsMap.put(withEquals, 10.0);\n\t\twithEqualsMap.put(withEquals2, 20.0);\n\n\t\t// Then the Map using the class with the default equals method\n\t\t// will contain two keys and two values, while the Map using the class\n\t\t// with an equals method will only have one key and one value\n\t\t// (because it knows that the two keys are equal).\n\t\tSystem.out.println(\"Map using ObjectWithoutEquals: \" + noEqualsMap);\n\t\tSystem.out.println(\"Map using ObjectWithEquals: \" + withEqualsMap);\n\t\tSystem.out.println();\n\n\t\t//\n\t\t// The hashCode method\n\t\t//\n\n\t\t// Another method used by Collections is the hashCode method. If the\n\t\t// equals method says that two instances are equal, then the hashCode\n\t\t// method should generate the same int.\n\n\t\t// The hashCode value is used in Maps\n\t\tSystem.out.println(\"Two instances of ObjectWithoutEquals, hashCodes?: \"\n\t\t\t\t+ noEquals.hashCode() + \" and \" + noEquals2.hashCode());\n\t\tSystem.out.println(\"Two instances of ObjectWithEquals, hashCodes?: \"\n\t\t\t\t+ withEquals.hashCode() + \" and \" + withEquals2.hashCode());\n\t\tSystem.out.println();\n\n\t\t// Since the default hashCode method is overridden in the\n\t\t// ObjectWithEquals class, the two instances return the same int value.\n\n\t\t// The hashCode method is not required to give a unique value\n\t\t// for every unequal instance, but performance can be improved by having\n\t\t// the hashCode method generate distinct values.\n\n\t\t// For example:\n\t\tMap<ObjectWithEquals, Integer> mapUsingDistinctHashCodes = new HashMap<ObjectWithEquals, Integer>();\n\t\tMap<ObjectWithEquals, Integer> mapUsingSameHashCodes = new HashMap<ObjectWithEquals, Integer>();\n\n\t\t// Now add 10,000 objects to each map\n\t\tfor (int i = 0; i < 10000; i++) {\n\t\t\t// Uses the hashCode in ObjectWithEquals\n\t\t\tObjectWithEquals distinctHashCode = new ObjectWithEquals(i, i);\n\t\t\tmapUsingDistinctHashCodes.put(distinctHashCode, i);\n\n\t\t\t// The following overrides the hashCode method using an anonymous\n\t\t\t// inner class.\n\t\t\t// We will get to anonymous inner classes later... the important\n\t\t\t// part is that it returns the same hashCode no matter what values\n\t\t\t// are given to the constructor, which is a really bad idea!\n\t\t\tObjectWithEquals sameHashCode = new ObjectWithEquals(i, i) {\n\t\t\t\t@Override\n\t\t\t\tpublic int hashCode() {\n\t\t\t\t\treturn 31;\n\t\t\t\t}\n\t\t\t};\n\t\t\tmapUsingSameHashCodes.put(sameHashCode, i);\n\t\t}\n\n\t\t// Iterate over the two maps and time how long it takes\n\t\tlong startTime = System.nanoTime();\n\n\t\tfor (ObjectWithEquals key : mapUsingDistinctHashCodes.keySet()) {\n\t\t\tint i = mapUsingDistinctHashCodes.get(key);\n\t\t}\n\n\t\tlong endTime = System.nanoTime();\n\n\t\tSystem.out.println(\"Time required when using distinct hashCodes: \"\n\t\t\t\t+ (endTime - startTime));\n\n\t\tstartTime = System.nanoTime();\n\n\t\tfor (ObjectWithEquals key : mapUsingSameHashCodes.keySet()) {\n\t\t\tint i = mapUsingSameHashCodes.get(key);\n\t\t}\n\n\t\tendTime = System.nanoTime();\n\n\t\tSystem.out.println(\"Time required when using same hashCodes: \"\n\t\t\t\t+ (endTime - startTime));\n\t\tSystem.out.println();\n\n\t\t//\n\t\t// Warning about hashCode method\n\t\t//\n\n\t\t// You can run into trouble if your hashCode is based on a value that\n\t\t// could change.\n\t\t// For example, we create an instance with a custom hashCode\n\t\t// implementation:\n\t\tObjectWithEquals withEquals3 = new ObjectWithEquals(1, 10.0);\n\n\t\t// Create the Map and add the instance as a key\n\t\tMap<ObjectWithEquals, Double> withEquals3Map = new HashMap<ObjectWithEquals, Double>();\n\t\twithEquals3Map.put(withEquals3, 100.0);\n\n\t\t// Print some info about Map before changing attribute\n\t\tSystem.out.println(\"Map before changing attribute of key: \"\n\t\t\t\t+ withEquals3Map);\n\t\tSystem.out\n\t\t\t\t.println(\"Map before changing attribute, does it contain key: \"\n\t\t\t\t\t\t+ withEquals3Map.containsKey(withEquals3));\n\t\tSystem.out.println();\n\n\t\t// Now we change one of the values that the hashCode is based on:\n\t\twithEquals3.setX(123);\n\n\t\t// See what the Map look like now\n\t\tSystem.out.println(\"Map after changing attribute of key: \"\n\t\t\t\t+ withEquals3Map);\n\t\tSystem.out\n\t\t\t\t.println(\"Map after changing attribute, does it contain key: \"\n\t\t\t\t\t\t+ withEquals3Map.containsKey(withEquals3));\n\t\tSystem.out.println();\n\n\t\t// What is the source of this problem?\n\t\t// So, even though we used the same instance to put a value in the Map,\n\t\t// the Map does not recognize that the key is in the Map if an attribute\n\t\t// that is being used by the hashCode method is changed.\n\t\t// This can create some really confusing behavior!\n\n\t\t//\n\t\t// Final notes about equals and hashCode\n\t\t//\n\n\t\t// Also, Eclipse has a nice feature for generating the equals and\n\t\t// hashCode methods (Source -> Generate hashCode and equals methods), so\n\t\t// I would recommend using this feature if you need to implement these\n\t\t// methods. The source generator allows you to choose which attributes\n\t\t// should be used in the equals and hashCode methods.\n\n\t\t// GOOD CODING PRACTICE:\n\t\t// When working with objects, it is good to know if you are working with\n\t\t// the same instances over and over again or if you are expected to do\n\t\t// comparisons between different instances that may actually be equal.\n\t\t//\n\t\t// Also, if you override the hashCode method, if possible have the\n\t\t// hashCode be based on immutable data (data that cannot change value).\n\t}", "protected abstract boolean isEqual(E entryA, E entryB);", "@Test\n public void equals_trulyEqual() {\n SiteInfo si1 = new SiteInfo(\n Amount.valueOf(12000, SiteInfo.CUBIC_FOOT),\n Amount.valueOf(76, NonSI.FAHRENHEIT),\n Amount.valueOf(92, NonSI.FAHRENHEIT),\n Amount.valueOf(100, NonSI.FAHRENHEIT),\n Amount.valueOf(100, NonSI.FAHRENHEIT),\n 56,\n Damage.CLASS2,\n Country.USA,\n \"Default Site\"\n );\n SiteInfo si2 = new SiteInfo(\n Amount.valueOf(12000, SiteInfo.CUBIC_FOOT),\n Amount.valueOf(76, NonSI.FAHRENHEIT),\n Amount.valueOf(92, NonSI.FAHRENHEIT),\n Amount.valueOf(100, NonSI.FAHRENHEIT),\n Amount.valueOf(100, NonSI.FAHRENHEIT),\n 56,\n Damage.CLASS2,\n Country.USA,\n \"Default Site\"\n );\n\n Assert.assertEquals(si1, si2);\n }", "@Test\n\tpublic void test_equals1() {\n\tTvShow t1 = new TvShow(\"Sherlock\",\"BBC\");\n\tTvShow t2 = new TvShow(\"Sherlock\",\"BBC\");\n\tassertTrue(t1.equals(t2));\n }", "public boolean equals(java.lang.Object other){\n return false; //TODO codavaj!!\n }", "@Test\n public void testEqualsReturnsTrueOnIdenticalRecords() {\n boolean equals = record.equals(otherRecord);\n\n assertThat(equals, is(true));\n }", "@Override\n\tpublic boolean equal() {\n\t\treturn false;\n\t}", "@org.testng.annotations.Test\n public void test_equals_Symmetric()\n throws Exception {\n CategorieClient categorieClient = new CategorieClient(\"denis\", 1000, 10.2, 1.1, 1.2, false);\n Client x = new Client(\"Denis\", \"Denise\", \"Paris\", categorieClient);\n Client y = new Client(\"Denis\", \"Denise\", \"Paris\", categorieClient);\n Assert.assertTrue(x.equals(y) && y.equals(x));\n Assert.assertTrue(x.hashCode() == y.hashCode());\n }", "public abstract boolean equals(Object o);", "@Test\n public void testEquals() {\n System.out.println(\"equals\");\n Setting s = Setting.factory();\n Setting s1 = Setting.factory();\n Setting s2 = Setting.factory();\n Setting s3 = Setting.getSetting(\"test1\");\n Setting s4 = Setting.getSetting(\"test1\");\n\n Object o = null;\n Setting instance = s;\n assertFalse(s.equals(o));\n o = new Object();\n assertFalse(s.equals(o));\n assertFalse(s.equals(s1));\n assertEquals(s3, s4);\n // TODO review the generated test code and remove the default call to fail.\n fail(\"The test case is a prototype. need more tests\");\n }", "public static boolean equal(Object a, Object b) {\r\n\t\tif (a == b) {\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\treturn a != null && b != null && a.equals(b);\r\n\t}", "protected boolean safeEquals(Object one, Object two) {\r\n\t\treturn one == null ? two == null : one.equals(two);\r\n\t}", "public static boolean notEqual(Object object1, Object object2) {\n return ObjectUtils.equals(object1, object2) == false;\n }", "@Test\r\n public void testEquals() {\r\n Articulo art = new Articulo();\r\n articuloPrueba.setCodigo(1212);\r\n art.setCodigo(1212);\r\n boolean expResult = true;\r\n boolean result = articuloPrueba.equals(art);\r\n assertEquals(expResult, result);\r\n }", "@Test\n\tpublic void testEquals2() {\n\t\tDistance d2 = new Distance();\n\t\tDistance d4 = new Distance(1, 1);\n\t\tassertEquals(true, d2.equals(d4));\n\t}", "@Test\n public void equal() {\n assertTrue(commandItem.equals(commandItemCopy));\n assertTrue(commandItem.isSameCommand(commandItemCopy));\n //not commanditem return false\n assertFalse(commandItem.equals(commandWord));\n }", "@Test\r\n public void testReflexiveForEqual() throws Exception {\n\r\n EmployeeImpl emp1 = new EmployeeImpl(\"7993389\", \"gagandeep.singh@rbs.com\");\r\n EmployeeImpl emp2 = new EmployeeImpl(\"7993389\", \"ramandeep.singh@rbs.com\");\r\n\r\n Assert.assertTrue(\"Comparable implementation is incorrect\", emp1.compareTo(emp2) == 0);\r\n Assert.assertTrue(\"Comparable implementation is incorrect\", emp1.compareTo(emp2) == emp2.compareTo(emp1));\r\n }", "@Test\n public void testEquals() {\n System.out.println(\"equals\");\n Object object = null;\n Reserva instance = new Reserva();\n boolean expResult = false;\n boolean result = instance.equals(object);\n assertEquals(expResult, result);\n \n }", "@Test\n public void testEquals() {\n\n final Role role = new Role(Role.Name.ROLE_USER);\n\n assertNotEquals(role, null);\n assertNotEquals(role, new Object());\n assertEquals(role, role);\n\n final Role roleEquals = new Role(Role.Name.ROLE_USER);\n\n assertEquals(role, roleEquals);\n\n final Role roleNotEquals = new Role(Role.Name.ROLE_COMPANY);\n final Role roleNotEquals1 = new Role(Role.Name.ROLE_TRAINING_ORGANIZATION);\n\n assertNotEquals(roleNotEquals, roleNotEquals1);\n }", "@Test\n public void equals() {\n Beneficiary animalShelterCopy = new BeneficiaryBuilder(ANIMAL_SHELTER).build();\n assertTrue(ANIMAL_SHELTER.equals(animalShelterCopy));\n\n // same object -> returns true\n assertTrue(ANIMAL_SHELTER.equals(ANIMAL_SHELTER));\n\n // null -> returns false\n assertFalse(ANIMAL_SHELTER.equals(null));\n\n // different type -> returns false\n assertFalse(ANIMAL_SHELTER.equals(5));\n\n // different beneficiary -> returns false\n assertFalse(ANIMAL_SHELTER.equals(BABES));\n\n // same name -> returns true\n Beneficiary editedAnimalShelter = new BeneficiaryBuilder(BABES).withName(VALID_NAME_ANIMAL_SHELTER).build();\n assertTrue(ANIMAL_SHELTER.equals(editedAnimalShelter));\n\n // same phone and email -> returns true\n editedAnimalShelter = new BeneficiaryBuilder(BABES)\n .withPhone(VALID_PHONE_ANIMAL_SHELTER).withEmail(VALID_EMAIL_ANIMAL_SHELTER).build();\n assertTrue(ANIMAL_SHELTER.equals(editedAnimalShelter));\n }", "@Test\n public void equalsOtherTest() {\n Device device2 = new Device(deviceID, \"other\");\n assertNotEquals(device, device2);\n }", "@Test\n public void checkEquals() {\n EqualsVerifier.forClass(GenericMessageDto.class).usingGetClass()\n .suppress(Warning.NONFINAL_FIELDS).verify();\n }", "public boolean equals(XObject obj2) {\n/* */ try {\n/* 262 */ if (4 == obj2.getType())\n/* */ {\n/* */ \n/* */ \n/* */ \n/* */ \n/* 268 */ return obj2.equals(this);\n/* */ }\n/* 270 */ if (1 == obj2.getType())\n/* */ {\n/* 272 */ return (bool() == obj2.bool());\n/* */ }\n/* 274 */ if (2 == obj2.getType())\n/* */ {\n/* 276 */ return (num() == obj2.num());\n/* */ }\n/* 278 */ if (4 == obj2.getType())\n/* */ {\n/* 280 */ return xstr().equals(obj2.xstr());\n/* */ }\n/* 282 */ if (3 == obj2.getType())\n/* */ {\n/* 284 */ return xstr().equals(obj2.xstr());\n/* */ }\n/* 286 */ if (5 == obj2.getType())\n/* */ {\n/* */ \n/* */ \n/* 290 */ return xstr().equals(obj2.xstr());\n/* */ }\n/* */ \n/* */ \n/* 294 */ return super.equals(obj2);\n/* */ \n/* */ }\n/* 297 */ catch (TransformerException te) {\n/* */ \n/* 299 */ throw new WrappedRuntimeException(te);\n/* */ } \n/* */ }", "public static boolean equals(Object obj1, Object obj2)\n {\n return obj1 == obj2;\n }", "@Test\n void compareTo_Identical_AllParts()\n {\n runIsMatchTest(AnswerType.yes, AnswerType.yes, AnswerType.yes, AnswerType.yes, ContactMatchType.Identical);\n }", "boolean _is_equivalent(org.omg.CORBA.Object other);", "@Test\n public void equals() {\n Command commandCopy = new McqInputCommand(\"a\", mcqTest);\n assertTrue(G_MCQ_COMMAND.equals(commandCopy));\n\n // same object -> returns true\n assertTrue(commandCopy.equals(commandCopy));\n\n assertFalse(commandCopy.equals(null));\n\n // different type -> returns false\n assertFalse(commandCopy.equals(10));\n assertFalse(commandCopy.equals(\"TestString\"));\n }", "@Test\r\n public void testEquals() {\r\n System.out.println(\"equals\");\r\n Object obj = null;\r\n RevisorParentesis instance = null;\r\n boolean expResult = false;\r\n boolean result = instance.equals(obj);\r\n assertEquals(expResult, result);\r\n // TODO review the generated test code and remove the default call to fail.\r\n fail(\"The test case is a prototype.\");\r\n }", "public void testEqualsObject()\n {\n Mana meme = new Mana( myMise );\n Assert.assertEquals( myMise, meme );\n \n System.out.println( myMise.toString());\n Mana autre = new Mana( 49 );\n Assert.assertFalse( myMise.equals( autre ));\n autre = new Mana( 50 );\n Assert.assertTrue( myMise.equals( autre ));\n }", "@Test\n public void equalsTrueMySelf() {\n Player player1 = new Player(PlayerColor.BLACK, \"\");\n assertTrue(player1.equals(player1));\n assertTrue(player1.hashCode() == player1.hashCode());\n }", "boolean equals(Object object);" ]
[ "0.72269857", "0.71516186", "0.7130689", "0.71034116", "0.7074891", "0.7029325", "0.7026331", "0.7007498", "0.7002552", "0.6962357", "0.69231164", "0.67984706", "0.67983013", "0.6792519", "0.6777234", "0.6775169", "0.67338204", "0.6718098", "0.67177534", "0.67173535", "0.6702264", "0.66739506", "0.6661186", "0.6639104", "0.66094", "0.6609044", "0.6607921", "0.6597097", "0.65806395", "0.65310687", "0.6524355", "0.65220815", "0.6507546", "0.6505585", "0.65020305", "0.64995575", "0.649803", "0.64979446", "0.6489802", "0.64877576", "0.64852846", "0.6483177", "0.6481982", "0.6476174", "0.6473167", "0.6436486", "0.6429742", "0.6427034", "0.6413869", "0.63952017", "0.63920987", "0.6385336", "0.6384372", "0.6383588", "0.63668376", "0.6356854", "0.6317014", "0.6310019", "0.63088584", "0.63009095", "0.63006717", "0.6300068", "0.62990683", "0.62974423", "0.62842244", "0.6275282", "0.6273469", "0.62588257", "0.6252953", "0.62475675", "0.6244389", "0.6242935", "0.6240802", "0.62301683", "0.6223021", "0.6221011", "0.6220447", "0.62091386", "0.6206037", "0.6205787", "0.620299", "0.6188709", "0.6187813", "0.6179698", "0.6178386", "0.6177426", "0.61760265", "0.6163726", "0.6159259", "0.6147872", "0.6146742", "0.61466813", "0.6139602", "0.6131815", "0.61279064", "0.612318", "0.611698", "0.6114381", "0.61082846", "0.6108141", "0.6107361" ]
0.0
-1
Processes the elements of actors. Implemented to "eat" (i.e. remove) all rocks. Postcondition: (1) The state of all actors in the grid other than this critter and the elements of actors is unchanged. (2) The location of this critter is unchanged.
public void processActors(ArrayList<Actor> actors) { for (Actor a : actors) { if ( a instanceof Rock ) a.removeSelfFromGrid(); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Override\n\t public void processActors(ArrayList<Actor> actors)\n\t {\n\t for (Actor a : actors)\n\t {\n\t if (a instanceof Flower){\n\t a.removeSelfFromGrid();\n\t }\n\t if (a instanceof Cow){\n\t \t++this.myMilkTank.MilkMenge;\n\t \ta.removeSelfFromGrid();\n\t }\n\t \n\t }\n\t }", "public void moveActors() {\n\t\tfor (int row = 0; row < battlefield.length; row++) {\n\t\t\tfor (int column = 0; column < battlefield.length; column++) {\n\t\t\t\tif (battlefield[row][column].getElf() != null) {\n\t\t\t\t\tbattlefield[row][column].getElf().move(battlefield, row,\n\t\t\t\t\t\t\tcolumn);\n\t\t\t\t}\n\t\t\t\tif (battlefield[row][column].getOrc() != null) {\n\t\t\t\t\tbattlefield[row][column].getOrc().move(battlefield, row,\n\t\t\t\t\t\t\tcolumn);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}", "public void processActors(ArrayList<Actor> actors) {\n\t\t\n\t\tfor(int i = 0; i < actors.size(); i++) {\n\t\t\tActor a = actors.get(i);\n\t\t\tLocation current = a.getLocation();\n\t\t\tLocation moveTo = a.getLocation().getAdjacentLocation(current.getDirectionToward(getLocation()));\n\t\t\t\n\t\t\tif(getGrid().isValid(moveTo) && getGrid().get(moveTo) == null) {\n\t\t\t\ta.moveTo(moveTo);\n\t\t\t}\n\t\t}\n\t\t\n\t}", "public void processActors(ArrayList<Actor> actors) {\n int count = 0;\n for (Actor temp : actors) {\n if (temp instanceof Critter) {\n count++;\n }\n }\n if (count < courage) {\n changeColor(2);\n } else {\n changeColor(-2);\n }\n }", "void processActors(ArrayList<Actor> actors);", "public void processActors(ArrayList<Actor> actors)\n {\n int n = actors.size();\n if (n < courage) {\n brighter();\n } else {\n darken();\n }\n }", "void updateEnemies() {\n getEnemies().forEach(e -> {\n if (!e.isAlive()) {\n e.die();\n SoundPlayer.play(SoundPlayer.enemyDestroyed);\n }\n });\n objectsInMap.removeIf(o -> o instanceof Enemy && !(((Enemy) o).isAlive()));//Removing Dead Enemies\n getEnemies().forEach(e -> e.setTarget(objectsInMap.stream().filter(p -> p.identifier.contains(\"PlayerTank0.\") &&\n p.isBlocking && ((Tank) p).isVisible()).collect(Collectors.toList())));//Giving Possible target to enemies to decide\n }", "public void act() \n {\n World w = getWorld();\n int height = w.getHeight();\n \n setLocation(getX(),getY()+1);\n if (getY() <=0 || getY() >= height || getX() <= 0) // off the world\n {\n w.removeObject(this);\n return;\n }\n \n \n SaboWorld thisWorld = (SaboWorld) getWorld();\n Turret turret = thisWorld.getTurret();\n Actor turretActor = getOneIntersectingObject(Turret.class);\n Actor bullet = getOneIntersectingObject(Projectile.class);\n \n if (turretActor!=null && bullet==null) // hit the turret!\n {\n \n turret.bombed(); //Turret loses health\n explode();\n w.removeObject(this);\n } else if (turret==null && bullet!=null) //hit by a bullet!\n {\n explode();\n w.removeObject(this);\n }\n \n }", "public void act()\n {\n if (getGrid() == null)\n return;\n if (caughtPokemon.size() <= 0)\n {\n removeSelfFromGrid();\n System.out.println(toString() + \" has blacked out! \" + toString() + \" has appeared at a PokeCenter.\");\n return;\n }\n ArrayList<Location> moveLocs = getMoveLocations();\n Location loc = selectMoveLocation(moveLocs);\n makeMove(loc);\n }", "public ArrayList<Actor> getActors(){\n\t\t\n\t\tArrayList<Location> occupiedLocations = getGrid().getOccupiedLocations();\n\t\toccupiedLocations.remove(getLocation());\n\t\tArrayList<Actor> actors = new ArrayList<Actor>();\n\t\t\n\t\tfor(int i = 0; i < occupiedLocations.size(); i++) {\n\t\t\tactors.add(getGrid().get(occupiedLocations.get(i)));\n\t\t}\n\t\t\n\t\treturn actors;\n\t}", "public void enleverTousLesObs() {\n\n\t\tobstaclesList.removeAll(obstaclesList);\n\t}", "public void effect() {\n if (course == 2) {\n //RIGHT\n x += fac;\n } else if (course == 5) {\n //LEFT\n x -= fac;\n } else {\n y = (int)(origY + fac * f * Math.tan(angle)) + offsetY;\n x = (int)(origX + fac * f) + offsetX;\n }\n boolean b = computeCell();\n\n if (b) {\n //Detect ennemy\n if (current != null) {\n Player p = current.getOccupied();\n if (p != null && p != thrower) {\n p.makeHimWait((Params.howLongBlockingMagician * 1000) / 2);\n this.destroy();\n }\n }\n }\n //Detect ennemy's cell\n if (current != null) {\n Team te = current.getOwner();\n if (te != thrower.getTeam() && current.getType() == 1) {\n current.setHp(current.getHp() - Params.archerDammage);\n if (current.getHp() <= 0) {\n current.setOwner(thrower.getTeam());\n current.setHp(thrower.getInitHP());\n }\n }\n if (current.isHeight()) {\n this.destroy();\n }\n } else {\n int bound = 10;\n //System.out.println(game.getWidth());\n if (this.x < -bound || this.x > game.getWidth() + bound || this.y < -bound ||\n this.y > game.getHeight() + bound) {\n this.destroy();\n }\n }\n\n f++;\n }", "private void moveInvaders() {\n\t\tfor (ArrayList<Invader> row : enemyArray) {\n\t\t\tfor (Invader a : row) {\n\t\t\ta.move();\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor (ArrayList<Invader> row : enemyArray) {\n\t\t\tfor (Invader a : row) {\n\t\t\t\tif (a.getVisibility()) {\n\t\t\t\t\t\n\t\t\t\t\tcheckLeftWall(a);\n\t\t\t\t\tcheckRightWall(a);\n\t\t\t\t\t\n\t\t\t\t\tif ((a.getY() + PLAYER_WIDTH) >= HEIGHT) {\n\t\t\t\t\t\trunning = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "private void iterateEnemyShots() {\n\t\tfor (Shot s : enemyShotList) {\n\t\t\tfor (ArrayList<Invader> row : enemyArray) {\n\t\t\t\tfor(Invader a : row) {\n\t\t\t\t\ta.shouldAttack(s);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "public void reassignAllAgents() {\n\t\tPoint safePosition = null;\n\t\tfor(Player p : playerList) {\n\t\t\tif(p.getType() == PlayerType.Agent) {\n\t\t\t\tremovePosition(p.getPosition());\n\t\t\t\tsafePosition = getSafeTeleportPosition();\n\t\t\t\tp.setPosition(safePosition);\n\t\t\t\toccupiedPositions.add(safePosition);\n\t\t\t}\n\t\t}\n\t}", "public void manageJunction() {\r\n for (Vehicle v : this.getVehicles()) {\r\n v.act();\r\n }\r\n }", "public void act() \r\n {\r\n // Add your action code here.\r\n espacio esp=(espacio)getWorld();\r\n Actor act=getOneIntersectingObject(nave.class);//Cuando la nave tome el poder \r\n if(act!=null)\r\n {\r\n for(int i=1;i<=10;i++)//incrementa el poder mediante el metodo solo 1s disparos\r\n esp.poder.incrementar();\r\n getWorld().removeObject(this);\r\n Greenfoot.playSound(\"Poder.wav\");\r\n }\r\n \r\n }", "private void collision() {\n\t\tfor(int i = 0; i < brownMeteors.length; i++) {\n\t\t\tif( distance(brownMeteors[i].getLayoutX() + ENTITIES_SIZE/2, brownMeteors[i].getLayoutY() - ENTITIES_SIZE/2, \n\t\t\t\t\tplayer.getLayoutX() + ENTITIES_SIZE/2, player.getLayoutY() - ENTITIES_SIZE/2) <= ENTITIES_SIZE) {\n\t\t\t\tsetNewElementPosition(brownMeteors[i]);\n\t\t\t\t\n\t\t\t\t//Update score -\n\t\t\t\tsc.score -= 3 * sc.collisionCounter; \n\t\t\t\tsc.collisionCounter++;\n\t\t\t}\n\t\t}\n\t\t//player vs grey Meteor\n\t\tfor(int i = 0; i < greyMeteors.length; i++) {\n\t\t\tif( distance(greyMeteors[i].getLayoutX() + ENTITIES_SIZE/2, greyMeteors[i].getLayoutY() - ENTITIES_SIZE/2, \n\t\t\t\t\tplayer.getLayoutX() + ENTITIES_SIZE/2, player.getLayoutY() - ENTITIES_SIZE/2) <= ENTITIES_SIZE) {\n\t\t\t\tsetNewElementPosition(greyMeteors[i]);\n\n\t\t\t\t//Update score -\n\t\t\t\tsc.score -= 3 * sc.collisionCounter;\n\t\t\t\tsc.collisionCounter++;\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\t//laser vs brown Meteor\n\t\tfor(int i = 0; i < lasers.size(); i++) {\n\t\t\tfor(int j = 0; j < brownMeteors.length; j++) { // 0 - 2 -> 3elem\n\t\t\t\tif(lasers.get(i).getBoundsInParent().intersects(brownMeteors[j].getBoundsInParent())) {\t// bounds of a node in it's parent coordinates\n\t\t\t\t\tsetNewElementPosition(brownMeteors[j]);\n\t\t\t\t\tgamePane.getChildren().remove(lasers.get(i));\n\t\t\t\t\tlasers.remove(i);\n\t\t\t\t\tSystem.out.println(lasers.size());\n\t\t\t\t\t\n\t\t\t\t\t//Update score +\n\t\t\t\t\tsc.score += 1; \n\t\t\t\t\tbreak; //kein fehler mehr durch index out of bounds verletzung\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t\t\n\t\tfor(int i = 0; i < lasers.size(); i++) {\n\t\t\tfor(int j = 0; j < greyMeteors.length; j++) { // 0 - 2 -> 3elem\n\t\t\t\tif(lasers.get(i).getBoundsInParent().intersects(greyMeteors[j].getBoundsInParent())) {\t// bounds of a node in it's parent coordinates\n\t\t\t\t\tsetNewElementPosition(greyMeteors[j]);\n\t\t\t\t\tgamePane.getChildren().remove(lasers.get(i));\n\t\t\t\t\tlasers.remove(i);\n\t\t\t\t\tSystem.out.println(lasers.size());\n\t\t\t\t\t\n\t\t\t\t\t//Update score +\n\t\t\t\t\tsc.score += 1; \n\t\t\t\t\tbreak; //kein fehler mehr durch index out of bounds verletzung\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\t\t\n\t}", "public void processFights() {\n\n\t\tfor (int row = 0; row < battlefield.length; row++) {\n\t\t\tfor (int column = 0; column < battlefield[row].length; column++) {\n\t\t\t\tbattlefield[row][column].fight();\n\t\t\t}\n\t\t}\n\t}", "public void areaEffect(Player player){\n if(object.getProperties().containsKey(\"endLevel\")) {\n System.out.println(\"Fin du level\");\n setCategoryFilter(GameTest.DESTROYED_BIT);\n PlayScreen.setEndLevel();\n }\n\n if(object.getProperties().containsKey(\"startBossFight\")) {\n\n System.out.println(\"Start Boss Fight\");\n setCategoryFilter(GameTest.DESTROYED_BIT);\n\n TiledMapTileLayer.Cell cell = new TiledMapTileLayer.Cell();\n cell.setTile(tileSet.getTile(910));\n layer.setCell(99, 6, cell);\n cell.setTile(tileSet.getTile(910));\n layer.setCell(99, 7, cell);\n cell.setTile(tileSet.getTile(910));\n layer.setCell(99, 8, cell);\n cell.setTile(tileSet.getTile(910));\n layer.setCell(99, 9, cell);\n\n cell.setTile(tileSet.getTile(910));\n layer.setCell(100, 6, cell);\n cell.setTile(tileSet.getTile(910));\n layer.setCell(100, 7, cell);\n cell.setTile(tileSet.getTile(910));\n layer.setCell(100, 8, cell);\n cell.setTile(tileSet.getTile(910));\n layer.setCell(100, 9, cell);\n\n PlayScreen.cameraChangeBoss(true);\n setCategoryFilterFixture(GameTest.GROUND_BIT, PlayScreen.getFixtureStartBoss());\n\n }\n\n if(object.getProperties().containsKey(\"blueKnight\")) {\n System.out.println(\"Changement en bleu\");\n setCategoryFilter(GameTest.DESTROYED_BIT);\n getCell().setTile(null);\n PlayScreen.setColorKnight(\"blue\");\n }\n\n if(object.getProperties().containsKey(\"greyKnight\")) {\n System.out.println(\"Changement en gris\");\n setCategoryFilter(GameTest.DESTROYED_BIT);\n getCell().setTile(null);\n PlayScreen.setColorKnight(\"grey\");\n }\n\n if(object.getProperties().containsKey(\"redKnight\")) {\n System.out.println(\"Changement en rouge\");\n setCategoryFilter(GameTest.DESTROYED_BIT);\n getCell().setTile(null);\n PlayScreen.setColorKnight(\"red\");\n }\n\n }", "public void act() \n {\n setImage(\"1up.png\");\n setImage(\"acrate.png\");\n setImage(\"Betacactus.png\");\n setImage(\"bullet1.png\");\n setImage(\"bullet2.png\");\n setImage(\"burst.png\");\n setImage(\"cowboy.png\");\n setImage(\"fOxen1.png\");\n setImage(\"fOxen2.png\");\n setImage(\"fOxen3.png\");\n setImage(\"fOxen4.png\");\n setImage(\"fOxenH.png\");\n setImage(\"fWagon1.png\");\n setImage(\"fWagon2.png\");\n setImage(\"fWagon3.png\");\n setImage(\"fWagon4.png\");\n setImage(\"fWagonH.png\");\n setImage(\"health.png\");\n setImage(\"indian.png\");\n setImage(\"normal.png\");\n setImage(\"oxen.png\");\n setImage(\"oxen2.png\");\n setImage(\"oxen3.png\");\n setImage(\"oxen4.png\");\n setImage(\"oxen-hit.png\");\n setImage(\"plasma.png\");\n setImage(\"rapid.png\");\n setImage(\"snake1.png\");\n setImage(\"snake2.png\");\n setImage(\"snake3.png\");\n setImage(\"snake4.png\");\n setImage(\"spread.png\");\n setImage(\"theif.png\");\n setImage(\"train1.png\");\n setImage(\"train-hit.png\");\n setImage(\"wagon.png\");\n setImage(\"wagonhit.png\");\n setImage(\"wave.png\");\n getWorld().removeObject(this);\n }", "public void act() \r\n {\n if(getOneIntersectingObject(Player.class)!=null)\r\n {\r\n if(MenuWorld.gamemode == 1)\r\n //marcheaza regenerarea labirintului(trecere la nivelul urmator in Modul Contra Timp)\r\n TAworld.shouldRegen=true;\r\n else\r\n { \r\n //reseteaza variabilele care tin de modul de joc\r\n MenuWorld.gamemode=-1;\r\n MenuWorld.isPlaying=false;\r\n for(int i=0;i<4;i++)\r\n ItemCounter.gems_taken[i]=0;\r\n \r\n //arata fereastra de castig \r\n PMworld.shouldShowVictoryWindow=true;\r\n }\r\n \r\n }\r\n \r\n }", "public void makeChanges() { \n for(int i = 1; i < 9; i++) {\n for(int j = 1; j < 11; j++) {\n if(!(controller.getBoard().getPiece(i, j) instanceof Forbidden)) {\n Cell[i][j].setBackground(Color.white);\n if(controller.getBoard().getPiece(i,j) != null) {\n if(controller.getPlayer(controller.getTurn()).getColour() != controller.getBoard().getPiece(i,j).getColour()) {\n if(controller.getTurn() == 1) {\n Cell[i][j].setIcon(new ImageIcon(\"pieces\\\\redHidden.png\"));\n Cell[i][j].setEnabled(false);\n } else {\n Cell[i][j].setIcon(new ImageIcon(\"pieces\\\\blueHidden.png\"));\n Cell[i][j].setEnabled(false);\n }\n } else {\n Cell[i][j].setIcon((controller.getBoard().getPiece(i, j).getIcon()));\n Cell[i][j].setEnabled(true);\n }\n if(controller.getBoard().getPiece(i,j) instanceof Trap || controller.getBoard().getPiece(i,j) instanceof Flag) {\n Cell[i][j].removeActionListener(handler);\n Cell[i][j].setEnabled(false);\n }\n } else {\n Cell[i][j].setBackground(Color.white);\n Cell[i][j].setEnabled(false);\n }\n }\n }\n }\n controller.setTurn(); \n }", "public void act()\n {\n \n //move();\n //if(canSee(Worm.class))\n //{\n // eat(Worm.class);\n //}\n //else if( atWorldEdge() )\n //{\n // turn(15);\n //}\n\n }", "@Override\n public void action(){\n\n Position move=this.findWeed();\n if(move.getX()==0 && move.getY()==0){\n super.action();\n }\n else{\n System.out.println(this.getClass().getSimpleName());\n int actualX = this.position.getX();\n int actualY = this.position.getY();\n int xAction = actualX+move.getX();\n int yAction = actualY+move.getY();\n Organism tmpOrganism = this.WORLD.getOrganism(xAction, yAction);\n if(tmpOrganism==null){\n this.move(move.getX(), move.getY());\n this.WORLD.erasePosition(actualX,actualY);\n }\n else{\n tmpOrganism.collision(this, actualX, actualY, move);\n }\n }\n }", "public ArrayList<Actor> getActors() {\n ArrayList<Actor> actors = new ArrayList<Actor>();\n Location loc = getLocation();\n for (int row = loc.getRow() - 2; row <= loc.getRow() + 2; row++) {\n for (int col = loc.getCol() - 2; col <= loc.getCol() + 2; col++) {\n if (getGrid().isValid(new Location(row, col))) {\n Actor temp = getGrid().get(new Location(row, col));\n if (temp != null && temp != this) {\n actors.add(temp);\n }\n }\n }\n }\n return actors;\n }", "public void act()\n {\n if (health == 0)\n {\n this.remove();\n }\n }", "public void act() \r\n {\r\n move(speed); //move at set speed\r\n \r\n if(actCounter < 2) //increases act counter if only 1 act has passed\r\n actCounter++;\r\n\r\n if(actCounter == 1) //if on the first act\r\n {\r\n targetClosestPlanet(); //will target closest planet depending on if it wants to find an unconquered planet, or just the closest one\r\n if(planet == null && findNearestPlanet)\r\n findNearestPlanet = false;\r\n }\r\n \r\n if(health > 0) //if alive\r\n {\r\n if(findNearestPlanet)\r\n targetClosestPlanet();\r\n if(planet != null && planet.getWorld() != null) //if planet exists\r\n moveTowards(); //move toward it\r\n else\r\n moveRandomly(); //move randomly\r\n }\r\n \r\n if(removeMe || atWorldEdge())\r\n getWorld().removeObject(this);\r\n }", "private void computeMovableTilesToDisplayToPlayer() {\n \tfor (Entity enemyEntity : allCreaturesOfCurrentRoom) {\n \t\tAIComponent aiComponent = Mappers.aiComponent.get(enemyEntity);\n \t\tif (aiComponent.getSubSystem() != null) {\n \t\t\tboolean handledInSubSystem = aiComponent.getSubSystem().computeMovableTilesToDisplayToPlayer(this, enemyEntity, room);\n \t\t\tif (handledInSubSystem) continue;\n \t\t}\n \t\t\n \tMoveComponent moveCompo = Mappers.moveComponent.get(enemyEntity);\n \tAttackComponent attackCompo = Mappers.attackComponent.get(enemyEntity);\n \t\n \t\t//clear the movable tile\n \t\tmoveCompo.clearMovableTiles();\n \t\tif (attackCompo != null) attackCompo.clearAttackableTiles();\n \t\t\n \t\tmoveCompo.setMoveRemaining(moveCompo.getMoveSpeed());\n \t\t\n \t//Build the movable tiles list\n \t\ttileSearchService.buildMoveTilesSet(enemyEntity, room);\n \t\tif (attackCompo != null) attackTileSearchService.buildAttackTilesSet(enemyEntity, room, false, true);\n \t\tmoveCompo.hideMovableTiles();\n \t\tif (attackCompo != null) attackCompo.hideAttackableTiles();\n \t}\n }", "public static void worldTimeStep() {\n\t\t\n\t//Do time step for all critters\n\t\tfor (Critter c: population) {\n\t\t\tc.doTimeStep();\t\t\t\n\t\t}\n\t\n\t\t\n\t//Resolve encounters\n\t\tIterator<Critter> it1 = population.iterator();\n\t\tfightMode = true;\n\t\twhile(it1.hasNext())\n\t\t{\n\t\t\tCritter c = it1.next();\n\t\t\tIterator<Critter> it2 = population.iterator();\n\t\t\twhile(it2.hasNext()&&(c.energy > 0)) \n\t\t\t{\t\n\t\t\t\tCritter a =it2.next();\n\t\t\t\tif((c != a)&&(a.x_coord==c.x_coord)&&(a.y_coord==c.y_coord))\n\t\t\t\t{\n\t\t\t\t\tboolean cFighting = c.fight(a.toString());\n\t\t\t\t\tboolean aFighting = a.fight(c.toString());\n\t\t\t\t//If they are both still in the same location and alive, then fight\n\t\t\t\t\tif ((a.x_coord == c.x_coord) && (a.y_coord == c.y_coord) && (a.energy > 0) && (c.energy > 0)) {\t\t\n\t\t\t\t\t\tint cFight=0;\n\t\t\t\t\t\tint aFight=0;\n\t\t\t\t\t\tif(cFighting)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcFight = getRandomInt(100);\n\t\t\t\t\t\t\tcFight++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(aFighting)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\taFight =getRandomInt(100);\n\t\t\t\t\t\t\taFight++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(cFight>aFight)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tc.energy+=(a.energy/2);\n\t\t\t\t\t\t\t//it2.remove();\n\t\t\t\t\t\t\ta.energy=0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if(aFight>cFight)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ta.energy+=(c.energy/2);\n\t\t\t\t\t\t\t//it1.remove()\n\t\t\t\t\t\t\tc.energy=0;\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(aFight>50)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ta.energy+=(c.energy/2);\n\t\t\t\t\t\t\t\t//it1.remove();\n\t\t\t\t\t\t\t\tc.energy=0;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tc.energy+=(a.energy);\n\t\t\t\t\t\t\t\t//it2.remove();\n\t\t\t\t\t\t\t\ta.energy=0;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfightMode = false;\n\t\t\n\t//Update rest energy and reset hasMoved\n\t\tfor (Critter c2: population) {\n\t\t\tc2.hasMoved = false;\n\t\t\tc2.energy -= Params.rest_energy_cost;\n\t\t}\n\t\t\n\t//Spawn offspring and add to population\n\t\tpopulation.addAll(babies);\n\t\tbabies.clear();\n\t\t\n\t\tIterator<Critter> it3 = population.iterator();\n\t\twhile(it3.hasNext())\n\t\t{\n\t\t\tif(it3.next().energy<=0)\n\t\t\t\tit3.remove();\n\t\t}\n\t//Create new algae\n\t\tfor (int i = 0; i < Params.refresh_algae_count; i++) {\n\t\t\ttry {\n\t\t\t\tmakeCritter(\"Algae\");\n\t\t\t} catch (InvalidCritterException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t}\n\t}", "public void clear() {\n for (int i = 0; i < if_you_items.length; i++) {\n if_you_items[i].setEnabled(true);\n }\n for (int i = 0; i < then_we_items.length; i++) {\n then_we_items[i].setEnabled(true);\n }\n non_promised_ministries.clear();\n non_promised_ministries.addAll(all_ministries);\n // if not at war, can't ask/offer peace\n if (game.getDiplomacy().getDiplomaticState(game.getTurn(), faction) != C.DS_WAR) {\n if_you_items[IfYouWill.PEACE.ordinal()].setEnabled(false);\n then_we_items[ThenWeWill.PEACE.ordinal()].setEnabled(false);\n }\n if (faction > C.HOUSE5) { // non-house\n non_promised_ministries.clear();\n if_you_items[IfYouWill.TECH.ordinal()].setEnabled(false);\n then_we_items[ThenWeWill.TECH.ordinal()].setEnabled(false);\n if_you_items[IfYouWill.VOTES.ordinal()].setEnabled(false);\n then_we_items[ThenWeWill.VOTES.ordinal()].setEnabled(false);\n return;\n }\n // search for promised votes and ministries in pending contracts of sender\n for (Contract con : game.getDiplomacy().getSentContracts()) {\n for (Term term : con.getTerms()) {\n if (term.getDonor() == game.getTurn()) {\n switch (term.getType()) {\n case VOTES:\n System.out.println(\"DBG no votes\");\n then_we_items[ThenWeWill.VOTES.ordinal()].setEnabled(false);\n break;\n case MINISTRY:\n non_promised_ministries.remove(new Integer(term.getAmount()));\n break;\n case MONEY:\n break;\n case STATE:\n break;\n case TECH:\n break;\n default:\n throw new AssertionError();\n }\n }\n if (term.getDonor() == faction) {\n switch (term.getType()) {\n case VOTES:\n System.out.println(\"DBG no votes\");\n if_you_items[IfYouWill.VOTES.ordinal()].setEnabled(false);\n break;\n case MINISTRY:\n non_promised_ministries.remove(new Integer(term.getAmount()));\n break;\n case MONEY:\n break;\n case STATE:\n break;\n case TECH:\n break;\n default:\n throw new AssertionError();\n }\n }\n }\n }\n // search for promised votes and ministries for sender and for receiver\n // those that are made with sender\n if (game.getRegency().getVotes()[game.getTurn()][Regency.CANDIDATE_IDX] > -1\n || game.getRegency().getVotes()[faction][Regency.CANDIDATE_IDX] == game.getTurn()) {\n then_we_items[ThenWeWill.VOTES.ordinal()].setEnabled(false);\n if_you_items[IfYouWill.VOTES.ordinal()].setEnabled(false);\n }\n int[] promises = game.getDiplomacy().getMinistryPromises(game.getTurn());\n for (int i = 0; i < promises.length; i++) {\n if (promises[i] > -1) {\n non_promised_ministries.remove(new Integer(promises[i]));\n }\n }\n promises = game.getDiplomacy().getMinistryPromises(faction);\n for (int i = 0; i < promises.length; i++) {\n if (promises[i] == game.getTurn()) {\n non_promised_ministries.remove(new Integer(promises[i]));\n }\n }\n if (non_promised_ministries.isEmpty()) {\n then_we_items[ThenWeWill.MINISTRY.ordinal()].setEnabled(false);\n if_you_items[IfYouWill.MINISTRY.ordinal()].setEnabled(false);\n }\n }", "public void action() throws Exception {\n // Cop move to another place\n move();\n\n // Search for agents nearby\n ArrayList<Position> occupiedNeighbor = this.getPosition().getOccupiedNeighborhood();\n ArrayList<Agent> arrestList = new ArrayList<>();\n for (Position neighbor : occupiedNeighbor) {\n Person person = neighbor.getOccupiedPerson();\n String className = person.getClass().getName();\n // if this is a agent and is active\n if (className.equals(Person.AGENT)) {\n if (((Agent) person).isActive()) {\n arrestList.add((Agent) person);\n }\n }\n }\n\n // If there at least one agent nearby\n if (0 != arrestList.size()) {\n // Randomly pick active agent to jail\n Random random = new Random();\n int maxIndex = arrestList.size();\n int randomIndex = random.nextInt(maxIndex);\n Agent arrestAgent = arrestList.get(randomIndex);\n int jailTerm = random.nextInt(getPersonEnvironment().getMaxJailTerm());\n arrestAgent.beArrested(jailTerm, this);\n }\n }", "public void act() \r\n {\r\n Actor hitMC = getOneIntersectingObject(MC.class);\r\n if (hitMC != null) {\r\n ((Hall) getWorld()).player.health++;\r\n getWorld().removeObject(this);\r\n }\r\n }", "public void removeAllPawns(){\n\n for (Map.Entry<Integer, ImageView> entry : actionButtons.entrySet()) {\n Image image = null;\n entry.getValue().setImage(image);\n }\n\n for (Map.Entry<Integer, ImageView> entry : harvestBox.entrySet()) {\n\n Image image = null;\n entry.getValue().setImage(image);\n harvestBoxFreeSlot = 0;\n\n }\n\n for (Map.Entry<Integer, ImageView> entry : productionBox.entrySet()) {\n\n Image image = null;\n entry.getValue().setImage(image);\n productionBoxFreeSlot = 0;\n\n }\n\n for (Map.Entry<Integer, ImageView> entry : gridMap.entrySet()) {\n Image image = null;\n entry.getValue().setImage(image);\n gridFreeSlot = 0;\n }\n }", "public void processStimulus (Enumeration criteria) \r\n \t{\r\n\t \tWakeupCriterion wakeup = (WakeupCriterion)criteria.nextElement();\r\n\t \tAWTEvent[] evt = ((WakeupOnAWTEvent)wakeup).getAWTEvent();\r\n\t \tint xpos = 0, ypos = 0;\r\n\r\n\t \tmevent = (MouseEvent) evt[0];\r\n\t\tprocessMouseEvent((MouseEvent)evt[0]);\r\n\t\txpos = mevent.getPoint().x;\r\n\t\typos = mevent.getPoint().y;\r\n\t\t\r\n\t\tif(evt[0].getID()==MouseEvent.MOUSE_RELEASED)\r\n\t\t{\r\n\t\t\tif(solid instanceof CompoundSolid)\r\n\t\t\t{\r\n\t\t\t\tCompoundSolid compound = (CompoundSolid)solid;\r\n\t\t\t\tcompound.updateChildren();\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t//\t \tupdateScene(xpos, ypos);\r\n\t\t}\r\n\t \t\r\n\t \twakeupOn (wakeupCondition);\r\n\t}", "void removeAllSpawn();", "public void act() // method act\n {\n moveBear(); //lakukan method movebear\n objectDisappear(); // lakukan method objeectDisappear\n }", "public void processCells() {\n\n //Create a new grid which will be next iteration\n Cell[][] nextGrid = new Cell[this.width][this.height];\n\n //Populate the new grid with dead cells\n populateGrid(nextGrid);\n\n //Iterate through the grid\n for (int x = 0; x < this.width; x++) {\n for (int y = 0; y < this.height; y++) {\n\n //Get the cell\n Cell currentCell = getCell(x, y);\n\n // Get current status of the Cell\n boolean isAlive = currentCell.isAlive();\n\n //Check its neighbours\n int aliveNeighbours = getNeighbours(currentCell);\n\n //Evaluate against rules\n isAlive = applyRules(isAlive, aliveNeighbours);\n\n //Add cell to new grid\n nextGrid[x][y].setAlive(isAlive);\n }\n }\n\n //Set the next iteration to the current iteration\n this.grid = nextGrid;\n }", "private void removeObjectFromContainer(UsableActor actor) {\n if (actor instanceof Cookie){\n for (int x = 0 ; x < this.cookies.size(); x++){\n if (this.cookies.get(x).equals(actor)){\n this.cookies.remove(x);\n break;\n }\n } \n }\n else if (actor instanceof Whistle){\n for (int x = 0 ; x < this.whistles.size(); x++){\n if (this.whistles.get(x).equals(actor)){\n this.whistles.remove(x);\n break;\n }\n }\n }\n }", "public static void removeIceAndFire(){\r\n for(int i = 0; i < board.length; i++) {\r\n for (int j = 0; j < board[i].length; j++) {\r\n if(board[i][j].isOnFireForTheNextNTurns == currentTurn){\r\n board[i][j].isOnFire = false;\r\n }\r\n if(board[i][j].isFrozenForTheNextNTurns == currentTurn){\r\n board[i][j].isFrozen = false;\r\n }\r\n }\r\n }\r\n }", "private void actualizarEnemigosItems() {\n if(estadoMapa== EstadoMapa.RURAL || estadoMapa== EstadoMapa.RURALURBANO ){\n moverCamionetas();\n moverAves();\n }\n if(estadoMapa== EstadoMapa.URBANO || estadoMapa == EstadoMapa.URBANOUNIVERSIDAD){\n moverCarroLujo();\n moverAves();\n }\n if(estadoMapa== EstadoMapa.UNIVERSIDAD){\n moverCarritoGolf();\n moverAves();\n }\n if (estadoMapa == EstadoMapa.SALONES){\n moverLamparas();\n moverSillas();\n }\n actualizaPuntuacion();\n moverTareas();\n moverItemCorazon();\n verificarColisiones();\n verificarMuerte();\n moverItemRayo();\n /*\n IMPLEMENTAR\n\n //moverPajaro();\n //etc\n */\n }", "public void act() \n {\n if(foundAvatar())\n {\n int delta = getFun();\n timeRem.addTime(delta);\n getWorld().removeObject(this);\n // setLocation(Greenfoot.getRandomNumber(800), Greenfoot.getRandomNumber(600));\n }\n\n }", "@Override\n\tpublic void update(GameContainer arg0, int delta) throws SlickException {\n\t\tfor (Actors a : actors) {\n\t\t\ta.move();\n\t\t}\n\t}", "public void removeActor(int index) { ActorSet.removeElementAt(index); }", "public void decision(Entity[][] map, int y, int x){ \r\n if (!getTired()){\r\n // check if surrounding area is another animal\r\n if ((x > 0) && (y > 0) && (map[y-1][x-1] instanceof Animal )){\r\n destroyArea(map, x, y);\r\n }else if ((x < map.length-1) && (y < map.length -1) && (map[y+1][x+1] instanceof Animal)){\r\n destroyArea(map, x, y);\r\n }else if ((y > 0) && map[y-1][x] instanceof Animal){\r\n destroyArea(map, x, y);\r\n }else if ((x < map.length -1) && (y > 0) && (map[y-1][x+1] instanceof Animal)){\r\n destroyArea(map, x, y);\r\n }else if(( x < map.length -1) && (map[y][x+1] instanceof Animal)){\r\n destroyArea(map, x, y);\r\n }else if(( x > 0) && (map[y][x-1] instanceof Animal)){\r\n destroyArea(map, x, y);\r\n }else if( (y < map.length-1) && (map[y+1][x] instanceof Animal)){\r\n destroyArea(map, x, y);\r\n }else if((x > 0) && (y < map.length -1) && (map[y+1][x-1] instanceof Animal)){\r\n destroyArea(map, x, y);\r\n }else if (numOfTurns == 3){\r\n numOfTurns = 0;\r\n moveRandom(map, y, x);\r\n }\r\n }\r\n numOfTurns ++;\r\n }", "private void checkForDeaths() {\n Iterator<Entity> entityIter = this.entities.iterator();\n\n //geht alle teilnehmer durch\n while ( entityIter.hasNext() ) {\n Entity entity = entityIter.next();\n\n //und entfernt sie wenn sie tot sind aus der liste und der engine\n if ( this.combatMapper.get(entity).curHealth <= 0 ) {\n entityIter.remove();\n\n //alle actions der entity entfernen, können ja nichts machen wenn sie tot sind\n Iterator<IAction> actionIter = this.actions.iterator();\n\n while ( actionIter.hasNext() ) {\n if ( actionIter.next().getOwner().equals(entity) ) {\n actionIter.remove();\n }\n }\n\n this.combatExp += this.combatMapper.get(entity).level * 5; //TODO\n\n EventSystem.getInstance().commitEvent(new Event(EventSystem.EventType.KILL_EVENT, entity));\n\n this.combatSystem.getEngine().removeEntity(entity);\n }\n }\n }", "void animalMove(int x,int y, Living[][] map,int gridLength, int gridWidth){\r\n \r\n boolean age=map[x][y].getAge();\r\n boolean gender=map[x][y].getGender();\r\n boolean checkRight=false;\r\n boolean checkLeft=false;\r\n boolean checkUp=false;\r\n boolean checkDown=false;\r\n boolean up=false;\r\n boolean down=false;\r\n boolean right=false;\r\n boolean left=false;\r\n boolean baby=false;\r\n boolean turn=map[x][y].getMovement(); //Check to see if it moved before in the array\r\n \r\n double random=Math.random();\r\n \r\n \r\n \r\n \r\n //Checks to see if it is possible to even see to the left first\r\n if(y-1>=0){\r\n left=true;\r\n \r\n if(turn && (map[x][y-1] instanceof Plant) ){ //Check to see if there is plants and goes to plants\r\n map[x][y].gainHealth((map[x][y-1].getHealth()));\r\n map[x][y].setMovement(false); \r\n map[x][y-1]=map[x][y];\r\n map[x][y]=null;\r\n turn=false; \r\n }\r\n if(turn && (map[x][y-1] instanceof Sheep) && (age==map[x][y-1].getAge()) ){ \r\n //If the ages match they must be false to be adults and both be opposite genders\r\n if(turn && !(age) && !(gender==map[x][y-1].getGender()) && (map[x][y].getHealth()>19) && (map[x][y-1].getHealth()>19) ){\r\n \r\n //Success rate of conceiving\r\n if( (Math.random()<=0.85) ){ \r\n \r\n if( (x+1<gridLength) && (map[x+1][y]==null)&& !(baby) ){ //Following ifs check to see if a baby can be made surrounding the intitiating sheep\r\n map[x+1][y]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true; \r\n }\r\n \r\n if( (x-1>=0) && (map[x-1][y]==null)&& !(baby) ){\r\n map[x-1][y]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n if((y+1<gridLength) && (map[x][y+1]==null) && !(baby) ){\r\n map[x][y+1]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n if(baby){ //If baby is made then sheep will lose health and turn is therefore over \r\n map[x][y].lowerHealth(10);\r\n map[x][y-1].lowerHealth(10);\r\n map[x][y].setMovement(false);\r\n map[x][y-1].setMovement(false);\r\n turn=false;\r\n baby=false;\r\n }\r\n }\r\n } \r\n }\r\n //If it can move to the left need to check if it can foresee more incase there wasn't any place for it to go\r\n if(y-2>=0){\r\n checkLeft=true;\r\n }\r\n }\r\n \r\n //Checks to see if it is possible to even see to the right first \r\n if(y+1<gridWidth){\r\n right=true;\r\n \r\n //Check to move on towards plants\r\n if(turn && (map[x][y+1] instanceof Plant)){\r\n map[x][y].gainHealth(map[x][y+1].getHealth()); \r\n map[x][y].setMovement(false); \r\n map[x][y+1]=map[x][y];\r\n map[x][y]=null;\r\n turn=false; \r\n }\r\n \r\n if(turn && (map[x][y+1] instanceof Sheep && age==map[x][y+1].getAge()) ){ \r\n //If the ages match they must be false to be adults and both be opposite genders\r\n if(turn && !(age) && !(gender==map[x][y+1].getGender()) && (map[x][y].getHealth()>19) && (map[x][y+1].getHealth()>19) ){\r\n \r\n //Success rate of conceiving\r\n if( (Math.random()<=0.85) ){\r\n \r\n if( (x+1<gridLength) && (map[x+1][y]==null) && !(baby) ){ //Following ifs check to see if a baby can be made surrounding the intitiating sheep\r\n \r\n map[x+1][y]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true; \r\n }\r\n \r\n if( (x-1>=0) && (map[x-1][y]==null) && !(baby) ){\r\n map[x-1][y]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n if( (y-1>=0) && (map[x][y-1]==null) && !(baby) ){\r\n map[x][y-1]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n if(baby){ //If baby is made then sheeps will lose health and turn is therefore over \r\n map[x][y].lowerHealth(10);\r\n map[x][y+1].lowerHealth(10);\r\n map[x][y].setMovement(false);\r\n map[x][y+1].setMovement(false);\r\n turn=false; \r\n baby=false;\r\n }\r\n }\r\n } \r\n }\r\n \r\n //If it can move to the right need to check if it can foresee more incase there wasn't any place for it to go\r\n if(y+2<gridWidth){ \r\n checkRight=true;\r\n }\r\n } \r\n \r\n //Check to see if it can go up\r\n if(x-1>=0){\r\n up=true;\r\n \r\n //Check for plant to go on to upwards \r\n if(turn && (map[x-1][y] instanceof Plant) ){\r\n map[x][y].gainHealth(map[x-1][y].getHealth()); \r\n map[x][y].setMovement(false); \r\n map[x-1][y]=map[x][y];\r\n map[x][y]=null;\r\n turn=false;\r\n }\r\n \r\n if(turn && (map[x-1][y] instanceof Sheep) && (age==map[x-1][y].getAge()) ){ \r\n //If the ages match age must be false to be adults and both be opposite genders and have more then 19 health\r\n if(turn && !age && !(gender==map[x-1][y].getGender()) &&map[x][y].getHealth()>19 &&map[x-1][y].getHealth()>19){\r\n \r\n //Success rate of conceiving\r\n if( (Math.random()<=0.85) ){\r\n if( (y+1<gridLength) && (map[x][y+1]==null) && !(baby) ){ //Following ifs check to see if a baby can be made surrounding the intitiating sheep\r\n \r\n map[x][y+1]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true; \r\n }\r\n if( (y-1>=0) && (map[x][y-1]==null) && !(baby) ){\r\n map[x][y-1]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n \r\n if( (x+1<gridLength) && (map[x+1][y]==null) && !(baby) ){\r\n map[x+1][y]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n \r\n if(baby){ //If baby is made then sheep will lose health and turn is therefore over \r\n map[x][y].lowerHealth(10);\r\n map[x-1][y].lowerHealth(10);\r\n map[x][y].setMovement(false);\r\n map[x-1][y].setMovement(false);\r\n turn=false; \r\n baby=false;\r\n }\r\n }\r\n } \r\n }\r\n \r\n //If it can move to upwards need to check if it can foresee more incase there wasn't any place for it to go\r\n if(x-2>=0){\r\n checkUp=true; \r\n }\r\n } \r\n //Check to see where to go downwards\r\n if(x+1<gridLength){\r\n down=true; \r\n \r\n //Check to see if any plants are downwards\r\n if(turn && (map[x+1][y] instanceof Plant) ){\r\n map[x][y].gainHealth( (map[x+1][y].getHealth()));\r\n map[x][y].setMovement(false);\r\n map[x+1][y]=map[x][y];\r\n map[x][y]=null;\r\n turn=false;\r\n } \r\n \r\n if(turn && (map[x+1][y] instanceof Sheep) && (age==map[x+1][y].getAge()) ){ \r\n \r\n //If the ages match they must be false to be adults and both be opposite genders\r\n if(turn && !(age) && !(gender==map[x+1][y].getGender()) && (map[x][y].getHealth()>=20) && (map[x+1][y].getHealth()>=20) ){\r\n \r\n //Success rate of conceiving\r\n if( (Math.random()<=0.85) ){\r\n if( (y+1<gridLength) && (map[x][y+1]==null) && !(baby) ){ //Following ifs check to see if a baby can be made surrounding the intitiating sheep \r\n map[x][y+1]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true; \r\n }\r\n if( (y-1>=0) && (map[x][y-1]==null) && !(baby) ){\r\n map[x][y-1]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n if( (x-1>=0) && (map[x+1][y]==null) && !(baby) ){\r\n map[x-1][y]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n if(baby){ //If baby is made then sheep will lose health and turn is therefore over \r\n map[x][y].lowerHealth(10);\r\n map[x+1][y].lowerHealth(10);\r\n map[x][y].setMovement(false);\r\n map[x+1][y].setMovement(false);\r\n turn=false;\r\n baby=false;\r\n }\r\n }\r\n } \r\n } \r\n if(x+2<gridLength){\r\n checkDown=true;\r\n }\r\n } \r\n \r\n //Movement towards plant only if no immediate sheep/plants are there to move to\r\n if(turn && checkRight && (map[x][y+2] instanceof Plant) ){\r\n if(map[x][y+1]==null){\r\n \r\n map[x][y+1]=map[x][y];\r\n map[x][y]=null;\r\n map[x][y+1].setMovement(false);\r\n turn=false;\r\n }\r\n }\r\n if(turn && checkDown && (map[x+2][y] instanceof Plant) ){\r\n if(map[x+1][y]==null){\r\n map[x+1][y]=map[x][y];\r\n map[x][y]=null;\r\n map[x+1][y].setMovement(false);\r\n turn=false;\r\n }\r\n } \r\n if(turn && checkUp && (map[x-2][y] instanceof Plant) ){\r\n if(map[x-1][y]==null){\r\n \r\n map[x-1][y]=map[x][y];\r\n map[x][y]=null;\r\n map[x-1][y].setMovement(false);\r\n turn=false;\r\n }\r\n }\r\n \r\n if(turn && checkLeft && (map[x][y-2] instanceof Plant) ){\r\n if(map[x][y-1]==null){\r\n map[x][y-1]=map[x][y];\r\n map[x][y]=null;\r\n map[x][y-1].setMovement(false);\r\n turn=false;\r\n }\r\n }\r\n \r\n //Random Movement if there are no plants to move towards \r\n if(turn && right && (random<=0.2) ){\r\n if(map[x][y+1]==null){\r\n map[x][y].setMovement(false);\r\n map[x][y+1]=map[x][y];\r\n map[x][y]=null; \r\n }\r\n }\r\n if(turn && left && (random>0.2) && (random<=0.4) ){\r\n if(map[x][y-1]==null){\r\n map[x][y].setMovement(false);\r\n map[x][y-1]=map[x][y];\r\n map[x][y]=null;\r\n }\r\n }\r\n if(turn && up && (random>0.4) && (random<=0.6) ){\r\n if(map[x-1][y]==null){\r\n map[x][y].setMovement(false);\r\n map[x-1][y]=map[x][y];\r\n map[x][y]=null;\r\n }\r\n }\r\n if(turn && down && (random>0.6) && (random<=0.8) ){\r\n if(map[x+1][y]==null){\r\n map[x][y].setMovement(false);\r\n map[x+1][y]=map[x][y];\r\n map[x][y]=null;\r\n }\r\n }\r\n }", "@Override\n public void update() {\n for (Integer i : arrAttack) {\n //System.out.println(scene.entityManager.getEntityByID(i).getName());\n\n //if the weapon has not a -1\n if (scene.entityManager.getEntityComponentInstance(i, Tool.class).currentActive != - 1) {\n\n ArrayList<AttackCollider> arrColliders = scene.entityManager.getEntityComponentInstance(i, attackComponent.getClass()).arrColliders;\n\n //Check if it collides with a collidable entity\n for (Integer j : arrCollidable) {\n //if they are not the same and i is not a weapon of j, and if j is alive\n if (!Objects.equals(i, j) && !isWeaponOf(i, j) && scene.entityManager.getEntityComponentInstance(j, Playable.class).isAlive) {\n\n //for each collider that collides with the entity\n for (AttackCollider k : checkAttack(i, j)) {\n //Do something to the collidable entity\n executeAttack(i, j);\n }\n }\n }\n }\n }\n initializeEntities();\n }", "private void updateEnemies()\n\t \n\t {\n\t for(int i = 0; i < EnemyList.size(); i++)\n\t {\n\t \t//get and update enemy for the enemy list\n\t Enemy eh = EnemyList.get(i);\n\t eh.Update();\n\t \n\t //checks for enemy and player crashes \n\t Rectangle playerRectangel = new Rectangle(pl.xCoord, pl.yCoord, pl.PlayerImage.getWidth(), pl.PlayerImage.getHeight());\n\t Rectangle enemyRectangel = new Rectangle(eh.xCoord, eh.yCoord, eh.EnemyHelicopterImage.getWidth(), eh.EnemyHelicopterImage.getHeight());\n\t if(playerRectangel.intersects(enemyRectangel)){\n\t \n\t \t//set player health to zero\n\t \tpl.Health = 0;\n\t \n\t // Remove helicopter from the list.\n\t EnemyList.remove(i);\n\t \n\t //creates new explosion coordinates \n\t enExplosionX = eh.xCoord; \n\t enExplosionY = eh.yCoord; \n\t plExplosionX = pl.xCoord+120;\n\t plExplosionY = pl.yCoord;\n\t GameOn = false;\n\t \n\t }\n\t \n\t // Check health.\n\t if(eh.Health <= 0){\n\t \n\t // Increase the number of destroyed enemies and removes a helicopter froma list.\n\t DestroyedEnemies++;\n\t \n\t \n\t if(DestroyedEnemies == 10)\n\t {\n\t \t//WinsState = true; \n\t \t\n\t }\n\t EnemyList.remove(i);\n\t \n\t }\n\t \n\t // If the current enemy has left the scree it is removed from the list and the number of runAwayEnemies is increased.\n\t if(eh.HasLeftScreen())\n\t {\n\t \tEnemyList.remove(i);\n\t RunAwayEnemies++;\n\t }\n\t \n\t if(RunAwayEnemies > 5)\n\t {\n\t \tGameOn = false; \n\t \t\n\t }\n\t }\n\t \n\t }", "protected final void run(int direction) {\r\n \t\r\n \t//deduct this from the critter's energy\r\n \tenergy = energy - Params.RUN_ENERGY_COST;\r\n \t\r\n \tif(hasMoved == false) {\r\n \t\tif((isFight == false || (isFight == true && unoccupiedPosition(direction, 2) == true)) && energy > 0) {\r\n \t\t\t\r\n \t\t\t//get the critter's new position\r\n \t\t\tint[] critterCoord = getCritterPos(direction, 2);\r\n \t\t\tx_coord = critterCoord[0];\r\n \t\t\ty_coord = critterCoord[1];\r\n \t\t\t\r\n \t\t\thasMoved = true;\r\n \t\t\tisFight = false;\r\n \t\t\r\n \t\t\tString critterPos = Integer.toString(x_coord) + \"_\" + Integer.toString(y_coord);\r\n \t\t\t\r\n \t\t\tArrayList<Critter> critterList = populationMoved.get(critterPos);\r\n \t\t\t\r\n \t\t\t//if there are already critters in this grid position\r\n \t\t\tif(!(critterList == null)) {\r\n \t\t\t\tcritterList.add(this);\r\n \t\t\t\tpopulationMoved.replace(critterPos, critterList);\r\n \t\t\t\t\r\n \t\t\t//if critter moves into an empty space\r\n \t\t\t} else {\r\n \t\t\t\tArrayList<Critter> newList = new ArrayList<Critter>();\r\n \t\t\t\tnewList.add(this);\r\n \t\t\t\tpopulationMoved.put(critterPos, newList);\r\n \t\t\t}\r\n \t\t\t\r\n \t\t}\r\n \t}\r\n }", "public synchronized void moveAnts() {\r\n\t\tArrayList<Ant> deadAnts = new ArrayList<Ant>();// holds all ants killed during current loop\r\n\t\tArrayList<Integer> bornAnts = new ArrayList<Integer>();// holds all ants \r\n\t\tfor (int i = 0; i < ants.size(); i++) {// loops through all the ants\r\n\t\t\tint deadAnt = 999999;// determines whether an ant has died and holds the index\r\n\t\t\tint antBorn = 999999;// determines whether an ant has been born and holds the index\r\n\t\t\t\r\n\t\t\tAnt iAnt = (Ant) ants.get(i);// creates duplicate of each Spider, necessary for deletion purposes\r\n\t\t\t\r\n\t\t\tif (iAnt.getActions().isEmpty())// checks if the Ant has any current actions to complete\r\n\t\t\t\tiAnt.setActions(antFSM.get(iAnt).update());// if not, gets actions from FSM\r\n\t\t\t\r\n\t\t\tString action = iAnt.getActions().remove(0);// gets the first action in the list\r\n\t\t\t\r\n\t\t\tint newPosition = iAnt.getCurrent();// will hold the next position of the ant\r\n\t\t\tboolean alive = true;// used to flag ant deaths\r\n\t\t\tantFSM.get(iAnt).getCurrentState().getTransition(foundFood).setTriggered(false);// sets the found food trigger to false\r\n\t\t\tantFSM.get(iAnt).getCurrentState().getTransition(foundHome).setTriggered(false);// sets the found food trigger to false\r\n\t\t\tantFSM.get(iAnt).getCurrentState().getTransition(foundWater).setTriggered(false);// sets the found food trigger to false\r\n\t\t\t\r\n\t\t\tswitch(action) {// switch handles the different actions registered by the FSM\r\n\t\t\t\tcase (\"Died\"):\t\t\t\r\n\t\t\t\t\tnodes[iAnt.getCurrent()].setImage(terrain);// sets the node image to terrain\r\n\t\t\t\t\tnodes[iAnt.getCurrent()].setOccupant(\"terrain\");// sets the node occupant to terrain\r\n\t\t\t\t\talive = false;// flags the ant as dead\r\n\t\t\t\t\tbreak;// breaks from switch\r\n\t\t\t\tcase (\"SearchForFood\"):\t\r\n\t\t\t\t\tnewPosition = wander(iAnt);// gets new position through wander method\r\n\t\t\t\t\tnodes[iAnt.getCurrent()].setImage(new ImageIcon(nodes[iAnt.getCurrent()].getOccupant() + \".png\").getImage());// sets current node image as previous occupant\r\n\t\t\t\t\tiAnt.setCurrent(newPosition);// updates the ant position\r\n\t\t\t\t\tnodes[iAnt.getCurrent()].setImage(ant);// sets the new node image as the ant\r\n\t\t\t\t\tif (nodes[newPosition].getOccupant().equals(\"food\")) {// checks if food has been found\r\n\t\t\t\t\t\tantFSM.get(iAnt).getCurrentState().getTransition(foundFood).setTriggered(true);// updates foundFood trigger\r\n\t\t\t\t\t}// if (food)\r\n\t\t\t\t\tbreak;// breaks from switch\r\n\t\t\t\tcase (\"PickupFood\"):\t\r\n\t\t\t\t\tnodes[iAnt.getCurrent()].setImage(antWithFood);// sets node image to ant with food\r\n\t\t\t\t\tnodes[iAnt.getCurrent()].setOccupant(\"terrain\");// sets node occupant to terrain\r\n\t\t\t\t\tbreak;// breaks from switch\r\n\t\t\t\tcase (\"EnterAntHill\"):\t\r\n\t\t\t\t\tnodes[iAnt.getCurrent()].setImage(antInHill);// updates node image to ant in hill\r\n\t\t\t\t\tbreak;// breaks from switch\r\n\t\t\t\tcase (\"InAntHill\"):\t\t\r\n\t\t\t\t\tnodes[iAnt.getCurrent()].setImage(antHill);// updates node image to ant hill\r\n\t\t\t\t\tbreak;// breaks from switch\r\n\t\t\t\tcase (\"LeaveAntHill\"):\t\r\n\t\t\t\t\tnodes[iAnt.getCurrent()].setImage(antInHill);// updates node image to ant in hill\r\n\t\t\t\t\tbreak;// breaks from switch\r\n\t\t\t\tcase (\"SearchForHome\"):\t\r\n\t\t\t\t\tnewPosition = getAStar(iAnt);// gets new position from A*\r\n\t\t\t\t\tnodes[iAnt.getCurrent()].setImage(new ImageIcon(nodes[iAnt.getCurrent()].getOccupant() + \".png\").getImage());// updates old node image to current occupant\r\n\t\t\t\t\tiAnt.setCurrent(newPosition);// updates ant position\r\n\t\t\t\t\tnodes[iAnt.getCurrent()].setImage(antWithFood);// updates new node image to ant with food\r\n\t\t\t\t\tif (iAnt.getHome() == newPosition) {// if home has been found\r\n\t\t\t\t\t\tantBorn = iAnt.getHome();// gets node for new ant\r\n\t\t\t\t\t\tantFSM.get(iAnt).getCurrentState().getTransition(foundHome).setTriggered(true);// sets found home trigger to true\r\n\t\t\t\t\t\tnodes[iAnt.getCurrent()].setImage(antInHill);// sets new node image to ant in hill\r\n\t\t\t\t\t}// if (home)\r\n\t\t\t\t\tbreak;// breaks from switch\r\n\t\t\t\tcase (\"SearchForWater\"):\r\n\t\t\t\t\tnewPosition = wander(iAnt);// gets new position from wander\r\n\t\t\t\t\tnodes[iAnt.getCurrent()].setImage(new ImageIcon(nodes[iAnt.getCurrent()].getOccupant() + \".png\").getImage());// updates old node to previous occupant image\r\n\t\t\t\t\tiAnt.setCurrent(newPosition);// updates ant position\r\n\t\t\t\t\tnodes[iAnt.getCurrent()].setImage(ant);// updates new node image to ant\r\n\t\t\t\t\tif (nodes[newPosition].getOccupant().equals(\"water\")) {// checks if water has been found\r\n\t\t\t\t\t\tantFSM.get(iAnt).getCurrentState().getTransition(foundWater).setTriggered(true);// sets found water trigger to true\r\n\t\t\t\t\t}// if (water)\t\t\t\r\n\t\t\t\t\tbreak;// breaks from switch\r\n\t\t\t\tcase (\"DrinkWater\"):\t\r\n\t\t\t\t\tnodes[iAnt.getCurrent()].setImage(antInWater);// updates node image to ant in water\r\n\t\t\t\t\tnodes[iAnt.getCurrent()].setOccupant(\"terrain\");// updates node occupant to terrain\r\n\t\t\t\t\tbreak;// breaks from switch\r\n\t\t\t\tdefault:\t\t\t\t\r\n\t\t\t\t\tbreak;// breaks from switch\r\n\t\t\t}// switch(action)\r\n\t\t\t\r\n\t\t\tif (nodes[newPosition].getOccupant().equals(\"poison\")) {// checks if ant steps in poison\r\n\t\t\t\tnodes[iAnt.getCurrent()].setImage(terrain);// updates the node image to terrain\r\n\t\t\t\tnodes[iAnt.getCurrent()].setOccupant(\"terrain\");// updates the node occupant to terrain\r\n\t\t\t\talive = false;// flags that ant was killed\r\n\t\t\t\tdeadAnt = i;// gets number of ant killed\r\n\t\t\t}// if (poison)\r\n\t\t\t\r\n\t\t\tif (alive) {// checks if ant is alive\r\n\t\t\t\tif (ants.get(i).getCurrent() == ants.get(i).getHome() && !action.equals(\"EnterAntHill\") && !action.equals(\"LeaveAntHill\") && !action.equals(\"SearchForHome\"))// checks if ant hill image needs to be added\r\n\t\t\t\t\tnodes[ants.get(i).getCurrent()].setImage(new ImageIcon(\"antHill.png\").getImage());//sets image to ant hill\r\n\t\t\t}// if (alive)\r\n\t\t\t\r\n\t\t\tif (deadAnt != 999999) {// checks if current ant was killed\r\n\t\t\t\tdeadAnts.add(iAnt);// adds number of ant killed\r\n\t\t\t}// if (ant died)\r\n\t\t\t\r\n\t\t\tif (antBorn != 999999) {// check if an ant was born\r\n\t\t\t\tbornAnts.add(antBorn);// adds number of ant born\r\n\t\t\t}// if (ant born)\r\n\t\t}// for (ants)\r\n\t\t\r\n\t\tfor (Ant ant : deadAnts)// loops through all ants killed in current game loop\r\n\t\t\tants.remove(ant);// removes ants killed during game loop\r\n\t\t\r\n\t\tfor (Integer node : bornAnts)// loops through all ant born in current game loop\r\n\t\t\taddAnt(node, node);// adds ants born during game loop\r\n\t}", "private void RePeaterAction(RePeater r, int i, int j) {\n\t\tif (r.getHp() <= 0) {\n\t\t\tthis.board.removeModel(r, i, j);\n\t\t} else {\n\t\t\tfor (int k = j; k < this.board.getLength(); k++) {\n\t\t\t\tif (this.board.getModel(i, k) instanceof AbstractZombie) {\n\t\t\t\t\tr.attack(this.board.getModel(i, k));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "private void updateGrid() {\n\t\tfor (Neighbor neighbor : upsetNeighbors) {\n\t\t\tClear vacated_cell = new Clear(neighbor.getCoordsX(), neighbor.getCoordsY());\n\t\t\tgrid.setGridIndex(vacated_cell, vacated_cell.getCoordsX(), vacated_cell.getCoordsY());\n\t\t\tCell new_location = availableSpaces.get((int) (Math.random() * (availableSpaces.size() - 1)));\n\t\t\tint new_x = new_location.getCoordsX();\n\t\t\tint new_y = new_location.getCoordsY();\n\t\t\tif (neighbor.getClass().equals(Group1.class))\n\t\t\t\tgrid.setGridIndex(new Group1(new_x, new_y, percentSimilar), new_x, new_y);\n\t\t\telse\n\t\t\t\tgrid.setGridIndex(new Group2(new_x, new_y, percentSimilar), new_x, new_y);\n\t\t\tavailableSpaces.remove(new_location);\n\t\t\tavailableSpaces.add(vacated_cell);\n\t\t}\n\t}", "public void collect() {\n\t\tthis.getOwnerArea().unregisterActor(this);\n\t\t\n\t}", "public void act() \n {\n String worldname = getWorld().getClass().getName();\n if (worldname == \"Level0\")\n setImage(new GreenfootImage(\"vibranium.png\"));\n else if (worldname == \"Level1\")\n setImage(rocket.getCurrentImage());\n setLocation(getX()-8, getY()); \n if (getX() == 0) \n {\n getWorld().removeObject(this);\n }\n \n }", "private void moverCarritoGolf() {\n for (AutoGolf carrito : arrEnemigosCarritoGolf) {\n carrito.render(batch);\n\n carrito.moverIzquierda();\n }\n }", "private void eat() {\r\n\t\tthis.energy = this.baseEnergy;\r\n\t\tArrayList<Block> foodNeighbors = (ArrayList<Block>)this.getBlock().getAdjacent(prey, \"2457\");\r\n\t\twhile (foodNeighbors.size() > 0) {\r\n\t\t\tint randomNeighbor = r.nextInt(foodNeighbors.size());\r\n\t\t\tBlock b = this.getBlock();\r\n\t\t\tBlock t = foodNeighbors.get(randomNeighbor);\r\n\t\t\tif (!t.getNextCell().getNextState().equals(predator)) {\r\n\t\t\t\tmoveCell(this, b, t, new WaTorCell(this.getBlock(), new WaTorState(State.EMPTY_STATE),\r\n\t\t\t\t\t\tthis.ageToReproduce, this.baseEnergy));\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tfoodNeighbors.remove(t);\r\n\t\t}\r\n\t\tcellPreyRules(new WaTorState(WaTorState.WATOR_PREDATOR));\r\n\t}", "public void act()\n {\n // if (claimer ==null){\n // this.setClaim(false);\n //}\n if(claimer == null){\n setClaim(false);\n }\n if (energy>0){\n \n removeEnergy(decayRate);\n\n }\n else {\n // getWorld().removeObject(this);\n\n }\n \n //check the energy decay\n //change size and weight\n //\n }", "public void clearEnemies() {\n\t\tIterator<Entity> it = entities.iterator();\n\t\twhile (it.hasNext()) {\n\t\t\tEntity e = it.next();\n\t\t\t//Skip playerfish\n\t\t\tif (e instanceof PlayerFish) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\n\t\t\t//Kill and remove the entity\n\t\t\te.kill();\n\t\t\tit.remove();\n\t\t}\n\t\t\n\t\t//Remove all non playerfish from collidables\n\t\tcollidables.removeIf(c -> !(c instanceof PlayerFish));\n\t\tdrawables.removeIf(c -> !(c instanceof PlayerFish));\n\t}", "public ArrayList<Actor> getActors()\n {\n ArrayList<Actor> a = new ArrayList<Actor>();\n Location loc = this.getLocation();\n for (int i = loc.getRow()-2; i < loc.getRow() + 2; i++) {\n for (int j = loc.getCol()-2; j < loc.getCol() + 2; j++) {\n Location tmpLoc = new Location(i,j);\n if (getGrid().isValid(tmpLoc)) {\n Actor tmpActor = getGrid().get(tmpLoc);\n if (tmpActor != null && tmpActor != this) {\n a.add(tmpActor);\n }\n }\n }\n }\n return a;\n }", "public void act()\n {\n setPosition(posX + liftDirection[0] * liftSpeed, posY\n + liftDirection[1] * liftSpeed);\n setLocation(posToLoc(posX, posY));\n\n if (posY < 50)\n removeSelf();\n }", "public void act() \n {\n\n World wrld = getWorld();\n if(frameCounter >= frameWait)\n {\n super.act();\n frameCounter = 0;\n }\n else\n {\n frameCounter++;\n }\n if (dying)\n deathcounter++;\n GreenfootImage trans = getImage();\n trans.scale(500,500);\n setImage(trans);\n setLocation(getX(), (getY()));\n\n if (deathcounter > 10)\n {\n wrld.removeObject(this);\n ((Universe)wrld).score += 50;\n }\n else if (getX() < 10)\n wrld.removeObject(this);\n }", "private void moverCamionetas() {\n for (Camioneta cam : arrEnemigosCamioneta) {\n cam.render(batch);\n\n cam.moverIzquierda();\n }\n }", "private void iterateUpdate()\n\t{\n\t\tSystem.out.println(\"ITERATE\");\n\t\t\t\n\t\tfor (Organism org : simState.getOrganisms()) \n\t\t{\n\t\t\torganismViewData.resetOrganismView(org);\n\t\t}\n\t\t\n\t\tIterationResult result = simEngine.iterate();\n\t\t\n\t\t// Process born and dead organisms\n\t\taddBornModels(result.getBorn());\n\t\tremoveDeadModels(result.getLastDead());\n\t\t\n\t\trotateAnimals();\t\t\n\t}", "public static void doEncounters() {\r\n \t\r\n \tIterator<String> populationIter = population.keySet().iterator();\r\n\t\twhile (populationIter.hasNext()) { \r\n\t String pos = populationIter.next();\r\n\t ArrayList<Critter> critterList = population.get(pos);\r\n\t if(critterList.size() > 1) {\r\n\t \tint[] coords = stringToPos(pos);\r\n\t \t//get the integer value of the coordinates from the String key\r\n\t \tint x_copy = coords[0];\r\n\t \tint y_copy = coords[1];\r\n\t \t\r\n\t \tfor(int i = 0; i < critterList.size(); i++) {\r\n\t \t\tfor (int j = i+1; j < critterList.size(); j++) {\r\n\t \t\t\tCritter A = critterList.get(i);\r\n\t \t\t\tCritter B = critterList.get(j);\r\n\t \t\t\tif(A.getEnergy() > 0 && B.getEnergy() > 0 && A.x_coord == x_copy && A.y_coord == y_copy && B.x_coord == x_copy && B.y_coord == y_copy) {\r\n\t \t\t\t\t\r\n\t \t\t\t\t//Critters A and B are fighting\r\n\t \t\t\t\tA.isFight = true;\r\n\t \t\t\t\tB.isFight = true;\r\n\t \t\t\t\t\r\n\t \t\t\t\t//boolean AWantsToFight = A.fight(B.toString());\r\n\t \t\t\t\t//boolean BWantsToFight = B.fight(A.toString());\r\n\t \t\t\t\tint skillA = 0;\r\n\t \t\t\t\tint skillB = 0;\r\n\t \t\t\t\t\r\n\t \t\t\t\t//determine how A wants to respond\r\n\t \t\t\t\tif(A.fight(B.toString()) == true) {\r\n\t \t\t\t\t\tskillA = getRandomInt(A.energy);\r\n\t \t\t\t\t}\r\n\t \t\t\t\t\r\n\t \t\t\t\t//determine how B wants to respond\r\n\t \t\t\t\tif(B.fight(A.toString()) == true) {\r\n\t \t\t\t\t\tskillB = getRandomInt(B.energy);\r\n\t \t\t\t\t}\r\n\t \t\t\t\tif(A.x_coord == x_copy && B.x_coord == x_copy && A.y_coord == y_copy && B.y_coord == y_copy) {\r\n\t \t\t\t\t\tif(skillA > skillB) { // A wins\r\n\t \t\t\t\t\t\tA.energy += (int) Math.floor(B.energy*1.0*0.5);\r\n\t \t\t\t\t\t\tB.energy = 0;\r\n\t \t\t\t\t\t} else if (skillB > skillA) {\r\n\t \t\t\t\t\t\tB.energy += (int) Math.floor(A.energy*1.0*0.5); //B wins\r\n\t \t\t\t\t\t\tA.energy = 0;\r\n\t \t\t\t\t\t} else {\r\n\t \t\t\t\t\t\tif(getRandomInt(1) == 0) { // A wins\r\n\t\t \t\t\t\t\t\tA.energy += (int) Math.floor(B.energy*1.0*0.5);\r\n\t\t \t\t\t\t\t\tB.energy = 0;\r\n\t \t\t\t\t\t\t} else {\r\n\t\t \t\t\t\t\t\tB.energy += (int) Math.floor(A.energy*1.0*0.5); //B wins\r\n\t\t \t\t\t\t\t\tA.energy = 0;\r\n\t \t\t\t\t\t\t}\r\n\t \t\t\t\t\t}\r\n\t \t\t\t\t}\r\n\t \t\t\t\t\r\n\t \t\t\t\t//Critters A and B have completed their fight\r\n\t \t\t\t\tA.isFight = false;\r\n\t \t\t\t\tB.isFight = false;\r\n\t \t\t\t\t\r\n\t \t\t\t\tcritterList.set(i, A);\r\n\t \t\t\t\tcritterList.set(j, B);\r\n\t \t\t\t}\r\n\t \t\t}\r\n\t \t}\r\n\t \t\r\n\t \t//Iterate through the critters in that position\r\n\t \tIterator<Critter> crittIter = critterList.iterator();\r\n\t \twhile(crittIter.hasNext()) {\r\n\t \t\tCritter c = crittIter.next();\r\n\t \t\t//remove critters who have moved out of that grid position or who have died\r\n\t \t\tif(c.x_coord != x_copy || c.y_coord != y_copy || (c.energy <= 0)) {\r\n\t \t\t\tcrittIter.remove();\r\n\t \t\t}\r\n\t \t}\r\n\t \tpopulation.replace(pos, critterList);\r\n\t }\r\n\t\t}\r\n }", "public void update(GameState gameState) {\n for (int i = 0;i < map.length; i++) {\n for (int j = 0;j < map[0].length;j++) {\n if (map[i][j] == TileType.WATER) {\n continue;\n }\n\n if (map[i][j] == TileType.MY_ANT) {\n map[i][j] = TileType.LAND;\n }\n\n if (gameState.getMap()[i][j] != TileType.UNKNOWN) {\n this.map[i][j] = gameState.getMap()[i][j];\n }\n }\n }\n\n this.myAnts = gameState.getMyAnts();\n this.enemyAnts = gameState.getEnemyAnts();\n this.myHills = gameState.getMyHills();\n this.seenEnemyHills.addAll(gameState.getEnemyHills());\n\n // remove eaten food\n MapUtils mapUtils = new MapUtils(gameSetup);\n Set<Tile> filteredFood = new HashSet<Tile>();\n filteredFood.addAll(seenFood);\n for (Tile foodTile : seenFood) {\n if (mapUtils.isVisible(foodTile, gameState.getMyAnts(), gameSetup.getViewRadius2())\n && getTileType(foodTile) != TileType.FOOD) {\n filteredFood.remove(foodTile);\n }\n }\n\n // add new foods\n filteredFood.addAll(gameState.getFoodTiles());\n this.seenFood = filteredFood;\n\n // explore unseen areas\n Set<Tile> copy = new HashSet<Tile>();\n copy.addAll(unseenTiles);\n for (Tile tile : copy) {\n if (isVisible(tile)) {\n unseenTiles.remove(tile);\n }\n }\n\n // remove fallen defenders\n Set<Tile> defenders = new HashSet<Tile>();\n for (Tile defender : motherlandDefenders) {\n if (myAnts.contains(defender)) {\n defenders.add(defender);\n }\n }\n this.motherlandDefenders = defenders;\n\n // prevent stepping on own hill\n reservedTiles.clear();\n reservedTiles.addAll(gameState.getMyHills());\n\n targetTiles.clear();\n }", "public void act() \n {\n moveEnemy();\n checkHealth();\n attacked();\n }", "public static void move (Species map[][], int plantHealth, int sheepHealth, int wolfHealth) {\n \n // Check map\n for (int y = 0; y < map[0].length; y++) {\n for (int x = 0; x < map.length; x++) {\n \n // Chooses an action to do (anything else does nothing)\n boolean [] actionChoice = action (map, x, y, plantHealth);\n \n // Avoid null pointers\n if (map[y][x] != null) {\n \n // Sheep\n // Check if sheep wants to move\n if ((map[y][x] instanceof Sheep) && (((Sheep)map[y][x]).getMoved() == false)) {\n ((Sheep)map[y][x]).loseHealthPerTurn();\n \n // If sheep run out of health, they die\n if ((map[y][x]).getHealth() < 1) {\n map[y][x] = null; \n \n // If sheep have sufficient health, they move, stay still, eat, or breed\n } else {\n \n // Choose direction using specific preferences (anything else stays still)\n int [] direction = moveDecision(map, x, y, plantHealth);\n \n // Chose to move up\n if (direction[0] == 1) {\n \n // Check in bounds\n if (y > 0) {\n \n // Wants to eat a plant\n if (actionChoice[0]) {\n \n // Depending on plant consumed, the effects vary\n if (map[y-1][x] instanceof EnergizingPlant) {\n ((Sheep)map[y][x]).energized(plantHealth);\n } else if (map[y-1][x] instanceof PoisonousPlant) {\n ((Sheep)map[y][x]).poisoned(plantHealth);\n } else {\n ((Sheep)map[y][x]).healed(plantHealth);\n }\n \n // Update sheep position\n ((Sheep)map[y][x]).setEnergy(((Sheep)map[y][x]).getEnergy()-1);\n ((Sheep)map[y][x]).up();\n ((Sheep)map[y][x]).setMoved(true);\n map[y-1][x] = map[y][x];\n map[y][x] = null;\n \n // Move to empty space\n } else if ((y > 0) && (map[y-1][x] == null)) {\n ((Sheep)map[y][x]).setEnergy(((Sheep)map[y][x]).getEnergy()-1);\n ((Sheep)map[y][x]).up();\n ((Sheep)map[y][x]).setMoved(true);\n map[y-1][x] = map[y][x];\n map[y][x] = null;\n }\n }\n \n // Chose to move down\n } else if (direction[0] == 2) {\n \n //Check in bounds\n if (y < map[0].length - 2) {\n \n // Wants to eat a plant\n if (actionChoice[0]) {\n \n // Depending on plant consumed, the effects vary\n if (map[y+1][x] instanceof EnergizingPlant) {\n ((Sheep)map[y][x]).energized(plantHealth);\n } else if (map[y+1][x] instanceof PoisonousPlant) {\n ((Sheep)map[y][x]).poisoned(plantHealth);\n } else {\n ((Sheep)map[y][x]).healed(plantHealth);\n }\n \n // Update sheep position\n ((Sheep)map[y][x]).setEnergy(((Sheep)map[y][x]).getEnergy()-1);\n ((Sheep)map[y][x]).down();\n ((Sheep)map[y][x]).setMoved(true);\n map[y+1][x] = map[y][x];\n map[y][x] = null;\n \n // Move to empty space\n } else if ((y < (map.length - 2)) && (map[y+1][x] == null)) {\n ((Sheep)map[y][x]).setEnergy(((Sheep)map[y][x]).getEnergy()-1);\n ((Sheep)map[y][x]).down();\n ((Sheep)map[y][x]).setMoved(true);\n map[y+1][x] = map[y][x];\n map[y][x] = null;\n }\n }\n \n // Chose to move left\n } else if (direction[0] == 3) {\n \n // Check in bounds\n if (x > 0) {\n \n // Wants to eat a plant\n if (actionChoice[0]) {\n \n // Depending on plant consumed, the effects vary\n if (map[y][x-1] instanceof EnergizingPlant) {\n ((Sheep)map[y][x]).energized(plantHealth);\n } else if (map[y][x-1] instanceof PoisonousPlant) {\n ((Sheep)map[y][x]).poisoned(plantHealth);\n } else {\n ((Sheep)map[y][x]).healed(plantHealth);\n } \n \n // Update sheep position\n ((Sheep)map[y][x]).setEnergy(((Sheep)map[y][x]).getEnergy()-1);\n ((Sheep)map[y][x]).left();\n ((Sheep)map[y][x]).setMoved(true);\n map[y][x-1] = map[y][x];\n map[y][x] = null;\n \n // Move to empty space\n } else if ((x > 0) && (map[y][x-1] == null)) {\n ((Sheep)map[y][x]).setEnergy(((Sheep)map[y][x]).getEnergy()-1);\n ((Sheep)map[y][x]).left();\n ((Sheep)map[y][x]).setMoved(true);\n map[y][x-1] = map[y][x];\n map[y][x] = null;\n }\n }\n \n // Chose to move right\n } else if (direction[0] == 4) {\n \n // Checks in bounds\n if (x < map.length - 2) {\n \n // Wants to eat a plant\n if (actionChoice[0]) {\n \n // Depending on plant consumed, the effects vary\n if (map[y][x+1] instanceof EnergizingPlant) {\n ((Sheep)map[y][x]).energized(plantHealth);\n } else if (map[y][x+1] instanceof PoisonousPlant) {\n ((Sheep)map[y][x]).poisoned(plantHealth);\n } else {\n ((Sheep)map[y][x]).healed(plantHealth);\n }\n \n // Update sheep position\n ((Sheep)map[y][x]).setEnergy(((Sheep)map[y][x]).getEnergy()-1);\n ((Sheep)map[y][x]).right();\n ((Sheep)map[y][x]).setMoved(true);\n map[y][x+1] = map[y][x];\n map[y][x] = null;\n \n // Move to empty space\n } else if ((x < (map.length - 2)) && (map[y][x+1] == null)) {\n ((Sheep)map[y][x]).setEnergy(((Sheep)map[y][x]).getEnergy()-1);\n ((Sheep)map[y][x]).right();\n ((Sheep)map[y][x]).setMoved(true);\n map[y][x+1] = map[y][x];\n map[y][x] = null;\n }\n \n }\n }\n \n }\n }\n \n // WOLF\n // Check if wolves wants to move \n if ((map[y][x] instanceof Wolf) && (((Wolf)map[y][x]).getMoved() == false)) { \n int run = 0;\n ((Wolf)map[y][x]).loseHealthPerTurn();\n \n // If wolves run out of health, they die\n if (map[y][x].getHealth() < 1) {\n map[y][x] = null;\n \n // If wolves have sufficient health, they move, stay still, eat, breed, or fight\n } else {\n \n // Choose direction using specific preferences (anything else stays still)\n int [] direction = moveDecision (map, x, y, plantHealth);\n \n // Chose to move up\n if (direction[1] == 1) {\n \n // Checks in bounds\n if (y > 0) {\n \n // Wants to eat a sheep\n if ((actionChoice[1]) && (map[y-1][x] instanceof Sheep)) {\n \n // Update healths\n ((Wolf)map[y][x]).healed(((Sheep)map[y-1][x]).getHealth());\n \n // Update wolf position\n ((Wolf)map[y][x]).setEnergy(((Wolf)map[y][x]).getEnergy()-1);\n ((Wolf)map[y][x]).up();\n ((Wolf)map[y][x]).setMoved(true);\n map[y-1][x] = map[y][x];\n map[y][x] = null;\n\n // Wants to fight\n } else if ((actionChoice[2]) && (map[y-1][x] instanceof Wolf)) {\n \n // Weaker wolf loses health; otherwise, nothing happens\n if (((Wolf)map[y][x]).compareTo((Wolf)map[y-1][x]) > 0) {\n ((Wolf)map[y-1][x]).damage(10);\n } else if (((Wolf)map[y][x]).compareTo((Wolf)map[y-1][x]) < 0) {\n ((Wolf)map[y][x]).damage(10);\n }\n \n // Move to empty space\n } else if ((x < (map.length - 2)) && (map[y-1][x] == null)) {\n ((Wolf)map[y][x]).setEnergy(((Wolf)map[y][x]).getEnergy()-1);\n ((Wolf)map[y][x]).right();\n ((Wolf)map[y][x]).setMoved(true);\n map[y-1][x] = map[y][x];\n map[y][x] = null;\n }\n }\n \n // Chose to move down\n } else if (direction[1] == 2) {\n \n // Checks in bounds\n if (y < map[0].length - 2) {\n \n // Wants to eat a sheep\n if ((actionChoice[1]) && (map[y+1][x] instanceof Sheep)) {\n \n // Update healths\n ((Wolf)map[y][x]).healed(((Sheep)map[y+1][x]).getHealth());\n \n // Update wolf position\n ((Wolf)map[y][x]).setEnergy(((Wolf)map[y][x]).getEnergy()-1);\n ((Wolf)map[y][x]).up();\n ((Wolf)map[y][x]).setMoved(true);\n map[y+1][x] = map[y][x];\n map[y][x] = null;\n \n // Wants to fight (does not move)\n } else if ((actionChoice[2]) && (map[y+1][x] instanceof Wolf)) {\n \n // Weaker wolf loses health; otherwise, nothing happens\n if (((Wolf)map[y][x]).compareTo((Wolf)map[y+1][x]) > 0) {\n ((Wolf)map[y+1][x]).damage(10);\n } else if (((Wolf)map[y][x]).compareTo((Wolf)map[y+1][x]) < 0) {\n ((Wolf)map[y][x]).damage(10);\n }\n \n // Move to empty space\n } else if ((x < (map.length - 2)) && (map[y+1][x] == null)) {\n ((Wolf)map[y][x]).setEnergy(((Wolf)map[y][x]).getEnergy()-1);\n ((Wolf)map[y][x]).right();\n ((Wolf)map[y][x]).setMoved(true);\n map[y+1][x] = map[y][x];\n map[y][x] = null;\n }\n }\n \n // Chose to move left\n } else if (direction[1] == 3) {\n \n // Checks in bounds\n if (x > 0) {\n \n // Wants to eat a sheep\n if ((actionChoice[1]) && (map[y][x-1] instanceof Sheep)) {\n \n // Update healths\n ((Wolf)map[y][x]).healed(((Sheep)map[y][x-1]).getHealth());\n \n // Update wolf position\n ((Wolf)map[y][x]).setEnergy(((Wolf)map[y][x]).getEnergy()-1);\n ((Wolf)map[y][x]).up();\n ((Wolf)map[y][x]).setMoved(true);\n map[y][x-1] = map[y][x];\n map[y][x] = null;\n \n // Wants to fight (does not move)\n } else if ((actionChoice[2]) && (map[y][x-1] instanceof Wolf)) {\n \n // Weaker wolf loses health; otherwise, nothing happens\n if (((Wolf)map[y][x]).compareTo((Wolf)map[y][x-1]) > 0) {\n ((Wolf)map[y][x-1]).damage(10);\n } else if (((Wolf)map[y][x]).compareTo((Wolf)map[y][x-1]) < 0) {\n ((Wolf)map[y][x]).damage(10);\n }\n \n // Move to empty space\n } else if ((x < (map.length - 2)) && (map[y][x-1] == null)) {\n ((Wolf)map[y][x]).setEnergy(((Wolf)map[y][x]).getEnergy()-1);\n ((Wolf)map[y][x]).right();\n ((Wolf)map[y][x]).setMoved(true);\n map[y][x-1] = map[y][x];\n map[y][x] = null;\n }\n }\n \n // Chose to move right \n } else if (direction[1] == 4) {\n \n // Checks in bounds\n if (x < map.length - 2) {\n \n // Wants to eat a sheep\n if ((actionChoice[1]) && (map[y][x+1] instanceof Sheep)) {\n \n // Update healths\n ((Wolf)map[y][x]).healed(((Sheep)map[y][x+1]).getHealth());\n \n // Update wolf position\n ((Wolf)map[y][x]).setEnergy(((Wolf)map[y][x]).getEnergy()-1);\n ((Wolf)map[y][x]).up();\n ((Wolf)map[y][x]).setMoved(true);\n map[y][x+1] = map[y][x];\n map[y][x] = null;\n \n // Wants to fight (does not move)\n } else if ((actionChoice[2]) && (map[y][x+1] instanceof Wolf)) {\n \n // Weaker wolf loses health; otherwise, nothing happens\n if (((Wolf)map[y][x]).compareTo((Wolf)map[y][x+1]) > 0) {\n ((Wolf)map[y][x+1]).damage(10);\n } else if (((Wolf)map[y][x]).compareTo((Wolf)map[y][x+1]) < 0) {\n ((Wolf)map[y][x]).damage(10);\n }\n \n // Move to empty space\n } else if ((x < (map.length - 2)) && (map[y][x+1] == null)) {\n ((Wolf)map[y][x]).setEnergy(((Wolf)map[y][x]).getEnergy()-1);\n ((Wolf)map[y][x]).right();\n ((Wolf)map[y][x]).setMoved(true);\n map[y][x+1] = map[y][x];\n map[y][x] = null;\n }\n }\n \n }\n }\n }\n \n }\n \n }\n }\n \n }", "public void removeActor(Actor act) { ActorSet.removeElement(act); }", "public void act() \n {\n // Add your action code here.\n if (Greenfoot.mouseClicked(this)){\n World myWorld = getWorld();\n List<Crab> crabs = myWorld.getObjects(Crab.class);\n for(Crab c : crabs){\n // int y = Greenfoot.getRandomNumber(560);\n // int x = Greenfoot.getRandomNumber(560);\n //c.setLocation(x,y);\n // myWorld.removeObjects(crabs);\n }\n \n /*\n Crab c = new Crab();\n int y = Greenfoot.getRandomNumber(560);\n int x = Greenfoot.getRandomNumber(560);\n myWorld.addObject(c, x, y);\n */\n \n }\n}", "public void tryAct() {\n\n List<Player> onCardPlayers = new ArrayList<Player>();\n List<Player> offCardPlayers = new ArrayList<Player>();\n if (currentPlayer.isEmployed() == true) {\n if(!currentPlayer.getHasPlayed()){\n onCardPlayers = findPlayers(currentPlayer.getLocation().getOnCardRoles());\n offCardPlayers = findPlayers(currentPlayer.getLocation().getOffCardRoles());\n currentPlayer.act(onCardPlayers, offCardPlayers);\n refreshPlayerPanel();\n }\n else{\n view.showPopUp(currentPlayer.isComputer(), \"You've already moved, rehearsed or acted this turn. Try a different command or click `end turn` to end your turn.\");\n }\n }\n else {\n view.showPopUp(currentPlayer.isComputer(), \"You're not employed, so you need to take a role before you can act.\");\n }\n view.updateSidePanel(playerArray);\n }", "public static void worldTimeStep() {\r\n \t\r\n \t//remake the hash map based on the x and y coordinates of the critters\r\n \tremakeMap(population);\r\n \t\r\n \t//Iterate through the grid positions in the population HashMap\r\n \tIterator<String> populationIter = population.keySet().iterator();\r\n \twhile (populationIter.hasNext()) { \r\n String pos = populationIter.next();\r\n ArrayList<Critter> critterList = population.get(pos);\r\n \r\n //Iterate through the critters ArrayList \r\n ListIterator<Critter> currCritter = critterList.listIterator();\r\n while(currCritter.hasNext()) {\r\n \tCritter thisCritter = currCritter.next();\r\n \tthisCritter.hasMoved = false;\r\n \tthisCritter.doTimeStep();\r\n \tif(thisCritter.hasMoved || thisCritter.getEnergy() <= 0) {\r\n \t\tcurrCritter.remove();\r\n \t} else {\r\n \t\tcurrCritter.set(thisCritter);\r\n \t}\r\n }\r\n population.replace(pos, critterList);\r\n }\r\n \t\r\n \tfixPopulation();\r\n \tmergePopulationMoved(populationMoved);\r\n \t\r\n \tdoEncounters();\r\n \t\r\n \tfixPopulation();\r\n \tmergePopulationMoved(populationMoved); //Stage 1 Complete\r\n \r\n \t//deduct resting energy cost from all critters in the hash map\r\n \t//could do a FOR EACH loop instead of iterator -- fixed\r\n \tpopulationIter = population.keySet().iterator();\r\n \twhile(populationIter.hasNext()) {\r\n \t\tString pos = populationIter.next();\r\n ArrayList<Critter> critterList = population.get(pos);\r\n \r\n //Iterate through the Critters attached to the keys in the Hash Map\r\n ListIterator<Critter> currCritter = critterList.listIterator();\r\n while(currCritter.hasNext()) {\r\n \tCritter thisCritter = currCritter.next();\r\n \t//deduct the rest energy cost from each critter\r\n \tthisCritter.energy = thisCritter.energy - Params.REST_ENERGY_COST;\r\n \t//remove all critters that have died after reducing the rest energy cost\r\n \tif(thisCritter.getEnergy() <= 0) {\r\n \t\tcurrCritter.remove();\r\n \t} else {\r\n \t\tcurrCritter.set(thisCritter);\r\n \t}\r\n }\r\n population.replace(pos, critterList);\r\n \t}\r\n \t\r\n \tmergePopulationMoved(babies);\r\n \t\r\n \t\r\n \t//add the clovers in each refresh of the world \r\n \ttry {\r\n \t\tfor(int j = 0; j < Params.REFRESH_CLOVER_COUNT; j++) {\r\n \t\t\tcreateCritter(\"Clover\");\r\n \t\t}\r\n \t} catch(InvalidCritterException p) {\r\n \t\tp.printStackTrace();\r\n \t}\r\n }", "public void moveStopped()\n {\n for (GraphElement element : elements) {\n if(element instanceof Moveable) {\n Moveable moveable = (Moveable) element;\n moveable.setPositionToGhost();\n }\n } \n }", "private void moveRobots() {\n\t\tfor(Player p : playerList) {\n\t\t\tif(p.getType() == Player.PlayerType.Robot) {\n\t\t\t\tPoint old = new Point(p.getX(), p.getY());\n\t\t\t\tPoint newPoint = new Point(p.getX(), p.getY());\n\t\t\t\t\n\t\t\t\toccupiedPositions.remove(old);\n\t\t\t\t\n\t\t\t\tint playerX = p.getPlayerToFollow().getX();\n\t\t\t\tint playerY = p.getPlayerToFollow().getY();\n\t\t\t\t\n\t\t\t\t//move towards the agent\n\t\t\t\tif(p.getX() < playerX)\n\t\t\t\t\tnewPoint.x += 1;\n\t\t\t\telse if(p.getX() > playerX)\n\t\t\t\t\tnewPoint.x -= 1;\n\t\t\t\t\n\t\t\t\tif(p.getY() < playerY)\n\t\t\t\t\tnewPoint.y += 1;\n\t\t\t\telse if(p.getY() > playerY)\n\t\t\t\t\tnewPoint.y -= 1;\n\t\t\t\t\n\t\t\t\tp.setPosition(newPoint);\n\t\t\t\t\n\t\t\t\t//check if the robot has moved on to something\n\t\t\t\tif(occupiedPositions.contains(newPoint)) { \t\t// check if the position is occupied\n\t\t\t\t\tfor(Player p2 : playerList) { \t\t\t\n\t\t\t\t\t\tif(!p.getName().equals(p2.getName())) {\t// check so it not is the robot itself\n\t\t\t\t\t\t\tif(newPoint.equals(p2.getPosition())) {\n\t\t\t\t\t\t\t\tif(p2.getType() == PlayerType.Robot) { // if it is a robot, both should be rubble\n\t\t\t\t\t\t\t\t\tp2.setType(PlayerType.Rubble);\n\t\t\t\t\t\t\t\t\tp2.getPlayerToFollow().decreaseRobotsFollowing();\n\t\t\t\t\t\t\t\t\tp.setType(PlayerType.Rubble);\n\t\t\t\t\t\t\t\t\tp.getPlayerToFollow().decreaseRobotsFollowing();\n\t\t\t\t\t\t\t\t\tHandleCommunication.broadcastToClient(null, server.getConnectedClientList(), SendSetting.ChangedType, p.getName(), p2.getName());\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif(p2.getType() == PlayerType.Rubble) { // if it is rubble\n\t\t\t\t\t\t\t\t\tp.setType(PlayerType.Rubble);\n\t\t\t\t\t\t\t\t\tp.getPlayerToFollow().decreaseRobotsFollowing();\n\t\t\t\t\t\t\t\t\tHandleCommunication.broadcastToClient(null, server.getConnectedClientList(), SendSetting.ChangedType, p.getName(), p2.getName());\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse if(p2.getType() == PlayerType.Agent) {\n\t\t\t\t\t\t\t\t\tString send = generateSendableHighscoreList();\n\t\t\t\t\t\t\t\t\tserver.sendMessageToClient(p2.getName(), \"@132@\" + highscore.size() + \"@\" + send);\n\t\t\t\t\t\t\t\t\tserver.addTextToLoggingWindow(\"Robot killed player (\" + p2.getName() + \")\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\toccupiedPositions.add(newPoint);\n\t\t\t\tserver.broadcastToClient(p.getName(), SendSetting.PlayerMoved, old, newPoint);\n\t\t\t}\t\n\t\t}\n\t\t\n\t\t//send that it is agents turn again\n\t\tserver.broadcastToClient(null, SendSetting.AgentsTurnToMove, null, null);\n\t}", "@Override\n public void revealAllMines() {\n for (Tile[] tiles : grid) {\n for (Tile t : tiles) {\n if (t.getType() == Tile.MINE) {\n t.setState(Tile.REVEALED);\n }\n }\n }\n }", "private void resetInvaders() {\n\t\t\n\t\tfor (ArrayList<Invader> row : enemyArray) {\n\t\t\tfor (Invader a : row) {\n\t\t\t\ta.setX(invaderX);\n\t\t\t\ta.setY(invaderY);\n\t\t\t\ta.setVisibility(true);\n\t\t\t\tinvaderX += 40;\n\t\t\t}\n\t\t\tinvaderY += 40;\n\t\t\tresetInvaderX();\n\t\t}\n\t\tresetInvaderY();\n\t}", "public void removeAllAgents()\n/* 76: */ {\n/* 77:125 */ this.mapPanel.removeAllAgents();\n/* 78: */ }", "public void processStimulus(java.util.Enumeration en) {\n//\t\tSystem.out.println(\"physics\");\n// performPhysics();\n\n//\t\tSystem.out.println(\"behavior\");\n doEveryFrame();\n\n//\t\tobjHPindicator\n// hpAppear.setColoringAttributes(new ColoringAttributes(1.0f - (float) hitpoints / (float) maxHitpoints, (float) hitpoints / (float) maxHitpoints, 0.0f, ColoringAttributes.NICEST));\n\n// refreshPosition();\n\n if (isAlive()) {\n wakeupOn(w);\n } else {\n kill();\n }\n }", "public void act() \n {\n advance(); // move forward in the correct direction\n\n if(canSee(Ground.class) || atWorldEdge()) {\n getWorld().removeObject(this);\n return; \n }\n\n bImpact();\n takeExplosionTimer();\n }", "@SuppressWarnings(\"rawtypes\")\r\n\tpublic void actionPerformed(ActionEvent e) {\n\t\t// Bullet //\r\n\t\t////////////\r\n\t\tArrayList msDOWN = GameCraft.getBulletDOWN();\r\n\t\tfor (int i = 0; i < msDOWN.size(); i++) {\r\n\t\t\tBulletDOWN m = (BulletDOWN) msDOWN.get(i);\r\n\t\t\tif (m.isVisible()) \r\n\t\t\t\tm.moveDOWN();\r\n\t\t\telse msDOWN.remove(i);\r\n\t\t}\r\n\r\n\t\tArrayList msUP = GameCraft.getBulletUP();\r\n\t\tfor (int i = 0; i < msUP.size(); i++) {\r\n\t\t\tBulletUP m = (BulletUP) msUP.get(i);\r\n\t\t\tif (m.isVisible()) \r\n\t\t\t\tm.moveUP();\r\n\t\t\telse msUP.remove(i);\r\n\t\t}\r\n\r\n\t\tArrayList msLEFT = GameCraft.getBulletLEFT();\r\n\t\tfor (int i = 0; i < msLEFT.size(); i++) {\r\n\t\t\tBulletLEFT m = (BulletLEFT) msLEFT.get(i);\r\n\t\t\tif (m.isVisible()) \r\n\t\t\t\tm.moveLEFT();\r\n\t\t\telse msLEFT.remove(i);\r\n\t\t}\r\n\r\n\t\tArrayList msRIGHT = GameCraft.getBulletRIGHT();\r\n\t\tfor (int i = 0; i < msRIGHT.size(); i++) {\r\n\t\t\tBulletRIGHT m = (BulletRIGHT) msRIGHT.get(i);\r\n\t\t\tif (m.isVisible()) \r\n\t\t\t\tm.moveRIGHT();\r\n\t\t\telse msRIGHT.remove(i);\r\n\t\t}\r\n\t\t\r\n\t\tArrayList msEnemys = GameCraft.getEnemys();\r\n\t\tif(moveamount >= 150){\r\n\t\t\tfor (int i = 0; i < msEnemys.size(); i++) {\r\n\t\t\t\tEnemys m = (Enemys) msEnemys.get(i);\r\n\t\t\t\tif (m.isVisible()){\r\n\t\t\t\t\tm.moveMe();\r\n\t\t\t\t}else{ \r\n\t\t\t\t\tmsEnemys.remove(i);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tmoveamount = 0;\r\n\t\t}\r\n\t\tmoveamount++;\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\tfor(int a = 0; a < msDOWN.size(); a++){\r\n\t\t\tfor(int b = 0; b < msEnemys.size(); b++){\r\n\t\t\t\tBulletDOWN bdown = (BulletDOWN) msDOWN.get(a);\r\n\t\t\t\tEnemys enemy = (Enemys) msEnemys.get(b);\r\n\t\t\t\tint xbul = bdown.getX();\r\n\t\t\t\tint ybul = bdown.getY();\r\n\t\t\t\tint xenemy = enemy.getX();\r\n\t\t\t\tint yenemy = enemy.getY();\r\n\t\t\t\t\r\n\t\t\t\tif((xbul - xenemy < 20 && xbul - xenemy > -20) && ( ybul - yenemy < 20 && xbul - yenemy > -20)){\r\n\t\t\t\t\tenemy.visible = false;\r\n\t\t\t\t\tscoreamount++;\r\n\t\t\t\t\t//GameCraft.SpawnEnemys();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tfor(int a = 0; a < msRIGHT.size(); a++){\r\n\t\t\tfor(int b = 0; b < msEnemys.size(); b++){\r\n\t\t\t\tBulletRIGHT bright = (BulletRIGHT) msRIGHT.get(a);\r\n\t\t\t\tEnemys enemy = (Enemys) msEnemys.get(b);\r\n\t\t\t\tint xbul = bright.getX();\r\n\t\t\t\tint ybul = bright.getY();\r\n\t\t\t\tint xenemy = enemy.getX();\r\n\t\t\t\tint yenemy = enemy.getY();\r\n\t\t\t\t\r\n\t\t\t\tif((xbul - xenemy < 20 && xbul - xenemy > -20) && ( ybul - yenemy < 20 && xbul - yenemy > -20)){\r\n\t\t\t\t\tenemy.visible = false;\r\n\t\t\t\t\tscoreamount++;\r\n\t\t\t\t\t//GameCraft.SpawnEnemys();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tfor(int a = 0; a < msLEFT.size(); a++){\r\n\t\t\tfor(int b = 0; b < msEnemys.size(); b++){\r\n\t\t\t\tBulletLEFT bleft = (BulletLEFT) msLEFT.get(a);\r\n\t\t\t\tEnemys enemy = (Enemys) msEnemys.get(b);\r\n\t\t\t\tint xbul = bleft.getX();\r\n\t\t\t\tint ybul = bleft.getY();\r\n\t\t\t\tint xenemy = enemy.getX();\r\n\t\t\t\tint yenemy = enemy.getY();\r\n\t\t\t\t\r\n\t\t\t\tif((xbul - xenemy < 20 && xbul - xenemy > -20) && ( ybul - yenemy < 20 && xbul - yenemy > -20)){\r\n\t\t\t\t\tenemy.visible = false;\r\n\t\t\t\t\tscoreamount++;\r\n\t\t\t\t\t//GameCraft.SpawnEnemys();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tfor(int a = 0; a < msUP.size(); a++){\r\n\t\t\tfor(int b = 0; b < msEnemys.size(); b++){\r\n\t\t\t\tBulletUP bup = (BulletUP) msUP.get(a);\r\n\t\t\t\tEnemys enemy = (Enemys) msEnemys.get(b);\r\n\t\t\t\tint xbul = bup.getX();\r\n\t\t\t\tint ybul = bup.getY();\r\n\t\t\t\tint xenemy = enemy.getX();\r\n\t\t\t\tint yenemy = enemy.getY();\r\n\t\t\t\t\r\n\t\t\t\tif((xbul - xenemy < 20 && xbul - xenemy > -20) && ( ybul - yenemy < 20 && xbul - yenemy > -20)){\r\n\t\t\t\t\tenemy.visible = false;\r\n\t\t\t\t\tscoreamount++;\r\n\t\t\t\t\t//GameCraft.SpawnEnemys();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\t/*\r\n\t\tEnemy 500 500\r\n\t\tBullet 510 510\r\n\t\t510 < 500 && 480 < 500 || 500 > 510 && 500 > 480\r\n\t\t500 > 320 && 500 > 380\r\n\t\t\r\n\t\t*/\r\n\t\t\r\n\t\t////////////\r\n\t\t// Bullet //\r\n\t\t////////////\r\n\t\tGameCraft.move();\r\n\t\trepaint(); \r\n\t}", "public static void makeEnemyMove() { //all players after index 1 are enemies\n if (gameMode == EARTH_INVADERS) {//find leftmost and rightmost vehicle columns to see if we need to move down\n int leftMost = board[0].length;\n int rightMost = 0;\n int lowest = 0;\n for (int i = FIRST_VEHICLE; i < players.length; i++) {//find left-most, right-most and lowest most vehicles (non aircraft/train) to determine how formation should move\n Player curr = players[i];\n if (curr == null)\n continue;\n String name = curr.getName();\n if (name.equals(\"NONE\") || curr.isFlying() || name.startsWith(\"TRAIN\") || (curr instanceof Monster))\n continue;\n if (curr.getCol() < leftMost)\n leftMost = curr.getCol();\n if (curr.getCol() > rightMost)\n rightMost = curr.getCol();\n if (curr.getRow() > lowest)\n lowest = curr.getRow();\n curr.setHeadDirection(DOWN);\n }\n for (int i = FIRST_VEHICLE; i < players.length; i++) {//***move aircraft and trains\n Player curr = players[i];\n if (curr == null)\n continue;\n String name = curr.getName();\n if (name.equals(\"NONE\") || curr.isFlying() || name.startsWith(\"TRAIN\") || (curr instanceof Monster)) {\n if (curr.isMoving())\n continue;\n ArrayList<Integer> dirs = new ArrayList(); //array of preferred directions - everything but the reverse of their body position\n int bodyDir = curr.getBodyDirection();\n curr.clearDirections();\n int r = curr.getRow();\n int c = curr.getCol();\n if (bodyDir == UP) {\n if (isValidMove(curr, r - 1, c))\n dirs.add(UP);\n if (isValidMove(curr, r, c + 1))\n dirs.add(RIGHT);\n if (!name.startsWith(\"TRAIN\")) //trains need to follow the track circuit - only straight and right turns\n {\n if (isValidMove(curr, r, c - 1))\n dirs.add(LEFT);\n }\n } else if (bodyDir == RIGHT) {\n if (!name.startsWith(\"TRAIN\")) //trains need to follow the track circuit - only straight and right turns\n {\n if (isValidMove(curr, r - 1, c))\n dirs.add(UP);\n }\n if (isValidMove(curr, r, c + 1))\n dirs.add(RIGHT);\n if (isValidMove(curr, r + 1, c))\n dirs.add(DOWN);\n } else if (bodyDir == DOWN) {\n if (isValidMove(curr, r + 1, c))\n dirs.add(DOWN);\n if (!name.startsWith(\"TRAIN\")) //trains need to follow the track circuit - only straight and right turns\n {\n if (isValidMove(curr, r, c + 1))\n dirs.add(RIGHT);\n }\n if (isValidMove(curr, r, c - 1))\n dirs.add(LEFT);\n } else //if(curr.getBodyDirection()==LEFT)\n {\n if (isValidMove(curr, r - 1, c))\n dirs.add(UP);\n if (!name.startsWith(\"TRAIN\")) //trains need to follow the track circuit - only straight and right turns\n {\n if (isValidMove(curr, r + 1, c))\n dirs.add(DOWN);\n }\n if (isValidMove(curr, r, c - 1))\n dirs.add(LEFT);\n }\n int rand = 0;\n if (dirs.size() > 0)\n rand = dirs.get((int) (Math.random() * dirs.size()));\n if (curr.isFlying()) { //if aircraft is flying in the visible board, don't change direction\n if (r == 1 && (c == 0 || c == board[0].length - 1)) //we are in the first row but behind a border\n { //we only want aircraft to appear in row 1 in EARTH INVADERS (like the UFO in space invaders)\n if (bodyDir == LEFT || bodyDir == RIGHT) {\n rand = UP;\n if (Math.random() < .5)\n rand = DOWN;\n } else if (c == 0)\n rand = RIGHT;\n else if (c == board[0].length - 1)\n rand = LEFT;\n else\n //if(dirs.contains(bodyDir))\n rand = bodyDir;\n } else if (r == 0 || c == 0 || r == board.length - 1 || c == board[0].length - 1) {\n rand = bodyDir;\n if (r == 0 && c == 0) {\n rand = RIGHT;\n if (Math.random() < .5)\n rand = DOWN;\n } else if (r == 0 && c == board[0].length - 1) {\n rand = LEFT;\n if (Math.random() < .5)\n rand = DOWN;\n } else if (r == board.length - 1 && c == 0) {\n rand = RIGHT;\n if (Math.random() < .5)\n rand = UP;\n } else if (r == board.length - 1 && c == board[0].length - 1) {\n rand = LEFT;\n if (Math.random() < .5)\n rand = UP;\n }\n } else if (/*dirs.contains(bodyDir) && */(r > 0 && c > 0 && r < board.length - 1 && c < board[0].length - 1))\n rand = bodyDir; //make it so aircraft prefer to keep going the same direciton\n\n } else if (name.startsWith(\"TRAIN\")) {//make it so trains prefer to follow the right wall\n for (int j = 0; j < dirs.size(); j++)\n if (dirs.get(j) != bodyDir) {\n rand = dirs.get(j);\n break;\n }\n }\n curr.setDirection(rand);\n curr.setBodyDirection(rand);\n }\n }//***end aircraft/train movement\n if (leftMost == 1) //move vehicles down and start them moving right\n {\n if (EI_moving == LEFT) {\n EI_moving = DOWN;\n for (int i = FIRST_VEHICLE; i < players.length; i++) {\n Player curr = players[i];\n if (curr == null || curr.getName().equals(\"NONE\"))\n continue;\n if (lowest < board.length - 3 && !curr.isFlying() && !curr.getName().startsWith(\"TRAIN\"))\n curr.setRow(curr.getRow() + 1);\n }\n } else if (EI_moving == DOWN) {\n EI_moving = RIGHT;\n for (int i = FIRST_VEHICLE; i < players.length; i++) {\n Player curr = players[i];\n if (curr == null || curr.getName().equals(\"NONE\"))\n continue;\n if (!curr.isFlying() && !curr.getName().startsWith(\"TRAIN\")) {\n curr.setDirection(RIGHT);\n curr.setBodyDirection(RIGHT);\n }\n }\n } else if (EI_moving == RIGHT)\n for (int i = FIRST_VEHICLE; i < players.length; i++) {\n Player curr = players[i];\n if (curr == null || curr.getName().equals(\"NONE\"))\n continue;\n if (!curr.isFlying() && !curr.getName().startsWith(\"TRAIN\"))\n curr.setDirection(RIGHT);\n }\n }//***end leftmost is first col\n else if (rightMost == board[0].length - 2) //move vehicles down and start them moving left\n {\n if (EI_moving == RIGHT) {\n EI_moving = DOWN;\n for (int i = FIRST_VEHICLE; i < players.length; i++) {\n Player curr = players[i];\n if (curr == null || curr.getName().equals(\"NONE\"))\n continue;\n if (lowest < board.length - 3 && !curr.isFlying() && !curr.getName().startsWith(\"TRAIN\"))\n curr.setRow(curr.getRow() + 1);\n }\n } else if (EI_moving == DOWN) {\n EI_moving = LEFT;\n for (int i = FIRST_VEHICLE; i < players.length; i++) {\n Player curr = players[i];\n if (curr == null || curr.getName().equals(\"NONE\"))\n continue;\n if (!curr.isFlying() && !curr.getName().startsWith(\"TRAIN\")) {\n curr.setDirection(LEFT);\n curr.setBodyDirection(LEFT);\n }\n }\n } else if (EI_moving == LEFT)\n for (int i = FIRST_VEHICLE; i < players.length; i++) {\n Player curr = players[i];\n if (curr == null || curr.getName().equals(\"NONE\"))\n continue;\n\n if (!curr.isFlying() && !curr.getName().startsWith(\"TRAIN\"))\n curr.setDirection(LEFT);\n }\n }//***end rightmost is last col\n else if (EI_moving == LEFT)\n for (int i = FIRST_VEHICLE; i < players.length; i++) {\n Player curr = players[i];\n if (curr == null || curr.getName().equals(\"NONE\"))\n continue;\n if (!curr.isFlying() && !curr.getName().startsWith(\"TRAIN\"))\n curr.setDirection(LEFT);\n }\n else if (EI_moving == RIGHT)\n for (int i = FIRST_VEHICLE; i < players.length; i++) {\n Player curr = players[i];\n if (curr == null || curr.getName().equals(\"NONE\"))\n continue;\n if (!curr.isFlying() && !curr.getName().startsWith(\"TRAIN\"))\n curr.setDirection(RIGHT);\n }\n return;\n }//***end EARTH INVADERS enemy movements\n for (int i = 2; i < players.length; i++) {\n Player curr = players[i];\n if (curr == null || curr.getName().equals(\"NONE\"))\n continue;\n String name = curr.getName();\n int r = curr.getRow();\n int c = curr.getCol();\n if (r > 0 && c > 0 && r < board.length - 1 && c < board[0].length - 1 && (curr instanceof Vehicle))\n ((Vehicle) (curr)).setOnField(true);\n\n if (curr.isFlying() && webs[panel].size() > 0) {\n int x = curr.findX(cellSize);\n int y = curr.findY(cellSize);\n for (int p = 0; p < webs[panel].size(); p++) {\n int[] ray = webs[panel].get(p);\n if (Utilities.isPointOnRay(x, y, ray[0], ray[1], ray[2], ray[3])) {\n explosions.add(new Explosion(\"BIG\", x, y, explosionImages, animation_delay));\n Ordinance.radiusDamage(-1, x, y, 25, panel, .5);\n Spawner.resetEnemy(i);\n webs[panel].remove(p);\n p--;\n Structure str1 = structures[ray[4]][ray[5]][panel];\n Structure str2 = structures[ray[6]][ray[7]][panel];\n if (str1 != null)\n str1.setWebValue(0);\n if (str2 != null)\n str2.setWebValue(0);\n Utilities.updateKillStats(curr);\n break;\n }\n }\n }\n //reset any ground vehicle that ended up in the water\n //reset any train not on tracks - we need this because a player might change panels as a vehicle spawns\n if (name.startsWith(\"TRAIN\")) {\n Structure str = structures[r][c][panel];\n if (str != null && str.getName().equals(\"hole\") && str.getHealth() != 0) {\n explosions.add(new Explosion(\"BIG\", curr.getX() - (cellSize / 2), curr.getY() - (cellSize / 2), puffImages, animation_delay));\n Utilities.updateKillStats(curr);\n Spawner.resetEnemy(i);\n continue;\n } else if (board[r][c][panel].startsWith(\"~\")) {\n explosions.add(new Explosion(\"BIG\", curr.getX() - (cellSize / 2), curr.getY() - (cellSize / 2), puffImages, animation_delay));\n Spawner.resetEnemy(i);\n continue;\n } else if (!board[r][c][panel].startsWith(\"T\")) {\n explosions.add(new Explosion(\"SMALL\", curr.getX() - (cellSize / 2), curr.getY() - (cellSize / 2), puffImages, animation_delay));\n Spawner.resetEnemy(i);\n continue;\n }\n } else //ground vehicles\n if (!curr.isFlying() && !curr.getName().startsWith(\"BOAT\") && (curr instanceof Vehicle)) {\n\n if (((Vehicle) (curr)).getStunTime() > numFrames) //ground unit might be stunned by WoeMantis shriek\n continue;\n if (board[r][c][panel].startsWith(\"~\")) {\n explosions.add(new Explosion(\"SMALL\", curr.getX() - (cellSize / 2), curr.getY() - (cellSize / 2), puffImages, animation_delay));\n Spawner.resetEnemy(i);\n continue;\n }\n } else //reset any water vehicle that ended up on land\n if (name.startsWith(\"BOAT\")) {\n if (!board[r][c][panel].startsWith(\"~\")) {\n explosions.add(new Explosion(\"SMALL\", curr.getX() - (cellSize / 2), curr.getY() - (cellSize / 2), puffImages, animation_delay));\n Spawner.resetEnemy(i);\n continue;\n }\n } else if (curr.getHealth() <= 0) {\n Spawner.resetEnemy(i);\n continue;\n }\n\n //if a ground unit has been on the playable field and leaves it, respawn them\n if (!curr.isFlying() && !name.startsWith(\"TRAIN\") && (curr instanceof Vehicle)) {\n if ((r == 0 || c == 0 || r == board.length - 1 || c == board[0].length - 1) && ((Vehicle) (curr)).getOnField()) {\n ((Vehicle) (curr)).setOnField(false);\n Spawner.resetEnemy(i);\n continue;\n }\n }\n if (name.endsWith(\"nukebomber\")) {//for the nukebomber, set the detonation coordinates so nuke fires when the plane exits the field\n int dr = curr.getDetRow();\n int dc = curr.getDetCol();\n int bd = curr.getBodyDirection();\n int dd = curr.getDetDir();\n if (bd == dd && (((bd == LEFT || bd == RIGHT) && c == dc) || (bd == UP || bd == DOWN) && r == dr)) {\n Ordinance.nuke();\n curr.setDetRow(-1);\n curr.setDetCol(-1);\n }\n }\n\n if (curr.isMoving())\n continue;\n int bodyDir = curr.getBodyDirection();\n curr.clearDirections();\n int[] target = isMonsterInSight(curr);\n int mDir = target[0]; //direction of the monster, -1 if none\n int monsterIndex = target[1]; //index of the monster in the players array, -1 if none\n ArrayList<Integer> dirs = new ArrayList(); //array of preferred directions - everything but the reverse of their body position\n if (bodyDir == UP) {\n if (isValidMove(curr, r - 1, c)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == UP) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(UP);\n }\n if (isValidMove(curr, r, c + 1)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == RIGHT) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(RIGHT);\n }\n if (!name.startsWith(\"TRAIN\")) //trains need to follow the track circuit - only straight and right turns\n {\n if (isValidMove(curr, r, c - 1)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == LEFT) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(LEFT);\n }\n }\n } else if (bodyDir == RIGHT) {\n if (!name.startsWith(\"TRAIN\")) //trains need to follow the track circuit - only straight and right turns\n {\n if (isValidMove(curr, r - 1, c)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == UP) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(UP);\n }\n }\n if (isValidMove(curr, r, c + 1)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == RIGHT) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(RIGHT);\n }\n if (isValidMove(curr, r + 1, c)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == DOWN) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(DOWN);\n }\n } else if (bodyDir == DOWN) {\n if (isValidMove(curr, r + 1, c)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == DOWN) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(DOWN);\n }\n if (!name.startsWith(\"TRAIN\")) //trains need to follow the track circuit - only straight and right turns\n {\n if (isValidMove(curr, r, c + 1)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == RIGHT) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(RIGHT);\n }\n }\n if (isValidMove(curr, r, c - 1)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == LEFT) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(LEFT);\n }\n } else //if(curr.getBodyDirection()==LEFT)\n {\n\n if (isValidMove(curr, r - 1, c)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == UP) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(UP);\n }\n if (!name.startsWith(\"TRAIN\")) //trains need to follow the track circuit - only straight and right turns\n {\n if (isValidMove(curr, r + 1, c)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == DOWN) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(DOWN);\n }\n }\n if (isValidMove(curr, r, c - 1)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == LEFT) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(LEFT);\n }\n }\n\n if (dirs.size() > 0) {\n if (curr instanceof Monster) {//***MONSTER AI*******************\n double headTurnProb = 0.25;\n double stompProb = 0.5;\n int vDir = isVehicleInSight(curr);\n if (vDir >= 0) {\n boolean airShot = false;\n int vD = vDir;\n if (vD >= 10) {\n airShot = true;\n vD -= 10;\n }\n if (curr.head360() || !Utilities.oppositeDirections(vD, curr.getHeadDirection())) {\n curr.setHeadDirection(vD);\n if ((curr.getName().startsWith(\"Gob\") || curr.getName().startsWith(\"Boo\")) && numFrames >= curr.getLastShotTime() + curr.getReloadTime()) {\n Bullet temp = null;\n if (curr.getName().startsWith(\"Boo\")) {\n temp = new Bullet(curr.getName() + vD, curr.getX(), curr.getY(), 50, beamImages, SPEED, \"BEAM\", SPEED * 10, airShot, i, -1, -1);\n } else if (curr.getName().startsWith(\"Gob\")) {\n temp = new Bullet(\"flame\" + vD, curr.getX(), curr.getY(), 15, monsterFireImages, SPEED, \"FIRE\", SPEED * 4, airShot, i, -1, -1);\n }\n if (temp != null) {\n temp.setDirection(vD);\n bullets.add(temp);\n curr.setLastShotTime(numFrames);\n continue;\n }\n }\n }\n } else if (Math.random() < headTurnProb) {\n String hd = \"right\";\n if (Math.random() < .5)\n hd = \"left\";\n Utilities.turnHead(curr, hd);\n }\n Structure str = structures[r][c][panel];\n if (str != null && str.getHealth() > 0 && str.isDestroyable() && !str.getName().startsWith(\"FUEL\") && Math.random() < stompProb)\n playerMove(KeyEvent.VK_SPACE, i);\n else {\n int dir = dirs.get((int) (Math.random() * dirs.size()));\n if (dir == UP) {\n if (curr.getBodyDirection() != UP) {\n curr.setBodyDirection(UP);\n curr.setHeadDirection(UP);\n } else {\n if (!curr.isSwimmer() && board[r - 1][c][panel].equals(\"~~~\") && !board[r][c][panel].equals(\"~~~\")) {\n continue;\n }\n if (r - 1 >= 1) {\n str = structures[r - 1][c][panel]; //don't walk into a fire\n if (str != null && str.onFire())\n continue;\n }\n playerMove(KeyEvent.VK_UP, i);\n }\n } else if (dir == DOWN) {\n if (curr.getBodyDirection() != DOWN) {\n curr.setBodyDirection(DOWN);\n curr.setHeadDirection(DOWN);\n } else {\n if (!curr.isSwimmer() && board[r + 1][c][panel].equals(\"~~~\") && !board[r][c][panel].equals(\"~~~\")) {\n continue;\n }\n if (r + 1 <= structures.length - 1) {\n str = structures[r + 1][c][panel]; //don't walk into a fire\n if (str != null && str.onFire())\n continue;\n }\n playerMove(KeyEvent.VK_DOWN, i);\n }\n } else if (dir == LEFT) {\n if (curr.getBodyDirection() != LEFT) {\n curr.setBodyDirection(LEFT);\n curr.setHeadDirection(LEFT);\n } else {\n if (!curr.isSwimmer() && board[r][c - 1][panel].equals(\"~~~\") && !board[r][c][panel].equals(\"~~~\")) {\n continue;\n }\n if (c - 1 >= 1) {\n str = structures[r][c - 1][panel]; //don't walk into a fire\n if (str != null && str.onFire())\n continue;\n }\n playerMove(KeyEvent.VK_LEFT, i);\n }\n } else if (dir == RIGHT) {\n if (curr.getBodyDirection() != RIGHT) {\n curr.setBodyDirection(RIGHT);\n curr.setHeadDirection(RIGHT);\n } else {\n if (!curr.isSwimmer() && board[r][c + 1][panel].equals(\"~~~\") && !board[r][c][panel].equals(\"~~~\")) {\n continue;\n }\n if (c + 1 <= board[0].length - 1) {\n str = structures[r][c + 1][panel]; //don't walk into a fire\n if (str != null && str.onFire())\n continue;\n }\n playerMove(KeyEvent.VK_RIGHT, i);\n }\n }\n }\n continue;\n }//end monster AI movement\n else //shoot at a target\n if (name.endsWith(\"troops\") || name.endsWith(\"jeep\") || name.endsWith(\"police\") || name.startsWith(\"TANK\") || name.endsWith(\"coastguard\") || name.endsWith(\"destroyer\") || name.endsWith(\"fighter\") || name.equals(\"AIR bomber\")) {\n boolean airShot = false;\n if (gameMode == EARTH_INVADERS) //we don't want vehicles to shoot each other\n {\n airShot = true;\n curr.setHeadDirection(DOWN);\n }\n if (monsterIndex >= 0 && monsterIndex < players.length && players[monsterIndex].isFlying())\n airShot = true;\n if (curr.getName().endsWith(\"fighter\"))\n curr.setDirection(bodyDir); //keep moving while shooting\n if (mDir != -1 && curr.getRow() > 0 && curr.getCol() > 0 && curr.getRow() < board.length - 1 && curr.getCol() < board[0].length - 1) { //don't shoot from off the visible board\n if ((mDir == bodyDir || ((curr.getName().startsWith(\"TANK\") || curr.getName().endsWith(\"jeep\") || name.equals(\"AIR bomber\")) && (mDir == curr.getHeadDirection() || name.equals(\"AIR bomber\")))) && numFrames >= curr.getLastShotTime() + curr.getReloadTime()) { //AIR bomber needs to be able to drop bombs if they see the monster in front of them or behind them, so we need to check the name in two conditions\n Bullet temp;\n if (name.endsWith(\"jeep\") || name.endsWith(\"coastguard\")) {\n channels[0].programChange(instr[GUNSHOT].getPatch().getProgram());\n channels[0].noteOn((int) (Math.random() * 6) + 65, (int) (Math.random() * 10) + 30);\n temp = new Bullet(\"jeep\" + mDir, curr.getX(), curr.getY(), 5, machBulletImages, SPEED, \"BULLET\", SPEED * 6, airShot, i, -1, -1);\n } else if (name.endsWith(\"troops\") || name.endsWith(\"police\")) {\n channels[0].programChange(instr[GUNSHOT].getPatch().getProgram());\n channels[0].noteOn((int) (Math.random() * 6) + 70, (int) (Math.random() * 10) + 20);\n temp = new Bullet(\"troops\" + mDir, curr.getX(), curr.getY(), 3, bulletImages, SPEED, \"BULLET\", SPEED * 6, airShot, i, -1, -1);\n } else if (name.endsWith(\"destroyer\") || name.endsWith(\"artillery\")) {\n channels[0].programChange(instr[GUNSHOT].getPatch().getProgram());\n channels[0].noteOn((int) (Math.random() * 6) + 45, (int) (Math.random() * 10) + 85);\n temp = new Bullet(\"destroyer\" + mDir, curr.getX(), curr.getY(), 15, shellImages, SPEED, \"SHELL\", SPEED * 3, true, i, players[monsterIndex].findX(cellSize), players[monsterIndex].findY(cellSize));\n } else if (name.endsWith(\"fighter\")) {\n channels[0].programChange(instr[TAIKO].getPatch().getProgram());\n channels[0].noteOn((int) (Math.random() * 10) + 5, (int) (Math.random() * 10) + 40);\n temp = new Bullet(\"fighter\" + mDir, curr.getX(), curr.getY(), 30, rocketImages, SPEED, \"SHELL\", SPEED * 8, true, i, players[monsterIndex].findX(cellSize), players[monsterIndex].findY(cellSize));\n } else if (name.endsWith(\"missile\")) {\n temp = new Bullet(\"missile\" + mDir, curr.getX(), curr.getY(), 50, rocketImages, SPEED, \"SHELL\", SPEED * 3, true, i, players[monsterIndex].findX(cellSize), players[monsterIndex].findY(cellSize));\n channels[0].programChange(instr[TAIKO].getPatch().getProgram());\n channels[0].noteOn((int) (Math.random() * 10) + 5, (int) (Math.random() * 10) + 40);\n } else if (name.endsWith(\"flame\")) {\n temp = new Bullet(\"flame\" + mDir, curr.getX(), curr.getY(), 15, monsterFireImages, SPEED, \"FIRE\", SPEED * 4, airShot, i, -1, -1);\n channels[0].programChange(instr[TAIKO].getPatch().getProgram());\n channels[0].noteOn((int) (Math.random() * 10) + 5, (int) (Math.random() * 10) + 40);\n } else if (name.equals(\"AIR bomber\")) {\n temp = null;\n if (!DISABLE_BOMBERS) {\n int mR = players[PLAYER1].getRow(); //main player row & col\n int mC = players[PLAYER1].getCol();\n int mR2 = -99; //possible 2nd monster row & col\n int mC2 = -99;\n if (p1partner) {\n mR2 = players[PLAYER2].getRow();\n mC2 = players[PLAYER2].getCol();\n }\n if (players[PLAYER1].getHealth() > 0 && (Math.abs(r - mR) <= 2 || Math.abs(c - mC) <= 2 || Math.abs(r - mR2) <= 2 || Math.abs(c - mC2) <= 2)) {//our bomber is in the same row & col as a monster + or - 1\n if (bodyDir == UP && r < board.length - 1) {\n Ordinance.bigExplosion(curr.getX(), curr.getY() + (cellSize * 2), panel);\n Ordinance.radiusDamage(-1, curr.getX(), curr.getY() + (cellSize * 2), 50, panel, .25);\n } else if (bodyDir == DOWN && r > 1) {\n Ordinance.bigExplosion(curr.getX(), curr.getY() - (cellSize * 2), panel);\n Ordinance.radiusDamage(-1, curr.getX(), curr.getY() - (cellSize * 2), 50, panel, .25);\n } else if (bodyDir == RIGHT && c < board[0].length - 1) {\n Ordinance.bigExplosion(curr.getX() - (cellSize * 2), curr.getY(), panel);\n Ordinance.radiusDamage(-1, curr.getX() - (cellSize * 2), curr.getY(), 50, panel, .25);\n } else if (bodyDir == LEFT && c > 1) {\n Ordinance.bigExplosion(curr.getX() + (cellSize * 2), curr.getY(), panel);\n Ordinance.radiusDamage(-1, curr.getX() + (cellSize * 2), curr.getY(), 50, panel, .25);\n }\n }\n }\n } else {\n channels[0].programChange(instr[GUNSHOT].getPatch().getProgram());\n channels[0].noteOn((int) (Math.random() * 6) + 45, (int) (Math.random() * 10) + 85);\n temp = new Bullet(\"\" + mDir, curr.getX(), curr.getY(), 15, shellImages, SPEED, \"SHELL\", SPEED * 5, airShot, i, -1, -1);\n }\n if (temp != null)\n temp.setDirection(mDir);\n\n if (name.endsWith(\"troops\") || name.endsWith(\"police\") && Math.random() < .5) //make the police move towards the monster half the time\n {\n if (mDir == UP && isValidMove(curr, curr.getRow() - 1, curr.getCol()))\n curr.setDirection(UP);\n else if (mDir == DOWN && isValidMove(curr, curr.getRow() + 1, curr.getCol()))\n curr.setDirection(DOWN);\n else if (mDir == LEFT && isValidMove(curr, curr.getRow(), curr.getCol() - 1))\n curr.setDirection(LEFT);\n else if (mDir == RIGHT && isValidMove(curr, curr.getRow(), curr.getCol() + 1))\n curr.setDirection(RIGHT);\n else\n curr.setDirection(-1);\n }\n if (temp != null && players[PLAYER1].getHealth() > 0) {\n if (gameMode == EARTH_INVADERS && !curr.isFlying()) {\n } else {\n if (numFrames >= ceaseFireTime + ceaseFireDuration || gameMode == EARTH_INVADERS) {\n bullets.add(temp);\n curr.setLastShotTime(numFrames);\n continue;\n }\n }\n }\n } else //change to face the monster to line up a shot\n {\n if (name.endsWith(\"troops\") || name.endsWith(\"police\") || name.endsWith(\"destroyer\") || name.endsWith(\"coastguard\") || name.endsWith(\"artillery\")) {\n curr.setDirection(-1); //stop to shoot\n curr.setBodyDirection(mDir);\n } else if (curr.getName().startsWith(\"TANK\") || curr.getName().endsWith(\"jeep\"))\n curr.setHeadDirection(mDir);\n continue;\n }\n }\n }\n int rand = dirs.get((int) (Math.random() * dirs.size()));\n if (curr.isFlying() && (r > 0 && c > 0 && r < board.length - 1 && c < board[0].length - 1)) {\n rand = bodyDir; //make it so aircraft prefer to keep going the same direciton\n } else if (name.startsWith(\"TRAIN\")) {//make it so trains prefer to follow the right wall\n for (int j = 0; j < dirs.size(); j++)\n if (dirs.get(j) != bodyDir) {\n rand = dirs.get(j);\n break;\n }\n }\n curr.setDirection(rand);\n curr.setBodyDirection(rand);\n\n continue;\n }\n //if no preferred direction, include the option to turn around\n //civilians should prefer to turn around rather than approach the monster\n if (name.endsWith(\"civilian\") || name.endsWith(\"bus\")) {\n if (bodyDir == mDir) //if we are facing the same direction as the monster, turn around\n {\n if (bodyDir == UP && isValidMove(curr, curr.getRow() + 1, curr.getCol())) {\n curr.setDirection(DOWN);\n curr.setBodyDirection(DOWN);\n continue;\n } else if (bodyDir == DOWN && isValidMove(curr, curr.getRow() - 1, curr.getCol())) {\n curr.setDirection(UP);\n curr.setBodyDirection(UP);\n continue;\n } else if (bodyDir == LEFT && isValidMove(curr, curr.getRow(), curr.getCol() + 1)) {\n curr.setDirection(RIGHT);\n curr.setBodyDirection(RIGHT);\n continue;\n } else if (bodyDir == RIGHT && isValidMove(curr, curr.getRow(), curr.getCol() - 1)) {\n curr.setDirection(LEFT);\n curr.setBodyDirection(LEFT);\n continue;\n }\n }\n }\n int rand = (int) (Math.random() * 4);\n if (rand == UP && isValidMove(curr, curr.getRow() - 1, curr.getCol())) {\n curr.setDirection(UP);\n curr.setBodyDirection(UP);\n continue;\n }\n if (rand == DOWN && isValidMove(curr, curr.getRow() + 1, curr.getCol())) {\n curr.setDirection(DOWN);\n curr.setBodyDirection(DOWN);\n continue;\n }\n if (rand == LEFT && isValidMove(curr, curr.getRow(), curr.getCol() - 1)) {\n curr.setDirection(LEFT);\n curr.setBodyDirection(LEFT);\n continue;\n }\n if (rand == RIGHT && isValidMove(curr, curr.getRow(), curr.getCol() + 1)) {\n curr.setDirection(RIGHT);\n curr.setBodyDirection(RIGHT);\n continue;\n }\n\n }\n }", "public void act(){\n // Removing object, if out of the simulated zone\n if (atWorldEdge()){\n getWorld().removeObject(this);\n return;\n }\n\n //Move Thanos up\n setLocation (getX(), getY() - speed);\n }", "private void removeRobot(Actor r) {\n\t\tfor (int i = 0; i < attackRobots.size(); i++) {\n\t\t\tif (attackRobots.get(i).equals(r)) {\n\t\t\t\tattackRobots.remove(i);\n\t\t\t\tcheckLost();\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < supportRobots.size(); i++) {\n\t\t\tif (supportRobots.get(i).equals(r))\n\t\t\t\tsupportRobots.remove(i);\n\t\t}\n\t}", "private void modifyIndividuals(){\n for(AbstractBehaviour behaviour: entityBehaviours){\n JSONObject jsonPop = null;\n GeneticInterface gi = interfaceMap.get(behaviour);\n try {\n jsonPop = gi.receiveNewPopulation();\n } catch (IOException e) {\n e.printStackTrace();\n }\n for(String key: jsonPop.keySet()){\n JSONArray funArray = jsonPop.getJSONObject(key).getJSONArray(\"functions\");\n List<Function> functions = new LinkedList<>();\n for(int a = 0; a <funArray.length(); a++){\n String tree = funArray.getString(a);\n Function functionTree = Node.treeFromString(tree, behaviour.getNumberOfInputs());\n functions.add(functionTree);\n }\n behaviour.setEntityByName(key, functions);\n }\n behaviour.resetEntities();\n }\n }", "public void act() \r\n {\r\n Controller world = (Controller) getWorld();\r\n player = world.getPlayer();\r\n if (this.isTouching(Player.class))\r\n {\r\n player.minusHealth(5);\r\n world.removeObject(this);\r\n }\r\n }", "private void penguinStormReaction(){\n if(obstacle.getUserData().getAssetId().equals(OBSTACLE_CLOUD_ASSETS_ID)){\n if(penguin.isFrightStopped()){\n obstacle.setStormRaining(false);\n }else{\n obstacle.setStormRaining(true);\n }\n }\n }", "public void act() \n {\n moveAround(); \n addBomb(); \n touchGhost(); \n }", "public void popEnemies() {\n\t\t\n\t\tEnemyList.add(orc);\n\t\tEnemyList.add(goblin);\n\t\tEnemyList.add(necromancer);\n\t\tEnemyList.add(troll);\n\t\tEnemyList.add(minotaur);\n\t\tEnemyList.add(hydra);\n\t\tEnemyList.add(zombie);\n\t\tEnemyList.add(thrall);\n\t\tEnemyList.add(demon);\n\t\tEnemyList.add(witch);\n\t\tEnemyList.add(boss);\n\t}", "public void foodLocated() {\n ArrayList<Creature> creatures = world.getCreatureList();\n for (Creature c : creatures) {\n if (c.creatureLocation().equals(predatorLocation())) {\n //System.out.println(\"Eating Creature: \" + c.creatureLocation());\n c.removed();\n eaten++;\n }\n }\n for (int j = 0; j < world.getCreatureList().size(); j++) {\n if (!world.getCreatureList().get(j).isSpawned()) {\n world.despawnCreature(world.getCreatureList().get(j));\n }\n }\n }", "public static void mutate(Chromosome chrome) {\n \n // Loop through tour cities\n for(int rosterNursePos1=0; rosterNursePos1 < chrome.ChromosomeRowSize(); rosterNursePos1++){\n for (int rosterDayPos1=0; rosterDayPos1<chrome.chromosomeColumnCount();rosterDayPos1++){\n if(RosterManager.isPreviousShift(chrome.getShift(rosterNursePos1, rosterDayPos1))==false || RosterManager.isNextShift(chrome.getShift(rosterNursePos1, rosterDayPos1))==false || chrome.getShift(rosterNursePos1, rosterDayPos1).getHours()!=0 ){\n if(Math.random() < mutationRate){\n // Get a second random position in the tour\n int rosterNursePos2= rosterNursePos1;\n int rosterDayPos2 = returnValidPos(rosterNursePos2, randomizeShiftGeneration(chrome), chrome );\n\n // Get the cities at target position in tour\n Gene gene1 = chrome.retrieveGene(rosterNursePos1, rosterDayPos1);\n Gene gene2 = chrome.retrieveGene(rosterNursePos2, rosterDayPos2);\n\n // Swap them around\n chrome.saveGene(rosterNursePos1, rosterDayPos1, gene2);\n chrome.saveGene(rosterNursePos2, rosterDayPos2, gene1);\n \n }\n \n \n } \n // Apply mutation rate\n \n }\n \n }\n \n \n }", "private void UpdateRockets()\n\t {\n\t for(int i = 0; i < RocketList.size(); i++)\n\t {\n\t Rocket rocket = RocketList.get(i);\n\t \n\t // Moves the rocket.\n\t rocket.Update();\n\t \n\t // Checks if it the rocket has left the screen.\n\t if(rocket.HasLeftScreen())\n\t {\n\t RocketList.remove(i);\n\t \n\t }\n\t \n\t // Checks if current rocket hit any enemy.\n\t if( HasRocketHitEnemy(rocket) )\n\t // Removes the rocket\n\t RocketList.remove(i);\n\t }\n\t }", "public static void shootCritters(){\n\t\tfor(Tower t : towers) \n\t\t\tt.shootCritters(CritterManager.getCritters());\n\t}", "public synchronized void removeTheWarrior(){\n charactersOccupiedTheLocation[0]=null;\n notifyAll();\n }", "public void handleItemMovements() {\n\t\tfor (MovingItem item : currentScene.getMovingItems()) {\n\t\t\tmoveItemX(item);\n\t\t\tmoveItemY(item);\n\t\t\tif (nextScene != null) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\titem.simulateGravity();\n\n\t\t\tif (item.getTranslateXProperty().get() < 0 || item.getTranslateYProperty().get() > currentScene.getHeight() || item.getTranslateYProperty().get() < 0 || item.getTranslateXProperty().get() > currentScene.getWidth()) {\n\t\t\t\titemsToDelete.add(item);\n\t\t\t}\n\t\t\tif (item instanceof Projectile) {\n\t\t\t\tif (((Projectile) item).traveledFullDistance()) itemsToDelete.add(item);\n\t\t\t}\n\t\t\tif (item instanceof Enemy) {\n\t\t\t\tif (((Enemy) item).shouldJump() && item.canJump()) {\n\t\t\t\t\titem.jump();\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (item instanceof ProjectileHurler) {\n\t\t\t\tProjectileHurler hurler = (ProjectileHurler) item;\n\t\t\t\tif (hurler.canFire()) {\n\t\t\t\t\titemsToAdd.add(hurler.fire());\n\t\t\t\t\thurler.resetProjectileCooldown();\n\t\t\t\t} else\n\t\t\t\t\thurler.decrementProjectileCooldownTimer();\n\t\t\t}\n\t\t}\n\t\titemsToDelete.forEach(item -> currentScene.removeItem(item));\n\t\titemsToDelete.clear();\n\t\titemsToAdd.forEach(item -> currentScene.addItem(item));\n\t\titemsToAdd.clear();\n\t\tif (nextScene != null) setCurrentScene();\n\t}", "public void attack() {\n if (st instanceof RedAlienState.Attacking) {\n \tRedAlienState.Attacking att = (RedAlienState.Attacking)st;\n \ttry{\n \t\tDelta d = att.path.remove();\n \t\tthis.x += d.xd;\n \t\tthis.y += d.yd;\n \t\tif(Math.random() > .99){\n \t\t\tthis.fire();\n \t\t}\n \t}catch(NoSuchElementException e){\n \t\tthis.x = this.column;\n \t\tthis.y = this.row;\n \t\tst = new RedAlienState.Normal();\n \t\tthis.isAttacking = false;\n \t}\n }\n }", "private void cellPredatorRules() {\r\n\t\tif (this.energy <= 0) { // Issue with energy\r\n\t\t\tthis.setNextState(new WaTorState(WaTorState.EMPTY_STATE));\r\n\t\t\tthis.setNextBlock(this.getBlock());\r\n\t\t\tthis.getBlock().setNextCell(this);\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis.energy--;\r\n\t\tint food = this.getBlock().getAdjacent(prey, \"2457\").size();\r\n\t\tif (food > 0) {\r\n\t\t\tif (!incrementAge(new WaTorState(WaTorState.WATOR_PREDATOR))) {\r\n\t\t\t\teat();\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tcellPreyRules(new WaTorState(WaTorState.WATOR_PREDATOR));\r\n\t\t}\r\n\t}", "private void removeOtherPointActors(PointActor pointActor) {\n for (int i = 0; i < pointActors.size(); i++) {\n if (!pointActors.get(i).equals(pointActor)) {\n pointActors.get(i).remove();\n }\n }\n }", "public void removeEffectFromSpecialBrick(){\r\n\t\t\t// return everything to the original\r\n\t\t\tColor origColor = (specialBrickId.equals(\"Rect0\"))? discsColors[0]:(specialBrickId.equals(\"Rect1\"))? discsColors[1]:\r\n\t\t\t\t\t\t (specialBrickId.equals(\"Rect2\"))? discsColors[2]:(specialBrickId.equals(\"Rect3\"))? discsColors[3]:\r\n\t\t\t\t\t\t (specialBrickId.equals(\"Rect4\"))? discsColors[4]:(specialBrickId.equals(\"Rect5\"))? discsColors[5]:\r\n\t\t\t\t\t\t (specialBrickId.equals(\"Rect6\"))? discsColors[6]:(specialBrickId.equals(\"Rect7\"))? discsColors[7]:null; \r\n\t\t\tint origWidth = (specialBrickId.equals(\"Rect0\"))? 30:(specialBrickId.equals(\"Rect1\"))? 60:\r\n\t\t\t\t\t\t\t(specialBrickId.equals(\"Rect2\"))? 90:(specialBrickId.equals(\"Rect3\"))? 120:\r\n\t\t\t\t\t\t\t(specialBrickId.equals(\"Rect4\"))? 150:(specialBrickId.equals(\"Rect5\"))? 180:\r\n\t\t\t\t\t\t\t(specialBrickId.equals(\"Rect6\"))? 210:(specialBrickId.equals(\"Rect7\"))? 240:null;\r\n\t\t\tRectangle rect = new Rectangle(origWidth,20, origColor);\r\n\t\t\trect.setId(specialBrickId);\r\n\t\t\trect.setStroke(Color.BLACK);\r\n\t\t\trect.setStrokeWidth(3);\r\n\t\t\t\t\t\t\r\n\t\t\tswitch(specialBrickTower){\r\n\t\t\t\tcase \"firstTower\":\r\n\t\t\t\t\tfor(int i=0; i<firstTower.getChildren().size(); i++){ // cycle through the tower to check which one is the special brick\r\n\t\t\t\t\t\tif (firstTower.getChildren().get(i).getId().equals(specialBrickId)){\r\n\t\t\t\t\t\t\tfirstTower.getChildren().set(i, rect); // then reset it\r\n\t\t\t\t\t}}\r\n\t\t\t\tbreak;\r\n\t\t\t\tcase \"secondTower\":\r\n\t\t\t\t\tfor(int i=0; i<secondTower.getChildren().size(); i++){\r\n\t\t\t\t\t\tif (secondTower.getChildren().get(i).getId().equals(specialBrickId)){\r\n\t\t\t\t\t\t\tsecondTower.getChildren().set(i, rect);\r\n\t\t\t\t\t}}\r\n\t\t\t\tbreak;\r\n\t\t\t\tcase \"thirdTower\":\r\n\t\t\t\t\tfor(int i=0; i<thirdTower.getChildren().size(); i++){\r\n\t\t\t\t\t\tif (thirdTower.getChildren().get(i).getId().equals(specialBrickId)){\r\n\t\t\t\t\t\t\tthirdTower.getChildren().set(i, rect);\r\n\t\t\t\t\t}}\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\trect.widthProperty().bind(scene.widthProperty().divide(3).subtract(250-origWidth));\r\n\t\t\trect.heightProperty().bind(scene.heightProperty().divide(19));\r\n\t\t\r\n\t\tif(countDownRunning){towersRegion.getChildren().remove(2);countDownRunning=false;} // remove the count down watch from the screen\t\t\r\n\t\tspecialBrickId=null; // reset the special brick id\r\n\t}", "@Override\r\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tif(!chesses.isEmpty()) {\r\n\t\t\t\t\tChess to_remove = chesses.getLast();\r\n\t\t\t\t\tPoint to_delete = to_remove.getCor();\r\n\t\t\t\t\tisChess[to_delete.x][to_delete.y] = 0;\r\n\t\t\t\t\tchesses.remove(chesses.size() - 1);\r\n\t\t\t\t\tturn = 1 - turn;\t\r\n\t\t\t\t\trepaint();\r\n\t\t\t\t}\r\n\t\t\t}", "protected final void walk(int direction) {\r\n \t//deduct this from the critter's energy\r\n \tenergy = energy - Params.WALK_ENERGY_COST;\r\n \t\r\n \tif(hasMoved == false) {\r\n \t\tif((isFight == false || (isFight == true && unoccupiedPosition(direction, 1) == true)) && energy > 1) {\r\n \t\t\t//get new critter position\r\n \t\t\tint[] critterCoord = getCritterPos(direction, 1);\r\n \t\t\tx_coord = critterCoord[0];\r\n \t\t\ty_coord = critterCoord[1];\r\n \t\t\t\r\n \t\t\thasMoved = true;\r\n \t\t\tisFight = false;\r\n \t\t\r\n \t\t\tString critterPos = Integer.toString(x_coord) + \"_\" + Integer.toString(y_coord);\r\n \t\t\t\r\n \t\t\tArrayList<Critter> critterList = populationMoved.get(critterPos);\r\n \t\t\t\r\n \t\t\t//if there are critters already in this grid position\r\n \t\t\tif(!(critterList == null)) {\r\n \t\t\t\tcritterList.add(this);\r\n \t\t\t\tpopulationMoved.replace(critterPos, critterList);\r\n \t\t\t\t\r\n \t\t\t//if the critter moves into an empty space\t\r\n \t\t\t} else {\r\n \t\t\t\tArrayList<Critter> newList = new ArrayList<Critter>();\r\n \t\t\t\tnewList.add(this);\r\n \t\t\t\tpopulationMoved.put(critterPos, newList);\r\n \t\t\t}\r\n \t\t\t\r\n \t\t}\r\n \t}\r\n }" ]
[ "0.7473655", "0.6611561", "0.6427156", "0.6399431", "0.6374232", "0.62789786", "0.60613614", "0.58498925", "0.5815534", "0.57378334", "0.56567675", "0.56467956", "0.56410193", "0.5626609", "0.56131613", "0.5600553", "0.55952144", "0.5588814", "0.55855757", "0.5545129", "0.5544828", "0.5533279", "0.5524899", "0.55231977", "0.55074215", "0.5501531", "0.5495493", "0.5491916", "0.54861337", "0.5484037", "0.54832464", "0.54801446", "0.5449826", "0.5441915", "0.54307246", "0.5427459", "0.5425548", "0.54184896", "0.5403216", "0.54011536", "0.53938866", "0.53816545", "0.53768945", "0.5367551", "0.5359278", "0.53483397", "0.5343107", "0.53331554", "0.53284156", "0.53240615", "0.53222066", "0.5321825", "0.53061277", "0.5304668", "0.52989197", "0.529362", "0.5292651", "0.52915543", "0.5287717", "0.5286716", "0.52860504", "0.52818084", "0.5278188", "0.5272808", "0.5272239", "0.5270891", "0.52642196", "0.52628046", "0.5257777", "0.5255527", "0.52546835", "0.52489704", "0.52392036", "0.52312076", "0.5226372", "0.52238715", "0.52163196", "0.5212608", "0.5211834", "0.5202356", "0.51967597", "0.5193129", "0.5186355", "0.5184536", "0.5180039", "0.51792437", "0.51791763", "0.51750726", "0.51696795", "0.51651514", "0.51625305", "0.5158316", "0.515002", "0.51444757", "0.51399577", "0.51396996", "0.5129195", "0.5119262", "0.5109447", "0.5103459" ]
0.7558505
0
disable DNS cache, to enable neptune dns load balancing on ro instances
static Cluster clusterProvider(String neptune, int BATCH_SIZE) { java.security.Security.setProperty("networkaddress.cache.ttl", "0"); java.security.Security.setProperty("networkaddress.cache.negative.ttl", "0"); Cluster.Builder clusterBuilder = Cluster.build() .addContactPoint(neptune) // add more ro contact points for load balancing .port(8182) .enableSsl(true) // .keyStore(keyStore) // optional as amazon cert will be used and should be in truststore of server // .keyStorePassword(keyStorePassword) .channelizer(SigV4WebSocketChannelizer.class) .serializer(Serializers.GRAPHBINARY_V1D0) .maxInProcessPerConnection(1) // ensure no contention for connections per batch .minInProcessPerConnection(1) .maxSimultaneousUsagePerConnection(1) .minSimultaneousUsagePerConnection(1) .maxWaitForConnection(15000) .minConnectionPoolSize(BATCH_SIZE) .maxConnectionPoolSize(BATCH_SIZE); return clusterBuilder.create(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "AgentPolicyBuilder disableCache();", "AgentPolicyBuilder setBypassCache(boolean bypassCache);", "public void enableDnsSearch(boolean enable);", "public DBMaker disableCacheAutoClear(){\n this.autoClearRefCacheOnLowMem = false;\n return this;\n }", "public void disableHighAvailability() {\n enableHa = false;\n listMembersService.shutdown();\n }", "public void enableDnsSrv(boolean enable);", "public void stopAutomaticRefresh() {\n try {\n dnsService.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }", "boolean hasDnsCacheConfig();", "public void resetDecoyRouter() {\n this.hostsDecoyRouter = false;\n }", "public DBMaker enableHardCache() {\n cacheType = DBCacheRef.HARD;\n return this;\n }", "public void setNoCache() {\n noCache= true;\n }", "public static void noClientCache() {\n sBinderServiceCache = BinderCache.noCache();\n sInterfaceServiceCache = BinderCache.noCache();\n }", "AgentPolicyBuilder setClearCache(boolean clearCache);", "void disable()\n{\n synchronized (this) {\n is_enabled = false;\n request_queue.clear();\n for (DymonPatchRequest ar : active_requests) removeActive(ar);\n if (request_timer != null) request_timer.cancel();\n request_timer = null;\n }\n}", "public boolean dnsSrvEnabled();", "public boolean dnsSearchEnabled();", "public synchronized void blacklist( IpAddress address ) {\n blacklist( new IpNetwork( address, IpNetwork.HOSTMASK ) );\n }", "private static void disableConnectionReuseIfNecessary() {\n if (Integer.parseInt(Build.VERSION.SDK) < Build.VERSION_CODES.FROYO) {\n System.setProperty(\"http.keepAlive\", \"false\");\n }\n }", "private static void disableConnectionReuseIfNecessary() {\n if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {\n System.setProperty(\"http.keepAlive\", \"false\");\n }\n }", "public static CacheControlDirective noCache() {\n\t\treturn new CacheControlDirective().setNoCache(true);\n\t}", "public void disable() {\n for (int i = 0; i < listeners.size(); i++) {\n CacheManagerListener listener = (CacheManagerListener) \n listeners.get(i);\n listener.cacheManagerDisabled();\n }\n }", "protected void disableHTTPResponCache( HttpServletResponse response )\n {\n // see article http://onjava.com/pub/a/onjava/excerpt/jebp_3/index2.html\n // Set to expire far in the past.\n response.setHeader( HttpHeaderUtils.EXPIRES, HttpHeaderUtils.SAT_6_MAY_1995_12_00_00_GMT );\n // Set standard HTTP/1.1 no-cache headers.\n response.setHeader( HttpHeaderUtils.CACHE_CONTROL_HTTP_HEADER,\n HttpHeaderUtils.NO_STORE_NO_CACHE_MUST_REVALIDATE );\n // Set IE extended HTTP/1.1 no-cache headers (use addHeader).\n response.addHeader( HttpHeaderUtils.CACHE_CONTROL_HTTP_HEADER, HttpHeaderUtils.POST_CHECK_0_PRE_CHECK_0 );\n // Set standard HTTP/1.0 no-cache header.\n response.setHeader( HttpHeaderUtils.PRAGMA, HttpHeaderUtils.NO_CACHE );\n }", "private static void disableConnectionReuseIfNecessary() {\n\t if (Integer.parseInt(Build.VERSION.SDK) < Build.VERSION_CODES.FROYO) {\n\t System.setProperty(\"http.keepAlive\", \"false\");\n\t }\n\t}", "public void limpaCache()\n\t{\n\t\tpoolMensagens.clear();\n\t}", "public void disableDomainBasedUnfixing() { this.exec = this.exec.withProperty(\"sm.domainUnfix\", false); }", "@Override\n public boolean isCaching() {\n return false;\n }", "@Override\n\tprotected void onNetworkDisConnected() {\n\n\t}", "public void onDisable() {\n \n \t\tprintCon(\"Stopping auto flusher\");\n \t\tgetServer().getScheduler().cancelTask(runner);\n \t\tprintCon(\"Flushing cache to database\");\n \t\tPlayerStatManager.saveCache();\n \t\tprintCon(\"Cache flushed to database\");\n \n \t\tself = null;\n \t}", "public void disable();", "public void disableWarp() {\n warpEnabled = false;\n }", "void resetCache();", "public void stopDiscoverability() {\r\n this.findableServerThread.interrupt();\r\n }", "void disable();", "void disable();", "private void putPrivateDnsSettings(int mode, @Nullable String host) {\n mInjector.binderWithCleanCallingIdentity(() -> {\n ConnectivitySettingsManager.setPrivateDnsMode(mContext, mode);\n ConnectivitySettingsManager.setPrivateDnsHostname(mContext, host);\n });\n }", "com.google.container.v1.DnsCacheConfig getDnsCacheConfig();", "public boolean disassociateAddress(EC2DisassociateAddress request) {\n try {\n List<CloudStackIpAddress> cloudIps = getApi().listPublicIpAddresses(null, null, null, null, null, request.getPublicIp(), null, null, null);\n if (cloudIps == null)\n throw new Exception(\"Specified ipAddress doesn't exist\");\n CloudStackIpAddress cloudIp = cloudIps.get(0);\n\n CloudStackInfoResponse resp = getApi().disableStaticNat(cloudIp.getId());\n if (resp != null) {\n return resp.getSuccess();\n }\n } catch (Exception e) {\n logger.error(\"EC2 DisassociateAddress - \", e);\n handleException(e);\n }\n return false;\n }", "ServiceBindingOptions preventReloading();", "void resetCacheCounters();", "public void setMayUseCache (boolean useCache) {\n\tmayUseCache = mayUseCache && useCache;\n }", "public DBMaker enableWeakCache() {\n cacheType = DBCacheRef.WEAK;\n return this;\n }", "@Override\r\n\tpublic DNSSupport getDnsSupport() {\n\t\treturn null;\r\n\t}", "@Override\n\tpublic boolean remove(InetAddress address) {\n\t\tsynchronized (cache) {\n\t\t\tint key = address.hashCode();\n\t\t\tif (cache.containsKey(key)) {\n\t\t\t\tDoubleLinkedListNode nodeToDelete = cache.get(key);\n\t\t\t\tcache.remove(key);\n\t\t\t\tremoveNode(nodeToDelete);\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}", "public void disable()\r\n\t{\r\n\t\tenabled = false;\r\n\t}", "@Override\n public void onDisable() {\n try {\n System.out.println(\"Cleaning Dynamic Server System Processes.\");\n for (MinigameServer minigameServer : dynamicServerSystemManager.getServers())\n minigameServer.deleteServer();\n\n // Clean the output directory.\n FileUtils.deleteDirectory(new File(\"../minigameservers\"));\n new File(\"../minigameservers\").mkdirs();\n } catch (IOException e) {\n e.printStackTrace();\n }\n\n plugin = null;\n }", "public NeighbourhoodCache(boolean disable) {\n this.disable = disable;\n this.cachedNeighborhoods = new HashMap<CacheKey, List<AdjacentVertexWithEdge>>(MaxCacheSize);\n this.lruQueue = new ArrayDeque<CacheKey>(MaxCacheSize);\n }", "boolean isNodesMonitoringDisabled() {\n\t\treturn Boolean.parseBoolean(System.getProperty(\"javamelody.nodes-monitoring-disabled\"));\r\n\t}", "public void disable() {\n TalonHelper.configNeutralMode(Arrays.asList(armMotor, armMotorSlave), NeutralMode.Coast);\n }", "public static void disableConnectionReuseIfNecessary() {\n\t\t// HTTP connection reuse which was buggy pre-froyo\n\t\tif (hasHttpConnectionBug()) {\n\t\t\tSystem.setProperty(\"http.keepAlive\", \"false\");\n\t\t}\n\t}", "protected boolean disableEnableSvcs() throws Throwable {\n int i = ((int)(Math.random() * nodes));\n portString = \"\" + (i + NODE_PORT_OFFSET);\n \n return (verifySvcs(\"online\") &&\n changeSvcs(\"disable\") &&\n verifySvcs(\"disabled\") &&\n changeSvcs(\"enable\") &&\n verifySvcs(\"online\"));\n }", "static void invalidateBinderCaches() {\n DevicePolicyManager.invalidateBinderCaches();\n }", "private void clearCache() {\r\n for (int i = 1; i < neurons.length; i++) {\r\n for (int j = 0; j < neurons[i].length; j++) {\r\n neurons[i][j].clearCache();\r\n }\r\n }\r\n }", "private static InternalCacheConfig defaultDomainCacheConfig() {\n InternalCacheConfig cacheConfig = new InternalCacheConfig();\n cacheConfig.maxIdle = Duration.ofSeconds(100);\n cacheConfig.objectCount = 10_000;\n return cacheConfig;\n }", "public void setCachedAddress(boolean shouldCacheAddress) {\n this.cachedAddress = shouldCacheAddress;\n }", "public static void enableCache(boolean useCache) {\n OntologyTextProvider.useCache = useCache;\n }", "public void setReuseAddress (boolean on) {\n reuseAddrEnabled = on;\n }", "public static void disable() {\n if (lock.compareAndSet(false, true)) {\n\n RxJavaPlugins.setOnCompletableAssembly(null);\n RxJavaPlugins.setOnSingleAssembly(null);\n RxJavaPlugins.setOnMaybeAssembly(null);\n\n RxJavaPlugins.setOnObservableAssembly(null);\n RxJavaPlugins.setOnFlowableAssembly(null);\n RxJavaPlugins.setOnConnectableObservableAssembly(null);\n RxJavaPlugins.setOnConnectableFlowableAssembly(null);\n\n RxJavaPlugins.setOnParallelAssembly(null);\n\n lock.set(false);\n }\n }", "boolean disableMonitoring();", "private void stopDiscovery() {\n if (mDisposable != null) {\n mDisposable.dispose();\n }\n }", "public void disable ( ) {\r\n\t\tenabled = false;\r\n\t}", "@Deprecated\n public static boolean cacheDisabled() {\n return false;\n }", "AgentPolicyBuilder setMaxCacheAgeMs(long maxCacheAgeMs);", "public synchronized void blacklist( IpNetwork network ) {\n server.addToACL( network, false );\n if ( Log.isLogging( Log.DEBUG_EVENTS ) ) {\n Log.append( HTTPD.EVENT, \"Blacklisted \" + network.toString() );\n Log.append( HTTPD.EVENT, \"ACL: \" + server.getIpAcl().toString() );\n }\n }", "@DSGenerator(tool_name = \"Doppelganger\", tool_version = \"2.0\", generated_on = \"2014-03-25 14:14:32.543 -0400\", hash_original_method = \"4307E51DC423CE1BAC6B97E15C5D1C4A\", hash_generated_method = \"9877899ED403165DDF0C45CDE0153220\")\n \n public static boolean disableNetworkCommand(int netId){\n \tdouble taintDouble = 0;\n \ttaintDouble += netId;\n \n \treturn ((taintDouble) == 1);\n }", "public void setAvoidProxy(boolean avoidProxy) {\n this.avoidProxy = avoidProxy;\n }", "public void stopDiscovery() {\n if (mApiClient != null) {\n Weave.DEVICE_API.stopLoading(mApiClient, mDiscoveryListener);\n }\n }", "void disable() {\n }", "private void resetPIDBreach() {\n\t\t\n\t}", "public static void stopNetworkVirtualization(AppiumDriver driver) {\r\n\r\n\t\t\tHashMap<Object, Object> params = new HashMap<>();\r\n\r\n\t\t\tdriver.executeScript(\"mobile:vnetwork:stop\", params);\r\n\r\n\t\t}", "protected abstract boolean getDisableCacheControl(U result);", "private void reset() throws ParallelException {\r\n\t\tif (_k==2) _g.makeNNbors(true); // force reset (from cache)\r\n\t\t// else _g.makeNbors(true); // don't force reset (from cache): no need\r\n _nodesq = new TreeSet(_origNodesq);\r\n }", "public boolean checkNoCache() {\n\treturn getBoolean(ATTR_NOCACHE, false);\n }", "public Boolean getDisableCacheSync() {\r\n return getAttributeAsBoolean(\"disableCacheSync\");\r\n }", "boolean isNoCache();", "private void limitedMemoryWithoutEviction() {\n Jedis jedis = this.connector.connection();\n System.out.println(\"Collect: \" + jedis.get(\"0\")); // Redis still services read operations.\n System.out.println(jedis.set(\"0\", \"0\")); // Write operations will be refused.\n }", "@Override\n\tpublic boolean isCaching() {\n\t\treturn false;\n\t}", "void setAllowClusterGet( boolean r );", "public void test1(HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException {\n InetAddress addr = InetAddress.getByName(request.getRemoteAddr());\n\n if(addr.getCanonicalHostName().contains(\"trustme.com\")){ // disabled\n\n }\n }", "public static void restartDNS(){\n try {\n ProcessBuilder builder = new ProcessBuilder(\"cmd.exe\", \"/c\", \"\" );\n Process process;\n \n process = builder.start(); \n\n BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));\n String line=\"\";\n\n while ((line = reader.readLine()) != null) {\n Console.log(line);\n }\n \n } catch (IOException ex) {\n Logger.getLogger(HostEdit.class.getName()).log(Level.SEVERE, null, ex);\n }\n }", "public void setPingOnReuse(boolean pingOnReuse)\n {\n _isPing = pingOnReuse;\n }", "public ChannelServerConfiguration disableBind() {\n this.disableBind = true;\n return this;\n }", "@Scheduled(fixedRate = 30 * 60 * 1000)\n public void clearStaleCache(){\n\n }", "public FakeDns unknownHost() {\n this.addresses = Collections.emptyList();\n return this;\n }", "public void deregisterIPAddress(Inet4Address address) {\n\t\tusedAddresses.remove(address);\n\t}", "private boolean switchFailoverWithDNS() throws Throwable {\n \t// switch failover\n \t// ping from master\n \t// switch failback\n \t// ping from master\n \treturn (setupAPCScript() &&\n \t\t\tpingFromMaster(hostname) &&\n \t\t\tapcCommand(1, \"Off\") &&\n \t\t\tpingFromMaster(hostname) &&\n \t\t\tapcCommand(1, \"On\") &&\n \t\t\tpingFromMaster(hostname));\n\t}", "public void onNetDisConnect() {\n\n\t}", "public void clearProxyConfig();", "protected abstract void disable();", "public static void disablePermissionCache() {\n sPermissionCache.disableLocal();\n }", "public void disableBuildHotel(){\r\n\t\tbuildHotel = false;\r\n\t}", "public static void stopCaching() {\n\t\t/*\n\t\t * remove existing cache. Also, null implies that they are not be cached\n\t\t */\n\t\tfor (ComponentType aType : ComponentType.values()) {\n\t\t\tif (aType.preLoaded == false) {\n\t\t\t\taType.cachedOnes = null;\n\t\t\t}\n\t\t}\n\t}", "public native void disableRetransmitCountFactorInRTO();", "public void onNotEnabled() {\n Timber.d(\"onNotEnabled\");\n // keep the callback in case they turn it on manually\n setTorPref(Status.DISABLED);\n createClearnetClient();\n status = Status.NOT_ENABLED;\n if (onStatusChangedListener != null) {\n new Thread(() -> onStatusChangedListener.notEnabled()).start();\n }\n }", "public CacheControlDirective setNoCache(boolean theNoCache) {\n\t\tmyNoCache = theNoCache;\n\t\treturn this;\n\t}", "public boolean getNoCache() {\n return noCache;\n }", "void resetToDefaultServerAddress();", "boolean hasDnsSettings();", "void stopNodeAgentServices();", "public static void performanceCountDisable() { }", "public void setAsDown () \n\t{ \n\t\tn.setFailureState(false);\n\t\tfinal SortedSet<WLightpathRequest> affectedDemands = new TreeSet<> ();\n\t\tgetOutgoingFibers().forEach(f->affectedDemands.addAll(f.getTraversingLpRequestsInAtLeastOneLp()));\n\t\tgetIncomingFibers().forEach(f->affectedDemands.addAll(f.getTraversingLpRequestsInAtLeastOneLp()));\n\t\tfor (WLightpathRequest lpReq : affectedDemands)\n\t\t\tlpReq.internalUpdateOfRoutesCarriedTrafficFromFailureState();\n\t}", "public Collection<String> loadDisabledDataSources() {\n return loadAllDataSourcesNodes().stream().filter(each -> !Strings.isNullOrEmpty(getDataSourcesNodeData(each))\n && RegistryCenterNodeStatus.DISABLED.toString().equalsIgnoreCase(getDataSourcesNodeData(each))).collect(Collectors.toList());\n }" ]
[ "0.65652376", "0.60956883", "0.6065219", "0.60171276", "0.5899328", "0.5807126", "0.5716456", "0.56419", "0.56032956", "0.55505663", "0.5494505", "0.549051", "0.544372", "0.5284707", "0.5272565", "0.5266525", "0.5255992", "0.52126855", "0.5208211", "0.5202225", "0.51986647", "0.51871467", "0.5177395", "0.5105449", "0.50961524", "0.5093423", "0.50782984", "0.5054522", "0.5042964", "0.50032634", "0.5002271", "0.49910074", "0.4981238", "0.4981238", "0.49744934", "0.49725354", "0.49693936", "0.49630693", "0.4956855", "0.49474436", "0.4901395", "0.48950398", "0.48939273", "0.48871565", "0.48726422", "0.48698556", "0.4864571", "0.4856279", "0.4851145", "0.4836468", "0.48235652", "0.4817431", "0.48094076", "0.48068845", "0.48000363", "0.4794227", "0.47935066", "0.47930506", "0.47877", "0.47846174", "0.4779824", "0.47755298", "0.47734833", "0.47681442", "0.47650814", "0.47521758", "0.47519448", "0.47517744", "0.47464395", "0.4744926", "0.47435012", "0.47330934", "0.4729122", "0.47290394", "0.4719685", "0.47193938", "0.47146863", "0.47133905", "0.47103125", "0.47078475", "0.47041678", "0.47029603", "0.46924487", "0.46914658", "0.46908885", "0.46845466", "0.4679635", "0.4676813", "0.4672817", "0.46710488", "0.46693757", "0.46680006", "0.46549478", "0.46544543", "0.4648537", "0.46457347", "0.4641888", "0.46391264", "0.46255398", "0.46218333", "0.4620052" ]
0.0
-1
File diretorio = new File(ObterDiretorio());
public void Listar() { File diretorio = new File(dir_arq_download); File[] arquivos = diretorio.listFiles(); if(arquivos != null) { int length = arquivos.length; for(int i = 0; i < length; ++i) { File f = arquivos[i]; if (f.isFile()) { Arquivos.add(f.getName()); } } ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String> (this,android.R.layout.simple_dropdown_item_1line, Arquivos); SpnListarArquivos.setAdapter(arrayAdapter); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public void Leer() throws FileNotFoundException\n {\n // se crea una nueva ruta en donde se va a ir a leer el archivo\n String ruta = new File(\"datos.txt\").getAbsolutePath(); \n archivo=new File(ruta); \n }", "public static File obtenerDirectorioEnUnidadExterna(String DIRECTORIOEXTERNO, String nuevaCarpeta) {\n File file = new File(Environment.getExternalStoragePublicDirectory(DIRECTORIOEXTERNO), nuevaCarpeta);\n if (file.exists()) {\n return file;\n }\n if (!file.mkdirs()) {\n file = null;\n }\n return file;\n }", "File openFile();", "public File getDoveFile(){\n File temp = new File(drv.getAbsolutePath() + File.separator \n + folderName);\n return temp;\n }", "private synchronized Directory getDirectoryEmDisco() throws IOException{\r\n\t\tif(diretorioEmDisco == null){\r\n\t\t\tdiretorioEmDisco = FSDirectory.open(pastaDoIndice);\r\n\t\t}\r\n\t\t\r\n\t\treturn diretorioEmDisco;\r\n\t}", "public String pathToSave() {\n String path;\n File folder;\n do {\n System.out.print(\"Introduce la ruta en la que quieres guardar el fichero(separando directorios por guiones: directorio1-directorio2-directorio3): \");\n path = Utils.getString();\n path = String.valueOf(System.getProperty(\"user.dir\")).substring(0, 2) + \"\\\\\" + path.replace('-', '\\\\');\n folder = new File(path);\n if (!folder.exists()) {\n System.out.println(\"El directorio introducido no existe intentalo de nuevo...\");\n } else {\n if (!folder.isDirectory()) {\n System.out.println(\"Eso no es un directorio intentalo de nuevo...\");\n }\n }\n } while (!folder.exists() && !folder.isDirectory());\n return path;\n }", "public InventarioFile(){\r\n \r\n }", "public void crearPrimerFichero(){\n File f=new File(getApplicationContext().getFilesDir(),\"datos.json\");\n // si no existe lo creo\n if(!f.exists()) {\n String filename = \"datos.json\";\n String fileContents = \"[]\";\n FileOutputStream outputStream;\n\n try {\n outputStream = openFileOutput(filename, Context.MODE_PRIVATE);\n outputStream.write(fileContents.getBytes());\n outputStream.close();\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n\n }", "public static File obtenerFileDeFicheroEnUnidadExterna(String DIRECTORIOEXTERNO, String carpetaorigen, String nombrefichero) {\n boolean res = true;\n File file = null;\n try {\n // se crea variable separada por conveniencia, para facilitar una depuracion\n String pathcompleto = Environment.getExternalStoragePublicDirectory(DIRECTORIOEXTERNO) + File.separator + carpetaorigen;\n file = new File(pathcompleto, nombrefichero);\n if (file.exists()) {\n return file;\n }\n } catch (Exception e) {\n e.printStackTrace();\n }\n return file;\n }", "File getFile();", "File getFile();", "public void criar() throws IOException {\nif (!directorio.exists()) {\n directorio.mkdir();\n System.out.println(\"Directorio criado\");\n } else {\n System.out.println(\"Directorio existe\");\n }\n if (!fileAdmin.exists()) {\n fileAdmin.createNewFile();\n System.out.println(\"file de Administrador criado com sucesso\");\n escrever(lista);\n } else {\n System.out.println(\"ficheiro existe\");\n }\n\n }", "public void abrirArchivo() {\r\n try {\r\n entrada = new Scanner(new File(\"estudiantes.txt\"));\r\n } // fin de try\r\n catch (FileNotFoundException fileNotFoundException) {\r\n System.err.println(\"Error al abrir el archivo.\");\r\n System.exit(1);\r\n } // fin de catch\r\n }", "public abstract String direcao();", "public void salvaPartita(String file) {\n\r\n }", "String getFilepath();", "public File getFile();", "public File getFile();", "public File getFile ();", "public static void main(String[] args) throws IOException {\n File ruta = new File(\"C:\\\\Users\\\\usuario\\\\Documents\\\\curso de java online sepe\\\\unidad 1 clase file\\\\ejercicios\");\n // establecer el nombre del fichero a crear\n File f = new File(ruta, \"datos.txt\");\n File f1 = new File(ruta, \"datosNuevos.txt\");\n // imprimir la ruta absoluta del archivo\n System.out.println(f.getAbsolutePath());\n // Devuelve un String conteniendo el directorio padre del File. Devuelve null si no tiene directorio padre. del archivo\n System.out.println(f.getParent());\n // imprimir la ruta absoluta de la ruta del archivo\n System.out.println(ruta.getAbsolutePath());\n // Devuelve un String conteniendo el directorio padre del File. Devuelve null si no tiene directorio padre. de la ruta\n System.out.println(ruta.getParent());\n if (!f.exists()) { //se comprueba si el fichero existe o no\n System.out.println(\"Fichero \" + f.getName() + \" no existe\");\n if (!ruta.exists()) { //se comprueba si la ruta existe o no\n System.out.println(\"El directorio \" + ruta.getName() + \" no existe\");\n if (ruta.mkdir()) { //se crea la carpeta\n System.out.println(\"Directorio creado\");\n if (f.createNewFile()) { //se crea el fichero.\n System.out.println(\"Fichero \" + f.getName() + \" creado\");\n } else {\n System.out.println(\"No se ha podido crear \" + f.getName());\n }\n } else {\n System.out.println(\"No se ha podido crear \" + ruta.getName());\n }\n } else { //si la ruta existe creamos el fichero\n if (f.createNewFile()) {\n System.out.println(\"Fichero \" + f.getName() + \" creado\");\n } else {\n System.out.println(\"No se ha podido crear \" + f.getName());\n }\n }\n } else { //el fichero existe. Mostramos el tamaño\n System.out.println(\"Fichero \" + f.getName() + \" existe\");\n System.out.println(\"Tamaño \" + f.length() + \" bytes\");\n }\n\n // mostrar los archivos en esa carpeta\n File f2 = new File(ruta, \".\");\n // creamos un array para mostrar todos los archivos en esa ruta\n String[] listaArchivos = f2.list();\n if (!f1.exists()) { //se comprueba si el fichero existe o no\n System.out.println(\"Fichero \" + f1.getName() + \" no existe\");\n }\n if (f1.createNewFile()) { //se crea el fichero. Si se ha creado correctamente\n System.out.println(\"Fichero \" + f1.getName() + \" creado\");\n } else {\n System.out.println(\"No se ha podido crear \" + f1.getName());\n }\n for (int i = 0; i < listaArchivos.length; i++) {\n System.out.println(listaArchivos[i]);\n }\n // mostrar el numero de archivos en esa carpeta\n String[] elementos = ruta.list();\n System.out.println(\"La carpeta \" + ruta.getAbsolutePath() + \" tiene \" + elementos.length + \" subelementos\");\n }", "public void leeArchivo() throws IOException {\n // defino el objeto de Entrada para tomar datos\n BufferedReader brwEntrada;\n try {\n // creo el objeto de entrada a partir de un archivo de texto\n brwEntrada = new BufferedReader(new FileReader(\"datos.txt\"));\n } catch (FileNotFoundException e) {\n // si marca error es que el archivo no existia entonces lo creo\n File filPuntos = new File(\"datos.txt\");\n PrintWriter prwSalida = new PrintWriter(filPuntos);\n // le pongo datos ficticios o de default\n // lo cierro para que se grabe lo que meti al archivo\n prwSalida.close();\n // lo vuelvo a abrir porque el objetivo es leer datos\n brwEntrada = new BufferedReader(new FileReader(\"datos.txt\"));\n }\n // con el archivo abierto leo los datos que estan guardados\n brwEntrada.close();\n }", "public File filePath() throws FileNotFoundException {\n String path;\n File fileCreated;\n\n do {\n System.out.println(\"Disco en el que se encuentra ejecutando el programa: \" + String.valueOf(System.getProperty(\"user.dir\")).substring(0, 2));\n System.out.print(\"Introduce la ruta del fichero(Separalos con guiones, al final pon el nombre del fichero nada mas, directorio1-directorio2-fichero): \");\n path = Utils.getString();\n path = String.valueOf(System.getProperty(\"user.dir\").substring(0, 2)) + \"\\\\\" + path.replace('-', '\\\\') + \".txt\";\n fileCreated = new File(path);\n } while (!fileCreated.exists() || !fileCreated.isFile());\n\n return fileCreated;\n }", "public GestorArchivos(String numeroArchivo)\r\n {\r\n this.rutaArchivoEntrada = new File(\"archivostexto/in/in\" + numeroArchivo + \".txt\").getAbsolutePath().replace(\"\\\\\", \"/\");\r\n this.rutaArchivoSalida = new File(\"archivostexto/out/out\" + numeroArchivo + \".txt\").getAbsolutePath().replace(\"\\\\\", \"/\");\r\n }", "private File crearAchivoDeImagen() throws IOException {\n String fecha = new SimpleDateFormat(\"yyyyMMdd_HHmmss\").format(new Date());\n String nombreImagen = \"respaldo_\" + fecha + \"_\";\n File directorio = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);\n File imagen = File.createTempFile(nombreImagen, \".jpg\", directorio);\n\n imagePath = imagen.getAbsolutePath();\n Log.d(\"Retrofit\",imagePath);\n return imagen;\n }", "Path getFilePath();", "File getWorkfile();", "@Override\n protected void onActivityResult(int requestCode, int resultCode, Intent data) {\n if ((requestCode == request_code) && (resultCode == RESULT_OK)){\n Toast.makeText(getApplicationContext(),data.getDataString(),Toast.LENGTH_LONG).show();\n elemento = new File(data.getDataString());\n }\n }", "private static File erstelleDatei(String pfad)\r\n\t{\r\n\t\tFile f = new File(pfad);\r\n\t\tif (!f.exists())\r\n\t\t{\r\n\t\t\ttry\r\n\t\t\t{\r\n\t\t\t\tf.createNewFile();\r\n\t\t\t} catch (IOException e)\r\n\t\t\t{\r\n\t\t\t\treturn null;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn f;\r\n\t}", "String getFilePath();", "public ArchivoClientes(){\n\t\t\n\t\tif(archivo.exists()){\n\t\t\t//System.out.println(\"El archivo ya existe\");\n\t\t}else{\n\t\t\ttry {\n\t\t\t\t//archivo.mkdir();\n\t\t\t\tarchivo.createNewFile();\n\t\t\t} catch (Exception e) {\n\t\t\t\tSystem.out.println(\"Creación del archivo clientes: \" +e.getMessage());\n\t\t\t}\n\t\t}\n\t}", "String getFile();", "String getFile();", "String getFile();", "static void inicializarentrada(){\n try {\n archivo_entrada= new FileInputStream(\"src/serializacion/salida.txt\");\n } catch (FileNotFoundException ex) {\n System.out.println(\"Error al abrir el archivo\");\n }\n \n try {\n lector= new ObjectInputStream(archivo_entrada);\n } catch (IOException ex) {\n System.out.println(\"Error al acceder al archivo\");\n }\n }", "public Documento(String camino) {\n File archivo = new File(camino);\n try {\n byte[] temp = new byte[(int) archivo.length()];\n BufferedInputStream entrada = new\n BufferedInputStream(new FileInputStream(archivo));\n\n entrada.read(temp,0,temp.length);\n entrada.close();\n contenido = temp;\n } catch(Exception e) {\n System.out.println(\"El archivo dado no existe.\");\n }\n\n this.camino = camino;\n nombre = archivo.getName();\n\n }", "public File salvarStringEnUnidadExterna(String DIRECTORIOEXTERNO, String contenido, String carpetadestino, String nombreficherodestino) {\n boolean res = true;\n File fileDestino = null;\n try {\n File carpetaDestino = JYOCUtilsv4.obtenerDirectorioEnUnidadExterna(DIRECTORIOEXTERNO, carpetadestino);\n if (carpetaDestino != null) {\n fileDestino = new File(carpetaDestino, nombreficherodestino);\n if (!fileDestino.exists())\n fileDestino.createNewFile(); // por si acaso android en el futuro ..... hace algo raro\n PrintWriter pw = new PrintWriter(fileDestino);\n pw.println(contenido);\n pw.close();\n return fileDestino;\n }\n } catch (Exception e) {\n e.printStackTrace();\n }\n return fileDestino;\n }", "public void crearArchivoDeTexto(String rutas,String nombre, String texto){\n try{\n archivo = new File(rutas + File.separator + nombre);\n String rutaCompleta=archivo.getAbsolutePath();\n \n System.out.println(rutaCompleta);\n FileWriter archivoEscritura= new FileWriter(rutaCompleta,true);\n BufferedWriter escritura= new BufferedWriter(archivoEscritura);\n escritura.append(texto+\"\\n\");\n escritura.close();\n archivoEscritura.close();\n }catch(FileNotFoundException e1){\n System.out.println(\"Ruta de archivo no encontrada\");\n }catch(IOException e2){\n System.out.println(\"Error de escritura\");\n }catch(Exception e3){\n System.out.println(\"Error General\");\n }\n }", "public String open() throws Exception {\n\t\tFile d = new File(dir);\n\n\t\tif (d.mkdirs()) {\n\t\t\t// all OK, return.\n\t\t\treturn path;\n\t\t}\n\n\t\tif (d.exists()) {\n\t\t\t// already exists, return.\n\t\t\treturn path;\n\t\t}\n\n\t\t// try and fix the path\n\t\tlogger.warn(\"Cannot create directory: \" + d.getPath());\n\t\tfixPath(d);\n\n\t\tif (d.mkdirs()) {\n\t\t\t// all OK, return.\n\t\t\treturn path;\n\t\t}\n\n\t\tif (d.exists()) {\n\t\t\t// already exists, return.\n\t\t\treturn path;\n\t\t}\n\n\t\tthrow new ConverterException(\"Unable to fix path: \" + d.getPath());\n\t}", "private static String returnDiretorioPai(Path a){\n return a.getParent().toString();\n }", "FileObject getFile();", "FileObject getFile();", "public AsociarArchivoSerializado(String nuevoMaest, String registro){\n try{\n salNuevoMaest = new ObjectOutputStream(\n Files.newOutputStream(Paths.get(nuevoMaest)));\n \n salRegistro = new ObjectOutputStream(\n Files.newOutputStream(Paths.get(registro)));\n }\n catch(IOException iOException){\n System.err.println(\"Error al abrir el archivo. Terminado.\");\n System.exit(1);\n }\n }", "File getDefaultFile();", "private static File safeOpenFile() throws IOException {\n\t\tPath path = Paths.get(PropertyUtil.getConfigPath() + \"/config\");\n\n\t\tif (!Files.exists(path)) {\n\t\t\tFiles.createDirectories(path.getParent());\n\t\t\tFiles.createFile(path);\n\t\t\tlogger.debug(\"Creating {}\", path.toAbsolutePath());\n\t\t}\n\n\t\treturn path.toFile();\n\t}", "public static File gerarFile(String conteudo, File file)\n\t\t\tthrows WriterException, IOException {\n\t\treturn gerarFile(conteudo, WIDTH, HEIGHT, file);\n\t}", "public void compDire(String pathDire) throws Exception;", "public void setDiretor(IPessoa diretor);", "File getSaveFile();", "public void creaRutaImgPerfil(){\n servletContext=(ServletContext) contexto.getExternalContext().getContext();\n String ruta=\"\";\n //Ruta real hasta la carpeta de uploads\n ruta=servletContext.getRealPath(\"/upload/\");\n \n //Concatenamiento de directorios internos\n ruta+=File.separatorChar+\"img\"+File.separatorChar+\"users\"+File.separatorChar;\n \n //Asignacion de la ruta creada\n this.rutaImgPerfil=ruta;\n }", "public static void init(){\n Path path = FileDirectoryUtil.getPath(\"src\", \"fileIO\", \"test.txt\");\n FileDirectoryUtil.tryCreateDirectory(path);\n\n // Try to create the file\n path = Paths.get(path.toAbsolutePath().toString(), \"test.txt\");\n FileDirectoryUtil.tryCreateFile(path);\n\n // Print out the final location of the file\n System.out.println(path.toAbsolutePath());\n\n // Try to write to the file\n IOUtil.tryWriteToFile(getContent(), path);\n\n // Try to print the content of the file\n IOUtil.tryPrintContents(path);\n\n }", "@Test\n public void createFile(){\n try\n {\n URI uri = new URI(\"http://www.yu.edu/documents/doc390\");//given the complete uri\n String path = uri.getAuthority() + this.disectURI(uri);//get the Path which is www.yu.edu\\documents\n File file = new File(baseDir.getAbsolutePath() + File.separator + path);//make a File with the full class path and with the \"URI Path\"\n Files.createDirectories(file.toPath());//create the directories we didn't have before, ie not apart of the baseDir\n\n File theFile = new File(file.getAbsolutePath() + File.separator + \"doc390.txt\");//create a new File with the document as the last piece\n //wrap in a try because if the file is already there than we don't need to create a file\n if(!theFile.exists())Files.createFile(theFile.toPath());//create this file in the computer\n\n //write to the file -- in the real application this is the writing of the json\n FileWriter fileWriter = new FileWriter(theFile);\n fileWriter.write(\"HaYom sishi BShabbos\");\n fileWriter.flush();\n fileWriter.close();\n\n }\n catch(Exception e){\n e.printStackTrace();\n }\n }", "private File getFile() {\n Date date = new Date();\n File file = new File(\"D://meteopost//\" + date + \".txt\");\n if (file.exists()) {\n file.delete();\n }\n return file;\n }", "public static File salvarStringEnUnidadInterna(Context context, String contenido, String nombredelficheroDestino) {\n ContextWrapper wrapper = new ContextWrapper(context);\n // AL indicar \"Images\" almacena en /data/data/(nuestraappid)/app_Images ... aunque se puede\n // poner cualquier cosa, \"Almacen\" por ejemplo, y lo crea en /data/data/(nuestraappid)/app_Almacen\n File carpeta = wrapper.getDir(\"Images\", MODE_PRIVATE);\n File fileDestino = new File(carpeta, nombredelficheroDestino);\n try {\n if (!fileDestino.exists())\n fileDestino.createNewFile(); // por si acaso android en el futuro ..... hace algo raro\n PrintWriter pw = new PrintWriter(fileDestino);\n pw.println(contenido);\n pw.close();\n return fileDestino;\n } catch (IOException e) {\n e.printStackTrace();\n }\n return fileDestino;\n }", "private void grabarArchivo() {\n\t\tPrintWriter salida;\n\t\ttry {\n\t\t\tsalida = new PrintWriter(new FileWriter(super.salida));\n\t\t\tsalida.println(this.aDevolver);\n\t\t\tsalida.close();\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}", "public void guardarArchivo(String nombre, byte[] contenido) {\n\t\tFileOutputStream fos = null;\r\n\t\t// tenemos un objeto de tipo file, aqui no se crea el archivo\r\n\t\tFile carpetaPrincipal = new File(\"C:\\\\java\\\\wildfly-9.0.2.Final\\\\welcome-content\\\\documentos\\\\clientes\");\r\n\t\t// se crea la carpeta\r\n\t\tcarpetaPrincipal.mkdir();\r\n\t\tString nombreSinEspacios = \"\";\r\n\t\tFile miArchivo = new File(\"C:\\\\java\\\\wildfly-9.0.2.Final\\\\welcome-content\\\\documentos\\\\clientes\\\\\" + nombre);\r\n\t\ttry {\r\n\t\t\tmiArchivo.createNewFile();// se crea el archivo\r\n\t\t\tfos = new FileOutputStream(miArchivo);\r\n\t\t\tfos.write(contenido); // en memoria se escribe el archivo\r\n\t\t\tfos.flush();// escribir en el disco y tambien\r\n\t\t\tSystem.out.println(\"path donde se guardo \" + carpetaPrincipal.getAbsolutePath());\r\n\r\n\t\t} catch (IOException e) {\r\n\t\t\te.printStackTrace();\r\n\t\t} finally {\r\n\t\t\ttry {\r\n\t\t\t\tfos.close();// permite liberar el archivo\r\n\t\t\t} catch (IOException e1) {\r\n\t\t\t\te1.printStackTrace();\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t\tString nmArchivo = \"<a href=\\\"http://localhost:8081/documentos/clientes/\" + nombre + \"\\\" target=\\\"_blank\\\">\"\r\n\t\t\t\t+ nombre + \"</a><br/>\";\r\n\t\tSystem.out.println(\"filename:\" + nmArchivo);\r\n\t}", "public void escribir(String direccion,String texto) {\n try {\n FileWriter writer = new FileWriter(direccion);\n PrintWriter print = new PrintWriter(writer);\n print.print(texto);\n writer.close();\n } catch (IOException e) {\n System.out.println(e.getMessage());\n }\n }", "private FileUtil() {}", "public Registro() {\n this.nomeChar = new char[V_Constantes.TAM_STR_DIR_FILE];\n this.doZerarRegistro();\n }", "Object getDir();", "public static void crearPartida() throws FileNotFoundException, IOException, ExcepcionesFich {\n\t\tLecturaFicheros.AllLecture(\"C:\\\\Users\\\\Erick\\\\pruebaPOO.txt\");\n\t\tinterfaz = new GUI(0);\t\t\n\t}", "public FileIOManager(Conscientia conscientia) {\n\t\tthis.reader = new Reader(this);\n\t\tthis.writer = new Writer(this);\n\t\tthis.conscientia = conscientia;\n\t}", "public static void existeFichero(){\n File fichero = new File(\"config.ser\");\n\n try{\n\n if (fichero.exists()) {\n recuperarFecha();\n }\n else {\n fichero.createNewFile();\n }\n }catch(IOException ex){\n System.out.println(\"Excepcion al crear el fichero: \" + ex);\n }\n\n }", "public void recevoirDossier() {\n try {\n fileInfo = (FileInfo) ois.readObject(); //lire les informations du fichier\n //chemin du fichier en sortie\n String outputFile = fileInfo.getDestinationDirectory() + fileInfo.getFilename();\n dstFile = new File(outputFile);\n if (!new File(fileInfo.getDestinationDirectory()).exists()) { //si le fichier n'existe pas\n new File(fileInfo.getDestinationDirectory()).mkdirs(); //creation du fichier\n fos = new FileOutputStream(dstFile);\n fos.write(fileInfo.getFileData()); //ecrire les données dans le fichier\n fos.flush();\n fileInfo.setFileData(null);\n System.gc();\n fos.close();\n dstFile.setLastModified(fileInfo.getModifier());\n\n } else if (dstFile.lastModified() < fileInfo.getModifier()) { //si le fichier existe et que c'est une nouvelle version alors\n fos = new FileOutputStream(dstFile);\n fos.write(fileInfo.getFileData());\n fos.flush();\n fileInfo.setFileData(null);\n fos.close();\n dstFile.setLastModified(fileInfo.getModifier());\n }\n } catch (IOException | ClassNotFoundException ex) {\n Logger.getLogger(RecevoirFichier.class.getName()).log(Level.SEVERE, null, ex);\n }\n }", "File retrieveFile(String absolutePath);", "private File getIOFile() {\n \t\tIPath location = resource.getLocation();\n \t\tif(location!=null) {\n \t\t\treturn location.toFile();\n \t\t}\n \t\treturn null;\n \t}", "public static void main(String[] args) {\n File file = new File (\"tesEt.txt\");\n // Path file = Paths.get(\"test.txt\");\n // System.out.println(file.get);\n System.out.println(file.getAbsoluteFile());\n System.out.println(file.isAbsolute());\n System.out.println(file.exists());\n \n // try {\n // // File.createTempFile(\"prefix\", \"suffix\");\n // sy\n // } catch (IOException e) {\n // // TODO Auto-generated catch block\n // e.printStackTrace();\n // }finally\n // {\n // System.out.println(\"hehehehe\");\n // }\n // file.\n\n }", "private static void createFileUmidade() throws IOException {\r\n\t\tInteger defaultUmidade = 30;\r\n\t\tarqUmidade = new File(pathUmidade);\r\n\t\tif(!arqUmidade.exists()) {\r\n\t\t\tarqUmidade.createNewFile();\r\n\t\t\tFileWriter fw = new FileWriter(getArqUmidade());\r\n\t\t\tBufferedWriter buffWrite = new BufferedWriter(fw);\r\n\t\t\tbuffWrite.append(defaultUmidade.toString() + String.valueOf('\\n'));/*Inicializa o arquivo com uma umidade Inicial*/\r\n\t\t\tbuffWrite.close();\r\n\t\t}else {\r\n\t\t\tFileReader fr = new FileReader(getArqUmidade());\r\n\t\t\tBufferedReader buffRead = new BufferedReader(fr);\r\n\t\t\tif(!buffRead.ready()) {/*Se o arquivo se encontar criado mas estiver vazio*/\r\n\t\t\t\tFileWriter fw = new FileWriter(arqUmidade);\r\n\t\t\t\tBufferedWriter buffWrite = new BufferedWriter(fw);\r\n\t\t\t\tbuffWrite.append(defaultUmidade.toString() + String.valueOf('\\n'));/*Inicializa o arquivo com uma umidade Inicial*/\r\n\t\t\t\tbuffWrite.close();\r\n\t\t\t}\r\n\t\t\tbuffRead.close();\r\n\t\t}\r\n\t}", "@Test\n public void testCreateFilePath() {\n System.out.println(\"createFilePath with realistic path\");\n String path = System.getProperty(\"user.dir\")+fSeparator+\"MyDiaryBook\"\n +fSeparator+\"Users\"+fSeparator+\"Panagiwtis Georgiadis\"+fSeparator+\"Entries\"\n +fSeparator+\"Test1\";\n FilesDao instance = new FilesDao();\n boolean expResult = true;\n boolean result = instance.createFilePath(path);\n assertEquals(\"Some message\",expResult, result);\n }", "public String getDirecao(){\n return direcao;\n }", "private synchronized RAMDirectory getCopiaDiretorioMemoria() throws IOException{\r\n\t\tif(diretorioEmMemoria == null){\r\n\t\t\tdiretorioEmMemoria = new RAMDirectory(getDirectoryEmDisco(), IOContext.DEFAULT);\r\n\t\t}\r\n\t\treturn diretorioEmMemoria;\r\n\t}", "public void openFile() throws IOException {\n\t\tclientOutput.println(\">>> Unesite putanju do fajla fajla koji zelite da otvorite: \");\n\t\tuserInput = clientInput.readLine();\n\n\t\tizabraniF = new File(userInput);\n\n\t\t// Provera tipa fajla (.txt ili binarni)\n\t\tif (izabraniF.getName().endsWith(\".txt\")) {\n\t\t\tBufferedReader br = null;\n\t\t\ttry {\n\t\t\t\tbr = new BufferedReader(new FileReader(userInput));\n\n\t\t\t\tboolean kraj = false;\n\n\t\t\t\twhile (!kraj) {\n\t\t\t\t\tpom = br.readLine();\n\t\t\t\t\tif (pom == null)\n\t\t\t\t\t\tkraj = true;\n\t\t\t\t\telse\n\t\t\t\t\t\tclientOutput.println(pom);\n\t\t\t\t}\n\n\t\t\t} catch (Exception e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t} else {\n\t\t\tpom = null;\n\t\t\ttry {\n\t\t\t\tFileInputStream fIs = new FileInputStream(izabraniF);\n\t\t\t\tbyte[] b = new byte[(int) izabraniF.length()];\n\t\t\t\tfIs.read(b);\n\t\t\t\tpom = new String(Base64.getEncoder().encode(b), \"UTF-8\");\n\t\t\t\tclientOutput.println(pom);\n\t\t\t\tfIs.close();\n\t\t\t} catch (FileNotFoundException e) {\n\t\t\t\tclientOutput.println(\">>> Fajl nije pronadjen!\");\n\t\t\t}\n\t\t}\n\t}", "String savedFile();", "public FileUtility()\n {\n }", "public void crearRutaImgPublicacion(){\n \n servletContext=(ServletContext) contexto.getExternalContext().getContext();\n String ruta=\"\";\n //Ruta real hasta la carpeta uploads\n ruta=servletContext.getRealPath(\"/upload/\");\n //Obtener el codigo del usuario de la sesion actual\n //este es utilizado para ubicar la carpeta que le eprtenece\n String codUsuario=String.valueOf(new SessionLogica().obtenerUsuarioSession().getCodUsuario());\n //Concatenamiento de directorios internos\n ruta+=File.separatorChar+\"img\"+File.separatorChar+\"post\"+File.separatorChar+codUsuario+File.separatorChar+\"all\"+File.separatorChar;\n //Asignacion de la ruta creada\n this.rutaImgPublicacion=ruta;\n }", "public Files files();", "private File loadFile() throws IOException {\r\n File file = new File(filePath);\r\n if (!file.exists()) {\r\n File dir = new File(fileDirectory);\r\n dir.mkdir();\r\n File newFile = new File(filePath);\r\n newFile.createNewFile();\r\n return newFile;\r\n } else {\r\n return file;\r\n }\r\n }", "public static void CrearDirectorio (String args){\n File directorio = new File(args);\n \n if (!directorio.exists()) {\n if (directorio.mkdirs()) {\n //System.out.println(\"Directorio creado\\n\");\n } else {\n //System.out.println(\"Error al crear directorio\\n\");\n }\n }\n }", "public static File createPlayerFile(){\n try {\n playerFile = new File(System.getProperty(\"user.dir\") + \"/PlayerFiles/\" + \".txt\"); //creates player file, can it run on android?\n playerFile.createNewFile();\n }catch (IOException e){\n e.printStackTrace();\n }\n finally {\n return playerFile;\n }\n }", "private File getFile() {\n\t\t// retornamos el fichero a enviar\n\t\treturn this.file;\n\t}", "public abstract String getFileLocation();", "Path createPath();", "public void setDireccion(String direccion);", "public void criarArvoreDeDiretorioLocal(String caminhoDestino, String raiz, String fs) {\r\n String caminhoDeCriacao;\r\n \r\n caminhoDeCriacao = caminhoDestino;\r\n if (new File(caminhoDeCriacao).mkdir())\r\n System.out.println(\"Diretorio Criado\");\r\n else\r\n System.out.println(\"Diretorio: \" + caminhoDeCriacao + \" nao criado\");\r\n \r\n ArrayList<String> filhos = new ArrayList<>(arvoreDeDiretorios.getSuccessors(raiz));\r\n \r\n for (String filho : filhos) {\r\n //new File(caminhoDeCriacao +fs + filho).mkdir();\r\n criarArvoreDeDiretorioLocal(caminhoDeCriacao + fs + filho, filho,fs);\r\n } \r\n }", "public static void guardar()\n {\n File fileUsuario,fileDocente;\n ObjectOutputStream entradaUsuario,entradaDocente;\n \n fileDocente = new File(\"docentes\"); \n fileUsuario = new File(\"usuarios\");\n \n try \n {\n \n entradaDocente = new ObjectOutputStream(new FileOutputStream(fileDocente));\n entradaUsuario = new ObjectOutputStream(new FileOutputStream(fileUsuario));\n \n entradaDocente.writeObject(docentes);\n entradaUsuario.writeObject(usuarios);\n \n entradaDocente.close();\n entradaUsuario.close();\n } \n catch (Exception e) \n {\n e.printStackTrace();\n }\n }", "public File getFile() {\n\t\treturn new File(filepath);\n\t}", "public String leerArchivoJSON() {\n String contenido = \"\";\n FileReader entradaBytes;\n try {\n entradaBytes = new FileReader(new File(ruta));\n BufferedReader lector = new BufferedReader(entradaBytes);\n String linea;\n try {\n while ((linea = lector.readLine()) != null) {\n contenido += linea;\n }\n } catch (IOException e) {\n e.printStackTrace();\n } finally {\n try {\n if (entradaBytes != null) {\n entradaBytes.close();\n }\n if (lector != null) {\n lector.close();\n }\n } catch (IOException ex) {\n ex.printStackTrace();\n }\n }\n } catch (FileNotFoundException ex) {\n Logger.getLogger(GenerarIsla.class.getName()).log(Level.SEVERE, null, ex);\n }\n return contenido;\n }", "public String getFile() {\n \n // return it\n return theFile;\n }", "public static String crearRuta(String ruta) {\n\t\tFile directorio = new File(ruta);\n\t\tif (!directorio.exists())\n\t\t\tdirectorio.mkdirs();\n\t\treturn ruta;\n\t}", "private File getFile(String fileName, HttpServletRequest request){\n\t\tString fileSite = request.getSession().getServletContext().getRealPath(\"resources/upload\"); // 배포폴더\n\t\treturn new File(fileSite, fileName);\n\t}", "public EnigmaFile() throws Exception\n {\n\n String path = Main.class.getClassLoader().getResource(\"filein.txt\").getPath();\n File currentDirectory=new File(path);\n finstream = new FileInputStream(currentDirectory);\n\n\n String pathToWrite = path.replaceFirst(\"filein.txt\",\"fileout.txt\");\n File outputFile = new File(pathToWrite);\n br = new BufferedReader(new InputStreamReader(finstream));\n outputFile.createNewFile();\n FileWriter fileWrite = new FileWriter(outputFile.getAbsoluteFile());\n writer = new BufferedWriter(fileWrite);\n\n\n }", "public String getDir();", "private static void copyFile(File scrFile, File file) {\n\t\r\n}", "public static File getTestFile( String path )\r\n {\r\n return new File( getBasedir(), path );\r\n }", "@SuppressWarnings(\"unused\")\r\n\tprivate static File createFile(String path) {\r\n\t\t\r\n\t\t// open the file\r\n\t\tFile currentFile = new File(path);\r\n\t\t\r\n\t\t\r\n\t\t// check if it is a valid file\r\n\t\tif (currentFile == null) {\r\n\t\t\tSystem.out.println(\"Could not create the file\");\r\n\t\t\tthrow new NullPointerException();\r\n\t\t}\r\n\r\n\t\t// hopefully things went perfect\r\n\t\treturn currentFile;\r\n\r\n\t}", "private File getOpenApiFile(String oasDefinition) throws IOException {\n File oasTempFile = File.createTempFile(\"oasTempFile\", \".json\");\n try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(oasTempFile),\n StandardCharsets.UTF_8))) {\n bw.write(oasDefinition);\n }\n return oasTempFile;\n }", "public File toFile() throws WoodException\n {\n if(!exists()) {\n throw new WoodException(\"Attempt to use not existing file path |%s|.\", value);\n }\n return file;\n }", "private String getDirTempDruida()\n\t\t\tthrows Exception\n {\t\t\t\t\n\t\t\tString dir = null;\n\t\t\tdir = Contexto.getPropiedad(\"TMP.UPLOAD\");\t\t\n\t\t\treturn dir;\n }", "public interface IOFactory {\n\n public FileIO newFile(String path);\n\n}", "public void armarPreguntas(){\n preguntas = file.listaPreguntas(\"Preguntas.txt\");\n }", "public BrihaspatiProFile() {\n }", "public String getDireccion(){\n return direccion;\n }" ]
[ "0.72535", "0.6832523", "0.6581299", "0.65297514", "0.6514348", "0.64635205", "0.64610654", "0.64267546", "0.6402736", "0.6396326", "0.6396326", "0.6363232", "0.63253653", "0.6318947", "0.62997615", "0.6295106", "0.62711585", "0.62711585", "0.61884105", "0.61829203", "0.6167296", "0.61671597", "0.61346376", "0.61142766", "0.61113536", "0.6097458", "0.6090797", "0.60694027", "0.6068753", "0.60670924", "0.60611296", "0.60611296", "0.60611296", "0.6028162", "0.6005654", "0.5994368", "0.5992375", "0.59854925", "0.598545", "0.59706575", "0.59706575", "0.59618443", "0.59376997", "0.59368885", "0.59362566", "0.592672", "0.5913924", "0.5911615", "0.58975375", "0.58813316", "0.5879343", "0.58778304", "0.5861725", "0.58533627", "0.58518267", "0.5828188", "0.57987934", "0.5793679", "0.57901806", "0.5784224", "0.5781378", "0.5765032", "0.5763149", "0.5757943", "0.575354", "0.57416755", "0.5740329", "0.573096", "0.5727752", "0.5717619", "0.5713522", "0.5702488", "0.5697246", "0.5684294", "0.5678696", "0.5669731", "0.56602794", "0.5660225", "0.5641268", "0.56375897", "0.5632604", "0.5624467", "0.561904", "0.5616296", "0.5612958", "0.56069577", "0.56054115", "0.560068", "0.5597626", "0.5591049", "0.55867916", "0.5581835", "0.5580292", "0.55781054", "0.55728966", "0.5572175", "0.55666924", "0.55578804", "0.55570245", "0.5556793", "0.55494064" ]
0.0
-1
get the classloader to load into
public static void addURL(URL u) throws IOException { ClassLoader classLoader = MVdWUpdater.class.getClassLoader(); if (classLoader instanceof URLClassLoader) { try { ADD_URL_METHOD.invoke(classLoader, u); } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException("Unable to invoke URLClassLoader#addURL", e); } } else { throw new RuntimeException("Unknown classloader: " + classLoader.getClass()); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public ClassLoader getClassLoader () { return _classLoader; }", "@Override\n public Loader getClassLoader() {\n\treturn this.classLoader;\n }", "private ClassLoader getClassLoader() {\r\n return this.getClass().getClassLoader();\r\n }", "protected ClassLoader getClassLoader()\n {\n return m_classLoader;\n }", "public IClassLoader getClassLoader();", "public ClassLoader getClassLoader() {\r\n return _classLoader;\r\n }", "public ClassLoader getClassLoader ()\n {\n return Thread.currentThread ().getContextClassLoader ();\n }", "private static ClassLoader getClassLoader() {\n return LoggerProviders.class.getClassLoader();\n }", "public ClassLoader getBootClassLoader ()\n {\n return bootLoader;\n }", "public String getSharedLoader(IPath baseDir);", "protected ClassLoader getClassLoader() throws PortletException {\n return getClass().getClassLoader();\n }", "public ClassLoader getClassLoader() {\n return null;\n }", "public ClassLoader getClassLoader() {\n\t\treturn ClassLoader.getSystemClassLoader();\n\t}", "public ClassLoader getClassLoader() {\n return classLoader;\n }", "public ClassLoader getClassLoader() {\n return new BundleClassLoader(bundle);\n }", "public ScriptingClassLoader getClassLoader()\n {\n return vm.getClassLoader();\n }", "@Override\n public ClassLoader getClassLoader() {\n return null;\n }", "private URLClassLoader getURLClassLoader(URL jarURL) {\n \t\tClassLoader baseClassLoader = AGLoader.class.getClassLoader();\n \t\tif (baseClassLoader == null)\n \t\t\tbaseClassLoader = ClassLoader.getSystemClassLoader();\n \t\treturn new URLClassLoader(new URL[] { jarURL }, baseClassLoader);\n \t}", "ClassLoader getClassLoader() throws GeDARuntimeException;", "public ClassLoader getClassLoader() {\n\t\treturn classLoader;\n\t}", "public ClassLoader getClassLoader() {\n\t\treturn classLoader;\n\t}", "public static ClassLoader getClassLoader() {\n ClassLoader loader = Ruby.class.getClassLoader();\n if (loader == null) {\n loader = ClassLoader.getSystemClassLoader();\n }\n \n return loader;\n }", "public static ClassLoader getClassLoader() {\n ClassLoader loader = Ruby.class.getClassLoader();\n if (loader == null) {\n loader = ClassLoader.getSystemClassLoader();\n }\n \n return loader;\n }", "static ClassLoader contextClassLoader() {\n return Thread.currentThread().getContextClassLoader();\n }", "public synchronized ClassLoader getClassLoader() {\n return new BrainClassLoader(buildClassLoader(projectCP), \n buildClassLoader(buildCP), \n buildClassLoader(projectFilesCP), \n buildClassLoader(externalFilesCP), \n buildClassLoader(extraCP));\n }", "public ContainerLoader getLoader();", "private ClassLoader getCompileClassLoader() throws MojoExecutionException {\n\t\ttry {\n\t\t\tList<String> runtimeClasspathElements = project.getRuntimeClasspathElements();\n\t\t\tList<String> compileClasspathElements = project.getCompileClasspathElements();\n\t\t\tArrayList<URL> classpathURLs = new ArrayList<>();\n\t\t\tfor (String element : runtimeClasspathElements) {\n\t\t\t\tclasspathURLs.add(new File(element).toURI().toURL());\n\t\t\t}\n\t\t\tfor (String element : compileClasspathElements) {\n\t\t\t\tclasspathURLs.add(new File(element).toURI().toURL());\n\t\t\t}\n\t\t\tURL[] urlArray = classpathURLs.toArray(new URL[classpathURLs.size()]);\n\t\t\treturn new URLClassLoader(urlArray, Thread.currentThread().getContextClassLoader());\n\n\t\t} catch (Exception e) {\n\t\t\tthrow new MojoExecutionException(\"Unable to load project runtime !\", e);\n\t\t}\n\t}", "void injectorClassLoader() {\n\t\t//To get the package name\n\t\tString pkgName = context.getPackageName();\n\t\t//To get the context\n\t\tContext contextImpl = ((ContextWrapper) context).getBaseContext();\n\t\t//Access to the Activity of the main thread\n\t\tObject activityThread = null;\n\t\ttry {\n\t\t\tactivityThread = Reflection.getField(contextImpl, \"mMainThread\");\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\t//Get package container\n\t\tMap mPackages = null;\n\t\ttry {\n\t\t\tmPackages = (Map) Reflection.getField(activityThread, \"mPackages\");\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\t//To obtain a weak reference object, the standard reflection\n\t\tWeakReference weakReference = (WeakReference) mPackages.get(pkgName);\n\t\tif (weakReference == null) {\n\t\t\tlog.e(\"loadedApk is null\");\n\t\t} else {\n\t\t\t//Get apk need to be loaded\n\t\t\tObject loadedApk = weakReference.get();\n\t\t\t\n\t\t\tif (loadedApk == null) {\n\t\t\t\tlog.e(\"loadedApk is null\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (appClassLoader == null) {\n\t\t\t\t//Access to the original class loader\n\t\t\t\tClassLoader old = null;\n\t\t\t\ttry {\n\t\t\t\t\told = (ClassLoader) Reflection.getField(loadedApk,\n\t\t\t\t\t\t\t\"mClassLoader\");\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t\t//According to the default class loader instantiate a plug-in class loader\n\t\t\t\tappClassLoader = new SyknetAppClassLoader(old, this);\n\t\t\t}\n\t\t\t//Replace the new plug-in loader loader by default\n\t\t\ttry {\n\t\t\t\tReflection.setField(loadedApk, \"mClassLoader\", appClassLoader);\n\t\t\t} catch (Exception e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t}\n\t}", "public static ClassLoader getCurrentClassLoader() {\n ClassLoader classLoader = Thread.currentThread()\n .getContextClassLoader();\n if (classLoader == null) {\n classLoader = ConsumerTest.class.getClassLoader();\n }\n return classLoader;\n }", "public ClassLoader getCoreLoader() {\n return coreLoader;\n }", "ClassLoader getWebComponentClassLoader(URI componentId);", "public Class<?> getClazz(ClassLoader loader);", "SpringLoader getSpringLoader();", "public void initClassLoader() {\n FileClassLoadingService classLoader = new FileClassLoadingService();\n\n // init from preferences...\n Domain classLoaderDomain = getPreferenceDomain().getSubdomain(\n FileClassLoadingService.class);\n\n Collection details = classLoaderDomain.getPreferences();\n if (details.size() > 0) {\n\n // transform preference to file...\n Transformer transformer = new Transformer() {\n\n public Object transform(Object object) {\n DomainPreference pref = (DomainPreference) object;\n return new File(pref.getKey());\n }\n };\n\n classLoader.setPathFiles(CollectionUtils.collect(details, transformer));\n }\n\n this.modelerClassLoader = classLoader;\n }", "public static ClassLoader getDefaultClassLoader() {\n ClassLoader cl = null;\n try {\n cl = Thread.currentThread().getContextClassLoader();\n } finally {\n if (cl == null) {\n cl = ClassUtils.class.getClassLoader();\n }\n if (cl == null) {\n cl = ClassLoader.getSystemClassLoader();\n }\n }\n return cl;\n }", "EnvironmentLoader getEnvironmentLoader();", "public synchronized PluginClassLoader getPluginClassloader( Plugin plugin )\n {\n return classloaders.get( plugin );\n }", "private Class<?> loadClass(final ClassLoader lastLoader, final String className) {\n Class<?> clazz;\n if (lastLoader != null) {\n try {\n clazz = lastLoader.loadClass(className);\n if (clazz != null) {\n return clazz;\n }\n } catch (final Exception ex) {\n // Ignore exception.\n }\n }\n try {\n clazz = Thread.currentThread().getContextClassLoader().loadClass(className);\n } catch (final ClassNotFoundException e) {\n try {\n clazz = Class.forName(className);\n } catch (final ClassNotFoundException e1) {\n try {\n clazz = getClass().getClassLoader().loadClass(className);\n } catch (final ClassNotFoundException e2) {\n return null;\n }\n }\n }\n return clazz;\n }", "public URI getClassLoaderId() {\n return classLoaderId;\n }", "private void initClassloaders() {\n\t\tthis.commonloader = createClassloader(\"common\",null);\n\t\tthis.sharedloader = createClassloader(\"shared\", commonloader);\n\t\tthis.catalinaloader = createClassloader(\"server\", commonloader);\n\t}", "static private URLClassLoader separateClassLoader(URL[] classpath) throws Exception {\n\t\treturn new URLClassLoader(classpath, ClassLoader.getSystemClassLoader().getParent());\r\n\t}", "private ClassLoader makeClassLoader() throws MojoExecutionException {\n final List<URL> urls = new ArrayList<URL>();\n try {\n for (String cp: project.getRuntimeClasspathElements()) {\n urls.add(new File(cp).toURI().toURL());\n }\n } catch (DependencyResolutionRequiredException e) {\n throw new MojoExecutionException(\"dependencies not resolved\", e);\n } catch (MalformedURLException e) {\n throw new MojoExecutionException(\"invalid classpath element\", e);\n }\n return new URLClassLoader(urls.toArray(new URL[urls.size()]),\n getClass().getClassLoader());\n }", "public static XML.ObjectLoader getLoader() {\n return new Loader();\n }", "public Loader getLoader() {\n\t\treturn loader;\n\t}", "String resolveClassPath(String classPath);", "private List<ExtensionClassLoader> getClassLoaders() {\n final List<ExtensionClassLoader> classLoaders = new ArrayList<>();\n\n // start with the class loader that loaded ExtensionManager, should be WebAppClassLoader for API WAR\n final ExtensionClassLoader frameworkClassLoader = new ExtensionClassLoader(\"web-api\", new URL[0], this.getClass().getClassLoader());\n classLoaders.add(frameworkClassLoader);\n\n // we want to use the system class loader as the parent of the extension class loaders\n ClassLoader systemClassLoader = FlowPersistenceProvider.class.getClassLoader();\n\n // add a class loader for each extension dir\n final Set<String> extensionDirs = properties.getExtensionsDirs();\n for (final String dir : extensionDirs) {\n if (!StringUtils.isBlank(dir)) {\n final ExtensionClassLoader classLoader = createClassLoader(dir, systemClassLoader);\n if (classLoader != null) {\n classLoaders.add(classLoader);\n }\n }\n }\n\n return classLoaders;\n }", "@Override\n public Class getJavaClass() throws IOException, ClassNotFoundException {\n open();\n URL url;\n int p = path.lastIndexOf('/');\n int p2 = path.substring(0,p-1).lastIndexOf('/');\n\n File f = new File(path.substring(0,p2));\n url = f.toURI().toURL();\n URL[] urls = new URL[1];\n urls[0] = url;\n ClassLoader loader = new URLClassLoader(urls);\n\n String cls = path.substring(p2 + 1, path.lastIndexOf('.')).replace('/', '.');\n\n if (cfile.getParentFile().getParentFile().getName().equals(\"production\")) {\n cls = cls.substring(cls.lastIndexOf('.') + 1);\n }\n\n\n\n return loader.loadClass(cls);\n }", "private ClassLoader createHostClassLoader() throws MojoExecutionException {\n \n Set<URL> hostClasspath = artifactHelper.resolve(\"org.codehaus.fabric3\", \"fabric3-api\", runtimeVersion, Artifact.SCOPE_RUNTIME, \"jar\");\n hostClasspath.addAll(artifactHelper.resolve(\"org.codehaus.fabric3\", \"fabric3-host-api\", runtimeVersion, Artifact.SCOPE_RUNTIME, \"jar\"));\n hostClasspath.addAll(artifactHelper.resolve(\"javax.servlet\", \"servlet-api\", \"2.4\", Artifact.SCOPE_RUNTIME, \"jar\"));\n \n return new URLClassLoader(hostClasspath.toArray(new URL[] {}), getClass().getClassLoader());\n \n }", "protected WjrConfigLoader getConfigLoader() {\r\n\t\treturn new WjrConfigLoader();\r\n\t}", "public synchronized JRubyClassLoader getJRubyClassLoader() {\n if (!Ruby.isSecurityRestricted() && jrubyClassLoader == null) {\n jrubyClassLoader = new JRubyClassLoader(config.getLoader());\n }\n \n return jrubyClassLoader;\n }", "public synchronized JRubyClassLoader getJRubyClassLoader() {\n if (!Ruby.isSecurityRestricted() && jrubyClassLoader == null) {\n jrubyClassLoader = new JRubyClassLoader(config.getLoader());\n }\n \n return jrubyClassLoader;\n }", "public ClassLoader createClassLoader(ClassLoader aParent) throws MagnetException {\n\n if (_theClassLoader == null) {\n try {\n ArrayList<URL> someURLs = new ArrayList<URL>();\n for (Path path: _thePaths) {\n for (Resource resource: path.getSelectedResources()) {\n someURLs.add(resource.toURL());\n }\n }\n \n if (someURLs.size() == 0) {\n _theClassLoader = aParent;\n } else {\n _theClassLoader = URLClassLoader.newInstance((URL[]) someURLs.toArray(new URL[0]), aParent);\n }\n \n } catch (MalformedURLException mue) {\n throw new MagnetException(\"Error creating a classloader for this classpath\", mue);\n }\n }\n \n return _theClassLoader;\n }", "public String getCustomLoaderName();", "private Class loadClass(ClassInfo classInfo) {\n Class type = null;\n try {\n URLClassLoader classLoader = new URLClassLoader(new URL[]{\n new File(classInfo.getPath()).toURI().toURL()\n });\n type = classLoader.loadClass(classInfo.getName());\n } catch (MalformedURLException ex) {\n Logger.getLogger(CDIC.class.getName()).log(Level.SEVERE, \"Class url stimmt nicht. Ggf. hat der ClassIndexer einen falschen Pfad!\", ex);\n } catch (ClassNotFoundException ex) {\n Logger.getLogger(CDIC.class.getName()).log(Level.SEVERE, \"Klasse konnte nicht gefunden werden!\", ex);\n }\n return type;\n }", "public static ImageLoader getImageLoader() {\n return ImageLoader.IMAGE;\n }", "ClassLoader getNewTempClassLoader() {\n return new ClassLoader(getClassLoader()) {\n };\n }", "public static void checkClassloaders() {\n\t\tSystem.out.println(ClassLoaderDemo.class.getClassLoader()); //sun.misc.Launcher$AppClassLoader@36422510\n\t\tSystem.out.println(ClassLoaderDemo.class.getClassLoader().getParent()); //sun.misc.Launcher$ExtClassLoader@308f5944\n\t\tSystem.out.println(ClassLoaderDemo.class.getClassLoader().getParent().getParent()); //null\n\t}", "public synchronized Class<?> loadJPPFClass(String name) throws ClassNotFoundException\n\t{\n\t\ttry\n\t\t{\n\t\t\tif (debugEnabled) log.debug(\"looking up resource [\" + name + \"]\");\n\t\t\tClass<?> c = findLoadedClass(name);\n\t\t\tif (c != null)\n\t\t\t{\n\t\t\t\tClassLoader cl = c.getClassLoader();\n\t\t\t\tif (debugEnabled) log.debug(\"classloader = \" + cl);\n\t\t\t}\n\t\t\t/*\n\t\t\tif (c == null)\n\t\t\t{\n\t\t\t\tClassLoader parent = getParent();\n\t\t\t\tif (parent instanceof AbstractJPPFClassLoader) c = ((AbstractJPPFClassLoader) parent).findLoadedClass(name);\n\t\t\t}\n\t\t\t*/\n\t\t\tif (c == null)\n\t\t\t{\n\t\t\t\tif (debugEnabled) log.debug(\"resource [\" + name + \"] not already loaded\");\n\t\t\t\tc = findClass(name);\n\t\t\t}\n\t\t\tif (debugEnabled) log.debug(\"definition for resource [\" + name + \"] : \" + c);\n\t\t\treturn c;\n\t\t}\n\t\tcatch(NoClassDefFoundError e)\n\t\t{\n\t\t\tthrow e;\n\t\t}\n\t}", "ClassLoaderLogInfo getClassLoaderLogInfo();", "void addClassLoader(ClassLoader cl);", "public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassLoaderPolicy policy, Set<String> parentPackages)\n {\n String[] parentPkgs = parentPackages.toArray(new String[parentPackages.size()]);\n return initializeClassLoader(clazz, system, policy, parentPkgs);\n }", "protected ClassLoader getRestrictedClassloader(Profile profile) throws MalformedURLException\n {\n StringContainsClassRestrictor recipeLoader = null;\n URL libUrl = servletContext.getResource(\"/WEB-INF/\" + RECIPE_LIBRARY_PATH + \"/\" + profile.getRecipeLibraryFile());\n recipeLoader = new StringContainsClassRestrictor(new URL[] { libUrl }, servletContext.getClassLoader(), RESTRICTED_PACKAGES);\n return recipeLoader;\n }", "public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassLoaderPolicy policy)\n {\n return initializeClassLoader(clazz, system, policy, getParentPackages());\n }", "static void setParentClassLoader(ClassLoader bootStrap, BaseManager baseMgr,\n DeploymentRequest req) throws ConfigException, IOException {\n\n List allClassPaths = new ArrayList();\n \n // system class loader \n List systemClasspath = baseMgr.getSystemCPathPrefixNSuffix();\n if (systemClasspath.size() > 0) {\n allClassPaths.addAll(systemClasspath);\n }\n\n // common class loader\n List commonClassPath = getCommonClasspath(baseMgr);\n if (commonClassPath.size() > 0) {\n allClassPaths.addAll(commonClassPath);\n }\n\n // shared class loader\n // Some explanation on the special handling below:\n // Per the platform specification, connector classes are to be availble\n // to all applications, i.e. a connector deployed to target foo should\n // be available to apps deployed on foo (and not target bar). In that\n // case, we will need to figure out all connector module deployed to \n // the target on which the application is deployed. Resolving the\n // classpath accordlingly. \n String targetString = req.getResourceTargetList();\n List<String> targets = null;\n if (targetString != null) {\n // get the accurate list of targets from client\n targets = DeploymentServiceUtils.getTargetNamesFromTargetString(\n targetString); \n } else {\n // get all the targets of this domain\n targets = new ArrayList<String>(); \n ConfigContext configContext = AdminService.getAdminService(\n ).getAdminContext().getAdminConfigContext();\n\n Server[] servers = ServerHelper.getServersInDomain(configContext); \n for (Server server: servers) {\n targets.add(server.getName());\n } \n Cluster[] clusters = ClusterHelper.getClustersInDomain(\n configContext); \n for (Cluster cluster: clusters) {\n targets.add(cluster.getName());\n } \n }\n\n for (String target: targets) {\n List sharedClassPath = \n baseMgr.getSharedClasspath(true, target);\n if (sharedClassPath.size() > 0) {\n allClassPaths.addAll(sharedClassPath);\n }\n }\n\n ClassLoader parentClassLoader = \n getClassLoader(allClassPaths, bootStrap, null);\n\n // sets the parent class loader\n req.setParentClassLoader(parentClassLoader);\n\n // sets the class path for the class loader\n req.setParentClasspath(allClassPaths);\n }", "public ClassLoader getClassLoaderFor(ObjectName mbeanName)\n throws InstanceNotFoundException{\n return mbsInterceptor.getClassLoaderFor(cloneObjectName(mbeanName));\n }", "private static Class<?> loadClass(String archiveImplClassName) throws Exception \n {\n return SecurityActions.getThreadContextClassLoader().loadClass(archiveImplClassName);\n }", "public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ParentPolicy parentPolicy, ClassLoaderPolicy policy)\n {\n ClassLoaderDomain domain = system.createAndRegisterDomain(\"TEST\", parentPolicy);\n return initializeClassLoader(clazz, system, domain, policy);\n }", "private ClassLoader createBootClassLoader(ClassLoader hostClassLoader) throws MojoExecutionException {\n \n Set<URL> bootClassPath = artifactHelper.resolve(\"org.codehaus.fabric3\", \"fabric3-test-runtime\", runtimeVersion, Artifact.SCOPE_RUNTIME, \"jar\");\n return new URLClassLoader(bootClassPath.toArray(new URL[] {}), hostClassLoader);\n \n }", "public ClassPath getClassPath();", "public String getSystemClassPath();", "private void loadJarsFromClasspath() {\n\n loadedJarsMap.clear();\n\n ClassLoader classLoader = getClass().getClassLoader();\n URL[] urls = null;\n do {\n //check if the class loader is instance of URL and cast it\n if (classLoader instanceof URLClassLoader) {\n urls = ((URLClassLoader) classLoader).getURLs();\n } else {\n // if the ClassLoader is not instance of URLClassLoader we will break the cycle and log a message\n log.info(\"ClassLoader \" + classLoader\n + \" is not instance of URLClassLoader, so it will skip it.\");\n\n // if the ClassLoader is from JBoss, it is instance of BaseClassLoader,\n // we can take the ClassPath from a public method -> listResourceCache(), from JBoss-classloader.jar\n // this ClassLoader is empty, we will get the parent\n classLoader = classLoader.getParent();\n continue;\n }\n try {\n loadJarsFromManifestFile(classLoader);\n } catch (IOException ioe) {\n log.warn(\"MANIFEST.MF is loaded, so we will not search for duplicated jars!\");\n }\n\n // add all jars from ClassPath to the map\n for (int i = 0; i < urls.length; i++) {\n addJarToMap(urls[i].getFile());\n }\n\n // get the parent classLoader\n classLoader = classLoader.getParent();\n } while (classLoader != null);\n\n if (loadedJarsMap.isEmpty()) {\n // jars are not found, so probably no URL ClassLoaders are found\n throw new RuntimeException(\"Most probrably specific server is used without URLClassLoader instances!\");\n }\n }", "public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassLoaderDomain domain, ClassLoaderPolicy policy)\n {\n // Remember some information\n this.system = system;\n this.domain = domain;\n this.policy = policy;\n \n // Create the classloader\n ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy);\n\n // Load the class from the isolated classloader\n try\n {\n clazz = classLoader.loadClass(clazz.getName());\n }\n catch (ClassNotFoundException e)\n {\n throw new RuntimeException(\"Unable to load test class in isolated classloader \" + clazz, e);\n }\n \n return clazz;\n }", "public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassFilter parentFilter, ClassLoaderPolicy policy)\n {\n Set<String> parentPackages = getParentPackages();\n String[] parentPkgs = parentPackages.toArray(new String[parentPackages.size()]);\n PackageClassFilter filter = new PackageClassFilter(parentPkgs);\n filter.setIncludeJava(true);\n CombiningClassFilter beforeFilter = CombiningClassFilter.create(filter, parentFilter);\n ParentPolicy parentPolicy = new ParentPolicy(beforeFilter, ClassFilterUtils.NOTHING);\n return initializeClassLoader(clazz, system, parentPolicy, policy);\n }", "ClassLoaderConfigType createClassLoaderConfigType();", "protected synchronized Class<?> loadClass(String paramString, boolean paramBoolean) throws ClassNotFoundException {\n/* 321 */ ReflectUtil.checkPackageAccess(paramString);\n/* 322 */ Class<?> clazz = findLoadedClass(paramString);\n/* 323 */ if (clazz == null) {\n/* */ try {\n/* 325 */ clazz = findClass(paramString);\n/* 326 */ } catch (ClassNotFoundException classNotFoundException) {}\n/* */ \n/* */ \n/* 329 */ if (clazz == null) {\n/* 330 */ clazz = getParent().loadClass(paramString);\n/* */ }\n/* */ } \n/* 333 */ if (paramBoolean) {\n/* 334 */ resolveClass(clazz);\n/* */ }\n/* 336 */ return clazz;\n/* */ }", "public void classLoader(){\n \t\n URL xmlpath = this.getClass().getClassLoader().getResource(\"\");\n System.out.println(xmlpath.getPath());\n }", "public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderPolicy policy)\n {\n ClassLoaderSystem system = new DefaultClassLoaderSystem();\n return initializeClassLoader(clazz, system, policy, getParentPackages());\n }", "public URL getResource(String name) {\n for (int i = 0; i < classLoaders.length; i++) {\n URL url = classLoaders[i].getResource(name);\n if (url != null) {\n return url;\n }\n }\n if (getParent() != null) {\n return super.getResource(name);\n } else {\n return null;\n }\n }", "public Class<?> initializeClassLoader(Class<?> clazz, ClassFilter parentFilter, ClassLoaderPolicy policy)\n {\n ClassLoaderSystem system = new DefaultClassLoaderSystem();\n return initializeClassLoader(clazz, system, parentFilter, policy);\n }", "protected StoryClassLoader createStoryClassLoader() throws MalformedURLException {\n return new StoryClassLoader(classpathElements());\n }", "public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassFilter beforeFilter, ClassFilter afterFilter, ClassLoaderPolicy policy)\n {\n ParentPolicy parentPolicy = new ParentPolicy(beforeFilter, afterFilter);\n return initializeClassLoader(clazz, system, parentPolicy, policy);\n }", "public static Class<?> loadClass(String className) throws ClassNotFoundException {\n // Use the thread context class loader. This is necessary because in some configurations, e.g.\n // when run from a single JAR containing caliper and all its dependencies the caliper JAR\n // ends up on the boot class path of the Worker and so needs to the use thread context class\n // loader to load classes provided by the user.\n return Class.forName(className, true, Thread.currentThread().getContextClassLoader());\n }", "private HashMap getRuntimeImport() {\n \t\tURL url = InternalBootLoader.class.getProtectionDomain().getCodeSource().getLocation();\n \t\tString path = InternalBootLoader.decode(url.getFile());\n \t\tFile base = new File(path);\n \t\tif (!base.isDirectory())\n \t\t\tbase = base.getParentFile(); // was loaded from jar\n \n \t\t// find the plugin.xml (need to search because in dev mode\n \t\t// we can have some extra directory entries)\n \t\tFile xml = null;\n \t\twhile (base != null) {\n \t\t\txml = new File(base, BOOT_XML);\n \t\t\tif (xml.exists())\n \t\t\t\tbreak;\n \t\t\tbase = base.getParentFile();\n \t\t}\n \t\tif (xml == null)\n \t\t\tthrow new RuntimeException(Policy.bind(\"error.boot\")); //$NON-NLS-1$\n \n \t\ttry {\n \t\t\treturn getImport(xml.toURL(), RUNTIME_PLUGIN_ID);\n \t\t} catch (MalformedURLException e) {\n \t\t\treturn null;\n \t\t}\n \t}", "private Class<?> loadClass(String className) {\n try {\n return Class.forName(className);\n } catch (ClassNotFoundException ignore) {\n return null;\n }\n }", "public Class<?> loadApplicationClass(String name) {\n \n for (GraphClassLoader graphClassLoader : this.classLoaders) {\n Class<?> loadClass = graphClassLoader.loadApplicationClass(name, \n false //don't try delegate\n );\n \n if (logger.isDebugEnabled()) {\n logger.debug(\"Attempting to load class \" + name + \" from classloader \" + graphClassLoader + \" on behalf of delegate \" + this);\n }\n \n if (loadClass != null) {\n return loadClass;\n }\n }\n \n return null;\n }", "public static List<ClassLoader> findAllClassLoaders(final LogNode log) {\n // Need both a set and a list so we can keep them unique, but in an order that (hopefully) reflects\n // the order in which the JDK calls classloaders.\n //\n // See:\n // https://docs.oracle.com/javase/8/docs/technotes/tools/findingclasses.html\n // http://www.javaworld.com/article/2077344/core-java/find-a-way-out-of-the-classloader-maze.html?page=2\n //\n final AdditionOrderedSet<ClassLoader> classLoadersSet = new AdditionOrderedSet<>();\n\n // Look for classloaders on the call stack\n // Find the first caller in the call stack to call a method in the FastClasspathScanner package\n ClassLoader callerLoader = null;\n if (CALLER_RESOLVER == null) {\n if (log != null) {\n log.log(ClasspathFinder.class.getSimpleName() + \" could not create \"\n + CallerResolver.class.getSimpleName() + \", current SecurityManager does not grant \"\n + \"RuntimePermission(\\\"createSecurityManager\\\")\");\n }\n } else {\n final Class<?>[] callStack = CALLER_RESOLVER.getClassContext();\n if (callStack == null) {\n if (log != null) {\n log.log(ClasspathFinder.class.getSimpleName() + \": \" + CallerResolver.class.getSimpleName()\n + \"#getClassContext() returned null\");\n }\n } else {\n final String fcsPkgPrefix = FastClasspathScanner.class.getPackage().getName() + \".\";\n int fcsIdx;\n for (fcsIdx = callStack.length - 1; fcsIdx >= 0; --fcsIdx) {\n if (callStack[fcsIdx].getName().startsWith(fcsPkgPrefix)) {\n break;\n }\n }\n if (fcsIdx < 0 || fcsIdx == callStack.length - 1) {\n // Should not happen\n throw new RuntimeException(\"Could not find caller of \" + fcsPkgPrefix + \"* in call stack\");\n }\n\n // Get the caller's current classloader\n callerLoader = callStack[fcsIdx + 1].getClassLoader();\n }\n }\n boolean useCallerLoader = callerLoader != null;\n\n // Get the context classloader\n final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();\n boolean useContextLoader = contextLoader != null;\n\n // Get the system classloader\n final ClassLoader systemLoader = ClassLoader.getSystemClassLoader();\n boolean useSystemLoader = systemLoader != null;\n\n // Establish descendancy relationships, and ignore any classloader that is an ancestor of another.\n if (useCallerLoader && useContextLoader && isDescendantOf(callerLoader, contextLoader)) {\n useContextLoader = false;\n }\n if (useContextLoader && useCallerLoader && isDescendantOf(contextLoader, callerLoader)) {\n useCallerLoader = false;\n }\n if (useSystemLoader && useContextLoader && isDescendantOf(systemLoader, contextLoader)) {\n useContextLoader = false;\n }\n if (useContextLoader && useSystemLoader && isDescendantOf(contextLoader, systemLoader)) {\n useSystemLoader = false;\n }\n if (useSystemLoader && useCallerLoader && isDescendantOf(systemLoader, callerLoader)) {\n useCallerLoader = false;\n }\n if (useCallerLoader && useSystemLoader && isDescendantOf(callerLoader, systemLoader)) {\n useSystemLoader = false;\n }\n if (!useCallerLoader && !useContextLoader && !useSystemLoader) {\n // Should not happen\n throw new RuntimeException(\"Could not find a usable ClassLoader\");\n }\n // There will generally only be one class left after this. In rare cases, you may have a separate\n // callerLoader and contextLoader, but those cases are ill-defined -- see:\n // http://www.javaworld.com/article/2077344/core-java/find-a-way-out-of-the-classloader-maze.html?page=2\n // We specifically add the classloaders in the following order however, so that in the case that there\n // are two of them left, they are resolved in this order. The relative ordering of callerLoader and\n // contextLoader is due to the recommendation at the above URL.\n if (useSystemLoader) {\n classLoadersSet.add(systemLoader);\n }\n if (useCallerLoader) {\n classLoadersSet.add(callerLoader);\n }\n if (useContextLoader) {\n classLoadersSet.add(contextLoader);\n }\n\n final List<ClassLoader> classLoaders = classLoadersSet.getList();\n if (log != null) {\n for (final ClassLoader classLoader : classLoaders) {\n log.log(\"Found ClassLoader \" + classLoader.toString());\n }\n log.addElapsedTime();\n }\n return classLoaders;\n }", "protected ClassLoader(ClassLoader parent) {\r\n if (parent == null) {\r\n if (!getClass().equals(Launcher.ExtClassLoader.class)) {\r\n this.parent = getSystemClassLoader();\r\n } else {\r\n this.parent = null;\r\n }\r\n } else {\r\n this.parent = parent;\r\n }\r\n RefNative.initNativeClassLoader(this, parent);\r\n }", "public static NativeLibraryLoader getInstance() {\n return instance;\n }", "public String getRuntimeClass();", "public static PathAnchor classpath(ClassLoader loader) {\n return classpath(\"\", loader);\n }", "private static Class<?> loadInClassloader(ClassLoader loader, Class<?> cls)\n throws ClassNotFoundException {\n return cls.isPrimitive() ? cls : Class.forName(cls.getName(), true, loader);\n }", "public Class<?> lookupClass(String name) throws ClassNotFoundException {\n return getClass().getClassLoader().loadClass(name);\n }", "public Class<?> initializeClassLoader(Class<?> clazz, ClassLoaderSystem system, ClassLoaderPolicy policy, String... parentPackages)\n {\n // The parent filter\n PackageClassFilter filter = new PackageClassFilter(parentPackages);\n filter.setIncludeJava(true);\n return initializeClassLoader(clazz, system, filter, ClassFilterUtils.NOTHING, policy);\n }", "public static Class get_CLASS()\n {\n Class clz;\n try\n {\n clz = Class.forName(\"com.tangosol.coherence/component/net/Security\".replace('/', '.'));\n }\n catch (ClassNotFoundException e)\n {\n throw new NoClassDefFoundError(e.getMessage());\n }\n return clz;\n }", "protected SchemaTypeLoader getSchemaTypeLoader() {\n return Connector15DCBRoot.SCHEMA_TYPE_LOADER;\n }", "public AntClassLoader createClassLoader(Path path) {\n AntClassLoader loader = new AntClassLoader();\n loader.setProject(this);\n loader.setClassPath(path);\n return loader;\n }", "protected void setUpClassloader() throws Exception\n {\n threadContextClassLoader = Thread.currentThread()\n .getContextClassLoader();\n Thread.currentThread()\n .setContextClassLoader(\n new URLClassLoader(new URL[0], this.getClass()\n .getClassLoader()));\n classLoaderSet = true;\n }", "@Override\n protected Class<?> loadClass(String name, boolean resolve)\n throws ClassNotFoundException {\n Class<?> loadedClass = findLoadedClass(name);\n if (loadedClass == null) {\n try {\n if (_classLoader != null) {\n loadedClass = _classLoader.loadClass(name);\n }\n } catch (ClassNotFoundException ex) {\n // class not found in system class loader... silently skipping\n }\n\n try {\n // find the class from given jar urls as in first constructor parameter.\n if (loadedClass == null) {\n loadedClass = findClass(name);\n }\n } catch (ClassNotFoundException e) {\n // class is not found in the given urls.\n // Let's try it in parent classloader.\n // If class is still not found, then this method will throw class not found ex.\n loadedClass = super.loadClass(name, resolve);\n }\n }\n\n if (resolve) { // marked to resolve\n resolveClass(loadedClass);\n }\n return loadedClass;\n }", "public static void loadClass(String name) {\n\n }", "protected Class loadClass(String type) {\n try {\n return getClass().getClassLoader().loadClass(type);\n }\n catch (ClassNotFoundException e) {\n try {\n return Thread.currentThread().getContextClassLoader().loadClass(type);\n }\n catch (ClassNotFoundException e2) {\n try {\n return Class.forName(type);\n }\n catch (ClassNotFoundException e3) {\n }\n }\n throw new GroovyRuntimeException(\"Could not load type: \" + type, e);\n }\n }", "private CacheHelper loadCacheHelper(String className)\n throws Exception {\n\n // use the context class loader to load class so that any\n // user-defined classes in WEB-INF can also be loaded.\n ClassLoader cl = Thread.currentThread().getContextClassLoader();\n Class helperClass = cl.loadClass(className);\n\n CacheHelper helper = (CacheHelper) helperClass.newInstance();\n\n return helper;\n }" ]
[ "0.80412674", "0.8016583", "0.78913325", "0.7785217", "0.77486044", "0.75974214", "0.74104774", "0.7310615", "0.72216976", "0.72194445", "0.721731", "0.720166", "0.71417654", "0.7122677", "0.7039984", "0.70304453", "0.70127124", "0.6966703", "0.6950884", "0.69273114", "0.69273114", "0.6786062", "0.6786062", "0.6728919", "0.6726559", "0.6720501", "0.66935074", "0.66615945", "0.66469294", "0.6608388", "0.6587712", "0.652831", "0.6519383", "0.64695495", "0.64450955", "0.63968766", "0.63547575", "0.63397485", "0.6335614", "0.6324158", "0.6217926", "0.6198461", "0.6161125", "0.61495394", "0.6135349", "0.6114247", "0.6092853", "0.6083225", "0.6049967", "0.602488", "0.602488", "0.6022745", "0.5968547", "0.5959137", "0.5948062", "0.59468186", "0.5939312", "0.5926559", "0.59240156", "0.59226125", "0.5922281", "0.59085035", "0.5904873", "0.59047997", "0.59024066", "0.59006137", "0.5897213", "0.5880309", "0.58723736", "0.5858653", "0.5809873", "0.5807621", "0.5790726", "0.5783627", "0.5782835", "0.57741237", "0.5758357", "0.5758314", "0.57492924", "0.5744635", "0.5710429", "0.5706177", "0.5688695", "0.5685645", "0.56834656", "0.5662748", "0.5662415", "0.5646156", "0.56326866", "0.56252414", "0.5611709", "0.56078017", "0.5592577", "0.5580304", "0.55775046", "0.554883", "0.55420846", "0.55283874", "0.5527043", "0.55266464", "0.5526382" ]
0.0
-1
Created by liukun on 16/icon_cs3/10.
public interface SubscriberOnNextListener<T> { void onNext(T t); void onError(String Code); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Override\n public void perish() {\n \n }", "private static void cajas() {\n\t\t\n\t}", "@Override\r\n\tpublic void bicar() {\n\t\t\r\n\t}", "@Override\r\n\tpublic void bicar() {\n\t\t\r\n\t}", "private stendhal() {\n\t}", "@Override\n public void func_104112_b() {\n \n }", "@Override\n\tpublic void grabar() {\n\t\t\n\t}", "public void mo38117a() {\n }", "public void mo4359a() {\n }", "public final void mo51373a() {\n }", "@Override\n\tprotected void getExras() {\n\n\t}", "@Override\n\tpublic void comer() {\n\t\t\n\t}", "@Override\r\n\tpublic void tires() {\n\t\t\r\n\t}", "private void poetries() {\n\n\t}", "@Override\n\tpublic void anular() {\n\n\t}", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "@Override\r\n\tpublic void comer() \r\n\t{\n\t\t\r\n\t}", "private void strin() {\n\n\t}", "private void kk12() {\n\n\t}", "public void gored() {\n\t\t\n\t}", "protected boolean func_70814_o() { return true; }", "@Override\n\tpublic void entrenar() {\n\t\t\n\t}", "private void m50366E() {\n }", "@Override\n\tpublic void nadar() {\n\t\t\n\t}", "@Override\r\n\tpublic void dormir() {\n\t\t\r\n\t}", "public void mo6081a() {\n }", "@Override\n\tprotected void interr() {\n\t}", "@Override\n\tpublic void gravarBd() {\n\t\t\n\t}", "public void mo12628c() {\n }", "public void mo55254a() {\n }", "@Override\n\tpublic void nghe() {\n\n\t}", "@Override\r\n\tpublic void rozmnozovat() {\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n protected void getExras() {\n }", "public void skystonePos4() {\n }", "@Override\n\tpublic void ligar() {\n\t\t\n\t}", "@Override\r\n\tprotected void func03() {\n\t\t\r\n\t}", "@Override\n\tpublic void nefesAl() {\n\n\t}", "public void mo12930a() {\n }", "static void feladat9() {\n\t}", "public void skystonePos6() {\n }", "@Override\r\n\tvoid func04() {\n\t\t\r\n\t}", "public void mo9848a() {\n }", "protected void mo6255a() {\n }", "@Override\n\tpublic void sacrifier() {\n\t\t\n\t}", "@Override\r\n\tprotected void doF4() {\n\t\t\r\n\t}", "@Override\r\n\t\t\tpublic void annadir() {\n\r\n\t\t\t}", "@Override\n public void memoria() {\n \n }", "private void init() {\n\n\t}", "@Override\r\n\t\tpublic void init() {\n\t\t\t\r\n\t\t}", "static void feladat4() {\n\t}", "@Override\r\n\tprotected void doF8() {\n\t\t\r\n\t}", "public void mo21877s() {\n }", "@Override\n public void inizializza() {\n\n super.inizializza();\n }", "@Override\r\n\t\t\tpublic void ayuda() {\n\r\n\t\t\t}", "@Override\n public void init() {\n\n }", "public void m23075a() {\n }", "@Override\n\tpublic void init() {\n\n\t}", "@Override\n\tpublic void init() {\n\n\t}", "@Override\n\tpublic void init() {\n\n\t}", "public void Tyre() {\n\t\t\r\n\t}", "Constructor() {\r\n\t\t \r\n\t }", "public void mo21779D() {\n }", "@Override\n\tpublic void einkaufen() {\n\t}", "private void m50367F() {\n }", "@Override\n\tpublic void one() {\n\t\t\n\t}", "static void feladat7() {\n\t}", "public void skystonePos5() {\n }", "@Override\r\n\tpublic void anularFact() {\n\t\t\r\n\t}", "@Override\n\t\t\tpublic void ic() {\n\t\t\t\t\n\t\t\t}", "public void skystonePos3() {\n }", "private zza.zza()\n\t\t{\n\t\t}", "@Override\n public int describeContents() { return 0; }", "public abstract void mo70713b();", "@Override\n\tpublic int mettreAJour() {\n\t\treturn 0;\n\t}", "@Override\r\n\tprotected void doF6() {\n\t\t\r\n\t}", "@Override\r\n\tpublic void init() {\n\t\t\r\n\t}", "@Override\r\n\tpublic void init() {\n\t\t\r\n\t}", "@Override\r\n\tpublic void init() {\n\t\t\r\n\t}", "@Override\n protected void initialize() {\n\n \n }", "private Rekenhulp()\n\t{\n\t}", "@Override\n\tpublic void jugar() {\n\t\t\n\t}", "@Override\r\n\tpublic void init() {\n\r\n\t}", "@Override\r\n\tpublic void init() {\n\r\n\t}", "@Override\r\n\tpublic void init() {\n\r\n\t}", "public void Exterior() {\n\t\t\r\n\t}", "public void mo3376r() {\n }", "public void mo21825b() {\n }", "public void mo21783H() {\n }", "public void mo97908d() {\n }", "@Override\n\tprotected void initdata() {\n\n\t}" ]
[ "0.585783", "0.582243", "0.5715462", "0.5715462", "0.5710184", "0.5677947", "0.5652429", "0.5648088", "0.56302977", "0.5629172", "0.56183827", "0.5612104", "0.5591078", "0.55830795", "0.55372167", "0.55338687", "0.55338687", "0.55338687", "0.55338687", "0.55338687", "0.55338687", "0.55338687", "0.5516912", "0.5513108", "0.5505419", "0.5500286", "0.5494917", "0.54876864", "0.5466713", "0.5464066", "0.5459275", "0.5453864", "0.5444321", "0.54427165", "0.5432377", "0.54259425", "0.54192233", "0.5365611", "0.5362537", "0.5362537", "0.5362537", "0.5362537", "0.5362537", "0.5358329", "0.53555924", "0.53449905", "0.53441584", "0.53340226", "0.53210163", "0.53100264", "0.53076756", "0.5305886", "0.5303272", "0.53017366", "0.5296508", "0.5289908", "0.5284883", "0.52812815", "0.5281126", "0.5276878", "0.5263792", "0.52617776", "0.5259857", "0.52587324", "0.5254768", "0.52410656", "0.52377844", "0.5233941", "0.5233941", "0.5233941", "0.5227976", "0.52260953", "0.52151364", "0.52113175", "0.52056915", "0.5204735", "0.52023655", "0.5195805", "0.51954293", "0.51913035", "0.51900643", "0.5189714", "0.51891834", "0.51881117", "0.5187647", "0.51842725", "0.5180891", "0.5180891", "0.5180891", "0.5179725", "0.5178805", "0.51746017", "0.51723385", "0.51723385", "0.51723385", "0.5170745", "0.5168726", "0.5166732", "0.51613253", "0.51599234", "0.51594526" ]
0.0
-1
JFREECHART DEVELOPER GUIDE The JFreeChart Developer Guide, written by David Gilbert, is available to purchase from Object Refinery Limited: Sales are used to provide funding for the JFreeChart project please support us so that we can continue developing free software. Starting point for the demonstration application.
public static void main(final String[] args) { GradientDescent gd = new GradientDescent(A_INTERCEPT, B_SLOPE, DATA, PACE); final MainGradientDescentGUI gui = new MainGradientDescentGUI(gd); gui.pack(); RefineryUtilities.centerFrameOnScreen(gui); gui.setVisible(true); gd.calculateGradientDescent(100); final MainGradientDescentGUI gui2 = new MainGradientDescentGUI(gd); gui2.pack(); RefineryUtilities.centerFrameOnScreen(gui2); gui2.setVisible(true); gd.calculateGradientDescent(300); final MainGradientDescentGUI gui3 = new MainGradientDescentGUI(gd); gui3.pack(); RefineryUtilities.centerFrameOnScreen(gui3); gui3.setVisible(true); gd.calculateGradientDescent(300); final MainGradientDescentGUI gui4 = new MainGradientDescentGUI(gd); gui4.pack(); RefineryUtilities.centerFrameOnScreen(gui4); gui4.setVisible(true); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static void main(String[] args) {\r\n\r\n // create a chart\r\n double[][] data = new double[][] {\r\n {56.0, -12.0, 34.0, 76.0, 56.0, 100.0, 67.0, 45.0},\r\n {37.0, 45.0, 67.0, 25.0, 34.0, 34.0, 100.0, 53.0},\r\n {43.0, 54.0, 34.0, 34.0, 87.0, 64.0, 73.0, 12.0}};\r\n CategoryDataset dataset = DatasetUtilities.createCategoryDataset(\r\n \"Series \", \"Type \", data);\r\n\r\n JFreeChart chart = null;\r\n boolean drilldown = true;\r\n\r\n if (drilldown) {\r\n CategoryAxis categoryAxis = new CategoryAxis(\"Category\");\r\n ValueAxis valueAxis = new NumberAxis(\"Value\");\r\n BarRenderer renderer = new BarRenderer();\r\n renderer.setBaseToolTipGenerator(\r\n new StandardCategoryToolTipGenerator());\r\n renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator(\r\n \"bar_chart_detail.jsp\"));\r\n \r\n // add URLs to the series names in the legend...\r\n renderer.setLegendItemURLGenerator(new CategorySeriesLabelGenerator() \r\n {\r\n public String generateLabel(CategoryDataset dataset, int series) {\r\n return \"series.html?series=\" + (series + 1);\r\n }\r\n \r\n });\r\n \r\n // add tool tips to the series names in the legend...\r\n renderer.setLegendItemToolTipGenerator(new CategorySeriesLabelGenerator() \r\n {\r\n public String generateLabel(CategoryDataset dataset, int series) {\r\n return \"Tool tip for series \" + (series + 1);\r\n }\r\n \r\n });\r\n CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, \r\n valueAxis, renderer);\r\n plot.setOrientation(PlotOrientation.VERTICAL);\r\n chart = new JFreeChart(\"Bar Chart\", JFreeChart.DEFAULT_TITLE_FONT,\r\n plot, true);\r\n }\r\n else {\r\n chart = ChartFactory.createBarChart(\r\n \"Vertical Bar Chart\", // chart title\r\n \"Category\", // domain axis label\r\n \"Value\", // range axis label\r\n dataset, // data\r\n PlotOrientation.VERTICAL,\r\n true, // include legend\r\n true,\r\n false\r\n );\r\n }\r\n chart.setBackgroundPaint(java.awt.Color.white);\r\n \r\n // save it to an image\r\n try {\r\n ChartRenderingInfo info = new ChartRenderingInfo(\r\n new StandardEntityCollection());\r\n File file1 = new File(\"barchart100.png\");\r\n ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);\r\n\r\n // write an HTML page incorporating the image with an image map\r\n File file2 = new File(\"barchart100.html\");\r\n OutputStream out = new BufferedOutputStream(\r\n new FileOutputStream(file2));\r\n PrintWriter writer = new PrintWriter(out);\r\n writer.println(\"<!DOCTYPE html PUBLIC \\\"-//W3C//DTD XHTML 1.0 Strict//EN\\\"\");\r\n writer.println(\"\\\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\\\">\");\r\n writer.println(\"<html xmlns=\\\"http://www.w3.org/1999/xhtml\\\" lang=\\\"en\\\" xml:lang=\\\"en\\\">\");\r\n writer.println(\"<head><title>JFreeChart Image Map Demo</title></head>\");\r\n writer.println(\"<body><p>\");\r\n ImageMapUtilities.writeImageMap(writer, \"chart\", info);\r\n writer.println(\"<img src=\\\"barchart100.png\\\" \"\r\n + \"width=\\\"600\\\" height=\\\"400\\\" usemap=\\\"#chart\\\" alt=\\\"barchart100.png\\\"/>\");\r\n writer.println(\"</p></body>\");\r\n writer.println(\"</html>\");\r\n writer.close();\r\n\r\n }\r\n catch (IOException e) {\r\n System.out.println(e.toString());\r\n }\r\n\r\n }", "public JFreeChart render();", "@Test\n public void test61() throws Throwable {\n CategoryPlot categoryPlot0 = new CategoryPlot();\n categoryPlot0.setRangeGridlinesVisible(true);\n categoryPlot0.clearDomainAxes();\n JDBCXYDataset jDBCXYDataset0 = new JDBCXYDataset((Connection) null);\n MeterPlot meterPlot0 = new MeterPlot();\n JFreeChart jFreeChart0 = new JFreeChart((Plot) meterPlot0);\n ChartPanel chartPanel0 = new ChartPanel(jFreeChart0, true);\n String[] stringArray0 = new String[6];\n stringArray0[0] = \"[*tQy\\\"Ir)|..\";\n stringArray0[1] = \".\";\n stringArray0[2] = \"org.jfree.chart.annotations.TextAnnotation\";\n stringArray0[3] = \"Category_Plot\";\n stringArray0[4] = \"mt1@^eqB0HF9rLg\";\n stringArray0[5] = \"B9t}^@/]9\";\n JFreeChart.main(stringArray0);\n boolean boolean0 = jDBCXYDataset0.hasListener(chartPanel0);\n jDBCXYDataset0.setTimeSeries(false);\n DatasetChangeEvent datasetChangeEvent0 = new DatasetChangeEvent((Object) categoryPlot0, (Dataset) jDBCXYDataset0);\n categoryPlot0.datasetChanged(datasetChangeEvent0);\n AxisLocation axisLocation0 = categoryPlot0.getDomainAxisLocation(0);\n Rectangle2D.Double rectangle2D_Double0 = new Rectangle2D.Double((double) 0, (double) 0, (-2820.4), (-2820.4));\n int int0 = rectangle2D_Double0.outcode((double) 0, (-2820.4));\n CategoryAxis categoryAxis0 = new CategoryAxis();\n categoryPlot0.setDomainAxis(15, categoryAxis0);\n }", "@Test\n public void test58() throws Throwable {\n Rectangle2D.Double rectangle2D_Double0 = new Rectangle2D.Double(500000.0, 500000.0, 0.0, 0.0);\n rectangle2D_Double0.x = 1.0;\n Rectangle2D.Double rectangle2D_Double1 = (Rectangle2D.Double)rectangle2D_Double0.getBounds2D();\n Point2D.Double point2D_Double0 = new Point2D.Double();\n double double0 = point2D_Double0.getX();\n CategoryAxis3D categoryAxis3D0 = new CategoryAxis3D(\"\");\n CombinedDomainCategoryPlot combinedDomainCategoryPlot0 = new CombinedDomainCategoryPlot((CategoryAxis) categoryAxis3D0);\n Range range0 = combinedDomainCategoryPlot0.getDataRange((ValueAxis) null);\n Color color0 = (Color)combinedDomainCategoryPlot0.getDomainGridlinePaint();\n Line2D.Double line2D_Double0 = new Line2D.Double((Point2D) point2D_Double0, (Point2D) point2D_Double0);\n double double1 = line2D_Double0.getX2();\n BasicStroke basicStroke0 = (BasicStroke)CyclicNumberAxis.DEFAULT_ADVANCE_LINE_STROKE;\n combinedDomainCategoryPlot0.setRangeGridlineStroke(basicStroke0);\n Font font0 = SpiderWebPlot.DEFAULT_LABEL_FONT;\n JFreeChart jFreeChart0 = new JFreeChart(\"\", font0, (Plot) combinedDomainCategoryPlot0, false);\n ChartPanel chartPanel0 = new ChartPanel(jFreeChart0, false);\n Point point0 = chartPanel0.translateJava2DToScreen(point2D_Double0);\n combinedDomainCategoryPlot0.zoomDomainAxes(500000.0, (PlotRenderingInfo) null, (Point2D) point0, false);\n }", "public void showChart(boolean enable) {\n mainChartPanel.remove(chartPanel);\n\n if (showChartPanel) {\n\n JFreeChart chart = createChart();\n chartPanel = new ChartPanel(chart);\n setDefaultChartOptions();\n mainChartPanel.add(chartPanel, BorderLayout.CENTER);\n\n //chartTableModel = new ChartTableModel(xySeriesCollection.getSeriesCount());\n chartTableModel = new ChartTableModel(dataSets.size());\n\n for (int row = 0; row < dataSets.size(); row++) {\n DataSet data_set = dataSets.get(row);\n chartTableModel.setValueAt(data_set.getDataCollection().getSeries(0).getDescription(), row, 0);\n chartTableModel.setValueAt(new Double(\"0.00\"), row, 1);\n chartTableModel.setValueAt(new Double(\"0.00\"), row, 2);\n chartTableModel.setValueAt(new Double(\"0.00\"), row, 3);\n chartTableModel.setValueAt(new Double(\"0.00\"), row, 4);\n chartTableModel.setValueAt(new Double(\"0.00\"), row, 5);\n chartTableModel.setValueAt(new Double(\"0.00\"), row, 6);\n }\n }\n /*\n for (int row = 0; row < xySeriesCollection.getSeriesCount(); row++) {\n XYPlot plot = (XYPlot) chart.getPlot();\n XYSeries series = xySeriesCollection.getSeries(row);\n chartTableModel.setValueAt(series.getDescription(), row, 0);\n chartTableModel.setValueAt(new Double(\"0.00\"), row, 1);\n chartTableModel.setValueAt(new Double(\"0.00\"), row, 2);\n chartTableModel.setValueAt(new Double(\"0.00\"), row, 3);\n chartTableModel.setValueAt(new Double(\"0.00\"), row, 4);\n chartTableModel.setValueAt(new Double(\"0.00\"), row, 5);\n chartTableModel.setValueAt(new Double(\"0.00\"), row, 6);\n }\n */\n\n jScrollPane1.getViewport().removeAll();\n if (showTablePanel) {\n JTable table = new JTable(chartTableModel);\n TableCellRenderer renderer2 = new NumberCellRenderer();\n table.getColumnModel().getColumn(1).setCellRenderer(renderer2);\n table.getColumnModel().getColumn(2).setCellRenderer(renderer2);\n table.getColumnModel().getColumn(3).setCellRenderer(renderer2);\n table.getColumnModel().getColumn(4).setCellRenderer(renderer2);\n table.getColumnModel().getColumn(5).setCellRenderer(renderer2);\n table.getColumnModel().getColumn(6).setCellRenderer(renderer2);\n jScrollPane1.getViewport().add(table);\n }\n\n //jSplitPane.add(tablePanel, JSplitPane.BOTTOM);\n\n chartSlider.setEnabled(false);\n chartSlider.setValue(0);\n chartSlider.setEnabled(true);\n\n this.validate();\n }", "@Test\n public void test27() throws Throwable {\n PeriodAxis periodAxis0 = new PeriodAxis(\"org.jfree.data.general.WaferMapDataset\");\n CombinedRangeCategoryPlot combinedRangeCategoryPlot0 = new CombinedRangeCategoryPlot((ValueAxis) periodAxis0);\n AxisLocation axisLocation0 = combinedRangeCategoryPlot0.getRangeAxisLocation(52);\n StatisticalLineAndShapeRenderer statisticalLineAndShapeRenderer0 = new StatisticalLineAndShapeRenderer(true, true);\n StatisticalLineAndShapeRenderer statisticalLineAndShapeRenderer1 = (StatisticalLineAndShapeRenderer)statisticalLineAndShapeRenderer0.clone();\n int int0 = combinedRangeCategoryPlot0.getIndexOf(statisticalLineAndShapeRenderer0);\n SortOrder sortOrder0 = combinedRangeCategoryPlot0.getRowRenderingOrder();\n combinedRangeCategoryPlot0.setColumnRenderingOrder(sortOrder0);\n Layer layer0 = Layer.BACKGROUND;\n Collection collection0 = combinedRangeCategoryPlot0.getDomainMarkers(layer0);\n AxisLocation axisLocation1 = combinedRangeCategoryPlot0.getDomainAxisLocation(23);\n Rectangle2D.Double rectangle2D_Double0 = new Rectangle2D.Double(10.0, (double) (-1), (double) 52, 10.0);\n JFreeChart jFreeChart0 = new JFreeChart(\"a@s4%C}8D{zFf7+[\", (Plot) combinedRangeCategoryPlot0);\n statisticalLineAndShapeRenderer0.setSeriesShapesFilled(4, false);\n ChartPanel chartPanel0 = new ChartPanel(jFreeChart0, true, false, true, false, true);\n Rectangle2D.Double rectangle2D_Double1 = (Rectangle2D.Double)chartPanel0.getScreenDataArea(23, (-1));\n rectangle2D_Double0.setRect((Rectangle2D) rectangle2D_Double1);\n }", "public interface ChartRenderer {\n\t\n\t/**\n\t * Renders this object's data as a chart.\n\t */\n\tpublic JFreeChart render();\n\n\t\n}", "@Test\n public void test07() throws Throwable {\n BarRenderer barRenderer0 = new BarRenderer();\n float float0 = 787.887F;\n Font font0 = SpiderWebPlot.DEFAULT_LABEL_FONT;\n JFreeChart jFreeChart0 = null;\n try {\n jFreeChart0 = new JFreeChart(\"\", font0, (Plot) null, false);\n } catch(NullPointerException e) {\n //\n // Null 'plot' argument.\n //\n assertThrownBy(\"org.jfree.chart.JFreeChart\", e);\n }\n }", "@Test\n public void test29() throws Throwable {\n CombinedRangeCategoryPlot combinedRangeCategoryPlot0 = new CombinedRangeCategoryPlot();\n combinedRangeCategoryPlot0.setRangeGridlinesVisible(true);\n JFreeChart jFreeChart0 = new JFreeChart((Plot) combinedRangeCategoryPlot0);\n ChartPanel chartPanel0 = new ChartPanel(jFreeChart0, 0, 0, 0, 0, 24, 0, true, true, true, true, false, false);\n chartPanel0.transferFocusBackward();\n Point point0 = chartPanel0.getLocation();\n Line2D.Double line2D_Double0 = new Line2D.Double((Point2D) point0, (Point2D) point0);\n line2D_Double0.y1 = (double) 0;\n DefaultCategoryItemRenderer defaultCategoryItemRenderer0 = new DefaultCategoryItemRenderer();\n boolean boolean0 = jFreeChart0.equals(defaultCategoryItemRenderer0);\n Rectangle2D.Double rectangle2D_Double0 = (Rectangle2D.Double)line2D_Double0.getBounds2D();\n combinedRangeCategoryPlot0.setDrawSharedDomainAxis(false);\n combinedRangeCategoryPlot0.setWeight(0);\n StandardEntityCollection standardEntityCollection0 = new StandardEntityCollection();\n ChartRenderingInfo chartRenderingInfo0 = new ChartRenderingInfo((EntityCollection) standardEntityCollection0);\n // Undeclared exception!\n try { \n jFreeChart0.createBufferedImage(0, 0, (double) 0, (-629.173823008773), chartRenderingInfo0);\n } catch(IllegalArgumentException e) {\n //\n // Width (0) and height (0) cannot be <= 0\n //\n assertThrownBy(\"java.awt.image.DirectColorModel\", e);\n }\n }", "public JFreeChart createChart(IntervalXYDataset paramIntervalXYDataset) {\n\n\n JFreeChart jfreechart = ChartFactory.createXYBarChart(\n \"Spread Example\", //title\n \"Resource\", //xAxisLabel\n false, //dateAxis\n \"Timing\", //yAxisLabel\n paramIntervalXYDataset, //dataset\n PlotOrientation.VERTICAL, //orientation\n true, //legend\n true, //tooltips\n false); //urls\n\n\n\n XYPlot xyplot = (XYPlot) jfreechart.getPlot();\n\n xyplot.setBackgroundPaint(Color.white);\n xyplot.setRangeGridlinePaint(Color.darkGray);//vertical\n xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY);//horizontal\n\n// xyplot.setDomainAxis(createTimeAxis());\n xyplot.setDomainAxis(createSymbolAxis());\n\n xyplot.setFixedLegendItems(createLegend());\n\n MyXYBarRenderer xyBarRenderer = new MyXYBarRenderer();\n xyBarRenderer.setUseYInterval(true);\n\n xyBarRenderer.setShadowVisible(false);\n\n xyBarRenderer.setDrawBarOutline(true);\n xyBarRenderer.setBaseOutlinePaint(Color.DARK_GRAY);\n\n xyBarRenderer.setBaseItemLabelFont(new Font(\"Arial\", Font.PLAIN, 10));\n\n xyBarRenderer.setMargin(0.2);\n xyplot.setRenderer(0, xyBarRenderer, true);\n\n//xyBarRenderer.\n\n\n MyXYBarPainter barPainter = new MyXYBarPainter((XYTaskDataset) paramIntervalXYDataset);\n barPainter.setPainterType(MyXYBarPainter.PainterType.GRADIENT);\n xyBarRenderer.setBarPainter(barPainter);\n\n\n\n //Item-Label:\n xyBarRenderer.setBaseItemLabelsVisible(true);\n xyBarRenderer.setBaseItemLabelGenerator(createItemLabelGenerator());\n xyBarRenderer.setBasePositiveItemLabelPosition(createItemLabelPosition());\n\n\n\n xyBarRenderer.setBaseToolTipGenerator(createTooltipGenerator());\n\n\n\n//PeriodAxis xaxis= new PeriodAxis(\"kk\");\n\n xyplot.setRangeAxis(createTimeAxis());\n// xyplot.setRangeAxis(createSymbolAxis());\n\n\n\n// DateAxis xaxis = new DateAxis();\n// xaxis.setVerticalTickLabels(true);\n// xyplot.setRangeAxis(xaxis);\n xyplot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);\n\n// ChartUtilities.applyCurrentTheme(jfreechart);\n\n return jfreechart;\n }", "@Override\n\tprotected final JFreeChart createChart() {\n\t\tJFreeChart jFreeChart=null;\n\t\tIntervalXYDataset dataset=createDataset();\n\t\t\n\t\tjFreeChart=ChartFactory.createXYBarChart(title,xalabel, dateAxis, yalabel,dataset, por, legend, tooltips, urls);\n\t\t\n\t\tXYPlot plot=(XYPlot)jFreeChart.getPlot();\n\t\tpreRender(plot);\n\t\treturn jFreeChart; \n\t}", "private static JFreeChart createChart(CategoryDataset dataset) {\n JFreeChart chart = ChartFactory.createLineChart(\n \"Line Chart\", null /* x-axis label*/, \n \"Range\" /* y-axis label */, dataset);\n chart.addSubtitle(new TextTitle(\" Its is generated to show patient History \" \n ));\n chart.setBackgroundPaint(Color.white);\n CategoryPlot plot = (CategoryPlot) chart.getPlot();\n\tNumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();\n rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());\n // Line renderer = (BarRenderer) plot.getRenderer();\n // renderer.setDrawBarOutline(false);\n // LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); \n//renderer.setItemMargin(3); \n//renderer.setItemLabelsVisible(true);\n chart.getLegend().setFrame(BlockBorder.NONE);\n return chart;\n }", "@Test\n public void test39() throws Throwable {\n CategoryAxis categoryAxis0 = new CategoryAxis(\"Null 'info' argument.\");\n CombinedDomainCategoryPlot combinedDomainCategoryPlot0 = new CombinedDomainCategoryPlot(categoryAxis0);\n PlotOrientation plotOrientation0 = PlotOrientation.HORIZONTAL;\n combinedDomainCategoryPlot0.setOrientation(plotOrientation0);\n AxisChangeEvent axisChangeEvent0 = new AxisChangeEvent((Axis) categoryAxis0);\n JFreeChart jFreeChart0 = axisChangeEvent0.getChart();\n ChartRenderingInfo chartRenderingInfo0 = new ChartRenderingInfo();\n }", "@Test\n public void test02() throws Throwable {\n Rectangle2D.Double rectangle2D_Double0 = new Rectangle2D.Double(0.0, (-317.2908), (-2943.525478), 2896.89);\n TaskSeriesCollection taskSeriesCollection0 = new TaskSeriesCollection();\n CategoryAxis categoryAxis0 = new CategoryAxis();\n MultiplePiePlot multiplePiePlot0 = new MultiplePiePlot((CategoryDataset) taskSeriesCollection0);\n JFreeChart jFreeChart0 = multiplePiePlot0.getPieChart();\n ChartPanel chartPanel0 = new ChartPanel(jFreeChart0, 3, 3, (-283), (-283), 125, (-283), true, true, false, true, false, true);\n BasicTreeUI basicTreeUI0 = new BasicTreeUI();\n BasicTreeUI.NodeDimensionsHandler basicTreeUI_NodeDimensionsHandler0 = basicTreeUI0.new NodeDimensionsHandler();\n SystemColor systemColor0 = SystemColor.activeCaption;\n LineBorder lineBorder0 = new LineBorder((Color) systemColor0);\n Rectangle rectangle0 = AbstractBorder.getInteriorRectangle((Component) chartPanel0, (Border) lineBorder0, 3, 0, 44, 70);\n Rectangle rectangle1 = basicTreeUI_NodeDimensionsHandler0.getNodeDimensions(taskSeriesCollection0, 0, 1999, true, rectangle0);\n Rectangle rectangle2 = chartPanel0.getBounds((Rectangle) null);\n boolean boolean0 = rectangle2D_Double0.contains((Rectangle2D) rectangle2);\n NumberAxis numberAxis0 = new NumberAxis();\n CategoryPlot categoryPlot0 = new CategoryPlot((CategoryDataset) taskSeriesCollection0, categoryAxis0, (ValueAxis) numberAxis0, (CategoryItemRenderer) null);\n PlotRenderingInfo plotRenderingInfo0 = new PlotRenderingInfo((ChartRenderingInfo) null);\n CategoryItemRendererState categoryItemRendererState0 = new CategoryItemRendererState(plotRenderingInfo0);\n EntityCollection entityCollection0 = categoryItemRendererState0.getEntityCollection();\n ChartRenderingInfo chartRenderingInfo0 = new ChartRenderingInfo((EntityCollection) null);\n PlotRenderingInfo plotRenderingInfo1 = chartRenderingInfo0.getPlotInfo();\n MultiListUI multiListUI0 = new MultiListUI();\n StatisticalLineAndShapeRenderer[] statisticalLineAndShapeRendererArray0 = new StatisticalLineAndShapeRenderer[0];\n boolean boolean1 = plotRenderingInfo0.equals((Object) null);\n JList<StatisticalLineAndShapeRenderer> jList0 = new JList<StatisticalLineAndShapeRenderer>(statisticalLineAndShapeRendererArray0);\n // Undeclared exception!\n try { \n multiListUI0.indexToLocation(jList0, 671);\n } catch(ArrayIndexOutOfBoundsException e) {\n //\n // 0 >= 0\n //\n assertThrownBy(\"java.util.Vector\", e);\n }\n }", "@Test\n public void test01() throws Throwable {\n CategoryPlot categoryPlot0 = new CategoryPlot();\n AxisLocation axisLocation0 = AxisLocation.TOP_OR_LEFT;\n categoryPlot0.setRangeAxisLocation(axisLocation0, true);\n Layer layer0 = Layer.BACKGROUND;\n Collection collection0 = categoryPlot0.getDomainMarkers(layer0);\n LineRenderer3D lineRenderer3D0 = new LineRenderer3D();\n lineRenderer3D0.setSeriesLinesVisible(597, true);\n lineRenderer3D0.setUseOutlinePaint(true);\n categoryPlot0.setRenderer(597, (CategoryItemRenderer) lineRenderer3D0, true);\n DatasetRenderingOrder datasetRenderingOrder0 = DatasetRenderingOrder.FORWARD;\n categoryPlot0.setDatasetRenderingOrder(datasetRenderingOrder0);\n Rectangle2D.Double rectangle2D_Double0 = (Rectangle2D.Double)Plot.DEFAULT_LEGEND_ITEM_BOX;\n double double0 = rectangle2D_Double0.getY();\n boolean boolean0 = categoryPlot0.isRangeGridlinesVisible();\n BasicStroke basicStroke0 = (BasicStroke)categoryPlot0.getRangeGridlineStroke();\n CategoryAxis[] categoryAxisArray0 = new CategoryAxis[0];\n categoryPlot0.setDomainAxes(categoryAxisArray0);\n ChartRenderingInfo chartRenderingInfo0 = new ChartRenderingInfo();\n PlotRenderingInfo plotRenderingInfo0 = new PlotRenderingInfo(chartRenderingInfo0);\n MultiplePiePlot multiplePiePlot0 = new MultiplePiePlot();\n JFreeChart jFreeChart0 = multiplePiePlot0.getPieChart();\n ChartPanel chartPanel0 = new ChartPanel(jFreeChart0);\n MenuElement[] menuElementArray0 = new MenuElement[2];\n JPopupMenu jPopupMenu0 = new JPopupMenu();\n menuElementArray0[0] = (MenuElement) jPopupMenu0;\n JFrame jFrame0 = null;\n try {\n jFrame0 = new JFrame();\n } catch(HeadlessException e) {\n //\n // no message in exception (getMessage() returned null)\n //\n assertThrownBy(\"java.awt.GraphicsEnvironment\", e);\n }\n }", "@Test\n public void test62() throws Throwable {\n Rectangle2D.Double rectangle2D_Double0 = new Rectangle2D.Double(0.0, 0.0, 1000000.0, 500000.0);\n CombinedDomainCategoryPlot combinedDomainCategoryPlot0 = new CombinedDomainCategoryPlot();\n RectangleInsets rectangleInsets0 = Title.DEFAULT_PADDING;\n LengthAdjustmentType lengthAdjustmentType0 = LengthAdjustmentType.EXPAND;\n Rectangle2D.Double rectangle2D_Double1 = (Rectangle2D.Double)rectangleInsets0.createInsetRectangle((Rectangle2D) rectangle2D_Double0, false, false);\n boolean boolean0 = rectangle2D_Double0.contains((Rectangle2D) rectangle2D_Double1);\n rectangle2D_Double0.add(1000000.0, 0.0);\n Rectangle2D.Double rectangle2D_Double2 = (Rectangle2D.Double)rectangleInsets0.createAdjustedRectangle(rectangle2D_Double0, lengthAdjustmentType0, lengthAdjustmentType0);\n combinedDomainCategoryPlot0.setAxisOffset(rectangleInsets0);\n combinedDomainCategoryPlot0.configureDomainAxes();\n CategoryItemRenderer categoryItemRenderer0 = combinedDomainCategoryPlot0.getRenderer(3);\n boolean boolean1 = combinedDomainCategoryPlot0.getDrawSharedDomainAxis();\n double double0 = rectangle2D_Double0.getWidth();\n combinedDomainCategoryPlot0.clearDomainAxes();\n ValueAxis valueAxis0 = combinedDomainCategoryPlot0.getRangeAxisForDataset(3);\n LongNeedle longNeedle0 = new LongNeedle();\n AffineTransform affineTransform0 = longNeedle0.getTransform();\n Font font0 = LegendTitle.DEFAULT_ITEM_FONT;\n JFreeChart jFreeChart0 = new JFreeChart(\"\", font0, (Plot) combinedDomainCategoryPlot0, false);\n RenderingHints renderingHints0 = jFreeChart0.getRenderingHints();\n AffineTransformOp affineTransformOp0 = new AffineTransformOp(affineTransform0, renderingHints0);\n ChartRenderingInfo chartRenderingInfo0 = new ChartRenderingInfo();\n // Undeclared exception!\n try { \n jFreeChart0.createBufferedImage(262, 285, 262, chartRenderingInfo0);\n } catch(IllegalArgumentException e) {\n //\n // Unknown image type 262\n //\n assertThrownBy(\"java.awt.image.BufferedImage\", e);\n }\n }", "@Test\n public void test01() throws Throwable {\n SimpleTimeZone simpleTimeZone0 = (SimpleTimeZone)SegmentedTimeline.NO_DST_TIME_ZONE;\n DateAxis dateAxis0 = new DateAxis(\"\", (TimeZone) simpleTimeZone0);\n CombinedRangeCategoryPlot combinedRangeCategoryPlot0 = new CombinedRangeCategoryPlot((ValueAxis) dateAxis0);\n ZoneInfo zoneInfo0 = (ZoneInfo)TimeZone.getDefault();\n JFreeChart jFreeChart0 = new JFreeChart(\"The renderer has changed and I don't know what to do!\", (Plot) combinedRangeCategoryPlot0);\n ChartPanel chartPanel0 = new ChartPanel(jFreeChart0, (-1747), (-1747), 952, 952, 0, 855, true, false, false, true, true, false);\n ChartRenderingInfo chartRenderingInfo0 = chartPanel0.getChartRenderingInfo();\n PlotRenderingInfo plotRenderingInfo0 = new PlotRenderingInfo(chartRenderingInfo0);\n Point2D.Double point2D_Double0 = new Point2D.Double();\n combinedRangeCategoryPlot0.zoomDomainAxes(0.0, plotRenderingInfo0, (Point2D) point2D_Double0, false);\n double double0 = point2D_Double0.getX();\n Rectangle2D.Double rectangle2D_Double0 = new Rectangle2D.Double(0.0, 1794.185816547, (double) 0, (double) (-1747));\n double double1 = rectangle2D_Double0.x;\n DefaultPolarItemRenderer defaultPolarItemRenderer0 = new DefaultPolarItemRenderer();\n Color color0 = (Color)defaultPolarItemRenderer0.getBaseOutlinePaint();\n BasicStroke basicStroke0 = (BasicStroke)WaferMapPlot.DEFAULT_GRIDLINE_STROKE;\n CategoryMarker categoryMarker0 = new CategoryMarker((Comparable) 0.0, (Paint) color0, (Stroke) basicStroke0);\n Layer layer0 = Layer.BACKGROUND;\n combinedRangeCategoryPlot0.addRangeMarker((Marker) categoryMarker0, layer0);\n combinedRangeCategoryPlot0.setDomainGridlinePaint(color0);\n double double2 = rectangle2D_Double0.getWidth();\n }", "ChartPackage getChartPackage();", "public JFreeChart getPieChart(String start, String end) throws CostManagerException;", "private static JFreeChart createChart(XYDataset dataset) {\n\n chart = ChartFactory.createTimeSeriesChart(\n \"Stromzählerübersicht\", // Titel\n \"Datum\", // x-Achse label\n \"kWh\", // y-Achse label\n dataset);\n\n chart.setBackgroundPaint(Color.WHITE);\n\n XYPlot plot = (XYPlot) chart.getPlot();\n plot.setBackgroundPaint(Color.LIGHT_GRAY);\n plot.setDomainGridlinePaint(Color.WHITE);\n plot.setRangeGridlinePaint(Color.WHITE);\n plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));\n plot.setDomainCrosshairVisible(true);\n plot.setRangeCrosshairVisible(true);\n\n XYItemRenderer r = plot.getRenderer();\n if (r instanceof XYLineAndShapeRenderer) {\n XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;\n renderer.setDefaultShapesVisible(false);\n renderer.setDefaultShapesFilled(false);\n renderer.setDrawSeriesLineAsPath(true);\n }\n\n DateAxis axis = (DateAxis) plot.getDomainAxis();\n axis.setDateFormatOverride(new SimpleDateFormat(\"dd-MM-yyyy\"));\n\n return chart;\n\n }", "public void chart() {\r\n setLayout(new FlowLayout());\r\n String[] testNumbers = {\"LINEAR SEARCH\", \"TEST 1\", \"TEST 2\", \"TEST 3\", \"TEST 4\", \"TEST 5\", \"TEST 6\", \"TEST 7\", \"TEST 8\", \"TEST 9\", \"TEST 10\", \"AVERAGE\", \"STANDARD DEV.\"};\r\n Object[][] testResult = {{\"500\", lin[0][0], lin[0][1], lin[0][2], lin[0][3], lin[0][4], lin[0][5], lin[0][6], lin[0][7], lin[0][8], lin[0][0], linAvAndDev[0][0], linAvAndDev[0][1]},\r\n {\"10,000\", lin[1][0], lin[1][1], lin[1][2], lin[1][3], lin[1][4], lin[1][5], lin[1][6], lin[1][7], lin[1][8], lin[1][9], linAvAndDev[1][0], linAvAndDev[1][1]},\r\n {\"100,000\", lin[2][0], lin[2][1], lin[2][2], lin[2][3], lin[2][4], lin[2][5], lin[2][6], lin[2][7], lin[2][8], lin[2][9], linAvAndDev[2][0], linAvAndDev[2][1]},\r\n {\"1,000,000\", lin[3][0], lin[3][1], lin[3][2], lin[3][3], lin[3][4], lin[3][5], lin[3][6], lin[3][7], lin[3][8], lin[3][9], linAvAndDev[3][0], linAvAndDev[3][1]},\r\n {\"5,000,000\", lin[4][0], lin[4][1], lin[4][2], lin[4][3], lin[4][4], lin[4][5], lin[4][6], lin[4][7], lin[4][8], lin[4][9], linAvAndDev[4][0], linAvAndDev[4][1]},\r\n {\"7,000,000\", lin[5][0], lin[5][1], lin[5][2], lin[5][3], lin[5][4], lin[5][5], lin[5][6], lin[5][7], lin[5][8], lin[5][9], linAvAndDev[5][0], linAvAndDev[5][1]},\r\n {\"10,000,000\", lin[6][0], lin[6][1], lin[6][2], lin[6][3], lin[6][4], lin[6][5], lin[6][6], lin[6][7], lin[6][8], lin[6][9], linAvAndDev[6][0], linAvAndDev[6][1]},\r\n {\"BINARY SEARCH\", \"TEST 1\", \"TEST 2\", \"TEST 3\", \"TEST 4\", \"TEST 5\", \"TEST 6\", \"TEST 7\", \"TEST 8\", \"TEST 9\", \"TEST 10\", \"AVERAGE\", \"STANDARD DEV.\"},\r\n {\"500\", bin[0][0], bin[0][1], bin[0][2], bin[0][3], bin[0][4], bin[0][5], bin[0][6], bin[0][7], bin[0][8], bin[0][9], linAvAndDev[7][0], linAvAndDev[7][1]},\r\n {\"10,000\", bin[1][0], bin[1][1], bin[1][2], bin[1][3], bin[1][4], bin[1][5], bin[1][6], bin[1][7], bin[1][8], bin[1][9], linAvAndDev[8][0], linAvAndDev[8][1]},\r\n {\"100,000\", bin[2][0], bin[2][1], bin[2][2], bin[2][3], bin[2][4], bin[2][5], bin[2][6], bin[2][7], bin[2][8], bin[2][9], linAvAndDev[9][0], linAvAndDev[9][1]},\r\n {\"1,000,000\", bin[3][0], bin[3][1], bin[3][2], bin[3][3], bin[3][4], bin[3][5], bin[3][6], bin[3][7], bin[3][8], bin[3][9], linAvAndDev[10][0], linAvAndDev[10][1]},\r\n {\"5,000,000\", bin[4][0], bin[4][1], bin[4][2], bin[4][3], bin[4][4], bin[4][5], bin[4][6], bin[4][7], bin[4][8], bin[4][9], linAvAndDev[11][0], linAvAndDev[11][1]},\r\n {\"7,000,000\", bin[5][0], bin[5][1], bin[5][2], bin[5][3], bin[5][4], bin[5][5], bin[5][6], bin[5][7], bin[5][8], bin[5][9], linAvAndDev[12][0], linAvAndDev[12][1]},\r\n {\"10,000,000\", bin[6][0], bin[6][1], bin[6][2], bin[6][3], bin[6][4], bin[6][5], bin[6][6], bin[6][7], bin[6][8], bin[6][9], linAvAndDev[13][0], linAvAndDev[13][1]}};\r\n chart = new JTable(testResult, testNumbers);\r\n chart.setPreferredScrollableViewportSize(new Dimension(1500, 500)); // SETS SIZE OF CHART.\r\n chart.setFillsViewportHeight(true);\r\n JScrollPane scrollPane = new JScrollPane(chart);\r\n add(scrollPane);\r\n }", "public interface ChartGenerator {\n /**\n * 生成jfreechart对象\n * @param list\n * @param title\n * @param chartType\n * @return\n * @throws Exception\n */\n public JFreeChart generateChart(List<ChartPoint> list\n , String title\n , ChartTypeEnum chartType) throws Exception;\n\n /**\n * 得到折线图的折点数据列表\n * @param events\n * @param begin\n * @param end\n * @param dataType\n * @return\n */\n public List<ChartPoint> getChartPoints(List<DailyEvent> events, long begin, long end, ChartDataTypeEnum dataType);\n\n /**\n * 将jfreechart 转换为base64编码的字符串\n * @param chart\n * @return\n * @throws Exception\n */\n public String chartToBASE64(JFreeChart chart) throws Exception;\n}", "@Test\n public void test63() throws Throwable {\n CombinedDomainCategoryPlot combinedDomainCategoryPlot0 = new CombinedDomainCategoryPlot((CategoryAxis) null);\n boolean boolean0 = combinedDomainCategoryPlot0.isRangeZoomable();\n boolean boolean1 = combinedDomainCategoryPlot0.isRangeGridlinesVisible();\n boolean boolean2 = combinedDomainCategoryPlot0.getDrawSharedDomainAxis();\n Layer layer0 = Layer.BACKGROUND;\n DeviationRenderer deviationRenderer0 = new DeviationRenderer(true, true);\n DrawingSupplier drawingSupplier0 = deviationRenderer0.getDrawingSupplier();\n combinedDomainCategoryPlot0.setDrawingSupplier((DrawingSupplier) null);\n Collection collection0 = combinedDomainCategoryPlot0.getRangeMarkers(2526, layer0);\n CategoryAxis categoryAxis0 = combinedDomainCategoryPlot0.getDomainAxis(2526);\n combinedDomainCategoryPlot0.configureDomainAxes();\n ChartRenderingInfo chartRenderingInfo0 = new ChartRenderingInfo();\n PlotRenderingInfo plotRenderingInfo0 = new PlotRenderingInfo(chartRenderingInfo0);\n CategoryItemRendererState categoryItemRendererState0 = new CategoryItemRendererState(plotRenderingInfo0);\n StandardEntityCollection standardEntityCollection0 = (StandardEntityCollection)categoryItemRendererState0.getEntityCollection();\n ChartRenderingInfo chartRenderingInfo1 = new ChartRenderingInfo((EntityCollection) standardEntityCollection0);\n PlotRenderingInfo plotRenderingInfo1 = chartRenderingInfo1.getPlotInfo();\n Number[][] numberArray0 = new Number[8][4];\n Number[] numberArray1 = new Number[1];\n float float0 = Component.BOTTOM_ALIGNMENT;\n numberArray1[0] = (Number) 1.0F;\n numberArray0[0] = numberArray1;\n Number[] numberArray2 = new Number[7];\n double double0 = PiePlot.DEFAULT_START_ANGLE;\n numberArray2[0] = (Number) 90.0;\n int int0 = ColorSpace.TYPE_BCLR;\n numberArray2[1] = (Number) 21;\n int int1 = Calendar.OCTOBER;\n numberArray2[2] = (Number) 9;\n int int2 = AffineTransform.TYPE_GENERAL_ROTATION;\n numberArray2[3] = (Number) 16;\n int int3 = PageFormat.LANDSCAPE;\n numberArray2[4] = (Number) 0;\n int int4 = ObjectStreamConstants.PROTOCOL_VERSION_2;\n numberArray2[5] = (Number) 2;\n int int5 = ColorSpace.TYPE_8CLR;\n numberArray2[6] = (Number) 18;\n numberArray0[1] = numberArray2;\n Number[] numberArray3 = new Number[1];\n int int6 = ColorSpace.CS_LINEAR_RGB;\n numberArray3[0] = (Number) 1004;\n numberArray0[2] = numberArray3;\n Number[] numberArray4 = new Number[0];\n numberArray0[3] = numberArray4;\n Number[] numberArray5 = new Number[2];\n int int7 = ColorSpace.TYPE_RGB;\n numberArray5[0] = (Number) 5;\n Integer integer0 = JLayeredPane.DRAG_LAYER;\n numberArray5[1] = (Number) integer0;\n numberArray0[4] = numberArray5;\n Number[] numberArray6 = new Number[6];\n numberArray6[0] = (Number) integer0;\n numberArray6[1] = (Number) integer0;\n numberArray6[2] = (Number) integer0;\n numberArray6[3] = (Number) integer0;\n numberArray6[4] = (Number) integer0;\n numberArray6[5] = (Number) integer0;\n numberArray0[5] = numberArray6;\n Number[] numberArray7 = new Number[0];\n numberArray0[6] = numberArray7;\n Number[] numberArray8 = new Number[2];\n numberArray8[0] = (Number) integer0;\n numberArray8[1] = (Number) integer0;\n numberArray0[7] = numberArray8;\n DefaultIntervalCategoryDataset defaultIntervalCategoryDataset0 = new DefaultIntervalCategoryDataset(numberArray0, numberArray0);\n TableOrder tableOrder0 = TableOrder.BY_COLUMN;\n SpiderWebPlot spiderWebPlot0 = new SpiderWebPlot((CategoryDataset) defaultIntervalCategoryDataset0, tableOrder0);\n ThermometerPlot thermometerPlot0 = new ThermometerPlot((ValueDataset) null);\n RectangleInsets rectangleInsets0 = thermometerPlot0.getPadding();\n Rectangle2D.Float rectangle2D_Float0 = new Rectangle2D.Float((float) 21, 0.95F, 0.6F, (-170.0F));\n Rectangle2D.Double rectangle2D_Double0 = (Rectangle2D.Double)rectangleInsets0.createOutsetRectangle((Rectangle2D) rectangle2D_Float0);\n Point2D.Double point2D_Double0 = (Point2D.Double)spiderWebPlot0.getWebPoint(rectangle2D_Double0, 21.0F, 3215.444465);\n combinedDomainCategoryPlot0.zoomRangeAxes((double) 2526, plotRenderingInfo1, (Point2D) point2D_Double0);\n }", "public static JFreeChart createChart(final CategoryDataset dataset) {\n \n // create the chart...\n final JFreeChart chart = ChartFactory.createLineChart(\n \"Line Chart\", // chart title\n \"Type\", // domain axis label\n \"Value\", // range axis label\n dataset, // data\n PlotOrientation.VERTICAL, // orientation\n true, // include legend\n true, // tooltips\n false // urls\n );\n\n // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...\n //final StandardLegend legend = (StandardLegend) chart.getLegend();\n //legend.setDisplaySeriesShapes(true);\n //legend.setShapeScaleX(1.5);\n //legend.setShapeScaleY(1.5);\n //legend.setDisplaySeriesLines(true);\n\n chart.setBackgroundPaint(Color.white);\n\n final CategoryPlot plot = (CategoryPlot) chart.getPlot();\n plot.setBackgroundPaint(Color.lightGray);\n plot.setRangeGridlinePaint(Color.white);\n\n // customise the range axis...\n final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();\n rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());\n rangeAxis.setAutoRangeIncludesZero(true);\n\n \n \n \n // customise the renderer...\n final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();\n //renderer.setDrawShapes(true);\n\n renderer.setSeriesStroke(\n 0, new BasicStroke(\n 2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,\n 1.0f, new float[] {10.0f, 6.0f}, 0.0f\n )\n );\n renderer.setSeriesStroke(\n 1, new BasicStroke(\n 2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,\n 1.0f, new float[] {6.0f, 6.0f}, 0.0f\n )\n );\n renderer.setSeriesStroke(\n 2, new BasicStroke(\n 2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,\n 1.0f, new float[] {2.0f, 6.0f}, 0.0f\n )\n );\n // OPTIONAL CUSTOMISATION COMPLETED.\n \n return chart;\n }", "@Override\r\n\tprotected void generateChart() throws Exception {\n\t\t\r\n\t}", "@Override\n public void initialize(URL url, ResourceBundle rb) { \n \n XYChart.Series series = new XYChart.Series<>();\n \n \n series.setName(\"Gagnant\");\n series.getData().add(new XYChart.Data(\"Jan\", 100));\n series.getData().add(new XYChart.Data(\"Fev\", 170));\n series.getData().add(new XYChart.Data(\"Mars\", 197));\n series.getData().add(new XYChart.Data(\"Avr\", 160));\n series.getData().add(new XYChart.Data(\"Mai\", 165));\n series.getData().add(new XYChart.Data(\"Juin\", 179));\n series.getData().add(new XYChart.Data(\"Juil\", 195));\n series.getData().add(new XYChart.Data(\"Aout\", 140));\n series.getData().add(new XYChart.Data(\"Sept\", 121));\n series.getData().add(new XYChart.Data(\"Oct\", 173));\n series.getData().add(new XYChart.Data(\"Nov\", 185));\n series.getData().add(new XYChart.Data(\"Dec\", 150));\n \n XYChart.Series perdant = new XYChart.Series<>();\n perdant.setName(\"Perdant\");\n \n perdant.getData().add(new XYChart.Data(\"Jan\", 80));\n perdant.getData().add(new XYChart.Data(\"Fev\", 60));\n perdant.getData().add(new XYChart.Data(\"Mars\", 80));\n perdant.getData().add(new XYChart.Data(\"Avr\", 70));\n perdant.getData().add(new XYChart.Data(\"Mai\", 70));\n perdant.getData().add(new XYChart.Data(\"Juin\", 60));\n perdant.getData().add(new XYChart.Data(\"Juil\", 100));\n perdant.getData().add(new XYChart.Data(\"Aout\", 80));\n perdant.getData().add(new XYChart.Data(\"Sept\", 50));\n perdant.getData().add(new XYChart.Data(\"Oct\", 79));\n perdant.getData().add(new XYChart.Data(\"Nov\", 70));\n perdant.getData().add(new XYChart.Data(\"Dec\", 12));\n \n\n Tooltip tooltip = new Tooltip(\"Le nombre de gagnants ou cours des mois augmentent souvent.\");\n areaChart.getStylesheets().add(\"-fx-color:green;\");\n areaChart.getData().addAll(series, perdant);\n BarChart.getStylesheets().add(\"chart-bar series<1> bar-legend-symbol default-color<red>\");\n BarChart.getData().addAll(perdant);\n\n\n }", "@Test\n public void test32() throws Throwable {\n CategoryAxis categoryAxis0 = new CategoryAxis(\"\");\n Font font0 = categoryAxis0.getTickLabelFont();\n LongNeedle longNeedle0 = new LongNeedle();\n AffineTransform affineTransform0 = longNeedle0.getTransform();\n Font font1 = font0.deriveFont(76, affineTransform0);\n CombinedRangeCategoryPlot combinedRangeCategoryPlot0 = new CombinedRangeCategoryPlot();\n JFreeChart jFreeChart0 = new JFreeChart(\"The renderer has changed and I don't know what to do!\", font1, (Plot) combinedRangeCategoryPlot0, false);\n CombinedRangeCategoryPlot combinedRangeCategoryPlot1 = (CombinedRangeCategoryPlot)jFreeChart0.getCategoryPlot();\n AxisLocation axisLocation0 = AxisLocation.TOP_OR_RIGHT;\n AxisLocation axisLocation1 = axisLocation0.getOpposite();\n AxisLocation axisLocation2 = axisLocation0.getOpposite();\n List list0 = combinedRangeCategoryPlot1.getCategoriesForAxis(categoryAxis0);\n jFreeChart0.setSubtitles(list0);\n combinedRangeCategoryPlot1.setRangeAxisLocation(axisLocation1);\n Rectangle2D.Double rectangle2D_Double0 = (Rectangle2D.Double)Plot.DEFAULT_LEGEND_ITEM_BOX;\n rectangle2D_Double0.setRect(483.0, 483.0, 483.0, 483.0);\n }", "@Test\n public void test51() throws Throwable {\n DefaultBoxAndWhiskerCategoryDataset defaultBoxAndWhiskerCategoryDataset0 = new DefaultBoxAndWhiskerCategoryDataset();\n CategoryAxis categoryAxis0 = new CategoryAxis();\n ZoneInfo zoneInfo0 = (ZoneInfo)TimeZone.getTimeZone(\"S0;<fg/hGr_<T\");\n DateAxis dateAxis0 = new DateAxis(\"+7SK1xz+\", (TimeZone) zoneInfo0);\n GroupedStackedBarRenderer groupedStackedBarRenderer0 = new GroupedStackedBarRenderer();\n CategoryPlot categoryPlot0 = new CategoryPlot((CategoryDataset) defaultBoxAndWhiskerCategoryDataset0, categoryAxis0, (ValueAxis) dateAxis0, (CategoryItemRenderer) groupedStackedBarRenderer0);\n JFreeChart jFreeChart0 = new JFreeChart((String) null, (Plot) categoryPlot0);\n ChartPanel chartPanel0 = new ChartPanel(jFreeChart0, 1551, 0, 1551, (-1157), 1551, 0, true, true, false, true, true, true);\n ChartRenderingInfo chartRenderingInfo0 = chartPanel0.getChartRenderingInfo();\n PlotRenderingInfo plotRenderingInfo0 = chartRenderingInfo0.getPlotInfo();\n String[] stringArray0 = new String[4];\n stringArray0[0] = \"S0;<fg/hGr_<T\";\n stringArray0[1] = \"+7SK1xz+\";\n stringArray0[2] = null;\n stringArray0[3] = \"S0;<fg/hGr_<T\";\n JFreeChart.main(stringArray0);\n Arc2D.Double arc2D_Double0 = new Arc2D.Double(0.0, 5504.00353418296, 2252.7, 5504.00353418296, (-44.30819825288613), (-2488.2967568), 0);\n Point2D.Double point2D_Double0 = (Point2D.Double)arc2D_Double0.getEndPoint();\n // Undeclared exception!\n try { \n categoryPlot0.zoomRangeAxes(5504.00353418296, 2252.7, plotRenderingInfo0, (Point2D) point2D_Double0);\n } catch(IllegalArgumentException e) {\n //\n // Range(double, double): require lower (11007.0) <= upper (4504.0).\n //\n assertThrownBy(\"org.jfree.data.Range\", e);\n }\n }", "public static JFreeChart createTimeSeriesChart (String xAxisTitle,\n String yAxisTitle,\n XYDataset tsc)\n {\n JFreeChart chart = ChartFactory.createTimeSeriesChart (null,\n xAxisTitle,\n yAxisTitle,\n tsc,\n true,\n true,\n true);\n\n XYPlot xyplot = (XYPlot) chart.getPlot ();\n xyplot.setBackgroundPaint (UIUtils.getComponentColor ());\n xyplot.setDomainGridlinePaint (UIUtils.getBorderColor ());\n xyplot.setRangeGridlinePaint (UIUtils.getBorderColor ());\n /*\n xyplot.setAxisOffset (new RectangleInsets (5D,\n 5D,\n 5D,\n 5D));\n */\n xyplot.setDomainCrosshairVisible (true);\n xyplot.setRangeCrosshairVisible (true);\n xyplot.setDomainGridlinePaint (UIUtils.getColor (\"#cfcfcf\"));\n xyplot.setRangeGridlinePaint (UIUtils.getColor (\"#cfcfcf\"));\n\n final SimpleDateFormat dateFormat = new SimpleDateFormat (\"dd MMM yyyy\");\n\n ((NumberAxis) xyplot.getRangeAxis ()).setNumberFormatOverride (Environment.getNumberFormatter ());\n\n XYLineAndShapeRenderer xyitemrenderer = new XYLineAndShapeRenderer (true,\n true);\n xyitemrenderer.setUseFillPaint (true);\n\n XYToolTipGenerator ttgen = new StandardXYToolTipGenerator ()\n {\n\n public String generateToolTip (XYDataset dataset,\n int series,\n int item)\n {\n\n TimeSeriesCollection tsc = (TimeSeriesCollection) dataset;\n\n TimeSeries ts = tsc.getSeries (series);\n\n Number n = ts.getValue (item);\n Number p = Integer.valueOf (0);\n\n if (item > 0)\n {\n\n p = ts.getValue (item - 1);\n\n }\n\n String suff = \"\";\n int v = n.intValue () - p.intValue ();\n\n if (v != 0)\n {\n\n String sufftype = added;\n int val = v;\n\n if (v < 0)\n {\n\n sufftype = removed;\n val *= -1;\n\n }\n\n suff = String.format (getUIString (charts,timeseries,suffixes,sufftype),\n Environment.formatNumber (val));\n\n }\n\n return String.format (getUIString (charts,timeseries,tooltip),\n dateFormat.format (ts.getTimePeriod (item).getEnd ()),\n Environment.formatNumber (n.intValue ()),\n suff);\n\n }\n\n };\n\n xyplot.setRenderer (xyitemrenderer);\n\n List colors = new ArrayList ();\n colors.add (UIUtils.getColor (\"#f5b800\"));\n colors.add (UIUtils.getColor (\"#7547ff\"));\n colors.add (UIUtils.getColor (\"#9c4f4f\"));\n colors.add (UIUtils.getColor (\"#99cc99\"));\n colors.add (UIUtils.getColor (\"#cc6600\"));\n\n for (int i = 0; i < tsc.getSeriesCount (); i++)\n {\n\n if (i < (colors.size () - 1))\n {\n\n xyitemrenderer.setSeriesPaint (i,\n (Color) colors.get (i));\n\n }\n\n xyitemrenderer.setSeriesStroke (i,\n new java.awt.BasicStroke (2f));\n xyitemrenderer.setSeriesShapesFilled (i,\n true);\n xyitemrenderer.setSeriesToolTipGenerator (i,\n ttgen);\n xyitemrenderer.setSeriesShape (i,\n new java.awt.geom.Ellipse2D.Float (-3,\n -3,\n 6,\n 6));\n /*\n if (i > 0)\n {\n\n xyitemrenderer.setSeriesShape (i,\n xyitemrenderer.lookupSeriesShape (0));\n\n }\n */\n }\n\n PeriodAxis periodaxis = new PeriodAxis (xAxisTitle);\n\n periodaxis.setAutoRangeTimePeriodClass (Day.class);\n\n PeriodAxisLabelInfo[] aperiodaxislabelinfo = new PeriodAxisLabelInfo[3];\n aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo (Day.class,\n new SimpleDateFormat (\"d\"));\n aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo (Month.class,\n new SimpleDateFormat (\"MMM\"));\n aperiodaxislabelinfo[2] = new PeriodAxisLabelInfo (Year.class,\n new SimpleDateFormat (\"yyyy\"));\n periodaxis.setLabelInfo (aperiodaxislabelinfo);\n xyplot.setDomainAxis (periodaxis);\n\n return chart;\n\n }", "@Test\n public void test28() throws Throwable {\n double[][] doubleArray0 = new double[4][3];\n double[] doubleArray1 = new double[0];\n doubleArray0[0] = doubleArray1;\n double[] doubleArray2 = new double[1];\n doubleArray2[0] = 4394.831255689545;\n doubleArray0[1] = doubleArray2;\n double[] doubleArray3 = new double[5];\n doubleArray3[0] = 4394.831255689545;\n doubleArray3[1] = 4394.831255689545;\n doubleArray3[2] = 4394.831255689545;\n doubleArray3[3] = 4394.831255689545;\n doubleArray0[2] = doubleArray3;\n double[] doubleArray4 = new double[3];\n doubleArray4[0] = 4394.831255689545;\n doubleArray4[1] = 4394.831255689545;\n doubleArray0[3] = doubleArray4;\n DefaultIntervalCategoryDataset defaultIntervalCategoryDataset0 = new DefaultIntervalCategoryDataset(doubleArray0, doubleArray0);\n CategoryAxis3D categoryAxis3D0 = new CategoryAxis3D(\"org.jfree.data.xy.DefaultWindDataset\");\n Month month0 = new Month();\n ZoneOffset zoneOffset0 = ZoneOffset.MAX;\n ZoneInfo zoneInfo0 = (ZoneInfo)TimeZone.getTimeZone((ZoneId) zoneOffset0);\n PeriodAxis periodAxis0 = new PeriodAxis(\"'Ypi)?q\", (RegularTimePeriod) month0, (RegularTimePeriod) month0, (TimeZone) zoneInfo0);\n LayeredBarRenderer layeredBarRenderer0 = new LayeredBarRenderer();\n CategoryPlot categoryPlot0 = new CategoryPlot((CategoryDataset) defaultIntervalCategoryDataset0, (CategoryAxis) categoryAxis3D0, (ValueAxis) periodAxis0, (CategoryItemRenderer) layeredBarRenderer0);\n ChartRenderingInfo chartRenderingInfo0 = new ChartRenderingInfo();\n PlotRenderingInfo plotRenderingInfo0 = new PlotRenderingInfo(chartRenderingInfo0);\n CategoryItemRendererState categoryItemRendererState0 = new CategoryItemRendererState(plotRenderingInfo0);\n StandardEntityCollection standardEntityCollection0 = (StandardEntityCollection)categoryItemRendererState0.getEntityCollection();\n ChartRenderingInfo chartRenderingInfo1 = new ChartRenderingInfo((EntityCollection) standardEntityCollection0);\n PlotRenderingInfo plotRenderingInfo1 = chartRenderingInfo1.getPlotInfo();\n categoryPlot0.zoomRangeAxes(4394.831255689545, plotRenderingInfo1, (Point2D) null, false);\n }", "@Test\n public void test82() throws Throwable {\n DefaultValueDataset defaultValueDataset0 = new DefaultValueDataset(10.0);\n MeterPlot meterPlot0 = new MeterPlot((ValueDataset) defaultValueDataset0);\n JFreeChart jFreeChart0 = new JFreeChart(\"8BNI=Ry\", (Plot) meterPlot0);\n CombinedRangeCategoryPlot combinedRangeCategoryPlot0 = new CombinedRangeCategoryPlot();\n BasicStroke basicStroke0 = (BasicStroke)combinedRangeCategoryPlot0.getDomainGridlineStroke();\n }", "ArrayList<JFreeChart> generateAll();", "public void View()\n\t{\n\t\tDefaultPieDataset pieDataset = new DefaultPieDataset();\n\t\t\n\t\tfor(String key : result.keySet())\n\t\t{\n\t\t\tpieDataset.setValue(key, Double.parseDouble(result.get(key).toString()));\n\t\t}\n\t\t\n\t\tJFreeChart chart = ChartFactory.createPieChart(title, pieDataset, true, true, true);\n\t\t\n\t\tChartFrame frame = new ChartFrame(\"Pie Chart\", chart);\n\t\t\n\t\tframe.setVisible(true);\n\t\tframe.setSize(450,500);\n\t}", "public static void main(String[] args) {\r\n MinMaxCategoryPlotDemo1 demo = new MinMaxCategoryPlotDemo1(\r\n \"JFreeChart: MinMaxCategoryPlotDemo1.java\");\r\n demo.pack();\r\n RefineryUtilities.centerFrameOnScreen(demo);\r\n demo.setVisible(true);\r\n }", "public JFreeChart getChart() {\n return chart;\n }", "@Test\n public void test84() throws Throwable {\n Point2D.Double point2D_Double0 = new Point2D.Double();\n point2D_Double0.setLocation(0.0, 0.0);\n CategoryAxis categoryAxis0 = new CategoryAxis(\"\");\n CombinedDomainCategoryPlot combinedDomainCategoryPlot0 = new CombinedDomainCategoryPlot(categoryAxis0);\n DefaultPolarItemRenderer defaultPolarItemRenderer0 = new DefaultPolarItemRenderer();\n Color color0 = (Color)defaultPolarItemRenderer0.getItemLabelPaint(871, (-1498));\n Number[][] numberArray0 = new Number[5][3];\n Number[] numberArray1 = new Number[2];\n int int0 = Calendar.LONG_FORMAT;\n numberArray1[0] = (Number) 2;\n int int1 = Float.SIZE;\n numberArray1[1] = (Number) 32;\n numberArray0[0] = numberArray1;\n Number[] numberArray2 = new Number[4];\n numberArray2[0] = (Number) 0.0;\n numberArray2[1] = (Number) 0.0;\n numberArray2[2] = (Number) 0.0;\n numberArray2[3] = (Number) 0.0;\n numberArray0[1] = numberArray2;\n Number[] numberArray3 = new Number[1];\n numberArray3[0] = (Number) 0.0;\n numberArray0[2] = numberArray3;\n Number[] numberArray4 = new Number[7];\n numberArray4[0] = (Number) 0.0;\n long long0 = XYBubbleRenderer.serialVersionUID;\n numberArray4[1] = (Number) (-5221991598674249125L);\n numberArray4[2] = (Number) 0.0;\n numberArray4[3] = (Number) 0.0;\n numberArray4[4] = (Number) 0.0;\n int int2 = JDesktopPane.LIVE_DRAG_MODE;\n numberArray4[5] = (Number) 0;\n numberArray4[6] = (Number) 0.0;\n numberArray0[3] = numberArray4;\n Number[] numberArray5 = new Number[9];\n numberArray5[0] = (Number) 0.0;\n numberArray5[1] = (Number) 0.0;\n numberArray5[2] = (Number) 0.0;\n numberArray5[3] = (Number) 0.0;\n numberArray5[4] = (Number) 0.0;\n numberArray5[5] = (Number) 0.0;\n numberArray5[6] = (Number) 0.0;\n numberArray5[7] = (Number) 0.0;\n int int3 = SwingConstants.HORIZONTAL;\n numberArray5[8] = (Number) 0;\n numberArray0[4] = numberArray5;\n DefaultIntervalCategoryDataset defaultIntervalCategoryDataset0 = new DefaultIntervalCategoryDataset(numberArray0, numberArray0);\n LogarithmicAxis logarithmicAxis0 = new LogarithmicAxis(\"org.jfree.data.ComparableObjectItem\");\n LineAndShapeRenderer lineAndShapeRenderer0 = new LineAndShapeRenderer();\n CategoryPlot categoryPlot0 = null;\n try {\n categoryPlot0 = new CategoryPlot((CategoryDataset) defaultIntervalCategoryDataset0, categoryAxis0, (ValueAxis) logarithmicAxis0, (CategoryItemRenderer) lineAndShapeRenderer0);\n } catch(ArrayIndexOutOfBoundsException e) {\n //\n // 1\n //\n assertThrownBy(\"org.jfree.data.category.DefaultIntervalCategoryDataset\", e);\n }\n }", "@Test\n public void test05() throws Throwable {\n CategoryPlot categoryPlot0 = new CategoryPlot();\n List list0 = categoryPlot0.getAnnotations();\n JFreeChart jFreeChart0 = new JFreeChart((Plot) categoryPlot0);\n categoryPlot0.removeChangeListener(jFreeChart0);\n LogAxis logAxis0 = new LogAxis(\"\");\n categoryPlot0.setRangeAxis(0, (ValueAxis) logAxis0, false);\n Line2D.Double line2D_Double0 = new Line2D.Double(2679.0111898666, 0.0, 0.0, 1.0);\n double double0 = line2D_Double0.getY2();\n }", "@Test\n public void test71() throws Throwable {\n DefaultCategoryDataset defaultCategoryDataset0 = new DefaultCategoryDataset();\n SubCategoryAxis subCategoryAxis0 = new SubCategoryAxis(\"\");\n NumberAxis3D numberAxis3D0 = new NumberAxis3D();\n DefaultPolarItemRenderer defaultPolarItemRenderer0 = new DefaultPolarItemRenderer();\n Color color0 = (Color)defaultPolarItemRenderer0.getBaseFillPaint();\n CategoryLabelPositions categoryLabelPositions0 = CategoryLabelPositions.UP_45;\n subCategoryAxis0.setCategoryLabelPositions(categoryLabelPositions0);\n WaterfallBarRenderer waterfallBarRenderer0 = new WaterfallBarRenderer((Paint) color0, (Paint) color0, (Paint) color0, (Paint) color0);\n Boolean boolean0 = Boolean.valueOf(\"\");\n defaultPolarItemRenderer0.setSeriesVisible(2989, boolean0);\n CategoryPlot categoryPlot0 = new CategoryPlot((CategoryDataset) defaultCategoryDataset0, (CategoryAxis) subCategoryAxis0, (ValueAxis) numberAxis3D0, (CategoryItemRenderer) waterfallBarRenderer0);\n Font font0 = SpiderWebPlot.DEFAULT_LABEL_FONT;\n subCategoryAxis0.setTickLabelFont(font0);\n DefaultCategoryDataset defaultCategoryDataset1 = (DefaultCategoryDataset)categoryPlot0.getDataset();\n DatasetChangeEvent datasetChangeEvent0 = new DatasetChangeEvent((Object) defaultCategoryDataset1, (Dataset) defaultCategoryDataset0);\n categoryPlot0.datasetChanged(datasetChangeEvent0);\n CombinedDomainXYPlot combinedDomainXYPlot0 = new CombinedDomainXYPlot();\n PlotRenderingInfo plotRenderingInfo0 = new PlotRenderingInfo((ChartRenderingInfo) null);\n Point2D.Double point2D_Double0 = new Point2D.Double();\n XYPlot xYPlot0 = combinedDomainXYPlot0.findSubplot(plotRenderingInfo0, point2D_Double0);\n }", "@Test\n public void test06() throws Throwable {\n CategoryPlot categoryPlot0 = new CategoryPlot();\n List list0 = categoryPlot0.getCategories();\n StatisticalBarRenderer statisticalBarRenderer0 = new StatisticalBarRenderer();\n statisticalBarRenderer0.setAutoPopulateSeriesOutlineStroke(true);\n BasicStroke basicStroke0 = (BasicStroke)statisticalBarRenderer0.lookupSeriesOutlineStroke(1143);\n statisticalBarRenderer0.setItemLabelAnchorOffset((-2697.5));\n categoryPlot0.setRangeCrosshairStroke(basicStroke0);\n ValueAxis valueAxis0 = categoryPlot0.getRangeAxis(1900);\n categoryPlot0.clearRangeMarkers(1143);\n double double0 = 20000.0;\n Font font0 = XYTextAnnotation.DEFAULT_FONT;\n JFreeChart jFreeChart0 = new JFreeChart(\"A{\", font0, (Plot) categoryPlot0, true);\n ChartPanel chartPanel0 = new ChartPanel(jFreeChart0, true);\n ChartRenderingInfo chartRenderingInfo0 = chartPanel0.getChartRenderingInfo();\n PlotRenderingInfo plotRenderingInfo0 = chartRenderingInfo0.getPlotInfo();\n // Undeclared exception!\n try { \n plotRenderingInfo0.getSubplotInfo(1900);\n } catch(IndexOutOfBoundsException e) {\n //\n // Index: 1900, Size: 0\n //\n assertThrownBy(\"java.util.ArrayList\", e);\n }\n }", "@SuppressWarnings(\"unchecked\")\n // <editor-fold defaultstate=\"collapsed\" desc=\"Generated Code\">//GEN-BEGIN:initComponents\n private void initComponents() {\n\n jSeparator2 = new javax.swing.JSeparator();\n jSeparator1 = new javax.swing.JSeparator();\n totalLabel = new javax.swing.JLabel();\n jScrollPane1 = new javax.swing.JScrollPane();\n valueTable = new javax.swing.JTable();\n chartPanel = new javax.swing.JPanel();\n\n totalLabel.setFont(new java.awt.Font(\"Courier New\", 0, 12)); // NOI18N\n totalLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);\n totalLabel.setText(\"Total\");\n\n valueTable.setModel(new javax.swing.table.DefaultTableModel(\n new Object [][] {\n {null, null, null, null},\n {null, null, null, null},\n {null, null, null, null},\n {null, null, null, null}\n },\n new String [] {\n \"Title 1\", \"Title 2\", \"Title 3\", \"Title 4\"\n }\n ));\n jScrollPane1.setViewportView(valueTable);\n\n javax.swing.GroupLayout chartPanelLayout = new javax.swing.GroupLayout(chartPanel);\n chartPanel.setLayout(chartPanelLayout);\n chartPanelLayout.setHorizontalGroup(\n chartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)\n .addGap(0, 0, Short.MAX_VALUE)\n );\n chartPanelLayout.setVerticalGroup(\n chartPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)\n .addGap(0, 157, Short.MAX_VALUE)\n );\n\n javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);\n this.setLayout(layout);\n layout.setHorizontalGroup(\n layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)\n .addComponent(chartPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)\n .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE)\n .addComponent(jSeparator2)\n .addComponent(jSeparator1)\n .addComponent(totalLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)\n );\n layout.setVerticalGroup(\n layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)\n .addGroup(layout.createSequentialGroup()\n .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 438, javax.swing.GroupLayout.PREFERRED_SIZE)\n .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)\n .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)\n .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)\n .addComponent(totalLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)\n .addGap(8, 8, 8)\n .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 13, javax.swing.GroupLayout.PREFERRED_SIZE)\n .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)\n .addComponent(chartPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)\n .addContainerGap())\n );\n }", "public JFrame displayChart() {\n final JFrame frame = new JFrame(\"dds\");\n\n // Schedule a job for the event-dispatching thread:\n // creating and showing this application's GUI.\n try {\n javax.swing.SwingUtilities.invokeAndWait(new Runnable() {\n\n @Override\n public void run() {\n\n frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);\n // XChartPanel<XYChart> chartPanel = new XChartPanel<XYChart>(charts.get(0));\n //() chartPanels.add(chartPanel);\n // frame.add(chartPanel);\n\n // Display the window.\n frame.setName(\"Динаміка системи\");\n frame.pack();\n frame.setVisible(true);\n }\n });\n } catch (InterruptedException e) {\n e.printStackTrace();\n } catch (InvocationTargetException e) {\n e.printStackTrace();\n }\n\n return frame;\n }", "public Chart(double[][] result, double[][] observed){\n //Create a new Frame object\n final Frame f1 = new Frame(\"Model Fit\");\n\t//Set the Frame object size\t\n\tf1.setSize(600,400);\n //Add a window listener to the Frame to close it\n\tf1.addWindowListener(new WindowAdapter() {\n @Override\n\t\tpublic void windowClosing(WindowEvent we) {\n\t\t\tf1.dispose();\n\t\t}\n\t});\n \n //add in the code to create the chart\n //create a data object to hold the XY data\n DefaultXYDataset data = new DefaultXYDataset();\n //cycle through the origins\n for (int i = 0; i < observed.length; i++) {\n //create a two dimensional array to hold the observed and result\n double dataArray[][] = new double[2][observed[i].length];\n //put the observed data in element 0\n dataArray[0]=observed[i];\n //put the result data in element 1\n dataArray[1]=result[i];\n //add the data series with a unique name\n data.addSeries(\"Origin \"+i, dataArray);\n }\n\t//Create the chart with the correct title and axis names and data etc.\n\tJFreeChart chart = ChartFactory.createScatterPlot(\"Observed vs. Results\", \n\t\t\"Observed\", // x axis label\n\t\t\"Results\", // y axis label\n\t\tdata, // data\n\t\tPlotOrientation.VERTICAL, // orientation\n\t\ttrue, // legend\n\t\ttrue, // tooltips\n\t\tfalse // URLs\n\t);\n\t//get the plot area and format it to the desired colours\n\tXYPlot plot = (XYPlot) chart.getPlot();\n\tplot.setBackgroundPaint(Color.white);\n\tplot.setDomainGridlinePaint(Color.darkGray);\n\tplot.setDomainGridlinesVisible(true);\n\tplot.setRangeGridlinePaint(Color.black);\n\t\n\t// We're going to add some regression stuff here shortly.\n double[] coeffs = Regression.getOLSRegression(createTwoDArray(result, observed));\n\tLineFunction2D linefunction2d = new LineFunction2D(coeffs[0], coeffs[1]);\n\tXYDataset series2 = DatasetUtilities.sampleFunction2D(linefunction2d, 10, 50, 5, \"Linear Regression Line\");\n\tplot.setDataset(2, series2); \n\tXYLineAndShapeRenderer lineDrawer = new XYLineAndShapeRenderer(true, false);\n\tlineDrawer.setSeriesPaint(0, Color.BLACK);\n\tplot.setRenderer(2, lineDrawer);\n\t\n //create a chart panel to render to the screnn\n\tChartPanel chartPanel = new ChartPanel(chart);\n //add the chart panel to the frame\n\tf1.add(chartPanel);\n //set the frame to be visible\n\tf1.setVisible(true);\n }", "public Chart initializeChart();", "public CoreChart()\n {\n super(\"org.apache.myfaces.trinidad.Chart\");\n }", "@Test\n public void test15() throws Throwable {\n DefaultMultiValueCategoryDataset defaultMultiValueCategoryDataset0 = new DefaultMultiValueCategoryDataset();\n ExtendedCategoryAxis extendedCategoryAxis0 = new ExtendedCategoryAxis(\"#C%b:FJR+QY\");\n DateAxis dateAxis0 = new DateAxis(\"#C%b:FJR+QY\");\n GroupedStackedBarRenderer groupedStackedBarRenderer0 = new GroupedStackedBarRenderer();\n CategoryPlot categoryPlot0 = new CategoryPlot((CategoryDataset) defaultMultiValueCategoryDataset0, (CategoryAxis) extendedCategoryAxis0, (ValueAxis) dateAxis0, (CategoryItemRenderer) groupedStackedBarRenderer0);\n JFreeChart jFreeChart0 = new JFreeChart((Plot) categoryPlot0);\n DefaultMultiValueCategoryDataset defaultMultiValueCategoryDataset1 = (DefaultMultiValueCategoryDataset)defaultMultiValueCategoryDataset0.clone();\n // Undeclared exception!\n try { \n jFreeChart0.createBufferedImage(1628, 1628, 1502.679, (double) 1628, (ChartRenderingInfo) null);\n } catch(NoClassDefFoundError e) {\n //\n // Could not initialize class sun.dc.pr.Rasterizer\n //\n assertThrownBy(\"sun.dc.DuctusRenderingEngine\", e);\n }\n }", "public testChart() {\n initComponents();\n }", "@Test\n public void test71() throws Throwable {\n CategoryAxis categoryAxis0 = new CategoryAxis(\"GT>r\");\n CombinedDomainCategoryPlot combinedDomainCategoryPlot0 = new CombinedDomainCategoryPlot(categoryAxis0);\n AxisLocation axisLocation0 = combinedDomainCategoryPlot0.getRangeAxisLocation(0);\n combinedDomainCategoryPlot0.setRangeGridlinesVisible(false);\n CombinedDomainCategoryPlot combinedDomainCategoryPlot1 = (CombinedDomainCategoryPlot)combinedDomainCategoryPlot0.clone();\n CategoryAxis categoryAxis1 = combinedDomainCategoryPlot0.getDomainAxisForDataset(0);\n Line2D.Double line2D_Double0 = new Line2D.Double();\n categoryAxis0.setAxisLineVisible(true);\n Line2D.Double line2D_Double1 = new Line2D.Double(20000.0, 534.2347460165499, 0.0, (double) 0);\n line2D_Double0.setLine((Line2D) line2D_Double1);\n line2D_Double0.y2 = 0.0;\n double double0 = line2D_Double0.getY2();\n CategoryDataset categoryDataset0 = combinedDomainCategoryPlot0.getDataset();\n Rectangle2D.Double rectangle2D_Double0 = new Rectangle2D.Double();\n ChartRenderingInfo chartRenderingInfo0 = new ChartRenderingInfo();\n PlotRenderingInfo plotRenderingInfo0 = chartRenderingInfo0.getPlotInfo();\n JScrollPane jScrollPane0 = null;\n try {\n jScrollPane0 = new JScrollPane(0, 0);\n } catch(IllegalArgumentException e) {\n //\n // invalid verticalScrollBarPolicy\n //\n assertThrownBy(\"javax.swing.JScrollPane\", e);\n }\n }", "public static void main(String[] args) throws Exception {\n Mapper mapper = new Mapper() {\n @Override\n public double f(double x, double y) {\n return 10 * Math.sin(x / 10) * Math.cos(y / 20) * x;\n }\n };\n\n // Define range and precision for the function to plot\n Range range = new Range(-150, 150);\n int steps = 50;\n\n // Create the object to represent the function over the given range.\n final Shape surface =\n new SurfaceBuilder().orthonormal(new OrthonormalGrid(range, steps, range, steps), mapper);\n surface.setColorMapper(new ColorMapper(new ColorMapRainbow(), surface.getBounds().getZmin(),\n surface.getBounds().getZmax(), new Color(1, 1, 1, .5f)));\n surface.setFaceDisplayed(true);\n surface.setWireframeDisplayed(true);\n surface.setWireframeColor(Color.BLACK);\n\n // Create a chart and add surface\n \n AWTChartFactory f = new DepthPeelingChartFactory(new DepthPeelingPainterFactory());\n Chart chart = f.newChart(Quality.Advanced().setAlphaActivated(false));\n\n chart.getScene().getGraph().add(surface);\n \n chart.getScene().getGraph().setStrategy(null);\n \n // depth peeling shaders do not mix correctly with 2.0.1 TextRenderer\n chart.getView().getAxis().setTextRenderer(new TextBitmapRenderer());\n\n\n // Setup a colorbar\n AWTColorbarLegend cbar = new AWTColorbarLegend(surface, chart.getView().getAxis().getLayout());\n cbar.setMinimumDimension(new Dimension(100, 600));\n //surface.setLegend(cbar);\n \n chart.open();\n chart.getMouse();\n\n ChartLauncher.openChart(chart);\n }", "@Test\n public void test79() throws Throwable {\n DefaultBoxAndWhiskerCategoryDataset defaultBoxAndWhiskerCategoryDataset0 = new DefaultBoxAndWhiskerCategoryDataset();\n SubCategoryAxis subCategoryAxis0 = new SubCategoryAxis(\":HD:3P^w7T\");\n DateAxis dateAxis0 = new DateAxis();\n DefaultPolarItemRenderer defaultPolarItemRenderer0 = new DefaultPolarItemRenderer();\n Color color0 = (Color)defaultPolarItemRenderer0.getBaseFillPaint();\n subCategoryAxis0.setSubLabelPaint(color0);\n StackedBarRenderer3D stackedBarRenderer3D0 = new StackedBarRenderer3D(729.43602760018, 729.43602760018, true);\n CategoryPlot categoryPlot0 = new CategoryPlot((CategoryDataset) defaultBoxAndWhiskerCategoryDataset0, (CategoryAxis) subCategoryAxis0, (ValueAxis) dateAxis0, (CategoryItemRenderer) stackedBarRenderer3D0);\n BasicStroke basicStroke0 = (BasicStroke)categoryPlot0.getRangeGridlineStroke();\n categoryPlot0.setDomainAxis(2052, (CategoryAxis) subCategoryAxis0, true);\n JFreeChart jFreeChart0 = new JFreeChart((Plot) categoryPlot0);\n ChartPanel chartPanel0 = new ChartPanel(jFreeChart0, true);\n ChartRenderingInfo chartRenderingInfo0 = chartPanel0.getChartRenderingInfo();\n PlotRenderingInfo plotRenderingInfo0 = chartRenderingInfo0.getPlotInfo();\n ScrollPane scrollPane0 = null;\n try {\n scrollPane0 = new ScrollPane();\n } catch(HeadlessException e) {\n //\n // no message in exception (getMessage() returned null)\n //\n assertThrownBy(\"java.awt.GraphicsEnvironment\", e);\n }\n }", "public UIXChart()\n {\n super(\"org.apache.myfaces.trinidad.Chart\");\n }", "private JFreeChart createChart ( final XYDataset dataset1, final XYDataset dataset2 ) {\n final JFreeChart result = ChartFactory.createTimeSeriesChart( null, \"\", \"\", dataset1, true, true, false );\n final XYPlot plot = result.getXYPlot();\n final XYItemRenderer renderer1 = new XYLineAndShapeRenderer( true, false );\n final XYItemRenderer renderer2 = new XYLineAndShapeRenderer( true, false );\n plot.setDomainPannable( true );\n plot.setRangePannable( true );\n plot.setDataset( SPEED_SERIES_DATASET, dataset2 );\n plot.mapDatasetToRangeAxis( SPEED_SERIES_DATASET, SPEED_SERIES_DATASET );\n plot.setRenderer( SPEED_SERIES_DATASET, renderer1 );\n plot.setDataset( POSITION_SERIES_DATASET, dataset1 );\n plot.mapDatasetToRangeAxis( POSITION_SERIES_DATASET, POSITION_SERIES_DATASET );\n plot.setRenderer( POSITION_SERIES_DATASET, renderer2 );\n plot.setBackgroundPaint( StartUI.MAIN_BACKGROUND_COLOR );\n plot.setDomainGridlinePaint( Color.decode(\"0x3b4246\") );\n plot.setRangeGridlinePaint( Color.decode(\"0x3b4246\") );\n plot.setRangeGridlineStroke( new BasicStroke( 0.8f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL ) );\n plot.setDomainGridlineStroke( new BasicStroke( 0.8f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL ) );\n renderer1.setSeriesPaint( 0, Color.decode( \"#AAFF44\" ) );\n renderer2.setSeriesPaint( 0, Color.decode( \"#EEDD00\" ) );\n result.setBackgroundPaint( null );\n result.removeLegend();\n return result;\n }", "@Test\n public void test65() throws Throwable {\n CategoryPlot categoryPlot0 = new CategoryPlot();\n Rectangle2D.Double rectangle2D_Double0 = (Rectangle2D.Double)Plot.DEFAULT_LEGEND_ITEM_BOX;\n rectangle2D_Double0.y = 0.0;\n categoryPlot0.setRangeGridlinesVisible(false);\n Line2D.Double line2D_Double0 = new Line2D.Double(0.0, 0.0, 0.0, 4.0);\n line2D_Double0.y1 = 0.0;\n Rectangle2D.Double rectangle2D_Double1 = new Rectangle2D.Double();\n rectangle2D_Double1.setFrameFromDiagonal(0.0, 6.0, 0.0, 0.0);\n double double0 = rectangle2D_Double1.y;\n ValueAxis[] valueAxisArray0 = new ValueAxis[4];\n NumberAxis3D numberAxis3D0 = new NumberAxis3D(\"\");\n valueAxisArray0[0] = (ValueAxis) numberAxis3D0;\n CyclicNumberAxis cyclicNumberAxis0 = new CyclicNumberAxis(0.0, \"+k\");\n Range range0 = numberAxis3D0.getRange();\n valueAxisArray0[1] = (ValueAxis) cyclicNumberAxis0;\n CyclicNumberAxis cyclicNumberAxis1 = new CyclicNumberAxis((-641.9), \"uLBz=!Lx,@4\");\n valueAxisArray0[2] = (ValueAxis) cyclicNumberAxis1;\n PeriodAxis periodAxis0 = null;\n try {\n periodAxis0 = new PeriodAxis(\"\", (RegularTimePeriod) null, (RegularTimePeriod) null);\n } catch(NullPointerException e) {\n //\n // no message in exception (getMessage() returned null)\n //\n assertThrownBy(\"org.jfree.chart.axis.PeriodAxis\", e);\n }\n }", "@Test\n public void test81() throws Throwable {\n CombinedDomainCategoryPlot combinedDomainCategoryPlot0 = new CombinedDomainCategoryPlot();\n CombinedDomainCategoryPlot combinedDomainCategoryPlot1 = new CombinedDomainCategoryPlot();\n combinedDomainCategoryPlot0.addChangeListener(combinedDomainCategoryPlot1);\n RectangleEdge rectangleEdge0 = combinedDomainCategoryPlot0.getRangeAxisEdge();\n JDBCCategoryDataset jDBCCategoryDataset0 = null;\n try {\n jDBCCategoryDataset0 = new JDBCCategoryDataset(\"\", \"Null 'seriesKey' argument.\", \"\", \"Null 'seriesKey' argument.\");\n } catch(ClassNotFoundException e) {\n }\n }", "@Test\n public void test17() throws Throwable {\n DefaultStatisticalCategoryDataset defaultStatisticalCategoryDataset0 = new DefaultStatisticalCategoryDataset();\n CategoryAxis3D categoryAxis3D0 = new CategoryAxis3D(\"The renderer has changed and I don't know what to do!\");\n IntervalBarRenderer intervalBarRenderer0 = new IntervalBarRenderer();\n CategoryPlot categoryPlot0 = new CategoryPlot((CategoryDataset) defaultStatisticalCategoryDataset0, (CategoryAxis) categoryAxis3D0, (ValueAxis) null, (CategoryItemRenderer) intervalBarRenderer0);\n JFreeChart jFreeChart0 = new JFreeChart((Plot) categoryPlot0);\n ChartRenderingInfo chartRenderingInfo0 = new ChartRenderingInfo();\n // Undeclared exception!\n try { \n jFreeChart0.createBufferedImage(0, (-2355), chartRenderingInfo0);\n } catch(IllegalArgumentException e) {\n //\n // Width (0) and height (-2355) cannot be <= 0\n //\n assertThrownBy(\"java.awt.image.DirectColorModel\", e);\n }\n }", "@Test\n public void test45() throws Throwable {\n Line2D.Double line2D_Double0 = new Line2D.Double();\n double double0 = line2D_Double0.getX2();\n CategoryPlot categoryPlot0 = new CategoryPlot();\n JFreeChart jFreeChart0 = new JFreeChart(\"\", (Plot) categoryPlot0);\n CategoryPlot categoryPlot1 = jFreeChart0.getCategoryPlot();\n CategoryTextAnnotation categoryTextAnnotation0 = new CategoryTextAnnotation(\"\", (Comparable) 0.0, 0.0);\n categoryPlot1.addAnnotation(categoryTextAnnotation0);\n }", "private void initChart() {\n Cartesian cartesian = AnyChart.line();\n\n cartesian.animation(true);\n\n cartesian.padding(10d, 20d, 5d, 20d);\n\n cartesian.crosshair().enabled(true);\n cartesian.crosshair()\n .yLabel(true)\n // TODO ystroke\n .yStroke((Stroke) null, null, null, (String) null, (String) null);\n\n cartesian.tooltip().positionMode(TooltipPositionMode.POINT);\n\n cartesian.title(\"Steps taken in this week and last week\");\n\n cartesian.yAxis(0).title(\"Steps\");\n cartesian.xAxis(0).labels().padding(5d, 5d, 5d, 5d);\n\n List<DataEntry> seriesData = new ArrayList<>();\n Log.d(\"Size This Week\",stepsTakenModelsThisWeek.size()+\"\");\n for(int i = 0 ; i<7 ; i++){\n CustomDataEntry c = new CustomDataEntry(days[i],stepsTakenModelsLastWeek.get(i).getSteps());\n if(i<stepsTakenModelsThisWeek.size()){\n c.setValue(\"value2\",stepsTakenModelsThisWeek.get(i).getSteps());\n }else{\n if(DateUtilities.getDayInAbbBySelectedDate(stepsTakenModelsLastWeek.get(i).getDate()).equals(\n DateUtilities.getCurrentDayInAbb()))\n {\n c.setValue(\"value2\",stepsToday);\n }else{\n c.setValue(\"value2\",0);\n }\n }\n seriesData.add(c);\n }\n\n Set set = Set.instantiate();\n set.data(seriesData);\n Mapping series1Mapping = set.mapAs(\"{ x: 'x', value: 'value' }\");\n Mapping series2Mapping = set.mapAs(\"{ x: 'x', value: 'value2' }\");\n\n Line series1 = cartesian.line(series1Mapping);\n series1.name(\"Last Week\");\n series1.hovered().markers().enabled(true);\n series1.hovered().markers()\n .type(MarkerType.CIRCLE)\n .size(4d);\n series1.tooltip()\n .position(\"right\")\n .anchor(Anchor.LEFT_CENTER)\n .offsetX(5d)\n .offsetY(5d);\n\n Line series2 = cartesian.line(series2Mapping);\n series2.name(\"This Week\");\n series2.hovered().markers().enabled(true);\n series2.hovered().markers()\n .type(MarkerType.CIRCLE)\n .size(4d);\n series2.tooltip()\n .position(\"right\")\n .anchor(Anchor.LEFT_CENTER)\n .offsetX(5d)\n .offsetY(5d);\n\n\n cartesian.legend().enabled(true);\n cartesian.legend().fontSize(13d);\n cartesian.legend().padding(0d, 0d, 10d, 0d);\n\n chart.setChart(cartesian);\n }", "public void onModuleLoad() {\n\n Chart chart = new Chart()\n .setType(Series.Type.SPLINE)\n .setChartTitleText(\"Temperaturen\")\n .setMarginRight(10);\n\t\n\tSeries series = chart.createSeries()\n\t.setName(\"°C in Palma\")\n\t.setPoints(new Number[] { 22.4, 25.6, 20.5, 19.0, 17.0, 18.0, 19.0, 18.3 });\n\tchart.addSeries(series);\n\n\tSeries series2 = chart.createSeries()\n\t.setName(\"°C in Leipzig\")\n\t.setPoints(new Number[] { 13.5, 14.3, 16.4, 9.9, 12.5, 13.0, 15.9, 20.0} );\n\tchart.addSeries(series2);\n\t\n\tRootPanel.get().add(chart);\n\t\n\t}", "public JFreeChart getChart() {\n\t\treturn chart_;\n\t}", "public static JFreeChart createBarChart (String xAxisTitle,\n String yAxisTitle,\n CategoryDataset ds)\n {\n JFreeChart chart = ChartFactory.createBarChart (null,\n xAxisTitle,\n yAxisTitle,\n ds,\n PlotOrientation.VERTICAL,\n true,\n true,\n true);\n\n chart.setBackgroundPaint(Color.white);\n\n // get a reference to the plot for further customisation...\n final CategoryPlot plot = chart.getCategoryPlot();\n plot.setBackgroundPaint (UIUtils.getComponentColor ());\n plot.setDomainGridlinePaint (UIUtils.getBorderColor ());\n plot.setRangeGridlinePaint (UIUtils.getBorderColor ());\n /*\n plot.setAxisOffset (new RectangleInsets (5D,\n 5D,\n 5D,\n 5D));\n*/\n plot.setDomainCrosshairVisible (true);\n plot.setRangeCrosshairVisible (true);\n plot.setDomainGridlinePaint (UIUtils.getColor (\"#cfcfcf\"));\n plot.setRangeGridlinePaint (UIUtils.getColor (\"#cfcfcf\"));\n\n // set the range axis to display integers only...\n final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();\n rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());\n rangeAxis.setNumberFormatOverride (Environment.getNumberFormatter ());\n\n // disable bar outlines...\n final BarRenderer renderer = (BarRenderer) plot.getRenderer();\n renderer.setDrawBarOutline(false);\n renderer.setItemMargin (0);\n /*\n // set up gradient paints for series...\n final GradientPaint gp0 = new GradientPaint(\n 0.0f, 0.0f, Color.blue,\n 0.0f, 0.0f, Color.lightGray\n );\n final GradientPaint gp1 = new GradientPaint(\n 0.0f, 0.0f, Color.green,\n 0.0f, 0.0f, Color.lightGray\n );\n final GradientPaint gp2 = new GradientPaint(\n 0.0f, 0.0f, Color.red,\n 0.0f, 0.0f, Color.lightGray\n );\n renderer.setSeriesPaint(0, gp0);\n renderer.setSeriesPaint(1, gp1);\n renderer.setSeriesPaint(2, gp2);\n*/\n final CategoryAxis domainAxis = plot.getDomainAxis();\n domainAxis.setCategoryLabelPositions(\n CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / -0.6)\n );\n\n return chart;\n\n }", "@Test\n public void test40() throws Throwable {\n CategoryAxis categoryAxis0 = new CategoryAxis();\n CombinedDomainCategoryPlot combinedDomainCategoryPlot0 = new CombinedDomainCategoryPlot(categoryAxis0);\n AxisSpace axisSpace0 = combinedDomainCategoryPlot0.getFixedRangeAxisSpace();\n JFreeChart jFreeChart0 = new JFreeChart(\",q3=\", (Plot) combinedDomainCategoryPlot0);\n PolarChartPanel polarChartPanel0 = null;\n try {\n polarChartPanel0 = new PolarChartPanel(jFreeChart0);\n } catch(IllegalArgumentException e) {\n //\n // plot is not a PolarPlot\n //\n assertThrownBy(\"org.jfree.chart.PolarChartPanel\", e);\n }\n }", "@SuppressWarnings(\"unchecked\")\n // <editor-fold defaultstate=\"collapsed\" desc=\"Generated Code\">//GEN-BEGIN:initComponents\n private void initComponents() {\n\n pnlChart = new javax.swing.JPanel();\n jButton2 = new javax.swing.JButton();\n\n setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);\n\n pnlChart.setBackground(new java.awt.Color(0, 0, 0));\n pnlChart.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));\n pnlChart.setForeground(new java.awt.Color(255, 255, 255));\n pnlChart.setAlignmentX(1.5F);\n pnlChart.setAlignmentY(0.35F);\n pnlChart.setMaximumSize(new java.awt.Dimension(1000, 1000));\n pnlChart.setMinimumSize(new java.awt.Dimension(1, 1));\n pnlChart.setPreferredSize(new java.awt.Dimension(1, 1));\n pnlChart.setLayout(new java.awt.BorderLayout());\n\n jButton2.setText(\"jButton2\");\n jButton2.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n jButton2ActionPerformed(evt);\n }\n });\n pnlChart.add(jButton2, java.awt.BorderLayout.PAGE_START);\n\n javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());\n getContentPane().setLayout(layout);\n layout.setHorizontalGroup(\n layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)\n .addGroup(layout.createSequentialGroup()\n .addComponent(pnlChart, javax.swing.GroupLayout.PREFERRED_SIZE, 631, javax.swing.GroupLayout.PREFERRED_SIZE)\n .addGap(0, 993, Short.MAX_VALUE))\n );\n layout.setVerticalGroup(\n layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)\n .addGroup(layout.createSequentialGroup()\n .addComponent(pnlChart, javax.swing.GroupLayout.PREFERRED_SIZE, 595, javax.swing.GroupLayout.PREFERRED_SIZE)\n .addGap(0, 801, Short.MAX_VALUE))\n );\n\n pack();\n }", "@Test\n public void test43() throws Throwable {\n Point2D.Double point2D_Double0 = new Point2D.Double(2544.735178220915, 2544.735178220915);\n CategoryAxis3D categoryAxis3D0 = new CategoryAxis3D(\"W6dcfYW#F6:9T;Bi?W\");\n CombinedDomainCategoryPlot combinedDomainCategoryPlot0 = new CombinedDomainCategoryPlot((CategoryAxis) categoryAxis3D0);\n Font font0 = Axis.DEFAULT_AXIS_LABEL_FONT;\n combinedDomainCategoryPlot0.setNoDataMessageFont(font0);\n PlotOrientation plotOrientation0 = combinedDomainCategoryPlot0.getOrientation();\n Color color0 = (Color)combinedDomainCategoryPlot0.getRangeGridlinePaint();\n Point2D.Double point2D_Double1 = new Point2D.Double(0.0, 1215.36);\n Rectangle2D.Double rectangle2D_Double0 = new Rectangle2D.Double(1215.36, 87.128070112, 0.0, 0.0);\n rectangle2D_Double0.height = 2544.735178220915;\n Class<CategoryAxis3D> class0 = CategoryAxis3D.class;\n boolean boolean0 = SerialUtilities.isSerializable(class0);\n NumberAxis3D numberAxis3D0 = new NumberAxis3D();\n combinedDomainCategoryPlot0.setRangeAxis((ValueAxis) numberAxis3D0);\n StandardEntityCollection standardEntityCollection0 = new StandardEntityCollection();\n ChartRenderingInfo chartRenderingInfo0 = new ChartRenderingInfo((EntityCollection) standardEntityCollection0);\n PlotRenderingInfo plotRenderingInfo0 = new PlotRenderingInfo(chartRenderingInfo0);\n combinedDomainCategoryPlot0.zoomRangeAxes(1215.36, plotRenderingInfo0, (Point2D) point2D_Double0, true);\n }", "public static void main(String[] args) throws SQLException {\n EventQueue.invokeLater(new Runnable() {\n @Override\n public void run() {\n try {\n int nilaiKiloan = 0;\n int nilaiSatuan = 0;\n\n pieChart frame = new pieChart();\n frame.setVisible(true);\n String queryKiloan = \"SELECT COUNT(*) FROM laundry WHERE jenis_layanan='Laundry Kiloan'\";\n String querySatuan = \"SELECT COUNT(*) FROM laundry WHERE jenis_layanan='Laundry Satuan'\";\n ConnectionDB.InstanceDB.openConnection();\n ResultSet rs = ConnectionDB.InstanceDB.RunSelectQuery(queryKiloan);\n while (rs.next()) {\n nilaiKiloan = rs.getInt(1);\n }\n System.out.println(nilaiKiloan);\n\n ResultSet rs1 = ConnectionDB.InstanceDB.RunSelectQuery(querySatuan);\n while (rs1.next()) {\n nilaiSatuan = rs1.getInt(1);\n }\n System.out.println(nilaiSatuan);\n DefaultPieDataset pieDataset = new DefaultPieDataset();\n pieDataset.setValue(\"Laundry Kiloan\", nilaiKiloan);\n pieDataset.setValue(\"Laundry Satuan\", nilaiSatuan);\n \n JFreeChart chart=ChartFactory.createPieChart3D(\n \"Perbandingan Pengguna Layanan Laundry\", \n pieDataset, \n true, \n true, \n false);\n ChartPanel cPanel = new ChartPanel(chart);\n frame.setContentPane(cPanel);\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n });\n }", "public ChartPanel getChartPanel();", "JFreeChart generateBox();", "public static void main(String[] args) throws Exception {\n Presentation presentation = new Presentation();\r\n\r\n //Load the file from disk.\r\n presentation.loadFromFile(\"data/VaryColorsOfSameSeriesDataMarkers.pptx\");\r\n\r\n //Get the chart from the presentation.\r\n IChart chart = (IChart)presentation.getSlides().get(0).getShapes().get(0);\r\n\r\n //Create a ChartDataPoint object and specify the index.\r\n ChartDataPoint dataPoint = new ChartDataPoint(chart.getSeries().get(0));\r\n dataPoint.setIndex(0);\r\n\r\n //Set the fill color of the data marker.\r\n dataPoint.getMarkerFill().getFill().setFillType(FillFormatType.SOLID);\r\n dataPoint.getMarkerFill().getFill().getSolidColor().setColor(Color.RED);\r\n\r\n //Set the line color of the data marker.\r\n dataPoint.getMarkerFill().getLine().setFillType(FillFormatType.SOLID);\r\n dataPoint.getMarkerFill().getLine().getSolidFillColor().setColor(Color.RED);\r\n\r\n //Add the data point to the point collection of a series.\r\n chart.getSeries().get(0).getDataPoints().add(dataPoint);\r\n\r\n dataPoint = new ChartDataPoint(chart.getSeries().get(0));\r\n dataPoint.setIndex(1);\r\n //Set the fill color of the data marker.\r\n dataPoint.getMarkerFill().getFill().setFillType(FillFormatType.SOLID);\r\n dataPoint.getMarkerFill().getFill().getSolidColor().setColor(Color.BLACK);\r\n\r\n //Set the line color of the data marker.\r\n dataPoint.getMarkerFill().getLine().setFillType(FillFormatType.SOLID);\r\n dataPoint.getMarkerFill().getLine().getSolidFillColor().setColor(Color.BLACK);\r\n chart.getSeries().get(0).getDataPoints().add(dataPoint);\r\n\r\n dataPoint = new ChartDataPoint(chart.getSeries().get(0));\r\n dataPoint.setIndex(2);\r\n //Set the fill color of the data marker.\r\n dataPoint.getMarkerFill().getFill().setFillType(FillFormatType.SOLID);\r\n dataPoint.getMarkerFill().getFill().getSolidColor().setColor(Color.BLUE);\r\n\r\n //Set the line color of the data marker.\r\n dataPoint.getMarkerFill().getLine().setFillType(FillFormatType.SOLID);\r\n dataPoint.getMarkerFill().getLine().getSolidFillColor().setColor(Color.BLUE);\r\n chart.getSeries().get(0).getDataPoints().add(dataPoint);\r\n\r\n String result = \"output/varyColorsOfSameSeriesDataMarkers_result.pptx\";\r\n\r\n //Save to file.\r\n presentation.saveToFile(result, FileFormat.PPTX_2010);\r\n }", "@Test\n public void test74() throws Throwable {\n CombinedDomainCategoryPlot combinedDomainCategoryPlot0 = new CombinedDomainCategoryPlot();\n CategoryAxis categoryAxis0 = new CategoryAxis();\n RectangleEdge rectangleEdge0 = combinedDomainCategoryPlot0.getRangeAxisEdge();\n int int0 = combinedDomainCategoryPlot0.getDomainAxisIndex(categoryAxis0);\n StandardEntityCollection standardEntityCollection0 = new StandardEntityCollection();\n ChartRenderingInfo chartRenderingInfo0 = new ChartRenderingInfo((EntityCollection) standardEntityCollection0);\n PlotRenderingInfo plotRenderingInfo0 = chartRenderingInfo0.getPlotInfo();\n AxisChangeEvent axisChangeEvent0 = new AxisChangeEvent((Axis) categoryAxis0);\n JFreeChart jFreeChart0 = axisChangeEvent0.getChart();\n ChartPanel chartPanel0 = new ChartPanel((JFreeChart) null, false, false, false, false, false);\n MouseWheelEvent mouseWheelEvent0 = new MouseWheelEvent((Component) chartPanel0, (-1), 2678400000L, 1128, (-1162), (-931), 0, false, 1541, 4091, 500);\n Point point0 = chartPanel0.getPopupLocation(mouseWheelEvent0);\n combinedDomainCategoryPlot0.zoomDomainAxes((double) (-1), plotRenderingInfo0, (Point2D) null, false);\n }", "public interface ChartBuilder {\n\n /**\n * @return an AnalyticsTableModel containing the source data for the chart\n */\n AnalyticsTableModel buildTableModel( ChartViewConfiguration chartViewConfiguration, BeanCollection beanCollection) throws InvalidColumnException;\n\n /**\n * @return the JFreeChart instance to display\n */\n JFreeChart buildChart( ChartViewConfiguration chartViewConfiguration, KeyedColumnTableModel chartTableModel) throws InvalidColumnException;\n\n /**\n * @return a list of components which will be displayed above the chart, typically these will be filters or controls which change the way the chart is presented\n */\n public java.util.List<JComponent> getViewControls(ChartViewConfiguration chartViewConfiguration, AnalyticsTableModel chartTableModel, JFreeChart freeChart) throws InvalidColumnException;\n\n /**\n * @return a ChartPanel for the given chart\n */\n ChartPanel buildChartPanel(JFreeChart chart);\n}", "public static void main(String[]args){\n JFrame frame = new JFrame(\"Pie Chart\"); \n frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);\n Pie chart1 = new Pie();\n frame.getContentPane().add (chart1);\n frame.pack();\n frame.setVisible(true);\n }", "@Test\n public void CanvasChartTest() {\n }", "public static JPanel createDemoPanel() {\r\n JFreeChart chart = createChart(createDataset());\r\n ChartPanel panel = new ChartPanel(chart);\r\n panel.setMouseWheelEnabled(true);\r\n return panel;\r\n }", "@Test\n public void test76() throws Throwable {\n SimpleTimeZone simpleTimeZone0 = new SimpleTimeZone((-614), \"\", 0, 0, 0, (-1), 0, 0, 3473, (-1));\n DateAxis dateAxis0 = new DateAxis(\"\", (TimeZone) simpleTimeZone0);\n CombinedRangeCategoryPlot combinedRangeCategoryPlot0 = new CombinedRangeCategoryPlot((ValueAxis) dateAxis0);\n DatasetRenderingOrder datasetRenderingOrder0 = combinedRangeCategoryPlot0.getDatasetRenderingOrder();\n CombinedRangeXYPlot combinedRangeXYPlot0 = new CombinedRangeXYPlot((ValueAxis) dateAxis0);\n BasicStroke basicStroke0 = (BasicStroke)combinedRangeXYPlot0.getDomainZeroBaselineStroke();\n PipedInputStream pipedInputStream0 = new PipedInputStream();\n PipedOutputStream pipedOutputStream0 = new PipedOutputStream(pipedInputStream0);\n DataOutputStream dataOutputStream0 = new DataOutputStream((OutputStream) pipedOutputStream0);\n ObjectOutputStream objectOutputStream0 = new ObjectOutputStream((OutputStream) dataOutputStream0);\n SerialUtilities.writeStroke(basicStroke0, objectOutputStream0);\n SystemColor systemColor0 = SystemColor.text;\n LookupPaintScale lookupPaintScale0 = new LookupPaintScale((double) 0, 1955.7194307587054, (Paint) systemColor0);\n PaintScaleLegend paintScaleLegend0 = new PaintScaleLegend((PaintScale) lookupPaintScale0, (ValueAxis) dateAxis0);\n AxisLocation axisLocation0 = paintScaleLegend0.getAxisLocation();\n combinedRangeCategoryPlot0.setDomainAxisLocation(334, axisLocation0);\n }", "@Test\n public void test23() throws Throwable {\n CombinedDomainCategoryPlot combinedDomainCategoryPlot0 = new CombinedDomainCategoryPlot();\n SortOrder sortOrder0 = combinedDomainCategoryPlot0.getColumnRenderingOrder();\n combinedDomainCategoryPlot0.setRangeCrosshairVisible(true);\n LegendItemCollection legendItemCollection0 = combinedDomainCategoryPlot0.getLegendItems();\n }", "public static void graph(){\n\t\t double[][] valuepairs = new double[2][];\n\t\t valuepairs[0] = mutTotal; //x values\n\t\t valuepairs[1] = frequency; //y values\n\t\t DefaultXYDataset set = new DefaultXYDataset();\n\t\t set.addSeries(\"Occurances\",valuepairs); \n\t\t XYBarDataset barset = new XYBarDataset(set, .8);\n\t\t JFreeChart chart = ChartFactory.createXYBarChart(\n\t\t \"Mutation Analysis\",\"Number of Mutations\",false,\"Frequency\",\n\t\t barset,PlotOrientation.VERTICAL,true, true, false);\n\t\t JFrame frame = new JFrame(\"Mutation Analysis\");\n\t\t frame.setContentPane(new ChartPanel(chart));\n\t\t frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n\t\t frame.pack();\n\t\t frame.setVisible(true);\n\t\t }", "@Test\n public void test27() throws Throwable {\n Point2D.Double point2D_Double0 = new Point2D.Double(0.0, 0.0);\n String string0 = point2D_Double0.toString();\n CombinedDomainCategoryPlot combinedDomainCategoryPlot0 = new CombinedDomainCategoryPlot();\n SortOrder sortOrder0 = combinedDomainCategoryPlot0.getRowRenderingOrder();\n combinedDomainCategoryPlot0.setRowRenderingOrder(sortOrder0);\n CategoryItemRenderer categoryItemRenderer0 = combinedDomainCategoryPlot0.getRenderer(2);\n combinedDomainCategoryPlot0.mapDatasetToRangeAxis(2, 0);\n Layer layer0 = Layer.FOREGROUND;\n Collection collection0 = combinedDomainCategoryPlot0.getDomainMarkers(0, layer0);\n boolean boolean0 = combinedDomainCategoryPlot0.isRangeCrosshairVisible();\n combinedDomainCategoryPlot0.mapDatasetToRangeAxis(0, 3);\n StandardEntityCollection standardEntityCollection0 = new StandardEntityCollection();\n ChartRenderingInfo chartRenderingInfo0 = new ChartRenderingInfo((EntityCollection) standardEntityCollection0);\n PlotRenderingInfo plotRenderingInfo0 = new PlotRenderingInfo(chartRenderingInfo0);\n combinedDomainCategoryPlot0.zoomRangeAxes(4.0, plotRenderingInfo0, (Point2D) point2D_Double0, true);\n StandardXYZURLGenerator standardXYZURLGenerator0 = new StandardXYZURLGenerator();\n XYStepRenderer xYStepRenderer0 = new XYStepRenderer((XYToolTipGenerator) null, (XYURLGenerator) standardXYZURLGenerator0);\n XYPlot xYPlot0 = xYStepRenderer0.getPlot();\n }", "@Test\n public void test20() throws Throwable {\n ExtendedCategoryAxis extendedCategoryAxis0 = new ExtendedCategoryAxis((String) null);\n CombinedDomainCategoryPlot combinedDomainCategoryPlot0 = new CombinedDomainCategoryPlot((CategoryAxis) extendedCategoryAxis0);\n Layer layer0 = Layer.BACKGROUND;\n Collection collection0 = combinedDomainCategoryPlot0.getRangeMarkers(0, layer0);\n Font font0 = Axis.DEFAULT_AXIS_LABEL_FONT;\n JFreeChart jFreeChart0 = new JFreeChart(\"org.jfree.chart.renderer.xy.XYErrorRenderer\", font0, (Plot) combinedDomainCategoryPlot0, true);\n // Undeclared exception!\n try { \n jFreeChart0.getXYPlot();\n } catch(ClassCastException e) {\n //\n // org.jfree.chart.plot.CombinedDomainCategoryPlot cannot be cast to org.jfree.chart.plot.XYPlot\n //\n assertThrownBy(\"org.jfree.chart.JFreeChart\", e);\n }\n }", "@Test\n public void test26() throws Throwable {\n CyclicNumberAxis cyclicNumberAxis0 = new CyclicNumberAxis(0.0, 0.0);\n CombinedRangeCategoryPlot combinedRangeCategoryPlot0 = new CombinedRangeCategoryPlot((ValueAxis) cyclicNumberAxis0);\n RectangleEdge rectangleEdge0 = combinedRangeCategoryPlot0.getDomainAxisEdge(1248);\n List list0 = combinedRangeCategoryPlot0.getSubplots();\n AxisLocation axisLocation0 = AxisLocation.BOTTOM_OR_LEFT;\n combinedRangeCategoryPlot0.setDomainAxisLocation(0, axisLocation0, false);\n combinedRangeCategoryPlot0.setRangeCrosshairValue(0.18, false);\n AxisLocation axisLocation1 = combinedRangeCategoryPlot0.getRangeAxisLocation();\n boolean boolean0 = combinedRangeCategoryPlot0.isRangeCrosshairLockedOnData();\n TextBlock textBlock0 = new TextBlock();\n TextBox textBox0 = new TextBox(textBlock0);\n MultiplePiePlot multiplePiePlot0 = new MultiplePiePlot();\n JFreeChart jFreeChart0 = multiplePiePlot0.getPieChart();\n StandardEntityCollection standardEntityCollection0 = new StandardEntityCollection();\n ChartRenderingInfo chartRenderingInfo0 = new ChartRenderingInfo((EntityCollection) standardEntityCollection0);\n // Undeclared exception!\n try { \n jFreeChart0.createBufferedImage(0, 3030, chartRenderingInfo0);\n } catch(IllegalArgumentException e) {\n //\n // Width (0) and height (3030) cannot be <= 0\n //\n assertThrownBy(\"java.awt.image.DirectColorModel\", e);\n }\n }", "public ChartTest() {\n initComponents();\n }", "@Test\n public void test16() throws Throwable {\n DefaultCategoryDataset defaultCategoryDataset0 = new DefaultCategoryDataset();\n CategoryAxis categoryAxis0 = new CategoryAxis();\n NumberAxis3D numberAxis3D0 = new NumberAxis3D();\n BoxAndWhiskerRenderer boxAndWhiskerRenderer0 = new BoxAndWhiskerRenderer();\n CategoryPlot categoryPlot0 = new CategoryPlot((CategoryDataset) defaultCategoryDataset0, categoryAxis0, (ValueAxis) numberAxis3D0, (CategoryItemRenderer) boxAndWhiskerRenderer0);\n AxisLocation axisLocation0 = categoryPlot0.getDomainAxisLocation((-619));\n categoryPlot0.setRangeAxisLocation(axisLocation0, false);\n CenterArrangement centerArrangement0 = new CenterArrangement();\n HorizontalAlignment horizontalAlignment0 = HorizontalAlignment.RIGHT;\n VerticalAlignment verticalAlignment0 = VerticalAlignment.BOTTOM;\n FlowArrangement flowArrangement0 = new FlowArrangement(horizontalAlignment0, verticalAlignment0, (-3146.85728861904), (-3146.85728861904));\n LegendTitle legendTitle0 = new LegendTitle((LegendItemSource) categoryPlot0, (Arrangement) centerArrangement0, (Arrangement) flowArrangement0);\n RectangleInsets rectangleInsets0 = legendTitle0.getPadding();\n categoryPlot0.setAxisOffset(rectangleInsets0);\n AxisSpace axisSpace0 = categoryPlot0.getFixedDomainAxisSpace();\n categoryPlot0.drawDomainGridlines((Graphics2D) null, (Rectangle2D) null);\n }", "JFreeChart generateDot();", "@Test\n public void test72() throws Throwable {\n CombinedRangeCategoryPlot combinedRangeCategoryPlot0 = new CombinedRangeCategoryPlot();\n combinedRangeCategoryPlot0.mapDatasetToDomainAxis(304, 908);\n Point2D.Double point2D_Double0 = new Point2D.Double((double) 304, (double) 908);\n AxisLocation axisLocation0 = AxisLocation.TOP_OR_LEFT;\n combinedRangeCategoryPlot0.setRangeAxisLocation(908, axisLocation0);\n CategoryAxis3D categoryAxis3D0 = new CategoryAxis3D(\"org.jfree.chart.annotations.XYBoxAnnotation\");\n combinedRangeCategoryPlot0.setDomainAxis((CategoryAxis) categoryAxis3D0);\n point2D_Double0.x = 4978.54542523173;\n String string0 = combinedRangeCategoryPlot0.getPlotType();\n ValueAxis[] valueAxisArray0 = new ValueAxis[6];\n DateAxis dateAxis0 = new DateAxis(\"org.jfree.chart.annotations.XYBoxAnnotation\");\n valueAxisArray0[0] = (ValueAxis) dateAxis0;\n CyclicNumberAxis cyclicNumberAxis0 = new CyclicNumberAxis((-1.0), (double) 304);\n valueAxisArray0[1] = (ValueAxis) cyclicNumberAxis0;\n NumberAxis numberAxis0 = new NumberAxis(\"z)m!{V![\");\n valueAxisArray0[2] = (ValueAxis) numberAxis0;\n SimpleDateFormat simpleDateFormat0 = (SimpleDateFormat)DateFormat.getInstance();\n ZoneInfo zoneInfo0 = (ZoneInfo)simpleDateFormat0.getTimeZone();\n DateAxis dateAxis1 = new DateAxis(\"org.jfree.chart.annotations.XYBoxAnnotation\", (TimeZone) zoneInfo0);\n valueAxisArray0[3] = (ValueAxis) dateAxis1;\n DefaultValueDataset defaultValueDataset0 = new DefaultValueDataset();\n ThermometerPlot thermometerPlot0 = new ThermometerPlot((ValueDataset) defaultValueDataset0);\n NumberAxis numberAxis1 = (NumberAxis)thermometerPlot0.getRangeAxis();\n valueAxisArray0[4] = (ValueAxis) numberAxis1;\n String[] stringArray0 = new String[7];\n stringArray0[0] = \"z)m!{V![\";\n stringArray0[1] = \"\";\n stringArray0[2] = \"%}~t|T'c.q2O/M@;Vu5\";\n stringArray0[3] = \"?_t}%h[qlt\";\n stringArray0[4] = \"z)m!{V![\";\n stringArray0[5] = \"z)m!{V![\";\n stringArray0[6] = \"d*%)TD6zCx!%m^]|\";\n }", "public JFreeChart createChart(CategoryDataset dataset) {\n CategoryAxis categoryAxis = new CategoryAxis(\"\");\n ValueAxis valueAxis = new NumberAxis(\"\");\n valueAxis.setVisible(false);\n BarRenderer renderer = new BarRenderer() {\n\n @Override\n public Paint getItemPaint(int row, int column) {\n return Color.blue;\n// switch (column) {\n// case 0:\n// return Color.red;\n// case 1:\n// return Color.yellow;\n// case 2:\n// return Color.blue;\n// case 3:\n// return Color.orange;\n// case 4:\n// return Color.gray;\n// case 5:\n// return Color.green.darker();\n// default:\n// return Color.red;\n// }\n }\n };\n renderer.setDrawBarOutline(false);\n renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());\n renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(\n ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER));\n renderer.setBaseItemLabelsVisible(Boolean.TRUE);\n renderer.setBarPainter(new StandardBarPainter());\n CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);\n JFreeChart chart = new JFreeChart(\"\", JFreeChart.DEFAULT_TITLE_FONT, plot, false);\n chart.setBackgroundPaint(Color.white);\n return chart;\n }", "@Test\n public void test67() throws Throwable {\n CombinedRangeCategoryPlot combinedRangeCategoryPlot0 = new CombinedRangeCategoryPlot();\n DatasetRenderingOrder datasetRenderingOrder0 = DatasetRenderingOrder.FORWARD;\n combinedRangeCategoryPlot0.setDatasetRenderingOrder(datasetRenderingOrder0);\n AxisLocation axisLocation0 = combinedRangeCategoryPlot0.getRangeAxisLocation();\n CategoryAxis categoryAxis0 = combinedRangeCategoryPlot0.getDomainAxis();\n AxisLocation axisLocation1 = combinedRangeCategoryPlot0.getRangeAxisLocation();\n Number[][] numberArray0 = new Number[3][5];\n Number[] numberArray1 = new Number[5];\n double double0 = SpiderWebPlot.DEFAULT_AXIS_LABEL_GAP;\n numberArray1[0] = (Number) 0.1;\n int int0 = SystemColor.INFO;\n numberArray1[1] = (Number) 24;\n int int1 = TransferHandler.MOVE;\n numberArray1[2] = (Number) 2;\n int int2 = MockThread.MIN_PRIORITY;\n numberArray1[3] = (Number) 1;\n int int3 = ColorSpace.TYPE_ACLR;\n numberArray1[4] = (Number) 20;\n numberArray0[0] = numberArray1;\n Number[] numberArray2 = new Number[2];\n byte byte0 = Character.CONTROL;\n numberArray2[0] = (Number) (byte)15;\n int int4 = ThermometerPlot.BULB_DIAMETER;\n numberArray2[1] = (Number) 80;\n numberArray0[1] = numberArray2;\n Number[] numberArray3 = new Number[8];\n Object[][][] objectArray0 = new Object[2][8][7];\n objectArray0[0] = (Object[][]) numberArray0;\n objectArray0[1] = (Object[][]) numberArray0;\n DefaultWindDataset defaultWindDataset0 = null;\n try {\n defaultWindDataset0 = new DefaultWindDataset(objectArray0);\n } catch(ArrayIndexOutOfBoundsException e) {\n //\n // 2\n //\n assertThrownBy(\"org.jfree.data.xy.DefaultWindDataset\", e);\n }\n }", "private void createChart() {\n\t\tchartSpace = CTChartSpace.Factory.newInstance();\n\t\tchart = chartSpace.addNewChart();\n\t\tCTPlotArea plotArea = chart.addNewPlotArea();\n\n\t\tplotArea.addNewLayout();\n\t\tchart.addNewPlotVisOnly().setVal(true);\n\n\t\tCTPrintSettings printSettings = chartSpace.addNewPrintSettings();\n\t\tprintSettings.addNewHeaderFooter();\n\n\t\tCTPageMargins pageMargins = printSettings.addNewPageMargins();\n\t\tpageMargins.setB(0.75);\n\t\tpageMargins.setL(0.70);\n\t\tpageMargins.setR(0.70);\n\t\tpageMargins.setT(0.75);\n\t\tpageMargins.setHeader(0.30);\n\t\tpageMargins.setFooter(0.30);\n\t\tprintSettings.addNewPageSetup();\n\t}", "JFreeChart generateHist();", "private void initialize() {\r\n\t\t//frame = new JFrame();\r\n\t\tframe.setSize(725, 482);\r\n\t\tframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\r\n\t\t//frame.getContentPane().setLayout(null);\r\n\t\t\r\n\t\t\r\n\t\tDefaultCategoryDataset dataset= new DefaultCategoryDataset();\r\n\t\t//JOptionPane.showMessageDialog(null, \"BUTTON CLICKED!!!\");\r\n\t\t//LableMessage.setText(\"BUTTON CLICKED!!!\");\r\n\t\t\r\n\t\t//Pain, Drowsiness, Nausea, Anxiety, and Depression\r\n\t\tdataset.setValue(2, \"day1\",\"Pain\");\r\n\t\tdataset.setValue(5, \"day2\",\"Pain\");\r\n\t\tdataset.setValue(4, \"day3\",\"Pain\");\r\n\t\tdataset.setValue(6, \"day1\", \"Drowsiness\");\r\n\t\tdataset.setValue(10, \"day2\", \"Drowsiness\");\r\n\t\tdataset.setValue(8, \"day3\", \"Drowsiness\");\r\n\t\tdataset.setValue(1, \"day1\", \"Nausea\");\r\n\t\tdataset.setValue(7, \"day2\", \"Nausea\");\r\n\t\tdataset.setValue(5, \"day3\", \"Nausea\");\r\n\t\tdataset.setValue(3,\"day1\",\"Anxiety\");\t\r\n\t\tdataset.setValue(8,\"day2\",\"Anxiety\");\r\n\t\tdataset.setValue(9,\"day3\",\"Anxiety\");\r\n\t\tdataset.setValue(8, \"day1\", \"Depression\");\r\n\t\tdataset.setValue(7, \"day2\", \"Depression\");\r\n\t\tdataset.setValue(9, \"day3\", \"Depression\");\r\n\t\tint test[] = new int[7];\r\n\t\tfor (int i=0;i<7; i++)\r\n\t\t{\r\n\t\t\ttest[i]=5;\r\n\t\t}\r\n\t\tDefaultCategoryDataset dataset2= new DefaultCategoryDataset();\r\n\t\t//dataset2 = dataSetInit(P1.getEnterSymptomLevel(),P1.getPreviousSymptomLevel1(),P1.getPreviousSymptomLevel2());\r\n\t\tdataset2 = dataSetInit(test,test,test);\r\n\t\t//P1.getEnter\r\n\t\t//DefaultCategoryDataset dataset2= new DefaultCategoryDataset();\r\n\r\n\t\t//JFreeChart chart= ChartFactory.createBarChart(P1.firstName+\" \"+P1.lastName,\"Symptoms\", \"Levels\", dataset2, PlotOrientation.VERTICAL,false,true,false);\r\n\r\n\t\tJFreeChart chart= ChartFactory.createBarChart3D(\"Symptom Report\",\"Symptoms\", \"Levels\", dataset2, PlotOrientation.VERTICAL,true,true,true);\r\n\t\t//JFreeChart chart2= ChartFactory.createBarChart(\"Symptom Report\",\"Symptoms\", \"Levels\", dataset2, PlotOrientation.VERTICAL,false,true,false);\r\n\t\tchart.setBackgroundPaint(Color.lightGray);\r\n\t\t//JFreeChart chart2= ChartFactory.createBarChart(\"Grade Report\",\"Student Name\", \"Marks\", dataset2, PlotOrientation.VERTICAL,false,true,false);\r\n\t\t\r\n\t\tChartPanel chartPanel = new ChartPanel(chart);\r\n\t\tchartPanel.setPreferredSize(new Dimension(700,350));\r\n\t\tPan.add(chartPanel);\r\n\t\t\r\n\t\tframe.getContentPane().add(Pan);\r\n\t\tCategoryPlot p=chart.getCategoryPlot();\r\n\t\tp.setRangeGridlinePaint(Color.red);\r\n\t\tp.setBackgroundPaint(Color.WHITE);\r\n\t\tframe.setVisible(true);\r\n//\t\tChartFrame frame= new ChartFrame(\"Bar Graph Test\",chart,false);\r\n//\t\t\r\n//\t\tframe.setVisible(true);\r\n//\t\tframe.setSize(700,350);\r\n//\t\tframe.setResizable(false);\r\n\t\t//frame2 =new JFrame()\r\n\t}", "@Test\n public void test70() throws Throwable {\n CombinedDomainCategoryPlot combinedDomainCategoryPlot0 = new CombinedDomainCategoryPlot((CategoryAxis) null);\n Color color0 = (Color)combinedDomainCategoryPlot0.getRangeGridlinePaint();\n CategoryAxis categoryAxis0 = combinedDomainCategoryPlot0.getDomainAxis();\n JFreeChart jFreeChart0 = new JFreeChart((Plot) combinedDomainCategoryPlot0);\n ChartPanel chartPanel0 = new ChartPanel(jFreeChart0, (-1369), (-797), (-797), (-797), (-797), (-797), true, false, true, true, false, false);\n ChartRenderingInfo chartRenderingInfo0 = chartPanel0.getChartRenderingInfo();\n PlotRenderingInfo plotRenderingInfo0 = new PlotRenderingInfo(chartRenderingInfo0);\n Button button0 = null;\n try {\n button0 = new Button(\"yw{>Kt*0}\");\n } catch(HeadlessException e) {\n //\n // no message in exception (getMessage() returned null)\n //\n assertThrownBy(\"java.awt.GraphicsEnvironment\", e);\n }\n }", "@SuppressWarnings(\"unchecked\")\n // <editor-fold defaultstate=\"collapsed\" desc=\"Generated Code\">//GEN-BEGIN:initComponents\n private void initComponents() {\n\n jPanel1 = new javax.swing.JPanel();\n jButton1 = new javax.swing.JButton();\n jLabel1 = new javax.swing.JLabel();\n\n setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);\n\n jPanel1.setBackground(new java.awt.Color(153, 255, 153));\n jPanel1.setForeground(new java.awt.Color(255, 255, 51));\n jPanel1.setName(\"chartPanel\"); // NOI18N\n jPanel1.setPreferredSize(new java.awt.Dimension(486, 381));\n jPanel1.setLayout(new java.awt.BorderLayout());\n\n jButton1.setText(\"jButton1\");\n jButton1.setName(\"button1\"); // NOI18N\n jButton1.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n jButton1ActionPerformed(evt);\n }\n });\n jPanel1.add(jButton1, java.awt.BorderLayout.PAGE_START);\n\n jLabel1.setText(\"J Frame Chart Test\");\n jPanel1.add(jLabel1, java.awt.BorderLayout.CENTER);\n\n javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());\n getContentPane().setLayout(layout);\n layout.setHorizontalGroup(\n layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)\n .addGroup(layout.createSequentialGroup()\n .addGap(131, 131, 131)\n .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 486, javax.swing.GroupLayout.PREFERRED_SIZE)\n .addContainerGap(835, Short.MAX_VALUE))\n );\n layout.setVerticalGroup(\n layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)\n .addGroup(layout.createSequentialGroup()\n .addGap(23, 23, 23)\n .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 381, javax.swing.GroupLayout.PREFERRED_SIZE)\n .addContainerGap(124, Short.MAX_VALUE))\n );\n\n pack();\n }", "@Test\n public void test73() throws Throwable {\n ExtendedCategoryAxis extendedCategoryAxis0 = new ExtendedCategoryAxis(\"jhpWb\\\"F\");\n CombinedDomainCategoryPlot combinedDomainCategoryPlot0 = new CombinedDomainCategoryPlot((CategoryAxis) extendedCategoryAxis0);\n ExtendedCategoryAxis extendedCategoryAxis1 = (ExtendedCategoryAxis)combinedDomainCategoryPlot0.getDomainAxisForDataset(777);\n List list0 = combinedDomainCategoryPlot0.getCategories();\n Rectangle2D.Double rectangle2D_Double0 = new Rectangle2D.Double();\n ChartRenderingInfo chartRenderingInfo0 = new ChartRenderingInfo();\n rectangle2D_Double0.setFrameFromDiagonal(4364.40135, 0.0, (double) 777, (double) 777);\n PlotRenderingInfo plotRenderingInfo0 = new PlotRenderingInfo(chartRenderingInfo0);\n Rectangle2D.Double rectangle2D_Double1 = (Rectangle2D.Double)plotRenderingInfo0.getDataArea();\n rectangle2D_Double0.setRect((Rectangle2D) rectangle2D_Double1);\n RectangleEdge rectangleEdge0 = combinedDomainCategoryPlot0.getDomainAxisEdge();\n }", "@Test\n public void test77() throws Throwable {\n CombinedDomainCategoryPlot combinedDomainCategoryPlot0 = new CombinedDomainCategoryPlot();\n AxisLocation axisLocation0 = combinedDomainCategoryPlot0.getRangeAxisLocation((-2261));\n Rectangle2D.Double rectangle2D_Double0 = new Rectangle2D.Double((-1788.20871), 0.0, 0.0, 0.0);\n double double0 = rectangle2D_Double0.x;\n JDBCXYDataset jDBCXYDataset0 = new JDBCXYDataset((Connection) null);\n DatasetChangeEvent datasetChangeEvent0 = new DatasetChangeEvent((Object) rectangle2D_Double0, (Dataset) jDBCXYDataset0);\n combinedDomainCategoryPlot0.datasetChanged(datasetChangeEvent0);\n }", "@Test\n public void test77() throws Throwable {\n CombinedDomainCategoryPlot combinedDomainCategoryPlot0 = new CombinedDomainCategoryPlot((CategoryAxis) null);\n combinedDomainCategoryPlot0.setDrawSharedDomainAxis(false);\n DecimalFormat decimalFormat0 = (DecimalFormat)NumberFormat.getCurrencyInstance();\n NumberTickUnit numberTickUnit0 = new NumberTickUnit((-28.552), (NumberFormat) decimalFormat0);\n Color color0 = (Color)Axis.DEFAULT_TICK_MARK_PAINT;\n boolean boolean0 = numberTickUnit0.equals((Object) null);\n TimeTableXYDataset timeTableXYDataset0 = new TimeTableXYDataset();\n RectangleEdge rectangleEdge0 = combinedDomainCategoryPlot0.getDomainAxisEdge();\n CyclicNumberAxis cyclicNumberAxis0 = new CyclicNumberAxis(0.0, 0.0);\n XYAreaRenderer2 xYAreaRenderer2_0 = new XYAreaRenderer2();\n XYPlot xYPlot0 = new XYPlot((XYDataset) timeTableXYDataset0, (ValueAxis) cyclicNumberAxis0, (ValueAxis) cyclicNumberAxis0, (XYItemRenderer) xYAreaRenderer2_0);\n BasicStroke basicStroke0 = (BasicStroke)xYPlot0.getRangeZeroBaselineStroke();\n CategoryMarker categoryMarker0 = new CategoryMarker((Comparable) numberTickUnit0, (Paint) color0, (Stroke) basicStroke0, (Paint) color0, cyclicNumberAxis0.DEFAULT_ADVANCE_LINE_STROKE, 0.85F);\n combinedDomainCategoryPlot0.addRangeMarker((Marker) categoryMarker0);\n int int0 = combinedDomainCategoryPlot0.getRangeAxisIndex(cyclicNumberAxis0);\n Layer layer0 = Layer.BACKGROUND;\n combinedDomainCategoryPlot0.addDomainMarker(0, categoryMarker0, layer0);\n combinedDomainCategoryPlot0.setRenderer((CategoryItemRenderer) null);\n boolean boolean1 = combinedDomainCategoryPlot0.isRangeZoomable();\n Point2D.Double point2D_Double0 = new Point2D.Double((-862.0), 1.0E-6);\n point2D_Double0.y = (double) 0;\n AxisLocation axisLocation0 = combinedDomainCategoryPlot0.getDomainAxisLocation((-2040));\n combinedDomainCategoryPlot0.setDomainAxisLocation(axisLocation0);\n }", "@Test\n public void test08() throws Throwable {\n CategoryPlot categoryPlot0 = new CategoryPlot();\n categoryPlot0.clearDomainMarkers(44);\n BasicStroke basicStroke0 = (BasicStroke)categoryPlot0.getRangeGridlineStroke();\n ValueAxis[] valueAxisArray0 = new ValueAxis[6];\n ThermometerPlot thermometerPlot0 = new ThermometerPlot();\n NumberAxis numberAxis0 = (NumberAxis)thermometerPlot0.getRangeAxis();\n valueAxisArray0[0] = (ValueAxis) numberAxis0;\n LogarithmicAxis logarithmicAxis0 = new LogarithmicAxis(\"Null 'marker' not permitted.\");\n valueAxisArray0[1] = (ValueAxis) logarithmicAxis0;\n LogAxis logAxis0 = new LogAxis();\n valueAxisArray0[2] = (ValueAxis) logAxis0;\n CyclicNumberAxis cyclicNumberAxis0 = new CyclicNumberAxis(0.0, \"o>v!{PNMe{\");\n valueAxisArray0[3] = (ValueAxis) cyclicNumberAxis0;\n NumberAxis3D numberAxis3D0 = new NumberAxis3D(\"Null 'marker' not permitted.\");\n valueAxisArray0[4] = (ValueAxis) numberAxis3D0;\n NumberAxis numberAxis1 = (NumberAxis)thermometerPlot0.getRangeAxis();\n valueAxisArray0[5] = (ValueAxis) numberAxis1;\n XYPlot xYPlot0 = new XYPlot();\n RectangleInsets rectangleInsets0 = xYPlot0.getAxisOffset();\n cyclicNumberAxis0.setTickLabelInsets(rectangleInsets0);\n categoryPlot0.setRangeAxes(valueAxisArray0);\n categoryPlot0.setRangeCrosshairValue(3583.22971, false);\n LegendItemCollection legendItemCollection0 = categoryPlot0.getFixedLegendItems();\n float[] floatArray0 = new float[2];\n floatArray0[0] = (float) 44;\n floatArray0[1] = (float) 44;\n Font font0 = AbstractRenderer.DEFAULT_VALUE_LABEL_FONT;\n }", "@Test\n public void test16() throws Throwable {\n CategoryAxis3D categoryAxis3D0 = new CategoryAxis3D(\"\");\n NumberAxis3D numberAxis3D0 = new NumberAxis3D(\"\");\n LayeredBarRenderer layeredBarRenderer0 = new LayeredBarRenderer();\n CategoryPlot categoryPlot0 = new CategoryPlot((CategoryDataset) null, (CategoryAxis) categoryAxis3D0, (ValueAxis) numberAxis3D0, (CategoryItemRenderer) layeredBarRenderer0);\n JFreeChart jFreeChart0 = new JFreeChart((Plot) categoryPlot0);\n CategoryPlot categoryPlot1 = jFreeChart0.getCategoryPlot();\n boolean boolean0 = categoryPlot1.isDomainGridlinesVisible();\n }", "public void initializeChart(String subtitle) {\n JFreeChart jfreechart = ChartFactory.createXYLineChart(\n subtitle, \"X\", \"Y\", this.dataset.getXYDataset(),\n PlotOrientation.VERTICAL, true, true, false);\n XYPlot xyplot = (XYPlot) jfreechart.getPlot();\n XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer();\n xylineandshaperenderer.setBaseLinesVisible(true);\n\n // System.out.println(\"date set series count: \" + xydataset.getSeriesCount());\n // set visible or not shapes of series\n// System.out.printf(\"sets in the dataset: \"); // TODO delete this \"print\" if necessary\n for (int i = 0; i < this.dataset.seriesCount(); i++) {\n// System.out.printf(this.dataset.getSeries(i).getKey() + \" \");\n xylineandshaperenderer.setSeriesLinesVisible(i, false);\n xylineandshaperenderer.setSeriesShapesVisible(i, this.dataset.shapeVisible(i));\n }\n xylineandshaperenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());\n xyplot.setRenderer(xylineandshaperenderer);\n NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();\n numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());\n this.jPanel = new ChartPanel(jfreechart);\n }", "@PostConstruct\n public void init() {\n\n areaChartByDate = displayerLocator.lookupDisplayer(\n DisplayerSettingsFactory.newAreaChartSettings()\n .dataset(SALES_OPPS)\n .group(CREATION_DATE).dynamic(80, DAY, true)\n .column(CREATION_DATE, \"Creation date\")\n .column(EXPECTED_AMOUNT, SUM).format(AppConstants.INSTANCE.sales_bydate_area_column1(), \"$ #,###\")\n .title(AppConstants.INSTANCE.sales_bydate_area_title())\n .titleVisible(true)\n .width(700).height(200)\n .margins(10, 100, 80, 100)\n .filterOn(true, true, true)\n .buildSettings());\n\n pieChartYears = displayerLocator.lookupDisplayer(\n DisplayerSettingsFactory.newPieChartSettings()\n .dataset(SALES_OPPS)\n .group(CREATION_DATE).dynamic(YEAR, true)\n .column(CREATION_DATE, \"Year\")\n .column(COUNT, \"#occs\").format(AppConstants.INSTANCE.sales_bydate_pie_years_column1(), \"#,###\")\n .title(AppConstants.INSTANCE.sales_bydate_pie_years_title())\n .titleVisible(true)\n .width(200).height(150)\n .margins(0, 0, 0, 0)\n .filterOn(false, true, false)\n .buildSettings());\n\n pieChartQuarters = displayerLocator.lookupDisplayer(\n DisplayerSettingsFactory.newPieChartSettings()\n .dataset(SALES_OPPS)\n .group(CREATION_DATE).fixed(QUARTER, true)\n .column(CREATION_DATE, \"Creation date\")\n .column(COUNT, \"#occs\").format(AppConstants.INSTANCE.sales_bydate_pie_quarters_column1(), \"#,###\")\n .title(AppConstants.INSTANCE.sales_bydate_pie_quarters_title())\n .titleVisible(true)\n .width(200).height(150)\n .margins(0, 0, 0, 0)\n .filterOn(false, true, false)\n .buildSettings());\n\n barChartDayOfWeek = displayerLocator.lookupDisplayer(\n DisplayerSettingsFactory.newBarChartSettings()\n .subType_Bar()\n .dataset(SALES_OPPS)\n .group(CREATION_DATE).fixed(DAY_OF_WEEK, true).firstDay(SUNDAY)\n .column(CREATION_DATE, \"Creation date\")\n .column(COUNT, \"#occs\").format(AppConstants.INSTANCE.sales_bydate_bar_weekday_column1(), \"#,###\")\n .title(AppConstants.INSTANCE.sales_bydate_bar_weekday_title())\n .titleVisible(true)\n .width(200).height(150)\n .margins(0, 20, 80, 0)\n .filterOn(false, true, true)\n .buildSettings());\n\n\n pieChartByPipeline = displayerLocator.lookupDisplayer(\n DisplayerSettingsFactory.newPieChartSettings()\n .dataset(SALES_OPPS)\n .group(PIPELINE)\n .column(PIPELINE, \"Pipeline\")\n .column(COUNT, \"#opps\").format(AppConstants.INSTANCE.sales_bydate_pie_pipe_column1(), \"#,###\")\n .title(AppConstants.INSTANCE.sales_bydate_pie_pipe_title())\n .titleVisible(true)\n .width(200).height(150)\n .margins(0, 0, 0, 0)\n .filterOn(false, true, true)\n .buildSettings());\n\n tableAll = displayerLocator.lookupDisplayer(\n DisplayerSettingsFactory.newTableSettings()\n .dataset(SALES_OPPS)\n .title(AppConstants.INSTANCE.sales_bydate_title())\n .titleVisible(false)\n .tablePageSize(5)\n .tableWidth(800)\n .tableOrderEnabled(true)\n .tableOrderDefault(AMOUNT, DESCENDING)\n .renderer(DefaultRenderer.UUID)\n .column(COUNTRY, AppConstants.INSTANCE.sales_bydate_table_column1())\n .column(CUSTOMER, AppConstants.INSTANCE.sales_bydate_table_column2())\n .column(PRODUCT, AppConstants.INSTANCE.sales_bydate_table_column3())\n .column(SALES_PERSON, AppConstants.INSTANCE.sales_bydate_table_column4())\n .column(STATUS, AppConstants.INSTANCE.sales_bydate_table_column5())\n .column(AMOUNT).format(AppConstants.INSTANCE.sales_bydate_table_column6(), \"$ #,###\")\n .column(EXPECTED_AMOUNT).format(AppConstants.INSTANCE.sales_bydate_table_column7(), \"$ #,###\")\n .column(CREATION_DATE).format(AppConstants.INSTANCE.sales_bydate_table_column8(), \"MMM dd, yyyy\")\n .column(CLOSING_DATE).format(AppConstants.INSTANCE.sales_bydate_table_column9(), \"MMM dd, yyyy\")\n .filterOn(false, true, true)\n .buildSettings());\n\n // Create the selectors\n\n countrySelector = displayerLocator.lookupDisplayer(\n DisplayerSettingsFactory.newSelectorSettings()\n .dataset(SALES_OPPS)\n .group(COUNTRY)\n .column(COUNTRY, \"Country\")\n .column(COUNT, \"#Opps\").format(\"#Opps\", \"#,###\")\n .column(AMOUNT, SUM).format(AppConstants.INSTANCE.sales_bydate_selector_total(), \"$ #,##0.00\")\n .sort(COUNTRY, ASCENDING)\n .filterOn(false, true, true)\n .buildSettings());\n\n salesmanSelector = displayerLocator.lookupDisplayer(\n DisplayerSettingsFactory.newSelectorSettings()\n .dataset(SALES_OPPS)\n .group(SALES_PERSON)\n .column(SALES_PERSON, \"Employee\")\n .column(COUNT, \"#Opps\").format(\"#Opps\", \"#,###\")\n .column(AMOUNT, SUM).format(AppConstants.INSTANCE.sales_bydate_selector_total(), \"$ #,##0.00\")\n .sort(SALES_PERSON, ASCENDING)\n .filterOn(false, true, true)\n .buildSettings());\n\n customerSelector = displayerLocator.lookupDisplayer(\n DisplayerSettingsFactory.newSelectorSettings()\n .dataset(SALES_OPPS)\n .group(CUSTOMER)\n .column(CUSTOMER, \"Customer\")\n .column(COUNT, \"#Opps\").format(\"#Opps\", \"#,###\")\n .column(AMOUNT, SUM).format(AppConstants.INSTANCE.sales_bydate_selector_total(), \"$ #,##0.00\")\n .sort(CUSTOMER, ASCENDING)\n .filterOn(false, true, true)\n .buildSettings());\n\n // Make the displayers interact among them\n displayerCoordinator.addDisplayer(areaChartByDate);\n displayerCoordinator.addDisplayer(pieChartYears);\n displayerCoordinator.addDisplayer(pieChartQuarters);\n displayerCoordinator.addDisplayer(barChartDayOfWeek);\n displayerCoordinator.addDisplayer(pieChartByPipeline);\n displayerCoordinator.addDisplayer(tableAll);\n displayerCoordinator.addDisplayer(countrySelector);\n displayerCoordinator.addDisplayer(salesmanSelector);\n displayerCoordinator.addDisplayer(customerSelector);\n\n // Init the dashboard from the UI Binder template\n initWidget(uiBinder.createAndBindUi(this));\n\n // Draw the charts\n displayerCoordinator.drawAll();\n }", "public static String exampleBarChart2() {\n final int MAX_MEDALS = 51;\n Data goldData= DataUtil.scaleWithinRange(0, MAX_MEDALS, Arrays.asList(MAX_MEDALS, 36, 23, 19, 16));\n Data silverData= DataUtil.scaleWithinRange(0, MAX_MEDALS, Arrays.asList(21, 38, 21, 13, 10));\n Data bronzeData= DataUtil.scaleWithinRange(0, MAX_MEDALS, Arrays.asList(28, 36, 28, 15, 15));\n BarChartPlot gold = Plots.newBarChartPlot(goldData, GOLD, \"Gold\");\n BarChartPlot silver = Plots.newBarChartPlot(silverData, SILVER, \"Silver\");\n BarChartPlot bronze = Plots.newBarChartPlot(bronzeData, Color.BROWN, \"Bronze\");\n BarChart chart = GCharts.newBarChart(gold, silver, bronze);\n\n // Defining axis info and styles\n AxisStyle axisStyle = AxisStyle.newAxisStyle(BLACK, 13, AxisTextAlignment.CENTER);\n AxisLabels country = AxisLabelsFactory.newAxisLabels(\"Country\", 50.0);\n country.setAxisStyle(axisStyle);\n AxisLabels countries = AxisLabelsFactory.newAxisLabels(\"Germany\", \"United Kingdom\", \"Russia\", \"USA\", \"China\");\n countries.setAxisStyle(axisStyle);\n AxisLabels medals = AxisLabelsFactory.newAxisLabels(\"Medals\", 50.0);\n medals.setAxisStyle(axisStyle);\n AxisLabels medalCount = AxisLabelsFactory.newNumericRangeAxisLabels(0, MAX_MEDALS);\n medalCount.setAxisStyle(axisStyle);\n\n\n // Adding axis info to chart.\n chart.addXAxisLabels(medalCount);\n chart.addXAxisLabels(medals);\n chart.addYAxisLabels(countries);\n chart.addYAxisLabels(country);\n chart.addTopAxisLabels(medalCount);\n chart.setHorizontal(true);\n chart.setSize(450, 650);\n chart.setSpaceBetweenGroupsOfBars(30);\n\n chart.setTitle(\"2008 Beijing Olympics Medal Count\", BLACK, 16);\n ///51 is the max number of medals.\n chart.setGrid((50.0/MAX_MEDALS)*20, 600, 3, 2);\n chart.setBackgroundFill(Fills.newSolidFill(LIGHTGREY));\n LinearGradientFill fill = Fills.newLinearGradientFill(0, Color.newColor(\"E37600\"), 100);\n fill.addColorAndOffset(Color.newColor(\"DC4800\"), 0);\n chart.setAreaFill(fill);\n String url = chart.toURLString();\n return url;\n }", "private void initChart() {\r\n /*mCurrentSeries = new XYSeries(\"Sample Data\");\r\n mDataset.addSeries(mCurrentSeries);\r\n mCurrentRenderer = new XYSeriesRenderer();\r\n mRenderer.addSeriesRenderer(mCurrentRenderer);*/\r\n \t\r\n \tList<Integer> MyListValue = new ArrayList<Integer>();\r\n\t\t/*for (int i = 0; i < SpeakingTimeList.size(); i++){\r\n\t\t\tMyListValue.add(SpeakingTimeList.get(i));\r\n\t\t}*/\r\n\t\tfor (int i = 0; i < participantAndSpeakingTimeList.size(); i++){\r\n\t\t\tMyListValue.add(participantAndSpeakingTimeList.get(i).getValue());\r\n\t\t}\r\n\t\t\r\n\t\t/*MyList.add(25);\r\n\t\tMyList.add(10);\r\n\t\tMyList.add(15);\r\n\t\tMyList.add(20);*/\r\n\t\t\t\t\r\n\t\tint[] y = new int[MyListValue.size()];\r\n\t\tfor (int i = 0; i < MyListValue.size(); i++) \r\n\t\t\ty[i] = MyListValue.get(i);\r\n\t\t\r\n\t\t//int y[] = {25,10,15,20};\r\n\t \r\n CategorySeries series = new CategorySeries(\"Speaking time in secondes\");\r\n for(int i=0; i < y.length; i++){\r\n series.add(\"Bar\"+(i+1),y[i]);\r\n }\r\n \r\n dataSet = new XYMultipleSeriesDataset(); // collection of series under one object.,there could any\r\n dataSet.addSeries(series.toXYSeries()); // number of series\r\n \r\n //customization of the chart\r\n \r\n XYSeriesRenderer renderer = new XYSeriesRenderer(); // one renderer for one series\r\n renderer.setColor(Color.parseColor(\"#0099FF\"));\r\n renderer.setDisplayChartValues(true);\r\n renderer.setChartValuesSpacing((float) 5.5d);\r\n renderer.setLineWidth((float) 10.5d);\r\n \r\n \r\n mRenderer = new XYMultipleSeriesRenderer(); // collection multiple values for one renderer or series\r\n mRenderer.addSeriesRenderer(renderer);\r\n mRenderer.setChartTitle(\"Speaking time per participant\");\r\n// mRenderer.setXTitle(\"xValues\");\r\n mRenderer.setYTitle(\"Time in secondes\");\r\n mRenderer.setZoomButtonsVisible(true); mRenderer.setShowLegend(true);\r\n mRenderer.setShowGridX(true); // this will show the grid in graph\r\n mRenderer.setShowGridY(true); \r\n// mRenderer.setAntialiasing(true);\r\n mRenderer.setBarSpacing(.5); // adding spacing between the line or stacks\r\n mRenderer.setApplyBackgroundColor(true);\r\n mRenderer.setBackgroundColor(Color.BLACK);\r\n mRenderer.setXAxisMin(0);\r\n mRenderer.setYAxisMin(0);\r\n //mRenderer.setXAxisMax(5);\r\n /*mRenderer.setXAxisMax(ParticipantsList.size()+1);*/\r\n mRenderer.setXAxisMax(participantAndSpeakingTimeList.size()+1);\r\n //mRenderer.setYAxisMax(100);\r\n mRenderer.setYAxisMax(Math.round(getMaxValue()/10)*10+10);\r\n// \r\n \r\n mRenderer.setXLabels(0);\r\n \r\n mRenderer.setXLabelsAngle(90);\r\n mRenderer.setXLabelsAlign(Align.LEFT);\r\n \r\n /*for (int i = 0; i < ParticipantsList.size(); i++){\r\n\t\t\tmRenderer.addXTextLabel(i+1, ParticipantsList.get(i));\r\n\t\t}*/\r\n for (int i = 0; i < participantAndSpeakingTimeList.size(); i++){\r\n\t\t\tmRenderer.addXTextLabel(i+1, participantAndSpeakingTimeList.get(i).getName());\r\n\t\t}\r\n \r\n /*mRenderer.addXTextLabel(1,\"Income\");\r\n mRenderer.addXTextLabel(2,\"Saving\");\r\n mRenderer.addXTextLabel(3,\"Expenditure\");\r\n mRenderer.addXTextLabel(4,\"NetIncome\");*/\r\n \r\n mRenderer.setPanEnabled(true, true); // will fix the chart position\r\n //Intent intent = ChartFactory.getBarChartIntent(context, dataSet, mRenderer,Type.DEFAULT);\r\n \r\n //return intent;\r\n\r\n\t\r\n\t}", "public MotionChartPanel () {\n super( null );\n\n // Data set.\n setLayout( new BorderLayout() );\n\n// setMaximumDrawWidth( Toolkit.getDefaultToolkit().getScreenSize().width );\n// setMaximumDrawHeight( Toolkit.getDefaultToolkit().getScreenSize().height );\n\n final DynamicTimeSeriesCollection dataset1 = new DynamicTimeSeriesCollection( 1, COUNT, new Second() );\n dataset1.setTimeBase( new Second( 0, 0, 0, 1, 1, 2011 ) );\n dataset1.addSeries( initialPositionData(), 0, POSITION_SERIES_TEXT );\n\n final DynamicTimeSeriesCollection dataset2 = new DynamicTimeSeriesCollection( 1, COUNT, new Second() );\n dataset2.setTimeBase( new Second( 0, 0, 0, 1, 1, 2011 ) );\n dataset2.addSeries( initialSpeedData(), 0, SPEED_SERIES_TEXT );\n\n // Create the chart.\n JFreeChart chart = createChart( dataset1, dataset2 );\n setChart( chart );\n setRangeBound( 200000, 2500 );\n setMouseZoomable( false );\n\n // Timer (Refersh the chart).\n timer = new Timer( 10, new ActionListener() {\n\n /**\n * The speed previous plotted.\n */\n private float prevSpeed;\n\n /**\n * The position previous plotted.\n */\n private float prevPosition;\n @Override\n public void actionPerformed ( ActionEvent e ) {\n if ( speedQueue.isEmpty() == false && positionQueue.isEmpty() == false ) {\n long time = System.currentTimeMillis();\n prevSpeed = speedQueue.poll();\n prevPosition = positionQueue.poll();\n dataset1.advanceTime();\n dataset2.advanceTime();\n dataset1.appendData( new float[]{ prevPosition } );\n dataset2.appendData( new float[]{ prevSpeed } );\n }\n\n// else {\n // Maintain previous record once no new record/enough record could show.\n// dataset1.appendData( new float[]{ prevPosition } );\n// dataset2.appendData( new float[]{ prevSpeed } );\n// }\n }\n } );\n }", "public GraphicalView execute(Context context) {\r\n double[] minValues = new double[] { 4300, 3500, 5300, 4900, 3800, 2900, };\r\n double[] maxValues = new double[] { 8000,7000, 9700, 8600, 7000, 6500};\r\n\r\n XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();\r\n RangeCategorySeries series = new RangeCategorySeries(\"波动情况\");\r\n int length = minValues.length;\r\n for (int k = 0; k < length; k++) {\r\n series.add(minValues[k], maxValues[k]);\r\n }\r\n dataset.addSeries(series.toXYSeries());\r\n int[] colors = new int[] { Color.CYAN };\r\n XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);\r\n setChartSettings(renderer, \"好友们最近一周的能量波动范围\", \"用户\", \"能量值\", 0.5, 6.5,\r\n 2000, 12000, Color.GRAY, Color.LTGRAY);\r\n renderer.setBarSpacing(1);\r\n renderer.setXLabels(0);\r\n renderer.setYLabels(10);\r\n renderer.addXTextLabel(1, \"任东卫\");\r\n renderer.addXTextLabel(2, \"罗智宜\");\r\n renderer.addXTextLabel(3, \"郭子涵\");\r\n renderer.addXTextLabel(4, \"谢以荷\");\r\n renderer.addXTextLabel(5, \"赵一援\");\r\n renderer.addXTextLabel(6, \"萧之雁\");\r\n renderer.addYTextLabel(3000, \"心情差\");\r\n renderer.addYTextLabel(4500, \"心情有点差\");\r\n renderer.addYTextLabel(6000, \"心情一般\");\r\n renderer.addYTextLabel(8500, \"心情棒\");\r\n renderer.setMargins(new int[] {30, 70, 30, 70});\r\n renderer.setYLabelsAlign(Align.RIGHT);\r\n SimpleSeriesRenderer r = renderer.getSeriesRendererAt(0);\r\n r.setDisplayChartValues(true);\r\n r.setChartValuesTextSize(12);\r\n r.setChartValuesSpacing(3);\r\n r.setGradientEnabled(true);\r\n r.setGradientStart(4000, Color.parseColor(\"#B0C4DE\"));\r\n r.setGradientStop(8000, Color.parseColor(\"#00AAAA\"));\r\n return ChartFactory.getRangeBarChartView(context, dataset, renderer, Type.DEFAULT);\r\n }", "private void initPieChart(){\n }", "private JPanel createChartPanel(XYSeriesCollection li) {\n\n String chartTitle = \" Movement Chart\";\n String xAxisLabel = \"Matrix Size\";\n String yAxisLabel = \"time in ms\";\n\n XYSeriesCollection dataset = li;\n // System.out.println(\"tesst count \" + dataset.getSeriesCount());\n\n //XYDataset dataset = createDataset(li);\n JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, xAxisLabel, yAxisLabel, dataset);\n XYPlot plot = chart.getXYPlot();\n XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();\n plot.setRenderer(renderer);\n\n return new ChartPanel(chart);\n }" ]
[ "0.6993843", "0.6697136", "0.6450347", "0.6378541", "0.6352176", "0.6318332", "0.6297686", "0.6294173", "0.62747586", "0.62656677", "0.6264921", "0.626342", "0.62578", "0.6239284", "0.622722", "0.6192045", "0.6151552", "0.61465806", "0.61280394", "0.61243254", "0.6113349", "0.6105349", "0.60864127", "0.60508215", "0.6050252", "0.60371226", "0.6020736", "0.6000497", "0.59879154", "0.5980153", "0.59681624", "0.59535074", "0.59498984", "0.594546", "0.59404284", "0.59297615", "0.5927857", "0.58912796", "0.5863444", "0.58623064", "0.5861551", "0.5859015", "0.5842658", "0.5835873", "0.58241403", "0.5813256", "0.58056295", "0.5804422", "0.57987934", "0.5794955", "0.5793068", "0.57864976", "0.5782717", "0.5768362", "0.5760334", "0.5756996", "0.57550085", "0.57545877", "0.5753277", "0.57441336", "0.5744017", "0.573499", "0.5726085", "0.5725621", "0.57224965", "0.5702885", "0.5688402", "0.56850636", "0.56753397", "0.5669086", "0.56682175", "0.56667864", "0.5662471", "0.566067", "0.56581086", "0.5650027", "0.56331974", "0.56319636", "0.5617764", "0.561174", "0.56068456", "0.5604905", "0.5601693", "0.55960613", "0.55651706", "0.5561536", "0.5556464", "0.55557394", "0.555281", "0.5550439", "0.5537464", "0.55314344", "0.55283", "0.55222726", "0.5521044", "0.55188245", "0.55097765", "0.5507638", "0.5506207", "0.54989207", "0.5496545" ]
0.0
-1
Constructs the demo application.
public MainGradientDescentGUI(final GradientDescent gd) { super("Gradient Descent"); XYDataset dataset = createSampleDataset(gd); JFreeChart chart = ChartFactory.createXYLineChart( "Gradient Descent [" + gd.getCurrentIteration() + "]", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false ); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, false); renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, true); plot.setRenderer(renderer); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 300)); setContentPane(chartPanel); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public DemonstrationApp()\n {\n // Create Customers of all 3 types\n s = new Senior(\"alice\", \"123 road\", 65, \"555-5555\", 1);\n a = new Adult(\"stacy\", \"123 lane\", 65, \"555-1111\", 2);\n u = new Student(\"bob\", \"123 street\", 65, \"555-3333\", 3);\n \n //Create an account for each customer \n ca = new CheckingAccount(s,1,0);\n sa = new SavingsAccount(a,2,100);\n sav = new SavingsAccount(u,3,1000);\n \n //Create a bank\n b = new Bank();\n \n //Create a date object\n date = new Date(2019, 02, 12);\n }", "public Main() {\r\n\t\tsuper();\r\n\t\tinitialize();\r\n\r\n\t}", "public DemoScreenControllerMasterApp(String[] args) {\r\n\t\t// transfer args to start the selected demo \r\n\t\t// via listener callback method \"tfStackReConnected()\" \r\n\t\t// => see end of this class\r\n\t\tthis.args = args;\r\n\t\t\r\n\r\n\t\t// Define Tinkerforge Stack (Listener)\r\n\t\tdemoTfStack = new DemoTfStackImpl(this);\r\n\r\n\t\t\r\n\t\t//Create connection and add listener\r\n\t\tnew TfConnectService(\"localhost\",4223, null, demoTfStack);\r\n\t\t\r\n\t\t// Define Clone LCD Connection\r\n\t\t// Connect will be processed after this stack is connected\r\n\t\tcloneHost = \"Tf-AU-EG-WZ\";\r\n\t\tclonePort = 4223;\r\n\t}", "public MainApp() {\n initComponents();\n }", "public void init()\n {\n _appContext = SubAppContext.createOMM(System.out);\n _serviceName = CommandLine.variable(\"serviceName\");\n initGUI();\n }", "public MyDemoApplication(){\n\t\t//System.out.println(\"hi\");\n\t\t/*register(RequestContextFilter.class);\n\t\tregister(RestServiceUsingJersey.class);\n\t\tregister(ServiceYearImpl.class);\n\t\tregister(YearDaoImpl.class);\n\t\tregister(JacksonFeature.class);*/\n\t\t\n\t\t/**\n\t\t * Register JAX-RS application components.\n\t\t */\n\t\t\n\t\t\t\n\t packages(\"com.reporting.webapi\");\n\n\t\t\t// register features\n\t\t\tEncodingFilter.enableFor(this, GZipEncoder.class);\t\t\n\t\t\t\n\t\n\n\t}", "public App() {\n initComponents();\n }", "public App() {\n initComponents();\n }", "public static void main(String[] args) {\n new GraphicStudyApp();\n }", "public Application()\n {\n newsFeed = new NewsFeed();\n test = new Test();\n \n makeDummies();\n display();\n displayShortSummary();\n runTest();\n }", "public DefaultApplication() {\n\t}", "public main() {\n initComponents();\n \n }", "public ClientApp()\n\t{\n\t\tinitComponents();\n\t\tafterInitComponents();\n\t}", "public Main() {\n \n \n }", "Main ()\n\t{\n\t\tview = new View ();\t\t\n\t\tmodel = new Model(view);\n\t\tcontroller = new Controller(model, view);\n\t}", "public static void main(String[] args)\n {\n\n DemoCliApp demo = new DemoCliApp();\n demo.run();\n }", "public MainApp() {\r\n\t\tsuper();\r\n\t\tthis.setSize(642, 455);\r\n\t\tthis.setContentPane(getJContentPane());\r\n\t}", "public static void main(String args[]) {\n \t// create the app\n \tGLApp_Demo_lines demo = new GLApp_Demo_lines();\n\n \t// set title, window size\n \tdemo.window_title = \"Hello World\";\n \tdemo.displayWidth = 640;\n \tdemo.displayHeight = 480;\n\n \t// start running: will call init(), setup(), draw(), mouse functions\n \tdemo.run();\n }", "private Main() {\n\n super();\n }", "public static void main(String args[]) {\n Greeting.ToyApp toyApp = DaggerGreeting_ToyComponent.builder().build().toyApp();\n toyApp.greeting.sayHello();\n }", "public Main() {\n\t\tsuper();\n\t}", "public MainEntryPoint() {\r\n\r\n }", "public Demo() {\n\t\t\n\t}", "public void startDemo() {\n // Welcoming display\n this.view.displayMenu();\n\n // State of the inventory and the users\n this.view.displaySystem(this.system);\n\n this.view.displayExampleMessage();\n\n // Example with a student\n Student s = this.system.getStudents().get(0);\n\n Calendar startDate = Calendar.getInstance();\n Calendar endDate = Calendar.getInstance();\n endDate.setTimeInMillis(endDate.getTimeInMillis() + 6*24*60*60*1000);\n\n Loan l = s.book(Model.IPAD3, new Period(startDate, endDate));\n this.system.checkLoan(l);\n\n this.view.displayBorrow(s, l);\n this.system.putAway(l);\n this.view.displayReturn(s, l);\n\n // Example with a teacher\n\n Teacher t = this.system.getTeachers().get(0);\n\n Loan l2 = s.book(Model.XPERIAZ, new Period(startDate, endDate));\n this.system.checkLoan(l2);\n\n this.view.displayBorrow(t, l2);\n this.system.putAway(l2);\n this.view.displayReturn(t, l2);\n\n }", "@Override\n public void simpleInitApp() {\n configureCamera();\n configureMaterials();\n viewPort.setBackgroundColor(new ColorRGBA(0.5f, 0.2f, 0.2f, 1f));\n configurePhysics();\n initializeHeightData();\n addTerrain();\n showHints();\n }", "@Inject\n\tMainApp(SimpleApplication app, GuiManager guiManager, PageManager<Pages> pageManager) {\n\t\t//\t\tsetAspectRatio(app, 16, 9);\n\t\tSetupHelpers.disableDefaults(app);\n\t\tSetupHelpers.setDebug(app, false);\n\t\tSetupHelpers.logJoystickInfo(app.getInputManager());\n\t\tinitLoaders(app);\n\t\tinitGui(guiManager);\n\t\tinitPages(pageManager, app, false);\n\t}", "public static void main(String[] argv) {\r\n\t\tDemo15 demo = new Demo15();\r\n\t\tdemo.start();\r\n\t}", "public MainGUI() {\n\t\tString xmlpath = \"classpath:applicationContext.xml\";\n\t\tApplicationContext applicationContext = new ClassPathXmlApplicationContext(xmlpath);\n\t\t\n\t\tcenter = (CenterController)applicationContext.getBean(\"CenterController\");\n\t\t\n\t\tinitialize();\n\t\t\n\t}", "@Override\n public void start (Stage primaryStage) {\n Group root = new Group();\n Scene scene = new Scene(root, AppConstants.STAGE_WIDTH, AppConstants.STAGE_HEIGHT);\n ModulePopulator = new ModuleCreationHelper(root, scene, primaryStage);\n view = new View();\n scene.setFill(AppConstants.BACKGROUND_COLOR);\n // scene.getStylesheets().add(getClass().getResource(\"application.css\").toExternalForm());\n view.init(root, ModulePopulator);\n ModulePopulator.setView(view);\n ModulePopulator.createMainPageModules();\n view.initRunner(root, ModulePopulator);\n primaryStage.setTitle(\"SLogo!\");\n primaryStage.setScene(scene);\n primaryStage.show();\n\n System.out.println(\"App Has Started!\");\n }", "public static void main(String args[]) throws IOException {\n GUI app = new GUI();\n }", "public App() {\n\t\tLog.d(\"App\", \"App created\");\n\t\tinstance = this;\n\t}", "public static void main(String[] args) {\n // Create the system.\n Application.launch( args );\n }", "public static void main(String[] args) {\n // Start App\n EventQueue.invokeLater(new Runnable() {\n @Override\n public void run() { new App(); }\n });\n }", "public static void main(String[] args) {\n //Size of window\n int width = 1000;\n int height = 1100;\n Model m = new Model();\n View v = new View(m);\n Controller c = new Controller(m, v);\n v.setController(c);\n c.init(width, height);\n }", "public ApplicationCreator() {\n }", "public static void main(String[] args) {\n new MyApp();\n }", "public static void main(String[] args) {\n TextTransformerApp2 application = new TextTransformerApp2();\n application.createAndShowGUI();\n }", "public MediaWSDemoApplication(BundleContext context) {\n\t\ttheContext = context ;\n\t}", "public StockApp()\n {\n reader = new InputReader();\n manager = new StockManager();\n menuSetup();\n }", "public static void main(String[] args) {\r\n \t\r\n // Creates new controller named the main controller\r\n GlobalResources.MainControl = new Control();\r\n // Starts main application\r\n GlobalResources.MainControl.StartApplication();\r\n }", "public static void main(String[] args) {\n demoClass();\n }", "public static void main(String[] args) {\n demoClass();\n }", "public DemoComponentManager() {\n this(PROJECT_ROOT_PATH, DEFAULT_EFFECTS_PATHS, DEFAULT_CALCULATORS_PATHS);\n }", "public MainDemo() {\n initComponents(); // Init Components from de Matisse form's design\n initBaseIcons(); // Init base icons\n initBusyIcons(); // Init busy icons\n\n /** Complete specific initialization of each tabs\n */\n initJBusyComponentTab();\n initBusyIconTab();\n initHubTab();\n initWorkerTab();\n\n updateBusyIconModel();\n }", "public static void main(String[] args) {\n\r\n Starter starter = new Starter();\r\n starter.start();\r\n\r\n\r\n }", "private SudokuSolverApplication() {\n\t}", "public ChatbotAppController()\n\t{\n\t\tapplicationView = new ChatbotView(this);\n\t\tbaseFrame = new ChatbotFrame(this);\n\t\tmySillyChatbot = new Chatbot(\"Derf\");\n\t\tstartMessage = \"Welcome to the \" + mySillyChatbot.getName() + \" chatbot. What is your name?\";\n\t\tquitMessage = \"goodbye cruel user :(\";\n\t\tcontentMessages = \"That's really cool I love riding motorcycles too!\";\n\t}", "public Main() {\r\n\t}", "public App() {\n\t\tContainer pane = getContentPane();\n\t\t\n\t\ttetapan = new JButton(\"Tetapan\");\n\t\tpane.add(tetapan);\n\t\ttetapan.setBounds(10, 20, 80, 30);\n\t\t// tetapan.addActionListener(arg0);\n\t\tcarian = new JTextField(\"Cari...\");\n\t\tpane.add(carian);\n\t\tcarian.setBounds(260, 20, 150, 30);\n\t\tcari = new JButton(\"Cari\");\n\t\tpane.add(cari);\n\t\tcari.setBounds(410, 20, 60, 30);\n\t\t// cari.addActionListener(arg0);\n\t}", "@Override\n public void simpleInitApp() {\n this.viewPort.setBackgroundColor(ColorRGBA.LightGray);\n im = new InteractionManager();\n setEdgeFilter();\n initEnemies();\n initCamera();\n initScene();\n initPlayer();\n initCrossHairs();\n }", "public static void main(String[] args) {\n SimpleUserInterface app = new SimpleUserInterface();\n app.start();\n }", "public static void main(String[] args) {\n\t\tEventQueue.invokeLater(new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tDemo gui = new Demo();\n\t\t\t\tgui.setVisible(true);\n\t\t\t}\n\t\t});\n\t}", "public static void main(String[] args) {\n InitStart.Init();\r\n new MainMenuView().displayMenu();\r\n\r\n }", "public static void main(String[] args) {\n\t\tnew OpenDemo();\r\n\t}", "public static void main(String[] args) {\n\t\tnew App();\r\n\t}", "public Main() {\n\t\tsuper();\n\t\tInitScreen screen = new InitScreen();\n\t\tpushScreen(screen);\n\t\tUiApplication.getUiApplication().repaint();\n\t}", "public GuiMain02() {\r\n\t\tinitialize();\r\n\t}", "public ParkingApp() {\n runApp();\n }", "public static void main(String[] args) {\n Injector guice = Guice.createInjector(new DiscountGuiceModule());\n\n // Creates separate object graph with business logic, etc. Instantiate the main object on that\n MainAppWithCustomFactory application = guice.getInstance(MainAppWithCustomFactory.class);\n\n // Start your app\n application.start();\n }", "public static void main ( String[] args ) {\n PhoneBook myApp = new PhoneBook(); \r\n }", "@Override\n @SuppressWarnings(\"CallToPrintStackTrace\")\n public void simpleInitApp() {\n \n\n try {\n System.out.println(\"Using port \" + port);\n // create the server by opening a port\n server = Network.createServer(port);\n server.start(); // start the server, so it starts using the port\n } catch (IOException ex) {\n ex.printStackTrace();\n destroy();\n this.stop();\n }\n System.out.println(\"Server started\");\n // create a separat thread for sending \"heartbeats\" every now and then\n new Thread(new NetWrite()).start();\n server.addMessageListener(new ServerListener(), ChangeVelocityMessage.class);\n // add a listener that reacts on incoming network packets\n \n }", "public static void main(String[] args) {\n TestApp testApp=new TestApp();\r\n testApp.startApp();\r\n }", "public SimpleWorkspaceApplication (String[] args) {\n super (args, false);\n Frame f;\n commandHandler = new ApplicationCommandHandler ();\n MenuBar mb = setupMenu ();\n String title = getTitleInformation ();\n setCurrentFrame (f = new Frame (title != null ? title : \"Simple Workspace Application\"));\n f.setMenuBar (mb);\n String geometry = getGeometryInformation ();\n if (geometry == null)\n f.setBounds (0, 0, 600, 400);\n else {\n Rectangle desiredBounds = parseBounds (geometry);\n f.setBounds (desiredBounds.x, desiredBounds.y, desiredBounds.width, desiredBounds.height);\n }\n\n f.add (multiWkspView = new MultipleWorkspaceView (), BorderLayout.CENTER);\n f.addWindowListener(new WindowAdapter() {\n @Override\n public void windowClosing(WindowEvent e) {\n\tSystem.exit(0);\n }\n });\n }", "public static void main(String args[]){\n\n createConnection();\n\n if (conn == null) {\n System.err.println(\"Failed to establish connection!\");\n }\n\n new App();\n\n }", "public static void main(String[] args) {\n WeatherApplication gui = new WeatherApplication( );\n \n // make window visible\n gui.setVisible( true );\n \n }", "public AuctionApp() {\r\n runAuctionApp();\r\n }", "public static void main(String[] args) {\n\t\tHelloAiming app = new HelloAiming();\n app.setConfigShowMode(ConfigShowMode.AlwaysShow);\n\t\tapp.start();\n\n\t}", "public MusicClientApp() {\n\n tlm = new TrackListModel(new RecordDto());\n rcm = new RecordComboBoxModel(new MusicCollectionDto());\n scm = new PlayerComboBoxModel(new ArrayList<>());\n sercm = new ServerComboBoxModel(new ArrayList<>());\n\n initComponents();\n\n EventQueue.invokeLater(new Runnable() {\n @Override\n public void run() {\n StartMusicClient smc = new StartMusicClient(MusicClientApp.this);\n new Thread(smc).start();\n }\n });\n }", "public static void main(String[] argv) {\r\n new BubbleGraphDemo(new BasicFrame(\"Bubble Graph Demo\"));\r\n }", "public Client_app() {\n initComponents();\n }", "public MainView() {\r\n\t\tinitialize();\r\n\t}", "@Override\n public void simpleInitApp()\n {\n makeInitialWorld();\n \tAudio audio = new Audio(assetManager, rootNode);\n inputManager.setCursorVisible(false);\n \trootNode.attachChild(overlayNode);\n\n \tflyCam.setEnabled(true);\n flyCam.setMoveSpeed(25);\n\n setDisplayFps(true);\n setDisplayStatView(true);\n\n GUIInfo guiInfo = new GUIInfo(guiNode, assetManager.loadFont(\"Interface/Fonts/Console.fnt\"));\n guiNode.addControl(guiInfo);\n }", "public void start(){\n JmeFormatter formatter = new JmeFormatter();\n\n Handler consoleHandler = new ConsoleHandler();\n consoleHandler.setFormatter(formatter);\n\n Logger.getLogger(\"\").removeHandler(Logger.getLogger(\"\").getHandlers()[0]);\n Logger.getLogger(\"\").addHandler(consoleHandler);\n \n createCanvas(appClass);\n \n try {\n Thread.sleep(500);\n } catch (InterruptedException ex) {\n }\n \n SwingUtilities.invokeLater(new Runnable(){\n public void run(){\n JPopupMenu.setDefaultLightWeightPopupEnabled(false);\n\n createFrame();\n \n //currentPanel.add(canvas, BorderLayout.CENTER);\n mMainFrame.pack();\n startApp();\n mMainFrame.setLocationRelativeTo(null);\n mMainFrame.setVisible(true);\n }\n });\n \n \n }", "public Main() {\n }", "public Main() {\r\n }", "public Main() {\r\n }", "public static void main(String[] args) {\n SettVisualizer.startApplication();\r\n }", "private Main ()\n {\n super ();\n }", "public Main() {}", "public static void main(String[] args) {\n\t\tif (sNeedRepack == 1) {\n\t\t\trepackGfx();\n\t\t\tSystem.out.printf(\"repacking completed; don't forget to refresh projects(F5 eclipse)\");\n\t\t\treturn;\n\t\t}\n\t\tif (sNeedCrypt == 1) {\n\t\t\tcryptAssets();\n\t\t\tSystem.out.printf(\"encrypting completed; don't forget to refresh projects(F5 eclipse)\");\n\t\t\treturn;\n\t\t}\n\n\t\tLwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();\n\t\tcfg.title = \"Demo Title\";\n\t\tcfg.width = 1280;\n\t\tcfg.height = 800;\n\t\t\n\t\t\n\t\tCoreManager coreManager = new CoreManager(new CoreOsManager() {\n\t\t\t@Override\n\t\t\tpublic void doAction(int actionId, UniversalBundle bundle) {\n\t\t\t}\n\t\t}, 32, 20) {\n\t\t\t@Override\n\t\t\tpublic void create() {\n\t\t\t\tsuper.create();\n\t\t\t\tCoreScreen screen = new ExampleGameScreen();\n\t\t\t\tpushScreen(screen);\n\t\t\t\tpushScreen(screen.createLoaderScreen());\n\t\t\t}\n\t\t};\n\n\t\tnew LwjglApplication(coreManager, cfg);\n\t}", "public void init() {\n \t\tWindow main = new Window(\"Table demo\");\n \t\tsetMainWindow(main);\n \n \t\t// set the application to use Corporate -theme\n \t\tsetTheme(\"corporate\");\n \n \t\t// Add link back to index.html\n \t\tmain.addComponent(menuLink);\n \n \t\t// create demo database\n \t\tsampleDatabase = new SampleDatabase();\n \n \t\t// Main window contains heading, two buttons, table and label\n \t\tmain.addComponent(new Label(\"<h2>Table demo</h2>\" + ACTION_DESCRIPTION,\n \t\t\t\tLabel.CONTENT_XHTML));\n \t\tOrderedLayout layout = new OrderedLayout(\n \t\t\t\tOrderedLayout.ORIENTATION_HORIZONTAL);\n \t\tlayout.addComponent(tableVisibility);\n \t\tlayout.addComponent(tableEnabler);\n \t\tlayout.addComponent(tableCaption);\n \t\tmain.addComponent(layout);\n \t\tmain.addComponent(table);\n \t\tmain.addComponent(tableLastAction);\n \t\tmain.addComponent(embeddedToolkitLink);\n \t\tmain.addComponent(tableDemoLink);\n \n \t\t// initialize demo components\n \t\tinitTable();\n \t}", "public Main() {\n initComponents();\n }", "public Main() {\n initComponents();\n }", "public Main() {\n initComponents();\n }", "public Main() {\n initComponents();\n }", "public Main() {\n initComponents();\n }", "public Main() {\n // Required empty public constructor\n }", "public static void main(java.lang.String[] args)\r\n {\r\n // Insert code to start the application here.\r\n WatchListTableModule demo = new WatchListTableModule(null);\r\n demo.mainImpl();\r\n }", "public static void main(String[] args) {\n\t\tnew LoipeApp();\n\t}", "public void init() {\n\t\tThread appThread = new Thread() {\n\t\t\tpublic void run() {\n\t\t\t\ttry {\n\t\t\t\t\tSwingUtilities.invokeAndWait(doHelloWorld);\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t\tSystem.out.println(\"Finished on \" + Thread.currentThread());\n\t\t\t}\n\t\t};\n\t\tappThread.start();\n\t}", "public static void main(String[] args){\n ConfigurationAppGUI gui = new ConfigurationAppGUI();\n }", "public static void main(String[] args) {\n startApplication();\n }", "public GUICarsApp() {\n initComponents();\n \n aList = new ArrayList<Object>();\n }", "public static void main(String[] args) {\n JFXPanel fxPanel = new JFXPanel();\n new Main().start();\n }", "public static void main(String[] args) {\n JFrame frame = new JFrame(\"App\");\n frame.setContentPane(new App().PanelMenu);\n frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n frame.pack();\n frame.setVisible(true);\n }", "public static void main(String[] args)\n {\n Injector guice = Guice.createInjector(new DiscountGuiceModule());\n\n // Inject the application which contains a separate object graph which contains all the business logic\n // When we call the top level class, BasicApplication, guice will inject every static dependency that we request\n // via @Inject\n BasicApplication basicApplication = guice.getInstance(BasicApplication.class);\n\n // now start the application\n basicApplication.start();\n }", "public CompleteableToDoListApp() {\n\t\t\n//\t\tmanager = TaskableFactory.getBasicTaskManager();\n//\t\tsc = new Scanner(System.in);\n\t}", "public static void main(String[] args) throws Exception {\n\n Application.launch(sample.Main.class, args);\n }", "public static void main (String args[]){\n\t\tJFrame application = new JFrame();\r\n\t\tapplication.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\r\n\r\n\t\tPendulumDemo gui = new PendulumDemo();\r\n\r\n\t\tapplication.setLayout(new GridLayout(1,2));\r\n\t\tapplication.add(gui.scopePanel);\r\n\t\tapplication.add(gui.graphicsPanel);\r\n\t\tapplication.setSize (1200, 900); // (width, height)\r\n\t\tapplication.setVisible(true);\r\n\r\n\t\tAnimator animator = new Animator(gui);\r\n\t\tanimator.run();\r\n\r\n\t}", "public ToDoListApp() {\n runToDoList();\n }", "public ApplicationTest() {\n\t\t/*\n\t\t * This constructor should not be modified. Any initialization code should be\n\t\t * placed in the setUp() method instead.\n\t\t */\n\n\t}" ]
[ "0.6809715", "0.6753035", "0.6733103", "0.67080766", "0.66652596", "0.6648726", "0.66447306", "0.66447306", "0.6625309", "0.662488", "0.6553477", "0.65163493", "0.6511654", "0.6492171", "0.6469039", "0.64576274", "0.64316607", "0.6426154", "0.6361194", "0.63610566", "0.6360768", "0.6351017", "0.6345381", "0.63328534", "0.63190764", "0.6315336", "0.63076293", "0.6305671", "0.63023514", "0.6283122", "0.62776184", "0.62751603", "0.62417316", "0.62403905", "0.62330055", "0.6230354", "0.6210963", "0.62074524", "0.620282", "0.6194083", "0.6184824", "0.6184824", "0.61828005", "0.6178004", "0.6172195", "0.61666435", "0.6165019", "0.6164531", "0.6160917", "0.6157178", "0.6153837", "0.61495703", "0.61360025", "0.6132896", "0.6127599", "0.6121925", "0.61208004", "0.6118224", "0.61147827", "0.611108", "0.6107655", "0.6095598", "0.60928833", "0.6075529", "0.60742265", "0.60725665", "0.6069077", "0.6068632", "0.60649526", "0.6064421", "0.60556895", "0.60500544", "0.6047969", "0.603653", "0.6034213", "0.6034213", "0.60337937", "0.6032409", "0.60206044", "0.6018375", "0.6014678", "0.6013898", "0.6013898", "0.6013898", "0.6013898", "0.6013898", "0.6013335", "0.6011265", "0.6006442", "0.6001477", "0.5994866", "0.5988789", "0.59876436", "0.59800774", "0.5977276", "0.597042", "0.59703404", "0.5968767", "0.595958", "0.5956403", "0.59556735" ]
0.0
-1
Creates a sample dataset.
private XYDataset createSampleDataset(GradientDescent gd) { XYSeries predictedY = new XYSeries("Predicted Y"); XYSeries actualY = new XYSeries("Actual Y"); List<BigDecimal> xValues = gd.getInitialXValues(); List<BigDecimal> yPred = gd.getPredictedY(xValues); List<BigDecimal> yActual = gd.getInitialYValues(); for (int cont = 0; cont < xValues.size(); cont++){ predictedY.add(xValues.get(cont), yPred.get(cont)); System.out.println("pred: " + xValues.get(cont) + ", " + yPred.get(cont)); actualY.add(xValues.get(cont), yActual.get(cont)); System.out.println("actual: " + xValues.get(cont) + ", " + yActual.get(cont)); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(predictedY); dataset.addSeries(actualY); return dataset; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static CategoryDataset createSampleDataset() {\n \t\n \t// row keys...\n final String series1 = \"Expected\";\n final String series2 = \"Have\";\n final String series3 = \"Goal\";\n\n // column keys...\n final String type1 = \"Type 1\";\n final String type2 = \"Type 2\";\n final String type3 = \"Type 3\";\n final String type4 = \"Type 4\";\n final String type5 = \"Type 5\";\n final String type6 = \"Type 6\";\n final String type7 = \"Type 7\";\n final String type8 = \"Type 8\";\n\n // create the dataset...\n final DefaultCategoryDataset dataset = new DefaultCategoryDataset();\n\n dataset.addValue(1.0, series1, type1);\n dataset.addValue(4.0, series1, type2);\n dataset.addValue(3.0, series1, type3);\n dataset.addValue(5.0, series1, type4);\n dataset.addValue(5.0, series1, type5);\n dataset.addValue(7.0, series1, type6);\n dataset.addValue(7.0, series1, type7);\n dataset.addValue(8.0, series1, type8);\n\n dataset.addValue(5.0, series2, type1);\n dataset.addValue(7.0, series2, type2);\n dataset.addValue(6.0, series2, type3);\n dataset.addValue(8.0, series2, type4);\n dataset.addValue(4.0, series2, type5);\n dataset.addValue(4.0, series2, type6);\n dataset.addValue(2.0, series2, type7);\n dataset.addValue(1.0, series2, type8);\n\n dataset.addValue(4.0, series3, type1);\n dataset.addValue(3.0, series3, type2);\n dataset.addValue(2.0, series3, type3);\n dataset.addValue(3.0, series3, type4);\n dataset.addValue(6.0, series3, type5);\n dataset.addValue(3.0, series3, type6);\n dataset.addValue(4.0, series3, type7);\n dataset.addValue(3.0, series3, type8);\n\n return dataset;\n \n }", "@Override\n public CreateDatasetResult createDataset(CreateDatasetRequest request) {\n request = beforeClientExecution(request);\n return executeCreateDataset(request);\n }", "private Dataset prepareDataset() {\n // create TAPIR dataset with single endpoint\n Dataset dataset = new Dataset();\n dataset.setKey(UUID.randomUUID());\n dataset.setTitle(\"Beavers\");\n dataset.addEndpoint(endpoint);\n\n // add single Contact\n Contact contact = new Contact();\n contact.setKey(1);\n contact.addEmail(\"test@gbif.org\");\n dataset.setContacts(Lists.newArrayList(contact));\n\n // add single Identifier\n Identifier identifier = new Identifier();\n identifier.setKey(1);\n identifier.setType(IdentifierType.GBIF_PORTAL);\n identifier.setIdentifier(\"450\");\n dataset.setIdentifiers(Lists.newArrayList(identifier));\n\n // add 2 MachineTags 1 with metasync.gbif.org namespace, and another not having it\n List<MachineTag> machineTags = Lists.newArrayList();\n\n MachineTag machineTag = new MachineTag();\n machineTag.setKey(1);\n machineTag.setNamespace(Constants.METADATA_NAMESPACE);\n machineTag.setName(Constants.DECLARED_COUNT);\n machineTag.setValue(\"1000\");\n machineTags.add(machineTag);\n\n MachineTag machineTag2 = new MachineTag();\n machineTag2.setKey(2);\n machineTag2.setNamespace(\"public\");\n machineTag2.setName(\"IsoCountryCode\");\n machineTag2.setValue(\"DK\");\n machineTags.add(machineTag2);\n\n dataset.setMachineTags(machineTags);\n\n // add 1 Tag\n Tag tag = new Tag();\n tag.setKey(1);\n tag.setValue(\"Invasive\");\n dataset.setTags(Lists.newArrayList(tag));\n\n return dataset;\n }", "private DefaultCategoryDataset createDataset() {\n\t\t\n\t\tdataset.clear();\n\t\t\n\t\t// Query HIM to submit data for bar chart display \n\t\tHistoricalInfoMgr.getChartDataset(expNum);\n\n\n\t\treturn dataset; // add the data point (y-value, variable, x-value)\n\t}", "private MolecularSample createTestSample() {\n testMolecularSample = new MolecularSample();\n testMolecularSample.setName(TEST_MOLECULAR_SAMPLE_NAME_CREATE);\n testMolecularSample.setMaterialSample(TEST_MATERIAL_SAMPLE_UUID);\n testMolecularSample.setSampleType(TEST_MOLECULAR_SAMPLE_SAMPLE_TYPE);\n \n persist(testMolecularSample);\n \n return testMolecularSample;\n }", "private XYDataset createDataset() {\n\t\tfinal XYSeriesCollection dataset = new XYSeriesCollection( ); \n\t\tdataset.addSeries(trainErrors); \n\t\tdataset.addSeries(testErrors);\n\t\treturn dataset;\n\t}", "private Dataset createDataset1() {\n final RDF factory1 = createFactory();\n\n final IRI name = factory1.createIRI(\"http://xmlns.com/foaf/0.1/name\");\n final Dataset g1 = factory1.createDataset();\n final BlankNode b1 = createOwnBlankNode(\"b1\", \"0240eaaa-d33e-4fc0-a4f1-169d6ced3680\");\n g1.add(b1, b1, name, factory1.createLiteral(\"Alice\"));\n\n final BlankNode b2 = createOwnBlankNode(\"b2\", \"9de7db45-0ce7-4b0f-a1ce-c9680ffcfd9f\");\n g1.add(b2, b2, name, factory1.createLiteral(\"Bob\"));\n\n final IRI hasChild = factory1.createIRI(\"http://example.com/hasChild\");\n g1.add(null, b1, hasChild, b2);\n\n return g1;\n }", "public static CategoryDataset createDataset() {\r\n DefaultCategoryDataset dataset = new DefaultCategoryDataset();\r\n dataset.addValue(1.0, \"First\", \"C1\");\r\n dataset.addValue(4.0, \"First\", \"C2\");\r\n dataset.addValue(3.0, \"First\", \"C3\");\r\n dataset.addValue(5.0, \"First\", \"C4\");\r\n dataset.addValue(5.0, \"First\", \"C5\");\r\n dataset.addValue(7.0, \"First\", \"C6\");\r\n dataset.addValue(7.0, \"First\", \"C7\");\r\n dataset.addValue(8.0, \"First\", \"C8\");\r\n dataset.addValue(5.0, \"Second\", \"C1\");\r\n dataset.addValue(7.0, \"Second\", \"C2\");\r\n dataset.addValue(6.0, \"Second\", \"C3\");\r\n dataset.addValue(8.0, \"Second\", \"C4\");\r\n dataset.addValue(4.0, \"Second\", \"C5\");\r\n dataset.addValue(4.0, \"Second\", \"C6\");\r\n dataset.addValue(2.0, \"Second\", \"C7\");\r\n dataset.addValue(1.0, \"Second\", \"C8\");\r\n dataset.addValue(4.0, \"Third\", \"C1\");\r\n dataset.addValue(3.0, \"Third\", \"C2\");\r\n dataset.addValue(2.0, \"Third\", \"C3\");\r\n dataset.addValue(3.0, \"Third\", \"C4\");\r\n dataset.addValue(6.0, \"Third\", \"C5\");\r\n dataset.addValue(3.0, \"Third\", \"C6\");\r\n dataset.addValue(4.0, \"Third\", \"C7\");\r\n dataset.addValue(3.0, \"Third\", \"C8\");\r\n return dataset;\r\n }", "public abstract FastqSampleGroup create(File sampleDir) throws IOException;", "private Dataset createDataSet(RecordingObject recordingObject, Group parentObject, String name) throws Exception\n\t{\n\t\t// dimension of dataset, length of array and 1 column\n\t\tlong[] dims2D = { recordingObject.getYValuesLength(), recordingObject.getXValuesLength() };\n\n\t\t// H5Datatype type = new H5Dataype(CLASS_FLOAT, 8, NATIVE, -1);\n\t\tDatatype dataType = recordingsH5File.createDatatype(recordingObject.getDataType(), recordingObject.getDataBytes(), Datatype.NATIVE, -1);\n\t\t// create 1D 32-bit float dataset\n\t\tDataset dataset = recordingsH5File.createScalarDS(name, parentObject, dataType, dims2D, null, null, 0, recordingObject.getValues());\n\n\t\t// add attributes for unit and metatype\n\t\tcreateAttributes(recordingObject.getMetaType().toString(), recordingObject.getUnit(), dataset);\n\n\t\treturn dataset;\n\t}", "private PieDataset createDataset() {\n\t\tDefaultPieDataset result = new DefaultPieDataset();\n\t\tresult.setValue(\"Linux\", 29);\n\t\tresult.setValue(\"Mac\", 20);\n\t\tresult.setValue(\"Windows\", 51);\n\t\treturn result;\n\n\t}", "private XYDataset createDataset() {\n final XYSeriesCollection dataset = new XYSeriesCollection();\n //dataset.addSeries(totalDemand);\n dataset.addSeries(cerContent);\n //dataset.addSeries(cerDemand);\n dataset.addSeries(comContent);\n //dataset.addSeries(comDemand);\n dataset.addSeries(activation);\n dataset.addSeries(resolutionLevel);\n \n return dataset;\n }", "private void createTestDataSet() throws Exception {\n LOG.info(\"creating test data set...\"); \n Database db = null;\n try {\n db = this._category.getDatabase();\n db.begin();\n\n LazyEmployee person = new LazyEmployee();\n person.setFirstName(\"First\");\n person.setLastName(\"Person\");\n person.setBirthday(JDO_ORIGINAL_DATE);\n person.setStartDate(JDO_ORIGINAL_DATE);\n\n LazyAddress address1 = new LazyAddress();\n address1.setId(1);\n address1.setStreet(Integer.toString(1) + JDO_ORIGINAL_STRING);\n address1.setCity(\"First City\");\n address1.setState(\"AB\");\n address1.setZip(\"10000\");\n address1.setPerson(person);\n\n LazyAddress address2 = new LazyAddress();\n address2.setId(2);\n address2.setStreet(Integer.toString(2) + JDO_ORIGINAL_STRING);\n address2.setCity(\"Second City\");\n address2.setState(\"BC\");\n address2.setZip(\"22222\");\n address2.setPerson(person);\n\n LazyAddress address3 = new LazyAddress();\n address3.setId(3);\n address3.setStreet(Integer.toString(3) + JDO_ORIGINAL_STRING);\n address3.setCity(\"Third Ave\");\n address3.setState(\"AB\");\n address3.setZip(\"30003\");\n address3.setPerson(person);\n\n ArrayList addresslist = new ArrayList();\n addresslist.add(address1);\n addresslist.add(address2);\n addresslist.add(address3);\n\n person.setAddress(addresslist);\n\n LazyPayRoll pr1 = new LazyPayRoll();\n pr1.setId(1);\n pr1.setHoliday(15);\n pr1.setHourlyRate(25);\n pr1.setEmployee(person);\n person.setPayRoll(pr1);\n\n LazyContractCategory cc = new LazyContractCategory();\n cc.setId(101);\n cc.setName(\"Full-time slave\");\n db.create(cc);\n\n LazyContractCategory cc2 = new LazyContractCategory();\n cc2.setId(102);\n cc2.setName(\"Full-time employee\");\n db.create(cc2);\n \n ArrayList category = new ArrayList();\n category.add(cc);\n category.add(cc2);\n\n LazyContract con = new LazyContract();\n con.setPolicyNo(1001);\n con.setComment(\"80 hours a week, no pay hoilday, \"\n + \"no sick leave, arrive office at 7:30am everyday\");\n con.setContractNo(78);\n con.setEmployee(person);\n con.setCategory(category);\n person.setContract(con);\n \n db.create(person);\n \n db.commit();\n db.close();\n } catch (Exception e) {\n LOG.error(\"createTestDataSet: exception caught\", e);\n throw e;\n }\n }", "private List<Tuple2<Integer, Integer>> initSampleDataset() {\n List<Tuple2<Integer, Integer>> rawChapterData = new ArrayList<>();\n rawChapterData.add(new Tuple2<>(96, 1));\n rawChapterData.add(new Tuple2<>(97, 1));\n rawChapterData.add(new Tuple2<>(98, 1));\n rawChapterData.add(new Tuple2<>(99, 2));\n rawChapterData.add(new Tuple2<>(100, 3));\n rawChapterData.add(new Tuple2<>(101, 3));\n rawChapterData.add(new Tuple2<>(102, 3));\n rawChapterData.add(new Tuple2<>(103, 3));\n rawChapterData.add(new Tuple2<>(104, 3));\n rawChapterData.add(new Tuple2<>(105, 3));\n rawChapterData.add(new Tuple2<>(106, 3));\n rawChapterData.add(new Tuple2<>(107, 3));\n rawChapterData.add(new Tuple2<>(108, 3));\n rawChapterData.add(new Tuple2<>(109, 3));\n\n return rawChapterData;\n }", "private DataSet normalDataSet(){\n //create normal distribution with mean .05 and sd .05/3 so that 99.7% of events are < .1\n NormalDistribution normalDistribution = new NormalDistribution(TARGET_MEAN, TARGET_MEAN/3D);\n DataSet dataSet = new DataSet();\n Task[] tasks = new Task[NUM_DISTINCT_TASKS];\n //generate costs from sampling from normal distribution\n for(int i=0; i < NUM_DISTINCT_TASKS; i++){\n UUID uuid = UUID.randomUUID();\n Long cost = (long) Math.max(1, normalDistribution.sample()); //make sure no 0 cost events\n tasks[i] = new Task(cost, uuid);\n }\n //generate task multiplities from sampling from uniform distribution\n for(int i=0; i < NUM_TASKS; i++){\n dataSet.getTasks().add(tasks[random.nextInt(NUM_DISTINCT_TASKS)]);\n }\n return dataSet;\n }", "public AzureDataLakeStoreDataset() {\n }", "private DataSet constantDataSet(){\n DataSet dataSet = new DataSet();\n Task[] tasks = new Task[NUM_DISTINCT_TASKS];\n //generate taks with all 50 mills\n for(int i=0; i < NUM_DISTINCT_TASKS; i++){\n UUID uuid = UUID.randomUUID();\n tasks[i] = new Task(TARGET_MEAN, uuid);\n }\n for(int i=0; i < NUM_TASKS; i++){\n dataSet.getTasks().add(tasks[random.nextInt(NUM_DISTINCT_TASKS)]);\n }\n return dataSet;\n }", "private void addSampleData() {\r\n }", "private void initDataset(){\n dataSet.add(\"Karin\");\n dataSet.add(\"Ingrid\");\n dataSet.add(\"Helga\");\n dataSet.add(\"Renate\");\n dataSet.add(\"Elke\");\n dataSet.add(\"Ursula\");\n dataSet.add(\"Erika\");\n dataSet.add(\"Christa\");\n dataSet.add(\"Gisela\");\n dataSet.add(\"Monika\");\n\n addDataSet.add(\"Anna\");\n addDataSet.add(\"Sofia\");\n addDataSet.add(\"Emilia\");\n addDataSet.add(\"Emma\");\n addDataSet.add(\"Neele\");\n addDataSet.add(\"Franziska\");\n addDataSet.add(\"Heike\");\n addDataSet.add(\"Katrin\");\n addDataSet.add(\"Katharina\");\n addDataSet.add(\"Liselotte\");\n }", "private CategoryDataset createDataset() {\n\t \n\t \tvar dataset = new DefaultCategoryDataset();\n\t \n\t\t\tSystem.out.println(bic);\n\t\t\t\n\t\t\tfor(Map.Entry<String, Integer> entry : bic.entrySet()) {\n\t\t\t String key = entry.getKey();\n\t\t\t Integer value = entry.getValue();\n\t\t\t dataset.setValue(value, \"# Bicicletas\", key);\n\t \n\t\t\t}\n\t return dataset;\n\t \n\t }", "private CategoryDataset createDataset( )\n\t {\n\t final DefaultCategoryDataset dataset = \n\t new DefaultCategoryDataset( ); \n\t \n\t dataset.addValue(23756.0, \"余杭\", \"闲林\");\n\t dataset.addValue(29513.5, \"余杭\", \"良渚\");\n\t dataset.addValue(25722.2, \"余杭\", \"瓶窑\");\n\t dataset.addValue(19650.9, \"余杭\", \"星桥\");\n\t dataset.addValue(19661.6, \"余杭\", \"崇贤\");\n\t dataset.addValue(13353.9, \"余杭\", \"塘栖\");\n\t dataset.addValue(25768.9, \"余杭\", \"勾庄\");\n\t dataset.addValue(12682.8, \"余杭\", \"仁和\");\n\t dataset.addValue(22963.1, \"余杭\", \"乔司\");\n\t dataset.addValue(19695.6, \"余杭\", \"临平\");\n\t \n\t return dataset; \n\t }", "private static MarketDataSet createTestMarketData() {\n final MarketDataSet dataSet = MarketDataSet.empty();\n dataSet.put(MarketDataKey.of(ExternalId.of(TEST_SCHEME, \"AUDUSD\").toBundle(), DataField.of(MarketDataRequirementNames.MARKET_VALUE)), 1.8);\n dataSet.put(MarketDataKey.of(ExternalId.of(TEST_SCHEME, \"NZDUSD\").toBundle(), DataField.of(MarketDataRequirementNames.MARKET_VALUE)), 2.2);\n dataSet.put(MarketDataKey.of(ExternalId.of(TEST_SCHEME, \"GBPUSD\").toBundle(), DataField.of(MarketDataRequirementNames.MARKET_VALUE)), 1.5);\n dataSet.put(MarketDataKey.of(ExternalId.of(TEST_SCHEME, \"GBP1Y\").toBundle(), DataField.of(MarketDataRequirementNames.MARKET_VALUE)),\n ImmutableLocalDateDoubleTimeSeries.builder()\n .putAll(new LocalDate[] {LocalDate.of(2016, 1, 1), LocalDate.of(2016, 1, 2)}, new double[] {0.01, 0.02}).build());\n return dataSet;\n }", "@DataProvider(name = \"test1\")\n\tpublic Object[][] createData1() {\n\t return new Object[][] {\n\t { \"Cedric\", new Integer(36) },\n\t { \"Anne\", new Integer(37)},\n\t };\n\t}", "@Override public void createSample(Sample sample)\n {\n try\n {\n clientDoctor.createSample(sample);\n }\n catch (RemoteException e)\n {\n throw new RuntimeException(\"Error while creating sample. Please try again.\");\n }\n }", "public DataSet() {\r\n \r\n }", "private DataSet caucyDataSet(){\n CauchyDistribution cauchyDistribution = new CauchyDistribution(TARGET_MEAN, TARGET_MEAN/10);\n DataSet dataSet = new DataSet();\n Task[] tasks = new Task[NUM_DISTINCT_TASKS];\n //generate costs from sampling from normal distribution\n for(int i=0; i < NUM_DISTINCT_TASKS; i++){\n UUID uuid = UUID.randomUUID();\n Long cost = (long) Math.max(1, cauchyDistribution.sample()); //make sure no 0 cost events\n tasks[i] = new Task(cost, uuid);\n }\n //generate task multiplities from sampling from uniform distribution\n for(int i=0; i < NUM_TASKS; i++){\n dataSet.getTasks().add(tasks[random.nextInt(NUM_DISTINCT_TASKS)]);\n }\n return dataSet;\n }", "protected abstract D createData();", "public DataSet() {\n labels = new HashMap<>();\n locations = new HashMap<>();\n counter= new AtomicInteger(0);\n }", "DataPackage createDataPackage();", "public CreateData() {\n\t\t\n\t\t// TODO Auto-generated constructor stub\n\t}", "public void PrepareTestDataset(String dataset, boolean islabeled)\n\t{\n\t\tdbiterator = DBInstanceIterator.getInstance();\n\t\tSystem.out.println(\"Preparing Test Datasets ...\");\n\t\ttry {\n\t\t\tPrepareAll(dataset,islabeled);\n\t\t\tSystem.out.println(\"Test Dataset is saved & ready for Training ..\");\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}", "private void createTestData() {\n for (int i = startKey; i < startKey + numKeys; i++) {\n keys.add(i);\n }\n }", "private CinaImageDataSetInformation createDataSetInformation()\n {\n CinaImageDataSetInformation metadataDataSetInfo = new CinaImageDataSetInformation();\n metadataDataSetInfo.setSampleCode(replicaSampleId.getSampleCode());\n metadataDataSetInfo.setSpaceCode(replicaSampleId.getSpaceLevel().getSpaceCode());\n metadataDataSetInfo.setDataSetType(globalState.getImageDataSetType().getDataSetType());\n metadataDataSetInfo.setDataSetKind(DataSetKind.PHYSICAL);\n List<String> parentDataSetCodes =\n Collections.singletonList(bundleMetadataDataSetInformation.getDataSetCode());\n metadataDataSetInfo.setParentDataSetCodes(parentDataSetCodes);\n metadataDataSetInfo.setShareId(bundleMetadataDataSetInformation.getShareId());\n return metadataDataSetInfo;\n }", "private XYDataset createDataset(String WellID, String lang) {\n final TimeSeries eur = createEURTimeSeries(WellID, lang);\n final TimeSeriesCollection dataset = new TimeSeriesCollection();\n dataset.addSeries(eur);\n return dataset;\n }", "public void create_dataset(double sampling_rate, double freq, int n) {\n double amplitude = 10.0d;\n double constant = freq/sampling_rate*2.0d*Math.PI;\n double sumTWD=0.0d;\n\n for (int i = 0; i < n; i++) {\n NavigationTools.TWD.add((Math.sin((double)i*constant)+Math.random()*0.2d)*amplitude);\n sumTWD += NavigationTools.TWD.getLast();\n }\n\n NavigationTools.TWD_longAVG=sumTWD/(double)n;\n }", "@DataProvider(name = \"test1\")\n\tpublic Object [][] createData1() {\n\t\treturn new Object [][] {\n\t\t\tnew Object [] { 0, 0 },\n\t\t\tnew Object [] { 9, 2 },\n\t\t\tnew Object [] { 15, 0 },\n\t\t\tnew Object [] { 32, 0 },\n\t\t\tnew Object [] { 529, 4 },\n\t\t\tnew Object [] { 1041, 5 },\n\t\t\tnew Object [] { 65536, 0 },\n\t\t\tnew Object [] { 65537, 15 },\n\t\t\tnew Object [] { 100000, 4 }, \n\t\t\tnew Object [] { 2147483, 5 },\n\t\t\tnew Object [] { 2147483637, 1 }, //max - 10\n\t\t\tnew Object [] { 2147483646, 0 }, //max - 1\n\t\t\tnew Object [] { 2147483647, 0 } //max\n\t\t};\n\t}", "public void setupDryadCloudDataSets(){\n\t\ttry{\n\t\t\t\n\t\t\t// A Dryad \n\t\t\tDryadDataSet ds = new DryadDataSet(_DRYAD_D1_TREEBASE);\n\t\t\tds.harvestMetadataToRDF();\n\t\t\tds.harvestDataToRDF(_DRYAD_D1_TREEBASE_F1);\n\t\t\t_datasets.add(ds);\n\t\t\tds = new DryadDataSet(_DRYAD_D3_POPULAR);\n\t\t\tds.harvestMetadataToRDF();\n\t\t\tds.harvestDataToRDF(_DRYAD_D3_POPULAR_F1);\n\t\t\t_datasets.add(ds);\n\t\t\tds = new DryadDataSet(_DRYAD_D4_CSV);\n\t\t\tds.harvestMetadataToRDF();\n\t\t\tds.harvestDataToRDF(_DRYAD_D4_CSV_F1);\n\t\t\tds.harvestDataToRDF(_DRYAD_D4_CSV_F2);\n\t\t\t_datasets.add(ds);\n\t\t\tds = new DryadDataSet(_DRYAD_D6_CSV);\n\t\t\tds.harvestMetadataToRDF();\n\t\t\tds.harvestDataToRDF(_DRYAD_D6_CSV_F1);\n\t\t\tds.harvestDataToRDF(_DRYAD_D6_CSV_F2);\n\t\t\t_datasets.add(ds);\n\t\t\tds = new DryadDataSet(_DRYAD_D2_GENBANK);\n\t\t\tds.harvestMetadataToRDF();\n\t\t\tds.harvestDataToRDF(_DRYAD_D2_GENBANK_F1);\t\n\t\t\tds.harvestDataToRDF(_DRYAD_D2_GENBANK_F2);\n\t\t\tds.harvestDataToRDF(_DRYAD_D2_GENBANK_F3);\n\t\t\tds.harvestDataToRDF(_DRYAD_D2_GENBANK_F4);\n\t\t\t_datasets.add(ds);\n\t\t\tds = new DryadDataSet(_DRYAD_D5_CSV);\n\t\t\tds.harvestMetadataToRDF();\n\t\t\tds.harvestDataToRDF(_DRYAD_D5_CSV_F1);\n\t\t\tds.harvestDataToRDF(_DRYAD_D5_CSV_F2);\n\t\t\t_datasets.add(ds);\n\t\t}\n\t\tcatch(Exception ex){\n\t\t\tSystem.out.println(\"ERROR: Exception \"+ex.getMessage());\n\t\t}\n\t}", "public DataSet( int _height , int _width) throws FileNotFoundException {\n height = _height;\n width = _width;\n InitFile( \"src/com/algorithme/DataSet.txt\" );\n InitTargets();\n InitFeatures();\n System.out.println(\"Création de la DataSet\");\n }", "@POST\n @Produces(MediaType.APPLICATION_JSON)\n @Consumes(MediaType.APPLICATION_JSON)\n public Response createDataSet(@QueryParam(Q_PROVIDER) String providerId, Dataset<String> dataset) {\n\n ParamUtil.require(\"dataset\", dataset);\n ParamUtil.require(\"providerId\", providerId);\n\n Dataset<String> createdDataset = datasetService.createDataSet(providerId, dataset);\n return Response.ok().entity(createdDataset).build();\n }", "InlineDataExample createInlineDataExample();", "private static XYDataset createDataset(Double[] x, Double[] y) {\n\t\tlogger.info(\"Creating Dataset\");\n\t\tXYSeries s1 = new XYSeries(Double.valueOf(1));\n\t\tif (x.length != y.length) {\n\t\t\tlogger.error(\"Error in createDataset of ScatterDialog. \" +\n\t\t\t\t\t\"Could not create a dataset for the scatter plot -- missing data\");\n\t\t\treturn null;\n\t\t}\n\t\tfor (int i = 0; i < x.length; i++) {\n\t\t\tif (y[i] != null) {\n\t\t\t\ts1.add(x[i], y[i]);\n\t\t\t}\n\t\t}\n\t\tXYSeriesCollection dataset = new XYSeriesCollection();\n\t\tdataset.addSeries(s1);\n\t\treturn dataset;\n\t}", "private void populateData() {\n\t\tList<TrafficRecord> l = TestHelper.getSampleData();\r\n\t\tfor(TrafficRecord tr: l){\r\n\t\t\tput(tr);\r\n\t\t}\r\n\t\t \r\n\t}", "List<Pair<String, byte[]>> generateSample(Object descriptor);", "public void generateData()\n {\n }", "org.hl7.fhir.SampledData addNewValueSampledData();", "void create(DataTableDef def) throws IOException;", "public JavaRandomSampleOperator(int sampleSize, long datasetSize, DataSetType type) {\n super(sampleSize, datasetSize, type, Methods.RANDOM);\n rand = new Random();\n }", "private PieDataset createDataset() {\n JOptionPane.showMessageDialog(null, \"teste\"+dados.getEntrada());\r\n \r\n DefaultPieDataset result = new DefaultPieDataset();\r\n result.setValue(\"Entrada\", dados.getEntrada());\r\n result.setValue(\"Saida\", dados.getSaida());\r\n result.setValue(\"Saldo do Periodo\", dados.getSaldo());\r\n return result;\r\n\r\n }", "public JavaRandomSampleOperator(int sampleSize, DataSetType type) {\n super(sampleSize, type, Methods.RANDOM);\n rand = new Random();\n }", "public DataResourceBuilder _sample_(Resource _sample_) {\n this.dataResourceImpl.getSample().add(_sample_);\n return this;\n }", "@Test\n public void testRun() {\n System.out.println(\"run\");\n FluorescenceImporter importer = null;\n try {\n FluorescenceFixture tf = new FluorescenceFixture();\n importer = new FluorescenceImporter(tf.testData());\n ProgressHandle ph = ProgressHandleFactory.createHandle(\"Importing dataset\");\n importer.setProgressHandle(ph);\n \n importer.run();\n } catch (IOException ex) {\n Exceptions.printStackTrace(ex);\n }\n \n //FluorescenceDataset dataset = importer.getDataset();\n Dataset<? extends Instance> plate = importer.getDataset();\n System.out.println(\"inst A1 \"+ plate.instance(0).toString());\n System.out.println(\"plate \"+plate.toString());\n Dataset<Instance> output = new SampleDataset<Instance>();\n output.setParent((Dataset<Instance>) plate);\n ProgressHandle ph = ProgressHandleFactory.createHandle(\"Analyzing dataset\");\n // AnalyzeRunner instance = new AnalyzeRunner((Timeseries<ContinuousInstance>) plate, output, ph);\n // instance.run();\n \n }", "public CategoryDataset createDataset() {\n\t\tfinal DefaultCategoryDataset dataset = new DefaultCategoryDataset();\n\t\tProjectManagement projectManagement = new ProjectManagement();\n\t\tif (this.chartName == \"Earned Value\") {\n\t\t\tfor (LocalDate date : dateList) {\n\t\t\t\tdataset.addValue(projectManagement.getEarnedValue(date), \"Earned Value\", date);\n\t\t\t}\n\t\t} else if (this.chartName == \"Schedule Variance\") {\n\t\t\tfor (LocalDate date : dateList) {\n\t\t\t\tdataset.addValue(projectManagement.getScheduleVariance(date), \"Schedule Variance\", date);\n\t\t\t}\n\n\t\t} else {// Cost Variance\n\t\t\tfor (LocalDate date : dateList) {\n\t\t\t\tdataset.addValue(projectManagement.getCostVariance(date), \"Cost Variance\", date);\n\t\t\t}\n\t\t}\n\t\treturn dataset;\n\t}", "private static XYZDataset createDataset(Comparable<?> xKey, \n Comparable<?> yKey, Comparable<?> zKey) {\n Reader in = new InputStreamReader(\n ScatterPlot3D3.class.getResourceAsStream(\"iris.txt\"));\n KeyedValues3D data;\n try {\n data = JSONUtils.readKeyedValues3D(in);\n } catch (IOException ex) {\n throw new RuntimeException(ex);\n }\n return DataUtils.extractXYZDatasetFromColumns(data, xKey, yKey, zKey);\n }", "public AnalysisDatasets() {\n }", "@Before\n\tpublic void setUpData() {\n\n\t\t// Make sure there is a type in the database\n\t\tType defaultType = new Type();\n\t\tdefaultType.setName(\"type\");\n\t\ttypeService.save(defaultType);\n\n\t\t// Make sure there is a seed packet in the database\n\t\tSeedPacket seedPacket = new SeedPacketBuilder()\n\t\t\t\t.withName(\"seed\")\n\t\t\t\t.withType(\"type\")\n\t\t\t\t.withPackSize(500).build();\n\n\t\tseedPacketService.save(seedPacket);\n\t}", "public DataResourceBuilder _sample_(List<Resource> _sample_) {\n this.dataResourceImpl.setSample(_sample_);\n return this;\n }", "private RandomData() {\n initFields();\n }", "private Object createDataset(final ChartConfiguration config) {\n final CategoryChart chart = (CategoryChart) config.chart;\n for (final Fields key: config.fields) {\n chart.addSeries(key.getLocalizedName(), new double[1], new double[1]);\n }\n populateDataset(config);\n return null;\n }", "private boolean initializeDataset(){\n this.dataset = new Dataset(this.users.size(),this.recipes.size());\n //1. Read Dataset\n boolean succesReadDataset = this.dataset.read(this.userMap,this.recipeMap);\n if (!succesReadDataset) return false;\n return true;\n }", "private PieDataset createDataset() {\n\t\tDefaultPieDataset result = new DefaultPieDataset();\n\n\t\tif (_controler != null) {\n\t\t\tfor (Object cat : _controler.getCategorieData()) {\n\n\t\t\t\tresult.setValue((String) cat, _controler.getTotal((String) cat));\n\n\t\t\t}\n\t\t}\n\t\treturn result;\n\n\t}", "private static List<Point> createConvergingDataset() {\r\n List<Point> data = new ArrayList<Point>();\r\n add(data, 1, 400);\r\n add(data, 5, 700);\r\n add(data, 10, 900);\r\n add(data, 15, 1000);\r\n add(data, 20, 1050);\r\n add(data, 25, 1060);\r\n add(data, 30, 1062);\r\n return data;\r\n }", "private void createTableWithTestData(final DataSource dataSource) throws Exception {\n // create table\n Connection conn = dataSource.getConnection();\n Statement st = conn.createStatement();\n st.execute(CREATE_TEST_TABLE);\n conn.commit();\n st.close();\n conn.close();\n\n // fill with values\n conn = dataSource.getConnection();\n // prevent auto commit for batching\n conn.setAutoCommit(false);\n PreparedStatement ps = conn.prepareStatement(INSERT);\n // fill with values\n for (int i = 0; i < EXPECTED_COUNT; i++) {\n ps.setString(1, String.valueOf(i));\n ps.addBatch();\n }\n ps.executeBatch();\n conn.commit();\n ps.close();\n conn.close();\n }", "public static Dataset createDataset(RepositoryConnection connection)\n {\n DatasetGraph dsg = new JenaSesameDatasetGraph(connection) ;\n return DatasetFactory.wrap(dsg) ;\n }", "@Override\n public BaseDataProvider creatDataProvider() {\n return null;\n }", "public Test makeTest(DataSource ds, List<Question> givenQns){\n\t\tArrayList<Question> startQns = new ArrayList<Question>();\n\t\tfor (int i = 0; i < givenQns.size(); i++){\n\t\t\tstartQns.add((Question)givenQns.get(i));\n\t\t}\n\t\tString category = startQns.get(0).getCategory();\n\t\tString difficulty = \"any\";\n\t\t\n\t\twhile(startQns.size()>5){\n\t\t\tint index = (int)(Math.random()*startQns.size());\n\t\t\tstartQns.remove(index);\n\t\t}\n\t\tTest test = this.makeTest(ds, difficulty, category, 5, startQns);\n//\t\tSystem.out.println(\"TestMakerA->test: \" + test.toString());\n\t\tint[] correct = new int[5];\n\t\tArrayList<Question[]> questions = (ArrayList<Question[]>)test.getTest();\n\n\t\tfor(int i = 0; i < 5; i++){\n\t\t\tcorrect[i] = (int)(Math.random()*4);\n\t\t\tif(questions.get(i)[correct[i]] != startQns.get(i)){\n\t\t\t\tquestions.get(i)[correct[i]] = startQns.get(i);\n\t\t\t}\n\t\t}\n\n\t\ttest.setCorrect(correct);\n\t\treturn test;\n\t}", "DataPointType createDataPointType();", "@DataProvider(name = \"tasksForUserStory\")\n\tpublic Object[][] createData1() {\n\t\treturn new Object[][] {\n\t\t\t\t{\"Task 1\"}, \n\t\t\t\t{\"Task 2\"},\n\t\t\t\t{\"Task 3\"},\n\t\t\t\t{\"Task 4\"} \n\t\t};\n\t}", "private static void createFile() throws Exception {\n\t\t // retrieve an instance of H4File\n\t\t FileFormat fileFormat = FileFormat.getFileFormat(FileFormat.FILE_TYPE_HDF4);\n\n\t\t if (fileFormat == null) {\n\t\t System.err.println(\"Cannot find HDF4 FileFormat.\");\n\t\t return;\n\t\t }\n\n\t\t // create a new file with a given file name.\n\t\t @SuppressWarnings(\"deprecation\")\n\t\t\t\tH4File testFile = (H4File) fileFormat.create(fname);\n\n\t\t if (testFile == null) {\n\t\t System.err.println(\"Failed to create file:\" + fname);\n\t\t return;\n\t\t }\n\n\t\t // open the file and retrieve the root group\n\t\t testFile.open();\n\t\t Group root = (Group) ((javax.swing.tree.DefaultMutableTreeNode) testFile.getRootNode()).getUserObject();\n\n\t\t // set the data values\n\t\t int[] dataIn = new int[20 * 10];\n\t\t for (int i = 0; i < 20; i++) {\n\t\t for (int j = 0; j < 10; j++) {\n\t\t dataIn[i * 10 + j] = 1000 + i * 100 + j;\n\t\t }\n\t\t }\n\n\t\t // create 2D 32-bit (4 bytes) integer dataset of 20 by 10\n\t\t Datatype dtype = testFile.createDatatype(Datatype.CLASS_INTEGER, 4, Datatype.NATIVE, Datatype.NATIVE);\n\t\t @SuppressWarnings(\"unused\")\n\t\t\t\tDataset dataset = testFile\n\t\t .createScalarDS(\"2D 32-bit integer 20x10\", root, dtype, dims2D, null, null, 0, dataIn);\n\n\t\t // close file resource\n\t\t //testFile.close();\n\t\t }", "public DataSet(){\r\n\t\tdocs = Lists.newArrayList();\r\n//\t\t_docs = Lists.newArrayList();\r\n\t\t\r\n\t\tnewId2trnId = HashBiMap.create();\r\n\t\t\r\n\t\tM = 0;\r\n\t\tV = 0;\r\n\t}", "public hu.blackbelt.epsilon.runtime.model.test1.data.DataModel build() {\n final hu.blackbelt.epsilon.runtime.model.test1.data.DataModel _newInstance = hu.blackbelt.epsilon.runtime.model.test1.data.DataFactory.eINSTANCE.createDataModel();\n if (m_featureNameSet) {\n _newInstance.setName(m_name);\n }\n if (m_featureEntitySet) {\n _newInstance.getEntity().addAll(m_entity);\n } else {\n if (!m_featureEntityBuilder.isEmpty()) {\n for (hu.blackbelt.epsilon.runtime.model.test1.data.util.builder.IDataBuilder<? extends hu.blackbelt.epsilon.runtime.model.test1.data.Entity> builder : m_featureEntityBuilder) {\n _newInstance.getEntity().add(builder.build());\n }\n }\n }\n return _newInstance;\n }", "public static void main(String[] args) throws Exception {\n DataSet houseVotes = DataParser.parseData(HouseVotes.filename, HouseVotes.columnNames, HouseVotes.dataTypes, HouseVotes.ignoreColumns, HouseVotes.classColumn, HouseVotes.discretizeColumns);\n DataSet breastCancer = DataParser.parseData(BreastCancer.filename, BreastCancer.columnNames, BreastCancer.dataTypes, BreastCancer.ignoreColumns, BreastCancer.classColumn, HouseVotes.discretizeColumns);\n DataSet glass = DataParser.parseData(Glass.filename, Glass.columnNames, Glass.dataTypes, Glass.ignoreColumns, Glass.classColumn, Glass.discretizeColumns);\n DataSet iris = DataParser.parseData(Iris.filename, Iris.columnNames, Iris.dataTypes, Iris.ignoreColumns, Iris.classColumn, Iris.discretizeColumns);\n DataSet soybean = DataParser.parseData(Soybean.filename, Soybean.columnNames, Soybean.dataTypes, Soybean.ignoreColumns, Soybean.classColumn, Soybean.discretizeColumns);\n \n /*\n * The contents of the DataSet are not always random.\n * You can shuffle them using Collections.shuffle()\n */\n \n Collections.shuffle(houseVotes);\n Collections.shuffle(breastCancer);\n Collections.shuffle(glass);\n Collections.shuffle(iris);\n Collections.shuffle(soybean);\n /*\n * Lastly, you want to split the data into a regular dataset and a testing set.\n * DataSet has a function for this, since it gets a little weird.\n * This grabs 10% of the data in the dataset and sets pulls it out to make the testing set.\n * This also means that the remaining 90% in DataSet can serve as our training set.\n */\n\n DataSet houseVotesTestingSet = houseVotes.getTestingSet(.1);\n DataSet breastCancerTestingSet = breastCancer.getTestingSet(.1);\n DataSet glassTestingSet = glass.getTestingSet(.1);\n DataSet irisTestingSet = iris.getTestingSet(.1);\n DataSet soybeanTestingSet = soybean.getTestingSet(.1);\n \n //KNN\n //House Votes\n System.out.println(HouseVotes.class.getSimpleName());\n KNN knn = new KNN(houseVotes, houseVotesTestingSet, HouseVotes.classColumn, 3);\n String[] knnHouseVotes = new String[houseVotesTestingSet.size()];\n for(int i = 0; i < houseVotesTestingSet.size(); i++) {\n knnHouseVotes[i] = knn.classify(houseVotesTestingSet.get(i));\n }\n for(int i = 0; i < houseVotesTestingSet.size(); i++) {\n if(knnHouseVotes[i].equals(houseVotesTestingSet.get(i)[HouseVotes.classColumn].value())) {\n System.out.println(\"KNN: Correct (\" + knnHouseVotes[i] + \")\");\n } else {\n System.out.println(\"KNN: Incorrect (\" + knnHouseVotes[i] + \", actually \" + houseVotesTestingSet.get(i)[HouseVotes.classColumn].value() + \")\");\n }\n }\n \n //Breast Cancer\n System.out.println(BreastCancer.class.getSimpleName());\n knn = new KNN(breastCancer, breastCancerTestingSet, BreastCancer.classColumn, 3);\n String[] knnBreastCancer = new String[breastCancerTestingSet.size()];\n for(int i = 0; i < breastCancerTestingSet.size(); i++) {\n knnBreastCancer[i] = knn.classify(breastCancerTestingSet.get(i));\n }\n for(int i = 0; i < breastCancerTestingSet.size(); i++) {\n if(knnBreastCancer[i].equals(breastCancerTestingSet.get(i)[BreastCancer.classColumn].value())) {\n System.out.println(\"KNN: Correct (\" + knnBreastCancer[i] + \")\");\n } else {\n System.out.println(\"KNN: Incorrect (\" + knnBreastCancer[i] + \", actually \" + breastCancerTestingSet.get(i)[BreastCancer.classColumn].value() + \")\");\n }\n }\n \n //Glass\n System.out.println(Glass.class.getSimpleName());\n knn = new KNN(glass, glassTestingSet, Glass.classColumn, 3);\n String[] knnGlass = new String[glassTestingSet.size()];\n for(int i = 0; i < glassTestingSet.size(); i++) {\n knnGlass[i] = knn.classify(glassTestingSet.get(i));\n }\n for(int i = 0; i < glassTestingSet.size(); i++) {\n if(knnGlass[i].equals(glassTestingSet.get(i)[Glass.classColumn].value())) {\n System.out.println(\"KNN: Correct (\" + knnGlass[i] + \")\");\n } else {\n System.out.println(\"KNN: Incorrect (\" + knnGlass[i] + \", actually \" + glassTestingSet.get(i)[Glass.classColumn].value() + \")\");\n }\n }\n \n //Iris\n System.out.println(Iris.class.getSimpleName());\n knn = new KNN(iris, irisTestingSet, Iris.classColumn, 3);\n String[] knnIris = new String[irisTestingSet.size()];\n for(int i = 0; i < irisTestingSet.size(); i++) {\n knnIris[i] = knn.classify(irisTestingSet.get(i));\n }\n for(int i = 0; i < irisTestingSet.size(); i++) {\n if(knnIris[i].equals(irisTestingSet.get(i)[Iris.classColumn].value())) {\n System.out.println(\"KNN: Correct (\" + knnIris[i] + \")\");\n } else {\n System.out.println(\"KNN: Incorrect (\" + knnIris[i] + \", actually \" + irisTestingSet.get(i)[Iris.classColumn].value() + \")\");\n }\n }\n \n //Soybean\n System.out.println(Soybean.class.getSimpleName());\n knn = new KNN(soybean, soybeanTestingSet, Soybean.classColumn, 3);\n String[] knnSoybean = new String[soybeanTestingSet.size()];\n for(int i = 0; i < soybeanTestingSet.size(); i++) {\n knnSoybean[i] = knn.classify(soybeanTestingSet.get(i));\n }\n for(int i = 0; i < soybeanTestingSet.size(); i++) {\n if(knnSoybean[i].equals(soybeanTestingSet.get(i)[Soybean.classColumn].value())) {\n System.out.println(\"KNN: Correct (\" + knnSoybean[i] + \")\");\n } else {\n System.out.println(\"KNN: Incorrect (\" + knnSoybean[i] + \", actually \" + soybeanTestingSet.get(i)[Soybean.classColumn].value() + \")\");\n }\n }\n \n \n /*\n * Lets setup ID3:\n * DataSet, TestSet, column with the class categorization. (republican, democrat in this case)\n */\n\n System.out.println(HouseVotes.class.getSimpleName());\n ID3 id3 = new ID3(houseVotes, houseVotesTestingSet, HouseVotes.classColumn);\n String[] id3HouseVotes = new String[houseVotesTestingSet.size()];\n for(int i = 0; i < houseVotesTestingSet.size(); i++) {\n id3HouseVotes[i] = id3.classify(houseVotesTestingSet.get(i));\n }\n for(int i = 0; i < houseVotesTestingSet.size(); i++) {\n if(id3HouseVotes[i].equals(houseVotesTestingSet.get(i)[HouseVotes.classColumn].value())) {\n System.out.println(\"ID3: Correct (\" + id3HouseVotes[i] + \")\");\n } else {\n System.out.println(\"ID3: Incorrect (\" + id3HouseVotes[i] + \", actually \" + houseVotesTestingSet.get(i)[HouseVotes.classColumn].value() + \")\");\n }\n }\n\n System.out.println(BreastCancer.class.getSimpleName());\n id3 = new ID3(breastCancer, breastCancerTestingSet, BreastCancer.classColumn);\n String[] id3BreastCancer = new String[breastCancerTestingSet.size()];\n for(int i = 0; i < breastCancerTestingSet.size(); i++) {\n id3BreastCancer[i] = id3.classify(breastCancerTestingSet.get(i));\n }\n for(int i = 0; i < breastCancerTestingSet.size(); i++) {\n if(id3BreastCancer[i].equals(breastCancerTestingSet.get(i)[BreastCancer.classColumn].value())) {\n System.out.println(\"ID3: Correct (\" + id3BreastCancer[i] + \")\");\n } else {\n System.out.println(\"ID3: Incorrect (\" + id3BreastCancer[i] + \", actually \" + breastCancerTestingSet.get(i)[BreastCancer.classColumn].value() + \")\");\n }\n }\n\n System.out.println(Glass.class.getSimpleName());\n id3 = new ID3(glass, glassTestingSet, Glass.classColumn);\n String[] id3Glass = new String[glassTestingSet.size()];\n for(int i = 0; i < glassTestingSet.size(); i++) {\n id3Glass[i] = id3.classify(glassTestingSet.get(i));\n }\n for(int i = 0; i < glassTestingSet.size(); i++) {\n if(id3Glass[i].equals(glassTestingSet.get(i)[Glass.classColumn].value())) {\n System.out.println(\"ID3: Correct (\" + id3Glass[i] + \")\");\n } else {\n System.out.println(\"ID3: Incorrect (\" + id3Glass[i] + \", actually \" + glassTestingSet.get(i)[Glass.classColumn].value() + \")\");\n }\n }\n\n System.out.println(Iris.class.getSimpleName());\n id3 = new ID3(iris, irisTestingSet, Iris.classColumn);\n String[] id3Iris = new String[irisTestingSet.size()];\n for(int i = 0; i < irisTestingSet.size(); i++) {\n id3Iris[i] = id3.classify(irisTestingSet.get(i));\n }\n for(int i = 0; i < irisTestingSet.size(); i++) {\n if(id3Iris[i].equals(irisTestingSet.get(i)[Iris.classColumn].value())) {\n System.out.println(\"ID3: Correct (\" + id3Iris[i] + \")\");\n } else {\n System.out.println(\"ID3: Incorrect (\" + id3Iris[i] + \", actually \" + irisTestingSet.get(i)[Iris.classColumn].value() + \")\");\n }\n }\n\n System.out.println(Soybean.class.getSimpleName());\n id3 = new ID3(soybean, soybeanTestingSet, Soybean.classColumn);\n String[] id3Soybean = new String[soybeanTestingSet.size()];\n for(int i = 0; i < soybeanTestingSet.size(); i++) {\n id3Soybean[i] = id3.classify(soybeanTestingSet.get(i));\n }\n for(int i = 0; i < soybeanTestingSet.size(); i++) {\n if(id3Soybean[i].equals(soybeanTestingSet.get(i)[Soybean.classColumn].value())) {\n System.out.println(\"ID3: Correct (\" + id3Soybean[i] + \")\");\n } else {\n System.out.println(\"ID3: Incorrect (\" + id3Soybean[i] + \", actually \" + soybeanTestingSet.get(i)[Soybean.classColumn].value() + \")\");\n }\n }\n }", "void makeSampleGraph() {\n\t\tg.addVertex(\"a\");\n\t\tg.addVertex(\"b\");\n\t\tg.addVertex(\"c\");\n\t\tg.addVertex(\"d\");\n\t\tg.addVertex(\"e\");\n\t\tg.addVertex(\"f\");\n\t\tg.addVertex(\"g\");\n\t\tg.addEdge(\"a\", \"b\");\n\t\tg.addEdge(\"b\", \"c\");\n\t\tg.addEdge(\"b\", \"f\");\n\t\tg.addEdge(\"c\", \"d\");\n\t\tg.addEdge(\"d\", \"e\");\n\t\tg.addEdge(\"e\", \"f\");\n\t\tg.addEdge(\"e\", \"g\");\n\t}", "private void createData() {\n//\n// tour = new Tour();\n// tour.setTitle(\"Death Valley\");\n// tour.setDescription(\"A tour to Death Valley\");\n// tour.setPrice(900);\n// tour.setImage(\"death_valley\");\n// tour = dataSource.create(tour);\n// Log.i(LOGTAG, \"Tour created with id \" + tour.getId());\n//\n// tour = new Tour();\n// tour.setTitle(\"San Francisco\");\n// tour.setDescription(\"A tour to San Francisco\");\n// tour.setPrice(1200);\n// tour.setImage(\"san_francisco\");\n// tour = dataSource.create(tour);\n// Log.i(LOGTAG, \"Tour created with id \" + tour.getId());\n\n ToursPullParser parser = new ToursPullParser();\n tours = parser.parseXML(this);\n\n for (Tour tour : tours) {\n dataSource.create(tour);\n }\n\n }", "public Dataset(final int dimensions, final int numPoints) {\n this(dimensions);\n\n for (int i = 0; i < numPoints; i++) {\n double[] point = new double[dimensions];\n addPoint(new DataPoint(point));\n }\n }", "private XYDataset createDataset() {\n\t \tXYSeriesCollection dataset = new XYSeriesCollection();\n\t \t\n\t \t//Definir cada Estacao\n\t\t XYSeries aes1 = new XYSeries(\"Estação1\");\n\t\t XYSeries aes2 = new XYSeries(\"Estação2\");\n\t\t XYSeries aes3 = new XYSeries(\"Estação3\");\n\t\t XYSeries aes4 = new XYSeries(\"Estação4\");\n\t\t XYSeries aes5 = new XYSeries(\"Estação5\");\n\t\t XYSeries aes6 = new XYSeries(\"Estação6\");\n\t\t XYSeries aes7 = new XYSeries(\"Estação7\");\n\t\t XYSeries aes8 = new XYSeries(\"Estação8\");\n\t\t XYSeries aes9 = new XYSeries(\"Estação9\");\n\t\t XYSeries aes10 = new XYSeries(\"Estação10\");\n\t\t XYSeries aes11 = new XYSeries(\"Estação11\");\n\t\t XYSeries aes12 = new XYSeries(\"Estação12\");\n\t\t XYSeries aes13 = new XYSeries(\"Estação13\");\n\t\t XYSeries aes14 = new XYSeries(\"Estação14\");\n\t\t XYSeries aes15 = new XYSeries(\"Estação15\");\n\t\t XYSeries aes16 = new XYSeries(\"Estação16\");\n\t\t \n\t\t //Definir numero de utilizadores em simultaneo para aparece na Interface\n\t\t XYSeries au1 = new XYSeries(\"AU1\");\n\t\t XYSeries au2 = new XYSeries(\"AU2\");\n\t\t XYSeries au3 = new XYSeries(\"AU3\");\n\t\t XYSeries au4 = new XYSeries(\"AU4\");\n\t\t XYSeries au5 = new XYSeries(\"AU5\");\n\t\t XYSeries au6 = new XYSeries(\"AU6\");\n\t\t XYSeries au7 = new XYSeries(\"AU7\");\n\t\t XYSeries au8 = new XYSeries(\"AU8\");\n\t\t XYSeries au9 = new XYSeries(\"AU9\");\n\t\t XYSeries au10 = new XYSeries(\"AU10\");\n\t\t \n\t\t //Colocar estacoes no gráfico\n\t\t aes1.add(12,12);\n\t\t aes2.add(12,37);\n\t\t aes3.add(12,62);\n\t\t aes4.add(12,87);\n\t\t \n\t\t aes5.add(37,12);\n\t\t aes6.add(37,37);\n\t\t aes7.add(37,62);\n\t\t aes8.add(37,87);\n\t\t \n\t\t aes9.add(62,12); \n\t\t aes10.add(62,37);\n\t\t aes11.add(62,62);\n\t\t aes12.add(62,87);\n\t\t \n\t\t aes13.add(87,12);\n\t\t aes14.add(87,37);\n\t\t aes15.add(87,62);\n\t\t aes16.add(87,87);\n\t\t \n\t\t//Para a bicicleta 1\n\t\t \t\n\t\t\t for(Entry<String, String> entry : position1.entrySet()) {\n\t\t\t\t String key = entry.getKey();\n\t\t\t\t \n\t\t\t\t String[] part= key.split(\",\");\n\t\t\t\t double keyX=Double.valueOf(part[0]);\n\t\t\t\t double keyY=Double.valueOf(part[1]);\n\t\t\t\t \n\t\t\t\t au1.add(keyX,keyY);\n\t\t\t }\n\t\t \n\t\t\t //Para a bicicleta 2\n\t\t for(Entry<String, String> entry : position2.entrySet()) {\n\t\t\t String key = entry.getKey();\n\t\t\t \n\t\t\t String[] part= key.split(\",\");\n\t\t\t double keyX=Double.valueOf(part[0]);\n\t\t\t double keyY=Double.valueOf(part[1]);\n\t\t\t \n\t\t\t au2.add(keyX,keyY);\n\t\t }\n\t\t \n\t\t //Para a bicicleta 3\n\t\t for(Entry<String, String> entry : position3.entrySet()) {\n\t\t\t String key = entry.getKey();\n\t\t\t \n\t\t\t String[] part= key.split(\",\");\n\t\t\t double keyX=Double.valueOf(part[0]);\n\t\t\t double keyY=Double.valueOf(part[1]);\n\t\t\t \n\t\t\t au3.add(keyX,keyY);\n\t\t }\n\t\t for(Entry<String, String> entry : position4.entrySet()) {\n\t\t\t String key = entry.getKey();\n\t\t\t \n\t\t\t String[] part= key.split(\",\");\n\t\t\t double keyX=Double.valueOf(part[0]);\n\t\t\t double keyY=Double.valueOf(part[1]);\n\t\t\t \n\t\t\t au4.add(keyX,keyY);\n\t\t }\n\t\t for(Entry<String, String> entry : position5.entrySet()) {\n\t\t\t String key = entry.getKey();\n\t\t\t \n\t\t\t String[] part= key.split(\",\");\n\t\t\t double keyX=Double.valueOf(part[0]);\n\t\t\t double keyY=Double.valueOf(part[1]);\n\t\t\t \n\t\t\t au5.add(keyX,keyY);\n\t\t }\n\t\t for(Entry<String, String> entry : position6.entrySet()) {\n\t\t\t String key = entry.getKey();\n\t\t\t \n\t\t\t String[] part= key.split(\",\");\n\t\t\t double keyX=Double.valueOf(part[0]);\n\t\t\t double keyY=Double.valueOf(part[1]);\n\t\t\t \n\t\t\t au6.add(keyX,keyY);\n\t\t }\n\t\t for(Entry<String, String> entry : position7.entrySet()) {\n\t\t\t String key = entry.getKey();\n\t\t\t \n\t\t\t String[] part= key.split(\",\");\n\t\t\t double keyX=Double.valueOf(part[0]);\n\t\t\t double keyY=Double.valueOf(part[1]);\n\t\t\t \n\t\t\t au7.add(keyX,keyY);\n\t\t }\n\t\t for(Entry<String, String> entry : position8.entrySet()) {\n\t\t\t String key = entry.getKey();\n\t\t\t \n\t\t\t String[] part= key.split(\",\");\n\t\t\t double keyX=Double.valueOf(part[0]);\n\t\t\t double keyY=Double.valueOf(part[1]);\n\t\t\t \n\t\t\t au8.add(keyX,keyY);\n\t\t }\n\t\t for(Entry<String, String> entry : position9.entrySet()) {\n\t\t\t String key = entry.getKey();\n\t\t\t \n\t\t\t String[] part= key.split(\",\");\n\t\t\t double keyX=Double.valueOf(part[0]);\n\t\t\t double keyY=Double.valueOf(part[1]);\n\t\t\t \n\t\t\t au9.add(keyX,keyY);\n\t\t }\n\t\t for(Entry<String, String> entry : position10.entrySet()) {\n\t\t\t String key = entry.getKey();\n\t\t\t \n\t\t\t String[] part= key.split(\",\");\n\t\t\t double keyX=Double.valueOf(part[0]);\n\t\t\t double keyY=Double.valueOf(part[1]);\n\t\t\t \n\t\t\t au10.add(keyX,keyY);\n\t\t }\n\t\t \n\t\t //Add series to dataset\n\t\t dataset.addSeries(au1);\n\t\t dataset.addSeries(au2);\n\t\t dataset.addSeries(au3);\n\t\t dataset.addSeries(au4);\n\t\t dataset.addSeries(au5);\n\t\t dataset.addSeries(au6);\n\t\t dataset.addSeries(au7);\n\t\t dataset.addSeries(au8);\n\t\t dataset.addSeries(au9);\n\t\t dataset.addSeries(au10);\n\t\t \n\t\t \n\t\t dataset.addSeries(aes1);\n\t\t dataset.addSeries(aes2);\n\t\t dataset.addSeries(aes3);\n\t\t dataset.addSeries(aes4);\n\t\t dataset.addSeries(aes5);\n\t\t dataset.addSeries(aes6);\n\t\t dataset.addSeries(aes7);\n\t\t dataset.addSeries(aes8);\n\t\t dataset.addSeries(aes9);\n\t\t dataset.addSeries(aes10);\n\t\t dataset.addSeries(aes11);\n\t\t dataset.addSeries(aes12);\n\t\t dataset.addSeries(aes13);\n\t\t dataset.addSeries(aes14);\n\t\t dataset.addSeries(aes15);\n\t\t dataset.addSeries(aes16);\n\t\t \n\t\t return dataset;\n\t }", "DataElement createDataElement();", "public UsersDataSet() {}", "@Test\r\n public void testDataBuilder_Init(){\r\n \tdataBuild.initAllData();\r\n \tassertTrue(dataBuild.getCPUList().size() > 0);\r\n \tSystem.out.println(\"Total # of CPUs: \" + dataBuild.getCPUList().size());\r\n \tassertTrue(dataBuild.getGPUList().size() > 0);\r\n \tSystem.out.println(\"Total # of GPUs: \" + dataBuild.getGPUList().size());\r\n \tassertTrue(dataBuild.getMBList().size() > 0);\r\n \tSystem.out.println(\"Total # of Motherboards: \" + dataBuild.getMBList().size());\r\n \tassertTrue(dataBuild.getMEMList().size() > 0);\r\n \tSystem.out.println(\"Total # of Memory Units: \" + dataBuild.getMEMList().size());\r\n \tassertTrue(dataBuild.getPSUList().size() > 0);\r\n \tSystem.out.println(\"Total # of PSUs: \" + dataBuild.getPSUList().size());\r\n \tassertTrue(dataBuild.getDISKList().size() > 0);\r\n \tSystem.out.println(\"Total # of Disks: \" + dataBuild.getDISKList().size());\r\n }", "private void generateSampleKeys()\n {\n Iterator<ArrayList<String>> di = data.iterator();\n String key2;\n\n while (di.hasNext())\n {\n ArrayList<String> row = di.next();\n\n Iterator<Integer> kci = keyCols.iterator();\n StringBuffer buf = new StringBuffer();\n while (kci.hasNext())\n {\n Integer i = kci.next();\n String value = row.get(i);\n buf.append(value + '_');\n }\n key2 = new String(StringUtils.chop(buf.toString()));\n key2 = key2.toUpperCase();\n\n SampleWithProperties s = new SampleWithProperties(key2);\n\n // now have to add properties\n Iterator<Integer> pi = spts.keySet().iterator();\n while (pi.hasNext())\n {\n Integer key3 = pi.next();\n String val = row.get(key3);\n val = val.toUpperCase();\n s.addProperty(spts.get(key3), val);\n }\n swp.add(s);\n }\n }", "static double[][] makeTestData() {\n double[][] data = new double[21][2];\n double xmax = 5;\n double xmin = -5;\n double dx = (xmax - xmin) / (data.length -1);\n for (int i = 0; i < data.length; i++) {\n double x = xmin + dx * i;\n double y = 2.5 * x * x * x - x * x / 3 + 3 * x;\n data[i][0] = x;\n data[i][1] = y;\n }\n return data;\n }", "public SimpleDataGenerator() {\n\n names.add(\"Anna\");\n names.add(\"Maria\");\n names.add(\"Angela\");\n names.add(\"Monika\");\n names.add(\"Agnieszka\");\n names.add(\"Agnieszka\");\n names.add(\"Natalia\");\n names.add(\"Andzrzej\");\n names.add(\"Ferdynand\");\n names.add(\"Mateusz\");\n names.add(\"Adam\");\n names.add(\"Wojciech\");\n names.add(\"Robert\");\n names.add(\"Jerzy\");\n names.add(\"Jakub\");\n names.add(\"Patryk\");\n names.add(\"Alekasnder\");\n names.add(\"Lech\");\n names.add(\"Antoni\");\n names.add(\"Marian\");\n\n surnames.add(\"Kowalski\");\n surnames.add(\"Nowak\");\n surnames.add(\"Brzozowski\");\n surnames.add(\"Kaczynski\");\n surnames.add(\"Ziobro\");\n surnames.add(\"Macierewicz\");\n surnames.add(\"Kopacz\");\n surnames.add(\"Tusk\");\n surnames.add(\"Szydlo\");\n surnames.add(\"Niesiolowski\");\n surnames.add(\"Grodzki\");\n surnames.add(\"Szpak\");\n surnames.add(\"Kiepski\");\n surnames.add(\"Aleksandrowicz\");\n surnames.add(\"Wyrostek\");\n surnames.add(\"Gibala\");\n surnames.add(\"Marcinkiewicz\");\n surnames.add(\"Mrozowicz\");\n surnames.add(\"Olechowski\");\n surnames.add(\"Duda\");\n surnames.add(\"Thrump\");\n\n products.add(\"Komputer\");\n products.add(\"Myszka\");\n products.add(\"Monitor\");\n products.add(\"Klawiatura\");\n products.add(\"Kawa\");\n products.add(\"Herbata\");\n }", "@Override\n public TestingSet createTestingSet(int individuals) \n {\n return TestingSet.createSingleTrialForAllIndividuals(individuals);\n }", "DataType createDataType();", "public Dataset(final int dimensions) {\n this.dimensions = dimensions;\n ntree = new NTree(dimensions);\n }", "DataStreams createDataStreams();", "public void createDataSourceReturnsCorrectDefinition() {\n SoftDeleteColumnDeletionDetectionPolicy deletionDetectionPolicy =\n new SoftDeleteColumnDeletionDetectionPolicy()\n .setSoftDeleteColumnName(\"isDeleted\")\n .setSoftDeleteMarkerValue(\"1\");\n\n HighWaterMarkChangeDetectionPolicy changeDetectionPolicy =\n new HighWaterMarkChangeDetectionPolicy(\"fakecolumn\");\n\n // AzureSql\n createAndValidateDataSource(createTestSqlDataSourceObject(null, null));\n createAndValidateDataSource(createTestSqlDataSourceObject(deletionDetectionPolicy, null));\n createAndValidateDataSource(createTestSqlDataSourceObject(null, new SqlIntegratedChangeTrackingPolicy()));\n createAndValidateDataSource(createTestSqlDataSourceObject(deletionDetectionPolicy,\n changeDetectionPolicy));\n\n // Cosmos\n createAndValidateDataSource(createTestCosmosDataSource(null, false));\n createAndValidateDataSource(createTestCosmosDataSource(null, true));\n createAndValidateDataSource(createTestCosmosDataSource(deletionDetectionPolicy, false));\n createAndValidateDataSource(createTestCosmosDataSource(deletionDetectionPolicy, false));\n\n // Azure Blob Storage\n createAndValidateDataSource(createTestBlobDataSource(null));\n createAndValidateDataSource(createTestBlobDataSource(deletionDetectionPolicy));\n\n // Azure Table Storage\n createAndValidateDataSource(createTestTableStorageDataSource());\n createAndValidateDataSource(createTestBlobDataSource(deletionDetectionPolicy));\n }", "public void createDataSourceReturnsCorrectDefinition() {\n SoftDeleteColumnDeletionDetectionPolicy deletionDetectionPolicy =\n new SoftDeleteColumnDeletionDetectionPolicy()\n .setSoftDeleteColumnName(\"isDeleted\")\n .setSoftDeleteMarkerValue(\"1\");\n\n HighWaterMarkChangeDetectionPolicy changeDetectionPolicy =\n new HighWaterMarkChangeDetectionPolicy(\"fakecolumn\");\n\n // AzureSql\n createAndValidateDataSource(createTestSqlDataSourceObject(null, null));\n createAndValidateDataSource(createTestSqlDataSourceObject(deletionDetectionPolicy, null));\n createAndValidateDataSource(createTestSqlDataSourceObject(null, new SqlIntegratedChangeTrackingPolicy()));\n createAndValidateDataSource(createTestSqlDataSourceObject(deletionDetectionPolicy,\n changeDetectionPolicy));\n\n // Cosmos\n createAndValidateDataSource(createTestCosmosDataSource(null, false));\n createAndValidateDataSource(createTestCosmosDataSource(null, true));\n createAndValidateDataSource(createTestCosmosDataSource(deletionDetectionPolicy, false));\n createAndValidateDataSource(createTestCosmosDataSource(deletionDetectionPolicy, false));\n\n // Azure Blob Storage\n createAndValidateDataSource(createTestBlobDataSource(null));\n createAndValidateDataSource(createTestBlobDataSource(deletionDetectionPolicy));\n\n // Azure Table Storage\n createAndValidateDataSource(createTestTableStorageDataSource());\n createAndValidateDataSource(createTestBlobDataSource(deletionDetectionPolicy));\n }", "private static Data generateDataPoint(String raw, DataType type) {\n Data data = new Data<Boolean>(false);\n //There can be null data. Its marked as a question mark in the datasets.\n\n if(raw.equals(\"?\")) {\n return null;\n }\n\n switch (type) {\n case Boolean:\n if(raw.equals(\"y\")) {\n data = new Data<Boolean>(true);\n }\n else if(raw.equals(\"n\")) {\n data = new Data<Boolean>(false);\n }\n else {\n data = new Data<Boolean>(Boolean.parseBoolean(raw));\n }\n break;\n case Double:\n data = new Data<Double>(Double.parseDouble(raw));\n break;\n case Integer:\n data = new Data<Integer>(Integer.parseInt(raw));\n break;\n case String:\n data = new Data<String>(raw);\n break;\n }\n return data;\n }", "DataTable createDataTable();", "@SuppressWarnings(\"unchecked\")\n\tprivate static void createTestData() {\n\t\t\n\t\tusers.put(\"User0\", objectHandler.createUser(25.0));\n\t\tusers.put(\"User1\", objectHandler.createUser(1.0));\n\t\t\n\t\tdocuments.put(\"Doc0\", objectHandler.createDocument(\"mydoc\", 25, '4', 'C'));\n\t\tdocuments.put(\"Doc1\", objectHandler.createDocument(\"another\", 15, '3', 'B'));\n\t\t\n\t\tusers.get(\"User0\").addDocument(documents.get(\"Doc0\"));\n\t\tusers.get(\"User1\").addDocument(documents.get(\"Doc1\"));\n\t\t\n\t\tPrinterCapability capability1 = objectHandler.createPrinterCapability(true, false, true, true);\n\t\tPrinterCapability capability2 = objectHandler.createPrinterCapability(false, true, true, false);\n\t\tPrinterCapability capability3 = objectHandler.createPrinterCapability(false, true, true, false);\n\t\t\n\t\tPrinterPricing pricing = objectHandler.createPrinterPricing(0.03, 0.14, 0.06, 0.24);\n\t\t\n\t\tPrinterCapacity capacity1 = objectHandler.createPrinterCapacity(25, 0, 10, 30);\n\t\tPrinterCapacity capacity2 = objectHandler.createPrinterCapacity(0, 10, 15, 0);\n\t\tPrinterCapacity capacity3 = objectHandler.createPrinterCapacity(0, 10, 15, 0);\n\t\t\n\t\tprinters.put(\"Printer0\", objectHandler.createPrinter(\"A4All\", capability1, pricing, capacity1, objectHandler.createPrinterStatus()));\n\t\tprinters.put(\"Printer1\", objectHandler.createPrinter(\"A3B\", capability2, pricing, capacity2, objectHandler.createPrinterStatus()));\n\t\tprinters.put(\"Printer2\", objectHandler.createPrinter(\"A3B-rip\", capability3, pricing, capacity3, objectHandler.createPrinterStatus()));\n\t\t\n\t\tVDMSet status = new VDMSet();\n\t\tstatus.add(\"needFixing\");\n\t\tprinters.get(\"Printer2\").break_(status);\n\t}", "public Database createTableFromArray(int [][] dataDbn){\r\n \tDatabase db = new Database();\r\n \tTable table = null;\r\n \tToken t = null, t2 = null;\r\n \tAttribute attr = null;\r\n \tList ll;\r\n \tLinkedList attributeValues = new LinkedList();\r\n \tLinkedList sampleValueList;\r\n \tint numGenesTotal;\r\n \tint samples;\r\n \tString atrNode = \"node\";\r\n \t\r\n \ttry {\r\n \t\ttable = new Table(); \r\n \t\ttable.setName(\"name\");\r\n \t}catch(Exception e){\r\n \t\t\r\n\t\t\te.printStackTrace();\r\n \t}\r\n \t\r\n \t\r\n \tnumGenesTotal = dataDbn[0].length;\r\n \tsamples = dataDbn.length;\r\n \t\r\n \t// each gene has 3 levels (3 attributes). they are represent by 0,1,2\r\n \tattributeValues.add(new Integer(0));\r\n \tattributeValues.add(new Integer(1));\r\n \tattributeValues.add(new Integer(2));\r\n \t\r\n \t// set attributes for each gene\r\n \tfor(int k=0;k<numGenesTotal;k++){\r\n \t\tString name = atrNode + k;\r\n \t\tattr = new Attribute(name);\r\n \t\tattr.setValues(attributeValues);\r\n \t\ttable.addAttribute(attr);\r\n \t}\r\n \t\r\n \t// read dbnData and load gene's value of each sample in to List and then add this List in to the table\r\n \tfor(int i =0;i<samples;i++){\r\n \t\tsampleValueList = new LinkedList();\r\n \t\tfor(int j=0; j<numGenesTotal;j++){\r\n \t\t\tInteger val = new Integer(dataDbn[i][j]);\r\n \t\t\tsampleValueList.add(val);\r\n \t\t}\r\n \t\ttable.addTuple(new Tuple(sampleValueList));\r\n \t}\r\n \t\r\n \tdb.addTable(table);\r\n \t/*\r\n \tString filePath = \"C:\\\\Users\\\\devamuni\\\\Documents\\\\D_Result\\\\Input.out\";\r\n File f1 = new File(filePath);\r\n try {\r\n\t\t\tOutputStream os = new FileOutputStream(f1);\r\n\t\t\tsave(os, db);\r\n } catch (FileNotFoundException e) {\r\n\t\t\t// TODO Auto-generated catch block\t\r\n\t\t\te.printStackTrace();\r\n } */\r\n \treturn db;\r\n }", "public void create () {\n // TODO random generation of a ~100 x 100 x 100 world\n }", "public void addDataset(Resource dataset, String label, String comment, String publisher, String date, Resource structure){\n\t\tdataCubeModel.add(dataset, RDF.type, QB.Dataset);\n\t\tdataCubeModel.add(dataset, DCTerms.publisher, publisher);\n\t\tdataCubeModel.add(dataset, RDFS.label, label);\n\t\tdataCubeModel.add(dataset, RDFS.comment, comment);\n\t\tdataCubeModel.add(dataset, QB.structure, structure);\n\t\tdataCubeModel.add(dataset, DCTerms.date, date);\n\t}", "private DataSet zipfDataSet(){\n ZipfDistribution zipfDistribution = new ZipfDistribution(NUM_DISTINCT_TASKS, 1);\n //Magic number which is computed the following way\n //Take the H_{2500,1}/(1+4+9+...) * Target Mean\n //this will result in mean of 50\n Double multiplier = (8.4/1.644)*TARGET_MEAN;\n DataSet dataSet = new DataSet();\n Map<Integer, UUID> ids = new HashMap<>();\n //generate costs from sampling from normal distribution\n for(int i=0; i < NUM_TASKS; i++){\n //zipf gives numbers from 1 to NUM_DISTINCT_TASKS where 1 is most frequent\n int sample = zipfDistribution.sample();\n UUID id = ids.getOrDefault(sample, UUID.randomUUID());\n ids.put(sample, id);\n Double cost = multiplier * (1D/sample);\n dataSet.getTasks().add(new Task(cost.longValue(), id));\n }\n return dataSet;\n }", "private static CategoryDataset createDataset() throws SQLException, InterruptedException \n\t{ \n\t\t// creating dataset \n\t\tDefaultCategoryDataset dataset = new DefaultCategoryDataset();\n\t\t\n\t\t//setting up the connexion\n\t\tConnection con = null;\n\t\tString conUrl = \"jdbc:sqlserver://\"+Login.Host+\"; databaseName=\"+Login.databaseName+\"; user=\"+Login.user+\"; password=\"+Login.password+\";\";\n\t\ttry \n\t\t{\n\t\t\tcon = DriverManager.getConnection(conUrl);\n\t\t} \n\t\tcatch (SQLException e1) \n\t\t{\n\t\t\te1.printStackTrace();\n\t\t}\n\t\t\n\t\t//this counter will allow me to run my while loop only once\n\t\tint cnt=0;\n\t\twhile(cnt<1)\n\t\t{ \n\t\t\t//check the query number at each call to the function in order to know which procedure must me executed\n\t\t\tif (queryNumber==0){\n\t\t\t\tcnt++;\n\t\t\t\tcstmt = con.prepareCall(\"{call avgMonthly(?,?,?,?)}\");\n\t\t\t\t\n\t\t\t\t//setting the procedures parameters with the one chosen by the user\n\t\t\t\tcstmt.setInt(1, Integer.parseInt(year));\n\t\t\t\tcstmt.setInt(2, Integer.parseInt(month));\n\t\t\t\tcstmt.setString(3, featureStringH);\t\n\t\t\t\tcstmt.setString(4, actionStringH);\t\n\t\t\t\tResultSet aveTempAvg = cstmt.executeQuery();\n\t\t\t\t\n\t\t\t\t// extracting the data of my query in order to plot it\n\t\t\t\tResultSetMetaData rsmd = aveTempAvg.getMetaData();\n\t\t\t\tif(rsmd!=null) \n\t\t\t\t{\n\t\t\t\t\twhile (aveTempAvg.next()) \n\t\t\t\t\t{\n\t\t\t\t\t\tString columnValue = aveTempAvg.getString(1);//latency\n\t\t\t\t\t\tint dayAxisNum=aveTempAvg.getInt(2);//average\n\t\t\t\t\t\tif(columnValue!=null) {\n\t\t\t\t\t\t\t//Adding the result of the query to the data set and setting y value to the average latency and x to the corresponding day\n\t\t\t\t\t\t\tdataset.setValue(Double.parseDouble(columnValue),\"series\",Integer.toString(dayAxisNum));\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse \n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdataset.setValue(0, (\"series\" +\"\"+0), \"\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\telse if (queryNumber==1){\n\t\t\t\tcnt++;\n\t\t\t\tcstmt = con.prepareCall(\"{call avgDaily(?,?,?)}\");\t\n\t\t\t\t/*for the second query , the user will enter seperate year month and day \n\t\t\t\t so we wil have to concatenate the date into a string before setting the date value*/\n\t\t\t\tString newDate= year+\"-\"+month+\"-\"+day;\n\t\t\t\tcstmt.setString(1, newDate);\n\t\t\t\tcstmt.setString(2, featureStringH);\n\t\t\t\tcstmt.setString(3, actionStringH);\t\n\t\t\t\tResultSet aveTempAvg = cstmt.executeQuery();\n\t\t\t\t\n\t\t\t\t//extracting the data of the query\n\t\t\t\tResultSetMetaData rsmd = aveTempAvg.getMetaData();\n\t\t\t\tif(rsmd!=null) \n\t\t\t\t{\n\t\t\t\t\tint hour = 0;\n\t\t\t\t\twhile (aveTempAvg.next()) \n\t\t\t\t\t{\n\t\t\t\t\t\tString columnValue = aveTempAvg.getString(1);\n\t\t\t\t\t\tint hour2=aveTempAvg.getInt(2);\n\t\t\t\t\t\tif(columnValue!=null) {\n\t\t\t\t\t\t\t//setting y value to the average and the x is the corresponding hour\n\t\t\t\t\t\t\tdataset.setValue(Double.parseDouble(columnValue),\"series\",Integer.toString(hour2));\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse \n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//I will add 0 if I don't have the corresponding value of the specified Hour\n\t\t\t\t\t\t\tdataset.setValue(0, (\"series\" +\"\"+hour), \"\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (queryNumber==2){\n\t\t\t\tcnt++;\n\t\t\t\t//Thread.sleep(100);\n\t\t\t\tcstmt = con.prepareCall(\"{call avgHour(?,?,?,?)}\");\t\n\t\t\t\tString newDate2= year+\"-\"+month+\"-\"+day;\n\t\t\t\t//same as for the daily query we have to set the parameters , we add to that the hour as last parameter\n\t\t\t\tcstmt.setString(1, newDate2);\n\t\t\t\tcstmt.setString(2, featureStringH);\n\t\t\t\tcstmt.setString(3, actionStringH);\n\t\t\t\tcstmt.setInt(4,Integer.parseInt(hourString));\n\t\t\t\tResultSet aveTempAvg = cstmt.executeQuery();\n\t\t\t\t\n\t\t\t\t//extract the data from the query\n\t\t\t\tResultSetMetaData rsmd = aveTempAvg.getMetaData();\n\t\t\t\tif(rsmd!=null) \n\t\t\t\t{\n\t\t\t\t\twhile (aveTempAvg.next()) \n\t\t\t\t\t{\n\t\t\t\t\t\tString columnValue = aveTempAvg.getString(1);\n\t\t\t\t\t\tint min=aveTempAvg.getInt(2);\n\t\t\t\t\t\tif(columnValue!=null) {\n\t\t\t\t\t\t\t//setting y value to the average and the x is the corresponding minute\n\n\t\t\t\t\t\t\tdataset.setValue(Double.parseDouble(columnValue),\"series\",Integer.toString(min));\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse \n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//adding 0 if I don't have the corresponding minute\n\t\t\t\t\t\t\tdataset.setValue(0, (\"series\"+min),\"\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\t\treturn dataset; \n\t}", "DataList createDataList();", "public static String generateDatasetName() {\n return DATASET_NAME_PREFIX + UUID.randomUUID().toString().replace('-', '_');\n }", "public void PrepareDataset(TweetPreprocessor preprocessor, String dataset)\n\t{\n\t\tdbiterator = DBInstanceIterator.getInstance();\n\t\ttry\n {\n System.out.println(\"Preparing Datasets ...\");\n //PrepareAll(preprocessor,dataset);\n\n\t\t\tSystem.out.println(\"Saving work to Database ..\");\n\t\t\tsaveTextOutput(Dataset + \"data_text.csv\", \"d_text\");\n\t\t\tsaveTextOutput(Dataset + \"data_feature.csv\", \"d_feature\");\n\t\t\tsaveTextOutput(Dataset + \"data_complex.csv\", \"d_complex\");\n\t\t\t//saveLexiconOuput(Dataset + \"data_lexicon.csv\",true);\n\t\t\tSystem.out.println(\"Datasets ready for training .%.\");\n\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}", "public Sample()\n {\n inputs = new ArrayList<>();\n outputs = new ArrayList<>();\n numberOfInputs = 0;\n numberOfOutputs = 0;\n comment = \"\";\n }", "public Data createData(Address addr, DataType dataType) throws CodeUnitInsertionException;" ]
[ "0.67965585", "0.6705405", "0.65027916", "0.6312678", "0.6250663", "0.6235951", "0.61107457", "0.6095708", "0.6056649", "0.60484695", "0.60422295", "0.6012751", "0.5971338", "0.5967914", "0.5940529", "0.58956224", "0.5895352", "0.5860418", "0.5852834", "0.5832635", "0.57935923", "0.5793536", "0.5765934", "0.5686505", "0.56501824", "0.5649613", "0.5648408", "0.56294316", "0.562126", "0.56184375", "0.5615308", "0.56031126", "0.55885535", "0.558459", "0.5559601", "0.5545348", "0.5522643", "0.55123496", "0.54908323", "0.54591435", "0.5454956", "0.54546636", "0.5446699", "0.5403384", "0.53882116", "0.5367241", "0.53595054", "0.5355719", "0.5352016", "0.53137946", "0.5312472", "0.5309264", "0.53049713", "0.5298905", "0.52876186", "0.5286736", "0.52828467", "0.5261378", "0.5260161", "0.52498955", "0.5239064", "0.523707", "0.52264786", "0.5221868", "0.5212149", "0.5203192", "0.5201331", "0.519953", "0.5196182", "0.5183212", "0.5179204", "0.5177413", "0.51736623", "0.51709443", "0.5157059", "0.5155547", "0.5151269", "0.5141116", "0.5139684", "0.51391304", "0.51390445", "0.5134394", "0.5129086", "0.51266766", "0.51264405", "0.5125301", "0.5125301", "0.5114233", "0.5104199", "0.51019585", "0.51019067", "0.50969124", "0.5084318", "0.50798404", "0.5075096", "0.50715345", "0.50653404", "0.5061992", "0.5059758", "0.5056196" ]
0.57282895
23
returns Thai word if exists, otherwise returns English word passed in
public String getThaiWordFromEngWord(String englishWord) { Cursor cursor = mDatabase.query( TABLE_NAME, new String[]{COL_THAI_WORD}, COL_ENG_WORD + "=?", new String[]{englishWord}, null, null, null ); if (cursor.getCount() > 0) { cursor.moveToFirst(); return cursor.getString(cursor.getColumnIndex(COL_THAI_WORD)); } else { return englishWord; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public String getEngWordFromThaiWord(String thaiWord) {\n Cursor cursor = mDatabase.query(\n TABLE_NAME,\n new String[]{COL_ENG_WORD},\n COL_THAI_WORD + \"=?\",\n new String[]{thaiWord},\n null,\n null,\n null\n );\n if (cursor.getCount() > 0) {\n cursor.moveToFirst();\n return cursor.getString(cursor.getColumnIndex(COL_ENG_WORD));\n } else {\n return thaiWord;\n }\n }", "public String getEnglish()\n {\n if (spanishWord.substring(0,3).equals(\"el \"))\n {\n spanishWord = spanishWord.substring(3, spanishWord.length());\n }\n else if (spanishWord.substring(0, 3).equals(\"la \"))\n {\n spanishWord = spanishWord.substring(3, spanishWord.length());\n }\n if (spanishWord.equals(\"estudiante\"))\n {\n return \"student\"; \n }\n else if (spanishWord.equals(\"aprender\"))\n {\n return \"to learn\";\n }\n else if (spanishWord.equals(\"entender\"))\n {\n return\"to understand\";\n }\n else if (spanishWord.equals(\"verde\"))\n {\n return \"green\";\n }\n else\n {\n return null;\n }\n }", "java.lang.String getWord();", "public String spellcheck(String word) {\n // Check if the world is already in lcDictionary.\n String lcdictionaryLookup = lcDictionary.get(word.toLowerCase());\n if(lcdictionaryLookup != null) {\n return lcdictionaryLookup;\n }\n String reducedWord = reducedWord(word);\n String rwdictionaryLookup = rwDictionary.get(reducedWord);\n if(rwdictionaryLookup != null) {\n return rwdictionaryLookup;\n }\n return \"NO SUGGESTION\";\n }", "static boolean isEnglishWord(String str) {\r\n return localDictionary.contains(str);\r\n }", "private String getPhrase(String key) {\r\n if (\"pl\".equals(System.getProperty(\"user.language\")) && phrasesPL.containsKey(key)) {\r\n return phrasesPL.get(key);\r\n } else if (phrasesEN.containsKey(key)) {\r\n return phrasesEN.get(key);\r\n }\r\n return \"Translation not found!\";\r\n }", "public static String translateWord(String word) {\n\n if (word.length() < 1) return word;\n int[] vowelArray = word.chars().filter(c -> vowels.contains((char) c)).toArray();\n if (vowelArray.length == 0) return word.charAt(0) + word.substring(1).toLowerCase() + \"ay\";\n\n char first = Character.isUpperCase(word.charAt(0))\n ? Character.toUpperCase((char) vowelArray[0]) : (char) vowelArray[0];\n if (vowels.contains(word.charAt(0)))\n word = first + word.substring(1).toLowerCase() + \"yay\";\n else\n word = first + word.substring(word.indexOf(vowelArray[0]) + 1).toLowerCase()\n + word.substring(0, word.indexOf(vowelArray[0])).toLowerCase() + \"ay\";\n return word;\n }", "private static String convertToLatin(String word)\n {\n return word.substring(1) + word.substring(0,1) + \"ay\";\n }", "public String spanishWord() {\n\t\treturn \"Depurar\";\n\t}", "public String getKeyword(String word) {\n\t\tboolean foundPunct = false;\n String returnStr = \"\";\n for(int inc = 0; inc < word.length(); inc++) {\n char testChar = word.charAt(inc);\n if(Character.isLetter(testChar) == true) {\n if(foundPunct == true) {return null;}\n else{returnStr = returnStr + Character.toString(testChar).toLowerCase();}}\n else {foundPunct = true;}}\n if(noiseWords.contains(returnStr) == true) {\n return null;}\n if(returnStr == \"\") {\n return null;}\n return returnStr;\n\t}", "public WordInfo searchWord(String word) {\n\t\tSystem.out.println(\"Dic:SearchWord: \"+word);\n\n\t\tDocument doc;\n\t\ttry {\n\t\t\tdoc = Jsoup.connect(\"https://dictionary.cambridge.org/dictionary/english-vietnamese/\" + word).get();\n\t\t} catch(Exception e) {\n\t\t\te.printStackTrace();\n\t\t\treturn null;\n\t\t}\n\n\t\tElements elements = doc.select(\".dpos-h.di-head.normal-entry\");\n\t\tif (elements.isEmpty()) {\n\t\t\tSystem.out.println(\" not found\");\n\t\t\treturn null;\n\t\t}\n\n\t\tWordInfo wordInfo = new WordInfo(word);\n\n\t\t// Word\n\t\telements = doc.select(\".tw-bw.dhw.dpos-h_hw.di-title\");\n\n\t\tif (elements.size() == 0) {\n\t\t\tSystem.out.println(\" word not found in doc!\");\n\t\t\treturn null;\n\t\t}\n\n\t\twordInfo.setWordDictionary(elements.get(0).html());\n\n\t\t// Type\n\t\telements = doc.select(\".pos.dpos\");\n\n\t\tif(elements.size() > 0) {\n\t\t\twordInfo.setType(WordInfo.getTypeShort(elements.get(0).html()));\n//\t\t\tif (wordInfo.getTypeShort().equals(\"\"))\n//\t\t\t\tSystem.out.println(\" typemis: \"+wordInfo.getType());\n\t\t}\n\n\t\t// Pronoun\n\t\telements = doc.select(\".ipa.dipa\");\n\n\t\tif (elements.size() > 0)\n\t\t\twordInfo.setAPI(\"/\"+elements.get(0).html()+\"/\");\n\n\t\t// Trans\n\t\telements = doc.select(\".trans.dtrans\");\n\n\t\tif (elements.size() > 0)\n\t\t\twordInfo.setTrans(elements.get(0).html());\n\n\t\tSystem.out.println(\" found\");\n\t\treturn wordInfo;\n\t}", "public String getCorrectionWord(String misspell);", "boolean containsUtilize(String word)\n {\n return word.contains(\"utilize\");\n }", "public static String the(String str)\n\t{\t\t\n\t\tif (str.startsWith(\"the \")) return str;\n\t\telse if (str.startsWith(\"The \")) return str;\n\t\telse if (str.toLowerCase().charAt(0) == str.charAt(0)) return \"the \" + str;\n\t\telse return \"The \" + str.toLowerCase();\n\t}", "public String getWord(int index) {\n\t\t\n\t\tswitch (index) {\n\t\t\tcase 0:\n\t\t\t\treturn \"BUOY\";\n\t\t\tcase 1:\n\t\t\t\treturn \"COMPUTER\";\n\t\t\tcase 2:\n\t\t\t\treturn \"CONNOISSEUR\";\n\t\t\tcase 3:\n\t\t\t\treturn \"DEHYDRATE\";\n\t\t\tcase 4:\n\t\t\t\treturn \"FUZZY\";\n\t\t\tcase 5:\n\t\t\t\treturn \"HUBBUB\";\n\t\t\tcase 6:\n\t\t\t\treturn \"KEYHOLE\";\n\t\t\tcase 7:\n\t\t\t\treturn \"QUAGMIRE\";\n\t\t\tcase 8:\n\t\t\t\treturn \"SLITHER\";\n\t\t\tcase 9:\n\t\t\t\treturn \"ZIRCON\";\n\t\t\tdefault:\n\t\t\t\treturn new String(\"Illegal index\");\n\t\t}\n\t}", "@SneakyThrows\n public String get(String word) {\n String url = \"https://clients5.google.com/translate_a/t?client=dict-chrome-ex&sl=auto&tl=he&q=\"+word;\n this.response = getResponse(url);\n if(response.getSentences().size()>0) {\n return response.getSentences().get(0).getTrans();\n }\n return \"\";\n }", "public String translateFi(String s) {\n if (s == \"always\") {\n return \"aina\";\n } else if (s == \"often\") {\n return \"usein\";\n } else if (s == \"sometimes\") {\n return \"joskus\";\n } else if (s == \"never\") {\n return \"en koskaan\";\n } else if (s == \"low\") {\n return \"vähän\";\n } else if (s == \"high\") {\n return \"paljon\";\n } else if (s == \"normal\") {\n return \"jonkin verran\";\n }\n return \"\";\n }", "boolean isWord(String potentialWord);", "private static String capitaliseSingleWord(String word) {\n String capitalisedFirstLetter = word.substring(0, 1).toUpperCase();\n String lowercaseRemaining = word.substring(1).toLowerCase();\n return capitalisedFirstLetter + lowercaseRemaining;\n }", "public static String getWord(String sentence, char word) {\n\t\tString[] words;\n\t\twords = sentence.split(\" \");\n\t\tString cleanedWord=\"\";\n\t\t\n\t\tif(word=='f') {//return the first word\n\t\t\tString temp = words[0];\n\t\t\t\n\t\t\tfor(int i=0; i < temp.length(); i++) {\n\t\t\t\tif(Character.isLetter(temp.charAt(i))) {\n\t\t\t\t\tcleanedWord+= Character.toString(temp.charAt(i));\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}else {//return the last word\n\t\t\tString temp = words[words.length -1];\n\t\t\t\n\t\t\tfor(int i=0; i < temp.length(); i++) {\n\t\t\t\tif(Character.isLetter(temp.charAt(i))) {\n\t\t\t\t\tcleanedWord+= Character.toString(temp.charAt(i));\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\treturn cleanedWord;\n\t}", "String getWordIn(String schar, String echar);", "public String convertToUpperCase(String word);", "private static void printLatinWord(String s) {\n\t\tif (s.length() < 2|| !s.matches(\"\\\\w*\")) {\n\t\t\tSystem.out.print(s+\" \");\n\t\t\treturn;\n\t\t}\n\t\tSystem.out.print(s.replaceAll(\"(\\\\w)(\\\\w*)\", \"$2$1ay \"));\n\t}", "private boolean isWord(String word) {\n\t\treturn dict.isWord(word);\n\t}", "boolean hasWord();", "public String getKeyWord(String word) {\n // COMPLETE THIS METHOD\n word = word.toLowerCase();\n while (word.length() > 0 && !(Character.isDigit(word.charAt(word.length() - 1))) && !(Character.isLetter(word.charAt(word.length() - 1)))) {\n char ch = word.charAt(word.length()-1);\n //if((isPunctuation(ch))){\n if (word.endsWith(\"!\") ||\n word.endsWith(\";\") ||\n word.endsWith(\":\") ||\n word.endsWith(\"?\") ||\n word.endsWith(\",\") ||\n word.endsWith(\".\")) {\n word = word.substring(0, word.length() - 1);\n } else {\n return null;\n }\n }\n\n for (int i = 0; i < word.length(); i++) {\n if (!(Character.isLetter(word.charAt(i)))) {\n return null;\n }\n }\n\n if (noiseWords.containsKey(word))\n return null;\n return word;\n\n }", "public String acronym(String phrase) {\n String accrStr = phrase.replaceAll(\"\\\\B.|\\\\P{L}\", \"\").toUpperCase();\n return accrStr;\n }", "private String search_words(String word, int index){\n\t\tString found_words = \"\";\n\t\tint local_index = index +1;\n\t\t//We try to find the word within our childs\n\t\tfor(LexiNode child: childs){\n\t\t\tif(local_index > word.length()-1 || word.toLowerCase().charAt(local_index) == Character.toLowerCase(child.getRepresentative_letter()))\n\t\t\t\tfound_words += child.search_words(word, local_index);\n\t\t}\n\t\tif(current_word != null && word.length() > current_word.length())\n\t\t\treturn found_words;\n\t\tif(current_word != null && !found_words.equals(\"\"))\n\t\t\treturn current_word.toLowerCase().equals(word.toLowerCase()) ? current_word +\" & \" + definition + \"#\" + found_words +\"#\" : current_word + \"#\" + found_words;\n\t\telse if(current_word != null && found_words.equals(\"\"))\n\t\t\treturn current_word.toLowerCase().equals(word.toLowerCase()) ? current_word +\" & \" + definition + \"#\": current_word+ \"#\";\n\t\telse //current_word == null && found_words != null\n\t\t\treturn found_words;\n\t}", "public String wordAdmitted(String word) {\n if(!this._keyWords.contains(word)) {\n Etat currentState = this._start;\n String[] characters = word.split(\"\");\n\n for(String s : characters) {\n Etat next = currentState.isAdmitted(s);\n //If no transition exist with this character\n if(Objects.isNull(next)) return \"missingTransition\";\n else {\n currentState = next;\n }\n }\n //If last state is final\n if(currentState.isFinal()) return \"final\";\n //If last state isn't final\n else return \"notFinal\";\n } else {\n //Word is in keyWords\n return \"keyWord\";\n }\n }", "public String translate(String words) {\n String[] sentence = words.split(\" \");\n //go through each element\n for (int i = 0; i < sentence.length; i++) {\n //if the dictionary contains the word\n if (hm.containsKey(sentence[i])) {\n //change it out with the new translated one\n sentence[i] = hm.get(sentence[i]) + \" (\" + sentence[i] + \")\";\n }\n }\n\n //Build the sentence back together\n String text = \"\";\n\n for (int i = 0; i < sentence.length; i++) {\n text += sentence[i] + \" \";\n }\n\n return text;\n\n /*if(amITranslating) {\n return text;\n } else {\n return words;\n }*/\n\n\n }", "private String processWord(String word){\r\n\t\tString lword = word.toLowerCase();\r\n\t\tfor (int i = 0;i<word.length();++i){\r\n\t\t\tstemmer.add(lword.charAt(i));\r\n\t\t}\r\n\t\tstemmer.stem();\r\n\t\treturn stemmer.toString();\r\n\t}", "private String toLowerCyrillic(String word) {\n StringBuilder stringBuilder = new StringBuilder();\n for (int i = 0; i < word.length(); i++) {\n char curChar = word.charAt(i);\n if (curChar >= 'А' && curChar <= 'Я') {\n curChar += 0x20;\n } else if (curChar == 'Ё') {\n curChar = 'ё';\n }\n stringBuilder.append(curChar);\n }\n return stringBuilder.toString();\n }", "public static String stemNSW(String word)\n\t{\n\t\treturn isNSW(getRoot(word.toLowerCase()));\n\t}", "public String wordAt(int index) {\n if (index < 0 || index >= myWords.length) {\n throw new IndexOutOfBoundsException(\"bad index in wordAt \"+index);\n }\n return myWords[index];\n }", "private Word askForWord(Language lastLanguage) throws LanguageException {\n Language language = askForLanguage();\r\n if(language == null || language.equals(lastLanguage)) {\r\n throw new LanguageException();\r\n }\r\n // Step 2 : Name of the word\r\n String name = askForLine(\"Name of the word : \");\r\n Word searchedWord = czech.searchWord(language, name);\r\n if(searchedWord != null) {\r\n System.out.println(\"Word \" + name + \" found !\");\r\n return searchedWord;\r\n }\r\n System.out.println(\"Word \" + name + \" not found.\");\r\n // Step 3 : Gender/Phonetic of the word\r\n String gender = askForLine(\"\\tGender of the word : \");\r\n String phonetic = askForLine(\"\\tPhonetic of the word : \");\r\n // Last step : Creation of the word\r\n Word word = new Word(language, name, gender, phonetic);\r\n int id = czech.getListWords(language).get(-1).getId() + 1;\r\n word.setId(id);\r\n czech.getListWords(language).put(-1, word);\r\n return word;\r\n }", "public String acronym(String phrase) {\n\t\tString[] p = phrase.split(\"[\\\\W\\\\s]\");\n\t\tString returner = \"\";\n\t\tfor (String s : p) {\n\t\t\tif (!s.isEmpty())\n\t\t\t\treturner = returner + s.charAt(0);\n\t\t}\n\t\treturn returner.toUpperCase();\n\t}", "String getLang();", "private String containingWord(String attribute, String word) {\r\n return \"contains(concat(' ',normalize-space(@\" + attribute + \"),' '),' \"\r\n + word + \" ')\";\r\n }", "public static String getWord(){\n\t\t\n\t\tSystem.out.println(\"--------- Welcome to Hangman ---------\");\n\t\tScanner input = new Scanner(System.in);\n\t\tSystem.out.print(\"Enter a word:\");\n\t return input.nextLine();\n\t}", "private static String convert(String word) {\n\n char[] charArray = word.toCharArray();\n\n for (int letter = 0; letter < word.length(); letter++) {\n // Finding the first letter of a word.\n if (letter == 0 && charArray[letter] != ' ' || charArray[letter] != ' ' && charArray[letter - 1] == ' ') {\n // Checking if the first letter is lower case.\n if (charArray[letter] >= 'a' && charArray[letter] <= 'z') {\n // Converting first letter to upper case\n charArray[letter] = (char)(charArray[letter] - 'a' + 'A');\n }\n }\n // Checking if the letters other than the first letter are capital\n else if (charArray[letter] >= 'A' && charArray[letter] <= 'Z')\n // Converting uppercase other letters to lower case.\n charArray[letter] = (char)(charArray[letter] + 'a' - 'A');\n }\n // Returning a Title cased String.\n return new String(charArray);\n }", "String getLocalizedString(Locale locale);", "private static int searchStandardDictionary(String word) {\n if (word.length() < 4) {\n return Arrays.binarySearch(STANDARD_DICTIONARY, 0, FOUR_LETTER_WORDS_OFFSET, word.toUpperCase(Locale.ENGLISH));\n } else {\n return Arrays.binarySearch(STANDARD_DICTIONARY, FOUR_LETTER_WORDS_OFFSET, STANDARD_DICTIONARY.length, word.toUpperCase(Locale.ENGLISH));\n }\n }", "java.lang.String getLanguage();", "java.lang.String getLanguage();", "public static String acronym(String phrase) {\n\t\tString[] arrPhrase = phrase.split(\" \", 0);\n\t\treturn arrPhrase[2];\n\t}", "private Spannable applyWordMarkup(String text) {\n SpannableStringBuilder ssb = new SpannableStringBuilder();\n int languageCodeStart = 0;\n int untranslatedStart = 0;\n\n int textLength = text.length();\n for (int i = 0; i < textLength; i++) {\n char c = text.charAt(i);\n if (c == '.') {\n if (++i < textLength) {\n c = text.charAt(i);\n if (c == '.') {\n ssb.append(c);\n } else if (c == 'c') {\n languageCodeStart = ssb.length();\n } else if (c == 'C') {\n ssb.setSpan(new TextAppearanceSpan(BrowseWordsActivity.this,\n R.style.language_code_tag),\n languageCodeStart, ssb.length(), 0);\n languageCodeStart = ssb.length();\n } else if (c == 'u') {\n untranslatedStart = ssb.length();\n } else if (c == 'U') {\n ssb.setSpan(new TextAppearanceSpan(BrowseWordsActivity.this,\n R.style.untranslated_word),\n untranslatedStart, ssb.length(), 0);\n untranslatedStart = ssb.length();\n } else if (c == '0') {\n Resources res = getResources();\n ssb.append(res.getString(R.string.no_translations));\n }\n }\n } else\n ssb.append(c);\n }\n\n return ssb;\n }", "private String capitalize(final String word) {\n return Character.toUpperCase(word.charAt(0)) + word.substring(1);\n }", "public static String createPluralWord(String word){\n\t\t//Keep the type in a variable since it's called a lot\n\t\tint typeWordEnd = determineWordType(word);\n\t\t\n\t\tString pluralWord;\n\t\t\n\t\t//These just make the string with respect to the table given in the problem document.\n\t\t// Relatively simple use of string functions involved.\n\t\tif(typeWordEnd == 1){\n\t\t\tpluralWord = word + \"gh\";\n\t\t} else if(typeWordEnd == 2){\n\t\t\tpluralWord = ((word.substring(0, word.length() - 1)) + \"g\");\n\t\t} else if(typeWordEnd == 3){\n\t\t\tpluralWord = (word + (word.substring(word.length() - 1)) + \"h\");\n\t\t} else {\n\t\t\t//Just in case something strange happens. I don't know why it would, but I guess it might as well be there.\n\t\t\tpluralWord = \"Error: Unexpected word type.\";\n\t\t}\n\t\t\n\t\t//Return the value...\n\t\treturn pluralWord;\n\t}", "@Override\r\n public String speak() {\r\n String word = \"\";\r\n Time.getInstance().time += 1;\r\n if (Time.getInstance().time == 1) {\r\n word = \"One day Neznaika decided to become an artist.\";\r\n }\r\n if (Time.getInstance().time == 101) {\r\n word = \"This story happened once day with Neznaika.\";\r\n }\r\n if (Time.getInstance().time == 201) {\r\n word = \"One day Neznaika wanted to become a musician.\";\r\n }\r\n if (Time.getInstance().time == 401) {\r\n word = \"One day Neznaika wanted to become a poet.\";\r\n }\r\n System.out.println(word);\r\n return word;\r\n }", "public String checkFile(String word) throws IOException {\n BufferedReader reader = new BufferedReader(new FileReader(\"antonyms.txt\"));\n boolean searchNext = true;\n String antonym;\n String line;\n do {\n line = reader.readLine();\n if(line!=null)\n if(line.split(\" - \")[0].equals(word))\n searchNext = false;\n }\n while (line!=null && searchNext);\n antonym = line.split(\" - \")[1];\n reader.close();\n return \"Antonym/s for \" + word + \": \" + antonym;\n }", "static String refineWord(String currentWord) {\n\t\t// makes string builder of word\n\t\tStringBuilder builder = new StringBuilder(currentWord);\n\t\tStringBuilder newWord = new StringBuilder();\n\n\t\t// goes through; if it's not a letter, doesn't add to the new word\n\t\tfor (int i = 0; i < builder.length(); i++) {\n\t\t\tchar currentChar = builder.charAt(i);\n\t\t\tif (Character.isLetter(currentChar)) {\n\t\t\t\tnewWord.append(currentChar);\n\t\t\t}\n\t\t}\n\n\t\t// returns lower case\n\t\treturn newWord.toString().toLowerCase().trim();\n\t}", "public String getTitile(String language) {\n if (language.startsWith(\"e\")) {\n return enTitle;\n } else {\n return localTitle;\n }\n }", "String getLocalization();", "public String acronym(String phrase) {\n /*StringBuilder acronymFeed = new StringBuilder(\"\");\n String wordHolder = \"\";\n int spaceIndex;\n char firstLetter;\n do{\n spaceIndex = phrase.indexOf(\" \");\n wordHolder = phrase.substring(0,spaceIndex);\n acronymFeed.append(wordHolder.charAt(0));\n phrase = phrase.replaceFirst(wordHolder, \"\");\n } while (spaceIndex != -1 && wordHolder != \"\" && phrase != \"\");\n \n \n \n \n \n String acronymResult = acronymFeed.toString().toUpperCase();\n return acronymResult;\n */\n \n char[] letters = phrase.toCharArray();\n String firstLetters = \"\";\n firstLetters += String.valueOf(letters[0]);\n for (int i = 1; i < phrase.length();i++){\n if (letters[i-1] == ' '){\n firstLetters += String.valueOf(letters[i]);\n }\n }\n firstLetters = firstLetters.toUpperCase();\n return firstLetters;\n }", "public static String cap(String w) {\n if (w.toLowerCase().equals(w)){ //if there are no capitals\n return w; // //then just return the word as is\n }\n else{\n // for (int i=0; i<w.length(); i++) {\n \n return w.substring(0,1).toUpperCase() + w.substring(1).toLowerCase(); //if there is a capital then make the first only the first letter capital and the rest lowercase\n }\n }", "private static String firstUpperCase(String word) {\n\t\tif (word == null || word.isEmpty()) {\n\t\t\treturn \"\";\n\t\t}\n\t\treturn word.substring(0, 1).toUpperCase() + word.substring(1);\n\t}", "public static String stemWord(String word) {\n if (word.matches(\".*\\\\s.*\")) throw \n new IllegalArgumentException(\"argument is not a single word: \" + word); \n EnglishStemmer stemmer = new EnglishStemmer();\n stemmer.setCurrent(word);\n stemmer.stem();\n return stemmer.getCurrent();\n // slow way of doing it with jcas\n// List<TokenCanonic> c = getCanonicForms(word, CanonicForm.STEM);\n// return c.get(0).canonic;\n }", "@Test(expected = NotEnglishWordException.class)\r\n\tpublic void testEnglishAdd() throws LanguageSyntaxException {\r\n\t\ttrans.addWord(\"дом\", \"домик\");\r\n\t}", "public static synchronized BitmapFont getFontWithSize(int size, String word){\n \t\n \tString laCode = Locale.getDefault().getLanguage();\n \t\n \tif(word != null){\n \t\tword = getUniqueLetters(word);\n \t}\n \t\n \t\n \t\n \t\n\n\t\tif (laCode.equalsIgnoreCase(\"ja\") && word != null) {\n\t\t\tBitmapFont font = forenTable.get(word);\n\n\t\t\tif (font != null) {\n\t\t\t\treturn font;\n\t\t\t} else {\n\t\t\t\tFreeTypeFontGenerator generator = new FreeTypeFontGenerator(\n\t\t\t\t\t\tGdx.files.internal(\"SupportFiles/fontTest.otf\"));\n\t\t\t\tFreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();\n\t\t\t\tparameter.characters = word;\n\t\t\t\tparameter.size = size;\n\n\t\t\t\tfont = generator.generateFont(parameter);\n\t\t\t\tforenTable.put(word, font);\n\t\t\t\tgenerator.dispose();\n\t\t\t\treturn font;\n\t\t\t}\n\n\t\t} else if (laCode.equalsIgnoreCase(\"zh\") && word != null) {\n\t\t\tBitmapFont font = forenTable.get(word);\n\n\t\t\tif (font != null) {\n\t\t\t\treturn font;\n\t\t\t} else {\n\t\t\t\tFreeTypeFontGenerator generator = new FreeTypeFontGenerator(\n\t\t\t\t\t\tGdx.files.internal(\"SupportFiles/fontTest.otf\"));\n\t\t\t\tFreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();\n\t\t\t\tparameter.characters = word;\n\t\t\t\tparameter.size = size;\n\n\t\t\t\tfont = generator.generateFont(parameter);\n\t\t\t\tforenTable.put(word, font);\n\t\t\t\tgenerator.dispose();\n\t\t\t\treturn font;\n\t\t\t}\n\n\t\t} else if (laCode.equalsIgnoreCase(\"ko\") && word != null) {\n\n\t\t\tBitmapFont font = forenTable.get(word);\n\n\t\t\tif (font != null) {\n\t\t\t\treturn font;\n\t\t\t} else {\n\t\t\t\tFreeTypeFontGenerator generator = new FreeTypeFontGenerator(\n\t\t\t\t\t\tGdx.files\n\t\t\t\t\t\t\t\t.internal(\"SupportFiles/AppleSDGothicNeo-Bold.otf\"));\n\t\t\t\tFreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();\n\t\t\t\tparameter.characters = word;\n\t\t\t\tparameter.size = size;\n\n\t\t\t\tfont = generator.generateFont(parameter);\n\t\t\t\tforenTable.put(word, font);\n\t\t\t\tgenerator.dispose();\n\t\t\t\treturn font;\n\t\t\t}\n\n\t\t} else if (laCode.equalsIgnoreCase(\"ru\") && word != null) {\n\t\t\tBitmapFont font = forenTable.get(word);\n\n\t\t\tif (font != null) {\n\t\t\t\treturn font;\n\t\t\t} else {\n\t\t\t\tFreeTypeFontGenerator generator = new FreeTypeFontGenerator(\n\t\t\t\t\t\tGdx.files.internal(\"SupportFiles/GenevaCY.dfont\"));\n\t\t\t\tFreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();\n\t\t\t\tparameter.characters = word;\n\t\t\t\tparameter.size = size;\n\n\t\t\t\tfont = generator.generateFont(parameter);\n\t\t\t\tforenTable.put(word, font);\n\t\t\t\tgenerator.dispose();\n\t\t\t\treturn font;\n\t\t\t}\n \t\t\n \t}else{\n \t\tBitmapFont bitmapFont = fontTable.get(size);\n if (bitmapFont != null){\n return bitmapFont;\n }else {\n\n FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal(\"SupportFiles/CooperBlack.ttf\"));\n FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();\n parameter.size = size; \n fontTable.put(size, generator.generateFont(parameter));\n generator.dispose();\n }\n\n return fontTable.get(size);\n \t}\n \t\n \t\n \n }", "public static String isNSW(String word)\n\t{\n\t\tif (sw.contains(word))\n\t\t{\n\t\t\treturn \"\";\n\t\t}\n\t\treturn word;\n\t}", "public static String translate_word_to_pig_latin(String word) {\r\n String new_word = word;\r\n int vowel_index = index_of_first_vowel(word);\r\n // Put starting consonant(s), if any, at the end of the word\r\n if(vowel_index > 0){\r\n new_word = word.substring(vowel_index) + word.substring(0, vowel_index);\r\n }\r\n\r\n // Add the ay to the end of all words\r\n new_word = new_word.concat(\"ay\");\r\n return new_word;\r\n }", "public DictionaryData lookup(String word) {\r\n\r\n return dictionaryMap.get(word.toUpperCase());\r\n }", "public String getKeyword(String word) {\n\t\t/** COMPLETE THIS METHOD **/\n\t\t//strip trailing punctuation\n\t\tint n = 1;\n\t\tString output = \"\";\n\t\tword = word.toLowerCase();\n\t\tint j = 0;\n\t\twhile(j<word.length())\n\t\t{\n\t\t\tif(Character.isLetter(word.charAt(j)))\n\t\t\t{\n\t\t\t\t\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t//return null;\n\t\t\t}\n\t\t\tj++;\n\t\t}\n\t\t\n\t\twhile(n<word.length())\n\t\t{\n\t\t\t\n\t\t\tif( word.charAt(word.length()-n) == '.' ||\n\t\t\t\t\tword.charAt(word.length()-n) == ',' ||\n\t\t\t\t\tword.charAt(word.length()-n) == '?' || \n\t\t\t\t\tword.charAt(word.length()-n) == ':' ||\n\t\t\t\t\tword.charAt(word.length()-n) == ';' ||\n\t\t\t\t\tword.charAt(word.length()-n) == '!' )\n\t\t\t{\n\t\t\t\toutput = word.substring(0, word.length()-n);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tn++;\n\t\t}\n\t\tif( !(word.charAt(word.length()-1) == '.' ||\n\t\t\t\tword.charAt(word.length()-1) == ',' ||\n\t\t\t\tword.charAt(word.length()-1) == '?' || \n\t\t\t\tword.charAt(word.length()-1) == ':' ||\n\t\t\t\tword.charAt(word.length()-1) == ';' ||\n\t\t\t\tword.charAt(word.length()-1) == '!' )\n\t\t\t\t)\n\t\t{\n\t\t\toutput = word.substring(0, word.length());\n\t\t}\n\t\t// check if there are only alphanumeric characters\n\t\t\n\t\tArrayList<String> items = new ArrayList<>();\n\t\t\n\t\t\n\t try {\n\t \t\n\t Scanner scanner = new Scanner(new File(\"noisewords.txt\"));\n\t while (scanner.hasNextLine()) {\n\t String line = scanner.nextLine();\n\t items.add(line);\n\t \n\t }\n\t scanner.close();\n\t } catch (FileNotFoundException e) {\n\t e.printStackTrace();\n\t }\n\t int i = 0;\n\t boolean ans = false;\n\t while(i<items.size()) {\n\t\t if(output.equals(items.get(i))) \n\t\t {\n\t\t \tans = true;\n\t\t \tbreak;\n\t\t }\n\t\t else\n\t\t {\n\t\t \t ans = false;\n\t\t }\n\t\t i++;\n\t }\n\t //System.out.println(ans);\n\t if(ans == true)\n\t {\n\t \t return null;\n\t }\n\t /* int a = 0;\n\t\twhile(a<items.size())\n\t\t{\n\t\t\tSystem.out.println(items.get(a));\n\t\t\ta++;\n\t\t}*/\n\t\t// following line is a placeholder to make the program compile\n\t\t// you should modify it as needed when you write your code\n\t\tif(output != null)\n\t\t{\n\t\t\treturn output;\n\t\t}\n\t\t\n\t\treturn null;\n\t}", "public static String translate(Context context, String input) {\n StringBuilder output = new StringBuilder(\"\");\n Locale currentLocale = new Locale(LanguageChange.getUserLocale(context));\n\n if (input != null && !\"\".equals(input)) {\n int j = 1;\n boolean capitalFlag = false;\n\n for (int i = 0; i < input.length(); i = i + j) {\n\n // Case there are at least 3 more symbols\n if (input.substring(i).length() > 2) {\n capitalFlag = Character.isUpperCase(input.charAt(i))\n || Character.isUpperCase(input.charAt(i + 1))\n || Character.isUpperCase(input.charAt(i + 2));\n\n String latinSymbol = \"\" + input.charAt(i)\n + input.charAt(i + 1) + input.charAt(i + 2);\n latinSymbol = latinSymbol.toLowerCase(currentLocale);\n String cyrillicSymbol = translatorMap.get(latinSymbol);\n\n if (cyrillicSymbol == null) {\n capitalFlag = Character.isUpperCase(input.charAt(i))\n || Character.isUpperCase(input.charAt(i + 1));\n\n latinSymbol = \"\" + input.charAt(i)\n + input.charAt(i + 1);\n latinSymbol = latinSymbol.toLowerCase(currentLocale);\n cyrillicSymbol = translatorMap.get(latinSymbol);\n\n if (cyrillicSymbol == null) {\n latinSymbol = \"\" + input.charAt(i);\n cyrillicSymbol = translatorMap.get(latinSymbol);\n\n if (cyrillicSymbol == null) {\n output.append(latinSymbol);\n j = 1;\n } else {\n output.append(cyrillicSymbol);\n j = 1;\n }\n } else {\n if (capitalFlag) {\n output.append(cyrillicSymbol\n .toUpperCase(currentLocale));\n } else {\n output.append(cyrillicSymbol);\n }\n j = 2;\n }\n } else {\n if (capitalFlag) {\n output.append(cyrillicSymbol\n .toUpperCase(currentLocale));\n } else {\n output.append(cyrillicSymbol);\n }\n j = 3;\n }\n // Case there are 2 more symbols\n } else if (input.substring(i).length() == 2) {\n capitalFlag = Character.isUpperCase(input.charAt(i))\n || Character.isUpperCase(input.charAt(i + 1));\n\n String latinSymbol = \"\" + input.charAt(i)\n + input.charAt(i + 1);\n latinSymbol = latinSymbol.toLowerCase(currentLocale);\n String cyrillicSymbol = translatorMap.get(latinSymbol);\n\n if (cyrillicSymbol == null) {\n latinSymbol = \"\" + input.charAt(i);\n cyrillicSymbol = translatorMap.get(latinSymbol);\n\n if (cyrillicSymbol == null) {\n output.append(latinSymbol);\n j = 1;\n } else {\n output.append(cyrillicSymbol);\n j = 1;\n }\n } else {\n if (capitalFlag) {\n output.append(cyrillicSymbol\n .toUpperCase(currentLocale));\n } else {\n output.append(cyrillicSymbol);\n }\n j = 2;\n }\n // Case there is 1 more symbol\n } else if (input.substring(i).length() == 1) {\n String latinSymbol = \"\" + input.charAt(i);\n String cyrillicSymbol = translatorMap.get(latinSymbol);\n\n if (cyrillicSymbol == null) {\n output.append(latinSymbol);\n j = 1;\n } else {\n output.append(cyrillicSymbol);\n j = 1;\n }\n }\n }\n }\n\n return output.toString();\n }", "@Test\n public void shouldTranslateWithRegionalVariant() {\n List<String> sentence = Arrays.asList(\"it\", \"is\", \"cold\");\n String result = \"\";\n for (String token : sentence) {\n result += manager.message(Locale.CANADA_FRENCH, token, token) + \" \";\n }\n assertEquals(\"Il fait frette \", result);\n }", "public static Boolean Word(String arg){\n\t\tif(arg.matches(\"^[a-zA-ZåÅäÄöÖüÜéÉèÈ]*\")){\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\t\n\t}", "public static CommandType getWord(String word){\r\n\t\treturn dictionary.get(word);\r\n\t}", "public static String getWordFromKey(String senseKey)\n\t{\n\t\tint lastUS = senseKey.lastIndexOf(\"_\");\n\t\treturn senseKey.substring(0, lastUS - 3);\n\t}", "public String Stem( String word )\n {\n // check if we already know the word\n String stemmedword = AllWords.get(word);\n if ( stemmedword != null )\n return stemmedword; // return it if we already know it\n\n // don't check words with digits in them\n // if ( containsNumbers (word) == true )\n // stemmedword = null;\n // else\t// unknown word: try to stem it\n stemmedword = StemWordWithWordNet (word);\n\n if ( stemmedword != null )\n {\n // word was recognized and stemmed with wordnet:\n // add it to hashmap and return the stemmed word\n AllWords.put( word, stemmedword );\n return stemmedword;\n }\n // word could not be stemmed by wordnet,\n // thus it is no correct english word\n // just add it to the list of known words so\n // we won't have to look it up again\n AllWords.put( word, word );\n return word;\n }", "private void listen_meaning_word() {\n\t\tif(this.dwd!=null)\n\t\t{\n\t\t\tString meaning_word=\"\";\n\t\t\tif(isHindi)\n\t\t\t{\n\t\t\t\tmeaning_word=dwd.eng_word;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tmeaning_word=dwd.hin_word;\n\t\t\t}\n\t\t\tif(isHindi)\n\t\t\t{\n\t\t\t\tif(this.main_word!=\"\")\n\t\t\t\t{\n\t\t\t\t\tif(mCallBack==null)\n\t\t\t\t\t{\n\t\t\t\t\t\tmCallBack=(OnWordSelectedFromSearchSuccess) getActivity();\n\t\t\t\t\t}\n\t\t\t\t\tmCallBack.onWordSpeak(meaning_word);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tDictCommon.listen_in_hindi(meaning_word);\n\t\t\t}\n\t\t}\n\t}", "private LexiNode search_specific_word(String word, int index){\n\t\tif(current_word != null && !current_word.isEmpty()){\n\t\tint local_index = index + 1;\n\t\t//if we found the word, we make the change\n\t\tif(current_word != null && \n\t\t !current_word.isEmpty() && \n\t\t\tword.toLowerCase().equals(current_word.toLowerCase()))\n\t\t\treturn this;\n\t\t//We try to find the word within our childs\n\t\tfor(LexiNode child: childs)\n\t\t\tif(word.toLowerCase().charAt(local_index) == Character.toLowerCase(child.getRepresentative_letter()))\n\t\t\t\treturn child.search_specific_word(word, local_index);\n\t\t}\n\t\treturn null;\n\t}", "public static void main(String[] args) {\n Scanner input = new Scanner(System.in);\n String word = \"Tenet\";\n String word3 = \"tenet\";\n System.out.println(\"word \" + word);\n word.toLowerCase(); //porównanie bez wielkosci znakow\n //charAt(0) - zero,\n String[] Tablica = new String[word.length()];\n for (int i = 0; i < word.length(); i++) {\n Tablica[i] = String.valueOf(word.charAt(i));\n }\n String word2 = \"\";\n\n for (int i = (word.length() - 1); i >= 0; i--) {\n //System.out.print(Tablica[i]);\n word2 = word2 + Tablica[i];\n }\n //System.out.println();\n System.out.println(\"word 2 \" + word2);\n System.out.println(\"word 3 \" + word3);\n\n System.out.print(\"word 3 i word 2 \");\n if (word3.toLowerCase().equals(word2.toLowerCase())) {\n System.out.println(\"jest palidronem\");\n } else {\n System.out.println(\"nie jest palidronem\");\n }\n\n//koniec\n\n }", "public abstract String guessedWord();", "public String talkNiceWords() {\n\t\treturn \"How are you\";\n\t}", "public static String localeToTwineLanguage(Locale locale)\n {\n if (locale == null)\n {\n Log.e(TAG, \"localeToTwineLanguage was called with null Locale.\");\n return \"\";\n }\n\n final String chinese = Locale.CHINESE.getLanguage();\n final String language = locale.getLanguage();\n final String country = locale.getCountry();\n\n if (chinese == null || language == null || country == null)\n {\n Log.e(TAG, \"Methods Locale.getLanguage or Locale.getCountry return null.\");\n return \"\";\n }\n\n if (chinese.equals(language))\n {\n if (country.equals(\"TW\") || country.equals(\"MO\") || country.equals(\"HK\"))\n {\n return \"zh-Hant\"; // Chinese traditional\n }\n return \"zh-Hans\"; // Chinese simplified\n }\n if (TextUtils.isEmpty(language))\n {\n Log.e(TAG, \"locale.getLanguage() returns null or empty string.\");\n return \"\";\n }\n return language;\n }", "String getLanguage();", "String getLanguage();", "String getLanguage();", "String stemOf (String word);", "public String getWord (int wordIndex) {\n if (wordIndex < 0 ) {\n return \"\";\n } else {\n int s = getWordStart (wordIndex);\n int e = indexOfNextSeparator (tags, s, true, true, slashToSeparate);\n if (e > s) {\n return tags.substring (s, e);\n } else {\n return \"\";\n }\n }\n }", "public boolean wordExists(String word)\n\t{\n\t\t//checks to make sure the word is a word that starts with a lowercase letter, otherwise return false\n\t\tif(word.charAt(0) >= 'a' && word.charAt(0) <= 'z')\n\t\t{\n\t\t\tchar letter = word.charAt(0);\n\t\t\t\n\t\t\treturn (myDictionaryArray[(int)letter - (int)'a'].wordExists(word));\n\t\t}\n\t\t\n\t\treturn false;\t\t\n\t}", "private String searchString(String inWord)\n {\n String line = null;\n StringBuffer rtn = new StringBuffer();\n int len = inWord.length();\n boolean found = false;\n\n if(len == 1)\n {\n if(Character.isDigit(inWord.charAt(0)))\n {\n rtn.append(inWord).append(\"I\");\n found = true;\n } // fi\n\n else if(Character.isLetter(inWord.charAt(0)))\n {\n rtn.append(inWord.toLowerCase()).append(\"S\");\n found = true;\n } // else fi\n } // fi\n\n if(!found)\n {\n int\tnum_A = 0; // Upper case\n int\tnum_L = 0; // Lower case\n int\tnum_N = 0; // Numbers\n int\tnum_P = 0; // Punctuation (numeric)\n int\tnum_Q = 0; // Quotes\n int\tnum_O = 0; // Other\n char last_ch = ' ';\n\n for(int i = 0; i < len; i++)\n {\n if((i == 0) && (inWord.charAt(i) == '-'))\n num_L++;\n\n else if(Character.isLowerCase(inWord.charAt(i)))\n num_L++;\n\n else if(Character.isUpperCase(inWord.charAt(i)))\n num_A++;\n\n else if(Character.isDigit(inWord.charAt(i)))\n num_N++;\n\n else if((inWord.charAt(i) == '=')||(inWord.charAt(i) == ':') ||\n (inWord.charAt(i) == '+')||(inWord.charAt(i) == '.') ||\n (inWord.charAt(i) == ','))\n num_P++;\n\n else if((inWord.charAt(i) == '\\'') ||\n (inWord.charAt(i) == '`') || (inWord.charAt(i) == '\"'))\n num_Q++;\n\n else\n num_O++;\n\n last_ch = inWord.charAt(i);\n } // for\n\n int pos = 0;\n if((len - ntail) > 0)\n pos = len - ntail;\n\n rtn.append(inWord.substring(pos).toLowerCase());\n\n if((num_L + num_Q) == len)\n rtn.append(\"\");\n\n else if((num_A + num_Q) == len)\n rtn.append(\"A\");\n\n else if((num_N + num_P + num_Q) == len)\n rtn.append(\"N\");\n\n else if((num_L + num_A + num_Q) == len)\n rtn.append(\"B\");\n\n else if((num_A + num_N + num_P + num_Q) == len)\n rtn.append(\"C\");\n\n else if((num_L + num_N + num_P + num_Q) == len)\n rtn.append(\"E\");\n\n else if((num_A + num_L + num_N + num_P + num_Q) == len)\n rtn.append(\"D\");\n\n else if((num_O == 0) && (last_ch == '+'))\n rtn.append(\"F\");\n\n else\n rtn.append(\"O\");\n } // else\n\n rtn.append(\"_\");\n\n return(rtn.toString());\n }", "public static boolean searchWordInTemplateString(TemplateString tStr, String word) {\n\t\tString text = tStr.string;\r\n\t\tint currentIndex = 0;\r\n\t\tfor(int j = 0; j < text.length() && currentIndex < word.length(); j++) {\r\n\t\t\tchar c = text.charAt(j);\r\n\t\t\t// Check uppercase\r\n\t\t\tif(c >= 'A' && c <= 'Z') c = (char) (c + 'a' - 'A');\r\n\t\t\t// Check if equal to current word char\r\n\t\t\tif(c == word.charAt(currentIndex)) {\r\n\t\t\t\t// If last index then the word exists in template\r\n\t\t\t\tif(currentIndex == word.length() - 1) return true;\r\n\t\t\t\t// Otherwise add one to index\r\n\t\t\t\tcurrentIndex++;\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\tif(currentIndex > 0 && ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9'))) {\r\n\t\t\t\t// If the char was alphanumerical but unequal, the word train was broken..\r\n\t\t\t\tcurrentIndex = 0;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn false;\r\n\t}", "public abstract WordEntry autoTranslate(String text, String to);", "private String stemmingForAWord(String identifiedWord) {\n String word;\n if (identifiedWord.contains(\"_\")) {\n word = identifiedWord;\n } else {\n word = morphology.stem(identifiedWord);\n }\n return word;\n }", "private String fixWordStarts(final String line) {\n final String[] parts = line.split(\" \");\n\n final StringBuilder lineBuilder = new StringBuilder();\n\n for (int i = 0; i < parts.length; i++) {\n String part = parts[i];\n\n // I prefer a space between a - and the word, when the word starts with a dash\n if (part.matches(\"-[0-9a-zA-Z']+\")) {\n final String word = part.substring(1);\n part = \"- \" + word;\n }\n\n // yes this can be done in 1 if, no I'm not doing it\n if (startsWithAny(part, \"lb\", \"lc\", \"ld\", \"lf\", \"lg\", \"lh\", \"lj\", \"lk\", \"ll\", \"lm\", \"ln\", \"lp\", \"lq\", \"lr\",\n \"ls\", \"lt\", \"lv\", \"lw\", \"lx\", \"lz\")) {\n // some words are incorrectly fixed (llama for instance, and some Spanish stuff)\n if (startsWithAny(part, \"ll\") && isOnIgnoreList(part)) {\n lineBuilder.append(part);\n } else {\n // I starting a word\n part = part.replaceFirst(\"l\", \"I\");\n lineBuilder.append(part);\n }\n } else if (\"l.\".equals(part)) {\n // I at the end of a sentence.\n lineBuilder.append(\"I.\");\n } else if (\"l,\".equals(part)) {\n // I, just before a comma\n lineBuilder.append(\"I,\");\n } else if (\"l?\".equals(part)) {\n // I? Wut? Me? Moi?\n lineBuilder.append(\"I?\");\n } else if (\"l!\".equals(part)) {\n // I! 't-was me!\n lineBuilder.append(\"I!\");\n } else if (\"l..\".equals(part)) {\n // I.. think?\n lineBuilder.append(\"I..\");\n } else if (\"l...\".equals(part)) {\n // I... like dots.\n lineBuilder.append(\"I...\");\n } else if (\"i\".equals(part)) {\n // i suck at spelling.\n lineBuilder.append(\"I\");\n } else if (part.startsWith(\"i'\")) {\n // i also suck at spelling.\n part = part.replaceFirst(\"i\", \"I\");\n lineBuilder.append(part);\n } else {\n // nothing special to do\n lineBuilder.append(part);\n }\n\n // add trailing space if it is not the last part\n if (i != parts.length - 1) {\n lineBuilder.append(\" \");\n }\n }\n\n return lineBuilder.toString();\n }", "protected boolean isLanguage( String word )\r\n\t{\r\n\t\treturn m_listLanguage.contains(word);\r\n\t}", "ILoLoString translate();", "static String question(String sentence) {\r\n\t\tString result = null;\r\n\t\tif (sentence.contains(\"can you tell me\")) {\r\n\t\t\tint index = sentence.indexOf(\"can you tell me\");\r\n\t\t\tString search = sentence.substring(index + 15);\r\n\t\t\tresult = googleFind(search);\r\n\t\t} else if (sentence.contains(\"do you know\")) {\r\n\t\t\tint index = sentence.indexOf(\"do you know\");\r\n\t\t\tString search = sentence.substring(index + \"do you know\".length());\r\n\t\t\tresult = googleFind(search);\r\n\t\t}\r\n\t\treturn result;\r\n\t}", "public static String removeNonWord(String message)\r\n {\r\n int start = getLetterIndex(message, head); //get the fist index that contain English letter\r\n int end = getLetterIndex(message, tail); //get the last index that contain English letter\r\n if (start == end) // if only contain one letter\r\n return String.valueOf(message.charAt(start)); // return the letter\r\n return message.substring(start, end + 1); // return the content that contain English letter\r\n }", "private void save_meaning_word() {\n\t\tif(this.dwd!=null && this.main_word!=null)\n\t\t{\n\n\n\t\t\tString meaning_word=\"\";\n\t\t\tif(isHindi)\n\t\t\t{\n\t\t\t\tmeaning_word=dwd.eng_word;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tmeaning_word=dwd.hin_word;\n\t\t\t}\n\n\t\t\tDictCommon.SaveWord(meaning_word,!isHindi);\n\t\t\tToast.makeText(view.getContext(), \"word \"+meaning_word+\" successfully saved!!!\", Toast.LENGTH_LONG).show();\n\t\t}\n\t}", "public Boolean lookupAWord(String target) {\n ArrayList<Word> fullDictionary = dictionaryManagement.getDictionary().getWords();\n int result = dictionaryManagement.lookupWord(target);\n if (result == -1) {\n System.out.println(\"This word is dose not exsit!\");\n return false;\n } else {\n System.out.println(\"Result: \");\n System.out.println(\"\\tTarget: \" + target);\n System.out.println(\"\\tExplain: \" + fullDictionary.get(result).getWordExplain());\n return true;\n }\n }", "private String getConvertedWord(String word) {\r\n\t\tString newWord = \"\";\r\n\t\tif(word == null || word.length() == 0)\r\n\t\t\tnewWord = \"\";\r\n\t\telse if(word.length() < 3)\r\n\t\t\tnewWord = word;\r\n\t\telse \r\n\t\t\tnewWord = \"\"+word.charAt(0) + (word.length() - 2) + word.charAt(word.length() - 1);\r\n\t\t\t\r\n\t\tif(DEBUG)\r\n\t\t\tSystem.out.printf(\"Converted %s to %s\\n\", word, newWord);\r\n\t\treturn newWord;\r\n\r\n\t}", "private String pickWord() {\n \thangmanWords = new HangmanLexicon();\n \tint randomWord = rgen.nextInt(0, (hangmanWords.getWordCount() - 1)); \n \tString pickedWord = hangmanWords.getWord(randomWord);\n \treturn pickedWord;\n }", "public String getWord() {\n if(words[index] != null) {\n return words[index];\n } else {\n return \"\";\n }\n }", "public String search_words(String word){\n\t\tString found_words = \"\";\n\t\t//We try to find the word within our childs\n\t\tfor(LexiNode child: childs)\n\t\t\tif(word.toLowerCase().charAt(0) == Character.toLowerCase(child.getRepresentative_letter()))\n\t\t\t\tfound_words += child.search_words(word, 0);\n\t\t\n\t\treturn found_words;\n\t}", "public String propergram(String word){\n // word.toLowerCase();\n String[] tempstr =word.split(\"_\");\n String tempstr2;\n\n for(int i=0;i<tempstr.length;i++){\n if((tempstr[i].charAt(0))>='A'&&(tempstr[i].charAt(0))<='Z') {\n tempstr2 = (String.valueOf(tempstr[i].charAt(0)));\n }\n else {\n tempstr2 = (String.valueOf(tempstr[i].charAt(0))).toUpperCase();\n }\n tempstr[i] = tempstr2.concat(tempstr[i].substring(1));\n if (i != 0) {\n word=word.concat(\" \").concat(tempstr[i]);\n } else {\n word = tempstr[i];\n }\n\n }\n return word;\n\n\n }", "public static String pluralize(String word)\n {\n if (Inflection.isUncountable(word))\n {\n return word;\n }\n else\n {\n for (Inflection inflection : plural)\n {\n // System.out.println(word + \" matches \" + inflection.pattern + \"? (ignore case: \" + inflection.ignoreCase + \")\");\n if (inflection.match(word))\n {\n // System.out.println(\"match!\");\n return inflection.replace(word);\n }\n }\n return word;\n }\n }", "public String getLexEntry(String word)\n {\n boolean found = false;\n String buff = \"\";\n String rtn = \"\";\n\n lastCount = 0.0;\n if(word.length() > 0)\n {\n buff = compactNumbers(word);\n rtn = searchLexDb(buff, true);\n if(rtn.length() > 0)\n found = true;\n\n else // try the lowercase version\n {\n buff = buff.toLowerCase();\n rtn = searchLexDb(buff, true);\n if(rtn.length() > 0)\n found = true;\n } // else\n } // fi\n\n // If not found, get the search string corresponding to the word.\n\n if(!found)\n {\n buff = searchString(word);\n\n while(!found && (buff.length() > 0))\n {\n rtn = searchLexDb(buff, false);\n if(rtn.length() > 0)\n found = true;\n else\n buff = buff.substring(1);\n } // while\n } // fi\n\n if(!found)\n System.out.println(\"word: #\" + word + \"# lex entry not found\");\n\n return(rtn.toString());\n }", "public static String translate(String word) {\n\t\t// Method variables.\n\t\tint vowelIndex = 0;\n\t\tint wordLength = word.length();\n\t\tString pigLatin = \"\";\n\n\t\t// Loop through the word marking at what point the first vowel is.\n\t\tfor (int i = 0; i < wordLength; i++) {\n\t\t\t// Gets the char at i and sets it to lower case for comparing to vowels.\n\t\t\tchar letter = Character.toLowerCase(word.charAt(i));\n\n\t\t\t// If a letter of a word equals a vowel break loop\n\t\t\tif (letter == 'a' || letter == 'e' || letter == 'i' || letter == 'o' || letter == 'u') {\n\t\t\t\tvowelIndex = i; // Set the value of firstVowel the index of the character in the word.\n\t\t\t\tbreak; // Exit loops\n\t\t\t}\n\n\t\t}\n\n\t\t// Rearrange word into Pig Latin.\n\t\t// First test if it starts with a vowel\n\t\tif (vowelIndex == 0) {\n\t\t\tpigLatin = word + \"way\"; // Put way on end of any word starting with a vowel.\n\t\t} else {\n\t\t\t// Create substring of characters to add to the end of the word.\n\t\t\tString toEnd = word.substring(0, vowelIndex);\n\t\t\t\n\t\t\t// Create a substring of the new start of the word.\n\t\t\tString newStart = word.substring(vowelIndex, wordLength);\n\n\t\t\t// Combine both substrings together and add ay.\n\t\t\tpigLatin = newStart + toEnd + \"ay\";\n\t\t}\n\n\t\treturn pigLatin.toUpperCase(); // returns the word translated into Pig Latin\n\t}" ]
[ "0.73529524", "0.6612347", "0.6469052", "0.63299173", "0.6302331", "0.6287474", "0.62821096", "0.6122809", "0.59474576", "0.5917636", "0.5886497", "0.5862471", "0.58013827", "0.58003473", "0.57514614", "0.5743975", "0.5720528", "0.5676441", "0.56760013", "0.56745917", "0.5674016", "0.56569034", "0.56512153", "0.56309485", "0.56229717", "0.5619468", "0.5617799", "0.5604465", "0.55836713", "0.5580224", "0.5564648", "0.556079", "0.5559437", "0.555932", "0.55467457", "0.55435455", "0.5540324", "0.5533995", "0.5531283", "0.5528923", "0.5499905", "0.5491108", "0.548635", "0.548635", "0.5486242", "0.5482057", "0.5466201", "0.5455653", "0.5440988", "0.54338294", "0.54239583", "0.54221046", "0.54087955", "0.54039687", "0.53996414", "0.5394383", "0.53716063", "0.5367663", "0.5357982", "0.5355569", "0.53444666", "0.5342887", "0.5342764", "0.5332374", "0.53184265", "0.5310781", "0.5306334", "0.5305402", "0.53050506", "0.5303147", "0.5301875", "0.5294387", "0.5286762", "0.5285123", "0.528011", "0.527439", "0.527439", "0.527439", "0.5267006", "0.5263224", "0.5259768", "0.5255154", "0.5252472", "0.52508545", "0.52417195", "0.52369875", "0.5236323", "0.5233669", "0.522772", "0.5218301", "0.5195133", "0.51861465", "0.5184342", "0.5174939", "0.5168448", "0.51663744", "0.51662165", "0.51618016", "0.5155423", "0.5150268" ]
0.7285939
1
returns English word if exists, otherwise returns Thai word passed in
public String getEngWordFromThaiWord(String thaiWord) { Cursor cursor = mDatabase.query( TABLE_NAME, new String[]{COL_ENG_WORD}, COL_THAI_WORD + "=?", new String[]{thaiWord}, null, null, null ); if (cursor.getCount() > 0) { cursor.moveToFirst(); return cursor.getString(cursor.getColumnIndex(COL_ENG_WORD)); } else { return thaiWord; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public String getThaiWordFromEngWord(String englishWord) {\n Cursor cursor = mDatabase.query(\n TABLE_NAME,\n new String[]{COL_THAI_WORD},\n COL_ENG_WORD + \"=?\",\n new String[]{englishWord},\n null,\n null,\n null\n );\n if (cursor.getCount() > 0) {\n cursor.moveToFirst();\n return cursor.getString(cursor.getColumnIndex(COL_THAI_WORD));\n } else {\n return englishWord;\n }\n }", "public String getEnglish()\n {\n if (spanishWord.substring(0,3).equals(\"el \"))\n {\n spanishWord = spanishWord.substring(3, spanishWord.length());\n }\n else if (spanishWord.substring(0, 3).equals(\"la \"))\n {\n spanishWord = spanishWord.substring(3, spanishWord.length());\n }\n if (spanishWord.equals(\"estudiante\"))\n {\n return \"student\"; \n }\n else if (spanishWord.equals(\"aprender\"))\n {\n return \"to learn\";\n }\n else if (spanishWord.equals(\"entender\"))\n {\n return\"to understand\";\n }\n else if (spanishWord.equals(\"verde\"))\n {\n return \"green\";\n }\n else\n {\n return null;\n }\n }", "java.lang.String getWord();", "static boolean isEnglishWord(String str) {\r\n return localDictionary.contains(str);\r\n }", "public String spellcheck(String word) {\n // Check if the world is already in lcDictionary.\n String lcdictionaryLookup = lcDictionary.get(word.toLowerCase());\n if(lcdictionaryLookup != null) {\n return lcdictionaryLookup;\n }\n String reducedWord = reducedWord(word);\n String rwdictionaryLookup = rwDictionary.get(reducedWord);\n if(rwdictionaryLookup != null) {\n return rwdictionaryLookup;\n }\n return \"NO SUGGESTION\";\n }", "private String getPhrase(String key) {\r\n if (\"pl\".equals(System.getProperty(\"user.language\")) && phrasesPL.containsKey(key)) {\r\n return phrasesPL.get(key);\r\n } else if (phrasesEN.containsKey(key)) {\r\n return phrasesEN.get(key);\r\n }\r\n return \"Translation not found!\";\r\n }", "public static String translateWord(String word) {\n\n if (word.length() < 1) return word;\n int[] vowelArray = word.chars().filter(c -> vowels.contains((char) c)).toArray();\n if (vowelArray.length == 0) return word.charAt(0) + word.substring(1).toLowerCase() + \"ay\";\n\n char first = Character.isUpperCase(word.charAt(0))\n ? Character.toUpperCase((char) vowelArray[0]) : (char) vowelArray[0];\n if (vowels.contains(word.charAt(0)))\n word = first + word.substring(1).toLowerCase() + \"yay\";\n else\n word = first + word.substring(word.indexOf(vowelArray[0]) + 1).toLowerCase()\n + word.substring(0, word.indexOf(vowelArray[0])).toLowerCase() + \"ay\";\n return word;\n }", "private static String convertToLatin(String word)\n {\n return word.substring(1) + word.substring(0,1) + \"ay\";\n }", "public String getKeyword(String word) {\n\t\tboolean foundPunct = false;\n String returnStr = \"\";\n for(int inc = 0; inc < word.length(); inc++) {\n char testChar = word.charAt(inc);\n if(Character.isLetter(testChar) == true) {\n if(foundPunct == true) {return null;}\n else{returnStr = returnStr + Character.toString(testChar).toLowerCase();}}\n else {foundPunct = true;}}\n if(noiseWords.contains(returnStr) == true) {\n return null;}\n if(returnStr == \"\") {\n return null;}\n return returnStr;\n\t}", "public String spanishWord() {\n\t\treturn \"Depurar\";\n\t}", "public String getCorrectionWord(String misspell);", "public WordInfo searchWord(String word) {\n\t\tSystem.out.println(\"Dic:SearchWord: \"+word);\n\n\t\tDocument doc;\n\t\ttry {\n\t\t\tdoc = Jsoup.connect(\"https://dictionary.cambridge.org/dictionary/english-vietnamese/\" + word).get();\n\t\t} catch(Exception e) {\n\t\t\te.printStackTrace();\n\t\t\treturn null;\n\t\t}\n\n\t\tElements elements = doc.select(\".dpos-h.di-head.normal-entry\");\n\t\tif (elements.isEmpty()) {\n\t\t\tSystem.out.println(\" not found\");\n\t\t\treturn null;\n\t\t}\n\n\t\tWordInfo wordInfo = new WordInfo(word);\n\n\t\t// Word\n\t\telements = doc.select(\".tw-bw.dhw.dpos-h_hw.di-title\");\n\n\t\tif (elements.size() == 0) {\n\t\t\tSystem.out.println(\" word not found in doc!\");\n\t\t\treturn null;\n\t\t}\n\n\t\twordInfo.setWordDictionary(elements.get(0).html());\n\n\t\t// Type\n\t\telements = doc.select(\".pos.dpos\");\n\n\t\tif(elements.size() > 0) {\n\t\t\twordInfo.setType(WordInfo.getTypeShort(elements.get(0).html()));\n//\t\t\tif (wordInfo.getTypeShort().equals(\"\"))\n//\t\t\t\tSystem.out.println(\" typemis: \"+wordInfo.getType());\n\t\t}\n\n\t\t// Pronoun\n\t\telements = doc.select(\".ipa.dipa\");\n\n\t\tif (elements.size() > 0)\n\t\t\twordInfo.setAPI(\"/\"+elements.get(0).html()+\"/\");\n\n\t\t// Trans\n\t\telements = doc.select(\".trans.dtrans\");\n\n\t\tif (elements.size() > 0)\n\t\t\twordInfo.setTrans(elements.get(0).html());\n\n\t\tSystem.out.println(\" found\");\n\t\treturn wordInfo;\n\t}", "@SneakyThrows\n public String get(String word) {\n String url = \"https://clients5.google.com/translate_a/t?client=dict-chrome-ex&sl=auto&tl=he&q=\"+word;\n this.response = getResponse(url);\n if(response.getSentences().size()>0) {\n return response.getSentences().get(0).getTrans();\n }\n return \"\";\n }", "private Word askForWord(Language lastLanguage) throws LanguageException {\n Language language = askForLanguage();\r\n if(language == null || language.equals(lastLanguage)) {\r\n throw new LanguageException();\r\n }\r\n // Step 2 : Name of the word\r\n String name = askForLine(\"Name of the word : \");\r\n Word searchedWord = czech.searchWord(language, name);\r\n if(searchedWord != null) {\r\n System.out.println(\"Word \" + name + \" found !\");\r\n return searchedWord;\r\n }\r\n System.out.println(\"Word \" + name + \" not found.\");\r\n // Step 3 : Gender/Phonetic of the word\r\n String gender = askForLine(\"\\tGender of the word : \");\r\n String phonetic = askForLine(\"\\tPhonetic of the word : \");\r\n // Last step : Creation of the word\r\n Word word = new Word(language, name, gender, phonetic);\r\n int id = czech.getListWords(language).get(-1).getId() + 1;\r\n word.setId(id);\r\n czech.getListWords(language).put(-1, word);\r\n return word;\r\n }", "boolean isWord(String potentialWord);", "boolean hasWord();", "String getWordIn(String schar, String echar);", "String getLang();", "java.lang.String getLanguage();", "java.lang.String getLanguage();", "public String getKeyWord(String word) {\n // COMPLETE THIS METHOD\n word = word.toLowerCase();\n while (word.length() > 0 && !(Character.isDigit(word.charAt(word.length() - 1))) && !(Character.isLetter(word.charAt(word.length() - 1)))) {\n char ch = word.charAt(word.length()-1);\n //if((isPunctuation(ch))){\n if (word.endsWith(\"!\") ||\n word.endsWith(\";\") ||\n word.endsWith(\":\") ||\n word.endsWith(\"?\") ||\n word.endsWith(\",\") ||\n word.endsWith(\".\")) {\n word = word.substring(0, word.length() - 1);\n } else {\n return null;\n }\n }\n\n for (int i = 0; i < word.length(); i++) {\n if (!(Character.isLetter(word.charAt(i)))) {\n return null;\n }\n }\n\n if (noiseWords.containsKey(word))\n return null;\n return word;\n\n }", "public String wordAdmitted(String word) {\n if(!this._keyWords.contains(word)) {\n Etat currentState = this._start;\n String[] characters = word.split(\"\");\n\n for(String s : characters) {\n Etat next = currentState.isAdmitted(s);\n //If no transition exist with this character\n if(Objects.isNull(next)) return \"missingTransition\";\n else {\n currentState = next;\n }\n }\n //If last state is final\n if(currentState.isFinal()) return \"final\";\n //If last state isn't final\n else return \"notFinal\";\n } else {\n //Word is in keyWords\n return \"keyWord\";\n }\n }", "public static String getWord(String sentence, char word) {\n\t\tString[] words;\n\t\twords = sentence.split(\" \");\n\t\tString cleanedWord=\"\";\n\t\t\n\t\tif(word=='f') {//return the first word\n\t\t\tString temp = words[0];\n\t\t\t\n\t\t\tfor(int i=0; i < temp.length(); i++) {\n\t\t\t\tif(Character.isLetter(temp.charAt(i))) {\n\t\t\t\t\tcleanedWord+= Character.toString(temp.charAt(i));\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}else {//return the last word\n\t\t\tString temp = words[words.length -1];\n\t\t\t\n\t\t\tfor(int i=0; i < temp.length(); i++) {\n\t\t\t\tif(Character.isLetter(temp.charAt(i))) {\n\t\t\t\t\tcleanedWord+= Character.toString(temp.charAt(i));\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\treturn cleanedWord;\n\t}", "public String translateFi(String s) {\n if (s == \"always\") {\n return \"aina\";\n } else if (s == \"often\") {\n return \"usein\";\n } else if (s == \"sometimes\") {\n return \"joskus\";\n } else if (s == \"never\") {\n return \"en koskaan\";\n } else if (s == \"low\") {\n return \"vähän\";\n } else if (s == \"high\") {\n return \"paljon\";\n } else if (s == \"normal\") {\n return \"jonkin verran\";\n }\n return \"\";\n }", "public String getWord(int index) {\n\t\t\n\t\tswitch (index) {\n\t\t\tcase 0:\n\t\t\t\treturn \"BUOY\";\n\t\t\tcase 1:\n\t\t\t\treturn \"COMPUTER\";\n\t\t\tcase 2:\n\t\t\t\treturn \"CONNOISSEUR\";\n\t\t\tcase 3:\n\t\t\t\treturn \"DEHYDRATE\";\n\t\t\tcase 4:\n\t\t\t\treturn \"FUZZY\";\n\t\t\tcase 5:\n\t\t\t\treturn \"HUBBUB\";\n\t\t\tcase 6:\n\t\t\t\treturn \"KEYHOLE\";\n\t\t\tcase 7:\n\t\t\t\treturn \"QUAGMIRE\";\n\t\t\tcase 8:\n\t\t\t\treturn \"SLITHER\";\n\t\t\tcase 9:\n\t\t\t\treturn \"ZIRCON\";\n\t\t\tdefault:\n\t\t\t\treturn new String(\"Illegal index\");\n\t\t}\n\t}", "private String search_words(String word, int index){\n\t\tString found_words = \"\";\n\t\tint local_index = index +1;\n\t\t//We try to find the word within our childs\n\t\tfor(LexiNode child: childs){\n\t\t\tif(local_index > word.length()-1 || word.toLowerCase().charAt(local_index) == Character.toLowerCase(child.getRepresentative_letter()))\n\t\t\t\tfound_words += child.search_words(word, local_index);\n\t\t}\n\t\tif(current_word != null && word.length() > current_word.length())\n\t\t\treturn found_words;\n\t\tif(current_word != null && !found_words.equals(\"\"))\n\t\t\treturn current_word.toLowerCase().equals(word.toLowerCase()) ? current_word +\" & \" + definition + \"#\" + found_words +\"#\" : current_word + \"#\" + found_words;\n\t\telse if(current_word != null && found_words.equals(\"\"))\n\t\t\treturn current_word.toLowerCase().equals(word.toLowerCase()) ? current_word +\" & \" + definition + \"#\": current_word+ \"#\";\n\t\telse //current_word == null && found_words != null\n\t\t\treturn found_words;\n\t}", "private boolean isWord(String word) {\n\t\treturn dict.isWord(word);\n\t}", "public static String getWord(){\n\t\t\n\t\tSystem.out.println(\"--------- Welcome to Hangman ---------\");\n\t\tScanner input = new Scanner(System.in);\n\t\tSystem.out.print(\"Enter a word:\");\n\t return input.nextLine();\n\t}", "String getLocalizedString(Locale locale);", "boolean containsUtilize(String word)\n {\n return word.contains(\"utilize\");\n }", "public static String the(String str)\n\t{\t\t\n\t\tif (str.startsWith(\"the \")) return str;\n\t\telse if (str.startsWith(\"The \")) return str;\n\t\telse if (str.toLowerCase().charAt(0) == str.charAt(0)) return \"the \" + str;\n\t\telse return \"The \" + str.toLowerCase();\n\t}", "@Test(expected = NotEnglishWordException.class)\r\n\tpublic void testEnglishAdd() throws LanguageSyntaxException {\r\n\t\ttrans.addWord(\"дом\", \"домик\");\r\n\t}", "private static String capitaliseSingleWord(String word) {\n String capitalisedFirstLetter = word.substring(0, 1).toUpperCase();\n String lowercaseRemaining = word.substring(1).toLowerCase();\n return capitalisedFirstLetter + lowercaseRemaining;\n }", "private String processWord(String word){\r\n\t\tString lword = word.toLowerCase();\r\n\t\tfor (int i = 0;i<word.length();++i){\r\n\t\t\tstemmer.add(lword.charAt(i));\r\n\t\t}\r\n\t\tstemmer.stem();\r\n\t\treturn stemmer.toString();\r\n\t}", "private static void printLatinWord(String s) {\n\t\tif (s.length() < 2|| !s.matches(\"\\\\w*\")) {\n\t\t\tSystem.out.print(s+\" \");\n\t\t\treturn;\n\t\t}\n\t\tSystem.out.print(s.replaceAll(\"(\\\\w)(\\\\w*)\", \"$2$1ay \"));\n\t}", "public String translate(String words) {\n String[] sentence = words.split(\" \");\n //go through each element\n for (int i = 0; i < sentence.length; i++) {\n //if the dictionary contains the word\n if (hm.containsKey(sentence[i])) {\n //change it out with the new translated one\n sentence[i] = hm.get(sentence[i]) + \" (\" + sentence[i] + \")\";\n }\n }\n\n //Build the sentence back together\n String text = \"\";\n\n for (int i = 0; i < sentence.length; i++) {\n text += sentence[i] + \" \";\n }\n\n return text;\n\n /*if(amITranslating) {\n return text;\n } else {\n return words;\n }*/\n\n\n }", "public static String stemNSW(String word)\n\t{\n\t\treturn isNSW(getRoot(word.toLowerCase()));\n\t}", "public String wordAt(int index) {\n if (index < 0 || index >= myWords.length) {\n throw new IndexOutOfBoundsException(\"bad index in wordAt \"+index);\n }\n return myWords[index];\n }", "String getLanguage();", "String getLanguage();", "String getLanguage();", "public String convertToUpperCase(String word);", "String getLocalization();", "public String acronym(String phrase) {\n String accrStr = phrase.replaceAll(\"\\\\B.|\\\\P{L}\", \"\").toUpperCase();\n return accrStr;\n }", "public String getTitile(String language) {\n if (language.startsWith(\"e\")) {\n return enTitle;\n } else {\n return localTitle;\n }\n }", "private static String convert(String word) {\n\n char[] charArray = word.toCharArray();\n\n for (int letter = 0; letter < word.length(); letter++) {\n // Finding the first letter of a word.\n if (letter == 0 && charArray[letter] != ' ' || charArray[letter] != ' ' && charArray[letter - 1] == ' ') {\n // Checking if the first letter is lower case.\n if (charArray[letter] >= 'a' && charArray[letter] <= 'z') {\n // Converting first letter to upper case\n charArray[letter] = (char)(charArray[letter] - 'a' + 'A');\n }\n }\n // Checking if the letters other than the first letter are capital\n else if (charArray[letter] >= 'A' && charArray[letter] <= 'Z')\n // Converting uppercase other letters to lower case.\n charArray[letter] = (char)(charArray[letter] + 'a' - 'A');\n }\n // Returning a Title cased String.\n return new String(charArray);\n }", "static String refineWord(String currentWord) {\n\t\t// makes string builder of word\n\t\tStringBuilder builder = new StringBuilder(currentWord);\n\t\tStringBuilder newWord = new StringBuilder();\n\n\t\t// goes through; if it's not a letter, doesn't add to the new word\n\t\tfor (int i = 0; i < builder.length(); i++) {\n\t\t\tchar currentChar = builder.charAt(i);\n\t\t\tif (Character.isLetter(currentChar)) {\n\t\t\t\tnewWord.append(currentChar);\n\t\t\t}\n\t\t}\n\n\t\t// returns lower case\n\t\treturn newWord.toString().toLowerCase().trim();\n\t}", "private static int searchStandardDictionary(String word) {\n if (word.length() < 4) {\n return Arrays.binarySearch(STANDARD_DICTIONARY, 0, FOUR_LETTER_WORDS_OFFSET, word.toUpperCase(Locale.ENGLISH));\n } else {\n return Arrays.binarySearch(STANDARD_DICTIONARY, FOUR_LETTER_WORDS_OFFSET, STANDARD_DICTIONARY.length, word.toUpperCase(Locale.ENGLISH));\n }\n }", "public static String stemWord(String word) {\n if (word.matches(\".*\\\\s.*\")) throw \n new IllegalArgumentException(\"argument is not a single word: \" + word); \n EnglishStemmer stemmer = new EnglishStemmer();\n stemmer.setCurrent(word);\n stemmer.stem();\n return stemmer.getCurrent();\n // slow way of doing it with jcas\n// List<TokenCanonic> c = getCanonicForms(word, CanonicForm.STEM);\n// return c.get(0).canonic;\n }", "public String acronym(String phrase) {\n\t\tString[] p = phrase.split(\"[\\\\W\\\\s]\");\n\t\tString returner = \"\";\n\t\tfor (String s : p) {\n\t\t\tif (!s.isEmpty())\n\t\t\t\treturner = returner + s.charAt(0);\n\t\t}\n\t\treturn returner.toUpperCase();\n\t}", "private String containingWord(String attribute, String word) {\r\n return \"contains(concat(' ',normalize-space(@\" + attribute + \"),' '),' \"\r\n + word + \" ')\";\r\n }", "private Spannable applyWordMarkup(String text) {\n SpannableStringBuilder ssb = new SpannableStringBuilder();\n int languageCodeStart = 0;\n int untranslatedStart = 0;\n\n int textLength = text.length();\n for (int i = 0; i < textLength; i++) {\n char c = text.charAt(i);\n if (c == '.') {\n if (++i < textLength) {\n c = text.charAt(i);\n if (c == '.') {\n ssb.append(c);\n } else if (c == 'c') {\n languageCodeStart = ssb.length();\n } else if (c == 'C') {\n ssb.setSpan(new TextAppearanceSpan(BrowseWordsActivity.this,\n R.style.language_code_tag),\n languageCodeStart, ssb.length(), 0);\n languageCodeStart = ssb.length();\n } else if (c == 'u') {\n untranslatedStart = ssb.length();\n } else if (c == 'U') {\n ssb.setSpan(new TextAppearanceSpan(BrowseWordsActivity.this,\n R.style.untranslated_word),\n untranslatedStart, ssb.length(), 0);\n untranslatedStart = ssb.length();\n } else if (c == '0') {\n Resources res = getResources();\n ssb.append(res.getString(R.string.no_translations));\n }\n }\n } else\n ssb.append(c);\n }\n\n return ssb;\n }", "public static String createPluralWord(String word){\n\t\t//Keep the type in a variable since it's called a lot\n\t\tint typeWordEnd = determineWordType(word);\n\t\t\n\t\tString pluralWord;\n\t\t\n\t\t//These just make the string with respect to the table given in the problem document.\n\t\t// Relatively simple use of string functions involved.\n\t\tif(typeWordEnd == 1){\n\t\t\tpluralWord = word + \"gh\";\n\t\t} else if(typeWordEnd == 2){\n\t\t\tpluralWord = ((word.substring(0, word.length() - 1)) + \"g\");\n\t\t} else if(typeWordEnd == 3){\n\t\t\tpluralWord = (word + (word.substring(word.length() - 1)) + \"h\");\n\t\t} else {\n\t\t\t//Just in case something strange happens. I don't know why it would, but I guess it might as well be there.\n\t\t\tpluralWord = \"Error: Unexpected word type.\";\n\t\t}\n\t\t\n\t\t//Return the value...\n\t\treturn pluralWord;\n\t}", "public abstract String guessedWord();", "public String Stem( String word )\n {\n // check if we already know the word\n String stemmedword = AllWords.get(word);\n if ( stemmedword != null )\n return stemmedword; // return it if we already know it\n\n // don't check words with digits in them\n // if ( containsNumbers (word) == true )\n // stemmedword = null;\n // else\t// unknown word: try to stem it\n stemmedword = StemWordWithWordNet (word);\n\n if ( stemmedword != null )\n {\n // word was recognized and stemmed with wordnet:\n // add it to hashmap and return the stemmed word\n AllWords.put( word, stemmedword );\n return stemmedword;\n }\n // word could not be stemmed by wordnet,\n // thus it is no correct english word\n // just add it to the list of known words so\n // we won't have to look it up again\n AllWords.put( word, word );\n return word;\n }", "public DictionaryData lookup(String word) {\r\n\r\n return dictionaryMap.get(word.toUpperCase());\r\n }", "public String checkFile(String word) throws IOException {\n BufferedReader reader = new BufferedReader(new FileReader(\"antonyms.txt\"));\n boolean searchNext = true;\n String antonym;\n String line;\n do {\n line = reader.readLine();\n if(line!=null)\n if(line.split(\" - \")[0].equals(word))\n searchNext = false;\n }\n while (line!=null && searchNext);\n antonym = line.split(\" - \")[1];\n reader.close();\n return \"Antonym/s for \" + word + \": \" + antonym;\n }", "protected boolean isLanguage( String word )\r\n\t{\r\n\t\treturn m_listLanguage.contains(word);\r\n\t}", "public String getKeyword(String word) {\n\t\t/** COMPLETE THIS METHOD **/\n\t\t//strip trailing punctuation\n\t\tint n = 1;\n\t\tString output = \"\";\n\t\tword = word.toLowerCase();\n\t\tint j = 0;\n\t\twhile(j<word.length())\n\t\t{\n\t\t\tif(Character.isLetter(word.charAt(j)))\n\t\t\t{\n\t\t\t\t\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t//return null;\n\t\t\t}\n\t\t\tj++;\n\t\t}\n\t\t\n\t\twhile(n<word.length())\n\t\t{\n\t\t\t\n\t\t\tif( word.charAt(word.length()-n) == '.' ||\n\t\t\t\t\tword.charAt(word.length()-n) == ',' ||\n\t\t\t\t\tword.charAt(word.length()-n) == '?' || \n\t\t\t\t\tword.charAt(word.length()-n) == ':' ||\n\t\t\t\t\tword.charAt(word.length()-n) == ';' ||\n\t\t\t\t\tword.charAt(word.length()-n) == '!' )\n\t\t\t{\n\t\t\t\toutput = word.substring(0, word.length()-n);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tn++;\n\t\t}\n\t\tif( !(word.charAt(word.length()-1) == '.' ||\n\t\t\t\tword.charAt(word.length()-1) == ',' ||\n\t\t\t\tword.charAt(word.length()-1) == '?' || \n\t\t\t\tword.charAt(word.length()-1) == ':' ||\n\t\t\t\tword.charAt(word.length()-1) == ';' ||\n\t\t\t\tword.charAt(word.length()-1) == '!' )\n\t\t\t\t)\n\t\t{\n\t\t\toutput = word.substring(0, word.length());\n\t\t}\n\t\t// check if there are only alphanumeric characters\n\t\t\n\t\tArrayList<String> items = new ArrayList<>();\n\t\t\n\t\t\n\t try {\n\t \t\n\t Scanner scanner = new Scanner(new File(\"noisewords.txt\"));\n\t while (scanner.hasNextLine()) {\n\t String line = scanner.nextLine();\n\t items.add(line);\n\t \n\t }\n\t scanner.close();\n\t } catch (FileNotFoundException e) {\n\t e.printStackTrace();\n\t }\n\t int i = 0;\n\t boolean ans = false;\n\t while(i<items.size()) {\n\t\t if(output.equals(items.get(i))) \n\t\t {\n\t\t \tans = true;\n\t\t \tbreak;\n\t\t }\n\t\t else\n\t\t {\n\t\t \t ans = false;\n\t\t }\n\t\t i++;\n\t }\n\t //System.out.println(ans);\n\t if(ans == true)\n\t {\n\t \t return null;\n\t }\n\t /* int a = 0;\n\t\twhile(a<items.size())\n\t\t{\n\t\t\tSystem.out.println(items.get(a));\n\t\t\ta++;\n\t\t}*/\n\t\t// following line is a placeholder to make the program compile\n\t\t// you should modify it as needed when you write your code\n\t\tif(output != null)\n\t\t{\n\t\t\treturn output;\n\t\t}\n\t\t\n\t\treturn null;\n\t}", "public static String acronym(String phrase) {\n\t\tString[] arrPhrase = phrase.split(\" \", 0);\n\t\treturn arrPhrase[2];\n\t}", "private String toLowerCyrillic(String word) {\n StringBuilder stringBuilder = new StringBuilder();\n for (int i = 0; i < word.length(); i++) {\n char curChar = word.charAt(i);\n if (curChar >= 'А' && curChar <= 'Я') {\n curChar += 0x20;\n } else if (curChar == 'Ё') {\n curChar = 'ё';\n }\n stringBuilder.append(curChar);\n }\n return stringBuilder.toString();\n }", "@Test\n public void shouldTranslateWithRegionalVariant() {\n List<String> sentence = Arrays.asList(\"it\", \"is\", \"cold\");\n String result = \"\";\n for (String token : sentence) {\n result += manager.message(Locale.CANADA_FRENCH, token, token) + \" \";\n }\n assertEquals(\"Il fait frette \", result);\n }", "private LexiNode search_specific_word(String word, int index){\n\t\tif(current_word != null && !current_word.isEmpty()){\n\t\tint local_index = index + 1;\n\t\t//if we found the word, we make the change\n\t\tif(current_word != null && \n\t\t !current_word.isEmpty() && \n\t\t\tword.toLowerCase().equals(current_word.toLowerCase()))\n\t\t\treturn this;\n\t\t//We try to find the word within our childs\n\t\tfor(LexiNode child: childs)\n\t\t\tif(word.toLowerCase().charAt(local_index) == Character.toLowerCase(child.getRepresentative_letter()))\n\t\t\t\treturn child.search_specific_word(word, local_index);\n\t\t}\n\t\treturn null;\n\t}", "@Override\r\n public String speak() {\r\n String word = \"\";\r\n Time.getInstance().time += 1;\r\n if (Time.getInstance().time == 1) {\r\n word = \"One day Neznaika decided to become an artist.\";\r\n }\r\n if (Time.getInstance().time == 101) {\r\n word = \"This story happened once day with Neznaika.\";\r\n }\r\n if (Time.getInstance().time == 201) {\r\n word = \"One day Neznaika wanted to become a musician.\";\r\n }\r\n if (Time.getInstance().time == 401) {\r\n word = \"One day Neznaika wanted to become a poet.\";\r\n }\r\n System.out.println(word);\r\n return word;\r\n }", "public static Boolean Word(String arg){\n\t\tif(arg.matches(\"^[a-zA-ZåÅäÄöÖüÜéÉèÈ]*\")){\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\t\n\t}", "public String getWord() {\n if(words[index] != null) {\n return words[index];\n } else {\n return \"\";\n }\n }", "public String StemWordWithWordNet ( String word )\n {\n if ( !IsInitialized )\n return word;\n if ( word == null ) return null;\n if ( morph == null ) morph = dic.getMorphologicalProcessor();\n\n IndexWord w;\n try\n {\n w = morph.lookupBaseForm( POS.VERB, word );\n if ( w != null )\n return w.getLemma().toString ();\n w = morph.lookupBaseForm( POS.NOUN, word );\n if ( w != null )\n return w.getLemma().toString();\n w = morph.lookupBaseForm( POS.ADJECTIVE, word );\n if ( w != null )\n return w.getLemma().toString();\n w = morph.lookupBaseForm( POS.ADVERB, word );\n if ( w != null )\n return w.getLemma().toString();\n }\n catch ( JWNLException e )\n {\n }\n return null;\n }", "public static CommandType getWord(String word){\r\n\t\treturn dictionary.get(word);\r\n\t}", "public String getWord()\n\t{\n\t\treturn word.get(matcher());\n\t}", "private void listen_meaning_word() {\n\t\tif(this.dwd!=null)\n\t\t{\n\t\t\tString meaning_word=\"\";\n\t\t\tif(isHindi)\n\t\t\t{\n\t\t\t\tmeaning_word=dwd.eng_word;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tmeaning_word=dwd.hin_word;\n\t\t\t}\n\t\t\tif(isHindi)\n\t\t\t{\n\t\t\t\tif(this.main_word!=\"\")\n\t\t\t\t{\n\t\t\t\t\tif(mCallBack==null)\n\t\t\t\t\t{\n\t\t\t\t\t\tmCallBack=(OnWordSelectedFromSearchSuccess) getActivity();\n\t\t\t\t\t}\n\t\t\t\t\tmCallBack.onWordSpeak(meaning_word);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tDictCommon.listen_in_hindi(meaning_word);\n\t\t\t}\n\t\t}\n\t}", "Language findByName(String name);", "public String acronym(String phrase) {\n /*StringBuilder acronymFeed = new StringBuilder(\"\");\n String wordHolder = \"\";\n int spaceIndex;\n char firstLetter;\n do{\n spaceIndex = phrase.indexOf(\" \");\n wordHolder = phrase.substring(0,spaceIndex);\n acronymFeed.append(wordHolder.charAt(0));\n phrase = phrase.replaceFirst(wordHolder, \"\");\n } while (spaceIndex != -1 && wordHolder != \"\" && phrase != \"\");\n \n \n \n \n \n String acronymResult = acronymFeed.toString().toUpperCase();\n return acronymResult;\n */\n \n char[] letters = phrase.toCharArray();\n String firstLetters = \"\";\n firstLetters += String.valueOf(letters[0]);\n for (int i = 1; i < phrase.length();i++){\n if (letters[i-1] == ' '){\n firstLetters += String.valueOf(letters[i]);\n }\n }\n firstLetters = firstLetters.toUpperCase();\n return firstLetters;\n }", "public Boolean lookupAWord(String target) {\n ArrayList<Word> fullDictionary = dictionaryManagement.getDictionary().getWords();\n int result = dictionaryManagement.lookupWord(target);\n if (result == -1) {\n System.out.println(\"This word is dose not exsit!\");\n return false;\n } else {\n System.out.println(\"Result: \");\n System.out.println(\"\\tTarget: \" + target);\n System.out.println(\"\\tExplain: \" + fullDictionary.get(result).getWordExplain());\n return true;\n }\n }", "public static String getWordFromKey(String senseKey)\n\t{\n\t\tint lastUS = senseKey.lastIndexOf(\"_\");\n\t\treturn senseKey.substring(0, lastUS - 3);\n\t}", "private static String firstUpperCase(String word) {\n\t\tif (word == null || word.isEmpty()) {\n\t\t\treturn \"\";\n\t\t}\n\t\treturn word.substring(0, 1).toUpperCase() + word.substring(1);\n\t}", "public boolean wordExists(String word)\n\t{\n\t\t//checks to make sure the word is a word that starts with a lowercase letter, otherwise return false\n\t\tif(word.charAt(0) >= 'a' && word.charAt(0) <= 'z')\n\t\t{\n\t\t\tchar letter = word.charAt(0);\n\t\t\t\n\t\t\treturn (myDictionaryArray[(int)letter - (int)'a'].wordExists(word));\n\t\t}\n\t\t\n\t\treturn false;\t\t\n\t}", "ILoLoString translate();", "String stemOf (String word);", "private String pickWord() {\n \thangmanWords = new HangmanLexicon();\n \tint randomWord = rgen.nextInt(0, (hangmanWords.getWordCount() - 1)); \n \tString pickedWord = hangmanWords.getWord(randomWord);\n \treturn pickedWord;\n }", "public String getLexEntry(String word)\n {\n boolean found = false;\n String buff = \"\";\n String rtn = \"\";\n\n lastCount = 0.0;\n if(word.length() > 0)\n {\n buff = compactNumbers(word);\n rtn = searchLexDb(buff, true);\n if(rtn.length() > 0)\n found = true;\n\n else // try the lowercase version\n {\n buff = buff.toLowerCase();\n rtn = searchLexDb(buff, true);\n if(rtn.length() > 0)\n found = true;\n } // else\n } // fi\n\n // If not found, get the search string corresponding to the word.\n\n if(!found)\n {\n buff = searchString(word);\n\n while(!found && (buff.length() > 0))\n {\n rtn = searchLexDb(buff, false);\n if(rtn.length() > 0)\n found = true;\n else\n buff = buff.substring(1);\n } // while\n } // fi\n\n if(!found)\n System.out.println(\"word: #\" + word + \"# lex entry not found\");\n\n return(rtn.toString());\n }", "public static String removeNonWord(String message)\r\n {\r\n int start = getLetterIndex(message, head); //get the fist index that contain English letter\r\n int end = getLetterIndex(message, tail); //get the last index that contain English letter\r\n if (start == end) // if only contain one letter\r\n return String.valueOf(message.charAt(start)); // return the letter\r\n return message.substring(start, end + 1); // return the content that contain English letter\r\n }", "public static String isNSW(String word)\n\t{\n\t\tif (sw.contains(word))\n\t\t{\n\t\t\treturn \"\";\n\t\t}\n\t\treturn word;\n\t}", "private void save_meaning_word() {\n\t\tif(this.dwd!=null && this.main_word!=null)\n\t\t{\n\n\n\t\t\tString meaning_word=\"\";\n\t\t\tif(isHindi)\n\t\t\t{\n\t\t\t\tmeaning_word=dwd.eng_word;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tmeaning_word=dwd.hin_word;\n\t\t\t}\n\n\t\t\tDictCommon.SaveWord(meaning_word,!isHindi);\n\t\t\tToast.makeText(view.getContext(), \"word \"+meaning_word+\" successfully saved!!!\", Toast.LENGTH_LONG).show();\n\t\t}\n\t}", "WordBean getWord(String word);", "public String getWord (int wordIndex) {\n if (wordIndex < 0 ) {\n return \"\";\n } else {\n int s = getWordStart (wordIndex);\n int e = indexOfNextSeparator (tags, s, true, true, slashToSeparate);\n if (e > s) {\n return tags.substring (s, e);\n } else {\n return \"\";\n }\n }\n }", "private String capitalize(final String word) {\n return Character.toUpperCase(word.charAt(0)) + word.substring(1);\n }", "public void englishlanguage() {\nSystem.out.println(\"englishlanguage\");\n\t}", "static String question(String sentence) {\r\n\t\tString result = null;\r\n\t\tif (sentence.contains(\"can you tell me\")) {\r\n\t\t\tint index = sentence.indexOf(\"can you tell me\");\r\n\t\t\tString search = sentence.substring(index + 15);\r\n\t\t\tresult = googleFind(search);\r\n\t\t} else if (sentence.contains(\"do you know\")) {\r\n\t\t\tint index = sentence.indexOf(\"do you know\");\r\n\t\t\tString search = sentence.substring(index + \"do you know\".length());\r\n\t\t\tresult = googleFind(search);\r\n\t\t}\r\n\t\treturn result;\r\n\t}", "java.lang.String getLanguageCode();", "java.lang.String getLanguageCode();", "private String searchString(String inWord)\n {\n String line = null;\n StringBuffer rtn = new StringBuffer();\n int len = inWord.length();\n boolean found = false;\n\n if(len == 1)\n {\n if(Character.isDigit(inWord.charAt(0)))\n {\n rtn.append(inWord).append(\"I\");\n found = true;\n } // fi\n\n else if(Character.isLetter(inWord.charAt(0)))\n {\n rtn.append(inWord.toLowerCase()).append(\"S\");\n found = true;\n } // else fi\n } // fi\n\n if(!found)\n {\n int\tnum_A = 0; // Upper case\n int\tnum_L = 0; // Lower case\n int\tnum_N = 0; // Numbers\n int\tnum_P = 0; // Punctuation (numeric)\n int\tnum_Q = 0; // Quotes\n int\tnum_O = 0; // Other\n char last_ch = ' ';\n\n for(int i = 0; i < len; i++)\n {\n if((i == 0) && (inWord.charAt(i) == '-'))\n num_L++;\n\n else if(Character.isLowerCase(inWord.charAt(i)))\n num_L++;\n\n else if(Character.isUpperCase(inWord.charAt(i)))\n num_A++;\n\n else if(Character.isDigit(inWord.charAt(i)))\n num_N++;\n\n else if((inWord.charAt(i) == '=')||(inWord.charAt(i) == ':') ||\n (inWord.charAt(i) == '+')||(inWord.charAt(i) == '.') ||\n (inWord.charAt(i) == ','))\n num_P++;\n\n else if((inWord.charAt(i) == '\\'') ||\n (inWord.charAt(i) == '`') || (inWord.charAt(i) == '\"'))\n num_Q++;\n\n else\n num_O++;\n\n last_ch = inWord.charAt(i);\n } // for\n\n int pos = 0;\n if((len - ntail) > 0)\n pos = len - ntail;\n\n rtn.append(inWord.substring(pos).toLowerCase());\n\n if((num_L + num_Q) == len)\n rtn.append(\"\");\n\n else if((num_A + num_Q) == len)\n rtn.append(\"A\");\n\n else if((num_N + num_P + num_Q) == len)\n rtn.append(\"N\");\n\n else if((num_L + num_A + num_Q) == len)\n rtn.append(\"B\");\n\n else if((num_A + num_N + num_P + num_Q) == len)\n rtn.append(\"C\");\n\n else if((num_L + num_N + num_P + num_Q) == len)\n rtn.append(\"E\");\n\n else if((num_A + num_L + num_N + num_P + num_Q) == len)\n rtn.append(\"D\");\n\n else if((num_O == 0) && (last_ch == '+'))\n rtn.append(\"F\");\n\n else\n rtn.append(\"O\");\n } // else\n\n rtn.append(\"_\");\n\n return(rtn.toString());\n }", "private String stemmingForAWord(String identifiedWord) {\n String word;\n if (identifiedWord.contains(\"_\")) {\n word = identifiedWord;\n } else {\n word = morphology.stem(identifiedWord);\n }\n return word;\n }", "public static String singularize(String word)\n {\n if (Inflection.isUncountable(word))\n {\n return word;\n }\n else\n {\n for (Inflection inflection : singular)\n {\n //System.out.println(word + \" matches \" + inflection.pattern + \"? (ignore case: \" + inflection.ignoreCase + \")\");\n if (inflection.match(word))\n {\n //System.out.println(\"match!\");\n return inflection.replace(word);\n }\n }\n }\n return word;\n }", "public String search_words(String word){\n\t\tString found_words = \"\";\n\t\t//We try to find the word within our childs\n\t\tfor(LexiNode child: childs)\n\t\t\tif(word.toLowerCase().charAt(0) == Character.toLowerCase(child.getRepresentative_letter()))\n\t\t\t\tfound_words += child.search_words(word, 0);\n\t\t\n\t\treturn found_words;\n\t}", "public abstract WordEntry autoTranslate(String text, String to);", "public String detectLanguage(String text) {\n\t\treturn dictionary.detectLanguage(text);\n\t}", "public String getWordAt(int pos){\n\t\treturn sentence.get(pos).getWord();\n\t}", "public static String translate_word_to_pig_latin(String word) {\r\n String new_word = word;\r\n int vowel_index = index_of_first_vowel(word);\r\n // Put starting consonant(s), if any, at the end of the word\r\n if(vowel_index > 0){\r\n new_word = word.substring(vowel_index) + word.substring(0, vowel_index);\r\n }\r\n\r\n // Add the ay to the end of all words\r\n new_word = new_word.concat(\"ay\");\r\n return new_word;\r\n }", "private String getLanguageFromTokenizer(StreamTokenizer st)\n\t\t\tthrows IOException {\n\t\tst.nextToken();\n\t\t// if not defined -> define default language of server...\n\t\tif (st.sval == null || st.sval.equals(\"\"))\n\t\t\treturn Locale.getDefault().getLanguage();\n\t\t// else return language string\n\t\treturn st.sval;\n\t}", "public interface IWord2Spell {\r\n String word2spell();\r\n}" ]
[ "0.7332769", "0.70806056", "0.67419034", "0.66082346", "0.65244263", "0.6474713", "0.62998134", "0.61095107", "0.6104621", "0.60872614", "0.6013805", "0.60035247", "0.59306955", "0.5918872", "0.5865067", "0.58529234", "0.5850527", "0.5844446", "0.5823395", "0.5823395", "0.5793732", "0.578717", "0.57822937", "0.57802194", "0.57776004", "0.57740015", "0.57529396", "0.5743813", "0.57105196", "0.5690848", "0.5679528", "0.5677641", "0.56656206", "0.5658484", "0.56555855", "0.5651286", "0.5636263", "0.5606545", "0.5601465", "0.5601465", "0.5601465", "0.55903405", "0.55760217", "0.5572769", "0.557123", "0.55472404", "0.5546286", "0.55413604", "0.5534609", "0.5528493", "0.5524699", "0.5523454", "0.55202913", "0.55162126", "0.5510769", "0.5492727", "0.548534", "0.54847825", "0.54842603", "0.54578465", "0.54540825", "0.5447016", "0.5444691", "0.5441388", "0.5436543", "0.5436256", "0.5427525", "0.54266167", "0.54164696", "0.5414064", "0.54119754", "0.5410476", "0.54086524", "0.54023427", "0.5391845", "0.53790015", "0.5375967", "0.5372348", "0.5367335", "0.5365332", "0.5353661", "0.53491735", "0.5347754", "0.53449184", "0.53442186", "0.53266644", "0.5325823", "0.53205657", "0.53078806", "0.53078806", "0.52998567", "0.52976686", "0.5285164", "0.5282536", "0.5273978", "0.52675676", "0.5264772", "0.5253479", "0.5242299", "0.52419496" ]
0.71805966
1
Getter for board state.
public static String[][] getBoardState() { return boardState; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public char[][] getBoardState(){\n\t\treturn board;\n\t}", "public char[][] getBoardState(){\n return board;\n }", "private Board getBoard() {\n return gameStatus.getBoard();\n }", "public Status getStatus() {\n return board.getStatus();\n }", "public GameState getState(){\n\t\tGameState State=new GameState(this.points, this.currentBoard.getState());\n\t\t\n\t\treturn State;\n\t}", "public String getStateOfBoard()\n {\n // This function is used to print state of the board. such as number of coins present on the board\n String str=\"\";\n str += \"Black_Coins Count:\"+this.gameController.getCoinsCount(CoinType.BLACK) +\" Red_Coins Count:\"+this.gameController.getCoinsCount(CoinType.RED);\n return str;\n }", "public boolean[][] getBoard() {\r\n return board;\r\n }", "public static Board getBoard(){\n\t\treturn board;\n\t}", "public Board getBoard() {\r\n return board;\r\n }", "public int getState(int row, int col) throws ArrayIndexOutOfBoundsException {\r\n return board[row][col];\r\n }", "public Board getBoard() {\n return board;\n }", "public Board getBoard() {\n return this.board;\n }", "public Board getBoard() {\n return this.board;\n }", "public Integer[][] getBoard() {\n\t\treturn _board;\n\t}", "public Board getBoard() {\n return board;\n }", "Board getBoard() {\r\n return _board;\r\n }", "public int[][] getBoard() {\r\n\t\treturn board;\r\n\t}", "public int[][] getBoard() {\n\t\treturn board;\n\t}", "public Tile[][] getBoard() {\r\n return board;\r\n }", "public Board getBoard() {\n\t\treturn this.board;\n\t}", "public int[][] getState(){\r\n return this.state;\r\n }", "public Board getBoard() {\n\t\treturn (this.gameBoard);\n\t}", "public Board getBoard() {\n\t\treturn board;\n\t}", "public Board getBoard() {\n\t\treturn board;\n\t}", "public int[] getBoard() {\n\t return board;\n }", "public Board getCurrentBoard() {\n return boardIterator.board;\n }", "public GameState GetState(){\n\t\treturn this.state;\n\t}", "public static String[][] createBoardState() {\n String[][] initialBoardState = {\n {\"Rw\", \"Nw\", \"Bw\", \"Qw\", \"Kw\", \"Bw\", \"Nw\", \"Rw\"},\n {\"Pw\", \"Pw\", \"Pw\", \"Pw\", \"Pw\", \"Pw\", \"Pw\", \"Pw\"},\n {\" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \"},\n {\" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \"},\n {\" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \"},\n {\" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \"},\n {\"Pb\", \"Pb\", \"Pb\", \"Pb\", \"Pb\", \"Pb\", \"Pb\", \"Pb\"},\n {\"Rb\", \"Nb\", \"Bb\", \"Qb\", \"Kb\", \"Bb\", \"Nb\", \"Rb\"}\n };\n\n return initialBoardState;\n }", "Board getBoard() {\n return _board;\n }", "public Board getBoard ();", "public Board getBoard()\r\n {\r\n return gameBoard;\r\n }", "private int getStateOfPositionFromBoard(positionTicTacToe position, List<positionTicTacToe> targetBoard)\n\t{\n\t\tint index = position.x*16+position.y*4+position.z;\n\t\treturn targetBoard.get(index).state;\n\t}", "public GameBoard getBoard() {\n return board;\n }", "public GameState getState() {\n\t\treturn state;\n\t}", "public byte getState() {\n return myState;\n }", "public int getBoardState(boolean whiteTeamMoving) {\n\t\tint result = 0;\n\t\tboolean moves = doMovesExist(whiteTeamMoving);\n\n\t\tresult |= moves ? 0 : 1;\n\t\tresult |= isWhiteCheck() ? 1<<1 : 0;\n\t\tresult |= isBlackCheck() ? 1<<2 : 0;\n\t\tresult |= result == 1 ? 0 : 1<<3;\n\n\t\treturn result;\n\t}", "public Board getBoard(){\n return undoBoards.peek();\n }", "@Override\n public BattleState getBattleState() {\n return state;\n }", "public Board getBoard() {\n return gameBoard;\n }", "public Board getBoard(){\n return m_board;\n }", "State getState();", "State getState();", "State getState();", "State getState();", "public GUIBoard getBoard() {\n return board;\n }", "public Board getBoardObject() {\n return boardObject;\n }", "protected Board getBoard() { // nao vou deixar public, vou deixar privado\n\t\treturn board;\n\t}", "public Board getBoard(){return board;}", "public int getBoardLocation() {return boardLocation;}", "int getState();", "int getState();", "int getState();", "int getState();", "int getState();", "int getState();", "public KetchLeader.State getState() {\n\t\treturn state;\n\t}", "public State getState();", "public State getState();", "public Board aiGetBoard() {\n return b;\n }", "String getBoard();", "public int getState();", "public int getState();", "public int getState();", "public int getState();", "public int getState() {return state;}", "public int getState() {return state;}", "public Piece[][] getBoard(){\r\n\t\treturn this.board;\r\n\t}", "public byte getState(){\n\t\t/*\n\t\tOFFLINE((byte)0),\n ONLINE((byte)1),\n SAVING((byte)2);\n\t\t */\n\t\t//getWorld().getcWorld().update(this);\n\t\treturn state;\n\t}", "public FloorTile[][] getBoard(){\r\n return board;\r\n }", "public int getBoardPosition() {\n return boardPosition;\n }", "public int[][] getBoard();", "public Piece[][] getBoard() {\n return _board;\n }", "public int getState() {\n return m_state;\n }", "public int getState(){\n return state;\n }", "public Board getBoard(){\n return board;\n }", "public AeBpelState getState();", "Object getState();", "public int getState() {\n return state.getValue();\n }", "public static char[][] getBoard() {\n\t\treturn board;\n\t}", "public EditableBoard getBoard() {\n\treturn board;\n }", "public char[][] getBoard() {\n return board;\n\t}", "public int getState() {\n return this.mState;\n }", "public Object getState() {\n\t\tint columnCount = getColumnCount();\n\t\tColumnState[] state = new ColumnState[columnCount + hiddenCols.size()];\n\t\tfor (int i = 0; i < columnCount; i++) {\n\t\t\tTableColumn col = getColumn(i);\n\t\t\tObject id = col.getIdentifier();\n\t\t\tstate[i] = getColumnState(id);\n\t\t}\n\t\tfor (Object id : hiddenCols.keySet()) {\n\t\t\tstate[columnCount++] = getColumnState(id);\n\t\t}\n\t\treturn state;\n\t}", "public Color getColor() {\r\n return this.BoardColor;\r\n }", "public int getState() {\n return state;\n }", "public int getState() {\n return state;\n }", "public State getState()\r\n\t{\r\n\t\treturn this.state;\r\n\t}", "public SudokuBoard getBoard() {\n return board;\n }", "@Override\n public int getState() {\n return myState;\n }", "public State GetState()\n {\n return this.state;\n }", "public int getState() {\n return state;\n }", "public int getState() {\n return _state;\n }", "public int getState()\n {\n return m_state.getState();\n }", "public int getState() {\n \t\treturn state;\n \t}", "public GameToken[][] getBoard() {\n\t\treturn this.board;\n\t}", "public int getState() {\n return mState;\n }", "public State getState() {\n return state.get();\n }", "public BlockFor2048[][] getBoard() {\n\t\treturn this.myBoard;\n\t}", "public Player getState() {\n\t\treturn state;\n\t}", "public int getState(){\n\t\treturn state;\n\t}" ]
[ "0.80403364", "0.7899998", "0.7526082", "0.7405892", "0.72089565", "0.72056293", "0.6962611", "0.69581753", "0.6946021", "0.69379884", "0.6937766", "0.69296324", "0.69296324", "0.68982816", "0.68747956", "0.68586105", "0.6849712", "0.6842748", "0.68349993", "0.6810481", "0.68064535", "0.6798907", "0.6776495", "0.6776495", "0.6775769", "0.6772125", "0.67642474", "0.6756797", "0.67532164", "0.67514026", "0.6748053", "0.67378294", "0.67332184", "0.67167866", "0.6716478", "0.67138296", "0.6703614", "0.6685486", "0.6683591", "0.6665949", "0.6656025", "0.6656025", "0.6656025", "0.6656025", "0.66465145", "0.6615953", "0.6593237", "0.65875506", "0.65846217", "0.6579489", "0.6579489", "0.6579489", "0.6579489", "0.6579489", "0.6579489", "0.6575186", "0.6565564", "0.6565564", "0.6556277", "0.6547915", "0.65473217", "0.65473217", "0.65473217", "0.65473217", "0.6547127", "0.6547127", "0.65403265", "0.6538545", "0.6535419", "0.6530704", "0.6521515", "0.6512151", "0.6494946", "0.649368", "0.6492185", "0.648234", "0.6475577", "0.64729565", "0.6467687", "0.6467129", "0.6464998", "0.64548457", "0.6440527", "0.6439691", "0.6434565", "0.6434565", "0.64289266", "0.6426347", "0.6423863", "0.6422467", "0.641757", "0.6416996", "0.64117515", "0.6408716", "0.6406429", "0.6402987", "0.6399556", "0.63977104", "0.6396993", "0.63918793" ]
0.830407
0
Setter for board state.
public static void setBoardState(String[][] bs) { boardState = bs; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public void setCellState(int newState) {\n this.myState = newState;\n }", "void setBoard(Board board);", "@Override\r\n\tpublic void setBoard(Board board) {\n\t\t\r\n\t}", "public void setState(int row, int col) throws ArrayIndexOutOfBoundsException {\r\n board[row][col] = currentPlayer;\r\n }", "public void setBoard(Board board){this.board = board;}", "protected abstract void setCell(int x, int y, boolean state);", "public void setBoard(Board board) {\n this.board = board;\n }", "public void setBoard(Board board) {\n this.board = board;\n }", "public void setBoard(int[][] board) {\n this.board = board;\n }", "public void changeBoard(Board board){\n this.board = board;\n }", "public void setBoard(Board board) {\n\t\tthis.board = board;\n\t\t\n\t}", "public void setState(GameState aState){\n\t\tpoints=aState.getScore();\n\t\tcurrentBoard.setState(aState.getBoardState());\n\t}", "private void setState(WFDState s) {\n Log.d(TAG, \"Moving from \" + sState + \" --> \" + s);\n sState = s;\n }", "public void SetState(int s) {\n this.state=LS[s];\n }", "public void setBoard() {\n bestPieceToMove = null;\n bestPieceFound = false;\n bestMoveDirectionX = 0;\n bestMoveDirectionY = 0;\n bestMoveFound = false;\n killAvailable = false;\n lightCounter = 12;\n darkCounter = 12;\n for (int y = 0; y < boardSize; y++) {\n for (int x = 0; x < boardSize; x++) {\n board[y][x] = new Field(x, y);\n if (y < 3 && board[y][x].getPlaceable()) {\n board[y][x].setPiece(new Piece(PieceColor.DARK, PieceType.MEN));\n } else if (y > 4 && board[y][x].getPlaceable()) {\n board[y][x].setPiece(new Piece(PieceColor.LIGHT, PieceType.MEN));\n }\n }\n }\n }", "public void setBoard(GUIBoard board) {\n this.board = board;\n }", "public void setBoardLocation(int boardLocation) {this.boardLocation = boardLocation;}", "public char[][] getBoardState(){\n\t\treturn board;\n\t}", "public void setCellState(int i, int j, CellState value) {\n switch (value) {\n case ZERO_CELL: {\n int ZERO_MARK = -1;\n field[i][j] = ZERO_MARK;\n break;\n }\n case CROSS_CELL: {\n int CROSS_MARK = 1;\n field[i][j] = CROSS_MARK;\n break;\n }\n case EMPTY_CELL: {\n field[i][j] = EMPTY_MARK;\n break;\n }\n }\n }", "public void setState(int state);", "public void setState(int state);", "public void setBoard(Board theBoard) {\n\t\tthis.board = theBoard;\n\t}", "void setState(int state);", "public void testSetCell()\r\n {\r\n board.loadBoardState(\"OOOO\",\r\n \"OOOO\",\r\n \"O+OO\",\r\n \"OOOO\");\r\n board.setCell(1, 2, MineSweeperCell.FLAGGED_MINE);\r\n assertBoard(board, \"OOOO\",\r\n \"OOOO\",\r\n \"OMOO\",\r\n \"OOOO\");\r\n }", "public void setBoard(int row, int col, int value) {\n this.board[row][col] = value;\n }", "public void setBoard(Board theBoard) {\n\t\tthis.board = theBoard;\n\n\t}", "private void restoreBoard(int[]board, boolean[] state)\n {\n int [] ids = new int[]{\n R.id.box1, R.id.box2, R.id.box3, R.id.box4, R.id.box5, R.id.box6,\n R.id.box7, R.id.box8, R.id.box9\n };\n\n for (int i = 0; i < board.length; i++)\n {\n\n ImageButton btn = (ImageButton)findViewById(ids[i]);\n if (board[i] == 1)\n {\n btn.setBackgroundResource(R.drawable.x);\n\n }\n else if (board[i] == 2)\n {\n btn.setBackgroundResource(R.drawable.o);\n\n }\n else if(board[i] ==0)\n {\n\n btn.setBackgroundResource(R.drawable.tile);\n }\n\n btn.setEnabled(state[i]);\n }\n\n\n }", "public void setState(PlayerState state) {\n this.state = state;\n }", "public static String[][] getBoardState() {\n return boardState;\n }", "public void setState(int i, int j, int val){\r\n this.state[i][j] = val;\r\n }", "public void changeState() {\n if (!isDead) {\n Bitmap temp = getBitmap();\n setBitmap(stateBitmap);\n stateBitmap = temp;\n }\n }", "public char[][] getBoardState(){\n return board;\n }", "@Override\n\tpublic void setState(State state) \n\t\t{ current = new PuzzleState(state.getString(state.getState()),\n\t\t\t\t\t\t\t\t\tstate.getString(state.getGoalState())); \n\t\t}", "public static void setBoard(char[][] board) {\n\t\tBoard.board = board;\n\t}", "public void setState(GameState s) {\n this.state = s;\n }", "public void setState(State newState) {this.state = newState;}", "public void updateCellState(Move move)\r\n\t{\r\n\t\tCellState color = this.grid[move.getMovedMarbleInitialPosition(0).getX()][move.getMovedMarbleInitialPosition(0).getY()];\r\n\t\t\r\n\t\tfor(int i = 0;i < move.getMovedMarblesCount();i++)\r\n\t\t{\r\n\t\t\tthis.grid[move.getMovedMarbleInitialPosition(i).getX()][move.getMovedMarbleInitialPosition(i).getY()] = CellState.EMPTY;\r\n\t\t}\r\n\t\tfor(int i = 0; i < move.getMovedMarblesFinalCount();i++)\r\n\t\t{\r\n\t\t\tif(isPositionValid(move.getMovedMarbleFinalPosition(i)))\r\n\t\t\t{\r\n\t\t\t\tthis.grid[move.getMovedMarbleFinalPosition(i).getX()][move.getMovedMarbleFinalPosition(i).getY()] = color;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tif(color == CellState.BLACK_MARBLE) this.blackMarblesCount --;\r\n\t\t\t\tif(color == CellState.WHITE_MARBLE) this.whiteMarblesCount --;\r\n\t\t\t}\r\n\t\t}\r\n\t}", "public void setState(State state) { model.setState(state); }", "public void setState(StateEnum val) {\n state = val;\n }", "public void setBattleState(BattleState newState) {\n requireNonNull(newState);\n this.state = newState;\n }", "public int setCurrentState(int[][] state) {\n\t\tfor (int i = 0; i < 9; i++) {\n\t\t\tfor (int j = 0; j < 9; j++) {\n\t\t\t\tthis.currentState[i][j] = state[i][j];\n\t\t\t}\n\t\t}\n\n\t\treturn 0;\n\t}", "protected void takeTurn(int[][] boardState)\n {\n \n }", "public void setState(Byte state) {\n this.state = state;\n }", "public void setState(Byte state) {\n this.state = state;\n }", "private void setCell(boolean[][] board, int i, int j) {\n\t\tint numOfNeighbors = getNeighbors(board, i, j);\n\t\tif(board[i][j]) { // if alive\n\t\t\tif(numOfNeighbors < 2 || numOfNeighbors >= 4) {\n\t\t\t\ttempBoard[i][j] = false; // kill cell\n\t\t\t}\n\t\t}else{ // if dead\n\t\t\tif(numOfNeighbors == 3)\n\t\t\t\ttempBoard[i][j] = true; // become alive\n\t\t}\n\t}", "public State(char[] arr) {\r\n\t\tthis.board = Arrays.copyOf(arr, arr.length);\r\n\t}", "private void mStateSet(cKonst.eSerial nNewState) {\n if (nState_Serial!=nNewState) {\n switch (nNewState) {\n case kBT_Disconnected:\n mMsgDebug(sRemoteDeviceName + \" Disconnected 1\");\n break;\n }\n bDoRedraw = true; //Something has changed redraw controls\n }\n nState_Serial=nNewState;\n }", "public void setState(int state) {\n m_state = state;\n }", "public void setState(int state) {\n \t\tthis.state = state;\n \t}", "public void setStateOfMovement(int movementState){stateOfMovement = movementState; }", "private void setState( int state )\n {\n m_state.setState( state );\n }", "public void setState(Integer state) {\r\n this.state = state;\r\n }", "public void setState(Integer state) {\r\n this.state = state;\r\n }", "void onBoardStateChanged(BoardView view);", "public static void setState(GameState state) {\r\n\t\tgameState = state;\r\n\t}", "void setState(State state);", "public void setBoard(){\n \n\t m_Pieces[3][3]= WHITE_PIECE;\n m_Pieces[4][4]= WHITE_PIECE;\n m_Pieces[3][4]= BLACK_PIECE;\n m_Pieces[4][3]= BLACK_PIECE;\n for(int x=0;x<WIDTH;x++){\n for(int y=0;y<HEIGHT;y++){\n if(m_Pieces[x][y]==null){\n m_Pieces[x][y]=NONE_PIECE;\n }\n }\n }\n }", "public void setState(int state) {\n\t\tif (state == CHASE)\n\t\t\tthis.state = CHASE;\n\t\telse if (state == RUN) \n\t\t\tthis.state = RUN;\n\t}", "public GameBoard() {\n this.gameStarted = false;\n this.turn = 1; \n this.boardState = new char[3][3];\n this.winner = 0; \n this.isDraw = false; \n\n }", "public void set(GameState state){\n states.pop();\n states.push(state);\n }", "public static void setBoardStateSquare(int file, int rank, String piece) {\n boardState[rank][file] = piece;\n }", "public Cell(int state) {\n \t\tthis.state = state;\n \t}", "@Override\n\tpublic void setState(STATE state) {\n\n\t}", "public void setOpBoardMove(int row, int col, int oppiece)\n\t{\n\t\tboard[row][col] = oppiece;\n\t}", "public void setState(String state) {\n // checkValidState(state);\n if ((!States.special.contains(this.state)\n || !this.inSpecialState)\n && this.state != state) {\n this.spriteNum = 0;\n this.curSpriteFrame = 0;\n this.state = state;\n }\n \n }", "public void changeState() {\r\n if(state == KioskState.CLOSED) {\r\n state = KioskState.OPEN;\r\n } else {\r\n state = KioskState.CLOSED;\r\n }\r\n }", "public void setState(Integer state) {\n this.state = state;\n }", "public void setState(Integer state) {\n this.state = state;\n }", "public void setState(Integer state) {\n this.state = state;\n }", "public void setState(Integer state) {\n this.state = state;\n }", "public void setState(Integer state) {\n this.state = state;\n }", "public void setState(Integer state) {\n this.state = state;\n }", "void setState(Object state);", "public void setBoard(final Board the_board)\n {\n my_board = the_board;\n my_board.addObserver(this);\n }", "public void setState(TileState newState) {\n\t\tthis.setState(newState, true);\n\t}", "void setState(boolean state);", "State(int[][] startBoardState, int [][] goalBoardState){\n this.currentBoardState = startBoardState;\n this.goalBoardState = goalBoardState;\n this.g_cost = 0;\n this.parentState = null;\n }", "public static void setState(States state) {\r\n\t\tcurrentState = state;\r\n\t}", "public void setState(int state) {\n\t\t\tmState = state;\n\t\t}", "public void setState(Integer state) {\n\t\tthis.state = state;\n\t}", "public void setBoard(GameToken[][] board) {\n\t\tif (board == null) {\n\t\t\tthrow new NullPointerException();\n\t\t}\n\t\t\n\t\t// get length of row\n\t\tint size = board.length;\n\t\t// check length of all columns\n\t\tfor (int row = 0; row < size; row++) {\n\t\t\tif (board[row] == null) {\n\t\t\t\tthrow new NullPointerException();\n\t\t\t}\n\t\t\t// does the column length match the row length?\n\t\t\tif (board[row].length != size) {\n\t\t\t\tthrow new IndexOutOfBoundsException();\n\t\t\t}\n\t\t}\n\t\t// all checks passed\n\t\tthis.size = size;\n\t\tthis.board = board;\n\t}", "public void resetBoard() {\n piece = 1;\n b = new Board(9);\n board = b.getBoard();\n\n board2d = new int[3][3];\n makeBoard2d();\n\n }", "public void setColor(Color boardColor) {\r\n this.BoardColor = boardColor;\r\n }", "public void setToPlaceTowerState() {\n for (int i = 0; i < cells.size(); i++) {\n if (cells.get(i) == CellState.Grass) {\n cells.set(i, CellState.ToPlaceTower);\n } else if (cells.get(i) == CellState.Chosen) {\n cells.set(i, CellState.Tower);\n }\n }\n }", "public void setState(States s) {\n\t\tthis.state = s;\n\t}", "public void setBoard(BoardSpace[][] newBoard){\n boardSpaces = newBoard;\n maxScore = 0;\n }", "public void setState(State state) {\n\t\tthis.state = state;\n\t}", "protected void setState(int value) {\r\n\t\tdState = value;\r\n\t\tstateChanged();\r\n\t\t\r\n\t\t// System debug\r\n\t\tSystem.out.println(\"State changed: \" + STATUS[dState]);\r\n\t}", "public void setState(State state) {\n this.state = state;\n }", "public void setState(State state) {\n this.state = state;\n }", "public void updateBoard() {\n notifyBoardUpdate(board);\n }", "public void setState(int i) {\n this.mState = i;\n }", "void setState(org.landxml.schema.landXML11.StateType.Enum state);", "public void setState(final State state);", "@Override\r\n\tpublic void setCell(Integer x, Integer y, Integer value) {\n\t\tgame[x][y] = value;\r\n\t}", "public void setShipState(Point xy, int state) {\r\n\t\tshipStateMap.put(xy, state);\r\n\t\tif (state==3)\r\n\t\t\tnumberOfAllowedShotsRemaining --;\r\n\t}", "public synchronized void set() {\n this.currentState = EventState.UP;\n notify();\n }", "@IcalProperty(pindex = PropertyInfoIndex.SCHEDULE_STATE,\n jname = \"scheduleState\",\n eventProperty = true,\n todoProperty = true)\n public void setScheduleState(final int val) {\n if ((val != scheduleStateNotProcessed) &&\n (val != scheduleStateProcessed) &&\n (val != scheduleStateExternalDone)) {\n throw new RuntimeException(\"org.bedework.badvalue\");\n }\n\n scheduleState = val;\n }", "public void setBoardEnabled(boolean flag) {\r\n\t\tfor (int i = 0; i < order.length; i++) {\r\n\t\t\tChessBoardBlock block = board.get(order[i]);\r\n\t\t\tblock.setEnabled(flag);\r\n//\t\t\tblock.setBorderPainted(flag);\r\n\t\t}\r\n\t}", "private void setCell(int x, int y, int newValue) {\n hiddenGrid[x][y] = newValue;\n }" ]
[ "0.70340246", "0.6885366", "0.6882225", "0.6877525", "0.68580854", "0.67117274", "0.6658703", "0.6658703", "0.65053165", "0.6487617", "0.64363533", "0.63491035", "0.63300645", "0.63265836", "0.6311303", "0.6306059", "0.63016355", "0.6297058", "0.6291854", "0.62738657", "0.62738657", "0.6272241", "0.6267545", "0.6266905", "0.62448317", "0.6231363", "0.6229621", "0.62221295", "0.6219243", "0.620149", "0.6194651", "0.6170502", "0.6154272", "0.6152963", "0.6137117", "0.61117756", "0.6102796", "0.61011183", "0.60904866", "0.608527", "0.60839444", "0.60775685", "0.6025614", "0.6025614", "0.6005931", "0.60029775", "0.5991829", "0.5986533", "0.59773594", "0.5975304", "0.59683734", "0.5942555", "0.5942555", "0.5927143", "0.59206617", "0.59164655", "0.59092385", "0.59047353", "0.59023094", "0.589981", "0.58975506", "0.58962774", "0.589042", "0.5888623", "0.58864975", "0.5881203", "0.58765125", "0.58765125", "0.58765125", "0.58765125", "0.58765125", "0.58765125", "0.58697164", "0.5869697", "0.586432", "0.58435196", "0.58421785", "0.5839228", "0.5831619", "0.58268714", "0.58156794", "0.5793336", "0.5789401", "0.578919", "0.5787885", "0.57791525", "0.57781726", "0.5767155", "0.57592607", "0.57592607", "0.57589394", "0.5758075", "0.575111", "0.57486427", "0.5748456", "0.57454455", "0.5741888", "0.57416785", "0.5739629", "0.5736378" ]
0.73301387
0
Get the status of the square on the board.
public static String getBoardStateSquare(int file, int rank) { return boardState[rank][file]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public Status getStatus() {\n return board.getStatus();\n }", "int getCellStatus(int x, int y);", "private Board getBoard() {\n return gameStatus.getBoard();\n }", "public int getStatus(int row, int column) {\n\t\treturn this.grid[row][column].getStatus();\n\t}", "private char getGameStatus() {\n int row;\n int col;\n\n Map<Character, Integer> lineCounts = new HashMap<>();\n\n for (row = 0; row < this.boardSize; row++) {\n countLine(getLineStatus(this.board[row]), lineCounts);\n }\n\n for (col = 0; col < this.boardSize; col++) {\n countLine(getLineStatus(getColumn(col)), lineCounts);\n }\n\n countLine(getLineStatus(getMajorDiag()), lineCounts);\n countLine(getLineStatus(getSubDiag()), lineCounts);\n\n boolean player1Won = lineCounts.getOrDefault(players[0].symbol, 0) > 0;\n boolean player2Won = lineCounts.getOrDefault(players[1].symbol, 0) > 0;\n boolean boardIsFull = lineCounts.getOrDefault(' ', 0) == 0;\n if (player1Won && player2Won) // both players completed lines, it is a tie\n return 'T';\n if (player1Won)\n return players[0].symbol;\n if (player2Won)\n return players[1].symbol;\n if (boardIsFull)\n return 'T';\n return '?';\n }", "public int status() \n {\n \tif (stonesCount(7,12) != 0 && stonesCount(0,5) != 0)\n \t\treturn GAME_NOT_OVER;\n \telse if (stonesCount(7,13) < stonesCount(0,6))\n \t\treturn GAME_OVER_WIN;\n \telse if (stonesCount(7,13) == stonesCount(0,6))\n \t\treturn GAME_OVER_TIE;\n \telse\n \t\treturn GAME_OVER_LOSE;\n }", "public GameStatus getStatus() {\n\t\treturn status;\n\t}", "public int gameStatus() {\n \t\tfor(int x = 0;x<3;x++) {\n \t\t\tif((Grid[x][0] == Grid[x][1]) && (Grid[x][1] == Grid[x][2]))\n \t\t\t\tif(Grid[x][0] != 0 && Grid[x][1] != 0 && Grid[x][2] != 0)\n \t\t\t\t\treturn Grid[x][0];\n \t\t}\n \t\tfor(int y=0;y<3;y++) {\n \t\t\tif((Grid[0][y] == Grid[1][y]) && (Grid[1][y] == Grid[2][y])) \n \t\t\t\tif(Grid[0][y] != 0 && Grid[1][y] != 0 && Grid[2][y] != 0)\n \t\t\t\t\treturn Grid[0][y];\n \t\t}\n \t\tif(Grid[0][0] == Grid[1][1] && Grid[1][1] == Grid[2][2]) \n \t\t\tif(Grid[0][0] != 0 && Grid[1][1] != 0 && Grid[2][2] != 0)\n \t\t\t\treturn Grid[0][0];\n \t\tif(Grid[2][0] == Grid[1][1] && Grid[1][1] == Grid[0][2])\n \t\t\tif(Grid[2][0] != 0 && Grid[1][1] != 0 && Grid[0][2] != 0)\n \t\t\t\treturn Grid[0][0];\n \t\tfor(int x = 0;x<3;x++) {\n \t\t\tfor(int y = 0;y<3;y++) {\n \t\t\t\tif(Grid[x][y] == 0)\n \t\t\t\t\treturn 0;\n \t\t\t}\n \t\t}\n \t\treturn 3;\t\t\n \t}", "public String getStatus() {\r\n if (status == null)\r\n status = cells.get(7).findElement(By.tagName(\"div\")).getText();\r\n return status;\r\n }", "public String getStateOfBoard()\n {\n // This function is used to print state of the board. such as number of coins present on the board\n String str=\"\";\n str += \"Black_Coins Count:\"+this.gameController.getCoinsCount(CoinType.BLACK) +\" Red_Coins Count:\"+this.gameController.getCoinsCount(CoinType.RED);\n return str;\n }", "public Status getStatus();", "public int getBoardState(boolean whiteTeamMoving) {\n\t\tint result = 0;\n\t\tboolean moves = doMovesExist(whiteTeamMoving);\n\n\t\tresult |= moves ? 0 : 1;\n\t\tresult |= isWhiteCheck() ? 1<<1 : 0;\n\t\tresult |= isBlackCheck() ? 1<<2 : 0;\n\t\tresult |= result == 1 ? 0 : 1<<3;\n\n\t\treturn result;\n\t}", "public Rectangle getSquare(){\n\t\treturn this.square;\n\t}", "@GET\n\t@Path(\"/status\")\n\t@Produces(MediaType.APPLICATION_JSON)\n\tpublic String getStatus() {\n\t\treturn new JSONObject().put(\"currFloor\", Constants.currFloor).put(\"movingState\", Constants.movingState).toString();\n\t}", "public int getState(int row, int col) throws ArrayIndexOutOfBoundsException {\r\n return board[row][col];\r\n }", "Integer getStatus();", "public GRect getSquare() {\n\t\treturn square;\n\t}", "public static Gamestatus getGameStatus() {\r\n\t\treturn STATUS;\r\n\t}", "public state getStatus(){\n return this.st;\n }", "public int getStatus()\n {\n synchronized (monitor())\n {\n check_orphaned();\n org.apache.xmlbeans.SimpleValue target = null;\n target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(STATUS$12, 0);\n if (target == null)\n {\n return 0;\n }\n return target.getIntValue();\n }\n }", "Square getSquare(int x, int y){\n return board[x][y];\n }", "public int getStatus ()\n {\n return status;\n }", "public int getStatus ()\n {\n return status;\n }", "public String getUiStatus() {\n\t\tif (switchInfo.getType().compareTo(\"thermostat\") == 0) {\r\n\t\t\ttry {\r\n\t\t\t\tDouble tmp = new Double((String) myISY.getCurrValue(myISY.getNodes().get(switchInfo.getSwitchAddress()),\r\n\t\t\t\t\t\tInsteonConstants.DEVICE_STATUS));\r\n\t\t\t\ttmp = tmp / 2;\r\n\t\t\t\treturn tmp.toString();\r\n\t\t\t} catch (NoDeviceException e) {\r\n\t\t\t\te.printStackTrace();\r\n\t\t\t} catch (NullPointerException e) {\r\n\t\t\t}\r\n\t\t} else if ((switchInfo.getType().compareTo(\"light\") == 0)\r\n\t\t\t\t|| (switchInfo.getType().compareTo(\"circulator\") == 0)) {\r\n\t\t\ttry {\r\n\t\t\t\tDouble tmp = new Double((String) myISY.getCurrValue(myISY.getNodes().get(switchInfo.getSwitchAddress()),\r\n\t\t\t\t\t\tInsteonConstants.DEVICE_STATUS));\r\n\t\t\t\ttmp = tmp / 255 * 100;\r\n\t\t\t\tif (tmp == 0)\r\n\t\t\t\t\treturn \"OFF\";\r\n\t\t\t\telse if (tmp == 100)\r\n\t\t\t\t\treturn \"ON\";\r\n\t\t\t\treturn \"ON \" + tmp + \"%\";\r\n\t\t\t} catch (NoDeviceException e) {\r\n\t\t\t\te.printStackTrace();\r\n\t\t\t} catch (NullPointerException e) {\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn \"\";\r\n\t}", "public int getSmileyStatus() {\n return smileyStatus;\n }", "public Status getStatus()\n {\n return (this.status);\n }", "public int getStatus();", "public int getStatus();", "public int getStatus();", "int getStatus();", "int getStatus();", "int getStatus();", "int getStatus();", "int getStatus();", "int getStatus();", "int getStatus();", "int getStatus();", "int getStatus();", "int getStatus();", "int getStatus();", "public WorkerStatus getStatus(){\r\n\t\ttry {\r\n\t\t\t//System.out.println(\"Place 1\");\r\n\t\t\treturn this.workerStatusHandler.getWorkerStatus(this.getPassword());\r\n\t\t\t\r\n\t\t} catch (IOException e) {\r\n\t\t\t//System.out.println(\"Place 2\");\r\n\t\t\te.printStackTrace();\r\n\t\t\tdead = true;\r\n\t\t\treturn null;\r\n\t\t}\r\n\t}", "public short getStatus()\r\n {\r\n return statusObj.getValue();\r\n }", "public Status getStatus()\n\t{\n\t\treturn status;\n\t}", "public int getSquareAccessibility(int row, int col) {\n return playingBoard[row][col].getAccessibility();\n }", "com.polytech.spik.protocol.SpikMessages.Status getStatus();", "com.polytech.spik.protocol.SpikMessages.Status getStatus();", "public int determineWinner() {\n\t\tif(board[1][1] != 0 && (\n\t\t\t(board[1][1] == board[0][0] && board[1][1] == board[2][2]) ||\n\t\t\t(board[1][1] == board[0][2] && board[1][1] == board[2][0]) ||\n\t\t\t(board[1][1] == board[0][1] && board[1][1] == board[2][1]) ||\n\t\t\t(board[1][1] == board[1][0] && board[1][1] == board[1][2]))){\n\t\t\treturn board[1][1];\n\t\t}\n\t\telse if (board[0][0] != 0 &&(\n\t\t\t(board[0][0] == board[0][1] && board[0][0] == board[0][2]) ||\n\t\t\t(board[0][0] == board[1][0] && board[0][0] == board[2][0]))){\n\t\t\treturn board[0][0];\n\t\t}\n\t\telse if (board [2][2] != 0 && (\n\t\t\t(board[2][2] == board[2][0] && board[2][2] == board[2][1]) ||\n\t\t\t(board[2][2] == board[0][2] && board[2][2] == board[1][2]))) {\n\t\t\treturn board[2][2];\n\t\t}\n\t\t\n\t\t//See if every square has been marked, return still in progress if not\n\t\tfor(int i = 0; i < 3; ++i) {\n\t\t\tfor(int j = 0; j < 3; ++j) {\n\t\t\t\tif (board[i][j] == 0)\n\t\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\t\n\t\t//Return tie\n\t\treturn 3;\n\t}", "public Status getStatus() {\r\n\t return status;\r\n\t }", "public Status getStatus() {\r\n return status;\r\n }", "public int getStatus()\n {\n return status;\n }", "public int getStatus(){\r\n\t\treturn this.status;\r\n\t}", "String getSwstatus();", "@SuppressWarnings(\"unused\")\n public String getStatusString() {\n\n switch (this.status) {\n case SCREEN_OFF:\n return \"screen off\";\n\n case SCREEN_ON:\n return \"screen on\";\n\n default:\n return \"unknown\";\n }\n }", "public Byte getStatus() {\n\t\treturn status;\n\t}", "public Byte getStatus() {\n\t\treturn status;\n\t}", "public Byte getStatus() {\n return status;\n }", "public Byte getStatus() {\n return status;\n }", "public Byte getStatus() {\n return status;\n }", "public Byte getStatus() {\n return status;\n }", "public Byte getStatus() {\n return status;\n }", "public Byte getStatus() {\n return status;\n }", "public Byte getStatus() {\n return status;\n }", "public Byte getStatus() {\n return status;\n }", "public Byte getStatus() {\n return status;\n }", "public Byte getStatus() {\n return status;\n }", "public Byte getStatus() {\n return status;\n }", "public Byte getStatus() {\n return status;\n }", "public Byte getStatus() {\n return status;\n }", "boolean getStatus();", "boolean getStatus();", "boolean getStatus();", "public int getStatus() {\n return status;\n }", "public int getStatus() {\n return status;\n }", "public int getStatus() {\n return status;\n }", "public int getStatus() {\n return status;\n }", "public int getStatus() {\n return status;\n }", "public Short getStatus() {\n\t\treturn status;\n\t}", "public Status getStatus()\n {\n return status;\n }", "public Byte getStatus() {\r\n return status;\r\n }", "public Byte getStatus() {\r\n return status;\r\n }", "public Byte getStatus() {\r\n return status;\r\n }", "public Byte getStatus() {\r\n return status;\r\n }", "public Byte getStatus() {\r\n return status;\r\n }", "public Byte getStatus() {\r\n return status;\r\n }", "public Byte getStatus() {\r\n return status;\r\n }", "public Integer getStatus() {\r\n return status;\r\n }", "public Integer getStatus() {\r\n return status;\r\n }", "public synchronized Status getStatus(){\n return state;\n }", "public Status getStatus() {\n return status;\n }", "public Status getStatus() {\n return status;\n }", "public Status getStatus() {\n return status;\n }", "public Status getStatus() {\n\t\treturn status;\n\t}", "public Integer getStatus() {\n return status;\n }", "public Integer getStatus() {\n return status;\n }", "public Integer getStatus() {\n return status;\n }", "public Integer getStatus() {\n return status;\n }", "public Integer getStatus() {\n return status;\n }", "public Integer getStatus() {\n return status;\n }", "public Integer getStatus() {\n return status;\n }", "public Integer getStatus() {\n return status;\n }", "public Integer getStatus() {\n return status;\n }" ]
[ "0.7923532", "0.68977916", "0.68648374", "0.6860003", "0.67127395", "0.66248846", "0.6558619", "0.65442836", "0.6484421", "0.62799764", "0.6243761", "0.62139034", "0.6213427", "0.619414", "0.6192773", "0.6189903", "0.6176924", "0.6152169", "0.61504114", "0.61456436", "0.6101935", "0.6101318", "0.6101318", "0.6100105", "0.609613", "0.60700494", "0.6066753", "0.6066753", "0.6066753", "0.60664237", "0.60664237", "0.60664237", "0.60664237", "0.60664237", "0.60664237", "0.60664237", "0.60664237", "0.60664237", "0.60664237", "0.60664237", "0.60607046", "0.6036868", "0.6035922", "0.6024847", "0.59785444", "0.59785444", "0.5971606", "0.5966055", "0.5958791", "0.59587806", "0.595738", "0.59567016", "0.5952528", "0.5951393", "0.5951393", "0.5940479", "0.5940479", "0.5940479", "0.5940479", "0.5940479", "0.5940479", "0.5940479", "0.5940479", "0.5940479", "0.5940479", "0.5940479", "0.5940479", "0.5940479", "0.5937386", "0.5937386", "0.5937386", "0.5936435", "0.5936435", "0.5936435", "0.5936435", "0.5936435", "0.5934955", "0.5925831", "0.59252936", "0.59252936", "0.59252936", "0.59252936", "0.59252936", "0.59252936", "0.59252936", "0.59190345", "0.59190345", "0.5918178", "0.5910861", "0.5910861", "0.5910861", "0.5906", "0.5900652", "0.5900652", "0.5900652", "0.5900652", "0.5900652", "0.5900652", "0.5900652", "0.5900652", "0.5900652" ]
0.0
-1
Set the status of a square on the board.
public static void setBoardStateSquare(int file, int rank, String piece) { boardState[rank][file] = piece; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public void setStatus(int row, int column, int status) {\n\t\tthis.grid[row][column].setStatus(status);\n\t}", "public boolean setSquare(int row, int col, int value) {\n if (! isStartLocation(row, col)) {\n board.setSquare(row, col, value);\n return checkRules();\n }\n return true; //no move is 'valid'\n }", "public void setTileStatus(int x, int y, TileStatus ts) throws IndexOutOfBoundsException{\n if(x < 0 || y < 0 || x >= grid.length || y >= grid[0].length) {\n throw new IndexOutOfBoundsException(\"Il n'existe pas de tuile à la position (\"+x+\",\"+y+\")\");\n }\n grid[x][y].setStatus(ts);\n }", "public synchronized void setState(Status status){\n state=status;\n if(status.equals(Status.RED)){\n updateScreen(\"red\");\n }\n else if(status.equals(Status.YELLOW)){\n updateScreen(\"yellow\");\n }\n }", "void setCurrentPosition(Square currentPosition);", "public void setSeatStatus(int row, int col, boolean status) {\n seatPlan[row][col].setStatus(status);\n }", "public void setCurrentSquare( Square square )\n\t{\n\t\tcurrentSquare = square; // set current square to argument\n\t\tcurrentSquareLocation = square.location;\n\t}", "public void changeColourSquare(int i) {\n //determines the y-index of the move, set to 0 as a default\n int colourPlace = 0;\n //searches from the top (bottom of the display) down to 0 (the top of the display)\n for (int y = currentBoard.getSizeY() - 1; y >= 0; y--) {\n //saves y + 1 to colourPlace ( + 1 offset is due to using a board where the \n //move at int i was made before this function call) when the piece is 0 and exits the loop\n if (currentBoard.getBoardValue(i, y) == 0) {\n colourPlace = y + 1;\n y = -1;\n }\n }\n\n //determines which colour to use based on the value of turn\n if (turn) {\n squares[i][colourPlace].setBackground(Color.red);\n } else {\n squares[i][colourPlace].setBackground(Color.blue);\n }\n\n }", "public void setSquare(boolean equal) {\r\n\t\tsquare = equal;\r\n\t}", "protected abstract void setCell(int x, int y, boolean state);", "public void setSquareMoveNumber(int row, int col, int moveCounter) {\n playingBoard[row][col].setMoveNumber(moveCounter);\n }", "public void setSquare(Square cell) {\n\t\tcells[cell.getRow()][cell.getColumn()] = cell; \n\t}", "public void setBoard(int row, int col, int value) {\n this.board[row][col] = value;\n }", "void setStatusColour(Color colour);", "protected void setSquare(int i, Color playerColor)\n {\n //System.out.println(\"Set \" + i + \" \" + playerColor);\n ticTacToeButtons[i].setBackground(playerColor);\n ticTacToeButtons[i].setContentAreaFilled(true);\n ticTacToeButtons[i].setEnabled(false);\n }", "public void setState(int row, int col) throws ArrayIndexOutOfBoundsException {\r\n board[row][col] = currentPlayer;\r\n }", "void setStone(int x, int y, int color);", "@Override\r\n\tpublic void placePiece(JumpInButton[][] square) {\r\n\t\tsquare[this.x][this.y].setBackground(Color.RED);\r\n\t}", "public void changeStatus(){\n Status = !Status;\n\n }", "void setBoard(Board board);", "public void markBoardSquare(int curRow, int curCol, int moveCounter) {\n setSquareVisited(curRow, curCol);\n setSquareMoveNumber(curRow, curCol, moveCounter);\n }", "private void modifyMapStatus(int status) {\n\t\tint bC = centerPoint.getX() / UNIT;\n\t\tint bR = centerPoint.getY() / UNIT;\n\n\t\tfor (int i = bR; i < bR + row; i++) {\n\t\t\tfor (int j = bC; j < bC + column; j++) {\n\t\t\t\tif(stage==1){\n\t\t\t\t\tGameView.map[i][j] = status;\n\t\t\t\t}else if(stage ==2){\n\t\t\t\t\tGameViewStage2.map[i][j] = status;\n\t\t\t\t}else {\n\t\t\t\t\tGameViewStage3.map[i][j] = status;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "@Test\n public void testSetTile()\n {\n try\n {\n Square s = new Square();\n\n s.setTile(Tile.E); // Add a tile\n\n assertEquals(Tile.E, s.getTile()); // Check the tile is now on the square\n assertTrue(s.isOccupied()); // Check the status is now true\n }\n catch(Exception ex)\n {\n fail(\"No exception should be thrown when setting a Tile onto the square.\");\n }\n }", "public void setSquareVisited(int row, int col) {\n playingBoard[row][col].setVisited(true);\n }", "public synchronized void setMyGameStatus(boolean status)\n {\n \tgameStatus=status;\n }", "public void set(int x,int y) {\n\tif ( ! (board[x][y] == 9)) {\n\t board[x][y] = 1;\n\t}\n }", "public void testSetCell()\r\n {\r\n board.loadBoardState(\"OOOO\",\r\n \"OOOO\",\r\n \"O+OO\",\r\n \"OOOO\");\r\n board.setCell(1, 2, MineSweeperCell.FLAGGED_MINE);\r\n assertBoard(board, \"OOOO\",\r\n \"OOOO\",\r\n \"OMOO\",\r\n \"OOOO\");\r\n }", "public void setStatus(Status newStatus){\n status = newStatus;\n }", "void setStatus(STATUS status);", "public void turnOn() {\n this.status = true;\n update(this.redValue, this.greenValue, this.blueValue);\n }", "public void toggle() {\n if (currentPlayer.equals(\"red\")) {\n currentColor = BLUE_COLOUR;\n currentPlayer = \"blue\";\n } else {\n currentColor = RED_COLOUR;\n currentPlayer = \"red\";\n }\n //change color of grid\n changeColor();\n }", "public void setStatus(boolean newStatus);", "void highlightSquare(boolean highlight, Button button, int row, int column, ChessPiece piece);", "@Override\r\n\tpublic void setCell(Integer x, Integer y, Integer value) {\n\t\tgame[x][y] = value;\r\n\t}", "public void testSquare(){\n\t\tSquare s = new Square(false);\n\t\ts.toggleSquare();\n\t\tassertTrue(s.isToggle());\n\t\ts.setToggle(false);\n\t\tassertFalse(s.isToggle());\n\n\t}", "public void setOpBoardMove(int row, int col, int oppiece)\n\t{\n\t\tboard[row][col] = oppiece;\n\t}", "private void updateStatus(int row, int col) {\n\t\tCell cell = grid.getGridIndex(row, col);\n\t\tcell.calculateNextState(grid.getNeighbors(row, col));\n\t\tif (cell instanceof Neighbor) {\n\t\t\tNeighbor person = (Neighbor) cell;\n\t\t\tString name = person.getClass().getName();\n\t\t\tif (!cellSizes.containsKey(name)) {\n\t\t\t\tcellSizes.put(name, 0);\n\t\t\t}\n\t\t\tcellSizes.put(name, cellSizes.get(name) + 1);\n\t\t\tif (!person.Satisfied())\n\t\t\t\tupsetNeighbors.add(person);\n\t\t} else {\n\t\t\tavailableSpaces.add(cell);\n\t\t}\n\t}", "public void updateCell() {\n alive = !alive;\n simulator.getSimulation().changeState(xPosition, yPosition);\n setColor();\n }", "public void status(leapstream.scoreboard.core.model.Status status) {\n Stati stati = status.is();\n foreground(stati);\n background(stati);\n label.text(\"\" + stati);\n }", "void setGreen(int x, int y, int value);", "boolean setStone(int x, int y);", "@Override\n\tpublic void squareChanged(int row, int col) {\n\t\tsquares[row][col].setText(game.getCurrentPlayer().name());\n\t}", "private void setCell(int x, int y, int newValue) {\n hiddenGrid[x][y] = newValue;\n }", "public void setStatus(int status)\n {\n synchronized (monitor())\n {\n check_orphaned();\n org.apache.xmlbeans.SimpleValue target = null;\n target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(STATUS$12, 0);\n if (target == null)\n {\n target = (org.apache.xmlbeans.SimpleValue)get_store().add_element_user(STATUS$12);\n }\n target.setIntValue(status);\n }\n }", "public void setCommand(String sq, Piece p) {\r\n if (!_board.ROW_COL.matcher(sq).matches()) {\r\n error(\"invalid square: %s%n\", sq);\r\n return;\r\n }\r\n _board.set(sq.charAt(0) - 'a' + 1, sq.charAt(1) - '0', p, p.opposite());\r\n _playing = false;\r\n _command.repaint();\r\n }", "public void setTileStatus(int r, int c, int val) {\n\t\tgameBoard.setTileStatus(r, c, val);\n\t}", "public void setStatus(Boolean s){ status = s;}", "public synchronized void setMyTurn(boolean status)\n {\n \tmyTurn[0]=status;\n }", "private void paintSquare(PositionInBoard position, int numberOfMovement){\n board[position.row()][position.column()].setBackground(Color.red);\n board[position.row()][position.column()].setText(\"\"+numberOfMovement);\n\n Font font = new Font(\"Arial\", Font.PLAIN, 30);\n board[position.row()][position.column()].setFont(font);\n board[position.row()][position.column()].setHorizontalAlignment(SwingConstants.CENTER);\n }", "boolean setPiece(int x, int y, Piece.OthelloPieceColour colour) {\n return false;\n }", "@Override\n\tpublic void actionPerformed(ActionEvent e) {\n\t\t// Toggles the active square and updates the boundary\n\t\tMove m = new ToggleSquareMove(level.getBoard().getActiveSquare(),level);\n\t\tif(m.doMove()) {\n\t\t\tbuilder.pushMove(m, false);\t\n\t\t}\n\t\t\n\t\tboardView.repaint();\n\t}", "void setStatus(final UserStatus status);", "public void setBoard(){\n \n\t m_Pieces[3][3]= WHITE_PIECE;\n m_Pieces[4][4]= WHITE_PIECE;\n m_Pieces[3][4]= BLACK_PIECE;\n m_Pieces[4][3]= BLACK_PIECE;\n for(int x=0;x<WIDTH;x++){\n for(int y=0;y<HEIGHT;y++){\n if(m_Pieces[x][y]==null){\n m_Pieces[x][y]=NONE_PIECE;\n }\n }\n }\n }", "void setStatus(int status);", "public void changeSquarePlayer(int row, int col, String name){\n board[row][col].setName(name);\n }", "public void setStatus(int status) {\n\t\tswitch (status) {\r\n\t\tcase 1:\r\n\t\t\tthis.status = FRESHMAN;\r\n\t\t\tbreak;\r\n\t\tcase 2:\r\n\t\t\tthis.status = SOPHOMORE;\r\n\t\t\tbreak;\r\n\t\tcase 3:\r\n\t\t\tthis.status = JUNIOR;\r\n\t\t\tbreak;\r\n\t\tcase 4:\r\n\t\t\tthis.status = SENIOR;\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}", "public void doClickSquare(int row, int col) {\n if (!gameInProgress()) {\n console(\"Click \\\"New Game\\\" to start a new game.\");\n } else {\n \n if (currentPlayer() == CheckersData.BLACK\n && aiBlack == true) {\n //console(\"Click to move black\");\n try{Thread.sleep(50);}catch(Exception e){System.out.println(\"thread.sleep error: \" + e.toString());}\n AIblackMove blacksMove = new AIblackMove(this,legalMoves);\n doMakeMove(blacksMove.nextMove());\n return;\n } else if (currentPlayer() == CheckersData.RED\n && aiRed == true) {\n //console(\"Click to move red\");\n try{Thread.sleep(50);}catch(Exception e){System.out.println(\"thread.sleep error: \" + e.toString());}\n AIredMove redsMove = new AIredMove(this,legalMoves);\n //AIredMoveBetter redsMove = new AIredMoveBetter(this, legalMoves);\n doMakeMove(redsMove.nextMove());\n return;\n }\n\n\n /* If the player clicked on one of the pieces that the player\n can move, mark this row and col as selected and return. (This\n might change a previous selection.) Reset the message, in\n case it was previously displaying an error message. */\n for (int i = 0; i < legalMoves.length; i++) {\n System.out.println(\"In one\");\n if (legalMoves[i].fromRow == row && legalMoves[i].fromCol == col) {\n selectedRow = row;\n selectedCol = col;\n if (currentPlayer == CheckersData.RED) {\n console(\"RED: Make your move.\");\n } else {\n console(\"BLACK: Make your move.\");\n }\n refreshBoard();\n return;\n }\n }\n\n /* If no piece has been selected to be moved, the user must first\n select a piece. Show an error message and return. */\n if (selectedRow < 0) {\n System.out.println(\"In two\");\n\n console(\"Click the piece you want to move.\");\n return;\n }\n\n /* If the user clicked on a square where the selected piece can be\n legally moved, then make the move and return. */\n for (int i = 0; i < legalMoves.length; i++) {\n System.out.println(\"In three\");\n\n if (legalMoves[i].fromRow == selectedRow && legalMoves[i].fromCol == selectedCol\n && legalMoves[i].toRow == row && legalMoves[i].toCol == col) {\n doMakeMove(legalMoves[i]);\n return;\n }\n }\n\n /* If we get to this point, there is a piece selected, and the square where\n the user just clicked is not one where that piece can be legally moved.\n Show an error message. */\n console(\"Click the square you want to move to.\");\n }\n }", "void updateBoard() {\r\n\t\tfor (int x = 0; x < length; x++) {\r\n\t\t\tfor (int y = 0; y < length; y++) {\r\n\t\t\t\tif (filled[x][y]) {\r\n\t\t\t\t\t// Draw filled square\r\n\t\t\t\t\tdouble rand = Math.random();\r\n\t\t\t\t\tColor use = new Color(0, 0, 0);\r\n\t\t\t\t\tif (rand < .25) {\r\n\t\t\t\t\t\tuse = a;\r\n\t\t\t\t\t} else if (rand < .50) {\r\n\t\t\t\t\t\tuse = b;\r\n\t\t\t\t\t} else if (rand < .75) {\r\n\t\t\t\t\t\tuse = c;\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tuse = d;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tJSquare element = new JSquare(this.getWidth() / length, this.board.getHeight() / length, use, true);\r\n\t\t\t\t\telement.addMouseListener(this);\r\n\t\t\t\t\tboard.add(element);\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// Draw empty square\r\n\t\t\t\t\tJSquare element = new JSquare(this.getWidth() / length, this.board.getHeight() / length,\r\n\t\t\t\t\t\t\tnew Color(192, 192, 192), false);\r\n\t\t\t\t\telement.addMouseListener(this);\r\n\t\t\t\t\tboard.add(element);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}", "public void setStatus(int status);", "public void setStatus(int status);", "Cell(int xpos, int ypos, int status)\n {\n this.X = xpos;\n this.Y = ypos;\n this.status = status;\n if (status == 0)\n {\n cell.setVisible(false);\n }\n cell.setFill(Color.WHITE);\n }", "public void setStatus(boolean stat) {\n\t\tstatus = stat;\n\t}", "void setRed(int x, int y, int value);", "public void updateBoard(Color color, int i, int y) {\r\n\t\tif (color == Color.yellow) {\r\n\t\t\tboard[i][y] = '1';\r\n\r\n\t\t} else if (color == Color.red) {\r\n\t\t\tboard[i][y] = '2';\r\n\t\t}\r\n\t}", "public void setShip(int row, int column, boolean value) {\n\t\tthis.grid[row][column].setShip(value);\n\t}", "void setStatus(String status);", "public void setStatus(int status) {\n\t\tthis.status = (byte) status;\n\t\trefreshStatus();\n\t}", "@Focus\n\tpublic void setFocus() \n\t{\n\t\t\tfor(int r = Board.LENGTH - 1; r >= 0; r--)\n\t\t\t{\t\n\t\t\t\t\tfor(int c=0;c<Board.LENGTH;c++)\n\t\t\t\t\t{\t\n\t\t\t\t\t\tsquares[r][c+1].setBackground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\tif(((Square) squares[r][c+1].getData()).isLegal())//It returns the legal attribute wrong\n\t\t\t\t\t\t{squares[r][c+1].setBackground(Display.getDefault().getSystemColor(SWT.COLOR_YELLOW));}\n\t\t\t\t\t\t\n\t\t\t\t\t\tPiece piece = ((Square) squares[r][c+1].getData()).getPiece();\n\t\t\t\t\t\t\n\t\t\t\t\t\tif(piece == null)\t\n\t\t\t\t\t\t\tsquares[r][c+1].setImage(IconHandler.getBlankIcon());\t\t\t\t\t\t\t\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tsquares[r][c+1].setImage(piece.getIcon());\t\t\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t}\t\t\n\t}", "public void addToBoard(Location location, State state)\n {\n for (Node node : gridPaneBoard.getChildren())\n if (GridPane.getColumnIndex(node) == location.getX() && GridPane.getRowIndex(node) == location.getY())\n {\n Rectangle rectangle = ((Rectangle) node);\n switch(state)\n {\n case HEAD:\n rectangle.setFill(Color.DARKGREEN);\n break;\n case TAIL:\n rectangle.setFill(Color.GREEN);\n score++;\n break;\n case FOOD:\n rectangle.setFill(Color.RED);\n break;\n }\n labelScore.setText(\"Wynik: \" + score);\n }\n }", "public void setStatus(boolean newstatus){activestatus = newstatus;}", "private void stateChanged() {\n\t\tfor (Row r : containingRows) {\n\t\t\tr.selectSquare(this);\n\t\t}\n\t}", "public void setCell(int dim, int row, int col ) {\n\n\t\tCell value = getEnumCell();\n\n\t\tif(isEmpty( dim, row, col)){\n\n\t\t\tboard[dim][row][col]= value;\n\n\t\t\tturn++;\n\t\t}\n\n\t\t//\t\telse System.out.println(value.toString() + \" cannot play there. Choose another location for\" + value.toString() + \" .\");\n\n\n\t}", "void doMove(int move, int piece) {\n //makes a move on the offscreen board\n currentBoard.makeMove(move, piece);\n //displays the move in the GUI\n changeColourSquare(move);\n //changes turn\n turn = !turn;\n }", "public void setBoard(Board board){this.board = board;}", "void highlightCheckSquare(boolean highlight, Button button, int row, int column, CenterPiece piece);", "public boolean setFlag(int x, int y) {\t\n\t\tif (util.wrongPosition(x, y)){\n\t\t\tSystem.out.println(\"Not a valid position\");\n\t\t\treturn false;\n\t\t}\n\t\tgameBoard[x][y] = flagLogic(x, y);\n\t\treturn true;\n\t}", "void updateRoomStatus(long roomId, int status);", "private void setTurn() {\n if (turn == black) {\n turn = white;\n } else {\n turn = black;\n }\n }", "public synchronized final void setStatus(int sts) {\n\t\tm_status = sts;\n\t\tnotifyAll();\n\t}", "public void setStatus(String stat)\n {\n status = stat;\n }", "public synchronized void setStatus(Status stat) {\n if (!isMutable()) {\n throw new IllegalStateException(\n \"This TestResult is no longer mutable!\");\n }\n\n if (stat == null) {\n throw new IllegalArgumentException(\n \"TestResult status cannot be set to null!\");\n }\n\n // close out message section\n sections[0].setStatus(null);\n\n execStatus = stat;\n\n if (execStatus == inProgress) {\n execStatus = interrupted;\n }\n\n // verify integrity of status in all sections\n for (Section section : sections) {\n if (section.isMutable()) {\n section.setStatus(incomplete);\n }\n }\n\n props = PropertyArray.put(props, SECTIONS,\n StringArray.join(getSectionTitles()));\n props = PropertyArray.put(props, EXEC_STATUS,\n execStatus.toString());\n\n // end time now required\n // mainly for writing in the TRC for the Last Run Filter\n if (PropertyArray.get(props, END) == null) {\n props = PropertyArray.put(props, END, formatDate(new Date()));\n }\n\n // this object is now immutable\n notifyCompleted();\n }", "void setBlue(int x, int y, int value);", "public void refreshDisplay(){\r\n for (int i = 0; i < 6; i++) {\r\n for (int j = 0; j < 7; j++) {\r\n switch (boardRep[i][j]) { //maybe not best style to have default red but whatever (change board\r\n case 0:\r\n boardSquares[i][j].setBackground(Color.WHITE);\r\n break;\r\n case 1:\r\n boardSquares[i][j].setBackground(Color.BLACK);\r\n break;\r\n default:\r\n boardSquares[i][j].setBackground(Color.RED);\r\n break;\r\n }\r\n }\r\n }\r\n \r\n if (blackToPlay){ //change to move squares\r\n for (int i = 0; i < 7; i++) {\r\n moveSelect[i].setBackground(Color.BLACK);\r\n }\r\n } else{\r\n for (int i = 0; i < 7; i++) {\r\n moveSelect[i].setBackground(Color.RED);\r\n }\r\n }\r\n \r\n \r\n }", "void setStatus(TaskStatus status);", "public void setCellState(int newState) {\n this.myState = newState;\n }", "private void updateSideRectColor() {\n this.sideRect.setFill(controller.getCurrentSide()\n .toString().equals(\"White\") ? Color.WHITE : Color.BLACK);\n }", "public boolean setPiece (int x, int y, OthelloPiece colour) {\n m_Pieces[x][y]=colour;\n \n return true;\n \n }", "public void setStatus(int value) {\n this.status = value;\n }", "public void setStatus(int value) {\n this.status = value;\n }", "public void change_status(int pos) {\n\t\tif (dragoes[pos].getStatus() != 0 && dragoes[pos].getStatus() != 1)\n\t\t\treturn;\n\t\tint random = 1 + (int)(Math.random()*4);\n\t\tif (random == 1) {\n\t\t\tif (dragoes[pos].getStatus() == 1) {\n\t\t\t\tdragoes[pos].setStatus(0);\n\t\t\t\tchange_dragon_pos(pos);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tdragoes[pos].setStatus(1);\n\t\t\t\tchange_dragon_pos(pos);\n\t\t\t}\n\t\t}\n\t}", "public void setCell(int color) {\r\n\t\tSound sound = Assets.manager.get(Assets.CLICK_SOUND);\r\n\t\tsound.play();\r\n\t\toccupied = color;\r\n\t\tif (color == -1) {\r\n\t\t\tpiece = new Image(Assets.manager.get(Assets.RED_TXT, Texture.class));\r\n\t\t} else {\r\n\t\t\tpiece = new Image(Assets.manager.get(Assets.YELLOW_TXT, Texture.class));\r\n\t\t}\r\n\t\tpiece.setPosition(img.getX() + OFFSET, img.getY() + OFFSET);\r\n\t\tstage.addActor(piece);\r\n\t}", "public void setCell(int row, int col, String val) {\n board[row][col] = val;\n }", "void updateRoomStatus(String username, long roomId, int status);", "@External\n\tpublic void set_game_status(String _status,Address _scoreAddress) {\n\t\tAddress sender = Context.getCaller();\n\t\tif ( !this.get_admin().contains(sender)) {\n\t\t\tContext.revert(\"Sender not an admin\");\n\t\t}\n\t\tif (!STATUS_TYPE.contains(_status)) {\n\t\t\tContext.revert(\"Invalid status\");\n\t\t}\n\t\tString statusScoreAddress = this.status_data.get(_scoreAddress);\n\t\tif(_status.equals(\"gameRejected\") && !statusScoreAddress.equals(\"gameReady\") ) {\n\t\t\tContext.revert(\"This game cannot be rejected from state \" +statusScoreAddress );\n\t\t}\n\t\tif(_status.equals(\"gameApproved\") && !(\n\t\t\t\tstatusScoreAddress.equals(\"gameReady\") || statusScoreAddress.equals(\"gameSuspended\")\n\t\t\t\t)) {\n\t\t\tContext.revert(\"This game cannot be approved from state \" +statusScoreAddress );\n\t\t}\n\t\tif(_status.equals(\"gameSuspended\") && !statusScoreAddress.equals(\"gameApproved\")) {\n\t\t\tContext.revert(\"Only approved games may be suspended.\");\n\t\t}\n\t\tif(_status.equals(\"gameDeleted\") && !statusScoreAddress.equals(\"gameSuspended\")) {\n\t\t\tContext.revert(\"Only suspended games may be deleted.\");\n\t\t}\n\t\t\n\t\tthis.status_data.set(_scoreAddress, statusScoreAddress); \t\n\t\t\n\t}", "public void setStatus(Status status) {\r\n\t this.status = status;\r\n\t }", "public void setStatus(StatusEnum status) {\n this.status = status;\n }", "public static void setPieceInBoard(int[] piece, int pos) {\n for (int f = 0; f < ColorFrames.FRAMES_DIM; ++f) { // For each frame dimension\n int color = piece[f];\n if (color != ColorFrames.NO_FRAME) {\n Panel.printFrame(f, color, pos); // Displays the frame with (f) dimension and (color)\n Panel.clearFrame(f, 0); // Clean the frame of piece.\n pieces[pos - 1][f] = color;\n }\n }\n\n checkGridPos(pos);\n }", "public Color setSquareColor(int num) {\n\t\tColor color = null;\r\n\t\tswitch (num) {\r\n\t\tcase 1:\r\n\t\t\tcolor = new Color(192, 80, 77);\r\n\t\t\tbreak;\r\n\t\tcase 2:\r\n\t\t\tcolor = new Color(155, 187, 89);\r\n\t\t\tbreak;\r\n\t\tcase 3:\r\n\t\t\tcolor = new Color(254, 0, 133);\r\n\t\t\tbreak;\r\n\t\tcase 4:\r\n\t\t\tcolor = new Color(247, 150, 70);\r\n\t\t\tbreak;\r\n\t\tcase 5:\r\n\t\t\tcolor = new Color(128, 100, 162);\r\n\t\t\tbreak;\r\n\t\tcase 6:\r\n\t\t\tcolor = new Color(75, 172, 198);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\treturn color;\r\n\r\n\t}", "public void setPiece(int x, int y, Piece piece) {\n \tboard[y][x] = piece;\n }", "public void updateBoard(int[][] board, int piece){\r\n this.board=board;\r\n this.piece=piece;\r\n columns = board.length;\r\n rows = board[0].length;\r\n save = Math.min((size / columns), (size / rows));\r\n this.repaint();\r\n repaint();\r\n }" ]
[ "0.6719838", "0.66498065", "0.6514867", "0.6479449", "0.647936", "0.642706", "0.64005655", "0.63905084", "0.6138831", "0.6098137", "0.6097601", "0.6080075", "0.6062813", "0.60589087", "0.6024839", "0.6021784", "0.6003469", "0.59961724", "0.5991198", "0.59906244", "0.59724325", "0.5960668", "0.59556013", "0.59551835", "0.59226847", "0.5919067", "0.5905145", "0.5878369", "0.5871197", "0.5859139", "0.58534783", "0.5852708", "0.584999", "0.5847077", "0.5845512", "0.5819768", "0.58166754", "0.5810452", "0.5803451", "0.5801538", "0.579498", "0.57910043", "0.57871085", "0.5777477", "0.57751155", "0.5770317", "0.57532394", "0.57383347", "0.57312065", "0.5730807", "0.57307285", "0.572582", "0.5716119", "0.57112217", "0.5704546", "0.56988204", "0.56970125", "0.5685986", "0.56823957", "0.56823957", "0.5670019", "0.5662239", "0.5654485", "0.56544757", "0.5649745", "0.56467116", "0.56430864", "0.5641072", "0.56379014", "0.5630802", "0.56306756", "0.5629944", "0.5616422", "0.56118786", "0.56053376", "0.5601957", "0.5582593", "0.5580982", "0.5571327", "0.5563736", "0.55627745", "0.555798", "0.5554175", "0.5553918", "0.5549981", "0.55484897", "0.5546409", "0.5543911", "0.5543911", "0.55410033", "0.5538859", "0.5523494", "0.55203915", "0.5518856", "0.5515932", "0.55154824", "0.5514314", "0.5510676", "0.5508665", "0.5505795" ]
0.5952176
24
The main method of the program. Get the pgn content from the pgn file and use the String as a variable to pass to methods to get the tagValues and the final position.
public static void main(String[] args) { String pgn = ""; try { pgn = new String(Files.readAllBytes(Paths.get(args[0]))); } catch (Exception e) { e.printStackTrace(); } System.out.println("Event: " + tagValue("Event", pgn)); System.out.println("Site: " + tagValue("Site", pgn)); System.out.println("Date: " + tagValue("Date", pgn)); System.out.println("Round: " + tagValue("Round", pgn)); System.out.println("White: " + tagValue("White", pgn)); System.out.println("Black: " + tagValue("Black", pgn)); System.out.println("Result: " + tagValue("Result", pgn)); System.out.println("Final Position: " + finalPosition(pgn)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static void main(String[] args) throws ParseException {\n String text;\n\n File file;\n\n /* pdfStripper = null;\n pdDoc = null;\n cosDoc = null;\n */ String parsed = parseWithTika();\n file = new File(filePath);\n try {\n /* parser = new PDFParser(new FileInputStream(file)); // update for PDFBox V 2.0\n parser.parse();\n cosDoc = parser.getDocument();\n pdfStripper = new PDFTextStripper();\n pdDoc = new PDDocument(cosDoc);\n pdDoc.getNumberOfPages();\n */ //pdfStripper.setStartPage(1);\n //pdfStripper.setEndPage(10);\n /* text = pdfStripper.getText(pdDoc);\n String resultString = text.replaceAll(\"\\\\p{C}|\\\\p{Sm}|\\\\p{Sk}|\\\\p{So}\", \" \");\n */\n\n //testDictionary();\n testOpenNlp(parsed);\n testOpenNlp(\"anas al bassit\");\n testOpenNlp(\"Anas Al Bassit\");\n testOpenNlp(\"barack obama\");\n testOpenNlp(\"Barack Obama\");\n\n\n System.out.println();\n } catch (IOException e) {\n e.printStackTrace();\n }\n// catch (ParseException e) {\n// e.printStackTrace();\n// }\n }", "public String parseSrc() throws Exception{\n\t\tr = new FileReader(userArg); \r\n\t\tst = new StreamTokenizer(r);\r\n\t\t st.eolIsSignificant(true);\r\n\t\t st.commentChar(46);\r\n\t\t st.whitespaceChars(9, 9);\r\n\t\t st.whitespaceChars(32, 32);\r\n\t\t st.wordChars(39, 39);\r\n\t\t st.wordChars(44, 44);\r\n\t\t \r\n\t\t //first we check for a specified start address\r\n\t\t while (InstructionsRead < 2) {\r\n\t\t \tif (st.sval != null) {\r\n\t\t \t\tInstructionsRead++;\r\n\t\t \t\tif (st.sval.equals(\"START\")) {\r\n\t\t \t\twhile(st.ttype != StreamTokenizer.TT_NUMBER) {\r\n\t\t \t\t\tst.nextToken();\r\n\t\t \t\t}\r\n\t\t \t\tDDnval = st.nval;\r\n\t\t \t\tstartAddress = Integer.parseInt(\"\" + DDnval.intValue(), 16);\r\n\t\t \t\tlocctr = startAddress;\r\n\t\t \t\tsLocctr = Integer.toHexString(locctr.intValue());\r\n\t\t \t\tif (sLocctr.length() == 1) {\r\n\t\t \t\t\tSystem.out.println(\"locctr: 000\" + Integer.toHexString(locctr.intValue()));\r\n\t\t \t\t}\r\n\t\t \t\telse if (sLocctr.length() == 2) {\r\n\t\t \t\t\tSystem.out.println(\"locctr: 00\" + Integer.toHexString(locctr.intValue()));\r\n\t\t \t\t}\r\n\t\t \t\telse if (sLocctr.length() == 3 ) {\r\n\t\t \t\t\tSystem.out.println(\"locctr: 0\" + Integer.toHexString(locctr.intValue()));\r\n\t\t \t\t}\r\n\t\t \t\telse {\r\n\t\t \t\t\tSystem.out.println(\"locctr: \" + Integer.toHexString(locctr.intValue()));\r\n\t\t \t\t}\r\n\t\t \t\t//writer.write(\"\" + locctr); //should write to IF, not working yet 2/15/2011\r\n\t\t \t\tstartSpecified = true;\r\n\t\t \t\t}\r\n\t\t \t\telse if (!st.sval.equals(\"START\") && InstructionsRead < 2) { //this should be the program name, also could allow for label here potentially...\r\n\t\t \t\t\t//this is the name of the program\r\n\t\t \t\t\t//search SYMTAB for label etc. \r\n\t\t \t\t\tname = st.sval;\r\n\t\t \t\t}\r\n\t\t \t}\r\n\t\t st.nextToken();\r\n\t\t }\r\n\t\t if (!startSpecified) {\r\n\t\t \tstartAddress = 0;\r\n\t\t \tlocctr = startAddress;\r\n\t\t }\r\n\t\t startAddress2 = startAddress;\r\n\t\t /*\r\n\t\t ATW = Integer.toHexString(startAddress2.intValue());\r\n\t\t \r\n\t\t for (int i = 0; i<(6-ATW.length()); i++){\r\n\t\t \tmyWriter.write(\"0\");\r\n\t\t }\r\n\t\t myWriter.write(ATW);\r\n\t\t myWriter.newLine();//end of line for now; in ReadIF when this line is read and translated to object code, the program length will be tacked on the end\r\n\t\t */\r\n\t\t \r\n\t\t //Now that startAddress has been established, we move on to the main parsing loop\r\n\t\t while (st.ttype != StreamTokenizer.TT_EOF) { //starts parsing to end of file\r\n\t\t \t//System.out.println(\"Stuck in eof\");\r\n\t\t \t//iLocctr = locctr.intValue();\r\n\t\t \tinstFound = false;\r\n\t\t \topcodeDone = false;\r\n\t\t \tlabelDone = false;\r\n\t\t \tmoveOn = true;\r\n\t\t \t//constantCaseW = false;\r\n\t\t \tconstantCaseB = false;\r\n\t\t \txfound = false;\r\n\t\t \tcfound = false;\r\n\t\t \t\r\n\t\t \tInstructionsRead = 0; //init InsRead to 0 at the start of each line\r\n\t\t \tSystem.out.println(\"new line\");\r\n\t\t \tSystem.out.println(\"Ins read: \" + InstructionsRead);\r\n\t\t \tsLocctr = Integer.toHexString(locctr.intValue());\r\n\t \t\tif (sLocctr.length() == 1) {\r\n\t \t\t\tSystem.out.println(\"locctr: 000\" + Integer.toHexString(locctr.intValue()));\r\n\t \t\t}\r\n\t \t\telse if (sLocctr.length() == 2) {\r\n\t \t\t\tSystem.out.println(\"locctr: 00\" + Integer.toHexString(locctr.intValue()));\r\n\t \t\t}\r\n\t \t\telse if (sLocctr.length() == 3 ) {\r\n\t \t\t\tSystem.out.println(\"locctr: 0\" + Integer.toHexString(locctr.intValue()));\r\n\t \t\t}\r\n\t \t\telse {\r\n\t \t\t\tSystem.out.println(\"locctr: \" + Integer.toHexString(locctr.intValue()));\r\n\t \t\t}\r\n\t\t \tif (foundEnd()) {\r\n\t\t \t\tbreak;\r\n\t\t \t}\r\n\t\t \twhile (st.ttype != StreamTokenizer.TT_EOL) {//breaks up parsing by lines so that InstructionsRead will be a useful count\r\n\t\t \t\t\r\n\t\t \t\tmoveOn = true;\r\n\t\t \t\tif (st.ttype == StreamTokenizer.TT_WORD) { \r\n\t\t \t\t\tInstructionsRead++;\r\n\t\t \t\t\tSystem.out.println(st.sval);\r\n\t\t \t\t\tSystem.out.println(\"Instructions Read: \" + InstructionsRead);\r\n\t\t \t\t\tif (foundEnd()) {\r\n\t\t \t\t\t\tbreak;\r\n\t\t \t\t\t}\r\n\t\t \t\t\t/*\r\n\t\t \t\t\t * The whole instructinsread control architecture doesn't quite work, because\r\n\t\t \t\t\t * the ST doesn't count the whitespace it reads in. This is by design because\r\n\t\t \t\t\t * the prof specified that whitespace is non-regulated and thus we cannot\r\n\t\t \t\t\t * predict exactly how many instances of char dec value 32 (space) will appear\r\n\t\t \t\t\t * before and/or between the label/instruction/operand 'fields'. \r\n\t\t \t\t\t * \r\n\t\t \t\t\t * What we could try alternatively is to structure the control around'\r\n\t\t \t\t\t * the optab, since it it static and populated pre-runtime. The schema might\r\n\t\t \t\t\t * go something like this: first convert whatever the sval or nval is to string.\r\n\t\t \t\t\t * Then call the optab.searchOpcode method with the resultant string as the input\r\n\t\t \t\t\t * parameter. If the string is in optab then it is an instruction and the ST is in the\r\n\t\t \t\t\t * instruction 'field' and boolean foundInst is set to true. If it is not in optab AND a boolean variable foundInst which resets to\r\n\t\t \t\t\t * false at the beginning of each new line is still false, then it is a label being declared in the label 'field'\r\n\t\t \t\t\t * If it is not in the optab AND foundInst is true, then the ST is at the operand 'field'.\r\n\t\t \t\t\t * This should work even if the prof has a crappy line with just a label declaration and no instruction or operand, because there\r\n\t\t \t\t\t * definitely cannot be an operand without an instruction...\r\n\t\t \t\t\t */\r\n\t\t \t\t\tif (instFound){\r\n\t\t \t\t\t\tprocessOperand(st);\r\n\t\t \t\t\t}\r\n\t\t \t\t\tif (!instFound) {//this is either label or instruction field\r\n\t\t \t\t\t\t//before anything, search optab to see if this might be the opcode\r\n\t\t \t\t\t\t//if it is an opcode, send it to the opcode processing function\r\n\t\t \t\t\t\tif (st.sval.equals(\"WORD\") || st.sval.equals(\"BYTE\")){//these are the directives... not technically instructions, but they go in the instruction field\r\n\t\t \t\t\t\t\tresCount = 0;\r\n\t\t \t\t\t\t\tif (st.sval.equals(\"WORD\")){\r\n\t\t \t\t\t\t\t\tif (hexDigitCount >= 55){\r\n\t\t \t\t\t\t\t\t\tnewTHandle();\r\n\t\t \t\t\t\t\t\t}\r\n\t\t \t\t\t\t\t\thexDigitCount += 6;\r\n\t\t \t\t\t\t\t}\r\n\t\t \t\t\t\t\tif (st.sval.equals(\"BYTE\")){\r\n\t\t \t\t\t\t\t\tconstantCaseB = true;\r\n\t\t \t\t\t\t\t}\r\n\t\t \t\t\t\t\tinstFound = true;\r\n\t\t \t\t\t\t\tprocessOpcode(st);\r\n\t\t \t\t\t\t}\r\n\t\t \t\t\t\telse if (st.sval.equals(\"RESW\") || st.sval.equals(\"RESB\")){//these are the directives... not technically instructions, but they go in the instruction field\r\n\t\t \t\t\t\t\tresCount++;\r\n\t\t \t\t\t\t\tnewTHandle();\r\n\t\t \t\t\t\t\tinstFound = true;\r\n\t\t \t\t\t\t\tprocessOpcode(st);\r\n\t\t \t\t\t\t}\r\n\t\t \t\t\t\telse if (optab.searchOpcode(st.sval)) {//if true this is the instruction\r\n\t\t \t\t\t\t\tresCount = 0;\r\n\t\t \t\t\t\t\tif (hexDigitCount >= 55){\r\n\t \t\t\t\t\t\t\tnewTHandle();\r\n\t \t\t\t\t\t\t}\r\n\t\t \t\t\t\t\thexDigitCount += 6;\r\n\t\t \t\t\t\t\tinstFound = true;\r\n\t\t \t\t\t\t\tprocessOpcode(st);\r\n\t\t \t\t\t\t\t//InstructionsRead++;\r\n\t\t \t\t\t\t}\r\n\t\t \t\t\t\telse {//otherwise this is the label\r\n\t\t \t\t\t\t\tprocessLabel(st);\r\n\t\t \t\t\t\t}\r\n\t\t \t\t\t\t\r\n\t\t \t\t\t\t\r\n\t\t \t\t\t\t\r\n\t\t \t\t\t}\r\n\t\t \t\t\t//else{ //if instFound is true, this must be the operand field\r\n\t\t \t\t\t\t\r\n\t\t \t\t\t\t//processOperand(st);\r\n\t\t \t\t\t//}\r\n\t\t \t\t\t//if (InstructionsRead == 3) {//this is the operand field\r\n\t\t \t\t\t\t//processOperand();\r\n\t\t \t\t\t\t\r\n\t\t \t\t\t//}\r\n\t\t \t\t}\r\n\t\t \t\t\r\n\t\t \t\tif (st.ttype == StreamTokenizer.TT_NUMBER) {\r\n\t\t \t\t\tInstructionsRead++;\r\n\t\t \t\t\tif (!instFound) {//this is either label or instruction field\r\n\t\t \t\t\t\t//before anything, search optab to see if this might be the opcode\r\n\t\t \t\t\t\t//if it is an opcode, send it to the opcode processing function\r\n\t\t \t\t\t\tif (NtoString(st.nval).equals(\"WORD\") || NtoString(st.nval).equals(\"BYTE\")){//these are the directives... not technically instructions, but they go in the instruction field\r\n\t\t \t\t\t\t\tresCount = 0;\r\n\t\t \t\t\t\t\tif (NtoString(st.nval).equals(\"WORD\")){\r\n\t\t \t\t\t\t\t\tif (hexDigitCount >= 55){\r\n\t\t \t\t\t\t\t\t\tnewTHandle();\r\n\t\t \t\t\t\t\t\t}\r\n\t\t \t\t\t\t\t\thexDigitCount += 6;\r\n\t\t \t\t\t\t\t}\r\n\t\t \t\t\t\t\tif (NtoString(st.nval).equals(\"BYTE\")){\r\n\t\t \t\t\t\t\t\tconstantCaseB = true;\r\n\t\t \t\t\t\t\t}\r\n\t\t \t\t\t\t\tinstFound = true;\r\n\t\t \t\t\t\t\tprocessOpcodeN(st);\r\n\t\t \t\t\t\t}\r\n\t\t \t\t\t\tif (NtoString(st.nval).equals(\"RESW\") || NtoString(st.nval).equals(\"RESB\")){//these are the directives... not technically instructions, but they go in the instruction field\r\n\t\t \t\t\t\t\tresCount++;\r\n\t\t \t\t\t\t\tnewTHandle();\r\n\t\t \t\t\t\t\tinstFound = true;\r\n\t\t \t\t\t\t\tprocessOpcodeN(st);\r\n\t\t \t\t\t\t}\r\n\t\t \t\t\t\telse if (optab.searchOpcode(\"\" + st.nval)) {\r\n\t\t \t\t\t\t\tresCount = 0;\r\n\t\t \t\t\t\t\tif (hexDigitCount >= 55){\r\n\t \t\t\t\t\t\t\tnewTHandle();\r\n\t \t\t\t\t\t\t}\r\n\t\t \t\t\t\t\thexDigitCount += 6;\r\n\t\t \t\t\t\t\tinstFound = true;\r\n\t\t \t\t\t\t\tprocessOpcodeN(st);\r\n\t\t \t\t\t\t\t//InstructionsRead++;\r\n\t\t \t\t\t\t}\r\n\t\t \t\t\t\telse {\r\n\t\t \t\t\t\t\tprocessLabelN(st);\r\n\t\t \t\t\t\t}\r\n\t\t \t\t\t\t\r\n\t\t \t\t\t}\r\n\t\t \t\t\telse{ //this is the operand field\r\n\t\t \t\t\t\tprocessOperandN(st);\r\n\t\t \t\t\t}\r\n\t\t \t\t}\r\n\t\t \t\t\r\n\t\t \tif (moveOn){\r\n\t\t \tst.nextToken(); //read next token in current line\r\n\t\t \t}\r\n\t\t \t}\r\n\t\t \t////write line just finished to IF eventually\r\n\t\t if (moveOn){\r\n\t\t st.nextToken(); //read first token of next line\t\r\n\t\t }\r\n\t\t }\r\n\t\t programLength = (locctr - startAddress); \r\n\t\t programLength2 = programLength;\r\n\t\t System.out.println(\" !!prgmlngth2:\" + Integer.toHexString(programLength2.intValue()));\r\n\t\t /*\r\n\t\t sProgramLength = Integer.toHexString(programLength2.intValue());\r\n\t\t for (int i = 0; i<(6-sProgramLength.length()); i++){\r\n\t\t \tmyWriter.write(\"0\");\r\n\t\t }\r\n\t\t myWriter.write(sProgramLength);\r\n\t\t myWriter.close();\r\n\t\t ////myWriter.close();\r\n\t\t \r\n\t\t */\r\n\t\t r.close();\r\n\t\t System.out.println(\"?????!?!?!?!?ALPHA?!?!?!?!?!??!?!?!\");\r\n\t\t if (hexDigitCount/2 < 16){\r\n\t\t \tlineLength.add(\"0\" + Integer.toHexString(hexDigitCount/2));\r\n\t\t }\r\n\t\t else{\r\n\t\t lineLength.add(Integer.toHexString(hexDigitCount/2));\r\n\t\t }\r\n\t\t for (int i = 0; i<lineLength.size(); i++){\r\n\t\t System.out.println(lineLength.get(i));\r\n\t\t }\r\n\t\t // System.out.println(hexDigitCount);\r\n\t\t ReadIF pass2 = new ReadIF(this.optab,this.symtab,this.startAddress2,this.programLength2,this.name,this.lineLength,this.userArg);\r\n\t\t return st.sval;\r\n\t\t \r\n\t\t\r\n\r\n\t}", "public static void main(String[] args) {\n \n fillArrayList();\n getNextToken();\n parseProgram();\n\n //TODO output into file ID.java\n //This seems to work\n// File f = new File(programID+\".java\");\n// try {\n// PrintWriter write = new PrintWriter(f);\n// write.print(sb.toString());\n// write.flush();\n// write.close();\n// } catch (FileNotFoundException ex) {\n// Logger.getLogger(setTranslator.class.getName()).log(Level.SEVERE, null, ex);\n// }\n System.out.println(sb.toString());\n \n }", "public static void main(String[] args){\n String testFiles = \"D:\\\\self\\\\algorithms\\\\assignment specification\\\\wordnet\\\\\";\n String digraphFile = \"digraph4.txt\";\n\t In inputFile = new In(testFiles+digraphFile);\n\t Digraph D = new Digraph(inputFile);\n\t \n\t SAP testAgent = new SAP(D);\n\t System.out.println(testAgent.D.toString());\n }", "public static void main(String args[]) throws IOException {\n\t\tProcessData ged = new ProcessData(); \r\n\t\tged.readFile(\"My Family.ged\"); \r\n\t\t\r\n\t\t// output result for sprint 1, sprint 2, sprint 3 and sprint 4 to output.txt file\r\n\t\tVector<String> s = new Vector<String>();\r\n\t\t\r\n\t\t// get the individuals data\r\n\t\ts.add(\"Individuals Info:\");\r\n\t\ts.addAll(ged.print_individual());\r\n\t\tPrintWriter writer = new PrintWriter(\"Output.txt\", \"UTF-8\");\r\n\t\twhile(s.size()>0)\r\n\t\t{\r\n\t\t writer.write(s.firstElement());\r\n\t\t writer.println();\r\n\t\t s.removeElementAt(0);\r\n\t\t}\r\n\t\ts.add(\"\");\r\n\t\ts.add(\"\");\r\n\t\ts.add(\"\");\r\n\t\t\r\n\t\t// get the family data\r\n\t\ts.add(\"Family Info\");\r\n\t\ts.addAll(ged.print_family());\r\n\t\twhile(s.size()>0)\r\n\t\t{\r\n\t\t writer.write(s.firstElement());\r\n\t\t writer.println();\r\n\t\t s.removeElementAt(0);\r\n\t\t}\t\t\t\r\n\t\tSystem.out.println(\"Result is printed to Output.txt file.\");\r\n\t\twriter.close();\t\t\r\n\t}", "public static void main(String[] args) {\n try {\n readHouseTxt();\n } catch (ParseException e) {\n e.printStackTrace();\n }\n\n\n\n\n }", "public static void main(String[] args)\n {\n try\n {\n Global.initializer();\n TopicExtendedReg t = \n new TopicExtendedReg(datDirName + topicExtendedFilename);\n t.openToRead();\n if (t.read(\"10\")) System.out.println(t);\n if (t.read(\"10020\")) System.out.println(t);\n if (t.read(\"1014\")) System.out.println(t);\n if (t.read(\"9997\")) System.out.println(t);\n if (t.read(\"9982\")) System.out.println(t);\n if (t.read(\"28586\")) System.out.println(t);\n t.close();\n }\n catch (IOException ex)\n {\n System.out.println(ex);\n }\n }", "public static void demoDP(LexicalizedParser lp, String filename) {\n\t\t// This option shows loading and sentence-segmenting and tokenizing\n\t\t// a file using DocumentPreprocessor.\n\t\tTreebankLanguagePack tlp = new PennTreebankLanguagePack();\n\t\tGrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();\n\t\t// You could also create a tokenizer here (as below) and pass it\n\t\t// to DocumentPreprocessor\n\t\tfor (List<HasWord> sentence : new DocumentPreprocessor(filename)) {\n\t\t\tTree parse = lp.apply(sentence);\n\t\t\tList<Tree> testTree = new ArrayList<Tree>();\n\n\t\t\t// for (Tree subtree : parse) {\n\t\t\t// if (subtree.label().value().equals(\"VP\")) {\n\t\t\t// testTree.add(subtree);\n\t\t\t// }\n\t\t\t// }\n\t\t\t//\n//\t\t\tString pattern = \"VP < ((/VB.?/ < am|is|are|was|were) $+ (RB < /n['o]t/)) [< NP | < VP]\";// \"\\\\(VP \\\\([am|is|was|were|are]\\\\) .*\\\\)\";//\n//\t\t\tString pat = \"@NP < /NN.?/\";\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// \"\\\\(VP \\\\(.* [am|is|are|was|were]\\\\) \\\\(RB n[o’]t\\\\) \\\\(*\\\\)\\\\)\";\n//\t\t\tTregexPattern tgrepPattern = TregexPattern.compile(pattern);\n//\t\t\tTregexMatcher m = tgrepPattern.matcher(parse);\n//\t\t\twhile (m.find()) {\n//\t\t\t\tTree subtree = m.getMatch();\n//\t\t\t\ttestTree.add(subtree);\n//\t\t\t\tSystem.out.println(subtree.toString());\n//\t\t\t}\n\n\t\t\tTregexPatternCompiler tpc = new TregexPatternCompiler();\n\t\t\ttpc.addMacro(\"@VB\", \"/^VB/\");\n\t\t\ttpc.addMacro(\"@Be\", \"am|is|are|was|were\");\n\t\t\ttpc.addMacro(\"@Aux\", \"have|has|had|do|does|did\");\n\t\t\ttpc.addMacro(\"@NEGTerm\", \"(RB < /n['o]t/)\");\n\t\t\ttpc.addMacro(\"@PRN\", \"NP|ADJP|PP|ADVP|SBAR|S\");\n\t\t\ttpc.addMacro(\"@Modal\", \"can|could|may|might|will|would|must|shall|should|ought\");\n\t\t\ttpc.addMacro(\"@Be-Not\", \"(@VB < @Be $+ @NEGTerm)\");\n//\t\t\tTregexPattern test = tpc.compile(\"NP = cnp < DT !$ PP\");\n//\t\t\tTregexPattern test = tpc.compile(\"VP < ((@VB < @Be) $+ @NEGTerm) <@PRN\");\n//\t\t\tTregexPattern test = tpc.compile(\"VP < ((@VB < @Be) $+ @NEGTerm) < @PRN\");\n//\t\t\tTregexPattern test = tpc.compile(\"VP < @VB =vb < @NEGTerm < @PRN =xc \");\n//\t\t\tTregexPattern test = tpc.compile(\"VP < ((MD < @Modal) $+ @NEGTerm) < @PRN\");\n//\t\t\tTregexPattern test = tpc.compile(\"VP < (MD $+ @NEGTerm) < VP \"); //GOOD\n//\t\t\tTregexPattern test = tpc.compile(\"VP < MD=md < VP: =md $+ @NEGTerm \");\n//\t\t\tTregexPattern test = tpc.compile(\"VP < @VB=vb : =vb < @Be : =vb $+ @NEGTerm\");\n//\t\t\tTregexPattern test = tpc.compile(\"VP < @VB=vb < @PRN :(=vb < @Be $+ @NEGTerm)\");\n//\t\t\tTregexPattern test = tpc.compile(\"@VB < @Be $+ @NEGTerm\");\n\n\t\t\tTregexPattern test = tpc.compile(\"VP < ((@VB < @Aux) $+ @NEGTerm) < VP\");\n\t\t\t\n\n\t\t\tTregexMatcher mth = test.matcher(parse);\n\t\t\tif (mth.find()) {\n\t\t\t\tTree subtree = mth.getMatch();\n\t\t\t\ttestTree.add(subtree);\n\t\t\t\tSystem.out.println(\"Ter Compiler: \"+subtree.toString());\n\t\t\t}\n//\t\t\tfor (Tree subTree : testTree) {\n//\t\t\t\tString prdPattern = \"NP\";\n//\t\t\t\t TregexPattern prd = TregexPattern.compile(prdPattern);\n//\t\t\t\t TregexMatcher macher = prd.matcher(subTree);\n//\t\t\t\t if (macher.find()) {\n//\t\t\t\t Tree prdTree = m.getMatch();\n//\t\t\t\t System.out.println(\"PRD pattern: \"+prdTree.toString());\n//\t\t\t\t }\n//\t\t\t}\n\t\t\tSystem.out.println(\"--- Pattern: \" + testTree.toString());\n\t\t\t System.out.println(\"***\" + parse.toString());\n//\t\t\tparse.pennPrint();\n//\t\t\tSystem.out.println(parse.pennString());\n\t\t\tSystem.out.println();\n\n\t\t\tGrammaticalStructure gs = gsf.newGrammaticalStructure(parse);\n\t\t\t@SuppressWarnings(\"rawtypes\")\n\t\t\tCollection tdl = gs.typedDependenciesCCprocessed();\n\t\t\t System.out.println(\"td1: \"+tdl);\n\t\t\t System.out.println();\n\t\t}\n\t}", "public static void main(String[] args) throws IOException {\n\t\t\n\t\tString folder = \"/Users/haopeng/Dropbox/research/2nd/Usecase/Yanlei/\";\n\t\tString fileName = \"P0_2324.txt\";\n\t\t\n\t\tFileReader reader = new FileReader(folder + fileName, 20000000);\n\t\treader.parseFile();\n\t\t\n\t\t//reader.printValues(reader.getServerName(), \"ServerName\");\n\t\t//reader.printValues(reader.getCommand(), \"Command\");\n\t\t//reader.printValues(reader.getTimestamp(), \"Timestamp\"); \n\t\t//reader.printValues(reader.getPath(), \"Path\");\n\t\treader.printValues(reader.getMethod(), \"Method\");\n\t}", "public static void main(String[] args) throws TesseractException, IOException {\n String filepath = \"D:\\\\Development\\\\Temporary\\\\RemovableFiles\\\\test file\\\\Sample 5\\\\CCF06017_0012.pdf\";\n new OCROperation().getOcrParsedCharacterPosition(filepath, 4.2, 105, 3450, 300, 300);\n }", "public static void main(String args[]) throws Exception {\n\t String filePath = \"test.pdf\";\r\n\t \r\n\t String pdfText = FileReader.getFile(filePath, 581, 584); \r\n\t text_position.position(580, 584);\r\n\t \r\n//\t String pdfText = FileReader.getFile(filePath, 396, 407); \r\n//\t text_position.position(395, 407);\r\n\r\n\t txtCreate.creatTxtFile(\"test\");\r\n\t txtCreate.writeTxtFile(pdfText);\r\n\t xmlCreater.getXML(\"test.txt\");\r\n }", "public static void main(String[] args) throws IOException \r\n\t{\r\n\t\tString s1 = \"THE SALVADORAN GOVERNMENT TODAY DEPLORED THE DISAPPEARANCE OF SOCIAL DEMOCRATIC LEADER HECTOR OQUELI COLINDRES THIS MORNING IN GUATEMALA.\";\r\n\t\tString soln = classifier.classifyToString(s1);\r\n\t\tSystem.out.println(soln);\r\n\t\tNER n = new NER();\r\n\t\tn.getPersons(s1);\r\n\t\tSystem.out.println(\"\\n\");\r\n\t\tn.getOrgs(s1);\r\n\t\tSystem.out.println(\"\\n\");\r\n\t\tn.getLocations(s1);\r\n\t}", "public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException{\n\t File inputFile = new File(\"C:\\\\Users\\\\msamiull\\\\workspace\\\\jgraphx-master\\\\t.xml\");\r\n DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();\r\n DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();\r\n Document doc = dBuilder.parse(inputFile);\r\n \r\n\t\tdoc.getDocumentElement().normalize();\r\n System.out.println(\"Main element :\"+ doc.getDocumentElement().getNodeName());\r\n// NodeList nodeList = doc.getElementsByTagName(\"root\");\r\n \r\n NodeList nodeList = doc.getElementsByTagName(\"iOOBN\");\r\n// NamedNodeMap attribList = doc.getAttributes();\r\n \r\n// nonRecursiveParserXML(nList, doc);\r\n\r\n ArrayList<String> tagList = new ArrayList<String>();\r\n// tagList.add(\"mxCell\");\r\n// tagList.add(\"mxGeometry\");\r\n// tagList.add(\"mxPoint\");\r\n tagList.add(\"Node\");\r\n tagList.add(\"state\");\r\n tagList.add(\"tuple\"); // purposely i raplced \"datarow\" by \"tuple\" so that my parser can consider state first before tuple/data\r\n tagList.add(\"parent\");\r\n \r\n recursiveParserXML(nodeList, tagList);\r\n\r\n }", "public static void main(String[] args)\n\t{\n\t\tString filePath = \"C:/dev/RND/mdbdmproj/xml/FC_REPLY.XML\";\n//\t\tTestXML test = new TestXML();\n//\t\ttest.parseXml(null, Reader.getFileContetns(filePath));\n\t\t\n\t\tString msgXML = Reader.getFileContetns(filePath);\n\t\ttry\n\t\t{\n\t\t\tDocument msgDocument = DocumentHelper.parseText(msgXML);\n\t\t\tElement rootEle = msgDocument.getRootElement();\n\t\t\tSystem.out.println(rootEle.getName());\n\t\t\t\n\t\t\tIterator iterator=rootEle.element(\"REPLY_CPMNT\").elements().iterator();\n\t\t\twhile(iterator.hasNext())\n\t\t\t{\n\t\t\t\tElement ele=(Element)iterator.next();\n\t\t\t\tString name = ele.getName();\n\t\t\t\tString value=ele.getText();\n\t\t\t\tSystem.out.println(name+\"-------\"+value);\n\t\t\t}\t\n\t\t}\n\t\tcatch( Exception e )\n\t\t{\n\t\t\te.printStackTrace();\n\t\t}\n\t}", "public static void main(String[] args) {\n\r\n\t\ttry{\r\n\t\t\tString tac2008Path = \"C:/Users/jipeng/Desktop/Qiang/updateSum/TAC2008_Update_Summarization_Documents/UpdateSumm08_test_docs_files\";\r\n\t\t\tExtractPrag ep = new ExtractPrag();\r\n\t\t\t\r\n\t\t\t//String wordPath = \"\";\r\n\t\t\t//ep.extractWords(wordPath)\r\n\t\t\tep.allDataset(tac2008Path);\r\n\t\t\t\r\n\t\t}catch(Exception e)\r\n\t\t{\r\n\t\t\te.printStackTrace();\r\n\t\t}\r\n\t}", "public static void main(String[] args){\r\n\tif (args.length>0){\r\n\t for (String arg : args){\r\n\t\tFile f = new File(arg);\r\n\t\tif (f.exists()){\r\n\t\t System.out.println(\"Parsing '\"+ f+\"'\");\r\n\t\t RobotProgramNode prog = parseFile(f);\r\n\t\t System.out.println(\"Parsing completed \");\r\n\t\t if (prog!=null){\r\n\t\t\tSystem.out.println(\"================\\nProgram:\");\r\n\t\t\tSystem.out.println(prog);}\r\n\t\t System.out.println(\"=================\");\r\n\t\t}\r\n\t\telse {System.out.println(\"Can't find file '\"+f+\"'\");}\r\n\t }\r\n\t} else {\r\n\t while (true){\r\n\t\tJFileChooser chooser = new JFileChooser(\".\");//System.getProperty(\"user.dir\"));\r\n\t\tint res = chooser.showOpenDialog(null);\r\n\t\tif(res != JFileChooser.APPROVE_OPTION){ break;}\r\n\t\tRobotProgramNode prog = parseFile(chooser.getSelectedFile());\r\n\t\tSystem.out.println(\"Parsing completed\");\r\n\t\tif (prog!=null){\r\n\t\t System.out.println(\"Program: \\n\"+prog);\r\n\t\t}\r\n\t\tSystem.out.println(\"=================\");\r\n\t }\r\n\t}\r\n\tSystem.out.println(\"Done\");\r\n }", "public static void main(String [] args)\n\t{\n\t\tString newickStr=\"(Selaginella_uncinata:0.1,((Panax_ginseng:0.1,Daucus_carota:0.1):0.1,Liriodendron_tulipifera:0.1):0.1,Coffea_arabica:0.1);\";\n//\t\tString newickStr=\"((Liriodendron_tulipifera:0.100000,(Selaginella_uncinata:0.100000,Panax_ginseng:0.100000):0.100000):0.100000,Daucus_carota:0.100000,Coffea_arabica:0.100000);\";\n\t\tRootedTree rt=RootedTree.Util.fromNewickString(newickStr);\n\t System.out.println(rt);\n\t\t\n\t\t/*\n\t\t// debug:\n\t\tFile mrBayesTrees = new File(\"/Users/bouchard/w/ptychodus/data/mrBayesOnWalsIE/nAryCharacters-1m-iters/inMrBayesFolder/test.nex.run1.t\");\n\t\t// for (String line : i(mrBayesTrees))\n\t\t// System.out.println(line);\n\t\tprocessMrBayesTrees(mrBayesTrees, new RootedTreeProcessor() {\n\n\t\t\t@Override\n\t\t\tpublic void process(RootedTree rt)\n\t\t\t{\n\t\t\t\tSystem.out.println(rt);\n\t\t\t}\n\t\t});\n\t\t*/\n\t}", "public static void main(final String[] args)\r\n {\r\n // Set the path to the data files\r\n Dictionary.initialize(\"c:/Program Files/WordNet/2.1/dict\");\r\n \r\n // Get an instance of the Dictionary object\r\n Dictionary dict = Dictionary.getInstance();\r\n \r\n // Declare a filter for all terms starting with \"car\", ignoring case\r\n TermFilter filter = new WildcardFilter(\"car*\", true);\r\n \r\n // Get an iterator to the list of nouns\r\n Iterator<IndexTerm> iter = \r\n dict.getIndexTermIterator(PartOfSpeech.NOUN, 1, filter);\r\n \r\n // Go over the list items\r\n while (iter.hasNext())\r\n {\r\n // Get the next object\r\n IndexTerm term = iter.next();\r\n \r\n // Write out the object\r\n System.out.println(term.toString());\r\n \r\n // Write out the unique pointers for this term\r\n int nNumPtrs = term.getPointerCount();\r\n if (nNumPtrs > 0)\r\n {\r\n // Print out the number of pointers\r\n System.out.println(\"\\nThis term has \" + Integer.toString(nNumPtrs) +\r\n \" pointers\");\r\n \r\n // Print out all of the pointers\r\n String[] ptrs = term.getPointers();\r\n for (int i = 0; i < nNumPtrs; ++i)\r\n {\r\n String p = Pointer.getPointerDescription(term.getPartOfSpeech(), ptrs[i]);\r\n System.out.println(ptrs[i] + \": \" + p);\r\n }\r\n }\r\n \r\n // Get the definitions for this term\r\n int nNumSynsets = term.getSynsetCount();\r\n if (nNumSynsets > 0)\r\n {\r\n // Print out the number of synsets\r\n System.out.println(\"\\nThis term has \" + Integer.toString(nNumSynsets) +\r\n \" synsets\");\r\n \r\n // Print out all of the synsets\r\n Synset[] synsets = term.getSynsets();\r\n for (int i = 0; i < nNumSynsets; ++i)\r\n {\r\n System.out.println(synsets[i].toString());\r\n }\r\n }\r\n }\r\n \r\n System.out.println(\"Demo processing finished.\");\r\n }", "public static void main(String[] args) throws IOException {\n String dataDir = Utils.getDataDir(PrimaveraXmlRead.class);\n\n readProjectUidsFromXmlFile(dataDir);\n\n readLoadPrimaveraXmlProject(dataDir);\n\n readProjectUidsFromStream(dataDir);\n\n // Display result of conversion.\n System.out.println(\"Process completed Successfully\");\n }", "public static void main(String[] args) {\n\t\tString text = \"\\\"undifferentiated's thyroid carcinomas were carried out with antisera against calcitonin, calcitonin-gene related peptide (CGRP), somatostatin, and also thyroglobulin, using the PAP method. \";\n\t\ttext = text.replace('\\\"', ' ');\n\t\t\n\t\tStringUtil su = new StringUtil();\n\t\t\n\t\t// Extracting...\n\t\tString text2 = new String(text);\n\t\tEnvironmentVariable.setMoaraHome(\"./\");\n\t\tGeneRecognition gr = new GeneRecognition();\n\t\tArrayList<GeneMention> gms = gr.extract(MentionConstant.MODEL_BC2,text);\n\t\t// Listing mentions...\n\t\tSystem.out.println(\"Start\\tEnd\\tMention\");\n\t\tfor (int i=0; i<gms.size(); i++) {\n\t\t\tGeneMention gm = gms.get(i);\n\t\t\tSystem.out.println(gm.Start() + \"\\t\" + gm.End() + \"\\t\" + gm.Text());\n\t\t\t//System.out.println(text2.substring(gm.Start(), gm.End()));\n\t\t\tSystem.out.println(su.getTokenByPosition(text,gm.Start(),gm.End()).trim());\n\t\t}\n\t\tif (true){\n\t\t\treturn;\n\t\t}\n\t\t// Normalizing mentions...\n\t\tOrganism yeast = new Organism(Constant.ORGANISM_YEAST);\n\t\tOrganism human = new Organism(Constant.ORGANISM_HUMAN);\n\t\tExactMatchingNormalization gn = new ExactMatchingNormalization(human);\n\t\tgms = gn.normalize(text,gms);\n\t\t// Listing normalized identifiers...\n\t\t\n\t\tSystem.out.println(\"\\nStart\\tEnd\\t#Pred\\tMention\");\n\t\tfor (int i=0; i<gms.size(); i++) {\n\t\t\tGeneMention gm = gms.get(i);\n\t\t\tif (gm.GeneIds().size()>0) {\n\t\t\t\tSystem.out.println(gm.Start() + \"\\t\" + gm.End() + \"\\t\" + gm.GeneIds().size() + \n\t\t\t\t\t\"\\t\" + su.getTokenByPosition(text,gm.Start(),gm.End()).trim());\n\t\t\t\tfor (int j=0; j<gm.GeneIds().size(); j++) {\n\t\t\t\t\tGenePrediction gp = gm.GeneIds().get(j);\n\t\t\t\t\tSystem.out.print(\"\\t\" + gp.GeneId() + \" \" + gp.OriginalSynonym() + \" \" + gp.ScoreDisambig());\n\t\t\t\t\tSystem.out.println((gm.GeneId().GeneId().equals(gp.GeneId())?\" (*)\":\"\"));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "public static void main(String[] args) throws IOException {\n\t\tCharStream input = CharStreams.fromFileName(\"C:\\\\Users\\\\User\\\\eclipse-workspace\\\\Compilateur-Aisha-Liliya\\\\src\\\\test\\\\test0.txt\");\n\t\tLangageLexer lexer = new LangageLexer( input);\n\t\tLangageParser parser = new \tLangageParser(new CommonTokenStream(lexer));\n\t\tListener l =new Listener();\n\t\tparser.addParseListener(l);\n\t\t\n\t\tParseTree tree = parser.code();\n\tl.s.printTE();\n\tl.s.printTS();\n\tl.s.printQuad();\n\tl.s.printCODEOBJET();\n\t}", "public static void main(String[] args) {\n\t\tPropertyManager.setPropertyFilePath(\"/home/francesco/Desktop/NLP_HACHATHON_4YFN/TextDigesterConfig.properties\");\n\t\t\n\t\tString text = MultilingImport.readText(\"/home/francesco/Desktop/NLP_HACHATHON_4YFN/EXAMPLE_TEXTS/multilingMss2015Training/body/text/\" + lang + \"/\" + docName);\n\n\t\t/* Process text document */\n\t\tLangENUM languageOfHTMLdoc = FlProcessor.getLanguage(text);\n\t\t\n\t\tTDDocument TDdoc = FlProcessor.generateDocumentFromFreeText(text, null, languageOfHTMLdoc);\n\n\t\t// Store GATE document\n\t\tWriter out = null;\n\t\ttry {\n\t\t\tout = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(\"/home/francesco/Desktop/NLP_HACHATHON_4YFN/EXAMPLE_TEXTS/\" + lang + \"_\" + docName.replace(\".txt\", \"_GATE.xml\")), \"UTF-8\"));\n\t\t} catch (UnsupportedEncodingException e1) {\n\t\t\te1.printStackTrace();\n\t\t} catch (FileNotFoundException e1) {\n\t\t\te1.printStackTrace();\n\t\t}\n\t\t\n\t\ttry {\n\t\t\tout.write(TDdoc.getGATEdoc().toXml());\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t} finally {\n\t\t\ttry {\n\t\t\t\tout.close();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t}\n\t\t\n\t\t/*\n\t\ttry {\n\t\t\tLexRankSummarizer lexRank = new LexRankSummarizer(languageOfHTMLdoc, SentenceSimilarityENUM.cosineTFIDF, false, 0.01);\n\t\t\tMap<Annotation, Double> sortedSentences = lexRank.sortSentences(TDdoc);\n\t\t\t\n\t\t\tList<Annotation> sentListOrderedByRelevance = new ArrayList<Annotation>();\n\t\t\tfor(Entry<Annotation, Double> sentence : sortedSentences.entrySet()) {\n\t\t\t\tlogger.info(\"Score: \" + sentence.getValue() + \" - '\" + GtUtils.getTextOfAnnotation(sentence.getKey(), TDdoc.getGATEdoc()) + \"'\");\n\t\t\t\tsentListOrderedByRelevance.add(sentence.getKey());\n\t\t\t}\n\t\t\t\n\t\t\tlogger.info(\"Summary max 100 tokens: \");\n\t\t\tList<Annotation> summarySentences = GtUtils.orderAnnotations(sentListOrderedByRelevance, TDdoc.getGATEdoc(), 100);\n\t\t\tfor(Annotation ann : summarySentences) {\n\t\t\t\tlogger.info(GtUtils.getTextOfAnnotation(ann, TDdoc.getGATEdoc()));\n\t\t\t}\n\t\t} catch (TextDigesterException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\t*/\n\t}", "public static void main(String[] args) throws IOException {\r\n\t\t\r\n\t\tSystem.out.println(parseInputFile());\r\n\t\t\r\n\t}", "private void posRead() throws IOException {\n\t\tFile file = new File(fullFileName());\n\t\tString line;\n\t\tBufferedReader reader = new BufferedReader(new FileReader(file));\n\t\tStringBuffer fileText = new StringBuffer();\n\t\twhile((line = reader.readLine()) != null) {\n\t\t\tStringTokenizer st = new StringTokenizer(line);\n\t\t\twhile (st.hasMoreTokens()) {\n \t\tString tokenAndPos = st.nextToken();\n \t\tint slashIndex = tokenAndPos.lastIndexOf('/');\n \t\tif (slashIndex <= 0) throw new IOException(\"invalid data\");\n \t\tString token = tokenAndPos.substring(0,slashIndex);\n \t\tString pos = tokenAndPos.substring(1+slashIndex).intern();\n \t\tint start = this.length();\n \t\tthis.append(token);\n \t\tif (st.hasMoreTokens())\n \t\t\tthis.append(\" \");\n \t\telse\n \t\t\tthis.append(\" \\n\");\n \t\tint end = this.length();\n \t\tSpan span = new Span(start,end);\n \t\tthis.annotate(\"token\", span, new FeatureSet());\n \t\tthis.annotate(\"constit\", span, new FeatureSet(\"cat\", pos));\n \t}\n\t\t}\n\t}", "public static void main(String[] args) {\n\t\ttry {\n//\t\t\tExtractorXML xml = new ExtractorXML(\"./TLf6PpaaExclBrkdnD-sqlMap.xml\", \"utf-8\");\n\t\t\tExtractorXML xml = new ExtractorXML(\"D:/tmp/test.xml\",\"utf-8\");\n\n\n\t\t\tTObj nd = xml.doAnalyze();\n\n\t\t\txml.dump(\"c:\\\\a.out\");\n/*\t\t\tfor ( int i = 0; ; i ++) {\n\t\t\tif (xml.getAttributeValue(\"/sqlMap/insert[\" + i +\"]\", \"id\") == null)\n\t\t\t\tbreak;\n\t\t\tSystem.out.println(xml.getAttributeValue(\"/sqlMap/insert[\" + i +\"]\", \"id\"));\n\t\t\t}*/\n\n\t\t//System.out.println(\"!!\" + rootnode.getNodeValue(\"/navigation/action[\" + 3 +\"]\"));\n\n\t\t\tSystem.out.println(\"root=\"+xml.getRootName());\n//\t\tArrayList arr = node_list.get(3).sublist;\n\n/*\t\tfor(int i = 0; i < arr.size() ; i ++){\n\n\t\t\tnode_data ndd = (node_data)arr.get(i);\n\t\t\tif(ndd.nodename.equals(\"command\") ){\n\t\t\t\t//System.out.println(ndd.tlocation.getStartLine() + \" :: \" + ndd.nodename + \" :: \" + ndd.tlocation.getEndLine());\n\t\t\t\tfor(int j =0; j < ndd.sublist.size() ; j ++){\n\t\t\t\t\tSystem.out.println(ndd.sublist.get(j).nodename);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n*/\n\t\t/*\tfor(int j =0 ; j < node_list.size(); j ++){\n\n\t\t\tnode_data nd = (node_data)node_list.get(j);\n\t\t\tSystem.out.println(nd.keylist.get(0).value + \" TLOCATION start :: \" + nd.tlocation.getStartLine() + \" TLOCATION end :: \" + nd.tlocation.getEndLine());\n\t\t}\n\t\tSystem.out.println(rootnode.sublist.get(0).tlocation.getStartLine() + \" \"+ rootnode.sublist.get(0).tlocation.getEndLine());\n\t\t */\n\t\t\t// xml.log.close();\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t\t// TODO: handle exception\n\t\t}\n\t}", "public static void main(String[] args){\n SentenceParser sp = new SentenceParser (\"Peas and carrots and potatoes.\");\n System.out.println(sp);\n //then print your results\n \n\n }", "public static void main(String[] args) {\n\t\tString s = \"this is a small house .\";\n\t\tString t = \"das ist ein kleines haus .\";\n\t\tString m = \"das ist |0-1| ein kleines |2-3| haus . |4-5|\";\n\t\tArrayList<String> x = new XlingualProjection().ExtractAlignments(s,t,m);\n\t\tfor (int i=0; i<x.size(); i++){\n\t\t\tSystem.out.println(x.get(i));\n\t\t}\n\t\n\t\tString[] y = new XlingualProjection().getSrcPhrases(x);\n\t\tint start = 0;\n\t\tint end = 0;\n\t\t\n\t\tfor(int i=0; i < y.length; i++){ // Traverse through each phrase\n \tend = start + y[i].length();\n \tSystem.out.println(y[i] + \" \" + start + \" \" + end);\n \t\t\n \t\tstart = end+1;\n }\n\n }", "public static void main(String[] args) {\n \tScanner s = null;\n try{\n s = new Scanner(new File(args[0]));\n }catch (FileNotFoundException e) {\t\t\n \tSystem.out.println(\"File not found!\");\n }catch (Exception e){\t\t\n \tSystem.out.println(\"Something else went wrong!\");\n \te.printStackTrace();\n }\n \t \t\n //Read Line by Line\n s.nextLine();\n while(s.hasNext()){\n\t\t\tString Line=s.nextLine();\n\t\t\tString tokens[] = Line.split(\";\");//4 tokens created(MAIN LINE)\n\t\t\tString personCode=tokens[0];\t\t\n\t\t\tString name[] = tokens[1].split(\", \");//String name created split with comas\t\n\t\t\t\n\t\t\tName personName =new Name (name[0],name[1]);//personName object created under Name class, both name are passed\n\t\t\tSystem.out.println(name[0]);\n\t\t\tpersonName.setFirstName(name[0]);\n \t\tpersonName.setLastName(name[1]);\t\t\t\n \t\tString address[] = tokens[2].split(\",\");\n \t\tAddress personAddress =new Address (address[0],address[1],address[2],address[3],address[4]);\n\t\t\tSystem.out.println(tokens[2]);\t\n\t\t\tif(tokens.length==4) {\n \t\t\tString emailAdress=tokens[3];\n \t\t\tSystem.out.println(tokens[3]);\t\n \n \t\t}\n \n \t}\n\t}", "public static void main(String[] args) {\n\t\tString great_association_rule =\"singlenearestgene\";\n\t\t\n\t\t//String filename = \"C:\\\\Users\\\\Burçak\\\\Google Drive\\\\GLANET_Bioinformatics_2ndSubmission\\\\GREAT\\\\great_twonearestgenes_found_enriched_BP_GO_Terms.txt\";\n\t\tString filename = \"C:\\\\Users\\\\Burçak\\\\Google Drive\\\\GLANET_Bioinformatics_2ndSubmission\\\\GREAT\\\\great_singlenearestgene_found_enriched_BP_GO_Terms.txt\";\n\t\tList<String> great_enriched_BP_GOTermNames_List = new ArrayList<String>();\n\t\treadFileAndFill(filename,great_enriched_BP_GOTermNames_List);\n\t\t\n\t\tSystem.out.println(\"Number of GO Term Names found enriched by GREAT: \" + great_enriched_BP_GOTermNames_List.size());\n\t\t\n\t\t//Fill GOTermName 2 GOTermID map\n\t\tString GOID2TermInputFile = \"C:\\\\Users\\\\Burçak\\\\Google Drive\\\\Data\\\\\" + Commons.GENE_ONTOLOGY_TERMS + System.getProperty(\"file.separator\") + Commons.GOID2TERM_INPUTFILE;\n\t\tMap<String,String> GOTermName2GOTermIDMap = new HashMap<String,String>();\n\t\tGOTermsUtility.fillGOTermName2GOTermIDMap(GOID2TermInputFile, GOTermName2GOTermIDMap);\n\t\t\n\t\t//output the converted GO Term IDs\n\t\t//GOTermList_GATA2_P= c(\"GO:0006351\",\"GO:0035854\",\"GO:0045599\",\"GO:0045746\",\"GO:0045766\",\"GO:0045944\",\"GO:0070345\",\"GO:2000178\")\n\t\tString great_enriched_BP_GOTermIDs = creatGOTermIDString(great_association_rule,great_enriched_BP_GOTermNames_List,GOTermName2GOTermIDMap);\n\t\t\n\t\tSystem.out.println(\"**************************************************\");\n\t\tSystem.out.println(great_enriched_BP_GOTermIDs);\n\n\t}", "public static void main(String[] args) {\n \tString file = \"ensembl_genes.txt\";\r\n \tString dbname = \"ensembl_homo_sapiens_38_36\";\r\n \tEnsembl2Visio ensj = new Ensembl2Visio();\r\n // \tensj.fetchFromEnsembl(nrGenes, organism, file); // Do this with perl\r\n \tensj.createGdbFromTxt(file, dbname);\r\n }", "public static void main(String[] args) throws IOException {\n\t\t\r\n\t\t\r\n\t\tString dir = \"C:\\\\Eclipse\\\\OxygenWorkspace\\\\DigestedProteinDB\\\\misc\\\\sample_data\";\r\n\t\t//dir = \"F:\\\\Downloads\\\\uniprot\\\\uniprot_sprot.dat_delta-db1_100000\";\r\n\t\treadPeptideRow1(dir, 600.1f, 600.3f);\r\n\t\t\r\n\r\n\t}", "public static void main(String[] args) {\n\t\tarticle.add(\"the\");\n\t\tarticle.add(\"a\");\n\t\tarticle.add(\"some\");\n\t\tarticle.add(\"one\");\n\t\tnoun.add(\"boy\");\n\t\tnoun.add(\"girl\");\n\t\tnoun.add(\"dog\");\n\t\tnoun.add(\"town\");\n\t\tnoun.add(\"car\");\n\t\tverb.add(\"drove\");\n\t\tverb.add(\"ran\");\n\t\tverb.add(\"jumped\");\n\t\tverb.add(\"walked\");\n\t\tverb.add(\"skipped\");\n\t\tpreposition.add(\"to\");\n\t\tpreposition.add(\"from\");\n\t\tpreposition.add(\"over\");\n\t\tpreposition.add(\"on\");\n\t\tpreposition.add(\"under\");\n\t\tRandom r= new Random();\n\t\tfor(int i=0;i<15;i++)\n\t\t{\n\t\tint n= r.nextInt(4);\n\t\tint n2= r.nextInt(5);\n\t\tint n3= r.nextInt(5);\n\n\t\tint n4= r.nextInt(5);\n\t\tint n5= r.nextInt(4);\n\t\tint n6= r.nextInt(5);\n\n\t\tSystem.out.println(article.get(n)+ \" \"+ noun.get(n2)+\" \"+ verb.get(n3)+\" \"+ preposition.get(n4)+\" \" + article.get(n5)+\" \"+ noun.get(n6)+\".\");\n\t\t}\n\n\t}", "public static void main(String[] args) throws Exception {\n\t\tTSNodeLabel structure = new TSNodeLabel(\"(S (NP (NNP Mary)) (VP-H (VBZ-H is) (VP (VBG-H singing) (NP (DT an) (JJP (JJ old) (CC and) (JJ beautiful)) (NN-H song)))))\");\n\t\tchunkSentence(structure);\n\t}", "public static void main(String[] args) {\n\t\tString filePath = \"J:\\\\\\\\GCU\\\\\\\\Programming 1(CST-105)\\\\\\\\Assignments\\\\\\\\Week3CHyde\\\\\\\\week3_workspace\\\\\\\\ProgrammingExercise4\\\\\\\\src\\\\\\\\Exercise4_Text.txt\";\n\t\tString entireText = \"\";\n\t\t\n\t\t// Try-Catch to make sure file is present. \n\t\ttry {\n\t\t\tBufferedReader bufferedReader = new BufferedReader(new FileReader(filePath));\n\n\t\t\tString readLine = \"\";\n\n\t\t\t// Start while loop\n\t\t\twhile ((readLine = bufferedReader.readLine()) != null) {\n\t\t\t\tentireText += readLine; // Set each line that is read to the entireText String variable.\n\t\t\t} \n\t\t\t// End while loop\n\n\t\t\tbufferedReader.close(); // Close the Buffered Reader\n\t\t}\n\t\tcatch (IOException e) { // Catch starts\n\t\t\te.printStackTrace();\n\t\t} // Catch ends. \n\n\t\t//Run the method printTranslation\n\t\tprintTranslation(entireText);\n\n\t}", "public static void main(String[] args)\r\n\t{\n\t\tacceptConfig();\r\n\t\treadDictionary();\r\n\t\t//Then, it reads the input file and it prints the word (if contained on the file) or the suggestions\r\n\t\t//(if not contained) in the output file. These files are given by command line arguments\r\n\t\tprocessFile(args[0], args[1]);\r\n\t\t\r\n\t}", "public static void main(String args[])\r\n {\n\t\tString result = new epsnfa().Start(\"sampleRE.in\");\r\n\t\tSystem.out.println(result);\r\n\t}", "public static void main(String[] args) {\n String filename = null;\n for (String s : args) {\n filename = s;\n }\n\n // ...or use a default file name\n if (filename == null)\n filename = \"neighbor-dump.txt\";\n\n // Open a file stream and process each line (Java 8+ only)\n try (Stream<String> lines = Files.lines(Paths.get(filename), Charset.defaultCharset())) {\n lines.forEachOrdered(line -> process(line));\n } catch (IOException ex) {\n ex.printStackTrace();\n }\n\n // Print the required output\n System.out.println(\"Results are as follows:\");\n System.out.println(\"- List of PAN IDs (Total of \" + Integer.toString(panIds.size()) + \")\");\n for (String s : panIds) {\n System.out.println(\"PANID = \" + s);\n }\n\n System.out.println(\"- List of MAC Addresses (Total of \" + Integer.toString(macAdresses.size()) + \")\");\n for (String key : macAdresses.keySet()) {\n System.out.println(key);\n }\n\n System.out.println(\"- List of RF_RSSI_M values for each MAC address\");\n for (String key : macAdresses.keySet()) {\n System.out.println(key + \" \" + macAdresses.get(key));\n }\n\n }", "public static void main(String[] args) {\n\t\tPeptide peptide = new Peptide(\"P41220\", \"MQSAMFLAVQHDCRPMDKSAGSGHKSEEKREKMKRTLLKDWKTRLSYFLQNSSTPGKPKTGKKSKQQAFIKPSPEEAQLWSEAFDELLASKYGLAAFRAFLKSEFCEENIEFWLACEDFKKTKSPQKLSSKARKIYTDFIEKEAPKEINIDFQTKTLIAQNIQEATSGCFTTAQKRVYSLMENNSYPRFLESEFYQDLCKKPQITTEPHAT\");\n\t\tpeptide.addPositive(106 - 1, 'C');\n\t\tpeptide.addPositive(116 - 1, 'C');\t\t\n\t\tpeptide.addPositive(199 - 1, 'C');\n\t\tpeptide.generateNegativePositions('C');\n\t\tSystem.out.println(peptide.generateSites(20, 20));\n\t}", "private void fileToPoSTags(String filePath,int version){\n Log.log(\"Reading TreeBank file <\" + filePath +\">\");\n\n FileReader fr = null;\n BufferedReader br = null;\n\n try{\n fr = new FileReader(filePath);\n br = new BufferedReader(fr);\n\n String currentLine;\n String[] columns;\n\n Tag tag1 = null;\n Tag tag2;\n String word;\n\n Integer numRow;\n while((currentLine = br.readLine()) != null){\n columns = currentLine.split(\"\\t\");\n numRow = getIntegerString(columns[0]);\n if(numRow != null && numRow >= 1){\n if(numRow == 1) {\n tag1 = Tag.valueOf(\"START\");\n saveTag(tag1);\n }\n try{\n tag2 = Tag.valueOf(columns[3]);\n saveTag(tag2);\n word = columns[1];\n switch (version){\n case 1:\n savePoSTag(new PoSTag(word.toLowerCase(),tag2));\n break;\n case 2:\n if(!tag2.equals(Tag.PROPN))\n savePoSTag(new PoSTag(word.toLowerCase(),tag2));\n else if(Character.isUpperCase(word.charAt(0)))\n savePoSTag(new PoSTag(word,tag2));\n break;\n case 3:\n\n if(tag2.equals(Tag.PROPN))\n savePoSTag(new PoSTag(word,tag2));\n else{\n if(Character.isUpperCase(word.charAt(0))){\n savePoSTag(new PoSTag(word,tag2));\n savePoSTag(new PoSTag(word.toLowerCase(),tag2));\n }else{\n savePoSTag(new PoSTag(word,tag2));\n savePoSTag(new PoSTag(\n word.substring(0,1).toUpperCase()\n +word.substring(1),tag2));\n }\n\n }\n\n break;\n case 4:\n\n if(!tag2.equals(Tag.PROPN))\n savePoSTag(new PoSTag(word,tag2));\n savePoSTag(new PoSTag(word,tag2));\n break;\n case 5:\n\n if(!tag2.equals(Tag.PROPN))\n savePoSTag(new PoSTag(word.toLowerCase(),tag2));\n savePoSTag(new PoSTag(word,tag2));\n break;\n\n }\n saveBigram(new BiGram(tag1,tag2));\n tag1 = tag2;\n }catch (IllegalArgumentException e){\n e.printStackTrace();\n }\n }\n }\n\n }catch (IOException e){\n e.printStackTrace();\n }finally {\n UtilitiesIO.closeFile(fr,br);\n }\n }", "public static void main(String[] args) {\n\t\tfileName = args[0];\n\t\t//set up file name for the data:\n\t\ttry {\n\t\t\treader = new Scanner(new File(args[1]));\n\t\t\t\n\t\t\t//create a new program, then parse, print, and execute:\n\t\t\tProgram p = new Program();\n\t\t\tp.parse();\n\t\t\tp.print();\n\t\t\tSystem.out.println(\"---PROGRAM OUTPUT---\");\n\t\t\tp.execute();\n\t\t\t\n\t\t} catch (FileNotFoundException e) {\n\t\t\tSystem.out.println(\"ERROR reading data file \" + args[1]);\n\t\t\te.printStackTrace();\n\t\t} finally{\n\t\t\treader.close();\n\t\t}\n\t}", "public static void main (String[] args) {\r\n try {\r\n BufferedReader in = new BufferedReader(\r\n new InputStreamReader(\r\n new FileInputStream(new File(\"D:\\\\bitext.html\")), \"UTF-8\"));\r\n\r\n String s;\r\n StringBuffer b = new StringBuffer();\r\n while( (s = in.readLine()) != null) {\r\n b.append(s );\r\n }\r\n String page= b.toString();\r\n HTMLParser parser = new HTMLParser(page.getBytes(\"UTF-8\"));\r\n //parser.getTagValue (\"meta\");\r\n //System.out.println();\r\n\r\n System.out.println(parser.htmlParsing (false, null, null, false));\r\n //System.out.println(htmlParsing (page3, \"euc-kr\"));\r\n\r\n\r\n } catch (Throwable t) {\r\n t.printStackTrace ();\r\n }\r\n }", "public static void main(String[] args) {\n \r\n PedersenScheme ps = new PedersenScheme();\r\n Element tag = ps.getTag();\r\n System.out.println(tag.convertToString());\r\n System.out.println(tag.toString());\r\n \r\n example1();\r\n \r\n }", "public static void main(String[] args) throws IOException {\n\t\tScanner sc = new Scanner(System.in);\n\t\tFileReader fin = null;\n\t\tFileWriter fout = null;\n\t\tXMLString x;\n\t\tScanner f;\n\t\tString fname, fpath, tpath, wd = \"\", tag, content;\n\t\tint ch, k = 0, n = 0 ;\n\t\tchar c;\n\t\tSystem.out.println(\"Enter the File Name (without .xml)\");\n\t\tfname = sc.next();\n\t\tfpath = \"C:\\\\Users\\\\HP\\\\Desktop\\\\adobe interview projects\\\\XML JSON Parser (1)\\\\src\\\\miniProject\\\\\" + fname + \".xml\";\n\t\tSystem.out.println(fpath);\n\t\ttpath = \"C:\\\\Users\\\\HP\\\\Desktop\\\\adobe interview projects\\\\XML JSON Parser (1)\\\\src\\\\miniProject\\\\\" + fname + \".txt\";\n\t\tSystem.out.println(tpath);\n\t\tSystem.out.print(\"Parsing \" + fname + \".xml\");\n\t\twhile(n!=5) {\n\t\t\tSystem.out.print(\" .\");\n\t\t\ttry {\n\t\t\t\tThread.sleep(1000);\n\t\t\t}\n\t\t\tcatch(Exception e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tn++;\n\t\t}\n\t\tSystem.out.println();\n\t\ttry {\n\t\t\tThread.sleep(1000);\n\t\t}\n\t\tcatch(Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tSystem.out.println(fname +\".xml PARSED SUCCESSFULLY !\");\n\t\ttry {\n\t\t\tThread.sleep(500);\n\t\t}\n\t\tcatch(Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tSystem.out.println(fname + \".txt FILE CREATED SUCCESSFULLY\");\n\t\tSystem.out.println();\n\t\ttry {\n\t\t\tfin = new FileReader(fpath);\n\t\t\tfout = new FileWriter(tpath);\n\t\t\tf = new Scanner(fin);\n\t\t\tf.useDelimiter(\"\\n\");\n\t\t\twhile(f.hasNext()) {\n\t\t\t\twd = f.next();\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tx = new XMLString();\n\t\t\t\ttag = x.XMLtoTag(wd);\n\t\t\t\t\n\t\t\t\tfor(int i=0; i<wd.length()-1; i++) {\n\t\t\t\t\tc = wd.charAt(i+1);\n\t\t\t\t\tif(wd.charAt(i) == '>') {\n\t\t\t\t\t\tif( !(Character.isLetter(c)) && !(Character.isDigit(c)) && !(x.isSpecialCharacter(c)) ) {\n\t\t\t\t\t\t\tk = 0;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tk = 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(tag != \"\") {\n\t\t\t\t\tif(k == 1) {\n\t\t\t\t\t\tSystem.out.print(tag + \" : \");\n\t\t\t\t\t\tfout.write(tag + \" : \");\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tSystem.out.print(tag);\n\t\t\t\t\t\tfout.write(tag);\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontent = x.XMLtoString(wd);\n\t\t\t\tSystem.out.println(content);\n\t\t\t\t\n\t\t\t\tfout.write(content);\n\t\t\t\t//Can use either for getting a newline\n\t\t\t\t//fout.write(\"\\r\\n\");\n\t\t\t\tfout.write(System.lineSeparator());\n\t\t\t}\n\t\t\t\n\t\t} catch (FileNotFoundException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\tSystem.out.println(fname + \".xml File Not Found\");\n\t\t\te.printStackTrace();\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tfinally {\n\t\t\ttry {\n\t\t\t\tif(fin != null) {\n\t\t\t\t\tfin.close();\n\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\tif(fout !=null) {\n\t\t\t\t\tfout.close();\t\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch(IOException e) {\n\t\t\t\tSystem.out.println(\"Unable to Close File\" + e);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t}", "public static List<GPSPeak> parseGPSOutput(String filename, Genome g) throws IOException {\n\t\tArrayList<GPSPeak> results = new ArrayList<GPSPeak>();\n\n\t\tint count = 0;\n BufferedReader bin = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));\n\t\t\n String line;\n while((line = bin.readLine()) != null) { \n line = line.trim();\n if (line.length()==0)\n \tcontinue;\n String[] f=line.split(\"\\t\");\n if (f[0].equals(\"Position\")||f[0].equals(\"chr\")){\n continue;\n }\n try {\n GPSPeak hit = GPSParser.parseLine(g, line, count);\n if (hit!=null) {\n results.add(hit);\n }\n } catch (RuntimeException e) {\n System.err.println(\"Parsing line \" + line);\n System.err.println(e.toString());\n throw(e);\n }\t\t\t\t\n count++;\n }\t\t\t\n if (bin != null) {\n bin.close();\n }\n results.trimToSize();\n \n\t\treturn results;\n\t}", "public ProgramParser(String[] args) throws InterpreterException {\n java.util.Scanner scanner;\n String text = \"\";\n try {\n scanner = new java.util.Scanner(new java.io.File(args[0]));\n text = scanner.useDelimiter(\"\\u005c\\u005cA\").next();\n scanner.close();\n ProgramParser.programCode = new java.io.StringReader(text);\n } catch (FileNotFoundException ex) {\n throw new InterpreterException(\"FileNotFoundException\", \"Check file path.\", ex.getMessage());\n }\n ProgramParser.stringInput = args[1];\n System.out.println(\"Program: \" + args[0] + \" - input: \" + stringInput);\n //System.out.println(\"code\\n\" + text + \"\\n---Done\");\n }", "public static void main(String[] args) {\n\t\tif (args.length != 1) {\n\t\t\tSystem.out.println(\"Broj argumenata naredbenog retka mora biti 1.\");\n\t\t\tSystem.exit(-1);\n\t\t}\n\t\t\n\t\tString filepath = args[0];\n\t\tString docBody = \"\";\n\t\t\n\t\ttry {\n\t\t\tdocBody = new String(Files.readAllBytes(Paths.get(filepath)), StandardCharsets.UTF_8);\n\t\t} catch (IOException e1) {\n\t\t\te1.printStackTrace();\n\t\t\tSystem.exit(-1);\n\t\t}\n\t\t\n\t\tSmartScriptParser parser = null;\n\t\t\n\t\ttry {\n\t\t\tparser = new SmartScriptParser(docBody);\n\t\t} catch(SmartScriptParserException e) {\n\t\t\tSystem.out.println(\"Unable to parse document!\");\n\t\t\tSystem.exit(-1);\n\t\t} catch(Exception e) {\n\t\t\tSystem.out.println(\"If this line ever executes, you have failed this class!\");\n\t\t\tSystem.exit(-1);\n\t\t}\n\t\t\n\t\tDocumentNode document = parser.getDocumentNode();\n\t\tString originalDocumentBody = createOriginalDocumentBody(document);\n\t\tSystem.out.println(originalDocumentBody);\n\t\t\n\t\tSmartScriptParser parser2 = new SmartScriptParser(originalDocumentBody);\n\t\tDocumentNode document2 = parser2.getDocumentNode();\n\t\tString originalDocumentBodySecond = createOriginalDocumentBody(document2);\n\t\t\n\t\tif (originalDocumentBody.equals(originalDocumentBodySecond)) {\n\t\t\tSystem.out.println(\"Identični\");\n\t\t}\n\t}", "private void loadInformation(){\n\t\ttry{\n\t\t\tFileReader fr = new FileReader(\"SpaceProgramGaussDistribution.txt\");\n\t\t\tBufferedReader br = new BufferedReader(fr);\n\t\t\tScanner sc = new Scanner(br);\n\t\t\t\n\t\t\tString info = \"\";\n\t\t\t\n\t\t\twhile(sc.hasNextLine()){\n\t\t\t\tinfo += sc.nextLine();\n\t\t\t}\n\t\t\t\n\t\t\tString split[] = info.split(\"#\");\n\t\t\t\n\t\t\tfor(int i = 0; i < split.length; i++){\n\t\t\t\tpopulationInfo += split[i]+\"\\n\";\n\t\t\t}\n\t\t\tsc.close();\n\t\t\tbr.close();\n\t\t\tfr.close();\n\t\t\t\n\t\t}catch(Exception e){\n\t\t\tSystem.out.println(\"File not found: SpaceProgramGaussDistribution.txt\");\n\t\t}\n\t}", "public static void main(String[] args) {\n\t\t\ttry(FileReader fr = new FileReader(\"Numbers2.txt\");\n\t\t\t\tBufferedReader br= new BufferedReader(fr); )\n\t\t\t{\n\t\t\t\t\n\t\t\t\tint index=0;\n//\t\t\t\tThis is one way to read code from txt file\n\t\t\t\twhile(br.ready()) {\n\t\t\t\t\tSystem.out.print(++index+\":\");\n\t\t\t\t\tSystem.out.println(br.readLine());\t\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch(FileNotFoundException e){\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\t\n\t\t\tcatch(IOException e){\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\t\t\n\t\t\tfinally {\n\t\t\tSystem.out.println(\"Ended..\");\n\t\t\t\t\n\t\t\t}\n\t\t}", "public static void main(String[] args)\n {\n URL xmlURL = RpgConfMain.class.getResource(\"/baseList.xml\");\n\n if(xmlURL == null)\n {\n System.out.println(\"Failed to read xml file, xmlURL was null\");\n System.exit(-1);\n }\n\n //Getting the xml file\n try(InputStream xmlStream = (InputStream) xmlURL.getContent())\n {\n //Reading the xml file\n xmlReader = new StructXMLReader(xmlStream);\n } catch (IOException | XMLStreamException e)\n {\n System.exit(-1);\n e.printStackTrace();\n }\n\n MainFrame frame = new MainFrame(new ConfigCode(), xmlReader); //Used before initialization is wrong. If the xmlReader\n //variable is wrong, the program will exit\n\n frame.setVisible(true);\n }", "public static void main(String[] args) throws IOException {\n\t\tFileInputStream fis=new FileInputStream(\"F:\\\\WORKSPACE\\\\OOPS\\\\testdata.properties\");\n\t\t\n\t\tProperties pro=new Properties();\n\t\t\n\t\tpro.load(fis);\n\t\t\n\t\tString Name=pro.getProperty(\"name\");\n\t\t\t\tSystem.out.println(Name);\n\t\t\t\tSystem.out.println(pro.getProperty(\"Name\"));\n\t\t\t\tSystem.out.println(pro.getProperty(\"At.Post\"));\n\t\t\t\tSystem.out.println(pro.getProperty(\"Ta\"));\n\t\t\t\tSystem.out.println(pro.getProperty(\"Dist\"));\n\t\t\t\tSystem.out.println(pro.getProperty(\"Mobile-number\"));\n\t\t\t\tSystem.out.println(pro.getProperty(\"collage\"));\n\t\t\t\tSystem.out.println(pro.getProperty(\"Bike-number\"));\n\t\t\t\t\n\n\t}", "public static void main(String[] args) {\n ReadMappings rs = new ReadMappings();\n try {\n Hashtable result = rs.getMappingsFromFile();\n Enumeration en = result.elements();\n while(en.hasMoreElements()) {\n System.out.println(en.nextElement());\n }\n\n System.out.println(\"Pons:\"+result.get(\"Pons\"));\n System.out.println(\"Hypothalamus:\"+result.get(\"Hypothalamus\"));\n System.out.println(\"Medulla:\"+result.get(\"Medulla\"));\n } catch(Exception e) {\n e.printStackTrace();\n }\n }", "public static void main(String[] args) throws IOException {\r\n\t\tInputStreamReader isr = null;\r\n\t\tBufferedReader br = null;\r\n\t\tInputStream is = new ByteArrayInputStream(\"C:\\\\Users\\\\Amit\\\\Desktop\\\\AMIT KUMAR PRADHAN.docx\".getBytes());\r\n\t\tStringBuilder sb = new StringBuilder();\r\n\t\tString content;\r\n\t\ttry {\r\n\t\t\tisr = new InputStreamReader(is);\r\n\t\t\tbr = new BufferedReader(isr);\r\n\t\t\twhile ((content = br.readLine()) != null) {\r\n\t\t\t\tsb.append(content);\r\n\t\t\t}\r\n\t\t} catch (IOException ioe) {\r\n\t\t\tSystem.out.println(\"IO Exception occurred\");\r\n\t\t\tioe.printStackTrace();\r\n\t\t} finally {\r\n\t\t\tisr.close();\r\n\t\t\tbr.close();\r\n\t\t}\r\n\t\tString mystring = sb.toString();\r\n\t\tSystem.out.println(mystring);\r\n\t}", "public static void main(String[] args) {\n\t\ttry {\n\t\t\t// Instantiates a InputStreamReader that connects to the file passed in by input redirection,\n\t\t\t// which is then thrown into a BufferedReader enabling the lines to be read. The BufferedReader\n\t\t\t// is then passed into the fetchEvents method, which will create Event objects based on the file contents\n\t\t\t// and return it as a SortedEventList.\n\t\t\tSortedEventList events = fetchEvents(new BufferedReader(new InputStreamReader(System.in), 1));\n\t\t\tint place = 1; // A place counter.\n\t\t\t// Iterates foreach Event object.\n\t\t\t// Since the LinkedList implements Iterable it can be used in an enchanced for.\n\t\t\tfor (Event event : events) { \n\t\t\t\t// It will output the event based on it's toString() with the place appended after.\n\t\t\t\tSystem.out.println(event + ((place == 1) ? GOLD : (place == 2) ? SILVER : (place == 3) ? BRONZE : EMPTY_STRING));\n\t\t\t\tplace++; // Increments place.\n\t\t\t}\n\t\t} catch (Exception ex) {\n\t\t\t// Somethings wrong. It outputs the thrown exception message.\n\t\t\tSystem.out.println(ex.getMessage()); \n\t\t}\n\t}", "public static void main(String[] args) throws Exception {\n String[] arrays = BillPraser.getInstance().generateBillCodeAndNumber(\"D:\\\\log\\\\pdf\\\\liantong.pdf\");\n System.out.println(Arrays.toString(arrays));\n// testFindNextStr();\n }", "public static void main(String[] args) {\n appendInfoToFile();\n readFile();\n }", "public static void main(String[] args) throws FileNotFoundException {\n\t\t\t\n\t\tScanner scan = new Scanner(new File(\"input.txt\"));\n\t\t\n\t\tParser parse;\n\t\tCode code = new Code();\n\t\tSymbolTable st = new SymbolTable();\n\t\t\n\t\twhile(scan.hasNextLine()) {\n\t\t\tString inCode = scan.nextLine();\t\n\t\t\tparse = new Parser(inCode);\n\t\t}\n\t\t\n\t}", "public static void main(String[] args) throws Exception {\n Scanner scan = new Scanner(new File(\"prob01.txt\"));\n String a = scan.nextLine();\n System.out.println(\"Greetings, O Honorable \" + a + \" the Magnificent! May I kiss your signet ring?\");\n }", "public static void main(String[] args) {\n\t\ttry {\n\t\t\tFileInputStream fileInputStream=new FileInputStream(\"src/test.txt\");\n\t\t\tInputStreamReader inputStreamReader=new InputStreamReader(fileInputStream);\n\t\t\tchar[] chars=new char[97];\n\t\t\tString str=\"\";\n//\t\t\tint i;\n\t\t\twhile (inputStreamReader.read(chars)!=-1) {\n\t\t\t\tstr+=new String(chars);\n\t\t\t}\n\t\t\tSystem.out.println(str);\n\t\t} catch (FileNotFoundException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t}", "public static void main(String[] args) throws FileNotFoundException {\n String paragraphs[]=parser(\"tomSawyer.txt\");\r\n\r\n //creates ID for each paragraph\r\n String[] ID=new String[paragraphs.length];\r\n for(int i=0;i<paragraphs.length;i++)\r\n {\r\n ID[i]=\"\"+(i);\r\n paragraphs[i]=paragraphs[i].trim();\r\n }\r\n\r\n //read ID from user\r\n System.out.println(\"Enter the ID of the paragraph you want <eg. 3> :\");\r\n Scanner scan=new Scanner(System.in);\r\n String key=scan.next();\r\n int flag=0;\r\n int pos=-1;\r\n\r\n //search ID\r\n for(int i=1;i<ID.length;i++)\r\n {\r\n if(ID[i].equalsIgnoreCase(key))\r\n {\r\n flag=1;\r\n pos=i;\r\n break;\r\n }\r\n }\r\n\r\n //if match, display corresponding para\r\n if(flag==1)\r\n {\r\n System.out.println(paragraphs[pos]);\r\n }\r\n\r\n //else error\r\n else\r\n {\r\n System.out.println(\"No such ID exists\");\r\n }\r\n}", "public static void main(String[] args) {\n\t\t\r\n\t\tSystem.out.println(\"Ngram\");\r\n\t\tSystem.out.println(Configuration.getNforNgram());\r\n\t\t\r\n\t\tSystem.out.println(\"crterion weight\");\r\n\t\tSystem.out.println(getWeight(\"ClassName\"));\r\n\t\tSystem.out.println(getWeight(\"ClassAttribute\"));\r\n\t\tSystem.out.println(getWeight(\"ClassOperation\"));\r\n\t\tSystem.out.println(getWeight(\"AttributeName\"));\r\n\t\tSystem.out.println(getWeight(\"AttributeType\"));\r\n\t\tSystem.out.println(getWeight(\"OperationName\"));\r\n\t\tSystem.out.println(getWeight(\"OperationType\"));\r\n\t\tSystem.out.println(getWeight(\"Parameter\"));\r\n\t\tSystem.out.println(getWeight(\"ParameterName\"));\r\n\t\tSystem.out.println(getWeight(\"ParameterType\"));\r\n\t\t\r\n\t\tSystem.out.println(\"thresholed\");\r\n\t\tSystem.out.println(getThreshold(\"ClassName\"));\r\n\t\tSystem.out.println(getThreshold(\"ClassAttribute\"));\r\n\t\tSystem.out.println(getThreshold(\"ClassOperation\"));\r\n\t\tSystem.out.println(getThreshold(\"AttributeName\"));\r\n\t\tSystem.out.println(getThreshold(\"AttributeType\"));\r\n\t\tSystem.out.println(getThreshold(\"OperationName\"));\r\n\t\tSystem.out.println(getThreshold(\"OperationType\"));\r\n\t\tSystem.out.println(getThreshold(\"Parameter\"));\r\n\t\tSystem.out.println(getThreshold(\"ParameterName\"));\r\n\t\tSystem.out.println(getThreshold(\"ParameterType\"));\r\n\t\t\t\r\n\t\t\r\n\t}", "public static void main(String[] args) throws IOException {\n\r\n ParserMain Parse = new ParserMain(args);\r\n Node n_program = Parse.program();\r\n\tSystem.out.println(\"\\ninside parser: parsing end, pass tree ro type checking\\n\");\r\n CodeGener cg= new CodeGener(n_program,args[0]); ////////////////////////////////////////////////////////////////////////////////////kavita\r\n h_typeCheckingClass tp = new h_typeCheckingClass(n_program);\r\n Node result = tp.starttype(n_program);\r\n\tSystem.out.println(\"\\ninside parser: TYPE checking end, pass tree to WRITING AST\\n\");\r\n AST2word ast=new AST2word();\r\n ast.read(result, args);\r\n\r\n\r\n\r\n\r\n }", "public static void main(String[] args) throws IOException, ScannerException{\n Scanner scan = new Scanner(\"test_input/ex1.tiger\");\n List<Token> tokens = scan.getTokens();\n for (Token tok : tokens) {\n System.out.println(tok.allDetails());\n }\n }", "public static void main(String[] args) throws IOException {\n //arg0: dictDir\n //arg1: partOfSpeech (char)\n //args1+: words to lookup\n\n try {\n final String dictDir = args[0].length() > 1 ? args[0] : null;\n final String posChar = args[1];\n final int wordsIndex = 2;\n\n final WordNetFile wordNetFile = WordNetFile.getInstance(dictDir, WordNetUtils.parsePOS(posChar));\n\n for (int i = wordsIndex; i < args.length; ++i) {\n final List<Entry> entries = wordNetFile.getEntries(args[i]);\n\n System.out.print(args[i] + \" --> \");\n if (entries == null) {\n System.out.print(\"<no entries>\");\n }\n else {\n boolean didFirst = false;\n for (Entry entry : entries) {\n if (didFirst) System.out.print(\", \");\n System.out.print(entry);\n didFirst = true;\n }\n }\n System.out.println();\n }\n }\n finally {\n WordNetUtils.closeAll();\n }\n }", "public static void main(String[] args) {\n\t\t\n\t\tVariablePractice4 vp = new VariablePractice4();\n\t\tvp.inputString();\n\t\t\n\t}", "public static void main(final String[] args) throws IOException, TikaException, SAXException {\n\t File file = new File(args[0]);\n\n Tika tika = new Tika();\n \n //detecting the file type using detect method\n String filetype = tika.detect(file);\n //System.out.println(filetype);\n \n //Parser method parameters\n //Parser parser = new AutoDetectParser();\n //Parser parser = new DcXMLParser();\n Parser parser = new Eml211Parser();\n \n BodyContentHandler handler = new BodyContentHandler();\n Metadata metadata = new Metadata();\n FileInputStream inputstream = new FileInputStream(file);\n ParseContext context = new ParseContext();\n \n parser.parse(inputstream, handler, metadata, context);\n \n //System.out.println(handler.toString());\n \n System.out.println(\"Extracting Metadata of the document: \");\n //getting the list of all meta data elements \n String[] metadataNames = metadata.names();\n \n for(String name : metadataNames) {\t\t \n System.out.println(name + \": \"+ metadata.get(name));\n } \n }", "public static void main(String[] args) throws JsonGenerationException, JsonMappingException, IOException{\n\t\tDictionary root = new Dictionary();\n\t\tparse Parse = new parse();\n long begin = System.currentTimeMillis();\n //String fileName = args[0];\n //String examine = args[1];\n Parse.parseFILE(\"word_tagged.txt\", root);\n long end = System.currentTimeMillis();\n System.out.println(\"insertion time elapse: \" + (double)(end-begin)/1000);\n \n \n /***********************Read data from phrase check dataset**************************/\n \n\t\tBigram n = new Bigram(Parse.parseFILE(\"Grammar.txt\"));\n\t n.train();\n\t ObjectMapper phrase = new ObjectMapper();\n\t String PhraseJson = phrase.writeValueAsString(n);\n\t phrase.writeValue(new File(\"Phrase.json\"), n);\n\t \n\t /***********************Read data from grammar rule dataset**************************/\n\t BuildRule rule = new BuildRule(Parse.parseFILE(\"Grammar.txt\"), 3, root);\n\t rule.train();\n\t \n\t System.out.println(rule.testing);\n\t ConvertToJson con = new ConvertToJson(rule);\n\t ObjectMapper mapper = new ObjectMapper();\n\t String ruleJson = mapper.writeValueAsString(rule);\n\t\tmapper.writeValue(new File(\"GrammarRule.json\"), rule);\n /***************************Begin to check*************************************/\n\t}", "public void prog() {\r\n \t\r\n // First parse declarations\r\n decls();\r\n // Next parse expression\r\n ArrayList<Integer> values = new ArrayList<Integer>(); \r\n values = exprs(values);\r\n for(int i = 0; i < values.size(); i++) {\r\n \tSystem.out.print(values.get(i) + \" \");\r\n }\r\n System.out.println();\r\n \r\n \r\n //int value = expr();\r\n // Finally parse the end of file character\r\n match(TokenType.END_OF_FILE);\r\n //System.out.println(\"Value of expression is: \" + value);\r\n }", "void parse(String[] args);", "public static void main(String[] args) {\n\t\t// String path = \"/devel/ostwald/projects/schemedit-project/web/WEB-INF/data/Adn-to-Asf-mappings.xml\";\n\t\tString path = \"C:/Documents and Settings/ostwald/devel/projects/dcs-project/web/WEB-INF/data/Adn-to-Asn-v1.2.5-info.xml\";\n\t\tAsnToAdnMapper mapper = new AsnToAdnMapper(path);\n\n\t\tString id = Constants.ASN_PURL_BASE + \"S1002B43\";\n\t\tprtln(\"adnText for \" + id + \"\\n\" + mapper.getAdnText(id));\n\t\tString adnText = mapper.getAdnText(id);\n\t\tif (adnText != null)\n\t\t\tprtln(\"id back atcha: \" + mapper.getAsfId(adnText));\n\t}", "public void Main(){\n \n \n String dna = \"ATGCTGCTGATGTAA\";\n Main one = new Main();\n processGenes(testProcessGenes(fr));\n \n //System.out.println(processGenes(testProcessGenes(fr)));\n \n \n //System.out.println(processGenes());\n //System.out.println(cgRatio(dna));\n //System.out.println(countCTG(dna));\n //System.out.println(HOW RIGHT HERE?);\n //testProcessGenes() takes the fileresource and converts it into a \n //storageresource.\n //processgenes takes a SR and processes it. \n //How would i call the two in main?\n \n \n \n }", "public static void main(String[] args) throws IOException {\n\t\ttry {\n\t\t\tStringBuilder sb = null;\n\t\t\tint x = Integer.parseInt(args[1]), y = Integer.parseInt(args[2]);\n\t\t\t// creates a FileReader Object\n\t\t\tFile file = new File(args[0] + \".txt\");\n\t\t\tBufferedReader br = new BufferedReader(new FileReader(file));\n\n\t\t\tfile = new File(args[3] + \".txt\");\n\n\t\t\t// creates the file\n\t\t\tfile.createNewFile();\n\n\t\t\t// creates a FileWriter Object\n\t\t\tFileWriter fwriter = new FileWriter(file, false);\n\t\t\tString ip;\n\t\t\tBufferedWriter bwriter = new BufferedWriter(fwriter);\n\t\t\twhile ((ip = br.readLine()) != null) {\n\t\t\t\tif (ip.charAt(0) == '>') {\n\t\t\t\t\tif (sb != null) {\n\t\t\t\t\t\tsequencePartitioning(sb, x, y, bwriter);\n\t\t\t\t\t}\n\t\t\t\t\tsb = new StringBuilder();\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tsb.append(ip);\n\t\t\t}\n\t\t\tif (sb != null) {\n\t\t\t\tsequencePartitioning(sb, x, y, bwriter);\n\t\t\t}\n\t\t\tbwriter.close();\n\t\t\tbr.close();\n\n\t\t} catch (FileNotFoundException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\tSystem.out.println(\"Unable to locate file \" + args[0]);\n\t\t\te.printStackTrace();\n\t\t}\n\t}", "private static String getContent() throws IOException\n\t{\n\t\tString instr = \"\";\n\t\ttry\n\t\t{\n\t\t\tStream<String> lines = Files.lines(Paths.get(\"input.txt\"));\n\t\t\tinstr = lines.skip(currentFilePointer).findFirst().get();\n\t\t\tinstr = instr.replaceAll(\"#\", \"\");\n\t\t\tinstr = instr.replaceAll(\",\", \"\");\n\t\t\tcurrentFilePointer++;\n\t\t\tcurrentPC = currentPC + 4;\n\t\t\tSystem.out.println(\"-------------------------Instruction Address : \" + currentPC + \"------------------------\");\n\n\t\t} catch (Exception ex)\n\t\t{\n//\t\t\t ex.printStackTrace();\n\t\t}\n\t\treturn instr;\n\t}", "public static void main(String[] argv) throws IOException, ParseException {\r\n\r\n\t\tif (argv.length < 1) {\r\n\t\t\tSystem.err.println(\"Usage: java GeoGDSPArser inputFilename.soft\");\r\n\t\t\tSystem.exit(2);\r\n\t\t}\r\n\r\n\t\tGeoGDSParser parser = new GeoGDSParser();\r\n\t\tparser.parseFile(argv[0]);\t\t\r\n\r\n\t\tfor (String k: parser.singleKeys) {\r\n\t\t\tString val = parser.getSingleValue(k);\r\n\t\t\tif (val != null) {\r\n\t\t\t\tSystem.out.println(k + \": \" + val);\r\n\t\t\t}\r\n\t\t}\r\n\t\tfor (String k: parser.multiKeys) {\r\n\t\t\tArrayList<String> vals = parser.getValues(k);\t\t\t\t\t\r\n\t\t\tif (vals != null) {\r\n\t\t\t\tSystem.out.println(k + \":\");\r\n\t\t\t\tfor (String v: vals) {\r\n\t\t\t\t\tSystem.out.println(\"\\t\" + v);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}", "public static void main( String[] args ) throws FileNotFoundException, IOException, URISyntaxException\n {\n \tif((args != null) && (args.length > 0)) {\n \t\tif(args[0].contains(\"-help\")) {\n \t\t\tprintHelp();\n \t\t\tSystem.exit(0);\n \t\t}\n \t\tif(args[0].contains(\"--help\")) {\n \t\t\tprintHelp();\n \t\t\tSystem.exit(0);\n \t\t}\n \t\tif(args[0].contains(\"-h\")) {\n \t\t\tprintHelp();\n \t\t\tSystem.exit(0);\n \t\t}\n \t\tif(args[0].contains(\"?\")) {\n \t\t\tprintHelp();\n \t\t\tSystem.exit(0);\n \t\t}\n \t}\n\n \t//If the -l is used then print a list of region ids and stop\n \tif((args != null) && (args.length > 0)) {\n \t\tif(args[0].contains(\"-l\")) {\n \t\t\tValidate.notNull(args[1], \"Using the -l requires a zipcode after the argument\");\n \t\t\tValidate.notEmpty(args[1], \"Using the -l requires a zipcode after the argument\");\n \t\t\t\n \t\t\tGuideHelper.printHelp(args[1]);\n \t\t\tSystem.exit(0);\n \t\t}\n \t}\n\n \t//Assume we are parsing, this is the default\n \tStopWatch watch = new StopWatch();\n \twatch.start();\n \t\n \tprops = new Properties();\n \t\n \t//Read the property file if passed in\n \tif((args != null) && (args.length > 0)){\n \n\t \tFile file = new File(args[0]);\n\t \tValidate.isTrue(file.exists(), \"The file `\" + args[0] + \"` could not be located\");\n\t \tprops.load(new FileInputStream(file));\n \t} else {\n \t\t\n \t\t//If not passed in then search the classpath\n \t\tGrabber grabber = new Grabber();\n \t\tInputStream in = grabber.getClass().getClassLoader().getResourceAsStream(PROPERTY_DEFAULT_FILE_NAME);\n \t\t\n \t\t//If found in classpath use that, if not search local directory\n \t\tif(in != null) {\n \t \tprops.load(in);\n \t\t} else {\n \t\t\tFile file = new File(PROPERTY_DEFAULT_FILE_NAME);\n \t\t\t\n \t\t\tif(file.exists()) {\n \t\t \tprops.load(new FileInputStream(file)); \t\t\t\t\n \t\t\t} \n \t\t}\n \t}\n \t\n \t//Collect all the properties\n \tString outputDir = props.getProperty(PROPERTY_OUTPUT_DIRECTORY, PROPERTY_OUTPUT_DIRECTORY_DEFAULT);\n \tString outputFile = props.getProperty(PROPERTY_OUTPUT_FILE, PROPERTY_OUTPUT_FILE_DEFAULT);\n \tString parseHours = props.getProperty(PROPERTY_PARSE_HOURS, PROPERTY_PARSE_HOURS_DEFAULT);\n \tString zipcode = props.getProperty(PROPERTY_ZIPCODE, PROPERTY_ZIPCODE_DEFAULT);\n \tString regionid = props.getProperty(PROPERTY_REGION_ID, PROPERTY_REGION_ID_DEFAULT);\n \t\n \tlog.info(\"Starting Download ---------------\");\n \tlog.info(\"Parameters: \");\n \tlog.info(\" Output Directory: \" + outputDir);\n \tlog.info(\" Output File Name: \" + outputFile);\n \tlog.info(\" Scrape Hours Ahead: \" + parseHours);\n \tlog.info(\" Region Id: \" + regionid);\n \tlog.info(\" Zipcode: \" + zipcode);\n \t\n \tFile dir = new File(outputDir);\n \tif(!dir.exists()) {\n \t\tValidate.isTrue(dir.mkdirs(), \"Output directory `\" + outputDir + \"` does not exist and could not be created\");\n \t}\n \t\n \tFile guide = new File(outputDir + File.separator + outputFile); \t\n \tint parseHoursInt = Integer.parseInt(parseHours);\n \t\n GuideScrapper gs = new GuideScrapper();\n \n try {\n gs.scrapeHoursAhead(parseHoursInt, guide, regionid, zipcode);\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n \n watch.stop();\n \n log.info(\"Total Run Time: \" + watch);\n \n }", "public static void main(String[] args) {\n\t\tNode root = null;\r\n\t\tboolean print=false; //是否打印错误信息\r\n\t\ttry {\r\n\t\t\troot = new MiniJavaParser(System.in).Goal();\r\n\t\t\t//System.out.println(\"Program parsed successfully\");\r\n\t\t}\r\n\t\tcatch (ParseException e) {\r\n\t\t\tSystem.out.println(e.toString());\r\n\t\t\tSystem.exit(1);\r\n\t\t}\r\n\r\n\t\t// 建立符号表,判断是否重定义,是否有循环继承,是否有重载\r\n\t\tSymbolTableVisitor stv = new SymbolTableVisitor();\r\n\t\troot.accept(stv,null);\r\n\t\tif (stv.error.size()!=0) {\r\n\t\t\tSystem.out.println(\"Type error\");\r\n\t\t\t\r\n\t\t\tif (print){\r\n\t\t\t\tfor (int i=0;i<stv.error.size();i++){\r\n\t\t\t\t\tSystem.out.println(stv.error.get(i));\r\n\t\t\t\t}\t\t\t\r\n\t\t\t}\r\n\t\t\tSystem.exit(1);\r\n\t\t}\r\n\t\t\r\n\t\t// 类型检查,检查各种类型是否匹配\r\n\t\tTypeCheckVisitor tcv = new TypeCheckVisitor(stv);\r\n\t\troot.accept(tcv,null);\r\n\t\tif (tcv.error.size()!=0) {\r\n\t\t\tSystem.out.println(\"Type error\");\r\n\t\t\t\r\n\t\t\tif (print){\r\n\t\t\t\tfor (int i=0;i<tcv.error.size();i++){\r\n\t\t\t\t\tSystem.out.println(tcv.error.get(i));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tSystem.exit(1);\r\n\t\t} else {\r\n\t\t\t//System.out.println(\"Program type checked successfully\");\r\n\t\t}\r\n\t\t\r\n\t\t//生成Piglet代码\r\n\t\tPigletGenerateVisitor pg=new PigletGenerateVisitor(stv);\r\n\t\troot.accept(pg,null);\r\n\t}", "public String parse(File file);", "public static void main(String[] args) {\n TextAnalyzerService tas = new TextAnalyzerService();\n ResultObject resultObject;\n List<String> resultList = new ArrayList<>();\n String path = \"1.txt\";\n boolean isBracketsOk = false;\n\n try {\n isBracketsOk = tas.parsing(path).equals(\"correct\") ? true : false;\n } catch (IOException e) {\n e.printStackTrace();\n }\n\n\n try {\n resultList = tas.readFile(path);\n } catch (IOException e) {\n e.printStackTrace();\n }\n\n resultObject = new ResultObject(path, resultList, isBracketsOk);\n //System.out.println(resultObject.toString());\n\n for(String x : resultObject.getListOfString()){\n System.out.println(x);\n }\n }", "public static void startup() {\n\t\tString thisLine;\n\t\tString currentName = \"\";\n\t\tboolean next = true;\n\n\t\t// DEBUG\n\t\t// System.out.println(\"entered here\");\n\n\t\t// Loop across the arguments\n\n\t\t// Open the file for reading\n\t\ttry {\n\t\t\tBufferedReader br = new BufferedReader(new FileReader(GIGA_WORD));\n\t\t\twhile ((thisLine = br.readLine()) != null) {\n\t\t\t\tString str = thisLine.trim();// .replaceAll(\"(\\\\r|\\\\n)\", \"\");\n\t\t\t\tString[] wordNumber = str.split(\"[ ]{2,}\");\n\t\t\t\tString word = wordNumber[0].toLowerCase();\n\t\t\t\tint cnt = Integer.parseInt(wordNumber[1]);\n\t\t\t\tgigaMap.put(word, cnt);\n\t\t\t}\n\t\t\tbr.close();\n\t\t\tbr = null;\n\t\t\tbr = new BufferedReader(new FileReader(FILE_NAME));\n\t\t\twhile ((thisLine = br.readLine()) != null) {\n\t\t\t\tString str = thisLine.trim();// replaceAll(\"(\\\\r|\\\\n)\", \"\");\n\t\t\t\tif (str.equals(\"[Term]\")) {\n\t\t\t\t\tnext = true;\n\t\t\t\t}\n\t\t\t\tif (str.startsWith(\"name:\")) {\n\t\t\t\t\tif (next) {\n\t\t\t\t\t\tcurrentName = str.replaceAll(\"name: \", \"\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (str.startsWith(\"synonym:\")) {\n\t\t\t\t\tif (str.contains(\"EXACT\") || str.contains(\"NARROW\")) {\n\t\t\t\t\t\t// synonym..\n\t\t\t\t\t\tPattern pattern = Pattern\n\t\t\t\t\t\t\t\t.compile(\"synonym:.*\\\"(.*)\\\".*\");\n\t\t\t\t\t\tMatcher matcher = pattern.matcher(str);\n\t\t\t\t\t\t// DEBUG\n\t\t\t\t\t\t// System.err.println(str);\n\t\t\t\t\t\tif (matcher.find()) {\n\t\t\t\t\t\t\tString syno = matcher.group(1);\n\t\t\t\t\t\t\tif (!currentName.equals(\"\")) {\n\t\t\t\t\t\t\t\t// System.err.format(\"%s:%s.\\n\", currentName,\n\t\t\t\t\t\t\t\t// syno);\n\n\t\t\t\t\t\t\t\tadd(currentName, syno);\n\t\t\t\t\t\t\t\tadd(syno, currentName);\n\t\t\t\t\t\t\t\trecursiveAddSyno(currentName, syno);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbr.close();\n\t\t\tbr = null;\n\t\t} catch (IOException e) {\n\t\t\tSystem.err.println(\"Error: \" + e);\n\t\t}\n\t}", "public void startDocument()\r\n\t{\r\n\t marc_out.add(\"=LDR 00000nam\\\\\\\\22000007a\\\\4500\") ;\r\n\t marc_out.add(\"=001 etd_\" + pid);\r\n\t marc_out.add(\"=003 MiAaPQ\");\r\n\t marc_out.add(\"=006 m\\\\\\\\\\\\\\\\fo\\\\\\\\d\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");\r\n\t marc_out.add(\"=007 cr\\\\mnu\\\\\\\\\\\\aacaa\");\r\n\t marc_out.add(\"=040 \\\\\\\\$aMiAaPQ$beng$cDGW$dDGW\");\r\n\t marc_out.add(\"=049 \\\\\\\\$aDGWW\");\r\n\t marc_out.add(\"=504 \\\\\\\\$aIncludes bibliographical references.\");\r\n\t marc_out.add(\"=538 \\\\\\\\$aMode of access: Internet\");\r\n marc_out.add(\"=996 \\\\\\\\$aNew title added ; 20\" + running_date);\r\n marc_out.add(\"=998 \\\\\\\\$cgwjshieh ; UMI-ETDxml conv ; 20\" + running_date);\r\n\t marc_out.add(\"=852 8\\\\$bgwg ed$hGW: Electronic Dissertation\");\r\n\t marc_out.add(\"=856 40$uhttp://etd.gelman.gwu.edu/\" + pid + \".html$zClick here to access.\");\r\n\r\n }", "public static void main(String[] args) {\n\t\tstringprg1 p = new stringprg1();\n\t\tScanner S = new Scanner(System.in);\n\t\tString in1,in2;\n\t\tint pin,num;\n\t\tSystem.out.println(\"Enter a name\");\n\t\tin1 =S.next();\n\t\tSystem.out.println(\"Enter a name\");\n\t\tin2 =S.next();\n\t\tSystem.out.println(\"Enter a pin\");\n\t\tpin =S.nextInt();\n\t\tSystem.out.println(\"Enter a number\");\n\t\tnum =S.nextInt();\n\t\tString result = p.generator(in1, in2, pin, num);\n\t\tSystem.out.println(result);\n\t}", "public static void main(String[] args) {\n String s1 = \"/Users/ElvisLee/Dropbox/workspace/drjava_workspace/algorithms/WordNet/wordnet/synsets.txt\";\n String s2 = \"/Users/ElvisLee/Dropbox/workspace/drjava_workspace/algorithms/WordNet/wordnet/hypernyms.txt\";\n WordNet wordnet = new WordNet(s1, s2);\n Outcast outcast = new Outcast(wordnet);\n for (int t = 0; t < args.length; t++) {\n In in = new In(args[t]);\n String[] nouns = in.readAllStrings();\n StdOut.println(args[t] + \": \" + outcast.outcast(nouns));\n }\n }", "public void parse(String filename);", "public static void main(String[] args) {\n\t\tString configFileName = args[0];\r\n\t\tScanner input = new Scanner(System.in);\r\n\t\t// Read File\r\n\t\tRIP_v2 reader = new RIP_v2();\r\n\t\treader.readFile(configFileName);\r\n\t}", "public static void main(String args[])\n\t{\n\t\tString fileName = \"../Test Programs/cast.cpp\";\n\t\tParser parser = new Parser(new Lexer(fileName));\n\t\tDisplay.print(0, \"Begin parsing... \" + fileName + \"\\n\");\n\t\tProgram prog = parser.program();\n\t\tprog.display(); // display abstract syntax tree\n\t}", "public static void main(String[] args) throws IOException {\n\t\t// TODO Auto-generated method stub\n\t\tJsonFileParser parser = new JsonFileParser();\n\t\tparser.parseJsonFile(args);\n\t\tList<String> labelset = parser.getLset();\n\t\tfor(String label : labelset){\n\t\t\tSystem.out.println(label);\n\t\t}\n\t\tList<String> corpus = parser.getCorpus();\n\t\tfor(String doc : corpus){\n\t\t\tSystem.out.println(doc);\n\t\t}\n\t\tList<String> labels = parser.getLabels();\n\t\tfor(String label : labels){\n\t\t\tSystem.out.println(label);\n\t\t}\n\t\tList<String> headerInforList = parser.getPmids();\n\t\tfor(String pmid : headerInforList){\n\t\t\tSystem.out.println(pmid);\n\t\t}\n\t}", "public void Parse()\n {\n String prepend = \"urn:cerner:mid:core.personnel:c232:\";\n try{\n\n BufferedReader br = new BufferedReader(new FileReader(new File(path)));\n\n String line;\n\n while ((line = br.readLine()) != null)\n {\n line = line.trim();\n String[] lines = line.split(\",\");\n for (String entry : lines)\n {\n entry = entry.trim();\n entry = entry.replace(prepend, replace);\n System.out.println(entry+\",\");\n }\n\n }\n \n br.close();\n }catch(IOException IO)\n {\n System.out.println(IO.getStackTrace());\n } \n \n }", "public static void main(String[] args)\n/* */ {\n/* 214 */ DisabledPreferencesFactory.install();\n/* 215 */ String dataFilename = null;\n/* 216 */ String parserFilename = null;\n/* 217 */ ParserPanel parserPanel = new ParserPanel();\n/* 218 */ if (args.length > 0) {\n/* 219 */ if (args[0].equals(\"-h\")) {\n/* 220 */ System.out.println(\"Usage: java edu.stanford.nlp.parser.ui.ParserPanel [parserfilename] [textFilename]\");\n/* */ } else {\n/* 222 */ parserFilename = args[0];\n/* 223 */ if (args.length > 1) {\n/* 224 */ dataFilename = args[1];\n/* */ }\n/* */ }\n/* */ }\n/* */ \n/* 229 */ Parser parser = new Parser(parserFilename, dataFilename);\n/* 230 */ parser.setVisible(true);\n/* */ }", "public static void main(String[] args) {\n\n FoodWineDatasetParser fwdp = new FoodWineDatasetParser();\n\n fwdp.loadPizzaIngredients(\"resource/pizza_ingredients.tsv\");\n fwdp.getPizzaIngredients();\n\n }", "public static void main(String[] args) throws IOException {\n Dictionary d = new Dictionary(\"whatevs\", \"/home/mayhew/IdeaProjects/ner-annotation/bendict.txt\", \"testuser\");\n }", "static public void main(String argv[]) {\n String archivo_a_parsear = \"/home/maldad/repos/automatas/semantico/EjemploA/src/ejemploa/test.txt\";\n try {\n parser p = new parser(new Lexer(new FileReader(archivo_a_parsear)));\n Object result = p.parse().value; \n } catch (Exception e) {\n /* do cleanup here -- possibly rethrow e */\n e.printStackTrace();\n }\n }", "public static void main(String[] args) throws IOException {\n \n // set parameter set list\n ParameterSetListMaker maker = new ParameterSetListMaker(DefaultParameterRecipes.getDEFAULT_PARAMETER_RECIPES());\n List<ParameterSet> psList = maker.getParameterSetList();\n \n //Get sequenceDNA a singleton chromsomome II currently\n Path p1 = Paths.get(ParameterSet.FA_SEQ_FILE);\n seq = new SequenceDNA(p1, new SeqInterval(ParameterSet.SEQUENCE_START, ParameterSet.SEQUENCE_END));\n \n //Get PUExpt chromosome II - a singleton\n Path p = Paths.get(ParameterSet.BIN_COUNT_FILE);\n pu = new PuExperiment(p, new SeqBin(ParameterSet.PU_BIN_SIZE,0)); //the pu experiment under study - also sets bin size for analysis\n \n //Get genbank annotation file of chromosome II - a singleton\n Path p2 = Paths.get(ParameterSet.CHROMOSOME_II_GENBANK);\n annotation = new SequenceDNAAnnotationGenbank(p2);\n \n //get transcript list - a singleton\n transcriptList = annotation.getTranscriptsByType(type-> type == Transcript.TRANSCRIPT_TYPE.MRNA || type == Transcript.TRANSCRIPT_TYPE.SNRNA ||\n type == Transcript.TRANSCRIPT_TYPE.RRNA || type == Transcript.TRANSCRIPT_TYPE.SNORNA || type == Transcript.TRANSCRIPT_TYPE.TRNA);\n \n //get Rif1 list\n Path rif1p = Paths.get(ParameterSet.RIF1_INTERVAL_FILE);\n rif1List = new Rif1Sites(rif1p).getRif1IntervalList();\n \n \n //RUN PARAMETER SETS FOR DYNAMIC SIMULATION\n \n //Iterate over all parameter sets\n for (ParameterSet paramSet : psList) { \n\n //Create probability distribution based on transcript exclusion and AT content\n probDistribution = new ProbabilityDistribution2(seq.atFunction(paramSet.getInitiatorSiteLength()), paramSet, \n annotation.getTranscriptBlocks(transcriptList));\n\n //Replicate molecules\n population = new ReplicatingMoleculePopulation(probDistribution, paramSet, rif1List);\n\n //Create new model comparator to compare pu data with predicted right fork frequency distribution from population of replicating molecules\n modelComparator = new AtModelComparator(pu, ParameterSet.SEQUENCE_START / ParameterSet.PU_BIN_SIZE, population.getPopulationAveRtForkFreqInBins());\n \n //print list of interTranscripts with probabilities\n /*System.out.println(\"index\\tstart\\tend\\tAT Content\\tRif1 index\\tprob\"); \n InterTranscriptSites sites = new InterTranscriptSites(seq, annotation.getTranscriptBlocks(transcriptList), rif1List, probDistribution);\n sites.getInterTranscriptList().forEach(System.out::println);\n System.out.println(\"\");*/\n\n switch (task) {\n case PRINT_PARAMETER_SET:\n System.out.println(paramSet); \n break;\n case PRINT_SEQUENCE:\n System.out.println(seq.intervalToString(new SeqInterval(0, seq.getLength() - 1)));\n break;\n case PRINT_CDF:\n System.out.println(paramSet); \n System.out.println(\"MIDPOINT\\tCDF\");\n probDistribution.printCDf(ParameterSet.PU_BIN_SIZE);\n break;\n case PRINT_MEAN_SQUARED_DEVIATION_RIGHT_FORK_FREQUENCY:\n System.out.println(\"MSD\\tNumPreRCs\\tExpConst\\tAttenuator\\tInitLength\\tMaxRate\\tStdDevPredicted\\tStdDevObserved\");\n System.out.println(modelComparator.getMeanSquaredDifference() + \"\\t\" + paramSet.getNumberInitiators() + \"\\t\" + paramSet.getExponentialPowerFactor() + \"\\t\" + \n paramSet.getAttenuationFactor() + \"\\t\" + paramSet.getInitiatorSiteLength() \n + \"\\t\" + paramSet.getMaxFiringProbabilityPerMin() + \"\\t\" + modelComparator.getPredictedStdDeviation() + \"\\t\" + modelComparator.getObservedStdDeviation());\n break;\n case PRINT_PREDICTED_AND_OBSERVED_RIGHT_FORK_FREQUENCIES:\n printPredictedAndObservedRtForkFrequencies(paramSet);\n break;\n case PRINT_INITIATION_FREQUENCIES:\n printInitiationFrequencies(paramSet);\n break;\n case PRINT_TERMINATION_FREQUENCIES:\n printTerminationFrequencies(paramSet);\n break;\n case PRINT_MEDIAN_REPLICATION_TIMES_FOR_BINS_IN_GENOME:\n System.out.println(paramSet);\n System.out.println(\"Position\\tMedianTime\");\n List<Double> replicationTimes = population.getPopulationMedianTimeOfReplicationInBins(ParameterSet.PU_BIN_SIZE, ParameterSet.NUMBER_BINS);\n for (int i = 0; i < replicationTimes.size(); i++) {\n System.out.println(i * ParameterSet.PU_BIN_SIZE + ParameterSet.PU_BIN_SIZE / 2 + \"\\t\" + replicationTimes.get(i));\n }\n break;\n case PRINT_SPHASE_DURATION_FOR_MOLECULES_IN_POPULATION:\n System.out.println(paramSet);\n population.getElapsedTimeList().stream().forEach(f-> System.out.println(f));\n break;\n case PRINT_FRACTION_REPLICATED_OF_BINS_AT_GIVEN_TIME:\n System.out.println(paramSet);\n System.out.println(\"ELAPSED TIME: \" + timeOfReplication + \" min\");\n System.out.println(\"Position\\tFxReplicated\");\n List<Double> fxReplicated = population.getPopulationAveFxReplicatedInBins(timeOfReplication, ParameterSet.PU_BIN_SIZE, ParameterSet.NUMBER_BINS, paramSet.getMinPerCycle());\n for (int i = 0; i < fxReplicated.size(); i++) {\n System.out.println(i * ParameterSet.PU_BIN_SIZE + ParameterSet.PU_BIN_SIZE / 2 + \"\\t\" + fxReplicated.get(i));\n }\n break;\n case PRINT_REPLICATION_TIME_OF_BIN_FOR_MOLECULES_IN_POPULATION:\n System.out.println(paramSet);\n System.out.println(\"BIN NUMBER: \" + binNumber);\n for (int i = 0; i < paramSet.getNumberCells(); i++) {\n System.out.println(population.getPopulationTimesOfReplicationOfBin(binNumber)[i]);\n }\n break;\n case PRINT_RF_DELTA_LIST:\n PrintDeltaAtContentAndNumberTranscribedPositionsOfBins();\n }\n } \n }", "public void testParse() throws Exception\r\n {\r\n System.out.println(\"parse\");\r\n \r\n String context1 = \"package test.testpack;\\n class TestClass\\n{\\n\\tdouble d;\\n}\";\r\n String context2 = \"package test.test.testpack;\\n class TestClass\\n{\\n\\tdouble d;\\n}\";\r\n String context3 = \"\\npack age test.test.testpack ;\\n class TestClass \\n{\\n\\tdouble d;\\n}\";\r\n String context4 = \"package test.test.testpack\\n class TestClass\\n{\\n\\tdouble d;\\n}\";\r\n \r\n String context5 = \"package test.test.testpack;\\n class TestClass {\\n\\tdouble d;\\n}\";\r\n String context6 = \"package test.test.testpack;\\n class Test Class{\\n\\tdouble d;\\n}\";\r\n String context7 = \"package test.test.testpack;\\n class TestClass\\n{\\n\" +\r\n \"\\t//Det här är en double\\n\" +\r\n \"\\tdouble d;\\n\" +\r\n \"\\tdouble[] ds;\\n\" +\r\n \"\\tidltype test.test2.Test2Class idlTestObject;\" +\r\n \"\\n}\";\r\n \r\n \r\n FileParser instance = new FileParser();\r\n \r\n IDLClass expResult = null;\r\n \r\n IDLClass result = instance.parse(context1);\r\n assertEquals(result.getPackageName(), \"test.testpack\");\r\n assertEquals(result.getClassName(), \"TestClass\");\r\n \r\n result = instance.parse(context2);\r\n assertEquals(result.getPackageName(), \"test.test.testpack\");\r\n assertEquals(result.getClassName(), \"TestClass\");\r\n \r\n try\r\n {\r\n \r\n result = instance.parse(context3);\r\n fail(\"Should through\");\r\n } \r\n catch (ParseException ex)\r\n {\r\n assertEquals(\"At line 2: Invalid package declaration.\", ex.getMessage());\r\n }\r\n \r\n try\r\n {\r\n \r\n result = instance.parse(context4);\r\n fail(\"Should through\");\r\n } \r\n catch (ParseException ex)\r\n {\r\n assertEquals(\"At line 1: Missing ; .\", ex.getMessage());\r\n }\r\n \r\n result = instance.parse(context5);\r\n assertEquals(result.getPackageName(), \"test.test.testpack\");\r\n assertEquals(result.getClassName(), \"TestClass\");\r\n \r\n try\r\n {\r\n \r\n result = instance.parse(context6);\r\n fail(\"Should through\");\r\n } \r\n catch (ParseException ex)\r\n {\r\n assertEquals(\"At line 2: Invalid class declaration.\", ex.getMessage());\r\n }\r\n \r\n result = instance.parse(context7);\r\n assertEquals(result.getPackageName(), \"test.test.testpack\");\r\n assertEquals(result.getClassName(), \"TestClass\");\r\n assertEquals(result.getFields().get(0).getComment(), \"//Det här är en double\");\r\n \r\n \r\n // TODO review the generated test code and remove the default call to fail.\r\n //fail(\"The test case is a prototype.\");\r\n }", "public static void main( String[] args ) {\n List<Package> packages = new ArrayList<>();\n File file = new File(\"orasele de livrare.txt\");\n List<String> dataFromFile = null;\n try {\n dataFromFile = Files.readAllLines(Paths.get(file.getPath()));\n } catch (IOException e) {\n e.printStackTrace();\n }\n for (String s : dataFromFile) {\n String[] dataSplitted = s.split(\",\");\n Package pack = new Package(dataSplitted[0], Double.parseDouble(dataSplitted[1]), Double.parseDouble(dataSplitted[2]), dataSplitted[3]);\n packages.add(pack);\n double packagesTotalValue = 0.0;\n for (Package p : packages) {\n System.out.println(\"This package is considered to be delivered in \" + p.getTargetLocation() + \" on \" + p.getLocalDate());\n final double pricePerKm = 1.0;\n double packageValue = p.getTargetDistance() * pricePerKm;\n System.out.println(\"The price for delivering this package is \" + packageValue);\n packagesTotalValue = packageValue + packagesTotalValue;\n System.out.println(\"Delivering for \" + p.getTargetLocation() + \" and date \" + p.getLocalDate() + \" in \" + p.getTargetDistance() + \" seconds\");\n }\n System.out.println(\"The total value of the packages delivered is \" + packagesTotalValue);\n }\n }", "public static void main(String[] args) {\n In in = new In(\"/Users/kliner/Downloads/wordnet/digraph3.txt\");\n Digraph digraph = new Digraph(in);\n SAP sap = new SAP(digraph);\n System.out.println(sap.ancestor(0, 4));\n System.out.println(sap.ancestor(10, 13));\n System.out.println(sap.length(10, 13));\n// System.out.println(sap.ancestor(7, 3));\n// System.out.println(sap.length(7, 3));\n// System.out.println(sap.ancestor(3, 7));\n// System.out.println(sap.length(3, 7));\n// System.out.println(sap.ancestor(7, 1));\n// System.out.println(sap.length(7, 1));\n// System.out.println(sap.ancestor(7, 0));\n// System.out.println(sap.length(7, 0));\n// System.out.println(sap.ancestor(10, 11));\n// System.out.println(sap.length(10, 11));\n// System.out.println(sap.ancestor(10, 12));\n// System.out.println(sap.length(10, 12));\n// System.out.println(sap.ancestor(5, 12));\n// System.out.println(sap.length(5, 12));\n// System.out.println(sap.ancestor(0, 12));\n// System.out.println(sap.length(0, 12));\n }", "public static void main(String[] args)throws Throwable {\n FileLib flib = new FileLib();\n flib.readPropertyData(\"./data/config.properties\", \"browser\");\n // System.out.println(value); \n\t}", "public static void main(String[] args) {\n\t\tLexicalizedParser lp = LexicalizedParser\n\t\t\t\t.loadModel(\"edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz\");\n\t\tString fileName = \"../../TrainingSet/Test/test_rather.txt\";\n\t\tif (fileName != \"\") {\n\t\t\tdemoDP(lp, fileName);\n\t\t} else {\n\t\t\tdemoAPI(lp);\n\t\t}\n\t}", "public AnalysePSRFile(File file) throws IOException {\n ReadFileToString str = new ReadFileToString();\n str.read(file);\n StringTokenizer tok = new StringTokenizer(str.outputString,\"\\n\");\n boolean notfound = true;\n int count = 4;\n while(notfound && tok.hasMoreTokens()) {\n String line = tok.nextToken();\n if(line.indexOf(startKeyword) >= 0) \n count--;\n if(count == 0)\n notfound = false;\n }\n if(!notfound) {\n Temperature = getTemperature(tok);\n getMoleFractionHeader(tok);\n getMoleFractions(tok);\n int n = namesV.size();\n namesS = new String[n];\n molefractionsD = new Double[n];\n for(int i=0;i<n;i++) {\n namesS[i] = (String) namesV.elementAt(i);\n molefractionsD[i] = (Double) molefractionsV.elementAt(i);\n }\n } else {\n throw new IOException(\"PSR file incomplete: Begin not found in \\n \" + file.toString() );\n }\n \n }", "public static void main(String[] args) {\n\t\tif (args.length != 1) {\n\t\t\tSystem.err.println(\n\t\t\t\t\"Please provide only one argument (document filepath).\"\n\t\t\t);\n\t\t\tSystem.exit(1);\n\t\t}\n\t\t\n\t\tString docBody = null;\n\t\ttry {\n\t\t\tdocBody = new String(\n\t\t\t\tFiles.readAllBytes(Paths.get(args[0]))\n\t\t\t);\n\t\t} catch (IOException e1) {\n\t\t\tSystem.err.println(\"Invalid document filepath.\");\n\t\t\tSystem.exit(1);\n\t\t}\n\t\t\n\t\tSmartScriptParser parser = null;\n\t\t\n\t\ttry {\n\t\t\tparser = new SmartScriptParser(docBody);\n\t\t} catch (SmartScriptParserException e) {\n\t\t\tSystem.out.println(\"Unable to parse document!\");\n\t\t\tSystem.exit(-1);\n\t\t} catch (Exception e) {\n\t\t\tSystem.out.println(\n\t\t\t\t\"If this line ever executes, you have failed this class!\"\n\t\t\t);\n\t\t\tSystem.exit(-1);\n\t\t}\n\t\t\n\t\tDocumentNode document = parser.getDocumentNode();\n\t\tString originalDocumentBody = createOriginalDocumentBody(document);\n\t\t\n\t\t// should write something like original content of docBody\n\t\tSystem.out.println(originalDocumentBody);\n\t}", "public static void main(String[] args) throws IOException,\n\t\tSAXException, ParserConfigurationException {\n\t\tString start = \"1 Lomb Memorail Drive, Rochester, NY\";\n\t\tString[] end = { \"Hartford\", \"CT\", \"US\" };\n\t\tSystem.out\n\t\t\t.println(\"Traveling from Rochester, NY to Hartford, CT \\n\");\n\t\tSystem.out.println(getHotel(end[0], end[1], end[2]));\n\t\tSystem.out.println(getDirections(start,\n\t\t\tgetHotelAdress(end[0], end[1], end[2])));\n\t\tSystem.out\n\t\t\t.println(getCityTemp(getHotelZip(end[0], end[1], end[2])));\n\t}", "public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException {\r\n\t\tSAXParserFactory spf = SAXParserFactory.newInstance();\r\n\t\t// Create the parser from the factory instance\r\n\t\t// two exceptions to the main method\r\n\t\tSAXParser sp = spf.newSAXParser();\r\n\r\n\t\t/*\r\n\t\t * Parse the XML document. Event based parsing it sends it to a handler . It need a\r\n\t\t * handler to Accepts 2 parameters. The file and the handler.\r\n\t\t */\r\n\t\t\r\n\t\t//set the file path and handler. The handler can implement certain interfaces. Throw exceptions to the mail\r\n\t\tsp.parse(\"C:/GitHub/MyJava/MyJavaProject/src/com/stoneriver/xml/validation/intro.xml\", new MyHandler());\r\n\r\n\t}" ]
[ "0.6059385", "0.6010413", "0.5763583", "0.57227814", "0.5698822", "0.5657063", "0.5637494", "0.5626197", "0.5606277", "0.5603729", "0.5591522", "0.55846614", "0.55393094", "0.5525297", "0.5477093", "0.5462694", "0.5447847", "0.54317755", "0.53993297", "0.53981334", "0.53957653", "0.539126", "0.53853774", "0.5380581", "0.53710926", "0.5367198", "0.53417826", "0.5340951", "0.5332527", "0.53244436", "0.531804", "0.5315368", "0.5314174", "0.5294392", "0.52745706", "0.5270308", "0.5264959", "0.5261765", "0.52587533", "0.5244001", "0.5242274", "0.5240424", "0.52396655", "0.52378696", "0.5226862", "0.5226604", "0.52225107", "0.521078", "0.5206488", "0.52059", "0.5205797", "0.52010435", "0.5187005", "0.51854396", "0.5177784", "0.5175232", "0.5167491", "0.51631594", "0.51580596", "0.5152258", "0.5150553", "0.514613", "0.5143697", "0.5137449", "0.5132642", "0.5123311", "0.51231325", "0.509796", "0.50944626", "0.50881106", "0.508139", "0.5077073", "0.507497", "0.5063268", "0.5058344", "0.5054615", "0.5054064", "0.5053846", "0.5042232", "0.50385344", "0.5038002", "0.5028108", "0.50264084", "0.5023944", "0.5023478", "0.50220335", "0.50183797", "0.5014605", "0.50115913", "0.5005162", "0.5004776", "0.5004745", "0.4998424", "0.49906725", "0.49900514", "0.4988871", "0.4986028", "0.4983704", "0.49788052", "0.49698794" ]
0.7504704
0
Get the value corresponding to the tag name in the pgn file.
public static String tagValue(String name, String pgn) { name = "[" + name; int startIndex = pgn.indexOf(name); if (startIndex == -1) { return "NOT GIVEN"; } startIndex += name.length() + 2; int endIndex = pgn.indexOf("]", startIndex) - 1; return pgn.substring(startIndex, endIndex); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public String readValue(final String name) {\r\n\r\n\t\tfinal StringTokenizer tok = new StringTokenizer(name, \".\");\r\n\t\twhile (tok.hasMoreTokens()) {\r\n\t\t\tfinal String subName = tok.nextToken();\r\n\t\t\tif (!readNextTag(subName)) {\r\n\t\t\t\treturn null;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn readNextText(this.in.getTag().getName());\r\n\t}", "java.lang.String getTagValue();", "public String getValue(String name) {\n/* 192 */ Attr attr = (Attr)this.m_attrs.getNamedItem(name);\n/* 193 */ return (null != attr) ? attr.getValue() : null;\n/* */ }", "public String getFromTag();", "public String getTagVal() {\n return tagVal;\n }", "public static String getTag(String name) {\n\t\treturn tags.get(name);\n\t}", "java.lang.String getTag();", "java.lang.String getTag();", "private String getValue(String def, Element doc, String tag) {\r\n String value = def;\r\n NodeList nl;\r\n nl = doc.getElementsByTagName(tag);\r\n if (nl.getLength() > 0 && nl.item(0).hasChildNodes()) {\r\n value = nl.item(0).getFirstChild().getNodeValue();\r\n }\r\n return value;\r\n }", "public Object getTag(String name)\r\n\t{\r\n\t\treturn tagMap.get(name);\r\n\t}", "public String getValue() throws IOException\r\n {\r\n return getDictionary().getNameAsString( \"V\" );\r\n }", "private String readAttributeValue(XmlPullParser xpp, String name, String def)\n {\n int count = xpp.getAttributeCount();\n for (int n = 0; n < count; n++)\n {\n String attrName = xpp.getAttributeName(n);\n if (attrName != null && attrName.equalsIgnoreCase(name))\n return xpp.getAttributeValue(n);\n }\n return def;\n }", "private String getStringValue(Element element, String tagname) {\n return assistLogic.getStringValue(element, tagname);\n }", "public String parseNamedItemValue(String name, Node node) {\n\t\tString value = null;\n\t\tNamedNodeMap namedNodeMap = node.getAttributes();\n\t\tNode namedItem = namedNodeMap.getNamedItem(name);\n\n\t\tif (namedItem != null && namedItem.getNodeType() == 2) {\n\t\t\tvalue = namedItem.getNodeValue();\n\t\t}\n\t\treturn value;\n\t}", "String getTag();", "public String getValue(String xmlName)\n {\n int index = getIndex(xmlName);\n \n if (index < 0)\n {\n return null;\n }\n return getValue(index);\n }", "public Object getTagValue(String tagName){\n\t\t\n\t\treturn getPicture().getMainDisplay().\n\t\t\tgetAnimationsHandler().getData(tagName);\n\t}", "private String getTextValue(String def, Element doc, String tag) {\n String value = def;\n NodeList nl;\n nl = doc.getElementsByTagName(tag);\n if (nl.getLength() > 0 && nl.item(0).hasChildNodes()) {\n value = nl.item(0).getFirstChild().getNodeValue();\n }\n return value;\n }", "private String getValue(Element element, String tagName)\n {\n String value = \"\";\n\n NodeList nodeList = element.getElementsByTagName(tagName);\n if ((nodeList != null) && (nodeList.getLength() > 0))\n {\n NodeList subNodeList = nodeList.item(0).getChildNodes();\n if (subNodeList != null)\n {\n Node node = (Node)subNodeList.item(0);\n if (node != null)\n {\n value = node.getNodeValue();\n }\n }\n }\n\n return value;\n }", "private String getAttrValue(Object name) {\n\t return (String)this.mAtts.get(name);//.toString();\n\t}", "public java.lang.String getTagValue() {\n java.lang.Object ref = tagValue_;\n if (ref instanceof java.lang.String) {\n return (java.lang.String) ref;\n } else {\n com.google.protobuf.ByteString bs = \n (com.google.protobuf.ByteString) ref;\n java.lang.String s = bs.toStringUtf8();\n if (bs.isValidUtf8()) {\n tagValue_ = s;\n }\n return s;\n }\n }", "public String getTag() {\n return tagNum;\n }", "public String getTagValue() {\n return tagValue;\n }", "private static String extractChildValue(Xpp3Dom node, String name) {\n final Xpp3Dom child = node.getChild(name);\n return child == null ? \"\" : child.getValue();\n }", "public java.lang.String getTagValue() {\n java.lang.Object ref = tagValue_;\n if (!(ref instanceof java.lang.String)) {\n java.lang.String s = ((com.google.protobuf.ByteString) ref)\n .toStringUtf8();\n tagValue_ = s;\n return s;\n } else {\n return (java.lang.String) ref;\n }\n }", "public String getDPTag(String key)\r\n {\n return tagHash.get(key).toString();\r\n }", "public String getTagname() {\n return tagname;\n }", "public String getTagByName(String tagName) {\r\n\t\treturn dcmObj.getString(Tag.toTag(tagName));\r\n\t}", "public String getModelXMLTagValue(String tagname) {\n\t\treturn getModelXMLTagValue(tagname, null);\n\t}", "protected synchronized String getStringValue(String tag) {\n String value = \"\";\n if (actualProperties != null) {\n value = actualProperties.getProperty(tag, \"\");\n }\n return value;\n }", "public String getCustomTag(String pTagName) {\n\t\tassert pTagName != null;\n\t\tpTagName = pTagName.toUpperCase();\n\t\tif (aCustomTags.containsKey(pTagName)) {\n\t\t\treturn aCustomTags.get(pTagName);\n\t\t} else {\n\t\t\tthrow new NoSuchFieldError();\n\t\t}\n\t}", "String getMetadataValue( String name )\n throws MetadataNameNotFoundException;", "private String getAttribute(Node nNode,String name) {\n \tNamedNodeMap attributes = nNode.getAttributes();\n \t\n \t// get the number of nodes in this map\n \tint numAttrs = attributes.getLength();\n \t\n \tfor (int i = 0; i < numAttrs; i++) {\n \t\t\n \t\tAttr attr = (Attr) attributes.item(i);\n \t\tString attrName = attr.getNodeName();\n \t\tString attrValue = attr.getNodeValue();\n \n \t\tif(attrName == name) {\n \t\t\treturn attrValue;\n \t\t}\n \t}\n \t\n \treturn null;\n }", "public String getAttribute(String name) {\n if (_lastTag == null)\n return null;\n return _lastTag.getAttribute(name);\n }", "public static String getProperty (Document doc, String tag) {\n Element eLement = (Element) doc.getElementsByTagName(\"Properties\").item(0);\n return eLement.getAttribute(tag);\n }", "public String getTextValue (Node node);", "Node getVariable();", "public String tag(int k) {\n return mTags.get(k);\n }", "public int getTagNum() {\n return Integer.parseInt(getTag());\n }", "String getValueName();", "public static __Tag getTagSub(String tag) {\n\t return map.get(tag);\n\t}", "public static __Tag getTagSub(String tag) {\n\t return map.get(tag);\n\t}", "private String getTextValue(Element ele, String tagName) {\r\n\t\tString textVal = null;\r\n\t\tNodeList nl = ele.getElementsByTagName(tagName);\r\n\t\tif(nl != null && nl.getLength() > 0) {\r\n\t\t\tElement sl = (Element)nl.item(0);\r\n\t\t\ttextVal = sl.getFirstChild().getNodeValue();\r\n\t\t}\r\n\r\n\t\treturn textVal;\r\n\t}", "public String getTag();", "public Object getValue() {\n return tags.toString();\n }", "String getValueOfNode(String path)\n throws ProcessingException;", "public String tag()\r\n {\r\n return this.tag;\r\n }", "public static String getString(Tag tag){\n makeInstance();\n return settingsFile.getString(tag);\n }", "public IRvtPoiAoiMetadataValue getField(RvtAoiMetadataKey tag) {\n return map.get(tag);\n }", "public String getValue(String name){\n if(!kchain.containsKey(name))return akargs.get(name);\n else return kchain.get(name).toString();\n }", "public String getValue() throws SdpParseException {\n\t\tNameValue nameValue = getAttribute();\n\t\tif (nameValue == null)\n\t\t\treturn null;\n\t\telse {\n\t\t\tObject value = nameValue.getValue();\n\t\t\tif (value == null)\n\t\t\t\treturn null;\n\t\t\telse if (value instanceof String)\n\t\t\t\treturn (String) value;\n\t\t\telse\n\t\t\t\treturn value.toString();\n\t\t}\n\t}", "public String get(String key) {\n\t\t//get this file's text\n\t\tString text = FileIO.read(this.getPath());\n\t\tString value = null;\n\t\ttry {\n\t\t\t//try matching the pattern: key : value\\n \n\t\t\tPattern pattern = Pattern.compile(key+\" : (.*?)\\n\");\n\t\t\t\n\t\t\tMatcher matcher = pattern.matcher(text);\n\t\t\tmatcher.find();\n\t\t\t\n\t\t\t//get the value\n\t\t\tvalue = matcher.group(1);\n\t\t\t\n\t\t}catch(Exception e) {/*do nothing*/}\n\t\t\n\t\treturn value;\n\t}", "public java.lang.String getTag() {\n java.lang.Object ref = tag_;\n if (ref instanceof java.lang.String) {\n return (java.lang.String) ref;\n } else {\n com.google.protobuf.ByteString bs = \n (com.google.protobuf.ByteString) ref;\n java.lang.String s = bs.toStringUtf8();\n tag_ = s;\n return s;\n }\n }", "public String getValue(String uri, String localName) {\n/* 208 */ Node a = this.m_attrs.getNamedItemNS(uri, localName);\n/* 209 */ return (a == null) ? null : a.getNodeValue();\n/* */ }", "public java.lang.String getTag() {\n java.lang.Object ref = tag_;\n if (!(ref instanceof java.lang.String)) {\n com.google.protobuf.ByteString bs =\n (com.google.protobuf.ByteString) ref;\n java.lang.String s = bs.toStringUtf8();\n tag_ = s;\n return s;\n } else {\n return (java.lang.String) ref;\n }\n }", "org.apache.xmlbeans.XmlString xgetTag();", "public String getModelXMLTagValue(String tagname, String default_value) {\n\t\tElement res = getModelXMLElement(tagname);\n\t\treturn (res != null) ? res.getTextContent() : default_value;\n\t}", "@Override\n\tpublic String getValue() {\n\t\treturn name;\n\t}", "public String getNodeValue(Node node) throws Exception;", "public String getAttribute(String name)\n\tthrows SdpParseException {\n\tif (name != null) {\n\t for (int i = 0; i < this.attributeFields.size(); i++) {\n\t\tAttributeField af = (AttributeField)\n\t\t this.attributeFields.elementAt(i);\n\t\tif (name.equals(af.getAttribute().getName())) \n\t\t return (String) af.getAttribute().getValue();\n\t }\n\t return null; \n\t} else throw new NullPointerException(\"null arg!\");\n }", "public Object getValue(String name)\n\t\t{\n\t\t\tString[] names = name.split(ResourcesMetadata.DOT);\n\t\t\tObject rv = m_structuredArtifact;\n\t\t\tif(rv != null && (rv instanceof Map) && ((Map) rv).isEmpty())\n\t\t\t{\n\t\t\t\trv = null;\n\t\t\t}\n\t\t\tfor(int i = 1; rv != null && i < names.length; i++)\n\t\t\t{\n\t\t\t\tif(rv instanceof Map)\n\t\t\t\t{\n\t\t\t\t\trv = ((Map) rv).get(names[i]);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\trv = null;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rv;\n\n\t\t}", "public String getFieldValue(LVValue name) throws LRException\n\t{\n\t\tDataHRecordData myData=(DataHRecordData)getData();\n\t\ttry\n\t\t{\n\t\t\tclearStatus();\n\t\t\tLDBRecord record=myData.record;\n\t\t\tif (record!=null) return record.getStringValue(name.getStringValue());\n\t\t}\n\t\tcatch (LDBException e) { setStatus(e); }\n\t\treturn \"\";\n\t}", "public String getParameterValue(String name) {\n\t\treturn _parameters.getParameterValue(name);\n\t}", "public String getNodeValue ();", "public String getTag()\n\t{\n\t\treturn tag;\n\t}", "public String getTag()\n\t{\n\t\treturn tag;\n\t}", "public String getTag()\n {\n return this.tag;\n }", "String getValue();", "String getValue();", "String getValue();", "String getValue();", "String getValue();", "String getValue();", "String getValue();", "String getValue();", "String getValue();", "String getValue();", "abstract Object getXMLProperty(XMLName name);", "String getVal();", "int getTagNo();", "public abstract String getTag();", "public TagInfo getTag(String shortname) {\n/* 190 */ TagInfo[] tags = getTags();\n/* */ \n/* 192 */ if (tags == null || tags.length == 0) {\n/* 193 */ return null;\n/* */ }\n/* */ \n/* 196 */ for (int i = 0; i < tags.length; i++) {\n/* 197 */ if (tags[i].getTagName().equals(shortname)) {\n/* 198 */ return tags[i];\n/* */ }\n/* */ } \n/* 201 */ return null;\n/* */ }", "public String getAttribute(String name);", "public Object getParameter(String name) {\n\t\tIterator itr = this.parameters.getInParameters().iterator();\n\t\twhile(itr.hasNext()){\n\t\t\tParameterExtendedImpl param = ((ParameterExtendedImpl)itr.next());\n\t\t\t\n\t\t\tif(param.getName() != null && param.getName().equalsIgnoreCase(name)){\t\t\t\t\n\t\t\t\treturn param.value;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}", "public String getTag() {\n return tag;\n }", "public String getTag() {\n return tag;\n }", "public Variable getVariable(String name);", "public GTag getTag() {\r\n\t\treturn tag;\r\n\t}", "public String getVariable(String _name) {\r\n\t\treturn getVariable(_name, \",\");\r\n\t}", "public int getMyTag()\n\t{\n\t\treturn myTag;\n\t}", "java.lang.String getVarValue();", "String getPropertyValue(String filename, String lang, String key);", "protected ProbeValue getAttribute(String name) {\n if (values != null) {\n return values.get(name);\n } else {\n return null;\n }\n }", "public Value lookup (String name){\n Closure exist = find_var(name);\n return exist.getValues().get(name);\n }", "public Object getAdditionalTagValue(String tagId, Concept concept) {\n\n Collection additionalTags = this.assignedTag.getAdditionalTags();\n\n for (Iterator i = additionalTags.iterator(); i.hasNext();) {\n\n AssignedTag additionalTag = (AssignedTag) i.next();\n Tag tag = additionalTag.getTag();\n Concept[] concepts = (additionalTag.getTarget()).getConcepts();\n\n if (tag.getId() == tagId && Arrays.binarySearch(concepts, concept) >= 0) {\n\n return additionalTag.getValue();\n }\n }\n\n return null;\n }", "public String getTag() {\r\n return tag;\r\n }", "public Object getValue(String name) {\n Object value = localScope.get(name);\n if ( value!=null ) {\n return value;\n }\n // if not found\n BFlatGUI.debugPrint(0, \"undefined variable \"+name);\n return null;\n }", "public String getTag() {\n return this.tag;\n }", "public String getParameter( String name )\n {\n return getParameter(VAL, name, null, false);\n }", "public String getTag(int tagIndex) {\n int s = getTagStart(tagIndex);\n if (s >= 0 && s < tags.length()) {\n int e = getTagEnd(tagIndex);\n return substring(s, e);\n } else {\n return \"\";\n }\n }" ]
[ "0.7097422", "0.67392164", "0.65843797", "0.63608074", "0.6233446", "0.62065905", "0.62063944", "0.62063944", "0.617987", "0.6065698", "0.6019608", "0.5997284", "0.5951329", "0.5932417", "0.5914294", "0.5913061", "0.590333", "0.590279", "0.58713835", "0.5854929", "0.5848965", "0.5845688", "0.58147615", "0.5760136", "0.57297593", "0.5691426", "0.56895995", "0.5682595", "0.5674288", "0.5660037", "0.5651771", "0.56244624", "0.5622765", "0.56187904", "0.5605076", "0.5594732", "0.5575305", "0.55534893", "0.5552929", "0.55413055", "0.55346304", "0.55346304", "0.5531745", "0.5514964", "0.55092275", "0.55076635", "0.5503761", "0.548718", "0.54867864", "0.54752094", "0.54670614", "0.54345703", "0.54233867", "0.5416948", "0.5407684", "0.5407075", "0.5401773", "0.5397137", "0.539265", "0.5390417", "0.5385423", "0.53799933", "0.537841", "0.53733397", "0.5366871", "0.5366871", "0.5360854", "0.5359781", "0.5359781", "0.5359781", "0.5359781", "0.5359781", "0.5359781", "0.5359781", "0.5359781", "0.5359781", "0.5359781", "0.53582066", "0.5355849", "0.5355482", "0.5349814", "0.5348019", "0.5345266", "0.53429925", "0.53357744", "0.53357744", "0.53310144", "0.53307307", "0.53285736", "0.53221816", "0.5317", "0.5316004", "0.53142506", "0.53095937", "0.5309557", "0.53024966", "0.5302182", "0.5278564", "0.52773243", "0.527476" ]
0.68797386
1
Get the FEN of the final position in the pgn file.
public static String finalPosition(String pgn) { setBoardState(createBoardState()); moves(pgn); return pgnToFen(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public String getFetalposition() {\n return fetalposition;\n }", "public int getLast5SSPos() {\n\t\tfinal BEDentry secondLastExon = getBEDentry().getBlockAtRelativePosition(-2);\n\t\treturn getEndOfBEDentry(secondLastExon); \n\t}", "public int getFE(){\n return this._FE;\n }", "public long getNextIFDOffset() {\n return nextIFDOffset;\n }", "public int getEndx(){\n\t\treturn endx;\n\t}", "public int getFin() {\r\n return fin;\r\n }", "public int getEnd() {\n switch(getType()) {\n case Insertion:\n case SNP:\n case InterDup:\n case TandemDup:\n case TransDup:\n return pos;\n default:\n return pos + maxLen() - 1;\n }\n }", "public static String pgnToFen() {\n String fen = \"\";\n\n for (int i = getBoardState().length - 1; i >= 0; i--) {\n String fenLine = \"\";\n\n int spaceStreak = 0;\n\n for (String file: getBoardState()[i]) {\n String piece = Character.toString(file.charAt(0));\n char color = file.charAt(1);\n\n if (color == ' ') {\n spaceStreak++;\n\n continue;\n } else if (spaceStreak > 0) {\n fenLine += spaceStreak;\n\n spaceStreak = 0;\n }\n\n String square = color == 'w' ? piece : piece.toLowerCase();\n\n fenLine += square;\n }\n\n if (spaceStreak > 0) {\n fenLine += spaceStreak;\n }\n\n fen += fenLine + (i != 0 ? \"/\" : \"\");\n }\n\n return fen;\n }", "public int getFe() {\n return fe;\n }", "public int getFinalMark() {\r\n return finalMark;\r\n }", "public int getFinalMark()\n {\n return finalMark;\n }", "public byte getN_OF_FILE() throws CardException {\n\n if (!this.IC_ALREADY_SUBMIT) {\n this.SubmitIC();\n }\n\n //byte[] id = {(byte)0xFF, (byte)0x02};\n this.SelectFF02();\n\n byte n_of_file = this.__ReadRecord((byte)0, (byte)4)[2];\n System.out.println(\"Card contains \" + n_of_file + \" file.\");\n this.N_OF_FILE = n_of_file;\n return n_of_file;\n }", "@VisibleForTesting\n public final long e() {\n long b2 = this.f10064d.n().b();\n long j = b2 - this.f10062b;\n this.f10062b = b2;\n return j;\n }", "public int getDefensa() {\r\n\t\treturn this.unidad.getDefensa() - REDUCCION_DEFENSA;\r\n\t}", "public int getLast3SSPos() {\n\t\treturn getStartOfBEDentry(getBEDentry().getBlockAtRelativePosition(-1)); \n\t}", "public int[] getPositionFinale(int N){\n\t\t\n\t\tfor(int i=N-2; i>=0; i--){\n\t\t\n\t\t\tif(pi[i+1] == pf[i+1]){\n\t\t\t\tpf[i]=pf[i+1];\n\t\t\t\t\n\t\t\t//System.out.println(\" \" + pf[i] + \"init \" +pi[i]);\t\n\t\t\t}else{\n\t\t\t\tpf[i]=6-getPosInitiale(i+1)-pf[i+1];\n\t\t\tSystem.out.println(\" \" + pf[i] + \"init \" +pi[i]);\n\t\t\t}\n\t\t}\n\t\treturn pf;\n\t\t\t\n\t}", "public long getFileIndex(){\n \tString fileName=file.getName();\n// \tSystem.out.println(\"fileName:\"+fileName);\n \tfinal long start = Long.parseLong(fileName.substring(0,\n\t\t\t\tfileName.length() - FILE_SUFFIX.length()));\n// \tSystem.out.println(\"start:\"+start);\n \treturn start;\n }", "public Integer getFpNumber() {\r\n return fpNumber;\r\n }", "public int getF() {\n\t\treturn f;\n\t}", "public int getEndX() {\r\n\t\treturn endX;\r\n\t}", "public int obtenerFE(nodoArbolAVL x){\n if(x== null){\n return -1;\n }else{\n return x.fe;\n }\n }", "public int getNobilityTrackLength(String endPath) {\r\n\t\tint nobilityTrackLenght = 0;\r\n\r\n\t\ttry {// provo a leggere il file xml\r\n\t\t\tnobilityTrackLenght = nobilityXml.nobilityTrackLenght(endPath);\r\n\t\t} catch (XmlException e) {\r\n\t\t\tlogger.error(err + endPath, e);\r\n\t\t\tnobilityTrackLenght = 0;\r\n\t\t}\r\n\r\n\t\treturn nobilityTrackLenght;\r\n\t}", "public int getEndLIne() {\r\n return this.endLine;\r\n }", "private int getIndexOfEnd(String document) {\n int indexOfEnd = -1;\n indexOfEnd = document.indexOf(\"</span> °C\");\n return indexOfEnd;\n }", "public synchronized int getLastPos() {\n PageMeta pm = pmList.get(numPages - 1);\n return pm.startPos + pm.numPairs - 1;\n }", "public int getOffset()\n {\n if (m_bufferOffset_ != -1) {\n if (m_isForwards_) {\n return m_FCDLimit_;\n }\n return m_FCDStart_;\n }\n return m_source_.getIndex();\n }", "public static int getEndXCoordinate(){\n\t\tint x = getThymioEndField_X(); \n\t\t\n\t\tif(x == 0){\n\t\t\n \t}else{\n \t x *= FIELD_HEIGHT;\n \t}\n\n\t\treturn x;\n\t}", "public int getEndNum() {\r\n return this.endNum;\r\n }", "public long getFreeBlockPosn(byte fileId) {\n\t\treturn freeBlocksMgrMap.get(fileId).getFreePosn();\n\t}", "public java.lang.Integer getFurthestPoint() {\n return furthest_point;\n }", "public int outDegree(Position vp) throws InvalidPositionException;", "@Override\n public long position() throws IOException {\n return _backing.getFilePointer() - _head.offset;\n }", "public java.lang.Integer getFurthestPoint() {\n return furthest_point;\n }", "private int rightmostDip() {\n for (int i = n - 2; i >= 0; i--) {\n if (index[i] < index[i + 1]) {\n return i;\n }\n }\n return -1;\n }", "public Float getProfundidadFinal() {\r\n\t\treturn profundidadFinal;\r\n\t}", "public long getFileOffset();", "public long getFileIndex()\r\n {\r\n return fileIndex;\r\n }", "public String mo133917g() {\n List<String> list = this.f114446a;\n return list.get(list.size() - 1);\n }", "private int m216e(float f) {\n int i = (int) (f + 0.5f);\n return i % 2 == 1 ? i - 1 : i;\n }", "public int feldNummer(Farbe farbe);", "public long getComplementary_end() {\n return complementary_end;\n }", "int getEndPosition();", "public String getFin() {\n return fin;\n }", "public Integer getFeenum() {\n return feenum;\n }", "public int getEndPosition() {\n return endPosition_;\n }", "private int getEndOfBEDentry(final BEDentry entry ) {\n\t\tif( entry.getStrand().equals(\"+\") ) { \n\t\t\treturn entry.getChromEnd(); \n\t\t} else {\n\t\t\treturn entry.getChromStart(); \n\t\t}\n\t}", "public int stapelPosition(Farbe farbe);", "public int getPiEnd()\r\n\t{\r\n\t\treturn piEnd;\r\n\t}", "public int getEndPosition() {\n return getStartPosition() + getLength();\n }", "String getDefiningEnd();", "public int getFaithPointsOut() {\n return this.pointsFaithOut;\n }", "public int getEndPosition() {\n return endPosition_;\n }", "long getFileOffset();", "public int rtf() {\n/* 219 */ return this.m_dtmRoot;\n/* */ }", "public Location getOffset() {\n\t\treturn gfPos;\n\t}", "@Override\n public int getEnd() {\n return feature.getEnd();\n }", "public float getDescent() {\n Object value = library.getObject(entries, DESCENT);\n if (value instanceof Number) {\n return ((Number) value).floatValue();\n }\n return 0.0f;\n }", "public int getDegree() {\n return coefs.length - 1;\n }", "public int getFinalFacing() {\n MoveStep last = getLastStep();\n if (last != null) {\n return last.getFacing();\n }\n return getEntity().getFacing();\n }", "public double getAbsPosition() {\n double distCM = ToFSerial.get() - startDist;\n //System.out.println(\"Dist in CM \" + distCM);\n\n double distIn = distCM * Constants.k_CMtoIn;\n //System.out.println(\"Dist in In \" + distIn);\n\n return (int) (1000 * distIn); \n\n }", "public int getFileno() {\n return internalFileno;\n }", "org.mojolang.mojo.lang.Position getEndPosition();", "public int getEncPosition() {\n //System.out.println(this.EncX.getRaw() + \"raw\");\n return (int) (1000 * this.EncX.getDistance());\n //return (int)(1000 * this.EncX.getRaw() / 8.6);\n \n }", "java.lang.String getFrequencyOffset();", "@Override\n public long getFilePosition(int tileIndex) {\n int row = tileIndex / nColsOfTiles;\n int col = tileIndex - row * nColsOfTiles;\n if (nCols == 0 || row < row0 || col < col0 || row > row1 || col > col1) {\n return 0;\n }\n\n // for files larger than 16 GB, the offset value may be negative.\n // so a mask is applied to convert it to a positive value.\n return offsets[row - row0][col - col0];\n }", "protected long indexPositionToKeyFp(int pos) {\n return FILE_HEADERS_REGION_LENGTH + (INDEX_ENTRY_LENGTH * pos);\n }", "public java.lang.String getCur_elg_ind() {\n\t\treturn cur_elg_ind;\n\t}", "public Float getxEnd() {\r\n return xEnd;\r\n }", "public int getPointsDeFidelite() {\n return pointsDeFidelite;\n }", "public float getProgress() throws IOException {\r\n\t\tif (start == totalend) {\r\n\t\t\treturn 0.0f;\r\n\t\t} else {\r\n\t\t\treturn Math.min(1.0f, ((getFilePosition() - start) + finishLen) / (float) totalend);\r\n\t\t}\r\n\t}", "@Override\n\t\tpublic long getPos() throws IOException {\n\t\t\treturn 0;\n\t\t}", "public int mo25070f() {\n return this.f14801c;\n }", "public long getIFDOffset() {\n return ifdOffset;\n }", "public int getFinalElevation() {\n if (getLastStep() != null) {\n return getLastStep().getElevation();\n }\n return getEntity().getElevation();\n }", "public static int getFileNum(File f)\r\n\t{\r\n\t\tString fileStr = f.toString().substring(2);\r\n\t\t\r\n\t\tint num = Integer.parseInt(fileStr.substring(13, fileStr.length()-5));\r\n\t\treturn num;\r\n\t}", "public double getFLAngle(){\r\n \treturn frontLeftPot.get() - FLOFFSET;\r\n }", "public int mo35057e() {\n return this.f30701f;\n }", "public int getTerminalExonLength() { \n\t\tfinal BEDentry te = getBEDentry().getBlockAtRelativePosition(-1); \n\t\treturn( te.getChromEnd() - te.getChromStart() ); \n\t}", "public long correctedPosition() {\n\t\tif (audioOut == null)\n\t\t\treturn currentPosition;\n\t\treturn currentPosition - (outputBufferSize - audioOut.available());\n\t}", "public int\ngetFootprint() {\n\treturn footprint;\n}", "public int getEndOffset() {\n return endPosition.getOffset();\n }", "BigInteger getReplacedEP();", "public Vector3f getEndPosition()\n {\n return endPosition;\n }", "public int getAngulo(){\n\t\treturn this.angulo_final;\n\t}", "public Integer getEndMark() {\n return endMark;\n }", "public float getFurthestPoint() {\r\n\t\treturn furthestPoint;\r\n\t}", "public String getEnd() {\n\t\t\t\t\n\t\t\t\t\tString vS = \"NONE\";\n\t\t\t\t\tSystem.out.println(vS + \" l \" + length);\n\t\t\t\t\tif (length != 0) vS = tail.getPrev().getValue();\n\t\t\t\t\tSystem.out.println(vS + \" l2 \" + length);\n\t\t\t\treturn vS;\n\t\t\t\t}", "public java.lang.Long getDEALPNTFEATLNID() {\n return DEAL_PNT_FEAT_LN_ID;\n }", "public int getFile() {\n validify();\n return Client.INSTANCE.pieceGetFile(ptr);\n }", "@Override\n public final Float getForfeit() {\n return _forfeit;\n }", "private int readFdocaOneByte() {\n checkForSplitRowAndComplete(1);\n //return dataBuffer_[position_++] & 0xff;\n return dataBuffer_.readUnsignedByte();\n }", "public java.lang.Long getDEALPNTFEATLNID() {\n return DEAL_PNT_FEAT_LN_ID;\n }", "public int findGeneStart()\n {\n return findGeneStart(0);\n }", "public int getFECHACRREVAL() {\n return fechacrreval;\n }", "public final int getFileId() {\n\t\treturn m_FID;\n\t}", "public long getNPT() throws MPEGDeliveryException\n\t{ return (long)0;\n\t}", "public int getAnyFi() {\n\t\treturn anyfi;\n\t}", "public int getDegree () {\n int size = myCoefficients.size();\n if (size <= 0) {\n return -1;\n }\n else {\n return size - 1;\n }\n }", "public Vector2 getEndLoc( ) { return endLoc; }", "public Integer getFileNo() {\n return fileNo;\n }" ]
[ "0.60988426", "0.55677176", "0.555168", "0.55516386", "0.5537145", "0.5505213", "0.5488636", "0.54829746", "0.5482442", "0.5454225", "0.5451137", "0.54444313", "0.5426783", "0.5406043", "0.54037124", "0.5396275", "0.53632873", "0.53329843", "0.53234315", "0.5289393", "0.5279066", "0.52784824", "0.5264266", "0.525996", "0.5248055", "0.5233471", "0.5220125", "0.51796347", "0.5161927", "0.51613456", "0.5161282", "0.51607835", "0.5156555", "0.515094", "0.5143269", "0.5137232", "0.51329136", "0.512378", "0.5119675", "0.5119136", "0.5110757", "0.51037997", "0.5095713", "0.5094108", "0.50929075", "0.5092557", "0.5088891", "0.50863945", "0.50805396", "0.5077664", "0.50707895", "0.5067392", "0.50581926", "0.5055145", "0.50453347", "0.5038263", "0.5037839", "0.50325173", "0.5031059", "0.5027952", "0.50194705", "0.50123894", "0.5011378", "0.5009716", "0.50078845", "0.50074834", "0.5000077", "0.4995972", "0.49955112", "0.4995458", "0.49932492", "0.49898297", "0.49870294", "0.4983319", "0.49783897", "0.4968148", "0.4960053", "0.49530673", "0.49486566", "0.4948266", "0.4939786", "0.49395108", "0.49319562", "0.49318907", "0.49316484", "0.49313733", "0.49276796", "0.4924514", "0.4920974", "0.4920026", "0.49161708", "0.49134007", "0.49094158", "0.49073195", "0.49023128", "0.4901795", "0.48950976", "0.48925287", "0.48894054", "0.48889703" ]
0.57800317
1
Create the inital board state of the chess board. The pieces are shown in the form Pc (Piece color). R = Rook; B = Bishop; N = Knight; K = King; Q = Queen; P = Pawn
public static String[][] createBoardState() { String[][] initialBoardState = { {"Rw", "Nw", "Bw", "Qw", "Kw", "Bw", "Nw", "Rw"}, {"Pw", "Pw", "Pw", "Pw", "Pw", "Pw", "Pw", "Pw"}, {" ", " ", " ", " ", " ", " ", " ", " "}, {" ", " ", " ", " ", " ", " ", " ", " "}, {" ", " ", " ", " ", " ", " ", " ", " "}, {" ", " ", " ", " ", " ", " ", " ", " "}, {"Pb", "Pb", "Pb", "Pb", "Pb", "Pb", "Pb", "Pb"}, {"Rb", "Nb", "Bb", "Qb", "Kb", "Bb", "Nb", "Rb"} }; return initialBoardState; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public void initializeBoard() {\n\n\t\t/*\n\t\t * How the array coordinates align with the actual chess board\n\t\t * (row,col) \n\t\t * (7,0) ... ... ... \n\t\t * (7,7) ... ... ... \n\t\t * ... ... ... \n\t\t * (2,0) ...\n\t\t * (1,0) ... \n\t\t * (0,0) ... ... ... (0,7)\n\t\t */\n\n\t\tboolean hasMoved = false;\n\t\tboolean white = true;\n\t\tboolean black = false;\n\n\t\t// Set white piece row\n\t\tboard[0][0] = new Piece('r', white, hasMoved, 0, 0, PieceArray.A_rookId);\n\t\tboard[0][1] = new Piece('n', white, hasMoved, 0, 1, PieceArray.B_knightId);\n\t\tboard[0][2] = new Piece('b', white, hasMoved, 0, 2, PieceArray.C_bishopId);\n\t\tboard[0][3] = new Piece('q', white, hasMoved, 0, 3, PieceArray.D_queenId);\n\t\tboard[0][4] = new Piece('k', white, hasMoved, 0, 4, PieceArray.E_kingId);\n\t\tboard[0][5] = new Piece('b', white, hasMoved, 0, 5, PieceArray.F_bishopId);\n\t\tboard[0][6] = new Piece('n', white, hasMoved, 0, 6, PieceArray.G_knightId);\n\t\tboard[0][7] = new Piece('r', white, hasMoved, 0, 7, PieceArray.H_rookId);\n\n\t\t// Set white pawns\n\t\tfor (int i = 0; i < 8; i++) {\n\t\t\tboard[1][i] = new Piece('p', white, hasMoved, 1, i, i + 8);\n\t\t}\n\n\t\t// Set empty rows\n\t\tfor (int row = 2; row < 6; row++)\n\t\t\tfor (int col = 0; col < 8; col++)\n\t\t\t\tboard[row][col] = null;\n\n\t\t// Set black pawns\n\t\tfor (int i = 0; i < 8; i++) {\n\t\t\tboard[6][i] = new Piece('p', black, hasMoved, 6, i, i+8);\n\t\t}\n\n\t\t// Set black piece row\n\t\tboard[7][0] = new Piece('r', black, hasMoved, 7, 0, PieceArray.A_rookId);\n\t\tboard[7][1] = new Piece('n', black, hasMoved, 7, 1, PieceArray.B_knightId);\n\t\tboard[7][2] = new Piece('b', black, hasMoved, 7, 2, PieceArray.C_bishopId);\n\t\tboard[7][3] = new Piece('q', black, hasMoved, 7, 3, PieceArray.D_queenId);\n\t\tboard[7][4] = new Piece('k', black, hasMoved, 7, 4, PieceArray.E_kingId);\n\t\tboard[7][5] = new Piece('b', black, hasMoved, 7, 5, PieceArray.F_bishopId);\n\t\tboard[7][6] = new Piece('n', black, hasMoved, 7, 6, PieceArray.G_knightId);\n\t\tboard[7][7] = new Piece('r', black, hasMoved, 7, 7, PieceArray.H_rookId);\n\t}", "public static void makeBoardChess() {\r\n \r\n white = new AllPiece(\"White\");\r\n black = new AllPiece(\"Black\");\r\n \r\n }", "public static void boardInit() {\n ArrayList<Piece> white_piece_list = new ArrayList<>();\n ArrayList<Piece> black_piece_list = new ArrayList<>();\n ArrayList<Piece> piece_array = PieceFactory.createPieces();\n for(Piece p : piece_array)\n {\n if(p.getColor())\n {\n black_piece_list.add(p);\n }\n else\n {\n white_piece_list.add(p);\n }\n }\n white_player.setpieceList(white_piece_list);\n white_player.setKingXYCoords(PieceFactory.KING_INITIAL_X, PieceFactory.INITAL_Y_COORD_WHITE_PLAYER_OTHER);\n black_player.setpieceList(black_piece_list);\n black_player.setKingXYCoords(PieceFactory.KING_INITIAL_X, PieceFactory.INITAL_Y_COORD_WHITE_PLAYER_OTHER + PieceFactory.DIST_BETWEEN_PIECES);\n }", "public void initPieces() {\r\n\t\tfor (int i = 0; i < 64; i++) {\r\n\t\t\tif (i < 12) {\r\n\t\t\t\tblackPieces[i] = new ChessPiece(\"black\", \"\");\r\n\t\t\t\tblackPieces[i].setBackground(Color.BLACK);\r\n\t\t\t\tblackPieces[i].addMouseMotionListener(this);\r\n\t\t\t\tblackPieces[i].addMouseListener(this);\r\n\t\t\t\tblackPieces[i].setText(null);\r\n\t\t\t\twhitePieces[i] = new ChessPiece(\"white\", \"\");\r\n\t\t\t\twhitePieces[i].setBackground(Color.WHITE);\r\n\t\t\t\twhitePieces[i].addMouseMotionListener(this);\r\n\t\t\t\twhitePieces[i].addMouseListener(this);\r\n\t\t\t\twhitePieces[i].setText(null);\r\n\t\t\t}\r\n\t\t\tspacePieces[i] = new ChessPiece(\"empty\", \"\");\r\n\t\t\tspacePieces[i].setEnabled(false);\r\n\t\t\tspacePieces[i].setVisible(false);\r\n\t\t\tspacePieces[i].setText(null);\r\n\t\t}\r\n\t}", "public void newGame() {\n \tturn = PieceColor.White;\n \t\n \t//the middle are empty squares\n \tfor(int i = 2; i < 6; i++) {\n \t\tfor(int j = 0; j < 8; j++) {\n \t\t\tsetPiece(j, i, new NoPiece(j, i));\n \t\t}\n \t}\n \t\n \t//pawns\n \tfor(int i = 0; i < 8; i++) {\n \t\t//make these pawns\n \t\tsetPiece(i, 1, new Pawn(i, 1, PieceColor.White, this));\n \t\tsetPiece(i, 6, new Pawn(i, 6, PieceColor.Black, this));\n \t}\n \t\n \t//white back row\n \tsetPiece(0, 0, new Rook(0, 0, PieceColor.White, this));\n \tsetPiece(1, 0, new Knight(1, 0, PieceColor.White, this));\n \tsetPiece(2, 0, new Bishop(2, 0, PieceColor.White, this));\n \tsetPiece(3, 0, new Queen(3, 0, PieceColor.White, this));\n \tsetPiece(4, 0, new King(4, 0, PieceColor.White, this));\n \tsetPiece(5, 0, new Bishop(5, 0, PieceColor.White, this));\n \tsetPiece(6, 0, new Knight(6, 0, PieceColor.White, this));\n \tsetPiece(7, 0, new Rook(7, 0, PieceColor.White, this));\n \t\n \t//black back row\n \tsetPiece(0, 7, new Rook(0, 7, PieceColor.Black, this));\n \tsetPiece(1, 7, new Knight(1, 7, PieceColor.Black, this));\n \tsetPiece(2, 7, new Bishop(2, 7, PieceColor.Black, this));\n \tsetPiece(3, 7, new Queen(3, 7, PieceColor.Black, this));\n \tsetPiece(4, 7, new King(4, 7, PieceColor.Black, this));\n \tsetPiece(5, 7, new Bishop(5, 7, PieceColor.Black, this));\n \tsetPiece(6, 7, new Knight(6, 7, PieceColor.Black, this));\n \tsetPiece(7, 7, new Rook(7, 7, PieceColor.Black, this));\n \t\n \t//store locations of king so they can be checked\n \twKing = new Square(4, 0);\n \tbKing = new Square(4, 7);\n }", "public void initChessBoardAutomaticly() {\r\n\t\tthis.initPieces();\r\n\t\tthis.clearBoard();\r\n\t\tfor (int i=0; i<board.size(); i++) {\r\n\t\t\tChessBoardBlock b = board.get(order[i]);\r\n\t\t\tb.setBorderPainted(false);\r\n\t\t}\r\n\t\tfor (int i = 0, w = 0, b = 0, s = 0; i < 8 * 8; i++) {\r\n\r\n\t\t\t// Assign1, Disable board clickable\r\n\t\t\tChessBoardBlock block = board.get(order[i]);\r\n\t\t\tblock.setEnabled(false);\r\n\r\n\t\t\t// Assign1, Put black pieces and record the position\r\n\t\t\tif (i % 2 != 1 && i >= 8 && i < 16) {\r\n\t\t\t\tChessPiece blackPiece = blackPieces[b];\r\n\t\t\t\tblackPiece.position = order[i];\r\n\t\t\t\tpiece.put(order[i], blackPiece);\r\n\t\t\t\tbody.add(blackPiece);\r\n\t\t\t\tb++;\r\n\t\t\t} else if (i % 2 != 0 && (i < 8 || (i > 16 && i < 24))) {\r\n\t\t\t\tChessPiece blackPiece = blackPieces[b];\r\n\t\t\t\tblackPiece.position = order[i];\r\n\r\n\t\t\t\tpiece.put(order[i], blackPiece);\r\n\t\t\t\tbody.add(blackPiece);\r\n\t\t\t\tb++;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t// Assign1, Put white pieces and record the position\r\n\t\t\telse if (i % 2 != 0 && i > 48 && i < 56) {\r\n\t\t\t\tChessPiece whitePiece = whitePieces[w];\r\n\t\t\t\twhitePiece.position = order[i];\r\n\t\t\t\tpiece.put(order[i], whitePiece);\r\n\t\t\t\tbody.add(whitePiece);\r\n\t\t\t\tw++;\r\n\t\t\t} else if (i % 2 != 1\r\n\t\t\t\t\t&& ((i >= 40 && i < 48) || (i >= 56 && i < 64))) {\r\n\t\t\t\tChessPiece whitePiece = whitePieces[w];\r\n\t\t\t\twhitePiece.position = order[i];\r\n\t\t\t\t\r\n\t\t\t\tpiece.put(order[i], whitePiece);\r\n\t\t\t\tbody.add(whitePiece);\r\n\t\t\t\tw++;\r\n\t\t\t}\r\n\r\n\t\t\t// Assign1, Put empty pieces on the board\r\n\t\t\t// Actually, empty pieces will not display on the board, they are\r\n\t\t\t// not existing\r\n\t\t\t// to chess players, just for calculation\r\n\t\t\telse {\r\n\t\t\t\tChessPiece spacePiece = spacePieces[s];\r\n\t\t\t\tspacePiece.position = order[i];\r\n\t\t\t\tbody.add(spacePiece);\r\n\t\t\t\tpiece.put(order[i], spacePiece);\r\n\t\t\t\tspacePiece.setVisible(false);\r\n\t\t\t\ts++;\r\n\t\t\t}\r\n\t\t}\r\n\t\tt.setText(\"Chess Board has been initialized automatically\");\r\n\t\tthis.startGame();\r\n\t}", "public void createPieces(){ \n\t\tfor(int x = 0; x<BOARD_LENGTH; x++){\n\t\t\tfor(int y = 0; y<BOARD_LENGTH; y++){ \n\t\t\t\tif(CHESS_MAP[x][y] != (null)){\n\t\t\t\t\tswitch (CHESS_MAP[x][y]){\n\t\t\t\t\tcase KING:\n\t\t\t\t\t\tpieces[pieceCounter] = new King(pieceCounter, new Point(x+1,y+1), new Point(0,0), true, true, BOARD_PIECE_LENGTH, true);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase QUEEN:\n\t\t\t\t\t\tpieces[pieceCounter] = new Queen(pieceCounter, new Point(x+1,y+1), new Point(0,0), true, true, BOARD_PIECE_LENGTH, true);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase BISHOP:\n\t\t\t\t\t\tpieces[pieceCounter] = new Bishop(pieceCounter, new Point(x+1,y+1), new Point(0,0), true, true, BOARD_PIECE_LENGTH, true);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase KNIGHT:\n\t\t\t\t\t\tpieces[pieceCounter] = new Knight(pieceCounter, new Point(x+1,y+1), new Point(0,0), true, true, BOARD_PIECE_LENGTH, true);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase PAWN:\n\t\t\t\t\t\tpieces[pieceCounter] = new Pawn(pieceCounter, new Point(x+1,y+1), new Point(0,0), true, true, BOARD_PIECE_LENGTH, true);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ROOK:\n\t\t\t\t\t\tpieces[pieceCounter] = new Rook(pieceCounter, new Point(x+1,y+1), new Point(0,0), true, true, BOARD_PIECE_LENGTH, true);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} \n\t\t\t\t\tsetPieceIconAndName(x, y, CHESS_MAP[x][y]); \t\n\t\t\t\t\tpieceCounter++;\n\t\t\t\t}else{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} \n\t}", "public ChessBoard() {\n initComponents();\n createChessBoard();\n\n }", "public Board() {\n //Create all pieces\n board[0][0] = new Rook(\"black\", 0, 0);\n board[0][1] = new Knight(\"black\", 0, 1);\n board[0][2] = new Bishop(\"black\", 0, 2);\n board[0][3] = new Queen(\"black\", 0, 3);\n board[0][4] = new King(\"black\", 0, 4);\n board[0][5] = new Bishop(\"black\", 0, 5);\n board[0][6] = new Knight(\"black\", 0, 6);\n board[0][7] = new Rook(\"black\", 0, 7);\n\n board[7][0] = new Rook(\"white\", 7, 0);\n board[7][1] = new Knight(\"white\", 7, 1);\n board[7][2] = new Bishop(\"white\", 7, 2);\n board[7][3] = new Queen(\"white\", 7, 3);\n board[7][4] = new King(\"white\", 7, 4);\n board[7][5] = new Bishop(\"white\", 7, 5);\n board[7][6] = new Knight(\"white\", 7, 6);\n board[7][7] = new Rook(\"white\", 7, 7);\n\n for (int j = 0; j < 8; j++) {\n board[1][j] = new Pawn(\"black\", 1, j);\n board[6][j] = new Pawn(\"white\", 6, j);\n }\n\n //Printing everything\n for (Piece[] a : board) {\n for (Piece b : a) {\n System.out.printf(\"%-15s\", \"[\" + b + \"]\");\n }\n System.out.println(\"\");\n }\n }", "public Piece[][] createStandardChessboard(Player whitePlayer, Player blackPlayer) {\t\t\r\n\t\tPiece[][] start_board = {\r\n\t\t\t\t{new Rook(0,0,blackPlayer), new Knight(1,0,blackPlayer), new Bishop(2,0,blackPlayer), new Queen(3,0,blackPlayer),new King(4,0,blackPlayer), new Bishop(5,0,blackPlayer), new Knight(6,0,blackPlayer), new Rook(7,0,blackPlayer)},\r\n\t\t\t\t{new Pawn(0,1,blackPlayer), new Pawn(1,1,blackPlayer), new Pawn(2,1,blackPlayer), new Pawn(3,1,blackPlayer),new Pawn(4,1,blackPlayer), new Pawn(5,1,blackPlayer), new Pawn(6,1,blackPlayer), new Pawn(7,1,blackPlayer)},\r\n\t\t\t\t{null, null, null, null,null, null, null, null},\r\n\t\t\t\t{null, null, null, null,null, null, null, null},\r\n\t\t\t\t{null, null, null, null,null, null, null, null},\r\n\t\t\t\t{null, null, null, null,null, null, null, null},\r\n\t\t\t\t{new Pawn(0,6,whitePlayer), new Pawn(1,6,whitePlayer), new Pawn(2,6,whitePlayer), new Pawn(3,6,whitePlayer),new Pawn(4,6,whitePlayer), new Pawn(5,6,whitePlayer), new Pawn(6,6,whitePlayer), new Pawn(7,6,whitePlayer)},\r\n\t\t\t\t{new Rook(0,7,whitePlayer), new Knight(1,7,whitePlayer), new Bishop(2,7,whitePlayer), new Queen(3,7,whitePlayer),new King(4,7,whitePlayer), new Bishop(5,7,whitePlayer), new Knight(6,7,whitePlayer), new Rook(7,7,whitePlayer)}\r\n\t\t};\r\n\t\treturn start_board;\r\n\t}", "public Chess() {\n\t\t// TODO Auto-generated constructor stub\n\t\tchessBoard = new int[BOARD_LENGTH][BOARD_LENGTH];\n\t\tpieces = new AbstractPiece[BOARD_NUM_PIECES];\n\t\toldPosition = new Point();\n\t\tokToMove = false;\n\t\tpieceCounter = 0;\n\t\tpieceChosen = 0;\n\t\tnumClicks = 0; \n\t}", "public void initializeDebugBoard() {\n\t\tboolean hasNotMoved = false;\n\t\tboolean hasMoved = true;\n\t\tboolean white = true;\n\t\tboolean black = false;\n\n\t\t// Set empty rows\n\t\tfor (int row = 0; row < 8; row++)\n\t\t\tfor (int col = 0; col < 8; col++)\n\t\t\t\tboard[row][col] = null;\n\n\t\tboard[5][4] = new Piece('k', white, hasMoved, 5, 4, PieceArray.E_kingId);\n//\t\tboard[1][4] = new Piece(\"rook\", white, hasMoved, 1, 4);\n\t\tboard[2][2] = new Piece('q', black, hasMoved, 2, 2, PieceArray.A_rookId);\n//\t\tboard[3][2] = new Piece('q', black, hasMoved, 3, 2, PieceArray.H_rookId);\n\t\t\n\n\t\tboard[0][0] = new Piece('k', black, hasMoved, 0, 0, PieceArray.E_kingId);\n//\t\tboard[7][7] = new Piece('r', black, hasNotMoved, 7, 7, PieceArray.A_rookId);\n//\t\tboard[6][7] = new Piece('p', black, hasNotMoved, 6, 7, PieceArray.A_pawnId);\n//\t\tboard[6][6] = new Piece('p', black, hasNotMoved, 6, 6, PieceArray.B_pawnId);\n//\t\tboard[6][5] = new Piece('p', black, hasNotMoved, 6, 5, PieceArray.C_pawnId);\n//\t\tboard[6][4] = new Piece('p', black, hasNotMoved, 6, 4, PieceArray.D_pawnId);\n\t\n//\t\tboard[6][6] = new Piece(\"pawn\", black, hasMoved, 6, 6);\n//\t\tboard[6][7] = new Piece(\"pawn\", black, hasMoved, 6, 7);\n//\t\tboard[6][4] = new Piece(\"pawn\", black, hasMoved, 6, 4);\n//\t\t\t\n//\t\t\n//\t\tboard[4][4] = new Piece(\"pawn\", black, hasMoved, 4,4);\n//\t\tboard[3][5] = new Piece(\"rook\", white,hasMoved,3,5);\n//\t\tboard[1][7] = new Piece(\"pawn\",black,hasMoved,1,7);\n\n\t}", "public void create() {\n\t\t// setup Chess board\n\t\tthis.removeAll();\n\t\tthis.layout = new GridLayout(this.startupBoardSize, this.startupBoardSize);\n\t\tthis.squares = new SquarePanel[this.startupBoardSize][this.startupBoardSize];\n\t\t\n\t\tsetLayout(layout);\n\t\tsetPreferredSize(new Dimension(600, 600));\n\t\tsetBorder(new LineBorder(new Color(0, 0, 0)));\n\n\t\t//paint the chess board\n\n\t\tfor (int i = 0; i < this.startupBoardSize; i++) \n\t\t{\n\t\t\tfor (int j = 0; j < this.startupBoardSize; j++) \n\t\t\t{\n\t\t\t\tsquares[i][j] = new SquarePanel(j, i);\n\t\t\t\tsquares[i][j].setPreferredSize(new Dimension(600 / this.startupBoardSize - 5, 600 / this.startupBoardSize - 5));\n\n\n\t\t\t\tsquares[i][j].setBackground(Color.WHITE);\n\t\t\t\t\n\t\t\t\tif (((i + j) % 2) == 0) \n\t\t\t\t{\n\t\t\t\t\tsquares[i][j].setBackground(Color.DARK_GRAY);\n\t\t\t\t}\n\t\t\t\tadd(squares[i][j]);\n\t\t\t}\n\t\t}\n\t}", "public ChessRunner(){\n\t\taddMouseListener(this);\n\t\tfor(int i=0;i<8;i++){\n\t\t\tfor (int j=1;j<7;j++)\n\t\t\t\tif(j==1)\n\t\t\t\t\tboard[i][j] = new BlackPawn();\n\t\t\t\telse if(j==6)\n\t\t\t\t\tboard[i][j] = new WhitePawn();\n\t\t\t\telse\n\t\t\t\t\tboard[i][j]= new BlankPiece();\n\t\t}\n\t\tboard[1][0] = new BlackKnight();\n\t\tboard[6][0] = new BlackKnight();\n\t\tboard[0][0] = new BlackRook();\n\t\tboard[7][0] = new BlackRook();\n\t\tboard[2][0] = new BlackBishop();\n\t\tboard[5][0] = new BlackBishop();\n\t\tboard[4][0] = new BlackKing();\n\t\tboard[3][0] = new BlackQueen();\n\t\t\n\t\tboard[1][7] = new WhiteKnight();\n\t\tboard[6][7] = new WhiteKnight();\n\t\tboard[0][7] = new WhiteRook();\n\t\tboard[7][7] = new WhiteRook();\n\t\tboard[2][7] = new WhiteBishop();\n\t\tboard[5][7] = new WhiteBishop();\n\t\tboard[4][7] = new WhiteKing();\n\t\tboard[3][7] = new WhiteQueen();\n\t\t\n\t}", "void init() {\r\n\r\n map = new HashMap<Square, Piece>();\r\n for (Square sq: INITIAL_ATTACKERS) {\r\n map.put(sq, BLACK);\r\n }\r\n for (Square sq: INITIAL_DEFENDERS) {\r\n map.put(sq, WHITE);\r\n }\r\n king = sq(4, 4);\r\n map.put(king, KING);\r\n for (int i = 0; i <= 8; i++) {\r\n for (int j = 0; j <= 8; j++) {\r\n if (!map.containsKey(sq(i, j))) {\r\n map.put(sq(i, j), EMPTY);\r\n }\r\n }\r\n }\r\n\r\n board = new Piece[9][9];\r\n\r\n for (Square keys : map.keySet()) {\r\n board[keys.col()][keys.row()] = map.get(keys);\r\n }\r\n }", "private void initializeBoard() {\n\n squares = new Square[8][8];\n\n // Sets the initial turn to the White Player\n turn = white;\n\n final int maxSquares = 8;\n for(int i = 0; i < maxSquares; i ++) {\n for (int j = 0; j < maxSquares; j ++) {\n\n Square square = new Square(j, i);\n Piece piece;\n Player player;\n\n if (i < 2) {\n player = black;\n } else {\n player = white;\n }\n\n if (i == 0 || i == 7) {\n switch(j) {\n case 3:\n piece = new Queen(player, square);\n break;\n case 4:\n piece = new King(player, square);\n break;\n case 2:\n case 5:\n piece = new Bishop(player, square);\n break;\n case 1:\n case 6:\n piece = new Knight(player, square);\n break;\n default:\n piece = new Rook(player, square);\n }\n square.setPiece(piece);\n } else if (i == 1 || i == 6) {\n piece = new Pawn(player, square);\n square.setPiece(piece);\n }\n squares[j][i] = square;\n }\n }\n }", "public void initChessBoardManually() {\r\n\t\tstatus.setStatusEdit();\r\n\t\tclearBoard();\r\n\t\tthis.setBoardEnabled(true);\r\n\t\tfor (int i=0; i<8*8; i++) {\r\n\t\t\tChessBoardBlock block = board.get(order[i]);\r\n\t\t\tblock.setBorderPainted(false);\r\n\t\t}\r\n\t\tswitcher.setEnabled(true);\r\n\t\tconfirm.setEnabled(true);\r\n\t\tt.setText(\"<html>Please choose position to put the pieces.<br>Right click to set/cancel King flag</html>\");\r\n\t}", "public Board(GamePieceCreator gamePieces, List<List<Integer>> startingConfiguration,\n List<List<Integer>> objectConfiguration, List<Neighborhood> neighborhoods, int emptyState) {\n myGamePieces = new ArrayList<>();\n myEmptyState = emptyState;\n myStartingConfiguration = startingConfiguration;\n myGamePieceFactory = gamePieces;\n myNeighborhoods = neighborhoods;\n myObjectConfiguration = objectConfiguration;\n createBoardFromStartingConfig();\n }", "public Board(List<List<GamePiece>> pieces, List<Neighborhood> neighborhoods, int emptyState){\n myGamePieces = pieces;\n myNeighborhoods = neighborhoods;\n myEmptyState = emptyState;\n }", "public void createBoard() {\n\t\tboard = new Piece[8][8];\n\t\t\n\t\tfor(int i=0; i<8; i++) {\n\t\t\tfor(int j=0; j<8; j++) {\n\t\t\t\tboard[i][j] = null;\n\t\t\t}\n\t\t}\n\t}", "private void startNewGame(){\n if (selectedPiece!=null)\n selectedPiece.setBackground(getDefaultColor(selectedPiece));\n selectedPiece = null;\n setAllToDefaultColor();\n setDefulatMessage();\n board = new ChessBoard(1, false);\n for(int row = 0 ; row < ROWS; row++){\n for(int col = 0; col < COLS ; col++){\n setButtonIcon(row,col);\n }\n }\n }", "private void initialSetup() {\n\t\tplaceNewPiece('a', 1, new Rook(board, Color.WHITE));\n placeNewPiece('b', 1, new Knight(board, Color.WHITE));\n placeNewPiece('c', 1, new Bishop(board, Color.WHITE));\n placeNewPiece('d', 1, new Queen(board, Color.WHITE));\n placeNewPiece('e', 1, new King(board, Color.WHITE, this)); // 'this' refere-se a esta jogada\n placeNewPiece('f', 1, new Bishop(board, Color.WHITE));\n placeNewPiece('g', 1, new Knight(board, Color.WHITE));\n placeNewPiece('h', 1, new Rook(board, Color.WHITE));\n placeNewPiece('a', 2, new Pawn(board, Color.WHITE, this));\n placeNewPiece('b', 2, new Pawn(board, Color.WHITE, this));\n placeNewPiece('c', 2, new Pawn(board, Color.WHITE, this));\n placeNewPiece('d', 2, new Pawn(board, Color.WHITE, this));\n placeNewPiece('e', 2, new Pawn(board, Color.WHITE, this));\n placeNewPiece('f', 2, new Pawn(board, Color.WHITE, this));\n placeNewPiece('g', 2, new Pawn(board, Color.WHITE, this));\n placeNewPiece('h', 2, new Pawn(board, Color.WHITE, this));\n\n placeNewPiece('a', 8, new Rook(board, Color.BLACK));\n placeNewPiece('b', 8, new Knight(board, Color.BLACK));\n placeNewPiece('c', 8, new Bishop(board, Color.BLACK));\n placeNewPiece('d', 8, new Queen(board, Color.BLACK));\n placeNewPiece('e', 8, new King(board, Color.BLACK, this));\n placeNewPiece('f', 8, new Bishop(board, Color.BLACK));\n placeNewPiece('g', 8, new Knight(board, Color.BLACK));\n placeNewPiece('h', 8, new Rook(board, Color.BLACK));\n placeNewPiece('a', 7, new Pawn(board, Color.BLACK, this));\n placeNewPiece('b', 7, new Pawn(board, Color.BLACK, this));\n placeNewPiece('c', 7, new Pawn(board, Color.BLACK, this));\n placeNewPiece('d', 7, new Pawn(board, Color.BLACK, this));\n placeNewPiece('e', 7, new Pawn(board, Color.BLACK, this));\n placeNewPiece('f', 7, new Pawn(board, Color.BLACK, this));\n placeNewPiece('g', 7, new Pawn(board, Color.BLACK, this));\n placeNewPiece('h', 7, new Pawn(board, Color.BLACK, this));\n\t}", "public Board()\n\t{\n\t\tcols = DEFAULT_WIDTH;\n\t\trows = DEFAULT_HEIGHT;\n\t\t\n\t\tpieces = new int[rows][cols];\n\t\tif (pieces.length > 0)\n\t\t{\n\t\t\tfor (int i = 0; i < pieces.length; i++)\n\t\t\t\tfor (int j = 0; j < pieces[0].length; j++)\n\t\t\t\t\tpieces[i][j] = -1;\n\t\t}\n\t}", "public void setPieces(){\r\n Pawn[] arrwPawn = new Pawn[8];\r\n for (int i=0 ; i<8 ; i++){\r\n pos.setPosition(6,i);\r\n arrwPawn[i] = new Pawn (pos , piece.Colour.WHITE);\r\n GameBoard.putPiece(arrwPawn[i]);\r\n }\r\n\r\n Pawn[] arrbPawn = new Pawn[8];\r\n for(int i=0 ; i<8 ; i++){\r\n pos.setPosition(0,i);\r\n arrbPawn[i] = new Pawn(pos , piece.Colour.BLACK);\r\n GameBoard.putPiece(arrbPawn[i]);\r\n }\r\n\r\n\r\n //set black pieces in the board\r\n\r\n pos.setPosition(0,0);\r\n Rook bRook1 = new Rook(pos, piece.Colour.BLACK);\r\n GameBoard.putPiece(bRook1);;\r\n\r\n pos.setPosition(0,7);\r\n Rook bRook2 = new Rook(pos, piece.Colour.BLACK);\r\n GameBoard.putPiece(bRook2);\r\n\r\n\r\n pos.setPosition(0,1);\r\n Knight bKnight1 = new Knight(pos, piece.Colour.BLACK);\r\n GameBoard.putPiece(bKnight1);\r\n\r\n pos.setPosition(0,6);\r\n Knight bKnight2 = new Knight(pos, piece.Colour.BLACK);\r\n GameBoard.putPiece(bKnight1);\r\n\r\n pos.setPosition(0,2);\r\n Bishop bBishop1 = new Bishop(pos, piece.Colour.BLACK);\r\n GameBoard.putPiece(bBishop1);\r\n\r\n pos.setPosition(0,5);\r\n Bishop bBishop2 = new Bishop(pos, piece.Colour.BLACK);\r\n GameBoard.putPiece(bBishop2);\r\n\r\n pos.setPosition(0,3);\r\n Queen bQueen = new Queen(pos, piece.Colour.BLACK);\r\n GameBoard.putPiece(bQueen);\r\n\r\n pos.setPosition(0,4);\r\n King bKing = new King(pos, piece.Colour.BLACK);\r\n GameBoard.putPiece(bKing);\r\n\r\n //set white pieces in the board\r\n\r\n pos.setPosition(7,0);\r\n Rook wRook1 = new Rook(pos, piece.Colour.WHITE);\r\n GameBoard.putPiece(wRook1);\r\n\r\n pos.setPosition(7,7);\r\n Rook wRook2 = new Rook(pos, piece.Colour.WHITE);\r\n GameBoard.putPiece(wRook2);\r\n\r\n pos.setPosition(7,1);\r\n Knight wKnight1 = new Knight(pos, piece.Colour.WHITE);\r\n GameBoard.putPiece(wKnight1);\r\n\r\n pos.setPosition(7,6);\r\n Knight wKnight2 = new Knight(pos, piece.Colour.WHITE);\r\n GameBoard.putPiece(wKnight1);\r\n\r\n pos.setPosition(7,2);\r\n Bishop wBishop1 = new Bishop(pos, piece.Colour.WHITE);\r\n GameBoard.putPiece(wBishop1);\r\n\r\n pos.setPosition(7,5);\r\n Bishop wBishop2 = new Bishop(pos, piece.Colour.WHITE);\r\n GameBoard.putPiece(wBishop2);\r\n\r\n pos.setPosition(7,3);\r\n Queen wQueen = new Queen(pos, piece.Colour.WHITE);\r\n GameBoard.putPiece(wQueen);\r\n\r\n pos.setPosition(7,4);\r\n King wKing = new King(pos, piece.Colour.WHITE);\r\n GameBoard.putPiece(wKing);\r\n\r\n\r\n\r\n Rook arrwRook[] = {wRook1,wRook2};\r\n Rook arrbRook[] = {bRook1,bRook2};\r\n Queen arrwQueen[] = {wQueen};\r\n Queen arrbQueen[] = {bQueen};\r\n Knight arrwKnight[] = {wKnight1,wKnight2};\r\n Knight arrbKnight[] = {bKnight1,bKnight2};\r\n King arrwKing[] = {wKing};\r\n King arrbKing[] = {bKing};\r\n Bishop arrwBishop[] = {wBishop1,wBishop2};\r\n Bishop arrbBishop[] = {bBishop1,bBishop2};\r\n }", "public static void initBoard()\r\n\t{\n\t\tfor ( int r=0; r<3; r++ )\r\n\t\t\tfor ( int c=0; c<3; c++ )\r\n\t\t\t\tboard[r][c] = ' ';\r\n\t}", "private void initPieceColors(){\n\t\tfor(Piece p : this.pieces)\n\t\t\tpieceColors.put(p, Utils.randomColor());\n\t}", "private void initializeGameBoard()\n\t{\n\t\tboard = new State[3][3];\n\t\tfor (int r = 0; r < 3; r++)\n\t\t\tfor (int c = 0; c < 3; c++)\n\t\t\t\tboard[r][c] = State.EMPTY;\n\t}", "public Board()\r\n\t{\r\n\t\tthis.grid = new CellState[GRID_SIZE][GRID_SIZE];\r\n\t\tthis.whiteMarblesCount = MARBLES_COUNT;\r\n\t\tthis.blackMarblesCount = MARBLES_COUNT;\r\n\t\t\r\n\t\t/**\r\n\t\t * Initializes the board with empty value\r\n\t\t */\r\n\t\tfor (int indexcol = 0; indexcol < GRID_SIZE; indexcol++)\r\n\t\t{\r\n\t\t\tfor (int indexrow = 0; indexrow < GRID_SIZE; indexrow++)\r\n\t\t\t{\r\n\t\t\t\tthis.grid[indexrow][indexcol] = CellState.EMPTY;\t\t\t\t\r\n\t\t\t}\t\r\n\t\t}\r\n\t\t\r\n\t\t/**\r\n\t\t * Sets marbles on the board with default style\r\n\t\t */\r\n\t\tfor (int indexcol = 0; indexcol < 5; indexcol++)\r\n\t\t{\r\n\t\t\tthis.grid[0][indexcol] = CellState.WHITE_MARBLE;\r\n\t\t\tthis.grid[8][8 - indexcol] = CellState.BLACK_MARBLE;\r\n\t\t}\r\n\t\tfor (int indexcol = 0; indexcol < 6; indexcol++)\r\n\t\t{\r\n\t\t\tthis.grid[1][indexcol] = CellState.WHITE_MARBLE;\r\n\t\t\tthis.grid[7][8 - indexcol] = CellState.BLACK_MARBLE;\r\n\t\t}\r\n\t\tfor (int indexcol = 2; indexcol < 5; indexcol++)\r\n\t\t{\r\n\t\t\tthis.grid[2][indexcol] = CellState.WHITE_MARBLE;\r\n\t\t\tthis.grid[6][8 - indexcol] = CellState.BLACK_MARBLE;\r\n\t\t}\r\n\t\tthis.grid[3][8] = CellState.INVALID;\r\n\t\tthis.grid[2][7] = CellState.INVALID;\r\n\t\tthis.grid[1][6] = CellState.INVALID;\r\n\t\tthis.grid[0][5] = CellState.INVALID;\r\n\t\tthis.grid[5][0] = CellState.INVALID;\r\n\t\tthis.grid[6][1] = CellState.INVALID;\r\n\t\tthis.grid[7][2] = CellState.INVALID;\r\n\t\tthis.grid[8][3] = CellState.INVALID;\r\n\t}", "public void initializeBoard() {\r\n int x;\r\n int y;\r\n\r\n this.loc = this.userColors();\r\n\r\n this.board = new ArrayList<ACell>();\r\n\r\n for (y = -1; y < this.blocks + 1; y += 1) {\r\n for (x = -1; x < this.blocks + 1; x += 1) {\r\n ACell nextCell;\r\n\r\n if (x == -1 || x == this.blocks || y == -1 || y == this.blocks) {\r\n nextCell = new EndCell(x, y);\r\n } else {\r\n nextCell = new Cell(x, y, this.randColor(), false);\r\n }\r\n if (x == 0 && y == 0) {\r\n nextCell.flood();\r\n }\r\n this.board.add(nextCell);\r\n }\r\n }\r\n this.stitchCells();\r\n this.indexHelp(0, 0).floodInitStarter();\r\n }", "private void init() {\n\t\tpossibleFlips = new HashSet<Square>();\n\t\t\n\t\tfor (int i = 0; i < dimensions.x; ++i) {\n\t\t\tfor (int j = 0; j < dimensions.y; ++j) {\n\t\t\t\tboard[i][j] = new Square(Square.SquareType.Empty, i, j, this);\n\t\t\t}\n\t\t}\n\t\tswitch (boardType) {\n\t\tcase Tiny:\n\t\t\tplacePiece(new Square(Square.SquareType.Red, 2, 2, this));\n\t\t\tplacePiece(new Square(Square.SquareType.Black, 3, 2, this));\n\t\t\tplacePiece(new Square(Square.SquareType.Red, 3, 3, this));\n\t\t\tplacePiece(new Square(Square.SquareType.Black, 2, 3, this));\n\t\t\tbreak;\n\t\tcase Standard:\n\t\t\tplacePiece(new Square(Square.SquareType.Red, 3, 3, this));\n\t\t\tplacePiece(new Square(Square.SquareType.Black, 4, 3, this));\n\t\t\tplacePiece(new Square(Square.SquareType.Red, 4, 4, this));\n\t\t\tplacePiece(new Square(Square.SquareType.Black, 3, 4, this));\n\t\t\tbreak;\n\t\tcase Giant:\n\t\t\tplacePiece(new Square(Square.SquareType.Red, 5, 5, this));\n\t\t\tplacePiece(new Square(Square.SquareType.Black, 6, 5, this));\n\t\t\tplacePiece(new Square(Square.SquareType.Red, 6, 6, this));\n\t\t\tplacePiece(new Square(Square.SquareType.Black, 5, 6, this));\n\t\t\tbreak;\n\t\t}\n\t\t\n\t\tsetHighlightedSquare(0, 0);\n\t\t// Calculate possible moves with black to play\n\t\tCalculatePossibleMoves(true);\n\t}", "public final void initialPosition() {\n\t\tfor( int i = 0; i < 4; i++) {\n\t\t setPiece( new PieceImpl( Color.RED, Type.PAWN), new PositionImpl( 38 + 8*i));\n\t\t}\n\t\tfor( int i = 0; i < 4; i++) {\n\t\t setPiece( new PieceImpl( Color.BLACK, Type.PAWN), new PositionImpl( 12 + i));\n\t\t}\n\t\tfor( int i = 0; i < 4; i++) {\n\t\t setPiece( new PieceImpl( Color.YELLOW, Type.PAWN), new PositionImpl( 1 + 8*i));\n\t\t}\n\t\tfor( int i = 0; i < 4; i++) {\n\t\t setPiece( new PieceImpl( Color.GREEN, Type.PAWN), new PositionImpl( 48 + i));\n\t\t}\n\t\t\n\t\tsetPiece( new PieceImpl( Color.RED, Type.BOAT), new PositionImpl( 63 ));\n\t\tsetPiece( new PieceImpl( Color.RED, Type.KNIGHT), new PositionImpl( 55 ));\n\t\tsetPiece( new PieceImpl( Color.RED, Type.ELEPHANT), new PositionImpl( 47 ));\n\t\tsetPiece( new PieceImpl( Color.RED, Type.KING), new PositionImpl( 39 ));\n\t\t\n\t\tsetPiece( new PieceImpl( Color.BLACK, Type.BOAT), new PositionImpl( 7 ));\n\t\tsetPiece( new PieceImpl( Color.BLACK, Type.KNIGHT), new PositionImpl( 6 ));\n\t\tsetPiece( new PieceImpl( Color.BLACK, Type.ELEPHANT), new PositionImpl( 5 ));\n\t\tsetPiece( new PieceImpl( Color.BLACK, Type.KING), new PositionImpl( 4 ));\n\n\t\tsetPiece( new PieceImpl( Color.YELLOW, Type.BOAT), new PositionImpl( 0 ));\n\t\tsetPiece( new PieceImpl( Color.YELLOW, Type.KNIGHT), new PositionImpl( 8 ));\n\t\tsetPiece( new PieceImpl( Color.YELLOW, Type.ELEPHANT), new PositionImpl( 16 ));\n\t\tsetPiece( new PieceImpl( Color.YELLOW, Type.KING), new PositionImpl( 24 ));\n\n\t\tsetPiece( new PieceImpl( Color.GREEN, Type.BOAT), new PositionImpl( 56 ));\n\t\tsetPiece( new PieceImpl( Color.GREEN, Type.KNIGHT), new PositionImpl( 57 ));\n\t\tsetPiece( new PieceImpl( Color.GREEN, Type.ELEPHANT), new PositionImpl( 58 ));\n\t\tsetPiece( new PieceImpl( Color.GREEN, Type.KING), new PositionImpl( 59 ));\n\t\t\n }", "public GameBoard() {\n this.gameStarted = false;\n this.turn = 1; \n this.boardState = new char[3][3];\n this.winner = 0; \n this.isDraw = false; \n\n }", "private void initializeBoard(){\r\n checks =new int[][]{{0,2,0,2,0,2,0,2},\r\n {2,0,2,0,2,0,2,0},\r\n {0,2,0,2,0,2,0,2},\r\n {0,0,0,0,0,0,0,0},\r\n {0,0,0,0,0,0,0,0},\r\n {1,0,1,0,1,0,1,0},\r\n {0,1,0,1,0,1,0,1},\r\n {1,0,1,0,1,0,1,0}};\r\n }", "public ChessBoard() {\r\n\t\t\tsuper();\r\n\t\t\ttry {\r\n\t\t\t\tbgImage = ImageIO.read(new File(\"人人\\\\棋盘背景.png\"));\r\n\t\t\t\twImage = ImageIO.read(new File(\"人人\\\\白棋子.png\"));\r\n\t\t\t\tbImage = ImageIO.read(new File(\"人人\\\\黑棋子.png\"));\r\n\t\t\t} catch (IOException e) {\r\n\t\t\t\t// TODO Auto-generated catch block\r\n\t\t\t\te.printStackTrace();\r\n\t\t\t}\r\n\r\n\t\t\tthis.repaint();\r\n\t\t}", "public void setBoard(){\n \n\t m_Pieces[3][3]= WHITE_PIECE;\n m_Pieces[4][4]= WHITE_PIECE;\n m_Pieces[3][4]= BLACK_PIECE;\n m_Pieces[4][3]= BLACK_PIECE;\n for(int x=0;x<WIDTH;x++){\n for(int y=0;y<HEIGHT;y++){\n if(m_Pieces[x][y]==null){\n m_Pieces[x][y]=NONE_PIECE;\n }\n }\n }\n }", "private void boardInit() {\n for(int i = 0; i < this.boardHeight; i++)\n this.board[i][0] = ' ';\n for(int i = 0; i < this.boardWidth; i++)\n this.board[0][i] = ' ';\n \n for(int i = 1; i < this.boardHeight; i++) {\n for(int j = 1; j < this.boardWidth; j++) {\n this.board[i][j] = '*';\n }\n }\n }", "public void start() {\n clear();\n // Assigning chess pieces to players.\n whitePieces.add(new Piece(Owner.WHITE, Who.KING, Rank.R1, File.E));\n whitePieces.add(new Piece(Owner.WHITE, Who.QUEEN, Rank.R1, File.D));\n whitePieces.add(new Piece(Owner.WHITE, Who.ROOK, Rank.R1, File.A));\n whitePieces.add(new Piece(Owner.WHITE, Who.ROOK, Rank.R1, File.H));\n whitePieces.add(new Piece(Owner.WHITE, Who.BISHOP, Rank.R1, File.C));\n whitePieces.add(new Piece(Owner.WHITE, Who.BISHOP, Rank.R1, File.F));\n whitePieces.add(new Piece(Owner.WHITE, Who.KNIGHT, Rank.R1, File.B));\n whitePieces.add(new Piece(Owner.WHITE, Who.KNIGHT, Rank.R1, File.G));\n whitePieces.add(new Piece(Owner.WHITE, Who.PAWN, Rank.R2, File.A));\n whitePieces.add(new Piece(Owner.WHITE, Who.PAWN, Rank.R2, File.B));\n whitePieces.add(new Piece(Owner.WHITE, Who.PAWN, Rank.R2, File.C));\n whitePieces.add(new Piece(Owner.WHITE, Who.PAWN, Rank.R2, File.D));\n whitePieces.add(new Piece(Owner.WHITE, Who.PAWN, Rank.R2, File.E));\n whitePieces.add(new Piece(Owner.WHITE, Who.PAWN, Rank.R2, File.F));\n whitePieces.add(new Piece(Owner.WHITE, Who.PAWN, Rank.R2, File.G));\n whitePieces.add(new Piece(Owner.WHITE, Who.PAWN, Rank.R2, File.H));\n\n for (Piece p : whitePieces) {\n board[p.row.ordinal()][p.col.ordinal()] = p;\n }\n\n blackPieces.add(new Piece(Owner.BLACK, Who.KING, Rank.R8, File.E));\n blackPieces.add(new Piece(Owner.BLACK, Who.QUEEN, Rank.R8, File.D));\n blackPieces.add(new Piece(Owner.BLACK, Who.ROOK, Rank.R8, File.A));\n blackPieces.add(new Piece(Owner.BLACK, Who.ROOK, Rank.R8, File.H));\n blackPieces.add(new Piece(Owner.BLACK, Who.BISHOP, Rank.R8, File.C));\n blackPieces.add(new Piece(Owner.BLACK, Who.BISHOP, Rank.R8, File.F));\n blackPieces.add(new Piece(Owner.BLACK, Who.KNIGHT, Rank.R8, File.B));\n blackPieces.add(new Piece(Owner.BLACK, Who.KNIGHT, Rank.R8, File.G));\n blackPieces.add(new Piece(Owner.BLACK, Who.PAWN, Rank.R7, File.A));\n blackPieces.add(new Piece(Owner.BLACK, Who.PAWN, Rank.R7, File.B));\n blackPieces.add(new Piece(Owner.BLACK, Who.PAWN, Rank.R7, File.C));\n blackPieces.add(new Piece(Owner.BLACK, Who.PAWN, Rank.R7, File.D));\n blackPieces.add(new Piece(Owner.BLACK, Who.PAWN, Rank.R7, File.E));\n blackPieces.add(new Piece(Owner.BLACK, Who.PAWN, Rank.R7, File.F));\n blackPieces.add(new Piece(Owner.BLACK, Who.PAWN, Rank.R7, File.G));\n blackPieces.add(new Piece(Owner.BLACK, Who.PAWN, Rank.R7, File.H));\n\n for (Piece p : blackPieces) {\n board[p.row.ordinal()][p.col.ordinal()] = p;\n }\n\n whoseTurn = Owner.WHITE;\n canCastle = 15;\n passer = null;\n movesDone = lastEatMove = 0;\n }", "public void initialize() {\r\n\r\n\t\t// Assign1, Add control button\r\n\t\tFlowLayout fl = new FlowLayout();\r\n\t\tfl.setAlignment(FlowLayout.LEFT);\r\n\t\tthis.setLayout(fl);\r\n\t\tswitcher = new JButton(\"Switch Player:black\");\r\n\t\tswitcher.setEnabled(false);\r\n\t\tswitcher.addActionListener(this);\r\n\t\tconfirm = new JButton(\"Confirm\");\r\n\t\tconfirm.setEnabled(false);\r\n\t\tconfirm.addActionListener(this);\r\n\t\tthis.add(switcher);\r\n\t\tthis.add(confirm);\r\n\t\tswitcher.setBounds(520, 200, 50, 20);\r\n\t\tconfirm.setBounds(520, 400, 50, 20);\r\n\r\n\t\t// Assign1, Add message upper from the board\r\n\t\tt = new JLabel();\r\n\t\tt.setVerticalAlignment(JLabel.TOP);\r\n\t\tthis.add(t);\r\n\t\tt.setVisible(true);\r\n\r\n\t\t// Assign1, Get layer object, which in order to enable layering of JFrame\r\n\t\tlp = this.getLayeredPane();\r\n\r\n\t\t// Define board by JPanel with a 8*8 GridLayout\r\n\t\t// Put red and white board\r\n\t\tboardBg = new JPanel();\r\n\t\tboardBg.setLayout(new GridLayout(8, 8));\r\n\t\tfor (int i = 0; i < 8 * 8; i++) {\r\n\t\t\t// Assign1, Put red board\r\n\t\t\tif ((i % 2 == 0 && (i / 8) % 2 == 1)\r\n\t\t\t\t\t|| (i % 2 == 1 && (i / 8) % 2 == 0)) {\r\n\t\t\t\tChessBoardBlock block = new ChessBoardBlock(\"red\", order[i]);\r\n\t\t\t\tblock.addActionListener(this);\r\n\t\t\t\tblock.addMouseListener(this);\r\n\t\t\t\tboard.put(order[i], block);\r\n\t\t\t\tblock.setEnabled(false);\r\n\t\t\t\tblock.setBorderPainted(false);\r\n\t\t\t\tboardBg.add(block);\r\n\t\t\t}\r\n\t\t\t// Assign1, Put white board\r\n\t\t\telse {\r\n\t\t\t\tChessBoardBlock block = new ChessBoardBlock(\"white\", order[i]);\r\n\t\t\t\tblock.addActionListener(this);\r\n\t\t\t\tblock.addMouseListener(this);\r\n\t\t\t\tboard.put(order[i], block);\r\n\t\t\t\tblock.setEnabled(false);\r\n\t\t\t\tblock.setBorderPainted(false);\r\n\t\t\t\tboardBg.add(block);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Assign1, Put pieces on the board, on another same JPanel with 8*8 GridLayout\r\n\t\tbody = new JPanel();\r\n\t\tbody.setLayout(new GridLayout(8, 8));\r\n\r\n\t\t// Assign1, Put board panel and piece panel in different layer by the Integer parameter\r\n\t\tlp.add(boardBg, new Integer(1));\r\n\t\tlp.add(body, new Integer(2));\r\n\t\tboardBg.setBounds(0, 70, 500, 500);\r\n\t\tboardBg.setVisible(true);\r\n\t\tbody.setBounds(0, 70, 500, 500);\r\n\t\tbody.setOpaque(false);// Assign1, Make the upper layer panel transparent so that lower layer can be seen\r\n\t\tbody.setVisible(true);\r\n\t\t\r\n\t\tstatus.setStatusInit();\r\n\r\n\t}", "public Game() {\n\t\tthis.board = new Board();\n\t\tthis.pieces = new HashMap<Chess.Color, List<Piece>>();\n\t\tthis.pieces.put(Chess.Color.WHITE, new ArrayList<Piece>());\n\t\tthis.pieces.put(Chess.Color.BLACK, new ArrayList<Piece>());\n\t\tthis.moveStack = new Stack<Move>();\n\t}", "public void setBeginningBoard() {\n clearBooleanBoard();\n\n figBoard[0][0] = new Rook(\"white\", 00, white[0]);\n figBoard[0][1] = new Knight(\"white\", 01, white[1]);\n figBoard[0][2] = new Bishop(\"white\", 02, white[2]);\n figBoard[0][4] = new King(\"white\", 04, white[3]);\n figBoard[0][3] = new Queen(\"white\", 03, white[4]);\n figBoard[0][5] = new Bishop(\"white\", 05, white[2]);\n figBoard[0][6] = new Knight(\"white\", 06, white[1]);\n figBoard[0][7] = new Rook(\"white\", 07, white[0]);\n\n for (int i = 0; i < gA.getBoard().length; i++) {\n booleanBoard[0][i] = true;\n gA.getBoard()[0][i].setRotation(180);\n }\n\n for (int i = 0; i < gA.getBoard().length; i++) {\n booleanBoard[1][i] = true;\n gA.getBoard()[1][i].setRotation(180);\n figBoard[1][i] = new Pawn(\"white\", 10 + i, white[8]);\n }\n\n figBoard[7][0] = new Rook(\"black\", 70, black[0]);\n figBoard[7][1] = new Knight(\"black\", 71, black[1]);\n figBoard[7][2] = new Bishop(\"black\", 72, black[2]);\n figBoard[7][4] = new King(\"black\", 74, black[3]);\n figBoard[7][3] = new Queen(\"black\", 73, black[4]);\n figBoard[7][5] = new Bishop(\"black\", 75, black[2]);\n figBoard[7][6] = new Knight(\"black\", 76, black[1]);\n figBoard[7][7] = new Rook(\"black\", 77, black[0]);\n\n for (int i = 0; i < gA.getBoard().length; i++) {\n booleanBoard[7][i] = true;\n gA.getBoard()[7][i].setRotation(0);\n }\n\n for (int i = 0; i < gA.getBoard().length; i++) {\n booleanBoard[6][i] = true;\n gA.getBoard()[6][i].setRotation(0);\n figBoard[6][i] = new Pawn(\"black\", 60 + i, black[8]);\n }\n\n clearFallenFigures();\n clearBoardBackground();\n clearStringBoard();\n showBoard(); //shows the figures\n showScore();\n setBoardClickable();\n\n if (beginner % 2 == 0)\n this.turn = 0;\n else this.turn = 1;\n\n beginner++;\n\n numberOfBlackFallen = 0;\n numberOfWhiteFallen = 0;\n fallenFiguresWhite = new ArrayList<Figure>();\n fallenFiguresBlack = new ArrayList<Figure>();\n\n showCheck();\n showTurn();\n }", "public static int[][] createBoard() {\r\n\t\t\r\n\t\tint[][] board = new int [8][8];\r\n\t\t//printing the red solduers\r\n\t\tfor (int line =0,column=0;line<3;line=line+1){\r\n\t\t\tif (line%2==0){column=0;}\r\n\t\t\telse {column=1;}\r\n\t\t\tfor (;column<8;column=column+2){\r\n\t\t\t\tboard [line][column] = 1;\r\n\t\t\t}\r\n\t\t}\r\n\t\t//printing the blu solduers\r\n\t\tfor (int line =5,column=0;line<8;line=line+1){\r\n\t\t\tif (line%2==0){column=0;}\r\n\t\t\telse {column=1;}\r\n\t\t\tfor (;column<8;column=column+2){\r\n\t\t\t\tboard [line][column] = -1;\r\n\t\t\t}\r\n\t\t}\t\t\t\r\n\t\treturn board;\r\n\t}", "public Board(ArrayList<Piece> pieces)\n {\n squares = new Square[Chess.ROWS][Chess.COLUMNS];\n setLayout(new GridLayout(Chess.ROWS,Chess.COLUMNS,0,0));\n firstSelected = null;\n mainBoard=true;\n turn = 0;\n fiftyMove = 0;\n for (int i = 0; i < Chess.ROWS; i++)\n for (int j = 0; j < Chess.COLUMNS; j++)\n {\n squares[i][j] = new Square(i,j,this);\n for (Piece p: pieces)\n if (p.getOrigin().equals(new Location(i,j)))\n squares[i][j].setPiece(p);\n add(squares[i][j]);\n }\n positions = new ArrayList<>();\n positions.add(toString());\n }", "interface Cnst {\r\n\r\n /////////////////////////////////////////////////////////////\r\n // These constants can be changed to edit the big bang ran //\r\n /////////////////////////////////////////////////////////////\r\n\r\n //full size is eight, scales the size of the board\r\n int scale = 8;\r\n\r\n //numbers of blocks in a row and a column\r\n int blocks = 10;\r\n\r\n //number of colors the game will use, between 2-8 inclusive\r\n int numOfColors = 8;\r\n\r\n //the number of turns you have to win the game\r\n int maxTurns = 25;\r\n\r\n\r\n ////////////////////////////////////////\r\n // Please do not edit these constants //\r\n ////////////////////////////////////////\r\n\r\n //the visible board width, scales with scale\r\n int boardWidth = 70 * scale;\r\n\r\n //the visible board height, scales with scale\r\n int boardHeight = 70 * scale;\r\n\r\n //cell width scales with the board and scale\r\n int cellWidth = boardWidth / blocks;\r\n\r\n //cell height scales with board and scale\r\n int cellHeight = boardHeight / blocks;\r\n\r\n //new constant for text on the board\r\n int textHeight = boardWidth / 12;\r\n\r\n //the 8 colors that can be selected by the user\r\n ArrayList<Color> colorsToChoose =\r\n new ArrayList<Color>(Arrays.asList(\r\n Color.CYAN, Color.PINK, Color.ORANGE,\r\n Color.BLUE, Color.RED, Color.GREEN,\r\n Color.MAGENTA, Color.YELLOW));\r\n}", "private void initializeBoard() {\n\t\t\n\t}", "public Board(Player p1, Player p2) {\r\n try {\r\n crownImage = ImageIO.read(new File(\"crown.jpg\"));\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n }\r\n checks = new int[8][8];\r\n currentPlayer = p2;\r\n nextPlayer = p1;\r\n whiteQueens = 0;\r\n whiteChecks = 12;\r\n blackQueens = 0;\r\n blackChecks = 12;\r\n winner = null;\r\n isGame = true;\r\n window(this);\r\n initializeBoard();\r\n swapPlayer();\r\n repaint();\r\n\r\n }", "public void initialize() {\n int numberOfReds = board.length / 2;\n\n for (int i = 0; i < board.length; i++) {\n if (i < numberOfReds) {\n board[i] = PIECE_RED;\n } else if (i > numberOfReds) {\n board[i] = PIECE_BLUE;\n }\n }\n }", "public Player(int startR ,int endR , int startC ,int endC , String color) { // constractor\n // startR - start row for creating the pieces , startC - start colomn for creating the pieces\n // endR - End row for creating the pieces , endC - END colomn for creating the pieces\n this.color=color;\n \n for(int i = startR; i <= endR; i++){\n for(int j = startC ; j <= endC ;j++){\n pieces.put(new Integer (j*Board.N+i), new Piece(i,j, color)); // new piece\n teritory.add(j* Board.N +i); // saving index of teritory base \n }\n }\n }", "public void createNewGame() {\n\t\tfor(int n = 0; n < 8; n++){\n\t\t\tfor(int j = 0; j < 8; j++){\n\t\t\t\tif ( n % 2 == j % BLACK_PAWN ) {\n\t\t\t\t\tif (n < 3)\n\t\t\t\t\t\tarr[n][j] = RED_PAWN;\n\t\t\t\t\telse if (n > 4)\n\t\t\t\t\t\tarr[n][j] = BLACK_PAWN;\n\t\t\t\t\telse\n\t\t\t\t\t\tarr[n][j] = EMPTY;\n\t\t } \n\t\t\t\telse\n\t\t\t\t\tarr[n][j] = EMPTY;\n\t\t\t}\n\t\t}\n\t}", "public Board()\r\n {\r\n board = new Piece[8][8];\r\n xLength = yLength = 8;\r\n }", "public void setInitialPosition()\n {\n putGenericPiece(GenericPiece.PAWN, Colour.WHITE, Square.a2);\n putGenericPiece(GenericPiece.PAWN, Colour.WHITE, Square.b2);\n putGenericPiece(GenericPiece.PAWN, Colour.WHITE, Square.c2);\n putGenericPiece(GenericPiece.PAWN, Colour.WHITE, Square.d2);\n putGenericPiece(GenericPiece.PAWN, Colour.WHITE, Square.e2);\n putGenericPiece(GenericPiece.PAWN, Colour.WHITE, Square.f2);\n putGenericPiece(GenericPiece.PAWN, Colour.WHITE, Square.g2);\n putGenericPiece(GenericPiece.PAWN, Colour.WHITE, Square.h2);\n //Se colocan los peones negros en la séptima fila\n putGenericPiece(GenericPiece.PAWN, Colour.BLACK, Square.a7);\n putGenericPiece(GenericPiece.PAWN, Colour.BLACK, Square.b7);\n putGenericPiece(GenericPiece.PAWN, Colour.BLACK, Square.c7);\n putGenericPiece(GenericPiece.PAWN, Colour.BLACK, Square.d7);\n putGenericPiece(GenericPiece.PAWN, Colour.BLACK, Square.e7);\n putGenericPiece(GenericPiece.PAWN, Colour.BLACK, Square.f7);\n putGenericPiece(GenericPiece.PAWN, Colour.BLACK, Square.g7);\n putGenericPiece(GenericPiece.PAWN, Colour.BLACK, Square.h7);\n //Se colocan las torres blancas en a1 y h1\n putGenericPiece(GenericPiece.ROOK,Colour.WHITE,Square.a1);\n putGenericPiece(GenericPiece.ROOK,Colour.WHITE,Square.h1);\n //Se colocan las torres negras en a8 y h9\n putGenericPiece(GenericPiece.ROOK,Colour.BLACK,Square.a8);\n putGenericPiece(GenericPiece.ROOK,Colour.BLACK,Square.h8);\n //Se colocan los caballos blancos en b1 y g1\n putGenericPiece(GenericPiece.KNIGHT,Colour.WHITE,Square.b1);\n putGenericPiece(GenericPiece.KNIGHT,Colour.WHITE,Square.g1);\n //Se colocan los caballos negros en b8 y g8\n putGenericPiece(GenericPiece.KNIGHT,Colour.BLACK,Square.b8);\n putGenericPiece(GenericPiece.KNIGHT,Colour.BLACK,Square.g8);\n //Se colocan los alfiles blancos en c1 y f1\n putGenericPiece(GenericPiece.BISHOP,Colour.WHITE,Square.c1);\n putGenericPiece(GenericPiece.BISHOP,Colour.WHITE,Square.f1);\n //Se colocan los alfiles negros en c8 y f8\n putGenericPiece(GenericPiece.BISHOP,Colour.BLACK,Square.c8);\n putGenericPiece(GenericPiece.BISHOP,Colour.BLACK,Square.f8);\n //Se coloca la dama blanca en d1\n putGenericPiece(GenericPiece.QUEEN,Colour.WHITE,Square.d1);\n //Se coloca la dama negra en d8\n putGenericPiece(GenericPiece.QUEEN,Colour.BLACK,Square.d8);\n //Se coloca el rey blanco en e1\n putGenericPiece(GenericPiece.KING,Colour.WHITE,Square.e1);\n //Se coloca el rey negro en e8\n putGenericPiece(GenericPiece.KING,Colour.BLACK,Square.e8);\n \n //Se permiten los enroques para ambos jugadores\n setCastlingShort(Colour.WHITE,true);\n setCastlingShort(Colour.BLACK,true);\n setCastlingLong(Colour.WHITE,true);\n setCastlingLong(Colour.BLACK,true);\n \n //Se da el turno a las blancas\n setTurn(Colour.WHITE);\n \n gamePositionsHash.clear();\n gamePositionsHash.put(zobristKey.getKey(), 1);\n }", "public void initGame() {\n for (int row = 0; row < ROWS; ++row) {\n for (int columns = 0; columns < COLUMNS; ++columns) {\n board[row][columns] = Seed.EMPTY; // all cells empty\n }\n }\n currentState = GameState.PLAYING; // ready to play\n currentPlayer = Seed.CROSS; // cross starts first\n }", "private void initialiseBoard() {\r\n\t\t//Set all squares to EMPTY\r\n\t\tfor(int x = 0; x < board.getWidth(); x++) {\r\n\t\t\tfor(int y = 0; y < board.getHeight(); y++) {\r\n\t\t\t\tboard.setSquare(new GridSquare(GridSquare.Type.EMPTY), x, y);\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\t//Assign player tiles\r\n\t\tsetFixedTile(new PlayerTile(GridSquare.Type.PLAYER_ONE_TILE), Board.PLAYER_ONE_POSITION_X, Board.PLAYER_ONE_POSITION_Y);\r\n\t\tsetFixedTile(new PlayerTile(GridSquare.Type.PLAYER_TWO_TILE), Board.PLAYER_TWO_POSITION_X, Board.PLAYER_TWO_POSITION_Y);\r\n\t\t\r\n\t\t//Assign Creation tiles\r\n\t\tsetFixedTile(new CreationTile(GridSquare.Type.CREATION_TILE), Board.PLAYER_ONE_POSITION_X+3, Board.PLAYER_ONE_POSITION_Y+3);\r\n\t\tsetFixedTile(new CreationTile(GridSquare.Type.CREATION_TILE), Board.PLAYER_TWO_POSITION_X-3, Board.PLAYER_TWO_POSITION_Y-3);\r\n\t\t\r\n\t\t//Assign Out of Bounds tiles\r\n\t\tsetFixedTile(new OutOfBoundsTile(GridSquare.Type.OUT_OF_BOUNDS), Board.PLAYER_ONE_POSITION_X-3, Board.PLAYER_ONE_POSITION_Y);\r\n\t\tsetFixedTile(new OutOfBoundsTile(GridSquare.Type.OUT_OF_BOUNDS), Board.PLAYER_ONE_POSITION_X, Board.PLAYER_ONE_POSITION_Y-3);\r\n\t\tsetFixedTile(new OutOfBoundsTile(GridSquare.Type.OUT_OF_BOUNDS), Board.PLAYER_ONE_POSITION_X-3, Board.PLAYER_ONE_POSITION_Y-3);\r\n\t\t\r\n\t\tsetFixedTile(new OutOfBoundsTile(GridSquare.Type.OUT_OF_BOUNDS), Board.PLAYER_TWO_POSITION_X+3, Board.PLAYER_TWO_POSITION_Y);\r\n\t\tsetFixedTile(new OutOfBoundsTile(GridSquare.Type.OUT_OF_BOUNDS), Board.PLAYER_TWO_POSITION_X, Board.PLAYER_TWO_POSITION_Y+3);\r\n\t\tsetFixedTile(new OutOfBoundsTile(GridSquare.Type.OUT_OF_BOUNDS), Board.PLAYER_TWO_POSITION_X+3, Board.PLAYER_TWO_POSITION_Y+3);\r\n\t\t\r\n\t\t\r\n\t}", "@Override\n public int init(int n, int p) {\n if (p != BLUE && p != RED) {\n return INVALID;\n }\n\n this.player = p;\n this.boardDimension = n;\n this.board = new Board(this.boardDimension);\n\n return 0;\n }", "public Grid generateGrid(){\n myGrid = new RectGrid();\n myStates = new HashMap<>();\n\n for(int row = 0; row < imageHeight; row++){\n for(int column = 0; column < imageWidth; column++){\n int color = myImage.getRGB(column, row);\n int blue = color & 0xff;\n int green = (color & 0xff00) >> 8;\n int red = (color & 0xff0000) >> 16;\n\n int stateValue = color*-1;\n System.out.println(stateValue);\n //int stateValue = Integer.parseInt(hex, 16);\n //System.out.println(stateValue);\n\n Cell myCell = new RPSCell();\n myCell.setState(stateValue);\n myGrid.placeCell(row, column, myCell);\n\n Color myColor = Color.rgb(red, green, blue);\n myStates.put(stateValue, myColor);\n }\n }\n return myGrid;\n }", "public ChessRook(\r\n final int initX, final int initY,\r\n final Color color, final ChessStandardBoard board) {\r\n super(initX, initY, color, board);\r\n this.setNameOfPiece(\"rook\");\r\n }", "private void initializeVariables() {\n rnd = new Random();\n\n pieceKind = rnd.nextInt() % 7;\n if(pieceKind < 0) pieceKind *= -1;\n pieceKind2 = rnd.nextInt() % 7;\n if(pieceKind2 < 0) pieceKind2 *= -1;\n\n piece = new Piece(pieceKind,this);\n newPiece();\n startedGame = true;\n\n for(i=0; i<276; i++) {\n modulo = i%12;\n if(modulo == 0 || modulo == 11 || i>251) {\n matrix[i] = 0; colMatrix[i] = true;\n } else {\n matrix[i] = -1; colMatrix[i] = false;\n }\n }\n\n for(i=0; i<5; i++) completeLines[i] = -1;\n for(i=0; i<4; i++) keybl.setMovTable(i, false);\n }", "Board() {\n this(INITIAL_PIECES, BLACK);\n _countBlack = 12;\n _countWhite = 12;\n _moveHistory = new ArrayList<Move>();\n _movesMade = 0;\n }", "public Board() {\n\t\tthis.table = new int[Constants.SIZE][Constants.SIZE];\n\t\tthis.P1Movable = new boolean[Constants.SIZE][Constants.SIZE];\n\t\tthis.P2Movable = new boolean[Constants.SIZE][Constants.SIZE];\n\t\tP1turn = true;\n\t\tnumPieces = 0;\n\t\t\n\t\tfor(int i=0; i<table.length; i++) {\n\t\t\tfor(int j=0; j<table[i].length; j++) {\n\t\t\t\ttable[i][j] = Constants.EMPTY;\n\t\t\t\tP1Movable[i][j] = true;\n\t\t\t\tP2Movable[i][j] = true;\n\t\t\t}\n\t\t}\n\t\t\n\t}", "public void initialize_it(){\n\t\treadScoreFromFile();\n\t\twell = new Color[14][25];\n\t\tfor(int i = 0; i < well.length; i++){\n\t\t\tfor(int j = 0; j < well[0].length; j++){\n\t\t\t\tif(i == 0 || i == well.length-1 || j == well[0].length - 1)\n\t\t\t\t\twell[i][j] = Color.GRAY;\n\t\t\t\telse\n\t\t\t\t\twell[i][j] = Color.WHITE;\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0; i < next_pieces_array.length; i++){\n\t\t\tfor(int j = 0; j<next_pieces_array[0].length; j++){\n\t\t\t\t\tnext_pieces_array[i][j] = Color.WHITE;\n\t\t\t}\n\t\t}\n\t\tscore = 0;\n\t\tgetNewPiece();\n\t\tsetNewPiece();\n\t\tgetNewPiece();\n\t}", "public GameState() {\n positionToPieceMap = new HashMap<Position, Piece>();\n }", "public Pawn(boolean c, Square p, Chess chess) {\n\t\tsuper(c, p, chess);\n\t}", "public void startGameState(){\n\n ArrayList<Integer> checkeredSpaces = new ArrayList<Integer>(Arrays.asList(1, 3, 5, 7, 8, 10, 12, 14, 17, 19, 21,\n 23, 24, 26, 28, 30, 33, 35, 37, 39, 41, 42, 44, 46, 48,\n 51, 53, 55, 56, 58, 60, 62));\n\n\n\n for(int i =0; i < 63; i++){\n if(!checkeredSpaces.contains(i)){\n //set all black spaces to null on the board\n mCheckerBoard.add(null);\n }\n else if(i < 24){\n //set first three rows to red checkers\n mCheckerBoard.add(new Checker((i/2), true));\n }\n else if(i < 40){\n //set middle two rows to null\n mCheckerBoard.add(null);\n }\n else{\n //set top three row to black checkers\n mCheckerBoard.add(new Checker((i/2), false));\n }\n }\n\n }", "public Board() {\n this.board = new Piece[16];\n }", "private void displayBoard() {\r\n\r\n for (int r = 0; r < 8; r++) {\r\n for (int c = 0; c < 8; c++) {\r\n if (model.pieceAt(r, c) == null)\r\n board[r][c].setIcon(null);\r\n else if (model.pieceAt(r, c).player() == Player.WHITE) {\r\n if (model.pieceAt(r, c).type().equals(\"Pawn\"))\r\n board[r][c].setIcon(wPawn);\r\n\r\n if (model.pieceAt(r, c).type().equals(\"Rook\"))\r\n board[r][c].setIcon(wRook);\r\n\r\n if (model.pieceAt(r, c).type().equals(\"Knight\"))\r\n board[r][c].setIcon(wKnight);\r\n\r\n if (model.pieceAt(r, c).type().equals(\"Bishop\"))\r\n board[r][c].setIcon(wBishop);\r\n\r\n if (model.pieceAt(r, c).type().equals(\"Queen\"))\r\n board[r][c].setIcon(wQueen);\r\n\r\n if (model.pieceAt(r, c).type().equals(\"King\"))\r\n board[r][c].setIcon(wKing);\r\n } else if (model.pieceAt(r, c).player() == Player.BLACK) {\r\n if (model.pieceAt(r, c).type().equals(\"Pawn\"))\r\n board[r][c].setIcon(bPawn);\r\n\r\n if (model.pieceAt(r, c).type().equals(\"Rook\"))\r\n board[r][c].setIcon(bRook);\r\n\r\n if (model.pieceAt(r, c).type().equals(\"Knight\"))\r\n board[r][c].setIcon(bKnight);\r\n\r\n if (model.pieceAt(r, c).type().equals(\"Bishop\"))\r\n board[r][c].setIcon(bBishop);\r\n\r\n if (model.pieceAt(r, c).type().equals(\"Queen\"))\r\n board[r][c].setIcon(bQueen);\r\n\r\n if (model.pieceAt(r, c).type().equals(\"King\"))\r\n board[r][c].setIcon(bKing);\r\n }\r\n repaint();\r\n }\r\n }\r\n if (model.inCheck(Player.WHITE))\r\n JOptionPane.showMessageDialog(null, \"White King in Check\");\r\n if (model.inCheck(Player.BLACK))\r\n JOptionPane.showMessageDialog(null, \"Black King in Check\");\r\n if (model.movingIntoCheck())\r\n JOptionPane.showMessageDialog(null, \"Cannot move into check\");\r\n if (model.isComplete())\r\n JOptionPane.showMessageDialog(null, \"Checkmate\");\r\n }", "public void initBasicBoardTiles() {\n\t\ttry {\n\t\t\tfor(int i = 1 ; i <= BOARD_SIZE ; i+=2) {\n\t\t\t\tfor(char c = getColumnLowerBound() ; c <= getColumnUpperBound() ; c+=2) {\n\n\t\t\t\t\taddTile(new Tile.Builder(new Location(i, c), PrimaryColor.BLACK).build());\n\t\t\t\t\taddTile(new Tile.Builder(new Location(i, (char) ( c + 1)), PrimaryColor.WHITE).build());\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor(int i = 2 ; i <= BOARD_SIZE ; i+=2) {\n\t\t\t\tfor(char c = getColumnLowerBound() ; c <= getColumnUpperBound() ; c+=2) {\n\n\t\t\t\t\taddTile(new Tile.Builder(new Location(i, c), PrimaryColor.WHITE).build());\n\t\t\t\t\taddTile(new Tile.Builder(new Location(i, (char) ( c + 1)), PrimaryColor.BLACK).build());\n\t\t\t\t}\n\t\t\t}\n\t\t}catch(LocationException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}", "public Board(){\n for(int holeIndex = 0; holeIndex<holes.length; holeIndex++)\n holes[holeIndex] = new Hole(holeIndex);\n for(int kazanIndex = 0; kazanIndex<kazans.length; kazanIndex++)\n kazans[kazanIndex] = new Kazan(kazanIndex);\n nextToPlay = Side.WHITE;\n }", "public ChessBoard(Knight knight) {\n BOARD_SIZE = 8;\n playingBoard = new Square[BOARD_SIZE][BOARD_SIZE];\n currentKnight = knight;\n\n createSquares();\n createHeuristics();\n }", "private GamePiece[][] initBoard(int rows, int cols, Random rand) {\n gameBoard = new GamePiece[rows][cols];\n curPlayerRow = 0;\n curPlayerCol = 0;\n for(int i = 0; i < rows; i++){\n for(int j = 0; j < cols; j++){\n gameBoard[i][j] = new EmptyPiece();\n }\n }\n gameBoard[0][0] = new PlayerPiece(INIT_PLAYER_POINTS);\n curTrollRow = getRandTrollRow(rand, rows);\n curTrollCol = getRandTrollCol(rand, cols);\n while(curTrollRow == 7 && curTrollCol == 9){\n curTrollRow = getRandTrollRow(rand, rows);\n curTrollCol = getRandTrollCol(rand, cols);\n }\n gameBoard[curTrollRow][curTrollCol] = new TrollPiece();\n gameBoard[7][9] = new TreasurePiece(TREASURE_POINTS);\n return gameBoard;\n }", "private void initBoard() {\n initCommands();\n setBackground(Color.BLACK);\n setPreferredSize(new Dimension((int) (W * Application.scale), (int) (H * Application.scale)));\n\n commandClasses.forEach((cmdstr) -> {\n try {\n Object obj = Class.forName(cmdstr).getDeclaredConstructor().newInstance();\n Command cmd = (Command) obj;\n connectCommand(cmd);\n System.out.println(\"Loaded \" + cmdstr);\n } catch (Exception e) {\n e.printStackTrace();\n }\n\n });\n\n Particle.heatmap.addColor(0, Color.GREEN);\n Particle.heatmap.addColor(50, Color.YELLOW);\n Particle.heatmap.addColor(100, Color.RED);\n\n Particle.slopemap.addColor(-5, Color.RED);\n Particle.slopemap.addColor(0, Color.WHITE);\n Particle.slopemap.addColor(5, Color.GREEN);\n\n setFocusable(true);\n }", "public static void initialBoard() {\n\t\tSystem.out.println(\"Welcome to TicTacToe ♡\");\n\t\tfor (int i = 0; i < 9; i++) {\n\t\t\tfor (int j = 0; j < 9; j++) {\n\t\t\t\tboard[i][j] = '-';\n\t\t\t}\n\t\t}\n\t}", "public void initialize(){ \r\n\t\tfor (int i=0; i<3; i++){ \r\n\t\t\tfor (int j=0; j<3; j++){\r\n\t\t\t\tboard [i][j] = '-';\r\n\t\t\t}\r\n\t\t}\r\n\t}", "public static void createBoard() {\n Checkers[] CheckerBoard = new Checkers[24];\n CheckerBoard[0] = new Checkers(0,1,\"black\");\n CheckerBoard[1] = new Checkers(0,3,\"black\");\n CheckerBoard[2] = new Checkers(0,5,\"black\");\n CheckerBoard[3] = new Checkers(0,7,\"black\");\n CheckerBoard[4] = new Checkers(1,0,\"black\");\n CheckerBoard[5] = new Checkers(1,2,\"black\");\n CheckerBoard[6] = new Checkers(1,4,\"black\");\n CheckerBoard[7] = new Checkers(1,6,\"black\");\n CheckerBoard[8] = new Checkers(2,1,\"black\");\n CheckerBoard[9] = new Checkers(2,3,\"black\");\n CheckerBoard[10] = new Checkers(2,5,\"black\");\n CheckerBoard[11] = new Checkers(2,7,\"black\");\n CheckerBoard[12] = new Checkers(5,1,\"red\");\n CheckerBoard[13] = new Checkers(5,3,\"red\");\n CheckerBoard[14] = new Checkers(5,5,\"red\");\n CheckerBoard[15] = new Checkers(5,7,\"red\");\n CheckerBoard[16] = new Checkers(6,0,\"red\");\n CheckerBoard[17] = new Checkers(6,2,\"red\");\n CheckerBoard[18] = new Checkers(6,4,\"red\");\n CheckerBoard[19] = new Checkers(6,6,\"red\");\n CheckerBoard[20] = new Checkers(7,1,\"red\");\n CheckerBoard[21] = new Checkers(7,3,\"red\");\n CheckerBoard[22] = new Checkers(7,5,\"red\");\n CheckerBoard[23] = new Checkers(7,7,\"red\");\n\n\n\n }", "private Board(Piece[][] initialContents, Side player) {\n assert player != null && initialContents.length == 8;\n Piece p;\n for (int i = 0; i < 8; i++) {\n for(int j = 0; j < 8; j++) {\n p = initialContents[i][j];\n if (p.side() != null) {\n if (p.side() == BLACK) {\n _countBlack += 1;\n } else {\n _countWhite += 1;\n }\n addPiece(j + 1, i + 1);\n }\n _pieces[i][j] = p\n }\n }\n _turn = player;\n }", "public void initializeBoard() {\n\t\tfor (int i = 0; i < 9; i++) {\n\t\t\tthis.board[i] = \"-\";\n\n\t\t}\n\n\t}", "void setColor(char c, char t) {\n\t\tif(c == 'b' && t == 'b') pI = PieceImage.B_BISHOP;\n\t\tif(c == 'b' && t == 'k') pI = PieceImage.B_KING;\n\t\tif(c == 'b' && t == 'c') pI = PieceImage.B_KNIGHT;\n\t\tif(c == 'b' && t == 'p') pI = PieceImage.B_PAWN;\n\t\tif(c == 'b' && t == 'q') pI = PieceImage.B_QUEEN;\n\t\tif(c == 'b' && t == 'r') pI = PieceImage.B_ROOK;\n\t\t\n\t\tif(c == 'w' && t == 'b') pI = PieceImage.W_BISHOP;\n\t\tif(c == 'w' && t == 'k') pI = PieceImage.W_KING;\n\t\tif(c == 'w' && t == 'c') pI = PieceImage.W_KNIGHT;\n\t\tif(c == 'w' && t == 'p') pI = PieceImage.W_PAWN;\n\t\tif(c == 'w' && t == 'q') pI = PieceImage.W_QUEEN;\n\t\tif(c == 'w' && t == 'r') pI = PieceImage.W_ROOK;\n\t\n\t\tif(c == 'c' && t == 'b') pI = PieceImage.C_BISHOP;\n\t\tif(c == 'c' && t == 'k') pI = PieceImage.C_KING;\n\t\tif(c == 'c' && t == 'c') pI = PieceImage.C_KNIGHT;\n\t\tif(c == 'c' && t == 'p') pI = PieceImage.C_PAWN;\n\t\tif(c == 'c' && t == 'q') pI = PieceImage.C_QUEEN;\n\t\tif(c == 'c' && t == 'r') pI = PieceImage.C_ROOK;\n\t\t\n\t\tif(c == 'p' && t == 'b') pI = PieceImage.P_BISHOP;\n\t\tif(c == 'p' && t == 'k') pI = PieceImage.P_KING;\n\t\tif(c == 'p' && t == 'c') pI = PieceImage.P_KNIGHT;\n\t\tif(c == 'p' && t == 'p') pI = PieceImage.P_PAWN;\n\t\tif(c == 'p' && t == 'q') pI = PieceImage.P_QUEEN;\n\t\tif(c == 'p' && t == 'r') pI = PieceImage.P_ROOK;\n\t\t}", "public void paintComponent(Graphics g)\r\n {\r\n super.paintComponent(g);\r\n g2 = (Graphics2D) g;\r\n this.setBackground(Color.black);\r\n\r\n this.addMouseListener(this);\r\n this.addMouseMotionListener(this);\r\n Image chPieces;\r\n chPieces = new ImageIcon(\"C:/Users/eolochr/Desktop/backup/own/code/Ch/ChessPieces.png\").getImage();\r\n for (int x = 0; x < 8; x++)\r\n {\r\n for (int y = 0; y < 8; y++)\r\n {\r\n if ((x % 2 == 0 && y % 2 == 0) || (x % 2 == 1 && y % 2 == 1))\r\n {\r\n g.setColor(Color.white);\r\n }\r\n else if ((x % 2 == 0 && y % 2 == 1) || (x % 2 == 1 && y % 2 == 0))\r\n {\r\n g.setColor(Color.gray);\r\n }\r\n else\r\n {}\r\n g.fillRect(sizeOfSquare * x, sizeOfSquare * y, sizeOfSquare, sizeOfSquare);\r\n\r\n g.drawString(y + \"\", 420, 24 + (sizeOfSquare * y));\r\n g.drawString(x + \"\", 24 + (sizeOfSquare * x), 420);\r\n }\r\n\r\n }\r\n\r\n for (int i = 0; i < 64; i++) //taken, not my logic\r\n {\r\n int j = -1, k = -1;\r\n switch (Movements.chessBoard[i / 8][i % 8])\r\n {\r\n\r\n case \"R\":\r\n j = 2;\r\n k = 0;\r\n break;\r\n case \"P\":\r\n j = 5;\r\n k = 0;\r\n break;\r\n case \"K\":\r\n j = 4;\r\n k = 0;\r\n break;\r\n case \"B\":\r\n j = 3;\r\n k = 0;\r\n break;\r\n case \"Q\":\r\n j = 1;\r\n k = 0;\r\n break;\r\n case \"A\":\r\n j = 0;\r\n k = 0;\r\n break;\r\n\r\n case \"p\":\r\n j = 5;\r\n k = 1;\r\n break;\r\n case \"r\":\r\n j = 2;\r\n k = 1;\r\n break;\r\n case \"k\":\r\n j = 4;\r\n k = 1;\r\n break;\r\n case \"b\":\r\n j = 3;\r\n k = 1;\r\n break;\r\n case \"q\":\r\n j = 1;\r\n k = 1;\r\n break;\r\n case \"a\":\r\n j = 0;\r\n k = 1;\r\n break;\r\n\r\n }\r\n if (j != -1 && k != -1)\r\n {\r\n g.drawImage(chPieces, (i % 8) * sizeOfSquare, (i / 8) * sizeOfSquare, (i % 8 + 1) * sizeOfSquare, (i / 8 + 1) * sizeOfSquare, j * 64, k * 64, (j + 1) * 64,\r\n (k + 1) * 64, this);\r\n }\r\n }\r\n g.setColor(Color.GREEN);\r\n\r\n if (Movements.turnC)\r\n {\r\n g.drawString(\"White turn\", 150, 440);\r\n }\r\n else\r\n {\r\n g.drawString(\"Black turn\", 150, 440);\r\n }\r\n\r\n if(movement.length() > 3)\r\n {\r\n g.drawString(\"Selected square: \" + movement.charAt(0) + movement.charAt(1), 120, 460);\r\n }\r\n\r\n\r\n if (Movements.checkC)\r\n {\r\n g.drawString(\"Check white\", 240, 440);\r\n }\r\n else if (Movements.checkL)\r\n {\r\n g.drawString(\"Check black\", 240, 440);\r\n }\r\n\r\n }", "private final void setupNewGame() throws IOException {\n\t\tmessage.setText(\"Make your move!\");\n\n\t\twhiteTeam = PokemonDao.getRandomPokemons(TEAM_SIZE);\n\t\tblackTeam = PokemonDao.getRandomPokemons(TEAM_SIZE);\n\n\t\tcreateImages();\n\n\t\tint middleSquare = BOARD_SIZE/2;\n\n\t\tint i=0;\n\t\tfor(int col = middleSquare - whiteTeam.size()/2; col< middleSquare+ whiteTeam.size()/2;col++){\n\t\t\tJButton jButton = chessBoardSquares[col][0];\n\t\t\tImageIcon icon = new ImageIcon(whiteImages.get(i++));\n\t\t\tjButton.setIcon(icon);\n\t\t}\n\n\t\tint j=0;\n\t\tfor(int col = middleSquare - whiteTeam.size()/2; col< middleSquare+ whiteTeam.size()/2;col++){\n\t\t\tJButton jButton = chessBoardSquares[col][BOARD_SIZE-1];\n\t\t\tImageIcon icon = new ImageIcon(blackImages.get(j++));\n\t\t\tjButton.setIcon(icon);\n\t\t}\n\n\t\tframe.pack();\n\t\t//\t\tfor (int ii = 0; ii < BOARD_SIZE; ii++) {\n\t\t//\t\t\tfor (int jj = 0; jj < BOARD_SIZE; jj++) {\n\t\t//\t\t\t\tchessBoardSquares[ii][jj].setIcon(new ImageIcon(whiteImages.get(0)));\n\t\t//\t\t\t}\n\t\t//\t\t}\n\t\t//\t\t// set up the black pieces\n\t\t//\t\tfor (int ii = 0; ii < STARTING_ROW.length; ii++) {\n\t\t//\t\t\tchessBoardSquares[ii][0].setIcon(new ImageIcon(chessPieceImages[BLACK][STARTING_ROW[ii]]));\n\t\t//\t\t}\n\t\t//\t\tfor (int ii = 0; ii < STARTING_ROW.length; ii++) {\n\t\t//\t\t\tchessBoardSquares[ii][1].setIcon(new ImageIcon(chessPieceImages[BLACK][PAWN]));\n\t\t//\t\t}\n\t\t//\t\t// set up the white pieces\n\t\t//\t\tfor (int ii = 0; ii < STARTING_ROW.length; ii++) {\n\t\t//\t\t\tchessBoardSquares[ii][6].setIcon(new ImageIcon(chessPieceImages[WHITE][PAWN]));\n\t\t//\t\t}\n\t\t//\t\tfor (int ii = 0; ii < STARTING_ROW.length; ii++) {\n\t\t//\t\t\tchessBoardSquares[ii][7].setIcon(new ImageIcon(chessPieceImages[WHITE][STARTING_ROW[ii]]));\n\t\t//\t\t}\n\t}", "public static void makePieces() {\n\t\tPiece[] pieces = new Piece[35];\n\t\tfor (int i = 0; i < pieces.length; i++) {\n\t\t\tTile t = new Tile(false, true, 0, 0);\n\t\t\tTile f = new Tile(false, false, 0, 0);\n\t\t\tTile[][] tiles = new Tile[6][6];\n\t\t\tswitch (i) {\n\t\t\tcase 0:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, t, t, f, f }, { f, f, t, f, f, f },\n\t\t\t\t\t\t{ f, f, t, f, f, f }, { f, f, t, t, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, t, t, f, f }, { f, f, t, f, f, f },\n\t\t\t\t\t\t{ f, f, t, t, f, f }, { f, f, t, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, t, t, f, f }, { f, f, t, t, f, f },\n\t\t\t\t\t\t{ f, f, f, t, f, f }, { f, f, f, t, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, t, f, f }, { f, f, t, t, f, f }, { f, f, t, f, f, f },\n\t\t\t\t\t\t{ f, f, t, f, f, f }, { f, f, t, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 4:\n\t\t\t\ttiles = new Tile[][] { { f, f, t, f, f, f }, { f, f, t, f, f, f }, { f, f, t, t, f, f },\n\t\t\t\t\t\t{ f, f, t, f, f, f }, { f, f, t, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 5:\n\t\t\t\ttiles = new Tile[][] { { f, f, t, f, f, f }, { f, f, t, t, f, f }, { f, f, t, f, f, f },\n\t\t\t\t\t\t{ f, f, t, f, f, f }, { f, f, t, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 6:\n\t\t\t\ttiles = new Tile[][] { { f, f, t, t, f, f }, { f, f, t, f, f, f }, { f, f, t, f, f, f },\n\t\t\t\t\t\t{ f, f, t, f, f, f }, { f, f, t, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 7:\n\t\t\t\ttiles = new Tile[][] { { f, f, t, f, f, f }, { f, f, t, f, f, f }, { f, f, t, f, f, f },\n\t\t\t\t\t\t{ f, f, t, f, f, f }, { f, f, t, f, f, f }, { f, f, t, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 8:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, t, f, f, f, f }, { f, t, t, f, f, f },\n\t\t\t\t\t\t{ f, t, t, t, f, f }, { f, f, f, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 9:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, f, t, f, f }, { f, t, t, t, f, f },\n\t\t\t\t\t\t{ f, t, t, f, f, f }, { f, f, f, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 10:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, t, f, f, f }, { f, f, t, t, f, f },\n\t\t\t\t\t\t{ f, f, t, t, f, f }, { f, f, t, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 11:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, t, t, t, f, f }, { f, t, f, f, f, f },\n\t\t\t\t\t\t{ f, t, f, f, f, f }, { f, t, f, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 12:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, t, f, f, f, f }, { f, t, t, t, f, f },\n\t\t\t\t\t\t{ f, t, f, f, f, f }, { f, t, f, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 13:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, t, t, t, f, f }, { f, f, t, f, f, f },\n\t\t\t\t\t\t{ f, f, t, f, f, f }, { f, f, t, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 14:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, t, t, f, f }, { f, t, t, f, f, f },\n\t\t\t\t\t\t{ f, f, t, f, f, f }, { f, f, t, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 15:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, t, t, f, f }, { f, f, t, f, f, f },\n\t\t\t\t\t\t{ f, t, t, f, f, f }, { f, f, t, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 16:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, t, t, f, f }, { f, f, t, f, f, f },\n\t\t\t\t\t\t{ f, f, t, f, f, f }, { f, t, t, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 17:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, t, f, f, f }, { f, f, t, t, f, f },\n\t\t\t\t\t\t{ f, t, t, f, f, f }, { f, f, t, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 18:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, t, f, t, f, f }, { f, t, t, t, f, f },\n\t\t\t\t\t\t{ f, t, f, f, f, f }, { f, f, f, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 19:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, t, t, t, f, f }, { f, f, t, t, f, f },\n\t\t\t\t\t\t{ f, f, t, f, f, f }, { f, f, f, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 20:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, t, f, t, f, f }, { f, t, t, t, f, f },\n\t\t\t\t\t\t{ f, f, t, f, f, f }, { f, f, f, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 21:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, t, f, f, f }, { f, t, t, t, f, f },\n\t\t\t\t\t\t{ f, t, t, f, f, f }, { f, f, f, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 22:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, t, f, f, f }, { f, t, t, t, f, f },\n\t\t\t\t\t\t{ f, f, t, f, f, f }, { f, f, t, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 23:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, t, f, f, f }, { f, t, t, t, f, f },\n\t\t\t\t\t\t{ f, t, f, f, f, f }, { f, t, f, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 24:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, t, f, f }, { f, f, f, t, f, f }, { f, f, t, t, f, f },\n\t\t\t\t\t\t{ f, f, t, f, f, f }, { f, f, t, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 25:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, f, t, f, f }, { f, f, t, t, f, f },\n\t\t\t\t\t\t{ f, f, t, f, f, f }, { f, f, t, t, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 26:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, f, t, f, f }, { f, f, t, t, f, f },\n\t\t\t\t\t\t{ f, f, t, t, f, f }, { f, f, t, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 27:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, t, t, f, f }, { f, f, t, t, f, f },\n\t\t\t\t\t\t{ f, f, t, t, f, f }, { f, f, f, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 28:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, f, t, f, f }, { f, t, t, t, f, f },\n\t\t\t\t\t\t{ f, f, t, f, f, f }, { f, f, t, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 29:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, f, t, f, f }, { f, f, t, t, f, f },\n\t\t\t\t\t\t{ f, t, t, f, f, f }, { f, f, t, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 30:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, f, t, f, f }, { f, t, t, t, f, f },\n\t\t\t\t\t\t{ f, t, f, f, f, f }, { f, t, f, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 31:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, t, t, t, f, f }, { f, t, f, t, f, f },\n\t\t\t\t\t\t{ f, t, f, f, f, f }, { f, f, f, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 32:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, f, t, f, f }, { f, f, t, t, f, f },\n\t\t\t\t\t\t{ f, t, t, f, f, f }, { f, t, f, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 33:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, t, t, f, f }, { f, t, t, f, f, f },\n\t\t\t\t\t\t{ f, t, f, f, f, f }, { f, t, f, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\tcase 34:\n\t\t\t\ttiles = new Tile[][] { { f, f, f, f, f, f }, { f, f, t, t, f, f }, { f, f, t, f, f, f },\n\t\t\t\t\t\t{ f, t, t, f, f, f }, { f, t, f, f, f, f }, { f, f, f, f, f, f } };\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tpieces[i] = new Piece(tiles);\n\t\t}\n\t\ttry {\n\t\t\tFileOutputStream saveFile = new FileOutputStream(\"pieces.data\");\n\t\t\tObjectOutputStream save = new ObjectOutputStream(saveFile);\n\t\t\tsave.reset();\n\t\t\tsave.writeObject(pieces);\n\t\t\tsave.close();\n\t\t} catch (Exception exc) {\n\t\t\texc.printStackTrace(); // If there was an error, print the info.\n\t\t}\n\t}", "public void reset() {\n // White Pieces\n placePiece(new Rook(Player.White), new Position(\"a1\"));\n placePiece(new Knight(Player.White), new Position(\"b1\"));\n placePiece(new Bishop(Player.White), new Position(\"c1\"));\n placePiece(new Queen(Player.White), new Position(\"d1\"));\n placePiece(new King(Player.White), new Position(\"e1\"));\n placePiece(new Bishop(Player.White), new Position(\"f1\"));\n placePiece(new Knight(Player.White), new Position(\"g1\"));\n placePiece(new Rook(Player.White), new Position(\"h1\"));\n placePiece(new Pawn(Player.White), new Position(\"a2\"));\n placePiece(new Pawn(Player.White), new Position(\"b2\"));\n placePiece(new Pawn(Player.White), new Position(\"c2\"));\n placePiece(new Pawn(Player.White), new Position(\"d2\"));\n placePiece(new Pawn(Player.White), new Position(\"e2\"));\n placePiece(new Pawn(Player.White), new Position(\"f2\"));\n placePiece(new Pawn(Player.White), new Position(\"g2\"));\n placePiece(new Pawn(Player.White), new Position(\"h2\"));\n\n // Black Pieces\n placePiece(new Rook(Player.Black), new Position(\"a8\"));\n placePiece(new Knight(Player.Black), new Position(\"b8\"));\n placePiece(new Bishop(Player.Black), new Position(\"c8\"));\n placePiece(new Queen(Player.Black), new Position(\"d8\"));\n placePiece(new King(Player.Black), new Position(\"e8\"));\n placePiece(new Bishop(Player.Black), new Position(\"f8\"));\n placePiece(new Knight(Player.Black), new Position(\"g8\"));\n placePiece(new Rook(Player.Black), new Position(\"h8\"));\n placePiece(new Pawn(Player.Black), new Position(\"a7\"));\n placePiece(new Pawn(Player.Black), new Position(\"b7\"));\n placePiece(new Pawn(Player.Black), new Position(\"c7\"));\n placePiece(new Pawn(Player.Black), new Position(\"d7\"));\n placePiece(new Pawn(Player.Black), new Position(\"e7\"));\n placePiece(new Pawn(Player.Black), new Position(\"f7\"));\n placePiece(new Pawn(Player.Black), new Position(\"g7\"));\n placePiece(new Pawn(Player.Black), new Position(\"h7\"));\n }", "private void setupChessBoard() {\n add(announcementBtn).expandX().width(ChessGame.MENU_WIDTH);\n row();\n add(currentGamesBtn).expandX().width(ChessGame.MENU_WIDTH);\n row();\n add(chatRoomBtn).expandX().width(ChessGame.MENU_WIDTH);\n row();\n add(friendsListBtn).expandX().width(ChessGame.MENU_WIDTH);\n row();\n add(leaderboardBtn).expandX().width(ChessGame.MENU_WIDTH);\n row();\n add(settingsBtn).expandX().width(ChessGame.MENU_WIDTH);\n row();\n }", "Board (boolean[][] board, List<Piece> pieces) {\n\n this.board = board;\n unusedPieces = new ArrayList<>(pieces);\n List<Piece> possiblePieces = new ArrayList<>(pieces);\n tessellate(possiblePieces.get(0));\n }", "public void Makeboard() {\r\n\r\n Normalboard(new Point2(20, 300));\r\n Normalboard(new Point2(224, 391));\r\n Stingboard(new Point2(156, 209));\r\n Leftlboard(new Point2(88, 482));\r\n Rightboard(new Point2(292, 573));\r\n Regenerateboard(new Point2(360, 118));\r\n\r\n }", "void initializeGame() {\n // Initialize players\n // Put the pieces on the board\n }", "@Override\n public void startGame() {\n //create new board instance\n board = new int[NUM_ROWS][NUM_COLS];\n //set all elements to EMPTY\n for (int c = 0; c < NUM_COLS; c++) {\n for (int r = 0; r < NUM_ROWS; r++) {\n board[r][c] = EMPTY;\n }\n }\n //set the turn to red\n turn = RED;\n }", "public static void createBoard() \n\t{\n\t\tfor (int i = 0; i < tictactoeBoard.length; i++) \n\t\t{\n\t\t\ttictactoeBoard[i] = '-';\n\t\t}\n\t}", "public Board(int gridSize) throws Exception {\n\t\tthis.gridSize = gridSize;\n\t\tint currentPiece;\n\t\tint i, j;\n\n\t\t// initialize the pieces\n\t\tpiecePlacement = new Piece[NUM_PIECES];\n\t\tfor(i=0; i<piecePlacement.length; i++)\n\t\t\tpiecePlacement[i] = null;\n\n\t\tcurrentPiece = 0;\n\n\t\t// create all of the black pieces\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\tfor (j = 0; j < this.gridSize; j++) {\n\t\t\t\tif ((i + j) % 2 == 1) {\n\t\t\t\t\t// NOTE: i == y and j == x\n\t\t\t\t\tPiece piece = new Piece(new Position(j, i), false, Piece.WHITE);\n\t\t\t\t\tpiecePlacement[currentPiece++] = piece;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// create all of the white pieces\n\t\tfor (i = gridSize - 1; i > this.gridSize - 4; i--) {\n\t\t\tfor (j = 0; j < gridSize; j++) {\n\t\t\t\tif ((i + j) % 2 == 1) {\n\t\t\t\t\t// NOTE: i == y and j == x\n\t\t\t\t\tPiece piece = new Piece(new Position(j, i), false, Piece.BLACK);\n\t\t\t\t\tpiecePlacement[currentPiece++] = piece;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "public GamePiece(Color color, int x, int y){\n king = false;\n this.x = x;\n this.y = y;\n this.color = color;\n // Aligns to correct position on centre of the correct tile\n setCenterX(30 + (x * 60));\n setCenterY(30 + (y * 60));\n setRadius(20);\n // Sets the colour of the piece to visually show who it belongs to\n setFill(color);\n }", "public Board() {\n\t\tboardState = new Field[DIMENSION][DIMENSION];\n\t\tfor(int i = 0; i < DIMENSION; i++) {\n\t\t\tfor(int j = 0; j < DIMENSION; j++) {\n\t\t\t\tboardState[i][j] = new Field();\n\t\t\t}\n\t\t}\n\t}", "public static void initialiseGameBoard(){\n\n for ( int row = 0 ; row < 6 ; row++ ){\n for ( int column = 0 ; column < 7 ; column++ ){\n gameBoard[row][column] = \"-\";\n }\n }\n }", "public static Board makeBoard(final Player lightPlayer, final Player darkPlayer, final String FEN) {\n Board board = new Board(lightPlayer, darkPlayer);\n\n Tile[][] matrix = board.getMatrix();\n \n // rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 default ren\n \n /*\n Part 1: read in board state string and generate the pieces based off of their location\n */\n \n int i = 0, j = 0, k = 0;\n boolean boardComplete = false;\n for( ; !boardComplete ; k++){\n switch (FEN.charAt(k)){\n case ' ':\n boardComplete=true; // a _ means we are done with the board data\n break;\n case '/':\n i++; // a / means move to next rank/line\n j=0;\n break;\n case 'r': // ROOKS\n matrix[i][j].setPiece(new Rook(darkPlayer, true));\n j++;\n break;\n case 'R':\n matrix[i][j].setPiece(new Rook(lightPlayer, true));\n j++;\n break;\n case 'n': // KNIGHTS\n matrix[i][j].setPiece(new Knight(darkPlayer));\n j++;\n break;\n case 'N':\n matrix[i][j].setPiece(new Knight(lightPlayer));\n j++;\n break;\n case 'b': // BISHOPS\n matrix[i][j].setPiece(new Bishop(darkPlayer));\n j++;\n break;\n case 'B':\n matrix[i][j].setPiece(new Bishop(lightPlayer));\n j++;\n break;\n case 'q': // QUEENS\n matrix[i][j].setPiece(new Queen(darkPlayer));\n j++;\n break;\n case 'Q':\n matrix[i][j].setPiece(new Queen(lightPlayer));\n j++;\n break;\n case 'k': // KINGS\n matrix[i][j].setPiece(new King(darkPlayer, true));\n darkPlayer.setLocationOfKing(matrix[i][j].getPosition());\n j++;\n break;\n case 'K':\n matrix[i][j].setPiece(new King(lightPlayer, true));\n lightPlayer.setLocationOfKing(matrix[i][j].getPosition());\n j++;\n break;\n case 'p': // PAWNS\n matrix[i][j].setPiece(new Pawn(darkPlayer));\n j++;\n break;\n case 'P':\n matrix[i][j].setPiece(new Pawn(lightPlayer));\n j++;\n break;\n default: // SPACES BETWEEN PIECES\n j+=Character.getNumericValue(FEN.charAt(k));\n \n }\n }\n\n /*\n Part 2: load in character w or b to determine who's turn it is\n */\n \n board.setCurrentPlayer(FEN.charAt(k) == 'w' ? board.getLightPlayer() : board.getDarkPlayer());\n board.setEnemyPlayer(FEN.charAt(k) == 'w' ? board.getDarkPlayer() : board.getLightPlayer());\n \n k += 2; // skips over the turn char and the space after it putting FEN.charAt(k) at the next stage\n \n /*\n Part 3: read in castle availability string and set the boolean flag hasTakenFirstMove for each respective piece\n For rook and king hasTakenFirstMove is default to true. It is only set to false if the correct char's below are present.\n */\n boolean notFinishedCastle = true;\n for ( ; notFinishedCastle; k++) {\n switch (FEN.charAt(k)) {\n case '-':\n notFinishedCastle = false;\n break;\n case ' ':\n notFinishedCastle = false;\n break;\n case 'K':\n board.getMatrix()[board.getLightPlayer().getHomeRow()][Constants.ROOK_COLUMN_KINGSIDE].getPiece().setHasTakenFirstMove(false);\n board.getMatrix()[board.getLightPlayer().getHomeRow()][Constants.KING_COLUMN].getPiece().setHasTakenFirstMove(false);\n break;\n case 'Q':\n board.getMatrix()[board.getLightPlayer().getHomeRow()][Constants.ROOK_COLUMN_QUEENSIDE].getPiece().setHasTakenFirstMove(false);\n board.getMatrix()[board.getLightPlayer().getHomeRow()][Constants.KING_COLUMN].getPiece().setHasTakenFirstMove(false);\n break;\n case 'k':\n board.getMatrix()[board.getDarkPlayer().getHomeRow()][Constants.ROOK_COLUMN_KINGSIDE].getPiece().setHasTakenFirstMove(false);\n board.getMatrix()[board.getDarkPlayer().getHomeRow()][Constants.KING_COLUMN].getPiece().setHasTakenFirstMove(false);\n break;\n case 'q':\n board.getMatrix()[board.getDarkPlayer().getHomeRow()][Constants.ROOK_COLUMN_QUEENSIDE].getPiece().setHasTakenFirstMove(false);\n board.getMatrix()[board.getDarkPlayer().getHomeRow()][Constants.KING_COLUMN].getPiece().setHasTakenFirstMove(false);\n break;\n }\n \n if (k == FEN.length() - 1) {\n notFinishedCastle = false;\n }\n }\n \n return board;\n }", "public Board() {\n initialize(3, null);\n }", "public Board(int[][] grid, Tetrimino piece) {\n //initComponents();\n this.grid = grid;\n this.piece = piece;\n setLayout(new GridLayout(grid.length-4, grid[0].length));\n init();\n }", "public static Board fen(String str) {\n\t\tPiece[][] b = new Piece[8][8];\n\t\tbyte r = 7, c = 0;\n\t\tString[] s = str.split(\" \");\n\t\t\n\t\tfor (int i = 0; i < s[0].length(); i++) {\n\t\t\tif (s[0].charAt(i) == '/') {\n\t\t\t\tr--;\n\t\t\t\tc = -1;\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'P') {\n\t\t\t\tb[r][c] = new Pawn(true, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'N') {\n\t\t\t\tb[r][c] = new Knight(true, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'B') {\n\t\t\t\tb[r][c] = new Bishop(true, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'R') {\n\t\t\t\tb[r][c] = new Rook(true, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'Q') {\n\t\t\t\tb[r][c] = new Queen(true, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'K') {\n\t\t\t\tb[r][c] = new King(true, r, c, s[1].charAt(0)=='1', s[1].charAt(1)=='1');\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'p') {\n\t\t\t\tb[r][c] = new Pawn(false, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'n') {\n\t\t\t\tb[r][c] = new Knight(false, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'b') {\n\t\t\t\tb[r][c] = new Bishop(false, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'r') {\n\t\t\t\tb[r][c] = new Rook(false, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'q') {\n\t\t\t\tb[r][c] = new Queen(false, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'k') {\n\t\t\t\tb[r][c] = new King(false, r, c, s[1].charAt(2)=='1', s[1].charAt(3)=='1');\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\tfor (byte j = 0; j < Byte.parseByte(s[0].charAt(i)+\"\"); j++) {\n\t\t\t\t\tb[r][c+j] = new Null(r, (byte)(c+j));\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tc += Byte.parseByte(s[0].charAt(i)+\"\") - 1;\n\t\t\t}\n\t\t\t\n\t\t\tc++;\n\t\t}\n\t\t\n\t\treturn new Board(b);\n\t}", "private void init() {\r\n\t\tint linePos = this.playBoard.length / 2;\r\n\t\tint columnPos = this.playBoard[0].length / 2;\r\n\t\tfor (int i = 0; i < playBoard.length; i++) {\r\n\t\t\tfor (int j = 0; j < playBoard[0].length; j++) {\r\n\t\t\t\tplayBoard[i][j] = '-';\r\n\t\t\t}\r\n\t\t}\r\n\t\tplayBoard[linePos - 1][columnPos - 1] = 'W';\r\n\t\tplayBoard[linePos - 1][columnPos] = 'B';\r\n\t\tplayBoard[linePos][columnPos] = 'W';\r\n\t\tplayBoard[linePos][columnPos - 1] = 'B';\r\n\t}", "public ChessModel(int r, int c, ArrayList<Integer> s){\n Rows = r;\n Cols = c;\n start = s;\n curBoard = s;\n clearStack();\n }", "protected Board(){\n\t\tpool = 0;\n\t\tsquares = new Square[3][61];\n\t\tcommunityCards = new LinkedList<CommunityCard>();\n\t\tchanceCards = new LinkedList<ChanceCard>();\n\t\tmap = new HashMap<String, Integer>();\n\t\tcompanyArray = new Company[6];\n\t\tcreateBoard();\n\t\tfillHashMap();\t\t\t\n\t\tfillChanceCards();\n\t\tfillCommunityChestCards();\n\t\tfillCompanyArray();\n\t\tshuffleChanceCards();\n\t\tshuffleCommunityCards();\n\t}", "public Board(List<Piece> pieceList)\n\t{\n\t\tCoordinate aux = new Coordinate();\n\t\t\n\t\tfor (int x = 0; x < board_size; x++)\n\t\t{\n\t\t\tfor (int y = 0; y < board_size; y++)\n\t\t\t{\n\t\t\t\taux.set(x, y);\n\t\t\t\tsetPiece(null, aux);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor (Piece piece : pieceList) {setPiece(piece, piece.getCoord());}\n\t}", "public IImage createCheckerboard() {\n List<List<Pixel>> grid = new ArrayList<>();\n for (int i = 0; i < this.height; i++) {\n List<Pixel> row;\n // alternating between making rows starting with black or white tiles\n if (i % 2 == 0) {\n // start white\n for (int j = 0; j < this.tileSize; j++) {\n row = createRow(255, 0, (i * this.tileSize) + j);\n grid.add(row);\n }\n }\n else {\n // start black\n for (int m = 0; m < this.tileSize; m++) {\n row = createRow(0, 255, (i * this.tileSize) + m);\n grid.add(row);\n }\n }\n }\n return new Image(grid, 255);\n }", "private void initialize() {\n\t\tthis.setSize(152, 506);\n\t\tthis.setLayout(new GridLayout(22, 2));\n\t\tthis.setBackground(Color.LIGHT_GRAY);\n\t\tDirection = Still;\n\t\tNext_Direction = Still;\n\t\tbutton = new JButton[floorCnt];\n\t\tButton = new JButton[floorCnt];\n\t\tstate = new boolean[floorCnt];\n\t\tthread = new Thread(this);\n\t\tjlabel.setText(\"STILL\");\n\t\tjlabel.setFont(new Font(\"Consolas\", Font.BOLD, 20));\n\t\tjlabel.setForeground(Color.blue);\n\t\tjlabel.setHorizontalAlignment(SwingConstants.CENTER);\n\t\tjlabel1.setText(\"1\");\n\t\tjlabel1.setFont(new Font(\"Consolas\", Font.BOLD, 20));\n\t\tjlabel1.setForeground(Color.blue);\n\t\tjlabel1.setHorizontalAlignment(SwingConstants.CENTER);\n\t\tthis.add(jlabel);\n\t\tthis.add(jlabel1);\n\t\tfor (int i = floorCnt-1; i >= 0; i--) {\n\t\t\tstate[i] = false;\n\t\t\tbutton[i] = new JButton();\n\t\t\tButton[i] = new JButton();\n\t\t\tbutton[i].setText(String.valueOf(i + 1));\n\t\t\tButton[i].setText(String.valueOf(i + 1));\n\t\t\tButton[i].setBackground(Color.lightGray);\n\t\t\tButton[i].addActionListener(new Action());\n\t\t\tbutton[i].setBorder(javax.swing.BorderFactory.createLineBorder(Color.blue, 4));\n\t\t\tbutton[i].setEnabled(false);\n\t\t\tbutton[i].setBackground(Color.black);\n\t\t\tthis.add(button[i]);\n\t\t\tthis.add(Button[i]);\n\t\t}\n\t\tbutton[0].setBackground(Color.red);\n\t}", "public GameState(int initialStones) \n {\n \tif (initialStones < 1) initialStones = 4;\n \tfor (int i=0; i<6; i++)\n \t\tstate[i] = state[i+7] = initialStones;\n }" ]
[ "0.75009525", "0.7403005", "0.7227467", "0.71058846", "0.7061751", "0.70471305", "0.69900346", "0.68945354", "0.6867953", "0.6862198", "0.68194896", "0.67648965", "0.67485684", "0.6735084", "0.67324835", "0.66568166", "0.66164905", "0.65973395", "0.6544149", "0.6533342", "0.6516876", "0.6503024", "0.6478807", "0.6440038", "0.6425623", "0.6395446", "0.63924396", "0.63918525", "0.63815165", "0.6380975", "0.6380593", "0.63778734", "0.636973", "0.6362648", "0.6352642", "0.63405216", "0.6338191", "0.6313447", "0.6296679", "0.6287264", "0.62763125", "0.62569225", "0.62565446", "0.62453014", "0.6228876", "0.6226468", "0.6167154", "0.61620647", "0.6139198", "0.6136748", "0.6135392", "0.6132292", "0.6130451", "0.6128964", "0.61224025", "0.611513", "0.6109444", "0.6107555", "0.6106989", "0.6079492", "0.607482", "0.6068542", "0.60681003", "0.606545", "0.605914", "0.6058971", "0.6056314", "0.6053461", "0.6048051", "0.604679", "0.6037966", "0.6033326", "0.60327417", "0.6029769", "0.60218537", "0.60100424", "0.60025674", "0.59727424", "0.5971046", "0.5962901", "0.5948065", "0.5945642", "0.59425825", "0.59408057", "0.59374446", "0.5936985", "0.59310657", "0.59244007", "0.5914271", "0.5895331", "0.5894911", "0.5891692", "0.5885445", "0.5885024", "0.5884864", "0.58835846", "0.58827734", "0.5881096", "0.58803105", "0.58760035" ]
0.6979593
7
Update boardState by moving the piece to its new location.
public static void move(String piece, int startFile, int startRank, int endFile, int endRank) { setBoardStateSquare(startFile, startRank, " "); setBoardStateSquare(endFile, endRank, piece); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public void updateBoard(int[][] board, int piece){\r\n this.board=board;\r\n this.piece=piece;\r\n columns = board.length;\r\n rows = board[0].length;\r\n save = Math.min((size / columns), (size / rows));\r\n this.repaint();\r\n repaint();\r\n }", "public void updateBoard() {\n notifyBoardUpdate(board);\n }", "public abstract void move(int newXPosition, int newYPosition, PiecePosition position) throws BoardException;", "public boolean move(int x, int y, CheckersBoard board) {\n if (whiteTurn == true && team == Constants.TeamId.team1Id) {\n return false;\n }\n if (whiteTurn == false && team == Constants.TeamId.team2Id) {\n return false;\n }\n /**\n * then change the x - y coords of the piece\n * update the UI to remove the highlighted squares then move the piece\n * if chess and shared square you take a piece\n * if checkers you jumped them you take the piece\n * return new x - y components\n *\n * if this is too high up in the tree you can override this implementation or update it\n * to fit specific pieces if its not working for some reason\n */\n if (possible(x, y, gameBoard)) {\n int changex = this.getX()-x;\n int changey = this.getY()-y;\n CheckersPiece temp = gameBoard.boardPositions[getX()][getY()];\n gameBoard.boardPositions[getX()][getY()] = null;\n gameBoard.boardPositions[x][y] = temp;\n if (gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2] != null) {\n System.out.println(\"Here\");\n if (gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2].team != this.team) {\n gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2].imageView.setVisibility(View.GONE);\n gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2] = null;\n }\n }\n this.setX(x);\n this.setY(y);/*\n if (Math.abs(changex) == 2) {\n gameBoard.boardPositions[x + (changex/2)][y + (changey/2)] = null;\n if (team == Constants.TeamId.team1Id) {\n board.numPieces1--;\n } else if (team == Constants.TeamId.team2Id) {\n board.numPieces0--;\n }\n }*/\n\n gameBoard.boardPositions[x][y].imageView.setX(142*x);\n gameBoard.boardPositions[x][y].imageView.setY(142*y);\n // flips after move is\n whiteTurn = !whiteTurn;\n gameBoard.startTimer();\n }\n //setUpUI(gameBoard);\n if (getY() == 7 && team == Constants.TeamId.team2Id) {\n board.crown(this);\n }\n if (getY() == 0 && team == Constants.TeamId.team1Id) {\n board.crown(this);\n }\n return possible(x, y, gameBoard);\n }", "void doMove(int move, int piece) {\n //makes a move on the offscreen board\n currentBoard.makeMove(move, piece);\n //displays the move in the GUI\n changeColourSquare(move);\n //changes turn\n turn = !turn;\n }", "public void movePiece(Coordinate from, Coordinate to);", "public void updateBoard() {\n for(SnakePart s : snakePartList) {\n board[s.getSnakePartRowsOld()][s.getSnakePartCollsOld()] = ' ';\n board[s.getSnakePartRowsNew()][s.getSnakePartCollsNew()] = 'S';\n }\n \n for (SnakeEnemyPart e : snakeEnemyPartList) {\n board[e.getSnakeEnemyPartRowsOld()][e.getSnakeEnemyPartCollsOld()] = ' ';\n board[e.getSnakeEnemyPartRowsNew()][e.getSnakeEnemyPartCollsNew()] = 'E';\n }\n }", "public static void move(TTTBoard board, char piece) {\n if (board.winner() != ' ') {\n throw new IllegalArgumentException(\"Game Over\");\n }\n if (board.size() == 1) {\n board.set(0, 0, piece);\n return;\n }\n if (board.size() == 3) {\n int turnNumber = getBoardTurnNumber(board);\n if (turnNumber == 1) {\n board.set(0, 0, piece);\n return;\n } else if (turnNumber == 2) {\n if (board.get(1, 1) == ' ') {\n board.set(1, 1, piece);\n return;\n } else if (board.get(0, 0) == ' ') {\n board.set(0, 0, piece);\n return;\n }\n } else if (turnNumber == 3) {\n try {\n int[] opp = getFirstOpp(board, piece);\n int oppRow = opp[0];\n if (oppRow == 0) {\n board.set(2, 0, piece);\n return;\n } else if (oppRow == 1) {\n board.set(0, 2, piece);\n return;\n } else {\n board.set(0, 2, piece);\n return;\n }\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n }\n\n // check if win diagonal\n int selfC = 0;\n int oppC = 0;\n int spaceC = 0;\n for (int i = 0; i < board.size(); ++i) {\n int j = i;\n char p = board.get(i, j);\n if (p == ' ') spaceC++;\n else if (p == piece) selfC++;\n else oppC++;\n }\n\n if (spaceC == 1 && (selfC == 0 || oppC == 0)) {\n // fill in that space\n for (int i = 0; i < board.size(); ++i) {\n int j = i;\n char p = board.get(i, j);\n if (p == ' ') {\n board.set(i, j, piece);\n return;\n }\n }\n }\n\n selfC = 0;\n oppC = 0;\n spaceC = 0;\n for (int i = 0; i < board.size(); ++i) {\n int j = board.size() - i - 1;\n char p = board.get(i, j);\n if (p == ' ') spaceC++;\n else if (p == piece) selfC++;\n else oppC++;\n\n }\n\n if (spaceC == 1 && (selfC == 0 || oppC == 0)) {\n // fill in that space\n for (int i = 0; i < board.size(); ++i) {\n int j = board.size() - i - 1;\n char p = board.get(i, j);\n if (p == ' ') {\n board.set(i, j, piece);\n return;\n }\n }\n }\n\n // check if win row col\n\n boolean[] selfWinnableRows = new boolean[board.size()];\n boolean[] oppWinnableRows = new boolean[board.size()];\n boolean[] selfWinnableCols = new boolean[board.size()];\n boolean[] oppWinnableCols = new boolean[board.size()];\n int[] selfCountRows = new int[board.size()];\n int[] selfCountCols = new int[board.size()];\n int[] oppCountRows = new int[board.size()];\n int[] oppCountCols = new int[board.size()];\n\n // checks if any rows can be won\n for (int i = 0; i < board.size(); ++i) {\n boolean containsSelf = false;\n boolean containsOpp = false;\n boolean hasEmpty = false;\n int selfCount = 0;\n int oppCount = 0;\n\n for (int j = 0; j < board.size(); ++j) {\n char p = board.get(i, j);\n\n if (p == ' ') {\n hasEmpty = true;\n } else if (p == piece) {\n containsSelf = true;\n selfCount++;\n } else {\n containsOpp = true;\n oppCount++;\n }\n }\n\n selfCountRows[i] = selfCount;\n oppCountRows[i] = oppCount;\n\n if (!hasEmpty) continue;\n\n if (!containsSelf && !containsOpp) {\n selfWinnableRows[i] = true;\n oppWinnableRows[i] = true;\n }\n\n if (containsSelf && !containsOpp) {\n selfWinnableRows[i] = true;\n }\n if (containsOpp && !containsSelf) {\n oppWinnableRows[i] = true;\n }\n }\n\n // checks if any cols can be won\n for (int i = 0; i < board.size(); ++i) {\n boolean containsSelf = false;\n boolean containsOpp = false;\n boolean hasEmpty = false;\n int selfCount = 0;\n int oppCount = 0;\n for (int j = 0; j < board.size(); ++j) {\n char p = board.get(j, i);\n\n if (p == ' ') {\n hasEmpty = true;\n } else if (p == piece) {\n containsSelf = true;\n selfCount++;\n } else {\n containsOpp = true;\n oppCount++;\n }\n }\n\n selfCountCols[i] = selfCount;\n oppCountCols[i] = oppCount;\n\n if (!hasEmpty) continue;\n\n if (!containsSelf && !containsOpp) {\n selfWinnableCols[i] = true;\n oppWinnableCols[i] = true;\n }\n\n if (containsSelf && !containsOpp) {\n selfWinnableCols[i] = true;\n }\n\n if (containsOpp && !containsSelf) {\n oppWinnableCols[i] = true;\n }\n }\n\n int[] selfInRowRows = new int[board.size()];\n int[] selfInRowCols = new int[board.size()];\n int[] oppInRowRows = new int[board.size()];\n int[] oppInRowCols = new int[board.size()];\n\n for (int i = 0; i < selfWinnableRows.length; ++i) {\n if (selfWinnableRows[i]) {\n int count = selfCountRows[i];\n selfInRowRows[count]++;\n }\n }\n for (int i = 0; i < selfWinnableCols.length; ++i) {\n if (selfWinnableCols[i]) {\n int count = selfCountCols[i];\n selfInRowCols[count]++;\n }\n }\n for (int i = 0; i < oppWinnableRows.length; ++i) {\n if (oppWinnableRows[i]) {\n int count = oppCountRows[i];\n oppInRowRows[count]++;\n }\n }\n for (int i = 0; i < oppWinnableCols.length; ++i) {\n if (oppWinnableCols[i]) {\n int count = oppCountCols[i];\n oppInRowCols[count]++;\n }\n }\n\n if (board.size() == 3) {\n int turnNumber = getBoardTurnNumber(board);\n if (selfInRowRows[board.size() - 1] == 0 &&\n selfInRowCols[board.size() - 1] == 0 &&\n oppInRowRows[board.size() - 1] == 0 &&\n oppInRowCols[board.size() - 1] == 0) {\n if (turnNumber == 4) {\n if ((board.get(1, 1) != ' ' && board.get(1, 1) != piece)\n && (board.get(2, 2) != ' ' && board.get(2, 2) != piece)) {\n board.set(2, 0, piece);\n return;\n }\n } else if (turnNumber == 5) {\n if (selfCountCols[0] == 2) {\n board.set(2, 2, piece);\n return;\n } else if (selfCountRows[0] == 2) {\n if (board.get(1, 0) != piece && board.get(1, 0) != ' ') {\n board.set(2, 2, piece);\n return;\n }\n if (board.get(2, 0) != piece && board.get(2, 0) != ' ') {\n board.set(2, 2, piece);\n return;\n }\n board.set(2, 0, piece);\n return;\n }\n }\n }\n }\n\n for (int i = board.size() - 1; i >= 0; i--) {\n int selfRowsCount = selfInRowRows[i];\n //System.out.println(i + \" self rows count: \" + selfRowsCount);\n if (selfRowsCount > 0) {\n // get a row index that contains this self in row rows\n try {\n int rowIndex = getRowIndexForInRowRows(board, i, selfWinnableRows, selfCountRows);\n int colIndex = getNextInRow(board, rowIndex);\n board.set(rowIndex, colIndex, piece);\n return;\n } catch (Exception e) {\n e.printStackTrace();\n }\n\n }\n int selfColsCount = selfInRowCols[i];\n if (selfColsCount > 0) {\n try {\n int colIndex = getRowIndexForInRowRows(board, i, selfWinnableCols, selfCountCols);\n int rowIndex = getNextInCol(board, colIndex);\n board.set(rowIndex, colIndex, piece);\n return;\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n int oppRowsCount = oppInRowRows[i];\n // System.out.println(i + \" opp rows count: \" + oppRowsCount);\n if (oppRowsCount > 0) {\n\n try {\n int rowIndex = getRowIndexForInRowRows(board, i, oppWinnableRows, oppCountRows);\n int colIndex = getNextInRow(board, rowIndex);\n board.set(rowIndex, colIndex, piece);\n return;\n } catch (Exception e) {\n e.printStackTrace();\n }\n\n }\n int oppColsCount = oppInRowCols[i];\n if (oppColsCount > 0) {\n try {\n int colIndex = getRowIndexForInRowRows(board, i, oppWinnableCols, oppCountCols);\n int rowIndex = getNextInCol(board, colIndex);\n board.set(rowIndex, colIndex, piece);\n return;\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n }\n\n try {\n int[] nextEmpty = getNextEmpty(board);\n board.set(nextEmpty[0], nextEmpty[1], piece);\n } catch (Exception e) {\n throw new IllegalArgumentException(\"DRAW / SOMEONE WON\");\n }\n }", "private void playerMove(PlayerPiece playerPiece, String direction) {\n // Row will be -1 from player location with the same column value\n System.out.println(playerPiece + \" trying to move \" + direction + \".\");\n Tile playerLocation = playerPiece.getLocation();\n System.out.println(\"Player in: \" + playerLocation.getRow() + \" \" + playerLocation.getColumn());\n int newRow = playerLocation.getRow();\n int newColumn = playerLocation.getColumn();\n switch (direction) {\n case \"u\":\n newRow -= 1;\n break;\n case \"d\":\n newRow += 1;\n break;\n case \"l\":\n newColumn -= 1;\n break;\n case \"r\":\n newColumn += 1;\n break;\n }\n if (newRow >= 0 && newColumn >= 0 && newRow < this.board.getGrid().getRows() && newColumn < this.board.getGrid().getColumns()) {\n System.out.println(newRow + \" \" + newColumn);\n Tile newLocation = this.board.getGrid().getTile(newRow, newColumn);\n System.out.println(\"New Location:\" + newLocation);\n System.out.println(\"Cords: \" + newLocation.getRow() + \" \" + newLocation.getColumn());\n if (newLocation.isAvailable()) {\n playerLocation.removeOccupier();\n playerPiece.setLocation(newLocation);\n newLocation.setOccupier(playerPiece);\n System.out.println(\"Player moved to: \" + playerLocation.getRow() + \" \" + playerLocation.getColumn());\n this.board.getGrid().print();\n }\n }\n }", "@Override\n\tpublic boolean move(int col, int row, piece[][] board) {\n\t\treturn false;\n\t}", "private boolean movePiece(Tile fromTile) {\r\n\t\tgetBoard().setToTile(tile);\r\n\t\tmakeBackup();\r\n\r\n\t\ttile.setPiece(fromTile.getPiece());\r\n\r\n\t\t// League wins the game if the piece carrying the flag returns to its territory\r\n\t\tif (tile.getPiece().getHasEnemyFlag() == true && tile.getPiece().getLEAGUE().toString().toLowerCase()\r\n\t\t\t\t.equals(tile.getTer().territoryName().toLowerCase())) {\r\n\t\t\tGame.getInstance().setGameOver(true);\r\n\t\t}\r\n\r\n\t\t// reset the old position\r\n\t\tfromTile.setPiece(null);\r\n\t\tgetBoard().setFromTile(null);\r\n\r\n\t\t// reset the selection\r\n\t\tgetBoard().setPieceSelected(false);\r\n\r\n\t\t// fromTile = null;\r\n\t\tgetBoard().setToTile(null);\r\n\r\n\t\treturn true;\r\n\t}", "public void executeCommand(ChessPiece piece)\n {\n piece.getBoardMediator().movePiece(piece);\n }", "void step () {\n if (gameOver)\n return;\n if (!isFalling) {\n // if last piece finished falling, spawn a new one\n spawnNewPiece();\n // if it can't move, game over\n if (!canMove(currentRow + 1, currentColumn)) {\n endGame();\n }\n updateView();\n }\n else if (canMove(currentRow + 1, currentColumn)) {\n currentRow += 1;\n updateView();\n } else {\n // the piece fell!\n isFalling = false;\n // draw current shape to the board\n drawCurrentToBoard();\n currentPiece.blocks = new int[currentPiece.blocks.length][currentPiece.blocks[0].length];\n increaseScore(board.clearFullRows(this));\n }\n }", "public void setNewPieceLocation(GuiPiece dragPiece, int x, int y) {\n int targetRow = Gui.convertYToRow(y);\n int targetColumn = Gui.convertXToColumn(x);\n\n if (targetRow < Piece.ROW_1 || targetRow > Piece.ROW_6 || targetColumn < Piece.COLUMN_A\n || targetColumn > Piece.COLUMN_F) {\n dragPiece.resetToUnderlyingPiecePosition();\n } else {\n System.out.println(\"moving piece to \" + targetRow + \"/\" + targetColumn);\n Move move = new Move(dragPiece.getPiece().getRow(), dragPiece.getPiece().getColumn(), targetRow, targetColumn);\n boolean wasMoveSuccessfull = game.movePiece(move);\n \n if(wasMoveSuccessfull) lastMove = move;\n \n dragPiece.resetToUnderlyingPiecePosition();\n }\n }", "protected void move(Player player, Movement move) {\n if (board.board[move.oldP.x][move.oldP.y] != null) {\n board.board[move.newP.x][move.newP.y] = board.board[move.oldP.x][move.oldP.y];\n board.board[move.oldP.x][move.oldP.y] = null;\n\n if (player.colour == Colour.BLACK) {\n blackPlayer.move(move);\n whitePlayer.removePiece(move.newP);\n } else if (player.colour == Colour.WHITE) {\n whitePlayer.move(move);\n blackPlayer.removePiece(move.newP);\n }\n\n sharedBoard.update(whitePlayer.getOccupied(), blackPlayer.getOccupied());\n\n // Check for promotions...\n for (int x = 0; x < board.board.length; ++x)\n if (board.board[x][0] instanceof Pawn)\n board.board[x][0] = new Queen(Colour.BLACK);\n else if (board.board[x][7] instanceof Pawn)\n board.board[x][7] = new Queen(Colour.WHITE);\n }\n }", "public void movePiece(int xStart, int yStart, int xEnd, int yEnd) {\n board[xEnd][yEnd] = board[xStart][yStart];\n board[xStart][yStart] = null;\n board[xEnd][yEnd].moveTo(xEnd, yEnd);\n if (board[xEnd][yEnd] instanceof ChessPieceKing) {\n if (board[xEnd][yEnd].isBlack()) {\n locationBlackKing = new Point(xEnd, yEnd);\n } else {\n locationWhiteKing = new Point(xEnd, yEnd);\n }\n }\n\n drawScreen();\n }", "@Override\n public void movePiece(Piece piece, char file, GridPosition end) {\n GridPosition current = getCurrentGridPositionOfPiece(piece, file, end);\n\n Move mv = new Move(piece, current, end);\n\n int[] curYX = ChessGameUtils_Ng.convertGridPositionTo2DYXArray(current);\n int curY = curYX[ChessGameUtils_Ng.Y_INDEX], curX = curYX[ChessGameUtils_Ng.X_INDEX];\n\n int[] update = mv.getYXDelta();\n int dY = update[DELTA_Y_INDEX], dX = update[DELTA_X_INDEX];\n\n board[curY][curX] = EMPTY_SPACE;\n board[curY + dY][curX + dX] = piece;\n moveHistory.add(mv);\n }", "private Board moveTo(int direction) {\n Board newBoard = new Board(this.state);\n int oZ = this.zero;\n int nZ = oZ;\n switch (direction) {\n case Board.LEFT: nZ = oZ - 1; break;\n case Board.RIGHT: nZ = oZ + 1; break;\n case Board.UP: nZ = oZ - Board.dim; break;\n case Board.DOWN: nZ = oZ + Board.dim; break;\n default: return null;\n }\n newBoard.state[oZ] = state[nZ];\n newBoard.state[nZ] = 0;\n newBoard.zero = nZ;\n\n // update heuristic iteratively except for MAN\n switch(Board.heuristic) {\n case HAM:\n if (state[nZ] == oZ) newBoard.dist = this.dist - 1;\n else if (state[nZ] == nZ) newBoard.dist = this.dist + 1;\n else newBoard.dist = this.dist;\n break;\n case INT: // iterative update the interference\n // this is the most logically complicated code I have\n // done in a while\n int moved = state[nZ];\n int oC;\n newBoard.inter = inter;\n switch (direction) {\n case Board.LEFT:\n case Board.RIGHT: // LEFT AND RIGHT\n if (Board.colOf[state[nZ]] == Board.colOf[nZ]) {\n // we've replaced a piece on its col with a zero\n // interference can only decrease since we know\n // the piece didn't belong to its old column\n //System.out.println(\"Took \" + state[nZ] + \" out of its col\");\n for (int i = Board.colOf[nZ]; i < nZ; i+=Board.dim)\n if (Board.colOf[state[i]] == Board.colOf[nZ] &&\n state[i] > state[nZ])\n newBoard.inter--;\n for (int i = nZ + Board.dim; i < state.length; i+=Board.dim)\n if (Board.colOf[state[i]] == Board.colOf[nZ] &&\n state[i] < state[nZ])\n newBoard.inter--;\n \n } else if (Board.colOf[state[nZ]] == Board.colOf[oZ]) {\n // we've put a piece on its col that was a zero\n // interference can only increase since we know\n // the piece didn't below to its old column\n //System.out.println(\"Put \" + state[nZ] + \" into its col\");\n for (int i = Board.colOf[oZ]; i < oZ; i+=Board.dim)\n if (Board.colOf[state[i]] == Board.colOf[oZ] &&\n state[i] > state[nZ])\n newBoard.inter++;\n for (int i = oZ + Board.dim; i < state.length; i+=Board.dim)\n if (Board.colOf[state[i]] == Board.colOf[oZ] &&\n state[i] < state[nZ])\n newBoard.inter++;\n }\n break;\n default: // UP AND DOWN\n if (Board.rowOf[state[nZ]] == Board.rowOf[nZ]) {\n // we've replaced a piece on its row with a zero\n // interference can only decrease since we know\n // the piece didn't belong to its old row\n //System.out.println(\"Took \" + state[nZ] + \" out of its row\");\n for (int i = Board.dim*Board.rowOf[nZ]; i < nZ; i++)\n if (Board.rowOf[state[i]] == Board.rowOf[nZ] &&\n state[i] > state[nZ])\n newBoard.inter--;\n for (int i = nZ+1; i < Board.dim*(Board.rowOf[nZ]+1); i++)\n if (Board.rowOf[state[i]] == Board.rowOf[nZ] &&\n state[i] < state[nZ])\n newBoard.inter--;\n } else if (Board.rowOf[state[nZ]] == Board.rowOf[oZ]) {\n // we've put a piece on its row that was a zero\n // interference can only increase since we know\n // the piece didn't belong to its old row\n //System.out.println(\"Put \" + state[nZ] + \" into its row\");\n for (int i = Board.dim*Board.rowOf[oZ]; i < oZ; i++)\n if (Board.rowOf[state[i]] == Board.rowOf[oZ] &&\n state[i] > state[nZ])\n newBoard.inter++;\n for (int i = oZ+1; i < Board.dim*(Board.rowOf[oZ]+1); i++)\n if (Board.rowOf[state[i]] == Board.rowOf[oZ] &&\n state[i] < state[nZ])\n newBoard.inter++;\n }\n } \n default: // update the manhattan distance\n newBoard.dist = this.dist - \n Board.manhattanTable[state[nZ]][nZ] +\n Board.manhattanTable[state[nZ]][oZ];\n }\n return newBoard;\n }", "public void move(Cell[][] board) {\n Cell[] nextCells = generateNeighbors(this.x, this.y);\n Cell nextCell = nextCells[rand.nextInt(4)];\n if (!this.objectFound) {\n if (nextCell != null && nextCell.isOccupied() && nextCell.occupiedBy instanceof Integer) {\n this.objectFound = true;\n this.goal = nextCell;\n } else if (nextCell != null && !nextCell.isOccupied()) {\n synchronized (board[this.x][this.y]) {\n board[this.x][this.y].resetCell();\n nextCell.occupiedBy = this;\n }\n }\n } else {\n // bfs to location\n System.out.println(\"BFS to goal\");\n }\n }", "public void updateCellState(Move move)\r\n\t{\r\n\t\tCellState color = this.grid[move.getMovedMarbleInitialPosition(0).getX()][move.getMovedMarbleInitialPosition(0).getY()];\r\n\t\t\r\n\t\tfor(int i = 0;i < move.getMovedMarblesCount();i++)\r\n\t\t{\r\n\t\t\tthis.grid[move.getMovedMarbleInitialPosition(i).getX()][move.getMovedMarbleInitialPosition(i).getY()] = CellState.EMPTY;\r\n\t\t}\r\n\t\tfor(int i = 0; i < move.getMovedMarblesFinalCount();i++)\r\n\t\t{\r\n\t\t\tif(isPositionValid(move.getMovedMarbleFinalPosition(i)))\r\n\t\t\t{\r\n\t\t\t\tthis.grid[move.getMovedMarbleFinalPosition(i).getX()][move.getMovedMarbleFinalPosition(i).getY()] = color;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tif(color == CellState.BLACK_MARBLE) this.blackMarblesCount --;\r\n\t\t\t\tif(color == CellState.WHITE_MARBLE) this.whiteMarblesCount --;\r\n\t\t\t}\r\n\t\t}\r\n\t}", "public void nextPiece() {\n\t\tif (currentPiece != null) {\n\t\t\tfor (Loc l : currentPiece.getLocation()) {\n\t\t\t\tif (!l.isOnBoard()) {\n\t\t\t\t\tendGame();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tcurrentPiece = piecePlacer.nextPiece();\n\n\t\tdropPiece();\n\t\tnextPiecePanel.setNextPiece();\n\t}", "public void updateBoard(Move move) {\n\t\ttry {\n\t\tint type = board.getBoard()[move.getyOrigin()][move.getxOrigin()];\n\t\t\n\t\t\tboard.getBoard()[move.getyOrigin()][move.getxOrigin()] = 0;\n\t\t\tboard.getBoard()[move.getyMove()][move.getxMove()] = type;\n\t\t} catch (NullPointerException e) {\n\t\t\tSystem.out.println(\"Move invalid\");\n\t\t}\n\t}", "public int move(Piece piece, int dices){\n int step = this.roll(dices); //and returns the new position of piece of player.\n this.piece.position += step;\n this.piece.position = (this.piece.position%40);\n System.out.println(this.name + \" is now located in Square \" + this.piece.position);\n return piece.position;\n }", "public void applyMove(Move move) {\r\n Piece piece = grid[move.getStart()];\r\n piece.setPosition(move.getEnd());\r\n\r\n grid[move.getStart()] = null;\r\n grid[move.getEnd()] = piece;\r\n if (move.getTakes() != null) {\r\n grid[move.getTakes().getPosition()] = null;\r\n pieces.get(move.getTakes().getPlayerColor()).remove(move.getTakes());\r\n }\r\n\r\n moveHistory.add(move);\r\n }", "public void setState(int row, int col) throws ArrayIndexOutOfBoundsException {\r\n board[row][col] = currentPlayer;\r\n }", "@Override\n\tpublic MoveResult move(PieceType piece, Location from, Location to)\n\t\t\tthrows StrategyException {\n\t\tfinal String errorMessage = checkLegalMove(piece, from, to);\n\t\tif (errorMessage != null) {\n\t\t\tthrow new StrategyException(errorMessage);\n\t\t}\n\n\t\t// Get the piece from the from location that is attempting to move.\n\t\tfinal Piece movingPiece = gameBoard.getPieceAt(from);\n\t\t// Get the piece, if any, from the to location.\n\t\tfinal Piece targetPiece = gameBoard.getPieceAt(to);\n\n\t\t// Store the result of the move\n\t\tMoveResult result = null;\n\n\t\t// Advance the turn counter to the next turn\n\t\tendTurn();\n\n\t\t// If the move is to an empty space\n\t\tif (targetPiece == null) {\n\t\t\t// For a move into an empty space, change the location of the\n\t\t\t// piece\n\t\t\t// to the destination.\n\t\t\tgameBoard.putPiece(to, movingPiece);\n\t\t\tgameBoard.putPiece(from, null);\n\t\t\tresult = new MoveResult(MoveResultStatus.OK, null);\n\n\t\t} else {\n\t\t\t// Otherwise, there is a battle.\n\t\t\tfinal BetaBattleController battle = new BetaBattleController(gameBoard,\n\t\t\t\t\tfrom, to);\n\t\t\tresult = battle.getBattleResult();\n\t\t\tfinal PieceLocationDescriptor battleWinner = result.getBattleWinner();\n\t\t\tgameBoard.updateBattlePositions(from, to, battleWinner);\n\t\t}\n\n\t\tMoveResultStatus moveStatus = result.getStatus();\n\n\t\t// If neither side has captured a flag\n\t\tif (moveStatus == MoveResultStatus.OK) {\n\t\t\t// if it is the (12th) move, game status set to draw\n\t\t\tif (turnsCounter == NUMBER_OF_TURNS) {\n\t\t\t\tmoveStatus = MoveResultStatus.DRAW;\n\t\t\t\tresult = new MoveResult(moveStatus, result.getBattleWinner());\n\t\t\t}\n\n\t\t}\n\n\t\t// If the game has ended, reset the board.\n\t\tif (moveStatus == MoveResultStatus.RED_WINS\n\t\t\t\t|| moveStatus == MoveResultStatus.BLUE_WINS\n\t\t\t\t|| moveStatus == MoveResultStatus.DRAW) {\n\t\t\t// End the game\n\t\t\tgameStarted = false;\n\t\t\t// Reset the board.\n\t\t\tgameBoard = new BetaBoard(initialRedConfig, initialBlueConfig);\n\t\t}\n\n\t\treturn result;\n\t}", "public void movePlayerPiece(Tile newTile) {\n // Check if the target tile is a position that can be moved to.\n PlayerPiece pp = currentPlayersTurn.getPiece();\n int tileRow = pp.getLocation().getRow();\n int tileCol = pp.getLocation().getColumn();\n List<Pair<Integer, Integer>> neighbours = new ArrayList<>();\n\n // Generate immediately adjacent tiles.\n for (int row = tileRow - 1; row <= tileRow + 1; row++) {\n if (row == tileRow || row > board.getGrid().getRows() ||\n row < 0) {\n continue;\n }\n neighbours.add(new Pair<>(row, tileCol));\n }\n for (int col = tileCol - 1; col <= tileCol + 1; col++) {\n if (col == tileCol || col > board.getGrid().getColumns() ||\n col < 0) {\n continue;\n }\n neighbours.add(new Pair<>(tileRow, col));\n }\n\n boolean canMove = neighbours.contains(new Pair<>(newTile.getRow(),\n newTile.getColumn())) && (currentPlayersSteps > 0)\n && state == GameState.InPlay && !newTile.isOccupied();\n\n if (canMove) {\n currentPlayersTurn.getPiece().getLocation().removeOccupier();\n currentPlayersTurn.getPiece().setLocation(newTile);\n currentPlayersSteps--;\n }\n\n if (currentPlayersSteps <= 0) {\n endTurn();\n }\n }", "protected void pieceButtonClicked(ActionEvent e) {\n if (board.ended) return;\n JButton button = (JButton) e.getSource();\n Pair<Integer, Integer> coord = getJButtonCoord(button);\n int row = coord.getKey();\n int col = coord.getValue();\n\n if (board.isCurrentPlayerPiece(row, col)) {\n if (selectedPiece != null) {\n setAllToDefaultColor();\n //selectedPiece.setBackground(getDefaultColor(selectedPiece));\n }\n selectedPiece = button;\n selectedPiece.setBackground(Color.BLUE);\n drawPossibleMoves();\n } else {\n if (selectedPiece != null) { //try move selectedPiece to coord\n Pair<Integer,Integer> coordSelected = getJButtonCoord(selectedPiece);\n int startRow = coordSelected.getKey();\n int startCol = coordSelected.getValue();\n int status = board.movePiece(startRow,startCol,row,col);\n if (status == 0){ // invalid move\n message.setText(\"illegal move\");\n }else {\n //move the piece\n button.setIcon(selectedPiece.getIcon());\n selectedPiece.setIcon(null);\n selectedPiece.setBackground(getDefaultColor(selectedPiece));\n selectedPiece = null;\n setAllToDefaultColor();\n if (status == 1) {\n Boolean isChecked = board.isChecked(board.turn);\n String nextTurn = board.turn == 0 ? \"Black\" : \"White\";\n if (isChecked)\n nextTurn = \"CHECK! \" + nextTurn;\n message.setText(nextTurn + \"'s turn\");\n }else if (status == 2){ // black wins\n message.setText(\"Black Wins!\");\n playerScores[blackPlayer]++;\n refreshScore();\n } else if (status == 3){ // white wins\n playerScores[ 1- blackPlayer] ++;\n refreshScore();\n message.setText(\"White Wins!\");\n } else if (status == 4 ) { // draws\n playerScores[0]++;\n playerScores[1]++;\n refreshScore();\n message.setText(\"Draws!\");\n }\n }\n }\n }\n }", "public static void updatePositions() {\n\t\tfor(Square s1 : ChessBoard.BOARD_SQUARES) {\n\t\t\tif(s1.hasPiece()) {\n\t\t\t\t(s1.getPiece()).setPosition(s1.getPosition());\n\t\t\t\t(s1.getPiece()).updatePossibleMoves();\n\t\t\t}\n\t\t}\n\t}", "public void movePiece(Location a, Location b)\n {\n Square s1 = getSquare(a);\n Square s2 = getSquare(b);\n Piece p = s1.getPiece();\n if (p==null)\n return;\n int moveType = canMoveTo(p,b);\n boolean taking = getPiece(b)!=null;\n boolean fiftyMoveBreak = getPiece(b)!=null||p.getType()==Type.PAWN;\n s2.setPiece(s1.removePiece());\n p.setHasMoved(true);\n if (p.getType()==Type.PAWN)\n {\n if (mainBoard&&((p.white()&&getLocation(p).getRow()==0)\n || !p.white()&&getLocation(p).getRow()==7))\n promotePawn(p);\n else if (moveType==EN_PASSANT)\n {\n int row = a.getRow();\n int col = b.getCol();\n removePiece(new Location(row,col));\n taking = true;\n }\n }\n else if (moveType==KINGSIDE_CASTLING||moveType==QUEENSIDE_CASTLING)\n {\n Location rookLoc;\n Location rookDest;\n if (moveType==KINGSIDE_CASTLING)\n {\n rookLoc = b.farther(Direction.EAST);\n rookDest = b.farther(Direction.WEST);\n }\n else\n {\n rookLoc = new Location(b.getRow(),b.getCol()-2);\n rookDest = b.farther(Direction.EAST);\n }\n //movePiece(getLocation(rook),rookDest);\n getSquare(rookDest).setPiece(removePiece(rookLoc)); //moves the rook\n }\n if (mainBoard)\n {\n turn++;\n if (fiftyMoveBreak)\n fiftyMove= 0;\n else fiftyMove++;\n }\n for (Piece piece: getPieces())\n piece.setHasJustMoved(false);\n p.setHasJustMoved(true);\n if (mainBoard)\n {\n positions.add(toString());\n \n //this is all for the notation on the side\n notateMove(p,b,moveType,taking);\n /*JTable not = frame.getNotation();\n DefaultTableModel d = (DefaultTableModel)not.getModel();\n String notation;\n PieceColor color = p.getColor();\n if (color==PieceColor.WHITE)\n notation = turn/2+1+\". \"; //the turn number first, on the left\n else notation = \"\";\n if (moveType==QUEENSIDE_CASTLING)\n notation += \"0-0-0\";\n else if (moveType==KINGSIDE_CASTLING)\n notation += \"0-0\";\n else //normal move\n {\n if (p.getType()!=Type.PAWN)\n notation+=p.getType().toNotation(); //the type of piece (K,N,R,etc)\n if (taking)\n notation+=\"x\"; //this is if the move involves taking\n notation+=Location.LocToNot(b);\n }\n if (checkmate(colorGoing())) //notates # for checkmate\n notation+=\"#\";\n else if (inCheck(colorGoing())) //notates + for check\n notation+=\"+\";\n \n if (color==PieceColor.WHITE)\n d.addRow(new Object[]{notation,\"\"});\n else \n d.setValueAt(notation, (turn-1)/2, 1);*/\n }\n }", "void movePiece() {\n\n }", "public void applyMove(String name, int posx, int posy, int piece) {\n\t\tif (curPlayer == 1)\n\t\t\tSystem.out.println(\"Moving a black piece\");\n\t\telse\n\t\t\tSystem.out.println(\"Moving a red piece\");\n\t\tif (jumpedComp != null && jumping == true) {\n\t\t\t((JLabel) jumpedComp).setIcon(Playboard.empty); \n\t\t\tarr[prevPosX + xdiff][prevPosY + ydiff] = 0;\n\t\t\t\n\t\t\tif ((curPlayer == 1 && !((prevPosX + (xdiff * 4)) >= 8) && !((prevPosX + (xdiff * 4)) <= -1) && !((prevPosY + (ydiff * 4)) <= -1) && !((prevPosY + (ydiff * 4)) >= 8) && ((contJumpInt(3) == 2 || contJumpInt(3) == 4)) && contJumpInt(4) == 0)) {\n\t\t\t\tchangeBackground(curComp, null, false);\n\t\t\t\tdoubleJump();\n\t\t\t} else if (curPlayer == 2 && !((prevPosX + (xdiff * 4)) <= -1) && !((prevPosX + (xdiff * 4)) >= 8) && !((prevPosY + (ydiff * 4)) <= -1) && !((prevPosY + (ydiff * 4)) >= 8) && (contJumpInt(3) == 1 || contJumpInt(3) == 3) && contJumpInt(4) == 0) {\n\t\t\t\tchangeBackground(curComp, null, false);\n\t\t\t\tdoubleJump();\n\t\t\t}\n\t\t\t\t\n\t\t}\n\t\tif (!multipleJump) {\n\t\t\tchangeBackground(curComp, null, false);\n\t\t\tpp.setPiece(name, posx, posy, piece);\n\t\t\tSystem.out.println(\"Red is done, Black's up next.\");\n\t\t}\n\t}", "public void setBoard() {\n bestPieceToMove = null;\n bestPieceFound = false;\n bestMoveDirectionX = 0;\n bestMoveDirectionY = 0;\n bestMoveFound = false;\n killAvailable = false;\n lightCounter = 12;\n darkCounter = 12;\n for (int y = 0; y < boardSize; y++) {\n for (int x = 0; x < boardSize; x++) {\n board[y][x] = new Field(x, y);\n if (y < 3 && board[y][x].getPlaceable()) {\n board[y][x].setPiece(new Piece(PieceColor.DARK, PieceType.MEN));\n } else if (y > 4 && board[y][x].getPlaceable()) {\n board[y][x].setPiece(new Piece(PieceColor.LIGHT, PieceType.MEN));\n }\n }\n }\n }", "public void setOpBoardMove(int row, int col, int oppiece)\n\t{\n\t\tboard[row][col] = oppiece;\n\t}", "public void setPiece(int x, int y, Piece piece) {\n \tboard[y][x] = piece;\n }", "@Override\r\n\tpublic void actionPerformed(ActionEvent e) {\r\n\t\tBoardButton button = (BoardButton) e.getSource();\r\n\t\tGameBoard board = game.getBoard();\r\n\t\tint row = button.getRow();\r\n\t\tint column = button.getColumn();\r\n\t\tgame.savePieceToMove(column, row);\r\n\t}", "private void HandleOnMoveStart(Board board, Piece turn){}", "public abstract Piece setLocation(int row, int column);", "public PuzzleState move(int row, int column, Operation op);", "private static int upScore(char piece, State state, int row, int col) {\n\t\tif(row != 0 && state.getGrid()[row-1][col] == piece) {\n\t\t\treturn NEXT_TO;\n\t\t}\n\t\telse {\n\t\t\treturn ZERO;\n\t\t}\n\t}", "private void easyMove(Board board) {\n\t\t\r\n\t}", "private boolean tryMove(Shape newPiece, int newX, int newY) {\n for (int i = 0; i < 4; ++i) {\n\n int x = newX + newPiece.x(i);\n int y = newY - newPiece.y(i);\n//if a piece reaches the edge it stops\n if (x < 0 || x >= BOARD_WIDTH || y < 0 || y >= BOARD_HEIGHT) {\n return false;\n }\n//if a piece is adjacent to any fallen tetris pieces it stops\n if (shapeAt(x, y) != Tetrominoe.NoShape) {\n return false;\n }\n }\n\n curPiece = newPiece;\n curX = newX;\n curY = newY;\n\n repaint();\n\n return true;\n }", "public void updateCell() {\n alive = !alive;\n simulator.getSimulation().changeState(xPosition, yPosition);\n setColor();\n }", "private void update() {\n setPieceType();\n initBackground(pieceIndex);\n }", "public static void changepieces(int row, int column, String piecevalue){\n\t\tString oppositepiece;\n\t\tif(piecevalue.equals(\"x\")){\n\t\t\toppositepiece=\"o\";\n\t\t}\n\t\telse if(piecevalue.equals(\"o\")){\n\t\t\toppositepiece=\"x\";\n\t\t}\n\t\telse{\n\t\t\toppositepiece=\"-\";\n\t\t}\n\t\t//R=right, L=left, T=top, B=bottom, and there are diagonals such as TL=top left.\n\t\tboolean foundR=false,foundL=false,foundT=false,foundB=false,foundTL=false,foundTR=false,foundBL=false,foundBR=false;\n\t\tint checkfurtherR=1,checkfurtherL=1,checkfurtherT=1,checkfurtherB=1,checkfurtherTL=1,checkfurtherTR=1,checkfurtherBL=1,checkfurtherBR=1;\n\t\twhile(board[row][column+checkfurtherR].equals(oppositepiece)){\n\t\t\tcheckfurtherR++;\n\t\t}\n\t\tif(board[row][column+checkfurtherR].equals(piecevalue)){\n\t\t\tfoundR=true;\n\t\t}\n\t\t//The board changes the board if a 'connection' has been found in the [right] direction. It makes the connection following the game rules.\n\t\tif(foundR==true){\n\t\tfor(int i=column;i<column+checkfurtherR;i++){\n\t\t\t\tboard[row][i]=(piecevalue);\n\t\t\t}\n\t\t}\n\t\twhile(board[row][column-checkfurtherL].equals(oppositepiece)){\n\t\t\tcheckfurtherL++;\n\t\t}\n\t\tif(board[row][column-checkfurtherL].equals(piecevalue)){\n\t\t\tfoundL=true;\n\t\t}\n\t\t//Again, if something is found in the [left] direction, this block of code will be initialized to change to board array (making that 'connection' on the board).\n\t\tif(foundL==true){\n\t\tfor(int i=column;i>column-checkfurtherL;i--){\n\t\t\t\tboard[row][i]=(piecevalue);\n\t\t\t}\n\t\t}\n\t\twhile(board[row+checkfurtherB][column].equals(oppositepiece)){\n\t\t\tcheckfurtherB++;\n\t\t}\n\t\tif(board[row+checkfurtherB][column].equals(piecevalue)){\n\t\t\tfoundB=true;\n\t\t}\n\t\tif(foundB==true){\n\t\tfor(int i=row;i<row+checkfurtherB;i++){\n\t\t\t\tboard[i][column]=(piecevalue);\n\t\t\t}\n\t\t}\n\t\twhile(board[row-checkfurtherT][column].equals(oppositepiece)){\n\t\t\tcheckfurtherT++;\n\t\t}\n\t\tif(board[row-checkfurtherT][column].equals(piecevalue)){\n\t\t\tfoundT=true;\n\t\t}\n\t\tif(foundT==true){\n\t\tfor(int i=row;i>row-checkfurtherT;i--){\n\t\t\t\tboard[i][column]=(piecevalue);\n\t\t\t}\n\t\t}\n\t\t//Diagonal directions are harder and different from the 4 basic directions\n\t\t//It must use dynamic board to 'mark' the coordinates that it must convert to make a proper 'connection'\n\t\twhile(board[row-checkfurtherTR][column+checkfurtherTR].equals(oppositepiece)){\n\t\t\t//each coordinate that is reached will be recorded on the dynamic board\n\t\t\tdynamicboard[row-checkfurtherTR][column+checkfurtherTR]=1;\n\t\t\tcheckfurtherTR++;\n\t\t}\n\t\tif(board[row-checkfurtherTR][column+checkfurtherTR].equals(piecevalue)){\n\t\t\tfoundTR=true;\n\t\t}\n\t\t//Now the board will be changed if an available move has been found\n\t\tif(foundTR==true){\n\t\t\tfor(int x=row;x>row-checkfurtherTR;x--){\n\t\t\t\tfor(int i=column;i<column+checkfurtherTR;i++){\n\t\t\t\t\t//without the use of the dynamic board, some units of the board that should not be converted, will be converted.\n\t\t\t\t\t//(hard to explain)Example, if coordinate places a piece on the Top right of an available move, the connection and change on the board will be performed but [down] and [right] directions will also be inconveniently converted \n\t\t\t\t\tif(dynamicboard[x][i]==1){\n\t\t\t\t\t\tboard[x][i]=(piecevalue);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//dynamicboard must be cleared each time for its next job in 'marking' units in the array to be converted.\n\t\tcleandynamicboard();\n\t\twhile(board[row-checkfurtherTL][column-checkfurtherTL].equals(oppositepiece)){\n\t\t\tdynamicboard[row-checkfurtherTL][column-checkfurtherTL]=1;\n\t\t\tcheckfurtherTL++;\n\t\t}\n\t\tif(board[row-checkfurtherTL][column-checkfurtherTL].equals(piecevalue)){\n\t\t\tfoundTL=true;\n\t\t}\n\t\tif(foundTL==true){\n\t\t\tfor(int x=row;x>row-checkfurtherTL;x--){\n\t\t\t\tfor(int i=column;i>column-checkfurtherTL;i--){\n\t\t\t\t\tif(dynamicboard[x][i]==1){\n\t\t\t\t\t\tboard[x][i]=(piecevalue);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcleandynamicboard();\n\t\twhile(board[row+checkfurtherBL][column-checkfurtherBL].equals(oppositepiece)){\n\t\t\tdynamicboard[row+checkfurtherBL][column-checkfurtherBL]=1;\n\t\t\tcheckfurtherBL++;\n\t\t}\n\t\tif(board[row+checkfurtherBL][column-checkfurtherBL].equals(piecevalue)){\n\t\t\tfoundBL=true;\n\t\t}\n\t\tif(foundBL==true){\n\t\t\tfor(int x=row;x<row+checkfurtherBL;x++){\n\t\t\t\tfor(int i=column;i>column-checkfurtherBL;i--){\n\t\t\t\t\tif(dynamicboard[x][i]==1){\n\t\t\t\t\t\tboard[x][i]=(piecevalue);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcleandynamicboard();\n\t\twhile(board[row+checkfurtherBR][column+checkfurtherBR].equals(oppositepiece)){\n\t\t\tdynamicboard[row+checkfurtherBR][column+checkfurtherBR]=1;\n\t\t\tcheckfurtherBR++;\n\t\t}\n\t\tif(board[row+checkfurtherBR][column+checkfurtherBR].equals(piecevalue)){\n\t\t\tfoundBR=true;\n\t\t}\n\t\tif(foundBR==true){\n\t\t\tfor(int x=row;x<row+checkfurtherBR;x++){\n\t\t\t\tfor(int i=column;i<column+checkfurtherBR;i++){\n\t\t\t\t\tif(dynamicboard[x][i]==1){\n\t\t\t\t\t\tboard[x][i]=(piecevalue);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "private BoardState makeMove(ChessGameNode rootNodeCurr, NewMove nextMoveCurr) {\r\n \tTile[][] currentBoard = rootNodeCurr.getBoardState().getBoard();\r\n \tUnit[] unitListcB = rootNodeCurr.getBoardState().getUnitList();\r\n\r\n \tUnit unitThatMoves = nextMoveCurr.getUnit();\r\n \tMoves moveToMake = nextMoveCurr.getMove();\r\n\r\n \tTile oldSquare = currentBoard[unitThatMoves.getX()][unitThatMoves.getY()];\r\n Tile newSquare = chessBoard[moveToMake.getX()][moveToMake.getY()];\r\n\r\n Unit oldUnit = oldSquare.getPiece();\r\n Unit targetUnit = newSquare.getPiece();\r\n\r\n BoardState newBoard;\r\n\r\n if (targetUnit != null) {\r\n for (int i = 0; i < unitListcB.length; i++) {\r\n if (unitListcB[i] == targetUnit) {\r\n unitListcB[i] = null;\r\n }\r\n } \r\n }\r\n\r\n // update the coordinates of the piece\r\n\t\toldUnit.setCoordinates(moveToMake.getX(),moveToMake.getY());\r\n\t\t// doesn;t update the unit in the unitlist i think\r\n oldSquare.setPiece(null);\r\n newSquare.setPiece(oldUnit);\r\n newBoard = new BoardState(currentBoard, unitListcB);\r\n\r\n \treturn newBoard;\r\n }", "private void undoPosition() {\r\n String undoingBoard = listOfBoards.pop();\r\n listOfMoves.pop();\r\n for (Square sq : map.keySet()) {\r\n char piece = undoingBoard.charAt(sq.index() + 1);\r\n if (piece == '-') {\r\n map.put(sq, EMPTY);\r\n }\r\n if (piece == 'B') {\r\n map.put(sq, BLACK);\r\n }\r\n if (piece == 'W') {\r\n map.put(sq, WHITE);\r\n }\r\n if (piece == 'K') {\r\n map.put(sq, KING);\r\n }\r\n board[sq.col()][sq.row()] = map.get(sq);\r\n }\r\n _moveCount -= 1;\r\n _turn = _turn.opponent();\r\n _repeated = false;\r\n }", "@Override\r\n\tpublic boolean movement(BoardCells[][] chessBoard, Piece targetPiece, int fromX,int fromY,int toX,int toY) {\t\t\r\n\t\t//DEBUG -- System.out.println(\"\"+fromX+fromY+\" \"+toX+toY);\r\n\t\t\r\n\t\tif(fromY == toY){\t\t\t\r\n\t\t\tif(fromX > toX) {\r\n\t\t\t\tfor(int i = fromX-1; i>toX; i--) {\r\n\t\t\t\t\tif(chessBoard[8-fromY][i].getPiece() != null) {\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\r\n\t\t\t} else if (fromX < toX) {\r\n\t\t\t\tfor(int i = fromX+1; i<toX; i++) {\r\n\t\t\t\t\tif(chessBoard[8-fromY][i].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif(getPieceID().equals(\"bR\")) {\r\n\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"bKc\")) {\r\n\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"bK\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif(getPieceID().equals(\"wR\")) {\r\n\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"wKc\")) {\r\n\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"wK\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\tif(fromX == toX) {\t\t\t\t\r\n\t\t\tif(fromY > toY) {\t\r\n\t\t\t\tfor(int i = fromY-1; i>toY; i--) {\r\n\t\t\t\t\tif(chessBoard[8-i][toX].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t} else if (fromY < toY) {\t\t\t\t\r\n\t\t\t\tfor(int i = fromY+1; i<toY; i++) {\t\t\t\t\t\r\n\t\t\t\t\tif(chessBoard[8-i][toX].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tif(getPieceID().equals(\"bR\")) {\r\n\t\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"bKc\")) {\r\n\t\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"bK\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(getPieceID().equals(\"wR\")) {\r\n\t\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"wKc\")) {\r\n\t\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"wK\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\r\n\t\t\treturn true;\t\r\n\t\t}\r\n\t\t\t\t\r\n\t\treturn false;\t\t\r\n\t}", "public static void moveElement(int[][] currentPuzzleState, int row1, int column1, int row2, int column2) {\n int tmp = currentPuzzleState[row1][column1];\n currentPuzzleState[row1][column1] = currentPuzzleState[row2][column2];\n currentPuzzleState[row2][column2] = tmp;\n\t}", "public void setBoardLocation(int boardLocation) {this.boardLocation = boardLocation;}", "public void putPiece(Piece piece, int x, int y)\r\n {\r\n if(isValidSqr(x, y))\r\n {\r\n board[x][y] = piece;\r\n if(piece != null) piece.setLocation(x, y);\r\n }\r\n }", "public void move() {\n\t\tif(right) {\n\t\t\tgoRight();\n\t\t\tstate++;\n\t\t\tif(state > 5) {\n\t\t\t\tstate = 3;\n\t\t\t}\n\t\t}\n\t\telse if(left) {\n\t\t\tgoLeft();\n\t\t\tstate++;\n\t\t\tif(state > 2) {\n\t\t\t\tstate = 0;\n\t\t\t}\n\t\t}\n\t}", "private static int downScore(char piece, State state, int row, int col) {\n\t\tif(row != state.getGrid().length-1 && state.getGrid()[row+1][col] == piece) {\n\t\t\treturn NEXT_TO;\n\t\t}\n\t\telse {\n\t\t\treturn ZERO;\n\t\t}\n\t}", "public static void setPieceInBoard(int[] piece, int pos) {\n for (int f = 0; f < ColorFrames.FRAMES_DIM; ++f) { // For each frame dimension\n int color = piece[f];\n if (color != ColorFrames.NO_FRAME) {\n Panel.printFrame(f, color, pos); // Displays the frame with (f) dimension and (color)\n Panel.clearFrame(f, 0); // Clean the frame of piece.\n pieces[pos - 1][f] = color;\n }\n }\n\n checkGridPos(pos);\n }", "public void updateMoves(){\r\n\t\tthis.moves = getMoves() + 1;\r\n\t}", "public boolean movePiece(int player, int from, int to) {\n\n int piece = players.get(player).getPiece(from);\n\n // PIECELISTENER : Throw PieceEvent to PieceListeners\n for (PieceListener listener : pieceListeners) {\n PieceEvent pieceEvent = new PieceEvent(this, player, piece, from, to);\n listener.pieceMoved(pieceEvent);\n }\n\n if (piece != -1) {\n //last throw was a 6, but player is in starting position\n //end of turn\n if (this.lastThrow == 6 && players.get(player).inStartingPosition() && from == 0) {\n // PLAYERLISTENER : Trigger playerEvent for player that is WAITING\n for (PlayerListener listener : playerListeners) {\n PlayerEvent event = new PlayerEvent(this, players.get(player).getColour(), PlayerEvent.WAITING);\n listener.playerStateChanged(event);\n }\n this.setNextActivePlayer();\n }\n //player didn't throw a 6\n //end of turn\n if (this.lastThrow != 6) {\n // PLAYERLISTENER : Trigger playerEvent for player that is WAITING\n for (PlayerListener listener : playerListeners) {\n PlayerEvent event = new PlayerEvent(this, players.get(player).getColour(), PlayerEvent.WAITING);\n listener.playerStateChanged(event);\n }\n this.setNextActivePlayer();\n }\n\n //Resets the tower info when a tower is split\n if (players.get(player).getPieces().get(piece).towerPos != -1) {\n players.get(player)\n .getPieces()\n .get(piece)\n .setTower(-1);\n\n for (Piece piece2 : players.get(player).pieces) {\n if (piece2.position == from) {\n piece2.setTower(-1);\n }\n }\n }\n\n //Sets tower info when a tower is made\n for (Piece piece2 : players.get(player).pieces) {\n if (piece2.position == to) {\n //Both pieces become a tower\n piece2.setTower(piece2.position);\n players.get(player)\n .getPieces()\n .get(piece)\n .setTower(to);\n }\n }\n\n //move piece\n players.get(player)\n .getPieces()\n .get(piece)\n .setPosition(to);\n\n //set piece to in play\n if (to > 0 && to < 59) {\n players.get(player)\n .getPieces()\n .get(piece)\n .setInPlay(true);\n }\n\n checkIfAnotherPlayerLiesThere(player, to);\n\n if (to == 59) {\n\n if (players.get(player).pieceFinished()) {\n this.status = \"Finished\";\n getWinner();\n }\n }\n\n return true;\n } else {\n //doesn't work\n return false;\n }\n\n }", "@Test\n void RookMoveUp() {\n Board board = new Board(8, 8);\n Piece rook = new Rook(board, 5, 4, 1);\n\n board.getBoard()[5][4] = rook;\n\n board.movePiece(rook, 5, 2);\n\n Assertions.assertEquals(rook, board.getBoard()[5][2]);\n Assertions.assertNull(board.getBoard()[5][4]);\n }", "public void initializeBoard() {\n\n\t\t/*\n\t\t * How the array coordinates align with the actual chess board\n\t\t * (row,col) \n\t\t * (7,0) ... ... ... \n\t\t * (7,7) ... ... ... \n\t\t * ... ... ... \n\t\t * (2,0) ...\n\t\t * (1,0) ... \n\t\t * (0,0) ... ... ... (0,7)\n\t\t */\n\n\t\tboolean hasMoved = false;\n\t\tboolean white = true;\n\t\tboolean black = false;\n\n\t\t// Set white piece row\n\t\tboard[0][0] = new Piece('r', white, hasMoved, 0, 0, PieceArray.A_rookId);\n\t\tboard[0][1] = new Piece('n', white, hasMoved, 0, 1, PieceArray.B_knightId);\n\t\tboard[0][2] = new Piece('b', white, hasMoved, 0, 2, PieceArray.C_bishopId);\n\t\tboard[0][3] = new Piece('q', white, hasMoved, 0, 3, PieceArray.D_queenId);\n\t\tboard[0][4] = new Piece('k', white, hasMoved, 0, 4, PieceArray.E_kingId);\n\t\tboard[0][5] = new Piece('b', white, hasMoved, 0, 5, PieceArray.F_bishopId);\n\t\tboard[0][6] = new Piece('n', white, hasMoved, 0, 6, PieceArray.G_knightId);\n\t\tboard[0][7] = new Piece('r', white, hasMoved, 0, 7, PieceArray.H_rookId);\n\n\t\t// Set white pawns\n\t\tfor (int i = 0; i < 8; i++) {\n\t\t\tboard[1][i] = new Piece('p', white, hasMoved, 1, i, i + 8);\n\t\t}\n\n\t\t// Set empty rows\n\t\tfor (int row = 2; row < 6; row++)\n\t\t\tfor (int col = 0; col < 8; col++)\n\t\t\t\tboard[row][col] = null;\n\n\t\t// Set black pawns\n\t\tfor (int i = 0; i < 8; i++) {\n\t\t\tboard[6][i] = new Piece('p', black, hasMoved, 6, i, i+8);\n\t\t}\n\n\t\t// Set black piece row\n\t\tboard[7][0] = new Piece('r', black, hasMoved, 7, 0, PieceArray.A_rookId);\n\t\tboard[7][1] = new Piece('n', black, hasMoved, 7, 1, PieceArray.B_knightId);\n\t\tboard[7][2] = new Piece('b', black, hasMoved, 7, 2, PieceArray.C_bishopId);\n\t\tboard[7][3] = new Piece('q', black, hasMoved, 7, 3, PieceArray.D_queenId);\n\t\tboard[7][4] = new Piece('k', black, hasMoved, 7, 4, PieceArray.E_kingId);\n\t\tboard[7][5] = new Piece('b', black, hasMoved, 7, 5, PieceArray.F_bishopId);\n\t\tboard[7][6] = new Piece('n', black, hasMoved, 7, 6, PieceArray.G_knightId);\n\t\tboard[7][7] = new Piece('r', black, hasMoved, 7, 7, PieceArray.H_rookId);\n\t}", "private void advance(Board board, List<Move> moves) {\n int x = location.x;\n int y = location.y;\n \n Piece pc;\n Point pt;\n int move;\n \n if (color == Color.White)\n move = -1;\n else\n move = 1;\n \n pt = new Point(x, y + move);\n if (board.validLocation(pt)) {\n pc = board.getPieceAt(pt); \n if(pc == null) {\n moves.add(new Move(this, pt, pc)); \n \n pt = new Point(x, y + move * 2);\n if (board.validLocation(pt)) {\n pc = board.getPieceAt(pt);\n if(pc == null && numMoves == 0)\n moves.add(new Move(this, pt, pc));\n }\n } \n }\n }", "public void movePiece(Square from, Square dest)\r\n {\r\n if(from.equals(dest)) return;\r\n if(isValidSqr(from) && isValidSqr(dest) && hasPiece(from))\r\n {\r\n Piece movedPiece = board[from.x][from.y];\r\n board[from.x][from.y] = null;\r\n board[dest.x][dest.y] = null;\r\n movedPiece.setLocation(dest);\r\n board[dest.x][dest.y] = movedPiece;\r\n }\r\n }", "private void moveComputer(String[][] gameState) {\n possiblemoves possibleMoves = new possiblemoves();\r\n String moves = possibleMoves.calculateMoves(gameState);\r\n String[] arrMoves = moves.split(\"\\\\r?\\\\n\");\r\n int randIndex = (int) (Math.random() * arrMoves.length);\r\n // Choose one of the possible moves at random\r\n String choosenSpace = arrMoves[randIndex];\r\n int xPosition = Character.getNumericValue(choosenSpace.charAt(0));\r\n int yPosition = Character.getNumericValue(choosenSpace.charAt(2));\r\n gameState[xPosition][yPosition] = \"o\";\r\n }", "@Override\n public void makeMove(int player, Coordinate startCoordinate, Coordinate endCoordinate) throws InvalidMoveException {\n GamePiece curr = myGamePieces.get(startCoordinate.getRow()).get(startCoordinate.getCol());\n Coordinate oldPos = curr.getPosition();\n List<GamePiece> neighbors = getNeighbors(curr);\n if (curr.calculateAllPossibleMoves(neighbors,player).contains(endCoordinate)) {\n curr.makeMove(endCoordinate, neighbors, player);\n doesTurnChange = curr.changeTurnAfterMove();\n if(curr.getPosition() != oldPos){\n Coordinate currPosition = curr.getPosition();\n GamePiece switchedWith = myGamePieces.get(currPosition.getRow()).get(currPosition.getCol());\n myGamePieces.get(oldPos.getRow()).set(oldPos.getCol(), switchedWith);\n myGamePieces.get(currPosition.getRow()).set(currPosition.getCol(), curr);\n }\n } else {\n throw new InvalidMoveException(\"Your move to \" + endCoordinate.toString() + \" is invalid\");\n }\n }", "public void move()\n {\n if (!alive) {\n return;\n }\n\n if (speedTimer > 0) {\n speedTimer --;\n } else if (speedTimer == 0 && speed != DEFAULT_SPEED) {\n speed = DEFAULT_SPEED;\n }\n\n Location last = playerLocations.get(playerLocations.size()-1);\n Location next = null;\n\n // For the speed, iterate x blocks between last and next\n\n if (direction == UPKEY)\n {\n next = getLocation(last.getX(), (int)(last.getY() - speed * getPixelSize()));\n } else if (direction == DOWNKEY)\n {\n next = getLocation(last.getX(), (int)(last.getY() + speed * getPixelSize()));\n } else if (direction == LEFTKEY)\n {\n next = getLocation((int)(last.getX() - speed * getPixelSize()), last.getY());\n } else if (direction == RIGHTKEY)\n {\n next = getLocation((int)(last.getX() + speed * getPixelSize()), last.getY());\n }\n\n ArrayList<Location> line = getLine(last, next);\n\n if (line.size() == 0) {\n gameOver();\n return;\n }\n\n for (Location loc : line) {\n if (checkCrash (loc)) {\n gameOver();\n return;\n } else {\n // Former bug: For some reason when a player eats a powerup a hole appears in the line where the powerup was.\n Location l2 = getLocation(loc.getX(), loc.getY());\n l2.setType(LocationType.PLAYER);\n l2.setColor(this.col);\n\n playerLocations.add(l2);\n getGridCache().add(l2);\n }\n }\n }", "private void newPiece() {\n curPiece.setRandomShape();\n//compute the initial curX and curY values \n curX = BOARD_WIDTH / 2 + 1;\n curY = BOARD_HEIGHT - 1 + curPiece.minY();\n//if a piece reaches the top and cannot drop any more piece\n if (!tryMove(curPiece, curX, curY)) {\n//cancel timer and display game over\n curPiece.setShape(Tetrominoe.NoShape);\n timer.cancel();\n isStarted = false;\n statusbar.setText(\"Game over\");\n }\n }", "public void move() {\n char move;\n\n do {\n System.out.println(\"Move snake: (wasd)\");\n move = scan.nextLine().charAt(0);\n } while(move != 'a' && move != 'w' && move != 's' && move != 'd');\n \n\n switch (move) {\n case 'w':\n if(board[snakePartList.get(0).getSnakePartRowsOld()-1][snakePartList.get(0).getSnakePartCollsOld()] != '*' ) {\n if(board[snakePartList.get(0).getSnakePartRowsOld()-1][snakePartList.get(0).getSnakePartCollsOld()] == '@') {\n eatApple();\n }\n\n if(board[snakePartList.get(0).getSnakePartRowsOld()-1][snakePartList.get(0).getSnakePartCollsOld()] == 'S') {\n keepMoving = false;\n }\n\n for(int i = 0; i < snakePartList.size(); i++) {\n if(i != 0) {\n snakePartList.get(i).setSnakePartRowsNew(snakePartList.get(i-1).getSnakePartRowsOld());\n snakePartList.get(i).setSnakePartCollsNew(snakePartList.get(i-1).getSnakePartCollsOld());\n } else {\n snakePartList.get(i).setSnakePartRowsNew(snakePartList.get(i).getSnakePartRowsOld()-1);\n }\n }\n\n updateBoard();\n\n for(int i = 0; i < snakePartList.size(); i++) {\n snakePartList.get(i).updateOldPlace();\n }\n \n \n } else {\n keepMoving = false;\n }\n break;\n\n case 'a':\n if(board[snakePartList.get(0).getSnakePartRowsOld()][snakePartList.get(0).getSnakePartCollsOld()-1] != '*' ) {\n if( board[snakePartList.get(0).getSnakePartRowsOld()][snakePartList.get(0).getSnakePartCollsOld()-1] == '@') {\n eatApple();\n }\n if( board[snakePartList.get(0).getSnakePartRowsOld()][snakePartList.get(0).getSnakePartCollsOld()-1] == 'S') {\n keepMoving = false;\n }\n for(int i = 0; i < snakePartList.size(); i++) {\n if(i != 0) {\n snakePartList.get(i).setSnakePartCollsNew(snakePartList.get(i-1).getSnakePartCollsOld());\n snakePartList.get(i).setSnakePartRowsNew(snakePartList.get(i-1).getSnakePartRowsOld());\n } else {\n snakePartList.get(i).setSnakePartCollsNew(snakePartList.get(i).getSnakePartCollsOld()-1);\n }\n }\n updateBoard();\n\n for(int i = 0; i < snakePartList.size(); i++) {\n snakePartList.get(i).updateOldPlace();\n }\n\n \n } else {\n keepMoving = false;\n }\n break;\n\n case 's':\n if(board[snakePartList.get(0).getSnakePartRowsOld()+1][snakePartList.get(0).getSnakePartCollsOld()] != '*') {\n if( board[snakePartList.get(0).getSnakePartRowsOld()+1][snakePartList.get(0).getSnakePartCollsOld()] == '@') {\n eatApple();\n }\n if( board[snakePartList.get(0).getSnakePartRowsOld()+1][snakePartList.get(0).getSnakePartCollsOld()] == 'S') {\n keepMoving = false;\n }\n for(int i = 0; i < snakePartList.size(); i++) {\n if(i != 0) {\n snakePartList.get(i).setSnakePartRowsNew(snakePartList.get(i-1).getSnakePartRowsOld());\n snakePartList.get(i).setSnakePartCollsNew(snakePartList.get(i-1).getSnakePartCollsOld());\n } else {\n snakePartList.get(i).setSnakePartRowsNew(snakePartList.get(i).getSnakePartRowsOld()+1);\n }\n }\n updateBoard();\n\n for(int i = 0; i < snakePartList.size(); i++) {\n snakePartList.get(i).updateOldPlace();\n }\n\n \n } else {\n keepMoving = false;\n }\n break;\n\n case 'd':\n if(board[snakePartList.get(0).getSnakePartRowsOld()][snakePartList.get(0).getSnakePartCollsOld()+1] != '*') {\n if(board[snakePartList.get(0).getSnakePartRowsOld()][snakePartList.get(0).getSnakePartCollsOld()+1] == '@') {\n eatApple();\n }\n if(board[snakePartList.get(0).getSnakePartRowsOld()][snakePartList.get(0).getSnakePartCollsOld()+1] == 'S') {\n keepMoving = false;\n }\n for(int i = 0; i < snakePartList.size(); i++) {\n if(i != 0) {\n snakePartList.get(i).setSnakePartCollsNew(snakePartList.get(i-1).getSnakePartCollsOld());\n snakePartList.get(i).setSnakePartRowsNew(snakePartList.get(i-1).getSnakePartRowsOld());\n } else {\n snakePartList.get(i).setSnakePartCollsNew(snakePartList.get(i).getSnakePartCollsOld()+1);\n }\n }\n updateBoard();\n \n for(int i = 0; i < snakePartList.size(); i++) {\n snakePartList.get(i).updateOldPlace();\n }\n\n \n } else {\n keepMoving = false;\n }\n break;\n }\n }", "void drawCurrentToBoard () {\n board.clearTemp();\n for (int r = 0; r < currentPiece.height; ++r)\n for (int c = 0; c < currentPiece.width; ++c)\n if (currentPiece.blocks[r][c] == 1)\n board.addBlock(new Block(currentPiece.color), r + currentRow, c + currentColumn);\n }", "public void move(int side){\n\t\tPoint test_location = new Point(pieceOrigin);\n\t\ttest_location.x += side;\n\t\tif(!collides(test_location, currentPiece)){\n\t\t\tpieceOrigin.x += side;\n\t\t}\n\t\trepaint();\n\t}", "public void initializeDebugBoard() {\n\t\tboolean hasNotMoved = false;\n\t\tboolean hasMoved = true;\n\t\tboolean white = true;\n\t\tboolean black = false;\n\n\t\t// Set empty rows\n\t\tfor (int row = 0; row < 8; row++)\n\t\t\tfor (int col = 0; col < 8; col++)\n\t\t\t\tboard[row][col] = null;\n\n\t\tboard[5][4] = new Piece('k', white, hasMoved, 5, 4, PieceArray.E_kingId);\n//\t\tboard[1][4] = new Piece(\"rook\", white, hasMoved, 1, 4);\n\t\tboard[2][2] = new Piece('q', black, hasMoved, 2, 2, PieceArray.A_rookId);\n//\t\tboard[3][2] = new Piece('q', black, hasMoved, 3, 2, PieceArray.H_rookId);\n\t\t\n\n\t\tboard[0][0] = new Piece('k', black, hasMoved, 0, 0, PieceArray.E_kingId);\n//\t\tboard[7][7] = new Piece('r', black, hasNotMoved, 7, 7, PieceArray.A_rookId);\n//\t\tboard[6][7] = new Piece('p', black, hasNotMoved, 6, 7, PieceArray.A_pawnId);\n//\t\tboard[6][6] = new Piece('p', black, hasNotMoved, 6, 6, PieceArray.B_pawnId);\n//\t\tboard[6][5] = new Piece('p', black, hasNotMoved, 6, 5, PieceArray.C_pawnId);\n//\t\tboard[6][4] = new Piece('p', black, hasNotMoved, 6, 4, PieceArray.D_pawnId);\n\t\n//\t\tboard[6][6] = new Piece(\"pawn\", black, hasMoved, 6, 6);\n//\t\tboard[6][7] = new Piece(\"pawn\", black, hasMoved, 6, 7);\n//\t\tboard[6][4] = new Piece(\"pawn\", black, hasMoved, 6, 4);\n//\t\t\t\n//\t\t\n//\t\tboard[4][4] = new Piece(\"pawn\", black, hasMoved, 4,4);\n//\t\tboard[3][5] = new Piece(\"rook\", white,hasMoved,3,5);\n//\t\tboard[1][7] = new Piece(\"pawn\",black,hasMoved,1,7);\n\n\t}", "public void setNewPiece(){\n\t\tcurrentPiece = Pentominoes.Pentomino_array[this.next_piece_index];\n\t\tcurrentColor = Pentominoes.color_array[this.next_piece_colour];\n\t\tpieceOrigin = new Point(6, 2);\n\t}", "private void moveTile()\n {\n int[] moveIndices = null;\n \n int sourceRow = moveIndices[0];\n int sourceCol = moveIndices[1];\n int destRow = moveIndices[2] - 1;\n int destCol = moveIndices[3];\n \n if (sourceRow == 0) \n {\n try\n {\n game.playTileFromHand(sourceCol, destRow, destCol);\n }\n catch(ArrayIndexOutOfBoundsException ex)\n {\n // TODO: ConsoleUtils.message(\"Unable to complete your play, wrong indices!\");\n }\n }\n else\n {\n sourceRow--;\n try\n {\n game.moveTileInBoard(sourceRow, sourceCol, destRow, destCol); \n }\n catch(ArrayIndexOutOfBoundsException ex)\n {\n // TODO: ConsoleUtils.message(\"Unable to complete your play, wrong indices!\");\n }\n }\n }", "public void move() {\n\t\tGrid<Actor> gr = getGrid();\n\t\tif (gr == null) {\n\t\t\treturn;\n\t\t}\n\t\tLocation loc = getLocation();\n\t\tLocation next = loc.getAdjacentLocation(getDirection());\n\t\t\n\t\tLocation next2 = next.getAdjacentLocation(getDirection());\n\t\tif (gr.isValid(next2)) {\n\t\t\tmoveTo(next2);\n\t\t} else {\n\t\t\tremoveSelfFromGrid();\n\t\t}\n\t}", "public void move() {\n\n\tGrid<Actor> gr = getGrid();\n\tif (gr == null) {\n\n\t return;\n\t}\n\n\tLocation loc = getLocation();\n\tif (gr.isValid(next)) {\n\n\t setDirection(loc.getDirectionToward(next));\n\t moveTo(next);\n\n\t int counter = dirCounter.get(getDirection());\n\t dirCounter.put(getDirection(), ++counter);\n\n\t if (!crossLocation.isEmpty()) {\n\t\t\n\t\t//reset the node of previously occupied location\n\t\tArrayList<Location> lastNode = crossLocation.pop();\n\t\tlastNode.add(next);\n\t\tcrossLocation.push(lastNode);\t\n\t\t\n\t\t//push the node of current location\n\t\tArrayList<Location> currentNode = new ArrayList<Location>();\n\t\tcurrentNode.add(getLocation());\n\t\tcurrentNode.add(loc);\n\n\t\tcrossLocation.push(currentNode);\t\n\t }\n\n\t} else {\n\t removeSelfFromGrid();\n\t}\n\n\tFlower flower = new Flower(getColor());\n\tflower.putSelfInGrid(gr, loc);\n\t\n\tlast = loc;\n\t\t\n }", "boolean updateBoard(String currentPlayerTurn, String newBoard);", "@Override\n\tpublic void actionPerformed(ActionEvent e) {\n\t\t// Toggles the active square and updates the boundary\n\t\tMove m = new ToggleSquareMove(level.getBoard().getActiveSquare(),level);\n\t\tif(m.doMove()) {\n\t\t\tbuilder.pushMove(m, false);\t\n\t\t}\n\t\t\n\t\tboardView.repaint();\n\t}", "public static void setBoardStateSquare(int file, int rank, String piece) {\n boardState[rank][file] = piece;\n }", "@Override\n public void updateCellState(CellPosition cellPosition, CellState cellState) {\n grid.replace(cellPosition, cellState);\n }", "void changepos(MouseEvent e, pieces chessPiece) \n { \n for(int beta : chessPiece.movnum)\n { \n if (chessPiece.color == 0 && e.getSource()== panel[beta-1 ]&& chessPiece.select == true && Checkerboard.allWhitePositions.contains(beta-1) == false)\n {\n if(this.getPiece(beta-1) != null)\n { \n getPiece(beta-1).alive = false;\n \n \n \n panel[beta-1].removeAll();/*getPiece(beta-1).position = 64;*/\n }\n chessPiece.position = beta-1;\n chessPiece.movnum.clear();\n chessPiece.mov.clear();\n chessPiece.select = false;\n chessPiece.timesMoved++;\n whiteToPlay = false;\n }\n else if (chessPiece.color == 1 && e.getSource()== panel[beta-1 ]&& chessPiece.select == true && Checkerboard.allBlackPositions.contains(beta-1) == false)\n {\n if(this.getPiece(beta-1) != null)\n { \n getPiece(beta-1).alive = false; \n panel[beta-1].removeAll();/*getPiece(beta-1).position = 64;*/}\n chessPiece.position = beta-1;\n chessPiece.movnum.clear();\n chessPiece.mov.clear();\n chessPiece.select = false;\n chessPiece.timesMoved++;\n whiteToPlay = true;\n }\n }//for ends\n \n }", "public void move() {\n\t\tif ( board.getLevel() == 5 )\n\t\t\tmovementIndex = ( movementIndex + 1 ) % movement.length;\n\t}", "public void eatPiece(Point pos){\r\n // Update Board Numbers\r\n if(isRed(pos)){\r\n if(isQueen(pos))\r\n model.setRedQueenCount(-1);\r\n else \r\n model.setRedCount(-1);\r\n } else {\r\n if(isQueen(pos))\r\n model.setBlackQueenCount(-1);\r\n else\r\n model.setBlackCount(-1);\r\n }\r\n // Update Rival Piece Number\r\n model.getRivalPlayer().setPieceNumber(-1);\r\n // Update Current Player Eated Pieces\r\n model.getCurrentPlayer().setPieceEated(+1);\r\n // Make Eat\r\n model.setValueAt(pos,Cells.BLACK_FLOOR);\r\n }", "@Override\n public void drawValidMove() {\n if(this.getPlayer().getPlayerID() % 2 != 0) {\n //Pawn can move one space forwards if no piece is in front\n if (board.getSquare(x-1, y).getPiece()== null) {\n board.getSquare(x-1, y).drawOutline();\n }\n \n //if first move, pawn can move 2 spaces forward\n if (!hasMoved && board.getSquare(x-2, y).getPiece() == null && board.getSquare(x-1, y).getPiece() == null) {\n board.getSquare(x-2, y).drawOutline();\n }\n \n //If there is an enemy piece in the diagonal forward square of the pawn, the pawn can move (capture the piece)\n if (y-1 > 0) { //ensures no arrayoutofbounds error\n if (board.getSquare(x-1, y-1) != null && board.getSquare(x-1, y-1).getPiece() != null &&\n board.getSquare(x-1, y-1).getPiece().getPlayer() != this.getPlayer()) {\n board.getSquare(x-1, y-1).drawOutline();\n }\n }\n \n if(y+1<SIZE) { //ensures no arrayoutofbounds error\n if (board.getSquare(x-1, y+1) != null && board.getSquare(x-1, y+1).getPiece() != null &&\n board.getSquare(x-1, y+1).getPiece().getPlayer() != this.getPlayer() ) {\n board.getSquare(x-1, y+1).drawOutline();\n }\n }\n \n System.out.println(\"\");\n //En passant\n if (y - 1 > 0) {\n \n System.out.println();\n if (board.getSquare(x, y-1).getPiece() != null) { \n System.out.println(\"the piece's enPassant is: \" + board.getSquare(x, y-1).getPiece().getEnPassant());\n System.out.println(\"The game's turn counter is: \" + board.getTurnCounter());\n }\n else {\n System.out.println(\"Null piece when checking for en passent.\");\n }\n \n if (board.getSquare(x, y-1).getPiece() != null && board.getSquare(x, y-1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y-1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x-1, y-1).drawOutline();\n board.getSquare(x-1, y-1).setEnPassent(true);\n }\n }\n \n if (y + 1 < SIZE) {\n if (board.getSquare(x, y+1).getPiece() != null && board.getSquare(x, y+1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y+1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x-1, y+1).drawOutline();\n board.getSquare(x-1, y+1).setEnPassent(true);\n }\n }\n }\n \n //If this pawn belongs to player 2:\n else {\n \n if (board.getSquare(x+1, y).getPiece() == null) {\n board.getSquare(x+1, y).drawOutline();\n }\n \n //if first move, pawn can move 2 spaces forward\n if (!hasMoved && board.getSquare(x+2, y).getPiece() == null && board.getSquare(x+1, y).getPiece() == null) {\n board.getSquare(x+2, y).drawOutline();\n \n }\n \n if(y-1 > 0) {\n if (board.getSquare(x+1, y-1) != null && board.getSquare(x+1, y-1).getPiece() != null &&\n board.getSquare(x+1, y-1).getPiece().getPlayer() != this.getPlayer() ) {\n board.getSquare(x+1, y-1).drawOutline();\n }\n }\n \n if(y+1 < SIZE) {\n if (board.getSquare(x+1, y+1) != null && board.getSquare(x+1, y+1).getPiece() != null &&\n board.getSquare(x+1, y+1).getPiece().getPlayer() != this.getPlayer()) {\n board.getSquare(x+1, y+1).drawOutline();\n }\n }\n \n //En passant\n if (y - 1 > 0) {\n if (board.getSquare(x, y-1).getPiece() != null &&board.getSquare(x, y-1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y-1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x+1, y-1).drawOutline();\n board.getSquare(x+1, y-1).setEnPassent(true);\n }\n }\n \n if (y + 1 < SIZE) {\n if (board.getSquare(x, y+1).getPiece() != null && board.getSquare(x, y+1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y+1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x+1, y+1).drawOutline();\n board.getSquare(x+1, y+1).setEnPassent(true);\n }\n }\n }\n }", "public synchronized void moveDown(){\n if (!this.isAtBottom()){\n for (int j = 1; j < 25; j++){\n for (int i = 1; i < 13; i++){\n if (this.movable[i][j]){\n this.map[i][j - 1] = this.map[i][j];\n this.movable[i][j - 1] = this.movable[i][j];\n this.colors[i][j - 1] = this.colors[i][j];\n\n this.map[i][j] = false;\n this.movable[i][j] = false;\n this.colors[i][j] = null;\n\n }\n }\n }\n }\n this.piecePositionY--;\n repaint();\n }", "@Override\r\n\tpublic void actionPerformed(ActionEvent e) {\n\t\tif (myBoard.myGame.status != GameStatus.inProgress) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t//if starting square is selected\r\n\t\tif (myBoard.selectedSquare!=null) {\r\n\t\t\t//create list of valid moves\r\n\t\t\tArrayList<Move> validMovesList = myBoard.selectedSquare.mySB.validMoves;\r\n\t\t\t//remove highlight from board\r\n\t\t\tint size = validMovesList.size();\r\n\t\t\tfor (int i = 0; i < size; i++) {\r\n\t\t\t\tSquareButton sb = validMovesList.get(i).end.mySB;\r\n\t\t\t\tsb.setBackground(sb.defaultColor);\r\n\t\t\t}\r\n\t\t\t//making sure we do not move to the same square\r\n\t\t\tif (myBoard.selectedSquare!=mySquare) {\r\n\t\t\t\tMove attemptedMove = new Move(myBoard.selectedSquare, mySquare, myBoard.selectedSquare.myPiece.colour);\r\n\t\t\t\tSystem.out.println(\"Attempted move is: \" + attemptedMove);\r\n\t\t\t\t\r\n\t\t\t\t//check if attempted move is valid\r\n\t\t\t\tif(validMovesList.contains(attemptedMove)) {\r\n\t\t\t\t\tMove moveFound = validMovesList.get(validMovesList.indexOf(attemptedMove));\r\n\t\t\t\t\tSystem.out.println(\"Move Found Type: \" + moveFound.moveType);\r\n\t\t\t\t\tmyBoard.performMove(moveFound);\r\n\t\t\t\t\t//check if the move is legal - if so, undo the move\r\n\t\t\t\t\tif (myBoard.isKingThreatened()) {\r\n\t\t\t\t\t\tmyBoard.undoMove(myBoard.moveStack.pop());\r\n\t\t\t\t\t} else { //the player has made a legal move\r\n\t\t\t\t\t\tmyBoard.swapActiveColour();\r\n\t\t\t\t\t\t//determine if we are playing against AI\r\n\t\t\t\t\t\tif (Game.myAILevel != AILevel.off) {\r\n\t\t\t\t\t\t\tmyBoard.myGame.myAI.makeMove();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n//\t\t\t\t\t//debugging\r\n//\t\t\t\t\tSystem.out.println(\"Enemy's List - My active colour was: \" + myBoard.activeColour);\r\n//\t\t\t\t\tArrayList<Square> result = enemyValidSquares();\r\n//\t\t\t\t\tfor (Square s: result) {\r\n//\t\t\t\t\t\ts.mySB.setBackground(Color.ORANGE);\r\n//\t\t\t\t\t}\r\n//\t\t\t\t\tmyBoard.whiteKingSquare.mySB.setBackground(Color.PINK);\r\n//\t\t\t\t\tmyBoard.blackKingSquare.mySB.setBackground(Color.magenta);\r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n//\t\t\t\t\tshowLists();\r\n\t\t\t\t\t//check if my opponent is checkmated by this move\r\n\t\t\t\t\t//if opponent is in check\r\n\t\t\t\t\tif (myBoard.isKingThreatened()) {\r\n\t\t\t\t\t\t//try every possible move\r\n\t\t\t\t\t\tif (myBoard.isCheckmate()) {\r\n\t\t\t\t\t\t\tColour winningColour = (myBoard.activeColour == Colour.WHITE) ? Colour.BLACK : Colour.WHITE;\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tJOptionPane.showMessageDialog(new JFrame(), myBoard.activeColour + \" is checkmated! \\n\" + winningColour + \" wins!\");\r\n\t\t\t\t\t\t\tmyBoard.myGame.status = (winningColour == Colour.WHITE) ? GameStatus.winWhite : GameStatus.winBlack;\r\n\t\t\t\t\t\t\t//turn off all buttons in the east panel\r\n\t\t\t\t\t\t\tfor (Component comp : myBoard.myGame.myBoardHolder.myEastPanel.getComponents()) {\r\n\t\t\t\t\t\t\t\tcomp.setEnabled(false);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tSystem.out.println(\"Checkmate!\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} \r\n//\t\t\t\t\t//end of debug\r\n\t\t\t\t\t\r\n\r\n\t\t\t\t\t\r\n\t\t\t\t} else {\r\n\t\t\t\t\t//unselect the square\r\n\t\t\t\t\tmyBoard.selectedSquare = null;\r\n\t\t\t\t\tSystem.out.println(\"Invalid Move\");\r\n\t\t\t\t\tfor (int i = 0; i < size; i++) {\r\n\t\t\t\t\t\tSystem.out.println(validMovesList.get(i));\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tSystem.out.print(myBoard);\r\n\t\t\t}\r\n\t\t\tmyBoard.selectedSquare = null;\r\n\t\t\tif (myBoard.myGame.status == GameStatus.inProgress) myBoard.myGame.myBoardHolder.myEastPanel.getComponent(0).setEnabled(true);\r\n\t\t\t\r\n\t\t}\r\n\t\t//if starting square is not selected\r\n\t\telse {\r\n\t\t\t//debugging\r\n//\t\t\tshowLists();\r\n\t\t\t//end of debug\r\n\t\t\tif ((mySquare.myPiece!=null) && (mySquare.myPiece.colour == myBoard.activeColour)) {\r\n\t\t\t\tmyBoard.selectedSquare = mySquare;\r\n\t\t\t\tSystem.out.println(\"Selected starting square: \" + myBoard.selectedSquare.row + \", \" + myBoard.selectedSquare.col);\r\n\t\t\t\t//generate valid moves\r\n\t\t\t\tvalidMoves = getValidMoves();\r\n\t\t\t\t\r\n\t\t\t\t//highlight valid squares if starting square has not been selected yet\r\n\t\t\t\tint size = validMoves.size();\r\n\t\t\t\tfor (int i = 0; i < size; i++) {\r\n\t\t\t\t\tSquareButton sb = validMoves.get(i).end.mySB;\r\n\t\t\t\t\tsb.setBackground(sb.getBackground().brighter());\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tmyBoard.myGame.myBoardHolder.myEastPanel.getComponent(0).setEnabled(false);\r\n\t\t}\r\n\t}", "public void changeBoard(Board board){\n this.board = board;\n }", "public void setPiece(Piece newPiece) {\n this.piece = newPiece;\n }", "public void updatemove() {\n\t\tmove = new Movement(getX(), getY(),dungeon,this);\n\t\t//System.out.println(\"Updated\");\n\t\tnotifys();\n\t\tif(this.getInvincible()) {\n\t\t\tsteptracer++;\n\t\t}\n\t\tdungeon.checkGoal();\n\t}", "@Test\n void RookMoveDown() {\n Board board = new Board(8, 8);\n Piece rook = new Rook(board, 4, 4, 1);\n\n board.getBoard()[4][4] = rook;\n\n board.movePiece(rook, 4, 7);\n\n Assertions.assertEquals(rook, board.getBoard()[4][7]);\n Assertions.assertNull(board.getBoard()[4][4]);\n }", "private void mediumMove(Board board) {\n\t}", "protected void move()\n {\n // Find a location to move to.\n Debug.print(\"Fish \" + toString() + \" attempting to move. \");\n Location nextLoc = nextLocation();\n\n // If the next location is different, move there.\n if ( ! nextLoc.equals(location()) )\n {\n // Move to new location.\n Location oldLoc = location();\n changeLocation(nextLoc);\n\n // Update direction in case fish had to turn to move.\n Direction newDir = environment().getDirection(oldLoc, nextLoc);\n changeDirection(newDir);\n Debug.println(\" Moves to \" + location() + direction());\n }\n else\n Debug.println(\" Does not move.\");\n }", "private void nextPiece() {\n if (_c == M && _r <= M) {\n _c = 1;\n _r++;\n } else if (_r > M) {\n _move = null;\n } else {\n _c++;\n }\n }", "public void makeMove (int row,int col,int disc){\n gameboard[row][col] = disc;\n effectMove(gameboard,row,col,disc);\n lastMove =new Move(row,col);\n lastDiscPlayed =disc;\n }", "public void move() {\n if (!canMove) {\n return;\n }\n int moveX = currDirection == EAST ? PACE : currDirection == WEST ? -PACE : 0;\n int moveY = currDirection == NORTH ? PACE : currDirection == SOUTH ? -PACE : 0;\n if (grid == null || grid.isOutside(currX + moveX, currY + moveY)) {\n return;\n }\n currX += moveX;\n currY += moveY;\n }", "private void swapPosition(int curRow, int curCol, int newRow, int newCol){\n gameBoard[newRow][newCol] = gameBoard[curRow][curCol];\n gameBoard[curRow][curCol] = new EmptyPiece();\n }", "public void play() {\r\n _board = new Board();\r\n _command = new LoaGUI(\"Lines of Action\", this);\r\n\r\n while (true) {\r\n int playerInd = _board.turn().ordinal();\r\n if (_playing) {\r\n if (_board.gameOver()) {\r\n announceWinner();\r\n _playing = false;\r\n continue;\r\n }\r\n Move next = _players[playerInd].makeMove();\r\n System.out.println(\"The move is get\");\r\n if (next != null) {\r\n assert _board.isLegal(next);\r\n _board.makeMove(next);\r\n _command.repaint();\r\n System.out.println(\"Repaint\");\r\n if (_board.gameOver()) {\r\n announceWinner();\r\n _playing = false;\r\n }\r\n }\r\n } else {\r\n try {\r\n Thread.sleep(magic2);\r\n } catch (InterruptedException ex) {\r\n return;\r\n }\r\n }\r\n }\r\n }", "public void move() {\n this.pposX = this.posX;\n this.pposY = this.posY;\n this.posX = newPosX;\n this.posY = newPosY;\n }", "public void move(int fromRow, int fromColumn, int toRow, int toColumn) {\n ImmutablePair<Integer, Integer> from = new ImmutablePair<>(fromRow, fromColumn);\n ImmutablePair<Integer, Integer> to = new ImmutablePair<>(toRow, toColumn);\n // Step 2. Generating move action\n ShiftChipAction moveAction = new ShiftChipAction(getPlayer(), from, to);\n // Step 3. Actually performing action\n perform(moveAction);\n }", "@Override\n\t\tpublic void update(Graphics g) {\n\t\t\t\n\t\t\tImage pieceImg = null;\n\t\t\tif (board.square(row,column).isOccupied()) {\n\t\t\t\tint index = board.square(row,column).piece().imageIndex();\n\t\t\t\tpieceImg = pieceImages[index];\n\t\t\t}\n\t\t\tif (lightSquare)\n\t\t\t\t{ setIcon(new ImageIcon(combine(pieceImg, lightSquareImg))); }\n\t\t\telse\n\t\t\t\t{ setIcon(new ImageIcon(combine(pieceImg, darkSquareImg))); }\n\t\t}", "public void applyConvertedMove(String move) {\n\n\t\tString[] moveParts = move.split(\";\");\n\n\t\tint fromRow = Integer.parseInt(moveParts[0].charAt(0) + \"\");\n\t\tint fromCol = Integer.parseInt(moveParts[0].charAt(1) + \"\");\n\n\t\tint toRow = Integer.parseInt(moveParts[1].charAt(0) + \"\");\n\t\tint toCol = Integer.parseInt(moveParts[1].charAt(1) + \"\");\n\n\t\tint piece = board[fromRow][fromCol];//Integer.parseInt(moveParts[2]);\n\t\tint pieceType = Math.abs(board[fromRow][fromCol]);\n\t\tint team = Math.round(Math.signum(board[fromRow][fromCol]));\n\n\t\tboolean doResetEnpassant = true;\n\n\t\tif (pieceType == 1) { //If this is a pawn\n\t\t\tif (Math.abs(board[toRow][toCol]) == 7) { //If it is moving onto an enpassant stored tile\n\t\t\t\tboard[toRow + board[toRow][toCol]/7][toCol] = 0; //Kill the pawn that produced the enpassant tile\n\t\t\t} else if (Math.abs(fromRow - toRow) == 2) { //If it just did the double move thing\n\t\t\t\t//Reset the current enpassant tile\n\t\t\t\tresetEnpassant(team);\n\t\t\t\tdoResetEnpassant = false;\n\n\t\t\t\t//Set an empassant tile\n\t\t\t\tboard[(toRow + fromRow)/2][toCol] = 7 * team;\n\t\t\t\tenpassantCol = toCol;\n\t\t\t}\n\t\t} else if (pieceType == 6) { //If this is a king\n\t\t\tif (fromCol == 4) {\n\t\t\t\tif (doResetEnpassant) resetEnpassant(team);\n\t\t\t\tif (toCol == 7) { //Kingside Castle\n\t\t\t\t\tboard[toRow][6] = piece;\n\t\t\t\t\tboard[toRow][5] = board[toRow][7];\n\t\t\t\t\tboard[toRow][7] = 0;\n\t\t\t\t\tboard[toRow][4] = 0;\n\t\t\t\t\treturn;\n\t\t\t\t} else if (toCol == 0) { //Queenside Castle\n\t\t\t\t\tboard[toRow][2] = piece;\n\t\t\t\t\tboard[toRow][3] = board[toRow][0];\n\t\t\t\t\tboard[toRow][0] = 0;\n\t\t\t\t\tboard[toRow][4] = 0;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (doResetEnpassant) resetEnpassant(team);\n\t\tboard[fromRow][fromCol] = 0;\n\t\tif (moveParts.length > 2 && pieceType == 1 && (team == 1 ? toRow == 7 : team == -1 ? toRow == 0 : false)) {\n\t\t\tpiece = Integer.parseInt(moveParts[2]);\n\t\t}\n\t\tboard[toRow][toCol] = piece;\n\t}", "public void move(FightCell cell);", "public void move(Pawn pawn, Point destination) {\n\t\tPoint lastLocation = pawn.getLocation();\r\n\t\tboard[lastLocation.x][lastLocation.y].setEmpty();\r\n\t\tboard[destination.x][destination.y].setTaken();\r\n\t\tpawn.setLocation(destination);\r\n\t\tpawn.setLastLocation(lastLocation);\r\n\t\t\r\n\t\tif(isNeighbor(lastLocation, destination)) {\r\n\t\t\tpawn.setAfterStep();\r\n\t\t}\r\n\t\t\r\n\t\tif(board[destination.x][destination.y].getFieldType().equals(pawn.getTarget())) {\r\n\t\t\tpawn.setInTarget();\r\n\t\t}\r\n\t}", "private void updateBigGameBoardForNextMove(){\n changeLetterAndVisuals();\n /*\n This next step is essential to the game:\n The player just chose a position on a smallGameBoard; this position is where he will\n be able to choose on the big board. For example, if player 1 puts an x in the top-left\n corner of a small game, then player 2 should play in the top-left small game (provided\n it is not already won).\n */\n nextGamePosition = chosenButton.getButtonPosition();\n nextGame = getGame(nextGamePosition);\n //If the next game is already won, then the next player can choose anywhere\n if (checkGameWin(nextGame.getLettersOfAllButtons())){\n for (ButtonClass b : allButtons) {\n b.setAvailable(true);\n }\n for(SmallGameBoard game: games){\n if (game.getGameBoardColor() == R.color.blackTransparent){\n game.changeGameColor(R.color.black);\n }\n }\n } else {\n //If next game is not won, then the player must play on the next game board\n setAvailableButtons(nextGamePosition);\n //Sets all boards besides the next game board to half transparent\n for (SmallGameBoard game: games){\n if(game.getGameBoardColor() == R.color.black){\n game.changeGameColor(R.color.blackTransparent);\n }\n }\n nextGame.changeGameColor(R.color.black);\n }\n //For playerVsComputer, this is when the computer makes its move\n if (!activity.getPlayerVsPlayer() && !computerIsMoving){\n computerMove(activity.getDifficulty());\n computerIsMoving = false;\n }\n }" ]
[ "0.71437967", "0.68819624", "0.68604106", "0.68138677", "0.6795215", "0.6721139", "0.6657849", "0.66286653", "0.6492563", "0.64594954", "0.6435333", "0.6425703", "0.64192986", "0.64042485", "0.6402081", "0.636453", "0.63308823", "0.63205713", "0.63185436", "0.6316668", "0.6311869", "0.6302149", "0.6291259", "0.6283585", "0.62661153", "0.6264035", "0.62600106", "0.622143", "0.6220265", "0.6211774", "0.6197817", "0.6191496", "0.6178767", "0.61779076", "0.61499894", "0.61394083", "0.61244756", "0.61102176", "0.6109724", "0.6099751", "0.60851663", "0.608355", "0.60817593", "0.60753626", "0.6050743", "0.60312814", "0.6027623", "0.60231143", "0.60172164", "0.6006962", "0.6006596", "0.5991317", "0.59881246", "0.5975579", "0.59639716", "0.5951937", "0.59506476", "0.59496874", "0.5946392", "0.5938723", "0.5930979", "0.5917067", "0.59147066", "0.5901451", "0.5891964", "0.58900416", "0.58765745", "0.58696014", "0.5869259", "0.58547395", "0.5852007", "0.58508277", "0.58487755", "0.5840767", "0.5832138", "0.5829108", "0.58264077", "0.5826003", "0.5818943", "0.5813298", "0.58126146", "0.5806267", "0.58046573", "0.5789169", "0.57886475", "0.5786843", "0.57835406", "0.57764554", "0.5771839", "0.5764884", "0.57646173", "0.5762406", "0.5758301", "0.5755548", "0.5753071", "0.57510495", "0.5746674", "0.5737632", "0.5735112", "0.57268536" ]
0.58624023
69
Determine the moves in the chess game based on the pgn. Individually send the moves to be handled.
public static void moves(String pgn) { pgn = pgn.substring(pgn.lastIndexOf("]"), pgn.length()); pgn = pgn.replaceAll("[\\t\\n\\r]+", " "); String pgnMoves = pgn.substring(pgn.indexOf("1.")); int lastMoveIndex = 0; int startIndex = 0; while (startIndex != -1) { startIndex = pgnMoves.indexOf(".", startIndex); int endIndex = pgnMoves.indexOf(".", startIndex + 1); String[] moves; if (endIndex == -1) { moves = pgnMoves.substring(startIndex + 1).trim().split(" "); } else { moves = pgnMoves.substring(startIndex + 1, endIndex - 1).trim() .split(" "); } processMove(moves[0], 'w'); if (moves.length >= 2) { processMove(moves[1], 'b'); } startIndex = endIndex; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Override\r\n\tpublic boolean makeMove(String notation) {\n\t\tif(Castle.isCastlingMove(new ChessCoordinate(notation))) {\r\n\t\t\tKing playerKing = (King) getPlayerTurn().getPieces(\"King\", true).get(0);\r\n\t\t\t//return the result of trying to castle\r\n\t\t\treturn playerKing.move(new ChessCoordinate(notation));\r\n\t\t\t\r\n\t\t}else {\r\n\t\t\t//not a castling move, standard move\r\n\t\t\t\t\r\n\t\t\tString[] notationList = notation.split(\"\");\r\n\t\t\t//find the piece name\r\n\t\t\tString pieceName = ChessPieceNames.getPieceName(notationList[0]);\t\t\r\n\t\t\t\r\n\t\t\tif(pieceName == null && getColumnNames().contains(notationList[0].toLowerCase())) {\r\n\t\t\t\t//if first character is a column and returned null from above\r\n\t\t\t\t//must be a pawn move like e4 or axb2\r\n\t\t\t\tpieceName = ChessPieceNames.PAWN.toString();\r\n\t\t\t}else if(pieceName == null){\r\n\t\t\t\t//not a column and null so invalid move\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\r\n//\t\t\t//capturing move if there is a capture (x)\r\n\t\t\tboolean isCaptureMove = Arrays.asList(notationList).contains(\"x\");\r\n\t\t\t\r\n\t\t\t//final coordinate\r\n\t\t\tString coordinateString = notationList[notationList.length-2] + notationList[notationList.length-1];\r\n\t\t\tChessCoordinate coordinate = new ChessCoordinate(coordinateString);\r\n\t\t\tif(coordinate.isValid()) {\r\n\t\t\t\t//extract players alive pieces of piece name\r\n\t\t\t\tList<Piece> piecesOfType = getPlayerTurn().getPieces(pieceName, true);\r\n\t\t\t\t//list of pieces that can move to the same square\r\n\t\t\t\tList<Piece> piecesCanMoveToSquare = new ArrayList<Piece>();\r\n\t\t\t\tfor (Piece piece : piecesOfType) {\r\n\t\t\t\t\t\r\n\t\t\t\t\t//use valid moves of attacking if capturing move, else use move to\r\n\t\t\t\t\tSet<Coordinate> pieceMoves = isCaptureMove \r\n\t\t\t\t\t\t\t? piece.getValidMoves(Action.ATTACK) : piece.getValidMoves(Action.MOVE_TO);\r\n\t\t\t\t\tif(pieceMoves.contains(coordinate))piecesCanMoveToSquare.add(piece);\r\n\t\t\t\t}\t\r\n\t\t\t\t\r\n\t\t\t\tif (piecesCanMoveToSquare.size() == 1) {\r\n\t\t\t\t\t//only one piece can go to that square, so take piece at 0th index as the list only has one element\r\n\t\t\t\t\tpiecesCanMoveToSquare.get(0).move(coordinate);\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\telse if (piecesCanMoveToSquare.size() > 1) {\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(notation.length() <= 3) {\r\n\t\t\t\t\t\tSystem.out.println(\"Invalid move, specify which piece to move to \" + coordinateString);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//multiple pieces of the same type can move to that square, check which one to use\r\n\t\t\t\t\t//if pawn, the identifier to use is the 0th index of notationList, eg axb4. use pawn in column a.\r\n\t\t\t\t\t//for other pieces, column to use is the 1st index of notationList. eg Nab4.\r\n\t\t\t\t\t\r\n\t\t\t\t\t//variable called identifier as it can be a row or column value.\r\n\t\t\t\t\tString identifier = (pieceName.equalsIgnoreCase(ChessPieceNames.PAWN.toString()) ?\r\n\t\t\t\t\t\t\tnotationList[0] : notationList[1]).toLowerCase();\r\n\t\t\t\t\t//identifier should be a row value if pieces share the same column\r\n\t\t\t\t\tboolean isRowIdentifier = shareColumn(piecesOfType);\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(isRowIdentifier && getRowNames().contains(identifier)) {\r\n\t\t\t\t\t\t//locate piece by row and move that piece to coordinate\r\n\t\t\t\t\t\tfor (Piece piece : piecesCanMoveToSquare) {\r\n\t\t\t\t\t\t\t//look at the row number of piece coordinate, see if it matches the identifier \r\n\t\t\t\t\t\t\tif(Character.toString(piece.getPosition().toString().charAt(1)).equalsIgnoreCase(identifier)) {\r\n\t\t\t\t\t\t\t\tpiece.move(coordinate);\r\n\t\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tSystem.out.println(\"There is no \" + pieceName + \" on row \" + identifier);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}else if(getColumnNames().contains(identifier)) {\r\n\t\t\t\t\t\tfor (Piece piece : piecesCanMoveToSquare) {\r\n\t\t\t\t\t\t\t//look at the column letter of piece coordinate, see if it matches the identifier \r\n\t\t\t\t\t\t\tif(Character.toString(piece.getPosition().toString().charAt(0)).equalsIgnoreCase(identifier)) {\r\n\t\t\t\t\t\t\t\tpiece.move(coordinate);\r\n\t\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tSystem.out.println(\"There is no \" + pieceName + \" on column \" + identifier);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//invalid identifier\r\n\t\t\t\t\telse return false;\r\n\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\telse {\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t//invalid coordinate, move can not be played\r\n\t\t\telse return false;\r\n\t\t}\r\n\t\t\r\n\t}", "public void executegenmoves() {\n \t\tObject state = gm.hashToState(new BigInteger(conf.getProperty(\"gamesman.hash\")));\n \t\tfor (Object nextstate : gm.validMoves(state)) {\n \t\t\tSystem.out.println(gm.stateToHash(nextstate));\n \t\t\tSystem.out.println(gm.displayState(nextstate));\n \t\t}\n \t}", "@Override\n\tpublic Collection<Move> calculateLegalMoves(final Board board) {\n\t\t\n\t\t//Array that will hold of the legal moves for the Pawn\n\t\tfinal List<Move> legalMoves = new ArrayList<>();\n\t\t\n\t\t//Loop through all possible moves by applying of the offsets to the Pawn's current position\n\t\tfor(final int currentCandidateOffset: CANDIDATE_MOVE_COORDINATES){\n\t\t\t\n\t\t\t//Apply the offset to the Pawn's current position\n\t\t\tfinal int candidateDestinationCoordinate = this.piecePosition + (this.getPieceTeam().getDirection() * currentCandidateOffset);\n\t\t\t\n\t\t\t//Checks if the Destination Coordinate is valid\n\t\t\tif(!BoardUtils.isValidTileCoordinate(candidateDestinationCoordinate)){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t//Checks if this tile is occupied\n\t\t\tif(currentCandidateOffset == 8 && !board.getTile(candidateDestinationCoordinate).isTileOccupied()){\n\t\t\t\tif(this.pieceTeam.isPawnPromotionSquare(candidateDestinationCoordinate))\n\t\t\t\t\tlegalMoves.add(new Move.PawnPromotion(new Move.PawnMove(board, this, candidateDestinationCoordinate)));\n\t\t\t\telse\n\t\t\t\t\tlegalMoves.add(new Move.PawnMove(board, this, candidateDestinationCoordinate));\t\n\t\t\t}\n\t\t\t//Checks if the Pawn is on it's first move\n\t\t\telse if(currentCandidateOffset == 16 && this.isFirstMove() && ((BoardUtils.SEVENTH_RANK[this.piecePosition] && \n\t\t\t\t\tthis.getPieceTeam().isBlack()) || (BoardUtils.SECOND_RANK[this.piecePosition] && this.getPieceTeam().isWhite()))) {\n\t\t\t\t\n\t\t\t\t//Calculate coordinate of the tile behind candidate coordinate\n\t\t\t\tfinal int behindCandidateDestinationCoordinate = this.piecePosition + (this.pieceTeam.getDirection() * 8);\n\t\t\t\t\n\t\t\t\t//Checks if the tile behind the candidate destination is NOT occupied & if the Tile at the Candidate Destination is NOT occupied\n\t\t\t\tif(!board.getTile(behindCandidateDestinationCoordinate).isTileOccupied() && \n\t\t\t !board.getTile(candidateDestinationCoordinate).isTileOccupied())\n\t\t\t\t\t\tlegalMoves.add(new Move.PawnJump(board, this, candidateDestinationCoordinate));\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t//Checks for edge cases in the 7 direction\t\n\t\t\t} else if(currentCandidateOffset == 7 &&\n\t\t\t\t\t!((BoardUtils.FILE_H[this.piecePosition] && this.getPieceTeam().isWhite() ||\n\t\t\t\t\t(BoardUtils.FILE_A[this.piecePosition] && this.getPieceTeam().isBlack())))){\n\t\t\t\t\n\t\t\t\tif(board.getTile(candidateDestinationCoordinate).isTileOccupied()){\n\t\t\t\t\tfinal Piece pieceOnCandidate = board.getTile(candidateDestinationCoordinate).getPiece();\n\t\t\t\t\t//If the pieces are not on the same team an Attack move is added to legal moves.\n\t\t\t\t\tif(this.getPieceTeam() != pieceOnCandidate.getPieceTeam())\n\t\t\t\t\t\tif(this.pieceTeam.isPawnPromotionSquare(candidateDestinationCoordinate))\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnPromotion(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate)));\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t\t\t\n\t\t\t\t//This basically checks if En Passant Pawn is next to Player's pawn\t\n\t\t\t\t} else if(board.getEnPassantPawn() != null){\n\t\t\t\t\tif(board.getEnPassantPawn().getPiecePosition() == (this.piecePosition + (this.pieceTeam.getOppositeDirection()))){\n\t\t\t\t\t\tfinal Piece pieceOnCandidate = board.getEnPassantPawn();\n\t\t\t\t\t\tif(this.pieceTeam != pieceOnCandidate.getPieceTeam()){\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnEnPassantAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t//Checks for edge cases in the 9 direction\t\n\t\t\t} else if(currentCandidateOffset == 9 && \n\t\t\t\t\t!((BoardUtils.FILE_A[this.piecePosition] && this.getPieceTeam().isWhite() ||\n\t\t\t\t\t(BoardUtils.FILE_H[this.piecePosition] && this.getPieceTeam().isBlack())))){\n\t\t\t\t\n\t\t\t\tif(board.getTile(candidateDestinationCoordinate).isTileOccupied()){\n\t\t\t\t\tfinal Piece pieceOnCandidate = board.getTile(candidateDestinationCoordinate).getPiece();\n\t\t\t\t\t//If the pieces are not on the same team an Attack move is added to legal moves.\n\t\t\t\t\tif(this.getPieceTeam() != pieceOnCandidate.getPieceTeam())\n\t\t\t\t\t\tif(this.pieceTeam.isPawnPromotionSquare(candidateDestinationCoordinate))\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnPromotion(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate)));\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t} else if(board.getEnPassantPawn() != null){\n\t\t\t\t\tif(board.getEnPassantPawn().getPiecePosition() == (this.piecePosition - (this.pieceTeam.getOppositeDirection()))){\n\t\t\t\t\t\tfinal Piece pieceOnCandidate = board.getEnPassantPawn();\n\t\t\t\t\t\tif(this.pieceTeam != pieceOnCandidate.getPieceTeam()){\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnEnPassantAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\t\t\t\t\t\n\t\t}\n\t\t\n\t\treturn ImmutableList.copyOf(legalMoves);\n\t}", "public static void getMoves(Player p, GameSquare[][] board) {\n\t\t// keep track of the number of possible moves\n\t\t// and number of unique pieces you could move\n\t\tint moveCount = 0;\n\t\tint uniquePieceCount = 0;\n\n\t\tArrayList<GameSquare> playerSpotsWithPieces = p.places;\n\t\tArrayList<GameSquare> validMoves;\n\n\t\t// for each square with a piece on it\n\t\t// find out where you can move that piece\n\t\tfor (GameSquare currentSquare : playerSpotsWithPieces) {\n\t\t\tvalidMoves = new ArrayList<GameSquare>();\n\n\t\t\t// grab all valid moves from\n\t\t\tvalidMoves.addAll(currentSquare.getValidMoves(board));\n\t\t\tif (validMoves.size() > 0)\n\t\t\t\tuniquePieceCount++;\n\t\t\tfor (GameSquare move : validMoves) {\n\t\t\t\tSystem.out.printf(\"%s at <%d:%d> can move to <%d:%d>\\n\", currentSquare.pieceType(), currentSquare.x,\n\t\t\t\t\t\tcurrentSquare.y, move.x, move.y);\n\t\t\t\tmoveCount++;\n\t\t\t}\n\t\t}\n\n\t\t// print the number of possible moves and number of unique pieces that\n\t\t// can be moved\n\t\tSystem.out.printf(\"%d legal moves (%d unique pieces) for %s player\", moveCount, uniquePieceCount,\n\t\t\t\tp.color.toString().toLowerCase());\n\n\t}", "public boolean sendMove(Move move) {\n // Define an array as large as the most packets sent by a single Move\n // Some moves send more than one packet.\n Packet[] packets = new Packet[2];\n\n switch (move.action) {\n case START:\n packets[0] = new Packet(Network.Command.START);\n packets[0].putField(\"id\", move.id);\n break;\n\n case ANTE_STAKES:\n packets[0] = new Packet(Network.Command.ANTE);\n packets[0].putField(\"chips\", move.chips);\n\n packets[1] = new Packet(Network.Command.STAKES);\n packets[1].putField(\"stakes_client\", move.cStakes);\n packets[1].putField(\"stakes_server\", move.sStakes);\n break;\n\n case STAKES:\n packets[0] = new Packet(Network.Command.STAKES);\n packets[0].putField(\"stakes_client\", move.cStakes);\n packets[0].putField(\"stakes_server\", move.sStakes);\n break;\n\n case QUIT:\n packets[0] = new Packet(Network.Command.QUIT);\n break;\n\n case ANTE_OK:\n packets[0] = new Packet(Network.Command.ANTE_OK);\n break;\n\n case DEALER_HAND:\n packets[0] = new Packet(Network.Command.DEALER);\n // Changed to 1 byte char\n packets[0].putField(\"dealer\", \"\" + move.dealer);\n //packets[0].putWrittable(new Writable.String(\"\"+move.dealer));\n\n packets[1] = new Packet(Network.Command.HAND);\n packets[1].putField(\"cards\", cardsToCodeString(move.cards));\n break;\n\n case PASS:\n packets[0] = new Packet(Network.Command.PASS);\n break;\n\n case BET:\n packets[0] = new Packet(Network.Command.BET);\n packets[0].putField(\"chips\", move.chips);\n break;\n\n case RAISE:\n packets[0] = new Packet(Network.Command.RAISE);\n packets[0].putField(\"chips\", move.chips);\n break;\n\n case FOLD:\n packets[0] = new Packet(Network.Command.FOLD);\n break;\n\n case CALL:\n packets[0] = new Packet(Network.Command.CALL);\n break;\n\n case DRAW:\n packets[0] = new Packet(Network.Command.DRAW);\n // Create a list of arguments as follows: '2' 2C 3H\n if (move.cDrawn == move.cards.length)\n // Changed to 1 byte char\n packets[0].putField(\"number\", move.cDrawn + \"\");\n\n else\n // Changed to 1 byte char\n packets[0].putField(\"number\", move.cards.length + \"\");\n\n if (move.cards.length > 0)\n packets[0].putField(\"cards\", cardsToCodeString(move.cards));\n\n break;\n\n case DRAW_SERVER:\n packets[0] = new Packet(Network.Command.DRAW_SERVER);\n // Create a list of arguments as follows: DRWS 2C 3H 4D '2'\n if (move.cDrawn > 0)\n packets[0].putField(\"cards\", cardsToCodeString(move.cards));\n\n // Changed to 1 byte char\n packets[0].putField(\"number\", \"\" + move.sDrawn);\n break;\n\n case SHOW:\n packets[0] = new Packet(Network.Command.SHOWDOWN);\n packets[0].putField(\"cards\", cardsToCodeString(move.cards));\n break;\n\n case ERROR:\n packets[0] = new Packet(Network.Command.ERROR);\n packets[0].putWrittable(new Writable.VariableString(2, move.error));\n }\n\n // Write all packets to the network\n for (Packet packet : packets) {\n if (packet != null) {\n // TODO Deal with exception inside try-catch\n\n if (!comUtils.write_NetworkPacket(packet)) {\n // Something has gone wrong. Terminate everything\n try {\n comUtils.getSocket().close();\n } catch (IOException ex) {\n NET_ERROR(\"Network: Error while closing connection.\");\n }\n comUtils = null;\n return false;\n }\n \n LOG_CLIENT(packet.toString());\n \n }\n\n }\n return true;\n }", "public void run() {\n Scanner cin = new Scanner(System.in, \"UTF-8\");\n boolean quit = false;\n chess = new Chess();\n Player temp;\n boolean check = false;\n Pawnposition p = null;\n int checknew = 0;\n\n while (!quit) {\n System.out.print(\"Chess> \");\n String str = cin.nextLine();\n if (str.length() <= 0) {\n System.out.println(\"Error! Not support this command1!\\n\");\n }\n else {\n String[] cmd = str.split(\" \");\n if (\"new\".startsWith(cmd[0]) && cmd.length == 2) {\n if(cmd[1].equals(\"SINGLE\")||(cmd[1].equals(\"single\"))){\n chess = new Chess();\n checknew = 1;\n }\n if(cmd[1].equals(\"HOTSEAT\")){\n chess = new Chess();\n }\n }\n else if (\"help\".startsWith(cmd[0]) && cmd.length == 1) {\n this.showHelp();\n }\n else if (\"quit\".startsWith(cmd[0]) && cmd.length == 1) {\n return;\n }\n else if (\"move\".startsWith(cmd[0]) && cmd.length == 3) {\n Cell f = new Cell(this.inputChange(cmd[1].charAt(0)), this.inputChange(cmd[1].charAt(1)));\n Cell t = new Cell(this.inputChange(cmd[2].charAt(0)), this.inputChange(cmd[2].charAt(1)));\n\n check = chess.move(f, t);\n if (check == true) {\n if ((chess.getState().getWinner() == Player.BLACK) || (chess.getState().getWinner() == Player.WHITE)) {\n Player tempforwin = this.chess.getState().getCurrentPlayer();\n System.out.println(tempforwin + \" moved \" + cmd[1] + \" to \" + cmd[2]);\n System.out.println(\"Game over. \" + tempforwin + \" has won\");\n continue;\n }\n if (this.chess.getState().getCurrentPlayer() == Player.WHITE) {\n temp = Player.BLACK;\n System.out.println(temp + \" moved \" + cmd[1] + \" to \" + cmd[2]);\n }\n if (this.chess.getState().getCurrentPlayer() == Player.BLACK) {\n temp = Player.WHITE;\n System.out.println(temp + \" moved \" + cmd[1] + \" to \" + cmd[2]);\n if(checknew == 1) {\n p = this.chess.minmax(0, Player.BLACK);\n if (p == null) {\n System.out.println(\"Fehler bei p\");\n } else if (p.getresult() == 0) {\n System.out.println(\"Fehler bei p.r\");\n } else if (p.getcellt() == null) {\n System.out.println(\"Fehler bei p.getcellt\");\n } else if (p.getcellf() == null) {\n System.out.println(\"Fehler bei p.getcellf\");\n } else {\n this.chess.move(p.getcellf(), p.getcellt());\n }\n }\n }\n }\n if (this.chess.ifmiss() == false && chess.getState().getWinner() == null) {\n System.out.println(this.chess.getState().getCurrentPlayer() + \" must miss a turn\");\n this.chess.getState().setCurrentPlayer(this.chess.getState().getCurrentPlayer());\n }\n\n\n }\n else if (\"print\".startsWith(cmd[0]) && cmd.length == 1) {\n if (chess == null) {\n System.out.println(\"Error! Fehler chess\");\n }\n else {\n chess.print();\n }\n }\n else {\n System.out.println(\"Error! Not support this command!\");\n }\n }\n }\n }", "public List<Move> validMoves(){\n List<Move> results = new LinkedList<>();\n int kingVal = turn == WHITE ? WHITE_KING : BLACK_KING;\n int kingX = 0, kingY = 0;\n List<Piece> checks = null;\n kingSearch:\n for (int y = 0; y < 8; y++){\n for (int x = 0; x < 8; x++){\n if (board[y][x] == kingVal){\n kingX = x;\n kingY = y;\n checks = inCheck(x,y);\n break kingSearch;\n }\n }\n }\n if (checks.size() > 1){ // must move king\n for (int x = -1; x < 2; x++){\n for (int y = -1; y < 2; y++){\n if (kingX+x >= 0 && kingX + x < 8 && kingY+y >= 0 && kingY+y < 8){\n int val = board[kingY+y][kingX+x];\n if (val == 0 || turn == WHITE && val > WHITE_KING || turn == BLACK && val < BLACK_PAWN){\n // may still be a move into check, must test at end\n results.add(new Move(kingVal, kingX, kingY, kingX+x, kingY+y, val, 0, this));\n }\n }\n }\n }\n } else { // could be in check TODO: split into case of single check and none, identify pin/capture lines\n int queen = turn == WHITE ? WHITE_QUEEN : BLACK_QUEEN;\n int knight = turn == WHITE ? WHITE_KNIGHT : BLACK_KNIGHT;\n int rook = turn == WHITE ? WHITE_ROOK : BLACK_ROOK;\n int bishop = turn == WHITE ? WHITE_BISHOP : BLACK_BISHOP;\n for (int y = 0; y < 8; y++) {\n for (int x = 0; x < 8; x++) {\n int piece = board[y][x];\n if (piece == (turn == WHITE ? WHITE_PAWN : BLACK_PAWN)) { // pawns\n // regular | 2 move\n if (board[y+turn][x] == 0){\n if (y+turn == 0 || y + turn == 7){ // promotion\n results.add(new Move(piece, x, y, x, y + turn, 0, queen, this));\n results.add(new Move(piece, x, y, x, y + turn, 0, knight, this));\n results.add(new Move(piece, x, y, x, y + turn, 0, rook, this));\n results.add(new Move(piece, x, y, x, y + turn, 0, bishop, this));\n }\n else {\n results.add(new Move(piece, x, y, x, y + turn, 0, 0, this));\n if ((y == (turn == WHITE ? 1 : 6)) && board[y + 2 * turn][x] == 0) { // initial 2 move\n results.add(new Move(piece, x, y, x, y + 2*turn, 0, 0, this));\n }\n }\n }\n // capture\n for (int dx = -1; dx <= 1; dx += 2){\n if (x + dx >= 0 && x + dx < 8) {\n int val = board[y+turn][x+dx];\n if (val > 0 && (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n if (y + turn == 0 || y + turn == 7){ // promotion\n results.add(new Move(piece, x, y, x+dx, y + turn, val, queen, this));\n results.add(new Move(piece, x, y, x+dx, y + turn, val, knight, this));\n results.add(new Move(piece, x, y, x+dx, y + turn, val, rook, this));\n results.add(new Move(piece, x, y, x+dx, y + turn, val, bishop, this));\n } else {\n results.add(new Move(piece, x, y, x+dx, y + turn, val, 0, this));\n }\n }\n if (val == 0 && y == (turn == WHITE ? 4 : 3) && x+dx == enPassant){ // en passant\n results.add(new Move(piece, x, y, x+dx, y + turn, 0, 0, this));\n }\n }\n }\n\n } else if (piece == knight) { // knights TODO: lookup table\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -2; dy <= 2; dy += 4){\n if (x+dx >= 0 && x + dx < 8 && y + dy >= 0 && y + dy < 8){\n int val = board[y+dy][x+dx];\n if (val == 0 || (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n results.add(new Move(piece,x,y,x+dx,y+dy,val,0,this));\n }\n }\n if (x+dy >= 0 && x + dy < 8 && y + dx >= 0 && y + dx < 8){\n int val = board[y+dx][x+dy];\n if (val == 0 || (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n results.add(new Move(piece,x,y,x+dy,y+dx,val,0,this));\n }\n }\n }\n }\n } else if (piece == bishop) { // bishops\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -1; dy <= 1; dy += 2){\n int i = 1;\n while (x + dx*i >= 0 && x + dx*i < 8 && y + dy*i >= 0 && y + dy*i < 8){\n int val = board[y+dy*i][x+dx*i];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n } else if (piece == rook) { // rooks\n for (int dx = -1; dx <= 1; dx+= 2){\n for (int ax = 0; ax < 2; ax++){\n int i = 1;\n while (ax==0 ? y+dx*i >= 0 && y+dx*i < 8 : x+dx*i >= 0 && x+dx*i < 8){\n int val = board[y+dx*i*(1-ax)][x+dx*i*ax];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n } else if (piece == (turn == WHITE ? WHITE_QUEEN : BLACK_QUEEN)) { // queens\n // Diagonals - same as bishops\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -1; dy <= 1; dy += 2){\n int i = 1;\n while (x + dx*i >= 0 && x + dx*i < 8 && y + dy*i >= 0 && y + dy*i < 8){\n int val = board[y+dy*i][x+dx*i];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n for (int dx = -1; dx <= 1; dx+= 2){\n for (int ax = 0; ax < 2; ax++){\n int i = 1;\n while (ax==0 ? y+dx*i >= 0 && y+dx*i < 8 : x+dx*i >= 0 && x+dx*i < 8){\n int val = board[y+dx*i*(1-ax)][x+dx*i*ax];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n } else if (piece == (turn == WHITE ? WHITE_KING : BLACK_KING)) { // king\n for (int dx = -1; dx < 2; dx++){\n for (int dy = -1; dy < 2; dy++){\n if ((dx != 0 || dy != 0) && x+dx >= 0 && x + dx < 8 && y + dy >= 0 && y + dy < 8){\n int val = board[y+dy][x+dx];\n if (val == 0 || (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n results.add(new Move(piece,x,y,x+dx,y+dy,val,0,this));\n }\n }\n }\n }\n }\n }\n }\n // castle\n if (checks.size() == 0){\n if (turn == WHITE && (castles & 0b11) != 0){//(castles[0] || castles[1])){\n board[0][4] = 0; // remove king to avoid check test collisions with extra king\n if ((castles & WHITE_SHORT) != 0 && board[0][5] == 0 && board[0][6] == 0 && inCheck(5,0).size() == 0){\n //if (castles[0] && board[0][5] == 0 && board[0][6] == 0 && inCheck(5,0).size() == 0){\n results.add(new Move(WHITE_KING, 4, 0, 6, 0, 0, 0, this));\n }\n if ((castles & WHITE_LONG) != 0 && board[0][1] == 0 && board[0][2] == 0 && board[0][3] == 0 &&\n inCheck(3,0).size() == 0){\n //if (castles[1] && board[0][1] == 0 && board[0][2] == 0 && board[0][3] == 0 && inCheck(3,0).size() == 0){\n results.add(new Move(WHITE_KING, 4, 0, 2, 0, 0, 0, this));\n }\n board[0][4] = WHITE_KING;\n }else if (turn == BLACK && (castles & 0b1100) != 0){//(castles[2] || castles[3])) {\n board[7][4] = 0; // remove king to avoid check test collisions with extra king\n //if (castles[2] && board[7][5] == 0 && board[7][6] == 0 && inCheck(5, 7).size() == 0) {\n if ((castles & BLACK_SHORT) != 0 && board[7][5] == 0 && board[7][6] == 0 && inCheck(5, 7).size() == 0) {\n results.add(new Move(BLACK_KING, 4, 7, 6, 7, 0, 0, this));\n }\n //if (castles[3] && board[7][1] == 0 && board[7][2] == 0 && board[7][3] == 0 && inCheck(3, 7).size() == 0) {\n if ((castles & BLACK_LONG) != 0 && board[7][1] == 0 && board[7][2] == 0 && board[7][3] == 0 &&\n inCheck(3, 7).size() == 0) {\n results.add(new Move(BLACK_KING, 4, 7, 2, 7, 0, 0, this));\n }\n board[7][4] = BLACK_KING;\n }\n }\n }\n List<Move> fullLegal = new LinkedList<>();\n for (Move m : results){\n makeMove(m);\n turn = -turn;\n if (m.piece == WHITE_KING || m.piece == BLACK_KING){\n if (inCheck(m.toX,m.toY).size() == 0){\n fullLegal.add(m);\n }\n }else if (inCheck(kingX,kingY).size() == 0){\n fullLegal.add(m);\n }\n turn = -turn;\n undoMove(m);\n }\n Collections.sort(fullLegal, (o1, o2) -> o2.score - o1.score); // greatest score treated as least so appears first\n return fullLegal;\n }", "@Override\n public ArrayList<xMCTSStringGameState> getPossibleMoves(xMCTSStringGameState gameState)\n {\n\t ArrayList<xMCTSStringGameState> posMoves = new ArrayList<xMCTSStringGameState>();\n\t if (gameStatus(gameState) == xMCTSGame.status.ONGOING) {\n\t \t String activeCard = gameState.toString().substring(gameState.toString().length() - 2, gameState.toString().length());\n\t \t int gridSize = SIZE*2;\n\t for (int i = 0; i < gridSize; i += 2) {\n\t for (int j = 0; j < gridSize; j += 2) {\n\t int pos = i * SIZE + j;\n\t if (gameState.toString().charAt(pos) == '_') {\n\t String temp = gameState.toString().substring(0, pos)\n\t \t\t + activeCard\n\t + gameState.toString().substring(pos + 2,\n\t gameState.toString().length());\n\t posMoves.add(new xMCTSStringGameState(temp, 0.0, 0));\n\t }\n\t }\n\n\t }\n\t }\n\t else {\n\t \t // System.out.println(\"No moves can be made from this state\");\n\t \t// callsFromFullBoards++;\n\t \t// System.out.println(\"There have been \" + callsFromFullBoards + \"attempts to get possible moves from a full board\");\n\t }\n\t return posMoves;\n }", "Iterator<BoardPosition> possibleMovingPositions(BoardPosition from, Game game, Map<BoardPosition, Piece> pieceMap);", "private static void playersMove() {\r\n\t\tPrint print = new Print(); \r\n\t\tprint.board(game); \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Prints the entire gameBoard.\r\n\t\t\r\n\t\tboolean flag = false;\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//true = Get Gideon's move | false = Get User's move\r\n\t\r\n\t\tArrayList<Integer> moves = MoveGenerator.Gen(flag, gamePieces);\t\t\t\t\t\t\t//returns all the legal moves possible to make by the player.\r\n\t\tPrint.moves(moves);\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Prints all the moves returned by the Gen method.\r\n\t\t\r\n\t\tSystem.out.print(\"\\n\\n Enter your move: \");\r\n\t\t@SuppressWarnings(\"resource\")\r\n\t\tScanner kb = new Scanner(System.in);\r\n\t\tString userInput = kb.next();\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Captures the players move\r\n\t\t\r\n\t\tboolean moveCheck = CheckUserInput.checkMove(userInput, moves);\t\t\t\t\t\t\t//Checks if the move entered by the player is in the legal move list\r\n\t\t\r\n\t\tString formattedUserInput = null;\r\n\t\t\r\n\t\tif(!moveCheck)\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Recall the playersMove() method if the move entered by the user is illegal\r\n\t\t\tplayersMove();\r\n\r\n\t\tformattedUserInput = FormatInput.formatUserMove(userInput);\t\t\t\t\t\t\t//Formatting the user's move to make it as an executable move on the board\r\n\t\t\r\n\t\t//System.out.println(formattedUserInput);\r\n\t\t\r\n\t\tUpdateBoard boardUpdater = new UpdateBoard();\r\n\t\tgame = boardUpdater.playMove(formattedUserInput,game, gamePieces, flag, false, true); //Executing the legal move on the gameBoard\r\n\t\tgamePieces = game.getGamePiecesArray();\t\t\t\t\t\t\t\t\t\t\t\t\t//Getting the updated copy of the Game Pieces Array\r\n\t\tgame.updateGameBoard();\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Updating the String copy of the game board (required to print the updated gameBoard)\r\n\t\t\r\n\t\tSystem.out.println(\"\\n ========================\");\r\n\t\tGideonsMove();\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Gideon's turn to make a move\r\n\t\r\n\t}", "@Override\r\n\tpublic boolean movement(BoardCells[][] chessBoard, Piece targetPiece, int fromX,int fromY,int toX,int toY) {\t\t\r\n\t\t//DEBUG -- System.out.println(\"\"+fromX+fromY+\" \"+toX+toY);\r\n\t\t\r\n\t\tif(fromY == toY){\t\t\t\r\n\t\t\tif(fromX > toX) {\r\n\t\t\t\tfor(int i = fromX-1; i>toX; i--) {\r\n\t\t\t\t\tif(chessBoard[8-fromY][i].getPiece() != null) {\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\r\n\t\t\t} else if (fromX < toX) {\r\n\t\t\t\tfor(int i = fromX+1; i<toX; i++) {\r\n\t\t\t\t\tif(chessBoard[8-fromY][i].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif(getPieceID().equals(\"bR\")) {\r\n\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"bKc\")) {\r\n\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"bK\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif(getPieceID().equals(\"wR\")) {\r\n\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"wKc\")) {\r\n\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"wK\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\tif(fromX == toX) {\t\t\t\t\r\n\t\t\tif(fromY > toY) {\t\r\n\t\t\t\tfor(int i = fromY-1; i>toY; i--) {\r\n\t\t\t\t\tif(chessBoard[8-i][toX].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t} else if (fromY < toY) {\t\t\t\t\r\n\t\t\t\tfor(int i = fromY+1; i<toY; i++) {\t\t\t\t\t\r\n\t\t\t\t\tif(chessBoard[8-i][toX].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tif(getPieceID().equals(\"bR\")) {\r\n\t\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"bKc\")) {\r\n\t\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"bK\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(getPieceID().equals(\"wR\")) {\r\n\t\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"wKc\")) {\r\n\t\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"wK\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\r\n\t\t\treturn true;\t\r\n\t\t}\r\n\t\t\t\t\r\n\t\treturn false;\t\t\r\n\t}", "private static void GideonsMove() {\r\n\t\tPrint print = new Print();\r\n\t\tprint.board(game);\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Prints the entire gameBoard.\r\n\t\t\r\n\t\tboolean flag = true;\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//true = Gideon's move | false = user's move\r\n\t\t\r\n\t\tArrayList<Integer> moves = MoveGenerator.Gen(flag, gamePieces);\t\t\t\t\t\t\t//returns all the legal moves possible to make by the player.\r\n\t\tPrint.moves(moves);\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Prints all the moves returned by the Gen method.\r\n\t\t\r\n\t\t//System.out.println(\"\\n\\n Gideon will play......\" \r\n\t\t\t\t\t\t//+\"Feature coming soon, until then keep practicing\\n\");\r\n\t\t \r\n\t\tMiniMax minimax = new MiniMax(game, moves);\t\t\t\t\t\t\t\t\t\t\t\t//Declaring and initializing MiniMax object with parameters game and moves\r\n\r\n\t\tif(moves.size() < 6) {\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Will increment the MiniMax MAX_DEPTH size by 1 if the legal moves are less than 6\r\n\t\t\tminimax.incrementMAX_DEPTH();\r\n\t\t}\r\n\t\t\r\n\t\tlong start_time = System.nanoTime();\t\t\t\t\t\t\t\t\t\t\t\t\t//Time before starting MiniMax\r\n\t\t\r\n\t\tString gideonsMove = minimax.start();\t\t\t\t\t\t\t\t\t\t\t\t\t//Starting MiniMax\r\n\t\r\n\t\tdouble elapsed = System.nanoTime()-start_time;\t\t\t\t\t\t\t\t\t\t\t//Total time taken by MiniMax=Time after MiniMax is finished-Time before MiniMax was started\r\n\t elapsed=elapsed/1000000000;\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Converting to seconds\r\n\t \r\n\t\tSystem.out.print(\"\\n\\n Gideon's move: \"+\r\n\t\t\t\tGideonsMoveConvertor.convert(gideonsMove)+\"\\n\\n\");\t\t\t\t\t\t\t\t//Changing GideonsMove to A1B2 format\r\n\t\t\r\n\t\tUpdateBoard boardUpdater = new UpdateBoard();\r\n\t\t\r\n\t\tgame = boardUpdater.playMove(gideonsMove, game, gamePieces, flag, false, true);\t\t\t//Executing the legal move on the gameBoard\r\n\t\tgamePieces = game.getGamePiecesArray();\t\t\t\t\t\t\t\t\t\t\t\t\t//Getting the updated copy of the Game Pieces Array\r\n\t\tgame.updateGameBoard();\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Updating the String copy of the game board (required to print the updated gameBoard)\r\n\t\t\r\n\t\tSystem.out.println(\"Depth used for this iteration --> \"+minimax.getMAX_DEPTH());\t\t//Printing the MAX_DEPTH used by MiniMax to calculate the best move\r\n\t\tSystem.out.println(\"Time Taken for MiniMax --> \"+elapsed);\t\t\t\t\t\t\t\t//Printing time taken by MiniMax to calculate the best move\r\n\t\tSystem.out.println(\"\\n ========================\");\r\n\t\tplayersMove();\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Player's turn to make a move\r\n\t\t\r\n\t}", "Piece askMove(Player J, Piece[] Board, MovingPiece movingPiece, ChessGame G);", "public ArrayList<Coordinate> getPossibleMoveCoordinate() {\n ChessBoard board = this.getChessBoard(); // get chess board\n ArrayList<Coordinate> coords = new ArrayList<Coordinate>(); // create return ArrayList\n int x, y;\n /*\n several cases\n 2 3\n 1 4\n\n 5 8\n 6 7\n\n */\n // case1\n x = this.x_coordinate - 2;\n y = this.y_coordinate + 1;\n if(x >= 0 && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case2\n x = this.x_coordinate - 1;\n y = this.y_coordinate + 2;\n if(x >= 0 && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case3\n x = this.x_coordinate + 1;\n y = this.y_coordinate + 2;\n if(x < board.getWidth() && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case4\n x = this.x_coordinate + 2;\n y = this.y_coordinate + 1;\n if(x < board.getWidth() && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case5\n x = this.x_coordinate - 2;\n y = this.y_coordinate - 1;\n if(x >= 0 && y >= 0 ){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case6\n x = this.x_coordinate - 1;\n y = this.y_coordinate - 2;\n if(x >= 0 && y >= 0){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case7\n x = this.x_coordinate + 1;\n y = this.y_coordinate - 2;\n if(x < board.getWidth() && y >= 0){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case1\n x = this.x_coordinate + 2;\n y = this.y_coordinate - 1;\n if(x < board.getWidth() && y >= 0){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n\n\n return coords;\n }", "@Override\r\n\tpublic void getLegalMoves() {\r\n\t\tint pawnX = this.getX();\r\n\t\tint pawnY = this.getY();\r\n\t\tchar pawnColor = getColor();\r\n\t\tTile[][] chessBoard = SimpleChess.getChessBoard();\r\n\t\tcheckInFront(chessBoard,pawnX,pawnY,pawnColor);\r\n\t\tcheckDiagonal(chessBoard,pawnX,pawnY,pawnColor);\r\n\t}", "static List<Move> generateLegalMoves(Position pos) {\n\t\tList<Move> moves = new ArrayList<>();\n\n\t\t// for (int square : pos.pieces) {\n\t\t// \tif (pos.pieces.size() > 32) {\n\t\t// \t\tSystem.out.println(\"problem\" + pos.pieces.size());\n\t\t// \t}\n\t\t// \tif (pos.at(square) != 0 && Piece.isColor(pos.at(square), pos.toMove)) {\n\t\t// \t\tint piece = pos.at(square);\n\t\t// \t\tint name = Piece.name(piece);\n\t\t// \t\tif (name == Piece.Pawn) {\n\t\t// \t\t\tint step = pos.toMove == 'w' ? MoveData.Up : MoveData.Down;\n\t\t// \t\t\tif (square + step >= 0 && square + step < 64) {\n\t\t// \t\t\t\t// 1 square\n\t\t// \t\t\t\tif (pos.board.squares[square + step] == 0) {\n\t\t// \t\t\t\t\tif ((pos.toMove == 'w' && square >= 48) || (pos.toMove == 'b' && square <= 15)) {\n\t\t// \t\t\t\t\t\tmoves.add(new Move(square, square + step, 'q'));\n\t\t// \t\t\t\t\t\tmoves.add(new Move(square, square + step, 'b'));\n\t\t// \t\t\t\t\t\tmoves.add(new Move(square, square + step, 'n'));\n\t\t// \t\t\t\t\t\tmoves.add(new Move(square, square + step, 'r'));\n\t\t// \t\t\t\t\t}\n\t\t// \t\t\t\t\telse {\n\t\t// \t\t\t\t\t\tmoves.add(new Move(square, square + step));\n\t\t// \t\t\t\t\t}\t\t\t\t\t\t\t\n\t\t// \t\t\t\t}\n\t\t// \t\t\t\t// 2 squares\n\t\t// \t\t\t\tif ((square < 16 && pos.toMove == 'w') || square > 47 && pos.toMove == 'b') {\n\t\t// \t\t\t\t\tif (pos.board.squares[square + 2*step] == 0 && pos.board.squares[square + step] == 0) {\n\t\t// \t\t\t\t\t\tmoves.add(new Move(square, square + 2*step));\n\t\t// \t\t\t\t\t}\n\t\t// \t\t\t\t}\t\n\t\t// \t\t\t\t// capture\n\t\t// \t\t\t\t// right\n\t\t// \t\t\t\tif (MoveData.DistanceToEdge[square][3] > 0) {\n\t\t// \t\t\t\t\tint target = square + step + 1;\t\t\t\t\t\t\t\n\t\t// \t\t\t\t\tif (Piece.isColor(pos.board.squares[target], Opposite(pos.toMove))) {\t\t\t\t\t\t\t\t\n\t\t// \t\t\t\t\t\tif ((pos.toMove == 'w' && square >= 48) || (pos.toMove == 'b' && square <= 15)) {\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target, 'q'));\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target, 'b'));\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target, 'n'));\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target, 'r'));\n\t\t// \t\t\t\t\t\t}\n\t\t// \t\t\t\t\t\telse {\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target));\n\t\t// \t\t\t\t\t\t}\t\t\t\n\t\t// \t\t\t\t\t} \n\t\t// \t\t\t\t\telse if (target == pos.enPassantTarget) {\n\t\t// \t\t\t\t\t\tif ((pos.toMove == 'w' && target > 32) || (pos.toMove == 'b' && target < 24)) {\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target));\n\t\t// \t\t\t\t\t\t}\n\t\t// \t\t\t\t\t}\n\t\t// \t\t\t\t}\n\t\t// \t\t\t\t// left\n\t\t// \t\t\t\tif (MoveData.DistanceToEdge[square][2] > 0) {\n\t\t// \t\t\t\t\tint target = square + step - 1;\n\t\t// \t\t\t\t\tif (Piece.isColor(pos.board.squares[target], Opposite(pos.toMove))) {\n\t\t// \t\t\t\t\t\tif ((pos.toMove == 'w' && square >= 48) || (pos.toMove == 'b' && square <= 15)) {\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target, 'q'));\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target, 'b'));\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target, 'n'));\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target, 'r'));\n\t\t// \t\t\t\t\t\t}\n\t\t// \t\t\t\t\t\telse {\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target));\n\t\t// \t\t\t\t\t\t}\t\t\t\n\t\t// \t\t\t\t\t}\n\t\t// \t\t\t\t\telse if (target == pos.enPassantTarget) {\n\t\t// \t\t\t\t\t\tif ((pos.toMove == 'w' && target > 32) || (pos.toMove == 'b' && target < 24)) {\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target));\n\t\t// \t\t\t\t\t\t}\n\t\t// \t\t\t\t\t}\n\t\t// \t\t\t\t}\t\n\t\t// \t\t\t}\t\t\t\t\t\t\t\t\n\t\t// \t\t}\n\t\t// \t\telse if (name == Piece.Knight) {\t\t\t\t\t\t\t\t\t\t\n\t\t// \t\t\tfor (int offset : MoveData.KnightOffsets.get(square)) {\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t// \t\t\t\tif (!Piece.isColor(pos.board.squares[square + offset], pos.toMove)) {\t\t\t\t\t\t\t\n\t\t// \t\t\t\t\tMove move = new Move(square, square + offset);\n\t\t// \t\t\t\t\tmoves.add(move);\t\t\t\t\t\t\t\n\t\t// \t\t\t\t}\t\n\t\t// \t\t\t}\t\t\t\t\t\n\t\t// \t\t}\n\t\t// \t\telse {\n\t\t// \t\t\tint dirStart = name == Piece.Bishop ? 4 : 0;\n\t\t// \t\t\tint dirEnd = name == Piece.Rook ? 4 : 8;\n\t\t// \t\t\tfor (int dir = dirStart; dir < dirEnd; dir++) {\n\t\t// \t\t\t\tint maxDist = MoveData.DistanceToEdge[square][dir];\n\t\t// \t\t\t\tint dist = name == Piece.King ? Math.min(1, maxDist) : maxDist;\n\n\t\t// \t\t\t\tfor (int steps = 1; steps <= dist; steps++) {\n\t\t// \t\t\t\t\tint squareIdx = square + steps * MoveData.Offsets[dir];\t\t\t\t\t\t\t\t\t\t\t\n\t\t// \t\t\t\t\tif (!Piece.isColor(pos.board.squares[squareIdx], pos.toMove)) {\n\t\t// \t\t\t\t\t\tmoves.add(new Move(square, squareIdx));\n\t\t// \t\t\t\t\t\tif (Piece.isColor(pos.board.squares[squareIdx], Opposite(pos.toMove))) {\n\t\t// \t\t\t\t\t\t\tbreak;\n\t\t// \t\t\t\t\t\t}\n\t\t// \t\t\t\t\t}\n\t\t// \t\t\t\t\telse {\n\t\t// \t\t\t\t\t\tbreak;\n\t\t// \t\t\t\t\t}\n\t\t// \t\t\t\t}\t\t\t\t\t\t\n\t\t// \t\t\t}\n\t\t// \t\t}\n\t\t// \t}\n\t\t// }\n\n\t\tfor (int i = 0; i < 64; i++) {\n\t\t\tif (pos.board.squares[i] != 0 && Piece.isColor(pos.board.squares[i], pos.toMove)) {\n\t\t\t\tint piece = pos.board.squares[i];\n\t\t\t\tint name = Piece.name(piece);\n\t\t\t\tif (name == Piece.Pawn) {\n\t\t\t\t\tint step = pos.toMove == 'w' ? MoveData.Up : MoveData.Down;\n\t\t\t\t\tif (i + step >= 0 && i + step < 64) {\n\t\t\t\t\t\t// 1 square\n\t\t\t\t\t\tif (pos.board.squares[i + step] == 0) {\n\t\t\t\t\t\t\tif ((pos.toMove == 'w' && i >= 48) || (pos.toMove == 'b' && i <= 15)) {\n\t\t\t\t\t\t\t\tmoves.add(new Move(i, i + step, 'q'));\n\t\t\t\t\t\t\t\tmoves.add(new Move(i, i + step, 'b'));\n\t\t\t\t\t\t\t\tmoves.add(new Move(i, i + step, 'n'));\n\t\t\t\t\t\t\t\tmoves.add(new Move(i, i + step, 'r'));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tmoves.add(new Move(i, i + step));\n\t\t\t\t\t\t\t}\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// 2 squares\n\t\t\t\t\t\tif ((i < 16 && pos.toMove == 'w') || i > 47 && pos.toMove == 'b') {\n\t\t\t\t\t\t\tif (pos.board.squares[i + 2*step] == 0 && pos.board.squares[i + step] == 0) {\n\t\t\t\t\t\t\t\tmoves.add(new Move(i, i + 2*step));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\t\n\t\t\t\t\t\t// capture\n\t\t\t\t\t\t// right\n\t\t\t\t\t\tif (MoveData.DistanceToEdge[i][3] > 0) {\n\t\t\t\t\t\t\tint target = i + step + 1;\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (Piece.isColor(pos.board.squares[target], Opposite(pos.toMove))) {\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tif ((pos.toMove == 'w' && i >= 48) || (pos.toMove == 'b' && i <= 15)) {\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target, 'q'));\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target, 'b'));\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target, 'n'));\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target, 'r'));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target));\n\t\t\t\t\t\t\t\t}\t\t\t\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\telse if (target == pos.enPassantTarget) {\n\t\t\t\t\t\t\t\tif ((pos.toMove == 'w' && target > 32) || (pos.toMove == 'b' && target < 24)) {\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// left\n\t\t\t\t\t\tif (MoveData.DistanceToEdge[i][2] > 0) {\n\t\t\t\t\t\t\tint target = i + step - 1;\n\t\t\t\t\t\t\tif (Piece.isColor(pos.board.squares[target], Opposite(pos.toMove))) {\n\t\t\t\t\t\t\t\tif ((pos.toMove == 'w' && i >= 48) || (pos.toMove == 'b' && i <= 15)) {\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target, 'q'));\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target, 'b'));\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target, 'n'));\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target, 'r'));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target));\n\t\t\t\t\t\t\t\t}\t\t\t\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (target == pos.enPassantTarget) {\n\t\t\t\t\t\t\t\tif ((pos.toMove == 'w' && target > 32) || (pos.toMove == 'b' && target < 24)) {\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\t\n\t\t\t\t\t}\t\t\t\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\telse if (name == Piece.Knight) {\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tfor (int offset : MoveData.KnightOffsets.get(i)) {\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\tif (!Piece.isColor(pos.board.squares[i + offset], pos.toMove)) {\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tMove move = new Move(i, i + offset);\n\t\t\t\t\t\t\tmoves.add(move);\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\t\n\t\t\t\t\t}\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tint dirStart = name == Piece.Bishop ? 4 : 0;\n\t\t\t\t\tint dirEnd = name == Piece.Rook ? 4 : 8;\n\t\t\t\t\tfor (int dir = dirStart; dir < dirEnd; dir++) {\n\t\t\t\t\t\tint maxDist = MoveData.DistanceToEdge[i][dir];\n\t\t\t\t\t\tint dist = name == Piece.King ? Math.min(1, maxDist) : maxDist;\n\t\t\t\t\t\tfor (int steps = 1; steps <= dist; steps++) {\n\t\t\t\t\t\t\tint squareIdx = i + steps * MoveData.Offsets[dir];\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (!Piece.isColor(pos.board.squares[squareIdx], pos.toMove)) {\n\t\t\t\t\t\t\t\tmoves.add(new Move(i, squareIdx));\n\t\t\t\t\t\t\t\tif (Piece.isColor(pos.board.squares[squareIdx], Opposite(pos.toMove))) {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// castling\t\t\n\t\tif (pos.toMove == 'w' && !underAttack(pos, pos.whiteKing, 'b')) {\t\t\t\n\t\t\tif (pos.castlingRights.whiteKingSide && pos.at(Board.H1) == (Piece.Rook | Piece.White)) {\n\t\t\t\tif (pos.at(Board.F1) == Piece.Empty && pos.at(Board.G1) == Piece.Empty) {\n\t\t\t\t\tif (!underAttack(pos, Board.F1, 'b') && !underAttack(pos, Board.G1, 'b')) {\n\t\t\t\t\t\tmoves.add(new Move(Board.E1, Board.G1));\n\t\t\t\t\t}\t\t\t\t\n\t\t\t\t}\t\t\t\n\t\t\t}\n\t\t\tif (pos.castlingRights.whiteQueenSide && pos.at(Board.A1) == (Piece.Rook | Piece.White)) {\t\t\t\t\n\t\t\t\tif (pos.at(Board.B1) == Piece.Empty && pos.at(Board.C1) == Piece.Empty && pos.at(Board.D1) == Piece.Empty) {\n\t\t\t\t\tif (!underAttack(pos, Board.D1, 'b') && !underAttack(pos, Board.C1, 'b')) {\n\t\t\t\t\t\tmoves.add(new Move(Board.E1, Board.C1));\n\t\t\t\t\t}\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t\telse if (pos.toMove == 'b' && !underAttack(pos, pos.blackKing, 'w')){\n\t\t\tif (pos.castlingRights.blackKingSide && pos.at(Board.H8) == (Piece.Rook | Piece.Black)) {\n\t\t\t\tif (pos.at(Board.F8) == Piece.Empty && pos.at(Board.G8) == Piece.Empty) {\n\t\t\t\t\tif (!underAttack(pos, Board.F8, 'w') && !underAttack(pos, Board.G8, 'w')) {\n\t\t\t\t\t\tmoves.add(new Move(Board.E8, Board.G8));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (pos.castlingRights.blackQueenSide && pos.at(Board.A8) == (Piece.Rook | Piece.Black)) {\n\t\t\t\tif (pos.at(Board.B8) == Piece.Empty && pos.at(Board.C8) == Piece.Empty && pos.at(Board.D8) == Piece.Empty) {\n\t\t\t\t\tif (!underAttack(pos, Board.D8, 'w') && !underAttack(pos, Board.C8, 'w')) {\n\t\t\t\t\t\tmoves.add(new Move(Board.E8, Board.C8));\n\t\t\t\t\t}\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t// filter illegal moves\n\t\tList<Move> legalMoves = new ArrayList<>();\n\t\tchar color = pos.toMove;\n\t\tfor (Move move : moves) {\n\t\t\tpos.makeMove(move);\n\t\t\tif (!kingInCheck(pos, color)) {\n\t\t\t\tlegalMoves.add(move);\n\t\t\t}\t\t\t\n\t\t\tpos.undoMove();\n\t\t}\n\n\t\treturn legalMoves;\n\t}", "public void applyConvertedMove(String move) {\n\n\t\tString[] moveParts = move.split(\";\");\n\n\t\tint fromRow = Integer.parseInt(moveParts[0].charAt(0) + \"\");\n\t\tint fromCol = Integer.parseInt(moveParts[0].charAt(1) + \"\");\n\n\t\tint toRow = Integer.parseInt(moveParts[1].charAt(0) + \"\");\n\t\tint toCol = Integer.parseInt(moveParts[1].charAt(1) + \"\");\n\n\t\tint piece = board[fromRow][fromCol];//Integer.parseInt(moveParts[2]);\n\t\tint pieceType = Math.abs(board[fromRow][fromCol]);\n\t\tint team = Math.round(Math.signum(board[fromRow][fromCol]));\n\n\t\tboolean doResetEnpassant = true;\n\n\t\tif (pieceType == 1) { //If this is a pawn\n\t\t\tif (Math.abs(board[toRow][toCol]) == 7) { //If it is moving onto an enpassant stored tile\n\t\t\t\tboard[toRow + board[toRow][toCol]/7][toCol] = 0; //Kill the pawn that produced the enpassant tile\n\t\t\t} else if (Math.abs(fromRow - toRow) == 2) { //If it just did the double move thing\n\t\t\t\t//Reset the current enpassant tile\n\t\t\t\tresetEnpassant(team);\n\t\t\t\tdoResetEnpassant = false;\n\n\t\t\t\t//Set an empassant tile\n\t\t\t\tboard[(toRow + fromRow)/2][toCol] = 7 * team;\n\t\t\t\tenpassantCol = toCol;\n\t\t\t}\n\t\t} else if (pieceType == 6) { //If this is a king\n\t\t\tif (fromCol == 4) {\n\t\t\t\tif (doResetEnpassant) resetEnpassant(team);\n\t\t\t\tif (toCol == 7) { //Kingside Castle\n\t\t\t\t\tboard[toRow][6] = piece;\n\t\t\t\t\tboard[toRow][5] = board[toRow][7];\n\t\t\t\t\tboard[toRow][7] = 0;\n\t\t\t\t\tboard[toRow][4] = 0;\n\t\t\t\t\treturn;\n\t\t\t\t} else if (toCol == 0) { //Queenside Castle\n\t\t\t\t\tboard[toRow][2] = piece;\n\t\t\t\t\tboard[toRow][3] = board[toRow][0];\n\t\t\t\t\tboard[toRow][0] = 0;\n\t\t\t\t\tboard[toRow][4] = 0;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (doResetEnpassant) resetEnpassant(team);\n\t\tboard[fromRow][fromCol] = 0;\n\t\tif (moveParts.length > 2 && pieceType == 1 && (team == 1 ? toRow == 7 : team == -1 ? toRow == 0 : false)) {\n\t\t\tpiece = Integer.parseInt(moveParts[2]);\n\t\t}\n\t\tboard[toRow][toCol] = piece;\n\t}", "public AgentAction getNextMove(GameTile [][] visibleMap) {\r\n\t\t//Possible things to add to your moves\r\n//\t\tnextMove = AgentAction.doNothing;\r\n//\t\tnextMove = AgentAction.moveDown;\r\n//\t\tnextMove = AgentAction.moveUp;\r\n//\t\tnextMove = AgentAction.moveUp;\r\n//\t\tnextMove = AgentAction.moveLeft;\r\n//\t\tnextMove = AgentAction.pickupSomething;\r\n//\t\tnextMove = AgentAction.declareVictory;\r\n//\r\n//\t\tnextMove = AgentAction.shootArrowNorth;\r\n//\t\tnextMove = AgentAction.shootArrowSouth;\r\n//\t\tnextMove = AgentAction.shootArrowEast;\r\n//\t\tnextMove = AgentAction.shootArrowWest;\r\n//\t\tnextMove = AgentAction.quit\r\n\t\t\r\n\t\t\r\n\r\n\t\t//Ideally you would remove all this code, but I left it in so the keylistener would work\r\n\t\tif(keyboardPlayOnly) {\r\n\t\t\tif(nextMove == null) {\r\n\t\t\t\treturn AgentAction.doNothing;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tAgentAction tmp = nextMove;\r\n\t\t\t\tnextMove = null;\r\n\t\t\t\treturn tmp;\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t\telse {\r\n\t\t\t//This code plays 5 \"games\" and then quits\r\n\t\t\t//Just does random things\r\n\t\t\tif(numGamesPlayed > 19) {\r\n\t\t\t\treturn AgentAction.quit;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tif(nextMoves.isEmpty()) {\r\n\t\t\t\t\tsetStartingPosition(visibleMap);\r\n//\t\t\t\t\tfindWumpus(visibleMap);\r\n//\t\t\t\t\tfindWumpus(visibleMap);\r\n//\t\t\t\t\tWumpusState currentState = huntTheWumpus(visibleMap);\r\n//\t\t\t\t\tSystem.out.println(wumpusHunted);\r\n//\t\t\t\t\tif(wumpusHunted) {\r\n//\t\t\t\t\t\tcurrentState.setParent(null);\r\n//\t\t\t\t\t\taddToNextMoves(currentState);\r\n//\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\t//this is the code to collect the gold\r\n//\t\t\t\t\tcurrentState.setParent(null);\r\n//\t\t\t\t\tcurrentState = findTheGold(currentState);\r\n//\t\t\t\t\tif(currentState.getGoldCollected()) {\r\n//\t\t\t\t\t\tcurrentState.setParent(null);\r\n//\t\t\t\t\t\taddToNextMoves(currentState);\r\n//\t\t\t\t\t}\r\n\t\t\t\t\tif(!goldCollected) {\r\n\t\t\t\t\t\twellItsDarkNow(visibleMap);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif(goldCollected) {\r\n//\t\t\t\t\t\tcurrentState.setParent(null);\r\n\t\t\t\t\t\taddToNextMoves(visibleMap);\r\n//\t\t\t\t\t\tgoldCollected = false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t\tif(!nextMoves.isEmpty()) {\r\n\t\t\t\t\tSystem.out.println(nextMoves.peek());\r\n\t\t\t\t\tsetNextMove(nextMoves.remove());\r\n//\t\t\t\t\tSystem.out.println(nextMove);\r\n//\t\t\t\t\treturn nextMove;\r\n\t\t\t\t}\r\n\t\t\t\treturn nextMove;\r\n//\t\t\t\tcurrentNumMoves++;\r\n//\t\t\t\tif(currentNumMoves < 20) {\r\n//\t\t\t\t\treturn AgentAction.randomAction();\r\n//\t\t\t\t}\r\n//\t\t\t\telse {\r\n//\t\t\t\t\treturn AgentAction.declareVictory;\r\n//\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t}", "private void updateMoveList(Move m) {\n \t//first check for castling move\n \tif(m.getSource().getName().equals(\"King\")) {\n \tint sx = m.getSource().getLocation().getX();\n \tint dx = m.getDest().getLocation().getX();\n \t\n \t//castle king side\n \tif(dx - sx == 2) {\n \t\tmoveList.add(\"0-0\");\n \t\treturn;\n \t}\n \t//castle queen side\n \telse if(sx - dx == 2) {\n \t\tmoveList.add(\"0-0-0\");\n \t\treturn;\n \t}\n \t}\n \t\n \t//now do normal checks for moves\n \t//if no piece, normal notation\n \tif(m.getDest().getName().equals(\"None\")) {\n \t\t\n \t\t//check for en passant\n \t\tif(m.getSource().getName().equals(\"Pawn\")) {\n \t\t\t\n \t\t\t//it's only en passant if the pawn moves diagonally to an empty square \n \t\t\tif(m.getSource().getLocation().getX() != m.getDest().getLocation().getX()) {\n \t\t\t\tmoveList.add(m.getSource().getLocation().getFile()+ \"x\" + m.getDest().getLocation().getNotation());\n \t\t\t\treturn;\n \t\t\t}\n \t\t}\n \t\t\n \t\tmoveList.add(m.getSource().getID() + m.getDest().getLocation().getNotation());\n \t}\n \t//add \"x\" for capturing\n \t//for pawn, it's a bit different\n \telse if(m.getSource().getName().equals(\"Pawn\")) {\n \t\tmoveList.add(m.getSource().getLocation().getFile()+ \"x\" + m.getDest().getLocation().getNotation());\n \t}\n \telse {\n \t\tmoveList.add(m.getSource().getID() + \"x\" + m.getDest().getLocation().getNotation());\n \t}\n }", "public static int generateMoves(BoardState bs, long[] moves) {\n int count = 0;\n //int from, int to, int special, int movPiece, int content, int pawnStart\n int piece, tmp_piece, pIndex, index;\n int sq, tmp_sq, pieceNum, dir;\n\n int turn = bs.turn;\n int opponent = turn ^ 1;\n int pawn = PAWN_BY_COLOR[turn];\n\n //PAWNS\n for (pieceNum = 0; pieceNum < bs.pieceNum[pawn]; pieceNum++) {\n sq = bs.pieceArray[pawn][pieceNum];\n assert (isOnboard(sq));\n\n tmp_sq = sq + MOVES_PAWN_STRAIGHT[turn];\n if (bs.pieces[tmp_sq] == EMPTY) {\n count = addPawnMove(bs, sq, tmp_sq, 0, 0, turn, moves, count);\n tmp_sq += MOVES_PAWN_STRAIGHT[turn];\n if (((RANKS_MAP[sq] == RANK_7 && turn == BLACK)\n || (RANKS_MAP[sq] == RANK_2 && turn == WHITE))\n && bs.pieces[tmp_sq] == EMPTY) {\n count = addPawnMove(bs, sq, tmp_sq, 0, 1, turn, moves, count);\n }\n }\n\n tmp_sq = sq + MOVES_PAWNS[turn][0];\n if (isOnboard(tmp_sq) && PIECE_COLORS[bs.pieces[tmp_sq]] == opponent) {\n count = addPawnMove(bs, sq, tmp_sq, bs.pieces[tmp_sq], 0, turn, moves, count);\n }\n if (isOnboard(bs.enPas) && bs.enPas == tmp_sq) { //En passant check\n int move = Moves.generateMove(sq, tmp_sq, 1, pawn, EMPTY, 0);\n count = addMove(move, moves, count, 105);\n }\n\n tmp_sq = sq + MOVES_PAWNS[turn][1];\n if (isOnboard(tmp_sq) && PIECE_COLORS[bs.pieces[tmp_sq]] == opponent) {\n count = addPawnMove(bs, sq, tmp_sq, bs.pieces[tmp_sq], 0, turn, moves, count);\n }\n if (isOnboard(bs.enPas) && bs.enPas == tmp_sq) { //En passant check\n int move = Moves.generateMove(sq, tmp_sq, 1, pawn, EMPTY, 0);\n count = addMove(move, moves, count, 105);\n }\n }\n\n //Bishops, Rooks & Queens\n pIndex = SLIDERS_INDEX[turn];\n piece = SLIDERS[pIndex++];\n while (piece != -1) {\n for (pieceNum = 0; pieceNum < bs.pieceNum[piece]; pieceNum++) {\n sq = bs.pieceArray[piece][pieceNum];\n for (index = 0; index < MOVES_ALL[piece].length; index++) {\n dir = MOVES_ALL[piece][index];\n tmp_sq = sq;\n\n //Slide loop\n while (isOnboard(tmp_sq += dir)) {\n tmp_piece = bs.pieces[tmp_sq];\n if (tmp_piece != EMPTY) {\n if (PIECE_COLORS[tmp_piece] == opponent) {\n int move = Moves.generateMove(sq, tmp_sq, 0, piece, tmp_piece, 0);\n count = addCaptureMove(bs, move, moves, count);\n }\n break; //Stop sliding\n } else {\n int move = Moves.generateMove(sq, tmp_sq, 0, piece, EMPTY, 0);\n count = addMove(bs, move, moves, count);\n }\n }\n }\n }\n piece = SLIDERS[pIndex++];\n }\n //Kings & Knights\n pIndex = MOVERS_INDEX[turn];\n while ((piece = MOVERS[pIndex]) != -1) {\n for (pieceNum = 0; pieceNum < bs.pieceNum[piece]; pieceNum++) {\n sq = bs.pieceArray[piece][pieceNum];\n for (index = 0; index < MOVES_ALL[piece].length; index++) {\n dir = MOVES_ALL[piece][index];\n tmp_sq = sq + dir;\n if (isOnboard(tmp_sq)) {\n tmp_piece = bs.pieces[tmp_sq];\n if (tmp_piece != EMPTY) {\n if (PIECE_COLORS[tmp_piece] == opponent) {\n int move = Moves.generateMove(sq, tmp_sq, 0, piece, tmp_piece, 0);\n count = addCaptureMove(bs, move, moves, count);\n }\n } else {\n int move = Moves.generateMove(sq, tmp_sq, 0, piece, EMPTY, 0);\n count = addMove(bs, move, moves, count);\n }\n }\n }\n }\n pIndex++;\n }\n\n //Castling\n if (turn == WHITE) {\n if ((bs.castlePerms & WKCA) != 0\n && bs.pieces[F1] == EMPTY\n && bs.pieces[G1] == EMPTY\n && !bs.isSquareThreatened(E1, BLACK)\n && !bs.isSquareThreatened(F1, BLACK)) {\n int move = Moves.generateMove(E1, G1, 1, W_KING, EMPTY, 0);\n count = addMove(bs, move, moves, count);\n }\n if ((bs.castlePerms & WQCA) != 0\n && bs.pieces[D1] == EMPTY\n && bs.pieces[C1] == EMPTY\n && bs.pieces[B1] == EMPTY\n && !bs.isSquareThreatened(E1, BLACK)\n && !bs.isSquareThreatened(D1, BLACK)) {\n int move = Moves.generateMove(E1, C1, 1, W_KING, EMPTY, 0);\n count = addMove(bs, move, moves, count);\n }\n } else {\n if ((bs.castlePerms & BKCA) != 0\n && bs.pieces[F8] == EMPTY\n && bs.pieces[G8] == EMPTY\n && !bs.isSquareThreatened(E8, WHITE)\n && !bs.isSquareThreatened(F8, WHITE)) {\n int move = Moves.generateMove(E8, G8, 1, B_KING, EMPTY, 0);\n count = addMove(bs, move, moves, count);\n }\n if ((bs.castlePerms & BQCA) != 0\n && bs.pieces[D8] == EMPTY\n && bs.pieces[C8] == EMPTY\n && bs.pieces[B8] == EMPTY\n && !bs.isSquareThreatened(E8, WHITE)\n && !bs.isSquareThreatened(D8, WHITE)) {\n int move = Moves.generateMove(E8, C8, 1, B_KING, EMPTY, 0);\n count = addMove(bs, move, moves, count);\n }\n }\n\n return count;\n }", "@Override\n public Collection<Move> calculateLegalMoves(Board board) {\n System.out.println(\"INSIDE Knight: calculateLegalMoves()\");\n System.out.println(\"------------------------------>\\n\");\n\n //ArrayList of moves used to store all possible legal moves.\n final List<Move> legalMoves = new ArrayList<>();\n\n //Iterate the constant class array of piece offsets.\n for(final int currentCandidate : CANDIDATE_MOVE_COORDS){\n //Add the current coordinate of the piece to each offset, storing as a destination coordinate.\n final int candidateDestinationCoord = this.piecePosition + currentCandidate;\n\n //If the destination coordinate is within legal board bounds (between 0 and 64)...\n if(BoardUtils.isValidCoord(candidateDestinationCoord)){\n //Check to see if the piece is in the first column and its destination would move it outside the board.\n if(isfirstColumnExclusion(this.piecePosition, currentCandidate) ||\n isSecondColumnExclusion(this.piecePosition, currentCandidate) ||\n isSeventhColumnExclusion(this.piecePosition, currentCandidate) ||\n isEighthColumnExclusion(this.piecePosition, currentCandidate)){\n continue; //Continue the loop if any of these methods return true\n }\n\n //Store the tile of the destination coordinate.\n final Tile candidateDestinationTile = board.getTile(candidateDestinationCoord);\n\n //If the tile is not marked as occupied by the Tile class...\n if(!candidateDestinationTile.isOccupied()){\n //Add the move to the list of legal moves as a non-attack move.\n legalMoves.add(new MajorMove(board, this, candidateDestinationCoord));\n }\n else{\n //Otherwise, get the type and alliance of the piece at the destination.\n final Piece pieceAtDestination = candidateDestinationTile.getPiece();\n final Alliance pieceAlliance = pieceAtDestination.getPieceAlliance();\n\n //If the piece at the occupied tile's alliance differs...\n if(this.pieceAlliance != pieceAlliance){\n //Add the move to the list of legal moves as an attack move.\n legalMoves.add(new MajorAttackMove(board, this, candidateDestinationCoord, pieceAtDestination));\n }\n }\n }\n }\n\n //Return the list of legal moves.\n return legalMoves;\n }", "public void processMove(MahjongSolitaireMove move)\n {\n // REMOVE THE MOVE TILES FROM THE GRID\n ArrayList<MahjongSolitaireTile> stack1 = tileGrid[move.col1][move.row1];\n ArrayList<MahjongSolitaireTile> stack2 = tileGrid[move.col2][move.row2]; \n MahjongSolitaireTile tile1 = stack1.remove(stack1.size()-1);\n MahjongSolitaireTile tile2 = stack2.remove(stack2.size()-1);\n \n // MAKE SURE BOTH ARE UNSELECTED\n tile1.setState(VISIBLE_STATE);\n tile2.setState(VISIBLE_STATE);\n \n // SEND THEM TO THE STACK\n tile1.setTarget(TILE_STACK_X + TILE_STACK_OFFSET_X, TILE_STACK_Y + TILE_STACK_OFFSET_Y);\n tile1.startMovingToTarget(MAX_TILE_VELOCITY);\n tile2.setTarget(TILE_STACK_X + TILE_STACK_2_OFFSET_X, TILE_STACK_Y + TILE_STACK_OFFSET_Y);\n tile2.startMovingToTarget(MAX_TILE_VELOCITY);\n stackTiles.add(tile1);\n stackTiles.add(tile2); \n \n // MAKE SURE THEY MOVE\n movingTiles.add(tile1);\n movingTiles.add(tile2);\n \n // AND MAKE SURE NEW TILES CAN BE SELECTED\n selectedTile = null;\n \n // PLAY THE AUDIO CUE\n miniGame.getAudio().play(MahjongSolitairePropertyType.MATCH_AUDIO_CUE.toString(), false);\n \n // NOW CHECK TO SEE IF THE GAME HAS EITHER BEEN WON OR LOST\n \n // HAS THE PLAYER WON?\n if (stackTiles.size() == NUM_TILES)\n {\n // YUP UPDATE EVERYTHING ACCORDINGLY\n endGameAsWin();\n }\n else\n {\n // SEE IF THERE ARE ANY MOVES LEFT\n MahjongSolitaireMove possibleMove = this.findMove();\n if (possibleMove == null)\n {\n // NOPE, WITH NO MOVES LEFT BUT TILES LEFT ON\n // THE GRID, THE PLAYER HAS LOST\n endGameAsLoss();\n }\n }\n }", "public abstract void buildMoveData(ChessBoard board);", "public int[][] getMovesKnight(Piece p) {\n x = p.getX();\n y = p.getY();\n int[][] legalMoves = new int[8][8];\n\n if ((x + 2) < 8 && (y + 1) < 8) {\n if (b.getPieceAt((y + 1), (x + 2)) != null) {\n if (b.getPieceAt((y + 1), (x + 2)).isWhite() != p.isWhite()) {\n legalMoves[y + 1][x + 2] = 1;\n }\n } else {\n legalMoves[y + 1][x + 2] = 1;\n }\n }\n if ((x + 2) < 8 && (y - 1) > -1) {\n if (b.getPieceAt((y - 1), (x + 2)) != null) {\n if (b.getPieceAt((y - 1), (x + 2)).isWhite() != p.isWhite()) {\n legalMoves[y - 1][x + 2] = 1;\n }\n } else {\n legalMoves[y - 1][x + 2] = 1;\n }\n }\n if ((x - 2) > -1 && (y + 1) < 8) {\n if (b.getPieceAt((y + 1), (x - 2)) != null) {\n if (b.getPieceAt((y + 1), (x - 2)).isWhite() != p.isWhite()) {\n legalMoves[y + 1][x - 2] = 1;\n }\n } else {\n legalMoves[y + 1][x - 2] = 1;\n }\n }\n if ((x - 2) > -1 && (y - 1) > -1) {\n if (b.getPieceAt((y - 1), (x - 2)) != null) {\n if (b.getPieceAt((y - 1), (x - 2)).isWhite() != p.isWhite()) {\n legalMoves[y - 1][x - 2] = 1;\n }\n } else {\n legalMoves[y - 1][x - 2] = 1;\n }\n }\n if ((x + 1) < 8 && (y + 2) < 8) {\n if (b.getPieceAt((y + 2), (x + 1)) != null) {\n if (b.getPieceAt((y + 2), (x + 1)).isWhite() != p.isWhite()) {\n legalMoves[y + 2][x + 1] = 1;\n }\n } else {\n legalMoves[y + 2][x + 1] = 1;\n }\n }\n if ((x - 1) > -1 && (y + 2) < 8) {\n if (b.getPieceAt((y + 2), (x - 1)) != null) {\n if (b.getPieceAt((y + 2), (x - 1)).isWhite() != p.isWhite()) {\n legalMoves[y + 2][x - 1] = 1;\n }\n } else {\n legalMoves[y + 2][x - 1] = 1;\n }\n }\n if ((x - 1) > -1 && (y - 2) > -1) {\n if (b.getPieceAt((y - 2), (x - 1)) != null) {\n if (b.getPieceAt((y - 2), (x - 1)).isWhite() != p.isWhite()) {\n legalMoves[y - 2][x - 1] = 1;\n }\n } else {\n legalMoves[y - 2][x - 1] = 1;\n }\n }\n if ((x + 1) < 8 && (y - 2) > -1) {\n if (b.getPieceAt((y - 2), (x + 1)) != null) {\n if (b.getPieceAt((y - 2), (x + 1)).isWhite() != p.isWhite()) {\n legalMoves[y - 2][x + 1] = 1;\n }\n } else {\n legalMoves[y - 2][x + 1] = 1;\n }\n }\n return legalMoves;\n }", "public LinkedList<Move> getPossibleMoves() {\n\t\tAIPossibleMoves.clear();\n\t\tint xOrigin = 0, yOrigin = 0, xMove1 = 0, xMove2 = 0, yMove1 = 0, yMove2 = 0;\n\t\tMove move = null;\t\n\t\t\tint type = 0;\n\t\t\tfor(Checker checker: model.whitePieces) {\n\t\t\t\t\n\t\t\t\txOrigin = checker.getCurrentXPosition();\n\t\t\t\tyOrigin = checker.getCurrentYPosition();\n\t\t\t\txMove1 = (checker.getCurrentXPosition() - 1);\n\t\t\t\txMove2 = (checker.getCurrentXPosition() + 1);\n\t\t\t\tyMove1 = (checker.getCurrentYPosition() - 1);\n\t\t\t\tyMove2 = (checker.getCurrentYPosition() + 1);\n\t\t\t\ttype = checker.getType();\n\t\t\t\tswitch(type) {\n\t\t\t\tcase 2:\n\n\t\t\t\t\tif((xMove1 < 0) || (yMove1 <0)) {\n\t\t\t\t\t//\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\tif(isMoveValid(xOrigin,yOrigin, xMove1, yMove1, false, false )) {\n\t\t\t\t\t\tif(!isSpaceTaken(xMove1,yMove1)) {\n\t\t\t\t\t\t\t//System.out.println(\"Space is not Taken\");\n\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove1, yMove1);\n\t\t\t\t\t\t\tAIPossibleMoves.add(move);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(isPieceEnemy(xMove1,yMove1,checker,2)) {\n\t\t\t\t\t\t\t\tif(isJumpValid(xOrigin, yOrigin, xMove1, yMove1, false, false)) {\n\t\t\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove1, yMove1);\n\t\t\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n \n\t\t\t\t\tif((xMove2 > 7) || (yMove1 < 0)) {\n\t\t\t\t\t//\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\n\t\t\t\t\tif(isMoveValid(xOrigin,yOrigin, xMove2, yMove1, true, false )) {\n\t\t\t\t\t\tif(!isSpaceTaken(xMove2,yMove1)) {\n\t\t\t\t\t\t\t// System.out.println(\"Space is not Taken\");\n\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove2, yMove1);\n\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(isPieceEnemy(xMove2,yMove1,checker,2)) {\n\t\t\t\t\t\t\t\tif(isJumpValid(xOrigin, yOrigin, xMove2, yMove1, true, false)) {\n\t\t\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove2, yMove1);\n\t\t\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\t\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase 4:\n\t\t\t\t\t//Moving up and left isMovingRight,IsMovingDown\n\t\t\t\t\tif((xMove1 <0) || (yMove1 < 0)) {\n\t\t\t\t\t\t//continue;\n\t\t\t\t\t} else {\n\t\t\t\t\tif(isMoveValid(xOrigin,yOrigin, xMove1, yMove1, false, false )) {\n\t\t\t\t\t\tif(!isSpaceTaken(xMove1,yMove1)) {\n\t\t\t\t\t\t//\tSystem.out.println(\"Space is not Taken\");\n\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove1, yMove1);\n\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(isPieceEnemy(xMove1,yMove1,checker,2)) {\n\t\t\t\t\t\t\t\tif(isJumpValid(xOrigin, yOrigin, xMove1, yMove1, false, false)) {\n\t\t\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove1, yMove1);\n\t\t\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif((xMove2 > 7) || (yMove1 < 0)) {\n\t\t\t\t\t//continue;\n\t\t\t\t} else {\n\t\t\t\t\t//moving up and right\n\t\t\t\t\tif(isMoveValid(xOrigin,yOrigin, xMove2, yMove1, true, false )) {\n\t\t\t\t\t\tif(!isSpaceTaken(xMove2,yMove1)) {\n\t\t\t\t\t\t//\tSystem.out.println(\"Space is not Taken\");\n\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove2, yMove1);\n\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(isPieceEnemy(xMove2,yMove1,checker,2)) {\n\t\t\t\t\t\t\t\tif(isJumpValid(xOrigin, yOrigin, xMove2, yMove1, true, false)) {\n\t\t\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove2, yMove1);\n\t\t\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif((xMove1 < 0) || (yMove2 > 7)) {\n\t\t\t\t//\tcontinue;\n\t\t\t\t} else {\n\t\t\t\t\t//moving down and left isMovingRight,IsMovingDown\n\t\t\t\t\tif(isMoveValid(xOrigin,yOrigin, xMove1, yMove2, false, true )) {\n\t\t\t\t\t\tif(!isSpaceTaken(xMove1,yMove2)) {\n\t\t\t\t\t\t//\tSystem.out.println(\"Space is not Taken\");\n\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove1, yMove2);\n\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(isPieceEnemy(xMove1,yMove2,checker,2)) {\n\t\t\t\t\t\t\t\tif(isJumpValid(xOrigin, yOrigin, xMove1, yMove2, false, true)) {\n\t\t\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove1, yMove2);\n\t\t\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif((xMove2 > 7) || (yMove2 > 7)) {\n\t\t\t\t\t//continue;\n\t\t\t\t} else {\n\t\t\t\t\n\t\t\t\t\t//moving down and right isMovingRight,IsMovingDown\n\t\t\t\t\tif(isMoveValid(xOrigin,yOrigin, xMove2, yMove2, true, true )) {\n\t\t\t\t\t\tif(!isSpaceTaken(xMove2,yMove2)) {\n\t\t\t\t\t\t//\tSystem.out.println(\"Space is not Taken\");\n\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove2, yMove2);\n\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(isPieceEnemy(xMove2,yMove2,checker,2)) {\n\t\t\t\t\t\t\t\tif(isJumpValid(xOrigin, yOrigin, xMove2, yMove2, true, true)) {\n\t\t\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove2, yMove2);\n\t\t\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\tbreak;\t\n\t\t\t\t}\t\n\t\t\t\n\t\t\t}\n\n\t\t\treturn AIPossibleMoves;\n\t\t\t\n\t\t}", "public void playGame(Parser p){\n\t\t// until someone wins, loop through turns\n\t\twhile(!Game.gameWon){\n\n\t\t\t// get move from player\n\n\t\t\t// String move = Game.getCurrPlayer().getMove();\n\t\t\tString move = this.network.getMove();\n\t\t\tif(move.length()==2){\n\t\t\t\tmove = p.moveTranslate(move);\n\t\t\t}else{\n\t\t\t\tmove = p.wallTranslate(move);\n\t\t\t}\n\n\t\t\tif(move.isEmpty()){\n\t \tSystem.out.println(\"\\t[Move error]: Move is empty.\");\n\t\t\t\tkickPlayer();\n\t\t\t\tthis.network.kickLastPlayer();\n\t\t\t\tGame.nextTurn();\n\t\t\t\tif(this.checkForWin()){\n\t\t\t\t\tnotifyObservers(ui);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// try to play turn\n\t\t\tif(this.playTurn(move)){\n\t\t\t\tif(this.checkForWin()){\n\t\t\t\t\tplayers.get(curr).clearMoves();\n\t\t\t\t\tnotifyObservers(ui);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tGame.nextTurn();\n\t\t\t}else{\n\t\t\t\tkickPlayer();\n\t\t\t\tthis.network.kickLastPlayer();\n\t\t\t\tGame.nextTurn();\n\t\t\t\tif(this.checkForWin()){\n\t\t\t\t\tplayers.get(curr).clearMoves();\n\t\t\t\t\tnotifyObservers(ui);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tGame.updatePlayer(players.get(curr));\n\t\t\tthis.notifyObservers(this, Game.getBoard());\n\t\t}\n\t}", "public void Move(){\n for(int i = 0; i < moveList.length; i++){\n playerString = \"\";\n switch(moveList[i]) {\n case 1: {\n //TODO: Visited points to others\n System.out.println(\"Moving up!\");\n //Logic for fitness score might need to be moved\n if(!(game.mazeArray[game.playerPosition.getPlayerY() -1][game.playerPosition.getPlayerX()] == 1)){\n playerString.concat(\"game.playerPosition.getPlayerY() - 1 + game.playerPosition.getPlayerX()\");\n if(vistedMoves.contains(playerString)){\n vistedPoints += 2;\n } else {\n freedomPoints += 5;\n vistedMoves.add(playerString);\n }\n } else {\n System.out.println(\"Stuck\");\n wallHugs += 10;\n }\n game.moveUp();\n if(game.checkWin()){\n freedomPoints += 200;\n }\n break;\n }\n case 2: {\n System.out.println(\"Moving left!\");\n if(!(game.mazeArray[game.playerPosition.getPlayerY()][game.playerPosition.getPlayerX() -1] == 1)){\n playerString.concat(\"game.playerPosition.getPlayerY() + game.playerPosition.getPlayerX() -1\");\n if(vistedMoves.contains(playerString)){\n vistedPoints += 2;\n } else {\n freedomPoints += 5;\n vistedMoves.add(playerString);\n }\n } else {\n System.out.println(\"Stuck\");\n wallHugs += 1;\n }\n game.moveLeft();\n if(game.checkWin()){\n freedomPoints += 200;\n }\n break;\n }\n case 3: {\n System.out.println(\"Moving right!\");\n if(!(game.mazeArray[game.playerPosition.getPlayerY()][game.playerPosition.getPlayerX() +1] == 1)){\n playerString.concat(\"game.playerPosition.getPlayerY() + game.playerPosition.getPlayerX() +1\");\n if(vistedMoves.contains(playerString)){\n vistedPoints += 2;\n } else {\n freedomPoints += 5;\n vistedMoves.add(playerString);\n }\n } else {\n System.out.println(\"Stuck\");\n wallHugs += 1;\n }\n game.moveRight();\n if(game.checkWin()){\n freedomPoints += 200;\n }\n break;\n }\n case 4: {\n System.out.println(\"Moving down!\");\n if(!(game.mazeArray[game.playerPosition.getPlayerY() +1][game.playerPosition.getPlayerX()] == 1)){\n playerString.concat(\"game.playerPosition.getPlayerY() + 1 + game.playerPosition.getPlayerX()\");\n if(vistedMoves.contains(playerString)){\n vistedPoints += 2;\n } else {\n freedomPoints += 5;\n vistedMoves.add(playerString);\n }\n freedomPoints += 1;\n } else {\n System.out.println(\"Stuck\");\n wallHugs += 1;\n }\n game.moveDown();\n if(game.checkWin()){\n freedomPoints += 200;\n }\n break;\n }\n default: {\n System.out.println(\"End of line\");\n break;\n //You shouldn't be here mate.\n }\n }\n }\n\n }", "private void sendMessagetoRespectivePlayer(int num) {\n Message msg1;\n if(flag == \"player1\"){\n prevP1 = num;\n int newPositionGroup = num / 10;\n if(winningHoleGroup == newPositionGroup){\n msg1 = p1Handler.obtainMessage(3);\n }\n else if((winningHoleGroup == newPositionGroup-1) || (winningHoleGroup == newPositionGroup+1)){\n msg1 = p1Handler.obtainMessage(4);\n }\n else{\n msg1 = p1Handler.obtainMessage(5);\n }\n p1Handler.sendMessage(msg1);\n }\n else{\n prevP2 = num;\n int newPositionGroup = num / 10;\n if(winningHoleGroup == newPositionGroup){\n msg1 = p2Handler.obtainMessage(3);\n }\n else if((winningHoleGroup == newPositionGroup-1) || (winningHoleGroup == newPositionGroup+1)){\n msg1 = p2Handler.obtainMessage(4);\n }\n else{\n msg1 = p2Handler.obtainMessage(5);\n }\n p2Handler.sendMessage(msg1);\n }\n }", "abstract public List<Move> getPossibleMoves();", "public void isPawnPromotion(AbstractPiece pawn) { // aixo va en pawn noperque ha de crear una nova instancia abstracta xD aki nose no tinc clar\n\t\tString newPiece;\n\t\tboolean finished = false;\n\n\t\tString fileName;\n\t\tString fileExt = \".gif\";\n\t\tString filePackagePath = \"chess/icon/\"; \n\n\t\tPieceColor pColor = pawn.getColor();\n\n\t\twhile (!finished) {\n\t\t\tnewPiece = JOptionPane\n\t\t\t\t\t.showInputDialog(\"Choose a new piece Q / R / B / K\"); \n\n\t\t\tswitch(newPiece){\n\t\t\tcase \"Q\": \n\t\t\t\tpieces[pieceChosen] = new Queen(pawn.getPieceID(), pawn.getPosition(), pawn.getColumnRow(), true, false, BOARD_PIECE_LENGTH, false);\n\t\t\t\tfinished = true;\n\t\t\t\tbreak;\n\t\t\tcase \"R\": \n\t\t\t\tpieces[pieceChosen] = new Rook(pawn.getPieceID(), pawn.getPosition(), pawn.getColumnRow(), true, false, BOARD_PIECE_LENGTH, false);\n\t\t\t\tfinished = true;\n\t\t\t\tbreak;\n\t\t\tcase \"B\":\n\t\t\t\tpieces[pieceChosen] = new Bishop(pawn.getPieceID(), pawn.getPosition(), pawn.getColumnRow(), true, false, BOARD_PIECE_LENGTH, false);\n\t\t\t\tfinished = true;\n\t\t\t\tbreak;\n\t\t\tcase \"K\": \n\t\t\t\tpieces[pieceChosen] = new Knight(pawn.getPieceID(), pawn.getPosition(), pawn.getColumnRow(), true, false, BOARD_PIECE_LENGTH, false);\n\t\t\t\tfinished = true;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tSystem.out.println(\"Error: promote error option!\");\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif(finished){ \n\t\t\t\tString color = pColor.equals(PieceColor.WHITE) ? \"w\" : \"b\"; \n\t\t\t\tfileName = filePackagePath+color+pieces[pieceChosen].getName()+fileExt;\n\t\t\t\tpieces[pieceChosen].setPieceIcon(getImage(getCodeBase(), fileName));\n\t\t\t\tpieces[pieceChosen].setColor(pColor);\n\t\t\t} \n\t\t} \n\t}", "public void getPossibleMoves() { \n\t\t\tsuper.getPossibleMoves();\n\t\t\tfor (int i = 0; i < Math.abs(xrange); i++) {\n\t\t\t\tif (currentx + xrange - ((int) Math.pow(-1,color)*i) >= 0) { \n\t\t\t\t\tGameWindow.potentialMoves.add(GameWindow.GridCells[currentx + xrange - ((int) Math.pow(-1,color)*i) ][currenty]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( currentx - 1 >= 0 && currenty - 1 >= 0 &&\n\t\t\t\t\tGameWindow.GridCells[currentx + ((int) Math.pow(-1,color)) ][currenty - 1].isOccupiedByOpponent()) {\t// Diagonol left space occupied\n\t\t\t\tGameWindow.potentialMoves.add(GameWindow.GridCells[currentx + ((int) Math.pow(-1,color)) ][currenty - 1]);\n\t\t\t}\n\t\t\tif (currentx - 1 >= 0 && currenty + 1 <= 7 &&\n\t\t\t\t\tGameWindow.GridCells[currentx + ((int) Math.pow(-1,color)) ][currenty + 1].isOccupiedByOpponent()) { \t//Diagonol right space occupied\n\t\t\t\tGameWindow.potentialMoves.add(GameWindow.GridCells[currentx + ((int) Math.pow(-1,color)) ][currenty + 1]);\n\t\t\t}\n\t\t\t\n\t}", "public void actionPerformed(ActionEvent e) {\n timer.stop();\n //get all the available moves\n ArrayList<Point> possibleMoves = getCurrentlyValidMoves();\n canLastPlayerMove = false;\n try {\n //check if we can move\n if( possibleMoves.size() == 0 ){\n return;\n }\n //make an array to store the best moves available\n ArrayList<Point> bestMoves = new ArrayList<Point>();\n //the lower the level, the higher priority is assigned to the move\n //a move of level 10 is the absolute lowest\n //this heuristic follows the strategy I use, omitting situation-specific content\n int level = 10;\n for (Point p : possibleMoves) {\n int x = (int) p.getX();\n int y = (int) p.getY();\n if ((x == 0 || x == 7) && (y == 0 || y == 7)) {\n if (level > 0) {\n bestMoves.clear();\n level = 0;\n }\n bestMoves.add( p );\n } else if (level >= 1 && (x == 0 || y == 0 || x == 7 || y == 7)) {\n if (level > 1) {\n bestMoves.clear();\n level = 1;\n }\n bestMoves.add( p );\n } else if (level >= 2 && (x > 2 && x < 6 && y > 2 && y < 6)) {\n if ( level > 2) {\n bestMoves.clear();\n level = 2;\n }\n bestMoves.add( p );\n } else if (level >= 3 && x != 1 && x != 6 && y != 1 && y != 6) {\n if (level > 3) {\n bestMoves.clear();\n level = 3;\n }\n bestMoves.add(p);\n } else if (level >= 4) {\n bestMoves.add(p);\n }\n }\n //for debugging purposes, output the level of move chosen by the ai\n System.out.println(level);\n //select a random move from the pool of best moves\n Point move = bestMoves.get((int) (Math.random() * bestMoves.size()));\n int aix = (int) move.getX();\n int aiy = (int) move.getY();\n //move there\n attemptMove(aix, aiy);\n gamepieces[aix][aiy] = currentPlayer;\n //the ai moved, so this is true\n canLastPlayerMove = true;\n } finally { //if the ai moved or if it didn't\n //change the player\n currentPlayer = Color.WHITE;\n gameFrame.repaint();\n //if the human player has no moves left\n if( getCurrentlyValidMoves().size() == 0 ){\n if( canLastPlayerMove ){ //... and the ai could move\n //switch players, enable the ai to move again in 1 second\n currentPlayer = Color.BLACK;\n timer.start();\n }else{ //... and the ai couldn't move\n gameOver();\n }\n }\n }\n }", "public PentagoMove alphabetaw(PentagoBoardState boardState){\n PentagoBoardState pbs = (PentagoBoardState) boardState.clone();\n ArrayList<PentagoMove> legalmoves = pbs.getAllLegalMoves();\n\n PentagoMove bestmove = legalmoves.get(0);\n PentagoMove bestopponentmove = new PentagoMove(0,0,0,0,0);\n int bestmovescore = -9999999;\n int bestwhitescore = 0;\n //ArrayList<Integer> scores = new ArrayList<Integer>();\n for(int i = 0;i<legalmoves.size()-1;i++){\n\n PentagoBoardState newboard = (PentagoBoardState) pbs.clone();\n //System.out.println( pbs.getTurnPlayer() + \"BEFORE PROCESS\");\n PentagoMove next = legalmoves.get(i);\n\n newboard.processMove(next);\n\n int score = evaluate(newboard);\n //scores.add(score);\n //System.out.println( pbs.getTurnPlayer() + \" AFTER PROCES\");\n\n if(score > 100000){\n newboard.getWinner();\n newboard.printBoard();\n System.out.println(\"FOUND A WINNER\" + score);\n return next;\n }\n\n\n PentagoMove currentopponentmove;\n ArrayList<PentagoMove> opponentlegalmoves = newboard.getAllLegalMoves();\n if (opponentlegalmoves.size()!=0){\n currentopponentmove = opponentlegalmoves.get(0);\n }\n\n int minopponentmovescore = 999999;\n int thismovescore = -9999;\n ArrayList<PentagoMove> bestopponentmoves = new ArrayList<PentagoMove>();\n PentagoMove currentbestopponentmove = new PentagoMove(0,0,0,0,0);\n\n for(int a = 0;a<opponentlegalmoves.size()-1;a++){\n\n PentagoBoardState pbsopponent = (PentagoBoardState) newboard.clone();\n //System.out.println( pbs.getTurnPlayer() + \"BEFORE PROCESS\");\n PentagoMove opponentnext = opponentlegalmoves.get(a);\n\n pbsopponent.processMove(opponentnext);\n //System.out.println( pbs.getTurnPlayer() + \" AFTER PROCES\");\n //pbs.printBoard();\n\n int opponentscore = evaluate(pbsopponent);\n\n\n\n\n\n if (minopponentmovescore>opponentscore){\n //currentopponentmove = opponentnext;\n minopponentmovescore = opponentscore;\n bestopponentmoves.add(opponentnext);\n currentbestopponentmove = opponentnext;\n }\n\n\n }\n bestopponentmove = currentbestopponentmove;\n //lvl 3\n /*\n\n int lvl3minscore =99999;\n PentagoMove currentmaxmove;\n for (int r = 0;r<bestopponentmoves.size()-1;r++) {\n PentagoBoardState pbsopponent = (PentagoBoardState) newboard.clone();\n pbsopponent.processMove(bestopponentmoves.get(r));\n\n ArrayList<PentagoMove> maxlegalmoves = pbsopponent.getAllLegalMoves();\n if (maxlegalmoves.size() != 0) {\n currentmaxmove = maxlegalmoves.get(0);\n }\n int opponentscore = evaluate(pbsopponent);\n int findminmaxmovescore = -99999;\n for (int s = 0; s < maxlegalmoves.size() - 1; s++) {\n\n PentagoBoardState maxboard = (PentagoBoardState) pbsopponent.clone();\n //System.out.println( pbs.getTurnPlayer() + \"BEFORE PROCESS\");\n PentagoMove maxnext = maxlegalmoves.get(s);\n\n maxboard.processMove(maxnext);\n //System.out.println( pbs.getTurnPlayer() + \" AFTER PROCES\");\n //pbs.printBoard();\n\n int maxnextscore = evaluate(pbsopponent);\n if (findminmaxmovescore < maxnextscore) {\n currentmaxmove = maxnext;\n findminmaxmovescore = maxnextscore;\n }\n }\n if (thismovescore<findminmaxmovescore){\n //currentopponentmove = opponentnext;\n thismovescore = findminmaxmovescore;\n }\n\n //opponentscore = maxmovescore;\n }\n\n //end experiment\n\n\n\n\n if (mycolour ==1){\n lvl3minscore =minopponentmovescore;\n }\n */\n if (minopponentmovescore>bestmovescore){//minopponentmovescore\n System.out.println(\"max player move score: \"+score + \"Min : \" + minopponentmovescore);\n bestmovescore = minopponentmovescore;\n bestmove = next;\n bestwhitescore = score;\n\n }\n else if (minopponentmovescore == bestmovescore){\n if (score > bestwhitescore){\n System.out.println(\"max player move score: \"+score + \"Min : \" + minopponentmovescore);\n bestmovescore = minopponentmovescore;\n bestmove = next;\n bestwhitescore = score;\n }\n\n\n\n }\n\n\n }\n System.out.println(\"final max player move score: \"+ bestmovescore + \"\\n My best move: \"+bestmove.toPrettyString() + \"\\n My best move: \"+ bestopponentmove.toPrettyString());\n return bestmove;\n }", "public Move move() {\n\n byte[] piece;\n int pieceIndex;\n Move.Direction direction = null;\n int counter = 0;\n\n Scanner s = new Scanner(System.in);\n\n\n System.out.println(\"Please select piece to move: \");\n\n\n while (true) {\n try {\n pieceIndex = s.nextInt();\n\n if ((piece = getPiece(pieceIndex)) == null) {\n System.out.println(\"invalid index, try again!\");\n// check if selected piece is stuck\n } else if (\n (((player == Board.V) && (piece[1]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O ) || // UP\n ((player == Board.H) && (piece[1]-1 >=0) && (board.layout[piece[0]][piece[1]-1] == O)) || // DOWN\n ((player == Board.V) && (piece[0]-1 >=0) && (board.layout[piece[0]-1][piece[1]] == O)) || // LEFT\n (((player == Board.H) && (piece[0]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O )) // RIGHT\n {\n break;\n// if all are stuck pass turn\n } else if (counter + 1 < Board.getSize()) {\n counter++;\n System.out.println(\"Piece is stuck, pick another, \" + counter + \" pieces stuck.\");\n } else {\n System.out.println(\"Passing\");\n return null;\n }\n } catch (Exception e){\n System.out.println(\"Piece index expects int, try again\");\n s = new Scanner(System.in);\n }\n }\n System.out.println(\"Please select direction ('w' // 'a' // 's' // 'd'): \");\n\n boolean valid = false;\n while (!valid) {\n\n switch (s.next().charAt(0)) {\n // if the move requested is valid, break the loop, make the move on our record of layout and return the\n // move made\n case 'w':\n direction = Move.Direction.UP;\n valid = (((player == Board.V) && (piece[1]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O );\n break;\n\n case 'a':\n direction = Move.Direction.LEFT;\n valid = ((player == Board.V) && (piece[0]-1 >=0) && (board.layout[piece[0]-1][piece[1]] == O));\n break;\n\n case 's':\n direction = Move.Direction.DOWN;\n valid = ((player == Board.H) && (piece[1]-1 >=0) && (board.layout[piece[0]][piece[1]-1] == O));\n break;\n\n case 'd':\n direction = Move.Direction.RIGHT;\n valid = (((player == Board.H) && (piece[0]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O );\n break;\n default:\n System.out.println(\"Invalid key press, controls are wasd\");\n valid = false;\n }\n }\n Move move = makeMove(direction, pieceIndex);\n board.update(move, player);\n\n return move;\n }", "public List<ScoredMove> allValidMoves(GameState gm){\n\t\tList<ScoredMove> validMoves = new ArrayList<ScoredMove>();\n\t\t\n\t\t// check for draw move\n\t\tif (getDeckSize() > 0) {\n\t\t\tvalidMoves.add(new ScoredMove(ACTION.DRAW, null, null));\n\t\t}\n\t\t/*\n\t\telse {\n\t\t\t// check for discarding move (note: only allowing if decksize is empty)\n\t\t\tfor (Card c: getHand().getCards()){\n\t\t\t\tif (!(c instanceof MerchantShip)) {\n\t\t\t\t\tvalidMoves.add(new ScoredMove(ACTION.DISCARD, c, null));\n\t\t\t\t}\n\t\t\t}\n\t\t}*/\n\t\t\n\t\tvalidMoves.addAll(allDiscardMoves(gm));\n\t\t\n\t\t// check for playing merchant ships\n\t\tvalidMoves.addAll(allmShipMoves(gm));\n\t\t\n\t\t// add all attacks\n\t\tvalidMoves.addAll(allAttackMoves(gm));\n\t\t\n\t\tif (super.getVerbosity()) {\n\t\t\tSystem.out.println(\"Valid moves found: \" + validMoves.size());\n\t\t}\n\t\treturn validMoves;\n\t}", "public IGameAlgo.GameState getGameState (GameBoard.GameMove move){\n\t\t/*\n\t\t * If last move made by computer,check if computer wins.\n\t\t */\n\t\tif(this.board[lastMove.getRow()][lastMove.getColumn()]==BoardSigns.COMPUTER.getSign()) {\n\t\t\t if(\n\t\t (board[0][0] == BoardSigns.COMPUTER.getSign() && board[0][1] == BoardSigns.COMPUTER.getSign() && board[0][2] == BoardSigns.COMPUTER.getSign()) ||\n\t\t (board[1][0] == BoardSigns.COMPUTER.getSign() && board[1][1] == BoardSigns.COMPUTER.getSign() && board[1][2] == BoardSigns.COMPUTER.getSign()) ||\n\t\t (board[2][0] == BoardSigns.COMPUTER.getSign() && board[2][1] == BoardSigns.COMPUTER.getSign() && board[2][2] == BoardSigns.COMPUTER.getSign()) ||\n\t\t (board[0][0] == BoardSigns.COMPUTER.getSign() && board[1][0] == BoardSigns.COMPUTER.getSign() && board[2][0] == BoardSigns.COMPUTER.getSign()) ||\n\t\t (board[0][1] == BoardSigns.COMPUTER.getSign() && board[1][1] == BoardSigns.COMPUTER.getSign() && board[2][1] == BoardSigns.COMPUTER.getSign()) ||\n\t\t (board[0][2] == BoardSigns.COMPUTER.getSign() && board[1][2] == BoardSigns.COMPUTER.getSign() && board[2][2] == BoardSigns.COMPUTER.getSign()) ||\n\t\t (board[0][0] == BoardSigns.COMPUTER.getSign() && board[1][1] == BoardSigns.COMPUTER.getSign() && board[2][2] == BoardSigns.COMPUTER.getSign()) ||\n\t\t (board[0][2] == BoardSigns.COMPUTER.getSign() && board[1][1] == BoardSigns.COMPUTER.getSign() && board[2][0] == BoardSigns.COMPUTER.getSign())\n\t\t )\n\t\t\t\t return GameState.PLAYER_LOST;\t\t\t\t\t\t \n\t\t}\n\t\t/*\n\t\t * If last move made by player,check if player wins.\n\t\t */\n\t\telse {\n\t\t\t if(\n\t\t (board[0][0] == BoardSigns.PLAYER.getSign() && board[0][1] == BoardSigns.PLAYER.getSign() && board[0][2] == BoardSigns.PLAYER.getSign()) ||\n\t\t (board[1][0] == BoardSigns.PLAYER.getSign() && board[1][1] == BoardSigns.PLAYER.getSign() && board[1][2] == BoardSigns.PLAYER.getSign()) ||\n\t\t (board[2][0] == BoardSigns.PLAYER.getSign() && board[2][1] == BoardSigns.PLAYER.getSign() && board[2][2] == BoardSigns.PLAYER.getSign()) ||\n\t\t (board[0][0] == BoardSigns.PLAYER.getSign() && board[1][0] == BoardSigns.PLAYER.getSign() && board[2][0] == BoardSigns.PLAYER.getSign()) ||\n\t\t (board[0][1] == BoardSigns.PLAYER.getSign() && board[1][1] == BoardSigns.PLAYER.getSign() && board[2][1] == BoardSigns.PLAYER.getSign()) ||\n\t\t (board[0][2] == BoardSigns.PLAYER.getSign() && board[1][2] == BoardSigns.PLAYER.getSign() && board[2][2] == BoardSigns.PLAYER.getSign()) ||\n\t\t (board[0][0] == BoardSigns.PLAYER.getSign() && board[1][1] == BoardSigns.PLAYER.getSign() && board[2][2] == BoardSigns.PLAYER.getSign()) ||\n\t\t (board[0][2] == BoardSigns.PLAYER.getSign() && board[1][1] == BoardSigns.PLAYER.getSign() && board[2][0] == BoardSigns.PLAYER.getSign())\n\t\t )\n\t\t\t\t return GameState.PLAYER_WON;\t\n\t\t}\n\t\t/*\n\t\t * No one wins,check if in progress or game ends with tie.\n\t\t */\n\t\t\n\t\t //check if exist empty spots. \n\t\t\tfor(int i=0;i<3;i++)\n\t\t\tfor(int j=0;j<3;j++)\n\t\t\t\tif(board[i][j]==TicTacTow.BoardSigns.BLANK.getSign()) \n\t\t\t\t return GameState.IN_PROGRESS;\n\t\t\treturn GameState.TIE;\t\t\t\n\t}", "public void updatePossibleMovesOther(){\n\t\tif( hasMoved){\n\t\t\tpossibleMovesOther = null;\n\t\t\treturn;\n\t\t}\n\t\t// Get left castle updateMoves first\n\t\tchar[] temp = AlgebraicNotationHelper.getAlgebraicNotationLeftOf( startingFile, startingRank);\n\t\ttemp = AlgebraicNotationHelper.getAlgebraicNotationLeftOf( temp[0], temp[1]);\n\t\ttemp = AlgebraicNotationHelper.getAlgebraicNotationLeftOf( temp[0], temp[1]);\n\t\t// Should be b1 for light color King (or b8 for dark color King)\n\t\tAlgebraicNotation tempAN = new AlgebraicNotation( temp[0], temp[1]);\n\t\tpossibleMovesOther.add( tempAN);\n\t\t// Get right castle updateMoves next\n\t\ttemp = AlgebraicNotationHelper.getAlgebraicNotationRightOf( startingFile, startingRank);\n\t\ttemp = AlgebraicNotationHelper.getAlgebraicNotationRightOf( temp[0], temp[1]);\n\t\t// Should be g1 for light color King (or g8 for dark color King)\n\t\ttempAN = new AlgebraicNotation( temp[0], temp[1]);\n\t\tpossibleMovesOther.add( tempAN);\t\n\t}", "@Override\n public Map<Direction, List<Coordinate>> getPossibleMoves() {\n\n Map<Direction, List<Coordinate>> moves = new HashMap<>();\n\n Coordinate coordinate = this.getCoordinate();\n int row = coordinate.getRow();\n int col = coordinate.getCol();\n\n //Jumps\n List<Coordinate> jumps = new ArrayList<>();\n\n //\n //\n ////\n int tempRow1 = row - 2;\n int tempCol1 = col - 1;\n Coordinate tempCoordinate1 = new Coordinate(tempRow1, tempCol1);\n if (Board.inBounds(tempCoordinate1)) {\n jumps.add(tempCoordinate1);\n }\n\n ////\n //\n //\n int tempRow2 = row + 2;\n int tempCol2 = col - 1;\n Coordinate tempCoordinate2 = new Coordinate(tempRow2, tempCol2);\n if (Board.inBounds(tempCoordinate2)) {\n jumps.add(tempCoordinate2);\n }\n\n //////\n //\n int tempRow3 = row - 1;\n int tempCol3 = col - 2;\n Coordinate tempCoordinate3 = new Coordinate(tempRow3, tempCol3);\n if (Board.inBounds(tempCoordinate3)) {\n jumps.add(tempCoordinate3);\n }\n\n ///////\n //\n int tempRow4 = row - 1;\n int tempCol4 = col + 2;\n Coordinate tempCoordinate4 = new Coordinate(tempRow4, tempCol4);\n if (Board.inBounds(tempCoordinate4)) {\n jumps.add(tempCoordinate4);\n }\n\n ////\n //\n //\n int tempRow5 = row + 2;\n int tempCol5 = col + 1;\n Coordinate tempCoordinate5 = new Coordinate(tempRow5, tempCol5);\n if (Board.inBounds(tempCoordinate5)) {\n jumps.add(tempCoordinate5);\n }\n\n //\n //\n ////\n int tempRow6 = row - 2;\n int tempCol6 = col + 1;\n Coordinate tempCoordinate6 = new Coordinate(tempRow6, tempCol6);\n if (Board.inBounds(tempCoordinate6)) {\n jumps.add(tempCoordinate6);\n }\n\n //\n //////\n int tempRow7 = row + 1;\n int tempCol7 = col - 2;\n Coordinate tempCoordinate7 = new Coordinate(tempRow7, tempCol7);\n if (Board.inBounds(tempCoordinate7)) {\n jumps.add(tempCoordinate7);\n }\n\n //\n //////\n int tempRow8 = row + 1;\n int tempCol8 = col + 2;\n Coordinate tempCoordinate8 = new Coordinate(tempRow8, tempCol8);\n if (Board.inBounds(tempCoordinate8)) {\n jumps.add(tempCoordinate8);\n }\n\n if (!jumps.isEmpty()) {\n moves.put(Direction.Jump, jumps);\n }\n return moves;\n }", "public void evaluate(GameState gm, List<ScoredMove> moves) {\n\t\tfloat d = 0;\n\t\tCardSet cs;\n\t\tfloat newBattleListScore = 0;\n\t\t\n\t\tfloat currentHandScore = calcCardSetScore(gm, getHand());\n\t\tfloat currentBattleListScore = calcBattleListScore(gm, gm.getBattleList());\n\t\tfloat unknownCardsScore = calcCardSetScore(gm, getUnknownCards());\n\t\t\n\t\tif (super.getVerbosity()) {\n\t\t\tSystem.out.println(\"Current Hand Score: \" + currentHandScore);\n\t\t\tSystem.out.println(\"Current BattleList Score: \" + currentBattleListScore);\n\t\t\tSystem.out.println(\"UnknownCards Score: \" + unknownCardsScore\n\t\t\t\t+ \" | Count: \" + getUnknownCards().getCount() + \" | Avg/card: \" + \n\t\t\t\tunknownCardsScore/(float)getUnknownCards().getCount());\n\t\t}\n\t\t\n\t\tfor (ScoredMove m: moves) {\n\t\t\tif (m.getMove().getAction() == ACTION.DRAW) {\n\t\t\t\td = calcDrawScore(gm) + currentHandScore + currentBattleListScore;\n\t\t\t}\n\t\t\telse if (m.getMove().getAction() == ACTION.PLAY_ATTACK) {\n\t\t\t\tcs = new CardSet(getHand());\n\t\t\t\tcs.removeCard(m.getMove().getCard());\n\t\t\t\tnewBattleListScore = calcBattleListScore(gm, createNewBattleList(gm, m.getMove()));\n\t\t\t\td= calcCardSetScore(gm, cs) + newBattleListScore; \n\t\t\t}\n\t\t\telse if (m.getMove().getAction() == ACTION.PLAY_MERCHANT_SHIP) {\n\t\t\t\tcs = new CardSet(getHand());\n\t\t\t\tcs.removeCard(m.getMove().getCard());\n\t\t\t\tnewBattleListScore = calcBattleListScore(gm, createNewBattleList(gm, m.getMove()));\n\t\t\t\td= calcCardSetScore(gm, cs) + newBattleListScore;\n\t\t\t}\n\t\t\telse if (m.getMove().getAction() == ACTION.DISCARD) {\n\t\t\t\tcs = new CardSet(getHand());\n\t\t\t\tcs.removeCard(m.getMove().getCard());\n\t\t\t\td = calcCardSetScore(gm, cs) + currentBattleListScore;\n\t\t\t}\n\t\t\t\n\t\t\t// TODO: could be done better somewhere else?\n \t\tif (m.getMove().getAction() != ACTION.PLAY_MERCHANT_SHIP) {\n\t\t\t\td += calcMShipPenaltyScore(gm);\n\t\t\t}\n\t\t\t\n\t\t\tm.setScore(d);\n\t\t\tif (super.getVerbosity()) {\n\t\t\t\tSystem.out.println(m);\n\t\t\t}\n\t\t}\n\t}", "public List<ScoredMove> allmShipMoves(GameState gm){\n\t\t\n\t\tList<ScoredMove> mShipMoves = new ArrayList<ScoredMove>();\n\t\t\n\t\tif (getHand().hasMShip()) {\n\t\t\tfor (Card c: getHand().getCards()) {\n\t\t\t\tif (c instanceof MerchantShip) {\n\t\t\t\t\tmShipMoves.add(new ScoredMove(ACTION.PLAY_MERCHANT_SHIP, c, null));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn mShipMoves;\n\t}", "public abstract void calculateMoves();", "private void HandleOnMoveStart(Board board, Piece turn){}", "public ArrayList<Cell> getPseudoLegalMoves() {\n\n Cell[][] board = Board.getBoard();\n ArrayList<Cell> moves = new ArrayList<Cell>();\n\n //Possible ways to move a knight\n int[][] possibleOffsets = {{-2,-1},{-2,1},{-1,-2},{-1,2},{1,-2},{1,2},{2,1},{2,-1}};\n\n for(int i=0; i<possibleOffsets.length; i++){\n int x = possibleOffsets[i][0] + getRow();\n int y = possibleOffsets[i][1] + getColumn();\n\n //Making sure we dont leave the board\n if(x >= board.length || x < 0\n || y >= board.length || y < 0)\n continue;\n\n //Making sure destination does not contain a friendly piece\n if(Board.containsPieceOfColor(x,y,this.getColor()))\n continue;\n\n moves.add(board[x][y]);\n }\n\n return moves;\n }", "@Test\n public void testGetPossibleMoveCoordinate() throws Exception{\n ChessBoard board = new ChessBoard(8, 8);\n Piece p;\n\n p = new Pawn(board, Player.WHITE);\n p.setCoordinate(0, 0);\n assertEquals(2, p.getPossibleMoveCoordinate().size()); // first time move, therefore it should be able to advance two squares.\n\n\n p.setCoordinate(0, 1);\n assertEquals(1, p.getPossibleMoveCoordinate().size()); // already moved, therefore it could move two squares.\n\n\n /*\n * create a pawn in same group\n * put it ahead p, then p couldn't move\n */\n Piece friend = new Pawn(board, Player.WHITE);\n friend.setCoordinate(0, 2);\n assertEquals(0, p.getPossibleMoveCoordinate().size());\n\n /*\n * create an opponent piece at top right\n * therefore, p can move top right\n */\n Piece opponent_piece = new Pawn(board, Player.BLACK);\n opponent_piece.setCoordinate(1, 2);\n assertEquals(1, p.getPossibleMoveCoordinate().size());\n\n /*\n * p reaches top boundary\n */\n p.setCoordinate(0, 7);\n assertEquals(0, p.getPossibleMoveCoordinate().size());\n }", "@Override\n public void drawValidMove() {\n if(this.getPlayer().getPlayerID() % 2 != 0) {\n //Pawn can move one space forwards if no piece is in front\n if (board.getSquare(x-1, y).getPiece()== null) {\n board.getSquare(x-1, y).drawOutline();\n }\n \n //if first move, pawn can move 2 spaces forward\n if (!hasMoved && board.getSquare(x-2, y).getPiece() == null && board.getSquare(x-1, y).getPiece() == null) {\n board.getSquare(x-2, y).drawOutline();\n }\n \n //If there is an enemy piece in the diagonal forward square of the pawn, the pawn can move (capture the piece)\n if (y-1 > 0) { //ensures no arrayoutofbounds error\n if (board.getSquare(x-1, y-1) != null && board.getSquare(x-1, y-1).getPiece() != null &&\n board.getSquare(x-1, y-1).getPiece().getPlayer() != this.getPlayer()) {\n board.getSquare(x-1, y-1).drawOutline();\n }\n }\n \n if(y+1<SIZE) { //ensures no arrayoutofbounds error\n if (board.getSquare(x-1, y+1) != null && board.getSquare(x-1, y+1).getPiece() != null &&\n board.getSquare(x-1, y+1).getPiece().getPlayer() != this.getPlayer() ) {\n board.getSquare(x-1, y+1).drawOutline();\n }\n }\n \n System.out.println(\"\");\n //En passant\n if (y - 1 > 0) {\n \n System.out.println();\n if (board.getSquare(x, y-1).getPiece() != null) { \n System.out.println(\"the piece's enPassant is: \" + board.getSquare(x, y-1).getPiece().getEnPassant());\n System.out.println(\"The game's turn counter is: \" + board.getTurnCounter());\n }\n else {\n System.out.println(\"Null piece when checking for en passent.\");\n }\n \n if (board.getSquare(x, y-1).getPiece() != null && board.getSquare(x, y-1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y-1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x-1, y-1).drawOutline();\n board.getSquare(x-1, y-1).setEnPassent(true);\n }\n }\n \n if (y + 1 < SIZE) {\n if (board.getSquare(x, y+1).getPiece() != null && board.getSquare(x, y+1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y+1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x-1, y+1).drawOutline();\n board.getSquare(x-1, y+1).setEnPassent(true);\n }\n }\n }\n \n //If this pawn belongs to player 2:\n else {\n \n if (board.getSquare(x+1, y).getPiece() == null) {\n board.getSquare(x+1, y).drawOutline();\n }\n \n //if first move, pawn can move 2 spaces forward\n if (!hasMoved && board.getSquare(x+2, y).getPiece() == null && board.getSquare(x+1, y).getPiece() == null) {\n board.getSquare(x+2, y).drawOutline();\n \n }\n \n if(y-1 > 0) {\n if (board.getSquare(x+1, y-1) != null && board.getSquare(x+1, y-1).getPiece() != null &&\n board.getSquare(x+1, y-1).getPiece().getPlayer() != this.getPlayer() ) {\n board.getSquare(x+1, y-1).drawOutline();\n }\n }\n \n if(y+1 < SIZE) {\n if (board.getSquare(x+1, y+1) != null && board.getSquare(x+1, y+1).getPiece() != null &&\n board.getSquare(x+1, y+1).getPiece().getPlayer() != this.getPlayer()) {\n board.getSquare(x+1, y+1).drawOutline();\n }\n }\n \n //En passant\n if (y - 1 > 0) {\n if (board.getSquare(x, y-1).getPiece() != null &&board.getSquare(x, y-1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y-1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x+1, y-1).drawOutline();\n board.getSquare(x+1, y-1).setEnPassent(true);\n }\n }\n \n if (y + 1 < SIZE) {\n if (board.getSquare(x, y+1).getPiece() != null && board.getSquare(x, y+1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y+1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x+1, y+1).drawOutline();\n board.getSquare(x+1, y+1).setEnPassent(true);\n }\n }\n }\n }", "public abstract void process(final King pKing, final Piece pPiece, final Chess pChess);", "public int[][] getMovesKing(Piece p) {\n x = p.getX();\n y = p.getY();\n int legalMoves[][] = new int[8][8];\n\n //Sjekker alle åtte mulige trekk en konge har.\n if ((x + 1) < 8) {\n if (b.getPieceAt(y, (x + 1)) != null) {\n if (p.isWhite() != b.getPieceAt(y, (x + 1)).isWhite()) {\n legalMoves[y][(x + 1)] = 1;\n }\n } else {\n legalMoves[y][(x + 1)] = 1;\n }\n }\n\n if ((x + 1) < 8 && (y + 1) < 8) {\n if (b.getPieceAt((y + 1), (x + 1)) != null) {\n if (p.isWhite() != b.getPieceAt((y + 1), (x + 1)).isWhite()) {\n legalMoves[(y + 1)][(x + 1)] = 1;\n }\n } else {\n legalMoves[(y + 1)][(x + 1)] = 1;\n }\n }\n\n if ((x - 1) > -1 && (y - 1) > -1) {\n if (b.getPieceAt((y - 1), (x - 1)) != null) {\n if (p.isWhite() != b.getPieceAt((y - 1), (x - 1)).isWhite()) {\n legalMoves[(y - 1)][(x - 1)] = 1;\n }\n } else {\n legalMoves[(y - 1)][(x - 1)] = 1;\n }\n }\n\n if ((x + 1) < 8 && (y - 1) > -1) {\n if (b.getPieceAt((y - 1), (x + 1)) != null) {\n if (p.isWhite() != b.getPieceAt((y - 1), (x + 1)).isWhite()) {\n legalMoves[(y - 1)][(x + 1)] = 1;\n }\n } else {\n legalMoves[(y - 1)][(x + 1)] = 1;\n }\n }\n\n if ((x - 1) > -1) {\n if (b.getPieceAt(y, (x - 1)) != null) {\n if (p.isWhite() != b.getPieceAt(y, (x - 1)).isWhite()) {\n legalMoves[y][(x - 1)] = 1;\n }\n } else {\n legalMoves[y][(x - 1)] = 1;\n }\n }\n\n if ((y - 1) > -1) {\n if (b.getPieceAt((y - 1), x) != null) {\n if (p.isWhite() != b.getPieceAt((y - 1), x).isWhite()) {\n legalMoves[(y - 1)][x] = 1;\n }\n } else {\n legalMoves[(y - 1)][x] = 1;\n }\n }\n\n if ((y + 1) < 8) {\n if (b.getPieceAt((y + 1), x) != null) {\n if (p.isWhite() != b.getPieceAt((y + 1), x).isWhite()) {\n legalMoves[(y + 1)][x] = 1;\n }\n } else {\n legalMoves[(y + 1)][x] = 1;\n }\n }\n\n if ((x - 1) > -1 && (y + 1) < 8) {\n if (b.getPieceAt((y + 1), (x - 1)) != null) {\n if (p.isWhite() != b.getPieceAt((y + 1), (x - 1)).isWhite()) {\n legalMoves[(y + 1)][x - 1] = 1;\n\n }\n } else {\n legalMoves[(y + 1)][x - 1] = 1;\n }\n }\n //Sjekker så om passant trekk går.\n if(p.isWhite()){\n \n if(p.getY() == 7 && p.getX() == 4){\n if(b.getPieceAt(7, 6) == null && b.getPieceAt(7, 5) == null){\n if(b.getPieceAt(7,7) instanceof Rook){\n legalMoves[7][7] = 1;\n }\n }\n if(b.getPieceAt(7,3) == null && b.getPieceAt(7, 2) == null && b.getPieceAt(7, 1)==null){\n if(b.getPieceAt(7, 0) instanceof Rook){\n legalMoves[7][0] = 1;\n }\n }\n }\n }\n if(!p.isWhite()){\n if(p.getY() == 0 && p.getX() == 4){\n if(b.getPieceAt(0, 6) == null && b.getPieceAt(0, 5) == null){\n if(b.getPieceAt(0,7) instanceof Rook){\n legalMoves[0][7] = 1;\n }\n }\n if(b.getPieceAt(0,3) == null && b.getPieceAt(0, 2) == null && b.getPieceAt(0, 1)==null){\n if(b.getPieceAt(0, 0) instanceof Rook){\n legalMoves[0][0] = 1;\n }\n }\n }\n }\n\n return legalMoves;\n\n }", "private void busquets() {\n\t\ttry {\n\t\t\tThread.sleep(5000); // espera, para dar tempo de ver as mensagens iniciais\n\t\t} catch (InterruptedException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tint xInit = -25;\n\t\tint yInit = -10;\n\t\tplayerDeafaultPosition = new Vector2D(xInit*selfPerception.getSide().value(), yInit *selfPerception.getSide().value());\n\t\t\n\t\twhile (commander.isActive()) {\n\t\t\tupdatePerceptions(); // deixar aqui, no começo do loop, para ler o resultado do 'move'\n\t\t\tswitch (matchPerception.getState()) {\n\t\t\tcase BEFORE_KICK_OFF:\n\t\t\t\tcommander.doMoveBlocking(xInit, yInit);\t\t\t\t\n\t\t\t\tbreak;\n\t\t\tcase PLAY_ON:\n\t\t\t\tstate = State.ATTACKING;\n\t\t\t\texecuteStateMachine();\n\t\t\t\tbreak;\n\t\t\tcase KICK_OFF_LEFT:\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.LEFT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase KICK_OFF_RIGHT:\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.RIGHT) {\n\t\t\t\t\t//if(closer)\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CORNER_KICK_LEFT: // escanteio time esquerdo\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.LEFT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CORNER_KICK_RIGHT: // escanteio time direito\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.RIGHT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase KICK_IN_LEFT: // lateral time esquerdo\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.LEFT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\tcase KICK_IN_RIGHT: // lateal time direito\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.RIGHT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase FREE_KICK_LEFT: // Tiro livre time esquerdo\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.LEFT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase FREE_KICK_RIGHT: // Tiro Livre time direito\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.RIGHT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase FREE_KICK_FAULT_LEFT:\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.LEFT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase FREE_KICK_FAULT_RIGHT:\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.RIGHT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase GOAL_KICK_LEFT:\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.LEFT) {\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase GOAL_KICK_RIGHT:\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.RIGHT) {\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase AFTER_GOAL_LEFT:\n\t\t\t\tcommander.doMoveBlocking(xInit, yInit);\t\n\t\t\t\tbreak;\n\t\t\tcase AFTER_GOAL_RIGHT:\n\t\t\t\tcommander.doMoveBlocking(xInit, yInit);\t\n\t\t\t\tbreak;\n\t\t\tcase INDIRECT_FREE_KICK_LEFT:\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.LEFT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase INDIRECT_FREE_KICK_RIGHT:\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.RIGHT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}", "public String getMoveConverted(String move, boolean whiteTeamMoving) {\n\t\tif (move.startsWith(\"O-O-O\")) { //Queenside castle\n\t\t\tint row = whiteTeamMoving ? 0 : 7;\n\t\t\treturn row + \"\" + 4 + \";\" + row + \"\" + 0 + \";\" + (6 * (whiteTeamMoving ? 1 : -1)) + \";CASTLE\";\n\t\t} else if (move.startsWith(\"O-O\")) { //Kingside castle\n\t\t\tint row = whiteTeamMoving ? 0 : 7;\n\t\t\treturn row + \"\" + 4 + \";\" + row + \"\" + 7 + \";\" + (6 * (whiteTeamMoving ? 1 : -1)) + \";CASTLE\";\n\t\t}\n\n\t\tMatcher matcher = matchingPattern.matcher(move);\n\t\tmatcher.find();\n\n\t\t//Get the matching groups from the regex\n\t\tString pieceType = matcher.group(1);\n\t\tString fromSpecifier = matcher.group(2);\n\t\tString capture = matcher.group(3);\n\t\tString toLocation = matcher.group(4);\n\t\tString upgradeType = matcher.group(5);\n\n\t\tboolean isCapture = capture != null && capture.equals(\"x\");\n\n\t\t//Get the piece type\n\t\tint piece = getPieceNumFromStr(pieceType);\n\n\t\tif (piece != 1) {\n\t\t\tresetEnpassant(whiteTeamMoving ? 1 : -1);\n\t\t}\n\n\t\t//Get the already known row and column values\n\t\tint fromRow = -1;\n\t\tint fromCol = -1;\n\t\tif (fromSpecifier != null) {\n\t\t\tMatcher fromMatcher = positionPattern.matcher(fromSpecifier);\n\t\t\tfromMatcher.find();\n\n\t\t\tString col = fromMatcher.group(1);\n\t\t\tString row = fromMatcher.group(2);\n\n\t\t\tif (col != null) fromCol = (int)col.charAt(0) - (int)'a';\n\t\t\tif (row != null) fromRow = (int)row.charAt(0) - (int)'1';\n\t\t}\n\n\t\t//Get the to row and column values\n\t\tint toCol = (int)toLocation.charAt(0) - (int)'a';\n\t\tint toRow = (int)toLocation.charAt(1) - (int)'1';\n\n\t\t//Figure out what type of piece this will be when it is done\n\t\tint newType = piece;\n\t\tif (upgradeType != null) newType = getPieceNumFromStr(upgradeType);\n\n\t\tif (fromRow == -1 || fromCol == -1) {\n\t\t\tList<String> possibleFroms = new LinkedList<String>();\n\t\t\tif (piece == 1) { //If it is a pawn\n\t\t\t\tif (whiteTeamMoving) {\n\t\t\t\t\tif (isCapture) {\n\t\t\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol+1));\n\t\t\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol-1));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol));\n\t\t\t\t\t\tif (toRow == 3) {\n\t\t\t\t\t\t\tpossibleFroms.add((toRow-2) + \"\" + (toCol));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (isCapture) {\n\t\t\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol+1));\n\t\t\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol-1));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol));\n\t\t\t\t\t\tif (toRow == 4) {\n\t\t\t\t\t\t\tpossibleFroms.add((toRow+2) + \"\" + (toCol));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (piece == 2) { //If it is a rook\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toCol) {\n\t\t\t\t\t\tpossibleFroms.add(toRow + \"\" + i);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toRow) {\n\t\t\t\t\t\tpossibleFroms.add(i + \"\" + toCol);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (piece == 3) { //If it is a knight\n\t\t\t\tpossibleFroms.add((toRow+2) + \"\" + (toCol+1));\n\t\t\t\tpossibleFroms.add((toRow+2) + \"\" + (toCol-1));\n\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol+2));\n\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol-2));\n\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol+2));\n\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol-2));\n\t\t\t\tpossibleFroms.add((toRow-2) + \"\" + (toCol+1));\n\t\t\t\tpossibleFroms.add((toRow-2) + \"\" + (toCol-1));\n\t\t\t} else if (piece == 4) { //If it is a bishop\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toCol) {\n\t\t\t\t\t\tpossibleFroms.add((toRow - toCol + i) + \"\" + (i));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toRow) {\n\t\t\t\t\t\tpossibleFroms.add((i) + \"\" + (toRow + toCol - i));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (piece == 5) { //If it is a queen\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toCol) {\n\t\t\t\t\t\tpossibleFroms.add(toRow + \"\" + i);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toRow) {\n\t\t\t\t\t\tpossibleFroms.add(i + \"\" + toCol);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toCol) {\n\t\t\t\t\t\tpossibleFroms.add((toRow - toCol + i) + \"\" + (i));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toRow) {\n\t\t\t\t\t\tpossibleFroms.add((i) + \"\" + (toRow + toCol - i));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (piece == 6) { //If it is a king\n\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol));\n\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol));\n\t\t\t\tpossibleFroms.add((toRow) + \"\" + (toCol+1));\n\t\t\t\tpossibleFroms.add((toRow) + \"\" + (toCol-1));\n\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol+1));\n\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol-1));\n\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol+1));\n\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol-1));\n\t\t\t}\n\n\t\t\tfinal int fr = fromRow;\n\t\t\tfinal int fc = fromCol;\n\t\t\tOptional<String> originalLocationOP = possibleFroms.stream().filter((s)->{\n\t\t\t\tif (s.contains(\"-\")) return false;\n\n\t\t\t\tint r = Integer.parseInt(s.charAt(0)+\"\");\n\t\t\t\tint c = Integer.parseInt(s.charAt(1)+\"\");\n\n\t\t\t\tif (r < 0 || r > 7 || c < 0 || c > 7) return false;\n\n\t\t\t\tif (board[r][c] != piece * (whiteTeamMoving ? 1 : -1)) return false;\n\n\t\t\t\tif (fr != -1 && fr != r) return false;\n\t\t\t\tif (fc != -1 && fc != c) return false;\n\n\t\t\t\tif (!isLegalMove((r + \"\" + c) + \";\" + (toRow + \"\" + toCol) + \";\" + piece * (whiteTeamMoving ? 1 : -1))) return false;\n\n\t\t\t\treturn true;\n\t\t\t}).findAny(); \n\n\t\t\tString originalLoc = originalLocationOP.get();\n\t\t\tfromRow = Integer.parseInt(originalLoc.charAt(0)+\"\");\n\t\t\tfromCol = Integer.parseInt(originalLoc.charAt(1)+\"\");\n\t\t}\n\n\t\treturn (fromRow + \"\" + fromCol) + \";\" + (toRow + \"\" + toCol) + \";\" + newType * (whiteTeamMoving ? 1 : -1);\n\t}", "public void setValidMoves(Board board, int x, int y, int playerType) {\n\t\tmoves.clear();\n\t\t// if this is pawn's first move, it can move two squares forward\n\t\tif (firstMove == true)\n\t\t{\n\t\t\t// white moves forward with y++\n\t\t\tif(this.getPlayer() == 1)\n\t\t\t{\n\t\t\t\tPoint firstMove = new Point(x + 0, y + 2);\n\t\t\t\tif (board.getPiece(x, y + 1) == null && board.getPiece(x, y + 2) == null)\n\t\t\t\t{\n\t\t\t\t\t\tmoves.add(firstMove);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// black moves forward with y--\n\t\t\telse\n\t\t\t{\n\t\t\t\tPoint firstMove = new Point(x + 0, y - 2);\n\t\t\t\tif (board.getPiece(x, y - 1) == null && board.getPiece(x, y - 2) == null)\n\t\t\t\t{\n\t\t\t\t\t\tmoves.add(firstMove);\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif (this.getPlayer() == 1)\n\t\t{\n\t\t\t// if a piece is occupying a square diagonal from pawn, it can capture\n\t\t\tif (x + 1 < 8 && y + 1 < 8 && x + 1 >= 0 && y + 1 >= 0)\n\t\t\t{\n\t\t\t\tPoint move = new Point(x + 1, y + 1);\n\t\t\t\tif (board.getPiece(x + 1, y + 1) != null)\n\t\t\t\t{\n\t\t\t\t\tif (board.getPiece(x+1,y+1).getPlayer() != this.getPlayer())\n\t\t\t\t\t{\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (x - 1 < 8 && y + 1 < 8 && x - 1 >= 0 && y + 1 >= 0)\n\t\t\t{\n\t\t\t\tPoint move = new Point(x - 1, y + 1);\n\t\t\t\tif (board.getPiece(x - 1, y + 1) != null)\n\t\t\t\t{\n\t\t\t\t\tif (board.getPiece(x - 1, y + 1).getPlayer() != this.getPlayer())\n\t\t\t\t\t{\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\t// if no piece is in front of pawn, it can move forward one square\n\t\t\tif (x < 8 && y + 1 < 8 && x >= 0 && y + 1 >=0)\n\t\t\t{\n\t\t\t\tPoint move = new Point(x + 0, y + 1);\n\t\t\t\tif (board.getPiece(x, y + 1) == null)\n\t\t\t\t{\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// if a piece is occupying a square diagonal from pawn, it can capture\n\t\t\tif (x + 1 < 8 && y - 1 < 8 && x + 1 >= 0 && y - 1 >= 0)\n\t\t\t{\n\t\t\t\tPoint move = new Point(x + 1, y - 1);\n\t\t\t\tif (board.getPiece(x + 1, y - 1) != null)\n\t\t\t\t{\n\t\t\t\t\tif (board.getPiece(x + 1,y - 1).getPlayer() != this.getPlayer())\n\t\t\t\t\t{\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (x - 1 < 8 && y - 1 < 8 && x - 1 >= 0 && y - 1 >= 0)\n\t\t\t{\n\t\t\t\tPoint move = new Point(x - 1, y - 1);\n\t\t\t\tif (board.getPiece(x - 1, y - 1) != null)\n\t\t\t\t{\n\t\t\t\t\tif (board.getPiece(x - 1, y - 1).getPlayer() != this.getPlayer())\n\t\t\t\t\t{\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\t// if no piece is in front of pawn, it can move forward one square\n\t\t\tif (x < 8 && y - 1 < 8 && x >= 0 && y - 1 >=0)\n\t\t\t{\n\t\t\t\tPoint move = new Point(x + 0, y - 1);\n\t\t\t\tif (board.getPiece(x, y - 1) == null)\n\t\t\t\t{\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}", "public Move movePiece(int turn) {\n\t\tboolean error = false;\n\t\tString moveInput = null;\n\t\tString origin = null;\n\t\tboolean isCorrectTurn = false;\n\t\t@SuppressWarnings(\"resource\")\n\t\tScanner keyboard = new Scanner(System.in);\n\n\t\tdo {\n\t\t\t\n\t\t\ttry {\n\t\t\t\tdo {\n\t\t\t\t\tSystem.out.println(\"Which piece would you like to move?\");\n\t\t\t\t\torigin = keyboard.next();\n\n\t\t\t\t\tif(validateInput(origin)) {\n\t\t\t\t\t\tSystem.out.println(\"Error in input, please try again\");\n\t\t\t\t\t\terror = true; \n\t\t\t\t\t} else {\n\t\t\t\t\t\n\t\t\t\t\t\terror = false;\n\t\t\t\t\t}\n\n\t\t\t\t}while(error);\n\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tString xOrigin = origin.substring(0, 1);\n\t\t\t\tint yOrigin = Integer.parseInt(origin.substring(1,2));\n\t\t\t\tint convertedXOrigin = convertXPosition(xOrigin);\n\t\t\t\tyOrigin -= 1;\n\t\t\t\t\nif((board.getBoard()[yOrigin][convertedXOrigin] == turn) || (board.getBoard()[yOrigin][convertedXOrigin] == (turn + 2))) {\n\t\t\t\tisCorrectTurn = true;\n\t\t\t\tChecker checker = validatePiece(convertedXOrigin, yOrigin);\t\n\t\t\t\tdo {\n\t\t\t\t\t\n\t\t\t\t\t\tSystem.out.println(\"Where would you like to move\");\n\t\t\t\t\t\t moveInput = keyboard.next();\n\t\t\t\t\t\tif(validateInput(moveInput)) {\n\t\t\t\t\t\t\tSystem.out.println(\"Error in Input, please try again\");\n\t\t\t\t\t\t\terror = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\terror = false;\n\t\t\t\t\t\t//\tSystem.out.println(\"No errors found with input move\");\n\t\t\t\t\t\t}\n\n\t\t\t\t} while(error);\n\t\t\t\t\n\t\t\t\tString xMove = moveInput.substring(0, 1);\n\t\t\t\tint yMove = Integer.parseInt(moveInput.substring(1,2));\n\t\t\t\tint convertedXMove = convertXPosition(xMove);\n\t\t\t\tyMove -= 1;\n\t\t\t\tboolean isMovingRight = isMovingRight(convertedXOrigin, yOrigin, convertedXMove, yMove);\n\t\t\t\tboolean isMovingDown = isMovingDown(convertedXOrigin, yOrigin, convertedXMove, yMove);\n\t\t\t\tMove move = null;\n\t\t\t\t\n\t\t\t\t//checks to see if the move itself is valid\n\t\t\t\ttry {\nif(isMoveValid(convertedXOrigin, yOrigin, convertedXMove, yMove, isMovingRight, isMovingDown)) {\n\t\t\t\tif(isSpaceTaken(convertedXMove, yMove)) {\n\t\t\t\t\t//System.out.println(\"Space is taken\");\n\t\t\t\t\tif(isPieceEnemy(convertedXMove, yMove, checker, turn)) {\n\t\t\t\t\t\tif(isJumpValid(convertedXOrigin, yOrigin, convertedXMove, yMove, isMovingRight, isMovingDown)) {\n\t\t\t\t\t\t\tif(isMovingRight) {\n\t\t\t\t\t\t\t\t//checks to see if the piece is moving up or down\n\t\t\t\t\t\t\t\tif(isMovingDown) {\n\t\t\t\t\t\t\t\t\t//means the piece is moving right and down\n\t\t\t\t\t\t\t\t\t move = new Move(convertedXOrigin, yOrigin, convertedXMove + 1, yMove + 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\t\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t//means the piece is moving right, but up\n\t\t\t\t\t\t\t\t\t move = new Move(convertedXOrigin, yOrigin, convertedXMove + 1, yMove - 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif(isMovingDown) {\n\t\t\t\t\t\t\t\t\t//means its moving left and down\n\t\t\t\t\t\t\t\t\tmove = new Move(convertedXOrigin, yOrigin, convertedXMove - 1, yMove + 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t//means it's moving left and up\n\t\t\t\t\t\t\t\t\tmove = new Move(convertedXOrigin, yOrigin, convertedXMove - 1, yMove - 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\t\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t//System.out.println(\"Space isn't taken\");\n\t\t\t\t\tmove = new Move(convertedXOrigin, yOrigin, convertedXMove, yMove);\n\t\t\t\t\tmodel.moves.add(move);\n\t\t\t\t\tif(canBeKing(checker, move)) {\n\t\t\t\t\t\tchecker = convertToKing(checker, move);\n\t\t\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\tprintBoard();\n\t\t\t\t\t\treturn move;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\t\tupdateBoard(move);\n\t\t\t\t\t\n\t\t\t\t\tprintBoard();\n\t\t\t\t\treturn move;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tSystem.out.println(\"Error in move\");\n\t\t\t\t//System.out.println(\"It's not your turn\");\n\t\t\t\tisCorrectTurn = false;\n\t\t\t\t}\n\t\t\t\t} catch (NullPointerException e) {\n\t\t\t\t\tSystem.out.println(\"NullPointerException - Error\");\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tif(canBeKing(checker, move)) {\n\t\t\t\tchecker = convertToKing(checker, move);\n\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\t\n\t\t\t\tprintBoard();\n\t\t\t\treturn move;\n}\n\n\n\n\t\t\t\t\n\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\tupdateBoard(move);\n\t\t\t\t\n\t\t\t\tprintBoard();\n\t\t\t\treturn move;\n\t\t\t\t}\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\tSystem.out.println(\"Error in Input. Please try again\");\n\t\t\t}\n\t\t\n\t\t}while(!isCorrectTurn);\n\n\t\tprintBoard();\n\t\treturn null;\n\t\t\n\t}", "public void makeMove(Move m){\n int oldTurn = turn;\n turn = -turn;\n moves++;\n enPassant = -1;\n if (m.toY == 0){ // white rook space\n if (m.toX == 0){\n castles &= nWHITE_LONG;\n //castles[1] = false;\n }else if (m.toX == 7){\n castles &= nWHITE_SHORT;\n //castles[0] = false;\n }\n } else if (m.toY == 7){ // black rook space\n if (m.toX == 0){\n castles &= nBLACK_LONG;\n //castles[3] = false;\n }else if (m.toX == 7){\n castles &= nBLACK_SHORT;\n //castles[2] = false;\n }\n }\n if (m.piece == WHITE_ROOK && m.fromY == 0){\n if (m.fromX == 0){castles &= nWHITE_LONG;} //castles[1] = false;}\n else if (m.fromX == 7){castles &= nWHITE_SHORT;} //castles[0] = false;}\n } else if (m.piece == BLACK_ROOK && m.fromY == 7){\n if (m.fromX == 0){castles &= nBLACK_LONG;} //castles[3] = false;}\n else if (m.fromX == 7){castles &= nBLACK_SHORT;} //castles[2] = false;}\n }\n // castling\n if (m.piece % 6 == 0){\n if (oldTurn == WHITE){\n castles &= 0b1100;\n //castles[0] = false; castles[1] = false;\n } else {\n castles &= 0b11;\n //castles[2] = false; castles[3] = false;\n }\n if (m.toX - m.fromX == 2){ // short\n board[m.fromY][m.fromX] = 0;\n board[m.toY][m.toX] = m.piece;\n // rook\n board[m.fromY][5] = board[m.fromY][7];\n board[m.fromY][7] = 0;\n return;\n } else if (m.toX - m.fromX == -2){ // long\n board[m.fromY][m.fromX] = 0;\n board[m.toY][m.toX] = m.piece;\n // rook\n board[m.fromY][3] = board[m.fromY][0];\n board[m.fromY][0] = 0;\n return;\n }\n } else if (m.piece % 6 == 1) { // pawn move\n stalemateCountdown = 0; // resets on a pawn move\n // promotion\n if (m.toY % 7 == 0){\n board[m.toY][m.toX] = m.promoteTo;\n board[m.fromY][m.fromX] = 0;\n return;\n }\n // en passant\n else if (m.fromX != m.toX && board[m.toY][m.toX] == 0){\n board[m.fromY][m.fromX] = 0;\n board[m.toY][m.toX] = m.piece;\n if (oldTurn == WHITE){\n board[4][m.toX] = 0;\n }else{\n board[3][m.toX] = 0;\n }\n return;\n } else if (m.toY - m.fromY == 2*oldTurn){\n enPassant = m.fromX;\n }\n }\n // regular\n if (board[m.toY][m.toX] != 0){\n stalemateCountdown = 0; // resets on a capture\n }\n board[m.fromY][m.fromX] = 0;\n board[m.toY][m.toX] = m.piece;\n }", "public void play() {\n HashSet<Board> positionsPlayed = new HashSet<Board>();\n _board = new Board();\n\n while (true) {\n int playerInd = _board.turn().ordinal();\n Move next;\n if (_playing) {\n if (_board.gameOver()) {\n announceWinner();\n _playing = false;\n continue;\n }\n if (_hasGUI) {\n if (_players[playerInd].type().equals(\"human\")) {\n if (_ready) {\n next = _nextMove;\n } else if (_readyCommand) {\n processCommand(_nextCommand);\n next = null;\n } else {\n continue;\n }\n } else {\n next = _players[playerInd].makeMove();\n }\n } else {\n next = _players[playerInd].makeMove();\n }\n assert !_playing || next != null;\n } else {\n if (_hasGUI) {\n System.out.print(\"\");\n if (_readyCommand) {\n processString(_nextCommand);\n }\n } else {\n getMove();\n }\n next = null;\n }\n if (next != null) {\n assert _board.isLegal(next);\n _board.makeMove(next);\n if (_players[playerInd].type().equals(\"machine\") && !_hasGUI) {\n System.out.println(_players[playerInd].side().abbrev().toUpperCase() + \"::\" + next.toString());\n if (_autoprint) {\n System.out.println(_board.toString2());\n }\n }\n if (_board.gameOver()) {\n announceWinner();\n _playing = false;\n }\n }\n _ready = false;\n }\n }", "public static void updatePositions() {\n\t\tfor(Square s1 : ChessBoard.BOARD_SQUARES) {\n\t\t\tif(s1.hasPiece()) {\n\t\t\t\t(s1.getPiece()).setPosition(s1.getPosition());\n\t\t\t\t(s1.getPiece()).updatePossibleMoves();\n\t\t\t}\n\t\t}\n\t}", "public String[] getPossibleMoves(Position p)\r\n\t{\r\n\t\tint x,y,z,counter = 0; \r\n\t\tString[] moves;\r\n\t\t\r\n\t\tx = p.getX();\r\n\t\ty = p.getY();\r\n\t\tz = p.getZ();\r\n\t\t\r\n\t\tif(y+1 < maze.length)\r\n\t\t\tif(this.maze[y+1][z][x] == 0)\r\n\t\t\t\tcounter++;\r\n\t\tif(y-1 >= 0)\r\n\t\t\tif(this.maze[y-1][z][x] == 0)\r\n\t\t\t\tcounter++;\r\n\t\tif(z+1 < maze[0].length)\r\n\t\t\tif(this.maze[y][z+1][x] == 0)\r\n\t\t\t\tcounter++;\r\n\t\tif(z-1 >= 0)\r\n\t\t\tif(this.maze[y][z-1][x] == 0)\r\n\t\t\t\tcounter++;\r\n\t\tif(x+1 < maze[0][0].length)\r\n\t\t\tif(this.maze[y][z][x+1] == 0)\r\n\t\t\t\tcounter++;\r\n\t\tif(x-1 >= 0)\r\n\t\t\tif(this.maze[y][z][x-1] == 0)\r\n\t\t\t\tcounter++;\r\n\t\t\r\n\t\tmoves = new String[counter];\r\n\t\tint j = 0;\r\n\t\t\r\n\t\tif(y+1 < maze.length)\r\n\t\t\tif(this.maze[y+1][z][x] == 0)\r\n\t\t\t{\r\n\t\t\t\tmoves[j] = \"Up\";\r\n\t\t\t\tj++;\r\n\t\t\t}\r\n\t\tif(y-1 >= 0)\r\n\t\t\tif(this.maze[y-1][z][x] == 0)\r\n\t\t\t{\r\n\t\t\t\tmoves[j] = \"Down\";\r\n\t\t\t\tj++;\r\n\t\t\t}\r\n\t\tif(z+1 < maze[0].length)\r\n\t\t\tif(this.maze[y][z+1][x] == 0)\r\n\t\t\t{\r\n\t\t\t\tmoves[j] = \"Forward\";\r\n\t\t\t\tj++;\r\n\t\t\t}\r\n\t\tif(z-1 >= 0)\r\n\t\t\tif(this.maze[y][z-1][x] == 0)\r\n\t\t\t{\r\n\t\t\t\tmoves[j] = \"Backward\";\r\n\t\t\t\tj++;\r\n\t\t\t}\r\n\t\tif(x+1 < maze[0][0].length)\r\n\t\t\tif(this.maze[y][z][x+1] == 0)\r\n\t\t\t{\r\n\t\t\t\tmoves[j] = \"Right\";\r\n\t\t\t\tj++;\r\n\t\t\t}\r\n\t\tif(x-1 >= 0)\r\n\t\t\tif(this.maze[y][z][x-1] == 0)\r\n\t\t\t{\r\n\t\t\t\tmoves[j] = \"Left\";\r\n\t\t\t\tj++;\r\n\t\t\t}\r\n\t\t\r\n\t\treturn moves;\r\n\t\t\r\n\t}", "private Point move(Point[] players, int[] chat_ids, Point self)\n\t{\n\t\t//Move to a new position within the room anywhere within 6 meters of your current position. Any conversation you were previously engaged in is terminated: you have to be stationary to chat.\n\t\t//Initiate a conversation with somebody who is standing at a distance between 0.5 meters and 2 meters of you. In this case you do not move. You can only initiate a conversation with somebody on the next turn if they and you are both not currently engaged in a conversation with somebody else. \t\n\t\tint i = 0, target = 0;\n\t\twhile (players[i].id != self_id) i++;\n\t\t//look through players who are within 6 meters => Point[] players\n\t\tPoint p = self;\n for (target = 0; target<players.length; ++target) {\n\t\t\t//if we do not contain any information on them, they are our target => W[]\n\t\t\tif (W[p.id] != -1 || p.id == self.id) continue;\n p = players[target];\n }\n if (p.equals(self)) {\n for (target = 0; target < players.length; ++target) {\n if (W[p.id] == 0 || p.id == self.id) continue;\n p = players[target];\n }\n }\n if (!p.equals(self)) {\n\t\t\t// compute squared distance\n\t\t\tdouble dx1 = self.x - p.x;\n\t\t\tdouble dy1 = self.y - p.y;\n\t\t\tdouble dd1 = dx1 * dx1 + dy1 * dy1;\n\t\t\t//check if they are engaged in conversations with someone\n\t\t\tint chatter = 0;\n\t\t\twhile (chatter<players.length && players[chatter].id != chat_ids[target]) chatter++;\n\n\t\t\t//check if they are engaged in conversations with someone and whether that person is in our vicinity\n\t\t\tif(chat_ids[target]!=p.id && chatter!=players.length)\n\t\t\t{\n\t\t\t\t//if they are, we want to stand in front of them, .5 meters in the direction of who they're conversing with => check if result is within 6meters\n\t\t\t\tPoint other = players[chatter];\n\t\t\t\tdouble dx2 = self.x - other.x;\n\t\t\t\tdouble dy2 = self.y - other.y;\n\t\t\t\tdouble dd2 = dx2 * dx2 + dy2 * dy2;\n\n\t\t\t\tdouble dx3 = dx2-dx1;\n\t\t\t\tdouble dy3 = dy2-dy1;\n\t\t\t\tdouble dd3 = Math.sqrt(dx3 * dx3 + dy3 * dy3);\n\n\t\t\t\tdouble dx4 = (dx2 - 0.5*(dx3/dd3)) * -1;\n\t\t\t\tdouble dy4 = (dy2 - 0.5*(dy3/dd3)) * -1;\n\t\t\t\tdouble dd4 = dx4 * dx4 + dy4 * dy4;\n\n\t\t\t\tif (dd4 <= 2.0)\n\t\t\t\t\treturn new Point(dx4, dy4, self.id);\n }\n\t\t\t//if not chatting to someone or don't know position of chatter, just get as close to them as possible\n\t\t\telse return new Point((dx1-0.5*(dx1/dd1)) * -1, (dy1-0.5*(dy1/dd1)) * -1, self.id);\t\t\t\t\n\t\t}\n\n\t\t\tdouble dir = random.nextDouble() * 2 * Math.PI;\n\t\t\tdouble dx = 6 * Math.cos(dir);\n\t\t\tdouble dy = 6 * Math.sin(dir);\n\t\t\treturn new Point(dx, dy, self_id);\n\t}", "public boolean movePiece(int player, int from, int to) {\n\n int piece = players.get(player).getPiece(from);\n\n // PIECELISTENER : Throw PieceEvent to PieceListeners\n for (PieceListener listener : pieceListeners) {\n PieceEvent pieceEvent = new PieceEvent(this, player, piece, from, to);\n listener.pieceMoved(pieceEvent);\n }\n\n if (piece != -1) {\n //last throw was a 6, but player is in starting position\n //end of turn\n if (this.lastThrow == 6 && players.get(player).inStartingPosition() && from == 0) {\n // PLAYERLISTENER : Trigger playerEvent for player that is WAITING\n for (PlayerListener listener : playerListeners) {\n PlayerEvent event = new PlayerEvent(this, players.get(player).getColour(), PlayerEvent.WAITING);\n listener.playerStateChanged(event);\n }\n this.setNextActivePlayer();\n }\n //player didn't throw a 6\n //end of turn\n if (this.lastThrow != 6) {\n // PLAYERLISTENER : Trigger playerEvent for player that is WAITING\n for (PlayerListener listener : playerListeners) {\n PlayerEvent event = new PlayerEvent(this, players.get(player).getColour(), PlayerEvent.WAITING);\n listener.playerStateChanged(event);\n }\n this.setNextActivePlayer();\n }\n\n //Resets the tower info when a tower is split\n if (players.get(player).getPieces().get(piece).towerPos != -1) {\n players.get(player)\n .getPieces()\n .get(piece)\n .setTower(-1);\n\n for (Piece piece2 : players.get(player).pieces) {\n if (piece2.position == from) {\n piece2.setTower(-1);\n }\n }\n }\n\n //Sets tower info when a tower is made\n for (Piece piece2 : players.get(player).pieces) {\n if (piece2.position == to) {\n //Both pieces become a tower\n piece2.setTower(piece2.position);\n players.get(player)\n .getPieces()\n .get(piece)\n .setTower(to);\n }\n }\n\n //move piece\n players.get(player)\n .getPieces()\n .get(piece)\n .setPosition(to);\n\n //set piece to in play\n if (to > 0 && to < 59) {\n players.get(player)\n .getPieces()\n .get(piece)\n .setInPlay(true);\n }\n\n checkIfAnotherPlayerLiesThere(player, to);\n\n if (to == 59) {\n\n if (players.get(player).pieceFinished()) {\n this.status = \"Finished\";\n getWinner();\n }\n }\n\n return true;\n } else {\n //doesn't work\n return false;\n }\n\n }", "public int move_diagonally(Square[][] squares, int [] move, Boolean turn) {\n\n /* going down and right = f4 h2 [4,5,6,7] */\n if (move[2] > move[0] && move[3] > move[1]) {\n ////System.out.println(\"Down right\");\n int x = move[0];\n int y = move[1];\n x++;\n y++;\n while (x < move[2] && y < move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x++;\n y++;\n }\n }\n /* going down and left */\n else if (move[2] > move[0] && move[3] < move[1]){\n ////System.out.println(\"Down Left\");\n int x = move[0];\n int y = move[1];\n x++;\n y--;\n while (x < move[2] && y > move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x++;\n y--;\n }\n }\n /* going up and left */\n else if (move[2] < move[0] && move[3] < move[1]){\n ////System.out.println(\"Up Left\");\n int x = move[0];\n int y = move[1];\n x--;\n y--;\n while (x > move[2] && y > move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x--;\n y--;\n }\n }\n /* going up and right c1 f4 [7,2,4,5] */\n else if (move[2] < move[0] && move[3] > move[1]){\n ////System.out.println(\"Up right\");\n int x = move[0];\n int y = move[1];\n x--;\n y++;\n while (x > move[2] && y < move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x--;\n y++;\n }\n }\n return 0;\n }", "public boolean move(ChessBoard n, int a, int b, int c, int d) throws OutOfBoardException, PathwayException {\n if(!n.getPiece(c,d).getSymbol().equals(\"--- \")){\n System.out.println(\"KING: (\" + a + \",\" + b + \") (\" + c + \",\" + d + \")\");\n System.out.println(\"Invalid Move.(\" + a + \",\" + b + \") (\" + c + \",\" + d + \") Another Piece is in the way.\");\n System.out.println(\"=======================================\");\n System.out.println(n);\n throw new PathwayException();\n }\n //CHECKS TO SEE IF IT IS OUT OF BOARD\n if (c >= 8 || d >= 8) {\n tof = false;\n System.out.println(\"King: (\" + a + \",\" + b + \") (\" + c + \",\" + d + \")\");\n System.out.println(\"Invalid Move.(\" + a + \",\" + b + \") (\" + c + \",\" + d + \") Out of Board. \");\n System.out.println(\"=======================================\");\n System.out.println(n);\n throw new OutOfBoardException();\n } else if (c == a + 1 || c == a - 1 && d == b + 1 || d == b - 1) {\n tof = true;\n } else {\n tof = false;\n }\n return tof;\n }", "GameState requestActionGamePiece();", "private void suarez() {\n\t\ttry {\n\t\t\tThread.sleep(5000); // espera, para dar tempo de ver as mensagens iniciais\n\t\t} catch (InterruptedException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tint xInit = -10;\n\t\tint yInit = 8;\n\t\tplayerDeafaultPosition = new Vector2D(xInit*selfPerception.getSide().value(), yInit*selfPerception.getSide().value());\n\t\twhile (commander.isActive()) {\n\t\t\t\n\t\t\tupdatePerceptions(); // deixar aqui, no começo do loop, para ler o resultado do 'move'\n\t\t\tswitch (matchPerception.getState()) {\n\t\t\tcase BEFORE_KICK_OFF:\n\t\t\t\tcommander.doMoveBlocking(xInit, yInit);\t\t\t\t\t\t\t\t\n\t\t\t\tbreak;\n\t\t\tcase PLAY_ON:\n\t\t\t\t//state = State.FOLLOW;\n\t\t\t\texecuteStateMachine();\n\t\t\t\tbreak;\n\t\t\tcase KICK_OFF_LEFT:\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.LEFT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase KICK_OFF_RIGHT:\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.RIGHT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CORNER_KICK_LEFT: // escanteio time esquerdo\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.LEFT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CORNER_KICK_RIGHT: // escanteio time direito\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.RIGHT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase KICK_IN_LEFT: // lateral time esquerdo\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.LEFT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\tcase KICK_IN_RIGHT: // lateal time direito\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.RIGHT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase FREE_KICK_LEFT: // Tiro livre time esquerdo\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.LEFT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase FREE_KICK_RIGHT: // Tiro Livre time direito\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.RIGHT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase FREE_KICK_FAULT_LEFT:\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.LEFT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase FREE_KICK_FAULT_RIGHT:\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.RIGHT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase GOAL_KICK_LEFT:\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.LEFT) {\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase GOAL_KICK_RIGHT:\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.RIGHT) {\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase AFTER_GOAL_LEFT:\n\t\t\t\tcommander.doMoveBlocking(xInit, yInit);\n\t\t\t\tbreak;\n\t\t\tcase AFTER_GOAL_RIGHT:\n\t\t\t\tcommander.doMoveBlocking(xInit, yInit);\n\t\t\t\tbreak;\n\t\t\tcase INDIRECT_FREE_KICK_LEFT:\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.LEFT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase INDIRECT_FREE_KICK_RIGHT:\n\t\t\t\tif (selfPerception.getSide() == EFieldSide.RIGHT) {\n\t\t\t\t\tstate = State.PASSING_BALL;\n\t\t\t\t\texecuteStateMachine();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t}\n\t}", "public boolean move(int x, int y, CheckersBoard board) {\n if (whiteTurn == true && team == Constants.TeamId.team1Id) {\n return false;\n }\n if (whiteTurn == false && team == Constants.TeamId.team2Id) {\n return false;\n }\n /**\n * then change the x - y coords of the piece\n * update the UI to remove the highlighted squares then move the piece\n * if chess and shared square you take a piece\n * if checkers you jumped them you take the piece\n * return new x - y components\n *\n * if this is too high up in the tree you can override this implementation or update it\n * to fit specific pieces if its not working for some reason\n */\n if (possible(x, y, gameBoard)) {\n int changex = this.getX()-x;\n int changey = this.getY()-y;\n CheckersPiece temp = gameBoard.boardPositions[getX()][getY()];\n gameBoard.boardPositions[getX()][getY()] = null;\n gameBoard.boardPositions[x][y] = temp;\n if (gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2] != null) {\n System.out.println(\"Here\");\n if (gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2].team != this.team) {\n gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2].imageView.setVisibility(View.GONE);\n gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2] = null;\n }\n }\n this.setX(x);\n this.setY(y);/*\n if (Math.abs(changex) == 2) {\n gameBoard.boardPositions[x + (changex/2)][y + (changey/2)] = null;\n if (team == Constants.TeamId.team1Id) {\n board.numPieces1--;\n } else if (team == Constants.TeamId.team2Id) {\n board.numPieces0--;\n }\n }*/\n\n gameBoard.boardPositions[x][y].imageView.setX(142*x);\n gameBoard.boardPositions[x][y].imageView.setY(142*y);\n // flips after move is\n whiteTurn = !whiteTurn;\n gameBoard.startTimer();\n }\n //setUpUI(gameBoard);\n if (getY() == 7 && team == Constants.TeamId.team2Id) {\n board.crown(this);\n }\n if (getY() == 0 && team == Constants.TeamId.team1Id) {\n board.crown(this);\n }\n return possible(x, y, gameBoard);\n }", "public void processTurn(Player player) {\n Move move;\n do {\n Scanner scan = new Scanner(System.in);\n\n System.out.println(\"Enter current position of Piece you want to move\");\n // Positions entered by player\n int startX = scan.nextInt();\n int startY = scan.nextInt();\n\n System.out.println(\"Enter position where you want to put Piece\");\n int endX = scan.nextInt();\n int endY = scan.nextInt();\n\n // Move created based on position entered by player 1\n move = new Move(player, board.getCellAtLocation(startX, startY), board.getCellAtLocation(endX, endY));\n } while (!makeMove(move));\n }", "private static void play(Board chess, Scanner scan) {\r\n boolean whiteCanCastle = true;\r\n boolean blackCanCastle = true;\r\n\r\n // Get's user's choice\r\n // Split into the <old x position>, <old y position>, <new x position>, <new y position>\r\n for (int i = 0; i < 100; i++) {\r\n // Gets the user's requested move, moves the pieces (with move verification), and prints the final board\r\n int[] move = Tasks.getMove(chess, scan);\r\n boolean valid = chess.move(move[1], move[0], move[3], move[2], move[4], move[5]);\r\n if (move[4] == 99 && valid) {whiteCanCastle = false;}\r\n else if (move[4] == -99 && valid) {blackCanCastle = false;}\r\n chess.printBoard();\r\n }\r\n // System.out.println(\"50 Move Rule Exceeded!\\nGame Over!\");\r\n }", "private List<Move> generateMoves(boolean debug) {\r\n\r\n\t\tList<Piece> pieces = this.chessGame.getPieces();\r\n\t\tList<Move> validMoves = new ArrayList<Move>();\r\n\t\tMove testMove = new Move(0,0,0,0);\r\n\t\t\r\n\t\tint pieceColor = (this.chessGame.getGameState()==ChessGame.GAME_STATE_WHITE\r\n\t\t\t?Piece.COLOR_WHITE\r\n\t\t\t:Piece.COLOR_BLACK);\r\n\r\n\t\t// iterate over all non-captured pieces\r\n\t\tfor (Piece piece : pieces) {\r\n\r\n\t\t\t// only look at pieces of current players color\r\n\t\t\tif (pieceColor == piece.getColor()) {\r\n\t\t\t\t// start generating move\r\n\t\t\t\ttestMove.sourceRow = piece.getRow();\r\n\t\t\t\ttestMove.sourceColumn = piece.getColumn();\r\n\r\n\t\t\t\t// iterate over all board rows and columns\r\n\t\t\t\tfor (int targetRow = Piece.ROW_1; targetRow <= Piece.ROW_8; targetRow++) {\r\n\t\t\t\t\tfor (int targetColumn = Piece.COLUMN_A; targetColumn <= Piece.COLUMN_H; targetColumn++) {\r\n\r\n\t\t\t\t\t\t// finish generating move\r\n\t\t\t\t\t\ttestMove.targetRow = targetRow;\r\n\t\t\t\t\t\ttestMove.targetColumn = targetColumn;\r\n\r\n\t\t\t\t\t\tif(debug) System.out.println(\"testing move: \"+testMove);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t// check if generated move is valid\r\n\t\t\t\t\t\tif (this.validator.isMoveValid(testMove, true)) {\r\n\t\t\t\t\t\t\t// valid move\r\n\t\t\t\t\t\t\tvalidMoves.add(testMove.clone());\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t// generated move is invalid, so we skip it\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn validMoves;\r\n\t}", "@Test(timeout=2000) public void testMovesToReach(){\r\n GameStateSpace states = new GameStateSpace(this.initial);\r\n // For every target state based on the initial game look at a\r\n // target and calculate the moves to reach it\r\n for(int target=0; target<this.targetGameMoves.size(); target++){\r\n GameAndMoves gm = this.targetGameMoves.get(target);\r\n ZombieTrapGame targetGame = gm.game;\r\n List<String> expectMoves = gm.moves;\r\n List<String> actualMoves = states.movesToReach(targetGame);\r\n StringBuilder sb = new StringBuilder(this.name+\"\\n\");\r\n sb.append(\"TARGET GAME NUMBER \"+target+\"\\n\");\r\n \r\n // Check if the moves are equal to the expectation\r\n if(expectMoves==null && actualMoves==null){\r\n continue;\r\n }\r\n else if(expectMoves !=null && expectMoves.equals(actualMoves)){\r\n continue;\r\n }\r\n else if(expectMoves!=null && actualMoves==null){\r\n sb.append(\"State misidentified as NOT reachable\\n\");\r\n sb.append(String.format(\"Expect sequence: %s\\n\",expectMoves));\r\n sb.append(String.format(\"Actual sequence: %s\\n\",actualMoves));\r\n sb.append(String.format(\"Target Game:\\n%s\",targetGame));\r\n sb.append(this.toString());\r\n appendAllStates(states, sb);\r\n fail(sb.toString());\r\n }\r\n\r\n // ALREADY THERE\r\n // If equal length do they produce the correct board: could be\r\n // alternate paths to the same state\r\n ZombieTrapGame game = this.initial.copy();\r\n for(String move : actualMoves){\r\n doShift(game,move);\r\n }\r\n\r\n // ADD THIS CODE to fix a bug in the original test cases\r\n if(expectMoves==null && actualMoves!=null){\r\n sb.append(\"State misidentified as IS reachable\\n\");\r\n sb.append(String.format(\"Expect sequence: %s\\n\",expectMoves));\r\n sb.append(String.format(\"Actual sequence: %s\\n\",actualMoves));\r\n sb.append(String.format(\"Target Game:\\n%s\",targetGame));\r\n sb.append(String.format(\"Actual End Game:\\n%s\",game));\r\n sb.append(this.toString());\r\n appendAllStates(states, sb);\r\n fail(sb.toString());\r\n }\r\n\r\n // ALREADY THERE\r\n if(!game.equals(targetGame)){ // Moves don't lead to target state\r\n sb.append(\"Actual move sequence does not lead to target state\\n\");\r\n sb.append(String.format(\"Expect sequence (length %s): %s\\n\",expectMoves.size(),expectMoves));\r\n sb.append(String.format(\"Target Game:\\n%s\",targetGame));\r\n sb.append(String.format(\"Actual sequence (length %s): %s\\n\",actualMoves.size(),actualMoves));\r\n sb.append(String.format(\"Actual End Game:\\n%s\",game));\r\n } \r\n // Different path but same length, not an error\r\n else if(actualMoves.size() == expectMoves.size()){\r\n continue;\r\n }\r\n // Check if the moves are longer than the expected\r\n else if(actualMoves.size() > expectMoves.size()){\r\n sb.append(\"Actual move sequence is longer than the expected move sequence\\n\");\r\n sb.append(String.format(\"Expect sequence (length %s): %s\\n\",expectMoves.size(),expectMoves));\r\n sb.append(String.format(\"Actual sequence (length %s): %s\\n\",actualMoves.size(),actualMoves));\r\n sb.append(String.format(\"Target Game:\\n%s\",targetGame));\r\n }\r\n // A shorter path!?\r\n else {\r\n sb.append(\"Actual move sequence is SHORTER than the expected move sequence\\n\");\r\n sb.append(\"YOU HAVE DISCOVERED A BUG IN THE TEST CASES: NOTIFY THE COURSE INSTRUCTOR\\n\");\r\n sb.append(String.format(\"Expect sequence (length %s): %s\\n\",expectMoves.size(),expectMoves));\r\n sb.append(String.format(\"Actual sequence (length %s): %s\\n\",actualMoves.size(),actualMoves));\r\n sb.append(String.format(\"Target Game:\\n%s\",targetGame));\r\n }\r\n sb.append(this.toString());\r\n appendAllStates(states, sb);\r\n fail(sb.toString());\r\n }\r\n }", "private boolean simulate(Piece p) {\n \tArrayList<Square> moves = p.getLegalMoves();\n \tSquare temp;\n \tMove m;\n \tPiece piece;\n \t\n \t//need to copy the board\n \tBoard copy = null;\n \t\n \tfor(int i = 0; i < moves.size(); i++) {\n \t\ttemp = moves.get(i);\n \t\tcopy = new Board();\n \t\tcopyBoard(copy);\n \t\tpiece = copy.getPiece(p.getLocation().getX(), p.getLocation().getY());\n \t\tm = new Move(piece, copy.getPiece(temp.getX(), temp.getY()));\n \t\tif(copy.tryMove(m)) {\n \t\t\tcopy.makeMove(m);\n \t\t\tif(!copy.isCheck(p.getColor())) return true;\n \t\t}\n \t}\n \t\n \treturn false;\n }", "public int possibleMoves(int i, int x, int y, int[][] board) {\n\t\tint canMove = 0;\n\n\t\tif (i == 12) {\n\t\t\tStdDraw.setPenColor(Move);\n\t\t\tif (((y > 0 && y <= 7) && (x > 1 && x <= 7))\n\t\t\t\t\t&& board[x - 2][y - 1] > 3) {\n\t\t\t\tcanMove = canMove\n\t\t\t\t\t\t+ possibleAttacks(x - 2, y - 1, board, StdDraw.BLACK);\n\t\t\t}\n\t\t\tif (((y > 0 && y <= 7) && (x > 1 && x <= 7))\n\t\t\t\t\t&& board[x - 2][y - 1] < 3) {\n\t\t\t\tStdDraw.filledRectangle(x - 1.5, y - .5, .5, .5);\n\t\t\t\tStdDraw.setPenColor();\n\t\t\t\tStdDraw.rectangle(x - 1.5, y - .5, .5, .5);\n\t\t\t\tboard[x - 2][y - 1] = 0;\n\t\t\t\tcanMove++;\n\t\t\t}\n\t\t\tStdDraw.setPenColor(Move);\n\t\t\tif (((y >= 0 && y < 7) && (x > 1 && x <= 7))\n\t\t\t\t\t&& board[x - 2][y + 1] > 3) {\n\t\t\t\tcanMove = canMove\n\t\t\t\t\t\t+ possibleAttacks(x - 2, y + 1, board, StdDraw.BLACK);\n\t\t\t}\n\n\t\t\tif (((y >= 0 && y < 7) && (x > 1 && x <= 7))\n\t\t\t\t\t&& board[x - 2][y + 1] < 3) {\n\t\t\t\tStdDraw.filledRectangle(x - 1.5, y + 1.5, .5, .5);\n\t\t\t\tStdDraw.setPenColor();\n\t\t\t\tStdDraw.rectangle(x - 1.5, y + 1.5, .5, .5);\n\t\t\t\tboard[x - 2][y + 1] = 0;\n\t\t\t\tcanMove++;\n\t\t\t}\n\t\t\tStdDraw.setPenColor(Move);\n\t\t\tif (((y >= 0 && y < 6) && (x > 0 && x <= 7))\n\t\t\t\t\t&& board[x - 1][y + 2] > 3) {\n\t\t\t\tcanMove = canMove\n\t\t\t\t\t\t+ possibleAttacks(x - 1, y + 2, board, StdDraw.BLACK);\n\t\t\t}\n\t\t\tif (((y >= 0 && y < 6) && (x > 0 && x <= 7))\n\t\t\t\t\t&& board[x - 1][y + 2] < 3) {\n\t\t\t\tStdDraw.filledRectangle(x - .5, y + 2.5, .5, .5);\n\t\t\t\tStdDraw.setPenColor();\n\t\t\t\tStdDraw.rectangle(x - .5, y + 2.5, .5, .5);\n\t\t\t\tboard[x - 1][y + 2] = 0;\n\t\t\t\tcanMove++;\n\t\t\t}\n\t\t\tStdDraw.setPenColor(Move);\n\t\t\tif (((y >= 0 && y < 6) && (x >= 0 && x < 7))\n\t\t\t\t\t&& board[x + 1][y + 2] > 3) {\n\t\t\t\tcanMove = canMove\n\t\t\t\t\t\t+ possibleAttacks(x + 1, y + 2, board, StdDraw.BLACK);\n\t\t\t}\n\t\t\tif (((y >= 0 && y < 6) && (x >= 0 && x < 7))\n\t\t\t\t\t&& board[x + 1][y + 2] < 3) {\n\t\t\t\tStdDraw.filledRectangle(x + 1.5, y + 2.5, .5, .5);\n\t\t\t\tStdDraw.setPenColor();\n\t\t\t\tStdDraw.rectangle(x + 1.5, y + 2.5, .5, .5);\n\t\t\t\tboard[x + 1][y + 2] = 0;\n\t\t\t\tcanMove++;\n\t\t\t}\n\t\t\tStdDraw.setPenColor(Move);\n\t\t\tif (((y >= 0 && y < 7) && (x >= 0 && x < 6))\n\t\t\t\t\t&& board[x + 2][y + 1] > 3) {\n\t\t\t\tcanMove = canMove\n\t\t\t\t\t\t+ possibleAttacks(x + 2, y + 1, board, StdDraw.BLACK);\n\t\t\t}\n\t\t\tif (((y >= 0 && y < 7) && (x >= 0 && x < 6))\n\t\t\t\t\t&& board[x + 2][y + 1] < 3) {\n\t\t\t\tStdDraw.filledRectangle(x + 2.5, y + 1.5, .5, .5);\n\t\t\t\tStdDraw.setPenColor();\n\t\t\t\tStdDraw.rectangle(x + 2.5, y + 1.5, .5, .5);\n\t\t\t\tboard[x + 2][y + 1] = 0;\n\t\t\t\tcanMove++;\n\t\t\t}\n\t\t\tStdDraw.setPenColor(Move);\n\t\t\tif (((y > 0 && y <= 7) && (x >= 0 && x < 6))\n\t\t\t\t\t&& board[x + 2][y - 1] > 3) {\n\t\t\t\tcanMove = canMove\n\t\t\t\t\t\t+ possibleAttacks(x + 2, y - 1, board, StdDraw.BLACK);\n\t\t\t}\n\t\t\tif (((y > 0 && y <= 7) && (x >= 0 && x < 6))\n\t\t\t\t\t&& board[x + 2][y - 1] < 3) {\n\t\t\t\tStdDraw.filledRectangle(x + 2.5, y - .5, .5, .5);\n\t\t\t\tStdDraw.setPenColor();\n\t\t\t\tStdDraw.rectangle(x + 2.5, y - .5, .5, .5);\n\t\t\t\tboard[x + 2][y - 1] = 0;\n\t\t\t\tcanMove++;\n\t\t\t}\n\t\t\tStdDraw.setPenColor(Move);\n\t\t\tif (((y > 1 && y <= 7) && (x >= 0 && x < 7))\n\t\t\t\t\t&& board[x + 1][y - 2] > 3) {\n\t\t\t\tcanMove = canMove\n\t\t\t\t\t\t+ possibleAttacks(x + 1, y - 2, board, StdDraw.BLACK);\n\t\t\t}\n\t\t\tif (((y > 1 && y <= 7) && (x >= 0 && x < 7))\n\t\t\t\t\t&& board[x + 1][y - 2] < 3) {\n\t\t\t\tStdDraw.filledRectangle(x + 1.5, y - 1.5, .5, .5);\n\t\t\t\tStdDraw.setPenColor();\n\t\t\t\tStdDraw.rectangle(x + 1.5, y - 1.5, .5, .5);\n\t\t\t\tboard[x + 1][y - 2] = 0;\n\t\t\t\tcanMove++;\n\t\t\t}\n\t\t\tStdDraw.setPenColor(Move);\n\t\t\tif (((y > 1 && y <= 7) && (x > 0 && x <= 7))\n\t\t\t\t\t&& board[x - 1][y - 2] > 3) {\n\t\t\t\tcanMove = canMove\n\t\t\t\t\t\t+ possibleAttacks(x - 1, y - 2, board, StdDraw.BLACK);\n\t\t\t}\n\t\t\tif (((y > 1 && y <= 7) && (x > 0 && x <= 7))\n\t\t\t\t\t&& board[x - 1][y - 2] < 3) {\n\t\t\t\tStdDraw.filledRectangle(x - .5, y - 1.5, .5, .5);\n\t\t\t\tStdDraw.setPenColor();\n\t\t\t\tStdDraw.rectangle(x - .5, y - 1.5, .5, .5);\n\t\t\t\tboard[x - 1][y - 2] = 0;\n\t\t\t\tcanMove++;\n\t\t\t}\n\n\t\t\tStdDraw.show(30);\n\t\t\treturn canMove;\n\t\t}\n\n\t\tif (i == 22) {\n\t\t\tStdDraw.setPenColor(Move);\n\t\t\tif (((y > 0 && y <= 7) && (x > 1 && x <= 7))\n\t\t\t\t\t&& board[x - 2][y - 1] > 3) {\n\t\t\t\tcanMove = canMove\n\t\t\t\t\t\t+ possibleAttacks(x - 2, y - 1, board, StdDraw.WHITE);\n\t\t\t}\n\t\t\tif (((y > 0 && y <= 7) && (x > 1 && x <= 7))\n\t\t\t\t\t&& board[x - 2][y - 1] < 3) {\n\t\t\t\tStdDraw.filledRectangle(x - 1.5, y - .5, .5, .5);\n\t\t\t\tStdDraw.setPenColor();\n\t\t\t\tStdDraw.rectangle(x - 1.5, y - .5, .5, .5);\n\t\t\t\tboard[x - 2][y - 1] = 0;\n\t\t\t\tcanMove++;\n\t\t\t}\n\t\t\tStdDraw.setPenColor(Move);\n\t\t\tif (((y >= 0 && y < 7) && (x > 1 && x <= 7))\n\t\t\t\t\t&& board[x - 2][y + 1] > 3) {\n\t\t\t\tcanMove = canMove\n\t\t\t\t\t\t+ possibleAttacks(x - 2, y + 1, board, StdDraw.WHITE);\n\t\t\t}\n\n\t\t\tif (((y >= 0 && y < 7) && (x > 1 && x <= 7))\n\t\t\t\t\t&& board[x - 2][y + 1] < 3) {\n\t\t\t\tStdDraw.filledRectangle(x - 1.5, y + 1.5, .5, .5);\n\t\t\t\tStdDraw.setPenColor();\n\t\t\t\tStdDraw.rectangle(x - 1.5, y + 1.5, .5, .5);\n\t\t\t\tboard[x - 2][y + 1] = 0;\n\t\t\t\tcanMove++;\n\t\t\t}\n\t\t\tStdDraw.setPenColor(Move);\n\t\t\tif (((y >= 0 && y < 6) && (x > 0 && x <= 7))\n\t\t\t\t\t&& board[x - 1][y + 2] > 3) {\n\t\t\t\tcanMove = canMove\n\t\t\t\t\t\t+ possibleAttacks(x - 1, y + 2, board, StdDraw.WHITE);\n\t\t\t}\n\t\t\tif (((y >= 0 && y < 6) && (x > 0 && x <= 7))\n\t\t\t\t\t&& board[x - 1][y + 2] < 3) {\n\t\t\t\tStdDraw.filledRectangle(x - .5, y + 2.5, .5, .5);\n\t\t\t\tStdDraw.setPenColor();\n\t\t\t\tStdDraw.rectangle(x - .5, y + 2.5, .5, .5);\n\t\t\t\tboard[x - 1][y + 2] = 0;\n\t\t\t\tcanMove++;\n\t\t\t}\n\t\t\tStdDraw.setPenColor(Move);\n\t\t\tif (((y >= 0 && y < 6) && (x >= 0 && x < 7))\n\t\t\t\t\t&& board[x + 1][y + 2] > 3) {\n\t\t\t\tcanMove = canMove\n\t\t\t\t\t\t+ possibleAttacks(x + 1, y + 2, board, StdDraw.WHITE);\n\t\t\t}\n\t\t\tif (((y >= 0 && y < 6) && (x >= 0 && x < 7))\n\t\t\t\t\t&& board[x + 1][y + 2] < 3) {\n\t\t\t\tStdDraw.filledRectangle(x + 1.5, y + 2.5, .5, .5);\n\t\t\t\tStdDraw.setPenColor();\n\t\t\t\tStdDraw.rectangle(x + 1.5, y + 2.5, .5, .5);\n\t\t\t\tboard[x + 1][y + 2] = 0;\n\t\t\t\tcanMove++;\n\t\t\t}\n\t\t\tStdDraw.setPenColor(Move);\n\t\t\tif (((y >= 0 && y < 7) && (x >= 0 && x < 6))\n\t\t\t\t\t&& board[x + 2][y + 1] > 3) {\n\t\t\t\tcanMove = canMove\n\t\t\t\t\t\t+ possibleAttacks(x + 2, y + 1, board, StdDraw.WHITE);\n\t\t\t}\n\t\t\tif (((y >= 0 && y < 7) && (x >= 0 && x < 6))\n\t\t\t\t\t&& board[x + 2][y + 1] < 3) {\n\t\t\t\tStdDraw.filledRectangle(x + 2.5, y + 1.5, .5, .5);\n\t\t\t\tStdDraw.setPenColor();\n\t\t\t\tStdDraw.rectangle(x + 2.5, y + 1.5, .5, .5);\n\t\t\t\tboard[x + 2][y + 1] = 0;\n\t\t\t\tcanMove++;\n\t\t\t}\n\t\t\tStdDraw.setPenColor(Move);\n\t\t\tif (((y > 0 && y <= 7) && (x >= 0 && x < 6))\n\t\t\t\t\t&& board[x + 2][y - 1] > 3) {\n\t\t\t\tcanMove = canMove\n\t\t\t\t\t\t+ possibleAttacks(x + 2, y - 1, board, StdDraw.WHITE);\n\t\t\t}\n\t\t\tif (((y > 0 && y <= 7) && (x >= 0 && x < 6))\n\t\t\t\t\t&& board[x + 2][y - 1] < 3) {\n\t\t\t\tStdDraw.filledRectangle(x + 2.5, y - .5, .5, .5);\n\t\t\t\tStdDraw.setPenColor();\n\t\t\t\tStdDraw.rectangle(x + 2.5, y - .5, .5, .5);\n\t\t\t\tboard[x + 2][y - 1] = 0;\n\t\t\t\tcanMove++;\n\t\t\t}\n\t\t\tStdDraw.setPenColor(Move);\n\t\t\tif (((y > 1 && y <= 7) && (x >= 0 && x < 7))\n\t\t\t\t\t&& board[x + 1][y - 2] > 3) {\n\t\t\t\tcanMove = canMove\n\t\t\t\t\t\t+ possibleAttacks(x + 1, y - 2, board, StdDraw.WHITE);\n\t\t\t}\n\t\t\tif (((y > 1 && y <= 7) && (x >= 0 && x < 7))\n\t\t\t\t\t&& board[x + 1][y - 2] < 3) {\n\t\t\t\tStdDraw.filledRectangle(x + 1.5, y - 1.5, .5, .5);\n\t\t\t\tStdDraw.setPenColor();\n\t\t\t\tStdDraw.rectangle(x + 1.5, y - 1.5, .5, .5);\n\t\t\t\tboard[x + 1][y - 2] = 0;\n\t\t\t\tcanMove++;\n\t\t\t}\n\t\t\tStdDraw.setPenColor(Move);\n\t\t\tif (((y > 1 && y <= 7) && (x > 0 && x <= 7))\n\t\t\t\t\t&& board[x - 1][y - 2] > 3) {\n\t\t\t\tcanMove = canMove\n\t\t\t\t\t\t+ possibleAttacks(x - 1, y - 2, board, StdDraw.WHITE);\n\t\t\t}\n\t\t\tif (((y > 1 && y <= 7) && (x > 0 && x <= 7))\n\t\t\t\t\t&& board[x - 1][y - 2] < 3) {\n\t\t\t\tStdDraw.filledRectangle(x - .5, y - 1.5, .5, .5);\n\t\t\t\tStdDraw.setPenColor();\n\t\t\t\tStdDraw.rectangle(x - .5, y - 1.5, .5, .5);\n\t\t\t\tboard[x - 1][y - 2] = 0;\n\t\t\t\tcanMove++;\n\t\t\t}\n\n\t\t\tStdDraw.show(30);\n\t\t\treturn canMove;\n\t\t} else\n\t\t\treturn canMove;\n\t}", "@Override\n public Position[] getCanMoves() {\n PieceWay way = new PieceWay(getPosition());\n Position[] PawnWay = way.waysPawnPos(color);\n return PawnWay;\n }", "public static HashSet<gameState> Actions(gameState currentState) {\n\t\t\n\t\tHashSet<gameState> possibleStates = new HashSet<gameState>();\n\t\t\n\t\t\n\t\t// Store which player goes next after this player plays\n\t\tint nextNextUp;\n\t\tif (currentState.getNextUp() == 0) {\n\t\t\tnextNextUp = 1;\n\t\t} else {\n\t\t\tnextNextUp = 0;\n\t\t}\n\t\t\n\t\t// Store corresponding characters for each player\n\t\t// DARK(X) - 0, LIGHT(O) - 1\n\t\tchar myTile;\n\t\tchar opponentTile;\n\t\tif (currentState.getNextUp() == 0) {\n\t\t\tmyTile = 'x';\n\t\t\topponentTile = 'o';\n\t\t} else {\n\t\t\tmyTile = 'o';\n\t\t\topponentTile = 'x';\n\t\t}\n\n\t\t\n\n\t\t// Check the entire board of the state \n\t\tfor (int i = 0; i<boardSize; i++) {\n\t\t\tfor (int j = 0; j<boardSize; j++) {\n\t\t\t\t\n\t\t\t\t// If the tile is my tile\n\t\t\t\tif (currentState.getBoard()[i][j] == '_') {\n\t\t\t\t\t\n\t\t\t\t\tchar[][] moveBoard = createNewBoard(currentState);\n\t\t\t\t\t\n\t\t\t\t\t// Up\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// If it is an opponent tile, then you keep going up until you either my tile (fail) or\n\t\t\t\t\t\t// a blank space (success/move possible)\n\t\t\t\t\t\tif (currentState.getBoard()[i-1][j] == opponentTile) { \n\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// Keep going up until the top is hit\n\t\t\t\t\t\t\tfor (int k = i-2; k >= 0; k--) {\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tif (currentState.getBoard()[k][j] == myTile) {\n\t\t\t\t\t\t\t\t\tfor (int l = k+1; l<=i;l++) {\n\t\t\t\t\t\t\t\t\t\tmoveBoard[l][j] = myTile;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t} else if (currentState.getBoard()[k][j] == opponentTile) {\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (Exception e) {}\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t// Down\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (currentState.getBoard()[i+1][j] == opponentTile) { \n\t\t\t\t\t\t\t\n\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// Keep going up until the top is hit\n\t\t\t\t\t\t\tfor (int k = i+2; k < boardSize; k++) {\n\t\t\t\t\t\t\t\tif (currentState.getBoard()[k][j] == myTile) {\n\t\t\t\t\t\t\t\t\tfor (int l = k-1; l>=i;l--) {\n\t\t\t\t\t\t\t\t\t\tmoveBoard[l][j] = myTile;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t} else if (currentState.getBoard()[k][j] == opponentTile) {\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (Exception e) {}\n\t\t\t\t\t\n\t\t\t\t\t// Left\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (currentState.getBoard()[i][j-1] == opponentTile) { \n\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// Keep going up until the top is hit\n\t\t\t\t\t\t\tfor (int k = j-2; k >= 0; k--) {\n\t\t\t\t\t\t\t\tif (currentState.getBoard()[i][k] == myTile) {\n\t\t\t\t\t\t\t\t\tfor (int l = k+1; l<=j;l++) {\n\t\t\t\t\t\t\t\t\t\tmoveBoard[i][l] = myTile;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t} else if (currentState.getBoard()[i][k] == opponentTile) {\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (Exception e) {}\n\t\t\t\t\t\n\t\t\t\t\t// Right\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (currentState.getBoard()[i][j+1] == opponentTile) { \n\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// Keep going up until the top is hit\n\t\t\t\t\t\t\tfor (int k = j+2; k < boardSize; k++) {\n\t\t\t\t\t\t\t\tif (currentState.getBoard()[i][k] == myTile) {\n\t\t\t\t\t\t\t\t\tfor (int l = k-1; l>=j;l--) {\n\t\t\t\t\t\t\t\t\t\tmoveBoard[i][l] = myTile;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t} else if (currentState.getBoard()[i][k] == opponentTile) {\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (Exception e) {}\n\t\t\t\t\t\n\t\t\t\t\t// Up and Left\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (currentState.getBoard()[i-1][j-1] == opponentTile) { \n\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// Keep going up until the top is hit\n\t\t\t\t\t\t\tint l = j-2;\n\t\t\t\t\t\t\tfor (int k = i-2; k >= 0; k--) {\n\t\t\t\t\t\t\t\tif (currentState.getBoard()[k][l] == myTile) {\n\t\t\t\t\t\t\t\t\tint p = l+1;\n\t\t\t\t\t\t\t\t\tfor (int q = k+1; q<=i;q++) {\n\t\t\t\t\t\t\t\t\t\tmoveBoard[q][p] = myTile;\n\t\t\t\t\t\t\t\t\t\tp++;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t} else if (currentState.getBoard()[k][l] == opponentTile) {\n\t\t\t\t\t\t\t\t\tl--;\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (Exception e) {}\n\t\t\t\t\t\n\t\t\t\t\t// Up and Right\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (currentState.getBoard()[i-1][j+1] == opponentTile) { \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// Keep going up until the top is hit\n\t\t\t\t\t\t\tint l = j+2;\n\t\t\t\t\t\t\tfor (int k = i-2; k >= 0; k--) {\n\t\t\t\t\t\t\t\tif (currentState.getBoard()[k][l] == myTile) {\n\t\t\t\t\t\t\t\t\tint p = l-1;\n\t\t\t\t\t\t\t\t\tfor (int q = k+1; q<=i;q++) {\n\t\t\t\t\t\t\t\t\t\tmoveBoard[q][p] = myTile;\n\t\t\t\t\t\t\t\t\t\tp--;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t} else if (currentState.getBoard()[k][l] == opponentTile) {\n\t\t\t\t\t\t\t\t\tl++;\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (Exception e) {}\n\t\t\t\t\t\n\t\t\t\t\t// Down and Left\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (currentState.getBoard()[i+1][j-1] == opponentTile) { \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// Keep going up until the top is hit\n\t\t\t\t\t\t\tint l = j-2;\n\t\t\t\t\t\t\tfor (int k = i+2; k < boardSize; k++) {\n\t\t\t\t\t\t\t\tif (currentState.getBoard()[k][l] == myTile) {\n\t\t\t\t\t\t\t\t\tint p = l+1;\n\t\t\t\t\t\t\t\t\tfor (int q = k-1; q>=i;q--) {\n\t\t\t\t\t\t\t\t\t\tmoveBoard[q][p] = myTile;\n\t\t\t\t\t\t\t\t\t\tp++;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t} else if (currentState.getBoard()[k][l] == opponentTile) {\n\t\t\t\t\t\t\t\t\tl--;\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (Exception e) {}\n\t\t\t\t\t\n\t\t\t\t\t// Down and Right\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (currentState.getBoard()[i+1][j+1] == opponentTile) { \n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// Keep going up until the top is hit\n\t\t\t\t\t\t\tint l = j+2;\n\t\t\t\t\t\t\tfor (int k = i+2; k < boardSize; k++) {\n\t\t\t\t\t\t\t\tif (currentState.getBoard()[k][l] == myTile) {\n\t\t\t\t\t\t\t\t\tint p = l-1;\n\t\t\t\t\t\t\t\t\tfor (int q = k-1; q>=i;q--) {\n\t\t\t\t\t\t\t\t\t\tmoveBoard[q][p] = myTile;\n\t\t\t\t\t\t\t\t\t\tp--;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else if (currentState.getBoard()[k][l] == opponentTile) {\n\t\t\t\t\t\t\t\t\tl++;\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (Exception e) {}\n\t\t\t\t\t\n\t\t\t\t\tif (!compareBoards(moveBoard, currentState.getBoard())) {\n\t\t\t\t\t\tgameState move = new gameState(moveBoard, nextNextUp);\t\t\n\t\t\t\t\t\tpossibleStates.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\n\t\t\t}\n\t\t}\n\t\t\n\n\t\treturn possibleStates;\n\t\t\n\t\t\n\t\t\n\t}", "public int[][] getMovesBishop(Piece p) {\n x = p.getX();\n y = p.getY();\n int legalMoves[][] = new int[8][8];\n\n for (int i = 1; i < 8; i++) {//Traversing from piece coords, right till end of board.\n if ((x + i) < 8 && (y + i) < 8) {\n if (b.getPieceAt((y + i), (x + i)) != null) {\n if (p.isWhite() == b.getPieceAt((y + i), (x + i)).isWhite()) {\n break;\n } else {\n legalMoves[(y + i)][(x + i)] = 1;\n break;\n }\n } else {\n legalMoves[(y + i)][(x + i)] = 1;\n }\n }\n }\n for (int i = 1; i < 8; i++) {\n if ((x - i) > -1 && (y + i) < 8) {\n if (b.getPieceAt((y + i), (x - i)) != null) {\n if (p.isWhite() == b.getPieceAt((y + i), (x - i)).isWhite()) {\n break;\n } else {\n legalMoves[(y + i)][(x - i)] = 1;\n break;\n }\n } else {\n legalMoves[(y + i)][(x - i)] = 1;\n }\n }\n }\n\n for (int i = 1; i < 8; i++) {\n\n if ((x - i) > -1 && (y - i) > -1) {\n if (b.getPieceAt((y - i), (x - i)) != null) {\n if (p.isWhite() == b.getPieceAt((y - i), (x - i)).isWhite()) {\n break;\n } else {\n legalMoves[(y - i)][(x - i)] = 1;\n break;\n }\n } else {\n legalMoves[(y - i)][(x - i)] = 1;\n }\n }\n }\n\n for (int i = 1; i < 8; i++) {\n\n if ((x + i) < 8 && (y - i) > -1) {\n if (b.getPieceAt((y - i), (x + i)) != null) {\n if (p.isWhite() == b.getPieceAt((y - i), (x + i)).isWhite()) {\n break;\n } else {\n legalMoves[(y - i)][(x + i)] = 1;\n break;\n }\n } else {\n legalMoves[(y - i)][(x + i)] = 1;\n }\n }\n }\n return legalMoves;\n }", "public static void compute_possible_moves(Board s){\n\t\tint b [][] = s.board;\n\t\tint x = -1;\n\t\tint y = -1;\n\t\tfor (int i = 0;i < b.length;i++) {\n\t\t\tfor (int j = 0;j < b[i].length;j++) {\n\t\t\t\tif(b[i][j] == 0){\n\t\t\t\t\tx = i;\n\t\t\t\t\ty = j;\n\t\t\t\t\tbreak;\n\t\t\t\t}\t\n\t\t\t}\n\t\t}\n\n\t\tint left [][];\n\t\tint right [][];\n\t\tint up [][];\n\t\tint down [][];\n\t\tpossible_boards.clear();\n\t\tif(x - 1 != -1 && x >= 0 && x < 3){\n\t\t\t//up is a legal move\n\t\t\tint temporary_board [][] = new int[b.length][];\n\t\t\tfor(int q = 0; q < b.length; q++)\n\t\t\t temporary_board [q] = b[q].clone();\n\t\t\t\n\n\t\t\tint temp = temporary_board[x - 1][y];\n\t\t\ttemporary_board[x - 1][y] = temporary_board[x][y];\n\t\t\ttemporary_board[x][y] = temp;\n\t\t\tup = temporary_board;\n\n\t\t\tBoard up_board = new Board(up);\n\t\t\tpossible_boards.add(up_board);\n\n\t\t}\n\t\tif(x + 1 != 3 && x >= 0 && x < 3){\n\t\t\t//down is a legal move\n\t\t\tint temporary_board [][] = new int[b.length][];\n\t\t\tfor(int q = 0; q < b.length; q++)\n\t\t\t temporary_board [q] = b[q].clone();\n\t\t\t\n\t\t\tint temp = temporary_board[x + 1][y];\n\t\t\ttemporary_board[x + 1][y] = temporary_board[x][y];\n\t\t\ttemporary_board[x][y] = temp;\n\t\t\tdown = temporary_board;\n\t\t\tBoard down_board = new Board(down);\n\t\t\tpossible_boards.add(down_board);\n\t\t}\n\t\tif(y - 1 != -1 && y >= 0 && y < 3){\n\t\t\t//left move is legal\n\t\t\tint temporary_board [][] = new int[b.length][];\n\t\t\tfor(int q = 0; q < b.length; q++)\n\t\t\t temporary_board [q] = b[q].clone();\n\t\t\t\n\t\t\tint temp = temporary_board[x][y - 1];\n\t\t\ttemporary_board[x][y - 1] = temporary_board[x][y];\n\t\t\ttemporary_board[x][y] = temp;\n\t\t\tleft = temporary_board;\n\t\t\tBoard left_board = new Board(left);\n\t\t\tpossible_boards.add(left_board);\n\n\t\t}\n\t\tif(y + 1 != 3 && y >= 0 && y < 3){\n\t\t\t//right move is legal\n\t\t\tint temporary_board [][] = new int[b.length][];\n\t\t\tfor(int q = 0; q < b.length; q++)\n\t\t\t temporary_board [q] = b[q].clone();\n\t\t\t\n\t\t\tint temp = temporary_board[x][y + 1];\n\t\t\ttemporary_board[x][y + 1] = temporary_board[x][y];\n\t\t\ttemporary_board[x][y] = temp;\n\t\t\tright = temporary_board;\n\t\t\tBoard right_board = new Board(right);\n\t\t\tpossible_boards.add(right_board);\n\n\t\t}\n\n\t}", "protected Set<ChessMove> getPossibleCastlingMoves(ChessModel model, Location location, Set<ChessMove> movesSoFar) {\n\t\tCastlingAvailability castlingAvailability = model.getCastlingAvailability();\n\t\tif ((location == E1) && (getColor() == White)) {\n\t\t\t// this is the white king in the starting position\n\t\t\tif (castlingAvailability.isWhiteCanCastleKingSide()) {\n\t\t\t\tif (model.isLocationEmpty(F1) && model.isLocationEmpty(G1)) {\n\t\t\t\t\tif (!isInCheckAtLocations(model, E1, F1, G1)) {\n\t\t\t\t\t\tChessMove move = new ChessMoveCastleKingSide(getPiece(), E1, G1);\n\t\t\t\t\t\tmovesSoFar.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (castlingAvailability.isWhiteCanCastleQueenSide()) {\n\t\t\t\tif (model.isLocationEmpty(B1) && model.isLocationEmpty(C1) && model.isLocationEmpty(D1)) {\n\t\t\t\t\tif (!isInCheckAtLocations(model, B1, C1, D1, E1)) {\n\t\t\t\t\t\tChessMove move = new ChessMoveCastleQueenSide(getPiece(), E1, C1);\n\t\t\t\t\t\tmovesSoFar.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ((location == E8) && (getColor() == Black)) {\n\t\t\t// this is the black king in the starting position\n\t\t\tif (castlingAvailability.isBlackCanCastleKingSide()) {\n\t\t\t\tif (model.isLocationEmpty(F8) && model.isLocationEmpty(G8)) {\n\t\t\t\t\tif (!isInCheckAtLocations(model, E8, F8, G8)) {\n\t\t\t\t\t\tChessMove move = new ChessMoveCastleKingSide(getPiece(), E8, G8);\n\t\t\t\t\t\tmovesSoFar.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t\tif (castlingAvailability.isBlackCanCastleQueenSide()) {\n\t\t\t\tif (model.isLocationEmpty(B8) && model.isLocationEmpty(C8) && model.isLocationEmpty(D8)) {\n\t\t\t\t\tif (!isInCheckAtLocations(model, B8, C8, D8, E8)) {\n\t\t\t\t\t\tChessMove move = new ChessMoveCastleQueenSide(getPiece(), E8, C8);\n\t\t\t\t\t\tmovesSoFar.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\t\t\t\t\n\t\t\t}\t\t\t\n\t\t}\n\t\treturn movesSoFar;\n\t}", "void doMove() {\n\t\t// we saved the moves in a queue to avoid recursing.\n\t\tint[] move;\n\t\twhile(!moveQueue.isEmpty()) {\n\t\t\tmove = moveQueue.remove(); \n\t\t\tif (board[move[0]][move[1]] == 0) {\n\t\t\t\tinsertNumber(move[0], move[1], move[2]);\n\t\t\t}\n\t\t}\n\t\tgoOverLines();\n\t}", "@Override\n void movePhase() throws IOException, InterruptedException, IOExceptionFromController {\n boolean godPower = false;\n ArrayList<Cell> possibleMoves = findPossibleMoves(activeWorker.getPosition());\n Cell movePosition = client.chooseMovePosition(possibleMoves);\n CellView startView = new CellView(activeWorker.getPosition());\n CellView endView = new CellView(movePosition);\n CellView startView2 = null;\n CellView endView2 = null;\n // + allow pushing away opponents\n if (movePosition.hasWorker()) {\n godPower = true;\n Worker pushedWorker = movePosition.getWorker();\n Cell nextCell;\n int nextX = movePosition.getPosX() + (movePosition.getPosX() - activeWorker.getPosition().getPosX());\n int nextY = movePosition.getPosY() + (movePosition.getPosY() - activeWorker.getPosition().getPosY());\n nextCell = board.getCell(nextX, nextY);\n startView2 = endView;\n endView2 = new CellView(nextCell);\n try {\n pushedWorker.move(nextCell);\n } catch (IllegalMoveException e) {\n gameController.logError(e.getMessage());\n return;\n }\n //\n }\n try {\n activeWorker.move(movePosition);\n } catch (IllegalMoveException e) {\n gameController.logError(e.getMessage());\n }\n if (godPower) displayMove(startView, endView, startView2, endView2, card);\n else displayMove(startView, endView, null);\n }", "public static Move openingStrategy(PentagoBoardState boardState, int player) {\n\t Move firstMoveOne = new PentagoMove(1, 0, Quadrant.BL, Quadrant.BR, player);\r\n\t Move firstMoveTwo = new PentagoMove(1, 3, Quadrant.BL, Quadrant.BR, player);\r\n\t Move moveThree = new PentagoMove(0, 1, Quadrant.BL, Quadrant.TR, player);\r\n\t Move moveFour = new PentagoMove(0, 4, Quadrant.TL, Quadrant.BR, player);\r\n\t Move moveFive = new PentagoMove(3, 1, Quadrant.BL, Quadrant.TL, player);\r\n\t Move moveSix = new PentagoMove(3, 4, Quadrant.TL, Quadrant.TR, player);\r\n\t Move moveSeven = new PentagoMove(2, 2, Quadrant.TL, Quadrant.TR, player);\r\n\t Move moveEight = new PentagoMove(2, 5, Quadrant.TL, Quadrant.BR, player);\r\n\t Move moveNine = new PentagoMove(5, 2, Quadrant.BL, Quadrant.TL, player);\r\n\t Move moveTen = new PentagoMove(5, 5, Quadrant.TL, Quadrant.TR, player);\r\n\t \r\n\t //First turn as either Black or White\r\n\t if(boardState.getTurnNumber() == 0 || boardState.getTurnNumber() == 1) {\r\n\t if(boardState.isLegal((PentagoMove) firstMoveOne)) {\r\n\t \treturn firstMoveOne;\r\n\t }\r\n\t else if(boardState.isLegal((PentagoMove) firstMoveTwo)) {\r\n\t \treturn firstMoveTwo;\r\n\t }\r\n\t else {\r\n\t \t/* If something goes awry, play the first legal move (will place pieces in TL quadrant usually).\r\n\t \t * Same error condition for the following moves as well.\r\n\t \t **/\r\n\t \tArrayList<PentagoMove> legalMoves = boardState.getAllLegalMoves();\r\n\t \treturn legalMoves.get(0);\r\n\t }\r\n\t }\r\n\t else if(boardState.getTurnNumber() == 2 || boardState.getTurnNumber() == 3) {\r\n\t \t//White player turn 2 & 3 set up\r\n\t \tif(player == 0) {\r\n\t\t \tif(boardState.isLegal((PentagoMove) moveThree) && boardState.getPieceAt(1, 0).toString().equals(\"w\")) {\r\n\t\t \treturn moveThree;\r\n\t\t }\r\n\t\t \tif(boardState.isLegal((PentagoMove) moveFour) && boardState.getPieceAt(1, 3).toString().equals(\"w\")) {\r\n\t\t \t\treturn moveFour;\r\n\t\t \t}\r\n\t\t \tif(boardState.isLegal((PentagoMove) moveFive) && boardState.getPieceAt(4, 0).toString().equals(\"w\")) {\r\n\t\t \treturn moveFive;\r\n\t\t }\r\n\t\t \tif(boardState.isLegal((PentagoMove) moveSix) && boardState.getPieceAt(4, 3).toString().equals(\"w\")) {\r\n\t\t \t\treturn moveSix;\r\n\t\t \t}\r\n\t\t \tif(boardState.getPieceAt(0, 1).toString().equals(\"b\") && boardState.getPieceAt(1, 0).toString().equals(\"w\")\t\r\n\t\t \t\t\t&& boardState.isLegal((PentagoMove) moveSeven)) {\r\n\t\t \treturn moveSeven;\r\n\t\t }\r\n\t\t \tif(boardState.getPieceAt(0, 4).toString().equals(\"b\") && boardState.getPieceAt(1, 3).toString().equals(\"w\")\r\n\t\t \t\t\t&& boardState.isLegal((PentagoMove) moveEight)) {\r\n\t\t \t\treturn moveEight;\r\n\t\t \t}\r\n\t\t \tif(boardState.getPieceAt(3, 1).toString().equals(\"b\") && boardState.getPieceAt(4, 0).toString().equals(\"w\")\r\n\t\t \t\t\t&& boardState.isLegal((PentagoMove) moveNine)) {\r\n\t\t \treturn moveNine;\r\n\t\t }\r\n\t\t \tif(boardState.getPieceAt(3, 4).toString().equals(\"b\") && boardState.getPieceAt(4, 3).toString().equals(\"w\")\r\n\t\t \t\t\t&& boardState.isLegal((PentagoMove) moveTen)) {\r\n\t\t \t\treturn moveTen;\r\n\t\t \t}\r\n\t\t else {\r\n\t\t \tArrayList<PentagoMove> legalMoves = boardState.getAllLegalMoves();\r\n\t\t \treturn legalMoves.get(0);\r\n\t\t }\r\n\t \t} \r\n\t \t//Black player turn 2 & 3 set up\r\n\t \telse {\r\n\t \t\tif(boardState.isLegal((PentagoMove) moveThree) && boardState.getPieceAt(1, 0).toString().equals(\"b\")) {\r\n\t\t \treturn moveThree;\r\n\t\t }\r\n\t \t\tif(boardState.isLegal((PentagoMove) moveFour) && boardState.getPieceAt(1, 3).toString().equals(\"b\")) {\r\n\t\t \treturn moveFour;\r\n\t\t }\r\n\t \t\tif(boardState.isLegal((PentagoMove) moveFive) && boardState.getPieceAt(4, 0).toString().equals(\"b\")) {\r\n\t\t \treturn moveFive;\r\n\t\t }\r\n\t \t\tif(boardState.isLegal((PentagoMove) moveSix) && boardState.getPieceAt(4, 3).toString().equals(\"b\")) {\r\n\t\t \treturn moveSix;\r\n\t\t }\r\n\t \t\tif(boardState.getPieceAt(0, 1).toString().equals(\"w\") && boardState.getPieceAt(1, 0).toString().equals(\"b\")\r\n\t \t\t\t\t&& boardState.isLegal((PentagoMove) moveSeven)) {\r\n\t\t \treturn moveSeven;\r\n\t\t }\r\n\t\t \tif(boardState.getPieceAt(0, 4).toString().equals(\"w\") && boardState.getPieceAt(1, 3).toString().equals(\"b\")\r\n\t\t \t\t\t&& boardState.isLegal((PentagoMove) moveEight)) {\r\n\t\t \t\treturn moveEight;\r\n\t\t \t}\r\n\t\t \tif(boardState.getPieceAt(3, 1).toString().equals(\"w\") && boardState.getPieceAt(4, 0).toString().equals(\"b\")\r\n\t\t \t\t\t&& boardState.isLegal((PentagoMove) moveNine)) {\r\n\t\t \treturn moveNine;\r\n\t\t }\r\n\t\t \tif(boardState.getPieceAt(3, 4).toString().equals(\"w\") && boardState.getPieceAt(4, 3).toString().equals(\"b\")\r\n\t\t \t\t\t&& boardState.isLegal((PentagoMove) moveTen)) {\r\n\t\t \t\treturn moveTen;\r\n\t\t \t}\r\n\t\t else {\r\n\t\t \tArrayList<PentagoMove> legalMoves = boardState.getAllLegalMoves();\r\n\t\t \treturn legalMoves.get(0);\r\n\t\t }\r\n\t \t}\t \r\n\t }\r\n\t else {\r\n\t \t//If we are past Player's Turn 3, start using MiniMax with a-b pruning\r\n\t \tMiniMaxABPruning instc = new MiniMaxABPruning();\r\n\t \treturn instc.abPruningStrategy(boardState, boardState.getTurnPlayer());\r\n\t }\r\n\t}", "private boolean isLegalMove(String move) {\n\t\tString[] moveParts = move.split(\";\");\n\n\t\tint fromRow = Integer.parseInt(moveParts[0].charAt(0) + \"\");\n\t\tint fromCol = Integer.parseInt(moveParts[0].charAt(1) + \"\");\n\n\t\tint toRow = Integer.parseInt(moveParts[1].charAt(0) + \"\");\n\t\tint toCol = Integer.parseInt(moveParts[1].charAt(1) + \"\");\n\n\t\tint minRow = Math.min(fromRow, toRow);\n\t\tint minCol = Math.min(fromCol, toCol);\n\n\t\tint maxRow = Math.max(fromRow, toRow);\n\t\tint maxCol = Math.max(fromCol, toCol);\n\n\t\tint piece = board[fromRow][fromCol];//Integer.parseInt(moveParts[2]);\n\t\tint pieceType = Math.abs(piece);\n\t\tint team = Math.round(Math.signum(piece));\n\n\t\tif (team == Math.round(Math.signum(board[toRow][toCol]))) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif (toRow < 0 || toRow > 7 && toCol < 0 && toCol > 7) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (team > 0) { // WHITE\n\t\t\tint enpassantBackup = enpassantCol;\n\t\t\tint[][] boardBackup = deepCopyBoard();\n\t\t\tapplyConvertedMove(move);\n\t\t\tboolean check = isWhiteCheck();\n\t\t\tboard = boardBackup;\n\t\t\tenpassantCol = enpassantBackup;\n\t\t\tif (check) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else { //BLACK\n\t\t\tint enpassantBackup = enpassantCol;\n\t\t\tint[][] boardBackup = deepCopyBoard();\n\t\t\tapplyConvertedMove(move);\n\t\t\tboolean check = isBlackCheck();\n\t\t\tboard = boardBackup;\n\t\t\tenpassantCol = enpassantBackup;\n\t\t\tif (check) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tif (pieceType == 1) { //Pawn\n\t\t\treturn ((board[toRow][toCol] != 0 && toRow == fromRow + team && (toCol == fromCol + 1 || toCol == fromCol - 1)) || (toCol == fromCol && board[toRow][toCol] == 0 && ((toRow == fromRow + team) || (((fromRow == 1 && team == 1) || (fromRow == 6 && team == -1)) ? toRow == fromRow + 2*team && board[fromRow + team][fromCol] == 0 : false))));\n\t\t} else if (pieceType == 2) { //Rook\n\t\t\tif (toRow == fromRow) {\n\t\t\t\tfor (int i = minCol + 1; i < maxCol; i++) {\n\t\t\t\t\tif (board[toRow][i] != 0 && Math.abs(board[toRow][i]) != 7) return false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} else if (toCol == fromCol) {\n\t\t\t\tfor (int i = minRow + 1; i < maxRow; i++) {\n\t\t\t\t\tif (board[i][toCol] != 0 && Math.abs(board[i][toCol]) != 7) return false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else if (pieceType == 3) { //Knight\n\t\t\tint dx = toRow - fromRow;\n\t\t\tint dy = toCol - fromCol;\n\t\t\treturn dx*dx + dy*dy == 5;\n\t\t} else if (pieceType == 4) { //Bishop\n\t\t\tint dx = toRow - fromRow;\n\t\t\tint dy = toCol - fromCol;\n\t\t\tif (dy != dx && dy != -dx) return false;\n\t\t\tint m = dy/dx;\n\t\t\tint startCol = (m < 0 ? maxCol : minCol);\n\t\t\tfor (int i = minRow + 1; i < maxRow; i++) {\n\t\t\t\tif (board[i][startCol + m*(i - minRow)] != 0 && board[i][startCol + m*(i - minRow)] != 7) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t} else if (pieceType == 5) { //Queen\n\t\t\tif (toRow == fromRow) {\n\t\t\t\tfor (int i = minCol + 1; i < maxCol; i++) {\n\t\t\t\t\tif (board[toRow][i] != 0 && Math.abs(board[toRow][i]) != 7) return false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} else if (toCol == fromCol) {\n\t\t\t\tfor (int i = minRow + 1; i < maxRow; i++) {\n\t\t\t\t\tif (board[i][toCol] != 0 && Math.abs(board[i][toCol]) != 7) return false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\tint dx = toRow - fromRow;\n\t\t\t\tint dy = toCol - fromCol;\n\t\t\t\tif (dy != dx && dy != -dx) return false;\n\t\t\t\tint m = dy/dx;\n\t\t\t\tint startCol = (m < 0 ? maxCol : minCol);\n\t\t\t\tfor (int i = minRow + 1; i < maxRow; i++) {\n\t\t\t\t\tif (board[i][startCol + m*(i - minRow)] != 0 && Math.abs(board[i][startCol + m*(i - minRow)]) != 7) return false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if (pieceType == 6) { //King\n\t\t\tint dx = toRow - fromRow;\n\t\t\tint dy = toCol - fromCol;\n\t\t\treturn dx*dx + dy*dy <= 2;\n\t\t}\n\n\t\treturn false;\n\t}", "@Override\n\tpublic GridCell execute() {\n\t\t//1. if there is a winning position, take it\n\t\tArrayList<GridCell> winningCell = TicTacToeBoardExaminer.getWinningPositions(board, side);\n\t\tif (winningCell.size() > 0) {\n\t\t\tGridCell move = winningCell.get(0);\n\t\t\treturn move;\n\t\t}\n\t\t\n\t\t//2. if there is a losing position, block it\n\t\tArrayList<GridCell> losingCell = TicTacToeBoardExaminer.getLosingPositions(board, side);\n\t\tif (losingCell.size() > 0) {\n\t\t\tGridCell move = losingCell.get(0);\n\t\t\treturn move;\n\t\t}\n\t\t\n\t\t//TODO: Implement checking of forks. This will get you to 100% win or tie rate\n\t\t\n\t\t//3. Otherwise get the optimal position\n\t\tGridCell optimal = TicTacToeBoardExaminer.getOptimal(board, side);\n\t\tif (optimal != null)\n\t\t\treturn optimal;\n\t\t\n\t\t//4. Otherwise just move randomly\n\t\telse \n\t\t\treturn new RandomStrategy(board, side).execute();\n\t\t\n\t}", "boolean isLegal(String move) {\n int[][] theStatusBoard;\n if (_playerOnMove == ORANGE) {\n theStatusBoard = _orangeStatusBoard;\n } else {\n theStatusBoard = _violetStatusBoard;\n }\n Pieces thispiece = new Pieces();\n String piecename = move.substring(0, 1);\n int col = getCoordinate(move.substring(1, 2));\n int row = getCoordinate(move.substring(2, 3));\n int ori = Integer.parseInt(move.substring(3, 4));\n int[][] initialPositions = thispiece.getInitialPositions(piecename);\n int[][] finalPositions = thispiece.processPositions(initialPositions, ori);\n int depth = finalPositions.length;\n int length = finalPositions[0].length;\n\n if (row + depth - 1 > 13 || col + length - 1 > 13) {\n System.out.println(\"Your move makes your piece out of the board, try again!\");\n return false;\n }\n\n boolean has1 = false;\n boolean no2 = true;\n\n int i, j;\n for (i = 0; i < depth; i++) {\n for (j = 0; j < length; j++) {\n if (finalPositions[i][j] == 1) {\n if (theStatusBoard[15 - (row + depth - i)][col + j + 1] == 1) {\n has1 = true;\n } else if (theStatusBoard[15 - (row + depth - i)][col + j + 1] == 2) {\n return false;\n }\n }\n }\n }\n System.out.println(\"has1: \" + has1);\n return has1;\n }", "public void printGameInfo(Game game, MOVE pacManMove) {\n\n \t// find state features\n \tMOVE toPill=MOVE.NEUTRAL, toGhost=MOVE.NEUTRAL;\n int current = game.getPacmanCurrentNodeIndex();\n\t\tint[] pills=game.getActivePillsIndices();\n\t\tint[] powerPills=game.getActivePowerPillsIndices();\n\t\t\n\t\tint closestPill = Integer.MAX_VALUE;\n\t\tint i = 0;\n\t\tfor(i=0;i<pills.length;i++){\t\t\t\t//find the nearest pill\n\t\t\tint tempDistance = game.getManhattanDistance(current, pills[i]);\n\t\t\tif(tempDistance < closestPill){\n\t\t\t\tclosestPill = tempDistance;\n\t\t\t\ttoPill = game.getNextMoveTowardsTarget(current, pills[i], DM.PATH);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(;i<pills.length + powerPills.length;i++){\t\t\t\t//find the nearest power pill\n\t\t\tint tempDistance = game.getManhattanDistance(current, powerPills[i - pills.length]);\n\t\t\tif(tempDistance < closestPill){\n\t\t\t\tclosestPill = tempDistance;\n\t\t\t\ttoPill = game.getNextMoveTowardsTarget(current, powerPills[i - pills.length], DM.PATH);\n\t\t\t}\n\t\t}\n\t\t\n\t\tGHOST[] ghosts = GHOST.values();\n\t\t\n\t\tint closestGhost = Integer.MAX_VALUE;\n\t\tboolean islair = false;\n\t\t\n\t\tfor(GHOST ghost : ghosts){\t\t\t\t\t\t//find the nearest ghost and whether it is edible\n\t\t\tint tempDistance = game.getShortestPathDistance(current, game.getGhostCurrentNodeIndex(ghost));\n\t\t\tif(tempDistance < closestGhost){\n\t\t\t\tclosestGhost = tempDistance;\n\t\t\t\tislair = game.getGhostEdibleTime(ghost)>0;\n\t\t\t\ttoGhost = game.getNextMoveTowardsTarget(current, game.getGhostCurrentNodeIndex(ghost), DM.PATH);\n\t\t\t}\n\t\t}\n\n // directory to store training data\n String path = \"/home/liaoyu/workspace/Pacman2/data/data1.txt\";\n File file = new File(path);\n\n try {\n PrintWriter pw = new PrintWriter(new FileWriter(file, true));\n\n \t\tpw.print(closestPill + \" \"); // get the distance from nearest pill or power pill\n \t\t\n \t\tpw.print(closestGhost + \" \"); // get the distance from closest ghost\n \t\tpw.print(islair ? 1 : 0 + \" \"); // get whether this ghost is edible\n \t\t\n \t\tpw.print(pacManMove == toPill ? 1 : 0 + \" \"); // get whether pac man move towards pills\n \t\tpw.println(pacManMove == toGhost ? 0 : 1); // get whether pac man move away from ghosts\n \t\t\n// pw.print(game.getScore() + \" \"); // get current score\n// pw.print(game.getTotalTime() + \" \"); // get time\n// pw.print(game.getEuclideanDistance(currPacLocation, ghostLocation) + \" \"); // get distance\n// pw.print(game.getPacmanCurrentNodeIndex() + \" \"); // get current index\n// pw.println(pacManMove); // move\n\n pw.close();\n\n } catch (IOException e) {\n e.printStackTrace();\n }\n }", "public abstract boolean validMove(ChessBoard board, Square from, Square to);", "private void checkMove(Tile[][] chessBoard, int pawnX, int pawnY, int direction) {\r\n\t\tUnit unit = chessBoard[pawnX][pawnY+direction].getPiece();\r\n\t\tif (unit == null) {\r\n\t\t\tMoves move = new Moves(pawnX, pawnY+direction);\r\n\t\t\tinsertMove(move, moveList);\r\n\t\t}\r\n\t}", "public List<ScoredMove> allAttackMoves(GameState gm) {\n\t\tList<ScoredMove> attackMoves = new ArrayList<ScoredMove>();\n\t\t\n\t\t// check for attacking battles\n\t\tif (gm.getBattleList().size() > 0) {\n\t\t\tfor (Battle b: gm.getBattleList()) {\n\t\t\t\tif (!b.isBattleUsingTrumps()) {\n\t\t\t\t\tfor (Card c: getHand().getCards()){\n\t\t\t\t\t\tif (c instanceof PirateShip) {\n\t\t\t\t\t\t\tif (canPirateShipCardAttack(b, (PirateShip)c)){\n\t\t\t\t\t\t\t\tattackMoves.add(new ScoredMove(ACTION.PLAY_ATTACK, c, b));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (Card c: getHand().getCards()) {\n\t\t\t\t\tif (c instanceof Trump) {\n\t\t\t\t\t\tif (canTrumpCardAttack(b, (Trump)c)) {\n\t\t\t\t\t\t\tattackMoves.add(new ScoredMove(ACTION.PLAY_ATTACK, c, b));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn attackMoves;\n\t}", "public List<Move> getValidMoves(Board board, boolean checkKing) {\n List<Move> moves = new ArrayList<Move>();\n\n // if no board given, return empty list\n if (board == null)\n return moves;\n\n // checks moves where the pawn advances a rank\n advance(board, moves);\n // checks moves where the pawn captures another piece\n capture(board, moves);\n // checks en passant moves\n enPassant(board, moves);\n\n // check that move doesn't put own king in check\n if (checkKing)\n for(int i = 0; i < moves.size(); i++)\n if (board.movePutsKingInCheck(moves.get(i), this.color)) {\n // if move would put king it check, it is invalid and\n // is removed from the list\n moves.remove(moves.get(i));\n // iterator is decremented due to the size of the list\n // decreasing.\n i--;\n }\n return moves;\n }", "public ArrayList<Pair<Coord,Coord>> returnMoves(Board b) {\r\n\t\t//copy Piece grid\r\n\t\tPiece[][] g = b.getGrid();\r\n\t\t\r\n\t\t//return array of all the possible moves\r\n\t\tArrayList<Pair<Coord,Coord>> possibleMoves = new ArrayList<Pair<Coord,Coord>>();\r\n\r\n\t\t//System.out.println(team + \": (\" + c.y + \", \" + c.x + \")\");\r\n\t\t//if the team is moving north (white team)\r\n\t\tif(team) {\r\n\t\t\t//first move, two square pawn advance\r\n\t\t\tif(moves==0 && g[c.y-1][c.x] == null && g[c.y-2][c.x] == null)\r\n\t\t\t\tpossibleMoves.add(new Pair<Coord, Coord>(new Coord(c.y-2,c.x),null));\r\n\t\t\t\r\n\t\t\t//single square pawn advance\r\n\t\t\tif(g[c.y-1][c.x] == null)\r\n\t\t\t\tpossibleMoves.add(new Pair<Coord, Coord>(new Coord(c.y-1,c.x),null));\r\n\t\t\t\r\n\t\t\t//capture diagonally west\r\n\t\t\tif(c.x-1>=0 && c.x-1<=7 && g[c.y-1][c.x-1]!=null && (!g[c.y-1][c.x-1].team))\r\n\t\t\t\tpossibleMoves.add(new Pair<Coord, Coord>(new Coord(c.y-1,c.x-1),null));\r\n\t\t\t\r\n\t\t\t//capture diagonally east\r\n\t\t\tif(c.x+1>=0 && c.x+1<=7 && g[c.y-1][c.x+1]!=null && (!g[c.y-1][c.x+1].team))\r\n\t\t\t\tpossibleMoves.add(new Pair<Coord, Coord>(new Coord(c.y-1,c.x+1),null));\r\n\t\t\t\r\n\t\t\t//en passant west\r\n\t\t\tif(c.x-1>=0 && c.y==3 && g[c.y-1][c.x-1]==null && g[c.y][c.x-1]!=null && !g[c.y][c.x-1].team \r\n\t\t\t\t\t&& g[c.y][c.x-1].toString().equals(\"P\") && g[c.y][c.x-1].moves==1)\r\n\t\t\t\tpossibleMoves.add(new Pair<Coord, Coord>(new Coord(c.y-1,c.x-1),new Coord(c.y, c.x-1)));\r\n\t\t\t\r\n\t\t\t//en passant east\r\n\t\t\tif(c.x+1<=7 && c.y==3 && g[c.y-1][c.x+1]==null && g[c.y][c.x+1]!=null && !g[c.y][c.x+1].team\r\n\t\t\t\t\t&& g[c.y][c.x+1].toString().equals(\"P\") && g[c.y][c.x+1].moves==1)\r\n\t\t\t\tpossibleMoves.add(new Pair<Coord, Coord>(new Coord(c.y-1,c.x+1),new Coord(c.y, c.x+1)));\r\n\t\t\t\r\n\t\t//if the team is moving south (black team)\r\n\t\t} else {\r\n\t\t\t//first move, two square pawn advance\r\n\t\t\tif(moves==0 && g[c.y+1][c.x] == null && g[c.y+2][c.x] == null)\r\n\t\t\t\tpossibleMoves.add(new Pair<Coord, Coord>(new Coord(c.y+2,c.x),null));\r\n\r\n\t\t\t//single square pawn advance\r\n\t\t\tif(g[c.y+1][c.x] == null)\r\n\t\t\t\tpossibleMoves.add(new Pair<Coord, Coord>(new Coord(c.y+1,c.x),null));\r\n\t\t\t\r\n\t\t\t//capture diagonally west\r\n\t\t\tif(c.x-1>=0 && c.x-1<=7 && g[c.y+1][c.x-1]!=null && (g[c.y+1][c.x-1].team))\r\n\t\t\t\tpossibleMoves.add(new Pair<Coord, Coord>(new Coord(c.y+1,c.x-1),null));\r\n\t\t\t\r\n\t\t\t//capture diagonally east\r\n\t\t\tif(c.x+1>=0 && c.x+1<=7 && g[c.y+1][c.x+1]!=null && (g[c.y+1][c.x+1].team))\r\n\t\t\t\tpossibleMoves.add(new Pair<Coord, Coord>(new Coord(c.y+1,c.x+1),null));\r\n\t\t\t\r\n\t\t\t//en passant west\r\n\t\t\tif(c.x-1>=0 && c.y==4 && g[c.y+1][c.x-1]==null && g[c.y][c.x-1]!=null && g[c.y][c.x-1].team \r\n\t\t\t\t\t&& g[c.y][c.x-1].toString().equals(\"P\") && g[c.y][c.x-1].moves==1)\r\n\t\t\t\tpossibleMoves.add(new Pair<Coord, Coord>(new Coord(c.y+1,c.x-1),new Coord(c.y, c.x-1)));\r\n\t\t\t\r\n\t\t\t//en passant east\r\n\t\t\tif(c.x+1<=7 && c.y==4 && g[c.y-1][c.x+1]==null && g[c.y][c.x+1]!=null && g[c.y][c.x+1].team \r\n\t\t\t\t\t&& g[c.y][c.x+1].toString().equals(\"P\") && g[c.y][c.x+1].moves==1)\r\n\t\t\t\tpossibleMoves.add(new Pair<Coord, Coord>(new Coord(c.y+1,c.x+1),new Coord(c.y, c.x+1)));\r\n\t\t\t\r\n\t\t}\t\t\r\n\r\n\t\treturn possibleMoves;\r\n\t}", "@Override\n ArrayList<Cell> findPossibleMoves(Cell workerPosition) {\n ArrayList<Cell> neighbors = board.getNeighbors(workerPosition);\n ArrayList<Cell> possibleMoves = new ArrayList<Cell>();\n for (Cell cell : neighbors) {\n // + allow movement to cells occupied by opponents, if they can be pushed away\n Cell nextCell;\n int nextX = cell.getPosX() + (cell.getPosX() - workerPosition.getPosX());\n int nextY = cell.getPosY() + (cell.getPosY() - workerPosition.getPosY());\n try {\n nextCell = board.getCell(nextX, nextY);\n } catch (ArrayIndexOutOfBoundsException e) {\n nextCell = null;\n }\n if ((!cell.hasWorker() || (nextCell != null && !nextCell.hasWorker() && !nextCell.isDomed())) &&\n !cell.isDomed() && (cell.getBuildLevel() <= workerPosition.getBuildLevel() + 1))\n possibleMoves.add(cell);\n //\n }\n return findLegalMoves(workerPosition, possibleMoves);\n }", "public int[][] getMovesRook(Piece p) {\n x = p.getX();\n y = p.getY();\n int legalMoves[][] = new int[8][8];\n\n for (int i = x + 1; i < 8; i++) {//Traversing from piece coords, right till end of board.\n if (b.getPieceAt(y, i) != null) {\n if (p.isWhite() == b.getPieceAt(y, i).isWhite()) {\n break;\n } else {\n legalMoves[y][i] = 1;\n break;\n }\n } else {\n legalMoves[y][i] = 1;\n }\n }\n for (int i = x - 1; i > -1; i--) {//Traversing from piece coords, left till end of board.\n if (b.getPieceAt((y), i) != null) {\n if (p.isWhite() == b.getPieceAt((y), i).isWhite()) {\n break;\n } else {\n legalMoves[(y)][i] = 1;\n break;\n }\n } else {\n legalMoves[y][i] = 1;\n }\n }\n for (int i = y - 1; i > -1; i--) { //Traversing from piece coords, downwards till end of board.\n if (b.getPieceAt((i), x) != null) {\n if (p.isWhite() == b.getPieceAt(i, x).isWhite()) {\n break;\n } else {\n legalMoves[i][x] = 1;\n break;\n }\n } else {\n legalMoves[i][x] = 1;\n }\n }\n for (int i = y + 1; i < 8; i++) { //Traversing from piece coords, upwards till end of board.\n if (b.getPieceAt((i), x) != null) {\n if (p.isWhite() == b.getPieceAt(i, x).isWhite()) {\n break;\n } else {\n legalMoves[i][x] = 1;\n break;\n }\n } else {\n legalMoves[i][x] = 1;\n }\n }\n return legalMoves;\n }", "public void run() {\n System.out.println(\"Starting game!\");\n this.clients[0].startgame();\n this.clients[1].startgame();\n\n this.clients[0].setError(this::error);\n this.clients[1].setError(this::error);\n\n for (int moveNum = 0; !this.board.gameOver(); moveNum = (moveNum + 1) % 2) {\n ChessConnection player = this.clients[moveNum];\n\n player.make_move();\n\n String[] move;\n try {\n move = player.parseCommand();\n }\n catch (NullPointerException e) {\n System.err.println(\"Could not read response from client\");\n error();\n break;\n }\n\n if (!move[0].equals(ChessConnection.MOVE)) {\n if (move[0].equals(ChessConnection.CHOSE)) {\n Piece p = Piece.createPiece(this.board, ChessColor.valueOf(move[2]), move[1], parseInt(move[3]), parseInt(move[4]));\n this.board.chosePiece(p);\n this.clients[0].chose(p);\n this.clients[1].chose(p);\n moveNum++;\n continue;\n }\n\n if (error)\n break;\n\n System.err.printf(\"Invalid Command from client: %s\\n\", move[0]);\n error();\n break;\n }\n\n int startRow = Integer.parseInt(move[1]);\n int startCol = Integer.parseInt(move[2]);\n int row = Integer.parseInt(move[3]);\n int col = Integer.parseInt(move[4]);\n\n try {\n Piece p = this.board.pieceAt(startRow, startCol);\n this.board.movePiece(p, row, col);\n }\n catch (PawnInterrupt e) {\n this.board.choosePiece(e.getPawn());\n this.clients[(moveNum + 1) % 2].choose(e.getPawn().getRow(), e.getPawn().getCol());\n }\n catch (ChessException e) {\n e.printStackTrace();\n error();\n break;\n }\n\n /* No error */\n this.clients[0].move_made(startRow, startCol, row, col);\n this.clients[1].move_made(startRow, startCol, row, col);\n }\n\n if (!error) {\n /* Tell the client if they won or not */\n if (this.board.getWinner() == ChessColor.BLACK) {\n this.clients[0].game_won();\n this.clients[1].game_lost();\n } else if (this.board.getWinner() == ChessColor.WHITE) {\n this.clients[1].game_won();\n this.clients[0].game_lost();\n } else {\n this.clients[0].game_tied();\n this.clients[1].game_tied();\n }\n }\n\n /* parseCommand on each thread should exit because socket closed */\n this.clients[0].close();\n this.clients[1].close();\n }", "public void run(){\n\n while(Server.running){\n curTime = System.currentTimeMillis();\n\n if(turnGoing){\n \n if(curTime - lastTime >= ONE_MINUTE){\n lastTime = curTime;\n game.doTurn();\n\n sendTo(allUsers, \"<te>\");\n System.out.println(\"turn ended\");\n\n //scps\n sendTo(allUsers, \"\" + SCP0492.level);\n sendTo(allUsers, \"\" + game.getScps().size());\n Iterator<SCP0492> scpIterator = game.getScps().iterator(); \n while(scpIterator.hasNext()){\n SCP0492 curScp = scpIterator.next();\n sendTo(allUsers, curScp.getHealth() + \" \" + curScp.getMaxHealth() + \" \" + curScp.getX() + \" \" + curScp.getY() + \" \" + curScp.getAttackDamage());\n \n }\n\n //events\n sendTo(allUsers, \"\" + game.getEventsWithoutStonks().size());\n Iterator<Event> eIterator = game.getEventsWithoutStonks().iterator();\n while(eIterator.hasNext()){\n Event curEvent = eIterator.next();\n if(curEvent instanceof WholeGameEvent){\n sendTo(allUsers, curEvent.getClass().getSimpleName() + \" \" + curEvent.getLevel() + \" \" + curEvent.getTimeLeft());\n }else{\n sendTo(allUsers, curEvent.getClass().getSimpleName() + \" \" + curEvent.getLevel() + \" \" + curEvent.getTimeLeft() + \" \" + (int)(((AoeEvent)curEvent).getAoe().getX()) + \" \" + (int)(((AoeEvent)curEvent).getAoe().getY()));\n }\n }\n\n //buildings\n sendTo(allUsers, \"\" + game.getBuildings().size());\n Iterator<Building> bIterator = game.getBuildings().iterator();\n while(bIterator.hasNext()){\n Building curBuilding = bIterator.next();\n String send = curBuilding.getClass().getSimpleName() + \" \" + curBuilding.getInitialPrice() + \" \" + curBuilding.getMaxHealth() + \" \" + curBuilding.getHealth() + \" \" + curBuilding.getX() + \" \" + curBuilding.getY();\n if(curBuilding instanceof Residency){\n send = send + \" \" + ((Residency)curBuilding).getMaxCap();\n }else if(curBuilding instanceof Hospital){\n send = send + \" \" + ((Hospital)curBuilding).getMaxCapacity();\n }\n sendTo(allUsers, send); \n }\n\n //humans\n sendTo(allUsers, \"\" + game.getHumanMap().size());\n Iterator<Integer> humanKeyIterator = game.getHumanMap().keySet().iterator();\n while(humanKeyIterator.hasNext()){\n int key = humanKeyIterator.next();\n Human curHuman = game.getHumanMap().get(key);\n town.sendMessage(\"\" + key);\n String humanInfo = curHuman.getClass().getSimpleName() + \" \" + curHuman.getAge() + \" \" + curHuman.getHealth() + \" \" + curHuman.getX() + \" \" + curHuman.getY();\n if(curHuman instanceof Doctor){\n humanInfo += \" \" + ((Doctor)curHuman).getHealingAmount();\n }else if(curHuman instanceof Soldier){\n humanInfo = curHuman.getClass().getSimpleName() + \" \" + curHuman.getAge() + \" \" + curHuman.getHealth() + \" \" + curHuman.getMaxHealth() + \" \" + curHuman.getX() + \" \" + curHuman.getY() + \" \" + ((Soldier)curHuman).getAttackDamage();\n }else if(curHuman instanceof Spy){\n humanInfo += \" \" + ((Spy)curHuman).getSuccessRate() + \" \" + ((Spy)curHuman).getSus();\n }\n sendTo(allUsers, humanInfo);\n }\n\n //town supplies\n town.sendMessage(\"\" + game.getMoney());\n town.sendMessage(\"\" + game.getFood());\n //scp supplies\n scp.sendMessage(\"\" + game.getHume());\n \n //intel gathering\n if(game.gotIntel()){\n town.sendMessage(\"<i>\");\n town.sendMessage(\"\" + game.getHume());\n }\n\n //check for if either side has won\n if(game.checkScpWin()){\n sendTo(allUsers, \"<ge>\");\n scp.sendMessage(\"win\");\n town.sendMessage(\"lose\");\n Server.running = false;\n \n }else if(game.checkTownWin()){\n sendTo(allUsers, \"<ge>\");\n town.sendMessage(\"win\");\n scp.sendMessage(\"lose\");\n Server.running = false;\n }\n\n //In case of game ending because max turns reached\n if(game.getTurn() > Game.MAX_TURNS){\n sendTo(allUsers, \"<ge>\");\n sendTo(allUsers, \"tie\");\n Server.running = false;\n }\n\n turnGoing = !turnGoing;\n }\n }else{\n if(curTime - lastTime >= ONE_MINUTE/2){\n lastTime = curTime;\n game.resetTurnChanges();\n lastTime = curTime;\n sendTo(allUsers, \"<ts>\");\n System.out.println(\"turn started\");\n turnGoing = !turnGoing;\n }\n }\n }\n }", "private int getBestMove(int[] board, int depth, boolean turn) {\n int boardCopy[];\n if (depth <= 0) {\n return 0;\n }\n if (depth > STEP_BACK_DEPTH) {\n try {\n Thread.sleep(3);\n } catch (InterruptedException e) {\n e.printStackTrace();\n if (shouldStop()) {\n Log.d(Constants.MY_TAG,\"out CalculatingBot\");\n unlock();\n return 0;\n }\n }\n }\n if (turn) {\n int minimum = MAXIMUM_POSSIPLE_SCORE_DIFFERENCE;\n for (int i = 0; i < 5; i++) {\n if (board[i] < 2) {\n continue;\n }\n boardCopy = board.clone();\n int x = playMove(boardCopy, i);\n int y = 0;\n if (!hasPlayer2Move(boardCopy)) {\n if (hasPlayer1Move(boardCopy)) {\n y = getBestMove(boardCopy, depth - 1, turn);\n } else {\n for (int j = 0; j < 5; j++) {\n y = y - boardCopy[j];\n }\n for (int j = 5; j < 10; j++) {\n y = y + boardCopy[j];\n }\n }\n } else {\n y = getBestMove(boardCopy, depth - 1, ! turn);\n }\n int z = y - x;\n if (z < minimum) {\n minimum = z;\n }\n }\n int i = 10;\n if (board[2] < 2) {\n return minimum;\n }\n boardCopy = board.clone();\n int x = playMove(boardCopy, i);\n int y = 0;\n if (!hasPlayer2Move(boardCopy)) {\n if (hasPlayer1Move(boardCopy)) {\n y = getBestMove(boardCopy, depth - 1, turn);\n } else {\n for (int j = 0; j < 5; j++) {\n y = y - boardCopy[j];\n }\n for (int j = 5; j < 10; j++) {\n y = y + boardCopy[j];\n }\n }\n } else {\n y = getBestMove(boardCopy, depth - 1, !turn);\n }\n int z = y - x;\n if (z < minimum) {\n minimum = z;\n }\n return minimum;\n } else {\n int maximum = MINIMUM_POSSIPLE_SCORE_DIFFERENCE;\n for (int i = 5; i < 10; i++) {\n if (board[i] < 2) {\n continue;\n }\n boardCopy = board.clone();\n int x = playMove(boardCopy, i);\n int y = 0;\n if (!hasPlayer1Move(boardCopy)) {\n if (hasPlayer2Move(boardCopy)) {\n y = getBestMove(boardCopy, depth - 1, turn);\n } else {\n for (int j = 0; j < 5; j++) {\n y = y - boardCopy[j];\n }\n for (int j = 5; j < 10; j++) {\n y = y + boardCopy[j];\n }\n }\n } else {\n y = getBestMove(boardCopy, depth - 1, !turn);\n }\n int z = y + x;\n if (z > maximum) {\n maximum = z;\n }\n }\n int i = 11;\n if (board[7] < 2) {\n return maximum;\n }\n boardCopy = board.clone();\n int x = playMove(boardCopy, i);\n int y = 0;\n if (!hasPlayer1Move(boardCopy)) {\n if (hasPlayer2Move(boardCopy)) {\n y = getBestMove(boardCopy, depth - 1, turn);\n } else {\n for (int j = 0; j < 5; j++) {\n y = y - boardCopy[j];\n }\n for (int j = 5; j < 10; j++) {\n y = y + boardCopy[j];\n }\n }\n } else {\n y = getBestMove(boardCopy, depth - 1, !turn);\n }\n int z = y + x;\n if (z > maximum) {\n maximum = z;\n }\n return maximum;\n }\n }", "public abstract void generateNextMove(final ChessGameConsole console);", "public void performMove() {\n\t\tfor (int x = 0; x <= size-1; x++)\n\t\t\tfor (int y = 0; y <= size-1; y++)\n\t\t\t\tlocalBoard[y][x] = 0;\n\t\t\n\t\t//reset the flag that indicates if a move has been found that decreases the heuristic\n\t\tfoundBetterMove = false;\n\t\t\n\t\t//fill in the appropriate heuristic values\n\t\tpopulateHillValues();\n\t\tArrayList<PotentialMove> myBestList = new ArrayList<PotentialMove>();\n\n\t\t//Find the square with the lowest heuristic value. this should really write the values to an array. \n\t\tint squareDifferential = -1;\n\t\t//String outValue = \"\";\n\t\tfor (int y = 0; y <= size-1; y++) {\n\t\t\tfor (int x = 0; x <= size-1; x++){\n\t\t\t\t//outValue = outValue + localBoard[y][x];\n\t\t\t\tif (squareDifferential < 0) //lowestSquareFound not found yet \n\t\t\t\t{\n\t\t\t\t\tif ((NQueens.queens[x] != y) && //set if the current square isn't already occupied by a queen\n\t\t\t\t\t\t\t(localBoard[NQueens.queens[x]][x] >= localBoard[y][x])) {\n\t\t\t\t\t\tif (localBoard[y][x] == localBoard[NQueens.queens[x]][x])\n\t\t\t\t\t\t\tmyBestList.add(new PotentialMove(x, y, true));\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tmyBestList.add(new PotentialMove(x, y, false));\n\t\t\t\t\t\tsquareDifferential = localBoard[NQueens.queens[x]][x] - localBoard[y][x];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if ((localBoard[NQueens.queens[x]][x] - localBoard[y][x]) > squareDifferential) { // find the square with the largest differential in value from the queen in the column\n\t\t\t\t\tmyBestList.clear();\n\t\t\t\t\tmyBestList.add(new PotentialMove(x, y, false));\n\t\t\t\t\tsquareDifferential = localBoard[NQueens.queens[x]][x] - localBoard[y][x];\n\t\t\t\t}\n\t\t\t\telse if (((localBoard[NQueens.queens[x]][x] - localBoard[y][x]) == squareDifferential) && // the differential is equal to the current best differential\n\t\t\t\t\t\t(NQueens.queens[x] != y)) { // and isn't already occupied by a queen\n\t\t\t\t\tmyBestList.add(new PotentialMove(x, y, true));\n\t\t\t\t}\n\t\t\t\t//else the square is higher, has a queen or isn't marginally better than the current queen's position in the row\n\t\t\t}\n\t\t\t//outValue = outValue + \"\\n\";\n\t\t}\n\t\t//JOptionPane.showMessageDialog(null, outValue);\n\t\t\n\t\tif (myBestList.isEmpty())\n\t\t\treturn;\n\t\t\n\t\tint listSize = myBestList.size();\n\t\tPotentialMove bestMove;\n\t\t\n\t\t//grab the non-Sideways moves first\n\t\tfor (int i = 0; i < listSize; i++) {\n\t\t\tif (!(myBestList.get(i).isSideways)) {\n\t\t\t\tbestMove = myBestList.get(i);\n\t\t\t\tfoundBetterMove = true;\n\t\t\t\tsidewaysMoves = 0;\n\t\t\t\tNQueens.queens[bestMove.xCoordinate] = bestMove.yCoordinate;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (sidewaysMoves > MAXSIDEWAYSMOVES) { // hit MAXSIDEWAYSMOVES consecutive sideways moves, mark as unsolvable\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t//all available moves sideways moves, let's select one randomly\n\t\tRandom generator = new Random();\n\t\tint randomElement = generator.nextInt(listSize);\n\t\t\n\t\tbestMove = myBestList.get(randomElement);\n\t\tfoundBetterMove = true;\n\t\tsidewaysMoves++;\n\t\tNQueens.queens[bestMove.xCoordinate] = bestMove.yCoordinate;\n\t}", "public static boolean validMove(String move, Person p, Board building )\n {\n Room[][] map = building.getMap();\n move = move.toLowerCase().trim();\n switch (move) {\n case \"n\":\n if (p.getxLoc() > 0)\n {\n map[p.getxLoc()][p.getyLoc()].leaveRoom(p);\n System.out.println(\"You are in the \"+map[p.getxLoc()-1][p.getyLoc()].getName());\n map[p.getxLoc()-1][p.getyLoc()].enterRoom(p,building);\n return true;\n }\n else\n {\n return false;\n }\n case \"e\":\n if (p.getyLoc()< map[p.getyLoc()].length -1)\n {\n map[p.getxLoc()][p.getyLoc()].leaveRoom(p);\n System.out.println(\"You are in the \"+map[p.getxLoc()][p.getyLoc() + 1].getName());\n map[p.getxLoc()][p.getyLoc() + 1].enterRoom(p, building);\n return true;\n }\n else\n {\n return false;\n }\n\n case \"s\":\n if (p.getxLoc() < map.length - 1)\n {\n map[p.getxLoc()][p.getyLoc()].leaveRoom(p);\n System.out.println(\"You are in the \"+map[p.getxLoc()+1][p.getyLoc()].getName());\n map[p.getxLoc()+1][p.getyLoc()].enterRoom(p, building);\n return true;\n }\n else\n {\n return false;\n }\n\n case \"w\":\n if (p.getyLoc() > 0)\n {\n map[p.getxLoc()][p.getyLoc()].leaveRoom(p);\n System.out.println(\"You are in the \"+map[p.getxLoc()][p.getyLoc()-1].getName());\n map[p.getxLoc()][p.getyLoc()-1].enterRoom(p, building);\n return true;\n }\n else\n {\n return false;\n }\n default:\n break;\n\n }\n return true;\n }", "private void move() {\n resetUpdate();\n\n gameMessage.setSpace1(clientMessage.getSpace1());\n gameMessage.resetGameMessage();\n gameMessage.notify(gameMessage);\n\n\n if( liteGame.isWinner() ) endOfTheGame = true;\n }", "@Override\n\tpublic String getMove(String opponentsMove, int boardDimension, \n\t\t\tString board, char color, List<String> prevBoards) {\n\t\t\n\t\tboolean opponentCanDoAMove = canOpponentDoAMove(boardDimension, board, color, prevBoards);\n\t\tboolean opponentPassed = opponentsMove.equals(Character.toString(ProtocolMessages.PASS));\n\t\tchar winner = boardState.highestScore(board);\n\t\tif ((!opponentCanDoAMove || opponentPassed) && winner == color) {\n\t\t\treturn Character.toString(ProtocolMessages.PASS);\n\t\t}\n\t\t\n\t\tboolean noMovesLeft = false;\n\t\tList<String> possibleLocations = new ArrayList<String>();\n\t\t//fill up left five columns, then move on\n\t\tint xmin = 0;\n\t\tint xmax = 4;\n\t\twhile (!noMovesLeft) {\n\t\t\tfor (int x = xmin; x <= xmax; x++) {\n\t\t\t\tfor (int y = 0; y <= boardDimension - 1; y++) {\n\t\t\t\t\tint location = x + y * boardDimension;\n\t\t\t\t\tif (isValidMove(board, boardDimension, color, prevBoards, location)) {\n\t\t\t\t\t\tif (!neighborsAllOwnColor(board, boardDimension, color, location)) {\n\t\t\t\t\t\t\tpossibleLocations.add(Integer.toString(location));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (possibleLocations.size() != 0) {\n\t\t\t\tint randomInt = (int) (Math.random() * possibleLocations.size());\n\t\t\t\treturn possibleLocations.get(randomInt);\n\t\t\t} \n\t\t\txmin = xmin + 5;\n\t\t\txmax = xmax + 5;\n\t\t\tif (xmin > boardDimension - 1) {\n\t\t\t\tnoMovesLeft = true;\n\t\t\t} else if (xmax > boardDimension - 1) {\n\t\t\t\txmax = boardDimension - 1;\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn Character.toString(ProtocolMessages.PASS);\n\t}", "public void executeMove(Game game) {\n int bestScore = 0;\n int comScore = 0;\n Board board = game.getBoard();\n int col = (board.getCols());\n int row = (board.getRows());\n \n // Basic for loop to go through and grab each gem and call the score policy on it\n // it stores the best opton in best score\n for(int i = 0; i < row; i++){\n for(int ii = 0; ii < col; ii++){\n if(board.gemAt(i,ii).isEmpty() == true){\n continue;\n }\n comScore = game.getPolicy().scoreMove(i,ii,board);\n if(comScore >= bestScore){\n bestScore = comScore;\n }\n }\n }\n \n // This for loop makes a Coord with the rows and col i and ii to keep track of where the best gem was located \n for(int i = 0; i < row; i++){\n for(int ii = 0; ii < col; ii++){\n if(board.gemAt(i,ii).isEmpty() == true){\n continue;\n }\n if(game.getPolicy().scoreMove(i,ii,board) == bestScore){\n holder.add(new Coord(i,ii));\n }\n }\n }\n \n // For loop to choose the best Gem out of the holders Coords to call \"removeGemAdjustScore()\"\n for(int i = 0; i < holder.size(); i++){\n if(holder.size() == 1){\n game.removeGemAdjustScore(holder.get(i).row,holder.get(i).col);\n break;\n }\n game.removeGemAdjustScore(holder.get(i).row,holder.get(i).col);\n break;\n }\n \n // Resets the holder and best score for the next move\n holder = new ArrayList<Coord>();\n bestScore = 0;\n \n }", "private static void addPawnPushes(BitBoard board, LinkedList<Move> moveList, int side) {\n\t\t// If side is 0, then the piece is white\n\t\tint pieceType = (side == 0) ? CoreConstants.WHITE_PAWN : CoreConstants.BLACK_PAWN;\n\t\t// Offsets used to add correct moves for white and black\n\t\tint[] offsets = { 8, 56 };\n\t\t// Masks allow promotion moves to be separated\n\t\tlong[] promotions_mask = { CoreConstants.ROW_8, CoreConstants.ROW_1 };\n\t\t// If a white can move to row 3, then it might be able to double push\n\t\tlong[] startWithMask = { CoreConstants.ROW_3, CoreConstants.ROW_6 };\n\t\tint offset = offsets[side];\n\t\tlong pawns = board.getBitBoards()[side + CoreConstants.WHITE_PAWN];\n\t\t// Empty squares i.e. the squares where there is neither a white piece\n\t\t// nor a black piece\n\t\t// Hence NOT (white OR black)\n\t\tlong emptySquares = ~(board.getBitBoards()[CoreConstants.WHITE]\n\t\t\t\t| board.getBitBoards()[CoreConstants.BLACK]);\n\t\t// Circular left shift is equivalent to moving each pawn forward one\n\t\t// square\n\t\t// If it is empty then the push is valid\n\t\tlong pushes = (side == 0 ? (pawns << 8) : (pawns >>> 8)) & emptySquares;\n\t\taddMovesWithOffset(pieceType, pushes & ~promotions_mask[side], moveList, false, false,\n\t\t\t\tCoreConstants.noCastle, offset);\n\t\t// Isolate which moves are promotions\n\t\tlong promotions = pushes & promotions_mask[side];\n\t\taddMovesWithOffset(pieceType, promotions, moveList, false, true, CoreConstants.noCastle,\n\t\t\t\toffset);\n\t\t// If the push led to row 3 if white or row 8 if black and the square\n\t\t// ahead is empty then double push is possible\n\t\tpushes &= startWithMask[side];\n\t\tlong doublePushes = (side == 0 ? (pushes << 8) : (pushes >>> 8)) & emptySquares;\n\t\taddMovesWithOffset(pieceType, doublePushes, moveList, false, false, CoreConstants.noCastle,\n\t\t\t\toffset + offset);\n\t}", "@Override\n public IMove doMove(IGameState state) {\n\n //Find macroboard to play in\n for (int[] move : preferredMoves)\n {\n if(state.getField().getMacroboard()[move[0]][move[1]].equals(IField.AVAILABLE_FIELD))\n {\n \n Random rnd = new Random();\n //find move to play\n for (int[] selectedMove : preferredMoves)\n {\n \n int x = move[0]*3 + selectedMove[0];\n int y = move[1]*3 + selectedMove[1];\n if(!state.getField().getBoard()[x][y].contains(IField.EMPTY_FIELD)\n && !state.getField().getBoard()[x][y].contains(IField.AVAILABLE_FIELD))\n {\n try\n {\n x = x + (rnd.nextInt(selectedMove[0] % 2 + 1));\n \n \n } catch (Exception e)\n {\n \n }\n try\n {\n y = y - (rnd.nextInt(selectedMove[0] % 2 - 1));\n \n } catch (Exception e)\n {\n \n }\n try\n {\n x = x - (rnd.nextInt(selectedMove[0] % 2 -1));\n \n \n } catch (Exception e)\n {\n \n }\n \n \n \n \n }\n if(state.getField().getBoard()[x][y].equals(IField.EMPTY_FIELD))\n {\n \n return new Move(x,y);\n }\n }\n }\n }\n\n //NOTE: Something failed, just take the first available move I guess!\n return state.getField().getAvailableMoves().get(0);\n }", "@Override\n protected Move makeDecision() {\n myTurn = index();\n /* block the nearest + most effective player (as in, people who arent blocked) */\n ArrayList<Move> pathMoves = new ArrayList<>();\n ArrayList<Move> playMoves = new ArrayList<>();\n ArrayList<Move> discardMoves = new ArrayList<>();\n Map<Integer, Card> destroyCards = new HashMap<Integer, Card>();\n Map<Integer, Card> repairCards = new HashMap<Integer, Card>();\n Map<Integer, Card> blockCards = new HashMap<Integer, Card>();\n Map<Integer, Card> pathCards = new HashMap<Integer, Card>();\n Set<Position> reachable = game().board().getReachable();\n canSee=false;\n canMove=false;\n canBlock=false;\n canRockfall=false;\n canRepair=false;\n int len = hand().size();\n for (int i = 0; i < len; ++i) {\n Card c = hand().get(i);\n if (c instanceof PathCard && !isSabotaged()) {\n pathCards.put(i,c);\n// pathMoves.addAll(generatePossiblePaths(i, (PathCard) c));\n canMove = true;\n }\n if (c instanceof PlayerActionCard) {\n// playMoves.addAll(generatePossiblePlayerActions(i, (PlayerActionCard) c));\n if(c.type()== Card.Type.BLOCK) {\n blockCards.put(i, c);\n canBlock=true;\n }\n else if(c.type()== Card.Type.REPAIR) {\n repairCards.put(i, c);\n canRepair=true;\n }\n }\n if (c.type() == Card.Type.MAP) {\n// playMoves.addAll(generatePossibleMap(i));\n mapIndex = i;\n canSee = true;\n }\n if (c.type() == Card.Type.ROCKFALL) {\n destroyCards.put(i,c);\n// playMoves.addAll(generatePossibleRockfall(i));\n canRockfall = true;\n }\n discardMoves.add(Move.NewDiscardMove(index(), i));\n }\n\n if(canSee) {\n //sum of all heuristics\n double sumGoal[] = new double[3];\n for (Position h : reachable) {\n sumGoal[0]+=(9-(8-h.x)+ 5-(4-h.y));\n sumGoal[1]+=(9-(8-h.x)+ 5-(2-h.y));\n sumGoal[2]+=(9-(8-h.x)+ 5-(-h.y));\n }\n //update goldProb\n for(int i=0; i<3; i++) {\n int seenSum=0;\n for(int j=0; j<numPlayers; j++) {\n if(j!=myTurn) {\n if(haveSeen.get(j)[i]==1) seenSum++;\n }\n }\n goldProb[i] = (i==1?0.5:1)*(1-haveSeen.get(myTurn)[i])*(mapRate*(seenSum/numPlayers)+(sumGoal[i]/10));\n }\n }\n\n// System.out.println(hand());\n// System.out.println(pathMoves);\n\n\n if (role() == Role.GOLD_MINER) {\n //Path\n if(canSee && !goldFound) {\n int selection=0;\n double maxProb=goldProb[0];\n for(int i=0; i<3; i++) {\n if(goldProb[i]>maxProb) {\n maxProb = goldProb[i];\n selection=i;\n }\n }\n Move look = Move.NewMapMove(index(), mapIndex, Board.GoalPosition.TOP);\n switch(selection) {\n case 0:\n look = Move.NewMapMove(index(), mapIndex, Board.GoalPosition.TOP);\n break;\n case 1:\n look = Move.NewMapMove(index(), mapIndex, Board.GoalPosition.MIDDLE);\n break;\n case 2:\n look = Move.NewMapMove(index(), mapIndex, Board.GoalPosition.BOTTOM);\n break;\n }\n return look;\n }\n if(canMove) {\n int globalIndex = 0;\n double maxH = 0;\n double oldH;\n Position bp = new Position(0,0);\n boolean rotate = false;\n //Find best path to place;\n Board board = game().board().copy();\n oldH = getClosest(board);\n// System.out.print(getClosest(board)+\" : \");\n for( Map.Entry<Integer, Card> p : pathCards.entrySet()) {\n int index = p.getKey();\n Card path = p.getValue();\n ((PathCard)path).setRotated(false);\n Set<Position> placeable = game().board().getPlaceable((PathCard)path);\n for (Position h : placeable) {\n Board simulated = board.simulatePlaceCardAt((PathCard)path, h.x, h.y);\n// System.out.println(path.type());\n double cH = getClosest(simulated);\n if(maxH<cH) {\n bp=h;\n globalIndex = index;\n maxH = cH;\n rotate=false;\n }\n }\n ((PathCard) path).setRotated(true);\n placeable = game().board().getPlaceable((PathCard)path);\n for (Position h : placeable) {\n Board simulated = board.simulatePlaceCardAt((PathCard)path, h.x, h.y);\n// System.out.println(simulated);\n double cH = getClosest(simulated);\n if(maxH<cH) {\n bp=h;\n globalIndex = index;\n rotate=true;\n maxH = cH;\n }\n }\n }\n// System.out.println(oldH+\": \"+maxH+\" (\"+abs(maxH-oldH)+\")\");\n oldBoard = game().board().copy();\n if(maxH>0 && abs(maxH-oldH)>0.01)\n return Move.NewPathMove(index(), globalIndex, bp.x, bp.y, rotate);\n }\n //Unblock\n if(canRepair) {\n double blockMore = 0.0;\n int targetPlayer = -1;\n int cardIndex = 0;\n for(int i=0; i<numPlayers; i++) {\n //heal self\n if(i == myTurn) {\n for(Map.Entry<Integer, Card> r : repairCards.entrySet()) {\n int index = r.getKey();\n// System.out.println(Arrays.toString(game().playerAt(index()).sabotaged()));\n PlayerActionCard repair = (PlayerActionCard) r.getValue();\n if (game().playerAt(index()).isRepairable(repair.effects())) {\n return Move.NewPlayerActionMove(index(),index, index());\n }\n }\n }\n else if(i!=myTurn) {\n for(Map.Entry<Integer, Card> r : repairCards.entrySet()) {\n int index = r.getKey();\n PlayerActionCard repair = (PlayerActionCard) r.getValue();\n// System.out.println(Arrays.toString(game().playerAt(i).sabotaged()));\n if (game().playerAt(i).isRepairable(repair.effects())) {\n //calculate the should i repair? function\n double shouldIBlockMore = Probability[i]+(0.03*(numPlayers-i));\n if(blockMore<shouldIBlockMore) {\n blockMore = shouldIBlockMore;\n targetPlayer = i;\n cardIndex = index;\n }\n }\n }\n }\n }\n if(blockMore>0.75 && targetPlayer>=0)\n return Move.NewPlayerActionMove(index(), cardIndex, targetPlayer);\n }\n //Block Enemy\n if(canBlock) {\n double blockMore = 0.0;\n int targetPlayer = -1;\n int cardIndex = 0;\n for (int i = 0; i < numPlayers; i++) {\n if (i != myTurn) {\n for (Map.Entry<Integer, Card> b : blockCards.entrySet()) {\n int index = b.getKey();\n PlayerActionCard block = (PlayerActionCard) b.getValue();\n if (game().playerAt(i).isSabotageable(block.effects()[0])) {\n //calculate the should i repair? function\n double shouldIBlockMore = (1 - Probability[i]) * ((1 - Probability[i]) + 0.2 * (numPlayers - i));\n if (blockMore < shouldIBlockMore) {\n blockMore = shouldIBlockMore;\n targetPlayer = i;\n cardIndex = index;\n }\n }\n }\n }\n }\n if(blockMore>0.6 && targetPlayer>=0)\n return Move.NewPlayerActionMove(index(), cardIndex, targetPlayer);\n }\n //Fix (Rockfall)\n if(canRockfall) {\n int globalIndex = 0;\n double maxH = 0.0;\n Position bp = new Position(0,0);\n //Find best path to place;\n Board board = game().board().copy();\n for( Map.Entry<Integer, Card> d : destroyCards.entrySet()) {\n int index = d.getKey();\n Set<Position> destroyable = game().board().getDestroyable();\n for (Position h : destroyable) {\n Board simulated = board.simulateRemoveCardAt(h.x, h.y);\n// System.out.println(path.type());\n double cH = getClosest(simulated);\n if(maxH<cH) {\n bp=h;\n globalIndex = index;\n maxH = cH;\n }\n }\n }\n oldBoard = game().board().copy();\n if(maxH>0)\n return Move.NewRockfallMove(index(), globalIndex, bp.x, bp.y);\n }\n //See map\n\n //Conserve (Find the best card to discard)\n\n //calculate the heuristics and adjust accordingly,\n //choose between playing a card or discarding.\n } else if (role() == Role.SABOTEUR) {\n //See map\n if(canSee && !goldFound) {\n int selection=0;\n //specific for saboteurs\n double maxProb=goldProb[0];\n for(int i=0; i<3; i++) {\n if(goldProb[i]>maxProb) {\n maxProb = goldProb[i];\n selection=i;\n }\n }\n Move look = Move.NewMapMove(index(), mapIndex, Board.GoalPosition.TOP);\n switch(selection) {\n case 0:\n look = Move.NewMapMove(index(), mapIndex, Board.GoalPosition.TOP);\n break;\n case 1:\n look = Move.NewMapMove(index(), mapIndex, Board.GoalPosition.MIDDLE);\n break;\n case 2:\n look = Move.NewMapMove(index(), mapIndex, Board.GoalPosition.BOTTOM);\n break;\n }\n return look;\n }\n //Path\n if(canMove) {\n int globalIndex = 0;\n double maxH = 0.0;\n Position bp = new Position(0,0);\n boolean rotate = false;\n //Find best path to place;\n Board board = game().board().copy();\n double oldH = getClosestSabotage(board);\n for( Map.Entry<Integer, Card> p : pathCards.entrySet()) {\n int index = p.getKey();\n Card path = p.getValue();\n ((PathCard)path).setRotated(false);\n Set<Position> placeable = game().board().getPlaceable((PathCard)path);\n for (Position h : placeable) {\n Board simulated = board.simulatePlaceCardAt((PathCard)path, h.x, h.y);\n// System.out.println(path.type());\n double cH = getClosestSabotage(simulated);\n if(maxH<cH) {\n bp=h;\n globalIndex = index;\n maxH = cH;\n rotate=false;\n }\n }\n ((PathCard) path).setRotated(true);\n placeable = game().board().getPlaceable((PathCard)path);\n for (Position h : placeable) {\n Board simulated = board.simulatePlaceCardAt((PathCard)path, h.x, h.y);\n// System.out.println(simulated);\n double cH = getClosestSabotage(simulated);\n if(maxH<cH) {\n bp=h;\n globalIndex = index;\n rotate=true;\n maxH = cH;\n }\n }\n }\n oldBoard = game().board().copy();\n if(maxH>0 && abs(maxH-oldH)>0.01)\n return Move.NewPathMove(index(), globalIndex, bp.x, bp.y, rotate);\n }\n //Unblock Friend\n if(canRepair) {\n double blockMore = 0.0;\n int targetPlayer = -1;\n int cardIndex = 0;\n for(int i=0; i<numPlayers; i++) {\n if(i == myTurn) {\n for(Map.Entry<Integer, Card> r : repairCards.entrySet()) {\n int index = r.getKey();\n PlayerActionCard repair = (PlayerActionCard) r.getValue();\n if (game().playerAt(myTurn).isRepairable(repair.effects())) {\n return Move.NewPlayerActionMove(index(),index, index());\n }\n }\n }\n else if(i!=myTurn) {\n for(Map.Entry<Integer, Card> r : repairCards.entrySet()) {\n int index = r.getKey();\n PlayerActionCard repair = (PlayerActionCard) r.getValue();\n if (game().playerAt(i).isRepairable(repair.effects())) {\n //calculate the should i repair? function\n double shouldIBlockMore = (1-Probability[i])+(0.03*(numPlayers-i));\n if(blockMore<shouldIBlockMore) {\n blockMore = shouldIBlockMore;\n targetPlayer = i;\n cardIndex = index;\n }\n }\n }\n }\n }\n if(blockMore>0.75 && targetPlayer>=0)\n return Move.NewPlayerActionMove(index(), cardIndex, targetPlayer);\n }\n //Block Enemy\n if(canBlock) {\n double blockMore = 0.0;\n int targetPlayer = -1;\n int cardIndex = 0;\n for (int i = 0; i < numPlayers; i++) {\n if (i != myTurn) {\n for (Map.Entry<Integer, Card> b : blockCards.entrySet()) {\n int index = b.getKey();\n PlayerActionCard block = (PlayerActionCard) b.getValue();\n if (game().playerAt(i).isSabotageable(block.effects()[0])) {\n //calculate the should i repair? function\n double shouldIBlockMore = (Probability[i]) * ((Probability[i]) + 0.2 * (numPlayers - i));\n if (blockMore < shouldIBlockMore) {\n blockMore = shouldIBlockMore;\n targetPlayer = i;\n cardIndex = index;\n }\n }\n }\n }\n }\n if(blockMore>0.6 && targetPlayer>=0)\n return Move.NewPlayerActionMove(index(), cardIndex, targetPlayer);\n }\n //Sabotage (Rockfall)\n if(canRockfall) {\n int globalIndex = 0;\n double maxH = 0;\n Position bp = new Position(0,0);\n //Find best path to place;\n Board board = game().board().copy();\n for( Map.Entry<Integer, Card> d : destroyCards.entrySet()) {\n int index = d.getKey();\n Set<Position> destroyable = game().board().getDestroyable();\n for (Position h : destroyable) {\n Board simulated = board.simulateRemoveCardAt(h.x, h.y);\n// System.out.println(path.type());\n double cH = getClosestSabotage(simulated);\n if(maxH<cH) {\n bp=h;\n globalIndex = index;\n maxH = cH;\n }\n }\n }\n oldBoard = game().board().copy();\n if(maxH>0)\n return Move.NewRockfallMove(index(), globalIndex, bp.x, bp.y);\n }\n //Conserve (Find the best card to discard\n\n //calculate the heuristics and adjust accordingly,\n //choose between playing a card or discarding.\n }\n return discardMoves.get(0);\n }", "private boolean moveCheck(Piece p, List<Move> m, int fC, int fR, int tC, int tR) {\n if (null == p) {\n // Legal move!\n m.add(new Move(fC, fR, tC, tR));\n // Continue checking for moves.\n return false;\n }\n if (p.owner != whoseTurn) {\n // Enemy sighted!\n // Legal move!\n m.add(new Move(fC, fR, tC, tR));\n // No more moves!\n }\n return true;\n }" ]
[ "0.6635961", "0.6621705", "0.6436687", "0.6370353", "0.6348739", "0.6331498", "0.6286062", "0.6240484", "0.62336534", "0.6175586", "0.6149953", "0.61392987", "0.61360127", "0.61188114", "0.6077475", "0.6058792", "0.60450363", "0.60390705", "0.6022469", "0.59300905", "0.59243906", "0.59197474", "0.59049714", "0.5893587", "0.5878154", "0.5873138", "0.5872587", "0.58483696", "0.5831212", "0.5826406", "0.5819992", "0.58138317", "0.5808927", "0.5758444", "0.57193106", "0.5689257", "0.56719583", "0.5657549", "0.5655231", "0.56508505", "0.5648813", "0.56430346", "0.56332076", "0.563029", "0.56154895", "0.5614726", "0.56117517", "0.5609214", "0.55964535", "0.5578675", "0.55731124", "0.55727136", "0.55600053", "0.5559941", "0.5553862", "0.5535794", "0.5534049", "0.5529069", "0.5528933", "0.5524573", "0.55238235", "0.55158734", "0.55124", "0.5504597", "0.54984254", "0.5494287", "0.549298", "0.5486839", "0.54832685", "0.5481811", "0.5481673", "0.54779756", "0.5477208", "0.5474528", "0.5472958", "0.5469848", "0.54600817", "0.5459877", "0.5451205", "0.5450989", "0.5444974", "0.5444714", "0.54407156", "0.5437605", "0.5432569", "0.5431179", "0.54279757", "0.5423837", "0.5422338", "0.54182726", "0.54158765", "0.5410307", "0.54092103", "0.54027516", "0.5401804", "0.5400942", "0.5396729", "0.5388668", "0.53820455", "0.5376112" ]
0.64206994
3
Obtain information from algebraic notation of move. First, remove all annotations from the end of the notation. After, if the move is a castle, call the relevant method. If the move is not a castle, retrieve relevent information from the notation, removing the information from the notation after storing it. Use the information to get the starting position of the piece moved and move the piece.
public static void processMove(String move, char color) { if (!Character.isLetter(move.charAt(0))) { return; } char lastChar = move.charAt(move.length() - 1); while (lastChar == '+' || lastChar == '#' || lastChar == '!' || lastChar == '?') { move = move.substring(0, move.length() - 1); lastChar = move.charAt(move.length() - 1); } // Castling if (move.equals("O-O")) { castleKingSide(color); return; } else if (move.equals("O-O-O")) { castleQueenSide(color); return; } char piece = Character.isUpperCase(move.charAt(0)) ? move.charAt(0) : 'P'; int promoteIndex = move.indexOf('='); boolean promote = promoteIndex != -1; int xIndex = move.indexOf('x'); boolean capture = xIndex != -1; if (piece != 'P') { move = move.substring(1, move.length()); } String promotion = promote ? Character.toString(move.charAt(promoteIndex + 1)) + Character.toString(color) : null; if (promote) { move = move.substring(0, promoteIndex); } if (capture) { move = move.replace("x", ""); } int endFile = move.charAt(move.length() - 2) - 97; int endRank = move.charAt(move.length() - 1) - 49; move = move.substring(0, move.length() - 2); int startFile = -1; int startRank = -1; if (!move.equals("")) { for (int i = 0; i < move.length(); i++) { char c = move.charAt(i); if (Character.isLetter(c)) { startFile = c - 97; } else { startRank = c - 49; } } move = ""; } String piecePlusColor = Character.toString(piece) + Character.toString(color); String endPiece = promote ? promotion : piecePlusColor; int[] startPos = getStartPosition(piece, color, startFile, startRank, endFile, endRank, capture); move(endPiece, startPos[0], startPos[1], endFile, endRank); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Override\r\n\tpublic boolean makeMove(String notation) {\n\t\tif(Castle.isCastlingMove(new ChessCoordinate(notation))) {\r\n\t\t\tKing playerKing = (King) getPlayerTurn().getPieces(\"King\", true).get(0);\r\n\t\t\t//return the result of trying to castle\r\n\t\t\treturn playerKing.move(new ChessCoordinate(notation));\r\n\t\t\t\r\n\t\t}else {\r\n\t\t\t//not a castling move, standard move\r\n\t\t\t\t\r\n\t\t\tString[] notationList = notation.split(\"\");\r\n\t\t\t//find the piece name\r\n\t\t\tString pieceName = ChessPieceNames.getPieceName(notationList[0]);\t\t\r\n\t\t\t\r\n\t\t\tif(pieceName == null && getColumnNames().contains(notationList[0].toLowerCase())) {\r\n\t\t\t\t//if first character is a column and returned null from above\r\n\t\t\t\t//must be a pawn move like e4 or axb2\r\n\t\t\t\tpieceName = ChessPieceNames.PAWN.toString();\r\n\t\t\t}else if(pieceName == null){\r\n\t\t\t\t//not a column and null so invalid move\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\r\n//\t\t\t//capturing move if there is a capture (x)\r\n\t\t\tboolean isCaptureMove = Arrays.asList(notationList).contains(\"x\");\r\n\t\t\t\r\n\t\t\t//final coordinate\r\n\t\t\tString coordinateString = notationList[notationList.length-2] + notationList[notationList.length-1];\r\n\t\t\tChessCoordinate coordinate = new ChessCoordinate(coordinateString);\r\n\t\t\tif(coordinate.isValid()) {\r\n\t\t\t\t//extract players alive pieces of piece name\r\n\t\t\t\tList<Piece> piecesOfType = getPlayerTurn().getPieces(pieceName, true);\r\n\t\t\t\t//list of pieces that can move to the same square\r\n\t\t\t\tList<Piece> piecesCanMoveToSquare = new ArrayList<Piece>();\r\n\t\t\t\tfor (Piece piece : piecesOfType) {\r\n\t\t\t\t\t\r\n\t\t\t\t\t//use valid moves of attacking if capturing move, else use move to\r\n\t\t\t\t\tSet<Coordinate> pieceMoves = isCaptureMove \r\n\t\t\t\t\t\t\t? piece.getValidMoves(Action.ATTACK) : piece.getValidMoves(Action.MOVE_TO);\r\n\t\t\t\t\tif(pieceMoves.contains(coordinate))piecesCanMoveToSquare.add(piece);\r\n\t\t\t\t}\t\r\n\t\t\t\t\r\n\t\t\t\tif (piecesCanMoveToSquare.size() == 1) {\r\n\t\t\t\t\t//only one piece can go to that square, so take piece at 0th index as the list only has one element\r\n\t\t\t\t\tpiecesCanMoveToSquare.get(0).move(coordinate);\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\telse if (piecesCanMoveToSquare.size() > 1) {\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(notation.length() <= 3) {\r\n\t\t\t\t\t\tSystem.out.println(\"Invalid move, specify which piece to move to \" + coordinateString);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//multiple pieces of the same type can move to that square, check which one to use\r\n\t\t\t\t\t//if pawn, the identifier to use is the 0th index of notationList, eg axb4. use pawn in column a.\r\n\t\t\t\t\t//for other pieces, column to use is the 1st index of notationList. eg Nab4.\r\n\t\t\t\t\t\r\n\t\t\t\t\t//variable called identifier as it can be a row or column value.\r\n\t\t\t\t\tString identifier = (pieceName.equalsIgnoreCase(ChessPieceNames.PAWN.toString()) ?\r\n\t\t\t\t\t\t\tnotationList[0] : notationList[1]).toLowerCase();\r\n\t\t\t\t\t//identifier should be a row value if pieces share the same column\r\n\t\t\t\t\tboolean isRowIdentifier = shareColumn(piecesOfType);\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(isRowIdentifier && getRowNames().contains(identifier)) {\r\n\t\t\t\t\t\t//locate piece by row and move that piece to coordinate\r\n\t\t\t\t\t\tfor (Piece piece : piecesCanMoveToSquare) {\r\n\t\t\t\t\t\t\t//look at the row number of piece coordinate, see if it matches the identifier \r\n\t\t\t\t\t\t\tif(Character.toString(piece.getPosition().toString().charAt(1)).equalsIgnoreCase(identifier)) {\r\n\t\t\t\t\t\t\t\tpiece.move(coordinate);\r\n\t\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tSystem.out.println(\"There is no \" + pieceName + \" on row \" + identifier);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}else if(getColumnNames().contains(identifier)) {\r\n\t\t\t\t\t\tfor (Piece piece : piecesCanMoveToSquare) {\r\n\t\t\t\t\t\t\t//look at the column letter of piece coordinate, see if it matches the identifier \r\n\t\t\t\t\t\t\tif(Character.toString(piece.getPosition().toString().charAt(0)).equalsIgnoreCase(identifier)) {\r\n\t\t\t\t\t\t\t\tpiece.move(coordinate);\r\n\t\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tSystem.out.println(\"There is no \" + pieceName + \" on column \" + identifier);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//invalid identifier\r\n\t\t\t\t\telse return false;\r\n\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\telse {\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t//invalid coordinate, move can not be played\r\n\t\t\telse return false;\r\n\t\t}\r\n\t\t\r\n\t}", "public String getMoveConverted(String move, boolean whiteTeamMoving) {\n\t\tif (move.startsWith(\"O-O-O\")) { //Queenside castle\n\t\t\tint row = whiteTeamMoving ? 0 : 7;\n\t\t\treturn row + \"\" + 4 + \";\" + row + \"\" + 0 + \";\" + (6 * (whiteTeamMoving ? 1 : -1)) + \";CASTLE\";\n\t\t} else if (move.startsWith(\"O-O\")) { //Kingside castle\n\t\t\tint row = whiteTeamMoving ? 0 : 7;\n\t\t\treturn row + \"\" + 4 + \";\" + row + \"\" + 7 + \";\" + (6 * (whiteTeamMoving ? 1 : -1)) + \";CASTLE\";\n\t\t}\n\n\t\tMatcher matcher = matchingPattern.matcher(move);\n\t\tmatcher.find();\n\n\t\t//Get the matching groups from the regex\n\t\tString pieceType = matcher.group(1);\n\t\tString fromSpecifier = matcher.group(2);\n\t\tString capture = matcher.group(3);\n\t\tString toLocation = matcher.group(4);\n\t\tString upgradeType = matcher.group(5);\n\n\t\tboolean isCapture = capture != null && capture.equals(\"x\");\n\n\t\t//Get the piece type\n\t\tint piece = getPieceNumFromStr(pieceType);\n\n\t\tif (piece != 1) {\n\t\t\tresetEnpassant(whiteTeamMoving ? 1 : -1);\n\t\t}\n\n\t\t//Get the already known row and column values\n\t\tint fromRow = -1;\n\t\tint fromCol = -1;\n\t\tif (fromSpecifier != null) {\n\t\t\tMatcher fromMatcher = positionPattern.matcher(fromSpecifier);\n\t\t\tfromMatcher.find();\n\n\t\t\tString col = fromMatcher.group(1);\n\t\t\tString row = fromMatcher.group(2);\n\n\t\t\tif (col != null) fromCol = (int)col.charAt(0) - (int)'a';\n\t\t\tif (row != null) fromRow = (int)row.charAt(0) - (int)'1';\n\t\t}\n\n\t\t//Get the to row and column values\n\t\tint toCol = (int)toLocation.charAt(0) - (int)'a';\n\t\tint toRow = (int)toLocation.charAt(1) - (int)'1';\n\n\t\t//Figure out what type of piece this will be when it is done\n\t\tint newType = piece;\n\t\tif (upgradeType != null) newType = getPieceNumFromStr(upgradeType);\n\n\t\tif (fromRow == -1 || fromCol == -1) {\n\t\t\tList<String> possibleFroms = new LinkedList<String>();\n\t\t\tif (piece == 1) { //If it is a pawn\n\t\t\t\tif (whiteTeamMoving) {\n\t\t\t\t\tif (isCapture) {\n\t\t\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol+1));\n\t\t\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol-1));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol));\n\t\t\t\t\t\tif (toRow == 3) {\n\t\t\t\t\t\t\tpossibleFroms.add((toRow-2) + \"\" + (toCol));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (isCapture) {\n\t\t\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol+1));\n\t\t\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol-1));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol));\n\t\t\t\t\t\tif (toRow == 4) {\n\t\t\t\t\t\t\tpossibleFroms.add((toRow+2) + \"\" + (toCol));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (piece == 2) { //If it is a rook\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toCol) {\n\t\t\t\t\t\tpossibleFroms.add(toRow + \"\" + i);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toRow) {\n\t\t\t\t\t\tpossibleFroms.add(i + \"\" + toCol);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (piece == 3) { //If it is a knight\n\t\t\t\tpossibleFroms.add((toRow+2) + \"\" + (toCol+1));\n\t\t\t\tpossibleFroms.add((toRow+2) + \"\" + (toCol-1));\n\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol+2));\n\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol-2));\n\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol+2));\n\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol-2));\n\t\t\t\tpossibleFroms.add((toRow-2) + \"\" + (toCol+1));\n\t\t\t\tpossibleFroms.add((toRow-2) + \"\" + (toCol-1));\n\t\t\t} else if (piece == 4) { //If it is a bishop\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toCol) {\n\t\t\t\t\t\tpossibleFroms.add((toRow - toCol + i) + \"\" + (i));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toRow) {\n\t\t\t\t\t\tpossibleFroms.add((i) + \"\" + (toRow + toCol - i));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (piece == 5) { //If it is a queen\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toCol) {\n\t\t\t\t\t\tpossibleFroms.add(toRow + \"\" + i);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toRow) {\n\t\t\t\t\t\tpossibleFroms.add(i + \"\" + toCol);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toCol) {\n\t\t\t\t\t\tpossibleFroms.add((toRow - toCol + i) + \"\" + (i));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toRow) {\n\t\t\t\t\t\tpossibleFroms.add((i) + \"\" + (toRow + toCol - i));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (piece == 6) { //If it is a king\n\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol));\n\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol));\n\t\t\t\tpossibleFroms.add((toRow) + \"\" + (toCol+1));\n\t\t\t\tpossibleFroms.add((toRow) + \"\" + (toCol-1));\n\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol+1));\n\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol-1));\n\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol+1));\n\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol-1));\n\t\t\t}\n\n\t\t\tfinal int fr = fromRow;\n\t\t\tfinal int fc = fromCol;\n\t\t\tOptional<String> originalLocationOP = possibleFroms.stream().filter((s)->{\n\t\t\t\tif (s.contains(\"-\")) return false;\n\n\t\t\t\tint r = Integer.parseInt(s.charAt(0)+\"\");\n\t\t\t\tint c = Integer.parseInt(s.charAt(1)+\"\");\n\n\t\t\t\tif (r < 0 || r > 7 || c < 0 || c > 7) return false;\n\n\t\t\t\tif (board[r][c] != piece * (whiteTeamMoving ? 1 : -1)) return false;\n\n\t\t\t\tif (fr != -1 && fr != r) return false;\n\t\t\t\tif (fc != -1 && fc != c) return false;\n\n\t\t\t\tif (!isLegalMove((r + \"\" + c) + \";\" + (toRow + \"\" + toCol) + \";\" + piece * (whiteTeamMoving ? 1 : -1))) return false;\n\n\t\t\t\treturn true;\n\t\t\t}).findAny(); \n\n\t\t\tString originalLoc = originalLocationOP.get();\n\t\t\tfromRow = Integer.parseInt(originalLoc.charAt(0)+\"\");\n\t\t\tfromCol = Integer.parseInt(originalLoc.charAt(1)+\"\");\n\t\t}\n\n\t\treturn (fromRow + \"\" + fromCol) + \";\" + (toRow + \"\" + toCol) + \";\" + newType * (whiteTeamMoving ? 1 : -1);\n\t}", "private PawnMoveInformation getMoveInformation() {\n\t\treturn this.info;\n\t}", "public void movePiece(Coordinate from, Coordinate to);", "public void processMove(String s) {\n\t\tScanner sc = new Scanner(s);\r\n\t\t// Get the flag change\r\n\t\tString command = sc.next();\r\n\t\tboolean value = sc.nextBoolean();\r\n\t\tif (command.equals(\"turnL\"))\r\n\t\t\tturnL = value;\r\n\t\telse if (command.equals(\"turnR\"))\r\n\t\t\tturnR = value;\r\n\t\telse if (command.equals(\"forth\"))\r\n\t\t\tforth = value;\r\n\t\telse if (command.equals(\"fire\"))\r\n\t\t\tfire = value;\r\n\t\telse\r\n\t\t\tSystem.out.println(\"Unexpected move: \" + command);\r\n\t\t// then unpack position update\r\n\t\tlocX = sc.nextDouble();\r\n\t\tlocY = sc.nextDouble();\r\n\t\tangle = sc.nextDouble();\r\n\t}", "public abstract void buildMoveData(HexagonalBoard board);", "public abstract Piece movePiece(Move move);", "public abstract Move getMove(Board board);", "public void getMove(){\n\t\t\n\t}", "public void applyConvertedMove(String move) {\n\n\t\tString[] moveParts = move.split(\";\");\n\n\t\tint fromRow = Integer.parseInt(moveParts[0].charAt(0) + \"\");\n\t\tint fromCol = Integer.parseInt(moveParts[0].charAt(1) + \"\");\n\n\t\tint toRow = Integer.parseInt(moveParts[1].charAt(0) + \"\");\n\t\tint toCol = Integer.parseInt(moveParts[1].charAt(1) + \"\");\n\n\t\tint piece = board[fromRow][fromCol];//Integer.parseInt(moveParts[2]);\n\t\tint pieceType = Math.abs(board[fromRow][fromCol]);\n\t\tint team = Math.round(Math.signum(board[fromRow][fromCol]));\n\n\t\tboolean doResetEnpassant = true;\n\n\t\tif (pieceType == 1) { //If this is a pawn\n\t\t\tif (Math.abs(board[toRow][toCol]) == 7) { //If it is moving onto an enpassant stored tile\n\t\t\t\tboard[toRow + board[toRow][toCol]/7][toCol] = 0; //Kill the pawn that produced the enpassant tile\n\t\t\t} else if (Math.abs(fromRow - toRow) == 2) { //If it just did the double move thing\n\t\t\t\t//Reset the current enpassant tile\n\t\t\t\tresetEnpassant(team);\n\t\t\t\tdoResetEnpassant = false;\n\n\t\t\t\t//Set an empassant tile\n\t\t\t\tboard[(toRow + fromRow)/2][toCol] = 7 * team;\n\t\t\t\tenpassantCol = toCol;\n\t\t\t}\n\t\t} else if (pieceType == 6) { //If this is a king\n\t\t\tif (fromCol == 4) {\n\t\t\t\tif (doResetEnpassant) resetEnpassant(team);\n\t\t\t\tif (toCol == 7) { //Kingside Castle\n\t\t\t\t\tboard[toRow][6] = piece;\n\t\t\t\t\tboard[toRow][5] = board[toRow][7];\n\t\t\t\t\tboard[toRow][7] = 0;\n\t\t\t\t\tboard[toRow][4] = 0;\n\t\t\t\t\treturn;\n\t\t\t\t} else if (toCol == 0) { //Queenside Castle\n\t\t\t\t\tboard[toRow][2] = piece;\n\t\t\t\t\tboard[toRow][3] = board[toRow][0];\n\t\t\t\t\tboard[toRow][0] = 0;\n\t\t\t\t\tboard[toRow][4] = 0;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (doResetEnpassant) resetEnpassant(team);\n\t\tboard[fromRow][fromCol] = 0;\n\t\tif (moveParts.length > 2 && pieceType == 1 && (team == 1 ? toRow == 7 : team == -1 ? toRow == 0 : false)) {\n\t\t\tpiece = Integer.parseInt(moveParts[2]);\n\t\t}\n\t\tboard[toRow][toCol] = piece;\n\t}", "public abstract void buildMoveData(ChessBoard board);", "void onMoveTaken(Piece captured);", "public char makeMove(Coordinate move);", "private void updateMoveList(Move m) {\n \t//first check for castling move\n \tif(m.getSource().getName().equals(\"King\")) {\n \tint sx = m.getSource().getLocation().getX();\n \tint dx = m.getDest().getLocation().getX();\n \t\n \t//castle king side\n \tif(dx - sx == 2) {\n \t\tmoveList.add(\"0-0\");\n \t\treturn;\n \t}\n \t//castle queen side\n \telse if(sx - dx == 2) {\n \t\tmoveList.add(\"0-0-0\");\n \t\treturn;\n \t}\n \t}\n \t\n \t//now do normal checks for moves\n \t//if no piece, normal notation\n \tif(m.getDest().getName().equals(\"None\")) {\n \t\t\n \t\t//check for en passant\n \t\tif(m.getSource().getName().equals(\"Pawn\")) {\n \t\t\t\n \t\t\t//it's only en passant if the pawn moves diagonally to an empty square \n \t\t\tif(m.getSource().getLocation().getX() != m.getDest().getLocation().getX()) {\n \t\t\t\tmoveList.add(m.getSource().getLocation().getFile()+ \"x\" + m.getDest().getLocation().getNotation());\n \t\t\t\treturn;\n \t\t\t}\n \t\t}\n \t\t\n \t\tmoveList.add(m.getSource().getID() + m.getDest().getLocation().getNotation());\n \t}\n \t//add \"x\" for capturing\n \t//for pawn, it's a bit different\n \telse if(m.getSource().getName().equals(\"Pawn\")) {\n \t\tmoveList.add(m.getSource().getLocation().getFile()+ \"x\" + m.getDest().getLocation().getNotation());\n \t}\n \telse {\n \t\tmoveList.add(m.getSource().getID() + \"x\" + m.getDest().getLocation().getNotation());\n \t}\n }", "public String getMove() {\n\t\treturn move;\n\t}", "public Coordinate getMoveTo();", "public abstract String[] move();", "public abstract void calculateMoves();", "public ArrayList<Coordinate> getPossibleMoveCoordinate() {\n ChessBoard board = this.getChessBoard(); // get chess board\n ArrayList<Coordinate> coords = new ArrayList<Coordinate>(); // create return ArrayList\n int x, y;\n /*\n several cases\n 2 3\n 1 4\n\n 5 8\n 6 7\n\n */\n // case1\n x = this.x_coordinate - 2;\n y = this.y_coordinate + 1;\n if(x >= 0 && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case2\n x = this.x_coordinate - 1;\n y = this.y_coordinate + 2;\n if(x >= 0 && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case3\n x = this.x_coordinate + 1;\n y = this.y_coordinate + 2;\n if(x < board.getWidth() && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case4\n x = this.x_coordinate + 2;\n y = this.y_coordinate + 1;\n if(x < board.getWidth() && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case5\n x = this.x_coordinate - 2;\n y = this.y_coordinate - 1;\n if(x >= 0 && y >= 0 ){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case6\n x = this.x_coordinate - 1;\n y = this.y_coordinate - 2;\n if(x >= 0 && y >= 0){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case7\n x = this.x_coordinate + 1;\n y = this.y_coordinate - 2;\n if(x < board.getWidth() && y >= 0){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case1\n x = this.x_coordinate + 2;\n y = this.y_coordinate - 1;\n if(x < board.getWidth() && y >= 0){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n\n\n return coords;\n }", "public static void moves(String pgn) {\n pgn = pgn.substring(pgn.lastIndexOf(\"]\"), pgn.length());\n\n pgn = pgn.replaceAll(\"[\\\\t\\\\n\\\\r]+\", \" \");\n\n String pgnMoves = pgn.substring(pgn.indexOf(\"1.\"));\n\n int lastMoveIndex = 0;\n int startIndex = 0;\n\n while (startIndex != -1) {\n startIndex = pgnMoves.indexOf(\".\", startIndex);\n int endIndex = pgnMoves.indexOf(\".\", startIndex + 1);\n\n String[] moves;\n\n if (endIndex == -1) {\n moves = pgnMoves.substring(startIndex + 1).trim().split(\" \");\n } else {\n moves = pgnMoves.substring(startIndex + 1, endIndex - 1).trim()\n .split(\" \");\n }\n\n processMove(moves[0], 'w');\n\n if (moves.length >= 2) {\n processMove(moves[1], 'b');\n }\n\n startIndex = endIndex;\n }\n }", "public void move(Instruction instruction) {\n\t\tAction action = instruction.getAction();\n\t\t// System.out.println(\"Instruction: \" + action\n\t\t// + \", Current Position: \"\n\t\t// + this.getCurrentPosition().toString());\n\t\tif (action.equals(Action.I) || action.equals(Action.D)) {\n\t\t\thip.turnDependOnAction(action);\n\t\t} else if (action.equals(Action.A)) {\n\t\t\tif (!isAnExaminedPosition()) {\n\t\t\t\tnotificarSensores();\n\t\t\t}\n\t\t\tmotor.walk();\n\t\t}\n\t}", "protected int getMove() \t\t\t\t{\treturn move;\t\t}", "public SinglePieceMove getMove() {\n return move;\n }", "public interface Moves {\n\n /**\n * Applies the move onto a shape when it is on the correct tick.\n *\n * @return the shape with the move applied onto it\n */\n ShapeState apply(int tick);\n\n\n /**\n * Gets the initial tick of which the move is applicable on.\n *\n * @return the initial tick.\n */\n ShapeState getInitialState();\n\n /**\n * Gets the final tick of which the move is applicable on.\n *\n * @return the final tick.\n */\n ShapeState getFinalState();\n\n /**\n * Checks whether the move is finished at a certain time.\n *\n * @param tick the time to be checked.\n * @return whether the move is finished at that time.\n *\n */\n boolean isMoveFinished(int tick);\n\n\n\n}", "public void MOVE(String input){\n\t\tint YM=0;\n\t\tint XM=0;\n\t\tfor(int i = 0; i<this.position.length;i++){\n\t\t\tfor(int p =0; p<this.position.length;p++){\n\t\t\t\tif(this.position[i][p] == 1){\n\t\t\t\t\tYM = i;\n\t\t\t\t\tXM = p;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tswitch(input){//first block is up and down second block is left and right\n\t\t\tcase \"a\":\n\t\t\t\tif(this.area[YM][XM-1] != \"[ ]\"){\n\t\t\t\t\tthis.position[YM][XM-1] = 1;//to turn left\n\t\t\t\t\tthis.position[YM][XM] = 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"d\":\n\t\t\t\tif(this.area[YM][XM+1] != \"[ ]\"){\n\t\t\t\t\tthis.position[YM][XM+1] = 1;//to turn right\n\t\t\t\t\tthis.position[YM][XM] = 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"w\":\n\t\t\t\tif(this.area[YM-1][XM] != \"[ ]\"){\n\t\t\t\t\tthis.position[YM-1][XM] = 1;//to turn up\n\t\t\t\t\tthis.position[YM][XM] = 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"s\":\n\t\t\t\tif(this.area[YM+1][XM] != \"[ ]\"){\n\t\t\t\t\tthis.position[YM+1][XM] = 1;//to turn down\n\t\t\t\t\tthis.position[YM][XM] = 0; \n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}//end of switch\n\t}", "public abstract void move(int newXPosition, int newYPosition, PiecePosition position) throws BoardException;", "public int[][] Move(/*int []Start, int[]End, */Board B) {\r\n \tif(this.Status[1]=='X'||this.Position[0]<0||this.Position[1]<0) {\r\n \tSystem.out.println(\"This piece is eliminated, cannot move\");\r\n \treturn null;\t\r\n \t}\r\n \t/*\r\n \tif(this.Status[1]=='C'&&this.CMovesets==null) {\r\n \tSystem.out.println(\"This piece cannot save king in check, cannot move\");\r\n \treturn null;\t\r\n \t}\r\n \t*/\r\n \t/*\r\n \tif(Start==null||End==null) {\r\n \t\t\r\n \t\tSystem.out.println(\"Null Start or End Positions\");\r\n \t\t\r\n \t\treturn null;\r\n \t}\r\n \tif(Start.length!=2||End.length!=2) {\r\n \t\t\r\n \t\tSystem.out.println(\"Start or End Positions invalid size\");\r\n \t\t\r\n \t\treturn null;\r\n \t\t\r\n \t}\r\n \tif(Start[0]!=this.Position[0]||Start[1]!=this.Position[1]) {\r\n \t\tSystem.out.println(\"ERROR, Piece Not Synchronized with where it should be\");\r\n \t\tSystem.exit(-1);\r\n \t}\r\n \t*/\r\n \t\r\n \t///////////////////////////\r\n \tint [][]PathSeq = isAnyPath(/*Start,End,*/B);\r\n \t\r\n \tif(PathSeq==null) {\r\n \t\tSystem.out.println(\"No Path sequences possible for this piece\");\r\n \t//////////////////////////\r\n \t\t// IF PIECE IS KING, CHECK IF NO MOVES AVAILABLE to destroy enemy, \r\n \t\t//block enemy, or if king is only piece left, MOVE king, Then Checkmate!\r\n \t\r\n \t//////////////////////////\r\n \treturn null;\r\n \t}\r\n \t\r\n \t/*\r\n \tScanner reader = new Scanner(System.in);\r\n \tboolean ValidIn=false;\r\n \twhile(!ValidIn) {\r\n \t\tSystem.out.println(\"Enter Path seq to be taken\");\r\n \t\t\r\n \t\t\r\n \t}\r\n \t*/\r\n \treturn PathSeq;\r\n }", "public Move movePiece(int turn) {\n\t\tboolean error = false;\n\t\tString moveInput = null;\n\t\tString origin = null;\n\t\tboolean isCorrectTurn = false;\n\t\t@SuppressWarnings(\"resource\")\n\t\tScanner keyboard = new Scanner(System.in);\n\n\t\tdo {\n\t\t\t\n\t\t\ttry {\n\t\t\t\tdo {\n\t\t\t\t\tSystem.out.println(\"Which piece would you like to move?\");\n\t\t\t\t\torigin = keyboard.next();\n\n\t\t\t\t\tif(validateInput(origin)) {\n\t\t\t\t\t\tSystem.out.println(\"Error in input, please try again\");\n\t\t\t\t\t\terror = true; \n\t\t\t\t\t} else {\n\t\t\t\t\t\n\t\t\t\t\t\terror = false;\n\t\t\t\t\t}\n\n\t\t\t\t}while(error);\n\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tString xOrigin = origin.substring(0, 1);\n\t\t\t\tint yOrigin = Integer.parseInt(origin.substring(1,2));\n\t\t\t\tint convertedXOrigin = convertXPosition(xOrigin);\n\t\t\t\tyOrigin -= 1;\n\t\t\t\t\nif((board.getBoard()[yOrigin][convertedXOrigin] == turn) || (board.getBoard()[yOrigin][convertedXOrigin] == (turn + 2))) {\n\t\t\t\tisCorrectTurn = true;\n\t\t\t\tChecker checker = validatePiece(convertedXOrigin, yOrigin);\t\n\t\t\t\tdo {\n\t\t\t\t\t\n\t\t\t\t\t\tSystem.out.println(\"Where would you like to move\");\n\t\t\t\t\t\t moveInput = keyboard.next();\n\t\t\t\t\t\tif(validateInput(moveInput)) {\n\t\t\t\t\t\t\tSystem.out.println(\"Error in Input, please try again\");\n\t\t\t\t\t\t\terror = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\terror = false;\n\t\t\t\t\t\t//\tSystem.out.println(\"No errors found with input move\");\n\t\t\t\t\t\t}\n\n\t\t\t\t} while(error);\n\t\t\t\t\n\t\t\t\tString xMove = moveInput.substring(0, 1);\n\t\t\t\tint yMove = Integer.parseInt(moveInput.substring(1,2));\n\t\t\t\tint convertedXMove = convertXPosition(xMove);\n\t\t\t\tyMove -= 1;\n\t\t\t\tboolean isMovingRight = isMovingRight(convertedXOrigin, yOrigin, convertedXMove, yMove);\n\t\t\t\tboolean isMovingDown = isMovingDown(convertedXOrigin, yOrigin, convertedXMove, yMove);\n\t\t\t\tMove move = null;\n\t\t\t\t\n\t\t\t\t//checks to see if the move itself is valid\n\t\t\t\ttry {\nif(isMoveValid(convertedXOrigin, yOrigin, convertedXMove, yMove, isMovingRight, isMovingDown)) {\n\t\t\t\tif(isSpaceTaken(convertedXMove, yMove)) {\n\t\t\t\t\t//System.out.println(\"Space is taken\");\n\t\t\t\t\tif(isPieceEnemy(convertedXMove, yMove, checker, turn)) {\n\t\t\t\t\t\tif(isJumpValid(convertedXOrigin, yOrigin, convertedXMove, yMove, isMovingRight, isMovingDown)) {\n\t\t\t\t\t\t\tif(isMovingRight) {\n\t\t\t\t\t\t\t\t//checks to see if the piece is moving up or down\n\t\t\t\t\t\t\t\tif(isMovingDown) {\n\t\t\t\t\t\t\t\t\t//means the piece is moving right and down\n\t\t\t\t\t\t\t\t\t move = new Move(convertedXOrigin, yOrigin, convertedXMove + 1, yMove + 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\t\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t//means the piece is moving right, but up\n\t\t\t\t\t\t\t\t\t move = new Move(convertedXOrigin, yOrigin, convertedXMove + 1, yMove - 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif(isMovingDown) {\n\t\t\t\t\t\t\t\t\t//means its moving left and down\n\t\t\t\t\t\t\t\t\tmove = new Move(convertedXOrigin, yOrigin, convertedXMove - 1, yMove + 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t//means it's moving left and up\n\t\t\t\t\t\t\t\t\tmove = new Move(convertedXOrigin, yOrigin, convertedXMove - 1, yMove - 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\t\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t//System.out.println(\"Space isn't taken\");\n\t\t\t\t\tmove = new Move(convertedXOrigin, yOrigin, convertedXMove, yMove);\n\t\t\t\t\tmodel.moves.add(move);\n\t\t\t\t\tif(canBeKing(checker, move)) {\n\t\t\t\t\t\tchecker = convertToKing(checker, move);\n\t\t\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\tprintBoard();\n\t\t\t\t\t\treturn move;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\t\tupdateBoard(move);\n\t\t\t\t\t\n\t\t\t\t\tprintBoard();\n\t\t\t\t\treturn move;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tSystem.out.println(\"Error in move\");\n\t\t\t\t//System.out.println(\"It's not your turn\");\n\t\t\t\tisCorrectTurn = false;\n\t\t\t\t}\n\t\t\t\t} catch (NullPointerException e) {\n\t\t\t\t\tSystem.out.println(\"NullPointerException - Error\");\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tif(canBeKing(checker, move)) {\n\t\t\t\tchecker = convertToKing(checker, move);\n\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\t\n\t\t\t\tprintBoard();\n\t\t\t\treturn move;\n}\n\n\n\n\t\t\t\t\n\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\tupdateBoard(move);\n\t\t\t\t\n\t\t\t\tprintBoard();\n\t\t\t\treturn move;\n\t\t\t\t}\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\tSystem.out.println(\"Error in Input. Please try again\");\n\t\t\t}\n\t\t\n\t\t}while(!isCorrectTurn);\n\n\t\tprintBoard();\n\t\treturn null;\n\t\t\n\t}", "@Override\n public void calculateMove() {\n int xa = 0, ya = 0;\n if (steps <= 0) {\n direction = ep.calculateDirection();\n steps = MAX_STEPS;\n }\n if (direction == 0) {\n ya--;\n }\n if (direction == 2) {\n ya++;\n }\n if (direction == 3) {\n xa--;\n }\n if (direction == 1) {\n xa++;\n }\n if (canMove(xa, ya)) {\n steps -= 1 + rest;\n move(xa * speed, ya * speed);\n moving = true;\n } else {\n steps = 0;\n moving = false;\n }\n }", "@Override\n public void process(AS3Parser context) {\n\n String[] result = context.findFileByString(\"init ship manager\");\n if(result.length == 0)\n System.out.println(\"FIX ME: cant find ship manager.\");\n else if(result.length > 1)\n System.out.println(\"FIX ME: multiply results for: ship manager.\");\n else{\n mShipManagerSrc = result[0];\n int moveFuncIndex = mShipManagerSrc.indexOf(\"_.x\");\n if(moveFuncIndex != -1){\n //System.out.println(\"Found player move command.\");\n String xLine = context.findLineByString(mShipManagerSrc,\"_.x\")[0];\n String yLine = context.findLineByString(mShipManagerSrc,\"_.y\")[0];\n\n String var_x = RegexHelper.match(xLine,\"var (.*?):\")[1];\n String var_y = RegexHelper.match(yLine,\"var (.*?):\")[1];\n\n String moveSubSrc = context.findLineByString(mShipManagerSrc,\"(\" + var_x + \",\" + var_y + \");\")[1];\n String moveMessageClass = RegexHelper.match(moveSubSrc,\".(.*?)\\\\.\")[1];\n moveMessageClass = moveMessageClass.trim();\n\n String proxyClassSrc = context.findFileByString(\"class \" + moveMessageClass + \" \")[0];\n String moveMessageClass2 = RegexHelper.match(proxyClassSrc,\"var_.*?\\\\.method_.*?\\\\((class_.*?)\\\\..*?\\\\);\")[1];\n String moveMessageSrc = context.findFileByString(\"class \" + moveMessageClass2 + \" \")[0];\n\n\n //getting infos\n packetId = Integer.parseInt(RegexHelper.match(RegexHelper.getStringBetween(moveMessageSrc,\"method_16()\",\"}\"),\"return (.*?);\")[1]);\n findWrite(moveMessageSrc);\n }else{\n System.out.println(\"FIX ME: cant find player move command.\");\n }\n }\n\n\n\n }", "P applyMovement(M move);", "public abstract void calcPathToKing(Space kingSpot);", "private Move _getNextMovePacket(Packet packet) {\n Move move = new Move();\n\n try {\n switch (packet.command) {\n\n case START:\n move.action = Action.START;\n move.id = packet.getField(\"id\", Integer.class);\n break;\n\n case ANTE:\n move.chips = packet.getField(\"chips\", Integer.class);\n\n // Request the next Move directly, which should be a STAKES\n Move stks = getNextMove();\n if (stks.action != Action.STAKES) {\n System.err.println(\"Invalid packet after ANTE\");\n move.action = Action.NOOP;\n return move;\n }\n\n move.action = Action.ANTE_STAKES;\n move.cStakes = stks.cStakes;\n move.sStakes = stks.sStakes;\n break;\n\n case STAKES:\n move.action = Action.STAKES;\n move.cStakes = packet.getField(\"stakes_client\", Integer.class);\n move.sStakes = packet.getField(\"stakes_server\", Integer.class);\n break;\n\n case ANTE_OK:\n move.action = Action.ANTE_OK;\n break;\n\n case QUIT:\n move.action = Action.QUIT;\n break;\n\n case DEALER:\n move.action = Action.DEALER_HAND;\n move.dealer = packet.getField(\"dealer\", Integer.class);\n Move hand = getNextMove();\n if (hand.cards == null) {\n System.err.println(\"Invalid packet after DEALER\");\n move.action = Action.NOOP;\n return move;\n }\n move.cards = hand.cards;\n break;\n case HAND:\n move.action = Action.DEALER_HAND;\n move.cards = cardsFromCodeString(packet.getField(\"cards\", String.class));\n break;\n\n case RAISE:\n move.action = Action.RAISE;\n move.chips = packet.getField(\"chips\", Integer.class);\n break;\n case BET:\n move.action = Action.BET;\n move.chips = packet.getField(\"chips\", Integer.class);\n break;\n\n case DRAW:\n // If any cards were requested, get the Card array\n move.action = Action.DRAW;\n move.cDrawn = packet.getField(\"number\", Integer.class);\n if (move.cDrawn > 0)\n move.cards = cardsFromCodeString(packet.getField(\"cards\", String.class));\n break;\n\n case DRAW_SERVER:\n move.action = Action.DRAW_SERVER;\n move.sDrawn = packet.getField(\"number\", Integer.class);\n move.cards = cardsFromCodeString(packet.getField(\"cards\", String.class));\n break;\n\n case SHOWDOWN:\n move.action = Action.SHOW;\n move.cards = cardsFromCodeString(packet.getField(\"cards\", String.class));\n break;\n\n case ERROR:\n move.action = Action.ERROR;\n move.error = packet.getField(\"error\", String.class);\n break;\n\n case NET_ERROR:\n // Irrecoverable network error. Terminate the Client Game\n move.action = Action.TERMINATE;\n break;\n\n case PASS:\n move.action = Action.PASS;\n break;\n case CALL:\n move.action = Action.CALL;\n break;\n case FOLD:\n move.action = Action.FOLD;\n break;\n }\n } catch (Exception e) {\n e.printStackTrace();\n NET_ERROR(\"Network Source: Problem reading next Move arguments\");\n move.action = Action.NOOP;\n }\n\n return move;\n }", "public void moveToNextPosition(final char movement) throws UnknownInstructionException {\n switch(movement) {\n case 'G':\n case 'D':\n MowerCardinality newOrientation = MowerCardinality.rotate(this.getPosition().getOrientation(), movement);\n logger.debug(\"Rotating mower : {} -> {}\", this.position.getOrientation(), newOrientation);\n this.position.setOrientation(newOrientation);\n break;\n case 'A':\n this.moveMower(movement);\n break;\n default:\n throw new UnknownInstructionException();\n }\n }", "public void findValidMoveDirections(){\n\t\t\n\t\tif(currentTile == 2 && (tileRotation == 0 || tileRotation == 180)){ // in vertical I configuration\n\t\t\tcanMoveNorth = true; canMoveSouth = true;\n\t\t\tcanMoveEast = false; canMoveWest = false;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" N,S: T E,W: F\");\n\t\t}\n\t\telse if(currentTile == 2 && (tileRotation == 90 || tileRotation == 270)){ // in horizontal I configuration\n\t\t\tcanMoveNorth = false; canMoveSouth = false;\n\t\t\tcanMoveEast = true; canMoveWest = true;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" N,S: F E,W: T\");\n\t\t}\n\t\t\n\t\t\n\t\telse if(currentTile == 3 && tileRotation == 0){ // L rotated 0 degrees\n\t\t\tcanMoveNorth = true; canMoveSouth = false;\n\t\t\tcanMoveEast = true; canMoveWest = false;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" N,E: T S,W: F\");\n\t\t}\n\t\telse if(currentTile == 3 && tileRotation == 90){ // L rotated 90 degrees\n\t\t\tcanMoveNorth = true; canMoveSouth = false;\n\t\t\tcanMoveEast = false; canMoveWest = true;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" N,W: T S,E: F\");\n\t\t}\n\t\telse if(currentTile == 3 && tileRotation == 180){ // L rotated 180 degrees\n\t\t\tcanMoveNorth = false; canMoveSouth = true;\n\t\t\tcanMoveEast = false; canMoveWest = true;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" S,W: T N,E: F\");\n\t\t}\n\t\telse if(currentTile == 3 && tileRotation == 270){ // L rotated 270 degrees\n\t\t\tcanMoveNorth = false; canMoveSouth = true;\n\t\t\tcanMoveEast = true; canMoveWest = false;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" S,E: T N,W: F\");\n\t\t}\n\t\t\n\t\t\n\t\telse if(currentTile == 4 && tileRotation == 0){ // T rotated 0 degrees\n\t\t\tcanMoveNorth = false; canMoveSouth = true;\n\t\t\tcanMoveEast = true; canMoveWest = true;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" S,W,E: T N: F\");\n\t\t}\n\t\telse if(currentTile == 4 && tileRotation == 90){ // T rotated 90 degrees\n\t\t\tcanMoveNorth = true; canMoveSouth = true;\n\t\t\tcanMoveEast = true; canMoveWest = false;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" N,S,E: T W: F\");\n\t\t}\n\t\telse if(currentTile == 4 && tileRotation == 180){ // T rotated 180 degrees\n\t\t\tcanMoveNorth = true; canMoveSouth = false;\n\t\t\tcanMoveEast = true; canMoveWest = true;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" N,W,E: T S: F\");\n\t\t}\n\t\telse if(currentTile == 4 && tileRotation == 270){ // T rotated 270 degrees\n\t\t\tcanMoveNorth = true; canMoveSouth = true;\n\t\t\tcanMoveEast = false; canMoveWest = true;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" N,S,W: T E: F\");\n\t\t}\n\t\telse if(currentTile == 5){ //in plus tile\n\t\t\tcanMoveNorth = true; canMoveSouth = true;\n\t\t\tcanMoveEast = true; canMoveWest = true;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" N,S,W,E: T\");\n\t\t}\n\t\t\n\t}", "private void moveAllignedMhos() {\n\n\t\t//Assign playerX and playerY to the X and Y of the player\n\t\tint playerX = getNewPlayerLocation()[0];\n\t\tint playerY = getNewPlayerLocation()[1];\n\n\t\t//Iterate through every mho's X and Y values\n\t\tfor(int i = 0; i < mhoLocations.size()/2; i++) {\n\n\t\t\t//Assign mhoX and mhoY to the X and Y values of the mho that is currently being tested\n\t\t\tint mhoX = mhoLocations.get(i*2);\n\t\t\tint mhoY = mhoLocations.get(i*2+1);\n\n\t\t\t//set the default X and Y offsets to 0, and the move to NO_MOVEMENT\n\t\t\tint xOffset = 0;\n\t\t\tint yOffset = 0;\n\t\t\tchar move = Legend.NO_MOVEMENT;\n\n\t\t\t//Check if the playerX is equal to mhoX (aligned on x-axis)\n\t\t\tif(playerX == mhoX) {\n\n\t\t\t\t//Check which direction the mho would have to move, and assign the corresponding move and yOffset\n\t\t\t\tif(playerY > mhoY) {\n\t\t\t\t\tyOffset = 1;\n\t\t\t\t\tmove = Legend.DOWN;\n\t\t\t\t} else {\n\t\t\t\t\tyOffset = -1;\n\t\t\t\t\tmove = Legend.UP;\n\t\t\t\t}\n\t\t\t} else if(playerY == mhoY) {\n\n\t\t\t\t//Check which direction the mho would have to move, and assign the corresponding move and XOffset\n\t\t\t\tif(playerX > mhoX) {\n\t\t\t\t\txOffset = 1;\n\t\t\t\t\tmove = Legend.RIGHT;\n\t\t\t\t} else {\n\t\t\t\t\txOffset = -1;\n\t\t\t\t\tmove = Legend.LEFT;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//Only move if the new location is not an instance of mho (in order to make sure they are moved in the right order)\n\t\t\tif(!(newMap[mhoX+xOffset][mhoY+yOffset] instanceof Mho)) {\n\n\t\t\t\t//Set the previous location to a BlankSpace\n\t\t\t\tnewMap[mhoX][mhoY] = new BlankSpace(mhoX, mhoY, board);\n\n\t\t\t\t//If the new square would be a player, end the game\n\t\t\t\tif(newMap[mhoX+xOffset][mhoY+yOffset] instanceof Player) {\n\t\t\t\t\tmoveList[mhoX+xOffset][mhoY+yOffset] = Legend.SHRINK;\n\t\t\t\t\tgameOver();\n\t\t\t\t}\n\n\t\t\t\t//If the new square would be a fence, remove the mho from the map\n\t\t\t\tif(!(newMap[mhoX+xOffset][mhoY+yOffset] instanceof Fence)) {\n\t\t\t\t\tnewMap[mhoX+xOffset][mhoY+yOffset] = new Mho(mhoX+xOffset, mhoY+yOffset, board);\n\t\t\t\t} else {\n\t\t\t\t\tmove = Legend.SHRINK;\n\t\t\t\t}\n\n\t\t\t\t//Set the move of the mho on moveList\n\t\t\t\tmoveList[mhoX][mhoY] = move;\n\n\t\t\t\t//remove the mhoX and mhoY in mhoLocations\n\t\t\t\tmhoLocations.remove(i*2+1);\n\t\t\t\tmhoLocations.remove(i*2);\n\n\t\t\t\t//Call moveAllignedMhos() again, because the list failed to be checked through completely\n\t\t\t\tmoveAllignedMhos();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}", "public Board move(String s, boolean si) {\t\t\n\t\t\n\t\t//Queen-side castling\n\t\tif (s.length() >= 5 && s.substring(0, 5).equals(\"O-O-O\")) {\n\t\t\t\n\t\t\tPiece tempKing;\n\t\t\tPiece tempRook;\n\t\t\tPiece tempNull1;\n\t\t\tPiece tempNull2;\n\t\t\t\n\t\t\tif (si) {\n\t\t\t\t((King) b[0][4]).castle();\n\t\t\t\ttempKing = b[0][4];\n\t\t\t\ttempRook = b[0][0];\n\t\t\t\ttempNull1 = b[0][2];\n\t\t\t\ttempNull2 = b[0][3];\n\t\t\t\t\n\t\t\t\tb[0][2] = tempKing;\n\t\t\t\tb[0][3] = tempRook;\n\t\t\t\tb[0][2].setPosition((byte) 0, (byte) 2);\n\t\t\t\tb[0][3].setPosition((byte) 0, (byte) 3);\n\t\t\t\t\n\t\t\t\tb[0][0] = tempNull1;\n\t\t\t\tb[0][4] = tempNull2;\n\t\t\t\tb[0][0].setPosition((byte) 0, (byte) 0);\n\t\t\t\tb[0][4].setPosition((byte) 0, (byte) 4);\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\t((King) b[7][4]).castle();\n\t\t\t\ttempKing = b[7][4];\n\t\t\t\ttempRook = b[7][0];\n\t\t\t\ttempNull1 = b[7][2];\n\t\t\t\ttempNull2 = b[7][3];\n\t\t\t\t\n\t\t\t\tb[7][2] = tempKing;\n\t\t\t\tb[7][3] = tempRook;\n\t\t\t\tb[7][2].setPosition((byte) 7, (byte) 2);\n\t\t\t\tb[7][3].setPosition((byte) 7, (byte) 3);\n\t\t\t\t\n\t\t\t\tb[7][0] = tempNull1;\n\t\t\t\tb[7][4] = tempNull2;\n\t\t\t\tb[7][0].setPosition((byte) 7, (byte) 0);\n\t\t\t\tb[7][4].setPosition((byte) 7, (byte) 4);\n\t\t\t}\n\t\t\t\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t//King-side castling\n\t\tif (s.substring(0, 3).equals(\"O-O\")) {\n\t\t\tPiece tempKing;\n\t\t\tPiece tempRook;\n\t\t\tPiece tempNull1;\n\t\t\tPiece tempNull2;\n\t\t\t\n\t\t\tif (si) {\n\t\t\t\t((King) b[0][4]).castle();\n\t\t\t\t\n\t\t\t\ttempKing = b[0][4];\n\t\t\t\ttempRook = b[0][7];\n\t\t\t\ttempNull1 = b[0][5];\n\t\t\t\ttempNull2 = b[0][6];\n\t\t\t\t\n\t\t\t\tb[0][6] = tempKing;\n\t\t\t\tb[0][5] = tempRook;\n\t\t\t\tb[0][6].setPosition((byte) 0, (byte) 6);\n\t\t\t\tb[0][5].setPosition((byte) 0, (byte) 5);\n\t\t\t\t\n\t\t\t\tb[0][7] = tempNull1;\n\t\t\t\tb[0][4] = tempNull2;\n\t\t\t\tb[0][7].setPosition((byte) 0, (byte) 7);\n\t\t\t\tb[0][4].setPosition((byte) 0, (byte) 4);\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\t((King) b[7][4]).castle();\n\t\t\t\t\n\t\t\t\ttempKing = b[7][4];\n\t\t\t\ttempRook = b[7][7];\n\t\t\t\ttempNull1 = b[7][5];\n\t\t\t\ttempNull2 = b[7][6];\n\t\t\t\t\n\t\t\t\tb[7][6] = tempKing;\n\t\t\t\tb[7][5] = tempRook;\n\t\t\t\tb[7][6].setPosition((byte) 7, (byte) 6);\n\t\t\t\tb[7][5].setPosition((byte) 7, (byte) 5);\n\t\t\t\t\n\t\t\t\tb[7][7] = tempNull1;\n\t\t\t\tb[7][4] = tempNull2;\n\t\t\t\tb[7][7].setPosition((byte) 7, (byte) 7);\n\t\t\t\tb[7][4].setPosition((byte) 7, (byte) 4);\n\t\t\t}\n\t\t\t\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\tbyte fR, fC, tR, tC;\n\t\t\n\t\tfR = (byte) (Byte.parseByte(s.substring(2, 3)) - 1);\n\t\ttR = (byte) (Byte.parseByte(s.substring(5, 6)) - 1);\n\t\t\n\t\tif (s.charAt(1) == 'a') {\n\t\t\tfC = 0;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'b') {\n\t\t\tfC = 1;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'c') {\n\t\t\tfC = 2;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'd') {\n\t\t\tfC = 3;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'e') {\n\t\t\tfC = 4;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'f') {\n\t\t\tfC = 5;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'g') {\n\t\t\tfC = 6;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'h') {\n\t\t\tfC = 7;\n\t\t}\n\t\t\n\t\telse {\n\t\t\tSystem.out.println(\"Invalid Entry\");\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\tif (s.charAt(4) == 'a') {\n\t\t\ttC = 0;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'b') {\n\t\t\ttC = 1;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'c') {\n\t\t\ttC = 2;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'd') {\n\t\t\ttC = 3;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'e') {\n\t\t\ttC = 4;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'f') {\n\t\t\ttC = 5;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'g') {\n\t\t\ttC = 6;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'h') {\n\t\t\ttC = 7;\n\t\t}\n\t\t\n\t\telse {\n\t\t\tSystem.out.println(\"Invalid Entry\");\n\t\t\treader.pause();\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\tif (b[fR][fC] instanceof King) {\n\t\t\t((King) b[fR][fC]).cantC(0);\n\t\t}\n\t\t\n\t\tif (b[fR][fC] instanceof Rook) {\n\t\t\tif (si) {\n\t\t\t\tif (fR == 0 && fC == 0) {\n\t\t\t\t\tgetKing(si).cantC(-1);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\telse if (fR == 0 && fC == 7) {\n\t\t\t\t\tgetKing(si).cantC(1);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\tif (fR == 7 && fC == 0) {\n\t\t\t\t\tgetKing(si).cantC(-1);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\telse if (fR == 7 && fC == 7) {\n\t\t\t\t\tgetKing(si).cantC(1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tb[tR][tC] = b[fR][fC];\n\t\tb[tR][tC].setPosition(tR, tC);\n\t\tb[fR][fC] = new Null(fR, fC);\n\t\t\n\t\tif (s.length() >= 8 && s.charAt(6) == '=') {\n\t\t\tchar p = s.charAt(7);\n\t\t\t\n\t\t\tif (p == 'N') {\n\t\t\t\tb[tR][tC] = new Knight(si, tR, tC);\n\t\t\t}\n\t\t\n\t\t\telse if (p == 'B') {\n\t\t\t\tb[tR][tC] = new Bishop(si, tR, tC);\n\t\t\t}\n\t\t\t\n\t\t\telse if (p == 'R') {\n\t\t\t\tb[tR][tC] = new Rook(si, tR, tC);\n\t\t\t}\n\t\t\t\n\t\t\telse if (p == 'Q') {\n\t\t\t\tb[tR][tC] = new Queen(si, tR, tC);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}", "public Direction getMove(){\n\t\tif (diam < 3){\n\t\t\tdiam++;\n\t\t\tjustnow = \"east\";\n\t\t\treturn Direction.EAST;\n\t\t}\n\t\telse if (diam < 6){\n\t\t\tdiam++;\n\t\t\tjustnow = \"south\";\n\t\t\treturn Direction.SOUTH;\n\t\t}\n\t\telse if (diam < 9){\n\t\t\tdiam++;\n\t\t\tjustnow = \"west\";\n\t\t\treturn Direction.WEST;\n\t\t}\n\t\telse if (diam < 12){\n\t\t\tdiam++;\n\t\t\tjustnow = \"north\";\n\t\t\treturn Direction.NORTH;\n\t\t}\n\t\telse {\n\t\t\tdiam = 0;\n\t\t\tdiam++;\n\t\t\tjustnow = \"east\";\n\t\t\treturn Direction.EAST;\n\t\t}\t\n\t}", "public Move move(char[][] fields) {\n int vision = getVisionFieldsCount(); //count of fields / middle\n char me = fields[vision][vision]; //middle of fields\n int leastDanger = Integer.MAX_VALUE;\n Move bestMove = Move.STAY;\n for (Move move : Move.values()) {\n int danger = 0;\n for (int i = 1; i <= vision; i++) { //loop through fields in specific direction\n int fieldX = vision + (i * move.getXOffset());\n int fieldY = vision + (i * move.getYOffset());\n switch(fields[fieldX][fieldY]) {\n case 'A':\n if(boldness < 10)\n danger++;\n else\n danger--;\n break;\n case ' ':\n break;\n default:\n danger-=2;\n }\n }\n if (danger < leastDanger) {\n bestMove = move;\n leastDanger = danger;\n }\n }\n return bestMove;\n }", "public Move move() {\n\n byte[] piece;\n int pieceIndex;\n Move.Direction direction = null;\n int counter = 0;\n\n Scanner s = new Scanner(System.in);\n\n\n System.out.println(\"Please select piece to move: \");\n\n\n while (true) {\n try {\n pieceIndex = s.nextInt();\n\n if ((piece = getPiece(pieceIndex)) == null) {\n System.out.println(\"invalid index, try again!\");\n// check if selected piece is stuck\n } else if (\n (((player == Board.V) && (piece[1]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O ) || // UP\n ((player == Board.H) && (piece[1]-1 >=0) && (board.layout[piece[0]][piece[1]-1] == O)) || // DOWN\n ((player == Board.V) && (piece[0]-1 >=0) && (board.layout[piece[0]-1][piece[1]] == O)) || // LEFT\n (((player == Board.H) && (piece[0]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O )) // RIGHT\n {\n break;\n// if all are stuck pass turn\n } else if (counter + 1 < Board.getSize()) {\n counter++;\n System.out.println(\"Piece is stuck, pick another, \" + counter + \" pieces stuck.\");\n } else {\n System.out.println(\"Passing\");\n return null;\n }\n } catch (Exception e){\n System.out.println(\"Piece index expects int, try again\");\n s = new Scanner(System.in);\n }\n }\n System.out.println(\"Please select direction ('w' // 'a' // 's' // 'd'): \");\n\n boolean valid = false;\n while (!valid) {\n\n switch (s.next().charAt(0)) {\n // if the move requested is valid, break the loop, make the move on our record of layout and return the\n // move made\n case 'w':\n direction = Move.Direction.UP;\n valid = (((player == Board.V) && (piece[1]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O );\n break;\n\n case 'a':\n direction = Move.Direction.LEFT;\n valid = ((player == Board.V) && (piece[0]-1 >=0) && (board.layout[piece[0]-1][piece[1]] == O));\n break;\n\n case 's':\n direction = Move.Direction.DOWN;\n valid = ((player == Board.H) && (piece[1]-1 >=0) && (board.layout[piece[0]][piece[1]-1] == O));\n break;\n\n case 'd':\n direction = Move.Direction.RIGHT;\n valid = (((player == Board.H) && (piece[0]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O );\n break;\n default:\n System.out.println(\"Invalid key press, controls are wasd\");\n valid = false;\n }\n }\n Move move = makeMove(direction, pieceIndex);\n board.update(move, player);\n\n return move;\n }", "public abstract void calculateMovement();", "public void updatePossibleMovesOther(){\n\t\tif( hasMoved){\n\t\t\tpossibleMovesOther = null;\n\t\t\treturn;\n\t\t}\n\t\t// Get left castle updateMoves first\n\t\tchar[] temp = AlgebraicNotationHelper.getAlgebraicNotationLeftOf( startingFile, startingRank);\n\t\ttemp = AlgebraicNotationHelper.getAlgebraicNotationLeftOf( temp[0], temp[1]);\n\t\ttemp = AlgebraicNotationHelper.getAlgebraicNotationLeftOf( temp[0], temp[1]);\n\t\t// Should be b1 for light color King (or b8 for dark color King)\n\t\tAlgebraicNotation tempAN = new AlgebraicNotation( temp[0], temp[1]);\n\t\tpossibleMovesOther.add( tempAN);\n\t\t// Get right castle updateMoves next\n\t\ttemp = AlgebraicNotationHelper.getAlgebraicNotationRightOf( startingFile, startingRank);\n\t\ttemp = AlgebraicNotationHelper.getAlgebraicNotationRightOf( temp[0], temp[1]);\n\t\t// Should be g1 for light color King (or g8 for dark color King)\n\t\ttempAN = new AlgebraicNotation( temp[0], temp[1]);\n\t\tpossibleMovesOther.add( tempAN);\t\n\t}", "public void makeMove(String castleString) throws InvalidMoveException {\n Piece kingPiece, rookPiece, betweenPiece;\n Coordinate kingCoordinate, rookCoordinate, betweenCoordinate, oppCoordinate;\n int xIncrement, spacesToRook;\n\n // verify valid castle String O-O or O-O-O\n if (!castleString.equals(KING_SIDE_CASTLE_STRING) && !castleString.equals(QUEEN_SIDE_CASTLE_STRING)) {\n throw new InvalidMoveException();\n }\n\n kingCoordinate = getKingCoordinate(nextMoveColor);\n kingPiece = getPieceFromCoordinate(kingCoordinate);\n\n // King cannot be in check or have moved already\n if (isInCheck(nextMoveColor) || kingPiece.getHasMoved()) {\n throw new InvalidMoveException();\n }\n\n if (castleString == KING_SIDE_CASTLE_STRING) {\n xIncrement = 1;\n spacesToRook = 3;\n }\n else {\n xIncrement = -1;\n spacesToRook = 4;\n }\n\n rookCoordinate = new Coordinate(kingCoordinate.getPosX() + spacesToRook * xIncrement,\n kingCoordinate.getPosY());\n rookPiece = getPieceFromCoordinate(rookCoordinate);\n // Rook must not have moved already\n if (!(rookPiece instanceof Rook) || rookPiece.getPieceColor() != nextMoveColor || rookPiece.getHasMoved()) {\n throw new InvalidMoveException();\n }\n\n betweenCoordinate = new Coordinate(kingCoordinate);\n for (int i = 0; i < 2; i++) {\n betweenCoordinate.addVals(xIncrement, 0);\n betweenPiece = getPieceFromCoordinate(betweenCoordinate);\n // the two spaces to the left or right of the King must be empty\n if (betweenPiece != null) {\n throw new InvalidMoveException();\n }\n for (int j = 0; j < VERTICAL_BOARD_LENGTH; j++) {\n for (int k = 0; k < HORIZONTAL_BOARD_LENGTH; k++) {\n oppCoordinate = new Coordinate(k, j);\n // an opposing piece cannot be attacking the two empty spaces\n if (isValidEndpoints(oppCoordinate, betweenCoordinate, oppositeColor(nextMoveColor))) {\n if (isValidPath(oppCoordinate, betweenCoordinate, oppositeColor(nextMoveColor), false)) {\n throw new InvalidMoveException();\n }\n }\n }\n }\n }\n\n // move the King and Rook for castling\n boardArray[betweenCoordinate.getPosY()][betweenCoordinate.getPosX()] = kingPiece;\n boardArray[kingCoordinate.getPosY()][kingCoordinate.getPosX()] = null;\n kingPiece.setPieceCoordinate(betweenCoordinate);\n\n betweenCoordinate.addVals(xIncrement * -1, 0);\n boardArray[betweenCoordinate.getPosY()][betweenCoordinate.getPosX()] = rookPiece;\n boardArray[rookCoordinate.getPosY()][rookCoordinate.getPosX()] = null;\n rookPiece.setPieceCoordinate(betweenCoordinate);\n\n\n kingPiece.setHasMoved(true);\n rookPiece.setHasMoved(true);\n\n nextMoveColor = oppositeColor(nextMoveColor);\n turnNumber++;\n }", "protected void executeCommand() {\n // build the type string\n StringBuilder stateString = new StringBuilder();\n StringBuilder moveNamesString = new StringBuilder();\n StringBuilder basicPieceString = new StringBuilder();\n StringBuilder factionRingString = new StringBuilder();\n\n // start the state string\n stateString.append(\"emb2;Activate;2;;;2;;;2;;;;1;false;0;-24;,\");\n basicPieceString.append(\"emb2;;2;;;2;;;2;;;;;false;0;0;\");\n\n String moveImage;\n String move = newMoveList.get(0);\n String moveWithoutSpeed = move.substring(1);\n moveImage = dialHeadingImages.get(moveWithoutSpeed);\n\n String speed = move.substring(0,1);\n String moveCode = move.substring(1,2);\n String moveName = maneuverNames.get(moveCode);\n\n basicPieceString.append(\"D2e_\" + xwsShipName + \".png\");\n basicPieceString.append(\";;false;Front Plate;;;false;;1;1;true;;;\");\n\n moveNamesString.append(moveName).append(\" \").append(speed);\n // add in move names\n stateString.append(moveImage);\n stateString.append(\";empty,\"+moveNamesString);\n\n // finish the type string\n stateString.append(\";false;Chosen Move;;;false;;1;1;true;65,130\");\n Embellishment chosenMoveEmb = (Embellishment)Util.getEmbellishment(piece,\"Layer - Chosen Move\");\n Embellishment chosenSpeedEmb = (Embellishment)Util.getEmbellishment(piece, \"Layer - Chosen Speed\");\n Embellishment fullDialEmb = (Embellishment)Util.getEmbellishment(piece, \"Layer - Front Plate\");\n Embellishment ringEmb = (Embellishment)Util.getEmbellishment(piece, \"Layer - Faction Ring\");\n\n factionRingString.append(\"emb2;;2;;;2;;;2;;;;;false;0;0;DialSelect_\");\n factionRingString.append(faction);\n factionRingString.append(\".png;;false;Faction Ring;;;false;;1;1;true;;;\");\n chosenSpeedEmb.setValue(Integer.parseInt(speed)+1);\n\n String injectDialString = \"\";\n int count=0;\n for(String moveItem : newMoveList) {\n count++;\n injectDialString+= moveItem;\n if(count!=newMoveList.size()) injectDialString+=\",\";\n }\n piece.setProperty(\"dialstring\",injectDialString);\n piece.setProperty(\"shipID\", associatedShipID);\n\n // chosen move embellishment looks like: emb2;Activate;2;;;2;;;2;;;;1;false;0;-24;,mFW.png;empty,move;false;Chosen Move;;;false;;1;1;true;65,130;;\n // chosen speed embell looks like: emb2;;2;;;2;;;2;;;;1;false;0;24;kimb5.png,,kimb0.png,kimb1.png,kimb2.png,kimb3.png,kimb4.png;5,empty,0,1,2,3,4;false;Chosen Speed;;;false;;1;1;true;;;\n // basic piece face plate looks like: emb2;;2;;;2;;;2;;;;;false;0;0;D2e_arc170starfighter.png;;false;Front Plate;;;false;;1;1;true;;;\n // faction ring looks like: emb2;;2;;;2;;;2;;;;;false;0;-6;DialSelect_rebelalliance.png;;false;Faction Ring;;;false;;1;1;true;;;\n\n chosenMoveEmb.mySetType(stateString.toString());\n chosenMoveEmb.setValue(1);\n\n fullDialEmb.mySetType(basicPieceString.toString());\n ringEmb.mySetType(factionRingString.toString());\n }", "public String getCommands(String plateau, String location, String movement) {\r\n parsePlateau(plateau);\r\n parseLocation(location);\r\n move(movement);\r\n \r\n return report();\r\n }", "public int move_diagonally(Square[][] squares, int [] move, Boolean turn) {\n\n /* going down and right = f4 h2 [4,5,6,7] */\n if (move[2] > move[0] && move[3] > move[1]) {\n ////System.out.println(\"Down right\");\n int x = move[0];\n int y = move[1];\n x++;\n y++;\n while (x < move[2] && y < move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x++;\n y++;\n }\n }\n /* going down and left */\n else if (move[2] > move[0] && move[3] < move[1]){\n ////System.out.println(\"Down Left\");\n int x = move[0];\n int y = move[1];\n x++;\n y--;\n while (x < move[2] && y > move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x++;\n y--;\n }\n }\n /* going up and left */\n else if (move[2] < move[0] && move[3] < move[1]){\n ////System.out.println(\"Up Left\");\n int x = move[0];\n int y = move[1];\n x--;\n y--;\n while (x > move[2] && y > move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x--;\n y--;\n }\n }\n /* going up and right c1 f4 [7,2,4,5] */\n else if (move[2] < move[0] && move[3] > move[1]){\n ////System.out.println(\"Up right\");\n int x = move[0];\n int y = move[1];\n x--;\n y++;\n while (x > move[2] && y < move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x--;\n y++;\n }\n }\n return 0;\n }", "void movePiece() {\n\n }", "public abstract void removeMove(Move move, int indexOfMove, String label);", "public interface CombatPositioning {\n /**\n * Gets the tile the given unit should move to next\n * \n * @param u\n * @return the next tile\n */\n public Tile getNextTile(Unit u);\n\n /**\n * Allows us to prepare a log string that can be used later\n * \n * @return the log message\n */\n public String getLog();\n\n}", "public static Move parseMove(String move, PieceColor pieceColor, Board board) {\n try {\n LinkedList<String> moveStream = new LinkedList<>(Arrays.asList(move.split(\"\")));\n String first = moveStream.removeFirst();\n PieceType pieceType = PieceType.getPieceType(first);\n String cellCode;\n if (!PieceType.isPieceTypeCode(first)) {\n cellCode = first;\n } else {\n cellCode = moveStream.removeFirst();\n }\n cellCode += moveStream.removeFirst();\n Cell moveTo = board.getCell(cellCode);\n return new Move(pieceColor, pieceType, moveTo);\n } catch (NoSuchElementException nsee) {\n throw new IllegalArgumentException(\"Algebraic chess notation is invalid: \" + nsee.getMessage(), nsee);\n }\n }", "@Override\n public String visit(MoveStmt n) {\n String _ret = null;\n String r1 = this.reg[n.f1.f0.which];\n int which = n.f2.f0.which;\n if (which == 0) {\n /* 0 MOVE r1 HALLOCATE SimpleExp */\n this.save_a0v0(r1);\n n.f2.accept(this);\n Global.outputString += \"move $\" + r1 + \", $v0\\n\";\n this.load_a0v0(r1);\n } else {\n /* 1 MOVE r1 Operator Reg SimpleExp */\n /* 2 MOVE r1 SimpleExp */\n this.moveReg = r1;\n n.f2.accept(this);\n this.moveReg = null;\n }\n return _ret;\n }", "public abstract void move(Position position);", "@Override\n\tpublic void updatePosition()\n\t{\n\t\tif(!fired && !pathfinding)\n\t\t{\n\t\t\tif(x == destX && y == destY)\n\t\t\t{\n\t\t\t\tfired = true;\n\t\t\t\tvehicle.msgAnimationDestinationReached();\n\t\t\t\tcurrentDirection = MovementDirection.None;\n\t\t\t\t\n\t\t\t\tIntersection nextIntersection = city.getIntersection(next);\n\t\t\t\tIntersection cIntersection = city.getIntersection(current);\n\t\t\t\tif(cIntersection == null)\n\t\t\t\t{\n\t\t\t\t\tif(city.permissions[current.y][current.x].tryAcquire() || true)\n\t\t\t\t\t{\n\t\t\t\t\t\tcity.permissions[current.y][current.x].release();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif(nextIntersection == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(!cIntersection.acquireIntersection())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcIntersection.releaseAll();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcIntersection.releaseIntersection();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(Pathfinder.isCrossWalk(current,city.getWalkingMap(), city.getDrivingMap()))\n\t\t\t\t{\n\t\t\t\t\tList<Gui> guiList = city.crosswalkPermissions.get(current.y).get(current.x);\n\t\t\t\t\tsynchronized(guiList)\n\t\t\t\t\t{\n\t\t\t\t\t\twhile(guiList.contains(this))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tguiList.remove(this);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif(allowedToMove || drunk)\n\t\t\t{\n\t\t\t\tswitch(currentDirection)\n\t\t\t\t{\n\t\t\t\t\tcase Right:\n\t\t\t\t\t\tx++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Up:\n\t\t\t\t\t\ty--;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Down:\n\t\t\t\t\t\ty++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Left:\n\t\t\t\t\t\tx--;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(x % CityPanel.GRID_SIZE == 0 && y % CityPanel.GRID_SIZE == 0 && !moves.isEmpty())\n\t\t\t{\t\n\t\t\t\tif(allowedToMove || drunk)\n\t\t\t\t{\n\t\t\t\t\tcurrentDirection = moves.pop();\n\t\t\t\t\n\t\t\t\t\tIntersection nextIntersection = city.getIntersection(next);\n\t\t\t\t\tIntersection cIntersection = city.getIntersection(current);\n\t\t\t\t\t\n\t\t\t\t\tif(current != next)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(cIntersection == null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(city.permissions[current.y][current.x].tryAcquire() || true)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcity.permissions[current.y][current.x].release();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(nextIntersection == null)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif(!cIntersection.acquireIntersection())\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcIntersection.releaseAll();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcIntersection.releaseIntersection();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t//**************************ADDED**************************//\n\t\t\t\t\t\tif(Pathfinder.isCrossWalk(current,city.getWalkingMap(), city.getDrivingMap()))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tList<Gui> guiList = city.crosswalkPermissions.get(current.y).get(current.x);\n\t\t\t\t\t\t\tsynchronized(guiList)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\twhile(guiList.contains(this))\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tguiList.remove(this);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t//**************************END ADDED**************************//\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcurrent = next;\n\t\t\t\t\t\n\t\t\t\t\tswitch(currentDirection)\n\t\t\t\t\t{\n\t\t\t\t\tcase Down:next = new Point(current.x,current.y + 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Left:next = new Point(current.x - 1,current.y);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Right:next = new Point(current.x + 1,current.y);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase Up:next = new Point(current.x,current.y - 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:next = current;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t\n\n\t\t\t\tIntersection nextIntersection = city.getIntersection(next);\n\t\t\t\tIntersection cIntersection = city.getIntersection(current);\n\t\t\t\t\n\t\t\t\tif(nextIntersection == null)\n\t\t\t\t{\n\t\t\t\t\tif(city.permissions[next.y][next.x].tryAcquire())\n\t\t\t\t\t{\n\t\t\t\t\t\tallowedToMove = true;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tallowedToMove = false;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif(cIntersection == null)\n\t\t\t\t\t{\n\t\t\t\t\t\t//**************************ADDED**************************//\n\t\t\t\t\t\tList<Gui> guiList = city.crosswalkPermissions.get(next.y).get(next.x);\n\t\t\t\t\t\tsynchronized(guiList)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(Pathfinder.isCrossWalk(next, city.getWalkingMap(), city.getDrivingMap()))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfor(Gui g : guiList)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tif(g instanceof PassengerGui)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tallowedToMove = false;\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif(nextIntersection.acquireIntersection())\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tnextIntersection.acquireAll();\n\t\t\t\t\t\t\t\t\tallowedToMove = true;\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tallowedToMove = false;\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tguiList.add(this);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t//**************************END ADDED**************************//\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tallowedToMove = true;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(!allowedToMove && drunk)\n\t\t{\n\t\t\tcity.addGui(new ExplosionGui(x,y));\n\t\t\tSystem.out.println(\"DESTROYING\");\n\t\t\tcity.removeGui(this);\n\t\t\tvehicle.stopThread();\n\t\t\tsetPresent(false);\n\t\t\t\n\t\t\tIntersection nextIntersection = city.getIntersection(next);\n\t\t\tIntersection cIntersection = city.getIntersection(current);\n\t\t\t\n\t\t\tif(cIntersection == null)\n\t\t\t{\n\t\t\t\tif(city.permissions[current.y][current.x].tryAcquire() || true)\n\t\t\t\t{\n\t\t\t\t\tcity.permissions[current.y][current.x].release();\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(nextIntersection == null)\n\t\t\t\t{\n\t\t\t\t\tif(!cIntersection.acquireIntersection())\n\t\t\t\t\t{\n\t\t\t\t\t\tcIntersection.releaseAll();\n\t\t\t\t\t}\n\t\t\t\t\tcIntersection.releaseIntersection();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "@Override\n public Collection<Move> calculateLegalMoves(Board board) {\n System.out.println(\"INSIDE Knight: calculateLegalMoves()\");\n System.out.println(\"------------------------------>\\n\");\n\n //ArrayList of moves used to store all possible legal moves.\n final List<Move> legalMoves = new ArrayList<>();\n\n //Iterate the constant class array of piece offsets.\n for(final int currentCandidate : CANDIDATE_MOVE_COORDS){\n //Add the current coordinate of the piece to each offset, storing as a destination coordinate.\n final int candidateDestinationCoord = this.piecePosition + currentCandidate;\n\n //If the destination coordinate is within legal board bounds (between 0 and 64)...\n if(BoardUtils.isValidCoord(candidateDestinationCoord)){\n //Check to see if the piece is in the first column and its destination would move it outside the board.\n if(isfirstColumnExclusion(this.piecePosition, currentCandidate) ||\n isSecondColumnExclusion(this.piecePosition, currentCandidate) ||\n isSeventhColumnExclusion(this.piecePosition, currentCandidate) ||\n isEighthColumnExclusion(this.piecePosition, currentCandidate)){\n continue; //Continue the loop if any of these methods return true\n }\n\n //Store the tile of the destination coordinate.\n final Tile candidateDestinationTile = board.getTile(candidateDestinationCoord);\n\n //If the tile is not marked as occupied by the Tile class...\n if(!candidateDestinationTile.isOccupied()){\n //Add the move to the list of legal moves as a non-attack move.\n legalMoves.add(new MajorMove(board, this, candidateDestinationCoord));\n }\n else{\n //Otherwise, get the type and alliance of the piece at the destination.\n final Piece pieceAtDestination = candidateDestinationTile.getPiece();\n final Alliance pieceAlliance = pieceAtDestination.getPieceAlliance();\n\n //If the piece at the occupied tile's alliance differs...\n if(this.pieceAlliance != pieceAlliance){\n //Add the move to the list of legal moves as an attack move.\n legalMoves.add(new MajorAttackMove(board, this, candidateDestinationCoord, pieceAtDestination));\n }\n }\n }\n }\n\n //Return the list of legal moves.\n return legalMoves;\n }", "private void calculateLocation()\r\n\t{\r\n\t\tdouble leftAngleSpeed \t= this.angleMeasurementLeft.getAngleSum() / ((double)this.angleMeasurementLeft.getDeltaT()/1000); //degree/seconds\r\n\t\tdouble rightAngleSpeed \t= this.angleMeasurementRight.getAngleSum() / ((double)this.angleMeasurementRight.getDeltaT()/1000); //degree/seconds\r\n\r\n\t\tdouble vLeft\t= (leftAngleSpeed * Math.PI * LEFT_WHEEL_RADIUS ) / 180 ; //velocity of left wheel in m/s\r\n\t\tdouble vRight\t= (rightAngleSpeed * Math.PI * RIGHT_WHEEL_RADIUS) / 180 ; //velocity of right wheel in m/s\t\t\r\n\t\tdouble w \t\t= (vRight - vLeft) / WHEEL_DISTANCE; //angular velocity of robot in rad/s\r\n\t\t\r\n\t\tDouble R \t= new Double(( WHEEL_DISTANCE / 2 ) * ( (vLeft + vRight) / (vRight - vLeft) ));\t\t\t\t\t\t\t\t\r\n\t\t\r\n\t\tdouble ICCx = 0;\r\n\t\tdouble ICCy = 0;\r\n\r\n\t\tdouble W_xResult \t\t= 0;\r\n\t\tdouble W_yResult \t\t= 0;\r\n\t\tdouble W_angleResult \t= 0;\r\n\t\t\r\n\t\tdouble E_xResult \t\t= 0;\r\n\t\tdouble E_yResult \t\t= 0;\r\n\t\tdouble E_angleResult \t= 0;\r\n\t\t\r\n\t\t//short axe = 0;\r\n\t\t\r\n\t\tdouble deltaT = ((double)this.angleMeasurementLeft.getDeltaT())/1000;\r\n\t\t\r\n\t\t// Odometry calculations\r\n\t\tif (R.isNaN()) \t\t\t\t//robot don't move\r\n\t\t{\r\n\t\t\tW_xResult\t\t= this.pose.getX();\r\n\t\t\tW_yResult\t\t= this.pose.getY();\r\n\t\t\tW_angleResult \t= this.pose.getHeading();\r\n\t\t} \r\n\t\telse if (R.isInfinite()) \t//robot moves straight forward/backward, vLeft==vRight\r\n\t\t{ \r\n\t\t\tW_xResult\t\t= this.pose.getX() + vLeft * Math.cos(this.pose.getHeading()) * deltaT;\r\n\t\t\tW_yResult\t\t= this.pose.getY() + vLeft * Math.sin(this.pose.getHeading()) * deltaT;\r\n\t\t\tW_angleResult \t= this.pose.getHeading();\r\n\t\t} \r\n\t\telse \r\n\t\t{\t\t\t\r\n\t\t\tICCx = this.pose.getX() - R.doubleValue() * Math.sin(this.pose.getHeading());\r\n\t\t\tICCy = this.pose.getY() + R.doubleValue() * Math.cos(this.pose.getHeading());\r\n\t\t\r\n\t\t\tW_xResult \t\t= Math.cos(w * deltaT) * (this.pose.getX()-ICCx) - Math.sin(w * deltaT) * (this.pose.getY() - ICCy) + ICCx;\r\n\t\t\tW_yResult \t\t= Math.sin(w * deltaT) * (this.pose.getX()-ICCx) + Math.cos(w * deltaT) * (this.pose.getY() - ICCy) + ICCy;\r\n\t\t\tW_angleResult \t= this.pose.getHeading() + w * deltaT;\r\n\t\t}\r\n\t\t\r\n\t\tthis.pose.setLocation((float)W_xResult, (float)W_yResult);\r\n\t\tthis.pose.setHeading((float)W_angleResult);\r\n\t\t\r\n\t\t// Conversion to grads\r\n\t\tW_angleResult = W_angleResult/Math.PI*180;\r\n\t\t\r\n\t\t// Get the heading axe\r\n\t\t//axe = getHeadingAxe();\r\n\t\tgetHeadingAxe();\r\n\t\t\r\n\t\t// Verify the coordinates and the heading angle\r\n\t\tif (Po_Corn == 1)\r\n\t\t{\r\n\t\t\tswitch (Po_CORNER_ID)\r\n\t\t\t{\r\n\t\t\t\tcase 0:\r\n\t\t\t\t\tE_xResult = 0;\r\n\t\t\t\t\tE_yResult = 0;\r\n\t\t\t\t\tPo_ExpAng = 0;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 1:\r\n\t\t\t\t\tE_xResult = 1.8;\r\n\t\t\t\t\tE_yResult = 0.11;\r\n\t\t\t\t\tPo_ExpAng = 90;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 2:\r\n\t\t\t\t\tE_xResult = 1.6;\r\n\t\t\t\t\tE_yResult = 0.6;\r\n\t\t\t\t\tPo_ExpAng = 180;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 3:\r\n\t\t\t\t\tE_xResult = 1.5;\r\n\t\t\t\t\tE_yResult = 0.45;\r\n\t\t\t\t\tPo_ExpAng = 270;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 4:\r\n\t\t\t\t\tE_xResult = 1.5;\r\n\t\t\t\t\tE_yResult = 0.3;\r\n\t\t\t\t\tPo_ExpAng = 180;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 5:\r\n\t\t\t\t\tE_xResult = 0.3;\r\n\t\t\t\t\tE_yResult = 0.3;\r\n\t\t\t\t\tPo_ExpAng = 90;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 6:\r\n\t\t\t\t\tE_xResult = 0.3;\r\n\t\t\t\t\tE_yResult = 0.6;\r\n\t\t\t\t\tPo_ExpAng = 180;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 7:\r\n\t\t\t\t\tE_xResult = 0;\r\n\t\t\t\t\tE_yResult = 0.6;\r\n\t\t\t\t\tPo_ExpAng = 270;\r\n\t\t\t\t\tbreak;\t\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tE_angleResult = W_angleResult;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tint block = 0;\r\n\t\t\t// white = 0, black = 2, grey = 1\r\n\t\t\tif ((lineSensorLeft == 0) && (lineSensorRight == 0) && (block == 0)) \t// Robot moves on the black line\r\n\t\t\t{\r\n\t\t\t\tswitch (Po_CORNER_ID)\t\t\t\t\t\t\t\t// Even numbers - x, Odd numbers - y\r\n\t\t\t\t{\r\n\t\t\t\tcase 0: \r\n\t\t\t\t\tif (this.pose.getX() < 1.6)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tE_angleResult = Po_ExpAng;\r\n\t\t\t\t\t\tE_yResult = 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tE_angleResult = W_angleResult;\r\n\t\t\t\t\t\tE_yResult = W_yResult;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tE_xResult = W_xResult;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t\r\n\t\t\t\tcase 1: \r\n\t\t\t\t\tif (this.pose.getY() < 0.4)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tE_angleResult = Po_ExpAng;\r\n\t\t\t\t\t\tE_xResult = 1.8;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tE_angleResult = W_angleResult; \r\n\t\t\t\t\t\tE_xResult = W_xResult;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tE_yResult = W_yResult;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t\r\n\t\t\t\tcase 2:\r\n\t\t\t\t\tif (this.pose.getX() > 1.65)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tE_angleResult = Po_ExpAng;\r\n\t\t\t\t\t\tE_yResult = 0.6;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tE_angleResult = W_angleResult;\r\n\t\t\t\t\t\tE_yResult = W_yResult;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tE_xResult = W_xResult;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t\r\n\t\t\t\tcase 3:\r\n\t\t\t\t\tif (this.pose.getY() > 0.4)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tE_angleResult = Po_ExpAng;\r\n\t\t\t\t\t\tE_xResult = 1.5; \r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tE_angleResult = W_angleResult; \r\n\t\t\t\t\t\tE_xResult = W_xResult;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tE_yResult = W_yResult;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t\r\n\t\t\t\tcase 4: \r\n\t\t\t\t\tif (this.pose.getX() > 0.4)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tE_angleResult = Po_ExpAng;\r\n\t\t\t\t\t\tE_yResult = 0.3;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tE_angleResult = W_angleResult;\r\n\t\t\t\t\t\tE_yResult = W_yResult;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tE_xResult = W_xResult;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t\r\n\t\t\t\tcase 5:\r\n\t\t\t\t\tif (this.pose.getY() < 0.5)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tE_angleResult = Po_ExpAng;\r\n\t\t\t\t\t\tE_xResult = 0.3;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tE_angleResult = W_angleResult; \r\n\t\t\t\t\t\tE_xResult = W_xResult;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tE_yResult = W_yResult;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t\r\n\t\t\t\tcase 6: \r\n\t\t\t\t\tif (this.pose.getX() > 0.1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tE_angleResult = Po_ExpAng;\r\n\t\t\t\t\t\tE_yResult = 0.6;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tE_angleResult = W_angleResult;\r\n\t\t\t\t\t\tE_yResult = W_yResult;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tE_xResult = W_xResult;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t\r\n\t\t\t\tcase 7:\r\n\t\t\t\t\tif (this.pose.getY() > 0.1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tE_angleResult = Po_ExpAng;\r\n\t\t\t\t\t\tE_xResult = 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tE_angleResult = W_angleResult; \r\n\t\t\t\t\t\tE_xResult = W_xResult;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tE_yResult = W_yResult;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t\r\n\t\t\t\tdefault: \r\n\t\t\t\t\tE_angleResult = W_angleResult;\r\n\t\t\t\t\tE_yResult = W_yResult;\r\n\t\t\t\t\tE_xResult = W_xResult;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse if(((lineSensorLeft == 0) && (lineSensorRight == 2)) || ((lineSensorLeft == 2) && (lineSensorRight == 0)))\r\n\t\t\t{\r\n\t\t\t\tE_xResult = W_xResult;\r\n\t\t\t\tE_yResult = W_yResult;\r\n\t\t\t\t\r\n\t \tif (W_angleResult >= TRSH_W)\r\n\t \t{\r\n\t \t\tE_angleResult = TRSH_W;\r\n\t \t}\r\n\t \telse if (W_angleResult >= (360 - TRSH_W))\r\n\t \t{\r\n\t \t\tE_angleResult = 360 - TRSH_W;\r\n\t \t}\r\n\t \telse\r\n\t \t{\r\n\t \t\tE_angleResult = W_angleResult;\r\n\t \t}\r\n\t \t\r\n\t \t// test\r\n\t \tE_angleResult = W_angleResult;\r\n\t\t\t}\r\n\t\t\telse if(((lineSensorLeft == 0) && (lineSensorRight == 1)) || ((lineSensorLeft == 1) && (lineSensorRight == 0)))\r\n\t\t\t{\r\n\t\t\t\tE_xResult = W_xResult;\r\n\t\t\t\tE_yResult = W_yResult;\r\n\t\t\t\t\r\n\t \tif (W_angleResult >= TRSH_G)\r\n\t \t{\r\n\t \t\tE_angleResult = TRSH_G;\r\n\t \t}\r\n\t \telse if (W_angleResult >= (360 - TRSH_G))\r\n\t \t{\r\n\t \t\tE_angleResult = 360 - TRSH_G;\r\n\t \t}\r\n\t \telse\r\n\t \t{\r\n\t \t\tE_angleResult = W_angleResult;\r\n\t \t}\r\n\t \t\r\n\t \t// test\r\n\t \tE_angleResult = W_angleResult;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tE_xResult = W_xResult;\r\n\t\t\t\tE_yResult = W_yResult;\r\n\t\t\t\tE_angleResult = W_angleResult;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tLCD.drawString(\"AngRs: \" + (E_angleResult), 0, 7);\r\n\t\t\r\n\t\t// Conversion to rads\r\n\t\tW_angleResult = W_angleResult*Math.PI/180;\r\n\t\tE_angleResult = E_angleResult*Math.PI/180;\r\n\t\t\r\n\t\tif ((Po_CORNER_ID == 3) && (100*this.pose.getY() < 45))\r\n\t\t{\r\n\t\t\tE_angleResult = 3*Math.PI/180;;\r\n\t\t}\r\n\t\t\r\n\t\tthis.pose.setLocation((float)E_xResult, (float)E_yResult);\r\n\t\tthis.pose.setHeading((float)E_angleResult);\r\n\t\t\r\n\t\t/*\r\n\t\t// Integration deviation correction\r\n\t\tthis.pose.setLocation((float)(W_xResult), (float)(W_yResult + (0.01*22.4)/175));\r\n\t\tthis.pose.setHeading((float)((W_angleResult + 14/175)*Math.PI/180));\r\n\t\t*/\r\n\t}", "public interface PieceLogic {\n\n\t/**\n\t * Return the unique set of possible moves made possible by a\n\t * piece associated with the given {@link PieceLogic} at the \n\t * passed in {@link Location}.\n\t * <p />\n\t * In all cases we assume the underlying model actually has a piece\n\t * associated with the given logic at the passed in location\n\t * (this is not something we assert at runtime)\n\t * \n\t * @param model\n\t * @param location\n\t * @return\n\t */\n\tSet<ChessMove> getPossibleMoves(ChessModel model, Location location);\n\t\n\t/**\n\t * Return the {@link Piece} associated with the underlying piece\n\t * logic implementation\n\t * \n\t * @return\n\t */\n\tPiece getPiece();\n\t\n}", "@Override\n protected String moveSelectionAlgorithm(int pieceID) {\n\n //If there is a winning move, take it\n\n\n // [This is where you should insert the required code for Assignment 1.]\n \n boolean skip = false;\n int row,col=0;\n for (row = 0; row < this.quartoBoard.getNumberOfRows(); row++) {\n for (col = 0; col < this.quartoBoard.getNumberOfColumns(); col++) {\n if (!this.quartoBoard.isSpaceTaken(row, col)) {\n QuartoBoard copyBoard = new QuartoBoard(this.quartoBoard);\n copyBoard.insertPieceOnBoard(row, col, pieceID);\n if (copyBoard.checkRow(row) || copyBoard.checkColumn(col) || copyBoard.checkDiagonals()) {\n skip = true;\n break;\n }\n }\n }\n if (skip) {\n break;\n }\n }\n\tSystem.out.print(\"ROW , COLUMNS = \"+ row+\" , \"+ col);\n\t\n\tif(skip){\n return row +\",\"+ col;}\n\n\n\n // If no winning move is found in the above code, then return a random (unoccupied) square\n\n int[] move = new int[2];\n QuartoBoard copyBoard = new QuartoBoard(this.quartoBoard);\n move = copyBoard.chooseRandomPositionNotPlayed(100);\n\n return move[0] + \",\" + move[1];\n }", "public static Move getMoveFromProposition(Proposition p){\r\n \treturn new Move(p.getName().get(1));\r\n }", "private void checkForConversions() {\n\n for(int r=0; r<COLUMN_ROW_COUNT; r++) {\n for(int c=0; c<COLUMN_ROW_COUNT; c++) {\n Piece p = cells[r][c];\n if(p == null) continue;\n\n if (p.getType().equals(Type.GUARD)) {\n int surroundingDragons = 0;\n Piece piece;\n\n if ((c - 1) >= 0) {\n piece = cells[r][c - 1];\n if (piece != null && piece.getType().equals(Type.DRAGON)) surroundingDragons++;\n }\n if ((r- 1) >= 0) {\n piece = cells[r- 1][c];\n if (piece != null && piece.getType().equals(Type.DRAGON)) surroundingDragons++;\n }\n if ((c + 1) < COLUMN_ROW_COUNT) {\n piece = cells[r][c + 1];\n if (piece != null && piece.getType().equals(Type.DRAGON)) surroundingDragons++;\n }\n if ((r+ 1) < COLUMN_ROW_COUNT) {\n piece = cells[r+ 1][c];\n if (piece != null && piece.getType().equals(Type.DRAGON)) surroundingDragons++;\n }\n\n if (surroundingDragons >= 3) {\n cells[r][c].changeType(Type.DRAGON);\n }\n }\n\n /*\n if(p.getType().equals(Type.KING)) {\n int blockedDirections = 0;\n Piece piece;\n\n if ((c - 1) >= 0) {\n piece = cells[r][c - 1];\n if (piece != null) {\n if (piece.getType().equals(Type.DRAGON)) {\n blockedDirections++;\n } else if (piece.getType().equals(Type.GUARD) && (c - 2) >= COLUMN_ROW_COUNT && cells[r][c-2] != null) {\n blockedDirections++;\n }\n }\n } else blockedDirections++;\n\n if ((r- 1) >= 0) {\n piece = cells[r- 1][c];\n if (piece != null) {\n if (piece.getType().equals(Type.DRAGON)) {\n blockedDirections++;\n } else if (piece.getType().equals(Type.GUARD) && (r - 2) >= COLUMN_ROW_COUNT && cells[r-2][c] != null) {\n blockedDirections++;\n }\n }\n } else blockedDirections++;\n\n if ((c + 1) < COLUMN_ROW_COUNT) {\n piece = cells[r][c+1];\n if (piece != null) {\n if (piece.getType().equals(Type.DRAGON)) {\n blockedDirections++;\n } else if (piece.getType().equals(Type.GUARD) && (c + 2) < COLUMN_ROW_COUNT && cells[r][c+2] != null) {\n blockedDirections++;\n }\n }\n } else blockedDirections++;\n\n if ((r+ 1) < COLUMN_ROW_COUNT) {\n piece = cells[r+1][c];\n if (piece != null) {\n if (piece.getType().equals(Type.DRAGON)) {\n blockedDirections++;\n } else if (piece.getType().equals(Type.GUARD) && (r + 2) < COLUMN_ROW_COUNT && cells[r+2][c] != null) {\n blockedDirections++;\n }\n }\n } else blockedDirections++;\n\n if(blockedDirections == 4) {\n //gameOver = true;\n }\n }*/\n }\n }\n }", "public void move(FightCell cell);", "public synchronized String computeMove() {\n if (game == null) {\n System.err.println(\"CODE ERROR: AI is not attached to a game.\");\n return \"0,0\";\n }\n\n char[] board = (char[]) game.getStateAsObject();\n\n //Choose a smart move if that AI is set to \"Smart\" or if the random value equals 2\n if (aiType == 1) {\n if(useHeat && ((int) (Math.random() * heat)) == 2){\n return \"\" + getRandomMove(board);\n }\n else{\n return \"\" + getSmartMove(board);\n }\n } else {\n return \"\" + getRandomMove(board);\n }\n }", "@Override\r\n\tpublic String moveDown() {\n\t\tif((0<=x && x<=50) && (0<y && y<=10) && (0<=z && z<=50))\r\n\t\t{\r\n\t\t\ty--;\r\n\t\t}\r\n\t\telse if((0<=x && x<=50) && (40<y && y<=50) && (0<=z && z<=50))\r\n\t\t{\r\n\t\t\ty--;\r\n\t\t}\r\n\t\telse if((0<=x && x<=50) && (0<y && y<=50) && (0<=z && z<=10))\r\n\t\t{\r\n\t\t\ty--;\r\n\t\t}\r\n\t\telse if((0<=x && x<=10) && (0<y && y<=50) && (0<=z && z<=50))\r\n\t\t{\r\n\t\t\ty--;\r\n\t\t}\r\n\t\telse if((0<=x && x<=50) && (0<y && y<=50) && (40<=z && z<=50))\r\n\t\t{\r\n\t\t\ty--;\r\n\t\t}\r\n\t\telse if((40<=x && x<=50) && (0<y && y<=50) && (0<=z && z<=50))\r\n\t\t{\r\n\t\t\ty--;\r\n\t\t}\r\n\t\treturn getFormatedCoordinates();\r\n\t}", "Move getMove() {\n try {\n boolean playing0 = _playing;\n while (_playing == playing0) {\n prompt();\n\n String line = _input.readLine();\n if (line == null) {\n quit();\n }\n line = line.trim();\n if (!processCommand(line)) {\n Move move = Move.create(line, _board);\n if (move == null) {\n error(\"invalid move: %s%n\", line);\n } else if (!_playing) {\n error(\"game not started\");\n } else if (!_board.isLegal(move)) {\n error(\"illegal move: %s%n\", line);\n } else {\n return move;\n }\n }\n }\n } catch (IOException excp) {\n error(1, \"unexpected I/O error on input\");\n }\n return null;\n }", "@Override\r\n public void makeLogicMove() {\r\n\r\n this.printThoughts();\r\n this.printMessages();\r\n \r\n // If dead, don't make a move //\r\n if (this.isDead()) {\r\n return;\r\n } \r\n \r\n if (this.getVerbose()) {\r\n System.err.println(\"Making logic move for aibotscorer - \" + this.getMoves().size());\r\n }\r\n \r\n final AIBotScoreModel scores = scoreAllDirections();\r\n if (this.getVerbose()) {\r\n System.err.println(scores);\r\n }\r\n if (this.getMoves().size() <= 3) {\r\n super.makeLogicMove();\r\n return;\r\n }\r\n \r\n if (this.getMoves().size() == 26) {\r\n this.addMessages(\"-5000-AI: using default move, on 30 clause\");\r\n super.makeLogicMove();\r\n return;\r\n }\r\n \r\n final int randomMoveFlag = random.nextInt(16);\r\n if (randomMoveFlag == 1) {\r\n this.addMessages(\"-4000-AI: using default move, random case\");\r\n super.makeLogicMove();\r\n return;\r\n }\r\n \r\n final Move lastMove = this.getLastMoveNull();\r\n if (lastMove == null) {\r\n this.addMessages(\"-3000-AI: using default move, last move null\");\r\n // Revert back to the default move\r\n super.makeLogicMove();\r\n return;\r\n }\r\n \r\n final Move north = lastMove.decy();\r\n final Move south = lastMove.incy();\r\n final Move east = lastMove.incx();\r\n final Move west = lastMove.decx();\r\n \r\n final LinkedHashMap<Double, Move> map = new LinkedHashMap<Double, Move>();\r\n map.put(new Double(scores.getScoreNorth()), north);\r\n map.put(new Double(scores.getScoreSouth()), south);\r\n map.put(new Double(scores.getScoreEast()), east);\r\n map.put(new Double(scores.getScoreWest()), west);\r\n final LinkedHashMap<Double, Move> scoreMap = BotUtilityMap.sortMapByKey(map);\r\n \r\n if (this.getVerbose()) {\r\n System.err.println(scoreMap);\r\n }\r\n \r\n final boolean validScoreCheck = this.makeLogicMoveAIValidateScores(scoreMap);\r\n if (!validScoreCheck) {\r\n // If on the valid case, the move has already been made \r\n super.makeLogicMove();\r\n return;\r\n } // End of if //\r\n }", "public abstract String whichToMove(boolean[] available, String lastMove, int whoseTurn, Scanner scanner);", "@Override\n public DirType getMove(GameState state) {\n if (print) System.out.println(\"\\n\\n\");\n this.gb.update(state); // Must be done every turn\n this.findEnemySnake(); // Update Enemy Snake's head Location\n this.markDangerTiles(); // Mark tiles the Enemy Snake can reach and filled\n if (print) this.gb.printBoard();\n if (print) System.out.println(\"DIVEBOMB ENTER -> Us_X: \" + this.us_head_x + \", Us_Y: \" + this.us_head_y + \" -> \" + this.us_num);\n Tile target = this.diveBomb();\n if (print) System.out.print(\"DIVEBOMB EXIT -> Target_X: \" + target.getX() + \" Target_Y: \" + target.getY());\n DirType retVal = getDir(target);\n if (print) System.out.println(\" Dir: \" + retVal);\n\n\n if (this.us_num == 0) {\n System.out.println(\"\\n\\n\\n\");\n GameBoard gb= new GameBoard(state, 1,0);\n gb.update(state);\n float val = USuckUnless.grade(state, this.us_num, DirType.South);\n System.out.println(val);\n this.gb.printBoard();\n }\n return retVal;\n }", "public static boolean validMove(String move, Person p, Board building )\n {\n Room[][] map = building.getMap();\n move = move.toLowerCase().trim();\n switch (move) {\n case \"n\":\n if (p.getxLoc() > 0)\n {\n map[p.getxLoc()][p.getyLoc()].leaveRoom(p);\n System.out.println(\"You are in the \"+map[p.getxLoc()-1][p.getyLoc()].getName());\n map[p.getxLoc()-1][p.getyLoc()].enterRoom(p,building);\n return true;\n }\n else\n {\n return false;\n }\n case \"e\":\n if (p.getyLoc()< map[p.getyLoc()].length -1)\n {\n map[p.getxLoc()][p.getyLoc()].leaveRoom(p);\n System.out.println(\"You are in the \"+map[p.getxLoc()][p.getyLoc() + 1].getName());\n map[p.getxLoc()][p.getyLoc() + 1].enterRoom(p, building);\n return true;\n }\n else\n {\n return false;\n }\n\n case \"s\":\n if (p.getxLoc() < map.length - 1)\n {\n map[p.getxLoc()][p.getyLoc()].leaveRoom(p);\n System.out.println(\"You are in the \"+map[p.getxLoc()+1][p.getyLoc()].getName());\n map[p.getxLoc()+1][p.getyLoc()].enterRoom(p, building);\n return true;\n }\n else\n {\n return false;\n }\n\n case \"w\":\n if (p.getyLoc() > 0)\n {\n map[p.getxLoc()][p.getyLoc()].leaveRoom(p);\n System.out.println(\"You are in the \"+map[p.getxLoc()][p.getyLoc()-1].getName());\n map[p.getxLoc()][p.getyLoc()-1].enterRoom(p, building);\n return true;\n }\n else\n {\n return false;\n }\n default:\n break;\n\n }\n return true;\n }", "@Override\n\tpublic Direction getMove() {\n if (ticks < MAX_TICKS_PER_ROUND - 100) {\n Direction[] dirs = Direction.values();\n return dirs[random.nextInt(dirs.length)];\n } else {\n // Move towards boat\n int deltaX = 0;\n int deltaY = 0;\n if (currentLocation.getX() < 0)\n deltaX = 1;\n else if (currentLocation.getX() > 0)\n deltaX = -1;\n\n if (currentLocation.getY() < 0)\n deltaY = 1;\n else if (currentLocation.getY() > 0)\n deltaY = -1;\n\n if (deltaX > 0 && deltaY == 0) {\n return Direction.E;\n } else if (deltaX > 0 && deltaY > 0) {\n return Direction.NE;\n } else if (deltaX > 0 && deltaY < 0) {\n return Direction.SE;\n } else if (deltaX == 0 && deltaY == 0) {\n return Direction.STAYPUT;\n } else if (deltaX == 0 && deltaY < 0) {\n return Direction.N;\n } else if (deltaX == 0 && deltaY > 0) {\n return Direction.S;\n } else if (deltaX < 0 && deltaY == 0) {\n return Direction.W;\n } else if (deltaX < 0 && deltaY > 0) {\n return Direction.NW;\n } else if (deltaX < 0 && deltaY < 0) {\n return Direction.NE;\n } else {\n throw new RuntimeException(\"I HAVE NO IDEA\");\n }\n }\n\t}", "private void HandleOnMoveStart(Board board, Piece turn){}", "private void parse(String position) throws Exception {\r\n\t \r\n\t StringTokenizer tokens = new StringTokenizer(position);\r\n\t if(tokens.hasMoreTokens()){\r\n\t \r\n\t try{\r\n\t\t x = Integer.parseInt(tokens.nextToken());\r\n\t\t y = Integer.parseInt(tokens.nextToken());\r\n\t }catch(NumberFormatException ne){\r\n\t throw new Exception(\"Invalid number!!\");\r\n\t }\r\n\t direction = tokens.nextToken().getBytes()[0];\r\n\t }\r\n\t if(!verifyBounds()){\r\n\t throw new Exception(\"Invalid inital position!!!\");\r\n\t }\r\n\t}", "public CopyMoveLinesOperation(String op, boolean move) {\n\t\t// Find the end of the operation -- first non-alpha and non-whitespace\n\t // character.\n\t assert op.length() >= 1;\n\t\tint addrPos;\n\t\tfor (addrPos = 1; addrPos < op.length(); ++addrPos) {\n\t\t final char ch = op.charAt(addrPos);\n\t\t if (!Character.isLetter(ch) && !Character.isWhitespace(ch)) {\n\t\t break;\n\t\t }\n\t\t}\n\t\t//chop off the operation and an optional space, leaving the definition\n\t\tif (addrPos < op.length()) {\n\t\t this.address = op.substring(addrPos).trim();\n\t\t}\n\t\tthis.move = move;\n\t}", "static public TmMove from(String represention) throws InvalidMovementRepresentationException {\n\t\tswitch (represention) {\n\t\tcase \"S\":\n\t\t\treturn TmMove.STOP;\n\t\tcase \"L\":\n\t\t\treturn TmMove.LEFT;\n\t\tcase \"R\":\n\t\t\treturn TmMove.RIGHT;\n\n\t\tdefault:\n\t\t\tthrow new InvalidMovementRepresentationException(represention);\n\t\t}\n\t}", "public Direction moveClyde(Ghost g);", "private String makeAIMove() {\n switch (level) {\n case 1:\n return easyMove();\n case 2:\n return mediumMove();\n case 3:\n return hardMove();\n default:\n //unreachable statement\n return null;\n }\n }", "public void movePiece(Location a, Location b)\n {\n Square s1 = getSquare(a);\n Square s2 = getSquare(b);\n Piece p = s1.getPiece();\n if (p==null)\n return;\n int moveType = canMoveTo(p,b);\n boolean taking = getPiece(b)!=null;\n boolean fiftyMoveBreak = getPiece(b)!=null||p.getType()==Type.PAWN;\n s2.setPiece(s1.removePiece());\n p.setHasMoved(true);\n if (p.getType()==Type.PAWN)\n {\n if (mainBoard&&((p.white()&&getLocation(p).getRow()==0)\n || !p.white()&&getLocation(p).getRow()==7))\n promotePawn(p);\n else if (moveType==EN_PASSANT)\n {\n int row = a.getRow();\n int col = b.getCol();\n removePiece(new Location(row,col));\n taking = true;\n }\n }\n else if (moveType==KINGSIDE_CASTLING||moveType==QUEENSIDE_CASTLING)\n {\n Location rookLoc;\n Location rookDest;\n if (moveType==KINGSIDE_CASTLING)\n {\n rookLoc = b.farther(Direction.EAST);\n rookDest = b.farther(Direction.WEST);\n }\n else\n {\n rookLoc = new Location(b.getRow(),b.getCol()-2);\n rookDest = b.farther(Direction.EAST);\n }\n //movePiece(getLocation(rook),rookDest);\n getSquare(rookDest).setPiece(removePiece(rookLoc)); //moves the rook\n }\n if (mainBoard)\n {\n turn++;\n if (fiftyMoveBreak)\n fiftyMove= 0;\n else fiftyMove++;\n }\n for (Piece piece: getPieces())\n piece.setHasJustMoved(false);\n p.setHasJustMoved(true);\n if (mainBoard)\n {\n positions.add(toString());\n \n //this is all for the notation on the side\n notateMove(p,b,moveType,taking);\n /*JTable not = frame.getNotation();\n DefaultTableModel d = (DefaultTableModel)not.getModel();\n String notation;\n PieceColor color = p.getColor();\n if (color==PieceColor.WHITE)\n notation = turn/2+1+\". \"; //the turn number first, on the left\n else notation = \"\";\n if (moveType==QUEENSIDE_CASTLING)\n notation += \"0-0-0\";\n else if (moveType==KINGSIDE_CASTLING)\n notation += \"0-0\";\n else //normal move\n {\n if (p.getType()!=Type.PAWN)\n notation+=p.getType().toNotation(); //the type of piece (K,N,R,etc)\n if (taking)\n notation+=\"x\"; //this is if the move involves taking\n notation+=Location.LocToNot(b);\n }\n if (checkmate(colorGoing())) //notates # for checkmate\n notation+=\"#\";\n else if (inCheck(colorGoing())) //notates + for check\n notation+=\"+\";\n \n if (color==PieceColor.WHITE)\n d.addRow(new Object[]{notation,\"\"});\n else \n d.setValueAt(notation, (turn-1)/2, 1);*/\n }\n }", "abstract public Tuple move(Tuple c, char [][] forest);", "public abstract Point move(Point position);", "public interface IStrategy {\n\n\t\t\n\t\t\t\n\t/** \n\t * calculate the next position of the pacman. Gets the curent position and returns the new position.\n\t */\n\tpublic abstract Point move(Point position);\n\t\t\t\n\t\t\n\n}", "@Test\n public void testMove() {\n Point Left_1_North = Day1.move(\"L\", 1, new Point(0, 0), \"NORTH\");\n assertEquals(new Point(-1, 0), Left_1_North);\n\n Point Left_1_South = Day1.move(\"L\", 1, new Point(0, 0), \"SOUTH\");\n assertEquals(new Point(1, 0), Left_1_South);\n\n Point Left_1_East = Day1.move(\"L\", 1, new Point(0, 0), \"EAST\");\n assertEquals(new Point(0, 1), Left_1_East);\n\n Point Left_1_West = Day1.move(\"L\", 1, new Point(0, 0), \"WEST\");\n assertEquals(new Point(0, -1), Left_1_West);\n\n //turn right when facing North, South, East and West\n Point Right_1_North = Day1.move(\"R\", 1, new Point(0, 0), \"NORTH\");\n assertEquals(new Point(1, 0), Right_1_North);\n\n Point Right_1_South = Day1.move(\"R\", 1, new Point(0, 0), \"SOUTH\");\n assertEquals(new Point(-1, 0), Right_1_South);\n\n Point Right_1_East = Day1.move(\"R\", 1, new Point(0, 0), \"EAST\");\n assertEquals(new Point(0, -1), Right_1_East);\n\n Point Right_1_West = Day1.move(\"R\", 1, new Point(0, 0), \"WEST\");\n assertEquals(new Point(0, 1), Right_1_West);\n\n //wrong Input, return current point\n Point wrong = Day1.move(\"A\", 1, new Point(0, 0), \"B\");\n assertEquals(new Point(0, 0), wrong);\n\n }", "public int[] decomposeMove(String move) {\r\n\t\tint[] decomposedMove = new int[2];\r\n\t\tString[] letters={\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\",\"H\",\"I\",\"J\"};\r\n\t\tfor (int num=0; num<letters.length; num++) {\r\n\t\t\tif (letters[num].equals(move.substring(0, 1))) {\r\n\t\t\t\tdecomposedMove[0]=num;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\tdecomposedMove[1]=Integer.valueOf(move.substring(1))-1;\r\n\t\treturn decomposedMove;\r\n\t}", "public static Move alg2Move(String moveStr)\r\n\t{\r\n\t\treturn new Move(0,Board.alg2Square(moveStr.substring(0,2)),Board.alg2Square(moveStr.substring(2,4)));\r\n\t}", "@Override\n public void fetchInstruction(Location newLocation) {\n// Float bearing;\n// Float speed = 0f;\n\n if (newLocation.hasSpeed() && newLocation.hasBearing()) {\n LatLng currentLoc = new LatLng(newLocation.getLatitude(), newLocation.getLongitude());\n\n float speed = newLocation.getSpeed();\n float bearing = newLocation.getBearing();\n new InstructionProviderTask(this)\n .execute(currentLoc, speed, bearing, pathRadius, pathCoordinates, deltaT);\n }\n\n// if (newLocation.hasSpeed()) {\n// speed = newLocation.getSpeed();\n// previousSpeed = speed;\n// } else {\n// //average walking speed is 1.4 m/s\n// speed = 1.4f;\n// }\n//\n// speed = toMph(speed);\n//\n// LatLng startPoint = new LatLng(newLocation.getLatitude(), newLocation.getLongitude());\n//\n// if (newLocation.hasBearing()) {\n// bearing = newLocation.getBearing();\n// /**\n// * Don't provide any instruction if the user is not moving\n// */\n// new InstructionProviderTask(this)\n// .execute(startPoint, speed, bearing, pathRadius, pathCoordinates, deltaT);\n//\n// //update\n// previousBearing = bearing;\n// } else {\n// bearing = previousBearing;\n// }\n\n }", "public void specialMove() {\n\t\tChessSquare initial = getSquare();\n\t\tChessSquare next;\n\t\t\n\t\tif(initial.getNorth() != null){\n\t\t\tnext = initial.getNorth();\n\t\t\t\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getEast() != null)\n\t\t\t\tif((next.getEast().getOccupant() == null) || (!next.getEast().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getWest() != null && next.getWest().getOccupant() == null)\n\t\t\t\tif((next.getWest().getOccupant() == null) || (!next.getWest().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t}\n\t\t\n\t\tif(initial.getSouth() != null){\n\t\t\tnext = initial.getSouth();\n\t\t\t\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getEast() != null)\n\t\t\t\tif((next.getEast().getOccupant() == null) || (!next.getEast().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getWest() != null)\n\t\t\t\tif((next.getWest().getOccupant() == null) || (!next.getWest().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t\t\n\t\t}\n\t\t\n\t\tnext = initial.getEast();\n\t\tif(next != null)\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\tnext = initial.getWest();\n\t\tif(next != null)\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\tsetCountdown(9);\n\t}", "public int[] parseMove(String move) throws Exception {\r\n if (move.length() != 2)\r\n throw new Exception(\"Invalid move format.\");\r\n\r\n int row = move.charAt(0) - 'A';\r\n int column = move.charAt(1) - '1';\r\n int[] res = { row, column };\r\n return res;\r\n }", "Object GetMove (Object game_state);", "@Override\n public Map<Direction, List<Coordinate>> getPossibleMoves() {\n\n Map<Direction, List<Coordinate>> moves = new HashMap<>();\n\n Coordinate coordinate = this.getCoordinate();\n int row = coordinate.getRow();\n int col = coordinate.getCol();\n\n //Jumps\n List<Coordinate> jumps = new ArrayList<>();\n\n //\n //\n ////\n int tempRow1 = row - 2;\n int tempCol1 = col - 1;\n Coordinate tempCoordinate1 = new Coordinate(tempRow1, tempCol1);\n if (Board.inBounds(tempCoordinate1)) {\n jumps.add(tempCoordinate1);\n }\n\n ////\n //\n //\n int tempRow2 = row + 2;\n int tempCol2 = col - 1;\n Coordinate tempCoordinate2 = new Coordinate(tempRow2, tempCol2);\n if (Board.inBounds(tempCoordinate2)) {\n jumps.add(tempCoordinate2);\n }\n\n //////\n //\n int tempRow3 = row - 1;\n int tempCol3 = col - 2;\n Coordinate tempCoordinate3 = new Coordinate(tempRow3, tempCol3);\n if (Board.inBounds(tempCoordinate3)) {\n jumps.add(tempCoordinate3);\n }\n\n ///////\n //\n int tempRow4 = row - 1;\n int tempCol4 = col + 2;\n Coordinate tempCoordinate4 = new Coordinate(tempRow4, tempCol4);\n if (Board.inBounds(tempCoordinate4)) {\n jumps.add(tempCoordinate4);\n }\n\n ////\n //\n //\n int tempRow5 = row + 2;\n int tempCol5 = col + 1;\n Coordinate tempCoordinate5 = new Coordinate(tempRow5, tempCol5);\n if (Board.inBounds(tempCoordinate5)) {\n jumps.add(tempCoordinate5);\n }\n\n //\n //\n ////\n int tempRow6 = row - 2;\n int tempCol6 = col + 1;\n Coordinate tempCoordinate6 = new Coordinate(tempRow6, tempCol6);\n if (Board.inBounds(tempCoordinate6)) {\n jumps.add(tempCoordinate6);\n }\n\n //\n //////\n int tempRow7 = row + 1;\n int tempCol7 = col - 2;\n Coordinate tempCoordinate7 = new Coordinate(tempRow7, tempCol7);\n if (Board.inBounds(tempCoordinate7)) {\n jumps.add(tempCoordinate7);\n }\n\n //\n //////\n int tempRow8 = row + 1;\n int tempCol8 = col + 2;\n Coordinate tempCoordinate8 = new Coordinate(tempRow8, tempCol8);\n if (Board.inBounds(tempCoordinate8)) {\n jumps.add(tempCoordinate8);\n }\n\n if (!jumps.isEmpty()) {\n moves.put(Direction.Jump, jumps);\n }\n return moves;\n }", "void getMotionInfo(){\n double degreeDistance = Math.sqrt(Math.pow((startLat - endLat),2) + Math.pow((startLong - endLong),2));\n double R = 6378.137; // Radius of earth in KM\n double dLat = startLat * Math.PI / 180 - endLat* Math.PI / 180;\n dLat = Math.abs(dLat);\n double dLon = startLong * Math.PI / 180 - endLong* Math.PI / 180;\n dLon = Math.abs(dLon);\n double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +\n Math.cos(endLat * Math.PI / 180) * Math.cos(startLat* Math.PI / 180) *\n Math.sin(dLon / 2) * Math.sin(dLon / 2);\n double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n double distance;\n distance = R * c;\n distance = distance * 1000f;\n pathDistance = distance;\n degToMRatio = degreeDistance/distance;\n double angle = Math.atan(dLat/dLon);\n xCompMotion = Math.cos(angle);\n yCompMotion = Math.sin(angle);\n totalNumSteps = pathDistance/STEP_LENGTH;\n //Rounds number of steps to nearest whole number\n totalNumSteps = Math.round(totalNumSteps);\n }", "public PuzzleType getMoverType( );", "public Move parseMove(String s) throws GameException {\n\t\t\ttry {\n\t\t\t\ts = s.split(\"\\\\s+\")[0]; // first token\n\t\t\t\tint i = Integer.parseInt(s);\n\t\t\t\tCMN.CMNMove m = CMN.moveList.get(i);\n\t\t\t\tif (isLegal(m)) {\n\t\t\t\t\treturn m;\n\t\t\t\t}\n\t\t\t\tthrow new IllegalMoveException(m);\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\tthrow new NoSuchMoveException(s);\n\t\t\t} catch (IndexOutOfBoundsException e) {\n\t\t\t\tthrow new NoSuchMoveException(s);\n\t\t\t}\n\t\t}", "public void readCommands() {\n\t\t\n\t\tif(this.initialPoint.getOrientation() == 'N' ||\n\t\t\t\tthis.initialPoint.getOrientation() == 'E' ||\n\t\t\t\tthis.initialPoint.getOrientation() == 'W' ||\n\t\t\t\tthis.initialPoint.getOrientation() == 'S') {\n\n\t\t\tfor(char letter : commands) {\n\t\t\t\tswitch (letter) {\n\t\t\t\tcase 'D':\n\t\t\t\t\tturnRight();\n\t\t\t\t\tprintPosition();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'G':\n\t\t\t\t\tturnLeft();\n\t\t\t\t\tprintPosition();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'A':\n\t\t\t\t\tmoveForward();\n\t\t\t\t\tprintPosition();\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t// If the sequence of commands contains a letter which is not recognized\n\t\t\t\t\t// the mower will process the next command/letter.\n\t\t\t\t\tSystem.out.println(\"Command not recognized. Admissible values: [D, G, A].\");\n\t\t\t\t\tSystem.out.println(\"Processing next command.\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\telse {\n\t\t\tSystem.out.println(\"Orientation not admissible. Stopping program.\");\n\t\t\treturn;\n\t\t}\n\n\t}", "@Override\n public void parse(String sentence) {\n String[] tmp = sentence.split(DELIM);\n if (tmp.length > 4) {\n // fits example 1\n updateTimeStamp(parseTimeToDate(tmp[5]));\n if (!\"A\".equals(tmp[6])) {\n return;\n }\n mFixLatitude = parseCoordinate(tmp[1], tmp[2]);\n mFixLongitude = parseCoordinate(tmp[3], tmp[4]);\n } else if (tmp.length > 3) {\n // fits example 2\n mFixLatitude = parseCoordinate(tmp[1], tmp[2]);\n mFixLongitude = parseCoordinate(tmp[3], tmp[4]);\n }\n }", "@Override\n\tpublic Collection<Move> calculateLegalMoves(final Board board) {\n\t\t\n\t\t//Array that will hold of the legal moves for the Pawn\n\t\tfinal List<Move> legalMoves = new ArrayList<>();\n\t\t\n\t\t//Loop through all possible moves by applying of the offsets to the Pawn's current position\n\t\tfor(final int currentCandidateOffset: CANDIDATE_MOVE_COORDINATES){\n\t\t\t\n\t\t\t//Apply the offset to the Pawn's current position\n\t\t\tfinal int candidateDestinationCoordinate = this.piecePosition + (this.getPieceTeam().getDirection() * currentCandidateOffset);\n\t\t\t\n\t\t\t//Checks if the Destination Coordinate is valid\n\t\t\tif(!BoardUtils.isValidTileCoordinate(candidateDestinationCoordinate)){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t//Checks if this tile is occupied\n\t\t\tif(currentCandidateOffset == 8 && !board.getTile(candidateDestinationCoordinate).isTileOccupied()){\n\t\t\t\tif(this.pieceTeam.isPawnPromotionSquare(candidateDestinationCoordinate))\n\t\t\t\t\tlegalMoves.add(new Move.PawnPromotion(new Move.PawnMove(board, this, candidateDestinationCoordinate)));\n\t\t\t\telse\n\t\t\t\t\tlegalMoves.add(new Move.PawnMove(board, this, candidateDestinationCoordinate));\t\n\t\t\t}\n\t\t\t//Checks if the Pawn is on it's first move\n\t\t\telse if(currentCandidateOffset == 16 && this.isFirstMove() && ((BoardUtils.SEVENTH_RANK[this.piecePosition] && \n\t\t\t\t\tthis.getPieceTeam().isBlack()) || (BoardUtils.SECOND_RANK[this.piecePosition] && this.getPieceTeam().isWhite()))) {\n\t\t\t\t\n\t\t\t\t//Calculate coordinate of the tile behind candidate coordinate\n\t\t\t\tfinal int behindCandidateDestinationCoordinate = this.piecePosition + (this.pieceTeam.getDirection() * 8);\n\t\t\t\t\n\t\t\t\t//Checks if the tile behind the candidate destination is NOT occupied & if the Tile at the Candidate Destination is NOT occupied\n\t\t\t\tif(!board.getTile(behindCandidateDestinationCoordinate).isTileOccupied() && \n\t\t\t !board.getTile(candidateDestinationCoordinate).isTileOccupied())\n\t\t\t\t\t\tlegalMoves.add(new Move.PawnJump(board, this, candidateDestinationCoordinate));\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t//Checks for edge cases in the 7 direction\t\n\t\t\t} else if(currentCandidateOffset == 7 &&\n\t\t\t\t\t!((BoardUtils.FILE_H[this.piecePosition] && this.getPieceTeam().isWhite() ||\n\t\t\t\t\t(BoardUtils.FILE_A[this.piecePosition] && this.getPieceTeam().isBlack())))){\n\t\t\t\t\n\t\t\t\tif(board.getTile(candidateDestinationCoordinate).isTileOccupied()){\n\t\t\t\t\tfinal Piece pieceOnCandidate = board.getTile(candidateDestinationCoordinate).getPiece();\n\t\t\t\t\t//If the pieces are not on the same team an Attack move is added to legal moves.\n\t\t\t\t\tif(this.getPieceTeam() != pieceOnCandidate.getPieceTeam())\n\t\t\t\t\t\tif(this.pieceTeam.isPawnPromotionSquare(candidateDestinationCoordinate))\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnPromotion(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate)));\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t\t\t\n\t\t\t\t//This basically checks if En Passant Pawn is next to Player's pawn\t\n\t\t\t\t} else if(board.getEnPassantPawn() != null){\n\t\t\t\t\tif(board.getEnPassantPawn().getPiecePosition() == (this.piecePosition + (this.pieceTeam.getOppositeDirection()))){\n\t\t\t\t\t\tfinal Piece pieceOnCandidate = board.getEnPassantPawn();\n\t\t\t\t\t\tif(this.pieceTeam != pieceOnCandidate.getPieceTeam()){\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnEnPassantAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t//Checks for edge cases in the 9 direction\t\n\t\t\t} else if(currentCandidateOffset == 9 && \n\t\t\t\t\t!((BoardUtils.FILE_A[this.piecePosition] && this.getPieceTeam().isWhite() ||\n\t\t\t\t\t(BoardUtils.FILE_H[this.piecePosition] && this.getPieceTeam().isBlack())))){\n\t\t\t\t\n\t\t\t\tif(board.getTile(candidateDestinationCoordinate).isTileOccupied()){\n\t\t\t\t\tfinal Piece pieceOnCandidate = board.getTile(candidateDestinationCoordinate).getPiece();\n\t\t\t\t\t//If the pieces are not on the same team an Attack move is added to legal moves.\n\t\t\t\t\tif(this.getPieceTeam() != pieceOnCandidate.getPieceTeam())\n\t\t\t\t\t\tif(this.pieceTeam.isPawnPromotionSquare(candidateDestinationCoordinate))\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnPromotion(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate)));\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t} else if(board.getEnPassantPawn() != null){\n\t\t\t\t\tif(board.getEnPassantPawn().getPiecePosition() == (this.piecePosition - (this.pieceTeam.getOppositeDirection()))){\n\t\t\t\t\t\tfinal Piece pieceOnCandidate = board.getEnPassantPawn();\n\t\t\t\t\t\tif(this.pieceTeam != pieceOnCandidate.getPieceTeam()){\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnEnPassantAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\t\t\t\t\t\n\t\t}\n\t\t\n\t\treturn ImmutableList.copyOf(legalMoves);\n\t}", "public String getValidMove() {\r\n\t\tboolean isValidMove = false;\r\n\t\tString Command = \"\";\r\n\t\twhile(!isValidMove) {\r\n\t\t\ttry {\r\n\t\t\t\tCommand = FromClient.readUTF();\r\n\t\t\t\tString[] parts = Command.split(\" \");\r\n\t\t\t\tint move = Integer.parseInt(parts[1]);\r\n\t\t\t\tisValidMove = engine.ValidPosition(move, User.Iindex, User.Jindex);\r\n\t\t\t\tToClient.writeBoolean(isValidMove);\r\n\t\t\t} catch (IOException e) {\r\n\t\t\t\t// TODO Auto-generated catch block\r\n\t\t\t\te.printStackTrace();\r\n\t\t\t} catch (NumberFormatException e1) {\r\n\t\t\t\t// TODO Auto-generated catch block\r\n\t\t\t\te1.printStackTrace();\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn Command;\r\n\t}", "void lastMoveInfo(int playerIndex, int column, int row);", "public interface IMonster {\n\n /**\n * Checks surrounding grid locations for spots\n * Then makes corresponding moves based upon the locations\n */\n void act();\n\n /**\n * Gets the actors currently on the grid.\n * Looks for grid locations that are surrounding the area for open spots\n * @return List of actor\n */\n ArrayList<Actor> getActors();\n\n /**\n * Gets the actors currently on the grid\n * Watches to see if a current monster can eat a human or food\n * Once the Human or food as been ate it is removed from the grid\n * @param actors\n */\n void processActors(ArrayList<Actor> actors);\n\n /**\n * Locates moves available on the grid\n * @return location\n */\n ArrayList<Location> getMoveLocations();\n\n /**\n * Selects an available move that can be made\n * @param locs\n * @return location of r\n */\n Location selectMoveLocation(ArrayList<Location> locs);\n\n /**\n * Checks whether a monster can move to the next grid spot\n * @return true or false\n */\n boolean canMove();\n\n /**\n * Moves the Monster to a location of the grid\n * If the location is null the Monster is removed from the grid\n * Also over writes other Monsters of the grid spot if needed\n * @param loc\n */\n void makeMove(Location loc);\n}", "Move getMove(String str) {\n String line = str;\n Move move = Move.create(line, _board);\n if (move == null) {\n error(\"invalid move: %s%n\", line);\n } else if (!_playing) {\n error(\"game not started\");\n } else if (!_board.isLegal(move)) {\n error(\"illegal move: %s%n\", line);\n } else {\n return move;\n }\n System.out.println();\n prompt();\n return null;\n }", "@Override\r\n\tpublic Move validateMove(Piece[][] state, Coordinate from, Coordinate to) throws InvalidMoveException {\r\n\t\tList<Coordinate> possibles = getPossibleLocations(from);\r\n\t\tif (!possibles.contains(to))\r\n\t\t\tthrow new InvalidMoveException();\r\n\r\n\t\tMove result = new Move();\r\n\r\n\t\tMoveType type = MoveTypeChecker.getMoveType(getColor(), state, to);\r\n\t\tif (type == null)\r\n\t\t\treturn null;\r\n\r\n\t\tresult.setType(type);\r\n\t\tresult.setFrom(from);\r\n\t\tresult.setTo(to);\r\n\t\tresult.setMovedPiece(this);\r\n\r\n\t\tint i = 1;\r\n\t\tif (to.getX() < from.getX()) {\r\n\t\t\tif (to.getY() < from.getY()) {\r\n\t\t\t\twhile (from.getX() - i > to.getX()) {\r\n\t\t\t\t\tif (state[from.getX() - i][from.getY() - i] != null)\r\n\t\t\t\t\t\tthrow new InvalidMoveException();\r\n\t\t\t\t\ti++;\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\twhile (from.getX() - i > to.getX()) {\r\n\t\t\t\t\tif (state[from.getX() - i][from.getY() + i] != null)\r\n\t\t\t\t\t\tthrow new InvalidMoveException();\r\n\t\t\t\t\ti++;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} else if (to.getY() < from.getY()) {\r\n\t\t\twhile (from.getX() + i < to.getX()) {\r\n\t\t\t\tif (state[from.getX() + i][from.getY() - i] != null)\r\n\t\t\t\t\tthrow new InvalidMoveException();\r\n\t\t\t\ti++;\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\twhile (from.getX() + i < to.getX()) {\r\n\t\t\t\tif (state[from.getX() + i][from.getY() + i] != null)\r\n\t\t\t\t\tthrow new InvalidMoveException();\r\n\t\t\t\ti++;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn result;\r\n\t}", "private boolean move(int move, String sAnnotation, boolean bUpdate) {\n if (jni.move(move) == 0) {\n return false;\n }\n addPGNEntry(jni.getNumBoard() - 1, jni.getMyMoveToString(), sAnnotation, jni.getMyMove(), -1);\n\n return true;\n }", "@Override\n public void movePiece(Piece piece, char file, GridPosition end) {\n GridPosition current = getCurrentGridPositionOfPiece(piece, file, end);\n\n Move mv = new Move(piece, current, end);\n\n int[] curYX = ChessGameUtils_Ng.convertGridPositionTo2DYXArray(current);\n int curY = curYX[ChessGameUtils_Ng.Y_INDEX], curX = curYX[ChessGameUtils_Ng.X_INDEX];\n\n int[] update = mv.getYXDelta();\n int dY = update[DELTA_Y_INDEX], dX = update[DELTA_X_INDEX];\n\n board[curY][curX] = EMPTY_SPACE;\n board[curY + dY][curX + dX] = piece;\n moveHistory.add(mv);\n }", "public void unapplyMove()\r\n\t{\r\n\t\tif (appliedMoves == null || appliedMoves.isEmpty()) return;\r\n\t\t\r\n\t\tdecrementPositionCount();\r\n\t\t\r\n\t\tboolean lastMoveRochade = isLastMoveRochade(); //Check before any changes to the board are made\r\n\t\tboolean isLastMoveEnPassentCapture = !lastMoveRochade && isLastMoveEnPassentCapture();\r\n\r\n\t\tMove lastMove = getLastMove();\r\n\t\tif (lastMoveRochade)\r\n\t\t{\r\n\t\t\tlastMove.from.piece = lastMove.to.piece;\r\n\t\t\tlastMove.to.piece = lastMove.capture;\r\n\t\t\t\r\n\t\t\tField kingFieldTo = lastMove.to;\r\n\t\t\tif (kingFieldTo.coordinate.x == 6)\r\n\t\t\t{\r\n\t\t\t\tField rookRochadeField = fields[5][kingFieldTo.coordinate.y];\r\n\t\t\t\tField rookBeforeRochadeField = fields[7][kingFieldTo.coordinate.y];\r\n\t\t\t\trookBeforeRochadeField.piece = rookRochadeField.piece;\r\n\t\t\t\trookRochadeField.piece = null;\r\n\t\t\t}\r\n\t\t\telse if (kingFieldTo.coordinate.x == 2)\r\n\t\t\t{\r\n\t\t\t\tField rookRochadeField = fields[3][kingFieldTo.coordinate.y];\r\n\t\t\t\tField rookBeforeRochadeField = fields[0][kingFieldTo.coordinate.y];\r\n\t\t\t\trookBeforeRochadeField.piece = rookRochadeField.piece;\r\n\t\t\t\trookRochadeField.piece = null;\r\n\t\t\t}\t\r\n\t\t}\r\n\t\telse if (isLastMoveEnPassentCapture)\r\n\t\t{\r\n\t\t\tlastMove.from.piece = lastMove.to.piece;\r\n\t\t\tlastMove.to.piece = null;\r\n\t\t\t\r\n\t\t\tMove beforeLastMove = appliedMoves.get(appliedMoves.size() - 2);\r\n\t\t\tbeforeLastMove.to.piece = lastMove.capture;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (lastMove.promotion != null)\r\n\t\t\t{\r\n\t\t\t\tlastMove.from.piece = new Pawn(lastMove.color);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tlastMove.from.piece = lastMove.to.piece;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tlastMove.to.piece = lastMove.capture;\r\n\t\t}\r\n\t\t\r\n\t\tappliedMoves.remove(appliedMoves.size() - 1);\r\n\t}" ]
[ "0.62437624", "0.547183", "0.5428035", "0.54022276", "0.53858143", "0.5368387", "0.5354206", "0.5347687", "0.53318053", "0.52536476", "0.5214768", "0.51406527", "0.51346844", "0.51200336", "0.50885856", "0.50885385", "0.50795054", "0.5076348", "0.5055636", "0.50204337", "0.5014532", "0.5006351", "0.5001491", "0.49750727", "0.496963", "0.49553904", "0.4950932", "0.49205762", "0.48996165", "0.4888887", "0.48829806", "0.48827606", "0.4843052", "0.48407745", "0.48283067", "0.4826019", "0.48251328", "0.48197564", "0.4815591", "0.4777699", "0.4776915", "0.47679588", "0.4760743", "0.47415736", "0.4740448", "0.47368848", "0.47323197", "0.47161075", "0.47041547", "0.4703753", "0.47020376", "0.4701323", "0.46883518", "0.4680858", "0.46805578", "0.4674686", "0.466796", "0.46603078", "0.46596208", "0.465243", "0.46506858", "0.46473926", "0.46311596", "0.46286863", "0.46271053", "0.46233845", "0.46122304", "0.46086973", "0.45996293", "0.45984897", "0.45967776", "0.45958534", "0.45912355", "0.45907608", "0.4587421", "0.45828754", "0.45823583", "0.45810023", "0.45785156", "0.45744294", "0.4570589", "0.45649618", "0.45609492", "0.45585856", "0.4554037", "0.4553965", "0.4552714", "0.4540816", "0.45398167", "0.45308116", "0.45296156", "0.4522926", "0.45218724", "0.45206788", "0.45202178", "0.4519614", "0.45167622", "0.45141965", "0.45014864", "0.4499478" ]
0.47648165
42
Handle king side castling. King side castling is annotated as "OO" and moves the king to g1 for white and g8 for black and the rook to f1 for white and f8 for black. This method moves the king and rook to the correct square.
public static void castleKingSide(char color) { String colorString = Character.toString(color); String king = "K" + colorString; String rook = "R" + colorString; int rank = color == 'w' ? 0 : 7; move(king, 4, rank, 6, rank); move(rook, 7, rank, 5, rank); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Override\r\n\tpublic boolean makeMove(String notation) {\n\t\tif(Castle.isCastlingMove(new ChessCoordinate(notation))) {\r\n\t\t\tKing playerKing = (King) getPlayerTurn().getPieces(\"King\", true).get(0);\r\n\t\t\t//return the result of trying to castle\r\n\t\t\treturn playerKing.move(new ChessCoordinate(notation));\r\n\t\t\t\r\n\t\t}else {\r\n\t\t\t//not a castling move, standard move\r\n\t\t\t\t\r\n\t\t\tString[] notationList = notation.split(\"\");\r\n\t\t\t//find the piece name\r\n\t\t\tString pieceName = ChessPieceNames.getPieceName(notationList[0]);\t\t\r\n\t\t\t\r\n\t\t\tif(pieceName == null && getColumnNames().contains(notationList[0].toLowerCase())) {\r\n\t\t\t\t//if first character is a column and returned null from above\r\n\t\t\t\t//must be a pawn move like e4 or axb2\r\n\t\t\t\tpieceName = ChessPieceNames.PAWN.toString();\r\n\t\t\t}else if(pieceName == null){\r\n\t\t\t\t//not a column and null so invalid move\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\r\n//\t\t\t//capturing move if there is a capture (x)\r\n\t\t\tboolean isCaptureMove = Arrays.asList(notationList).contains(\"x\");\r\n\t\t\t\r\n\t\t\t//final coordinate\r\n\t\t\tString coordinateString = notationList[notationList.length-2] + notationList[notationList.length-1];\r\n\t\t\tChessCoordinate coordinate = new ChessCoordinate(coordinateString);\r\n\t\t\tif(coordinate.isValid()) {\r\n\t\t\t\t//extract players alive pieces of piece name\r\n\t\t\t\tList<Piece> piecesOfType = getPlayerTurn().getPieces(pieceName, true);\r\n\t\t\t\t//list of pieces that can move to the same square\r\n\t\t\t\tList<Piece> piecesCanMoveToSquare = new ArrayList<Piece>();\r\n\t\t\t\tfor (Piece piece : piecesOfType) {\r\n\t\t\t\t\t\r\n\t\t\t\t\t//use valid moves of attacking if capturing move, else use move to\r\n\t\t\t\t\tSet<Coordinate> pieceMoves = isCaptureMove \r\n\t\t\t\t\t\t\t? piece.getValidMoves(Action.ATTACK) : piece.getValidMoves(Action.MOVE_TO);\r\n\t\t\t\t\tif(pieceMoves.contains(coordinate))piecesCanMoveToSquare.add(piece);\r\n\t\t\t\t}\t\r\n\t\t\t\t\r\n\t\t\t\tif (piecesCanMoveToSquare.size() == 1) {\r\n\t\t\t\t\t//only one piece can go to that square, so take piece at 0th index as the list only has one element\r\n\t\t\t\t\tpiecesCanMoveToSquare.get(0).move(coordinate);\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\telse if (piecesCanMoveToSquare.size() > 1) {\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(notation.length() <= 3) {\r\n\t\t\t\t\t\tSystem.out.println(\"Invalid move, specify which piece to move to \" + coordinateString);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//multiple pieces of the same type can move to that square, check which one to use\r\n\t\t\t\t\t//if pawn, the identifier to use is the 0th index of notationList, eg axb4. use pawn in column a.\r\n\t\t\t\t\t//for other pieces, column to use is the 1st index of notationList. eg Nab4.\r\n\t\t\t\t\t\r\n\t\t\t\t\t//variable called identifier as it can be a row or column value.\r\n\t\t\t\t\tString identifier = (pieceName.equalsIgnoreCase(ChessPieceNames.PAWN.toString()) ?\r\n\t\t\t\t\t\t\tnotationList[0] : notationList[1]).toLowerCase();\r\n\t\t\t\t\t//identifier should be a row value if pieces share the same column\r\n\t\t\t\t\tboolean isRowIdentifier = shareColumn(piecesOfType);\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(isRowIdentifier && getRowNames().contains(identifier)) {\r\n\t\t\t\t\t\t//locate piece by row and move that piece to coordinate\r\n\t\t\t\t\t\tfor (Piece piece : piecesCanMoveToSquare) {\r\n\t\t\t\t\t\t\t//look at the row number of piece coordinate, see if it matches the identifier \r\n\t\t\t\t\t\t\tif(Character.toString(piece.getPosition().toString().charAt(1)).equalsIgnoreCase(identifier)) {\r\n\t\t\t\t\t\t\t\tpiece.move(coordinate);\r\n\t\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tSystem.out.println(\"There is no \" + pieceName + \" on row \" + identifier);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}else if(getColumnNames().contains(identifier)) {\r\n\t\t\t\t\t\tfor (Piece piece : piecesCanMoveToSquare) {\r\n\t\t\t\t\t\t\t//look at the column letter of piece coordinate, see if it matches the identifier \r\n\t\t\t\t\t\t\tif(Character.toString(piece.getPosition().toString().charAt(0)).equalsIgnoreCase(identifier)) {\r\n\t\t\t\t\t\t\t\tpiece.move(coordinate);\r\n\t\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tSystem.out.println(\"There is no \" + pieceName + \" on column \" + identifier);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//invalid identifier\r\n\t\t\t\t\telse return false;\r\n\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\telse {\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t//invalid coordinate, move can not be played\r\n\t\t\telse return false;\r\n\t\t}\r\n\t\t\r\n\t}", "protected void kingPieces() {\n Row firstRowRed = redBoard.getLastRow();\n Row firstRowWhite = whiteBoard.getLastRow();\n\n for (Space space : firstRowRed) {\n Piece piece = space.getPiece();\n if (piece != null)\n if (piece.getColor() == Piece.COLOR.WHITE) {\n if (piece.getType() == Piece.TYPE.SINGLE) {\n redBoard.kingPiece(firstRowRed.getIndex(), space.getCellIdx());\n whiteBoard.kingPiece(7 - firstRowRed.getIndex(), 7 - space.getCellIdx());\n }\n }\n }\n for (Space space : firstRowWhite) {\n Piece piece = space.getPiece();\n if (piece != null)\n if (piece.getColor() == Piece.COLOR.RED) {\n if (piece.getType() == Piece.TYPE.SINGLE) {\n redBoard.kingPiece(7 - firstRowWhite.getIndex(), 7 - space.getCellIdx());\n whiteBoard.kingPiece(firstRowWhite.getIndex(), space.getCellIdx());\n }\n }\n }\n }", "public void convertPawnToKing() {\n pawn.convertToKing();\n }", "private ArrayList<Move> blackKing() {\n // obtain current co-ordinates\n int x = this.getX();\n int y = this.getY();\n\n ArrayList<Move> blackMoves = new ArrayList<Move>();\n\n // set up m to refer to a Move object\n Move theMove = null;\n\n\n // the top and bottom are opposites coordinates for the black and white kings and so are left and right\n // all Unoccupied moves\n\n // first legal move is to go from x,y to x,y-1 if x,y-1 is unoccupied (top)\n if (validNormalMove(x, y - 1)) {\n theMove = new Move(this, x, y, x, y - 1, false);\n if(takeOverCheck(x, y-1)){\n theMove.setOccupied(true);\n }\n\n blackMoves.add(theMove);\n }\n\n\n // legal move is to go from x,y to x,y+1 if x,y+1 is unoccupied (bottom)\n if (validNormalMove(x, y + 1)) {\n theMove = new Move(this, x, y, x, y + 1, false);\n if(takeOverCheck(x, y+1)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n }\n\n //left\n // legal move to go left from x,y to x+1, y if x+1,y is unoccupied (left)\n\n if (validNormalMove(x+1, y)) {\n theMove = new Move(this, x, y, x+1, y, false);\n if(takeOverCheck(x+1, y)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n\n }\n\n //right\n // legal move to go right from x,y to x-1, y if x-1,y is unoccupied (right)\n\n if (validNormalMove(x-1, y)) {\n theMove = new Move(this, x, y, x-1, y, false);\n\n if(takeOverCheck(x-1, y)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n }\n\n\n // legal move to diagonal top right for white king\n if (validNormalMove(x-1, y - 1)) {\n theMove = new Move(this, x, y, x-1, y - 1, false);\n if(takeOverCheck(x-1, y-1)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n }\n\n // legal move to diagonal bottom left\n\n if (validNormalMove(x+1, y +1)) {\n theMove = new Move(this, x, y, x+1, y + 1, false);\n\n if(takeOverCheck(x+1, y+1)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n }\n\n // legal move to diagonal bottom right\n if (validNormalMove(x-1, y +1)) {\n theMove = new Move(this, x, y, x-1, y + 1, false);\n if(takeOverCheck(x-1, y+1)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n }\n\n // legal move to diagonal top left\n if (validNormalMove(x+1, y-1)) {\n theMove = new Move(this, x, y, x+1, y - 1, false);\n if(takeOverCheck(x+1, y-1)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n }\n\n\n\n\n\n if (blackMoves.isEmpty())\n return null;\n return blackMoves;\n }", "private ArrayList<Move> whiteKing(){\n // obtain current co-ordinates\n int x = this.getX();\n int y = this.getY();\n\n // otherwise create a new vector to store legal whiteMoves\n ArrayList<Move> whiteMoves = new ArrayList<Move>();\n\n // set up m to refer to a Move object\n Move theMove = null;\n\n // first legal move is to go from x,y to x,y+1\n if (validNormalMove(x, y + 1)) {\n theMove = new Move(this, x, y, x, y + 1, false);\n if(takeOverCheck(x, y+1)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n\n // legal move is to go from x,y to x,y-1 if x,y-1 is unoccupied (bottom)\n if (validNormalMove(x, y - 1)) {\n theMove = new Move(this, x, y, x, y - 1, false);\n if(takeOverCheck(x, y-1)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n //left\n // legal move to go left from x,y to x-1, y if x-1,y is unoccupied (left)\n\n if (validNormalMove(x-1, y)) {\n theMove = new Move(this, x, y, x-1, y, false);\n if(takeOverCheck(x-1, y)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n //right\n // legal move to go right from x,y to x+1, y if x+1,y is unoccupied (right)\n\n if (validNormalMove(x+1, y)) {\n theMove = new Move(this, x, y, x+1, y, false);\n\n if(takeOverCheck(x+1, y)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n\n\n // legal move to diagonal top right for white king\n if (validNormalMove(x+1, y + 1)) {\n theMove = new Move(this, x, y, x+1, y + 1, false);\n if(takeOverCheck(x+1, y+1)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n // legal move to diagonal bottom right\n\n if (validNormalMove(x+1, y -1)) {\n theMove = new Move(this, x, y, x+1, y - 1, false);\n if(takeOverCheck(x+1, y-1)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n // legal move to diagonal bottom left\n if (validNormalMove(x-1, y -1)) {\n theMove = new Move(this, x, y, x-1, y - 1, false);\n if(takeOverCheck(x-1, y-1)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n // legal move to diagonal top left\n if (validNormalMove(x-1, y+1)) {\n theMove = new Move(this, x, y, x-1, y + 1, false);\n if(takeOverCheck(x-1, y+1)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n\n\n if (whiteMoves.isEmpty())\n return null;\n return whiteMoves;\n }", "public void makeKing() {\n // Set king variable to true\n this.king = true;\n\n // Add stroke effect to piece to represent as a king\n setStroke(Color.GOLD);\n }", "public void specialMove() {\n\t\tChessSquare initial = getSquare();\n\t\tChessSquare next;\n\t\t\n\t\tif(initial.getNorth() != null){\n\t\t\tnext = initial.getNorth();\n\t\t\t\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getEast() != null)\n\t\t\t\tif((next.getEast().getOccupant() == null) || (!next.getEast().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getWest() != null && next.getWest().getOccupant() == null)\n\t\t\t\tif((next.getWest().getOccupant() == null) || (!next.getWest().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t}\n\t\t\n\t\tif(initial.getSouth() != null){\n\t\t\tnext = initial.getSouth();\n\t\t\t\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getEast() != null)\n\t\t\t\tif((next.getEast().getOccupant() == null) || (!next.getEast().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getWest() != null)\n\t\t\t\tif((next.getWest().getOccupant() == null) || (!next.getWest().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t\t\n\t\t}\n\t\t\n\t\tnext = initial.getEast();\n\t\tif(next != null)\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\tnext = initial.getWest();\n\t\tif(next != null)\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\tsetCountdown(9);\n\t}", "public void makeMove(String castleString) throws InvalidMoveException {\n Piece kingPiece, rookPiece, betweenPiece;\n Coordinate kingCoordinate, rookCoordinate, betweenCoordinate, oppCoordinate;\n int xIncrement, spacesToRook;\n\n // verify valid castle String O-O or O-O-O\n if (!castleString.equals(KING_SIDE_CASTLE_STRING) && !castleString.equals(QUEEN_SIDE_CASTLE_STRING)) {\n throw new InvalidMoveException();\n }\n\n kingCoordinate = getKingCoordinate(nextMoveColor);\n kingPiece = getPieceFromCoordinate(kingCoordinate);\n\n // King cannot be in check or have moved already\n if (isInCheck(nextMoveColor) || kingPiece.getHasMoved()) {\n throw new InvalidMoveException();\n }\n\n if (castleString == KING_SIDE_CASTLE_STRING) {\n xIncrement = 1;\n spacesToRook = 3;\n }\n else {\n xIncrement = -1;\n spacesToRook = 4;\n }\n\n rookCoordinate = new Coordinate(kingCoordinate.getPosX() + spacesToRook * xIncrement,\n kingCoordinate.getPosY());\n rookPiece = getPieceFromCoordinate(rookCoordinate);\n // Rook must not have moved already\n if (!(rookPiece instanceof Rook) || rookPiece.getPieceColor() != nextMoveColor || rookPiece.getHasMoved()) {\n throw new InvalidMoveException();\n }\n\n betweenCoordinate = new Coordinate(kingCoordinate);\n for (int i = 0; i < 2; i++) {\n betweenCoordinate.addVals(xIncrement, 0);\n betweenPiece = getPieceFromCoordinate(betweenCoordinate);\n // the two spaces to the left or right of the King must be empty\n if (betweenPiece != null) {\n throw new InvalidMoveException();\n }\n for (int j = 0; j < VERTICAL_BOARD_LENGTH; j++) {\n for (int k = 0; k < HORIZONTAL_BOARD_LENGTH; k++) {\n oppCoordinate = new Coordinate(k, j);\n // an opposing piece cannot be attacking the two empty spaces\n if (isValidEndpoints(oppCoordinate, betweenCoordinate, oppositeColor(nextMoveColor))) {\n if (isValidPath(oppCoordinate, betweenCoordinate, oppositeColor(nextMoveColor), false)) {\n throw new InvalidMoveException();\n }\n }\n }\n }\n }\n\n // move the King and Rook for castling\n boardArray[betweenCoordinate.getPosY()][betweenCoordinate.getPosX()] = kingPiece;\n boardArray[kingCoordinate.getPosY()][kingCoordinate.getPosX()] = null;\n kingPiece.setPieceCoordinate(betweenCoordinate);\n\n betweenCoordinate.addVals(xIncrement * -1, 0);\n boardArray[betweenCoordinate.getPosY()][betweenCoordinate.getPosX()] = rookPiece;\n boardArray[rookCoordinate.getPosY()][rookCoordinate.getPosX()] = null;\n rookPiece.setPieceCoordinate(betweenCoordinate);\n\n\n kingPiece.setHasMoved(true);\n rookPiece.setHasMoved(true);\n\n nextMoveColor = oppositeColor(nextMoveColor);\n turnNumber++;\n }", "public Board move(String s, boolean si) {\t\t\n\t\t\n\t\t//Queen-side castling\n\t\tif (s.length() >= 5 && s.substring(0, 5).equals(\"O-O-O\")) {\n\t\t\t\n\t\t\tPiece tempKing;\n\t\t\tPiece tempRook;\n\t\t\tPiece tempNull1;\n\t\t\tPiece tempNull2;\n\t\t\t\n\t\t\tif (si) {\n\t\t\t\t((King) b[0][4]).castle();\n\t\t\t\ttempKing = b[0][4];\n\t\t\t\ttempRook = b[0][0];\n\t\t\t\ttempNull1 = b[0][2];\n\t\t\t\ttempNull2 = b[0][3];\n\t\t\t\t\n\t\t\t\tb[0][2] = tempKing;\n\t\t\t\tb[0][3] = tempRook;\n\t\t\t\tb[0][2].setPosition((byte) 0, (byte) 2);\n\t\t\t\tb[0][3].setPosition((byte) 0, (byte) 3);\n\t\t\t\t\n\t\t\t\tb[0][0] = tempNull1;\n\t\t\t\tb[0][4] = tempNull2;\n\t\t\t\tb[0][0].setPosition((byte) 0, (byte) 0);\n\t\t\t\tb[0][4].setPosition((byte) 0, (byte) 4);\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\t((King) b[7][4]).castle();\n\t\t\t\ttempKing = b[7][4];\n\t\t\t\ttempRook = b[7][0];\n\t\t\t\ttempNull1 = b[7][2];\n\t\t\t\ttempNull2 = b[7][3];\n\t\t\t\t\n\t\t\t\tb[7][2] = tempKing;\n\t\t\t\tb[7][3] = tempRook;\n\t\t\t\tb[7][2].setPosition((byte) 7, (byte) 2);\n\t\t\t\tb[7][3].setPosition((byte) 7, (byte) 3);\n\t\t\t\t\n\t\t\t\tb[7][0] = tempNull1;\n\t\t\t\tb[7][4] = tempNull2;\n\t\t\t\tb[7][0].setPosition((byte) 7, (byte) 0);\n\t\t\t\tb[7][4].setPosition((byte) 7, (byte) 4);\n\t\t\t}\n\t\t\t\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t//King-side castling\n\t\tif (s.substring(0, 3).equals(\"O-O\")) {\n\t\t\tPiece tempKing;\n\t\t\tPiece tempRook;\n\t\t\tPiece tempNull1;\n\t\t\tPiece tempNull2;\n\t\t\t\n\t\t\tif (si) {\n\t\t\t\t((King) b[0][4]).castle();\n\t\t\t\t\n\t\t\t\ttempKing = b[0][4];\n\t\t\t\ttempRook = b[0][7];\n\t\t\t\ttempNull1 = b[0][5];\n\t\t\t\ttempNull2 = b[0][6];\n\t\t\t\t\n\t\t\t\tb[0][6] = tempKing;\n\t\t\t\tb[0][5] = tempRook;\n\t\t\t\tb[0][6].setPosition((byte) 0, (byte) 6);\n\t\t\t\tb[0][5].setPosition((byte) 0, (byte) 5);\n\t\t\t\t\n\t\t\t\tb[0][7] = tempNull1;\n\t\t\t\tb[0][4] = tempNull2;\n\t\t\t\tb[0][7].setPosition((byte) 0, (byte) 7);\n\t\t\t\tb[0][4].setPosition((byte) 0, (byte) 4);\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\t((King) b[7][4]).castle();\n\t\t\t\t\n\t\t\t\ttempKing = b[7][4];\n\t\t\t\ttempRook = b[7][7];\n\t\t\t\ttempNull1 = b[7][5];\n\t\t\t\ttempNull2 = b[7][6];\n\t\t\t\t\n\t\t\t\tb[7][6] = tempKing;\n\t\t\t\tb[7][5] = tempRook;\n\t\t\t\tb[7][6].setPosition((byte) 7, (byte) 6);\n\t\t\t\tb[7][5].setPosition((byte) 7, (byte) 5);\n\t\t\t\t\n\t\t\t\tb[7][7] = tempNull1;\n\t\t\t\tb[7][4] = tempNull2;\n\t\t\t\tb[7][7].setPosition((byte) 7, (byte) 7);\n\t\t\t\tb[7][4].setPosition((byte) 7, (byte) 4);\n\t\t\t}\n\t\t\t\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\tbyte fR, fC, tR, tC;\n\t\t\n\t\tfR = (byte) (Byte.parseByte(s.substring(2, 3)) - 1);\n\t\ttR = (byte) (Byte.parseByte(s.substring(5, 6)) - 1);\n\t\t\n\t\tif (s.charAt(1) == 'a') {\n\t\t\tfC = 0;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'b') {\n\t\t\tfC = 1;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'c') {\n\t\t\tfC = 2;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'd') {\n\t\t\tfC = 3;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'e') {\n\t\t\tfC = 4;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'f') {\n\t\t\tfC = 5;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'g') {\n\t\t\tfC = 6;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'h') {\n\t\t\tfC = 7;\n\t\t}\n\t\t\n\t\telse {\n\t\t\tSystem.out.println(\"Invalid Entry\");\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\tif (s.charAt(4) == 'a') {\n\t\t\ttC = 0;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'b') {\n\t\t\ttC = 1;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'c') {\n\t\t\ttC = 2;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'd') {\n\t\t\ttC = 3;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'e') {\n\t\t\ttC = 4;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'f') {\n\t\t\ttC = 5;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'g') {\n\t\t\ttC = 6;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'h') {\n\t\t\ttC = 7;\n\t\t}\n\t\t\n\t\telse {\n\t\t\tSystem.out.println(\"Invalid Entry\");\n\t\t\treader.pause();\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\tif (b[fR][fC] instanceof King) {\n\t\t\t((King) b[fR][fC]).cantC(0);\n\t\t}\n\t\t\n\t\tif (b[fR][fC] instanceof Rook) {\n\t\t\tif (si) {\n\t\t\t\tif (fR == 0 && fC == 0) {\n\t\t\t\t\tgetKing(si).cantC(-1);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\telse if (fR == 0 && fC == 7) {\n\t\t\t\t\tgetKing(si).cantC(1);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\tif (fR == 7 && fC == 0) {\n\t\t\t\t\tgetKing(si).cantC(-1);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\telse if (fR == 7 && fC == 7) {\n\t\t\t\t\tgetKing(si).cantC(1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tb[tR][tC] = b[fR][fC];\n\t\tb[tR][tC].setPosition(tR, tC);\n\t\tb[fR][fC] = new Null(fR, fC);\n\t\t\n\t\tif (s.length() >= 8 && s.charAt(6) == '=') {\n\t\t\tchar p = s.charAt(7);\n\t\t\t\n\t\t\tif (p == 'N') {\n\t\t\t\tb[tR][tC] = new Knight(si, tR, tC);\n\t\t\t}\n\t\t\n\t\t\telse if (p == 'B') {\n\t\t\t\tb[tR][tC] = new Bishop(si, tR, tC);\n\t\t\t}\n\t\t\t\n\t\t\telse if (p == 'R') {\n\t\t\t\tb[tR][tC] = new Rook(si, tR, tC);\n\t\t\t}\n\t\t\t\n\t\t\telse if (p == 'Q') {\n\t\t\t\tb[tR][tC] = new Queen(si, tR, tC);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}", "protected Set<ChessMove> getPossibleCastlingMoves(ChessModel model, Location location, Set<ChessMove> movesSoFar) {\n\t\tCastlingAvailability castlingAvailability = model.getCastlingAvailability();\n\t\tif ((location == E1) && (getColor() == White)) {\n\t\t\t// this is the white king in the starting position\n\t\t\tif (castlingAvailability.isWhiteCanCastleKingSide()) {\n\t\t\t\tif (model.isLocationEmpty(F1) && model.isLocationEmpty(G1)) {\n\t\t\t\t\tif (!isInCheckAtLocations(model, E1, F1, G1)) {\n\t\t\t\t\t\tChessMove move = new ChessMoveCastleKingSide(getPiece(), E1, G1);\n\t\t\t\t\t\tmovesSoFar.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (castlingAvailability.isWhiteCanCastleQueenSide()) {\n\t\t\t\tif (model.isLocationEmpty(B1) && model.isLocationEmpty(C1) && model.isLocationEmpty(D1)) {\n\t\t\t\t\tif (!isInCheckAtLocations(model, B1, C1, D1, E1)) {\n\t\t\t\t\t\tChessMove move = new ChessMoveCastleQueenSide(getPiece(), E1, C1);\n\t\t\t\t\t\tmovesSoFar.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ((location == E8) && (getColor() == Black)) {\n\t\t\t// this is the black king in the starting position\n\t\t\tif (castlingAvailability.isBlackCanCastleKingSide()) {\n\t\t\t\tif (model.isLocationEmpty(F8) && model.isLocationEmpty(G8)) {\n\t\t\t\t\tif (!isInCheckAtLocations(model, E8, F8, G8)) {\n\t\t\t\t\t\tChessMove move = new ChessMoveCastleKingSide(getPiece(), E8, G8);\n\t\t\t\t\t\tmovesSoFar.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t\tif (castlingAvailability.isBlackCanCastleQueenSide()) {\n\t\t\t\tif (model.isLocationEmpty(B8) && model.isLocationEmpty(C8) && model.isLocationEmpty(D8)) {\n\t\t\t\t\tif (!isInCheckAtLocations(model, B8, C8, D8, E8)) {\n\t\t\t\t\t\tChessMove move = new ChessMoveCastleQueenSide(getPiece(), E8, C8);\n\t\t\t\t\t\tmovesSoFar.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\t\t\t\t\n\t\t\t}\t\t\t\n\t\t}\n\t\treturn movesSoFar;\n\t}", "public abstract void calcPathToKing(Space kingSpot);", "public void makeMove(Move m){\n int oldTurn = turn;\n turn = -turn;\n moves++;\n enPassant = -1;\n if (m.toY == 0){ // white rook space\n if (m.toX == 0){\n castles &= nWHITE_LONG;\n //castles[1] = false;\n }else if (m.toX == 7){\n castles &= nWHITE_SHORT;\n //castles[0] = false;\n }\n } else if (m.toY == 7){ // black rook space\n if (m.toX == 0){\n castles &= nBLACK_LONG;\n //castles[3] = false;\n }else if (m.toX == 7){\n castles &= nBLACK_SHORT;\n //castles[2] = false;\n }\n }\n if (m.piece == WHITE_ROOK && m.fromY == 0){\n if (m.fromX == 0){castles &= nWHITE_LONG;} //castles[1] = false;}\n else if (m.fromX == 7){castles &= nWHITE_SHORT;} //castles[0] = false;}\n } else if (m.piece == BLACK_ROOK && m.fromY == 7){\n if (m.fromX == 0){castles &= nBLACK_LONG;} //castles[3] = false;}\n else if (m.fromX == 7){castles &= nBLACK_SHORT;} //castles[2] = false;}\n }\n // castling\n if (m.piece % 6 == 0){\n if (oldTurn == WHITE){\n castles &= 0b1100;\n //castles[0] = false; castles[1] = false;\n } else {\n castles &= 0b11;\n //castles[2] = false; castles[3] = false;\n }\n if (m.toX - m.fromX == 2){ // short\n board[m.fromY][m.fromX] = 0;\n board[m.toY][m.toX] = m.piece;\n // rook\n board[m.fromY][5] = board[m.fromY][7];\n board[m.fromY][7] = 0;\n return;\n } else if (m.toX - m.fromX == -2){ // long\n board[m.fromY][m.fromX] = 0;\n board[m.toY][m.toX] = m.piece;\n // rook\n board[m.fromY][3] = board[m.fromY][0];\n board[m.fromY][0] = 0;\n return;\n }\n } else if (m.piece % 6 == 1) { // pawn move\n stalemateCountdown = 0; // resets on a pawn move\n // promotion\n if (m.toY % 7 == 0){\n board[m.toY][m.toX] = m.promoteTo;\n board[m.fromY][m.fromX] = 0;\n return;\n }\n // en passant\n else if (m.fromX != m.toX && board[m.toY][m.toX] == 0){\n board[m.fromY][m.fromX] = 0;\n board[m.toY][m.toX] = m.piece;\n if (oldTurn == WHITE){\n board[4][m.toX] = 0;\n }else{\n board[3][m.toX] = 0;\n }\n return;\n } else if (m.toY - m.fromY == 2*oldTurn){\n enPassant = m.fromX;\n }\n }\n // regular\n if (board[m.toY][m.toX] != 0){\n stalemateCountdown = 0; // resets on a capture\n }\n board[m.fromY][m.fromX] = 0;\n board[m.toY][m.toX] = m.piece;\n }", "private static void addKingMoves(BitBoard board, LinkedList<Move> moveList, int index,\n\t\t\tint side) {\n\t\tlong moves = CoreConstants.KING_TABLE[index] & ~board.getBitBoards()[side];\n\t\tint pieceType = (side == 0) ? CoreConstants.WHITE_KING : CoreConstants.BLACK_KING;\n\t\taddMoves(pieceType, index, moves, moveList, false, false, CoreConstants.noCastle);\n\t\t// Check for castling moves\n\t\t// Check the castling flags (descirbed in the BitBoard class)\n\t\t// If some have set bits in the correct position castling is legal, if\n\t\t// so add moves accordingly\n\t\tif (side == CoreConstants.WHITE) {\n\t\t\tif ((board.getCastlingFlags()[side] & 0b10000) == 16) {\n\t\t\t\taddMoves(pieceType, index, CoreConstants.wqueenside, moveList, false, false,\n\t\t\t\t\t\tCoreConstants.wQSide);\n\t\t\t}\n\t\t\tif ((board.getCastlingFlags()[side] & 0b01000) == 8) {\n\t\t\t\taddMoves(pieceType, index, CoreConstants.wkingside, moveList, false, false,\n\t\t\t\t\t\tCoreConstants.wKSide);\n\t\t\t}\n\t\t} else {\n\t\t\tif ((board.getCastlingFlags()[side] & 0b10000) == 16) {\n\t\t\t\taddMoves(pieceType, index, CoreConstants.bqueenside, moveList, false, false,\n\t\t\t\t\t\tCoreConstants.bQSide);\n\t\t\t}\n\t\t\tif ((board.getCastlingFlags()[side] & 0b01000) == 8) {\n\t\t\t\taddMoves(pieceType, index, CoreConstants.bkingside, moveList, false, false,\n\t\t\t\t\t\tCoreConstants.bKSide);\n\t\t\t}\n\t\t}\n\t}", "private void makeMove(){\r\n\t\tif(cornerColorIs(GREEN)){\r\n\t\t\tif(noBeepersPresent()){\r\n\t\t\t\tmove();\r\n\t\t\t\tpaintCorner(GREEN);\r\n\t\t\t}\r\n\t\t}\r\n\t\telse{\r\n\t\t\tif(noBeepersPresent()){\r\n\t\t\t\tmove();\r\n\t\t\t\tpaintCorner(RED);\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n//\t\tif(()) {\r\n//\t\t if(cornerColorIs(GREEN)) {\r\n//\t\t move();\r\n//\t\t paintCorner(GREEN);\r\n//\t\t } else {\r\n//\t\t move();\r\n//\t\t paintCorner(RED);\r\n//\t\t }\r\n//\t\t}noBeepersPresent\r\n\t}", "@Override\r\n\tpublic boolean movement(BoardCells[][] chessBoard, Piece targetPiece, int fromX,int fromY,int toX,int toY) {\t\t\r\n\t\t//DEBUG -- System.out.println(\"\"+fromX+fromY+\" \"+toX+toY);\r\n\t\t\r\n\t\tif(fromY == toY){\t\t\t\r\n\t\t\tif(fromX > toX) {\r\n\t\t\t\tfor(int i = fromX-1; i>toX; i--) {\r\n\t\t\t\t\tif(chessBoard[8-fromY][i].getPiece() != null) {\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\r\n\t\t\t} else if (fromX < toX) {\r\n\t\t\t\tfor(int i = fromX+1; i<toX; i++) {\r\n\t\t\t\t\tif(chessBoard[8-fromY][i].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif(getPieceID().equals(\"bR\")) {\r\n\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"bKc\")) {\r\n\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"bK\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif(getPieceID().equals(\"wR\")) {\r\n\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"wKc\")) {\r\n\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"wK\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\tif(fromX == toX) {\t\t\t\t\r\n\t\t\tif(fromY > toY) {\t\r\n\t\t\t\tfor(int i = fromY-1; i>toY; i--) {\r\n\t\t\t\t\tif(chessBoard[8-i][toX].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t} else if (fromY < toY) {\t\t\t\t\r\n\t\t\t\tfor(int i = fromY+1; i<toY; i++) {\t\t\t\t\t\r\n\t\t\t\t\tif(chessBoard[8-i][toX].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tif(getPieceID().equals(\"bR\")) {\r\n\t\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"bKc\")) {\r\n\t\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"bK\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(getPieceID().equals(\"wR\")) {\r\n\t\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"wKc\")) {\r\n\t\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"wK\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\r\n\t\t\treturn true;\t\r\n\t\t}\r\n\t\t\t\t\r\n\t\treturn false;\t\t\r\n\t}", "public static void main(String[] args) {\n\n chessGUI g = new chessGUI();\n\n /*\n // test Root-1\n System.out.println(\"Hello World!\");\n Board test = new Board();\n test.printBoard();\n Piece king1 = new King(1, new Position(2,2), test);\n Piece king2 = new King(1, new Position(1,1), test);\n Piece ROOK3 = new Rook(-1, new Position(1,2), test);\n test.putPieceOnBoard(king1.getRow(), king1.getCol(), king1);\n test.putPieceOnBoard(king2.getRow(), king2.getCol(), king2);\n test.putPieceOnBoard(ROOK3.getRow(), ROOK3.getCol(), ROOK3);\n test.printBoard();\n Object r = ROOK3;\n if (r instanceof Rook){\n System.out.println(\"r instanceof Rook\");\n //r = (Rook) r;\n //System.out.println(((King) k).getBoard()==null);\n //.printBoard();\n int result = ((Rook) r).judgeMove(3,2);\n System.out.println(\"result\"+result);\n }\n\n // test Bishop\n Board test = new Board();\n test.printBoard();\n Piece king1 = new King(1, new Position(2,2), test);\n Piece king2 = new King(-1, new Position(1,1), test);\n Piece king3 = new King(1, new Position(2,3), test);\n\n Piece bishop = new Bishop(-1, new Position(1,2), test);\n test.putPieceOnBoard(king1.getRow(), king1.getCol(), king1);\n test.putPieceOnBoard(king2.getRow(), king2.getCol(), king2);\n test.putPieceOnBoard(king3.getRow(), king3.getCol(), king3);\n test.putPieceOnBoard(bishop.getRow(), bishop.getCol(), bishop);\n test.printBoard();\n Object r = bishop;\n if (r instanceof Bishop){\n System.out.println(\"r instanceof Bishop\");\n // 2,1 == 0\n // 2,3 == 1\n // 4,5 == -3\n int result = ((Bishop) r).judgeMove(4,5);\n System.out.println(\"result\"+result);\n }\n\n\n // test Queen\n Board test = new Board();\n test.printBoard();\n Piece king1 = new King(1, new Position(2,2), test);\n Piece king2 = new King(-1, new Position(1,1), test);\n Piece king3 = new King(1, new Position(2,3), test);\n\n Piece queen = new Queen(-1, new Position(3,2), test);\n test.putPieceOnBoard(king1.getRow(), king1.getCol(), king1);\n test.putPieceOnBoard(king2.getRow(), king2.getCol(), king2);\n test.putPieceOnBoard(king3.getRow(), king3.getCol(), king3);\n test.putPieceOnBoard(queen.getRow(), queen.getCol(), queen);\n test.printBoard();\n Object r = queen;\n if (r instanceof Queen){\n System.out.println(\"r instanceof Queen\");\n // 4,3 == 0\n // 2,2 == 1\n // 1,4 == -3\n // 3,2 == -2\n\n // 1,4 == -3\n // 5,2 == 0\n // 5,4 == 0\n // 1,0 == 0\n\n // 0,2 == -3\n // 2,3 == 1\n\n }\n Piece king4 = new King(1, new Position(4,1), test);\n test.putPieceOnBoard(king4.getRow(), king4.getCol(), king4);\n test.printBoard();\n // 4,1 == 1\n // 5, 0 == -3\n // 5, 5 == -4\n int result = ((Queen) r).judgeMove(5,5);\n System.out.println(\"result\"+result);\n\n //test Knight\n Board test = new Board();\n test.printBoard();\n Piece king1 = new King(1, new Position(2,2), test);\n Piece king2 = new King(-1, new Position(1,1), test);\n Piece king3 = new King(1, new Position(2,3), test);\n Piece queen = new Queen(-1, new Position(3,3), test);\n Piece queen1 = new Queen(1, new Position(3,1), test);\n\n Piece knight = new Knight(-1, new Position(1,2), test);\n test.putPieceOnBoard(king1.getRow(), king1.getCol(), king1);\n test.putPieceOnBoard(king2.getRow(), king2.getCol(), king2);\n test.putPieceOnBoard(king3.getRow(), king3.getCol(), king3);\n test.putPieceOnBoard(queen.getRow(), queen.getCol(), queen);\n test.putPieceOnBoard(queen1.getRow(), queen1.getCol(), queen1);\n test.putPieceOnBoard(knight.getRow(), knight.getCol(), knight);\n test.printBoard();\n Object r = knight;\n if (r instanceof Knight){\n System.out.println(\"r instanceof Knight\");\n // 2,0 == 0\n // 3,1 == 1\n // 3,3 == -3\n // 2,3 == -4\n int result = ((Knight) r).judgeMove(3,1);\n System.out.println(\"result\"+result);\n }\n\n //test Pawn\n Board test = new Board();\n Piece king1 = new King(-1, new Position(2,2), test);\n Piece king2 = new King(-1, new Position(1,1), test);\n Piece king3 = new King(-1, new Position(3,3), test);\n Piece king4 = new King(1, new Position(4,0), test);\n\n Piece pawn = new Pawn(1, new Position(1,3), test);\n Piece pawn_1 = new Pawn(-1, new Position(5,1), test);\n test.putPieceOnBoard(king1.getRow(), king1.getCol(), king1);\n test.putPieceOnBoard(king2.getRow(), king2.getCol(), king2);\n test.putPieceOnBoard(king3.getRow(), king3.getCol(), king3);\n test.putPieceOnBoard(king4.getRow(), king4.getCol(), king4);\n test.putPieceOnBoard(pawn.getRow(), pawn.getCol(), pawn);\n test.putPieceOnBoard(pawn_1.getRow(), pawn_1.getCol(), pawn_1);\n\n test.printBoard();\n // pawn 2,2 = 1\n // pawn 2,3 = 0\n // pawn -3, 0 = -1\n // pawn 1,3 = -2\n // pawn 0,3 = -4\n // pawn 3,3 = -3\n\n\n //(Pawn) pawn).isFirstMove = 0;\n\n // pawn[-1] 6,1 = -4\n // pawn[-1] 4,0 = 1\n // pawn[-1] 4,1 = 0\n // pawn[-1] 3,1 = 0\n int result = ((Pawn) pawn_1).judgeMove(3,1);\n\n System.out.println(\"result\"+result);\n\n Board test = new Board();\n Piece king1 = new King(1, new Position(2,2), test);\n Piece king2 = new King(-1, new Position(1,1), test);\n Piece king3 = new King(1, new Position(2,3), test);\n Piece queen = new Queen(-1, new Position(3,3), test);\n Piece queen1 = new Queen(1, new Position(3,1), test);\n\n Piece rook = new Rook(-1, new Position(1,2), test);\n\n test.putPieceOnBoard(king1.getRow(), king1.getCol(), king1);\n test.putPieceOnBoard(king2.getRow(), king2.getCol(), king2);\n test.putPieceOnBoard(king3.getRow(), king3.getCol(), king3);\n test.putPieceOnBoard(queen.getRow(), queen.getCol(), queen);\n test.putPieceOnBoard(queen1.getRow(), queen1.getCol(), queen1);\n test.putPieceOnBoard(rook.getRow(), rook.getCol(), rook);\n test.printBoard();\n\n // 2,2 = 1\n // 1,3 = 0\n // 1,5 = 0\n // -1,0 = -1\n // 1,2 = -2\n // 1,0 = -3\n // 0,0 = -4\n int result = ((Rook) rook).judgeMove(1,3);\n\n System.out.println(\"result\"+result);\n */\n\n /* test startingBoard()\n Board board = new Board();\n board.startingBoard();\n board.printBoard();\n */\n\n //test pawnThread();\n /*\n Board board = new Board();\n Piece kingwhite = new King(1, new Position(2,2), board);\n Piece kingblack = new King(-1, new Position(5,2), board);\n Piece king3 = new King(1, new Position(3,4), board);\n Piece p1 = new Pawn(1, new Position(4,1), board);\n Piece p2 = new Pawn(-1, new Position(4,3), board);\n Piece p3 = new Pawn(1, new Position(3,1), board);\n Piece p4 = new Pawn(-1, new Position(1,1), board);\n\n board.putPieceOnBoard(kingwhite.getRow(),kingwhite.getCol(),kingwhite);\n board.putPieceOnBoard(kingblack.getRow(),kingblack.getCol(),kingblack);\n board.putPieceOnBoard(king3.getRow(), king3.getCol(), king3);\n board.putPieceOnBoard(p1.getRow(), p1.getCol(), p1);\n board.putPieceOnBoard(p2.getRow(), p2.getCol(), p2);\n board.putPieceOnBoard(p3.getRow(), p3.getCol(), p3);\n board.putPieceOnBoard(p4.getRow(), p4.getCol(), p4);\n\n board.printBoard();\n // true\n System.out.println(board.pawnThread(-1*kingblack.getColor(),kingblack.getRow(),kingblack.getCol()));\n // false\n System.out.println(board.pawnThread(-1*kingwhite.getColor(),kingwhite.getRow(),kingwhite.getCol()));\n // true\n System.out.println(board.pawnThread(-1*king3.getColor(),king3.getRow(),king3.getCol()));\n */\n\n //test kingThread();\n /*\n Board board = new Board();\n Piece king1 = new King(1, new Position(2,2), board);\n Piece king2 = new King(-1, new Position(5,2), board);\n\n Piece p1 = new King(1, new Position(3,2), board);\n Piece p2 = new King(-1, new Position(5,1), board);\n Piece p3 = new King(1, new Position(4,1), board);\n Piece p4 = new King(1, new Position(4,3), board);\n\n\n board.putPieceOnBoard(king1.getRow(),king1.getCol(),king1);\n board.putPieceOnBoard(king2.getRow(),king2.getCol(),king2);\n board.putPieceOnBoard(p1.getRow(), p1.getCol(), p1);\n board.putPieceOnBoard(p2.getRow(), p2.getCol(), p2);\n board.putPieceOnBoard(p3.getRow(), p3.getCol(), p3);\n board.putPieceOnBoard(p4.getRow(), p4.getCol(), p4);\n board.printBoard();\n //false\n System.out.println(board.kingThread(-1*king1.getColor(),king1.getRow(),king1.getCol()));\n //true\n System.out.println(board.kingThread(-1*king2.getColor(),king2.getRow(),king2.getCol()));\n //true\n System.out.println(board.kingThread(-1*p4.getColor(),p4.getRow(),p4.getCol()));\n //false\n System.out.println(board.kingThread(-1*p1.getColor(),p1.getRow(),p1.getCol()));\n */\n\n\n //test knightThread();\n /*\n Board board = new Board();\n Piece k1 = new King(1, new Position(2,2), board);\n Piece k2 = new King(-1, new Position(5,2), board);\n Piece k3 = new King(-1, new Position(6,4), board);\n\n Piece p1 = new Knight(-1, new Position(0,3), board);\n Piece p2 = new Knight(-1, new Position(5,1), board);\n Piece p3 = new Knight(1, new Position(4,1), board);\n Piece p4 = new Knight(1, new Position(4,4), board);\n\n\n board.putPieceOnBoard(k1.getRow(),k1.getCol(),k1);\n board.putPieceOnBoard(k2.getRow(),k2.getCol(),k2);\n board.putPieceOnBoard(k3.getRow(),k3.getCol(),k3);\n board.putPieceOnBoard(p1.getRow(), p1.getCol(), p1);\n board.putPieceOnBoard(p2.getRow(), p2.getCol(), p2);\n board.putPieceOnBoard(p3.getRow(), p3.getCol(), p3);\n board.putPieceOnBoard(p4.getRow(), p4.getCol(), p4);\n board.printBoard();\n //true\n System.out.println(board.knightThread(-1*k1.getColor(),k1.getRow(),k1.getCol()));\n //true\n System.out.println(board.knightThread(-1*k2.getColor(),k2.getRow(),k2.getCol()));\n //false\n System.out.println(board.knightThread(-1*k3.getColor(),k3.getRow(),k3.getCol()));\n */\n\n //test bishopQueenThread();\n/*\n Board board = new Board();\n //board.bishopQueenThread(1, 3,4);\n\n Piece k1 = new King(1, new Position(2,2), board);\n Piece k2 = new King(-1, new Position(5,2), board);\n Piece k3 = new King(1, new Position(6,4), board);\n\n Piece p1 = new Bishop(-1, new Position(0,3), board);\n Piece p2 = new Bishop(-1, new Position(5,1), board);\n Piece p3 = new Bishop(1, new Position(3,0), board);\n Piece p4 = new Bishop(1, new Position(4,4), board);\n Piece p5 = new Bishop(-1, new Position(5,5), board);\n\n\n board.putPieceOnBoard(k1.getRow(),k1.getCol(),k1);\n board.putPieceOnBoard(k2.getRow(),k2.getCol(),k2);\n board.putPieceOnBoard(k3.getRow(),k3.getCol(),k3);\n board.putPieceOnBoard(p1.getRow(), p1.getCol(), p1);\n board.putPieceOnBoard(p2.getRow(), p2.getCol(), p2);\n board.putPieceOnBoard(p3.getRow(), p3.getCol(), p3);\n board.putPieceOnBoard(p4.getRow(), p4.getCol(), p4);\n board.putPieceOnBoard(p5.getRow(), p5.getCol(), p5);\n board.printBoard();\n //false\n System.out.println(board.bishopQueenThread(-1*k1.getColor(),k1.getRow(),k1.getCol()));\n //true\n System.out.println(board.bishopQueenThread(-1*k2.getColor(),k2.getRow(),k2.getCol()));\n //true\n System.out.println(board.bishopQueenThread(-1*k3.getColor(),k3.getRow(),k3.getCol()));\n */\n\n //test rookQueenThread\n\n /*\n Piece k1 = new King(1, new Position(2,2), board);\n Piece k2 = new King(1, new Position(5,2), board);\n Piece k3 = new King(-1, new Position(6,4), board);\n\n Piece p1 = new Rook(-1, new Position(0,3), board);\n Piece p2 = new Rook(-1, new Position(5,1), board);\n Piece p3 = new Rook(1, new Position(3,0), board);\n Piece p4 = new Rook(1, new Position(4,4), board);\n Piece p5 = new Rook(-1, new Position(5,5), board);\n\n\n board.putPieceOnBoard(k1.getRow(),k1.getCol(),k1);\n board.putPieceOnBoard(k2.getRow(),k2.getCol(),k2);\n board.putPieceOnBoard(k3.getRow(),k3.getCol(),k3);\n board.putPieceOnBoard(p1.getRow(), p1.getCol(), p1);\n board.putPieceOnBoard(p2.getRow(), p2.getCol(), p2);\n board.putPieceOnBoard(p3.getRow(), p3.getCol(), p3);\n board.putPieceOnBoard(p4.getRow(), p4.getCol(), p4);\n board.putPieceOnBoard(p5.getRow(), p5.getCol(), p5);\n board.printBoard();\n //false\n System.out.println(board.rookQueenThread(-1*k1.getColor(),k1.getRow(),k1.getCol()));\n //true\n System.out.println(board.rookQueenThread(-1*k2.getColor(),k2.getRow(),k2.getCol()));\n //true\n System.out.println(board.rookQueenThread(-1*k3.getColor(),k3.getRow(),k3.getCol()));\n */\n\n\n }", "private static boolean kingInKingSquare(BitBoard board, int side) {\n\t\tint myKingIndex = BitBoard.bitScanForward(board.getBitBoards()[12 + side]);\n\t\tint enemyKingIndex = BitBoard\n\t\t\t\t.bitScanForward(board.getBitBoards()[12 + ((side == 0) ? 1 : 0)]);\n\t\tif (((1L << myKingIndex) & CoreConstants.KING_TABLE[enemyKingIndex]) != 0) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}", "private void switchCaseFallThroughWorkaround1(List<Move> moves, int col, int row, Piece king) {\n for (int r = row, c = col; r != king.row.ordinal() || c != king.col.ordinal(); ) {\n // Kutsu funktiota joka tarkistaa voiko oman napin siirtää tähän kohtaan laudalla.\n checkOwnMovesToHere(moves, c, r, king);\n\n if (r > king.row.ordinal()) r--;\n else if (r < king.row.ordinal()) r++;\n\n if (c > king.col.ordinal()) c--;\n else if (c < king.col.ordinal()) c++;\n }\n }", "public Checker convertToKing(Checker checker, Move move) {\n\t\t int type = 0;\n\t\t if(checker.getType() == 1) {\n\t\t\t checker.setType(3);\n\t\t\t type = 3;\n\t\t } else if (checker.getType() == 2) {\n\t\t\t checker.setType(4);\n\t\t\t type = 4;\n\t\t }\n\t\t \n\t\t board.getBoard()[move.getyOrigin()][move.getxOrigin()] = 0;\n\t\tboard.getBoard()[move.getyMove()][move.getxMove()] = type;\n\t\t \n\t\treturn checker;\n\t\t \n\t\t \n\t }", "public void kingMe() {\r\n this.type = Type.KING;\r\n }", "@Test\n\tpublic void moveToOccupiedSpace() throws Exception {\n\t\tKing obstruction1 = new King(PieceColor.WHITE, 1, 5);\n\t\tKing obstruction2 = new King(PieceColor.BLACK, 5, 1);\n\t\tRook obstruction3 = new Rook(PieceColor.WHITE, 1, 1);\n\t\tQueen obstruction4 = new Queen(PieceColor.BLACK, 6, 5);\n\t\tgame.board.addPiece(obstruction1);\n\t\tgame.board.addPiece(obstruction2);\n\t\tgame.board.addPiece(obstruction3);\n\t\tgame.board.addPiece(obstruction4);\n\t\t\n\t\tgame.board.movePiece(knightCorner1White, 1, 5);\n\t\tgame.board.movePiece(knightCorner2Black, 5, 1);\n\t\tgame.board.movePiece(knightSide1White, 1, 1);\n\t\tgame.board.movePiece(knightSide2Black, 6, 5);\n\t\tassertEquals(knightCorner1White, game.board.getPiece(0, 7));\n\t\tassertEquals(knightCorner2Black, game.board.getPiece(7, 0));\n\t\tassertEquals(knightSide1White, game.board.getPiece(3, 0));\n\t\tassertEquals(knightSide2Black, game.board.getPiece(7, 3));\n\t}", "public void move(char way) {\n try {\n if (way == 'w'||way == 'W') { \n this.playerMoveUp();\n } else if (way == 'a'|| way == 'A') {\n this.playerMoveLeft();\n } else if (way == 'd' || way == 'D') {\n this.playerMoveRight();\n } else if (way == 's' || way == 'S') {\n this.playerMoveDown();\n }\n } catch (ArrayIndexOutOfBoundsException e) {\n System.out.println(\"hit edge!\");\n }\n\t}", "@Override\n public String makeAMove(int pressedHole) {\n if (isWhiteTurn && super.makeAMove(pressedHole) == \"White\") return \"White\";\n if (!isWhiteTurn) return makeAIMove();\n return null;\n }", "boolean makeMove(Bouger m) {\n\tlong oldBits[] = { pieceBits[LIGHT], pieceBits[DARK] };\n\n\tint from, to;\n\t/*\n\t* test to see if a castle move is legal and move the rook (the king is\n\t* moved with the usual move code later)\n\t*/\n\tif ((m.bits & 2) != 0) {\n\n\tif (inCheck(side))\n\treturn false;\n\tswitch (m.getTo()) {\n\tcase 62:\n\tif (color[F1] != EMPTY || color[G1] != EMPTY\n\t|| attack(F1, xside) || attack(G1, xside))\n\treturn false;\n\tfrom = H1;\n\tto = F1;\n\tbreak;\n\tcase 58:\n\tif (color[B1] != EMPTY || color[C1] != EMPTY\n\t|| color[D1] != EMPTY || attack(C1, xside)\n\t|| attack(D1, xside))\n\treturn false;\n\tfrom = A1;\n\tto = D1;\n\tbreak;\n\tcase 6:\n\tif (color[F8] != EMPTY || color[G8] != EMPTY\n\t|| attack(F8, xside) || attack(G8, xside))\n\treturn false;\n\tfrom = H8;\n\tto = F8;\n\tbreak;\n\tcase 2:\n\tif (color[B8] != EMPTY || color[C8] != EMPTY\n\t|| color[D8] != EMPTY || attack(C8, xside)\n\t|| attack(D8, xside))\n\treturn false;\n\tfrom = A8;\n\tto = D8;\n\tbreak;\n\tdefault: /* shouldn't get here */\n\tfrom = -1;\n\tto = -1;\n\tbreak;\n\t}\n\tcolor[to] = color[from];\n\tpiece[to] = piece[from];\n\tcolor[from] = EMPTY;\n\tpiece[from] = EMPTY;\n\tpieceBits[side] ^= (1L << from) | (1L << to);\n\t}\n\t/* back up information so we can take the move back later. */\n\n\tHistoryData h = new HistoryData();\n\th.m = m;\n\tto = m.getTo();\n\tfrom = m.getFrom();\n\th.capture = piece[to];\n\th.castle = castle;\n\th.ep = ep;\n\th.fifty = fifty;\n\th.pawnBits = new long[] { pawnBits[LIGHT], pawnBits[DARK] };\n\th.pieceBits = oldBits;\n\thistDat[hply++] = h;\n\n\t/*\n\t* update the castle, en passant, and fifty-move-draw variables\n\t*/\n\tcastle &= castleMask[from] & castleMask[to];\n\tif ((m.bits & 8) != 0) {\n\tif (side == LIGHT)\n\tep = to + 8;\n\telse\n\tep = to - 8;\n\t} else\n\tep = -1;\n\tif ((m.bits & 17) != 0)\n\tfifty = 0;\n\telse\n\t++fifty;\n\n\t/* move the piece */\n\tint thePiece = piece[from];\n\tif (thePiece == KING)\n\tkingSquare[side] = to;\n\tcolor[to] = side;\n\tif ((m.bits & 32) != 0) {\n\tpiece[to] = m.promote;\n\tpieceMat[side] += pieceValue[m.promote];\n\t} else\n\tpiece[to] = thePiece;\n\tcolor[from] = EMPTY;\n\tpiece[from] = EMPTY;\n\tlong fromBits = 1L << from;\n\tlong toBits = 1L << to;\n\tpieceBits[side] ^= fromBits | toBits;\n\tif ((m.bits & 16) != 0) {\n\tpawnBits[side] ^= fromBits;\n\tif ((m.bits & 32) == 0)\n\tpawnBits[side] |= toBits;\n\t}\n\tint capture = h.capture;\n\tif (capture != EMPTY) {\n\tpieceBits[xside] ^= toBits;\n\tif (capture == PAWN)\n\tpawnBits[xside] ^= toBits;\n\telse\n\tpieceMat[xside] -= pieceValue[capture];\n\t}\n\n\t/* erase the pawn if this is an en passant move */\n\tif ((m.bits & 4) != 0) {\n\tif (side == LIGHT) {\n\tcolor[to + 8] = EMPTY;\n\tpiece[to + 8] = EMPTY;\n\tpieceBits[DARK] ^= (1L << (to + 8));\n\tpawnBits[DARK] ^= (1L << (to + 8));\n\t} else {\n\tcolor[to - 8] = EMPTY;\n\tpiece[to - 8] = EMPTY;\n\tpieceBits[LIGHT] ^= (1L << (to - 8));\n\tpawnBits[LIGHT] ^= (1L << (to - 8));\n\t}\n\t}\n\n\t/*\n\t* switch sides and test for legality (if we can capture the other guy's\n\t* king, it's an illegal position and we need to take the move back)\n\t*/\n\tside ^= 1;\n\txside ^= 1;\n\tif (inCheck(xside)) {\n\ttakeBack();\n\treturn false;\n\t}\n\treturn true;\n\t}", "public static boolean moveking() //returns false if valid move is there\n{ System.out.println(\"IN FUNCTION MOVE KING.....\");\n flag=0;\n int kx,ky;\n if(q==2)\n {\n kx=p2.ka.kbx; //WHITE KING....\n ky=p2.ka.kby;\n } \nelse\n {\n kx=p1.ka.kax; //BLACK KING....\n\tky=p1.ka.kay;\n }\n//CHECKS WHETHER KING CAN MOVE TO THE 8 adjacent places...\n if(kx-1>=0)\n {\n move2(kx,ky,kx-1,ky);\n \n if(flag==1)\n {\n revert(kx,ky,kx-1,ky);\n return false;\n }\n }\n //r\n if(kx+1<=7)\n { move2(kx,ky,kx+1,ky);\n if(flag==1)\n {revert(kx,ky,kx+1,ky);\n return false;\n \n }\n }\n \n //u\n if(ky-1>=0)\n {\n move2(kx,ky,kx,ky-1);\n \n if(flag==1)\n {revert(kx,ky,kx,ky-1);\n return false;\n \n }\n }\n //d\n if(ky+1<=7)\n {\n move2(kx,ky,kx,ky+1);\n \n if(flag==1)\n { revert(kx,ky,kx,ky+1);\n return false;\n \n }\n }\n //lu\n if(kx-1>=0&&ky-1>=0)\n {\n move2(kx,ky,kx-1,ky-1);\n \n if(flag==1)\n {revert(kx,ky,kx-1,ky-1);\n return false;\n \n }\n }\n //ld\n if(kx-1>=0&&ky+1<=7)\n {\n move2(kx,ky,kx-1,ky+1);\n \n if(flag==1)\n {revert(kx,ky,kx-1,ky+1);\n return false;\n \n }\n }\n //ru\n if(kx+1<=7&&ky-1>=0)\n {\n move2(kx,ky,kx+1,ky-1);\n \n if(flag==1)\n {revert(kx,ky,kx+1,ky-1);\n return false;\n \n }\n }\n //rd\n if(kx+1<=7&&ky+1<=7)\n {\n move2(kx,ky,kx+1,ky+1);\n \n if(flag==1)\n {revert(kx,ky,kx+1,ky+1);\n return false;\n \n }\n }\n return true; \n }", "public void makeMove() {\n\t\tif (CheckForVictory(this)) {\n\t\t\t// System.out.println(\"VICTORY\");\n\t\t\tInterface.goalReached = true;\n\t\t\tfor (int i = 0; i < tmpStrings.length; i++) {\n\t\t\t\tif (moveOrder[i] == 0)\n\t\t\t\t\ttmpStrings[i] = \"turn left\";\n\t\t\t\telse if (moveOrder[i] == 1)\n\t\t\t\t\ttmpStrings[i] = \"turn right\";\n\t\t\t\telse\n\t\t\t\t\ttmpStrings[i] = \"go forward\";\n\n\t\t\t\tInterface.info.setText(\"Generation: \" + Parallel.generationNo + 1 + \" and closest distance to goal: \" + 0);\n\t\t\t}\n\t\t} else {\n\t\t\tmoveOrder[this.movesMade] = moves.remove();\n\t\t\tswitch (moveOrder[this.movesMade]) {\n\t\t\tcase (0):\n\t\t\t\tthis.movesMade++;\n\t\t\t\tif (face == 0)\n\t\t\t\t\tface = 3;\n\t\t\t\telse\n\t\t\t\t\tface--;\n\t\t\t\tbreak;\n\t\t\tcase (1):\n\t\t\t\tthis.movesMade++;\n\t\t\t\tif (face == 3)\n\t\t\t\t\tface = 0;\n\t\t\t\telse\n\t\t\t\t\tface++;\n\t\t\t\tbreak;\n\t\t\tcase (2):\n\t\t\t\tthis.movesMade++;\n\t\t\t\tif (face == 0 && Y - 1 >= 0)\n\t\t\t\t\tY--;\n\t\t\t\telse if (face == 1 && X + 1 <= map[0].length - 1)\n\t\t\t\t\tX++;\n\t\t\t\telse if (face == 2 && Y + 1 <= map.length - 1)\n\t\t\t\t\tY++;\n\t\t\t\telse if (face == 3 && X - 1 >= 0)\n\t\t\t\t\tX--;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tSystem.out.println(\"Error making move :(\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}", "@Override\n\tpublic void win() {\n\t\t\n\t\tfround[fighter1]++;\n\t fplatz[fighter1]=Math.round((float)fplatz[fighter1]/2); \n\t \n\t\tnextRound();\n\t}", "public List<Piece> inCheck(int kingX, int kingY){ // returns list of attacking pieces.\n // Also have to look for opponent king to avoid moving into check.\n // In this case only care whether or not a check occurs, not how many so breaks still ok\n // for regular check tests, want to know if 1 or 2 checks, cannot have multiple diagonal checks.\n List<Piece> attackers = new ArrayList<>();\n // knights\n int knight = turn == WHITE ? BLACK_KNIGHT : WHITE_KNIGHT;\n knightSearch:\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -2; dy <= 2; dy += 4){\n if (kingX + dx >= 0 && kingX + dx < 8 && kingY + dy >= 0 && kingY + dy < 8){\n if (board[kingY+dy][kingX+dx] == knight){\n attackers.add(new Piece(knight, kingX+dx, kingY+dy));\n break knightSearch; // can only be checked by 1 knight at a time\n }\n }\n if (kingX + dy >= 0 && kingX + dy < 8 && kingY + dx >= 0 && kingY + dx < 8){\n if (board[kingY+dx][kingX+dy] == knight){\n attackers.add(new Piece(knight, kingX+dy, kingY+dx));\n break knightSearch;\n }\n }\n }\n }\n // bishop/queen/pawn/king\n int pawn = turn == WHITE ? BLACK_PAWN : WHITE_PAWN;\n int bish = turn == WHITE ? BLACK_BISHOP : WHITE_BISHOP;\n int queen = turn == WHITE ? BLACK_QUEEN : WHITE_QUEEN;\n int king = turn == WHITE ? BLACK_KING : WHITE_KING;\n diagSearch:\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -1; dy <= 1; dy += 2){\n int i = 1;\n while (kingX + dx*i >= 0 && kingX + dx*i < 8 && kingY + dy*i >= 0 && kingY + dy*i < 8){\n int piece = board[kingY + dy*i][kingX + dx*i];\n if (piece != 0){\n if (piece == bish || piece == queen || (piece == pawn && i == 1 && dy == turn)\n || (piece == king && i == 1)){\n attackers.add(new Piece(piece, kingX+dx*i, kingY+dy*i));\n break diagSearch;\n }\n break;\n }\n i++;\n }\n }\n }\n // rook/queen/king\n int rook = turn == WHITE ? BLACK_ROOK : WHITE_ROOK;\n straightSearch:\n for (int dx = -1; dx <= 1; dx += 2){\n int i = 1;\n while (kingX + i*dx >= 0 && kingX + i*dx < 8){\n int piece = board[kingY][kingX + dx*i];\n if (piece != 0){\n if (piece == rook || piece == queen || (piece == king && i == 1)){\n attackers.add(new Piece(piece, kingX+dx*i, kingY));\n break straightSearch;\n }\n break;\n }\n i++;\n }\n i = 1;\n while (kingY + i*dx >= 0 && kingY + i*dx < 8){\n int piece = board[kingY+dx*i][kingX];\n if (piece != 0){\n if (piece == rook || piece == queen || (piece == king && i == 1)){\n attackers.add(new Piece(piece, kingX, kingY+dx*i));\n break straightSearch;\n }\n break;\n }\n i++;\n }\n }\n return attackers;\n }", "@Test\n public void kingTest() {\n assertTrue(!red_piece.isKing());\n red_piece.king();\n assertTrue(red_piece.isKing());\n assertTrue(!white_piece.isKing());\n }", "static void moving() throws GameActionException {\n\n\t\tcheckLumberjack();\n\n\t\trc.setIndicatorLine(myLocation, myLocation.add(robotDirection), 0, 0, 0);\n\n\t\tif (rc.canBuildRobot(RobotType.SCOUT, robotDirection)\n\t\t\t\t&& rc.readBroadcast(Channels.COUNT_SCOUT) < Constants.MAX_COUNT_SCOUT) {\n\t\t\trc.buildRobot(RobotType.SCOUT, robotDirection);\n\t\t\tCommunication.countMe(RobotType.SCOUT);\n\t\t\treturn;\n\t\t}\n\t\t// } else if (rc.canBuildRobot(RobotType.SOLDIER, buildDirection) &&\n\t\t// rc.readBroadcast(Channels.COUNT_SOLDIER) <\n\t\t// Constants.MAX_COUNT_SOLDIER) {\n\t\t// rc.buildRobot(RobotType.SOLDIER, buildDirection);\n\t\t// Communication.countMe(RobotType.SOLDIER);\n\t\t// return;\n\t\t// }\n\n\t}", "public Castling(King king, Rook rook, boolean isShortCastling, int x, int y) {\n super(king, x, y);\n this.rook = rook;\n this.isShortCastling = isShortCastling;\n }", "public boolean move(int x, int y, CheckersBoard board) {\n if (whiteTurn == true && team == Constants.TeamId.team1Id) {\n return false;\n }\n if (whiteTurn == false && team == Constants.TeamId.team2Id) {\n return false;\n }\n /**\n * then change the x - y coords of the piece\n * update the UI to remove the highlighted squares then move the piece\n * if chess and shared square you take a piece\n * if checkers you jumped them you take the piece\n * return new x - y components\n *\n * if this is too high up in the tree you can override this implementation or update it\n * to fit specific pieces if its not working for some reason\n */\n if (possible(x, y, gameBoard)) {\n int changex = this.getX()-x;\n int changey = this.getY()-y;\n CheckersPiece temp = gameBoard.boardPositions[getX()][getY()];\n gameBoard.boardPositions[getX()][getY()] = null;\n gameBoard.boardPositions[x][y] = temp;\n if (gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2] != null) {\n System.out.println(\"Here\");\n if (gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2].team != this.team) {\n gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2].imageView.setVisibility(View.GONE);\n gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2] = null;\n }\n }\n this.setX(x);\n this.setY(y);/*\n if (Math.abs(changex) == 2) {\n gameBoard.boardPositions[x + (changex/2)][y + (changey/2)] = null;\n if (team == Constants.TeamId.team1Id) {\n board.numPieces1--;\n } else if (team == Constants.TeamId.team2Id) {\n board.numPieces0--;\n }\n }*/\n\n gameBoard.boardPositions[x][y].imageView.setX(142*x);\n gameBoard.boardPositions[x][y].imageView.setY(142*y);\n // flips after move is\n whiteTurn = !whiteTurn;\n gameBoard.startTimer();\n }\n //setUpUI(gameBoard);\n if (getY() == 7 && team == Constants.TeamId.team2Id) {\n board.crown(this);\n }\n if (getY() == 0 && team == Constants.TeamId.team1Id) {\n board.crown(this);\n }\n return possible(x, y, gameBoard);\n }", "private void goAcrossWall() {\n\t\t// TODO Auto-generated method stub\n\t\tthis.move();\n\t\tthis.turnRight();\n\t}", "@Test\n\tpublic void testIfKingHasLostNearThrone()\n\t{\n\t\tData d = new Data();\n\t\td.set(9, 10); // move 9th white piece to the 10th square\n\t\td.set(10, 9); // move 10th white piece to the 9th square\n\t\td.set(11, 12); // move 11th white piece to the 12th square\n\t\td.set(12, 14); // move 12th white piece to the 14th square\n\t\td.set(14, 71); // set a black piece to square 71\n\t\td.set(15, 73); // set a black piece to square 73\n\t\td.set(16, 83); //set a black piece to square 83, i.e. one below the king\n\t\n\t\t\n\t\tassertTrue(d.kingLost(72)); // a square below the throne is 72\n\t}", "void animalMove(int x,int y, Living[][] map,int gridLength, int gridWidth){\r\n \r\n boolean age=map[x][y].getAge();\r\n boolean gender=map[x][y].getGender();\r\n boolean checkRight=false;\r\n boolean checkLeft=false;\r\n boolean checkUp=false;\r\n boolean checkDown=false;\r\n boolean up=false;\r\n boolean down=false;\r\n boolean right=false;\r\n boolean left=false;\r\n boolean baby=false;\r\n boolean turn=map[x][y].getMovement(); //Check to see if it moved before in the array\r\n \r\n double random=Math.random();\r\n \r\n \r\n \r\n \r\n //Checks to see if it is possible to even see to the left first\r\n if(y-1>=0){\r\n left=true;\r\n \r\n if(turn && (map[x][y-1] instanceof Plant) ){ //Check to see if there is plants and goes to plants\r\n map[x][y].gainHealth((map[x][y-1].getHealth()));\r\n map[x][y].setMovement(false); \r\n map[x][y-1]=map[x][y];\r\n map[x][y]=null;\r\n turn=false; \r\n }\r\n if(turn && (map[x][y-1] instanceof Sheep) && (age==map[x][y-1].getAge()) ){ \r\n //If the ages match they must be false to be adults and both be opposite genders\r\n if(turn && !(age) && !(gender==map[x][y-1].getGender()) && (map[x][y].getHealth()>19) && (map[x][y-1].getHealth()>19) ){\r\n \r\n //Success rate of conceiving\r\n if( (Math.random()<=0.85) ){ \r\n \r\n if( (x+1<gridLength) && (map[x+1][y]==null)&& !(baby) ){ //Following ifs check to see if a baby can be made surrounding the intitiating sheep\r\n map[x+1][y]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true; \r\n }\r\n \r\n if( (x-1>=0) && (map[x-1][y]==null)&& !(baby) ){\r\n map[x-1][y]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n if((y+1<gridLength) && (map[x][y+1]==null) && !(baby) ){\r\n map[x][y+1]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n if(baby){ //If baby is made then sheep will lose health and turn is therefore over \r\n map[x][y].lowerHealth(10);\r\n map[x][y-1].lowerHealth(10);\r\n map[x][y].setMovement(false);\r\n map[x][y-1].setMovement(false);\r\n turn=false;\r\n baby=false;\r\n }\r\n }\r\n } \r\n }\r\n //If it can move to the left need to check if it can foresee more incase there wasn't any place for it to go\r\n if(y-2>=0){\r\n checkLeft=true;\r\n }\r\n }\r\n \r\n //Checks to see if it is possible to even see to the right first \r\n if(y+1<gridWidth){\r\n right=true;\r\n \r\n //Check to move on towards plants\r\n if(turn && (map[x][y+1] instanceof Plant)){\r\n map[x][y].gainHealth(map[x][y+1].getHealth()); \r\n map[x][y].setMovement(false); \r\n map[x][y+1]=map[x][y];\r\n map[x][y]=null;\r\n turn=false; \r\n }\r\n \r\n if(turn && (map[x][y+1] instanceof Sheep && age==map[x][y+1].getAge()) ){ \r\n //If the ages match they must be false to be adults and both be opposite genders\r\n if(turn && !(age) && !(gender==map[x][y+1].getGender()) && (map[x][y].getHealth()>19) && (map[x][y+1].getHealth()>19) ){\r\n \r\n //Success rate of conceiving\r\n if( (Math.random()<=0.85) ){\r\n \r\n if( (x+1<gridLength) && (map[x+1][y]==null) && !(baby) ){ //Following ifs check to see if a baby can be made surrounding the intitiating sheep\r\n \r\n map[x+1][y]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true; \r\n }\r\n \r\n if( (x-1>=0) && (map[x-1][y]==null) && !(baby) ){\r\n map[x-1][y]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n if( (y-1>=0) && (map[x][y-1]==null) && !(baby) ){\r\n map[x][y-1]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n if(baby){ //If baby is made then sheeps will lose health and turn is therefore over \r\n map[x][y].lowerHealth(10);\r\n map[x][y+1].lowerHealth(10);\r\n map[x][y].setMovement(false);\r\n map[x][y+1].setMovement(false);\r\n turn=false; \r\n baby=false;\r\n }\r\n }\r\n } \r\n }\r\n \r\n //If it can move to the right need to check if it can foresee more incase there wasn't any place for it to go\r\n if(y+2<gridWidth){ \r\n checkRight=true;\r\n }\r\n } \r\n \r\n //Check to see if it can go up\r\n if(x-1>=0){\r\n up=true;\r\n \r\n //Check for plant to go on to upwards \r\n if(turn && (map[x-1][y] instanceof Plant) ){\r\n map[x][y].gainHealth(map[x-1][y].getHealth()); \r\n map[x][y].setMovement(false); \r\n map[x-1][y]=map[x][y];\r\n map[x][y]=null;\r\n turn=false;\r\n }\r\n \r\n if(turn && (map[x-1][y] instanceof Sheep) && (age==map[x-1][y].getAge()) ){ \r\n //If the ages match age must be false to be adults and both be opposite genders and have more then 19 health\r\n if(turn && !age && !(gender==map[x-1][y].getGender()) &&map[x][y].getHealth()>19 &&map[x-1][y].getHealth()>19){\r\n \r\n //Success rate of conceiving\r\n if( (Math.random()<=0.85) ){\r\n if( (y+1<gridLength) && (map[x][y+1]==null) && !(baby) ){ //Following ifs check to see if a baby can be made surrounding the intitiating sheep\r\n \r\n map[x][y+1]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true; \r\n }\r\n if( (y-1>=0) && (map[x][y-1]==null) && !(baby) ){\r\n map[x][y-1]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n \r\n if( (x+1<gridLength) && (map[x+1][y]==null) && !(baby) ){\r\n map[x+1][y]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n \r\n if(baby){ //If baby is made then sheep will lose health and turn is therefore over \r\n map[x][y].lowerHealth(10);\r\n map[x-1][y].lowerHealth(10);\r\n map[x][y].setMovement(false);\r\n map[x-1][y].setMovement(false);\r\n turn=false; \r\n baby=false;\r\n }\r\n }\r\n } \r\n }\r\n \r\n //If it can move to upwards need to check if it can foresee more incase there wasn't any place for it to go\r\n if(x-2>=0){\r\n checkUp=true; \r\n }\r\n } \r\n //Check to see where to go downwards\r\n if(x+1<gridLength){\r\n down=true; \r\n \r\n //Check to see if any plants are downwards\r\n if(turn && (map[x+1][y] instanceof Plant) ){\r\n map[x][y].gainHealth( (map[x+1][y].getHealth()));\r\n map[x][y].setMovement(false);\r\n map[x+1][y]=map[x][y];\r\n map[x][y]=null;\r\n turn=false;\r\n } \r\n \r\n if(turn && (map[x+1][y] instanceof Sheep) && (age==map[x+1][y].getAge()) ){ \r\n \r\n //If the ages match they must be false to be adults and both be opposite genders\r\n if(turn && !(age) && !(gender==map[x+1][y].getGender()) && (map[x][y].getHealth()>=20) && (map[x+1][y].getHealth()>=20) ){\r\n \r\n //Success rate of conceiving\r\n if( (Math.random()<=0.85) ){\r\n if( (y+1<gridLength) && (map[x][y+1]==null) && !(baby) ){ //Following ifs check to see if a baby can be made surrounding the intitiating sheep \r\n map[x][y+1]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true; \r\n }\r\n if( (y-1>=0) && (map[x][y-1]==null) && !(baby) ){\r\n map[x][y-1]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n if( (x-1>=0) && (map[x+1][y]==null) && !(baby) ){\r\n map[x-1][y]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n if(baby){ //If baby is made then sheep will lose health and turn is therefore over \r\n map[x][y].lowerHealth(10);\r\n map[x+1][y].lowerHealth(10);\r\n map[x][y].setMovement(false);\r\n map[x+1][y].setMovement(false);\r\n turn=false;\r\n baby=false;\r\n }\r\n }\r\n } \r\n } \r\n if(x+2<gridLength){\r\n checkDown=true;\r\n }\r\n } \r\n \r\n //Movement towards plant only if no immediate sheep/plants are there to move to\r\n if(turn && checkRight && (map[x][y+2] instanceof Plant) ){\r\n if(map[x][y+1]==null){\r\n \r\n map[x][y+1]=map[x][y];\r\n map[x][y]=null;\r\n map[x][y+1].setMovement(false);\r\n turn=false;\r\n }\r\n }\r\n if(turn && checkDown && (map[x+2][y] instanceof Plant) ){\r\n if(map[x+1][y]==null){\r\n map[x+1][y]=map[x][y];\r\n map[x][y]=null;\r\n map[x+1][y].setMovement(false);\r\n turn=false;\r\n }\r\n } \r\n if(turn && checkUp && (map[x-2][y] instanceof Plant) ){\r\n if(map[x-1][y]==null){\r\n \r\n map[x-1][y]=map[x][y];\r\n map[x][y]=null;\r\n map[x-1][y].setMovement(false);\r\n turn=false;\r\n }\r\n }\r\n \r\n if(turn && checkLeft && (map[x][y-2] instanceof Plant) ){\r\n if(map[x][y-1]==null){\r\n map[x][y-1]=map[x][y];\r\n map[x][y]=null;\r\n map[x][y-1].setMovement(false);\r\n turn=false;\r\n }\r\n }\r\n \r\n //Random Movement if there are no plants to move towards \r\n if(turn && right && (random<=0.2) ){\r\n if(map[x][y+1]==null){\r\n map[x][y].setMovement(false);\r\n map[x][y+1]=map[x][y];\r\n map[x][y]=null; \r\n }\r\n }\r\n if(turn && left && (random>0.2) && (random<=0.4) ){\r\n if(map[x][y-1]==null){\r\n map[x][y].setMovement(false);\r\n map[x][y-1]=map[x][y];\r\n map[x][y]=null;\r\n }\r\n }\r\n if(turn && up && (random>0.4) && (random<=0.6) ){\r\n if(map[x-1][y]==null){\r\n map[x][y].setMovement(false);\r\n map[x-1][y]=map[x][y];\r\n map[x][y]=null;\r\n }\r\n }\r\n if(turn && down && (random>0.6) && (random<=0.8) ){\r\n if(map[x+1][y]==null){\r\n map[x][y].setMovement(false);\r\n map[x+1][y]=map[x][y];\r\n map[x][y]=null;\r\n }\r\n }\r\n }", "public void makeMove(Move m) {\n \tPieceColor moved = m.getSource().getColor();\n\n \t//before the move is made, record the move in the movelist\n \tupdateMoveList(m);\n \t\n \t//store locations\n \tint sx = m.getSource().getLocation().getX();\n \tint sy = m.getSource().getLocation().getY();\n \tint dx = m.getDest().getLocation().getX();\n \tint dy = m.getDest().getLocation().getY();\n \tString name_moved = m.getSource().getName();\n \t\n \t//store new king location if it moved\n \tif(name_moved.equals(\"King\")) {\n \t\tif(moved == PieceColor.White) {\n \t\t\twKing = m.getDest().getLocation();\n \t\t\t\n \t\t\t//remove castle rights on both sides\n \t\t\tcastle[0] = false;\n \t\t\tcastle[1] = false;\n \t\t}\n \t\telse if(moved == PieceColor.Black) {\n \t\t\tbKing = m.getDest().getLocation();\n \t\t\t\n \t\t\t//remove castle rights on both sides\n \t\t\tcastle[2] = false;\n \t\t\tcastle[3] = false;\n \t\t}\n \t\telse System.exit(0);\n \t}\n \t\n \t//rook check for castling rights\n \tif(name_moved.equals(\"Rook\")) {\n \t\tif(moved == PieceColor.White) {\n \t\t\tif(sx == 0 && sy == 0) removeCastle(moved, false);\n \t\t\tif(sx == 7 && sy == 0) removeCastle(moved, true);\n \t\t}\n \t\t\n \t\telse if(moved == PieceColor.Black) {\n \t\t\tif(sx == 0 && sy == 7) removeCastle(moved, false);\n \t\t\tif(sx == 7 && sy == 7) removeCastle(moved, true);\n \t\t}\n \t}\n \t\n \tPiece temp = getPiece(sx, sy);\n \t\n \tsetPiece(sx, sy, new NoPiece(sx, sy));\n \t\n \tif(temp.getName().equals(\"Pawn\") && ((Pawn)temp).getPromo() == dy) {\n \t\ttemp = new Queen(dx, dy, temp.getColor(), this);\n \t}\n \t\n \t\n \ttemp.setLocation(new Square(dx, dy));\n \t\n \t//check for en passant\n \tif(name_moved.equals(\"Pawn\")) {\n \t\tint loc = ((Pawn)temp).advance();\n \t\t((Pawn)temp).setMoved(moveList.size());\n \t\t\n \t\t//only a valid en passant move if the pawn moves diagonally\n \t\t//and the destination square is empty\n \t\tif(sx != dx && getPiece(dx, dy).getName().equals(\"None\")) {\n \t\t\tsetPiece(dx, dy-loc, new NoPiece(dx, dy-loc));\n \t\t}\n \t}\n \t\n \tsetPiece(dx, dy, temp);\n \t\n \tif(turn == PieceColor.White) turn = PieceColor.Black;\n \telse turn = PieceColor.White;\n \t\n \t//check if the move was a castle\n \tif(name_moved.equals(\"King\")) {\n \t\t\n \t\tif(moved == PieceColor.White) { \n\t \t\t//if king moved positive x, then moved king side\n\t \t\tif(dx - sx == 2) {\n\t \t\t\ttemp = getPiece(7, 0);\n\t \t\t\tsetPiece(7, 0, new NoPiece(7, 0));\n\t \t\t\t\n\t \t\t\ttemp.setLocation(new Square(5,0));\n\t \t\t\tsetPiece(5, 0, temp);\n\t \t\t}\n\t \t\t\n\t \t\telse if(sx - dx == 2) {\n\t \t\t\ttemp = getPiece(0, 0);\n\t \t\t\tsetPiece(0, 0, new NoPiece(0, 0));\n\t \t\t\t\n\t \t\t\ttemp.setLocation(new Square(3, 0));\n\t \t\t\tsetPiece(3, 0, temp);\n\t \t\t}\n \t\t}\n \t\t\n \t\tif(moved == PieceColor.Black) { \n\t \t\t//if king moved positive x, then moved king side\n\t \t\tif(dx - sx == 2) {\n\t \t\t\ttemp = getPiece(7, 7);\n\t \t\t\tsetPiece(7, 7, new NoPiece(7, 7));\n\t \t\t\t\n\t \t\t\ttemp.setLocation(new Square(5, 7));\n\t \t\t\tsetPiece(5, 7, temp);\n\t \t\t}\n\t \t\t\n\t \t\telse if(sx - dx == 2) {\n\t \t\t\ttemp = getPiece(0, 7);\n\t \t\t\tsetPiece(0, 7, new NoPiece(0, 7));\n\t \t\t\t\n\t \t\t\ttemp.setLocation(new Square(3, 7));\n\t \t\t\tsetPiece(3, 7, temp);\n\t \t\t}\n \t\t}\n \t}\n }", "@Test\n\tpublic void kingSWC() \n\t{\n\t\tData d = new Data();\n\t\td.set(19, 35);\n\t\td.set(21, 46);\n\t\td.set(23, 89);\n\t\td.set(27, 68);\n\t\td.set(29, 79);\n\t\td.set(0, 34);\n\t\td.set(2, 45);\n\t\td.set(3, 56);\n\t\td.set(4, 67);\n\t\td.set(5, 78);\n\t\td.set(31, 23);\n\t\tArrayList<Coordinate> test_arr = d.shieldWallCapture(23);\n\t\tassertTrue(0==test_arr.get(0).getX() && 4==test_arr.get(0).getY()\n\t\t\t&& 0==test_arr.get(1).getX() && 5==test_arr.get(1).getY()\n\t\t\t&& 0==test_arr.get(2).getX() && 6==test_arr.get(2).getY()\n\t\t\t&& 0==test_arr.get(3).getX() && 7==test_arr.get(3).getY());\n\t}", "public void setKing() {\n this.isKing = true;\n\n this.setupPiece();\n }", "private static void GideonsMove() {\r\n\t\tPrint print = new Print();\r\n\t\tprint.board(game);\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Prints the entire gameBoard.\r\n\t\t\r\n\t\tboolean flag = true;\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//true = Gideon's move | false = user's move\r\n\t\t\r\n\t\tArrayList<Integer> moves = MoveGenerator.Gen(flag, gamePieces);\t\t\t\t\t\t\t//returns all the legal moves possible to make by the player.\r\n\t\tPrint.moves(moves);\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Prints all the moves returned by the Gen method.\r\n\t\t\r\n\t\t//System.out.println(\"\\n\\n Gideon will play......\" \r\n\t\t\t\t\t\t//+\"Feature coming soon, until then keep practicing\\n\");\r\n\t\t \r\n\t\tMiniMax minimax = new MiniMax(game, moves);\t\t\t\t\t\t\t\t\t\t\t\t//Declaring and initializing MiniMax object with parameters game and moves\r\n\r\n\t\tif(moves.size() < 6) {\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Will increment the MiniMax MAX_DEPTH size by 1 if the legal moves are less than 6\r\n\t\t\tminimax.incrementMAX_DEPTH();\r\n\t\t}\r\n\t\t\r\n\t\tlong start_time = System.nanoTime();\t\t\t\t\t\t\t\t\t\t\t\t\t//Time before starting MiniMax\r\n\t\t\r\n\t\tString gideonsMove = minimax.start();\t\t\t\t\t\t\t\t\t\t\t\t\t//Starting MiniMax\r\n\t\r\n\t\tdouble elapsed = System.nanoTime()-start_time;\t\t\t\t\t\t\t\t\t\t\t//Total time taken by MiniMax=Time after MiniMax is finished-Time before MiniMax was started\r\n\t elapsed=elapsed/1000000000;\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Converting to seconds\r\n\t \r\n\t\tSystem.out.print(\"\\n\\n Gideon's move: \"+\r\n\t\t\t\tGideonsMoveConvertor.convert(gideonsMove)+\"\\n\\n\");\t\t\t\t\t\t\t\t//Changing GideonsMove to A1B2 format\r\n\t\t\r\n\t\tUpdateBoard boardUpdater = new UpdateBoard();\r\n\t\t\r\n\t\tgame = boardUpdater.playMove(gideonsMove, game, gamePieces, flag, false, true);\t\t\t//Executing the legal move on the gameBoard\r\n\t\tgamePieces = game.getGamePiecesArray();\t\t\t\t\t\t\t\t\t\t\t\t\t//Getting the updated copy of the Game Pieces Array\r\n\t\tgame.updateGameBoard();\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Updating the String copy of the game board (required to print the updated gameBoard)\r\n\t\t\r\n\t\tSystem.out.println(\"Depth used for this iteration --> \"+minimax.getMAX_DEPTH());\t\t//Printing the MAX_DEPTH used by MiniMax to calculate the best move\r\n\t\tSystem.out.println(\"Time Taken for MiniMax --> \"+elapsed);\t\t\t\t\t\t\t\t//Printing time taken by MiniMax to calculate the best move\r\n\t\tSystem.out.println(\"\\n ========================\");\r\n\t\tplayersMove();\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Player's turn to make a move\r\n\t\t\r\n\t}", "public abstract void process(final King pKing, final Piece pPiece, final Chess pChess);", "public void setKing(PieceColor color, Square sq) {\n \tif(color == PieceColor.White) wKing = sq;\n \telse if(color == PieceColor.Black) bKing = sq;\n }", "public boolean canCastle(int direction){\n\t\tPiece rook;\n\t\t\n\t\tif(!((getColor().equals(\"White\") && getSquare().getCol() == 4 && getSquare().getRow() == 7 ) ||\n\t\t\t\t(getColor().equals(\"Black\") && getSquare().getCol() == 4 && getSquare().getRow() == 0 )))\n\t\t\treturn false;\n\t\t\n\t\t\n\t\tif(direction == 1){\n\t\t\trook = getSquare().getEast().getEast().getEast().getOccupant();\n\t\t\tif(rook == null || !rook.getColor().equals(this.getColor()) || !rook.getType().equals(\"Rook\") || rook.hasMoved() || this.hasMoved())\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getEast().getEast().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getEast().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\t\n\t\t\tif(getColor().equals(\"White\")){\n\t\t\t\tfor(int i = 0; i < ChessBoard.getPieces().size(); i++){\n\t\t\t\t\tif(ChessBoard.getPieces().get(i).getColor().equals(\"Black\"))\n\t\t\t\t\t\tfor(int location: ChessBoard.getPieces().get(i).getMoves()){\n\t\t\t\t\t\t\tif(location == 75 || location == 76){\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tfor(int i = 0; i < ChessBoard.getPieces().size(); i++){\n\t\t\t\t\tif(ChessBoard.getPieces().get(i).getColor().equals(\"White\"))\n\t\t\t\t\t\tfor(int location: ChessBoard.getPieces().get(i).getMoves()){\n\t\t\t\t\t\t\tif(location == 5 || location == 6){\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\t\n\t\t}\n\t\t\n\t\telse if (direction == -1){//East\n\t\t\trook = getSquare().getWest().getWest().getWest().getWest().getOccupant();\n\t\t\tif(rook == null || !rook.getColor().equals(this.getColor()) || !rook.getType().equals(\"Rook\") || rook.hasMoved() || this.hasMoved())\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getWest().getWest().getWest().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getWest().getWest().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getWest().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\t\n\t\t\tif(getColor().equals(\"White\")){\n\t\t\t\tfor(int i = 0; i < ChessBoard.getPieces().size(); i++){\n\t\t\t\t\tif(ChessBoard.getPieces().get(i).getColor().equals(\"Black\"))\n\t\t\t\t\t\tfor(int location: ChessBoard.getPieces().get(i).getMoves()){\n\t\t\t\t\t\t\tif(location == 73 || location == 72 || location == 71){\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\telse{\n\t\t\t\tfor(int i = 0; i < ChessBoard.getPieces().size(); i++){\n\t\t\t\t\tif(ChessBoard.getPieces().get(i).getColor().equals(\"White\"))\n\t\t\t\t\t\tfor(int location: ChessBoard.getPieces().get(i).getMoves()){\n\t\t\t\t\t\t\tif(location == 3 || location == 2 || location == 1){\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn true;\n\t}", "public void turnSmaround()\n { \n Wall w= (Wall)getOneIntersectingObject(Wall.class);\n wX=w.getX();\n wY=w.getY();\n }", "@Test\n public void testKingSide() {\n // initialize the complete chess board\n ChessBoard chessBoard = init(\"CHESS\");\n\n assertEquals(north, chessBoard.getPiece(0, 4).getSide());\n assertEquals(south, chessBoard.getPiece(7, 4).getSide());\n }", "public void updatePossibleMovesOther(){\n\t\tif( hasMoved){\n\t\t\tpossibleMovesOther = null;\n\t\t\treturn;\n\t\t}\n\t\t// Get left castle updateMoves first\n\t\tchar[] temp = AlgebraicNotationHelper.getAlgebraicNotationLeftOf( startingFile, startingRank);\n\t\ttemp = AlgebraicNotationHelper.getAlgebraicNotationLeftOf( temp[0], temp[1]);\n\t\ttemp = AlgebraicNotationHelper.getAlgebraicNotationLeftOf( temp[0], temp[1]);\n\t\t// Should be b1 for light color King (or b8 for dark color King)\n\t\tAlgebraicNotation tempAN = new AlgebraicNotation( temp[0], temp[1]);\n\t\tpossibleMovesOther.add( tempAN);\n\t\t// Get right castle updateMoves next\n\t\ttemp = AlgebraicNotationHelper.getAlgebraicNotationRightOf( startingFile, startingRank);\n\t\ttemp = AlgebraicNotationHelper.getAlgebraicNotationRightOf( temp[0], temp[1]);\n\t\t// Should be g1 for light color King (or g8 for dark color King)\n\t\ttempAN = new AlgebraicNotation( temp[0], temp[1]);\n\t\tpossibleMovesOther.add( tempAN);\t\n\t}", "private void moveAllignedMhos() {\n\n\t\t//Assign playerX and playerY to the X and Y of the player\n\t\tint playerX = getNewPlayerLocation()[0];\n\t\tint playerY = getNewPlayerLocation()[1];\n\n\t\t//Iterate through every mho's X and Y values\n\t\tfor(int i = 0; i < mhoLocations.size()/2; i++) {\n\n\t\t\t//Assign mhoX and mhoY to the X and Y values of the mho that is currently being tested\n\t\t\tint mhoX = mhoLocations.get(i*2);\n\t\t\tint mhoY = mhoLocations.get(i*2+1);\n\n\t\t\t//set the default X and Y offsets to 0, and the move to NO_MOVEMENT\n\t\t\tint xOffset = 0;\n\t\t\tint yOffset = 0;\n\t\t\tchar move = Legend.NO_MOVEMENT;\n\n\t\t\t//Check if the playerX is equal to mhoX (aligned on x-axis)\n\t\t\tif(playerX == mhoX) {\n\n\t\t\t\t//Check which direction the mho would have to move, and assign the corresponding move and yOffset\n\t\t\t\tif(playerY > mhoY) {\n\t\t\t\t\tyOffset = 1;\n\t\t\t\t\tmove = Legend.DOWN;\n\t\t\t\t} else {\n\t\t\t\t\tyOffset = -1;\n\t\t\t\t\tmove = Legend.UP;\n\t\t\t\t}\n\t\t\t} else if(playerY == mhoY) {\n\n\t\t\t\t//Check which direction the mho would have to move, and assign the corresponding move and XOffset\n\t\t\t\tif(playerX > mhoX) {\n\t\t\t\t\txOffset = 1;\n\t\t\t\t\tmove = Legend.RIGHT;\n\t\t\t\t} else {\n\t\t\t\t\txOffset = -1;\n\t\t\t\t\tmove = Legend.LEFT;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//Only move if the new location is not an instance of mho (in order to make sure they are moved in the right order)\n\t\t\tif(!(newMap[mhoX+xOffset][mhoY+yOffset] instanceof Mho)) {\n\n\t\t\t\t//Set the previous location to a BlankSpace\n\t\t\t\tnewMap[mhoX][mhoY] = new BlankSpace(mhoX, mhoY, board);\n\n\t\t\t\t//If the new square would be a player, end the game\n\t\t\t\tif(newMap[mhoX+xOffset][mhoY+yOffset] instanceof Player) {\n\t\t\t\t\tmoveList[mhoX+xOffset][mhoY+yOffset] = Legend.SHRINK;\n\t\t\t\t\tgameOver();\n\t\t\t\t}\n\n\t\t\t\t//If the new square would be a fence, remove the mho from the map\n\t\t\t\tif(!(newMap[mhoX+xOffset][mhoY+yOffset] instanceof Fence)) {\n\t\t\t\t\tnewMap[mhoX+xOffset][mhoY+yOffset] = new Mho(mhoX+xOffset, mhoY+yOffset, board);\n\t\t\t\t} else {\n\t\t\t\t\tmove = Legend.SHRINK;\n\t\t\t\t}\n\n\t\t\t\t//Set the move of the mho on moveList\n\t\t\t\tmoveList[mhoX][mhoY] = move;\n\n\t\t\t\t//remove the mhoX and mhoY in mhoLocations\n\t\t\t\tmhoLocations.remove(i*2+1);\n\t\t\t\tmhoLocations.remove(i*2);\n\n\t\t\t\t//Call moveAllignedMhos() again, because the list failed to be checked through completely\n\t\t\t\tmoveAllignedMhos();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}", "@Override\n public void drawValidMove() {\n if(this.getPlayer().getPlayerID() % 2 != 0) {\n //Pawn can move one space forwards if no piece is in front\n if (board.getSquare(x-1, y).getPiece()== null) {\n board.getSquare(x-1, y).drawOutline();\n }\n \n //if first move, pawn can move 2 spaces forward\n if (!hasMoved && board.getSquare(x-2, y).getPiece() == null && board.getSquare(x-1, y).getPiece() == null) {\n board.getSquare(x-2, y).drawOutline();\n }\n \n //If there is an enemy piece in the diagonal forward square of the pawn, the pawn can move (capture the piece)\n if (y-1 > 0) { //ensures no arrayoutofbounds error\n if (board.getSquare(x-1, y-1) != null && board.getSquare(x-1, y-1).getPiece() != null &&\n board.getSquare(x-1, y-1).getPiece().getPlayer() != this.getPlayer()) {\n board.getSquare(x-1, y-1).drawOutline();\n }\n }\n \n if(y+1<SIZE) { //ensures no arrayoutofbounds error\n if (board.getSquare(x-1, y+1) != null && board.getSquare(x-1, y+1).getPiece() != null &&\n board.getSquare(x-1, y+1).getPiece().getPlayer() != this.getPlayer() ) {\n board.getSquare(x-1, y+1).drawOutline();\n }\n }\n \n System.out.println(\"\");\n //En passant\n if (y - 1 > 0) {\n \n System.out.println();\n if (board.getSquare(x, y-1).getPiece() != null) { \n System.out.println(\"the piece's enPassant is: \" + board.getSquare(x, y-1).getPiece().getEnPassant());\n System.out.println(\"The game's turn counter is: \" + board.getTurnCounter());\n }\n else {\n System.out.println(\"Null piece when checking for en passent.\");\n }\n \n if (board.getSquare(x, y-1).getPiece() != null && board.getSquare(x, y-1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y-1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x-1, y-1).drawOutline();\n board.getSquare(x-1, y-1).setEnPassent(true);\n }\n }\n \n if (y + 1 < SIZE) {\n if (board.getSquare(x, y+1).getPiece() != null && board.getSquare(x, y+1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y+1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x-1, y+1).drawOutline();\n board.getSquare(x-1, y+1).setEnPassent(true);\n }\n }\n }\n \n //If this pawn belongs to player 2:\n else {\n \n if (board.getSquare(x+1, y).getPiece() == null) {\n board.getSquare(x+1, y).drawOutline();\n }\n \n //if first move, pawn can move 2 spaces forward\n if (!hasMoved && board.getSquare(x+2, y).getPiece() == null && board.getSquare(x+1, y).getPiece() == null) {\n board.getSquare(x+2, y).drawOutline();\n \n }\n \n if(y-1 > 0) {\n if (board.getSquare(x+1, y-1) != null && board.getSquare(x+1, y-1).getPiece() != null &&\n board.getSquare(x+1, y-1).getPiece().getPlayer() != this.getPlayer() ) {\n board.getSquare(x+1, y-1).drawOutline();\n }\n }\n \n if(y+1 < SIZE) {\n if (board.getSquare(x+1, y+1) != null && board.getSquare(x+1, y+1).getPiece() != null &&\n board.getSquare(x+1, y+1).getPiece().getPlayer() != this.getPlayer()) {\n board.getSquare(x+1, y+1).drawOutline();\n }\n }\n \n //En passant\n if (y - 1 > 0) {\n if (board.getSquare(x, y-1).getPiece() != null &&board.getSquare(x, y-1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y-1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x+1, y-1).drawOutline();\n board.getSquare(x+1, y-1).setEnPassent(true);\n }\n }\n \n if (y + 1 < SIZE) {\n if (board.getSquare(x, y+1).getPiece() != null && board.getSquare(x, y+1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y+1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x+1, y+1).drawOutline();\n board.getSquare(x+1, y+1).setEnPassent(true);\n }\n }\n }\n }", "void makeMove(Square from, Square to) {\r\n assert isLegal(from, to);\r\n\r\n if (kingPosition().isEdge()) {\r\n _winner = WHITE;\r\n listOfMoves.push(mv(kingPosition(), sq(0, 0)));\r\n System.out.println(winner());\r\n checkRepeated();\r\n return;\r\n }\r\n\r\n Piece side = map.get(from);\r\n if (_turn == side.opponent()) {\r\n return;\r\n }\r\n listOfMoves.push(mv(from, to));\r\n revPut(map.get(from), to);\r\n map.put(from, EMPTY);\r\n map.put(to, side);\r\n board[from.col()][from.row()] = EMPTY;\r\n legalMoves(side);\r\n for (Square sq : map.keySet()) {\r\n if (map.get(sq) == side.opponent()) {\r\n if (to.isRookMove(sq)) {\r\n Square captureAble = to.rookMove(to.direction(sq), 2);\r\n if (to.adjacent(sq) && ((map.get(captureAble) == side)\r\n || (captureAble == THRONE\r\n && map.get(THRONE) == EMPTY))) {\r\n capture(to, captureAble);\r\n }\r\n }\r\n }\r\n }\r\n\r\n _turn = _turn.opponent();\r\n _moveCount += 1;\r\n checkRepeated();\r\n }", "void move(int row, int col) {\n\n int rowdiff = row - this._row; int coldiff = col - this.column;\n if (((Math.abs(rowdiff)) > 1) || (Math.abs(coldiff)) > 1);\n || (row >= _side) || (col >= _side) || (row < 0) || (col < 0);\n || ((Math.abs(coldiff)) == 1) && ((Math.abs(rowdiff)) == 1))); {\n throw new java.lang.IllegalArgumentException();\n } \n else if (rowdiff == 1) && (coldiff == 0)//up method\n { \n if (((isPaintedSquare(row, col) && isPaintedFace(2)) || \n (!isPaintedSquare(row, col) && !isPaintedFace(2))) {\n up_method(cube)\n } else if (isPaintedFace(2) == true) {\n _facePainted[2] == false\n grid[row][col] == true\n up_method(cube)\n }\n else {\n _facePainted[2] == true\n grid[row][col] == false \n up_method(cube)\n }\n }\n else if ((rowdiff == -1) && (coldiff == 0)) //down method\n\n { \n if (((isPaintedSquare(row, col) && isPaintedFace(4)) || \n (!isPaintedSquare(row, col) && !isPaintedFace(4))) {\n up_method(cube)\n } else if (isPaintedFace(4) == true) {\n _facePainted[4] == false\n grid[row][col] == true\n up_method(cube)\n } else {\n _facePainted[4] == true\n grid[row][col] == false \n up_method(cube)\n }\n }\n else if (rowdiff == 0) && (coldiff == -1) { //left method\n if (((isPaintedSquare(row, col) && isPaintedFace(5)) || \n (!isPaintedSquare(row, col) && !isPaintedFace(5))) {\n up_method(cube)\n } else if (isPaintedFace(5) == true) {\n _facePainted[5] == false\n grid[row][col] == true\n up_method(cube)}\n else {\n _facePainted[5] == true\n grid[row][col] == false \n up_method(cube)}\n }\n else if ((rowdiff == 0) && (coldiff == 1)) { //right method\n if (((isPaintedSquare(row, col) && isPaintedFace(6)) || \n (!isPaintedSquare(row, col) && !isPaintedFace(6))) {\n up_method(cube)\n } else if (isPaintedFace(6) == true) {\n _facePainted[6] == false\n grid[row][col] == true\n up_method(cube)}\n else {\n _facePainted[6] == true\n grid[row][col] == false \n up_method(cube)\n \n }\n }\n\n\n }", "public void enemymoveGarret(){\n\t\tint YEG = 0;\n\t\tint XEG = 0;\n\t\tint[] turns = new int[]{0,0,0,0,0,2,1,1,1,1,1,3};//dependign on the placement garret will move a certain way\n\t\tfor(int i = 0 ; i < this.Garret.length;i++){//this grabs garrets current locations\n\t\t\tfor(int p = 0; p < this.Garret.length;p++){\n\t\t\t\tif(this.Garret[i][p] == 1){\n\t\t\t\t\tYEG = i;\n\t\t\t\t\tXEG = p;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tint move = turns[count];\n\t\tswitch(move){//first block is up and down second block is left and right\n\t\t\tcase 0:\n\t\t\t\tif(this.area[YEG][XEG-1] != \"[ ]\"){\n\t\t\t\t\tthis.Garret[YEG][XEG-1] = 1;//to turn left\n\t\t\t\t\tthis.Garret[YEG][XEG] = 0;\n\t\t\t\t\tcount++;\n\t\t\t\t\tif(count == 12){\n\t\t\t\t\t\tcount = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\tif(this.area[YEG][XEG+1] != \"[ ]\"){\n\t\t\t\t\tthis.Garret[YEG][XEG+1] = 1;//to turn right\n\t\t\t\t\tthis.Garret[YEG][XEG] = 0;\n\t\t\t\t\tcount++;\n\t\t\t\t\tif(count == 12){\n\t\t\t\t\t\tcount = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tif(this.area[YEG-1][XEG] != \"[ ]\"){\n\t\t\t\t\tthis.Garret[YEG-1][XEG] = 1;//to turn up\n\t\t\t\t\tthis.Garret[YEG][XEG] = 0;\n\t\t\t\t\tcount++;\n\t\t\t\t\tif(count == 12){\n\t\t\t\t\t\tcount = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\tif(this.area[YEG+1][XEG] != \"[ ]\"){\n\t\t\t\t\tthis.Garret[YEG+1][XEG] = 1;//to turn down\n\t\t\t\t\tthis.Garret[YEG][XEG] = 0;\n\t\t\t\t\tcount++;\n\t\t\t\t\tif(count == 12){\n\t\t\t\t\t\tcount = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}//end of switch\t\n\t}", "public ArrayList<String> legalMoves(boolean side) {\n\t\tArrayList<String> moveList = new ArrayList<String>();\n\t\tchar fTemp = ' ', tTemp = ' ';\n\t\tString tempMove;\n\t\tupdate();\n\t\t\n\t\tfor (byte r = 0; r < b.length; r++) {\n\t\t\tfor (byte c = 0; c < b[r].length; c++) {\n\t\t\t\tif (b[r][c].getSide() == side && !(b[r][c] instanceof Null)) {\n\t\t\t\t\tif (c == 0) {\n\t\t\t\t\t\tfTemp = 'a';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\telse if (c == 1) {\n\t\t\t\t\t\tfTemp = 'b';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\telse if (c == 2) {\n\t\t\t\t\t\tfTemp = 'c';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\telse if (c == 3) {\n\t\t\t\t\t\tfTemp = 'd';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\telse if (c == 4) {\n\t\t\t\t\t\tfTemp = 'e';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\telse if (c == 5) {\n\t\t\t\t\t\tfTemp = 'f';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\telse if (c == 6) {\n\t\t\t\t\t\tfTemp = 'g';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\telse if (c == 7) {\n\t\t\t\t\t\tfTemp = 'h';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (b[r][c] instanceof King) {\n\t\t\t\t\t\tif (side) {\n\t\t\t\t\t\t\tif (b[0][5] instanceof Null && b[0][6] instanceof Null && ((King) b[r][c]).getCKS()) {\n\t\t\t\t\t\t\t\tmoveList.add(\"O-O\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (b[0][1] instanceof Null && b[0][2] instanceof Null && ((King) b[r][c]).getCQS()) {\n\t\t\t\t\t\t\t\tmoveList.add(\"O-O-O\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tif (b[7][5] instanceof Null && b[7][6] instanceof Null && ((King) b[r][c]).getCKS()) {\n\t\t\t\t\t\t\t\tmoveList.add(\"O-O\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (b[7][1] instanceof Null && b[7][2] instanceof Null && ((King) b[r][c]).getCQS()) {\n\t\t\t\t\t\t\t\tmoveList.add(\"O-O-O\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tfor (Piece p : b[r][c].getMoves()) {\n\t\t\t\t\t\tif (p.getFile() == 0) {\n\t\t\t\t\t\t\ttTemp = 'a';\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\telse if (p.getFile() == 1) {\n\t\t\t\t\t\t\ttTemp = 'b';\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\telse if (p.getFile() == 2) {\n\t\t\t\t\t\t\ttTemp = 'c';\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\telse if (p.getFile() == 3) {\n\t\t\t\t\t\t\ttTemp = 'd';\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\telse if (p.getFile() == 4) {\n\t\t\t\t\t\t\ttTemp = 'e';\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\telse if (p.getFile() == 5) {\n\t\t\t\t\t\t\ttTemp = 'f';\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\telse if (p.getFile() == 6) {\n\t\t\t\t\t\t\ttTemp = 'g';\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\telse if (p.getFile() == 7) {\n\t\t\t\t\t\t\ttTemp = 'h';\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\ttempMove = b[r][c].getSymbol() + \"\" + fTemp + \"\" + (b[r][c].getRank()+1) + '-' + tTemp + (p.getRank()+1);\n\t\t\t\t\t\tBoard nBD = new Board(getBoard());\n\t\t\t\t\t\tnBD.move(tempMove, side);\n\t\t\t\t\t\tnBD.update();\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (!(nBD.check(!side))) {\n\t\t\t\t\t\t\t//Promotion\n\t\t\t\t\t\t\tif (side && p.getRank() == 7 && b[r][c] instanceof Pawn) {\n\t\t\t\t\t\t\t\tmoveList.add(tempMove + \"=Q\");\n\t\t\t\t\t\t\t\tmoveList.add(tempMove + \"=R\");\n\t\t\t\t\t\t\t\tmoveList.add(tempMove + \"=N\");\n\t\t\t\t\t\t\t\tmoveList.add(tempMove + \"=B\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\telse if (!side && p.getRank() == 0 && b[r][c] instanceof Pawn) {\n\t\t\t\t\t\t\t\tmoveList.add(tempMove + \"=Q\");\n\t\t\t\t\t\t\t\tmoveList.add(tempMove + \"=R\");\n\t\t\t\t\t\t\t\tmoveList.add(tempMove + \"=N\");\n\t\t\t\t\t\t\t\tmoveList.add(tempMove + \"=B\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tmoveList.add(tempMove);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn moveList;\n\t}", "private boolean isKingThreatened(int col, int row, List<Piece> threats) {/Down/Left/Right: queens, rooks\n // Up\n for (int r = row + 1; r < 8; r++) {\n if (threatenCheck(board[r][col], threats, Who.ROOK)) break;\n }\n // Right\n for (int c = col + 1; c < 8; c++) {\n if (threatenCheck(board[row][c], threats, Who.ROOK)) break;\n }\n // Down\n for (int r = row - 1; r >= 0; r--) {\n if (threatenCheck(board[r][col], threats, Who.ROOK)) break;\n }\n // Left\n for (int c = col - 1; c >= 0; c--) {\n if (threatenCheck(board[row][c], threats, Who.ROOK)) break;\n }\n\n // Sideways: queens, bishops\n // Up-right\n for (int r = row + 1, c = col + 1; r < 8 && c < 8; r++, c++) {\n if (threatenCheck(board[r][c], threats, Who.BISHOP)) break;\n }\n // Right-down\n for (int r = row - 1, c = col + 1; r >= 0 && c < 8; r--, c++) {\n if (threatenCheck(board[r][c], threats, Who.BISHOP)) break;\n }\n // Down-left\n for (int r = row - 1, c = col - 1; r >= 0 && c >= 0; r--, c--) {\n if (threatenCheck(board[r][c], threats, Who.BISHOP)) break;\n }\n // Left-up\n for (int r = row + 1, c = col - 1; r < 8 && c >= 0; r++, c--) {\n if (threatenCheck(board[r][c], threats, Who.BISHOP)) break;\n }\n\n // Checking for knights\n int r = row, c = col;\n // Up\n if (r < 6) {\n // Right\n if (c < 7)\n threatenCheck1Piece(board[r + 2][c + 1], threats, Who.KNIGHT);\n // Left\n if (c > 0)\n threatenCheck1Piece(board[r + 2][c - 1], threats, Who.KNIGHT);\n }\n // Right\n if (c < 6) {\n // Up\n if (r < 7)\n threatenCheck1Piece(board[r + 1][c + 2], threats, Who.KNIGHT);\n // Down\n if (r > 0)\n threatenCheck1Piece(board[r - 1][c + 2], threats, Who.KNIGHT);\n }\n // Down\n if (r > 1) {\n // Right\n if (c < 7)\n threatenCheck1Piece(board[r - 2][c + 1], threats, Who.KNIGHT);\n // Left\n if (c > 0)\n threatenCheck1Piece(board[r - 2][c - 1], threats, Who.KNIGHT);\n }\n // Left\n if (c > 1) {\n // Up\n if (r < 7)\n threatenCheck1Piece(board[r + 1][c - 2], threats, Who.KNIGHT);\n // Down\n if (r > 0)\n threatenCheck1Piece(board[r - 1][c - 2], threats, Who.KNIGHT);\n }\n\n // Checking for pawns.\n boolean doPawns = true;\n if (whoseTurn == Owner.WHITE) {\n // No threat from pawns.\n if (row == 7) doPawns = false;\n row++;\n } else {\n // No threat from pawns.\n if (row == 0) doPawns = false;\n row--;\n }\n if (doPawns) {\n // Right side\n if (col < 7)\n threatenCheck1Piece(board[row][col + 1], threats, Who.PAWN);\n // Left side\n if (col > 0)\n threatenCheck1Piece(board[row][col - 1], threats, Who.PAWN);\n }\n\n return threats.size() != 0;\n }", "private void move(MoveAction moveAction) {\n Move move = moveAction.getLoad();\n Container selectedContainer = mContainersManager.getContainer(move.getBowlNumber());\n boolean anotherRound = false;\n\n if (isAValidMove(move.getPlayer(), selectedContainer)) {\n anotherRound = spreadSeedFrom(move.getBowlNumber());\n\n if (isGameEnded()) {\n Action gameEnded;\n if (!mEvenGame) {\n gameEnded = new Winner(mWinner, getRepresentation(), mContainersManager.getAtomicMoves());\n } else {\n gameEnded = new EvenGame(getRepresentation(), mContainersManager.getAtomicMoves());\n }\n\n postOnTurnContext(gameEnded);\n } else {\n postOnTurnContext(new BoardUpdated(getRepresentation(),\n anotherRound, mContainersManager.getAtomicMoves()));\n }\n\n } else if (!isGameEnded()) {\n postOnTurnContext(new InvalidMove(\n move,\n getRepresentation(),\n mActivePlayer\n ));\n }\n\n\n }", "public static void move(TTTBoard board, char piece) {\n if (board.winner() != ' ') {\n throw new IllegalArgumentException(\"Game Over\");\n }\n if (board.size() == 1) {\n board.set(0, 0, piece);\n return;\n }\n if (board.size() == 3) {\n int turnNumber = getBoardTurnNumber(board);\n if (turnNumber == 1) {\n board.set(0, 0, piece);\n return;\n } else if (turnNumber == 2) {\n if (board.get(1, 1) == ' ') {\n board.set(1, 1, piece);\n return;\n } else if (board.get(0, 0) == ' ') {\n board.set(0, 0, piece);\n return;\n }\n } else if (turnNumber == 3) {\n try {\n int[] opp = getFirstOpp(board, piece);\n int oppRow = opp[0];\n if (oppRow == 0) {\n board.set(2, 0, piece);\n return;\n } else if (oppRow == 1) {\n board.set(0, 2, piece);\n return;\n } else {\n board.set(0, 2, piece);\n return;\n }\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n }\n\n // check if win diagonal\n int selfC = 0;\n int oppC = 0;\n int spaceC = 0;\n for (int i = 0; i < board.size(); ++i) {\n int j = i;\n char p = board.get(i, j);\n if (p == ' ') spaceC++;\n else if (p == piece) selfC++;\n else oppC++;\n }\n\n if (spaceC == 1 && (selfC == 0 || oppC == 0)) {\n // fill in that space\n for (int i = 0; i < board.size(); ++i) {\n int j = i;\n char p = board.get(i, j);\n if (p == ' ') {\n board.set(i, j, piece);\n return;\n }\n }\n }\n\n selfC = 0;\n oppC = 0;\n spaceC = 0;\n for (int i = 0; i < board.size(); ++i) {\n int j = board.size() - i - 1;\n char p = board.get(i, j);\n if (p == ' ') spaceC++;\n else if (p == piece) selfC++;\n else oppC++;\n\n }\n\n if (spaceC == 1 && (selfC == 0 || oppC == 0)) {\n // fill in that space\n for (int i = 0; i < board.size(); ++i) {\n int j = board.size() - i - 1;\n char p = board.get(i, j);\n if (p == ' ') {\n board.set(i, j, piece);\n return;\n }\n }\n }\n\n // check if win row col\n\n boolean[] selfWinnableRows = new boolean[board.size()];\n boolean[] oppWinnableRows = new boolean[board.size()];\n boolean[] selfWinnableCols = new boolean[board.size()];\n boolean[] oppWinnableCols = new boolean[board.size()];\n int[] selfCountRows = new int[board.size()];\n int[] selfCountCols = new int[board.size()];\n int[] oppCountRows = new int[board.size()];\n int[] oppCountCols = new int[board.size()];\n\n // checks if any rows can be won\n for (int i = 0; i < board.size(); ++i) {\n boolean containsSelf = false;\n boolean containsOpp = false;\n boolean hasEmpty = false;\n int selfCount = 0;\n int oppCount = 0;\n\n for (int j = 0; j < board.size(); ++j) {\n char p = board.get(i, j);\n\n if (p == ' ') {\n hasEmpty = true;\n } else if (p == piece) {\n containsSelf = true;\n selfCount++;\n } else {\n containsOpp = true;\n oppCount++;\n }\n }\n\n selfCountRows[i] = selfCount;\n oppCountRows[i] = oppCount;\n\n if (!hasEmpty) continue;\n\n if (!containsSelf && !containsOpp) {\n selfWinnableRows[i] = true;\n oppWinnableRows[i] = true;\n }\n\n if (containsSelf && !containsOpp) {\n selfWinnableRows[i] = true;\n }\n if (containsOpp && !containsSelf) {\n oppWinnableRows[i] = true;\n }\n }\n\n // checks if any cols can be won\n for (int i = 0; i < board.size(); ++i) {\n boolean containsSelf = false;\n boolean containsOpp = false;\n boolean hasEmpty = false;\n int selfCount = 0;\n int oppCount = 0;\n for (int j = 0; j < board.size(); ++j) {\n char p = board.get(j, i);\n\n if (p == ' ') {\n hasEmpty = true;\n } else if (p == piece) {\n containsSelf = true;\n selfCount++;\n } else {\n containsOpp = true;\n oppCount++;\n }\n }\n\n selfCountCols[i] = selfCount;\n oppCountCols[i] = oppCount;\n\n if (!hasEmpty) continue;\n\n if (!containsSelf && !containsOpp) {\n selfWinnableCols[i] = true;\n oppWinnableCols[i] = true;\n }\n\n if (containsSelf && !containsOpp) {\n selfWinnableCols[i] = true;\n }\n\n if (containsOpp && !containsSelf) {\n oppWinnableCols[i] = true;\n }\n }\n\n int[] selfInRowRows = new int[board.size()];\n int[] selfInRowCols = new int[board.size()];\n int[] oppInRowRows = new int[board.size()];\n int[] oppInRowCols = new int[board.size()];\n\n for (int i = 0; i < selfWinnableRows.length; ++i) {\n if (selfWinnableRows[i]) {\n int count = selfCountRows[i];\n selfInRowRows[count]++;\n }\n }\n for (int i = 0; i < selfWinnableCols.length; ++i) {\n if (selfWinnableCols[i]) {\n int count = selfCountCols[i];\n selfInRowCols[count]++;\n }\n }\n for (int i = 0; i < oppWinnableRows.length; ++i) {\n if (oppWinnableRows[i]) {\n int count = oppCountRows[i];\n oppInRowRows[count]++;\n }\n }\n for (int i = 0; i < oppWinnableCols.length; ++i) {\n if (oppWinnableCols[i]) {\n int count = oppCountCols[i];\n oppInRowCols[count]++;\n }\n }\n\n if (board.size() == 3) {\n int turnNumber = getBoardTurnNumber(board);\n if (selfInRowRows[board.size() - 1] == 0 &&\n selfInRowCols[board.size() - 1] == 0 &&\n oppInRowRows[board.size() - 1] == 0 &&\n oppInRowCols[board.size() - 1] == 0) {\n if (turnNumber == 4) {\n if ((board.get(1, 1) != ' ' && board.get(1, 1) != piece)\n && (board.get(2, 2) != ' ' && board.get(2, 2) != piece)) {\n board.set(2, 0, piece);\n return;\n }\n } else if (turnNumber == 5) {\n if (selfCountCols[0] == 2) {\n board.set(2, 2, piece);\n return;\n } else if (selfCountRows[0] == 2) {\n if (board.get(1, 0) != piece && board.get(1, 0) != ' ') {\n board.set(2, 2, piece);\n return;\n }\n if (board.get(2, 0) != piece && board.get(2, 0) != ' ') {\n board.set(2, 2, piece);\n return;\n }\n board.set(2, 0, piece);\n return;\n }\n }\n }\n }\n\n for (int i = board.size() - 1; i >= 0; i--) {\n int selfRowsCount = selfInRowRows[i];\n //System.out.println(i + \" self rows count: \" + selfRowsCount);\n if (selfRowsCount > 0) {\n // get a row index that contains this self in row rows\n try {\n int rowIndex = getRowIndexForInRowRows(board, i, selfWinnableRows, selfCountRows);\n int colIndex = getNextInRow(board, rowIndex);\n board.set(rowIndex, colIndex, piece);\n return;\n } catch (Exception e) {\n e.printStackTrace();\n }\n\n }\n int selfColsCount = selfInRowCols[i];\n if (selfColsCount > 0) {\n try {\n int colIndex = getRowIndexForInRowRows(board, i, selfWinnableCols, selfCountCols);\n int rowIndex = getNextInCol(board, colIndex);\n board.set(rowIndex, colIndex, piece);\n return;\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n int oppRowsCount = oppInRowRows[i];\n // System.out.println(i + \" opp rows count: \" + oppRowsCount);\n if (oppRowsCount > 0) {\n\n try {\n int rowIndex = getRowIndexForInRowRows(board, i, oppWinnableRows, oppCountRows);\n int colIndex = getNextInRow(board, rowIndex);\n board.set(rowIndex, colIndex, piece);\n return;\n } catch (Exception e) {\n e.printStackTrace();\n }\n\n }\n int oppColsCount = oppInRowCols[i];\n if (oppColsCount > 0) {\n try {\n int colIndex = getRowIndexForInRowRows(board, i, oppWinnableCols, oppCountCols);\n int rowIndex = getNextInCol(board, colIndex);\n board.set(rowIndex, colIndex, piece);\n return;\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n }\n\n try {\n int[] nextEmpty = getNextEmpty(board);\n board.set(nextEmpty[0], nextEmpty[1], piece);\n } catch (Exception e) {\n throw new IllegalArgumentException(\"DRAW / SOMEONE WON\");\n }\n }", "public MoveType GetMoveTypeForTurn(int turn) {\n switch ((turn - 1) % 6) {\n case 2:\n case 5:\n return MoveType.AllGrow;\n\n case 0:\n case 1:\n case 3:\n case 4:\n default:\n return MoveType.SingleGrow;\n }\n }", "public King(Color color) {\n super(color, RANK);\n castling = false;\n }", "private void mediumMove(Board board) {\n\t}", "public int gameState() {\n \tboolean check = isCheck(turn);\n \t\n \t//change this code to be some sort of checkmate detection\n \tif(check) {\n \t\t//we need to check whether there is a legal move that puts the king out of check\n \t\t//we need to loop through all pieces of the same color as the turn and make all legal moves\n \t\t//then after each move, check whether the king is still in check\n \t\t\n \t\t//first generate a list of all pieces for the turn color\n \t\tArrayList<Piece> pieces = getPieces(turn);\n \t\t\n \t\tboolean freedom;\n \t\t\n \t\t//now for each piece, check whether moving that piece can get the king out of check\n \t\tfor(int i = 0; i < pieces.size(); i++) {\n \t\t\tfreedom = simulate(pieces.get(i));\n \t\t\tif(freedom) {\n \t \t\tupdateCheckMove(false);\n \t \t\tSystem.out.println(\"Check on \" + turn + \" King!\");\n \t\t\t\treturn 2; //if the king can move, then the game isn't over yet\n \t\t\t}\n \t\t}\n \t\t\n \t\t//the game is over if we reach this far, so we can assume checkmate\n \t\t//resignation logic will probably be specific to Display class\n \t\t\n \t\tupdateCheckMove(true);\n \t\t\n \t\tif(turn == PieceColor.White) return -1; //black win if white king in check and can't move\n \t\tif(turn == PieceColor.Black) return 1;\n \t}\n \t\n \t//if all of these fail, the game isn't over yet\n \treturn 2;\n }", "@Test\n\tpublic void kingOnThroneBlackPieceRightWhiteCapture()\n\t{\n\t\tData d=new Data();\n\t\t//moving pieces out so capture can occur\n\t\td.set(24,68);\n\t\td.set(7,29);\n\t\td.set(36,119);\n\t\td.set(11,106);\n\t\td.set(20,33);\n\t\td.set(4,85);\n\t\td.set(35,118);\n\t\td.set(3,95);\n\t\td.set(25,62);\n\t\td.set(4,63);\n\t\tArrayList<Coordinate> test_arr=d.pieceLost(63);\n\t\tassertTrue(6==test_arr.get(0).getX() && 5==test_arr.get(0).getY());\n\n\t}", "public void checkWinner(){\n \n if ((board[0][0] == 'X' && board[0][1] == 'X' && board[0][2] == 'X')||(board[1][0] == 'X' && board[1][1] == 'X' && board[1][2] == 'X')||(board[2][0] == 'X' && board[2][1] == 'X' && board[2][2] == 'X')){\n winner();\n }\n else if ((board[0][0] == 'X' && board[1][0] == 'X' && board[2][0] == 'X')||(board[0][1] == 'X' && board[1][1] == 'X' && board[2][1] == 'X')||(board[0][2] == 'X' && board[1][2] == 'X' && board[2][2] == 'X')){\n winner();\n }\n else if ((board[0][0] == 'X' && board[1][1] == 'X' && board[2][2] == 'X')||(board[0][2] == 'X' && board[1][1] == 'X' && board[2][0] == 'X')){\n winner();\n }\n else if ((board[0][0] == 'O' && board[0][1] == 'O' && board[0][2] == 'O')||(board[1][0] == 'O' && board[1][1] == 'O' && board[1][2] == 'O')||(board[2][0] == 'O' && board[2][1] == 'O' && board[2][2] == 'O')){\n winner();\n }\n else if ((board[0][0] == 'O' && board[1][0] == 'O' && board[2][0] == 'O')||(board[0][1] == 'O' && board[1][1] == 'O' && board[2][1] == 'O')||(board[0][2] == 'O' && board[1][2] == 'O' && board[2][2] == 'O')){\n winner();\n }\n else if ((board[0][0] == 'O' && board[1][1] == 'O' && board[2][2] == 'O')||(board[0][2] == 'O' && board[1][1] == 'O' && board[2][0] == 'O')){\n winner();\n }\n \n }", "public List<Move> validMoves(){\n List<Move> results = new LinkedList<>();\n int kingVal = turn == WHITE ? WHITE_KING : BLACK_KING;\n int kingX = 0, kingY = 0;\n List<Piece> checks = null;\n kingSearch:\n for (int y = 0; y < 8; y++){\n for (int x = 0; x < 8; x++){\n if (board[y][x] == kingVal){\n kingX = x;\n kingY = y;\n checks = inCheck(x,y);\n break kingSearch;\n }\n }\n }\n if (checks.size() > 1){ // must move king\n for (int x = -1; x < 2; x++){\n for (int y = -1; y < 2; y++){\n if (kingX+x >= 0 && kingX + x < 8 && kingY+y >= 0 && kingY+y < 8){\n int val = board[kingY+y][kingX+x];\n if (val == 0 || turn == WHITE && val > WHITE_KING || turn == BLACK && val < BLACK_PAWN){\n // may still be a move into check, must test at end\n results.add(new Move(kingVal, kingX, kingY, kingX+x, kingY+y, val, 0, this));\n }\n }\n }\n }\n } else { // could be in check TODO: split into case of single check and none, identify pin/capture lines\n int queen = turn == WHITE ? WHITE_QUEEN : BLACK_QUEEN;\n int knight = turn == WHITE ? WHITE_KNIGHT : BLACK_KNIGHT;\n int rook = turn == WHITE ? WHITE_ROOK : BLACK_ROOK;\n int bishop = turn == WHITE ? WHITE_BISHOP : BLACK_BISHOP;\n for (int y = 0; y < 8; y++) {\n for (int x = 0; x < 8; x++) {\n int piece = board[y][x];\n if (piece == (turn == WHITE ? WHITE_PAWN : BLACK_PAWN)) { // pawns\n // regular | 2 move\n if (board[y+turn][x] == 0){\n if (y+turn == 0 || y + turn == 7){ // promotion\n results.add(new Move(piece, x, y, x, y + turn, 0, queen, this));\n results.add(new Move(piece, x, y, x, y + turn, 0, knight, this));\n results.add(new Move(piece, x, y, x, y + turn, 0, rook, this));\n results.add(new Move(piece, x, y, x, y + turn, 0, bishop, this));\n }\n else {\n results.add(new Move(piece, x, y, x, y + turn, 0, 0, this));\n if ((y == (turn == WHITE ? 1 : 6)) && board[y + 2 * turn][x] == 0) { // initial 2 move\n results.add(new Move(piece, x, y, x, y + 2*turn, 0, 0, this));\n }\n }\n }\n // capture\n for (int dx = -1; dx <= 1; dx += 2){\n if (x + dx >= 0 && x + dx < 8) {\n int val = board[y+turn][x+dx];\n if (val > 0 && (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n if (y + turn == 0 || y + turn == 7){ // promotion\n results.add(new Move(piece, x, y, x+dx, y + turn, val, queen, this));\n results.add(new Move(piece, x, y, x+dx, y + turn, val, knight, this));\n results.add(new Move(piece, x, y, x+dx, y + turn, val, rook, this));\n results.add(new Move(piece, x, y, x+dx, y + turn, val, bishop, this));\n } else {\n results.add(new Move(piece, x, y, x+dx, y + turn, val, 0, this));\n }\n }\n if (val == 0 && y == (turn == WHITE ? 4 : 3) && x+dx == enPassant){ // en passant\n results.add(new Move(piece, x, y, x+dx, y + turn, 0, 0, this));\n }\n }\n }\n\n } else if (piece == knight) { // knights TODO: lookup table\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -2; dy <= 2; dy += 4){\n if (x+dx >= 0 && x + dx < 8 && y + dy >= 0 && y + dy < 8){\n int val = board[y+dy][x+dx];\n if (val == 0 || (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n results.add(new Move(piece,x,y,x+dx,y+dy,val,0,this));\n }\n }\n if (x+dy >= 0 && x + dy < 8 && y + dx >= 0 && y + dx < 8){\n int val = board[y+dx][x+dy];\n if (val == 0 || (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n results.add(new Move(piece,x,y,x+dy,y+dx,val,0,this));\n }\n }\n }\n }\n } else if (piece == bishop) { // bishops\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -1; dy <= 1; dy += 2){\n int i = 1;\n while (x + dx*i >= 0 && x + dx*i < 8 && y + dy*i >= 0 && y + dy*i < 8){\n int val = board[y+dy*i][x+dx*i];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n } else if (piece == rook) { // rooks\n for (int dx = -1; dx <= 1; dx+= 2){\n for (int ax = 0; ax < 2; ax++){\n int i = 1;\n while (ax==0 ? y+dx*i >= 0 && y+dx*i < 8 : x+dx*i >= 0 && x+dx*i < 8){\n int val = board[y+dx*i*(1-ax)][x+dx*i*ax];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n } else if (piece == (turn == WHITE ? WHITE_QUEEN : BLACK_QUEEN)) { // queens\n // Diagonals - same as bishops\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -1; dy <= 1; dy += 2){\n int i = 1;\n while (x + dx*i >= 0 && x + dx*i < 8 && y + dy*i >= 0 && y + dy*i < 8){\n int val = board[y+dy*i][x+dx*i];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n for (int dx = -1; dx <= 1; dx+= 2){\n for (int ax = 0; ax < 2; ax++){\n int i = 1;\n while (ax==0 ? y+dx*i >= 0 && y+dx*i < 8 : x+dx*i >= 0 && x+dx*i < 8){\n int val = board[y+dx*i*(1-ax)][x+dx*i*ax];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n } else if (piece == (turn == WHITE ? WHITE_KING : BLACK_KING)) { // king\n for (int dx = -1; dx < 2; dx++){\n for (int dy = -1; dy < 2; dy++){\n if ((dx != 0 || dy != 0) && x+dx >= 0 && x + dx < 8 && y + dy >= 0 && y + dy < 8){\n int val = board[y+dy][x+dx];\n if (val == 0 || (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n results.add(new Move(piece,x,y,x+dx,y+dy,val,0,this));\n }\n }\n }\n }\n }\n }\n }\n // castle\n if (checks.size() == 0){\n if (turn == WHITE && (castles & 0b11) != 0){//(castles[0] || castles[1])){\n board[0][4] = 0; // remove king to avoid check test collisions with extra king\n if ((castles & WHITE_SHORT) != 0 && board[0][5] == 0 && board[0][6] == 0 && inCheck(5,0).size() == 0){\n //if (castles[0] && board[0][5] == 0 && board[0][6] == 0 && inCheck(5,0).size() == 0){\n results.add(new Move(WHITE_KING, 4, 0, 6, 0, 0, 0, this));\n }\n if ((castles & WHITE_LONG) != 0 && board[0][1] == 0 && board[0][2] == 0 && board[0][3] == 0 &&\n inCheck(3,0).size() == 0){\n //if (castles[1] && board[0][1] == 0 && board[0][2] == 0 && board[0][3] == 0 && inCheck(3,0).size() == 0){\n results.add(new Move(WHITE_KING, 4, 0, 2, 0, 0, 0, this));\n }\n board[0][4] = WHITE_KING;\n }else if (turn == BLACK && (castles & 0b1100) != 0){//(castles[2] || castles[3])) {\n board[7][4] = 0; // remove king to avoid check test collisions with extra king\n //if (castles[2] && board[7][5] == 0 && board[7][6] == 0 && inCheck(5, 7).size() == 0) {\n if ((castles & BLACK_SHORT) != 0 && board[7][5] == 0 && board[7][6] == 0 && inCheck(5, 7).size() == 0) {\n results.add(new Move(BLACK_KING, 4, 7, 6, 7, 0, 0, this));\n }\n //if (castles[3] && board[7][1] == 0 && board[7][2] == 0 && board[7][3] == 0 && inCheck(3, 7).size() == 0) {\n if ((castles & BLACK_LONG) != 0 && board[7][1] == 0 && board[7][2] == 0 && board[7][3] == 0 &&\n inCheck(3, 7).size() == 0) {\n results.add(new Move(BLACK_KING, 4, 7, 2, 7, 0, 0, this));\n }\n board[7][4] = BLACK_KING;\n }\n }\n }\n List<Move> fullLegal = new LinkedList<>();\n for (Move m : results){\n makeMove(m);\n turn = -turn;\n if (m.piece == WHITE_KING || m.piece == BLACK_KING){\n if (inCheck(m.toX,m.toY).size() == 0){\n fullLegal.add(m);\n }\n }else if (inCheck(kingX,kingY).size() == 0){\n fullLegal.add(m);\n }\n turn = -turn;\n undoMove(m);\n }\n Collections.sort(fullLegal, (o1, o2) -> o2.score - o1.score); // greatest score treated as least so appears first\n return fullLegal;\n }", "public void movePiece(Location a, Location b)\n {\n Square s1 = getSquare(a);\n Square s2 = getSquare(b);\n Piece p = s1.getPiece();\n if (p==null)\n return;\n int moveType = canMoveTo(p,b);\n boolean taking = getPiece(b)!=null;\n boolean fiftyMoveBreak = getPiece(b)!=null||p.getType()==Type.PAWN;\n s2.setPiece(s1.removePiece());\n p.setHasMoved(true);\n if (p.getType()==Type.PAWN)\n {\n if (mainBoard&&((p.white()&&getLocation(p).getRow()==0)\n || !p.white()&&getLocation(p).getRow()==7))\n promotePawn(p);\n else if (moveType==EN_PASSANT)\n {\n int row = a.getRow();\n int col = b.getCol();\n removePiece(new Location(row,col));\n taking = true;\n }\n }\n else if (moveType==KINGSIDE_CASTLING||moveType==QUEENSIDE_CASTLING)\n {\n Location rookLoc;\n Location rookDest;\n if (moveType==KINGSIDE_CASTLING)\n {\n rookLoc = b.farther(Direction.EAST);\n rookDest = b.farther(Direction.WEST);\n }\n else\n {\n rookLoc = new Location(b.getRow(),b.getCol()-2);\n rookDest = b.farther(Direction.EAST);\n }\n //movePiece(getLocation(rook),rookDest);\n getSquare(rookDest).setPiece(removePiece(rookLoc)); //moves the rook\n }\n if (mainBoard)\n {\n turn++;\n if (fiftyMoveBreak)\n fiftyMove= 0;\n else fiftyMove++;\n }\n for (Piece piece: getPieces())\n piece.setHasJustMoved(false);\n p.setHasJustMoved(true);\n if (mainBoard)\n {\n positions.add(toString());\n \n //this is all for the notation on the side\n notateMove(p,b,moveType,taking);\n /*JTable not = frame.getNotation();\n DefaultTableModel d = (DefaultTableModel)not.getModel();\n String notation;\n PieceColor color = p.getColor();\n if (color==PieceColor.WHITE)\n notation = turn/2+1+\". \"; //the turn number first, on the left\n else notation = \"\";\n if (moveType==QUEENSIDE_CASTLING)\n notation += \"0-0-0\";\n else if (moveType==KINGSIDE_CASTLING)\n notation += \"0-0\";\n else //normal move\n {\n if (p.getType()!=Type.PAWN)\n notation+=p.getType().toNotation(); //the type of piece (K,N,R,etc)\n if (taking)\n notation+=\"x\"; //this is if the move involves taking\n notation+=Location.LocToNot(b);\n }\n if (checkmate(colorGoing())) //notates # for checkmate\n notation+=\"#\";\n else if (inCheck(colorGoing())) //notates + for check\n notation+=\"+\";\n \n if (color==PieceColor.WHITE)\n d.addRow(new Object[]{notation,\"\"});\n else \n d.setValueAt(notation, (turn-1)/2, 1);*/\n }\n }", "public int move_diagonally(Square[][] squares, int [] move, Boolean turn) {\n\n /* going down and right = f4 h2 [4,5,6,7] */\n if (move[2] > move[0] && move[3] > move[1]) {\n ////System.out.println(\"Down right\");\n int x = move[0];\n int y = move[1];\n x++;\n y++;\n while (x < move[2] && y < move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x++;\n y++;\n }\n }\n /* going down and left */\n else if (move[2] > move[0] && move[3] < move[1]){\n ////System.out.println(\"Down Left\");\n int x = move[0];\n int y = move[1];\n x++;\n y--;\n while (x < move[2] && y > move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x++;\n y--;\n }\n }\n /* going up and left */\n else if (move[2] < move[0] && move[3] < move[1]){\n ////System.out.println(\"Up Left\");\n int x = move[0];\n int y = move[1];\n x--;\n y--;\n while (x > move[2] && y > move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x--;\n y--;\n }\n }\n /* going up and right c1 f4 [7,2,4,5] */\n else if (move[2] < move[0] && move[3] > move[1]){\n ////System.out.println(\"Up right\");\n int x = move[0];\n int y = move[1];\n x--;\n y++;\n while (x > move[2] && y < move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x--;\n y++;\n }\n }\n return 0;\n }", "private boolean isNextMoveRochade(Move move)\r\n\t{\r\n\t\tif (!(move.from.piece instanceof King)) return false;\r\n\t\tint xDiffAbs = Math.abs(move.to.coordinate.x - move.from.coordinate.x); \r\n\t\treturn xDiffAbs == 2;\r\n\t}", "@Test\n\tpublic void whenHorseMoveThrowAnotherFigureThanOk() {\n\t\tCell[][] cells = new Cell[8][8];\n\t\tfor (int x = 0; x < 8; x++) {\n\t\t\tfor (int y = 0; y < 8; y++) {\n\t\t\t\tcells[x][y] = new Cell(x, y);\n\t\t\t}\n\t\t}\n\t\tFigure[] figures = {new Horse(cells[4][4]),\n\t\t\t\t\t\t\tnew Tura(cells[2][5]),\n\t\t\t\t\t\t\tnew Tura(cells[3][5]),\n\t\t\t\t\t\t\tnew Tura(cells[4][5]),\n\t\t\t\t\t\t\tnew Tura(cells[5][5]),\n\t\t\t\t\t\t\tnew Tura(cells[6][5])};\n\t\tBoard board = new Board(cells, figures);\n\t\tassertThat(board.move(cells[4][4], board.getCell(3, 6)), is(true));\n\t}", "private void action() {\r\n moveSnake();\r\n if (hasEatenPowerUp() == false) checkForCollisionWithSelf();\r\n if (hasHitBoundry() == false) redraw();\r\n }", "public void changeBoard(int columnnumber, int whoseTurn, Color color1, Color color2){ //changes the colour of the circles on the board\r\n \r\n if(whoseTurn==1){ \r\n if(erase>0){ //this if statement runs if a checker needs to be erased; (because AI was checking future game states)\r\n for(int i = 0; i<=5; i++){ //going from top to bottom to change the last entered checker\r\n if(arrayCircles[i][erase-1].getColor()==color1){\r\n arrayCircles[i][erase-1].setColor(Color.white); //removing the checker that was previously placed\r\n repaint();\r\n break;\r\n }\r\n }\r\n }\r\n else{\r\n for(int i = 5; i>=0; i--){\r\n if(arrayCircles[i][columnnumber-1].getColor()==Color.white){ //starting from row 5 (the bottom one) see if any of those within the column is null\r\n arrayCircles[i][columnnumber-1].setColor(color1); //if so, set that value to the colour of the player who inputted that columnnumber\r\n repaint(); //repainting the board so that it updates and is visible to viewers\r\n break; //break once the colour has been changed and a move has been made\r\n }\r\n }\r\n }\r\n }\r\n \r\n else if(whoseTurn==2){\r\n for(int i = 5; i>=0; i--){\r\n if(arrayCircles[i][columnnumber-1].getColor()==Color.white){ //if there is an open space, set its colour to the desired colour \r\n arrayCircles[i][columnnumber-1].setColor(color2);\r\n repaint();\r\n break;\r\n }\r\n }\r\n }\r\n \r\n else if(whoseTurn==3||whoseTurn==4){ //either the easyAI or the hardAI\r\n \r\n \r\n if(erase>0){ //this if statement erases the last placed coloured checker\r\n for(int i = 0; i<=5; i++){ //going from top to bottom to change the last entered checker to white\r\n if(arrayCircles[i][erase-1].getColor()==Color.magenta){\r\n arrayCircles[i][erase-1].setColor(Color.white); //sets it back to white\r\n repaint(); //repaints and breaks\r\n break;\r\n }\r\n }\r\n }\r\n else{\r\n for(int i = 5; i>=0; i--){ //setting the colour of the column to magenta (for the AI)\r\n if(arrayCircles[i][columnnumber-1].getColor()==Color.white){\r\n arrayCircles[i][columnnumber-1].setColor(color2);\r\n repaint();\r\n break;\r\n }\r\n }\r\n } \r\n }\r\n }", "public boolean isKingMove(Piece.PColor colorCheckedForKing) {\n if(colorCheckedForKing == PColor.red) {\n return end.getRow() == 7;\n } else {\n return end.getRow() == 0;\n }\n }", "public void gameLoop() {\r\n // make the whites of the eyes move from side to side\r\n if (whiteRight == 210){\r\n whiteRight += 20;\r\n }\r\n else if (whiteRight == 230){\r\n whiteRight -= 30;\r\n }\r\n else if (whiteRight == 200){\r\n whiteRight += 10;\r\n }\r\n if (whiteLeft == 350){\r\n whiteLeft += 20;\r\n }\r\n else if (whiteLeft == 370){\r\n whiteLeft -= 30;\r\n }\r\n else if (whiteLeft == 340){\r\n whiteLeft += 10;\r\n }\r\n // make the eyebrows move up and down\r\n if (eyebrowMove == 150){\r\n eyebrowMove -= 100;\r\n }\r\n else if (eyebrowMove == 50){\r\n eyebrowMove += 100;\r\n }\r\n // make the mustache move up and down\r\n if (mustache == 590){\r\n mustache +=20;\r\n }\r\n else if (mustache == 610){\r\n mustache -=40;\r\n }\r\n else if (mustache == 570){\r\n mustache +=20;\r\n }\r\n // make the tongue move up and down\r\n if (tongue == 700){\r\n tongue += 15;\r\n }\r\n else if (tongue == 715){\r\n tongue -= 15;\r\n }\r\n }", "public Direction movePinky(Ghost g);", "@Override\n\tpublic void goForward() {\n\t\t// check side and move the according room and side\n\t\tif (side.equals(\"hRight\")) {\n\t\t\tthis.side = \"bFront\";\n\t\t\tthis.room = properties.getRoomFromProperties().get(3);\n\n\t\t} else if (side.equals(\"hFront\")) {\n\t\t\tthis.side = \"mFront\";\n\t\t\tthis.room = properties.getRoomFromProperties().get(2);\n\n\t\t} else if (side.equals(\"bLeft\")) {\n\t\t\tthis.side = \"rLeft\";\n\t\t\tthis.room = properties.getRoomFromProperties().get(4);\n\n\t\t} else if (side.equals(\"rBack\")) {\n\t\t\tthis.side = \"bBack\";\n\t\t\tthis.room = properties.getRoomFromProperties().get(3);\n\n\t\t} else if (side.equals(\"bBack\")) {\n\t\t\tthis.side = \"hLeft\";\n\t\t\tthis.room = properties.getRoomFromProperties().get(1);\n\n\t\t} else if (side.equals(\"kBack\")) {\n\t\t\tthis.side = \"lFront\";\n\t\t\tthis.room = properties.getRoomFromProperties().get(5);\n\n\t\t} else if (side.equals(\"lLeft\")) {\n\t\t\tthis.side = \"kRight\";\n\t\t\tthis.room = properties.getRoomFromProperties().get(6);\n\n\t\t} else if (side.equals(\"lBack\")) {\n\t\t\tthis.side = \"mBack\";\n\t\t\tthis.room = properties.getRoomFromProperties().get(2);\n\n\t\t} else if (side.equals(\"mFront\")) {\n\t\t\tthis.side = \"lFront\";\n\t\t\tthis.room = properties.getRoomFromProperties().get(5);\n\n\t\t} else if (side.equals(\"mBack\")) {\n\t\t\tthis.side = \"hBack\";\n\t\t\tthis.room = properties.getRoomFromProperties().get(1);\n\n\t\t} else {\n\t\t\trandomRoom();\n\t\t\tSystem.out.println(\"Entered Wormhole!\");\n\t\t\tSystem.out.println(\"Location was chosen at random\");\n\t\t\tSystem.out.println(\"New location is: \" + room + \" room and \" + side.substring(1) + \" side\");\n\n\t\t}\n\t}", "private void easyMove(Board board) {\n\t\t\r\n\t}", "public void move() {\n boolean changeDirection = true;\r\n if (y + y1 < 0) { // We want to change the direction if the ball hits the upper border\r\n y1 = game.speed;\r\n }else if (y + y1 > game.getHeight() - DIAMETER) { // we want to change the direction if the ball hits the lower border\r\n y1 = -game.speed;\r\n }else if (x + x1 < 0) { // Checks if the ball hits the left or right border. If it does, the round ends\r\n score2++;\r\n game.player2Score = score2;\r\n x1 = game.speed;\r\n }else if (x + x1 > game.getWidth() - DIAMETER) {\r\n score1++;\r\n game.player1Score = score1;\r\n x1 = -game.speed;\r\n }else if (collision1()) { // checks if our ball collides with our first racket\r\n x1 = -game.speed;\r\n// y = game.racket1.getTopY() - DIAMETER;\r\n game.speed++;\r\n }else if (collision2()) { // checks if our ball collides with our second racket\r\n x1 = game.speed + 1;\r\n// y = game.racket2.getTopY() + DIAMETER;\r\n// game.speed++;\r\n }else { // if neither of the borders nor the rackets are hit, we don't change our direction of the ball\r\n changeDirection = false;\r\n }\r\n if (changeDirection) { // if the ball hits the border or the racket, the sound of collision is going to play.\r\n Sound.BALL.play();\r\n }\r\n\r\n if (score1 == 3 || score2 == 3) {\r\n game.gameOver(\" Wins!\");\r\n }\r\n x += x1; // helps in moving our ball in x-axis\r\n y += y1; // helps in moving our ball in y-axis\r\n }", "private String easyMove() {\n int randomHole = evaluate();\n while (!isValidMove(randomHole)) {\n randomHole = evaluate();\n }\n\n return super.makeAMove(randomHole);\n }", "public void act() \n {\n move(3);\n turnAtEdge(); \n StrikeSeaHorse();\n }", "private King establishKing() {\n\t\tfor(final Piece piece : getActivePieces()) {\n\t\t\tif(piece.getPieceType().isKing()){\n\t\t\t\treturn (King) piece;\n\t\t\t}\n\t\t}\n\t\tthrow new RuntimeException(\"Why are you here?! This is not a valid board!!\");\n\t}", "public void move() {\n\t\tsetHealth(getHealth() - 1);\n\t\t//status();\n\t\tint row = getPosition().getRow() ;\n\t\tint column = getPosition().getColumn();\n\t\tint randomInt = (int)((Math.random()*2) - 1);\n\t\t\n\t\tif(hunter == false && row < 33) {\n\t\t\tif(row == 32) {\n\t\t\t\tgetPosition().setCoordinates(row -1 , randomInt);\n\t\t\t\tsetPosition(getPosition()) ;\n\t\t\t}\n\t\t\tif(row == 0) {\n\t\t\t\tgetPosition().setCoordinates(row + 1 , randomInt);\n\t\t\t\tsetPosition(getPosition()) ;\n\t\t\t}\n\t\t\tif(column == 99) {\n\t\t\t\tgetPosition().setCoordinates(randomInt , column - 1);\n\t\t\t\tsetPosition(getPosition()) ;\n\t\t\t}\n\t\t\tif(column == 0) {\n\t\t\t\tgetPosition().setCoordinates(randomInt , column + 1);\n\t\t\t\tsetPosition(getPosition()) ;\n\t\t\t}\n\t\t}\n\t\tif(hunter == false && row > 32) {\n\t\t\t//setHealth(100);\n\t\t\tgetPosition().setCoordinates(row -1 , randomInt);\n\t\t\tsetPosition(getPosition()) ;\n\t\t}\n\t\telse {\n\t\t\tif(row < 65 && hunter == true) {\n\t\t\t\tgetPosition().setCoordinates(row + 1, column);\n\t\t\t\tsetPosition(getPosition()) ;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tgetPosition().setCoordinates(65, column);\n\t\t\t\tsetPosition(getPosition());\n\t\t\t\t//Check if there is a gazelle\n\t\t\t\tPair [][] range = {{Drawer.pairs[row+1][column-1],Drawer.pairs[row+1][column],\n\t\t\t\t\t\t\t Drawer.pairs[row+1][column+1]}, {\n\t\t\t\t\t\t\t Drawer.pairs[row+2][column-1],\n\t\t\t\t\t\t\t Drawer.pairs[row+2][column],Drawer.pairs[row+2][column+1]}};\n\t\t\t\t\n\t\t\t\tfor(Pair [] line: range) {\n\t\t\t\t\tfor(Pair prey: line) {\n\t\t\t\t\t\tif(prey.getAnimal() instanceof Gazelle ) {\n\t\t\t\t\t\t\tattack();\n\t\t\t\t\t\t\tprey.getAnimal().die();\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "private void cp2turn(){\n\t\tboolean attacked = false;\n\t\twhile(!attacked){\n\t\t\tranX = ranNum.nextInt(30);\n\t\t\tranY = ranNum.nextInt(30);\n\n\t\t\tif(cp2Attacks[ranX][ranY] == false){\n\t\t\t\tcp2Shots.add(new Shot(ranX * 20,ranY * 20));\n\t\t\t\tboardOne.add(cp2Shots.get(cp2ShotCount));\n\n\t\t\t\tboardOne.setComponentZOrder(cp2Shots.get(cp2ShotCount), 0);\n\n\t\t\t\tfor(int x = 0; x < ships.length; x++){\n\t\t\t\t\tif(ships[x].getPlayer() == 1){\n\t\t\t\t\t\tif(ships[x].checkBounds(ranX * 20 + 5, ranY * 20 + 5)){\n\t\t\t\t\t\t\tcp2Shots.get(cp2ShotCount).hit();\n\t\t\t\t\t\t\tships[x].hit();\n\t\t\t\t\t\t\tif(ships[x].sunk()){\n\t\t\t\t\t\t\t\tcp1BoatsSunk++;\n\t\t\t\t\t\t\t\tcp1shipLabel.setText(\"Computer Player 1 ships sunk: \" + cp1BoatsSunk);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcp2ShotCount++;\n\t\t\t\tattacked = true;\n\t\t\t\tcp2Attacks[ranX][ranY] = true;\n\t\t\t}\n\t\t}\n\t\trepaint();\n\t}", "public void applyConvertedMove(String move) {\n\n\t\tString[] moveParts = move.split(\";\");\n\n\t\tint fromRow = Integer.parseInt(moveParts[0].charAt(0) + \"\");\n\t\tint fromCol = Integer.parseInt(moveParts[0].charAt(1) + \"\");\n\n\t\tint toRow = Integer.parseInt(moveParts[1].charAt(0) + \"\");\n\t\tint toCol = Integer.parseInt(moveParts[1].charAt(1) + \"\");\n\n\t\tint piece = board[fromRow][fromCol];//Integer.parseInt(moveParts[2]);\n\t\tint pieceType = Math.abs(board[fromRow][fromCol]);\n\t\tint team = Math.round(Math.signum(board[fromRow][fromCol]));\n\n\t\tboolean doResetEnpassant = true;\n\n\t\tif (pieceType == 1) { //If this is a pawn\n\t\t\tif (Math.abs(board[toRow][toCol]) == 7) { //If it is moving onto an enpassant stored tile\n\t\t\t\tboard[toRow + board[toRow][toCol]/7][toCol] = 0; //Kill the pawn that produced the enpassant tile\n\t\t\t} else if (Math.abs(fromRow - toRow) == 2) { //If it just did the double move thing\n\t\t\t\t//Reset the current enpassant tile\n\t\t\t\tresetEnpassant(team);\n\t\t\t\tdoResetEnpassant = false;\n\n\t\t\t\t//Set an empassant tile\n\t\t\t\tboard[(toRow + fromRow)/2][toCol] = 7 * team;\n\t\t\t\tenpassantCol = toCol;\n\t\t\t}\n\t\t} else if (pieceType == 6) { //If this is a king\n\t\t\tif (fromCol == 4) {\n\t\t\t\tif (doResetEnpassant) resetEnpassant(team);\n\t\t\t\tif (toCol == 7) { //Kingside Castle\n\t\t\t\t\tboard[toRow][6] = piece;\n\t\t\t\t\tboard[toRow][5] = board[toRow][7];\n\t\t\t\t\tboard[toRow][7] = 0;\n\t\t\t\t\tboard[toRow][4] = 0;\n\t\t\t\t\treturn;\n\t\t\t\t} else if (toCol == 0) { //Queenside Castle\n\t\t\t\t\tboard[toRow][2] = piece;\n\t\t\t\t\tboard[toRow][3] = board[toRow][0];\n\t\t\t\t\tboard[toRow][0] = 0;\n\t\t\t\t\tboard[toRow][4] = 0;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (doResetEnpassant) resetEnpassant(team);\n\t\tboard[fromRow][fromCol] = 0;\n\t\tif (moveParts.length > 2 && pieceType == 1 && (team == 1 ? toRow == 7 : team == -1 ? toRow == 0 : false)) {\n\t\t\tpiece = Integer.parseInt(moveParts[2]);\n\t\t}\n\t\tboard[toRow][toCol] = piece;\n\t}", "@Test\n\tpublic void whenHorseMovedInRightDirectionThanDirectionCellFullOfHorse() {\n\t\tCell[][] cells = new Cell[8][8];\n\t\tfor (int x = 0; x < 8; x++) {\n\t\t\tfor (int y = 0; y < 8; y++) {\n\t\t\t\tcells[x][y] = new Cell(x, y);\n\t\t\t}\n\t\t}\n\t\tFigure[] figures = {new Horse(cells[4][4])};\n\t\tBoard board = new Board(cells, figures);\n\t\t// Horse moving downleft.\n\t\tboard.move(board.getCell(4, 4), board.getCell(3, 6));\n\t\tassertThat(figures[0].getPosition(), is(cells[3][6]));\n\t\t// Horse moving upright.\n\t\tboard.move(board.getCell(3, 6), board.getCell(4, 4));\n\t\tassertThat(figures[0].getPosition(), is(cells[4][4]));\n\t\t// Horse moving downright.\n\t\tboard.move(board.getCell(4, 4), board.getCell(5, 6));\n\t\tassertThat(figures[0].getPosition(), is(cells[5][6]));\n\t\t// Horse moving upleft.\n\t\tboard.move(board.getCell(5, 6), board.getCell(4, 4));\n\t\tassertThat(figures[0].getPosition(), is(cells[4][4]));\n\t\t// Horse moving leftdown.\n\t\tboard.move(board.getCell(4, 4), board.getCell(2, 5));\n\t\tassertThat(figures[0].getPosition(), is(cells[2][5]));\n\t\t// Horse moving rightup.\n\t\tboard.move(board.getCell(2, 5), board.getCell(4, 4));\n\t\tassertThat(figures[0].getPosition(), is(cells[4][4]));\n\t\t// Horse moving leftup.\n\t\tboard.move(board.getCell(4, 4), board.getCell(2, 3));\n\t\tassertThat(figures[0].getPosition(), is(cells[2][3]));\n\t\t// Horse moving rightdown.\n\t\tboard.move(board.getCell(2, 3), board.getCell(4, 4));\n\t\tassertThat(figures[0].getPosition(), is(cells[4][4]));\n\t}", "Square kingPosition() {\r\n return king;\r\n }", "public void performMove(RubiksMove move) {\n RubiksCube initialState = new RubiksCube(this);\n\n printCube(\"PRE: \" + move);\n\n switch (move) {\n case UP:\n\n moveFaceClockwise(initialState, RubiksFace.RubiksFacePosition.UP);\n\n break;\n case DOWN:\n\n moveFaceClockwise(initialState, RubiksFace.RubiksFacePosition.DOWN);\n\n break;\n case LEFT:\n\n moveFaceClockwise(initialState, RubiksFace.RubiksFacePosition.LEFT);\n\n break;\n case RIGHT:\n\n moveFaceClockwise(initialState, RubiksFace.RubiksFacePosition.RIGHT);\n\n break;\n case FRONT:\n\n moveFaceClockwise(initialState, RubiksFace.RubiksFacePosition.FRONT);\n\n break;\n case BACK:\n moveFaceClockwise(initialState, RubiksFace.RubiksFacePosition.BACK);\n\n break;\n case UP2:\n\n moveFaceClockwise(initialState, RubiksFace.RubiksFacePosition.UP);\n initialState = new RubiksCube(this);\n moveFaceClockwise(initialState, RubiksFace.RubiksFacePosition.UP);\n\n break;\n case DOWN2:\n\n moveFaceClockwise(initialState, RubiksFace.RubiksFacePosition.DOWN);\n initialState = new RubiksCube(this);\n moveFaceClockwise(initialState, RubiksFace.RubiksFacePosition.DOWN);\n\n break;\n case LEFT2:\n\n moveFaceClockwise(initialState, RubiksFace.RubiksFacePosition.LEFT);\n initialState = new RubiksCube(this);\n moveFaceClockwise(initialState, RubiksFace.RubiksFacePosition.LEFT);\n\n break;\n case RIGHT2:\n\n moveFaceClockwise(initialState, RubiksFace.RubiksFacePosition.RIGHT);\n initialState = new RubiksCube(this);\n moveFaceClockwise(initialState, RubiksFace.RubiksFacePosition.RIGHT);\n\n break;\n case FRONT2:\n\n moveFaceClockwise(initialState, RubiksFace.RubiksFacePosition.FRONT);\n initialState = new RubiksCube(this);\n moveFaceClockwise(initialState, RubiksFace.RubiksFacePosition.FRONT);\n\n break;\n case BACK2:\n\n moveFaceClockwise(initialState, RubiksFace.RubiksFacePosition.BACK);\n initialState = new RubiksCube(this);\n moveFaceClockwise(initialState, RubiksFace.RubiksFacePosition.BACK);\n\n break;\n case INVERSE_UP:\n\n moveFaceAntiClockwise(initialState, RubiksFace.RubiksFacePosition.UP);\n\n break;\n case INVERSE_DOWN:\n\n moveFaceAntiClockwise(initialState, RubiksFace.RubiksFacePosition.DOWN);\n\n break;\n case INVERSE_LEFT:\n\n moveFaceAntiClockwise(initialState, RubiksFace.RubiksFacePosition.LEFT);\n\n break;\n case INVERSE_RIGHT:\n\n moveFaceAntiClockwise(initialState, RubiksFace.RubiksFacePosition.RIGHT);\n\n break;\n case INVERSE_FRONT:\n\n moveFaceAntiClockwise(initialState, RubiksFace.RubiksFacePosition.FRONT);\n\n break;\n case INVERSE_BACK:\n\n moveFaceAntiClockwise(initialState, RubiksFace.RubiksFacePosition.BACK);\n\n break;\n }\n\n printCube(\"POST: \" + move);\n\n }", "private void drawGame() {\r\n //For each each cell of the grid if there is a snake draw green,\r\n //an apple draw red or nothing draw white.\r\n for (int x = 0; x < gridWidth; x++) {\r\n for (int y = 0; y < gridHeight; y++) {\r\n if (isSnakeAt(new Coordinates(x, y))) {\r\n drawCell(x, y, Color.GREEN);\r\n } else if (apple.equals(new Coordinates(x, y))) {\r\n drawCell(x, y, Color.RED);\r\n } else {\r\n drawCell(x, y, Color.WHITE);\r\n }\r\n }\r\n }\r\n //Draw a grid around the game grid\r\n gc.strokeRect(0, 0, gridWidth * cellSize, gridHeight * cellSize); \r\n }", "public void aiMove(int turn)\n\t{\n\t\tint row = 0;\n\t\tint col = 0;\n\t\tint choice = 0;\n\t\t/*\n\t\t * Picks a random move on the first turn\n\t\t */\n\t\tif (turn == 0 )\n\t\t{\n\t\t\twhile (true)\n\t\t\t{\n\t\t\t\trow = (int) (Math.random() * 3);\n\t\t\t\tcol = (int) (Math.random() * 3);\n\t\t\t\tchoice = (int) (Math.random() * (ai.size()-1));\n\t\t\t\tif (board[row][col] == 0) \n\t\t\t\t{\t\t// valid move (empty slot)\n\t\t\t\t\tboard[row][col] = ai.get(choice);\n\t\t\t\t\tdraw.drawMove(col, row,ai.get(choice));\n\t\t\t\t\tai.remove(choice);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t\t\n\t\t\t}\n\t\t}\n\t\t/*\n\t\t * Otherwise checks every number, and every square for a winning move\n\t\t */\n\t\telse\n\t\t{\n\t\t\tboolean madeMove = false;\n\t\t\twhile (true) \t\t\t\t\t\t\t\t\t\n\t\t\t{\n\t\t\t\tif (madeMove == true)\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tfor (int a = 0; a <ai.size(); a++)\n\t\t\t\t{\n\t\t\t \t\tfor (int x = 0; x < 3; x++)\t\t\t\t\t//loops through all squares and checks if free\n\t\t\t \t\t{\n\t\t\t \t\t\tfor ( int y = 0; y < 3; y++)\n\t\t\t \t\t\t{\n\t\t\t \t\t\t\tif (madeMove == false)\n\t\t\t \t\t\t\t{\n\t\t\t\t \t\t\t\tif( board[x][y] == 0)\n\t\t\t\t \t\t\t\t{\n\t\t\t\t \t\t\t\t\tif (((x == 0 && y == 0)\t\t\t\t\t//checks for first diagonal and then if it is the winning move\n\t\t\t\t \t\t\t\t\t\t|| (x == 1 && y == 1) \n\t\t\t\t \t\t\t\t\t\t|| (x == 2 && y == 2)))\n\t\t\t\t \t\t\t\t\t{\n\t\t\t\t \t\t\t\t\t\tif (Math.abs(board[0][0] + board[1][1] + board[2][2]) + ai.get(a) == 15)\n\t\t\t\t \t\t\t\t\t\t{\n\t\t\t\t \t\t\t\t\t\t\trow = x;\n\t\t\t\t \t\t\t\t\t\t\tcol = y;\n\t\t\t\t \t\t\t\t\t\t\tboard[x][y] = ai.get(a);\n\t\t\t\t \t\t\t\t\t\t\tmadeMove = true;\n\t\t\t\t \t\t\t\t\t\t\tdraw.drawMove(col, row, ai.get(a));\n\t\t\t\t \t\t\t\t\t\t\tai.remove(a);\n\t\t\t\t \t\t\t\t\t\t\tbreak;\n\t\t\t\t \t\t\t\t\t\t}\n\t\t\t\t \t\t\t\t\t}\n\t\t\t\t \t\t\t\t\tif (((x == 0 && y == 2) \t\t\t//checks second diagonal for winning move\n\t\t\t\t\t \t\t\t\t\t\t|| (x == 1 && y == 1) \n\t\t\t\t\t \t\t\t\t\t\t|| (x == 2 && y == 0)))\n\t\t\t\t\t \t\t\t\t{\n\t\t\t\t \t\t\t\t\t\tif (Math.abs(board[0][2] + board[1][1] + board[2][0]) + ai.get(a) == 15)\n\t\t\t\t \t\t\t\t\t\t{\n\t\t\t\t \t\t\t\t\t\t\trow = x;\n\t\t\t\t \t\t\t\t\t\t\tcol = y;\n\t\t\t\t \t\t\t\t\t\t\tboard[x][y] = ai.get(a);\n\t\t\t\t \t\t\t\t\t\t\tmadeMove = true;\n\t\t\t\t \t\t\t\t\t\t\tdraw.drawMove(col, row, ai.get(a));\n\t\t\t\t \t\t\t\t\t\t\tai.remove(a);\n\t\t\t\t \t\t\t\t\t\t\tbreak;\n\t\t\t\t \t\t\t\t\t\t}\n\t\t\t\t\t \t\t\t\t}\n\t\t\t\t \t\t\t\t\telse if ((Math.abs(board[x][0] + board[x][1] + board[x][2]) + ai.get(a) == 15))\t//checks for winning row\n\t\t\t\t \t\t\t\t\t{\n\t\t\t\t \t\t\t\t\t\trow = x;\n\t\t\t \t\t\t\t\t\t\tcol = y;\n\t\t\t \t\t\t\t\t\t\tboard[x][y] = ai.get(a);\n\t\t\t \t\t\t\t\t\t\tmadeMove = true;\n\t\t\t \t\t\t\t\t\t\tdraw.drawMove(col, row, ai.get(a));\n\t\t\t \t\t\t\t\t\t\tai.remove(a);\n\t\t\t \t\t\t\t\t\t\tbreak;\n\t\t\t\t \t\t\t\t\t}\n\t\t\t\t \t\t\t\t\telse if ((Math.abs(board[0][y] + board[1][y] + board[2][y]) + ai.get(a) == 15)) //checks for winning column\n\t\t\t\t \t\t\t\t\t{\n\t\t\t\t \t\t\t\t\t\trow = x;\n\t\t\t \t\t\t\t\t\t\tcol = y;\n\t\t\t \t\t\t\t\t\t\tboard[x][y] = ai.get(a);\n\t\t\t \t\t\t\t\t\t\tmadeMove = true;\n\t\t\t \t\t\t\t\t\t\tdraw.drawMove(col, row, ai.get(a));\n\t\t\t \t\t\t\t\t\t\tai.remove(a);\n\t\t\t \t\t\t\t\t\t\tbreak;\n\t\t\t\t \t\t\t\t\t}\n\t\t\t\t \t\t\t\t}\n\t\t\t \t\t\t\t}\n\t\t\t\t \t\t}\n\t\t\t\t \t}\n\t\t\t \t\tif (madeMove == false)\t\t\t\t\t\t//if a winning move can't be found, a random one is made\n\t \t\t\t\t{\n\t\t\t\t\t\tchoice = (int) (Math.random() * (ai.size()-1));\n\t \t\t\t\t\trow = (int) (Math.random() * 3);\n\t \t\t\t\t\tcol = (int) (Math.random() * 3);\n\t \t\t\t\t\tif (board[row][col] == 0) \n\t \t\t\t\t\t{\t\t\t// valid move (empty slot)\n\t \t\t\t\t\t\tboard[row][col] = ai.get(choice);\n\t \t\t\t\t\t\tdraw.drawMove(col, row, ai.get(choice));\n\t \t\t\t\t\t\tai.remove(choice);\n\t \t\t\t\t\t\tmadeMove = true;\n\t \t\t\t\t\t\tbreak;\n\t \t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t \t\telse\n\t\t\t \t\t{\n\t\t\t \t\t\tbreak;\n\t\t\t \t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "@Override\n\tpublic void makeMove(Game game) \n\t{\n\t\t\n\t\tint row1,col1,row2,col2;\n\t\tCheckers tttGame = (Checkers) game;\n\t\t\n\t\tboolean first = true;\n\n\t\t\tcorrectmove= false;\n\t\t\tSystem.out.println(\"Insert target (row,column) and destination (row, column) ([0,7])\");\n\n\t\t\trow1 = tttGame.x1;\n\t\t\tcol1 = tttGame.y1;\n\t\t\trow2 = tttGame.x2;\n\t\t\tcol2 = tttGame.y2;\n\t\t\tSystem.out.println(row1 + \" \" + col1 + \" \" + row2 + \" \" + col2 + \" \" + role);\n\t\t\t\n\t\t\tfirst=false;\n\t\tcorrectmove= tttGame.isValidCell(row1, col1, row2, col2,role);\n\t\tSystem.out.println(correctmove);\n\n\t\tif(correctmove)\n\t\t{\n\t\t\ttttGame.board[row2][col2]= tttGame.board[row1][col1];\n\t\t\tif(row2==0 && role==0) \n\t\t\t{\n\t\t\t\tif(role==0) tttGame.board[row2][col2]= 2;\n\t\t\t\telse tttGame.board[row2][col2]= -2;\n\t\t\t}\n\t\t\telse if(row2==7 && role==1) \n\t\t\t{\n\t\t\t\tif(role==0) tttGame.board[row2][col2]= 2;\n\t\t\t\telse tttGame.board[row2][col2]= -2;\n\t\t\t}\n\t\t\ttttGame.board[row1][col1]=0;\n\t\t\tif(abs(row1-row2)==2)\n\t\t\t{\n\t\t\t\tint x= (row1+ row2)/2;\n\t\t\t\tint y= (col1+ col2)/2;\n\t\t\t\ttttGame.board[x][y]=0;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tSystem.out.println(\"invalid move!\");\n\t\t}\n\t\t\n//\t\ttttGame.board[row][col] = role;\n\t}", "private String mediumMove() {\n int a = getBestMoveForBlack(FORESEEN_MOVES * 2);\n System.out.println(\"Moving \" + a);\n return super.makeAMove(a);\n }", "public static void move(int square, char mark) {\n\t\tif (isSquareEmpty(square)) {\n\t\t\tspacesLeft = spacesLeft - 1;\n\t\t}\n\n\t\tif (square == 1) {\n\t\t\tboard[0][0] = mark;\n\t\t} else if (square == 2) {\n\t\t\tboard[0][1] = mark;\n\t\t} else if (square == 3) {\n\t\t\tboard[0][2] = mark;\n\t\t} else if (square == 4) {\n\t\t\tboard[1][0] = mark;\n\t\t} else if (square == 5) {\n\t\t\tboard[1][1] = mark;\n\t\t} else if (square == 6) {\n\t\t\tboard[1][2] = mark;\n\t\t} else if (square == 7) {\n\t\t\tboard[2][0] = mark;\n\t\t} else if (square == 8) {\n\t\t\tboard[2][1] = mark;\n\t\t} else if (square == 9) {\n\t\t\tboard[2][2] = mark;\n\t\t}\n\t}", "private void nextRound() {\n\t\n\t\t\n\t\tcfight++;\n\t\tif(cfight>=maxround)\n\t\t{\n\t\tcfight=0;\n\t\t\n\t\tround++;\n\t\t\tmaxround/=2;\n\t\t}\n\t\t\n\tif(round<4)\n\t{\n\tcontrollPCRound();\n\t}\n\telse\n\t{\n\t\tint sp=0;\n\t\tint round=0;\n\t\tfor(int i=0; i<fighter.length; i++)\n\t\t{\n\t\t\tif(spieler[i]>0)\n\t\t\t{\n\t\t\t\tsp++;\n\t\t\t\tif(fround[i]>round)\n\t\t\t\t{\n\t\t\t\tround=fround[i];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\tif(geld==false)\n\t{\n\t\tgeld=true;\n\t\tif(sp==1)\n\t\t{\n\t\tZeniScreen.addZenis(round*3500);\t\t\n\t\t}\n\t\telse\n\t\t{\n\t\t\tint w=round*4000-500*sp;\n\t\t\tif(w<1)\n\t\t\t{\n\t\t\t\tw=100;\n\t\t\t}\n\t\t\tZeniScreen.addZenis(w);\t\n\t\t}\n\t}\n\t}\n\t\n\t\n\t}", "public void moveBomber(){\n\t\t\t\n\t\t\tif (startredtimer) redtimer++;\n\t\t\tif (redtimer > 5) {\n\t\t\t\tredtimer = 0;\n\t\t\t\tstartredtimer = false;\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t\tif (rand.nextInt(21) == 20){ //controls the switching of directions\n\t\t\t\tif (direction == 1) direction = 0;\n\t\t\t\telse if (direction == 0) direction = 1;\n\t\t\t}\n\t\t\tif (direction == 1){ //actually moves the plain\n\t\t\t\tx += 10;\n\t\t\t\tr = true;\n\t\t\t}\n\t\t\telse if (direction == 0){\n\t\t\t\tx -= 10;\n\t\t\t\tr = false;\n\t\t\t}\n\t\t\t\n\t\t\tif (x <= 0) x = 992; //handles the ofscrean plane\n\t\t\telse if ( x >= 992) x = 0;\n\t\t\t\n\t\t\tthis.setBounds(x,y,100,50); //updates the bounds\n\t\t\t\n\t\t}", "public void setPieces(){\r\n Pawn[] arrwPawn = new Pawn[8];\r\n for (int i=0 ; i<8 ; i++){\r\n pos.setPosition(6,i);\r\n arrwPawn[i] = new Pawn (pos , piece.Colour.WHITE);\r\n GameBoard.putPiece(arrwPawn[i]);\r\n }\r\n\r\n Pawn[] arrbPawn = new Pawn[8];\r\n for(int i=0 ; i<8 ; i++){\r\n pos.setPosition(0,i);\r\n arrbPawn[i] = new Pawn(pos , piece.Colour.BLACK);\r\n GameBoard.putPiece(arrbPawn[i]);\r\n }\r\n\r\n\r\n //set black pieces in the board\r\n\r\n pos.setPosition(0,0);\r\n Rook bRook1 = new Rook(pos, piece.Colour.BLACK);\r\n GameBoard.putPiece(bRook1);;\r\n\r\n pos.setPosition(0,7);\r\n Rook bRook2 = new Rook(pos, piece.Colour.BLACK);\r\n GameBoard.putPiece(bRook2);\r\n\r\n\r\n pos.setPosition(0,1);\r\n Knight bKnight1 = new Knight(pos, piece.Colour.BLACK);\r\n GameBoard.putPiece(bKnight1);\r\n\r\n pos.setPosition(0,6);\r\n Knight bKnight2 = new Knight(pos, piece.Colour.BLACK);\r\n GameBoard.putPiece(bKnight1);\r\n\r\n pos.setPosition(0,2);\r\n Bishop bBishop1 = new Bishop(pos, piece.Colour.BLACK);\r\n GameBoard.putPiece(bBishop1);\r\n\r\n pos.setPosition(0,5);\r\n Bishop bBishop2 = new Bishop(pos, piece.Colour.BLACK);\r\n GameBoard.putPiece(bBishop2);\r\n\r\n pos.setPosition(0,3);\r\n Queen bQueen = new Queen(pos, piece.Colour.BLACK);\r\n GameBoard.putPiece(bQueen);\r\n\r\n pos.setPosition(0,4);\r\n King bKing = new King(pos, piece.Colour.BLACK);\r\n GameBoard.putPiece(bKing);\r\n\r\n //set white pieces in the board\r\n\r\n pos.setPosition(7,0);\r\n Rook wRook1 = new Rook(pos, piece.Colour.WHITE);\r\n GameBoard.putPiece(wRook1);\r\n\r\n pos.setPosition(7,7);\r\n Rook wRook2 = new Rook(pos, piece.Colour.WHITE);\r\n GameBoard.putPiece(wRook2);\r\n\r\n pos.setPosition(7,1);\r\n Knight wKnight1 = new Knight(pos, piece.Colour.WHITE);\r\n GameBoard.putPiece(wKnight1);\r\n\r\n pos.setPosition(7,6);\r\n Knight wKnight2 = new Knight(pos, piece.Colour.WHITE);\r\n GameBoard.putPiece(wKnight1);\r\n\r\n pos.setPosition(7,2);\r\n Bishop wBishop1 = new Bishop(pos, piece.Colour.WHITE);\r\n GameBoard.putPiece(wBishop1);\r\n\r\n pos.setPosition(7,5);\r\n Bishop wBishop2 = new Bishop(pos, piece.Colour.WHITE);\r\n GameBoard.putPiece(wBishop2);\r\n\r\n pos.setPosition(7,3);\r\n Queen wQueen = new Queen(pos, piece.Colour.WHITE);\r\n GameBoard.putPiece(wQueen);\r\n\r\n pos.setPosition(7,4);\r\n King wKing = new King(pos, piece.Colour.WHITE);\r\n GameBoard.putPiece(wKing);\r\n\r\n\r\n\r\n Rook arrwRook[] = {wRook1,wRook2};\r\n Rook arrbRook[] = {bRook1,bRook2};\r\n Queen arrwQueen[] = {wQueen};\r\n Queen arrbQueen[] = {bQueen};\r\n Knight arrwKnight[] = {wKnight1,wKnight2};\r\n Knight arrbKnight[] = {bKnight1,bKnight2};\r\n King arrwKing[] = {wKing};\r\n King arrbKing[] = {bKing};\r\n Bishop arrwBishop[] = {wBishop1,wBishop2};\r\n Bishop arrbBishop[] = {bBishop1,bBishop2};\r\n }", "public void move(FightCell cell);", "public void initializeBoard() {\n\n\t\t/*\n\t\t * How the array coordinates align with the actual chess board\n\t\t * (row,col) \n\t\t * (7,0) ... ... ... \n\t\t * (7,7) ... ... ... \n\t\t * ... ... ... \n\t\t * (2,0) ...\n\t\t * (1,0) ... \n\t\t * (0,0) ... ... ... (0,7)\n\t\t */\n\n\t\tboolean hasMoved = false;\n\t\tboolean white = true;\n\t\tboolean black = false;\n\n\t\t// Set white piece row\n\t\tboard[0][0] = new Piece('r', white, hasMoved, 0, 0, PieceArray.A_rookId);\n\t\tboard[0][1] = new Piece('n', white, hasMoved, 0, 1, PieceArray.B_knightId);\n\t\tboard[0][2] = new Piece('b', white, hasMoved, 0, 2, PieceArray.C_bishopId);\n\t\tboard[0][3] = new Piece('q', white, hasMoved, 0, 3, PieceArray.D_queenId);\n\t\tboard[0][4] = new Piece('k', white, hasMoved, 0, 4, PieceArray.E_kingId);\n\t\tboard[0][5] = new Piece('b', white, hasMoved, 0, 5, PieceArray.F_bishopId);\n\t\tboard[0][6] = new Piece('n', white, hasMoved, 0, 6, PieceArray.G_knightId);\n\t\tboard[0][7] = new Piece('r', white, hasMoved, 0, 7, PieceArray.H_rookId);\n\n\t\t// Set white pawns\n\t\tfor (int i = 0; i < 8; i++) {\n\t\t\tboard[1][i] = new Piece('p', white, hasMoved, 1, i, i + 8);\n\t\t}\n\n\t\t// Set empty rows\n\t\tfor (int row = 2; row < 6; row++)\n\t\t\tfor (int col = 0; col < 8; col++)\n\t\t\t\tboard[row][col] = null;\n\n\t\t// Set black pawns\n\t\tfor (int i = 0; i < 8; i++) {\n\t\t\tboard[6][i] = new Piece('p', black, hasMoved, 6, i, i+8);\n\t\t}\n\n\t\t// Set black piece row\n\t\tboard[7][0] = new Piece('r', black, hasMoved, 7, 0, PieceArray.A_rookId);\n\t\tboard[7][1] = new Piece('n', black, hasMoved, 7, 1, PieceArray.B_knightId);\n\t\tboard[7][2] = new Piece('b', black, hasMoved, 7, 2, PieceArray.C_bishopId);\n\t\tboard[7][3] = new Piece('q', black, hasMoved, 7, 3, PieceArray.D_queenId);\n\t\tboard[7][4] = new Piece('k', black, hasMoved, 7, 4, PieceArray.E_kingId);\n\t\tboard[7][5] = new Piece('b', black, hasMoved, 7, 5, PieceArray.F_bishopId);\n\t\tboard[7][6] = new Piece('n', black, hasMoved, 7, 6, PieceArray.G_knightId);\n\t\tboard[7][7] = new Piece('r', black, hasMoved, 7, 7, PieceArray.H_rookId);\n\t}", "private void onClickHandler(MouseEvent e) {\n Circle source = (Circle) e.getSource();\n int selectColumnIndex = GridPane.getColumnIndex(source);\n // Display the move of Player on the Grid, and registered that move to the Game logic\n checkCircle(selectColumnIndex);\n client.getHumanPlayer().play((byte) selectColumnIndex);\n // Check if player's move is a winning move. 1 mean player\n if (client.getHumanPlayer().getGame().playerHasWon((byte) 1)) {\n playerWinCounter++;\n playerCounter.setText((Integer.toString(playerWinCounter)));\n winDisplay.setText(\"YOU WON THE MATCH.\\nClick Reset to replay, , or Quit to Close the Game\\n\");\n // Disable the Grid so user Cannot continue after they won\n grid.setDisable(true);\n // Exit the method\n return;\n } // --------------------- \\\\\n // If the last move from Player is NOT a winning move, send the Player's move to server \n else {\n // Disable the Grid so user cannot make move while waiting for AI to respond\n grid.setDisable(true);\n try {\n serverPackage = client.sendAndReceive(client.getSocket(), client.getPackage(), 1, selectColumnIndex);\n } catch (IOException error) {\n System.out.println(\"There is an error while trying to send the Client move to server: \" + error + \"\\n\");\n }\n }\n\n // Get the move from the server\n int serverMove = client.checkPackage(serverPackage);\n // Display the move of AI on the Grid, and registered that move to the Game logic\n checkCircle(serverMove);\n client.getGame().getBoard().insertToken((byte) serverMove, (byte) 2);\n // Check if AI's move is a winning move. 2 mean AI\n if (client.getHumanPlayer().getGame().playerHasWon((byte) 2)) {\n AIwinCounter++;\n aiCounter.setText(Integer.toString(AIwinCounter));\n winDisplay.setText(\"COMPUTER WON THE MATCH.\\nClick Reset to replay, or Quit to Close the Game\");\n grid.setDisable(true);\n // Exit the method\n return;\n }\n\n // If 42 moves have been made, and noone win, then it's a draw\n if (client.getGame().isDraw()) {\n winDisplay.setText(\"IT IS A DRAW.\\nClick Reset to replay, or Quit to Close the Game\");\n grid.setDisable(true);\n // Exit the method\n return;\n }\n // Enable the Grid again so User can Play\n grid.setDisable(false);\n }", "public Action getMove(CritterInfo info) {\n\n turn++;\n\n if (info.getFront() == Neighbor.OTHER) {\n return Action.INFECT;\n } else if (info.getFront() == Neighbor.WALL || info.getRight() == Neighbor.WALL) {\n return Action.LEFT;\n } else if (info.getFront() == Neighbor.SAME) {\n return Action.RIGHT;\n } else {\n return Action.HOP;\n }\n }", "public void doAction()\n {\n \n //Location of the player\n int cX = w.getPlayerX();\n int cY = w.getPlayerY();\n \n //Basic action:\n //Grab Gold if we can.\n if (w.hasGlitter(cX, cY))\n {\n w.doAction(World.A_GRAB);\n return;\n }\n \n //Basic action:\n //We are in a pit. Climb up.\n if (w.isInPit())\n {\n w.doAction(World.A_CLIMB);\n return;\n }\n //Test the environment\n /*if (w.hasBreeze(cX, cY))\n {\n System.out.println(\"I am in a Breeze\");\n }\n if (w.hasStench(cX, cY))\n {\n System.out.println(\"I am in a Stench\");\n }\n if (w.hasPit(cX, cY))\n {\n System.out.println(\"I am in a Pit\");\n }\n if (w.getDirection() == World.DIR_RIGHT)\n {\n System.out.println(\"I am facing Right\");\n }\n if (w.getDirection() == World.DIR_LEFT)\n {\n System.out.println(\"I am facing Left\");\n }\n if (w.getDirection() == World.DIR_UP)\n {\n System.out.println(\"I am facing Up\");\n }\n if (w.getDirection() == World.DIR_DOWN)\n {\n System.out.println(\"I am facing Down\");\n }\n */\n \n //decide next move\n if(w.hasStench(cX, cY)&&w.hasArrow())//Wumpus can be shot if located\n {\n if((w.hasStench(cX, cY+2))||(w.hasStench(cX-1, cY+1)&&w.isVisited(cX-1, cY))||(w.hasStench(cX+1, cY+1)&&w.isVisited(cX+1, cY)))//Condition for checking wumpus location\n {\n turnTo(World.DIR_UP);\n w.doAction(World.A_SHOOT);\n }\n else if((w.hasStench(cX+2, cY))||(w.hasStench(cX+1, cY-1)&&w.isVisited(cX, cY-1))||(w.hasStench(cX+1, cY+1)&&w.isVisited(cX, cY+1)))//Condition for checking wumpus location\n {\n turnTo(World.DIR_RIGHT);\n w.doAction(World.A_SHOOT);\n }\n else if((w.hasStench(cX, cY-2))||(w.hasStench(cX-1, cY-1)&&w.isVisited(cX-1, cY))||(w.hasStench(cX+1, cY-1)&&w.isVisited(cX+1, cY)))//Condition for checking wumpus location\n {\n turnTo(World.DIR_DOWN);\n w.doAction(World.A_SHOOT);\n }\n else if((w.hasStench(cX-2, cY))||(w.hasStench(cX-1, cY+1)&&w.isVisited(cX, cY+1))||(w.hasStench(cX-1, cY-1)&&w.isVisited(cX, cY-1)))//Condition for checking wumpus location\n {\n turnTo(World.DIR_LEFT);\n w.doAction(World.A_SHOOT);\n }\n else if(cX==1&&cY==1) //First tile. Shoot North. If wumpus still alive, store its location as (2,1) to avoid it\n {\n turnTo(World.DIR_UP);\n w.doAction(World.A_SHOOT);\n if(w.hasStench(cX, cY))\n {\n wumpusLoc[0] = 2;\n wumpusLoc[1] = 1;\n }\n }\n else if(cX==1&&cY==4) //Condition for corner\n {\n if(w.isVisited(1, 3))\n {\n turnTo(World.DIR_RIGHT);\n w.doAction(World.A_SHOOT);\n }\n if(w.isVisited(2, 4))\n {\n turnTo(World.DIR_DOWN);\n w.doAction(World.A_SHOOT);\n }\n \n }\n else if(cX==4&&cY==1) //Condition for corner\n {\n if(w.isVisited(3, 1))\n {\n turnTo(World.DIR_UP);\n w.doAction(World.A_SHOOT);\n }\n if(w.isVisited(4, 2))\n {\n turnTo(World.DIR_LEFT);\n w.doAction(World.A_SHOOT);\n }\n \n }\n else if(cX==4&&cY==4) //Condition for corner\n {\n if(w.isVisited(3, 4))\n {\n turnTo(World.DIR_DOWN);\n w.doAction(World.A_SHOOT);\n }\n if(w.isVisited(4, 3))\n {\n turnTo(World.DIR_LEFT);\n w.doAction(World.A_SHOOT);\n }\n \n }\n else if((cX==1)&&(w.isVisited(cX+1, cY-1))) //Condition for edge\n {\n \n turnTo(World.DIR_UP);\n w.doAction(World.A_SHOOT);\n }\n else if((cX==4)&&(w.isVisited(cX-1, cY-1))) //Condition for edge\n {\n turnTo(World.DIR_UP);\n w.doAction(World.A_SHOOT);\n }\n else if((cY==1)&&(w.isVisited(cX-1, cY+1))) //Condition for edge\n {\n turnTo(World.DIR_RIGHT);\n w.doAction(World.A_SHOOT);\n }\n else if((cY==4)&&(w.isVisited(cX-1, cY-1))) //Condition for edge\n {\n turnTo(World.DIR_RIGHT);\n w.doAction(World.A_SHOOT);\n }\n else //Can't locate wumpus, go back to safe location\n {\n turnTo((w.getDirection()+2)%4);\n w.doAction(World.A_MOVE);\n }\n }\n else // No stench. Explore \n {\n if(w.isValidPosition(cX, cY-1)&&!w.isVisited(cX, cY-1)&&isSafe(cX, cY-1)) \n {\n turnTo(World.DIR_DOWN);\n w.doAction(World.A_MOVE);\n }\n else if(w.isValidPosition(cX+1, cY)&&!w.isVisited(cX+1, cY)&&isSafe(cX+1, cY))\n {\n turnTo(World.DIR_RIGHT);\n w.doAction(World.A_MOVE);\n }\n else if(w.isValidPosition(cX-1, cY)&&!w.isVisited(cX-1, cY)&&isSafe(cX-1,cY))\n {\n turnTo(World.DIR_LEFT);\n w.doAction(World.A_MOVE);\n }\n else\n {\n if(w.isValidPosition(cX, cY+1))\n {\n turnTo(World.DIR_UP);\n w.doAction(World.A_MOVE);\n }\n else if(w.isValidPosition(cX+1, cY))\n {\n turnTo(World.DIR_RIGHT);\n w.doAction(World.A_MOVE);\n }\n else if(w.isValidPosition(cX-1, cY))\n {\n turnTo(World.DIR_LEFT);\n w.doAction(World.A_MOVE);\n }\n }\n }\n \n }", "public static void main(String[] args) {\n\t\tBoard gameBoard = new Board();\n\t\tDisplay screen = new TextDisplay();\n\n\t\t// give each player some pieces\n\t\tPieces blackPieces = new Pieces(gameBoard, PieceCode.BLACK);\n\t\tPieces whitePieces = new Pieces(gameBoard, PieceCode.WHITE);\n\n\t\t// Player blackPlayer = new HumanPlayer(\"Black\", blackPieces, gameBoard, null);\n\t\t// Player blackPlayer = new RandomPlayer(\"Black\", blackPieces, gameBoard, null);\n\t\tPlayer blackPlayer = new AggressivePlayer(\"Black\", blackPieces, gameBoard, null);\n\n\t\tPlayer whitePlayer = new HumanPlayer(\"White\", whitePieces, gameBoard, null);\n\t\t// Player whitePlayer = new RandomPlayer(\"White\", whitePieces, gameBoard,null);\n\t\t// Player whitePlayer = new AggressivePlayer(\"White\", whitePieces,\n\t\t// gameBoard,null);\n\n\t\tblackPlayer.setOpponent(whitePlayer);\n\t\twhitePlayer.setOpponent(blackPlayer);\n\n\t\tPlayer activePlayer = whitePlayer;\n\t\t// while both kings are alive\n\t\twhile (blackPlayer.getPieces().getPiece(blackPlayer.getPieces().getNumPieces() - 1).getValue() == PieceCode.KING\n\t\t\t\t&& whitePlayer.getPieces().getPiece(whitePlayer.getPieces().getNumPieces() - 1)\n\t\t\t\t\t\t.getValue() == PieceCode.KING) {\n\n\t\t\tscreen.displayBoard(activePlayer.getPieces());\n\t\t\tBoolean madeMove = false;\n\n\t\t\twhile (!madeMove) {\n\t\t\t\tmadeMove = activePlayer.makeMove();\n\t\t\t}\n\n\t\t\tactivePlayer = activePlayer.getOpponent();\n\t\t}\n\t\t// Display the end board\n\t\tscreen.displayBoard(activePlayer.getPieces());\n\n\t\t// Find out who's king died\n\t\tPlayer winner = null;\n\t\tif (blackPlayer.getPieces().getPiece(blackPlayer.getPieces().getNumPieces() - 1).getValue() == PieceCode.KING) {\n\t\t\twinner = blackPlayer;\n\t\t} else {\n\t\t\twinner = whitePlayer;\n\t\t}\n\t\t// and crown them champion\n\t\tSystem.out.println(winner + \" Wins!\");\n\t}", "private int Win_Move() {\n\t\tfinal int POSSIBLE_WIN = 8;\n\t\tint move = NO_MOVE;\n\t\tif(( gameBoard[TOP_LEFT] + gameBoard[TOP_CENTER] + gameBoard[TOP_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[TOP_CENTER] == EMPTY){\n\t\t\t\tmove = TOP_CENTER;\n\t\t\t}else if (gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[CTR_LEFT] + gameBoard[CTR_CENTER] + gameBoard[CTR_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[CTR_LEFT] == EMPTY){\n\t\t\t\tmove = CTR_LEFT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[CTR_RIGHT] == EMPTY){\n\t\t\t\tmove = CTR_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[BTM_LEFT] + gameBoard[BTM_CENTER] + gameBoard[BTM_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}else if (gameBoard[BTM_CENTER] == EMPTY){\n\t\t\t\tmove = BTM_CENTER;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_LEFT] + gameBoard[CTR_LEFT] + gameBoard[BTM_LEFT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[CTR_LEFT] == EMPTY){\n\t\t\t\tmove = CTR_LEFT;\n\t\t\t}else if (gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_CENTER] + gameBoard[CTR_CENTER] + gameBoard[BTM_CENTER]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_CENTER] == EMPTY){\n\t\t\t\tmove = TOP_CENTER;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_CENTER] == EMPTY){\n\t\t\t\tmove = BTM_CENTER;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_RIGHT] + gameBoard[CTR_RIGHT] + gameBoard[BTM_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}else if (gameBoard[CTR_RIGHT] == EMPTY){\n\t\t\t\tmove = CTR_RIGHT;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_LEFT] + gameBoard[CTR_CENTER] + gameBoard[BTM_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_RIGHT] + gameBoard[CTR_CENTER] + gameBoard[BTM_LEFT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}\n\t\t}\n\t\treturn move;\n\t}", "@Override\n\tpublic void mousePressed(MouseEvent me) {\n\t\tint x = me.getX();\n\t\tint y = me.getY();\n\t\tx = (int)( (x-mrg_x+spc_x/2) / spc_x) + nWALL;\n\t\ty = (int)( (y-mrg_y+spc_y/2) / spc_y) + nWALL;\n\t\t\n\t\tif (isPlaying && arr[x][y] == NONE) {\n\t\t// TODO Auto-generated method stub\n\t\t\t\n\t\t\t\n\t\t\tint t = (n+isWhiteWin+1) %2 ;\n\t\t\t\n\t\t\tif ( is33(x, y, (t%2==0)? WHITE:BLACK) ) {\n\t\t\t\t\n\t\t\t\tGraphics g = cvBoard.getGraphics();\n\t\t\t\tg.setColor(Color.red);\n\t\t\t\tg.drawOval((int) (mrg_x + (x-nWALL) * spc_x - spc_x/2) ,\n\t\t\t\t\t\t(int) (mrg_y + (y-nWALL) * spc_y -spc_y/2),\n\t\t\t\t\t\t(int) spc_x-1, (int) spc_y-1);\n\t\t\t\tg.fillOval((int) (mrg_x + (x-nWALL) * spc_x - spc_x/2) ,\n\t\t\t\t\t\t(int) (mrg_y + (y-nWALL) * spc_y -spc_y/2),\n\t\t\t\t\t\t(int) spc_x, (int) spc_y);\n\t\t\t}\n\t\t\t\n\t\t}\n\n\t}", "public void faceUp(){\r\n changePlace(hand);\r\n //do a magical work\r\n changePlace(graveYard);\r\n }", "private static void play(Board chess, Scanner scan) {\r\n boolean whiteCanCastle = true;\r\n boolean blackCanCastle = true;\r\n\r\n // Get's user's choice\r\n // Split into the <old x position>, <old y position>, <new x position>, <new y position>\r\n for (int i = 0; i < 100; i++) {\r\n // Gets the user's requested move, moves the pieces (with move verification), and prints the final board\r\n int[] move = Tasks.getMove(chess, scan);\r\n boolean valid = chess.move(move[1], move[0], move[3], move[2], move[4], move[5]);\r\n if (move[4] == 99 && valid) {whiteCanCastle = false;}\r\n else if (move[4] == -99 && valid) {blackCanCastle = false;}\r\n chess.printBoard();\r\n }\r\n // System.out.println(\"50 Move Rule Exceeded!\\nGame Over!\");\r\n }" ]
[ "0.6356678", "0.6218137", "0.6209278", "0.6179475", "0.6175234", "0.6172553", "0.6088661", "0.6086468", "0.6055479", "0.6035897", "0.60346895", "0.5994513", "0.5953392", "0.5942921", "0.59334", "0.5931044", "0.59191746", "0.5918819", "0.58946794", "0.5886772", "0.5859846", "0.58452487", "0.58415437", "0.5781011", "0.5760972", "0.5748874", "0.5732275", "0.5726339", "0.57229614", "0.5714513", "0.5708241", "0.5695813", "0.56778264", "0.5676442", "0.56744176", "0.5655024", "0.5653637", "0.5641638", "0.5640182", "0.5631629", "0.562811", "0.56241524", "0.5622051", "0.5613954", "0.5608372", "0.56062114", "0.55949616", "0.55935454", "0.5592725", "0.5591256", "0.5571837", "0.55475914", "0.5523039", "0.5517239", "0.55169755", "0.550793", "0.55078876", "0.55022657", "0.5495594", "0.54935706", "0.54747504", "0.54707426", "0.5453097", "0.5444945", "0.54289997", "0.5425836", "0.5423881", "0.54235774", "0.54230726", "0.5423062", "0.5421751", "0.54186743", "0.54173875", "0.5406259", "0.5402917", "0.53997976", "0.5396797", "0.53953904", "0.5394034", "0.5393168", "0.5389246", "0.5377612", "0.53730756", "0.5372056", "0.53711486", "0.53668153", "0.53549486", "0.5351678", "0.53503096", "0.534316", "0.53418076", "0.53337455", "0.53265107", "0.5324972", "0.53231955", "0.5321344", "0.53150946", "0.5313247", "0.5309028", "0.5308838" ]
0.6255479
1
Handle queen side castling. Queen side castling is annotated as "OOO" and moves the king to c1 for white and c8 for black and the rook to d1 for white and d8 for black. This method moves the king and rook to the correct square.
public static void castleQueenSide(char color) { String colorString = Character.toString(color); String king = "K" + colorString; String rook = "R" + colorString; int rank = color == 'w' ? 0 : 7; move(king, 4, rank, 2, rank); move(rook, 0, rank, 3, rank); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public Board move(String s, boolean si) {\t\t\n\t\t\n\t\t//Queen-side castling\n\t\tif (s.length() >= 5 && s.substring(0, 5).equals(\"O-O-O\")) {\n\t\t\t\n\t\t\tPiece tempKing;\n\t\t\tPiece tempRook;\n\t\t\tPiece tempNull1;\n\t\t\tPiece tempNull2;\n\t\t\t\n\t\t\tif (si) {\n\t\t\t\t((King) b[0][4]).castle();\n\t\t\t\ttempKing = b[0][4];\n\t\t\t\ttempRook = b[0][0];\n\t\t\t\ttempNull1 = b[0][2];\n\t\t\t\ttempNull2 = b[0][3];\n\t\t\t\t\n\t\t\t\tb[0][2] = tempKing;\n\t\t\t\tb[0][3] = tempRook;\n\t\t\t\tb[0][2].setPosition((byte) 0, (byte) 2);\n\t\t\t\tb[0][3].setPosition((byte) 0, (byte) 3);\n\t\t\t\t\n\t\t\t\tb[0][0] = tempNull1;\n\t\t\t\tb[0][4] = tempNull2;\n\t\t\t\tb[0][0].setPosition((byte) 0, (byte) 0);\n\t\t\t\tb[0][4].setPosition((byte) 0, (byte) 4);\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\t((King) b[7][4]).castle();\n\t\t\t\ttempKing = b[7][4];\n\t\t\t\ttempRook = b[7][0];\n\t\t\t\ttempNull1 = b[7][2];\n\t\t\t\ttempNull2 = b[7][3];\n\t\t\t\t\n\t\t\t\tb[7][2] = tempKing;\n\t\t\t\tb[7][3] = tempRook;\n\t\t\t\tb[7][2].setPosition((byte) 7, (byte) 2);\n\t\t\t\tb[7][3].setPosition((byte) 7, (byte) 3);\n\t\t\t\t\n\t\t\t\tb[7][0] = tempNull1;\n\t\t\t\tb[7][4] = tempNull2;\n\t\t\t\tb[7][0].setPosition((byte) 7, (byte) 0);\n\t\t\t\tb[7][4].setPosition((byte) 7, (byte) 4);\n\t\t\t}\n\t\t\t\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t//King-side castling\n\t\tif (s.substring(0, 3).equals(\"O-O\")) {\n\t\t\tPiece tempKing;\n\t\t\tPiece tempRook;\n\t\t\tPiece tempNull1;\n\t\t\tPiece tempNull2;\n\t\t\t\n\t\t\tif (si) {\n\t\t\t\t((King) b[0][4]).castle();\n\t\t\t\t\n\t\t\t\ttempKing = b[0][4];\n\t\t\t\ttempRook = b[0][7];\n\t\t\t\ttempNull1 = b[0][5];\n\t\t\t\ttempNull2 = b[0][6];\n\t\t\t\t\n\t\t\t\tb[0][6] = tempKing;\n\t\t\t\tb[0][5] = tempRook;\n\t\t\t\tb[0][6].setPosition((byte) 0, (byte) 6);\n\t\t\t\tb[0][5].setPosition((byte) 0, (byte) 5);\n\t\t\t\t\n\t\t\t\tb[0][7] = tempNull1;\n\t\t\t\tb[0][4] = tempNull2;\n\t\t\t\tb[0][7].setPosition((byte) 0, (byte) 7);\n\t\t\t\tb[0][4].setPosition((byte) 0, (byte) 4);\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\t((King) b[7][4]).castle();\n\t\t\t\t\n\t\t\t\ttempKing = b[7][4];\n\t\t\t\ttempRook = b[7][7];\n\t\t\t\ttempNull1 = b[7][5];\n\t\t\t\ttempNull2 = b[7][6];\n\t\t\t\t\n\t\t\t\tb[7][6] = tempKing;\n\t\t\t\tb[7][5] = tempRook;\n\t\t\t\tb[7][6].setPosition((byte) 7, (byte) 6);\n\t\t\t\tb[7][5].setPosition((byte) 7, (byte) 5);\n\t\t\t\t\n\t\t\t\tb[7][7] = tempNull1;\n\t\t\t\tb[7][4] = tempNull2;\n\t\t\t\tb[7][7].setPosition((byte) 7, (byte) 7);\n\t\t\t\tb[7][4].setPosition((byte) 7, (byte) 4);\n\t\t\t}\n\t\t\t\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\tbyte fR, fC, tR, tC;\n\t\t\n\t\tfR = (byte) (Byte.parseByte(s.substring(2, 3)) - 1);\n\t\ttR = (byte) (Byte.parseByte(s.substring(5, 6)) - 1);\n\t\t\n\t\tif (s.charAt(1) == 'a') {\n\t\t\tfC = 0;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'b') {\n\t\t\tfC = 1;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'c') {\n\t\t\tfC = 2;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'd') {\n\t\t\tfC = 3;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'e') {\n\t\t\tfC = 4;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'f') {\n\t\t\tfC = 5;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'g') {\n\t\t\tfC = 6;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'h') {\n\t\t\tfC = 7;\n\t\t}\n\t\t\n\t\telse {\n\t\t\tSystem.out.println(\"Invalid Entry\");\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\tif (s.charAt(4) == 'a') {\n\t\t\ttC = 0;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'b') {\n\t\t\ttC = 1;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'c') {\n\t\t\ttC = 2;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'd') {\n\t\t\ttC = 3;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'e') {\n\t\t\ttC = 4;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'f') {\n\t\t\ttC = 5;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'g') {\n\t\t\ttC = 6;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'h') {\n\t\t\ttC = 7;\n\t\t}\n\t\t\n\t\telse {\n\t\t\tSystem.out.println(\"Invalid Entry\");\n\t\t\treader.pause();\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\tif (b[fR][fC] instanceof King) {\n\t\t\t((King) b[fR][fC]).cantC(0);\n\t\t}\n\t\t\n\t\tif (b[fR][fC] instanceof Rook) {\n\t\t\tif (si) {\n\t\t\t\tif (fR == 0 && fC == 0) {\n\t\t\t\t\tgetKing(si).cantC(-1);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\telse if (fR == 0 && fC == 7) {\n\t\t\t\t\tgetKing(si).cantC(1);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\tif (fR == 7 && fC == 0) {\n\t\t\t\t\tgetKing(si).cantC(-1);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\telse if (fR == 7 && fC == 7) {\n\t\t\t\t\tgetKing(si).cantC(1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tb[tR][tC] = b[fR][fC];\n\t\tb[tR][tC].setPosition(tR, tC);\n\t\tb[fR][fC] = new Null(fR, fC);\n\t\t\n\t\tif (s.length() >= 8 && s.charAt(6) == '=') {\n\t\t\tchar p = s.charAt(7);\n\t\t\t\n\t\t\tif (p == 'N') {\n\t\t\t\tb[tR][tC] = new Knight(si, tR, tC);\n\t\t\t}\n\t\t\n\t\t\telse if (p == 'B') {\n\t\t\t\tb[tR][tC] = new Bishop(si, tR, tC);\n\t\t\t}\n\t\t\t\n\t\t\telse if (p == 'R') {\n\t\t\t\tb[tR][tC] = new Rook(si, tR, tC);\n\t\t\t}\n\t\t\t\n\t\t\telse if (p == 'Q') {\n\t\t\t\tb[tR][tC] = new Queen(si, tR, tC);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}", "@Test\n public void testQueenSide() {\n // initialize the complete chess board\n ChessBoard chessBoard = init(\"CHESS\");\n\n assertEquals(north, chessBoard.getPiece(0, 3).getSide());\n assertEquals(south, chessBoard.getPiece(7, 3).getSide());\n }", "public void specialMove() {\n\t\tChessSquare initial = getSquare();\n\t\tChessSquare next;\n\t\t\n\t\tif(initial.getNorth() != null){\n\t\t\tnext = initial.getNorth();\n\t\t\t\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getEast() != null)\n\t\t\t\tif((next.getEast().getOccupant() == null) || (!next.getEast().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getWest() != null && next.getWest().getOccupant() == null)\n\t\t\t\tif((next.getWest().getOccupant() == null) || (!next.getWest().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t}\n\t\t\n\t\tif(initial.getSouth() != null){\n\t\t\tnext = initial.getSouth();\n\t\t\t\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getEast() != null)\n\t\t\t\tif((next.getEast().getOccupant() == null) || (!next.getEast().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getWest() != null)\n\t\t\t\tif((next.getWest().getOccupant() == null) || (!next.getWest().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t\t\n\t\t}\n\t\t\n\t\tnext = initial.getEast();\n\t\tif(next != null)\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\tnext = initial.getWest();\n\t\tif(next != null)\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\tsetCountdown(9);\n\t}", "private static void addQueenMoves(BitBoard board, LinkedList<Move> moveList, int index,\n\t\t\tint side) {\n\t\tint pieceType = (side == 0) ? CoreConstants.WHITE_QUEEN : CoreConstants.BLACK_QUEEN;\n\t\tlong rookBlockers = (board.getBitBoards()[CoreConstants.WHITE]\n\t\t\t\t| board.getBitBoards()[CoreConstants.BLACK])\n\t\t\t\t& CoreConstants.occupancyMaskRook[index];\n\t\tint lookupIndexRook = (int) ((rookBlockers\n\t\t\t\t* CoreConstants.magicNumbersRook[index]) >>> CoreConstants.magicShiftRook[index]);\n\t\tlong moveSquaresRook = CoreConstants.magicMovesRook[index][lookupIndexRook]\n\t\t\t\t& ~board.getBitBoards()[side];\n\n\t\tlong bishopBlockers = (board.getBitBoards()[CoreConstants.WHITE]\n\t\t\t\t| board.getBitBoards()[CoreConstants.BLACK])\n\t\t\t\t& CoreConstants.occupancyMaskBishop[index];\n\t\tint lookupIndexBishop = (int) ((bishopBlockers\n\t\t\t\t* CoreConstants.magicNumbersBishop[index]) >>> CoreConstants.magicShiftBishop[index]);\n\t\tlong moveSquaresBishop = CoreConstants.magicMovesBishop[index][lookupIndexBishop]\n\t\t\t\t& ~board.getBitBoards()[side];\n\n\t\tlong queenMoves = moveSquaresRook | moveSquaresBishop;\n\t\taddMoves(pieceType, index, queenMoves, moveList, false, false, CoreConstants.noCastle);\n\t}", "@Override\r\n\tpublic boolean makeMove(String notation) {\n\t\tif(Castle.isCastlingMove(new ChessCoordinate(notation))) {\r\n\t\t\tKing playerKing = (King) getPlayerTurn().getPieces(\"King\", true).get(0);\r\n\t\t\t//return the result of trying to castle\r\n\t\t\treturn playerKing.move(new ChessCoordinate(notation));\r\n\t\t\t\r\n\t\t}else {\r\n\t\t\t//not a castling move, standard move\r\n\t\t\t\t\r\n\t\t\tString[] notationList = notation.split(\"\");\r\n\t\t\t//find the piece name\r\n\t\t\tString pieceName = ChessPieceNames.getPieceName(notationList[0]);\t\t\r\n\t\t\t\r\n\t\t\tif(pieceName == null && getColumnNames().contains(notationList[0].toLowerCase())) {\r\n\t\t\t\t//if first character is a column and returned null from above\r\n\t\t\t\t//must be a pawn move like e4 or axb2\r\n\t\t\t\tpieceName = ChessPieceNames.PAWN.toString();\r\n\t\t\t}else if(pieceName == null){\r\n\t\t\t\t//not a column and null so invalid move\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\r\n//\t\t\t//capturing move if there is a capture (x)\r\n\t\t\tboolean isCaptureMove = Arrays.asList(notationList).contains(\"x\");\r\n\t\t\t\r\n\t\t\t//final coordinate\r\n\t\t\tString coordinateString = notationList[notationList.length-2] + notationList[notationList.length-1];\r\n\t\t\tChessCoordinate coordinate = new ChessCoordinate(coordinateString);\r\n\t\t\tif(coordinate.isValid()) {\r\n\t\t\t\t//extract players alive pieces of piece name\r\n\t\t\t\tList<Piece> piecesOfType = getPlayerTurn().getPieces(pieceName, true);\r\n\t\t\t\t//list of pieces that can move to the same square\r\n\t\t\t\tList<Piece> piecesCanMoveToSquare = new ArrayList<Piece>();\r\n\t\t\t\tfor (Piece piece : piecesOfType) {\r\n\t\t\t\t\t\r\n\t\t\t\t\t//use valid moves of attacking if capturing move, else use move to\r\n\t\t\t\t\tSet<Coordinate> pieceMoves = isCaptureMove \r\n\t\t\t\t\t\t\t? piece.getValidMoves(Action.ATTACK) : piece.getValidMoves(Action.MOVE_TO);\r\n\t\t\t\t\tif(pieceMoves.contains(coordinate))piecesCanMoveToSquare.add(piece);\r\n\t\t\t\t}\t\r\n\t\t\t\t\r\n\t\t\t\tif (piecesCanMoveToSquare.size() == 1) {\r\n\t\t\t\t\t//only one piece can go to that square, so take piece at 0th index as the list only has one element\r\n\t\t\t\t\tpiecesCanMoveToSquare.get(0).move(coordinate);\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\telse if (piecesCanMoveToSquare.size() > 1) {\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(notation.length() <= 3) {\r\n\t\t\t\t\t\tSystem.out.println(\"Invalid move, specify which piece to move to \" + coordinateString);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//multiple pieces of the same type can move to that square, check which one to use\r\n\t\t\t\t\t//if pawn, the identifier to use is the 0th index of notationList, eg axb4. use pawn in column a.\r\n\t\t\t\t\t//for other pieces, column to use is the 1st index of notationList. eg Nab4.\r\n\t\t\t\t\t\r\n\t\t\t\t\t//variable called identifier as it can be a row or column value.\r\n\t\t\t\t\tString identifier = (pieceName.equalsIgnoreCase(ChessPieceNames.PAWN.toString()) ?\r\n\t\t\t\t\t\t\tnotationList[0] : notationList[1]).toLowerCase();\r\n\t\t\t\t\t//identifier should be a row value if pieces share the same column\r\n\t\t\t\t\tboolean isRowIdentifier = shareColumn(piecesOfType);\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(isRowIdentifier && getRowNames().contains(identifier)) {\r\n\t\t\t\t\t\t//locate piece by row and move that piece to coordinate\r\n\t\t\t\t\t\tfor (Piece piece : piecesCanMoveToSquare) {\r\n\t\t\t\t\t\t\t//look at the row number of piece coordinate, see if it matches the identifier \r\n\t\t\t\t\t\t\tif(Character.toString(piece.getPosition().toString().charAt(1)).equalsIgnoreCase(identifier)) {\r\n\t\t\t\t\t\t\t\tpiece.move(coordinate);\r\n\t\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tSystem.out.println(\"There is no \" + pieceName + \" on row \" + identifier);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}else if(getColumnNames().contains(identifier)) {\r\n\t\t\t\t\t\tfor (Piece piece : piecesCanMoveToSquare) {\r\n\t\t\t\t\t\t\t//look at the column letter of piece coordinate, see if it matches the identifier \r\n\t\t\t\t\t\t\tif(Character.toString(piece.getPosition().toString().charAt(0)).equalsIgnoreCase(identifier)) {\r\n\t\t\t\t\t\t\t\tpiece.move(coordinate);\r\n\t\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tSystem.out.println(\"There is no \" + pieceName + \" on column \" + identifier);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//invalid identifier\r\n\t\t\t\t\telse return false;\r\n\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\telse {\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t//invalid coordinate, move can not be played\r\n\t\t\telse return false;\r\n\t\t}\r\n\t\t\r\n\t}", "private boolean moveMakeQueen(Point orig, Point dest){\r\n if(isQueen(orig)) return false;\r\n return (isBlack(orig) && dest.getFirst() == 7) || (isRed(orig) && dest.getFirst() == 0);\r\n }", "public void toQueen(Point pos){\r\n model.getCurrentPlayer().setQueenNumber(+1);\r\n if(isBlack(pos)){ \r\n model.setValueAt(pos,Cells.BLACK_QUEEN);\r\n model.setBlackQueenCount(+1);\r\n model.setBlackCount(-1);\r\n } else {\r\n model.setValueAt(pos,Cells.RED_QUEEN);\r\n model.setRedQueenCount(+1);\r\n model.setRedCount(-1);\r\n }\r\n }", "public void setKing(PieceColor color, Square sq) {\n \tif(color == PieceColor.White) wKing = sq;\n \telse if(color == PieceColor.Black) bKing = sq;\n }", "public static void castleKingSide(char color) {\n String colorString = Character.toString(color);\n\n String king = \"K\" + colorString;\n String rook = \"R\" + colorString;\n\n int rank = color == 'w' ? 0 : 7;\n\n move(king, 4, rank, 6, rank);\n move(rook, 7, rank, 5, rank);\n }", "@Override\r\n\tpublic boolean movement(BoardCells[][] chessBoard, Piece targetPiece, int fromX,int fromY,int toX,int toY) {\t\t\r\n\t\t//DEBUG -- System.out.println(\"\"+fromX+fromY+\" \"+toX+toY);\r\n\t\t\r\n\t\tif(fromY == toY){\t\t\t\r\n\t\t\tif(fromX > toX) {\r\n\t\t\t\tfor(int i = fromX-1; i>toX; i--) {\r\n\t\t\t\t\tif(chessBoard[8-fromY][i].getPiece() != null) {\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\r\n\t\t\t} else if (fromX < toX) {\r\n\t\t\t\tfor(int i = fromX+1; i<toX; i++) {\r\n\t\t\t\t\tif(chessBoard[8-fromY][i].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif(getPieceID().equals(\"bR\")) {\r\n\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"bKc\")) {\r\n\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"bK\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif(getPieceID().equals(\"wR\")) {\r\n\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"wKc\")) {\r\n\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"wK\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\tif(fromX == toX) {\t\t\t\t\r\n\t\t\tif(fromY > toY) {\t\r\n\t\t\t\tfor(int i = fromY-1; i>toY; i--) {\r\n\t\t\t\t\tif(chessBoard[8-i][toX].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t} else if (fromY < toY) {\t\t\t\t\r\n\t\t\t\tfor(int i = fromY+1; i<toY; i++) {\t\t\t\t\t\r\n\t\t\t\t\tif(chessBoard[8-i][toX].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tif(getPieceID().equals(\"bR\")) {\r\n\t\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"bKc\")) {\r\n\t\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"bK\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(getPieceID().equals(\"wR\")) {\r\n\t\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"wKc\")) {\r\n\t\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"wK\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\r\n\t\t\treturn true;\t\r\n\t\t}\r\n\t\t\t\t\r\n\t\treturn false;\t\t\r\n\t}", "private static void addKingMoves(BitBoard board, LinkedList<Move> moveList, int index,\n\t\t\tint side) {\n\t\tlong moves = CoreConstants.KING_TABLE[index] & ~board.getBitBoards()[side];\n\t\tint pieceType = (side == 0) ? CoreConstants.WHITE_KING : CoreConstants.BLACK_KING;\n\t\taddMoves(pieceType, index, moves, moveList, false, false, CoreConstants.noCastle);\n\t\t// Check for castling moves\n\t\t// Check the castling flags (descirbed in the BitBoard class)\n\t\t// If some have set bits in the correct position castling is legal, if\n\t\t// so add moves accordingly\n\t\tif (side == CoreConstants.WHITE) {\n\t\t\tif ((board.getCastlingFlags()[side] & 0b10000) == 16) {\n\t\t\t\taddMoves(pieceType, index, CoreConstants.wqueenside, moveList, false, false,\n\t\t\t\t\t\tCoreConstants.wQSide);\n\t\t\t}\n\t\t\tif ((board.getCastlingFlags()[side] & 0b01000) == 8) {\n\t\t\t\taddMoves(pieceType, index, CoreConstants.wkingside, moveList, false, false,\n\t\t\t\t\t\tCoreConstants.wKSide);\n\t\t\t}\n\t\t} else {\n\t\t\tif ((board.getCastlingFlags()[side] & 0b10000) == 16) {\n\t\t\t\taddMoves(pieceType, index, CoreConstants.bqueenside, moveList, false, false,\n\t\t\t\t\t\tCoreConstants.bQSide);\n\t\t\t}\n\t\t\tif ((board.getCastlingFlags()[side] & 0b01000) == 8) {\n\t\t\t\taddMoves(pieceType, index, CoreConstants.bkingside, moveList, false, false,\n\t\t\t\t\t\tCoreConstants.bKSide);\n\t\t\t}\n\t\t}\n\t}", "protected Set<ChessMove> getPossibleCastlingMoves(ChessModel model, Location location, Set<ChessMove> movesSoFar) {\n\t\tCastlingAvailability castlingAvailability = model.getCastlingAvailability();\n\t\tif ((location == E1) && (getColor() == White)) {\n\t\t\t// this is the white king in the starting position\n\t\t\tif (castlingAvailability.isWhiteCanCastleKingSide()) {\n\t\t\t\tif (model.isLocationEmpty(F1) && model.isLocationEmpty(G1)) {\n\t\t\t\t\tif (!isInCheckAtLocations(model, E1, F1, G1)) {\n\t\t\t\t\t\tChessMove move = new ChessMoveCastleKingSide(getPiece(), E1, G1);\n\t\t\t\t\t\tmovesSoFar.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (castlingAvailability.isWhiteCanCastleQueenSide()) {\n\t\t\t\tif (model.isLocationEmpty(B1) && model.isLocationEmpty(C1) && model.isLocationEmpty(D1)) {\n\t\t\t\t\tif (!isInCheckAtLocations(model, B1, C1, D1, E1)) {\n\t\t\t\t\t\tChessMove move = new ChessMoveCastleQueenSide(getPiece(), E1, C1);\n\t\t\t\t\t\tmovesSoFar.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ((location == E8) && (getColor() == Black)) {\n\t\t\t// this is the black king in the starting position\n\t\t\tif (castlingAvailability.isBlackCanCastleKingSide()) {\n\t\t\t\tif (model.isLocationEmpty(F8) && model.isLocationEmpty(G8)) {\n\t\t\t\t\tif (!isInCheckAtLocations(model, E8, F8, G8)) {\n\t\t\t\t\t\tChessMove move = new ChessMoveCastleKingSide(getPiece(), E8, G8);\n\t\t\t\t\t\tmovesSoFar.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t\tif (castlingAvailability.isBlackCanCastleQueenSide()) {\n\t\t\t\tif (model.isLocationEmpty(B8) && model.isLocationEmpty(C8) && model.isLocationEmpty(D8)) {\n\t\t\t\t\tif (!isInCheckAtLocations(model, B8, C8, D8, E8)) {\n\t\t\t\t\t\tChessMove move = new ChessMoveCastleQueenSide(getPiece(), E8, C8);\n\t\t\t\t\t\tmovesSoFar.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\t\t\t\t\n\t\t\t}\t\t\t\n\t\t}\n\t\treturn movesSoFar;\n\t}", "public int move_diagonally(Square[][] squares, int [] move, Boolean turn) {\n\n /* going down and right = f4 h2 [4,5,6,7] */\n if (move[2] > move[0] && move[3] > move[1]) {\n ////System.out.println(\"Down right\");\n int x = move[0];\n int y = move[1];\n x++;\n y++;\n while (x < move[2] && y < move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x++;\n y++;\n }\n }\n /* going down and left */\n else if (move[2] > move[0] && move[3] < move[1]){\n ////System.out.println(\"Down Left\");\n int x = move[0];\n int y = move[1];\n x++;\n y--;\n while (x < move[2] && y > move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x++;\n y--;\n }\n }\n /* going up and left */\n else if (move[2] < move[0] && move[3] < move[1]){\n ////System.out.println(\"Up Left\");\n int x = move[0];\n int y = move[1];\n x--;\n y--;\n while (x > move[2] && y > move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x--;\n y--;\n }\n }\n /* going up and right c1 f4 [7,2,4,5] */\n else if (move[2] < move[0] && move[3] > move[1]){\n ////System.out.println(\"Up right\");\n int x = move[0];\n int y = move[1];\n x--;\n y++;\n while (x > move[2] && y < move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x--;\n y++;\n }\n }\n return 0;\n }", "@Test\n\tpublic void moveToOccupiedSpace() throws Exception {\n\t\tKing obstruction1 = new King(PieceColor.WHITE, 1, 5);\n\t\tKing obstruction2 = new King(PieceColor.BLACK, 5, 1);\n\t\tRook obstruction3 = new Rook(PieceColor.WHITE, 1, 1);\n\t\tQueen obstruction4 = new Queen(PieceColor.BLACK, 6, 5);\n\t\tgame.board.addPiece(obstruction1);\n\t\tgame.board.addPiece(obstruction2);\n\t\tgame.board.addPiece(obstruction3);\n\t\tgame.board.addPiece(obstruction4);\n\t\t\n\t\tgame.board.movePiece(knightCorner1White, 1, 5);\n\t\tgame.board.movePiece(knightCorner2Black, 5, 1);\n\t\tgame.board.movePiece(knightSide1White, 1, 1);\n\t\tgame.board.movePiece(knightSide2Black, 6, 5);\n\t\tassertEquals(knightCorner1White, game.board.getPiece(0, 7));\n\t\tassertEquals(knightCorner2Black, game.board.getPiece(7, 0));\n\t\tassertEquals(knightSide1White, game.board.getPiece(3, 0));\n\t\tassertEquals(knightSide2Black, game.board.getPiece(7, 3));\n\t}", "void move(int row, int col) {\n\n int rowdiff = row - this._row; int coldiff = col - this.column;\n if (((Math.abs(rowdiff)) > 1) || (Math.abs(coldiff)) > 1);\n || (row >= _side) || (col >= _side) || (row < 0) || (col < 0);\n || ((Math.abs(coldiff)) == 1) && ((Math.abs(rowdiff)) == 1))); {\n throw new java.lang.IllegalArgumentException();\n } \n else if (rowdiff == 1) && (coldiff == 0)//up method\n { \n if (((isPaintedSquare(row, col) && isPaintedFace(2)) || \n (!isPaintedSquare(row, col) && !isPaintedFace(2))) {\n up_method(cube)\n } else if (isPaintedFace(2) == true) {\n _facePainted[2] == false\n grid[row][col] == true\n up_method(cube)\n }\n else {\n _facePainted[2] == true\n grid[row][col] == false \n up_method(cube)\n }\n }\n else if ((rowdiff == -1) && (coldiff == 0)) //down method\n\n { \n if (((isPaintedSquare(row, col) && isPaintedFace(4)) || \n (!isPaintedSquare(row, col) && !isPaintedFace(4))) {\n up_method(cube)\n } else if (isPaintedFace(4) == true) {\n _facePainted[4] == false\n grid[row][col] == true\n up_method(cube)\n } else {\n _facePainted[4] == true\n grid[row][col] == false \n up_method(cube)\n }\n }\n else if (rowdiff == 0) && (coldiff == -1) { //left method\n if (((isPaintedSquare(row, col) && isPaintedFace(5)) || \n (!isPaintedSquare(row, col) && !isPaintedFace(5))) {\n up_method(cube)\n } else if (isPaintedFace(5) == true) {\n _facePainted[5] == false\n grid[row][col] == true\n up_method(cube)}\n else {\n _facePainted[5] == true\n grid[row][col] == false \n up_method(cube)}\n }\n else if ((rowdiff == 0) && (coldiff == 1)) { //right method\n if (((isPaintedSquare(row, col) && isPaintedFace(6)) || \n (!isPaintedSquare(row, col) && !isPaintedFace(6))) {\n up_method(cube)\n } else if (isPaintedFace(6) == true) {\n _facePainted[6] == false\n grid[row][col] == true\n up_method(cube)}\n else {\n _facePainted[6] == true\n grid[row][col] == false \n up_method(cube)\n \n }\n }\n\n\n }", "private static boolean kingInKingSquare(BitBoard board, int side) {\n\t\tint myKingIndex = BitBoard.bitScanForward(board.getBitBoards()[12 + side]);\n\t\tint enemyKingIndex = BitBoard\n\t\t\t\t.bitScanForward(board.getBitBoards()[12 + ((side == 0) ? 1 : 0)]);\n\t\tif (((1L << myKingIndex) & CoreConstants.KING_TABLE[enemyKingIndex]) != 0) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}", "public static void move(TTTBoard board, char piece) {\n if (board.winner() != ' ') {\n throw new IllegalArgumentException(\"Game Over\");\n }\n if (board.size() == 1) {\n board.set(0, 0, piece);\n return;\n }\n if (board.size() == 3) {\n int turnNumber = getBoardTurnNumber(board);\n if (turnNumber == 1) {\n board.set(0, 0, piece);\n return;\n } else if (turnNumber == 2) {\n if (board.get(1, 1) == ' ') {\n board.set(1, 1, piece);\n return;\n } else if (board.get(0, 0) == ' ') {\n board.set(0, 0, piece);\n return;\n }\n } else if (turnNumber == 3) {\n try {\n int[] opp = getFirstOpp(board, piece);\n int oppRow = opp[0];\n if (oppRow == 0) {\n board.set(2, 0, piece);\n return;\n } else if (oppRow == 1) {\n board.set(0, 2, piece);\n return;\n } else {\n board.set(0, 2, piece);\n return;\n }\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n }\n\n // check if win diagonal\n int selfC = 0;\n int oppC = 0;\n int spaceC = 0;\n for (int i = 0; i < board.size(); ++i) {\n int j = i;\n char p = board.get(i, j);\n if (p == ' ') spaceC++;\n else if (p == piece) selfC++;\n else oppC++;\n }\n\n if (spaceC == 1 && (selfC == 0 || oppC == 0)) {\n // fill in that space\n for (int i = 0; i < board.size(); ++i) {\n int j = i;\n char p = board.get(i, j);\n if (p == ' ') {\n board.set(i, j, piece);\n return;\n }\n }\n }\n\n selfC = 0;\n oppC = 0;\n spaceC = 0;\n for (int i = 0; i < board.size(); ++i) {\n int j = board.size() - i - 1;\n char p = board.get(i, j);\n if (p == ' ') spaceC++;\n else if (p == piece) selfC++;\n else oppC++;\n\n }\n\n if (spaceC == 1 && (selfC == 0 || oppC == 0)) {\n // fill in that space\n for (int i = 0; i < board.size(); ++i) {\n int j = board.size() - i - 1;\n char p = board.get(i, j);\n if (p == ' ') {\n board.set(i, j, piece);\n return;\n }\n }\n }\n\n // check if win row col\n\n boolean[] selfWinnableRows = new boolean[board.size()];\n boolean[] oppWinnableRows = new boolean[board.size()];\n boolean[] selfWinnableCols = new boolean[board.size()];\n boolean[] oppWinnableCols = new boolean[board.size()];\n int[] selfCountRows = new int[board.size()];\n int[] selfCountCols = new int[board.size()];\n int[] oppCountRows = new int[board.size()];\n int[] oppCountCols = new int[board.size()];\n\n // checks if any rows can be won\n for (int i = 0; i < board.size(); ++i) {\n boolean containsSelf = false;\n boolean containsOpp = false;\n boolean hasEmpty = false;\n int selfCount = 0;\n int oppCount = 0;\n\n for (int j = 0; j < board.size(); ++j) {\n char p = board.get(i, j);\n\n if (p == ' ') {\n hasEmpty = true;\n } else if (p == piece) {\n containsSelf = true;\n selfCount++;\n } else {\n containsOpp = true;\n oppCount++;\n }\n }\n\n selfCountRows[i] = selfCount;\n oppCountRows[i] = oppCount;\n\n if (!hasEmpty) continue;\n\n if (!containsSelf && !containsOpp) {\n selfWinnableRows[i] = true;\n oppWinnableRows[i] = true;\n }\n\n if (containsSelf && !containsOpp) {\n selfWinnableRows[i] = true;\n }\n if (containsOpp && !containsSelf) {\n oppWinnableRows[i] = true;\n }\n }\n\n // checks if any cols can be won\n for (int i = 0; i < board.size(); ++i) {\n boolean containsSelf = false;\n boolean containsOpp = false;\n boolean hasEmpty = false;\n int selfCount = 0;\n int oppCount = 0;\n for (int j = 0; j < board.size(); ++j) {\n char p = board.get(j, i);\n\n if (p == ' ') {\n hasEmpty = true;\n } else if (p == piece) {\n containsSelf = true;\n selfCount++;\n } else {\n containsOpp = true;\n oppCount++;\n }\n }\n\n selfCountCols[i] = selfCount;\n oppCountCols[i] = oppCount;\n\n if (!hasEmpty) continue;\n\n if (!containsSelf && !containsOpp) {\n selfWinnableCols[i] = true;\n oppWinnableCols[i] = true;\n }\n\n if (containsSelf && !containsOpp) {\n selfWinnableCols[i] = true;\n }\n\n if (containsOpp && !containsSelf) {\n oppWinnableCols[i] = true;\n }\n }\n\n int[] selfInRowRows = new int[board.size()];\n int[] selfInRowCols = new int[board.size()];\n int[] oppInRowRows = new int[board.size()];\n int[] oppInRowCols = new int[board.size()];\n\n for (int i = 0; i < selfWinnableRows.length; ++i) {\n if (selfWinnableRows[i]) {\n int count = selfCountRows[i];\n selfInRowRows[count]++;\n }\n }\n for (int i = 0; i < selfWinnableCols.length; ++i) {\n if (selfWinnableCols[i]) {\n int count = selfCountCols[i];\n selfInRowCols[count]++;\n }\n }\n for (int i = 0; i < oppWinnableRows.length; ++i) {\n if (oppWinnableRows[i]) {\n int count = oppCountRows[i];\n oppInRowRows[count]++;\n }\n }\n for (int i = 0; i < oppWinnableCols.length; ++i) {\n if (oppWinnableCols[i]) {\n int count = oppCountCols[i];\n oppInRowCols[count]++;\n }\n }\n\n if (board.size() == 3) {\n int turnNumber = getBoardTurnNumber(board);\n if (selfInRowRows[board.size() - 1] == 0 &&\n selfInRowCols[board.size() - 1] == 0 &&\n oppInRowRows[board.size() - 1] == 0 &&\n oppInRowCols[board.size() - 1] == 0) {\n if (turnNumber == 4) {\n if ((board.get(1, 1) != ' ' && board.get(1, 1) != piece)\n && (board.get(2, 2) != ' ' && board.get(2, 2) != piece)) {\n board.set(2, 0, piece);\n return;\n }\n } else if (turnNumber == 5) {\n if (selfCountCols[0] == 2) {\n board.set(2, 2, piece);\n return;\n } else if (selfCountRows[0] == 2) {\n if (board.get(1, 0) != piece && board.get(1, 0) != ' ') {\n board.set(2, 2, piece);\n return;\n }\n if (board.get(2, 0) != piece && board.get(2, 0) != ' ') {\n board.set(2, 2, piece);\n return;\n }\n board.set(2, 0, piece);\n return;\n }\n }\n }\n }\n\n for (int i = board.size() - 1; i >= 0; i--) {\n int selfRowsCount = selfInRowRows[i];\n //System.out.println(i + \" self rows count: \" + selfRowsCount);\n if (selfRowsCount > 0) {\n // get a row index that contains this self in row rows\n try {\n int rowIndex = getRowIndexForInRowRows(board, i, selfWinnableRows, selfCountRows);\n int colIndex = getNextInRow(board, rowIndex);\n board.set(rowIndex, colIndex, piece);\n return;\n } catch (Exception e) {\n e.printStackTrace();\n }\n\n }\n int selfColsCount = selfInRowCols[i];\n if (selfColsCount > 0) {\n try {\n int colIndex = getRowIndexForInRowRows(board, i, selfWinnableCols, selfCountCols);\n int rowIndex = getNextInCol(board, colIndex);\n board.set(rowIndex, colIndex, piece);\n return;\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n int oppRowsCount = oppInRowRows[i];\n // System.out.println(i + \" opp rows count: \" + oppRowsCount);\n if (oppRowsCount > 0) {\n\n try {\n int rowIndex = getRowIndexForInRowRows(board, i, oppWinnableRows, oppCountRows);\n int colIndex = getNextInRow(board, rowIndex);\n board.set(rowIndex, colIndex, piece);\n return;\n } catch (Exception e) {\n e.printStackTrace();\n }\n\n }\n int oppColsCount = oppInRowCols[i];\n if (oppColsCount > 0) {\n try {\n int colIndex = getRowIndexForInRowRows(board, i, oppWinnableCols, oppCountCols);\n int rowIndex = getNextInCol(board, colIndex);\n board.set(rowIndex, colIndex, piece);\n return;\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n }\n\n try {\n int[] nextEmpty = getNextEmpty(board);\n board.set(nextEmpty[0], nextEmpty[1], piece);\n } catch (Exception e) {\n throw new IllegalArgumentException(\"DRAW / SOMEONE WON\");\n }\n }", "private void checkKing(int row, int col) {\r\n if (checks[row][col]== BLACK && row == 0) {\r\n if(isGame) currentPlayer.addQueen();\r\n else blackQueens ++;\r\n }\r\n else if (checks[row][col]== WHITE && row == 7) {\r\n if(isGame) currentPlayer.addQueen();\r\n else whiteQueens ++;\r\n }\r\n }", "public void makeMove(String castleString) throws InvalidMoveException {\n Piece kingPiece, rookPiece, betweenPiece;\n Coordinate kingCoordinate, rookCoordinate, betweenCoordinate, oppCoordinate;\n int xIncrement, spacesToRook;\n\n // verify valid castle String O-O or O-O-O\n if (!castleString.equals(KING_SIDE_CASTLE_STRING) && !castleString.equals(QUEEN_SIDE_CASTLE_STRING)) {\n throw new InvalidMoveException();\n }\n\n kingCoordinate = getKingCoordinate(nextMoveColor);\n kingPiece = getPieceFromCoordinate(kingCoordinate);\n\n // King cannot be in check or have moved already\n if (isInCheck(nextMoveColor) || kingPiece.getHasMoved()) {\n throw new InvalidMoveException();\n }\n\n if (castleString == KING_SIDE_CASTLE_STRING) {\n xIncrement = 1;\n spacesToRook = 3;\n }\n else {\n xIncrement = -1;\n spacesToRook = 4;\n }\n\n rookCoordinate = new Coordinate(kingCoordinate.getPosX() + spacesToRook * xIncrement,\n kingCoordinate.getPosY());\n rookPiece = getPieceFromCoordinate(rookCoordinate);\n // Rook must not have moved already\n if (!(rookPiece instanceof Rook) || rookPiece.getPieceColor() != nextMoveColor || rookPiece.getHasMoved()) {\n throw new InvalidMoveException();\n }\n\n betweenCoordinate = new Coordinate(kingCoordinate);\n for (int i = 0; i < 2; i++) {\n betweenCoordinate.addVals(xIncrement, 0);\n betweenPiece = getPieceFromCoordinate(betweenCoordinate);\n // the two spaces to the left or right of the King must be empty\n if (betweenPiece != null) {\n throw new InvalidMoveException();\n }\n for (int j = 0; j < VERTICAL_BOARD_LENGTH; j++) {\n for (int k = 0; k < HORIZONTAL_BOARD_LENGTH; k++) {\n oppCoordinate = new Coordinate(k, j);\n // an opposing piece cannot be attacking the two empty spaces\n if (isValidEndpoints(oppCoordinate, betweenCoordinate, oppositeColor(nextMoveColor))) {\n if (isValidPath(oppCoordinate, betweenCoordinate, oppositeColor(nextMoveColor), false)) {\n throw new InvalidMoveException();\n }\n }\n }\n }\n }\n\n // move the King and Rook for castling\n boardArray[betweenCoordinate.getPosY()][betweenCoordinate.getPosX()] = kingPiece;\n boardArray[kingCoordinate.getPosY()][kingCoordinate.getPosX()] = null;\n kingPiece.setPieceCoordinate(betweenCoordinate);\n\n betweenCoordinate.addVals(xIncrement * -1, 0);\n boardArray[betweenCoordinate.getPosY()][betweenCoordinate.getPosX()] = rookPiece;\n boardArray[rookCoordinate.getPosY()][rookCoordinate.getPosX()] = null;\n rookPiece.setPieceCoordinate(betweenCoordinate);\n\n\n kingPiece.setHasMoved(true);\n rookPiece.setHasMoved(true);\n\n nextMoveColor = oppositeColor(nextMoveColor);\n turnNumber++;\n }", "@Test\n public void testQueenPosition() {\n // initialize the complete chess board\n ChessBoard chessBoard = init(\"CHESS\");\n\n assertEquals(0, chessBoard.getPiece(0, 3).getRow());\n assertEquals(3, chessBoard.getPiece(0, 3).getColumn());\n\n assertEquals(7, chessBoard.getPiece(7, 3).getRow());\n assertEquals(3, chessBoard.getPiece(7, 3).getColumn());\n }", "protected void kingPieces() {\n Row firstRowRed = redBoard.getLastRow();\n Row firstRowWhite = whiteBoard.getLastRow();\n\n for (Space space : firstRowRed) {\n Piece piece = space.getPiece();\n if (piece != null)\n if (piece.getColor() == Piece.COLOR.WHITE) {\n if (piece.getType() == Piece.TYPE.SINGLE) {\n redBoard.kingPiece(firstRowRed.getIndex(), space.getCellIdx());\n whiteBoard.kingPiece(7 - firstRowRed.getIndex(), 7 - space.getCellIdx());\n }\n }\n }\n for (Space space : firstRowWhite) {\n Piece piece = space.getPiece();\n if (piece != null)\n if (piece.getColor() == Piece.COLOR.RED) {\n if (piece.getType() == Piece.TYPE.SINGLE) {\n redBoard.kingPiece(7 - firstRowWhite.getIndex(), 7 - space.getCellIdx());\n whiteBoard.kingPiece(firstRowWhite.getIndex(), space.getCellIdx());\n }\n }\n }\n }", "public static void main(String[] args) throws IOException {\n Scanner f = new Scanner(System.in);\n //BufferedReader f = new BufferedReader(new FileReader(\"uva.in\"));\n //BufferedReader f = new BufferedReader(new InputStreamReader(System.in));\n PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));\n while(f.hasNext()) {\n int kingPos = f.nextInt();\n int queenPos = f.nextInt();\n int nextQueenPos = f.nextInt();\n int kingRow = kingPos/8;\n int kingCol = kingPos%8;\n int queenRow = queenPos/8;\n int queenCol = queenPos%8;\n int nextQueenRow = nextQueenPos/8;\n int nextQueenCol = nextQueenPos%8;\n if(kingRow == queenRow && kingCol == queenCol) {\n out.println(\"Illegal state\");\n } else if((queenRow == nextQueenRow && queenCol == nextQueenCol) || (queenRow != nextQueenRow && queenCol != nextQueenCol) || inBetween(kingRow,kingCol,queenRow,queenCol,nextQueenRow,nextQueenCol)) {\n out.println(\"Illegal move\");\n } else if((Math.abs(nextQueenRow-kingRow) == 1 && Math.abs(nextQueenCol-kingCol) == 0) || (Math.abs(nextQueenRow-kingRow) == 0 && Math.abs(nextQueenCol-kingCol) == 1)) {\n out.println(\"Move not allowed\");\n } else if((kingRow == 0 && kingCol == 0 && nextQueenRow == 1 && nextQueenCol == 1) || (kingRow == 0 && kingCol == 7 && nextQueenRow == 1 && nextQueenCol == 6) || (kingRow == 7 && kingCol == 0 && nextQueenRow == 6 && nextQueenCol == 1) || (kingRow == 7 && kingCol == 7 && nextQueenRow == 6 && nextQueenCol == 6)) {\n out.println(\"Stop\");\n } else {\n out.println(\"Continue\");\n }\n }\n f.close();\n out.close();\n }", "private void switchCaseFallThroughWorkaround1(List<Move> moves, int col, int row, Piece king) {\n for (int r = row, c = col; r != king.row.ordinal() || c != king.col.ordinal(); ) {\n // Kutsu funktiota joka tarkistaa voiko oman napin siirtää tähän kohtaan laudalla.\n checkOwnMovesToHere(moves, c, r, king);\n\n if (r > king.row.ordinal()) r--;\n else if (r < king.row.ordinal()) r++;\n\n if (c > king.col.ordinal()) c--;\n else if (c < king.col.ordinal()) c++;\n }\n }", "private boolean isKingThreatened(int col, int row, List<Piece> threats) {/Down/Left/Right: queens, rooks\n // Up\n for (int r = row + 1; r < 8; r++) {\n if (threatenCheck(board[r][col], threats, Who.ROOK)) break;\n }\n // Right\n for (int c = col + 1; c < 8; c++) {\n if (threatenCheck(board[row][c], threats, Who.ROOK)) break;\n }\n // Down\n for (int r = row - 1; r >= 0; r--) {\n if (threatenCheck(board[r][col], threats, Who.ROOK)) break;\n }\n // Left\n for (int c = col - 1; c >= 0; c--) {\n if (threatenCheck(board[row][c], threats, Who.ROOK)) break;\n }\n\n // Sideways: queens, bishops\n // Up-right\n for (int r = row + 1, c = col + 1; r < 8 && c < 8; r++, c++) {\n if (threatenCheck(board[r][c], threats, Who.BISHOP)) break;\n }\n // Right-down\n for (int r = row - 1, c = col + 1; r >= 0 && c < 8; r--, c++) {\n if (threatenCheck(board[r][c], threats, Who.BISHOP)) break;\n }\n // Down-left\n for (int r = row - 1, c = col - 1; r >= 0 && c >= 0; r--, c--) {\n if (threatenCheck(board[r][c], threats, Who.BISHOP)) break;\n }\n // Left-up\n for (int r = row + 1, c = col - 1; r < 8 && c >= 0; r++, c--) {\n if (threatenCheck(board[r][c], threats, Who.BISHOP)) break;\n }\n\n // Checking for knights\n int r = row, c = col;\n // Up\n if (r < 6) {\n // Right\n if (c < 7)\n threatenCheck1Piece(board[r + 2][c + 1], threats, Who.KNIGHT);\n // Left\n if (c > 0)\n threatenCheck1Piece(board[r + 2][c - 1], threats, Who.KNIGHT);\n }\n // Right\n if (c < 6) {\n // Up\n if (r < 7)\n threatenCheck1Piece(board[r + 1][c + 2], threats, Who.KNIGHT);\n // Down\n if (r > 0)\n threatenCheck1Piece(board[r - 1][c + 2], threats, Who.KNIGHT);\n }\n // Down\n if (r > 1) {\n // Right\n if (c < 7)\n threatenCheck1Piece(board[r - 2][c + 1], threats, Who.KNIGHT);\n // Left\n if (c > 0)\n threatenCheck1Piece(board[r - 2][c - 1], threats, Who.KNIGHT);\n }\n // Left\n if (c > 1) {\n // Up\n if (r < 7)\n threatenCheck1Piece(board[r + 1][c - 2], threats, Who.KNIGHT);\n // Down\n if (r > 0)\n threatenCheck1Piece(board[r - 1][c - 2], threats, Who.KNIGHT);\n }\n\n // Checking for pawns.\n boolean doPawns = true;\n if (whoseTurn == Owner.WHITE) {\n // No threat from pawns.\n if (row == 7) doPawns = false;\n row++;\n } else {\n // No threat from pawns.\n if (row == 0) doPawns = false;\n row--;\n }\n if (doPawns) {\n // Right side\n if (col < 7)\n threatenCheck1Piece(board[row][col + 1], threats, Who.PAWN);\n // Left side\n if (col > 0)\n threatenCheck1Piece(board[row][col - 1], threats, Who.PAWN);\n }\n\n return threats.size() != 0;\n }", "public void makeMove(Move m){\n int oldTurn = turn;\n turn = -turn;\n moves++;\n enPassant = -1;\n if (m.toY == 0){ // white rook space\n if (m.toX == 0){\n castles &= nWHITE_LONG;\n //castles[1] = false;\n }else if (m.toX == 7){\n castles &= nWHITE_SHORT;\n //castles[0] = false;\n }\n } else if (m.toY == 7){ // black rook space\n if (m.toX == 0){\n castles &= nBLACK_LONG;\n //castles[3] = false;\n }else if (m.toX == 7){\n castles &= nBLACK_SHORT;\n //castles[2] = false;\n }\n }\n if (m.piece == WHITE_ROOK && m.fromY == 0){\n if (m.fromX == 0){castles &= nWHITE_LONG;} //castles[1] = false;}\n else if (m.fromX == 7){castles &= nWHITE_SHORT;} //castles[0] = false;}\n } else if (m.piece == BLACK_ROOK && m.fromY == 7){\n if (m.fromX == 0){castles &= nBLACK_LONG;} //castles[3] = false;}\n else if (m.fromX == 7){castles &= nBLACK_SHORT;} //castles[2] = false;}\n }\n // castling\n if (m.piece % 6 == 0){\n if (oldTurn == WHITE){\n castles &= 0b1100;\n //castles[0] = false; castles[1] = false;\n } else {\n castles &= 0b11;\n //castles[2] = false; castles[3] = false;\n }\n if (m.toX - m.fromX == 2){ // short\n board[m.fromY][m.fromX] = 0;\n board[m.toY][m.toX] = m.piece;\n // rook\n board[m.fromY][5] = board[m.fromY][7];\n board[m.fromY][7] = 0;\n return;\n } else if (m.toX - m.fromX == -2){ // long\n board[m.fromY][m.fromX] = 0;\n board[m.toY][m.toX] = m.piece;\n // rook\n board[m.fromY][3] = board[m.fromY][0];\n board[m.fromY][0] = 0;\n return;\n }\n } else if (m.piece % 6 == 1) { // pawn move\n stalemateCountdown = 0; // resets on a pawn move\n // promotion\n if (m.toY % 7 == 0){\n board[m.toY][m.toX] = m.promoteTo;\n board[m.fromY][m.fromX] = 0;\n return;\n }\n // en passant\n else if (m.fromX != m.toX && board[m.toY][m.toX] == 0){\n board[m.fromY][m.fromX] = 0;\n board[m.toY][m.toX] = m.piece;\n if (oldTurn == WHITE){\n board[4][m.toX] = 0;\n }else{\n board[3][m.toX] = 0;\n }\n return;\n } else if (m.toY - m.fromY == 2*oldTurn){\n enPassant = m.fromX;\n }\n }\n // regular\n if (board[m.toY][m.toX] != 0){\n stalemateCountdown = 0; // resets on a capture\n }\n board[m.fromY][m.fromX] = 0;\n board[m.toY][m.toX] = m.piece;\n }", "public void doClickSquare(int row, int col) {\n if (!gameInProgress()) {\n console(\"Click \\\"New Game\\\" to start a new game.\");\n } else {\n \n if (currentPlayer() == CheckersData.BLACK\n && aiBlack == true) {\n //console(\"Click to move black\");\n try{Thread.sleep(50);}catch(Exception e){System.out.println(\"thread.sleep error: \" + e.toString());}\n AIblackMove blacksMove = new AIblackMove(this,legalMoves);\n doMakeMove(blacksMove.nextMove());\n return;\n } else if (currentPlayer() == CheckersData.RED\n && aiRed == true) {\n //console(\"Click to move red\");\n try{Thread.sleep(50);}catch(Exception e){System.out.println(\"thread.sleep error: \" + e.toString());}\n AIredMove redsMove = new AIredMove(this,legalMoves);\n //AIredMoveBetter redsMove = new AIredMoveBetter(this, legalMoves);\n doMakeMove(redsMove.nextMove());\n return;\n }\n\n\n /* If the player clicked on one of the pieces that the player\n can move, mark this row and col as selected and return. (This\n might change a previous selection.) Reset the message, in\n case it was previously displaying an error message. */\n for (int i = 0; i < legalMoves.length; i++) {\n System.out.println(\"In one\");\n if (legalMoves[i].fromRow == row && legalMoves[i].fromCol == col) {\n selectedRow = row;\n selectedCol = col;\n if (currentPlayer == CheckersData.RED) {\n console(\"RED: Make your move.\");\n } else {\n console(\"BLACK: Make your move.\");\n }\n refreshBoard();\n return;\n }\n }\n\n /* If no piece has been selected to be moved, the user must first\n select a piece. Show an error message and return. */\n if (selectedRow < 0) {\n System.out.println(\"In two\");\n\n console(\"Click the piece you want to move.\");\n return;\n }\n\n /* If the user clicked on a square where the selected piece can be\n legally moved, then make the move and return. */\n for (int i = 0; i < legalMoves.length; i++) {\n System.out.println(\"In three\");\n\n if (legalMoves[i].fromRow == selectedRow && legalMoves[i].fromCol == selectedCol\n && legalMoves[i].toRow == row && legalMoves[i].toCol == col) {\n doMakeMove(legalMoves[i]);\n return;\n }\n }\n\n /* If we get to this point, there is a piece selected, and the square where\n the user just clicked is not one where that piece can be legally moved.\n Show an error message. */\n console(\"Click the square you want to move to.\");\n }\n }", "public void move(char way) {\n try {\n if (way == 'w'||way == 'W') { \n this.playerMoveUp();\n } else if (way == 'a'|| way == 'A') {\n this.playerMoveLeft();\n } else if (way == 'd' || way == 'D') {\n this.playerMoveRight();\n } else if (way == 's' || way == 'S') {\n this.playerMoveDown();\n }\n } catch (ArrayIndexOutOfBoundsException e) {\n System.out.println(\"hit edge!\");\n }\n\t}", "void makeMove(Square from, Square to) {\r\n assert isLegal(from, to);\r\n\r\n if (kingPosition().isEdge()) {\r\n _winner = WHITE;\r\n listOfMoves.push(mv(kingPosition(), sq(0, 0)));\r\n System.out.println(winner());\r\n checkRepeated();\r\n return;\r\n }\r\n\r\n Piece side = map.get(from);\r\n if (_turn == side.opponent()) {\r\n return;\r\n }\r\n listOfMoves.push(mv(from, to));\r\n revPut(map.get(from), to);\r\n map.put(from, EMPTY);\r\n map.put(to, side);\r\n board[from.col()][from.row()] = EMPTY;\r\n legalMoves(side);\r\n for (Square sq : map.keySet()) {\r\n if (map.get(sq) == side.opponent()) {\r\n if (to.isRookMove(sq)) {\r\n Square captureAble = to.rookMove(to.direction(sq), 2);\r\n if (to.adjacent(sq) && ((map.get(captureAble) == side)\r\n || (captureAble == THRONE\r\n && map.get(THRONE) == EMPTY))) {\r\n capture(to, captureAble);\r\n }\r\n }\r\n }\r\n }\r\n\r\n _turn = _turn.opponent();\r\n _moveCount += 1;\r\n checkRepeated();\r\n }", "private void genQueenMovesMap(int[] list, int[] board, int queen) {\n\t\tfor(int i = 0; i < list.length; i++){\n\t\t\tlist[i] = 0;\n\t\t}\n\n\t\tint x = queen%10;\n\t\tint y = queen/10;\n\t\tint xOff, yOff;\n\t\tfor(int[] offset : MATRIX){\n\t\t\tfor(yOff = y+offset[0], xOff = x+offset[1]; (yOff > -1 && yOff < 10) && (xOff > -1 && xOff < 10); yOff += offset[0], xOff += offset[1]){\n\t\t\t\tif(board[yOff*GRID+xOff] == 0){\n\t\t\t\t\tlist[yOff*GRID+xOff] = (((yOff&0xf) << 12) | ((xOff&0xf) << 8) | ((y&0xf) << 4) | x&0xf);\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "private void makeMove(){\r\n\t\tif(cornerColorIs(GREEN)){\r\n\t\t\tif(noBeepersPresent()){\r\n\t\t\t\tmove();\r\n\t\t\t\tpaintCorner(GREEN);\r\n\t\t\t}\r\n\t\t}\r\n\t\telse{\r\n\t\t\tif(noBeepersPresent()){\r\n\t\t\t\tmove();\r\n\t\t\t\tpaintCorner(RED);\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n//\t\tif(()) {\r\n//\t\t if(cornerColorIs(GREEN)) {\r\n//\t\t move();\r\n//\t\t paintCorner(GREEN);\r\n//\t\t } else {\r\n//\t\t move();\r\n//\t\t paintCorner(RED);\r\n//\t\t }\r\n//\t\t}noBeepersPresent\r\n\t}", "void makeMove(int row, int col, int nextRow, int nextCol) {\r\n int temp = checks[row][col];\r\n checks[nextRow][nextCol] = temp;\r\n checks[row][col] = 0;\r\n if (Math.abs(nextRow - row) == 2){\r\n removePiece(nextRow, nextCol,row, col);\r\n }\r\n checkKing(nextRow,nextCol);\r\n }", "public Queen(int r, int c)\r\n {\r\n row = r;\r\n column = c;\r\n }", "public void performMove() {\n\t\tfor (int x = 0; x <= size-1; x++)\n\t\t\tfor (int y = 0; y <= size-1; y++)\n\t\t\t\tlocalBoard[y][x] = 0;\n\t\t\n\t\t//reset the flag that indicates if a move has been found that decreases the heuristic\n\t\tfoundBetterMove = false;\n\t\t\n\t\t//fill in the appropriate heuristic values\n\t\tpopulateHillValues();\n\t\tArrayList<PotentialMove> myBestList = new ArrayList<PotentialMove>();\n\n\t\t//Find the square with the lowest heuristic value. this should really write the values to an array. \n\t\tint squareDifferential = -1;\n\t\t//String outValue = \"\";\n\t\tfor (int y = 0; y <= size-1; y++) {\n\t\t\tfor (int x = 0; x <= size-1; x++){\n\t\t\t\t//outValue = outValue + localBoard[y][x];\n\t\t\t\tif (squareDifferential < 0) //lowestSquareFound not found yet \n\t\t\t\t{\n\t\t\t\t\tif ((NQueens.queens[x] != y) && //set if the current square isn't already occupied by a queen\n\t\t\t\t\t\t\t(localBoard[NQueens.queens[x]][x] >= localBoard[y][x])) {\n\t\t\t\t\t\tif (localBoard[y][x] == localBoard[NQueens.queens[x]][x])\n\t\t\t\t\t\t\tmyBestList.add(new PotentialMove(x, y, true));\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tmyBestList.add(new PotentialMove(x, y, false));\n\t\t\t\t\t\tsquareDifferential = localBoard[NQueens.queens[x]][x] - localBoard[y][x];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if ((localBoard[NQueens.queens[x]][x] - localBoard[y][x]) > squareDifferential) { // find the square with the largest differential in value from the queen in the column\n\t\t\t\t\tmyBestList.clear();\n\t\t\t\t\tmyBestList.add(new PotentialMove(x, y, false));\n\t\t\t\t\tsquareDifferential = localBoard[NQueens.queens[x]][x] - localBoard[y][x];\n\t\t\t\t}\n\t\t\t\telse if (((localBoard[NQueens.queens[x]][x] - localBoard[y][x]) == squareDifferential) && // the differential is equal to the current best differential\n\t\t\t\t\t\t(NQueens.queens[x] != y)) { // and isn't already occupied by a queen\n\t\t\t\t\tmyBestList.add(new PotentialMove(x, y, true));\n\t\t\t\t}\n\t\t\t\t//else the square is higher, has a queen or isn't marginally better than the current queen's position in the row\n\t\t\t}\n\t\t\t//outValue = outValue + \"\\n\";\n\t\t}\n\t\t//JOptionPane.showMessageDialog(null, outValue);\n\t\t\n\t\tif (myBestList.isEmpty())\n\t\t\treturn;\n\t\t\n\t\tint listSize = myBestList.size();\n\t\tPotentialMove bestMove;\n\t\t\n\t\t//grab the non-Sideways moves first\n\t\tfor (int i = 0; i < listSize; i++) {\n\t\t\tif (!(myBestList.get(i).isSideways)) {\n\t\t\t\tbestMove = myBestList.get(i);\n\t\t\t\tfoundBetterMove = true;\n\t\t\t\tsidewaysMoves = 0;\n\t\t\t\tNQueens.queens[bestMove.xCoordinate] = bestMove.yCoordinate;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (sidewaysMoves > MAXSIDEWAYSMOVES) { // hit MAXSIDEWAYSMOVES consecutive sideways moves, mark as unsolvable\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t//all available moves sideways moves, let's select one randomly\n\t\tRandom generator = new Random();\n\t\tint randomElement = generator.nextInt(listSize);\n\t\t\n\t\tbestMove = myBestList.get(randomElement);\n\t\tfoundBetterMove = true;\n\t\tsidewaysMoves++;\n\t\tNQueens.queens[bestMove.xCoordinate] = bestMove.yCoordinate;\n\t}", "@Test\n public void testKingSide() {\n // initialize the complete chess board\n ChessBoard chessBoard = init(\"CHESS\");\n\n assertEquals(north, chessBoard.getPiece(0, 4).getSide());\n assertEquals(south, chessBoard.getPiece(7, 4).getSide());\n }", "private ArrayList<Move> whiteKing(){\n // obtain current co-ordinates\n int x = this.getX();\n int y = this.getY();\n\n // otherwise create a new vector to store legal whiteMoves\n ArrayList<Move> whiteMoves = new ArrayList<Move>();\n\n // set up m to refer to a Move object\n Move theMove = null;\n\n // first legal move is to go from x,y to x,y+1\n if (validNormalMove(x, y + 1)) {\n theMove = new Move(this, x, y, x, y + 1, false);\n if(takeOverCheck(x, y+1)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n\n // legal move is to go from x,y to x,y-1 if x,y-1 is unoccupied (bottom)\n if (validNormalMove(x, y - 1)) {\n theMove = new Move(this, x, y, x, y - 1, false);\n if(takeOverCheck(x, y-1)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n //left\n // legal move to go left from x,y to x-1, y if x-1,y is unoccupied (left)\n\n if (validNormalMove(x-1, y)) {\n theMove = new Move(this, x, y, x-1, y, false);\n if(takeOverCheck(x-1, y)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n //right\n // legal move to go right from x,y to x+1, y if x+1,y is unoccupied (right)\n\n if (validNormalMove(x+1, y)) {\n theMove = new Move(this, x, y, x+1, y, false);\n\n if(takeOverCheck(x+1, y)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n\n\n // legal move to diagonal top right for white king\n if (validNormalMove(x+1, y + 1)) {\n theMove = new Move(this, x, y, x+1, y + 1, false);\n if(takeOverCheck(x+1, y+1)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n // legal move to diagonal bottom right\n\n if (validNormalMove(x+1, y -1)) {\n theMove = new Move(this, x, y, x+1, y - 1, false);\n if(takeOverCheck(x+1, y-1)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n // legal move to diagonal bottom left\n if (validNormalMove(x-1, y -1)) {\n theMove = new Move(this, x, y, x-1, y - 1, false);\n if(takeOverCheck(x-1, y-1)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n // legal move to diagonal top left\n if (validNormalMove(x-1, y+1)) {\n theMove = new Move(this, x, y, x-1, y + 1, false);\n if(takeOverCheck(x-1, y+1)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n\n\n if (whiteMoves.isEmpty())\n return null;\n return whiteMoves;\n }", "public void makeMove(Move m) {\n \tPieceColor moved = m.getSource().getColor();\n\n \t//before the move is made, record the move in the movelist\n \tupdateMoveList(m);\n \t\n \t//store locations\n \tint sx = m.getSource().getLocation().getX();\n \tint sy = m.getSource().getLocation().getY();\n \tint dx = m.getDest().getLocation().getX();\n \tint dy = m.getDest().getLocation().getY();\n \tString name_moved = m.getSource().getName();\n \t\n \t//store new king location if it moved\n \tif(name_moved.equals(\"King\")) {\n \t\tif(moved == PieceColor.White) {\n \t\t\twKing = m.getDest().getLocation();\n \t\t\t\n \t\t\t//remove castle rights on both sides\n \t\t\tcastle[0] = false;\n \t\t\tcastle[1] = false;\n \t\t}\n \t\telse if(moved == PieceColor.Black) {\n \t\t\tbKing = m.getDest().getLocation();\n \t\t\t\n \t\t\t//remove castle rights on both sides\n \t\t\tcastle[2] = false;\n \t\t\tcastle[3] = false;\n \t\t}\n \t\telse System.exit(0);\n \t}\n \t\n \t//rook check for castling rights\n \tif(name_moved.equals(\"Rook\")) {\n \t\tif(moved == PieceColor.White) {\n \t\t\tif(sx == 0 && sy == 0) removeCastle(moved, false);\n \t\t\tif(sx == 7 && sy == 0) removeCastle(moved, true);\n \t\t}\n \t\t\n \t\telse if(moved == PieceColor.Black) {\n \t\t\tif(sx == 0 && sy == 7) removeCastle(moved, false);\n \t\t\tif(sx == 7 && sy == 7) removeCastle(moved, true);\n \t\t}\n \t}\n \t\n \tPiece temp = getPiece(sx, sy);\n \t\n \tsetPiece(sx, sy, new NoPiece(sx, sy));\n \t\n \tif(temp.getName().equals(\"Pawn\") && ((Pawn)temp).getPromo() == dy) {\n \t\ttemp = new Queen(dx, dy, temp.getColor(), this);\n \t}\n \t\n \t\n \ttemp.setLocation(new Square(dx, dy));\n \t\n \t//check for en passant\n \tif(name_moved.equals(\"Pawn\")) {\n \t\tint loc = ((Pawn)temp).advance();\n \t\t((Pawn)temp).setMoved(moveList.size());\n \t\t\n \t\t//only a valid en passant move if the pawn moves diagonally\n \t\t//and the destination square is empty\n \t\tif(sx != dx && getPiece(dx, dy).getName().equals(\"None\")) {\n \t\t\tsetPiece(dx, dy-loc, new NoPiece(dx, dy-loc));\n \t\t}\n \t}\n \t\n \tsetPiece(dx, dy, temp);\n \t\n \tif(turn == PieceColor.White) turn = PieceColor.Black;\n \telse turn = PieceColor.White;\n \t\n \t//check if the move was a castle\n \tif(name_moved.equals(\"King\")) {\n \t\t\n \t\tif(moved == PieceColor.White) { \n\t \t\t//if king moved positive x, then moved king side\n\t \t\tif(dx - sx == 2) {\n\t \t\t\ttemp = getPiece(7, 0);\n\t \t\t\tsetPiece(7, 0, new NoPiece(7, 0));\n\t \t\t\t\n\t \t\t\ttemp.setLocation(new Square(5,0));\n\t \t\t\tsetPiece(5, 0, temp);\n\t \t\t}\n\t \t\t\n\t \t\telse if(sx - dx == 2) {\n\t \t\t\ttemp = getPiece(0, 0);\n\t \t\t\tsetPiece(0, 0, new NoPiece(0, 0));\n\t \t\t\t\n\t \t\t\ttemp.setLocation(new Square(3, 0));\n\t \t\t\tsetPiece(3, 0, temp);\n\t \t\t}\n \t\t}\n \t\t\n \t\tif(moved == PieceColor.Black) { \n\t \t\t//if king moved positive x, then moved king side\n\t \t\tif(dx - sx == 2) {\n\t \t\t\ttemp = getPiece(7, 7);\n\t \t\t\tsetPiece(7, 7, new NoPiece(7, 7));\n\t \t\t\t\n\t \t\t\ttemp.setLocation(new Square(5, 7));\n\t \t\t\tsetPiece(5, 7, temp);\n\t \t\t}\n\t \t\t\n\t \t\telse if(sx - dx == 2) {\n\t \t\t\ttemp = getPiece(0, 7);\n\t \t\t\tsetPiece(0, 7, new NoPiece(0, 7));\n\t \t\t\t\n\t \t\t\ttemp.setLocation(new Square(3, 7));\n\t \t\t\tsetPiece(3, 7, temp);\n\t \t\t}\n \t\t}\n \t}\n }", "public static void move(int square, char mark) {\n\t\tif (isSquareEmpty(square)) {\n\t\t\tspacesLeft = spacesLeft - 1;\n\t\t}\n\n\t\tif (square == 1) {\n\t\t\tboard[0][0] = mark;\n\t\t} else if (square == 2) {\n\t\t\tboard[0][1] = mark;\n\t\t} else if (square == 3) {\n\t\t\tboard[0][2] = mark;\n\t\t} else if (square == 4) {\n\t\t\tboard[1][0] = mark;\n\t\t} else if (square == 5) {\n\t\t\tboard[1][1] = mark;\n\t\t} else if (square == 6) {\n\t\t\tboard[1][2] = mark;\n\t\t} else if (square == 7) {\n\t\t\tboard[2][0] = mark;\n\t\t} else if (square == 8) {\n\t\t\tboard[2][1] = mark;\n\t\t} else if (square == 9) {\n\t\t\tboard[2][2] = mark;\n\t\t}\n\t}", "@Override\n\tpublic void mousePressed(MouseEvent e) {\n\t\tOptional<Piece> p = null;\n\t\t\n\t\tp = sq.processMousePress(e);\n\t\tp.ifPresent(item->{\n\t\t\titem.setScale(AnimalQueue.PieceScale);\n\t\t\titem.getMyQueue().addPiece(item, 0);\n\t\t\titem.draw();\n\t\t//\tsq.draw();\n\t\t\t});\n\t\tfor(int i=0; i<this.BOARD_SIZE; i++)\n\t\t{\n\t\t\tAnimalQueue aq = this.TheBoard[i];\n\t\t\tif(aq.contains(e.getPoint()))\n\t\t\t{\n\t\t\t\taq.getTop().ifPresent(item->{\n\t\t\t\t\tif(sq.isValidMove(item))\n\t\t\t\t\t{\n\t\t\t\t\t\taq.removePiece()\n\t\t\t\t\t\t.ifPresent(item2->{\n\t\t\t\t\t\t\tSystem.out.println(item2);\n\t\t\t\t\t\t\titem2.setScale(SolutionQueue.PieceScale);\n\t\t\t\t\t\t\tsq.addPiece(item2);\n\t\t\t\t\t\t\titem2.draw();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\t\n\t\t\t\t\t\tSystem.out.println(\"Not a valie move\");\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\t/*\n\t\t\t\tp = aq.processMousePress(e);\n\t\t\t\tp.ifPresent(item->{\n\t\t//\t\t\tSystem.out.println(\"\\t aq contents =\"+ aq.myQueue);\n\t\t\t\t\tPiece tempP = aq.removePiece();\n\t\t\t\t\ttempP.setScale(SolutionQueue.PieceScale);\n\t\t\t\t\tsq.addPiece(tempP);\n\t\t//\t\t\tSystem.out.println(\"\\t Peek =\"+ aq.removePiece());\n\t\t//\t\t\tSystem.out.println(\"\\t PieceCode removed =\"+ tempP);\n\t\t//\t\t\tSystem.out.println(\"\\t aq contents =\"+ aq.myQueue);\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\t*/\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tdraw();\n\t\trepaint();\n\t}", "public static void main(String[] args) {\n\n chessGUI g = new chessGUI();\n\n /*\n // test Root-1\n System.out.println(\"Hello World!\");\n Board test = new Board();\n test.printBoard();\n Piece king1 = new King(1, new Position(2,2), test);\n Piece king2 = new King(1, new Position(1,1), test);\n Piece ROOK3 = new Rook(-1, new Position(1,2), test);\n test.putPieceOnBoard(king1.getRow(), king1.getCol(), king1);\n test.putPieceOnBoard(king2.getRow(), king2.getCol(), king2);\n test.putPieceOnBoard(ROOK3.getRow(), ROOK3.getCol(), ROOK3);\n test.printBoard();\n Object r = ROOK3;\n if (r instanceof Rook){\n System.out.println(\"r instanceof Rook\");\n //r = (Rook) r;\n //System.out.println(((King) k).getBoard()==null);\n //.printBoard();\n int result = ((Rook) r).judgeMove(3,2);\n System.out.println(\"result\"+result);\n }\n\n // test Bishop\n Board test = new Board();\n test.printBoard();\n Piece king1 = new King(1, new Position(2,2), test);\n Piece king2 = new King(-1, new Position(1,1), test);\n Piece king3 = new King(1, new Position(2,3), test);\n\n Piece bishop = new Bishop(-1, new Position(1,2), test);\n test.putPieceOnBoard(king1.getRow(), king1.getCol(), king1);\n test.putPieceOnBoard(king2.getRow(), king2.getCol(), king2);\n test.putPieceOnBoard(king3.getRow(), king3.getCol(), king3);\n test.putPieceOnBoard(bishop.getRow(), bishop.getCol(), bishop);\n test.printBoard();\n Object r = bishop;\n if (r instanceof Bishop){\n System.out.println(\"r instanceof Bishop\");\n // 2,1 == 0\n // 2,3 == 1\n // 4,5 == -3\n int result = ((Bishop) r).judgeMove(4,5);\n System.out.println(\"result\"+result);\n }\n\n\n // test Queen\n Board test = new Board();\n test.printBoard();\n Piece king1 = new King(1, new Position(2,2), test);\n Piece king2 = new King(-1, new Position(1,1), test);\n Piece king3 = new King(1, new Position(2,3), test);\n\n Piece queen = new Queen(-1, new Position(3,2), test);\n test.putPieceOnBoard(king1.getRow(), king1.getCol(), king1);\n test.putPieceOnBoard(king2.getRow(), king2.getCol(), king2);\n test.putPieceOnBoard(king3.getRow(), king3.getCol(), king3);\n test.putPieceOnBoard(queen.getRow(), queen.getCol(), queen);\n test.printBoard();\n Object r = queen;\n if (r instanceof Queen){\n System.out.println(\"r instanceof Queen\");\n // 4,3 == 0\n // 2,2 == 1\n // 1,4 == -3\n // 3,2 == -2\n\n // 1,4 == -3\n // 5,2 == 0\n // 5,4 == 0\n // 1,0 == 0\n\n // 0,2 == -3\n // 2,3 == 1\n\n }\n Piece king4 = new King(1, new Position(4,1), test);\n test.putPieceOnBoard(king4.getRow(), king4.getCol(), king4);\n test.printBoard();\n // 4,1 == 1\n // 5, 0 == -3\n // 5, 5 == -4\n int result = ((Queen) r).judgeMove(5,5);\n System.out.println(\"result\"+result);\n\n //test Knight\n Board test = new Board();\n test.printBoard();\n Piece king1 = new King(1, new Position(2,2), test);\n Piece king2 = new King(-1, new Position(1,1), test);\n Piece king3 = new King(1, new Position(2,3), test);\n Piece queen = new Queen(-1, new Position(3,3), test);\n Piece queen1 = new Queen(1, new Position(3,1), test);\n\n Piece knight = new Knight(-1, new Position(1,2), test);\n test.putPieceOnBoard(king1.getRow(), king1.getCol(), king1);\n test.putPieceOnBoard(king2.getRow(), king2.getCol(), king2);\n test.putPieceOnBoard(king3.getRow(), king3.getCol(), king3);\n test.putPieceOnBoard(queen.getRow(), queen.getCol(), queen);\n test.putPieceOnBoard(queen1.getRow(), queen1.getCol(), queen1);\n test.putPieceOnBoard(knight.getRow(), knight.getCol(), knight);\n test.printBoard();\n Object r = knight;\n if (r instanceof Knight){\n System.out.println(\"r instanceof Knight\");\n // 2,0 == 0\n // 3,1 == 1\n // 3,3 == -3\n // 2,3 == -4\n int result = ((Knight) r).judgeMove(3,1);\n System.out.println(\"result\"+result);\n }\n\n //test Pawn\n Board test = new Board();\n Piece king1 = new King(-1, new Position(2,2), test);\n Piece king2 = new King(-1, new Position(1,1), test);\n Piece king3 = new King(-1, new Position(3,3), test);\n Piece king4 = new King(1, new Position(4,0), test);\n\n Piece pawn = new Pawn(1, new Position(1,3), test);\n Piece pawn_1 = new Pawn(-1, new Position(5,1), test);\n test.putPieceOnBoard(king1.getRow(), king1.getCol(), king1);\n test.putPieceOnBoard(king2.getRow(), king2.getCol(), king2);\n test.putPieceOnBoard(king3.getRow(), king3.getCol(), king3);\n test.putPieceOnBoard(king4.getRow(), king4.getCol(), king4);\n test.putPieceOnBoard(pawn.getRow(), pawn.getCol(), pawn);\n test.putPieceOnBoard(pawn_1.getRow(), pawn_1.getCol(), pawn_1);\n\n test.printBoard();\n // pawn 2,2 = 1\n // pawn 2,3 = 0\n // pawn -3, 0 = -1\n // pawn 1,3 = -2\n // pawn 0,3 = -4\n // pawn 3,3 = -3\n\n\n //(Pawn) pawn).isFirstMove = 0;\n\n // pawn[-1] 6,1 = -4\n // pawn[-1] 4,0 = 1\n // pawn[-1] 4,1 = 0\n // pawn[-1] 3,1 = 0\n int result = ((Pawn) pawn_1).judgeMove(3,1);\n\n System.out.println(\"result\"+result);\n\n Board test = new Board();\n Piece king1 = new King(1, new Position(2,2), test);\n Piece king2 = new King(-1, new Position(1,1), test);\n Piece king3 = new King(1, new Position(2,3), test);\n Piece queen = new Queen(-1, new Position(3,3), test);\n Piece queen1 = new Queen(1, new Position(3,1), test);\n\n Piece rook = new Rook(-1, new Position(1,2), test);\n\n test.putPieceOnBoard(king1.getRow(), king1.getCol(), king1);\n test.putPieceOnBoard(king2.getRow(), king2.getCol(), king2);\n test.putPieceOnBoard(king3.getRow(), king3.getCol(), king3);\n test.putPieceOnBoard(queen.getRow(), queen.getCol(), queen);\n test.putPieceOnBoard(queen1.getRow(), queen1.getCol(), queen1);\n test.putPieceOnBoard(rook.getRow(), rook.getCol(), rook);\n test.printBoard();\n\n // 2,2 = 1\n // 1,3 = 0\n // 1,5 = 0\n // -1,0 = -1\n // 1,2 = -2\n // 1,0 = -3\n // 0,0 = -4\n int result = ((Rook) rook).judgeMove(1,3);\n\n System.out.println(\"result\"+result);\n */\n\n /* test startingBoard()\n Board board = new Board();\n board.startingBoard();\n board.printBoard();\n */\n\n //test pawnThread();\n /*\n Board board = new Board();\n Piece kingwhite = new King(1, new Position(2,2), board);\n Piece kingblack = new King(-1, new Position(5,2), board);\n Piece king3 = new King(1, new Position(3,4), board);\n Piece p1 = new Pawn(1, new Position(4,1), board);\n Piece p2 = new Pawn(-1, new Position(4,3), board);\n Piece p3 = new Pawn(1, new Position(3,1), board);\n Piece p4 = new Pawn(-1, new Position(1,1), board);\n\n board.putPieceOnBoard(kingwhite.getRow(),kingwhite.getCol(),kingwhite);\n board.putPieceOnBoard(kingblack.getRow(),kingblack.getCol(),kingblack);\n board.putPieceOnBoard(king3.getRow(), king3.getCol(), king3);\n board.putPieceOnBoard(p1.getRow(), p1.getCol(), p1);\n board.putPieceOnBoard(p2.getRow(), p2.getCol(), p2);\n board.putPieceOnBoard(p3.getRow(), p3.getCol(), p3);\n board.putPieceOnBoard(p4.getRow(), p4.getCol(), p4);\n\n board.printBoard();\n // true\n System.out.println(board.pawnThread(-1*kingblack.getColor(),kingblack.getRow(),kingblack.getCol()));\n // false\n System.out.println(board.pawnThread(-1*kingwhite.getColor(),kingwhite.getRow(),kingwhite.getCol()));\n // true\n System.out.println(board.pawnThread(-1*king3.getColor(),king3.getRow(),king3.getCol()));\n */\n\n //test kingThread();\n /*\n Board board = new Board();\n Piece king1 = new King(1, new Position(2,2), board);\n Piece king2 = new King(-1, new Position(5,2), board);\n\n Piece p1 = new King(1, new Position(3,2), board);\n Piece p2 = new King(-1, new Position(5,1), board);\n Piece p3 = new King(1, new Position(4,1), board);\n Piece p4 = new King(1, new Position(4,3), board);\n\n\n board.putPieceOnBoard(king1.getRow(),king1.getCol(),king1);\n board.putPieceOnBoard(king2.getRow(),king2.getCol(),king2);\n board.putPieceOnBoard(p1.getRow(), p1.getCol(), p1);\n board.putPieceOnBoard(p2.getRow(), p2.getCol(), p2);\n board.putPieceOnBoard(p3.getRow(), p3.getCol(), p3);\n board.putPieceOnBoard(p4.getRow(), p4.getCol(), p4);\n board.printBoard();\n //false\n System.out.println(board.kingThread(-1*king1.getColor(),king1.getRow(),king1.getCol()));\n //true\n System.out.println(board.kingThread(-1*king2.getColor(),king2.getRow(),king2.getCol()));\n //true\n System.out.println(board.kingThread(-1*p4.getColor(),p4.getRow(),p4.getCol()));\n //false\n System.out.println(board.kingThread(-1*p1.getColor(),p1.getRow(),p1.getCol()));\n */\n\n\n //test knightThread();\n /*\n Board board = new Board();\n Piece k1 = new King(1, new Position(2,2), board);\n Piece k2 = new King(-1, new Position(5,2), board);\n Piece k3 = new King(-1, new Position(6,4), board);\n\n Piece p1 = new Knight(-1, new Position(0,3), board);\n Piece p2 = new Knight(-1, new Position(5,1), board);\n Piece p3 = new Knight(1, new Position(4,1), board);\n Piece p4 = new Knight(1, new Position(4,4), board);\n\n\n board.putPieceOnBoard(k1.getRow(),k1.getCol(),k1);\n board.putPieceOnBoard(k2.getRow(),k2.getCol(),k2);\n board.putPieceOnBoard(k3.getRow(),k3.getCol(),k3);\n board.putPieceOnBoard(p1.getRow(), p1.getCol(), p1);\n board.putPieceOnBoard(p2.getRow(), p2.getCol(), p2);\n board.putPieceOnBoard(p3.getRow(), p3.getCol(), p3);\n board.putPieceOnBoard(p4.getRow(), p4.getCol(), p4);\n board.printBoard();\n //true\n System.out.println(board.knightThread(-1*k1.getColor(),k1.getRow(),k1.getCol()));\n //true\n System.out.println(board.knightThread(-1*k2.getColor(),k2.getRow(),k2.getCol()));\n //false\n System.out.println(board.knightThread(-1*k3.getColor(),k3.getRow(),k3.getCol()));\n */\n\n //test bishopQueenThread();\n/*\n Board board = new Board();\n //board.bishopQueenThread(1, 3,4);\n\n Piece k1 = new King(1, new Position(2,2), board);\n Piece k2 = new King(-1, new Position(5,2), board);\n Piece k3 = new King(1, new Position(6,4), board);\n\n Piece p1 = new Bishop(-1, new Position(0,3), board);\n Piece p2 = new Bishop(-1, new Position(5,1), board);\n Piece p3 = new Bishop(1, new Position(3,0), board);\n Piece p4 = new Bishop(1, new Position(4,4), board);\n Piece p5 = new Bishop(-1, new Position(5,5), board);\n\n\n board.putPieceOnBoard(k1.getRow(),k1.getCol(),k1);\n board.putPieceOnBoard(k2.getRow(),k2.getCol(),k2);\n board.putPieceOnBoard(k3.getRow(),k3.getCol(),k3);\n board.putPieceOnBoard(p1.getRow(), p1.getCol(), p1);\n board.putPieceOnBoard(p2.getRow(), p2.getCol(), p2);\n board.putPieceOnBoard(p3.getRow(), p3.getCol(), p3);\n board.putPieceOnBoard(p4.getRow(), p4.getCol(), p4);\n board.putPieceOnBoard(p5.getRow(), p5.getCol(), p5);\n board.printBoard();\n //false\n System.out.println(board.bishopQueenThread(-1*k1.getColor(),k1.getRow(),k1.getCol()));\n //true\n System.out.println(board.bishopQueenThread(-1*k2.getColor(),k2.getRow(),k2.getCol()));\n //true\n System.out.println(board.bishopQueenThread(-1*k3.getColor(),k3.getRow(),k3.getCol()));\n */\n\n //test rookQueenThread\n\n /*\n Piece k1 = new King(1, new Position(2,2), board);\n Piece k2 = new King(1, new Position(5,2), board);\n Piece k3 = new King(-1, new Position(6,4), board);\n\n Piece p1 = new Rook(-1, new Position(0,3), board);\n Piece p2 = new Rook(-1, new Position(5,1), board);\n Piece p3 = new Rook(1, new Position(3,0), board);\n Piece p4 = new Rook(1, new Position(4,4), board);\n Piece p5 = new Rook(-1, new Position(5,5), board);\n\n\n board.putPieceOnBoard(k1.getRow(),k1.getCol(),k1);\n board.putPieceOnBoard(k2.getRow(),k2.getCol(),k2);\n board.putPieceOnBoard(k3.getRow(),k3.getCol(),k3);\n board.putPieceOnBoard(p1.getRow(), p1.getCol(), p1);\n board.putPieceOnBoard(p2.getRow(), p2.getCol(), p2);\n board.putPieceOnBoard(p3.getRow(), p3.getCol(), p3);\n board.putPieceOnBoard(p4.getRow(), p4.getCol(), p4);\n board.putPieceOnBoard(p5.getRow(), p5.getCol(), p5);\n board.printBoard();\n //false\n System.out.println(board.rookQueenThread(-1*k1.getColor(),k1.getRow(),k1.getCol()));\n //true\n System.out.println(board.rookQueenThread(-1*k2.getColor(),k2.getRow(),k2.getCol()));\n //true\n System.out.println(board.rookQueenThread(-1*k3.getColor(),k3.getRow(),k3.getCol()));\n */\n\n\n }", "private ArrayList<Move> blackKing() {\n // obtain current co-ordinates\n int x = this.getX();\n int y = this.getY();\n\n ArrayList<Move> blackMoves = new ArrayList<Move>();\n\n // set up m to refer to a Move object\n Move theMove = null;\n\n\n // the top and bottom are opposites coordinates for the black and white kings and so are left and right\n // all Unoccupied moves\n\n // first legal move is to go from x,y to x,y-1 if x,y-1 is unoccupied (top)\n if (validNormalMove(x, y - 1)) {\n theMove = new Move(this, x, y, x, y - 1, false);\n if(takeOverCheck(x, y-1)){\n theMove.setOccupied(true);\n }\n\n blackMoves.add(theMove);\n }\n\n\n // legal move is to go from x,y to x,y+1 if x,y+1 is unoccupied (bottom)\n if (validNormalMove(x, y + 1)) {\n theMove = new Move(this, x, y, x, y + 1, false);\n if(takeOverCheck(x, y+1)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n }\n\n //left\n // legal move to go left from x,y to x+1, y if x+1,y is unoccupied (left)\n\n if (validNormalMove(x+1, y)) {\n theMove = new Move(this, x, y, x+1, y, false);\n if(takeOverCheck(x+1, y)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n\n }\n\n //right\n // legal move to go right from x,y to x-1, y if x-1,y is unoccupied (right)\n\n if (validNormalMove(x-1, y)) {\n theMove = new Move(this, x, y, x-1, y, false);\n\n if(takeOverCheck(x-1, y)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n }\n\n\n // legal move to diagonal top right for white king\n if (validNormalMove(x-1, y - 1)) {\n theMove = new Move(this, x, y, x-1, y - 1, false);\n if(takeOverCheck(x-1, y-1)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n }\n\n // legal move to diagonal bottom left\n\n if (validNormalMove(x+1, y +1)) {\n theMove = new Move(this, x, y, x+1, y + 1, false);\n\n if(takeOverCheck(x+1, y+1)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n }\n\n // legal move to diagonal bottom right\n if (validNormalMove(x-1, y +1)) {\n theMove = new Move(this, x, y, x-1, y + 1, false);\n if(takeOverCheck(x-1, y+1)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n }\n\n // legal move to diagonal top left\n if (validNormalMove(x+1, y-1)) {\n theMove = new Move(this, x, y, x+1, y - 1, false);\n if(takeOverCheck(x+1, y-1)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n }\n\n\n\n\n\n if (blackMoves.isEmpty())\n return null;\n return blackMoves;\n }", "@Test\n public void testQueenLabel() {\n // initialize the complete chess board\n ChessBoard chessBoard = init(\"CHESS\");\n\n assertEquals(\"Q\", chessBoard.getPiece(0, 3).getLabel());\n assertEquals(\"Q\", chessBoard.getPiece(7, 3).getLabel());\n }", "public boolean canCastle(int direction){\n\t\tPiece rook;\n\t\t\n\t\tif(!((getColor().equals(\"White\") && getSquare().getCol() == 4 && getSquare().getRow() == 7 ) ||\n\t\t\t\t(getColor().equals(\"Black\") && getSquare().getCol() == 4 && getSquare().getRow() == 0 )))\n\t\t\treturn false;\n\t\t\n\t\t\n\t\tif(direction == 1){\n\t\t\trook = getSquare().getEast().getEast().getEast().getOccupant();\n\t\t\tif(rook == null || !rook.getColor().equals(this.getColor()) || !rook.getType().equals(\"Rook\") || rook.hasMoved() || this.hasMoved())\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getEast().getEast().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getEast().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\t\n\t\t\tif(getColor().equals(\"White\")){\n\t\t\t\tfor(int i = 0; i < ChessBoard.getPieces().size(); i++){\n\t\t\t\t\tif(ChessBoard.getPieces().get(i).getColor().equals(\"Black\"))\n\t\t\t\t\t\tfor(int location: ChessBoard.getPieces().get(i).getMoves()){\n\t\t\t\t\t\t\tif(location == 75 || location == 76){\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tfor(int i = 0; i < ChessBoard.getPieces().size(); i++){\n\t\t\t\t\tif(ChessBoard.getPieces().get(i).getColor().equals(\"White\"))\n\t\t\t\t\t\tfor(int location: ChessBoard.getPieces().get(i).getMoves()){\n\t\t\t\t\t\t\tif(location == 5 || location == 6){\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\t\n\t\t}\n\t\t\n\t\telse if (direction == -1){//East\n\t\t\trook = getSquare().getWest().getWest().getWest().getWest().getOccupant();\n\t\t\tif(rook == null || !rook.getColor().equals(this.getColor()) || !rook.getType().equals(\"Rook\") || rook.hasMoved() || this.hasMoved())\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getWest().getWest().getWest().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getWest().getWest().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getWest().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\t\n\t\t\tif(getColor().equals(\"White\")){\n\t\t\t\tfor(int i = 0; i < ChessBoard.getPieces().size(); i++){\n\t\t\t\t\tif(ChessBoard.getPieces().get(i).getColor().equals(\"Black\"))\n\t\t\t\t\t\tfor(int location: ChessBoard.getPieces().get(i).getMoves()){\n\t\t\t\t\t\t\tif(location == 73 || location == 72 || location == 71){\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\telse{\n\t\t\t\tfor(int i = 0; i < ChessBoard.getPieces().size(); i++){\n\t\t\t\t\tif(ChessBoard.getPieces().get(i).getColor().equals(\"White\"))\n\t\t\t\t\t\tfor(int location: ChessBoard.getPieces().get(i).getMoves()){\n\t\t\t\t\t\t\tif(location == 3 || location == 2 || location == 1){\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn true;\n\t}", "public Queen(Chess chess, Player player, int x, int y) {\n super(chess, player, x, y);\n }", "boolean makeMove(Bouger m) {\n\tlong oldBits[] = { pieceBits[LIGHT], pieceBits[DARK] };\n\n\tint from, to;\n\t/*\n\t* test to see if a castle move is legal and move the rook (the king is\n\t* moved with the usual move code later)\n\t*/\n\tif ((m.bits & 2) != 0) {\n\n\tif (inCheck(side))\n\treturn false;\n\tswitch (m.getTo()) {\n\tcase 62:\n\tif (color[F1] != EMPTY || color[G1] != EMPTY\n\t|| attack(F1, xside) || attack(G1, xside))\n\treturn false;\n\tfrom = H1;\n\tto = F1;\n\tbreak;\n\tcase 58:\n\tif (color[B1] != EMPTY || color[C1] != EMPTY\n\t|| color[D1] != EMPTY || attack(C1, xside)\n\t|| attack(D1, xside))\n\treturn false;\n\tfrom = A1;\n\tto = D1;\n\tbreak;\n\tcase 6:\n\tif (color[F8] != EMPTY || color[G8] != EMPTY\n\t|| attack(F8, xside) || attack(G8, xside))\n\treturn false;\n\tfrom = H8;\n\tto = F8;\n\tbreak;\n\tcase 2:\n\tif (color[B8] != EMPTY || color[C8] != EMPTY\n\t|| color[D8] != EMPTY || attack(C8, xside)\n\t|| attack(D8, xside))\n\treturn false;\n\tfrom = A8;\n\tto = D8;\n\tbreak;\n\tdefault: /* shouldn't get here */\n\tfrom = -1;\n\tto = -1;\n\tbreak;\n\t}\n\tcolor[to] = color[from];\n\tpiece[to] = piece[from];\n\tcolor[from] = EMPTY;\n\tpiece[from] = EMPTY;\n\tpieceBits[side] ^= (1L << from) | (1L << to);\n\t}\n\t/* back up information so we can take the move back later. */\n\n\tHistoryData h = new HistoryData();\n\th.m = m;\n\tto = m.getTo();\n\tfrom = m.getFrom();\n\th.capture = piece[to];\n\th.castle = castle;\n\th.ep = ep;\n\th.fifty = fifty;\n\th.pawnBits = new long[] { pawnBits[LIGHT], pawnBits[DARK] };\n\th.pieceBits = oldBits;\n\thistDat[hply++] = h;\n\n\t/*\n\t* update the castle, en passant, and fifty-move-draw variables\n\t*/\n\tcastle &= castleMask[from] & castleMask[to];\n\tif ((m.bits & 8) != 0) {\n\tif (side == LIGHT)\n\tep = to + 8;\n\telse\n\tep = to - 8;\n\t} else\n\tep = -1;\n\tif ((m.bits & 17) != 0)\n\tfifty = 0;\n\telse\n\t++fifty;\n\n\t/* move the piece */\n\tint thePiece = piece[from];\n\tif (thePiece == KING)\n\tkingSquare[side] = to;\n\tcolor[to] = side;\n\tif ((m.bits & 32) != 0) {\n\tpiece[to] = m.promote;\n\tpieceMat[side] += pieceValue[m.promote];\n\t} else\n\tpiece[to] = thePiece;\n\tcolor[from] = EMPTY;\n\tpiece[from] = EMPTY;\n\tlong fromBits = 1L << from;\n\tlong toBits = 1L << to;\n\tpieceBits[side] ^= fromBits | toBits;\n\tif ((m.bits & 16) != 0) {\n\tpawnBits[side] ^= fromBits;\n\tif ((m.bits & 32) == 0)\n\tpawnBits[side] |= toBits;\n\t}\n\tint capture = h.capture;\n\tif (capture != EMPTY) {\n\tpieceBits[xside] ^= toBits;\n\tif (capture == PAWN)\n\tpawnBits[xside] ^= toBits;\n\telse\n\tpieceMat[xside] -= pieceValue[capture];\n\t}\n\n\t/* erase the pawn if this is an en passant move */\n\tif ((m.bits & 4) != 0) {\n\tif (side == LIGHT) {\n\tcolor[to + 8] = EMPTY;\n\tpiece[to + 8] = EMPTY;\n\tpieceBits[DARK] ^= (1L << (to + 8));\n\tpawnBits[DARK] ^= (1L << (to + 8));\n\t} else {\n\tcolor[to - 8] = EMPTY;\n\tpiece[to - 8] = EMPTY;\n\tpieceBits[LIGHT] ^= (1L << (to - 8));\n\tpawnBits[LIGHT] ^= (1L << (to - 8));\n\t}\n\t}\n\n\t/*\n\t* switch sides and test for legality (if we can capture the other guy's\n\t* king, it's an illegal position and we need to take the move back)\n\t*/\n\tside ^= 1;\n\txside ^= 1;\n\tif (inCheck(xside)) {\n\ttakeBack();\n\treturn false;\n\t}\n\treturn true;\n\t}", "public ArrayList<String> legalMoves(boolean side) {\n\t\tArrayList<String> moveList = new ArrayList<String>();\n\t\tchar fTemp = ' ', tTemp = ' ';\n\t\tString tempMove;\n\t\tupdate();\n\t\t\n\t\tfor (byte r = 0; r < b.length; r++) {\n\t\t\tfor (byte c = 0; c < b[r].length; c++) {\n\t\t\t\tif (b[r][c].getSide() == side && !(b[r][c] instanceof Null)) {\n\t\t\t\t\tif (c == 0) {\n\t\t\t\t\t\tfTemp = 'a';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\telse if (c == 1) {\n\t\t\t\t\t\tfTemp = 'b';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\telse if (c == 2) {\n\t\t\t\t\t\tfTemp = 'c';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\telse if (c == 3) {\n\t\t\t\t\t\tfTemp = 'd';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\telse if (c == 4) {\n\t\t\t\t\t\tfTemp = 'e';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\telse if (c == 5) {\n\t\t\t\t\t\tfTemp = 'f';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\telse if (c == 6) {\n\t\t\t\t\t\tfTemp = 'g';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\telse if (c == 7) {\n\t\t\t\t\t\tfTemp = 'h';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (b[r][c] instanceof King) {\n\t\t\t\t\t\tif (side) {\n\t\t\t\t\t\t\tif (b[0][5] instanceof Null && b[0][6] instanceof Null && ((King) b[r][c]).getCKS()) {\n\t\t\t\t\t\t\t\tmoveList.add(\"O-O\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (b[0][1] instanceof Null && b[0][2] instanceof Null && ((King) b[r][c]).getCQS()) {\n\t\t\t\t\t\t\t\tmoveList.add(\"O-O-O\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tif (b[7][5] instanceof Null && b[7][6] instanceof Null && ((King) b[r][c]).getCKS()) {\n\t\t\t\t\t\t\t\tmoveList.add(\"O-O\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (b[7][1] instanceof Null && b[7][2] instanceof Null && ((King) b[r][c]).getCQS()) {\n\t\t\t\t\t\t\t\tmoveList.add(\"O-O-O\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tfor (Piece p : b[r][c].getMoves()) {\n\t\t\t\t\t\tif (p.getFile() == 0) {\n\t\t\t\t\t\t\ttTemp = 'a';\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\telse if (p.getFile() == 1) {\n\t\t\t\t\t\t\ttTemp = 'b';\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\telse if (p.getFile() == 2) {\n\t\t\t\t\t\t\ttTemp = 'c';\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\telse if (p.getFile() == 3) {\n\t\t\t\t\t\t\ttTemp = 'd';\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\telse if (p.getFile() == 4) {\n\t\t\t\t\t\t\ttTemp = 'e';\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\telse if (p.getFile() == 5) {\n\t\t\t\t\t\t\ttTemp = 'f';\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\telse if (p.getFile() == 6) {\n\t\t\t\t\t\t\ttTemp = 'g';\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\telse if (p.getFile() == 7) {\n\t\t\t\t\t\t\ttTemp = 'h';\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\ttempMove = b[r][c].getSymbol() + \"\" + fTemp + \"\" + (b[r][c].getRank()+1) + '-' + tTemp + (p.getRank()+1);\n\t\t\t\t\t\tBoard nBD = new Board(getBoard());\n\t\t\t\t\t\tnBD.move(tempMove, side);\n\t\t\t\t\t\tnBD.update();\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (!(nBD.check(!side))) {\n\t\t\t\t\t\t\t//Promotion\n\t\t\t\t\t\t\tif (side && p.getRank() == 7 && b[r][c] instanceof Pawn) {\n\t\t\t\t\t\t\t\tmoveList.add(tempMove + \"=Q\");\n\t\t\t\t\t\t\t\tmoveList.add(tempMove + \"=R\");\n\t\t\t\t\t\t\t\tmoveList.add(tempMove + \"=N\");\n\t\t\t\t\t\t\t\tmoveList.add(tempMove + \"=B\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\telse if (!side && p.getRank() == 0 && b[r][c] instanceof Pawn) {\n\t\t\t\t\t\t\t\tmoveList.add(tempMove + \"=Q\");\n\t\t\t\t\t\t\t\tmoveList.add(tempMove + \"=R\");\n\t\t\t\t\t\t\t\tmoveList.add(tempMove + \"=N\");\n\t\t\t\t\t\t\t\tmoveList.add(tempMove + \"=B\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tmoveList.add(tempMove);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn moveList;\n\t}", "private void getWinner() {\r\n int nWhite = 0, nBlack = 0;\r\n if(nextPlayer.getChecks() == 0 && nextPlayer.getQueens() == 0){\r\n winner = currentPlayer;\r\n }\r\n else if(currentPlayer.getQueens() == nextPlayer.getQueens()){\r\n for (int i = 1; i<8; i++){\r\n for (int x = 0; x<8; x++) {\r\n if (checks[i][x] == 1) nBlack++;\r\n if (checks[7 - i][x] == 2) nWhite++;\r\n }\r\n if (nWhite>nBlack) winner = getPlayer(WHITE);\r\n else if(nBlack>nWhite)winner = getPlayer(BLACK);\r\n nWhite = 0;\r\n nBlack = 0;\r\n }\r\n }\r\n else if (currentPlayer.getQueens() > nextPlayer.getQueens()){ winner = currentPlayer;}\r\n else{winner = nextPlayer; }\r\n }", "public boolean move(int x, int y, CheckersBoard board) {\n if (whiteTurn == true && team == Constants.TeamId.team1Id) {\n return false;\n }\n if (whiteTurn == false && team == Constants.TeamId.team2Id) {\n return false;\n }\n /**\n * then change the x - y coords of the piece\n * update the UI to remove the highlighted squares then move the piece\n * if chess and shared square you take a piece\n * if checkers you jumped them you take the piece\n * return new x - y components\n *\n * if this is too high up in the tree you can override this implementation or update it\n * to fit specific pieces if its not working for some reason\n */\n if (possible(x, y, gameBoard)) {\n int changex = this.getX()-x;\n int changey = this.getY()-y;\n CheckersPiece temp = gameBoard.boardPositions[getX()][getY()];\n gameBoard.boardPositions[getX()][getY()] = null;\n gameBoard.boardPositions[x][y] = temp;\n if (gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2] != null) {\n System.out.println(\"Here\");\n if (gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2].team != this.team) {\n gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2].imageView.setVisibility(View.GONE);\n gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2] = null;\n }\n }\n this.setX(x);\n this.setY(y);/*\n if (Math.abs(changex) == 2) {\n gameBoard.boardPositions[x + (changex/2)][y + (changey/2)] = null;\n if (team == Constants.TeamId.team1Id) {\n board.numPieces1--;\n } else if (team == Constants.TeamId.team2Id) {\n board.numPieces0--;\n }\n }*/\n\n gameBoard.boardPositions[x][y].imageView.setX(142*x);\n gameBoard.boardPositions[x][y].imageView.setY(142*y);\n // flips after move is\n whiteTurn = !whiteTurn;\n gameBoard.startTimer();\n }\n //setUpUI(gameBoard);\n if (getY() == 7 && team == Constants.TeamId.team2Id) {\n board.crown(this);\n }\n if (getY() == 0 && team == Constants.TeamId.team1Id) {\n board.crown(this);\n }\n return possible(x, y, gameBoard);\n }", "public Move move() {\n\n byte[] piece;\n int pieceIndex;\n Move.Direction direction = null;\n int counter = 0;\n\n Scanner s = new Scanner(System.in);\n\n\n System.out.println(\"Please select piece to move: \");\n\n\n while (true) {\n try {\n pieceIndex = s.nextInt();\n\n if ((piece = getPiece(pieceIndex)) == null) {\n System.out.println(\"invalid index, try again!\");\n// check if selected piece is stuck\n } else if (\n (((player == Board.V) && (piece[1]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O ) || // UP\n ((player == Board.H) && (piece[1]-1 >=0) && (board.layout[piece[0]][piece[1]-1] == O)) || // DOWN\n ((player == Board.V) && (piece[0]-1 >=0) && (board.layout[piece[0]-1][piece[1]] == O)) || // LEFT\n (((player == Board.H) && (piece[0]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O )) // RIGHT\n {\n break;\n// if all are stuck pass turn\n } else if (counter + 1 < Board.getSize()) {\n counter++;\n System.out.println(\"Piece is stuck, pick another, \" + counter + \" pieces stuck.\");\n } else {\n System.out.println(\"Passing\");\n return null;\n }\n } catch (Exception e){\n System.out.println(\"Piece index expects int, try again\");\n s = new Scanner(System.in);\n }\n }\n System.out.println(\"Please select direction ('w' // 'a' // 's' // 'd'): \");\n\n boolean valid = false;\n while (!valid) {\n\n switch (s.next().charAt(0)) {\n // if the move requested is valid, break the loop, make the move on our record of layout and return the\n // move made\n case 'w':\n direction = Move.Direction.UP;\n valid = (((player == Board.V) && (piece[1]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O );\n break;\n\n case 'a':\n direction = Move.Direction.LEFT;\n valid = ((player == Board.V) && (piece[0]-1 >=0) && (board.layout[piece[0]-1][piece[1]] == O));\n break;\n\n case 's':\n direction = Move.Direction.DOWN;\n valid = ((player == Board.H) && (piece[1]-1 >=0) && (board.layout[piece[0]][piece[1]-1] == O));\n break;\n\n case 'd':\n direction = Move.Direction.RIGHT;\n valid = (((player == Board.H) && (piece[0]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O );\n break;\n default:\n System.out.println(\"Invalid key press, controls are wasd\");\n valid = false;\n }\n }\n Move move = makeMove(direction, pieceIndex);\n board.update(move, player);\n\n return move;\n }", "private void reMark(int row, int col){\n for(int i = 0; i < sizeOfBoard; ++i){\n int rowOfOtherCol = rowUsedByColNumber[i] - 1;\n if(rowOfOtherCol != -1){//Is there a queen in this row?\n int colOffSet = Math.abs(rowOfOtherCol - row);\n int rowOffSet = col - i;\n \n if(col + colOffSet < sizeOfBoard){\n openPositions[rowOfOtherCol][col + colOffSet] = true;//Mark the one open square in the row of other queen.\n }\n if(i+ colOffSet < sizeOfBoard){\n openPositions[row][i + colOffSet] = true;//Mark the diagonal of the other queen at can attack in the row that the removed queen was in.\n }\n //remake were a queen and the queen removed could both attack in the diagonal direction.\n int colD = (i + col + row - rowOfOtherCol) / 2;//First intersection point.\n int rowD = (col - i + row + rowOfOtherCol) / 2;//First intersection point.\n \n if(colD >= 0 && colD < sizeOfBoard && rowD >= 0 && rowD < sizeOfBoard){//Does that point lie in the board?\n if( colD*2 == i + col + row - rowOfOtherCol && rowD*2 == col - i + row + rowOfOtherCol && colD >col){//Is the point a lattice point?\n openPositions[rowD][colD] = true;\n }\n }\n \n colD = (i + col - row + rowOfOtherCol) / 2;//Second intersection point.\n rowD = (i - col +row + rowOfOtherCol) / 2;//Second intersection point.\n if(colD >= 0 && colD < sizeOfBoard && rowD >= 0 && rowD < sizeOfBoard){\n if(colD*2 == i + col - row + rowOfOtherCol && rowD*2 == i - col +row + rowOfOtherCol && colD > col ){//Is the point a lattice point?\n openPositions[rowD][colD] = true;\n }\n }\n }\n }\n }", "private boolean isQueen(Point pos){\r\n Cells aux = model.getValueAt(pos);\r\n return (aux == Cells.BLACK_QUEEN || aux == Cells.RED_QUEEN);\r\n }", "public void checkWinner(){\n \n if ((board[0][0] == 'X' && board[0][1] == 'X' && board[0][2] == 'X')||(board[1][0] == 'X' && board[1][1] == 'X' && board[1][2] == 'X')||(board[2][0] == 'X' && board[2][1] == 'X' && board[2][2] == 'X')){\n winner();\n }\n else if ((board[0][0] == 'X' && board[1][0] == 'X' && board[2][0] == 'X')||(board[0][1] == 'X' && board[1][1] == 'X' && board[2][1] == 'X')||(board[0][2] == 'X' && board[1][2] == 'X' && board[2][2] == 'X')){\n winner();\n }\n else if ((board[0][0] == 'X' && board[1][1] == 'X' && board[2][2] == 'X')||(board[0][2] == 'X' && board[1][1] == 'X' && board[2][0] == 'X')){\n winner();\n }\n else if ((board[0][0] == 'O' && board[0][1] == 'O' && board[0][2] == 'O')||(board[1][0] == 'O' && board[1][1] == 'O' && board[1][2] == 'O')||(board[2][0] == 'O' && board[2][1] == 'O' && board[2][2] == 'O')){\n winner();\n }\n else if ((board[0][0] == 'O' && board[1][0] == 'O' && board[2][0] == 'O')||(board[0][1] == 'O' && board[1][1] == 'O' && board[2][1] == 'O')||(board[0][2] == 'O' && board[1][2] == 'O' && board[2][2] == 'O')){\n winner();\n }\n else if ((board[0][0] == 'O' && board[1][1] == 'O' && board[2][2] == 'O')||(board[0][2] == 'O' && board[1][1] == 'O' && board[2][0] == 'O')){\n winner();\n }\n \n }", "private void easyMove(Board board) {\n\t\t\r\n\t}", "public Queen (String color) {\n\t\tsuper (color);\n\t\tthis.type = \"Queen\";\n\t}", "@Override\n protected String moveSelectionAlgorithm(int pieceID) {\n\n //If there is a winning move, take it\n\n\n // [This is where you should insert the required code for Assignment 1.]\n \n boolean skip = false;\n int row,col=0;\n for (row = 0; row < this.quartoBoard.getNumberOfRows(); row++) {\n for (col = 0; col < this.quartoBoard.getNumberOfColumns(); col++) {\n if (!this.quartoBoard.isSpaceTaken(row, col)) {\n QuartoBoard copyBoard = new QuartoBoard(this.quartoBoard);\n copyBoard.insertPieceOnBoard(row, col, pieceID);\n if (copyBoard.checkRow(row) || copyBoard.checkColumn(col) || copyBoard.checkDiagonals()) {\n skip = true;\n break;\n }\n }\n }\n if (skip) {\n break;\n }\n }\n\tSystem.out.print(\"ROW , COLUMNS = \"+ row+\" , \"+ col);\n\t\n\tif(skip){\n return row +\",\"+ col;}\n\n\n\n // If no winning move is found in the above code, then return a random (unoccupied) square\n\n int[] move = new int[2];\n QuartoBoard copyBoard = new QuartoBoard(this.quartoBoard);\n move = copyBoard.chooseRandomPositionNotPlayed(100);\n\n return move[0] + \",\" + move[1];\n }", "@Override\n public void drawValidMove() {\n if(this.getPlayer().getPlayerID() % 2 != 0) {\n //Pawn can move one space forwards if no piece is in front\n if (board.getSquare(x-1, y).getPiece()== null) {\n board.getSquare(x-1, y).drawOutline();\n }\n \n //if first move, pawn can move 2 spaces forward\n if (!hasMoved && board.getSquare(x-2, y).getPiece() == null && board.getSquare(x-1, y).getPiece() == null) {\n board.getSquare(x-2, y).drawOutline();\n }\n \n //If there is an enemy piece in the diagonal forward square of the pawn, the pawn can move (capture the piece)\n if (y-1 > 0) { //ensures no arrayoutofbounds error\n if (board.getSquare(x-1, y-1) != null && board.getSquare(x-1, y-1).getPiece() != null &&\n board.getSquare(x-1, y-1).getPiece().getPlayer() != this.getPlayer()) {\n board.getSquare(x-1, y-1).drawOutline();\n }\n }\n \n if(y+1<SIZE) { //ensures no arrayoutofbounds error\n if (board.getSquare(x-1, y+1) != null && board.getSquare(x-1, y+1).getPiece() != null &&\n board.getSquare(x-1, y+1).getPiece().getPlayer() != this.getPlayer() ) {\n board.getSquare(x-1, y+1).drawOutline();\n }\n }\n \n System.out.println(\"\");\n //En passant\n if (y - 1 > 0) {\n \n System.out.println();\n if (board.getSquare(x, y-1).getPiece() != null) { \n System.out.println(\"the piece's enPassant is: \" + board.getSquare(x, y-1).getPiece().getEnPassant());\n System.out.println(\"The game's turn counter is: \" + board.getTurnCounter());\n }\n else {\n System.out.println(\"Null piece when checking for en passent.\");\n }\n \n if (board.getSquare(x, y-1).getPiece() != null && board.getSquare(x, y-1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y-1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x-1, y-1).drawOutline();\n board.getSquare(x-1, y-1).setEnPassent(true);\n }\n }\n \n if (y + 1 < SIZE) {\n if (board.getSquare(x, y+1).getPiece() != null && board.getSquare(x, y+1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y+1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x-1, y+1).drawOutline();\n board.getSquare(x-1, y+1).setEnPassent(true);\n }\n }\n }\n \n //If this pawn belongs to player 2:\n else {\n \n if (board.getSquare(x+1, y).getPiece() == null) {\n board.getSquare(x+1, y).drawOutline();\n }\n \n //if first move, pawn can move 2 spaces forward\n if (!hasMoved && board.getSquare(x+2, y).getPiece() == null && board.getSquare(x+1, y).getPiece() == null) {\n board.getSquare(x+2, y).drawOutline();\n \n }\n \n if(y-1 > 0) {\n if (board.getSquare(x+1, y-1) != null && board.getSquare(x+1, y-1).getPiece() != null &&\n board.getSquare(x+1, y-1).getPiece().getPlayer() != this.getPlayer() ) {\n board.getSquare(x+1, y-1).drawOutline();\n }\n }\n \n if(y+1 < SIZE) {\n if (board.getSquare(x+1, y+1) != null && board.getSquare(x+1, y+1).getPiece() != null &&\n board.getSquare(x+1, y+1).getPiece().getPlayer() != this.getPlayer()) {\n board.getSquare(x+1, y+1).drawOutline();\n }\n }\n \n //En passant\n if (y - 1 > 0) {\n if (board.getSquare(x, y-1).getPiece() != null &&board.getSquare(x, y-1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y-1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x+1, y-1).drawOutline();\n board.getSquare(x+1, y-1).setEnPassent(true);\n }\n }\n \n if (y + 1 < SIZE) {\n if (board.getSquare(x, y+1).getPiece() != null && board.getSquare(x, y+1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y+1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x+1, y+1).drawOutline();\n board.getSquare(x+1, y+1).setEnPassent(true);\n }\n }\n }\n }", "public void play(int direction)\r\n {\r\n int temp = 0; \r\n boolean moved = false;\r\n if (direction == LEFT_INPUT ) {\r\n for (int q = 0;q < 4; q++) { \r\n for (int i = 0; i < grid.length;i++){ \r\n if (grid[i][q] > 0 && q != 0){ \r\n for (int sum = q - 1; sum >= 0; sum--) {\r\n if (sum >= 0 && grid[i][sum] == grid[i][q]) {\r\n gui.clearSlot(i, q);\r\n currentScore = (long) Math.pow(2, grid[i][q]) + currentScore;\r\n gui.setScore(currentScore);\r\n moved = true;\r\n gui.setNewSlotBySlotIndex(i, sum, ++grid[i][q]);\r\n if (grid[i][q] == winningLevel+1){ highS(high); gui.showGameWon();}\r\n temp = grid[i][q];\r\n grid[i][q] = 0;\r\n grid[i][sum] = temp;\r\n break;\r\n } else if (sum >= 0 && grid[i][sum] != 0){\r\n break;\r\n }}\r\n for (int r = 0; grid[i][q] > 0 && r < q; r++){\r\n if (grid[i][r] == 0) {\r\n gui.clearSlot(i,q);\r\n gui.setNewSlotBySlotIndex(i,r,grid[i][q]);\r\n temp = grid[i][q];\r\n grid[i][q] = 0; \r\n grid[i][r] = temp;\r\n moved = true;\r\n break;\r\n }}}}} \r\n \r\n } else if (direction == DOWN_INPUT) {\r\n \r\n for (int i = grid.length - 1; i >= 0; i--) {\r\n for (int q = 0; q < grid[i].length; q++) {\r\n if (grid[i][q] > 0) {\r\n for (int sum = i + 1; sum <= 3; sum++) {\r\n if (sum >= 0 && grid[sum][q] == grid[i][q]) {\r\n gui.clearSlot(i, q);\r\n currentScore = (long) Math.pow(2, grid[i][q]) + currentScore;\r\n gui.setScore(currentScore);\r\n moved = true;\r\n gui.setNewSlotBySlotIndex(sum, q, ++grid[i][q]);\r\n if (grid[i][q] == winningLevel+1) {highS(high); gui.showGameWon();}\r\n temp = grid[i][q];\r\n grid[i][q] = 0;\r\n grid[sum][q] = temp;\r\n break;\r\n } else if (sum >= 0 && grid[sum][q] != 0)\r\n break;\r\n }\r\n for (int r = 3; grid[i][q] > 0 && r > i; r--)\r\n if (grid[r][q] == 0) {\r\n gui.clearSlot(i, q);\r\n gui.setNewSlotBySlotIndex(r, q, grid[i][q]);\r\n temp = grid[i][q];\r\n moved = true;\r\n grid[i][q] = 0;\r\n grid[r][q] = temp;\r\n break;\r\n }}}} \r\n \r\n } else if (direction == RIGHT_INPUT){\r\n \r\n for (int q = 3; q >= 0; q--) {\r\n for (int i = 0; i < grid.length; i++) {\r\n if (grid[i][q] > 0) {\r\n for (int sum = q + 1; sum <= 3; sum++) {\r\n if (sum >= 0 && grid[i][sum] == grid[i][q]) {\r\n gui.clearSlot(i, q);\r\n currentScore = (long) Math.pow(2, grid[i][q]) + currentScore;\r\n gui.setScore(currentScore);\r\n moved = true;\r\n gui.setNewSlotBySlotIndex(i, sum, ++grid[i][q]);\r\n if (grid[i][q] == winningLevel+1) {highS(high); gui.showGameWon();}\r\n temp = grid[i][q];\r\n grid[i][q] = 0;\r\n grid[i][sum] = temp;\r\n break;\r\n } else if (sum >= 0 && grid[i][sum] != 0)\r\n break;\r\n }\r\n for (int r = 3; grid[i][q] > 0 && r > q; r--)\r\n if (grid[i][r] == 0) {\r\n gui.clearSlot(i, q);\r\n gui.setNewSlotBySlotIndex(i, r, grid[i][q]);\r\n temp = grid[i][q];\r\n moved = true;\r\n grid[i][q] = 0;\r\n grid[i][r] = temp;\r\n break;\r\n }}}} \r\n \r\n } else if (direction == UP_INPUT) {\r\n \r\n for (int i = 0; i < grid.length; i++) {\r\n for (int q = 0; q < grid[i].length; q++) {\r\n if (grid[i][q] > 0) {\r\n for (int sum = i - 1; sum >= 0; sum--) {\r\n if (sum >= 0 && grid[sum][q] == grid[i][q]) {\r\n gui.clearSlot(i, q);\r\n currentScore = (long) Math.pow(2, grid[i][q]) + currentScore;\r\n gui.setScore(currentScore);\r\n moved = true;\r\n gui.setNewSlotBySlotIndex(sum, q, ++grid[i][q]);\r\n if (grid[i][q] == winningLevel+1) {highS(high); gui.showGameWon();}\r\n temp = grid[i][q];\r\n grid[i][q] = 0;\r\n grid[sum][q] = temp;\r\n break;\r\n } else if (sum >= 0 && grid[sum][q] != 0)\r\n break;\r\n }\r\n for (int r = 0; grid[i][q] > 0 && r < i; r++)\r\n if (grid[r][q] == 0) {\r\n gui.clearSlot(i, q);\r\n gui.setNewSlotBySlotIndex(r, q, grid[i][q]);\r\n temp = grid[i][q];\r\n moved = true;\r\n grid[i][q] = 0;\r\n grid[r][q] = temp;\r\n break;\r\n }}}} \r\n } else if (direction == S_INPUT) {\r\n int save = gui.saveGame();\r\n if (save == 0) {\r\n try {\r\n BufferedWriter out = new BufferedWriter(new FileWriter(\"load.txt\"));\r\n out.write(\"1\");\r\n out.newLine();\r\n for (int i = 0; i < grid.length; i++){\r\n for (int q = 0; q < grid[i].length; q++){\r\n out.write(\"\"+grid[i][q]);\r\n out.newLine();\r\n }}\r\n if (high == currentScore) highS(high);\r\n out.write(\"\"+currentScore);\r\n out.close();\r\n } catch (IOException iox) {\r\n System.out.println(\"Problem with files\" );\r\n }}}\r\n else if (direction == R_INPUT) {\r\n try {\r\n BufferedWriter out = new BufferedWriter(new FileWriter(\"load.txt\"));\r\n out.write(\"0\");\r\n out.newLine();\r\n for (int i = 0; i < grid.length; i++){\r\n for (int q = 0; q < grid[i].length; q++){\r\n out.write(\"0\");\r\n out.newLine();\r\n }}\r\n out.write(\"0\");\r\n out.close();\r\n gui.restSave();\r\n } catch (IOException iox) {\r\n System.out.println(\"Problem with files\" );\r\n }}\r\n else if (direction == H_INPUT) {\r\n gui.highScore(high,currentScore);\r\n }\r\n else if (direction == K_INPUT){\r\n gui.clearSlot(3, 3);\r\n gui.clearSlot(3, 2);\r\n grid[3][3] = 10;\r\n grid[3][2] = 10;\r\n gui.setNewSlotBySlotIndex(3, 3, grid[3][3]);\r\n gui.setNewSlotBySlotIndex(3, 2, grid[3][2]);\r\n }\r\n \r\n int counter = 0;\r\n boolean check = false;\r\n if (moved == false) {\r\n for (int i = 0;i<grid.length;i++){\r\n for(int q =0; q<grid[i].length;q++){\r\n if (i != 0) if (grid[i][q] == grid[i-1][q]) {check = true; break;} // Up\r\n if (q != 3) if (grid[i][q]==grid[i][q+1]){check = true; break;} // Right\r\n if (grid[i][q]>0) counter = counter + 1;\r\n }}\r\n for (int i = 3;i>=0;i--){\r\n for(int q =3; q>=0;q--){\r\n if (i != 0) if (grid[i][q] == grid[i-1][q]){check = true; break;} // Down\r\n if (q != 3) if (grid[i][q]==grid[i][q+1]) {check = true; break;} // Left\r\n if (grid[i][q]>0) counter = counter + 1;\r\n }}}\r\n if (counter == 32) {\r\n highS(high);\r\n gui.showGameOver();\r\n }\r\n \r\n newSlot(moved,check);\r\n // TO DO: implement the action to be taken after an arrow key of the\r\n // specified direction is pressed.\r\n }", "public void applyConvertedMove(String move) {\n\n\t\tString[] moveParts = move.split(\";\");\n\n\t\tint fromRow = Integer.parseInt(moveParts[0].charAt(0) + \"\");\n\t\tint fromCol = Integer.parseInt(moveParts[0].charAt(1) + \"\");\n\n\t\tint toRow = Integer.parseInt(moveParts[1].charAt(0) + \"\");\n\t\tint toCol = Integer.parseInt(moveParts[1].charAt(1) + \"\");\n\n\t\tint piece = board[fromRow][fromCol];//Integer.parseInt(moveParts[2]);\n\t\tint pieceType = Math.abs(board[fromRow][fromCol]);\n\t\tint team = Math.round(Math.signum(board[fromRow][fromCol]));\n\n\t\tboolean doResetEnpassant = true;\n\n\t\tif (pieceType == 1) { //If this is a pawn\n\t\t\tif (Math.abs(board[toRow][toCol]) == 7) { //If it is moving onto an enpassant stored tile\n\t\t\t\tboard[toRow + board[toRow][toCol]/7][toCol] = 0; //Kill the pawn that produced the enpassant tile\n\t\t\t} else if (Math.abs(fromRow - toRow) == 2) { //If it just did the double move thing\n\t\t\t\t//Reset the current enpassant tile\n\t\t\t\tresetEnpassant(team);\n\t\t\t\tdoResetEnpassant = false;\n\n\t\t\t\t//Set an empassant tile\n\t\t\t\tboard[(toRow + fromRow)/2][toCol] = 7 * team;\n\t\t\t\tenpassantCol = toCol;\n\t\t\t}\n\t\t} else if (pieceType == 6) { //If this is a king\n\t\t\tif (fromCol == 4) {\n\t\t\t\tif (doResetEnpassant) resetEnpassant(team);\n\t\t\t\tif (toCol == 7) { //Kingside Castle\n\t\t\t\t\tboard[toRow][6] = piece;\n\t\t\t\t\tboard[toRow][5] = board[toRow][7];\n\t\t\t\t\tboard[toRow][7] = 0;\n\t\t\t\t\tboard[toRow][4] = 0;\n\t\t\t\t\treturn;\n\t\t\t\t} else if (toCol == 0) { //Queenside Castle\n\t\t\t\t\tboard[toRow][2] = piece;\n\t\t\t\t\tboard[toRow][3] = board[toRow][0];\n\t\t\t\t\tboard[toRow][0] = 0;\n\t\t\t\t\tboard[toRow][4] = 0;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (doResetEnpassant) resetEnpassant(team);\n\t\tboard[fromRow][fromCol] = 0;\n\t\tif (moveParts.length > 2 && pieceType == 1 && (team == 1 ? toRow == 7 : team == -1 ? toRow == 0 : false)) {\n\t\t\tpiece = Integer.parseInt(moveParts[2]);\n\t\t}\n\t\tboard[toRow][toCol] = piece;\n\t}", "private boolean queenMovement(int xPosition, int yPosition){\r\n\t\tif (isMovingStraight(xPosition, yPosition) ||\r\n\t\t\t\tisMovingDiagonal(xPosition, yPosition))\r\n\t\t\t\treturn true;\r\n\t\treturn false;\r\n\t}", "public Queen(boolean color) {\n\n this.setColor(color);\n }", "public Queen(String color) {\r\n super(color);\r\n type = \"queen\";\r\n }", "void doMakeMove(CheckersMove move) {\n\n boardData.makeMove(move, false);\n\n /* If the move was a jump, it's possible that the player has another\n jump. Check for legal jumps starting from the square that the player\n just moved to. If there are any, the player must jump. The same\n player continues moving. */\n \n if (move.isJump()) {\n legalMoves = boardData.getLegalJumpsFrom(currentPlayer, move.toRow, move.toCol);\n if (legalMoves != null) {\n if (currentPlayer == CheckersData.RED) {\n console(\"RED: You must continue jumping.\");\n } else {\n console(\"BLACK: You must continue jumping.\");\n }\n selectedRow = move.toRow; // Since only one piece can be moved, select it.\n selectedCol = move.toCol;\n refreshBoard();\n return;\n }\n }\n\n /* The current player's turn is ended, so change to the other player.\n Get that player's legal moves. If the player has no legal moves,\n then the game ends. */\n if (currentPlayer == CheckersData.RED) {\n currentPlayer = CheckersData.BLACK;\n legalMoves = boardData.getLegalMoves(currentPlayer);\n if (legalMoves == null) {\n gameOver(\"BLACK has no moves. RED wins.\");\n } else if (legalMoves[0].isJump()) {\n console(\"BLACK: Make your move. You must jump.\");\n } else {\n console(\"BLACK: Make your move.\");\n }\n } else {\n currentPlayer = CheckersData.RED;\n legalMoves = boardData.getLegalMoves(currentPlayer);\n if (legalMoves == null) {\n gameOver(\"RED has no moves. BLACK wins.\");\n } else if (legalMoves[0].isJump()) {\n console(\"RED: Make your move. You must jump.\");\n } else {\n console(\"RED: Make your move.\");\n }\n }\n\n /* Set selectedRow = -1 to record that the player has not yet selected\n a piece to move. */\n selectedRow = -1;\n\n /* As a courtesy to the user, if all legal moves use the same piece, then\n select that piece automatically so the user won't have to click on it\n to select it. */\n if (legalMoves != null) {\n boolean sameStartSquare = true;\n for (int i = 1; i < legalMoves.length; i++) {\n if (legalMoves[i].fromRow != legalMoves[0].fromRow\n || legalMoves[i].fromCol != legalMoves[0].fromCol) {\n sameStartSquare = false;\n break;\n }\n }\n if (sameStartSquare) {\n selectedRow = legalMoves[0].fromRow;\n selectedCol = legalMoves[0].fromCol;\n }\n }\n\n /* Make sure the board is redrawn in its new state. */\n refreshBoard();\n\n }", "private static boolean placeQueen(char[][] board, int row, int col) {\n\n\t\tif (row > board.length || col > board[0].length) {\n\t\t\treturn false;\n\t\t} else {\n\t\t\tboard[row][col] = 'Q';\n\t\t\treturn true;\n\t\t}\n\t}", "public List<Move> validMoves(){\n List<Move> results = new LinkedList<>();\n int kingVal = turn == WHITE ? WHITE_KING : BLACK_KING;\n int kingX = 0, kingY = 0;\n List<Piece> checks = null;\n kingSearch:\n for (int y = 0; y < 8; y++){\n for (int x = 0; x < 8; x++){\n if (board[y][x] == kingVal){\n kingX = x;\n kingY = y;\n checks = inCheck(x,y);\n break kingSearch;\n }\n }\n }\n if (checks.size() > 1){ // must move king\n for (int x = -1; x < 2; x++){\n for (int y = -1; y < 2; y++){\n if (kingX+x >= 0 && kingX + x < 8 && kingY+y >= 0 && kingY+y < 8){\n int val = board[kingY+y][kingX+x];\n if (val == 0 || turn == WHITE && val > WHITE_KING || turn == BLACK && val < BLACK_PAWN){\n // may still be a move into check, must test at end\n results.add(new Move(kingVal, kingX, kingY, kingX+x, kingY+y, val, 0, this));\n }\n }\n }\n }\n } else { // could be in check TODO: split into case of single check and none, identify pin/capture lines\n int queen = turn == WHITE ? WHITE_QUEEN : BLACK_QUEEN;\n int knight = turn == WHITE ? WHITE_KNIGHT : BLACK_KNIGHT;\n int rook = turn == WHITE ? WHITE_ROOK : BLACK_ROOK;\n int bishop = turn == WHITE ? WHITE_BISHOP : BLACK_BISHOP;\n for (int y = 0; y < 8; y++) {\n for (int x = 0; x < 8; x++) {\n int piece = board[y][x];\n if (piece == (turn == WHITE ? WHITE_PAWN : BLACK_PAWN)) { // pawns\n // regular | 2 move\n if (board[y+turn][x] == 0){\n if (y+turn == 0 || y + turn == 7){ // promotion\n results.add(new Move(piece, x, y, x, y + turn, 0, queen, this));\n results.add(new Move(piece, x, y, x, y + turn, 0, knight, this));\n results.add(new Move(piece, x, y, x, y + turn, 0, rook, this));\n results.add(new Move(piece, x, y, x, y + turn, 0, bishop, this));\n }\n else {\n results.add(new Move(piece, x, y, x, y + turn, 0, 0, this));\n if ((y == (turn == WHITE ? 1 : 6)) && board[y + 2 * turn][x] == 0) { // initial 2 move\n results.add(new Move(piece, x, y, x, y + 2*turn, 0, 0, this));\n }\n }\n }\n // capture\n for (int dx = -1; dx <= 1; dx += 2){\n if (x + dx >= 0 && x + dx < 8) {\n int val = board[y+turn][x+dx];\n if (val > 0 && (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n if (y + turn == 0 || y + turn == 7){ // promotion\n results.add(new Move(piece, x, y, x+dx, y + turn, val, queen, this));\n results.add(new Move(piece, x, y, x+dx, y + turn, val, knight, this));\n results.add(new Move(piece, x, y, x+dx, y + turn, val, rook, this));\n results.add(new Move(piece, x, y, x+dx, y + turn, val, bishop, this));\n } else {\n results.add(new Move(piece, x, y, x+dx, y + turn, val, 0, this));\n }\n }\n if (val == 0 && y == (turn == WHITE ? 4 : 3) && x+dx == enPassant){ // en passant\n results.add(new Move(piece, x, y, x+dx, y + turn, 0, 0, this));\n }\n }\n }\n\n } else if (piece == knight) { // knights TODO: lookup table\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -2; dy <= 2; dy += 4){\n if (x+dx >= 0 && x + dx < 8 && y + dy >= 0 && y + dy < 8){\n int val = board[y+dy][x+dx];\n if (val == 0 || (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n results.add(new Move(piece,x,y,x+dx,y+dy,val,0,this));\n }\n }\n if (x+dy >= 0 && x + dy < 8 && y + dx >= 0 && y + dx < 8){\n int val = board[y+dx][x+dy];\n if (val == 0 || (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n results.add(new Move(piece,x,y,x+dy,y+dx,val,0,this));\n }\n }\n }\n }\n } else if (piece == bishop) { // bishops\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -1; dy <= 1; dy += 2){\n int i = 1;\n while (x + dx*i >= 0 && x + dx*i < 8 && y + dy*i >= 0 && y + dy*i < 8){\n int val = board[y+dy*i][x+dx*i];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n } else if (piece == rook) { // rooks\n for (int dx = -1; dx <= 1; dx+= 2){\n for (int ax = 0; ax < 2; ax++){\n int i = 1;\n while (ax==0 ? y+dx*i >= 0 && y+dx*i < 8 : x+dx*i >= 0 && x+dx*i < 8){\n int val = board[y+dx*i*(1-ax)][x+dx*i*ax];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n } else if (piece == (turn == WHITE ? WHITE_QUEEN : BLACK_QUEEN)) { // queens\n // Diagonals - same as bishops\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -1; dy <= 1; dy += 2){\n int i = 1;\n while (x + dx*i >= 0 && x + dx*i < 8 && y + dy*i >= 0 && y + dy*i < 8){\n int val = board[y+dy*i][x+dx*i];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n for (int dx = -1; dx <= 1; dx+= 2){\n for (int ax = 0; ax < 2; ax++){\n int i = 1;\n while (ax==0 ? y+dx*i >= 0 && y+dx*i < 8 : x+dx*i >= 0 && x+dx*i < 8){\n int val = board[y+dx*i*(1-ax)][x+dx*i*ax];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n } else if (piece == (turn == WHITE ? WHITE_KING : BLACK_KING)) { // king\n for (int dx = -1; dx < 2; dx++){\n for (int dy = -1; dy < 2; dy++){\n if ((dx != 0 || dy != 0) && x+dx >= 0 && x + dx < 8 && y + dy >= 0 && y + dy < 8){\n int val = board[y+dy][x+dx];\n if (val == 0 || (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n results.add(new Move(piece,x,y,x+dx,y+dy,val,0,this));\n }\n }\n }\n }\n }\n }\n }\n // castle\n if (checks.size() == 0){\n if (turn == WHITE && (castles & 0b11) != 0){//(castles[0] || castles[1])){\n board[0][4] = 0; // remove king to avoid check test collisions with extra king\n if ((castles & WHITE_SHORT) != 0 && board[0][5] == 0 && board[0][6] == 0 && inCheck(5,0).size() == 0){\n //if (castles[0] && board[0][5] == 0 && board[0][6] == 0 && inCheck(5,0).size() == 0){\n results.add(new Move(WHITE_KING, 4, 0, 6, 0, 0, 0, this));\n }\n if ((castles & WHITE_LONG) != 0 && board[0][1] == 0 && board[0][2] == 0 && board[0][3] == 0 &&\n inCheck(3,0).size() == 0){\n //if (castles[1] && board[0][1] == 0 && board[0][2] == 0 && board[0][3] == 0 && inCheck(3,0).size() == 0){\n results.add(new Move(WHITE_KING, 4, 0, 2, 0, 0, 0, this));\n }\n board[0][4] = WHITE_KING;\n }else if (turn == BLACK && (castles & 0b1100) != 0){//(castles[2] || castles[3])) {\n board[7][4] = 0; // remove king to avoid check test collisions with extra king\n //if (castles[2] && board[7][5] == 0 && board[7][6] == 0 && inCheck(5, 7).size() == 0) {\n if ((castles & BLACK_SHORT) != 0 && board[7][5] == 0 && board[7][6] == 0 && inCheck(5, 7).size() == 0) {\n results.add(new Move(BLACK_KING, 4, 7, 6, 7, 0, 0, this));\n }\n //if (castles[3] && board[7][1] == 0 && board[7][2] == 0 && board[7][3] == 0 && inCheck(3, 7).size() == 0) {\n if ((castles & BLACK_LONG) != 0 && board[7][1] == 0 && board[7][2] == 0 && board[7][3] == 0 &&\n inCheck(3, 7).size() == 0) {\n results.add(new Move(BLACK_KING, 4, 7, 2, 7, 0, 0, this));\n }\n board[7][4] = BLACK_KING;\n }\n }\n }\n List<Move> fullLegal = new LinkedList<>();\n for (Move m : results){\n makeMove(m);\n turn = -turn;\n if (m.piece == WHITE_KING || m.piece == BLACK_KING){\n if (inCheck(m.toX,m.toY).size() == 0){\n fullLegal.add(m);\n }\n }else if (inCheck(kingX,kingY).size() == 0){\n fullLegal.add(m);\n }\n turn = -turn;\n undoMove(m);\n }\n Collections.sort(fullLegal, (o1, o2) -> o2.score - o1.score); // greatest score treated as least so appears first\n return fullLegal;\n }", "public static void solve(char[][] board) {\n\t\t\n\t\tint height = board.length;\n\t\tif(height==0){\n\t\t\treturn;\n\t\t}\n\t\tint width = board[0].length;\n\t\t\n\t\tLinkedList<int[]> queue = new LinkedList<int[]>();\n\t\t//top edge & bottom edge\n\t\tfor (int i = 0; i < width; i++) {\n\t\t\tif(board[0][i]=='O'){\n\t\t\t\tint[] coord = {0, i};\n\t\t\t\tqueue.add(coord);\n\t\t\t}\n\t\t\t\n\t\t\tif(board[height-1][i]=='O'){\n\t\t\t\tint[] coord = {height-1, i};\n\t\t\t\tqueue.add(coord);\n\t\t\t}\n\t\t}\n\t\t\n\t\t//left edge & right edge\n\t\tfor (int i = 0; i < height; i++) {\n\t\t\tif(board[i][0]=='O'){\n\t\t\t\tint[] coord = {i, 0};\n\t\t\t\tqueue.add(coord);\n\t\t\t}\n\t\t\t\n\t\t\tif(board[i][width-1]=='O'){\n\t\t\t\tint[] coord = {i, width-1};\n\t\t\t\tqueue.add(coord);\n\t\t\t}\n\t\t}\n\t\t\n\t\twhile(queue.size()>0){\n\t\t\tint[] coord = queue.removeLast();\n\t\t\tint row = coord[0];\n\t\t\tint column = coord[1];\n\t\t\tif(board[row][column]=='O'){\n\t\t\t\tboard[row][column]='.';\n\t\t\t}\n\t\t\t//check left cell.\n\t\t\tif(column-1>0 && board[row][column-1]=='O'){\n\t\t\t\tint[] newCoord = {row, column-1};\n\t\t\t\tqueue.add(newCoord);\n\t\t\t}\n\t\t\t\n\t\t\t//check right cell.\n\t\t\tif(column+1 < width-1&& board[row][column+1]=='O'){\n\t\t\t\tint[] newCoord = {row, column+1};\n\t\t\t\tqueue.add(newCoord);\n\t\t\t}\n\t\t\t\n\t\t\t//check upper cell.\n\t\t\tif(row-1>0 && board[row-1][column]=='O'){\n\t\t\t\tint[] newCoord = {row-1, column};\n\t\t\t\tqueue.add(newCoord);\n\t\t\t}\n\t\t\t\n\t\t\t//check lower cell.\n\t\t\tif(row+1<height-1 && board[row+1][column]=='O'){\n\t\t\t\tint[] newCoord = {row+1, column};\n\t\t\t\tqueue.add(newCoord);\n\t\t\t}\n\t\t}\n\t\t\n\t\t//convert \".\" to \"O\" and \"O\" to \"X\".\n\t\tfor (int i = 0; i < height; i++) {\n\t\t\tfor (int j = 0; j < width; j++) {\n\t\t\t\tif(board[i][j]=='.'){\n\t\t\t\t\tboard[i][j] = 'O';\n\t\t\t\t}else if(board[i][j]=='O'){\n\t\t\t\t\tboard[i][j] = 'X';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "@Test\n void RookMoveToFriendlyOccupied() {\n Board board = new Board(8, 8);\n Piece rook1 = new Rook(board, 4, 3, 1);\n Piece rook2 = new Rook(board, 4, 6, 1);\n\n board.getBoard()[4][3] = rook1;\n board.getBoard()[4][6] = rook2;\n\n board.movePiece(rook1, 4, 6);\n\n Assertions.assertEquals(rook1, board.getBoard()[4][3]);\n Assertions.assertEquals(rook2, board.getBoard()[4][6]);\n }", "public void initializeBoard() {\n\n\t\t/*\n\t\t * How the array coordinates align with the actual chess board\n\t\t * (row,col) \n\t\t * (7,0) ... ... ... \n\t\t * (7,7) ... ... ... \n\t\t * ... ... ... \n\t\t * (2,0) ...\n\t\t * (1,0) ... \n\t\t * (0,0) ... ... ... (0,7)\n\t\t */\n\n\t\tboolean hasMoved = false;\n\t\tboolean white = true;\n\t\tboolean black = false;\n\n\t\t// Set white piece row\n\t\tboard[0][0] = new Piece('r', white, hasMoved, 0, 0, PieceArray.A_rookId);\n\t\tboard[0][1] = new Piece('n', white, hasMoved, 0, 1, PieceArray.B_knightId);\n\t\tboard[0][2] = new Piece('b', white, hasMoved, 0, 2, PieceArray.C_bishopId);\n\t\tboard[0][3] = new Piece('q', white, hasMoved, 0, 3, PieceArray.D_queenId);\n\t\tboard[0][4] = new Piece('k', white, hasMoved, 0, 4, PieceArray.E_kingId);\n\t\tboard[0][5] = new Piece('b', white, hasMoved, 0, 5, PieceArray.F_bishopId);\n\t\tboard[0][6] = new Piece('n', white, hasMoved, 0, 6, PieceArray.G_knightId);\n\t\tboard[0][7] = new Piece('r', white, hasMoved, 0, 7, PieceArray.H_rookId);\n\n\t\t// Set white pawns\n\t\tfor (int i = 0; i < 8; i++) {\n\t\t\tboard[1][i] = new Piece('p', white, hasMoved, 1, i, i + 8);\n\t\t}\n\n\t\t// Set empty rows\n\t\tfor (int row = 2; row < 6; row++)\n\t\t\tfor (int col = 0; col < 8; col++)\n\t\t\t\tboard[row][col] = null;\n\n\t\t// Set black pawns\n\t\tfor (int i = 0; i < 8; i++) {\n\t\t\tboard[6][i] = new Piece('p', black, hasMoved, 6, i, i+8);\n\t\t}\n\n\t\t// Set black piece row\n\t\tboard[7][0] = new Piece('r', black, hasMoved, 7, 0, PieceArray.A_rookId);\n\t\tboard[7][1] = new Piece('n', black, hasMoved, 7, 1, PieceArray.B_knightId);\n\t\tboard[7][2] = new Piece('b', black, hasMoved, 7, 2, PieceArray.C_bishopId);\n\t\tboard[7][3] = new Piece('q', black, hasMoved, 7, 3, PieceArray.D_queenId);\n\t\tboard[7][4] = new Piece('k', black, hasMoved, 7, 4, PieceArray.E_kingId);\n\t\tboard[7][5] = new Piece('b', black, hasMoved, 7, 5, PieceArray.F_bishopId);\n\t\tboard[7][6] = new Piece('n', black, hasMoved, 7, 6, PieceArray.G_knightId);\n\t\tboard[7][7] = new Piece('r', black, hasMoved, 7, 7, PieceArray.H_rookId);\n\t}", "public static boolean moveking() //returns false if valid move is there\n{ System.out.println(\"IN FUNCTION MOVE KING.....\");\n flag=0;\n int kx,ky;\n if(q==2)\n {\n kx=p2.ka.kbx; //WHITE KING....\n ky=p2.ka.kby;\n } \nelse\n {\n kx=p1.ka.kax; //BLACK KING....\n\tky=p1.ka.kay;\n }\n//CHECKS WHETHER KING CAN MOVE TO THE 8 adjacent places...\n if(kx-1>=0)\n {\n move2(kx,ky,kx-1,ky);\n \n if(flag==1)\n {\n revert(kx,ky,kx-1,ky);\n return false;\n }\n }\n //r\n if(kx+1<=7)\n { move2(kx,ky,kx+1,ky);\n if(flag==1)\n {revert(kx,ky,kx+1,ky);\n return false;\n \n }\n }\n \n //u\n if(ky-1>=0)\n {\n move2(kx,ky,kx,ky-1);\n \n if(flag==1)\n {revert(kx,ky,kx,ky-1);\n return false;\n \n }\n }\n //d\n if(ky+1<=7)\n {\n move2(kx,ky,kx,ky+1);\n \n if(flag==1)\n { revert(kx,ky,kx,ky+1);\n return false;\n \n }\n }\n //lu\n if(kx-1>=0&&ky-1>=0)\n {\n move2(kx,ky,kx-1,ky-1);\n \n if(flag==1)\n {revert(kx,ky,kx-1,ky-1);\n return false;\n \n }\n }\n //ld\n if(kx-1>=0&&ky+1<=7)\n {\n move2(kx,ky,kx-1,ky+1);\n \n if(flag==1)\n {revert(kx,ky,kx-1,ky+1);\n return false;\n \n }\n }\n //ru\n if(kx+1<=7&&ky-1>=0)\n {\n move2(kx,ky,kx+1,ky-1);\n \n if(flag==1)\n {revert(kx,ky,kx+1,ky-1);\n return false;\n \n }\n }\n //rd\n if(kx+1<=7&&ky+1<=7)\n {\n move2(kx,ky,kx+1,ky+1);\n \n if(flag==1)\n {revert(kx,ky,kx+1,ky+1);\n return false;\n \n }\n }\n return true; \n }", "public void movePiece(Location a, Location b)\n {\n Square s1 = getSquare(a);\n Square s2 = getSquare(b);\n Piece p = s1.getPiece();\n if (p==null)\n return;\n int moveType = canMoveTo(p,b);\n boolean taking = getPiece(b)!=null;\n boolean fiftyMoveBreak = getPiece(b)!=null||p.getType()==Type.PAWN;\n s2.setPiece(s1.removePiece());\n p.setHasMoved(true);\n if (p.getType()==Type.PAWN)\n {\n if (mainBoard&&((p.white()&&getLocation(p).getRow()==0)\n || !p.white()&&getLocation(p).getRow()==7))\n promotePawn(p);\n else if (moveType==EN_PASSANT)\n {\n int row = a.getRow();\n int col = b.getCol();\n removePiece(new Location(row,col));\n taking = true;\n }\n }\n else if (moveType==KINGSIDE_CASTLING||moveType==QUEENSIDE_CASTLING)\n {\n Location rookLoc;\n Location rookDest;\n if (moveType==KINGSIDE_CASTLING)\n {\n rookLoc = b.farther(Direction.EAST);\n rookDest = b.farther(Direction.WEST);\n }\n else\n {\n rookLoc = new Location(b.getRow(),b.getCol()-2);\n rookDest = b.farther(Direction.EAST);\n }\n //movePiece(getLocation(rook),rookDest);\n getSquare(rookDest).setPiece(removePiece(rookLoc)); //moves the rook\n }\n if (mainBoard)\n {\n turn++;\n if (fiftyMoveBreak)\n fiftyMove= 0;\n else fiftyMove++;\n }\n for (Piece piece: getPieces())\n piece.setHasJustMoved(false);\n p.setHasJustMoved(true);\n if (mainBoard)\n {\n positions.add(toString());\n \n //this is all for the notation on the side\n notateMove(p,b,moveType,taking);\n /*JTable not = frame.getNotation();\n DefaultTableModel d = (DefaultTableModel)not.getModel();\n String notation;\n PieceColor color = p.getColor();\n if (color==PieceColor.WHITE)\n notation = turn/2+1+\". \"; //the turn number first, on the left\n else notation = \"\";\n if (moveType==QUEENSIDE_CASTLING)\n notation += \"0-0-0\";\n else if (moveType==KINGSIDE_CASTLING)\n notation += \"0-0\";\n else //normal move\n {\n if (p.getType()!=Type.PAWN)\n notation+=p.getType().toNotation(); //the type of piece (K,N,R,etc)\n if (taking)\n notation+=\"x\"; //this is if the move involves taking\n notation+=Location.LocToNot(b);\n }\n if (checkmate(colorGoing())) //notates # for checkmate\n notation+=\"#\";\n else if (inCheck(colorGoing())) //notates + for check\n notation+=\"+\";\n \n if (color==PieceColor.WHITE)\n d.addRow(new Object[]{notation,\"\"});\n else \n d.setValueAt(notation, (turn-1)/2, 1);*/\n }\n }", "@Override\n public boolean lowCh(String Place,int x1, int y1, int x2,int y2, Board board)\n {\n switch(Place.toLowerCase())\n { \n //experiment to check to see if there is a piece in the way\n case \"uright\": \n for(; x1<=x2 && y1<=y2; x1++,y1++)\n {\n if (board.getSquare(x1,y1).getPiece()==null)\n {\n if (x1==x2-1 && y1==y2-1)\n {\n return true;\n }\n }else{\n return false;\n }\n }\n case \"uleft\":\n for(; x1>=x2 && y1<=y2; x1--,y1++)\n {\n if (board.getSquare(x1,y1).getPiece()==null)\n {\n if (x1==x2+1 && y1==y2-1)\n {\n return true;\n }\n }else{\n return false;\n }\n }\n case \"dright\":\n for(; x1<=x2 && y1>=y2; x1++,y1--)\n {\n if (board.getSquare(x1,y1).getPiece()==null)\n {\n if (x1==x2-1 && y1==y2+1)\n {\n return true;\n }\n }else{\n return false;\n }\n }\n case \"dleft\":\n for(; x1>=x2 && y1>=y2; x1--,y1--)\n {\n if (board.getSquare(x1,y1).getPiece()==null)\n {\n if (x1==x2+1 && y1==y2+2)\n {\n return true;\n }\n }else{ \n return false;\n }\n } \n default:\n return false;\n }\n }", "public static void makeBoardChess() {\r\n \r\n white = new AllPiece(\"White\");\r\n black = new AllPiece(\"Black\");\r\n \r\n }", "public Move movePiece(int turn) {\n\t\tboolean error = false;\n\t\tString moveInput = null;\n\t\tString origin = null;\n\t\tboolean isCorrectTurn = false;\n\t\t@SuppressWarnings(\"resource\")\n\t\tScanner keyboard = new Scanner(System.in);\n\n\t\tdo {\n\t\t\t\n\t\t\ttry {\n\t\t\t\tdo {\n\t\t\t\t\tSystem.out.println(\"Which piece would you like to move?\");\n\t\t\t\t\torigin = keyboard.next();\n\n\t\t\t\t\tif(validateInput(origin)) {\n\t\t\t\t\t\tSystem.out.println(\"Error in input, please try again\");\n\t\t\t\t\t\terror = true; \n\t\t\t\t\t} else {\n\t\t\t\t\t\n\t\t\t\t\t\terror = false;\n\t\t\t\t\t}\n\n\t\t\t\t}while(error);\n\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tString xOrigin = origin.substring(0, 1);\n\t\t\t\tint yOrigin = Integer.parseInt(origin.substring(1,2));\n\t\t\t\tint convertedXOrigin = convertXPosition(xOrigin);\n\t\t\t\tyOrigin -= 1;\n\t\t\t\t\nif((board.getBoard()[yOrigin][convertedXOrigin] == turn) || (board.getBoard()[yOrigin][convertedXOrigin] == (turn + 2))) {\n\t\t\t\tisCorrectTurn = true;\n\t\t\t\tChecker checker = validatePiece(convertedXOrigin, yOrigin);\t\n\t\t\t\tdo {\n\t\t\t\t\t\n\t\t\t\t\t\tSystem.out.println(\"Where would you like to move\");\n\t\t\t\t\t\t moveInput = keyboard.next();\n\t\t\t\t\t\tif(validateInput(moveInput)) {\n\t\t\t\t\t\t\tSystem.out.println(\"Error in Input, please try again\");\n\t\t\t\t\t\t\terror = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\terror = false;\n\t\t\t\t\t\t//\tSystem.out.println(\"No errors found with input move\");\n\t\t\t\t\t\t}\n\n\t\t\t\t} while(error);\n\t\t\t\t\n\t\t\t\tString xMove = moveInput.substring(0, 1);\n\t\t\t\tint yMove = Integer.parseInt(moveInput.substring(1,2));\n\t\t\t\tint convertedXMove = convertXPosition(xMove);\n\t\t\t\tyMove -= 1;\n\t\t\t\tboolean isMovingRight = isMovingRight(convertedXOrigin, yOrigin, convertedXMove, yMove);\n\t\t\t\tboolean isMovingDown = isMovingDown(convertedXOrigin, yOrigin, convertedXMove, yMove);\n\t\t\t\tMove move = null;\n\t\t\t\t\n\t\t\t\t//checks to see if the move itself is valid\n\t\t\t\ttry {\nif(isMoveValid(convertedXOrigin, yOrigin, convertedXMove, yMove, isMovingRight, isMovingDown)) {\n\t\t\t\tif(isSpaceTaken(convertedXMove, yMove)) {\n\t\t\t\t\t//System.out.println(\"Space is taken\");\n\t\t\t\t\tif(isPieceEnemy(convertedXMove, yMove, checker, turn)) {\n\t\t\t\t\t\tif(isJumpValid(convertedXOrigin, yOrigin, convertedXMove, yMove, isMovingRight, isMovingDown)) {\n\t\t\t\t\t\t\tif(isMovingRight) {\n\t\t\t\t\t\t\t\t//checks to see if the piece is moving up or down\n\t\t\t\t\t\t\t\tif(isMovingDown) {\n\t\t\t\t\t\t\t\t\t//means the piece is moving right and down\n\t\t\t\t\t\t\t\t\t move = new Move(convertedXOrigin, yOrigin, convertedXMove + 1, yMove + 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\t\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t//means the piece is moving right, but up\n\t\t\t\t\t\t\t\t\t move = new Move(convertedXOrigin, yOrigin, convertedXMove + 1, yMove - 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif(isMovingDown) {\n\t\t\t\t\t\t\t\t\t//means its moving left and down\n\t\t\t\t\t\t\t\t\tmove = new Move(convertedXOrigin, yOrigin, convertedXMove - 1, yMove + 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t//means it's moving left and up\n\t\t\t\t\t\t\t\t\tmove = new Move(convertedXOrigin, yOrigin, convertedXMove - 1, yMove - 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\t\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t//System.out.println(\"Space isn't taken\");\n\t\t\t\t\tmove = new Move(convertedXOrigin, yOrigin, convertedXMove, yMove);\n\t\t\t\t\tmodel.moves.add(move);\n\t\t\t\t\tif(canBeKing(checker, move)) {\n\t\t\t\t\t\tchecker = convertToKing(checker, move);\n\t\t\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\tprintBoard();\n\t\t\t\t\t\treturn move;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\t\tupdateBoard(move);\n\t\t\t\t\t\n\t\t\t\t\tprintBoard();\n\t\t\t\t\treturn move;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tSystem.out.println(\"Error in move\");\n\t\t\t\t//System.out.println(\"It's not your turn\");\n\t\t\t\tisCorrectTurn = false;\n\t\t\t\t}\n\t\t\t\t} catch (NullPointerException e) {\n\t\t\t\t\tSystem.out.println(\"NullPointerException - Error\");\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tif(canBeKing(checker, move)) {\n\t\t\t\tchecker = convertToKing(checker, move);\n\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\t\n\t\t\t\tprintBoard();\n\t\t\t\treturn move;\n}\n\n\n\n\t\t\t\t\n\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\tupdateBoard(move);\n\t\t\t\t\n\t\t\t\tprintBoard();\n\t\t\t\treturn move;\n\t\t\t\t}\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\tSystem.out.println(\"Error in Input. Please try again\");\n\t\t\t}\n\t\t\n\t\t}while(!isCorrectTurn);\n\n\t\tprintBoard();\n\t\treturn null;\n\t\t\n\t}", "public int canMoveTo(Piece p, Location dest)\n {\n if (p==null||dest==null||!dest.isValid())\n return ILLEGAL_MOVE;\n Location loc = getLocation(p);\n if (dest.equals(loc))\n return ILLEGAL_MOVE;\n int thisCol = loc.getCol();\n int thisRow = loc.getRow();\n int otherCol = dest.getCol();\n int otherRow = dest.getRow();\n int rowDiff = Math.abs(thisRow-otherRow);\n int colDiff = Math.abs(thisCol-otherCol);\n Piece other = getPiece(dest);\n if (other!=null&&other.sameColor(p))\n return ILLEGAL_MOVE;\n switch (p.getType())\n {\n case KING:\n if (rowDiff==0&&colDiff==2) //castling\n {\n if (p.hasMoved())\n return ILLEGAL_MOVE;\n Piece rook = null;\n Direction dir = null;\n if (thisCol > otherCol) //queenside\n {\n dir = Direction.WEST;\n rook = getPiece(new Location(thisRow,thisCol-4));\n }\n else //kingside\n {\n dir = Direction.EAST;\n rook = getPiece(new Location(thisRow,thisCol+3));\n }\n if (rook==null||rook.getType()!=Type.ROOK||!p.sameColor(rook)||rook.hasMoved())\n return ILLEGAL_MOVE;\n Location next = loc;\n for (int i=thisCol; i!=getLocation(rook).getCol(); i=next.getCol())\n {\n if ((!next.equals(loc)&&getPiece(next)!=null)||enemyCanAttack(p.getColor(),next))\n return ILLEGAL_MOVE;\n next = next.farther(dir);\n }\n if (thisCol > otherCol)\n return QUEENSIDE_CASTLING;\n else return KINGSIDE_CASTLING;\n }\n else //normal king move\n if (adjacent(loc,dest)\n && (other==null || !p.sameColor(other)))\n return KING_MOVE;\n else return ILLEGAL_MOVE;\n \n case PAWN:\n if (rowDiff>2||rowDiff<1||colDiff>1||(rowDiff==2&&colDiff>0)\n ||(p.white()&&otherRow>thisRow)||(!p.white()&&otherRow<thisRow))\n return ILLEGAL_MOVE;\n else if (rowDiff==2) //first move\n {\n if (p.hasMoved())\n return ILLEGAL_MOVE;\n Location temp = loc.closerTo(dest);\n if (getPiece(temp)==null&&other==null&&((p.white()&&thisRow==6)||(!p.white()&&thisRow==1)))\n return PAWN_FIRST_MOVE;\n else return ILLEGAL_MOVE;\n }\n else if (colDiff==1 && other!=null) //taking\n {\n if (p.sameColor(other))\n return ILLEGAL_MOVE;\n else return PAWN_CAPTURE;\n }\n else if (colDiff==1 && other==null) //en passant\n {\n int diff = otherCol-thisCol;\n Location otherLoc = new Location(thisRow,thisCol+diff);\n Piece otherPiece = getPiece(otherLoc);\n if (otherPiece!=null&&otherPiece.hasJustMoved()\n &&otherPiece.getType()==Type.PAWN&&!otherPiece.sameColor(p))\n return EN_PASSANT;\n else return ILLEGAL_MOVE;\n }\n else if (rowDiff==1) //normal move\n {\n if (other==null)\n return PAWN_MOVE;\n else return ILLEGAL_MOVE;\n }\n break;\n \n case ROOK:case QUEEN: case BISHOP:case KNIGHT:\n if (!canAttack(p,dest))\n return ILLEGAL_MOVE;\n else\n {\n switch (p.getType())\n {\n case ROOK:return ROOK_MOVE;\n case QUEEN:return QUEEN_MOVE;\n case BISHOP:return BISHOP_MOVE;\n case KNIGHT:return KNIGHT_MOVE;\n }\n }\n }\n return ILLEGAL_MOVE; //will never happen\n }", "@Test\n public void testRookSide() {\n // initialize the complete chess board\n ChessBoard chessBoard = init(\"CHESS\");\n\n assertEquals(north, chessBoard.getPiece(0, 0).getSide());\n assertEquals(north, chessBoard.getPiece(0, 7).getSide());\n assertEquals(south, chessBoard.getPiece(7, 0).getSide());\n assertEquals(south, chessBoard.getPiece(7, 7).getSide());\n }", "private static int rightScore(char piece, State state, int row, int col) {\n\t\tif(col != state.getGrid().length-1 && state.getGrid()[row][col+1] == piece) {\n\t\t\treturn NEXT_TO;\n\t\t}\n\t\telse {\n\t\t\treturn ZERO;\n\t\t}\n\t}", "public void playMove(int[] move, int side, BoardModel board) {\n\t\tboard.placeOnBoard(move, side);\n\t\t\n\t\t//we kunnen niet getOpponentSide gebruiken, omdat deze ook gebruikt wordt \n\t\t//voor de opponent. Daarom ff zo :)\n\t\tint opponent = 0;\n\t\tif(side == 0) opponent = 1;\n\t\t\n\t\t//nu gaan we alle shit omflippen...\n\t\tfor(int[] surround : surroundingCoordinates(move[0], move[1])) {\n\t\t\t//zo'n aanliggende positie moet van de tegenstander zijn\n\t\t\tif(board.getBoardValue(surround[0], surround[1]) == opponent){\n\t\t\t\t//nu moeten we gaan kijken of we verderop w�l onzelf tegenkomen!\n\t\t\t\t//wat is de relatieve waarde van de aanliggende positie ten opzichte van de geteste positie?\n\t\t\t\tint row_diff = surround[0] - move[0];\n\t\t\t\tint col_diff = surround[1] - move[1];\n\t\t\t\tflipMoves.clear();\n\t\t\t\tif(checkNext((move[0]+row_diff), (move[1]+col_diff), row_diff, col_diff, side, board)){\n\t\t\t\t\tfor(int[] flipMove : flipMoves){\n\t\t\t\t\t\tboard.placeOnBoard(flipMove, side);\n\t\t\t\t\t}\n\t\t\t\t\tflipMoves.clear();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "public List<Piece> inCheck(int kingX, int kingY){ // returns list of attacking pieces.\n // Also have to look for opponent king to avoid moving into check.\n // In this case only care whether or not a check occurs, not how many so breaks still ok\n // for regular check tests, want to know if 1 or 2 checks, cannot have multiple diagonal checks.\n List<Piece> attackers = new ArrayList<>();\n // knights\n int knight = turn == WHITE ? BLACK_KNIGHT : WHITE_KNIGHT;\n knightSearch:\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -2; dy <= 2; dy += 4){\n if (kingX + dx >= 0 && kingX + dx < 8 && kingY + dy >= 0 && kingY + dy < 8){\n if (board[kingY+dy][kingX+dx] == knight){\n attackers.add(new Piece(knight, kingX+dx, kingY+dy));\n break knightSearch; // can only be checked by 1 knight at a time\n }\n }\n if (kingX + dy >= 0 && kingX + dy < 8 && kingY + dx >= 0 && kingY + dx < 8){\n if (board[kingY+dx][kingX+dy] == knight){\n attackers.add(new Piece(knight, kingX+dy, kingY+dx));\n break knightSearch;\n }\n }\n }\n }\n // bishop/queen/pawn/king\n int pawn = turn == WHITE ? BLACK_PAWN : WHITE_PAWN;\n int bish = turn == WHITE ? BLACK_BISHOP : WHITE_BISHOP;\n int queen = turn == WHITE ? BLACK_QUEEN : WHITE_QUEEN;\n int king = turn == WHITE ? BLACK_KING : WHITE_KING;\n diagSearch:\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -1; dy <= 1; dy += 2){\n int i = 1;\n while (kingX + dx*i >= 0 && kingX + dx*i < 8 && kingY + dy*i >= 0 && kingY + dy*i < 8){\n int piece = board[kingY + dy*i][kingX + dx*i];\n if (piece != 0){\n if (piece == bish || piece == queen || (piece == pawn && i == 1 && dy == turn)\n || (piece == king && i == 1)){\n attackers.add(new Piece(piece, kingX+dx*i, kingY+dy*i));\n break diagSearch;\n }\n break;\n }\n i++;\n }\n }\n }\n // rook/queen/king\n int rook = turn == WHITE ? BLACK_ROOK : WHITE_ROOK;\n straightSearch:\n for (int dx = -1; dx <= 1; dx += 2){\n int i = 1;\n while (kingX + i*dx >= 0 && kingX + i*dx < 8){\n int piece = board[kingY][kingX + dx*i];\n if (piece != 0){\n if (piece == rook || piece == queen || (piece == king && i == 1)){\n attackers.add(new Piece(piece, kingX+dx*i, kingY));\n break straightSearch;\n }\n break;\n }\n i++;\n }\n i = 1;\n while (kingY + i*dx >= 0 && kingY + i*dx < 8){\n int piece = board[kingY+dx*i][kingX];\n if (piece != 0){\n if (piece == rook || piece == queen || (piece == king && i == 1)){\n attackers.add(new Piece(piece, kingX, kingY+dx*i));\n break straightSearch;\n }\n break;\n }\n i++;\n }\n }\n return attackers;\n }", "private void nextPiece() {\n if (_c == M && _r <= M) {\n _c = 1;\n _r++;\n } else if (_r > M) {\n _move = null;\n } else {\n _c++;\n }\n }", "protected void moveToDestination(){\n\t\tqueue.clear();\n\t\twhile (destination[0] < 0){\n\t\t\tqueue.add(\"MOVE S\");\n\t\t\tdestination[0] += 1;\n\t\t}\n\t\twhile (destination[0] > 0){\n\t\t\tqueue.add(\"MOVE N\");\n\t\t\tdestination[0] -= 1;\n\t\t}\n\t\twhile (destination[1] < 0){\n\t\t\tqueue.add(\"MOVE E\");\n\t\t\tdestination[1] += 1;\n\t\t}\n\t\twhile (destination[1] > 0){\n\t\t\tqueue.add(\"MOVE W\");\n\t\t\tdestination[1] -= 1;\n\t\t}\n\t\tdestination = null;\n\t}", "private void mediumMove(Board board) {\n\t}", "private boolean canEats(Point piece){\r\n\t// direction -1: red pieces +1: black pieces\r\n int dir = isRed(piece)? -1:+1;\r\n int dest = dir * 2; // eat move destination\r\n // compute movement points\r\n Point left = new Point(piece.getFirst() + dir, piece.getSecond() - 1);\r\n Point left2 = new Point(piece.getFirst()+ dest, piece.getSecond() - 2);\r\n Point right = new Point(piece.getFirst() + dir, piece.getSecond() + 1);\r\n Point right2 = new Point(piece.getFirst() + dest, piece.getSecond() + 2);\r\n // check left eat\r\n if(isValidPosition(left) && isValidPosition(left2)){\r\n if(isRed(piece) && isBlack(left) && isEmpty(left2)) return true;\r\n if(isBlack(piece) && isRed(left) && isEmpty(left2)) return true;\r\n }\r\n // check right eat\r\n if(isValidPosition(right) && isValidPosition(right2)){\r\n if(isRed(piece) && isBlack(right) && isEmpty(right2)) return true;\r\n if(isBlack(piece) && isRed(right) && isEmpty(right2)) return true;\r\n }\r\n // if is a queen\r\n if(isQueen(piece)){\r\n // compute queen move points (invert direction)\r\n Point leftQ = new Point(piece.getFirst() - dir, piece.getSecond() - 1);\r\n Point leftQ2 = new Point(piece.getFirst() - dest, piece.getSecond() - 2);\r\n Point rightQ = new Point(piece.getFirst() - dir, piece.getSecond() + 1);\r\n Point rightQ2 = new Point(piece.getFirst() - dest, piece.getSecond() + 2);\r\n // check left eat\r\n if(isValidPosition(leftQ) && isValidPosition(leftQ2)){\r\n if(isRed(piece) && isBlack(leftQ) && isEmpty(leftQ2)) return true;\r\n if(isBlack(piece) && isRed(leftQ) && isEmpty(leftQ2)) return true;\r\n }\r\n // check right eat\r\n if(isValidPosition(rightQ) && isValidPosition(rightQ2)){\r\n if(isRed(piece) && isBlack(rightQ) && isEmpty(rightQ2)) return true;\r\n if(isBlack(piece) && isRed(rightQ) && isEmpty(rightQ2)) return true;\r\n }\r\n }\r\n return false;\r\n }", "@Override\r\n\tpublic void placePiece(JumpInButton[][] square) {\r\n\t\tsquare[this.x][this.y].setBackground(Color.RED);\r\n\t}", "protected void move(Player player, Movement move) {\n if (board.board[move.oldP.x][move.oldP.y] != null) {\n board.board[move.newP.x][move.newP.y] = board.board[move.oldP.x][move.oldP.y];\n board.board[move.oldP.x][move.oldP.y] = null;\n\n if (player.colour == Colour.BLACK) {\n blackPlayer.move(move);\n whitePlayer.removePiece(move.newP);\n } else if (player.colour == Colour.WHITE) {\n whitePlayer.move(move);\n blackPlayer.removePiece(move.newP);\n }\n\n sharedBoard.update(whitePlayer.getOccupied(), blackPlayer.getOccupied());\n\n // Check for promotions...\n for (int x = 0; x < board.board.length; ++x)\n if (board.board[x][0] instanceof Pawn)\n board.board[x][0] = new Queen(Colour.BLACK);\n else if (board.board[x][7] instanceof Pawn)\n board.board[x][7] = new Queen(Colour.WHITE);\n }\n }", "public boolean isKingMove(Piece.PColor colorCheckedForKing) {\n if(colorCheckedForKing == PColor.red) {\n return end.getRow() == 7;\n } else {\n return end.getRow() == 0;\n }\n }", "public Queen(int initX, int initY, Color color, StandardBoard board) {\n\t\tsuper(initX, initY, color, board);\n\t\tthis.nameOfPiece = \"queen\";\n\t}", "private void capture(Square sq0, Square sq2) {\r\n Square between = sq0.between(sq2);\r\n map.put(between, EMPTY);\r\n board[between.col()][between.row()] = EMPTY;\r\n if (map.get(between) == KING) {\r\n _winner = BLACK;\r\n }\r\n }", "private boolean isSquareMovable(BoardSquareInfo target, int state, boolean isKing) {\n\t\tLog.d(LOG_TAG, String.format(\"Is square movable (recursive) square: %s, state: %s, isKing: %s\",target,state,isKing));\n\n\t\t// No need to check in opposite direction\n\t\tif (!isKing && state != activeState)\n\t\t\treturn false;\n\n\t\tif(ensureSquareMovable(target, state, isKing, /*backwards*/ true)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif(ensureSquareMovable(target, state, isKing, /*backwards*/ false)) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}", "private void HandleOnMoveStart(Board board, Piece turn){}", "private void updateMoveList(Move m) {\n \t//first check for castling move\n \tif(m.getSource().getName().equals(\"King\")) {\n \tint sx = m.getSource().getLocation().getX();\n \tint dx = m.getDest().getLocation().getX();\n \t\n \t//castle king side\n \tif(dx - sx == 2) {\n \t\tmoveList.add(\"0-0\");\n \t\treturn;\n \t}\n \t//castle queen side\n \telse if(sx - dx == 2) {\n \t\tmoveList.add(\"0-0-0\");\n \t\treturn;\n \t}\n \t}\n \t\n \t//now do normal checks for moves\n \t//if no piece, normal notation\n \tif(m.getDest().getName().equals(\"None\")) {\n \t\t\n \t\t//check for en passant\n \t\tif(m.getSource().getName().equals(\"Pawn\")) {\n \t\t\t\n \t\t\t//it's only en passant if the pawn moves diagonally to an empty square \n \t\t\tif(m.getSource().getLocation().getX() != m.getDest().getLocation().getX()) {\n \t\t\t\tmoveList.add(m.getSource().getLocation().getFile()+ \"x\" + m.getDest().getLocation().getNotation());\n \t\t\t\treturn;\n \t\t\t}\n \t\t}\n \t\t\n \t\tmoveList.add(m.getSource().getID() + m.getDest().getLocation().getNotation());\n \t}\n \t//add \"x\" for capturing\n \t//for pawn, it's a bit different\n \telse if(m.getSource().getName().equals(\"Pawn\")) {\n \t\tmoveList.add(m.getSource().getLocation().getFile()+ \"x\" + m.getDest().getLocation().getNotation());\n \t}\n \telse {\n \t\tmoveList.add(m.getSource().getID() + \"x\" + m.getDest().getLocation().getNotation());\n \t}\n }", "private boolean isNextMoveRochade(Move move)\r\n\t{\r\n\t\tif (!(move.from.piece instanceof King)) return false;\r\n\t\tint xDiffAbs = Math.abs(move.to.coordinate.x - move.from.coordinate.x); \r\n\t\treturn xDiffAbs == 2;\r\n\t}", "public void changeBoard(int columnnumber, int whoseTurn, Color color1, Color color2){ //changes the colour of the circles on the board\r\n \r\n if(whoseTurn==1){ \r\n if(erase>0){ //this if statement runs if a checker needs to be erased; (because AI was checking future game states)\r\n for(int i = 0; i<=5; i++){ //going from top to bottom to change the last entered checker\r\n if(arrayCircles[i][erase-1].getColor()==color1){\r\n arrayCircles[i][erase-1].setColor(Color.white); //removing the checker that was previously placed\r\n repaint();\r\n break;\r\n }\r\n }\r\n }\r\n else{\r\n for(int i = 5; i>=0; i--){\r\n if(arrayCircles[i][columnnumber-1].getColor()==Color.white){ //starting from row 5 (the bottom one) see if any of those within the column is null\r\n arrayCircles[i][columnnumber-1].setColor(color1); //if so, set that value to the colour of the player who inputted that columnnumber\r\n repaint(); //repainting the board so that it updates and is visible to viewers\r\n break; //break once the colour has been changed and a move has been made\r\n }\r\n }\r\n }\r\n }\r\n \r\n else if(whoseTurn==2){\r\n for(int i = 5; i>=0; i--){\r\n if(arrayCircles[i][columnnumber-1].getColor()==Color.white){ //if there is an open space, set its colour to the desired colour \r\n arrayCircles[i][columnnumber-1].setColor(color2);\r\n repaint();\r\n break;\r\n }\r\n }\r\n }\r\n \r\n else if(whoseTurn==3||whoseTurn==4){ //either the easyAI or the hardAI\r\n \r\n \r\n if(erase>0){ //this if statement erases the last placed coloured checker\r\n for(int i = 0; i<=5; i++){ //going from top to bottom to change the last entered checker to white\r\n if(arrayCircles[i][erase-1].getColor()==Color.magenta){\r\n arrayCircles[i][erase-1].setColor(Color.white); //sets it back to white\r\n repaint(); //repaints and breaks\r\n break;\r\n }\r\n }\r\n }\r\n else{\r\n for(int i = 5; i>=0; i--){ //setting the colour of the column to magenta (for the AI)\r\n if(arrayCircles[i][columnnumber-1].getColor()==Color.white){\r\n arrayCircles[i][columnnumber-1].setColor(color2);\r\n repaint();\r\n break;\r\n }\r\n }\r\n } \r\n }\r\n }", "public Action getMove(CritterInfo info) {\r\n if (info.getFront() == Neighbor.OTHER) {\r\n return Action.INFECT;\r\n } else if (info.getFront() == Neighbor.EMPTY){\r\n return Action.HOP;\r\n } else{\r\n return Action.RIGHT;\r\n }\r\n }", "public void makeMove() {\n\t\tif (CheckForVictory(this)) {\n\t\t\t// System.out.println(\"VICTORY\");\n\t\t\tInterface.goalReached = true;\n\t\t\tfor (int i = 0; i < tmpStrings.length; i++) {\n\t\t\t\tif (moveOrder[i] == 0)\n\t\t\t\t\ttmpStrings[i] = \"turn left\";\n\t\t\t\telse if (moveOrder[i] == 1)\n\t\t\t\t\ttmpStrings[i] = \"turn right\";\n\t\t\t\telse\n\t\t\t\t\ttmpStrings[i] = \"go forward\";\n\n\t\t\t\tInterface.info.setText(\"Generation: \" + Parallel.generationNo + 1 + \" and closest distance to goal: \" + 0);\n\t\t\t}\n\t\t} else {\n\t\t\tmoveOrder[this.movesMade] = moves.remove();\n\t\t\tswitch (moveOrder[this.movesMade]) {\n\t\t\tcase (0):\n\t\t\t\tthis.movesMade++;\n\t\t\t\tif (face == 0)\n\t\t\t\t\tface = 3;\n\t\t\t\telse\n\t\t\t\t\tface--;\n\t\t\t\tbreak;\n\t\t\tcase (1):\n\t\t\t\tthis.movesMade++;\n\t\t\t\tif (face == 3)\n\t\t\t\t\tface = 0;\n\t\t\t\telse\n\t\t\t\t\tface++;\n\t\t\t\tbreak;\n\t\t\tcase (2):\n\t\t\t\tthis.movesMade++;\n\t\t\t\tif (face == 0 && Y - 1 >= 0)\n\t\t\t\t\tY--;\n\t\t\t\telse if (face == 1 && X + 1 <= map[0].length - 1)\n\t\t\t\t\tX++;\n\t\t\t\telse if (face == 2 && Y + 1 <= map.length - 1)\n\t\t\t\t\tY++;\n\t\t\t\telse if (face == 3 && X - 1 >= 0)\n\t\t\t\t\tX--;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tSystem.out.println(\"Error making move :(\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}", "@Test\n\tpublic void moveToValidSpace() throws Exception {\n\t\tgame.board.movePiece(knightCorner1Black, 1, 2);\n\t\tgame.board.movePiece(knightCorner2White, 5, 6);\n\t\tgame.board.movePiece(knightSide1Black, 2, 2);\n\t\tgame.board.movePiece(knightSide2White, 4, 5);\n\t\tgame.board.movePiece(knightMiddleWhite, 5, 2);\n\t\tassertEquals(knightCorner1Black, game.board.getPiece(1, 2));\n\t\tassertEquals(knightCorner2White, game.board.getPiece(5, 6));\n\t\tassertEquals(knightSide1Black, game.board.getPiece(2, 2));\n\t\tassertEquals(knightSide2White, game.board.getPiece(4, 5));\n\t\tassertEquals(knightMiddleWhite, game.board.getPiece(5, 2));\n\t}", "public Action getMove(CritterInfo info) {\n\n turn++;\n\n if (info.getFront() == Neighbor.OTHER) {\n return Action.INFECT;\n } else if (info.getFront() == Neighbor.WALL || info.getRight() == Neighbor.WALL) {\n return Action.LEFT;\n } else if (info.getFront() == Neighbor.SAME) {\n return Action.RIGHT;\n } else {\n return Action.HOP;\n }\n }", "public void aiMove(int turn)\n\t{\n\t\tint row = 0;\n\t\tint col = 0;\n\t\tint choice = 0;\n\t\t/*\n\t\t * Picks a random move on the first turn\n\t\t */\n\t\tif (turn == 0 )\n\t\t{\n\t\t\twhile (true)\n\t\t\t{\n\t\t\t\trow = (int) (Math.random() * 3);\n\t\t\t\tcol = (int) (Math.random() * 3);\n\t\t\t\tchoice = (int) (Math.random() * (ai.size()-1));\n\t\t\t\tif (board[row][col] == 0) \n\t\t\t\t{\t\t// valid move (empty slot)\n\t\t\t\t\tboard[row][col] = ai.get(choice);\n\t\t\t\t\tdraw.drawMove(col, row,ai.get(choice));\n\t\t\t\t\tai.remove(choice);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t\t\n\t\t\t}\n\t\t}\n\t\t/*\n\t\t * Otherwise checks every number, and every square for a winning move\n\t\t */\n\t\telse\n\t\t{\n\t\t\tboolean madeMove = false;\n\t\t\twhile (true) \t\t\t\t\t\t\t\t\t\n\t\t\t{\n\t\t\t\tif (madeMove == true)\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tfor (int a = 0; a <ai.size(); a++)\n\t\t\t\t{\n\t\t\t \t\tfor (int x = 0; x < 3; x++)\t\t\t\t\t//loops through all squares and checks if free\n\t\t\t \t\t{\n\t\t\t \t\t\tfor ( int y = 0; y < 3; y++)\n\t\t\t \t\t\t{\n\t\t\t \t\t\t\tif (madeMove == false)\n\t\t\t \t\t\t\t{\n\t\t\t\t \t\t\t\tif( board[x][y] == 0)\n\t\t\t\t \t\t\t\t{\n\t\t\t\t \t\t\t\t\tif (((x == 0 && y == 0)\t\t\t\t\t//checks for first diagonal and then if it is the winning move\n\t\t\t\t \t\t\t\t\t\t|| (x == 1 && y == 1) \n\t\t\t\t \t\t\t\t\t\t|| (x == 2 && y == 2)))\n\t\t\t\t \t\t\t\t\t{\n\t\t\t\t \t\t\t\t\t\tif (Math.abs(board[0][0] + board[1][1] + board[2][2]) + ai.get(a) == 15)\n\t\t\t\t \t\t\t\t\t\t{\n\t\t\t\t \t\t\t\t\t\t\trow = x;\n\t\t\t\t \t\t\t\t\t\t\tcol = y;\n\t\t\t\t \t\t\t\t\t\t\tboard[x][y] = ai.get(a);\n\t\t\t\t \t\t\t\t\t\t\tmadeMove = true;\n\t\t\t\t \t\t\t\t\t\t\tdraw.drawMove(col, row, ai.get(a));\n\t\t\t\t \t\t\t\t\t\t\tai.remove(a);\n\t\t\t\t \t\t\t\t\t\t\tbreak;\n\t\t\t\t \t\t\t\t\t\t}\n\t\t\t\t \t\t\t\t\t}\n\t\t\t\t \t\t\t\t\tif (((x == 0 && y == 2) \t\t\t//checks second diagonal for winning move\n\t\t\t\t\t \t\t\t\t\t\t|| (x == 1 && y == 1) \n\t\t\t\t\t \t\t\t\t\t\t|| (x == 2 && y == 0)))\n\t\t\t\t\t \t\t\t\t{\n\t\t\t\t \t\t\t\t\t\tif (Math.abs(board[0][2] + board[1][1] + board[2][0]) + ai.get(a) == 15)\n\t\t\t\t \t\t\t\t\t\t{\n\t\t\t\t \t\t\t\t\t\t\trow = x;\n\t\t\t\t \t\t\t\t\t\t\tcol = y;\n\t\t\t\t \t\t\t\t\t\t\tboard[x][y] = ai.get(a);\n\t\t\t\t \t\t\t\t\t\t\tmadeMove = true;\n\t\t\t\t \t\t\t\t\t\t\tdraw.drawMove(col, row, ai.get(a));\n\t\t\t\t \t\t\t\t\t\t\tai.remove(a);\n\t\t\t\t \t\t\t\t\t\t\tbreak;\n\t\t\t\t \t\t\t\t\t\t}\n\t\t\t\t\t \t\t\t\t}\n\t\t\t\t \t\t\t\t\telse if ((Math.abs(board[x][0] + board[x][1] + board[x][2]) + ai.get(a) == 15))\t//checks for winning row\n\t\t\t\t \t\t\t\t\t{\n\t\t\t\t \t\t\t\t\t\trow = x;\n\t\t\t \t\t\t\t\t\t\tcol = y;\n\t\t\t \t\t\t\t\t\t\tboard[x][y] = ai.get(a);\n\t\t\t \t\t\t\t\t\t\tmadeMove = true;\n\t\t\t \t\t\t\t\t\t\tdraw.drawMove(col, row, ai.get(a));\n\t\t\t \t\t\t\t\t\t\tai.remove(a);\n\t\t\t \t\t\t\t\t\t\tbreak;\n\t\t\t\t \t\t\t\t\t}\n\t\t\t\t \t\t\t\t\telse if ((Math.abs(board[0][y] + board[1][y] + board[2][y]) + ai.get(a) == 15)) //checks for winning column\n\t\t\t\t \t\t\t\t\t{\n\t\t\t\t \t\t\t\t\t\trow = x;\n\t\t\t \t\t\t\t\t\t\tcol = y;\n\t\t\t \t\t\t\t\t\t\tboard[x][y] = ai.get(a);\n\t\t\t \t\t\t\t\t\t\tmadeMove = true;\n\t\t\t \t\t\t\t\t\t\tdraw.drawMove(col, row, ai.get(a));\n\t\t\t \t\t\t\t\t\t\tai.remove(a);\n\t\t\t \t\t\t\t\t\t\tbreak;\n\t\t\t\t \t\t\t\t\t}\n\t\t\t\t \t\t\t\t}\n\t\t\t \t\t\t\t}\n\t\t\t\t \t\t}\n\t\t\t\t \t}\n\t\t\t \t\tif (madeMove == false)\t\t\t\t\t\t//if a winning move can't be found, a random one is made\n\t \t\t\t\t{\n\t\t\t\t\t\tchoice = (int) (Math.random() * (ai.size()-1));\n\t \t\t\t\t\trow = (int) (Math.random() * 3);\n\t \t\t\t\t\tcol = (int) (Math.random() * 3);\n\t \t\t\t\t\tif (board[row][col] == 0) \n\t \t\t\t\t\t{\t\t\t// valid move (empty slot)\n\t \t\t\t\t\t\tboard[row][col] = ai.get(choice);\n\t \t\t\t\t\t\tdraw.drawMove(col, row, ai.get(choice));\n\t \t\t\t\t\t\tai.remove(choice);\n\t \t\t\t\t\t\tmadeMove = true;\n\t \t\t\t\t\t\tbreak;\n\t \t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t \t\telse\n\t\t\t \t\t{\n\t\t\t \t\t\tbreak;\n\t\t\t \t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "public boolean move(Piece piece, int moved_xgrid, int moved_ygrid, boolean check) {// check stores if it\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// needs to check\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// freezing and rabbits' moving backward\n\t\tif (moved_xgrid >= 0 && moved_xgrid <= 7 && moved_ygrid >= 0 && moved_ygrid <= 7) {//if it is in grid\n\t\t\tif (piece.possibleMoves(moved_xgrid, moved_ygrid,check)) {//check possible moves\n\t\t\t\tif (getPiece(moved_xgrid, moved_ygrid) == null) {\n\t\t\t\t\tif(checkMove(piece, check)) {\n\t\t\t\t\t// move\n\t\t\t\t\tpiece.setX(moved_xgrid);\n\t\t\t\t\tpiece.setY(moved_ygrid);\n\t\t\t\t\tchecktrap();\n\t\t\t\t\trepaint();\t\t\t\t\t\n\t\t\t\t\treturn true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmessage = \"It is freezed\";\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tmessage = \"There is piece on the place\";\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmessage = \"It is not next to the piece, or rabbit cannot move backward\";\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t} else {\n\t\t\tmessage = \"The selected square is outside the grid\";\n\t\t\treturn false;\n\t\t}\n\t}", "public static void changepieces(int row, int column, String piecevalue){\n\t\tString oppositepiece;\n\t\tif(piecevalue.equals(\"x\")){\n\t\t\toppositepiece=\"o\";\n\t\t}\n\t\telse if(piecevalue.equals(\"o\")){\n\t\t\toppositepiece=\"x\";\n\t\t}\n\t\telse{\n\t\t\toppositepiece=\"-\";\n\t\t}\n\t\t//R=right, L=left, T=top, B=bottom, and there are diagonals such as TL=top left.\n\t\tboolean foundR=false,foundL=false,foundT=false,foundB=false,foundTL=false,foundTR=false,foundBL=false,foundBR=false;\n\t\tint checkfurtherR=1,checkfurtherL=1,checkfurtherT=1,checkfurtherB=1,checkfurtherTL=1,checkfurtherTR=1,checkfurtherBL=1,checkfurtherBR=1;\n\t\twhile(board[row][column+checkfurtherR].equals(oppositepiece)){\n\t\t\tcheckfurtherR++;\n\t\t}\n\t\tif(board[row][column+checkfurtherR].equals(piecevalue)){\n\t\t\tfoundR=true;\n\t\t}\n\t\t//The board changes the board if a 'connection' has been found in the [right] direction. It makes the connection following the game rules.\n\t\tif(foundR==true){\n\t\tfor(int i=column;i<column+checkfurtherR;i++){\n\t\t\t\tboard[row][i]=(piecevalue);\n\t\t\t}\n\t\t}\n\t\twhile(board[row][column-checkfurtherL].equals(oppositepiece)){\n\t\t\tcheckfurtherL++;\n\t\t}\n\t\tif(board[row][column-checkfurtherL].equals(piecevalue)){\n\t\t\tfoundL=true;\n\t\t}\n\t\t//Again, if something is found in the [left] direction, this block of code will be initialized to change to board array (making that 'connection' on the board).\n\t\tif(foundL==true){\n\t\tfor(int i=column;i>column-checkfurtherL;i--){\n\t\t\t\tboard[row][i]=(piecevalue);\n\t\t\t}\n\t\t}\n\t\twhile(board[row+checkfurtherB][column].equals(oppositepiece)){\n\t\t\tcheckfurtherB++;\n\t\t}\n\t\tif(board[row+checkfurtherB][column].equals(piecevalue)){\n\t\t\tfoundB=true;\n\t\t}\n\t\tif(foundB==true){\n\t\tfor(int i=row;i<row+checkfurtherB;i++){\n\t\t\t\tboard[i][column]=(piecevalue);\n\t\t\t}\n\t\t}\n\t\twhile(board[row-checkfurtherT][column].equals(oppositepiece)){\n\t\t\tcheckfurtherT++;\n\t\t}\n\t\tif(board[row-checkfurtherT][column].equals(piecevalue)){\n\t\t\tfoundT=true;\n\t\t}\n\t\tif(foundT==true){\n\t\tfor(int i=row;i>row-checkfurtherT;i--){\n\t\t\t\tboard[i][column]=(piecevalue);\n\t\t\t}\n\t\t}\n\t\t//Diagonal directions are harder and different from the 4 basic directions\n\t\t//It must use dynamic board to 'mark' the coordinates that it must convert to make a proper 'connection'\n\t\twhile(board[row-checkfurtherTR][column+checkfurtherTR].equals(oppositepiece)){\n\t\t\t//each coordinate that is reached will be recorded on the dynamic board\n\t\t\tdynamicboard[row-checkfurtherTR][column+checkfurtherTR]=1;\n\t\t\tcheckfurtherTR++;\n\t\t}\n\t\tif(board[row-checkfurtherTR][column+checkfurtherTR].equals(piecevalue)){\n\t\t\tfoundTR=true;\n\t\t}\n\t\t//Now the board will be changed if an available move has been found\n\t\tif(foundTR==true){\n\t\t\tfor(int x=row;x>row-checkfurtherTR;x--){\n\t\t\t\tfor(int i=column;i<column+checkfurtherTR;i++){\n\t\t\t\t\t//without the use of the dynamic board, some units of the board that should not be converted, will be converted.\n\t\t\t\t\t//(hard to explain)Example, if coordinate places a piece on the Top right of an available move, the connection and change on the board will be performed but [down] and [right] directions will also be inconveniently converted \n\t\t\t\t\tif(dynamicboard[x][i]==1){\n\t\t\t\t\t\tboard[x][i]=(piecevalue);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//dynamicboard must be cleared each time for its next job in 'marking' units in the array to be converted.\n\t\tcleandynamicboard();\n\t\twhile(board[row-checkfurtherTL][column-checkfurtherTL].equals(oppositepiece)){\n\t\t\tdynamicboard[row-checkfurtherTL][column-checkfurtherTL]=1;\n\t\t\tcheckfurtherTL++;\n\t\t}\n\t\tif(board[row-checkfurtherTL][column-checkfurtherTL].equals(piecevalue)){\n\t\t\tfoundTL=true;\n\t\t}\n\t\tif(foundTL==true){\n\t\t\tfor(int x=row;x>row-checkfurtherTL;x--){\n\t\t\t\tfor(int i=column;i>column-checkfurtherTL;i--){\n\t\t\t\t\tif(dynamicboard[x][i]==1){\n\t\t\t\t\t\tboard[x][i]=(piecevalue);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcleandynamicboard();\n\t\twhile(board[row+checkfurtherBL][column-checkfurtherBL].equals(oppositepiece)){\n\t\t\tdynamicboard[row+checkfurtherBL][column-checkfurtherBL]=1;\n\t\t\tcheckfurtherBL++;\n\t\t}\n\t\tif(board[row+checkfurtherBL][column-checkfurtherBL].equals(piecevalue)){\n\t\t\tfoundBL=true;\n\t\t}\n\t\tif(foundBL==true){\n\t\t\tfor(int x=row;x<row+checkfurtherBL;x++){\n\t\t\t\tfor(int i=column;i>column-checkfurtherBL;i--){\n\t\t\t\t\tif(dynamicboard[x][i]==1){\n\t\t\t\t\t\tboard[x][i]=(piecevalue);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcleandynamicboard();\n\t\twhile(board[row+checkfurtherBR][column+checkfurtherBR].equals(oppositepiece)){\n\t\t\tdynamicboard[row+checkfurtherBR][column+checkfurtherBR]=1;\n\t\t\tcheckfurtherBR++;\n\t\t}\n\t\tif(board[row+checkfurtherBR][column+checkfurtherBR].equals(piecevalue)){\n\t\t\tfoundBR=true;\n\t\t}\n\t\tif(foundBR==true){\n\t\t\tfor(int x=row;x<row+checkfurtherBR;x++){\n\t\t\t\tfor(int i=column;i<column+checkfurtherBR;i++){\n\t\t\t\t\tif(dynamicboard[x][i]==1){\n\t\t\t\t\t\tboard[x][i]=(piecevalue);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "public void oneTurn(){\n Integer[] previousTurn = Arrays.copyOf(this.board, this.board.length);\n\n // itero su previousTurn per costruire il board successivo\n for (int i=0;i<previousTurn.length;i++){\n\n // mi salvo la situazione della casella sx, se i==0 prendo l'ultima\n int left = previousTurn[previousTurn.length-1];\n if (i!=0)\n left = previousTurn[i-1];\n\n // mi salvo la situazione della casella dx, se i==ultima prendo zero\n int right = previousTurn[0];\n if (i!=previousTurn.length-1)\n right = previousTurn[i+1];\n \n // se a sx e dx c'è 0, metto 0\n // caso fine sottopopolazione (010->000)\n if (left == 0 && right == 0){\n this.board[i] = 0;\n \n // se a sx e dx c'è 1, metto 1 se c'era 0 e viceversa\n // caso nascita (101->111) e fine sovrappopolazione (111->101)\n } else if (left == 1 && right == 1)\n if (this.board[i] == 1)\n this.board[i] = 0;\n else\n this.board[i] = 1;\n \n // tutte le altre casistiche, lascio invariata la situazione\n \n }\n\n this.turn += 1;\n }", "public void move(int side){\n\t\tPoint test_location = new Point(pieceOrigin);\n\t\ttest_location.x += side;\n\t\tif(!collides(test_location, currentPiece)){\n\t\t\tpieceOrigin.x += side;\n\t\t}\n\t\trepaint();\n\t}", "private static void GideonsMove() {\r\n\t\tPrint print = new Print();\r\n\t\tprint.board(game);\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Prints the entire gameBoard.\r\n\t\t\r\n\t\tboolean flag = true;\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//true = Gideon's move | false = user's move\r\n\t\t\r\n\t\tArrayList<Integer> moves = MoveGenerator.Gen(flag, gamePieces);\t\t\t\t\t\t\t//returns all the legal moves possible to make by the player.\r\n\t\tPrint.moves(moves);\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Prints all the moves returned by the Gen method.\r\n\t\t\r\n\t\t//System.out.println(\"\\n\\n Gideon will play......\" \r\n\t\t\t\t\t\t//+\"Feature coming soon, until then keep practicing\\n\");\r\n\t\t \r\n\t\tMiniMax minimax = new MiniMax(game, moves);\t\t\t\t\t\t\t\t\t\t\t\t//Declaring and initializing MiniMax object with parameters game and moves\r\n\r\n\t\tif(moves.size() < 6) {\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Will increment the MiniMax MAX_DEPTH size by 1 if the legal moves are less than 6\r\n\t\t\tminimax.incrementMAX_DEPTH();\r\n\t\t}\r\n\t\t\r\n\t\tlong start_time = System.nanoTime();\t\t\t\t\t\t\t\t\t\t\t\t\t//Time before starting MiniMax\r\n\t\t\r\n\t\tString gideonsMove = minimax.start();\t\t\t\t\t\t\t\t\t\t\t\t\t//Starting MiniMax\r\n\t\r\n\t\tdouble elapsed = System.nanoTime()-start_time;\t\t\t\t\t\t\t\t\t\t\t//Total time taken by MiniMax=Time after MiniMax is finished-Time before MiniMax was started\r\n\t elapsed=elapsed/1000000000;\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Converting to seconds\r\n\t \r\n\t\tSystem.out.print(\"\\n\\n Gideon's move: \"+\r\n\t\t\t\tGideonsMoveConvertor.convert(gideonsMove)+\"\\n\\n\");\t\t\t\t\t\t\t\t//Changing GideonsMove to A1B2 format\r\n\t\t\r\n\t\tUpdateBoard boardUpdater = new UpdateBoard();\r\n\t\t\r\n\t\tgame = boardUpdater.playMove(gideonsMove, game, gamePieces, flag, false, true);\t\t\t//Executing the legal move on the gameBoard\r\n\t\tgamePieces = game.getGamePiecesArray();\t\t\t\t\t\t\t\t\t\t\t\t\t//Getting the updated copy of the Game Pieces Array\r\n\t\tgame.updateGameBoard();\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Updating the String copy of the game board (required to print the updated gameBoard)\r\n\t\t\r\n\t\tSystem.out.println(\"Depth used for this iteration --> \"+minimax.getMAX_DEPTH());\t\t//Printing the MAX_DEPTH used by MiniMax to calculate the best move\r\n\t\tSystem.out.println(\"Time Taken for MiniMax --> \"+elapsed);\t\t\t\t\t\t\t\t//Printing time taken by MiniMax to calculate the best move\r\n\t\tSystem.out.println(\"\\n ========================\");\r\n\t\tplayersMove();\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Player's turn to make a move\r\n\t\t\r\n\t}" ]
[ "0.65978765", "0.6249001", "0.6123735", "0.6117235", "0.610422", "0.6065497", "0.60320723", "0.5910936", "0.58877826", "0.58682054", "0.5835846", "0.58123225", "0.5812245", "0.5748396", "0.57131845", "0.5705328", "0.56825095", "0.5636315", "0.5619606", "0.56016135", "0.5590641", "0.5589537", "0.55850524", "0.5584635", "0.5578552", "0.55622154", "0.55621225", "0.55374134", "0.5535453", "0.54903877", "0.5482741", "0.54745126", "0.54744625", "0.5468645", "0.5461046", "0.54608065", "0.54604185", "0.54411256", "0.54388356", "0.5437305", "0.5436059", "0.5428502", "0.54278946", "0.5418893", "0.5415572", "0.5415027", "0.5412301", "0.54037124", "0.54011905", "0.53901124", "0.5388022", "0.5382749", "0.5369394", "0.5339907", "0.5337907", "0.53297836", "0.5326224", "0.5322595", "0.5321193", "0.532023", "0.5314079", "0.529269", "0.5288022", "0.52833605", "0.52739763", "0.52732456", "0.5266002", "0.52654094", "0.5254012", "0.52425385", "0.52372736", "0.5234187", "0.5226415", "0.5224088", "0.5223153", "0.52200097", "0.5218887", "0.5218067", "0.5207452", "0.5202891", "0.51968396", "0.51935947", "0.51930094", "0.51917785", "0.51894987", "0.5188909", "0.5183096", "0.51806784", "0.5173014", "0.5172307", "0.51640016", "0.5162396", "0.51569504", "0.51548725", "0.5153372", "0.5151504", "0.5151361", "0.5146993", "0.5144222", "0.5143827" ]
0.6807194
0
Get the start position of the moved piece. Get pieces with the correct start positions. Each piece has different movement, so call the method that corresponds with the piece and returns the start position of the piece.
public static int[] getStartPosition(char piece, char color, int startFile, int startRank, int endFile, int endRank, boolean capture) { String piecePlusColor = Character.toString(piece) + Character.toString(color); int[][] piecePos = getPiecePositions(piecePlusColor, startFile, startRank); int[] startPos = null; if (piece == 'P') { startPos = getPawnStart(piecePos, color, endFile, endRank, capture); } else if (piece == 'R') { startPos = getRookStart(piecePos, endFile, endRank); } else if (piece == 'N') { startPos = getKnightStart(piecePos, endFile, endRank); } else if (piece == 'B') { startPos = getBishopStart(piecePos, endFile, endRank); } else if (piece == 'Q') { startPos = getQueenStart(piecePos, endFile, endRank); } else if (piece == 'K') { startPos = piecePos[0]; } return startPos; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "void positionToStart () {\n currentRow = 0 - currentPiece.getOffset();\n currentColumn = board.columns / 2 - currentPiece.width / 2;\n }", "public static int[] getRookStart(int[][] piecePos, int endFile,\n int endRank) {\n for (int[] pos: piecePos) {\n boolean correct = true;\n\n if (pos[0] == endFile) {\n int direction = (endRank - pos[1]) / Math.abs(endRank - pos[1]);\n\n for (int r = 0; r < Math.abs(pos[1] - endRank) - 1; r++) {\n if (!getBoardStateSquare(endFile,\n Math.abs(r + direction * pos[1] + 1))\n .equals(\" \")) {\n correct = false;\n\n break;\n }\n }\n\n if (correct) {\n int[] startPos = {pos[0], pos[1]};\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n }\n\n if (pos[1] == endRank) {\n correct = true;\n\n int direction = (endFile - pos[0]) / Math.abs(endFile - pos[0]);\n\n for (int f = 0; f < Math.abs(pos[0] - endFile) - 1; f++) {\n if (!getBoardStateSquare(Math.abs(\n f + direction * pos[0] + 1), endRank)\n .equals(\" \")) {\n correct = false;\n\n break;\n }\n }\n\n if (correct) {\n int[] startPos = {pos[0], pos[1]};\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n }\n }\n\n return null;\n }", "public PixelPoint getStartPoint ()\r\n {\r\n Point start = glyph.getLag()\r\n .switchRef(\r\n new Point(getStart(), line.yAt(getStart())),\r\n null);\r\n\r\n return new PixelPoint(start.x, start.y);\r\n }", "public static int[] getPawnStart(int[][] piecePos, char color, int endFile,\n int endRank, boolean capture) {\n if (capture) {\n // En Passant\n int direction = color == 'w' ? 1 : -1;\n\n if (getBoardStateSquare(endFile, endRank).equals(\" \")) {\n for (int[] pos: piecePos) {\n if (endRank == pos[1] + direction) {\n int[] startPos = {pos[0], pos[1]};\n move(\" \", endFile, endRank, endFile, pos[1]);\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n }\n\n }\n\n for (int[] pos: piecePos) {\n if (endRank == pos[1] + direction) {\n int[] startPos = {pos[0], pos[1]};\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n }\n }\n\n for (int[] pos: piecePos) {\n if (pos[0] == endFile) {\n int direction = color == 'w' ? 1 : -1;\n\n if (pos[1] + direction == endRank) {\n int[] startPos = {pos[0], pos[1]};\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n\n if (pos[1] + 2 * direction == endRank) {\n boolean correct = true;\n\n for (int r = 0; r < Math.abs(pos[1] - endRank) - 1; r++) {\n if (!getBoardStateSquare(endFile,\n Math.abs(r + direction * pos[1] + 1))\n .equals(\" \")) {\n correct = false;\n\n break;\n }\n }\n\n if (correct) {\n int[] startPos = {pos[0], pos[1]};\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n }\n }\n }\n\n return null;\n }", "public int getPosition(int player, int piece) {\n return players.get(player)\n .getPieces()\n .get(piece)\n .getPosition();\n }", "public int getStartingPos ()\r\n {\r\n if ((getThickness() >= 2) && !getLine()\r\n .isVertical()) {\r\n return getLine()\r\n .yAt(getStart());\r\n } else {\r\n return getFirstPos() + (getThickness() / 2);\r\n }\r\n }", "public SinglePieceMove getMove() {\n return move;\n }", "public Position getStartPosition() throws IllegalStateException{\r\n for (int i = 0; i < mazeData.length; i++) {\r\n for (int j = 0; j < mazeData[i].length; j++) {\r\n if (mazeData[i][j] == START)\r\n return new Position(i, j);\r\n }\r\n }\r\n throw new IllegalStateException(\"Could not find a start-point\");\r\n }", "public Position getStart() {\r\n return start;\r\n }", "public Coordinate getStart( )\n\t{\n\t\treturn startLocation;\n\t}", "public ArrayList<Coordinate> getPossibleMoveCoordinate() {\n ChessBoard board = this.getChessBoard(); // get chess board\n ArrayList<Coordinate> coords = new ArrayList<Coordinate>(); // create return ArrayList\n int x, y;\n /*\n several cases\n 2 3\n 1 4\n\n 5 8\n 6 7\n\n */\n // case1\n x = this.x_coordinate - 2;\n y = this.y_coordinate + 1;\n if(x >= 0 && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case2\n x = this.x_coordinate - 1;\n y = this.y_coordinate + 2;\n if(x >= 0 && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case3\n x = this.x_coordinate + 1;\n y = this.y_coordinate + 2;\n if(x < board.getWidth() && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case4\n x = this.x_coordinate + 2;\n y = this.y_coordinate + 1;\n if(x < board.getWidth() && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case5\n x = this.x_coordinate - 2;\n y = this.y_coordinate - 1;\n if(x >= 0 && y >= 0 ){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case6\n x = this.x_coordinate - 1;\n y = this.y_coordinate - 2;\n if(x >= 0 && y >= 0){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case7\n x = this.x_coordinate + 1;\n y = this.y_coordinate - 2;\n if(x < board.getWidth() && y >= 0){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case1\n x = this.x_coordinate + 2;\n y = this.y_coordinate - 1;\n if(x < board.getWidth() && y >= 0){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n\n\n return coords;\n }", "public static int[][] getPiecePositions(String piece, int startFile,\n int startRank) {\n int numPiecePos = 0;\n\n int[][] piecePos;\n\n if (startFile != -1 && startRank != -1) {\n piecePos = new int[1][2];\n\n piecePos[0][0] = startFile;\n piecePos[0][1] = startRank;\n } else if (startFile != -1) {\n for (int r = 0; r < 8; r++) {\n if (getBoardStateSquare(startFile, r).equals(piece)) {\n numPiecePos++;\n }\n }\n\n piecePos = new int[numPiecePos][2];\n\n int pieceIndex = 0;\n\n for (int rank = 0; rank < 8; rank++) {\n if (getBoardStateSquare(startFile, rank).equals(piece)) {\n piecePos[pieceIndex][0] = startFile;\n piecePos[pieceIndex][1] = rank;\n\n pieceIndex++;\n }\n }\n } else if (startRank != -1) {\n for (int f = 0; f < 8; f++) {\n if (getBoardStateSquare(f, startRank).equals(piece)) {\n numPiecePos++;\n }\n }\n\n piecePos = new int[numPiecePos][2];\n\n int pieceIndex = 0;\n\n for (int file = 0; file < 8; file++) {\n if (getBoardStateSquare(file, startRank).equals(piece)) {\n piecePos[pieceIndex][0] = file;\n piecePos[pieceIndex][1] = startRank;\n\n pieceIndex++;\n }\n }\n } else {\n for (String[] rank: getBoardState()) {\n for (String square: rank) {\n if (square.equals(piece)) {\n numPiecePos++;\n }\n }\n }\n\n piecePos = new int[numPiecePos][2];\n\n int pieceIndex = 0;\n\n for (int r = 0; r < getBoardState().length; r++) {\n for (int f = 0; f < getBoardState()[r].length; f++) {\n if (getBoardStateSquare(f, r).equals(piece)) {\n piecePos[pieceIndex][0] = f;\n piecePos[pieceIndex][1] = r;\n\n pieceIndex++;\n }\n }\n }\n }\n\n return piecePos;\n }", "public static int[] getKnightStart(int[][] piecePos, int endFile,\n int endRank) {\n for (int[] pos: piecePos) {\n if ((pos[0] + 1 == endFile || pos[0] - 1 == endFile)\n && (pos[1] + 2 == endRank || pos[1] - 2 == endRank)) {\n int[] startPos = {pos[0], pos[1]};\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n } else if ((pos[0] + 2 == endFile || pos[0] - 2 == endFile)\n && (pos[1] + 1 == endRank\n || pos[1] - 1 == endRank)) {\n int[] startPos = {pos[0], pos[1]};\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n }\n\n return null;\n }", "private Point findStartPoint(){\n Point min = points.get(0);\n for (int i = 1; i < points.size(); i++) {\n min = getMinValue(min, points.get(i));\n }\n return min;\n }", "public Point getStartPoint() {\n // First, this is Settler's location\n UnitList units = unitService.findByClassUuid(Settlers.CLASS_UUID);\n if (units != null && !units.isEmpty()) {\n return units.getAny().getLocation();\n }\n\n // If Settlers were destroyed then it is the first city's location\n City city = cityService.getAny();\n if (city != null) {\n return city.getLocation();\n }\n\n // If there is no cities, then the first Unit's location\n AbstractUnit unit = unitService.getAny();\n if (unit != null) {\n return unit.getLocation();\n }\n\n // If there is no units then (0, 0)\n return new Point(0, 0);\n }", "public void getTopLeft(List<Piece> moves){\n\t\t\n\t\tint pNum = PhiletoNum(this.phile);\n\t\tint rNum = this.rank;\n\t\twhile(pNum > 1 && rNum < 8){\n\t\t\tmoves.add(new Bishop(NumtoPhile(pNum - 1), rNum + 1));\n\t\t\tpNum -= 1;\n\t\t\trNum += 1;\n\t\t}\n\t}", "public XYPoint getSnakeHeadStartLocation();", "public Point getPlayerStart() {\r\n\t\treturn this.playerStart;\r\n\t}", "public Point getStart() {\n return mStart;\n }", "Tile getPosition();", "protected int getMove() \t\t\t\t{\treturn move;\t\t}", "public static String findPieceOriginal(String piece)\n\t{\n\t\tfor(int rows = 0; rows < 8; rows++)\n\t\t{\n\t\t\tfor(int cols = 0; cols < 8; cols++)\n\t\t\t{\n\t\t\t\tif(initialOccuMap[rows][cols].equals(piece))\n\t\t\t\t\treturn posMap[rows][cols];\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}", "public Coordinate getMoveTo();", "public Point start() {\r\n return this.start;\r\n }", "public Point getStartPosition()\r\n\t{\r\n\t\treturn startPosition;\r\n\t}", "public static Image movePoint()\n\t{\n\t\treturn movePoint;\n\t}", "public String getStartPoint()\n\t{\n\t\tString getStart;\n\t\tgetStart = (this.startPoint.xPosition + \",\" + this.startPoint.yPosition);\n\t\treturn getStart;\n\t}", "public ArrayList<Point> moves() {\n\t\tmoves = new ArrayList<Point>();\n\t\tif (point.x > 0 && board.pieceAt(point.x - 1, point.y) == null)\n\t\t\tmoves.add(board.left(point));\n\t\tif (point.x < board.getXDim() - 1 && board.pieceAt(point.x + 1, point.y) == null)\n\t\t\tmoves.add(board.right(point));\n\t\tif (point.y > 0 && board.pieceAt(point.x, point.y - 1) == null)\n\t\t\tmoves.add(board.above(point));\n\t\tif (point.y < board.getYDim() - 1 && board.pieceAt(point.x, point.y + 1) == null)\n\t\t\tmoves.add(board.below(point));\n\t\treturn (ArrayList<Point>) moves.clone();\n\t}", "public Point getStart() {\n\t\treturn _start;\n\t}", "private static int leftScore(char piece, State state, int row, int col) {\n\t\tif(col != 0 && state.getGrid()[row][col-1] == piece) {\n\t\t\treturn NEXT_TO;\n\t\t}\n\t\telse {\n\t\t\treturn ZERO;\n\t\t}\n\t}", "double getStartX();", "private void HandleOnMoveStart(Board board, Piece turn){}", "private float getMinX(HomePieceOfFurniture piece) {\n float [][] points = piece.getPoints();\n float minX = Float.POSITIVE_INFINITY;\n for (float [] point : points) {\n minX = Math.min(minX, point [0]);\n } \n return minX;\n }", "protected int getMove(){\r\n\t\treturn this.move;\r\n\t}", "public Position getStartPosition() {\n return start;\n }", "org.mojolang.mojo.lang.Position getStartPosition();", "public double getStartX()\n {\n return startxcoord; \n }", "public int moves() {\n return moveMin;\n }", "public abstract int getStartPosition();", "private int[] defineStartingPos() {\n\t\tint[] positions = new int[4];\n\t\tif(initPos.equals(UP)) {\n\t\t\tpositions[0] = 0;\n\t\t\tpositions[1] = (size-1)/2;\n\t\t\tpositions[2] = 1;\n\t\t}else if(initPos.equals(DOWN)) {\n\t\t\tpositions[0] = size-1;\n\t\t\tpositions[1] = (size-1)/2;\n\t\t\tpositions[2] = -1;\n\t\t}else if(initPos.equals(LEFT)) {\n\t\t\tpositions[0] = (size-1)/2;\n\t\t\tpositions[1] = 0;\n\t\t\tpositions[3] = 1;\n\t\t}else if(initPos.equals(RIGHT)) {\n\t\t\tpositions[0] = (size-1)/2;\n\t\t\tpositions[1] = size-1;\n\t\t\tpositions[3] = -1;\n\t\t}\n\t\treturn positions;\n\t}", "public int getStartPos() {\n return startPos;\n }", "public float getStartX() {return startX;}", "private int firstMove(ArrayList<Integer> open, ArrayList<Integer> plyr, ArrayList<Integer> comp, int turn)\r\n {\r\n int[] first = {0,2,4,4,4,4,6,8};\r\n int[] second = {0,2,6,8};\r\n if(turn == 0)\r\n return first[gen.nextInt(8)];\r\n else\r\n {\r\n int plyrMove = plyr.get(0);\r\n if(plyrMove == 4)\r\n return second[gen.nextInt(4)];\r\n else\r\n return 4;\r\n }\r\n }", "public Point getStartPoint() {\n\t\treturn startPoint;\n\t}", "public void movePiece(Coordinate from, Coordinate to);", "public Position getStartPosition()\r\n\t{\r\n\t\treturn startPosition;\r\n\t}", "private Position getTestPos1() {\r\n Grid grid = GridBuilder.builder()\r\n .withMaxX(10)\r\n .withMaxY(10)\r\n .withMinY(-20)\r\n .withMinY(-20)\r\n .build();\r\n Moveable moveable = MoveableBuilder.builder()\r\n .withGrid(grid)\r\n .withShape(PositionShapeBuilder.builder()\r\n .withPosition(Positions.of(Directions.S, 0, 0, 0))\r\n .build())\r\n .withVelocity(100)\r\n .build();\r\n moveable.moveForward();\r\n moveable.turnRight();\r\n moveable = MoveableBuilder.builder()\r\n .withGrid(grid)\r\n .withShape(PositionShapeBuilder.builder()\r\n .withPosition(moveable.getPosition())\r\n .build())\r\n .withVelocity(50)\r\n .build();\r\n moveable.moveForward();\r\n PositionImpl position = (PositionImpl) moveable.getPosition();\r\n moveable.makeTurn(position.calcAbsoluteAngle() - position.getDirection().getAngle());\r\n return moveable.getPosition();\r\n }", "public Square getStartSquare() {\n\t\treturn squares.get(0);\n\t}", "public FallingPiece moveLeft(){\r\n return new FallingPiece(coord.moveLeft(), innerPiece);\r\n }", "public Vector<ChessBoardBlock> getMovablePosition(ChessPiece p) {\r\n\t\tString player = p.chessPlayer;\r\n\t\tString position = p.position;\r\n\t\tchar h = position.charAt(0);\r\n\t\tint v = Integer.parseInt(position.substring(1));\r\n\t\tVector<ChessBoardBlock> tmp = new Vector<ChessBoardBlock>();\r\n\t\ttmp.add(board.get(position));\r\n\t\t\r\n\t\t// Condition for white piece\r\n\t\tif (player.equals(\"white\")) {\r\n\t\t\t\r\n\t\t\t// Condition for not King piece\r\n\t\t\tif (p.getText() == null) {\r\n\t\t\t\tChessBoardBlock br1 = board.get(Character.toString((char)(h+1)) + (v+1));\r\n\t\t\t\tChessBoardBlock br2 = board.get(Character.toString((char)(h+2)) + (v+2));\r\n\t\t\t\t// Condition for upper right to the piece\r\n\t\t\t\tif (br1 != null && piece.get(br1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(br1.position));\r\n\t\t\t\t} else if (br2 != null && piece.get(br1.position).chessPlayer.equals(\"black\") && piece.get(br2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(br2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tChessBoardBlock bl1 = board.get(Character.toString((char)(h-1)) + (v+1));\r\n\t\t\t\tChessBoardBlock bl2 = board.get(Character.toString((char)(h-2)) + (v+2));\r\n\t\t\t\t// Condition for upper left to the piece\r\n\t\t\t\tif (bl1 != null && piece.get(bl1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bl1.position));\r\n\t\t\t\t} else if (bl2 != null && piece.get(bl1.position).chessPlayer.equals(\"black\") && piece.get(bl2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bl2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t} \r\n\r\n\t\t\t// Condition for King piece\r\n\t\t\telse {\r\n\t\t\t\tChessBoardBlock bur1 = board.get(Character.toString((char)(h+1)) + (v+1));\r\n\t\t\t\tChessBoardBlock bur2 = board.get(Character.toString((char)(h+2)) + (v+2));\r\n\t\t\t\t// Condition for upper right to the piece\r\n\t\t\t\tif (bur1 != null && piece.get(bur1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bur1.position));\r\n\t\t\t\t} else if (bur2 != null && piece.get(bur1.position).chessPlayer.equals(\"black\") && piece.get(bur2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bur2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tChessBoardBlock bul1 = board.get(Character.toString((char)(h-1)) + (v+1));\r\n\t\t\t\tChessBoardBlock bul2 = board.get(Character.toString((char)(h-2)) + (v+2));\r\n\t\t\t\t// Condition for upper left to the piece\r\n\t\t\t\tif (bul1 != null && piece.get(bul1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bul1.position));\r\n\t\t\t\t} else if (bul2 != null && piece.get(bul1.position).chessPlayer.equals(\"black\") && piece.get(bul2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bul2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tChessBoardBlock bdr1 = board.get(Character.toString((char)(h+1)) + (v-1));\r\n\t\t\t\tChessBoardBlock bdr2 = board.get(Character.toString((char)(h+2)) + (v-2));\r\n\t\t\t\t// Condition for lower right to the piece\r\n\t\t\t\tif (bdr1 != null && piece.get(bdr1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bdr1.position));\r\n\t\t\t\t} else if (bdr2 != null && piece.get(bdr1.position).chessPlayer.equals(\"black\") && piece.get(bdr2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bdr2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tChessBoardBlock bdl1 = board.get(Character.toString((char)(h-1)) + (v-1));\r\n\t\t\t\tChessBoardBlock bdl2 = board.get(Character.toString((char)(h-2)) + (v-2));\r\n\t\t\t\t// Condition for lower left to the piece\r\n\t\t\t\tif (bdl1 != null && piece.get(bdl1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bdl1.position));\r\n\t\t\t\t} else if (bdl2 != null && piece.get(bdl1.position).chessPlayer.equals(\"black\") && piece.get(bdl2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bdl2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\t// Condition for black piece\r\n\t\telse {\r\n\t\t\t\r\n\t\t\t// Condition for not King piece\r\n\t\t\tif (p.getText() == null) {\r\n\t\t\t\tChessBoardBlock br1 = board.get(Character.toString((char)(h+1)) + (v-1));\r\n\t\t\t\tChessBoardBlock br2 = board.get(Character.toString((char)(h+2)) + (v-2));\r\n\t\t\t\t// Condition for upper right to the piece\r\n\t\t\t\tif (br1 != null && piece.get(br1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(br1.position));\r\n\t\t\t\t} else if (br2 != null && piece.get(br1.position).chessPlayer.equals(\"white\") && piece.get(br2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(br2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tChessBoardBlock bl1 = board.get(Character.toString((char)(h-1)) + (v-1));\r\n\t\t\t\tChessBoardBlock bl2 = board.get(Character.toString((char)(h-2)) + (v-2));\r\n\t\t\t\t// Condition for upper left to the piece\r\n\t\t\t\tif (bl1 != null && piece.get(bl1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bl1.position));\r\n\t\t\t\t} else if (bl2 != null && piece.get(bl1.position).chessPlayer.equals(\"white\") && piece.get(bl2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bl2.position));\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tChessBoardBlock bur1 = board.get(Character.toString((char)(h+1)) + (v+1));\r\n\t\t\t\tChessBoardBlock bur2 = board.get(Character.toString((char)(h+2)) + (v+2));\r\n\t\t\t\t// Condition for upper right to the piece\r\n\t\t\t\tif (bur1 != null && piece.get(bur1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bur1.position));\r\n\t\t\t\t} else if (bur2 != null && piece.get(bur1.position).chessPlayer.equals(\"white\") && piece.get(bur2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bur2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tChessBoardBlock bul1 = board.get(Character.toString((char)(h-1)) + (v+1));\r\n\t\t\t\tChessBoardBlock bul2 = board.get(Character.toString((char)(h-2)) + (v+2));\r\n\t\t\t\t// Condition for upper left to the piece\r\n\t\t\t\tif (bul1 != null && piece.get(bul1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bul1.position));\r\n\t\t\t\t} else if (bul2 != null && piece.get(bul1.position).chessPlayer.equals(\"white\") && piece.get(bul2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bul2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tChessBoardBlock bdr1 = board.get(Character.toString((char)(h+1)) + (v-1));\r\n\t\t\t\tChessBoardBlock bdr2 = board.get(Character.toString((char)(h+2)) + (v-2));\r\n\t\t\t\t// Condition for lower right to the piece\r\n\t\t\t\tif (bdr1 != null && piece.get(bdr1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bdr1.position));\r\n\t\t\t\t} else if (bdr2 != null && piece.get(bdr1.position).chessPlayer.equals(\"white\") && piece.get(bdr2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bdr2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tChessBoardBlock bdl1 = board.get(Character.toString((char)(h-1)) + (v-1));\r\n\t\t\t\tChessBoardBlock bdl2 = board.get(Character.toString((char)(h-2)) + (v-2));\r\n\t\t\t\t// Condition for lower left to the piece\r\n\t\t\t\tif (bdl1 != null && piece.get(bdl1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bdl1.position));\r\n\t\t\t\t} else if (bdl2 != null && piece.get(bdl1.position).chessPlayer.equals(\"white\") && piece.get(bdl2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bdl2.position));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn tmp;\r\n\t}", "public ArrayList<Move> getPossibleMoves(int startx, int starty, Board b){//String startpos, Board b){\n\t\t//startpos is the position of the current piece,\n\t\t//so we know which one it is on the board\n\t\t\n\t\tArrayList<Move> moves = new ArrayList<Move>();\n\t\t\n\t\t\n\t\t\n\t\t//int startx = Main.converttoMove(String.valueOf(startpos.charAt(0)));\n\t\t//int starty = Integer.valueOf(String.valueOf(startpos.charAt(1)));\n\t\t\t\t\t\n\t\tPosition startpo = b.getElement(startx, starty);\n\t\tString startcol = startpo.getState().getColor();\n\t\tboolean color = true;//color: white is true, black if false\n\t\tif(startcol.equalsIgnoreCase(\"b\")) {\n\t\t\tcolor = false;\n\t\t}\n\t\t\n\t\t\n\t\t//go up and down\n\t\t//Number of spaces to move in X and Y direction\n //int numSpacesYUp = starty+1;//Not sure if this math is correct\n \n\t\tint numSpacesYUp = Math.abs(starty);\n int numSpacesYDown = Math.abs(8-(starty+1));//^\n\t\t\n \n //go left and right\n\t\tint numSpacesXLeft=Math.abs(startx);//TO DO: Add Math\n\t\t//int numSpacesXRight =Math.abs(8-(startx+1)); //old\n\t\tint numSpacesXRight =Math.abs(8-(startx+1));//new\n \n \n \n\t\t//go diagonal upper right\n \n\t\tint numtoTopRightCorner = Math.min(numSpacesXRight, numSpacesYUp);//the min of the distance from the current spot to the right edge and to the top edge\n for(int i = 1;i<=numtoTopRightCorner;i++) {\n \tint endx = startx+i;\n \tint endy = starty-(i);\n \t\n \t\tPosition endpo = b.getElement(endx, endy);\n \t\tif(endpo.getState() != null) {//theres a piece at the end loc\n \t\tString endcol = endpo.getState().getColor();\n \t\tboolean endcolor = true;//color: white is true, black if false\n \t\tif(endcol.equalsIgnoreCase(\"b\")) {\n \t\t\tendcolor = false;\n \t\t}\n \t\tMove m = new Move(startx, starty, endx, endy);\n \tif(color != endcolor) {\n \t\t//System.out.println(\"\");\n \t\tm.setPieceTaken(true);\n \t\tif(endpo.getState() instanceof King) {\n \t\t\tm.setCheck(true);\n \t\t}else {\n \t\t\tm.setCheck(false);\n \t\t}\n \t\tmoves.add(m);\n \t\t//break;//can't get any more in the upper right diag because there would be a piece blocking its way\n \t}else if(color == endcolor) {\n \t\t//we don't add the move, because its not possible :/\n \t\t//you cant move to a location where you already have a piece\n \t\t//break;\n \t}\n \tbreak;//can't get any more in the upper right diag because there would be a piece blocking its way\n \t\t}else {\n \t\t\tMove m = new Move(startx, starty, endx, endy);\n \t\t\tmoves.add(m);\n \t\t}\n }\n\t\t\n\t\t\n\t\t\n\t\t//go diagonal upper left\n\t\tint numtoTopLeftCorner = Math.min(numSpacesXLeft, numSpacesYUp);//the min of the distance from the current spot to the right edge and to the top edge\n for(int i = 1;i<=numtoTopLeftCorner;i++) {\n \tint endx = startx-(i);\n \tint endy = starty-(i);\n \t\n \t\tPosition endpo = b.getElement(endx, endy);\n \t\tif(endpo.getState() != null) {//theres a piece at the end loc\n \t\tString endcol = endpo.getState().getColor();\n \t\tboolean endcolor = true;//color: white is true, black if false\n \t\tif(endcol.equalsIgnoreCase(\"b\")) {\n \t\t\tendcolor = false;\n \t\t}\n \t\tMove m = new Move(startx, starty, endx, endy);\n \tif(color != endcolor) {\n \t\tm.setPieceTaken(true);\n \t\tif(endpo.getState() instanceof King) {\n \t\t\tm.setCheck(true);\n \t\t}else {\n \t\t\tm.setCheck(false);\n \t\t}\n \t\tmoves.add(m);\n \t\t//break;//can't get any more in the upper right diag because there would be a piece blocking its way\n \t}else if(color == endcolor) {\n \t\t//we don't add the move, because its not possible :/\n \t\t//you cant move to a location where you already have a piece\n \t\t//break;\n \t}\n \tbreak;//can't get any more in the upper right diag because there would be a piece blocking its way\n \t\t}else {\n \t\t\tMove m = new Move(startx, starty, endx, endy);\n \t\t\tmoves.add(m);\n \t\t}\n \t\n \t\n }\n \n \n \n\t\t//go diagonal lewer left\n\t\tint numtoLowerLeftCorner = Math.min(numSpacesXLeft, numSpacesYDown);//the min of the distance from the current spot to the right edge and to the top edge\n for(int i = 1;i<=numtoLowerLeftCorner;i++) {\n \tint endx = startx-(i);\n \tint endy = starty+(i);\n \t\n \t\tPosition endpo = b.getElement(endx, endy);\n \t\tif(endpo.getState() != null) {//theres a piece at the end loc\n \t\tString endcol = endpo.getState().getColor();\n \t\tboolean endcolor = true;//color: white is true, black if false\n \t\tif(endcol.equalsIgnoreCase(\"b\")) {\n \t\t\tendcolor = false;\n \t\t}\n \t\tMove m = new Move(startx, starty, endx, endy);\n \tif(color != endcolor) {\n \t\tm.setPieceTaken(true);\n \t\tif(endpo.getState() instanceof King) {\n \t\t\tm.setCheck(true);\n \t\t}else {\n \t\t\tm.setCheck(false);\n \t\t}\n \t\tmoves.add(m);\n \t\t//break;//can't get any more in the upper right diag because there would be a piece blocking its way\n \t}else if(color == endcolor) {\n \t\t//we don't add the move, because its not possible :/\n \t\t//you cant move to a location where you already have a piece\n \t\t//break;\n \t}\n \tbreak;//can't get any more in the upper right diag because there would be a piece blocking its way\n \t\t}else {\n \t\t\tMove m = new Move(startx, starty, endx, endy);\n \t\t\tmoves.add(m);\n \t\t}\n }\n \n\t\t//go diagonal lower right\n\t\tint numtoLowerRightCorner = Math.min(numSpacesXRight, numSpacesYDown);//the min of the distance from the current spot to the right edge and to the top edge\n for(int i = 1;i<=numtoLowerRightCorner;i++) {\n \tint endx = startx+(i);\n \tint endy = starty+(i);\n \t\n \t//System.out.println(\"num spaces x right:\" + numSpacesXRight);\n \t//System.out.println(\"num spaces y down:\" + numSpacesYDown);\n \t\n \t\tPosition endpo = b.getElement(endx, endy);\n \t\tif(endpo.getState() != null) {//theres a piece at the end loc\n \t\tString endcol = endpo.getState().getColor();\n \t\tboolean endcolor = true;//color: white is true, black if false\n \t\tif(endcol.equalsIgnoreCase(\"b\")) {\n \t\t\tendcolor = false;\n \t\t}\n \t\tMove m = new Move(startx, starty, endx, endy);\n \tif(color != endcolor) {\n \t\tm.setPieceTaken(true);\n \t\tif(endpo.getState() instanceof King) {\n \t\t\tm.setCheck(true);\n \t\t}else {\n \t\t\tm.setCheck(false);\n \t\t}\n \t\tmoves.add(m);\n \t\t//break;//can't get any more in the upper right diag because there would be a piece blocking its way\n \t}else if(color == endcolor) {\n \t\t//we don't add the move, because its not possible :/\n \t\t//you cant move to a location where you already have a piece\n \t\t//break;//should break cause you cant go more in that direction\n \t}\n \tbreak;//can't get any more in the lower right diag because there would be a piece blocking its way\n \t\t}else {\n \t\t\tMove m = new Move(startx, starty, endx, endy);\n \t\t\tmoves.add(m);\n \t\t}\n \t\n \t\n }\n\t\t\n\t\t\n\t\treturn moves;//Return all possible legal moves\n\t}", "public Move getFirstMove() {\n return this.moves.get(0);\n }", "String computeNextLawnPosition();", "@Override\n public void movePiece(Piece piece, char file, GridPosition end) {\n GridPosition current = getCurrentGridPositionOfPiece(piece, file, end);\n\n Move mv = new Move(piece, current, end);\n\n int[] curYX = ChessGameUtils_Ng.convertGridPositionTo2DYXArray(current);\n int curY = curYX[ChessGameUtils_Ng.Y_INDEX], curX = curYX[ChessGameUtils_Ng.X_INDEX];\n\n int[] update = mv.getYXDelta();\n int dY = update[DELTA_Y_INDEX], dX = update[DELTA_X_INDEX];\n\n board[curY][curX] = EMPTY_SPACE;\n board[curY + dY][curX + dX] = piece;\n moveHistory.add(mv);\n }", "private static Image getMovePoint()\n\t{\n\t\ttry {\n\t\t\treturn ImageIO.read(new File(guiDirectory + move));\n\t\t} catch (IOException ioe) {\n\t\t}\n\t\treturn null;\n\t}", "int getStartPosition();", "int getStartPosition();", "public static int[] getBishopStart(int[][] piecePos, int endFile,\n int endRank) {\n int bishopColor = (endFile + endRank) % 2;\n\n for (int[] pos: piecePos) {\n if ((pos[0] + pos[1]) % 2 == bishopColor) {\n if (endFile - pos[0] != 0 && endRank - pos[1] != 0) {\n int fDir = (endFile - pos[0]) / Math.abs(endFile - pos[0]);\n int rDir = (endRank - pos[1]) / Math.abs(endRank - pos[1]);\n\n boolean correct = true;\n\n if (Math.abs(pos[0] - endFile) != Math.abs(\n pos[1] - endRank)) {\n continue;\n }\n\n if (Math.abs(pos[0] - endFile) - 1 != 0) {\n for (int i = 0; i < Math.abs(pos[0] - endFile) - 1;\n i++) {\n int file = Math.abs(i + fDir * pos[0] + 1);\n int rank = Math.abs(i + rDir * pos[1] + 1);\n\n if (!getBoardStateSquare(file, rank).equals(\" \")) {\n correct = false;\n }\n }\n }\n\n if (correct) {\n int[] startPos = {pos[0], pos[1]};\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n }\n }\n }\n\n return null;\n }", "@Override\r\n \tpublic final int getStartPos() {\r\n \t\treturn sourceStart;\r\n \t}", "Move getMove() {\n try {\n boolean playing0 = _playing;\n while (_playing == playing0) {\n prompt();\n\n String line = _input.readLine();\n if (line == null) {\n quit();\n }\n line = line.trim();\n if (!processCommand(line)) {\n Move move = Move.create(line, _board);\n if (move == null) {\n error(\"invalid move: %s%n\", line);\n } else if (!_playing) {\n error(\"game not started\");\n } else if (!_board.isLegal(move)) {\n error(\"illegal move: %s%n\", line);\n } else {\n return move;\n }\n }\n }\n } catch (IOException excp) {\n error(1, \"unexpected I/O error on input\");\n }\n return null;\n }", "public Position getStartPosition() {\n return startPosition;\n }", "public ArrayList<Integer> getStart(){\n return curBoard;\n }", "public int getStartX() {\r\n\t\treturn startX;\r\n\t}", "public Coordinate getPosition();", "public GeoPoint getStart(){\n return getOrigin();\n }", "public int getStartPosition() {\n return startPosition_;\n }", "int playerMoveStart(Player player, int oldAmount);", "String getLawnPosition();", "void movePiece() {\n\n }", "public Vector2D getStartPos(){\n\t\treturn startPos;\n\t}", "public Point getStart(){\n\t\treturn bigstart;\n\t}", "public List<Vector2f> getPlayerStartPositions() {\n \n List<Vector2f> list = new ArrayList();\n PlayerStart[] points = getPlayerStartingPoints();\n \n if(points == null || points.length <= 0) {\n return list;\n }\n \n for(int i = 0; i < points.length; i++) {\n PlayerStart p = points[i];\n list.add(new Vector2f( p.x, p.y ));\n }\n \n return list;\n \n }", "public int getXPos();", "public float getDistanceToStart() {\n\t\treturn distanceToStart;\n\t}", "public void getMove(){\n\t\t\n\t}", "public double getStartX() {\n\treturn v1.getX();\n }", "public Point getMinPoint() {\r\n int minX = children.get(0).getShapeStartingPoint().getX();\r\n int minY = children.get(0).getShapeStartingPoint().getY();\r\n for(IShape shape: children) {\r\n if(minX > shape.getShapeStartingPoint().getX()) {\r\n minX = shape.getShapeStartingPoint().getX();\r\n }\r\n if(minY > shape.getShapeStartingPoint().getY()) {\r\n minY = shape.getShapeStartingPoint().getY();\r\n }\r\n }\r\n minPoint = new Point(minX,minY);\r\n return minPoint;\r\n }", "public int getStart() {\r\n\t\treturn this.offset;\r\n\t}", "public Point getPosition();", "Coordinate getMinX();", "public int move(Piece piece, int dices){\n int step = this.roll(dices); //and returns the new position of piece of player.\n this.piece.position += step;\n this.piece.position = (this.piece.position%40);\n System.out.println(this.name + \" is now located in Square \" + this.piece.position);\n return piece.position;\n }", "public int getStartPosition() {\n return startPosition_;\n }", "public Position getPlayerPiecePosition(int playerNum) {\n return playerPiecePositions[playerNum];\n }", "public final BlockPos getPos() {\n\t\treturn baseTile.getPos();\n\t}", "public GeoPointND getStartPoint();", "Point getPosition();", "Point getPosition();", "@Override\n public double getPosX() {\n return this.pos[0];\n }", "public boolean movePiece(int player, int from, int to) {\n\n int piece = players.get(player).getPiece(from);\n\n // PIECELISTENER : Throw PieceEvent to PieceListeners\n for (PieceListener listener : pieceListeners) {\n PieceEvent pieceEvent = new PieceEvent(this, player, piece, from, to);\n listener.pieceMoved(pieceEvent);\n }\n\n if (piece != -1) {\n //last throw was a 6, but player is in starting position\n //end of turn\n if (this.lastThrow == 6 && players.get(player).inStartingPosition() && from == 0) {\n // PLAYERLISTENER : Trigger playerEvent for player that is WAITING\n for (PlayerListener listener : playerListeners) {\n PlayerEvent event = new PlayerEvent(this, players.get(player).getColour(), PlayerEvent.WAITING);\n listener.playerStateChanged(event);\n }\n this.setNextActivePlayer();\n }\n //player didn't throw a 6\n //end of turn\n if (this.lastThrow != 6) {\n // PLAYERLISTENER : Trigger playerEvent for player that is WAITING\n for (PlayerListener listener : playerListeners) {\n PlayerEvent event = new PlayerEvent(this, players.get(player).getColour(), PlayerEvent.WAITING);\n listener.playerStateChanged(event);\n }\n this.setNextActivePlayer();\n }\n\n //Resets the tower info when a tower is split\n if (players.get(player).getPieces().get(piece).towerPos != -1) {\n players.get(player)\n .getPieces()\n .get(piece)\n .setTower(-1);\n\n for (Piece piece2 : players.get(player).pieces) {\n if (piece2.position == from) {\n piece2.setTower(-1);\n }\n }\n }\n\n //Sets tower info when a tower is made\n for (Piece piece2 : players.get(player).pieces) {\n if (piece2.position == to) {\n //Both pieces become a tower\n piece2.setTower(piece2.position);\n players.get(player)\n .getPieces()\n .get(piece)\n .setTower(to);\n }\n }\n\n //move piece\n players.get(player)\n .getPieces()\n .get(piece)\n .setPosition(to);\n\n //set piece to in play\n if (to > 0 && to < 59) {\n players.get(player)\n .getPieces()\n .get(piece)\n .setInPlay(true);\n }\n\n checkIfAnotherPlayerLiesThere(player, to);\n\n if (to == 59) {\n\n if (players.get(player).pieceFinished()) {\n this.status = \"Finished\";\n getWinner();\n }\n }\n\n return true;\n } else {\n //doesn't work\n return false;\n }\n\n }", "public double getDistanceToStart() {\r\n return startDistance;\r\n }", "public int getLineToStart() {\r\n\t\treturn this.lineToStart;\r\n\t}", "String getPosX();", "@Override\n public int[] getStartPosition() {\n if(maze != null){\n int[] position = new int[2];\n position[0] = maze.getStartPosition().getRowIndex();\n position[1] = maze.getStartPosition().getColumnIndex();\n return position;\n }\n return null;\n }", "@Override\n public long getPosition() {\n return startPosition + super.getPosition();\n }", "public synchronized String Move(Coordinates step) {\n // check if player won't go over the grid\n if (step.getKey() + coord.getKey() < 0 || step.getKey() + coord.getKey() > sizeSide) {\n System.out.println(\"You can't go out of x bounds, retry\");\n return null;\n }\n else if (step.getValue() + coord.getValue() < 0 || step.getValue() + coord.getValue() > sizeSide) {\n System.out.println(\"You can't go out of y bounds, retry\");\n return null;\n }\n else {\n coord = new Coordinates(coord.getKey() + step.getKey(), coord.getValue() + step.getValue());\n return \"ok\";\n }\n }", "public int getPiece()\n\t{\n\t\treturn this.piece;\n\t}", "Square getCurrentPosition();", "public void moveStart(\n )\n {\n index = StartIndex;\n if(state == null)\n {\n if(parentLevel == null)\n {state = new GraphicsState(this);}\n else\n {state = parentLevel.state.clone(this);}\n }\n else\n {\n if(parentLevel == null)\n {state.initialize();}\n else\n {parentLevel.state.copyTo(state);}\n }\n\n notifyStart();\n\n refresh();\n }", "public ImPoint getCurrentLoc() {\n \treturn this.startLoc;\n }", "public Point getMovingPositions(Point c , Color color , Movement m){\n Orientation or = color==Color.black?Orientation.DOWN:Orientation.UP;\n Color oposite = color==Color.black?Color.red:Color.black;\n Point soldierPoint = getXandYgivenOrientation(c, or, m);\n Soldier friend = new Soldier(soldierPoint.x,soldierPoint.y,color);\n Soldier foe = new Soldier(soldierPoint.x,soldierPoint.y,oposite);\n if(!containsSoldier(friend, gamePieces) && !containsSoldier(foe, gamePieces) \n && isValidSquare(soldierPoint.x, soldierPoint.y))\n return new Point(soldierPoint.x,soldierPoint.y);\n else if(containsSoldier(friend, gamePieces))\n return new Point(0,0);\n else if (containsSoldier(foe, gamePieces))\n return new Point(0,0); \n return new Point(0,0);\n }" ]
[ "0.674201", "0.64870995", "0.64597094", "0.6388411", "0.6259571", "0.62403333", "0.6197974", "0.6146887", "0.6146686", "0.6140173", "0.61356825", "0.61140937", "0.61132365", "0.6074323", "0.60114557", "0.59963256", "0.5990154", "0.5974113", "0.59585905", "0.5924951", "0.59063303", "0.58916795", "0.58671963", "0.5866568", "0.5857496", "0.584314", "0.58274734", "0.58268714", "0.58205354", "0.58167374", "0.58068997", "0.577698", "0.5757504", "0.57395315", "0.5736926", "0.57280797", "0.57266396", "0.56953144", "0.5688256", "0.56801504", "0.5666", "0.56626886", "0.5661744", "0.5655838", "0.5655013", "0.5636656", "0.56360525", "0.56358016", "0.563547", "0.5623702", "0.56087047", "0.56041384", "0.5604031", "0.560206", "0.56010395", "0.55970263", "0.55970263", "0.556948", "0.5557391", "0.55570084", "0.5544156", "0.5542606", "0.55421793", "0.5527723", "0.55275935", "0.55212665", "0.55199516", "0.5515823", "0.5515405", "0.55149", "0.55098116", "0.5509803", "0.548188", "0.5479225", "0.5479135", "0.54758567", "0.54737854", "0.5465534", "0.5464554", "0.546414", "0.5450828", "0.5446734", "0.54444766", "0.5443574", "0.5441383", "0.5439703", "0.5439703", "0.5437793", "0.54327846", "0.54233", "0.542114", "0.54194605", "0.54163015", "0.5416062", "0.5415683", "0.5414495", "0.5410496", "0.5405568", "0.5404621", "0.54021424" ]
0.64485794
3
Get the positions of instances of piece. If information about a starting position exists, then only get instances of the piece that fit the information about the start position.
public static int[][] getPiecePositions(String piece, int startFile, int startRank) { int numPiecePos = 0; int[][] piecePos; if (startFile != -1 && startRank != -1) { piecePos = new int[1][2]; piecePos[0][0] = startFile; piecePos[0][1] = startRank; } else if (startFile != -1) { for (int r = 0; r < 8; r++) { if (getBoardStateSquare(startFile, r).equals(piece)) { numPiecePos++; } } piecePos = new int[numPiecePos][2]; int pieceIndex = 0; for (int rank = 0; rank < 8; rank++) { if (getBoardStateSquare(startFile, rank).equals(piece)) { piecePos[pieceIndex][0] = startFile; piecePos[pieceIndex][1] = rank; pieceIndex++; } } } else if (startRank != -1) { for (int f = 0; f < 8; f++) { if (getBoardStateSquare(f, startRank).equals(piece)) { numPiecePos++; } } piecePos = new int[numPiecePos][2]; int pieceIndex = 0; for (int file = 0; file < 8; file++) { if (getBoardStateSquare(file, startRank).equals(piece)) { piecePos[pieceIndex][0] = file; piecePos[pieceIndex][1] = startRank; pieceIndex++; } } } else { for (String[] rank: getBoardState()) { for (String square: rank) { if (square.equals(piece)) { numPiecePos++; } } } piecePos = new int[numPiecePos][2]; int pieceIndex = 0; for (int r = 0; r < getBoardState().length; r++) { for (int f = 0; f < getBoardState()[r].length; f++) { if (getBoardStateSquare(f, r).equals(piece)) { piecePos[pieceIndex][0] = f; piecePos[pieceIndex][1] = r; pieceIndex++; } } } } return piecePos; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public Pos[] getAllPiecesPos() {\n\t\tArrayList<Pos> resPos = new ArrayList<Pos>();\n\t\tfor (int i = 0; i < Board.getRow(); i++) {\n\t\t\tfor (int j = 0; j < Board.getCol(); j++) {\n\t\t\t\tif (Board.getSlot(i, j).Piece() != null) {\n\t\t\t\t\tresPos.add(new Pos(i, j));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (resPos.size() > 0) {\n\t\t\tPos[] res = new Pos[resPos.size()];\n\t\t\tfor (int i = 0; i < res.length; i++) {\n\t\t\t\tres[i] = resPos.get(i);\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\t\telse return null;\n\t}", "@Override\r\n public void getRange(ArrayList<Piece> pieces){\r\n this.range.clear();\r\n int pieceX = this.getX(); int pieceY = this.getY(); // X and Y coordinates for the king piece\r\n\r\n // getPiece: 0 = empty; 1 = same color; 2 = opposite color\r\n //Up\r\n if (this.getPiece(pieceX, pieceY+1, pieces) == 0 || this.getPiece(pieceX, pieceY+1, pieces) == 2)\r\n this.range.add(new int[] {pieceX, pieceY+1}); // Return int[] of tested coordinates\r\n\r\n //Up-right\r\n if (this.getPiece(pieceX+1, pieceY+1, pieces) == 0 || this.getPiece(pieceX+1, pieceY+1, pieces) == 2)\r\n this.range.add(new int[] {pieceX+1, pieceY+1}); // Return int[] of tested coordinates\r\n\r\n //Right\r\n if (this.getPiece(pieceX+1, pieceY, pieces) == 0 || this.getPiece(pieceX+1, pieceY, pieces) == 2)\r\n this.range.add(new int[] {pieceX+1, pieceY}); // Return int[] of tested coordinates\r\n\r\n //Down-right\r\n if (this.getPiece(pieceX+1, pieceY-1, pieces) == 0 || this.getPiece(pieceX+1, pieceY-1, pieces) == 2)\r\n this.range.add(new int[] {pieceX+1, pieceY-1}); // Return int[] of tested coordinates\r\n\r\n //Down\r\n if (this.getPiece(pieceX, pieceY-1, pieces) == 0 || this.getPiece(pieceX, pieceY-1, pieces) == 2)\r\n this.range.add(new int[] {pieceX, pieceY-1}); // Return int[] of tested coordinates\r\n\r\n //Down-left\r\n if (this.getPiece(pieceX-1, pieceY-1, pieces) == 0 || this.getPiece(pieceX-1, pieceY-1, pieces) == 2)\r\n this.range.add(new int[] {pieceX-1, pieceY-1}); // Return int[] of tested coordinates\r\n\r\n //Left\r\n if (this.getPiece(pieceX-1, pieceY, pieces) == 0 || this.getPiece(pieceX-1, pieceY, pieces) == 2)\r\n this.range.add(new int[] {pieceX-1, pieceY}); // Return int[] of tested coordinates\r\n\r\n //Up-left\r\n if (this.getPiece(pieceX-1, pieceY+1, pieces) == 0 || this.getPiece(pieceX-1, pieceY+1, pieces) == 2)\r\n this.range.add(new int[] {pieceX-1, pieceY+1}); // Return int[] of tested coordinates\r\n\r\n //Castling\r\n for (Piece piece : pieces) {\r\n if (piece instanceof Rook) {\r\n if (piece.getColor() == this.getColor()) {\r\n if (validCastling(pieces, (Rook)piece)) {\r\n int targetX = (piece.getX() < getX()) ? (this.getX() - 2) : (this.getX() + 2);\r\n this.range.add(new int[] {targetX, this.getY()});\r\n }\r\n }\r\n }\r\n }\r\n }", "public ArrayList<Coordinates> getHeroesPositions (){\n\t\tArrayList<Coordinates> path = new ArrayList<>();\n\t\tArrayList<Coordinates> coordinatePieces = chessboard.getTurnPieces();\n\t\tArrayList<Coordinates> threats = getThreats();\n\n\t\tfor ( Coordinates c : threats ){\n\t\t\tpath.add(c); //aggiungo la posizione dell'avversario\n\t\t\tif ( !(chessboard.at(c) instanceof Knight) )\n\t\t\t\tpath.addAll(chessboard.at(c).getPath(c, chessboard.getTurnKing())); //tutte le posizione in cui può andare\n\t\t}\n\t\t\n\t\tArrayList<Coordinates> result = new ArrayList<>();\n\t\t\tfor ( Coordinates c : coordinatePieces )\n\t\t\t\tfor ( Coordinates to : path)\n\t\t\t\t\tif ( !(chessboard.at(c) instanceof King) && checkMove(c, to) )\n\t\t\t\t\t\tresult.add(to);\n\t\treturn result;\n\t}", "private ArrayList<GridPiece> getDirectNeighbors(GridPiece piece) {\n neighbors.clear();\n\n //Top\n if (game.gridMap.size() > piece.row + 1) {\n neighbors.add(game.gridMap.get(piece.row + 1).get(piece.column));\n }\n //Bottom\n if (piece.row > 0) {\n neighbors.add(game.gridMap.get(piece.row - 1).get(piece.column));\n }\n\n //Right\n if (game.gridMap.get(0).size() > piece.column + 1) {\n neighbors.add(game.gridMap.get(piece.row).get(piece.column + 1));\n }\n\n //Left\n if (piece.column > 0) {\n neighbors.add(game.gridMap.get(piece.row).get(piece.column - 1));\n }\n\n return neighbors;\n }", "private List<BlockPoint> getReachablePositions(BlockType[][] chunk, List<BlockPoint> topPlattforms) throws\n\t IllegalStateException {\n\tList<BlockPoint> reachablePositions = new ArrayList<>();\n\t// For every upmost position find all reachable positions\n\tfor(BlockPoint pos : topPlattforms){\n\t // Transpose the highest position point into chunks coordinate system by placing\n\t // directly below the start of chunk.\n\t BlockPoint highPos = new BlockPoint(pos.x, -pos.y - 1);\n\t for(int c = 0; c < boardWidth; c++){\n\t\tfor(int r = 0; r < chunk.length; r++){\n\t\t BlockPoint pointInChunk = new BlockPoint(c,r);\n\t\t if(pointInChunk.distanceTo(highPos) <= MAX_DISTANCE && pointInChunk.distanceTo(highPos) >= minDistance){\n\t\t reachablePositions.add(pointInChunk);\n\t\t }\n\t\t}\n\t }\n\t}\n\tif(reachablePositions.isEmpty()){\n\t throw new IllegalStateException(\"No reachable positions exists\");\n\t}\n\treturn reachablePositions;\n }", "static Piece getPieceFromXY(float x, float y) {\n\t\t/* Coordinates are relative to the parent and the parent starts at (0,0)\n\t\t * Therefore, the first ImageView has coordinates of (0,0)\n\t\t * The layout of the ImageViews within the parent layout is as follows:\n\t\t * \n\t\t * (0,0)----------(width,0)----------(2*width,0)----------(3*width,0)\n\t\t *\t\t|\t\t\t\t |\t\t\t\t\t |\t\t\t\t\t |\n\t\t *\t\t|\t\t0\t\t |\t\t 1\t\t |\t\t\t2\t\t |\n\t\t *\t\t|\t\t\t\t |\t\t\t\t\t |\t\t\t\t\t |\n\t\t * (0,height)------(width,height)----(2*width,height)------(3*width,height)\n\t\t *\t\t|\t\t\t\t |\t\t\t\t\t |\t\t\t\t\t |\n\t\t *\t\t|\t\t3\t\t |\t\t 4\t\t |\t\t\t5\t\t |\n\t\t *\t\t|\t\t\t\t |\t\t\t\t\t |\t\t\t\t\t |\n\t\t * (0,2*height)---(width,2*height)---(2*width,2*height)---(3*width,2*height)\n\t\t *\t\t|\t\t\t\t |\t\t\t\t\t |\t\t\t\t\t |\n\t\t *\t\t|\t\t6\t\t |\t\t 7\t\t |\t\t\t8\t\t |\n\t\t *\t\t|\t\t\t\t |\t\t\t\t\t |\t\t\t\t\t |\n\t\t * (0,3*height)---(width,3*height)---(2*width,3*height)---(3*width,3*height)\n\t\t * \n\t\t */\n\t\t\n\t\tint i;\n\t\tfor (i=0; i<Play.NUM[TOTAL]; i++) {\n\t\t\tif ( (Play.pieceViewLocations.get(i)[0] == x) && (Play.pieceViewLocations.get(i)[1] == y)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn Play.jigsawPieces.get(i); //return the piece at the corresponding position\n\t}", "public ArrayList<Location> getMoveLocations(Piece p)\n {\n Location loc = getLocation(p);\n ArrayList<Location> locs = getCandidateLocations(loc);\n if (p==null)\n return null;\n for (int i = 0; i < locs.size(); i++)\n {\n if (canMoveTo(p,locs.get(i))==ILLEGAL_MOVE)\n {\n locs.remove(i);\n i--;\n }\n else\n {\n Board b = new Board(this);\n b.movePiece(loc,locs.get(i));\n if (b.findKing(p.getColor())!=null&&b.inCheck(p.getColor()))\n {\n locs.remove(i);\n i--;\n }\n }\n }\n return locs;\n }", "public abstract Collection<Piece> getActivePieces();", "public abstract Collection<Piece> getActivePieces();", "HashSet<Square> pieceLocations(Piece side) {\r\n assert side != EMPTY;\r\n HashSet<Square> squareSides = new HashSet<Square>();\r\n for (Square mapSquare : map.keySet()) {\r\n if (get(mapSquare) == side) {\r\n squareSides.add(mapSquare);\r\n }\r\n }\r\n return squareSides;\r\n }", "Iterator<BoardPosition> possibleMovingPositions(BoardPosition from, Game game, Map<BoardPosition, Piece> pieceMap);", "public ArrayList<Coordinates> getKingSafetyPositions (){\t\t\n\t\tArrayList<Coordinates> result = new ArrayList<>();\n\t\tCoordinates king = chessboard.getTurnKing();\n\t\t\n\t\tfor ( Coordinates c : chessboard.at(king).validPositions(king) ){\t\n\t\t\t\t\t\n\t\t\tif ( checkMove(king, c) ) {\n\t\t\t\t\n\t\t\t\tRules temp = new Rules(chessboard.move(king, c));\n\n\t\t\t\tif (!temp.kingOnCheck()){\n\t\t\t\t\tresult.add(c);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\treturn result;\n\t}", "private ArrayList<Location> getCandidateLocations(Location origin)\n {\n ArrayList<Location> locs = new ArrayList<>();\n Piece p = getPiece(origin);\n if (p==null)\n return locs;\n switch (p.getType())\n {\n case QUEEN:case ROOK:case BISHOP:\n locs = getLocations();break;\n case KNIGHT:case PAWN:case KING:\n locs = getLocationsWithin(getLocation(p),2);\n }\n return locs;\n }", "public List<Piece> allPieces();", "private ArrayList<Point> getNeighbors(Point p) {\n\t\tArrayList<Point> arr = new ArrayList<Point>();\n\t\tfor (int y = -1; y <= 1; y++) {\n\t\t\tfor (int x = -1; x <= 1; x++) {\n\t\t\t\tPoint npoint = new Point( p.x + x, p.y + y);\n\t\t\t\tint sind = spacesContains(npoint);\n\t\t\t\tif ( p.compareTo(npoint) != 0 && sind >= 0 ) { \n\t\t\t\t\tarr.add( spaces.get(sind) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn arr;\n\t}", "public void getTopLeft(List<Piece> moves){\n\t\t\n\t\tint pNum = PhiletoNum(this.phile);\n\t\tint rNum = this.rank;\n\t\twhile(pNum > 1 && rNum < 8){\n\t\t\tmoves.add(new Bishop(NumtoPhile(pNum - 1), rNum + 1));\n\t\t\tpNum -= 1;\n\t\t\trNum += 1;\n\t\t}\n\t}", "public ArrayList<NPPos> getNPPosition(){\n Iterator it = nextPanels.iterator();\n ArrayList<NPPos> listPositions = new ArrayList<>();\n while(it.hasNext()){\n listPositions.add((NPPos) positions.get(it.next()));\n }\n return listPositions;\n }", "public List<Piece> allPieces(){\n List<Piece> pieces = new ArrayList<>();\n for (int y = 0; y < 8; y++){\n for (int x = 0; x < 8; x++){\n int val = board[y][x];\n if (val != 0){\n pieces.add(new Piece(val,x,y));\n }\n }\n }\n return pieces;\n }", "public ArrayList<Piece> getPieces()\n {\n ArrayList<Piece> pieces = new ArrayList<>();\n for (Square[] s1: squares)\n {\n for (Square s: s1)\n {\n Piece p = s.getPiece();\n if (p!=null)\n pieces.add(p);\n }\n }\n return pieces;\n }", "public Position[] getWinningPositions();", "public Position findWeedPosition() {\n int x = 0;\n int y = 0;\n int sum = 0;\n for (int i = 0; i < this.WORLD.getMapSize().getX(); i++) {\n for (int j = 0; j < this.WORLD.getMapSize().getY(); j++) {\n\n //hogweed\n Organism organism = this.WORLD.getOrganism(i, j);\n if(organism!=null){\n Class c = organism.getClass();\n if (c.getSimpleName().equals(\"Parnsip\")) {\n int tmpX = Math.abs(this.position.getX() - i);\n int tmpY = Math.abs(this.position.getY() - j);\n if (!(sum==0)) {\n int tmpSum = tmpX + tmpY;\n if (sum > tmpSum) {\n x = i;\n y = j;\n sum = tmpSum;\n }\n }\n else {\n x = i;\n y = j;\n sum = tmpX + tmpY;\n\n }\n }\n }\n\n }\n }\n return new Position(x,y);\n }", "public void findShipPiece() {\r\n\t\tshipPiecesFound += 1;\r\n\t}", "public int getShipPieces() {\r\n\t\treturn shipPiecesFound;\r\n\t}", "public Collection<Position> getAccessiblePositions(Board board, Position position, Player player) throws BoardException{\r\n\t\t// collect directions ( when field is empty )\r\n\t\tCollection<Direction> directions=getDirections(position, player);\r\n\r\n\t\tCollection<Position> returnValue=new ArrayList<Position>();\r\n\t\t// analyze directions with other Pieces;\r\n\t\tfor(Direction eachDirection:directions){\r\n\t\t\tfor( Position nextStep: eachDirection.getPositions()){\r\n\t\t\t\tif(board.isEmpty(nextStep)){\r\n\t\t\t\t\treturnValue.add(nextStep);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tif(isFreeStyle()){\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn returnValue;\r\n\t}", "private void intElementCoordinates() throws InvalidLevelCharacterException, NoGhostSpawnPointException, NoPacmanSpawnPointException, NoItemsException {\n\n\t\tint ps = 0;// player spawn point counter\n\t\tint gs = 0;// ghost spawn point counter\n\t\tint item = 0;// item counter\n\t\t\n\t\t\tfor (int i = 0; i < height; i++) {\n\t\t\t\tfor (int j = 0; j < width; j++) {\n\t\t\t\t\t// j*MAPDENSITY as x coordinate, i*MAPDENSITY as y\n\t\t\t\t\t// coordinate\n\t\t\t\t\tfloat[] xy = { j * MAPDENSITY, i * MAPDENSITY };\n\t\t\t\t\t// add coordinates in to right category\n\t\t\t\t\tif (mapElementStringArray[i][j].equals(\"X\")) {\n\t\t\t\t\t\tmapElementArray[i][j] = new Wall(new Vector2f(xy), getWallType(\n\t\t\t\t\t\t\t\ti, j));\n\t\t\t\t\t} else if (mapElementStringArray[i][j].equals(\" \")) {\n\t\t\t\t\t\tmapElementArray[i][j] = new Dot(new Vector2f(xy), getForksForPacman(i, j), getForksForGhost(i, j));\n\t\t\t\t\t\tdots.add((Dot)mapElementArray[i][j]);\n\t\t\t\t\t\titem++;\n\t\t\t\t\t} else if (mapElementStringArray[i][j].equals(\"P\")) {\n\t\t\t\t\t\tmapElementArray[i][j] = new PlayerSpawnPoint(new Vector2f(xy), getForksForPacman(i, j), getForksForGhost(i, j));\n\t\t\t\t\t\tplayerSpawnPoints.add((PlayerSpawnPoint)mapElementArray[i][j]);\n\t\t\t\t\t\taPlayerSpawnPointRow=i;\n\t\t\t\t\t\taPlayerSpawnPointCol=j;\n\t\t\t\t\t\tps++;\n\t\t\t\t\t} else if (mapElementStringArray[i][j].equals(\"G\")) {\n\t\t\t\t\t\tmapElementArray[i][j] = new GhostSpawnPoint(new Vector2f(xy),getForksForPacman(i, j), getForksForGhost(i, j));\n\t\t\t\t\t\tghostSpawnPoints.add((GhostSpawnPoint)mapElementArray[i][j]);\n\t\t\t\t\t\tgs++;\n\t\t\t\t\t} else if (mapElementStringArray[i][j].equals(\"B\"))\n\t\t\t\t\t\tmapElementArray[i][j] = new InvisibleWall(new Vector2f(xy), getForksForPacman(i, j), getForksForGhost(i, j));\n\t\t\t\t\telse if (mapElementStringArray[i][j].equals(\"S\")) {\n\t\t\t\t\t\tmapElementArray[i][j] = new SpeedUp(new Vector2f(xy), getForksForPacman(i, j), getForksForGhost(i, j));\n\t\t\t\t\t\tspeedUps.add((SpeedUp)mapElementArray[i][j]);\n\t\t\t\t\t\titem++;\n\t\t\t\t\t} else if (mapElementStringArray[i][j].equals(\"T\")){\n\t\t\t\t\t\tmapElementArray[i][j] = new Teleporter(new Vector2f(xy),getForksForPacman(i, j), getForksForGhost(i, j));\n\t\t\t\t\t\tteleporters.add((Teleporter)mapElementArray[i][j]);\n\t\t\t\t\t}\n\t\t\t\t\telse if (mapElementStringArray[i][j].equals(\"U\")) {\n\t\t\t\t\t\tmapElementArray[i][j] = new PowerUp(new Vector2f(xy), getForksForPacman(i, j), getForksForGhost(i, j));\n\t\t\t\t\t\tpowerUps.add((PowerUp)mapElementArray[i][j]);\n\t\t\t\t\t\titem++;\n\t\t\t\t\t} else\n\t\t\t\t\t\t// thrwo invalidLevelCharacterException\n\t\t\t\t\t\tthrow new InvalidLevelCharacterException(\n\t\t\t\t\t\t\t\tmapElementStringArray[i][j].charAt(0));\n\n\t\t\t\t}\n\t\t\t}\n\t\t\t// check for PacmanSpawnPoint, GhostSpawnPoint and item exceptions\n\t\t\tif (gs == 0)\n\t\t\t\tthrow new NoGhostSpawnPointException();\n\t\t\tif (ps == 0)\n\t\t\t\tthrow new NoPacmanSpawnPointException();\n\t\t\tif (item == 0)\n\t\t\t\tthrow new NoItemsException();\n\t\t\n\t}", "public static Point[] init_starting_points(boolean red){\n \n Point corner = red ? Map.red_corner : Map.blue_corner;\n ArrayList<Point> list_points = new ArrayList<>();\n Point[] ret_points;\n for (int x = 0; x < MAP_HEIGHT; x++){\n for (int y = 0; y < MAP_WIDTH; y++){\n if (Point.distance(corner, x,y) < spawn_size ){\n\n boolean valid = true;\n for (int _x = x-2; _x < x+2 && valid; _x++){\n for (int _y = y-2; _y < y + 2 && valid; _y++){\n if (Point.distance(x,y,_x,_y) > 2)\n continue;\n try {\n if (global_map[_x][_y] != Terrain.GRASS)\n valid = false;\n\n }\n catch (Exception e){\n valid = false;\n }\n }\n }\n\n if (valid)\n list_points.add(new Point(x,y));\n\n }\n }\n }\n \n \n ret_points = new Point[list_points.size()];\n ret_points = list_points.toArray(ret_points);\n return ret_points;\n\n }", "@Test\n public void shouldBeAbleToInitializeWithPieces() {\n Player p1 = new Player(ChessPieceColor.WHITE, position);\n Player p2 = new Player(ChessPieceColor.BLACK, position);\n for (int i = 0; i < position.getSize(); i++) {\n Assert.assertNotNull(position.getPieceAtPosition(i, 0)); // Regular pieces\n Assert.assertNotNull(position.getPieceAtPosition(i, 1)); // Pawns\n Assert.assertNotNull(position.getPieceAtPosition(i, 7)); // Regular pieces\n Assert.assertNotNull(position.getPieceAtPosition(i, 6)); // Pawns\n }\n }", "public List<Position> getPositions(){\r\n List<Position> listPosition = new ArrayList();\r\n int row=currentPosition.getRow(),column=currentPosition.getColumn();\r\n listPosition=getPositionFor(row, column, listPosition);\r\n return listPosition;\r\n }", "public List<Vector2f> getPlayerStartPositions() {\n \n List<Vector2f> list = new ArrayList();\n PlayerStart[] points = getPlayerStartingPoints();\n \n if(points == null || points.length <= 0) {\n return list;\n }\n \n for(int i = 0; i < points.length; i++) {\n PlayerStart p = points[i];\n list.add(new Vector2f( p.x, p.y ));\n }\n \n return list;\n \n }", "pieces getPiece(int position)\n {\n int j ;\n if(position == whiteHorse1.position && whiteHorse1.alive == true ) return whiteHorse1;\n if(position == whiteHorse2.position && whiteHorse2.alive == true) return whiteHorse2;\n if(position == whiteQueen.position && whiteQueen.alive == true ) return whiteQueen;\n if(position == whiteKing.position && whiteKing.alive == true) return whiteKing;\n if(position == whiteCastle1.position && whiteCastle1.alive == true ) return whiteCastle1;\n if(position == whiteCastle2.position && whiteCastle2.alive == true) return whiteCastle2;\n if(position == whiteBishop1.position && whiteBishop1.alive == true) return whiteBishop1;\n if(position == whiteBishop2.position && whiteBishop2.alive == true) return whiteBishop2;\n j=0;\n if(position == whitePawn[j].position && whitePawn[j].alive == true) return whitePawn[j];j++;\n if(position == whitePawn[j].position && whitePawn[j].alive == true) return whitePawn[j];j++;\n if(position == whitePawn[j].position && whitePawn[j].alive == true) return whitePawn[j];j++;\n if(position == whitePawn[j].position && whitePawn[j].alive == true) return whitePawn[j];j++;\n if(position == whitePawn[j].position && whitePawn[j].alive == true) return whitePawn[j];j++;\n if(position == whitePawn[j].position && whitePawn[j].alive == true) return whitePawn[j];j++;\n if(position == whitePawn[j].position && whitePawn[j].alive == true) return whitePawn[j];j++;\n if(position == whitePawn[j].position && whitePawn[j].alive == true) return whitePawn[j];\n \n \n \n if(position == blackHorse1.position && blackHorse1.alive == true ) return blackHorse1;\n if(position == blackHorse2.position && blackHorse2.alive == true) return blackHorse2;\n if(position == blackQueen.position && blackQueen.alive == true ) return blackQueen;\n if(position == blackKing.position && blackKing.alive == true) return blackKing;\n if(position == blackCastle1.position && blackCastle1.alive == true ) return blackCastle1;\n if(position == blackCastle2.position && blackCastle2.alive == true) return blackCastle2;\n if(position == blackBishop1.position && blackBishop1.alive == true) return blackBishop1;\n if(position == blackBishop2.position && blackBishop2.alive == true) return blackBishop2;\n j=0;\n if(position == blackPawn[j].position && blackPawn[j].alive == true) return blackPawn[j];j++;\n if(position == blackPawn[j].position && blackPawn[j].alive == true) return blackPawn[j];j++;\n if(position == blackPawn[j].position && blackPawn[j].alive == true) return blackPawn[j];j++;\n if(position == blackPawn[j].position && blackPawn[j].alive == true) return blackPawn[j];j++;\n if(position == blackPawn[j].position && blackPawn[j].alive == true) return blackPawn[j];j++;\n if(position == blackPawn[j].position && blackPawn[j].alive == true) return blackPawn[j];j++;\n if(position == blackPawn[j].position && blackPawn[j].alive == true) return blackPawn[j];j++;\n if(position == blackPawn[j].position && blackPawn[j].alive == true) return blackPawn[j];\n\n else return null;\n }", "private vPiece find_vPiece(ArrayList<vPiece> pieces, Move theMove){\n\t\tfor(vPiece thePiece : pieces){\n\t\t\tif(thePiece.getxLoc() == theMove.i){\n\t\t\t\tif(thePiece.getyLoc() == theMove.j){\n\t\t\t\t\treturn thePiece;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn new vPiece(0,0);\n\t}", "public List<TicTacToeCoordinates> getAvailableSpots() {\n List<TicTacToeCoordinates> openSpots = new ArrayList<>();\n for (int x = 0; x < boardLength; x++) {\n for (int y = 0; y < boardWidth; y++) {\n if (board[x][y] == '\\u0000') {\n openSpots.add(new TicTacToeCoordinates(x, y));\n }\n }\n }\n return openSpots;\n }", "public static int[] getStartPosition(char piece, char color, int startFile,\n int startRank, int endFile, int endRank, boolean capture) {\n String piecePlusColor =\n Character.toString(piece) + Character.toString(color);\n\n int[][] piecePos = getPiecePositions(piecePlusColor, startFile,\n startRank);\n int[] startPos = null;\n\n if (piece == 'P') {\n startPos = getPawnStart(piecePos, color, endFile, endRank, capture);\n } else if (piece == 'R') {\n startPos = getRookStart(piecePos, endFile, endRank);\n } else if (piece == 'N') {\n startPos = getKnightStart(piecePos, endFile, endRank);\n } else if (piece == 'B') {\n startPos = getBishopStart(piecePos, endFile, endRank);\n } else if (piece == 'Q') {\n startPos = getQueenStart(piecePos, endFile, endRank);\n } else if (piece == 'K') {\n startPos = piecePos[0];\n }\n\n return startPos;\n }", "public List<Piece> getPieces() {\n\t\treturn this.pieces;\n\t}", "public CopyOnWriteArrayList<Point> \tgetOccupiedPositions() \t\t\t \t\t\t{ return this.occupiedPositions; }", "public Iterable<Point2D> range(RectHV rect) {\n if (rect == null) throw new IllegalArgumentException(\n \"Null pointer provided instead of a query rectangle\");\n ptsInside = new SET<Point2D>();\n searchForPoints(root, rect);\n return ptsInside;\n }", "public HashMap<Integer, Piece> getPieces() {\n return pieces;\n }", "Iterable<Position<E>> positions();", "public PlayerStart[] getPlayerStartingPoints() {\n if(mPlayerStartList == null) {\n generate();\n }\n return mPlayerStartList;\n }", "public ArrayList<Coordinate> getPossibleMoveCoordinate() {\n ChessBoard board = this.getChessBoard(); // get chess board\n ArrayList<Coordinate> coords = new ArrayList<Coordinate>(); // create return ArrayList\n int x, y;\n /*\n several cases\n 2 3\n 1 4\n\n 5 8\n 6 7\n\n */\n // case1\n x = this.x_coordinate - 2;\n y = this.y_coordinate + 1;\n if(x >= 0 && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case2\n x = this.x_coordinate - 1;\n y = this.y_coordinate + 2;\n if(x >= 0 && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case3\n x = this.x_coordinate + 1;\n y = this.y_coordinate + 2;\n if(x < board.getWidth() && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case4\n x = this.x_coordinate + 2;\n y = this.y_coordinate + 1;\n if(x < board.getWidth() && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case5\n x = this.x_coordinate - 2;\n y = this.y_coordinate - 1;\n if(x >= 0 && y >= 0 ){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case6\n x = this.x_coordinate - 1;\n y = this.y_coordinate - 2;\n if(x >= 0 && y >= 0){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case7\n x = this.x_coordinate + 1;\n y = this.y_coordinate - 2;\n if(x < board.getWidth() && y >= 0){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case1\n x = this.x_coordinate + 2;\n y = this.y_coordinate - 1;\n if(x < board.getWidth() && y >= 0){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n\n\n return coords;\n }", "public ArrayList<Coordinates> getSafetyPositions(Coordinates c){\n\t\tif (chessboard.at(c) instanceof King)\n\t\t\treturn getKingSafetyPositions();\t\t\n\t\t\n\t\treturn getHeroesPositions();\n\t}", "@Override\n\tpublic List<Coordonnees> getPosMines() {\n\t\treturn null;\n\t}", "public static List<InitialUnit> getStartingPositions (Scanner sc) {\n List<InitialUnit> res = new ArrayList<InitialUnit>();\n int n = sc.nextInt();\n for (int i = 0; i < n; i++) {\n res.add(InitialUnit.loadFrom(sc));\n }\n return res;\n }", "public static int[] getPawnStart(int[][] piecePos, char color, int endFile,\n int endRank, boolean capture) {\n if (capture) {\n // En Passant\n int direction = color == 'w' ? 1 : -1;\n\n if (getBoardStateSquare(endFile, endRank).equals(\" \")) {\n for (int[] pos: piecePos) {\n if (endRank == pos[1] + direction) {\n int[] startPos = {pos[0], pos[1]};\n move(\" \", endFile, endRank, endFile, pos[1]);\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n }\n\n }\n\n for (int[] pos: piecePos) {\n if (endRank == pos[1] + direction) {\n int[] startPos = {pos[0], pos[1]};\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n }\n }\n\n for (int[] pos: piecePos) {\n if (pos[0] == endFile) {\n int direction = color == 'w' ? 1 : -1;\n\n if (pos[1] + direction == endRank) {\n int[] startPos = {pos[0], pos[1]};\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n\n if (pos[1] + 2 * direction == endRank) {\n boolean correct = true;\n\n for (int r = 0; r < Math.abs(pos[1] - endRank) - 1; r++) {\n if (!getBoardStateSquare(endFile,\n Math.abs(r + direction * pos[1] + 1))\n .equals(\" \")) {\n correct = false;\n\n break;\n }\n }\n\n if (correct) {\n int[] startPos = {pos[0], pos[1]};\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n }\n }\n }\n\n return null;\n }", "public Piece[] getPiecePlacement() throws RemoteException {\n\t\t\treturn piecePlacement;\n\t\t}", "public PawnIterator getPawns(){\n\t\treturn new PawnIterator(pawns);\n\t}", "public Queue<Point> getPoints() {\n\tQueue<Point> iter = new Queue<Point>();\n\tfor (Shape s : this.shapes) {\n\t for (Point p : s.getPoints())\n\t\titer.enqueue(p);\n\t}\n\n\treturn iter;\n }", "public ArrayList<Piece> getPieces() {\n\treturn pieces;\n }", "public static ArrayList<XYCoord> findVisibleLocations(GameMap map, XYCoord origin, int range, boolean piercing)\n {\n ArrayList<XYCoord> locations = new ArrayList<XYCoord>();\n\n // Loop through all the valid x and y offsets, as dictated by the max range, and add valid spaces to our collection.\n for( int yOff = -range; yOff <= range; ++yOff )\n {\n for( int xOff = -range; xOff <= range; ++xOff )\n {\n int currentRange = Math.abs(xOff) + Math.abs(yOff);\n XYCoord coord = new XYCoord(origin.xCoord + xOff, origin.yCoord + yOff);\n if( currentRange <= range && map.isLocationValid(coord) )\n {\n // If we're adjacent, or we can see through cover, or it's *not* cover, we can see into it.\n if( piercing || !map.getEnvironment(coord).terrainType.isCover() )\n {\n // Add this location to the set.\n locations.add(coord);\n }\n }\n }\n }\n\n return locations;\n }", "public List<PuzzleInstance> generateInstance() {\n\n final String[] POSITION = {\"Up\", \"Down\", \"Left\", \"Right\"};// In this order\n List<PuzzleInstance> puzzleInstances = new ArrayList<>();\n\n for (String traverse : POSITION) {\n int tempI=-1, tempJ=-1;\n switch (traverse) {\n case \"Up\":\n tempI = row - 1; \n tempJ = coloum;\n break;\n case \"Down\":\n tempI = row + 1; \n tempJ = coloum;\n break;\n case \"Left\":\n tempI = row; \n tempJ = coloum - 1;\n break;\n case \"Right\":\n tempI = row; \n tempJ = coloum + 1;\n break;\n }\n \n if((tempI < 0 || tempJ <0)|| (tempI >= rowColoumSize || tempJ >=rowColoumSize )){\n System.out.println(\"Out of bound\");\n // skip it nothing to add in the list\n }else{\n final Integer[][] puzzleGenerator = cloneArray(puzzle); \n int temp = puzzleGenerator [tempI][tempJ];\n puzzleGenerator[tempI][tempJ] = 0;\n puzzleGenerator[row][coloum] = temp;\n \n PuzzleInstance puzzleInstance = new PuzzleInstance(cloneArray(puzzleGenerator),rowColoumSize,cost_of_path+1,traverse, this);\n puzzleInstances.add(puzzleInstance); \n }\n }\n\n return puzzleInstances;\n \n \n }", "public Position[] getSpawningPositions()\r\n {\r\n return concatArrays(metro.symbolPositions(' '), metro.symbolPositions('X'));\r\n }", "public HashSet<Position> getCoveredPos() { return coveredPos; }", "public Set<Move> getMovesForPlayer(Player player) {\n\t\tfinal Set<Move> moveList = new HashSet<Move>();\n\t\tfor (Map.Entry<Position, Piece> entry : positionToPieceMap.entrySet()) {\n\t\t\tfinal Position positionFrom = entry.getKey();\n\t\t\tfinal Piece piece = entry.getValue();\n\t\t\tif (player == piece.getOwner()) {\n\t\t\t\tfor (char column = Position.MIN_COLUMN; column <= Position.MAX_COLUMN; column++) {\n\t\t\t\t\tfor (int row = Position.MIN_ROW; row <= Position.MAX_ROW; row++) {\n\t\t\t\t\t\tfinal Position positionTo = new Position(column, row);\n\t\t\t\t\t\tif (!positionFrom.equals(positionTo)) {\n\t\t\t\t\t\t\tfinal Piece possiblePieceOnPosition = getPieceAt(positionTo);\n\t\t\t\t\t\t\tif (possiblePieceOnPosition == null || possiblePieceOnPosition.getOwner() != player) { //can move to free position \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t //or position where enemy is placed\n\t\t\t\t\t\t\t\tif (piece instanceof Pawn) {\n\t\t\t\t\t\t\t\t\tPawn pawn = (Pawn) piece;\n\t\t\t\t\t\t\t\t\tpawn.isValidFightMove(positionFrom, positionTo);\n\t\t\t\t\t\t\t\t\tmoveList.add(new Move(positionFrom, positionTo));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfinal boolean isKnight = (piece instanceof Knight); // knight can jump over sheets\n\t\t\t\t\t\t\t\tif (piece.isValidMove(positionFrom, positionTo) && !isBlocked(positionFrom, positionTo, isKnight)) {\n\t\t\t\t\t\t\t\t\tmoveList.add(new Move(positionFrom, positionTo));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn moveList;\n\t}", "public ArrayList<Point> moves() {\n\t\tmoves = new ArrayList<Point>();\n\t\tif (point.x > 0 && board.pieceAt(point.x - 1, point.y) == null)\n\t\t\tmoves.add(board.left(point));\n\t\tif (point.x < board.getXDim() - 1 && board.pieceAt(point.x + 1, point.y) == null)\n\t\t\tmoves.add(board.right(point));\n\t\tif (point.y > 0 && board.pieceAt(point.x, point.y - 1) == null)\n\t\t\tmoves.add(board.above(point));\n\t\tif (point.y < board.getYDim() - 1 && board.pieceAt(point.x, point.y + 1) == null)\n\t\t\tmoves.add(board.below(point));\n\t\treturn (ArrayList<Point>) moves.clone();\n\t}", "public ArrayList<GamePiece> getGamePiecesAtLocation(Location loc)\n\t{\n\t\tArrayList<GamePiece> pieceLocation = new ArrayList<GamePiece>();\n\t\tfor(String name: getPlayersAtLocation(loc))\n\t\t{\n\t\t\tpieceLocation.add(getPlayerGamePiece(name));\n\t\t}\n\t\treturn pieceLocation;\n\t}", "Collection<Point> getAllCoordinates();", "protected abstract int[][] getPossiblePositions();", "public Position findWeed() {\n int xVec =0;\n int yVec=0;\n int sum = 0;\n Position move = new Position(0, 0);\n for (int i = 0; i < this.WORLD.getMapSize().getX(); i++) {\n for (int j = 0; j < this.WORLD.getMapSize().getY(); j++) {\n\n //hogweed\n Organism organism = this.WORLD.getOrganism(i, j);\n if(organism!=null){\n Class c = organism.getClass();\n if (c.getSimpleName().equals(\"Parnsip\")) {\n int tmpX = Math.abs(this.position.getX() - i);\n int tmpY = Math.abs(this.position.getY() - j);\n if (!(xVec == 0 && yVec == 0)) {\n int tmpSum = tmpX + tmpY;\n if (sum > tmpSum) {\n xVec=tmpX;\n yVec=tmpY;\n sum = tmpSum;\n this.setMove(move, j, i);\n }\n }\n else {\n xVec=tmpX;\n yVec=tmpY;\n sum = tmpX + tmpY;\n this.setMove(move, j, i);\n }\n }\n }\n\n }\n }\n return move;\n }", "private int[] defineStartingPos() {\n\t\tint[] positions = new int[4];\n\t\tif(initPos.equals(UP)) {\n\t\t\tpositions[0] = 0;\n\t\t\tpositions[1] = (size-1)/2;\n\t\t\tpositions[2] = 1;\n\t\t}else if(initPos.equals(DOWN)) {\n\t\t\tpositions[0] = size-1;\n\t\t\tpositions[1] = (size-1)/2;\n\t\t\tpositions[2] = -1;\n\t\t}else if(initPos.equals(LEFT)) {\n\t\t\tpositions[0] = (size-1)/2;\n\t\t\tpositions[1] = 0;\n\t\t\tpositions[3] = 1;\n\t\t}else if(initPos.equals(RIGHT)) {\n\t\t\tpositions[0] = (size-1)/2;\n\t\t\tpositions[1] = size-1;\n\t\t\tpositions[3] = -1;\n\t\t}\n\t\treturn positions;\n\t}", "public Array<Point> allOuterPoints() {\r\n \tArray<Point> innerPoints = innerPiece.getPoints();\r\n Array<Point> outerPoints = new Array<Point>();\r\n for (Point inner : innerPoints) {\r\n outerPoints.add(toOuterPoint(inner));\r\n }\r\n return outerPoints;\r\n }", "public Piece getPieceAt(Position position) {\n return positionToPieceMap.get(position);\n }", "static ArrayList<Piece> createPieces (Bitmap image) {\n\t\tint[] picSize = InitDisplay.getPicDimensions();\n\t\tint[] pieceSize = InitDisplay.getPieceDimensions();\n\t\t\n\t\t/* Scale the image to the dynamically calculated values */\n\t\tBitmap imageScaled = Bitmap.createScaledBitmap(image, picSize[WIDTH], picSize[HEIGHT], false);\n\t\t\n\t\t/* The imageScaled bitmap now contains the given image in scaled bitmap form. Break it and\n\t\t * assign it to [rows*cols] small Jigsaw pieces after randomizing their positions and orientations\n\t\t * The image is being broken into a 3x3 grid. i represents rows while j represents columns */\n\t\t\n\t\tArrayList<Piece> pieces = new ArrayList<Piece>(Play.NUM[TOTAL]);\n\t\tBitmap imgPiece = null;\n\t\tint offsetX = 0, offsetY = 0;\n\t\tint pos = 0;\n\t\t\n\t\tfor (int i=0; i<Play.NUM[COLS]; i++) {\n\t\t\t/* offsetX represents the x coordinate while offsetY represents the y coordinate */\n\t\t\toffsetX = 0; //start from (0,0)\n\t\t\tfor (int j=0; j<Play.NUM[ROWS]; j++) {\n\t\t\t\t/* Extract a specific area of the imageScaled bitmap and store it in imgPiece.\n\t\t\t\t * Coordinates for the extraction are specified using offsetX and offsetY */\n\t\t\t\timgPiece = Bitmap.createBitmap\n\t\t\t\t\t\t(imageScaled, offsetX, offsetY, pieceSize[WIDTH], pieceSize[HEIGHT]);\n\t\t\t\t\n\t\t\t\t/* Create a Jigsaw piece and add it to the pieces array */\n\t\t\t\tPiece piece = new Piece (imgPiece); //create a new piece with the extracted bitmap image\n\t\t\t\tpieces.add(pos, piece); //add the piece to the pieces array\n\t\t\t\t\n\t\t\t\toffsetX += pieceSize[WIDTH]; //move to the next x coordinate\n\t\t\t\tpos++;\n\t\t\t}\n\t\t\toffsetY += pieceSize[HEIGHT]; //move to the next y coordinate\n\t\t}\n\t\t\n\t\treturn pieces;\n\t}", "public Iterable<Point2D> range(RectHV rect) {\n\n if (rect == null)\n throw new IllegalArgumentException(\"Got null object in range()\");\n \n Queue<Point2D> pointsInside = new Queue<>();\n \n for (Point2D p : point2DSET) {\n \n double x = p.x();\n double y = p.y();\n if (x >= rect.xmin() && x <= rect.xmax() &&\n y >= rect.ymin() && y <= rect.ymax())\n pointsInside.enqueue(p);\n \n }\n \n return pointsInside;\n }", "Piece[][] getPieces() {\n return _pieces;\n }", "public final void initialPosition() {\n\t\tfor( int i = 0; i < 4; i++) {\n\t\t setPiece( new PieceImpl( Color.RED, Type.PAWN), new PositionImpl( 38 + 8*i));\n\t\t}\n\t\tfor( int i = 0; i < 4; i++) {\n\t\t setPiece( new PieceImpl( Color.BLACK, Type.PAWN), new PositionImpl( 12 + i));\n\t\t}\n\t\tfor( int i = 0; i < 4; i++) {\n\t\t setPiece( new PieceImpl( Color.YELLOW, Type.PAWN), new PositionImpl( 1 + 8*i));\n\t\t}\n\t\tfor( int i = 0; i < 4; i++) {\n\t\t setPiece( new PieceImpl( Color.GREEN, Type.PAWN), new PositionImpl( 48 + i));\n\t\t}\n\t\t\n\t\tsetPiece( new PieceImpl( Color.RED, Type.BOAT), new PositionImpl( 63 ));\n\t\tsetPiece( new PieceImpl( Color.RED, Type.KNIGHT), new PositionImpl( 55 ));\n\t\tsetPiece( new PieceImpl( Color.RED, Type.ELEPHANT), new PositionImpl( 47 ));\n\t\tsetPiece( new PieceImpl( Color.RED, Type.KING), new PositionImpl( 39 ));\n\t\t\n\t\tsetPiece( new PieceImpl( Color.BLACK, Type.BOAT), new PositionImpl( 7 ));\n\t\tsetPiece( new PieceImpl( Color.BLACK, Type.KNIGHT), new PositionImpl( 6 ));\n\t\tsetPiece( new PieceImpl( Color.BLACK, Type.ELEPHANT), new PositionImpl( 5 ));\n\t\tsetPiece( new PieceImpl( Color.BLACK, Type.KING), new PositionImpl( 4 ));\n\n\t\tsetPiece( new PieceImpl( Color.YELLOW, Type.BOAT), new PositionImpl( 0 ));\n\t\tsetPiece( new PieceImpl( Color.YELLOW, Type.KNIGHT), new PositionImpl( 8 ));\n\t\tsetPiece( new PieceImpl( Color.YELLOW, Type.ELEPHANT), new PositionImpl( 16 ));\n\t\tsetPiece( new PieceImpl( Color.YELLOW, Type.KING), new PositionImpl( 24 ));\n\n\t\tsetPiece( new PieceImpl( Color.GREEN, Type.BOAT), new PositionImpl( 56 ));\n\t\tsetPiece( new PieceImpl( Color.GREEN, Type.KNIGHT), new PositionImpl( 57 ));\n\t\tsetPiece( new PieceImpl( Color.GREEN, Type.ELEPHANT), new PositionImpl( 58 ));\n\t\tsetPiece( new PieceImpl( Color.GREEN, Type.KING), new PositionImpl( 59 ));\n\t\t\n }", "@Override\n public int[] getPositionWorker() {\n return godPower.getPositionWorker();\n }", "public static int[] getKnightStart(int[][] piecePos, int endFile,\n int endRank) {\n for (int[] pos: piecePos) {\n if ((pos[0] + 1 == endFile || pos[0] - 1 == endFile)\n && (pos[1] + 2 == endRank || pos[1] - 2 == endRank)) {\n int[] startPos = {pos[0], pos[1]};\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n } else if ((pos[0] + 2 == endFile || pos[0] - 2 == endFile)\n && (pos[1] + 1 == endRank\n || pos[1] - 1 == endRank)) {\n int[] startPos = {pos[0], pos[1]};\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n }\n\n return null;\n }", "@Test\n public void testGetPawnPositionsAround() {\n assertNotNull(this.board.getPawnPositionsAround(Pawn.ZEN));\n assertNotNull(this.board.getPawnPositionsAround(Pawn.RED));\n assertNotNull(this.board.getPawnPositionsAround(Pawn.RED));\n }", "List<Coord> allActiveCells();", "public static int[] getRookStart(int[][] piecePos, int endFile,\n int endRank) {\n for (int[] pos: piecePos) {\n boolean correct = true;\n\n if (pos[0] == endFile) {\n int direction = (endRank - pos[1]) / Math.abs(endRank - pos[1]);\n\n for (int r = 0; r < Math.abs(pos[1] - endRank) - 1; r++) {\n if (!getBoardStateSquare(endFile,\n Math.abs(r + direction * pos[1] + 1))\n .equals(\" \")) {\n correct = false;\n\n break;\n }\n }\n\n if (correct) {\n int[] startPos = {pos[0], pos[1]};\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n }\n\n if (pos[1] == endRank) {\n correct = true;\n\n int direction = (endFile - pos[0]) / Math.abs(endFile - pos[0]);\n\n for (int f = 0; f < Math.abs(pos[0] - endFile) - 1; f++) {\n if (!getBoardStateSquare(Math.abs(\n f + direction * pos[0] + 1), endRank)\n .equals(\" \")) {\n correct = false;\n\n break;\n }\n }\n\n if (correct) {\n int[] startPos = {pos[0], pos[1]};\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n }\n }\n\n return null;\n }", "private Point findStartPoint(){\n Point min = points.get(0);\n for (int i = 1; i < points.size(); i++) {\n min = getMinValue(min, points.get(i));\n }\n return min;\n }", "static ArrayList<int[]> searcherTopLeftTiles(ArrayList<int[]> MoveList,int CurrentX, int CurrentY){\n\t\t\n\t\tfor(int j = 1; j <=7 ; j++){\n\t\t\tint [] NewXY = new int[2];\n\t\t\tNewXY[0] = CurrentX - j;\n\t\t\tNewXY[1] = CurrentY - j;\n\t\t\t\n\t\t\tif(NewXY[0] < 0 || NewXY[1] < 0){\n\t\t\t\treturn MoveList;\n\t\t\t}\n\t\t\t\n\n\t\t\tfor(int [] i: aggregateBlacks()){\n\t\t\t\tint[] Coordinate = i;\n\t\t\t\tif(Arrays.equals(Coordinate, NewXY)){\n\t\t\t\t\t//System.out.println(\"We have found a valid black piece to kill \" + j + \" tiles top left of this bishop\");\n\t\t\t\t\tMoveList.add(NewXY);\n\t\t\t\t\treturn MoveList;\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t\tfor(int [] i: aggregateWhites()){\n\t\t\t\tint[] Coordinate = i;\n\t\t\t\tif(Arrays.equals(Coordinate, NewXY)){\n\t\t\t\t\t//System.out.println(\"We have found a white piece \" + j + \" tiles top of this Queen\");\n\t\t\t\t\treturn MoveList;\n\t\t\t\t}\t\t\n\t\t\t}\t\n\t\t\tMoveList.add(NewXY);\n\t\t}\n\t\treturn MoveList;\n\t}", "public ArrayList<Particle> getNearParticles(Complex p, int range)\n\t{\n\t\tint cellX = (int)Math.floor(p.re() / meshWidth);\n\t\tint cellY = (int)Math.floor(p.im() / meshWidth);\n\t\treturn proximityList[cellX][cellY];\n\t}", "public List<Point> generatePointList(){\r\n\t\t//Can move up to 3 squares horizontally or vertically, but cannot move diagonally.\r\n List<Point> pointList = new ArrayList<>();\r\n int pointCount = 0;\r\n int px = (int)getCoordinate().getX();\r\n int py = (int)getCoordinate().getY();\r\n\r\n for (int i=px-3;i<=px+3;i++){\r\n for(int j=py-3;j<=py+3;j++){\r\n if((i>=0) && (i<9) && (j>=0) && (j<9) && ((i!=px)||(j!=py))){\r\n if ((i==px)||(j==py)){\r\n pointList.add(pointCount, new Point(i,j));\r\n pointCount+=1;\r\n } \r\n }\r\n }\r\n }\r\n return pointList;\r\n }", "private void setPoints () {\n\t\tArrayList<Point> emptySpot = new ArrayList<Point>();\n\t\tfor (int i = 0; i < width; i++) {\n\t\t\tfor (int j = 0; j < height; j++) {\n\t\t\tif (maze[i][j] == 0) {\n\t\t\t\temptySpot.add(new Point (i, j));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tCollections.shuffle(emptySpot);\n\t\tthis.goal = emptySpot.get(0);\n\t\tdouble goalRange = this.goal.getX() + this.goal.getY();\n\t\tfor (int i = 1; i < emptySpot.size(); i++) {\n\t\t\tPoint playerStart = emptySpot.get(i);\n\t\t\tdouble playerRange = playerStart.getX() + playerStart.getY();\n\t\t\tif (Math.abs(playerRange - goalRange) > width/2)\n\t\t\tthis.playerStart = playerStart;\n\t\t}\n\t}", "public void createPieces(){ \n\t\tfor(int x = 0; x<BOARD_LENGTH; x++){\n\t\t\tfor(int y = 0; y<BOARD_LENGTH; y++){ \n\t\t\t\tif(CHESS_MAP[x][y] != (null)){\n\t\t\t\t\tswitch (CHESS_MAP[x][y]){\n\t\t\t\t\tcase KING:\n\t\t\t\t\t\tpieces[pieceCounter] = new King(pieceCounter, new Point(x+1,y+1), new Point(0,0), true, true, BOARD_PIECE_LENGTH, true);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase QUEEN:\n\t\t\t\t\t\tpieces[pieceCounter] = new Queen(pieceCounter, new Point(x+1,y+1), new Point(0,0), true, true, BOARD_PIECE_LENGTH, true);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase BISHOP:\n\t\t\t\t\t\tpieces[pieceCounter] = new Bishop(pieceCounter, new Point(x+1,y+1), new Point(0,0), true, true, BOARD_PIECE_LENGTH, true);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase KNIGHT:\n\t\t\t\t\t\tpieces[pieceCounter] = new Knight(pieceCounter, new Point(x+1,y+1), new Point(0,0), true, true, BOARD_PIECE_LENGTH, true);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase PAWN:\n\t\t\t\t\t\tpieces[pieceCounter] = new Pawn(pieceCounter, new Point(x+1,y+1), new Point(0,0), true, true, BOARD_PIECE_LENGTH, true);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ROOK:\n\t\t\t\t\t\tpieces[pieceCounter] = new Rook(pieceCounter, new Point(x+1,y+1), new Point(0,0), true, true, BOARD_PIECE_LENGTH, true);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} \n\t\t\t\t\tsetPieceIconAndName(x, y, CHESS_MAP[x][y]); \t\n\t\t\t\t\tpieceCounter++;\n\t\t\t\t}else{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} \n\t}", "void positionToStart () {\n currentRow = 0 - currentPiece.getOffset();\n currentColumn = board.columns / 2 - currentPiece.width / 2;\n }", "public List<Long> getPatternOccurrencePositions() {\n if(!hasFinished()) {\n throw new IllegalArgumentException(\"the recompression is not jet ready.\");\n }\n S terminal = slp.get(getPattern().getLeft(), 1);\n if(matchingBlocks) {\n return getBlockOccurrencePositions(terminal);\n }\n else {\n return getNonBlockOccurrencePositions(terminal);\n }\n }", "public LinkedList<Point> segmentsToDraw() {\n LinkedList<Point> segmentCoordinates = new LinkedList<Point>();\n for (int segment = 1; segment <= snakeSize; segment++) {\n //search array for each segment number\n for (int x = 0; x < maxX; x++) {\n for (int y = 0; y < maxY; y++) {\n if (snakeSquares[x][y] == segment) {\n //make a Point for this segment's coordinates and add to list\n Point p = new Point(x * SnakeGame.getSquareSize(), y * SnakeGame.getSquareSize());\n segmentCoordinates.add(p);\n }\n }\n }\n }\n return segmentCoordinates;\n\n }", "public ArrayList<Location> getMoveLocations()\n {\n ArrayList<Location> locs = new ArrayList<Location>();\n ArrayList<Location> validLocations = getGrid().getValidAdjacentLocations(getLocation());\n for (Location neighborLoc : validLocations)\n {\n if (getGrid().get(neighborLoc) == null || getGrid().get(neighborLoc) instanceof AbstractPokemon || getGrid().get(neighborLoc) instanceof PokemonTrainer)\n locs.add(neighborLoc);\n }\n return locs;\n }", "@Test\n public void testGetPossibleMoveCoordinate() throws Exception{\n ChessBoard board = new ChessBoard(8, 8);\n Piece p;\n\n p = new Pawn(board, Player.WHITE);\n p.setCoordinate(0, 0);\n assertEquals(2, p.getPossibleMoveCoordinate().size()); // first time move, therefore it should be able to advance two squares.\n\n\n p.setCoordinate(0, 1);\n assertEquals(1, p.getPossibleMoveCoordinate().size()); // already moved, therefore it could move two squares.\n\n\n /*\n * create a pawn in same group\n * put it ahead p, then p couldn't move\n */\n Piece friend = new Pawn(board, Player.WHITE);\n friend.setCoordinate(0, 2);\n assertEquals(0, p.getPossibleMoveCoordinate().size());\n\n /*\n * create an opponent piece at top right\n * therefore, p can move top right\n */\n Piece opponent_piece = new Pawn(board, Player.BLACK);\n opponent_piece.setCoordinate(1, 2);\n assertEquals(1, p.getPossibleMoveCoordinate().size());\n\n /*\n * p reaches top boundary\n */\n p.setCoordinate(0, 7);\n assertEquals(0, p.getPossibleMoveCoordinate().size());\n }", "public List<Position> getFoodPositions() {\n List<Position> positions = new ArrayList<>();\n\n for (int i = 0; i < amount; i++) {\n positions.add(foodPositions[i]);\n }\n return positions;\n }", "public List<Position> getPositions() {\n List<Position> listPositions = new ArrayList<>();\n for (int i = 0; i < this.size; i++) {\n switch (this.orientation) {\n case HORIZONTAL:\n listPositions.add(new Position(\n this.currentPosition.getRow(),\n this.currentPosition.getColumn() + i));\n break;\n case VERTICAL:\n listPositions.add(new Position(\n this.currentPosition.getRow() + i,\n this.currentPosition.getColumn()));\n }\n }\n\n return listPositions;\n }", "public List<Point> getPoints() {\n return pointRepository.findAll()//\n .stream() //\n .sorted((p1, p2) -> Integer.compare(p1.getPosition(), p2.getPosition()))//\n .collect(Collectors.toList());\n }", "public List<Point> getPieces(Color pColor){\r\n List<Point> result = new LinkedList<>();\r\n Point pos = new Point();\r\n for (int i = 0; i < 8; i++){\r\n pos.setFirst(i);\r\n for (int j = 0; j < 8; j++){\r\n pos.setSecond(j);\r\n if((isBlack(pColor) && isBlack(pos)) || (isRed(pColor) && isRed(pos))){\r\n result.add(pos.clone());\r\n }\r\n }\r\n } \r\n return result;\r\n }", "public ArrayList<Vertex> initStart() {\r\n\t\tArrayList<Vertex> startPoint = new ArrayList<>();\r\n\t\tstartPoint.add(new Vertex(17, 2));\r\n\t\tstartPoint.add(new Vertex(16, 14));\r\n\t\tstartPoint.add(new Vertex(15, 14));\r\n\t\tstartPoint.add(new Vertex(11, 22));\r\n\t\tstartPoint.add(new Vertex(11, 21));\r\n\t\tstartPoint.add(new Vertex(22, 3));\r\n\t\tstartPoint.add(new Vertex(22, 2));\r\n\t\tstartPoint.add(new Vertex(20, 3));\r\n\t\tstartPoint.add(new Vertex(17, 21));\r\n\t\tstartPoint.add(new Vertex(17, 20));\r\n\t\tstartPoint.add(new Vertex(15, 21));\r\n\t\tstartPoint.add(new Vertex(12, 21));\r\n\t\treturn startPoint;\r\n\t}", "public abstract Set<Tile> getNeighbors(Tile tile);", "public void setSpawns() {\n List<Tile> spawns = this.board.getSpawns();// get all the possible spawns from board\n List<Tile> usedSpawns = new ArrayList<Tile>();// empty list used to represent all the spawns that have been used so no playerPiece gets the same spawn\n for (PlayerPiece playerPiece : this.playerPieces) { // for each playerPiece\n boolean hasSpawn = false; // boolean to represent whether the playerPiece has a spawn and used to initiate and stop the following while loop.\n while (!hasSpawn) { // while hasSpawn is false.\n int random_int = (int) (Math.random() * spawns.size());// get random number with max number of the total possible tiles the pieces can spawn from\n Tile spawn = spawns.get(random_int); // get spawn from spawns list using the random int as an index\n if (!usedSpawns.contains(spawn)) {// if the spawn isn't in the usedSpawn list\n playerPiece.setLocation(spawn);// set the location of the playerPiece to the spawn\n usedSpawns.add(spawn);//add the spawn to usedSpawns\n hasSpawn = true; // set the variable to true so the while loop stops.\n }\n }\n }\n }", "public int[] getCurrentPieceGridPosition() {\n\t\treturn currentPieceGridPosition; \n\t}", "static List<Point> getMoves(Point[] possibleTilePos, int[] rowMoves, int[] colMoves, List<Point> pieceMoves, int length) {\n pieceMoves.clear();\n for (int i = 0; i < length; i++) {\n possibleTilePos[i] = new Point(rowMoves[i], colMoves[i]);\n\n }\n pieceMoves.addAll(Arrays.asList(possibleTilePos));\n return pieceMoves;\n }", "private static ArrayList<Point> getCurrentlyValidMoves(){\n ArrayList<Point> currentlyValidMoves = new ArrayList<Point>();\n //iterate through the gameboard, checking if the move is valid\n for( int row = 0; row < 8; row++ ){\n for( int column = 0; column < 8; column++ ){\n if( gamepieces[ row ][ column ] == BACKGROUND_COLOR && isMoveValid( row, column ) ){\n //if it is valid, add it to our list\n currentlyValidMoves.add( new Point( row, column ) );\n }\n }\n }\n return currentlyValidMoves;\n }", "public List<Point> query(Rectangle rectangle) {\n if (!boundary.intersects(rectangle)) {\n return Collections.emptyList();\n }\n\n List<Point> found = new ArrayList<>();\n points.stream()\n .filter(rectangle::contains)\n .forEach(found::add);\n\n if (isSubdivided) {\n found.addAll(nw.query(rectangle));\n found.addAll(ne.query(rectangle));\n found.addAll(se.query(rectangle));\n found.addAll(sw.query(rectangle));\n }\n\n return found;\n }", "public interface Piece {\n /**\n * @return the current square the piece is on\n */\n public Square getCurrent();\n \n /**\n * @param s the new position of the piece\n */\n public void setCurrent(Square s);\n\n /**\n * Determines the squares that this piece can reach from its current position\n * according to the rules of the given board\n *\n * @param b the board whose rules to use\n * @return the squares the piece can reach\n */\n public Set<Square> validDestinations(Board b);\n}", "public Set<MapCoordinate> getAllSurroundingCellsAsMapCoordinatesStartingFromTopLeft(MapCoordinate topLeftMapCoordinate, int distance, Set<MapCoordinate> alreadyFound) {\n int currentX = topLeftMapCoordinate.getXAsInt();\n int currentY = topLeftMapCoordinate.getYAsInt();\n\n // first row\n int topLeftYMinusDistance = currentY - distance;\n int topLeftXMinusDistance = currentX - distance;\n\n int totalWidth = (distance + entityData.getWidthInCells() + distance) - 1;\n int totalHeight = (distance + entityData.getHeightInCells() + distance) - 1;\n\n Set<MapCoordinate> result = new HashSet<>(alreadyFound);\n\n // -1, because it is 0 based\n for (int x = 0; x <= totalWidth; x++) {\n result.add(MapCoordinate.create(topLeftXMinusDistance + x, topLeftYMinusDistance));\n }\n\n // then all 'sides' of the structure (left and right)\n // also start one row 'lower' since we do not want to calculate the top left/right twice (as we did it\n // in the above loop already)\n // totalHeight - 2 for same reason, -1 == zero based, -2 to reduce one row\n for (int y = 1; y <= (totalHeight - 1); y++) {\n int calculatedY = topLeftYMinusDistance + y;\n\n // left side\n result.add(MapCoordinate.create(topLeftXMinusDistance, calculatedY));\n\n // right side\n int rightX = topLeftXMinusDistance + totalWidth;\n result.add(MapCoordinate.create(rightX, calculatedY));\n }\n\n // bottom row\n int bottomRowY = topLeftYMinusDistance + totalHeight;\n for (int x = 0; x <= totalWidth; x++) {\n result.add(MapCoordinate.create(topLeftXMinusDistance + x, bottomRowY));\n }\n\n if (distance > 1) {\n return getAllSurroundingCellsAsMapCoordinatesStartingFromTopLeft(topLeftMapCoordinate, (distance-1), result);\n }\n return result;\n }", "public float[] GetStartPosition(int playerId)\r\n/* 515: */ {\r\n/* 516:621 */ for (int x = 0; x < getWidthInTiles(); x++) {\r\n/* 517:623 */ for (int y = 0; y < getHeightInTiles(); y++) {\r\n/* 518:625 */ if (tilePlayerPlacable(x, y, playerId)) {\r\n/* 519:627 */ return new float[] { x, y };\r\n/* 520: */ }\r\n/* 521: */ }\r\n/* 522: */ }\r\n/* 523:631 */ return new float[] { 0.0F, 0.0F };\r\n/* 524: */ }", "public int[][] place(){\r\n\t\treturn coords(pos);\r\n\t}", "public ArrayList<? extends Puzzle> getNeighbors();", "protected ArrayList<DataFromPoint> getFromPoints() {\n\t\treturn fromPoints.stream().map(e -> e.fromPoint)\n\t\t\t\t.collect(Collectors.toCollection(ArrayList::new));\n\t}", "public Position[] getPositions() {\n return _positions;\n }", "public Position getStartPosition() throws IllegalStateException{\r\n for (int i = 0; i < mazeData.length; i++) {\r\n for (int j = 0; j < mazeData[i].length; j++) {\r\n if (mazeData[i][j] == START)\r\n return new Position(i, j);\r\n }\r\n }\r\n throw new IllegalStateException(\"Could not find a start-point\");\r\n }" ]
[ "0.6267955", "0.608737", "0.5972652", "0.58733666", "0.5843262", "0.5786802", "0.57034796", "0.55977714", "0.55977714", "0.55976164", "0.5510756", "0.55048776", "0.5488861", "0.54584175", "0.5456151", "0.545534", "0.5418083", "0.54139185", "0.5394541", "0.53906", "0.5380616", "0.53772867", "0.5371788", "0.5371561", "0.5358574", "0.53580195", "0.5350027", "0.5348271", "0.53235704", "0.53021634", "0.5287097", "0.52821505", "0.52750534", "0.5273469", "0.52720696", "0.52680326", "0.5256397", "0.52508026", "0.5237993", "0.5234981", "0.52339226", "0.5221164", "0.52125514", "0.52103585", "0.5208458", "0.52061605", "0.51981205", "0.5194204", "0.51883125", "0.51764643", "0.51757544", "0.51742333", "0.51690066", "0.5168419", "0.5167093", "0.5160864", "0.5159062", "0.51472825", "0.51444983", "0.51360524", "0.51358724", "0.5129158", "0.51193964", "0.5104469", "0.5102361", "0.51006913", "0.5097651", "0.50953025", "0.50889486", "0.50862414", "0.50653076", "0.50650454", "0.5054367", "0.505057", "0.50426674", "0.50330305", "0.5032214", "0.50303024", "0.50217104", "0.50157887", "0.501214", "0.50069857", "0.5006565", "0.5002437", "0.4996778", "0.49963224", "0.4994641", "0.49942487", "0.49777415", "0.49655625", "0.4964259", "0.49611032", "0.4958102", "0.49459603", "0.4934243", "0.49341708", "0.49326432", "0.49313954", "0.49259946", "0.49244526" ]
0.5861754
4
Handle the movement of pawns. If it is a capture determine direction of the capture. If the end position does not contain a piece, then en passant. Otherwise check if the pawn is in the correct position to capture. If it isnt a capture, check for a pawn on the same file. If the pawn is 2 spaces away, check if is annn pawn in the middle space, if there is one then that pawn is moved, the pawn 2 spaces away is moved.
public static int[] getPawnStart(int[][] piecePos, char color, int endFile, int endRank, boolean capture) { if (capture) { // En Passant int direction = color == 'w' ? 1 : -1; if (getBoardStateSquare(endFile, endRank).equals(" ")) { for (int[] pos: piecePos) { if (endRank == pos[1] + direction) { int[] startPos = {pos[0], pos[1]}; move(" ", endFile, endRank, endFile, pos[1]); if (isLegalMove(startPos, endFile, endRank)) { return startPos; } } } } for (int[] pos: piecePos) { if (endRank == pos[1] + direction) { int[] startPos = {pos[0], pos[1]}; if (isLegalMove(startPos, endFile, endRank)) { return startPos; } } } } for (int[] pos: piecePos) { if (pos[0] == endFile) { int direction = color == 'w' ? 1 : -1; if (pos[1] + direction == endRank) { int[] startPos = {pos[0], pos[1]}; if (isLegalMove(startPos, endFile, endRank)) { return startPos; } } if (pos[1] + 2 * direction == endRank) { boolean correct = true; for (int r = 0; r < Math.abs(pos[1] - endRank) - 1; r++) { if (!getBoardStateSquare(endFile, Math.abs(r + direction * pos[1] + 1)) .equals(" ")) { correct = false; break; } } if (correct) { int[] startPos = {pos[0], pos[1]}; if (isLegalMove(startPos, endFile, endRank)) { return startPos; } } } } } return null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private boolean isNextMoveEnPassentCapture(Move move)\r\n\t{\r\n\t\tif (!(move.capture instanceof Pawn)) return false;\r\n\t\tif (Math.abs(move.from.coordinate.x - move.to.coordinate.x) != 1) return false;\r\n\t\tif (Math.abs(move.from.coordinate.y - move.to.coordinate.y) != 1) return false;\r\n\t\tif (!move.to.isEmpty()) return false;\r\n\t\treturn true;\r\n\t}", "@Override\n public void drawValidMove() {\n if(this.getPlayer().getPlayerID() % 2 != 0) {\n //Pawn can move one space forwards if no piece is in front\n if (board.getSquare(x-1, y).getPiece()== null) {\n board.getSquare(x-1, y).drawOutline();\n }\n \n //if first move, pawn can move 2 spaces forward\n if (!hasMoved && board.getSquare(x-2, y).getPiece() == null && board.getSquare(x-1, y).getPiece() == null) {\n board.getSquare(x-2, y).drawOutline();\n }\n \n //If there is an enemy piece in the diagonal forward square of the pawn, the pawn can move (capture the piece)\n if (y-1 > 0) { //ensures no arrayoutofbounds error\n if (board.getSquare(x-1, y-1) != null && board.getSquare(x-1, y-1).getPiece() != null &&\n board.getSquare(x-1, y-1).getPiece().getPlayer() != this.getPlayer()) {\n board.getSquare(x-1, y-1).drawOutline();\n }\n }\n \n if(y+1<SIZE) { //ensures no arrayoutofbounds error\n if (board.getSquare(x-1, y+1) != null && board.getSquare(x-1, y+1).getPiece() != null &&\n board.getSquare(x-1, y+1).getPiece().getPlayer() != this.getPlayer() ) {\n board.getSquare(x-1, y+1).drawOutline();\n }\n }\n \n System.out.println(\"\");\n //En passant\n if (y - 1 > 0) {\n \n System.out.println();\n if (board.getSquare(x, y-1).getPiece() != null) { \n System.out.println(\"the piece's enPassant is: \" + board.getSquare(x, y-1).getPiece().getEnPassant());\n System.out.println(\"The game's turn counter is: \" + board.getTurnCounter());\n }\n else {\n System.out.println(\"Null piece when checking for en passent.\");\n }\n \n if (board.getSquare(x, y-1).getPiece() != null && board.getSquare(x, y-1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y-1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x-1, y-1).drawOutline();\n board.getSquare(x-1, y-1).setEnPassent(true);\n }\n }\n \n if (y + 1 < SIZE) {\n if (board.getSquare(x, y+1).getPiece() != null && board.getSquare(x, y+1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y+1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x-1, y+1).drawOutline();\n board.getSquare(x-1, y+1).setEnPassent(true);\n }\n }\n }\n \n //If this pawn belongs to player 2:\n else {\n \n if (board.getSquare(x+1, y).getPiece() == null) {\n board.getSquare(x+1, y).drawOutline();\n }\n \n //if first move, pawn can move 2 spaces forward\n if (!hasMoved && board.getSquare(x+2, y).getPiece() == null && board.getSquare(x+1, y).getPiece() == null) {\n board.getSquare(x+2, y).drawOutline();\n \n }\n \n if(y-1 > 0) {\n if (board.getSquare(x+1, y-1) != null && board.getSquare(x+1, y-1).getPiece() != null &&\n board.getSquare(x+1, y-1).getPiece().getPlayer() != this.getPlayer() ) {\n board.getSquare(x+1, y-1).drawOutline();\n }\n }\n \n if(y+1 < SIZE) {\n if (board.getSquare(x+1, y+1) != null && board.getSquare(x+1, y+1).getPiece() != null &&\n board.getSquare(x+1, y+1).getPiece().getPlayer() != this.getPlayer()) {\n board.getSquare(x+1, y+1).drawOutline();\n }\n }\n \n //En passant\n if (y - 1 > 0) {\n if (board.getSquare(x, y-1).getPiece() != null &&board.getSquare(x, y-1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y-1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x+1, y-1).drawOutline();\n board.getSquare(x+1, y-1).setEnPassent(true);\n }\n }\n \n if (y + 1 < SIZE) {\n if (board.getSquare(x, y+1).getPiece() != null && board.getSquare(x, y+1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y+1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x+1, y+1).drawOutline();\n board.getSquare(x+1, y+1).setEnPassent(true);\n }\n }\n }\n }", "private boolean isLastMoveEnPassentCapture()\r\n\t{\r\n\t\tMove lastMove = getLastMove();\r\n\t\tif (lastMove == null) return false;\r\n\t\tif (appliedMoves.size() - 2 < 0) return false;\r\n\t\tMove beforeLastMove = appliedMoves.get(appliedMoves.size() - 2);\r\n\t\tif (beforeLastMove == null) return false;\r\n\t\t\r\n\t\tif (!(lastMove.capture instanceof Pawn)) return false;\r\n\t\tif (Math.abs(lastMove.from.coordinate.x - lastMove.to.coordinate.x) != 1) return false;\r\n\t\tif (Math.abs(lastMove.from.coordinate.y - lastMove.to.coordinate.y) != 1) return false;\r\n\r\n\t\t//Move before must have been a double move\r\n\t\tif (Math.abs(beforeLastMove.from.coordinate.y - beforeLastMove.to.coordinate.y) != 2) return false;\r\n\t\t//Pawn must have been removed\r\n\t\tif (fields[beforeLastMove.to.coordinate.x][beforeLastMove.to.coordinate.y].piece != null) return false;\r\n\t\t//Before last move's target must be on same y coordinate as from coordinate of last move\r\n\t\tif (beforeLastMove.to.coordinate.y != lastMove.from.coordinate.y) return false;\r\n\t\t//Before last move's target must be only one x coordinate away from coordinate of last move\r\n\t\tif (Math.abs(beforeLastMove.to.coordinate.x - lastMove.from.coordinate.x) != 1) return false;\r\n\t\t\r\n\t\treturn true;\r\n\t}", "@Override\r\n\tpublic boolean makeMove(String notation) {\n\t\tif(Castle.isCastlingMove(new ChessCoordinate(notation))) {\r\n\t\t\tKing playerKing = (King) getPlayerTurn().getPieces(\"King\", true).get(0);\r\n\t\t\t//return the result of trying to castle\r\n\t\t\treturn playerKing.move(new ChessCoordinate(notation));\r\n\t\t\t\r\n\t\t}else {\r\n\t\t\t//not a castling move, standard move\r\n\t\t\t\t\r\n\t\t\tString[] notationList = notation.split(\"\");\r\n\t\t\t//find the piece name\r\n\t\t\tString pieceName = ChessPieceNames.getPieceName(notationList[0]);\t\t\r\n\t\t\t\r\n\t\t\tif(pieceName == null && getColumnNames().contains(notationList[0].toLowerCase())) {\r\n\t\t\t\t//if first character is a column and returned null from above\r\n\t\t\t\t//must be a pawn move like e4 or axb2\r\n\t\t\t\tpieceName = ChessPieceNames.PAWN.toString();\r\n\t\t\t}else if(pieceName == null){\r\n\t\t\t\t//not a column and null so invalid move\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\r\n//\t\t\t//capturing move if there is a capture (x)\r\n\t\t\tboolean isCaptureMove = Arrays.asList(notationList).contains(\"x\");\r\n\t\t\t\r\n\t\t\t//final coordinate\r\n\t\t\tString coordinateString = notationList[notationList.length-2] + notationList[notationList.length-1];\r\n\t\t\tChessCoordinate coordinate = new ChessCoordinate(coordinateString);\r\n\t\t\tif(coordinate.isValid()) {\r\n\t\t\t\t//extract players alive pieces of piece name\r\n\t\t\t\tList<Piece> piecesOfType = getPlayerTurn().getPieces(pieceName, true);\r\n\t\t\t\t//list of pieces that can move to the same square\r\n\t\t\t\tList<Piece> piecesCanMoveToSquare = new ArrayList<Piece>();\r\n\t\t\t\tfor (Piece piece : piecesOfType) {\r\n\t\t\t\t\t\r\n\t\t\t\t\t//use valid moves of attacking if capturing move, else use move to\r\n\t\t\t\t\tSet<Coordinate> pieceMoves = isCaptureMove \r\n\t\t\t\t\t\t\t? piece.getValidMoves(Action.ATTACK) : piece.getValidMoves(Action.MOVE_TO);\r\n\t\t\t\t\tif(pieceMoves.contains(coordinate))piecesCanMoveToSquare.add(piece);\r\n\t\t\t\t}\t\r\n\t\t\t\t\r\n\t\t\t\tif (piecesCanMoveToSquare.size() == 1) {\r\n\t\t\t\t\t//only one piece can go to that square, so take piece at 0th index as the list only has one element\r\n\t\t\t\t\tpiecesCanMoveToSquare.get(0).move(coordinate);\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\telse if (piecesCanMoveToSquare.size() > 1) {\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(notation.length() <= 3) {\r\n\t\t\t\t\t\tSystem.out.println(\"Invalid move, specify which piece to move to \" + coordinateString);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//multiple pieces of the same type can move to that square, check which one to use\r\n\t\t\t\t\t//if pawn, the identifier to use is the 0th index of notationList, eg axb4. use pawn in column a.\r\n\t\t\t\t\t//for other pieces, column to use is the 1st index of notationList. eg Nab4.\r\n\t\t\t\t\t\r\n\t\t\t\t\t//variable called identifier as it can be a row or column value.\r\n\t\t\t\t\tString identifier = (pieceName.equalsIgnoreCase(ChessPieceNames.PAWN.toString()) ?\r\n\t\t\t\t\t\t\tnotationList[0] : notationList[1]).toLowerCase();\r\n\t\t\t\t\t//identifier should be a row value if pieces share the same column\r\n\t\t\t\t\tboolean isRowIdentifier = shareColumn(piecesOfType);\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(isRowIdentifier && getRowNames().contains(identifier)) {\r\n\t\t\t\t\t\t//locate piece by row and move that piece to coordinate\r\n\t\t\t\t\t\tfor (Piece piece : piecesCanMoveToSquare) {\r\n\t\t\t\t\t\t\t//look at the row number of piece coordinate, see if it matches the identifier \r\n\t\t\t\t\t\t\tif(Character.toString(piece.getPosition().toString().charAt(1)).equalsIgnoreCase(identifier)) {\r\n\t\t\t\t\t\t\t\tpiece.move(coordinate);\r\n\t\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tSystem.out.println(\"There is no \" + pieceName + \" on row \" + identifier);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}else if(getColumnNames().contains(identifier)) {\r\n\t\t\t\t\t\tfor (Piece piece : piecesCanMoveToSquare) {\r\n\t\t\t\t\t\t\t//look at the column letter of piece coordinate, see if it matches the identifier \r\n\t\t\t\t\t\t\tif(Character.toString(piece.getPosition().toString().charAt(0)).equalsIgnoreCase(identifier)) {\r\n\t\t\t\t\t\t\t\tpiece.move(coordinate);\r\n\t\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tSystem.out.println(\"There is no \" + pieceName + \" on column \" + identifier);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//invalid identifier\r\n\t\t\t\t\telse return false;\r\n\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\telse {\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t//invalid coordinate, move can not be played\r\n\t\t\telse return false;\r\n\t\t}\r\n\t\t\r\n\t}", "public static boolean validMove(String move, Person p, Board building )\n {\n Room[][] map = building.getMap();\n move = move.toLowerCase().trim();\n switch (move) {\n case \"n\":\n if (p.getxLoc() > 0)\n {\n map[p.getxLoc()][p.getyLoc()].leaveRoom(p);\n System.out.println(\"You are in the \"+map[p.getxLoc()-1][p.getyLoc()].getName());\n map[p.getxLoc()-1][p.getyLoc()].enterRoom(p,building);\n return true;\n }\n else\n {\n return false;\n }\n case \"e\":\n if (p.getyLoc()< map[p.getyLoc()].length -1)\n {\n map[p.getxLoc()][p.getyLoc()].leaveRoom(p);\n System.out.println(\"You are in the \"+map[p.getxLoc()][p.getyLoc() + 1].getName());\n map[p.getxLoc()][p.getyLoc() + 1].enterRoom(p, building);\n return true;\n }\n else\n {\n return false;\n }\n\n case \"s\":\n if (p.getxLoc() < map.length - 1)\n {\n map[p.getxLoc()][p.getyLoc()].leaveRoom(p);\n System.out.println(\"You are in the \"+map[p.getxLoc()+1][p.getyLoc()].getName());\n map[p.getxLoc()+1][p.getyLoc()].enterRoom(p, building);\n return true;\n }\n else\n {\n return false;\n }\n\n case \"w\":\n if (p.getyLoc() > 0)\n {\n map[p.getxLoc()][p.getyLoc()].leaveRoom(p);\n System.out.println(\"You are in the \"+map[p.getxLoc()][p.getyLoc()-1].getName());\n map[p.getxLoc()][p.getyLoc()-1].enterRoom(p, building);\n return true;\n }\n else\n {\n return false;\n }\n default:\n break;\n\n }\n return true;\n }", "void onMoveTaken(Piece captured);", "public int canMoveTo(Piece p, Location dest)\n {\n if (p==null||dest==null||!dest.isValid())\n return ILLEGAL_MOVE;\n Location loc = getLocation(p);\n if (dest.equals(loc))\n return ILLEGAL_MOVE;\n int thisCol = loc.getCol();\n int thisRow = loc.getRow();\n int otherCol = dest.getCol();\n int otherRow = dest.getRow();\n int rowDiff = Math.abs(thisRow-otherRow);\n int colDiff = Math.abs(thisCol-otherCol);\n Piece other = getPiece(dest);\n if (other!=null&&other.sameColor(p))\n return ILLEGAL_MOVE;\n switch (p.getType())\n {\n case KING:\n if (rowDiff==0&&colDiff==2) //castling\n {\n if (p.hasMoved())\n return ILLEGAL_MOVE;\n Piece rook = null;\n Direction dir = null;\n if (thisCol > otherCol) //queenside\n {\n dir = Direction.WEST;\n rook = getPiece(new Location(thisRow,thisCol-4));\n }\n else //kingside\n {\n dir = Direction.EAST;\n rook = getPiece(new Location(thisRow,thisCol+3));\n }\n if (rook==null||rook.getType()!=Type.ROOK||!p.sameColor(rook)||rook.hasMoved())\n return ILLEGAL_MOVE;\n Location next = loc;\n for (int i=thisCol; i!=getLocation(rook).getCol(); i=next.getCol())\n {\n if ((!next.equals(loc)&&getPiece(next)!=null)||enemyCanAttack(p.getColor(),next))\n return ILLEGAL_MOVE;\n next = next.farther(dir);\n }\n if (thisCol > otherCol)\n return QUEENSIDE_CASTLING;\n else return KINGSIDE_CASTLING;\n }\n else //normal king move\n if (adjacent(loc,dest)\n && (other==null || !p.sameColor(other)))\n return KING_MOVE;\n else return ILLEGAL_MOVE;\n \n case PAWN:\n if (rowDiff>2||rowDiff<1||colDiff>1||(rowDiff==2&&colDiff>0)\n ||(p.white()&&otherRow>thisRow)||(!p.white()&&otherRow<thisRow))\n return ILLEGAL_MOVE;\n else if (rowDiff==2) //first move\n {\n if (p.hasMoved())\n return ILLEGAL_MOVE;\n Location temp = loc.closerTo(dest);\n if (getPiece(temp)==null&&other==null&&((p.white()&&thisRow==6)||(!p.white()&&thisRow==1)))\n return PAWN_FIRST_MOVE;\n else return ILLEGAL_MOVE;\n }\n else if (colDiff==1 && other!=null) //taking\n {\n if (p.sameColor(other))\n return ILLEGAL_MOVE;\n else return PAWN_CAPTURE;\n }\n else if (colDiff==1 && other==null) //en passant\n {\n int diff = otherCol-thisCol;\n Location otherLoc = new Location(thisRow,thisCol+diff);\n Piece otherPiece = getPiece(otherLoc);\n if (otherPiece!=null&&otherPiece.hasJustMoved()\n &&otherPiece.getType()==Type.PAWN&&!otherPiece.sameColor(p))\n return EN_PASSANT;\n else return ILLEGAL_MOVE;\n }\n else if (rowDiff==1) //normal move\n {\n if (other==null)\n return PAWN_MOVE;\n else return ILLEGAL_MOVE;\n }\n break;\n \n case ROOK:case QUEEN: case BISHOP:case KNIGHT:\n if (!canAttack(p,dest))\n return ILLEGAL_MOVE;\n else\n {\n switch (p.getType())\n {\n case ROOK:return ROOK_MOVE;\n case QUEEN:return QUEEN_MOVE;\n case BISHOP:return BISHOP_MOVE;\n case KNIGHT:return KNIGHT_MOVE;\n }\n }\n }\n return ILLEGAL_MOVE; //will never happen\n }", "public void move(Pawn pawn, Point destination) {\n\t\tPoint lastLocation = pawn.getLocation();\r\n\t\tboard[lastLocation.x][lastLocation.y].setEmpty();\r\n\t\tboard[destination.x][destination.y].setTaken();\r\n\t\tpawn.setLocation(destination);\r\n\t\tpawn.setLastLocation(lastLocation);\r\n\t\t\r\n\t\tif(isNeighbor(lastLocation, destination)) {\r\n\t\t\tpawn.setAfterStep();\r\n\t\t}\r\n\t\t\r\n\t\tif(board[destination.x][destination.y].getFieldType().equals(pawn.getTarget())) {\r\n\t\t\tpawn.setInTarget();\r\n\t\t}\r\n\t}", "public MoveResult canMovePiece(Alignment player, Coordinate from, Coordinate to);", "public void setValidMoves(Board board, int x, int y, int playerType) {\n\t\tmoves.clear();\n\t\t// if this is pawn's first move, it can move two squares forward\n\t\tif (firstMove == true)\n\t\t{\n\t\t\t// white moves forward with y++\n\t\t\tif(this.getPlayer() == 1)\n\t\t\t{\n\t\t\t\tPoint firstMove = new Point(x + 0, y + 2);\n\t\t\t\tif (board.getPiece(x, y + 1) == null && board.getPiece(x, y + 2) == null)\n\t\t\t\t{\n\t\t\t\t\t\tmoves.add(firstMove);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// black moves forward with y--\n\t\t\telse\n\t\t\t{\n\t\t\t\tPoint firstMove = new Point(x + 0, y - 2);\n\t\t\t\tif (board.getPiece(x, y - 1) == null && board.getPiece(x, y - 2) == null)\n\t\t\t\t{\n\t\t\t\t\t\tmoves.add(firstMove);\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif (this.getPlayer() == 1)\n\t\t{\n\t\t\t// if a piece is occupying a square diagonal from pawn, it can capture\n\t\t\tif (x + 1 < 8 && y + 1 < 8 && x + 1 >= 0 && y + 1 >= 0)\n\t\t\t{\n\t\t\t\tPoint move = new Point(x + 1, y + 1);\n\t\t\t\tif (board.getPiece(x + 1, y + 1) != null)\n\t\t\t\t{\n\t\t\t\t\tif (board.getPiece(x+1,y+1).getPlayer() != this.getPlayer())\n\t\t\t\t\t{\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (x - 1 < 8 && y + 1 < 8 && x - 1 >= 0 && y + 1 >= 0)\n\t\t\t{\n\t\t\t\tPoint move = new Point(x - 1, y + 1);\n\t\t\t\tif (board.getPiece(x - 1, y + 1) != null)\n\t\t\t\t{\n\t\t\t\t\tif (board.getPiece(x - 1, y + 1).getPlayer() != this.getPlayer())\n\t\t\t\t\t{\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\t// if no piece is in front of pawn, it can move forward one square\n\t\t\tif (x < 8 && y + 1 < 8 && x >= 0 && y + 1 >=0)\n\t\t\t{\n\t\t\t\tPoint move = new Point(x + 0, y + 1);\n\t\t\t\tif (board.getPiece(x, y + 1) == null)\n\t\t\t\t{\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// if a piece is occupying a square diagonal from pawn, it can capture\n\t\t\tif (x + 1 < 8 && y - 1 < 8 && x + 1 >= 0 && y - 1 >= 0)\n\t\t\t{\n\t\t\t\tPoint move = new Point(x + 1, y - 1);\n\t\t\t\tif (board.getPiece(x + 1, y - 1) != null)\n\t\t\t\t{\n\t\t\t\t\tif (board.getPiece(x + 1,y - 1).getPlayer() != this.getPlayer())\n\t\t\t\t\t{\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (x - 1 < 8 && y - 1 < 8 && x - 1 >= 0 && y - 1 >= 0)\n\t\t\t{\n\t\t\t\tPoint move = new Point(x - 1, y - 1);\n\t\t\t\tif (board.getPiece(x - 1, y - 1) != null)\n\t\t\t\t{\n\t\t\t\t\tif (board.getPiece(x - 1, y - 1).getPlayer() != this.getPlayer())\n\t\t\t\t\t{\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\t// if no piece is in front of pawn, it can move forward one square\n\t\t\tif (x < 8 && y - 1 < 8 && x >= 0 && y - 1 >=0)\n\t\t\t{\n\t\t\t\tPoint move = new Point(x + 0, y - 1);\n\t\t\t\tif (board.getPiece(x, y - 1) == null)\n\t\t\t\t{\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}", "public boolean canCapture(Piece piece, Point start)\n \t{\n \t\t//Piece.Team team = piece.getTeam();\n \t\tPiece.Team opposite = piece.getOppositeTeam();\n \t\t\n \t\tboolean ahead = false;\n \t\tboolean behind = false;\n \t\tint captureAhead = 0;\n \t\tint captureBehind = 0;\n \t\t\n \t\tfor(Direction d : Direction.values())\n \t\t{\n \t\t\tPoint land = getPoint(start,d); //get point in all directions\n \t\t\t\n \t\t\tif( land == start) //when direction is none\n \t\t\t\tcontinue;\n \t\t\t\n \t\t\tif(board[land.y][land.x] == null) //you will land in an empty spot\n \t\t\t{\n \t\t\t\tPoint target = getPoint(land,d); //look for targets in the same direction you traveled\n \t\t\t\tPoint targetBehind = getPoint(start,getOppositeDirection(d)); //from your starting position get the target behind \n \t\t\t\tif(board[target.y][target.x].getTeam() == opposite) //check position ahead in the same direction you advanced for opposite team\n \t\t\t\t{\n \t\t\t\t\tahead = true;\n \t\t\t\t\t++captureAhead;\n \t\t\t\t}\n \t\t\t\tif(board[targetBehind.y][targetBehind.x].getTeam() == opposite)\n \t\t\t\t{\n \t\t\t\t\tbehind = true;\n \t\t\t\t\t++captureBehind;\n \t\t\t\t}\n \t\t\t}\n \t\t}\n \t\tif (captureAhead+captureBehind > 0)\n \t\t\treturn true;\n \t\telse \n \t\t\treturn false;\n \t}", "public boolean moveByTwo(Pawn pawn,Deck deck)\n\t{\n\t\tint possibleMove=pawn.getPosition()+2;\n\t\tpossibleMove=Math.floorMod(possibleMove, 72);\n\t\tif (!check.isPawnOnStartPosition(pawn)&&\n\t\t\t\t!check.IsEnemyHome(pawn, possibleMove, deck) && !check.IsEnemySafetyZone(pawn, possibleMove, deck) \n\t\t&& !check.IsEnemyStartSquare(pawn, possibleMove, deck) && !check.IsTwoSamePawnsOnSquare(pawn, possibleMove, deck) )\n\t\t{\n\t\t\tif(check.IsEnemyPawnOnSquare(pawn, possibleMove, deck))\n\t\t\t{\n\t\t\t\tdeck.getSquares().get(possibleMove).getCurr_pawn().setPosition(-10);//move the enemy pawn to his start square\n\t\t\t\n\t\t\t\tdeck.getSquares().get(possibleMove).getCurr_pawn().setCurrentSquare(new HomeSquare(deck.getSquares().get(possibleMove).getCurr_pawn().getColor(), null));//move the enemy pawn to his start square\n\t\t\t\t\n\t\t\t}\n\t\t\tpawn.getCurrentSquare().setCurr_pawn(null);\n\t\t\tupdate_Pawn_Current_Square(pawn, possibleMove, deck);\n\t\t\tset_Squares_Pawn(pawn, possibleMove, deck);\n\t\t\tpawn.setPosition(possibleMove);\n\t\t\treturn true;\n\t\t\t\n\t\t}\n\t\treturn false;\n\t}", "public Move movePiece(int turn) {\n\t\tboolean error = false;\n\t\tString moveInput = null;\n\t\tString origin = null;\n\t\tboolean isCorrectTurn = false;\n\t\t@SuppressWarnings(\"resource\")\n\t\tScanner keyboard = new Scanner(System.in);\n\n\t\tdo {\n\t\t\t\n\t\t\ttry {\n\t\t\t\tdo {\n\t\t\t\t\tSystem.out.println(\"Which piece would you like to move?\");\n\t\t\t\t\torigin = keyboard.next();\n\n\t\t\t\t\tif(validateInput(origin)) {\n\t\t\t\t\t\tSystem.out.println(\"Error in input, please try again\");\n\t\t\t\t\t\terror = true; \n\t\t\t\t\t} else {\n\t\t\t\t\t\n\t\t\t\t\t\terror = false;\n\t\t\t\t\t}\n\n\t\t\t\t}while(error);\n\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tString xOrigin = origin.substring(0, 1);\n\t\t\t\tint yOrigin = Integer.parseInt(origin.substring(1,2));\n\t\t\t\tint convertedXOrigin = convertXPosition(xOrigin);\n\t\t\t\tyOrigin -= 1;\n\t\t\t\t\nif((board.getBoard()[yOrigin][convertedXOrigin] == turn) || (board.getBoard()[yOrigin][convertedXOrigin] == (turn + 2))) {\n\t\t\t\tisCorrectTurn = true;\n\t\t\t\tChecker checker = validatePiece(convertedXOrigin, yOrigin);\t\n\t\t\t\tdo {\n\t\t\t\t\t\n\t\t\t\t\t\tSystem.out.println(\"Where would you like to move\");\n\t\t\t\t\t\t moveInput = keyboard.next();\n\t\t\t\t\t\tif(validateInput(moveInput)) {\n\t\t\t\t\t\t\tSystem.out.println(\"Error in Input, please try again\");\n\t\t\t\t\t\t\terror = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\terror = false;\n\t\t\t\t\t\t//\tSystem.out.println(\"No errors found with input move\");\n\t\t\t\t\t\t}\n\n\t\t\t\t} while(error);\n\t\t\t\t\n\t\t\t\tString xMove = moveInput.substring(0, 1);\n\t\t\t\tint yMove = Integer.parseInt(moveInput.substring(1,2));\n\t\t\t\tint convertedXMove = convertXPosition(xMove);\n\t\t\t\tyMove -= 1;\n\t\t\t\tboolean isMovingRight = isMovingRight(convertedXOrigin, yOrigin, convertedXMove, yMove);\n\t\t\t\tboolean isMovingDown = isMovingDown(convertedXOrigin, yOrigin, convertedXMove, yMove);\n\t\t\t\tMove move = null;\n\t\t\t\t\n\t\t\t\t//checks to see if the move itself is valid\n\t\t\t\ttry {\nif(isMoveValid(convertedXOrigin, yOrigin, convertedXMove, yMove, isMovingRight, isMovingDown)) {\n\t\t\t\tif(isSpaceTaken(convertedXMove, yMove)) {\n\t\t\t\t\t//System.out.println(\"Space is taken\");\n\t\t\t\t\tif(isPieceEnemy(convertedXMove, yMove, checker, turn)) {\n\t\t\t\t\t\tif(isJumpValid(convertedXOrigin, yOrigin, convertedXMove, yMove, isMovingRight, isMovingDown)) {\n\t\t\t\t\t\t\tif(isMovingRight) {\n\t\t\t\t\t\t\t\t//checks to see if the piece is moving up or down\n\t\t\t\t\t\t\t\tif(isMovingDown) {\n\t\t\t\t\t\t\t\t\t//means the piece is moving right and down\n\t\t\t\t\t\t\t\t\t move = new Move(convertedXOrigin, yOrigin, convertedXMove + 1, yMove + 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\t\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t//means the piece is moving right, but up\n\t\t\t\t\t\t\t\t\t move = new Move(convertedXOrigin, yOrigin, convertedXMove + 1, yMove - 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif(isMovingDown) {\n\t\t\t\t\t\t\t\t\t//means its moving left and down\n\t\t\t\t\t\t\t\t\tmove = new Move(convertedXOrigin, yOrigin, convertedXMove - 1, yMove + 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t//means it's moving left and up\n\t\t\t\t\t\t\t\t\tmove = new Move(convertedXOrigin, yOrigin, convertedXMove - 1, yMove - 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\t\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t//System.out.println(\"Space isn't taken\");\n\t\t\t\t\tmove = new Move(convertedXOrigin, yOrigin, convertedXMove, yMove);\n\t\t\t\t\tmodel.moves.add(move);\n\t\t\t\t\tif(canBeKing(checker, move)) {\n\t\t\t\t\t\tchecker = convertToKing(checker, move);\n\t\t\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\tprintBoard();\n\t\t\t\t\t\treturn move;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\t\tupdateBoard(move);\n\t\t\t\t\t\n\t\t\t\t\tprintBoard();\n\t\t\t\t\treturn move;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tSystem.out.println(\"Error in move\");\n\t\t\t\t//System.out.println(\"It's not your turn\");\n\t\t\t\tisCorrectTurn = false;\n\t\t\t\t}\n\t\t\t\t} catch (NullPointerException e) {\n\t\t\t\t\tSystem.out.println(\"NullPointerException - Error\");\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tif(canBeKing(checker, move)) {\n\t\t\t\tchecker = convertToKing(checker, move);\n\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\t\n\t\t\t\tprintBoard();\n\t\t\t\treturn move;\n}\n\n\n\n\t\t\t\t\n\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\tupdateBoard(move);\n\t\t\t\t\n\t\t\t\tprintBoard();\n\t\t\t\treturn move;\n\t\t\t\t}\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\tSystem.out.println(\"Error in Input. Please try again\");\n\t\t\t}\n\t\t\n\t\t}while(!isCorrectTurn);\n\n\t\tprintBoard();\n\t\treturn null;\n\t\t\n\t}", "@Override\n\tpublic boolean validMove(int xEnd, int yEnd, board b){\n\t\t//try to land one same color piece\n\t\tif(b.occupied(xEnd, yEnd)&&b.getPiece(xEnd, yEnd).getColor()==color){\n\t\t\treturn false;\n\t\t}\n\t\tif(v==0){\n\t\t\tif(!this.guard(xEnd, yEnd, b)){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t//normal move\n\t\tif((xEnd==x-1&&yEnd==y-1)||(xEnd==x-1&&yEnd==y)||(xEnd==x-1&&yEnd==y+1)||(xEnd==x&&yEnd==y-1)||(xEnd==x&&yEnd==y+1)||(xEnd==x+1&&yEnd==y-1)||(xEnd==x+1&&yEnd==y)||(xEnd==x+1&&yEnd==y+1)){\n\t\t\tif(b.occupied(xEnd, yEnd)){\n\t\t\t\t//set the enpass flage back\n\t\t\t\tb.setFlag(color, 100, 100);\n\t\t\t\tb.recycle(xEnd, yEnd);\n\t\t\t\tthis.setPosition(xEnd, yEnd);\n\t\t\t\tb.update();\n\t\t\t\tc=0;\n\t\t\t\treturn true;\n\t\t\t}else{\n\t\t\t\t//set the enpass flage back\n\t\t\t\tb.setFlag(color, 100, 100);\n\t\t\t\tthis.setPosition(xEnd, yEnd);\n\t\t\t\tb.update();\n\t\t\t\tc=0;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}else if((xEnd==x-2&&yEnd==y)){ //castling\n\t\t\tpiece r = b.getPiece(0, y);\n\t\t\tif(r==null){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif(r.getC()==0||r.getColor()!=color||r.getType()!= type.ROOK||c==0){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tfor(int i=3;i>0;i--){\n\t\t\t\tif(b.occupied(i, y)){\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.setPosition(xEnd, yEnd);\n\t\t\tr.setPosition(3,y);\n\t\t\tc=0;\n\t\t\tr.setC(0);\n\t\t\tb.setFlag(color, 100, 100);\n\t\t\tb.update();\n\t\t\treturn true;\n\t\t}else if((xEnd==x+2&&yEnd==y)){\n\t\t\tpiece r = b.getPiece(7, y);\n\t\t\tif(r==null){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif(r.getC()==0||r.getColor()!=color||r.getType()!= type.ROOK||c==0){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tfor(int i=5;i<=6;i++){\n\t\t\t\tif(b.occupied(i, y)){\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.setPosition(xEnd, yEnd);\n\t\t\tr.setPosition(5,y);\n\t\t\tc=0;\n\t\t\tr.setC(0);\n\t\t\tb.setFlag(color, 100, 100);\n\t\t\tb.update();\n\t\t\treturn true;\n\t\t}else{\n\t\t\treturn false;\n\t\t}\n\t}", "private boolean isLegalMove(String move) {\n\t\tString[] moveParts = move.split(\";\");\n\n\t\tint fromRow = Integer.parseInt(moveParts[0].charAt(0) + \"\");\n\t\tint fromCol = Integer.parseInt(moveParts[0].charAt(1) + \"\");\n\n\t\tint toRow = Integer.parseInt(moveParts[1].charAt(0) + \"\");\n\t\tint toCol = Integer.parseInt(moveParts[1].charAt(1) + \"\");\n\n\t\tint minRow = Math.min(fromRow, toRow);\n\t\tint minCol = Math.min(fromCol, toCol);\n\n\t\tint maxRow = Math.max(fromRow, toRow);\n\t\tint maxCol = Math.max(fromCol, toCol);\n\n\t\tint piece = board[fromRow][fromCol];//Integer.parseInt(moveParts[2]);\n\t\tint pieceType = Math.abs(piece);\n\t\tint team = Math.round(Math.signum(piece));\n\n\t\tif (team == Math.round(Math.signum(board[toRow][toCol]))) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif (toRow < 0 || toRow > 7 && toCol < 0 && toCol > 7) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (team > 0) { // WHITE\n\t\t\tint enpassantBackup = enpassantCol;\n\t\t\tint[][] boardBackup = deepCopyBoard();\n\t\t\tapplyConvertedMove(move);\n\t\t\tboolean check = isWhiteCheck();\n\t\t\tboard = boardBackup;\n\t\t\tenpassantCol = enpassantBackup;\n\t\t\tif (check) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else { //BLACK\n\t\t\tint enpassantBackup = enpassantCol;\n\t\t\tint[][] boardBackup = deepCopyBoard();\n\t\t\tapplyConvertedMove(move);\n\t\t\tboolean check = isBlackCheck();\n\t\t\tboard = boardBackup;\n\t\t\tenpassantCol = enpassantBackup;\n\t\t\tif (check) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tif (pieceType == 1) { //Pawn\n\t\t\treturn ((board[toRow][toCol] != 0 && toRow == fromRow + team && (toCol == fromCol + 1 || toCol == fromCol - 1)) || (toCol == fromCol && board[toRow][toCol] == 0 && ((toRow == fromRow + team) || (((fromRow == 1 && team == 1) || (fromRow == 6 && team == -1)) ? toRow == fromRow + 2*team && board[fromRow + team][fromCol] == 0 : false))));\n\t\t} else if (pieceType == 2) { //Rook\n\t\t\tif (toRow == fromRow) {\n\t\t\t\tfor (int i = minCol + 1; i < maxCol; i++) {\n\t\t\t\t\tif (board[toRow][i] != 0 && Math.abs(board[toRow][i]) != 7) return false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} else if (toCol == fromCol) {\n\t\t\t\tfor (int i = minRow + 1; i < maxRow; i++) {\n\t\t\t\t\tif (board[i][toCol] != 0 && Math.abs(board[i][toCol]) != 7) return false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else if (pieceType == 3) { //Knight\n\t\t\tint dx = toRow - fromRow;\n\t\t\tint dy = toCol - fromCol;\n\t\t\treturn dx*dx + dy*dy == 5;\n\t\t} else if (pieceType == 4) { //Bishop\n\t\t\tint dx = toRow - fromRow;\n\t\t\tint dy = toCol - fromCol;\n\t\t\tif (dy != dx && dy != -dx) return false;\n\t\t\tint m = dy/dx;\n\t\t\tint startCol = (m < 0 ? maxCol : minCol);\n\t\t\tfor (int i = minRow + 1; i < maxRow; i++) {\n\t\t\t\tif (board[i][startCol + m*(i - minRow)] != 0 && board[i][startCol + m*(i - minRow)] != 7) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t} else if (pieceType == 5) { //Queen\n\t\t\tif (toRow == fromRow) {\n\t\t\t\tfor (int i = minCol + 1; i < maxCol; i++) {\n\t\t\t\t\tif (board[toRow][i] != 0 && Math.abs(board[toRow][i]) != 7) return false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} else if (toCol == fromCol) {\n\t\t\t\tfor (int i = minRow + 1; i < maxRow; i++) {\n\t\t\t\t\tif (board[i][toCol] != 0 && Math.abs(board[i][toCol]) != 7) return false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\tint dx = toRow - fromRow;\n\t\t\t\tint dy = toCol - fromCol;\n\t\t\t\tif (dy != dx && dy != -dx) return false;\n\t\t\t\tint m = dy/dx;\n\t\t\t\tint startCol = (m < 0 ? maxCol : minCol);\n\t\t\t\tfor (int i = minRow + 1; i < maxRow; i++) {\n\t\t\t\t\tif (board[i][startCol + m*(i - minRow)] != 0 && Math.abs(board[i][startCol + m*(i - minRow)]) != 7) return false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if (pieceType == 6) { //King\n\t\t\tint dx = toRow - fromRow;\n\t\t\tint dy = toCol - fromCol;\n\t\t\treturn dx*dx + dy*dy <= 2;\n\t\t}\n\n\t\treturn false;\n\t}", "public Move move() {\n\n byte[] piece;\n int pieceIndex;\n Move.Direction direction = null;\n int counter = 0;\n\n Scanner s = new Scanner(System.in);\n\n\n System.out.println(\"Please select piece to move: \");\n\n\n while (true) {\n try {\n pieceIndex = s.nextInt();\n\n if ((piece = getPiece(pieceIndex)) == null) {\n System.out.println(\"invalid index, try again!\");\n// check if selected piece is stuck\n } else if (\n (((player == Board.V) && (piece[1]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O ) || // UP\n ((player == Board.H) && (piece[1]-1 >=0) && (board.layout[piece[0]][piece[1]-1] == O)) || // DOWN\n ((player == Board.V) && (piece[0]-1 >=0) && (board.layout[piece[0]-1][piece[1]] == O)) || // LEFT\n (((player == Board.H) && (piece[0]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O )) // RIGHT\n {\n break;\n// if all are stuck pass turn\n } else if (counter + 1 < Board.getSize()) {\n counter++;\n System.out.println(\"Piece is stuck, pick another, \" + counter + \" pieces stuck.\");\n } else {\n System.out.println(\"Passing\");\n return null;\n }\n } catch (Exception e){\n System.out.println(\"Piece index expects int, try again\");\n s = new Scanner(System.in);\n }\n }\n System.out.println(\"Please select direction ('w' // 'a' // 's' // 'd'): \");\n\n boolean valid = false;\n while (!valid) {\n\n switch (s.next().charAt(0)) {\n // if the move requested is valid, break the loop, make the move on our record of layout and return the\n // move made\n case 'w':\n direction = Move.Direction.UP;\n valid = (((player == Board.V) && (piece[1]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O );\n break;\n\n case 'a':\n direction = Move.Direction.LEFT;\n valid = ((player == Board.V) && (piece[0]-1 >=0) && (board.layout[piece[0]-1][piece[1]] == O));\n break;\n\n case 's':\n direction = Move.Direction.DOWN;\n valid = ((player == Board.H) && (piece[1]-1 >=0) && (board.layout[piece[0]][piece[1]-1] == O));\n break;\n\n case 'd':\n direction = Move.Direction.RIGHT;\n valid = (((player == Board.H) && (piece[0]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O );\n break;\n default:\n System.out.println(\"Invalid key press, controls are wasd\");\n valid = false;\n }\n }\n Move move = makeMove(direction, pieceIndex);\n board.update(move, player);\n\n return move;\n }", "@Override\r\n public boolean canMove() {\r\n Grid<Actor> gr = getGrid();\r\n int dirs[] = {\r\n Location.AHEAD, Location.HALF_CIRCLE, Location.LEFT,\r\n Location.RIGHT };\r\n // 当终点在周围时,不能移动且isEnd应当为true\r\n for (int i = 0; i < dirs.length; i++) {\r\n Location tarLoc = getLocation().getAdjacentLocation(dirs[i]);\r\n if (gr.isValid(tarLoc) && gr.get(tarLoc) != null) {\r\n // Color直接用==计算竟然不可行(真是哔了dog...\r\n if (gr.get(tarLoc) instanceof Rock\r\n && gr.get(tarLoc).getColor().equals(Color.RED)) {\r\n isEnd = true;\r\n return false;\r\n }\r\n }\r\n }\r\n ArrayList<Location> nextLocs = getValid(getLocation());\r\n // 当附近没有可以移动的位置时,不能移动\r\n if (nextLocs.size() == 0) {\r\n return false;\r\n }\r\n // 当可以移动的位置>1时,说明存在一个节点,这个节点应当被新建一个arraylist入栈\r\n if (nextLocs.size() > 1) {\r\n ArrayList<Location> newStackElem = new ArrayList<Location>();\r\n newStackElem.add(getLocation());\r\n crossLocation.push(newStackElem);\r\n }\r\n // 有可以移动的位置时,向概率最高的方向移动\r\n int maxProbLoc = 0;\r\n // 由于nextLocs不一定有4个location,所以只好循环判断取最大值\r\n for (int i = 0; i < nextLocs.size(); i++) {\r\n Location loc = nextLocs.get(i);\r\n int dirNum = getLocation().getDirectionToward(loc) / 90;\r\n if (probablyDir[dirNum] > probablyDir[maxProbLoc]) {\r\n maxProbLoc = i;\r\n }\r\n }\r\n next = nextLocs.get(maxProbLoc);\r\n return true;\r\n }", "private boolean moveContinues(Point piece){\r\n boolean result = canEats(piece);\r\n // if move continues, next move has to start with the same piece\r\n model.setCheckPiece((result)?piece:null);\r\n return result;\r\n }", "public boolean isValidMove(Point orig, Point dest){ \r\n Color playerColor = model.getCurrentPlayer().getColor();\r\n // Validate all point between board limits\r\n if(!isValidPosition(orig) || !isValidPosition(dest)) return false;\r\n // Check for continue move starting piece\r\n if(model.getCheckPiece() != null && !model.getCheckPiece().equals(orig)) return false;\r\n // Validate origin piece to player color\r\n if((isRed(playerColor) && !isRed(orig)) || (isBlack(playerColor) && !isBlack(orig))) return false;\r\n // Only can move to empty Black space\r\n if(!isEmpty(dest)) return false;\r\n // If current player have obligatory eats, then need to eat\r\n if(obligatoryEats(playerColor) && !moveEats(orig,dest)) return false;\r\n // Check move direction and length\r\n int moveDirection = orig.getFirst() - dest.getFirst(); // Direction in Rows\r\n int rLength = Math.abs(moveDirection); // Length in Rows\r\n int cLength = Math.abs(orig.getSecond() - dest.getSecond()); // Length in Columns\r\n int mLength;\r\n // Only acepts diagonal movements in 1 or 2 places (1 normal move, 2 eats move)\r\n if ((rLength == 1 && cLength == 1) || (rLength == 2 && cLength == 2)){\r\n mLength = rLength;\r\n } else {\r\n return false;\r\n }\r\n // 1 Place movement\r\n if (mLength == 1){ \r\n if (isRed(orig) && !isQueen(orig) && moveDirection > 0) return true;\r\n if (isBlack(orig) && !isQueen(orig) && moveDirection < 0) return true;\r\n if ((isRed(orig) && isQueen(orig)) || (isBlack(orig) && isQueen(orig))) return true;\r\n }\r\n // 2 Places movement need checks if eats rivals\r\n if (mLength == 2){\r\n // Compute mid point\r\n Point midPoint = getMidPoint(orig, dest);\r\n // Check move\r\n if ((isRed(orig) && isBlack(midPoint)) || (isBlack(orig) && isRed(midPoint))){\r\n if (isRed(orig) && !isQueen(orig) && moveDirection > 0) return true;\r\n if (isBlack(orig) && !isQueen(orig) && moveDirection < 0) return true;\r\n if ((isRed(orig) && isQueen(orig)) || (isBlack(orig) && isQueen(orig))) return true;\r\n }\r\n }\r\n return false;\r\n }", "@Override\n public boolean move(Coordinates beg, Coordinates end)\n {\n int mult = Player.PlayerType.White == type ? 1 : -1;\n boolean isKilling = false;\n\n // If end coordinates have an enemy in sight, set isKilling to true\n if (board.grid[end.r][end.c] != null)\n isKilling = true;\n\n // Checks if movement makes the \"L\" shape\n if (Math.abs(end.c - beg.c) == 1 && Math.abs(end.r - beg.r) == 2\n || Math.abs(end.c - beg.c) == 2 && Math.abs(end.r - beg.r) == 1) {\n System.out.println(\"Movement shape is correct for knight\");\n } else {\n System.out.println(\"Movement shape is incorrect for knight\");\n return false;\n }\n // If killing\n if (isKilling == true) {\n System.out.println(\"Murder is possible for knight\");\n board.grid[end.r][end.c] = null;\n board.grid[end.r][end.c] = board.grid[beg.r][beg.c];\n board.grid[beg.r][beg.c] = null;\n System.out.println(\"Murder by knight is successful\");\n } else {\n // If not killing\n board.grid[end.r][end.c] = board.grid[beg.r][beg.c];\n board.grid[beg.r][beg.c] = null;\n System.out.println(\"Knight movement successful\");\n return true;\n }\n\n return true;\n }", "public boolean move() {\n\t\tint nextDirection;\n\t\tint pacmanX = parent.getPacManX();\n\t\tint pacmanY = parent.getPacManY();\n\t\t\n\t\tint[] directionPriority = new int[4];\n\t\t/** The direction is added to the priority in order to achieve it once the move is chosen */\n\t\tdirectionPriority[0]=(pacmanX-pixelLocationX)*(10)*state+GameCharacter.RIGHT;\n\t\tdirectionPriority[1]=((pacmanX-pixelLocationX)*(-10)*state+GameCharacter.LEFT);\n\t\tdirectionPriority[2]=(pacmanY-pixelLocationY)*(10)*state+GameCharacter.DOWN;\n\t\tdirectionPriority[3]=((pacmanY-pixelLocationY)*(-10)*state+GameCharacter.UP);\n\t\tArrays.sort(directionPriority);\n\t\t\n\t\tint i=3;\n\t\t\n\t\tdo {\n\t\t\tnextDirection = directionPriority[i]%10;\n\t\t\tif (nextDirection < 0) {\n\t\t\t\tnextDirection += 10;\n\t\t\t}\n\t\t\tif(isLegalMove(nextDirection) && (Math.abs(nextDirection-currentDirection) != 2) || i==0) {\n\t\t\t\tsetDirection(nextDirection);\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\ti--;\n\t\t}\n\t\twhile (i>=0);\n\t\treturn super.move();\n\t}", "private boolean canMove(Point piece){\r\n // direction -1: red pieces +1: black pieces\r\n int dir = isRed(piece)? -1:+1;\r\n // normal movement\r\n Point left = new Point(piece.getFirst() + dir, piece.getSecond() - 1);\r\n Point right = new Point(piece.getFirst() + dir, piece.getSecond() + 1);\r\n // check for normal movements\r\n if(isValidPosition(left) && isEmpty(left)) return true;\r\n if(isValidPosition(right) && isEmpty(right)) return true;\r\n // if is a queen\r\n if(isQueen(piece)){\r\n // compute queen move points (invert direction)\r\n Point leftQ = new Point(piece.getFirst() - dir, piece.getSecond() - 1);\r\n Point rightQ = new Point(piece.getFirst() - dir, piece.getSecond() + 1);\r\n // check for down movements\r\n if(isValidPosition(leftQ) && isEmpty(leftQ)) return true;\r\n if(isValidPosition(rightQ) && isEmpty(rightQ)) return true;\r\n }\r\n return false;\r\n }", "public boolean move(Point startingP, Point desP, int depth){\n // START CONDITIONS\n //-----------------\n TakStack startStack = stacks[startingP.x][startingP.y];\n TakStack desStack = stacks[desP.x][desP.y];\n\n // are we grabbing a valid number given our board size\n if(depth > SIZE) return false;\n\n // is this move directly up,down,left, or right\n double xchange = Math.pow(startingP.x - desP.x, 2);\n double ychange = Math.pow(startingP.y - desP.y, 2);\n if(ychange > 1 || xchange > 1) return false;\n if(ychange >= 1 && xchange >= 1) return false;\n\n // are there enough pieces to grab\n if(depth > startStack.size()) return false;\n\n // Is the target des empty\n if(!desStack.isEmpty()){\n // Can this piece move ontop of destination piece\n TakPiece startTop = startStack.top();\n TakPiece desTop = desStack.top();\n\n if(desTop.isCapstone()){return false;} // Nothing we can do about this\n\n if(startTop.isCapstone()){\n if(desTop.isWall()){\n desTop.crush();\n }\n } else {\n if(desTop.isWall()){\n return false;\n }\n }\n }\n\n // Is the player grabbing a stack in their control\n if(startStack.top().isWhite() != whiteTurn) return false;\n //---------------\n // END CONDITIONS\n\n // Valid move - start move operation\n // Add onto our position we would like to move to the difference of what we grab from the postion we move from**\n desStack.add(startStack.sub(depth));\n // switch turns only if the player places a stack of depth = 1 (no possible additional moves)\n if (depth == 1) switchPlayer();\n\n turn++;\n return true;\n }", "private boolean canCaptureSomewhere(int x, int y){\n\t\tfor (int i = -2; i <= 2; i=i+4){\n\t\t\tfor (int j = -2; j <= 2; j=j+4){\n\t\t\t\tif (!(x+i < 0 || x+i > N\t\t\n\t\t\t\t|| y+j < 0 || y+j > N)){\t\t//don't give validMove impossible final coordinates\n\t\t\t\t\tif (validMove(x, y, x+i, y+j)) return true;\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}", "@Test\n\tpublic void captureOtherPiece() throws Exception {\n\t\tRook captureTarget1 = new Rook(PieceColor.BLACK, 1, 5);\n\t\tKnight captureTarget2 = new Knight(PieceColor.WHITE, 6, 2);\n\t\tRook captureTarget3 = new Rook(PieceColor.BLACK, 4, 2);\n\t\tQueen captureTarget4 = new Queen(PieceColor.WHITE, 5, 4);\n\t\tgame.board.addPiece(captureTarget1);\n\t\tgame.board.addPiece(captureTarget2);\n\t\tgame.board.addPiece(captureTarget3);\n\t\tgame.board.addPiece(captureTarget4);\n\t\t\n\t\tgame.board.movePiece(knightCorner1White, 1, 5);\n\t\tgame.board.movePiece(knightCorner2Black, 6, 2);\n\t\tgame.board.movePiece(knightSide1White, 4, 2);\n\t\tgame.board.movePiece(knightSide2Black, 5, 4);\n\t\tassertEquals(knightCorner1White, game.board.getPiece(1, 5));\n\t\tassertEquals(knightCorner2Black, game.board.getPiece(6, 2));\n\t\tassertEquals(knightSide1White, game.board.getPiece(4, 2));\n\t\tassertEquals(knightSide2Black, game.board.getPiece(5, 4));\n\t\tassertFalse(captureTarget1.isAlive());\n\t\tassertFalse(captureTarget2.isAlive());\n\t\tassertFalse(captureTarget3.isAlive());\n\t\tassertFalse(captureTarget4.isAlive());\n\t}", "@Override\n\tpublic void movePawn(Pawn pawn, Deck deck,int choice)\n\t{\n\t\tboolean move_Result=false;\n\t\tswitch (choice)\n\t\t{\n\t\tcase 1:\n\t\t\tmove_Result=beginFromStart(pawn,deck);\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tmove_Result=moveByTwo(pawn, deck);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t\t//check if the move that the user chose is valid or make the other move if it's possible\n \n\t\tif(choice==1 && move_Result==false)\n\t\t{\n\t\t\tmoveByTwo(pawn, deck);\n\t\t\t\n\t\t\t\n\t\t}\n\t\telse if(choice==2 && move_Result==false)\n\t\t{\n\t\t\tif ( beginFromStart(pawn,deck) ) \n\t\t\t{\n\t\t\t\t\n\t\t\t}\n\t\t\telse {\n\t\t\t\t//fold to continue\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t}", "private boolean validMove(int xi, int yi, int xf, int yf) {\n\t\tPiece prevP = pieceAt(xi, yi);\n\t\tPiece nextP = pieceAt(xf, yf);\n\n\t\tif (prevP.isKing()) {\n\t\t\tif (((xf - xi) == 1 || (xi - xf) == 1) && ((yf - yi) == 1 || (yi - yf) == 1)) \n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t} else \n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\tif (prevP.isFire()) \n\t\t{\n\t\t\tif (((xf - xi) == 1 || (xi - xf) == 1) && (yf - yi) == 1) \n\t\t\t{\n\t\t\t\tif (nextP != null && !nextP.isFire()) \n\t\t\t\t{\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} \n\t\t\telse if ((xf - xi) == 2 && (yf - yi) == 2) \n\t\t\t{\n\t\t\t\tPiece pBetween = pieceAt(xi+1, yi+1);\n\t\t\t\tif (pBetween != null && prevP.side() != pBetween.side()) \n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t} \n\t\t\telse if ((xi - xf) == 2 && (yf - yi) == 2) \n\t\t\t{\n\t\t\t\tPiece pBetween = pieceAt(xi-1, yi+1);\n\t\t\t\tif (pBetween != null && prevP.side() != pBetween.side()) \n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t} else \n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else \n\t\t{\n\t\t\tif (((xf - xi) == 1 || (xi - xf) == 1) && (yi - yf) == 1) \n\t\t\t{\n\t\t\t\tif (nextP != null && nextP.isFire()) \n\t\t\t\t{\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} \n\t\t\telse if ((xf - xi) == 2 && (yi - yf) == 2) \n\t\t\t{\n\t\t\t\tPiece pBetween = pieceAt(xi+1, yi-1);\n\t\t\t\tif (pBetween != null && prevP.side() != pBetween.side()) \n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t} \n\t\t\telse if ((xi - xf) == 2 && (yi - yf) == 2) \n\t\t\t{\n\t\t\t\tPiece pBetween = pieceAt(xi-1, yi-1);\n\t\t\t\tif (pBetween != null && prevP.side() != pBetween.side()) \n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t} \n\t\t\telse \n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}", "public MoveType isMoveValid(int newIndexX, int newIndexY, int oldIndexX, int oldIndexY) {\n\n if (!isFieldPlaceable(newIndexX, newIndexY) || isFieldOccupied(newIndexX, newIndexY)) {\n return INVALID;\n }\n\n if (bestPieceFound) {\n if (bestPieceToMove != board[oldIndexY][oldIndexX].getPiece()) {\n //check if chosen piece is the best piece to move\n return INVALID;\n }\n if (bestMoveFound) {\n int yDir = (newIndexY - oldIndexY < 0) ? -1 : 1;\n int xDir = (newIndexX - oldIndexX < 0) ? -1 : 1;\n if (xDir != bestMoveDirectionX || yDir != bestMoveDirectionY) {\n return INVALID;\n }\n }\n }\n\n if (board[oldIndexY][oldIndexX].getPiece().getType().equals(PieceType.MEN)) {\n if (abs(newIndexY - oldIndexY) == 2) {\n //kill attempt\n int enemyY = newIndexY - ((newIndexY - oldIndexY) / 2);\n int enemyX = newIndexX - ((newIndexX - oldIndexX) / 2);\n\n if (isEnemyKilled(enemyX, enemyY, board)) {\n //check if kill will be executed properly\n board[enemyY][enemyX].setPiece(null);\n if (controller.killEnemy(enemyX, enemyY)) {\n //update view after killing\n if (round == PieceColor.LIGHT) {\n darkCounter -= 1;\n } else {\n lightCounter -= 1;\n }\n return KILL;\n } else {\n return INVALID;\n }\n }\n }\n\n if (board[oldIndexY][oldIndexX].getPiece().getMoveDirection() == (oldIndexY - newIndexY)) {\n //check if men moves in right direction\n if (killAvailable) {\n //if user execute normal move when kill is available, move is invalid\n return INVALID;\n }\n return MoveType.NORMAL;\n }\n } else if (board[oldIndexY][oldIndexX].getPiece().getType().equals(PieceType.KING)) {\n\n if (abs(newIndexX - oldIndexX) == abs(newIndexY - oldIndexY)) {\n //check if king moves diagonally\n\n int yDir = (newIndexY - oldIndexY < 0) ? -1 : 1;\n int xDir = (newIndexX - oldIndexX < 0) ? -1 : 1;\n\n if (piecesInKingsWay(oldIndexX, oldIndexY, newIndexX, newIndexY, xDir, yDir) == 1)\n //check if king is able to kill piece in its way\n if (isEnemyKilled(newIndexX - xDir, newIndexY - yDir, board)) {\n //check if king is placed just behind piece and try to kill\n return killUsingKing(newIndexX, newIndexY, xDir, yDir, board);\n } else {\n return INVALID;\n }\n else {\n if (piecesInKingsWay(oldIndexX, oldIndexY, newIndexX, newIndexY, xDir, yDir) > 1) {\n //if more pieces in kings way, it cant move over them\n return INVALID;\n }\n }\n\n\n if (newIndexX != oldIndexX && newIndexY != oldIndexY) {\n //every other possibility is checked, if place is changed it is normal move\n if (killAvailable) {\n return INVALID;\n }\n return MoveType.NORMAL;\n }\n }\n }\n if (newIndexX == oldIndexX && newIndexY == oldIndexY) {\n return MoveType.NONE;\n }\n return MoveType.INVALID;\n }", "private void captureCheck(int x, int y, char checkNot, char[][] captureBoard)\n\t{\n\t\t// it is possible to capture 4 different groups of pieces with one piece\n\t\t// placement\n\t\tArrayList<Point> up = new ArrayList<>();\n\t\tArrayList<Point> down = new ArrayList<>();\n\t\tArrayList<Point> left = new ArrayList<>();\n\t\tArrayList<Point> right = new ArrayList<>();\n\t\tif (right(y, x, checkNot, captureBoard, right) != -1)\n\t\t{\n\t\t\tif (captureBoard[x + 1][y] == checkNot)\n\t\t\t{\n\t\t\t\tright = hasLiberties(x + 1, y, checkNot, captureBoard);\n\t\t\t\tif (right != null)\n\t\t\t\t{\n\t\t\t\t\twhile (!right.isEmpty())\n\t\t\t\t\t{\n\t\t\t\t\t\tPoint remove = right.remove(0);\n\t\t\t\t\t\tcaptureBoard[remove.x][remove.y] = ' ';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (left(y, x, checkNot, captureBoard, left) != -1)\n\t\t{\n\t\t\tif (captureBoard[x - 1][y] == checkNot)\n\t\t\t{\n\t\t\t\tleft = hasLiberties(x - 1, y, checkNot, captureBoard);\n\t\t\t\tif (left != null)\n\t\t\t\t{\n\t\t\t\t\twhile (!left.isEmpty())\n\t\t\t\t\t{\n\t\t\t\t\t\tPoint remove = left.remove(0);\n\t\t\t\t\t\tcaptureBoard[remove.x][remove.y] = ' ';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (up(y, x, checkNot, captureBoard, up) != -1)\n\t\t{\n\t\t\tif (captureBoard[x][y - 1] == checkNot)\n\t\t\t{\n\t\t\t\tup = hasLiberties(x, y - 1, checkNot, captureBoard);\n\t\t\t\tif (up != null)\n\t\t\t\t{\n\t\t\t\t\twhile (!up.isEmpty())\n\t\t\t\t\t{\n\t\t\t\t\t\tPoint remove = up.remove(0);\n\t\t\t\t\t\tcaptureBoard[remove.x][remove.y] = ' ';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (down(y, x, checkNot, captureBoard, down) != -1)\n\t\t{\n\t\t\tif (captureBoard[x][y + 1] == checkNot)\n\t\t\t{\n\t\t\t\tdown = hasLiberties(x, y + 1, checkNot, captureBoard);\n\t\t\t\tif (down != null)\n\t\t\t\t{\n\t\t\t\t\twhile (!down.isEmpty())\n\t\t\t\t\t{\n\t\t\t\t\t\tPoint remove = down.remove(0);\n\t\t\t\t\t\tcaptureBoard[remove.x][remove.y] = ' ';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t}", "public boolean canPieceMove(Piece piece, Location targetLocation, Directions direction) throws LocationException, IllegalMoveException {\n\t\t// is tile black location\n\t\tTile targetTile=null;\n\n\t\ttargetTile = getTileInLocation(targetLocation);\n\t\tif (targetTile.getColor1()!=PrimaryColor.BLACK) {\n\t\t\tthrow new IllegalMoveException(\"piece can't move to this \" + targetLocation + \", you can move only on black tiles! \");\n\t\t}\n\n\t\t// does tile contain another piece\n\t\tif(targetTile.getPiece() != null) {\n\t\t\tthrow new IllegalMoveException(\"piece can't move to this \" + targetLocation + \", it contains another Piece!\");\n\t\t}\n\t\tif(piece instanceof Soldier) {\n\t\t\tint steps = piece.getLocation().getRelativeNumberOfSteps(targetLocation);\n\t\t\tPiece ediblePiece = ((Soldier) piece).getEdiblePieceByDirection( direction);\n\t\t\t// if its moving in 2s make sure there is a piece we are eating by moving like that\n\t\t\tif(((piece.getColor()==PrimaryColor.WHITE) && (direction == Directions.UP_LEFT || direction == Directions.UP_RIGHT)) \n\t\t\t\t\t|| ((piece.getColor()==PrimaryColor.BLACK) && (direction == Directions.DOWN_LEFT|| direction == Directions.DOWN_RIGHT))){\n\t\t\t\tif(steps==2) {\n\t\t\t\t\t//if no piece to eat\n\t\t\t\t\tif(ediblePiece == null) {\n\t\t\t\t\t\tthrow new IllegalMoveException(\"soldier can't move 2 steps if you are not eating another piece fom rival player\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (steps!=1) {\n\t\t\t\t\tthrow new IllegalMoveException(\"soldier can only move 2 steps if you are eating ,and 1 step if you are not\");\n\t\t\t\t}\n\n\t\t\t}// if it's moving backwards it's because it's eating for second time\n\t\t\telse if(((piece.getColor()==PrimaryColor.BLACK) && (direction == Directions.UP_LEFT || direction == Directions.UP_RIGHT)) \n\t\t\t\t\t|| ((piece.getColor()==PrimaryColor.WHITE) && (direction == Directions.DOWN_LEFT|| direction == Directions.DOWN_RIGHT)) ) {\n\t\t\t\tif(steps !=2) {\n\t\t\t\t\tthrow new IllegalMoveException(\"soldier can't move backwards unless you are moving 2 steps while eating in sequence\");\n\t\t\t\t}//if 2 steps\n\t\t\t\telse {\n\t\t\t\t\tint eatingCntr =piece.getEatingCntr();\n\t\t\t\t\tif (eatingCntr<1) {\n\t\t\t\t\t\tthrow new IllegalMoveException(\"soldier can't move backwards unless you are eating for the second time\");\n\t\t\t\t\t}//if in eating sequence\n\t\t\t\t\telse {\n\t\t\t\t\t\t//if there is nothing to eat while moving in 2\n\t\t\t\t\t\tif(ediblePiece == null) {\n\t\t\t\t\t\t\tthrow new IllegalMoveException(\"soldier can't move 2 steps if you are not eating another piece from rival player\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t//not moving diagonally\n\t\t\telse {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t//Queen handling\n\t\telse if (piece instanceof Queen) {\n\n\t\t\tif(!((Queen) piece).isMoveLegalByDirection(targetLocation, direction)) {\n\t\t\t\tthrow new IllegalMoveException(\"Illegal Move!\");\n\t\t\t}\n\t\t\tif(((Queen) piece).isPieceBlockedByDirection(targetLocation, direction)) {\n\t\t\t\tthrow new IllegalMoveException(\"Queen is blocked!\");\n\t\t\t}\n\t\t\tif(((Queen) piece).getPiecesCountByDirection(targetLocation, direction) > 1) {\n\t\t\t\tthrow new IllegalMoveException(\"Failed to eat more than one piece in one move, try to split your move\");\n\t\t\t}\n\n\t\t}\n\t\treturn true;\n\t}", "public void processTurn(Player player) {\n Move move;\n do {\n Scanner scan = new Scanner(System.in);\n\n System.out.println(\"Enter current position of Piece you want to move\");\n // Positions entered by player\n int startX = scan.nextInt();\n int startY = scan.nextInt();\n\n System.out.println(\"Enter position where you want to put Piece\");\n int endX = scan.nextInt();\n int endY = scan.nextInt();\n\n // Move created based on position entered by player 1\n move = new Move(player, board.getCellAtLocation(startX, startY), board.getCellAtLocation(endX, endY));\n } while (!makeMove(move));\n }", "public boolean move(int x, int y, CheckersBoard board) {\n if (whiteTurn == true && team == Constants.TeamId.team1Id) {\n return false;\n }\n if (whiteTurn == false && team == Constants.TeamId.team2Id) {\n return false;\n }\n /**\n * then change the x - y coords of the piece\n * update the UI to remove the highlighted squares then move the piece\n * if chess and shared square you take a piece\n * if checkers you jumped them you take the piece\n * return new x - y components\n *\n * if this is too high up in the tree you can override this implementation or update it\n * to fit specific pieces if its not working for some reason\n */\n if (possible(x, y, gameBoard)) {\n int changex = this.getX()-x;\n int changey = this.getY()-y;\n CheckersPiece temp = gameBoard.boardPositions[getX()][getY()];\n gameBoard.boardPositions[getX()][getY()] = null;\n gameBoard.boardPositions[x][y] = temp;\n if (gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2] != null) {\n System.out.println(\"Here\");\n if (gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2].team != this.team) {\n gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2].imageView.setVisibility(View.GONE);\n gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2] = null;\n }\n }\n this.setX(x);\n this.setY(y);/*\n if (Math.abs(changex) == 2) {\n gameBoard.boardPositions[x + (changex/2)][y + (changey/2)] = null;\n if (team == Constants.TeamId.team1Id) {\n board.numPieces1--;\n } else if (team == Constants.TeamId.team2Id) {\n board.numPieces0--;\n }\n }*/\n\n gameBoard.boardPositions[x][y].imageView.setX(142*x);\n gameBoard.boardPositions[x][y].imageView.setY(142*y);\n // flips after move is\n whiteTurn = !whiteTurn;\n gameBoard.startTimer();\n }\n //setUpUI(gameBoard);\n if (getY() == 7 && team == Constants.TeamId.team2Id) {\n board.crown(this);\n }\n if (getY() == 0 && team == Constants.TeamId.team1Id) {\n board.crown(this);\n }\n return possible(x, y, gameBoard);\n }", "private void validPlayerMove(char moveType) {\n\n\t\t//Obtain X and Y of playerLocation\n\t\tint x = getPlayerLocation()[0];\n\t\tint y = getPlayerLocation()[1];\n\n\t\t//By default, set xOffset and yOffset to 0\n\t\tint xOffset = 0;\n\t\tint yOffset = 0;\n\n\t\t//Change xOffset and yOffset corresponding to each moveType\n\t\t//For example, RIGHT would set xOffset to +1\n\t\tswitch(moveType) {\n\t\tcase Legend.UP: \n\t\t\tyOffset = -1;\n\t\t\tbreak;\n\t\tcase Legend.UP_LEFT:\n\t\t\tyOffset = -1;\n\t\t\txOffset = -1;\n\t\t\tbreak;\n\t\tcase Legend.UP_RIGHT:\n\t\t\tyOffset = -1;\n\t\t\txOffset = 1;\n\t\t\tbreak;\n\t\tcase Legend.DOWN:\n\t\t\tyOffset = 1;\n\t\t\tbreak;\n\t\tcase Legend.DOWN_RIGHT:\n\t\t\tyOffset = 1;\n\t\t\txOffset = 1;\n\t\t\tbreak;\n\t\tcase Legend.DOWN_LEFT:\n\t\t\tyOffset = 1;\n\t\t\txOffset = -1;\n\t\t\tbreak;\n\t\tcase Legend.LEFT:\n\t\t\txOffset = -1;\n\t\t\tbreak;\n\t\tcase Legend.RIGHT:\n\t\t\txOffset = 1;\n\t\t\tbreak;\n\t\tcase Legend.JUMP:\n\n\t\t\t//Generate a random location of the jump\n\t\t\twhile (true) {\n\n\t\t\t\t//random x and y values (between 0-10)\n\t\t\t\tint randomX = 1+(int)(Math.random()*10);\n\t\t\t\tint randomY = 1+(int)(Math.random()*10);\n\n\t\t\t\t//If the new location is a BlankSpace, assign that as a Player, and assign a new move in moveList\n\t\t\t\tif(map[randomX][randomY] instanceof BlankSpace) {\n\t\t\t\t\tnewMap[randomX][randomY] = new Player(x, y, board);\n\t\t\t\t\tnewMap[x][y] = new BlankSpace(x, y, board);\n\t\t\t\t\tmoveList[x][y] = moveType;\n\t\t\t\t\tmap[x][y].setJumpLocation(randomX, randomY);\n\t\t\t\t\tsetNewPlayerLocation(new int[] {randomX, randomY});\n\t\t\t\t\tbreak;\n\t\t\t\t} \n\n\t\t\t\t//If the new location is a Mho, completely wipe the board of the player, and initiate a gameOver procedure\n\t\t\t\telse if(map[randomX][randomY] instanceof Mho) {\n\t\t\t\t\tnewMap[randomX][randomY] = new Mho(x, y, board);\n\t\t\t\t\tnewMap[x][y] = new BlankSpace(x, y, board);\n\t\t\t\t\tmoveList[x][y] = moveType;\n\t\t\t\t\tmap[x][y].setJumpLocation(randomX, randomY);\n\t\t\t\t\tsetNewPlayerLocation(new int[] {randomX, randomY});\n\t\t\t\t\tgameOver();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t//If the new location that the Player will move to will be a Player (in the case of Legend.SHRINK), or BlankSpace, change map and newMap, as well as moveList and the playerLocation \n\t\tif (map[x+xOffset][y+yOffset] instanceof BlankSpace || map[x+xOffset][y+yOffset] instanceof Player) {\n\t\t\tnewMap[x][y] = new BlankSpace(x, y, board);\n\t\t\tnewMap[x+xOffset][y+yOffset] = new Player(x+xOffset, y+yOffset, board);\n\t\t\tmoveList[x][y] = moveType;\n\t\t\tsetNewPlayerLocation(new int[] {x+xOffset, y+yOffset});\n\t\t\treturn;\n\t\t} \n\n\t\t//If the new location that the Player will move to will be a Fence, remove the player from the map and initiate the gameOver() process\n\t\telse {\n\t\t\tnewMap[x][y] = new BlankSpace(x, y, board);\n\t\t\tmoveList[x][y] = Legend.SHRINK;\n\t\t\tsetNewPlayerLocation(new int[] {x, y});\n\t\t\tgameOver();\n\t\t\treturn;\n\t\t}\n\n\t}", "public void endTurn() {\n \tselectedX = -1;\n \tselectedY = -1;\n \tmoveToX = -1;\n \tmoveToY = -1;\n \toneMove = false;\n \thasMoved = false;\n\t\tplayer = 0 - player;\n\t\tfor (int i = 0; i < N; i++) {\n for (int j = 0; j < N; j++) {\n \tif (pieces[i][j]) {\n \t\tboardPieces[i][j].doneCapturing();\n \t}\n }\n\t\t}\n\t}", "public boolean move(Block moveTo, boolean check, String move){\r\n\t\t//Translate File and Rank to array indices\r\n\t\t\t\tint srcFile = this.getBlock().getFile();\r\n\t\t\t\tint srcRank = chess.Chess.Rmap.get(this.getBlock().getRank()+\"\");\r\n\t\t\t\tint destFile = moveTo.getFile();\r\n\t\t\t\tint destRank = chess.Chess.Rmap.get(moveTo.getRank()+\"\"); \r\n\t\t\t\t\r\n\t\t\t\tif(((Math.abs(srcRank-destRank)==1 && Math.abs(srcFile-destFile)==2) || (Math.abs(srcRank-destRank)==2 && Math.abs(srcFile-destFile)==1))){\r\n\t\t\t\t\tif(moveTo.isOccupied()){\r\n\t\t\t\t\t\tif(moveTo.getPiece().getColor().equals(chess.Chess.board[srcRank][srcFile].getPiece().getColor())==true){\r\n\t\t\t\t\t\t\tif(check == true){\r\n\t\t\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tSystem.out.println(\"Invalid move, try again\");\r\n\t\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t//A check to see if this move puts the opponent's King in check\r\n\t\t\t\t\t\tif(check == true){\r\n\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t//Call deletePiece to indicate that target piece has been captured\r\n\t\t\t\t\t\tchess.Chess.board[destRank][destFile].getPiece().deletePiece(chess.Chess.board[destRank][destFile].getPiece().getNumber(), chess.Chess.board[destRank][destFile].getPiece());\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setPiece(getBlock().getPiece());\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif(chess.Chess.board[destRank][destFile].getPiece().getColor().equals(\"White\"))\r\n\t\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setDisplay(\"wN \");\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setDisplay(\"bN \");\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tthis.getBlock().setOccupied(false);\r\n\t\t\t\t\t\tthis.getBlock().setPiece(null);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif(this.getBlock().isShaded()){\r\n\t\t\t\t\t\t\tthis.getBlock().setDisplay(\"## \");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse{\r\n\t\t\t\t\t\t\tthis.getBlock().setDisplay(\" \");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tthis.setBlock(moveTo);\r\n\t\t\t\t\t\tchess.Chess.printBoard();\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\telse{\r\n\t\t\t\t\t\t//A check to see if this move puts the opponent's King in check\r\n\t\t\t\t\t\tif(check == true){\r\n\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setPiece(getBlock().getPiece());\r\n\t\t\t\t\t\tif(chess.Chess.board[destRank][destFile].getPiece().getColor().equals(\"White\"))\r\n\t\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setDisplay(\"wN \");\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setDisplay(\"bN \");\r\n\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setOccupied(true);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tthis.getBlock().setOccupied(false);\r\n\t\t\t\t\t\tthis.getBlock().setPiece(null);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif(this.getBlock().isShaded()){\r\n\t\t\t\t\t\t\tthis.getBlock().setDisplay(\"## \");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse{\r\n\t\t\t\t\t\t\tthis.getBlock().setDisplay(\" \");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tthis.setBlock(moveTo);\r\n\t\t\t\t\t\tchess.Chess.printBoard();\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse{\r\n\t\t\t\t\tif(check == true){\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tSystem.out.println(\"Invalid move, try again\");\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t}", "private void updateMoveList(Move m) {\n \t//first check for castling move\n \tif(m.getSource().getName().equals(\"King\")) {\n \tint sx = m.getSource().getLocation().getX();\n \tint dx = m.getDest().getLocation().getX();\n \t\n \t//castle king side\n \tif(dx - sx == 2) {\n \t\tmoveList.add(\"0-0\");\n \t\treturn;\n \t}\n \t//castle queen side\n \telse if(sx - dx == 2) {\n \t\tmoveList.add(\"0-0-0\");\n \t\treturn;\n \t}\n \t}\n \t\n \t//now do normal checks for moves\n \t//if no piece, normal notation\n \tif(m.getDest().getName().equals(\"None\")) {\n \t\t\n \t\t//check for en passant\n \t\tif(m.getSource().getName().equals(\"Pawn\")) {\n \t\t\t\n \t\t\t//it's only en passant if the pawn moves diagonally to an empty square \n \t\t\tif(m.getSource().getLocation().getX() != m.getDest().getLocation().getX()) {\n \t\t\t\tmoveList.add(m.getSource().getLocation().getFile()+ \"x\" + m.getDest().getLocation().getNotation());\n \t\t\t\treturn;\n \t\t\t}\n \t\t}\n \t\t\n \t\tmoveList.add(m.getSource().getID() + m.getDest().getLocation().getNotation());\n \t}\n \t//add \"x\" for capturing\n \t//for pawn, it's a bit different\n \telse if(m.getSource().getName().equals(\"Pawn\")) {\n \t\tmoveList.add(m.getSource().getLocation().getFile()+ \"x\" + m.getDest().getLocation().getNotation());\n \t}\n \telse {\n \t\tmoveList.add(m.getSource().getID() + \"x\" + m.getDest().getLocation().getNotation());\n \t}\n }", "private void checkMove(Tile[][] chessBoard, int pawnX, int pawnY, int direction) {\r\n\t\tUnit unit = chessBoard[pawnX][pawnY+direction].getPiece();\r\n\t\tif (unit == null) {\r\n\t\t\tMoves move = new Moves(pawnX, pawnY+direction);\r\n\t\t\tinsertMove(move, moveList);\r\n\t\t}\r\n\t}", "public int[][] Move(/*int []Start, int[]End, */Board B) {\r\n \tif(this.Status[1]=='X'||this.Position[0]<0||this.Position[1]<0) {\r\n \tSystem.out.println(\"This piece is eliminated, cannot move\");\r\n \treturn null;\t\r\n \t}\r\n \t/*\r\n \tif(this.Status[1]=='C'&&this.CMovesets==null) {\r\n \tSystem.out.println(\"This piece cannot save king in check, cannot move\");\r\n \treturn null;\t\r\n \t}\r\n \t*/\r\n \t/*\r\n \tif(Start==null||End==null) {\r\n \t\t\r\n \t\tSystem.out.println(\"Null Start or End Positions\");\r\n \t\t\r\n \t\treturn null;\r\n \t}\r\n \tif(Start.length!=2||End.length!=2) {\r\n \t\t\r\n \t\tSystem.out.println(\"Start or End Positions invalid size\");\r\n \t\t\r\n \t\treturn null;\r\n \t\t\r\n \t}\r\n \tif(Start[0]!=this.Position[0]||Start[1]!=this.Position[1]) {\r\n \t\tSystem.out.println(\"ERROR, Piece Not Synchronized with where it should be\");\r\n \t\tSystem.exit(-1);\r\n \t}\r\n \t*/\r\n \t\r\n \t///////////////////////////\r\n \tint [][]PathSeq = isAnyPath(/*Start,End,*/B);\r\n \t\r\n \tif(PathSeq==null) {\r\n \t\tSystem.out.println(\"No Path sequences possible for this piece\");\r\n \t//////////////////////////\r\n \t\t// IF PIECE IS KING, CHECK IF NO MOVES AVAILABLE to destroy enemy, \r\n \t\t//block enemy, or if king is only piece left, MOVE king, Then Checkmate!\r\n \t\r\n \t//////////////////////////\r\n \treturn null;\r\n \t}\r\n \t\r\n \t/*\r\n \tScanner reader = new Scanner(System.in);\r\n \tboolean ValidIn=false;\r\n \twhile(!ValidIn) {\r\n \t\tSystem.out.println(\"Enter Path seq to be taken\");\r\n \t\t\r\n \t\t\r\n \t}\r\n \t*/\r\n \treturn PathSeq;\r\n }", "boolean makeMove(Bouger m) {\n\tlong oldBits[] = { pieceBits[LIGHT], pieceBits[DARK] };\n\n\tint from, to;\n\t/*\n\t* test to see if a castle move is legal and move the rook (the king is\n\t* moved with the usual move code later)\n\t*/\n\tif ((m.bits & 2) != 0) {\n\n\tif (inCheck(side))\n\treturn false;\n\tswitch (m.getTo()) {\n\tcase 62:\n\tif (color[F1] != EMPTY || color[G1] != EMPTY\n\t|| attack(F1, xside) || attack(G1, xside))\n\treturn false;\n\tfrom = H1;\n\tto = F1;\n\tbreak;\n\tcase 58:\n\tif (color[B1] != EMPTY || color[C1] != EMPTY\n\t|| color[D1] != EMPTY || attack(C1, xside)\n\t|| attack(D1, xside))\n\treturn false;\n\tfrom = A1;\n\tto = D1;\n\tbreak;\n\tcase 6:\n\tif (color[F8] != EMPTY || color[G8] != EMPTY\n\t|| attack(F8, xside) || attack(G8, xside))\n\treturn false;\n\tfrom = H8;\n\tto = F8;\n\tbreak;\n\tcase 2:\n\tif (color[B8] != EMPTY || color[C8] != EMPTY\n\t|| color[D8] != EMPTY || attack(C8, xside)\n\t|| attack(D8, xside))\n\treturn false;\n\tfrom = A8;\n\tto = D8;\n\tbreak;\n\tdefault: /* shouldn't get here */\n\tfrom = -1;\n\tto = -1;\n\tbreak;\n\t}\n\tcolor[to] = color[from];\n\tpiece[to] = piece[from];\n\tcolor[from] = EMPTY;\n\tpiece[from] = EMPTY;\n\tpieceBits[side] ^= (1L << from) | (1L << to);\n\t}\n\t/* back up information so we can take the move back later. */\n\n\tHistoryData h = new HistoryData();\n\th.m = m;\n\tto = m.getTo();\n\tfrom = m.getFrom();\n\th.capture = piece[to];\n\th.castle = castle;\n\th.ep = ep;\n\th.fifty = fifty;\n\th.pawnBits = new long[] { pawnBits[LIGHT], pawnBits[DARK] };\n\th.pieceBits = oldBits;\n\thistDat[hply++] = h;\n\n\t/*\n\t* update the castle, en passant, and fifty-move-draw variables\n\t*/\n\tcastle &= castleMask[from] & castleMask[to];\n\tif ((m.bits & 8) != 0) {\n\tif (side == LIGHT)\n\tep = to + 8;\n\telse\n\tep = to - 8;\n\t} else\n\tep = -1;\n\tif ((m.bits & 17) != 0)\n\tfifty = 0;\n\telse\n\t++fifty;\n\n\t/* move the piece */\n\tint thePiece = piece[from];\n\tif (thePiece == KING)\n\tkingSquare[side] = to;\n\tcolor[to] = side;\n\tif ((m.bits & 32) != 0) {\n\tpiece[to] = m.promote;\n\tpieceMat[side] += pieceValue[m.promote];\n\t} else\n\tpiece[to] = thePiece;\n\tcolor[from] = EMPTY;\n\tpiece[from] = EMPTY;\n\tlong fromBits = 1L << from;\n\tlong toBits = 1L << to;\n\tpieceBits[side] ^= fromBits | toBits;\n\tif ((m.bits & 16) != 0) {\n\tpawnBits[side] ^= fromBits;\n\tif ((m.bits & 32) == 0)\n\tpawnBits[side] |= toBits;\n\t}\n\tint capture = h.capture;\n\tif (capture != EMPTY) {\n\tpieceBits[xside] ^= toBits;\n\tif (capture == PAWN)\n\tpawnBits[xside] ^= toBits;\n\telse\n\tpieceMat[xside] -= pieceValue[capture];\n\t}\n\n\t/* erase the pawn if this is an en passant move */\n\tif ((m.bits & 4) != 0) {\n\tif (side == LIGHT) {\n\tcolor[to + 8] = EMPTY;\n\tpiece[to + 8] = EMPTY;\n\tpieceBits[DARK] ^= (1L << (to + 8));\n\tpawnBits[DARK] ^= (1L << (to + 8));\n\t} else {\n\tcolor[to - 8] = EMPTY;\n\tpiece[to - 8] = EMPTY;\n\tpieceBits[LIGHT] ^= (1L << (to - 8));\n\tpawnBits[LIGHT] ^= (1L << (to - 8));\n\t}\n\t}\n\n\t/*\n\t* switch sides and test for legality (if we can capture the other guy's\n\t* king, it's an illegal position and we need to take the move back)\n\t*/\n\tside ^= 1;\n\txside ^= 1;\n\tif (inCheck(xside)) {\n\ttakeBack();\n\treturn false;\n\t}\n\treturn true;\n\t}", "private boolean canEats(Point piece){\r\n\t// direction -1: red pieces +1: black pieces\r\n int dir = isRed(piece)? -1:+1;\r\n int dest = dir * 2; // eat move destination\r\n // compute movement points\r\n Point left = new Point(piece.getFirst() + dir, piece.getSecond() - 1);\r\n Point left2 = new Point(piece.getFirst()+ dest, piece.getSecond() - 2);\r\n Point right = new Point(piece.getFirst() + dir, piece.getSecond() + 1);\r\n Point right2 = new Point(piece.getFirst() + dest, piece.getSecond() + 2);\r\n // check left eat\r\n if(isValidPosition(left) && isValidPosition(left2)){\r\n if(isRed(piece) && isBlack(left) && isEmpty(left2)) return true;\r\n if(isBlack(piece) && isRed(left) && isEmpty(left2)) return true;\r\n }\r\n // check right eat\r\n if(isValidPosition(right) && isValidPosition(right2)){\r\n if(isRed(piece) && isBlack(right) && isEmpty(right2)) return true;\r\n if(isBlack(piece) && isRed(right) && isEmpty(right2)) return true;\r\n }\r\n // if is a queen\r\n if(isQueen(piece)){\r\n // compute queen move points (invert direction)\r\n Point leftQ = new Point(piece.getFirst() - dir, piece.getSecond() - 1);\r\n Point leftQ2 = new Point(piece.getFirst() - dest, piece.getSecond() - 2);\r\n Point rightQ = new Point(piece.getFirst() - dir, piece.getSecond() + 1);\r\n Point rightQ2 = new Point(piece.getFirst() - dest, piece.getSecond() + 2);\r\n // check left eat\r\n if(isValidPosition(leftQ) && isValidPosition(leftQ2)){\r\n if(isRed(piece) && isBlack(leftQ) && isEmpty(leftQ2)) return true;\r\n if(isBlack(piece) && isRed(leftQ) && isEmpty(leftQ2)) return true;\r\n }\r\n // check right eat\r\n if(isValidPosition(rightQ) && isValidPosition(rightQ2)){\r\n if(isRed(piece) && isBlack(rightQ) && isEmpty(rightQ2)) return true;\r\n if(isBlack(piece) && isRed(rightQ) && isEmpty(rightQ2)) return true;\r\n }\r\n }\r\n return false;\r\n }", "private boolean moveCheck(Piece p, List<Move> m, int fC, int fR, int tC, int tR) {\n if (null == p) {\n // Legal move!\n m.add(new Move(fC, fR, tC, tR));\n // Continue checking for moves.\n return false;\n }\n if (p.owner != whoseTurn) {\n // Enemy sighted!\n // Legal move!\n m.add(new Move(fC, fR, tC, tR));\n // No more moves!\n }\n return true;\n }", "public boolean validMove(Player player, Movement move) {\n\n if (!player.hasPieceAt(move.oldP) || player.hasPieceAt(move.newP))\n return false;\n else if (sharedBoard.isBlocked(move) && !board.board[move.oldP.x][move.oldP.y].canJump())\n return false;\n else if (!sharedBoard.isPositionEmpty(move.newP))\n move = new Capture(move);\n\n return board.board[move.oldP.x][move.oldP.y].validMove(move);\n }", "private boolean tryMove(Shape newPiece, int newX, int newY) {\n for (int i = 0; i < 4; ++i) {\n\n int x = newX + newPiece.x(i);\n int y = newY - newPiece.y(i);\n//if a piece reaches the edge it stops\n if (x < 0 || x >= BOARD_WIDTH || y < 0 || y >= BOARD_HEIGHT) {\n return false;\n }\n//if a piece is adjacent to any fallen tetris pieces it stops\n if (shapeAt(x, y) != Tetrominoe.NoShape) {\n return false;\n }\n }\n\n curPiece = newPiece;\n curX = newX;\n curY = newY;\n\n repaint();\n\n return true;\n }", "public boolean movePiece(int player, int from, int to) {\n\n int piece = players.get(player).getPiece(from);\n\n // PIECELISTENER : Throw PieceEvent to PieceListeners\n for (PieceListener listener : pieceListeners) {\n PieceEvent pieceEvent = new PieceEvent(this, player, piece, from, to);\n listener.pieceMoved(pieceEvent);\n }\n\n if (piece != -1) {\n //last throw was a 6, but player is in starting position\n //end of turn\n if (this.lastThrow == 6 && players.get(player).inStartingPosition() && from == 0) {\n // PLAYERLISTENER : Trigger playerEvent for player that is WAITING\n for (PlayerListener listener : playerListeners) {\n PlayerEvent event = new PlayerEvent(this, players.get(player).getColour(), PlayerEvent.WAITING);\n listener.playerStateChanged(event);\n }\n this.setNextActivePlayer();\n }\n //player didn't throw a 6\n //end of turn\n if (this.lastThrow != 6) {\n // PLAYERLISTENER : Trigger playerEvent for player that is WAITING\n for (PlayerListener listener : playerListeners) {\n PlayerEvent event = new PlayerEvent(this, players.get(player).getColour(), PlayerEvent.WAITING);\n listener.playerStateChanged(event);\n }\n this.setNextActivePlayer();\n }\n\n //Resets the tower info when a tower is split\n if (players.get(player).getPieces().get(piece).towerPos != -1) {\n players.get(player)\n .getPieces()\n .get(piece)\n .setTower(-1);\n\n for (Piece piece2 : players.get(player).pieces) {\n if (piece2.position == from) {\n piece2.setTower(-1);\n }\n }\n }\n\n //Sets tower info when a tower is made\n for (Piece piece2 : players.get(player).pieces) {\n if (piece2.position == to) {\n //Both pieces become a tower\n piece2.setTower(piece2.position);\n players.get(player)\n .getPieces()\n .get(piece)\n .setTower(to);\n }\n }\n\n //move piece\n players.get(player)\n .getPieces()\n .get(piece)\n .setPosition(to);\n\n //set piece to in play\n if (to > 0 && to < 59) {\n players.get(player)\n .getPieces()\n .get(piece)\n .setInPlay(true);\n }\n\n checkIfAnotherPlayerLiesThere(player, to);\n\n if (to == 59) {\n\n if (players.get(player).pieceFinished()) {\n this.status = \"Finished\";\n getWinner();\n }\n }\n\n return true;\n } else {\n //doesn't work\n return false;\n }\n\n }", "public boolean isValidMove(Location from, Location to, Piece[][]b) {\n\t\t// Bishop\n\t\tboolean pieceInWay = true;\n\t\tint direction =0; \n\t\tboolean finalLocation = false;\n\t\tboolean verticalUp = false, verticalDown = false, horizontalLeft = false, horizontalRight = false;\n\t\t\n\t\tif(to.getColumn()>from.getColumn() && to.getRow()<from.getRow()){\n\t\t\tdirection = 1;\n\t\t}\n\t\telse if (to.getColumn()<from.getColumn() && to.getRow()>from.getRow()){\n\t\t\tdirection = 2;\n\t\t}\n\t\telse if (to.getColumn()<from.getColumn() && to.getRow()<from.getRow()){\n\t\t\tdirection = 4;\n\t\t}\n\t\telse\n\t\t\tdirection = 3;\t\n\t\t\n\t\t\n\t\tif (Math.abs(from.getColumn() - to.getColumn()) == Math.abs(from.getRow() - to.getRow())\n\t\t\t\t&& b[to.getRow()][to.getColumn()].getPlayer() != getPlayer()\n\t\t\t\t&& !pieceInWay/*b[to.getRow()][to.getColumn()].getPlayer() == 0 b[from.getRow()+1][from.getColumn()+1]*/) {\n\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\t// Rook\n\n\t\t//This line checks to see if the final destination of the piece contains anything but a friendly piece. This is here, because\n\t\t//anything other than a friendly piece would make the move valid, given that every space in between is blank.\n\t\tif(b[to.getRow()][to.getColumn()].getPlayer() != b[from.getRow()][from.getColumn()].getPlayer())\n\t\t\tfinalLocation = true;\n\t\telse\n\t\t\tfinalLocation = false;\n\t\t\n\t\t//verticalUp\n\t\tif(from.getRow() == to.getRow() && from.getColumn() > to.getColumn()){\n\t\t\tverticalUp = true;\n\t\t\tfor(int i = to.getColumn(); i < from.getColumn() && verticalUp; i++){\n\t\t\t\tif(b[to.getRow()][i].getPlayer() == 0 && verticalUp){\n\t\t\t\t\tverticalUp = true;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tverticalUp = false;\n\t\t\t}\n\t\t}\n\t\t//verticalDown\n\t\telse if(from.getRow() == to.getRow() && from.getColumn() < to.getColumn()){\n\t\t\tverticalDown = true;\n\t\t\tfor(int i = from.getColumn(); i < to.getColumn() && verticalDown; i++){\n\t\t\t\tif(b[from.getRow()][i].getPlayer() == 0 && verticalDown){\n\t\t\t\t\tverticalDown = true;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tverticalDown = false;\n\t\t\t}\n\t\t}\n\t\t//horizontalLeft\n\t\telse if(from.getColumn() == to.getColumn() && from.getRow() > to.getRow()){\n\t\t\thorizontalLeft = true;\n\t\t\tfor(int i = to.getRow(); i < from.getRow() && horizontalLeft; i++){\n\t\t\t\tif(b[i][to.getColumn()].getPlayer() == 0 && horizontalLeft){\n\t\t\t\t\thorizontalLeft = true;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\thorizontalLeft = false;\n\t\t\t}\n\t\t}\n\t\t//horizontalRight\n\t\telse if(from.getColumn() == to.getColumn() && from.getRow() < to.getRow()){\n\t\t\thorizontalRight = true;\n\t\t\tfor(int i = from.getRow(); i < to.getRow() && horizontalRight; i++){\n\t\t\t\tif(b[i][from.getColumn()].getPlayer() == 0 && horizontalRight){\n\t\t\t\t\thorizontalRight = true;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\thorizontalRight = false;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(verticalUp || verticalDown || horizontalLeft || horizontalRight && finalLocation){\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\treturn false;\n\t}", "public void move(int moveDirection) {\n //if same or opposite direction, check if movable\n if ((direction - moveDirection) % 6 == 0) {\n this.direction = moveDirection;\n if (moveable()) {\n if (direction == 12) {\n this.setLocation(new Point(this.getX(),\n this.getY() - speed));\n }\n //move right\n if (direction == 3) {\n this.setLocation(new Point(this.getX() + speed,\n this.getY()));\n\n }\n //move down\n if (direction == 6) {\n this.setLocation(new Point(this.getX(),\n this.getY() + speed));\n }\n //move left\n if (direction == 9) {\n this.setLocation(new Point(this.getX() - speed,\n this.getY()));\n }\n\n }\n } // if it is turning, check if can turn or not. If can turn then turn and move according to the direction before turn, otherwise, just leave the monster there\n else {\n Point snapToGridPoint = GameUtility.GameUtility.snapToGrid(\n this.getLocation());\n Point gridPoint = GameUtility.GameUtility.toGridCordinate(\n this.getLocation());\n Point nextPoint = new Point(gridPoint.x, gridPoint.y);\n //if the distance is acceptable\n if (GameUtility.GameUtility.distance(snapToGridPoint,\n this.getLocation()) < GameUtility.GameUtility.TILE_SIZE / 2.5) {\n\n if (moveDirection == 3) {\n int x = Math.max(0, gridPoint.x + 1);\n nextPoint = new Point(x, gridPoint.y);\n } else if (moveDirection == 6) {\n int y = Math.max(0, gridPoint.y + 1);\n nextPoint = new Point(gridPoint.x, y);\n } else if (moveDirection == 9) {\n int x = Math.min(19, gridPoint.x - 1);\n nextPoint = new Point(x, gridPoint.y);\n } else if (moveDirection == 12) {\n int y = Math.min(19, gridPoint.y - 1);\n nextPoint = new Point(gridPoint.x, y);\n }\n // if the turn is empty, then snap the monster to the grid location\n if (!(GameManager.getGameMap().getFromMap(nextPoint) instanceof Wall) && !(GameManager.getGameMap().getFromMap(\n nextPoint) instanceof Bomb)) {\n if (GameUtility.GameUtility.distance(snapToGridPoint,\n this.getLocation()) < GameUtility.GameUtility.TILE_SIZE / 10) {\n this.setLocation(snapToGridPoint);\n this.direction = moveDirection;\n } else {\n if (direction == 9 || direction == 3) {\n int directionOfMovement = (snapToGridPoint.x - getX());\n directionOfMovement = directionOfMovement / Math.abs(\n directionOfMovement);\n this.setLocation(new Point(\n this.getX() + directionOfMovement * speed,\n this.getY()));\n } else if (direction == 12 || direction == 6) {\n int directionOfMovement = (snapToGridPoint.y - getY());\n directionOfMovement = directionOfMovement / Math.abs(\n directionOfMovement);\n this.setLocation(new Point(\n this.getX(),\n this.getY() + directionOfMovement * speed));\n }\n }\n }\n }\n }\n }", "@Test\n public void testGetPossibleMoveCoordinate() throws Exception{\n ChessBoard board = new ChessBoard(8, 8);\n Piece p;\n\n p = new Pawn(board, Player.WHITE);\n p.setCoordinate(0, 0);\n assertEquals(2, p.getPossibleMoveCoordinate().size()); // first time move, therefore it should be able to advance two squares.\n\n\n p.setCoordinate(0, 1);\n assertEquals(1, p.getPossibleMoveCoordinate().size()); // already moved, therefore it could move two squares.\n\n\n /*\n * create a pawn in same group\n * put it ahead p, then p couldn't move\n */\n Piece friend = new Pawn(board, Player.WHITE);\n friend.setCoordinate(0, 2);\n assertEquals(0, p.getPossibleMoveCoordinate().size());\n\n /*\n * create an opponent piece at top right\n * therefore, p can move top right\n */\n Piece opponent_piece = new Pawn(board, Player.BLACK);\n opponent_piece.setCoordinate(1, 2);\n assertEquals(1, p.getPossibleMoveCoordinate().size());\n\n /*\n * p reaches top boundary\n */\n p.setCoordinate(0, 7);\n assertEquals(0, p.getPossibleMoveCoordinate().size());\n }", "public void applyConvertedMove(String move) {\n\n\t\tString[] moveParts = move.split(\";\");\n\n\t\tint fromRow = Integer.parseInt(moveParts[0].charAt(0) + \"\");\n\t\tint fromCol = Integer.parseInt(moveParts[0].charAt(1) + \"\");\n\n\t\tint toRow = Integer.parseInt(moveParts[1].charAt(0) + \"\");\n\t\tint toCol = Integer.parseInt(moveParts[1].charAt(1) + \"\");\n\n\t\tint piece = board[fromRow][fromCol];//Integer.parseInt(moveParts[2]);\n\t\tint pieceType = Math.abs(board[fromRow][fromCol]);\n\t\tint team = Math.round(Math.signum(board[fromRow][fromCol]));\n\n\t\tboolean doResetEnpassant = true;\n\n\t\tif (pieceType == 1) { //If this is a pawn\n\t\t\tif (Math.abs(board[toRow][toCol]) == 7) { //If it is moving onto an enpassant stored tile\n\t\t\t\tboard[toRow + board[toRow][toCol]/7][toCol] = 0; //Kill the pawn that produced the enpassant tile\n\t\t\t} else if (Math.abs(fromRow - toRow) == 2) { //If it just did the double move thing\n\t\t\t\t//Reset the current enpassant tile\n\t\t\t\tresetEnpassant(team);\n\t\t\t\tdoResetEnpassant = false;\n\n\t\t\t\t//Set an empassant tile\n\t\t\t\tboard[(toRow + fromRow)/2][toCol] = 7 * team;\n\t\t\t\tenpassantCol = toCol;\n\t\t\t}\n\t\t} else if (pieceType == 6) { //If this is a king\n\t\t\tif (fromCol == 4) {\n\t\t\t\tif (doResetEnpassant) resetEnpassant(team);\n\t\t\t\tif (toCol == 7) { //Kingside Castle\n\t\t\t\t\tboard[toRow][6] = piece;\n\t\t\t\t\tboard[toRow][5] = board[toRow][7];\n\t\t\t\t\tboard[toRow][7] = 0;\n\t\t\t\t\tboard[toRow][4] = 0;\n\t\t\t\t\treturn;\n\t\t\t\t} else if (toCol == 0) { //Queenside Castle\n\t\t\t\t\tboard[toRow][2] = piece;\n\t\t\t\t\tboard[toRow][3] = board[toRow][0];\n\t\t\t\t\tboard[toRow][0] = 0;\n\t\t\t\t\tboard[toRow][4] = 0;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (doResetEnpassant) resetEnpassant(team);\n\t\tboard[fromRow][fromCol] = 0;\n\t\tif (moveParts.length > 2 && pieceType == 1 && (team == 1 ? toRow == 7 : team == -1 ? toRow == 0 : false)) {\n\t\t\tpiece = Integer.parseInt(moveParts[2]);\n\t\t}\n\t\tboard[toRow][toCol] = piece;\n\t}", "public void enemymoveGarret(){\n\t\tint YEG = 0;\n\t\tint XEG = 0;\n\t\tint[] turns = new int[]{0,0,0,0,0,2,1,1,1,1,1,3};//dependign on the placement garret will move a certain way\n\t\tfor(int i = 0 ; i < this.Garret.length;i++){//this grabs garrets current locations\n\t\t\tfor(int p = 0; p < this.Garret.length;p++){\n\t\t\t\tif(this.Garret[i][p] == 1){\n\t\t\t\t\tYEG = i;\n\t\t\t\t\tXEG = p;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tint move = turns[count];\n\t\tswitch(move){//first block is up and down second block is left and right\n\t\t\tcase 0:\n\t\t\t\tif(this.area[YEG][XEG-1] != \"[ ]\"){\n\t\t\t\t\tthis.Garret[YEG][XEG-1] = 1;//to turn left\n\t\t\t\t\tthis.Garret[YEG][XEG] = 0;\n\t\t\t\t\tcount++;\n\t\t\t\t\tif(count == 12){\n\t\t\t\t\t\tcount = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\tif(this.area[YEG][XEG+1] != \"[ ]\"){\n\t\t\t\t\tthis.Garret[YEG][XEG+1] = 1;//to turn right\n\t\t\t\t\tthis.Garret[YEG][XEG] = 0;\n\t\t\t\t\tcount++;\n\t\t\t\t\tif(count == 12){\n\t\t\t\t\t\tcount = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tif(this.area[YEG-1][XEG] != \"[ ]\"){\n\t\t\t\t\tthis.Garret[YEG-1][XEG] = 1;//to turn up\n\t\t\t\t\tthis.Garret[YEG][XEG] = 0;\n\t\t\t\t\tcount++;\n\t\t\t\t\tif(count == 12){\n\t\t\t\t\t\tcount = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\tif(this.area[YEG+1][XEG] != \"[ ]\"){\n\t\t\t\t\tthis.Garret[YEG+1][XEG] = 1;//to turn down\n\t\t\t\t\tthis.Garret[YEG][XEG] = 0;\n\t\t\t\t\tcount++;\n\t\t\t\t\tif(count == 12){\n\t\t\t\t\t\tcount = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}//end of switch\t\n\t}", "boolean isLegal(String move) {\n int[][] theStatusBoard;\n if (_playerOnMove == ORANGE) {\n theStatusBoard = _orangeStatusBoard;\n } else {\n theStatusBoard = _violetStatusBoard;\n }\n Pieces thispiece = new Pieces();\n String piecename = move.substring(0, 1);\n int col = getCoordinate(move.substring(1, 2));\n int row = getCoordinate(move.substring(2, 3));\n int ori = Integer.parseInt(move.substring(3, 4));\n int[][] initialPositions = thispiece.getInitialPositions(piecename);\n int[][] finalPositions = thispiece.processPositions(initialPositions, ori);\n int depth = finalPositions.length;\n int length = finalPositions[0].length;\n\n if (row + depth - 1 > 13 || col + length - 1 > 13) {\n System.out.println(\"Your move makes your piece out of the board, try again!\");\n return false;\n }\n\n boolean has1 = false;\n boolean no2 = true;\n\n int i, j;\n for (i = 0; i < depth; i++) {\n for (j = 0; j < length; j++) {\n if (finalPositions[i][j] == 1) {\n if (theStatusBoard[15 - (row + depth - i)][col + j + 1] == 1) {\n has1 = true;\n } else if (theStatusBoard[15 - (row + depth - i)][col + j + 1] == 2) {\n return false;\n }\n }\n }\n }\n System.out.println(\"has1: \" + has1);\n return has1;\n }", "private boolean isLastMoveRochade()\r\n\t{\r\n\t\tMove lastMove = getLastMove();\r\n\t\tif (lastMove == null) return false;\r\n\t\tPiece king = lastMove.to.piece;\r\n\t\tif (!(king instanceof King)) return false;\r\n\t\t\r\n\t\tint y = king.getColor().equals(Color.WHITE) ? 0 : 7;\r\n\t\tif (lastMove.to.coordinate.y != y) return false;\r\n\t\t\r\n\t\tint xDiffAbs = Math.abs(lastMove.to.coordinate.x - lastMove.from.coordinate.x); \r\n\t\treturn xDiffAbs == 2;\r\n\t}", "@Test\n public void testMovePieceValidMove() {\n Position pos = new Position(board, 3, 3);\n Pawn pawn = new Pawn(Color.WHITE);\n board.getSquare(pos).addPiece(pawn);\n pawn.setPosition(pos);\n Position pos1 = new Position(board, 4, 3);\n assertTrue(chess.movePiece(board.getSquare(pos), board.getSquare(pos1), pawn));\n }", "public synchronized boolean MoveThatFigure(Figures.Color color, Figures.Type typ, Point pozice, Point direction, ArrayList<ModelObject> objekty) {\n for (Object obj : objekty) {\r\n objectsForMovement.add((ModelObject) obj);\r\n }\r\n\r\n Point pomPozice = new Point(pozice);\r\n Point pomDirxM = new Point(direction);\r\n Point pomDiryM = new Point(direction);\r\n Point pomDirxP = new Point(direction);\r\n Point pomDiryP = new Point(direction);\r\n Point BeforeLast = new Point();\r\n\r\n pomDirxM.x = pomDirxM.x - 1;\r\n pomDiryM.y = pomDiryM.y - 1;\r\n pomDirxP.x = pomDirxP.x + 1;\r\n pomDiryP.y = pomDiryP.y + 1;\r\n\r\n if (color == Figures.Color.White) {\r\n if (typ == Figures.Type.Pawn) {\r\n if ((direction.x == pozice.x && direction.y == pozice.y - 1)\r\n && free.isFree(direction, objectsForMovement)) {\r\n side = false;\r\n return true;\r\n }\r\n if ((direction.x == pozice.x - 1 && direction.y == pozice.y - 1\r\n || direction.x == pozice.x + 1 && direction.y == pozice.y - 1)\r\n && !free.isFree(direction, objectsForMovement)) {\r\n side = false;\r\n this.pawnTaking = true;\r\n return true;\r\n }\r\n }\r\n\r\n if (typ == Figures.Type.Rook) {\r\n // if ((CanTake(direction, Figures.Color.Black)) || free.isFree(direction, objectsForMovement)) {\r\n if (pozice.equals(pomDirxM)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDirxP)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDiryM)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDiryP)) {\r\n side = false;\r\n return true;\r\n } else {\r\n do {\r\n if ((direction.x == pomPozice.x && direction.y >= pomPozice.y)) {\r\n pomPozice.y = pomPozice.y + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDiryM;\r\n } else if (direction.x == pomPozice.x && direction.y <= pomPozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDiryP;\r\n } else if (direction.x <= pomPozice.x && direction.y == pomPozice.y) {\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDirxP;\r\n } else if (direction.x >= pomPozice.x && direction.y == pomPozice.y) {\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDirxM;\r\n }\r\n if (mahmadan == false) {\r\n break;\r\n }\r\n\r\n } while ((pomPozice.x != BeforeLast.x) || (pomPozice.y != BeforeLast.y));\r\n if (mahmadan == true) {\r\n side = false;\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n }\r\n // }\r\n\r\n if (typ == Figures.Type.Knight) {\r\n // if ((CanTake(direction, Figures.Color.Black)) || free.isFree(direction, objectsForMovement)) {\r\n if ((direction.x == pozice.x + 2 && direction.y == pozice.y - 1)\r\n || (direction.x == pozice.x - 2 && direction.y == pozice.y - 1)\r\n || (direction.x == pozice.x - 2 && direction.y == pozice.y + 1)\r\n || (direction.x == pozice.x + 2 && direction.y == pozice.y + 1)\r\n || (direction.x == pozice.x + 1 && direction.y == pozice.y + 2)\r\n || (direction.x == pozice.x + 1 && direction.y == pozice.y - 2)\r\n || (direction.x == pozice.x - 1 && direction.y == pozice.y - 2)\r\n || (direction.x == pozice.x - 1 && direction.y == pozice.y + 2)) {\r\n side = false;\r\n return true;\r\n }\r\n }\r\n // }\r\n\r\n if (typ == Figures.Type.Bishop) {\r\n // if ((CanTake(direction, Figures.Color.Black)) || free.isFree(direction, objectsForMovement)) {\r\n if (Math.abs(pozice.x - direction.x) == Math.abs(pozice.y - direction.y)) {\r\n if (pozice.x == pomDirxM.x && pozice.y == pomDiryM.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDirxP.x && pozice.y == pomDiryP.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDiryM.x && pozice.y == pomDiryP.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDiryP.x && pozice.y == pomDiryM.y) {\r\n side = false;\r\n return true;\r\n } else {\r\n do {\r\n if (direction.x >= pozice.x && direction.y >= pozice.y) {\r\n pomPozice.y = pomPozice.y + 1;\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxM.x;\r\n BeforeLast.y = pomDiryM.y;\r\n } else if (direction.x <= pozice.x && direction.y >= pozice.y) {\r\n pomPozice.y = pomPozice.y + 1;\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxP.x;\r\n BeforeLast.y = pomDiryM.y;\r\n } else if (direction.x <= pozice.x && direction.y <= pozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxP.x;\r\n BeforeLast.y = pomDiryP.y;\r\n } else if (direction.x >= pozice.x && direction.y <= pozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxM.x;\r\n BeforeLast.y = pomDiryP.y;\r\n }\r\n if (mahmadan == false) {\r\n break;\r\n }\r\n } while ((pomPozice.x != BeforeLast.x) && (pomPozice.y != BeforeLast.y));\r\n if (mahmadan == true) {\r\n side = false;\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n // }\r\n\r\n if (typ == Figures.Type.Queen) {\r\n // if ((CanTake(direction, Figures.Color.Black)) || free.isFree(direction, objectsForMovement)) {\r\n if (pozice.equals(pomDirxM)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDirxP)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDiryM)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDiryP)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDirxM.x && pozice.y == pomDiryM.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDirxP.x && pozice.y == pomDiryP.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDiryM.x && pozice.y == pomDiryP.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDiryP.x && pozice.y == pomDiryM.y) {\r\n side = false;\r\n return true;\r\n } else {\r\n if (((direction.x >= pozice.x && direction.y >= pozice.y)\r\n || (direction.x <= pozice.x && direction.y >= pozice.y)\r\n || (direction.x <= pozice.x && direction.y <= pozice.y)\r\n || (direction.x >= pozice.x && direction.y <= pozice.y))\r\n && (Math.abs(pozice.x - direction.x) == Math.abs(pozice.y - direction.y))) {\r\n do {\r\n if (direction.x >= pozice.x && direction.y >= pozice.y) {\r\n pomPozice.y = pomPozice.y + 1;\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxM.x;\r\n BeforeLast.y = pomDiryM.y;\r\n } else if (direction.x <= pozice.x && direction.y >= pozice.y) {\r\n pomPozice.y = pomPozice.y + 1;\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxP.x;\r\n BeforeLast.y = pomDiryM.y;\r\n } else if (direction.x <= pozice.x && direction.y <= pozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxP.x;\r\n BeforeLast.y = pomDiryP.y;\r\n } else if (direction.x >= pozice.x && direction.y <= pozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxM.x;\r\n BeforeLast.y = pomDiryP.y;\r\n }\r\n if (mahmadan == false) {\r\n break;\r\n }\r\n } while ((pomPozice.x != BeforeLast.x) && (pomPozice.y != BeforeLast.y));\r\n if ((Math.abs(pozice.x - direction.x) == Math.abs(pozice.y - direction.y)) && mahmadan == true) {\r\n side = false;\r\n return true;\r\n }\r\n }\r\n if ((direction.x == pozice.x && direction.y >= pozice.y)\r\n || (direction.x == pozice.x && direction.y <= pozice.y)\r\n || (direction.x <= pozice.x && direction.y == pozice.y)\r\n || (direction.x >= pozice.x && direction.y == pozice.y)) {\r\n do {\r\n if ((direction.x == pomPozice.x && direction.y >= pomPozice.y)) {\r\n pomPozice.y = pomPozice.y + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDiryM;\r\n } else if (direction.x == pomPozice.x && direction.y <= pomPozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDiryP;\r\n } else if (direction.x <= pomPozice.x && direction.y == pomPozice.y) {\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDirxP;\r\n } else if (direction.x >= pomPozice.x && direction.y == pomPozice.y) {\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDirxM;\r\n }\r\n if (mahmadan == false) {\r\n break;\r\n }\r\n\r\n } while ((pomPozice.x != BeforeLast.x) || (pomPozice.y != BeforeLast.y));\r\n if (mahmadan == true) {\r\n side = false;\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n }\r\n }\r\n // }\r\n\r\n if (typ == Figures.Type.King) {\r\n // if ((CanTake(direction, Figures.Color.Black)) || free.isFree(direction, objectsForMovement)) {\r\n if (direction.x == pozice.x && direction.y == pozice.y - 1 || direction.x == pozice.x - 1 && direction.y == pozice.y - 1\r\n || direction.x == pozice.x && direction.y == pozice.y + 1 || direction.x == pozice.x - 1 && direction.y == pozice.y + 1\r\n || direction.x == pozice.x + 1 && direction.y == pozice.y || direction.x == pozice.x + 1 && direction.y == pozice.y - 1\r\n || direction.x == pozice.x - 1 && direction.y == pozice.y || direction.x == pozice.x + 1 && direction.y == pozice.y + 1) {\r\n side = false;\r\n return true;\r\n }\r\n }\r\n //}\r\n\r\n } else if (color == Figures.Color.Black) {/* && side == false*/\r\n\r\n if (typ == Figures.Type.Pawn) {\r\n if ((direction.x == pozice.x && direction.y == pozice.y + 1)\r\n && free.isFree(direction, objectsForMovement)) {\r\n side = true;\r\n return true;\r\n }\r\n if (CanTake(direction, Figures.Color.White)) {\r\n if ((direction.x == pozice.x - 1 && direction.y == pozice.y + 1\r\n || direction.x == pozice.x + 1 && direction.y == pozice.y + 1)\r\n && !free.isFree(direction, objectsForMovement)) {\r\n side = true;\r\n this.pawnTaking = true;\r\n return true;\r\n }\r\n }\r\n }\r\n if (typ == Figures.Type.Rook) {\r\n if ((CanTake(direction, Figures.Color.White)) || free.isFree(direction, objectsForMovement)) {\r\n if (pozice.equals(pomDirxM)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDirxP)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDiryM)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDiryP)) {\r\n side = false;\r\n return true;\r\n } else {\r\n do {\r\n if ((direction.x == pomPozice.x && direction.y >= pomPozice.y)) {\r\n pomPozice.y = pomPozice.y + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDiryM;\r\n } else if (direction.x == pomPozice.x && direction.y <= pomPozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDiryP;\r\n } else if (direction.x <= pomPozice.x && direction.y == pomPozice.y) {\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDirxP;\r\n } else if (direction.x >= pomPozice.x && direction.y == pomPozice.y) {\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDirxM;\r\n }\r\n if (mahmadan == false) {\r\n break;\r\n }\r\n\r\n } while ((pomPozice.x != BeforeLast.x) || (pomPozice.y != BeforeLast.y));\r\n if (mahmadan == true) {\r\n side = false;\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (typ == Figures.Type.Knight) {\r\n if ((CanTake(direction, Figures.Color.White)) || free.isFree(direction, objectsForMovement)) {\r\n if ((direction.x == pozice.x + 2 && direction.y == pozice.y - 1)\r\n || (direction.x == pozice.x - 2 && direction.y == pozice.y - 1)\r\n || (direction.x == pozice.x - 2 && direction.y == pozice.y + 1)\r\n || (direction.x == pozice.x + 2 && direction.y == pozice.y + 1)\r\n || (direction.x == pozice.x + 1 && direction.y == pozice.y + 2)\r\n || (direction.x == pozice.x + 1 && direction.y == pozice.y - 2)\r\n || (direction.x == pozice.x - 1 && direction.y == pozice.y - 2)\r\n || (direction.x == pozice.x - 1 && direction.y == pozice.y + 2)) {\r\n side = true;\r\n return true;\r\n }\r\n }\r\n }\r\n\r\n if (typ == Figures.Type.Bishop) {\r\n if (Math.abs(pozice.x - direction.x) == Math.abs(pozice.y - direction.y)) {\r\n if ((CanTake(direction, Figures.Color.White)) || free.isFree(direction, objectsForMovement)) {\r\n if (pozice.x == pomDirxM.x && pozice.y == pomDiryM.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDirxP.x && pozice.y == pomDiryP.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDiryM.x && pozice.y == pomDiryP.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDiryP.x && pozice.y == pomDiryM.y) {\r\n side = false;\r\n return true;\r\n } else {\r\n do {\r\n if (direction.x >= pozice.x && direction.y >= pozice.y) {\r\n pomPozice.y = pomPozice.y + 1;\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxM.x;\r\n BeforeLast.y = pomDiryM.y;\r\n } else if (direction.x <= pozice.x && direction.y >= pozice.y) {\r\n pomPozice.y = pomPozice.y + 1;\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxP.x;\r\n BeforeLast.y = pomDiryM.y;\r\n } else if (direction.x <= pozice.x && direction.y <= pozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxP.x;\r\n BeforeLast.y = pomDiryP.y;\r\n } else if (direction.x >= pozice.x && direction.y <= pozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxM.x;\r\n BeforeLast.y = pomDiryP.y;\r\n }\r\n if (mahmadan == false) {\r\n break;\r\n }\r\n } while ((pomPozice.x != BeforeLast.x) && (pomPozice.y != BeforeLast.y));\r\n if ((Math.abs(pozice.x - direction.x) == Math.abs(pozice.y - direction.y)) && mahmadan == true) {\r\n side = false;\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (typ == Figures.Type.Queen) {\r\n if ((CanTake(direction, Figures.Color.White)) || free.isFree(direction, objectsForMovement)) {\r\n if (pozice.equals(pomDirxM)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDirxP)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDiryM)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDiryP)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDirxM.x && pozice.y == pomDiryM.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDirxP.x && pozice.y == pomDiryP.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDiryM.x && pozice.y == pomDiryP.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDiryP.x && pozice.y == pomDiryM.y) {\r\n side = false;\r\n return true;\r\n } else {\r\n if (((direction.x >= pozice.x && direction.y >= pozice.y)\r\n || (direction.x <= pozice.x && direction.y >= pozice.y)\r\n || (direction.x <= pozice.x && direction.y <= pozice.y)\r\n || (direction.x >= pozice.x && direction.y <= pozice.y))\r\n && (Math.abs(pozice.x - direction.x) == Math.abs(pozice.y - direction.y))) {\r\n do {\r\n if (direction.x >= pozice.x && direction.y >= pozice.y) {\r\n pomPozice.y = pomPozice.y + 1;\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxM.x;\r\n BeforeLast.y = pomDiryM.y;\r\n } else if (direction.x <= pozice.x && direction.y >= pozice.y) {\r\n pomPozice.y = pomPozice.y + 1;\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxP.x;\r\n BeforeLast.y = pomDiryM.y;\r\n } else if (direction.x <= pozice.x && direction.y <= pozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxP.x;\r\n BeforeLast.y = pomDiryP.y;\r\n } else if (direction.x >= pozice.x && direction.y <= pozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxM.x;\r\n BeforeLast.y = pomDiryP.y;\r\n }\r\n if (mahmadan == false) {\r\n break;\r\n }\r\n } while ((pomPozice.x != BeforeLast.x) && (pomPozice.y != BeforeLast.y));\r\n if ((Math.abs(pozice.x - direction.x) == Math.abs(pozice.y - direction.y)) && mahmadan == true) {\r\n side = false;\r\n return true;\r\n }\r\n }\r\n if ((direction.x == pozice.x && direction.y >= pozice.y)\r\n || (direction.x == pozice.x && direction.y <= pozice.y)\r\n || (direction.x <= pozice.x && direction.y == pozice.y)\r\n || (direction.x >= pozice.x && direction.y == pozice.y)) {\r\n do {\r\n if ((direction.x == pomPozice.x && direction.y >= pomPozice.y)) {\r\n pomPozice.y = pomPozice.y + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDiryM;\r\n } else if (direction.x == pomPozice.x && direction.y <= pomPozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDiryP;\r\n } else if (direction.x <= pomPozice.x && direction.y == pomPozice.y) {\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDirxP;\r\n } else if (direction.x >= pomPozice.x && direction.y == pomPozice.y) {\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDirxM;\r\n }\r\n if (mahmadan == false) {\r\n break;\r\n }\r\n\r\n } while ((pomPozice.x != BeforeLast.x) || (pomPozice.y != BeforeLast.y));\r\n if (mahmadan == true) {\r\n side = false;\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (typ == Figures.Type.King) {\r\n if ((CanTake(direction, Figures.Color.White)) || free.isFree(direction, objectsForMovement)) {\r\n if (direction.x == pozice.x && direction.y == pozice.y - 1\r\n || direction.x == pozice.x - 1 && direction.y == pozice.y - 1\r\n || direction.x == pozice.x && direction.y == pozice.y + 1\r\n || direction.x == pozice.x - 1 && direction.y == pozice.y + 1\r\n || direction.x == pozice.x + 1 && direction.y == pozice.y\r\n || direction.x == pozice.x + 1 && direction.y == pozice.y - 1\r\n || direction.x == pozice.x - 1 && direction.y == pozice.y\r\n || direction.x == pozice.x + 1 && direction.y == pozice.y + 1) {\r\n side = true;\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n return false;\r\n }", "@Override\n public boolean hasPossibleCapture(final Coordinate destination) {\n\n Coordinate coordinate = this.getCoordinate();\n int row = coordinate.getRow();\n int col = coordinate.getCol();\n\n //\n //\n ////\n int tempRow1 = row - 2;\n int tempCol1 = col - 1;\n Coordinate tempCoordinate1 = new Coordinate(tempRow1, tempCol1);\n if (destination.equals(tempCoordinate1)) {\n return true;\n }\n\n ////\n //\n //\n int tempRow2 = row + 2;\n int tempCol2 = col - 1;\n Coordinate tempCoordinate2 = new Coordinate(tempRow2, tempCol2);\n if (destination.equals(tempCoordinate2)) {\n return true;\n }\n\n //////\n //\n int tempRow3 = row - 1;\n int tempCol3 = col - 2;\n Coordinate tempCoordinate3 = new Coordinate(tempRow3, tempCol3);\n if (destination.equals(tempCoordinate3)) {\n return true;\n }\n\n ///////\n //\n int tempRow4 = row - 1;\n int tempCol4 = col + 2;\n Coordinate tempCoordinate4 = new Coordinate(tempRow4, tempCol4);\n if (destination.equals(tempCoordinate4)) {\n return true;\n }\n\n ////\n //\n //\n int tempRow5 = row + 2;\n int tempCol5 = col + 1;\n Coordinate tempCoordinate5 = new Coordinate(tempRow5, tempCol5);\n if (destination.equals(tempCoordinate5)) {\n return true;\n }\n\n //\n //\n ////\n int tempRow6 = row - 2;\n int tempCol6 = col + 1;\n Coordinate tempCoordinate6 = new Coordinate(tempRow6, tempCol6);\n if (destination.equals(tempCoordinate6)) {\n return true;\n }\n\n //\n //////\n int tempRow7 = row + 1;\n int tempCol7 = col - 2;\n Coordinate tempCoordinate7 = new Coordinate(tempRow7, tempCol7);\n if (destination.equals(tempCoordinate7)) {\n return true;\n }\n\n //\n //////\n int tempRow8 = row + 1;\n int tempCol8 = col + 2;\n Coordinate tempCoordinate8 = new Coordinate(tempRow8, tempCol8);\n return destination.equals(tempCoordinate8);\n }", "public void movePiece(Location a, Location b)\n {\n Square s1 = getSquare(a);\n Square s2 = getSquare(b);\n Piece p = s1.getPiece();\n if (p==null)\n return;\n int moveType = canMoveTo(p,b);\n boolean taking = getPiece(b)!=null;\n boolean fiftyMoveBreak = getPiece(b)!=null||p.getType()==Type.PAWN;\n s2.setPiece(s1.removePiece());\n p.setHasMoved(true);\n if (p.getType()==Type.PAWN)\n {\n if (mainBoard&&((p.white()&&getLocation(p).getRow()==0)\n || !p.white()&&getLocation(p).getRow()==7))\n promotePawn(p);\n else if (moveType==EN_PASSANT)\n {\n int row = a.getRow();\n int col = b.getCol();\n removePiece(new Location(row,col));\n taking = true;\n }\n }\n else if (moveType==KINGSIDE_CASTLING||moveType==QUEENSIDE_CASTLING)\n {\n Location rookLoc;\n Location rookDest;\n if (moveType==KINGSIDE_CASTLING)\n {\n rookLoc = b.farther(Direction.EAST);\n rookDest = b.farther(Direction.WEST);\n }\n else\n {\n rookLoc = new Location(b.getRow(),b.getCol()-2);\n rookDest = b.farther(Direction.EAST);\n }\n //movePiece(getLocation(rook),rookDest);\n getSquare(rookDest).setPiece(removePiece(rookLoc)); //moves the rook\n }\n if (mainBoard)\n {\n turn++;\n if (fiftyMoveBreak)\n fiftyMove= 0;\n else fiftyMove++;\n }\n for (Piece piece: getPieces())\n piece.setHasJustMoved(false);\n p.setHasJustMoved(true);\n if (mainBoard)\n {\n positions.add(toString());\n \n //this is all for the notation on the side\n notateMove(p,b,moveType,taking);\n /*JTable not = frame.getNotation();\n DefaultTableModel d = (DefaultTableModel)not.getModel();\n String notation;\n PieceColor color = p.getColor();\n if (color==PieceColor.WHITE)\n notation = turn/2+1+\". \"; //the turn number first, on the left\n else notation = \"\";\n if (moveType==QUEENSIDE_CASTLING)\n notation += \"0-0-0\";\n else if (moveType==KINGSIDE_CASTLING)\n notation += \"0-0\";\n else //normal move\n {\n if (p.getType()!=Type.PAWN)\n notation+=p.getType().toNotation(); //the type of piece (K,N,R,etc)\n if (taking)\n notation+=\"x\"; //this is if the move involves taking\n notation+=Location.LocToNot(b);\n }\n if (checkmate(colorGoing())) //notates # for checkmate\n notation+=\"#\";\n else if (inCheck(colorGoing())) //notates + for check\n notation+=\"+\";\n \n if (color==PieceColor.WHITE)\n d.addRow(new Object[]{notation,\"\"});\n else \n d.setValueAt(notation, (turn-1)/2, 1);*/\n }\n }", "private boolean handleIllegalMove(String line){\n if (!(line.startsWith(\"Illegal move \") ||\n line.equals(\"It is not your move.\") ||\n line.equals(\"The clock is paused, use \\\"unpause\\\" to resume.\")))\n return false;\n \n Matcher illegalMoveMatcher = ILLEGAL_MOVE_REGEX.matcher(line);\n Matcher notYourTurnMatcher = NOT_YOUR_TURN_REGEX.matcher(line);\n Matcher movedWhenGamePausedMatcher = MOVED_WHEN_GAME_PAUSED.matcher(line);\n\n if (illegalMoveMatcher.matches()){\n String moveString = illegalMoveMatcher.group(1);\n String reason = illegalMoveMatcher.group(2);\n\n if (!processIllegalMove(moveString, reason))\n processLine(line);\n\n return true;\n }\n else if (notYourTurnMatcher.matches()){\n String moveString = null; // sigh\n String reason = notYourTurnMatcher.group(1);\n\n if (!processIllegalMove(moveString, reason))\n processLine(line);\n\n return true;\n }\n else if (movedWhenGamePausedMatcher.matches()){\n String moveString = null;\n String reason = movedWhenGamePausedMatcher.group(1);\n \n if (!processIllegalMove(moveString, reason))\n processLine(line);\n \n return true;\n }\n\n return false;\n }", "private boolean checkMoveOthers(Pieces piece, Coordinates from, Coordinates to) {\n\t\t\t\t\n\t\t/* \n\t\t *il pedone: \n\t\t * -può andare dritto sse davanti a se non ha pedine\n\t\t * -può andare obliquo sse in quelle posizioni ha una pedina avversaria da mangiare\n\t\t * \n\t\t */\n\t\tif (piece instanceof Pawn) {\n\t\t\tif (from.getY() == to.getY()) {\n\t\t\t\tif(chessboard.at(to) == null)\n\t\t\t\t\treturn true;\n\t\t\t\telse\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(chessboard.at(to) == null) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t\n\t\t//il cavallo salta le pedine nel mezzo\n\t\tif (piece instanceof Knight)\n\t\t\treturn true;\n\t\t\n\t\t//Oltre non andranno il: cavallo, il re ed il pedone.\n\t\t/*\n\t\t *Calcolo le posizioni che intercorrono tra il from ed il to escluse \n\t\t *ed per ogni posizione verifico se è vuota\n\t\t *-se in almeno una posizione c'è una pedina(non importa il colore), la mossa non è valida\n\t\t *-altrimenti, la strada è spianata quindi posso effettuare lo spostamento \n\t\t */\n\t\tArrayList<Coordinates> path = piece.getPath(from, to);\n\t\tfor (Coordinates coordinate : path) {\n\t\t\tif ( chessboard.at(coordinate) != null ){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}", "public void checkwarp(){\n\t\tif(pacman.ypos > (colours[0].length*interval)-2){\r\n\t\t\tpacman.ypos = interval+2;\r\n\t\t}\r\n\t\telse if(pacman.xpos > (colours.length*interval)-2){\r\n\t\t\tpacman.xpos = interval+2;\r\n\t\t}\r\n\t\telse if(pacman.ypos < interval+2){\r\n\t\t\tpacman.ypos = (colours[0].length*interval)-2;\r\n\t\t}\r\n\t\telse if(pacman.xpos < interval+2){\r\n\t\t\tpacman.xpos = (colours.length*interval)-2;\r\n\t\t}\r\n\t\t\r\n\t}", "public boolean isLegalStep(MoveDirection dir){\r\n GamePosition curPos = currentGame.getCurrentPosition();\n\t\tPlayer white = currentGame.getWhitePlayer();\n\t\tint[] toCheckPos = new int[2];\n\t\tint[] existingPos = new int[2];\n\t\tif(curPos.getPlayerToMove().equals(white)) {\n\t\t\ttoCheckPos[0] = curPos.getWhitePosition().getTile().getColumn();\n\t\t\ttoCheckPos[1] = curPos.getWhitePosition().getTile().getRow();\n\t\t\t\n\t\t\texistingPos[0] = curPos.getBlackPosition().getTile().getColumn();\n\t\t\texistingPos[1] = curPos.getBlackPosition().getTile().getRow();\n\t\t\t\n\t\t} else {\n\t\t\ttoCheckPos[0] = curPos.getBlackPosition().getTile().getColumn();\n\t\t\ttoCheckPos[1] = curPos.getBlackPosition().getTile().getRow();\n\t\t\t\n\t\t\texistingPos[0] = curPos.getWhitePosition().getTile().getColumn();\n\t\t\texistingPos[1] = curPos.getWhitePosition().getTile().getRow();\n\t\t}\n\t\t//0 = column, 1 = row\n\t\tif(dir == MoveDirection.North) {\n\t\t\tif(toCheckPos[1] == 1) return false;\n\t\t\tif(toCheckPos[1] - 1 == existingPos[1] && toCheckPos[0] == existingPos[0]) return false;\n\t\t\treturn QuoridorController.noWallBlock(curPos.getPlayerToMove(), -1, 0);\n\t\t} else if(dir == MoveDirection.South) {\n\t\t\tif(toCheckPos[1] == 9) return false;\n\t\t\tif(toCheckPos[1] + 1 == existingPos[1] && toCheckPos[0] == existingPos[0]) return false;\n\t\t\treturn QuoridorController.noWallBlock(curPos.getPlayerToMove(), 1, 0);\n\t\t} else if(dir == MoveDirection.East) {\n\t\t\tif(toCheckPos[0] == 9) return false;\n\t\t\tif(toCheckPos[0] + 1 == existingPos[0] && toCheckPos[1] == existingPos[1]) return false;\n\t\t\treturn QuoridorController.noWallBlock(curPos.getPlayerToMove(), 0, 1);\n\t\t} else if(dir == MoveDirection.West) {\n\t\t\tif(toCheckPos[0] == 1) return false;\n\t\t\tif(toCheckPos[0] - 1 == existingPos[0] && toCheckPos[1] == existingPos[1]) return false;\n\t\t\treturn QuoridorController.noWallBlock(curPos.getPlayerToMove(), 0, -1);\n\t\t}\n\t\t\n\t\treturn false;\r\n }", "public boolean beginFromStart(Pawn pawn,Deck deck)\n\t{\n\n\t\t// check if the current pawn is at the home square\n\t\tif (pawn.getPosition()==-10)\n\t\t{\n\t\t\tif (pawn.getColor() == Color.red && !check.IsTwoSamePawnsOnSquare(pawn, 11, deck))\n\t\t\t{\n\t\t\t\tif(check.IsEnemyPawnOnSquare(pawn, 11, deck))\n\t\t\t\t{\n\t\t\t\t\tdeck.getSquares().get(11).getCurr_pawn().setPosition(-10);//move the enemy pawn to his start square\n\t\t\t\t\n\t\t\t\t\tdeck.getSquares().get(11).getCurr_pawn().setCurrentSquare(new StartSquare(deck.getSquares().get(11).getCurr_pawn().getColor(), null));//move the enemy pawn to his start square\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\tpawn.setPosition(11);\n\t\t\t\tpawn.getCurrentSquare().setCurr_pawn(null);\n\t\t\t\tupdate_Pawn_Current_Square(pawn, 11, deck);\n\t\t\t\tset_Squares_Pawn(pawn, 11, deck);\n\t\t\t\t\n\t\t\t} \n\t\t\telse if(pawn.getColor() == Color.yellow && !check.IsTwoSamePawnsOnSquare(pawn, 46, deck))\n\t\t\t{\n\t\t\t\tif(check.IsEnemyPawnOnSquare(pawn, 46, deck))\n\t\t\t\t{\n\t\t\t\t\tdeck.getSquares().get(46).getCurr_pawn().setPosition(-10);//move the enemy pawn to his start square\n\t\t\t\t\t\n\t\t\t\t\tdeck.getSquares().get(46).getCurr_pawn().setCurrentSquare(new StartSquare(deck.getSquares().get(46).getCurr_pawn().getColor(), null));//move the enemy pawn to his start square\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\tpawn.setPosition(46);\n\t\t\t\tpawn.getCurrentSquare().setCurr_pawn(null);\n\t\t\t\tupdate_Pawn_Current_Square(pawn, 46, deck);\n\t\t\t\tset_Squares_Pawn(pawn, 46, deck);\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\telse {\n\t\t\treturn false;\n\t\t}\n\n\t}", "private void enPassant(Board board, List<Move> moves) {\n int x = location.x;\n int y = location.y; \n \n if (this.color == Color.White && this.location.y == 3) {\n if(canCaptureEnPassant(board, new Point(x - 1, y)))\n moves.add(new Move(this, new Point(x - 1, y - 1),\n board.getPieceAt(new Point(x - 1, y))));\n if(canCaptureEnPassant(board, new Point(x + 1, y)))\n moves.add(new Move(this, new Point(x + 1, y - 1),\n board.getPieceAt(new Point(x + 1, y)))); \n }\n if (this.color == Color.Black && this.location.y == 4) {\n if(canCaptureEnPassant(board, new Point(x - 1, y)))\n moves.add(new Move(this, new Point(x - 1, y + 1),\n board.getPieceAt(new Point(x - 1, y))));\n if(canCaptureEnPassant(board, new Point(x + 1, y)))\n moves.add(new Move(this, new Point(x + 1, y + 1),\n board.getPieceAt(new Point(x + 1, y)))); \n }\n }", "public synchronized String Move(Coordinates step) {\n // check if player won't go over the grid\n if (step.getKey() + coord.getKey() < 0 || step.getKey() + coord.getKey() > sizeSide) {\n System.out.println(\"You can't go out of x bounds, retry\");\n return null;\n }\n else if (step.getValue() + coord.getValue() < 0 || step.getValue() + coord.getValue() > sizeSide) {\n System.out.println(\"You can't go out of y bounds, retry\");\n return null;\n }\n else {\n coord = new Coordinates(coord.getKey() + step.getKey(), coord.getValue() + step.getValue());\n return \"ok\";\n }\n }", "@Test\n public void testMovePieceInvalidMove() {\n Position pos = new Position(board, 3, 3);\n Pawn pawnOne = new Pawn(Color.WHITE);\n board.getSquare(pos).addPiece(pawnOne);\n pawnOne.setPosition(pos);\n Position pos1 = new Position(board, 5, 3);\n assertFalse(chess.movePiece(board.getSquare(pos), board.getSquare(pos1), pawnOne));\n }", "public void movePlayer(String direction) {\n if(playerAlive(curPlayerRow, curPlayerCol)){\n if(direction.equals(\"u\")&&(curPlayerRow-1)>=0){\n overwritePosition(curPlayerRow, curPlayerCol, (curPlayerRow-1), curPlayerCol);\n curPlayerRow -= 1;\n }else if(direction.equals(\"d\")&&(curPlayerRow+1)<=7){\n overwritePosition(curPlayerRow, curPlayerCol, (curPlayerRow+1), curPlayerCol);\n curPlayerRow += 1;\n }else if(direction.equals(\"l\")&&(curPlayerCol-1)>=0){\n overwritePosition(curPlayerRow, curPlayerCol, curPlayerRow, (curPlayerCol-1));\n curPlayerCol -= 1;\n }else if(direction.equals(\"r\")&&(curPlayerCol+1)<=9){\n overwritePosition(curPlayerRow, curPlayerCol, curPlayerRow, (curPlayerCol+1));\n curPlayerCol += 1;\n }\n }\n if(playerFoundTreasure(curPlayerRow, curPlayerCol)){\n playerWins();\n }\n adjustPlayerLifeLevel(curPlayerRow, curPlayerCol);\n int[] array = calcNewTrollCoordinates(curPlayerRow, curPlayerCol, curTrollRow, curTrollCol);\n if(curPlayerRow == curTrollRow && curPlayerCol == curTrollCol){\n gameBoard[curTrollRow][curTrollCol] = new TrollPiece();\n }else{\n int newTrollRow = array[0];\n int newTrollCol = array[1];\n overwritePosition(curTrollRow, curTrollCol, newTrollRow, newTrollCol);\n curTrollRow = newTrollRow;\n curTrollCol = newTrollCol;\n }\n }", "public void makeMove(Move m) {\n \tPieceColor moved = m.getSource().getColor();\n\n \t//before the move is made, record the move in the movelist\n \tupdateMoveList(m);\n \t\n \t//store locations\n \tint sx = m.getSource().getLocation().getX();\n \tint sy = m.getSource().getLocation().getY();\n \tint dx = m.getDest().getLocation().getX();\n \tint dy = m.getDest().getLocation().getY();\n \tString name_moved = m.getSource().getName();\n \t\n \t//store new king location if it moved\n \tif(name_moved.equals(\"King\")) {\n \t\tif(moved == PieceColor.White) {\n \t\t\twKing = m.getDest().getLocation();\n \t\t\t\n \t\t\t//remove castle rights on both sides\n \t\t\tcastle[0] = false;\n \t\t\tcastle[1] = false;\n \t\t}\n \t\telse if(moved == PieceColor.Black) {\n \t\t\tbKing = m.getDest().getLocation();\n \t\t\t\n \t\t\t//remove castle rights on both sides\n \t\t\tcastle[2] = false;\n \t\t\tcastle[3] = false;\n \t\t}\n \t\telse System.exit(0);\n \t}\n \t\n \t//rook check for castling rights\n \tif(name_moved.equals(\"Rook\")) {\n \t\tif(moved == PieceColor.White) {\n \t\t\tif(sx == 0 && sy == 0) removeCastle(moved, false);\n \t\t\tif(sx == 7 && sy == 0) removeCastle(moved, true);\n \t\t}\n \t\t\n \t\telse if(moved == PieceColor.Black) {\n \t\t\tif(sx == 0 && sy == 7) removeCastle(moved, false);\n \t\t\tif(sx == 7 && sy == 7) removeCastle(moved, true);\n \t\t}\n \t}\n \t\n \tPiece temp = getPiece(sx, sy);\n \t\n \tsetPiece(sx, sy, new NoPiece(sx, sy));\n \t\n \tif(temp.getName().equals(\"Pawn\") && ((Pawn)temp).getPromo() == dy) {\n \t\ttemp = new Queen(dx, dy, temp.getColor(), this);\n \t}\n \t\n \t\n \ttemp.setLocation(new Square(dx, dy));\n \t\n \t//check for en passant\n \tif(name_moved.equals(\"Pawn\")) {\n \t\tint loc = ((Pawn)temp).advance();\n \t\t((Pawn)temp).setMoved(moveList.size());\n \t\t\n \t\t//only a valid en passant move if the pawn moves diagonally\n \t\t//and the destination square is empty\n \t\tif(sx != dx && getPiece(dx, dy).getName().equals(\"None\")) {\n \t\t\tsetPiece(dx, dy-loc, new NoPiece(dx, dy-loc));\n \t\t}\n \t}\n \t\n \tsetPiece(dx, dy, temp);\n \t\n \tif(turn == PieceColor.White) turn = PieceColor.Black;\n \telse turn = PieceColor.White;\n \t\n \t//check if the move was a castle\n \tif(name_moved.equals(\"King\")) {\n \t\t\n \t\tif(moved == PieceColor.White) { \n\t \t\t//if king moved positive x, then moved king side\n\t \t\tif(dx - sx == 2) {\n\t \t\t\ttemp = getPiece(7, 0);\n\t \t\t\tsetPiece(7, 0, new NoPiece(7, 0));\n\t \t\t\t\n\t \t\t\ttemp.setLocation(new Square(5,0));\n\t \t\t\tsetPiece(5, 0, temp);\n\t \t\t}\n\t \t\t\n\t \t\telse if(sx - dx == 2) {\n\t \t\t\ttemp = getPiece(0, 0);\n\t \t\t\tsetPiece(0, 0, new NoPiece(0, 0));\n\t \t\t\t\n\t \t\t\ttemp.setLocation(new Square(3, 0));\n\t \t\t\tsetPiece(3, 0, temp);\n\t \t\t}\n \t\t}\n \t\t\n \t\tif(moved == PieceColor.Black) { \n\t \t\t//if king moved positive x, then moved king side\n\t \t\tif(dx - sx == 2) {\n\t \t\t\ttemp = getPiece(7, 7);\n\t \t\t\tsetPiece(7, 7, new NoPiece(7, 7));\n\t \t\t\t\n\t \t\t\ttemp.setLocation(new Square(5, 7));\n\t \t\t\tsetPiece(5, 7, temp);\n\t \t\t}\n\t \t\t\n\t \t\telse if(sx - dx == 2) {\n\t \t\t\ttemp = getPiece(0, 7);\n\t \t\t\tsetPiece(0, 7, new NoPiece(0, 7));\n\t \t\t\t\n\t \t\t\ttemp.setLocation(new Square(3, 7));\n\t \t\t\tsetPiece(3, 7, temp);\n\t \t\t}\n \t\t}\n \t}\n }", "public boolean canMove() {\n\n\tArrayList<Location> moveLocs = getValid(getLocation());\n\n\tif (isEnd == true) {\n\t return false;\n\t} \n\tif (!moveLocs.isEmpty()) {\n\t \n\t randomSelect(moveLocs);\n\t // selectMoveLocation(moveLocs);\n\t return true;\n\n\t} else {\n\t return false;\n\t}\n }", "private boolean isThereValidMove() {\n\t\treturn true;\n\t}", "boolean prepareToMove();", "@Override\n public void movePiece(Piece piece, char file, GridPosition end) {\n GridPosition current = getCurrentGridPositionOfPiece(piece, file, end);\n\n Move mv = new Move(piece, current, end);\n\n int[] curYX = ChessGameUtils_Ng.convertGridPositionTo2DYXArray(current);\n int curY = curYX[ChessGameUtils_Ng.Y_INDEX], curX = curYX[ChessGameUtils_Ng.X_INDEX];\n\n int[] update = mv.getYXDelta();\n int dY = update[DELTA_Y_INDEX], dX = update[DELTA_X_INDEX];\n\n board[curY][curX] = EMPTY_SPACE;\n board[curY + dY][curX + dX] = piece;\n moveHistory.add(mv);\n }", "public void tryMove() {\n if(!currentPlayer.getHasPlayed()){\n if (!currentPlayer.isEmployed()) {\n String destStr = chooseNeighbor();\n\n currentPlayer.moveTo(destStr, getBoardSet(destStr));\n if(currentPlayer.getLocation().getFlipStage() == 0){\n currentPlayer.getLocation().flipSet();\n }\n refreshPlayerPanel();\n }\n else {\n view.showPopUp(currentPlayer.isComputer(), \"Since you are employed in a role, you cannot move but you can act or rehearse if you have not already\");\n }\n }\n else{ \n view.showPopUp(currentPlayer.isComputer(), \"You've already moved, rehearsed or acted this turn. Try a different command or click `end turn` to end turn your turn.\");\n }\n view.updateSidePanel(playerArray);\n }", "private Pawn(Point location, Color color, int moves, boolean captureableEnPassant) {\n enPassantOk = captureableEnPassant;\n this.numMoves = moves;\n this.color = color;\n this.location = location;\n }", "public void movePlayer(String nomeArq, int px, int py) {\r\n if(Main.player1.Vez()) {\r\n if(nomeArq.equals(Main.PLAYER_LEFT)){\r\n \tMain.player1.MudaLado(true,false);\r\n }\r\n else {\r\n \tMain.player1.MudaLado(false,true);\r\n } \r\n pos = Main.player1.Position();\r\n int x = pos[0]+px;\r\n int y = pos[1];\r\n double t = 0.1;\r\n int OrigemY = y;\r\n double g=10;\r\n if(andar.BatidaFrente(x,y,Main.player1.Size()[0]+1,Main.player1.Size()[1]+1)==false) {\r\n \tMain.player1.NovaPosition(x,y); \r\n }\r\n Main.Fase.repinta(); \r\n while(andar.temChao(x,y,Main.player1.Size()[0]+1,Main.player1.Size()[1]+1)==false && andar.Paredao((int)x,(int)y,Main.player1.Size()[0],Main.player1.Size()[1])==false)\r\n {\r\n \tMain.player1.NovaPosition(x,y);\r\n \tMain.Fase.repinta(); \r\n y = (int)(OrigemY - (0-(g * (t*t))/2.0));\r\n t = t + 0.1; \r\n }\r\n Main.Fase.repinta(); \r\n }\r\n else {\r\n if(nomeArq.equals(Main.PLAYER_LEFT)) {\r\n \tMain.player2.MudaLado(true,false);\r\n }\r\n else {\r\n \tMain.player2.MudaLado(false,true);\r\n } \r\n pos = Main.player2.Position();\r\n int x = pos[0]+px;\r\n int y = pos[1];\r\n double t = 0;\r\n int OrigemY = y;\r\n double g=10;\r\n if(andar.BatidaFrente(x,y,Main.player2.Size()[0]+1,Main.player2.Size()[1]+1)==false) {\r\n \tMain.player2.NovaPosition(x,y); \r\n }\r\n Main.Fase.repinta(); \r\n while(andar.temChao(x,y,Main.player2.Size()[0]+1,Main.player2.Size()[1]+1)==false && andar.Paredao((int)x,(int)y,Main.player2.Size()[0]+1,Main.player2.Size()[1]+1)==false)\r\n {\r\n \tMain.player2.NovaPosition(x,y);\r\n \tMain.Fase.repinta(); \r\n y = (int)(OrigemY - (0-(g * (t*t))/2.0));\r\n t = t + 0.1; \r\n }\r\n }\r\n }", "void move() {\r\n\t\tif (x + xa < 0){\r\n\t\t\txa = mov;\r\n\t\t\tgame.puntuacion++;\r\n\t\t}\r\n\t\telse if (x + xa > game.getWidth() - diameter){\r\n\t\t\txa = -mov;\r\n\t\t\tgame.puntuacion++;\r\n\t\t}\r\n\t\tif (y + ya < 0){\r\n\t\t\tya = mov;\r\n\t\t\tgame.puntuacion++;\r\n\t\t}\r\n\t\telse if (y + ya > game.getHeight() - diameter){\r\n\t\t\tgame.gameOver();\r\n\t\t\tgame.puntuacion++;\r\n\t\t}\r\n\t\tif (colisionPalas()){\r\n\t\t\tya = -mov;\r\n\t\t}\r\n\t\telse if(colisionEstorbos()){\r\n\t\t\tgame.puntuacion+=2;\r\n\t\t}\r\n\t\t\r\n\t\tx = x + xa;\r\n\t\ty = y + ya;\r\n\t}", "private boolean canMove(String direction) {\n\t\tif (currentPiece.getLocation() == null) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (Loc loc : currentPiece.getLocation()) {\n\t\t\tLoc nextPoint = nextPoint(loc, direction);\n\t\t\tif (nextPoint == null) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t// if there's someone else's piece blocking you\n\t\t\tif ((new Loc(nextPoint.row, nextPoint.col).isOnBoard())\n\t\t\t\t\t&& boardTiles[nextPoint.row][nextPoint.col] != backgroundColor && !isMyPiece(nextPoint)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}", "void movePiece(int destX, int destY){\r\n\t\tif(isValid(this.xPos,this.yPos,destX,destY) == true){\r\n\t\t\tthis.xPos = destX;\r\n\t\t\tthis.yPos = destY;\r\n\t\t}\r\n\t}", "private void playerMove(PlayerPiece playerPiece, String direction) {\n // Row will be -1 from player location with the same column value\n System.out.println(playerPiece + \" trying to move \" + direction + \".\");\n Tile playerLocation = playerPiece.getLocation();\n System.out.println(\"Player in: \" + playerLocation.getRow() + \" \" + playerLocation.getColumn());\n int newRow = playerLocation.getRow();\n int newColumn = playerLocation.getColumn();\n switch (direction) {\n case \"u\":\n newRow -= 1;\n break;\n case \"d\":\n newRow += 1;\n break;\n case \"l\":\n newColumn -= 1;\n break;\n case \"r\":\n newColumn += 1;\n break;\n }\n if (newRow >= 0 && newColumn >= 0 && newRow < this.board.getGrid().getRows() && newColumn < this.board.getGrid().getColumns()) {\n System.out.println(newRow + \" \" + newColumn);\n Tile newLocation = this.board.getGrid().getTile(newRow, newColumn);\n System.out.println(\"New Location:\" + newLocation);\n System.out.println(\"Cords: \" + newLocation.getRow() + \" \" + newLocation.getColumn());\n if (newLocation.isAvailable()) {\n playerLocation.removeOccupier();\n playerPiece.setLocation(newLocation);\n newLocation.setOccupier(playerPiece);\n System.out.println(\"Player moved to: \" + playerLocation.getRow() + \" \" + playerLocation.getColumn());\n this.board.getGrid().print();\n }\n }\n }", "private void handleMovement() {\n if (movements.isEmpty()) return;\n try {\n switch (movements.peek()) {\n case MOVE_UP:\n game.movePlayer(Direction.N);\n break;\n case MOVE_LEFT:\n game.movePlayer(Direction.W);\n break;\n case MOVE_DOWN:\n game.movePlayer(Direction.S);\n break;\n case MOVE_RIGHT:\n game.movePlayer(Direction.E);\n break;\n }\n } catch (Exception ignored) { }\n }", "@Override\n public boolean canMove(int destinationX, int destinationY) {\n int differenceX = Math.abs(destinationX - this.boardCoordinates.x);\n int differenceY = Math.abs(destinationY - this.boardCoordinates.y);\n\n return (destinationX == this.boardCoordinates.x && differenceY == 1) ||\n (destinationY == this.boardCoordinates.y && differenceX == 1) ||\n (differenceX == differenceY && differenceX == 0); //we're handling start=finish coordinates separately\n }", "@Override\r\n\tpublic void move() {\n\t\tPoint target = strategy.search(this.getLocation(), new Point(0,0));\r\n\r\n\t\tint tries = 0;\r\n\t\t\r\n\t\twhile(!state.equals(\"Inactive\") && !game.movement(this, target.x, target.y)){\r\n\t\t\ttarget = strategy.search(new Point(x,y),playerLocation);\r\n\t\t\ttries++;\r\n\t\t\tif(tries > 4) return; // the search strategy has 4 tries to pick a valid location to move to\r\n\t\t}\r\n\t\t\r\n\t\tx = target.x;\r\n\t\ty = target.y;\r\n\r\n\t\tmoveSprite();\r\n\t}", "@Override\r\n\tpublic boolean movement(BoardCells[][] chessBoard, Piece targetPiece, int fromX,int fromY,int toX,int toY) {\t\t\r\n\t\t//DEBUG -- System.out.println(\"\"+fromX+fromY+\" \"+toX+toY);\r\n\t\t\r\n\t\tif(fromY == toY){\t\t\t\r\n\t\t\tif(fromX > toX) {\r\n\t\t\t\tfor(int i = fromX-1; i>toX; i--) {\r\n\t\t\t\t\tif(chessBoard[8-fromY][i].getPiece() != null) {\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\r\n\t\t\t} else if (fromX < toX) {\r\n\t\t\t\tfor(int i = fromX+1; i<toX; i++) {\r\n\t\t\t\t\tif(chessBoard[8-fromY][i].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif(getPieceID().equals(\"bR\")) {\r\n\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"bKc\")) {\r\n\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"bK\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif(getPieceID().equals(\"wR\")) {\r\n\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"wKc\")) {\r\n\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"wK\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\tif(fromX == toX) {\t\t\t\t\r\n\t\t\tif(fromY > toY) {\t\r\n\t\t\t\tfor(int i = fromY-1; i>toY; i--) {\r\n\t\t\t\t\tif(chessBoard[8-i][toX].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t} else if (fromY < toY) {\t\t\t\t\r\n\t\t\t\tfor(int i = fromY+1; i<toY; i++) {\t\t\t\t\t\r\n\t\t\t\t\tif(chessBoard[8-i][toX].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tif(getPieceID().equals(\"bR\")) {\r\n\t\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"bKc\")) {\r\n\t\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"bK\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(getPieceID().equals(\"wR\")) {\r\n\t\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"wKc\")) {\r\n\t\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"wK\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\r\n\t\t\treturn true;\t\r\n\t\t}\r\n\t\t\t\t\r\n\t\treturn false;\t\t\r\n\t}", "private boolean makeMove(Move move) {\n\n // Moving piece from Cell\n Piece sourcePiece = move.getStart().getCurrentPiece();\n\n // Valid Move? Calling Piece actual implementation\n if (!sourcePiece.canMove(board, move.getStart(), move.getEnd())) {\n System.out.println(\"Invalid Move, sourcePiece is \" + sourcePiece);\n }\n\n // Killed other player Piece?\n Piece destPiece = move.getEnd().getCurrentPiece();\n if (destPiece != null) {\n destPiece.setKilled(true);\n move.setPieceKilled(destPiece);\n }\n\n // castling?\n if (sourcePiece instanceof King\n && sourcePiece.isCastlingMove()) {\n move.setCastlingMove(true);\n }\n\n // Store the Move\n movesPlayed.add(move);\n\n // If move is VALID, set piece=null at start cell and new piece at dest cell\n move.getEnd().setCurrentPiece(sourcePiece);\n move.getStart().setCurrentPiece(null);\n\n // Game Win or not\n if (destPiece instanceof King) {\n if (move.getPlayedBy().isWhiteSide()) {\n this.setStatus(GameStatus.WHITE_WIN);\n } else {\n this.setStatus(GameStatus.BLACK_WIN);\n }\n\n }\n\n return true;\n }", "public boolean movePiece(Point orig, Point dest){\r\n // Move information\r\n boolean eat = moveEats(orig,dest);\r\n boolean queen = moveMakeQueen(orig,dest); \r\n // Move piece\r\n model.swapValues(orig,dest);\r\n model.getCurrentPlayer().setMovementCount(+1);\r\n // If move eats rivals piece\r\n if(eat)\r\n eatPiece(getPieceToEat(orig,dest));\r\n // If moves make a new queen\r\n if(queen)\r\n toQueen(dest);\r\n // If eat and can eats again from destiny position then move continues\r\n return !queen && (eat && moveContinues(dest));\r\n }", "public boolean move(double x, double y, Landscape scape ){\n\t\t// check to see if it is moving off the landscape in the x directions\n\t\tif( (this.x + x) > scape.getWidth() || (this.x + x) < 0 ){\n\t\t\t// it is on the edge, do nothing\n\t\t\tthis.isAlive = true;\n\t\t\treturn true;\n\t\t}\n\t\t// check to see if it is moving off of the landscape in the y direction. It cannot move more than 1/5 of the way up\n\t\telse if( (this.y + y) > scape.getHeight() || (this.y + y) < (4.0/5.0)*scape.getHeight() ){\n\t\t\t// it is on the edge in the y direction\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\t// check to see if there are any obstacles in the way of the motion of the Defender\n\t\tboolean check = checkObs(this.x +x , this.y + y,scape);\n\t\t// if this is false then we cannot move, but are still alive\n\t\tif(!check){\n\t\t\t// don't move, but return true (still alive)\n\t\t\tthis.isAlive = true;\n\t\t\treturn true;\n\t\t}\n\t\t// check to see if the defender is about to hit any of the millipede's\n\t\tcheck = checkMillipede(this.x+x, this.y+y , scape);\n\t\t// if it returns false, then the Defender has hit a millipede and died!\n\t\tif( !check){\n\t\t\t// user hit a millipede segment! It has died, return false\n\t\t\tthis.isAlive = false;\n\t\t\treturn false;\n\t\t}\n\t\t// Otherwise, the path is clear to move and it will do so\n\t\tthis.x += x;\n\t\tthis.y += y;\n\t\t// still alive\n\t\tthis.isAlive = true;\n\t\treturn true;\n\t}", "public boolean moveDown() { \n\t\t// x coordinate of current piece's northwest corner, with change\n\t\tint gridRow = currentPieceGridPosition[0] + 1; \n\t\t\n\t\t// y coordinate of current piece's northwest corner\n\t\tint gridCol = currentPieceGridPosition[1];\n\t\t\n\t\t// check to see if safe\n\t\tif(validMove(currentPiece, currentPiece.pieceRotation, gridRow, gridCol)) {\n\t\t\t// determined safe to change \n\t\t\tcurrentPieceGridPosition[0]++;\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\t// piece cannot go down any further\n\t\telse {\n\t\t\tlandPiece();\n\t\t\treturn false;\n\t\t}\n\t}", "public boolean allowMove(Point p, int pos);", "private boolean isNextMoveRochade(Move move)\r\n\t{\r\n\t\tif (!(move.from.piece instanceof King)) return false;\r\n\t\tint xDiffAbs = Math.abs(move.to.coordinate.x - move.from.coordinate.x); \r\n\t\treturn xDiffAbs == 2;\r\n\t}", "private void moveAllignedMhos() {\n\n\t\t//Assign playerX and playerY to the X and Y of the player\n\t\tint playerX = getNewPlayerLocation()[0];\n\t\tint playerY = getNewPlayerLocation()[1];\n\n\t\t//Iterate through every mho's X and Y values\n\t\tfor(int i = 0; i < mhoLocations.size()/2; i++) {\n\n\t\t\t//Assign mhoX and mhoY to the X and Y values of the mho that is currently being tested\n\t\t\tint mhoX = mhoLocations.get(i*2);\n\t\t\tint mhoY = mhoLocations.get(i*2+1);\n\n\t\t\t//set the default X and Y offsets to 0, and the move to NO_MOVEMENT\n\t\t\tint xOffset = 0;\n\t\t\tint yOffset = 0;\n\t\t\tchar move = Legend.NO_MOVEMENT;\n\n\t\t\t//Check if the playerX is equal to mhoX (aligned on x-axis)\n\t\t\tif(playerX == mhoX) {\n\n\t\t\t\t//Check which direction the mho would have to move, and assign the corresponding move and yOffset\n\t\t\t\tif(playerY > mhoY) {\n\t\t\t\t\tyOffset = 1;\n\t\t\t\t\tmove = Legend.DOWN;\n\t\t\t\t} else {\n\t\t\t\t\tyOffset = -1;\n\t\t\t\t\tmove = Legend.UP;\n\t\t\t\t}\n\t\t\t} else if(playerY == mhoY) {\n\n\t\t\t\t//Check which direction the mho would have to move, and assign the corresponding move and XOffset\n\t\t\t\tif(playerX > mhoX) {\n\t\t\t\t\txOffset = 1;\n\t\t\t\t\tmove = Legend.RIGHT;\n\t\t\t\t} else {\n\t\t\t\t\txOffset = -1;\n\t\t\t\t\tmove = Legend.LEFT;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//Only move if the new location is not an instance of mho (in order to make sure they are moved in the right order)\n\t\t\tif(!(newMap[mhoX+xOffset][mhoY+yOffset] instanceof Mho)) {\n\n\t\t\t\t//Set the previous location to a BlankSpace\n\t\t\t\tnewMap[mhoX][mhoY] = new BlankSpace(mhoX, mhoY, board);\n\n\t\t\t\t//If the new square would be a player, end the game\n\t\t\t\tif(newMap[mhoX+xOffset][mhoY+yOffset] instanceof Player) {\n\t\t\t\t\tmoveList[mhoX+xOffset][mhoY+yOffset] = Legend.SHRINK;\n\t\t\t\t\tgameOver();\n\t\t\t\t}\n\n\t\t\t\t//If the new square would be a fence, remove the mho from the map\n\t\t\t\tif(!(newMap[mhoX+xOffset][mhoY+yOffset] instanceof Fence)) {\n\t\t\t\t\tnewMap[mhoX+xOffset][mhoY+yOffset] = new Mho(mhoX+xOffset, mhoY+yOffset, board);\n\t\t\t\t} else {\n\t\t\t\t\tmove = Legend.SHRINK;\n\t\t\t\t}\n\n\t\t\t\t//Set the move of the mho on moveList\n\t\t\t\tmoveList[mhoX][mhoY] = move;\n\n\t\t\t\t//remove the mhoX and mhoY in mhoLocations\n\t\t\t\tmhoLocations.remove(i*2+1);\n\t\t\t\tmhoLocations.remove(i*2);\n\n\t\t\t\t//Call moveAllignedMhos() again, because the list failed to be checked through completely\n\t\t\t\tmoveAllignedMhos();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}", "public abstract boolean attemptMove(Player currentPlayerObj, Coordinate move);", "public boolean canMove() {\n\t\tArrayList<Location> loc = getValid(getLocation());\n\t\tif (loc.isEmpty()) {\n\t\t\treturn false;\n\t\t} else {\n\t\t\tpath.add(getLocation());\n\t\t\tif (loc.size() >= 2) {\n\t\t\t\tcrossLocation.push(path);\n\t\t\t\tpath = new ArrayList<Location>();\n\t\t\t\tnext = betterDir(loc);\n\t\t\t}\n\t\t\tnext = loc.get(0);\n\t\t}\n\t\treturn true;\n\t}", "public boolean checkAndMove() {\r\n\r\n\t\tif(position == 0)\r\n\t\t\tdirection = true;\r\n\r\n\t\tguardMove();\r\n\r\n\t\tif((position == (guardRoute.length - 1)) && direction) {\r\n\t\t\tposition = 0;\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\tif(direction)\r\n\t\t\tposition++;\r\n\t\telse\r\n\t\t\tposition--;\r\n\r\n\t\treturn false;\r\n\t}", "private void HandleOnMoveStart(Board board, Piece turn){}", "public boolean movePlayer(MazePlayer p, Direction d) {\n//\t System.out.println(\"Player \"+p.name+\" requests to move in direction \"+d);\n// players can move through walls with some small probability!\n\t\t // calculate the new position after the move \n\t\t MazePosition oldPos = playerPosition.get(p.name);\n\t\t MazePosition newPos = theBoard.tryMove(oldPos,d);\n\n\t\t \n\t\t //make sure there is no other player at that position\n\t\t // and if there is someone there then just return without moving\n\t\t if (playerPosition.containsValue(newPos)){\n\t\t\t if (!newPos.equals(oldPos))\n\t\t\t\t if (debugging) System.out.println(\"player \"+p.name+\" tried to move into an occupied space.\");\n\t\t\t else\n\t\t\t\t if (debugging) System.out.println(p.name+\" stays at \"+oldPos);\n\t\t\t return false;\n\t\t }\n\t\t \n\t\t //otherwise, make the move\n\t\t playerPosition.put(p.name,newPos);\n\t\t if (debugging) System.out.println(p.name+\": \"+oldPos+\" -> \"+newPos);\n\t\t \n\t\t //take off points if you moved through a wall\n\t\t if (!theBoard.canMove(oldPos,d)){\n\t\t\t score.put(p.name,score.get(p.name)-2);\n\t\t\t if (debugging) System.out.println(p.name+\" moved through a wall\");\n\t\t }\n\t\t \n\t\t // mark that old space as \"free space\"\n\t\t freeSpace.add(0,oldPos);\n\t\t \n\t\t // check to see if there is a jewel in the new position.\n\t\t int i = jewelPosition.indexOf(newPos);\n\t\t if (i > -1) {\n\t\t\t // add 5 to the score\n\t\t\t score.put(p.name,score.get(p.name)+5);\n\t\t\t // remove the jewel\n\t\t\t jewelPosition.remove(i);\n\t\t\t if (debugging) System.out.println(\"and lands on a jewel!, score is now \" +score.get(p.name));\n\t\t\t // add another jewel\n\t\t\t MazePosition q = getEmptySpace();\n\t\t\t jewelPosition.add(q);\n\t\t\t if (debugging) System.out.println(\"adding a new jewel at \"+q);\n\t\t\t \n\t\t }\n\t\t else {\n\t\t\t // if no jewel, then remove the space from the freeSpace list\n\t\t\t freeSpace.remove(newPos);\n\t\t }\n\t\t return true;\n\n }", "public void movePiece(int xStart, int yStart, int xEnd, int yEnd) {\n board[xEnd][yEnd] = board[xStart][yStart];\n board[xStart][yStart] = null;\n board[xEnd][yEnd].moveTo(xEnd, yEnd);\n if (board[xEnd][yEnd] instanceof ChessPieceKing) {\n if (board[xEnd][yEnd].isBlack()) {\n locationBlackKing = new Point(xEnd, yEnd);\n } else {\n locationWhiteKing = new Point(xEnd, yEnd);\n }\n }\n\n drawScreen();\n }", "boolean doMove();", "public void move() {\n\t\t// tolerance of angle at which the Base starts moving\n\t\tint tolerance = 10;\n\t\tif(Math.abs(angle) < Math.abs(angleDesired)+tolerance && Math.abs(angleDesired)-tolerance < Math.abs(angle)) {\n\t\t\tdouble vX = Math.cos(Math.toRadians(this.angle + 90)) * v;\n\t\t\tdouble vY = Math.sin(Math.toRadians(this.angle + 90)) * v;\n\t\t\t\n\t\t\tthis.x += vX;\n\t\t\tthis.y += vY;\t\n\t\t\tthis.rectHitbox = new Rectangle((int)(x-rectHitbox.width/2),(int)(y-rectHitbox.height/2),rectHitbox.width,rectHitbox.height);\n\t\t}\n\t\t// curTargetPathBoardRectangle\n\t\tRectangle curTPBR = pathBoardRectangles.get(curTargetPathCellIndex).rect;\n\t\tRectangle rectSmallerBR = new Rectangle((int)curTPBR.getCenterX()-5,(int)curTPBR.getCenterY()-5,10,10);\n\t\t// updates the index when it crosses a pathCell so it counts down from pathCell to pathCell,\n\t\t// always having the next pathCell in the array as the target until the end is reached then it stops\n\t\tif(rectSmallerBR.contains(new Point((int)x,(int)y))) {\n\t\t\tif(curTargetPathCellIndex < pathBoardRectangles.size()-1) {\n\t\t\t\tcurTargetPathCellIndex++;\n\t\t\t\tparentGP.boardRect = pathBoardRectangles.get(curTargetPathCellIndex-1);\n\t\t\t\ttAutoDirectionCorrection.restart();\n\t\t\t}else {\n\t\t\t\tparentGP.isMoving = false;\n\t\t\t\tparentGP.boardRect = pathBoardRectangles.get(curTargetPathCellIndex);\n\t\t\t\tpathBoardRectangles.clear();\n\t\t\t\ttAutoDirectionCorrection.stop();\n\t\t\t\tStagePanel.tryCaptureGoldMine(parentGP);\n\t\t\t}\n\t\t}\n\t}", "@Override\n\tpublic Collection<Move> calculateLegalMoves(final Board board) {\n\t\t\n\t\t//Array that will hold of the legal moves for the Pawn\n\t\tfinal List<Move> legalMoves = new ArrayList<>();\n\t\t\n\t\t//Loop through all possible moves by applying of the offsets to the Pawn's current position\n\t\tfor(final int currentCandidateOffset: CANDIDATE_MOVE_COORDINATES){\n\t\t\t\n\t\t\t//Apply the offset to the Pawn's current position\n\t\t\tfinal int candidateDestinationCoordinate = this.piecePosition + (this.getPieceTeam().getDirection() * currentCandidateOffset);\n\t\t\t\n\t\t\t//Checks if the Destination Coordinate is valid\n\t\t\tif(!BoardUtils.isValidTileCoordinate(candidateDestinationCoordinate)){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t//Checks if this tile is occupied\n\t\t\tif(currentCandidateOffset == 8 && !board.getTile(candidateDestinationCoordinate).isTileOccupied()){\n\t\t\t\tif(this.pieceTeam.isPawnPromotionSquare(candidateDestinationCoordinate))\n\t\t\t\t\tlegalMoves.add(new Move.PawnPromotion(new Move.PawnMove(board, this, candidateDestinationCoordinate)));\n\t\t\t\telse\n\t\t\t\t\tlegalMoves.add(new Move.PawnMove(board, this, candidateDestinationCoordinate));\t\n\t\t\t}\n\t\t\t//Checks if the Pawn is on it's first move\n\t\t\telse if(currentCandidateOffset == 16 && this.isFirstMove() && ((BoardUtils.SEVENTH_RANK[this.piecePosition] && \n\t\t\t\t\tthis.getPieceTeam().isBlack()) || (BoardUtils.SECOND_RANK[this.piecePosition] && this.getPieceTeam().isWhite()))) {\n\t\t\t\t\n\t\t\t\t//Calculate coordinate of the tile behind candidate coordinate\n\t\t\t\tfinal int behindCandidateDestinationCoordinate = this.piecePosition + (this.pieceTeam.getDirection() * 8);\n\t\t\t\t\n\t\t\t\t//Checks if the tile behind the candidate destination is NOT occupied & if the Tile at the Candidate Destination is NOT occupied\n\t\t\t\tif(!board.getTile(behindCandidateDestinationCoordinate).isTileOccupied() && \n\t\t\t !board.getTile(candidateDestinationCoordinate).isTileOccupied())\n\t\t\t\t\t\tlegalMoves.add(new Move.PawnJump(board, this, candidateDestinationCoordinate));\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t//Checks for edge cases in the 7 direction\t\n\t\t\t} else if(currentCandidateOffset == 7 &&\n\t\t\t\t\t!((BoardUtils.FILE_H[this.piecePosition] && this.getPieceTeam().isWhite() ||\n\t\t\t\t\t(BoardUtils.FILE_A[this.piecePosition] && this.getPieceTeam().isBlack())))){\n\t\t\t\t\n\t\t\t\tif(board.getTile(candidateDestinationCoordinate).isTileOccupied()){\n\t\t\t\t\tfinal Piece pieceOnCandidate = board.getTile(candidateDestinationCoordinate).getPiece();\n\t\t\t\t\t//If the pieces are not on the same team an Attack move is added to legal moves.\n\t\t\t\t\tif(this.getPieceTeam() != pieceOnCandidate.getPieceTeam())\n\t\t\t\t\t\tif(this.pieceTeam.isPawnPromotionSquare(candidateDestinationCoordinate))\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnPromotion(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate)));\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t\t\t\n\t\t\t\t//This basically checks if En Passant Pawn is next to Player's pawn\t\n\t\t\t\t} else if(board.getEnPassantPawn() != null){\n\t\t\t\t\tif(board.getEnPassantPawn().getPiecePosition() == (this.piecePosition + (this.pieceTeam.getOppositeDirection()))){\n\t\t\t\t\t\tfinal Piece pieceOnCandidate = board.getEnPassantPawn();\n\t\t\t\t\t\tif(this.pieceTeam != pieceOnCandidate.getPieceTeam()){\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnEnPassantAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t//Checks for edge cases in the 9 direction\t\n\t\t\t} else if(currentCandidateOffset == 9 && \n\t\t\t\t\t!((BoardUtils.FILE_A[this.piecePosition] && this.getPieceTeam().isWhite() ||\n\t\t\t\t\t(BoardUtils.FILE_H[this.piecePosition] && this.getPieceTeam().isBlack())))){\n\t\t\t\t\n\t\t\t\tif(board.getTile(candidateDestinationCoordinate).isTileOccupied()){\n\t\t\t\t\tfinal Piece pieceOnCandidate = board.getTile(candidateDestinationCoordinate).getPiece();\n\t\t\t\t\t//If the pieces are not on the same team an Attack move is added to legal moves.\n\t\t\t\t\tif(this.getPieceTeam() != pieceOnCandidate.getPieceTeam())\n\t\t\t\t\t\tif(this.pieceTeam.isPawnPromotionSquare(candidateDestinationCoordinate))\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnPromotion(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate)));\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t} else if(board.getEnPassantPawn() != null){\n\t\t\t\t\tif(board.getEnPassantPawn().getPiecePosition() == (this.piecePosition - (this.pieceTeam.getOppositeDirection()))){\n\t\t\t\t\t\tfinal Piece pieceOnCandidate = board.getEnPassantPawn();\n\t\t\t\t\t\tif(this.pieceTeam != pieceOnCandidate.getPieceTeam()){\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnEnPassantAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\t\t\t\t\t\n\t\t}\n\t\t\n\t\treturn ImmutableList.copyOf(legalMoves);\n\t}", "public boolean moveValidation(Board board, Piece piece, int sourceX, int sourceY, int targetX, int targetY){//TODO make directions in Piece class\n int diffX = targetX - sourceX;\n int diffY = targetY - sourceY;\n if (!board.isPieceAtLocation(targetX, targetY) || board.isPieceAtLocationCapturable(piece.getColour(), targetX, targetY)) {\n if(diffX==0 && diffY > 0 )\n return !board.isPieceBetweenLocations(sourceX, sourceY, targetX, targetY, 0, 1);\n else if(diffX > 0 && diffY == 0 )\n return !board.isPieceBetweenLocations(sourceX, sourceY, targetX, targetY, 1, 0);\n else if(diffX < 0 && diffY == 0 )\n return !board.isPieceBetweenLocations(sourceX, sourceY, targetX, targetY, -1, 0);\n else if(diffX==0 && diffY < 0 )\n return !board.isPieceBetweenLocations(sourceX, sourceY, targetX, targetY, 0, -1);\n }\n return false;\n }", "public boolean canEnpassantLeft(Piece p) {\n\t\t\n\t\tif( (!(p instanceof Pawn)) || p == null) { //check is piece p is a pawn\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif(p.color == 'w') { //white pawn\n\t\t\tif(p.getX() != 3) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\n\t\t\tint row = p.getX();\n\t\t\tint column = p.getY();\n\t\t\tString left_space = Board.convertToFileRank(row, column - 1);\n\t\t\t\n\t\t\t// EnPassant 1 (Left-Diagonal) - white\n\t\t\tif(board.getPiece(left_space) != null && board.getPiece(left_space) instanceof Pawn && board.getPiece(left_space).color != this.color) {\n\t\t\t\tif( ((Pawn)(board.getPiece(left_space))).hasMovedTwo == true ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\t\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else { //black pawn\n\t\t\t\n\t\t\tif(p.getX() != 4) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\n\t\t\tint row = p.getX();\n\t\t\tint column = p.getY();\n\t\t\tString left_space = Board.convertToFileRank(row, column - 1);\n\t\t\t\n\t\t\t// EnPassant 1 (Left-Diagonal) - black\n\t\t\tif(board.getPiece(left_space) != null && board.getPiece(left_space) instanceof Pawn && board.getPiece(left_space).color != this.color) {\n\t\t\t\tif( ((Pawn)(board.getPiece(left_space))).hasMovedTwo == true ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn false;\n\t}", "public int move_diagonally(Square[][] squares, int [] move, Boolean turn) {\n\n /* going down and right = f4 h2 [4,5,6,7] */\n if (move[2] > move[0] && move[3] > move[1]) {\n ////System.out.println(\"Down right\");\n int x = move[0];\n int y = move[1];\n x++;\n y++;\n while (x < move[2] && y < move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x++;\n y++;\n }\n }\n /* going down and left */\n else if (move[2] > move[0] && move[3] < move[1]){\n ////System.out.println(\"Down Left\");\n int x = move[0];\n int y = move[1];\n x++;\n y--;\n while (x < move[2] && y > move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x++;\n y--;\n }\n }\n /* going up and left */\n else if (move[2] < move[0] && move[3] < move[1]){\n ////System.out.println(\"Up Left\");\n int x = move[0];\n int y = move[1];\n x--;\n y--;\n while (x > move[2] && y > move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x--;\n y--;\n }\n }\n /* going up and right c1 f4 [7,2,4,5] */\n else if (move[2] < move[0] && move[3] > move[1]){\n ////System.out.println(\"Up right\");\n int x = move[0];\n int y = move[1];\n x--;\n y++;\n while (x > move[2] && y < move[3]) {\n if (squares[x][y] instanceof Piece) {\n ////System.out.println(\"Piece in between \"+x + \" \" + y);\n return -1;\n }\n x--;\n y++;\n }\n }\n return 0;\n }", "public boolean move (int x,int y, OthelloPiece colour){\n boolean valid = false;\n if(move(x,y,VALID_MOVE_3,VALID_MOVE_2,colour)) valid=true;\n if(move(x,y,VALID_MOVE_3,VALID_MOVE_3,colour)) valid=true;\n if(move(x,y,VALID_MOVE_3,VALID_MOVE_1,colour)) valid=true;\n if(move(x,y,VALID_MOVE_2,VALID_MOVE_3,colour)) valid=true;\n if(move(x,y,VALID_MOVE_2,VALID_MOVE_1,colour)) valid=true;\n if(move(x,y,VALID_MOVE_1,VALID_MOVE_2,colour)) valid=true;\n if(move(x,y,VALID_MOVE_1,VALID_MOVE_3,colour)) valid=true;\n if(move(x,y,VALID_MOVE_1,VALID_MOVE_1,colour)) valid=true;\n setThePieces();\n if(valid){\n m_PieceCount++;\n }\n return (valid);\n }" ]
[ "0.69592977", "0.67338604", "0.6708487", "0.6432735", "0.63247913", "0.62879354", "0.62768126", "0.62411505", "0.6208566", "0.61852735", "0.61787635", "0.6136605", "0.61134535", "0.61088395", "0.60935265", "0.60801876", "0.60553145", "0.6012141", "0.60101193", "0.5982236", "0.59812146", "0.5953935", "0.5951584", "0.59284717", "0.5918687", "0.59045863", "0.58940446", "0.5884933", "0.58701557", "0.5867699", "0.58668995", "0.5847338", "0.58441675", "0.5841354", "0.5838602", "0.58360386", "0.58308625", "0.5788093", "0.5778864", "0.57764316", "0.57756037", "0.5772248", "0.5756926", "0.5748438", "0.57468176", "0.5732124", "0.572207", "0.57196236", "0.57196194", "0.5719002", "0.5706006", "0.57038826", "0.5692885", "0.5690526", "0.5689335", "0.5677764", "0.56718653", "0.5642825", "0.563482", "0.56275433", "0.5625407", "0.56241703", "0.5623108", "0.56185293", "0.56104887", "0.56052554", "0.5599767", "0.55992025", "0.55951416", "0.55915433", "0.5589049", "0.5584619", "0.55841994", "0.55825585", "0.55813", "0.55774415", "0.5573889", "0.5572747", "0.55489814", "0.5546621", "0.5545434", "0.5541296", "0.5537485", "0.55228156", "0.5522691", "0.5517459", "0.5513235", "0.5506919", "0.55039394", "0.550095", "0.54950833", "0.54924744", "0.54875296", "0.54809725", "0.5477979", "0.54754895", "0.5471887", "0.54710805", "0.54678607", "0.5462719" ]
0.6627038
3
Handle the movement of rooks. Find the rook that shares the same end file location. If it exists, check if there are any pieces on the same file on a rank between the start and end rank. If there is or if no rook is on the same file, check if the rook shares the same end rank location. If it does, check if there are any pieces on the same rank on a file between the start and end file.
public static int[] getRookStart(int[][] piecePos, int endFile, int endRank) { for (int[] pos: piecePos) { boolean correct = true; if (pos[0] == endFile) { int direction = (endRank - pos[1]) / Math.abs(endRank - pos[1]); for (int r = 0; r < Math.abs(pos[1] - endRank) - 1; r++) { if (!getBoardStateSquare(endFile, Math.abs(r + direction * pos[1] + 1)) .equals(" ")) { correct = false; break; } } if (correct) { int[] startPos = {pos[0], pos[1]}; if (isLegalMove(startPos, endFile, endRank)) { return startPos; } } } if (pos[1] == endRank) { correct = true; int direction = (endFile - pos[0]) / Math.abs(endFile - pos[0]); for (int f = 0; f < Math.abs(pos[0] - endFile) - 1; f++) { if (!getBoardStateSquare(Math.abs( f + direction * pos[0] + 1), endRank) .equals(" ")) { correct = false; break; } } if (correct) { int[] startPos = {pos[0], pos[1]}; if (isLegalMove(startPos, endFile, endRank)) { return startPos; } } } } return null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "protected synchronized boolean processNewRscDataListWithBinning() {\n preProcessFrameUpdate();\n\n boolean frameMatched = false;\n IRscDataObject lastDataObj = null;\n IRscDataObject rscDataObj = null;\n int closestMatch = 0;\n\n for (AbstractFrameData frameData : frameDataMap.values()) {\n if (frameData != null) {\n\n frameMatched = false;\n\n while (!newRscDataObjsQueue.isEmpty()) {\n rscDataObj = newRscDataObjsQueue.poll();\n\n if (frameData.isRscDataObjInFrame(rscDataObj)) {\n\n // Which is a closer match to the frame, the current\n // IRscDataObject or the one before?\n closestMatch = frameData.closestToFrame(rscDataObj,\n lastDataObj);\n\n // If current IRscDataObject rscDataObj is closer match\n if (closestMatch == 1) {\n addRscDataToFrame(frameData, rscDataObj);\n lastDataObj = rscDataObj;\n }\n // Else last IRscDataObject lastDataObj, closer (2)\n // OR last & current IRscDataObject are equal (0)\n // AND BOTH are not null (-1)\n else if (closestMatch != -1) {\n addRscDataToFrame(frameData, lastDataObj);\n }\n\n frameMatched = true;\n break;\n }\n\n lastDataObj = rscDataObj;\n\n } // end while\n\n if (!frameMatched) {\n\n // Which IRscDataObject is a closer time match ?\n // the last one processed or the current one?\n closestMatch = frameData.closestToFrame(rscDataObj,\n lastDataObj);\n\n // Latest IRscDataObject rscDataObj is the closest match\n if (closestMatch == 1) {\n addRscDataToFrame(frameData, rscDataObj);\n lastDataObj = rscDataObj;\n }\n // IF the previous IRscDataObject lastDataObj was the\n // closest match (2)\n // OR\n // IF the latest & previous were equally good matches(0)\n // and the two objects were equal without being both null\n // (-1)\n else if (closestMatch != -1) {\n addRscDataToFrame(frameData, lastDataObj);\n }\n\n }\n\n }\n } // end for\n\n // allow resources to post-process the data after it is added to the\n // frames\n postProcessFrameUpdate();\n autoUpdateReady = false;\n return true;\n }", "protected void tryFindCandidateMovesForFileAndRankStrategy(IRuleAgent oCurrentRule, IPositionAgent oCurrentPosition, IPositionAgent oLastPosition, IPieceAgent oPieceToMove, IPositionAgent oSourcePosition, IPlayerAgent oPlayer, Queue<RuleProcessorData> qData, Map<String, IMoveCandidate> mpCandidatePositions) {\n\t\tm_oLogger.writeLog(LogLevel.DETAILED, \"Finding candidate move positions.\", \"tryFindCandidateMovesForFileAndRankStrategy\", \"DefaultRuleProcessor\");\n\n\t\tfor (Map.Entry<String, IPathAgent> entry: oCurrentPosition.getAllPathAgents().entrySet()) {\n\t\t\tIPathAgent oPath = entry.getValue();\n \tif (oPath.getDirection() != oCurrentRule.getDirection()) {\n \t\tcontinue;\n \t}\n\t\t \t\t\n \t\tIterator<IPositionAgent> itPosition = oPath.getAllPositionAgents().iterator();\n \twhile (itPosition.hasNext()) {\n \t\t\t// Possible candidate position.\n \t\tIPositionAgent oNextPosition = itPosition.next(); \t\t\n \t\t\t \t\t\n \t\t\t// Validating position with the parameters defined in the Rule.\n \t\tif (!oCurrentPosition.tryValidateRuleApplicability(oPlayer.getBoardMapping(), oCurrentRule.getFamily(), oCurrentRule.getFile(), oCurrentRule.getRank(), oNextPosition)) {\n \t\t\tcontinue;\n \t\t}\n \t\t\n \t\t// Confirming if this Position is acceptable as a candidate and does the Rule allows to proceed further.\n \t\tAtomicReference<Boolean> bIsValidMode = new AtomicReference<Boolean>(false);\n \t\tAtomicReference<Boolean> bCanContinue = new AtomicReference<Boolean>(false);\n \t\t\n \t\tcheckForPositionMoveCandidacyAndContinuity(oPlayer, oCurrentRule, oNextPosition, bIsValidMode, bCanContinue);\n \t\t\n \t\t// Adding position to move candidates.\n \t\tif (bIsValidMode.get()) {\n \t\t\tmpCandidatePositions.put(oNextPosition.getName(), new MoveCandidate(oCurrentRule, oPieceToMove, oSourcePosition, oNextPosition));\n \t\t}\n \t\t\n \t\tif (!bCanContinue.get()) {\n \t\t\tcontinue;\n \t\t}\n \t\t\n \t\t\tIRuleAgent oDuplicateRule = oCurrentRule.clone();\n \t\tif (oDuplicateRule.canProceedWithThisRule()) {\n \t\t\tqData.add(new RuleProcessorData(oDuplicateRule, oNextPosition, null));\n \t\t} else {\n \t\t\tIRuleAgent oChildRule = null;\n \t\twhile ((oChildRule = oDuplicateRule.getNextChildRule()) != null) {\n \t\tqData.add(new RuleProcessorData(oChildRule, oNextPosition, null));\n \t\t}\n \t\t} \t\t\n \t}\n\t\t}\n\t}", "public static boolean isLegalMove(int[] startPos, int endFile,\n int endRank) {\n String[][] tempBoardState = new String[8][8];\n\n for (int r = 0; r < 8; r++) {\n for (int f = 0; f < 8; f++) {\n tempBoardState[r][f] = getBoardStateSquare(f, r);\n }\n }\n\n String piecePlusColor = getBoardStateSquare(startPos[0], startPos[1]);\n char piece = piecePlusColor.charAt(0);\n char color = piecePlusColor.charAt(1);\n char oppositeColor = color == 'w' ? 'b' : 'w';\n\n move(piecePlusColor, startPos[0], startPos[1], endFile, endRank);\n\n int[] kingPos = getPiecePositions(\"K\" + color, -1, -1)[0];\n\n if (kingPos[0] == startPos[0] || kingPos[1] == startPos[1]) {\n int[][] rookPos = getPiecePositions(\"R\" + oppositeColor, -1, -1);\n\n if (getRookStart(rookPos, kingPos[0], kingPos[1]) != null) {\n setBoardState(tempBoardState);\n\n return false;\n }\n }\n\n int[][] bishopPos = getPiecePositions(\"B\" + oppositeColor, -1, -1);\n\n if (getBishopStart(bishopPos, kingPos[0], kingPos[1]) != null) {\n setBoardState(tempBoardState);\n\n return false;\n }\n\n int[][] queenPos = getPiecePositions(\"Q\" + oppositeColor, -1, -1);\n\n if (getQueenStart(queenPos, kingPos[0], kingPos[1]) != null) {\n setBoardState(tempBoardState);\n\n return false;\n }\n\n setBoardState(tempBoardState);\n\n return true;\n }", "private boolean isNextMoveRochade(Move move)\r\n\t{\r\n\t\tif (!(move.from.piece instanceof King)) return false;\r\n\t\tint xDiffAbs = Math.abs(move.to.coordinate.x - move.from.coordinate.x); \r\n\t\treturn xDiffAbs == 2;\r\n\t}", "public boolean move(Block moveTo, boolean check, String move){\r\n\t\t//Translate File and Rank to array indices\r\n\t\t\t\tint srcFile = this.getBlock().getFile();\r\n\t\t\t\tint srcRank = chess.Chess.Rmap.get(this.getBlock().getRank()+\"\");\r\n\t\t\t\tint destFile = moveTo.getFile();\r\n\t\t\t\tint destRank = chess.Chess.Rmap.get(moveTo.getRank()+\"\"); \r\n\t\t\t\t\r\n\t\t\t\tif(((Math.abs(srcRank-destRank)==1 && Math.abs(srcFile-destFile)==2) || (Math.abs(srcRank-destRank)==2 && Math.abs(srcFile-destFile)==1))){\r\n\t\t\t\t\tif(moveTo.isOccupied()){\r\n\t\t\t\t\t\tif(moveTo.getPiece().getColor().equals(chess.Chess.board[srcRank][srcFile].getPiece().getColor())==true){\r\n\t\t\t\t\t\t\tif(check == true){\r\n\t\t\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tSystem.out.println(\"Invalid move, try again\");\r\n\t\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t//A check to see if this move puts the opponent's King in check\r\n\t\t\t\t\t\tif(check == true){\r\n\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t//Call deletePiece to indicate that target piece has been captured\r\n\t\t\t\t\t\tchess.Chess.board[destRank][destFile].getPiece().deletePiece(chess.Chess.board[destRank][destFile].getPiece().getNumber(), chess.Chess.board[destRank][destFile].getPiece());\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setPiece(getBlock().getPiece());\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif(chess.Chess.board[destRank][destFile].getPiece().getColor().equals(\"White\"))\r\n\t\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setDisplay(\"wN \");\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setDisplay(\"bN \");\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tthis.getBlock().setOccupied(false);\r\n\t\t\t\t\t\tthis.getBlock().setPiece(null);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif(this.getBlock().isShaded()){\r\n\t\t\t\t\t\t\tthis.getBlock().setDisplay(\"## \");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse{\r\n\t\t\t\t\t\t\tthis.getBlock().setDisplay(\" \");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tthis.setBlock(moveTo);\r\n\t\t\t\t\t\tchess.Chess.printBoard();\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\telse{\r\n\t\t\t\t\t\t//A check to see if this move puts the opponent's King in check\r\n\t\t\t\t\t\tif(check == true){\r\n\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setPiece(getBlock().getPiece());\r\n\t\t\t\t\t\tif(chess.Chess.board[destRank][destFile].getPiece().getColor().equals(\"White\"))\r\n\t\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setDisplay(\"wN \");\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setDisplay(\"bN \");\r\n\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setOccupied(true);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tthis.getBlock().setOccupied(false);\r\n\t\t\t\t\t\tthis.getBlock().setPiece(null);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif(this.getBlock().isShaded()){\r\n\t\t\t\t\t\t\tthis.getBlock().setDisplay(\"## \");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse{\r\n\t\t\t\t\t\t\tthis.getBlock().setDisplay(\" \");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tthis.setBlock(moveTo);\r\n\t\t\t\t\t\tchess.Chess.printBoard();\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse{\r\n\t\t\t\t\tif(check == true){\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tSystem.out.println(\"Invalid move, try again\");\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t}", "private void compareMove(int next){\n moveBuffer[0] = moveBuffer[1];//moveBuffer[0]=currentLocation,1 is next;\n moveBuffer[1] = next;\n if(moveBuffer[0]==moveBuffer[1]){\n flagbuffer0=0;\n return;\n }\n int currenti=0;int currentj=0;\n for ( int i = 0; i < 3; ++i ) {\n for ( int j = 0; j < 3; ++j ) {\n if ( maze[i][j] == moveBuffer[0] ) {\n currenti=i;\n currentj=j;\n break;// Found the correct i,j - print them or return them or whatever\n }\n }\n }\n int nexti=0;int nextj=0;\n for ( int i = 0; i < 3; ++i ) {\n for ( int j = 0; j < 3; ++j ) {\n if ( maze[i][j] == moveBuffer[1] ) {\n nexti=i;\n nextj=j;\n break;// Found the correct i,j - print them or return them or whatever\n }\n }\n }\n\n if( currenti== nexti){\n if(nextj > currentj && flagbuffer0==0){\n /*uiShowToast(\"Going right\");\n System.out.println(\"Going right\");\n this.sendCarMovement(\"R\");*/\n uiShowToast(\"Going right\");\n this.sendCarMovement(\"R\");\n try {\n Thread.sleep(550);\n } catch (InterruptedException e) {\n e.printStackTrace();\n }\n this.sendCarMovement(\"U\"); flagbuffer0=1;\n }\n else if(nextj < currentj && flagbuffer0==0){\n uiShowToast(\"Going left\");\n this.sendCarMovement(\"L\");\n try {\n Thread.sleep(550);\n } catch (InterruptedException e) {\n e.printStackTrace();\n }\n this.sendCarMovement(\"U\"); flagbuffer0=1;\n }\n else if(flagbuffer0==1){\n this.sendCarMovement(\"U\");\n }\n }\n if( currentj== nextj){\n if(nexti > currenti){\n /*uiShowToast(\"Going down\");\n System.out.println(\"Going down\");\n this.sendCarMovement(\"D\");*/\n uiShowToast(\"Going down\");\n flagbuffer0=0;\n this.sendCarMovement(\"L\");\n try {\n Thread.sleep(1100);\n } catch (InterruptedException e) {\n e.printStackTrace();\n }\n this.sendCarMovement(\"U\");\n\n }\n else if(nexti < currenti){\n /*uiShowToast(\"Going up\");\n System.out.println(\"Going up\");\n this.sendCarMovement(\"U\");*/\n uiShowToast(\"Going up\");\n flagbuffer0=0;\n this.sendCarMovement(\"U\");\n try {\n Thread.sleep(550);\n } catch (InterruptedException e) {\n e.printStackTrace();\n }\n this.sendCarMovement(\"U\");\n }\n }\n /*if(movebuffer[0]==mvebuffer[1]){\n uiShowToast(\"Going up\");\n this.sendCarMovement(\"U\");\n try {\n Thread.sleep(550);\n } catch (InterruptedException e) {\n e.printStackTrace();\n }\n this.sendCarMovement(\"U\");\n }else{\n\n }\n\n /*\n */\n /* Damon movement code\n if(moveBuffer[1] == 100 && moveBuffer[0] == 200){\n uiShowToast(\"Going left\");\n System.out.println(\"Going left\");\n this.sendCarMovement(\"L\");\n try {\n Thread.sleep(550);\n } catch (InterruptedException e) {\n e.printStackTrace();\n }\n this.sendCarMovement(\"U\");\n try {\n Thread.sleep(2000);\n } catch (InterruptedException e) {\n e.printStackTrace();\n }\n }else{\n uiShowToast(\"Going up\");\n //Toast.makeText(getApplicationContext(), \"Going up\", Toast.LENGTH_LONG).show();\n System.out.println(\"Going up\");\n this.sendCarMovement(\"U\");\n try {\n Thread.sleep(2000);//wait 2 sec to next command;\n } catch (InterruptedException e) {\n e.printStackTrace();\n }\n }\n */\n return;\n }", "private static Point chooseNextPos(Point currPos, Point droneNextDes, Point coord1, Point coord2, double buildingSideGrad, Point buildingCentre, List<List<List<Point>>> noFlyZonesCoords, Point previous1, Point previous2) throws IOException, InterruptedException {\r\n\t\tvar possibleNextPos = possibleNextPos(currPos, coord1, coord2, buildingSideGrad, buildingCentre);\r\n\t\tvar nextPosTemp1 = possibleNextPos.get(0);\r\n\t\tvar nextPosTemp2 = possibleNextPos.get(1);\r\n\t\t\r\n\t\tvar euclidDist1 = euclidDist(droneNextDes, nextPosTemp1); \r\n\t\tvar euclidDist2 = euclidDist(droneNextDes, nextPosTemp2);\r\n\t\t\r\n\t\tPoint nextPos = droneNextDes;\r\n\t\t\r\n\r\n\t\t//in the case that both directions result in no intersection, \r\n\t\t//it chooses the one that minimises the distance between the drone's next position and desired position \r\n\t\t//and doesn't result in the drone going back and fourth continuously \r\n\t\tif(noIntersections(currPos, nextPosTemp1, noFlyZonesCoords)==true && noIntersections(currPos, nextPosTemp2, noFlyZonesCoords)==true) {\r\n\t\t\tvar repeatedMoveDir1 = false; //in the case that previous1 and previous2 are null\r\n\t\t\tvar repeatedMoveDir2 = false;\r\n\t\t\tif(previous1!=null && previous2!=null) {\r\n\t\t\t\trepeatedMoveDir1 = computeDir(previous2, previous1)==computeDir(currPos, nextPosTemp1); //next move is equal to 2 moves before, indicating repeated move\r\n\t\t\t\trepeatedMoveDir2 = computeDir(previous2, previous1)==computeDir(currPos, nextPosTemp2);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif(euclidDist1<euclidDist2 && repeatedMoveDir1==false || repeatedMoveDir2==true) {\r\n\t\t\t\tnextPos = nextPosTemp1;\r\n\t\t\t}\r\n\t\t\tif(repeatedMoveDir1==true || euclidDist2<euclidDist1 && repeatedMoveDir2==false){\r\n\t\t\t\tnextPos = nextPosTemp2;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse if(noIntersections(currPos, nextPosTemp1, noFlyZonesCoords)==true && noIntersections(currPos, nextPosTemp2, noFlyZonesCoords)==false) {\r\n\t\t\tnextPos = nextPosTemp1;\r\n\t\t}\r\n\t\telse if(noIntersections(currPos, nextPosTemp1, noFlyZonesCoords)==false && noIntersections(currPos, nextPosTemp2, noFlyZonesCoords)==true) { //\r\n\t\t\tnextPos = nextPosTemp2;\r\n\t\t}\r\n\t\t\r\n\r\n\t\treturn nextPos;\r\n\t}", "@Override\r\n public boolean canMove() {\r\n Grid<Actor> gr = getGrid();\r\n int dirs[] = {\r\n Location.AHEAD, Location.HALF_CIRCLE, Location.LEFT,\r\n Location.RIGHT };\r\n // 当终点在周围时,不能移动且isEnd应当为true\r\n for (int i = 0; i < dirs.length; i++) {\r\n Location tarLoc = getLocation().getAdjacentLocation(dirs[i]);\r\n if (gr.isValid(tarLoc) && gr.get(tarLoc) != null) {\r\n // Color直接用==计算竟然不可行(真是哔了dog...\r\n if (gr.get(tarLoc) instanceof Rock\r\n && gr.get(tarLoc).getColor().equals(Color.RED)) {\r\n isEnd = true;\r\n return false;\r\n }\r\n }\r\n }\r\n ArrayList<Location> nextLocs = getValid(getLocation());\r\n // 当附近没有可以移动的位置时,不能移动\r\n if (nextLocs.size() == 0) {\r\n return false;\r\n }\r\n // 当可以移动的位置>1时,说明存在一个节点,这个节点应当被新建一个arraylist入栈\r\n if (nextLocs.size() > 1) {\r\n ArrayList<Location> newStackElem = new ArrayList<Location>();\r\n newStackElem.add(getLocation());\r\n crossLocation.push(newStackElem);\r\n }\r\n // 有可以移动的位置时,向概率最高的方向移动\r\n int maxProbLoc = 0;\r\n // 由于nextLocs不一定有4个location,所以只好循环判断取最大值\r\n for (int i = 0; i < nextLocs.size(); i++) {\r\n Location loc = nextLocs.get(i);\r\n int dirNum = getLocation().getDirectionToward(loc) / 90;\r\n if (probablyDir[dirNum] > probablyDir[maxProbLoc]) {\r\n maxProbLoc = i;\r\n }\r\n }\r\n next = nextLocs.get(maxProbLoc);\r\n return true;\r\n }", "private boolean isLastMoveRochade()\r\n\t{\r\n\t\tMove lastMove = getLastMove();\r\n\t\tif (lastMove == null) return false;\r\n\t\tPiece king = lastMove.to.piece;\r\n\t\tif (!(king instanceof King)) return false;\r\n\t\t\r\n\t\tint y = king.getColor().equals(Color.WHITE) ? 0 : 7;\r\n\t\tif (lastMove.to.coordinate.y != y) return false;\r\n\t\t\r\n\t\tint xDiffAbs = Math.abs(lastMove.to.coordinate.x - lastMove.from.coordinate.x); \r\n\t\treturn xDiffAbs == 2;\r\n\t}", "private void moveRobots() {\n\t\tfor(Player p : playerList) {\n\t\t\tif(p.getType() == Player.PlayerType.Robot) {\n\t\t\t\tPoint old = new Point(p.getX(), p.getY());\n\t\t\t\tPoint newPoint = new Point(p.getX(), p.getY());\n\t\t\t\t\n\t\t\t\toccupiedPositions.remove(old);\n\t\t\t\t\n\t\t\t\tint playerX = p.getPlayerToFollow().getX();\n\t\t\t\tint playerY = p.getPlayerToFollow().getY();\n\t\t\t\t\n\t\t\t\t//move towards the agent\n\t\t\t\tif(p.getX() < playerX)\n\t\t\t\t\tnewPoint.x += 1;\n\t\t\t\telse if(p.getX() > playerX)\n\t\t\t\t\tnewPoint.x -= 1;\n\t\t\t\t\n\t\t\t\tif(p.getY() < playerY)\n\t\t\t\t\tnewPoint.y += 1;\n\t\t\t\telse if(p.getY() > playerY)\n\t\t\t\t\tnewPoint.y -= 1;\n\t\t\t\t\n\t\t\t\tp.setPosition(newPoint);\n\t\t\t\t\n\t\t\t\t//check if the robot has moved on to something\n\t\t\t\tif(occupiedPositions.contains(newPoint)) { \t\t// check if the position is occupied\n\t\t\t\t\tfor(Player p2 : playerList) { \t\t\t\n\t\t\t\t\t\tif(!p.getName().equals(p2.getName())) {\t// check so it not is the robot itself\n\t\t\t\t\t\t\tif(newPoint.equals(p2.getPosition())) {\n\t\t\t\t\t\t\t\tif(p2.getType() == PlayerType.Robot) { // if it is a robot, both should be rubble\n\t\t\t\t\t\t\t\t\tp2.setType(PlayerType.Rubble);\n\t\t\t\t\t\t\t\t\tp2.getPlayerToFollow().decreaseRobotsFollowing();\n\t\t\t\t\t\t\t\t\tp.setType(PlayerType.Rubble);\n\t\t\t\t\t\t\t\t\tp.getPlayerToFollow().decreaseRobotsFollowing();\n\t\t\t\t\t\t\t\t\tHandleCommunication.broadcastToClient(null, server.getConnectedClientList(), SendSetting.ChangedType, p.getName(), p2.getName());\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif(p2.getType() == PlayerType.Rubble) { // if it is rubble\n\t\t\t\t\t\t\t\t\tp.setType(PlayerType.Rubble);\n\t\t\t\t\t\t\t\t\tp.getPlayerToFollow().decreaseRobotsFollowing();\n\t\t\t\t\t\t\t\t\tHandleCommunication.broadcastToClient(null, server.getConnectedClientList(), SendSetting.ChangedType, p.getName(), p2.getName());\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse if(p2.getType() == PlayerType.Agent) {\n\t\t\t\t\t\t\t\t\tString send = generateSendableHighscoreList();\n\t\t\t\t\t\t\t\t\tserver.sendMessageToClient(p2.getName(), \"@132@\" + highscore.size() + \"@\" + send);\n\t\t\t\t\t\t\t\t\tserver.addTextToLoggingWindow(\"Robot killed player (\" + p2.getName() + \")\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\toccupiedPositions.add(newPoint);\n\t\t\t\tserver.broadcastToClient(p.getName(), SendSetting.PlayerMoved, old, newPoint);\n\t\t\t}\t\n\t\t}\n\t\t\n\t\t//send that it is agents turn again\n\t\tserver.broadcastToClient(null, SendSetting.AgentsTurnToMove, null, null);\n\t}", "public static void rosterSync() {\n\n Connection con = null; // init DB objects\n Connection con2 = null; // init DB objects\n PreparedStatement pstmt2 = null;\n Statement stmt = null;\n Statement stmt2 = null;\n ResultSet rs = null;\n ResultSet rs2 = null;\n\n String errorMsg = \"Error in Common_sync.rosterSync: \";\n\n String emailMsgAll = \"Roster Sync Results: \\n\\n\";\n\n\n boolean failed = false;\n boolean changed = false;\n boolean skip = false;\n\n int result = 0;\n int clubCount = 0;\n\n //\n // This must be the master server!!! If not, let the timer run in case master goes down.\n //\n if (Common_Server.SERVER_ID == TIMER_SERVER) {\n\n //\n // Load the JDBC Driver and connect to DB\n //\n String club = rev; // get v_ db name\n\n try {\n con2 = dbConn.Connect(club);\n\n }\n catch (Exception exc) {\n return;\n }\n\n try {\n //\n // Search through each club in the system and look for a corresponding file\n //\n stmt2 = con2.createStatement(); // create a statement\n\n rs2 = stmt2.executeQuery(\"SELECT clubname FROM clubs\");\n\n while (rs2.next()) {\n\n club = rs2.getString(1); // get a club name\n\n con = dbConn.Connect(club); // get a connection to this club's db\n\n //\n // Init the rsync flag for ALL clubs so only those that actually still use RSync will be set.\n //\n try {\n\n stmt = con.createStatement(); // create a statement\n\n stmt.executeUpdate(\"UPDATE club5 SET rsync = 0\");\n\n stmt.close();\n\n }\n catch (Exception exc) {\n }\n\n //\n // Do custom processing for clubs that do not use RS\n //\n if (club.equals(\"tualatincc\")) { // Tualatin CC\n\n checkTualatin(con); // check birth dates for mtypes (Juniors) - no rsoter sync\n\n } else if (club.equals(\"interlachen\")) { // Interlachen CC\n\n checkInterlachen(con); // check birth dates for mtypes (Juniors) - no roster sync\n\n } else if (club.equals(\"mountvernoncc\")) { // Mount Vernon CC\n\n checkMountVernon(con); // check birth dates for mtypes (Juniors) - no roster sync\n\n } else if (club.equals(\"hyperion\")) { // Hyperion Field Club\n\n checkHyperion(con); // check birth dates for mtypes (Juniors) - no roster sync\n\n } else if (club.equals(\"tahoedonner\")) {\n\n checkTahoeDonner(con); // check birth dates for mtypes (Juniors) - no roster sync\n\n } else {\n\n //\n // Go process this club\n //\n result = clubSync(club, con);\n\n if (result == 0) {\n //emailMsgAll = emailMsgAll + \"Roster Not Found for: \" + club + \"\\n\\n\";\n } else if (result == 1) {\n emailMsgAll += \"Roster Found for: \" + club + \"\\n\\n\";\n clubCount++;\n } else if (result == -1) {\n //emailMsgAll += \"Roster Sync Failed for: \" + club + \"\\n\\n\";\n }\n\n }\n\n con.close(); // return/close the connection\n\n } // end of WHILE clubs\n\n stmt2.close(); // close the stmt\n\n }\n catch (Exception exc) {\n\n errorMsg = errorMsg + \" Error getting club db for \" +club+ \", \" + exc.getMessage(); // build msg\n SystemUtils.logError(errorMsg); // log it\n }\n\n }\n\n //\n // Reset the Roster Sync Timer for next night\n //\n TimerSync sync_timer = new TimerSync();\n\n try {\n\n if (con != null) {\n\n con.close(); // return/close the connection\n }\n }\n catch (SQLException e) {\n }\n\n try {\n\n if (con2 != null) {\n\n con2.close(); // return/close the connection\n }\n }\n catch (SQLException e) {\n }\n\n //\n // Send an email to our support if any clubs were processed\n //\n if (Common_Server.SERVER_ID == TIMER_SERVER && clubCount > 0) {\n\n try {\n\n Properties properties = new Properties();\n properties.put(\"mail.smtp.host\", host); // set outbound host address\n properties.put(\"mail.smtp.port\", port); // set outbound port\n properties.put(\"mail.smtp.auth\", \"true\"); // set 'use authentication'\n\n Session mailSess = Session.getInstance(properties, SystemUtils.getAuthenticator()); // get session properties\n\n MimeMessage message = new MimeMessage(mailSess);\n\n message.setFrom(new InternetAddress(efrom)); // set from addr\n\n message.setSubject( \"ForeTees Roster Sync Report: \" +clubCount+ \" Clubs\" ); // set subject line\n message.setSentDate(new java.util.Date()); // set date/time sent\n\n message.addRecipient(Message.RecipientType.TO, new InternetAddress(emailFT)); // set our support email addr\n\n message.setText( emailMsgAll ); // put msg in email text area\n\n Transport.send(message); // send it!!\n\n }\n catch (Exception ignore) {\n }\n }\n\n }", "private String rooverSetUp() throws IOException\n {\n if (fileName == null)\n {\n System.err.println(\"Please set fileName before calling runRoover\");\n return null;\n }\n \n BufferedReader r = new BufferedReader(new FileReader(fileName));\n String[] dims = r.readLine().split(\" \"); //reads the first line, which is the dimensions of our grid\n numCols = Integer.parseInt(dims[0]);\n numRows = Integer.parseInt(dims[1]);\n String[] dirtPosArr;\n String currDirtPos;\n \n //read in rooverPos\n String[] rooverPosStr = r.readLine().split(\" \");\n currXPos = Integer.parseInt(rooverPosStr[0]);\n currYPos = Integer.parseInt(rooverPosStr[1]);\n \n //validate inputs\n if (numCols <= 0 || numRows <= 0 || currXPos < 0 || currXPos > numCols - 1 \n || currYPos < 0 || currYPos > numRows - 1)\n {\n System.err.println(\"Invalid inputs for board size or starting roover position.\");\n r.close();\n return null;\n }\n \n String currLine = r.readLine();\n String nextLine = r.readLine();\n //set up the roover and dirt patches\n while (nextLine != null)\n {\n dirtPosArr = currLine.split(\" \");\n \n //validate dirt pos\n if (Integer.parseInt(dirtPosArr[0]) < 0 || Integer.parseInt(dirtPosArr[0]) > numCols - 1\n || Integer.parseInt(dirtPosArr[1]) < 0 || Integer.parseInt(dirtPosArr[1]) > numRows - 1)\n {\n System.err.println(\"Invalid dirt position.\");\n r.close();\n return null;\n }\n \n currDirtPos = dirtPosArr[0] + dirtPosArr[1];\n dirtSet.add(currDirtPos);\n currLine = nextLine;\n nextLine = r.readLine();\n }\n \n r.close();\n \n //at this point, currLine is the driving instructions\n return currLine;\n }", "private static List<Point> possibleNextPos(Point currPos, Point coord1, Point coord2, double buildingSideGrad, Point buildingCentre){\r\n\t\tvar coord1Lat = coord1.latitude();\r\n\t\tvar coord1Lon = coord1.longitude();\r\n\t\tvar coord2Lat = coord2.latitude();\r\n\t\tvar coord2Lon = coord2.longitude();\r\n\t\t\r\n\t\tvar currPosLon = currPos.longitude();\r\n\t\tvar currPosLat = currPos.latitude();\r\n\t\t\r\n\t\tvar buildingLon = buildingCentre.longitude();\r\n\t\tvar buildingLat = buildingCentre.latitude();\r\n\t\t\r\n\t\tvar dir1 = computeDir(coord1, coord2); //in the case that the drone is moving in the direction coord1 to coord2\r\n\t\tvar nextPosTemp1 = nextPos(dir1, currPos); //the temporary next position if the drone moves in dir1\r\n\t\t\r\n\t\tvar dir2 = computeDir(coord2, coord1); //in the case that the drone is moving in the direction coord2 to coord1\r\n\t\tvar nextPosTemp2 = nextPos(dir2, currPos); //the temporary next position if the drone moves in dir2 \r\n\t\t\r\n\t\tvar possibleNextPos = new ArrayList<Point>();\r\n\t\t\r\n\t\tif(Math.abs(buildingSideGrad)>=1) { //in this case, longitudes of building centre and drone current position are compared\r\n\t\t\t//coord1 to coord2 scenario\r\n\t\t\tif((coord1Lat>coord2Lat && buildingLon<currPosLon) || (coord1Lat<coord2Lat && buildingLon>currPosLon)) {\r\n\t\t\t\tdir1 = (dir1+10)%360; //angle increased such that drone doesn't fly over side of building\r\n\t\t\t\tnextPosTemp1 = nextPos(dir1, currPos);\r\n\t\t\t}\r\n\t\t\t//coord2 to coord1 scenario\r\n\t\t\tif((coord1Lat<coord2Lat && buildingLon<currPosLon) || (coord1Lat>coord2Lat && buildingLon>currPosLon)) {\r\n\t\t\t\tdir2 = (dir2+10)%360;\r\n\t\t\t\tnextPosTemp2 = nextPos(dir2, currPos);\r\n\t\t\t}\t\t\t\r\n\t\t}\r\n\t\telse { //in this case, latitudes of building centre and drone current position are compared\r\n\t\t\tif((coord1Lon>coord2Lon && buildingLat>currPosLat) || (coord1Lon<coord2Lon && buildingLat<currPosLat)) {\r\n\t\t\t\tdir1 = (dir1+10)%360; \r\n\t\t\t\tnextPosTemp1 = nextPos(dir1, currPos);\r\n\t\t\t}\r\n\r\n\t\t\tif((coord1Lon<coord2Lon && buildingLat>currPosLat) || (coord1Lon>coord2Lon && buildingLat<currPosLat)) {\r\n\t\t\t\tdir2 = (dir2+10)%360;\r\n\t\t\t\tnextPosTemp2 = nextPos(dir2, currPos);\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tpossibleNextPos.add(nextPosTemp1);\r\n\t\tpossibleNextPos.add(nextPosTemp2);\r\n\t\t\r\n\t\treturn possibleNextPos;\r\n\t}", "public void runRoover() throws IOException\n { \n String drivingInstr = rooverSetUp();\n if (drivingInstr == null)\n return;\n \n //check to see if roover's original position has a dirt patch\n if (dirtSet.contains(Integer.toString(currXPos) + Integer.toString(currYPos)))\n {\n dirtSet.remove(Integer.toString(currXPos) + Integer.toString(currYPos));\n numPatchesCleaned++;\n }\n \n //at this point, currline will be the last line in our input, which is driving instructions\n char[] instructions = drivingInstr.toUpperCase().toCharArray();\n for (int i = 0; i < instructions.length; i++)\n {\n switch(instructions[i]) {\n case 'N':\n if (currYPos + 1 < numRows)\n {\n currYPos++;\n }\n break;\n case 'S':\n if (currYPos - 1 >= 0)\n {\n currYPos--;\n }\n break;\n case 'W':\n if (currXPos - 1 >= 0)\n {\n currXPos--;\n }\n break;\n case 'E':\n if (currXPos + 1 < numCols)\n {\n currXPos++;\n }\n break;\n default:\n System.err.println(\"Invalid driving instruction, please enter N, S, W, or E only.\");\n break;\n }\n \n if (dirtSet.contains(Integer.toString(currXPos) + Integer.toString(currYPos)))\n {\n dirtSet.remove(Integer.toString(currXPos) + Integer.toString(currYPos));\n numPatchesCleaned++;\n }\n }\n \n System.out.println(currXPos + \" \" + currYPos);\n System.out.println(numPatchesCleaned);\n }", "public void checkEndGame() {\n\t\t\n\t\tboolean gameFinished = false;\n\t\t//boolean playerOne = false;\n\t\t//boolean playerTwo = false;\n\t\t\n\t\t\n\t\tif (bucket[13].getnumOfRocks() == 0 && bucket[12].getnumOfRocks() == 0 && bucket[11].getnumOfRocks() == 0\n\t\t\t\t&& bucket[10].getnumOfRocks() == 0 && bucket[9].getnumOfRocks() == 0\n\t\t\t\t&& bucket[8].getnumOfRocks() == 0) {\n\n\t\t\tint left = bucket[6].getnumOfRocks() + bucket[5].getnumOfRocks() + bucket[4].getnumOfRocks()\n\t\t\t\t\t+ bucket[3].getnumOfRocks() + bucket[2].getnumOfRocks() + bucket[1].getnumOfRocks()\n\t\t\t\t\t+ bucket[0].getnumOfRocks();\n\n\t\t\tbucket[0].setnumOfRocks(left, c);\n\t\t\tbucket[6].setnumOfRocks(0, c);\n\t\t\tbucket[5].setnumOfRocks(0, c);\n\t\t\tbucket[4].setnumOfRocks(0, c);\n\t\t\tbucket[3].setnumOfRocks(0, c);\n\t\t\tbucket[2].setnumOfRocks(0, c);\n\t\t\tbucket[1].setnumOfRocks(0, c);\n\t\t\t\n\t\t\tgameFinished = true;\n\t\t}\n\n\t\tif (bucket[1].getnumOfRocks() == 0 && bucket[2].getnumOfRocks() == 0 && bucket[3].getnumOfRocks() == 0\n\t\t\t\t&& bucket[4].getnumOfRocks() == 0 && bucket[5].getnumOfRocks() == 0 && bucket[6].getnumOfRocks() == 0) {\n\n\t\t\tint right = bucket[13].getnumOfRocks() + bucket[12].getnumOfRocks() + bucket[11].getnumOfRocks();\n\t\t\tright = right + bucket[10].getnumOfRocks() + bucket[9].getnumOfRocks() + bucket[8].getnumOfRocks()\n\t\t\t\t\t+ bucket[7].getnumOfRocks();\n\n\t\t\tbucket[7].setnumOfRocks(right, c);\n\t\t\tbucket[13].setnumOfRocks(0, c);\n\t\t\tbucket[12].setnumOfRocks(0, c);\n\t\t\tbucket[11].setnumOfRocks(0, c);\n\t\t\tbucket[10].setnumOfRocks(0, c);\n\t\t\tbucket[9].setnumOfRocks(0, c);\n\t\t\tbucket[8].setnumOfRocks(0, c);\n\n\t\t\tgameFinished = true;\n\t\t}\n\t\t\n\t\t\n\t\tif(gameFinished==true){\n\t\t\tif(bucket[7].getnumOfRocks()<bucket[0].getnumOfRocks()){\n\t\t\t\tplayerOne=true;\n\t\t\t}else{\n\t\t\t\tplayerTwo=true;\n\t\t\t}\n\t\t}\n\t\t\n\t\t/*if(playerOne==true){\n\t\t\tSystem.out.println(\"Player A won\");\n\t\t}\n\t\tif(playerTwo == true){\n\t\t\tSystem.out.println(\"Player B won\");\n\t\t}\n\t\t */\n\t\t\n\t}", "public int[][] isAnyPath(/*int [] Start, int[] End,*/Board B) {\r\n \t//Trace Moveset, determine if moveset is valid for current position [Exceptions are knight, which can move OVER pieces\r\n \t//As long as knight's ending position is not taken.\r\n \t//If Pawn\r\n \t\r\n \t//8X8 Board\r\n \t//int BoundR = 8;\r\n \t//int BoundC = 8;\r\n \t\r\n \t//int[][]Seq = null;\r\n \t\r\n \t//int[][]C_ = null;\r\n \t\r\n \t//LinkedList<int[]> L = new LinkedList<int []>();\r\n \t\r\n \tint Max_Mv_ln = 0;\r\n \tfor(int k=0;k<this.Movesets.length;k++) {\r\n \t\tSystem.out.printf(\"Compare Mx %s\\n\",this.Movesets[k]);\r\n \t\tif(this.Movesets[k]!=null)\r\n \t\tif(this.Movesets[k].toCharArray().length>Max_Mv_ln) {\r\n \t\t\tMax_Mv_ln = this.Movesets[k].toCharArray().length;\r\n \t\t}\r\n \t}\r\n \t\r\n \tSystem.out.printf(\"Maximum Move Size for Piece:%c,%d:\",this.type,Max_Mv_ln);\r\n \t\r\n \t//Each row is a moveset, each column is sets of two integers corresponding \r\n \t//to each move position\r\n \t\r\n \t//List of Path Sequence freedoms for each moveset of this PIECE \r\n \tLinkedList<int[][]> LAll = new LinkedList<int[][]>();\r\n \t\r\n \t//int Ct = 0;\r\n \t\r\n \tfor(int i=0;i<this.Movesets.length;i++) { \r\n \t//Found MoveSet[ith]\r\n \t\tif(this.Movesets[i]!=null) {\r\n \tchar []Mv = this.Movesets[i].toCharArray();\r\n \tint [] C2 = null;\r\n \tint[][]C = new int[Mv.length][1];\r\n \tSystem.out.printf(\"\\n\\nAnalyze Moveset:%s\\n\\n\", this.Movesets[i]);\r\n \tfor(int j=0;j<Mv.length;j++) {\r\n \t//Iterate through each movement pattern\r\n //Return Collision list of endpoints for pieces\r\n \tif(Mv[j]=='R'||Mv[j]=='D'||Mv[j]=='L'||Mv[j]=='U') {\r\n \t\t\r\n \t\tchar v = Character.toLowerCase(Mv[j]);\r\n \t\r\n \t}\r\n \t\r\n \telse {\r\n \t\tif(this.type=='k'&&j<Mv.length-2) {\r\n \t\t\tif(j>0)\r\n \t\t\tC2 = Collisions(Mv[j],Mv[j+1],/*Start,End,*/B,true,C[j-1]);\r\n \t\t\telse\r\n \t\t\tC2 = Collisions(Mv[j],Mv[j+1],/*Start,End,*/B,true,null);\r\n \t\t}\r\n \t\telse {\r\n \t\t\tif(j>0)\r\n \t\t\tC2 = Collisions(Mv[j],Mv[j+1],/*Start,End,*/B,false,C[j-1]);\r\n \t\t\telse\r\n \t\t\tC2 = Collisions(Mv[j],Mv[j+1],/*Start,End,*/B,false,null);\r\n \t\t\t\r\n \t\t}\r\n \t\tj++;\r\n \t\r\n \t}\r\n \t\r\n \tif(C2==null) {\r\n \t\t//MoveSet failed, on to next moveset for piece...\r\n \t\tC=null;\r\n \t\tbreak;\r\n \t}\r\n \telse {\r\n \t\t\r\n \t\tif(C2[0]<0) {\r\n \t\t\tC = null;\r\n \t\t\tbreak;\r\n \t\t}\r\n \t\tC[j] = C2;//ReSize(C2,LengthMvSet(this.Movesets[i]));\r\n \t\t//Ct++;\r\n \t\t//System.out.println(\"Add Moveset:\\n\");\r\n \t\t//PrintAll(C2,(C2.length/2));\r\n \t\t//PrintAll(C2,LengthMvSet(this.Movesets[i]));\r\n \t\t//C[j].length = (C[j].length/2)+6;\r\n \t\t//Ct++;\r\n \t}\r\n \t\r\n \t}\r\n \t//Add Path seq possibilities to list\r\n \tLAll.add(C);\r\n \t//System.out.println(\"Add Moveset:\\n\");\r\n \t/*\r\n \tif(C2!=null)\r\n \tPrintAll(C2,(C2.length/2)//+6//);\r\n \t*/\r\n \t}\r\n \t}\r\n \t\r\n \tSystem.out.printf(\"\\nALL possible paths for piece %c in position [%d,%d]\\n\",this.type,this.Position[0],this.Position[1]);\r\n \t\r\n \t//Object[] A = LAll.toArray();\r\n \tSystem.out.printf(\"LENGTH Of LIST:%d\", LAll.toArray().length);\r\n \t\r\n \tint [] E = new int[2];\r\n \t\r\n \tint[][] EAll = new int[this.Movesets.length][1];\r\n \t\r\n \tfor(int i=0;i<LAll.toArray().length;i++) {\r\n \t\tSystem.out.printf(\"Player %c Possibilities for %d Moveset:%s\\n\",super.Player,i,this.Movesets[i]);\r\n \t\tint[][]C2 = LAll.get(i);\r\n \t\tif(C2!=null) {\r\n \t\t\tfor(int k=0; k<C2.length;k++) {\r\n \t\t\t//System.out.printf(\"Length of this moveset: %d\\n\",LengthMvSet(this.Movesets[i]));\r\n \t\t\tif(C2[k]!=null) {\r\n \t\t\tfor(int l=0; l<(C2[k].length/2);l=l+2) {\r\n \t\t\t\tSystem.out.printf(\"[%d,%d]\\n\", C2[k][l], C2[k][l+1]);\r\n \t\t\t\tif(l==0) {\r\n \t\t\t\t\t//System.out.printf(\"Effective position to Traverse to: [%d,%d]\\n\", LastElem(C2)[l],LastElem(C2)[l+1]);\r\n \t\t\t\t\tE = C2[k];\r\n \t\t\t\t\t//E[0] = C2[k][0];\r\n \t\t\t\t\t//E[1] = C2[k][1];\r\n \t\t\t\t}\r\n \t\t\t}\r\n \t\t\t//PrintAll(C2[k],(C2[k].length/2));\r\n \t\t\t}\r\n \t\t}\r\n \t\t\tEAll[i] = E;\r\n \t\t\tSystem.out.printf(\"Effective position to Traverse to: [%d,%d]\\n\",E[0],E[1]);\r\n \t\t}\r\n \t\telse {\r\n \t\t\tSystem.out.println(\"NO Effective Position to Traverse to!\");\r\n \t\t}\r\n \t}\r\n \t\r\n \t//System.out.printf(\"Effective Position to Traverse to: [%d,%d]\", LAll.get(LAll.size()-1)[LAll.get(LAll.size()-1).length-1][0],LAll.get(LAll.size()-1)[LAll.get(LAll.size()-1).length-1][1]);\r\n \t\r\n \t\r\n \treturn EAll;\r\n }", "private void checkTargetsReachable(){\n\t\tPathfinder pathfinder = new Pathfinder(collisionMatrix);\n\t\tLinkedList<Node> removeList = new LinkedList<Node>();\n\t\tboolean pathWasFound = false;\n\t\tLinkedList<Node> currentPath;\n\t\tLinkedList<Node> reversePath;\n\t\t\n\t\t//Go through all starting positions\n\t\tfor(LinkedList<Node> startList : targets){\n\t\t\tprogress += 8;\n\t\t\tsetProgress(progress);\n\t\t\tfor(Node startNode : startList){\n\t\t\t\t\n\t\t\t\tboolean outsideMap = (startNode.getCollisionXPos(scaleCollision) < 0 || startNode.getCollisionXPos(scaleCollision) >= (collisionMatrix.length-1) || startNode.getCollisionYPos(scaleCollision) < 0 || startNode.getCollisionYPos(scaleCollision) >= (collisionMatrix.length-1));\n\t\t\t\t\n\t\t\t\tpathWasFound = false;\n\t\t\t\t//Make sure that target is inside of map\n\t\t\t\tif(!outsideMap){\n\t\t\t\t\t//Check against all target positions\n\t\t\t\t\tfor(LinkedList<Node> targetList : targets){\n\t\t\t\t\t\tfor(Node targetNode : targetList){\n\t\t\t\t\t\t\t//Only check against targets that have not already been marked as unreachable\n\t\t\t\t\t\t\tboolean selfCheck = (targetNode.getXPos() != startNode.getXPos() || targetNode.getYPos() != startNode.getYPos());\n\t\t\t\t\t\t\tif(!removeList.contains(targetNode) && selfCheck){\n\t\t\t\t\t\t\t\t//Check if this path has already been checked\n\t\t\t\t\t\t\t\tif(!preCalculatedPaths.containsKey(startNode.toStringCollision(scaleCollision) + \"-\" + targetNode.toStringCollision(scaleCollision))){\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tcurrentPath = new LinkedList<Node>();\n\t\t\t\t\t\t\t\t\t//Check if a path can be found for this start and target node\n\t\t\t\t\t\t\t\t\tif(pathfinder.findPath(startNode.getCollisionXPos(scaleCollision), startNode.getCollisionYPos(scaleCollision), targetNode.getCollisionXPos(scaleCollision), targetNode.getCollisionYPos(scaleCollision), currentPath)){\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tif(Frame.USE_PRECALCULATED_PATHS)\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tpreCalculatedPaths.put(startNode.toStringCollision(scaleCollision) + \"-\" + targetNode.toStringCollision(scaleCollision), currentPath);\n\t\t\t\t\t\t\t\t\t\t\treversePath = new LinkedList<Node>();\n\t\t\t\t\t\t\t\t\t\t\treversePath.addAll(currentPath);\n\t\t\t\t\t\t\t\t\t\t\tCollections.reverse(reversePath);\n\t\t\t\t\t\t\t\t\t\t\treversePath.removeFirst();\n\t\t\t\t\t\t\t\t\t\t\treversePath.add(startNode);\n\t\t\t\t\t\t\t\t\t\t\tpreCalculatedPaths.put(targetNode.toStringCollision(scaleCollision) + \"-\" + startNode.toStringCollision(scaleCollision) ,reversePath);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tpathWasFound = true;\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse{\n\t\t\t\t\t\t\t\t\tpathWasFound = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//Remove nodes which we cannot find a path from\n\t\t\t\tif(!pathWasFound){\n\t\t\t\t\tremoveList.add(startNode);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t//Go through the remove list and remove unreachable nodes\n\t\tfor(Node node : removeList){\n\t\t\tfor(LinkedList<Node> startList : targets){\n\t\t\t\tstartList.remove(node);\n\t\t\t}\n\t\t}\n\t}", "void moveDisk(char fromRod, char toRod) {\n Rod fromThisRod = null;\n Rod toThisRod = null;\n for(int i = 0; i < listOfRods.size(); i++){\n if(listOfRods.get(i).getRodName() == fromRod)\n fromThisRod = listOfRods.get(i);\n else if((listOfRods.get(i).getRodName() == toRod))\n toThisRod = listOfRods.get(i);\n }\n try {\n toThisRod.addDisk(fromThisRod.removeTopMostDisk());\n }\n catch(NullPointerException rodIsNull){\n Display.displayWithNextLine(\"Rod you are trying to reach is null!\");\n }\n }", "public boolean moveable() {\n //check reach border\n if (reachBorder()) {\n return false;\n }\n //get the location of the next spot to move to\n //move up\n Point nextLocation = this.getCenterLocation();\n if (direction == 12) {\n nextLocation = new Point(this.getCenterX(),\n this.getCenterY() - speed);\n }\n //move right\n if (direction == 3) {\n nextLocation = new Point(this.getCenterX() + speed,\n this.getCenterY());\n\n }\n //move down\n if (direction == 6) {\n nextLocation = new Point(this.getCenterX(),\n this.getCenterY() + speed);\n\n }\n //move left\n if (direction == 9) {\n nextLocation = new Point(this.getCenterX() - speed,\n this.getCenterY());\n }\n\n // get all objects in a circle of radius tileSize * 2 around the players\n //these objects are those which can possibly colide with the players\n int checkRadius = GameUtility.GameUtility.TILE_SIZE * 2;\n for (GameObject gameObject : GameManager.getGameObjectList()) {\n if (GameUtility.GameUtility.distance(gameObject.getCenterLocation(),\n this.getCenterLocation()) < checkRadius) {\n if ((GameUtility.GameUtility.dectectCollision(\n gameObject.getCenterLocation(),\n nextLocation)) && !(GameUtility.GameUtility.dectectCollision(\n gameObject.getCenterLocation(),\n this.getCenterLocation())) && gameObject.getType() != GameObjectType.POWER_UP && gameObject.getType() != GameObjectType.MONSTER && gameObject.getType() != GameObjectType.PLAYER) {\n return false;\n }\n }\n }\n return true;\n\n }", "public static int clubSync(String club, Connection con) {\n\n\n boolean failed = false;\n boolean found = false;\n boolean changed = false;\n boolean skip = false;\n boolean clubcorp = false;\n\n\n //\n // Process each club\n //\n // Check for MFirst Rosters - must be named 'club.txt' in v_/rosters/mfirst (club = club name)\n //\n // Then check NorthStar Rosters - must be named 'club.csv' in /home/rosters/northstar (club = club name)\n //\n // Then check for CE files - must be named 'club.csv' in /home/rosters/ce\n //\n // Then check for Flexscape files - must be named 'club.csv' in /home/rosters/flexscape (manual upload)\n //\n // Then check for Dream World files - must be named 'club.csv' in /home/rosters/dreamworld\n //\n FileReader fr = null;\n File fileNS = null; // use file for NorthStar's csv files (no CR LF)\n FileInputStream fis = null;\n InputStreamReader isr = null;\n\n Connection con2 = null;\n ResultSet rs = null;\n\n try { // check CE on server\n\n fileNS = new File(\"//home//rosters//ce//\" +club+ \".csv\");\n\n fis = new FileInputStream(fileNS);\n\n isr = new InputStreamReader(fis);\n\n }\n catch (Exception e1) {\n\n failed = true;\n }\n\n //\n // if we found a CE file for this club - go process\n //\n if (failed == false) {\n\n ceSync(con, isr, club); // go process CE roster\n\n try {\n\n fis.close();\n\n }\n catch (Exception ignore) {\n }\n\n } else {\n\n failed = false;\n\n try { // check MFirst on server\n\n String clubname = club;\n\n if (clubname.equals(\"edina\")) {\n clubname = \"edina2010\";\n } else if (clubname.equals(\"quecheeclubtennis\")) {\n clubname = \"quecheeclub\";\n }\n\n fr = new FileReader(\"//home//rosters//mfirst//\" +clubname+ \".txt\");\n //fr = new FileReader(\"//home//rosters//mfirst//\" +club+ \".txt\"); changed to run off temp 'clubname' var instead of the actual 'club' var for use with customs\n\n }\n catch (Exception e1) {\n\n failed = true;\n }\n\n if (failed == true) {\n\n try {\n\n failed = false;\n\n con2 = dbConn.Connect(rev);\n\n // Check clubcorp table for name conversion\n PreparedStatement stmt = con2.prepareStatement(\"SELECT cc_name FROM clubcorp WHERE ft_name = ?\");\n\n stmt.clearParameters();\n stmt.setString(1, club);\n rs = stmt.executeQuery();\n\n if (rs.next()) {\n\n String ccClub = \"\";\n ccClub = rs.getString(\"cc_name\");\n clubcorp = true;\n\n try {\n fr = new FileReader(\"//home//rosters//mfirst//\" +ccClub+ \".txt\");\n } catch (Exception e2) {\n failed = true;\n }\n\n } else {\n\n failed = true; // club name not found\n }\n\n stmt.close();\n\n } catch (Exception exc) {\n\n failed = true;\n }\n }\n\n //\n // if we found a MFirst file for this club - go process\n //\n if (failed == false) {\n\n mFirstSync(con, fr, club, clubcorp); // go process MFirst roster\n\n } else {\n\n //\n // Check Jonas folder for a roster for this club\n //\n failed = true; //TEMP\n /*\n failed = false; // init\n\n try { // check NStar on server\n\n fileNS = new File(\"//home//rosters//jonas//\" +club+ \".csv\");\n\n fis = new FileInputStream(fileNS);\n\n isr = new InputStreamReader(fis);\n\n }\n catch (Exception e1) {\n\n failed = true;\n }\n */\n }\n\n //\n // if we found a Jonas file for this club - go process\n //\n if (failed == false) {\n\n //jonasSync(con, isr, club); // go process Jonas roster\n\n } else {\n\n //\n // Check NorthStar folder for a roster for this club\n //\n failed = false; // init\n\n try { // check NStar on server\n\n fileNS = new File(\"//home//rosters//northstar//\" +club+ \".csv\");\n\n fis = new FileInputStream(fileNS);\n\n isr = new InputStreamReader(fis);\n\n }\n catch (Exception e1) {\n\n failed = true;\n }\n\n\n //\n // if we found a NStar file for this club - go process\n //\n if (failed == false) {\n\n northstarSync(con, isr, club); // go process NStar roster\n\n try {\n\n fis.close();\n\n }\n catch (Exception ignore) {\n }\n\n } else {\n\n /* // no longer supported\n //\n // Check MeritSoft folder for a roster for this club\n //\n failed = false; // init\n\n try { // check MeritSoft on server\n\n fileNS = new File(\"//home//rosters//meritsoft//\" +club+ \".csv\");\n\n fis = new FileInputStream(fileNS);\n\n isr = new InputStreamReader(fis);\n\n }\n catch (Exception e1) {\n\n failed = true;\n }\n\n //\n // if we found a MeritSoft file for this club - go process\n //\n if (failed == false) {\n\n meritsoftSync(con, isr, club); // go process MeritSoft roster\n\n try {\n\n fis.close();\n\n }\n catch (Exception ignore) {\n }\n\n } else {\n */\n\n //\n // Check FlexScape folder for a roster for this club (added manually for now!!!)\n //\n failed = false; // init\n\n try { // check server\n\n fileNS = new File(\"//home//rosters//flexscape//\" +club+ \".csv\");\n\n fis = new FileInputStream(fileNS);\n\n isr = new InputStreamReader(fis);\n\n }\n catch (Exception e1) {\n\n failed = true;\n }\n\n //\n // if we found a FlexScape file for this club - go process\n //\n if (failed == false) {\n\n flexSync(con, isr, club); // go process FlexScape roster\n\n try {\n\n fis.close();\n\n }\n catch (Exception ignore) {\n }\n\n } else {\n\n //\n // Check Dream World folder for a roster for this club\n //\n failed = false; // init\n\n try { // check server\n\n fileNS = new File(\"//home//rosters//dreamworld//\" +club+ \".csv\");\n\n fis = new FileInputStream(fileNS);\n\n isr = new InputStreamReader(fis);\n\n }\n catch (Exception e1) {\n\n failed = true;\n }\n\n //\n // if we found a Dream WOrld file for this club - go process\n //\n if (failed == false) {\n\n dreamworldSync(con, isr, club); // go process Dream World roster\n\n try {\n\n fis.close();\n\n }\n catch (Exception ignore) {\n }\n \n } else { // end of Dream World\n\n //\n // Check ClubTec folder for a roster for this club\n //\n failed = false; // init\n\n try { // check server\n\n fileNS = new File(\"//home//rosters//clubtec//\" +club+ \".csv\");\n\n fis = new FileInputStream(fileNS);\n\n isr = new InputStreamReader(fis);\n\n }\n catch (Exception e1) {\n\n failed = true;\n }\n\n //\n // if we found a ClubTec file for this club - go process\n //\n if (failed == false) {\n\n clubTecSync(con, isr, club); // go process ClubTec roster\n\n try {\n\n fis.close();\n\n }\n catch (Exception ignore) {\n }\n } // end of ClubTec\n }\n } // end of IF Flexscape\n }\n// } // end of IF Meritsoft\n }\n } // end of IF file found for this club\n\n //\n // if we found a file for this club - make entry in email\n //\n if (failed == false) {\n\n //emailMsgAll = emailMsgAll + \"Roster Sync Processing Complete For Club = \" +club+ \".\\n\\n\";\n // File found\n return 1;\n } else {\n\n //emailMsgAll = emailMsgAll + \"Roster Sync File Not Found for Club = \" +club+ \".\\n\\n\";\n // file not found\n return 0;\n }\n\n }", "public int[][] Move(/*int []Start, int[]End, */Board B) {\r\n \tif(this.Status[1]=='X'||this.Position[0]<0||this.Position[1]<0) {\r\n \tSystem.out.println(\"This piece is eliminated, cannot move\");\r\n \treturn null;\t\r\n \t}\r\n \t/*\r\n \tif(this.Status[1]=='C'&&this.CMovesets==null) {\r\n \tSystem.out.println(\"This piece cannot save king in check, cannot move\");\r\n \treturn null;\t\r\n \t}\r\n \t*/\r\n \t/*\r\n \tif(Start==null||End==null) {\r\n \t\t\r\n \t\tSystem.out.println(\"Null Start or End Positions\");\r\n \t\t\r\n \t\treturn null;\r\n \t}\r\n \tif(Start.length!=2||End.length!=2) {\r\n \t\t\r\n \t\tSystem.out.println(\"Start or End Positions invalid size\");\r\n \t\t\r\n \t\treturn null;\r\n \t\t\r\n \t}\r\n \tif(Start[0]!=this.Position[0]||Start[1]!=this.Position[1]) {\r\n \t\tSystem.out.println(\"ERROR, Piece Not Synchronized with where it should be\");\r\n \t\tSystem.exit(-1);\r\n \t}\r\n \t*/\r\n \t\r\n \t///////////////////////////\r\n \tint [][]PathSeq = isAnyPath(/*Start,End,*/B);\r\n \t\r\n \tif(PathSeq==null) {\r\n \t\tSystem.out.println(\"No Path sequences possible for this piece\");\r\n \t//////////////////////////\r\n \t\t// IF PIECE IS KING, CHECK IF NO MOVES AVAILABLE to destroy enemy, \r\n \t\t//block enemy, or if king is only piece left, MOVE king, Then Checkmate!\r\n \t\r\n \t//////////////////////////\r\n \treturn null;\r\n \t}\r\n \t\r\n \t/*\r\n \tScanner reader = new Scanner(System.in);\r\n \tboolean ValidIn=false;\r\n \twhile(!ValidIn) {\r\n \t\tSystem.out.println(\"Enter Path seq to be taken\");\r\n \t\t\r\n \t\t\r\n \t}\r\n \t*/\r\n \treturn PathSeq;\r\n }", "private boolean processCurrFile(HashMap<String, Blob> currFile,\n Commit splitPt, Commit currCommit,\n Commit givenCommit) {\n for (String fileName: currFile.keySet()) {\n String contentInSp = splitPt.getFileContent(fileName);\n String contentInCur = currCommit.getFileContent(fileName);\n String contentInGiven = givenCommit.getFileContent(fileName);\n if (isInConflict(contentInCur, contentInGiven, contentInSp)) {\n generateConflict(fileName, contentInCur, contentInGiven);\n return true;\n }\n }\n return false;\n }", "private Player checkIfEatsRedPlayer(Player player)\n {\n int x_cord = getMidPoint(player.x_cordinate);//player.x_cordinate;\n int y_cord = getMidPoint(player.y_cordinate);//player.y_cordinate;\n int redx1 = getMidPoint(getRed_player1().x_cordinate);\n int redx2 = getMidPoint(getRed_player2().x_cordinate);\n int redx3 = getMidPoint(getRed_player3().x_cordinate);\n int redx4 = getMidPoint(getRed_player4().x_cordinate);\n int redy1 = getMidPoint(getRed_player1().y_cordinate);\n int redy2 = getMidPoint(getRed_player2().y_cordinate);\n int redy3 = getMidPoint(getRed_player3().y_cordinate);\n int redy4 = getMidPoint(getRed_player4().y_cordinate);\n if (collisionDetection(x_cord, y_cord, redx1, redy1) == 1)\n {\n return getRed_player1();\n }\n else if (collisionDetection(x_cord, y_cord, redx2, redy2) == 1)\n {\n return getRed_player2();\n }\n else if (collisionDetection(x_cord, y_cord, redx3, redy3) == 1)\n {\n return getRed_player3();\n }\n else if (collisionDetection(x_cord, y_cord, redx4, redy4) == 1)\n {\n return getRed_player4();\n }\n else\n {\n return null;\n }\n }", "private void run() throws IOException, InterruptedException {\n\n\t// Make connection and initialize streams\n\t// TODO - need to close this socket\n\tSocket socket = new Socket(SERVER_ADDRESS, PORT_ADDRESS); // set port\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// here\n\tin = new BufferedReader(new InputStreamReader(socket.getInputStream()));\n\tout = new PrintWriter(socket.getOutputStream(), true);\n\n\t// ******************* SET UP COMMUNICATION MODULE by Shay\n\t// *********************\n\t/* Your Group Info */\n\tGroup group = new Group(rovername, SERVER_ADDRESS, 53702, RoverDriveType.WALKER, RoverToolType.RADIATION_SENSOR,\n\t\t\tRoverToolType.CHEMICAL_SENSOR);\n\n\t/* Setup communication, only communicates with gatherers */\n\trocom = new RoverCommunication(group);\n\trocom.setGroupList(Group.getGatherers());\n\n\t// ******************************************************************\n\n\t// Gson gson = new GsonBuilder().setPrettyPrinting().create();\n\n\t// Process all messages from server, wait until server requests Rover ID\n\t// name\n\twhile (true) {\n\t\tString line = in.readLine();\n\t\tif (line.startsWith(\"SUBMITNAME\")) {\n\t\t\tout.println(rovername); // This sets the name of this instance\n\t\t\t\t\t\t\t\t\t// of a swarmBot for identifying the\n\t\t\t\t\t\t\t\t\t// thread to the server\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// ******** Rover logic *********\n\t// int cnt=0;\n\tString line = \"\";\n\n\tint counter = 0;\n\n\tboolean stuck = false; // just means it did not change locations between\n\t\t\t\t\t\t\t// requests,\n\t\t\t\t\t\t\t// could be velocity limit or obstruction etc.\n\tboolean blocked = false;\n\n\tCoord currentLoc = null;\n\tCoord previousLoc = null;\n\n\ttargetLocations[0] = new Coord(0, 0);\n\n\t// out.println(\"START_LOC\");\n\t// line = in.readLine();\n\t// if (line == null) {\n\t// System.out.println(\"ROVER_02 check connection to server\");\n\t// line = \"\";\n\t// }\n\t// if (line.startsWith(\"LOC\")) {\n\t// // loc = line.substring(4);\n\t// Coord Loc = extractLOC(line);\n\t// targetLocations[2] = new Coord(Loc.xpos, Loc.ypos);\n\t// }\n\n\tSystem.out.println(\"getting target loc\");\n\t\n\t out.println(\"TARGET_LOC\");\n\t line = in.readLine();\n\t System.out.println(\"line =\" + line);\n\t if (line == null) {\n\t System.out.println(\"ROVER_02 check connection to server\");\n\t line = \"\";\n\t }\n\t if (line.startsWith(\"TARGET_LOC\")) {\n\t // loc = line.substring(4);\n\t\t System.out.println(\"inside if\");\n\tSystem.out.println(line);\n\ttarget = extractLOC(line);\n//\t target = Loc;\n\t// target = new Coord(Loc.xpos,Loc.ypos);\n\t }\n//\t System.out.println(target.xpos + \" , \" + target.ypos);\n\n\t//target = new Coord(49, 49);\n\t// start Rover controller process\n\twhile (true) {\n\n\t\t// currently the requirements allow sensor calls to be made with no\n\t\t// simulated resource cost\n\n\t\t// **** location call ****\n\t\tout.println(\"LOC\");\n\t\tline = in.readLine();\n\t\tif (line == null) {\n\t\t\tSystem.out.println(\"ROVER_02 check connection to server\");\n\t\t\tline = \"\";\n\t\t}\n\t\tif (line.startsWith(\"LOC\")) {\n\t\t\t// loc = line.substring(4);\n\t\t\tcurrentLoc = extractLOC(line);\n\t\t}\n//\t\tSystem.out.println(\"ROVER_02 currentLoc at start: \" + currentLoc);\n\n\t\t// after getting location set previous equal current to be able to\n\t\t// check for stuckness and blocked later\n\t\tpreviousLoc = currentLoc;\n\n\t\t// **** get equipment listing ****\n\t\tArrayList<String> equipment = new ArrayList<String>();\n\t\tequipment = getEquipment();\n\t\t// System.out.println(\"ROVER_02 equipment list results drive \" +\n\t\t// equipment.get(0));\n//\t\tSystem.out.println(\"ROVER_02 equipment list results \" + equipment + \"\\n\");\n\n\t\t// ***** do a SCAN *****\n//\t\tSystem.out.println(\"ROVER_02 sending SCAN request\");\n\t\tthis.doScan();\n//\t\tSystem.out.println(\"debug\");\n\t\tscanMap.debugPrintMap();\n\n\t\t// MOVING\n\t\tSystem.out.println(\"moving\");\n\t\tMapTile[][] scanMapTiles = scanMap.getScanMap();\n\t//\tSystem.out.println(\"calling make a star\");\n\t\t\n\t//\tmakeAStarmove(scanMapTiles, currentLoc, target);\n\n\t//\tSystem.out.println(\"Astar done\");\n\n\t\tout.println(\"LOC\");\n\t\tline = in.readLine();\n\t\tif (line == null) {\n\t\t\t\t\t\t\tline = \"\";\n\t\t}\n\t\tif (line.startsWith(\"LOC\")) {\n\t\t\t// loc = line.substring(4);\n\t\t\tcurrentLoc = extractLOC(line);\n\t\t}\n\t\t\n\t\tif(currentLoc.equals(target))\n\t\t{\n\t\t\tout.println(\"START_LOC\");\n\t\t\t line = in.readLine();\n\t\t\t if (line == null) {\n\t\t\t System.out.println(\"ROVER_02 check connection to server\");\n\t\t\t line = \"\";\n\t\t\t }\n\t\t\t if (line.startsWith(\"START_LOC\")) {\n\t\t\t // loc = line.substring(4);\n\t\t\t Coord Loc = extractLOC(line);\n\t\t\t target = Loc;\n\t\t\t }\n\t\t\t continue;\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < 10; i++) {\n\t\t\tout.println(\"LOC\");\n\t\t\tline = in.readLine();\n\t\t\tif (line == null) {\n\t\t\t\t\t\t\t\tline = \"\";\n\t\t\t}\n\t\t\tif (line.startsWith(\"LOC\")) {\n\t\t\t\t// loc = line.substring(4);\n\t\t\t\tcurrentLoc = extractLOC(line);\n\t\t\t}\n\t\t\t//System.out.println(\"ROVER_02 currentLoc at start: \" + currentLoc);\n\t\t\tmake_a_move(scanMapTiles, currentLoc);\n\t\t}\n\n\t\t// test for stuckness\n\n\t\tSystem.out.println(\"ROVER_02 stuck test \" + stuck);\n\t\t// System.out.println(\"ROVER_02 blocked test \" + blocked);\n\n\t\t/* ********* Detect and Share Science by Shay ***************/\n\t\tdoScan();\n\t\trocom.detectAndShare(scanMap.getScanMap(), currentLoc, 3);\n\t\t/* *************************************************/\n\n\t\t// Thread.sleep(sleepTime);\n\n\t\t// System.out.println(\"ROVER_02 ------------ bottom process control\n\t\t// --------------\");\n\n\t}\n\n}", "public static boolean hasWinningMove(int[][] gamePlay){\n\t\tfor(int i=0;i<4;i++){\n\t\t\tfor(int j=0;j<4;j++){\n\t\t\t\tif(gamePlay[i][j]==1){\n\t\t\t\t\tfor(int k=1;k<9;k++){\n\t\t\t\t\t\tint[] root={i,j};\n\t\t\t\t\t\tint[] root1={i,j};\n\t\t\t\t\t\tint[] source=root;\n\t\t\t\t\t\tsource=calculatePosition(root,k);\n\t\t\t\t\t\t//System.out.println(\"Looking in direction \"+k+\" For root\"+i+\",\"+j);\n\t\t\t\t\t\tif(isValidLocation(source)){ \n\t\t\t\t\t\t\tif(gamePlay[source[0]][source[1]]==1){\n\t\t\t\t\t\t\t\tint[] newSource=calculatePosition(source,k);\n\t//System.out.println(\"Two contigous isValid:\"+isValidLocation(newSource)+\"newSource(\"+newSource[0]+\",\"+newSource[1]+\")\"+\" gamePlay:\"+(isValidLocation(newSource)?gamePlay[newSource[0]][newSource[1]]:-1));\n\t\t\t\t\t\t\t\tif(isValidLocation(newSource)){ \n\t\t\t\t\t\t\t\t\tif(gamePlay[newSource[0]][newSource[1]]==0){\n\t\t\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\t//System.out.println(\"Looking in opposite direction\");\n\t\t\t\t\t\t\t\t\t//Lookup in opposite direction\n\t\t\t\t\t\t\t\t\tnewSource=calculatePosition(root1,9-k);\n\t\t\t\t\t\t\t\t\tif(isValidLocation(newSource) && gamePlay[newSource[0]][newSource[1]]==1){\n\t\t\t\t\t\t\t\t\t\t//System.out.println(\"Valid Location:\"+newSource[0]+\" \"+newSource[1]+\" gamePlay\"+gamePlay[newSource[0]][newSource[1]]);\n\t\t\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t\t\t}\t\n\t\t\t\t\t\t\t\t}\t\t\n\t\t\t\t\t\t\t}else if(gamePlay[source[0]][source[1]]==0){\n\t\t\t\t\t\t\t\t\t//System.out.println(\"Looking for alternate\");\n\t\t\t\t\t\t\t\t\tsource=calculatePosition(source,k);\n\t\t\t\t\t\t\t\t\tif(isValidLocation(source) && gamePlay[source[0]][source[1]]==1){\n\t\t\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t//System.out.println(\"Invalid direction or no move here isValid:\"+isValidLocation(source)+\"Source(\"+source[0]+\",\"+source[1]+\")\"+\" gamePlay:\"+(isValidLocation(source)?gamePlay[source[0]][source[1]]:-1));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\t\t\n\t\t\t\t}\t\t\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}", "private boolean processGivenFile(HashMap<String, Blob> givenFile,\n Commit splitPt, Commit currCommit,\n Commit givenCommit) throws IOException {\n for (String fileName: givenFile.keySet()) {\n String contentInSp = splitPt.getFileContent(fileName);\n String contentInCur = currCommit.getFileContent(fileName);\n String contentInGiven = givenCommit.getFileContent(fileName);\n if (isInConflict(contentInCur, contentInGiven, contentInSp)) {\n generateConflict(fileName, contentInCur, contentInGiven);\n return true;\n } else if (bothNull(contentInCur, contentInGiven)\n || contentInGiven.equals(contentInCur)) {\n continue;\n }\n if (contentInSp != null && contentInSp.equals(contentInCur)\n && !contentInSp.equals(contentInGiven)) {\n commitIDCheckout(givenCommit.getShaCode(), fileName);\n File theNewFile = new File(Main.CWD, fileName);\n add(theNewFile);\n } else if (contentInCur == null && contentInSp == null) {\n commitIDCheckout(givenCommit.getShaCode(), fileName);\n File theNewFile = new File(Main.CWD, fileName);\n add(theNewFile);\n }\n }\n return false;\n }", "public void readFile() {\n ArrayList<Movement> onetime = new ArrayList<Movement>(); \n Movement newone = new Movement(); \n String readLine; \n\n File folder = new File(filefolder); \n File[] listOfFiles = folder.listFiles(); \n for (File file : listOfFiles) {\n if (file.isFile()&& file.getName().contains(\"200903\")) {\n try {\n onetime = new ArrayList<Movement>(); \n newone = new Movement(); \n BufferedReader br = new BufferedReader(new FileReader(filefolder+\"\\\\\"+file.getName())); \n readLine = br.readLine (); \n String[] previouline = readLine.split(\",\"); \n int previousint = Integer.parseInt(previouline[7]); \n while ( readLine != null) {\n String[] currentline = readLine.split(\",\"); \n if (Integer.parseInt(currentline[7]) == previousint)\n {\n newone.addRecord(currentline[0], currentline[1], currentline[2], currentline[4], currentline[5], currentline[6]); \n newone.ID = Integer.parseInt(currentline[7]); \n newone.filedate = file.getName();\n } else\n { \n onetime.add(newone); \n newone = new Movement(); \n newone.addRecord(currentline[0], currentline[1], currentline[2], currentline[4], currentline[5], currentline[6]);\n }\n previousint = Integer.parseInt(currentline[7]); \n readLine = br.readLine ();\n }\n }\n catch (IOException e) {\n e.printStackTrace();\n }\n rawdata.add(onetime);\n } \n }\n println(rawdata.size());\n}", "private void checkIfR2D2Found() throws Exception {\n\t\tint tortoiseLocationX = Tortoise.getX();\n\t\tint tortoiseLocationY = Tortoise.getY();\n\n\t\tif (tortoiseLocationX <= 510 && tortoiseLocationX >= 505 && tortoiseLocationY >= 110 && tortoiseLocationY <= 115)\n\t\t\tplayEureka();\n\t}", "public boolean canMove() {\n ArrayList<Location> valid = canMoveInit();\n if (valid == null || valid.isEmpty()) {\n return false;\n }\n ArrayList<Location> lastCross = crossLocation.peek();\n for (Location loc : valid) {\n Actor actor = (Actor) getGrid().get(loc);\n if (actor instanceof Rock && actor.getColor().equals(Color.RED)) {\n next = loc;\n isEnd = true;\n return false;\n }\n if (!lastCross.contains(loc)) {\n lastCross.add(loc);\n next = loc;\n ArrayList<Location> nextCross = new ArrayList<>();\n nextCross.add(next);\n nextCross.add(last);\n crossLocation.push(nextCross);\n return probabilityAdd();\n }\n }\n next = lastCross.get(1);\n crossLocation.pop();\n return probabilitySub();\n }", "private int nextNode(int rid) {\n if (!my_game.getMy_game().isRunning()) {\n return -1;\n }\n Robot robot = my_game.getRobots().get(rid);\n List<node_data> tmp = robots_paths.get(rid);\n if (tmp.isEmpty()) {\n fruits_status.remove(rid);\n synchronized (my_game.getFruits()) {\n if (my_game.getFruits().size() > 0) {\n Fruit fruit = findClosestFruit(robot);\n tmp = algo_g.shortestPath(robot.getSrc(),fruit.getEdge().getSrc());\n node_data dest = my_game.getGraph().getNode(fruit.getEdge().getDest());\n tmp.add(dest);\n robots_paths.put(robot.getId(),tmp);\n fruits_status.put(rid,fruit);\n }\n }\n }\n\n node_data n = tmp.get(0);\n tmp.remove(0);\n return n.getKey();\n\n\n// for (int i = 0; i < tmp.size(); i++) {\n// node_data n = tmp.get(i);\n// tmp.remove(i);\n// if (n.getKey() == robot.getSrc())\n// continue;\n// return n.getKey();\n// }\n// return -1;\n }", "private static boolean moveCloserToTarget() {\n Direction f = forward;\n int startingDistance = target.distanceSquaredTo(S.rc.getLocation());\n forward = S.rc.getLocation().directionTo(target);\n forward = forward.rotateLeft();\n for (int i = 0; i < 8; i++) {\n if (target.distanceSquaredTo(S.rc.getLocation().add(forward)) < startingDistance)\n if (moveForwardStrict())\n return true;\n forward = forward.rotateRight();\n }\n forward = f;\n return false;\n }", "public void updateRover()\n {\n //If reached the end of the simulation\n if(iFrame >= frames.size())\n {\n Rover.getRover().finished();\n }\n //If rover is attempting to go outside the level boundary\n else if (roverX + frames.get(iFrame).x >= MAX_COLUMNS //Too far right\n || roverX + frames.get(iFrame).x < 0 //Too far left\n || roverY + frames.get(iFrame).y >= MAX_ROWS //Too far down\n || roverY + frames.get(iFrame).y < 0) //Too far up\n {\n tilemap[roverX][roverY] = 5; //Draw warning to current position\n System.out.println(\"ERROR: Rover has lost connection to the sattelite!\");\n System.out.println(\" Where are you?!\");\n Rover.getRover().finished();\n }\n else\n { \n //Update tilemap\n //First, remove current rover position\n tilemap[roverX][roverY] = 0;\n \n //Move rover into new position (logic layer)\n roverX += frames.get(iFrame).x;\n roverY += frames.get(iFrame).y;\n \n //Check what exists on tile rover is moving into \n // If safe, move rover into new position (visual layer)\n switch(tilemap[roverX][roverY])\n {\n case 0: //Surface\n tilemap[roverX][roverY] = 1;\n break;\n case 1: //Rover - Safety, shouldn't happen\n tilemap[roverX][roverY] = 1;\n break;\n case 2: //Rock\n tilemap[roverX][roverY] = 5; //Draw warning\n System.out.println(\"CRASH DETECTED\");\n Rover.getRover().finished();\n break;\n case 3: //Mineral\n tilemap[roverX][roverY] = 5; //Draw warning\n System.out.println(\"CRASH DETECTED\");\n Rover.getRover().finished();\n break; \n case 4: //Target\n tilemap[roverX][roverY] = 1;\n System.out.println(\"REACHED TARGET!\");\n break;\n case 5: //Warning - Safety, shouldn't happen\n tilemap[roverX][roverY] = 5;\n System.out.println(\"CRASH DETECTED\");\n Rover.getRover().finished();\n break;\n default://Safety - shouldn't happen\n tilemap[roverX][roverY] = 1;\n break;\n }\n System.out.println(\"UPDATED: \" + roverX + \", \" + roverY); // DEBUG ONLY \n \n iFrame++; //inc framecounter\n } \n repaint(); //repaint level\n }", "@Override\n\tpublic boolean validMove(int xEnd, int yEnd, board b){\n\t\t//try to land one same color piece\n\t\tif(b.occupied(xEnd, yEnd)&&b.getPiece(xEnd, yEnd).getColor()==color){\n\t\t\treturn false;\n\t\t}\n\t\tif(v==0){\n\t\t\tif(!this.guard(xEnd, yEnd, b)){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t//normal move\n\t\tif((xEnd==x-1&&yEnd==y-1)||(xEnd==x-1&&yEnd==y)||(xEnd==x-1&&yEnd==y+1)||(xEnd==x&&yEnd==y-1)||(xEnd==x&&yEnd==y+1)||(xEnd==x+1&&yEnd==y-1)||(xEnd==x+1&&yEnd==y)||(xEnd==x+1&&yEnd==y+1)){\n\t\t\tif(b.occupied(xEnd, yEnd)){\n\t\t\t\t//set the enpass flage back\n\t\t\t\tb.setFlag(color, 100, 100);\n\t\t\t\tb.recycle(xEnd, yEnd);\n\t\t\t\tthis.setPosition(xEnd, yEnd);\n\t\t\t\tb.update();\n\t\t\t\tc=0;\n\t\t\t\treturn true;\n\t\t\t}else{\n\t\t\t\t//set the enpass flage back\n\t\t\t\tb.setFlag(color, 100, 100);\n\t\t\t\tthis.setPosition(xEnd, yEnd);\n\t\t\t\tb.update();\n\t\t\t\tc=0;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}else if((xEnd==x-2&&yEnd==y)){ //castling\n\t\t\tpiece r = b.getPiece(0, y);\n\t\t\tif(r==null){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif(r.getC()==0||r.getColor()!=color||r.getType()!= type.ROOK||c==0){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tfor(int i=3;i>0;i--){\n\t\t\t\tif(b.occupied(i, y)){\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.setPosition(xEnd, yEnd);\n\t\t\tr.setPosition(3,y);\n\t\t\tc=0;\n\t\t\tr.setC(0);\n\t\t\tb.setFlag(color, 100, 100);\n\t\t\tb.update();\n\t\t\treturn true;\n\t\t}else if((xEnd==x+2&&yEnd==y)){\n\t\t\tpiece r = b.getPiece(7, y);\n\t\t\tif(r==null){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif(r.getC()==0||r.getColor()!=color||r.getType()!= type.ROOK||c==0){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tfor(int i=5;i<=6;i++){\n\t\t\t\tif(b.occupied(i, y)){\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.setPosition(xEnd, yEnd);\n\t\t\tr.setPosition(5,y);\n\t\t\tc=0;\n\t\t\tr.setC(0);\n\t\t\tb.setFlag(color, 100, 100);\n\t\t\tb.update();\n\t\t\treturn true;\n\t\t}else{\n\t\t\treturn false;\n\t\t}\n\t}", "public boolean validRook (int startRow, int startColumn, int endRow, int endColumn, Tile[][] board) {\n\t\t\n\t\tint distanceMovedUpDown =endRow-startRow; \n\t\tint distanceMovedLeftRight = endColumn-startColumn;\n\n\t\tif (distanceMovedUpDown !=0 && distanceMovedLeftRight != 0) { //have to stay in the same column or row to be valid\n\t\t\treturn false;\n\t\t}\n\n\n\t\tif (startRow == endRow) { //moving left or right \n\t\t\tif (Math.abs(distanceMovedLeftRight) > 1) { //checking if there's pieces btwn start and end if moving more than 1\n\t\t\t\tif (distanceMovedLeftRight > 0) {//moving to the right \n\t\t\t\t\tint x=startColumn + 1;\n\t\t\t\t\twhile (x < endColumn) {\n\t\t\t\t\t\tif (board[startRow][x].getOccupyingPiece() != null) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tx++;\n\t\t\t\t\t}\t\n\t\t\t\t}\n\t\t\t\tif (distanceMovedLeftRight < 0) {//moving to the left\n\t\t\t\t\tint x = startColumn -1;\n\t\t\t\t\twhile (x > endColumn) {\n\t\t\t\t\t\tif (board[startRow][x].getOccupyingPiece() != null) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tx--;\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t\treturn true;\n\n\t\t}\n\t\tif (startColumn == endColumn) { //moving up or down\n\t\t\tif (Math.abs(distanceMovedUpDown) > 1) { //checking if there's pieces btwn start and end if moving more than 1\n\t\t\t\tif (distanceMovedUpDown > 0) {//moving up the array\n\t\t\t\t\tint x=startRow + 1;\n\t\t\t\t\twhile (x < endRow) {\n\t\t\t\t\t\tif (board[x][startColumn].getOccupyingPiece() != null) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tx++;\n\t\t\t\t\t}\t\n\t\t\t\t}\n\t\t\t\tif (distanceMovedUpDown < 0) {//moving down the array\n\t\t\t\t\tint x = startRow -1;\n\t\t\t\t\twhile (x > endRow) {\n\t\t\t\t\t\tif (board[x][startColumn].getOccupyingPiece() != null) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tx--;\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\n\t}", "public int checkCastle(Board b, char race) {\n Set<Coordinate> opponentPieces = (race == 'b') ? b.white : b.black;\n Set<Coordinate> opponentMoves = new HashSet<Coordinate>();\n\n for (Coordinate each : opponentPieces) {\n if (b.board[each.x][each.y] instanceof King) {\n continue;\n }\n if (b.board[each.x][each.y] instanceof Pawn) {\n opponentMoves.addAll(((Pawn) (b.board[each.x][each.y])).killableMoves(b));\n } else {\n opponentMoves.addAll(b.board[each.x][each.y].displayMoves(b));\n }\n }\n\n switch (race) {\n case 'b':\n if (b.board[0][4] != null && b.board[0][4].move == 0) {\n int i = 0;\n if (b.board[0][0] != null && b.board[0][0].move == 0) {\n if (b.board[0][1] == null && b.board[0][2] == null && b.board[0][3] == null) {\n if (!opponentMoves.contains(new Coordinate(0, 2)) && !opponentMoves.contains(new Coordinate(0, 3))\n && !opponentMoves.contains(new Coordinate(0, 4))) {\n i++;\n }\n }\n }\n\n if (b.board[0][7] != null && b.board[0][7].move == 0) {\n if (b.board[0][5] == null && b.board[0][6] == null) {\n if (!opponentMoves.contains(new Coordinate(0, 6)) && !opponentMoves.contains(new Coordinate(0, 5))\n && !opponentMoves.contains(new Coordinate(0, 4))) {\n i += 10;\n }\n }\n }\n return i;\n }\n break;\n\n case 'w':\n if (b.board[7][4] != null && b.board[7][4].move == 0) {\n int i = 20;\n if (b.board[7][0] != null && b.board[7][0].move == 0) {\n if (b.board[7][1] == null && b.board[7][2] == null && b.board[7][3] == null) {\n if (!opponentMoves.contains(new Coordinate(7, 2)) && !opponentMoves.contains(new Coordinate(7, 3))\n && !opponentMoves.contains(new Coordinate(7, 4))) {\n i++;\n }\n }\n }\n\n if (b.board[7][7] != null && b.board[7][7].move == 0) {\n if (b.board[7][5] == null && b.board[7][6] == null) {\n if (!opponentMoves.contains(new Coordinate(7, 6)) && !opponentMoves.contains(new Coordinate(7, 5))\n && !opponentMoves.contains(new Coordinate(7, 4))) {\n i += 10;\n }\n }\n }\n return i;\n }\n break;\n }\n return 69;\n }", "public synchronized boolean MoveThatFigure(Figures.Color color, Figures.Type typ, Point pozice, Point direction, ArrayList<ModelObject> objekty) {\n for (Object obj : objekty) {\r\n objectsForMovement.add((ModelObject) obj);\r\n }\r\n\r\n Point pomPozice = new Point(pozice);\r\n Point pomDirxM = new Point(direction);\r\n Point pomDiryM = new Point(direction);\r\n Point pomDirxP = new Point(direction);\r\n Point pomDiryP = new Point(direction);\r\n Point BeforeLast = new Point();\r\n\r\n pomDirxM.x = pomDirxM.x - 1;\r\n pomDiryM.y = pomDiryM.y - 1;\r\n pomDirxP.x = pomDirxP.x + 1;\r\n pomDiryP.y = pomDiryP.y + 1;\r\n\r\n if (color == Figures.Color.White) {\r\n if (typ == Figures.Type.Pawn) {\r\n if ((direction.x == pozice.x && direction.y == pozice.y - 1)\r\n && free.isFree(direction, objectsForMovement)) {\r\n side = false;\r\n return true;\r\n }\r\n if ((direction.x == pozice.x - 1 && direction.y == pozice.y - 1\r\n || direction.x == pozice.x + 1 && direction.y == pozice.y - 1)\r\n && !free.isFree(direction, objectsForMovement)) {\r\n side = false;\r\n this.pawnTaking = true;\r\n return true;\r\n }\r\n }\r\n\r\n if (typ == Figures.Type.Rook) {\r\n // if ((CanTake(direction, Figures.Color.Black)) || free.isFree(direction, objectsForMovement)) {\r\n if (pozice.equals(pomDirxM)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDirxP)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDiryM)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDiryP)) {\r\n side = false;\r\n return true;\r\n } else {\r\n do {\r\n if ((direction.x == pomPozice.x && direction.y >= pomPozice.y)) {\r\n pomPozice.y = pomPozice.y + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDiryM;\r\n } else if (direction.x == pomPozice.x && direction.y <= pomPozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDiryP;\r\n } else if (direction.x <= pomPozice.x && direction.y == pomPozice.y) {\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDirxP;\r\n } else if (direction.x >= pomPozice.x && direction.y == pomPozice.y) {\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDirxM;\r\n }\r\n if (mahmadan == false) {\r\n break;\r\n }\r\n\r\n } while ((pomPozice.x != BeforeLast.x) || (pomPozice.y != BeforeLast.y));\r\n if (mahmadan == true) {\r\n side = false;\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n }\r\n // }\r\n\r\n if (typ == Figures.Type.Knight) {\r\n // if ((CanTake(direction, Figures.Color.Black)) || free.isFree(direction, objectsForMovement)) {\r\n if ((direction.x == pozice.x + 2 && direction.y == pozice.y - 1)\r\n || (direction.x == pozice.x - 2 && direction.y == pozice.y - 1)\r\n || (direction.x == pozice.x - 2 && direction.y == pozice.y + 1)\r\n || (direction.x == pozice.x + 2 && direction.y == pozice.y + 1)\r\n || (direction.x == pozice.x + 1 && direction.y == pozice.y + 2)\r\n || (direction.x == pozice.x + 1 && direction.y == pozice.y - 2)\r\n || (direction.x == pozice.x - 1 && direction.y == pozice.y - 2)\r\n || (direction.x == pozice.x - 1 && direction.y == pozice.y + 2)) {\r\n side = false;\r\n return true;\r\n }\r\n }\r\n // }\r\n\r\n if (typ == Figures.Type.Bishop) {\r\n // if ((CanTake(direction, Figures.Color.Black)) || free.isFree(direction, objectsForMovement)) {\r\n if (Math.abs(pozice.x - direction.x) == Math.abs(pozice.y - direction.y)) {\r\n if (pozice.x == pomDirxM.x && pozice.y == pomDiryM.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDirxP.x && pozice.y == pomDiryP.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDiryM.x && pozice.y == pomDiryP.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDiryP.x && pozice.y == pomDiryM.y) {\r\n side = false;\r\n return true;\r\n } else {\r\n do {\r\n if (direction.x >= pozice.x && direction.y >= pozice.y) {\r\n pomPozice.y = pomPozice.y + 1;\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxM.x;\r\n BeforeLast.y = pomDiryM.y;\r\n } else if (direction.x <= pozice.x && direction.y >= pozice.y) {\r\n pomPozice.y = pomPozice.y + 1;\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxP.x;\r\n BeforeLast.y = pomDiryM.y;\r\n } else if (direction.x <= pozice.x && direction.y <= pozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxP.x;\r\n BeforeLast.y = pomDiryP.y;\r\n } else if (direction.x >= pozice.x && direction.y <= pozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxM.x;\r\n BeforeLast.y = pomDiryP.y;\r\n }\r\n if (mahmadan == false) {\r\n break;\r\n }\r\n } while ((pomPozice.x != BeforeLast.x) && (pomPozice.y != BeforeLast.y));\r\n if (mahmadan == true) {\r\n side = false;\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n // }\r\n\r\n if (typ == Figures.Type.Queen) {\r\n // if ((CanTake(direction, Figures.Color.Black)) || free.isFree(direction, objectsForMovement)) {\r\n if (pozice.equals(pomDirxM)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDirxP)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDiryM)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDiryP)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDirxM.x && pozice.y == pomDiryM.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDirxP.x && pozice.y == pomDiryP.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDiryM.x && pozice.y == pomDiryP.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDiryP.x && pozice.y == pomDiryM.y) {\r\n side = false;\r\n return true;\r\n } else {\r\n if (((direction.x >= pozice.x && direction.y >= pozice.y)\r\n || (direction.x <= pozice.x && direction.y >= pozice.y)\r\n || (direction.x <= pozice.x && direction.y <= pozice.y)\r\n || (direction.x >= pozice.x && direction.y <= pozice.y))\r\n && (Math.abs(pozice.x - direction.x) == Math.abs(pozice.y - direction.y))) {\r\n do {\r\n if (direction.x >= pozice.x && direction.y >= pozice.y) {\r\n pomPozice.y = pomPozice.y + 1;\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxM.x;\r\n BeforeLast.y = pomDiryM.y;\r\n } else if (direction.x <= pozice.x && direction.y >= pozice.y) {\r\n pomPozice.y = pomPozice.y + 1;\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxP.x;\r\n BeforeLast.y = pomDiryM.y;\r\n } else if (direction.x <= pozice.x && direction.y <= pozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxP.x;\r\n BeforeLast.y = pomDiryP.y;\r\n } else if (direction.x >= pozice.x && direction.y <= pozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxM.x;\r\n BeforeLast.y = pomDiryP.y;\r\n }\r\n if (mahmadan == false) {\r\n break;\r\n }\r\n } while ((pomPozice.x != BeforeLast.x) && (pomPozice.y != BeforeLast.y));\r\n if ((Math.abs(pozice.x - direction.x) == Math.abs(pozice.y - direction.y)) && mahmadan == true) {\r\n side = false;\r\n return true;\r\n }\r\n }\r\n if ((direction.x == pozice.x && direction.y >= pozice.y)\r\n || (direction.x == pozice.x && direction.y <= pozice.y)\r\n || (direction.x <= pozice.x && direction.y == pozice.y)\r\n || (direction.x >= pozice.x && direction.y == pozice.y)) {\r\n do {\r\n if ((direction.x == pomPozice.x && direction.y >= pomPozice.y)) {\r\n pomPozice.y = pomPozice.y + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDiryM;\r\n } else if (direction.x == pomPozice.x && direction.y <= pomPozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDiryP;\r\n } else if (direction.x <= pomPozice.x && direction.y == pomPozice.y) {\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDirxP;\r\n } else if (direction.x >= pomPozice.x && direction.y == pomPozice.y) {\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDirxM;\r\n }\r\n if (mahmadan == false) {\r\n break;\r\n }\r\n\r\n } while ((pomPozice.x != BeforeLast.x) || (pomPozice.y != BeforeLast.y));\r\n if (mahmadan == true) {\r\n side = false;\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n }\r\n }\r\n // }\r\n\r\n if (typ == Figures.Type.King) {\r\n // if ((CanTake(direction, Figures.Color.Black)) || free.isFree(direction, objectsForMovement)) {\r\n if (direction.x == pozice.x && direction.y == pozice.y - 1 || direction.x == pozice.x - 1 && direction.y == pozice.y - 1\r\n || direction.x == pozice.x && direction.y == pozice.y + 1 || direction.x == pozice.x - 1 && direction.y == pozice.y + 1\r\n || direction.x == pozice.x + 1 && direction.y == pozice.y || direction.x == pozice.x + 1 && direction.y == pozice.y - 1\r\n || direction.x == pozice.x - 1 && direction.y == pozice.y || direction.x == pozice.x + 1 && direction.y == pozice.y + 1) {\r\n side = false;\r\n return true;\r\n }\r\n }\r\n //}\r\n\r\n } else if (color == Figures.Color.Black) {/* && side == false*/\r\n\r\n if (typ == Figures.Type.Pawn) {\r\n if ((direction.x == pozice.x && direction.y == pozice.y + 1)\r\n && free.isFree(direction, objectsForMovement)) {\r\n side = true;\r\n return true;\r\n }\r\n if (CanTake(direction, Figures.Color.White)) {\r\n if ((direction.x == pozice.x - 1 && direction.y == pozice.y + 1\r\n || direction.x == pozice.x + 1 && direction.y == pozice.y + 1)\r\n && !free.isFree(direction, objectsForMovement)) {\r\n side = true;\r\n this.pawnTaking = true;\r\n return true;\r\n }\r\n }\r\n }\r\n if (typ == Figures.Type.Rook) {\r\n if ((CanTake(direction, Figures.Color.White)) || free.isFree(direction, objectsForMovement)) {\r\n if (pozice.equals(pomDirxM)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDirxP)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDiryM)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDiryP)) {\r\n side = false;\r\n return true;\r\n } else {\r\n do {\r\n if ((direction.x == pomPozice.x && direction.y >= pomPozice.y)) {\r\n pomPozice.y = pomPozice.y + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDiryM;\r\n } else if (direction.x == pomPozice.x && direction.y <= pomPozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDiryP;\r\n } else if (direction.x <= pomPozice.x && direction.y == pomPozice.y) {\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDirxP;\r\n } else if (direction.x >= pomPozice.x && direction.y == pomPozice.y) {\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDirxM;\r\n }\r\n if (mahmadan == false) {\r\n break;\r\n }\r\n\r\n } while ((pomPozice.x != BeforeLast.x) || (pomPozice.y != BeforeLast.y));\r\n if (mahmadan == true) {\r\n side = false;\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (typ == Figures.Type.Knight) {\r\n if ((CanTake(direction, Figures.Color.White)) || free.isFree(direction, objectsForMovement)) {\r\n if ((direction.x == pozice.x + 2 && direction.y == pozice.y - 1)\r\n || (direction.x == pozice.x - 2 && direction.y == pozice.y - 1)\r\n || (direction.x == pozice.x - 2 && direction.y == pozice.y + 1)\r\n || (direction.x == pozice.x + 2 && direction.y == pozice.y + 1)\r\n || (direction.x == pozice.x + 1 && direction.y == pozice.y + 2)\r\n || (direction.x == pozice.x + 1 && direction.y == pozice.y - 2)\r\n || (direction.x == pozice.x - 1 && direction.y == pozice.y - 2)\r\n || (direction.x == pozice.x - 1 && direction.y == pozice.y + 2)) {\r\n side = true;\r\n return true;\r\n }\r\n }\r\n }\r\n\r\n if (typ == Figures.Type.Bishop) {\r\n if (Math.abs(pozice.x - direction.x) == Math.abs(pozice.y - direction.y)) {\r\n if ((CanTake(direction, Figures.Color.White)) || free.isFree(direction, objectsForMovement)) {\r\n if (pozice.x == pomDirxM.x && pozice.y == pomDiryM.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDirxP.x && pozice.y == pomDiryP.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDiryM.x && pozice.y == pomDiryP.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDiryP.x && pozice.y == pomDiryM.y) {\r\n side = false;\r\n return true;\r\n } else {\r\n do {\r\n if (direction.x >= pozice.x && direction.y >= pozice.y) {\r\n pomPozice.y = pomPozice.y + 1;\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxM.x;\r\n BeforeLast.y = pomDiryM.y;\r\n } else if (direction.x <= pozice.x && direction.y >= pozice.y) {\r\n pomPozice.y = pomPozice.y + 1;\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxP.x;\r\n BeforeLast.y = pomDiryM.y;\r\n } else if (direction.x <= pozice.x && direction.y <= pozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxP.x;\r\n BeforeLast.y = pomDiryP.y;\r\n } else if (direction.x >= pozice.x && direction.y <= pozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxM.x;\r\n BeforeLast.y = pomDiryP.y;\r\n }\r\n if (mahmadan == false) {\r\n break;\r\n }\r\n } while ((pomPozice.x != BeforeLast.x) && (pomPozice.y != BeforeLast.y));\r\n if ((Math.abs(pozice.x - direction.x) == Math.abs(pozice.y - direction.y)) && mahmadan == true) {\r\n side = false;\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (typ == Figures.Type.Queen) {\r\n if ((CanTake(direction, Figures.Color.White)) || free.isFree(direction, objectsForMovement)) {\r\n if (pozice.equals(pomDirxM)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDirxP)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDiryM)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.equals(pomDiryP)) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDirxM.x && pozice.y == pomDiryM.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDirxP.x && pozice.y == pomDiryP.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDiryM.x && pozice.y == pomDiryP.y) {\r\n side = false;\r\n return true;\r\n }\r\n if (pozice.x == pomDiryP.x && pozice.y == pomDiryM.y) {\r\n side = false;\r\n return true;\r\n } else {\r\n if (((direction.x >= pozice.x && direction.y >= pozice.y)\r\n || (direction.x <= pozice.x && direction.y >= pozice.y)\r\n || (direction.x <= pozice.x && direction.y <= pozice.y)\r\n || (direction.x >= pozice.x && direction.y <= pozice.y))\r\n && (Math.abs(pozice.x - direction.x) == Math.abs(pozice.y - direction.y))) {\r\n do {\r\n if (direction.x >= pozice.x && direction.y >= pozice.y) {\r\n pomPozice.y = pomPozice.y + 1;\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxM.x;\r\n BeforeLast.y = pomDiryM.y;\r\n } else if (direction.x <= pozice.x && direction.y >= pozice.y) {\r\n pomPozice.y = pomPozice.y + 1;\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxP.x;\r\n BeforeLast.y = pomDiryM.y;\r\n } else if (direction.x <= pozice.x && direction.y <= pozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxP.x;\r\n BeforeLast.y = pomDiryP.y;\r\n } else if (direction.x >= pozice.x && direction.y <= pozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast.x = pomDirxM.x;\r\n BeforeLast.y = pomDiryP.y;\r\n }\r\n if (mahmadan == false) {\r\n break;\r\n }\r\n } while ((pomPozice.x != BeforeLast.x) && (pomPozice.y != BeforeLast.y));\r\n if ((Math.abs(pozice.x - direction.x) == Math.abs(pozice.y - direction.y)) && mahmadan == true) {\r\n side = false;\r\n return true;\r\n }\r\n }\r\n if ((direction.x == pozice.x && direction.y >= pozice.y)\r\n || (direction.x == pozice.x && direction.y <= pozice.y)\r\n || (direction.x <= pozice.x && direction.y == pozice.y)\r\n || (direction.x >= pozice.x && direction.y == pozice.y)) {\r\n do {\r\n if ((direction.x == pomPozice.x && direction.y >= pomPozice.y)) {\r\n pomPozice.y = pomPozice.y + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDiryM;\r\n } else if (direction.x == pomPozice.x && direction.y <= pomPozice.y) {\r\n pomPozice.y = pomPozice.y - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDiryP;\r\n } else if (direction.x <= pomPozice.x && direction.y == pomPozice.y) {\r\n pomPozice.x = pomPozice.x - 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDirxP;\r\n } else if (direction.x >= pomPozice.x && direction.y == pomPozice.y) {\r\n pomPozice.x = pomPozice.x + 1;\r\n mahmadan = free.isWayClear(pomPozice, objectsForMovement);\r\n BeforeLast = pomDirxM;\r\n }\r\n if (mahmadan == false) {\r\n break;\r\n }\r\n\r\n } while ((pomPozice.x != BeforeLast.x) || (pomPozice.y != BeforeLast.y));\r\n if (mahmadan == true) {\r\n side = false;\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (typ == Figures.Type.King) {\r\n if ((CanTake(direction, Figures.Color.White)) || free.isFree(direction, objectsForMovement)) {\r\n if (direction.x == pozice.x && direction.y == pozice.y - 1\r\n || direction.x == pozice.x - 1 && direction.y == pozice.y - 1\r\n || direction.x == pozice.x && direction.y == pozice.y + 1\r\n || direction.x == pozice.x - 1 && direction.y == pozice.y + 1\r\n || direction.x == pozice.x + 1 && direction.y == pozice.y\r\n || direction.x == pozice.x + 1 && direction.y == pozice.y - 1\r\n || direction.x == pozice.x - 1 && direction.y == pozice.y\r\n || direction.x == pozice.x + 1 && direction.y == pozice.y + 1) {\r\n side = true;\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n return false;\r\n }", "private void seekBy() {\n Queue<File> queue = new LinkedList<>();\n queue.offer(new File(root));\n while (!queue.isEmpty()) {\n File file = queue.poll();\n File[] list = file.listFiles();\n if (file.isDirectory() && list != null) {\n for (File tempFile : list) {\n queue.offer(tempFile);\n }\n } else {\n if (args.isFullMatch() && searchingFile.equalsIgnoreCase(file.getName())) {\n result.add(file);\n }\n if (args.isMask() && searchingFile.replaceAll(\"\\\\*\", \".*\").equalsIgnoreCase(file.getName())) {\n result.add(file);\n }\n if (args.isRegex() && file.getName().matches(args.getName())) {\n result.add(file);\n }\n }\n }\n this.writeLog(output, result);\n }", "private boolean tryPollingTheToMarkQueue(final boolean flush, final ReadEndsForMateCigar current) {\n boolean performedChunkAndMarkTheDuplicates = false;\n\n if (!flush && null == current) throw new PicardException(\"Flush cannot be false and current be null\");\n\n if (toMarkQueue.isEmpty()) return false;\n\n if (!toMarkQueue.isEmpty() && outputBuffer.isEmpty()) {\n throw new PicardException(\"0 < toMarkQueue && outputBuffer.isEmpty()\");\n }\n\n /**\n * Try to poll the toMarkQueue. If we are flushing all the records from it, just do so until empty. Otherwise, we need to\n * make sure we only poll those a certain distance away from current.\n */\n while (!toMarkQueue.isEmpty() &&\n (flush || referenceIndex != current.read1ReferenceIndex ||\n toMarkQueue.getToMarkQueueMinimumDistance() < current.read1Coordinate - toMarkQueue.peek().read1Coordinate)) {\n\n // Poll will track that this samRecordWithOrdinal has been through duplicate marking. It is not marked as a duplicate :)\n final ReadEndsForMateCigar next = toMarkQueue.poll(outputBuffer, header, opticalDuplicateFinder, libraryIdGenerator); // get the first one!\n performedChunkAndMarkTheDuplicates = true;\n\n // track optical duplicates using only those reads that are the first end...\n if (toMarkQueue.shouldBeInLocations(next) && next.getRecord().getFirstOfPairFlag()) {\n final Set<ReadEnds> locations = toMarkQueue.getLocations(next);\n\n if (!locations.isEmpty()) {\n AbstractMarkDuplicatesCommandLineProgram.trackOpticalDuplicates(new ArrayList<ReadEnds>(locations), null,\n opticalDuplicateFinder, libraryIdGenerator);\n }\n }\n // NB: we could try to greedily return a record if one is available here. Instead we continue processing the mark queue */\n }\n return performedChunkAndMarkTheDuplicates;\n }", "public boolean moveRIGHT() {\r\n\t\tint i,j,k;\r\n\t\tboolean flag = false;\r\n\t\t\r\n\t\tfor(i = (rows_size-1) ; i >= 0 ; i--) {\r\n\t\t\tfor( j = (columns_size-1); j >= 0 ; j--) {\r\n\t\t\t\tif( !isEmpty(i,j) ) {\r\n\t\t\t\t\tfor(k = j; k < columns_size && isEmpty(i,k+1); k++);\r\n\t\t\t\t\t\tif(k == (columns_size-1)) {\t\t\t\t\t\r\n\t\t\t\t\t\t\tif(k != j) {\r\n\t\t\t\t\t\t\tgame[i][k] = new Cell2048(game[i][j]);\r\n\t\t\t\t\t\t\tgame[i][j].setValue(0);\r\n\t\t\t\t\t\t\tflag = true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse {\r\n\t\t\t\t\t\t\tif(game[i][j].isEqual(game[i][k+1]) && game[i][k+1].getFlag() == false) {\r\n\t\t\t\t\t\t\t\tgame[i][k+1].setValue(game[i][k+1].getValue()*2);\r\n\t\t\t\t\t\t\t\tgame[i][k+1].setFlag(true);\r\n\t\t\t\t\t\t\t\tgame[i][j].setValue(0);\r\n\t\t\t\t\t\t\t\tscore += game[i][k+1].getValue();\r\n\t\t\t\t\t\t\t\t--takenCells;\r\n\t\t\t\t\t\t\t\t++freeCells;\r\n\t\t\t\t\t\t\t\tflag = true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\telse {\r\n\t\t\t\t\t\t\t\tif(k != j) {\r\n\t\t\t\t\t\t\t\tgame[i][k] = new Cell2048(game[i][j]);\r\n\t\t\t\t\t\t\t\tgame[i][j].setValue(0);\r\n\t\t\t\t\t\t\t\tflag = true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\tFalseFlag();\t\r\n\treturn flag;\r\n\t}", "@Override\n\tpublic boolean drive2Exit() throws Exception {\n\t\tint[][] timesVisited = new int[width][height];\n\t\tfor (int i = 0; i < timesVisited.length; i++) {\n\t\t\tfor (int j = 0; j < timesVisited[0].length; j++) {\n\t\t\t\ttimesVisited[i][j] = 0;\n\t\t\t}\n\t\t}\n\t\t\n\t\twhile (robot.isAtExit() == false) {\n\t\t\t/* start a list of potential positions to move to. */\n\t\t\tLinkedList<CardinalDirectionNumVisitsPair> possibleDirections = new LinkedList<CardinalDirectionNumVisitsPair>();\n\t\t\t\n\t\t\t/* get the directions and number of visits to all accessible adjacent spaces. */\n\t\t\tint robotX = robot.getCurrentPosition()[0];\n\t\t\tint robotY = robot.getCurrentPosition()[1];\n\t\t\taddCardinalDirectionNumVisitsPairIfValid(robotX + 1, robotY, CardinalDirection.East, possibleDirections, timesVisited);\n\t\t\taddCardinalDirectionNumVisitsPairIfValid(robotX - 1, robotY, CardinalDirection.West, possibleDirections, timesVisited);\n\t\t\taddCardinalDirectionNumVisitsPairIfValid(robotX, robotY + 1, CardinalDirection.North, possibleDirections, timesVisited);\n\t\t\taddCardinalDirectionNumVisitsPairIfValid(robotX, robotY - 1, CardinalDirection.South, possibleDirections, timesVisited);\n\t\t\t\n\t\t\t/* find the minimum number of visits. */\n\t\t\tint minVisits = Integer.MAX_VALUE;\n\t\t\tfor (CardinalDirectionNumVisitsPair pair : possibleDirections) {\n\t\t\t\tif (pair.numVisits < minVisits) {\n\t\t\t\t\tminVisits = pair.numVisits;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t/* remove all pairs that do NOT have minVisits visits from the list. */\n\t\t\tfor (Iterator<CardinalDirectionNumVisitsPair> iterator = possibleDirections.listIterator(); iterator.hasNext(); ) {\n\t\t\t CardinalDirectionNumVisitsPair pair = iterator.next();\n\t\t\t if (pair.numVisits != minVisits) {\n\t\t\t iterator.remove();\n\t\t\t }\n\t\t\t}\n\t\t\t\n\t\t\t/* the list now contains only spaces that have the minimum number of visits. */\n\t\t\t/* pick randomly from the list. */\n\t\t\tint randomIndex = (int) Math.floor(Math.random() * possibleDirections.size());\n\t\t\tCardinalDirectionNumVisitsPair randomPair = possibleDirections.get(randomIndex);\n\t\t\t\n\t\t\t/* turn to face that direction. */\n\t\t\trobot.turnToDirection(randomPair.cardinalDirection);\n\t\t\t\n\t\t\t/* move. */\n\t\t\trobot.move(1, false);\n\t\t\t\n\t\t\t/* update the numVisits array. */\n\t\t\ttimesVisited[robot.getCurrentPosition()[0]][robot.getCurrentPosition()[1]]++;\n\t\t}\n\t\t\n\t\treturn robot.stepOutOfExit();\n\t}", "public void findTrack() {\n for (Node n : start_node.getLinks()) {\n precedenti.put(n, start_node);\n valori.put(n, calculator.calcDistance(n, start_node));\n }\n while (!da_collegare.isEmpty()) {\n Node piu_vicino = null;\n double min = Double.MAX_VALUE;\n for (Node n : da_collegare) {\n double dist = valori.get(n);\n if (dist - min < THRESHOLD) {\n min = dist;\n piu_vicino = n;\n }\n }\n double dist = valori.get(piu_vicino);\n for (Node n : piu_vicino.getLinks()) {\n double ricalc = dist + calculator.calcDistance(n, piu_vicino);\n if (ricalc - valori.get(n) < THRESHOLD) {\n precedenti.put(n, piu_vicino);\n valori.put(n, ricalc);\n }\n }\n da_collegare.remove(piu_vicino);\n }\n }", "private boolean tieUpLooseEnds(){\n int length = looseEnds.size();\n if(length > 0){\n\n //Loop through all the loose ends and upload them. Start at the oldest and work to the latest\n for(int i=0; i<length; i++){\n Location l = looseEnds.elementAt(length-i-1);\n uploadLocation(l);\n }\n //Empty all the loose ends\n looseEnds.removeAllElements();\n\n if(toast)\n Toast.makeText(this, String.format(getString(R.string.toast_loose_ends), length), Toast.LENGTH_SHORT).show();\n }\n\n return true;\n }", "private boolean isOnTheWay(AStarNode start, AStarNode end, Obstacle obs){\n\t/*Making sure whether obstacle even has a chance to be on the way*/\n\tdouble x_left_bound = Math.min(start.getX(), end.getX()) - obs.getRadius() - CLEARANCE;\n\tdouble x_right_bound = Math.max(start.getX(), end.getY()) + obs.getRadius() + CLEARANCE;\n\tdouble y_top_bound = Math.min(start.getY(), end.getY()) - obs.getRadius() - CLEARANCE;\n\tdouble y_bottom_bound = Math.max(start.getY(), end.getY()) + obs.getRadius() + CLEARANCE;\n\t\n\t/*If it is not within the range we should worry about, return false*/\n\tif(obs.getX() < x_left_bound || obs.getX() > x_right_bound || obs.getY() < y_top_bound || obs.getY() > y_bottom_bound){\n\t return false;\n\t}\n\t\n\t/*Angle between the tangent line of clearance range that intersects start node position and the line between start node and center of Obstacle*/\n double theta = Math.atan((CLEARANCE / 2 + obs.getRadius()) / Math.abs(start.getDistTo(obs)));\n\t\n\t/*Absolute angle positions of two tangent lines of clearance ranges that intersects start position*/\n double leftBound = start.getHeadingTo(obs) - theta;\n double rightBound = start.getHeadingTo(obs) + theta;\n\n if (rightBound > Math.PI * 2) rightBound = rightBound - 2 * Math.PI; // In case the angle bounds\n if (leftBound < 0) leftBound = leftBound + 2 * Math.PI; // exceed the angle range\n\n double angle = start.getHeadingTo(end); // absolute angle position of end node relative to the start node\n\n if (leftBound < rightBound) { // Normal case\n if (angle > leftBound && angle < rightBound) return true;\n else return false;\n } else { // Special case, when either leftBound or rightBound value exceeded angle range\n if (angle > rightBound && angle < leftBound) return false;\n else return true;\n }\n\n }", "@Override\n public boolean equals(Object obj) {\n if (!(obj instanceof XiangqiCoordinate)) return false;\n XiangqiCoordinate coordinate = (XiangqiCoordinate) obj;\n return coordinate.getRank() == rank && coordinate.getFile() == file;\n }", "public boolean doWeHaveSameStops(String corridorA, String corridorB);", "private void computeNextRound(int roundNumber) {\n\t\tList<ChesspairingGame> games = new ArrayList<>();\n\t\tthis.generatedRound = new ChesspairingRound();\n\t\tthis.generatedRound.setGames(games);\n\t\tthis.generatedRound.setRoundNumber(roundNumber);\n\n\t\tthis.currentDownfloaters = new HashMap<>();\n\n\t\t/**\n\t\t * start the iteration over groups in the descending order. In order to\n\t\t * avoid thread weird behaviour because the group keys wee copy the keys\n\t\t * before wee iterate\n\t\t */\n\t\tList<Double> copyGroupKeys = new ArrayList<>(orderedGroupKeys);\n\n\t\t// while no need to downfloat then keep downfloating\n\t\tboolean someoneWasDownfloated = true;\n\t\twhile (someoneWasDownfloated) {\n\t\t\tsomeoneWasDownfloated = false;\n\t\t\tfor (Double groupKey : copyGroupKeys) {\n\t\t\t\tMap<String, ChesspairingPlayer> group = groupsByResult.get(groupKey);\n\t\t\t\tint size = group.size();\n\t\t\t\t// if modulo 2 != 0 then find a downfloater\n\t\t\t\tif ((size % 2) != 0) {\n\t\t\t\t\tsomeoneWasDownfloated = true;\n\t\t\t\t\tdownfloatSomeoneInGroup(groupKey);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (Double groupKey : copyGroupKeys) {\n\t\t\t/**\n\t\t\t * check to make sure the group still exists\n\t\t\t * this is related to bug 02\n\t\t\t */\n\t\t\tif (this.groupsByResult.get(groupKey)== null){\n\t\t\t\t//just move on\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\n\t\t\tboolean paringOK = pareGroup(groupKey, roundNumber);\n\t\t\tif (!paringOK) {\n\n\t\t\t\t/*\n\t\t\t\t * downfloat all players from group and then start again all\n\t\t\t\t * parings. Note for the future: you should see if you have\n\t\t\t\t * players that can be pared and then downfloat only those that\n\t\t\t\t * can not be pared. For the moment downfloating all will do.\n\t\t\t\t */\n\t\t\t\t// if this is the last group then join with the previous group\n\t\t\t\tif (copyGroupKeys.size() == 1) {\n\t\t\t\t\tthrow new IllegalStateException(\"What should I do when I only have one group?\");\n\t\t\t\t}\n\t\t\t\tDouble sourceGroup = -1.0;\n\t\t\t\tDouble destGroup = -1.0;\n\t\t\t\t// if this is the last index then join with the previous index\n\t\t\t\tif (copyGroupKeys.indexOf(groupKey) == copyGroupKeys.size() - 1) {\n\t\t\t\t\tint indexSource = copyGroupKeys.indexOf(groupKey);\n\t\t\t\t\tint indexDestination = indexSource - 1;\n\t\t\t\t\tsourceGroup = orderedGroupKeys.get(indexSource);\n\t\t\t\t\tdestGroup = orderedGroupKeys.get(indexDestination);\n\t\t\t\t} else {\n\t\t\t\t\tint indexSource = copyGroupKeys.indexOf(groupKey);\n\t\t\t\t\tint indexDestination = indexSource + 1;\n\t\t\t\t\tsourceGroup = orderedGroupKeys.get(indexSource);\n\t\t\t\t\tdestGroup = orderedGroupKeys.get(indexDestination);\n\t\t\t\t}\n\t\t\t\tjoinGroups(sourceGroup, destGroup);\n\t\t\t\t// and start again\n\t\t\t\tcomputeNextRound(roundNumber);\n\t\t\t}\n\t\t}\n\t}", "protected MoveToTask searchAccessPoint(final Point start, final Point target, final Goblin goblin) {\n\t\tObjects.requireNonNull(start, \"start must not be null!\");\n\t\tObjects.requireNonNull(target, \"target must not be null!\");\n\t\tObjects.requireNonNull(goblin, \"goblin must not be null!\");\n\n\t\tfor (Point neighbour : target.getNeighbours()) {\n\t\t\tif (goblin.getAI().getBlockadeMap().isBlocked(neighbour)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tMoveToTask path = new MoveToTask(start, neighbour, goblin, goblin.getAI().getBlockadeMap());\n\n\t\t\tif (path.hasPath()) {\n\t\t\t\treturn path;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}", "private StatusEnum stepInternal()\n {\n if (initialStep)\n {\n this.tail = map.getStart();\n this.openSet.push(map.getStart());\n initialStep = false;\n }\n\n if (status != StatusEnum.RUNNING)\n return status;\n\n cursor = openSet.pop(); // Pull the cursor off the open set min-heap\n if (cursor == null)\n {\n // The open set was empty, so although we have not reached the goal, there are no more points to investigate\n return StatusEnum.COMPLETED_NOT_FOUND;\n }\n\n while (closedSet.contains(cursor) || !map.isTraversable(cursor))\n {\n // The cursor is in the closed set (meaning it was already investigated) or the cursor point is non traversable on the map\n cursor = openSet.pop();\n if (cursor == null)\n {\n return StatusEnum.COMPLETED_NOT_FOUND;\n }\n }\n\n // The goal has been reached, the path is complete\n if (cursor.equals(map.getGoal()))\n {\n tail = cursor; // Set the member tail to be used in the reconstruction done in getPath()\n return StatusEnum.COMPLETED_FOUND;\n }\n\n // Add the cursor point to the closed set\n closedSet.add(cursor);\n\n // Get the list of neighboring points\n List<WeightedPoint> neighbors = neighborSelector.getNeighbors(map, cursor, heuristic);\n\n // Link the neighbors to the cursor (for backtracking the path when the goal is reached) and calculate their weight\n for (WeightedPoint wp : neighbors)\n {\n if (map.isTraversable(wp.getRow(), wp.getCol()) && !closedSet.contains(wp))\n {\n wp.setFromCost(cursor.getFromCost() + heuristic.distance(cursor, wp));\n\n if (dijkstra)\n {\n wp.setToCost(0);\n }\n else\n {\n wp.setToCost(heuristic.distance(wp, map.getGoal()));\n }\n wp.setPrev(cursor);\n }\n }\n\n if (shuffle)\n {\n // Shuffle the neighbors to randomize the order of testing nodes with the same cost value\n Collections.shuffle( neighbors );\n }\n Collections.sort( neighbors );\n\n // Put the neighbors on the open set\n for (WeightedPoint wp : neighbors)\n {\n if (!openSet.contains(wp))\n openSet.push(wp);\n }\n\n return StatusEnum.RUNNING;\n }", "public static int[] getPawnStart(int[][] piecePos, char color, int endFile,\n int endRank, boolean capture) {\n if (capture) {\n // En Passant\n int direction = color == 'w' ? 1 : -1;\n\n if (getBoardStateSquare(endFile, endRank).equals(\" \")) {\n for (int[] pos: piecePos) {\n if (endRank == pos[1] + direction) {\n int[] startPos = {pos[0], pos[1]};\n move(\" \", endFile, endRank, endFile, pos[1]);\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n }\n\n }\n\n for (int[] pos: piecePos) {\n if (endRank == pos[1] + direction) {\n int[] startPos = {pos[0], pos[1]};\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n }\n }\n\n for (int[] pos: piecePos) {\n if (pos[0] == endFile) {\n int direction = color == 'w' ? 1 : -1;\n\n if (pos[1] + direction == endRank) {\n int[] startPos = {pos[0], pos[1]};\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n\n if (pos[1] + 2 * direction == endRank) {\n boolean correct = true;\n\n for (int r = 0; r < Math.abs(pos[1] - endRank) - 1; r++) {\n if (!getBoardStateSquare(endFile,\n Math.abs(r + direction * pos[1] + 1))\n .equals(\" \")) {\n correct = false;\n\n break;\n }\n }\n\n if (correct) {\n int[] startPos = {pos[0], pos[1]};\n\n if (isLegalMove(startPos, endFile, endRank)) {\n return startPos;\n }\n }\n }\n }\n }\n\n return null;\n }", "private boolean read(Graphics2D graphics2D) {\r\n\t\tList list = new ArrayList();\r\n\r\n\t\tfor ( int i = 0; i < _sub_directory_names.length; ++i) {\r\n\t\t\tFile file = new File( _headerObject._directory, _sub_directory_names[ i]);\r\n\t\t\tif ( null != file) {\r\n\t\t\t\tFile[] files = file.listFiles();\r\n\t\t\t\tif ( null != files) {\r\n\t\t\t\t\tfor ( int j = 0; j < files.length; ++j) {\r\n\t\t\t\t\t\tif ( !files[ j].isFile() || !files[ j].canRead())\r\n\t\t\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\t\t\tFileObject fileObject = new FileObject( _sub_directory_names[ i], files[ j]);\r\n\t\t\t\t\t\tif ( !fileObject.read( list, graphics2D))\r\n\t\t\t\t\t\t\treturn false;\r\n\r\n\t\t\t\t\t\tif ( fileObject._type.equals( \"agents\") && fileObject._name.equals( \"$Spot\"))\r\n\t\t\t\t\t\t\t_headerObject._max = fileObject._max;\r\n\r\n\t\t\t\t\t\t_headerObject._fileObjectMap.put( _sub_directory_names[ i] + \"/\" + files[ j].getName(), fileObject);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif ( list.isEmpty())\r\n\t\t\t_steps = new String[] { \"\"};\r\n\t\telse {\r\n\t\t\tString[] temporary_steps = ( String[])list.toArray( new String[ 0]);\r\n\t\t\tArrays.sort( temporary_steps, new TimeComparator());\r\n\t\t\t_steps = new String[ temporary_steps.length + 1];\r\n\t\t\t_steps[ 0] = \"\";\r\n\t\t\tSystem.arraycopy( temporary_steps, 0, _steps, 1, temporary_steps.length);\r\n\t\t}\r\n\r\n\t\t_headerObject.set_last_time( _steps[ _steps.length - 1]);\r\n//\t\t_headerObject._last = _steps[ _steps.length - 1];\r\n\r\n\t\treturn true;\r\n\t}", "public static boolean moveking() //returns false if valid move is there\n{ System.out.println(\"IN FUNCTION MOVE KING.....\");\n flag=0;\n int kx,ky;\n if(q==2)\n {\n kx=p2.ka.kbx; //WHITE KING....\n ky=p2.ka.kby;\n } \nelse\n {\n kx=p1.ka.kax; //BLACK KING....\n\tky=p1.ka.kay;\n }\n//CHECKS WHETHER KING CAN MOVE TO THE 8 adjacent places...\n if(kx-1>=0)\n {\n move2(kx,ky,kx-1,ky);\n \n if(flag==1)\n {\n revert(kx,ky,kx-1,ky);\n return false;\n }\n }\n //r\n if(kx+1<=7)\n { move2(kx,ky,kx+1,ky);\n if(flag==1)\n {revert(kx,ky,kx+1,ky);\n return false;\n \n }\n }\n \n //u\n if(ky-1>=0)\n {\n move2(kx,ky,kx,ky-1);\n \n if(flag==1)\n {revert(kx,ky,kx,ky-1);\n return false;\n \n }\n }\n //d\n if(ky+1<=7)\n {\n move2(kx,ky,kx,ky+1);\n \n if(flag==1)\n { revert(kx,ky,kx,ky+1);\n return false;\n \n }\n }\n //lu\n if(kx-1>=0&&ky-1>=0)\n {\n move2(kx,ky,kx-1,ky-1);\n \n if(flag==1)\n {revert(kx,ky,kx-1,ky-1);\n return false;\n \n }\n }\n //ld\n if(kx-1>=0&&ky+1<=7)\n {\n move2(kx,ky,kx-1,ky+1);\n \n if(flag==1)\n {revert(kx,ky,kx-1,ky+1);\n return false;\n \n }\n }\n //ru\n if(kx+1<=7&&ky-1>=0)\n {\n move2(kx,ky,kx+1,ky-1);\n \n if(flag==1)\n {revert(kx,ky,kx+1,ky-1);\n return false;\n \n }\n }\n //rd\n if(kx+1<=7&&ky+1<=7)\n {\n move2(kx,ky,kx+1,ky+1);\n \n if(flag==1)\n {revert(kx,ky,kx+1,ky+1);\n return false;\n \n }\n }\n return true; \n }", "private boolean checkMoveOthers(Pieces piece, Coordinates from, Coordinates to) {\n\t\t\t\t\n\t\t/* \n\t\t *il pedone: \n\t\t * -può andare dritto sse davanti a se non ha pedine\n\t\t * -può andare obliquo sse in quelle posizioni ha una pedina avversaria da mangiare\n\t\t * \n\t\t */\n\t\tif (piece instanceof Pawn) {\n\t\t\tif (from.getY() == to.getY()) {\n\t\t\t\tif(chessboard.at(to) == null)\n\t\t\t\t\treturn true;\n\t\t\t\telse\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(chessboard.at(to) == null) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t\n\t\t//il cavallo salta le pedine nel mezzo\n\t\tif (piece instanceof Knight)\n\t\t\treturn true;\n\t\t\n\t\t//Oltre non andranno il: cavallo, il re ed il pedone.\n\t\t/*\n\t\t *Calcolo le posizioni che intercorrono tra il from ed il to escluse \n\t\t *ed per ogni posizione verifico se è vuota\n\t\t *-se in almeno una posizione c'è una pedina(non importa il colore), la mossa non è valida\n\t\t *-altrimenti, la strada è spianata quindi posso effettuare lo spostamento \n\t\t */\n\t\tArrayList<Coordinates> path = piece.getPath(from, to);\n\t\tfor (Coordinates coordinate : path) {\n\t\t\tif ( chessboard.at(coordinate) != null ){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}", "private boolean takeoutOverlaps(\r\n\t\t\tint root_frame_idx,\r\n\t\t\tint group_right_offset_idx,\r\n\t\t\tString [] segments_strs) {\r\n\r\n\t\tfor(int i = root_frame_idx; i < (root_frame_idx+group_right_offset_idx); i++) {\r\n\t\t\tfor(int j = 0; j < segments_strs.length; j ++) {\r\n\t\t\t\tString test_segment = segments_strs[j];\r\n\t\t\t\tSkeletonNode test_node = skeletonWrappers[i].getFromHash(test_segment);\r\n\r\n\t\t\t\t/**If node exist for this frame group within the skeleton\r\n\t\t\t\t * wrappers, remove it so that it does not appear in this\r\n\t\t\t\t * location for other frame groups with lower position in\r\n\t\t\t\t * the sorted list of frame groups**/\r\n\t\t\t\tif(test_node != null) {\r\n\t\t\t\t\tskeletonWrappers[i].remopveFromHash(test_segment);\r\n\t\t\t\t\tif(test_node.isFirstLevel()) {\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t/**If this node doesn't exit then it must already\r\n\t\t\t\t * belong to some other frame group with higher\r\n\t\t\t\t * significance. So filter this frame group out.**/\r\n\t\t\t\telse {\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t}", "public static void main(String[] args) {\n//\t\tmotorGrab.setSpeed(360);\r\n//\t\tdouble rotationGrab=(-0.02)*90/0.01;\r\n//\t\tmotorGrab.rotate(-(int)rotationGrab);\r\n//\t\t\r\n\t\t\r\n\t\tposFork.add(rack11); posFork.add(rack21);posFork.add(rack31);posFork.add(rack41);\r\n\t\tposFork.add(rack42); posFork.add(rack32);posFork.add(rack22);posFork.add(rack12);\r\n\t\tposFork.add(rack13); posFork.add(rack23);posFork.add(rack33);posFork.add(rack43);\r\n\t\tposFork.add(rack44); posFork.add(rack34);posFork.add(rack24);posFork.add(rack14);\r\n\t\tpositionFork=new double[3];\r\n\t\tpositionFork[0]=0.30;\r\n\t\tpositionFork[1]=0.05;\r\n\t\tpositionFork[2]=0.05;\r\n\r\n\t\tgoToInitialState();\r\n\t\tint i=0;\r\n\t\twhile(i<15)\r\n\t\t{\r\n\t\t\tscanPos(i);\r\n\t\t\tmoveFork(posFork.get(i).getCoordinates(),posFork.get(i+1).getCoordinates());\r\n\t\t\ti++;\r\n\t\t}\r\n\t\t// This moment the full rack is scanned, starting from the first shelf on the first row. The code below, could be written inside the while loop.\r\n\t\t// Then, we can for example break the while loop immediately when one column seems to be empty.\r\n\t\t// The code below will also be used to check if the class works\r\n\t\t// Idea if the movement of the motors is not accurate enough: use the color sensor to decide what the position of the robot is.\r\n\t\tint[] emptyOrMistake=new int[16];//0: right color, 1: empty, 2: wrong color \r\n\t\tfor(int j=0;j<16;j++)\r\n\t\t{\r\n\t\t\tif(posFork.get(j).getColorBlock()!=posFork.get(j).getColorShelf() && posFork.get(j).getColorBlock()!=5 )\r\n\t\t\t{\r\n\t\t\t\temptyOrMistake[j]=2;\r\n\t\t\t}\r\n\t\t\tif(posFork.get(j).getColorBlock()==5)\r\n\t\t\t{\r\n\t\t\t\temptyOrMistake[j]=1;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t}\r\n\t\twhile(Button.readButtons()==0) {\r\n\t\tfor(int k=0;k<16;k++)\r\n\t\t{\r\n\t\t\tSystem.out.println(emptyOrMistake[k]);\r\n\t\t}\r\n\t\t}\r\n\t\t// conditions for this class to be called: the robot shouldn't have a box on its fork, it should not have an assignment to deliver a box\r\n\t\t// it is not very efficient to scan each time a box is placed in the warehouse --> it could be an idea to give the robot different assignements after scanning one time\r\n\t\t\r\n\t}", "private boolean validMove(int xi, int yi, int xf, int yf) {\n\t\tPiece prevP = pieceAt(xi, yi);\n\t\tPiece nextP = pieceAt(xf, yf);\n\n\t\tif (prevP.isKing()) {\n\t\t\tif (((xf - xi) == 1 || (xi - xf) == 1) && ((yf - yi) == 1 || (yi - yf) == 1)) \n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t} else \n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\tif (prevP.isFire()) \n\t\t{\n\t\t\tif (((xf - xi) == 1 || (xi - xf) == 1) && (yf - yi) == 1) \n\t\t\t{\n\t\t\t\tif (nextP != null && !nextP.isFire()) \n\t\t\t\t{\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} \n\t\t\telse if ((xf - xi) == 2 && (yf - yi) == 2) \n\t\t\t{\n\t\t\t\tPiece pBetween = pieceAt(xi+1, yi+1);\n\t\t\t\tif (pBetween != null && prevP.side() != pBetween.side()) \n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t} \n\t\t\telse if ((xi - xf) == 2 && (yf - yi) == 2) \n\t\t\t{\n\t\t\t\tPiece pBetween = pieceAt(xi-1, yi+1);\n\t\t\t\tif (pBetween != null && prevP.side() != pBetween.side()) \n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t} else \n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else \n\t\t{\n\t\t\tif (((xf - xi) == 1 || (xi - xf) == 1) && (yi - yf) == 1) \n\t\t\t{\n\t\t\t\tif (nextP != null && nextP.isFire()) \n\t\t\t\t{\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} \n\t\t\telse if ((xf - xi) == 2 && (yi - yf) == 2) \n\t\t\t{\n\t\t\t\tPiece pBetween = pieceAt(xi+1, yi-1);\n\t\t\t\tif (pBetween != null && prevP.side() != pBetween.side()) \n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t} \n\t\t\telse if ((xi - xf) == 2 && (yi - yf) == 2) \n\t\t\t{\n\t\t\t\tPiece pBetween = pieceAt(xi-1, yi-1);\n\t\t\t\tif (pBetween != null && prevP.side() != pBetween.side()) \n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t} \n\t\t\telse \n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}", "public boolean canMove2() {\n\t\tGrid<Actor> gr = getGrid(); \n\t\tif (gr == null) {\n\t\t\treturn false; \n\t\t}\n\t\t\n\t\tLocation loc = getLocation(); \n\t\tLocation next = loc.getAdjacentLocation(getDirection());\n\t\tLocation next2 = next.getAdjacentLocation(getDirection());\n\t\tif (!gr.isValid(next)) {\n\t\t\treturn false;\n\t\t}\n\t\tif (!gr.isValid(next2)) {\n\t\t\treturn false;\n\t\t}\n\t\tActor neighbor = gr.get(next2); \n\t\treturn (neighbor == null) || (neighbor instanceof Flower); \n\t}", "public static boolean move() {\n S.rc.setIndicatorString(2, \"move\");\n if (target == null) {\n System.err.println(\"ERROR: tried to move without target\");\n return false;\n }\n\n // Check if we are close enough.\n int distanceSqToTarget = S.rc.getLocation().distanceSquaredTo(target);\n if (distanceSqToTarget <= thresholdDistanceSq) {\n // Stop bugging.\n start = null;\n S.rc.setIndicatorString(2, \"close enough\");\n return moveCloserToTarget();\n }\n\n if (start == null) {\n // Not currently bugging.\n forward = S.rc.getLocation().directionTo(target);\n S.rc.setIndicatorString(2, \"not buggin\");\n if (moveForwardish()) return true;\n // Start bugging.\n start = S.rc.getLocation();\n forward = forward.rotateRight().rotateRight();\n return move();\n } else {\n // Already bugging.\n // Stop bugging if we got closer to the target than when we started bugging.\n if (distanceSqToTarget < start.distanceSquaredTo(target)) {\n start = null;\n return move();\n }\n\n // Stop bugging if back-left is clear.\n // This means that we must have bugged around something that has since moved.\n if (canMove(forward.rotateLeft().rotateLeft().rotateLeft())) {\n start = null;\n forward = S.rc.getLocation().directionTo(target);\n S.rc.setIndicatorString(2, \"back left clear, forward \" + forward);\n return moveForwardish();\n }\n\n S.rc.setIndicatorString(2, \"scan circle\");\n forward = forward.rotateLeft().rotateLeft();\n // Try moving left, and try every direction in a circle from there.\n for (int i = 0; i < 8; i++) {\n if (moveForwardStrict()) return true;\n forward = forward.rotateRight();\n }\n return false;\n }\n }", "public boolean move(int startPeg, int endPeg) {\n\t\ttry {\n\t\t\t// if the startPeg and endPeg are the same return false.\n\t\t\tif (startPeg == endPeg) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t// If there are no rings on the startPeg return false.\n\t\t\telse if (getRingCount(startPeg) == 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t/*\n\t\t\t * If the top ring on the startPeg is larger than the top ring on\n\t\t\t * the endPeg return false, unless there is no ring on the end Peg.\n\t\t\t */\n\t\t\telse if (getTopDiameter(startPeg) > getTopDiameter(endPeg) && getTopDiameter(endPeg) != 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t//Set the index for each peg.\n\t\t\tstartPeg = getPegIndex(startPeg);\n\t\t\tendPeg = getPegIndex(endPeg);\n\t\t} catch (IllegalArgumentException e) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Place the ring on the endPeg.\n\t\tallPegs[endPeg].placeRing(allPegs[startPeg].getTopDiameter());\n\t\t\n\t\t// Remove the ring from the startPeg.\n\t\tallPegs[startPeg].removeRing();\n\t\treturn true;\n\n\t}", "public Boolean checkStalemate(IBoardAgent oBoard, IPlayerAgent oPlayer) {\n\t\tIPieceAgent oKingPiece = oPlayer.getKingPiece();\n\n\t\t// Checking if any piece other than King can make any move.\n\t\tfor (Map.Entry<String, IPieceAgent> itPiece : oPlayer.getAllPieces().entrySet()) {\n\t\t\tIPieceAgent oPiece = itPiece.getValue();\n\t\t\t\n\t\t\tif (oPiece.getPosition() == null) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\n\t\t\tif (oPiece.equals(oKingPiece)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\n\t\t\tMap<String, IMoveCandidate> mpCandidateMovePosition = new HashMap<String, IMoveCandidate>();\n\t\t\ttryEvaluateAllRules(oBoard, oPiece, mpCandidateMovePosition);\n\t\t\t\n\t\t\tif (!mpCandidateMovePosition.isEmpty()) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t\n\t\t// Fetching all the possible moves King can make.\n\t\tMap<String, IMoveCandidate> mpCandidateMovePositionForKing = new HashMap<String, IMoveCandidate>();\n\t\ttryEvaluateAllRules(oBoard, oKingPiece, mpCandidateMovePositionForKing);\n\t\t\n\t\t// Iterating through the opponent's pieces and see if there is any candidate move that King can make\n\t\t// without endangering itself.\n\t\tfor (Map.Entry<String, IPlayerAgent> itPlayer : oBoard.getAllPlayerAgents().entrySet()) {\n\t\t\tif (itPlayer.getValue().equals(oPlayer)) {\n\t\t\t\t// Ignore piece from same player.\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// Iterating the pieces of the current player.\n\t\t\tfor (Map.Entry<String, IPieceAgent> itPiece : itPlayer.getValue().getAllPieces().entrySet()) {\n\t\t\t\tIPieceAgent oOpponentPiece = itPiece.getValue();\n\t\t\t\tif (oOpponentPiece.getPosition() == null) {\n\t\t\t\t\t// Piece is not linked to any piece indicates the piece has been captured.\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// Fetching the possible moves the piece can make.\n\t\t\t\tMap<String, IMoveCandidate> mpCandidateMovePositionsForOpponentPlayerPiece = new HashMap<String, IMoveCandidate>();\n\t\t\t\ttryEvaluateAllRules(oBoard, oOpponentPiece, mpCandidateMovePositionsForOpponentPlayerPiece);\n\t\t\t\tfor (Map.Entry<String, IMoveCandidate> itCandidateMove : mpCandidateMovePositionsForOpponentPlayerPiece.entrySet()) {\t\t\t\t\n\t\t\t\t\tif (mpCandidateMovePositionForKing.containsKey(itCandidateMove.getKey())) {\n\t\t\t\t\t\tmpCandidateMovePositionForKing.remove(itCandidateMove.getKey());\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (mpCandidateMovePositionForKing.size() == 0) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (mpCandidateMovePositionForKing.size() > 0) {\n\t\t\treturn false;\n\t\t}\n\t\t\t\n\t\treturn true;\n\t}", "public MahjongSolitaireMove findMove()\n {\n // MAKE A MOVE TO FILL IN \n MahjongSolitaireMove move = new MahjongSolitaireMove();\n\n // GO THROUGH THE ENTIRE GRID TO FIND A MATCH BETWEEN AVAILABLE TILES\n for (int i = 0; i < gridColumns; i++)\n {\n for (int j = 0; j < gridRows; j++)\n {\n ArrayList<MahjongSolitaireTile> stack1 = tileGrid[i][j];\n if (stack1.size() > 0)\n {\n // GET THE FIRST TILE\n MahjongSolitaireTile testTile1 = stack1.get(stack1.size()-1);\n for (int k = 0; k < gridColumns; k++)\n {\n for (int l = 0; l < gridRows; l++)\n {\n if (!((i == k) && (j == l)))\n { \n ArrayList<MahjongSolitaireTile> stack2 = tileGrid[k][l];\n if (stack2.size() > 0) \n {\n // AND TEST IT AGAINST THE SECOND TILE\n MahjongSolitaireTile testTile2 = stack2.get(stack2.size()-1);\n \n // DO THEY MATCH\n if (testTile1.match(testTile2))\n {\n // YES, FILL IN THE MOVE AND RETURN IT\n move.col1 = i;\n move.row1 = j;\n move.col2 = k;\n move.row2 = l;\n return move;\n }\n }\n }\n }\n }\n }\n }\n }\n // WE'VE SEARCHED THE ENTIRE GRID AND THERE\n // ARE NO POSSIBLE MOVES REMAINING\n return null;\n }", "private boolean overlappingTaskAndGateway(BpmnShape s1, BpmnShape s2) {\n\t\tdouble firstHeight = s1.getBounds().getHeight() / 2;\n\t\tdouble firstWidth = s1.getBounds().getWidth() / 2;\n\t\tdouble firstX = s1.getBounds().getX() + firstWidth;\n\t\tdouble firstY = s1.getBounds().getY() + firstHeight;\n\t\t\n\n\t\tdouble secondWidth = s2.getBounds().getWidth() / 2;\n\t\tdouble secondHeight = s2.getBounds().getHeight() / 2;\n\t\tdouble secondX = s2.getBounds().getX();\n\t\tdouble secondY = s2.getBounds().getY() + secondHeight;\n\t\tdouble apothem = (s2.getBounds().getHeight() * Math.sqrt(2)) / 2;\n\t\t\n\t\tif (firstX > secondX && firstY > secondY){\n\t\t\tif ((firstX - firstWidth < secondX + secondWidth && firstY - firstHeight < secondY + secondHeight) &&\n\t\t\t\t(firstX - firstWidth < secondX + apothem || firstY - firstHeight < secondY + apothem))\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif (firstX > secondX && firstY < secondY){\n\t\t\tif ((firstX - firstWidth < secondX + secondWidth && firstY + firstHeight > secondY - secondHeight) &&\n\t\t\t\t(firstX - firstWidth < secondX + apothem || firstY + firstHeight > secondY - apothem))\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif (firstX < secondX && firstY > secondY){\n\t\t\tif ((firstX + firstWidth > secondX - secondWidth && firstY - firstHeight < secondY + secondHeight) &&\n\t\t\t\t(firstX + firstWidth > secondX - apothem || firstY - firstHeight < secondY + apothem))\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif (firstX < secondX && firstY < secondY){\n\t\t\tif ((firstX - firstWidth < secondX + secondWidth && firstY + firstHeight > secondY - secondHeight) &&\n\t\t\t\t(firstX - firstWidth < secondX + apothem || firstY + firstHeight > secondY - apothem))\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif (firstX == secondX && firstY == secondY)\n\t\t\t\treturn true;\n\t\t\n\t\tif (firstX == secondX && firstY > secondY){\n\t\t\tif (firstY - firstHeight < secondY + secondHeight)\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif (firstX > secondX && firstY == secondY){\n\t\t\tif (firstX - firstWidth < secondX + secondWidth)\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif (firstX == secondX && firstY < secondY){\n\t\t\tif (firstY + firstHeight > secondY - secondHeight)\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif (firstX < secondX && firstY == secondY){\n\t\t\tif (firstX + firstWidth > secondX - secondWidth)\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\treturn false;\n\t}", "public static void checkPlayerLongestRoad(Player player, Game game1, Road road1) {\n\n\t\t//the unique id for each node visit that takes place\n\t\tid = 0;\n\t\tloop = false;\n\n\t\tBoard board1 = game1.getBoard();\n\t\t\n\t\tint currLongest = player.getLongestRoad(); //old longest road\n\t\tint longest = 0; //longest road found from this point\n\n\t\t//this is one end of the road\n\t\tIntersection intA = (Intersection) game1.getBoard()\n\t\t\t\t.getLocationFromCoordinate(road1.getCoordinateA())\n\t\t\t\t.getContains();\n\t\t\n\t\t//this is the other\n\t\tIntersection intB = (Intersection) game1.getBoard()\n\t\t\t\t.getLocationFromCoordinate(road1.getCoordinateB())\n\t\t\t\t.getContains();\n\n\t\tRoad end1A = null;\n\t\tRoad end1B = null;\n\t\tRoad end2A = null;\n\t\tRoad end2B = null;\n\t\t\n\t\t// this sets end1A to be the first new road coming out of intA that is not the road placed (i.e. that does not go to intB)\n\t\tend1A = getRoadFromInt(game1, intA, player, intB, null);\n\t\t\n\t\t// if there was such a road, this looks for another road, to see if there are two roads coming out of that same end\n\t\tif (end1A != null) {\n\t\t\tend1B = getRoadFromInt(game1, intA, player, intB, getOtherInt(board1, end1A, intA));\n\t\t}\n\t\t\n\t\t//this sets end2a to be the first new road coming out of the other end (intB) that doesnt go to intA\n\t\tend2A = getRoadFromInt(game1, intB, player, intA, null);\n\t\t\n\t\t// if there was such a road, this looks for another road, to see if there are two roads coming out of that same end\n\t\tif (end2A != null) {\n\t\t\tend2B = getRoadFromInt(game1, intB, player, intA, getOtherInt(board1, end2A, intB));\n\t\t}\n\n\t\t// connecting, i.e. if this road links to other roads together\n\t\tif ((end1A != null || end1B != null) && (end2A != null || end2B != null)) {\n\t\t\t\n\t\t\tid = 0;\n\t\t\t\n\t\t\t//this maps a point to a sector for the purpose of finding overlap\n\t\t\tHashMap<Intersection, String> sectorMap = new HashMap<Intersection, String>();\n\t\t\t\t\t\n\t\t\t//END 1\n\t\t\tint longests1 = 0;\n\t\t\t\n\t\t\tHashMap<Intersection, Integer> distancesMaps1 = new HashMap<Intersection, Integer>();\n\t\t\tHashMap<Intersection, ArrayList<Integer>> visitorsMaps1 = new HashMap<Intersection, ArrayList<Integer>>();\n\t\t\tArrayList<Integer> namesLists1 = new ArrayList<Integer>();\n\t\t\t\n\t\t\tnamesLists1.add(new Integer(0));\n\t\t\tnamesLists1.add(new Integer(-1));\n\t\t\t\n\t\t\tArrayList<Integer> idArray1s1 = new ArrayList<Integer>();\n\t\t\tArrayList<Integer> idArray2s1 = new ArrayList<Integer>();\n\t\t\t\n\t\t\tidArray1s1.add(new Integer(id));\n\t\t\tidArray2s1.add(new Integer(id - 1));\n\t\t\tvisitorsMaps1.put(intB, idArray1s1);\n\n\t\t\tlongests1 = Branch(game1, player, intA, intB, road1,\n\t\t\t\t\t(ArrayList<Integer>) namesLists1.clone(), 1,\n\t\t\t\t\tdistancesMaps1, visitorsMaps1, \"s1\", sectorMap);\n\t\t\t\t\t\t\n\t\t\t// END2\n\t\t\tint longests2 = 0;\n\t\t\t\n\t\t\tHashMap<Intersection, Integer> distancesMaps2 = new HashMap<Intersection, Integer>();\n\t\t\tHashMap<Intersection, ArrayList<Integer>> visitorsMaps2 = new HashMap<Intersection, ArrayList<Integer>>();\n\t\t\tArrayList<Integer> namesLists2 = new ArrayList<Integer>();\n\t\t\t\n\t\t\tnamesLists2.add(new Integer(id));\n\t\t\tnamesLists2.add(new Integer(id-1));\n\n\t\t\tArrayList<Integer> idArray1s2 = new ArrayList<Integer>();\n\t\t\tArrayList<Integer> idArray2s2 = new ArrayList<Integer>();\n\t\t\t\n\t\t\tidArray1s2.add(new Integer(id));\n\t\t\tidArray2s2.add(new Integer(id-1 ));\n\t\t\tvisitorsMaps2.put(intA, idArray1s2);\n\t\t\t\n\t\t\tlongests2 = Branch(game1, player, intB, intA, road1,\n\t\t\t\t\t(ArrayList<Integer>) namesLists2.clone(), 1,\n\t\t\t\t\tdistancesMaps2, visitorsMaps2, \"s2\", sectorMap);\n\n\t\t\t//deciding on what to return\n\t\t\tif (loop) {\n\t\t\t\t\n\t\t\t\tif (longests2 > longests1) {\n\t\t\t\t\tlongest = longests2;\n\t\t\t\t} \n\t\t\t\telse {\n\t\t\t\t\tlongest = longests1;\n\t\t\t\t}\n\t\t\t} \n\t\t\telse {\n\t\t\t\tlongest = -1 + longests1 + longests2;\n\t\t\t}\n\n\t\t} \n\t\t\n\t\t//this is what happens if only one end connected to anything, this works!\n\t\telse {\n\t\t\t\n\t\t\t// setup\n\t\t\tid = 0;\n\t\t\t\n\t\t\t//this hashmap will record the distances to various points, using points as keys, longest distances as values, will update with longer distances\n\t\t\tHashMap<Intersection, Integer> distancesMap = new HashMap<Intersection, Integer>();\n\t\t\t\n\t\t\t//this hashmap will map points to an arraylist of ints\n\t\t\tHashMap<Intersection, ArrayList<Integer>> visitorsMap = new HashMap<Intersection, ArrayList<Integer>>();\n\t\t\t\n\t\t\t//this arraylist will be cloned to represent all the things that have been visited by a route, all routes have visited 0 and -1 (the two start intersections)\n\t\t\tArrayList<Integer> namesList = new ArrayList<Integer>();\n\t\t\t\n\t\t\tnamesList.add(new Integer(0));\n\t\t\tnamesList.add(new Integer(-1));\n\t\t\t\n\t\t\t// end 1 is not empty, end 2 is this means we will be branching intA\n\t\t\tif ((end1A != null || end1B != null)) {\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t// this adds the ids of the starting points to the visitorsmap hashmap\n\t\t\t\t//each node gets its own arraylist, which is why we get two, of course \n\t\t\t\t//these array lists should not really be added to\n\t\t\t\tArrayList<Integer> idArray1 = new ArrayList<Integer>();\n\t\t\t\tArrayList<Integer> idArray2 = new ArrayList<Integer>();\n\t\t\t\t\n\t\t\t\tidArray1.add(new Integer(id));\n\t\t\t\tidArray2.add(new Integer(id - 1));\n\t\t\t\tvisitorsMap.put(intB, idArray1);\n\t\t\t\tvisitorsMap.put(intA, idArray2);\n\t\t\t\t\n\t\t\t\t//the starting length of the branch coming out of end1A, this includes the original road\n\t\t\t\tint toplen = 1;\n\t\t\t\t\n\t\t\t\t//the starting length of the branch coming out of end1B\n\t\t\t\tint botLen = 1;\n\t\t\t\t\n\t\t\t\t// looking at the first branch possibility\n\t\t\t\tif (end1A != null) {\n\t\t\t\t\t\n\t\t\t\t\t//branch using the road end1A fro intA to the intersection\n\t\t\t\t\t//that road end1A leads to, and moving the length to two \n\t\t\t\t\ttoplen = Branch(game1, player, getOtherInt(board1, end1A, intA), intA, end1A,\n\t\t\t\t\t\t\t(ArrayList<Integer>) namesList.clone(), toplen + 1,\n\t\t\t\t\t\t\tdistancesMap, visitorsMap, null, null);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// looking at the other branch possibility\n\t\t\t\tif (end1B != null) {\n\t\t\t\t\t\n\t\t\t\t\ttoplen = Branch(game1, player, getOtherInt(board1, end1B, intA), intA, end1B,\n\t\t\t\t\t\t\t(ArrayList<Integer>) namesList.clone(), botLen + 1,\n\t\t\t\t\t\t\tdistancesMap, visitorsMap, null, null);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// getting which one of those is better!\n\t\t\t\tif (toplen > botLen) {\n\t\t\t\t\tlongest = toplen;\n\t\t\t\t} \n\t\t\t\telse {\n\t\t\t\t\tlongest = botLen;\n\t\t\t\t}\n\t\t\t} \n\t\t\t\n\t\t\t//end 2 is empty\n\t\t\telse {\n\t\t\t\t\n\t\t\t\tid = 0;\n\t\t\t\t\n\t\t\t\t// putting the ids in a map, getting them the right way\n\t\t\t\t// around(pointless?)\n\t\t\t\tArrayList<Integer> idArray1 = new ArrayList<Integer>();\n\t\t\t\tArrayList<Integer> idArray2 = new ArrayList<Integer>();\n\t\t\t\t\n\t\t\t\tidArray1.add(new Integer(id));\n\t\t\t\tidArray2.add(new Integer(id - 1));\n\t\t\t\tvisitorsMap.put(intA, idArray1);\n\t\t\t\tvisitorsMap.put(intB, idArray2);\n\t\t\t\t\n\t\t\t\t// length of each branch+initial road\n\t\t\t\tint toplen = 1;\n\t\t\t\tint botLen = 1;\n\t\t\t\t\n\t\t\t\t// looking at the first branch possibility road end2A from intersection intB to a new int\n\t\t\t\tif (end2A != null) {\n\t\t\t\t\t\n\t\t\t\t\tSystem.out.println(\"A\");\n\t\t\t\t\ttoplen = Branch(game1, player, getOtherInt(board1, end2A, intB), intB, end2A,\n\t\t\t\t\t\t\t(ArrayList<Integer>) namesList.clone(), toplen + 1,\n\t\t\t\t\t\t\tdistancesMap, visitorsMap, null, null);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// looking at the other branch possibility\n\t\t\t\tif (end2B != null) {\n\t\t\t\t\t\n\t\t\t\t\tSystem.out.println(\"B\");\n\t\t\t\t\tbotLen = Branch(game1, player, getOtherInt(board1, end2B, intB), intB, end2B,\n\t\t\t\t\t\t\t(ArrayList<Integer>) namesList.clone(), botLen + 1,\n\t\t\t\t\t\t\tdistancesMap, visitorsMap, null, null);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// getting which one of those is better!\n\t\t\t\tif (toplen > botLen) {\n\t\t\t\t\tlongest = toplen;\n\t\t\t\t} \n\t\t\t\telse {\n\t\t\t\t\tlongest = botLen;\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t}\n\t\t\n\t\tif (longest > currLongest) {\n\t\t\tplayer.setLongestRoad(longest);\n\t\t}\n\t\t\n\t\tloop = false;\n\t}", "public static int[][] getPiecePositions(String piece, int startFile,\n int startRank) {\n int numPiecePos = 0;\n\n int[][] piecePos;\n\n if (startFile != -1 && startRank != -1) {\n piecePos = new int[1][2];\n\n piecePos[0][0] = startFile;\n piecePos[0][1] = startRank;\n } else if (startFile != -1) {\n for (int r = 0; r < 8; r++) {\n if (getBoardStateSquare(startFile, r).equals(piece)) {\n numPiecePos++;\n }\n }\n\n piecePos = new int[numPiecePos][2];\n\n int pieceIndex = 0;\n\n for (int rank = 0; rank < 8; rank++) {\n if (getBoardStateSquare(startFile, rank).equals(piece)) {\n piecePos[pieceIndex][0] = startFile;\n piecePos[pieceIndex][1] = rank;\n\n pieceIndex++;\n }\n }\n } else if (startRank != -1) {\n for (int f = 0; f < 8; f++) {\n if (getBoardStateSquare(f, startRank).equals(piece)) {\n numPiecePos++;\n }\n }\n\n piecePos = new int[numPiecePos][2];\n\n int pieceIndex = 0;\n\n for (int file = 0; file < 8; file++) {\n if (getBoardStateSquare(file, startRank).equals(piece)) {\n piecePos[pieceIndex][0] = file;\n piecePos[pieceIndex][1] = startRank;\n\n pieceIndex++;\n }\n }\n } else {\n for (String[] rank: getBoardState()) {\n for (String square: rank) {\n if (square.equals(piece)) {\n numPiecePos++;\n }\n }\n }\n\n piecePos = new int[numPiecePos][2];\n\n int pieceIndex = 0;\n\n for (int r = 0; r < getBoardState().length; r++) {\n for (int f = 0; f < getBoardState()[r].length; f++) {\n if (getBoardStateSquare(f, r).equals(piece)) {\n piecePos[pieceIndex][0] = f;\n piecePos[pieceIndex][1] = r;\n\n pieceIndex++;\n }\n }\n }\n }\n\n return piecePos;\n }", "public Action moveCloser(Dinosaur dino, GameMap map){\n //for each exit\n for(Exit exits: here.getExits()){\n //eget exits from that exit\n for(Exit exit:exits.getDestination().getExits()){\n target = map.getActorAt(exit.getDestination());\n //check for mate\n if(target != null && target instanceof Dinosaur){\n Dinosaur targetDino = (Dinosaur) target;\n if(targetDino.getGender() != dino.getGender() &&\n targetDino.getDisplayChar() == dino.getDisplayChar()){\n Action fB = new FollowBehaviour(targetDino).getAction(dino, map);\n return fB;\n }\n }\n }\n }\n return null;\n }", "private boolean updateMovingObjects(double elapsedSeconds) {\n for(Movable movingObj : engine.getMovingObjects()){\n double dx = 0, dy = 0;\n switch (movingObj.getFacing()){\n case UP:\n dy -= movingObj.getSpeed() * GRID_SIZE * elapsedSeconds;\n break;\n case DOWN:\n dy += movingObj.getSpeed() * GRID_SIZE * elapsedSeconds;\n break;\n case LEFT:\n dx -= movingObj.getSpeed() * GRID_SIZE * elapsedSeconds;\n break;\n case RIGHT:\n dx += movingObj.getSpeed() * GRID_SIZE * elapsedSeconds;\n break;\n }\n Node movingNode = getNodeById(movingObj.getObjID());\n if(movingNode == null) break; // if the node is deleted\n double oldX = movingNode.getTranslateX();\n double oldY = movingNode.getTranslateY();\n double newX = oldX + dx;\n double newY = oldY + dy;\n\n // translate objs\n movingNode.setTranslateX(newX);\n movingNode.setTranslateY(newY);\n\n // detect collisions\n for(GameObject anotherObj : engine.getAllObjects()){\n // ignore self with self\n if(movingObj.equals(anotherObj)) continue;\n\n Node anotherNode =\n getNodeById(anotherObj.getObjID());\n\n if(isColliding(movingNode, anotherNode)){\n CollisionResult result = engine.handleCollision(movingObj, anotherObj);\n if(handleCollision(result, movingNode, anotherNode, oldX, oldY))\n return true;\n }\n }\n\n engine.changeObjectLocation(movingObj, getUpdatedPoint(movingObj, newX, newY));\n }\n return false;\n }", "@Override\r\n\tpublic boolean movement(BoardCells[][] chessBoard, Piece targetPiece, int fromX,int fromY,int toX,int toY) {\t\t\r\n\t\t//DEBUG -- System.out.println(\"\"+fromX+fromY+\" \"+toX+toY);\r\n\t\t\r\n\t\tif(fromY == toY){\t\t\t\r\n\t\t\tif(fromX > toX) {\r\n\t\t\t\tfor(int i = fromX-1; i>toX; i--) {\r\n\t\t\t\t\tif(chessBoard[8-fromY][i].getPiece() != null) {\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\r\n\t\t\t} else if (fromX < toX) {\r\n\t\t\t\tfor(int i = fromX+1; i<toX; i++) {\r\n\t\t\t\t\tif(chessBoard[8-fromY][i].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif(getPieceID().equals(\"bR\")) {\r\n\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"bKc\")) {\r\n\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"bK\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif(getPieceID().equals(\"wR\")) {\r\n\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"wKc\")) {\r\n\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"wK\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\tif(fromX == toX) {\t\t\t\t\r\n\t\t\tif(fromY > toY) {\t\r\n\t\t\t\tfor(int i = fromY-1; i>toY; i--) {\r\n\t\t\t\t\tif(chessBoard[8-i][toX].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t} else if (fromY < toY) {\t\t\t\t\r\n\t\t\t\tfor(int i = fromY+1; i<toY; i++) {\t\t\t\t\t\r\n\t\t\t\t\tif(chessBoard[8-i][toX].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tif(getPieceID().equals(\"bR\")) {\r\n\t\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"bKc\")) {\r\n\t\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"bK\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(getPieceID().equals(\"wR\")) {\r\n\t\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"wKc\")) {\r\n\t\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"wK\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\r\n\t\t\treturn true;\t\r\n\t\t}\r\n\t\t\t\t\r\n\t\treturn false;\t\t\r\n\t}", "public static void computeRanks(int first, int second) {\r\n\r\n double AOld[], A[];\r\n double BOld[], B[];\r\n double diffOld[], diff[];\r\n int ties, N, pointer;\r\n boolean sign[];\r\n double ranks[];\r\n double RA, RB;\r\n ArrayList<Double> walsh;\r\n int criticalN;\r\n String interval;\r\n\r\n AOld = new double[rows];\r\n BOld = new double[rows];\r\n diffOld = new double[rows];\r\n\r\n ties = 0;\r\n\r\n for (int i = 0; i < rows; i++) {\r\n\r\n if (Configuration.getObjective() == 1) {\r\n AOld[i] = data[i][first];\r\n BOld[i] = data[i][second];\r\n } else {\r\n AOld[i] = data[i][second];\r\n BOld[i] = data[i][first];\r\n }\r\n\r\n diffOld[i] = Math.abs(AOld[i] - BOld[i]);\r\n\r\n if (diffOld[i] == 0.0) {\r\n ties++;\r\n }\r\n }\r\n\r\n N = rows - ties;\r\n\r\n A = new double[N];\r\n B = new double[N];\r\n diff = new double[N];\r\n sign = new boolean[N];\r\n ranks = new double[N];\r\n\r\n pointer = 0;\r\n\r\n for (int i = 0; i < rows; i++) {\r\n\r\n if (diffOld[i] != 0.0) {\r\n A[pointer] = AOld[i];\r\n B[pointer] = BOld[i];\r\n diff[pointer] = Math.abs(A[pointer] - B[pointer]);\r\n if ((A[pointer] - B[pointer]) > 0.0) {\r\n sign[pointer] = true;\r\n } else {\r\n sign[pointer] = false;\r\n }\r\n pointer++;\r\n }\r\n\r\n }\r\n\r\n //compute ranks\r\n double min;\r\n double points;\r\n int tied;\r\n String tiedString = \"\";\r\n\r\n Arrays.fill(ranks, -1.0);\r\n\r\n for (int rank = 1; rank <= N;) {\r\n min = Double.MAX_VALUE;\r\n tied = 1;\r\n\r\n for (int i = 0; i < N; i++) {\r\n if ((ranks[i] == -1.0) && diff[i] == min) {\r\n tied++;\r\n }\r\n if ((ranks[i] == -1.0) && diff[i] < min) {\r\n min = diff[i];\r\n tied = 1;\r\n }\r\n\r\n }\r\n\r\n //min has the lower unassigned value\r\n if (tied == 1) {\r\n points = rank;\r\n } else {\r\n tiedString += (tied + \"-\");\r\n points = 0.0;\r\n for (int k = 0; k < tied; k++) {\r\n points += (rank + k);\r\n }\r\n points /= tied;\r\n }\r\n\r\n for (int i = 0; i < N; i++) {\r\n if (diff[i] == min) {\r\n ranks[i] = points;\r\n }\r\n }\r\n\r\n rank += tied;\r\n }\r\n\r\n //compute sumOfRanks\r\n\r\n RA = 0.0;\r\n RB = 0.0;\r\n\r\n for (int i = 0; i < ranks.length; i++) {\r\n if (sign[i]) {\r\n RA += ranks[i];\r\n } else {\r\n RB += ranks[i];\r\n }\r\n }\r\n\r\n //Treatment of 0's\r\n double increment;\r\n double sum0;\r\n if (ties > 1) {\r\n //discard a tie if there's an odd number of them\r\n if (ties % 2 == 1) {\r\n increment = ties - 1.0;\r\n } else {\r\n increment = ties;\r\n }\r\n\r\n //Adition of 0 ranked differences\r\n sum0 = (((double) increment + 1.0) * (double) increment) / 2.0;\r\n sum0 /= 2.0;\r\n\r\n RA += sum0;\r\n RB += sum0;\r\n\r\n //Reescaling of the rest of ranks\r\n for (int i = 0; i < ranks.length; i++) {\r\n if (sign[i]) {\r\n RA += increment;\r\n } else {\r\n RB += increment;\r\n }\r\n }\r\n }\r\n \r\n //save the ranks\r\n wilcoxonRanks[first][second] = RA;\r\n wilcoxonRanks[second][first] = RB;\r\n\r\n //compute exact pValue\r\n exactPValues[first][second] = WilcoxonDistribution.computeExactProbability(N, RB);\r\n exactPValues[second][first] = WilcoxonDistribution.computeExactProbability(N, RA);\r\n\r\n //compute asymptotic P Value\r\n\r\n int tiesDistribution[];\r\n\r\n tiesDistribution = decode(tiedString);\r\n\r\n asymptoticPValues[first][second] = WilcoxonDistribution.computeAsymptoticProbability(N, RB, tiesDistribution);\r\n asymptoticPValues[second][first] = WilcoxonDistribution.computeAsymptoticProbability(N, RA, tiesDistribution);\r\n\r\n //compute confidence intervals\r\n walsh = new ArrayList<Double>();\r\n\r\n double aux, aux2;\r\n for (int i = 0; i < diffOld.length - 1; i++) {\r\n if (Configuration.getObjective() == 1) {\r\n aux = AOld[i] - BOld[i];\r\n } else {\r\n aux = BOld[i] - AOld[i];\r\n }\r\n\r\n walsh.add(aux);\r\n for (int j = i + 1; j < diffOld.length; j++) {\r\n if (Configuration.getObjective() == 1) {\r\n aux2 = AOld[j] - BOld[j];\r\n } else {\r\n aux2 = BOld[j] - AOld[j];\r\n }\r\n walsh.add((aux + aux2) / 2.0);\r\n }\r\n }\r\n\r\n Collections.sort(walsh);\r\n\r\n //Find critical levels\r\n\r\n criticalN = findCriticalValue(diffOld.length, 0.05, tiesDistribution);\r\n criticalN = Math.max(criticalN, 0);\r\n\r\n //Build interval\r\n interval = \"[\";\r\n interval += nf.format(walsh.get(criticalN));\r\n interval += \" , \";\r\n interval += nf.format(walsh.get(walsh.size() - (criticalN + 1)));\r\n interval += \"]\";\r\n\r\n confidenceIntervals95[first][second] = interval;\r\n exactConfidence95[first][second] = 1.0 - (WilcoxonDistribution.computeExactProbability(diffOld.length, criticalN));\r\n\r\n criticalN = findCriticalValue(diffOld.length, 0.1, tiesDistribution);\r\n criticalN = Math.max(criticalN, 0);\r\n\r\n //Build interval\r\n interval = \"[\";\r\n interval += nf.format(walsh.get(criticalN));\r\n interval += \" , \";\r\n interval += nf.format(walsh.get(walsh.size() - (criticalN + 1)));\r\n interval += \"]\";\r\n\r\n confidenceIntervals90[first][second] = interval;\r\n exactConfidence90[first][second] = 1.0 - (WilcoxonDistribution.computeExactProbability(diffOld.length, criticalN));\r\n\r\n }", "Path run(Maze maze, Cell start, Cell finish) {\n Path path = new Path();\n if (start.equals(finish)) {\n path.add(start);\n return path;\n }\n Maze changed = new Maze(maze);\n CellQueue queue = new CellQueueLinkedListImpl();\n queue.enqueue(start);\n changed.setCellValue(start, 0);\n Cell curCell;\n do {\n curCell = queue.dequeue();\n for (int i = -1; i <= 1; i++) {\n for (int j = -1; j <= 1; j++) {\n for (int k = -1; k <= 1; k++) {\n Cell curNeighbour = new Cell(curCell.x + i, curCell.y + j, curCell.z + k);\n //check that curNeighbour exists and empty\n if (changed.getCellValue(curNeighbour) == -1) {\n changed.setCellValue(curNeighbour, changed.getCellValue(curCell) + 1);\n queue.enqueue(curNeighbour);\n }\n }\n }\n }\n } while (!queue.isEmpty() && !curCell.equals(finish));\n if (!curCell.equals(finish)) {\n return path;\n }\n while (!curCell.equals(start)) {\n path.addBegin(curCell);\n int curPathIndex = changed.getCellValue(curCell);\n boolean foundPrev = false;\n for (int i = -1; i <= 1 && !foundPrev; i++) {\n for (int j = -1; j <= 1 && !foundPrev; j++) {\n for (int k = -1; k <= 1 && !foundPrev; k++) {\n Cell curNeighbour = new Cell(curCell.x + i, curCell.y + j, curCell.z + k);\n if (changed.getCellValue(curNeighbour) == changed.getCellValue(curCell) - 1) {\n curCell = curNeighbour;\n foundPrev = true;\n }\n }\n }\n }\n }\n path.addBegin(start);\n return path;\n }", "public boolean canMove() {\n\t\tArrayList<Location> loc = getValid(getLocation());\n\t\tif (loc.isEmpty()) {\n\t\t\treturn false;\n\t\t} else {\n\t\t\tpath.add(getLocation());\n\t\t\tif (loc.size() >= 2) {\n\t\t\t\tcrossLocation.push(path);\n\t\t\t\tpath = new ArrayList<Location>();\n\t\t\t\tnext = betterDir(loc);\n\t\t\t}\n\t\t\tnext = loc.get(0);\n\t\t}\n\t\treturn true;\n\t}", "public boolean checkWithFragmentingWarheadRocketJump ()\n {\n Map<Square, List<Player>> squarePlayerListMap = checkRocketJump();\n List<Player> playerList;\n\n for (Square squareIterate : squarePlayerListMap.keySet())\n {\n\n for (Player playerIterate : squarePlayerListMap.get(squareIterate))\n {\n playerList = new ArrayList<>();\n\n playerList.addAll(playerIterate.getSquare().getPlayerList());\n playerList.remove(player);\n\n if (playerList.size()>1)\n return true;\n\n }\n }\n\n return false;\n }", "private boolean isEqual(Roster r2)\n\t{\n\t\tIterator<Player> it1 = iterator();\n\t\twhile(it1.hasNext())\n\t\t{\n\t\t\tPlayer p = it1.next();\n\t\t\tif(!r2.has(p))\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\tIterator<Player> it2 = r2.iterator();\n\t\twhile(it2.hasNext())\n\t\t{\n\t\t\tPlayer p = it2.next();\n\t\t\tif(!has(p))\n\t\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}", "private boolean overlappingTasks(BpmnShape s1, BpmnShape s2) {\n\n\t\tdouble firstHeight = s1.getBounds().getHeight() / 2;\n\t\tdouble firstWidth = s1.getBounds().getWidth() / 2;\n\t\t//The coordinates refer to the upper-left corner of the task, adding Width and Height \n\t\t//cause the coordinates to reflect the position of the center of the shape\n\t\tdouble firstX = s1.getBounds().getX() + firstWidth;\n\t\tdouble firstY = s1.getBounds().getY() + firstHeight;\n\t\t\n\t\tdouble secondHeight = s2.getBounds().getHeight() / 2;\n\t\tdouble secondWidth = s2.getBounds().getWidth() / 2;\n\t\tdouble secondX = s2.getBounds().getX() + secondWidth;\n\t\tdouble secondY = s2.getBounds().getY() + secondHeight;\n\t\t\n\t\tif (firstX > secondX && firstY > secondY){\n\t\t\t//Second shape is on the upper-left\n\t\t\tif (firstX - firstWidth < secondX + secondWidth && firstY - firstHeight < secondY + secondHeight)\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif (firstX > secondX && firstY < secondY){\n\t\t\t//Second shape is on the lower-left\n\t\t\tif (firstX - firstWidth < secondX + secondWidth && firstY + firstHeight > secondY - secondHeight)\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif (firstX < secondX && firstY > secondY){\n\t\t\t//Second shape is on the upper-right\n\t\t\tif (firstX + firstWidth > secondX - secondWidth && firstY - firstHeight < secondY + secondHeight)\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif (firstX < secondX && firstY < secondY){\n\t\t\t//Second shape is on the lower-shape\n\t\t\tif (firstX + firstWidth > secondX - secondWidth && firstY + firstHeight > secondY - secondHeight)\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif (firstX == secondX && firstY == secondY)\n\t\t\t//completely overlapped shapes\n\t\t\t\treturn true;\n\t\t\n\t\tif (firstX == secondX && firstY > secondY){\n\t\t\t//second shape is on top of the first one\n\t\t\tif (firstY - firstHeight < secondY + secondHeight)\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif (firstX < secondX && firstY == secondY){\n\t\t\t//second shape is on the right\n\t\t\tif (firstX + firstWidth > secondX - secondWidth)\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif (firstX == secondX && firstY < secondY){\n\t\t\t//second shape is on bottom of the first one\n\t\t\tif (firstY + firstHeight > secondY - secondHeight)\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif (firstX > secondX && firstY == secondY){\n\t\t\t//second shape is on the left\n\t\t\tif (firstX - firstWidth < secondX + secondWidth)\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\treturn false;\n\t}", "public boolean doIMoveToWorkPlace()\n\t{\n\t\t// if(myWorker.getPosition().getX() == destBuilding.getPosition().getX()\n\t\t// && myWorker.getPosition().getY() ==\n\t\t// destBuilding.getPosition().getY())\n\t\t// return false;\n\t\t// return true;\n\t\tObjectType workplaceType = destBuilding.getObjectType();\n\t\tPoint workplacePoint = destBuilding.getPosition();\n\t\tfor (int i = destBuilding.getPosition().getX(); i < destBuilding\n\t\t\t\t.getPosition().getX()\n\t\t\t\t+ getMyPlayer().getPlayerInfo().getBuildingSize()\n\t\t\t\t\t\t.get(workplaceType) - 1; i++)\n\t\t{\n\t\t\tif ((myWorker.getPosition().getX() == i && workplacePoint.getY() - 1 == myWorker\n\t\t\t\t\t.getPosition().getY())\n\t\t\t\t\t|| (myWorker.getPosition().getX() == i && workplacePoint\n\t\t\t\t\t\t\t.getY()\n\t\t\t\t\t\t\t+ getMyPlayer().getPlayerInfo().getBuildingSize()\n\t\t\t\t\t\t\t\t\t.get(workplaceType) == myWorker\n\t\t\t\t\t\t\t.getPosition().getY()))\n\t\t\t\treturn false;\n\t\t}\n\n\t\tfor (int i = destBuilding.getPosition().getY(); i < destBuilding\n\t\t\t\t.getPosition().getY()\n\t\t\t\t+ getMyPlayer().getPlayerInfo().getBuildingSize()\n\t\t\t\t\t\t.get(workplaceType) - 1; i++)\n\t\t{\n\t\t\tif ((myWorker.getPosition().getY() == i && workplacePoint.getX() - 1 == myWorker\n\t\t\t\t\t.getPosition().getX())\n\t\t\t\t\t|| (myWorker.getPosition().getY() == i && workplacePoint\n\t\t\t\t\t\t\t.getX()\n\t\t\t\t\t\t\t+ getMyPlayer().getPlayerInfo().getBuildingSize()\n\t\t\t\t\t\t\t\t\t.get(workplaceType) == myWorker\n\t\t\t\t\t\t\t.getPosition().getX()))\n\t\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}", "public List<Move> validMoves(){\n List<Move> results = new LinkedList<>();\n int kingVal = turn == WHITE ? WHITE_KING : BLACK_KING;\n int kingX = 0, kingY = 0;\n List<Piece> checks = null;\n kingSearch:\n for (int y = 0; y < 8; y++){\n for (int x = 0; x < 8; x++){\n if (board[y][x] == kingVal){\n kingX = x;\n kingY = y;\n checks = inCheck(x,y);\n break kingSearch;\n }\n }\n }\n if (checks.size() > 1){ // must move king\n for (int x = -1; x < 2; x++){\n for (int y = -1; y < 2; y++){\n if (kingX+x >= 0 && kingX + x < 8 && kingY+y >= 0 && kingY+y < 8){\n int val = board[kingY+y][kingX+x];\n if (val == 0 || turn == WHITE && val > WHITE_KING || turn == BLACK && val < BLACK_PAWN){\n // may still be a move into check, must test at end\n results.add(new Move(kingVal, kingX, kingY, kingX+x, kingY+y, val, 0, this));\n }\n }\n }\n }\n } else { // could be in check TODO: split into case of single check and none, identify pin/capture lines\n int queen = turn == WHITE ? WHITE_QUEEN : BLACK_QUEEN;\n int knight = turn == WHITE ? WHITE_KNIGHT : BLACK_KNIGHT;\n int rook = turn == WHITE ? WHITE_ROOK : BLACK_ROOK;\n int bishop = turn == WHITE ? WHITE_BISHOP : BLACK_BISHOP;\n for (int y = 0; y < 8; y++) {\n for (int x = 0; x < 8; x++) {\n int piece = board[y][x];\n if (piece == (turn == WHITE ? WHITE_PAWN : BLACK_PAWN)) { // pawns\n // regular | 2 move\n if (board[y+turn][x] == 0){\n if (y+turn == 0 || y + turn == 7){ // promotion\n results.add(new Move(piece, x, y, x, y + turn, 0, queen, this));\n results.add(new Move(piece, x, y, x, y + turn, 0, knight, this));\n results.add(new Move(piece, x, y, x, y + turn, 0, rook, this));\n results.add(new Move(piece, x, y, x, y + turn, 0, bishop, this));\n }\n else {\n results.add(new Move(piece, x, y, x, y + turn, 0, 0, this));\n if ((y == (turn == WHITE ? 1 : 6)) && board[y + 2 * turn][x] == 0) { // initial 2 move\n results.add(new Move(piece, x, y, x, y + 2*turn, 0, 0, this));\n }\n }\n }\n // capture\n for (int dx = -1; dx <= 1; dx += 2){\n if (x + dx >= 0 && x + dx < 8) {\n int val = board[y+turn][x+dx];\n if (val > 0 && (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n if (y + turn == 0 || y + turn == 7){ // promotion\n results.add(new Move(piece, x, y, x+dx, y + turn, val, queen, this));\n results.add(new Move(piece, x, y, x+dx, y + turn, val, knight, this));\n results.add(new Move(piece, x, y, x+dx, y + turn, val, rook, this));\n results.add(new Move(piece, x, y, x+dx, y + turn, val, bishop, this));\n } else {\n results.add(new Move(piece, x, y, x+dx, y + turn, val, 0, this));\n }\n }\n if (val == 0 && y == (turn == WHITE ? 4 : 3) && x+dx == enPassant){ // en passant\n results.add(new Move(piece, x, y, x+dx, y + turn, 0, 0, this));\n }\n }\n }\n\n } else if (piece == knight) { // knights TODO: lookup table\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -2; dy <= 2; dy += 4){\n if (x+dx >= 0 && x + dx < 8 && y + dy >= 0 && y + dy < 8){\n int val = board[y+dy][x+dx];\n if (val == 0 || (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n results.add(new Move(piece,x,y,x+dx,y+dy,val,0,this));\n }\n }\n if (x+dy >= 0 && x + dy < 8 && y + dx >= 0 && y + dx < 8){\n int val = board[y+dx][x+dy];\n if (val == 0 || (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n results.add(new Move(piece,x,y,x+dy,y+dx,val,0,this));\n }\n }\n }\n }\n } else if (piece == bishop) { // bishops\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -1; dy <= 1; dy += 2){\n int i = 1;\n while (x + dx*i >= 0 && x + dx*i < 8 && y + dy*i >= 0 && y + dy*i < 8){\n int val = board[y+dy*i][x+dx*i];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n } else if (piece == rook) { // rooks\n for (int dx = -1; dx <= 1; dx+= 2){\n for (int ax = 0; ax < 2; ax++){\n int i = 1;\n while (ax==0 ? y+dx*i >= 0 && y+dx*i < 8 : x+dx*i >= 0 && x+dx*i < 8){\n int val = board[y+dx*i*(1-ax)][x+dx*i*ax];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n } else if (piece == (turn == WHITE ? WHITE_QUEEN : BLACK_QUEEN)) { // queens\n // Diagonals - same as bishops\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -1; dy <= 1; dy += 2){\n int i = 1;\n while (x + dx*i >= 0 && x + dx*i < 8 && y + dy*i >= 0 && y + dy*i < 8){\n int val = board[y+dy*i][x+dx*i];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n for (int dx = -1; dx <= 1; dx+= 2){\n for (int ax = 0; ax < 2; ax++){\n int i = 1;\n while (ax==0 ? y+dx*i >= 0 && y+dx*i < 8 : x+dx*i >= 0 && x+dx*i < 8){\n int val = board[y+dx*i*(1-ax)][x+dx*i*ax];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n } else if (piece == (turn == WHITE ? WHITE_KING : BLACK_KING)) { // king\n for (int dx = -1; dx < 2; dx++){\n for (int dy = -1; dy < 2; dy++){\n if ((dx != 0 || dy != 0) && x+dx >= 0 && x + dx < 8 && y + dy >= 0 && y + dy < 8){\n int val = board[y+dy][x+dx];\n if (val == 0 || (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n results.add(new Move(piece,x,y,x+dx,y+dy,val,0,this));\n }\n }\n }\n }\n }\n }\n }\n // castle\n if (checks.size() == 0){\n if (turn == WHITE && (castles & 0b11) != 0){//(castles[0] || castles[1])){\n board[0][4] = 0; // remove king to avoid check test collisions with extra king\n if ((castles & WHITE_SHORT) != 0 && board[0][5] == 0 && board[0][6] == 0 && inCheck(5,0).size() == 0){\n //if (castles[0] && board[0][5] == 0 && board[0][6] == 0 && inCheck(5,0).size() == 0){\n results.add(new Move(WHITE_KING, 4, 0, 6, 0, 0, 0, this));\n }\n if ((castles & WHITE_LONG) != 0 && board[0][1] == 0 && board[0][2] == 0 && board[0][3] == 0 &&\n inCheck(3,0).size() == 0){\n //if (castles[1] && board[0][1] == 0 && board[0][2] == 0 && board[0][3] == 0 && inCheck(3,0).size() == 0){\n results.add(new Move(WHITE_KING, 4, 0, 2, 0, 0, 0, this));\n }\n board[0][4] = WHITE_KING;\n }else if (turn == BLACK && (castles & 0b1100) != 0){//(castles[2] || castles[3])) {\n board[7][4] = 0; // remove king to avoid check test collisions with extra king\n //if (castles[2] && board[7][5] == 0 && board[7][6] == 0 && inCheck(5, 7).size() == 0) {\n if ((castles & BLACK_SHORT) != 0 && board[7][5] == 0 && board[7][6] == 0 && inCheck(5, 7).size() == 0) {\n results.add(new Move(BLACK_KING, 4, 7, 6, 7, 0, 0, this));\n }\n //if (castles[3] && board[7][1] == 0 && board[7][2] == 0 && board[7][3] == 0 && inCheck(3, 7).size() == 0) {\n if ((castles & BLACK_LONG) != 0 && board[7][1] == 0 && board[7][2] == 0 && board[7][3] == 0 &&\n inCheck(3, 7).size() == 0) {\n results.add(new Move(BLACK_KING, 4, 7, 2, 7, 0, 0, this));\n }\n board[7][4] = BLACK_KING;\n }\n }\n }\n List<Move> fullLegal = new LinkedList<>();\n for (Move m : results){\n makeMove(m);\n turn = -turn;\n if (m.piece == WHITE_KING || m.piece == BLACK_KING){\n if (inCheck(m.toX,m.toY).size() == 0){\n fullLegal.add(m);\n }\n }else if (inCheck(kingX,kingY).size() == 0){\n fullLegal.add(m);\n }\n turn = -turn;\n undoMove(m);\n }\n Collections.sort(fullLegal, (o1, o2) -> o2.score - o1.score); // greatest score treated as least so appears first\n return fullLegal;\n }", "private boolean compareFile(java.io.FileInputStream r25, java.io.FileInputStream r26) {\n /*\n r24 = this;\n r7 = 5;\n r8 = 128; // 0x80 float:1.794E-43 double:6.32E-322;\n r2 = 0;\n r21 = r25.getChannel();\t Catch:{ IOException -> 0x00ce }\n r22 = r21.size();\t Catch:{ IOException -> 0x00ce }\n r0 = r22;\n r0 = (int) r0;\t Catch:{ IOException -> 0x00ce }\n r19 = r0;\n r21 = r26.getChannel();\t Catch:{ IOException -> 0x00ce }\n r22 = r21.size();\t Catch:{ IOException -> 0x00ce }\n r0 = r22;\n r9 = (int) r0;\n r0 = r19;\n if (r0 != r9) goto L_0x002e;\n L_0x0020:\n r21 = 1;\n r0 = r19;\n r1 = r21;\n if (r0 < r1) goto L_0x002e;\n L_0x0028:\n r21 = 1;\n r0 = r21;\n if (r9 >= r0) goto L_0x003c;\n L_0x002e:\n r21 = 0;\n r25.close();\t Catch:{ IOException -> 0x0037 }\n r26.close();\t Catch:{ IOException -> 0x0037 }\n L_0x0036:\n return r21;\n L_0x0037:\n r11 = move-exception;\n r11.printStackTrace();\n goto L_0x0036;\n L_0x003c:\n r21 = 128; // 0x80 float:1.794E-43 double:6.32E-322;\n r0 = r19;\n r1 = r21;\n if (r0 > r1) goto L_0x00b4;\n L_0x0044:\n r6 = r19;\n L_0x0046:\n r20 = r19 / r6;\n r21 = 5;\n r0 = r20;\n r1 = r21;\n if (r0 < r1) goto L_0x00b7;\n L_0x0050:\n r14 = 5;\n L_0x0051:\n r21 = r6 * r14;\n r20 = r19 - r21;\n r15 = r20 / r14;\n r3 = 1;\n r5 = 0;\n r4 = 0;\n r16 = 0;\n r0 = new byte[r6];\t Catch:{ IOException -> 0x00ce }\n r18 = r0;\n r0 = new byte[r6];\t Catch:{ IOException -> 0x00ce }\n r17 = r0;\n r5 = new java.io.BufferedInputStream;\t Catch:{ IOException -> 0x00ce }\n r0 = r25;\n r5.<init>(r0);\t Catch:{ IOException -> 0x00ce }\n r4 = new java.io.BufferedInputStream;\t Catch:{ IOException -> 0x00ce }\n r0 = r26;\n r4.<init>(r0);\t Catch:{ IOException -> 0x00ce }\n r12 = 0;\n L_0x0073:\n if (r12 >= r14) goto L_0x00bf;\n L_0x0075:\n if (r3 == 0) goto L_0x00bf;\n L_0x0077:\n r21 = 0;\n r0 = r18;\n r1 = r21;\n r5.read(r0, r1, r6);\t Catch:{ IOException -> 0x00ce }\n r21 = 0;\n r0 = r17;\n r1 = r21;\n r4.read(r0, r1, r6);\t Catch:{ IOException -> 0x00ce }\n r21 = r6 + r15;\n r16 = r16 + r21;\n r0 = r16;\n r0 = (long) r0;\t Catch:{ IOException -> 0x00ce }\n r22 = r0;\n r0 = r22;\n r5.skip(r0);\t Catch:{ IOException -> 0x00ce }\n r0 = r16;\n r0 = (long) r0;\t Catch:{ IOException -> 0x00ce }\n r22 = r0;\n r0 = r22;\n r4.skip(r0);\t Catch:{ IOException -> 0x00ce }\n r13 = 0;\n L_0x00a2:\n if (r13 >= r6) goto L_0x00bc;\n L_0x00a4:\n if (r3 == 0) goto L_0x00bc;\n L_0x00a6:\n r21 = r18[r13];\t Catch:{ IOException -> 0x00ce }\n r22 = r17[r13];\t Catch:{ IOException -> 0x00ce }\n r0 = r21;\n r1 = r22;\n if (r0 != r1) goto L_0x00ba;\n L_0x00b0:\n r2 = 1;\n L_0x00b1:\n r13 = r13 + 1;\n goto L_0x00a2;\n L_0x00b4:\n r6 = 128; // 0x80 float:1.794E-43 double:6.32E-322;\n goto L_0x0046;\n L_0x00b7:\n r14 = r20;\n goto L_0x0051;\n L_0x00ba:\n r2 = 0;\n goto L_0x00b1;\n L_0x00bc:\n r12 = r12 + 1;\n goto L_0x0073;\n L_0x00bf:\n r25.close();\t Catch:{ IOException -> 0x00c9 }\n r26.close();\t Catch:{ IOException -> 0x00c9 }\n L_0x00c5:\n r21 = r2;\n goto L_0x0036;\n L_0x00c9:\n r11 = move-exception;\n r11.printStackTrace();\n goto L_0x00c5;\n L_0x00ce:\n r10 = move-exception;\n r10.printStackTrace();\t Catch:{ all -> 0x00df }\n r2 = 0;\n r25.close();\t Catch:{ IOException -> 0x00da }\n r26.close();\t Catch:{ IOException -> 0x00da }\n goto L_0x00c5;\n L_0x00da:\n r11 = move-exception;\n r11.printStackTrace();\n goto L_0x00c5;\n L_0x00df:\n r21 = move-exception;\n r25.close();\t Catch:{ IOException -> 0x00e7 }\n r26.close();\t Catch:{ IOException -> 0x00e7 }\n L_0x00e6:\n throw r21;\n L_0x00e7:\n r11 = move-exception;\n r11.printStackTrace();\n goto L_0x00e6;\n */\n throw new UnsupportedOperationException(\"Method not decompiled: android.sec.clipboard.data.list.ClipboardDataBitmap.compareFile(java.io.FileInputStream, java.io.FileInputStream):boolean\");\n }", "public int runFromMuckrakerMove() throws GameActionException {\n\n //flag indicates best direction to move, not direction I am moving...\n\n boolean foundEnemyMuckraker = false;\n double rewardOfStaying = 9999;\n\n int canMoveIndicesSize = 0;\n int idx = 0;\n for (Direction direction : Constants.DIRECTIONS) {\n moveRewards[idx] = 9998;\n moveLocs[idx] = Cache.CURRENT_LOCATION.add(direction);\n if (controller.canMove(direction)) {\n canMoveIndices[canMoveIndicesSize++] = idx;\n }\n ++idx;\n }\n\n for (RobotInfo robotInfo : Cache.ALL_NEARBY_ENEMY_ROBOTS) {\n if (robotInfo.getType() == RobotType.MUCKRAKER) {\n foundEnemyMuckraker = true;\n MapLocation enemyLocation = robotInfo.location;\n //for all valid locations, find travelDistance...\n rewardOfStaying = Math.min(rewardOfStaying, Pathfinding.travelDistance(Cache.CURRENT_LOCATION, enemyLocation) + 0.01 * Cache.CURRENT_LOCATION.distanceSquaredTo(enemyLocation));\n for (int i = 0; i < idx; ++i) {\n moveRewards[i] = Math.min(moveRewards[i], Pathfinding.travelDistance(moveLocs[i], enemyLocation) + 0.01 * moveLocs[i].distanceSquaredTo(enemyLocation));\n }\n }\n }\n\n int flag = CommunicationMovement.encodeMovement(true, true, CommunicationMovement.MY_UNIT_TYPE.SL, CommunicationMovement.MOVEMENT_BOTS_DATA.NOT_MOVING, CommunicationMovement.COMMUNICATION_TO_OTHER_BOTS.NOOP, false, false, 0);\n int bestValidDirection = -1;\n double bestValidReward = rewardOfStaying;\n\n if (foundEnemyMuckraker) {\n int bestDirection = -1;\n double bestReward = rewardOfStaying;\n\n for (int i = 0; i < idx; ++i) {\n if (moveRewards[i] > bestReward) { //find the best direction based on the reward\n bestDirection = i;\n bestReward = moveRewards[i];\n }\n }\n\n /* MOVE TOWARDS ME IS SET SO POLITICANS CAN MOVE TOWARDS THIS BOT (NOT SLANDERERS) -> BE CAREFUL IF/WHEN PARSING THIS SETTING */\n flag = CommunicationMovement.encodeMovement(true, true, CommunicationMovement.MY_UNIT_TYPE.SL, CommunicationMovement.convert_DirectionInt_MovementBotsData(bestDirection), CommunicationMovement.COMMUNICATION_TO_OTHER_BOTS.MOVE_TOWARDS_ME, false, true, 0);\n\n for (int i = 0; i < canMoveIndicesSize; ++i) {\n if (moveRewards[canMoveIndices[i]] > bestValidReward) {\n bestValidDirection = canMoveIndices[i];\n bestValidReward = moveRewards[canMoveIndices[i]];\n }\n }\n }\n\n // if a politician or slanderer has both a muckraker and slanderer in range, then run away opposite of the danger direction\n int bestDirectionBasedOnPoliticianDangerIdx = -1;\n if (!foundEnemyMuckraker) {\n for (RobotInfo robotInfo : Cache.ALL_NEARBY_FRIENDLY_ROBOTS) {\n if (robotInfo.getType() == RobotType.POLITICIAN || robotInfo.getType() == RobotType.MUCKRAKER) {\n\n if (controller.canGetFlag(robotInfo.ID)) {\n int encodedFlag = controller.getFlag(robotInfo.ID);\n if (CommunicationMovement.decodeIsSchemaType(encodedFlag) &&\n CommunicationMovement.decodeIsDangerBit(encodedFlag)) {\n\n if (CommunicationMovement.decodeMyUnitType(encodedFlag) == CommunicationMovement.MY_UNIT_TYPE.PO\n || CommunicationMovement.decodeMyUnitType(encodedFlag) == CommunicationMovement.MY_UNIT_TYPE.MU) {\n //A POLITICIAN OR MUCKRAKER WHO SAYS HE IS IN DANGER (enemy muckraker nearby)\n CommunicationMovement.MOVEMENT_BOTS_DATA badArea = CommunicationMovement.decodeMyPreferredMovement(encodedFlag);\n int badIdx = CommunicationMovement.convert_MovementBotData_DirectionInt(badArea);\n Direction bestDirection = Constants.DIRECTIONS[badIdx].opposite();\n bestDirectionBasedOnPoliticianDangerIdx = bestDirection.ordinal();\n break;\n }\n }\n }\n }\n }\n }\n\n /* Set communication for other slanderers if there is a muckraker within my range */\n if (!Comms.hasSetFlag && controller.canSetFlag(flag)) {\n Comms.hasSetFlag = true;\n controller.setFlag(flag);\n }\n\n /* Below is based on movement */\n if (!controller.isReady()) return 1;\n\n if (foundEnemyMuckraker) {\n if (bestValidDirection != -1) {\n controller.move(Constants.DIRECTIONS[bestValidDirection]);\n return 2;\n }\n return 1;\n }\n\n\n /* No muckrakers were found, so we need to check the flags of nearby slanderer units instead. */\n double closestLocation = 9998;\n int preferedMovementDirectionIdx = -1;\n\n for (RobotInfo robotInfo : Cache.ALL_NEARBY_FRIENDLY_ROBOTS) {\n if (robotInfo.getType() == RobotType.POLITICIAN) { //SLANDERERS THINK ALL SLANDERERS ARE POLITICIANS, so we need to check politicians here...\n double dist = Pathfinding.travelDistance(Cache.CURRENT_LOCATION, robotInfo.location)\n + 0.01 * Cache.CURRENT_LOCATION.distanceSquaredTo(robotInfo.location);\n if (dist < closestLocation && controller.canGetFlag(robotInfo.ID)) { //the closest bot in danger to us is our biggest threat as well\n int encodedFlag = controller.getFlag(robotInfo.ID);\n\n if (CommunicationMovement.decodeIsSchemaType(encodedFlag)) {\n if (CommunicationMovement.decodeMyUnitType(encodedFlag) == CommunicationMovement.MY_UNIT_TYPE.SL && CommunicationMovement.decodeIsDangerBit(encodedFlag)) {\n CommunicationMovement.MOVEMENT_BOTS_DATA movementBotsData = CommunicationMovement.decodeMyPreferredMovement(encodedFlag);\n preferedMovementDirectionIdx = CommunicationMovement.convert_MovementBotData_DirectionInt(movementBotsData);\n closestLocation = dist;\n }\n }\n }\n }\n }\n\n if (preferedMovementDirectionIdx != -1) {\n Direction direction = Pathfinding.toMovePreferredDirection(Constants.DIRECTIONS[preferedMovementDirectionIdx], 1);\n if (direction != null) {\n controller.move(direction);\n return 2;\n }\n return 1;\n }\n\n if (bestDirectionBasedOnPoliticianDangerIdx != -1) {\n Direction direction = Pathfinding.toMovePreferredDirection(Constants.DIRECTIONS[bestDirectionBasedOnPoliticianDangerIdx], 1);\n if (direction != null) {\n controller.move(direction);\n return 2;\n }\n return 1;\n }\n\n return 0; // no reason whatsoever to move\n }", "public boolean movePlayer(MazePlayer p, Direction d) {\n//\t System.out.println(\"Player \"+p.name+\" requests to move in direction \"+d);\n// players can move through walls with some small probability!\n\t\t // calculate the new position after the move \n\t\t MazePosition oldPos = playerPosition.get(p.name);\n\t\t MazePosition newPos = theBoard.tryMove(oldPos,d);\n\n\t\t \n\t\t //make sure there is no other player at that position\n\t\t // and if there is someone there then just return without moving\n\t\t if (playerPosition.containsValue(newPos)){\n\t\t\t if (!newPos.equals(oldPos))\n\t\t\t\t if (debugging) System.out.println(\"player \"+p.name+\" tried to move into an occupied space.\");\n\t\t\t else\n\t\t\t\t if (debugging) System.out.println(p.name+\" stays at \"+oldPos);\n\t\t\t return false;\n\t\t }\n\t\t \n\t\t //otherwise, make the move\n\t\t playerPosition.put(p.name,newPos);\n\t\t if (debugging) System.out.println(p.name+\": \"+oldPos+\" -> \"+newPos);\n\t\t \n\t\t //take off points if you moved through a wall\n\t\t if (!theBoard.canMove(oldPos,d)){\n\t\t\t score.put(p.name,score.get(p.name)-2);\n\t\t\t if (debugging) System.out.println(p.name+\" moved through a wall\");\n\t\t }\n\t\t \n\t\t // mark that old space as \"free space\"\n\t\t freeSpace.add(0,oldPos);\n\t\t \n\t\t // check to see if there is a jewel in the new position.\n\t\t int i = jewelPosition.indexOf(newPos);\n\t\t if (i > -1) {\n\t\t\t // add 5 to the score\n\t\t\t score.put(p.name,score.get(p.name)+5);\n\t\t\t // remove the jewel\n\t\t\t jewelPosition.remove(i);\n\t\t\t if (debugging) System.out.println(\"and lands on a jewel!, score is now \" +score.get(p.name));\n\t\t\t // add another jewel\n\t\t\t MazePosition q = getEmptySpace();\n\t\t\t jewelPosition.add(q);\n\t\t\t if (debugging) System.out.println(\"adding a new jewel at \"+q);\n\t\t\t \n\t\t }\n\t\t else {\n\t\t\t // if no jewel, then remove the space from the freeSpace list\n\t\t\t freeSpace.remove(newPos);\n\t\t }\n\t\t return true;\n\n }", "public static List<MapTile> findPath(MovableObject mO, GameObject destination) {\n List<MapTile> openList = new LinkedList<>();\n List<MapTile> closedList = new LinkedList<>();\n List<MapTile> neighbours = new ArrayList<>();\n Point objectTileCoord = mO.getGridCoordinates();\n Point destinationTileCoord = destination.getGridCoordinates();\n MapTile currentTile;\n try {\n currentTile = mapGrid.mapGrid[objectTileCoord.x][objectTileCoord.y];\n } catch (ArrayIndexOutOfBoundsException e) {\n System.out.print(\"Error while getting current tile for pathfinding. Trying to adapt coords.\");\n if (mO.getX() >= MapManager.getWorldWidth()) {\n objectTileCoord.x -= 1;\n }\n if (mO.getY() >= MapManager.getWorldHeight()) {\n objectTileCoord.y -= 1;\n }\n if (mO.getY() >= MapManager.getWorldHeight() && mO.getX() >= MapManager.getWorldWidth()) {\n objectTileCoord.x -= 1;\n objectTileCoord.y -= 1;\n }\n currentTile = mapGrid.mapGrid[objectTileCoord.x][objectTileCoord.y];\n }\n\n currentTile.setParentMapTile(null);\n currentTile.totalMovementCost = 0;\n openList.add(currentTile);\n\n boolean notDone = true;\n\n while (notDone) {\n neighbours.clear();\n currentTile = getLowestCostTileFromOpenList(openList, currentTile);\n closedList.add(currentTile);\n openList.remove(currentTile);\n\n //ReachedGoal?\n if ((currentTile.xTileCoord == destinationTileCoord.x) && (currentTile.yTileCoord == destinationTileCoord.y)) {\n try {\n return getResultListOfMapTiles(currentTile);\n } catch (Exception e) {\n System.out.println(\"closed list size: \" + closedList.size());\n throw e;\n }\n }\n\n neighbours.addAll(currentTile.getNeighbourTiles());\n neighbours.removeAll(closedList);\n\n for (MapTile mapTile : neighbours) {\n if (openList.contains(mapTile)) {\n // compare total movement costs.\n if (mapTile.totalMovementCost > currentTile.getMovementCostToTile(mapTile) + currentTile.totalMovementCost) {\n mapTile.setParentMapTile(currentTile);\n mapTile.totalMovementCost = currentTile.getMovementCostToTile(mapTile) + currentTile.totalMovementCost;\n }\n } else {\n mapTile.setParentMapTile(currentTile);\n mapTile.totalMovementCost = currentTile.totalMovementCost + currentTile.getMovementCostToTile(mapTile);\n openList.add(mapTile);\n }\n }\n }\n return null;\n }", "void scanafter() {\n\t\tint oldline, newline;\n\n\t\tfor (newline = 0; newline <= newinfo.maxLine; newline++) {\n\t\t\toldline = newinfo.other[newline];\n\t\t\tif (oldline >= 0) { /* is unique in old & new */\n\t\t\t\tfor (;;) { /* scan after there in both files */\n\t\t\t\t\tif (++oldline > oldinfo.maxLine)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tif (oldinfo.other[oldline] >= 0)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tif (++newline > newinfo.maxLine)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tif (newinfo.other[newline] >= 0)\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t/*\n\t\t\t\t\t * oldline & newline exist, and aren't already matched\n\t\t\t\t\t */\n\n\t\t\t\t\tif (newinfo.symbol[newline] != oldinfo.symbol[oldline])\n\t\t\t\t\t\tbreak; // not same\n\n\t\t\t\t\tnewinfo.other[newline] = oldline; // record a match\n\t\t\t\t\toldinfo.other[oldline] = newline;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "public List<Blockade> move(PlayingPiece playingPiece, List<Card> cards, HexSpace moveTo) {\n System.out.println(\"Executing move\");\n System.out.println(myTurn());\n\n // is it the players turn\n if (!myTurn()) {\n return new ArrayList<>();\n }\n // are the cards in the hand\n for (Card card : cards) {\n if (!this.handPile.contains(card)) {\n System.out.println(\"hand wrong\");\n return new ArrayList<>();\n }\n }\n // does the player own this playingpiece\n if (!this.playingPieces.contains(playingPiece)) {\n return new ArrayList<>();\n }\n this.removableBlockades = new ArrayList<>(); // parentblockadesID the player can remove in this turn\n Memento memento = board.getMemento();\n // validates if cards and playingpieces are the same for wich the pathfinder was exectued, if not redo pathfinder\n if (!(playingPiece == memento.getPlayingPiece() && cards.equals(memento.getSelectedCards()))) {\n Pathfinder.getWay(board, cards, playingPiece);\n }\n Set<HexSpace> reachables = new HashSet<>(memento.getReachables());\n System.out.println(reachables);\n if (reachables.contains(moveTo)) {\n System.out.println(\"reachables Contains moveto\");\n HexSpace oldPosition = playingPiece.getStandsOn();\n playingPiece.setStandsOn(moveTo);\n for (Card card : cards) {\n card.moveAction(this, moveTo); // for history\n }\n for (HexSpace hexSpace : moveTo.getPrevious()) {\n if (hexSpace.getClass() == BlockadeSpace.class && hexSpace.getStrength() != 0) {\n // if you directly move over blockade\n autoRemoveBlockade(((BlockadeSpace) hexSpace).getParentBlockade());\n }\n }\n searchForRemovableBlockades(playingPiece, cards, moveTo, oldPosition);\n this.board.getMemento().reset(this.board); // reset memento after moving\n }\n if (playingPiece.getStandsOn().getColor() == COLOR.ENDFIELDJUNGLE ||\n playingPiece.getStandsOn().getColor() == COLOR.ENDFIELDRIVER) {\n if (board.getElDoradoSpaces().size() > 0) {\n playingPiece.setStandsOn(board.getElDoradoSpaces().get(0));\n board.getElDoradoSpaces().remove(board.getElDoradoSpaces().get(0));\n //List<HexSpace> newEldoradoSpaces = board.getElDoradoSpaces().subList(0,Math.max(board.getElDoradoSpaces().size()-2,0));\n //board.setElDoradoSpaces(newEldoradoSpaces);\n }\n boolean won = true;\n for (PlayingPiece piece : this.playingPieces) {\n won = won && (piece.getStandsOn().getColor() == COLOR.ELDORADO || piece == playingPiece);\n }\n if (won) {\n this.board.getWinners().add(this);\n }\n }\n return new ArrayList<>(blockadeIdsToBlockades(this.removableBlockades));\n }", "public void Stop(Player player){\r\n \r\n if (Players.size()==1)\r\n {\r\n enddate=new Date();\r\n //write the result in a file \r\n //read the last game id and plus it with 1\r\n int gameID=0;\r\n String result=\"\";\r\n boolean playerwin=false;\r\n File f = new File(new File(\"\").getAbsolutePath() + \"\\\\src\\\\projectafterupdatev1\\\\pkg2\\\\GameRecords\");\r\n ObjectInputStream obj=null;\r\n try {\r\n obj = new ObjectInputStream(new FileInputStream(f));\r\n } catch (IOException ex) {System.out.println(\"exeption for newing the obj in game id initllize\");}\r\n while (true) {\r\n try {\r\n\r\n FinishedGameRecord temp = (FinishedGameRecord) obj.readObject();\r\n gameID=temp.gameID;\r\n } catch (EOFException e) {\r\n try {\r\n obj.close();\r\n } catch (IOException ex) {}\r\n break;\r\n } catch (IOException ex) {System.out.println(\"gameID initlizing IOE error\"); \r\n } catch (ClassNotFoundException ex) {System.out.println(\"gameID initlizing Class not found error\");\r\n }\r\n }\r\n \r\n gameID++;\r\n if (Objects.equals(Players.get(0).name, new String(\"Random PC\")))\r\n {\r\n result=\"PC Win\";\r\n \r\n }else\r\n {\r\n playerwin=true;\r\n result=Players.get(0).name+\" Win\";\r\n }\r\n //insert the new game record \r\n FinishedGameRecord lastscore=new FinishedGameRecord(playername,\"Random PC\",startdate,enddate,gameID,result);\r\n try {\r\n FileOutputStream os=new FileOutputStream(new File(new File(\"\").getAbsoluteFile()+\"\\\\src\\\\projectafterupdatev1\\\\pkg2\\\\GameRecords\"),true);\r\n AppendingObjectOutputStream obj2=new AppendingObjectOutputStream(os);\r\n \r\n obj2.writeObject(lastscore);\r\n \r\n obj2.close();\r\n os.close();\r\n } catch (FileNotFoundException ex) {System.out.println(\"writeing finished game record 111a\");} \r\n catch (IOException ex){System.out.println(\"111b\");}\r\n \r\n //writing to the score board \r\n \r\n File f3 = new File(new File(\"\").getAbsolutePath() + \"\\\\src\\\\projectafterupdatev1\\\\pkg2\\\\ScoreBoard\");\r\n try {\r\n AppendingObjectOutputStream obj4sore=new AppendingObjectOutputStream(new FileOutputStream(f3,true));\r\n \r\n obj4sore.writeObject(new ScoreRecord(playername, playerwin));\r\n \r\n obj4sore.close();\r\n } catch (FileNotFoundException ex) {System.out.println(\"File not Found obj 4 score\");\r\n } catch (IOException ex) {System.out.println(\"IOEexception obj4score\");\r\n }\r\n \r\n \r\n //insert the toturial records\r\n File f2 = new File(new File(\"\").getAbsolutePath() + \"\\\\src\\\\projectafterupdatev1\\\\pkg2\\\\ToturialFile\");\r\n try {\r\n \r\n AppendingObjectOutputStream obj3=new AppendingObjectOutputStream(new FileOutputStream(f2,true));\r\n WritableToturialClass temp=new WritableToturialClass();\r\n temp.Initlize(moves.size());\r\n temp.gameID=gameID;\r\n temp.grid=boarddata;\r\n temp.note=notedata;\r\n temp.header=boardsheader;\r\n for(int i=0;i<moves.size();i++){\r\n temp.add(moves.get(i).nameoftheattacker, moves.get(i).xaxis, moves.get(i).xaxis,moves.get(i).date);\r\n moves.get(i);\r\n }\r\n obj3.writeObject(temp);\r\n obj3.close();\r\n } catch (FileNotFoundException ex) {System.out.println(\"File not Found obj 3 \");\r\n } catch (IOException ex) {System.out.println(\"IOEexception obj3\");\r\n }\r\n //end of the adding operations\r\n \r\n WinnerDisplay win=new WinnerDisplay();\r\n win.setWinner(Players.get(0).name);\r\n //make the list disappear before the saving shit happen\r\n playerboard.repaintafterupdate();\r\n playerboard.setVisible(false);\r\n win.setLocation(500,300);\r\n win.setVisible(true);\r\n music.StopTheMusic();\r\n music.PlayWinner();\r\n \r\n \r\n }\r\n }", "@Override\r\n boolean isValidSpecialMove(final int newX, final int newY) {\r\n int xDisplacement = newX - getXLocation();\r\n int yDisplacement = newY - getYLocation();\r\n if (isValidRookMove(xDisplacement, yDisplacement)) {\r\n // Total number of steps the piece has to take.\r\n //Either x = 0 or y = 0.\r\n int steps = Math.max(Math.abs(xDisplacement),\r\n Math.abs(yDisplacement));\r\n int xDirection = xDisplacement / steps;\r\n int yDirection = yDisplacement / steps;\r\n // Check for obstacles in path of Rook.\r\n for (int i = 1; i < steps; i++) {\r\n ChessSquare squareToCheck = getCurrentBoard().getSquaresList()\r\n [getXLocation() + i * xDirection]\r\n [getYLocation() + i * yDirection];\r\n if (squareToCheck.getIsOccupied()) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n return false;\r\n\r\n }", "private boolean canIGenerateNextRound() {\n\t\tint totalRounds = mTournament.getTotalRounds();\n\t\tint currentRouns = mTournament.getRounds().size();\n\n\t\tList<Integer> roundNumbers = new ArrayList<>();\n\t\tfor (ChesspairingRound round : mTournament.getRounds()) {\n\t\t\tif (roundNumbers.contains(round.getRoundNumber())) {\n\t\t\t\t// you have 2 rounds with the same id\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\troundNumbers.add(round.getRoundNumber());\n\t\t}\n\n\t\tif (currentRouns < totalRounds) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}", "@Test\r\n\tpublic void testWolfResultsReader() {\r\n\t\tString name = \"Krispy Kreme Challenge\";\r\n\t\tDouble dist = 5.0;\r\n\t\tLocalDate ld = LocalDate.parse(\"2018-02-18\");\r\n\t\tString location = \"Raleigh, NC\";\r\n\r\n\t\tRace r = new Race(name, dist, ld, location);\r\n\t\tString pName = \"BILLY FETZNER\";\r\n\t\tint age = 24;\r\n\t\tRaceTime time = new RaceTime(0, 11, 51);\r\n\t\tIndividualResult ir = new IndividualResult(r, pName, age, time);\r\n\r\n\t\tString pName2 = \"STEPHEN HENKEL\";\r\n\t\tint age2 = 21;\r\n\t\tRaceTime time2 = new RaceTime(0, 12, 02);\r\n\t\tIndividualResult ir2 = new IndividualResult(r, pName2, age2, time2);\r\n\r\n\t\tr.addIndividualResult(ir);\r\n\t\tr.addIndividualResult(ir2);\r\n\r\n\t\tRaceList rl = new RaceList();\r\n\t\trl.addRace(r);\r\n\r\n\t\tRaceList rl2 = WolfResultsReader.readRaceListFile(\"test-files/wolf_results_actual.md\");\r\n\r\n\t\tfor (int i = 0; i < rl.size(); i++) {\r\n\t\t\tRace race1 = rl.getRace(i);\r\n\t\t\tRace race2 = rl2.getRace(i);\r\n\t\t\tassertTrue(race1.equals(race2));\r\n\t\t\tassertEquals(race1.getResults().getResult(0).getAge(), race2.getResults().getResult(0).getAge());\r\n\t\t\tassertEquals(race1.getResults().getResult(0).getName(), race2.getResults().getResult(0).getName());\r\n\t\t\tassertEquals(0,\r\n\t\t\t\t\trace1.getResults().getResult(0).getTime().compareTo(race2.getResults().getResult(0).getTime()));\r\n\t\t\tassertEquals(0,\r\n\t\t\t\t\trace1.getResults().getResult(0).getPace().compareTo(race2.getResults().getResult(0).getPace()));\r\n\r\n\t\t\tassertEquals(race1.getResults().getResult(1).getAge(), race2.getResults().getResult(1).getAge());\r\n\t\t\tassertEquals(race1.getResults().getResult(1).getName(), race2.getResults().getResult(1).getName());\r\n\t\t\tassertEquals(0,\r\n\t\t\t\t\trace1.getResults().getResult(1).getTime().compareTo(race2.getResults().getResult(1).getTime()));\r\n\t\t\tassertEquals(0,\r\n\t\t\t\t\trace1.getResults().getResult(1).getPace().compareTo(race2.getResults().getResult(1).getPace()));\r\n\r\n\t\t}\r\n\r\n\t\t// test a bunch of invalid files\r\n\t\ttry {\r\n\t\t\trl2 = WolfResultsReader.readRaceListFile(\"test-files/iv1.md\");\r\n\t\t\tfail();\r\n\t\t} catch (IllegalArgumentException e) {\r\n\t\t\tSystem.out.println(\"Invalid file\");\r\n\t\t}\r\n\t\ttry {\r\n\t\t\trl2 = WolfResultsReader.readRaceListFile(\"test-files/iv2.md\");\r\n\t\t\tfail();\r\n\t\t} catch (IllegalArgumentException e) {\r\n\t\t\tSystem.out.println(\"Invalid file\");\r\n\t\t}\r\n\t\ttry {\r\n\t\t\trl2 = WolfResultsReader.readRaceListFile(\"test-files/iv3.md\");\r\n\t\t\tfail();\r\n\t\t} catch (IllegalArgumentException e) {\r\n\t\t\tSystem.out.println(\"Invalid file\");\r\n\t\t}\r\n\t\ttry {\r\n\t\t\trl2 = WolfResultsReader.readRaceListFile(\"test-files/iv4.md\");\r\n\t\t\tfail();\r\n\t\t} catch (IllegalArgumentException e) {\r\n\t\t\tSystem.out.println(\"Invalid file 4\");\r\n\r\n\t\t}\r\n\t\ttry {\r\n\t\t\trl2 = WolfResultsReader.readRaceListFile(\"test-files/iv5.md\");\r\n\t\t} catch (IllegalArgumentException e) {\r\n\t\t\t//\r\n\t\t}\r\n\t\ttry {\r\n\t\t\trl2 = WolfResultsReader.readRaceListFile(\"test-files/iv6.md\");\r\n\t\t} catch (IllegalArgumentException e) {\r\n\t\t\t//\r\n\t\t}\r\n\t\ttry {\r\n\t\t\trl2 = WolfResultsReader.readRaceListFile(\"test-files/iv7.md\");\r\n\t\t} catch (IllegalArgumentException e) {\r\n\t\t\t//\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\trl2 = WolfResultsReader.readRaceListFile(\"test-files/iv8.md\");\r\n\t\t} catch (IllegalArgumentException e) {\r\n\t\t\t//\r\n\t\t}\r\n//\t\ttry {\r\n//\t\t\tRaceList rl3 = WolfResultsReader.readRaceListFile(\"test-files/iv10.md\");\r\n//\t\t\tfail();\r\n//\t\t} catch (IllegalArgumentException e) {\r\n//\t\t\t//\r\n//\t\t}\r\n\t\ttry {\r\n\t\t\trl2 = WolfResultsReader.readRaceListFile(\"test-files/iv11.md\");\r\n\t\t\tfail();\r\n\t\t} catch (IllegalArgumentException e) {\r\n\t\t\t//\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\trl2 = WolfResultsReader.readRaceListFile(\"test-files/iv12.md\");\r\n\t\t} catch (IllegalArgumentException e) {\r\n\t\t\tSystem.out.println(e.getMessage());\r\n\t\t}\r\n\r\n\t}", "public static void calculateOwnership(BoardModel model) {\n for (int r = 0; r < 10; r++) {\n for (int c = 0; c < 10; c++) {\n if (model.getTile(r, c).equals(POS_AVAILABLE)) {\n int smallestMoves = 100;\n String closestQueen = \"\";\n for (int i = 0; i < 8; i++) {\n int[][] currentQueenArray = queenMoves(model.queenPositions.get(i), model);\n\n if (currentQueenArray[r][c] < smallestMoves && currentQueenArray[r][c] > 0) {\n smallestMoves = currentQueenArray[r][c];\n closestQueen = model.getTile(model.queenPositions.get(i));\n } else if (currentQueenArray[r][c] == smallestMoves && currentQueenArray[r][c] > 0 && !closestQueen.equals(model.getTile(model.queenPositions.get(i)))) {\n closestQueen = \"noone\";\n } else if (currentQueenArray[r][c] == smallestMoves && currentQueenArray[r][c] > 0 && closestQueen.equals(model.getTile(model.queenPositions.get(i)))) {\n closestQueen = model.getTile(model.queenPositions.get(i));\n }\n }\n\n ownedBy[r][c] = closestQueen;\n } \n else {\n ownedBy[r][c] = \"????\";\n // ownedBy[r][c] = model.getTile(new int[]{r, c});\n }\n }\n }\n }", "public boolean canCastle(int direction){\n\t\tPiece rook;\n\t\t\n\t\tif(!((getColor().equals(\"White\") && getSquare().getCol() == 4 && getSquare().getRow() == 7 ) ||\n\t\t\t\t(getColor().equals(\"Black\") && getSquare().getCol() == 4 && getSquare().getRow() == 0 )))\n\t\t\treturn false;\n\t\t\n\t\t\n\t\tif(direction == 1){\n\t\t\trook = getSquare().getEast().getEast().getEast().getOccupant();\n\t\t\tif(rook == null || !rook.getColor().equals(this.getColor()) || !rook.getType().equals(\"Rook\") || rook.hasMoved() || this.hasMoved())\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getEast().getEast().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getEast().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\t\n\t\t\tif(getColor().equals(\"White\")){\n\t\t\t\tfor(int i = 0; i < ChessBoard.getPieces().size(); i++){\n\t\t\t\t\tif(ChessBoard.getPieces().get(i).getColor().equals(\"Black\"))\n\t\t\t\t\t\tfor(int location: ChessBoard.getPieces().get(i).getMoves()){\n\t\t\t\t\t\t\tif(location == 75 || location == 76){\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tfor(int i = 0; i < ChessBoard.getPieces().size(); i++){\n\t\t\t\t\tif(ChessBoard.getPieces().get(i).getColor().equals(\"White\"))\n\t\t\t\t\t\tfor(int location: ChessBoard.getPieces().get(i).getMoves()){\n\t\t\t\t\t\t\tif(location == 5 || location == 6){\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\t\n\t\t}\n\t\t\n\t\telse if (direction == -1){//East\n\t\t\trook = getSquare().getWest().getWest().getWest().getWest().getOccupant();\n\t\t\tif(rook == null || !rook.getColor().equals(this.getColor()) || !rook.getType().equals(\"Rook\") || rook.hasMoved() || this.hasMoved())\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getWest().getWest().getWest().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getWest().getWest().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getWest().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\t\n\t\t\tif(getColor().equals(\"White\")){\n\t\t\t\tfor(int i = 0; i < ChessBoard.getPieces().size(); i++){\n\t\t\t\t\tif(ChessBoard.getPieces().get(i).getColor().equals(\"Black\"))\n\t\t\t\t\t\tfor(int location: ChessBoard.getPieces().get(i).getMoves()){\n\t\t\t\t\t\t\tif(location == 73 || location == 72 || location == 71){\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\telse{\n\t\t\t\tfor(int i = 0; i < ChessBoard.getPieces().size(); i++){\n\t\t\t\t\tif(ChessBoard.getPieces().get(i).getColor().equals(\"White\"))\n\t\t\t\t\t\tfor(int location: ChessBoard.getPieces().get(i).getMoves()){\n\t\t\t\t\t\t\tif(location == 3 || location == 2 || location == 1){\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn true;\n\t}", "public void performCheckAfterPlayerMove() {\n\t\tagentsMoved += 1;\n\t\t\n\t\tif(agentsMoved == agents) {\n\t\t\troundsPlayed += 1;\n\t\t\tmoveRobots();\n\t\t\tagentsMoved = 0;\n\t\t\t\n\t\t\t//restart game at new level after the robots has moved\n\t\t\tif(roundsPlayed > server.getRoundsPerLevel()) {\n\t\t\t\tHandleCommunication.broadcastToClient(null, server.getConnectedClientList(), SendSetting.NextLevel, server, null);\n\t\t\t\troundsPlayed = 0;\n\t\t\t}\n\t\t}\n\t}", "public boolean isequal(Position position) {\n\t\tif(this.getFile() == position.getFile() && this.getRank() == position.getRank()) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}", "@Test\n public void moreThanOneCheckerOnToLocation() {\n\n assertTrue(game.move(Location.R1, Location.R2));\n assertTrue(game.move(Location.R1, Location.R3));\n game.nextTurn();\n // to der gerne skulle vaere lovlige og stemme med terningerne\n assertTrue(game.move(Location.R6, Location.R5));\n assertTrue(game.move(Location.R8, Location.R6));\n game.nextTurn();\n assertTrue(game.move(Location.R2, Location.R5));\n assertTrue(game.move(Location.R3, Location.R7));\n game.nextTurn();\n // der staar nu to sorte paa R4\n assertFalse(game.move(Location.R6, Location.R3));\n }", "private boolean moveVehicleOverNode( final QVehicle veh, QLinkI fromLink, final QLaneI fromLane, final double now ) {\n\t\tId<Link> nextLinkId = veh.getDriver().chooseNextLinkId();\n\t\tLink currentLink = fromLink.getLink() ;\n\t\n\t\tAcceptTurn turn = turnAcceptanceLogic.isAcceptingTurn(currentLink, fromLane, nextLinkId, veh, this.netsimEngine.getNetsimNetwork(), now);\n\t\tif ( turn.equals(AcceptTurn.ABORT) ) {\n\t\t\tmoveVehicleFromInlinkToAbort( veh, fromLane, now, currentLink.getId() ) ;\n\t\t\treturn true ;\n\t\t} else if ( turn.equals(AcceptTurn.WAIT) ) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tQLinkI nextQueueLink = this.netsimEngine.getNetsimNetwork().getNetsimLinks().get(nextLinkId);\n\t\tQLaneI nextQueueLane = nextQueueLink.getAcceptingQLane() ;\n\t\tif (nextQueueLane.isAcceptingFromUpstream()) {\n\t\t\tmoveVehicleFromInlinkToOutlink(veh, currentLink.getId(), fromLane, nextLinkId, nextQueueLane);\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\tif (vehicleIsStuck(fromLane, now)) {\n\t\t\t/* We just push the vehicle further after stucktime is over, regardless\n\t\t\t * of if there is space on the next link or not.. optionally we let them\n\t\t\t * die here, we have a config setting for that!\n\t\t\t */\n\t\t\t\n\t\t\t// For analysis purposes\n\t\t\tCounters.countStuckEvents.incrementAndGet();\n\n\t\t\t\n\t\t\tif (this.context.qsimConfig.isRemoveStuckVehicles()) {\n\t\t\t\tmoveVehicleFromInlinkToAbort(veh, fromLane, now, currentLink.getId());\n\t\t\t\treturn false ;\n\t\t\t} else {\n\t\t\t\tmoveVehicleFromInlinkToOutlink(veh, currentLink.getId(), fromLane, nextLinkId, nextQueueLane);\n\t\t\t\treturn true;\n\t\t\t\t// (yyyy why is this returning `true'? Since this is a fix to avoid gridlock, this should proceed in small steps. \n\t\t\t\t// kai, feb'12) \n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\treturn false;\n\t\t\n\t}", "private static LinkedList<Integer> localSearch2Opt(File fileNameWithPath, int kNeighborHood ) throws Exception{\n\t\t\n\t\tString traceString = \"\";\n\t\tdouble bestCost = Double.POSITIVE_INFINITY;\n\t\tLinkedList<Integer> bestTspList = null;\n\t\tdouble bestCycleTime = Double.POSITIVE_INFINITY;\n\n\t\tif (Project.runId == -1 )\n\t\t\tProject.runId = 1;\n\n\t\t/* \n\t\t * read the file and build the cost table\n\t\t */\n parseEdges(fileNameWithPath);\n\n /*\n\t\t * time starts once you read the data\n */\n\t\tdouble baseTime = System.nanoTime();\n\n\t\t/*\n\t\t * invoking furthest insertion algorithm to get the tsp\n\t\t */\n\t\tlong startNodeSeed = (long)(1000.0*generator.nextDouble());\n\t\tLinkedList<Integer> currentTspList = FurthestInsertion.generateTSP(Project.sourceGTree,startNodeSeed);\n\t\t\n\t\tdouble currentTspCost = tspCost(currentTspList);\n\n\t\tbestTspList = currentTspList;\n\t\tbestCost = currentTspCost;\n\t\tbestCycleTime = System.nanoTime() - baseTime;\n\n\t\t/* print the trace file */\n\t\ttraceString = String.format(\"%.2f, %d\",Math.round(((System.nanoTime()-baseTime)/nanosecs)*100.0)/100.0,Math.round(bestCost));\n\t\tprintTrace(runId,traceString);\n\n\t\t/*\n\t\t * remove the last node as it matches the first\n\t\t */\n\t\tcurrentTspList.removeLast();\n\n\t\twhile ( true )\n\t\t{\n\t\t\t/*\n\t\t\t * reached cutoff time\n\t\t\t */\n\t\t\tif ( System.nanoTime()-baseTime >= Project.cutoffTimeSeconds*nanosecs ) {\n\t\t\t\ttimedOut=true;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdouble cycleStartTime = System.nanoTime();\n\n\t\t\tLinkedList<Integer> newTspList = currentTspList;\n\n\t\t\t/* do a 2 opt search in current k=5 neighborhood to get a newtsp */\n\t\t\t/* 1. Pick the first random element in the current tsp */\n\t\t\tint element2 = (int)((double)(newTspList.size()-1) * generator.nextDouble());\n\t\t\tint element1 = element2 - 1;\n\t\t\tif ( element1 == -1 ){\n\t\t\t\telement1 = newTspList.size()-1;\n\t\t\t}\n\t\t\t\n int delta;\n\n\t\t\t/*\n\t\t\t * search in the neighborhood specified\n * if not specified search all\n\t\t\t */\n if ( kNeighborHood != -1 ) {\n\t\t\t /* We want to search in the specified k=n neighborhoods of element1 */\n\t\t\t delta= (int)(2*kNeighborHood*generator.nextDouble()) - kNeighborHood;\n } else {\n\t\t\t delta= (int)((newTspList.size()-1)*generator.nextDouble()) - (int)(newTspList.size()/2);\n\t\t\t}\n\n\t\t\tif ( delta == 0 ) {\n\t\t\t\tdelta = 2;\n\t\t\t} else if ( delta == 1 ) {\n\t\t\t\tdelta = 2;\n\t\t\t} else if ( delta == -1) {\n\t\t\t\tdelta = -2; }\n\n\t\t\tint element4 = element2 + delta;\n\n\t\t\tif ( element4 < 0 ) {\n\t\t\t\telement4 = newTspList.size()+element4;\n\t\t\t}else if ( element4 >= newTspList.size() ) {\n\t\t\t\telement4 = element4-(newTspList.size()-1);\n\t\t\t}\n\n\t\t\tint element3 = element4 -1;\n\t\t\tif ( element3 == -1 ){\n\t\t\t\telement3 = newTspList.size()-1;\n\t\t\t}\n\n\n\t\t\t/* \n\t\t\t * the new tsp will have element2->element4.......element1->element3....\n\t\t\t */\n\t\t\tInteger vertex_3 = newTspList.get(element3);\n\t\t\tnewTspList.set(element3,newTspList.get(element2));\n\t\t\tnewTspList.set(element2,vertex_3);\n\n\t\t\t/*\n\t\t\t * from element2+1 to element3-1 swap to reverse their order\n\t\t\t */\n\t\t\twhile ( element2 < element3 ){\n\t\t\t\telement3 = element3-1;\n\t\t\t\tif ( element3 == -1 ) {\n\t\t\t\t\telement3 = newTspList.size()-1;\n\t\t\t\t}\n\n\t\t\t\telement2 = element2 + 1;\n\t\t\t\tif ( element2 == newTspList.size() ) {\n\t\t\t\t\telement3 = 0;\n\t\t\t\t}\n\n\t\t\t\tInteger tempVertex = newTspList.get(element2);\n\t\t\t\tnewTspList.set(element2,newTspList.get(element3));\n\t\t\t\tnewTspList.set(element3,tempVertex);\n\n\t\t\t}\n\n\t\t\tdouble newTspCost = tspCost(newTspList);\n\n\t\t\t/* if new local search solution is better than eariler take the search and continue search\n\t\t\t */\n\t\t\tif ( newTspCost <= currentTspCost ){\n\t\t\t\tcurrentTspList = newTspList;\n\t\t\t\tcurrentTspCost = newTspCost;\n\t\t\t} else {\n\t\t\t/* if new local search solution is not better than eariler \n\t\t\t */\n\t\t\t\tcontinue;\n\t\t\t}\n\t\n\t\t\t//Subtract the start time from the finish time to get the actual algorithm running time; divide by 10e6 to convert to milliseconds\n\t\t\tdouble cycleTime = (System.nanoTime()-cycleStartTime);\n\n\t\t\t/* first improvement , take the best each time */\n\t\t\tif ( newTspCost < bestCost ) {\n\t\t\t\tbestCost = newTspCost;\n\t\t\t\tbestTspList = newTspList;\n\t\t\t\tbestCycleTime = cycleTime;\n\t\t\t\t/* print the trace file */\n\t\t\t\ttraceString = String.format(\"%.2f, %d\",Math.round(((System.nanoTime()-baseTime)/nanosecs)*100.0)/100.0,Math.round(bestCost));\n\t\t\t\tappendToTraceFile(runId,traceString);\n\n\t\t\t\tif ( bestCost <= optimalCost )\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t}\n\n\t\t/* print the sol file */\n\t\tprintSol(runId,bestTspList,bestCost);\n\n\t\t/* print the tab results file */\n\t\tappendTabResults(runId,bestCycleTime,bestCost,bestTspList);\n\n\t\treturn bestTspList;\n\n\t}", "public boolean isMovePossible(int start, int end, boolean isRed){\n\n int moveDiff = end - start; //moveDiff tracks the movement made based on difference btwn start and end\n //general check for if a checker is on the end square\n if (mCheckerBoard.get(end) != null)\n {\n return false; //can't move b/c a checker is on the end square\n }\n\n //general checks that start and end are on the board\n if(end<0 || end>63)\n {\n return false; //can't move b/c end is off-board\n }\n\n\n //checks for diagonalRight\n if(moveDiff == 9 || moveDiff ==-7)\n {\n if(start % 8 == 7){\n return false; //can't move b/c off-board on right\n }\n }\n\n //checks for diagonalLeft\n if(moveDiff == 7 || moveDiff ==-9)\n {\n if(start % 8 == 0){\n return false; //can't move b/c off-board on left\n }\n }\n\n //checks for jumpRight\n if(moveDiff == 18 || moveDiff == -14){\n //column check\n if((start % 8 == 7) || (start % 8 == 6)){\n return false; //can't move b/c off-board on right\n }\n //need to check if there is a piece of opposite color in between\n int jumpSpace = start + (moveDiff/2);\n Checker jumped = mCheckerBoard.get(jumpSpace);\n if(jumped == null)\n {\n return false; //can't move b/c no checker to jump\n }\n else if (jumped.isRed() == isRed)\n {\n return false; //can't move b/c can't jump own color\n }\n }\n\n //checks for jumpLeft\n if(moveDiff == 14 || moveDiff == -18){\n if((start % 8 == 7) || (start % 8 == 6)) {\n return false; //can't move b/c off-board on right\n }\n //need to check if there is a piece of opposite color in between\n int jumpSpace = start + (moveDiff/2);\n Checker jumped = mCheckerBoard.get(jumpSpace);\n if(jumped == null)\n {\n return false; //can't move b/c no checker to jump\n }\n else if (jumped.isRed() == isRed)\n {\n return false; //can't move b/c can't jump own color\n }\n }\n\n if(moveDiff == 7 || moveDiff ==-7 || moveDiff ==9 || moveDiff ==-9\n || moveDiff == 18 || moveDiff == -18 || moveDiff == 14 || moveDiff ==-14){\n return true;\n }\n else{\n return false;\n }\n\n }", "public void fileReadGameHistory(String filename)\n {\n \t//ArrayList<GameObject> gameObject = new ArrayList<>();\n\t\tFileReader file = null;\n\t\ttry {\n\t\t\tfile = new FileReader(filename);\n\t\t} catch (FileNotFoundException e) {\n\n\t\t\te.printStackTrace();\n\t\t}\n\t\tSystem.out.println(filename);\n\t\tBufferedReader br = new BufferedReader(file);\n\t\tString s = \"\";\n\t\ttry\n\t\t{\n\t\t\twhile((s = br.readLine()) != null )\n\t\t\t{\n\t\t\t\tString[] prop1 = s.split(\"#\");\n\t\t\t\tSystem.out.println(prop1[0] + \" fgdfsgfds \" + prop1[1]);\n\t\t\t\tString indexOfList = prop1[0];\n\t\t\t\tString[] prop2 = prop1[1].split(\",\");\n\t\t\t\tString[] prop3;\n\t\t\t\tString[] prop4 = indexOfList.split(\";\");\n\t\t\t\t//gameObject.add(new GameObject(indexOfList));\n\t\t\t\tcount = count +1;\n\t\t\t\texistCount = existCount + 1;\n\t\t\t\tif (indexOfList.charAt(0) == 's')//when this line is data of a swimming game\n\t\t\t\t{\n\t\t\t\t\tSystem.out.println(prop4[0]);\n\t\t\t\t\tgames.add(new Swimming(prop4[1],\"Swimming\",prop4[0]));\n\t\t\t\t\tfor(int i = 0; i < Array.getLength(prop2); i++)\n\t\t\t\t\t{\n\t\t\t\t\t\tprop3 = prop2[i].split(\":\");\n\t\t\t\t\t\tgames.get(count - 1).addParticipant(prop3[0], Integer.parseInt(prop3[1]), 0);\n//\t\t\t\t\t\tgames.get(count-1).getResults().get(i).setId(prop3[0]);\n//\t\t\t\t\t\tgames.get(count-1).getResults().get(i).setRe(Integer.parseInt(prop3[1]));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (indexOfList.charAt(0) == 'c')//when this line is data of a cycling game\n\t\t\t\t{\n\t\t\t\t\tgames.add(new Cycling(prop4[1],\"Cycling\",prop4[0]));\n\t\t\t\t\tfor(int i = 0; i < Array.getLength(prop2); i++)\n\t\t\t\t\t{\n\t\t\t\t\t\tprop3 = prop2[i].split(\":\");\n\t\t\t\t\t\tgames.get(count - 1).addParticipant(prop3[0], Integer.parseInt(prop3[1]), 0);\n//\t\t\t\t\t\tgames.get(count-1).getResults().get(i).setId(prop3[0]);\n//\t\t\t\t\t\tgames.get(count-1).getResults().get(i).setRe(Integer.parseInt(prop3[1]));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (indexOfList.charAt(0) == 'r')//when this line is data of a running game\n\t\t\t\t{\n\t\t\t\t\tgames.add(new Running(prop4[1],\"Running\",prop4[0]));\n\t\t\t\t\tfor(int i = 0; i < Array.getLength(prop2); i++)\n\t\t\t\t\t{\n\t\t\t\t\t\tprop3 = prop2[i].split(\":\");\n\t\t\t\t\t\tgames.get(count - 1).addParticipant(prop3[0], Integer.parseInt(prop3[1]), 0);\n//\t\t\t\t\t\tgames.get(count-1).getResults().get(i).setId(prop3[0]);\n//\t\t\t\t\t\tgames.get(count-1).getResults().get(i).setRe(Integer.parseInt(prop3[1]));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}catch (NumberFormatException | IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n }", "public Position findWeed() {\n int xVec =0;\n int yVec=0;\n int sum = 0;\n Position move = new Position(0, 0);\n for (int i = 0; i < this.WORLD.getMapSize().getX(); i++) {\n for (int j = 0; j < this.WORLD.getMapSize().getY(); j++) {\n\n //hogweed\n Organism organism = this.WORLD.getOrganism(i, j);\n if(organism!=null){\n Class c = organism.getClass();\n if (c.getSimpleName().equals(\"Parnsip\")) {\n int tmpX = Math.abs(this.position.getX() - i);\n int tmpY = Math.abs(this.position.getY() - j);\n if (!(xVec == 0 && yVec == 0)) {\n int tmpSum = tmpX + tmpY;\n if (sum > tmpSum) {\n xVec=tmpX;\n yVec=tmpY;\n sum = tmpSum;\n this.setMove(move, j, i);\n }\n }\n else {\n xVec=tmpX;\n yVec=tmpY;\n sum = tmpX + tmpY;\n this.setMove(move, j, i);\n }\n }\n }\n\n }\n }\n return move;\n }", "boolean move(int a, int b, int ring) {//TODO: effizienter schreiben\t\n\t\tif(this.Ring == ring) {\n\t\t\t//interring bewegung\n\t\t\t\t//Bedingung1: Abstand=1\n\t\t\t\tif(Math.abs(X-a)+Math.abs(Y-b) == 1)return true;\n\t\t}\n\t\t//extraring bewegung\n\t\tif(this.Ring != ring) { \n\t\t\tif(Math.abs(Ring-ring) == 1 && X==a && Y==b)return true;\n\t\t}\n\t\treturn false;\n\t}", "@Test(groups = { \"unittest\", \"postiontests\" })\n public void testMatchOnlineAndBatch() throws Exception {\n BatchPositionCache batchCache = loadTestBatchFile();\n\n assertTrue(batchCache.size() > 0, \"Failed to read batch records\");\n \n // check that we have the records we need\n BatchPosition bp1 = batchCache.getCacheItem(new PositionKey(\"TUU8\", \"QMF\", \"QF.NDayBreak\",\n \"Breakout\", \"General\", \"QUANTYS\", new BigDecimal(96)));\n assertNotNull(bp1, \"Failed to find TUU8 for NDayBreak position 96\");\n assertComparable(bp1.getFullCurrentNetPosition(), new BigDecimal(7200000), \"Current position is wrong\");\n \n BatchPosition bp2 = batchCache.getCacheItem(new PositionKey(\"TUU8\", \"QMF\", \"QF.NDayBreak\",\n \"Breakout\", \"General\", \"QUANTYS\", new BigDecimal(-96)));\n assertNotNull(bp2, \"Failed to find TUU8 for NDayBreak position -96\");\n assertComparable(bp2.getFullCurrentNetPosition(), new BigDecimal(7200000), \"Current position is wrong\");\n \n // Build the online cache\n OnlinePositionAggregateCache onlineCache = loadTestOnlineFile(); \n \n assertTrue(onlineCache.size() > 0, \"Failed to read in online records\");\n \n // check that we have the records we need\n RtfOnlinePosition op1 = onlineCache.getOnlinePosition(new PositionKey(\"TUU8\", \"QMF\", \"QF.NDayBreak\",\n \"Breakout\", \"General\", \"QUANTYS\", new BigDecimal(96)));\n assertNotNull(op1, \"Failed to find TUU8 for NDayBreak position 96\");\n assertEquals(op1.getPrimeBroker(), \"NO PB\", \"Wrong record found\");\n assertEquals(op1.getCurrentPosition(), BigDecimal.ZERO, \"Current position is wrong\");\n \n RtfOnlinePosition op2 = onlineCache.getOnlinePosition(new PositionKey(\"TUU8\", \"QMF\", \"QF.NDayBreak\",\n \"Breakout\", \"General\", \"QUANTYS\", new BigDecimal(-96)));\n assertNotNull(op2, \"Failed to find TUU8 for NDayBreak position -96\");\n assertEquals(op2.getPrimeBroker(), \"GSFUT\", \"Wrong record found\");\n assertEquals(op2.getCurrentPosition(), BigDecimal.ZERO, \"Current position is wrong\");\n }", "public void tick() {\n\t\tif (mainRef.player().getPos()[1] <= lastEnd.getPos()[1] + 2000)\r\n\t\t\tloadNextMap();\r\n\r\n\t\tfor (GameObject go : gameObjects)\r\n\t\t\tgo.tick();\r\n\r\n\t\t// Check Player Collision\r\n\t\t// Top-Left\r\n\t\tPointColObj cTL = new PointColObj(mainRef.player().getPos()[0] + mainRef.player().getCol()[2],\r\n\t\t\t\tmainRef.player().getPos()[1] + mainRef.player().getCol()[3]);\r\n\t\t// Top-Right\r\n\t\tPointColObj cTR = new PointColObj(mainRef.player().getPos()[0] + mainRef.player().getCol()[2],\r\n\t\t\t\tmainRef.player().getPos()[1] + mainRef.player().getCol()[3] + mainRef.player().getCol()[1]);\r\n\t\t// Bottom-Left\r\n\t\tPointColObj cBL = new PointColObj(\r\n\t\t\t\tmainRef.player().getPos()[0] + mainRef.player().getCol()[2] + mainRef.player().getCol()[0],\r\n\t\t\t\tmainRef.player().getPos()[1] + mainRef.player().getCol()[3]);\r\n\t\t// Bottom-Right\r\n\t\tPointColObj cBR = new PointColObj(\r\n\t\t\t\tmainRef.player().getPos()[0] + mainRef.player().getCol()[2] + mainRef.player().getCol()[0],\r\n\t\t\t\tmainRef.player().getPos()[1] + mainRef.player().getCol()[3] + mainRef.player().getCol()[1]);\r\n\r\n\t\t// Inverse Collision, no part of the player's ColBox should be not\r\n\t\t// colliding...\r\n\t\tif (checkCollisionWith(cTL).size() == 0 || checkCollisionWith(cTR).size() == 0\r\n\t\t\t\t|| checkCollisionWith(cBL).size() == 0 || checkCollisionWith(cBR).size() == 0) {\r\n\t\t\t// If it would have left the bounding box of the floor, reverse the\r\n\t\t\t// player's posiiton\r\n\t\t\tmainRef.player().setMoveBack(true);\r\n\t\t} else\r\n\t\t\tmainRef.player().setMoveBack(false);\r\n\r\n\t\t// Check General Collision\r\n\t\tArrayList<GameObject> allCol = checkCollisionWith(mainRef.player());\r\n\t\tfor (GameObject go : allCol) {\r\n\t\t\tif (go instanceof Tile) {\r\n\t\t\t\tTile gameTile = (Tile) go;\r\n\t\t\t\tif (gameTile.getType() == GameObjectRegistry.TILE_WALL\r\n\t\t\t\t\t\t|| gameTile.getType() == GameObjectRegistry.TILE_BASE\r\n\t\t\t\t\t\t|| gameTile.getType() == GameObjectRegistry.TILE_DOOR\r\n\t\t\t\t\t\t|| gameTile.getType() == GameObjectRegistry.TILE_SEWER\r\n\t\t\t\t\t\t|| (gameTile.getType() == GameObjectRegistry.TILE_WATERFALL && gameTile.getVar() == 0)) {\r\n\t\t\t\t\tmainRef.player().setMoveBack(true);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t} else if (go instanceof LineColObjHor || go instanceof LineColObjVert) {\r\n\t\t\t\tmainRef.player().setMoveBack(true);\r\n\t\t\t\tbreak;\r\n\t\t\t} else if (go instanceof SkillDrop) {\r\n\t\t\t\tSkillDrop d = (SkillDrop) go;\r\n\t\t\t\tmainRef.player().getInv()[d.getVariation()]++;\r\n\t\t\t\tremoveGameObject(go);\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t}", "private static Point avoidNoFlyZones(Point droneCurr, Point droneNextDes, List<List<List<Point>>> noFlyZonesCoords, List<Point> dronePositions, String port) throws IOException, InterruptedException {\r\n\t\tvar intersectingLines = linesWhichIntersect(droneCurr, droneNextDes, noFlyZonesCoords);\r\n\t\tvar numCoords = intersectingLines.size();\r\n\t\t\r\n\t\tvar droneGrad = getGradient(droneCurr, droneNextDes);\r\n\t\tvar droneYint = getYint(droneCurr, droneNextDes);\r\n\t\tvar droneNext = droneNextDes; //in the case that there are no intersections with any lines\r\n\t\t\r\n\t\tPoint previous1 = null;\r\n\t\tPoint previous2 = null;\r\n\t\tvar lastIndex = dronePositions.size()-1;\r\n\t\tif(lastIndex>1) { //checks that drone has been in at least 3 positions\r\n\t\t\tprevious1 = dronePositions.get(lastIndex-1); //previous position of drone\r\n\t\t\tprevious2 = dronePositions.get(lastIndex-2); //position before previous position\r\n\t\t}\r\n\t\t\r\n\t\t//in the case that the drone intersects with one line\r\n\t\tif(numCoords == 2) {\r\n\t\t\tvar coord1 = intersectingLines.get(0);\r\n\t\t\tvar coord2 = intersectingLines.get(1); \r\n\t\t\tvar buildingInd = buildingIndex(coord1, port);\r\n\t\t\tif(buildingInd != 100) { //index initialised as 100 in buildingIndex function- if coordinate not found in list, 100 is returned\r\n\t\t\t\tvar buildingCentre = buildingCentres(port).get(buildingInd);\r\n\t\t\t\tvar buildingSideGrad = getGradient(coord1, coord2);\r\n\t\t\t\tdroneNext = chooseNextPos(droneCurr, droneNextDes, coord1, coord2, buildingSideGrad, buildingCentre, noFlyZonesCoords, previous1, previous2);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t}\r\n\t\t//in the case that the drone intersects with two lines\r\n\t\telse if(numCoords == 4) {\r\n\t\t\tvar coord1 = intersectingLines.get(0);\r\n\t\t\tvar coord2 = intersectingLines.get(1);\r\n\t\t\tvar coord3 = intersectingLines.get(2);\r\n\t\t\tvar coord4 = intersectingLines.get(3);\r\n\t\t\t\r\n\t\t\tvar buildingSide1Grad = getGradient(coord1, coord2);\r\n\t\t\tvar buildingSide1Yint = getYint(coord1, coord2);\r\n\t\t\tvar intersection1 = getIntersection(droneYint, buildingSide1Yint, droneGrad, buildingSide1Grad);\r\n\t\t\tvar dist1 = euclidDist(intersection1, droneCurr);\r\n\t\t\t\r\n\t\t\tvar buildingSide2Grad = getGradient(coord3, coord4);\r\n\t\t\tvar buildingSide2Yint = getYint(coord3, coord4);\r\n\t\t\tvar intersection2 = getIntersection(droneYint, buildingSide2Yint, droneGrad, buildingSide2Grad);\r\n\t\t\tvar dist2 = euclidDist(intersection2, droneCurr);\r\n\t\t\t\r\n\t\t\tvar buildingInd1 = buildingIndex(coord1, port); //in case the two lines which the drone intersects with are from 2 different buildings\r\n\t\t\tvar buildingInd2 = buildingIndex(coord3, port);\r\n\t\t\tif(buildingInd1 !=100 && buildingInd2 !=100) { \r\n\t\t\t\tvar buildingCentre1 = buildingCentres(port).get(buildingInd1);\r\n\t\t\t\tvar buildingCentre2 = buildingCentres(port).get(buildingInd2);\r\n\t\t\t\t\r\n\t\t\t\tif(dist1<dist2) { //to determine which side the drone path intersects with first\r\n\t\t\t\t\tdroneNext = chooseNextPos(droneCurr, droneNextDes, coord1, coord2, buildingSide1Grad, buildingCentre1, noFlyZonesCoords, previous1, previous2);\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\tdroneNext = chooseNextPos(droneCurr, droneNextDes, coord3, coord4, buildingSide2Grad, buildingCentre2, noFlyZonesCoords, previous1, previous2);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t} \r\n\t\t//in the case that the drone intersects with three lines\r\n\t\telse if(numCoords == 6) {\r\n\t\t\tvar coord1 = intersectingLines.get(0);\r\n\t\t\tvar coord2 = intersectingLines.get(1);\r\n\t\t\tvar coord3 = intersectingLines.get(2);\r\n\t\t\tvar coord4 = intersectingLines.get(3);\r\n\t\t\tvar coord5 = intersectingLines.get(4);\r\n\t\t\tvar coord6 = intersectingLines.get(5);\r\n\t\t\t\r\n\t\t\tvar buildingSide1Grad = getGradient(coord1, coord2);\r\n\t\t\tvar buildingSide1Yint = getYint(coord1, coord2);\r\n\t\t\tvar intersection1 = getIntersection(droneYint, buildingSide1Yint, droneGrad, buildingSide1Grad);\r\n\t\t\tvar dist1 = euclidDist(intersection1, droneCurr);\r\n\t\t\t\r\n\t\t\tvar buildingSide2Grad = getGradient(coord3, coord4);\r\n\t\t\tvar buildingSide2Yint = getYint(coord3, coord4);\r\n\t\t\tvar intersection2 = getIntersection(droneYint, buildingSide2Yint, droneGrad, buildingSide2Grad);\r\n\t\t\tvar dist2 = euclidDist(intersection2, droneCurr);\r\n\t\t\t\r\n\t\t\tvar buildingSide3Grad = getGradient(coord5, coord6);\r\n\t\t\tvar buildingSide3Yint = getYint(coord5, coord6);\r\n\t\t\tvar intersection3 = getIntersection(droneYint, buildingSide3Yint, droneGrad, buildingSide3Grad);\r\n\t\t\tvar dist3 = euclidDist(intersection3, droneCurr);\r\n\t\t\t\r\n\t\t\tvar minDist = Math.min(Math.min(dist1, dist2),dist3);\r\n\t\t\t\r\n\t\t\tvar buildingInd1 = buildingIndex(coord1, port); //in case the three lines which the drone intersects with are from 3 different buildings\r\n\t\t\tvar buildingInd2 = buildingIndex(coord3, port);\r\n\t\t\tvar buildingInd3 = buildingIndex(coord5, port);\r\n\t\t\tif(buildingInd1 !=100 && buildingInd2 != 100 && buildingInd3 != 100) {\r\n\t\t\t\tvar buildingCentre1 = buildingCentres(port).get(buildingInd1);\r\n\t\t\t\tvar buildingCentre2 = buildingCentres(port).get(buildingInd2);\r\n\t\t\t\tvar buildingCentre3 = buildingCentres(port).get(buildingInd3);\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\tif(minDist==dist1) {\r\n\t\t\t\t\tdroneNext = chooseNextPos(droneCurr, droneNextDes, coord1, coord2, buildingSide1Grad, buildingCentre1, noFlyZonesCoords, previous1, previous2);\r\n\t\t\t\t}\r\n\t\t\t\telse if(minDist==dist2) {\r\n\t\t\t\t\tdroneNext = chooseNextPos(droneCurr, droneNextDes, coord3, coord4, buildingSide2Grad, buildingCentre2, noFlyZonesCoords, previous1, previous2);\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\tdroneNext = chooseNextPos(droneCurr, droneNextDes, coord5, coord6, buildingSide3Grad, buildingCentre3, noFlyZonesCoords, previous1, previous2);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\treturn droneNext;\r\n\t}", "private boolean checkConflict(String branchName,\n Commit splitPt) throws IOException {\n Commit givenCommit = findCommit(branchName);\n checkUntracked(givenCommit);\n Commit currCommit = getHeadCommit();\n HashMap<String, Blob> givenFile = givenCommit.getFile();\n checkSplitPoint(splitPt, currCommit, givenCommit);\n boolean conflictInGiven = processGivenFile(givenFile, splitPt,\n currCommit, givenCommit);\n boolean conflictInCurr = processCurrFile(currCommit.getFile(),\n splitPt, currCommit, givenCommit);\n return (conflictInCurr || conflictInGiven);\n }", "public void mergeROIs() {\n\t\tgroup1 = new ArrayList<Double>();\n\t\tgroup1.add(Data[0][0]);\n\t\tfor (int i = 1; i < (nResults-1);i++) {\n\t\t\tif ((Data[1][i]-similarity*Data[2][i]) < (Data[1][0]+similarity*Data[2][0]) ) { // if the lines are similar to the minimum line, add them to group1\n\t\t\t\tgroup1.add(Data[0][i]);//addes new element to group 1 with value of roiindex[i]\n\t\t\t}\n\t\t}\n\t\tint[] group1a = new int[group1.size()];\n\t\tfor(int i =0; i < group1.size(); i++){\n\t\t\tdouble temp = group1.get(i);\n\t\t\tgroup1a[i] = (int)temp;\n\t\t}\n\t\tgroup2 = new ArrayList<Double>();\n\t\tgroup2.add(Data[0][nResults-1]);\n\t\tfor (int i=(nResults-2);i>1;i--) {\n\t\t\tif ((Data[1][i]+similarity*Data[2][i]) > (Data[1][nResults-1]-similarity*Data[2][nResults-1]) ) { \n\t\t\t// if the lines are similar to the maximum line, add them to group2\n\t\t\tgroup2.add(0,Data[0][i]);\n\t\t\t}\n\t\t}\n\t\tint[] group2a = new int[group2.size()];\n\t\tfor(int i =0; i < group2.size(); i++){\n\t\t\tdouble temp = group2.get(i);\n\t\t\tgroup2a[i] = (int)temp;\n\t\t}\n\t\tint count;\n\t\t//IJ.run(\"Select None\");\n\t\tActiveROIManager.deselect();\n\t\tActiveROIManager.setSelectedIndexes(group1a);\n\t\tif(group1a.length > 1) {\n\t\t\tActiveROIManager.runCommand(ActiveImage,\"Combine\"); \n\t\t\t//Creates new ROI that is combination of group 2\n\t\t\tcount = ActiveROIManager.getCount();\n\t\t\tRoi1 = ActiveROIManager.getRoi(count-1);//Selects the combined group1 ROI\n\t\t}\n\t\telse{\n\t\t\tRoi1 = ActiveROIManager.getRoi(group1a[0]);\n\t\t}\n\t\tActiveROIManager.setSelectedIndexes(group2a);\n\t\tif(group2a.length > 1) {\n\t\t\tActiveROIManager.runCommand(ActiveImage,\"Combine\"); \n\t\t\t//Creates new ROI that is combination of group 2\n\t\t\tcount = ActiveROIManager.getCount();\n\t\t\tRoi2 = ActiveROIManager.getRoi(count-1); //Selects the combined group2 ROI\n\t\t}\n\t\telse{\n\t\t\tRoi2 = ActiveROIManager.getRoi(group2a[0]);\n\t\t}\n\t\tActiveROIManager.reset();\n\t\trt.reset();\n\t\tActiveROIManager.add(ActiveImage,Roi1,0);\n\t\tActiveROIManager.select(ActiveImage,0);\n\t\tAnalyzer ActiveAnalyzer = new Analyzer(ActiveImage,measurements,rt);\n\t\tActiveAnalyzer.measure();\n\t\tActiveROIManager.add(ActiveImage,Roi2,1);\n\t\tActiveROIManager.select(ActiveImage,1);\n\t\tActiveAnalyzer.measure();\n\t\tActiveROIManager.runCommand(Image,\"Show All without labels\");// removes the labels, which a user may find confusing in the context of this macro\n\t\treturn;\n\t}" ]
[ "0.5760794", "0.548483", "0.542406", "0.5421079", "0.5403466", "0.5353307", "0.53237796", "0.53219616", "0.5321476", "0.5311719", "0.52512515", "0.52457935", "0.51988643", "0.5185123", "0.51765454", "0.5169464", "0.51434636", "0.5126927", "0.508683", "0.50767225", "0.50695384", "0.5069146", "0.5052254", "0.5048751", "0.5029249", "0.502135", "0.5001385", "0.49682266", "0.4954732", "0.49412546", "0.49269414", "0.49167964", "0.49101412", "0.49058607", "0.4904012", "0.48758784", "0.48322743", "0.48314708", "0.4830128", "0.48201284", "0.48196855", "0.48190546", "0.47910643", "0.47897956", "0.47881466", "0.4778625", "0.47581407", "0.4740479", "0.47393087", "0.47335875", "0.47328916", "0.47295916", "0.47281826", "0.47272402", "0.4722936", "0.47227305", "0.4716495", "0.47145912", "0.47124672", "0.47000647", "0.46921372", "0.46919286", "0.46896207", "0.46874055", "0.4674102", "0.46717018", "0.46713626", "0.46652362", "0.46651736", "0.46578702", "0.46539032", "0.46508026", "0.46499148", "0.46462238", "0.46381795", "0.46330154", "0.4625706", "0.4625289", "0.46212554", "0.46206534", "0.46158752", "0.46104282", "0.46092904", "0.46028087", "0.4602171", "0.46015796", "0.46013975", "0.45984274", "0.45892498", "0.45870396", "0.4586017", "0.4583145", "0.45693487", "0.45682448", "0.45626432", "0.45621872", "0.4562145", "0.45567912", "0.45566297", "0.45551196" ]
0.5386849
5
Handle the movement of knights. If the knight's file is one away from the final file, then the knight's rank is either two away from the final rank or the knight is not able to move there. If the knight's rank is one away from the final rank, then the knight's file is either two away from the final file or the knight is not able to move there.
public static int[] getKnightStart(int[][] piecePos, int endFile, int endRank) { for (int[] pos: piecePos) { if ((pos[0] + 1 == endFile || pos[0] - 1 == endFile) && (pos[1] + 2 == endRank || pos[1] - 2 == endRank)) { int[] startPos = {pos[0], pos[1]}; if (isLegalMove(startPos, endFile, endRank)) { return startPos; } } else if ((pos[0] + 2 == endFile || pos[0] - 2 == endFile) && (pos[1] + 1 == endRank || pos[1] - 1 == endRank)) { int[] startPos = {pos[0], pos[1]}; if (isLegalMove(startPos, endFile, endRank)) { return startPos; } } } return null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Override\n\tpublic void win() {\n\t\t\n\t\tfround[fighter1]++;\n\t fplatz[fighter1]=Math.round((float)fplatz[fighter1]/2); \n\t \n\t\tnextRound();\n\t}", "@Test\n\tpublic void testIfKingHasLostNearThrone()\n\t{\n\t\tData d = new Data();\n\t\td.set(9, 10); // move 9th white piece to the 10th square\n\t\td.set(10, 9); // move 10th white piece to the 9th square\n\t\td.set(11, 12); // move 11th white piece to the 12th square\n\t\td.set(12, 14); // move 12th white piece to the 14th square\n\t\td.set(14, 71); // set a black piece to square 71\n\t\td.set(15, 73); // set a black piece to square 73\n\t\td.set(16, 83); //set a black piece to square 83, i.e. one below the king\n\t\n\t\t\n\t\tassertTrue(d.kingLost(72)); // a square below the throne is 72\n\t}", "@Override\n\tpublic void lose() {\n\t\t\n\t\tfround[fighter2]++;\n\t fplatz[fighter2]=Math.round((float)fplatz[fighter2]/2); \n\t\tnextRound();\n\t}", "public void updatePossibleMovesKnights(){}", "public int runFromMuckrakerMove() throws GameActionException {\n\n //flag indicates best direction to move, not direction I am moving...\n\n boolean foundEnemyMuckraker = false;\n double rewardOfStaying = 9999;\n\n int canMoveIndicesSize = 0;\n int idx = 0;\n for (Direction direction : Constants.DIRECTIONS) {\n moveRewards[idx] = 9998;\n moveLocs[idx] = Cache.CURRENT_LOCATION.add(direction);\n if (controller.canMove(direction)) {\n canMoveIndices[canMoveIndicesSize++] = idx;\n }\n ++idx;\n }\n\n for (RobotInfo robotInfo : Cache.ALL_NEARBY_ENEMY_ROBOTS) {\n if (robotInfo.getType() == RobotType.MUCKRAKER) {\n foundEnemyMuckraker = true;\n MapLocation enemyLocation = robotInfo.location;\n //for all valid locations, find travelDistance...\n rewardOfStaying = Math.min(rewardOfStaying, Pathfinding.travelDistance(Cache.CURRENT_LOCATION, enemyLocation) + 0.01 * Cache.CURRENT_LOCATION.distanceSquaredTo(enemyLocation));\n for (int i = 0; i < idx; ++i) {\n moveRewards[i] = Math.min(moveRewards[i], Pathfinding.travelDistance(moveLocs[i], enemyLocation) + 0.01 * moveLocs[i].distanceSquaredTo(enemyLocation));\n }\n }\n }\n\n int flag = CommunicationMovement.encodeMovement(true, true, CommunicationMovement.MY_UNIT_TYPE.SL, CommunicationMovement.MOVEMENT_BOTS_DATA.NOT_MOVING, CommunicationMovement.COMMUNICATION_TO_OTHER_BOTS.NOOP, false, false, 0);\n int bestValidDirection = -1;\n double bestValidReward = rewardOfStaying;\n\n if (foundEnemyMuckraker) {\n int bestDirection = -1;\n double bestReward = rewardOfStaying;\n\n for (int i = 0; i < idx; ++i) {\n if (moveRewards[i] > bestReward) { //find the best direction based on the reward\n bestDirection = i;\n bestReward = moveRewards[i];\n }\n }\n\n /* MOVE TOWARDS ME IS SET SO POLITICANS CAN MOVE TOWARDS THIS BOT (NOT SLANDERERS) -> BE CAREFUL IF/WHEN PARSING THIS SETTING */\n flag = CommunicationMovement.encodeMovement(true, true, CommunicationMovement.MY_UNIT_TYPE.SL, CommunicationMovement.convert_DirectionInt_MovementBotsData(bestDirection), CommunicationMovement.COMMUNICATION_TO_OTHER_BOTS.MOVE_TOWARDS_ME, false, true, 0);\n\n for (int i = 0; i < canMoveIndicesSize; ++i) {\n if (moveRewards[canMoveIndices[i]] > bestValidReward) {\n bestValidDirection = canMoveIndices[i];\n bestValidReward = moveRewards[canMoveIndices[i]];\n }\n }\n }\n\n // if a politician or slanderer has both a muckraker and slanderer in range, then run away opposite of the danger direction\n int bestDirectionBasedOnPoliticianDangerIdx = -1;\n if (!foundEnemyMuckraker) {\n for (RobotInfo robotInfo : Cache.ALL_NEARBY_FRIENDLY_ROBOTS) {\n if (robotInfo.getType() == RobotType.POLITICIAN || robotInfo.getType() == RobotType.MUCKRAKER) {\n\n if (controller.canGetFlag(robotInfo.ID)) {\n int encodedFlag = controller.getFlag(robotInfo.ID);\n if (CommunicationMovement.decodeIsSchemaType(encodedFlag) &&\n CommunicationMovement.decodeIsDangerBit(encodedFlag)) {\n\n if (CommunicationMovement.decodeMyUnitType(encodedFlag) == CommunicationMovement.MY_UNIT_TYPE.PO\n || CommunicationMovement.decodeMyUnitType(encodedFlag) == CommunicationMovement.MY_UNIT_TYPE.MU) {\n //A POLITICIAN OR MUCKRAKER WHO SAYS HE IS IN DANGER (enemy muckraker nearby)\n CommunicationMovement.MOVEMENT_BOTS_DATA badArea = CommunicationMovement.decodeMyPreferredMovement(encodedFlag);\n int badIdx = CommunicationMovement.convert_MovementBotData_DirectionInt(badArea);\n Direction bestDirection = Constants.DIRECTIONS[badIdx].opposite();\n bestDirectionBasedOnPoliticianDangerIdx = bestDirection.ordinal();\n break;\n }\n }\n }\n }\n }\n }\n\n /* Set communication for other slanderers if there is a muckraker within my range */\n if (!Comms.hasSetFlag && controller.canSetFlag(flag)) {\n Comms.hasSetFlag = true;\n controller.setFlag(flag);\n }\n\n /* Below is based on movement */\n if (!controller.isReady()) return 1;\n\n if (foundEnemyMuckraker) {\n if (bestValidDirection != -1) {\n controller.move(Constants.DIRECTIONS[bestValidDirection]);\n return 2;\n }\n return 1;\n }\n\n\n /* No muckrakers were found, so we need to check the flags of nearby slanderer units instead. */\n double closestLocation = 9998;\n int preferedMovementDirectionIdx = -1;\n\n for (RobotInfo robotInfo : Cache.ALL_NEARBY_FRIENDLY_ROBOTS) {\n if (robotInfo.getType() == RobotType.POLITICIAN) { //SLANDERERS THINK ALL SLANDERERS ARE POLITICIANS, so we need to check politicians here...\n double dist = Pathfinding.travelDistance(Cache.CURRENT_LOCATION, robotInfo.location)\n + 0.01 * Cache.CURRENT_LOCATION.distanceSquaredTo(robotInfo.location);\n if (dist < closestLocation && controller.canGetFlag(robotInfo.ID)) { //the closest bot in danger to us is our biggest threat as well\n int encodedFlag = controller.getFlag(robotInfo.ID);\n\n if (CommunicationMovement.decodeIsSchemaType(encodedFlag)) {\n if (CommunicationMovement.decodeMyUnitType(encodedFlag) == CommunicationMovement.MY_UNIT_TYPE.SL && CommunicationMovement.decodeIsDangerBit(encodedFlag)) {\n CommunicationMovement.MOVEMENT_BOTS_DATA movementBotsData = CommunicationMovement.decodeMyPreferredMovement(encodedFlag);\n preferedMovementDirectionIdx = CommunicationMovement.convert_MovementBotData_DirectionInt(movementBotsData);\n closestLocation = dist;\n }\n }\n }\n }\n }\n\n if (preferedMovementDirectionIdx != -1) {\n Direction direction = Pathfinding.toMovePreferredDirection(Constants.DIRECTIONS[preferedMovementDirectionIdx], 1);\n if (direction != null) {\n controller.move(direction);\n return 2;\n }\n return 1;\n }\n\n if (bestDirectionBasedOnPoliticianDangerIdx != -1) {\n Direction direction = Pathfinding.toMovePreferredDirection(Constants.DIRECTIONS[bestDirectionBasedOnPoliticianDangerIdx], 1);\n if (direction != null) {\n controller.move(direction);\n return 2;\n }\n return 1;\n }\n\n return 0; // no reason whatsoever to move\n }", "public void Move(){\n for(int i = 0; i < moveList.length; i++){\n playerString = \"\";\n switch(moveList[i]) {\n case 1: {\n //TODO: Visited points to others\n System.out.println(\"Moving up!\");\n //Logic for fitness score might need to be moved\n if(!(game.mazeArray[game.playerPosition.getPlayerY() -1][game.playerPosition.getPlayerX()] == 1)){\n playerString.concat(\"game.playerPosition.getPlayerY() - 1 + game.playerPosition.getPlayerX()\");\n if(vistedMoves.contains(playerString)){\n vistedPoints += 2;\n } else {\n freedomPoints += 5;\n vistedMoves.add(playerString);\n }\n } else {\n System.out.println(\"Stuck\");\n wallHugs += 10;\n }\n game.moveUp();\n if(game.checkWin()){\n freedomPoints += 200;\n }\n break;\n }\n case 2: {\n System.out.println(\"Moving left!\");\n if(!(game.mazeArray[game.playerPosition.getPlayerY()][game.playerPosition.getPlayerX() -1] == 1)){\n playerString.concat(\"game.playerPosition.getPlayerY() + game.playerPosition.getPlayerX() -1\");\n if(vistedMoves.contains(playerString)){\n vistedPoints += 2;\n } else {\n freedomPoints += 5;\n vistedMoves.add(playerString);\n }\n } else {\n System.out.println(\"Stuck\");\n wallHugs += 1;\n }\n game.moveLeft();\n if(game.checkWin()){\n freedomPoints += 200;\n }\n break;\n }\n case 3: {\n System.out.println(\"Moving right!\");\n if(!(game.mazeArray[game.playerPosition.getPlayerY()][game.playerPosition.getPlayerX() +1] == 1)){\n playerString.concat(\"game.playerPosition.getPlayerY() + game.playerPosition.getPlayerX() +1\");\n if(vistedMoves.contains(playerString)){\n vistedPoints += 2;\n } else {\n freedomPoints += 5;\n vistedMoves.add(playerString);\n }\n } else {\n System.out.println(\"Stuck\");\n wallHugs += 1;\n }\n game.moveRight();\n if(game.checkWin()){\n freedomPoints += 200;\n }\n break;\n }\n case 4: {\n System.out.println(\"Moving down!\");\n if(!(game.mazeArray[game.playerPosition.getPlayerY() +1][game.playerPosition.getPlayerX()] == 1)){\n playerString.concat(\"game.playerPosition.getPlayerY() + 1 + game.playerPosition.getPlayerX()\");\n if(vistedMoves.contains(playerString)){\n vistedPoints += 2;\n } else {\n freedomPoints += 5;\n vistedMoves.add(playerString);\n }\n freedomPoints += 1;\n } else {\n System.out.println(\"Stuck\");\n wallHugs += 1;\n }\n game.moveDown();\n if(game.checkWin()){\n freedomPoints += 200;\n }\n break;\n }\n default: {\n System.out.println(\"End of line\");\n break;\n //You shouldn't be here mate.\n }\n }\n }\n\n }", "public void move(int moveDirection) {\n //if same or opposite direction, check if movable\n if ((direction - moveDirection) % 6 == 0) {\n this.direction = moveDirection;\n if (moveable()) {\n if (direction == 12) {\n this.setLocation(new Point(this.getX(),\n this.getY() - speed));\n }\n //move right\n if (direction == 3) {\n this.setLocation(new Point(this.getX() + speed,\n this.getY()));\n\n }\n //move down\n if (direction == 6) {\n this.setLocation(new Point(this.getX(),\n this.getY() + speed));\n }\n //move left\n if (direction == 9) {\n this.setLocation(new Point(this.getX() - speed,\n this.getY()));\n }\n\n }\n } // if it is turning, check if can turn or not. If can turn then turn and move according to the direction before turn, otherwise, just leave the monster there\n else {\n Point snapToGridPoint = GameUtility.GameUtility.snapToGrid(\n this.getLocation());\n Point gridPoint = GameUtility.GameUtility.toGridCordinate(\n this.getLocation());\n Point nextPoint = new Point(gridPoint.x, gridPoint.y);\n //if the distance is acceptable\n if (GameUtility.GameUtility.distance(snapToGridPoint,\n this.getLocation()) < GameUtility.GameUtility.TILE_SIZE / 2.5) {\n\n if (moveDirection == 3) {\n int x = Math.max(0, gridPoint.x + 1);\n nextPoint = new Point(x, gridPoint.y);\n } else if (moveDirection == 6) {\n int y = Math.max(0, gridPoint.y + 1);\n nextPoint = new Point(gridPoint.x, y);\n } else if (moveDirection == 9) {\n int x = Math.min(19, gridPoint.x - 1);\n nextPoint = new Point(x, gridPoint.y);\n } else if (moveDirection == 12) {\n int y = Math.min(19, gridPoint.y - 1);\n nextPoint = new Point(gridPoint.x, y);\n }\n // if the turn is empty, then snap the monster to the grid location\n if (!(GameManager.getGameMap().getFromMap(nextPoint) instanceof Wall) && !(GameManager.getGameMap().getFromMap(\n nextPoint) instanceof Bomb)) {\n if (GameUtility.GameUtility.distance(snapToGridPoint,\n this.getLocation()) < GameUtility.GameUtility.TILE_SIZE / 10) {\n this.setLocation(snapToGridPoint);\n this.direction = moveDirection;\n } else {\n if (direction == 9 || direction == 3) {\n int directionOfMovement = (snapToGridPoint.x - getX());\n directionOfMovement = directionOfMovement / Math.abs(\n directionOfMovement);\n this.setLocation(new Point(\n this.getX() + directionOfMovement * speed,\n this.getY()));\n } else if (direction == 12 || direction == 6) {\n int directionOfMovement = (snapToGridPoint.y - getY());\n directionOfMovement = directionOfMovement / Math.abs(\n directionOfMovement);\n this.setLocation(new Point(\n this.getX(),\n this.getY() + directionOfMovement * speed));\n }\n }\n }\n }\n }\n }", "public void updatePossibleMovesOther(){\n\t\tif( hasMoved){\n\t\t\tpossibleMovesOther = null;\n\t\t\treturn;\n\t\t}\n\t\t// Get left castle updateMoves first\n\t\tchar[] temp = AlgebraicNotationHelper.getAlgebraicNotationLeftOf( startingFile, startingRank);\n\t\ttemp = AlgebraicNotationHelper.getAlgebraicNotationLeftOf( temp[0], temp[1]);\n\t\ttemp = AlgebraicNotationHelper.getAlgebraicNotationLeftOf( temp[0], temp[1]);\n\t\t// Should be b1 for light color King (or b8 for dark color King)\n\t\tAlgebraicNotation tempAN = new AlgebraicNotation( temp[0], temp[1]);\n\t\tpossibleMovesOther.add( tempAN);\n\t\t// Get right castle updateMoves next\n\t\ttemp = AlgebraicNotationHelper.getAlgebraicNotationRightOf( startingFile, startingRank);\n\t\ttemp = AlgebraicNotationHelper.getAlgebraicNotationRightOf( temp[0], temp[1]);\n\t\t// Should be g1 for light color King (or g8 for dark color King)\n\t\ttempAN = new AlgebraicNotation( temp[0], temp[1]);\n\t\tpossibleMovesOther.add( tempAN);\t\n\t}", "private int setRank() {\n this.rank = 0;\n for(int row = 0; row < SIZE; row++){\n for(int col = 0; col < SIZE; col++){\n int currentBoardNumber = row * 3 + col + 1;\n if(row == 2 && col == 2) {\n currentBoardNumber = 0;\n }\n if(this.board[row][col] != currentBoardNumber) {\n this.rank += 1;\n }\n }\n }\n this.rank += this.prevMoves.length();\n return this.rank;\n }", "private boolean isNextMoveRochade(Move move)\r\n\t{\r\n\t\tif (!(move.from.piece instanceof King)) return false;\r\n\t\tint xDiffAbs = Math.abs(move.to.coordinate.x - move.from.coordinate.x); \r\n\t\treturn xDiffAbs == 2;\r\n\t}", "public static boolean moveking() //returns false if valid move is there\n{ System.out.println(\"IN FUNCTION MOVE KING.....\");\n flag=0;\n int kx,ky;\n if(q==2)\n {\n kx=p2.ka.kbx; //WHITE KING....\n ky=p2.ka.kby;\n } \nelse\n {\n kx=p1.ka.kax; //BLACK KING....\n\tky=p1.ka.kay;\n }\n//CHECKS WHETHER KING CAN MOVE TO THE 8 adjacent places...\n if(kx-1>=0)\n {\n move2(kx,ky,kx-1,ky);\n \n if(flag==1)\n {\n revert(kx,ky,kx-1,ky);\n return false;\n }\n }\n //r\n if(kx+1<=7)\n { move2(kx,ky,kx+1,ky);\n if(flag==1)\n {revert(kx,ky,kx+1,ky);\n return false;\n \n }\n }\n \n //u\n if(ky-1>=0)\n {\n move2(kx,ky,kx,ky-1);\n \n if(flag==1)\n {revert(kx,ky,kx,ky-1);\n return false;\n \n }\n }\n //d\n if(ky+1<=7)\n {\n move2(kx,ky,kx,ky+1);\n \n if(flag==1)\n { revert(kx,ky,kx,ky+1);\n return false;\n \n }\n }\n //lu\n if(kx-1>=0&&ky-1>=0)\n {\n move2(kx,ky,kx-1,ky-1);\n \n if(flag==1)\n {revert(kx,ky,kx-1,ky-1);\n return false;\n \n }\n }\n //ld\n if(kx-1>=0&&ky+1<=7)\n {\n move2(kx,ky,kx-1,ky+1);\n \n if(flag==1)\n {revert(kx,ky,kx-1,ky+1);\n return false;\n \n }\n }\n //ru\n if(kx+1<=7&&ky-1>=0)\n {\n move2(kx,ky,kx+1,ky-1);\n \n if(flag==1)\n {revert(kx,ky,kx+1,ky-1);\n return false;\n \n }\n }\n //rd\n if(kx+1<=7&&ky+1<=7)\n {\n move2(kx,ky,kx+1,ky+1);\n \n if(flag==1)\n {revert(kx,ky,kx+1,ky+1);\n return false;\n \n }\n }\n return true; \n }", "public void movePlayer(String direction) {\n if(playerAlive(curPlayerRow, curPlayerCol)){\n if(direction.equals(\"u\")&&(curPlayerRow-1)>=0){\n overwritePosition(curPlayerRow, curPlayerCol, (curPlayerRow-1), curPlayerCol);\n curPlayerRow -= 1;\n }else if(direction.equals(\"d\")&&(curPlayerRow+1)<=7){\n overwritePosition(curPlayerRow, curPlayerCol, (curPlayerRow+1), curPlayerCol);\n curPlayerRow += 1;\n }else if(direction.equals(\"l\")&&(curPlayerCol-1)>=0){\n overwritePosition(curPlayerRow, curPlayerCol, curPlayerRow, (curPlayerCol-1));\n curPlayerCol -= 1;\n }else if(direction.equals(\"r\")&&(curPlayerCol+1)<=9){\n overwritePosition(curPlayerRow, curPlayerCol, curPlayerRow, (curPlayerCol+1));\n curPlayerCol += 1;\n }\n }\n if(playerFoundTreasure(curPlayerRow, curPlayerCol)){\n playerWins();\n }\n adjustPlayerLifeLevel(curPlayerRow, curPlayerCol);\n int[] array = calcNewTrollCoordinates(curPlayerRow, curPlayerCol, curTrollRow, curTrollCol);\n if(curPlayerRow == curTrollRow && curPlayerCol == curTrollCol){\n gameBoard[curTrollRow][curTrollCol] = new TrollPiece();\n }else{\n int newTrollRow = array[0];\n int newTrollCol = array[1];\n overwritePosition(curTrollRow, curTrollCol, newTrollRow, newTrollCol);\n curTrollRow = newTrollRow;\n curTrollCol = newTrollCol;\n }\n }", "@Override\n public boolean move(Coordinates beg, Coordinates end)\n {\n int mult = Player.PlayerType.White == type ? 1 : -1;\n boolean isKilling = false;\n\n // If end coordinates have an enemy in sight, set isKilling to true\n if (board.grid[end.r][end.c] != null)\n isKilling = true;\n\n // Checks if movement makes the \"L\" shape\n if (Math.abs(end.c - beg.c) == 1 && Math.abs(end.r - beg.r) == 2\n || Math.abs(end.c - beg.c) == 2 && Math.abs(end.r - beg.r) == 1) {\n System.out.println(\"Movement shape is correct for knight\");\n } else {\n System.out.println(\"Movement shape is incorrect for knight\");\n return false;\n }\n // If killing\n if (isKilling == true) {\n System.out.println(\"Murder is possible for knight\");\n board.grid[end.r][end.c] = null;\n board.grid[end.r][end.c] = board.grid[beg.r][beg.c];\n board.grid[beg.r][beg.c] = null;\n System.out.println(\"Murder by knight is successful\");\n } else {\n // If not killing\n board.grid[end.r][end.c] = board.grid[beg.r][beg.c];\n board.grid[beg.r][beg.c] = null;\n System.out.println(\"Knight movement successful\");\n return true;\n }\n\n return true;\n }", "public boolean move(Block moveTo, boolean check, String move){\r\n\t\t//Translate File and Rank to array indices\r\n\t\t\t\tint srcFile = this.getBlock().getFile();\r\n\t\t\t\tint srcRank = chess.Chess.Rmap.get(this.getBlock().getRank()+\"\");\r\n\t\t\t\tint destFile = moveTo.getFile();\r\n\t\t\t\tint destRank = chess.Chess.Rmap.get(moveTo.getRank()+\"\"); \r\n\t\t\t\t\r\n\t\t\t\tif(((Math.abs(srcRank-destRank)==1 && Math.abs(srcFile-destFile)==2) || (Math.abs(srcRank-destRank)==2 && Math.abs(srcFile-destFile)==1))){\r\n\t\t\t\t\tif(moveTo.isOccupied()){\r\n\t\t\t\t\t\tif(moveTo.getPiece().getColor().equals(chess.Chess.board[srcRank][srcFile].getPiece().getColor())==true){\r\n\t\t\t\t\t\t\tif(check == true){\r\n\t\t\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tSystem.out.println(\"Invalid move, try again\");\r\n\t\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t//A check to see if this move puts the opponent's King in check\r\n\t\t\t\t\t\tif(check == true){\r\n\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t//Call deletePiece to indicate that target piece has been captured\r\n\t\t\t\t\t\tchess.Chess.board[destRank][destFile].getPiece().deletePiece(chess.Chess.board[destRank][destFile].getPiece().getNumber(), chess.Chess.board[destRank][destFile].getPiece());\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setPiece(getBlock().getPiece());\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif(chess.Chess.board[destRank][destFile].getPiece().getColor().equals(\"White\"))\r\n\t\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setDisplay(\"wN \");\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setDisplay(\"bN \");\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tthis.getBlock().setOccupied(false);\r\n\t\t\t\t\t\tthis.getBlock().setPiece(null);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif(this.getBlock().isShaded()){\r\n\t\t\t\t\t\t\tthis.getBlock().setDisplay(\"## \");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse{\r\n\t\t\t\t\t\t\tthis.getBlock().setDisplay(\" \");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tthis.setBlock(moveTo);\r\n\t\t\t\t\t\tchess.Chess.printBoard();\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\telse{\r\n\t\t\t\t\t\t//A check to see if this move puts the opponent's King in check\r\n\t\t\t\t\t\tif(check == true){\r\n\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setPiece(getBlock().getPiece());\r\n\t\t\t\t\t\tif(chess.Chess.board[destRank][destFile].getPiece().getColor().equals(\"White\"))\r\n\t\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setDisplay(\"wN \");\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setDisplay(\"bN \");\r\n\t\t\t\t\t\tchess.Chess.board[destRank][destFile].setOccupied(true);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tthis.getBlock().setOccupied(false);\r\n\t\t\t\t\t\tthis.getBlock().setPiece(null);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif(this.getBlock().isShaded()){\r\n\t\t\t\t\t\t\tthis.getBlock().setDisplay(\"## \");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse{\r\n\t\t\t\t\t\t\tthis.getBlock().setDisplay(\" \");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tthis.setBlock(moveTo);\r\n\t\t\t\t\t\tchess.Chess.printBoard();\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse{\r\n\t\t\t\t\tif(check == true){\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tSystem.out.println(\"Invalid move, try again\");\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t}", "public void challengeMove(){\n int maxOutcome = -1;\n int returnIndex = -1;\n Hole lastHole;\n Hole selectedHole;\n ArrayList<Hole> availableHoles = availableMoves(nextToPlay);\n for(int i = 0; i < availableHoles.size(); i++){\n selectedHole = availableHoles.get(i);\n lastHole = holes[(selectedHole.getHoleIndex() + selectedHole.getNumberOfKoorgools() - 1) % 18];\n if(lastHole.getOwner() != nextToPlay){\n int numOfKorgools = lastHole.getNumberOfKoorgools() +1;\n if(numOfKorgools == 3 && !nextToPlay.hasTuz()){\n int otherTuzIndex = getPlayerTuz(Side.WHITE);\n if(otherTuzIndex == -1 || ((otherTuzIndex + 9) != lastHole.getHoleIndex())) {\n redistribute(selectedHole.getHoleIndex());\n return;\n }\n redistribute(selectedHole.getHoleIndex());\n return;\n }\n if(numOfKorgools % 2 == 0 && numOfKorgools > maxOutcome){\n maxOutcome = numOfKorgools;\n returnIndex = selectedHole.getHoleIndex();\n }\n }\n }\n if(returnIndex <= -1){\n randomMove();\n return;\n }\n redistribute(returnIndex);\n }", "@Override\n public void lastMove( PlayerMove playerMove ) {\n int row = playerMove.getCoordinate().getRow();\n int col = playerMove.getCoordinate().getCol();\n int team = playerMove.getPlayerId();\n if(row%2 == 0 && col%2 == 0){\n if(team == 1){\n Dot n1 = board.getNode(new Coordinate(row+1,col));\n Dot n2 = board.getNode(new Coordinate(row -1,col));\n n1.addNeighbor(n2);\n n2.addNeighbor(n1);\n }\n else {\n Dot n1 = board.getNode(new Coordinate(row, col + 1));\n Dot n2 = board.getNode(new Coordinate(row, col - 1));\n n1.addNeighbor(n2);\n n2.addNeighbor(n1);\n }\n }\n else{\n if(team == 1){\n Dot n1 = board.getNode(new Coordinate(row,col+1));\n Dot n2 = board.getNode(new Coordinate(row ,col-1));\n n1.addNeighbor(n2);\n n2.addNeighbor(n1);\n }\n else {\n Dot n1 = board.getNode(new Coordinate(row+1, col));\n Dot n2 = board.getNode(new Coordinate(row-1, col));\n n1.addNeighbor(n2);\n n2.addNeighbor(n1);\n }\n }\n\n }", "@Override\n\tpublic void moveTowards(int destination) {\n \tif (stepCount % 2 == 0) {\n \tif (getFloor() < destination) {\n \t\tmoveUpstairs();\n \t} else {\n \t\tmoveDownstairs();\n \t}\n \t}\n }", "public boolean movePlayer(MazePlayer p, Direction d) {\n//\t System.out.println(\"Player \"+p.name+\" requests to move in direction \"+d);\n// players can move through walls with some small probability!\n\t\t // calculate the new position after the move \n\t\t MazePosition oldPos = playerPosition.get(p.name);\n\t\t MazePosition newPos = theBoard.tryMove(oldPos,d);\n\n\t\t \n\t\t //make sure there is no other player at that position\n\t\t // and if there is someone there then just return without moving\n\t\t if (playerPosition.containsValue(newPos)){\n\t\t\t if (!newPos.equals(oldPos))\n\t\t\t\t if (debugging) System.out.println(\"player \"+p.name+\" tried to move into an occupied space.\");\n\t\t\t else\n\t\t\t\t if (debugging) System.out.println(p.name+\" stays at \"+oldPos);\n\t\t\t return false;\n\t\t }\n\t\t \n\t\t //otherwise, make the move\n\t\t playerPosition.put(p.name,newPos);\n\t\t if (debugging) System.out.println(p.name+\": \"+oldPos+\" -> \"+newPos);\n\t\t \n\t\t //take off points if you moved through a wall\n\t\t if (!theBoard.canMove(oldPos,d)){\n\t\t\t score.put(p.name,score.get(p.name)-2);\n\t\t\t if (debugging) System.out.println(p.name+\" moved through a wall\");\n\t\t }\n\t\t \n\t\t // mark that old space as \"free space\"\n\t\t freeSpace.add(0,oldPos);\n\t\t \n\t\t // check to see if there is a jewel in the new position.\n\t\t int i = jewelPosition.indexOf(newPos);\n\t\t if (i > -1) {\n\t\t\t // add 5 to the score\n\t\t\t score.put(p.name,score.get(p.name)+5);\n\t\t\t // remove the jewel\n\t\t\t jewelPosition.remove(i);\n\t\t\t if (debugging) System.out.println(\"and lands on a jewel!, score is now \" +score.get(p.name));\n\t\t\t // add another jewel\n\t\t\t MazePosition q = getEmptySpace();\n\t\t\t jewelPosition.add(q);\n\t\t\t if (debugging) System.out.println(\"adding a new jewel at \"+q);\n\t\t\t \n\t\t }\n\t\t else {\n\t\t\t // if no jewel, then remove the space from the freeSpace list\n\t\t\t freeSpace.remove(newPos);\n\t\t }\n\t\t return true;\n\n }", "@Override\n public void noteNewTurn()\n {\n if ( traceStats && stateMachine.getInstanceId() == 1 )\n {\n ForwardDeadReckonLegalMoveInfo[] masterList = stateMachine.getFullPropNet().getMasterMoveList();\n for(int i = 0; i < bestResponseScores.length; i++)\n {\n float best = -Float.MAX_VALUE;\n float bestFollow = -Float.MAX_VALUE;\n int bestIndex = -1;\n int bestFollowIndex = -1;\n for(int j = 0; j < bestResponseScores.length; j++)\n {\n if ( responseSampleSize[i][j] > 0 )\n {\n float score = bestResponseScores[i][j]/responseSampleSize[i][j];\n if ( masterList[i].mRoleIndex != masterList[j].mRoleIndex)\n {\n if ( score > best )\n {\n best = score;\n bestIndex = j;\n }\n }\n else\n {\n if ( score > bestFollow )\n {\n bestFollow = score;\n bestFollowIndex = j;\n }\n }\n }\n }\n\n LOGGER.info(\"Best response to \" + masterList[i].mInputProposition + \": \" + (bestIndex == -1 ? \"NONE\" : masterList[bestIndex].mInputProposition + \" (\" + (100*best) + \"% [\" + responseSampleSize[i][bestIndex] + \"] )\"));\n LOGGER.info(\"Best follow-on to \" + masterList[i].mInputProposition + \": \" + (bestFollowIndex == -1 ? \"NONE\" : masterList[bestFollowIndex].mInputProposition + \" (\" + (100*bestFollow) + \"% [\" + responseSampleSize[i][bestFollowIndex] + \"] )\"));\n if ( bestIndex != -1 && opponentEquivalent[bestIndex] != bestFollowIndex )\n {\n int bestDeny = opponentEquivalent[bestIndex];\n LOGGER.info(\"Best denial to \" + masterList[i].mInputProposition + \": \" + (bestDeny == -1 ? \"NONE\" : masterList[bestDeny].mInputProposition + \" (\" + (100*(bestResponseScores[i][bestDeny]/responseSampleSize[i][bestDeny])) + \"% [\" + responseSampleSize[i][bestDeny] + \"] )\"));\n }\n }\n }\n\n // Reset the stats\n for(int i = 0; i < bestResponseScores.length; i++)\n {\n for(int j = 0; j < bestResponseScores.length; j++)\n {\n bestResponseScores[i][j] /= 2;\n responseSampleSize[i][j] /= 2;\n }\n }\n }", "private void moveOrTurn() {\n\t\t// TEMP: look at center of canvas if out of bounds\n\t\tif (!isInCanvas()) {\n\t\t\tlookAt(sens.getXMax() / 2, sens.getYMax() / 2);\n\t\t}\n\n\t\t// if we're not looking at our desired direction, turn towards. Else, move forward\n\t\tif (needToTurn()) {\n\t\t\tturnToDesiredDirection();\n\t\t} else {\n\t\t\tmoveForward(2.0);\n\t\t}\n\n\t\t// move in a random direction every 50 roaming ticks\n\t\tif (tickCount % 100 == 0) {\n\t\t\tgoRandomDirection();\n\t\t}\n\t\ttickCount++;\n\t}", "public boolean move(int x, int y, CheckersBoard board) {\n if (whiteTurn == true && team == Constants.TeamId.team1Id) {\n return false;\n }\n if (whiteTurn == false && team == Constants.TeamId.team2Id) {\n return false;\n }\n /**\n * then change the x - y coords of the piece\n * update the UI to remove the highlighted squares then move the piece\n * if chess and shared square you take a piece\n * if checkers you jumped them you take the piece\n * return new x - y components\n *\n * if this is too high up in the tree you can override this implementation or update it\n * to fit specific pieces if its not working for some reason\n */\n if (possible(x, y, gameBoard)) {\n int changex = this.getX()-x;\n int changey = this.getY()-y;\n CheckersPiece temp = gameBoard.boardPositions[getX()][getY()];\n gameBoard.boardPositions[getX()][getY()] = null;\n gameBoard.boardPositions[x][y] = temp;\n if (gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2] != null) {\n System.out.println(\"Here\");\n if (gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2].team != this.team) {\n gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2].imageView.setVisibility(View.GONE);\n gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2] = null;\n }\n }\n this.setX(x);\n this.setY(y);/*\n if (Math.abs(changex) == 2) {\n gameBoard.boardPositions[x + (changex/2)][y + (changey/2)] = null;\n if (team == Constants.TeamId.team1Id) {\n board.numPieces1--;\n } else if (team == Constants.TeamId.team2Id) {\n board.numPieces0--;\n }\n }*/\n\n gameBoard.boardPositions[x][y].imageView.setX(142*x);\n gameBoard.boardPositions[x][y].imageView.setY(142*y);\n // flips after move is\n whiteTurn = !whiteTurn;\n gameBoard.startTimer();\n }\n //setUpUI(gameBoard);\n if (getY() == 7 && team == Constants.TeamId.team2Id) {\n board.crown(this);\n }\n if (getY() == 0 && team == Constants.TeamId.team1Id) {\n board.crown(this);\n }\n return possible(x, y, gameBoard);\n }", "public void checkMoveOrPass(){\n if (this.xTokens.size() > 0) {\n this.diceRoller = false;} \n else { //if no tokens to move, pass and let player roll dice\n this.turn++;\n //System.out.println(\"next turn player \" + this.players[currentPlayer].getColor());\n }\n this.currentPlayer = this.xPlayers.get(this.turn % this.xPlayers.size());\n }", "private boolean isLastMoveRochade()\r\n\t{\r\n\t\tMove lastMove = getLastMove();\r\n\t\tif (lastMove == null) return false;\r\n\t\tPiece king = lastMove.to.piece;\r\n\t\tif (!(king instanceof King)) return false;\r\n\t\t\r\n\t\tint y = king.getColor().equals(Color.WHITE) ? 0 : 7;\r\n\t\tif (lastMove.to.coordinate.y != y) return false;\r\n\t\t\r\n\t\tint xDiffAbs = Math.abs(lastMove.to.coordinate.x - lastMove.from.coordinate.x); \r\n\t\treturn xDiffAbs == 2;\r\n\t}", "public void move()\n {\n daysSurvived+=1;\n\n energy -= energyLostPerDay;\n\n Random generator = new Random();\n\n //losowo okreslony ruch na podstawie genomu\n int turnIndex = generator.nextInt((int)Math.ceil(Genome.numberOfGenes));\n int turn = genome.getGenome().get(turnIndex);\n\n //wywolujemy metode obrotu - dodaje odpowiednio liczbe do aktualnego kierunku\n direction.turn(turn);\n\n //zmieniamy pozycje zwierzaka przez dodanie odpowiedniego wektora\n position = position.add(direction.move());\n //walidacja pozycji tak, by wychodzac za mape byc na mapie z drugiej strony\n position.validatePosition(map.getWidth(),map.getHeight());\n\n moveOnSimulation();\n\n //jesli po ruchu zwierzaczek nie ma juz energii na kolejny ruch\n if(energy < energyLostPerDay )\n {\n this.animalHungry = true;\n }\n }", "private int Win_Move() {\n\t\tfinal int POSSIBLE_WIN = 8;\n\t\tint move = NO_MOVE;\n\t\tif(( gameBoard[TOP_LEFT] + gameBoard[TOP_CENTER] + gameBoard[TOP_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[TOP_CENTER] == EMPTY){\n\t\t\t\tmove = TOP_CENTER;\n\t\t\t}else if (gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[CTR_LEFT] + gameBoard[CTR_CENTER] + gameBoard[CTR_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[CTR_LEFT] == EMPTY){\n\t\t\t\tmove = CTR_LEFT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[CTR_RIGHT] == EMPTY){\n\t\t\t\tmove = CTR_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[BTM_LEFT] + gameBoard[BTM_CENTER] + gameBoard[BTM_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}else if (gameBoard[BTM_CENTER] == EMPTY){\n\t\t\t\tmove = BTM_CENTER;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_LEFT] + gameBoard[CTR_LEFT] + gameBoard[BTM_LEFT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[CTR_LEFT] == EMPTY){\n\t\t\t\tmove = CTR_LEFT;\n\t\t\t}else if (gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_CENTER] + gameBoard[CTR_CENTER] + gameBoard[BTM_CENTER]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_CENTER] == EMPTY){\n\t\t\t\tmove = TOP_CENTER;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_CENTER] == EMPTY){\n\t\t\t\tmove = BTM_CENTER;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_RIGHT] + gameBoard[CTR_RIGHT] + gameBoard[BTM_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}else if (gameBoard[CTR_RIGHT] == EMPTY){\n\t\t\t\tmove = CTR_RIGHT;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_LEFT] + gameBoard[CTR_CENTER] + gameBoard[BTM_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_RIGHT] + gameBoard[CTR_CENTER] + gameBoard[BTM_LEFT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}\n\t\t}\n\t\treturn move;\n\t}", "private void calculateTurn () {\n // Do we need a turn? If not, we're done.\n if (dirOne.opposite() == dirTwo) return;\n /*\n * We need a turn. The coordinates of the turn point will be the x\n * coordinate of the north/south leg and the y coordinate of the\n * east/west leg.\n */\n if (dirOne == Direction.north || dirOne == Direction.south) {\n xTurn = xOne;\n yTurn = yTwo;\n } else {\n xTurn = xTwo;\n yTurn = yOne;\n }\n }", "private void moveRemainingMhos() {\n\t\t\n\t\t//Iterate through every mho's X and Y values\n\t\tfor(int i = 0; i < mhoLocations.size()/2; i++) {\n\t\t\t\n\t\t\t//Assign mhoX and mhoY to the X and Y values of the mho that is currently being tested\n\t\t\tint mhoX = mhoLocations.get(i*2);\n\t\t\tint mhoY = mhoLocations.get(i*2+1);\n\t\t\t\n\t\t\t//Check if there is a fence 1 block away from the mho\n\t\t\tif(newMap[mhoX][mhoY+1] instanceof Fence || newMap[mhoX][mhoY-1] instanceof Fence || newMap[mhoX-1][mhoY] instanceof Fence || newMap[mhoX-1][mhoY+1] instanceof Fence || newMap[mhoX-1][mhoY-1] instanceof Fence || newMap[mhoX+1][mhoY] instanceof Fence || newMap[mhoX+1][mhoY+1] instanceof Fence || newMap[mhoX+1][mhoY-1] instanceof Fence) {\n\t\t\t\t\n\t\t\t\t//Assign the new map location as a Mho\n\t\t\t\tnewMap[mhoX][mhoY] = new BlankSpace(mhoX, mhoY, board);\n\t\t\t\t\n\t\t\t\t//Set the mho's move in the moveList\n\t\t\t\tmoveList[mhoX][mhoY] = Legend.SHRINK;\n\t\t\t\t\n\t\t\t\t//remove each X and Y from mhoLocations\n\t\t\t\tmhoLocations.remove(i*2+1);\n\t\t\t\tmhoLocations.remove(i*2);\n\t\t\t\t\n\t\t\t\t//Call moveRemainingMhos again, because the list failed to be checked through completely\n\t\t\t\tmoveRemainingMhos();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}", "private boolean fourstonesReached() {\n\t\t\n\t\t\n\t\t//TO-DO: evtl. Abbruch, wenn ein freies Feld entdeckt wird\n\t\t\n\t\tint counter=0;\n\t\t\n\t\t//check horizontal lines\n\t\tfor(int i=0; i<horizontal;i++ ) {\n\t\t\t\n\t\t\tfor(int j=0; j<vertical;j++ ) {\n\t\t\t\t\n\t\t\t\tif(board[i][j] == player.ordinal()) {\n\t\t\t\t\tcounter++;\n\t\t\t\t\tif(counter == 4) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}else {\n\t\t\t\t\tcounter=0;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t\tcounter=0;\n\t\t}\n\t\t\n\t\t\n\t\t//check vertical lines\n\t\tfor(int i=0; i<vertical;i++ ) {\n\t\t\t\n\t\t\tfor(int j=0; j<horizontal;j++ ) {\n\t\t\t\t\n\t\t\t\tif(board[j][i] == player.ordinal()) {\n\t\t\t\t\tcounter++;\n\t\t\t\t\tif(counter == 4) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}else {\n\t\t\t\t\tcounter=0;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t\tcounter=0;\n\t\t}\n\t\t\n\t\t//check diagonal \n\t\tint ordinal = player.ordinal();\n\t\t\n\t\tif( //checking lines from up-left to down-right\n\t\t\t(board[3][0] == ordinal && board[2][1] == ordinal && board[1][2] == ordinal && board[0][3] == ordinal) || \n\t\t\t(board[4][0] == ordinal && board[3][1] == ordinal && board[2][2] == ordinal && board[1][3] == ordinal) ||\n\t\t\t(board[3][1] == ordinal && board[2][2] == ordinal && board[1][3] == ordinal && board[0][4] == ordinal) ||\n\t\t\t(board[5][0] == ordinal && board[4][1] == ordinal && board[3][2] == ordinal && board[2][3] == ordinal) ||\n\t\t\t(board[4][1] == ordinal && board[3][2] == ordinal && board[2][3] == ordinal && board[1][4] == ordinal) ||\n\t\t\t(board[3][2] == ordinal && board[2][3] == ordinal && board[1][4] == ordinal && board[0][5] == ordinal) ||\n\t\t\t(board[5][1] == ordinal && board[4][2] == ordinal && board[3][3] == ordinal && board[2][4] == ordinal) ||\n\t\t\t(board[4][2] == ordinal && board[3][3] == ordinal && board[2][4] == ordinal && board[1][5] == ordinal) ||\n\t\t\t(board[3][3] == ordinal && board[2][4] == ordinal && board[1][5] == ordinal && board[0][6] == ordinal) ||\n\t\t\t(board[5][2] == ordinal && board[4][3] == ordinal && board[3][4] == ordinal && board[2][5] == ordinal) ||\n\t\t\t(board[4][3] == ordinal && board[3][4] == ordinal && board[2][5] == ordinal && board[1][6] == ordinal) ||\n\t\t\t(board[5][3] == ordinal && board[4][4] == ordinal && board[3][5] == ordinal && board[2][6] == ordinal) ||\n\t\t\t\n\t\t\t//checking lines from up-right to down-left\n\t\t\t(board[2][0] == ordinal && board[3][1] == ordinal && board[4][2] == ordinal && board[5][3] == ordinal) ||\n\t\t\t(board[1][0] == ordinal && board[2][1] == ordinal && board[3][2] == ordinal && board[4][3] == ordinal) ||\n\t\t\t(board[2][1] == ordinal && board[3][2] == ordinal && board[4][3] == ordinal && board[5][4] == ordinal) ||\n\t\t\t(board[0][0] == ordinal && board[1][1] == ordinal && board[2][2] == ordinal && board[3][3] == ordinal) ||\n\t\t\t(board[1][1] == ordinal && board[2][2] == ordinal && board[3][3] == ordinal && board[4][4] == ordinal) ||\n\t\t\t(board[2][2] == ordinal && board[3][3] == ordinal && board[4][4] == ordinal && board[5][5] == ordinal) ||\n\t\t\t(board[0][1] == ordinal && board[1][2] == ordinal && board[2][3] == ordinal && board[3][4] == ordinal) ||\n\t\t\t(board[1][2] == ordinal && board[2][3] == ordinal && board[3][4] == ordinal && board[4][5] == ordinal) ||\n\t\t\t(board[2][3] == ordinal && board[3][4] == ordinal && board[4][5] == ordinal && board[5][6] == ordinal) ||\n\t\t\t(board[0][2] == ordinal && board[1][3] == ordinal && board[2][4] == ordinal && board[3][5] == ordinal) ||\n\t\t\t(board[1][3] == ordinal && board[2][4] == ordinal && board[3][5] == ordinal && board[4][6] == ordinal) ||\n\t\t\t(board[0][3] == ordinal && board[1][4] == ordinal && board[2][5] == ordinal && board[3][6] == ordinal)) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}", "@Override\r\n\tpublic int move(int lastMove, int[] takenList, int depthLimit) \r\n\t{\r\n\t\tGameState myState = new GameState(takenList, lastMove);\r\n\t\tdouble maxValue = max_value(myState, depthLimit);\r\n\t\tint myBestMove = myState.bestMove;\r\n\t\tif (myState.leaf) //why did i do this\r\n\t\t{\r\n\t\t\treturn -1;\r\n\t\t}\r\n\t\treturn myBestMove;\r\n\t}", "public abstract void calcPathToKing(Space kingSpot);", "public void determineRank(){\r\n //ranks highcard 0, pair 1, twopair 2, three of a kind 3, straight 4, flush 5,\r\n //full house 6, four of a kind 7 , straight flush 8, royal flush 9\r\n //I should start top down.\r\n\r\n //Royal Flush\r\n if(isRoyalFlush())\r\n setRank(9);\r\n //Straight flush\r\n else if(isFlush() && isStraight())\r\n setRank(8);\r\n //four of a kind\r\n else if(isFourOfAKind())\r\n setRank(7);\r\n //full house\r\n else if( isFullHouse())\r\n setRank(6);\r\n //flush\r\n else if(isFlush())\r\n setRank(5);\r\n //straight\r\n else if(isStraight())\r\n setRank(4);\r\n //three of a kind\r\n else if(isThreeOfAKind())\r\n setRank(3);\r\n //twoPair\r\n else if(isTwoPair())\r\n setRank(2);\r\n //pair\r\n else if(isPair())\r\n setRank(1);\r\n //highcard\r\n else\r\n setRank(0);\r\n\r\n }", "public void performMove() {\n\t\tfor (int x = 0; x <= size-1; x++)\n\t\t\tfor (int y = 0; y <= size-1; y++)\n\t\t\t\tlocalBoard[y][x] = 0;\n\t\t\n\t\t//reset the flag that indicates if a move has been found that decreases the heuristic\n\t\tfoundBetterMove = false;\n\t\t\n\t\t//fill in the appropriate heuristic values\n\t\tpopulateHillValues();\n\t\tArrayList<PotentialMove> myBestList = new ArrayList<PotentialMove>();\n\n\t\t//Find the square with the lowest heuristic value. this should really write the values to an array. \n\t\tint squareDifferential = -1;\n\t\t//String outValue = \"\";\n\t\tfor (int y = 0; y <= size-1; y++) {\n\t\t\tfor (int x = 0; x <= size-1; x++){\n\t\t\t\t//outValue = outValue + localBoard[y][x];\n\t\t\t\tif (squareDifferential < 0) //lowestSquareFound not found yet \n\t\t\t\t{\n\t\t\t\t\tif ((NQueens.queens[x] != y) && //set if the current square isn't already occupied by a queen\n\t\t\t\t\t\t\t(localBoard[NQueens.queens[x]][x] >= localBoard[y][x])) {\n\t\t\t\t\t\tif (localBoard[y][x] == localBoard[NQueens.queens[x]][x])\n\t\t\t\t\t\t\tmyBestList.add(new PotentialMove(x, y, true));\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tmyBestList.add(new PotentialMove(x, y, false));\n\t\t\t\t\t\tsquareDifferential = localBoard[NQueens.queens[x]][x] - localBoard[y][x];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if ((localBoard[NQueens.queens[x]][x] - localBoard[y][x]) > squareDifferential) { // find the square with the largest differential in value from the queen in the column\n\t\t\t\t\tmyBestList.clear();\n\t\t\t\t\tmyBestList.add(new PotentialMove(x, y, false));\n\t\t\t\t\tsquareDifferential = localBoard[NQueens.queens[x]][x] - localBoard[y][x];\n\t\t\t\t}\n\t\t\t\telse if (((localBoard[NQueens.queens[x]][x] - localBoard[y][x]) == squareDifferential) && // the differential is equal to the current best differential\n\t\t\t\t\t\t(NQueens.queens[x] != y)) { // and isn't already occupied by a queen\n\t\t\t\t\tmyBestList.add(new PotentialMove(x, y, true));\n\t\t\t\t}\n\t\t\t\t//else the square is higher, has a queen or isn't marginally better than the current queen's position in the row\n\t\t\t}\n\t\t\t//outValue = outValue + \"\\n\";\n\t\t}\n\t\t//JOptionPane.showMessageDialog(null, outValue);\n\t\t\n\t\tif (myBestList.isEmpty())\n\t\t\treturn;\n\t\t\n\t\tint listSize = myBestList.size();\n\t\tPotentialMove bestMove;\n\t\t\n\t\t//grab the non-Sideways moves first\n\t\tfor (int i = 0; i < listSize; i++) {\n\t\t\tif (!(myBestList.get(i).isSideways)) {\n\t\t\t\tbestMove = myBestList.get(i);\n\t\t\t\tfoundBetterMove = true;\n\t\t\t\tsidewaysMoves = 0;\n\t\t\t\tNQueens.queens[bestMove.xCoordinate] = bestMove.yCoordinate;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (sidewaysMoves > MAXSIDEWAYSMOVES) { // hit MAXSIDEWAYSMOVES consecutive sideways moves, mark as unsolvable\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t//all available moves sideways moves, let's select one randomly\n\t\tRandom generator = new Random();\n\t\tint randomElement = generator.nextInt(listSize);\n\t\t\n\t\tbestMove = myBestList.get(randomElement);\n\t\tfoundBetterMove = true;\n\t\tsidewaysMoves++;\n\t\tNQueens.queens[bestMove.xCoordinate] = bestMove.yCoordinate;\n\t}", "@Override\n public State doMove(State otherState) {\n\tWaterJugState state = (WaterJugState) otherState;\n \n if(this.getMoveName().equals(\"Fill Jug X\")){\n //if water jug X has room to add to \n if(state.getJugX() < 3){\n nextState = new WaterJugState(3, state.getJugY());\n } //else water jug x is full =3\n else {\n nextState = null;\n }\n }\n else if(this.getMoveName().equals(\"Fill Jug Y\")){\n if(state.getJugY()<4){\n nextState = new WaterJugState(state.getJugX(),4);\n }\n else{\n nextState=null;\n }\n }\n else if(this.getMoveName().equals(\"Empty Jug X\")){\n if(state.getJugX()>0){\n nextState = new WaterJugState(0,state.getJugY());\n }\n else{\n nextState=null;\n }\n }\n else if(this.getMoveName().equals(\"Empty Jug Y\")){\n if(state.getJugY()>0){\n nextState = new WaterJugState(state.getJugX(),0); \n }\n else{\n nextState= null;\n }\n }\n else if(this.getMoveName().equals(\"Transfer Jug X to Jug Y\")){\n if(state.getJugX()>0 && state.getJugY()<4){\n int Ycount=state.getJugY();\n int Xcount=state.getJugX();\n int total=Ycount+Xcount;\n if(total<=4){\n nextState = new WaterJugState(0,state.getJugX()+state.getJugY()); \n }\n else if(total>4){\n nextState= new WaterJugState((state.getJugX()+state.getJugY()-4),(state.getJugX()+state.getJugY())-(state.getJugX()+state.getJugY()-4)); \n }\n }\n else{\n nextState= null;\n }\n }\n else if(this.getMoveName().equals(\"Transfer Jug Y to Jug X\")){\n if(state.getJugY()>0 && state.getJugX()<3){\n int Ycount=state.getJugY();\n int Xcount=state.getJugX();\n int total=Ycount+Xcount;\n if(total<=3){\n nextState = new WaterJugState(state.getJugX()+state.getJugY(),0); \n }\n else if(total>3){\n nextState= new WaterJugState((state.getJugX()+state.getJugY())-(state.getJugX()+state.getJugY()-3),(state.getJugX()+state.getJugY()-3)); \n }\n }\n else{\n nextState= null;\n } \n }\n \n return nextState; \n }", "private void wander(){\n\t\tmonster.moveRandom();\r\n\t\tsaveMove();\r\n\t}", "public void updateWithPointWonBy(Player player) {\n if(managerTennisMatch.statusTennisMatch == \"ClassicalGame\") {\n if (player == player1) {\n managerTennisMatch.checkScoreAndUpdateGame(player, player2);\n } else {\n managerTennisMatch.checkScoreAndUpdateGame(player, player1);\n }\n } else if(managerTennisMatch.statusTennisMatch == \"TieBreakInProgress\") {\n player.setScore(player.getScore() + 1);\n if((player1.getScore() >= 7 && player1.getScore() - player2.getScore() >= 2) || (player2.getScore() >= 7 && player2.getScore() - player1.getScore() >= 2)) {\n tennisSetList.get(tennisSetList.size() - 1).getBaseGameList().add(new TieBreakGame(player));\n player1.setScore(0);\n player2.setScore(0);\n }\n } else {\n return;\n }\n }", "public int move(String direction) {\n int head = snake.peekFirst();\n int headRow = head / width;\n int headCol = head % width;\n switch (direction) {\n case \"U\": headRow--; break;\n case \"D\": headRow++; break;\n case \"L\": headCol--; break;\n case \"R\": headCol++; break;\n }\n int newHead = headRow * width + headCol;\n occupied.remove(snake.peekLast());\n if (headRow < 0 || headRow == height || headCol < 0 || headCol == width\n || occupied.contains(newHead)) {\n return score = -1;\n }\n occupied.add(newHead);\n snake.offerFirst(newHead);\n if (foodIndex < food.length && headRow == food[foodIndex][0] && headCol == food[foodIndex][1]) {\n occupied.add(snake.peekLast()); // add back\n foodIndex++;\n return ++score;\n }\n snake.pollLast();\n return score;\n }", "public int checkForWinner() {\n\n // Check horizontal wins\n for (int i = 0; i <= 6; i += 3)\t{\n if (mBoard[i] == HUMAN_PLAYER &&\n mBoard[i+1] == HUMAN_PLAYER &&\n mBoard[i+2]== HUMAN_PLAYER)\n return 2;\n if (mBoard[i] == COMPUTER_PLAYER &&\n mBoard[i+1]== COMPUTER_PLAYER &&\n mBoard[i+2] == COMPUTER_PLAYER)\n return 3;\n }\n\n // Check vertical wins\n for (int i = 0; i <= 2; i++) {\n if (mBoard[i] == HUMAN_PLAYER &&\n mBoard[i+3] == HUMAN_PLAYER &&\n mBoard[i+6]== HUMAN_PLAYER)\n return 2;\n if (mBoard[i] == COMPUTER_PLAYER &&\n mBoard[i+3] == COMPUTER_PLAYER &&\n mBoard[i+6]== COMPUTER_PLAYER)\n return 3;\n }\n\n // Check for diagonal wins\n if ((mBoard[0] == HUMAN_PLAYER &&\n mBoard[4] == HUMAN_PLAYER &&\n mBoard[8] == HUMAN_PLAYER) ||\n (mBoard[2] == HUMAN_PLAYER &&\n mBoard[4] == HUMAN_PLAYER &&\n mBoard[6] == HUMAN_PLAYER))\n return 2;\n if ((mBoard[0] == COMPUTER_PLAYER &&\n mBoard[4] == COMPUTER_PLAYER &&\n mBoard[8] == COMPUTER_PLAYER) ||\n (mBoard[2] == COMPUTER_PLAYER &&\n mBoard[4] == COMPUTER_PLAYER &&\n mBoard[6] == COMPUTER_PLAYER))\n return 3;\n\n // Check for tie\n for (int i = 0; i < BOARD_SIZE; i++) {\n // If we find a number, then no one has won yet\n if (mBoard[i] != HUMAN_PLAYER && mBoard[i] != COMPUTER_PLAYER)\n return 0;\n }\n\n // If we make it through the previous loop, all places are taken, so it's a tie\n return 1;\n }", "public void actionPerformed(ActionEvent e) {\n timer.stop();\n //get all the available moves\n ArrayList<Point> possibleMoves = getCurrentlyValidMoves();\n canLastPlayerMove = false;\n try {\n //check if we can move\n if( possibleMoves.size() == 0 ){\n return;\n }\n //make an array to store the best moves available\n ArrayList<Point> bestMoves = new ArrayList<Point>();\n //the lower the level, the higher priority is assigned to the move\n //a move of level 10 is the absolute lowest\n //this heuristic follows the strategy I use, omitting situation-specific content\n int level = 10;\n for (Point p : possibleMoves) {\n int x = (int) p.getX();\n int y = (int) p.getY();\n if ((x == 0 || x == 7) && (y == 0 || y == 7)) {\n if (level > 0) {\n bestMoves.clear();\n level = 0;\n }\n bestMoves.add( p );\n } else if (level >= 1 && (x == 0 || y == 0 || x == 7 || y == 7)) {\n if (level > 1) {\n bestMoves.clear();\n level = 1;\n }\n bestMoves.add( p );\n } else if (level >= 2 && (x > 2 && x < 6 && y > 2 && y < 6)) {\n if ( level > 2) {\n bestMoves.clear();\n level = 2;\n }\n bestMoves.add( p );\n } else if (level >= 3 && x != 1 && x != 6 && y != 1 && y != 6) {\n if (level > 3) {\n bestMoves.clear();\n level = 3;\n }\n bestMoves.add(p);\n } else if (level >= 4) {\n bestMoves.add(p);\n }\n }\n //for debugging purposes, output the level of move chosen by the ai\n System.out.println(level);\n //select a random move from the pool of best moves\n Point move = bestMoves.get((int) (Math.random() * bestMoves.size()));\n int aix = (int) move.getX();\n int aiy = (int) move.getY();\n //move there\n attemptMove(aix, aiy);\n gamepieces[aix][aiy] = currentPlayer;\n //the ai moved, so this is true\n canLastPlayerMove = true;\n } finally { //if the ai moved or if it didn't\n //change the player\n currentPlayer = Color.WHITE;\n gameFrame.repaint();\n //if the human player has no moves left\n if( getCurrentlyValidMoves().size() == 0 ){\n if( canLastPlayerMove ){ //... and the ai could move\n //switch players, enable the ai to move again in 1 second\n currentPlayer = Color.BLACK;\n timer.start();\n }else{ //... and the ai couldn't move\n gameOver();\n }\n }\n }\n }", "public void enemymoveGarret(){\n\t\tint YEG = 0;\n\t\tint XEG = 0;\n\t\tint[] turns = new int[]{0,0,0,0,0,2,1,1,1,1,1,3};//dependign on the placement garret will move a certain way\n\t\tfor(int i = 0 ; i < this.Garret.length;i++){//this grabs garrets current locations\n\t\t\tfor(int p = 0; p < this.Garret.length;p++){\n\t\t\t\tif(this.Garret[i][p] == 1){\n\t\t\t\t\tYEG = i;\n\t\t\t\t\tXEG = p;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tint move = turns[count];\n\t\tswitch(move){//first block is up and down second block is left and right\n\t\t\tcase 0:\n\t\t\t\tif(this.area[YEG][XEG-1] != \"[ ]\"){\n\t\t\t\t\tthis.Garret[YEG][XEG-1] = 1;//to turn left\n\t\t\t\t\tthis.Garret[YEG][XEG] = 0;\n\t\t\t\t\tcount++;\n\t\t\t\t\tif(count == 12){\n\t\t\t\t\t\tcount = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\tif(this.area[YEG][XEG+1] != \"[ ]\"){\n\t\t\t\t\tthis.Garret[YEG][XEG+1] = 1;//to turn right\n\t\t\t\t\tthis.Garret[YEG][XEG] = 0;\n\t\t\t\t\tcount++;\n\t\t\t\t\tif(count == 12){\n\t\t\t\t\t\tcount = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tif(this.area[YEG-1][XEG] != \"[ ]\"){\n\t\t\t\t\tthis.Garret[YEG-1][XEG] = 1;//to turn up\n\t\t\t\t\tthis.Garret[YEG][XEG] = 0;\n\t\t\t\t\tcount++;\n\t\t\t\t\tif(count == 12){\n\t\t\t\t\t\tcount = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\tif(this.area[YEG+1][XEG] != \"[ ]\"){\n\t\t\t\t\tthis.Garret[YEG+1][XEG] = 1;//to turn down\n\t\t\t\t\tthis.Garret[YEG][XEG] = 0;\n\t\t\t\t\tcount++;\n\t\t\t\t\tif(count == 12){\n\t\t\t\t\t\tcount = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}//end of switch\t\n\t}", "private static boolean move(int k) {\n\t\tSystem.out.println(sn.arr.size());\n\t\tint nr = sn.arr.getLast().r + dx[k];\n\t\tint nc = sn.arr.getLast().c + dy[k];\n\t\tif(nr<0||nr>=map.length||nc<0||nc>=map.length)\n\t\t\treturn false;\n\t\t\n\t\tif (map[nr][nc] == 1) {\n\t\t\tappleCnt--;\n\t\t\tsn.arr.add(new node(nr, nc));\n\t\t\tsn.size++;\n\t\t\tmap[nr][nc] = 2;\n\t\t} else if (map[nr][nc] == 0) {\n\t\t\tsn.arr.add(new node(nr, nc));\n\t\t\tmap[nr][nc]=2;\n\t\t\tmap[sn.arr.getFirst().r][sn.arr.getFirst().c] = 0;\n\t\t\tsn.arr.removeFirst();\n\t\t\t\n\t\t}else {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}", "static int minStepToReachTarget(int knightPos[], int targetPos[], int N) {\n // x and y direction, where a knight can move\n int dx[] = {-2, -1, 1, 2, -2, -1, 1, 2};\n int dy[] = {-1, -2, -2, -1, 1, 2, 2, 1};\n\n // queue for storing states of knight in board\n Queue<Cell> q = new LinkedList<>();\n\n // push starting position of knight with 0 distance\n q.add(new Cell(knightPos[0], knightPos[1], 0));\n\n Cell t;\n int x, y;\n boolean[][] visit = new boolean[N + 1][N + 1];\n\n // loop untill we have one element in queue\n while (!q.isEmpty()) {\n t = q.poll();\n if (visit[t.x][t.y]) \n continue;\n visit[t.x][t.y] = true;\n\n // if current cell is equal to target cell,\n // return its distance\n if (t.x == targetPos[0] && t.y == targetPos[1]) {\n return t.dis;\n }\n\n // loop for all reahable states\n for (int i = 0; i < 8; i++) {\n x = t.x + dx[i];\n y = t.y + dy[i];\n\n // If rechable state is not yet visited and\n // inside board, push that state into queue\n if (isInside(x, y, N) && !visit[x][y]) {\n q.add(new Cell(x, y, t.dis + 1));\n }\n }\n }\n return 0;\n }", "private void fixDancerPositions() {\n\t\tif (arrangePositionCrowdAuditorium()) return;\n\t\t\n\t\tSystem.out.println(\"*************** only one row stage **************\");\n\t\tint l = 1, r = 5;\n\t\twhile (l < r) {\n\t\t\tint mid = (l + r) >> 1;\n\t\t\tboolean ret = arrangePosition(mid);\n\t\t\tif (ret) r = mid; else l = mid + 1;\n\t\t}\n\t\tboredTime = Math.max(120 - 24 * (l - 1), 12);\n\t\tSystem.out.println(\"*************** numCol: \" + l + \"***************\");\n\t\tif (!arrangePosition(l)) {\n\t\t\tSystem.out.println(\"************** change to crowd auditorium *****************\");\n\t\t\tboredTime = 12;\n\t\t\tarrangePositionCrowdAuditorium();\n\t\t}\n\t}", "private void adjustWinnerError(GNode winner) {\n\n }", "private void enemyMove() {\n\n\t\tboolean goAgain = false;\n\n\t\tint x = (int) (Math.random() * 10);\n\t\tint y = (int) (Math.random() * 10);\n\n\t\t// Make sure the enemy hits in a checkerboard pattern.\n\t\tif (x % 2 == 0) { // if x is even, y should be odd\n\t\t\tif (y % 2 == 0) {\n\t\t\t\tif (y + 1 < 10)\n\t\t\t\t\ty++;\n\t\t\t\telse\n\t\t\t\t\ty--;\n\t\t\t}\n\t\t} else { // if x is odd, y should be even\n\t\t\tif (y % 2 == 1)\n\t\t\t\tif (y + 1 < 10)\n\t\t\t\t\ty++;\n\t\t\t\telse\n\t\t\t\t\ty--;\n\t\t}\n\n\t\tif (enemyLastShotHit && getDifficulty() > 0) { // /if last shot was a\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t// hit, enemy\n\t\t\t// will try to\n\t\t\t// check around it only run if difficulty is\n\t\t\t// normal or above\n\t\t\tx = enemyLastHitX;\n\t\t\ty = enemyLastHitY;\n\n\t\t\tif (getDifficulty() != 2) {\n\n\t\t\t\tif (conflictX == 4) {\n\t\t\t\t\tconflictX = 0;\n\t\t\t\t} else if (conflictY == 4) {\n\t\t\t\t\tconflictY = 0;\n\t\t\t\t\t// System.out.println(\"conflict has been reset \");\n\t\t\t\t}\n\n\t\t\t\tif (conflictX != 0) {\n\t\t\t\t\tif (conflictX == 1)\n\t\t\t\t\t\tx++;\n\t\t\t\t\telse {\n\t\t\t\t\t\tx--;\n\t\t\t\t\t}\n\t\t\t\t\tenemyLastHitX = x;\n\t\t\t\t\tenemyLastHitY = y;\n\t\t\t\t\tconflictX = 4;\n\t\t\t\t} else if (conflictY == 1) {\n\t\t\t\t\t// System.out.println(\"checking down\");\n\t\t\t\t\tconflictY = 4;\n\t\t\t\t\ty++;\n\t\t\t\t}\n\n\t\t\t\tif (x + 1 < 10 && x - 1 >= 0) {// branch for multiple hits\n\t\t\t\t\tif (egrid[x + 1][y] == 1 && egrid[x - 1][y] == 1) {\n\t\t\t\t\t\t// System.out.println(\"conflict at \"+ex+\",\"+ey);\n\t\t\t\t\t\tenemyLastHitX = x;\n\t\t\t\t\t\tenemyLastHitY = y;\n\t\t\t\t\t\tif (x + 2 < 10) {\n\t\t\t\t\t\t\tif (egrid[x + 2][y] == 1) {\n\t\t\t\t\t\t\t\tconflictX = 1;\n\t\t\t\t\t\t\t\tx--;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconflictX = 2;\n\t\t\t\t\t\t\t\tx++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconflictX = 2;\n\t\t\t\t\t\t\tx++;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (y + 1 < 10 && y - 1 >= 0) {// branch for multiple vertical\n\t\t\t\t\t\t\t\t\t\t\t\t// hits\n\t\t\t\t\tif (egrid[x][y + 1] == 1 && egrid[x][y - 1] == 1) {\n\t\t\t\t\t\t// System.out.println(\"conflict at \"+ex+\",\"+ey);\n\t\t\t\t\t\tenemyLastHitX = x;\n\t\t\t\t\t\tenemyLastHitY = y;\n\t\t\t\t\t\tconflictY = 1;\n\t\t\t\t\t\ty--;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (conflictX == 0 && conflictY == 0) {\n\n\t\t\t\t\tif (checkDirection == 0) // checks in each direction\n\t\t\t\t\t\tx++;\n\t\t\t\t\telse if (checkDirection == 1)\n\t\t\t\t\t\tx--;\n\t\t\t\t\telse if (checkDirection == 2)\n\t\t\t\t\t\ty++;\n\t\t\t\t\telse if (checkDirection == 3) {\n\t\t\t\t\t\ty--;\n\t\t\t\t\t\tenemyLastShotHit = false;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (x < 0) // making sure coordinates stay within bounds\n\t\t\t\t\t\tx = 0;\n\t\t\t\t\telse if (x > 9)\n\t\t\t\t\t\tx = 9;\n\t\t\t\t\tif (y < 0)\n\t\t\t\t\t\ty = 0;\n\t\t\t\t\telse if (y > 9)\n\t\t\t\t\t\ty = 9;\n\t\t\t\t}\n\t\t\t} // medium diff\n\n\t\t\telse if (getDifficulty() == 2) {// hard difficulty\n\t\t\t\t// gives enemy unfair advantage\n\n\t\t\t\tif (conflictX == 4)\n\t\t\t\t\tconflictX = 0;\n\t\t\t\tif (conflictY == 4)\n\t\t\t\t\tconflictY = 0;\n\n\t\t\t\tif (conflictX != 0) {\n\t\t\t\t\tif (conflictX == 1)\n\t\t\t\t\t\tx++;\n\t\t\t\t\telse {\n\t\t\t\t\t\tx--;\n\t\t\t\t\t}\n\t\t\t\t\tenemyLastHitX = x;\n\t\t\t\t\tenemyLastHitY = y;\n\t\t\t\t\tconflictX = 4;\n\t\t\t\t} else if (conflictY == 1) {\n\t\t\t\t\tconflictY = 4;\n\t\t\t\t\ty++;\n\t\t\t\t}\n\n\t\t\t\tif (x + 1 < 10 && x - 1 >= 0) {// branch for multiple hits\n\t\t\t\t\tif (egrid[x + 1][y] == 1 && egrid[x - 1][y] == 1) {\n\t\t\t\t\t\t// System.out.println(\"conflict at \"+ex+\",\"+ey);\n\t\t\t\t\t\tenemyLastHitX = x;\n\t\t\t\t\t\tenemyLastHitY = y;\n\t\t\t\t\t\tif (x + 2 < 10) {\n\t\t\t\t\t\t\tif (egrid[x + 2][y] == 1) {\n\t\t\t\t\t\t\t\tconflictX = 1;\n\t\t\t\t\t\t\t\tx--;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconflictX = 2;\n\t\t\t\t\t\t\t\tx++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconflictX = 2;\n\t\t\t\t\t\t\tx++;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (y + 1 < 10 && y - 1 >= 0) {// branch for multiple vertical\n\t\t\t\t\t\t\t\t\t\t\t\t// hits\n\t\t\t\t\tif (egrid[x][y + 1] == 1 && egrid[x][y - 1] == 1) {\n\t\t\t\t\t\t// System.out.println(\"conflict at \"+ex+\",\"+ey);\n\t\t\t\t\t\tenemyLastHitX = x;\n\t\t\t\t\t\tenemyLastHitY = y;\n\t\t\t\t\t\tconflictY = 1;\n\t\t\t\t\t\ty--;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (conflictX == 0 && conflictY == 0) {\n\t\t\t\t\tif (y + 1 < 10) {\n\t\t\t\t\t\tif (egrid[x][y + 1] == 1)// if y+1 is a hit and it is\n\t\t\t\t\t\t\t\t\t\t\t\t\t// within bounds, it will go\n\t\t\t\t\t\t\t\t\t\t\t\t\t// there\n\t\t\t\t\t\t\ty++;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (y - 1 >= 0) {\n\t\t\t\t\t\tif (egrid[x][y - 1] == 1)\n\t\t\t\t\t\t\ty--;\n\t\t\t\t\t}\n\t\t\t\t\tif (x + 1 < 10) {\n\t\t\t\t\t\tif (egrid[x + 1][y] == 1)\n\t\t\t\t\t\t\tx++;\n\t\t\t\t\t}\n\t\t\t\t\tif (x - 1 >= 0) {\n\t\t\t\t\t\tif (egrid[x - 1][y] == 1) {\n\t\t\t\t\t\t\tx--;\n\t\t\t\t\t\t\tenemyLastShotHit = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t} // hard diff\n\t\t\tcheckDirection++;\n\t\t} // lasthit\n\n\t\tint tryCount = 0;\n\t\twhile (egrid[x][y] == 3) { // makes sure enemy doesn't hit same spot\n\t\t\t\t\t\t\t\t\t// twice\n\t\t\tx = (int) (Math.random() * 10);\n\t\t\ty = (int) (Math.random() * 10);\n\t\t\tif (tryCount < 20 && getDifficulty() > 0) {\n\t\t\t\tif (x % 2 == 0) { // if x is even, y should be odd\n\t\t\t\t\tif (y % 2 == 0) { // for checkerboard pattern\n\t\t\t\t\t\tif (y + 1 < 10)\n\t\t\t\t\t\t\ty++;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ty--;\n\t\t\t\t\t}\n\t\t\t\t} else { // if x is odd, y should be even\n\t\t\t\t\tif (y % 2 == 1)\n\t\t\t\t\t\tif (y + 1 < 10)\n\t\t\t\t\t\t\ty++;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ty--;\n\t\t\t\t}\n\t\t\t}\n\t\t\ttryCount++;\n\t\t}\n\n\t\tif (egrid[x][y] == 1) { // hit branch\n\t\t\tenemyBoard[x][y].setIcon(createImageIcon(\"tilehit.jpg\"));\n\t\t\tstatus.setText(\" Enemy got a hit\");\n\t\t\tenemyLastShotHit = true; // starts ai\n\t\t\tcheckDirection = 0;\n\t\t\tif (conflictX == 0 && conflictY == 0) {\n\t\t\t\tenemyLastHitX = x; // stores x and y values\n\t\t\t\tenemyLastHitY = y;\n\t\t\t}\n\t\t\tehits--; // keeps score\n\t\t}\n\n\t\telse if (egrid[x][y] == 2) { // poweup branch\n\t\t\tenemyBoard[x][y].setIcon(createImageIcon(\"tilepower.jpg\"));\n\t\t\tstatus.setText(\" Enemy got a PowerUp\");\n\t\t\tgoAgain = true;\n\t\t}\n\n\t\telse\n\t\t\t// miss branch\n\t\t\tenemyBoard[x][y].setIcon(createImageIcon(\"tilemiss.jpg\"));\n\n\t\tegrid[x][y] = 3;\n\n\t\tcheckEnemyWin();\n\n\t\tif (goAgain)\n\t\t\tenemyMove();\n\n\t}", "public static int[] isMonsterInSight(Player curr) {\n int[] ans = {-1, -1};\n ArrayList<Integer> dirs = new ArrayList();\n int bodyDir = curr.getBodyDirection();\n String name = curr.getName();\n if (bodyDir == UP) {\n dirs.add(UP);\n if (!name.endsWith(\"fighter\")) //figher planes can only see what is in front of them\n {\n if (!name.equals(\"AIR bomber\"))//bombers only see what is in front and behind them for their bombing run\n {\n dirs.add(RIGHT);\n dirs.add(LEFT);\n }\n if (name.startsWith(\"TANK\") || name.endsWith(\"jeep\") || name.endsWith(\"destroyer\") || name.endsWith(\"coastguard\") || name.equals(\"AIR bomber\"))\n dirs.add(DOWN);\n }\n } else if (bodyDir == RIGHT) {\n dirs.add(RIGHT);\n if (!name.endsWith(\"fighter\")) //figher planes can only see what is in front of them\n {\n if (!name.equals(\"AIR bomber\"))//bombers only see what is in front and behind them for their bombing run\n {\n dirs.add(UP);\n dirs.add(DOWN);\n }\n if (name.startsWith(\"TANK\") || name.endsWith(\"jeep\") || name.endsWith(\"destroyer\") || name.endsWith(\"coastguard\") || name.equals(\"AIR bomber\"))\n dirs.add(LEFT);\n }\n } else if (bodyDir == DOWN) {\n dirs.add(DOWN);\n if (!name.endsWith(\"fighter\")) //figher planes can only see what is in front of them\n {\n if (!name.equals(\"AIR bomber\"))//bombers only see what is in front and behind them for their bombing run\n {\n dirs.add(RIGHT);\n dirs.add(LEFT);\n }\n if (name.startsWith(\"TANK\") || name.endsWith(\"jeep\") || name.endsWith(\"destroyer\") || name.endsWith(\"coastguard\") || name.equals(\"AIR bomber\"))\n dirs.add(UP);\n }\n } else //if(curr.getBodyDirection()==LEFT)\n {\n dirs.add(LEFT);\n if (!name.endsWith(\"fighter\")) //figher planes can only see what is in front of them\n {\n if (!name.equals(\"AIR bomber\"))//bombers only see what is in front and behind them for their bombing run\n {\n dirs.add(UP);\n dirs.add(DOWN);\n }\n if (name.startsWith(\"TANK\") || name.endsWith(\"jeep\") || name.endsWith(\"destroyer\") || name.endsWith(\"coastguard\") || name.equals(\"AIR bomber\"))\n dirs.add(RIGHT);\n }\n }\n\n if (dirs == null || dirs.size() == 0)\n return ans; //{-1,-1}\n for (int m = 0; m < players.length; m++) { //skip player if Vehicle is not mind controlled and the player is not a monster\n //skip player if Vehicle is mind controlled and the player is a monster\n if (players[m] == null || players[m].getName().equals(\"NONE\") || curr == players[m] ||\n ((curr instanceof Vehicle && !((Vehicle) (curr)).isMindControlled()) && !(players[m] instanceof Monster)) ||\n ((curr instanceof Vehicle && ((Vehicle) (curr)).isMindControlled()) && (players[m] instanceof Monster)))\n continue;\n int mR = players[m].getRow();\n int mC = players[m].getCol();\n\n for (int i = 0; i < dirs.size(); i++) {\n int dir = dirs.get(i);\n boolean skip = false;\n if (dir == UP) {\n for (int r = curr.getRow(); r >= 0; r--) { //coastguard, destroyer, fighter planes and artillery have the monsters position known - the monster is not hidden by structures\n if (!MapBuilder.noStructure(r, curr.getCol(), panel) && !name.endsWith(\"coastguard\") && !name.endsWith(\"destroyer\") && !name.endsWith(\"fighter\") && !name.endsWith(\"artillery\") && !name.endsWith(\"missile\") && !name.equals(\"AIR bomber\") && !players[m].isFlying()) {\n skip = true;\n break;\n }\n if (r == mR && curr.getCol() == mC) {\n ans[0] = dir;\n ans[1] = m;\n return ans;\n }\n }\n } else if (dir == DOWN) {\n for (int r = curr.getRow(); r < board.length - 1; r++) {\n if (!MapBuilder.noStructure(r, curr.getCol(), panel) && !name.endsWith(\"coastguard\") && !name.endsWith(\"destroyer\") && !name.endsWith(\"fighter\") && !name.endsWith(\"artillery\") && !name.endsWith(\"missile\") && !name.equals(\"AIR bomber\") && !players[m].isFlying()) {\n skip = true;\n break;\n }\n if (r == mR && curr.getCol() == mC) {\n ans[0] = dir;\n ans[1] = m;\n return ans;\n }\n\n }\n } else if (dir == RIGHT) {\n for (int c = curr.getCol(); c < board[0].length; c++) {\n if (!MapBuilder.noStructure(curr.getRow(), c, panel) && !name.endsWith(\"coastguard\") && !name.endsWith(\"destroyer\") && !name.endsWith(\"fighter\") && !name.endsWith(\"artillery\") && !name.endsWith(\"missile\") && !name.equals(\"AIR bomber\") && !players[m].isFlying()) {\n skip = true;\n break;\n }\n if (curr.getRow() == mR && c == mC) {\n ans[0] = dir;\n ans[1] = m;\n return ans;\n }\n }\n } else if (dir == LEFT) {\n for (int c = curr.getCol(); c >= 0; c--) {\n if (!MapBuilder.noStructure(curr.getRow(), c, panel) && !name.endsWith(\"coastguard\") && !name.endsWith(\"destroyer\") && !name.endsWith(\"fighter\") && !name.endsWith(\"artillery\") && !name.endsWith(\"missile\") && !name.equals(\"AIR bomber\") && !players[m].isFlying()) {\n skip = true;\n break;\n }\n if (curr.getRow() == mR && c == mC) {\n ans[0] = dir;\n ans[1] = m;\n return ans;\n }\n }\n }\n if (skip)\n continue;\n }\n }\n return ans;\n }", "private void playerMoved(int currentPlayer, int currentUnit, boolean moved)\r\n {\r\n if(moved == true)//if player has made a legitimate move\r\n {\r\n worldPanel.repaint();\r\n int movesLeft = 0;\r\n if(currentPlayer == 1)\r\n {\r\n int myPos = worldPanel.player1.units[currentUnit - 1].getPosition();\r\n\r\n //check to see if a player challenges another player\r\n for(int i = 0; i < worldPanel.player2.getNumUnits(); i++)\r\n {\r\n int pos = worldPanel.player2.units[i].getPosition();\r\n if(myPos == pos)\r\n {\r\n fight(1, currentUnit - 1, i);\r\n return;\r\n }\r\n }//end for\r\n\r\n //check to see if a player captures a city\r\n for(int i = 0; i < worldPanel.player2.getNumCities(); i++)\r\n {\r\n int pos = worldPanel.player2.cities[i].getLocation();\r\n if(myPos == pos)\r\n {\r\n captureCity(1,i);\r\n return;\r\n }\r\n }//end for\r\n movesLeft = worldPanel.player1.units[currentUnit - 1].getMovementsLeft();\r\n int temp = worldPanel.player1.units[currentUnit - 1].getPosition();\r\n int temp1 = mapPieces[0][temp];\r\n if(temp1 == 54 || temp1 == 51 || temp1 == 52 || temp1 == 53)//if unit moves on rock or something\r\n worldPanel.player1.units[currentUnit - 1].setMovementsLeft(movesLeft - 2);\r\n else\r\n worldPanel.player1.units[currentUnit - 1].setMovementsLeft(movesLeft - 1);\r\n movesLeft = worldPanel.player1.units[currentUnit - 1].getMovementsLeft();\r\n }//end if\r\n else if(currentPlayer == 2)\r\n {\r\n int myPos = worldPanel.player2.units[currentUnit - 1].getPosition();\r\n\r\n //check to see if a player challenges another player\r\n for(int i = 0; i < worldPanel.player1.getNumUnits(); i++)\r\n {\r\n int pos = worldPanel.player1.units[i].getPosition();\r\n if(myPos == pos)\r\n {\r\n fight(2, currentUnit - 1, i);\r\n return;\r\n }\r\n }\r\n\r\n //check to see if a player captures a city\r\n for(int i = 0; i < worldPanel.player1.getNumCities(); i++)\r\n {\r\n int pos = worldPanel.player1.cities[i].getLocation();\r\n if(myPos == pos)\r\n {\r\n captureCity(2,i);\r\n return;\r\n }\r\n }//end for\r\n movesLeft = worldPanel.player2.units[currentUnit - 1].getMovementsLeft();\r\n int temp = worldPanel.player2.units[currentUnit - 1].getPosition();\r\n int temp1 = mapPieces[0][temp];\r\n if(temp1 == 54 || temp1 == 51 || temp1 == 52 || temp1 == 53)//if unit moves on rock or something\r\n worldPanel.player2.units[currentUnit - 1].setMovementsLeft(movesLeft - 2);\r\n else\r\n worldPanel.player2.units[currentUnit - 1].setMovementsLeft(movesLeft - 1);\r\n movesLeft = worldPanel.player2.units[currentUnit - 1].getMovementsLeft();\r\n\r\n //worldPanel.player2.units[currentUnit - 1].setMovementsLeft(movesLeft - 1);\r\n movesLeft = worldPanel.player2.units[currentUnit - 1].getMovementsLeft();\r\n }\r\n\r\n if(movesLeft <= 0)//if unit has run out of moves\r\n {\r\n if(currentPlayer == 1)\r\n {\r\n worldPanel.player1.units[currentUnit - 1].resetMovement();\r\n }\r\n if(currentPlayer == 2)\r\n {\r\n worldPanel.player2.units[currentUnit - 1].resetMovement();\r\n }\r\n currentUnit++;\r\n }//end if\r\n worldPanel.setCurrentUnit(currentUnit);\r\n }//end if\r\n\r\n int temp = worldPanel.getNumUnits(currentPlayer);\r\n if(currentUnit > temp)\r\n {\r\n if(currentPlayer == 1)\r\n worldPanel.setCurrentPlayer(2);\r\n else\r\n\t\t\t\t\t\t{\r\n worldPanel.setCurrentPlayer(1);\r\n\t\t\t\t\t\t\t\tyear = unitPanel.getYear() + 20;//add 20 years to the game\r\n\t\t\t\t\t\t}\r\n worldPanel.setCurrentUnit(1);\r\n }//end if\r\n\r\n setInfoPanel();//set up the information panel\r\n }", "static void moving() throws GameActionException {\n\n\t\tcheckLumberjack();\n\n\t\trc.setIndicatorLine(myLocation, myLocation.add(robotDirection), 0, 0, 0);\n\n\t\tif (rc.canBuildRobot(RobotType.SCOUT, robotDirection)\n\t\t\t\t&& rc.readBroadcast(Channels.COUNT_SCOUT) < Constants.MAX_COUNT_SCOUT) {\n\t\t\trc.buildRobot(RobotType.SCOUT, robotDirection);\n\t\t\tCommunication.countMe(RobotType.SCOUT);\n\t\t\treturn;\n\t\t}\n\t\t// } else if (rc.canBuildRobot(RobotType.SOLDIER, buildDirection) &&\n\t\t// rc.readBroadcast(Channels.COUNT_SOLDIER) <\n\t\t// Constants.MAX_COUNT_SOLDIER) {\n\t\t// rc.buildRobot(RobotType.SOLDIER, buildDirection);\n\t\t// Communication.countMe(RobotType.SOLDIER);\n\t\t// return;\n\t\t// }\n\n\t}", "public void performCheckAfterPlayerMove() {\n\t\tagentsMoved += 1;\n\t\t\n\t\tif(agentsMoved == agents) {\n\t\t\troundsPlayed += 1;\n\t\t\tmoveRobots();\n\t\t\tagentsMoved = 0;\n\t\t\t\n\t\t\t//restart game at new level after the robots has moved\n\t\t\tif(roundsPlayed > server.getRoundsPerLevel()) {\n\t\t\t\tHandleCommunication.broadcastToClient(null, server.getConnectedClientList(), SendSetting.NextLevel, server, null);\n\t\t\t\troundsPlayed = 0;\n\t\t\t}\n\t\t}\n\t}", "private void moveForwards() {\n\t\tposition = MoveAlgorithmExecutor.getAlgorithmFromCondition(orientation).execute(position);\n\t\t\n\t\t// Extracted the condition to check if tractor is in Ditch\n\t\tif(isTractorInDitch()){\n\t\t\tthrow new TractorInDitchException();\n\t\t}\n\t}", "public checkersSetup.Turn getBestMoveBasedOnSearchOfDepthN(CheckersSetup setup, boolean isDarkPlayer, int curdepth) {\n\t\t\n\t\tint numAlternativelyGoodMoves=0;\n\t\t\n\t\tif(curdepth > 0) {\n\t\t\t\n\t\t\tArrayList<checkersSetup.Turn> turnChoices = BasicCheckersAIFunctions.getAllPossiblePlayerOptionsFor1Turn(setup, isDarkPlayer);\n\t\t\t\n\t\t\tfavTurn = new Turn[turnChoices.size()];\n\t\t\t\n\t\t\tfavTurn[0] = turnChoices.get(0);\n\t\t\t\n\t\t\tsetup.playTurn(turnChoices.get(0));\n\t\t\t//note: op = OPPONENT!\n\t\t\tdouble opWorstPosUtil = getEstUtilityOfPosition(setup, !isDarkPlayer, curdepth-1);\n\t\t\tsetup.reverseTurn(turnChoices.get(0));\n\t\t\t\n\t\t\tdouble opPosUtil;\n\t\t\n\t\t\tfor(int i=1; i<turnChoices.size(); i++) {\n\t\t\t\tsetup.playTurn(turnChoices.get(i));\n\t\t\t\t\n\t\t\t\topPosUtil = getEstUtilityOfPosition(setup, !isDarkPlayer, curdepth-1);\n\t\t\t\t\n\t\t\t\tif(opPosUtil < opWorstPosUtil) {\n\t\t\t\t\topWorstPosUtil = opPosUtil;\n\t\t\t\t\tfavTurn[0] = turnChoices.get(i);\n\t\t\t\t\tnumAlternativelyGoodMoves = 0;\n\t\t\t\t\n\t\t\t\t} else if(opPosUtil == opWorstPosUtil) {\n\t\t\t\t\tnumAlternativelyGoodMoves++;\n\t\t\t\t\tfavTurn[numAlternativelyGoodMoves] = turnChoices.get(i);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tsetup.reverseTurn(turnChoices.get(i));\n\t\t\t}\n\t\t\tif(opWorstPosUtil <= -BasicCheckersAIFunctions.DARK_WIN_UTILITY) {\n\t\t\t\tSystem.out.println(\"YOU ARE FUCKED!!\");\n\t\t\t}\n\t\t\t\n\t\t\t//TODO\n\t\t\t//opUtilityOfLastMove = -opWorstPosUtil;\n\t\t} else {\n\t\t\tSystem.out.println(\"Error: the depth should be bigger than 0!\");\n\t\t\tSystem.exit(1);\n\t\t\t//stub to stop java from complaining:\n\t\t\tfavTurn = new Turn[0];\n\t\t}\n\t\t\n\t\t//if AI is NOT deterministic AND\n\t\t//\tthere's several choices that seem similarly good, the AI randomly choses a move \n\t\tif(numAlternativelyGoodMoves > 0 && this.deterministic == false) {\n\t\t\tSystem.out.println(\"aitree is randomly choosing beetween \" + (numAlternativelyGoodMoves+1) + \" ways to do his turn\");\n\t\t\tnumFavMoves = numAlternativelyGoodMoves+1;\n\t\t\treturn favTurn[(int)(Math.random()*(numAlternativelyGoodMoves+1))];\n\t\t} else {\n\t\t\tnumFavMoves = 1;\n\t\t\treturn favTurn[0];\n\t\t}\n\t\t\n\t}", "private void distrErrToNeighbors(GNode winner, String leftK, String rightK, String topK, String bottomK) {\n\n }", "private void incr() {\n Move tempMove = null;\n Piece t1, t2;\n while (_r <= M) {\n t1 = Board.this._turn;\n t2 = Board.this.get(_c, _r);\n if (t1 == t2) {\n break;\n } else {\n nextPiece();\n }\n }\n if (_r > M) {\n _move = null;\n return;\n }\n int c1, r1, count3;\n Piece temp1, temp2;\n Board tempBoard;\n _dir = _dir.succ();\n while (_dir != null) {\n count3 = pieceCountAlong(_c, _r, _dir);\n c1 = _c + _dir.dc * count3;\n r1 = _r + _dir.dr * count3;\n tempMove = Move.create(_c, _r, c1, r1, Board.this);\n if (tempMove == null) {\n _dir = _dir.succ();\n continue;\n }\n if (isLegal(tempMove)) {\n _move = tempMove;\n break;\n }\n _dir = _dir.succ();\n }\n if (_dir == null) {\n _dir = NOWHERE;\n nextPiece();\n incr();\n }\n }", "int evalLkp(int f) {\n\tint r = 0;\n\n\tif (pawnRank[LIGHT][f] == 6)\n\t; /* pawn hasn't moved */\n\telse if (pawnRank[LIGHT][f] == 5)\n\tr -= 10; /* pawn moved one square */\n\telse if (pawnRank[LIGHT][f] != 0)\n\tr -= 20; /* pawn moved more than one square */\n\telse\n\tr -= 25; /* no pawn on this file */\n\n\tif (pawnRank[DARK][f] == 7)\n\tr -= 15; /* no enemy pawn */\n\telse if (pawnRank[DARK][f] == 5)\n\tr -= 10; /* enemy pawn on the 3rd rank */\n\telse if (pawnRank[DARK][f] == 4)\n\tr -= 5; /* enemy pawn on the 4th rank */\n\n\treturn r;\n\t}", "@Override\r\n\tpublic boolean movement(BoardCells[][] chessBoard, Piece targetPiece, int fromX,int fromY,int toX,int toY) {\t\t\r\n\t\t//DEBUG -- System.out.println(\"\"+fromX+fromY+\" \"+toX+toY);\r\n\t\t\r\n\t\tif(fromY == toY){\t\t\t\r\n\t\t\tif(fromX > toX) {\r\n\t\t\t\tfor(int i = fromX-1; i>toX; i--) {\r\n\t\t\t\t\tif(chessBoard[8-fromY][i].getPiece() != null) {\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\r\n\t\t\t} else if (fromX < toX) {\r\n\t\t\t\tfor(int i = fromX+1; i<toX; i++) {\r\n\t\t\t\t\tif(chessBoard[8-fromY][i].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif(getPieceID().equals(\"bR\")) {\r\n\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"bKc\")) {\r\n\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"bK\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif(getPieceID().equals(\"wR\")) {\r\n\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"wKc\")) {\r\n\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"wK\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\tif(fromX == toX) {\t\t\t\t\r\n\t\t\tif(fromY > toY) {\t\r\n\t\t\t\tfor(int i = fromY-1; i>toY; i--) {\r\n\t\t\t\t\tif(chessBoard[8-i][toX].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t} else if (fromY < toY) {\t\t\t\t\r\n\t\t\t\tfor(int i = fromY+1; i<toY; i++) {\t\t\t\t\t\r\n\t\t\t\t\tif(chessBoard[8-i][toX].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tif(getPieceID().equals(\"bR\")) {\r\n\t\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"bKc\")) {\r\n\t\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"bK\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(getPieceID().equals(\"wR\")) {\r\n\t\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"wKc\")) {\r\n\t\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"wK\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\r\n\t\t\treturn true;\t\r\n\t\t}\r\n\t\t\t\t\r\n\t\treturn false;\t\t\r\n\t}", "@Override\n\tpublic Direction getMove() {\n if (ticks < MAX_TICKS_PER_ROUND - 100) {\n Direction[] dirs = Direction.values();\n return dirs[random.nextInt(dirs.length)];\n } else {\n // Move towards boat\n int deltaX = 0;\n int deltaY = 0;\n if (currentLocation.getX() < 0)\n deltaX = 1;\n else if (currentLocation.getX() > 0)\n deltaX = -1;\n\n if (currentLocation.getY() < 0)\n deltaY = 1;\n else if (currentLocation.getY() > 0)\n deltaY = -1;\n\n if (deltaX > 0 && deltaY == 0) {\n return Direction.E;\n } else if (deltaX > 0 && deltaY > 0) {\n return Direction.NE;\n } else if (deltaX > 0 && deltaY < 0) {\n return Direction.SE;\n } else if (deltaX == 0 && deltaY == 0) {\n return Direction.STAYPUT;\n } else if (deltaX == 0 && deltaY < 0) {\n return Direction.N;\n } else if (deltaX == 0 && deltaY > 0) {\n return Direction.S;\n } else if (deltaX < 0 && deltaY == 0) {\n return Direction.W;\n } else if (deltaX < 0 && deltaY > 0) {\n return Direction.NW;\n } else if (deltaX < 0 && deltaY < 0) {\n return Direction.NE;\n } else {\n throw new RuntimeException(\"I HAVE NO IDEA\");\n }\n }\n\t}", "protected int checkMove(Direction d) {\n Position pos = currentPosition.nextPosition(d); \n if (!pos.inPlayArea()) return -1;\n Station nS = map.nearestStation(pos);\n if (Position.withinRange(nS.pos, pos) && !nS.isPositive) {\n return 0;\n }\n else return 1;\n }", "public static void makeEnemyMove() { //all players after index 1 are enemies\n if (gameMode == EARTH_INVADERS) {//find leftmost and rightmost vehicle columns to see if we need to move down\n int leftMost = board[0].length;\n int rightMost = 0;\n int lowest = 0;\n for (int i = FIRST_VEHICLE; i < players.length; i++) {//find left-most, right-most and lowest most vehicles (non aircraft/train) to determine how formation should move\n Player curr = players[i];\n if (curr == null)\n continue;\n String name = curr.getName();\n if (name.equals(\"NONE\") || curr.isFlying() || name.startsWith(\"TRAIN\") || (curr instanceof Monster))\n continue;\n if (curr.getCol() < leftMost)\n leftMost = curr.getCol();\n if (curr.getCol() > rightMost)\n rightMost = curr.getCol();\n if (curr.getRow() > lowest)\n lowest = curr.getRow();\n curr.setHeadDirection(DOWN);\n }\n for (int i = FIRST_VEHICLE; i < players.length; i++) {//***move aircraft and trains\n Player curr = players[i];\n if (curr == null)\n continue;\n String name = curr.getName();\n if (name.equals(\"NONE\") || curr.isFlying() || name.startsWith(\"TRAIN\") || (curr instanceof Monster)) {\n if (curr.isMoving())\n continue;\n ArrayList<Integer> dirs = new ArrayList(); //array of preferred directions - everything but the reverse of their body position\n int bodyDir = curr.getBodyDirection();\n curr.clearDirections();\n int r = curr.getRow();\n int c = curr.getCol();\n if (bodyDir == UP) {\n if (isValidMove(curr, r - 1, c))\n dirs.add(UP);\n if (isValidMove(curr, r, c + 1))\n dirs.add(RIGHT);\n if (!name.startsWith(\"TRAIN\")) //trains need to follow the track circuit - only straight and right turns\n {\n if (isValidMove(curr, r, c - 1))\n dirs.add(LEFT);\n }\n } else if (bodyDir == RIGHT) {\n if (!name.startsWith(\"TRAIN\")) //trains need to follow the track circuit - only straight and right turns\n {\n if (isValidMove(curr, r - 1, c))\n dirs.add(UP);\n }\n if (isValidMove(curr, r, c + 1))\n dirs.add(RIGHT);\n if (isValidMove(curr, r + 1, c))\n dirs.add(DOWN);\n } else if (bodyDir == DOWN) {\n if (isValidMove(curr, r + 1, c))\n dirs.add(DOWN);\n if (!name.startsWith(\"TRAIN\")) //trains need to follow the track circuit - only straight and right turns\n {\n if (isValidMove(curr, r, c + 1))\n dirs.add(RIGHT);\n }\n if (isValidMove(curr, r, c - 1))\n dirs.add(LEFT);\n } else //if(curr.getBodyDirection()==LEFT)\n {\n if (isValidMove(curr, r - 1, c))\n dirs.add(UP);\n if (!name.startsWith(\"TRAIN\")) //trains need to follow the track circuit - only straight and right turns\n {\n if (isValidMove(curr, r + 1, c))\n dirs.add(DOWN);\n }\n if (isValidMove(curr, r, c - 1))\n dirs.add(LEFT);\n }\n int rand = 0;\n if (dirs.size() > 0)\n rand = dirs.get((int) (Math.random() * dirs.size()));\n if (curr.isFlying()) { //if aircraft is flying in the visible board, don't change direction\n if (r == 1 && (c == 0 || c == board[0].length - 1)) //we are in the first row but behind a border\n { //we only want aircraft to appear in row 1 in EARTH INVADERS (like the UFO in space invaders)\n if (bodyDir == LEFT || bodyDir == RIGHT) {\n rand = UP;\n if (Math.random() < .5)\n rand = DOWN;\n } else if (c == 0)\n rand = RIGHT;\n else if (c == board[0].length - 1)\n rand = LEFT;\n else\n //if(dirs.contains(bodyDir))\n rand = bodyDir;\n } else if (r == 0 || c == 0 || r == board.length - 1 || c == board[0].length - 1) {\n rand = bodyDir;\n if (r == 0 && c == 0) {\n rand = RIGHT;\n if (Math.random() < .5)\n rand = DOWN;\n } else if (r == 0 && c == board[0].length - 1) {\n rand = LEFT;\n if (Math.random() < .5)\n rand = DOWN;\n } else if (r == board.length - 1 && c == 0) {\n rand = RIGHT;\n if (Math.random() < .5)\n rand = UP;\n } else if (r == board.length - 1 && c == board[0].length - 1) {\n rand = LEFT;\n if (Math.random() < .5)\n rand = UP;\n }\n } else if (/*dirs.contains(bodyDir) && */(r > 0 && c > 0 && r < board.length - 1 && c < board[0].length - 1))\n rand = bodyDir; //make it so aircraft prefer to keep going the same direciton\n\n } else if (name.startsWith(\"TRAIN\")) {//make it so trains prefer to follow the right wall\n for (int j = 0; j < dirs.size(); j++)\n if (dirs.get(j) != bodyDir) {\n rand = dirs.get(j);\n break;\n }\n }\n curr.setDirection(rand);\n curr.setBodyDirection(rand);\n }\n }//***end aircraft/train movement\n if (leftMost == 1) //move vehicles down and start them moving right\n {\n if (EI_moving == LEFT) {\n EI_moving = DOWN;\n for (int i = FIRST_VEHICLE; i < players.length; i++) {\n Player curr = players[i];\n if (curr == null || curr.getName().equals(\"NONE\"))\n continue;\n if (lowest < board.length - 3 && !curr.isFlying() && !curr.getName().startsWith(\"TRAIN\"))\n curr.setRow(curr.getRow() + 1);\n }\n } else if (EI_moving == DOWN) {\n EI_moving = RIGHT;\n for (int i = FIRST_VEHICLE; i < players.length; i++) {\n Player curr = players[i];\n if (curr == null || curr.getName().equals(\"NONE\"))\n continue;\n if (!curr.isFlying() && !curr.getName().startsWith(\"TRAIN\")) {\n curr.setDirection(RIGHT);\n curr.setBodyDirection(RIGHT);\n }\n }\n } else if (EI_moving == RIGHT)\n for (int i = FIRST_VEHICLE; i < players.length; i++) {\n Player curr = players[i];\n if (curr == null || curr.getName().equals(\"NONE\"))\n continue;\n if (!curr.isFlying() && !curr.getName().startsWith(\"TRAIN\"))\n curr.setDirection(RIGHT);\n }\n }//***end leftmost is first col\n else if (rightMost == board[0].length - 2) //move vehicles down and start them moving left\n {\n if (EI_moving == RIGHT) {\n EI_moving = DOWN;\n for (int i = FIRST_VEHICLE; i < players.length; i++) {\n Player curr = players[i];\n if (curr == null || curr.getName().equals(\"NONE\"))\n continue;\n if (lowest < board.length - 3 && !curr.isFlying() && !curr.getName().startsWith(\"TRAIN\"))\n curr.setRow(curr.getRow() + 1);\n }\n } else if (EI_moving == DOWN) {\n EI_moving = LEFT;\n for (int i = FIRST_VEHICLE; i < players.length; i++) {\n Player curr = players[i];\n if (curr == null || curr.getName().equals(\"NONE\"))\n continue;\n if (!curr.isFlying() && !curr.getName().startsWith(\"TRAIN\")) {\n curr.setDirection(LEFT);\n curr.setBodyDirection(LEFT);\n }\n }\n } else if (EI_moving == LEFT)\n for (int i = FIRST_VEHICLE; i < players.length; i++) {\n Player curr = players[i];\n if (curr == null || curr.getName().equals(\"NONE\"))\n continue;\n\n if (!curr.isFlying() && !curr.getName().startsWith(\"TRAIN\"))\n curr.setDirection(LEFT);\n }\n }//***end rightmost is last col\n else if (EI_moving == LEFT)\n for (int i = FIRST_VEHICLE; i < players.length; i++) {\n Player curr = players[i];\n if (curr == null || curr.getName().equals(\"NONE\"))\n continue;\n if (!curr.isFlying() && !curr.getName().startsWith(\"TRAIN\"))\n curr.setDirection(LEFT);\n }\n else if (EI_moving == RIGHT)\n for (int i = FIRST_VEHICLE; i < players.length; i++) {\n Player curr = players[i];\n if (curr == null || curr.getName().equals(\"NONE\"))\n continue;\n if (!curr.isFlying() && !curr.getName().startsWith(\"TRAIN\"))\n curr.setDirection(RIGHT);\n }\n return;\n }//***end EARTH INVADERS enemy movements\n for (int i = 2; i < players.length; i++) {\n Player curr = players[i];\n if (curr == null || curr.getName().equals(\"NONE\"))\n continue;\n String name = curr.getName();\n int r = curr.getRow();\n int c = curr.getCol();\n if (r > 0 && c > 0 && r < board.length - 1 && c < board[0].length - 1 && (curr instanceof Vehicle))\n ((Vehicle) (curr)).setOnField(true);\n\n if (curr.isFlying() && webs[panel].size() > 0) {\n int x = curr.findX(cellSize);\n int y = curr.findY(cellSize);\n for (int p = 0; p < webs[panel].size(); p++) {\n int[] ray = webs[panel].get(p);\n if (Utilities.isPointOnRay(x, y, ray[0], ray[1], ray[2], ray[3])) {\n explosions.add(new Explosion(\"BIG\", x, y, explosionImages, animation_delay));\n Ordinance.radiusDamage(-1, x, y, 25, panel, .5);\n Spawner.resetEnemy(i);\n webs[panel].remove(p);\n p--;\n Structure str1 = structures[ray[4]][ray[5]][panel];\n Structure str2 = structures[ray[6]][ray[7]][panel];\n if (str1 != null)\n str1.setWebValue(0);\n if (str2 != null)\n str2.setWebValue(0);\n Utilities.updateKillStats(curr);\n break;\n }\n }\n }\n //reset any ground vehicle that ended up in the water\n //reset any train not on tracks - we need this because a player might change panels as a vehicle spawns\n if (name.startsWith(\"TRAIN\")) {\n Structure str = structures[r][c][panel];\n if (str != null && str.getName().equals(\"hole\") && str.getHealth() != 0) {\n explosions.add(new Explosion(\"BIG\", curr.getX() - (cellSize / 2), curr.getY() - (cellSize / 2), puffImages, animation_delay));\n Utilities.updateKillStats(curr);\n Spawner.resetEnemy(i);\n continue;\n } else if (board[r][c][panel].startsWith(\"~\")) {\n explosions.add(new Explosion(\"BIG\", curr.getX() - (cellSize / 2), curr.getY() - (cellSize / 2), puffImages, animation_delay));\n Spawner.resetEnemy(i);\n continue;\n } else if (!board[r][c][panel].startsWith(\"T\")) {\n explosions.add(new Explosion(\"SMALL\", curr.getX() - (cellSize / 2), curr.getY() - (cellSize / 2), puffImages, animation_delay));\n Spawner.resetEnemy(i);\n continue;\n }\n } else //ground vehicles\n if (!curr.isFlying() && !curr.getName().startsWith(\"BOAT\") && (curr instanceof Vehicle)) {\n\n if (((Vehicle) (curr)).getStunTime() > numFrames) //ground unit might be stunned by WoeMantis shriek\n continue;\n if (board[r][c][panel].startsWith(\"~\")) {\n explosions.add(new Explosion(\"SMALL\", curr.getX() - (cellSize / 2), curr.getY() - (cellSize / 2), puffImages, animation_delay));\n Spawner.resetEnemy(i);\n continue;\n }\n } else //reset any water vehicle that ended up on land\n if (name.startsWith(\"BOAT\")) {\n if (!board[r][c][panel].startsWith(\"~\")) {\n explosions.add(new Explosion(\"SMALL\", curr.getX() - (cellSize / 2), curr.getY() - (cellSize / 2), puffImages, animation_delay));\n Spawner.resetEnemy(i);\n continue;\n }\n } else if (curr.getHealth() <= 0) {\n Spawner.resetEnemy(i);\n continue;\n }\n\n //if a ground unit has been on the playable field and leaves it, respawn them\n if (!curr.isFlying() && !name.startsWith(\"TRAIN\") && (curr instanceof Vehicle)) {\n if ((r == 0 || c == 0 || r == board.length - 1 || c == board[0].length - 1) && ((Vehicle) (curr)).getOnField()) {\n ((Vehicle) (curr)).setOnField(false);\n Spawner.resetEnemy(i);\n continue;\n }\n }\n if (name.endsWith(\"nukebomber\")) {//for the nukebomber, set the detonation coordinates so nuke fires when the plane exits the field\n int dr = curr.getDetRow();\n int dc = curr.getDetCol();\n int bd = curr.getBodyDirection();\n int dd = curr.getDetDir();\n if (bd == dd && (((bd == LEFT || bd == RIGHT) && c == dc) || (bd == UP || bd == DOWN) && r == dr)) {\n Ordinance.nuke();\n curr.setDetRow(-1);\n curr.setDetCol(-1);\n }\n }\n\n if (curr.isMoving())\n continue;\n int bodyDir = curr.getBodyDirection();\n curr.clearDirections();\n int[] target = isMonsterInSight(curr);\n int mDir = target[0]; //direction of the monster, -1 if none\n int monsterIndex = target[1]; //index of the monster in the players array, -1 if none\n ArrayList<Integer> dirs = new ArrayList(); //array of preferred directions - everything but the reverse of their body position\n if (bodyDir == UP) {\n if (isValidMove(curr, r - 1, c)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == UP) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(UP);\n }\n if (isValidMove(curr, r, c + 1)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == RIGHT) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(RIGHT);\n }\n if (!name.startsWith(\"TRAIN\")) //trains need to follow the track circuit - only straight and right turns\n {\n if (isValidMove(curr, r, c - 1)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == LEFT) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(LEFT);\n }\n }\n } else if (bodyDir == RIGHT) {\n if (!name.startsWith(\"TRAIN\")) //trains need to follow the track circuit - only straight and right turns\n {\n if (isValidMove(curr, r - 1, c)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == UP) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(UP);\n }\n }\n if (isValidMove(curr, r, c + 1)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == RIGHT) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(RIGHT);\n }\n if (isValidMove(curr, r + 1, c)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == DOWN) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(DOWN);\n }\n } else if (bodyDir == DOWN) {\n if (isValidMove(curr, r + 1, c)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == DOWN) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(DOWN);\n }\n if (!name.startsWith(\"TRAIN\")) //trains need to follow the track circuit - only straight and right turns\n {\n if (isValidMove(curr, r, c + 1)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == RIGHT) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(RIGHT);\n }\n }\n if (isValidMove(curr, r, c - 1)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == LEFT) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(LEFT);\n }\n } else //if(curr.getBodyDirection()==LEFT)\n {\n\n if (isValidMove(curr, r - 1, c)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == UP) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(UP);\n }\n if (!name.startsWith(\"TRAIN\")) //trains need to follow the track circuit - only straight and right turns\n {\n if (isValidMove(curr, r + 1, c)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == DOWN) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(DOWN);\n }\n }\n if (isValidMove(curr, r, c - 1)) {\n if (Utilities.nonFlyingCivilian(name) && mDir == LEFT) {\n }//civilians don't want to move towards the monster if it is in direct sight\n else\n dirs.add(LEFT);\n }\n }\n\n if (dirs.size() > 0) {\n if (curr instanceof Monster) {//***MONSTER AI*******************\n double headTurnProb = 0.25;\n double stompProb = 0.5;\n int vDir = isVehicleInSight(curr);\n if (vDir >= 0) {\n boolean airShot = false;\n int vD = vDir;\n if (vD >= 10) {\n airShot = true;\n vD -= 10;\n }\n if (curr.head360() || !Utilities.oppositeDirections(vD, curr.getHeadDirection())) {\n curr.setHeadDirection(vD);\n if ((curr.getName().startsWith(\"Gob\") || curr.getName().startsWith(\"Boo\")) && numFrames >= curr.getLastShotTime() + curr.getReloadTime()) {\n Bullet temp = null;\n if (curr.getName().startsWith(\"Boo\")) {\n temp = new Bullet(curr.getName() + vD, curr.getX(), curr.getY(), 50, beamImages, SPEED, \"BEAM\", SPEED * 10, airShot, i, -1, -1);\n } else if (curr.getName().startsWith(\"Gob\")) {\n temp = new Bullet(\"flame\" + vD, curr.getX(), curr.getY(), 15, monsterFireImages, SPEED, \"FIRE\", SPEED * 4, airShot, i, -1, -1);\n }\n if (temp != null) {\n temp.setDirection(vD);\n bullets.add(temp);\n curr.setLastShotTime(numFrames);\n continue;\n }\n }\n }\n } else if (Math.random() < headTurnProb) {\n String hd = \"right\";\n if (Math.random() < .5)\n hd = \"left\";\n Utilities.turnHead(curr, hd);\n }\n Structure str = structures[r][c][panel];\n if (str != null && str.getHealth() > 0 && str.isDestroyable() && !str.getName().startsWith(\"FUEL\") && Math.random() < stompProb)\n playerMove(KeyEvent.VK_SPACE, i);\n else {\n int dir = dirs.get((int) (Math.random() * dirs.size()));\n if (dir == UP) {\n if (curr.getBodyDirection() != UP) {\n curr.setBodyDirection(UP);\n curr.setHeadDirection(UP);\n } else {\n if (!curr.isSwimmer() && board[r - 1][c][panel].equals(\"~~~\") && !board[r][c][panel].equals(\"~~~\")) {\n continue;\n }\n if (r - 1 >= 1) {\n str = structures[r - 1][c][panel]; //don't walk into a fire\n if (str != null && str.onFire())\n continue;\n }\n playerMove(KeyEvent.VK_UP, i);\n }\n } else if (dir == DOWN) {\n if (curr.getBodyDirection() != DOWN) {\n curr.setBodyDirection(DOWN);\n curr.setHeadDirection(DOWN);\n } else {\n if (!curr.isSwimmer() && board[r + 1][c][panel].equals(\"~~~\") && !board[r][c][panel].equals(\"~~~\")) {\n continue;\n }\n if (r + 1 <= structures.length - 1) {\n str = structures[r + 1][c][panel]; //don't walk into a fire\n if (str != null && str.onFire())\n continue;\n }\n playerMove(KeyEvent.VK_DOWN, i);\n }\n } else if (dir == LEFT) {\n if (curr.getBodyDirection() != LEFT) {\n curr.setBodyDirection(LEFT);\n curr.setHeadDirection(LEFT);\n } else {\n if (!curr.isSwimmer() && board[r][c - 1][panel].equals(\"~~~\") && !board[r][c][panel].equals(\"~~~\")) {\n continue;\n }\n if (c - 1 >= 1) {\n str = structures[r][c - 1][panel]; //don't walk into a fire\n if (str != null && str.onFire())\n continue;\n }\n playerMove(KeyEvent.VK_LEFT, i);\n }\n } else if (dir == RIGHT) {\n if (curr.getBodyDirection() != RIGHT) {\n curr.setBodyDirection(RIGHT);\n curr.setHeadDirection(RIGHT);\n } else {\n if (!curr.isSwimmer() && board[r][c + 1][panel].equals(\"~~~\") && !board[r][c][panel].equals(\"~~~\")) {\n continue;\n }\n if (c + 1 <= board[0].length - 1) {\n str = structures[r][c + 1][panel]; //don't walk into a fire\n if (str != null && str.onFire())\n continue;\n }\n playerMove(KeyEvent.VK_RIGHT, i);\n }\n }\n }\n continue;\n }//end monster AI movement\n else //shoot at a target\n if (name.endsWith(\"troops\") || name.endsWith(\"jeep\") || name.endsWith(\"police\") || name.startsWith(\"TANK\") || name.endsWith(\"coastguard\") || name.endsWith(\"destroyer\") || name.endsWith(\"fighter\") || name.equals(\"AIR bomber\")) {\n boolean airShot = false;\n if (gameMode == EARTH_INVADERS) //we don't want vehicles to shoot each other\n {\n airShot = true;\n curr.setHeadDirection(DOWN);\n }\n if (monsterIndex >= 0 && monsterIndex < players.length && players[monsterIndex].isFlying())\n airShot = true;\n if (curr.getName().endsWith(\"fighter\"))\n curr.setDirection(bodyDir); //keep moving while shooting\n if (mDir != -1 && curr.getRow() > 0 && curr.getCol() > 0 && curr.getRow() < board.length - 1 && curr.getCol() < board[0].length - 1) { //don't shoot from off the visible board\n if ((mDir == bodyDir || ((curr.getName().startsWith(\"TANK\") || curr.getName().endsWith(\"jeep\") || name.equals(\"AIR bomber\")) && (mDir == curr.getHeadDirection() || name.equals(\"AIR bomber\")))) && numFrames >= curr.getLastShotTime() + curr.getReloadTime()) { //AIR bomber needs to be able to drop bombs if they see the monster in front of them or behind them, so we need to check the name in two conditions\n Bullet temp;\n if (name.endsWith(\"jeep\") || name.endsWith(\"coastguard\")) {\n channels[0].programChange(instr[GUNSHOT].getPatch().getProgram());\n channels[0].noteOn((int) (Math.random() * 6) + 65, (int) (Math.random() * 10) + 30);\n temp = new Bullet(\"jeep\" + mDir, curr.getX(), curr.getY(), 5, machBulletImages, SPEED, \"BULLET\", SPEED * 6, airShot, i, -1, -1);\n } else if (name.endsWith(\"troops\") || name.endsWith(\"police\")) {\n channels[0].programChange(instr[GUNSHOT].getPatch().getProgram());\n channels[0].noteOn((int) (Math.random() * 6) + 70, (int) (Math.random() * 10) + 20);\n temp = new Bullet(\"troops\" + mDir, curr.getX(), curr.getY(), 3, bulletImages, SPEED, \"BULLET\", SPEED * 6, airShot, i, -1, -1);\n } else if (name.endsWith(\"destroyer\") || name.endsWith(\"artillery\")) {\n channels[0].programChange(instr[GUNSHOT].getPatch().getProgram());\n channels[0].noteOn((int) (Math.random() * 6) + 45, (int) (Math.random() * 10) + 85);\n temp = new Bullet(\"destroyer\" + mDir, curr.getX(), curr.getY(), 15, shellImages, SPEED, \"SHELL\", SPEED * 3, true, i, players[monsterIndex].findX(cellSize), players[monsterIndex].findY(cellSize));\n } else if (name.endsWith(\"fighter\")) {\n channels[0].programChange(instr[TAIKO].getPatch().getProgram());\n channels[0].noteOn((int) (Math.random() * 10) + 5, (int) (Math.random() * 10) + 40);\n temp = new Bullet(\"fighter\" + mDir, curr.getX(), curr.getY(), 30, rocketImages, SPEED, \"SHELL\", SPEED * 8, true, i, players[monsterIndex].findX(cellSize), players[monsterIndex].findY(cellSize));\n } else if (name.endsWith(\"missile\")) {\n temp = new Bullet(\"missile\" + mDir, curr.getX(), curr.getY(), 50, rocketImages, SPEED, \"SHELL\", SPEED * 3, true, i, players[monsterIndex].findX(cellSize), players[monsterIndex].findY(cellSize));\n channels[0].programChange(instr[TAIKO].getPatch().getProgram());\n channels[0].noteOn((int) (Math.random() * 10) + 5, (int) (Math.random() * 10) + 40);\n } else if (name.endsWith(\"flame\")) {\n temp = new Bullet(\"flame\" + mDir, curr.getX(), curr.getY(), 15, monsterFireImages, SPEED, \"FIRE\", SPEED * 4, airShot, i, -1, -1);\n channels[0].programChange(instr[TAIKO].getPatch().getProgram());\n channels[0].noteOn((int) (Math.random() * 10) + 5, (int) (Math.random() * 10) + 40);\n } else if (name.equals(\"AIR bomber\")) {\n temp = null;\n if (!DISABLE_BOMBERS) {\n int mR = players[PLAYER1].getRow(); //main player row & col\n int mC = players[PLAYER1].getCol();\n int mR2 = -99; //possible 2nd monster row & col\n int mC2 = -99;\n if (p1partner) {\n mR2 = players[PLAYER2].getRow();\n mC2 = players[PLAYER2].getCol();\n }\n if (players[PLAYER1].getHealth() > 0 && (Math.abs(r - mR) <= 2 || Math.abs(c - mC) <= 2 || Math.abs(r - mR2) <= 2 || Math.abs(c - mC2) <= 2)) {//our bomber is in the same row & col as a monster + or - 1\n if (bodyDir == UP && r < board.length - 1) {\n Ordinance.bigExplosion(curr.getX(), curr.getY() + (cellSize * 2), panel);\n Ordinance.radiusDamage(-1, curr.getX(), curr.getY() + (cellSize * 2), 50, panel, .25);\n } else if (bodyDir == DOWN && r > 1) {\n Ordinance.bigExplosion(curr.getX(), curr.getY() - (cellSize * 2), panel);\n Ordinance.radiusDamage(-1, curr.getX(), curr.getY() - (cellSize * 2), 50, panel, .25);\n } else if (bodyDir == RIGHT && c < board[0].length - 1) {\n Ordinance.bigExplosion(curr.getX() - (cellSize * 2), curr.getY(), panel);\n Ordinance.radiusDamage(-1, curr.getX() - (cellSize * 2), curr.getY(), 50, panel, .25);\n } else if (bodyDir == LEFT && c > 1) {\n Ordinance.bigExplosion(curr.getX() + (cellSize * 2), curr.getY(), panel);\n Ordinance.radiusDamage(-1, curr.getX() + (cellSize * 2), curr.getY(), 50, panel, .25);\n }\n }\n }\n } else {\n channels[0].programChange(instr[GUNSHOT].getPatch().getProgram());\n channels[0].noteOn((int) (Math.random() * 6) + 45, (int) (Math.random() * 10) + 85);\n temp = new Bullet(\"\" + mDir, curr.getX(), curr.getY(), 15, shellImages, SPEED, \"SHELL\", SPEED * 5, airShot, i, -1, -1);\n }\n if (temp != null)\n temp.setDirection(mDir);\n\n if (name.endsWith(\"troops\") || name.endsWith(\"police\") && Math.random() < .5) //make the police move towards the monster half the time\n {\n if (mDir == UP && isValidMove(curr, curr.getRow() - 1, curr.getCol()))\n curr.setDirection(UP);\n else if (mDir == DOWN && isValidMove(curr, curr.getRow() + 1, curr.getCol()))\n curr.setDirection(DOWN);\n else if (mDir == LEFT && isValidMove(curr, curr.getRow(), curr.getCol() - 1))\n curr.setDirection(LEFT);\n else if (mDir == RIGHT && isValidMove(curr, curr.getRow(), curr.getCol() + 1))\n curr.setDirection(RIGHT);\n else\n curr.setDirection(-1);\n }\n if (temp != null && players[PLAYER1].getHealth() > 0) {\n if (gameMode == EARTH_INVADERS && !curr.isFlying()) {\n } else {\n if (numFrames >= ceaseFireTime + ceaseFireDuration || gameMode == EARTH_INVADERS) {\n bullets.add(temp);\n curr.setLastShotTime(numFrames);\n continue;\n }\n }\n }\n } else //change to face the monster to line up a shot\n {\n if (name.endsWith(\"troops\") || name.endsWith(\"police\") || name.endsWith(\"destroyer\") || name.endsWith(\"coastguard\") || name.endsWith(\"artillery\")) {\n curr.setDirection(-1); //stop to shoot\n curr.setBodyDirection(mDir);\n } else if (curr.getName().startsWith(\"TANK\") || curr.getName().endsWith(\"jeep\"))\n curr.setHeadDirection(mDir);\n continue;\n }\n }\n }\n int rand = dirs.get((int) (Math.random() * dirs.size()));\n if (curr.isFlying() && (r > 0 && c > 0 && r < board.length - 1 && c < board[0].length - 1)) {\n rand = bodyDir; //make it so aircraft prefer to keep going the same direciton\n } else if (name.startsWith(\"TRAIN\")) {//make it so trains prefer to follow the right wall\n for (int j = 0; j < dirs.size(); j++)\n if (dirs.get(j) != bodyDir) {\n rand = dirs.get(j);\n break;\n }\n }\n curr.setDirection(rand);\n curr.setBodyDirection(rand);\n\n continue;\n }\n //if no preferred direction, include the option to turn around\n //civilians should prefer to turn around rather than approach the monster\n if (name.endsWith(\"civilian\") || name.endsWith(\"bus\")) {\n if (bodyDir == mDir) //if we are facing the same direction as the monster, turn around\n {\n if (bodyDir == UP && isValidMove(curr, curr.getRow() + 1, curr.getCol())) {\n curr.setDirection(DOWN);\n curr.setBodyDirection(DOWN);\n continue;\n } else if (bodyDir == DOWN && isValidMove(curr, curr.getRow() - 1, curr.getCol())) {\n curr.setDirection(UP);\n curr.setBodyDirection(UP);\n continue;\n } else if (bodyDir == LEFT && isValidMove(curr, curr.getRow(), curr.getCol() + 1)) {\n curr.setDirection(RIGHT);\n curr.setBodyDirection(RIGHT);\n continue;\n } else if (bodyDir == RIGHT && isValidMove(curr, curr.getRow(), curr.getCol() - 1)) {\n curr.setDirection(LEFT);\n curr.setBodyDirection(LEFT);\n continue;\n }\n }\n }\n int rand = (int) (Math.random() * 4);\n if (rand == UP && isValidMove(curr, curr.getRow() - 1, curr.getCol())) {\n curr.setDirection(UP);\n curr.setBodyDirection(UP);\n continue;\n }\n if (rand == DOWN && isValidMove(curr, curr.getRow() + 1, curr.getCol())) {\n curr.setDirection(DOWN);\n curr.setBodyDirection(DOWN);\n continue;\n }\n if (rand == LEFT && isValidMove(curr, curr.getRow(), curr.getCol() - 1)) {\n curr.setDirection(LEFT);\n curr.setBodyDirection(LEFT);\n continue;\n }\n if (rand == RIGHT && isValidMove(curr, curr.getRow(), curr.getCol() + 1)) {\n curr.setDirection(RIGHT);\n curr.setBodyDirection(RIGHT);\n continue;\n }\n\n }\n }", "private void follow() {\n\t\t// calculate distance back to hive\n\t\tdouble distToHive = grid.getDistance(grid.getLocation(this),grid.getLocation(hive));\n\t\t// if close to flower from dance information, start scouting\n\t\tif(distToHive > followDist - 5) {\n\t\t\tstate = \"SCOUTING\";\n\t\t}\n\t\t// otherwise keep flying in direction of dance\n\t\telse{\n\t\t\t// deviate slightly from correct angle because bee's aren't perfect (I don't think)\n\t\t\tcurrentAngle += RandomHelper.nextDoubleFromTo(-Math.PI/50, Math.PI/50);\n\t\t\tspace.moveByVector(this, 4, currentAngle,0);\n\t\t\tNdPoint myPoint = space.getLocation(this);\n\t\t\tgrid.moveTo(this, (int) myPoint.getX(), (int) myPoint.getY());\n\t\t\tfood -= highMetabolicRate;\n\t\t}\n\t}", "public boolean move() {\n\t\tint nextDirection;\n\t\tint pacmanX = parent.getPacManX();\n\t\tint pacmanY = parent.getPacManY();\n\t\t\n\t\tint[] directionPriority = new int[4];\n\t\t/** The direction is added to the priority in order to achieve it once the move is chosen */\n\t\tdirectionPriority[0]=(pacmanX-pixelLocationX)*(10)*state+GameCharacter.RIGHT;\n\t\tdirectionPriority[1]=((pacmanX-pixelLocationX)*(-10)*state+GameCharacter.LEFT);\n\t\tdirectionPriority[2]=(pacmanY-pixelLocationY)*(10)*state+GameCharacter.DOWN;\n\t\tdirectionPriority[3]=((pacmanY-pixelLocationY)*(-10)*state+GameCharacter.UP);\n\t\tArrays.sort(directionPriority);\n\t\t\n\t\tint i=3;\n\t\t\n\t\tdo {\n\t\t\tnextDirection = directionPriority[i]%10;\n\t\t\tif (nextDirection < 0) {\n\t\t\t\tnextDirection += 10;\n\t\t\t}\n\t\t\tif(isLegalMove(nextDirection) && (Math.abs(nextDirection-currentDirection) != 2) || i==0) {\n\t\t\t\tsetDirection(nextDirection);\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\ti--;\n\t\t}\n\t\twhile (i>=0);\n\t\treturn super.move();\n\t}", "public void turn(Player player,String move) {\n String[] art = move.split(\" \");\n int x=Integer.parseInt(art[1]);\n int y=Integer.parseInt(art[2]);\n board.mark(player.getMark(),x-1,y-1);\n board.checkFinishCondition();\n if(board.isFinished()){\n finished = true;\n winner = order;\n }\n int aux = (order + 1) % 2;\n order = aux;\n }", "private void tryMovePlayer(int direction) {\n int layerOffset = 0, rowOffset = 0, colOffset = 0;\n boolean canMove = false;\n Maze3D.Cell currentCell = maze3D[playerLayer][playerRow][playerCol];\n Maze3D.Cell nextCell = null;\n try {\n switch (direction)\n {\n case Maze3D.UP:\n nextCell = maze3D[playerLayer][playerRow - 1][playerCol];\n canMove = !(currentCell.isWallTop() || nextCell.isWallBottom());\n rowOffset = -1;\n break;\n case Maze3D.DOWN:\n nextCell = maze3D[playerLayer][playerRow + 1][playerCol];\n canMove = !(currentCell.isWallBottom() || nextCell.isWallTop());\n rowOffset = 1;\n break;\n case Maze3D.LEFT:\n nextCell = maze3D[playerLayer][playerRow][playerCol - 1];\n canMove = !(currentCell.isWallLeft() || nextCell.isWallRight());\n colOffset = -1;\n break;\n case Maze3D.RIGHT:\n nextCell = maze3D[playerLayer][playerRow][playerCol + 1];\n canMove = !(currentCell.isWallRight() || nextCell.isWallLeft());\n colOffset = 1;\n break;\n case Maze3D.FRONT:\n nextCell = maze3D[playerLayer - 1][playerRow][playerCol];\n canMove = !(currentCell.isWallFront() || nextCell.isWallBack());\n layerOffset = -1;\n break;\n case Maze3D.BACK:\n nextCell = maze3D[playerLayer + 1][playerRow][playerCol];\n canMove = !(currentCell.isWallBack() || nextCell.isWallFront());\n layerOffset = 1;\n break;\n }\n //if cell is not null and can move, then move\n if (nextCell != null && canMove)\n {\n playerLayer += layerOffset;\n playerRow += rowOffset;\n playerCol += colOffset;\n mazeView.setPlayerLocation(playerLayer, playerRow, playerCol);\n moves++;\n }\n //if new position is the solution, then game is solved\n if (isSolved())\n {\n notifyGameEnd();\n }\n }\n catch (ArrayIndexOutOfBoundsException e)\n {\n Log.d(TAG, \"tryMovePlayer: player tried to move to edge\");\n }\n }", "private void nextRound()\n {\n Player currentPlayer = roundManager.next();\n\n if(!currentPlayer.getClientConnection().isConnected() || !currentPlayer.getClientConnection().isLogged())\n {\n if(currentPlayer.equals(lastFinalFrenzyPlayer))return;\n nextRound();\n return;\n }\n\n if(gameMode == GameMode.FINAL_FRENZY_BEFORE_FP && roundManager.isFirstPlayer(currentPlayer))gameMode = GameMode.FINAL_FRENZY_AFTER_FP;\n\n try\n {\n currentPlayer.getView().roundStart();\n notifyOtherClients(currentPlayer, virtualView -> virtualView.showNotification(\"È il turno di \"+currentPlayer.getUsername()));\n\n if(roundManager.isFirstRound() || !currentPlayer.isFirstRoundPlayed()) firstRound(currentPlayer);\n\n for(int i = 0; i < gameMode.getPlayableAction(); i++)\n {\n currentPlayer.resetExecutedAction();\n boolean continueRound = executeAction(currentPlayer);\n if(!continueRound)break;\n }\n\n if(gameMode == GameMode.NORMAL)new ReloadAction(this, currentPlayer, ReloadAction.RELOAD_ALL).execute();\n }\n catch (ConnectionErrorException e)\n {\n Logger.error(\"Connection error during \"+currentPlayer.getUsername()+\"'s round!\");\n notifyOtherClients(currentPlayer, virtualView -> virtualView.showNotification(currentPlayer.getUsername()+\" si è disconnesso!\"));\n }\n catch (TimeOutException e)\n {\n Logger.info(\"Player \"+currentPlayer.getUsername()+\" has finished his time\");\n }\n\n currentPlayer.getView().roundEnd();\n currentPlayer.resetExecutedAction();\n refillMap();\n sendBroadcastUpdate();\n if(isFinalFrenzy())currentPlayer.setLastRoundPlayed(true);\n handleDeadPlayers(currentPlayer);\n if(isFinalFrenzy() && currentPlayer.equals(lastFinalFrenzyPlayer))return;\n checkForFinalFrenzy(currentPlayer);\n if(match.connectedPlayerSize() <= 0 || match.connectedPlayerSize() < MatchSettings.getInstance().getMinPlayers())return;\n nextRound();\n\n }", "public void updateMoveRocks(int index) {\n\n\t\tfor (int x = 0; x < 14; x++) {\n\t\t\tbucket[x].setPrevNumOfRocks();\n\t\t}\n\n\t\t// Keep turn if click an empty pit.\n\t\tif (bucket[index].getnumOfRocks() == 0) {\n\t\t\tint player;\n\t\t\tif (index > 7) {\n\t\t\t\tplayer = 2;\n\t\t\t} else {\n\t\t\t\tplayer = 1;\n\t\t\t}\n\t\t\tif (player == 1) {\n\t\t\t\tb.setTurn(false);\n\t\t\t\ta.setTurn(true);\n\t\t\t\ta.resetUndoIncrement();\n\t\t\t} else {\n\t\t\t\ta.setTurn(false);\n\t\t\t\tb.setTurn(true);\n\t\t\t\tb.resetUndoIncrement();\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tint sIndex = index;\n\t\tint count = bucket[sIndex].getnumOfRocks();\n\t\tbucket[sIndex].setnumOfRocks(0, c);\n\t\tint eIndex = 0;\n\n\t\tif (sIndex == 0 || sIndex == 7)\n\t\t\treturn;\n\n\t\tint i = sIndex - 1;\n\t\twhile (!(count == 0)) {\n\t\t\tif (i == 7 && (sIndex == 1 || sIndex == 2 || sIndex == 3 || sIndex == 4 || sIndex == 5 || sIndex == 6)) {\n\t\t\t\ti--;\n\t\t\t}\n\t\t\tif (i == 0\n\t\t\t\t\t&& (sIndex == 13 || sIndex == 12 || sIndex == 11 || sIndex == 10 || sIndex == 9 || sIndex == 8)) {\n\t\t\t\ti = 13;\n\t\t\t}\n\n\t\t\tint t = bucket[i].getnumOfRocks() + 1;\n\t\t\tbucket[i].setnumOfRocks(t, c);\n\t\t\tcount--;\n\t\t\tif (count == 0) {\n\t\t\t\teIndex = i; // Gets the ending index so it can be checked for\n\t\t\t\t\t\t\t// capture and not reset if ends on 0.\n\t\t\t}\n\t\t\tif (i == 0) {\n\t\t\t\ti = 14;\n\t\t\t}\n\t\t\ti--;\n\n\t\t}\n\n\t\t// extra turn logic\n\t\tcheckIfFreeTurn(index, eIndex);\n\n\t\t// Capture Stone function\n\t\tcheckCaptureRock(eIndex, sIndex);\n\n\t\t// end game scenario, when one side is out of stones.\n\t\tcheckEndGame();\n\n\t}", "public void preyMovement(WallBuilding wb, int x1, int x2, int y1, int y2){\r\n int b1 = wb.block.get(wb.block.stx(x1), wb.block.sty(y1));//one away\r\n int b2 = wb.block.get(wb.block.stx(x2), wb.block.sty(y2));//two away\r\n if(b1 == 0){//if there are no blocks, we can move normally\r\n if(wb.food.getObjectsAtLocation(x1, y1) == null){//if there is no food in that space\r\n wb.prey.setObjectLocation(this, wb.prey.stx(x1),wb.prey.sty(y1));\r\n }\r\n }else if(b1 == 1){//if there is one block\r\n if(b2 == 0){//if the space after is empty, we can move too!\r\n if(wb.food.getObjectsAtLocation(x2, y2) == null){//if there is no food in that space\r\n wb.block.set(wb.block.stx(x2), wb.block.sty(y2), b2+1);\r\n wb.block.set(wb.block.stx(x1), wb.block.sty(y1), b1-1);\r\n wb.prey.setObjectLocation(this, wb.prey.stx(x1),wb.prey.sty(y1));\r\n }\r\n }else if(b2 < 3){//there is space to move the block\r\n wb.block.set(wb.block.stx(x2), wb.block.sty(y2), b2+1);\r\n wb.block.set(wb.block.stx(x1), wb.block.sty(y1), b1-1);\r\n }\r\n }else{//if there are 2 or 3 blocks\r\n if(b2 < 3){//there is space to move the block\r\n if(wb.food.getObjectsAtLocation(x2, y2) == null){//if there is no food in that space\r\n wb.block.set(wb.block.stx(x2), wb.block.sty(y2), b2+1);\r\n wb.block.set(wb.block.stx(x1), wb.block.sty(y1), b1-1);\r\n }\r\n }\r\n }\r\n }", "protected void wander() {\n\t\tfor(int i=3;i>0;){\n\t\t\tfindChest();\n\t\t\tint num = ((int) (Math.random()*100)) % 4;\n\t\t\tswitch (num+1){\n\t\t\t\tcase 1 :\n\t\t\t\t\tif(!(character.xOfFighter-1==game.getXofplayer()&&character.yOfFighter==game.getYofplayer())\n\t\t\t\t\t\t\t&&game.getPlayingmap().npcMove(character.xOfFighter,character.yOfFighter,character.xOfFighter-1,character.yOfFighter)){\n\t\t\t\t\t\tcharacter.xOfFighter = character.xOfFighter-1;\n\t\t\t\t\t\ti--;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2 :\n\t\t\t\t\tif(!(character.xOfFighter==game.getXofplayer()&&character.yOfFighter-1==game.getYofplayer())&&\n\t\t\t\t\t\t\tgame.getPlayingmap().npcMove(character.xOfFighter,character.yOfFighter,character.xOfFighter,character.yOfFighter-1)){\n\t\t\t\t\t\tcharacter.yOfFighter = character.yOfFighter-1;\n\t\t\t\t\t\ti--;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3 :\n\t\t\t\t\tif(!(character.xOfFighter+1==game.getXofplayer()&&character.yOfFighter==game.getYofplayer())&&\n\t\t\t\t\t\t\tgame.getPlayingmap().npcMove(character.xOfFighter,character.yOfFighter,character.xOfFighter+1,character.yOfFighter)){\n\t\t\t\t\t\tcharacter.xOfFighter = character.xOfFighter+1;\n\t\t\t\t\t\ti--;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 4 :\n\t\t\t\t\tif(!(character.xOfFighter==game.getXofplayer()&&character.yOfFighter+1==game.getYofplayer())&&\n\t\t\t\t\t\t\tgame.getPlayingmap().npcMove(character.xOfFighter,character.yOfFighter,character.xOfFighter,character.yOfFighter+1)){\n\t\t\t\t\t\tcharacter.yOfFighter = character.yOfFighter+1;\n\t\t\t\t\t\ti--;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tfindChest();\n\t}", "private static Score4MoveType winnerDecission(int opponentPawns, int mePawns) {\n\t\tif (opponentPawns == mePawns && opponentPawns > 0) {\n\t\t\treturn Score4MoveType.DRAW;\n\t\t}\n\t\tif (opponentPawns > mePawns) {\n\t\t\treturn Score4MoveType.LOST;\n\t\t}\n\t\tif (opponentPawns < mePawns) {\n\t\t\treturn Score4MoveType.WON;\n\t\t}\n\t\treturn null;\n\t}", "public int checkCastle(Board b, char race) {\n Set<Coordinate> opponentPieces = (race == 'b') ? b.white : b.black;\n Set<Coordinate> opponentMoves = new HashSet<Coordinate>();\n\n for (Coordinate each : opponentPieces) {\n if (b.board[each.x][each.y] instanceof King) {\n continue;\n }\n if (b.board[each.x][each.y] instanceof Pawn) {\n opponentMoves.addAll(((Pawn) (b.board[each.x][each.y])).killableMoves(b));\n } else {\n opponentMoves.addAll(b.board[each.x][each.y].displayMoves(b));\n }\n }\n\n switch (race) {\n case 'b':\n if (b.board[0][4] != null && b.board[0][4].move == 0) {\n int i = 0;\n if (b.board[0][0] != null && b.board[0][0].move == 0) {\n if (b.board[0][1] == null && b.board[0][2] == null && b.board[0][3] == null) {\n if (!opponentMoves.contains(new Coordinate(0, 2)) && !opponentMoves.contains(new Coordinate(0, 3))\n && !opponentMoves.contains(new Coordinate(0, 4))) {\n i++;\n }\n }\n }\n\n if (b.board[0][7] != null && b.board[0][7].move == 0) {\n if (b.board[0][5] == null && b.board[0][6] == null) {\n if (!opponentMoves.contains(new Coordinate(0, 6)) && !opponentMoves.contains(new Coordinate(0, 5))\n && !opponentMoves.contains(new Coordinate(0, 4))) {\n i += 10;\n }\n }\n }\n return i;\n }\n break;\n\n case 'w':\n if (b.board[7][4] != null && b.board[7][4].move == 0) {\n int i = 20;\n if (b.board[7][0] != null && b.board[7][0].move == 0) {\n if (b.board[7][1] == null && b.board[7][2] == null && b.board[7][3] == null) {\n if (!opponentMoves.contains(new Coordinate(7, 2)) && !opponentMoves.contains(new Coordinate(7, 3))\n && !opponentMoves.contains(new Coordinate(7, 4))) {\n i++;\n }\n }\n }\n\n if (b.board[7][7] != null && b.board[7][7].move == 0) {\n if (b.board[7][5] == null && b.board[7][6] == null) {\n if (!opponentMoves.contains(new Coordinate(7, 6)) && !opponentMoves.contains(new Coordinate(7, 5))\n && !opponentMoves.contains(new Coordinate(7, 4))) {\n i += 10;\n }\n }\n }\n return i;\n }\n break;\n }\n return 69;\n }", "public void goToNextRound() throws IOException {\r\n System.out.println(\"ROUND DONE: All messages sent and received for node \" + nodeInfo.nodeID + \" at round \" + currentRoundNumber);\r\n System.out.println();\r\n\r\n // If current round number equals the max number of rounds (i.e. maxHop-2)\r\n if(currentRoundNumber == maxHop-2)\r\n {\r\n // Display the node, k-hop neighbors of the node, and the eccentricity of the node.\r\n // Write those displayed values to an output file as well - config-nodeID.txt\r\n String filename = \"config-\" + nodeInfo.nodeID + \".txt\";\r\n String filepath = \"Documents/AOS/Projects/Project1/\";\r\n\r\n //check for write-ability and open output file\r\n File outFile = new File(filepath + filename);\r\n PrintWriter output = new PrintWriter(outFile);\r\n\r\n if(outFile.canWrite()) {\r\n\r\n System.out.println(\"Output files stored at: \" + outFile.getAbsolutePath());\r\n\r\n // Node ID\r\n String printline = \"Node \" + nodeInfo.nodeID;\r\n System.out.println(printline);\r\n output.write(printline + \"\\n\");\r\n int eccentricity = 0;\r\n\r\n // Loop through each k-hop neighbor list\r\n for (int i = 0; i < maxHop; i++) {\r\n // Print all k-hop neighbor lists for the node.\r\n printline = i + 1 + \"-hop neighbors --> \" + kHopNeighbors[i];\r\n System.out.println(printline);\r\n output.write(printline + \"\\n\");\r\n // Determine the eccentricity - it will be the last non-empty list of the k-hop neighbors.\r\n if (!kHopNeighbors[i].isEmpty()) {\r\n eccentricity = i + 1;\r\n }\r\n }\r\n\r\n // Display eccentricity of the node.\r\n printline = \"Eccentricity: \" + eccentricity;\r\n System.out.println(printline);\r\n output.write(printline + \"\\n\");\r\n\r\n output.close();\r\n }\r\n\r\n // Do not move to next round - return.\r\n return;\r\n }\r\n\r\n // Move to next round.\r\n currentRoundNumber++;\r\n // Reset messages received and sent for new round with a value of false.\r\n messagesReceivedThisRound.replaceAll((key, value) -> value = false);\r\n messagesSentThisRound.replaceAll((key, value) -> value = false);\r\n System.out.println(\"\\n\\nNEW ROUND: Node \" + nodeInfo.nodeID + \" moved to round \" + currentRoundNumber);\r\n // Notify all threads associated with this node that they are starting a new round. Any buffered messages will now\r\n // be processed.\r\n notifyAll();\r\n System.out.println(\"NOTIFIED: All threads notified of new round.\");\r\n\r\n\r\n }", "private int winnerMoves(int combinedMoveCounter) {\n return (int) (Math.ceil((double) combinedMoveCounter / 2.0));\n }", "public void move() {\n\t\tif ( board.getLevel() == 5 )\n\t\t\tmovementIndex = ( movementIndex + 1 ) % movement.length;\n\t}", "public void redistribute(int holeIndex){\n\n if(holes[holeIndex].getOwner() == nextToPlay) {\n ArrayList<Korgool> korgoolsToMove = holes[holeIndex].getKoorgools();\n Hole holeChosen = holes[holeIndex];\n Hole lastHole;\n //@Check if there are no korgools in the hole.\n if(korgoolsToMove.size() == 0){\n return;\n }\n //@Check if there are 1 korgool in the hole.\n else if(korgoolsToMove.size() == 1){\n lastHole = holes[(holeIndex + 1) % 18];\n lastHole.addKorgool(holeChosen.getKoorgools().get(0));\n holeChosen.emptyHole();\n }\n else{\n lastHole = holes[(holeIndex + korgoolsToMove.size() - 1) % 18];\n //Distributes each korgools\n for(int distributeIndex = 1; distributeIndex < korgoolsToMove.size(); distributeIndex++){\n holes[(holeIndex + distributeIndex) % 18].addKorgool(korgoolsToMove.get(distributeIndex));\n }\n Korgool first = korgoolsToMove.get(0);\n holeChosen.emptyHole();\n holeChosen.addKorgool(first);\n }\n //@Check if we add to kazan or make tuz.\n\n if(lastHole.getOwner() != nextToPlay) {\n Side checkTuzSide = (nextToPlay == Side.WHITE) ? Side.BLACK : Side.WHITE;\n int otherTuzIndex = getPlayerTuz(checkTuzSide);\n int playersKazanIndex = (nextToPlay == Side.WHITE) ? 0 : 1;\n ArrayList<Korgool> lastHoleKorgools = lastHole.getKoorgools();\n if ((((otherTuzIndex - 9) != lastHole.getHoleIndex() && (otherTuzIndex + 9) != lastHole.getHoleIndex()) || otherTuzIndex == -1) && (lastHole.getHoleIndex() != 8 && lastHole.getHoleIndex() != 17) && lastHoleKorgools.size() == 3 && !lastHole.isTuz() && !nextToPlay.hasTuz()) {\n lastHole.markAsTuz();\n\n nextToPlay.makeTuz();\n if (nextToPlay == Side.BLACK) {\n MouseListener mouseListener = lastHole.getGui().getMouseListeners()[0];\n lastHole.getGui().removeMouseListener(mouseListener);\n }\n for (int i = 0; i < lastHoleKorgools.size(); i++) {\n kazans[playersKazanIndex].addKorgool(new Korgool());\n }\n kazans[playersKazanIndex].addKorgools(lastHole.getKoorgools());\n lastHole.emptyHole();\n }\n else if(lastHoleKorgools.size() % 2 == 0){\n for(int i = 0; i < lastHoleKorgools.size(); i++) {\n kazans[playersKazanIndex].addKorgool(new Korgool());\n }\n lastHole.emptyHole();\n }\n }\n nextToPlay = nextToPlay==Side.WHITE ? Side.BLACK : Side.WHITE;\n }\n }", "public void run() {\n if(_dest!=null) {\n approachDest();\n return;\n }\n if(Rand.d100(_frequency)) {\n MSpace m = in.b.getEnvironment().getMSpace();\n if(!m.isOccupied()) {\n Logger.global.severe(in.b+\" has come unstuck\");\n return;\n }\n MSpace[] sur = m.surrounding();\n int i = Rand.om.nextInt(sur.length);\n for(int j=0;j<sur.length;j++) {\n if(sur[i]!=null&&sur[i].isWalkable()&&accept(sur[i])) {\n in.b.getEnvironment().face(sur[i]);\n MSpace sp = in.b.getEnvironment().getMSpace().move(in.b.getEnvironment().getFacing());\n if(sp!=null&&(in.b.isBlind()||!sp.isOccupied())) {\n _move.setBot(in.b);\n _move.perform();\n }\n break;\n }\n if(++i==sur.length) {\n i = 0;\n }\n }\n }\n else if(_dest==null&&Rand.d100(_travel)) {\n _dest = findNewSpace();\n //System.err.println(in.b+\" DEST: \"+_dest);\n }\n }", "private int getBestMove(int[] board, int depth, boolean turn) {\n int boardCopy[];\n if (depth <= 0) {\n return 0;\n }\n if (depth > STEP_BACK_DEPTH) {\n try {\n Thread.sleep(3);\n } catch (InterruptedException e) {\n e.printStackTrace();\n if (shouldStop()) {\n Log.d(Constants.MY_TAG,\"out CalculatingBot\");\n unlock();\n return 0;\n }\n }\n }\n if (turn) {\n int minimum = MAXIMUM_POSSIPLE_SCORE_DIFFERENCE;\n for (int i = 0; i < 5; i++) {\n if (board[i] < 2) {\n continue;\n }\n boardCopy = board.clone();\n int x = playMove(boardCopy, i);\n int y = 0;\n if (!hasPlayer2Move(boardCopy)) {\n if (hasPlayer1Move(boardCopy)) {\n y = getBestMove(boardCopy, depth - 1, turn);\n } else {\n for (int j = 0; j < 5; j++) {\n y = y - boardCopy[j];\n }\n for (int j = 5; j < 10; j++) {\n y = y + boardCopy[j];\n }\n }\n } else {\n y = getBestMove(boardCopy, depth - 1, ! turn);\n }\n int z = y - x;\n if (z < minimum) {\n minimum = z;\n }\n }\n int i = 10;\n if (board[2] < 2) {\n return minimum;\n }\n boardCopy = board.clone();\n int x = playMove(boardCopy, i);\n int y = 0;\n if (!hasPlayer2Move(boardCopy)) {\n if (hasPlayer1Move(boardCopy)) {\n y = getBestMove(boardCopy, depth - 1, turn);\n } else {\n for (int j = 0; j < 5; j++) {\n y = y - boardCopy[j];\n }\n for (int j = 5; j < 10; j++) {\n y = y + boardCopy[j];\n }\n }\n } else {\n y = getBestMove(boardCopy, depth - 1, !turn);\n }\n int z = y - x;\n if (z < minimum) {\n minimum = z;\n }\n return minimum;\n } else {\n int maximum = MINIMUM_POSSIPLE_SCORE_DIFFERENCE;\n for (int i = 5; i < 10; i++) {\n if (board[i] < 2) {\n continue;\n }\n boardCopy = board.clone();\n int x = playMove(boardCopy, i);\n int y = 0;\n if (!hasPlayer1Move(boardCopy)) {\n if (hasPlayer2Move(boardCopy)) {\n y = getBestMove(boardCopy, depth - 1, turn);\n } else {\n for (int j = 0; j < 5; j++) {\n y = y - boardCopy[j];\n }\n for (int j = 5; j < 10; j++) {\n y = y + boardCopy[j];\n }\n }\n } else {\n y = getBestMove(boardCopy, depth - 1, !turn);\n }\n int z = y + x;\n if (z > maximum) {\n maximum = z;\n }\n }\n int i = 11;\n if (board[7] < 2) {\n return maximum;\n }\n boardCopy = board.clone();\n int x = playMove(boardCopy, i);\n int y = 0;\n if (!hasPlayer1Move(boardCopy)) {\n if (hasPlayer2Move(boardCopy)) {\n y = getBestMove(boardCopy, depth - 1, turn);\n } else {\n for (int j = 0; j < 5; j++) {\n y = y - boardCopy[j];\n }\n for (int j = 5; j < 10; j++) {\n y = y + boardCopy[j];\n }\n }\n } else {\n y = getBestMove(boardCopy, depth - 1, !turn);\n }\n int z = y + x;\n if (z > maximum) {\n maximum = z;\n }\n return maximum;\n }\n }", "public void moveEnemy() {\n int moveDirection = randomGenerator(0, 3);\n int enemyAmount = snakeEnemyPartList.size();\n for(int i = 0; i < enemyAmount; i++) {\n\n int rowsNew = snakeEnemyPartList.get(i).getSnakeEnemyPartRowsNew();\n int collsNew = snakeEnemyPartList.get(i).getSnakeEnemyPartCollsNew();\n\n switch (moveDirection) {\n case 0:\n if(board[rowsNew-1][collsNew] == 'S'){\n keepMoving = false;\n System.out.println(\"ENEMY HAS EATEN YOU!\");\n }\n else if(board[rowsNew-1][collsNew] == ' '){\n snakeEnemyPartList.get(i).moveEnemy('w');\n } else {\n moveEnemy();\n }\n break;\n\n case 1:\n if(board[rowsNew][collsNew-1] == 'S'){\n keepMoving = false;\n System.out.println(\"ENEMY HAS EATEN YOU!\");\n }\n else if(board[rowsNew][collsNew-1] == ' '){\n snakeEnemyPartList.get(i).moveEnemy('a');\n }else {\n moveEnemy();\n }\n\n break;\n\n case 2:\n if(board[rowsNew+1][collsNew] == 'S'){\n keepMoving = false;\n System.out.println(\"ENEMY HAS EATEN YOU!\");\n }\n else if(board[rowsNew+1][collsNew] == ' '){\n snakeEnemyPartList.get(i).moveEnemy('s');\n }else {\n moveEnemy();\n }\n\n break;\n\n case 3:\n if(board[rowsNew][collsNew+1] == 'S'){\n keepMoving = false;\n System.out.println(\"ENEMY HAS EATEN YOU!\");\n }\n else if(board[rowsNew][collsNew+1] == ' '){\n snakeEnemyPartList.get(i).moveEnemy('d');\n }else {\n moveEnemy();\n }\n \n break;\n }\n }\n \n }", "public void makeMove() {\n\t\tif (CheckForVictory(this)) {\n\t\t\t// System.out.println(\"VICTORY\");\n\t\t\tInterface.goalReached = true;\n\t\t\tfor (int i = 0; i < tmpStrings.length; i++) {\n\t\t\t\tif (moveOrder[i] == 0)\n\t\t\t\t\ttmpStrings[i] = \"turn left\";\n\t\t\t\telse if (moveOrder[i] == 1)\n\t\t\t\t\ttmpStrings[i] = \"turn right\";\n\t\t\t\telse\n\t\t\t\t\ttmpStrings[i] = \"go forward\";\n\n\t\t\t\tInterface.info.setText(\"Generation: \" + Parallel.generationNo + 1 + \" and closest distance to goal: \" + 0);\n\t\t\t}\n\t\t} else {\n\t\t\tmoveOrder[this.movesMade] = moves.remove();\n\t\t\tswitch (moveOrder[this.movesMade]) {\n\t\t\tcase (0):\n\t\t\t\tthis.movesMade++;\n\t\t\t\tif (face == 0)\n\t\t\t\t\tface = 3;\n\t\t\t\telse\n\t\t\t\t\tface--;\n\t\t\t\tbreak;\n\t\t\tcase (1):\n\t\t\t\tthis.movesMade++;\n\t\t\t\tif (face == 3)\n\t\t\t\t\tface = 0;\n\t\t\t\telse\n\t\t\t\t\tface++;\n\t\t\t\tbreak;\n\t\t\tcase (2):\n\t\t\t\tthis.movesMade++;\n\t\t\t\tif (face == 0 && Y - 1 >= 0)\n\t\t\t\t\tY--;\n\t\t\t\telse if (face == 1 && X + 1 <= map[0].length - 1)\n\t\t\t\t\tX++;\n\t\t\t\telse if (face == 2 && Y + 1 <= map.length - 1)\n\t\t\t\t\tY++;\n\t\t\t\telse if (face == 3 && X - 1 >= 0)\n\t\t\t\t\tX--;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tSystem.out.println(\"Error making move :(\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}", "public final void visit(final Knight knight) {\n if (knight.getBackstabIndex() == 0) {\n if (knight.getPosition().equals('W')) {\n knight.takeDmg(Math.round(backstabDmg * Constants.WOODS_LAND\n * this.getKnightModifier() * Constants.BACKSTAB_CRIT));\n knight.setBackstabIndex(Constants.BACKSTAB_INDEX);\n return;\n } else {\n knight.setBackstabIndex(Constants.BACKSTAB_INDEX);\n }\n }\n if (knight.getPosition().equals('W')) {\n knight.takeDmg(Math.round(backstabDmg * Constants.WOODS_LAND\n * this.getKnightModifier()));\n } else {\n knight.takeDmg(Math.round(backstabDmg * this.getKnightModifier()));\n }\n knight.setBackstabIndex(knight.getBackstabIndex() - 1);\n }", "@Override\r\n\tpublic boolean makeMove(String notation) {\n\t\tif(Castle.isCastlingMove(new ChessCoordinate(notation))) {\r\n\t\t\tKing playerKing = (King) getPlayerTurn().getPieces(\"King\", true).get(0);\r\n\t\t\t//return the result of trying to castle\r\n\t\t\treturn playerKing.move(new ChessCoordinate(notation));\r\n\t\t\t\r\n\t\t}else {\r\n\t\t\t//not a castling move, standard move\r\n\t\t\t\t\r\n\t\t\tString[] notationList = notation.split(\"\");\r\n\t\t\t//find the piece name\r\n\t\t\tString pieceName = ChessPieceNames.getPieceName(notationList[0]);\t\t\r\n\t\t\t\r\n\t\t\tif(pieceName == null && getColumnNames().contains(notationList[0].toLowerCase())) {\r\n\t\t\t\t//if first character is a column and returned null from above\r\n\t\t\t\t//must be a pawn move like e4 or axb2\r\n\t\t\t\tpieceName = ChessPieceNames.PAWN.toString();\r\n\t\t\t}else if(pieceName == null){\r\n\t\t\t\t//not a column and null so invalid move\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\r\n//\t\t\t//capturing move if there is a capture (x)\r\n\t\t\tboolean isCaptureMove = Arrays.asList(notationList).contains(\"x\");\r\n\t\t\t\r\n\t\t\t//final coordinate\r\n\t\t\tString coordinateString = notationList[notationList.length-2] + notationList[notationList.length-1];\r\n\t\t\tChessCoordinate coordinate = new ChessCoordinate(coordinateString);\r\n\t\t\tif(coordinate.isValid()) {\r\n\t\t\t\t//extract players alive pieces of piece name\r\n\t\t\t\tList<Piece> piecesOfType = getPlayerTurn().getPieces(pieceName, true);\r\n\t\t\t\t//list of pieces that can move to the same square\r\n\t\t\t\tList<Piece> piecesCanMoveToSquare = new ArrayList<Piece>();\r\n\t\t\t\tfor (Piece piece : piecesOfType) {\r\n\t\t\t\t\t\r\n\t\t\t\t\t//use valid moves of attacking if capturing move, else use move to\r\n\t\t\t\t\tSet<Coordinate> pieceMoves = isCaptureMove \r\n\t\t\t\t\t\t\t? piece.getValidMoves(Action.ATTACK) : piece.getValidMoves(Action.MOVE_TO);\r\n\t\t\t\t\tif(pieceMoves.contains(coordinate))piecesCanMoveToSquare.add(piece);\r\n\t\t\t\t}\t\r\n\t\t\t\t\r\n\t\t\t\tif (piecesCanMoveToSquare.size() == 1) {\r\n\t\t\t\t\t//only one piece can go to that square, so take piece at 0th index as the list only has one element\r\n\t\t\t\t\tpiecesCanMoveToSquare.get(0).move(coordinate);\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\telse if (piecesCanMoveToSquare.size() > 1) {\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(notation.length() <= 3) {\r\n\t\t\t\t\t\tSystem.out.println(\"Invalid move, specify which piece to move to \" + coordinateString);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//multiple pieces of the same type can move to that square, check which one to use\r\n\t\t\t\t\t//if pawn, the identifier to use is the 0th index of notationList, eg axb4. use pawn in column a.\r\n\t\t\t\t\t//for other pieces, column to use is the 1st index of notationList. eg Nab4.\r\n\t\t\t\t\t\r\n\t\t\t\t\t//variable called identifier as it can be a row or column value.\r\n\t\t\t\t\tString identifier = (pieceName.equalsIgnoreCase(ChessPieceNames.PAWN.toString()) ?\r\n\t\t\t\t\t\t\tnotationList[0] : notationList[1]).toLowerCase();\r\n\t\t\t\t\t//identifier should be a row value if pieces share the same column\r\n\t\t\t\t\tboolean isRowIdentifier = shareColumn(piecesOfType);\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(isRowIdentifier && getRowNames().contains(identifier)) {\r\n\t\t\t\t\t\t//locate piece by row and move that piece to coordinate\r\n\t\t\t\t\t\tfor (Piece piece : piecesCanMoveToSquare) {\r\n\t\t\t\t\t\t\t//look at the row number of piece coordinate, see if it matches the identifier \r\n\t\t\t\t\t\t\tif(Character.toString(piece.getPosition().toString().charAt(1)).equalsIgnoreCase(identifier)) {\r\n\t\t\t\t\t\t\t\tpiece.move(coordinate);\r\n\t\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tSystem.out.println(\"There is no \" + pieceName + \" on row \" + identifier);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}else if(getColumnNames().contains(identifier)) {\r\n\t\t\t\t\t\tfor (Piece piece : piecesCanMoveToSquare) {\r\n\t\t\t\t\t\t\t//look at the column letter of piece coordinate, see if it matches the identifier \r\n\t\t\t\t\t\t\tif(Character.toString(piece.getPosition().toString().charAt(0)).equalsIgnoreCase(identifier)) {\r\n\t\t\t\t\t\t\t\tpiece.move(coordinate);\r\n\t\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tSystem.out.println(\"There is no \" + pieceName + \" on column \" + identifier);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//invalid identifier\r\n\t\t\t\t\telse return false;\r\n\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\telse {\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t//invalid coordinate, move can not be played\r\n\t\t\telse return false;\r\n\t\t}\r\n\t\t\r\n\t}", "@Override\n\tpublic void movePawn(Pawn pawn, Deck deck,int choice)\n\t{\n\t\tboolean move_Result=false;\n\t\tswitch (choice)\n\t\t{\n\t\tcase 1:\n\t\t\tmove_Result=beginFromStart(pawn,deck);\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tmove_Result=moveByTwo(pawn, deck);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t\t//check if the move that the user chose is valid or make the other move if it's possible\n \n\t\tif(choice==1 && move_Result==false)\n\t\t{\n\t\t\tmoveByTwo(pawn, deck);\n\t\t\t\n\t\t\t\n\t\t}\n\t\telse if(choice==2 && move_Result==false)\n\t\t{\n\t\t\tif ( beginFromStart(pawn,deck) ) \n\t\t\t{\n\t\t\t\t\n\t\t\t}\n\t\t\telse {\n\t\t\t\t//fold to continue\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t}", "public void move() {\n if (this.nextMove.equals(\"a\")) { // move down\n this.row = row + 1;\n progress += 1;\n if (progress == steps) {\n nextMove = \"b\";\n progress = 0;\n }\n } else if (this.nextMove.equals(\"b\")) { // move right\n this.col = col + 1;\n progress += 1;\n if (progress == steps) {\n nextMove = \"c\";\n progress = 0;\n }\n } else if (this.nextMove.equals(\"c\")) { // move up\n this.row = row - 1;\n progress += 1;\n if (progress == steps) {\n nextMove = \"a\";\n progress = 0;\n }\n }\n }", "public void win() {\n if (turn == 1) {\n p1.incrementLegs();\n if (p1.getLegs() == 5) {\n p1.incrementSets();\n p1.setLegs(0);\n p2.setSets(0);\n\n }\n if (p1LastScore > p1.getHighout()) {\n p1.setHighout(p1LastScore);\n\n }\n\n if (p1.getHighout() > OVERALL_HIGH_OUT) {\n OVERALL_HIGH_OUT = p1.getHighout();\n }\n } else if (turn == 2) {\n p2.incrementLegs();\n if (p2.getLegs() == 5) {\n p2.incrementSets();\n p2.setLegs(0);\n p1.setSets(0);\n\n }\n if (p2LastScore > p2.getHighout()) {\n p2.setHighout(p2LastScore);\n }\n\n if (p2.getHighout() > OVERALL_HIGH_OUT) {\n OVERALL_HIGH_OUT = p2.getHighout();\n }\n\n\n\n }\n changeFirstTurn();\n win = true;\n\n\n\n }", "public void chasePlayer() {\n refreshObstructionMatrix();\n Coordinate currPosition = new Coordinate(getX(), getY());\n Player player = this.dungeon.getPlayer();\n Coordinate playerPosition = new Coordinate(player.getX(), player.getY());\n\n if (currPosition.equals(playerPosition)) {\n // Debug.printC(\"Enemy has reached the player!\", Debug.RED);\n player.useItem(this);\n } else {\n this.pathToDest = pathFinder.getPathToDest(currPosition, playerPosition);\n if (!this.pathToDest.empty()) {\n Coordinate nextPosition = this.pathToDest.pop();\n // this.setCoordinate(nextPosition);\n if (getX() + 1 == nextPosition.x) {\n moveRight();\n } else if (getX() - 1 == nextPosition.x) {\n moveLeft();\n } else if (getY() + 1 == nextPosition.y) {\n moveDown();\n } else if (getY() - 1 == nextPosition.y) {\n moveUp();\n }\n }\n }\n }", "@Override\n public int turn() {\n return moveOnTurn;\n }", "public void makeMove(String castleString) throws InvalidMoveException {\n Piece kingPiece, rookPiece, betweenPiece;\n Coordinate kingCoordinate, rookCoordinate, betweenCoordinate, oppCoordinate;\n int xIncrement, spacesToRook;\n\n // verify valid castle String O-O or O-O-O\n if (!castleString.equals(KING_SIDE_CASTLE_STRING) && !castleString.equals(QUEEN_SIDE_CASTLE_STRING)) {\n throw new InvalidMoveException();\n }\n\n kingCoordinate = getKingCoordinate(nextMoveColor);\n kingPiece = getPieceFromCoordinate(kingCoordinate);\n\n // King cannot be in check or have moved already\n if (isInCheck(nextMoveColor) || kingPiece.getHasMoved()) {\n throw new InvalidMoveException();\n }\n\n if (castleString == KING_SIDE_CASTLE_STRING) {\n xIncrement = 1;\n spacesToRook = 3;\n }\n else {\n xIncrement = -1;\n spacesToRook = 4;\n }\n\n rookCoordinate = new Coordinate(kingCoordinate.getPosX() + spacesToRook * xIncrement,\n kingCoordinate.getPosY());\n rookPiece = getPieceFromCoordinate(rookCoordinate);\n // Rook must not have moved already\n if (!(rookPiece instanceof Rook) || rookPiece.getPieceColor() != nextMoveColor || rookPiece.getHasMoved()) {\n throw new InvalidMoveException();\n }\n\n betweenCoordinate = new Coordinate(kingCoordinate);\n for (int i = 0; i < 2; i++) {\n betweenCoordinate.addVals(xIncrement, 0);\n betweenPiece = getPieceFromCoordinate(betweenCoordinate);\n // the two spaces to the left or right of the King must be empty\n if (betweenPiece != null) {\n throw new InvalidMoveException();\n }\n for (int j = 0; j < VERTICAL_BOARD_LENGTH; j++) {\n for (int k = 0; k < HORIZONTAL_BOARD_LENGTH; k++) {\n oppCoordinate = new Coordinate(k, j);\n // an opposing piece cannot be attacking the two empty spaces\n if (isValidEndpoints(oppCoordinate, betweenCoordinate, oppositeColor(nextMoveColor))) {\n if (isValidPath(oppCoordinate, betweenCoordinate, oppositeColor(nextMoveColor), false)) {\n throw new InvalidMoveException();\n }\n }\n }\n }\n }\n\n // move the King and Rook for castling\n boardArray[betweenCoordinate.getPosY()][betweenCoordinate.getPosX()] = kingPiece;\n boardArray[kingCoordinate.getPosY()][kingCoordinate.getPosX()] = null;\n kingPiece.setPieceCoordinate(betweenCoordinate);\n\n betweenCoordinate.addVals(xIncrement * -1, 0);\n boardArray[betweenCoordinate.getPosY()][betweenCoordinate.getPosX()] = rookPiece;\n boardArray[rookCoordinate.getPosY()][rookCoordinate.getPosX()] = null;\n rookPiece.setPieceCoordinate(betweenCoordinate);\n\n\n kingPiece.setHasMoved(true);\n rookPiece.setHasMoved(true);\n\n nextMoveColor = oppositeColor(nextMoveColor);\n turnNumber++;\n }", "@Override\n\tpublic void move() {\n\t\tCoordinate currPos = new Coordinate(control.getPosition());\n\t\t\n\t\t// if we have enough packages head to the exit\n\t\tif (control.numParcels() <= control.numParcelsFound()) {\n\t\t\t// if we don't have a path to the exit\n\t\t\tif (control.currentPath == null || !control.isHeadingToFinish) {\t\n\t\t\t\t// find path to exit\n\t\t\t\tArrayList<Coordinate> tempPath = null;\n\t\t\t\t// See if there's a path without needing to go through hazards\n\t\t\t\ttempPath = control.findPath(currPos, control.finish.get(0), control.hazardsMap.keySet());\n\t\t\t\tSet<Coordinate> tempHazards = new HashSet<>(control.hazardsMap.keySet());\n\t\t\t\t// If no path without going through hazards, just go through them\n\t\t\t\tif (tempPath == null || tempPath.size() == 0) {\n\t\t\t\t\tfor (Coordinate coord : control.hazardsMap.keySet()) {\n\t\t\t\t\t\ttempHazards.remove(coord);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// If it's a valid map, there should be a path now\n\t\t\t\tcontrol.setPath(control.findPath(currPos, control.finish.get(0), tempHazards));\n\t\n\t\t\t\tcontrol.isHeadingToFinish = true;\n\t\t\t}\n\t\t}\n\t\t\n\t\theadTowardsPackages(currPos);\n\t\t\n\t\texploreUnseenMap(currPos);\n\t\t\n\t\tMapTile currTile = control.getView().get(currPos);\n\t\tboolean isHealth = false;\n\t\tif (currTile.getType() == MapTile.Type.TRAP) {\n\t\t\tTrapTile trap = (TrapTile) currTile;\n\t\t\tif (trap.getTrap().equals(\"health\")) {\n\t\t\t\tisHealth = true;\n\t\t\t}\n\t\t}\n\t\tif (isHealth && (control.getHealth() < HEALTH_TRAP_THRESHOLD)) {\n\t\t\t// do nothing\n\t\t\treturn;\n\t\t} else {\n\t\t\tisHealth = false;\n\t\t\tcontrol.moveTowards(control.dest);\n\t\t}\n\t\t\n\t}", "public int moveN(int row, int col, int player){\n int numOfMatches = player == 1 ? 1 : -1;\n\n rows[row] += numOfMatches;\n cols[col] += numOfMatches;\n\n if(col == row)\n dc1 += numOfMatches;\n\n if(col == n-1-row)\n dc2 += numOfMatches;\n\n if(Math.abs(rows[row]) == n || Math.abs(cols[col]) == n || dc1 == n || dc2 == n)\n return player;\n\n return 0; // draw\n }", "private Action doNextMove(Action move){\n\t\t// update east or north\n\t\tif (move == Action.East){\n\t\t\teast++;\n\t\t} else if (move == Action.West){\n\t\t\teast--;\n\t\t} else if (move == Action.North){\n\t\t\tnorth++;\n\t\t} else if (move == Action.South){\n\t\t\tnorth--;\n\t\t}\n\t\treturn move;\n\t}", "public synchronized String Move(Coordinates step) {\n // check if player won't go over the grid\n if (step.getKey() + coord.getKey() < 0 || step.getKey() + coord.getKey() > sizeSide) {\n System.out.println(\"You can't go out of x bounds, retry\");\n return null;\n }\n else if (step.getValue() + coord.getValue() < 0 || step.getValue() + coord.getValue() > sizeSide) {\n System.out.println(\"You can't go out of y bounds, retry\");\n return null;\n }\n else {\n coord = new Coordinates(coord.getKey() + step.getKey(), coord.getValue() + step.getValue());\n return \"ok\";\n }\n }", "public boolean move(ChessBoard n, int a, int b, int c, int d) throws OutOfBoardException, PathwayException {\n if(!n.getPiece(c,d).getSymbol().equals(\"--- \")){\n System.out.println(\"KING: (\" + a + \",\" + b + \") (\" + c + \",\" + d + \")\");\n System.out.println(\"Invalid Move.(\" + a + \",\" + b + \") (\" + c + \",\" + d + \") Another Piece is in the way.\");\n System.out.println(\"=======================================\");\n System.out.println(n);\n throw new PathwayException();\n }\n //CHECKS TO SEE IF IT IS OUT OF BOARD\n if (c >= 8 || d >= 8) {\n tof = false;\n System.out.println(\"King: (\" + a + \",\" + b + \") (\" + c + \",\" + d + \")\");\n System.out.println(\"Invalid Move.(\" + a + \",\" + b + \") (\" + c + \",\" + d + \") Out of Board. \");\n System.out.println(\"=======================================\");\n System.out.println(n);\n throw new OutOfBoardException();\n } else if (c == a + 1 || c == a - 1 && d == b + 1 || d == b - 1) {\n tof = true;\n } else {\n tof = false;\n }\n return tof;\n }", "protected void applyResult() {\n\t\tList<Move> moves = new ArrayList<Move>();\n\t\tMove move = null;\n\t\tPartition partition = this.getPartitioner().getPartition();\n\t File resultFile = new File(this.getHMetisOutFile());\n\t Map<Integer, PTNetlistNode> integerVertexMap = this.getIntegerVertexMap();\n\t Reader resultReader = null;\n\t\t// Create File Reader\n\t\ttry {\n\t\t\tresultReader = new FileReader(resultFile);\n\t\t} catch (FileNotFoundException e) {\n\t\t\tthrow new RuntimeException(\"Error with file: \" + resultFile);\n\t\t}\n\t\t// Read and assign move\n\t\tBufferedReader resultBufferedReader = new BufferedReader(resultReader);\n\t\ttry {\n\t\t\tString line = null;\n\t\t\tint i = 1;\n\t\t\twhile ((line = resultBufferedReader.readLine()) != null) {\n\t\t\t\tPTNetlistNode ptnode = integerVertexMap.get(i);\n\t\t\t\tint blockIdx = Utils.getInteger(line.trim());\n\t\t\t\tBlock block = partition.getBlockAtIdx(blockIdx);\n\t\t\t\tmove = new Move(ptnode, ptnode.getMyBlock(), block);\n\t\t\t\tmoves.add(move);\n\t\t\t\ti++;\n\t\t\t}\n\t\t} catch (IOException e) {\n\t\t\tthrow new RuntimeException(\"Error with file: \" + resultFile);\n\t\t}\n\t\t// close\n\t try {\n\t \tresultReader.close();\n\t\t} catch (IOException e) {\n\t\t\tthrow new RuntimeException(\"Error with file: \" + resultFile);\n\t\t}\n\t // do moves\n\t partition.doMoves(moves);\n\t}", "private void moveAllignedMhos() {\n\n\t\t//Assign playerX and playerY to the X and Y of the player\n\t\tint playerX = getNewPlayerLocation()[0];\n\t\tint playerY = getNewPlayerLocation()[1];\n\n\t\t//Iterate through every mho's X and Y values\n\t\tfor(int i = 0; i < mhoLocations.size()/2; i++) {\n\n\t\t\t//Assign mhoX and mhoY to the X and Y values of the mho that is currently being tested\n\t\t\tint mhoX = mhoLocations.get(i*2);\n\t\t\tint mhoY = mhoLocations.get(i*2+1);\n\n\t\t\t//set the default X and Y offsets to 0, and the move to NO_MOVEMENT\n\t\t\tint xOffset = 0;\n\t\t\tint yOffset = 0;\n\t\t\tchar move = Legend.NO_MOVEMENT;\n\n\t\t\t//Check if the playerX is equal to mhoX (aligned on x-axis)\n\t\t\tif(playerX == mhoX) {\n\n\t\t\t\t//Check which direction the mho would have to move, and assign the corresponding move and yOffset\n\t\t\t\tif(playerY > mhoY) {\n\t\t\t\t\tyOffset = 1;\n\t\t\t\t\tmove = Legend.DOWN;\n\t\t\t\t} else {\n\t\t\t\t\tyOffset = -1;\n\t\t\t\t\tmove = Legend.UP;\n\t\t\t\t}\n\t\t\t} else if(playerY == mhoY) {\n\n\t\t\t\t//Check which direction the mho would have to move, and assign the corresponding move and XOffset\n\t\t\t\tif(playerX > mhoX) {\n\t\t\t\t\txOffset = 1;\n\t\t\t\t\tmove = Legend.RIGHT;\n\t\t\t\t} else {\n\t\t\t\t\txOffset = -1;\n\t\t\t\t\tmove = Legend.LEFT;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//Only move if the new location is not an instance of mho (in order to make sure they are moved in the right order)\n\t\t\tif(!(newMap[mhoX+xOffset][mhoY+yOffset] instanceof Mho)) {\n\n\t\t\t\t//Set the previous location to a BlankSpace\n\t\t\t\tnewMap[mhoX][mhoY] = new BlankSpace(mhoX, mhoY, board);\n\n\t\t\t\t//If the new square would be a player, end the game\n\t\t\t\tif(newMap[mhoX+xOffset][mhoY+yOffset] instanceof Player) {\n\t\t\t\t\tmoveList[mhoX+xOffset][mhoY+yOffset] = Legend.SHRINK;\n\t\t\t\t\tgameOver();\n\t\t\t\t}\n\n\t\t\t\t//If the new square would be a fence, remove the mho from the map\n\t\t\t\tif(!(newMap[mhoX+xOffset][mhoY+yOffset] instanceof Fence)) {\n\t\t\t\t\tnewMap[mhoX+xOffset][mhoY+yOffset] = new Mho(mhoX+xOffset, mhoY+yOffset, board);\n\t\t\t\t} else {\n\t\t\t\t\tmove = Legend.SHRINK;\n\t\t\t\t}\n\n\t\t\t\t//Set the move of the mho on moveList\n\t\t\t\tmoveList[mhoX][mhoY] = move;\n\n\t\t\t\t//remove the mhoX and mhoY in mhoLocations\n\t\t\t\tmhoLocations.remove(i*2+1);\n\t\t\t\tmhoLocations.remove(i*2);\n\n\t\t\t\t//Call moveAllignedMhos() again, because the list failed to be checked through completely\n\t\t\t\tmoveAllignedMhos();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}", "protected void move()\n {\n // Find a location to move to.\n Debug.print(\"Fish \" + toString() + \" attempting to move. \");\n Location nextLoc = nextLocation();\n\n // If the next location is different, move there.\n if ( ! nextLoc.equals(location()) )\n {\n // Move to new location.\n Location oldLoc = location();\n changeLocation(nextLoc);\n\n // Update direction in case fish had to turn to move.\n Direction newDir = environment().getDirection(oldLoc, nextLoc);\n changeDirection(newDir);\n Debug.println(\" Moves to \" + location() + direction());\n }\n else\n Debug.println(\" Does not move.\");\n }", "public boolean playerMove(Character token, int dice){\n\n\t\tPlayers player = searchBox(token, 0, 0, 0).getPlayers().get(0);\n\t\tplayer.setCurrentBox(player.getCurrentBox() + dice);\n\t\t\n\t\tif(player.getCurrentBox() == colums*rows){\n\t\t\tplayer.setMovement(player.getMovement() + 1);\n\t\t\treturn true;\n\n\t\t}else if(player.getCurrentBox() > colums*rows){\n\t\t\tint difference = colums*rows - (player.getCurrentBox() - dice);\n\t\t\tgetBoxs().get(searchPosition(player.getCurrentBox() - dice, 0)).getPlayers().remove(0);\n\t\t\tplayer.setCurrentBox(colums*rows);\n\t\t\tgetBoxs().get(colums*rows - colums).getPlayers().add(player);\n\n\t\t\tif(dice - difference == colums*rows){\n\t\t\t\treturn playerMove(token, (colums*rows - 1) * (-1));\n\n\t\t\t}else{\n\t\t\t\treturn playerMove(token, (dice - difference) * (-1));\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t}else{\n\n\t\t\tint index = searchPosition(player.getCurrentBox(), 0);\n\t\t\tsearchBox(token, 0, 0, 0).getPlayers().remove(0);\n\t\t\tplayer.setMovement(player.getMovement() + 1);\n\n\t\t\tif(getBoxs().get(index).getTypeAction()){\n\t\t\t\tplayer.setCurrentBox(getBoxs().get(getBoxs().get(index).getSendTo()).getNumBoxInt());\n\t\t\t\tgetBoxs().get(getBoxs().get(index).getSendTo()).getPlayers().add(player);\n\t\t\t\tSystem.out.println(\"*. El jugador cayo en una casilla especial por ende su ficha queda en: \" + player.getCurrentBox());\n\t\t\t}else{\n\t\t\t\tgetBoxs().get(index).getPlayers().add(player);\n\t\t\t\n\t\t\t}\n\n\t\t\treturn false;\n\t\t}\n\t\t\n\n\t}", "@Test\n public void moreThanOneCheckerOnToLocation() {\n\n assertTrue(game.move(Location.R1, Location.R2));\n assertTrue(game.move(Location.R1, Location.R3));\n game.nextTurn();\n // to der gerne skulle vaere lovlige og stemme med terningerne\n assertTrue(game.move(Location.R6, Location.R5));\n assertTrue(game.move(Location.R8, Location.R6));\n game.nextTurn();\n assertTrue(game.move(Location.R2, Location.R5));\n assertTrue(game.move(Location.R3, Location.R7));\n game.nextTurn();\n // der staar nu to sorte paa R4\n assertFalse(game.move(Location.R6, Location.R3));\n }", "@Test\n\tpublic void testIfForbriddenSelfKillAdvanced(){\n\t\tboard.commitMove(new Point(2,1), 1);\n\t\tboard.commitMove(new Point(3,1), 1);\n\t\tboard.commitMove(new Point(4,2), 1);\n\t\tboard.commitMove(new Point(3,3), 1);\n\t\tboard.commitMove(new Point(3,4), 1);\n\t\tboard.commitMove(new Point(2,5), 1);\n\t\tboard.commitMove(new Point(1,4), 1);\n\t\tboard.commitMove(new Point(1,3), 1);\n\t\tboard.commitMove(new Point(1,2), 1);\n\t\t\n\t\tboard.commitMove(new Point(2,4), 0);\n\t\tboard.commitMove(new Point(2,3), 0);\n\t\tassertEquals(0, board.commitMove(new Point(2,2), 0));\n\t\tassertNotEquals(0,board.commitMove(new Point(3,2), 0));\n//\t\tboard.printBoard();\n\t}", "public void findValidMoveDirections(){\n\t\t\n\t\tif(currentTile == 2 && (tileRotation == 0 || tileRotation == 180)){ // in vertical I configuration\n\t\t\tcanMoveNorth = true; canMoveSouth = true;\n\t\t\tcanMoveEast = false; canMoveWest = false;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" N,S: T E,W: F\");\n\t\t}\n\t\telse if(currentTile == 2 && (tileRotation == 90 || tileRotation == 270)){ // in horizontal I configuration\n\t\t\tcanMoveNorth = false; canMoveSouth = false;\n\t\t\tcanMoveEast = true; canMoveWest = true;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" N,S: F E,W: T\");\n\t\t}\n\t\t\n\t\t\n\t\telse if(currentTile == 3 && tileRotation == 0){ // L rotated 0 degrees\n\t\t\tcanMoveNorth = true; canMoveSouth = false;\n\t\t\tcanMoveEast = true; canMoveWest = false;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" N,E: T S,W: F\");\n\t\t}\n\t\telse if(currentTile == 3 && tileRotation == 90){ // L rotated 90 degrees\n\t\t\tcanMoveNorth = true; canMoveSouth = false;\n\t\t\tcanMoveEast = false; canMoveWest = true;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" N,W: T S,E: F\");\n\t\t}\n\t\telse if(currentTile == 3 && tileRotation == 180){ // L rotated 180 degrees\n\t\t\tcanMoveNorth = false; canMoveSouth = true;\n\t\t\tcanMoveEast = false; canMoveWest = true;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" S,W: T N,E: F\");\n\t\t}\n\t\telse if(currentTile == 3 && tileRotation == 270){ // L rotated 270 degrees\n\t\t\tcanMoveNorth = false; canMoveSouth = true;\n\t\t\tcanMoveEast = true; canMoveWest = false;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" S,E: T N,W: F\");\n\t\t}\n\t\t\n\t\t\n\t\telse if(currentTile == 4 && tileRotation == 0){ // T rotated 0 degrees\n\t\t\tcanMoveNorth = false; canMoveSouth = true;\n\t\t\tcanMoveEast = true; canMoveWest = true;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" S,W,E: T N: F\");\n\t\t}\n\t\telse if(currentTile == 4 && tileRotation == 90){ // T rotated 90 degrees\n\t\t\tcanMoveNorth = true; canMoveSouth = true;\n\t\t\tcanMoveEast = true; canMoveWest = false;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" N,S,E: T W: F\");\n\t\t}\n\t\telse if(currentTile == 4 && tileRotation == 180){ // T rotated 180 degrees\n\t\t\tcanMoveNorth = true; canMoveSouth = false;\n\t\t\tcanMoveEast = true; canMoveWest = true;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" N,W,E: T S: F\");\n\t\t}\n\t\telse if(currentTile == 4 && tileRotation == 270){ // T rotated 270 degrees\n\t\t\tcanMoveNorth = true; canMoveSouth = true;\n\t\t\tcanMoveEast = false; canMoveWest = true;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" N,S,W: T E: F\");\n\t\t}\n\t\telse if(currentTile == 5){ //in plus tile\n\t\t\tcanMoveNorth = true; canMoveSouth = true;\n\t\t\tcanMoveEast = true; canMoveWest = true;\n//\t\t\tSystem.out.println(\"Current Tile: \" + currentTile + \" Rotatation: \" + tileRotation +\n//\t\t\t\t\t\" N,S,W,E: T\");\n\t\t}\n\t\t\n\t}", "public void move() {\r\n if(direction == 1) {\r\n if(userRow < grid.getNumRows() - 1) {\r\n userRow++;\r\n handleCollision(userRow, 1);\r\n }\r\n } else if(direction == -1) {\r\n if(userRow > 0) {\r\n userRow--;\r\n handleCollision(userRow, 1);\r\n }\r\n }\r\n }", "public void move() {\n\t\tsetHealth(getHealth() - 1);\n\t\t//status();\n\t\tint row = getPosition().getRow() ;\n\t\tint column = getPosition().getColumn();\n\t\tint randomInt = (int)((Math.random()*2) - 1);\n\t\t\n\t\tif(hunter == false && row < 33) {\n\t\t\tif(row == 32) {\n\t\t\t\tgetPosition().setCoordinates(row -1 , randomInt);\n\t\t\t\tsetPosition(getPosition()) ;\n\t\t\t}\n\t\t\tif(row == 0) {\n\t\t\t\tgetPosition().setCoordinates(row + 1 , randomInt);\n\t\t\t\tsetPosition(getPosition()) ;\n\t\t\t}\n\t\t\tif(column == 99) {\n\t\t\t\tgetPosition().setCoordinates(randomInt , column - 1);\n\t\t\t\tsetPosition(getPosition()) ;\n\t\t\t}\n\t\t\tif(column == 0) {\n\t\t\t\tgetPosition().setCoordinates(randomInt , column + 1);\n\t\t\t\tsetPosition(getPosition()) ;\n\t\t\t}\n\t\t}\n\t\tif(hunter == false && row > 32) {\n\t\t\t//setHealth(100);\n\t\t\tgetPosition().setCoordinates(row -1 , randomInt);\n\t\t\tsetPosition(getPosition()) ;\n\t\t}\n\t\telse {\n\t\t\tif(row < 65 && hunter == true) {\n\t\t\t\tgetPosition().setCoordinates(row + 1, column);\n\t\t\t\tsetPosition(getPosition()) ;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tgetPosition().setCoordinates(65, column);\n\t\t\t\tsetPosition(getPosition());\n\t\t\t\t//Check if there is a gazelle\n\t\t\t\tPair [][] range = {{Drawer.pairs[row+1][column-1],Drawer.pairs[row+1][column],\n\t\t\t\t\t\t\t Drawer.pairs[row+1][column+1]}, {\n\t\t\t\t\t\t\t Drawer.pairs[row+2][column-1],\n\t\t\t\t\t\t\t Drawer.pairs[row+2][column],Drawer.pairs[row+2][column+1]}};\n\t\t\t\t\n\t\t\t\tfor(Pair [] line: range) {\n\t\t\t\t\tfor(Pair prey: line) {\n\t\t\t\t\t\tif(prey.getAnimal() instanceof Gazelle ) {\n\t\t\t\t\t\t\tattack();\n\t\t\t\t\t\t\tprey.getAnimal().die();\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "private static void determineFinalRanks(Fold fold, ParametersManager params) {\n for (int currRank = fold.getNumInst(); currRank >= 1; currRank--) {\n Instance instSmallestWeight = fold.getInstSmallestWeight(); // selects the next less important instance\n\n instSmallestWeight.setRank(currRank); // ranks the instance by its order of elimination\n instSmallestWeight.setWeight(Double.POSITIVE_INFINITY); // the instance will be disregarded from now\n\n // removes the traces of the ranked instance out of the other instances\n fold.clearInstTraces(instSmallestWeight);\n\n /* For instances with rank value smaller than the number of neighbors, the relative position in the ranking\n is irrelevant (and, by construction, impossible to determine). Therefore, only the first steps of the\n ranking are performed for these instances. */\n if (currRank <= params.getNumNeighbors()) continue;\n\n // updates the distances matrix, setting the distance to or from the ranked instance to infinite\n fold.updateDistMatrix(instSmallestWeight.getId());\n\n // updates the weights of instances that had the eliminated instance among its nearest neighbors\n InstanceWeighting.updateAssociatesWeights(fold, instSmallestWeight, params);\n }\n }", "private void endTurn() {\n\t\t\n\t\tif (roundChanger == 1) {\n\t\t\tString currentPlayer = textFieldCurrentPlayer.getText();\n\t\t\tif (currentPlayer.equals(\"Player1\")) {\n\t\t\t\ttextAreaInstructions.setText(\"The current roll to beat is \" + player1.getDie1()\n\t\t\t\t+ \" \" + player1.getDie2() + \" \" + player1.getDie3());\n\t\t\t\trollToBeat = \"The current roll to beat is \" + player1.getDie1()\n\t\t\t\t+ \" \" + player1.getDie2() + \" \" + player1.getDie3();\n\t\t\t} else {\n\t\t\t\ttextAreaInstructions.setText(\"The current roll to beat is \" + player2.getDie1()\n\t\t\t\t+ \" \" + player2.getDie2() + \" \" + player2.getDie3());\n\t\t\t\trollToBeat = \"The current roll to beat is \" + player2.getDie1()\n\t\t\t\t+ \" \" + player2.getDie2() + \" \" + player2.getDie3();\n\t\t\t} \n\t\t\tchangeCurrentPlayerText();\n\t\t\tturn = 0;\n\t\t\troundChanger = 2;\n\t\t} else {\n\t\t\tString winningPlayer = calculateScore(player1, player2);\n\t\t\ttextFieldCurrentPlayer.setText(winningPlayer);\n\t\t\troundChanger = 1;\n\t\t\trollsTaken = 0;\n\t\t\tround = round + 1;\n\t\t\ttextFieldPlayerOneScore.setText(Integer.toString(player1.getPoints()));\n\t\t\ttextFieldPlayerTwoScore.setText(Integer.toString(player2.getPoints()));\n\t\t\ttextAreaInstructions.setText(\"Try to get the highest roll possible!\");\n\t\t\tcheckForGameOver();\n\t\t}\n\t\ttogglebtnD1.setSelected(false);\n\t\ttogglebtnD2.setSelected(false);\n\t\ttogglebtnD3.setSelected(false);\n\t\tdisableDice();\n\t\tturn = 0;\n\t}", "@Override\r\n\tpublic void move() {\n\t\tPoint target = strategy.search(this.getLocation(), new Point(0,0));\r\n\r\n\t\tint tries = 0;\r\n\t\t\r\n\t\twhile(!state.equals(\"Inactive\") && !game.movement(this, target.x, target.y)){\r\n\t\t\ttarget = strategy.search(new Point(x,y),playerLocation);\r\n\t\t\ttries++;\r\n\t\t\tif(tries > 4) return; // the search strategy has 4 tries to pick a valid location to move to\r\n\t\t}\r\n\t\t\r\n\t\tx = target.x;\r\n\t\ty = target.y;\r\n\r\n\t\tmoveSprite();\r\n\t}", "public void move() {\n\t\tif (isLuck) {\n\t\t\tif (rand.nextBoolean()) {\n\t\t\t\txPos++;\n\t\t\t}\n\t\t} else {\n\t\t\tif (rightCount < skill) {\n\t\t\t\trightCount++;\n\t\t\t\txPos++;\n\t\t\t}\n\t\t}\n\t}" ]
[ "0.5987757", "0.5845264", "0.5813729", "0.5800495", "0.5791907", "0.57259154", "0.5667936", "0.5638839", "0.5562458", "0.5562142", "0.5519372", "0.5504364", "0.55004394", "0.549855", "0.54957503", "0.5470248", "0.54677606", "0.54582494", "0.54350656", "0.54247165", "0.5415706", "0.5394163", "0.53936815", "0.5388661", "0.53784806", "0.5368691", "0.5367335", "0.53426814", "0.5337387", "0.53292865", "0.532846", "0.5316209", "0.5310889", "0.5300481", "0.5291088", "0.52791625", "0.5271983", "0.52568007", "0.52520216", "0.52471596", "0.5237089", "0.5235629", "0.52267516", "0.52179766", "0.5214719", "0.5212917", "0.520809", "0.52048504", "0.52029115", "0.5198295", "0.5198003", "0.51941955", "0.51920277", "0.5188927", "0.51781714", "0.51769024", "0.5174393", "0.51725805", "0.5172218", "0.5166554", "0.515679", "0.5152702", "0.51493037", "0.51486367", "0.5146692", "0.5144923", "0.51398355", "0.51396984", "0.5138661", "0.5132104", "0.512981", "0.5127054", "0.51243865", "0.5121796", "0.51188993", "0.51188064", "0.5115897", "0.51146126", "0.5113615", "0.51133764", "0.5112293", "0.510916", "0.5107199", "0.51009446", "0.5099394", "0.5097673", "0.50965774", "0.50953513", "0.50944996", "0.5091876", "0.50821435", "0.5078255", "0.50731474", "0.50718343", "0.5071048", "0.5069138", "0.50676614", "0.50666946", "0.5065822", "0.5065134", "0.50556433" ]
0.0
-1
Handle the movement of bishops. Determine if the bishop to be moved is dark squared or light squared using modulo on the end square and find the bishop that matches.
public static int[] getBishopStart(int[][] piecePos, int endFile, int endRank) { int bishopColor = (endFile + endRank) % 2; for (int[] pos: piecePos) { if ((pos[0] + pos[1]) % 2 == bishopColor) { if (endFile - pos[0] != 0 && endRank - pos[1] != 0) { int fDir = (endFile - pos[0]) / Math.abs(endFile - pos[0]); int rDir = (endRank - pos[1]) / Math.abs(endRank - pos[1]); boolean correct = true; if (Math.abs(pos[0] - endFile) != Math.abs( pos[1] - endRank)) { continue; } if (Math.abs(pos[0] - endFile) - 1 != 0) { for (int i = 0; i < Math.abs(pos[0] - endFile) - 1; i++) { int file = Math.abs(i + fDir * pos[0] + 1); int rank = Math.abs(i + rDir * pos[1] + 1); if (!getBoardStateSquare(file, rank).equals(" ")) { correct = false; } } } if (correct) { int[] startPos = {pos[0], pos[1]}; if (isLegalMove(startPos, endFile, endRank)) { return startPos; } } } } } return null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public int[][] getMovesBishop(Piece p) {\n x = p.getX();\n y = p.getY();\n int legalMoves[][] = new int[8][8];\n\n for (int i = 1; i < 8; i++) {//Traversing from piece coords, right till end of board.\n if ((x + i) < 8 && (y + i) < 8) {\n if (b.getPieceAt((y + i), (x + i)) != null) {\n if (p.isWhite() == b.getPieceAt((y + i), (x + i)).isWhite()) {\n break;\n } else {\n legalMoves[(y + i)][(x + i)] = 1;\n break;\n }\n } else {\n legalMoves[(y + i)][(x + i)] = 1;\n }\n }\n }\n for (int i = 1; i < 8; i++) {\n if ((x - i) > -1 && (y + i) < 8) {\n if (b.getPieceAt((y + i), (x - i)) != null) {\n if (p.isWhite() == b.getPieceAt((y + i), (x - i)).isWhite()) {\n break;\n } else {\n legalMoves[(y + i)][(x - i)] = 1;\n break;\n }\n } else {\n legalMoves[(y + i)][(x - i)] = 1;\n }\n }\n }\n\n for (int i = 1; i < 8; i++) {\n\n if ((x - i) > -1 && (y - i) > -1) {\n if (b.getPieceAt((y - i), (x - i)) != null) {\n if (p.isWhite() == b.getPieceAt((y - i), (x - i)).isWhite()) {\n break;\n } else {\n legalMoves[(y - i)][(x - i)] = 1;\n break;\n }\n } else {\n legalMoves[(y - i)][(x - i)] = 1;\n }\n }\n }\n\n for (int i = 1; i < 8; i++) {\n\n if ((x + i) < 8 && (y - i) > -1) {\n if (b.getPieceAt((y - i), (x + i)) != null) {\n if (p.isWhite() == b.getPieceAt((y - i), (x + i)).isWhite()) {\n break;\n } else {\n legalMoves[(y - i)][(x + i)] = 1;\n break;\n }\n } else {\n legalMoves[(y - i)][(x + i)] = 1;\n }\n }\n }\n return legalMoves;\n }", "@Override\n public boolean checkForScoringCondition(BotState botState) {\n Location botLocation = new Location(botState.x, botState.y);\n for (var ballLocation: ballLocations) {\n if (botLocation.getDistance(ballLocation) < SCORING_DISTANCE) {\n // The robot picked up the ball!\n logger.info(\"FOUND A BALL BOT=\"+botLocation+\" ball=\"+ballLocation);\n ballLocations.remove(ballLocation);\n return true;\n }\n }\n return false;\n }", "boolean attack(int sq, int s) {\n\tlong attackSq = (1L << sq);\n\tif (s == LIGHT) {\n\tlong moves = ((pawnBits[LIGHT] & 0x00fefefefefefefeL) >> 9)\n\t& attackSq;\n\tif (moves != 0)\n\treturn true;\n\tmoves = ((pawnBits[LIGHT] & 0x007f7f7f7f7f7f7fL) >> 7) & attackSq;\n\tif (moves != 0)\n\treturn true;\n\t} else {\n\tlong moves = ((pawnBits[DARK] & 0x00fefefefefefefeL) << 7)\n\t& attackSq;\n\tif (moves != 0)\n\treturn true;\n\tmoves = ((pawnBits[DARK] & 0x007f7f7f7f7f7f7fL) << 9) & attackSq;\n\tif (moves != 0)\n\treturn true;\n\t}\n\tlong pieces = pieceBits[s] ^ pawnBits[s];\n\twhile (pieces != 0) {\n\tint i = getLBit(pieces);\n\tint p = piece[i];\n\tfor (int j = 0; j < offsets[p]; ++j)\n\tfor (int n = i;;) {\n\tn = mailbox[mailbox64[n] + offset[p][j]];\n\tif (n == -1)\n\tbreak;\n\tif (n == sq)\n\treturn true;\n\tif (color[n] != EMPTY)\n\tbreak;\n\tif (!slide[p])\n\tbreak;\n\t}\n\tpieces &= (pieces - 1);\n\t}\n\treturn false;\n\t}", "public void moveBlueCrab() {\n\t\tloseLife();\n\t\tif (wallOverlapX()) {\n\t\t\tif (hitRight) {\n\t\t\t\tif (xVel > 0) {\n\t\t\t\t\tyPos += yVel;\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\txPos += xVel;\n\t\t\t\t\tyPos += yVel;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else if (hitLeft) {\n\t\t\t\tif (xVel < 0) {\n\t\t\t\t\tyPos += yVel;\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\txPos += xVel;\n\t\t\t\t\tyPos += yVel;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (wallOverlapY()) {\n\t\t\tif (hitUp) {\n\t\t\t\tif (yVel < 0) {\n\t\t\t\t\txPos += xVel;\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\txPos += xVel;\n\t\t\t\t\tyPos += yVel;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else if (hitDown) {\n\t\t\t\tif (yVel > 0) {\n\t\t\t\t\txPos += xVel;\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\txPos += xVel;\n\t\t\t\t\tyPos += yVel;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tint xLow = xPos;\n\t\tint xHigh =xPos + width;\n\t\tint yTop = yPos;\n\t\tint yBot = yPos + height;\n\t\tfor (int i = 0; i < game.m.walls.size(); i++) {\n\t\t\tif (game.m.walls.get(i).wallHit(this) > 0) {\n//\t\t\t\twhile (game.m.walls.get(i).wallHit(this)) {\n\t\t\t\tif (game.m.walls.get(i).wallHit(this) == 4) {\n\t\t\t\t\tif (yVel < 0) {\n\t\t\t\t\t\tyPos += yVel;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t} \n\t\t\t\t\telse {\n\t\t\t\t\t\tfor (int j = 0; j < game.m.walls.size(); j++) {\n\t\t\t\t\t\t\tif (game.m.walls.get(j).wallHit(this) == 1) {\n\t\t\t\t\t\t\t\tif (xVel > 0) {\n\t\t\t\t\t\t\t\t\txPos += xVel;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (int j = 0; j < game.m.walls.size(); j++) {\n\t\t\t\t\t\t\tif (game.m.walls.get(j).wallHit(this) == 2) {\n\t\t\t\t\t\t\t\tif (xVel < 0) {\n\t\t\t\t\t\t\t\t\txPos += xVel;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\txPos += xVel;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (game.m.walls.get(i).wallHit(this) == 3) {\n\t\t\t\t\tif (yVel > 0) {\n\t\t\t\t\t\tyPos += yVel;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t} \n\t\t\t\t\telse {\n\t\t\t\t\t\tfor (int j = 0; j < game.m.walls.size(); j++) {\n\t\t\t\t\t\t\tif (game.m.walls.get(j).wallHit(this) == 1) {\n\t\t\t\t\t\t\t\tif (xVel > 0) {\n\t\t\t\t\t\t\t\t\txPos += xVel;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (int j = 0; j < game.m.walls.size(); j++) {\n\t\t\t\t\t\t\tif (game.m.walls.get(j).wallHit(this) == 2) {\n\t\t\t\t\t\t\t\tif (xVel < 0) {\n\t\t\t\t\t\t\t\t\txPos += xVel;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\txPos += xVel;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (game.m.walls.get(i).wallHit(this) == 2) {\n\t\t\t\t\tif (xVel < 0) {\n\t\t\t\t\t\txPos += xVel;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t} \n\t\t\t\t\telse {\n\t\t\t\t\t\tfor (int j = 0; j < game.m.walls.size(); j++) {\n\t\t\t\t\t\t\tif (game.m.walls.get(j).wallHit(this) == 3) {\n\t\t\t\t\t\t\t\tif (yVel > 0) {\n\t\t\t\t\t\t\t\t\tyPos += yVel;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (int j = 0; j < game.m.walls.size(); j++) {\n\t\t\t\t\t\t\tif (game.m.walls.get(j).wallHit(this) == 4) {\n\t\t\t\t\t\t\t\tif (yVel < 0) {\n\t\t\t\t\t\t\t\t\tyPos += yVel;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tyPos += yVel;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (game.m.walls.get(i).wallHit(this) == 1) {\n\t\t\t\t\tif (xVel > 0) {\n\t\t\t\t\t\txPos += xVel;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t} \n\t\t\t\t\telse {\n\t\t\t\t\t\tfor (int j = 0; j < game.m.walls.size(); j++) {\n\t\t\t\t\t\t\tif (game.m.walls.get(j).wallHit(this) == 3) {\n\t\t\t\t\t\t\t\tif (yVel > 0) {\n\t\t\t\t\t\t\t\t\tyPos += yVel;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (int j = 0; j < game.m.walls.size(); j++) {\n\t\t\t\t\t\t\tif (game.m.walls.get(j).wallHit(this) == 4) {\n\t\t\t\t\t\t\t\tif (yVel < 0) {\n\t\t\t\t\t\t\t\t\tyPos += yVel;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tyPos += yVel;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n//\t\t\t\tif (xVel > 0) {\n//\t\t\t\t\txPos -= 20;\n//\t\t\t\t\treturn;\n//\t\t\t\t} \n//\t\t\t\telse if (xVel < 0) {\n//\t\t\t\t\txPos += 20;\n//\t\t\t\t\treturn;\n//\t\t\t\t}\n//\t\t\t\tif (yVel > 0) {\n//\t\t\t\t\tyPos -= 20;\n//\t\t\t\t\treturn;\n//\t\t\t\t}\n//\t\t\t\telse if (yVel < 0) {\n//\t\t\t\t\tyPos += 20;\n//\t\t\t\t\treturn;\n//\t\t\t\t}\n//\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (xPos <= 0) {\n\t\t\tif (xVel > 0) {\n\t\t\t\txPos += xVel;\n\t\t\t} else if (yPos + height <= game.mapHeight && yPos >= 0){\n\t\t\t\tyPos += yVel;\n\t\t\t} else {\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else if (xPos + width >= game.mapWidth) {\n\t\t\tif (xVel < 0) {\n\t\t\t\txPos += xVel;\n\t\t\t} else if (yPos + height <= game.mapHeight && yPos >= 0){\n\t\t\t\tyPos += yVel;\n\t\t\t} else {\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else if (yPos <= 0) {\n\t\t\tif (yVel > 0) {\n\t\t\t\tyPos += yVel;\n\t\t\t} else if (xPos + width <= game.mapWidth && xPos >= 0){ \n\t\t\t\txPos += xVel;\n\t\t\t} else {\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else if (yPos + height >= game.mapHeight) { \n\t\t\tif (yVel < 0) {\n\t\t\t\tyPos += yVel;\n\t\t\t} else if (xPos + width <= game.mapWidth && xPos >= 0){\n\t\t\t\txPos += xVel;\n\t\t\t} else {\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else {\n\t\t\txPos += xVel;\n\t\t\tyPos += yVel;\n\t\t}\n\n\t}", "public boolean isValidMove(Location from, Location to, Piece[][]b) {\n\t\t// Bishop\n\t\tboolean pieceInWay = true;\n\t\tint direction =0; \n\t\tboolean finalLocation = false;\n\t\tboolean verticalUp = false, verticalDown = false, horizontalLeft = false, horizontalRight = false;\n\t\t\n\t\tif(to.getColumn()>from.getColumn() && to.getRow()<from.getRow()){\n\t\t\tdirection = 1;\n\t\t}\n\t\telse if (to.getColumn()<from.getColumn() && to.getRow()>from.getRow()){\n\t\t\tdirection = 2;\n\t\t}\n\t\telse if (to.getColumn()<from.getColumn() && to.getRow()<from.getRow()){\n\t\t\tdirection = 4;\n\t\t}\n\t\telse\n\t\t\tdirection = 3;\t\n\t\t\n\t\t\n\t\tif (Math.abs(from.getColumn() - to.getColumn()) == Math.abs(from.getRow() - to.getRow())\n\t\t\t\t&& b[to.getRow()][to.getColumn()].getPlayer() != getPlayer()\n\t\t\t\t&& !pieceInWay/*b[to.getRow()][to.getColumn()].getPlayer() == 0 b[from.getRow()+1][from.getColumn()+1]*/) {\n\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\t// Rook\n\n\t\t//This line checks to see if the final destination of the piece contains anything but a friendly piece. This is here, because\n\t\t//anything other than a friendly piece would make the move valid, given that every space in between is blank.\n\t\tif(b[to.getRow()][to.getColumn()].getPlayer() != b[from.getRow()][from.getColumn()].getPlayer())\n\t\t\tfinalLocation = true;\n\t\telse\n\t\t\tfinalLocation = false;\n\t\t\n\t\t//verticalUp\n\t\tif(from.getRow() == to.getRow() && from.getColumn() > to.getColumn()){\n\t\t\tverticalUp = true;\n\t\t\tfor(int i = to.getColumn(); i < from.getColumn() && verticalUp; i++){\n\t\t\t\tif(b[to.getRow()][i].getPlayer() == 0 && verticalUp){\n\t\t\t\t\tverticalUp = true;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tverticalUp = false;\n\t\t\t}\n\t\t}\n\t\t//verticalDown\n\t\telse if(from.getRow() == to.getRow() && from.getColumn() < to.getColumn()){\n\t\t\tverticalDown = true;\n\t\t\tfor(int i = from.getColumn(); i < to.getColumn() && verticalDown; i++){\n\t\t\t\tif(b[from.getRow()][i].getPlayer() == 0 && verticalDown){\n\t\t\t\t\tverticalDown = true;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tverticalDown = false;\n\t\t\t}\n\t\t}\n\t\t//horizontalLeft\n\t\telse if(from.getColumn() == to.getColumn() && from.getRow() > to.getRow()){\n\t\t\thorizontalLeft = true;\n\t\t\tfor(int i = to.getRow(); i < from.getRow() && horizontalLeft; i++){\n\t\t\t\tif(b[i][to.getColumn()].getPlayer() == 0 && horizontalLeft){\n\t\t\t\t\thorizontalLeft = true;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\thorizontalLeft = false;\n\t\t\t}\n\t\t}\n\t\t//horizontalRight\n\t\telse if(from.getColumn() == to.getColumn() && from.getRow() < to.getRow()){\n\t\t\thorizontalRight = true;\n\t\t\tfor(int i = from.getRow(); i < to.getRow() && horizontalRight; i++){\n\t\t\t\tif(b[i][from.getColumn()].getPlayer() == 0 && horizontalRight){\n\t\t\t\t\thorizontalRight = true;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\thorizontalRight = false;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(verticalUp || verticalDown || horizontalLeft || horizontalRight && finalLocation){\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\treturn false;\n\t}", "private Cell getSnowballTarget() {\n Cell[][] blocks = gameState.map;\n int mostWormInRange = 0;\n Cell chosenCell = null;\n\n for (int i = currentWorm.position.x - 5; i <= currentWorm.position.x + 5; i++) {\n for (int j = currentWorm.position.y - 5; j <= currentWorm.position.y + 5; j++) {\n if (isValidCoordinate(i, j)\n && euclideanDistance(i, j, currentWorm.position.x, currentWorm.position.y) <= 5) {\n List<Cell> affectedCells = getSurroundingCells(i, j);\n affectedCells.add(blocks[j][i]);\n int wormInRange = 0;\n for (Cell cell : affectedCells) {\n for (Worm enemyWorm : opponent.worms) {\n if (enemyWorm.position.x == cell.x && enemyWorm.position.y == cell.y\n && enemyWorm.roundsUntilUnfrozen == 0 && enemyWorm.health > 0)\n wormInRange++;\n }\n for (Worm myWorm : player.worms) {\n if (myWorm.position.x == cell.x && myWorm.position.y == cell.y && myWorm.health > 0)\n wormInRange = -5;\n }\n }\n if (wormInRange > mostWormInRange) {\n mostWormInRange = wormInRange;\n chosenCell = blocks[j][i];\n }\n }\n }\n }\n\n return chosenCell;\n }", "private boolean thereispath(Move m, Tile tile, Integer integer, Graph g, Board B) {\n\n boolean result = true;\n boolean result1 = true;\n\n int start_dest_C = tile.COLUMN;\n int start_dest_R = tile.ROW;\n\n int move_column = m.getX();\n int move_row = m.getY();\n\n int TEMP = 0;\n int TEMP_ID = 0;\n int TEMP_ID_F = tile.id;\n int TEMP_ID_FIRST = tile.id;\n\n int final_dest_R = (integer / B.width);\n int final_dest_C = (integer % B.width);\n\n //System.out.println(\"* \" + tile.toString() + \" \" + integer + \" \" + m.toString());\n\n // Y ROW - X COLUMN\n\n for (int i = 0; i != 2; i++) {\n\n TEMP_ID_FIRST = tile.id;\n\n // possibility 1\n if (i == 0) {\n\n\n // first move columns\n for (int c = 0; c != Math.abs(move_column) && result != false; c++) {\n\n if (c == 0) {\n TEMP_ID_FIRST = tile.id;\n\n } else {\n TEMP_ID_FIRST = B.a.get(start_dest_R).get(start_dest_C).id;\n\n }\n\n TEMP = move_column / Math.abs(move_column);\n\n //System.out.println(\"1C:\" + TEMP);\n\n //System.out.println(\" \" + TEMP_ID_FIRST + \" - > \" + (start_dest_C + TEMP));\n\n start_dest_C += TEMP;\n\n TEMP_ID = B.a.get(start_dest_R).get(start_dest_C).id;\n\n //System.out.println(TEMP_ID_FIRST + \" = \" + TEMP_ID);\n\n if (g.adj.get(TEMP_ID_FIRST).contains(TEMP_ID)) {\n\n // System.out.println(\"OK\");\n\n } else {\n\n result = false;\n\n // System.out.println(\"NOPE\");\n\n\n }\n }\n\n for (int r = 0; r != Math.abs(move_row) && result != false; r++) {\n\n TEMP_ID_FIRST = B.a.get(start_dest_R).get(start_dest_C).id;\n\n TEMP = move_row / Math.abs(move_row);\n\n //System.out.println(\"1R:\" + TEMP);\n\n //System.out.println(start_dest_R + \" - > \" + (start_dest_R + TEMP));\n\n start_dest_R += TEMP;\n\n TEMP_ID = B.a.get(start_dest_R).get(start_dest_C).id;\n\n // System.out.println(TEMP_ID_FIRST + \" and \" + TEMP_ID);\n\n if (g.adj.get(TEMP_ID_FIRST).contains(TEMP_ID)) {\n\n //System.out.println(\"OK\");\n\n\n } else {\n\n result = false;\n\n //System.out.println(\"NOPE\");\n\n\n }\n }\n\n if (result == true) {\n return true;\n }\n\n\n }\n\n TEMP_ID = 0;\n\n if (i == 1) {\n\n result = true;\n\n start_dest_C = tile.COLUMN;\n start_dest_R = tile.ROW;\n // first move row\n for (int r = 0; r != Math.abs(move_row) && result1 != false; r++) {\n\n if (r == 0) {\n TEMP_ID_FIRST = tile.id;\n\n } else {\n TEMP_ID_FIRST = B.a.get(start_dest_R).get(start_dest_C).id;\n\n }\n\n TEMP_ID_FIRST = B.a.get(start_dest_R).get(start_dest_C).id;\n\n TEMP = move_row / Math.abs(move_row);\n\n //System.out.println(\"1R:\" + TEMP);\n\n //System.out.println(start_dest_R + \" - > \" + (start_dest_R + TEMP));\n\n start_dest_R += TEMP;\n\n TEMP_ID = B.a.get(start_dest_R).get(start_dest_C).id;\n\n\n //System.out.println(TEMP_ID_FIRST + \" = \" + TEMP_ID);\n\n if (g.adj.get(TEMP_ID_FIRST).contains(TEMP_ID)) {\n\n //System.out.println(\"OK\");\n\n } else {\n\n //System.out.println(\"NOPE\");\n\n result = false;\n\n }\n\n\n }\n\n // first move columns\n for (int c = 0; c != Math.abs(move_column) && result1 != false; c++) {\n\n\n TEMP_ID_FIRST = B.a.get(start_dest_R).get(start_dest_C).id;\n\n TEMP = move_column / Math.abs(move_column);\n\n //System.out.println(\"1C:\" + TEMP);\n\n //System.out.println(\" \" + TEMP_ID_FIRST + \" - > \" + (start_dest_C + TEMP));\n\n start_dest_C += TEMP;\n\n TEMP_ID = B.a.get(start_dest_R).get(start_dest_C).id;\n\n //System.out.println(TEMP_ID_FIRST + \" and \" + TEMP_ID);\n\n if (g.adj.get(TEMP_ID_FIRST).contains(TEMP_ID)) {\n\n //System.out.println(\"OK\");\n\n } else {\n result = false;\n\n //System.out.println(\"NOPE\");\n\n\n }\n }\n\n if (result == false) {\n return false;\n\n }\n\n\n }\n\n\n }\n\n\n return true;\n }", "@Test\n public void testBishopPosition() {\n // initialize the complete chess board\n ChessBoard chessBoard = init(\"CHESS\");\n\n assertEquals(0, chessBoard.getPiece(0, 2).getRow());\n assertEquals(2, chessBoard.getPiece(0, 2).getColumn());\n\n assertEquals(0, chessBoard.getPiece(0, 5).getRow());\n assertEquals(5, chessBoard.getPiece(0, 5).getColumn());\n\n assertEquals(7, chessBoard.getPiece(7, 2).getRow());\n assertEquals(2, chessBoard.getPiece(7, 2).getColumn());\n\n assertEquals(7, chessBoard.getPiece(7, 5).getRow());\n assertEquals(5, chessBoard.getPiece(7, 5).getColumn());\n }", "public static void moveBalls() {\n\t\tfor (Ball b : Panel.balls) {\n\t\t\tif (b.getxPOS() + b.getxVelocity() < 410 || b.getxPOS() + b.getxVelocity() > (1200 - (b.getMass() * 7))) { //checking next frame for boundry collision\n\t\t\t\tb.setxVelocity(-b.getxVelocity());\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//reverseing velocity if true\n\t\t\t}\n\t\t\tif (b.getyPOS() + b.getyVelocity() < 0) {\n\t\t\t\tb.setyVelocity(-(b.getyVelocity()));\n\t\t\t}\n\t\t\tif (b.getyPOS() + b.getyVelocity() > (800 - (b.getMass() * 7)) - 22) { //on each collision with the floor, decrease the balls X and Y velocity\n\t\t\t\tb.setyVelocity(-(b.getyVelocity() - energyLost));\n\t\t\t\tif (Panel.tick % 7 == 0 && Panel.Gravity) {\n\t\t\t\t\tif (b.getxVelocity() < 0) {\n\t\t\t\t\t\tb.setxVelocity(b.getxVelocity() + 1);\n\t\t\t\t\t}\n\t\t\t\t\tif (b.getxVelocity() > 0) {\n\t\t\t\t\t\tb.setxVelocity(b.getxVelocity() - 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!(b.getyPOS() + b.getyVelocity() > (800 - (b.getMass() * 7)) - 22)) { //applying motion in the Y direction only if the ball is not resting on the floor\n\t\t\t\tb.setyPOS(b.getyPOS() + b.getyVelocity());\n\t\t\t}\n\t\t\telse {\n\t\t\t\tb.setyPOS((800 - (b.getMass() * 7)) - 22);\n\t\t\t}\n\t\t\t\n\t\t\tb.setxPOS(b.getxPOS() + b.getxVelocity()); //motion is always applied in the X direction\n\t\t}\n\t}", "@Test\n\tpublic void whenHorseMovedInRightDirectionThanDirectionCellFullOfHorse() {\n\t\tCell[][] cells = new Cell[8][8];\n\t\tfor (int x = 0; x < 8; x++) {\n\t\t\tfor (int y = 0; y < 8; y++) {\n\t\t\t\tcells[x][y] = new Cell(x, y);\n\t\t\t}\n\t\t}\n\t\tFigure[] figures = {new Horse(cells[4][4])};\n\t\tBoard board = new Board(cells, figures);\n\t\t// Horse moving downleft.\n\t\tboard.move(board.getCell(4, 4), board.getCell(3, 6));\n\t\tassertThat(figures[0].getPosition(), is(cells[3][6]));\n\t\t// Horse moving upright.\n\t\tboard.move(board.getCell(3, 6), board.getCell(4, 4));\n\t\tassertThat(figures[0].getPosition(), is(cells[4][4]));\n\t\t// Horse moving downright.\n\t\tboard.move(board.getCell(4, 4), board.getCell(5, 6));\n\t\tassertThat(figures[0].getPosition(), is(cells[5][6]));\n\t\t// Horse moving upleft.\n\t\tboard.move(board.getCell(5, 6), board.getCell(4, 4));\n\t\tassertThat(figures[0].getPosition(), is(cells[4][4]));\n\t\t// Horse moving leftdown.\n\t\tboard.move(board.getCell(4, 4), board.getCell(2, 5));\n\t\tassertThat(figures[0].getPosition(), is(cells[2][5]));\n\t\t// Horse moving rightup.\n\t\tboard.move(board.getCell(2, 5), board.getCell(4, 4));\n\t\tassertThat(figures[0].getPosition(), is(cells[4][4]));\n\t\t// Horse moving leftup.\n\t\tboard.move(board.getCell(4, 4), board.getCell(2, 3));\n\t\tassertThat(figures[0].getPosition(), is(cells[2][3]));\n\t\t// Horse moving rightdown.\n\t\tboard.move(board.getCell(2, 3), board.getCell(4, 4));\n\t\tassertThat(figures[0].getPosition(), is(cells[4][4]));\n\t}", "private boolean move (int x, int y, int xdirection, int ydirection, OthelloPiece colour){\n \n OthelloPiece otherColour;\n int xsearch = x + xdirection;\n int ysearch = y + ydirection;\n\n\n if (colour.getPieceColour() == Piece.OthelloPieceColour.WHITE){\n otherColour = BLACK_PIECE;\n \n }else{\n otherColour = WHITE_PIECE;\n \n }\n if(m_Pieces[x][y].getPieceColour()==Piece.OthelloPieceColour.NONE){\n \n if(onBoard(xsearch,ysearch)){\n if(m_Pieces[xsearch][ysearch].getPieceColour()==otherColour.getPieceColour()){\n while(onBoard(xsearch,ysearch)&& \n \tm_Pieces[xsearch][ysearch].getPieceColour()==otherColour.getPieceColour()){\n xsearch+=xdirection;\n ysearch+=ydirection;\n }\n \n if(onBoard(xsearch,ysearch)&&\n \tm_Pieces[xsearch][ysearch].getPieceColour()== colour.getPieceColour()){\n xsearch-=xdirection;\n ysearch-=ydirection;\n piecesToSwap[xsearch][ysearch]=colour;\n while(m_Pieces[xsearch][ysearch].getPieceColour()==otherColour.getPieceColour()){\n \n xsearch-=xdirection; \n ysearch-=ydirection;\n piecesToSwap[xsearch][ysearch]=colour; \n }\n return true;\n }\n }\n }\n }else{\n return false;\n }\n return false;\n\t}", "private int Block_Move() {\n\t\tfinal int POSSIBLE_BLOCK = 2;\n\t\tint move = NO_MOVE;\n\t\t\n\t\tif(( gameBoard[TOP_LEFT] + gameBoard[TOP_CENTER] + gameBoard[TOP_RIGHT]) == POSSIBLE_BLOCK){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[TOP_CENTER] == EMPTY){\n\t\t\t\tmove = TOP_CENTER;\n\t\t\t}else if (gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[CTR_LEFT] + gameBoard[CTR_CENTER] + gameBoard[CTR_RIGHT]) == POSSIBLE_BLOCK){\n\t\t\tif(gameBoard[CTR_LEFT] == EMPTY){\n\t\t\t\tmove = CTR_LEFT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[CTR_RIGHT] == EMPTY){\n\t\t\t\tmove = CTR_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[BTM_LEFT] + gameBoard[BTM_CENTER] + gameBoard[BTM_RIGHT]) == POSSIBLE_BLOCK){\n\t\t\tif(gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}else if (gameBoard[BTM_CENTER] == EMPTY){\n\t\t\t\tmove = BTM_CENTER;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_LEFT] + gameBoard[CTR_LEFT] + gameBoard[BTM_LEFT]) == POSSIBLE_BLOCK){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[CTR_LEFT] == EMPTY){\n\t\t\t\tmove = CTR_LEFT;\n\t\t\t}else if (gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_CENTER] + gameBoard[CTR_CENTER] + gameBoard[BTM_CENTER]) == POSSIBLE_BLOCK){\n\t\t\tif(gameBoard[TOP_CENTER] == EMPTY){\n\t\t\t\tmove = TOP_CENTER;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_CENTER] == EMPTY){\n\t\t\t\tmove = BTM_CENTER;\n\t\t\t}\t\t\t\n\t\t}else if((gameBoard[TOP_RIGHT] + gameBoard[CTR_RIGHT] + gameBoard[BTM_RIGHT]) == POSSIBLE_BLOCK){\n\t\t\tif(gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}else if (gameBoard[CTR_RIGHT] == EMPTY){\n\t\t\t\tmove = CTR_RIGHT;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_LEFT] + gameBoard[CTR_CENTER] + gameBoard[BTM_RIGHT]) == POSSIBLE_BLOCK){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_RIGHT] + gameBoard[CTR_CENTER] + gameBoard[BTM_LEFT]) == POSSIBLE_BLOCK){\n\t\t\tif(gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}\n\t\t}\n\t\treturn move;\n\t}", "public int[] findMove(){\n int[] blackCheckerSpots = new int[12];\n int i =0;\n while(mCheckerBoard.indexOf(new Checker(1, false)) != -1){\n int startPosition = mCheckerBoard.indexOf(new Checker(1, false)); //need to override Checker equals method\n Checker current = mCheckerBoard.get(startPosition);\n int[] answer = jumpRight(startPosition, false, current);\n if(answer.length > 1)\n {\n //jumped right downwards\n return answer;\n }\n answer = jumpLeft(startPosition, false, current);\n if(answer.length > 1){\n //jumped left downwards\n return answer;\n }\n answer = moveDiagonalRight(startPosition, false, current);\n if(answer.length > 1){\n //moved diagonal right downwards\n return;\n }\n answer = moveDiagonalLeft(startPosition, false, current);\n if(answer.length > 1){\n //moved diagonal left downwards\n return;\n }\n\n //end of loop\n //these are the ones that need to be set back to black at the end\n current.setIsRed(true);\n blackCheckerSpots[i]=startPosition;\n i++;\n }\n\n for(int j =0; j<blackCheckerSpots.length; j++){\n Checker changed = mCheckerBoard.get(blackCheckerSpots[j]);\n changed.setIsRed(false);\n mCheckerBoard.set(blackCheckerSpots[j], changed);\n }\n\n }", "@Override\r\n\tpublic boolean movement(BoardCells[][] chessBoard, Piece targetPiece, int fromX,int fromY,int toX,int toY) {\t\t\r\n\t\t//DEBUG -- System.out.println(\"\"+fromX+fromY+\" \"+toX+toY);\r\n\t\t\r\n\t\tif(fromY == toY){\t\t\t\r\n\t\t\tif(fromX > toX) {\r\n\t\t\t\tfor(int i = fromX-1; i>toX; i--) {\r\n\t\t\t\t\tif(chessBoard[8-fromY][i].getPiece() != null) {\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\r\n\t\t\t} else if (fromX < toX) {\r\n\t\t\t\tfor(int i = fromX+1; i<toX; i++) {\r\n\t\t\t\t\tif(chessBoard[8-fromY][i].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif(getPieceID().equals(\"bR\")) {\r\n\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"bKc\")) {\r\n\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"bK\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif(getPieceID().equals(\"wR\")) {\r\n\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"wKc\")) {\r\n\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"wK\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\tif(fromX == toX) {\t\t\t\t\r\n\t\t\tif(fromY > toY) {\t\r\n\t\t\t\tfor(int i = fromY-1; i>toY; i--) {\r\n\t\t\t\t\tif(chessBoard[8-i][toX].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t} else if (fromY < toY) {\t\t\t\t\r\n\t\t\t\tfor(int i = fromY+1; i<toY; i++) {\t\t\t\t\t\r\n\t\t\t\t\tif(chessBoard[8-i][toX].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tif(getPieceID().equals(\"bR\")) {\r\n\t\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"bKc\")) {\r\n\t\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"bK\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(getPieceID().equals(\"wR\")) {\r\n\t\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"wKc\")) {\r\n\t\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"wK\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\r\n\t\t\treturn true;\t\r\n\t\t}\r\n\t\t\t\t\r\n\t\treturn false;\t\t\r\n\t}", "private boolean growSapling(World world, int x, int y, int z, Random rand)\r\n {\r\n \t// Total value of this crop\r\n \tfloat value = 0;\r\n \t\r\n \t// Not bright enough for the sapling to grow.\r\n \tif (world.getBlockLightValue(x, y + 1, z) < SaplingMinimumLight) \r\n \t\treturn true;\r\n \t\r\n \t// Radius to check nearby ground blocks.\r\n \tint r = 2;\r\n \tfor (int i = -r + x; i <= r + x; i++)\r\n \tfor (int k = -r + z; k <= r + z; k++)\r\n \tfor (int j = -2 + y; j <= 0 + y; j++)\r\n \t{\r\n \t\t// Ignore corners, sapling block and mounds next to sapling. Maintain surface gradient!\r\n \t\tif (Math.abs(i - x) <= 1 && j == y && Math.abs(k - z) <= 1) continue;\r\n \t\tif (i == x && j == (y - 1) && k == z) continue;\r\n \t\tif (Math.abs(i - x) == r && Math.abs(k - z) == r) continue;\r\n \t\t\r\n \t\tBlock block = world.getBlock(i, j, k);\r\n \t\tMaterial above = world.getBlock(i, j + 1, k).getMaterial();\r\n \t\tif (SaplingSoilBlocks.contains(block) && (above == Material.air || above == Material.vine || above == Material.plants || above == Material.snow || above == Material.leaves)) \r\n \t\t{\r\n \t\t\t// Light level above soil\r\n \t\t\tint light = world.getBlockLightValue(i, j + 1, k);\r\n\r\n \t\t\t// Light is \"natural\" if consistent over 4 y levels\r\n \t\t\tboolean natural = true;\r\n \t\t\tfor (int l = 2; l <= 4; l++)\r\n \t\t\t\tif (world.getBlockLightValue(i, j + 1, k) != light) \r\n \t\t\t\t\tnatural = false;\r\n \t\t\t\r\n \t\t\tvalue += (float)light * (natural ? 1.0f : 0.75f) * (above == Material.plants || above == Material.snow ? 0.75f : 1.0f) * (above == Material.vine || above == Material.leaves ? 0.5f : 1.0f);\r\n \t\t}\r\n \t}\r\n \t\r\n \tif (rand.nextDouble() < (GrowthMultiplierSapling * 0.25d / Math.pow(2.0d, (300.0d - value) / 75.0d)))\r\n \t\treturn !(new WorldGenKawaiiTree(this)).generate(world, rand, x, y, z);\r\n \t\r\n \treturn true;\r\n }", "@Test\n public void testBishopSide() {\n // initialize the complete chess board\n ChessBoard chessBoard = init(\"CHESS\");\n\n assertEquals(north, chessBoard.getPiece(0, 2).getSide());\n assertEquals(north, chessBoard.getPiece(0, 5).getSide());\n assertEquals(south, chessBoard.getPiece(7, 2).getSide());\n assertEquals(south, chessBoard.getPiece(7, 5).getSide());\n }", "boolean makeMove(Bouger m) {\n\tlong oldBits[] = { pieceBits[LIGHT], pieceBits[DARK] };\n\n\tint from, to;\n\t/*\n\t* test to see if a castle move is legal and move the rook (the king is\n\t* moved with the usual move code later)\n\t*/\n\tif ((m.bits & 2) != 0) {\n\n\tif (inCheck(side))\n\treturn false;\n\tswitch (m.getTo()) {\n\tcase 62:\n\tif (color[F1] != EMPTY || color[G1] != EMPTY\n\t|| attack(F1, xside) || attack(G1, xside))\n\treturn false;\n\tfrom = H1;\n\tto = F1;\n\tbreak;\n\tcase 58:\n\tif (color[B1] != EMPTY || color[C1] != EMPTY\n\t|| color[D1] != EMPTY || attack(C1, xside)\n\t|| attack(D1, xside))\n\treturn false;\n\tfrom = A1;\n\tto = D1;\n\tbreak;\n\tcase 6:\n\tif (color[F8] != EMPTY || color[G8] != EMPTY\n\t|| attack(F8, xside) || attack(G8, xside))\n\treturn false;\n\tfrom = H8;\n\tto = F8;\n\tbreak;\n\tcase 2:\n\tif (color[B8] != EMPTY || color[C8] != EMPTY\n\t|| color[D8] != EMPTY || attack(C8, xside)\n\t|| attack(D8, xside))\n\treturn false;\n\tfrom = A8;\n\tto = D8;\n\tbreak;\n\tdefault: /* shouldn't get here */\n\tfrom = -1;\n\tto = -1;\n\tbreak;\n\t}\n\tcolor[to] = color[from];\n\tpiece[to] = piece[from];\n\tcolor[from] = EMPTY;\n\tpiece[from] = EMPTY;\n\tpieceBits[side] ^= (1L << from) | (1L << to);\n\t}\n\t/* back up information so we can take the move back later. */\n\n\tHistoryData h = new HistoryData();\n\th.m = m;\n\tto = m.getTo();\n\tfrom = m.getFrom();\n\th.capture = piece[to];\n\th.castle = castle;\n\th.ep = ep;\n\th.fifty = fifty;\n\th.pawnBits = new long[] { pawnBits[LIGHT], pawnBits[DARK] };\n\th.pieceBits = oldBits;\n\thistDat[hply++] = h;\n\n\t/*\n\t* update the castle, en passant, and fifty-move-draw variables\n\t*/\n\tcastle &= castleMask[from] & castleMask[to];\n\tif ((m.bits & 8) != 0) {\n\tif (side == LIGHT)\n\tep = to + 8;\n\telse\n\tep = to - 8;\n\t} else\n\tep = -1;\n\tif ((m.bits & 17) != 0)\n\tfifty = 0;\n\telse\n\t++fifty;\n\n\t/* move the piece */\n\tint thePiece = piece[from];\n\tif (thePiece == KING)\n\tkingSquare[side] = to;\n\tcolor[to] = side;\n\tif ((m.bits & 32) != 0) {\n\tpiece[to] = m.promote;\n\tpieceMat[side] += pieceValue[m.promote];\n\t} else\n\tpiece[to] = thePiece;\n\tcolor[from] = EMPTY;\n\tpiece[from] = EMPTY;\n\tlong fromBits = 1L << from;\n\tlong toBits = 1L << to;\n\tpieceBits[side] ^= fromBits | toBits;\n\tif ((m.bits & 16) != 0) {\n\tpawnBits[side] ^= fromBits;\n\tif ((m.bits & 32) == 0)\n\tpawnBits[side] |= toBits;\n\t}\n\tint capture = h.capture;\n\tif (capture != EMPTY) {\n\tpieceBits[xside] ^= toBits;\n\tif (capture == PAWN)\n\tpawnBits[xside] ^= toBits;\n\telse\n\tpieceMat[xside] -= pieceValue[capture];\n\t}\n\n\t/* erase the pawn if this is an en passant move */\n\tif ((m.bits & 4) != 0) {\n\tif (side == LIGHT) {\n\tcolor[to + 8] = EMPTY;\n\tpiece[to + 8] = EMPTY;\n\tpieceBits[DARK] ^= (1L << (to + 8));\n\tpawnBits[DARK] ^= (1L << (to + 8));\n\t} else {\n\tcolor[to - 8] = EMPTY;\n\tpiece[to - 8] = EMPTY;\n\tpieceBits[LIGHT] ^= (1L << (to - 8));\n\tpawnBits[LIGHT] ^= (1L << (to - 8));\n\t}\n\t}\n\n\t/*\n\t* switch sides and test for legality (if we can capture the other guy's\n\t* king, it's an illegal position and we need to take the move back)\n\t*/\n\tside ^= 1;\n\txside ^= 1;\n\tif (inCheck(xside)) {\n\ttakeBack();\n\treturn false;\n\t}\n\treturn true;\n\t}", "public boolean isMovePossible(int start, int end, boolean isRed){\n\n int moveDiff = end - start; //moveDiff tracks the movement made based on difference btwn start and end\n //general check for if a checker is on the end square\n if (mCheckerBoard.get(end) != null)\n {\n return false; //can't move b/c a checker is on the end square\n }\n\n //general checks that start and end are on the board\n if(end<0 || end>63)\n {\n return false; //can't move b/c end is off-board\n }\n\n\n //checks for diagonalRight\n if(moveDiff == 9 || moveDiff ==-7)\n {\n if(start % 8 == 7){\n return false; //can't move b/c off-board on right\n }\n }\n\n //checks for diagonalLeft\n if(moveDiff == 7 || moveDiff ==-9)\n {\n if(start % 8 == 0){\n return false; //can't move b/c off-board on left\n }\n }\n\n //checks for jumpRight\n if(moveDiff == 18 || moveDiff == -14){\n //column check\n if((start % 8 == 7) || (start % 8 == 6)){\n return false; //can't move b/c off-board on right\n }\n //need to check if there is a piece of opposite color in between\n int jumpSpace = start + (moveDiff/2);\n Checker jumped = mCheckerBoard.get(jumpSpace);\n if(jumped == null)\n {\n return false; //can't move b/c no checker to jump\n }\n else if (jumped.isRed() == isRed)\n {\n return false; //can't move b/c can't jump own color\n }\n }\n\n //checks for jumpLeft\n if(moveDiff == 14 || moveDiff == -18){\n if((start % 8 == 7) || (start % 8 == 6)) {\n return false; //can't move b/c off-board on right\n }\n //need to check if there is a piece of opposite color in between\n int jumpSpace = start + (moveDiff/2);\n Checker jumped = mCheckerBoard.get(jumpSpace);\n if(jumped == null)\n {\n return false; //can't move b/c no checker to jump\n }\n else if (jumped.isRed() == isRed)\n {\n return false; //can't move b/c can't jump own color\n }\n }\n\n if(moveDiff == 7 || moveDiff ==-7 || moveDiff ==9 || moveDiff ==-9\n || moveDiff == 18 || moveDiff == -18 || moveDiff == 14 || moveDiff ==-14){\n return true;\n }\n else{\n return false;\n }\n\n }", "private boolean searchBoardForTarget(BoardSquareInfo start, BoardSquareInfo target, int state, boolean backwards, ArrayList<BoardSquareInfo> path) {\n\t\tLog.d(LOG_TAG, \"Search board for target\");\n\t\tLog.d(LOG_TAG, String.format(\"*****start: %s\",start));\n\t\tLog.d(LOG_TAG, String.format(\"*****target: %s\",target));\n\t\tLog.d(LOG_TAG, String.format(\"*****state: %s\",state));\n\t\tLog.d(LOG_TAG, String.format(\"*****backwards: %s\",backwards));\n\t\t\n\t\t// NOTE: Revisit code to ensure logic correct, especially if \n\t\t// I continue to add checks for cases not handled\n\t\t\n\t\t// See note at class level\n\t\tint row = (state == PLAYER1_STATE) ? -1 : +1;\n\t\tint col = (backwards)? -1: +1;\n\t\t\n\t\t// Check side\n\t\tBoardSquareInfo square = getData(start.row + row, start.column + col);\n\t\tif (square == null) {\n\t\t\tLog.d(LOG_TAG, \"*****square evaluate to null\");\n\t\t\treturn false;\n\t\t}\n\n\t\tLog.d(LOG_TAG, String.format(\"*****square evaluated: %s\", square));\n\t\t\n\t\t// Found it\n\t\tif (target.equals(square)) {\n\t\t\tLog.d(LOG_TAG, \"*****target found\");\n\t\t\treturn true;\n\t\t} // end if\n\n\t\t// STOP, square states are the same\n\t\tif(square.state == activeState)\n\t\t\treturn false;\n\t\t\n\t\t// Peek at next square. \n\t\tBoardSquareInfo peek = getData(square.row + row, square.column + col);\n\t\tif(peek == null) {\n\t\t\tLog.d(LOG_TAG, \"*****peek is null\");\n\t\t\t\t\t\t\n\t\t\treturn false;\n\t\t} // end if\n\t\t\n\t\t// We know now that we can't jump move to peek\n\t\t// STOP, we can never find target on this path\n\t\tif(peek.state == activeState) {\n\t\t\tLog.d(LOG_TAG, \"*****stop, we can never move pass a square with same state\");\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t// King allow to move over two consecutive empty squares\n \t\tif(activeSquare.isKing \n\t\t\t\t&& peek.state == EMPTY_STATE \n\t\t\t\t&& peek.state == square.state \n\t\t\t\t&& moveActiveSquare(square,target,state,path)) {\n \t\t\tLog.d(LOG_TAG, \"*****king moved over two or more consecutive emtpy squares complete\");\n \t\t\tpath.add(square);\n\t\t\treturn true;\n \t\t}\n\t\t\n\t\t// We know peek isn't an empty square\n\t\t// STOP, never jump over two square with same state \n\t\tif(peek.state == square.state) {\n\t\t\tLog.d(LOG_TAG, \"*****stop, never jump over two squares with same state\");\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t// Remove opponent\n\t\tif (square.state != EMPTY_STATE && moveActiveSquare(square, target, state,path)) {\n\t\t\tLog.d(LOG_TAG, String.format(\"*****removing opponent square: %s\", square));\n\t\t\tpath.add(square);\n\t\t\treturn true;\n\t\t}\n\n\t\t// Continue moving\n\t\tif(square.state == EMPTY_STATE && moveActiveSquare(square,target,state,path)) {\n\t\t\tLog.d(LOG_TAG, \"*****continue moving done\");\n\t\t\tpath.add(square);\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\tLog.d(LOG_TAG, \"*****target not found on this path\");\n\t\treturn false;\n\t}", "public boolean playLogic(int x, int y, float mScrWidth, float mScrHeight) {\n\t\tif (topBarrelRoundCompleted == false) { // If Circle Around top Barrel\n\t\t\t\t\t\t\t\t\t\t\t\t// is not completed\n\t\t\tif (topLeft == 0 // When Circle is started from bottom of Top Barrel\n\t\t\t\t\t\t\t\t// and approaches to Right\n\t\t\t\t\t&& topRight == 0\n\t\t\t\t\t&& (topBarrelPositiveY == 1 || (x < topBarrelCentreX + 20\n\t\t\t\t\t\t\t&& x > topBarrelCentreX - 20\n\t\t\t\t\t\t\t&& y >= topBarrelCentreY + 20 && y <= leftBarrelCentreY + 20))) {\n\t\t\t\ttopBarrelPositiveY = 1; // Set Positive Y of Top Barrel as 1\n\t\t\t\t\t\t\t\t\t\t// when Horse is reached their\n\t\t\t\ttopBottom = 1; // Set Bottom of Top BArrel as 1 which indicate\n\t\t\t\t\t\t\t\t// that the Circle has started from this point\n\t\t\t\ttopLeft = 0; // Set Other points as 0 as it is starting from top\n\t\t\t\t\t\t\t\t// Bottom\n\t\t\t\ttopRight = 0;\n\t\t\t\tif (topBarrelPositiveX == 1 // Set 1 if Horse reaches Right of\n\t\t\t\t\t\t\t\t\t\t\t// Top Barrel\n\t\t\t\t\t\t|| (x > topBarrelCentreX + 20\n\t\t\t\t\t\t\t\t&& y >= topBarrelCentreY - 25 && y <= topBarrelCentreY + 25)) {\n\t\t\t\t\ttopBarrelPositiveX = 1;\n\t\t\t\t\tif (leftBarrelRoundCompleted == false) { // Set all points\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// of other 2\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// barrels as 0\n\t\t\t\t\t\tleftBottom = 0;\n\t\t\t\t\t\tleftTop = 0;\n\t\t\t\t\t\tleftRight = 0;\n\t\t\t\t\t\tleftLeft = 0;\n\t\t\t\t\t\tleftBarrelPositiveX = 0;\n\t\t\t\t\t\tleftBarrelNegativeX = 0;\n\t\t\t\t\t\tleftBarrelPositiveY = 0;\n\t\t\t\t\t\tleftBarrelNegativeY = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (rightBarrelRoundCompleted == false) {\n\t\t\t\t\t\trightRight = 0;\n\t\t\t\t\t\trightleft = 0;\n\t\t\t\t\t\trightBottom = 0;\n\t\t\t\t\t\trightTop = 0;\n\t\t\t\t\t\trightBarrelPositiveX = 0;\n\t\t\t\t\t\trightBarrelNegativeX = 0;\n\t\t\t\t\t\trightBarrelPositiveY = 0;\n\t\t\t\t\t\trightBarrelNegativeY = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (topBarrelNegativeY == 1 // Set 1 if Horse reaches Top of\n\t\t\t\t\t\t\t\t\t\t\t\t// Top Barrel\n\t\t\t\t\t\t\t|| (y < topBarrelCentreY - 20\n\t\t\t\t\t\t\t\t\t&& x <= topBarrelCentreX + 25 && x >= topBarrelCentreX - 25)) {\n\t\t\t\t\t\ttopBarrelNegativeY = 1;\n\t\t\t\t\t\tif (topBarrelNegativeX == 1 // Set 1 if Horse reaches\n\t\t\t\t\t\t\t\t\t\t\t\t\t// Left of Top Barrel\n\t\t\t\t\t\t\t\t|| (x < topBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t\t&& y >= topBarrelCentreY - 25 && y <= topBarrelCentreY + 25)) {\n\t\t\t\t\t\t\ttopBarrelNegativeX = 1;\n\t\t\t\t\t\t\tif (y > topBarrelCentreY + 20 // Set 1 if Horse\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// reaches Bottom of\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// Top Barrel again\n\t\t\t\t\t\t\t\t\t&& x <= topBarrelCentreX + 5\n\t\t\t\t\t\t\t\t\t&& x >= topBarrelCentreX - 5) {\n\t\t\t\t\t\t\t\tif (topBottom == 1) {\n\t\t\t\t\t\t\t\t\ttopBarrelRoundCompleted = true; // Set that\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// Top\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// Barrel\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// Circle is\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// completed\n\t\t\t\t\t\t\t\t\tflag = 1; // set Flag 1\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (topLeft == 0 // When Circle is started from bottom of Top Barrel\n\t\t\t\t\t\t\t\t// and approaches to Left\n\t\t\t\t\t&& topRight == 0\n\t\t\t\t\t&& (topBarrelPositiveY == 1 || (x < topBarrelCentreX + 20\n\t\t\t\t\t\t\t&& x > topBarrelCentreX - 20\n\t\t\t\t\t\t\t&& y >= topBarrelCentreY + 25 && y <= leftBarrelCentreY + 25))) {\n\t\t\t\ttopBarrelPositiveY = 1;\n\t\t\t\ttopBottom = 1;\n\t\t\t\ttopLeft = 0;\n\t\t\t\ttopRight = 0;\n\t\t\t\tif (topBarrelNegativeX == 1\n\t\t\t\t\t\t|| (x < topBarrelCentreX - 20\n\t\t\t\t\t\t\t\t&& y >= topBarrelCentreY - 25 && y <= topBarrelCentreY + 25)) {\n\t\t\t\t\ttopBarrelNegativeX = 1;\n\t\t\t\t\tif (leftBarrelRoundCompleted == false) {\n\t\t\t\t\t\tleftBottom = 0;\n\t\t\t\t\t\tleftTop = 0;\n\t\t\t\t\t\tleftRight = 0;\n\t\t\t\t\t\tleftLeft = 0;\n\t\t\t\t\t\tleftBarrelPositiveX = 0;\n\t\t\t\t\t\tleftBarrelNegativeX = 0;\n\t\t\t\t\t\tleftBarrelPositiveY = 0;\n\t\t\t\t\t\tleftBarrelNegativeY = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (rightBarrelRoundCompleted == false) {\n\t\t\t\t\t\trightRight = 0;\n\t\t\t\t\t\trightleft = 0;\n\t\t\t\t\t\trightBottom = 0;\n\t\t\t\t\t\trightTop = 0;\n\t\t\t\t\t\trightBarrelPositiveX = 0;\n\t\t\t\t\t\trightBarrelNegativeX = 0;\n\t\t\t\t\t\trightBarrelPositiveY = 0;\n\t\t\t\t\t\trightBarrelNegativeY = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (topBarrelNegativeY == 1\n\t\t\t\t\t\t\t|| (y < topBarrelCentreY - 20\n\t\t\t\t\t\t\t\t\t&& x <= topBarrelCentreX + 25 && x >= topBarrelCentreX - 25)) {\n\t\t\t\t\t\ttopBarrelNegativeY = 1;\n\t\t\t\t\t\tif (topBarrelPositiveX == 1\n\t\t\t\t\t\t\t\t|| (x > topBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t\t&& y >= topBarrelCentreY - 25 && y <= topBarrelCentreY + 25)) {\n\t\t\t\t\t\t\ttopBarrelPositiveX = 1;\n\t\t\t\t\t\t\tif (y > topBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t&& x <= topBarrelCentreX + 5\n\t\t\t\t\t\t\t\t\t&& x >= topBarrelCentreX - 5) {\n\t\t\t\t\t\t\t\tif (topBottom == 1) {\n\t\t\t\t\t\t\t\t\ttopBarrelRoundCompleted = true;\n\t\t\t\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (topLeft == 0 // When Circle is started from Right of Top Barrel\n\t\t\t\t\t\t\t\t// and approaches to Top\n\t\t\t\t\t&& topBottom == 0\n\t\t\t\t\t&& (topBarrelPositiveX == 1 || (x > topBarrelCentreX + 20\n\t\t\t\t\t\t\t&& y >= topBarrelCentreY - 25 && y <= topBarrelCentreY + 25))) {\n\t\t\t\ttopBarrelPositiveX = 1;\n\t\t\t\ttopLeft = 0;\n\t\t\t\ttopBottom = 0;\n\t\t\t\ttopRight = 1;\n\t\t\t\tif (leftBarrelRoundCompleted == false) {\n\t\t\t\t\tleftBottom = 0;\n\t\t\t\t\tleftTop = 0;\n\t\t\t\t\tleftRight = 0;\n\t\t\t\t\tleftLeft = 0;\n\t\t\t\t\tleftBarrelPositiveX = 0;\n\t\t\t\t\tleftBarrelNegativeX = 0;\n\t\t\t\t\tleftBarrelPositiveY = 0;\n\t\t\t\t\tleftBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (rightBarrelRoundCompleted == false) {\n\t\t\t\t\trightRight = 0;\n\t\t\t\t\trightleft = 0;\n\t\t\t\t\trightBottom = 0;\n\t\t\t\t\trightTop = 0;\n\t\t\t\t\trightBarrelPositiveX = 0;\n\t\t\t\t\trightBarrelNegativeX = 0;\n\t\t\t\t\trightBarrelPositiveY = 0;\n\t\t\t\t\trightBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (topBarrelNegativeY == 1\n\t\t\t\t\t\t|| (y < topBarrelCentreY - 20\n\t\t\t\t\t\t\t\t&& x <= topBarrelCentreX + 25 && x >= topBarrelCentreX - 25)) {\n\t\t\t\t\ttopBarrelNegativeY = 1;\n\t\t\t\t\tif (topBarrelNegativeX == 1\n\t\t\t\t\t\t\t|| (x < topBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t&& y >= topBarrelCentreY - 25 && y <= topBarrelCentreY + 25)) {\n\t\t\t\t\t\ttopBarrelNegativeX = 1;\n\t\t\t\t\t\tif (topBarrelPositiveY == 1\n\t\t\t\t\t\t\t\t|| (x < topBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t\t&& x > topBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t\t&& y <= rightBarrelCentreY && y >= topBarrelCentreY + 20)) {\n\t\t\t\t\t\t\ttopBarrelPositiveY = 1;\n\t\t\t\t\t\t\tif (x > topBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t&& y >= topBarrelCentreY - 25\n\t\t\t\t\t\t\t\t\t&& y <= topBarrelCentreY + 25) {\n\t\t\t\t\t\t\t\tif (topRight == 1) {\n\t\t\t\t\t\t\t\t\ttopBarrelRoundCompleted = true;\n\t\t\t\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (topLeft == 0 // When Circle is started from Right of Top Barrel\n\t\t\t\t\t\t\t\t// and approaches to Bottom\n\t\t\t\t\t&& topBottom == 0\n\t\t\t\t\t&& (topBarrelPositiveX == 1 || (x > topBarrelCentreX + 20\n\t\t\t\t\t\t\t&& y >= topBarrelCentreY - 25 && y <= topBarrelCentreY + 25))) {\n\t\t\t\ttopBarrelPositiveX = 1;\n\t\t\t\ttopLeft = 0;\n\t\t\t\ttopBottom = 0;\n\t\t\t\ttopRight = 1;\n\t\t\t\tif (leftBarrelRoundCompleted == false) {\n\t\t\t\t\tleftBottom = 0;\n\t\t\t\t\tleftTop = 0;\n\t\t\t\t\tleftRight = 0;\n\t\t\t\t\tleftLeft = 0;\n\t\t\t\t\tleftBarrelPositiveX = 0;\n\t\t\t\t\tleftBarrelNegativeX = 0;\n\t\t\t\t\tleftBarrelPositiveY = 0;\n\t\t\t\t\tleftBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (rightBarrelRoundCompleted == false) {\n\t\t\t\t\trightRight = 0;\n\t\t\t\t\trightleft = 0;\n\t\t\t\t\trightBottom = 0;\n\t\t\t\t\trightTop = 0;\n\t\t\t\t\trightBarrelPositiveX = 0;\n\t\t\t\t\trightBarrelNegativeX = 0;\n\t\t\t\t\trightBarrelPositiveY = 0;\n\t\t\t\t\trightBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (topBarrelPositiveY == 1\n\t\t\t\t\t\t|| (x < topBarrelCentreX + 20\n\t\t\t\t\t\t\t\t&& x > topBarrelCentreX - 20\n\t\t\t\t\t\t\t\t&& y <= rightBarrelCentreY && y >= topBarrelCentreY + 20)) {\n\t\t\t\t\ttopBarrelPositiveY = 1;\n\t\t\t\t\tif (topBarrelNegativeX == 1\n\t\t\t\t\t\t\t|| (x < topBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t&& y >= topBarrelCentreY - 25 && y <= topBarrelCentreY + 25)) {\n\t\t\t\t\t\ttopBarrelNegativeX = 1;\n\t\t\t\t\t\tif (topBarrelNegativeY == 1\n\t\t\t\t\t\t\t\t|| (y < topBarrelCentreY - 20\n\t\t\t\t\t\t\t\t\t\t&& x <= topBarrelCentreX + 25 && x >= topBarrelCentreX - 25)) {\n\t\t\t\t\t\t\ttopBarrelNegativeY = 1;\n\t\t\t\t\t\t\tif ((x > topBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t&& y >= topBarrelCentreY - 25 && y <= topBarrelCentreY + 25)) {\n\t\t\t\t\t\t\t\tif (topRight == 1) {\n\t\t\t\t\t\t\t\t\ttopBarrelRoundCompleted = true;\n\t\t\t\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (topBottom == 0 // When Circle is started from Left of Top Barrel\n\t\t\t\t\t\t\t\t// and approaches to Bottom\n\t\t\t\t\t&& topRight == 0\n\t\t\t\t\t&& (topBarrelNegativeX == 1 || (x < topBarrelCentreX - 20\n\t\t\t\t\t\t\t&& y >= topBarrelCentreY - 25 && y <= topBarrelCentreY + 25))) {\n\t\t\t\ttopBarrelNegativeX = 1;\n\t\t\t\ttopLeft = 1;\n\t\t\t\ttopBottom = 0;\n\t\t\t\ttopRight = 0;\n\t\t\t\tif (leftBarrelRoundCompleted == false) {\n\t\t\t\t\tleftBottom = 0;\n\t\t\t\t\tleftTop = 0;\n\t\t\t\t\tleftRight = 0;\n\t\t\t\t\tleftLeft = 0;\n\t\t\t\t\tleftBarrelPositiveX = 0;\n\t\t\t\t\tleftBarrelNegativeX = 0;\n\t\t\t\t\tleftBarrelPositiveY = 0;\n\t\t\t\t\tleftBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (rightBarrelRoundCompleted == false) {\n\t\t\t\t\trightRight = 0;\n\t\t\t\t\trightleft = 0;\n\t\t\t\t\trightBottom = 0;\n\t\t\t\t\trightTop = 0;\n\t\t\t\t\trightBarrelPositiveX = 0;\n\t\t\t\t\trightBarrelNegativeX = 0;\n\t\t\t\t\trightBarrelPositiveY = 0;\n\t\t\t\t\trightBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (topBarrelPositiveY == 1\n\t\t\t\t\t\t|| (x < topBarrelCentreX + 20\n\t\t\t\t\t\t\t\t&& x > topBarrelCentreX - 20\n\t\t\t\t\t\t\t\t&& y <= rightBarrelCentreY && y >= topBarrelCentreY + 20)) {\n\t\t\t\t\ttopBarrelPositiveY = 1;\n\t\t\t\t\tif (topBarrelPositiveX == 1\n\t\t\t\t\t\t\t|| (x > topBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t&& y >= topBarrelCentreY - 25 && y <= topBarrelCentreY + 25)) {\n\t\t\t\t\t\ttopBarrelPositiveX = 1;\n\t\t\t\t\t\tif (topBarrelNegativeY == 1\n\t\t\t\t\t\t\t\t|| (y < topBarrelCentreY - 20\n\t\t\t\t\t\t\t\t\t\t&& x <= topBarrelCentreX + 25 && x >= topBarrelCentreX - 25)) {\n\t\t\t\t\t\t\ttopBarrelNegativeY = 1;\n\t\t\t\t\t\t\tif ((x < topBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t&& y >= topBarrelCentreY - 25 && y <= topBarrelCentreY + 25)) {\n\t\t\t\t\t\t\t\tif (topLeft == 1) {\n\t\t\t\t\t\t\t\t\ttopBarrelRoundCompleted = true;\n\t\t\t\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (topBottom == 0 // When Circle is started from Left of Top Barrel\n\t\t\t\t\t\t\t\t// and approaches to Top\n\t\t\t\t\t&& topRight == 0\n\t\t\t\t\t&& (topBarrelNegativeX == 1 || (x < topBarrelCentreX - 20\n\t\t\t\t\t\t\t&& y >= topBarrelCentreY - 25 && y <= topBarrelCentreY + 25))) {\n\t\t\t\ttopBarrelNegativeX = 1;\n\t\t\t\ttopLeft = 1;\n\t\t\t\ttopBottom = 0;\n\t\t\t\ttopRight = 0;\n\t\t\t\tif (leftBarrelRoundCompleted == false) {\n\t\t\t\t\tleftBottom = 0;\n\t\t\t\t\tleftTop = 0;\n\t\t\t\t\tleftRight = 0;\n\t\t\t\t\tleftLeft = 0;\n\t\t\t\t\tleftBarrelPositiveX = 0;\n\t\t\t\t\tleftBarrelNegativeX = 0;\n\t\t\t\t\tleftBarrelPositiveY = 0;\n\t\t\t\t\tleftBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (rightBarrelRoundCompleted == false) {\n\t\t\t\t\trightRight = 0;\n\t\t\t\t\trightleft = 0;\n\t\t\t\t\trightBottom = 0;\n\t\t\t\t\trightTop = 0;\n\t\t\t\t\trightBarrelPositiveX = 0;\n\t\t\t\t\trightBarrelNegativeX = 0;\n\t\t\t\t\trightBarrelPositiveY = 0;\n\t\t\t\t\trightBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (topBarrelNegativeY == 1\n\t\t\t\t\t\t|| (y < topBarrelCentreY - 20\n\t\t\t\t\t\t\t\t&& x <= topBarrelCentreX + 25 && x >= topBarrelCentreX - 25)) {\n\t\t\t\t\ttopBarrelNegativeY = 1;\n\t\t\t\t\tif (topBarrelPositiveX == 1\n\t\t\t\t\t\t\t|| (x > topBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t&& y >= topBarrelCentreY - 25 && y <= topBarrelCentreY + 25)) {\n\t\t\t\t\t\ttopBarrelPositiveX = 1;\n\t\t\t\t\t\tif (topBarrelPositiveY == 1\n\t\t\t\t\t\t\t\t|| (x < topBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t\t&& x > topBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t\t&& y <= rightBarrelCentreY && y >= topBarrelCentreY + 20)) {\n\t\t\t\t\t\t\ttopBarrelPositiveY = 1;\n\t\t\t\t\t\t\tif ((x < topBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t&& y >= topBarrelCentreY - 25 && y <= topBarrelCentreY + 25)) {\n\t\t\t\t\t\t\t\tif (topLeft == 1) {\n\t\t\t\t\t\t\t\t\ttopBarrelRoundCompleted = true;\n\t\t\t\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (rightBarrelRoundCompleted == false) { // If Circle Around Right\n\t\t\t\t\t\t\t\t\t\t\t\t\t// Barrel is not completed\n\t\t\tif (rightRight == 0 // When Circle is started from Left of Right\n\t\t\t\t\t\t\t\t// Barrel and approaches to Top\n\t\t\t\t\t&& rightTop == 0\n\t\t\t\t\t&& rightBottom == 0\n\t\t\t\t\t&& (rightBarrelNegativeX == 1 || (x < rightBarrelCentreX - 20\n\t\t\t\t\t\t\t&& x > leftBarrelCentreX + 20\n\t\t\t\t\t\t\t&& y <= rightBarrelCentreY + 25 && y >= rightBarrelCentreY - 25))) {\n\t\t\t\trightBarrelNegativeX = 1;\n\t\t\t\trightRight = 0;\n\t\t\t\trightleft = 1;\n\t\t\t\trightTop = 0;\n\t\t\t\trightBottom = 0;\n\t\t\t\tif (rightBarrelNegativeY == 1\n\t\t\t\t\t\t|| (y < rightBarrelCentreY - 20\n\t\t\t\t\t\t\t\t&& y > topBarrelCentreY + 20\n\t\t\t\t\t\t\t\t&& x <= rightBarrelCentreX + 25 && x >= rightBarrelCentreX - 25)) {\n\t\t\t\t\trightBarrelNegativeY = 1;\n\t\t\t\t\tif (leftBarrelRoundCompleted == false) {\n\t\t\t\t\t\tleftBottom = 0;\n\t\t\t\t\t\tleftTop = 0;\n\t\t\t\t\t\tleftRight = 0;\n\t\t\t\t\t\tleftLeft = 0;\n\t\t\t\t\t\tleftBarrelPositiveX = 0;\n\t\t\t\t\t\tleftBarrelNegativeX = 0;\n\t\t\t\t\t\tleftBarrelPositiveY = 0;\n\t\t\t\t\t\tleftBarrelNegativeY = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (topBarrelRoundCompleted == false) {\n\t\t\t\t\t\ttopRight = 0;\n\t\t\t\t\t\ttopLeft = 0;\n\t\t\t\t\t\ttopBottom = 0;\n\t\t\t\t\t\ttopBarrelPositiveX = 0;\n\t\t\t\t\t\ttopBarrelNegativeX = 0;\n\t\t\t\t\t\ttopBarrelPositiveY = 0;\n\t\t\t\t\t\ttopBarrelNegativeY = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (rightBarrelPositiveX == 1\n\t\t\t\t\t\t\t|| (x > rightBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t&& y <= rightBarrelCentreY + 25 && y >= rightBarrelCentreY - 25)) {\n\t\t\t\t\t\trightBarrelPositiveX = 1;\n\t\t\t\t\t\tif (rightBarrelPositiveY == 1\n\t\t\t\t\t\t\t\t|| (y > rightBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t\t&& y < mScrHeight - 170\n\t\t\t\t\t\t\t\t\t\t&& x <= rightBarrelCentreX + 25 && x >= rightBarrelCentreX - 25)) {\n\t\t\t\t\t\t\trightBarrelPositiveY = 1;\n\t\t\t\t\t\t\tif (x < rightBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t&& x > leftBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t&& y <= rightBarrelCentreY + 25\n\t\t\t\t\t\t\t\t\t&& y >= rightBarrelCentreY - 25) {\n\t\t\t\t\t\t\t\tif (rightleft == 1) {\n\t\t\t\t\t\t\t\t\trightBarrelRoundCompleted = true;\n\t\t\t\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (rightRight == 0 // When Circle is started from Left of Right\n\t\t\t\t\t\t\t\t// Barrel and approaches to Bottom\n\t\t\t\t\t&& rightTop == 0\n\t\t\t\t\t&& rightBottom == 0\n\t\t\t\t\t&& (rightBarrelNegativeX == 1 || (x < rightBarrelCentreX - 20\n\t\t\t\t\t\t\t&& x > leftBarrelCentreX + 20\n\t\t\t\t\t\t\t&& y <= rightBarrelCentreY + 25 && y >= rightBarrelCentreY - 25))) {\n\t\t\t\trightBarrelNegativeX = 1;\n\t\t\t\trightRight = 0;\n\t\t\t\trightleft = 1;\n\t\t\t\trightTop = 0;\n\t\t\t\trightBottom = 0;\n\t\t\t\tif (rightBarrelPositiveY == 1\n\t\t\t\t\t\t|| (y > rightBarrelCentreY + 20 && y < mScrHeight - 170\n\t\t\t\t\t\t\t\t&& x <= rightBarrelCentreX + 25 && x >= rightBarrelCentreX - 25)) {\n\t\t\t\t\trightBarrelPositiveY = 1;\n\t\t\t\t\tif (leftBarrelRoundCompleted == false) {\n\t\t\t\t\t\tleftBottom = 0;\n\t\t\t\t\t\tleftTop = 0;\n\t\t\t\t\t\tleftRight = 0;\n\t\t\t\t\t\tleftLeft = 0;\n\t\t\t\t\t\tleftBarrelPositiveX = 0;\n\t\t\t\t\t\tleftBarrelNegativeX = 0;\n\t\t\t\t\t\tleftBarrelPositiveY = 0;\n\t\t\t\t\t\tleftBarrelNegativeY = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (topBarrelRoundCompleted == false) {\n\t\t\t\t\t\ttopRight = 0;\n\t\t\t\t\t\ttopLeft = 0;\n\t\t\t\t\t\ttopBottom = 0;\n\t\t\t\t\t\ttopBarrelPositiveX = 0;\n\t\t\t\t\t\ttopBarrelNegativeX = 0;\n\t\t\t\t\t\ttopBarrelPositiveY = 0;\n\t\t\t\t\t\ttopBarrelNegativeY = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (rightBarrelPositiveX == 1\n\t\t\t\t\t\t\t|| (x > rightBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t&& y <= rightBarrelCentreY + 25 && y >= rightBarrelCentreY - 25)) {\n\t\t\t\t\t\trightBarrelPositiveX = 1;\n\t\t\t\t\t\tif (rightBarrelNegativeY == 1\n\t\t\t\t\t\t\t\t|| (y < rightBarrelCentreY - 20\n\t\t\t\t\t\t\t\t\t\t&& y > topBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t\t&& x <= rightBarrelCentreX + 25 && x >= rightBarrelCentreX - 25)) {\n\t\t\t\t\t\t\trightBarrelNegativeY = 1;\n\t\t\t\t\t\t\tif (x < rightBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t&& x > leftBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t&& y <= rightBarrelCentreY + 25\n\t\t\t\t\t\t\t\t\t&& y >= rightBarrelCentreY - 25) {\n\t\t\t\t\t\t\t\tif (rightleft == 1) {\n\t\t\t\t\t\t\t\t\trightBarrelRoundCompleted = true;\n\t\t\t\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (rightRight == 0 // When Circle is started from Bottom of Right\n\t\t\t\t\t\t\t\t// Barrel and approaches to Right\n\t\t\t\t\t&& rightleft == 0\n\t\t\t\t\t&& rightTop == 0\n\t\t\t\t\t&& (rightBarrelPositiveY == 1 || (y > rightBarrelCentreY + 20\n\t\t\t\t\t\t\t&& y < mScrHeight - 170\n\t\t\t\t\t\t\t&& x <= rightBarrelCentreX + 25 && x >= rightBarrelCentreX - 25))) {\n\t\t\t\trightBarrelPositiveY = 1;\n\t\t\t\trightRight = 0;\n\t\t\t\trightleft = 0;\n\t\t\t\trightTop = 0;\n\t\t\t\trightBottom = 1;\n\t\t\t\tif (leftBarrelRoundCompleted == false) {\n\t\t\t\t\tleftBottom = 0;\n\t\t\t\t\tleftTop = 0;\n\t\t\t\t\tleftRight = 0;\n\t\t\t\t\tleftLeft = 0;\n\t\t\t\t\tleftBarrelPositiveX = 0;\n\t\t\t\t\tleftBarrelNegativeX = 0;\n\t\t\t\t\tleftBarrelPositiveY = 0;\n\t\t\t\t\tleftBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (topBarrelRoundCompleted == false) {\n\t\t\t\t\ttopRight = 0;\n\t\t\t\t\ttopLeft = 0;\n\t\t\t\t\ttopBottom = 0;\n\t\t\t\t\ttopBarrelPositiveX = 0;\n\t\t\t\t\ttopBarrelNegativeX = 0;\n\t\t\t\t\ttopBarrelPositiveY = 0;\n\t\t\t\t\ttopBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (rightBarrelPositiveX == 1\n\t\t\t\t\t\t|| (x > rightBarrelCentreX + 20\n\t\t\t\t\t\t\t\t&& y <= rightBarrelCentreY + 25 && y >= rightBarrelCentreY - 25)) {\n\t\t\t\t\trightBarrelPositiveX = 1;\n\t\t\t\t\tif (rightBarrelNegativeY == 1\n\t\t\t\t\t\t\t|| (y < rightBarrelCentreY - 20\n\t\t\t\t\t\t\t\t\t&& y > topBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t&& x <= rightBarrelCentreX + 25 && x >= rightBarrelCentreX - 25)) {\n\t\t\t\t\t\trightBarrelNegativeY = 1;\n\t\t\t\t\t\tif (rightBarrelNegativeX == 1\n\t\t\t\t\t\t\t\t|| (x < rightBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t\t&& x > leftBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t\t&& y <= rightBarrelCentreY + 25 && y >= rightBarrelCentreY - 25)) {\n\t\t\t\t\t\t\trightBarrelNegativeX = 1;\n\t\t\t\t\t\t\tif ((y > rightBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t&& y < mScrHeight - 170\n\t\t\t\t\t\t\t\t\t&& x <= rightBarrelCentreX + 25 && x >= rightBarrelCentreX - 25)) {\n\t\t\t\t\t\t\t\tif (rightBottom == 1) {\n\t\t\t\t\t\t\t\t\trightBarrelRoundCompleted = true;\n\t\t\t\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (rightRight == 0 // When Circle is started from Bottom of Right\n\t\t\t\t\t\t\t\t// Barrel and approaches to Left\n\t\t\t\t\t&& rightleft == 0\n\t\t\t\t\t&& rightTop == 0\n\t\t\t\t\t&& (rightBarrelPositiveY == 1 || (y > rightBarrelCentreY + 20\n\t\t\t\t\t\t\t&& y < mScrHeight - 170\n\t\t\t\t\t\t\t&& x <= rightBarrelCentreX + 25 && x >= rightBarrelCentreX - 25))) {\n\t\t\t\trightBarrelPositiveY = 1;\n\t\t\t\trightRight = 0;\n\t\t\t\trightleft = 0;\n\t\t\t\trightTop = 0;\n\t\t\t\trightBottom = 1;\n\t\t\t\tif (leftBarrelRoundCompleted == false) {\n\t\t\t\t\tleftBottom = 0;\n\t\t\t\t\tleftTop = 0;\n\t\t\t\t\tleftRight = 0;\n\t\t\t\t\tleftLeft = 0;\n\t\t\t\t\tleftBarrelPositiveX = 0;\n\t\t\t\t\tleftBarrelNegativeX = 0;\n\t\t\t\t\tleftBarrelPositiveY = 0;\n\t\t\t\t\tleftBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (topBarrelRoundCompleted == false) {\n\t\t\t\t\ttopRight = 0;\n\t\t\t\t\ttopLeft = 0;\n\t\t\t\t\ttopBottom = 0;\n\t\t\t\t\ttopBarrelPositiveX = 0;\n\t\t\t\t\ttopBarrelNegativeX = 0;\n\t\t\t\t\ttopBarrelPositiveY = 0;\n\t\t\t\t\ttopBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (rightBarrelNegativeX == 1\n\t\t\t\t\t\t|| (x < rightBarrelCentreX - 20\n\t\t\t\t\t\t\t\t&& x > leftBarrelCentreX + 20\n\t\t\t\t\t\t\t\t&& y <= rightBarrelCentreY + 25 && y >= rightBarrelCentreY - 25)) {\n\t\t\t\t\trightBarrelNegativeX = 1;\n\t\t\t\t\tif (rightBarrelNegativeY == 1\n\t\t\t\t\t\t\t|| (y < rightBarrelCentreY - 20\n\t\t\t\t\t\t\t\t\t&& y > topBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t&& x <= rightBarrelCentreX + 25 && x >= rightBarrelCentreX - 25)) {\n\t\t\t\t\t\trightBarrelNegativeY = 1;\n\t\t\t\t\t\tif (rightBarrelPositiveX == 1\n\t\t\t\t\t\t\t\t|| (x > rightBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t\t&& y <= rightBarrelCentreY + 25 && y >= rightBarrelCentreY - 25)) {\n\t\t\t\t\t\t\trightBarrelPositiveX = 1;\n\n\t\t\t\t\t\t\tif ((y > rightBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t&& y < mScrHeight - 170\n\t\t\t\t\t\t\t\t\t&& x <= rightBarrelCentreX + 25 && x >= rightBarrelCentreX - 25)) {\n\t\t\t\t\t\t\t\tif (rightBottom == 1) {\n\t\t\t\t\t\t\t\t\trightBarrelRoundCompleted = true;\n\t\t\t\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (rightRight == 0 // When Circle is started from Top of Right\n\t\t\t\t\t\t\t\t// Barrel and approaches to Right\n\t\t\t\t\t&& rightleft == 0\n\t\t\t\t\t&& rightBottom == 0\n\t\t\t\t\t&& (rightBarrelNegativeY == 1 || (y < rightBarrelCentreY - 20\n\t\t\t\t\t\t\t&& y > topBarrelCentreY + 20\n\t\t\t\t\t\t\t&& x <= rightBarrelCentreX + 25 && x >= rightBarrelCentreX - 25))) {\n\t\t\t\trightBarrelNegativeY = 1;\n\t\t\t\trightRight = 0;\n\t\t\t\trightleft = 0;\n\t\t\t\trightTop = 1;\n\t\t\t\trightBottom = 0;\n\t\t\t\tif (leftBarrelRoundCompleted == false) {\n\t\t\t\t\tleftBottom = 0;\n\t\t\t\t\tleftTop = 0;\n\t\t\t\t\tleftRight = 0;\n\t\t\t\t\tleftLeft = 0;\n\t\t\t\t\tleftBarrelPositiveX = 0;\n\t\t\t\t\tleftBarrelNegativeX = 0;\n\t\t\t\t\tleftBarrelPositiveY = 0;\n\t\t\t\t\tleftBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (topBarrelRoundCompleted == false) {\n\t\t\t\t\ttopRight = 0;\n\t\t\t\t\ttopLeft = 0;\n\t\t\t\t\ttopBottom = 0;\n\t\t\t\t\ttopBarrelPositiveX = 0;\n\t\t\t\t\ttopBarrelNegativeX = 0;\n\t\t\t\t\ttopBarrelPositiveY = 0;\n\t\t\t\t\ttopBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (rightBarrelPositiveX == 1\n\t\t\t\t\t\t|| ((x > (rightBarrelCentreX + 20)) && (x < mScrWidth)\n\t\t\t\t\t\t\t\t&& (y <= (rightBarrelCentreY + 25)) && (y >= (rightBarrelCentreY - 25)))) {\n\t\t\t\t\trightBarrelPositiveX = 1;\n\t\t\t\t\tif ((rightBarrelPositiveY == 1 || (y > rightBarrelCentreY + 20\n\t\t\t\t\t\t\t&& y < mScrHeight - 170\n\t\t\t\t\t\t\t&& x <= rightBarrelCentreX + 25 && x >= rightBarrelCentreX - 25))) {\n\t\t\t\t\t\trightBarrelPositiveY = 1;\n\t\t\t\t\t\tif (rightBarrelNegativeX == 1\n\t\t\t\t\t\t\t\t|| (x < rightBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t\t&& x > leftBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t\t&& y <= rightBarrelCentreY + 25 && y >= rightBarrelCentreY - 25)) {\n\t\t\t\t\t\t\trightBarrelNegativeX = 1;\n\t\t\t\t\t\t\tif (y < rightBarrelCentreY - 20\n\t\t\t\t\t\t\t\t\t&& y > topBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t&& x <= rightBarrelCentreX + 25\n\t\t\t\t\t\t\t\t\t&& x >= rightBarrelCentreX - 25) {\n\t\t\t\t\t\t\t\tif (rightTop == 1) {\n\t\t\t\t\t\t\t\t\trightBarrelRoundCompleted = true;\n\t\t\t\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (rightRight == 0 // When Circle is started from Top of Right\n\t\t\t\t\t\t\t\t// Barrel and approaches to Left\n\t\t\t\t\t&& rightleft == 0\n\t\t\t\t\t&& rightBottom == 0\n\t\t\t\t\t&& (rightBarrelNegativeY == 1 || (y < rightBarrelCentreY - 20\n\t\t\t\t\t\t\t&& y > topBarrelCentreY + 20\n\t\t\t\t\t\t\t&& x <= rightBarrelCentreX + 25 && x >= rightBarrelCentreX - 25))) {\n\t\t\t\trightBarrelNegativeY = 1;\n\t\t\t\trightRight = 0;\n\t\t\t\trightleft = 0;\n\t\t\t\trightTop = 1;\n\t\t\t\trightBottom = 0;\n\t\t\t\tif (leftBarrelRoundCompleted == false) {\n\t\t\t\t\tleftBottom = 0;\n\t\t\t\t\tleftTop = 0;\n\t\t\t\t\tleftRight = 0;\n\t\t\t\t\tleftLeft = 0;\n\t\t\t\t\tleftBarrelPositiveX = 0;\n\t\t\t\t\tleftBarrelNegativeX = 0;\n\t\t\t\t\tleftBarrelPositiveY = 0;\n\t\t\t\t\tleftBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (topBarrelRoundCompleted == false) {\n\t\t\t\t\ttopRight = 0;\n\t\t\t\t\ttopLeft = 0;\n\t\t\t\t\ttopBottom = 0;\n\t\t\t\t\ttopBarrelPositiveX = 0;\n\t\t\t\t\ttopBarrelNegativeX = 0;\n\t\t\t\t\ttopBarrelPositiveY = 0;\n\t\t\t\t\ttopBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (rightBarrelNegativeX == 1\n\t\t\t\t\t\t|| (x < rightBarrelCentreX - 20\n\t\t\t\t\t\t\t\t&& x > leftBarrelCentreX + 20\n\t\t\t\t\t\t\t\t&& y <= rightBarrelCentreY + 25 && y >= rightBarrelCentreY - 25)) {\n\t\t\t\t\trightBarrelNegativeX = 1;\n\t\t\t\t\tif ((rightBarrelPositiveY == 1 || (y > rightBarrelCentreY + 20\n\t\t\t\t\t\t\t&& y < mScrHeight - 170\n\t\t\t\t\t\t\t&& x <= rightBarrelCentreX + 25 && x >= rightBarrelCentreX - 25))) {\n\t\t\t\t\t\trightBarrelPositiveY = 1;\n\t\t\t\t\t\tif (rightBarrelPositiveX == 1\n\t\t\t\t\t\t\t\t|| (x > rightBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t\t&& y <= rightBarrelCentreY + 25 && y >= rightBarrelCentreY - 25)) {\n\t\t\t\t\t\t\trightBarrelPositiveX = 1;\n\t\t\t\t\t\t\tif (y < rightBarrelCentreY - 20\n\t\t\t\t\t\t\t\t\t&& y > topBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t&& x <= rightBarrelCentreX + 25\n\t\t\t\t\t\t\t\t\t&& x >= rightBarrelCentreX - 25) {\n\t\t\t\t\t\t\t\tif (rightTop == 1) {\n\t\t\t\t\t\t\t\t\trightBarrelRoundCompleted = true;\n\t\t\t\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (leftBarrelRoundCompleted == false) { // If Circle Around Left Barrel\n\t\t\t\t\t\t\t\t\t\t\t\t\t// is not completed\n\t\t\tif (leftLeft == 0 // When Circle is started from Right of Left\n\t\t\t\t\t\t\t\t// Barrel and approaches to Top\n\t\t\t\t\t&& leftTop == 0\n\t\t\t\t\t&& leftBottom == 0\n\t\t\t\t\t&& (leftBarrelPositiveX == 1 || (x < rightBarrelCentreX - 20\n\t\t\t\t\t\t\t&& x > leftBarrelCentreX + 20\n\t\t\t\t\t\t\t&& y <= leftBarrelCentreY + 25 && y >= leftBarrelCentreY - 25))) {\n\t\t\t\tleftBarrelPositiveX = 1;\n\t\t\t\tleftRight = 1;\n\t\t\t\tleftLeft = 0;\n\t\t\t\tleftTop = 0;\n\t\t\t\tleftBottom = 0;\n\t\t\t\tif (leftBarrelNegativeY == 1\n\t\t\t\t\t\t|| (y < leftBarrelCentreY - 20\n\t\t\t\t\t\t\t\t&& y > topBarrelCentreY + 20\n\t\t\t\t\t\t\t\t&& x >= leftBarrelCentreX - 25 && x <= leftBarrelCentreX + 25)) {\n\t\t\t\t\tleftBarrelNegativeY = 1;\n\t\t\t\t\tif (topBarrelRoundCompleted == false) {\n\t\t\t\t\t\ttopRight = 0;\n\t\t\t\t\t\ttopLeft = 0;\n\t\t\t\t\t\ttopBottom = 0;\n\t\t\t\t\t\ttopBarrelPositiveX = 0;\n\t\t\t\t\t\ttopBarrelNegativeX = 0;\n\t\t\t\t\t\ttopBarrelPositiveY = 0;\n\t\t\t\t\t\ttopBarrelNegativeY = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (rightBarrelRoundCompleted == false) {\n\t\t\t\t\t\trightRight = 0;\n\t\t\t\t\t\trightleft = 0;\n\t\t\t\t\t\trightBottom = 0;\n\t\t\t\t\t\trightTop = 0;\n\t\t\t\t\t\trightBarrelPositiveX = 0;\n\t\t\t\t\t\trightBarrelNegativeX = 0;\n\t\t\t\t\t\trightBarrelPositiveY = 0;\n\t\t\t\t\t\trightBarrelNegativeY = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (leftBarrelNegativeX == 1\n\t\t\t\t\t\t\t|| (x < leftBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t&& y <= leftBarrelCentreY + 25 && y >= leftBarrelCentreY - 25)) {\n\t\t\t\t\t\tleftBarrelNegativeX = 1;\n\n\t\t\t\t\t\tif (leftBarrelPositiveY == 1\n\t\t\t\t\t\t\t\t|| (y > leftBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t\t&& y < mScrHeight - 170\n\t\t\t\t\t\t\t\t\t\t&& x >= leftBarrelCentreX - 25 && x <= leftBarrelCentreX + 25)) {\n\t\t\t\t\t\t\tleftBarrelPositiveY = 1;\n\t\t\t\t\t\t\tif (x > leftBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t&& x < rightBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t&& y <= leftBarrelCentreY + 25\n\t\t\t\t\t\t\t\t\t&& y >= leftBarrelCentreY - 25) {\n\t\t\t\t\t\t\t\tif (leftRight == 1) {\n\t\t\t\t\t\t\t\t\tleftBarrelRoundCompleted = true;\n\t\t\t\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (leftLeft == 0 // When Circle is started from Right of Left\n\t\t\t\t\t\t\t\t// Barrel and approaches to Bottom\n\t\t\t\t\t&& leftTop == 0\n\t\t\t\t\t&& leftBottom == 0\n\t\t\t\t\t&& (leftBarrelPositiveX == 1 || (x < rightBarrelCentreX - 20\n\t\t\t\t\t\t\t&& x > leftBarrelCentreX + 20\n\t\t\t\t\t\t\t&& y <= leftBarrelCentreY + 25 && y >= leftBarrelCentreY - 25))) {\n\t\t\t\tleftBarrelPositiveX = 1;\n\t\t\t\tleftRight = 1;\n\t\t\t\tleftLeft = 0;\n\t\t\t\tleftTop = 0;\n\t\t\t\tleftBottom = 0;\n\t\t\t\tif (leftBarrelPositiveY == 1\n\t\t\t\t\t\t|| (y > leftBarrelCentreY + 20 && y < mScrHeight - 170\n\t\t\t\t\t\t\t\t&& x >= leftBarrelCentreX - 25 && x <= leftBarrelCentreX + 25)) {\n\t\t\t\t\tleftBarrelPositiveY = 1;\n\t\t\t\t\tif (topBarrelRoundCompleted == false) {\n\t\t\t\t\t\ttopRight = 0;\n\t\t\t\t\t\ttopLeft = 0;\n\t\t\t\t\t\ttopBottom = 0;\n\t\t\t\t\t\ttopBarrelPositiveX = 0;\n\t\t\t\t\t\ttopBarrelNegativeX = 0;\n\t\t\t\t\t\ttopBarrelPositiveY = 0;\n\t\t\t\t\t\ttopBarrelNegativeY = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (rightBarrelRoundCompleted == false) {\n\t\t\t\t\t\trightRight = 0;\n\t\t\t\t\t\trightleft = 0;\n\t\t\t\t\t\trightBottom = 0;\n\t\t\t\t\t\trightTop = 0;\n\t\t\t\t\t\trightBarrelPositiveX = 0;\n\t\t\t\t\t\trightBarrelNegativeX = 0;\n\t\t\t\t\t\trightBarrelPositiveY = 0;\n\t\t\t\t\t\trightBarrelNegativeY = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (leftBarrelNegativeX == 1\n\t\t\t\t\t\t\t|| (x < leftBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t&& y <= leftBarrelCentreY + 25 && y >= leftBarrelCentreY - 25)) {\n\t\t\t\t\t\tleftBarrelNegativeX = 1;\n\n\t\t\t\t\t\tif (leftBarrelNegativeY == 1\n\t\t\t\t\t\t\t\t|| (y < leftBarrelCentreY - 20\n\t\t\t\t\t\t\t\t\t\t&& y > topBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t\t&& x >= leftBarrelCentreX - 25 && x <= leftBarrelCentreX + 25)) {\n\t\t\t\t\t\t\tleftBarrelNegativeY = 1;\n\t\t\t\t\t\t\tif (x > leftBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t&& x < rightBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t&& y <= leftBarrelCentreY + 25\n\t\t\t\t\t\t\t\t\t&& y >= leftBarrelCentreY - 25) {\n\t\t\t\t\t\t\t\tif (leftRight == 1) {\n\t\t\t\t\t\t\t\t\tleftBarrelRoundCompleted = true;\n\t\t\t\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (leftRight == 0 // When Circle is started from Bottom of Left\n\t\t\t\t\t\t\t\t// Barrel and approaches to Left\n\t\t\t\t\t&& leftLeft == 0\n\t\t\t\t\t&& leftTop == 0\n\t\t\t\t\t&& (leftBarrelPositiveY == 1 || (y > leftBarrelCentreY + 20\n\t\t\t\t\t\t\t&& y < mScrHeight - 170\n\t\t\t\t\t\t\t&& x >= leftBarrelCentreX - 25 && x <= leftBarrelCentreX + 25))) {\n\t\t\t\tleftBarrelPositiveY = 1;\n\t\t\t\tleftRight = 0;\n\t\t\t\tleftLeft = 0;\n\t\t\t\tleftTop = 0;\n\t\t\t\tleftBottom = 1;\n\t\t\t\tif (leftBarrelNegativeX == 1\n\t\t\t\t\t\t|| (x < leftBarrelCentreX - 20\n\t\t\t\t\t\t\t\t&& y <= leftBarrelCentreY + 25 && y >= leftBarrelCentreY - 25)) {\n\t\t\t\t\tleftBarrelNegativeX = 1;\n\t\t\t\t\tif (topBarrelRoundCompleted == false) {\n\t\t\t\t\t\ttopRight = 0;\n\t\t\t\t\t\ttopLeft = 0;\n\t\t\t\t\t\ttopBottom = 0;\n\t\t\t\t\t\ttopBarrelPositiveX = 0;\n\t\t\t\t\t\ttopBarrelNegativeX = 0;\n\t\t\t\t\t\ttopBarrelPositiveY = 0;\n\t\t\t\t\t\ttopBarrelNegativeY = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (rightBarrelRoundCompleted == false) {\n\t\t\t\t\t\trightRight = 0;\n\t\t\t\t\t\trightleft = 0;\n\t\t\t\t\t\trightBottom = 0;\n\t\t\t\t\t\trightTop = 0;\n\t\t\t\t\t\trightBarrelPositiveX = 0;\n\t\t\t\t\t\trightBarrelNegativeX = 0;\n\t\t\t\t\t\trightBarrelPositiveY = 0;\n\t\t\t\t\t\trightBarrelNegativeY = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (leftBarrelNegativeY == 1\n\t\t\t\t\t\t\t|| (y < leftBarrelCentreY - 20\n\t\t\t\t\t\t\t\t\t&& y > topBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t&& x >= leftBarrelCentreX - 25 && x <= leftBarrelCentreX + 25)) {\n\t\t\t\t\t\tleftBarrelNegativeY = 1;\n\t\t\t\t\t\tif (leftBarrelPositiveX == 1\n\t\t\t\t\t\t\t\t|| (x > leftBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t\t&& x < rightBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t\t&& y <= leftBarrelCentreY + 25 && y >= leftBarrelCentreY - 25)) {\n\t\t\t\t\t\t\tleftBarrelPositiveX = 1;\n\t\t\t\t\t\t\tif (y > leftBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t&& y < mScrHeight - 170\n\t\t\t\t\t\t\t\t\t&& x >= leftBarrelCentreX - 25\n\t\t\t\t\t\t\t\t\t&& x <= leftBarrelCentreX + 25) {\n\t\t\t\t\t\t\t\tif (leftBottom == 1) {\n\t\t\t\t\t\t\t\t\tleftBarrelRoundCompleted = true;\n\t\t\t\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (leftRight == 0 // When Circle is started from Bottom of Left\n\t\t\t\t\t\t\t\t// Barrel and approaches to Right\n\t\t\t\t\t&& leftLeft == 0\n\t\t\t\t\t&& leftTop == 0\n\t\t\t\t\t&& (leftBarrelPositiveY == 1 || (y > leftBarrelCentreY + 20\n\t\t\t\t\t\t\t&& y < mScrHeight - 170\n\t\t\t\t\t\t\t&& x >= leftBarrelCentreX - 25 && x <= leftBarrelCentreX + 25))) {\n\t\t\t\tleftBarrelPositiveY = 1;\n\t\t\t\tleftRight = 0;\n\t\t\t\tleftLeft = 0;\n\t\t\t\tleftTop = 0;\n\t\t\t\tleftBottom = 1;\n\t\t\t\tif (topBarrelRoundCompleted == false) {\n\t\t\t\t\ttopRight = 0;\n\t\t\t\t\ttopLeft = 0;\n\t\t\t\t\ttopBottom = 0;\n\t\t\t\t\ttopBarrelPositiveX = 0;\n\t\t\t\t\ttopBarrelNegativeX = 0;\n\t\t\t\t\ttopBarrelPositiveY = 0;\n\t\t\t\t\ttopBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (rightBarrelRoundCompleted == false) {\n\t\t\t\t\trightRight = 0;\n\t\t\t\t\trightleft = 0;\n\t\t\t\t\trightBottom = 0;\n\t\t\t\t\trightTop = 0;\n\t\t\t\t\trightBarrelPositiveX = 0;\n\t\t\t\t\trightBarrelNegativeX = 0;\n\t\t\t\t\trightBarrelPositiveY = 0;\n\t\t\t\t\trightBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (leftBarrelPositiveX == 1\n\t\t\t\t\t\t|| (x > leftBarrelCentreX + 20\n\t\t\t\t\t\t\t\t&& x < rightBarrelCentreX - 20\n\t\t\t\t\t\t\t\t&& y <= leftBarrelCentreY + 25 && y >= leftBarrelCentreY - 25)) {\n\t\t\t\t\tleftBarrelPositiveX = 1;\n\t\t\t\t\tif (leftBarrelNegativeY == 1\n\t\t\t\t\t\t\t|| (y < leftBarrelCentreY - 20\n\t\t\t\t\t\t\t\t\t&& y > topBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t&& x >= leftBarrelCentreX - 25 && x <= leftBarrelCentreX + 25)) {\n\t\t\t\t\t\tleftBarrelNegativeY = 1;\n\t\t\t\t\t\tif (leftBarrelNegativeX == 1\n\t\t\t\t\t\t\t\t|| (x < leftBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t\t&& y <= leftBarrelCentreY + 25 && y >= leftBarrelCentreY - 25)) {\n\t\t\t\t\t\t\tleftBarrelNegativeX = 1;\n\t\t\t\t\t\t\tif (y > leftBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t&& y < mScrHeight - 170\n\t\t\t\t\t\t\t\t\t&& x >= leftBarrelCentreX - 25\n\t\t\t\t\t\t\t\t\t&& x <= leftBarrelCentreX + 25) {\n\t\t\t\t\t\t\t\tif (leftBottom == 1) {\n\t\t\t\t\t\t\t\t\tleftBarrelRoundCompleted = true;\n\t\t\t\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (leftRight == 0 // When Circle is started from Top of Left Barrel\n\t\t\t\t\t\t\t\t// and approaches to Right\n\t\t\t\t\t&& leftLeft == 0\n\t\t\t\t\t&& leftBottom == 0\n\t\t\t\t\t&& (leftBarrelNegativeY == 1 || (y < leftBarrelCentreY - 20\n\t\t\t\t\t\t\t&& y > topBarrelCentreY + 20\n\t\t\t\t\t\t\t&& x >= leftBarrelCentreX - 25 && x <= leftBarrelCentreX + 25))) {\n\t\t\t\tleftBarrelNegativeY = 1;\n\t\t\t\tleftRight = 0;\n\t\t\t\tleftLeft = 0;\n\t\t\t\tleftTop = 1;\n\t\t\t\tleftBottom = 0;\n\t\t\t\tif (topBarrelRoundCompleted == false) {\n\t\t\t\t\ttopRight = 0;\n\t\t\t\t\ttopLeft = 0;\n\t\t\t\t\ttopBottom = 0;\n\t\t\t\t\ttopBarrelPositiveX = 0;\n\t\t\t\t\ttopBarrelNegativeX = 0;\n\t\t\t\t\ttopBarrelPositiveY = 0;\n\t\t\t\t\ttopBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (rightBarrelRoundCompleted == false) {\n\t\t\t\t\trightRight = 0;\n\t\t\t\t\trightleft = 0;\n\t\t\t\t\trightBottom = 0;\n\t\t\t\t\trightTop = 0;\n\t\t\t\t\trightBarrelPositiveX = 0;\n\t\t\t\t\trightBarrelNegativeX = 0;\n\t\t\t\t\trightBarrelPositiveY = 0;\n\t\t\t\t\trightBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (leftBarrelPositiveX == 1\n\t\t\t\t\t\t|| (x > leftBarrelCentreX + 20\n\t\t\t\t\t\t\t\t&& x < rightBarrelCentreX - 20\n\t\t\t\t\t\t\t\t&& y <= leftBarrelCentreY + 25 && y >= leftBarrelCentreY - 25)) {\n\t\t\t\t\tleftBarrelPositiveX = 1;\n\t\t\t\t\tif (leftBarrelPositiveY == 1\n\t\t\t\t\t\t\t|| (y > leftBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t&& y < mScrHeight - 170\n\t\t\t\t\t\t\t\t\t&& x >= leftBarrelCentreX - 25 && x <= leftBarrelCentreX + 25)) {\n\t\t\t\t\t\tleftBarrelPositiveY = 1;\n\t\t\t\t\t\tif (leftBarrelNegativeX == 1\n\t\t\t\t\t\t\t\t|| (x < leftBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t\t&& y <= leftBarrelCentreY + 25 && y >= leftBarrelCentreY - 25)) {\n\t\t\t\t\t\t\tleftBarrelNegativeX = 1;\n\n\t\t\t\t\t\t\tif (y < leftBarrelCentreY - 20\n\t\t\t\t\t\t\t\t\t&& y > topBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t&& x >= leftBarrelCentreX - 25\n\t\t\t\t\t\t\t\t\t&& x <= leftBarrelCentreX + 25) {\n\t\t\t\t\t\t\t\tif (leftTop == 1) {\n\t\t\t\t\t\t\t\t\tleftBarrelRoundCompleted = true;\n\t\t\t\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (leftRight == 0 // When Circle is started from Top of Left Barrel\n\t\t\t\t\t\t\t\t// and approaches to Left\n\t\t\t\t\t&& leftLeft == 0\n\t\t\t\t\t&& leftBottom == 0\n\t\t\t\t\t&& (leftBarrelNegativeY == 1 || (y < leftBarrelCentreY - 20\n\t\t\t\t\t\t\t&& y > topBarrelCentreY + 20\n\t\t\t\t\t\t\t&& x >= leftBarrelCentreX - 25 && x <= leftBarrelCentreX + 25))) {\n\t\t\t\tleftBarrelNegativeY = 1;\n\t\t\t\tleftRight = 0;\n\t\t\t\tleftLeft = 0;\n\t\t\t\tleftTop = 1;\n\t\t\t\tleftBottom = 0;\n\t\t\t\tif (topBarrelRoundCompleted == false) {\n\t\t\t\t\ttopRight = 0;\n\t\t\t\t\ttopLeft = 0;\n\t\t\t\t\ttopBottom = 0;\n\t\t\t\t\ttopBarrelPositiveX = 0;\n\t\t\t\t\ttopBarrelNegativeX = 0;\n\t\t\t\t\ttopBarrelPositiveY = 0;\n\t\t\t\t\ttopBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (rightBarrelRoundCompleted == false) {\n\t\t\t\t\trightRight = 0;\n\t\t\t\t\trightleft = 0;\n\t\t\t\t\trightBottom = 0;\n\t\t\t\t\trightTop = 0;\n\t\t\t\t\trightBarrelPositiveX = 0;\n\t\t\t\t\trightBarrelNegativeX = 0;\n\t\t\t\t\trightBarrelPositiveY = 0;\n\t\t\t\t\trightBarrelNegativeY = 0;\n\t\t\t\t}\n\t\t\t\tif (leftBarrelNegativeX == 1\n\t\t\t\t\t\t|| (x < leftBarrelCentreX - 20\n\t\t\t\t\t\t\t\t&& y <= leftBarrelCentreY + 25 && y >= leftBarrelCentreY - 25)) {\n\t\t\t\t\tleftBarrelNegativeX = 1;\n\t\t\t\t\tif (leftBarrelPositiveY == 1\n\t\t\t\t\t\t\t|| (y > leftBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t&& y < mScrHeight - 170\n\t\t\t\t\t\t\t\t\t&& x >= leftBarrelCentreX - 25 && x <= leftBarrelCentreX + 25)) {\n\t\t\t\t\t\tleftBarrelPositiveY = 1;\n\t\t\t\t\t\tif (leftBarrelPositiveX == 1\n\t\t\t\t\t\t\t\t|| (x > leftBarrelCentreX + 20\n\t\t\t\t\t\t\t\t\t\t&& x < rightBarrelCentreX - 20\n\t\t\t\t\t\t\t\t\t\t&& y <= leftBarrelCentreY + 25 && y >= leftBarrelCentreY - 25)) {\n\t\t\t\t\t\t\tleftBarrelPositiveX = 1;\n\t\t\t\t\t\t\tif (y < leftBarrelCentreY - 20\n\t\t\t\t\t\t\t\t\t&& y > topBarrelCentreY + 20\n\t\t\t\t\t\t\t\t\t&& x >= leftBarrelCentreX - 25\n\t\t\t\t\t\t\t\t\t&& x <= leftBarrelCentreX + 25) {\n\t\t\t\t\t\t\t\tif (leftTop == 1) {\n\t\t\t\t\t\t\t\t\tleftBarrelRoundCompleted = true;\n\t\t\t\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (rightBarrelRoundCompleted == true // If All the Barrels, Circle is\n\t\t\t\t\t\t\t\t\t\t\t\t// completed\n\t\t\t\t&& leftBarrelRoundCompleted == true\n\t\t\t\t&& topBarrelRoundCompleted == true) {\n\t\t\tif (y > mScrHeight - 140) // Go BAck to Start line\n\t\t\t\tfinishFlag = true; // Below Start line\n\t\t\telse\n\t\t\t\tfinishFlag = false; // Above Start Line\n\t\t} else\n\t\t\tfinishFlag = false; // when Circles are not completed\n\t\treturn finishFlag;\n\t}", "@Override\n\tpublic boolean validMove(int xEnd, int yEnd, board b){\n\t\t//try to land one same color piece\n\t\tif(b.occupied(xEnd, yEnd)&&b.getPiece(xEnd, yEnd).getColor()==color){\n\t\t\treturn false;\n\t\t}\n\t\tif(v==0){\n\t\t\tif(!this.guard(xEnd, yEnd, b)){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t//normal move\n\t\tif((xEnd==x-1&&yEnd==y-1)||(xEnd==x-1&&yEnd==y)||(xEnd==x-1&&yEnd==y+1)||(xEnd==x&&yEnd==y-1)||(xEnd==x&&yEnd==y+1)||(xEnd==x+1&&yEnd==y-1)||(xEnd==x+1&&yEnd==y)||(xEnd==x+1&&yEnd==y+1)){\n\t\t\tif(b.occupied(xEnd, yEnd)){\n\t\t\t\t//set the enpass flage back\n\t\t\t\tb.setFlag(color, 100, 100);\n\t\t\t\tb.recycle(xEnd, yEnd);\n\t\t\t\tthis.setPosition(xEnd, yEnd);\n\t\t\t\tb.update();\n\t\t\t\tc=0;\n\t\t\t\treturn true;\n\t\t\t}else{\n\t\t\t\t//set the enpass flage back\n\t\t\t\tb.setFlag(color, 100, 100);\n\t\t\t\tthis.setPosition(xEnd, yEnd);\n\t\t\t\tb.update();\n\t\t\t\tc=0;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}else if((xEnd==x-2&&yEnd==y)){ //castling\n\t\t\tpiece r = b.getPiece(0, y);\n\t\t\tif(r==null){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif(r.getC()==0||r.getColor()!=color||r.getType()!= type.ROOK||c==0){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tfor(int i=3;i>0;i--){\n\t\t\t\tif(b.occupied(i, y)){\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.setPosition(xEnd, yEnd);\n\t\t\tr.setPosition(3,y);\n\t\t\tc=0;\n\t\t\tr.setC(0);\n\t\t\tb.setFlag(color, 100, 100);\n\t\t\tb.update();\n\t\t\treturn true;\n\t\t}else if((xEnd==x+2&&yEnd==y)){\n\t\t\tpiece r = b.getPiece(7, y);\n\t\t\tif(r==null){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif(r.getC()==0||r.getColor()!=color||r.getType()!= type.ROOK||c==0){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tfor(int i=5;i<=6;i++){\n\t\t\t\tif(b.occupied(i, y)){\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.setPosition(xEnd, yEnd);\n\t\t\tr.setPosition(5,y);\n\t\t\tc=0;\n\t\t\tr.setC(0);\n\t\t\tb.setFlag(color, 100, 100);\n\t\t\tb.update();\n\t\t\treturn true;\n\t\t}else{\n\t\t\treturn false;\n\t\t}\n\t}", "public void checkForGearShift() {\n boolean shiftHi = Robot.leftJoystick.getRawButton(HI_SHIFTER);\n boolean shiftLo = Robot.leftJoystick.getRawButton(LO_SHIFTER);\n\n if (shiftHi) {\n currentGear = Gear.HI;\n if (shiftInit) {\n shiftTimer.setTimer(Constants.SHIFT_TIME);\n shiftInit = false;\n }\n if (shiftTimer.isExpired()) {\n isShifting = false;\n shiftInit = true;\n } else {\n isShifting = true;\n }\n gearShifter.set(Constants.HI_GEAR_VALUE);\n } else if (shiftLo) {\n currentGear = Gear.LO;\n if (shiftInit) {\n shiftTimer.setTimer(Constants.SHIFT_TIME);\n shiftInit = false;\n }\n if (shiftTimer.isExpired()) {\n isShifting = false;\n shiftInit = true;\n } else {\n isShifting = true;\n }\n gearShifter.set(Constants.LO_GEAR_VALUE);\n } else {\n isShifting = false;\n }\n\n }", "private Cell getBananaTarget() {\n Cell[][] blocks = gameState.map;\n int mostWormInRange = 0;\n Cell chosenCell = null;\n boolean wormAtCenter;\n\n for (int i = currentWorm.position.x - currentWorm.bananaBomb.range; i <= currentWorm.position.x + currentWorm.bananaBomb.range; i++){\n for (int j = currentWorm.position.y - currentWorm.bananaBomb.range; j <= currentWorm.position.y + currentWorm.bananaBomb.range; j++){\n wormAtCenter = false;\n if (isValidCoordinate(i, j)\n && euclideanDistance(i, j, currentWorm.position.x, currentWorm.position.y) <= 5) {\n List<Cell> affectedCells = getBananaAffectedCell(i, j);\n\n int wormInRange = 0;\n for (Cell cell : affectedCells) {\n for (Worm enemyWorm : opponent.worms) {\n if (enemyWorm.position.x == cell.x && enemyWorm.position.y == cell.y\n && enemyWorm.health > 0)\n wormInRange++;\n if (enemyWorm.position.x == i && enemyWorm.position.y == j)\n wormAtCenter = true;\n }\n for (Worm myWorm : player.worms) {\n if (myWorm.position.x == cell.x && myWorm.position.y == cell.y && myWorm.health > 0)\n wormInRange = -5;\n }\n }\n if (wormInRange > mostWormInRange) {\n mostWormInRange = wormInRange;\n chosenCell = blocks[j][i];\n } else if (wormInRange == mostWormInRange && wormAtCenter) {\n chosenCell = blocks[j][i];\n }\n }\n }\n }\n\n return chosenCell;\n }", "pieces getPiece(int position)\n {\n int j ;\n if(position == whiteHorse1.position && whiteHorse1.alive == true ) return whiteHorse1;\n if(position == whiteHorse2.position && whiteHorse2.alive == true) return whiteHorse2;\n if(position == whiteQueen.position && whiteQueen.alive == true ) return whiteQueen;\n if(position == whiteKing.position && whiteKing.alive == true) return whiteKing;\n if(position == whiteCastle1.position && whiteCastle1.alive == true ) return whiteCastle1;\n if(position == whiteCastle2.position && whiteCastle2.alive == true) return whiteCastle2;\n if(position == whiteBishop1.position && whiteBishop1.alive == true) return whiteBishop1;\n if(position == whiteBishop2.position && whiteBishop2.alive == true) return whiteBishop2;\n j=0;\n if(position == whitePawn[j].position && whitePawn[j].alive == true) return whitePawn[j];j++;\n if(position == whitePawn[j].position && whitePawn[j].alive == true) return whitePawn[j];j++;\n if(position == whitePawn[j].position && whitePawn[j].alive == true) return whitePawn[j];j++;\n if(position == whitePawn[j].position && whitePawn[j].alive == true) return whitePawn[j];j++;\n if(position == whitePawn[j].position && whitePawn[j].alive == true) return whitePawn[j];j++;\n if(position == whitePawn[j].position && whitePawn[j].alive == true) return whitePawn[j];j++;\n if(position == whitePawn[j].position && whitePawn[j].alive == true) return whitePawn[j];j++;\n if(position == whitePawn[j].position && whitePawn[j].alive == true) return whitePawn[j];\n \n \n \n if(position == blackHorse1.position && blackHorse1.alive == true ) return blackHorse1;\n if(position == blackHorse2.position && blackHorse2.alive == true) return blackHorse2;\n if(position == blackQueen.position && blackQueen.alive == true ) return blackQueen;\n if(position == blackKing.position && blackKing.alive == true) return blackKing;\n if(position == blackCastle1.position && blackCastle1.alive == true ) return blackCastle1;\n if(position == blackCastle2.position && blackCastle2.alive == true) return blackCastle2;\n if(position == blackBishop1.position && blackBishop1.alive == true) return blackBishop1;\n if(position == blackBishop2.position && blackBishop2.alive == true) return blackBishop2;\n j=0;\n if(position == blackPawn[j].position && blackPawn[j].alive == true) return blackPawn[j];j++;\n if(position == blackPawn[j].position && blackPawn[j].alive == true) return blackPawn[j];j++;\n if(position == blackPawn[j].position && blackPawn[j].alive == true) return blackPawn[j];j++;\n if(position == blackPawn[j].position && blackPawn[j].alive == true) return blackPawn[j];j++;\n if(position == blackPawn[j].position && blackPawn[j].alive == true) return blackPawn[j];j++;\n if(position == blackPawn[j].position && blackPawn[j].alive == true) return blackPawn[j];j++;\n if(position == blackPawn[j].position && blackPawn[j].alive == true) return blackPawn[j];j++;\n if(position == blackPawn[j].position && blackPawn[j].alive == true) return blackPawn[j];\n\n else return null;\n }", "private Move produceHeuristicMove(Board board){\n\n\t\tint numRows = board.getNumberOfRows();\n\t\tint[][] bins = new int[numRows][BINARY_LENGTH];\n\t\tint[] binarySum = new int[BINARY_LENGTH];\n\t\tint bitIndex,higherThenOne=0,totalOnes=0,lastRow=0,lastLeft=0,lastSize=0,lastOneRow=0,lastOneLeft=0;\n\t\t\n\t\tfor(bitIndex = 0;bitIndex<BINARY_LENGTH;bitIndex++){\n\t\t\tbinarySum[bitIndex] = 0;\n\t\t}\n\t\t\n\t\tfor(int k=0;k<numRows;k++){\n\t\t\t\n\t\t\tint curRowLength = board.getRowLength(k+1);\n\t\t\tint i = 0;\n\t\t\tint numOnes = 0;\n\t\t\t\n\t\t\tfor(bitIndex = 0;bitIndex<BINARY_LENGTH;bitIndex++){\n\t\t\t\tbins[k][bitIndex] = 0;\n\t\t\t}\n\t\t\t\n\t\t\tdo {\n\t\t\t\tif(i<curRowLength && board.isStickUnmarked(k+1,i+1) ){\n\t\t\t\t\tnumOnes++;\n\t\t\t\t} else {\n\t\t\t\t\t\n\t\t\t\t\tif(numOnes>0){\n\t\t\t\t\t\t\n\t\t\t\t\t\tString curNum = Integer.toBinaryString(numOnes);\n\t\t\t\t\t\twhile(curNum.length()<BINARY_LENGTH){\n\t\t\t\t\t\t\tcurNum = \"0\" + curNum;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor(bitIndex = 0;bitIndex<BINARY_LENGTH;bitIndex++){\n\t\t\t\t\t\t\tbins[k][bitIndex] += curNum.charAt(bitIndex)-'0'; //Convert from char to int\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tif(numOnes>1){\n\t\t\t\t\t\t\thigherThenOne++;\n\t\t\t\t\t\t\tlastRow = k +1;\n\t\t\t\t\t\t\tlastLeft = i - numOnes + 1;\n\t\t\t\t\t\t\tlastSize = numOnes;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttotalOnes++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlastOneRow = k+1;\n\t\t\t\t\t\tlastOneLeft = i;\n\t\t\t\t\t\t\n\t\t\t\t\t\tnumOnes = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ti++;\n\t\t\t}while(i<=curRowLength);\n\t\t\t\n\t\t\tfor(bitIndex = 0;bitIndex<BINARY_LENGTH;bitIndex++){\n\t\t\t\tbinarySum[bitIndex] = (binarySum[bitIndex]+bins[k][bitIndex])%2;\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\t//We only have single sticks\n\t\tif(higherThenOne==0){\n\t\t\treturn new Move(lastOneRow,lastOneLeft,lastOneLeft);\n\t\t}\n\t\t\n\t\t//We are at a finishing state\t\t\t\t\n\t\tif(higherThenOne<=1){\n\t\t\t\n\t\t\tif(totalOnes == 0){\n\t\t\t\treturn new Move(lastRow,lastLeft,lastLeft+(lastSize-1) - 1);\n\t\t\t} else {\n\t\t\t\treturn new Move(lastRow,lastLeft,lastLeft+(lastSize-1)-(1-totalOnes%2));\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\tfor(bitIndex = 0;bitIndex<BINARY_LENGTH-1;bitIndex++){\n\t\t\t\n\t\t\tif(binarySum[bitIndex]>0){\n\t\t\t\t\n\t\t\t\tint finalSum = 0,eraseRow = 0,eraseSize = 0,numRemove = 0;\n\t\t\t\tfor(int k=0;k<numRows;k++){\n\t\t\t\t\t\n\t\t\t\t\tif(bins[k][bitIndex]>0){\n\t\t\t\t\t\teraseRow = k+1;\n\t\t\t\t\t\teraseSize = (int)Math.pow(2,BINARY_LENGTH-bitIndex-1);\n\t\t\t\t\t\t\n\t\t\t\t\t\tfor(int b2 = bitIndex+1;b2<BINARY_LENGTH;b2++){\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif(binarySum[b2]>0){\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tif(bins[k][b2]==0){\n\t\t\t\t\t\t\t\t\tfinalSum = finalSum + (int)Math.pow(2,BINARY_LENGTH-b2-1);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tfinalSum = finalSum - (int)Math.pow(2,BINARY_LENGTH-b2-1);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tnumRemove = eraseSize - finalSum;\n\t\t\t\t\n\t\t\t\t//Now we find that part and remove from it the required piece\n\t\t\t\tint numOnes=0,i=0;\n\t\t\t\twhile(numOnes<eraseSize){\n\n\t\t\t\t\tif(board.isStickUnmarked(eraseRow,i+1)){\n\t\t\t\t\t\tnumOnes++;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnumOnes=0;\n\t\t\t\t\t}\n\t\t\t\t\ti++;\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\treturn new Move(eraseRow,i-numOnes+1,i-numOnes+numRemove);\n\t\t\t}\n\t\t}\n\t\t\n\t\t//If we reached here, and the board is not symmetric, then we only need to erase a single stick\n\t\tif(binarySum[BINARY_LENGTH-1]>0){\n\t\t\treturn new Move(lastOneRow,lastOneLeft,lastOneLeft);\n\t\t}\n\t\t\n\t\t//If we reached here, it means that the board is already symmetric, and then we simply mark one stick from the last sequence we saw:\n\t\treturn new Move(lastRow,lastLeft,lastLeft);\t\t\n\t}", "private static void addBishopMoves(BitBoard board, LinkedList<Move> moveList, int index,\n\t\t\tint side) {\n\t\tint pieceType = (side == 0) ? CoreConstants.WHITE_BISHOP : CoreConstants.BLACK_BISHOP;\n\t\tlong bishopBlockers = (board.getBitBoards()[CoreConstants.WHITE]\n\t\t\t\t| board.getBitBoards()[CoreConstants.BLACK])\n\t\t\t\t& CoreConstants.occupancyMaskBishop[index];\n\t\tint lookupIndex = (int) ((bishopBlockers\n\t\t\t\t* CoreConstants.magicNumbersBishop[index]) >>> CoreConstants.magicShiftBishop[index]);\n\t\tlong moveSquares = CoreConstants.magicMovesBishop[index][lookupIndex]\n\t\t\t\t& ~board.getBitBoards()[side];\n\t\taddMoves(pieceType, index, moveSquares, moveList, false, false, CoreConstants.noCastle);\n\t}", "private boolean reelIn()\n {\n final Point mouse = MouseInfo.getPointerInfo().getLocation();\n final long START_TS = System.currentTimeMillis(), GIVE_UP_TS = 26000;\n final int CPU_DELAY = 25;\n /* If the user moves his mouse, then we will still have memory of the right coordinates. */\n final int MOUSE_X = mouse.x, MOUSE_Y = mouse.y;\n\n /* Determine how much blue there WAS at the start of this cycle. */\n final double ctrlBlue = Tools.avgBlueProximity(MOUSE_X, MOUSE_Y);\n\n /* As long as the in-game cast is still going, there's hope of catching the fish. */\n while (!interrupted && !Tools.timePassed(START_TS, GIVE_UP_TS))\n {\n /* Sleep to prevent max-CPU usage. */\n Tools.sleep(CPU_DELAY);\n /* Find the average blue where the mouse is */\n final double avgBlue = Tools.avgBlueProximity(MOUSE_X, MOUSE_Y);\n final double diff = Math.abs(ctrlBlue - avgBlue);\n if (Controller.debugMode.get())\n Controller.sendMessage(Lang.EN_DEBUG_COLOR_THRESH.replaceFirst(\"%1\",\n String.format(\"%.2f\", diff))\n .replaceFirst(\"%2\", String.format(\"%.2f\", sensitivityProperty.get())));\n\n /* If the difference in blue changed enough, the bobber just splashed! */\n if (Math.abs(ctrlBlue - avgBlue) >= sensitivityProperty.get())\n {\n /* Shift right click to loot the fish. */\n Tools.bot.mouseMove(MOUSE_X, MOUSE_Y);\n Tools.bot.keyPress(KeyEvent.VK_SHIFT);\n Tools.bot.mousePress(InputEvent.BUTTON3_DOWN_MASK);\n Tools.bot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK);\n Tools.bot.keyRelease(KeyEvent.VK_SHIFT);\n return true;\n }\n }\n\n return false;\n }", "public int TakeStep()\n\t\t{\n\t\t// the eventual movement command is placed here\n\t\tVec2\tresult = new Vec2(0,0);\n\n\t\t// get the current time for timestamps\n\t\tlong\tcurr_time = abstract_robot.getTime();\n\n\n\t\t/*--- Get some sensor data ---*/\n\t\t// get vector to the ball\n\t\tVec2 ball = abstract_robot.getBall(curr_time);\n\n\t\t// get vector to our and their goal\n\t\tVec2 ourgoal = abstract_robot.getOurGoal(curr_time);\n\t\tVec2 theirgoal = abstract_robot.getOpponentsGoal(curr_time);\n\n\t\t// get a list of the positions of our teammates\n\t\tVec2[] teammates = abstract_robot.getTeammates(curr_time);\n\n\t\t// find the closest teammate\n\t\tVec2 closestteammate = new Vec2(99999,0);\n\t\tfor (int i=0; i< teammates.length; i++)\n\t\t\t{\n\t\t\tif (teammates[i].r < closestteammate.r)\n\t\t\t\tclosestteammate = teammates[i];\n\t\t\t}\n\n\n\t\t/*--- now compute some strategic places to go ---*/\n\t\t// compute a point one robot radius\n\t\t// behind the ball.\n\t\tVec2 kickspot = new Vec2(ball.x, ball.y);\n\t\tkickspot.sub(theirgoal);\n\t\tkickspot.setr(abstract_robot.RADIUS);\n\t\tkickspot.add(ball);\n\n\t\t// compute a point three robot radii\n\t\t// behind the ball.\n\t\tVec2 backspot = new Vec2(ball.x, ball.y);\n\t\tbackspot.sub(theirgoal);\n\t\tbackspot.setr(abstract_robot.RADIUS*5);\n\t\tbackspot.add(ball);\n\n\t\t// compute a north and south spot\n\t\tVec2 northspot = new Vec2(backspot.x,backspot.y+0.7);\n\t\tVec2 southspot = new Vec2(backspot.x,backspot.y-0.7);\n\n\t\t// compute a position between the ball and defended goal\n\t\tVec2 goaliepos = new Vec2(ourgoal.x + ball.x,\n\t\t\t\tourgoal.y + ball.y);\n\t\tgoaliepos.setr(goaliepos.r*0.5);\n\n\t\t// a direction away from the closest teammate.\n\t\tVec2 awayfromclosest = new Vec2(closestteammate.x,\n\t\t\t\tclosestteammate.y);\n\t\tawayfromclosest.sett(awayfromclosest.t + Math.PI);\n\n\n\t\t/*--- go to one of the places depending on player num ---*/\n\t\tint mynum = abstract_robot.getPlayerNumber(curr_time);\n\n\t\t/*--- Goalie ---*/\n\t\tif (mynum == 0)\n\t\t\t{\n\t\t\t// go to the goalie position if far from the ball\n\t\t\tif (ball.r > 0.5) \n\t\t\t\tresult = goaliepos;\n\t\t\t// otherwise go to kick it\n\t\t\telse if (ball.r > 0.1) \n\t\t\t\tresult = kickspot;\n\t\t\telse \n\t\t\t\tresult = ball;\n\t\t\t// keep away from others\n\t\t\tif (closestteammate.r < 0.3)\n\t\t\t\t{\n\t\t\t\tresult = awayfromclosest;\n\t\t\t\t}\n\t\t\t}\n\n\t\t/*--- midback ---*/\n\t\telse if (mynum == 1)\n\t\t\t{\n\t\t\t// go to a midback position if far from the ball\n\t\t\tif (ball.r > 0.5) \n\t\t\t\tresult = backspot;\n\t\t\t// otherwise go to kick it\n\t\t\telse if (ball.r > 0.30) \n\t\t\t\tresult = kickspot;\n\t\t\telse \n\t\t\t\tresult = ball;\n\t\t\t// keep away from others\n\t\t\tif (closestteammate.r < 0.3)\n\t\t\t\t{\n\t\t\t\tresult = awayfromclosest;\n\t\t\t\t}\n\t\t\t}\n\n\t\telse if (mynum == 2)\n\t\t\t{\n\t\t\t// go to a the northspot position if far from the ball\n\t\t\tif (ball.r > 0.5) \n\t\t\t\tresult = northspot;\n\t\t\t// otherwise go to kick it\n\t\t\telse if (ball.r > 0.30) \n\t\t\t\tresult = kickspot;\n\t\t\telse \n\t\t\t\tresult = ball;\n\t\t\t// keep away from others\n\t\t\tif (closestteammate.r < 0.3)\n\t\t\t\t{\n\t\t\t\tresult = awayfromclosest;\n\t\t\t\t}\n\t\t\t}\n\n\t\telse if (mynum == 4)\n\t\t\t{\n\t\t\t// go to a the northspot position if far from the ball\n\t\t\tif (ball.r > 0.5) \n\t\t\t\tresult = southspot;\n\t\t\t// otherwise go to kick it\n\t\t\telse if (ball.r > 0.3 )\n\t\t\t\tresult = kickspot;\n\t\t\telse \n\t\t\t\tresult = ball;\n\t\t\t// keep away from others\n\t\t\tif (closestteammate.r < 0.3)\n\t\t\t\t{\n\t\t\t\tresult = awayfromclosest;\n\t\t\t\t}\n\t\t\t}\n\n\t\t/*---Lead Forward ---*/\n\t\telse if (mynum == 3)\n\t\t\t{\n\t\t\t// if we are more than 4cm away from the ball\n\t\t\tif (ball.r > .3)\n\t\t\t\t// go to a good kicking position\n\t\t\t\tresult = kickspot;\n\t\t\telse\n\t\t\t\t// go to the ball\n\t\t\t\tresult = ball;\n\t\t\t}\n\n\n\t\t/*--- Send commands to actuators ---*/\n\t\t// set the heading\n\t\tabstract_robot.setSteerHeading(curr_time, result.t);\n\n\t\t// set speed at maximum\n\t\tabstract_robot.setSpeed(curr_time, 1.0);\n\n\t\t// kick it if we can\n\t\tif (abstract_robot.canKick(curr_time))\n\t\t\tabstract_robot.kick(curr_time);\n\n\t\t/*--- Send message to other robot ---*/\n\t\t// COMMUNICATION\n\t\t// if I can kick\n\t\tif (abstract_robot.canKick(curr_time))\n\t\t\t{\n\t\t\t// and I am robot #3\n\t\t\tif ((mynum==3))\n\t\t\t\t{\n\t\t\t\t// construct a message\n\t\t\t\tStringMessage m = new StringMessage();\n\t\t\t\tm.val = (new Integer(mynum)).toString();\n\t\t\t\tm.val = m.val.concat(\" can kick\");\n\n\t\t\t\t// send the message to robot 2\n\t\t\t\t// note: broadcast and multicast are also\n\t\t\t\t// available.\n\t\t\t\ttry{abstract_robot.unicast(2,m);}\n\t\t\t\tcatch(CommunicationException e){}\n\t\t\t\t}\n\t\t\t}\n\n\t\t/*--- Look for incoming messages ---*/\n\t\t//COMMUNICATION\n\t\twhile (messagesin.hasMoreElements())\n\t\t\t{\n\t\t\tStringMessage recvd = \n\t\t\t\t(StringMessage)messagesin.nextElement();\n\t\t\tSystem.out.println(mynum + \" received:\\n\" + recvd);\n\t\t\t}\n\n\t\t// tell the parent we're OK\n\t\treturn(CSSTAT_OK);\n\t\t}", "public void moveBoss() {\n\t\tdouble position = boss.getTranslateY();\n\t\tspeed = Math.random()*30;\n\t\tif(position > 600-70) {\n\t\t\tRandom r = new Random();\n\t\t\tboss.setTranslateY(-6);\n\t\t\tboss.setTranslateX(r.nextInt(900));\n\t\t}else {\n\t\tboss.setTranslateY(position + speed);\n\t\t}\n\t}", "public void bottomTopCheck() {\n bLCollide = false;\n bRCollide = false;\n tLCollide = false;\n tRCollide = false;\n if(grounded) {\n bottomCollision(); \n }\n else if(!grounded) {\n if(ySpeed > 0 || Math.abs(xSpeed) > Math.abs(ySpeed)) {\n bottomCollision(); \n }\n else if(ySpeed < 0 || Math.abs(xSpeed) > Math.abs(ySpeed)) {\n topCollision();\n }\n }\n }", "boolean moveBlack(int piece) {\n\t\treturn ((piece == 2 || piece == 4) && curPlayer == 2);\n\t}", "public void movement2()\n\t{\n\t\tballoon6Y = balloon6Y + speedBalloonY1;\n\t\tif(balloon6Y > 700)\n\t\t{\n\t\t\tballoon6Y = -100;\n\t\t\tballoon6X = (gen.nextInt(900)-75);\n\t\t}\n\t\tballoon7Y = balloon7Y + speedBalloonY2;\n\t\tif(balloon7Y > 700)\n\t\t{\n\t\t\tballoon7Y = -100;\n\t\t\tballoon7X = (gen.nextInt(900)-75);\n\t\t}\n\t\tballoon8Y = balloon8Y + speedBalloonY3;\n\t\tif(balloon8Y > 700)\n\t\t{\n\t\t\tballoon8Y = -100;\n\t\t\tballoon8X = (gen.nextInt(900)-75);\n\t\t}\n\t\tballoon9Y = balloon9Y + speedBalloonY4;\n\t\tif(balloon9Y > 700)\n\t\t{\n\t\t\tballoon9Y = -100;\n\t\t\tballoon9X = (gen.nextInt(900)-75);\n\t\t}\n\t\tballoon10Y = balloon10Y + speedBalloonY5;\n\t\tif(balloon10Y > 700)\n\t\t{\n\t\t\tballoon10Y = -100;\n\t\t\tballoon10X = (gen.nextInt(900)-75);\n\t\t}\n\t}", "public void explode(int min_pieces/* > 0 */, int max_pieces, double blastPower) {\n\t\t\n\t\tdouble blastPowerRandomness = .4;\n\n//\t\tfor (Point2D.Double p: disp.shape.points) {\n\t\tint s = disp.shape.points.size();\n\t\tfor (int i = 0; i < s; i++) {\n//\t\t\tPoint2D.Double p1 = disp.shape.points.get(i), p2 = disp.shape.points.get(i%s);\n\t\t\t//final int nbDebs = Math.random() > .5? 1: 2;\n//\t\t\tfinal int nbDebs = Util.rand.nextInt(max_pieces)+min_pieces;\n\t\t\tint nbDebs = Util.rand.nextInt(max_pieces)+min_pieces;\n\n//\t\t\tCoord.View prevPt = model().position();\n//\t\t\tCoord.View prevPt = new Coord(p1).view();\n//\t\t\tfinal Coord.View endPt = new Coord(p2).view();\n\n\t\t\tCoord.View prevPt = new Coord(disp.shape.points.get(i)).addedTo(model().position()).view();\n\t\t\tfinal Coord.View endPt = new Coord(disp.shape.points.get((i+1)%s)).addedTo(model().position()).view();\n\n\t\t\t\n//\t\t\tSystem.out.println(prevPt.distanceTo(endPt));\n//\t\t\tnbDebs = (prevPt.distanceTo(endPt) > 0.05)? 1: 2; // FIXME: doesn't work?\n\t\t\tnbDebs = 1;\n\t\t\t\n\t\t\tint nbDebsRemaining = nbDebs;\n\t\t\t\n\t\t\tfor (int j = 0; j < nbDebs; j++) {\n//\t\t\t\tCoord.View bary = Coord.barycenter(prevPt, endPt, ((double)j+1)/(nbDebs)).view();\n\t\t\t\tCoord.View bary = Coord.barycenter(prevPt, endPt, ((double)1)/(nbDebsRemaining)).view();\n\t\t\t\t\n\t\t\t\t//double blastPower = .003; // .005;\n\t\t\t\t\n\t\t\t\tCoord blast = prevPt.addedTo(model().position(), -1);\n\t\t\t\tblast.mult(blastPower/blast.norm() * (1 - blastPowerRandomness/2 + blastPowerRandomness * Math.random()));\n//\t\t\t\tUnique<Coord> inertia = model().speedVector();\n\t\t\t\tCoord.Unique inertia = new Coord.Unique(model().speedVector());\n\t\t\t\tinertia.mult(.5); // .5 ??? otherwise it's 2x too fast...\n\t\t\t\tinertia.add(blast.view());\n\t\t\t\tsim.addEntity(new Debris(\n\t\t\t\t\t\tsim,\n\t\t\t\t\t\tprevPt,\n\t\t\t\t\t\tbary,\n\t\t\t\t\t\tinertia,\n\t\t\t\t\t\tmodel.ownerId()\n\t\t\t\t));\n\t\t\t\tprevPt = bary;\n\t\t\t\tnbDebsRemaining--;\n\t\t\t}\n\t\t\t\n//\t\t\tfinal Coord.View begPt = new Coord(disp.shape.points.get(i)).addedTo(model().position()).view();\n//\t\t\tfinal Coord.View endPt = new Coord(disp.shape.points.get((i+1)%s)).addedTo(model().position()).view();\n//\t\t\tfor (int j = 0; j < nbDebs; j++) {\n//\t\t\t\tsim.addEntity(new Debris(\n//\t\t\t\t\t\tsim,\n//\t\t\t\t\t\tbegPt,\n//\t\t\t\t\t\tCoord.barycenter(begPt, endPt, ((double)j+1)/(nbDebs)).view(),\n//\t\t\t\t\t\tmodel().speedVector(),\n//\t\t\t\t\t\tmodel.ownerId()\n//\t\t\t\t));\n//\t\t\t}\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t}\n\t\t\n\t}", "@Test\n public void blackOnBarGettingBack() {\n\n game.move(Location.R1, Location.R3);\n game.move(Location.R3, Location.R4);\n game.nextTurn();\n assertTrue(game.move(Location.R6, Location.R4));\n assertEquals(1, game.getCount(Location.B_BAR));\n assertEquals(Color.RED, game.getColor(Location.R4));\n\n assertTrue(game.move(Location.R6, Location.R5));\n game.nextTurn();\n assertFalse(game.move(Location.R1, Location.R2));\n assertTrue(game.move(Location.B_BAR, Location.R3));\n assertTrue(game.move(Location.R1, Location.R5));\n }", "public boolean move(int x, int y, CheckersBoard board) {\n if (whiteTurn == true && team == Constants.TeamId.team1Id) {\n return false;\n }\n if (whiteTurn == false && team == Constants.TeamId.team2Id) {\n return false;\n }\n /**\n * then change the x - y coords of the piece\n * update the UI to remove the highlighted squares then move the piece\n * if chess and shared square you take a piece\n * if checkers you jumped them you take the piece\n * return new x - y components\n *\n * if this is too high up in the tree you can override this implementation or update it\n * to fit specific pieces if its not working for some reason\n */\n if (possible(x, y, gameBoard)) {\n int changex = this.getX()-x;\n int changey = this.getY()-y;\n CheckersPiece temp = gameBoard.boardPositions[getX()][getY()];\n gameBoard.boardPositions[getX()][getY()] = null;\n gameBoard.boardPositions[x][y] = temp;\n if (gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2] != null) {\n System.out.println(\"Here\");\n if (gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2].team != this.team) {\n gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2].imageView.setVisibility(View.GONE);\n gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2] = null;\n }\n }\n this.setX(x);\n this.setY(y);/*\n if (Math.abs(changex) == 2) {\n gameBoard.boardPositions[x + (changex/2)][y + (changey/2)] = null;\n if (team == Constants.TeamId.team1Id) {\n board.numPieces1--;\n } else if (team == Constants.TeamId.team2Id) {\n board.numPieces0--;\n }\n }*/\n\n gameBoard.boardPositions[x][y].imageView.setX(142*x);\n gameBoard.boardPositions[x][y].imageView.setY(142*y);\n // flips after move is\n whiteTurn = !whiteTurn;\n gameBoard.startTimer();\n }\n //setUpUI(gameBoard);\n if (getY() == 7 && team == Constants.TeamId.team2Id) {\n board.crown(this);\n }\n if (getY() == 0 && team == Constants.TeamId.team1Id) {\n board.crown(this);\n }\n return possible(x, y, gameBoard);\n }", "public int move () {\n intMoveState = 0;\r\n int pixel1;\r\n int pixel2;\r\n \r\n if (blnUp) {\r\n pixel1 = getPixelRGB (X - 25, Y + 10, \"r\");\r\n pixel2 = getPixelRGB (X + 25, Y + 10, \"r\");\r\n \r\n if (pixel1 != 0 && pixel2 != 0) { \r\n Y -= intSpeed;\r\n intMoveState -= 1;\r\n }\r\n }\r\n if (blnDown) {\r\n pixel1 = getPixelRGB (X - 25, Y + 46, \"r\");\r\n pixel2 = getPixelRGB (X + 25, Y + 46, \"r\");\r\n \r\n if (pixel1 != 0 && pixel2 != 0) { \r\n Y += intSpeed;\r\n intMoveState += 1;\r\n }\r\n }\r\n if (blnLeft) {\r\n pixel1 = getPixelRGB (X - 30, Y + 15, \"r\");\r\n pixel2 = getPixelRGB (X - 30, Y + 30, \"r\");\r\n \r\n if (pixel1 != 0 && pixel2 != 0) { \r\n X -= intSpeed;\r\n intMoveState -= 2;\r\n }\r\n }\r\n if (blnRight) {\r\n pixel1 = getPixelRGB (X + 30, Y + 15, \"r\");\r\n pixel2 = getPixelRGB (X + 30, Y + 30, \"r\");\r\n \r\n if (pixel1 != 0 && pixel2 != 0) { \r\n X += intSpeed;\r\n intMoveState += 2;\r\n }\r\n }\r\n \r\n try {\r\n dblAngle = Math.atan2((MouseY - Y),(MouseX - X));\r\n if (dblAngle < - Math.PI/4) {\r\n dblAngle = 2 * Math.PI + dblAngle;\r\n }\r\n }catch (ArithmeticException e) {\r\n if (MouseY < Y) {\r\n dblAngle = 3 * Math.PI/2;\r\n }else {\r\n dblAngle = Math.PI/2;\r\n }\r\n }\r\n degreesAngle = (int) (Math.toDegrees(dblAngle)); \r\n \r\n if(intHealth < 0 && !UserInterface.deathScreenVisible){\r\n UserInterface.deathScreenVisible = true;\r\n deathTime = System.nanoTime();\r\n ClientMain.ssm.sendText(\"player,\" + ClientMain.intPlayerNumber + \",iamdeadlol\");\r\n }\r\n \r\n return getPixelRGB (X, Y + 46, \"g\");\r\n }", "private boolean possible(){\n\t\tboolean psb = false;\n\t\tswitch(direction){\n\t\t\tcase RIGHT:\n\t\t\t\tif(hash_matrix.containsKey(x+1 + y*row_length)){\n\t\t\t\t\tpsb = true;\n\t\t\t\t}else if(hash_matrix.containsKey(x + (y+1)*row_length)){\n\t\t\t\t\tdirection = DOWN;\n\t\t\t\t\tpsb = true;\n\t\t\t\t}else if(hash_matrix.containsKey(x + (y-1)*row_length)){\n\t\t\t\t\tdirection = UP;\n\t\t\t\t\tpsb = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase LEFT:\n\t\t\t\tif(hash_matrix.containsKey(x - 1 + y*row_length)){\n\t\t\t\t\tpsb = true;\n\t\t\t\t}else if(hash_matrix.containsKey(x + (y+1)*row_length)){\n\t\t\t\t\tdirection = DOWN;\n\t\t\t\t\tpsb = true;\n\t\t\t\t}else if(hash_matrix.containsKey(x + (y-1)*row_length)){\n\t\t\t\t\tdirection = UP;\n\t\t\t\t\tpsb = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase UP:\n\t\t\t\tif(hash_matrix.containsKey(x + (y-1)*row_length)){\n\t\t\t\t\tpsb = true;\n\t\t\t\t}else if(hash_matrix.containsKey(x + 1 + (y)*row_length)){\n\t\t\t\t\tdirection = RIGHT;\n\t\t\t\t\tpsb = true;\n\t\t\t\t}else if(hash_matrix.containsKey(x - 1 + (y)*row_length)){\n\t\t\t\t\tdirection = LEFT;\n\t\t\t\t\tpsb = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase DOWN:\n\t\t\t\tif(hash_matrix.containsKey(x + (y+1)*row_length)){\n\t\t\t\t\tpsb = true;\n\t\t\t\t}else if(hash_matrix.containsKey(x + 1 + y*row_length)){\n\t\t\t\t\tdirection = RIGHT;\n\t\t\t\t\tpsb = true;\n\t\t\t\t}else if(hash_matrix.containsKey(x - 1 + (y)*row_length)){\n\t\t\t\t\tdirection = LEFT;\n\t\t\t\t\tpsb = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t\tsteps++;\t\t\t//last step that will generate false also needs to be counted\n\t\treturn psb;\n\t}", "private Player checkIfEatsBluePlayer(Player player)\n {\n int x_cord = getMidPoint(player.x_cordinate);\n int y_cord = getMidPoint(player.y_cordinate);\n int blux1 = getMidPoint(ludo.getBluePlayer1().x_cordinate);\n int blux2 = getMidPoint(ludo.getBluePlayer2().x_cordinate);\n int blux3 = getMidPoint(ludo.getBluePlayer3().x_cordinate);\n int blux4 = getMidPoint(ludo.getBluePlayer4().x_cordinate);\n int bluy1 = getMidPoint(ludo.getBluePlayer1().y_cordinate);\n int bluy2 = getMidPoint(ludo.getBluePlayer2().y_cordinate);\n int bluy3 = getMidPoint(ludo.getBluePlayer3().y_cordinate);\n int bluy4 = getMidPoint(ludo.getBluePlayer4().y_cordinate);\n if (collisionDetection(x_cord, y_cord, blux1, bluy1) == 1)\n {\n return blue_player1;\n }\n else if (collisionDetection(x_cord, y_cord, blux2, bluy2) == 1)\n {\n return blue_player2;\n }\n else if (collisionDetection(x_cord, y_cord, blux3, bluy3) == 1)\n {\n return blue_player3;\n }\n else if (collisionDetection(x_cord, y_cord, blux4, bluy4) == 1)\n {\n return blue_player4;\n }\n else\n {\n return null;\n }\n }", "public void processMove(MahjongSolitaireMove move)\n {\n // REMOVE THE MOVE TILES FROM THE GRID\n ArrayList<MahjongSolitaireTile> stack1 = tileGrid[move.col1][move.row1];\n ArrayList<MahjongSolitaireTile> stack2 = tileGrid[move.col2][move.row2]; \n MahjongSolitaireTile tile1 = stack1.remove(stack1.size()-1);\n MahjongSolitaireTile tile2 = stack2.remove(stack2.size()-1);\n \n // MAKE SURE BOTH ARE UNSELECTED\n tile1.setState(VISIBLE_STATE);\n tile2.setState(VISIBLE_STATE);\n \n // SEND THEM TO THE STACK\n tile1.setTarget(TILE_STACK_X + TILE_STACK_OFFSET_X, TILE_STACK_Y + TILE_STACK_OFFSET_Y);\n tile1.startMovingToTarget(MAX_TILE_VELOCITY);\n tile2.setTarget(TILE_STACK_X + TILE_STACK_2_OFFSET_X, TILE_STACK_Y + TILE_STACK_OFFSET_Y);\n tile2.startMovingToTarget(MAX_TILE_VELOCITY);\n stackTiles.add(tile1);\n stackTiles.add(tile2); \n \n // MAKE SURE THEY MOVE\n movingTiles.add(tile1);\n movingTiles.add(tile2);\n \n // AND MAKE SURE NEW TILES CAN BE SELECTED\n selectedTile = null;\n \n // PLAY THE AUDIO CUE\n miniGame.getAudio().play(MahjongSolitairePropertyType.MATCH_AUDIO_CUE.toString(), false);\n \n // NOW CHECK TO SEE IF THE GAME HAS EITHER BEEN WON OR LOST\n \n // HAS THE PLAYER WON?\n if (stackTiles.size() == NUM_TILES)\n {\n // YUP UPDATE EVERYTHING ACCORDINGLY\n endGameAsWin();\n }\n else\n {\n // SEE IF THERE ARE ANY MOVES LEFT\n MahjongSolitaireMove possibleMove = this.findMove();\n if (possibleMove == null)\n {\n // NOPE, WITH NO MOVES LEFT BUT TILES LEFT ON\n // THE GRID, THE PLAYER HAS LOST\n endGameAsLoss();\n }\n }\n }", "private boolean createStraightProtectingMoves(Chessboard chessboard, boolean colour) {\n\t\tint startRow = position / 8;\n\t\tint startCol = position % 8;\n\t\t\n\t\tboolean rightBlocked = false, downBlocked = false, leftBlocked = false, upBlocked = false;\n\t\tint maxMovement = Math.max(Math.max(startRow, startCol), Math.max(7-startRow, 7-startCol));\n\t\t\n\t\t// check route\n\t\tfor (int i = 1; i <= maxMovement; i++) {\n\t\t\t// check right\n\t\t\tif (!rightBlocked && startCol + i < 8) {\n\t\t\t\tint end = startRow * 8 + (startCol + i);\n\t\t\t\tPiece piece = chessboard.getSquareContents(end);\n\t\t\t\tif (chessboard.getSquareContents(end) == null) {\n\t\t\t\t\t// the route is clear, continue\n\t\t\t\t} else if ((piece instanceof Rook || piece instanceof Queen) && piece.amIWhite() == colour) {\n\t\t\t\t\treturn true;\n\t\t\t\t} else {\n\t\t\t\t\trightBlocked = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// check down\n\t\t\tif (!downBlocked && startRow + i < 8) {\n\t\t\t\tint end = (startRow + i) * 8 + startCol;\n\t\t\t\tPiece piece = chessboard.getSquareContents(end);\n\t\t\t\tif (chessboard.getSquareContents(end) == null) {\n\t\t\t\t\t// the route is clear, continue\n\t\t\t\t} else if ((piece instanceof Rook || piece instanceof Queen) && piece.amIWhite() == colour) {\n\t\t\t\t\treturn true;\n\t\t\t\t} else {\n\t\t\t\t\tdownBlocked = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// check left\n\t\t\tif (!leftBlocked && startCol - i >= 0) {\n\t\t\t\tint end = (startRow * 8) + startCol - i;\n\t\t\t\tPiece piece = chessboard.getSquareContents(end);\n\t\t\t\tif (chessboard.getSquareContents(end) == null) {\n\t\t\t\t\t// the route is clear, continue\n\t\t\t\t} else if ((piece instanceof Rook || piece instanceof Queen) && piece.amIWhite() == colour) {\n\t\t\t\t\treturn true;\n\t\t\t\t} else {\n\t\t\t\t\tleftBlocked = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// check up\n\t\t\tif (!upBlocked && startRow - i >= 0) {\n\t\t\t\tint end = (startRow - i) * 8 + startCol;\n\t\t\t\tPiece piece = chessboard.getSquareContents(end);\n\t\t\t\tif (chessboard.getSquareContents(end) == null) {\n\t\t\t\t\t// the route is clear, continue\n\t\t\t\t} else if ((piece instanceof Rook || piece instanceof Queen) && piece.amIWhite() == colour) {\n\t\t\t\t\treturn true;\n\t\t\t\t} else {\n\t\t\t\t\tupBlocked = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (rightBlocked && downBlocked && leftBlocked && upBlocked) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}", "void animalMove(int x,int y, Living[][] map,int gridLength, int gridWidth){\r\n \r\n boolean age=map[x][y].getAge();\r\n boolean gender=map[x][y].getGender();\r\n boolean checkRight=false;\r\n boolean checkLeft=false;\r\n boolean checkUp=false;\r\n boolean checkDown=false;\r\n boolean up=false;\r\n boolean down=false;\r\n boolean right=false;\r\n boolean left=false;\r\n boolean baby=false;\r\n boolean turn=map[x][y].getMovement(); //Check to see if it moved before in the array\r\n \r\n double random=Math.random();\r\n \r\n \r\n \r\n \r\n //Checks to see if it is possible to even see to the left first\r\n if(y-1>=0){\r\n left=true;\r\n \r\n if(turn && (map[x][y-1] instanceof Plant) ){ //Check to see if there is plants and goes to plants\r\n map[x][y].gainHealth((map[x][y-1].getHealth()));\r\n map[x][y].setMovement(false); \r\n map[x][y-1]=map[x][y];\r\n map[x][y]=null;\r\n turn=false; \r\n }\r\n if(turn && (map[x][y-1] instanceof Sheep) && (age==map[x][y-1].getAge()) ){ \r\n //If the ages match they must be false to be adults and both be opposite genders\r\n if(turn && !(age) && !(gender==map[x][y-1].getGender()) && (map[x][y].getHealth()>19) && (map[x][y-1].getHealth()>19) ){\r\n \r\n //Success rate of conceiving\r\n if( (Math.random()<=0.85) ){ \r\n \r\n if( (x+1<gridLength) && (map[x+1][y]==null)&& !(baby) ){ //Following ifs check to see if a baby can be made surrounding the intitiating sheep\r\n map[x+1][y]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true; \r\n }\r\n \r\n if( (x-1>=0) && (map[x-1][y]==null)&& !(baby) ){\r\n map[x-1][y]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n if((y+1<gridLength) && (map[x][y+1]==null) && !(baby) ){\r\n map[x][y+1]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n if(baby){ //If baby is made then sheep will lose health and turn is therefore over \r\n map[x][y].lowerHealth(10);\r\n map[x][y-1].lowerHealth(10);\r\n map[x][y].setMovement(false);\r\n map[x][y-1].setMovement(false);\r\n turn=false;\r\n baby=false;\r\n }\r\n }\r\n } \r\n }\r\n //If it can move to the left need to check if it can foresee more incase there wasn't any place for it to go\r\n if(y-2>=0){\r\n checkLeft=true;\r\n }\r\n }\r\n \r\n //Checks to see if it is possible to even see to the right first \r\n if(y+1<gridWidth){\r\n right=true;\r\n \r\n //Check to move on towards plants\r\n if(turn && (map[x][y+1] instanceof Plant)){\r\n map[x][y].gainHealth(map[x][y+1].getHealth()); \r\n map[x][y].setMovement(false); \r\n map[x][y+1]=map[x][y];\r\n map[x][y]=null;\r\n turn=false; \r\n }\r\n \r\n if(turn && (map[x][y+1] instanceof Sheep && age==map[x][y+1].getAge()) ){ \r\n //If the ages match they must be false to be adults and both be opposite genders\r\n if(turn && !(age) && !(gender==map[x][y+1].getGender()) && (map[x][y].getHealth()>19) && (map[x][y+1].getHealth()>19) ){\r\n \r\n //Success rate of conceiving\r\n if( (Math.random()<=0.85) ){\r\n \r\n if( (x+1<gridLength) && (map[x+1][y]==null) && !(baby) ){ //Following ifs check to see if a baby can be made surrounding the intitiating sheep\r\n \r\n map[x+1][y]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true; \r\n }\r\n \r\n if( (x-1>=0) && (map[x-1][y]==null) && !(baby) ){\r\n map[x-1][y]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n if( (y-1>=0) && (map[x][y-1]==null) && !(baby) ){\r\n map[x][y-1]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n if(baby){ //If baby is made then sheeps will lose health and turn is therefore over \r\n map[x][y].lowerHealth(10);\r\n map[x][y+1].lowerHealth(10);\r\n map[x][y].setMovement(false);\r\n map[x][y+1].setMovement(false);\r\n turn=false; \r\n baby=false;\r\n }\r\n }\r\n } \r\n }\r\n \r\n //If it can move to the right need to check if it can foresee more incase there wasn't any place for it to go\r\n if(y+2<gridWidth){ \r\n checkRight=true;\r\n }\r\n } \r\n \r\n //Check to see if it can go up\r\n if(x-1>=0){\r\n up=true;\r\n \r\n //Check for plant to go on to upwards \r\n if(turn && (map[x-1][y] instanceof Plant) ){\r\n map[x][y].gainHealth(map[x-1][y].getHealth()); \r\n map[x][y].setMovement(false); \r\n map[x-1][y]=map[x][y];\r\n map[x][y]=null;\r\n turn=false;\r\n }\r\n \r\n if(turn && (map[x-1][y] instanceof Sheep) && (age==map[x-1][y].getAge()) ){ \r\n //If the ages match age must be false to be adults and both be opposite genders and have more then 19 health\r\n if(turn && !age && !(gender==map[x-1][y].getGender()) &&map[x][y].getHealth()>19 &&map[x-1][y].getHealth()>19){\r\n \r\n //Success rate of conceiving\r\n if( (Math.random()<=0.85) ){\r\n if( (y+1<gridLength) && (map[x][y+1]==null) && !(baby) ){ //Following ifs check to see if a baby can be made surrounding the intitiating sheep\r\n \r\n map[x][y+1]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true; \r\n }\r\n if( (y-1>=0) && (map[x][y-1]==null) && !(baby) ){\r\n map[x][y-1]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n \r\n if( (x+1<gridLength) && (map[x+1][y]==null) && !(baby) ){\r\n map[x+1][y]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n \r\n if(baby){ //If baby is made then sheep will lose health and turn is therefore over \r\n map[x][y].lowerHealth(10);\r\n map[x-1][y].lowerHealth(10);\r\n map[x][y].setMovement(false);\r\n map[x-1][y].setMovement(false);\r\n turn=false; \r\n baby=false;\r\n }\r\n }\r\n } \r\n }\r\n \r\n //If it can move to upwards need to check if it can foresee more incase there wasn't any place for it to go\r\n if(x-2>=0){\r\n checkUp=true; \r\n }\r\n } \r\n //Check to see where to go downwards\r\n if(x+1<gridLength){\r\n down=true; \r\n \r\n //Check to see if any plants are downwards\r\n if(turn && (map[x+1][y] instanceof Plant) ){\r\n map[x][y].gainHealth( (map[x+1][y].getHealth()));\r\n map[x][y].setMovement(false);\r\n map[x+1][y]=map[x][y];\r\n map[x][y]=null;\r\n turn=false;\r\n } \r\n \r\n if(turn && (map[x+1][y] instanceof Sheep) && (age==map[x+1][y].getAge()) ){ \r\n \r\n //If the ages match they must be false to be adults and both be opposite genders\r\n if(turn && !(age) && !(gender==map[x+1][y].getGender()) && (map[x][y].getHealth()>=20) && (map[x+1][y].getHealth()>=20) ){\r\n \r\n //Success rate of conceiving\r\n if( (Math.random()<=0.85) ){\r\n if( (y+1<gridLength) && (map[x][y+1]==null) && !(baby) ){ //Following ifs check to see if a baby can be made surrounding the intitiating sheep \r\n map[x][y+1]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true; \r\n }\r\n if( (y-1>=0) && (map[x][y-1]==null) && !(baby) ){\r\n map[x][y-1]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n if( (x-1>=0) && (map[x+1][y]==null) && !(baby) ){\r\n map[x-1][y]=new Sheep(10,0,true,true,(Math.random()>0.5)); \r\n baby=true;\r\n }\r\n if(baby){ //If baby is made then sheep will lose health and turn is therefore over \r\n map[x][y].lowerHealth(10);\r\n map[x+1][y].lowerHealth(10);\r\n map[x][y].setMovement(false);\r\n map[x+1][y].setMovement(false);\r\n turn=false;\r\n baby=false;\r\n }\r\n }\r\n } \r\n } \r\n if(x+2<gridLength){\r\n checkDown=true;\r\n }\r\n } \r\n \r\n //Movement towards plant only if no immediate sheep/plants are there to move to\r\n if(turn && checkRight && (map[x][y+2] instanceof Plant) ){\r\n if(map[x][y+1]==null){\r\n \r\n map[x][y+1]=map[x][y];\r\n map[x][y]=null;\r\n map[x][y+1].setMovement(false);\r\n turn=false;\r\n }\r\n }\r\n if(turn && checkDown && (map[x+2][y] instanceof Plant) ){\r\n if(map[x+1][y]==null){\r\n map[x+1][y]=map[x][y];\r\n map[x][y]=null;\r\n map[x+1][y].setMovement(false);\r\n turn=false;\r\n }\r\n } \r\n if(turn && checkUp && (map[x-2][y] instanceof Plant) ){\r\n if(map[x-1][y]==null){\r\n \r\n map[x-1][y]=map[x][y];\r\n map[x][y]=null;\r\n map[x-1][y].setMovement(false);\r\n turn=false;\r\n }\r\n }\r\n \r\n if(turn && checkLeft && (map[x][y-2] instanceof Plant) ){\r\n if(map[x][y-1]==null){\r\n map[x][y-1]=map[x][y];\r\n map[x][y]=null;\r\n map[x][y-1].setMovement(false);\r\n turn=false;\r\n }\r\n }\r\n \r\n //Random Movement if there are no plants to move towards \r\n if(turn && right && (random<=0.2) ){\r\n if(map[x][y+1]==null){\r\n map[x][y].setMovement(false);\r\n map[x][y+1]=map[x][y];\r\n map[x][y]=null; \r\n }\r\n }\r\n if(turn && left && (random>0.2) && (random<=0.4) ){\r\n if(map[x][y-1]==null){\r\n map[x][y].setMovement(false);\r\n map[x][y-1]=map[x][y];\r\n map[x][y]=null;\r\n }\r\n }\r\n if(turn && up && (random>0.4) && (random<=0.6) ){\r\n if(map[x-1][y]==null){\r\n map[x][y].setMovement(false);\r\n map[x-1][y]=map[x][y];\r\n map[x][y]=null;\r\n }\r\n }\r\n if(turn && down && (random>0.6) && (random<=0.8) ){\r\n if(map[x+1][y]==null){\r\n map[x][y].setMovement(false);\r\n map[x+1][y]=map[x][y];\r\n map[x][y]=null;\r\n }\r\n }\r\n }", "public static int heuristic(PentagoBoardState boardState) {\n\t\tint value = 0;\n\t\t\n\t\tfor (int i = 0; i<size; i++) {\n\t\t\tfor (int j = 0; j<size; j++) {\n\t\t\t\tif (boardState.getPieceAt(i, j) == PentagoBoardState.Piece.BLACK) {\n\t\t\t\t\tvalue += 10;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn value;\n\t}", "static public void proccessGame(){\n int nextBallLeft = settingOfTheGame.getBallX() + settingOfTheGame.getBallDeltaX();\n int nextBallRight = settingOfTheGame.getBallX() + settingOfTheGame.getDiameter() + settingOfTheGame.getBallDeltaX();\n int nextBallTop = settingOfTheGame.getBallY() + settingOfTheGame.getBallDeltaY();\n int nextBallBottom = settingOfTheGame.getBallY() + settingOfTheGame.getDiameter() + settingOfTheGame.getBallDeltaY();\n\n int playerOneRight = settingOfTheGame.getFirst().getPlayerX() + settingOfTheGame.getFirst().getPlayerX();\n int playerOneTop = settingOfTheGame.getFirst().getPlayerY();\n int playerOneBottom = settingOfTheGame.getFirst().getPlayerY() + settingOfTheGame.getFirst().getPlayerHeight();\n\n float playerTwoLeft = settingOfTheGame.getSecond().getPlayerX();\n float playerTwoTop = settingOfTheGame.getSecond().getPlayerY();\n float playerTwoBottom = settingOfTheGame.getSecond().getPlayerY() + settingOfTheGame.getSecond().getPlayerHeight();\n\n //ball bounces off top and bottom of screen\n if (nextBallTop < 0 || nextBallBottom > 600) {\n settingOfTheGame.setBallDeltaY(settingOfTheGame.getBallDeltaY()*(-1));\n }\n\n //will the ball go off the left side?\n if (nextBallLeft < playerOneRight) {\n //is it going to miss the paddle?\n if (nextBallTop > playerOneBottom || nextBallBottom < playerOneTop) {\n\n Score.second++;\n\n if (Score.second == 3) {\n settingOfTheGame.setPlaying(false);\n settingOfTheGame.setGameOver(true);\n }\n\n settingOfTheGame.setBallX(250);\n settingOfTheGame.setBallY(250);\n } else {\n settingOfTheGame.setBallDeltaX(settingOfTheGame.getBallDeltaX()*(-1));\n }\n }\n\n //will the ball go off the right side?\n if (nextBallRight > playerTwoLeft) {\n //is it going to miss the paddle?\n if (nextBallTop > playerTwoBottom || nextBallBottom < playerTwoTop) {\n\n Score.first++;\n\n if (Score.first == 3) {\n settingOfTheGame.setPlaying(false);\n settingOfTheGame.setGameOver(true);\n }\n\n settingOfTheGame.setBallX(250);\n settingOfTheGame.setBallY(250);\n } else {\n settingOfTheGame.setBallDeltaX(settingOfTheGame.getBallDeltaX()*(-1));\n }\n }\n\n //move the ball\n settingOfTheGame.setBallX(settingOfTheGame.getBallX()+settingOfTheGame.getBallDeltaX()); //ballX += ballDeltaX;\n settingOfTheGame.setBallY(settingOfTheGame.getBallY()+settingOfTheGame.getBallDeltaY());//ballY += ballDeltaY;\n }", "public int[][] getMovesRook(Piece p) {\n x = p.getX();\n y = p.getY();\n int legalMoves[][] = new int[8][8];\n\n for (int i = x + 1; i < 8; i++) {//Traversing from piece coords, right till end of board.\n if (b.getPieceAt(y, i) != null) {\n if (p.isWhite() == b.getPieceAt(y, i).isWhite()) {\n break;\n } else {\n legalMoves[y][i] = 1;\n break;\n }\n } else {\n legalMoves[y][i] = 1;\n }\n }\n for (int i = x - 1; i > -1; i--) {//Traversing from piece coords, left till end of board.\n if (b.getPieceAt((y), i) != null) {\n if (p.isWhite() == b.getPieceAt((y), i).isWhite()) {\n break;\n } else {\n legalMoves[(y)][i] = 1;\n break;\n }\n } else {\n legalMoves[y][i] = 1;\n }\n }\n for (int i = y - 1; i > -1; i--) { //Traversing from piece coords, downwards till end of board.\n if (b.getPieceAt((i), x) != null) {\n if (p.isWhite() == b.getPieceAt(i, x).isWhite()) {\n break;\n } else {\n legalMoves[i][x] = 1;\n break;\n }\n } else {\n legalMoves[i][x] = 1;\n }\n }\n for (int i = y + 1; i < 8; i++) { //Traversing from piece coords, upwards till end of board.\n if (b.getPieceAt((i), x) != null) {\n if (p.isWhite() == b.getPieceAt(i, x).isWhite()) {\n break;\n } else {\n legalMoves[i][x] = 1;\n break;\n }\n } else {\n legalMoves[i][x] = 1;\n }\n }\n return legalMoves;\n }", "private void moveVerticalMhos() {\n\n\t\t//Assign playerX and playerY to the X and Y of the player\n\t\tint playerX = getNewPlayerLocation()[0];\n\t\tint playerY = getNewPlayerLocation()[1];\n\n\t\t//Iterate through every mho's X and Y values\n\t\tfor(int i = 0; i < mhoLocations.size()/2; i++) {\n\n\t\t\t//Assign mhoX and mhoY to the X and Y values of the mho that is currently being tested\n\t\t\tint mhoX = mhoLocations.get(i*2);\n\t\t\tint mhoY = mhoLocations.get(i*2+1);\n\n\t\t\t//set the default X and Y offsets to 0, and the move to NO_MOVEMENT\n\t\t\tint xOffset = 0;\n\t\t\tint yOffset = 0;\n\t\t\tchar move = Legend.NO_MOVEMENT;\n\n\t\t\t//If the horizontal distance is less than or equal to the vertical distance, change the xOffset and yOffset\n\t\t\tif((Math.abs(playerX-mhoX))<=(Math.abs(playerY-mhoY))) {\n\t\t\t\tif(playerY > mhoY) {\n\t\t\t\t\tyOffset = 1;\n\t\t\t\t\tmove = Legend.DOWN;\n\t\t\t\t} else {\n\t\t\t\t\tyOffset = -1;\n\t\t\t\t\tmove = Legend.UP;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//If the new location is an instance of BlankSpace, move the mho\n\t\t\tif(newMap[mhoX+xOffset][mhoY+yOffset] instanceof BlankSpace) {\n\t\t\t\tnewMap[mhoX][mhoY] = new BlankSpace(mhoX, mhoY, board);\n\t\t\t\t\n\t\t\t\t//If the new location is a player, shrink the player and call gameOver()\n\t\t\t\tif(newMap[mhoX+xOffset][mhoY+yOffset] instanceof Player) {\n\t\t\t\t\tmoveList[mhoX+xOffset][mhoY+yOffset] = Legend.SHRINK;\n\t\t\t\t\tgameOver();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t//Set the mho's move in the moveList\n\t\t\t\tmoveList[mhoX][mhoY] = move;\n\t\t\t\t\n\t\t\t\t//Assign the new map location as a Mho\n\t\t\t\tnewMap[mhoX+xOffset][mhoY+yOffset] = new Mho(mhoX+xOffset, mhoY+yOffset, board);\n\t\t\t\t\n\t\t\t\t//remove each X and Y from mhoLocations\n\t\t\t\tmhoLocations.remove(i*2+1);\n\t\t\t\tmhoLocations.remove(i*2);\n\t\t\t\t\n\t\t\t\t//Call moveVerticalMhos again, because the list failed to be checked through completely\n\t\t\t\tmoveVerticalMhos();\n\t\t\t\tbreak;\n\t\t\t} \n\t\t}\n\t\treturn;\n\t}", "void oppInCheck(Piece[] B,Player J2,boolean moveFound);", "public void HandleLejos(Integer old_position, Integer new_position){\n int compare = new_position-old_position;\n switch (compare){\n case(1):\n Lejos.Right();\n Lejos.TimeToBombSound = TIME_STRAIGHT+TIME_SIDE*2;\n break;\n case(-1):\n Lejos.Left();\n Lejos.TimeToBombSound = TIME_STRAIGHT+TIME_SIDE*2;\n break;\n case(-10):\n Lejos.Forward();\n Lejos.TimeToBombSound = TIME_STRAIGHT;\n break;\n case(10):\n Lejos.Back();\n Lejos.TimeToBombSound = TIME_STRAIGHT;\n break;\n case(-9):\n Lejos.ForwardRight();\n Lejos.TimeToBombSound = TIME_STRAIGHT*2+TIME_SIDE*2;\n break;\n case(9):\n Lejos.BackLeft();\n Lejos.TimeToBombSound = TIME_STRAIGHT*2+TIME_SIDE*2;\n break;\n case(-11):\n Lejos.ForwardLeft();\n Lejos.TimeToBombSound = TIME_STRAIGHT*2+TIME_SIDE*2;\n break;\n case(11):\n Lejos.BackRight();\n Lejos.TimeToBombSound = TIME_STRAIGHT*2+TIME_SIDE*2;\n break;\n }\n checkBombs(new_position);\n }", "public int[] getAllPossibleMoves(boolean ignore) {\n int[] validMoves;\n int[] validMovesResized;\n int validMovesIndex = 0;\n int startRow = this.getRow();\n int startCol = this.getCol();\n \n validMoves = new int[28]; // For a bishop, there are a maximum of 14 possible squares it could move to\n\n // First move from the bishops spot up diagonally to the right (ie col++, row++)\n for (int i = startCol+1, j = startRow+1; i<=8 && j<8; i++,j++) {\n validMoves[validMovesIndex] = i; // the col\n validMoves[validMovesIndex + 1] = j; // the row\n validMovesIndex = validMovesIndex + 2;\n }\n\n // Next move from the bishops start spot down diagonally to the right (ie col++, row--)\n for (int i = startCol+1, j = startRow-1; i<=8 && j>0; i++,j--) {\n validMoves[validMovesIndex] = i;\n validMoves[validMovesIndex + 1] = j;\n validMovesIndex = validMovesIndex + 2;\n }\n\n // Next move from the bishops start spot down diagonally to the left (ie col--, row--)\n for (int i = startCol-1, j = startRow-1; i>0 && j>0; i--,j--) {\n validMoves[validMovesIndex] = i;\n validMoves[validMovesIndex + 1] = j;\n validMovesIndex = validMovesIndex + 2;\n }\n // Next move from the bishops start spot up diagonally to the left (ie col--, row++)\n for (int i = startCol-1, j = startRow+1; i>0 && j<=8; i--,j++) {\n validMoves[validMovesIndex] = i;\n validMoves[validMovesIndex + 1] = j;\n validMovesIndex = validMovesIndex + 2;\n }\n \n // depending on the position of the bishop, the final array of possible moves may not have 14 squares\n // although that is the maximum. Create a new array of the actual size and copy into it.\n validMovesResized = Arrays.copyOf(validMoves, validMovesIndex);\n return validMovesResized;\n }", "@Override\r\n\tpublic void onLivingUpdate() {\r\n\t\tsuper.onLivingUpdate();\r\n\t\tthis.field_70888_h = this.field_70886_e;\r\n\t\tthis.field_70884_g = this.destPos;\r\n\t\tthis.destPos = (float)((double)this.destPos + (double)(this.onGround ? -1 : 4) * 0.3D);\r\n\t\t\r\n\t\tif(this.destPos < 0.0F) {\r\n\t\t\tthis.destPos = 0.0F;\r\n\t\t}\r\n\t\t\r\n\t\tif(this.destPos > 1.0F) {\r\n\t\t\tthis.destPos = 1.0F;\r\n\t\t}\r\n\t\t\r\n\t\tif(!this.onGround && this.field_70889_i < 1.0F) {\r\n\t\t\tthis.field_70889_i = 1.0F;\r\n\t\t}\r\n\t\t\r\n\t\tthis.field_70889_i = (float)((double)this.field_70889_i * 0.9D);\r\n\t\t\r\n\t\tif(!this.onGround && this.motionY < 0.0D) {\r\n\t\t\tthis.motionY *= 0.6D;\r\n\t\t}\r\n\t\t\r\n\t\tthis.field_70886_e += this.field_70889_i * 2.0F;\r\n\t\t\r\n\t\tif(!this.isChild() && !this.worldObj.isRemote && --this.timeUntilNextEgg <= 0) {\r\n\t\t\tthis.worldObj.playSoundAtEntity(this, \"mob.chickenplop\", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);\r\n\t\t\tthis.dropItem(SorceryItems.goldegg, 1);\r\n\t\t\tthis.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;\r\n\t\t}\r\n\t}", "private static Tile findBorderLocation(Entity mover, Entity destination) {\r\n\t\tint size = destination.getSize();\r\n\t\tTile centerDest = destination.getCurrentTile().copyNew(size >> 1, size >> 1, 0);\r\n\t\tTile center = mover.getCurrentTile().copyNew(mover.getSize() >> 1, mover.getSize() >> 1, 0);\r\n\t\tDirection direction = Direction.getLogicalDirection(centerDest, center);\r\n\t\tTile delta = Tile.getDelta(destination.getCurrentTile(), mover.getCurrentTile());\r\n\t\tmain: for (int i = 0; i < 4; i++) {\r\n\t\t\tint amount = 0;\r\n\t\t\tswitch (direction) {\r\n\t\t\tcase NORTH:\r\n\t\t\t\tamount = size - delta.getY();\r\n\t\t\t\tbreak;\r\n\t\t\tcase EAST:\r\n\t\t\t\tamount = size - delta.getX();\r\n\t\t\t\tbreak;\r\n\t\t\tcase SOUTH:\r\n\t\t\t\tamount = mover.getSize() + delta.getY();\r\n\t\t\t\tbreak;\r\n\t\t\tcase WEST:\r\n\t\t\t\tamount = mover.getSize() + delta.getX();\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\treturn null;\r\n\t\t\t}\r\n\t\t\tfor (int j = 0; j < amount; j++) {\r\n\t\t\t\tfor (int s = 0; s < mover.getSize(); s++) {\r\n\t\t\t\t\tswitch (direction) {\r\n\t\t\t\t\tcase NORTH:\r\n\t\t\t\t\t\tif (!direction.canMove(mover.getCurrentTile().copyNew(s, j + mover.getSize(), 0))) {\r\n\t\t\t\t\t\t\tdirection = Direction.get((direction.toInteger() + 1) & 3);\r\n\t\t\t\t\t\t\tcontinue main;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase EAST:\r\n\t\t\t\t\t\tif (!direction.canMove(mover.getCurrentTile().copyNew(j + mover.getSize(), s, 0))) {\r\n\t\t\t\t\t\t\tdirection = Direction.get((direction.toInteger() + 1) & 3);\r\n\t\t\t\t\t\t\tcontinue main;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase SOUTH:\r\n\t\t\t\t\t\tif (!direction.canMove(mover.getCurrentTile().copyNew(s, -(j + 1), 0))) {\r\n\t\t\t\t\t\t\tdirection = Direction.get((direction.toInteger() + 1) & 3);\r\n\t\t\t\t\t\t\tcontinue main;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase WEST:\r\n\t\t\t\t\t\tif (!direction.canMove(mover.getCurrentTile().copyNew(-(j + 1), s, 0))) {\r\n\t\t\t\t\t\t\tdirection = Direction.get((direction.toInteger() + 1) & 3);\r\n\t\t\t\t\t\t\tcontinue main;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\t\treturn null;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tTile location = mover.getCurrentTile().copyNew(direction, amount);\r\n\t\t\treturn location;\r\n\t\t}\r\n\t\treturn null;\r\n\t}", "public void getBotRight(List<Piece> moves){\n\n\t\tint pNum = PhiletoNum(this.phile);\n\t\tint rNum = this.rank;\n\t\twhile(pNum < 8 && rNum > 1){\n\t\t\tmoves.add(new Bishop(NumtoPhile(pNum + 1), rNum - 1));\n\t\t\tpNum += 1;\n\t\t\trNum -= 1;\n\t\t}\n\t}", "public void SpiritBomb()\r\n {\r\n\r\n\t \r\n\t\tLocation loc = new Location(userRow+1, userCol);\r\n\t\tLocation loc1 = new Location(userRow+1, userCol1);\r\n\t\tLocation loc2 = new Location(userRow+1, userCol2);\r\n\t\tLocation loc3 = new Location(userRow+1, userCol3);\r\n\t\t\r\n\t\tLocation loc4 = new Location(userRow, userCol);\r\n\t\tLocation loc5 = new Location(userRow, userCol1);\r\n\t\tLocation loc6 = new Location(userRow, userCol2);\r\n\t\tLocation loc7 = new Location(userRow, userCol3);\r\n\t\t\r\n\t\tLocation loc8 = new Location(userRow-1, userCol);\r\n\t\tLocation loc9 = new Location(userRow-1, userCol1);\r\n\t\tLocation loc10 = new Location(userRow-1, userCol2);\r\n\t\tLocation loc11 = new Location(userRow-1, userCol3);\r\n\t\t\r\n\t\tLocation loc12 = new Location(userRow-2, userCol);\r\n\t\tLocation loc13= new Location(userRow-2, userCol1);\r\n\t\tLocation loc14 = new Location(userRow-2, userCol2);\r\n\t\tLocation loc15 = new Location(userRow-2, userCol3);\r\n\r\n\t \r\n\r\n\r\n\r\n\t\t\r\n\t\tLocation base1 = new Location(userRow,0);\r\n\t\t\r\n\t\t\tgrid.setImage(base1, \"FSpiritHold.png\");\r\n\t\t\t\r\n\t\tfor(int a = 0; a<9; a++) {\r\n\t\tif(userCol>0 && userCol3 !=15 && userCol2!=15 && userCol1!=15 && userCol!=15 && userRow>0)\r\n\t\t{\r\n\t\r\n\t\t\t Location next101 = new Location(userRow+1,userCol);\r\n\t\t\t Location next102 = new Location(userRow+1,userCol1);\r\n\t\t\t Location next103 = new Location(userRow+1,userCol2);\r\n\t\t\t Location next104 = new Location(userRow+1,userCol3);\r\n\r\n\t\t\t\tLocation next201 = new Location(userRow,userCol);\r\n\t\t\t\tLocation next202 = new Location(userRow,userCol1);\r\n\t\t\t\tLocation next203 = new Location(userRow,userCol2);\r\n\t\t\t\tLocation next204 = new Location(userRow,userCol3);\r\n\t\t\t\t\r\n\t\t\t\tLocation next301 = new Location(userRow-1,userCol);\r\n\t\t\t\tLocation next302 = new Location(userRow-1,userCol1);\r\n\t\t\t\tLocation next303 = new Location(userRow-1,userCol2);\r\n\t\t\t\tLocation next304 = new Location(userRow-1,userCol3);\r\n\t\t\t\t\r\n\t\t\t Location next401 = new Location(userRow-2,userCol);\r\n\t\t\t Location next402 = new Location(userRow-2,userCol1);\r\n\t\t\t Location next403 = new Location(userRow-2,userCol2);\r\n\t\t\t Location next404 = new Location(userRow-2,userCol3);\r\n\t\t\t userCol+=1;\r\n\t\t\t userCol1+=1;\r\n\t\t\t\tuserCol2+=1;\r\n\t\t\t\tuserCol3+=1;\r\n\t\t\t grid.setImage(next101, \"SB401.png\");\r\n\t\t\t grid.setImage(loc1, null);\r\n\r\n\t\t\t \r\n\t\t\t\tgrid.setImage(next102, \"SB402.png\");\r\n\t\t\t grid.setImage(loc2, null);\r\n\r\n\t\t\t \r\n\t\t\t\tgrid.setImage(next103, \"SB403.png\");\r\n\t\t\t grid.setImage(loc2, null);\r\n\r\n\t\t\t \r\n\t\t\t\tgrid.setImage(next104, \"SB404.png\");\r\n\t\t\t grid.setImage(loc3, null);\r\n\r\n\t\t\t\t\r\n\t\t\t\tgrid.setImage(next201, \"SB301.png\");\r\n\t\t\t grid.setImage(loc4, null);\r\n\r\n\t\t\t \r\n\t\t\t\tgrid.setImage(next202, \"SB302.png\");\r\n\t\t\t grid.setImage(loc5, null);\r\n\r\n\t\t\t \r\n\t\t\t\tgrid.setImage(next203, \"SB303.png\");\r\n\t\t\t grid.setImage(loc6, null);\r\n\r\n\t\t\t \r\n\t\t\t\tgrid.setImage(next204, \"SB304.png\");\r\n\t\t\t grid.setImage(loc7, null);\r\n\r\n\t\t\t\t\r\n\t\t\t\tgrid.setImage(next301, \"SB201.png\");\r\n\t\t\t grid.setImage(loc8, null);\r\n\r\n\t\t\t \r\n\t\t\t\tgrid.setImage(next302, \"SB202.png\");\r\n\t\t\t grid.setImage(loc9, null);\r\n\r\n\t\t\t \r\n\t\t\t\tgrid.setImage(next303, \"SB203.png\");\r\n\t\t\t grid.setImage(loc10, null);\r\n\r\n\t\t\t \r\n\t\t\t\tgrid.setImage(next304, \"SB204.png\");\r\n\t\t\t grid.setImage(loc11, null);\r\n\r\n\t\t\t\t\r\n\t\t\t\tgrid.setImage(next401, \"SB101.png\");\r\n\t\t\t grid.setImage(loc12, null);\r\n\r\n\t\t\t \r\n\t\t\t\tgrid.setImage(next402, \"SB102.png\");\r\n\t\t\t grid.setImage(loc13, null);\r\n\r\n\t\t\t \r\n\t\t\t\tgrid.setImage(next403, \"SB103.png\");\r\n\t\t\t grid.setImage(loc14, null);\r\n\r\n\t\t\t \r\n\t\t\t\tgrid.setImage(next404, \"SB104.png\");\r\n\t\t\t grid.setImage(loc15, null);\r\n\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t\t \r\n\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\t\r\n }\r\n }", "public boolean applyMove(int bin) \n {\n \tint stones = state[bin];\n \t//clear the original bin\n \tstate[bin] = 0;\n \t\n \tfor (int i = 0; i < stones; ++i) \n \t{\n \t\tint nextBin = (bin+i+1)%14;\n \t\tif (!(nextBin == 6 && bin > 6) && !(nextBin == 13 && bin < 7))\n \t\t\t++state[nextBin];\n \t\telse\n \t\t\t++stones;\n \t}\n \tint lastBin = (bin+stones)%14;\n \tboolean lastBinEmpty = state[lastBin] == 1;\n \tboolean lastBinOnYourSide = bin/7 == lastBin/7;\n \tif ((lastBin == 6 || lastBin == 13) && !gameOver()) \n \t{\n \t\treturn true;\n }\n \tif (lastBinEmpty && lastBinOnYourSide && lastBin != 6 && lastBin != 13) \n \t{\n \t\tint mancalaBin = mancalaOf(bin);\n \t\tint neighborBin = neighborOf(lastBin);\n \t\tstate[mancalaBin] += state[neighborBin] + 1;\n \t\tstate[neighborBin] = 0;\n \t\tstate[lastBin] = 0;\n \t}\n if (gameOver())\n stonesToMancalas();\n return false;\n }", "public void changePos() {\r\n\r\n // Add timeCount\r\n timeCount += 20;\r\n\r\n // Orange\r\n orangeY += 12;\r\n\r\n float orangeCenterX = orangeX + orange.getWidth() / 2;\r\n float orangeCenterY = orangeY + orange.getHeight() / 2;\r\n\r\n if (hitCheck(orangeCenterX, orangeCenterY)) {\r\n orangeY = frameHeight + 100;\r\n score += 10;\r\n soundPlayer.playHitOrangeSound();\r\n }\r\n\r\n if (orangeY > frameHeight) {\r\n orangeY = -100;\r\n orangeX = (float) Math.floor(Math.random() * (frameWidth - orange.getWidth()));\r\n }\r\n orange.setX(orangeX);\r\n orange.setY(orangeY);\r\n\r\n // Pink\r\n if (!pink_flg && timeCount % 10000 == 0) {\r\n pink_flg = true;\r\n pinkY = -20;\r\n pinkX = (float) Math.floor(Math.random() * (frameWidth - pink.getWidth()));\r\n }\r\n\r\n if (pink_flg) {\r\n pinkY += 20;\r\n\r\n float pinkCenterX = pinkX + pink.getWidth() / 2;\r\n float pinkCenterY = pinkY + pink.getWidth() / 2;\r\n\r\n if (hitCheck(pinkCenterX, pinkCenterY)) {\r\n pinkY = frameHeight + 30;\r\n score += 30;\r\n // Change FrameWidth\r\n if (initialFrameWidth > frameWidth * 110 / 100) {\r\n frameWidth = frameWidth * 110 / 100;\r\n changeFrameWidth(frameWidth);\r\n }\r\n soundPlayer.playHitPinkSound();\r\n }\r\n\r\n if (pinkY > frameHeight) pink_flg = false;\r\n pink.setX(pinkX);\r\n pink.setY(pinkY);\r\n }\r\n\r\n if (level.equals(\"easy\")) {\r\n blackY += 18;\r\n } else if (level.equals(\"medium\")) {\r\n blackY += 34;\r\n\r\n } else if (level.equals(\"hard\")) {\r\n blackY += 50;\r\n }\r\n\r\n\r\n float blackCenterX = blackX + black.getWidth() / 2;\r\n float blackCenterY = blackY + black.getHeight() / 2;\r\n\r\n if (hitCheck(blackCenterX, blackCenterY)) {\r\n blackY = frameHeight + 100;\r\n\r\n // Change FrameWidth\r\n frameWidth = frameWidth * 80 / 100;\r\n changeFrameWidth(frameWidth);\r\n soundPlayer.playHitBlackSound();\r\n if (frameWidth <= boxSize) {\r\n gameOver();\r\n }\r\n\r\n }\r\n\r\n if (blackY > frameHeight) {\r\n blackY = -100;\r\n blackX = (float) Math.floor(Math.random() * (frameWidth - black.getWidth()));\r\n }\r\n\r\n black.setX(blackX);\r\n black.setY(blackY);\r\n\r\n // Move Box\r\n if (action_flg) {\r\n // Touching\r\n boxX += 14;\r\n box.setImageDrawable(imageBoxRight);\r\n } else {\r\n // Releasing\r\n boxX -= 14;\r\n box.setImageDrawable(imageBoxLeft);\r\n }\r\n\r\n // Check box position.\r\n if (boxX < 0) {\r\n boxX = 0;\r\n box.setImageDrawable(imageBoxRight);\r\n }\r\n if (frameWidth - boxSize < boxX) {\r\n boxX = frameWidth - boxSize;\r\n box.setImageDrawable(imageBoxLeft);\r\n }\r\n\r\n box.setX(boxX);\r\n String b = \"Score : \" + score;\r\n scoreLabel.setText(b);\r\n\r\n }", "public Tuple move(Board board, Dice dice, BuildDice bdice) {\n // Throw Dice\n int result = dice.roll();\n System.out.println(ANSI() + \"Player\" + id + \" rolls dice\" + ANSI_RESET);\n System.out.println(ANSI() + \"Player\" + id + \" please press any button\" + ANSI_RESET);\n Scanner s = new Scanner(System.in);\n String str = s.nextLine();\n System.out.println(\"Dice: \" + result);\n System.out.println();\n\n // Render legal your previous position\n board.legal[posX][posY] = 0; \n\n boolean capital = false, bank = false;\n Tuple res = new Tuple();\n Tuple player_pos = new Tuple(posX, posY);\n board.setShow(player_pos, board.board[posX][posY]);\n\n for (int i=0; i<result; i++) {\n int x1, x2, y1, y2, x3, y3, x4, y4;\n\n // right\n x1 = posX;\n y1 = posY + 1;\n // up \n x2 = posX - 1;\n y2 = posY;\n // left\n x3 = posX;\n y3 = posY - 1;\n // down\n x4 = posX + 1;\n y4 = posY;\n \n char c1 = board.board[x1][y1];\n char c2 = board.board[x2][y2];\n char c3 = board.board[x3][y3];\n char c4 = board.board[x4][y4];\n\n if (board.board[posX][posY] == 'S') {\n res.a = 6;\n res.b = 11; \n }\n else if ((c1 == 'B' || c1 == 'C' || c1 == 'H' || c1 == 'S' || c1 == 'E' || c1 == 'e') \n && (prevx != x1 || prevy != y1)) {\n res.a = x1;\n res.b = y1;\n }\n else if ((c2 == 'B' || c2 == 'C' || c2 == 'H' || c2 == 'S' || c2 == 'E' || c2 == 'e') \n && (prevx != x2 || prevy != y2)) {\n res.a = x2;\n res.b = y2;\n }\n else if ((c3 == 'B' || c3 == 'C' || c3 == 'H' || c3 == 'S' || c3 == 'E' || c3 == 'e') \n && (prevx != x3 || prevy != y3)) {\n res.a = x3;\n res.b = y3;\n }\n else if ((c4 == 'B' || c4 == 'C' || c4 == 'H' || c4 == 'S' || c4 == 'E' || c4 == 'e') \n && (prevx != x4 || prevy != y4)) {\n res.a = x4;\n res.b = y4;\n }\n\n prevx = posX;\n prevy = posY;\n // (res.a, res.b) is my next position\n posX = res.a;\n posY = res.b;\n\n // Check if player passes Bank ---> + 1000 MLS\n if (posX == board.B.a && posY == board.B.b) \n bank = true;\n \n // Check if player passes Capital ---> entrance ??\n if (posX == board.C.a && posY == board.C.b)\n capital = true;\n\n // if last round of dice result\n if (i == result - 1) {\n int legal = board.setLegal(prevx, prevy, posX, posY);\n if (legal == 0) {\n res.a = posX;\n res.b = posY;\n }\n // Someone else is on this position\n else if (legal == 1) {\n boolean ans = false;\n while (!ans) {\n // right\n x1 = posX;\n y1 = posY + 1;\n // up \n x2 = posX - 1;\n y2 = posY;\n // left\n x3 = posX;\n y3 = posY - 1;\n // down\n x4 = posX + 1;\n y4 = posY;\n \n c1 = board.board[x1][y1];\n c2 = board.board[x2][y2];\n c3 = board.board[x3][y3];\n c4 = board.board[x4][y4];\n \n if (board.board[posX][posY] == 'S') {\n res.a = 6;\n res.b = 11; \n }\n else if ((c1 == 'B' || c1 == 'C' || c1 == 'H' || c1 == 'S' || c1 == 'E' || c1 == 'e') \n && (prevx != x1 || prevy != y1)) {\n res.a = x1;\n res.b = y1;\n }\n else if ((c2 == 'B' || c2 == 'C' || c2 == 'H' || c2 == 'S' || c2 == 'E' || c2 == 'e') \n && (prevx != x2 || prevy != y2)) {\n res.a = x2;\n res.b = y2;\n }\n else if ((c3 == 'B' || c3 == 'C' || c3 == 'H' || c3 == 'S' || c3 == 'E' || c3 == 'e') \n && (prevx != x3 || prevy != y3)) {\n res.a = x3;\n res.b = y3;\n }\n else if ((c4 == 'B' || c4 == 'C' || c4 == 'H' || c4 == 'S' || c4 == 'E' || c4 == 'e') \n && (prevx != x4 || prevy != y4)) {\n res.a = x4;\n res.b = y4;\n }\n\n prevx = posX;\n prevy = posY;\n // (res.a, res.b) is my next position\n posX = res.a;\n posY = res.b;\n\n legal = board.setLegal(prevx, prevy, posX, posY);\n if (legal == 0) {\n ans = true;\n }\n \n // Check if player passes Bank ---> + 1000 MLS\n if (posX == board.B.a && posY == board.B.b) \n bank = true;\n \n // Check if player passes Capital ---> entrance ??\n if (posX == board.C.a && posY == board.C.b)\n capital = true; \n \n } // endwhile\n\n } // endelseif(legal==1)\n\n // Check if player passes Bank ---> + 1000 MLS\n if (posX == board.B.a && posY == board.B.b)\n bank = true;\n // Check if player passes Capital ---> entrance ??\n if (posX == board.C.a && posY == board.C.b)\n capital = true;\n\n } // endif(i==result-1)\n \n } // endfor\n\n /* ΔΙΝΩ ΠΡΟΤΕΡΑΙΟΤΗΤΑ ΠΡΩΤΑ ΣΤΟ ΝΑ ΠΑΙΡΝΩ ΧΡΗΜΑΤΑ ΑΠΟ ΤΗΝ ΤΡΑΠΕΖΑ\n * ΜΕΤΑ ΣΤΟ ΝΑ ΠΛΗΡΩΣΩ ΣΤΟΝ ΑΝΤΙΠΑΛΟ ΜΟΥ\n * ΜΕΤΑ ΣΤΟ ΝΑ ΜΠΟΡΩ ΝΑ ΑΓΟΡΑΣΩ ΕΙΣΟΔΟ Ή ΝΑ ΧΤΙΣΩ Ή ΝΑ ΑΓΟΡΑΣΩ ΞΕΝΟΔΟΧΕΙΟ\n */\n\n System.out.println(ANSI() + \"Player\" + id + \" is moving to position (\" + res.a + \", \" + res.b + \") \" + board.board[res.a][res.b] + \".\" + ANSI_RESET); \n System.out.println();\n if (!hotel_list.isEmpty()) {\n System.out.println(ANSI() + \"Player\" + id + \" hotels:\" + ANSI_RESET);\n for (HotelCard hc : hotel_list) {\n System.out.println(ANSI() + hc.getName() + ANSI_RESET);\n }\n }\n\n // Find player's position on the show board\n board.setShow(res, getMisc());\n\n // Player has passed from Bank, if (bank == true)\n if (bank)\n bank();\n\n // Check if player is on a rival's entrance \n pay(res, dice, board);\n // Check for bankrupt\n if (status == false) return null;\n\n /* Player has passed from Capital, if (capital == true)\n * Player moves to E --> wants to buy an entrance or upgrade??\n */ \n if ((capital || board.board[res.a][res.b] == 'E' || board.board[res.a][res.b] == 'e') \n && !hotel_list.isEmpty()) {\n String cap = null, build = \"no\";\n if (capital) cap = wantsEntrance(\"capital\");\n else if (board.board[res.a][res.b] == 'E' || board.board[res.a][res.b] == 'e') {\n cap = wantsEntrance(\"E\");\n if (cap.equals(\"no\")) {\n System.out.println(ANSI() + \"Want to build or upgrade a hotel?\" + ANSI_RESET);\n build = wantsBuild();\n }\n }\n // wantsEntrance() result\n if (cap.equals(\"yes\")) {\n System.out.println(ANSI() + \"Player\" + id + \" MLS is: \" + mls + \".\" + ANSI_RESET);\n HotelCard cap_hotel = searchHotel();\n System.out.println(ANSI() + \"Give the (line, column) of entrance position\"+ ANSI_RESET);\n int line = -1, column = -1;\n boolean answer = false;\n System.out.println(ANSI() + \"Give line\" + ANSI_RESET);\n while (answer == false) {\n s = new Scanner(System.in);\n str = s.nextLine();\n try {\n line = Integer.parseInt(str);\n answer = true; \n } catch (Exception e) {\n System.out.println(ANSI() + \"Give integer line\" + ANSI_RESET);\n } \n }\n System.out.println(ANSI() + \"Give column\" + ANSI_RESET);\n answer = false;\n while (answer == false) {\n s = new Scanner(System.in);\n str = s.nextLine();\n try {\n column = Integer.parseInt(str);\n answer = true; \n } catch (Exception e) {\n System.out.println(ANSI() + \"Give integer column\" + ANSI_RESET);\n } \n } \n Tuple pos = new Tuple(line, column);\n buyEntrance(cap_hotel, pos, board);\n }\n // wantsBuild() result\n else if (build.equals(\"yes\")) {\n System.out.println(ANSI() + \"Player\" + id + \" MLS is: \" + mls + ANSI_RESET);\n HotelCard cap_hotel = searchHotel();\n build(cap_hotel, bdice);\n }\n }\n \n // Player is on \"H\" --> Wants to buy??\n else if (board.board[res.a][res.b] == 'H') {\n String buy;\n System.out.println(ANSI() + \"Player\" + id + \" MLS is: \" + mls + ANSI_RESET);\n System.out.println(ANSI() + \"Want to buy a hotel?\" + ANSI_RESET);\n buy = wantsBuy();\n if (buy.equals(\"yes\")) { \n HotelCard buy_hotel = searchAdjacentHotels(board, res); \n buyHotel(buy_hotel);\n }\n }\n\n // After all, player's movement reach to an end...\n return res; \n }", "public Position findWeed() {\n int xVec =0;\n int yVec=0;\n int sum = 0;\n Position move = new Position(0, 0);\n for (int i = 0; i < this.WORLD.getMapSize().getX(); i++) {\n for (int j = 0; j < this.WORLD.getMapSize().getY(); j++) {\n\n //hogweed\n Organism organism = this.WORLD.getOrganism(i, j);\n if(organism!=null){\n Class c = organism.getClass();\n if (c.getSimpleName().equals(\"Parnsip\")) {\n int tmpX = Math.abs(this.position.getX() - i);\n int tmpY = Math.abs(this.position.getY() - j);\n if (!(xVec == 0 && yVec == 0)) {\n int tmpSum = tmpX + tmpY;\n if (sum > tmpSum) {\n xVec=tmpX;\n yVec=tmpY;\n sum = tmpSum;\n this.setMove(move, j, i);\n }\n }\n else {\n xVec=tmpX;\n yVec=tmpY;\n sum = tmpX + tmpY;\n this.setMove(move, j, i);\n }\n }\n }\n\n }\n }\n return move;\n }", "static ArrayList<int[]> searcherBottomRightTiles(ArrayList<int[]> MoveList,int CurrentX, int CurrentY){\n\t\t\n\t\tfor(int j = 1; j <=7 ; j++){\n\t\t\tint [] NewXY = new int[2];\t\n\t\t\tNewXY[0] = CurrentX + j;\n\t\t\tNewXY[1] = CurrentY + j;\n\t\t\t\n\t\t\tif(NewXY[0] > 7 || NewXY[1] > 7){\n\t\t\t\treturn MoveList;\n\t\t\t}\n\t\t\t\n\t\t\tfor(int [] i: aggregateBlacks()){\n\t\t\t\tint[] Coordinate = i;\n\t\t\t\tif(Arrays.equals(Coordinate, NewXY)){\n\t\t\t\t\t//System.out.println(\"We have found a valid black piece to kill \" + j + \" tiles bottom right of this bishop\");\n\t\t\t\t\tMoveList.add(NewXY);;\n\t\t\t\t\treturn MoveList;\n\t\t\t\t}\t \t\t\t\t\n\t\t\t}\n\t\t\tfor(int [] i: aggregateWhites()){\n\t\t\t\tint[] Coordinate = i;\n\t\t\t\tif(Arrays.equals(Coordinate, NewXY)){\n\t\t\t\t\t//System.out.println(\"We have found a white piece \" + j + \" tiles top of this Queen\");\n\t\t\t\t\treturn MoveList;\n\t\t\t\t}\t\t\n\t\t\t}\t\n\t\t\tMoveList.add(NewXY);\n\t\t\t}\n\t\treturn MoveList;\n\t\t}", "private boolean canBlackMoveRight(Pedina pedina) {\n if(!controllaSeCasellaLibera(pedina.getX() + 1, pedina.getY() + 1))\n return false;\n else {\n for (int i = 0; i < arrayPedineBianche.size(); i++) {\n if (pedina.getX() + 2 == arrayPedineBianche.get(i).getX()\n && pedina.getY() + 2 == arrayPedineBianche.get(i).getY()) \n seVadoDestraVengoMangiato = true;\n }\n \n for (int i = 0; i < arrayPedineBianche.size(); i++) {\n if (pedina.getX() + 2 == arrayPedineBianche.get(i).getX()\n && pedina.getY() == arrayPedineBianche.get(i).getY()\n && pedina.getY() + 2 <= 7\n && controllaSeCasellaLibera(pedina.getX(), pedina.getY() + 2)) \n seVadoDestraVengoMangiato = true;\n }\n \n for (int i = 0; i < arrayPedineBianche.size(); i++) {\n if (pedina.getX() == arrayPedineBianche.get(i).getX()\n && pedina.getY() + 2 == arrayPedineBianche.get(i).getY()\n && pedina.getX() + 2 <= 7\n && arrayPedineBianche.get(i) instanceof Damone\n && controllaSeCasellaLibera(pedina.getX() + 2, pedina.getY()))\n seVadoDestraVengoMangiato = true;\n }\n \n if(pedina.getX() + 1 > 7 || pedina.getY() + 1 > 7)\n return false;\n else {\n pedina.setXTemp(pedina.getX() + 1);\n pedina.setYTemp(pedina.getY() + 1);\n return true;\n }\n }\n }", "public boolean attemptMove(Move move, int color) {\n //ArrayList<Move> jumps = canJump(color);\n //make sure the to and from values don't go out of bounds\n if (move.xFrom > 7 || move.yFrom > 7 || move.xTo > 7 || move.yTo > 7 ||\n \tmove.xFrom < 0 || move.yFrom < 0 || move.xTo < 0 || move.yTo < 0 ){\n// System.out.println(\"out of bounds\");\n return false;\n }\n int stateOfFrom = gameState.getStateOfSquare(move.xFrom, move.yFrom);\n int stateOfTo = gameState.getStateOfSquare(move.xTo, move.yTo);\n \n\n //if there in no piece in the \"from\" location return false\n if (stateOfFrom == 0){\n// System.out.println(\"no piece at 'from'\");\n return false;\n }\n \n //if there is a piece in the \"to\" location return false\n if (!(stateOfTo == 0)){\n// System.out.println(\"'to' is not empty\");\n return false;\n }\n \n //if the \"from\" piece is not the correct color return false\n if (!(gameState.getStateOfSquare(move.xFrom, move.yFrom)%2 == color))\n {\n// System.out.println(\"that is not your piece\");\n return false;\n }\n \n //check if the \"from\" piece is moving in the right direction\n \n /*if (jumps.isEmpty() == false) //if there are jumps.\n {\n System.out.println(\"there are jumps\");\n //for every possible jump\n for (int i=0; i<jumps.size(); i++){\n \t//if this move matches a possible jump then it is valid\n \tSystem.out.println(\"is this jump \"+ i + \"?\");\n \tif ((move.xFrom == jumps.get(i).xFrom)&&\n \t\t\t(move.yFrom == jumps.get(i).yFrom)&&\n \t\t\t(move.xTo == jumps.get(i).xTo)&&\n \t\t\t(move.yTo == jumps.get(i).yTo)){\n \t\tSystem.out.println(\"yes\");\n \t\treturn true;\n \t}\n \telse{\n \t\tSystem.out.println(\"there are possible jumps\");\n \t}\n \t\t\n \t\n }\n //return false;\n \n //handle jumps\n }\n */\n //moving diagonally\n else{\n if (move.xTo == move.xFrom + 1 || move.xTo == move.xFrom - 1){\n //if (stateOfFrom >= 3) \n //if piece is king it can move both forward and back\n if (stateOfFrom >= 3 && (move.yTo == move.yFrom + 1 || move.yTo == move.yFrom - 1)){\n \treturn true;\n }\n //red can only move up\n else if(color == 0 && (move.yTo == move.yFrom + 1)){\n \treturn true;\n }\n //black can only move down\n else if(color == 1 && (move.yTo == move.yFrom - 1)){\n \treturn true;\n }\n else{\n// System.out.println(\"wrong way\");\n return false;\n }\n }\n else{\n// System.out.println(\"too far away\");\n return false;\n }\n }\n //return true;\n \n \n }", "public boolean isLegalStep(MoveDirection dir){\r\n GamePosition curPos = currentGame.getCurrentPosition();\n\t\tPlayer white = currentGame.getWhitePlayer();\n\t\tint[] toCheckPos = new int[2];\n\t\tint[] existingPos = new int[2];\n\t\tif(curPos.getPlayerToMove().equals(white)) {\n\t\t\ttoCheckPos[0] = curPos.getWhitePosition().getTile().getColumn();\n\t\t\ttoCheckPos[1] = curPos.getWhitePosition().getTile().getRow();\n\t\t\t\n\t\t\texistingPos[0] = curPos.getBlackPosition().getTile().getColumn();\n\t\t\texistingPos[1] = curPos.getBlackPosition().getTile().getRow();\n\t\t\t\n\t\t} else {\n\t\t\ttoCheckPos[0] = curPos.getBlackPosition().getTile().getColumn();\n\t\t\ttoCheckPos[1] = curPos.getBlackPosition().getTile().getRow();\n\t\t\t\n\t\t\texistingPos[0] = curPos.getWhitePosition().getTile().getColumn();\n\t\t\texistingPos[1] = curPos.getWhitePosition().getTile().getRow();\n\t\t}\n\t\t//0 = column, 1 = row\n\t\tif(dir == MoveDirection.North) {\n\t\t\tif(toCheckPos[1] == 1) return false;\n\t\t\tif(toCheckPos[1] - 1 == existingPos[1] && toCheckPos[0] == existingPos[0]) return false;\n\t\t\treturn QuoridorController.noWallBlock(curPos.getPlayerToMove(), -1, 0);\n\t\t} else if(dir == MoveDirection.South) {\n\t\t\tif(toCheckPos[1] == 9) return false;\n\t\t\tif(toCheckPos[1] + 1 == existingPos[1] && toCheckPos[0] == existingPos[0]) return false;\n\t\t\treturn QuoridorController.noWallBlock(curPos.getPlayerToMove(), 1, 0);\n\t\t} else if(dir == MoveDirection.East) {\n\t\t\tif(toCheckPos[0] == 9) return false;\n\t\t\tif(toCheckPos[0] + 1 == existingPos[0] && toCheckPos[1] == existingPos[1]) return false;\n\t\t\treturn QuoridorController.noWallBlock(curPos.getPlayerToMove(), 0, 1);\n\t\t} else if(dir == MoveDirection.West) {\n\t\t\tif(toCheckPos[0] == 1) return false;\n\t\t\tif(toCheckPos[0] - 1 == existingPos[0] && toCheckPos[1] == existingPos[1]) return false;\n\t\t\treturn QuoridorController.noWallBlock(curPos.getPlayerToMove(), 0, -1);\n\t\t}\n\t\t\n\t\treturn false;\r\n }", "protected int winnable(Board b){\r\n\t\t//checks if two tiles are the same (and not empty) and checks if\r\n\t\t//the third tile required to win is empty for a winning condition\r\n\t\tint condition = 0;\r\n\t\tif ((b.getTile(1) == b.getTile(2)) && (b.getTile(3) == ' ')\r\n\t\t\t\t&& (b.getTile(1) != ' ') && (b.getTile(1) == this.getSymbol()))\r\n\t\t\t\tcondition =3;\r\n\t\telse if ((b.getTile(1) == b.getTile(3)) && (b.getTile(2) == ' ')\r\n\t\t\t\t&& (b.getTile(1) != ' ') && (b.getTile(1) == this.getSymbol()))\r\n\t\t\tcondition = 2;\r\n\t\telse if ((b.getTile(2) == b.getTile(3)) && (b.getTile(1) == ' ')\r\n\t\t\t\t&& (b.getTile(2) != ' ') && (b.getTile(2) == this.getSymbol()))\r\n\t\t\tcondition = 1;\r\n\t\telse if ((b.getTile(4) == b.getTile(5)) && (b.getTile(6) == ' ')\r\n\t\t\t\t&& (b.getTile(4) != ' ') && (b.getTile(4) == this.getSymbol()))\r\n\t\t\tcondition = 6;\r\n\t\telse if ((b.getTile(4) == b.getTile(6)) && (b.getTile(5) == ' ')\r\n\t\t\t\t&& (b.getTile(4) != ' ') && (b.getTile(5) == this.getSymbol()))\r\n\t\t\tcondition = 5;\r\n\t\telse if ((b.getTile(5) == b.getTile(6)) && (b.getTile(4) == ' ')\r\n\t\t\t\t&& (b.getTile(5) != ' ') && (b.getTile(5) == this.getSymbol()))\r\n\t\t\tcondition = 4;\r\n\t\telse if ((b.getTile(7) == b.getTile(8)) && (b.getTile(9) == ' ')\r\n\t\t\t\t&& (b.getTile(7) != ' ') && (b.getTile(7) == this.getSymbol()))\r\n\t\t\tcondition = 9;\r\n\t\telse if ((b.getTile(7) == b.getTile(9)) && (b.getTile(8) == ' ')\r\n\t\t\t\t&& (b.getTile(7) != ' ') && (b.getTile(7) == this.getSymbol()))\r\n\t\t\tcondition = 8;\r\n\t\telse if ((b.getTile(8) == b.getTile(9)) && (b.getTile(7) == ' ')\r\n\t\t\t\t&& (b.getTile(8) != ' ') && (b.getTile(8) == this.getSymbol()))\r\n\t\t\tcondition = 7;\r\n\t\telse if ((b.getTile(1) == b.getTile(4)) && (b.getTile(7) == ' ')\r\n\t\t\t\t&& (b.getTile(1) != ' ') && (b.getTile(1) == this.getSymbol()))\r\n\t\t\tcondition = 7;\r\n\t\telse if ((b.getTile(1) == b.getTile(7)) && (b.getTile(4) == ' ')\r\n\t\t\t\t&& (b.getTile(1) != ' ') && (b.getTile(1) == this.getSymbol()))\r\n\t\t\tcondition = 4;\r\n\t\telse if ((b.getTile(4) == b.getTile(7)) && (b.getTile(1) == ' ')\r\n\t\t\t\t&& (b.getTile(4) != ' ') && (b.getTile(4) == this.getSymbol()))\r\n\t\t\tcondition = 1;\r\n\t\telse if ((b.getTile(2) == b.getTile(5)) && (b.getTile(8) == ' ')\r\n\t\t\t\t&& (b.getTile(2) != ' ') && (b.getTile(2) == this.getSymbol()))\r\n\t\t\tcondition = 8;\r\n\t\telse if ((b.getTile(2) == b.getTile(8)) && (b.getTile(5) == ' ')\r\n\t\t\t\t&& (b.getTile(2) != ' ') && (b.getTile(2) == this.getSymbol()))\r\n\t\t\tcondition = 5;\r\n\t\telse if ((b.getTile(5) == b.getTile(8)) && (b.getTile(2) == ' ')\r\n\t\t\t\t&& (b.getTile(5) != ' ') && (b.getTile(5) == this.getSymbol()))\r\n\t\t\tcondition = 2;\r\n\t\telse if ((b.getTile(3) == b.getTile(6)) && (b.getTile(9) == ' ')\r\n\t\t\t\t&& (b.getTile(3) != ' ') && (b.getTile(3) == this.getSymbol()))\r\n\t\t\tcondition = 9;\r\n\t\telse if ((b.getTile(3) == b.getTile(9)) && (b.getTile(6) == ' ')\r\n\t\t\t\t&& (b.getTile(3) != ' ') && (b.getTile(3) == this.getSymbol()))\r\n\t\t\tcondition = 6;\r\n\t\telse if ((b.getTile(6) == b.getTile(9)) && (b.getTile(3) == ' ')\r\n\t\t\t\t&& (b.getTile(6) != ' ') && (b.getTile(6) == this.getSymbol()))\r\n\t\t\tcondition = 3;\r\n\t\telse if ((b.getTile(1) == b.getTile(5)) && (b.getTile(9) == ' ')\r\n\t\t\t\t&& (b.getTile(1) != ' ') && (b.getTile(1) == this.getSymbol()))\r\n\t\t\tcondition = 9;\r\n\t\telse if ((b.getTile(1) == b.getTile(5)) && (b.getTile(5) == ' ')\r\n\t\t\t\t&& (b.getTile(1) != ' ') && (b.getTile(1) == this.getSymbol()))\r\n\t\t\tcondition = 5;\r\n\t\telse if ((b.getTile(5) == b.getTile(9)) && (b.getTile(1) == ' ')\r\n\t\t\t\t&& (b.getTile(5) != ' ') && (b.getTile(5) == this.getSymbol()))\r\n\t\t\tcondition = 1;\r\n\t\telse if ((b.getTile(3) == b.getTile(5)) && (b.getTile(7) == ' ')\r\n\t\t\t\t&& (b.getTile(3) != ' ') && (b.getTile(3) == this.getSymbol()))\r\n\t\t\tcondition = 7;\r\n\t\telse if ((b.getTile(3) == b.getTile(7)) && (b.getTile(5) == ' ')\r\n\t\t\t\t&& (b.getTile(3) != ' ') && (b.getTile(3) == this.getSymbol()))\r\n\t\t\tcondition = 5;\r\n\t\telse if ((b.getTile(5) == b.getTile(7)) && (b.getTile(3) == ' ')\r\n\t\t\t\t&& (b.getTile(5) != ' ') && (b.getTile(5) == this.getSymbol()))\r\n\t\t\tcondition = 3;\r\n\t\treturn condition;\r\n\t}", "private void updateHammingScore(int i, int j) {\n // if not free cell\n if (!(i == dimension() - 1 && j == dimension() - 1)) {\n // calculate goal value for this cell\n int goal = i * dimension() + j + 1;\n if (blocks[i][j] != goal) {\n hamming_score ++;\n }\n\n if (verbose) {\n // System.out.println(i + \",\" + j + \" \" + block + \" is \" + goal + \"?\" );\n }\n }\n }", "@Test\n public void shouldFindProperLocationBasedOnDistance() {\n assertEquals(Location.B6,\n Location.findLocation(Color.RED, Location.B2, 4));\n\n assertEquals(Location.B2,\n Location.findLocation(Color.BLACK, Location.B6, 4));\n\n // moving off the board\n assertEquals(Location.B_BEAR_OFF,\n Location.findLocation(Color.BLACK, Location.B2, 4));\n assertEquals(Location.B_BEAR_OFF,\n Location.findLocation(Color.BLACK, Location.B2, 6));\n assertEquals(Location.R_BEAR_OFF,\n Location.findLocation(Color.RED, Location.R2, 6));\n\n // moving in from the bar\n assertEquals(Location.R3,\n Location.findLocation(Color.BLACK,\n Location.B_BAR, 3));\n assertEquals(Location.B6,\n Location.findLocation(Color.RED,\n Location.R_BAR, 6));\n // passing from red to black table and opposite\n assertEquals(Location.B10,\n Location.findLocation(Color.BLACK,\n Location.R10, 5));\n assertEquals(Location.R10,\n Location.findLocation(Color.RED,\n Location.B10, 5));\n }", "static ArrayList<int[]> searcherBottomLeftTiles(ArrayList<int[]> MoveList,int CurrentX, int CurrentY){\n\t\t\n\t\tfor(int j = 1; j <=7 ; j++){\n\t\t\tint [] NewXY = new int[2];\n\t\t\tNewXY[0] = CurrentX - j;\n\t\t\tNewXY[1] = CurrentY + j;\n\t\t\t\n\t\t\tif(NewXY[0] < 0 || NewXY[1] > 7){\n\t\t\t\treturn MoveList;\n\t\t\t}\n\t\t\t\n\n\t\t\tfor(int [] i: aggregateBlacks()){\n\t\t\t\tint[] Coordinate = i;\n\t\t\t\tif(Arrays.equals(Coordinate, NewXY)){\n\t\t\t\t\t//System.out.println(\"We have found a valid blacks piece to kill \" + j + \" tiles bottom left of this bishop\");\n\t\t\t\t\tMoveList.add(NewXY);;\n\t\t\t\t\treturn MoveList;\n\t\t\t\t}\t \t\t\t\t\n\t\t\t}\n\n\t\t\tfor(int [] i: aggregateWhites()){\n\t\t\t\tint[] Coordinate = i;\n\t\t\t\tif(Arrays.equals(Coordinate, NewXY)){\n\t\t\t\t\t//System.out.println(\"We have found a white piece \" + j + \" tiles top of this Queen\");\n\t\t\t\t\treturn MoveList;\n\t\t\t\t}\t\t\n\t\t\t}\t\n\t\t\tMoveList.add(NewXY);\n\t\t\t}\n\t\treturn MoveList;\n\t\t}", "public boolean isLegalJump(MoveDirection dir){\r\n GamePosition curPos = currentGame.getCurrentPosition();\n\t\t\tPlayer white = currentGame.getWhitePlayer();\n\t\t\tint whiteCol = curPos.getWhitePosition().getTile().getColumn();\n\t\t\tint whiteRow = curPos.getWhitePosition().getTile().getRow();\n\t\t\tint blackCol = curPos.getBlackPosition().getTile().getColumn();\n\t\t\tint blackRow = curPos.getBlackPosition().getTile().getRow();\n\t\t\t\n\t\t\tint rChange = 0, cChange = 0;\n\t\t\tif(dir == MoveDirection.North) rChange = -2;\n\t\t\telse if(dir == MoveDirection.South) rChange = 2;\n\t\t\telse if(dir == MoveDirection.East) cChange = 2;\n\t\t\telse if(dir == MoveDirection.West) cChange = -2;\n\t\t\telse return false;\n\t\t\t\n\t\t\tif(curPos.getPlayerToMove().equals(white)) {\n\t\t\t\t\n\t\t\t\t//Moving left or right wall check\n\t\t\t\tif(cChange != 0) {\n\t\t\t\t\tif(blackRow != whiteRow || blackCol != (whiteCol + (cChange / 2) ) ) return false;\n\t\t\t\t\twhiteCol += cChange;\n\t\t\t\t\tif(whiteCol < 1 || whiteCol > 9) return false;\n\t\t\t\t\tfor(WallMove w : QuoridorController.getWalls()) {\n\t\t\t\t\t\tif(w.getWallDirection() == Direction.Vertical) {\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t//If left- check col -1, -2. If right- check col +0, +1\n\t\t\t\t\t\t\tint tmp;\n\t\t\t\t\t\t\tif(cChange < 0) tmp = -2;\n\t\t\t\t\t\t\telse tmp = 0;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tint checkCol = (whiteCol -cChange) + tmp;\n\t\t\t\t\t\t\tif((w.getTargetTile().getColumn() == checkCol ||w.getTargetTile().getColumn() == checkCol + 1) && \n\t\t\t\t\t\t\t (w.getTargetTile().getRow() == whiteRow || w.getTargetTile().getRow() == whiteRow - 1)) {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t//Horizontal Wall can't block right/left path\n\t\t\t\t\t}\t\n\t\t\t\t}\n\t\t\t\t//Moving up or down wall check\n\t\t\t\telse if(rChange != 0) {\n\t\t\t\t\tif(blackCol != whiteCol || blackRow != (whiteRow + (rChange / 2) ) ) return false;\n\t\t\t\t\twhiteRow += rChange;\n\t\t\t\t\tif(whiteRow < 1 || whiteRow > 9) return false;\n\t\t\t\t\tfor(WallMove w : QuoridorController.getWalls()) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tif(w.getWallDirection() == Direction.Horizontal) {\n\t\t\t\t\t\t\t//If up- check row -1, -2. If down- check row +0, +1\n\t\t\t\t\t\t\tint tmp;\n\t\t\t\t\t\t\tif(rChange < 0) tmp = -2;\n\t\t\t\t\t\t\telse tmp = 0;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tint checkRow = (whiteRow -rChange) + tmp;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif((w.getTargetTile().getRow() == checkRow || w.getTargetTile().getRow() == checkRow + 1)\n\t\t\t\t\t\t\t\t&& (w.getTargetTile().getColumn() == whiteCol || w.getTargetTile().getColumn() == whiteCol - 1)) {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t//Vertical Wall can't block up/down path\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif((blackRow == whiteRow) && (blackCol == whiteCol)) return false;\n\t\t\t} else {\n\n\t\t\t\t//Moving left or right wall check\n\t\t\t\tif(cChange != 0) {\n\t\t\t\t\tif(blackRow != whiteRow || whiteCol != (blackCol + (cChange / 2) ) ) return false;\n\t\t\t\t\tblackCol += cChange;\n\t\t\t\t\tif(blackCol < 1 || blackCol > 9) return false;\n\t\t\t\t\tfor(WallMove w : QuoridorController.getWalls()) {\n\t\t\t\t\t\tif(w.getWallDirection() == Direction.Vertical) {\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t//If left- check col -1, -2. If right- check col +0, +1\n\t\t\t\t\t\t\tint tmp;\n\t\t\t\t\t\t\tif(cChange < 0) tmp = -2;\n\t\t\t\t\t\t\telse tmp = 0;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tint checkCol = (blackCol -cChange) + tmp;\n\n\t\t\t\t\t\t\tif((w.getTargetTile().getColumn() == checkCol ||w.getTargetTile().getColumn() == checkCol + 1) && \n\t\t\t\t\t\t\t (w.getTargetTile().getRow() == blackRow || w.getTargetTile().getRow() == blackRow - 1)) {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\t//Horizontal Wall can't block right/left path\n\t\t\t\t\t}\t\n\t\t\t\t}\n\t\t\t\t//Moving up or down wall check\n\t\t\t\telse if(rChange != 0) {\n\t\t\t\t\tif(blackCol != whiteCol || whiteRow != (blackRow + (rChange / 2) ) ) return false;\n\t\t\t\t\tblackRow += rChange;\n\t\t\t\t\tif(blackRow < 1 || blackRow > 9) return false;\n\t\t\t\t\tfor(WallMove w : QuoridorController.getWalls()) {\n\t\t\t\t\t\tif(w.getWallDirection() == Direction.Horizontal) {\n\t\t\t\t\t\t\t//If up- check row -1, -2. If down- check row +0, +1\n\t\t\t\t\t\t\tint tmp;\n\t\t\t\t\t\t\tif(rChange < 0) tmp = -2;\n\t\t\t\t\t\t\telse tmp = 0;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tint checkRow = (blackRow -rChange) + tmp;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif((w.getTargetTile().getRow() == checkRow || w.getTargetTile().getRow() == checkRow + 1)\n\t\t\t\t\t\t\t\t&& (w.getTargetTile().getColumn() == blackCol || w.getTargetTile().getColumn() == blackCol - 1)) {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\t\t\t\t\t\t//Vertical Wall can't block up/down path\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif((blackRow == whiteRow) && (blackCol == whiteCol)) return false;\n\t\t\t}\n\t\t\treturn true;\r\n }", "private boolean isBallCollideCelling(GOval ball) {\n return ball.getY() <= 0;\n }", "public String checkCheese() {\n\n\n int j = 1;\n\n while (j < _cheese.getY() + 2) {\n\n for (int i = 1; i < _cheese.getX() + 1; i++) {\n\n int i2 = i;\n int j2 = j;\n\n\n if (_cheese.getCellArray()[i2][j2].getCheeseCell() == \"*\" && !_cheese.getCellArray()[i2][j2].isVisited()) {\n int temp1 = i2;\n int temp2 = j2;\n _holeCount++;\n while ((\n\n (_cheese.getCellArray()[i2 + 1][j2].getCheeseCell() == \"*\" && !_cheese.getCellArray()[i2 + 1][j2].isVisited()) ||\n\n\n (_cheese.getCellArray()[i2 + 1][j2 + 1].getCheeseCell() == \"*\" && !_cheese.getCellArray()[i2 + 1][j2 + 1].isVisited()) ||\n\n\n (_cheese.getCellArray()[i2][j2 + 1].getCheeseCell() == \"*\" && !_cheese.getCellArray()[i2][j2 + 1].isVisited()) ||\n\n (_cheese.getCellArray()[i2 - 1][j2 + 1].getCheeseCell() == \"*\" && !_cheese.getCellArray()[i2 - 1][j2 + 1].isVisited()) ||\n\n (_cheese.getCellArray()[i2 - 1][j2].getCheeseCell() == \"*\" && !_cheese.getCellArray()[i2 - 1][j2].isVisited()) ||\n\n (_cheese.getCellArray()[i2 - 1][j2 - 1].getCheeseCell() == \"*\" && !_cheese.getCellArray()[i2 - 1][j2 - 1].isVisited()) ||\n\n (_cheese.getCellArray()[i][j2 - 1].getCheeseCell() == \"*\" && !_cheese.getCellArray()[i][j2 - 1].isVisited()) ||\n\n (_cheese.getCellArray()[i2 + 1][j2 + 1].getCheeseCell() == \"*\" && !_cheese.getCellArray()[i2 + 1][j2 + 1].isVisited())\n\n )) {\n if (_cheese.getCellArray()[i2 + 1][j2].getCheeseCell() == \"*\" && !_cheese.getCellArray()[i2 + 1][j2].isVisited()) {\n _cheese.getCellArray()[i2 + 1][j2].setVisited(true);\n i2++;\n _holeCount++;\n } else if (_cheese.getCellArray()[i2 + 1][j2 + 1].getCheeseCell() == \"*\" && !_cheese.getCellArray()[i2 + 1][j2 + 1].isVisited()) {\n _cheese.getCellArray()[i2 + 1][j2 + 1].setVisited(true);\n i2++;\n j2++;\n _holeCount++;\n } else if (_cheese.getCellArray()[i2][j2 + 1].getCheeseCell() == \"*\" && !_cheese.getCellArray()[i2][j2 + 1].isVisited()) {\n _cheese.getCellArray()[i2][j2 + 1].setVisited(true);\n j2++;\n _holeCount++;\n } else if (_cheese.getCellArray()[i2 - 1][j2 + 1].getCheeseCell() == \"*\" && !_cheese.getCellArray()[i2][j2 + 1].isVisited()) {\n _cheese.getCellArray()[i2 - 1][j2 + 1].setVisited(true);\n j2++;\n _holeCount++;\n } else if (_cheese.getCellArray()[i2 - 1][j2].getCheeseCell() == \"*\" && !_cheese.getCellArray()[i2][j2 + 1].isVisited()) {\n _cheese.getCellArray()[i2 - 1][j2].setVisited(true);\n j2++;\n _holeCount++;\n } else if (_cheese.getCellArray()[i2 - 1][j2 - 1].getCheeseCell() == \"*\" && !_cheese.getCellArray()[i2][j2 + 1].isVisited()) {\n _cheese.getCellArray()[i2 - 1][j2 - 1].setVisited(true);\n j2++;\n _holeCount++;\n } else if (_cheese.getCellArray()[i2][j2 - 1].getCheeseCell() == \"*\" && !_cheese.getCellArray()[i2][j2 + 1].isVisited()) {\n _cheese.getCellArray()[i2][j2 - 1].setVisited(true);\n j2++;\n _holeCount++;\n } else if (_cheese.getCellArray()[i2 + 1][j2 + 1].getCheeseCell() == \"*\" && !_cheese.getCellArray()[i2][j2 + 1].isVisited()) {\n _cheese.getCellArray()[i2 + 1][j2 + 1].setVisited(true);\n j2++;\n\n }\n\n\n }\n _cheese.getCellArray()[temp1][temp2].setVisited(true);\n if (_holeCount > _biggestHole) {\n _biggestHole = _holeCount;\n }\n }\n _cheese.getCellArray()[i2][j2].setVisited(true);\n\n\n }\n\n\n j++;\n }\n\n\n return \"hole-count: \" + _holeCount + \"\\n\" +\n \"biggest hole edge: \" + _biggestHole;\n\n }", "private boolean isSurrounded(int row, int column, char[][] board,\n\t\t\tList<Integer> footPrints, Map<Integer, Boolean> resultRepo) {\n\t\tboolean result = true, temp = false;\n\t\tif (board[row][column] == 'X') {\n\t\t\t// 'X' is surrounded by himself\n\t\t\treturn true;\n\t\t}\n\t\tif (row == 0 || row == board.length - 1 || column == 0\n\t\t\t\t|| column == board[row].length - 1) {\n\t\t\t// Already touch the edge\n\t\t\treturn false;\n\t\t}\n\t\tif (resultRepo.containsKey(calculate(row, column, board))) {\n\t\t\treturn resultRepo.get(calculate(row, column, board));\n\t\t}\n\t\tfootPrints.add(calculate(row, column, board));\n\t\t// check left\n\t\tif (!footPrints.contains(calculate(row, column - 1, board))) {\n\t\t\tresult &= check(row, column - 1, board, footPrints, resultRepo);\n\t\t}\n\t\t// check right\n\t\tif (!footPrints.contains(calculate(row, column + 1, board))) {\n\t\t\tresult &= check(row, column + 1, board, footPrints, resultRepo);\n\t\t}\n\t\t// check upper\n\t\tif (!footPrints.contains(calculate(row + 1, column, board))) {\n\t\t\tresult &= check(row + 1, column, board, footPrints, resultRepo);\n\t\t}\n\t\t// check down\n\t\tif (!footPrints.contains(calculate(row - 1, column, board))) {\n\t\t\tresult &= check(row - 1, column, board, footPrints, resultRepo);\n\t\t}\n\t\treturn result;\n\t}", "public boolean validMove(ChessBoard board, Square from, Square to) {\r\n // check if piece killing his ally\r\n if(to.getPiece() != null){\r\n if (to.getPiece().isBlue() == this.isBlue()) {\r\n return false;\r\n }\r\n } \r\n\r\n int x = Math.abs(from.getX() - to.getX());\r\n int y = Math.abs(from.getY() - to.getY());\r\n if((from.getX() - to.getX()) > 0 || (from.getY() - to.getY()) > 0){\r\n if ((x == 0 && y >= 1)) {\r\n for(int i = 1; i <= y-1; i++){\r\n if(board.getBox(from.getX(), from.getY() - i).getPiece() != null){\r\n return false;\r\n }\r\n }\r\n return true;\r\n }else if((x >= 1 && y == 0)){\r\n for(int i = 1; i <= x-1; i++){\r\n if(board.getBox(from.getX() - i, from.getY()).getPiece() != null){\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n }else if((from.getX() - to.getX()) < 0 || (from.getY() - to.getY()) < 0){\r\n if (x == 0 && (from.getY() - to.getY()) <= -1) {\r\n for(int i = y-1; i > 0; i--){\r\n if(board.getBox(from.getX(), from.getY() + i).getPiece() != null){\r\n return false;\r\n }\r\n }\r\n return true;\r\n }else if((from.getX() - to.getX()) <= -1 && y == 0){\r\n for(int i = x-1; i > 0; i--){\r\n if(board.getBox(from.getX() + i, from.getY()).getPiece() != null){\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n }\r\n return false;\r\n }", "public void updateMhos() { \r\n\r\n\t\tfor (int i = 0; i < 12; i++) {\r\n\t\t\tif (Mhos[i].isAlive) {// Mho AI\r\n\t\t\t\t\r\n\t\t\t\tif (Mhos[i].x == p.x) // directly vertical\r\n\t\t\t\t\tif (Mhos[i].y > p.y) // move up\r\n\t\t\t\t\t\tmoveMho(i, 0, -1);\r\n\t\t\t\t\telse // move down\r\n\t\t\t\t\t\tmoveMho(i, 0, 1);\r\n\r\n\t\t\t\telse if (Mhos[i].y == p.y) { // directly horizontal\r\n\t\t\t\t\tif (Mhos[i].x > p.x) {\r\n\t\t\t\t\t\tmoveMho(i, -1, 0);\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tmoveMho(i, 1, 0);\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\tint relPos = Mhos[i].relToPlayer(p.x, p.y);\r\n\t\t\t\t\tint horDist = Math.abs(Mhos[i].x - p.x);\r\n\t\t\t\t\tint verDist = Math.abs(Mhos[i].y - p.y);\r\n\r\n\t\t\t\t\tif (relPos == 1) { // top right\r\n\t\t\t\t\t\tif (!(board[Mhos[i].x - 1][Mhos[i].y + 1] instanceof Fence\r\n\t\t\t\t\t\t\t\t|| board[Mhos[i].x - 1][Mhos[i].y + 1] instanceof Mho)) {\r\n\t\t\t\t\t\t\t// directly diagonal\r\n\t\t\t\t\t\t\tmoveMho(i, -1, 1);\r\n\t\t\t\t\t\t} else if (horDist >= verDist && !(board[Mhos[i].x - 1][Mhos[i].y] instanceof Fence\r\n\t\t\t\t\t\t\t\t|| board[Mhos[i].x - 1][Mhos[i].y] instanceof Mho)) // horizontal\r\n\t\t\t\t\t\t\tmoveMho(i, -1, 0);\r\n\r\n\t\t\t\t\t\telse if (horDist <= verDist && !(board[Mhos[i].x][Mhos[i].y + 1] instanceof Fence)\r\n\t\t\t\t\t\t\t\t|| board[Mhos[i].x][Mhos[i].y + 1] instanceof Fence) // vertical\r\n\t\t\t\t\t\t\tmoveMho(i, 0, 1);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t// tries to move on a fence now\r\n\t\t\t\t\t\telse if (board[Mhos[i].x - 1][Mhos[i].y + 1] instanceof Fence)\r\n\t\t\t\t\t\t\tmoveMho(i, -1, 1);\r\n\t\t\t\t\t\telse if (horDist >= verDist && board[Mhos[i].x - 1][Mhos[i].y] instanceof Fence)\r\n\t\t\t\t\t\t\tmoveMho(i, -1, 0);\r\n\t\t\t\t\t\telse if (horDist >= verDist && board[Mhos[i].x][Mhos[i].y + 1] instanceof Fence)\r\n\t\t\t\t\t\t\tmoveMho(i, 0, 1);\r\n\r\n\t\t\t\t\t} else if (relPos == 2) { // top left\r\n\t\t\t\t\t\tif (!(board[Mhos[i].x + 1][Mhos[i].y + 1] instanceof Fence\r\n\t\t\t\t\t\t\t\t|| board[Mhos[i].x + 1][Mhos[i].y + 1] instanceof Mho)) {\r\n\t\t\t\t\t\t\t// directly diagonal\r\n\t\t\t\t\t\t\tmoveMho(i, 1, 1);\r\n\t\t\t\t\t\t} else if (horDist >= verDist && !(board[Mhos[i].x + 1][Mhos[i].y] instanceof Fence\r\n\t\t\t\t\t\t\t\t|| board[Mhos[i].x + 1][Mhos[i].y] instanceof Mho)) // horizontal\r\n\t\t\t\t\t\t\tmoveMho(i, 1, 0);\r\n\r\n\t\t\t\t\t\telse if (horDist <= verDist && !(board[Mhos[i].x][Mhos[i].y + 1] instanceof Fence)\r\n\t\t\t\t\t\t\t\t|| board[Mhos[i].x][Mhos[i].y + 1] instanceof Fence) // vertical\r\n\t\t\t\t\t\t\tmoveMho(i, 0, 1);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t// tries to move on a fence now\r\n\t\t\t\t\t\telse if (board[Mhos[i].x + 1][Mhos[i].y + 1] instanceof Fence)\r\n\t\t\t\t\t\t\tmoveMho(i, 1, 1);\r\n\t\t\t\t\t\telse if (horDist >= verDist && board[Mhos[i].x + 1][Mhos[i].y] instanceof Fence)\r\n\t\t\t\t\t\t\tmoveMho(i, 1, 0);\r\n\t\t\t\t\t\telse if (horDist >= verDist && board[Mhos[i].x][Mhos[i].y + 1] instanceof Fence)\r\n\t\t\t\t\t\t\tmoveMho(i, 0, 1);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t} else if (relPos == 3) { // bottom left\r\n\t\t\t\t\t\tif (!(board[Mhos[i].x + 1][Mhos[i].y - 1] instanceof Fence\r\n\t\t\t\t\t\t\t\t|| board[Mhos[i].x + 1][Mhos[i].y - 1] instanceof Mho)) {\r\n\t\t\t\t\t\t\t// directly diagonal\r\n\t\t\t\t\t\t\tmoveMho(i, 1, -1);\r\n\t\t\t\t\t\t} else if (horDist >= verDist && !(board[Mhos[i].x + 1][Mhos[i].y] instanceof Fence\r\n\t\t\t\t\t\t\t\t|| board[Mhos[i].x + 1][Mhos[i].y] instanceof Mho)) // horizontal\r\n\t\t\t\t\t\t\tmoveMho(i, 1, 0);\r\n\r\n\t\t\t\t\t\telse if (horDist <= verDist && !(board[Mhos[i].x][Mhos[i].y - 1] instanceof Fence)\r\n\t\t\t\t\t\t\t\t|| board[Mhos[i].x][Mhos[i].y - 1] instanceof Fence) // vertical\r\n\t\t\t\t\t\t\tmoveMho(i, 0, -1);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t// tries to move on a fence now\r\n\t\t\t\t\t\telse if (board[Mhos[i].x + 1][Mhos[i].y - 1] instanceof Fence)\r\n\t\t\t\t\t\t\tmoveMho(i, 1, -1);\r\n\t\t\t\t\t\telse if (horDist >= verDist && board[Mhos[i].x + 1][Mhos[i].y] instanceof Fence)\r\n\t\t\t\t\t\t\tmoveMho(i, 1, 0);\r\n\t\t\t\t\t\telse if (horDist >= verDist && board[Mhos[i].x][Mhos[i].y - 1] instanceof Fence)\r\n\t\t\t\t\t\t\tmoveMho(i, 0, -1);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t} else if (relPos == 4) { // bottom right\r\n\t\t\t\t\t\tif (!(board[Mhos[i].x - 1][Mhos[i].y - 1] instanceof Fence\r\n\t\t\t\t\t\t\t\t|| board[Mhos[i].x - 1][Mhos[i].y - 1] instanceof Mho)) {\r\n\t\t\t\t\t\t\t// directly diagonal\r\n\t\t\t\t\t\t\tmoveMho(i, -1, -1);\r\n\t\t\t\t\t\t} else if (horDist >= verDist && !(board[Mhos[i].x - 1][Mhos[i].y] instanceof Fence\r\n\t\t\t\t\t\t\t\t|| board[Mhos[i].x - 1][Mhos[i].y] instanceof Mho)) // horizontal\r\n\t\t\t\t\t\t\tmoveMho(i, -1, 0);\r\n\r\n\t\t\t\t\t\telse if (horDist <= verDist && !(board[Mhos[i].x][Mhos[i].y - 1] instanceof Fence)\r\n\t\t\t\t\t\t\t\t|| board[Mhos[i].x][Mhos[i].y - 1] instanceof Fence) // vertical\r\n\t\t\t\t\t\t\tmoveMho(i, 0, -1);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t// tries to move on a fence now\r\n\t\t\t\t\t\telse if (board[Mhos[i].x - 1][Mhos[i].y - 1] instanceof Fence)\r\n\t\t\t\t\t\t\tmoveMho(i, -1, -1);\r\n\t\t\t\t\t\telse if (horDist >= verDist && board[Mhos[i].x - 1][Mhos[i].y] instanceof Fence)\r\n\t\t\t\t\t\t\tmoveMho(i, -1, 0);\r\n\t\t\t\t\t\telse if (horDist >= verDist && board[Mhos[i].x][Mhos[i].y - 1] instanceof Fence)\r\n\t\t\t\t\t\t\tmoveMho(i, 0, -1);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t}", "public void currentSquareIsBadExecute() throws GameActionException {\n\n if (!controller.isReady()) return;\n\n int badSquareMaximizedDistance = Cache.CURRENT_LOCATION.distanceSquaredTo(Cache.myECLocation);;\n Direction badSquareMaximizedDirection = null;\n\n // try to find a good square\n\n // move further or equal to EC\n\n int goodSquareMinimizedDistance = (int) 1E9;\n Direction goodSquareMinimizedDirection = null;\n\n for (Direction direction : Constants.DIRECTIONS) {\n if (controller.canMove(direction)) {\n MapLocation candidateLocation = Cache.CURRENT_LOCATION.add(direction);\n int candidateDistance = candidateLocation.distanceSquaredTo(Cache.myECLocation);\n boolean isGoodSquare = checkIfGoodSquare(candidateLocation);\n\n if (candidateLocation.isAdjacentTo(Cache.myECLocation)) continue;\n\n if (isGoodSquare) {\n if (goodSquareMinimizedDistance > candidateDistance) {\n goodSquareMinimizedDistance = candidateDistance;\n goodSquareMinimizedDirection = direction;\n }\n } else {\n if (badSquareMaximizedDistance <= candidateDistance) {\n badSquareMaximizedDistance = candidateDistance;\n badSquareMaximizedDirection = direction;\n }\n }\n }\n }\n\n if (goodSquareMinimizedDirection != null) {\n controller.move(goodSquareMinimizedDirection);\n } else if (badSquareMaximizedDirection != null) {\n controller.move(badSquareMaximizedDirection);\n }\n\n }", "private void move() {\n if(this.movement[0]) {\n moveRight();\n } else {\n moveLeft();\n }\n if(this.movement[1]) {\n moveDown();\n } else {\n moveUp();\n }\n\n //Checking boundaries of the game\n if(this.XPosition + this.ballWidth > instance.getWidth()) {\n this.movement[0] = false;\n } else if(XPosition <= 0) {\n this.movement[0] = true;\n } else if(YPosition <= 0) {\n this.movement[1] = true;\n } else if(YPosition + ballHeight >= instance.getHeight()) {\n instance.missedBall();\n if (instance.getBalls() > 0){\n this.lostLife.play();\n }\n this.XPosition = instance.getWidth() / 2;\n this.YPosition = instance.getHeight() - 43;\n this.movement[1] = false;\n Player.setPlayerX((instance.getWidth() - 111) / 2);\n Player.setPlayerY(instance.getHeight() - 19);\n instance.isPaused(true);\n }\n\n if (this.boundingBox.intersects(this.playerBoundingBox)){\n Rectangle leftHalfOfPlayer = new Rectangle((int)this.playerBoundingBox.getWidth() / 2, (int)this.playerBoundingBox.getHeight(),\n this.playerBoundingBox.x, this.playerBoundingBox.y);\n this.movement[0] = !this.boundingBox.intersects(leftHalfOfPlayer);\n this.movement[1] = false;\n } else {\n // Check if ball collides with brick;\n for (Bricks[] bricks : instance.getBricks()){\n for (Bricks brick: bricks){\n if (brick.collidesWith(new Rectangle(this.XPosition , this.YPosition , this.ballWidth , this.ballHeight))){\n Rectangle iRect = brick.brickHitBox.intersection(this.boundingBox);\n brick.destroy();\n //Sound brickBreak = new Sound(\"res/Break-Sound.wav\");\n this.brickBreak.play();\n // make logic\n this.movement[1] = true;\n if ((this.boundingBox.x+(this.boundingBox.width/2))<(iRect.x+(iRect.width/2))) {\n this.movement[0] = false;\n }\n if ((this.boundingBox.x+(this.boundingBox.width/2))>(iRect.x+(iRect.width/2))) {\n this.movement[0] = true;\n }\n if ((this.boundingBox.y+(this.boundingBox.height/2))<(iRect.y+(iRect.height/2))) {\n this.movement[1] = false;\n }\n }\n }\n }\n\n }\n\n }", "private int getCloseColor(int[] prgb) {\n \t\t\tfloat[] phsv = { 0, 0, 0 };\n \t\t\trgbToHsv(prgb[0], prgb[1], prgb[2], phsv);\n \t\t\t\n \t\t\tfloat hue = phsv[0];\n \t\t\tfloat val = phsv[2] * 100 / 256;\n \n \t\t\tint closest = -1;\n \n \t\t\tfinal int white = 15;\n \t\t\tfinal int black = 1;\n \t\t\tfinal int grey = 14;\n \t\t\t\n \t\t\tif (phsv[1] < (hue >= 30 && hue < 75 ? 0.66f : 0.33f)) {\n \t\t\t\tif (val >= 70) {\n \t\t\t\t\tclosest = white;\n \t\t\t\t} else if (val >= 10) {\n \t\t\t\t\t// dithering will take care of the rest\n \t\t\t\t\tclosest = grey;\n \t\t\t\t} else {\n \t\t\t\t\tclosest = black;\n \t\t\t\t}\n \t\t\t}\n \t\t\telse {\n \t\t\t\tclosest = getClosestColorByDistance(palette, firstColor, 16, prgb, 12);\n \t\t\t\t\n \t\t\t\t// see how the color matches\n \t\t\t\tif (closest == black) {\n \t\t\t\t\tif (phsv[1] > 0.9f) {\n \t\t\t\t\t\tif ((hue >= 75 && hue < 140) && (val >= 5 && val <= 33)) {\n \t\t\t\t\t\t\tclosest = 12;\n \t\t\t\t\t\t}\n \t\t\t\t\t}\n \t\t\t\t}\n \t\t\t\t/*else {\n \t\t\t\t\tint rigid = rigidMatch(phsv, hue, val);\n \t\t\t\t\tif (phsv[1] < 0.5f && (rigid == 1 || rigid == 14 || rigid == 15)) {\n \t\t\t\t\t\tclosest = rigid;\n \t\t\t\t\t}\n \t\t\t\t}*/\n \t\t\t}\n \t\t\t\n \t\t\t//closest = rigidMatch(phsv, hue, val);\n \t\t\t\n \t\t\treturn closest;\n \t\t}", "public void runPuzzleMovement( Screw screw, float screwVal, Platform p );", "public int evaluate(PentagoBoardState pbs) {\n PentagoBoardState.Piece[][] pieces = pbs.getBoard();\n\n\n int whitescore =0; //keep track of white's total score\n int blackscore = 0;//keep track of black's total score\n\n //Check rows\n for (int x = 0; x <6 ; x++) {\n int countWHori = 0;\n int countBHori = 0;\n\n int blacks = 0;\n int whites = 0;\n\n\n for (int y = 0; y <5 ; y++) {\n //Count how many black and white pieces\n if (pieces[x][y].ordinal() == 0 ) {\n\n //countBHori = countBHori + countvalue;\n blacks++;\n }\n if (pieces[x][y].ordinal() == 1) {\n\n //countWHori = countWHori +countvalue;\n whites++;\n }\n\n //Check for consecutive\n if (pieces[x][y].ordinal() == 0 && pieces[x][y+1].ordinal() == 0 ) {\n\n countBHori = countBHori +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 0 && pieces[x][y+1].ordinal() == 2 ) {\n\n countBHori = countBHori + blankspaceconsec;\n }\n else if (pieces[x][y].ordinal() == 2 && pieces[x][y+1].ordinal() == 0 ) {\n\n countBHori = countBHori + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x][y+1].ordinal() == 1 ) {\n\n countWHori = countWHori +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x][y+1].ordinal() == 2 ) {\n\n countWHori = countWHori + blankspaceconsec;\n }\n else if (pieces[x][y].ordinal() == 2 && pieces[x][y+1].ordinal() == 1 ) {\n\n countWHori = countWHori + blankspaceconsec;\n }\n\n //Check for disjoint and joint set If * B B W * * then disjoint and * B B * B * Then joint set for B * B\n if (y!=4){\n if (pieces[x][y].ordinal() == 0 && pieces[x][y+1].ordinal() == 0 && pieces[x][y+2].ordinal() == 1){\n countBHori = countBHori +disjointset;\n }\n else if (pieces[x][y].ordinal() == 1 && pieces[x][y+1].ordinal() == 1 && pieces[x][y+2].ordinal() == 0){\n countWHori = countWHori +disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x][y+1].ordinal() == 2 && pieces[x][y+2].ordinal() == 0){\n countBHori = countBHori +jointset;\n }\n else if (pieces[x][y].ordinal() == 1 && pieces[x][y+1].ordinal() == 2 && pieces[x][y+2].ordinal() == 1){\n countWHori = countWHori +jointset;\n }\n }\n }\n //check if unwinnable\n if (blacks == 4 && whites==2){\n countBHori += unwinnable;\n }\n if (blacks == 2 && whites==4){\n countWHori += unwinnable;\n }\n if (blacks == 3 && whites==3){\n countWHori += unwinnable;\n countBHori += unwinnable;\n }\n\n\n //Run value for row in evaluation scheme and add to total score\n int valuew = consecutivevalue(countWHori);\n whitescore = whitescore +valuew;\n int valueb = consecutivevalue(countBHori);\n blackscore = blackscore + valueb;\n //System.out.println(\"Black consec hori \" + valueb + \"White consec hori \" + valuew);\n\n }\n\n //Check Verticals\n for (int y = 0; y <6 ; y++) {\n int countWvert = 0;\n int countBvert = 0;\n int blacks = 0;\n int whites = 0;\n\n\n for (int x = 0; x <5 ; x++) {\n if (pieces[x][y].ordinal() == 0) {\n\n //countBvert = countBvert +1;\n blacks++;\n }\n if (pieces[x][y].ordinal() == 1) {\n\n //countWvert = countWvert +1;\n whites++;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y].ordinal() == 0 ) {\n\n countBvert = countBvert +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y].ordinal() == 2 ) {\n\n countBvert = countBvert + blankspaceconsec;\n }\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y].ordinal() == 0 ) {\n\n countBvert = countBvert + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y].ordinal() == 1 ) {\n\n countWvert = countWvert +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y].ordinal() == 2 ) {\n\n countWvert = countWvert + blankspaceconsec;\n }\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y].ordinal() == 1 ) {\n\n countWvert = countWvert + blankspaceconsec;\n }\n\n if (x!=4){\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y].ordinal() == 0 && pieces[x+1][y].ordinal() == 1){\n countBvert = countBvert +disjointset;\n }\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y].ordinal() == 1 && pieces[x+1][y].ordinal() == 0){\n countWvert = countWvert +disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y].ordinal() == 2 && pieces[x+1][y].ordinal() == 0){\n countBvert = countBvert +jointset;\n }\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y].ordinal() == 2 && pieces[x+1][y].ordinal() == 1){\n countWvert = countWvert +jointset;\n }\n }\n }\n\n if (blacks == 4 && whites==2){\n countBvert += unwinnable;\n }\n if (blacks == 3 && whites==3){\n countBvert += unwinnable;\n countWvert += unwinnable;\n }\n if (blacks == 2 && whites==4){\n countWvert += unwinnable;\n }\n //System.out.println(\"Black consec vert \" + countBvert + \"White consec \" + countWvert);\n int valuew = consecutivevalue(countWvert);\n whitescore = whitescore +valuew;\n int valueb = consecutivevalue(countBvert);\n blackscore = blackscore + valueb;\n //System.out.println(\"Black consec VERT \" + valueb + \"White consec hori \" + valuew);\n }\n\n //S West N EAST Top\n for (int a = 1; a <6 ; a++) { //loop through all diagonal lines\n int countWdiagSoNe = 0;\n int countBdiagSoNe = 0;\n int x=0;\n int blacks = 0;\n int whites = 0;\n\n\n for (int y = a; y !=0 ; y--) { //loop through one diagonal line\n\n int r = pieces[x][y].ordinal();\n int s =pieces[x+1][y-1].ordinal();\n //System.out.println(\"x \" + x+ \" y \" +y);\n //System.out.println(\"first \" + r+ \" second \" +s);\n if (pieces[x][y].ordinal() == 0) {\n\n //countBdiagSoNe = countBdiagSoNe +2;\n blacks++;\n }\n if (pieces[x][y].ordinal() == 1 ) {\n\n //countWdiagSoNe = countWdiagSoNe +2;\n whites++;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 ) {\n\n countBdiagSoNe = countBdiagSoNe +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 ) {\n\n countBdiagSoNe = countBdiagSoNe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y-1].ordinal() == 0 ) {\n\n countBdiagSoNe = countBdiagSoNe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 ) {\n\n countWdiagSoNe = countWdiagSoNe +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 ) {\n\n countWdiagSoNe = countWdiagSoNe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y-1].ordinal() == 1 ) {\n\n countWdiagSoNe = countWdiagSoNe + blankspaceconsec;\n }\n\n // check for joint and disjoint set at these x y coordinates by looking 2 pieces ahead\n if (x==0 && y==4){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n if (x==1 && y==3){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n if (x==2 && y==2){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n if (x==0 && y==5){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n if (x==1 && y==4){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n if (x==2 && y==3){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n if (x==3 && y==2){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n\n x++;\n\n\n }\n if (blacks == 4 && whites==2){\n countBdiagSoNe += unwinnable;\n }\n if (blacks == 3 && whites==3){\n countBdiagSoNe += unwinnable;\n countWdiagSoNe += unwinnable;\n }\n if (blacks == 2 && whites==4){\n countWdiagSoNe += unwinnable;\n }\n if (a==4 && blacks == 4 && whites==1){\n countBdiagSoNe += unwinnable;\n }\n if (a==4 && blacks == 1 && whites==4){\n countWdiagSoNe += unwinnable;\n }\n\n //System.out.println(\"Black consec vert \" + countBdiagSoNe + \"White consec \" + countWdiagSoNe);\n int valuew = consecutivevalue(countWdiagSoNe);\n whitescore = whitescore +valuew;\n int valueb = consecutivevalue(countBdiagSoNe);\n blackscore = blackscore + valueb;\n //System.out.println(\"Black consec DIAGOMAAL \" + valueb + \" \" + countBdiagSoNe + \"White consec hori \" + valuew + \" \" + countWdiagSoNe);\n }\n //S West N EAST Bot\n for (int a = 1; a <5 ; a++) {\n int countWdiagSoNe = 0;\n int countBdiagSoNe = 0;\n int y=5;\n int blacks = 0;\n int whites = 0;\n\n for (int x = a; x <5 ; x++) {\n\n int r = pieces[x][y].ordinal();\n int s =pieces[x+1][y-1].ordinal();\n //System.out.println(\"x \" + x+ \" y \" +y);\n //System.out.println(\"first \" + r+ \" second \" +s);\n if (pieces[x][y].ordinal() == 0) {\n\n //countBdiagSoNe = countBdiagSoNe +\n blacks++;\n }\n if (pieces[x][y].ordinal() == 1 ) {\n\n //countWdiagSoNe = countWdiagSoNe +2;\n whites++;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 ) {\n\n countBdiagSoNe = countBdiagSoNe +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 ) {\n\n countBdiagSoNe = countBdiagSoNe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y-1].ordinal() == 0 ) {\n\n countBdiagSoNe = countBdiagSoNe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 ) {\n\n countWdiagSoNe = countWdiagSoNe +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 ) {\n\n countWdiagSoNe = countWdiagSoNe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y-1].ordinal() == 1 ) {\n\n countWdiagSoNe = countWdiagSoNe + blankspaceconsec;\n }\n if (x==1 && y==5){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n if (x==2 && y==4){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n if (x==3 && y==3){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n //System.out.println(x + \" y:\" + y +\" Black consec DIAGOMAAL \" + countBdiagSoNe + \"White consec hori \" + countWdiagSoNe);\n y--;\n\n\n }\n if (a==1 && blacks == 4 && whites==1){\n countBdiagSoNe += unwinnable;\n }\n /*if (blacks == 3 && whites==3){\n countBdiagSoNe += unwinnable;\n countWdiagSoNe += unwinnable;\n }*/\n if (a==1&& blacks == 1 && whites==4){\n countWdiagSoNe += unwinnable;\n }\n //System.out.println(\"Black consec vert \" + countBdiagSoNe + \"White consec \" + countWdiagSoNe);\n int valuew = consecutivevalue(countWdiagSoNe);\n whitescore = whitescore +valuew;\n int valueb = consecutivevalue(countBdiagSoNe);\n blackscore = blackscore + valueb;\n //System.out.println(\"Black consec DIAGOMAAL \" + valueb + \" \" + countBdiagSoNe + \"White consec hori \" + valuew + \" \" + countWdiagSoNe);\n }\n\n //NorthWest S EAST Left\n for (int a = 0; a <5 ; a++) {\n int countWdiagNoSe = 0;\n int countBdiagNoSe = 0;\n int y=0;\n int blacks = 0;\n int whites = 0;\n\n for (int x = a; x <5 ; x++) {\n //System.out.println(pbs+\"x \" + x+ \" y \" +y);\n int r = pieces[x][y].ordinal();\n int s =pieces[x+1][y+1].ordinal();\n //System.out.println(\"x \" + x+ \" y \" +y);\n //System.out.println(\"first \" + r+ \" second \" +s);\n if (pieces[x][y].ordinal() == 0) {\n blacks++;\n //countBdiagNoSe = countBdiagNoSe +2;\n }\n if (pieces[x][y].ordinal() == 1) {\n whites++;\n //countWdiagNoSe = countWdiagNoSe +2;\n }\n\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 ) {\n\n countBdiagNoSe = countBdiagNoSe +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 ) {\n\n countBdiagNoSe = countBdiagNoSe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y+1].ordinal() == 0 ) {\n\n countBdiagNoSe = countBdiagNoSe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 ) {\n\n countWdiagNoSe = countWdiagNoSe +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 ) {\n\n countWdiagNoSe= countWdiagNoSe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y+1].ordinal() == 1 ) {\n\n countWdiagNoSe = countWdiagNoSe + blankspaceconsec;\n }\n\n if (x==0 && y==0){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n if (x==1 && y==1){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n if (x==2 && y==2){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n if (x==3 && y==3){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n if (x==1 && y==0){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n if (x==2 && y==1){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n if (x==3 && y==2){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n y++;\n\n\n }\n //System.out.println(\"Black consec vert \" + countBdiagSoNe + \"White consec \" + countWdiagSoNe);\n if (blacks == 4 && whites==2){\n countBdiagNoSe += unwinnable;\n }\n if (a==1 && blacks == 4 && whites==1){\n countBdiagNoSe += unwinnable;\n }\n if (blacks == 3 && whites==3){\n countBdiagNoSe += unwinnable;\n countWdiagNoSe += unwinnable;\n }\n if (blacks == 2 && whites==4){\n countWdiagNoSe += unwinnable;\n }\n if (a==1 && blacks == 1 && whites==4){\n countWdiagNoSe += unwinnable;\n }\n\n int valuew = consecutivevalue(countWdiagNoSe);\n whitescore = whitescore +valuew;\n int valueb = consecutivevalue( countBdiagNoSe);\n blackscore = blackscore + valueb;\n //System.out.println(\"Black consec DIAGOMAAL \" + valueb + \" \" + countBdiagNoSe + \"White consec hori \" + valuew + \" \" + countWdiagNoSe);\n }\n //NorthWest S EAST Right\n for (int a = 1; a <5 ; a++) {\n int countWdiagNoSe = 0;\n int countBdiagNoSe = 0;\n int x=0;\n int blacks = 0;\n int whites = 0;\n\n for (int y = a; y <5 ; y++) {\n //System.out.println(\"x \" + x+ \" y \" +y);\n int r = pieces[x][y].ordinal();\n int s =pieces[x+1][y+1].ordinal();\n //System.out.println(\"x \" + x+ \" y \" +y);\n //System.out.println(\"first \" + r+ \" second \" +s);\n if (pieces[x][y].ordinal() == 0 ) {\n blacks++;\n //countBdiagNoSe = countBdiagNoSe +2;\n }\n if (pieces[x][y].ordinal() == 1) {\n whites++;\n //countWdiagNoSe = countWdiagNoSe +2;\n }\n\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 ) {\n\n countBdiagNoSe = countBdiagNoSe +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 ) {\n\n countBdiagNoSe = countBdiagNoSe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y+1].ordinal() == 0 ) {\n\n countBdiagNoSe = countBdiagNoSe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 ) {\n\n countWdiagNoSe = countWdiagNoSe +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 ) {\n\n countWdiagNoSe= countWdiagNoSe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y+1].ordinal() == 1 ) {\n\n countWdiagNoSe = countWdiagNoSe + blankspaceconsec;\n }\n\n if (x==0 && y==1){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n if (x==1 && y==2){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n if (x==2 && y==3){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n x++;\n\n\n }\n if (a==1 && blacks == 1 && whites==4){\n countWdiagNoSe += unwinnable;\n }\n if (a==1 && blacks == 4 && whites==1){\n countBdiagNoSe += unwinnable;\n }\n //System.out.println(\"Black consec vert \" + countBdiagSoNe + \"White consec \" + countWdiagSoNe);\n int valuew = consecutivevalue(countWdiagNoSe);\n whitescore = whitescore +valuew;\n int valueb = consecutivevalue( countBdiagNoSe);\n blackscore = blackscore + valueb;\n //System.out.println(\"Black consec DIAGOMAAL \" + valueb + \" \" + countBdiagNoSe + \"White consec hori \" + valuew + \" \" + countWdiagNoSe);\n }\n\n\n\n\n\n //System.out.println(\"Black consec score \" + blackscore +\" \" + \"White consec scpre \" + whitescore);\n //System.out.println(\"max player is \" + maxplayer + \"My colour is \" + mycolour);\n int i = -123456789;\n if (mycolour == 0){\n //System.out.println(blackscore-whitescore +\" I am black\");\n\n\n i= blackscore-whitescore;\n return i;\n\n }\n else {\n //System.out.println(whitescore-blackscore +\" I am white\");\n i= whitescore-blackscore;\n return i;\n }\n /*\n if(i>0 && i<1000){\n return 100; //i*2;\n }\n else if(i>=1000 && i<10000){\n return 1000; //i*10;\n }\n else if(i>=10000 && i<100000){\n return 10000; //i*50;\n }\n else if(i>=100000){\n return 100000;//i*500;\n }\n else if(i<=0 && i>-100){\n return -100; //i*2;\n }\n else if(i<=-100 && i>-1000){\n return -1000; //i*10;\n }\n else if(i<=-1000 && i>-10000){\n return -10000; //i*50;\n }\n else if(i<=0 && i>-100000){\n return -100000;//i*500;\n }\n\n */\n\n\n }", "void checkForPlayer(boolean checkForBlacks, int i, int j) {\n\t\tcounter = 0;\n\t\tpossibleFlips.clear();\n\t\t//**Check vertical**\\\\\n\t\t// Check upwards\n\t\tfor (int n = j-1; n >= 0; --n) {\n\t\t\tif (!check(i, n, checkForBlacks))\n\t\t\t\tbreak;\n\t\t}\n\t\t\n\t\tcounter = 0;\n\t\tpossibleFlips.clear();\n\t\t\n\t\t// Check downwards\n\t\tfor (int n = j+1; n < dimensions.y; ++n) {\n\t\t\tif (!check (i, n, checkForBlacks))\n\t\t\t\tbreak;\n\t\t}\n\t\t\n\t\tcounter = 0;\n\t\tpossibleFlips.clear();\n\t\t\n\t\t//**Check horizontal**\\\\\n\t\t// Check to left\n\t\tfor (int n = i-1; n >=0; --n) {\n\t\t\tif (!check(n, j, checkForBlacks))\n\t\t\tbreak;\n\t\t}\n\n\t\tcounter = 0;\n\t\tpossibleFlips.clear();\n\t\t\n\t\t// Check to right\n\t\tfor (int n = i+1; n < dimensions.x; ++n) {\n\t\t\tif (!check(n, j, checkForBlacks))\n\t\t\tbreak;\n\t\t}\n\t\t\n\t\tcounter = 0;\n\t\tpossibleFlips.clear();\n\t\t\n\t\t//**Check diagonals**\\\\\n\t\t// Check North-East\n\t\tfor (int n = 1; i+n < dimensions.x && j-n >= 0; ++n) {\n\t\t\tif (!check(i+n, j-n, checkForBlacks))\n\t\t\tbreak;\n\t\t}\n\t\t\n\t\tcounter = 0;\n\t\tpossibleFlips.clear();\n\t\t\n\t\t// Check North-West\n\t\tfor (int n = 1; i-n >= 0 && j-n >= 0; ++n) {\n\t\t\tif (!check(i-n, j-n, checkForBlacks))\n\t\t\tbreak;\n\t\t}\n\t\t\n\t\tcounter = 0;\n\t\tpossibleFlips.clear();\n\t\t\n\t\t// Check South-East\n\t\tfor (int n = 1; i+n < dimensions.x && j+n < dimensions.y; ++n) {\n\t\t\tif (!check(i+n, j+n, checkForBlacks))\n\t\t\tbreak;\n\t\t}\n\t\t\n\t\tcounter = 0;\n\t\tpossibleFlips.clear();\n\t\t\n\t\t// Check South-West\n\t\tfor (int n = 1; i-n >= 0 && j+n < dimensions.y; ++n) {\n\t\t\tif (!check(i-n, j+n, checkForBlacks))\n\t\t\tbreak;\n\t\t}\n\t}", "public void moveBomber(){\n\t\t\t\n\t\t\tif (startredtimer) redtimer++;\n\t\t\tif (redtimer > 5) {\n\t\t\t\tredtimer = 0;\n\t\t\t\tstartredtimer = false;\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t\tif (rand.nextInt(21) == 20){ //controls the switching of directions\n\t\t\t\tif (direction == 1) direction = 0;\n\t\t\t\telse if (direction == 0) direction = 1;\n\t\t\t}\n\t\t\tif (direction == 1){ //actually moves the plain\n\t\t\t\tx += 10;\n\t\t\t\tr = true;\n\t\t\t}\n\t\t\telse if (direction == 0){\n\t\t\t\tx -= 10;\n\t\t\t\tr = false;\n\t\t\t}\n\t\t\t\n\t\t\tif (x <= 0) x = 992; //handles the ofscrean plane\n\t\t\telse if ( x >= 992) x = 0;\n\t\t\t\n\t\t\tthis.setBounds(x,y,100,50); //updates the bounds\n\t\t\t\n\t\t}", "private void UpdateSurround(int row, int col) {\n\t\t\n\t\t// updates the 3 positions below the bomb\n\t\tif(row - 1 >= 0) {\n\t\t\tif(grid[row-1][col] < 9)\n\t\t\t\tgrid[row-1][col] = grid[row-1][col] + 1;\n\t\t\tif(col - 1 >= 0) {\n\t\t\t\tif(grid[row-1][col-1] < 9)\n\t\t\t\t\tgrid[row-1][col-1] = grid[row-1][col-1] + 1;\n\t\t\t}\n\t\t\tif(col + 1 < width) {\n\t\t\t\tif(grid[row-1][col+1] < 9)\n\t\t\t\t\tgrid[row-1][col+1] = grid[row-1][col+1] + 1;\n\t\t\t}\n\t\t}\n\t\t// updates the 3 positions above the bomb\n\t\tif(row + 1 < height) {\n\t\t\tif(grid[row+1][col] < 9)\n\t\t\t\tgrid[row+1][col] = grid[row+1][col] + 1;\n\t\t\tif(col - 1 >= 0) {\n\t\t\t\tif(grid[row+1][col-1] <9)\n\t\t\t\t\tgrid[row+1][col-1] = grid[row+1][col-1] + 1;\n\t\t\t}\n\t\t\tif(col + 1 < width) {\n\t\t\t\tif(grid[row+1][col+1] < 9)\n\t\t\t\t\tgrid[row+1][col+1] = grid[row+1][col+1] + 1;\n\t\t\t}\n\t\t}\n\t\t// updates position to the left\n\t\tif(col - 1 >= 0) {\n\t\t\tif(grid[row][col-1] < 9)\n\t\t\t\tgrid[row][col-1] = grid[row][col-1] + 1;\n\t\t}\n\t\t// updates position to the right\n\t\tif(col + 1 < width) {\n\t\t\tif(grid[row][col+1] < 9)\n\t\t\t\tgrid[row][col+1] = grid[row][col+1] + 1;\n\t\t}\n\t}", "public double heuristic(Bitboard board) {\n double h = 0;\n\n // mobility\n int p1Mobility = 0;\n int p2Mobility = 0;\n // strength of piece positions\n double p1Position = 0;\n double p2Position = 0;\n // number of pieces\n int p1Pieces = 0;\n int p2Pieces = 0;\n // number of connected components\n int p1CC = 0;\n int p2CC = 0;\n // number of isolated circle pieces\n int p1Isolated = 0;\n int p2Isolated = 0;\n\n double weight;\n\n visited = 0;\n // check p1's pieces\n int posMasks = board.getPieces(0);\n int posMask;\n while (posMasks != 0) {\n posMask = posMasks & ~(posMasks - 1);\n posMasks ^= posMask;\n if ((visited & posMask) == 0) {\n if (exploreCC(board, posMask, 0) == 1)\n if (!board.isSquare(posMask))\n p1Isolated++;\n p1CC++;\n }\n weight = board.isSquare(posMask) ? weights[0] : weights[1];\n if (!boardValues.containsKey(posMask)) {\n System.out.println(\"I don't have \" + (int) (Math.log(posMask) / Math.log(2)));\n board.show();\n }\n p1Position += weight * boardValues.get(posMask);\n p1Pieces++;\n }\n // check p2's pieces\n visited = 0;\n posMasks = board.getPieces(1);\n while (posMasks != 0) {\n posMask = posMasks & ~(posMasks - 1);\n posMasks ^= posMask;\n if ((visited & posMask) == 0) {\n if (exploreCC(board, posMask, 1) == 1)\n if (!board.isSquare(posMask))\n p2Isolated++;\n p2CC++;\n }\n weight = board.isSquare(posMask) ? weights[0] : weights[1];\n p2Position += weight * boardValues.get(posMask);\n p2Pieces++;\n }\n\n // perform connected component analysis on empty spaces\n posToAdjCCID.clear();\n ccIDToOwner.clear();\n ownerToCCs.clear();\n int toCheck = (BitMasks.valid & (~board.getPieces()));\n int check;\n int ccId = 0;\n while (toCheck != 0) {\n check = toCheck & ~(toCheck - 1);\n toCheck ^= SearchUtils.checkSpaces(board, check, ccId++, posToAdjCCID, ccIDToOwner,\n ownerToCCs);\n }\n\n // check how close each player's circles are to an \"owned\" connected component\n int circles, circleMask, searchDistance;\n boolean adjacent;\n for (int turn = 0; turn < 2; turn++) {\n circles = board.getCircles(turn);\n while (circles != 0) {\n adjacent = false;\n circleMask = circles & ~(circles - 1);\n circles ^= circleMask;\n if (posToAdjCCID.containsKey(circleMask)) {\n for (int id : posToAdjCCID.get(circleMask)) {\n if (ccIDToOwner.get(id) == turn) {\n adjacent = true;\n break;\n }\n }\n }\n if (!adjacent) {\n searchDistance = search(board, circleMask, turn);\n if (turn == 0 && searchDistance > GameUtils.NUM_SLIDES) {\n h += -weights[6] * searchDistance;\n } else if (turn == 1 && searchDistance > GameUtils.NUM_SLIDES) {\n h += weights[6] * searchDistance;\n }\n }\n }\n }\n\n // a player missing a piece is the ultimate bad position\n if (p1Pieces != 5) {\n return -10000.0;\n }\n if (p2Pieces != 5) {\n return 10000.0;\n }\n // weight the components of the heuristic\n h += weights[2] * p1Mobility;\n h += -weights[2] * p2Mobility;\n h += weights[3] * p1Position;\n h += -weights[3] * p2Position;\n\n // make it so only > 1 connected components impacts heuristic\n h += -weights[4] * (p1CC - 1);\n h += weights[4] * (p2CC - 1);\n\n h += -weights[5] * p1Isolated;\n h += weights[5] * p2Isolated;\n\n h /= 6200; // normalize\n return h;\n }", "void changepos(MouseEvent e, pieces chessPiece) \n { \n for(int beta : chessPiece.movnum)\n { \n if (chessPiece.color == 0 && e.getSource()== panel[beta-1 ]&& chessPiece.select == true && Checkerboard.allWhitePositions.contains(beta-1) == false)\n {\n if(this.getPiece(beta-1) != null)\n { \n getPiece(beta-1).alive = false;\n \n \n \n panel[beta-1].removeAll();/*getPiece(beta-1).position = 64;*/\n }\n chessPiece.position = beta-1;\n chessPiece.movnum.clear();\n chessPiece.mov.clear();\n chessPiece.select = false;\n chessPiece.timesMoved++;\n whiteToPlay = false;\n }\n else if (chessPiece.color == 1 && e.getSource()== panel[beta-1 ]&& chessPiece.select == true && Checkerboard.allBlackPositions.contains(beta-1) == false)\n {\n if(this.getPiece(beta-1) != null)\n { \n getPiece(beta-1).alive = false; \n panel[beta-1].removeAll();/*getPiece(beta-1).position = 64;*/}\n chessPiece.position = beta-1;\n chessPiece.movnum.clear();\n chessPiece.mov.clear();\n chessPiece.select = false;\n chessPiece.timesMoved++;\n whiteToPlay = true;\n }\n }//for ends\n \n }", "private void moveRemainingMhos() {\n\t\t\n\t\t//Iterate through every mho's X and Y values\n\t\tfor(int i = 0; i < mhoLocations.size()/2; i++) {\n\t\t\t\n\t\t\t//Assign mhoX and mhoY to the X and Y values of the mho that is currently being tested\n\t\t\tint mhoX = mhoLocations.get(i*2);\n\t\t\tint mhoY = mhoLocations.get(i*2+1);\n\t\t\t\n\t\t\t//Check if there is a fence 1 block away from the mho\n\t\t\tif(newMap[mhoX][mhoY+1] instanceof Fence || newMap[mhoX][mhoY-1] instanceof Fence || newMap[mhoX-1][mhoY] instanceof Fence || newMap[mhoX-1][mhoY+1] instanceof Fence || newMap[mhoX-1][mhoY-1] instanceof Fence || newMap[mhoX+1][mhoY] instanceof Fence || newMap[mhoX+1][mhoY+1] instanceof Fence || newMap[mhoX+1][mhoY-1] instanceof Fence) {\n\t\t\t\t\n\t\t\t\t//Assign the new map location as a Mho\n\t\t\t\tnewMap[mhoX][mhoY] = new BlankSpace(mhoX, mhoY, board);\n\t\t\t\t\n\t\t\t\t//Set the mho's move in the moveList\n\t\t\t\tmoveList[mhoX][mhoY] = Legend.SHRINK;\n\t\t\t\t\n\t\t\t\t//remove each X and Y from mhoLocations\n\t\t\t\tmhoLocations.remove(i*2+1);\n\t\t\t\tmhoLocations.remove(i*2);\n\t\t\t\t\n\t\t\t\t//Call moveRemainingMhos again, because the list failed to be checked through completely\n\t\t\t\tmoveRemainingMhos();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}", "private int Win_Move() {\n\t\tfinal int POSSIBLE_WIN = 8;\n\t\tint move = NO_MOVE;\n\t\tif(( gameBoard[TOP_LEFT] + gameBoard[TOP_CENTER] + gameBoard[TOP_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[TOP_CENTER] == EMPTY){\n\t\t\t\tmove = TOP_CENTER;\n\t\t\t}else if (gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[CTR_LEFT] + gameBoard[CTR_CENTER] + gameBoard[CTR_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[CTR_LEFT] == EMPTY){\n\t\t\t\tmove = CTR_LEFT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[CTR_RIGHT] == EMPTY){\n\t\t\t\tmove = CTR_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[BTM_LEFT] + gameBoard[BTM_CENTER] + gameBoard[BTM_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}else if (gameBoard[BTM_CENTER] == EMPTY){\n\t\t\t\tmove = BTM_CENTER;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_LEFT] + gameBoard[CTR_LEFT] + gameBoard[BTM_LEFT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[CTR_LEFT] == EMPTY){\n\t\t\t\tmove = CTR_LEFT;\n\t\t\t}else if (gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_CENTER] + gameBoard[CTR_CENTER] + gameBoard[BTM_CENTER]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_CENTER] == EMPTY){\n\t\t\t\tmove = TOP_CENTER;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_CENTER] == EMPTY){\n\t\t\t\tmove = BTM_CENTER;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_RIGHT] + gameBoard[CTR_RIGHT] + gameBoard[BTM_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}else if (gameBoard[CTR_RIGHT] == EMPTY){\n\t\t\t\tmove = CTR_RIGHT;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_LEFT] + gameBoard[CTR_CENTER] + gameBoard[BTM_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_RIGHT] + gameBoard[CTR_CENTER] + gameBoard[BTM_LEFT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}\n\t\t}\n\t\treturn move;\n\t}", "@Override\n public DirType getMove(GameState state) {\n if (print) System.out.println(\"\\n\\n\");\n this.gb.update(state); // Must be done every turn\n this.findEnemySnake(); // Update Enemy Snake's head Location\n this.markDangerTiles(); // Mark tiles the Enemy Snake can reach and filled\n if (print) this.gb.printBoard();\n if (print) System.out.println(\"DIVEBOMB ENTER -> Us_X: \" + this.us_head_x + \", Us_Y: \" + this.us_head_y + \" -> \" + this.us_num);\n Tile target = this.diveBomb();\n if (print) System.out.print(\"DIVEBOMB EXIT -> Target_X: \" + target.getX() + \" Target_Y: \" + target.getY());\n DirType retVal = getDir(target);\n if (print) System.out.println(\" Dir: \" + retVal);\n\n\n if (this.us_num == 0) {\n System.out.println(\"\\n\\n\\n\");\n GameBoard gb= new GameBoard(state, 1,0);\n gb.update(state);\n float val = USuckUnless.grade(state, this.us_num, DirType.South);\n System.out.println(val);\n this.gb.printBoard();\n }\n return retVal;\n }", "public int getMarbles(int remainingMarbles) {\n\n /*\n Counter Used to keep track of how many marbles the SmartComputer has\n removed within his turn.\n */\n int Counter = 0 ;\n\n /*\n Local Variable \"holder\" Serves as a holder for the Intial Pile Size.\n This is used to check if the SmartComputer has removed half the amount\n of this current size. If so, It is also used to create a random number\n between 1 and this holders value which is the current pile size entered\n into the method.\n */\n int holder = remainingMarbles ;\n /*\n This While Loop Within the getMarbles() Method is the Algorithm for\n how the SmartComputer ensures it leaves a Pilesize of a power of 2 - 1.\n First, it checks to see if the Current Remaining Pile Size is a power of\n 2, if so the While Loop Breaks and Counter is initialized and returned.\n (1 Marble Removed to Leave Power of 2 - 1). However, if the Current \n Pile Size is not a power of 2, it will remove 1 marble and check to see\n if it has removed half the amount of marbles within the current pile. \n If it has, then it Stops and instead of removing that amount it instead \n ends up removing a random number between 1 and half the current pile \n size.This is because, the method has to remove one more marble in the \n end, which would be more than half which is not allowed. However, if it \n has not removed more than half it will keep removing and checking if the\n left over amount is a power of 2. When it obtains a power of 2 within \n the pile, it will remove exactly 1 more to leave a Power of 2 - 1 to \n ensure victory.\n */\n while (!isFound(remainingMarbles)) {\n remainingMarbles-- ;//Removes a marble if not power of 2 yet.\n Counter++ ;//Counter for how many marbles have been removed.\n /*\n You Might be thinking, How come the Smart Computer cannot remove \n half the amount of the pile? Well Because the Smart computer will\n never want to stop at half, it will want to continue as there is\n no power of 2 - 1 that can be reached by subtracting half of another \n power of 2 - 1. Example, 31: The SmartComputer Will want to get to\n 15, However that entails removing 16, Which is more than half, \n Therefore once the Counter reaches 15 it stops for it knows it will\n try to remove one more, therefore it returns a random int between\n 1 and the Initial Entered Pile Size instead. \n */\n if (Counter == ((holder) / 2)) {\n return ((gen.nextInt(holder / 2)) + 1) ;\n }\n }\n return ++Counter ; //Returns one more than the number of moves down to \n //get the pile to a power of 2 in order to leave a power of 2 - 1.\n }", "public static int bishopAttacks(int[][] board, int[][] bishops){\n int count = 0;\r\n if(bishops.length < 2){\r\n return 0;\r\n }\r\n for(int i = 0 ; i < bishops.length - 1; i++){\r\n if(bishops[i][0] >= board.length || bishops[i][1] >= board.length || bishops[i][0] < 0 || bishops[i][1] < 0){\r\n return -1;\r\n }\r\n for(int j = i+1; j < bishops.length; j++){\r\n if(Math.abs(bishops[i][0] - bishops[j][0]) == Math.abs(bishops[i][1] - bishops[j][1])){\r\n count++;\r\n }\r\n }\r\n }\r\n return count;\r\n }", "@Override\n\tpublic boolean testMove(int xEnd, int yEnd, board b){\n return (xEnd == x - 1 && yEnd == y - 1) || (xEnd == x - 1 && yEnd == y) || (xEnd == x - 1 && yEnd == y + 1) || (xEnd == x && yEnd == y - 1) || (xEnd == x && yEnd == y + 1) || (xEnd == x + 1 && yEnd == y - 1) || (xEnd == x + 1 && yEnd == y) || (xEnd == x + 1 && yEnd == y + 1);\n\t}", "private static boolean makeHallway(int[][] board, int[] from, int[] to, float[] filled, Random random) {\n // ignore out of bounds attempts\n if (!(from[X] >= 0 && from[X] < board.length && from[Y] >= 0 && from[Y] < board[0].length)\n || !(to[X] >= 0 && to[X] < board.length && to[Y] >= 0 && to[Y] < board[0].length)) {\n return false;\n }\n\n int x1 = from[X];\n int x2 = to[X];\n int y1 = from[Y];\n int y2 = to[Y];\n\n board[x1][y1] = ROOM;\n board[x2][y2] = ROOM;\n\n filled[0] += 2;\n\n // keep track of directional motion\n int dirX, dirY;\n\n // find initial direction\n if (x2 > x1)\n dirX = 1; // east\n else\n dirX = -1; // west\n if (y2 > y1)\n dirY = 1; // north\n else\n dirY = -1; // south\n\n // move into random direction\n boolean firstHorizontal = random.nextBoolean();\n boolean secondHorizontal = random.nextBoolean();\n\n // making a corridor might take awhile, just continue this iterative\n // process\n while (true) {\n\n if (x1 != x2 && y1 != y2) {\n // adjust the first tile iterator\n if (firstHorizontal)\n x1 += dirX;\n else\n y1 += dirY;\n }\n\n if (x1 != x2 && y1 != y2)\n // still not equal\n {\n // adjust the second tile iterator\n if (secondHorizontal)\n x2 -= dirX;\n else\n y2 -= dirY;\n }\n\n if (board[x1][y1] == NULL) {\n board[x1][y1] = HALL;\n filled[0]++;\n }\n if (board[x2][y2] == NULL) {\n board[x2][y2] = HALL;\n filled[0]++;\n }\n // check once more if the iterators match after moving\n // if the iterators are on the same level, try connecting them\n if (x1 == x2) {\n while (y1 != y2) {\n // adjust y until we reach destination\n y1 += dirY;\n if (board[x1][y1] == NULL) {\n board[x1][y1] = HALL;\n filled[0]++;\n }\n }\n if (board[x1][y1] == NULL) {\n board[x1][y1] = HALL;\n filled[0]++;\n }\n // return that we've connected the hallway successfully\n return true;\n }\n // iterators are on the same level horizontally, so we must now\n // connect across\n if (y1 == y2) {\n while (x1 != x2) {\n // adjust y until we reach destination\n x1 += dirX;\n if (board[x1][y1] == NULL) {\n board[x1][y1] = HALL;\n filled[0]++;\n }\n }\n if (board[x1][y1] == NULL) {\n board[x1][y1] = HALL;\n filled[0]++;\n }\n return true;\n }\n }\n }", "public void speckle() {\n\t\tint r = (height / res) - 1;\n\t\tint c = (width / res);\n\t\tfor (int i = 0; i < c; i++)\t\t{\n\t\t\tint x = rng.nextInt(25);\t\t\t\n\t\t\tif (x == 0) { // 1/25 chance of changing bottom row pixel to black\t \n\t\t\t\tvalues[r][i] = color1;\t\t\t\t\n\t\t\t}\n\t\t\telse if (x == 1) { // 1/25 chance of changing bottom row pixel to white\n\t\t\t\tvalues[r][i] = color2;\n\t\t\t}\n\t\t\t// 23/25 chance of leaving bottom pixel alone\n\t\t}\n\t}", "public Board move(int algo){\n //if the game has not been started and it is a black piece\n if (state.noMovesMade() == 0 && color == 1){\n state.increaseMoveCount();\n\n int [] arr= new int [] {1,4,5,8};\n\n int rand_int = rand.nextInt(4);\n System.out.println(\"Removed \" + color + \" Piece at index \"+ arr[rand_int] +\", \" + arr[rand_int] );\n\n state.remove(arr[rand_int],arr[rand_int]);\n\n return state;\n }\n\n //if it is white first move\n if(state.noMovesMade() == 1 && color == -1){\n state.increaseMoveCount();\n\n\n List<int []> adjPositions = state.getAdjacentSpots();\n int rand_int = rand.nextInt(adjPositions.size());\n System.out.println(\"Removed \" + color + \" Piece at index \"+ adjPositions.get(rand_int)[0] +\", \" + adjPositions.get(rand_int)[1] );\n\n state.remove(adjPositions.get(rand_int)[0],adjPositions.get(rand_int)[1]);\n return state;\n }\n\n Move action = new Move();\n if(algo == 1){\n action = alphaBetaHeurisitic();\n\n }\n else if (algo == 2){\n action = miniMaxHeurisitic();\n }\n else if (algo == 3){\n action = randomHeurisitic();\n\n }\n else if (algo == 4){\n\n }\n moveHelper(action);\n\n return state;\n }", "public static void main(String[] args) {\n\n chessGUI g = new chessGUI();\n\n /*\n // test Root-1\n System.out.println(\"Hello World!\");\n Board test = new Board();\n test.printBoard();\n Piece king1 = new King(1, new Position(2,2), test);\n Piece king2 = new King(1, new Position(1,1), test);\n Piece ROOK3 = new Rook(-1, new Position(1,2), test);\n test.putPieceOnBoard(king1.getRow(), king1.getCol(), king1);\n test.putPieceOnBoard(king2.getRow(), king2.getCol(), king2);\n test.putPieceOnBoard(ROOK3.getRow(), ROOK3.getCol(), ROOK3);\n test.printBoard();\n Object r = ROOK3;\n if (r instanceof Rook){\n System.out.println(\"r instanceof Rook\");\n //r = (Rook) r;\n //System.out.println(((King) k).getBoard()==null);\n //.printBoard();\n int result = ((Rook) r).judgeMove(3,2);\n System.out.println(\"result\"+result);\n }\n\n // test Bishop\n Board test = new Board();\n test.printBoard();\n Piece king1 = new King(1, new Position(2,2), test);\n Piece king2 = new King(-1, new Position(1,1), test);\n Piece king3 = new King(1, new Position(2,3), test);\n\n Piece bishop = new Bishop(-1, new Position(1,2), test);\n test.putPieceOnBoard(king1.getRow(), king1.getCol(), king1);\n test.putPieceOnBoard(king2.getRow(), king2.getCol(), king2);\n test.putPieceOnBoard(king3.getRow(), king3.getCol(), king3);\n test.putPieceOnBoard(bishop.getRow(), bishop.getCol(), bishop);\n test.printBoard();\n Object r = bishop;\n if (r instanceof Bishop){\n System.out.println(\"r instanceof Bishop\");\n // 2,1 == 0\n // 2,3 == 1\n // 4,5 == -3\n int result = ((Bishop) r).judgeMove(4,5);\n System.out.println(\"result\"+result);\n }\n\n\n // test Queen\n Board test = new Board();\n test.printBoard();\n Piece king1 = new King(1, new Position(2,2), test);\n Piece king2 = new King(-1, new Position(1,1), test);\n Piece king3 = new King(1, new Position(2,3), test);\n\n Piece queen = new Queen(-1, new Position(3,2), test);\n test.putPieceOnBoard(king1.getRow(), king1.getCol(), king1);\n test.putPieceOnBoard(king2.getRow(), king2.getCol(), king2);\n test.putPieceOnBoard(king3.getRow(), king3.getCol(), king3);\n test.putPieceOnBoard(queen.getRow(), queen.getCol(), queen);\n test.printBoard();\n Object r = queen;\n if (r instanceof Queen){\n System.out.println(\"r instanceof Queen\");\n // 4,3 == 0\n // 2,2 == 1\n // 1,4 == -3\n // 3,2 == -2\n\n // 1,4 == -3\n // 5,2 == 0\n // 5,4 == 0\n // 1,0 == 0\n\n // 0,2 == -3\n // 2,3 == 1\n\n }\n Piece king4 = new King(1, new Position(4,1), test);\n test.putPieceOnBoard(king4.getRow(), king4.getCol(), king4);\n test.printBoard();\n // 4,1 == 1\n // 5, 0 == -3\n // 5, 5 == -4\n int result = ((Queen) r).judgeMove(5,5);\n System.out.println(\"result\"+result);\n\n //test Knight\n Board test = new Board();\n test.printBoard();\n Piece king1 = new King(1, new Position(2,2), test);\n Piece king2 = new King(-1, new Position(1,1), test);\n Piece king3 = new King(1, new Position(2,3), test);\n Piece queen = new Queen(-1, new Position(3,3), test);\n Piece queen1 = new Queen(1, new Position(3,1), test);\n\n Piece knight = new Knight(-1, new Position(1,2), test);\n test.putPieceOnBoard(king1.getRow(), king1.getCol(), king1);\n test.putPieceOnBoard(king2.getRow(), king2.getCol(), king2);\n test.putPieceOnBoard(king3.getRow(), king3.getCol(), king3);\n test.putPieceOnBoard(queen.getRow(), queen.getCol(), queen);\n test.putPieceOnBoard(queen1.getRow(), queen1.getCol(), queen1);\n test.putPieceOnBoard(knight.getRow(), knight.getCol(), knight);\n test.printBoard();\n Object r = knight;\n if (r instanceof Knight){\n System.out.println(\"r instanceof Knight\");\n // 2,0 == 0\n // 3,1 == 1\n // 3,3 == -3\n // 2,3 == -4\n int result = ((Knight) r).judgeMove(3,1);\n System.out.println(\"result\"+result);\n }\n\n //test Pawn\n Board test = new Board();\n Piece king1 = new King(-1, new Position(2,2), test);\n Piece king2 = new King(-1, new Position(1,1), test);\n Piece king3 = new King(-1, new Position(3,3), test);\n Piece king4 = new King(1, new Position(4,0), test);\n\n Piece pawn = new Pawn(1, new Position(1,3), test);\n Piece pawn_1 = new Pawn(-1, new Position(5,1), test);\n test.putPieceOnBoard(king1.getRow(), king1.getCol(), king1);\n test.putPieceOnBoard(king2.getRow(), king2.getCol(), king2);\n test.putPieceOnBoard(king3.getRow(), king3.getCol(), king3);\n test.putPieceOnBoard(king4.getRow(), king4.getCol(), king4);\n test.putPieceOnBoard(pawn.getRow(), pawn.getCol(), pawn);\n test.putPieceOnBoard(pawn_1.getRow(), pawn_1.getCol(), pawn_1);\n\n test.printBoard();\n // pawn 2,2 = 1\n // pawn 2,3 = 0\n // pawn -3, 0 = -1\n // pawn 1,3 = -2\n // pawn 0,3 = -4\n // pawn 3,3 = -3\n\n\n //(Pawn) pawn).isFirstMove = 0;\n\n // pawn[-1] 6,1 = -4\n // pawn[-1] 4,0 = 1\n // pawn[-1] 4,1 = 0\n // pawn[-1] 3,1 = 0\n int result = ((Pawn) pawn_1).judgeMove(3,1);\n\n System.out.println(\"result\"+result);\n\n Board test = new Board();\n Piece king1 = new King(1, new Position(2,2), test);\n Piece king2 = new King(-1, new Position(1,1), test);\n Piece king3 = new King(1, new Position(2,3), test);\n Piece queen = new Queen(-1, new Position(3,3), test);\n Piece queen1 = new Queen(1, new Position(3,1), test);\n\n Piece rook = new Rook(-1, new Position(1,2), test);\n\n test.putPieceOnBoard(king1.getRow(), king1.getCol(), king1);\n test.putPieceOnBoard(king2.getRow(), king2.getCol(), king2);\n test.putPieceOnBoard(king3.getRow(), king3.getCol(), king3);\n test.putPieceOnBoard(queen.getRow(), queen.getCol(), queen);\n test.putPieceOnBoard(queen1.getRow(), queen1.getCol(), queen1);\n test.putPieceOnBoard(rook.getRow(), rook.getCol(), rook);\n test.printBoard();\n\n // 2,2 = 1\n // 1,3 = 0\n // 1,5 = 0\n // -1,0 = -1\n // 1,2 = -2\n // 1,0 = -3\n // 0,0 = -4\n int result = ((Rook) rook).judgeMove(1,3);\n\n System.out.println(\"result\"+result);\n */\n\n /* test startingBoard()\n Board board = new Board();\n board.startingBoard();\n board.printBoard();\n */\n\n //test pawnThread();\n /*\n Board board = new Board();\n Piece kingwhite = new King(1, new Position(2,2), board);\n Piece kingblack = new King(-1, new Position(5,2), board);\n Piece king3 = new King(1, new Position(3,4), board);\n Piece p1 = new Pawn(1, new Position(4,1), board);\n Piece p2 = new Pawn(-1, new Position(4,3), board);\n Piece p3 = new Pawn(1, new Position(3,1), board);\n Piece p4 = new Pawn(-1, new Position(1,1), board);\n\n board.putPieceOnBoard(kingwhite.getRow(),kingwhite.getCol(),kingwhite);\n board.putPieceOnBoard(kingblack.getRow(),kingblack.getCol(),kingblack);\n board.putPieceOnBoard(king3.getRow(), king3.getCol(), king3);\n board.putPieceOnBoard(p1.getRow(), p1.getCol(), p1);\n board.putPieceOnBoard(p2.getRow(), p2.getCol(), p2);\n board.putPieceOnBoard(p3.getRow(), p3.getCol(), p3);\n board.putPieceOnBoard(p4.getRow(), p4.getCol(), p4);\n\n board.printBoard();\n // true\n System.out.println(board.pawnThread(-1*kingblack.getColor(),kingblack.getRow(),kingblack.getCol()));\n // false\n System.out.println(board.pawnThread(-1*kingwhite.getColor(),kingwhite.getRow(),kingwhite.getCol()));\n // true\n System.out.println(board.pawnThread(-1*king3.getColor(),king3.getRow(),king3.getCol()));\n */\n\n //test kingThread();\n /*\n Board board = new Board();\n Piece king1 = new King(1, new Position(2,2), board);\n Piece king2 = new King(-1, new Position(5,2), board);\n\n Piece p1 = new King(1, new Position(3,2), board);\n Piece p2 = new King(-1, new Position(5,1), board);\n Piece p3 = new King(1, new Position(4,1), board);\n Piece p4 = new King(1, new Position(4,3), board);\n\n\n board.putPieceOnBoard(king1.getRow(),king1.getCol(),king1);\n board.putPieceOnBoard(king2.getRow(),king2.getCol(),king2);\n board.putPieceOnBoard(p1.getRow(), p1.getCol(), p1);\n board.putPieceOnBoard(p2.getRow(), p2.getCol(), p2);\n board.putPieceOnBoard(p3.getRow(), p3.getCol(), p3);\n board.putPieceOnBoard(p4.getRow(), p4.getCol(), p4);\n board.printBoard();\n //false\n System.out.println(board.kingThread(-1*king1.getColor(),king1.getRow(),king1.getCol()));\n //true\n System.out.println(board.kingThread(-1*king2.getColor(),king2.getRow(),king2.getCol()));\n //true\n System.out.println(board.kingThread(-1*p4.getColor(),p4.getRow(),p4.getCol()));\n //false\n System.out.println(board.kingThread(-1*p1.getColor(),p1.getRow(),p1.getCol()));\n */\n\n\n //test knightThread();\n /*\n Board board = new Board();\n Piece k1 = new King(1, new Position(2,2), board);\n Piece k2 = new King(-1, new Position(5,2), board);\n Piece k3 = new King(-1, new Position(6,4), board);\n\n Piece p1 = new Knight(-1, new Position(0,3), board);\n Piece p2 = new Knight(-1, new Position(5,1), board);\n Piece p3 = new Knight(1, new Position(4,1), board);\n Piece p4 = new Knight(1, new Position(4,4), board);\n\n\n board.putPieceOnBoard(k1.getRow(),k1.getCol(),k1);\n board.putPieceOnBoard(k2.getRow(),k2.getCol(),k2);\n board.putPieceOnBoard(k3.getRow(),k3.getCol(),k3);\n board.putPieceOnBoard(p1.getRow(), p1.getCol(), p1);\n board.putPieceOnBoard(p2.getRow(), p2.getCol(), p2);\n board.putPieceOnBoard(p3.getRow(), p3.getCol(), p3);\n board.putPieceOnBoard(p4.getRow(), p4.getCol(), p4);\n board.printBoard();\n //true\n System.out.println(board.knightThread(-1*k1.getColor(),k1.getRow(),k1.getCol()));\n //true\n System.out.println(board.knightThread(-1*k2.getColor(),k2.getRow(),k2.getCol()));\n //false\n System.out.println(board.knightThread(-1*k3.getColor(),k3.getRow(),k3.getCol()));\n */\n\n //test bishopQueenThread();\n/*\n Board board = new Board();\n //board.bishopQueenThread(1, 3,4);\n\n Piece k1 = new King(1, new Position(2,2), board);\n Piece k2 = new King(-1, new Position(5,2), board);\n Piece k3 = new King(1, new Position(6,4), board);\n\n Piece p1 = new Bishop(-1, new Position(0,3), board);\n Piece p2 = new Bishop(-1, new Position(5,1), board);\n Piece p3 = new Bishop(1, new Position(3,0), board);\n Piece p4 = new Bishop(1, new Position(4,4), board);\n Piece p5 = new Bishop(-1, new Position(5,5), board);\n\n\n board.putPieceOnBoard(k1.getRow(),k1.getCol(),k1);\n board.putPieceOnBoard(k2.getRow(),k2.getCol(),k2);\n board.putPieceOnBoard(k3.getRow(),k3.getCol(),k3);\n board.putPieceOnBoard(p1.getRow(), p1.getCol(), p1);\n board.putPieceOnBoard(p2.getRow(), p2.getCol(), p2);\n board.putPieceOnBoard(p3.getRow(), p3.getCol(), p3);\n board.putPieceOnBoard(p4.getRow(), p4.getCol(), p4);\n board.putPieceOnBoard(p5.getRow(), p5.getCol(), p5);\n board.printBoard();\n //false\n System.out.println(board.bishopQueenThread(-1*k1.getColor(),k1.getRow(),k1.getCol()));\n //true\n System.out.println(board.bishopQueenThread(-1*k2.getColor(),k2.getRow(),k2.getCol()));\n //true\n System.out.println(board.bishopQueenThread(-1*k3.getColor(),k3.getRow(),k3.getCol()));\n */\n\n //test rookQueenThread\n\n /*\n Piece k1 = new King(1, new Position(2,2), board);\n Piece k2 = new King(1, new Position(5,2), board);\n Piece k3 = new King(-1, new Position(6,4), board);\n\n Piece p1 = new Rook(-1, new Position(0,3), board);\n Piece p2 = new Rook(-1, new Position(5,1), board);\n Piece p3 = new Rook(1, new Position(3,0), board);\n Piece p4 = new Rook(1, new Position(4,4), board);\n Piece p5 = new Rook(-1, new Position(5,5), board);\n\n\n board.putPieceOnBoard(k1.getRow(),k1.getCol(),k1);\n board.putPieceOnBoard(k2.getRow(),k2.getCol(),k2);\n board.putPieceOnBoard(k3.getRow(),k3.getCol(),k3);\n board.putPieceOnBoard(p1.getRow(), p1.getCol(), p1);\n board.putPieceOnBoard(p2.getRow(), p2.getCol(), p2);\n board.putPieceOnBoard(p3.getRow(), p3.getCol(), p3);\n board.putPieceOnBoard(p4.getRow(), p4.getCol(), p4);\n board.putPieceOnBoard(p5.getRow(), p5.getCol(), p5);\n board.printBoard();\n //false\n System.out.println(board.rookQueenThread(-1*k1.getColor(),k1.getRow(),k1.getCol()));\n //true\n System.out.println(board.rookQueenThread(-1*k2.getColor(),k2.getRow(),k2.getCol()));\n //true\n System.out.println(board.rookQueenThread(-1*k3.getColor(),k3.getRow(),k3.getCol()));\n */\n\n\n }", "@Override\n public void update() {\n super.update();\n\n //check if ball is out\n checkBallOutTopBottom();\n checkBallOutLeftRight();\n }", "public int check4CollisionWithBlue(Player player)\n {\n int number_of_collisions = 0;\n int x_cord = getMidPoint(player.x_cordinate);\n int y_cord = getMidPoint(player.y_cordinate);\n int blux1 = getMidPoint(getBlue_player1().x_cordinate);//blue_player1.x_cordinate;\n int blux2 = getMidPoint(getBlue_player2().x_cordinate);\n int blux3 = getMidPoint(getBlue_player3().x_cordinate);//blue_player3.x_cordinate;\n int blux4 = getMidPoint(getBlue_player4().x_cordinate);//blue_player4.x_cordinate;\n int bluy1 = getMidPoint(getBlue_player1().y_cordinate);//blue_player1.y_cordinate;\n int bluy2 = getMidPoint(getBlue_player2().y_cordinate);//blue_player2.y_cordinate;\n int bluy3 = getMidPoint(getBlue_player3().y_cordinate);//blue_player3.y_cordinate;\n int bluy4 = getMidPoint(getBlue_player4().y_cordinate);//blue_player4.y_cordinate;\n number_of_collisions += collisionDetection(x_cord, y_cord, blux1, bluy1);\n number_of_collisions += collisionDetection(x_cord, y_cord, blux2, bluy2);\n number_of_collisions += collisionDetection(x_cord, y_cord, blux3, bluy3);\n number_of_collisions += collisionDetection(x_cord, y_cord, blux4, bluy4);\n return number_of_collisions;\n }", "boolean move(int a, int b, int ring) {//TODO: effizienter schreiben\t\n\t\tif(this.Ring == ring) {\n\t\t\t//interring bewegung\n\t\t\t\t//Bedingung1: Abstand=1\n\t\t\t\tif(Math.abs(X-a)+Math.abs(Y-b) == 1)return true;\n\t\t}\n\t\t//extraring bewegung\n\t\tif(this.Ring != ring) { \n\t\t\tif(Math.abs(Ring-ring) == 1 && X==a && Y==b)return true;\n\t\t}\n\t\treturn false;\n\t}", "public static boolean isValid(Chessmen[][] chessboard, int oldJ, int oldI, int newJ, int newI){\n\t\tboolean movePattern = false; //checks for the movement pattern of pieces\n\t\tboolean isPathClear = false; // checks if path is clear \n\t\tboolean isDestinationClear = false;\n\n\n\t\t//check movement pattern \n\t\tswitch(chessboard[oldJ][oldI]){\n\t\tcase WHITE_PAWN:\t\t\t\t\t\t\t\t\t//can move only one step ahead\n\t\t\tif(((newI - oldI)==0) && (newJ-oldJ == 1)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase WHITE_ROOK: \t\t\t\t\t\t\t\t\t//can move horizontally or vertically\n\t\t\tif(((newI - oldI)==0) || ((newJ - oldJ)==0)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase WHITE_KNIGHT:\t\t\t\t\t\t\t\t\t//moves in L shape\n\t\t\tif((Math.abs(newI-oldI)==2)&& (Math.abs(newJ-oldJ)==1) || (Math.abs(newI-oldI)==1)&& (Math.abs(newJ-oldJ)==2)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase WHITE_BISHOP:\t\t\t\t\t\t\t\t\t//no of steps in x = no. of steps in y\n\t\t\tif(Math.abs(newI - oldI) == Math.abs(newJ - oldJ)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase WHITE_KING:\t\t\t\t\t\t\t\t\t//no of steps in x & y is atmost 1\n\t\t\tif((Math.abs(newI - oldI)<2) && (Math.abs(newJ - oldJ)<2) ){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase WHITE_QUEEN: \n\t\t\tif(Math.abs(newI - oldI) == Math.abs(newJ - oldJ)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else if(((newI - oldI)==0) || ((newJ - oldJ)==0)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase BLACK_PAWN:\n\t\t\tif(((newI - oldI)==0) && (oldJ-newJ == 1)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase BLACK_ROOK: \n\t\t\tif(((newI - oldI)==0) || ((newJ - oldJ)==0)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase BLACK_KNIGHT: \n\t\t\tif((Math.abs(newI-oldI)==2)&& (Math.abs(newJ-oldJ)==1) || (Math.abs(newI-oldI)==1)&& (Math.abs(newJ-oldJ)==2)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase BLACK_BISHOP: \n\t\t\tif(Math.abs(newI - oldI) == Math.abs(newJ - oldJ)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase BLACK_KING: \n\t\t\tif((Math.abs(newI - oldI)<2) && (Math.abs(newJ - oldJ)<2) ){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase BLACK_QUEEN: \n\t\t\tif(Math.abs(newI - oldI) == Math.abs(newJ - oldJ)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else if(((newI - oldI)==0) || ((newJ - oldJ)==0)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase EMPTY: \n\t\t\tmovePattern = false;\n\t\t\tbreak;\n\n\t\t}\n\n\n\t\t//switch case for checking path\n\t\tswitch(chessboard[oldJ][oldI]){\n\t\tcase WHITE_PAWN: \n\t\t\tif(chessboard[newJ][newI] == Chessmen.EMPTY){\n\t\t\t\tisPathClear = true; \n\t\t\t}else{\n\t\t\t\tisPathClear=false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase WHITE_ROOK: \n\t\t\tif((Math.abs(newI - oldI) == 0)){ //vertical case\n\t\t\t\tboolean truth = true;\n\t\t\t\tint sign = (int)Math.signum(newJ - oldJ);\n\t\t\t\tint j = oldJ;\n\t\t\t\tif(sign>0){\n\t\t\t\t\twhile(truth && j<(newJ-1)){\n\t\t\t\t\t\tif(chessboard[++j][oldI] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth = true;\n\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\ttruth = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}else if(sign<0){\n\t\t\t\t\twhile(truth && j>(newJ+1)){\n\t\t\t\t\t\tif(chessboard[--j][oldI] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth = true;\n\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\ttruth = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tisPathClear = truth;\n\t\t\t} else if((Math.abs(newJ - oldJ) == 0)){ //horizontal case\n\t\t\t\tboolean truth = true;\n\t\t\t\tint sign = (int)Math.signum(newI - oldI);\n\t\t\t\tint i = oldI;\n\t\t\t\tif(sign>0){\n\t\t\t\t\twhile(truth && i<(newI-1)){\n\t\t\t\t\t\tif(chessboard[oldJ][++i] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth = true;\n\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\ttruth = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}else if(sign<0){\n\t\t\t\t\twhile(truth && i>(newI+1)){\n\t\t\t\t\t\tif(chessboard[oldJ][--i] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth = true;\n\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\ttruth = false;\t\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tisPathClear = truth;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase WHITE_KNIGHT : \n\t\t\tisPathClear = true; //trival case as Pawn\n\t\t\tbreak;\n\n\t\tcase WHITE_BISHOP:\n\t\t\tint horizontal = (int)Math.signum(newI - oldI);\n\t\t\tint vertical = (int)Math.signum(newJ - oldJ);\n\t\t\tboolean truth = true;\n\t\t\tint i = oldI;\n\t\t\tint j = oldJ;\n\t\t\tif(horizontal>0 && vertical>0){\n\t\t\t\twhile(truth && (i<(newI-1) && j<(newJ-1)) ){\n\t\t\t\t\tif(chessboard[++j][++i] == Chessmen.EMPTY){\n\t\t\t\t\t\ttruth = true;\n\n\t\t\t\t\t}else{\n\t\t\t\t\t\ttruth = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}// ++ case\n\t\t\t}\n\t\t\tif(horizontal>0 && vertical<0){\n\t\t\t\twhile(truth && (i<(newI-1) && j>(newJ+1)) ){\n\t\t\t\t\tif(chessboard[--j][++i] == Chessmen.EMPTY){\n\t\t\t\t\t\ttruth = true;\n\n\t\t\t\t\t}else{\n\t\t\t\t\t\ttruth = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(horizontal<0 && vertical<0){\n\t\t\t\twhile(truth && (i>(newI+1) && j>(newJ+1)) ){\n\t\t\t\t\tif(chessboard[--j][--i] == Chessmen.EMPTY){\n\t\t\t\t\t\ttruth = true;\n\n\t\t\t\t\t}else{\n\t\t\t\t\t\ttruth = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t\tif(horizontal<0 && vertical>0){\n\t\t\t\twhile(truth && (i>(newI+1) && j<(newJ-1)) ){\n\t\t\t\t\tif(chessboard[++j][--i] == Chessmen.EMPTY){\n\t\t\t\t\t\ttruth = true;\n\n\t\t\t\t\t}else{\n\t\t\t\t\t\ttruth = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tisPathClear = truth;\n\n\t\t\tbreak;\n\t\tcase WHITE_QUEEN :\n\t\t\tif((newI-oldI)==0 || (newJ-oldJ)==0){\n\t\t\t\t//rook's code\n\t\t\t\tif((Math.abs(newI - oldI) == 0)){ //vertical case\n\t\t\t\t\tboolean truth1 = true;\n\t\t\t\t\tint sign = (int)Math.signum(newJ - oldJ);\n\t\t\t\t\tint j1 = oldJ;\n\t\t\t\t\tif(sign>0){\n\t\t\t\t\t\twhile(truth1 && j1<(newJ-1)){\n\t\t\t\t\t\t\tif(chessboard[++j1][oldI] == Chessmen.EMPTY){\n\t\t\t\t\t\t\t\ttruth1 = true;\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}else if(sign<0){\n\t\t\t\t\t\twhile(truth1 && j1>(newJ+1)){\n\t\t\t\t\t\t\tif(chessboard[--j1][oldI] == Chessmen.EMPTY){\n\t\t\t\t\t\t\t\ttruth1 = true;\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tisPathClear = truth1;\n\t\t\t\t} else if((Math.abs(newJ - oldJ) == 0)){ //horizontal case\n\t\t\t\t\tboolean truth1 = true;\n\t\t\t\t\tint sign = (int)Math.signum(newI - oldI);\n\t\t\t\t\tint i1 = oldI;\n\t\t\t\t\tif(sign>0){\n\t\t\t\t\t\twhile(truth1 && i1<(newI-1)){\n\t\t\t\t\t\t\tif(chessboard[oldJ][++i1] == Chessmen.EMPTY){\n\t\t\t\t\t\t\t\ttruth1 = true;\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}else if(sign<0){\n\t\t\t\t\t\twhile(truth1 && i1>(newI+1)){\n\t\t\t\t\t\t\tif(chessboard[oldJ][--i1] == Chessmen.EMPTY){\n\t\t\t\t\t\t\t\ttruth1 = true;\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tisPathClear = truth1;\n\t\t\t\t}\t\t\t\t\n\t\t\t} else{\n\t\t\t\t//bishop's code\n\t\t\t\tint horizontal1 = (int)Math.signum(newI - oldI);\n\t\t\t\tint vertical1 = (int)Math.signum(newJ - oldJ);\n\t\t\t\tboolean truth1 = true;\n\t\t\t\tint i1 = oldI;\n\t\t\t\tint j1 = oldJ;\n\t\t\t\tif(horizontal1>0 && vertical1>0){\n\t\t\t\t\twhile(truth1 && (i1<(newI-1) && j1<(newJ-1)) ){\n\t\t\t\t\t\tif(chessboard[++j1][++i1] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth1 = true;\n\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}// ++ case\n\t\t\t\t}\n\t\t\t\tif(horizontal1>0 && vertical1<0){\n\t\t\t\t\twhile(truth1 && (i1<(newI-1) && j1>(newJ+1)) ){\n\t\t\t\t\t\tif(chessboard[--j1][++i1] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth1 = true;\n\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(horizontal1<0 && vertical1<0){\n\t\t\t\t\twhile(truth1 && (i1>(newI+1) && j1>(newJ+1)) ){\n\t\t\t\t\t\tif(chessboard[--j1][--i1] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth1 = true;\n\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t\tif(horizontal1<0 && vertical1>0){\n\t\t\t\t\twhile(truth1 && (i1>(newI+1) && j1<(newJ-1)) ){\n\t\t\t\t\t\tif(chessboard[++j1][--i1] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth1 = true;\n\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tisPathClear = truth1;\n\n\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t\tbreak;\n\t\tcase WHITE_KING: \n\t\t\tisPathClear = true;\n\t\t\tbreak;\n\t\tcase BLACK_PAWN: \n\t\t\tif(chessboard[newJ][newI] == Chessmen.EMPTY){\n\t\t\t\tisPathClear = true; \n\t\t\t}else{\n\t\t\t\tisPathClear=false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase BLACK_ROOK: \n\t\t\tif((Math.abs(newI - oldI) == 0)){ //vertical case\n\t\t\t\tboolean truth1 = true;\n\t\t\t\tint sign = (int)Math.signum(newJ - oldJ);\n\t\t\t\tint j1 = oldJ+ sign;\n\t\t\t\tif(sign>0){\n\t\t\t\t\twhile(truth1 && j1<newJ){\n\t\t\t\t\t\tif(chessboard[j1++][oldI] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth1 = true;\n\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}else if(sign<0){\n\t\t\t\t\twhile(truth1 && j1>newJ){\n\t\t\t\t\t\tif(chessboard[j1--][oldI] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth1 = true;\n\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tisPathClear = truth1;\n\t\t\t} else if((Math.abs(newJ - oldJ) == 0)){ //horizontal case\n\t\t\t\tboolean truth1 = true;\n\t\t\t\tint sign = (int)Math.signum(newI - oldI);\n\t\t\t\tint i1 = oldI+sign;\n\t\t\t\tif(sign>0){\n\t\t\t\t\twhile(truth1 && i1<newI){\n\t\t\t\t\t\tif(chessboard[oldJ][i1++] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth1 = true;\n\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}else if(sign<0){\n\t\t\t\t\twhile(truth1 && i1>newI){\n\t\t\t\t\t\tif(chessboard[oldJ][i1--] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth1 = true;\n\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tisPathClear = truth1;\n\t\t\t}\n\n\t\t\tbreak;\n\t\tcase BLACK_KNIGHT : \n\t\t\tisPathClear = true;\n\t\t\tbreak;\n\t\tcase BLACK_BISHOP: \n\t\t\tint horizontal1 = (int)Math.signum(newI - oldI);\n\t\t\tint vertical1 = (int)Math.signum(newJ - oldJ);\n\t\t\tboolean truth1 = true;\n\t\t\tint i1 = oldI + horizontal1;\n\t\t\tint j1 = oldJ + vertical1;\n\t\t\tif(horizontal1>0 && vertical1>0){\n\t\t\t\twhile(truth1 && (i1<newI && j1<newJ) ){\n\t\t\t\t\tif(chessboard[j1++][i1++] == Chessmen.EMPTY){\n\t\t\t\t\t\ttruth1 = true;\n\n\t\t\t\t\t}else{\n\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}// ++ case\n\t\t\t}\n\t\t\tif(horizontal1>0 && vertical1<0){\n\t\t\t\twhile(truth1 && (i1<newI && j1>newJ) ){\n\t\t\t\t\tif(chessboard[j1--][i1++] == Chessmen.EMPTY){\n\t\t\t\t\t\ttruth1 = true;\n\n\t\t\t\t\t}else{\n\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(horizontal1<0 && vertical1<0){\n\t\t\t\twhile(truth1 && (i1>newI && j1>newJ) ){\n\t\t\t\t\tif(chessboard[j1--][i1--] == Chessmen.EMPTY){\n\t\t\t\t\t\ttruth1 = true;\n\n\t\t\t\t\t}else{\n\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t\tif(horizontal1<0 && vertical1>0){\n\t\t\t\twhile(truth1 && (i1>newI && j1<newJ) ){\n\t\t\t\t\tif(chessboard[j1++][i1--] == Chessmen.EMPTY){\n\t\t\t\t\t\ttruth1 = true;\n\n\t\t\t\t\t}else{\n\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tisPathClear = truth1;\n\n\n\t\t\tbreak;\n\t\tcase BLACK_QUEEN : \n\t\t\tif((newI-oldI)==0 || (newJ-oldJ)==0){\n\t\t\t\t//rook's code\n\t\t\t\tif((Math.abs(newI - oldI) == 0)){ //vertical case\n\t\t\t\t\tboolean truth11 = true;\n\t\t\t\t\tint sign = (int)Math.signum(newJ - oldJ);\n\t\t\t\t\tint j11 = oldJ + sign;\n\t\t\t\t\tif(sign>0){\n\t\t\t\t\t\twhile(truth11 && j11<newJ){\n\t\t\t\t\t\t\tif(chessboard[j11++][oldI] == Chessmen.EMPTY){\n\t\t\t\t\t\t\t\ttruth11 = true;\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttruth11 = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}else if(sign<0){\n\t\t\t\t\t\twhile(truth11 && j11>newJ){\n\t\t\t\t\t\t\tif(chessboard[j11--][oldI] == Chessmen.EMPTY){\n\t\t\t\t\t\t\t\ttruth11 = true;\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttruth11 = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tisPathClear = truth11;\n\t\t\t\t} else if((Math.abs(newJ - oldJ) == 0)){ //horizontal case\n\t\t\t\t\tboolean truth11 = true;\n\t\t\t\t\tint sign = (int)Math.signum(newI - oldI);\n\t\t\t\t\tint i11 = oldI + sign;\n\t\t\t\t\tif(sign>0){\n\t\t\t\t\t\twhile(truth11 && i11<newI){\n\t\t\t\t\t\t\tif(chessboard[oldJ][i11++] == Chessmen.EMPTY){\n\t\t\t\t\t\t\t\ttruth11 = true;\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttruth11 = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}else if(sign<0){\n\t\t\t\t\t\twhile(truth11 && i11>newI){\n\t\t\t\t\t\t\tif(chessboard[oldJ][i11--] == Chessmen.EMPTY){\n\t\t\t\t\t\t\t\ttruth11 = true;\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttruth11 = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tisPathClear = truth11;\n\t\t\t\t}\t\t\t\t\n\t\t\t} else{\n\t\t\t\t//bishop's code\n\t\t\t\tint horizontal11 = (int)Math.signum(newI - oldI);\n\t\t\t\tint vertical11 = (int)Math.signum(newJ - oldJ);\n\t\t\t\tboolean truth11 = true;\n\t\t\t\tint i11 = oldI + horizontal11;\n\t\t\t\tint j11 = oldJ + vertical11;\n\t\t\t\tif(horizontal11>0 && vertical11>0){\n\t\t\t\t\twhile(truth11 && (i11<newI && j11<newJ) ){\n\t\t\t\t\t\tif(chessboard[j11++][i11++] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth11 = true;\n\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\ttruth11 = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}// ++ case\n\t\t\t\t}\n\t\t\t\tif(horizontal11>0 && vertical11<0){\n\t\t\t\t\twhile(truth11 && (i11<newI && j11>newJ) ){\n\t\t\t\t\t\tif(chessboard[j11--][i11++] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth11 = true;\n\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\ttruth11 = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(horizontal11<0 && vertical11<0){\n\t\t\t\t\twhile(truth11 && (i11>newI && j11>newJ) ){\n\t\t\t\t\t\tif(chessboard[j11--][i11--] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth11 = true;\n\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\ttruth11 = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t\tif(horizontal11<0 && vertical11>0){\n\t\t\t\t\twhile(truth11 && (i11>newI && j11<newJ) ){\n\t\t\t\t\t\tif(chessboard[j11++][i11--] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth11 = true;\n\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\ttruth11 = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tisPathClear = truth11;\n\n\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t\tbreak;\n\t\tcase BLACK_KING: \n\t\t\tisPathClear = true;\n\t\t\tbreak;\n\t\tcase EMPTY: break;\n\t\t}\n\n\n\t\t//destination Check\n\t\tif(chessboard[newJ][newI] == Chessmen.EMPTY){\n\t\t\tisDestinationClear = true;\n\t\t}else{\n\t\t\tisDestinationClear = false;\n\t\t}\n\n\t\tboolean initialIsWhite = false;\n\t\tboolean initialIsBlack = false;\n\t\tswitch(chessboard[oldJ][oldI]){\n\t\tcase WHITE_PAWN:\n\t\tcase WHITE_BISHOP:\n\t\tcase WHITE_KNIGHT:\n\t\tcase WHITE_ROOK:\n\t\tcase WHITE_QUEEN:\n\t\tcase WHITE_KING: \n\t\t\tinitialIsWhite = true;\n\t\t\tinitialIsBlack = false;\n\t\t\tbreak;\n\t\tcase BLACK_PAWN:\n\t\tcase BLACK_BISHOP:\n\t\tcase BLACK_KNIGHT:\n\t\tcase BLACK_ROOK:\n\t\tcase BLACK_QUEEN:\n\t\tcase BLACK_KING: \n\t\t\tinitialIsWhite = false;\n\t\t\tinitialIsBlack = true;\n\t\t\tbreak;\n\t\tcase EMPTY: break;\n\t\t}\n\n\t\tboolean finalIsWhite = false;\n\t\tboolean finalIsBlack = false;\n\t\tswitch(chessboard[newJ][newI]){\n\t\tcase WHITE_PAWN:\n\t\tcase WHITE_BISHOP:\n\t\tcase WHITE_KNIGHT:\n\t\tcase WHITE_ROOK:\n\t\tcase WHITE_QUEEN:\n\t\tcase WHITE_KING: \n\t\t\tfinalIsWhite = true;\n\t\t\tfinalIsBlack = false;\n\t\t\tbreak;\n\t\tcase BLACK_PAWN:\n\t\tcase BLACK_BISHOP:\n\t\tcase BLACK_KNIGHT:\n\t\tcase BLACK_ROOK:\n\t\tcase BLACK_QUEEN:\n\t\tcase BLACK_KING: \n\t\t\tfinalIsWhite = false;\n\t\t\tfinalIsBlack = true;\n\t\t\tbreak;\n\t\tcase EMPTY: break;\n\t\t}\n\n\t\tif(isDestinationClear == false){\n\t\t\tif((initialIsWhite & finalIsBlack) || (initialIsBlack&finalIsWhite)){\n\t\t\t\tif(isPathClear){\n\t\t\t\t\tSystem.out.println(\"Nailed It\");\n\t\t\t\t\tisDestinationClear = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//special Case of pawn !!\n\t\tif(chessboard[oldJ][oldI] == Chessmen.WHITE_PAWN){\n\t\t\tif(((newJ-oldJ)==1)&&(Math.abs(newI-oldI)==1) && finalIsBlack ){\n\t\t\t\tSystem.out.println(\"Nailed It! \");\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}else if(chessboard[oldJ][oldI] == Chessmen.BLACK_PAWN){\n\t\t\tif(((newJ-oldJ)==-1)&&(Math.abs(newI-oldI)==1) && finalIsWhite ){\n\t\t\t\tisDestinationClear = true;\n\t\t\t\tisPathClear = true;\n\t\t\t\tmovePattern = true;\n\t\t\t\tSystem.out.println(\"Nailed It! \");\n\t\t\t}\n\t\t}\n\t\treturn movePattern&isPathClear &isDestinationClear;\n\t}", "public int hamming() {\n int distance = 0;\n for (int i = 0; i < _N; i++) {\n for (int j = 0; j < _N; j++) {\n if (_tiles[i][j] != _goal[i][j]) {\n distance++;\n }\n }\n }\n return distance;\n }", "public void checkBombs(final Integer tile){\n if(bombs_location.contains(tile)){\n if(invulnerable){\n showTimedAlertDialog(\"PHEW!\", \"Your GODMODE saved your life\", 5);\n invulnerable = false;\n return;\n }\n invulnerable = false;\n Lejos.makeSound_Boom();\n hp = hp-1;\n DrawHP();\n bombs_location.remove(tile);\n final Handler handler = new Handler();\n handler.postDelayed(new Runnable() {\n @Override\n public void run() {\n MultiplayerManager.getInstance().SendMessage(\"bomb_remove \" + revertTile(tile).toString());\n }\n }, 1000);\n if(hp==0){\n onLose();\n }\n showTimedAlertDialog(\"PWNED!\", \"You just stepped on a mine\", 3);\n }\n }", "public void specialMove() {\n\t\tChessSquare initial = getSquare();\n\t\tChessSquare next;\n\t\t\n\t\tif(initial.getNorth() != null){\n\t\t\tnext = initial.getNorth();\n\t\t\t\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getEast() != null)\n\t\t\t\tif((next.getEast().getOccupant() == null) || (!next.getEast().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getWest() != null && next.getWest().getOccupant() == null)\n\t\t\t\tif((next.getWest().getOccupant() == null) || (!next.getWest().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t}\n\t\t\n\t\tif(initial.getSouth() != null){\n\t\t\tnext = initial.getSouth();\n\t\t\t\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getEast() != null)\n\t\t\t\tif((next.getEast().getOccupant() == null) || (!next.getEast().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getWest() != null)\n\t\t\t\tif((next.getWest().getOccupant() == null) || (!next.getWest().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t\t\n\t\t}\n\t\t\n\t\tnext = initial.getEast();\n\t\tif(next != null)\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\tnext = initial.getWest();\n\t\tif(next != null)\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\tsetCountdown(9);\n\t}", "private void traverseBayeredPatternHalfSizeRGB(){\n int originalPositionX = 0;\n int originalPositionY = 1;\n\n for (int newX = 0; originalPositionX < originalImageHeight -1; newX++){\n for (int newY = 0; originalPositionY < originalImageWidth -1; newY++){\n Point newPosition = new Point(newX,newY);\n int newAbsoultPosition = getAbsolutPixelPosition(newPosition, originalImageHeight / 2, originalImageWidth / 2);\n halfSizePixRGB[newAbsoultPosition] = getAverageRGB(new Point(originalPositionX,originalPositionY));\n originalPositionY += 2;\n }\n originalPositionY = 0;\n originalPositionX += 2;\n }\n }", "private int playMove(int[] board, int move) {\n boolean direction = false;\n boolean player1Move = isPlayer1Move(move);\n if ((move > 1) && (move < 8)) {\n direction = true;\n }\n if (move == 10) {\n move = 2;\n }\n if (move == 11) {\n move = 7;\n }\n int numberOfMarbleBalls = board[move];\n if (numberOfMarbleBalls < 2) {\n return -1;\n }\n board[move] = 0;\n while (numberOfMarbleBalls > 0) {\n move = goToNext(move, direction);\n board[move] = board[move] + 1;\n numberOfMarbleBalls = numberOfMarbleBalls - 1;\n }\n int takenMarbleBalls = 0;\n if (player1Move) {\n while (true) {\n if (move < 5) break;\n if (!((board[move] == 2) || (board[move] == 4))) break;\n takenMarbleBalls = takenMarbleBalls + board[move];\n board[move] = 0;\n move = goToNext(move, !(direction));\n }\n } else {\n while (true) {\n if (move > 4) break;\n if (!((board[move] == 2) || (board[move] == 4))) break;\n takenMarbleBalls = takenMarbleBalls + board[move];\n board[move] = 0;\n move = goToNext(move, !(direction));\n }\n }\n return takenMarbleBalls;\n }", "@Test\n\tpublic void whenHorseMoveThrowAnotherFigureThanOk() {\n\t\tCell[][] cells = new Cell[8][8];\n\t\tfor (int x = 0; x < 8; x++) {\n\t\t\tfor (int y = 0; y < 8; y++) {\n\t\t\t\tcells[x][y] = new Cell(x, y);\n\t\t\t}\n\t\t}\n\t\tFigure[] figures = {new Horse(cells[4][4]),\n\t\t\t\t\t\t\tnew Tura(cells[2][5]),\n\t\t\t\t\t\t\tnew Tura(cells[3][5]),\n\t\t\t\t\t\t\tnew Tura(cells[4][5]),\n\t\t\t\t\t\t\tnew Tura(cells[5][5]),\n\t\t\t\t\t\t\tnew Tura(cells[6][5])};\n\t\tBoard board = new Board(cells, figures);\n\t\tassertThat(board.move(cells[4][4], board.getCell(3, 6)), is(true));\n\t}" ]
[ "0.6187991", "0.5780737", "0.57512736", "0.5712571", "0.562431", "0.56065357", "0.5502396", "0.5456456", "0.54285175", "0.54131573", "0.5412099", "0.5388487", "0.5325605", "0.5302791", "0.5302343", "0.5284781", "0.52215874", "0.520105", "0.51973164", "0.5184246", "0.5183648", "0.5182899", "0.5179279", "0.51712036", "0.5163239", "0.51539105", "0.51502925", "0.5147865", "0.513073", "0.5123938", "0.51169515", "0.51158303", "0.5091912", "0.50888777", "0.50875825", "0.50728023", "0.5071158", "0.50600785", "0.50490075", "0.50431913", "0.5041069", "0.5035993", "0.503394", "0.5024693", "0.5011832", "0.5010531", "0.4998062", "0.49976912", "0.49890804", "0.49857965", "0.49803123", "0.4975581", "0.49668348", "0.49592182", "0.49502033", "0.49479386", "0.49465773", "0.49460334", "0.4935694", "0.4935489", "0.4928873", "0.49255973", "0.4924089", "0.49224874", "0.49205875", "0.49203998", "0.49182865", "0.4909781", "0.49088743", "0.49052444", "0.49033234", "0.48984554", "0.48957676", "0.48956943", "0.48942202", "0.4890659", "0.4888706", "0.48882848", "0.48846716", "0.48839504", "0.4878983", "0.48746482", "0.48744386", "0.48739138", "0.48738456", "0.48725402", "0.48719853", "0.48704842", "0.4867826", "0.4864491", "0.48643816", "0.48565736", "0.4853258", "0.48500904", "0.48489434", "0.48476547", "0.48469287", "0.4838957", "0.48384207", "0.48317078" ]
0.5448602
8
Handle the movement of Queens. First, check if any queen is capable of making a rook move. If one is, return its starting position; otherwise, check if any queen is capble of making a bishop move. If one is, return its starting position; otherwise, return null.
public static int[] getQueenStart(int[][] piecePos, int endFile, int endRank) { int[] rookMove = getRookStart(piecePos, endFile, endRank); if (rookMove != null) { return rookMove; } int[] bishopMove = getBishopStart(piecePos, endFile, endRank); if (bishopMove != null) { return bishopMove; } return null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Override\n\tprotected Collection<KeyPadPosition> getPossibleMovesFromOrigin(\n\t\t\tKey currentKey) {\n\t\tCollection<KeyPadPosition> possibleMovesFromOrigin = null;\n\t\tif (isChangeToQueenOnPromotionRow(currentKey)) {\n\t\t\tpossibleMovesFromOrigin = getPossibleMovesWhenPromoted(currentKey);\n\t\t} else {\n\t\t\tpossibleMovesFromOrigin = getStandardPossibleMovesFromCentre();\n\t\t}\n\t\treturn possibleMovesFromOrigin;\n\n\t}", "public void performMove() {\n\t\tfor (int x = 0; x <= size-1; x++)\n\t\t\tfor (int y = 0; y <= size-1; y++)\n\t\t\t\tlocalBoard[y][x] = 0;\n\t\t\n\t\t//reset the flag that indicates if a move has been found that decreases the heuristic\n\t\tfoundBetterMove = false;\n\t\t\n\t\t//fill in the appropriate heuristic values\n\t\tpopulateHillValues();\n\t\tArrayList<PotentialMove> myBestList = new ArrayList<PotentialMove>();\n\n\t\t//Find the square with the lowest heuristic value. this should really write the values to an array. \n\t\tint squareDifferential = -1;\n\t\t//String outValue = \"\";\n\t\tfor (int y = 0; y <= size-1; y++) {\n\t\t\tfor (int x = 0; x <= size-1; x++){\n\t\t\t\t//outValue = outValue + localBoard[y][x];\n\t\t\t\tif (squareDifferential < 0) //lowestSquareFound not found yet \n\t\t\t\t{\n\t\t\t\t\tif ((NQueens.queens[x] != y) && //set if the current square isn't already occupied by a queen\n\t\t\t\t\t\t\t(localBoard[NQueens.queens[x]][x] >= localBoard[y][x])) {\n\t\t\t\t\t\tif (localBoard[y][x] == localBoard[NQueens.queens[x]][x])\n\t\t\t\t\t\t\tmyBestList.add(new PotentialMove(x, y, true));\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tmyBestList.add(new PotentialMove(x, y, false));\n\t\t\t\t\t\tsquareDifferential = localBoard[NQueens.queens[x]][x] - localBoard[y][x];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if ((localBoard[NQueens.queens[x]][x] - localBoard[y][x]) > squareDifferential) { // find the square with the largest differential in value from the queen in the column\n\t\t\t\t\tmyBestList.clear();\n\t\t\t\t\tmyBestList.add(new PotentialMove(x, y, false));\n\t\t\t\t\tsquareDifferential = localBoard[NQueens.queens[x]][x] - localBoard[y][x];\n\t\t\t\t}\n\t\t\t\telse if (((localBoard[NQueens.queens[x]][x] - localBoard[y][x]) == squareDifferential) && // the differential is equal to the current best differential\n\t\t\t\t\t\t(NQueens.queens[x] != y)) { // and isn't already occupied by a queen\n\t\t\t\t\tmyBestList.add(new PotentialMove(x, y, true));\n\t\t\t\t}\n\t\t\t\t//else the square is higher, has a queen or isn't marginally better than the current queen's position in the row\n\t\t\t}\n\t\t\t//outValue = outValue + \"\\n\";\n\t\t}\n\t\t//JOptionPane.showMessageDialog(null, outValue);\n\t\t\n\t\tif (myBestList.isEmpty())\n\t\t\treturn;\n\t\t\n\t\tint listSize = myBestList.size();\n\t\tPotentialMove bestMove;\n\t\t\n\t\t//grab the non-Sideways moves first\n\t\tfor (int i = 0; i < listSize; i++) {\n\t\t\tif (!(myBestList.get(i).isSideways)) {\n\t\t\t\tbestMove = myBestList.get(i);\n\t\t\t\tfoundBetterMove = true;\n\t\t\t\tsidewaysMoves = 0;\n\t\t\t\tNQueens.queens[bestMove.xCoordinate] = bestMove.yCoordinate;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (sidewaysMoves > MAXSIDEWAYSMOVES) { // hit MAXSIDEWAYSMOVES consecutive sideways moves, mark as unsolvable\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t//all available moves sideways moves, let's select one randomly\n\t\tRandom generator = new Random();\n\t\tint randomElement = generator.nextInt(listSize);\n\t\t\n\t\tbestMove = myBestList.get(randomElement);\n\t\tfoundBetterMove = true;\n\t\tsidewaysMoves++;\n\t\tNQueens.queens[bestMove.xCoordinate] = bestMove.yCoordinate;\n\t}", "public void specialMove() {\n\t\tChessSquare initial = getSquare();\n\t\tChessSquare next;\n\t\t\n\t\tif(initial.getNorth() != null){\n\t\t\tnext = initial.getNorth();\n\t\t\t\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getEast() != null)\n\t\t\t\tif((next.getEast().getOccupant() == null) || (!next.getEast().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getWest() != null && next.getWest().getOccupant() == null)\n\t\t\t\tif((next.getWest().getOccupant() == null) || (!next.getWest().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t}\n\t\t\n\t\tif(initial.getSouth() != null){\n\t\t\tnext = initial.getSouth();\n\t\t\t\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getEast() != null)\n\t\t\t\tif((next.getEast().getOccupant() == null) || (!next.getEast().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t\tif(next.getWest() != null)\n\t\t\t\tif((next.getWest().getOccupant() == null) || (!next.getWest().getOccupant().getColor().equals(this.getColor())))\n\t\t\t\t\tnext.removeOccupant();\n\t\t\t\n\t\t}\n\t\t\n\t\tnext = initial.getEast();\n\t\tif(next != null)\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\tnext = initial.getWest();\n\t\tif(next != null)\n\t\t\tif((next.getOccupant() == null) || (!next.getOccupant().getColor().equals(this.getColor())))\n\t\t\t\tnext.removeOccupant();\n\t\tsetCountdown(9);\n\t}", "@Override\n\tboolean isValidSpecialMove(int newX, int newY) {\n\t\tint xDisplacement = newX - xLocation;\n\t\tint yDisplacement = newY - yLocation;\n\t\tif(isValidQueenMove(xDisplacement, yDisplacement)){\n\t\t\tint steps = Math.max(Math.abs(xDisplacement), Math.abs(yDisplacement));\n\t\t\tint xDirection = xDisplacement/steps;\n\t\t\tint yDirection = yDisplacement/steps;\n\t\t\t// Check for obstacles in path of Queen.\n\t\t\tfor(int i = 1; i < steps; i++){\n\t\t\t\tSquare squareToCheck = currentBoard.squaresList[xLocation + i*xDirection][yLocation + i*yDirection];\n\t\t\t\tif(squareToCheck.isOccupied)\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}", "private static ArrayList<Position> possibleMovesInEmptySpaces(ItalianBoard board, int posR, int posC) {\n ArrayList<Position> possibleMovementList = new ArrayList<>();\n\n try {\n if (board.getBoard()[posR - 1][posC - 1].getPlace() == PlaceType.EMPTY)//up left\n possibleMovementList.add(new Position(posR - 1, posC - 1));\n } catch (ArrayIndexOutOfBoundsException ignored) {\n }\n\n try {\n if (board.getBoard()[posR - 1][posC + 1].getPlace() == PlaceType.EMPTY)//up right\n possibleMovementList.add(new Position(posR - 1, posC + 1));\n } catch (ArrayIndexOutOfBoundsException ignored) {\n }\n\n if (board.getBoard()[posR][posC].getPiece() == PieceType.KING) {\n try {\n if (board.getBoard()[posR + 1][posC - 1].getPlace() == PlaceType.EMPTY)//down left\n possibleMovementList.add(new Position(posR + 1, posC - 1));\n } catch (ArrayIndexOutOfBoundsException ignored) {\n }\n\n try {\n if (board.getBoard()[posR + 1][posC + 1].getPlace() == PlaceType.EMPTY)//down right\n possibleMovementList.add(new Position(posR + 1, posC + 1));\n } catch (ArrayIndexOutOfBoundsException ignored) {\n }\n }\n return possibleMovementList;\n }", "private boolean isQueen(Point pos){\r\n Cells aux = model.getValueAt(pos);\r\n return (aux == Cells.BLACK_QUEEN || aux == Cells.RED_QUEEN);\r\n }", "public static int[][] queenMoves(int[] currentQueen, BoardModel model) {\n\n int[][] moveLevel = new int[10][10];\n boolean[][] visited = new boolean[10][10];\n Queue<int[]> nodesToCheck = new LinkedList<>();\n //initialize the queen array to show the location of the queen and the \n // number of moves it takes to get to the queen. \n int[] initQueen = new int[3];\n initQueen[0] = currentQueen[0];\n initQueen[1] = currentQueen[1];\n initQueen[2] = 0;\n moveLevel[initQueen[0]][initQueen[1]] = initQueen[2];\n nodesToCheck.add(initQueen);\n while (!nodesToCheck.isEmpty()) {\n int[] neighbourNode = nodesToCheck.poll();\n // search nodes above until positions are no longer available; \n for (int i = neighbourNode[0] + 1; i < 10; i++) {\n if (!visited[i][neighbourNode[1]]) {\n if (model.getTile(i, neighbourNode[1]) == BoardModel.POS_AVAILABLE) {\n visited[i][neighbourNode[1]] = true;\n int[] initCurrentSpot = new int[3];\n initCurrentSpot[0] = i;\n initCurrentSpot[1] = neighbourNode[1];\n initCurrentSpot[2] = neighbourNode[2] + 1;\n moveLevel[initCurrentSpot[0]][initCurrentSpot[1]] = initCurrentSpot[2];\n\n nodesToCheck.add(initCurrentSpot);\n\n } else {\n break;\n\n }\n }\n }\n // search nodes below until positions are no longer available\n for (int i = neighbourNode[0] - 1; i >= 0; i--) {\n if (!visited[i][neighbourNode[1]]) {\n if (model.getTile(i, neighbourNode[1]) == BoardModel.POS_AVAILABLE) {\n visited[i][neighbourNode[1]] = true;\n int[] initCurrentSpot = new int[3];\n initCurrentSpot[0] = i;\n initCurrentSpot[1] = neighbourNode[1];\n initCurrentSpot[2] = neighbourNode[2] + 1;\n moveLevel[initCurrentSpot[0]][initCurrentSpot[1]] = initCurrentSpot[2];\n nodesToCheck.add(initCurrentSpot);\n } else {\n break;\n }\n }\n\n }\n // search nodes to the right until positions are no longer available\n for (int i = neighbourNode[1] + 1; i < 10; i++) {\n if (!visited[neighbourNode[0]][i]) {\n if (model.getTile(neighbourNode[0], i) == BoardModel.POS_AVAILABLE) {\n visited[neighbourNode[0]][i] = true;\n int[] initCurrentSpot = new int[3];\n initCurrentSpot[0] = neighbourNode[0];\n initCurrentSpot[1] = i;\n initCurrentSpot[2] = neighbourNode[2] + 1;\n moveLevel[initCurrentSpot[0]][initCurrentSpot[1]] = initCurrentSpot[2];\n nodesToCheck.add(initCurrentSpot);\n } else {\n break;\n }\n }\n }\n\n // search nodes to the left until position are no longer available; \n for (int i = neighbourNode[1] - 1; i >= 0; i--) {\n if (!visited[neighbourNode[0]][i]) {\n if (model.getTile(neighbourNode[0], i) == BoardModel.POS_AVAILABLE) {\n visited[neighbourNode[0]][i] = true;\n int[] initCurrentSpot = new int[3];\n initCurrentSpot[0] = neighbourNode[0];\n initCurrentSpot[1] = i;\n initCurrentSpot[2] = neighbourNode[2] + 1;\n moveLevel[initCurrentSpot[0]][initCurrentSpot[1]] = initCurrentSpot[2];\n nodesToCheck.add(initCurrentSpot);\n } else {\n break;\n }\n }\n }\n // search nodes diagonally up and right until positions are no longer available;\n // up == decreasing in row, right == increasing in column \n for (int i = 1; neighbourNode[0] - i >= 0 && neighbourNode[1] + i < 10; i++) {\n if (!visited[neighbourNode[0] - i][neighbourNode[1] + i]) {\n if (model.getTile(neighbourNode[0] - i, neighbourNode[1] + i) == BoardModel.POS_AVAILABLE) {\n visited[neighbourNode[0] - i][neighbourNode[1] + i] = true;\n int[] initCurrentSpot = new int[3];\n initCurrentSpot[0] = neighbourNode[0] - i;\n initCurrentSpot[1] = neighbourNode[1] + i;\n initCurrentSpot[2] = neighbourNode[2] + 1;\n moveLevel[initCurrentSpot[0]][initCurrentSpot[1]] = initCurrentSpot[2];\n nodesToCheck.add(initCurrentSpot);\n } else {\n break;\n }\n }\n }\n\n //search nodes diagonally down and left until positions are no longer available \n for (int i = 1; neighbourNode[0] + i < 10 && neighbourNode[1] - i >= 0; i++) {\n if (!visited[neighbourNode[0] + i][neighbourNode[1] - i]) {\n if (model.getTile(neighbourNode[0] + i, neighbourNode[1] - i) == BoardModel.POS_AVAILABLE) {\n visited[neighbourNode[0] + i][neighbourNode[1] - i] = true;\n int[] initCurrentSpot = new int[3];\n initCurrentSpot[0] = neighbourNode[0] + i;\n initCurrentSpot[1] = neighbourNode[1] - i;\n initCurrentSpot[2] = neighbourNode[2] + 1;\n moveLevel[initCurrentSpot[0]][initCurrentSpot[1]] = initCurrentSpot[2];\n nodesToCheck.add(initCurrentSpot);\n } else {\n break;\n }\n }\n }\n\n // search nodes diagonally up and left until positions are no longer available \n for (int i = 1; neighbourNode[0] - i >= 0 && neighbourNode[1] - i >= 0; i++) {\n if (!visited[neighbourNode[0] - i][neighbourNode[1] - i]) {\n if (model.getTile(neighbourNode[0] - i, neighbourNode[1] - i) == BoardModel.POS_AVAILABLE) {\n visited[neighbourNode[0] - i][neighbourNode[1] - i] = true;\n int[] initCurrentSpot = new int[3];\n initCurrentSpot[0] = neighbourNode[0] - i;\n initCurrentSpot[1] = neighbourNode[1] - i;\n initCurrentSpot[2] = neighbourNode[2] + 1;\n moveLevel[initCurrentSpot[0]][initCurrentSpot[1]] = initCurrentSpot[2];\n nodesToCheck.add(initCurrentSpot);\n } else {\n break;\n }\n }\n }\n\n // search nodes diagonally down and right until positions are no longer available\n for (int i = 1; neighbourNode[0] + i < 10 && neighbourNode[1] + i < 10; i++) {\n if (!visited[neighbourNode[0] + i][neighbourNode[1] + i]) {\n if (model.getTile(neighbourNode[0] + i, neighbourNode[1] + i) == BoardModel.POS_AVAILABLE) {\n visited[neighbourNode[0] + i][neighbourNode[1] + i] = true;\n int[] initCurrentSpot = new int[3];\n initCurrentSpot[0] = neighbourNode[0] + i;\n initCurrentSpot[1] = neighbourNode[1] + i;\n initCurrentSpot[2] = neighbourNode[2] + 1;\n moveLevel[initCurrentSpot[0]][initCurrentSpot[1]] = initCurrentSpot[2];\n nodesToCheck.add(initCurrentSpot);\n } else {\n break;\n }\n }\n }\n\n }\n return moveLevel;\n }", "private boolean moveMakeQueen(Point orig, Point dest){\r\n if(isQueen(orig)) return false;\r\n return (isBlack(orig) && dest.getFirst() == 7) || (isRed(orig) && dest.getFirst() == 0);\r\n }", "private int Win_Move() {\n\t\tfinal int POSSIBLE_WIN = 8;\n\t\tint move = NO_MOVE;\n\t\tif(( gameBoard[TOP_LEFT] + gameBoard[TOP_CENTER] + gameBoard[TOP_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[TOP_CENTER] == EMPTY){\n\t\t\t\tmove = TOP_CENTER;\n\t\t\t}else if (gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[CTR_LEFT] + gameBoard[CTR_CENTER] + gameBoard[CTR_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[CTR_LEFT] == EMPTY){\n\t\t\t\tmove = CTR_LEFT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[CTR_RIGHT] == EMPTY){\n\t\t\t\tmove = CTR_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[BTM_LEFT] + gameBoard[BTM_CENTER] + gameBoard[BTM_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}else if (gameBoard[BTM_CENTER] == EMPTY){\n\t\t\t\tmove = BTM_CENTER;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_LEFT] + gameBoard[CTR_LEFT] + gameBoard[BTM_LEFT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[CTR_LEFT] == EMPTY){\n\t\t\t\tmove = CTR_LEFT;\n\t\t\t}else if (gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_CENTER] + gameBoard[CTR_CENTER] + gameBoard[BTM_CENTER]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_CENTER] == EMPTY){\n\t\t\t\tmove = TOP_CENTER;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_CENTER] == EMPTY){\n\t\t\t\tmove = BTM_CENTER;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_RIGHT] + gameBoard[CTR_RIGHT] + gameBoard[BTM_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}else if (gameBoard[CTR_RIGHT] == EMPTY){\n\t\t\t\tmove = CTR_RIGHT;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_LEFT] + gameBoard[CTR_CENTER] + gameBoard[BTM_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_RIGHT] + gameBoard[CTR_CENTER] + gameBoard[BTM_LEFT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}\n\t\t}\n\t\treturn move;\n\t}", "public Vector<ChessBoardBlock> getMovablePosition(ChessPiece p) {\r\n\t\tString player = p.chessPlayer;\r\n\t\tString position = p.position;\r\n\t\tchar h = position.charAt(0);\r\n\t\tint v = Integer.parseInt(position.substring(1));\r\n\t\tVector<ChessBoardBlock> tmp = new Vector<ChessBoardBlock>();\r\n\t\ttmp.add(board.get(position));\r\n\t\t\r\n\t\t// Condition for white piece\r\n\t\tif (player.equals(\"white\")) {\r\n\t\t\t\r\n\t\t\t// Condition for not King piece\r\n\t\t\tif (p.getText() == null) {\r\n\t\t\t\tChessBoardBlock br1 = board.get(Character.toString((char)(h+1)) + (v+1));\r\n\t\t\t\tChessBoardBlock br2 = board.get(Character.toString((char)(h+2)) + (v+2));\r\n\t\t\t\t// Condition for upper right to the piece\r\n\t\t\t\tif (br1 != null && piece.get(br1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(br1.position));\r\n\t\t\t\t} else if (br2 != null && piece.get(br1.position).chessPlayer.equals(\"black\") && piece.get(br2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(br2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tChessBoardBlock bl1 = board.get(Character.toString((char)(h-1)) + (v+1));\r\n\t\t\t\tChessBoardBlock bl2 = board.get(Character.toString((char)(h-2)) + (v+2));\r\n\t\t\t\t// Condition for upper left to the piece\r\n\t\t\t\tif (bl1 != null && piece.get(bl1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bl1.position));\r\n\t\t\t\t} else if (bl2 != null && piece.get(bl1.position).chessPlayer.equals(\"black\") && piece.get(bl2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bl2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t} \r\n\r\n\t\t\t// Condition for King piece\r\n\t\t\telse {\r\n\t\t\t\tChessBoardBlock bur1 = board.get(Character.toString((char)(h+1)) + (v+1));\r\n\t\t\t\tChessBoardBlock bur2 = board.get(Character.toString((char)(h+2)) + (v+2));\r\n\t\t\t\t// Condition for upper right to the piece\r\n\t\t\t\tif (bur1 != null && piece.get(bur1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bur1.position));\r\n\t\t\t\t} else if (bur2 != null && piece.get(bur1.position).chessPlayer.equals(\"black\") && piece.get(bur2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bur2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tChessBoardBlock bul1 = board.get(Character.toString((char)(h-1)) + (v+1));\r\n\t\t\t\tChessBoardBlock bul2 = board.get(Character.toString((char)(h-2)) + (v+2));\r\n\t\t\t\t// Condition for upper left to the piece\r\n\t\t\t\tif (bul1 != null && piece.get(bul1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bul1.position));\r\n\t\t\t\t} else if (bul2 != null && piece.get(bul1.position).chessPlayer.equals(\"black\") && piece.get(bul2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bul2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tChessBoardBlock bdr1 = board.get(Character.toString((char)(h+1)) + (v-1));\r\n\t\t\t\tChessBoardBlock bdr2 = board.get(Character.toString((char)(h+2)) + (v-2));\r\n\t\t\t\t// Condition for lower right to the piece\r\n\t\t\t\tif (bdr1 != null && piece.get(bdr1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bdr1.position));\r\n\t\t\t\t} else if (bdr2 != null && piece.get(bdr1.position).chessPlayer.equals(\"black\") && piece.get(bdr2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bdr2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tChessBoardBlock bdl1 = board.get(Character.toString((char)(h-1)) + (v-1));\r\n\t\t\t\tChessBoardBlock bdl2 = board.get(Character.toString((char)(h-2)) + (v-2));\r\n\t\t\t\t// Condition for lower left to the piece\r\n\t\t\t\tif (bdl1 != null && piece.get(bdl1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bdl1.position));\r\n\t\t\t\t} else if (bdl2 != null && piece.get(bdl1.position).chessPlayer.equals(\"black\") && piece.get(bdl2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bdl2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\t// Condition for black piece\r\n\t\telse {\r\n\t\t\t\r\n\t\t\t// Condition for not King piece\r\n\t\t\tif (p.getText() == null) {\r\n\t\t\t\tChessBoardBlock br1 = board.get(Character.toString((char)(h+1)) + (v-1));\r\n\t\t\t\tChessBoardBlock br2 = board.get(Character.toString((char)(h+2)) + (v-2));\r\n\t\t\t\t// Condition for upper right to the piece\r\n\t\t\t\tif (br1 != null && piece.get(br1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(br1.position));\r\n\t\t\t\t} else if (br2 != null && piece.get(br1.position).chessPlayer.equals(\"white\") && piece.get(br2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(br2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tChessBoardBlock bl1 = board.get(Character.toString((char)(h-1)) + (v-1));\r\n\t\t\t\tChessBoardBlock bl2 = board.get(Character.toString((char)(h-2)) + (v-2));\r\n\t\t\t\t// Condition for upper left to the piece\r\n\t\t\t\tif (bl1 != null && piece.get(bl1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bl1.position));\r\n\t\t\t\t} else if (bl2 != null && piece.get(bl1.position).chessPlayer.equals(\"white\") && piece.get(bl2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bl2.position));\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tChessBoardBlock bur1 = board.get(Character.toString((char)(h+1)) + (v+1));\r\n\t\t\t\tChessBoardBlock bur2 = board.get(Character.toString((char)(h+2)) + (v+2));\r\n\t\t\t\t// Condition for upper right to the piece\r\n\t\t\t\tif (bur1 != null && piece.get(bur1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bur1.position));\r\n\t\t\t\t} else if (bur2 != null && piece.get(bur1.position).chessPlayer.equals(\"white\") && piece.get(bur2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bur2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tChessBoardBlock bul1 = board.get(Character.toString((char)(h-1)) + (v+1));\r\n\t\t\t\tChessBoardBlock bul2 = board.get(Character.toString((char)(h-2)) + (v+2));\r\n\t\t\t\t// Condition for upper left to the piece\r\n\t\t\t\tif (bul1 != null && piece.get(bul1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bul1.position));\r\n\t\t\t\t} else if (bul2 != null && piece.get(bul1.position).chessPlayer.equals(\"white\") && piece.get(bul2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bul2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tChessBoardBlock bdr1 = board.get(Character.toString((char)(h+1)) + (v-1));\r\n\t\t\t\tChessBoardBlock bdr2 = board.get(Character.toString((char)(h+2)) + (v-2));\r\n\t\t\t\t// Condition for lower right to the piece\r\n\t\t\t\tif (bdr1 != null && piece.get(bdr1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bdr1.position));\r\n\t\t\t\t} else if (bdr2 != null && piece.get(bdr1.position).chessPlayer.equals(\"white\") && piece.get(bdr2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bdr2.position));\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tChessBoardBlock bdl1 = board.get(Character.toString((char)(h-1)) + (v-1));\r\n\t\t\t\tChessBoardBlock bdl2 = board.get(Character.toString((char)(h-2)) + (v-2));\r\n\t\t\t\t// Condition for lower left to the piece\r\n\t\t\t\tif (bdl1 != null && piece.get(bdl1.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bdl1.position));\r\n\t\t\t\t} else if (bdl2 != null && piece.get(bdl1.position).chessPlayer.equals(\"white\") && piece.get(bdl2.position).chessPlayer.equals(\"empty\")) {\r\n\t\t\t\t\ttmp.add(board.get(bdl2.position));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn tmp;\r\n\t}", "public ArrayList<Coordinate> getPossibleMoveCoordinate() {\n ChessBoard board = this.getChessBoard(); // get chess board\n ArrayList<Coordinate> coords = new ArrayList<Coordinate>(); // create return ArrayList\n int x, y;\n /*\n several cases\n 2 3\n 1 4\n\n 5 8\n 6 7\n\n */\n // case1\n x = this.x_coordinate - 2;\n y = this.y_coordinate + 1;\n if(x >= 0 && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case2\n x = this.x_coordinate - 1;\n y = this.y_coordinate + 2;\n if(x >= 0 && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case3\n x = this.x_coordinate + 1;\n y = this.y_coordinate + 2;\n if(x < board.getWidth() && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case4\n x = this.x_coordinate + 2;\n y = this.y_coordinate + 1;\n if(x < board.getWidth() && y < board.getHeight()){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case5\n x = this.x_coordinate - 2;\n y = this.y_coordinate - 1;\n if(x >= 0 && y >= 0 ){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case6\n x = this.x_coordinate - 1;\n y = this.y_coordinate - 2;\n if(x >= 0 && y >= 0){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case7\n x = this.x_coordinate + 1;\n y = this.y_coordinate - 2;\n if(x < board.getWidth() && y >= 0){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n // case1\n x = this.x_coordinate + 2;\n y = this.y_coordinate - 1;\n if(x < board.getWidth() && y >= 0){\n addToCoordinatesIfValid(coords, x, y); // add to coords if the piece can move to that coordinate\n }\n\n\n return coords;\n }", "private boolean canMove(Point piece){\r\n // direction -1: red pieces +1: black pieces\r\n int dir = isRed(piece)? -1:+1;\r\n // normal movement\r\n Point left = new Point(piece.getFirst() + dir, piece.getSecond() - 1);\r\n Point right = new Point(piece.getFirst() + dir, piece.getSecond() + 1);\r\n // check for normal movements\r\n if(isValidPosition(left) && isEmpty(left)) return true;\r\n if(isValidPosition(right) && isEmpty(right)) return true;\r\n // if is a queen\r\n if(isQueen(piece)){\r\n // compute queen move points (invert direction)\r\n Point leftQ = new Point(piece.getFirst() - dir, piece.getSecond() - 1);\r\n Point rightQ = new Point(piece.getFirst() - dir, piece.getSecond() + 1);\r\n // check for down movements\r\n if(isValidPosition(leftQ) && isEmpty(leftQ)) return true;\r\n if(isValidPosition(rightQ) && isEmpty(rightQ)) return true;\r\n }\r\n return false;\r\n }", "public List<Move> validMoves(){\n List<Move> results = new LinkedList<>();\n int kingVal = turn == WHITE ? WHITE_KING : BLACK_KING;\n int kingX = 0, kingY = 0;\n List<Piece> checks = null;\n kingSearch:\n for (int y = 0; y < 8; y++){\n for (int x = 0; x < 8; x++){\n if (board[y][x] == kingVal){\n kingX = x;\n kingY = y;\n checks = inCheck(x,y);\n break kingSearch;\n }\n }\n }\n if (checks.size() > 1){ // must move king\n for (int x = -1; x < 2; x++){\n for (int y = -1; y < 2; y++){\n if (kingX+x >= 0 && kingX + x < 8 && kingY+y >= 0 && kingY+y < 8){\n int val = board[kingY+y][kingX+x];\n if (val == 0 || turn == WHITE && val > WHITE_KING || turn == BLACK && val < BLACK_PAWN){\n // may still be a move into check, must test at end\n results.add(new Move(kingVal, kingX, kingY, kingX+x, kingY+y, val, 0, this));\n }\n }\n }\n }\n } else { // could be in check TODO: split into case of single check and none, identify pin/capture lines\n int queen = turn == WHITE ? WHITE_QUEEN : BLACK_QUEEN;\n int knight = turn == WHITE ? WHITE_KNIGHT : BLACK_KNIGHT;\n int rook = turn == WHITE ? WHITE_ROOK : BLACK_ROOK;\n int bishop = turn == WHITE ? WHITE_BISHOP : BLACK_BISHOP;\n for (int y = 0; y < 8; y++) {\n for (int x = 0; x < 8; x++) {\n int piece = board[y][x];\n if (piece == (turn == WHITE ? WHITE_PAWN : BLACK_PAWN)) { // pawns\n // regular | 2 move\n if (board[y+turn][x] == 0){\n if (y+turn == 0 || y + turn == 7){ // promotion\n results.add(new Move(piece, x, y, x, y + turn, 0, queen, this));\n results.add(new Move(piece, x, y, x, y + turn, 0, knight, this));\n results.add(new Move(piece, x, y, x, y + turn, 0, rook, this));\n results.add(new Move(piece, x, y, x, y + turn, 0, bishop, this));\n }\n else {\n results.add(new Move(piece, x, y, x, y + turn, 0, 0, this));\n if ((y == (turn == WHITE ? 1 : 6)) && board[y + 2 * turn][x] == 0) { // initial 2 move\n results.add(new Move(piece, x, y, x, y + 2*turn, 0, 0, this));\n }\n }\n }\n // capture\n for (int dx = -1; dx <= 1; dx += 2){\n if (x + dx >= 0 && x + dx < 8) {\n int val = board[y+turn][x+dx];\n if (val > 0 && (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n if (y + turn == 0 || y + turn == 7){ // promotion\n results.add(new Move(piece, x, y, x+dx, y + turn, val, queen, this));\n results.add(new Move(piece, x, y, x+dx, y + turn, val, knight, this));\n results.add(new Move(piece, x, y, x+dx, y + turn, val, rook, this));\n results.add(new Move(piece, x, y, x+dx, y + turn, val, bishop, this));\n } else {\n results.add(new Move(piece, x, y, x+dx, y + turn, val, 0, this));\n }\n }\n if (val == 0 && y == (turn == WHITE ? 4 : 3) && x+dx == enPassant){ // en passant\n results.add(new Move(piece, x, y, x+dx, y + turn, 0, 0, this));\n }\n }\n }\n\n } else if (piece == knight) { // knights TODO: lookup table\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -2; dy <= 2; dy += 4){\n if (x+dx >= 0 && x + dx < 8 && y + dy >= 0 && y + dy < 8){\n int val = board[y+dy][x+dx];\n if (val == 0 || (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n results.add(new Move(piece,x,y,x+dx,y+dy,val,0,this));\n }\n }\n if (x+dy >= 0 && x + dy < 8 && y + dx >= 0 && y + dx < 8){\n int val = board[y+dx][x+dy];\n if (val == 0 || (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n results.add(new Move(piece,x,y,x+dy,y+dx,val,0,this));\n }\n }\n }\n }\n } else if (piece == bishop) { // bishops\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -1; dy <= 1; dy += 2){\n int i = 1;\n while (x + dx*i >= 0 && x + dx*i < 8 && y + dy*i >= 0 && y + dy*i < 8){\n int val = board[y+dy*i][x+dx*i];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n } else if (piece == rook) { // rooks\n for (int dx = -1; dx <= 1; dx+= 2){\n for (int ax = 0; ax < 2; ax++){\n int i = 1;\n while (ax==0 ? y+dx*i >= 0 && y+dx*i < 8 : x+dx*i >= 0 && x+dx*i < 8){\n int val = board[y+dx*i*(1-ax)][x+dx*i*ax];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n } else if (piece == (turn == WHITE ? WHITE_QUEEN : BLACK_QUEEN)) { // queens\n // Diagonals - same as bishops\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -1; dy <= 1; dy += 2){\n int i = 1;\n while (x + dx*i >= 0 && x + dx*i < 8 && y + dy*i >= 0 && y + dy*i < 8){\n int val = board[y+dy*i][x+dx*i];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n for (int dx = -1; dx <= 1; dx+= 2){\n for (int ax = 0; ax < 2; ax++){\n int i = 1;\n while (ax==0 ? y+dx*i >= 0 && y+dx*i < 8 : x+dx*i >= 0 && x+dx*i < 8){\n int val = board[y+dx*i*(1-ax)][x+dx*i*ax];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n } else if (piece == (turn == WHITE ? WHITE_KING : BLACK_KING)) { // king\n for (int dx = -1; dx < 2; dx++){\n for (int dy = -1; dy < 2; dy++){\n if ((dx != 0 || dy != 0) && x+dx >= 0 && x + dx < 8 && y + dy >= 0 && y + dy < 8){\n int val = board[y+dy][x+dx];\n if (val == 0 || (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n results.add(new Move(piece,x,y,x+dx,y+dy,val,0,this));\n }\n }\n }\n }\n }\n }\n }\n // castle\n if (checks.size() == 0){\n if (turn == WHITE && (castles & 0b11) != 0){//(castles[0] || castles[1])){\n board[0][4] = 0; // remove king to avoid check test collisions with extra king\n if ((castles & WHITE_SHORT) != 0 && board[0][5] == 0 && board[0][6] == 0 && inCheck(5,0).size() == 0){\n //if (castles[0] && board[0][5] == 0 && board[0][6] == 0 && inCheck(5,0).size() == 0){\n results.add(new Move(WHITE_KING, 4, 0, 6, 0, 0, 0, this));\n }\n if ((castles & WHITE_LONG) != 0 && board[0][1] == 0 && board[0][2] == 0 && board[0][3] == 0 &&\n inCheck(3,0).size() == 0){\n //if (castles[1] && board[0][1] == 0 && board[0][2] == 0 && board[0][3] == 0 && inCheck(3,0).size() == 0){\n results.add(new Move(WHITE_KING, 4, 0, 2, 0, 0, 0, this));\n }\n board[0][4] = WHITE_KING;\n }else if (turn == BLACK && (castles & 0b1100) != 0){//(castles[2] || castles[3])) {\n board[7][4] = 0; // remove king to avoid check test collisions with extra king\n //if (castles[2] && board[7][5] == 0 && board[7][6] == 0 && inCheck(5, 7).size() == 0) {\n if ((castles & BLACK_SHORT) != 0 && board[7][5] == 0 && board[7][6] == 0 && inCheck(5, 7).size() == 0) {\n results.add(new Move(BLACK_KING, 4, 7, 6, 7, 0, 0, this));\n }\n //if (castles[3] && board[7][1] == 0 && board[7][2] == 0 && board[7][3] == 0 && inCheck(3, 7).size() == 0) {\n if ((castles & BLACK_LONG) != 0 && board[7][1] == 0 && board[7][2] == 0 && board[7][3] == 0 &&\n inCheck(3, 7).size() == 0) {\n results.add(new Move(BLACK_KING, 4, 7, 2, 7, 0, 0, this));\n }\n board[7][4] = BLACK_KING;\n }\n }\n }\n List<Move> fullLegal = new LinkedList<>();\n for (Move m : results){\n makeMove(m);\n turn = -turn;\n if (m.piece == WHITE_KING || m.piece == BLACK_KING){\n if (inCheck(m.toX,m.toY).size() == 0){\n fullLegal.add(m);\n }\n }else if (inCheck(kingX,kingY).size() == 0){\n fullLegal.add(m);\n }\n turn = -turn;\n undoMove(m);\n }\n Collections.sort(fullLegal, (o1, o2) -> o2.score - o1.score); // greatest score treated as least so appears first\n return fullLegal;\n }", "@Override\n ArrayList<Cell> findPossibleMoves(Cell workerPosition) {\n ArrayList<Cell> neighbors = board.getNeighbors(workerPosition);\n ArrayList<Cell> possibleMoves = new ArrayList<Cell>();\n for (Cell cell : neighbors) {\n // + allow movement to cells occupied by opponents, if they can be pushed away\n Cell nextCell;\n int nextX = cell.getPosX() + (cell.getPosX() - workerPosition.getPosX());\n int nextY = cell.getPosY() + (cell.getPosY() - workerPosition.getPosY());\n try {\n nextCell = board.getCell(nextX, nextY);\n } catch (ArrayIndexOutOfBoundsException e) {\n nextCell = null;\n }\n if ((!cell.hasWorker() || (nextCell != null && !nextCell.hasWorker() && !nextCell.isDomed())) &&\n !cell.isDomed() && (cell.getBuildLevel() <= workerPosition.getBuildLevel() + 1))\n possibleMoves.add(cell);\n //\n }\n return findLegalMoves(workerPosition, possibleMoves);\n }", "@Test\n public void testQueenPosition() {\n // initialize the complete chess board\n ChessBoard chessBoard = init(\"CHESS\");\n\n assertEquals(0, chessBoard.getPiece(0, 3).getRow());\n assertEquals(3, chessBoard.getPiece(0, 3).getColumn());\n\n assertEquals(7, chessBoard.getPiece(7, 3).getRow());\n assertEquals(3, chessBoard.getPiece(7, 3).getColumn());\n }", "@Override\r\n\tpublic boolean movement(BoardCells[][] chessBoard, Piece targetPiece, int fromX,int fromY,int toX,int toY) {\t\t\r\n\t\t//DEBUG -- System.out.println(\"\"+fromX+fromY+\" \"+toX+toY);\r\n\t\t\r\n\t\tif(fromY == toY){\t\t\t\r\n\t\t\tif(fromX > toX) {\r\n\t\t\t\tfor(int i = fromX-1; i>toX; i--) {\r\n\t\t\t\t\tif(chessBoard[8-fromY][i].getPiece() != null) {\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\r\n\t\t\t} else if (fromX < toX) {\r\n\t\t\t\tfor(int i = fromX+1; i<toX; i++) {\r\n\t\t\t\t\tif(chessBoard[8-fromY][i].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif(getPieceID().equals(\"bR\")) {\r\n\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"bKc\")) {\r\n\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"bK\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif(getPieceID().equals(\"wR\")) {\r\n\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"wKc\")) {\r\n\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"wK\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\tif(fromX == toX) {\t\t\t\t\r\n\t\t\tif(fromY > toY) {\t\r\n\t\t\t\tfor(int i = fromY-1; i>toY; i--) {\r\n\t\t\t\t\tif(chessBoard[8-i][toX].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t} else if (fromY < toY) {\t\t\t\t\r\n\t\t\t\tfor(int i = fromY+1; i<toY; i++) {\t\t\t\t\t\r\n\t\t\t\t\tif(chessBoard[8-i][toX].getPiece() != null) {\t\t\t\t\t\t\t\r\n\t\t\t\t\t\treturn false;\t\t\t\t\t\t\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t}\t\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tif(getPieceID().equals(\"bR\")) {\r\n\t\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"bKc\")) {\r\n\t\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"bK\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(getPieceID().equals(\"wR\")) {\r\n\t\t\t\t\tfor(int i = 0; i<9 ;i++) {\r\n\t\t\t\t\t\tfor (int j = 0; j<9; j++){\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece() != null) {\r\n\t\t\t\t\t\t\tif(chessBoard[8-i][j].getPiece().getPieceID().equals(\"wKc\")) {\r\n\t\t\t\t\t\t\t\t//Piece king = chessBoard[8-i][j].getPiece();\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t//DEBUG -- System.out.println(king.getPieceID()+color+\" \"+king );\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tchessBoard[8-i][j].getPiece().setPieceID(\"wK\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\r\n\t\t\treturn true;\t\r\n\t\t}\r\n\t\t\t\t\r\n\t\treturn false;\t\t\r\n\t}", "private int Block_Move() {\n\t\tfinal int POSSIBLE_BLOCK = 2;\n\t\tint move = NO_MOVE;\n\t\t\n\t\tif(( gameBoard[TOP_LEFT] + gameBoard[TOP_CENTER] + gameBoard[TOP_RIGHT]) == POSSIBLE_BLOCK){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[TOP_CENTER] == EMPTY){\n\t\t\t\tmove = TOP_CENTER;\n\t\t\t}else if (gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[CTR_LEFT] + gameBoard[CTR_CENTER] + gameBoard[CTR_RIGHT]) == POSSIBLE_BLOCK){\n\t\t\tif(gameBoard[CTR_LEFT] == EMPTY){\n\t\t\t\tmove = CTR_LEFT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[CTR_RIGHT] == EMPTY){\n\t\t\t\tmove = CTR_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[BTM_LEFT] + gameBoard[BTM_CENTER] + gameBoard[BTM_RIGHT]) == POSSIBLE_BLOCK){\n\t\t\tif(gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}else if (gameBoard[BTM_CENTER] == EMPTY){\n\t\t\t\tmove = BTM_CENTER;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_LEFT] + gameBoard[CTR_LEFT] + gameBoard[BTM_LEFT]) == POSSIBLE_BLOCK){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[CTR_LEFT] == EMPTY){\n\t\t\t\tmove = CTR_LEFT;\n\t\t\t}else if (gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_CENTER] + gameBoard[CTR_CENTER] + gameBoard[BTM_CENTER]) == POSSIBLE_BLOCK){\n\t\t\tif(gameBoard[TOP_CENTER] == EMPTY){\n\t\t\t\tmove = TOP_CENTER;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_CENTER] == EMPTY){\n\t\t\t\tmove = BTM_CENTER;\n\t\t\t}\t\t\t\n\t\t}else if((gameBoard[TOP_RIGHT] + gameBoard[CTR_RIGHT] + gameBoard[BTM_RIGHT]) == POSSIBLE_BLOCK){\n\t\t\tif(gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}else if (gameBoard[CTR_RIGHT] == EMPTY){\n\t\t\t\tmove = CTR_RIGHT;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_LEFT] + gameBoard[CTR_CENTER] + gameBoard[BTM_RIGHT]) == POSSIBLE_BLOCK){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_RIGHT] + gameBoard[CTR_CENTER] + gameBoard[BTM_LEFT]) == POSSIBLE_BLOCK){\n\t\t\tif(gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}\n\t\t}\n\t\treturn move;\n\t}", "public int[][] Move(/*int []Start, int[]End, */Board B) {\r\n \tif(this.Status[1]=='X'||this.Position[0]<0||this.Position[1]<0) {\r\n \tSystem.out.println(\"This piece is eliminated, cannot move\");\r\n \treturn null;\t\r\n \t}\r\n \t/*\r\n \tif(this.Status[1]=='C'&&this.CMovesets==null) {\r\n \tSystem.out.println(\"This piece cannot save king in check, cannot move\");\r\n \treturn null;\t\r\n \t}\r\n \t*/\r\n \t/*\r\n \tif(Start==null||End==null) {\r\n \t\t\r\n \t\tSystem.out.println(\"Null Start or End Positions\");\r\n \t\t\r\n \t\treturn null;\r\n \t}\r\n \tif(Start.length!=2||End.length!=2) {\r\n \t\t\r\n \t\tSystem.out.println(\"Start or End Positions invalid size\");\r\n \t\t\r\n \t\treturn null;\r\n \t\t\r\n \t}\r\n \tif(Start[0]!=this.Position[0]||Start[1]!=this.Position[1]) {\r\n \t\tSystem.out.println(\"ERROR, Piece Not Synchronized with where it should be\");\r\n \t\tSystem.exit(-1);\r\n \t}\r\n \t*/\r\n \t\r\n \t///////////////////////////\r\n \tint [][]PathSeq = isAnyPath(/*Start,End,*/B);\r\n \t\r\n \tif(PathSeq==null) {\r\n \t\tSystem.out.println(\"No Path sequences possible for this piece\");\r\n \t//////////////////////////\r\n \t\t// IF PIECE IS KING, CHECK IF NO MOVES AVAILABLE to destroy enemy, \r\n \t\t//block enemy, or if king is only piece left, MOVE king, Then Checkmate!\r\n \t\r\n \t//////////////////////////\r\n \treturn null;\r\n \t}\r\n \t\r\n \t/*\r\n \tScanner reader = new Scanner(System.in);\r\n \tboolean ValidIn=false;\r\n \twhile(!ValidIn) {\r\n \t\tSystem.out.println(\"Enter Path seq to be taken\");\r\n \t\t\r\n \t\t\r\n \t}\r\n \t*/\r\n \treturn PathSeq;\r\n }", "public interface Board\n{\n /** Value for an invalid move */\n int INVALID_MOVE = -1;\n\n /**\n * Returns the height of this Board.\n *\n * @return the height of this Board\n */\n int getHeight();\n\n /**\n * Returns the width of this Board.\n *\n * @return the width of this Board\n */\n int getWidth();\n\n /**\n * Returns the win condition of this Board.\n *\n * @return the win condition of this Board\n */\n int getWinCondition();\n\n /**\n * Returns the winner based on the current state of the board. Assumes that\n * the board is in a valid state and that there is only one player who has\n * n-in-a-row.\n *\n * @return the winner\n */\n Piece getWinner();\n\n /**\n * Returns the piece in the specified column and row.\n *\n * @param col the column\n * @param row the row\n * @return the Piece at the specified position\n */\n Piece getPieceAt(int col, int row);\n\n /**\n * Returns the current turn. Turns start at 0.\n *\n * @return the current turn\n */\n int getCurrentTurn();\n\n /**\n * Returns the next piece to be played. Turns alternate between Black and\n * Red, starting with Black on the first turn.\n *\n * @return the next piece to be played\n */\n Piece getNextPiece();\n\n /**\n * Plays the next piece in the specified column. Columns start from 0 on the\n * far left and end with (width - 1) on the far right. The next piece is\n * determined by the current turn. The piece will be placed in the lowest\n * empty row in the specified column.\n *\n * @param col the column to play the next piece\n * @throws IllegalMoveException if the column is not a valid column or if\n * the column is full\n */\n void play(int col) throws IllegalMoveException;\n\n /**\n * Undoes the last play on this Board.\n *\n * @throws IllegalStateException if the board is empty (i.e. no plays have\n * been made)\n */\n void undoPlay();\n\n /**\n * Checks if playing a piece in the specified column is valid. A move is\n * valid if the column is greater than or equal to 0 (far left column) and\n * less than the width of this Board (far right column) and the column is\n * not full. This method assumes that the board is in a valid state and only\n * checks if the top row of the column is empty.\n *\n * @param col the column to play the next piece\n * @return true if the move is valid, false otherwise.\n */\n boolean isValidMove(int col);\n\n /**\n * Adds a BoardListener to this Board.\n *\n * @param boardListener the BoardListener being added\n */\n void addBoardListener(BoardListener boardListener);\n\n /**\n * Returns an immutable view of this board.\n *\n * @return an immutable view of this board\n */\n ImmutableBoard getImmutableView();\n}", "public Board move(String s, boolean si) {\t\t\n\t\t\n\t\t//Queen-side castling\n\t\tif (s.length() >= 5 && s.substring(0, 5).equals(\"O-O-O\")) {\n\t\t\t\n\t\t\tPiece tempKing;\n\t\t\tPiece tempRook;\n\t\t\tPiece tempNull1;\n\t\t\tPiece tempNull2;\n\t\t\t\n\t\t\tif (si) {\n\t\t\t\t((King) b[0][4]).castle();\n\t\t\t\ttempKing = b[0][4];\n\t\t\t\ttempRook = b[0][0];\n\t\t\t\ttempNull1 = b[0][2];\n\t\t\t\ttempNull2 = b[0][3];\n\t\t\t\t\n\t\t\t\tb[0][2] = tempKing;\n\t\t\t\tb[0][3] = tempRook;\n\t\t\t\tb[0][2].setPosition((byte) 0, (byte) 2);\n\t\t\t\tb[0][3].setPosition((byte) 0, (byte) 3);\n\t\t\t\t\n\t\t\t\tb[0][0] = tempNull1;\n\t\t\t\tb[0][4] = tempNull2;\n\t\t\t\tb[0][0].setPosition((byte) 0, (byte) 0);\n\t\t\t\tb[0][4].setPosition((byte) 0, (byte) 4);\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\t((King) b[7][4]).castle();\n\t\t\t\ttempKing = b[7][4];\n\t\t\t\ttempRook = b[7][0];\n\t\t\t\ttempNull1 = b[7][2];\n\t\t\t\ttempNull2 = b[7][3];\n\t\t\t\t\n\t\t\t\tb[7][2] = tempKing;\n\t\t\t\tb[7][3] = tempRook;\n\t\t\t\tb[7][2].setPosition((byte) 7, (byte) 2);\n\t\t\t\tb[7][3].setPosition((byte) 7, (byte) 3);\n\t\t\t\t\n\t\t\t\tb[7][0] = tempNull1;\n\t\t\t\tb[7][4] = tempNull2;\n\t\t\t\tb[7][0].setPosition((byte) 7, (byte) 0);\n\t\t\t\tb[7][4].setPosition((byte) 7, (byte) 4);\n\t\t\t}\n\t\t\t\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\t//King-side castling\n\t\tif (s.substring(0, 3).equals(\"O-O\")) {\n\t\t\tPiece tempKing;\n\t\t\tPiece tempRook;\n\t\t\tPiece tempNull1;\n\t\t\tPiece tempNull2;\n\t\t\t\n\t\t\tif (si) {\n\t\t\t\t((King) b[0][4]).castle();\n\t\t\t\t\n\t\t\t\ttempKing = b[0][4];\n\t\t\t\ttempRook = b[0][7];\n\t\t\t\ttempNull1 = b[0][5];\n\t\t\t\ttempNull2 = b[0][6];\n\t\t\t\t\n\t\t\t\tb[0][6] = tempKing;\n\t\t\t\tb[0][5] = tempRook;\n\t\t\t\tb[0][6].setPosition((byte) 0, (byte) 6);\n\t\t\t\tb[0][5].setPosition((byte) 0, (byte) 5);\n\t\t\t\t\n\t\t\t\tb[0][7] = tempNull1;\n\t\t\t\tb[0][4] = tempNull2;\n\t\t\t\tb[0][7].setPosition((byte) 0, (byte) 7);\n\t\t\t\tb[0][4].setPosition((byte) 0, (byte) 4);\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\t((King) b[7][4]).castle();\n\t\t\t\t\n\t\t\t\ttempKing = b[7][4];\n\t\t\t\ttempRook = b[7][7];\n\t\t\t\ttempNull1 = b[7][5];\n\t\t\t\ttempNull2 = b[7][6];\n\t\t\t\t\n\t\t\t\tb[7][6] = tempKing;\n\t\t\t\tb[7][5] = tempRook;\n\t\t\t\tb[7][6].setPosition((byte) 7, (byte) 6);\n\t\t\t\tb[7][5].setPosition((byte) 7, (byte) 5);\n\t\t\t\t\n\t\t\t\tb[7][7] = tempNull1;\n\t\t\t\tb[7][4] = tempNull2;\n\t\t\t\tb[7][7].setPosition((byte) 7, (byte) 7);\n\t\t\t\tb[7][4].setPosition((byte) 7, (byte) 4);\n\t\t\t}\n\t\t\t\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\tbyte fR, fC, tR, tC;\n\t\t\n\t\tfR = (byte) (Byte.parseByte(s.substring(2, 3)) - 1);\n\t\ttR = (byte) (Byte.parseByte(s.substring(5, 6)) - 1);\n\t\t\n\t\tif (s.charAt(1) == 'a') {\n\t\t\tfC = 0;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'b') {\n\t\t\tfC = 1;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'c') {\n\t\t\tfC = 2;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'd') {\n\t\t\tfC = 3;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'e') {\n\t\t\tfC = 4;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'f') {\n\t\t\tfC = 5;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'g') {\n\t\t\tfC = 6;\n\t\t}\n\t\t\n\t\telse if (s.charAt(1) == 'h') {\n\t\t\tfC = 7;\n\t\t}\n\t\t\n\t\telse {\n\t\t\tSystem.out.println(\"Invalid Entry\");\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\tif (s.charAt(4) == 'a') {\n\t\t\ttC = 0;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'b') {\n\t\t\ttC = 1;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'c') {\n\t\t\ttC = 2;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'd') {\n\t\t\ttC = 3;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'e') {\n\t\t\ttC = 4;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'f') {\n\t\t\ttC = 5;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'g') {\n\t\t\ttC = 6;\n\t\t}\n\t\t\n\t\telse if (s.charAt(4) == 'h') {\n\t\t\ttC = 7;\n\t\t}\n\t\t\n\t\telse {\n\t\t\tSystem.out.println(\"Invalid Entry\");\n\t\t\treader.pause();\n\t\t\treturn this;\n\t\t}\n\t\t\n\t\tif (b[fR][fC] instanceof King) {\n\t\t\t((King) b[fR][fC]).cantC(0);\n\t\t}\n\t\t\n\t\tif (b[fR][fC] instanceof Rook) {\n\t\t\tif (si) {\n\t\t\t\tif (fR == 0 && fC == 0) {\n\t\t\t\t\tgetKing(si).cantC(-1);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\telse if (fR == 0 && fC == 7) {\n\t\t\t\t\tgetKing(si).cantC(1);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\tif (fR == 7 && fC == 0) {\n\t\t\t\t\tgetKing(si).cantC(-1);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\telse if (fR == 7 && fC == 7) {\n\t\t\t\t\tgetKing(si).cantC(1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tb[tR][tC] = b[fR][fC];\n\t\tb[tR][tC].setPosition(tR, tC);\n\t\tb[fR][fC] = new Null(fR, fC);\n\t\t\n\t\tif (s.length() >= 8 && s.charAt(6) == '=') {\n\t\t\tchar p = s.charAt(7);\n\t\t\t\n\t\t\tif (p == 'N') {\n\t\t\t\tb[tR][tC] = new Knight(si, tR, tC);\n\t\t\t}\n\t\t\n\t\t\telse if (p == 'B') {\n\t\t\t\tb[tR][tC] = new Bishop(si, tR, tC);\n\t\t\t}\n\t\t\t\n\t\t\telse if (p == 'R') {\n\t\t\t\tb[tR][tC] = new Rook(si, tR, tC);\n\t\t\t}\n\t\t\t\n\t\t\telse if (p == 'Q') {\n\t\t\t\tb[tR][tC] = new Queen(si, tR, tC);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}", "private boolean queenMovement(int xPosition, int yPosition){\r\n\t\tif (isMovingStraight(xPosition, yPosition) ||\r\n\t\t\t\tisMovingDiagonal(xPosition, yPosition))\r\n\t\t\t\treturn true;\r\n\t\treturn false;\r\n\t}", "public MahjongSolitaireMove findMove()\n {\n // MAKE A MOVE TO FILL IN \n MahjongSolitaireMove move = new MahjongSolitaireMove();\n\n // GO THROUGH THE ENTIRE GRID TO FIND A MATCH BETWEEN AVAILABLE TILES\n for (int i = 0; i < gridColumns; i++)\n {\n for (int j = 0; j < gridRows; j++)\n {\n ArrayList<MahjongSolitaireTile> stack1 = tileGrid[i][j];\n if (stack1.size() > 0)\n {\n // GET THE FIRST TILE\n MahjongSolitaireTile testTile1 = stack1.get(stack1.size()-1);\n for (int k = 0; k < gridColumns; k++)\n {\n for (int l = 0; l < gridRows; l++)\n {\n if (!((i == k) && (j == l)))\n { \n ArrayList<MahjongSolitaireTile> stack2 = tileGrid[k][l];\n if (stack2.size() > 0) \n {\n // AND TEST IT AGAINST THE SECOND TILE\n MahjongSolitaireTile testTile2 = stack2.get(stack2.size()-1);\n \n // DO THEY MATCH\n if (testTile1.match(testTile2))\n {\n // YES, FILL IN THE MOVE AND RETURN IT\n move.col1 = i;\n move.row1 = j;\n move.col2 = k;\n move.row2 = l;\n return move;\n }\n }\n }\n }\n }\n }\n }\n }\n // WE'VE SEARCHED THE ENTIRE GRID AND THERE\n // ARE NO POSSIBLE MOVES REMAINING\n return null;\n }", "public void move(){\n\t\tint y, z;\n\t\t\n\t\tif(queueArrayGetValue(1) == null && (queueArrayGetValue(2) == null || queueArrayGetValue(3) == null)){\n\t\t\tif(queueArrayGetValue(2) == null && queueArrayGetValue(3) != null){\n\t\t\t\tqueueArraySetKeyValue(1, queueArrayGetKey(3), queueArrayGetValue(3));\n\t\t\t\tqueueArraySetKeyValue(3, null, null);\n\t\t\t}else if(queueArrayGetValue(2) != null && queueArrayGetValue(3) == null){\n\t\t\t\tqueueArraySetKeyValue(1, queueArrayGetKey(2), queueArrayGetValue(2));\n\t\t\t\tqueueArraySetKeyValue(2, null, null);\n\t\t\t}\n\t\t}else{\n\t\t\touterloop:\n\t\t\tfor(int i = 1; i < queueArrayLength(); i++){\n\t\t\t\tif(queueArrayGetValue(i) == null){\n\t\t\t\t\ty = i * 2;\n\t\t\t\t\tz = i * 2 + 1;\n\t\t\t\t\tif(y >= queueArrayLength()){\n\t\t\t\t\t\tbreak outerloop;\n\t\t\t\t\t}else if(z >= queueArrayLength()){\n\t\t\t\t\t\tqueueArraySetKeyValue(i, queueArrayGetKey(y), queueArrayGetValue(y));\n\t\t\t\t\t\tqueueArraySetKeyValue(y, null, null);\n\t\t\t\t\t\tbreak outerloop;\n\t\t\t\t\t}else{\n\t\t\t\t\t\tif(lessThan(y,z)){\n\t\t\t\t\t\t\tqueueArraySetKeyValue(i, queueArrayGetKey(y), queueArrayGetValue(y));\n\t\t\t\t\t\t\tqueueArraySetKeyValue(y, null, null);\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tqueueArraySetKeyValue(i, queueArrayGetKey(z), queueArrayGetValue(z));\n\t\t\t\t\t\t\tqueueArraySetKeyValue(z, null, null);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "@Override\n\tpublic GridCell execute() {\n\t\t//1. if there is a winning position, take it\n\t\tArrayList<GridCell> winningCell = TicTacToeBoardExaminer.getWinningPositions(board, side);\n\t\tif (winningCell.size() > 0) {\n\t\t\tGridCell move = winningCell.get(0);\n\t\t\treturn move;\n\t\t}\n\t\t\n\t\t//2. if there is a losing position, block it\n\t\tArrayList<GridCell> losingCell = TicTacToeBoardExaminer.getLosingPositions(board, side);\n\t\tif (losingCell.size() > 0) {\n\t\t\tGridCell move = losingCell.get(0);\n\t\t\treturn move;\n\t\t}\n\t\t\n\t\t//TODO: Implement checking of forks. This will get you to 100% win or tie rate\n\t\t\n\t\t//3. Otherwise get the optimal position\n\t\tGridCell optimal = TicTacToeBoardExaminer.getOptimal(board, side);\n\t\tif (optimal != null)\n\t\t\treturn optimal;\n\t\t\n\t\t//4. Otherwise just move randomly\n\t\telse \n\t\t\treturn new RandomStrategy(board, side).execute();\n\t\t\n\t}", "public String computerMove() {\n\t\t// Look to win in a row\n\t\tfor (int r = 0; r < 3; r++) {\n\t\t\tif (rowSum[r] == -2) {\n\t\t\t\t// Find the empty space\n\t\t\t\tfor (int c = 0; c < 3; c++) {\n\t\t\t\t\tif (board[r][c] == 0) {\n\t\t\t\t\t\treturn done(r, c);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Look to win in a col\n\t\tfor (int c = 0; c < 3; c++) {\n\t\t\tif (colSum[c] == -2) {\n\t\t\t\t// Find the empty space\n\t\t\t\tfor (int r = 0; r < 3; r++) {\n\t\t\t\t\tif (board[r][c] == 0) {\n\t\t\t\t\t\treturn done(r, c);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Look to win a diag\n\t\tfor (int d = 0; d < 2; d++) {\n\t\t\tif (diagSum[d] == -2) {\n\t\t\t\t// Find the empty space\n\t\t\t\tfor (int r = 0; r < 3; r++) {\n\t\t\t\t\tint c = d == 0 ? r : 2 - r;\n\t\t\t\t\tif (board[r][c] == 0) {\n\t\t\t\t\t\treturn done(r, c);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Look to block a row\n\t\tfor (int r = 0; r < 3; r++) {\n\t\t\tif (rowSum[r] == 2) {\n\t\t\t\t// Find the empty space\n\t\t\t\tfor (int c = 0; c < 3; c++) {\n\t\t\t\t\tif (board[r][c] == 0) {\n\t\t\t\t\t\treturn done(r, c);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Look to block a col\n\t\tfor (int c = 0; c < 3; c++) {\n\t\t\tif (colSum[c] == 2) {\n\t\t\t\t// Find the empty space\n\t\t\t\tfor (int r = 0; r < 3; r++) {\n\t\t\t\t\tif (board[r][c] == 0) {\n\t\t\t\t\t\treturn done(r, c);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Look to block a diag\n\t\tfor (int d = 0; d < 2; d++) {\n\t\t\tif (diagSum[d] == 2) {\n\t\t\t\t// Find the empty space\n\t\t\t\tfor (int r = 0; r < 3; r++) {\n\t\t\t\t\tint c = d == 0 ? r : 2 - r;\n\t\t\t\t\tif (board[r][c] == 0) {\n\t\t\t\t\t\treturn done(r, c);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Find the non-full row and col w/ least val\n\t\tint bestR = -1;\n\t\tint bestC = -1;\n\t\tint minSum = 10;\n\t\tfor (int r = 0; r < 3; r++) {\n\t\t\tfor (int c = 0; c < 3; c++) {\n\t\t\t\tif (board[r][c] == 0) {\n\t\t\t\t\tint sum = rowSum[r] + colSum[c];\n\t\t\t\t\tif (sum < minSum) {\n\t\t\t\t\t\tminSum = sum;\n\t\t\t\t\t\tbestR = r;\n\t\t\t\t\t\tbestC = c;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn done(bestR, bestC);\n\t}", "public void getPossibleMoves() { \n\t\t\tsuper.getPossibleMoves();\n\t\t\tfor (int i = 0; i < Math.abs(xrange); i++) {\n\t\t\t\tif (currentx + xrange - ((int) Math.pow(-1,color)*i) >= 0) { \n\t\t\t\t\tGameWindow.potentialMoves.add(GameWindow.GridCells[currentx + xrange - ((int) Math.pow(-1,color)*i) ][currenty]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( currentx - 1 >= 0 && currenty - 1 >= 0 &&\n\t\t\t\t\tGameWindow.GridCells[currentx + ((int) Math.pow(-1,color)) ][currenty - 1].isOccupiedByOpponent()) {\t// Diagonol left space occupied\n\t\t\t\tGameWindow.potentialMoves.add(GameWindow.GridCells[currentx + ((int) Math.pow(-1,color)) ][currenty - 1]);\n\t\t\t}\n\t\t\tif (currentx - 1 >= 0 && currenty + 1 <= 7 &&\n\t\t\t\t\tGameWindow.GridCells[currentx + ((int) Math.pow(-1,color)) ][currenty + 1].isOccupiedByOpponent()) { \t//Diagonol right space occupied\n\t\t\t\tGameWindow.potentialMoves.add(GameWindow.GridCells[currentx + ((int) Math.pow(-1,color)) ][currenty + 1]);\n\t\t\t}\n\t\t\t\n\t}", "public boolean move(int x, int y, CheckersBoard board) {\n if (whiteTurn == true && team == Constants.TeamId.team1Id) {\n return false;\n }\n if (whiteTurn == false && team == Constants.TeamId.team2Id) {\n return false;\n }\n /**\n * then change the x - y coords of the piece\n * update the UI to remove the highlighted squares then move the piece\n * if chess and shared square you take a piece\n * if checkers you jumped them you take the piece\n * return new x - y components\n *\n * if this is too high up in the tree you can override this implementation or update it\n * to fit specific pieces if its not working for some reason\n */\n if (possible(x, y, gameBoard)) {\n int changex = this.getX()-x;\n int changey = this.getY()-y;\n CheckersPiece temp = gameBoard.boardPositions[getX()][getY()];\n gameBoard.boardPositions[getX()][getY()] = null;\n gameBoard.boardPositions[x][y] = temp;\n if (gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2] != null) {\n System.out.println(\"Here\");\n if (gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2].team != this.team) {\n gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2].imageView.setVisibility(View.GONE);\n gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2] = null;\n }\n }\n this.setX(x);\n this.setY(y);/*\n if (Math.abs(changex) == 2) {\n gameBoard.boardPositions[x + (changex/2)][y + (changey/2)] = null;\n if (team == Constants.TeamId.team1Id) {\n board.numPieces1--;\n } else if (team == Constants.TeamId.team2Id) {\n board.numPieces0--;\n }\n }*/\n\n gameBoard.boardPositions[x][y].imageView.setX(142*x);\n gameBoard.boardPositions[x][y].imageView.setY(142*y);\n // flips after move is\n whiteTurn = !whiteTurn;\n gameBoard.startTimer();\n }\n //setUpUI(gameBoard);\n if (getY() == 7 && team == Constants.TeamId.team2Id) {\n board.crown(this);\n }\n if (getY() == 0 && team == Constants.TeamId.team1Id) {\n board.crown(this);\n }\n return possible(x, y, gameBoard);\n }", "public int canMoveTo(Piece p, Location dest)\n {\n if (p==null||dest==null||!dest.isValid())\n return ILLEGAL_MOVE;\n Location loc = getLocation(p);\n if (dest.equals(loc))\n return ILLEGAL_MOVE;\n int thisCol = loc.getCol();\n int thisRow = loc.getRow();\n int otherCol = dest.getCol();\n int otherRow = dest.getRow();\n int rowDiff = Math.abs(thisRow-otherRow);\n int colDiff = Math.abs(thisCol-otherCol);\n Piece other = getPiece(dest);\n if (other!=null&&other.sameColor(p))\n return ILLEGAL_MOVE;\n switch (p.getType())\n {\n case KING:\n if (rowDiff==0&&colDiff==2) //castling\n {\n if (p.hasMoved())\n return ILLEGAL_MOVE;\n Piece rook = null;\n Direction dir = null;\n if (thisCol > otherCol) //queenside\n {\n dir = Direction.WEST;\n rook = getPiece(new Location(thisRow,thisCol-4));\n }\n else //kingside\n {\n dir = Direction.EAST;\n rook = getPiece(new Location(thisRow,thisCol+3));\n }\n if (rook==null||rook.getType()!=Type.ROOK||!p.sameColor(rook)||rook.hasMoved())\n return ILLEGAL_MOVE;\n Location next = loc;\n for (int i=thisCol; i!=getLocation(rook).getCol(); i=next.getCol())\n {\n if ((!next.equals(loc)&&getPiece(next)!=null)||enemyCanAttack(p.getColor(),next))\n return ILLEGAL_MOVE;\n next = next.farther(dir);\n }\n if (thisCol > otherCol)\n return QUEENSIDE_CASTLING;\n else return KINGSIDE_CASTLING;\n }\n else //normal king move\n if (adjacent(loc,dest)\n && (other==null || !p.sameColor(other)))\n return KING_MOVE;\n else return ILLEGAL_MOVE;\n \n case PAWN:\n if (rowDiff>2||rowDiff<1||colDiff>1||(rowDiff==2&&colDiff>0)\n ||(p.white()&&otherRow>thisRow)||(!p.white()&&otherRow<thisRow))\n return ILLEGAL_MOVE;\n else if (rowDiff==2) //first move\n {\n if (p.hasMoved())\n return ILLEGAL_MOVE;\n Location temp = loc.closerTo(dest);\n if (getPiece(temp)==null&&other==null&&((p.white()&&thisRow==6)||(!p.white()&&thisRow==1)))\n return PAWN_FIRST_MOVE;\n else return ILLEGAL_MOVE;\n }\n else if (colDiff==1 && other!=null) //taking\n {\n if (p.sameColor(other))\n return ILLEGAL_MOVE;\n else return PAWN_CAPTURE;\n }\n else if (colDiff==1 && other==null) //en passant\n {\n int diff = otherCol-thisCol;\n Location otherLoc = new Location(thisRow,thisCol+diff);\n Piece otherPiece = getPiece(otherLoc);\n if (otherPiece!=null&&otherPiece.hasJustMoved()\n &&otherPiece.getType()==Type.PAWN&&!otherPiece.sameColor(p))\n return EN_PASSANT;\n else return ILLEGAL_MOVE;\n }\n else if (rowDiff==1) //normal move\n {\n if (other==null)\n return PAWN_MOVE;\n else return ILLEGAL_MOVE;\n }\n break;\n \n case ROOK:case QUEEN: case BISHOP:case KNIGHT:\n if (!canAttack(p,dest))\n return ILLEGAL_MOVE;\n else\n {\n switch (p.getType())\n {\n case ROOK:return ROOK_MOVE;\n case QUEEN:return QUEEN_MOVE;\n case BISHOP:return BISHOP_MOVE;\n case KNIGHT:return KNIGHT_MOVE;\n }\n }\n }\n return ILLEGAL_MOVE; //will never happen\n }", "private void tryMovePlayer(int direction) {\n int layerOffset = 0, rowOffset = 0, colOffset = 0;\n boolean canMove = false;\n Maze3D.Cell currentCell = maze3D[playerLayer][playerRow][playerCol];\n Maze3D.Cell nextCell = null;\n try {\n switch (direction)\n {\n case Maze3D.UP:\n nextCell = maze3D[playerLayer][playerRow - 1][playerCol];\n canMove = !(currentCell.isWallTop() || nextCell.isWallBottom());\n rowOffset = -1;\n break;\n case Maze3D.DOWN:\n nextCell = maze3D[playerLayer][playerRow + 1][playerCol];\n canMove = !(currentCell.isWallBottom() || nextCell.isWallTop());\n rowOffset = 1;\n break;\n case Maze3D.LEFT:\n nextCell = maze3D[playerLayer][playerRow][playerCol - 1];\n canMove = !(currentCell.isWallLeft() || nextCell.isWallRight());\n colOffset = -1;\n break;\n case Maze3D.RIGHT:\n nextCell = maze3D[playerLayer][playerRow][playerCol + 1];\n canMove = !(currentCell.isWallRight() || nextCell.isWallLeft());\n colOffset = 1;\n break;\n case Maze3D.FRONT:\n nextCell = maze3D[playerLayer - 1][playerRow][playerCol];\n canMove = !(currentCell.isWallFront() || nextCell.isWallBack());\n layerOffset = -1;\n break;\n case Maze3D.BACK:\n nextCell = maze3D[playerLayer + 1][playerRow][playerCol];\n canMove = !(currentCell.isWallBack() || nextCell.isWallFront());\n layerOffset = 1;\n break;\n }\n //if cell is not null and can move, then move\n if (nextCell != null && canMove)\n {\n playerLayer += layerOffset;\n playerRow += rowOffset;\n playerCol += colOffset;\n mazeView.setPlayerLocation(playerLayer, playerRow, playerCol);\n moves++;\n }\n //if new position is the solution, then game is solved\n if (isSolved())\n {\n notifyGameEnd();\n }\n }\n catch (ArrayIndexOutOfBoundsException e)\n {\n Log.d(TAG, \"tryMovePlayer: player tried to move to edge\");\n }\n }", "public static void compute_possible_moves(Board s){\n\t\tint b [][] = s.board;\n\t\tint x = -1;\n\t\tint y = -1;\n\t\tfor (int i = 0;i < b.length;i++) {\n\t\t\tfor (int j = 0;j < b[i].length;j++) {\n\t\t\t\tif(b[i][j] == 0){\n\t\t\t\t\tx = i;\n\t\t\t\t\ty = j;\n\t\t\t\t\tbreak;\n\t\t\t\t}\t\n\t\t\t}\n\t\t}\n\n\t\tint left [][];\n\t\tint right [][];\n\t\tint up [][];\n\t\tint down [][];\n\t\tpossible_boards.clear();\n\t\tif(x - 1 != -1 && x >= 0 && x < 3){\n\t\t\t//up is a legal move\n\t\t\tint temporary_board [][] = new int[b.length][];\n\t\t\tfor(int q = 0; q < b.length; q++)\n\t\t\t temporary_board [q] = b[q].clone();\n\t\t\t\n\n\t\t\tint temp = temporary_board[x - 1][y];\n\t\t\ttemporary_board[x - 1][y] = temporary_board[x][y];\n\t\t\ttemporary_board[x][y] = temp;\n\t\t\tup = temporary_board;\n\n\t\t\tBoard up_board = new Board(up);\n\t\t\tpossible_boards.add(up_board);\n\n\t\t}\n\t\tif(x + 1 != 3 && x >= 0 && x < 3){\n\t\t\t//down is a legal move\n\t\t\tint temporary_board [][] = new int[b.length][];\n\t\t\tfor(int q = 0; q < b.length; q++)\n\t\t\t temporary_board [q] = b[q].clone();\n\t\t\t\n\t\t\tint temp = temporary_board[x + 1][y];\n\t\t\ttemporary_board[x + 1][y] = temporary_board[x][y];\n\t\t\ttemporary_board[x][y] = temp;\n\t\t\tdown = temporary_board;\n\t\t\tBoard down_board = new Board(down);\n\t\t\tpossible_boards.add(down_board);\n\t\t}\n\t\tif(y - 1 != -1 && y >= 0 && y < 3){\n\t\t\t//left move is legal\n\t\t\tint temporary_board [][] = new int[b.length][];\n\t\t\tfor(int q = 0; q < b.length; q++)\n\t\t\t temporary_board [q] = b[q].clone();\n\t\t\t\n\t\t\tint temp = temporary_board[x][y - 1];\n\t\t\ttemporary_board[x][y - 1] = temporary_board[x][y];\n\t\t\ttemporary_board[x][y] = temp;\n\t\t\tleft = temporary_board;\n\t\t\tBoard left_board = new Board(left);\n\t\t\tpossible_boards.add(left_board);\n\n\t\t}\n\t\tif(y + 1 != 3 && y >= 0 && y < 3){\n\t\t\t//right move is legal\n\t\t\tint temporary_board [][] = new int[b.length][];\n\t\t\tfor(int q = 0; q < b.length; q++)\n\t\t\t temporary_board [q] = b[q].clone();\n\t\t\t\n\t\t\tint temp = temporary_board[x][y + 1];\n\t\t\ttemporary_board[x][y + 1] = temporary_board[x][y];\n\t\t\ttemporary_board[x][y] = temp;\n\t\t\tright = temporary_board;\n\t\t\tBoard right_board = new Board(right);\n\t\t\tpossible_boards.add(right_board);\n\n\t\t}\n\n\t}", "public abstract boolean validMove(ChessBoard board, Square from, Square to);", "public Move move() {\n\n byte[] piece;\n int pieceIndex;\n Move.Direction direction = null;\n int counter = 0;\n\n Scanner s = new Scanner(System.in);\n\n\n System.out.println(\"Please select piece to move: \");\n\n\n while (true) {\n try {\n pieceIndex = s.nextInt();\n\n if ((piece = getPiece(pieceIndex)) == null) {\n System.out.println(\"invalid index, try again!\");\n// check if selected piece is stuck\n } else if (\n (((player == Board.V) && (piece[1]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O ) || // UP\n ((player == Board.H) && (piece[1]-1 >=0) && (board.layout[piece[0]][piece[1]-1] == O)) || // DOWN\n ((player == Board.V) && (piece[0]-1 >=0) && (board.layout[piece[0]-1][piece[1]] == O)) || // LEFT\n (((player == Board.H) && (piece[0]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O )) // RIGHT\n {\n break;\n// if all are stuck pass turn\n } else if (counter + 1 < Board.getSize()) {\n counter++;\n System.out.println(\"Piece is stuck, pick another, \" + counter + \" pieces stuck.\");\n } else {\n System.out.println(\"Passing\");\n return null;\n }\n } catch (Exception e){\n System.out.println(\"Piece index expects int, try again\");\n s = new Scanner(System.in);\n }\n }\n System.out.println(\"Please select direction ('w' // 'a' // 's' // 'd'): \");\n\n boolean valid = false;\n while (!valid) {\n\n switch (s.next().charAt(0)) {\n // if the move requested is valid, break the loop, make the move on our record of layout and return the\n // move made\n case 'w':\n direction = Move.Direction.UP;\n valid = (((player == Board.V) && (piece[1]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O );\n break;\n\n case 'a':\n direction = Move.Direction.LEFT;\n valid = ((player == Board.V) && (piece[0]-1 >=0) && (board.layout[piece[0]-1][piece[1]] == O));\n break;\n\n case 's':\n direction = Move.Direction.DOWN;\n valid = ((player == Board.H) && (piece[1]-1 >=0) && (board.layout[piece[0]][piece[1]-1] == O));\n break;\n\n case 'd':\n direction = Move.Direction.RIGHT;\n valid = (((player == Board.H) && (piece[0]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O );\n break;\n default:\n System.out.println(\"Invalid key press, controls are wasd\");\n valid = false;\n }\n }\n Move move = makeMove(direction, pieceIndex);\n board.update(move, player);\n\n return move;\n }", "public static boolean moveking() //returns false if valid move is there\n{ System.out.println(\"IN FUNCTION MOVE KING.....\");\n flag=0;\n int kx,ky;\n if(q==2)\n {\n kx=p2.ka.kbx; //WHITE KING....\n ky=p2.ka.kby;\n } \nelse\n {\n kx=p1.ka.kax; //BLACK KING....\n\tky=p1.ka.kay;\n }\n//CHECKS WHETHER KING CAN MOVE TO THE 8 adjacent places...\n if(kx-1>=0)\n {\n move2(kx,ky,kx-1,ky);\n \n if(flag==1)\n {\n revert(kx,ky,kx-1,ky);\n return false;\n }\n }\n //r\n if(kx+1<=7)\n { move2(kx,ky,kx+1,ky);\n if(flag==1)\n {revert(kx,ky,kx+1,ky);\n return false;\n \n }\n }\n \n //u\n if(ky-1>=0)\n {\n move2(kx,ky,kx,ky-1);\n \n if(flag==1)\n {revert(kx,ky,kx,ky-1);\n return false;\n \n }\n }\n //d\n if(ky+1<=7)\n {\n move2(kx,ky,kx,ky+1);\n \n if(flag==1)\n { revert(kx,ky,kx,ky+1);\n return false;\n \n }\n }\n //lu\n if(kx-1>=0&&ky-1>=0)\n {\n move2(kx,ky,kx-1,ky-1);\n \n if(flag==1)\n {revert(kx,ky,kx-1,ky-1);\n return false;\n \n }\n }\n //ld\n if(kx-1>=0&&ky+1<=7)\n {\n move2(kx,ky,kx-1,ky+1);\n \n if(flag==1)\n {revert(kx,ky,kx-1,ky+1);\n return false;\n \n }\n }\n //ru\n if(kx+1<=7&&ky-1>=0)\n {\n move2(kx,ky,kx+1,ky-1);\n \n if(flag==1)\n {revert(kx,ky,kx+1,ky-1);\n return false;\n \n }\n }\n //rd\n if(kx+1<=7&&ky+1<=7)\n {\n move2(kx,ky,kx+1,ky+1);\n \n if(flag==1)\n {revert(kx,ky,kx+1,ky+1);\n return false;\n \n }\n }\n return true; \n }", "private Coordinate firstMoveHeuristics(TicTacToeModel model, PossibleBoard possibleBoard) {\n BoardSpace[][] board = possibleBoard.board;\n\n if (possibleBoard.freeSpace == TicTacToeModel.BOARD_DIMENSION*TicTacToeModel.BOARD_DIMENSION) {\n if (board[0][0].getIcon() == Icon.EMPTY) {\n return new Coordinate(0,0);\n } else {\n return new Coordinate(0, TicTacToeModel.BOARD_DIMENSION - 1);\n }\n } else if (possibleBoard.freeSpace == TicTacToeModel.BOARD_DIMENSION*TicTacToeModel.BOARD_DIMENSION - 1) {\n if (model.cornerTaken()) {\n return new Coordinate(TicTacToeModel.BOARD_DIMENSION/2, TicTacToeModel.BOARD_DIMENSION/2);\n } else if (board[TicTacToeModel.BOARD_DIMENSION/2][TicTacToeModel.BOARD_DIMENSION/2].getIcon() != Icon.EMPTY) {\n return new Coordinate(0,0);\n } else {\n return model.getCornerNextToEdge();\n }\n }\n\n return null;\n }", "private Move defaultMoveInGoodPlace(PentagoBoard b0) {\n \tPentagoBoard b = (PentagoBoard)b0.clone();\n \tList<Move> moves = b.getMovesFor(getColor());\n \tfor(Move m: moves) {\n \t\tPentagoMove pM = (PentagoMove)m;\n \t\tif(havMyNeighbour(b,getColor(), pM.getPlaceX(), pM.getPlaceY()) == false)\n \t\t\tcontinue;\n \t\tif(canWinInRow(b,pM.getPlaceY(),getColor())) {\n \t\t\tb.doMove(m);\n \t\t\tif(canWinOpponentNow(b) != null) { // przeciwnik nie moze wygrac po moim ruchu\n \t\t\tb.undoMove(m);\n \t\t\tcontinue;\n \t\t}\n \t\t\treturn m;\n \t\t}\n \t\tif(canWinInColumn(b,pM.getPlaceX(),getColor())) {\n \t\t\tb.doMove(m);\n \t\t\tif(canWinOpponentNow(b) != null) { // przeciwnik nie moze wygrac po moim ruchu\n \t\t\tb.undoMove(m);\n \t\t\tcontinue;\n \t\t}\n \t\t\treturn m;\n \t\t}\n \t}\n \treturn null;\n }", "private ArrayList<Move> whiteKing(){\n // obtain current co-ordinates\n int x = this.getX();\n int y = this.getY();\n\n // otherwise create a new vector to store legal whiteMoves\n ArrayList<Move> whiteMoves = new ArrayList<Move>();\n\n // set up m to refer to a Move object\n Move theMove = null;\n\n // first legal move is to go from x,y to x,y+1\n if (validNormalMove(x, y + 1)) {\n theMove = new Move(this, x, y, x, y + 1, false);\n if(takeOverCheck(x, y+1)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n\n // legal move is to go from x,y to x,y-1 if x,y-1 is unoccupied (bottom)\n if (validNormalMove(x, y - 1)) {\n theMove = new Move(this, x, y, x, y - 1, false);\n if(takeOverCheck(x, y-1)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n //left\n // legal move to go left from x,y to x-1, y if x-1,y is unoccupied (left)\n\n if (validNormalMove(x-1, y)) {\n theMove = new Move(this, x, y, x-1, y, false);\n if(takeOverCheck(x-1, y)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n //right\n // legal move to go right from x,y to x+1, y if x+1,y is unoccupied (right)\n\n if (validNormalMove(x+1, y)) {\n theMove = new Move(this, x, y, x+1, y, false);\n\n if(takeOverCheck(x+1, y)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n\n\n // legal move to diagonal top right for white king\n if (validNormalMove(x+1, y + 1)) {\n theMove = new Move(this, x, y, x+1, y + 1, false);\n if(takeOverCheck(x+1, y+1)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n // legal move to diagonal bottom right\n\n if (validNormalMove(x+1, y -1)) {\n theMove = new Move(this, x, y, x+1, y - 1, false);\n if(takeOverCheck(x+1, y-1)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n // legal move to diagonal bottom left\n if (validNormalMove(x-1, y -1)) {\n theMove = new Move(this, x, y, x-1, y - 1, false);\n if(takeOverCheck(x-1, y-1)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n // legal move to diagonal top left\n if (validNormalMove(x-1, y+1)) {\n theMove = new Move(this, x, y, x-1, y + 1, false);\n if(takeOverCheck(x-1, y+1)){\n theMove.setOccupied(true);\n }\n whiteMoves.add(theMove);\n }\n\n\n\n if (whiteMoves.isEmpty())\n return null;\n return whiteMoves;\n }", "public int[][] getMovesQueen(Piece p) {\n x = p.getX();\n y = p.getY();\n int temp[][] = getMovesBishop(p);\n int legalMoves[][] = getMovesRook(p);\n\n for (int i = 0; i < 8; i++) {\n for (int j = 0; j < 8; j++) {\n if (temp[i][j] == 1) {\n legalMoves[i][j] = 1;\n }\n }\n }\n return legalMoves;\n }", "private boolean canEats(Point piece){\r\n\t// direction -1: red pieces +1: black pieces\r\n int dir = isRed(piece)? -1:+1;\r\n int dest = dir * 2; // eat move destination\r\n // compute movement points\r\n Point left = new Point(piece.getFirst() + dir, piece.getSecond() - 1);\r\n Point left2 = new Point(piece.getFirst()+ dest, piece.getSecond() - 2);\r\n Point right = new Point(piece.getFirst() + dir, piece.getSecond() + 1);\r\n Point right2 = new Point(piece.getFirst() + dest, piece.getSecond() + 2);\r\n // check left eat\r\n if(isValidPosition(left) && isValidPosition(left2)){\r\n if(isRed(piece) && isBlack(left) && isEmpty(left2)) return true;\r\n if(isBlack(piece) && isRed(left) && isEmpty(left2)) return true;\r\n }\r\n // check right eat\r\n if(isValidPosition(right) && isValidPosition(right2)){\r\n if(isRed(piece) && isBlack(right) && isEmpty(right2)) return true;\r\n if(isBlack(piece) && isRed(right) && isEmpty(right2)) return true;\r\n }\r\n // if is a queen\r\n if(isQueen(piece)){\r\n // compute queen move points (invert direction)\r\n Point leftQ = new Point(piece.getFirst() - dir, piece.getSecond() - 1);\r\n Point leftQ2 = new Point(piece.getFirst() - dest, piece.getSecond() - 2);\r\n Point rightQ = new Point(piece.getFirst() - dir, piece.getSecond() + 1);\r\n Point rightQ2 = new Point(piece.getFirst() - dest, piece.getSecond() + 2);\r\n // check left eat\r\n if(isValidPosition(leftQ) && isValidPosition(leftQ2)){\r\n if(isRed(piece) && isBlack(leftQ) && isEmpty(leftQ2)) return true;\r\n if(isBlack(piece) && isRed(leftQ) && isEmpty(leftQ2)) return true;\r\n }\r\n // check right eat\r\n if(isValidPosition(rightQ) && isValidPosition(rightQ2)){\r\n if(isRed(piece) && isBlack(rightQ) && isEmpty(rightQ2)) return true;\r\n if(isBlack(piece) && isRed(rightQ) && isEmpty(rightQ2)) return true;\r\n }\r\n }\r\n return false;\r\n }", "protected Set<ChessMove> getPossibleCastlingMoves(ChessModel model, Location location, Set<ChessMove> movesSoFar) {\n\t\tCastlingAvailability castlingAvailability = model.getCastlingAvailability();\n\t\tif ((location == E1) && (getColor() == White)) {\n\t\t\t// this is the white king in the starting position\n\t\t\tif (castlingAvailability.isWhiteCanCastleKingSide()) {\n\t\t\t\tif (model.isLocationEmpty(F1) && model.isLocationEmpty(G1)) {\n\t\t\t\t\tif (!isInCheckAtLocations(model, E1, F1, G1)) {\n\t\t\t\t\t\tChessMove move = new ChessMoveCastleKingSide(getPiece(), E1, G1);\n\t\t\t\t\t\tmovesSoFar.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (castlingAvailability.isWhiteCanCastleQueenSide()) {\n\t\t\t\tif (model.isLocationEmpty(B1) && model.isLocationEmpty(C1) && model.isLocationEmpty(D1)) {\n\t\t\t\t\tif (!isInCheckAtLocations(model, B1, C1, D1, E1)) {\n\t\t\t\t\t\tChessMove move = new ChessMoveCastleQueenSide(getPiece(), E1, C1);\n\t\t\t\t\t\tmovesSoFar.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ((location == E8) && (getColor() == Black)) {\n\t\t\t// this is the black king in the starting position\n\t\t\tif (castlingAvailability.isBlackCanCastleKingSide()) {\n\t\t\t\tif (model.isLocationEmpty(F8) && model.isLocationEmpty(G8)) {\n\t\t\t\t\tif (!isInCheckAtLocations(model, E8, F8, G8)) {\n\t\t\t\t\t\tChessMove move = new ChessMoveCastleKingSide(getPiece(), E8, G8);\n\t\t\t\t\t\tmovesSoFar.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t\tif (castlingAvailability.isBlackCanCastleQueenSide()) {\n\t\t\t\tif (model.isLocationEmpty(B8) && model.isLocationEmpty(C8) && model.isLocationEmpty(D8)) {\n\t\t\t\t\tif (!isInCheckAtLocations(model, B8, C8, D8, E8)) {\n\t\t\t\t\t\tChessMove move = new ChessMoveCastleQueenSide(getPiece(), E8, C8);\n\t\t\t\t\t\tmovesSoFar.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\t\t\t\t\n\t\t\t}\t\t\t\n\t\t}\n\t\treturn movesSoFar;\n\t}", "private boolean isValidQueenMove(int xDisplacement, int yDisplacement) {\n\t\t// Diagonal movement.\n\t\tif((Math.abs(xDisplacement) == Math.abs(yDisplacement)) && xDisplacement != 0)\n\t\t\treturn true;\n\t\telse{\n\t\t\t// Horizontal movement\n\t\t\tif(xDisplacement != 0 && yDisplacement == 0)\n\t\t\t\treturn true;\n\t\t\t// Vertical movement\n\t\t\telse if(xDisplacement == 0 && yDisplacement != 0)\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\treturn false;\n\t\t}\n\t}", "public int getComMove() {\n\n int move;\n\n // Checks if a computer played a move in that spot\n for (int i = 0; i < getBoardSize(); i++) {\n if (playBoard[i] != REAL_PLAYER && playBoard[i] != COM_PLAYER) {\n char currPlace = playBoard[i];\n playBoard[i] = COM_PLAYER;\n\n if (winCheck() == 3) {\n setMove(COM_PLAYER, i);\n return i;\n }\n else {\n playBoard[i] = currPlace;\n }\n }\n }\n\n // Check to block human player from winning\n for (int i = 0; i < getBoardSize(); i++) {\n if (playBoard[i] != REAL_PLAYER && playBoard[i] != COM_PLAYER) {\n char currPlace = playBoard[i];\n playBoard[i] = REAL_PLAYER;\n\n if (winCheck() == 2) {\n setMove(COM_PLAYER, i);\n return i;\n }\n else {\n playBoard[i] = currPlace;\n }\n }\n }\n\n // If play spot is empty, then make move\n do {\n move = randMove.nextInt(getBoardSize());\n } while (playBoard[move] == REAL_PLAYER || playBoard[move] == COM_PLAYER);\n setMove(COM_PLAYER, move);\n\n return move;\n }", "private ArrayList<Move> blackKing() {\n // obtain current co-ordinates\n int x = this.getX();\n int y = this.getY();\n\n ArrayList<Move> blackMoves = new ArrayList<Move>();\n\n // set up m to refer to a Move object\n Move theMove = null;\n\n\n // the top and bottom are opposites coordinates for the black and white kings and so are left and right\n // all Unoccupied moves\n\n // first legal move is to go from x,y to x,y-1 if x,y-1 is unoccupied (top)\n if (validNormalMove(x, y - 1)) {\n theMove = new Move(this, x, y, x, y - 1, false);\n if(takeOverCheck(x, y-1)){\n theMove.setOccupied(true);\n }\n\n blackMoves.add(theMove);\n }\n\n\n // legal move is to go from x,y to x,y+1 if x,y+1 is unoccupied (bottom)\n if (validNormalMove(x, y + 1)) {\n theMove = new Move(this, x, y, x, y + 1, false);\n if(takeOverCheck(x, y+1)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n }\n\n //left\n // legal move to go left from x,y to x+1, y if x+1,y is unoccupied (left)\n\n if (validNormalMove(x+1, y)) {\n theMove = new Move(this, x, y, x+1, y, false);\n if(takeOverCheck(x+1, y)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n\n }\n\n //right\n // legal move to go right from x,y to x-1, y if x-1,y is unoccupied (right)\n\n if (validNormalMove(x-1, y)) {\n theMove = new Move(this, x, y, x-1, y, false);\n\n if(takeOverCheck(x-1, y)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n }\n\n\n // legal move to diagonal top right for white king\n if (validNormalMove(x-1, y - 1)) {\n theMove = new Move(this, x, y, x-1, y - 1, false);\n if(takeOverCheck(x-1, y-1)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n }\n\n // legal move to diagonal bottom left\n\n if (validNormalMove(x+1, y +1)) {\n theMove = new Move(this, x, y, x+1, y + 1, false);\n\n if(takeOverCheck(x+1, y+1)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n }\n\n // legal move to diagonal bottom right\n if (validNormalMove(x-1, y +1)) {\n theMove = new Move(this, x, y, x-1, y + 1, false);\n if(takeOverCheck(x-1, y+1)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n }\n\n // legal move to diagonal top left\n if (validNormalMove(x+1, y-1)) {\n theMove = new Move(this, x, y, x+1, y - 1, false);\n if(takeOverCheck(x+1, y-1)){\n theMove.setOccupied(true);\n }\n blackMoves.add(theMove);\n }\n\n\n\n\n\n if (blackMoves.isEmpty())\n return null;\n return blackMoves;\n }", "boolean findMove(int row, int col, int[][] someStatusBoard) {\n String leftPieces;\n if (_playerOnMove == ORANGE) {\n leftPieces = Game._orangePieces;\n } else {\n leftPieces = Game._violetPieces;\n }\n String trialMove = \"\";\n int numleftPieces = leftPieces.length();\n int l, ori;\n for (l = 0; l < numleftPieces; l++) {\n for (ori = 0; ori < 8; ori++) {\n String piecename = leftPieces.substring(l, l + 1);\n Pieces thispiece = new Pieces();\n int[][] initialPositions = thispiece.getInitialPositions(piecename);\n int[][] finalPositions = thispiece.processPositions(initialPositions, ori);\n int depth = finalPositions.length;\n int length = finalPositions[0].length;\n\n int m, n;\n for (m = 0; m < depth; m++) {\n for (n = 0; n < length; n++) {\n if (finalPositions[m][n] == 1) {\n int newCol = col - 1 - n;\n int newRow = 15 - row - depth;\n if (newCol >= 0 && newRow >= 0) {\n trialMove = piecename + changeBack(newCol) + changeBack(newRow) + ori;\n System.out.println(newCol);\n System.out.println(newRow);\n System.out.println(trialMove);\n if (isLegal(trialMove)) {\n return true;\n }\n }\n }\n }\n }\n }\n }\n return false;\n }", "@Override\n\tpublic boolean canMoveTo(Integer row, Integer col, ChessBoard board) {\n\t\tif((0<=(this.row - row)<=1 && 0<=(this.col - col)<=1) && (1==(this.row - row) || (this.col - col)==1));\n\t\t\treturn true;\n\t\telse\n\t\t\treturn false;\n\t\tfor(int i=0; i<=1 i++) {\n\t\t\tfor(int j=0, j<=1, j++) {\n\t\t\t\tif((i=0) && (j=0))\n\t\t\t\t\t\tcontinue;\n\t\t\t\tboard.pieceAt(row, col);\n\t\t\t}\n\t\t}\n\t\tboard.pieceAt(row, col)\n\t\t\n\t\telse if()\n\t}\n\n\t@Override\n\tpublic void moveTo(Integer row, Integer col) {\n\t\t\n\t\t\n\t}\n\n\t@Override\n\tpublic PieceType getType() {\n\t\t// TODO Auto-generated method stub\n\t\treturn null;\n\t}\n}", "public LinkedList<Move> getPossibleMoves() {\n\t\tAIPossibleMoves.clear();\n\t\tint xOrigin = 0, yOrigin = 0, xMove1 = 0, xMove2 = 0, yMove1 = 0, yMove2 = 0;\n\t\tMove move = null;\t\n\t\t\tint type = 0;\n\t\t\tfor(Checker checker: model.whitePieces) {\n\t\t\t\t\n\t\t\t\txOrigin = checker.getCurrentXPosition();\n\t\t\t\tyOrigin = checker.getCurrentYPosition();\n\t\t\t\txMove1 = (checker.getCurrentXPosition() - 1);\n\t\t\t\txMove2 = (checker.getCurrentXPosition() + 1);\n\t\t\t\tyMove1 = (checker.getCurrentYPosition() - 1);\n\t\t\t\tyMove2 = (checker.getCurrentYPosition() + 1);\n\t\t\t\ttype = checker.getType();\n\t\t\t\tswitch(type) {\n\t\t\t\tcase 2:\n\n\t\t\t\t\tif((xMove1 < 0) || (yMove1 <0)) {\n\t\t\t\t\t//\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\tif(isMoveValid(xOrigin,yOrigin, xMove1, yMove1, false, false )) {\n\t\t\t\t\t\tif(!isSpaceTaken(xMove1,yMove1)) {\n\t\t\t\t\t\t\t//System.out.println(\"Space is not Taken\");\n\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove1, yMove1);\n\t\t\t\t\t\t\tAIPossibleMoves.add(move);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(isPieceEnemy(xMove1,yMove1,checker,2)) {\n\t\t\t\t\t\t\t\tif(isJumpValid(xOrigin, yOrigin, xMove1, yMove1, false, false)) {\n\t\t\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove1, yMove1);\n\t\t\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n \n\t\t\t\t\tif((xMove2 > 7) || (yMove1 < 0)) {\n\t\t\t\t\t//\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\n\t\t\t\t\tif(isMoveValid(xOrigin,yOrigin, xMove2, yMove1, true, false )) {\n\t\t\t\t\t\tif(!isSpaceTaken(xMove2,yMove1)) {\n\t\t\t\t\t\t\t// System.out.println(\"Space is not Taken\");\n\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove2, yMove1);\n\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(isPieceEnemy(xMove2,yMove1,checker,2)) {\n\t\t\t\t\t\t\t\tif(isJumpValid(xOrigin, yOrigin, xMove2, yMove1, true, false)) {\n\t\t\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove2, yMove1);\n\t\t\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\t\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase 4:\n\t\t\t\t\t//Moving up and left isMovingRight,IsMovingDown\n\t\t\t\t\tif((xMove1 <0) || (yMove1 < 0)) {\n\t\t\t\t\t\t//continue;\n\t\t\t\t\t} else {\n\t\t\t\t\tif(isMoveValid(xOrigin,yOrigin, xMove1, yMove1, false, false )) {\n\t\t\t\t\t\tif(!isSpaceTaken(xMove1,yMove1)) {\n\t\t\t\t\t\t//\tSystem.out.println(\"Space is not Taken\");\n\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove1, yMove1);\n\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(isPieceEnemy(xMove1,yMove1,checker,2)) {\n\t\t\t\t\t\t\t\tif(isJumpValid(xOrigin, yOrigin, xMove1, yMove1, false, false)) {\n\t\t\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove1, yMove1);\n\t\t\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif((xMove2 > 7) || (yMove1 < 0)) {\n\t\t\t\t\t//continue;\n\t\t\t\t} else {\n\t\t\t\t\t//moving up and right\n\t\t\t\t\tif(isMoveValid(xOrigin,yOrigin, xMove2, yMove1, true, false )) {\n\t\t\t\t\t\tif(!isSpaceTaken(xMove2,yMove1)) {\n\t\t\t\t\t\t//\tSystem.out.println(\"Space is not Taken\");\n\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove2, yMove1);\n\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(isPieceEnemy(xMove2,yMove1,checker,2)) {\n\t\t\t\t\t\t\t\tif(isJumpValid(xOrigin, yOrigin, xMove2, yMove1, true, false)) {\n\t\t\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove2, yMove1);\n\t\t\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif((xMove1 < 0) || (yMove2 > 7)) {\n\t\t\t\t//\tcontinue;\n\t\t\t\t} else {\n\t\t\t\t\t//moving down and left isMovingRight,IsMovingDown\n\t\t\t\t\tif(isMoveValid(xOrigin,yOrigin, xMove1, yMove2, false, true )) {\n\t\t\t\t\t\tif(!isSpaceTaken(xMove1,yMove2)) {\n\t\t\t\t\t\t//\tSystem.out.println(\"Space is not Taken\");\n\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove1, yMove2);\n\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(isPieceEnemy(xMove1,yMove2,checker,2)) {\n\t\t\t\t\t\t\t\tif(isJumpValid(xOrigin, yOrigin, xMove1, yMove2, false, true)) {\n\t\t\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove1, yMove2);\n\t\t\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif((xMove2 > 7) || (yMove2 > 7)) {\n\t\t\t\t\t//continue;\n\t\t\t\t} else {\n\t\t\t\t\n\t\t\t\t\t//moving down and right isMovingRight,IsMovingDown\n\t\t\t\t\tif(isMoveValid(xOrigin,yOrigin, xMove2, yMove2, true, true )) {\n\t\t\t\t\t\tif(!isSpaceTaken(xMove2,yMove2)) {\n\t\t\t\t\t\t//\tSystem.out.println(\"Space is not Taken\");\n\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove2, yMove2);\n\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(isPieceEnemy(xMove2,yMove2,checker,2)) {\n\t\t\t\t\t\t\t\tif(isJumpValid(xOrigin, yOrigin, xMove2, yMove2, true, true)) {\n\t\t\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove2, yMove2);\n\t\t\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\tbreak;\t\n\t\t\t\t}\t\n\t\t\t\n\t\t\t}\n\n\t\t\treturn AIPossibleMoves;\n\t\t\t\n\t\t}", "private boolean search() {\n // k - 1 indicates the number of queens placed so far\n // We are looking for a position in the kth row to place a queen\n int k = 0;\n while (k >= 0 && k < SIZE) {\n // Find a position to place a queen in the kth row\n int j = findPosition(k);\n if (j < 0) {\n queens[k] = -1;\n k--; // back track to the previous row\n } else {\n queens[k] = j;\n k++;\n }\n }\n \n if (k == -1)\n return false; // No solution\n else\n return true; // A solution is found\n }", "@Test\n\tpublic void moveToOccupiedSpace() throws Exception {\n\t\tKing obstruction1 = new King(PieceColor.WHITE, 1, 5);\n\t\tKing obstruction2 = new King(PieceColor.BLACK, 5, 1);\n\t\tRook obstruction3 = new Rook(PieceColor.WHITE, 1, 1);\n\t\tQueen obstruction4 = new Queen(PieceColor.BLACK, 6, 5);\n\t\tgame.board.addPiece(obstruction1);\n\t\tgame.board.addPiece(obstruction2);\n\t\tgame.board.addPiece(obstruction3);\n\t\tgame.board.addPiece(obstruction4);\n\t\t\n\t\tgame.board.movePiece(knightCorner1White, 1, 5);\n\t\tgame.board.movePiece(knightCorner2Black, 5, 1);\n\t\tgame.board.movePiece(knightSide1White, 1, 1);\n\t\tgame.board.movePiece(knightSide2Black, 6, 5);\n\t\tassertEquals(knightCorner1White, game.board.getPiece(0, 7));\n\t\tassertEquals(knightCorner2Black, game.board.getPiece(7, 0));\n\t\tassertEquals(knightSide1White, game.board.getPiece(3, 0));\n\t\tassertEquals(knightSide2Black, game.board.getPiece(7, 3));\n\t}", "@Override\r\n\tpublic boolean makeMove(String notation) {\n\t\tif(Castle.isCastlingMove(new ChessCoordinate(notation))) {\r\n\t\t\tKing playerKing = (King) getPlayerTurn().getPieces(\"King\", true).get(0);\r\n\t\t\t//return the result of trying to castle\r\n\t\t\treturn playerKing.move(new ChessCoordinate(notation));\r\n\t\t\t\r\n\t\t}else {\r\n\t\t\t//not a castling move, standard move\r\n\t\t\t\t\r\n\t\t\tString[] notationList = notation.split(\"\");\r\n\t\t\t//find the piece name\r\n\t\t\tString pieceName = ChessPieceNames.getPieceName(notationList[0]);\t\t\r\n\t\t\t\r\n\t\t\tif(pieceName == null && getColumnNames().contains(notationList[0].toLowerCase())) {\r\n\t\t\t\t//if first character is a column and returned null from above\r\n\t\t\t\t//must be a pawn move like e4 or axb2\r\n\t\t\t\tpieceName = ChessPieceNames.PAWN.toString();\r\n\t\t\t}else if(pieceName == null){\r\n\t\t\t\t//not a column and null so invalid move\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\r\n//\t\t\t//capturing move if there is a capture (x)\r\n\t\t\tboolean isCaptureMove = Arrays.asList(notationList).contains(\"x\");\r\n\t\t\t\r\n\t\t\t//final coordinate\r\n\t\t\tString coordinateString = notationList[notationList.length-2] + notationList[notationList.length-1];\r\n\t\t\tChessCoordinate coordinate = new ChessCoordinate(coordinateString);\r\n\t\t\tif(coordinate.isValid()) {\r\n\t\t\t\t//extract players alive pieces of piece name\r\n\t\t\t\tList<Piece> piecesOfType = getPlayerTurn().getPieces(pieceName, true);\r\n\t\t\t\t//list of pieces that can move to the same square\r\n\t\t\t\tList<Piece> piecesCanMoveToSquare = new ArrayList<Piece>();\r\n\t\t\t\tfor (Piece piece : piecesOfType) {\r\n\t\t\t\t\t\r\n\t\t\t\t\t//use valid moves of attacking if capturing move, else use move to\r\n\t\t\t\t\tSet<Coordinate> pieceMoves = isCaptureMove \r\n\t\t\t\t\t\t\t? piece.getValidMoves(Action.ATTACK) : piece.getValidMoves(Action.MOVE_TO);\r\n\t\t\t\t\tif(pieceMoves.contains(coordinate))piecesCanMoveToSquare.add(piece);\r\n\t\t\t\t}\t\r\n\t\t\t\t\r\n\t\t\t\tif (piecesCanMoveToSquare.size() == 1) {\r\n\t\t\t\t\t//only one piece can go to that square, so take piece at 0th index as the list only has one element\r\n\t\t\t\t\tpiecesCanMoveToSquare.get(0).move(coordinate);\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\telse if (piecesCanMoveToSquare.size() > 1) {\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(notation.length() <= 3) {\r\n\t\t\t\t\t\tSystem.out.println(\"Invalid move, specify which piece to move to \" + coordinateString);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//multiple pieces of the same type can move to that square, check which one to use\r\n\t\t\t\t\t//if pawn, the identifier to use is the 0th index of notationList, eg axb4. use pawn in column a.\r\n\t\t\t\t\t//for other pieces, column to use is the 1st index of notationList. eg Nab4.\r\n\t\t\t\t\t\r\n\t\t\t\t\t//variable called identifier as it can be a row or column value.\r\n\t\t\t\t\tString identifier = (pieceName.equalsIgnoreCase(ChessPieceNames.PAWN.toString()) ?\r\n\t\t\t\t\t\t\tnotationList[0] : notationList[1]).toLowerCase();\r\n\t\t\t\t\t//identifier should be a row value if pieces share the same column\r\n\t\t\t\t\tboolean isRowIdentifier = shareColumn(piecesOfType);\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(isRowIdentifier && getRowNames().contains(identifier)) {\r\n\t\t\t\t\t\t//locate piece by row and move that piece to coordinate\r\n\t\t\t\t\t\tfor (Piece piece : piecesCanMoveToSquare) {\r\n\t\t\t\t\t\t\t//look at the row number of piece coordinate, see if it matches the identifier \r\n\t\t\t\t\t\t\tif(Character.toString(piece.getPosition().toString().charAt(1)).equalsIgnoreCase(identifier)) {\r\n\t\t\t\t\t\t\t\tpiece.move(coordinate);\r\n\t\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tSystem.out.println(\"There is no \" + pieceName + \" on row \" + identifier);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}else if(getColumnNames().contains(identifier)) {\r\n\t\t\t\t\t\tfor (Piece piece : piecesCanMoveToSquare) {\r\n\t\t\t\t\t\t\t//look at the column letter of piece coordinate, see if it matches the identifier \r\n\t\t\t\t\t\t\tif(Character.toString(piece.getPosition().toString().charAt(0)).equalsIgnoreCase(identifier)) {\r\n\t\t\t\t\t\t\t\tpiece.move(coordinate);\r\n\t\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tSystem.out.println(\"There is no \" + pieceName + \" on column \" + identifier);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//invalid identifier\r\n\t\t\t\t\telse return false;\r\n\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\telse {\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t//invalid coordinate, move can not be played\r\n\t\t\telse return false;\r\n\t\t}\r\n\t\t\r\n\t}", "public MoveResult canMovePiece(Alignment player, Coordinate from, Coordinate to);", "public MoveType isMoveValid(int newIndexX, int newIndexY, int oldIndexX, int oldIndexY) {\n\n if (!isFieldPlaceable(newIndexX, newIndexY) || isFieldOccupied(newIndexX, newIndexY)) {\n return INVALID;\n }\n\n if (bestPieceFound) {\n if (bestPieceToMove != board[oldIndexY][oldIndexX].getPiece()) {\n //check if chosen piece is the best piece to move\n return INVALID;\n }\n if (bestMoveFound) {\n int yDir = (newIndexY - oldIndexY < 0) ? -1 : 1;\n int xDir = (newIndexX - oldIndexX < 0) ? -1 : 1;\n if (xDir != bestMoveDirectionX || yDir != bestMoveDirectionY) {\n return INVALID;\n }\n }\n }\n\n if (board[oldIndexY][oldIndexX].getPiece().getType().equals(PieceType.MEN)) {\n if (abs(newIndexY - oldIndexY) == 2) {\n //kill attempt\n int enemyY = newIndexY - ((newIndexY - oldIndexY) / 2);\n int enemyX = newIndexX - ((newIndexX - oldIndexX) / 2);\n\n if (isEnemyKilled(enemyX, enemyY, board)) {\n //check if kill will be executed properly\n board[enemyY][enemyX].setPiece(null);\n if (controller.killEnemy(enemyX, enemyY)) {\n //update view after killing\n if (round == PieceColor.LIGHT) {\n darkCounter -= 1;\n } else {\n lightCounter -= 1;\n }\n return KILL;\n } else {\n return INVALID;\n }\n }\n }\n\n if (board[oldIndexY][oldIndexX].getPiece().getMoveDirection() == (oldIndexY - newIndexY)) {\n //check if men moves in right direction\n if (killAvailable) {\n //if user execute normal move when kill is available, move is invalid\n return INVALID;\n }\n return MoveType.NORMAL;\n }\n } else if (board[oldIndexY][oldIndexX].getPiece().getType().equals(PieceType.KING)) {\n\n if (abs(newIndexX - oldIndexX) == abs(newIndexY - oldIndexY)) {\n //check if king moves diagonally\n\n int yDir = (newIndexY - oldIndexY < 0) ? -1 : 1;\n int xDir = (newIndexX - oldIndexX < 0) ? -1 : 1;\n\n if (piecesInKingsWay(oldIndexX, oldIndexY, newIndexX, newIndexY, xDir, yDir) == 1)\n //check if king is able to kill piece in its way\n if (isEnemyKilled(newIndexX - xDir, newIndexY - yDir, board)) {\n //check if king is placed just behind piece and try to kill\n return killUsingKing(newIndexX, newIndexY, xDir, yDir, board);\n } else {\n return INVALID;\n }\n else {\n if (piecesInKingsWay(oldIndexX, oldIndexY, newIndexX, newIndexY, xDir, yDir) > 1) {\n //if more pieces in kings way, it cant move over them\n return INVALID;\n }\n }\n\n\n if (newIndexX != oldIndexX && newIndexY != oldIndexY) {\n //every other possibility is checked, if place is changed it is normal move\n if (killAvailable) {\n return INVALID;\n }\n return MoveType.NORMAL;\n }\n }\n }\n if (newIndexX == oldIndexX && newIndexY == oldIndexY) {\n return MoveType.NONE;\n }\n return MoveType.INVALID;\n }", "private void checkMove(Tile[][] chessBoard, int pawnX, int pawnY, int direction) {\r\n\t\tUnit unit = chessBoard[pawnX][pawnY+direction].getPiece();\r\n\t\tif (unit == null) {\r\n\t\t\tMoves move = new Moves(pawnX, pawnY+direction);\r\n\t\t\tinsertMove(move, moveList);\r\n\t\t}\r\n\t}", "private static void addQueenMoves(BitBoard board, LinkedList<Move> moveList, int index,\n\t\t\tint side) {\n\t\tint pieceType = (side == 0) ? CoreConstants.WHITE_QUEEN : CoreConstants.BLACK_QUEEN;\n\t\tlong rookBlockers = (board.getBitBoards()[CoreConstants.WHITE]\n\t\t\t\t| board.getBitBoards()[CoreConstants.BLACK])\n\t\t\t\t& CoreConstants.occupancyMaskRook[index];\n\t\tint lookupIndexRook = (int) ((rookBlockers\n\t\t\t\t* CoreConstants.magicNumbersRook[index]) >>> CoreConstants.magicShiftRook[index]);\n\t\tlong moveSquaresRook = CoreConstants.magicMovesRook[index][lookupIndexRook]\n\t\t\t\t& ~board.getBitBoards()[side];\n\n\t\tlong bishopBlockers = (board.getBitBoards()[CoreConstants.WHITE]\n\t\t\t\t| board.getBitBoards()[CoreConstants.BLACK])\n\t\t\t\t& CoreConstants.occupancyMaskBishop[index];\n\t\tint lookupIndexBishop = (int) ((bishopBlockers\n\t\t\t\t* CoreConstants.magicNumbersBishop[index]) >>> CoreConstants.magicShiftBishop[index]);\n\t\tlong moveSquaresBishop = CoreConstants.magicMovesBishop[index][lookupIndexBishop]\n\t\t\t\t& ~board.getBitBoards()[side];\n\n\t\tlong queenMoves = moveSquaresRook | moveSquaresBishop;\n\t\taddMoves(pieceType, index, queenMoves, moveList, false, false, CoreConstants.noCastle);\n\t}", "@Override\n\tpublic Collection<Move> calculateLegalMoves(final Board board) {\n\t\t\n\t\t//Array that will hold of the legal moves for the Pawn\n\t\tfinal List<Move> legalMoves = new ArrayList<>();\n\t\t\n\t\t//Loop through all possible moves by applying of the offsets to the Pawn's current position\n\t\tfor(final int currentCandidateOffset: CANDIDATE_MOVE_COORDINATES){\n\t\t\t\n\t\t\t//Apply the offset to the Pawn's current position\n\t\t\tfinal int candidateDestinationCoordinate = this.piecePosition + (this.getPieceTeam().getDirection() * currentCandidateOffset);\n\t\t\t\n\t\t\t//Checks if the Destination Coordinate is valid\n\t\t\tif(!BoardUtils.isValidTileCoordinate(candidateDestinationCoordinate)){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t//Checks if this tile is occupied\n\t\t\tif(currentCandidateOffset == 8 && !board.getTile(candidateDestinationCoordinate).isTileOccupied()){\n\t\t\t\tif(this.pieceTeam.isPawnPromotionSquare(candidateDestinationCoordinate))\n\t\t\t\t\tlegalMoves.add(new Move.PawnPromotion(new Move.PawnMove(board, this, candidateDestinationCoordinate)));\n\t\t\t\telse\n\t\t\t\t\tlegalMoves.add(new Move.PawnMove(board, this, candidateDestinationCoordinate));\t\n\t\t\t}\n\t\t\t//Checks if the Pawn is on it's first move\n\t\t\telse if(currentCandidateOffset == 16 && this.isFirstMove() && ((BoardUtils.SEVENTH_RANK[this.piecePosition] && \n\t\t\t\t\tthis.getPieceTeam().isBlack()) || (BoardUtils.SECOND_RANK[this.piecePosition] && this.getPieceTeam().isWhite()))) {\n\t\t\t\t\n\t\t\t\t//Calculate coordinate of the tile behind candidate coordinate\n\t\t\t\tfinal int behindCandidateDestinationCoordinate = this.piecePosition + (this.pieceTeam.getDirection() * 8);\n\t\t\t\t\n\t\t\t\t//Checks if the tile behind the candidate destination is NOT occupied & if the Tile at the Candidate Destination is NOT occupied\n\t\t\t\tif(!board.getTile(behindCandidateDestinationCoordinate).isTileOccupied() && \n\t\t\t !board.getTile(candidateDestinationCoordinate).isTileOccupied())\n\t\t\t\t\t\tlegalMoves.add(new Move.PawnJump(board, this, candidateDestinationCoordinate));\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t//Checks for edge cases in the 7 direction\t\n\t\t\t} else if(currentCandidateOffset == 7 &&\n\t\t\t\t\t!((BoardUtils.FILE_H[this.piecePosition] && this.getPieceTeam().isWhite() ||\n\t\t\t\t\t(BoardUtils.FILE_A[this.piecePosition] && this.getPieceTeam().isBlack())))){\n\t\t\t\t\n\t\t\t\tif(board.getTile(candidateDestinationCoordinate).isTileOccupied()){\n\t\t\t\t\tfinal Piece pieceOnCandidate = board.getTile(candidateDestinationCoordinate).getPiece();\n\t\t\t\t\t//If the pieces are not on the same team an Attack move is added to legal moves.\n\t\t\t\t\tif(this.getPieceTeam() != pieceOnCandidate.getPieceTeam())\n\t\t\t\t\t\tif(this.pieceTeam.isPawnPromotionSquare(candidateDestinationCoordinate))\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnPromotion(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate)));\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t\t\t\n\t\t\t\t//This basically checks if En Passant Pawn is next to Player's pawn\t\n\t\t\t\t} else if(board.getEnPassantPawn() != null){\n\t\t\t\t\tif(board.getEnPassantPawn().getPiecePosition() == (this.piecePosition + (this.pieceTeam.getOppositeDirection()))){\n\t\t\t\t\t\tfinal Piece pieceOnCandidate = board.getEnPassantPawn();\n\t\t\t\t\t\tif(this.pieceTeam != pieceOnCandidate.getPieceTeam()){\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnEnPassantAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t//Checks for edge cases in the 9 direction\t\n\t\t\t} else if(currentCandidateOffset == 9 && \n\t\t\t\t\t!((BoardUtils.FILE_A[this.piecePosition] && this.getPieceTeam().isWhite() ||\n\t\t\t\t\t(BoardUtils.FILE_H[this.piecePosition] && this.getPieceTeam().isBlack())))){\n\t\t\t\t\n\t\t\t\tif(board.getTile(candidateDestinationCoordinate).isTileOccupied()){\n\t\t\t\t\tfinal Piece pieceOnCandidate = board.getTile(candidateDestinationCoordinate).getPiece();\n\t\t\t\t\t//If the pieces are not on the same team an Attack move is added to legal moves.\n\t\t\t\t\tif(this.getPieceTeam() != pieceOnCandidate.getPieceTeam())\n\t\t\t\t\t\tif(this.pieceTeam.isPawnPromotionSquare(candidateDestinationCoordinate))\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnPromotion(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate)));\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t} else if(board.getEnPassantPawn() != null){\n\t\t\t\t\tif(board.getEnPassantPawn().getPiecePosition() == (this.piecePosition - (this.pieceTeam.getOppositeDirection()))){\n\t\t\t\t\t\tfinal Piece pieceOnCandidate = board.getEnPassantPawn();\n\t\t\t\t\t\tif(this.pieceTeam != pieceOnCandidate.getPieceTeam()){\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnEnPassantAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\t\t\t\t\t\n\t\t}\n\t\t\n\t\treturn ImmutableList.copyOf(legalMoves);\n\t}", "private Cell searchEmptySurrounding(){\n List <Cell> blocks = getSurroundingCells(currentWorm.position.x, currentWorm.position.y);\n for (Cell block : blocks){\n if(!isCellOccupied(block)) return block;\n }\n return null;\n }", "private boolean isSquareMovable(BoardSquareInfo target, int state, boolean isKing) {\n\t\tLog.d(LOG_TAG, String.format(\"Is square movable (recursive) square: %s, state: %s, isKing: %s\",target,state,isKing));\n\n\t\t// No need to check in opposite direction\n\t\tif (!isKing && state != activeState)\n\t\t\treturn false;\n\n\t\tif(ensureSquareMovable(target, state, isKing, /*backwards*/ true)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif(ensureSquareMovable(target, state, isKing, /*backwards*/ false)) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}", "public boolean movePlayer(MazePlayer p, Direction d) {\n//\t System.out.println(\"Player \"+p.name+\" requests to move in direction \"+d);\n// players can move through walls with some small probability!\n\t\t // calculate the new position after the move \n\t\t MazePosition oldPos = playerPosition.get(p.name);\n\t\t MazePosition newPos = theBoard.tryMove(oldPos,d);\n\n\t\t \n\t\t //make sure there is no other player at that position\n\t\t // and if there is someone there then just return without moving\n\t\t if (playerPosition.containsValue(newPos)){\n\t\t\t if (!newPos.equals(oldPos))\n\t\t\t\t if (debugging) System.out.println(\"player \"+p.name+\" tried to move into an occupied space.\");\n\t\t\t else\n\t\t\t\t if (debugging) System.out.println(p.name+\" stays at \"+oldPos);\n\t\t\t return false;\n\t\t }\n\t\t \n\t\t //otherwise, make the move\n\t\t playerPosition.put(p.name,newPos);\n\t\t if (debugging) System.out.println(p.name+\": \"+oldPos+\" -> \"+newPos);\n\t\t \n\t\t //take off points if you moved through a wall\n\t\t if (!theBoard.canMove(oldPos,d)){\n\t\t\t score.put(p.name,score.get(p.name)-2);\n\t\t\t if (debugging) System.out.println(p.name+\" moved through a wall\");\n\t\t }\n\t\t \n\t\t // mark that old space as \"free space\"\n\t\t freeSpace.add(0,oldPos);\n\t\t \n\t\t // check to see if there is a jewel in the new position.\n\t\t int i = jewelPosition.indexOf(newPos);\n\t\t if (i > -1) {\n\t\t\t // add 5 to the score\n\t\t\t score.put(p.name,score.get(p.name)+5);\n\t\t\t // remove the jewel\n\t\t\t jewelPosition.remove(i);\n\t\t\t if (debugging) System.out.println(\"and lands on a jewel!, score is now \" +score.get(p.name));\n\t\t\t // add another jewel\n\t\t\t MazePosition q = getEmptySpace();\n\t\t\t jewelPosition.add(q);\n\t\t\t if (debugging) System.out.println(\"adding a new jewel at \"+q);\n\t\t\t \n\t\t }\n\t\t else {\n\t\t\t // if no jewel, then remove the space from the freeSpace list\n\t\t\t freeSpace.remove(newPos);\n\t\t }\n\t\t return true;\n\n }", "public boolean move(int oldCol, int oldRow, int newCol, int newRow , char promo) {\r\n\r\n\r\n if(isValidMove(oldCol, oldRow, newCol, newRow)) {\r\n\r\n\r\n // not a valid move for current player for ANY piece\r\n // if current players king will be in check as a result\r\n // move is disallowed\r\n if (King.isPlayerKingInCheck(oldRow, oldCol, newRow, newCol)) {\r\n return false;\r\n }\r\n else {\r\n\r\n if (Chessboard.whitesTurn==true) {\r\n Chessboard.whiteincheck=false;\r\n }\r\n if (Chessboard.blacksTurn==true) {\r\n Chessboard.blackincheck=false;\r\n }\r\n }\r\n\r\n\r\n\r\n Chessboard.chessBoard[newRow][newCol].setPiece(Chessboard.chessBoard[oldRow][oldCol].getPiece());\r\n Chessboard.chessBoard[oldRow][oldCol].setPiece(null);\r\n Chessboard.chessBoard[newRow][newCol].getPiece().moved();\r\n\r\n if (King.isOpponentKingInCheck(newRow, newCol)){\r\n if (Chessboard.whitesTurn==true) {\r\n Chessboard.blackincheck=true;\r\n }\r\n if (Chessboard.blacksTurn==true) {\r\n Chessboard.whiteincheck=true;\r\n }\r\n }\r\n else {\r\n if (Chessboard.whitesTurn==true) {\r\n Chessboard.blackincheck=false;\r\n }\r\n if (Chessboard.blacksTurn==true) {\r\n Chessboard.whiteincheck=false;\r\n }\r\n }\r\n if(King.isOpponentKinginCheckmate(newRow, newCol)) {\r\n Chessboard.checkMate=true;\r\n }\r\n\r\n\r\n Pawn.r = -1;\r\n Pawn.c = -1;\r\n return true;\r\n }\r\n return false;\r\n }", "boolean legalMove(Move mov) {\n if (mov == null || !validSquare(mov.toIndex())\n || !validSquare(mov.fromIndex())) {\n throw new IllegalArgumentException(\"Illegal move\");\n }\n PieceColor from = get(mov.fromIndex());\n PieceColor to = get(mov.toIndex());\n if (!mov.isJump() && jumpPossible()) {\n return false;\n }\n if (from != _whoseMove) {\n return false;\n } else if (mov.isJump()) {\n return checkJump(mov, false);\n } else if (from == BLACK && row(mov.fromIndex()) == '1') {\n return false;\n } else if (from == WHITE && row(mov.fromIndex()) == '5') {\n return false;\n } else if (mov.isLeftMove()) {\n ArrayList<String> rec = _directions.get(mov.fromIndex());\n return get(mov.toIndex()) == EMPTY\n && !rec.get(rec.size() - 1).equals(\"Right\");\n } else if (mov.isRightMove()) {\n ArrayList<String> rec = _directions.get(mov.fromIndex());\n return get(mov.toIndex()) == EMPTY\n && !rec.get(rec.size() - 1).equals(\"Left\");\n } else if (from == BLACK) {\n if (mov.fromIndex() % 2 == 0 && to == EMPTY) {\n return mov.fromIndex() - mov.toIndex() == SIDE\n || mov.fromIndex() - mov.toIndex() == SIDE - 1\n || mov.fromIndex() - mov.toIndex() == SIDE + 1;\n } else {\n return mov.fromIndex() - mov.toIndex() == SIDE && to == EMPTY;\n }\n } else if (from == WHITE) {\n if (mov.fromIndex() % 2 == 0 && to == EMPTY) {\n return mov.toIndex() - mov.fromIndex() == SIDE\n || mov.toIndex() - mov.fromIndex() == SIDE + 1\n || mov.toIndex() - mov.fromIndex() == SIDE - 1;\n } else {\n return mov.toIndex() - mov.fromIndex() == SIDE && to == EMPTY;\n }\n }\n return false;\n }", "public ArrayList<Move> availableMoves() {\n if (getColour() == PieceCode.WHITE)\n return whiteKing();\n else\n return blackKing();\n }", "Piece askMove(Player J, Piece[] Board, MovingPiece movingPiece, ChessGame G);", "private int getSmartMove(char[] boardConfig) {\n\n ArrayList<Integer> emptySpaces = getEmptySpaces(boardConfig);\n\n double bestScore = -1;\n String bestChoice = \"\";\n int move = 0;\n\n //Loop through each empty space on the board\n for (Integer emptySpace : emptySpaces) {\n int space = emptySpace;\n\n char[] tempBoard = new char[boardConfig.length];\n\n //Create a copy of the board array\n System.arraycopy(boardConfig, 0, tempBoard, 0, boardConfig.length);\n\n //Add the current player's piece to the current empty spot\n tempBoard[space] = game.getPlayer() == 0 ? 'X' : 'O';\n\n //Get a string from the possible move board\n String tempBoardString = boardToString(tempBoard);\n\n //Attempt to get the possible move board configuration data from the long term memory\n BoardRecord record = longTermMemory.get(tempBoardString);\n\n //Check if a record was found\n if (record != null) {\n\n //Calculate the score of the current move in question\n float currentValue = (float) (record.getWins() - record.getLosses()) / (record.getLosses() + record.getWins() + record.getTies());\n\n //If the new move is better than the current best move choose it\n if (currentValue > bestScore) {\n bestScore = currentValue;\n move = space;\n bestChoice = tempBoardString;\n }\n }\n }\n\n if (!Objects.equals(bestChoice, \"\")) {\n shortTermMemory.add(bestChoice);\n return move;\n } else {\n return getRandomMove(boardConfig);\n }\n }", "public interface BoardMoveStrategy {\n\n /**\n * Function that checks if there are any moves possible.\n *\n * <p>Iterates through all gems and looks for pairs or two or\n * constructions like \"xox\" where another x could fill in.\n * For each case a different function is called which checks for\n * a valid move.</p>\n *\n * @return returns two jewels in a list to swap if move is possible.\n */\n List<Jewel> getValidMovePair();\n}", "private MinCQueenState getNextQueen(MinCQueenState currentQueen) {\r\n int[] currentState = currentQueen.getState();\r\n int[] newState = currentState;\r\n\r\n int x = this.random.nextInt(currentState.length);\r\n\r\n for (int y = 0; y < currentState.length; y++) {\r\n // traversing y axis for next possible states.\r\n\r\n if (y == currentState[x]) {\r\n // don't check the same state.\r\n continue;\r\n }\r\n\r\n int[] tempState = Arrays.copyOf(currentState, currentState.length);\r\n tempState[x] = y;\r\n\r\n MinCQueenState tempQueen = new MinCQueenState(tempState);\r\n\r\n if (tempQueen.getColumnOfConflictNumber(x) < currentQueen.getColumnOfConflictNumber(x)) {\r\n // if there is a better state, go to the new state.\r\n newState = tempState;\r\n } else if (tempQueen.getColumnOfConflictNumber(x) == currentQueen.getColumnOfConflictNumber(x)) {\r\n if (tempQueen.getColumnOfConflictNumber(x) == 0 && this.random.nextBoolean()) {\r\n // if there isn't better state and there are other zero conflict positions, go to the new state.\r\n newState = tempState;\r\n }\r\n }\r\n }\r\n\r\n if (newState == currentState) {\r\n // there isn't change, return the original state.\r\n return currentQueen;\r\n } else {\r\n // there is a change, return a new state.\r\n return new MinCQueenState(newState);\r\n }\r\n }", "public static int applyMinMax(int d, BoardModel model, boolean maximizingTeam, int alpha, int beta, boolean whiteTeam, int startDepth) {\n //base case, figure out determinaion of game over\n\n // printMap(model);\n // System.out.println(\"Depth: \"+d);\n \n\n //allPossibleMoves moveTree = new allPossibleMoves();\n int[] currentQueen;\n ArrayList<int[]> whiteQueens = new ArrayList<>();\n ArrayList<int[]> blackQueens = new ArrayList<>();\n ArrayList<int[]> myQueens = new ArrayList<>();\n // possibleMove bestestMove = null;\n\n// for (int count = 0; count < model.queenPositions.size(); count++) {\n// if (model.getTile(model.queenPositions.get(count)).equals(POS_MARKED_BLACK)) {\n// blackQueens.add(model.queenPositions.get(count));\n// // System.out.println(\"Black: \"+model.getTile(model.queenPositions.get(count)));\n// } else {\n// whiteQueens.add(model.queenPositions.get(count));\n// // System.out.println(\"White: \"+model.getTile(model.queenPositions.get(count)));\n// }\n// }\n//set black and white queens \n for (int jam = 0; jam < 10; jam++) {\n for (int pb = 0; pb < 10; pb++) {\n if (model.getTile(new int[]{jam, pb}).equals(POS_MARKED_WHITE)) {\n whiteQueens.add(new int[]{jam, pb});\n }\n if (model.getTile(new int[]{jam, pb}).equals(POS_MARKED_BLACK)) {\n blackQueens.add(new int[]{jam, pb});\n }\n }\n }\n if (maximizingTeam){\n if (whiteTeam){\n myQueens = whiteQueens;\n }\n else{\n myQueens = blackQueens;\n }\n }\n if (!maximizingTeam){\n if (whiteTeam){\n myQueens = blackQueens;\n }\n else{\n myQueens = whiteQueens;\n }\n }\n \n if (d == 0 || findAllMoves(model,myQueens).isEmpty() ) {\n return baseCase(model, whiteTeam);\n }\n\n // System.out.println(\"White Queens identified as: \" + whiteQueens.get(0)[0] + \"\" + whiteQueens.get(0)[1] + \" \" + whiteQueens.get(1)[0] + whiteQueens.get(1)[1] + \" \" + whiteQueens.get(2)[0] + whiteQueens.get(2)[1] + \" \" + whiteQueens.get(3)[0] + whiteQueens.get(3)[1]);\n //if (whiteTeam) {\n // myQueens = whiteQueens;\n //} else {\n // myQueens = blackQueens;\n // }\n // perform a check to see which side we are on. \n // System.out.println(\"Status: \"+maximizingTeam);\n if (maximizingTeam) {\n // System.out.println(\"Maximizing turn\");\n if (whiteTeam) {\n myQueens = whiteQueens;\n } else {\n myQueens = blackQueens;\n }\n\n int maxEval = -1000000;\n // considering this move was played. \n\n // printMap(model);\n // System.out.println();\n //find all children from this state\n ArrayList<ArrayList<int[]>> children = findAllMoves(model, myQueens);\n if (children.size() == 0){\n return baseCase(model, whiteTeam);\n }\n if(children.size()==0 && d == startDepth){\n System.out.println(\"We Lost :( \");\n }\n // printMap(model);\n // System.out.println();\n for (int i = 0; i < children.size(); i++) {\n\n String m1 = stringMap(model);\n\n BoardModel recursionModel = new BoardModel(10);\n\n for (int jam = 0; jam < 10; jam++) {\n for (int pb = 0; pb < 10; pb++) {\n recursionModel.setTile(new int[]{jam, pb}, model.getTile(new int[]{jam, pb}));\n }\n }\n recursionModel.queenPositions = new ArrayList<>();\n for (int x = 0; x < model.queenPositions.size(); x++) {\n recursionModel.queenPositions.add(model.queenPositions.get(x));\n }\n\n // printMap(recursionModel);\n recursionModel.moveQueen(children.get(i).get(0), children.get(i).get(1));\n recursionModel.setTile(children.get(i).get(2), POS_MARKED_ARROW);\n // System.out.println(\"max recursive call\");\n int childVal = applyMinMax(d - 1, recursionModel, false, alpha, beta, whiteTeam, startDepth);\n recursionModel.moveQueen(children.get(i).get(1), children.get(i).get(0));\n recursionModel.setTile(children.get(i).get(2), POS_AVAILABLE);\n\n String m2 = stringMap(model);\n // System.out.println(\"Check board Validity Max: \"+m1.equals(m2));\n\n maxEval = max(maxEval, childVal);\n if (d == startDepth) {\n ArrayList<int[]> blah = new ArrayList<int[]>();\n blah.add(children.get(i).get(0));\n blah.add(children.get(i).get(1));\n blah.add(children.get(i).get(2));\n blah.add(new int[]{childVal});\n maxMinMoves.add(blah);\n }\n alpha = max(maxEval, alpha);\n // System.out.println(\"A: \"+alpha);\n if (alpha >= beta) {\n break;\n }\n }\n return maxEval;\n\n } else {\n // System.out.println(\"Minimizing turn\");\n if (!whiteTeam) {\n myQueens = whiteQueens;\n } else {\n myQueens = blackQueens;\n }\n\n int maxEval = 1000000;\n // considering this move was played. \n\n // printMap(model);\n // System.out.println();\n //find all children from this state\n ArrayList<ArrayList<int[]>> children = findAllMoves(model, myQueens);\n if (children.size() == 0){\n return baseCase(model, whiteTeam);\n }\n if(children.size()==0 && d == startDepth){\n System.out.println(\"We Lost :( \");\n }\n // printMap(model);\n // System.out.println();\n for (int i = 0; i < children.size(); i++) {\n\n String m1 = stringMap(model);\n\n BoardModel recursionModel = new BoardModel(10);\n\n for (int jam = 0; jam < 10; jam++) {\n for (int pb = 0; pb < 10; pb++) {\n recursionModel.setTile(new int[]{jam, pb}, model.getTile(new int[]{jam, pb}));\n }\n }\n recursionModel.queenPositions = new ArrayList<>();\n for (int x = 0; x < model.queenPositions.size(); x++) {\n recursionModel.queenPositions.add(model.queenPositions.get(x));\n }\n\n // printMap(recursionModel);\n recursionModel.moveQueen(children.get(i).get(0), children.get(i).get(1));\n recursionModel.setTile(children.get(i).get(2), POS_MARKED_ARROW);\n // System.out.println(\"min recursive call\");\n int childVal = applyMinMax(d - 1, recursionModel, true, alpha, beta, whiteTeam, startDepth);\n recursionModel.moveQueen(children.get(i).get(1), children.get(i).get(0));\n recursionModel.setTile(children.get(i).get(2), POS_AVAILABLE);\n\n String m2 = stringMap(model);\n // System.out.println(\"Check board Validity Max: \"+m1.equals(m2));\n\n maxEval = min(maxEval, childVal);\n if (d == startDepth) {\n ArrayList<int[]> blah = new ArrayList<int[]>();\n blah.add(children.get(i).get(0));\n blah.add(children.get(i).get(1));\n blah.add(children.get(i).get(2));\n blah.add(new int[]{childVal});\n maxMinMoves.add(blah);\n }\n beta = min(maxEval, alpha);\n // System.out.println(\"A: \"+alpha);\n if (alpha >= beta) {\n break;\n }\n }\n return maxEval;\n }\n\n }", "protected void move(Player player, Movement move) {\n if (board.board[move.oldP.x][move.oldP.y] != null) {\n board.board[move.newP.x][move.newP.y] = board.board[move.oldP.x][move.oldP.y];\n board.board[move.oldP.x][move.oldP.y] = null;\n\n if (player.colour == Colour.BLACK) {\n blackPlayer.move(move);\n whitePlayer.removePiece(move.newP);\n } else if (player.colour == Colour.WHITE) {\n whitePlayer.move(move);\n blackPlayer.removePiece(move.newP);\n }\n\n sharedBoard.update(whitePlayer.getOccupied(), blackPlayer.getOccupied());\n\n // Check for promotions...\n for (int x = 0; x < board.board.length; ++x)\n if (board.board[x][0] instanceof Pawn)\n board.board[x][0] = new Queen(Colour.BLACK);\n else if (board.board[x][7] instanceof Pawn)\n board.board[x][7] = new Queen(Colour.WHITE);\n }\n }", "public boolean move(Piece piece, int moved_xgrid, int moved_ygrid, boolean check) {// check stores if it\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// needs to check\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// freezing and rabbits' moving backward\n\t\tif (moved_xgrid >= 0 && moved_xgrid <= 7 && moved_ygrid >= 0 && moved_ygrid <= 7) {//if it is in grid\n\t\t\tif (piece.possibleMoves(moved_xgrid, moved_ygrid,check)) {//check possible moves\n\t\t\t\tif (getPiece(moved_xgrid, moved_ygrid) == null) {\n\t\t\t\t\tif(checkMove(piece, check)) {\n\t\t\t\t\t// move\n\t\t\t\t\tpiece.setX(moved_xgrid);\n\t\t\t\t\tpiece.setY(moved_ygrid);\n\t\t\t\t\tchecktrap();\n\t\t\t\t\trepaint();\t\t\t\t\t\n\t\t\t\t\treturn true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmessage = \"It is freezed\";\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tmessage = \"There is piece on the place\";\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmessage = \"It is not next to the piece, or rabbit cannot move backward\";\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t} else {\n\t\t\tmessage = \"The selected square is outside the grid\";\n\t\t\treturn false;\n\t\t}\n\t}", "public boolean validRook (int startRow, int startColumn, int endRow, int endColumn, Tile[][] board) {\n\t\t\n\t\tint distanceMovedUpDown =endRow-startRow; \n\t\tint distanceMovedLeftRight = endColumn-startColumn;\n\n\t\tif (distanceMovedUpDown !=0 && distanceMovedLeftRight != 0) { //have to stay in the same column or row to be valid\n\t\t\treturn false;\n\t\t}\n\n\n\t\tif (startRow == endRow) { //moving left or right \n\t\t\tif (Math.abs(distanceMovedLeftRight) > 1) { //checking if there's pieces btwn start and end if moving more than 1\n\t\t\t\tif (distanceMovedLeftRight > 0) {//moving to the right \n\t\t\t\t\tint x=startColumn + 1;\n\t\t\t\t\twhile (x < endColumn) {\n\t\t\t\t\t\tif (board[startRow][x].getOccupyingPiece() != null) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tx++;\n\t\t\t\t\t}\t\n\t\t\t\t}\n\t\t\t\tif (distanceMovedLeftRight < 0) {//moving to the left\n\t\t\t\t\tint x = startColumn -1;\n\t\t\t\t\twhile (x > endColumn) {\n\t\t\t\t\t\tif (board[startRow][x].getOccupyingPiece() != null) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tx--;\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t\treturn true;\n\n\t\t}\n\t\tif (startColumn == endColumn) { //moving up or down\n\t\t\tif (Math.abs(distanceMovedUpDown) > 1) { //checking if there's pieces btwn start and end if moving more than 1\n\t\t\t\tif (distanceMovedUpDown > 0) {//moving up the array\n\t\t\t\t\tint x=startRow + 1;\n\t\t\t\t\twhile (x < endRow) {\n\t\t\t\t\t\tif (board[x][startColumn].getOccupyingPiece() != null) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tx++;\n\t\t\t\t\t}\t\n\t\t\t\t}\n\t\t\t\tif (distanceMovedUpDown < 0) {//moving down the array\n\t\t\t\t\tint x = startRow -1;\n\t\t\t\t\twhile (x > endRow) {\n\t\t\t\t\t\tif (board[x][startColumn].getOccupyingPiece() != null) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tx--;\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\n\t}", "@Override\n public Collection<Move> calculateLegalMoves(Board board) {\n System.out.println(\"INSIDE Knight: calculateLegalMoves()\");\n System.out.println(\"------------------------------>\\n\");\n\n //ArrayList of moves used to store all possible legal moves.\n final List<Move> legalMoves = new ArrayList<>();\n\n //Iterate the constant class array of piece offsets.\n for(final int currentCandidate : CANDIDATE_MOVE_COORDS){\n //Add the current coordinate of the piece to each offset, storing as a destination coordinate.\n final int candidateDestinationCoord = this.piecePosition + currentCandidate;\n\n //If the destination coordinate is within legal board bounds (between 0 and 64)...\n if(BoardUtils.isValidCoord(candidateDestinationCoord)){\n //Check to see if the piece is in the first column and its destination would move it outside the board.\n if(isfirstColumnExclusion(this.piecePosition, currentCandidate) ||\n isSecondColumnExclusion(this.piecePosition, currentCandidate) ||\n isSeventhColumnExclusion(this.piecePosition, currentCandidate) ||\n isEighthColumnExclusion(this.piecePosition, currentCandidate)){\n continue; //Continue the loop if any of these methods return true\n }\n\n //Store the tile of the destination coordinate.\n final Tile candidateDestinationTile = board.getTile(candidateDestinationCoord);\n\n //If the tile is not marked as occupied by the Tile class...\n if(!candidateDestinationTile.isOccupied()){\n //Add the move to the list of legal moves as a non-attack move.\n legalMoves.add(new MajorMove(board, this, candidateDestinationCoord));\n }\n else{\n //Otherwise, get the type and alliance of the piece at the destination.\n final Piece pieceAtDestination = candidateDestinationTile.getPiece();\n final Alliance pieceAlliance = pieceAtDestination.getPieceAlliance();\n\n //If the piece at the occupied tile's alliance differs...\n if(this.pieceAlliance != pieceAlliance){\n //Add the move to the list of legal moves as an attack move.\n legalMoves.add(new MajorAttackMove(board, this, candidateDestinationCoord, pieceAtDestination));\n }\n }\n }\n }\n\n //Return the list of legal moves.\n return legalMoves;\n }", "boolean prepareToMove();", "private Board nextBoard () {\n while (!hasExhaustedDirections()) {\n getNextMove();\n directions_checked++;\n if (inBounds(move)) {\n return createMovedBoard(free, move);\n }\n }\n return null;\n }", "Move getMove() {\r\n int[] p0 = new int[2];\r\n int[] p1 = new int[3];\r\n\r\n while (_playing) {\r\n while (_playing) {\r\n while (_playing) {\r\n _command.getMouse(p0);\r\n System.out.println(\"_command.getMouse 0\");\r\n if (p0[0] >= 0 && p0[1] >= 0) {\r\n System.out.println(\"We got a mouse move on the board for 0\");\r\n break;\r\n }\r\n try {\r\n Thread.sleep(magic1);\r\n System.out.println(\"This is the thread.sleep.\");\r\n } catch (InterruptedException ex) {\r\n System.out.println(\"This is the interruption.\");\r\n return null;\r\n }\r\n }\r\n if (!_playing) {\r\n return null;\r\n }\r\n if (_board.get(p0[0] + 1, p0[1] + 1) == _board.turn()) {\r\n System.out.print(\"Warning!!!\");\r\n break;\r\n }\r\n }\r\n if (!_playing) {\r\n return null;\r\n }\r\n while (_playing) {\r\n _command.getMouse(p1);\r\n System.out.println(\"_command.getMouse 1\");\r\n if (p1[0] >= 0 && p1[1] >= 0) {\r\n System.out.println(\"We got a mouse move on the board for 1\");\r\n break;\r\n }\r\n try {\r\n Thread.sleep(magic1);\r\n System.out.println(\"This is the thread.sleep.\");\r\n } catch (InterruptedException ex) {\r\n System.out.println(\"This is the interruption.\");\r\n return null;\r\n }\r\n }\r\n if (!_playing) {\r\n return null;\r\n }\r\n if (p0[0] == p1[0] || p0[1] == p1[1]\r\n || Math.abs(p1[0] - p0[0]) == Math.abs(p1[1] - p0[1])) {\r\n Move m = Move.create(p0[0] + 1, p0[1] + 1, p1[0] + 1, p1[1] + 1,\r\n _board);\r\n if (m != null && _board.isLegal(m)) {\r\n return m;\r\n }\r\n }\r\n }\r\n return null;\r\n }", "public Queen[] lowestHeuristic(Queen[] state){\n Queen[] min = new Queen[n];\n int minHeuristic = general.getHeuristic(state);\n Queen[] curr = new Queen[n];\n\n //Copy the state in min and curr\n for(int i = 0; i < n; i++){\n min[i] = new Queen(state[i].getRow(), state[i].getColumn());\n curr[i] = new Queen(state[i].getRow(), state[i].getColumn());\n }\n\n //Iterate all columns\n for(int i = 0; i < n; i++){\n if (i>0)\n curr[i-1] = new Queen (state[i-1].getRow(), state[i-1].getColumn());\n curr[i] = new Queen (0, curr[i].getColumn());\n //Iterate rows\n for(int j = 0; j < n; j++){\n\n //Check if a minimum is found\n if(general.getHeuristic(curr) < minHeuristic){\n minHeuristic = general.getHeuristic(curr);\n\n for(int k = 0; k < n; k++)\n min[k] = new Queen(curr[k].getRow(), curr[k].getColumn());\n }\n\n //Move the queen\n if(curr[i].getRow() != n-1)\n curr[i].move();\n }\n }\n return min;\n }", "PrioritizedMove getBestMoveFor(int player, int desiredLength);", "public int[][] getMovesKing(Piece p) {\n x = p.getX();\n y = p.getY();\n int legalMoves[][] = new int[8][8];\n\n //Sjekker alle åtte mulige trekk en konge har.\n if ((x + 1) < 8) {\n if (b.getPieceAt(y, (x + 1)) != null) {\n if (p.isWhite() != b.getPieceAt(y, (x + 1)).isWhite()) {\n legalMoves[y][(x + 1)] = 1;\n }\n } else {\n legalMoves[y][(x + 1)] = 1;\n }\n }\n\n if ((x + 1) < 8 && (y + 1) < 8) {\n if (b.getPieceAt((y + 1), (x + 1)) != null) {\n if (p.isWhite() != b.getPieceAt((y + 1), (x + 1)).isWhite()) {\n legalMoves[(y + 1)][(x + 1)] = 1;\n }\n } else {\n legalMoves[(y + 1)][(x + 1)] = 1;\n }\n }\n\n if ((x - 1) > -1 && (y - 1) > -1) {\n if (b.getPieceAt((y - 1), (x - 1)) != null) {\n if (p.isWhite() != b.getPieceAt((y - 1), (x - 1)).isWhite()) {\n legalMoves[(y - 1)][(x - 1)] = 1;\n }\n } else {\n legalMoves[(y - 1)][(x - 1)] = 1;\n }\n }\n\n if ((x + 1) < 8 && (y - 1) > -1) {\n if (b.getPieceAt((y - 1), (x + 1)) != null) {\n if (p.isWhite() != b.getPieceAt((y - 1), (x + 1)).isWhite()) {\n legalMoves[(y - 1)][(x + 1)] = 1;\n }\n } else {\n legalMoves[(y - 1)][(x + 1)] = 1;\n }\n }\n\n if ((x - 1) > -1) {\n if (b.getPieceAt(y, (x - 1)) != null) {\n if (p.isWhite() != b.getPieceAt(y, (x - 1)).isWhite()) {\n legalMoves[y][(x - 1)] = 1;\n }\n } else {\n legalMoves[y][(x - 1)] = 1;\n }\n }\n\n if ((y - 1) > -1) {\n if (b.getPieceAt((y - 1), x) != null) {\n if (p.isWhite() != b.getPieceAt((y - 1), x).isWhite()) {\n legalMoves[(y - 1)][x] = 1;\n }\n } else {\n legalMoves[(y - 1)][x] = 1;\n }\n }\n\n if ((y + 1) < 8) {\n if (b.getPieceAt((y + 1), x) != null) {\n if (p.isWhite() != b.getPieceAt((y + 1), x).isWhite()) {\n legalMoves[(y + 1)][x] = 1;\n }\n } else {\n legalMoves[(y + 1)][x] = 1;\n }\n }\n\n if ((x - 1) > -1 && (y + 1) < 8) {\n if (b.getPieceAt((y + 1), (x - 1)) != null) {\n if (p.isWhite() != b.getPieceAt((y + 1), (x - 1)).isWhite()) {\n legalMoves[(y + 1)][x - 1] = 1;\n\n }\n } else {\n legalMoves[(y + 1)][x - 1] = 1;\n }\n }\n //Sjekker så om passant trekk går.\n if(p.isWhite()){\n \n if(p.getY() == 7 && p.getX() == 4){\n if(b.getPieceAt(7, 6) == null && b.getPieceAt(7, 5) == null){\n if(b.getPieceAt(7,7) instanceof Rook){\n legalMoves[7][7] = 1;\n }\n }\n if(b.getPieceAt(7,3) == null && b.getPieceAt(7, 2) == null && b.getPieceAt(7, 1)==null){\n if(b.getPieceAt(7, 0) instanceof Rook){\n legalMoves[7][0] = 1;\n }\n }\n }\n }\n if(!p.isWhite()){\n if(p.getY() == 0 && p.getX() == 4){\n if(b.getPieceAt(0, 6) == null && b.getPieceAt(0, 5) == null){\n if(b.getPieceAt(0,7) instanceof Rook){\n legalMoves[0][7] = 1;\n }\n }\n if(b.getPieceAt(0,3) == null && b.getPieceAt(0, 2) == null && b.getPieceAt(0, 1)==null){\n if(b.getPieceAt(0, 0) instanceof Rook){\n legalMoves[0][0] = 1;\n }\n }\n }\n }\n\n return legalMoves;\n\n }", "public ArrayList<Move> getPossibleMoves(int startx, int starty, Board b){//String startpos, Board b){\n\t\t//startpos is the position of the current piece,\n\t\t//so we know which one it is on the board\n\t\t\n\t\tArrayList<Move> moves = new ArrayList<Move>();\n\t\t\n\t\t\n\t\t\n\t\t//int startx = Main.converttoMove(String.valueOf(startpos.charAt(0)));\n\t\t//int starty = Integer.valueOf(String.valueOf(startpos.charAt(1)));\n\t\t\t\t\t\n\t\tPosition startpo = b.getElement(startx, starty);\n\t\tString startcol = startpo.getState().getColor();\n\t\tboolean color = true;//color: white is true, black if false\n\t\tif(startcol.equalsIgnoreCase(\"b\")) {\n\t\t\tcolor = false;\n\t\t}\n\t\t\n\t\t\n\t\t//go up and down\n\t\t//Number of spaces to move in X and Y direction\n //int numSpacesYUp = starty+1;//Not sure if this math is correct\n \n\t\tint numSpacesYUp = Math.abs(starty);\n int numSpacesYDown = Math.abs(8-(starty+1));//^\n\t\t\n \n //go left and right\n\t\tint numSpacesXLeft=Math.abs(startx);//TO DO: Add Math\n\t\t//int numSpacesXRight =Math.abs(8-(startx+1)); //old\n\t\tint numSpacesXRight =Math.abs(8-(startx+1));//new\n \n \n \n\t\t//go diagonal upper right\n \n\t\tint numtoTopRightCorner = Math.min(numSpacesXRight, numSpacesYUp);//the min of the distance from the current spot to the right edge and to the top edge\n for(int i = 1;i<=numtoTopRightCorner;i++) {\n \tint endx = startx+i;\n \tint endy = starty-(i);\n \t\n \t\tPosition endpo = b.getElement(endx, endy);\n \t\tif(endpo.getState() != null) {//theres a piece at the end loc\n \t\tString endcol = endpo.getState().getColor();\n \t\tboolean endcolor = true;//color: white is true, black if false\n \t\tif(endcol.equalsIgnoreCase(\"b\")) {\n \t\t\tendcolor = false;\n \t\t}\n \t\tMove m = new Move(startx, starty, endx, endy);\n \tif(color != endcolor) {\n \t\t//System.out.println(\"\");\n \t\tm.setPieceTaken(true);\n \t\tif(endpo.getState() instanceof King) {\n \t\t\tm.setCheck(true);\n \t\t}else {\n \t\t\tm.setCheck(false);\n \t\t}\n \t\tmoves.add(m);\n \t\t//break;//can't get any more in the upper right diag because there would be a piece blocking its way\n \t}else if(color == endcolor) {\n \t\t//we don't add the move, because its not possible :/\n \t\t//you cant move to a location where you already have a piece\n \t\t//break;\n \t}\n \tbreak;//can't get any more in the upper right diag because there would be a piece blocking its way\n \t\t}else {\n \t\t\tMove m = new Move(startx, starty, endx, endy);\n \t\t\tmoves.add(m);\n \t\t}\n }\n\t\t\n\t\t\n\t\t\n\t\t//go diagonal upper left\n\t\tint numtoTopLeftCorner = Math.min(numSpacesXLeft, numSpacesYUp);//the min of the distance from the current spot to the right edge and to the top edge\n for(int i = 1;i<=numtoTopLeftCorner;i++) {\n \tint endx = startx-(i);\n \tint endy = starty-(i);\n \t\n \t\tPosition endpo = b.getElement(endx, endy);\n \t\tif(endpo.getState() != null) {//theres a piece at the end loc\n \t\tString endcol = endpo.getState().getColor();\n \t\tboolean endcolor = true;//color: white is true, black if false\n \t\tif(endcol.equalsIgnoreCase(\"b\")) {\n \t\t\tendcolor = false;\n \t\t}\n \t\tMove m = new Move(startx, starty, endx, endy);\n \tif(color != endcolor) {\n \t\tm.setPieceTaken(true);\n \t\tif(endpo.getState() instanceof King) {\n \t\t\tm.setCheck(true);\n \t\t}else {\n \t\t\tm.setCheck(false);\n \t\t}\n \t\tmoves.add(m);\n \t\t//break;//can't get any more in the upper right diag because there would be a piece blocking its way\n \t}else if(color == endcolor) {\n \t\t//we don't add the move, because its not possible :/\n \t\t//you cant move to a location where you already have a piece\n \t\t//break;\n \t}\n \tbreak;//can't get any more in the upper right diag because there would be a piece blocking its way\n \t\t}else {\n \t\t\tMove m = new Move(startx, starty, endx, endy);\n \t\t\tmoves.add(m);\n \t\t}\n \t\n \t\n }\n \n \n \n\t\t//go diagonal lewer left\n\t\tint numtoLowerLeftCorner = Math.min(numSpacesXLeft, numSpacesYDown);//the min of the distance from the current spot to the right edge and to the top edge\n for(int i = 1;i<=numtoLowerLeftCorner;i++) {\n \tint endx = startx-(i);\n \tint endy = starty+(i);\n \t\n \t\tPosition endpo = b.getElement(endx, endy);\n \t\tif(endpo.getState() != null) {//theres a piece at the end loc\n \t\tString endcol = endpo.getState().getColor();\n \t\tboolean endcolor = true;//color: white is true, black if false\n \t\tif(endcol.equalsIgnoreCase(\"b\")) {\n \t\t\tendcolor = false;\n \t\t}\n \t\tMove m = new Move(startx, starty, endx, endy);\n \tif(color != endcolor) {\n \t\tm.setPieceTaken(true);\n \t\tif(endpo.getState() instanceof King) {\n \t\t\tm.setCheck(true);\n \t\t}else {\n \t\t\tm.setCheck(false);\n \t\t}\n \t\tmoves.add(m);\n \t\t//break;//can't get any more in the upper right diag because there would be a piece blocking its way\n \t}else if(color == endcolor) {\n \t\t//we don't add the move, because its not possible :/\n \t\t//you cant move to a location where you already have a piece\n \t\t//break;\n \t}\n \tbreak;//can't get any more in the upper right diag because there would be a piece blocking its way\n \t\t}else {\n \t\t\tMove m = new Move(startx, starty, endx, endy);\n \t\t\tmoves.add(m);\n \t\t}\n }\n \n\t\t//go diagonal lower right\n\t\tint numtoLowerRightCorner = Math.min(numSpacesXRight, numSpacesYDown);//the min of the distance from the current spot to the right edge and to the top edge\n for(int i = 1;i<=numtoLowerRightCorner;i++) {\n \tint endx = startx+(i);\n \tint endy = starty+(i);\n \t\n \t//System.out.println(\"num spaces x right:\" + numSpacesXRight);\n \t//System.out.println(\"num spaces y down:\" + numSpacesYDown);\n \t\n \t\tPosition endpo = b.getElement(endx, endy);\n \t\tif(endpo.getState() != null) {//theres a piece at the end loc\n \t\tString endcol = endpo.getState().getColor();\n \t\tboolean endcolor = true;//color: white is true, black if false\n \t\tif(endcol.equalsIgnoreCase(\"b\")) {\n \t\t\tendcolor = false;\n \t\t}\n \t\tMove m = new Move(startx, starty, endx, endy);\n \tif(color != endcolor) {\n \t\tm.setPieceTaken(true);\n \t\tif(endpo.getState() instanceof King) {\n \t\t\tm.setCheck(true);\n \t\t}else {\n \t\t\tm.setCheck(false);\n \t\t}\n \t\tmoves.add(m);\n \t\t//break;//can't get any more in the upper right diag because there would be a piece blocking its way\n \t}else if(color == endcolor) {\n \t\t//we don't add the move, because its not possible :/\n \t\t//you cant move to a location where you already have a piece\n \t\t//break;//should break cause you cant go more in that direction\n \t}\n \tbreak;//can't get any more in the lower right diag because there would be a piece blocking its way\n \t\t}else {\n \t\t\tMove m = new Move(startx, starty, endx, endy);\n \t\t\tmoves.add(m);\n \t\t}\n \t\n \t\n }\n\t\t\n\t\t\n\t\treturn moves;//Return all possible legal moves\n\t}", "private boolean isNextMoveRochade(Move move)\r\n\t{\r\n\t\tif (!(move.from.piece instanceof King)) return false;\r\n\t\tint xDiffAbs = Math.abs(move.to.coordinate.x - move.from.coordinate.x); \r\n\t\treturn xDiffAbs == 2;\r\n\t}", "public int moves() {\n if (!isSolvable()) {\n return -1;\n } else {\n return minNode.getMove();\n }\n\n }", "private Queue<Position> pathToClosest(MyAgentState state, Position start, int goal) {\n\t\tQueue<Position> frontier = new LinkedList<Position>();\n\t\tSet<String> enqueued = new HashSet<String>();\n\t\tMap<Position, Position> preceedes = new HashMap<Position, Position>();\n\t\tfrontier.add(start);\n\t\tenqueued.add(start.toString());\n\n\t\twhile (!frontier.isEmpty()) {\n\t\t\tPosition pos = frontier.remove();\n\t\t\tif (state.getTileData(pos) == goal) {\n\t\t\t\treturn toQueue(preceedes, pos, start);\n\t\t\t}\n\t\t\t\n\t\t\tfor (Position neighbour : pos.neighbours()) {\n\t\t\t\tif (!enqueued.contains(neighbour.toString()) && state.getTileData(neighbour) != state.WALL) {\n\t\t\t\t\tpreceedes.put(neighbour, pos);\n\t\t\t\t\tfrontier.add(neighbour);\n\t\t\t\t\tenqueued.add(neighbour.toString());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}", "public static boolean isValid(Chessmen[][] chessboard, int oldJ, int oldI, int newJ, int newI){\n\t\tboolean movePattern = false; //checks for the movement pattern of pieces\n\t\tboolean isPathClear = false; // checks if path is clear \n\t\tboolean isDestinationClear = false;\n\n\n\t\t//check movement pattern \n\t\tswitch(chessboard[oldJ][oldI]){\n\t\tcase WHITE_PAWN:\t\t\t\t\t\t\t\t\t//can move only one step ahead\n\t\t\tif(((newI - oldI)==0) && (newJ-oldJ == 1)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase WHITE_ROOK: \t\t\t\t\t\t\t\t\t//can move horizontally or vertically\n\t\t\tif(((newI - oldI)==0) || ((newJ - oldJ)==0)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase WHITE_KNIGHT:\t\t\t\t\t\t\t\t\t//moves in L shape\n\t\t\tif((Math.abs(newI-oldI)==2)&& (Math.abs(newJ-oldJ)==1) || (Math.abs(newI-oldI)==1)&& (Math.abs(newJ-oldJ)==2)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase WHITE_BISHOP:\t\t\t\t\t\t\t\t\t//no of steps in x = no. of steps in y\n\t\t\tif(Math.abs(newI - oldI) == Math.abs(newJ - oldJ)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase WHITE_KING:\t\t\t\t\t\t\t\t\t//no of steps in x & y is atmost 1\n\t\t\tif((Math.abs(newI - oldI)<2) && (Math.abs(newJ - oldJ)<2) ){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase WHITE_QUEEN: \n\t\t\tif(Math.abs(newI - oldI) == Math.abs(newJ - oldJ)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else if(((newI - oldI)==0) || ((newJ - oldJ)==0)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase BLACK_PAWN:\n\t\t\tif(((newI - oldI)==0) && (oldJ-newJ == 1)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase BLACK_ROOK: \n\t\t\tif(((newI - oldI)==0) || ((newJ - oldJ)==0)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase BLACK_KNIGHT: \n\t\t\tif((Math.abs(newI-oldI)==2)&& (Math.abs(newJ-oldJ)==1) || (Math.abs(newI-oldI)==1)&& (Math.abs(newJ-oldJ)==2)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase BLACK_BISHOP: \n\t\t\tif(Math.abs(newI - oldI) == Math.abs(newJ - oldJ)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase BLACK_KING: \n\t\t\tif((Math.abs(newI - oldI)<2) && (Math.abs(newJ - oldJ)<2) ){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase BLACK_QUEEN: \n\t\t\tif(Math.abs(newI - oldI) == Math.abs(newJ - oldJ)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else if(((newI - oldI)==0) || ((newJ - oldJ)==0)){\n\t\t\t\tmovePattern = true;\n\t\t\t}else{\n\t\t\t\tmovePattern = false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase EMPTY: \n\t\t\tmovePattern = false;\n\t\t\tbreak;\n\n\t\t}\n\n\n\t\t//switch case for checking path\n\t\tswitch(chessboard[oldJ][oldI]){\n\t\tcase WHITE_PAWN: \n\t\t\tif(chessboard[newJ][newI] == Chessmen.EMPTY){\n\t\t\t\tisPathClear = true; \n\t\t\t}else{\n\t\t\t\tisPathClear=false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase WHITE_ROOK: \n\t\t\tif((Math.abs(newI - oldI) == 0)){ //vertical case\n\t\t\t\tboolean truth = true;\n\t\t\t\tint sign = (int)Math.signum(newJ - oldJ);\n\t\t\t\tint j = oldJ;\n\t\t\t\tif(sign>0){\n\t\t\t\t\twhile(truth && j<(newJ-1)){\n\t\t\t\t\t\tif(chessboard[++j][oldI] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth = true;\n\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\ttruth = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}else if(sign<0){\n\t\t\t\t\twhile(truth && j>(newJ+1)){\n\t\t\t\t\t\tif(chessboard[--j][oldI] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth = true;\n\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\ttruth = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tisPathClear = truth;\n\t\t\t} else if((Math.abs(newJ - oldJ) == 0)){ //horizontal case\n\t\t\t\tboolean truth = true;\n\t\t\t\tint sign = (int)Math.signum(newI - oldI);\n\t\t\t\tint i = oldI;\n\t\t\t\tif(sign>0){\n\t\t\t\t\twhile(truth && i<(newI-1)){\n\t\t\t\t\t\tif(chessboard[oldJ][++i] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth = true;\n\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\ttruth = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}else if(sign<0){\n\t\t\t\t\twhile(truth && i>(newI+1)){\n\t\t\t\t\t\tif(chessboard[oldJ][--i] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth = true;\n\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\ttruth = false;\t\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tisPathClear = truth;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase WHITE_KNIGHT : \n\t\t\tisPathClear = true; //trival case as Pawn\n\t\t\tbreak;\n\n\t\tcase WHITE_BISHOP:\n\t\t\tint horizontal = (int)Math.signum(newI - oldI);\n\t\t\tint vertical = (int)Math.signum(newJ - oldJ);\n\t\t\tboolean truth = true;\n\t\t\tint i = oldI;\n\t\t\tint j = oldJ;\n\t\t\tif(horizontal>0 && vertical>0){\n\t\t\t\twhile(truth && (i<(newI-1) && j<(newJ-1)) ){\n\t\t\t\t\tif(chessboard[++j][++i] == Chessmen.EMPTY){\n\t\t\t\t\t\ttruth = true;\n\n\t\t\t\t\t}else{\n\t\t\t\t\t\ttruth = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}// ++ case\n\t\t\t}\n\t\t\tif(horizontal>0 && vertical<0){\n\t\t\t\twhile(truth && (i<(newI-1) && j>(newJ+1)) ){\n\t\t\t\t\tif(chessboard[--j][++i] == Chessmen.EMPTY){\n\t\t\t\t\t\ttruth = true;\n\n\t\t\t\t\t}else{\n\t\t\t\t\t\ttruth = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(horizontal<0 && vertical<0){\n\t\t\t\twhile(truth && (i>(newI+1) && j>(newJ+1)) ){\n\t\t\t\t\tif(chessboard[--j][--i] == Chessmen.EMPTY){\n\t\t\t\t\t\ttruth = true;\n\n\t\t\t\t\t}else{\n\t\t\t\t\t\ttruth = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t\tif(horizontal<0 && vertical>0){\n\t\t\t\twhile(truth && (i>(newI+1) && j<(newJ-1)) ){\n\t\t\t\t\tif(chessboard[++j][--i] == Chessmen.EMPTY){\n\t\t\t\t\t\ttruth = true;\n\n\t\t\t\t\t}else{\n\t\t\t\t\t\ttruth = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tisPathClear = truth;\n\n\t\t\tbreak;\n\t\tcase WHITE_QUEEN :\n\t\t\tif((newI-oldI)==0 || (newJ-oldJ)==0){\n\t\t\t\t//rook's code\n\t\t\t\tif((Math.abs(newI - oldI) == 0)){ //vertical case\n\t\t\t\t\tboolean truth1 = true;\n\t\t\t\t\tint sign = (int)Math.signum(newJ - oldJ);\n\t\t\t\t\tint j1 = oldJ;\n\t\t\t\t\tif(sign>0){\n\t\t\t\t\t\twhile(truth1 && j1<(newJ-1)){\n\t\t\t\t\t\t\tif(chessboard[++j1][oldI] == Chessmen.EMPTY){\n\t\t\t\t\t\t\t\ttruth1 = true;\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}else if(sign<0){\n\t\t\t\t\t\twhile(truth1 && j1>(newJ+1)){\n\t\t\t\t\t\t\tif(chessboard[--j1][oldI] == Chessmen.EMPTY){\n\t\t\t\t\t\t\t\ttruth1 = true;\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tisPathClear = truth1;\n\t\t\t\t} else if((Math.abs(newJ - oldJ) == 0)){ //horizontal case\n\t\t\t\t\tboolean truth1 = true;\n\t\t\t\t\tint sign = (int)Math.signum(newI - oldI);\n\t\t\t\t\tint i1 = oldI;\n\t\t\t\t\tif(sign>0){\n\t\t\t\t\t\twhile(truth1 && i1<(newI-1)){\n\t\t\t\t\t\t\tif(chessboard[oldJ][++i1] == Chessmen.EMPTY){\n\t\t\t\t\t\t\t\ttruth1 = true;\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}else if(sign<0){\n\t\t\t\t\t\twhile(truth1 && i1>(newI+1)){\n\t\t\t\t\t\t\tif(chessboard[oldJ][--i1] == Chessmen.EMPTY){\n\t\t\t\t\t\t\t\ttruth1 = true;\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tisPathClear = truth1;\n\t\t\t\t}\t\t\t\t\n\t\t\t} else{\n\t\t\t\t//bishop's code\n\t\t\t\tint horizontal1 = (int)Math.signum(newI - oldI);\n\t\t\t\tint vertical1 = (int)Math.signum(newJ - oldJ);\n\t\t\t\tboolean truth1 = true;\n\t\t\t\tint i1 = oldI;\n\t\t\t\tint j1 = oldJ;\n\t\t\t\tif(horizontal1>0 && vertical1>0){\n\t\t\t\t\twhile(truth1 && (i1<(newI-1) && j1<(newJ-1)) ){\n\t\t\t\t\t\tif(chessboard[++j1][++i1] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth1 = true;\n\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}// ++ case\n\t\t\t\t}\n\t\t\t\tif(horizontal1>0 && vertical1<0){\n\t\t\t\t\twhile(truth1 && (i1<(newI-1) && j1>(newJ+1)) ){\n\t\t\t\t\t\tif(chessboard[--j1][++i1] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth1 = true;\n\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(horizontal1<0 && vertical1<0){\n\t\t\t\t\twhile(truth1 && (i1>(newI+1) && j1>(newJ+1)) ){\n\t\t\t\t\t\tif(chessboard[--j1][--i1] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth1 = true;\n\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t\tif(horizontal1<0 && vertical1>0){\n\t\t\t\t\twhile(truth1 && (i1>(newI+1) && j1<(newJ-1)) ){\n\t\t\t\t\t\tif(chessboard[++j1][--i1] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth1 = true;\n\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tisPathClear = truth1;\n\n\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t\tbreak;\n\t\tcase WHITE_KING: \n\t\t\tisPathClear = true;\n\t\t\tbreak;\n\t\tcase BLACK_PAWN: \n\t\t\tif(chessboard[newJ][newI] == Chessmen.EMPTY){\n\t\t\t\tisPathClear = true; \n\t\t\t}else{\n\t\t\t\tisPathClear=false;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase BLACK_ROOK: \n\t\t\tif((Math.abs(newI - oldI) == 0)){ //vertical case\n\t\t\t\tboolean truth1 = true;\n\t\t\t\tint sign = (int)Math.signum(newJ - oldJ);\n\t\t\t\tint j1 = oldJ+ sign;\n\t\t\t\tif(sign>0){\n\t\t\t\t\twhile(truth1 && j1<newJ){\n\t\t\t\t\t\tif(chessboard[j1++][oldI] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth1 = true;\n\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}else if(sign<0){\n\t\t\t\t\twhile(truth1 && j1>newJ){\n\t\t\t\t\t\tif(chessboard[j1--][oldI] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth1 = true;\n\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tisPathClear = truth1;\n\t\t\t} else if((Math.abs(newJ - oldJ) == 0)){ //horizontal case\n\t\t\t\tboolean truth1 = true;\n\t\t\t\tint sign = (int)Math.signum(newI - oldI);\n\t\t\t\tint i1 = oldI+sign;\n\t\t\t\tif(sign>0){\n\t\t\t\t\twhile(truth1 && i1<newI){\n\t\t\t\t\t\tif(chessboard[oldJ][i1++] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth1 = true;\n\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}else if(sign<0){\n\t\t\t\t\twhile(truth1 && i1>newI){\n\t\t\t\t\t\tif(chessboard[oldJ][i1--] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth1 = true;\n\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tisPathClear = truth1;\n\t\t\t}\n\n\t\t\tbreak;\n\t\tcase BLACK_KNIGHT : \n\t\t\tisPathClear = true;\n\t\t\tbreak;\n\t\tcase BLACK_BISHOP: \n\t\t\tint horizontal1 = (int)Math.signum(newI - oldI);\n\t\t\tint vertical1 = (int)Math.signum(newJ - oldJ);\n\t\t\tboolean truth1 = true;\n\t\t\tint i1 = oldI + horizontal1;\n\t\t\tint j1 = oldJ + vertical1;\n\t\t\tif(horizontal1>0 && vertical1>0){\n\t\t\t\twhile(truth1 && (i1<newI && j1<newJ) ){\n\t\t\t\t\tif(chessboard[j1++][i1++] == Chessmen.EMPTY){\n\t\t\t\t\t\ttruth1 = true;\n\n\t\t\t\t\t}else{\n\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}// ++ case\n\t\t\t}\n\t\t\tif(horizontal1>0 && vertical1<0){\n\t\t\t\twhile(truth1 && (i1<newI && j1>newJ) ){\n\t\t\t\t\tif(chessboard[j1--][i1++] == Chessmen.EMPTY){\n\t\t\t\t\t\ttruth1 = true;\n\n\t\t\t\t\t}else{\n\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(horizontal1<0 && vertical1<0){\n\t\t\t\twhile(truth1 && (i1>newI && j1>newJ) ){\n\t\t\t\t\tif(chessboard[j1--][i1--] == Chessmen.EMPTY){\n\t\t\t\t\t\ttruth1 = true;\n\n\t\t\t\t\t}else{\n\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t\tif(horizontal1<0 && vertical1>0){\n\t\t\t\twhile(truth1 && (i1>newI && j1<newJ) ){\n\t\t\t\t\tif(chessboard[j1++][i1--] == Chessmen.EMPTY){\n\t\t\t\t\t\ttruth1 = true;\n\n\t\t\t\t\t}else{\n\t\t\t\t\t\ttruth1 = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tisPathClear = truth1;\n\n\n\t\t\tbreak;\n\t\tcase BLACK_QUEEN : \n\t\t\tif((newI-oldI)==0 || (newJ-oldJ)==0){\n\t\t\t\t//rook's code\n\t\t\t\tif((Math.abs(newI - oldI) == 0)){ //vertical case\n\t\t\t\t\tboolean truth11 = true;\n\t\t\t\t\tint sign = (int)Math.signum(newJ - oldJ);\n\t\t\t\t\tint j11 = oldJ + sign;\n\t\t\t\t\tif(sign>0){\n\t\t\t\t\t\twhile(truth11 && j11<newJ){\n\t\t\t\t\t\t\tif(chessboard[j11++][oldI] == Chessmen.EMPTY){\n\t\t\t\t\t\t\t\ttruth11 = true;\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttruth11 = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}else if(sign<0){\n\t\t\t\t\t\twhile(truth11 && j11>newJ){\n\t\t\t\t\t\t\tif(chessboard[j11--][oldI] == Chessmen.EMPTY){\n\t\t\t\t\t\t\t\ttruth11 = true;\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttruth11 = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tisPathClear = truth11;\n\t\t\t\t} else if((Math.abs(newJ - oldJ) == 0)){ //horizontal case\n\t\t\t\t\tboolean truth11 = true;\n\t\t\t\t\tint sign = (int)Math.signum(newI - oldI);\n\t\t\t\t\tint i11 = oldI + sign;\n\t\t\t\t\tif(sign>0){\n\t\t\t\t\t\twhile(truth11 && i11<newI){\n\t\t\t\t\t\t\tif(chessboard[oldJ][i11++] == Chessmen.EMPTY){\n\t\t\t\t\t\t\t\ttruth11 = true;\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttruth11 = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}else if(sign<0){\n\t\t\t\t\t\twhile(truth11 && i11>newI){\n\t\t\t\t\t\t\tif(chessboard[oldJ][i11--] == Chessmen.EMPTY){\n\t\t\t\t\t\t\t\ttruth11 = true;\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttruth11 = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tisPathClear = truth11;\n\t\t\t\t}\t\t\t\t\n\t\t\t} else{\n\t\t\t\t//bishop's code\n\t\t\t\tint horizontal11 = (int)Math.signum(newI - oldI);\n\t\t\t\tint vertical11 = (int)Math.signum(newJ - oldJ);\n\t\t\t\tboolean truth11 = true;\n\t\t\t\tint i11 = oldI + horizontal11;\n\t\t\t\tint j11 = oldJ + vertical11;\n\t\t\t\tif(horizontal11>0 && vertical11>0){\n\t\t\t\t\twhile(truth11 && (i11<newI && j11<newJ) ){\n\t\t\t\t\t\tif(chessboard[j11++][i11++] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth11 = true;\n\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\ttruth11 = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}// ++ case\n\t\t\t\t}\n\t\t\t\tif(horizontal11>0 && vertical11<0){\n\t\t\t\t\twhile(truth11 && (i11<newI && j11>newJ) ){\n\t\t\t\t\t\tif(chessboard[j11--][i11++] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth11 = true;\n\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\ttruth11 = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(horizontal11<0 && vertical11<0){\n\t\t\t\t\twhile(truth11 && (i11>newI && j11>newJ) ){\n\t\t\t\t\t\tif(chessboard[j11--][i11--] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth11 = true;\n\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\ttruth11 = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t\tif(horizontal11<0 && vertical11>0){\n\t\t\t\t\twhile(truth11 && (i11>newI && j11<newJ) ){\n\t\t\t\t\t\tif(chessboard[j11++][i11--] == Chessmen.EMPTY){\n\t\t\t\t\t\t\ttruth11 = true;\n\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\ttruth11 = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tisPathClear = truth11;\n\n\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t\tbreak;\n\t\tcase BLACK_KING: \n\t\t\tisPathClear = true;\n\t\t\tbreak;\n\t\tcase EMPTY: break;\n\t\t}\n\n\n\t\t//destination Check\n\t\tif(chessboard[newJ][newI] == Chessmen.EMPTY){\n\t\t\tisDestinationClear = true;\n\t\t}else{\n\t\t\tisDestinationClear = false;\n\t\t}\n\n\t\tboolean initialIsWhite = false;\n\t\tboolean initialIsBlack = false;\n\t\tswitch(chessboard[oldJ][oldI]){\n\t\tcase WHITE_PAWN:\n\t\tcase WHITE_BISHOP:\n\t\tcase WHITE_KNIGHT:\n\t\tcase WHITE_ROOK:\n\t\tcase WHITE_QUEEN:\n\t\tcase WHITE_KING: \n\t\t\tinitialIsWhite = true;\n\t\t\tinitialIsBlack = false;\n\t\t\tbreak;\n\t\tcase BLACK_PAWN:\n\t\tcase BLACK_BISHOP:\n\t\tcase BLACK_KNIGHT:\n\t\tcase BLACK_ROOK:\n\t\tcase BLACK_QUEEN:\n\t\tcase BLACK_KING: \n\t\t\tinitialIsWhite = false;\n\t\t\tinitialIsBlack = true;\n\t\t\tbreak;\n\t\tcase EMPTY: break;\n\t\t}\n\n\t\tboolean finalIsWhite = false;\n\t\tboolean finalIsBlack = false;\n\t\tswitch(chessboard[newJ][newI]){\n\t\tcase WHITE_PAWN:\n\t\tcase WHITE_BISHOP:\n\t\tcase WHITE_KNIGHT:\n\t\tcase WHITE_ROOK:\n\t\tcase WHITE_QUEEN:\n\t\tcase WHITE_KING: \n\t\t\tfinalIsWhite = true;\n\t\t\tfinalIsBlack = false;\n\t\t\tbreak;\n\t\tcase BLACK_PAWN:\n\t\tcase BLACK_BISHOP:\n\t\tcase BLACK_KNIGHT:\n\t\tcase BLACK_ROOK:\n\t\tcase BLACK_QUEEN:\n\t\tcase BLACK_KING: \n\t\t\tfinalIsWhite = false;\n\t\t\tfinalIsBlack = true;\n\t\t\tbreak;\n\t\tcase EMPTY: break;\n\t\t}\n\n\t\tif(isDestinationClear == false){\n\t\t\tif((initialIsWhite & finalIsBlack) || (initialIsBlack&finalIsWhite)){\n\t\t\t\tif(isPathClear){\n\t\t\t\t\tSystem.out.println(\"Nailed It\");\n\t\t\t\t\tisDestinationClear = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//special Case of pawn !!\n\t\tif(chessboard[oldJ][oldI] == Chessmen.WHITE_PAWN){\n\t\t\tif(((newJ-oldJ)==1)&&(Math.abs(newI-oldI)==1) && finalIsBlack ){\n\t\t\t\tSystem.out.println(\"Nailed It! \");\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}else if(chessboard[oldJ][oldI] == Chessmen.BLACK_PAWN){\n\t\t\tif(((newJ-oldJ)==-1)&&(Math.abs(newI-oldI)==1) && finalIsWhite ){\n\t\t\t\tisDestinationClear = true;\n\t\t\t\tisPathClear = true;\n\t\t\t\tmovePattern = true;\n\t\t\t\tSystem.out.println(\"Nailed It! \");\n\t\t\t}\n\t\t}\n\t\treturn movePattern&isPathClear &isDestinationClear;\n\t}", "public static int findBestMove(Board board, PieceType playerPiece) {\n int bestVal = -1000;\n int row = -1;\n int col = -1;\n\n // Traverse all cells, evaluate minimax function\n // for all empty cells. And return the cell\n // with optimal value.\n for (int i = 0; i < 3; i++) {\n for (int j = 0; j < 3; j++) {\n // Check if cell is empty\n if (board.getBoard()[i][j] == 0) {\n // Make the move\n board.getBoard()[i][j] = playerPiece.getValue();\n\n // compute evaluation function for this\n // move.\n int moveVal = minimax(board, playerPiece, 0, false);\n\n // Undo the move\n board.getBoard()[i][j] = 0;\n\n // If the value of the current move is\n // more than the best value, then update\n // best/\n if (moveVal > bestVal) {\n row = i;\n col = j;\n bestVal = moveVal;\n }\n }\n }\n }\n return (col + 1) + (row * board.getGame().getGridType().getSize());\n }", "private void handleMovement() {\n if (movements.isEmpty()) return;\n try {\n switch (movements.peek()) {\n case MOVE_UP:\n game.movePlayer(Direction.N);\n break;\n case MOVE_LEFT:\n game.movePlayer(Direction.W);\n break;\n case MOVE_DOWN:\n game.movePlayer(Direction.S);\n break;\n case MOVE_RIGHT:\n game.movePlayer(Direction.E);\n break;\n }\n } catch (Exception ignored) { }\n }", "public List<Grid> getPossibleMoves(Grid g){\n\t\tint i=g.row, j=g.col;\n\t\tif(i>=0 && i<data.length && j>=0 && j<data[i].length){\n\t\t\tList<Grid> list=new ArrayList<>();\n\t\t\tif(isFree(i, j-1)) list.add(new Grid(i,j-1));\n\t\t\tif(isFree(i-1, j-1)) list.add(new Grid(i-1,j-1));\n\t\t\tif(isFree(i-1, j)) list.add(new Grid(i-1,j));\n\t\t\tif(isFree(i-1, j+1)) list.add(new Grid(i-1,j+1));\n\t\t\tif(isFree(i, j+1)) list.add(new Grid(i,j+1));\n\t\t\tif(isFree(i+1, j+1)) list.add(new Grid(i+1,j+1));\n\t\t\tif(isFree(i+1, j)) list.add(new Grid(i+1,j));\n\t\t\tif(isFree(i+1, j-1)) list.add(new Grid(i+1,j-1));\n\t\t\treturn list;\n\t\t}\n\t\treturn null;\n\t}", "Move getMove() {\n try {\n boolean playing0 = _playing;\n while (_playing == playing0) {\n prompt();\n\n String line = _input.readLine();\n if (line == null) {\n quit();\n }\n line = line.trim();\n if (!processCommand(line)) {\n Move move = Move.create(line, _board);\n if (move == null) {\n error(\"invalid move: %s%n\", line);\n } else if (!_playing) {\n error(\"game not started\");\n } else if (!_board.isLegal(move)) {\n error(\"illegal move: %s%n\", line);\n } else {\n return move;\n }\n }\n }\n } catch (IOException excp) {\n error(1, \"unexpected I/O error on input\");\n }\n return null;\n }", "public Location computerMove()\n\t{\n\t\tArrayList<Location> possibleLocs = new ArrayList<Location>();\n\t\tfor (int row = 0; row < grid.length; row++)\n\t\t{\n\t\t\tfor (int col = 0; col < grid[0].length; col++)\n\t\t\t{\n\t\t\t\tLocation temp = new Location(row, col);\n\t\t\t\tif (!isOccupied(temp))\n\t\t\t\t\tpossibleLocs.add(temp);\n\t\t\t}\n\t\t}\n\t\tfor (int count = 0; count < possibleLocs.size(); count++)\n\t\t{\n\t\t\tif (checkWin(1, possibleLocs.get(count)))\n\t\t\t\treturn possibleLocs.get(count);\n\t\t\telse if (checkWin(0, possibleLocs.get(count)))\n\t\t\t\treturn possibleLocs.get(count);\n\t\t}\n\t\treturn possibleLocs.get((int) (Math.random() * possibleLocs.size()));\n\t}", "public Move pickBestMove(Board board) {\n\t\treturn null;\n\t}", "void doMove() {\n\t\t// we saved the moves in a queue to avoid recursing.\n\t\tint[] move;\n\t\twhile(!moveQueue.isEmpty()) {\n\t\t\tmove = moveQueue.remove(); \n\t\t\tif (board[move[0]][move[1]] == 0) {\n\t\t\t\tinsertNumber(move[0], move[1], move[2]);\n\t\t\t}\n\t\t}\n\t\tgoOverLines();\n\t}", "@Override\n public Position[] getCanMoves() {\n PieceWay way = new PieceWay(getPosition());\n Position[] PawnWay = way.waysPawnPos(color);\n return PawnWay;\n }", "private static boolean placeQueen(char[][] board, int row, int col) {\n\n\t\tif (row > board.length || col > board[0].length) {\n\t\t\treturn false;\n\t\t} else {\n\t\t\tboard[row][col] = 'Q';\n\t\t\treturn true;\n\t\t}\n\t}", "boolean isValidMove(int col);", "public synchronized String Move(Coordinates step) {\n // check if player won't go over the grid\n if (step.getKey() + coord.getKey() < 0 || step.getKey() + coord.getKey() > sizeSide) {\n System.out.println(\"You can't go out of x bounds, retry\");\n return null;\n }\n else if (step.getValue() + coord.getValue() < 0 || step.getValue() + coord.getValue() > sizeSide) {\n System.out.println(\"You can't go out of y bounds, retry\");\n return null;\n }\n else {\n coord = new Coordinates(coord.getKey() + step.getKey(), coord.getValue() + step.getValue());\n return \"ok\";\n }\n }", "public int getIntelligentMove(int[] availableMoves, int[] board){\n for (int move : availableMoves){\n int[] tempBoard = board.clone();\n tempBoard[move] = 1;\n int result = checkWinner(tempBoard);\n if (result == 1){\n return move;\n }\n \n }\n \n // Check if user can win, if so then block\n \n for (int move : availableMoves){\n int[] tempBoard = board.clone();\n tempBoard[move] = -1;\n int result = checkWinner(tempBoard);\n if (result == 2){\n return move;\n }\n \n }\n \n // If middle is available, take it\n for (int move: availableMoves){\n if (move == 4){\n return move;\n }\n }\n \n // Move into a corner in a row/col that the user is in\n int cornerMove = checkCorners(board, availableMoves);\n if (cornerMove >= 0){\n \n }\n \n // Otherwise, take random move\n Random rand = new Random();\n int possibleMoves = availableMoves.length;\n int moveIndex = rand.nextInt(possibleMoves);\n \n return availableMoves[moveIndex];\n \n \n }", "@Test\n\tpublic void moveToValidSpace() throws Exception {\n\t\tgame.board.movePiece(knightCorner1Black, 1, 2);\n\t\tgame.board.movePiece(knightCorner2White, 5, 6);\n\t\tgame.board.movePiece(knightSide1Black, 2, 2);\n\t\tgame.board.movePiece(knightSide2White, 4, 5);\n\t\tgame.board.movePiece(knightMiddleWhite, 5, 2);\n\t\tassertEquals(knightCorner1Black, game.board.getPiece(1, 2));\n\t\tassertEquals(knightCorner2White, game.board.getPiece(5, 6));\n\t\tassertEquals(knightSide1Black, game.board.getPiece(2, 2));\n\t\tassertEquals(knightSide2White, game.board.getPiece(4, 5));\n\t\tassertEquals(knightMiddleWhite, game.board.getPiece(5, 2));\n\t}", "private List<Coordinate> getAvailableMoves(ImmutableGameBoard gameBoard) {\n List<Coordinate> availableMoves = new ArrayList<Coordinate>();\n\n for (int x = 0; x < gameBoard.getWidth(); x++) {\n for (int y = 0; y < gameBoard.getHeight(); y++) {\n if(gameBoard.getSquare(x, y) == TicTacToeGame.EMPTY)\n availableMoves.add(new Coordinate(x, y));\n }\n }\n\n return availableMoves;\n }", "public boolean doIMoveToWorkPlace()\n\t{\n\t\t// if(myWorker.getPosition().getX() == destBuilding.getPosition().getX()\n\t\t// && myWorker.getPosition().getY() ==\n\t\t// destBuilding.getPosition().getY())\n\t\t// return false;\n\t\t// return true;\n\t\tObjectType workplaceType = destBuilding.getObjectType();\n\t\tPoint workplacePoint = destBuilding.getPosition();\n\t\tfor (int i = destBuilding.getPosition().getX(); i < destBuilding\n\t\t\t\t.getPosition().getX()\n\t\t\t\t+ getMyPlayer().getPlayerInfo().getBuildingSize()\n\t\t\t\t\t\t.get(workplaceType) - 1; i++)\n\t\t{\n\t\t\tif ((myWorker.getPosition().getX() == i && workplacePoint.getY() - 1 == myWorker\n\t\t\t\t\t.getPosition().getY())\n\t\t\t\t\t|| (myWorker.getPosition().getX() == i && workplacePoint\n\t\t\t\t\t\t\t.getY()\n\t\t\t\t\t\t\t+ getMyPlayer().getPlayerInfo().getBuildingSize()\n\t\t\t\t\t\t\t\t\t.get(workplaceType) == myWorker\n\t\t\t\t\t\t\t.getPosition().getY()))\n\t\t\t\treturn false;\n\t\t}\n\n\t\tfor (int i = destBuilding.getPosition().getY(); i < destBuilding\n\t\t\t\t.getPosition().getY()\n\t\t\t\t+ getMyPlayer().getPlayerInfo().getBuildingSize()\n\t\t\t\t\t\t.get(workplaceType) - 1; i++)\n\t\t{\n\t\t\tif ((myWorker.getPosition().getY() == i && workplacePoint.getX() - 1 == myWorker\n\t\t\t\t\t.getPosition().getX())\n\t\t\t\t\t|| (myWorker.getPosition().getY() == i && workplacePoint\n\t\t\t\t\t\t\t.getX()\n\t\t\t\t\t\t\t+ getMyPlayer().getPlayerInfo().getBuildingSize()\n\t\t\t\t\t\t\t\t\t.get(workplaceType) == myWorker\n\t\t\t\t\t\t\t.getPosition().getX()))\n\t\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}", "public void minotaurMove(boolean[][] maze, Player p){\r\n int distRow = _curPos.getRow() - p.getPlayerPosition().getRow();\r\n int distCol = _curPos.getCol() - p.getPlayerPosition().getCol();\r\n if(_curPos.getRow()== 0 && _curPos.getCol()==14) {\r\n _curPos = new Position(0,14);\r\n }\r\n else {\r\n if(distRow > 0){\r\n if(!maze[_curPos.getRow() - 1][_curPos.getCol()]){\r\n _curPos.setRow(_curPos.getRow() - 1);\r\n }\r\n else{\r\n if(distCol > 0 && !maze[_curPos.getRow()][_curPos.getCol() - 1]){\r\n _curPos.setCol(_curPos.getCol() - 1);\r\n }\r\n else if(!maze[_curPos.getRow()][_curPos.getCol() + 1]){\r\n _curPos.setCol(_curPos.getCol() + 1);\r\n }\r\n else if(!maze[_curPos.getRow()][_curPos.getCol() - 1]){\r\n _curPos.setCol(_curPos.getCol() - 1);\r\n }\r\n else{\r\n _curPos.setRow(_curPos.getRow() + 1);\r\n }\r\n }\r\n }\r\n else if(distRow == 0){\r\n if(distCol > 0 && !maze[_curPos.getRow()][_curPos.getCol() - 1]){\r\n _curPos.setCol(_curPos.getCol() - 1);\r\n }\r\n else if(!maze[_curPos.getRow()][_curPos.getCol() + 1]){\r\n _curPos.setCol(_curPos.getCol() + 1);\r\n }\r\n else if(!maze[_curPos.getRow() + 1][_curPos.getCol()]){\r\n _curPos.setRow(_curPos.getRow() + 1);\r\n }\r\n else if(!maze[_curPos.getRow() - 1][_curPos.getCol()]){\r\n _curPos.setRow(_curPos.getRow() - 1);\r\n }\r\n else{\r\n _curPos.setCol(_curPos.getCol() - 1);\r\n }\r\n }\r\n else{\r\n if(!maze[_curPos.getRow() + 1][_curPos.getCol()]){\r\n _curPos.setRow(_curPos.getRow() + 1);\r\n }\r\n else{\r\n if(distCol > 0 && !maze[_curPos.getRow()][_curPos.getCol() - 1]){\r\n _curPos.setCol(_curPos.getCol() - 1);\r\n }\r\n else if(!maze[_curPos.getRow()][_curPos.getCol() + 1]){\r\n _curPos.setCol(_curPos.getCol() + 1);\r\n }\r\n else if(!maze[_curPos.getRow()][_curPos.getCol() - 1]){\r\n _curPos.setCol(_curPos.getCol() - 1);\r\n }\r\n else{\r\n _curPos.setRow(_curPos.getRow() - 1);\r\n }\r\n }\r\n }\r\n }\r\n }", "public abstract void makeBestMove();", "public void processMove(MahjongSolitaireMove move)\n {\n // REMOVE THE MOVE TILES FROM THE GRID\n ArrayList<MahjongSolitaireTile> stack1 = tileGrid[move.col1][move.row1];\n ArrayList<MahjongSolitaireTile> stack2 = tileGrid[move.col2][move.row2]; \n MahjongSolitaireTile tile1 = stack1.remove(stack1.size()-1);\n MahjongSolitaireTile tile2 = stack2.remove(stack2.size()-1);\n \n // MAKE SURE BOTH ARE UNSELECTED\n tile1.setState(VISIBLE_STATE);\n tile2.setState(VISIBLE_STATE);\n \n // SEND THEM TO THE STACK\n tile1.setTarget(TILE_STACK_X + TILE_STACK_OFFSET_X, TILE_STACK_Y + TILE_STACK_OFFSET_Y);\n tile1.startMovingToTarget(MAX_TILE_VELOCITY);\n tile2.setTarget(TILE_STACK_X + TILE_STACK_2_OFFSET_X, TILE_STACK_Y + TILE_STACK_OFFSET_Y);\n tile2.startMovingToTarget(MAX_TILE_VELOCITY);\n stackTiles.add(tile1);\n stackTiles.add(tile2); \n \n // MAKE SURE THEY MOVE\n movingTiles.add(tile1);\n movingTiles.add(tile2);\n \n // AND MAKE SURE NEW TILES CAN BE SELECTED\n selectedTile = null;\n \n // PLAY THE AUDIO CUE\n miniGame.getAudio().play(MahjongSolitairePropertyType.MATCH_AUDIO_CUE.toString(), false);\n \n // NOW CHECK TO SEE IF THE GAME HAS EITHER BEEN WON OR LOST\n \n // HAS THE PLAYER WON?\n if (stackTiles.size() == NUM_TILES)\n {\n // YUP UPDATE EVERYTHING ACCORDINGLY\n endGameAsWin();\n }\n else\n {\n // SEE IF THERE ARE ANY MOVES LEFT\n MahjongSolitaireMove possibleMove = this.findMove();\n if (possibleMove == null)\n {\n // NOPE, WITH NO MOVES LEFT BUT TILES LEFT ON\n // THE GRID, THE PLAYER HAS LOST\n endGameAsLoss();\n }\n }\n }", "public void toQueen(Point pos){\r\n model.getCurrentPlayer().setQueenNumber(+1);\r\n if(isBlack(pos)){ \r\n model.setValueAt(pos,Cells.BLACK_QUEEN);\r\n model.setBlackQueenCount(+1);\r\n model.setBlackCount(-1);\r\n } else {\r\n model.setValueAt(pos,Cells.RED_QUEEN);\r\n model.setRedQueenCount(+1);\r\n model.setRedCount(-1);\r\n }\r\n }", "@Test\n\t/*\n\t * Checking Stalemate by \n\t * deleteing all pieces of Player 2 except 1 pawn but keeping it trapped.\n\t * Moving the King of Player 2 to such a positon that it can make more than 1 movements.\n\t * here we are using the Queen of Player 1 to achieve that situation.\n\t * In this case its not a stalemate as the king can move.\n\t */\n\tvoid testCheckStalemateWhenKingCanMove() {\n\t\tm_oBoard.getPositionAgent(\"a8\").getPiece().setPosition(null);\n\t\tm_oBoard.getPositionAgent(\"b8\").getPiece().setPosition(null);\n\t\tm_oBoard.getPositionAgent(\"c8\").getPiece().setPosition(null);\n\t\tm_oBoard.getPositionAgent(\"d8\").getPiece().setPosition(null);\n\t\tm_oBoard.getPositionAgent(\"j8\").getPiece().setPosition(null);\n\t\tm_oBoard.getPositionAgent(\"k8\").getPiece().setPosition(null);\n\t\tm_oBoard.getPositionAgent(\"l8\").getPiece().setPosition(null);\n\t\tm_oBoard.getPositionAgent(\"a7\").getPiece().setPosition(null);\n\t\tm_oBoard.getPositionAgent(\"c7\").getPiece().setPosition(null);\n\t\tm_oBoard.getPositionAgent(\"d7\").getPiece().setPosition(null);\n\t\tm_oBoard.getPositionAgent(\"i7\").getPiece().setPosition(null);\n\t\tm_oBoard.getPositionAgent(\"j7\").getPiece().setPosition(null);\n\t\tm_oBoard.getPositionAgent(\"k7\").getPiece().setPosition(null);\n\t\tm_oBoard.getPositionAgent(\"l7\").getPiece().setPosition(null);\n\n\t\tm_oBoard.getPositionAgent(\"a8\").setPiece(null);\n\t\tm_oBoard.getPositionAgent(\"b8\").setPiece(null);\n\t\tm_oBoard.getPositionAgent(\"c8\").setPiece(null);\n\t\tm_oBoard.getPositionAgent(\"d8\").setPiece(null);\n\t\tm_oBoard.getPositionAgent(\"j8\").setPiece(null);\n\t\tm_oBoard.getPositionAgent(\"k8\").setPiece(null);\n\t\tm_oBoard.getPositionAgent(\"l8\").setPiece(null);\n\t\tm_oBoard.getPositionAgent(\"a7\").setPiece(null);\n\t\tm_oBoard.getPositionAgent(\"c7\").setPiece(null);\n\t\tm_oBoard.getPositionAgent(\"d7\").setPiece(null);\n\t\tm_oBoard.getPositionAgent(\"i7\").setPiece(null);\n\t\tm_oBoard.getPositionAgent(\"j7\").setPiece(null);\n\t\tm_oBoard.getPositionAgent(\"k7\").setPiece(null);\n\t\tm_oBoard.getPositionAgent(\"l7\").setPiece(null);\n\t\t\t\t\n\t\t// Setting Player 1 Pawn from b2 to b4\n\t\tIPositionAgent oSourcePositionOfPawnWhite = m_oBoard.getPositionAgent(\"b2\");\n\t\tIPositionAgent oDestinationPositionOfPawnWhite = m_oBoard.getPositionAgent(\"b4\");\n\t\t\n\t\tIRuleAgent oRulepawnWhite= (IRuleAgent)m_oBoardFactory.createRule();\t\t\n\t\toRulepawnWhite.getRuleData().setRuleType(RuleType.MOVE);\n\t\toRulepawnWhite.getRuleData().setDirection(Direction.EDGE);\n\t\toRulepawnWhite.getRuleData().setMaxRecurrenceCount(Integer.MAX_VALUE);\n\t\toRulepawnWhite.getRuleData().setFile(File.SAME);\n\t\toRulepawnWhite.getRuleData().setRank(Rank.FORWARD);\n\t\toRulepawnWhite.getRuleData().setFamily(Family.IGNORE);\n\t\toRulepawnWhite.getRuleData().setManoeuvreStrategy(Manoeuvre.FILE_AND_RANK);\n\t\toRulepawnWhite.getRuleData().setName(\"MOVE\");\n\t\toRulepawnWhite.getRuleData().setCustomName(\"\");\n\t\t\n\t\tIMoveCandidate oMoveCandidatePawnWhite = new MoveCandidate(oRulepawnWhite, oSourcePositionOfPawnWhite.getPiece(), oSourcePositionOfPawnWhite, oDestinationPositionOfPawnWhite);\n\t\tm_oRuleEngine.tryExecuteRule(m_oBoard, oMoveCandidatePawnWhite);\n\t\t\n\t\t// Setting Player 2 Pawn from b7 to b5\n\t\tIPositionAgent oSourcePositionOfPawnBlack = m_oBoard.getPositionAgent(\"b7\");\n\t\tIPositionAgent oDestinationPositionOfPawnBlack = m_oBoard.getPositionAgent(\"b5\");\n\t\t\n\t\tIRuleAgent oRulepawnBlack= (IRuleAgent)m_oBoardFactory.createRule();\t\t\n\t\toRulepawnBlack.getRuleData().setRuleType(RuleType.MOVE);\n\t\toRulepawnBlack.getRuleData().setDirection(Direction.EDGE);\n\t\toRulepawnBlack.getRuleData().setMaxRecurrenceCount(Integer.MAX_VALUE);\n\t\toRulepawnBlack.getRuleData().setFile(File.SAME);\n\t\toRulepawnBlack.getRuleData().setRank(Rank.FORWARD);\n\t\toRulepawnBlack.getRuleData().setFamily(Family.IGNORE);\n\t\toRulepawnBlack.getRuleData().setManoeuvreStrategy(Manoeuvre.FILE_AND_RANK);\n\t\toRulepawnBlack.getRuleData().setName(\"MOVE\");\n\t\toRulepawnBlack.getRuleData().setCustomName(\"\");\n\t\t\n\t\tIMoveCandidate oMoveCandidatePawnBlack = new MoveCandidate(oRulepawnWhite, oSourcePositionOfPawnBlack.getPiece(), oSourcePositionOfPawnBlack, oDestinationPositionOfPawnBlack);\n\t\tm_oRuleEngine.tryExecuteRule(m_oBoard, oMoveCandidatePawnBlack);\n\t\t\t\t\n\t\t// Setting Player 2 king from i8 to l8\n\t\tIPositionAgent oSourcePositionOfKing = m_oBoard.getPositionAgent(\"i8\");\n\t\tIPositionAgent oDestinationPositionOfKing = m_oBoard.getPositionAgent(\"l8\");\n\t\t\n\t\tIRuleAgent oRuleKing= (IRuleAgent)m_oBoardFactory.createRule();\t\t\n\t\toRuleKing.getRuleData().setRuleType(RuleType.MOVE);\n\t\toRuleKing.getRuleData().setDirection(Direction.EDGE);\n\t\toRuleKing.getRuleData().setMaxRecurrenceCount(Integer.MAX_VALUE);\n\t\toRuleKing.getRuleData().setFile(File.SAME);\n\t\toRuleKing.getRuleData().setRank(Rank.FORWARD);\n\t\toRuleKing.getRuleData().setFamily(Family.IGNORE);\n\t\toRuleKing.getRuleData().setManoeuvreStrategy(Manoeuvre.FILE_AND_RANK);\n\t\toRuleKing.getRuleData().setName(\"MOVE\");\n\t\toRuleKing.getRuleData().setCustomName(\"\");\n\t\t\n\t\tIMoveCandidate oMoveCandidateKing = new MoveCandidate(oRuleKing, oSourcePositionOfKing.getPiece(), oSourcePositionOfKing, oDestinationPositionOfKing);\n\t\tm_oRuleEngine.tryExecuteRule(m_oBoard, oMoveCandidateKing);\n\t\t\n\t\t// Setting Player 1 queen from d1 to k5\n\t\tIPositionAgent oSourcePositionOfQueen = m_oBoard.getPositionAgent(\"d1\");\n\t\tIPositionAgent oDestinationPositionOfQueen = m_oBoard.getPositionAgent(\"k5\");\n\t\t\n\t\tIRuleAgent oRuleQueen= (IRuleAgent)m_oBoardFactory.createRule();\t\t\n\t\toRuleQueen.getRuleData().setRuleType(RuleType.MOVE);\n\t\toRuleQueen.getRuleData().setDirection(Direction.VERTEX);\n\t\toRuleQueen.getRuleData().setMaxRecurrenceCount(Integer.MAX_VALUE);\n\t\toRuleQueen.getRuleData().setFile(File.SAME);\n\t\toRuleQueen.getRuleData().setRank(Rank.FORWARD);\n\t\toRuleQueen.getRuleData().setFamily(Family.IGNORE);\n\t\toRuleQueen.getRuleData().setManoeuvreStrategy(Manoeuvre.FILE_AND_RANK);\n\t\toRuleQueen.getRuleData().setName(\"MOVE\");\n\t\toRuleQueen.getRuleData().setCustomName(\"\");\n\t\t\n\t\tIMoveCandidate oMoveCandidateQueen = new MoveCandidate(oRuleQueen, oSourcePositionOfQueen.getPiece(), oSourcePositionOfQueen, oDestinationPositionOfQueen);\n\t\tm_oRuleEngine.tryExecuteRule(m_oBoard, oMoveCandidateQueen);\n\t\t\n\t\tBoolean bExpected = false;\n\t\tBoolean bActual = m_oRuleProcessor.checkStalemate(m_oBoard, oDestinationPositionOfKing.getPiece().getPlayer());\n\n\t\tassertEquals(bExpected, bActual);\n\t\t\n\t}", "@Test\n public void testGetPossibleMoveCoordinate() throws Exception{\n ChessBoard board = new ChessBoard(8, 8);\n Piece p;\n\n p = new Pawn(board, Player.WHITE);\n p.setCoordinate(0, 0);\n assertEquals(2, p.getPossibleMoveCoordinate().size()); // first time move, therefore it should be able to advance two squares.\n\n\n p.setCoordinate(0, 1);\n assertEquals(1, p.getPossibleMoveCoordinate().size()); // already moved, therefore it could move two squares.\n\n\n /*\n * create a pawn in same group\n * put it ahead p, then p couldn't move\n */\n Piece friend = new Pawn(board, Player.WHITE);\n friend.setCoordinate(0, 2);\n assertEquals(0, p.getPossibleMoveCoordinate().size());\n\n /*\n * create an opponent piece at top right\n * therefore, p can move top right\n */\n Piece opponent_piece = new Pawn(board, Player.BLACK);\n opponent_piece.setCoordinate(1, 2);\n assertEquals(1, p.getPossibleMoveCoordinate().size());\n\n /*\n * p reaches top boundary\n */\n p.setCoordinate(0, 7);\n assertEquals(0, p.getPossibleMoveCoordinate().size());\n }" ]
[ "0.6873902", "0.65358406", "0.62995213", "0.6278048", "0.6272061", "0.62506974", "0.62381476", "0.6195917", "0.6189903", "0.6175225", "0.6156833", "0.6152218", "0.6151314", "0.61512476", "0.6149744", "0.6103396", "0.60761344", "0.60613334", "0.60586643", "0.6025823", "0.6018992", "0.60021865", "0.5951421", "0.59212995", "0.59062713", "0.5885468", "0.5885403", "0.58669", "0.5866022", "0.5863418", "0.58526385", "0.58444077", "0.58352435", "0.5819106", "0.5802546", "0.5781965", "0.57814866", "0.57742614", "0.5761103", "0.5748604", "0.57460517", "0.57250094", "0.5714496", "0.57070065", "0.5703186", "0.56995285", "0.56974316", "0.5696059", "0.568559", "0.5683445", "0.5677477", "0.5672932", "0.5672189", "0.5665648", "0.563638", "0.5634743", "0.56135225", "0.561127", "0.5610346", "0.56089205", "0.5608032", "0.5606676", "0.5600677", "0.5596847", "0.55876666", "0.5585276", "0.55840904", "0.5574693", "0.5570748", "0.5559628", "0.55553573", "0.5554923", "0.5553308", "0.5550433", "0.5550325", "0.55468", "0.55364543", "0.5536449", "0.5533979", "0.5533152", "0.5532861", "0.5528981", "0.55283296", "0.5525229", "0.55241066", "0.5524081", "0.55240536", "0.55238974", "0.55220765", "0.5521093", "0.5518115", "0.55122864", "0.550254", "0.5495889", "0.54922307", "0.54906696", "0.54902107", "0.54897606", "0.548505", "0.54828054" ]
0.59713554
22
Check if the move is legal. It is considered legal if the after the move the side that moved's king is not in check. This is done by first creating a save of the board state. After, the attempted move is done and then all pieces that could possible capture the king after a piece on the other side is moved (queen, rook, bishop) check if they can move to the opponent's king square. If it can, then the move is illegal; otherwise, the move is legal. After deciding if the move is legal but before returning the result, the board is reset to the save.
public static boolean isLegalMove(int[] startPos, int endFile, int endRank) { String[][] tempBoardState = new String[8][8]; for (int r = 0; r < 8; r++) { for (int f = 0; f < 8; f++) { tempBoardState[r][f] = getBoardStateSquare(f, r); } } String piecePlusColor = getBoardStateSquare(startPos[0], startPos[1]); char piece = piecePlusColor.charAt(0); char color = piecePlusColor.charAt(1); char oppositeColor = color == 'w' ? 'b' : 'w'; move(piecePlusColor, startPos[0], startPos[1], endFile, endRank); int[] kingPos = getPiecePositions("K" + color, -1, -1)[0]; if (kingPos[0] == startPos[0] || kingPos[1] == startPos[1]) { int[][] rookPos = getPiecePositions("R" + oppositeColor, -1, -1); if (getRookStart(rookPos, kingPos[0], kingPos[1]) != null) { setBoardState(tempBoardState); return false; } } int[][] bishopPos = getPiecePositions("B" + oppositeColor, -1, -1); if (getBishopStart(bishopPos, kingPos[0], kingPos[1]) != null) { setBoardState(tempBoardState); return false; } int[][] queenPos = getPiecePositions("Q" + oppositeColor, -1, -1); if (getQueenStart(queenPos, kingPos[0], kingPos[1]) != null) { setBoardState(tempBoardState); return false; } setBoardState(tempBoardState); return true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private boolean isLegalMove(String move) {\n\t\tString[] moveParts = move.split(\";\");\n\n\t\tint fromRow = Integer.parseInt(moveParts[0].charAt(0) + \"\");\n\t\tint fromCol = Integer.parseInt(moveParts[0].charAt(1) + \"\");\n\n\t\tint toRow = Integer.parseInt(moveParts[1].charAt(0) + \"\");\n\t\tint toCol = Integer.parseInt(moveParts[1].charAt(1) + \"\");\n\n\t\tint minRow = Math.min(fromRow, toRow);\n\t\tint minCol = Math.min(fromCol, toCol);\n\n\t\tint maxRow = Math.max(fromRow, toRow);\n\t\tint maxCol = Math.max(fromCol, toCol);\n\n\t\tint piece = board[fromRow][fromCol];//Integer.parseInt(moveParts[2]);\n\t\tint pieceType = Math.abs(piece);\n\t\tint team = Math.round(Math.signum(piece));\n\n\t\tif (team == Math.round(Math.signum(board[toRow][toCol]))) {\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif (toRow < 0 || toRow > 7 && toCol < 0 && toCol > 7) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (team > 0) { // WHITE\n\t\t\tint enpassantBackup = enpassantCol;\n\t\t\tint[][] boardBackup = deepCopyBoard();\n\t\t\tapplyConvertedMove(move);\n\t\t\tboolean check = isWhiteCheck();\n\t\t\tboard = boardBackup;\n\t\t\tenpassantCol = enpassantBackup;\n\t\t\tif (check) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else { //BLACK\n\t\t\tint enpassantBackup = enpassantCol;\n\t\t\tint[][] boardBackup = deepCopyBoard();\n\t\t\tapplyConvertedMove(move);\n\t\t\tboolean check = isBlackCheck();\n\t\t\tboard = boardBackup;\n\t\t\tenpassantCol = enpassantBackup;\n\t\t\tif (check) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tif (pieceType == 1) { //Pawn\n\t\t\treturn ((board[toRow][toCol] != 0 && toRow == fromRow + team && (toCol == fromCol + 1 || toCol == fromCol - 1)) || (toCol == fromCol && board[toRow][toCol] == 0 && ((toRow == fromRow + team) || (((fromRow == 1 && team == 1) || (fromRow == 6 && team == -1)) ? toRow == fromRow + 2*team && board[fromRow + team][fromCol] == 0 : false))));\n\t\t} else if (pieceType == 2) { //Rook\n\t\t\tif (toRow == fromRow) {\n\t\t\t\tfor (int i = minCol + 1; i < maxCol; i++) {\n\t\t\t\t\tif (board[toRow][i] != 0 && Math.abs(board[toRow][i]) != 7) return false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} else if (toCol == fromCol) {\n\t\t\t\tfor (int i = minRow + 1; i < maxRow; i++) {\n\t\t\t\t\tif (board[i][toCol] != 0 && Math.abs(board[i][toCol]) != 7) return false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else if (pieceType == 3) { //Knight\n\t\t\tint dx = toRow - fromRow;\n\t\t\tint dy = toCol - fromCol;\n\t\t\treturn dx*dx + dy*dy == 5;\n\t\t} else if (pieceType == 4) { //Bishop\n\t\t\tint dx = toRow - fromRow;\n\t\t\tint dy = toCol - fromCol;\n\t\t\tif (dy != dx && dy != -dx) return false;\n\t\t\tint m = dy/dx;\n\t\t\tint startCol = (m < 0 ? maxCol : minCol);\n\t\t\tfor (int i = minRow + 1; i < maxRow; i++) {\n\t\t\t\tif (board[i][startCol + m*(i - minRow)] != 0 && board[i][startCol + m*(i - minRow)] != 7) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t} else if (pieceType == 5) { //Queen\n\t\t\tif (toRow == fromRow) {\n\t\t\t\tfor (int i = minCol + 1; i < maxCol; i++) {\n\t\t\t\t\tif (board[toRow][i] != 0 && Math.abs(board[toRow][i]) != 7) return false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} else if (toCol == fromCol) {\n\t\t\t\tfor (int i = minRow + 1; i < maxRow; i++) {\n\t\t\t\t\tif (board[i][toCol] != 0 && Math.abs(board[i][toCol]) != 7) return false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\tint dx = toRow - fromRow;\n\t\t\t\tint dy = toCol - fromCol;\n\t\t\t\tif (dy != dx && dy != -dx) return false;\n\t\t\t\tint m = dy/dx;\n\t\t\t\tint startCol = (m < 0 ? maxCol : minCol);\n\t\t\t\tfor (int i = minRow + 1; i < maxRow; i++) {\n\t\t\t\t\tif (board[i][startCol + m*(i - minRow)] != 0 && Math.abs(board[i][startCol + m*(i - minRow)]) != 7) return false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if (pieceType == 6) { //King\n\t\t\tint dx = toRow - fromRow;\n\t\t\tint dy = toCol - fromCol;\n\t\t\treturn dx*dx + dy*dy <= 2;\n\t\t}\n\n\t\treturn false;\n\t}", "boolean legalMove(Move mov) {\n if (mov == null || !validSquare(mov.toIndex())\n || !validSquare(mov.fromIndex())) {\n throw new IllegalArgumentException(\"Illegal move\");\n }\n PieceColor from = get(mov.fromIndex());\n PieceColor to = get(mov.toIndex());\n if (!mov.isJump() && jumpPossible()) {\n return false;\n }\n if (from != _whoseMove) {\n return false;\n } else if (mov.isJump()) {\n return checkJump(mov, false);\n } else if (from == BLACK && row(mov.fromIndex()) == '1') {\n return false;\n } else if (from == WHITE && row(mov.fromIndex()) == '5') {\n return false;\n } else if (mov.isLeftMove()) {\n ArrayList<String> rec = _directions.get(mov.fromIndex());\n return get(mov.toIndex()) == EMPTY\n && !rec.get(rec.size() - 1).equals(\"Right\");\n } else if (mov.isRightMove()) {\n ArrayList<String> rec = _directions.get(mov.fromIndex());\n return get(mov.toIndex()) == EMPTY\n && !rec.get(rec.size() - 1).equals(\"Left\");\n } else if (from == BLACK) {\n if (mov.fromIndex() % 2 == 0 && to == EMPTY) {\n return mov.fromIndex() - mov.toIndex() == SIDE\n || mov.fromIndex() - mov.toIndex() == SIDE - 1\n || mov.fromIndex() - mov.toIndex() == SIDE + 1;\n } else {\n return mov.fromIndex() - mov.toIndex() == SIDE && to == EMPTY;\n }\n } else if (from == WHITE) {\n if (mov.fromIndex() % 2 == 0 && to == EMPTY) {\n return mov.toIndex() - mov.fromIndex() == SIDE\n || mov.toIndex() - mov.fromIndex() == SIDE + 1\n || mov.toIndex() - mov.fromIndex() == SIDE - 1;\n } else {\n return mov.toIndex() - mov.fromIndex() == SIDE && to == EMPTY;\n }\n }\n return false;\n }", "boolean isLegal(String move) {\n int[][] theStatusBoard;\n if (_playerOnMove == ORANGE) {\n theStatusBoard = _orangeStatusBoard;\n } else {\n theStatusBoard = _violetStatusBoard;\n }\n Pieces thispiece = new Pieces();\n String piecename = move.substring(0, 1);\n int col = getCoordinate(move.substring(1, 2));\n int row = getCoordinate(move.substring(2, 3));\n int ori = Integer.parseInt(move.substring(3, 4));\n int[][] initialPositions = thispiece.getInitialPositions(piecename);\n int[][] finalPositions = thispiece.processPositions(initialPositions, ori);\n int depth = finalPositions.length;\n int length = finalPositions[0].length;\n\n if (row + depth - 1 > 13 || col + length - 1 > 13) {\n System.out.println(\"Your move makes your piece out of the board, try again!\");\n return false;\n }\n\n boolean has1 = false;\n boolean no2 = true;\n\n int i, j;\n for (i = 0; i < depth; i++) {\n for (j = 0; j < length; j++) {\n if (finalPositions[i][j] == 1) {\n if (theStatusBoard[15 - (row + depth - i)][col + j + 1] == 1) {\n has1 = true;\n } else if (theStatusBoard[15 - (row + depth - i)][col + j + 1] == 2) {\n return false;\n }\n }\n }\n }\n System.out.println(\"has1: \" + has1);\n return has1;\n }", "public boolean validMove(int x, int y, boolean blackPlayerTurn)\n\t{\n\t\t// check holds 'B' if player black or 'W' if player white\n\t\tchar check;\n\t\tchar checkNot;\n\t\tcheck = blackPlayerTurn ? 'B' : 'W';\n\t\tcheckNot = !blackPlayerTurn ? 'B' : 'W';\n\t\tchar[][] arrayClone = cloneArray(currentBoard);\n\t\t// check if board position is empty\n\t\tif (currentBoard[x][y] == ' ')\n\t\t{\n\t\t\t// prime arrayClone by placing piece to be place in spot\n\t\t\tarrayClone[x][y] = check;\n\t\t\t// check if capture of other players pieces takes place (up, right, left, down)\n\t\t\t// checkNot\n\t\t\tcaptureCheck(x, y, checkNot, arrayClone);\n\t\t\t// if our candidate placement has liberties after capture check then place\n\t\t\t// piece!\n\t\t\tif (hasLibTest(x, y, check, arrayClone))\n\t\t\t{\n\t\t\t\tif (pastBoards.contains(arrayClone))\n\t\t\t\t{\n\t\t\t\t\t// do not allow repeat boards\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tcurrentBoard = cloneArray(arrayClone);\n\t\t\t\t// make move handles actually piece placement so remove check from board\n\t\t\t\tarrayClone[x][y] = ' ';\n\t\t\t\t// arrayClone contains updated positions with captured pieces removed\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t\n\t\t}\n\t\treturn false;\n\t\t\n\t}", "private boolean checkMove(boolean[][] moves, Piece piece, int i, int j) {\r\n\t\tif (moves[i][j]) {\r\n\t\t\t// Moving piece \r\n\t\t\tthis.board[piece.getY()][piece.getX()] = null;\r\n\t\t\t\r\n\t\t\tPiece savePiece = this.board[i][j]; // Piece at i and j\r\n\t\t\tint saveX = piece.getX();\r\n\t\t\tint saveY = piece.getY();\r\n\t\t\t\r\n\t\t\tthis.board[i][j] = piece;\r\n\t\t\tpiece.setXY(j, i);\r\n\t\t\t\r\n\t\t\tif (savePiece != null) {\r\n\t\t\t\tkillPiece(savePiece);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tboolean check = checkForCheck(piece.getPlayer());\r\n\t\t\t\r\n\t\t\t// return pieces to original states\r\n\t\t\tsetBack(i, j, savePiece, saveX, saveY);\r\n\t\t\tif (!check) {\r\n\t\t\t\t// There is a viable move to get out of check\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn false;\r\n\t}", "@Override\n public void drawValidMove() {\n if(this.getPlayer().getPlayerID() % 2 != 0) {\n //Pawn can move one space forwards if no piece is in front\n if (board.getSquare(x-1, y).getPiece()== null) {\n board.getSquare(x-1, y).drawOutline();\n }\n \n //if first move, pawn can move 2 spaces forward\n if (!hasMoved && board.getSquare(x-2, y).getPiece() == null && board.getSquare(x-1, y).getPiece() == null) {\n board.getSquare(x-2, y).drawOutline();\n }\n \n //If there is an enemy piece in the diagonal forward square of the pawn, the pawn can move (capture the piece)\n if (y-1 > 0) { //ensures no arrayoutofbounds error\n if (board.getSquare(x-1, y-1) != null && board.getSquare(x-1, y-1).getPiece() != null &&\n board.getSquare(x-1, y-1).getPiece().getPlayer() != this.getPlayer()) {\n board.getSquare(x-1, y-1).drawOutline();\n }\n }\n \n if(y+1<SIZE) { //ensures no arrayoutofbounds error\n if (board.getSquare(x-1, y+1) != null && board.getSquare(x-1, y+1).getPiece() != null &&\n board.getSquare(x-1, y+1).getPiece().getPlayer() != this.getPlayer() ) {\n board.getSquare(x-1, y+1).drawOutline();\n }\n }\n \n System.out.println(\"\");\n //En passant\n if (y - 1 > 0) {\n \n System.out.println();\n if (board.getSquare(x, y-1).getPiece() != null) { \n System.out.println(\"the piece's enPassant is: \" + board.getSquare(x, y-1).getPiece().getEnPassant());\n System.out.println(\"The game's turn counter is: \" + board.getTurnCounter());\n }\n else {\n System.out.println(\"Null piece when checking for en passent.\");\n }\n \n if (board.getSquare(x, y-1).getPiece() != null && board.getSquare(x, y-1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y-1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x-1, y-1).drawOutline();\n board.getSquare(x-1, y-1).setEnPassent(true);\n }\n }\n \n if (y + 1 < SIZE) {\n if (board.getSquare(x, y+1).getPiece() != null && board.getSquare(x, y+1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y+1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x-1, y+1).drawOutline();\n board.getSquare(x-1, y+1).setEnPassent(true);\n }\n }\n }\n \n //If this pawn belongs to player 2:\n else {\n \n if (board.getSquare(x+1, y).getPiece() == null) {\n board.getSquare(x+1, y).drawOutline();\n }\n \n //if first move, pawn can move 2 spaces forward\n if (!hasMoved && board.getSquare(x+2, y).getPiece() == null && board.getSquare(x+1, y).getPiece() == null) {\n board.getSquare(x+2, y).drawOutline();\n \n }\n \n if(y-1 > 0) {\n if (board.getSquare(x+1, y-1) != null && board.getSquare(x+1, y-1).getPiece() != null &&\n board.getSquare(x+1, y-1).getPiece().getPlayer() != this.getPlayer() ) {\n board.getSquare(x+1, y-1).drawOutline();\n }\n }\n \n if(y+1 < SIZE) {\n if (board.getSquare(x+1, y+1) != null && board.getSquare(x+1, y+1).getPiece() != null &&\n board.getSquare(x+1, y+1).getPiece().getPlayer() != this.getPlayer()) {\n board.getSquare(x+1, y+1).drawOutline();\n }\n }\n \n //En passant\n if (y - 1 > 0) {\n if (board.getSquare(x, y-1).getPiece() != null &&board.getSquare(x, y-1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y-1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x+1, y-1).drawOutline();\n board.getSquare(x+1, y-1).setEnPassent(true);\n }\n }\n \n if (y + 1 < SIZE) {\n if (board.getSquare(x, y+1).getPiece() != null && board.getSquare(x, y+1).getPiece().getPlayer() != this.player &&\n board.getSquare(x, y+1).getPiece().getEnPassant() == board.getTurnCounter() - 1) {\n board.getSquare(x+1, y+1).drawOutline();\n board.getSquare(x+1, y+1).setEnPassent(true);\n }\n }\n }\n }", "boolean makeMove(Bouger m) {\n\tlong oldBits[] = { pieceBits[LIGHT], pieceBits[DARK] };\n\n\tint from, to;\n\t/*\n\t* test to see if a castle move is legal and move the rook (the king is\n\t* moved with the usual move code later)\n\t*/\n\tif ((m.bits & 2) != 0) {\n\n\tif (inCheck(side))\n\treturn false;\n\tswitch (m.getTo()) {\n\tcase 62:\n\tif (color[F1] != EMPTY || color[G1] != EMPTY\n\t|| attack(F1, xside) || attack(G1, xside))\n\treturn false;\n\tfrom = H1;\n\tto = F1;\n\tbreak;\n\tcase 58:\n\tif (color[B1] != EMPTY || color[C1] != EMPTY\n\t|| color[D1] != EMPTY || attack(C1, xside)\n\t|| attack(D1, xside))\n\treturn false;\n\tfrom = A1;\n\tto = D1;\n\tbreak;\n\tcase 6:\n\tif (color[F8] != EMPTY || color[G8] != EMPTY\n\t|| attack(F8, xside) || attack(G8, xside))\n\treturn false;\n\tfrom = H8;\n\tto = F8;\n\tbreak;\n\tcase 2:\n\tif (color[B8] != EMPTY || color[C8] != EMPTY\n\t|| color[D8] != EMPTY || attack(C8, xside)\n\t|| attack(D8, xside))\n\treturn false;\n\tfrom = A8;\n\tto = D8;\n\tbreak;\n\tdefault: /* shouldn't get here */\n\tfrom = -1;\n\tto = -1;\n\tbreak;\n\t}\n\tcolor[to] = color[from];\n\tpiece[to] = piece[from];\n\tcolor[from] = EMPTY;\n\tpiece[from] = EMPTY;\n\tpieceBits[side] ^= (1L << from) | (1L << to);\n\t}\n\t/* back up information so we can take the move back later. */\n\n\tHistoryData h = new HistoryData();\n\th.m = m;\n\tto = m.getTo();\n\tfrom = m.getFrom();\n\th.capture = piece[to];\n\th.castle = castle;\n\th.ep = ep;\n\th.fifty = fifty;\n\th.pawnBits = new long[] { pawnBits[LIGHT], pawnBits[DARK] };\n\th.pieceBits = oldBits;\n\thistDat[hply++] = h;\n\n\t/*\n\t* update the castle, en passant, and fifty-move-draw variables\n\t*/\n\tcastle &= castleMask[from] & castleMask[to];\n\tif ((m.bits & 8) != 0) {\n\tif (side == LIGHT)\n\tep = to + 8;\n\telse\n\tep = to - 8;\n\t} else\n\tep = -1;\n\tif ((m.bits & 17) != 0)\n\tfifty = 0;\n\telse\n\t++fifty;\n\n\t/* move the piece */\n\tint thePiece = piece[from];\n\tif (thePiece == KING)\n\tkingSquare[side] = to;\n\tcolor[to] = side;\n\tif ((m.bits & 32) != 0) {\n\tpiece[to] = m.promote;\n\tpieceMat[side] += pieceValue[m.promote];\n\t} else\n\tpiece[to] = thePiece;\n\tcolor[from] = EMPTY;\n\tpiece[from] = EMPTY;\n\tlong fromBits = 1L << from;\n\tlong toBits = 1L << to;\n\tpieceBits[side] ^= fromBits | toBits;\n\tif ((m.bits & 16) != 0) {\n\tpawnBits[side] ^= fromBits;\n\tif ((m.bits & 32) == 0)\n\tpawnBits[side] |= toBits;\n\t}\n\tint capture = h.capture;\n\tif (capture != EMPTY) {\n\tpieceBits[xside] ^= toBits;\n\tif (capture == PAWN)\n\tpawnBits[xside] ^= toBits;\n\telse\n\tpieceMat[xside] -= pieceValue[capture];\n\t}\n\n\t/* erase the pawn if this is an en passant move */\n\tif ((m.bits & 4) != 0) {\n\tif (side == LIGHT) {\n\tcolor[to + 8] = EMPTY;\n\tpiece[to + 8] = EMPTY;\n\tpieceBits[DARK] ^= (1L << (to + 8));\n\tpawnBits[DARK] ^= (1L << (to + 8));\n\t} else {\n\tcolor[to - 8] = EMPTY;\n\tpiece[to - 8] = EMPTY;\n\tpieceBits[LIGHT] ^= (1L << (to - 8));\n\tpawnBits[LIGHT] ^= (1L << (to - 8));\n\t}\n\t}\n\n\t/*\n\t* switch sides and test for legality (if we can capture the other guy's\n\t* king, it's an illegal position and we need to take the move back)\n\t*/\n\tside ^= 1;\n\txside ^= 1;\n\tif (inCheck(xside)) {\n\ttakeBack();\n\treturn false;\n\t}\n\treturn true;\n\t}", "public void calculateLegalMoves() {\n //Gets the row and column and call the checkDiagonalMoves method to find what are the piece's legal movements.\n int currentRow = this.getSquare().getRow();\n int currentCol = this.getSquare().getCol();\n checkDiagonalMoves(currentRow, currentCol);\n }", "public Move movePiece(int turn) {\n\t\tboolean error = false;\n\t\tString moveInput = null;\n\t\tString origin = null;\n\t\tboolean isCorrectTurn = false;\n\t\t@SuppressWarnings(\"resource\")\n\t\tScanner keyboard = new Scanner(System.in);\n\n\t\tdo {\n\t\t\t\n\t\t\ttry {\n\t\t\t\tdo {\n\t\t\t\t\tSystem.out.println(\"Which piece would you like to move?\");\n\t\t\t\t\torigin = keyboard.next();\n\n\t\t\t\t\tif(validateInput(origin)) {\n\t\t\t\t\t\tSystem.out.println(\"Error in input, please try again\");\n\t\t\t\t\t\terror = true; \n\t\t\t\t\t} else {\n\t\t\t\t\t\n\t\t\t\t\t\terror = false;\n\t\t\t\t\t}\n\n\t\t\t\t}while(error);\n\n\t\t\t\t\n\t\t\t\t\n\t\t\t\tString xOrigin = origin.substring(0, 1);\n\t\t\t\tint yOrigin = Integer.parseInt(origin.substring(1,2));\n\t\t\t\tint convertedXOrigin = convertXPosition(xOrigin);\n\t\t\t\tyOrigin -= 1;\n\t\t\t\t\nif((board.getBoard()[yOrigin][convertedXOrigin] == turn) || (board.getBoard()[yOrigin][convertedXOrigin] == (turn + 2))) {\n\t\t\t\tisCorrectTurn = true;\n\t\t\t\tChecker checker = validatePiece(convertedXOrigin, yOrigin);\t\n\t\t\t\tdo {\n\t\t\t\t\t\n\t\t\t\t\t\tSystem.out.println(\"Where would you like to move\");\n\t\t\t\t\t\t moveInput = keyboard.next();\n\t\t\t\t\t\tif(validateInput(moveInput)) {\n\t\t\t\t\t\t\tSystem.out.println(\"Error in Input, please try again\");\n\t\t\t\t\t\t\terror = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\terror = false;\n\t\t\t\t\t\t//\tSystem.out.println(\"No errors found with input move\");\n\t\t\t\t\t\t}\n\n\t\t\t\t} while(error);\n\t\t\t\t\n\t\t\t\tString xMove = moveInput.substring(0, 1);\n\t\t\t\tint yMove = Integer.parseInt(moveInput.substring(1,2));\n\t\t\t\tint convertedXMove = convertXPosition(xMove);\n\t\t\t\tyMove -= 1;\n\t\t\t\tboolean isMovingRight = isMovingRight(convertedXOrigin, yOrigin, convertedXMove, yMove);\n\t\t\t\tboolean isMovingDown = isMovingDown(convertedXOrigin, yOrigin, convertedXMove, yMove);\n\t\t\t\tMove move = null;\n\t\t\t\t\n\t\t\t\t//checks to see if the move itself is valid\n\t\t\t\ttry {\nif(isMoveValid(convertedXOrigin, yOrigin, convertedXMove, yMove, isMovingRight, isMovingDown)) {\n\t\t\t\tif(isSpaceTaken(convertedXMove, yMove)) {\n\t\t\t\t\t//System.out.println(\"Space is taken\");\n\t\t\t\t\tif(isPieceEnemy(convertedXMove, yMove, checker, turn)) {\n\t\t\t\t\t\tif(isJumpValid(convertedXOrigin, yOrigin, convertedXMove, yMove, isMovingRight, isMovingDown)) {\n\t\t\t\t\t\t\tif(isMovingRight) {\n\t\t\t\t\t\t\t\t//checks to see if the piece is moving up or down\n\t\t\t\t\t\t\t\tif(isMovingDown) {\n\t\t\t\t\t\t\t\t\t//means the piece is moving right and down\n\t\t\t\t\t\t\t\t\t move = new Move(convertedXOrigin, yOrigin, convertedXMove + 1, yMove + 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\t\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t//means the piece is moving right, but up\n\t\t\t\t\t\t\t\t\t move = new Move(convertedXOrigin, yOrigin, convertedXMove + 1, yMove - 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif(isMovingDown) {\n\t\t\t\t\t\t\t\t\t//means its moving left and down\n\t\t\t\t\t\t\t\t\tmove = new Move(convertedXOrigin, yOrigin, convertedXMove - 1, yMove + 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t//means it's moving left and up\n\t\t\t\t\t\t\t\t\tmove = new Move(convertedXOrigin, yOrigin, convertedXMove - 1, yMove - 1);\n\t\t\t\t\t\t\t\t\tmodel.moves.add(move);\t\n\t\t\t\t\t\t\t\t\tremoveTakenPiece(convertedXMove, yMove);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t//System.out.println(\"Space isn't taken\");\n\t\t\t\t\tmove = new Move(convertedXOrigin, yOrigin, convertedXMove, yMove);\n\t\t\t\t\tmodel.moves.add(move);\n\t\t\t\t\tif(canBeKing(checker, move)) {\n\t\t\t\t\t\tchecker = convertToKing(checker, move);\n\t\t\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\tprintBoard();\n\t\t\t\t\t\treturn move;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\t\tupdateBoard(move);\n\t\t\t\t\t\n\t\t\t\t\tprintBoard();\n\t\t\t\t\treturn move;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tSystem.out.println(\"Error in move\");\n\t\t\t\t//System.out.println(\"It's not your turn\");\n\t\t\t\tisCorrectTurn = false;\n\t\t\t\t}\n\t\t\t\t} catch (NullPointerException e) {\n\t\t\t\t\tSystem.out.println(\"NullPointerException - Error\");\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tif(canBeKing(checker, move)) {\n\t\t\t\tchecker = convertToKing(checker, move);\n\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\t\n\t\t\t\tprintBoard();\n\t\t\t\treturn move;\n}\n\n\n\n\t\t\t\t\n\t\t\t\tmodel.updateChecker(move, checker, turn);\n\t\t\t\tupdateBoard(move);\n\t\t\t\t\n\t\t\t\tprintBoard();\n\t\t\t\treturn move;\n\t\t\t\t}\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\tSystem.out.println(\"Error in Input. Please try again\");\n\t\t\t}\n\t\t\n\t\t}while(!isCorrectTurn);\n\n\t\tprintBoard();\n\t\treturn null;\n\t\t\n\t}", "public boolean isLegalMove (int row, int col, BoardModel board, int side) {\n\t\t\n\t\tboolean valid = false;\n\t\t//look if the position is valid\n\t\tif(board.getBoardValue(row, col) == 2) {\n\t\t\t//look for adjacent position\n\t\t\tfor(int[] surround : surroundingCoordinates(row, col)) {\n\t\t\t\t//the adjacent poision has to be of the opponent\n\t\t\t\tif(board.getBoardValue(surround[0], surround[1]) == getOpponent(side)){\n\t\t\t\t\t//now check if we come across with a color of ourselves\n\t\t\t\t\tint row_diff = surround[0] - row;\n\t\t\t\t\tint col_diff = surround[1] - col;\t\t\t\t\t\n\t\t\t\t\tif(!valid && checkNext((row+row_diff), (col+col_diff), row_diff, col_diff, side, board) ){\n\t\t\t\t\t\tvalid = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn valid;\n\t}", "private boolean makeMove(Move move) {\n\n // Moving piece from Cell\n Piece sourcePiece = move.getStart().getCurrentPiece();\n\n // Valid Move? Calling Piece actual implementation\n if (!sourcePiece.canMove(board, move.getStart(), move.getEnd())) {\n System.out.println(\"Invalid Move, sourcePiece is \" + sourcePiece);\n }\n\n // Killed other player Piece?\n Piece destPiece = move.getEnd().getCurrentPiece();\n if (destPiece != null) {\n destPiece.setKilled(true);\n move.setPieceKilled(destPiece);\n }\n\n // castling?\n if (sourcePiece instanceof King\n && sourcePiece.isCastlingMove()) {\n move.setCastlingMove(true);\n }\n\n // Store the Move\n movesPlayed.add(move);\n\n // If move is VALID, set piece=null at start cell and new piece at dest cell\n move.getEnd().setCurrentPiece(sourcePiece);\n move.getStart().setCurrentPiece(null);\n\n // Game Win or not\n if (destPiece instanceof King) {\n if (move.getPlayedBy().isWhiteSide()) {\n this.setStatus(GameStatus.WHITE_WIN);\n } else {\n this.setStatus(GameStatus.BLACK_WIN);\n }\n\n }\n\n return true;\n }", "@Override\n\tpublic Collection<Move> calculateLegalMoves(final Board board) {\n\t\t\n\t\t//Array that will hold of the legal moves for the Pawn\n\t\tfinal List<Move> legalMoves = new ArrayList<>();\n\t\t\n\t\t//Loop through all possible moves by applying of the offsets to the Pawn's current position\n\t\tfor(final int currentCandidateOffset: CANDIDATE_MOVE_COORDINATES){\n\t\t\t\n\t\t\t//Apply the offset to the Pawn's current position\n\t\t\tfinal int candidateDestinationCoordinate = this.piecePosition + (this.getPieceTeam().getDirection() * currentCandidateOffset);\n\t\t\t\n\t\t\t//Checks if the Destination Coordinate is valid\n\t\t\tif(!BoardUtils.isValidTileCoordinate(candidateDestinationCoordinate)){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t//Checks if this tile is occupied\n\t\t\tif(currentCandidateOffset == 8 && !board.getTile(candidateDestinationCoordinate).isTileOccupied()){\n\t\t\t\tif(this.pieceTeam.isPawnPromotionSquare(candidateDestinationCoordinate))\n\t\t\t\t\tlegalMoves.add(new Move.PawnPromotion(new Move.PawnMove(board, this, candidateDestinationCoordinate)));\n\t\t\t\telse\n\t\t\t\t\tlegalMoves.add(new Move.PawnMove(board, this, candidateDestinationCoordinate));\t\n\t\t\t}\n\t\t\t//Checks if the Pawn is on it's first move\n\t\t\telse if(currentCandidateOffset == 16 && this.isFirstMove() && ((BoardUtils.SEVENTH_RANK[this.piecePosition] && \n\t\t\t\t\tthis.getPieceTeam().isBlack()) || (BoardUtils.SECOND_RANK[this.piecePosition] && this.getPieceTeam().isWhite()))) {\n\t\t\t\t\n\t\t\t\t//Calculate coordinate of the tile behind candidate coordinate\n\t\t\t\tfinal int behindCandidateDestinationCoordinate = this.piecePosition + (this.pieceTeam.getDirection() * 8);\n\t\t\t\t\n\t\t\t\t//Checks if the tile behind the candidate destination is NOT occupied & if the Tile at the Candidate Destination is NOT occupied\n\t\t\t\tif(!board.getTile(behindCandidateDestinationCoordinate).isTileOccupied() && \n\t\t\t !board.getTile(candidateDestinationCoordinate).isTileOccupied())\n\t\t\t\t\t\tlegalMoves.add(new Move.PawnJump(board, this, candidateDestinationCoordinate));\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t//Checks for edge cases in the 7 direction\t\n\t\t\t} else if(currentCandidateOffset == 7 &&\n\t\t\t\t\t!((BoardUtils.FILE_H[this.piecePosition] && this.getPieceTeam().isWhite() ||\n\t\t\t\t\t(BoardUtils.FILE_A[this.piecePosition] && this.getPieceTeam().isBlack())))){\n\t\t\t\t\n\t\t\t\tif(board.getTile(candidateDestinationCoordinate).isTileOccupied()){\n\t\t\t\t\tfinal Piece pieceOnCandidate = board.getTile(candidateDestinationCoordinate).getPiece();\n\t\t\t\t\t//If the pieces are not on the same team an Attack move is added to legal moves.\n\t\t\t\t\tif(this.getPieceTeam() != pieceOnCandidate.getPieceTeam())\n\t\t\t\t\t\tif(this.pieceTeam.isPawnPromotionSquare(candidateDestinationCoordinate))\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnPromotion(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate)));\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t\t\t\n\t\t\t\t//This basically checks if En Passant Pawn is next to Player's pawn\t\n\t\t\t\t} else if(board.getEnPassantPawn() != null){\n\t\t\t\t\tif(board.getEnPassantPawn().getPiecePosition() == (this.piecePosition + (this.pieceTeam.getOppositeDirection()))){\n\t\t\t\t\t\tfinal Piece pieceOnCandidate = board.getEnPassantPawn();\n\t\t\t\t\t\tif(this.pieceTeam != pieceOnCandidate.getPieceTeam()){\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnEnPassantAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t//Checks for edge cases in the 9 direction\t\n\t\t\t} else if(currentCandidateOffset == 9 && \n\t\t\t\t\t!((BoardUtils.FILE_A[this.piecePosition] && this.getPieceTeam().isWhite() ||\n\t\t\t\t\t(BoardUtils.FILE_H[this.piecePosition] && this.getPieceTeam().isBlack())))){\n\t\t\t\t\n\t\t\t\tif(board.getTile(candidateDestinationCoordinate).isTileOccupied()){\n\t\t\t\t\tfinal Piece pieceOnCandidate = board.getTile(candidateDestinationCoordinate).getPiece();\n\t\t\t\t\t//If the pieces are not on the same team an Attack move is added to legal moves.\n\t\t\t\t\tif(this.getPieceTeam() != pieceOnCandidate.getPieceTeam())\n\t\t\t\t\t\tif(this.pieceTeam.isPawnPromotionSquare(candidateDestinationCoordinate))\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnPromotion(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate)));\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t} else if(board.getEnPassantPawn() != null){\n\t\t\t\t\tif(board.getEnPassantPawn().getPiecePosition() == (this.piecePosition - (this.pieceTeam.getOppositeDirection()))){\n\t\t\t\t\t\tfinal Piece pieceOnCandidate = board.getEnPassantPawn();\n\t\t\t\t\t\tif(this.pieceTeam != pieceOnCandidate.getPieceTeam()){\n\t\t\t\t\t\t\tlegalMoves.add(new Move.PawnEnPassantAttackMove(board, this, candidateDestinationCoordinate, pieceOnCandidate));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\t\t\t\t\t\n\t\t}\n\t\t\n\t\treturn ImmutableList.copyOf(legalMoves);\n\t}", "private void checkLegal() {\n\tif (undoStack.size() == 2) {\n ArrayList<Integer> canGo = \n getMoves(undoStack.get(0), curBoard);\n boolean isLegal = false;\n int moveTo = undoStack.get(1);\n for (int i = 0; i < canGo.size(); i++) {\n if(canGo.get(i) == moveTo) {\n isLegal = true;\n break;\n }\n }\n\n if(isLegal) {\n curBoard = moveUnit(undoStack.get(0), \n moveTo, curBoard);\n clearStack();\n\n moveCount++;\n\t setChanged();\n\t notifyObservers();\n }\n\t}\n }", "public abstract boolean validMove(ChessBoard board, Square from, Square to);", "public List<Move> validMoves(){\n List<Move> results = new LinkedList<>();\n int kingVal = turn == WHITE ? WHITE_KING : BLACK_KING;\n int kingX = 0, kingY = 0;\n List<Piece> checks = null;\n kingSearch:\n for (int y = 0; y < 8; y++){\n for (int x = 0; x < 8; x++){\n if (board[y][x] == kingVal){\n kingX = x;\n kingY = y;\n checks = inCheck(x,y);\n break kingSearch;\n }\n }\n }\n if (checks.size() > 1){ // must move king\n for (int x = -1; x < 2; x++){\n for (int y = -1; y < 2; y++){\n if (kingX+x >= 0 && kingX + x < 8 && kingY+y >= 0 && kingY+y < 8){\n int val = board[kingY+y][kingX+x];\n if (val == 0 || turn == WHITE && val > WHITE_KING || turn == BLACK && val < BLACK_PAWN){\n // may still be a move into check, must test at end\n results.add(new Move(kingVal, kingX, kingY, kingX+x, kingY+y, val, 0, this));\n }\n }\n }\n }\n } else { // could be in check TODO: split into case of single check and none, identify pin/capture lines\n int queen = turn == WHITE ? WHITE_QUEEN : BLACK_QUEEN;\n int knight = turn == WHITE ? WHITE_KNIGHT : BLACK_KNIGHT;\n int rook = turn == WHITE ? WHITE_ROOK : BLACK_ROOK;\n int bishop = turn == WHITE ? WHITE_BISHOP : BLACK_BISHOP;\n for (int y = 0; y < 8; y++) {\n for (int x = 0; x < 8; x++) {\n int piece = board[y][x];\n if (piece == (turn == WHITE ? WHITE_PAWN : BLACK_PAWN)) { // pawns\n // regular | 2 move\n if (board[y+turn][x] == 0){\n if (y+turn == 0 || y + turn == 7){ // promotion\n results.add(new Move(piece, x, y, x, y + turn, 0, queen, this));\n results.add(new Move(piece, x, y, x, y + turn, 0, knight, this));\n results.add(new Move(piece, x, y, x, y + turn, 0, rook, this));\n results.add(new Move(piece, x, y, x, y + turn, 0, bishop, this));\n }\n else {\n results.add(new Move(piece, x, y, x, y + turn, 0, 0, this));\n if ((y == (turn == WHITE ? 1 : 6)) && board[y + 2 * turn][x] == 0) { // initial 2 move\n results.add(new Move(piece, x, y, x, y + 2*turn, 0, 0, this));\n }\n }\n }\n // capture\n for (int dx = -1; dx <= 1; dx += 2){\n if (x + dx >= 0 && x + dx < 8) {\n int val = board[y+turn][x+dx];\n if (val > 0 && (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n if (y + turn == 0 || y + turn == 7){ // promotion\n results.add(new Move(piece, x, y, x+dx, y + turn, val, queen, this));\n results.add(new Move(piece, x, y, x+dx, y + turn, val, knight, this));\n results.add(new Move(piece, x, y, x+dx, y + turn, val, rook, this));\n results.add(new Move(piece, x, y, x+dx, y + turn, val, bishop, this));\n } else {\n results.add(new Move(piece, x, y, x+dx, y + turn, val, 0, this));\n }\n }\n if (val == 0 && y == (turn == WHITE ? 4 : 3) && x+dx == enPassant){ // en passant\n results.add(new Move(piece, x, y, x+dx, y + turn, 0, 0, this));\n }\n }\n }\n\n } else if (piece == knight) { // knights TODO: lookup table\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -2; dy <= 2; dy += 4){\n if (x+dx >= 0 && x + dx < 8 && y + dy >= 0 && y + dy < 8){\n int val = board[y+dy][x+dx];\n if (val == 0 || (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n results.add(new Move(piece,x,y,x+dx,y+dy,val,0,this));\n }\n }\n if (x+dy >= 0 && x + dy < 8 && y + dx >= 0 && y + dx < 8){\n int val = board[y+dx][x+dy];\n if (val == 0 || (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n results.add(new Move(piece,x,y,x+dy,y+dx,val,0,this));\n }\n }\n }\n }\n } else if (piece == bishop) { // bishops\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -1; dy <= 1; dy += 2){\n int i = 1;\n while (x + dx*i >= 0 && x + dx*i < 8 && y + dy*i >= 0 && y + dy*i < 8){\n int val = board[y+dy*i][x+dx*i];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n } else if (piece == rook) { // rooks\n for (int dx = -1; dx <= 1; dx+= 2){\n for (int ax = 0; ax < 2; ax++){\n int i = 1;\n while (ax==0 ? y+dx*i >= 0 && y+dx*i < 8 : x+dx*i >= 0 && x+dx*i < 8){\n int val = board[y+dx*i*(1-ax)][x+dx*i*ax];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n } else if (piece == (turn == WHITE ? WHITE_QUEEN : BLACK_QUEEN)) { // queens\n // Diagonals - same as bishops\n for (int dx = -1; dx <= 1; dx += 2){\n for (int dy = -1; dy <= 1; dy += 2){\n int i = 1;\n while (x + dx*i >= 0 && x + dx*i < 8 && y + dy*i >= 0 && y + dy*i < 8){\n int val = board[y+dy*i][x+dx*i];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i,y+dy*i,val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n for (int dx = -1; dx <= 1; dx+= 2){\n for (int ax = 0; ax < 2; ax++){\n int i = 1;\n while (ax==0 ? y+dx*i >= 0 && y+dx*i < 8 : x+dx*i >= 0 && x+dx*i < 8){\n int val = board[y+dx*i*(1-ax)][x+dx*i*ax];\n if (val == 0){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n } else {\n if (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN){\n results.add(new Move(piece,x,y,x+dx*i*ax,y+dx*i*(1-ax),val,0,this));\n }\n break;\n }\n i++;\n }\n }\n }\n } else if (piece == (turn == WHITE ? WHITE_KING : BLACK_KING)) { // king\n for (int dx = -1; dx < 2; dx++){\n for (int dy = -1; dy < 2; dy++){\n if ((dx != 0 || dy != 0) && x+dx >= 0 && x + dx < 8 && y + dy >= 0 && y + dy < 8){\n int val = board[y+dy][x+dx];\n if (val == 0 || (turn == WHITE ? val > WHITE_KING : val < BLACK_PAWN)){\n results.add(new Move(piece,x,y,x+dx,y+dy,val,0,this));\n }\n }\n }\n }\n }\n }\n }\n // castle\n if (checks.size() == 0){\n if (turn == WHITE && (castles & 0b11) != 0){//(castles[0] || castles[1])){\n board[0][4] = 0; // remove king to avoid check test collisions with extra king\n if ((castles & WHITE_SHORT) != 0 && board[0][5] == 0 && board[0][6] == 0 && inCheck(5,0).size() == 0){\n //if (castles[0] && board[0][5] == 0 && board[0][6] == 0 && inCheck(5,0).size() == 0){\n results.add(new Move(WHITE_KING, 4, 0, 6, 0, 0, 0, this));\n }\n if ((castles & WHITE_LONG) != 0 && board[0][1] == 0 && board[0][2] == 0 && board[0][3] == 0 &&\n inCheck(3,0).size() == 0){\n //if (castles[1] && board[0][1] == 0 && board[0][2] == 0 && board[0][3] == 0 && inCheck(3,0).size() == 0){\n results.add(new Move(WHITE_KING, 4, 0, 2, 0, 0, 0, this));\n }\n board[0][4] = WHITE_KING;\n }else if (turn == BLACK && (castles & 0b1100) != 0){//(castles[2] || castles[3])) {\n board[7][4] = 0; // remove king to avoid check test collisions with extra king\n //if (castles[2] && board[7][5] == 0 && board[7][6] == 0 && inCheck(5, 7).size() == 0) {\n if ((castles & BLACK_SHORT) != 0 && board[7][5] == 0 && board[7][6] == 0 && inCheck(5, 7).size() == 0) {\n results.add(new Move(BLACK_KING, 4, 7, 6, 7, 0, 0, this));\n }\n //if (castles[3] && board[7][1] == 0 && board[7][2] == 0 && board[7][3] == 0 && inCheck(3, 7).size() == 0) {\n if ((castles & BLACK_LONG) != 0 && board[7][1] == 0 && board[7][2] == 0 && board[7][3] == 0 &&\n inCheck(3, 7).size() == 0) {\n results.add(new Move(BLACK_KING, 4, 7, 2, 7, 0, 0, this));\n }\n board[7][4] = BLACK_KING;\n }\n }\n }\n List<Move> fullLegal = new LinkedList<>();\n for (Move m : results){\n makeMove(m);\n turn = -turn;\n if (m.piece == WHITE_KING || m.piece == BLACK_KING){\n if (inCheck(m.toX,m.toY).size() == 0){\n fullLegal.add(m);\n }\n }else if (inCheck(kingX,kingY).size() == 0){\n fullLegal.add(m);\n }\n turn = -turn;\n undoMove(m);\n }\n Collections.sort(fullLegal, (o1, o2) -> o2.score - o1.score); // greatest score treated as least so appears first\n return fullLegal;\n }", "@Test\n void checkDoMove() {\n abilities.doMove(turn, board.getCellFromCoords(1, 1));\n assertEquals(turn.getWorker().getCell(), board.getCellFromCoords(1, 1));\n Worker forcedWorker = turn.getWorker();\n for (Worker other : turn.getOtherWorkers()) {\n if (other.getCell() == board.getCellFromCoords(2, 2)) {\n forcedWorker = other;\n }\n }\n\n assertEquals(forcedWorker.getCell(), board.getCellFromCoords(2, 2));\n\n // Can't move anymore after having already moved\n assertFalse(abilities.checkCanMove(turn, board.getCellFromCoords(0, 0)));\n }", "@Test\n\tpublic void invalidMove() throws Exception {\n\t\tgame.board.movePiece(knightCorner1Black, -1, 2);\n\t\tgame.board.movePiece(knightCorner2White, 4, 7);\n\t\tgame.board.movePiece(knightSide1Black, 1, -1);\n\t\tgame.board.movePiece(knightSide2White, 4, 6);\n\t\tgame.board.movePiece(knightMiddleWhite, 10, 4);\n\t\tassertEquals(knightCorner1Black, game.board.getPiece(0, 0));\n\t\tassertEquals(knightCorner2White, game.board.getPiece(7, 7));\n\t\tassertEquals(knightSide1Black, game.board.getPiece(0, 3));\n\t\tassertEquals(knightSide2White, game.board.getPiece(3, 7));\n\t\tassertEquals(knightMiddleWhite, game.board.getPiece(4, 4));\n\t}", "public boolean move(int x, int y, CheckersBoard board) {\n if (whiteTurn == true && team == Constants.TeamId.team1Id) {\n return false;\n }\n if (whiteTurn == false && team == Constants.TeamId.team2Id) {\n return false;\n }\n /**\n * then change the x - y coords of the piece\n * update the UI to remove the highlighted squares then move the piece\n * if chess and shared square you take a piece\n * if checkers you jumped them you take the piece\n * return new x - y components\n *\n * if this is too high up in the tree you can override this implementation or update it\n * to fit specific pieces if its not working for some reason\n */\n if (possible(x, y, gameBoard)) {\n int changex = this.getX()-x;\n int changey = this.getY()-y;\n CheckersPiece temp = gameBoard.boardPositions[getX()][getY()];\n gameBoard.boardPositions[getX()][getY()] = null;\n gameBoard.boardPositions[x][y] = temp;\n if (gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2] != null) {\n System.out.println(\"Here\");\n if (gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2].team != this.team) {\n gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2].imageView.setVisibility(View.GONE);\n gameBoard.boardPositions[(this.getX() + x)/2][(this.getY() + y)/2] = null;\n }\n }\n this.setX(x);\n this.setY(y);/*\n if (Math.abs(changex) == 2) {\n gameBoard.boardPositions[x + (changex/2)][y + (changey/2)] = null;\n if (team == Constants.TeamId.team1Id) {\n board.numPieces1--;\n } else if (team == Constants.TeamId.team2Id) {\n board.numPieces0--;\n }\n }*/\n\n gameBoard.boardPositions[x][y].imageView.setX(142*x);\n gameBoard.boardPositions[x][y].imageView.setY(142*y);\n // flips after move is\n whiteTurn = !whiteTurn;\n gameBoard.startTimer();\n }\n //setUpUI(gameBoard);\n if (getY() == 7 && team == Constants.TeamId.team2Id) {\n board.crown(this);\n }\n if (getY() == 0 && team == Constants.TeamId.team1Id) {\n board.crown(this);\n }\n return possible(x, y, gameBoard);\n }", "private String checkLegalMove(PieceType piece, Location from, Location to) {\n\t\t// Create a string to store the error message in case the move is\n\t\t// invalid.\n\t\tString errorMessage = null;\n\n\t\t// Check that none of the arguments are null.\n\t\tif (piece == null || from == null || to == null) {\n\t\t\terrorMessage = \"Arguments to the move method must not be null.\";\n\t\t\treturn errorMessage;\n\t\t}\n\n\t\t// Make sure that the game has been started first\n\t\tif (!gameStarted) {\n\t\t\terrorMessage = \"Cannot make a move before the game has started.\";\n\t\t\treturn errorMessage;\n\t\t}\n\n\t\t// Get the piece from the from location that is attempting to move.\n\t\tfinal Piece movingPiece = gameBoard.getPieceAt(from);\n\n\t\t// Check whether the move is a valid move on the board.\n\t\terrorMessage = gameBoard.checkValidMove(piece, from, to);\n\t\tif (errorMessage != null) {\n\t\t\treturn errorMessage;\n\t\t}\n\n\t\t// A piece that is not the color whose turn it is cannot move.\n\t\tif (movingPiece.getOwner() != currentTurnColor) {\n\t\t\terrorMessage = \"You cannot move when it is not you turn.\";\n\t\t\treturn errorMessage;\n\t\t}\n\n\t\treturn null;\n\t}", "@Override\r\n\tpublic boolean makeMove(String notation) {\n\t\tif(Castle.isCastlingMove(new ChessCoordinate(notation))) {\r\n\t\t\tKing playerKing = (King) getPlayerTurn().getPieces(\"King\", true).get(0);\r\n\t\t\t//return the result of trying to castle\r\n\t\t\treturn playerKing.move(new ChessCoordinate(notation));\r\n\t\t\t\r\n\t\t}else {\r\n\t\t\t//not a castling move, standard move\r\n\t\t\t\t\r\n\t\t\tString[] notationList = notation.split(\"\");\r\n\t\t\t//find the piece name\r\n\t\t\tString pieceName = ChessPieceNames.getPieceName(notationList[0]);\t\t\r\n\t\t\t\r\n\t\t\tif(pieceName == null && getColumnNames().contains(notationList[0].toLowerCase())) {\r\n\t\t\t\t//if first character is a column and returned null from above\r\n\t\t\t\t//must be a pawn move like e4 or axb2\r\n\t\t\t\tpieceName = ChessPieceNames.PAWN.toString();\r\n\t\t\t}else if(pieceName == null){\r\n\t\t\t\t//not a column and null so invalid move\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\r\n//\t\t\t//capturing move if there is a capture (x)\r\n\t\t\tboolean isCaptureMove = Arrays.asList(notationList).contains(\"x\");\r\n\t\t\t\r\n\t\t\t//final coordinate\r\n\t\t\tString coordinateString = notationList[notationList.length-2] + notationList[notationList.length-1];\r\n\t\t\tChessCoordinate coordinate = new ChessCoordinate(coordinateString);\r\n\t\t\tif(coordinate.isValid()) {\r\n\t\t\t\t//extract players alive pieces of piece name\r\n\t\t\t\tList<Piece> piecesOfType = getPlayerTurn().getPieces(pieceName, true);\r\n\t\t\t\t//list of pieces that can move to the same square\r\n\t\t\t\tList<Piece> piecesCanMoveToSquare = new ArrayList<Piece>();\r\n\t\t\t\tfor (Piece piece : piecesOfType) {\r\n\t\t\t\t\t\r\n\t\t\t\t\t//use valid moves of attacking if capturing move, else use move to\r\n\t\t\t\t\tSet<Coordinate> pieceMoves = isCaptureMove \r\n\t\t\t\t\t\t\t? piece.getValidMoves(Action.ATTACK) : piece.getValidMoves(Action.MOVE_TO);\r\n\t\t\t\t\tif(pieceMoves.contains(coordinate))piecesCanMoveToSquare.add(piece);\r\n\t\t\t\t}\t\r\n\t\t\t\t\r\n\t\t\t\tif (piecesCanMoveToSquare.size() == 1) {\r\n\t\t\t\t\t//only one piece can go to that square, so take piece at 0th index as the list only has one element\r\n\t\t\t\t\tpiecesCanMoveToSquare.get(0).move(coordinate);\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\telse if (piecesCanMoveToSquare.size() > 1) {\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(notation.length() <= 3) {\r\n\t\t\t\t\t\tSystem.out.println(\"Invalid move, specify which piece to move to \" + coordinateString);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//multiple pieces of the same type can move to that square, check which one to use\r\n\t\t\t\t\t//if pawn, the identifier to use is the 0th index of notationList, eg axb4. use pawn in column a.\r\n\t\t\t\t\t//for other pieces, column to use is the 1st index of notationList. eg Nab4.\r\n\t\t\t\t\t\r\n\t\t\t\t\t//variable called identifier as it can be a row or column value.\r\n\t\t\t\t\tString identifier = (pieceName.equalsIgnoreCase(ChessPieceNames.PAWN.toString()) ?\r\n\t\t\t\t\t\t\tnotationList[0] : notationList[1]).toLowerCase();\r\n\t\t\t\t\t//identifier should be a row value if pieces share the same column\r\n\t\t\t\t\tboolean isRowIdentifier = shareColumn(piecesOfType);\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(isRowIdentifier && getRowNames().contains(identifier)) {\r\n\t\t\t\t\t\t//locate piece by row and move that piece to coordinate\r\n\t\t\t\t\t\tfor (Piece piece : piecesCanMoveToSquare) {\r\n\t\t\t\t\t\t\t//look at the row number of piece coordinate, see if it matches the identifier \r\n\t\t\t\t\t\t\tif(Character.toString(piece.getPosition().toString().charAt(1)).equalsIgnoreCase(identifier)) {\r\n\t\t\t\t\t\t\t\tpiece.move(coordinate);\r\n\t\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tSystem.out.println(\"There is no \" + pieceName + \" on row \" + identifier);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}else if(getColumnNames().contains(identifier)) {\r\n\t\t\t\t\t\tfor (Piece piece : piecesCanMoveToSquare) {\r\n\t\t\t\t\t\t\t//look at the column letter of piece coordinate, see if it matches the identifier \r\n\t\t\t\t\t\t\tif(Character.toString(piece.getPosition().toString().charAt(0)).equalsIgnoreCase(identifier)) {\r\n\t\t\t\t\t\t\t\tpiece.move(coordinate);\r\n\t\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tSystem.out.println(\"There is no \" + pieceName + \" on column \" + identifier);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//invalid identifier\r\n\t\t\t\t\telse return false;\r\n\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\telse {\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t//invalid coordinate, move can not be played\r\n\t\t\telse return false;\r\n\t\t}\r\n\t\t\r\n\t}", "@Override\n public Collection<Move> calculateLegalMoves(Board board) {\n System.out.println(\"INSIDE Knight: calculateLegalMoves()\");\n System.out.println(\"------------------------------>\\n\");\n\n //ArrayList of moves used to store all possible legal moves.\n final List<Move> legalMoves = new ArrayList<>();\n\n //Iterate the constant class array of piece offsets.\n for(final int currentCandidate : CANDIDATE_MOVE_COORDS){\n //Add the current coordinate of the piece to each offset, storing as a destination coordinate.\n final int candidateDestinationCoord = this.piecePosition + currentCandidate;\n\n //If the destination coordinate is within legal board bounds (between 0 and 64)...\n if(BoardUtils.isValidCoord(candidateDestinationCoord)){\n //Check to see if the piece is in the first column and its destination would move it outside the board.\n if(isfirstColumnExclusion(this.piecePosition, currentCandidate) ||\n isSecondColumnExclusion(this.piecePosition, currentCandidate) ||\n isSeventhColumnExclusion(this.piecePosition, currentCandidate) ||\n isEighthColumnExclusion(this.piecePosition, currentCandidate)){\n continue; //Continue the loop if any of these methods return true\n }\n\n //Store the tile of the destination coordinate.\n final Tile candidateDestinationTile = board.getTile(candidateDestinationCoord);\n\n //If the tile is not marked as occupied by the Tile class...\n if(!candidateDestinationTile.isOccupied()){\n //Add the move to the list of legal moves as a non-attack move.\n legalMoves.add(new MajorMove(board, this, candidateDestinationCoord));\n }\n else{\n //Otherwise, get the type and alliance of the piece at the destination.\n final Piece pieceAtDestination = candidateDestinationTile.getPiece();\n final Alliance pieceAlliance = pieceAtDestination.getPieceAlliance();\n\n //If the piece at the occupied tile's alliance differs...\n if(this.pieceAlliance != pieceAlliance){\n //Add the move to the list of legal moves as an attack move.\n legalMoves.add(new MajorAttackMove(board, this, candidateDestinationCoord, pieceAtDestination));\n }\n }\n }\n }\n\n //Return the list of legal moves.\n return legalMoves;\n }", "private boolean moveIsValid(Move move){\n BoardSpace[][] boardCopy = new BoardSpace[Constants.BOARD_DIMENSIONS][Constants.BOARD_DIMENSIONS];\n for(int i = 0; i < Constants.BOARD_DIMENSIONS; i++){\n for(int j = 0; j < Constants.BOARD_DIMENSIONS; j++){\n boardCopy[i][j] = new BoardSpace(boardSpaces[i][j]);\n }\n }\n int row = move.getStartRow();\n int col = move.getStartCol();\n String ourWord = \"\";\n String currentWord = \"\";\n for (Tile tile: move.getTiles()){\n ourWord += tile.getLetter();\n if (move.isAcross()){\n col++;\n } else {\n row++;\n }\n }\n currentWord = ourWord;\n if(move.isAcross()){\n //check if we keep going right we invalidate the word\n while(col+1 < boardCopy.length && !boardCopy[row][++col].isEmpty() ){\n if( isValidWord(currentWord += boardCopy[row][col].getTile().getLetter()) == false ) return false;\n }\n //check if we keep going left we invalidate the word\n col = move.getStartCol();\n currentWord = ourWord;\n while(col-1 >= 0 && !boardCopy[row][--col].isEmpty() ){\n if(!isValidWord( currentWord = boardCopy[row][col].getTile().getLetter() + currentWord ) ) return false;\n }\n } else if(!move.isAcross()){\n row = move.getStartRow(); col = move.getStartCol();\n currentWord = ourWord;\n //check if we keep going down we invalidate the word;\n while(row+1 < boardCopy.length && !boardCopy[++row][col].isEmpty()){\n if( !isValidWord(currentWord += boardCopy[row][col].getTile().getLetter() )) return false;\n }\n row = move.getStartRow();\n currentWord = ourWord;\n while(row-1 >= 0 && !boardCopy[--row][col].isEmpty()){\n if( !isValidWord( currentWord = boardCopy[row][col].getTile().getLetter() + currentWord )) return false;\n }\n }\n return true;\n }", "public static void move(TTTBoard board, char piece) {\n if (board.winner() != ' ') {\n throw new IllegalArgumentException(\"Game Over\");\n }\n if (board.size() == 1) {\n board.set(0, 0, piece);\n return;\n }\n if (board.size() == 3) {\n int turnNumber = getBoardTurnNumber(board);\n if (turnNumber == 1) {\n board.set(0, 0, piece);\n return;\n } else if (turnNumber == 2) {\n if (board.get(1, 1) == ' ') {\n board.set(1, 1, piece);\n return;\n } else if (board.get(0, 0) == ' ') {\n board.set(0, 0, piece);\n return;\n }\n } else if (turnNumber == 3) {\n try {\n int[] opp = getFirstOpp(board, piece);\n int oppRow = opp[0];\n if (oppRow == 0) {\n board.set(2, 0, piece);\n return;\n } else if (oppRow == 1) {\n board.set(0, 2, piece);\n return;\n } else {\n board.set(0, 2, piece);\n return;\n }\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n }\n\n // check if win diagonal\n int selfC = 0;\n int oppC = 0;\n int spaceC = 0;\n for (int i = 0; i < board.size(); ++i) {\n int j = i;\n char p = board.get(i, j);\n if (p == ' ') spaceC++;\n else if (p == piece) selfC++;\n else oppC++;\n }\n\n if (spaceC == 1 && (selfC == 0 || oppC == 0)) {\n // fill in that space\n for (int i = 0; i < board.size(); ++i) {\n int j = i;\n char p = board.get(i, j);\n if (p == ' ') {\n board.set(i, j, piece);\n return;\n }\n }\n }\n\n selfC = 0;\n oppC = 0;\n spaceC = 0;\n for (int i = 0; i < board.size(); ++i) {\n int j = board.size() - i - 1;\n char p = board.get(i, j);\n if (p == ' ') spaceC++;\n else if (p == piece) selfC++;\n else oppC++;\n\n }\n\n if (spaceC == 1 && (selfC == 0 || oppC == 0)) {\n // fill in that space\n for (int i = 0; i < board.size(); ++i) {\n int j = board.size() - i - 1;\n char p = board.get(i, j);\n if (p == ' ') {\n board.set(i, j, piece);\n return;\n }\n }\n }\n\n // check if win row col\n\n boolean[] selfWinnableRows = new boolean[board.size()];\n boolean[] oppWinnableRows = new boolean[board.size()];\n boolean[] selfWinnableCols = new boolean[board.size()];\n boolean[] oppWinnableCols = new boolean[board.size()];\n int[] selfCountRows = new int[board.size()];\n int[] selfCountCols = new int[board.size()];\n int[] oppCountRows = new int[board.size()];\n int[] oppCountCols = new int[board.size()];\n\n // checks if any rows can be won\n for (int i = 0; i < board.size(); ++i) {\n boolean containsSelf = false;\n boolean containsOpp = false;\n boolean hasEmpty = false;\n int selfCount = 0;\n int oppCount = 0;\n\n for (int j = 0; j < board.size(); ++j) {\n char p = board.get(i, j);\n\n if (p == ' ') {\n hasEmpty = true;\n } else if (p == piece) {\n containsSelf = true;\n selfCount++;\n } else {\n containsOpp = true;\n oppCount++;\n }\n }\n\n selfCountRows[i] = selfCount;\n oppCountRows[i] = oppCount;\n\n if (!hasEmpty) continue;\n\n if (!containsSelf && !containsOpp) {\n selfWinnableRows[i] = true;\n oppWinnableRows[i] = true;\n }\n\n if (containsSelf && !containsOpp) {\n selfWinnableRows[i] = true;\n }\n if (containsOpp && !containsSelf) {\n oppWinnableRows[i] = true;\n }\n }\n\n // checks if any cols can be won\n for (int i = 0; i < board.size(); ++i) {\n boolean containsSelf = false;\n boolean containsOpp = false;\n boolean hasEmpty = false;\n int selfCount = 0;\n int oppCount = 0;\n for (int j = 0; j < board.size(); ++j) {\n char p = board.get(j, i);\n\n if (p == ' ') {\n hasEmpty = true;\n } else if (p == piece) {\n containsSelf = true;\n selfCount++;\n } else {\n containsOpp = true;\n oppCount++;\n }\n }\n\n selfCountCols[i] = selfCount;\n oppCountCols[i] = oppCount;\n\n if (!hasEmpty) continue;\n\n if (!containsSelf && !containsOpp) {\n selfWinnableCols[i] = true;\n oppWinnableCols[i] = true;\n }\n\n if (containsSelf && !containsOpp) {\n selfWinnableCols[i] = true;\n }\n\n if (containsOpp && !containsSelf) {\n oppWinnableCols[i] = true;\n }\n }\n\n int[] selfInRowRows = new int[board.size()];\n int[] selfInRowCols = new int[board.size()];\n int[] oppInRowRows = new int[board.size()];\n int[] oppInRowCols = new int[board.size()];\n\n for (int i = 0; i < selfWinnableRows.length; ++i) {\n if (selfWinnableRows[i]) {\n int count = selfCountRows[i];\n selfInRowRows[count]++;\n }\n }\n for (int i = 0; i < selfWinnableCols.length; ++i) {\n if (selfWinnableCols[i]) {\n int count = selfCountCols[i];\n selfInRowCols[count]++;\n }\n }\n for (int i = 0; i < oppWinnableRows.length; ++i) {\n if (oppWinnableRows[i]) {\n int count = oppCountRows[i];\n oppInRowRows[count]++;\n }\n }\n for (int i = 0; i < oppWinnableCols.length; ++i) {\n if (oppWinnableCols[i]) {\n int count = oppCountCols[i];\n oppInRowCols[count]++;\n }\n }\n\n if (board.size() == 3) {\n int turnNumber = getBoardTurnNumber(board);\n if (selfInRowRows[board.size() - 1] == 0 &&\n selfInRowCols[board.size() - 1] == 0 &&\n oppInRowRows[board.size() - 1] == 0 &&\n oppInRowCols[board.size() - 1] == 0) {\n if (turnNumber == 4) {\n if ((board.get(1, 1) != ' ' && board.get(1, 1) != piece)\n && (board.get(2, 2) != ' ' && board.get(2, 2) != piece)) {\n board.set(2, 0, piece);\n return;\n }\n } else if (turnNumber == 5) {\n if (selfCountCols[0] == 2) {\n board.set(2, 2, piece);\n return;\n } else if (selfCountRows[0] == 2) {\n if (board.get(1, 0) != piece && board.get(1, 0) != ' ') {\n board.set(2, 2, piece);\n return;\n }\n if (board.get(2, 0) != piece && board.get(2, 0) != ' ') {\n board.set(2, 2, piece);\n return;\n }\n board.set(2, 0, piece);\n return;\n }\n }\n }\n }\n\n for (int i = board.size() - 1; i >= 0; i--) {\n int selfRowsCount = selfInRowRows[i];\n //System.out.println(i + \" self rows count: \" + selfRowsCount);\n if (selfRowsCount > 0) {\n // get a row index that contains this self in row rows\n try {\n int rowIndex = getRowIndexForInRowRows(board, i, selfWinnableRows, selfCountRows);\n int colIndex = getNextInRow(board, rowIndex);\n board.set(rowIndex, colIndex, piece);\n return;\n } catch (Exception e) {\n e.printStackTrace();\n }\n\n }\n int selfColsCount = selfInRowCols[i];\n if (selfColsCount > 0) {\n try {\n int colIndex = getRowIndexForInRowRows(board, i, selfWinnableCols, selfCountCols);\n int rowIndex = getNextInCol(board, colIndex);\n board.set(rowIndex, colIndex, piece);\n return;\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n int oppRowsCount = oppInRowRows[i];\n // System.out.println(i + \" opp rows count: \" + oppRowsCount);\n if (oppRowsCount > 0) {\n\n try {\n int rowIndex = getRowIndexForInRowRows(board, i, oppWinnableRows, oppCountRows);\n int colIndex = getNextInRow(board, rowIndex);\n board.set(rowIndex, colIndex, piece);\n return;\n } catch (Exception e) {\n e.printStackTrace();\n }\n\n }\n int oppColsCount = oppInRowCols[i];\n if (oppColsCount > 0) {\n try {\n int colIndex = getRowIndexForInRowRows(board, i, oppWinnableCols, oppCountCols);\n int rowIndex = getNextInCol(board, colIndex);\n board.set(rowIndex, colIndex, piece);\n return;\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n }\n\n try {\n int[] nextEmpty = getNextEmpty(board);\n board.set(nextEmpty[0], nextEmpty[1], piece);\n } catch (Exception e) {\n throw new IllegalArgumentException(\"DRAW / SOMEONE WON\");\n }\n }", "boolean isLegal(Move move) {\n int c = move.getCol0();\n int r = move.getRow0();\n int[] vector = move.unit();\n Piece p;\n for(int i = 0; i <= vector[2]; i++) {\n p = get(c, r);\n if (p != null && p.side() != _turn) {\n return false;\n }\n }\n return true;\n\n }", "public Move move() {\n\n byte[] piece;\n int pieceIndex;\n Move.Direction direction = null;\n int counter = 0;\n\n Scanner s = new Scanner(System.in);\n\n\n System.out.println(\"Please select piece to move: \");\n\n\n while (true) {\n try {\n pieceIndex = s.nextInt();\n\n if ((piece = getPiece(pieceIndex)) == null) {\n System.out.println(\"invalid index, try again!\");\n// check if selected piece is stuck\n } else if (\n (((player == Board.V) && (piece[1]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O ) || // UP\n ((player == Board.H) && (piece[1]-1 >=0) && (board.layout[piece[0]][piece[1]-1] == O)) || // DOWN\n ((player == Board.V) && (piece[0]-1 >=0) && (board.layout[piece[0]-1][piece[1]] == O)) || // LEFT\n (((player == Board.H) && (piece[0]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O )) // RIGHT\n {\n break;\n// if all are stuck pass turn\n } else if (counter + 1 < Board.getSize()) {\n counter++;\n System.out.println(\"Piece is stuck, pick another, \" + counter + \" pieces stuck.\");\n } else {\n System.out.println(\"Passing\");\n return null;\n }\n } catch (Exception e){\n System.out.println(\"Piece index expects int, try again\");\n s = new Scanner(System.in);\n }\n }\n System.out.println(\"Please select direction ('w' // 'a' // 's' // 'd'): \");\n\n boolean valid = false;\n while (!valid) {\n\n switch (s.next().charAt(0)) {\n // if the move requested is valid, break the loop, make the move on our record of layout and return the\n // move made\n case 'w':\n direction = Move.Direction.UP;\n valid = (((player == Board.V) && (piece[1]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O );\n break;\n\n case 'a':\n direction = Move.Direction.LEFT;\n valid = ((player == Board.V) && (piece[0]-1 >=0) && (board.layout[piece[0]-1][piece[1]] == O));\n break;\n\n case 's':\n direction = Move.Direction.DOWN;\n valid = ((player == Board.H) && (piece[1]-1 >=0) && (board.layout[piece[0]][piece[1]-1] == O));\n break;\n\n case 'd':\n direction = Move.Direction.RIGHT;\n valid = (((player == Board.H) && (piece[0]+1 == Board.getSize()))) || (board.layout[piece[0]][piece[1]+1] == O );\n break;\n default:\n System.out.println(\"Invalid key press, controls are wasd\");\n valid = false;\n }\n }\n Move move = makeMove(direction, pieceIndex);\n board.update(move, player);\n\n return move;\n }", "public int gameState() {\n \tboolean check = isCheck(turn);\n \t\n \t//change this code to be some sort of checkmate detection\n \tif(check) {\n \t\t//we need to check whether there is a legal move that puts the king out of check\n \t\t//we need to loop through all pieces of the same color as the turn and make all legal moves\n \t\t//then after each move, check whether the king is still in check\n \t\t\n \t\t//first generate a list of all pieces for the turn color\n \t\tArrayList<Piece> pieces = getPieces(turn);\n \t\t\n \t\tboolean freedom;\n \t\t\n \t\t//now for each piece, check whether moving that piece can get the king out of check\n \t\tfor(int i = 0; i < pieces.size(); i++) {\n \t\t\tfreedom = simulate(pieces.get(i));\n \t\t\tif(freedom) {\n \t \t\tupdateCheckMove(false);\n \t \t\tSystem.out.println(\"Check on \" + turn + \" King!\");\n \t\t\t\treturn 2; //if the king can move, then the game isn't over yet\n \t\t\t}\n \t\t}\n \t\t\n \t\t//the game is over if we reach this far, so we can assume checkmate\n \t\t//resignation logic will probably be specific to Display class\n \t\t\n \t\tupdateCheckMove(true);\n \t\t\n \t\tif(turn == PieceColor.White) return -1; //black win if white king in check and can't move\n \t\tif(turn == PieceColor.Black) return 1;\n \t}\n \t\n \t//if all of these fail, the game isn't over yet\n \treturn 2;\n }", "@Override\n public boolean isValidMove(Move move) {\n if (board[move.oldRow][move.oldColumn].isValidMove(move, board))\n return true;\n //player will not be in check\n //move will get player out of check if they are in check\n return false;\n }", "void doMakeMove(CheckersMove move) {\n\n boardData.makeMove(move, false);\n\n /* If the move was a jump, it's possible that the player has another\n jump. Check for legal jumps starting from the square that the player\n just moved to. If there are any, the player must jump. The same\n player continues moving. */\n \n if (move.isJump()) {\n legalMoves = boardData.getLegalJumpsFrom(currentPlayer, move.toRow, move.toCol);\n if (legalMoves != null) {\n if (currentPlayer == CheckersData.RED) {\n console(\"RED: You must continue jumping.\");\n } else {\n console(\"BLACK: You must continue jumping.\");\n }\n selectedRow = move.toRow; // Since only one piece can be moved, select it.\n selectedCol = move.toCol;\n refreshBoard();\n return;\n }\n }\n\n /* The current player's turn is ended, so change to the other player.\n Get that player's legal moves. If the player has no legal moves,\n then the game ends. */\n if (currentPlayer == CheckersData.RED) {\n currentPlayer = CheckersData.BLACK;\n legalMoves = boardData.getLegalMoves(currentPlayer);\n if (legalMoves == null) {\n gameOver(\"BLACK has no moves. RED wins.\");\n } else if (legalMoves[0].isJump()) {\n console(\"BLACK: Make your move. You must jump.\");\n } else {\n console(\"BLACK: Make your move.\");\n }\n } else {\n currentPlayer = CheckersData.RED;\n legalMoves = boardData.getLegalMoves(currentPlayer);\n if (legalMoves == null) {\n gameOver(\"RED has no moves. BLACK wins.\");\n } else if (legalMoves[0].isJump()) {\n console(\"RED: Make your move. You must jump.\");\n } else {\n console(\"RED: Make your move.\");\n }\n }\n\n /* Set selectedRow = -1 to record that the player has not yet selected\n a piece to move. */\n selectedRow = -1;\n\n /* As a courtesy to the user, if all legal moves use the same piece, then\n select that piece automatically so the user won't have to click on it\n to select it. */\n if (legalMoves != null) {\n boolean sameStartSquare = true;\n for (int i = 1; i < legalMoves.length; i++) {\n if (legalMoves[i].fromRow != legalMoves[0].fromRow\n || legalMoves[i].fromCol != legalMoves[0].fromCol) {\n sameStartSquare = false;\n break;\n }\n }\n if (sameStartSquare) {\n selectedRow = legalMoves[0].fromRow;\n selectedCol = legalMoves[0].fromCol;\n }\n }\n\n /* Make sure the board is redrawn in its new state. */\n refreshBoard();\n\n }", "public static boolean isMoveValid(int[][] board, int player, int fromRow, int fromCol, int toRow, int toCol) {\r\n\t\t\r\n\t\tboolean ans = false;\r\n\t\t\r\n\t\tif (board[toRow][toCol]==0){/*is the target slot ia emtey*/\r\n\t\t\tif (player==1){\r\n\t\t\t\tif (board[fromRow][fromCol]==1||board[fromRow][fromCol]==2){ /*is the starting slot is red player queen olayer solduer*/\r\n\t\t\t\t\tif (isBasicJumpValid(board,player,fromRow,fromCol,toRow,toCol)){/*is the eating is legal*/\r\n\t\t\t\t\t\tans = true;\t\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse{\r\n\t\t\t\t\t\tif (canJump(board,player)==false){/*is ther no eating jump?*/\r\n\t\t\t\t\t\t\tif (isBasicMoveValid(board,player,fromRow,fromCol,toRow,toCol)){/*is this is legal move*/\r\n\t\t\t\t\t\t\t\tans = true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\t\t\r\n\t\t\tif (player==-1){\r\n\t\t\t\tif (board[fromRow][fromCol]==-1||board[fromRow][fromCol]==-2){/*is the starting slot is blue player queen olayer solduer*/\r\n\t\t\t\t\tif (isBasicJumpValid(board,player,fromRow,fromCol,toRow,toCol)){/*is the eating is legal*/\r\n\t\t\t\t\t\tans = true;\t\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse{\r\n\t\t\t\t\t\tif (canJump(board,player)==false){/*is ther are no eating move*/\r\n\t\t\t\t\t\t\tif (isBasicMoveValid(board,player,fromRow,fromCol,toRow,toCol)){/*is the move is legal*/\r\n\t\t\t\t\t\t\t\tans = true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\t\t\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn ans;\r\n\t}", "public boolean isMoveLegal() {\n if (!getGame().getBoard().contains(getFinalCoords())) {\n return false;\n }\n\n // for aero units move must use up all their velocity\n if (getEntity() instanceof Aero) {\n Aero a = (Aero) getEntity();\n if (getLastStep() == null) {\n if ((a.getCurrentVelocity() > 0) && !getGame().useVectorMove()) {\n return false;\n }\n } else {\n if ((getLastStep().getVelocityLeft() > 0) && !getGame().useVectorMove()\n && !(getLastStep().getType() == MovePath.MoveStepType.FLEE\n || getLastStep().getType() == MovePath.MoveStepType.EJECT)) {\n return false;\n }\n }\n }\n\n if (getLastStep() == null) {\n return true;\n }\n\n if (getLastStep().getType() == MoveStepType.CHARGE) {\n return getSecondLastStep().isLegal();\n }\n if (getLastStep().getType() == MoveStepType.RAM) {\n return getSecondLastStep().isLegal();\n }\n return getLastStep().isLegal();\n }", "public boolean checkMove(Piece piece, boolean check) {\n\t\tif (check) {\n\t\t\tint x = piece.getX();\n\t\t\tint y = piece.getY();\n\t\t\tif (x >= 0 && x <= 7 && y >= 0 && y <= 7) {\n\t\t\t\tstrong_enemy = false;\n\t\t\t\tfriend = false;\n\t\t\t\t// check surrounding\n\t\t\t\tcheck_enemy_and_friend(x - 1, y, piece.getStrength(), piece.getColor());\n\t\t\t\tcheck_enemy_and_friend(x + 1, y, piece.getStrength(), piece.getColor());\n\t\t\t\tcheck_enemy_and_friend(x, y - 1, piece.getStrength(), piece.getColor());\n\t\t\t\tcheck_enemy_and_friend(x, y + 1, piece.getStrength(), piece.getColor());\n\n\t\t\t\tif (strong_enemy == false) {\n\t\t\t\t\treturn true;\n\t\t\t\t} else if (strong_enemy == true && friend == true) {// freezing is solved\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else {\n\t\t\treturn true;\n\t\t}\n\t}", "@Override\r\n\tpublic void getLegalMoves() {\r\n\t\tint pawnX = this.getX();\r\n\t\tint pawnY = this.getY();\r\n\t\tchar pawnColor = getColor();\r\n\t\tTile[][] chessBoard = SimpleChess.getChessBoard();\r\n\t\tcheckInFront(chessBoard,pawnX,pawnY,pawnColor);\r\n\t\tcheckDiagonal(chessBoard,pawnX,pawnY,pawnColor);\r\n\t}", "public boolean moveValidation(Board board, Piece piece, int sourceX, int sourceY, int targetX, int targetY){//TODO make directions in Piece class\n int diffX = targetX - sourceX;\n int diffY = targetY - sourceY;\n if (!board.isPieceAtLocation(targetX, targetY) || board.isPieceAtLocationCapturable(piece.getColour(), targetX, targetY)) {\n if(diffX==0 && diffY > 0 )\n return !board.isPieceBetweenLocations(sourceX, sourceY, targetX, targetY, 0, 1);\n else if(diffX > 0 && diffY == 0 )\n return !board.isPieceBetweenLocations(sourceX, sourceY, targetX, targetY, 1, 0);\n else if(diffX < 0 && diffY == 0 )\n return !board.isPieceBetweenLocations(sourceX, sourceY, targetX, targetY, -1, 0);\n else if(diffX==0 && diffY < 0 )\n return !board.isPieceBetweenLocations(sourceX, sourceY, targetX, targetY, 0, -1);\n }\n return false;\n }", "public boolean isValidMove(Point orig, Point dest){ \r\n Color playerColor = model.getCurrentPlayer().getColor();\r\n // Validate all point between board limits\r\n if(!isValidPosition(orig) || !isValidPosition(dest)) return false;\r\n // Check for continue move starting piece\r\n if(model.getCheckPiece() != null && !model.getCheckPiece().equals(orig)) return false;\r\n // Validate origin piece to player color\r\n if((isRed(playerColor) && !isRed(orig)) || (isBlack(playerColor) && !isBlack(orig))) return false;\r\n // Only can move to empty Black space\r\n if(!isEmpty(dest)) return false;\r\n // If current player have obligatory eats, then need to eat\r\n if(obligatoryEats(playerColor) && !moveEats(orig,dest)) return false;\r\n // Check move direction and length\r\n int moveDirection = orig.getFirst() - dest.getFirst(); // Direction in Rows\r\n int rLength = Math.abs(moveDirection); // Length in Rows\r\n int cLength = Math.abs(orig.getSecond() - dest.getSecond()); // Length in Columns\r\n int mLength;\r\n // Only acepts diagonal movements in 1 or 2 places (1 normal move, 2 eats move)\r\n if ((rLength == 1 && cLength == 1) || (rLength == 2 && cLength == 2)){\r\n mLength = rLength;\r\n } else {\r\n return false;\r\n }\r\n // 1 Place movement\r\n if (mLength == 1){ \r\n if (isRed(orig) && !isQueen(orig) && moveDirection > 0) return true;\r\n if (isBlack(orig) && !isQueen(orig) && moveDirection < 0) return true;\r\n if ((isRed(orig) && isQueen(orig)) || (isBlack(orig) && isQueen(orig))) return true;\r\n }\r\n // 2 Places movement need checks if eats rivals\r\n if (mLength == 2){\r\n // Compute mid point\r\n Point midPoint = getMidPoint(orig, dest);\r\n // Check move\r\n if ((isRed(orig) && isBlack(midPoint)) || (isBlack(orig) && isRed(midPoint))){\r\n if (isRed(orig) && !isQueen(orig) && moveDirection > 0) return true;\r\n if (isBlack(orig) && !isQueen(orig) && moveDirection < 0) return true;\r\n if ((isRed(orig) && isQueen(orig)) || (isBlack(orig) && isQueen(orig))) return true;\r\n }\r\n }\r\n return false;\r\n }", "public void setValidMoves(Board board, int x, int y, int playerType) {\n\t\tmoves.clear();\n\t\t// if this is pawn's first move, it can move two squares forward\n\t\tif (firstMove == true)\n\t\t{\n\t\t\t// white moves forward with y++\n\t\t\tif(this.getPlayer() == 1)\n\t\t\t{\n\t\t\t\tPoint firstMove = new Point(x + 0, y + 2);\n\t\t\t\tif (board.getPiece(x, y + 1) == null && board.getPiece(x, y + 2) == null)\n\t\t\t\t{\n\t\t\t\t\t\tmoves.add(firstMove);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// black moves forward with y--\n\t\t\telse\n\t\t\t{\n\t\t\t\tPoint firstMove = new Point(x + 0, y - 2);\n\t\t\t\tif (board.getPiece(x, y - 1) == null && board.getPiece(x, y - 2) == null)\n\t\t\t\t{\n\t\t\t\t\t\tmoves.add(firstMove);\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\tif (this.getPlayer() == 1)\n\t\t{\n\t\t\t// if a piece is occupying a square diagonal from pawn, it can capture\n\t\t\tif (x + 1 < 8 && y + 1 < 8 && x + 1 >= 0 && y + 1 >= 0)\n\t\t\t{\n\t\t\t\tPoint move = new Point(x + 1, y + 1);\n\t\t\t\tif (board.getPiece(x + 1, y + 1) != null)\n\t\t\t\t{\n\t\t\t\t\tif (board.getPiece(x+1,y+1).getPlayer() != this.getPlayer())\n\t\t\t\t\t{\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (x - 1 < 8 && y + 1 < 8 && x - 1 >= 0 && y + 1 >= 0)\n\t\t\t{\n\t\t\t\tPoint move = new Point(x - 1, y + 1);\n\t\t\t\tif (board.getPiece(x - 1, y + 1) != null)\n\t\t\t\t{\n\t\t\t\t\tif (board.getPiece(x - 1, y + 1).getPlayer() != this.getPlayer())\n\t\t\t\t\t{\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\t// if no piece is in front of pawn, it can move forward one square\n\t\t\tif (x < 8 && y + 1 < 8 && x >= 0 && y + 1 >=0)\n\t\t\t{\n\t\t\t\tPoint move = new Point(x + 0, y + 1);\n\t\t\t\tif (board.getPiece(x, y + 1) == null)\n\t\t\t\t{\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// if a piece is occupying a square diagonal from pawn, it can capture\n\t\t\tif (x + 1 < 8 && y - 1 < 8 && x + 1 >= 0 && y - 1 >= 0)\n\t\t\t{\n\t\t\t\tPoint move = new Point(x + 1, y - 1);\n\t\t\t\tif (board.getPiece(x + 1, y - 1) != null)\n\t\t\t\t{\n\t\t\t\t\tif (board.getPiece(x + 1,y - 1).getPlayer() != this.getPlayer())\n\t\t\t\t\t{\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (x - 1 < 8 && y - 1 < 8 && x - 1 >= 0 && y - 1 >= 0)\n\t\t\t{\n\t\t\t\tPoint move = new Point(x - 1, y - 1);\n\t\t\t\tif (board.getPiece(x - 1, y - 1) != null)\n\t\t\t\t{\n\t\t\t\t\tif (board.getPiece(x - 1, y - 1).getPlayer() != this.getPlayer())\n\t\t\t\t\t{\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\t// if no piece is in front of pawn, it can move forward one square\n\t\t\tif (x < 8 && y - 1 < 8 && x >= 0 && y - 1 >=0)\n\t\t\t{\n\t\t\t\tPoint move = new Point(x + 0, y - 1);\n\t\t\t\tif (board.getPiece(x, y - 1) == null)\n\t\t\t\t{\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}", "public boolean isLegalMove(int row, int column) {\n // Check move beyond half of the rows\n if (getSide() == Side.NORTH && row > 4)\n return false;\n\n if (getSide() == Side.SOUTH && (chessBoard.getMaxRows() - 5) > row)\n return false;\n\n return isLegalNonCaptureMove(row, column);\n }", "boolean isLegal(Move move) {\n int count = pieceCountAlong(move);\n int c0 = move.getCol0();\n int r0 = move.getRow0();\n int c1 = move.getCol1();\n int r1 = move.getRow1();\n int count2 = Math.max(Math.abs(c1 - c0), Math.abs(r1 - r0));\n return ((count == count2) && !blocked(move));\n }", "@Test\r\n public void callingMovePossibleWhenTryingToTakeAnOpponentPieceWith2MarkersOnShouldReturnFalse() {\n player1.movePiece(12, 11, board);\r\n player1.movePiece(12, 11, board);\r\n\r\n player2.movesLeft.moves.add(2);\r\n\r\n // Then\r\n assertFalse(player2.isMovePossible(13, 11, board));\r\n }", "boolean checkLegalMove(int posx, int posy) {\n\t\tBoolean bool;\n\t\tint change;\n\t\tchange = curPlayer > 1 ? (change = 1) : (change = -1);\n\t\tif (kingJumping(posx, posy, change)){\n\t\t\tbool = true;\n\t\t} else if (prevPosX == posx + change && (prevPosY == posy - 1 || prevPosY == posy + 1)){\n\t\t\tSystem.out.println(\"Normal move\");\n\t\t\tbool = true;\n\t\t} else if (jump(posx, posy, prevPiece) && (prevPosX == posx + (change * 2) && (prevPosY == posy - 2 || prevPosY == posy + 2))) {\n\t\t\tbool = true;\n\t\t} else if (((JLabel)prevComp).getIcon().equals(Playboard.rKing) || ((JLabel)prevComp).getIcon().equals(Playboard.bKing) || ((JLabel)prevComp).getIcon().equals(Playboard.blackSKing) || ((JLabel)prevComp).getIcon().equals(Playboard.redSKing)){\n\t\t\tchange *= (-1);\n\t\t\tif (prevPosX == posx + change && (prevPosY == posy - 1 || prevPosY == posy + 1)){\n\t\t\t\tbool = true;\n\t\t\t} else\n\t\t\t\tbool = false;\n\t\t} else if (prevPiece == 4 && (prevPosX == posx + 1 || prevPosX == posx -1) && (prevPosY == posy - 1 || prevPosY == posy +1)) { // King moves\n\t\t\tchange *= (-1);\n\t\t\tif (prevPosX == posx + change && (prevPosY == posy - 1 || prevPosY == posy + 1))\n\t\t\t\tbool = true;\n\t\t\telse\n\t\t\t\tbool = false;\n\t\t} else {\n\t\t\tbool = false;\n\t\t}\n\t\treturn bool;\n\t}", "public int canMoveTo(Piece p, Location dest)\n {\n if (p==null||dest==null||!dest.isValid())\n return ILLEGAL_MOVE;\n Location loc = getLocation(p);\n if (dest.equals(loc))\n return ILLEGAL_MOVE;\n int thisCol = loc.getCol();\n int thisRow = loc.getRow();\n int otherCol = dest.getCol();\n int otherRow = dest.getRow();\n int rowDiff = Math.abs(thisRow-otherRow);\n int colDiff = Math.abs(thisCol-otherCol);\n Piece other = getPiece(dest);\n if (other!=null&&other.sameColor(p))\n return ILLEGAL_MOVE;\n switch (p.getType())\n {\n case KING:\n if (rowDiff==0&&colDiff==2) //castling\n {\n if (p.hasMoved())\n return ILLEGAL_MOVE;\n Piece rook = null;\n Direction dir = null;\n if (thisCol > otherCol) //queenside\n {\n dir = Direction.WEST;\n rook = getPiece(new Location(thisRow,thisCol-4));\n }\n else //kingside\n {\n dir = Direction.EAST;\n rook = getPiece(new Location(thisRow,thisCol+3));\n }\n if (rook==null||rook.getType()!=Type.ROOK||!p.sameColor(rook)||rook.hasMoved())\n return ILLEGAL_MOVE;\n Location next = loc;\n for (int i=thisCol; i!=getLocation(rook).getCol(); i=next.getCol())\n {\n if ((!next.equals(loc)&&getPiece(next)!=null)||enemyCanAttack(p.getColor(),next))\n return ILLEGAL_MOVE;\n next = next.farther(dir);\n }\n if (thisCol > otherCol)\n return QUEENSIDE_CASTLING;\n else return KINGSIDE_CASTLING;\n }\n else //normal king move\n if (adjacent(loc,dest)\n && (other==null || !p.sameColor(other)))\n return KING_MOVE;\n else return ILLEGAL_MOVE;\n \n case PAWN:\n if (rowDiff>2||rowDiff<1||colDiff>1||(rowDiff==2&&colDiff>0)\n ||(p.white()&&otherRow>thisRow)||(!p.white()&&otherRow<thisRow))\n return ILLEGAL_MOVE;\n else if (rowDiff==2) //first move\n {\n if (p.hasMoved())\n return ILLEGAL_MOVE;\n Location temp = loc.closerTo(dest);\n if (getPiece(temp)==null&&other==null&&((p.white()&&thisRow==6)||(!p.white()&&thisRow==1)))\n return PAWN_FIRST_MOVE;\n else return ILLEGAL_MOVE;\n }\n else if (colDiff==1 && other!=null) //taking\n {\n if (p.sameColor(other))\n return ILLEGAL_MOVE;\n else return PAWN_CAPTURE;\n }\n else if (colDiff==1 && other==null) //en passant\n {\n int diff = otherCol-thisCol;\n Location otherLoc = new Location(thisRow,thisCol+diff);\n Piece otherPiece = getPiece(otherLoc);\n if (otherPiece!=null&&otherPiece.hasJustMoved()\n &&otherPiece.getType()==Type.PAWN&&!otherPiece.sameColor(p))\n return EN_PASSANT;\n else return ILLEGAL_MOVE;\n }\n else if (rowDiff==1) //normal move\n {\n if (other==null)\n return PAWN_MOVE;\n else return ILLEGAL_MOVE;\n }\n break;\n \n case ROOK:case QUEEN: case BISHOP:case KNIGHT:\n if (!canAttack(p,dest))\n return ILLEGAL_MOVE;\n else\n {\n switch (p.getType())\n {\n case ROOK:return ROOK_MOVE;\n case QUEEN:return QUEEN_MOVE;\n case BISHOP:return BISHOP_MOVE;\n case KNIGHT:return KNIGHT_MOVE;\n }\n }\n }\n return ILLEGAL_MOVE; //will never happen\n }", "public List<Move> getValidMoves(Board board, boolean checkKing) {\n List<Move> moves = new ArrayList<Move>();\n\n // if no board given, return empty list\n if (board == null)\n return moves;\n\n // checks moves where the pawn advances a rank\n advance(board, moves);\n // checks moves where the pawn captures another piece\n capture(board, moves);\n // checks en passant moves\n enPassant(board, moves);\n\n // check that move doesn't put own king in check\n if (checkKing)\n for(int i = 0; i < moves.size(); i++)\n if (board.movePutsKingInCheck(moves.get(i), this.color)) {\n // if move would put king it check, it is invalid and\n // is removed from the list\n moves.remove(moves.get(i));\n // iterator is decremented due to the size of the list\n // decreasing.\n i--;\n }\n return moves;\n }", "public static void compute_possible_moves(Board s){\n\t\tint b [][] = s.board;\n\t\tint x = -1;\n\t\tint y = -1;\n\t\tfor (int i = 0;i < b.length;i++) {\n\t\t\tfor (int j = 0;j < b[i].length;j++) {\n\t\t\t\tif(b[i][j] == 0){\n\t\t\t\t\tx = i;\n\t\t\t\t\ty = j;\n\t\t\t\t\tbreak;\n\t\t\t\t}\t\n\t\t\t}\n\t\t}\n\n\t\tint left [][];\n\t\tint right [][];\n\t\tint up [][];\n\t\tint down [][];\n\t\tpossible_boards.clear();\n\t\tif(x - 1 != -1 && x >= 0 && x < 3){\n\t\t\t//up is a legal move\n\t\t\tint temporary_board [][] = new int[b.length][];\n\t\t\tfor(int q = 0; q < b.length; q++)\n\t\t\t temporary_board [q] = b[q].clone();\n\t\t\t\n\n\t\t\tint temp = temporary_board[x - 1][y];\n\t\t\ttemporary_board[x - 1][y] = temporary_board[x][y];\n\t\t\ttemporary_board[x][y] = temp;\n\t\t\tup = temporary_board;\n\n\t\t\tBoard up_board = new Board(up);\n\t\t\tpossible_boards.add(up_board);\n\n\t\t}\n\t\tif(x + 1 != 3 && x >= 0 && x < 3){\n\t\t\t//down is a legal move\n\t\t\tint temporary_board [][] = new int[b.length][];\n\t\t\tfor(int q = 0; q < b.length; q++)\n\t\t\t temporary_board [q] = b[q].clone();\n\t\t\t\n\t\t\tint temp = temporary_board[x + 1][y];\n\t\t\ttemporary_board[x + 1][y] = temporary_board[x][y];\n\t\t\ttemporary_board[x][y] = temp;\n\t\t\tdown = temporary_board;\n\t\t\tBoard down_board = new Board(down);\n\t\t\tpossible_boards.add(down_board);\n\t\t}\n\t\tif(y - 1 != -1 && y >= 0 && y < 3){\n\t\t\t//left move is legal\n\t\t\tint temporary_board [][] = new int[b.length][];\n\t\t\tfor(int q = 0; q < b.length; q++)\n\t\t\t temporary_board [q] = b[q].clone();\n\t\t\t\n\t\t\tint temp = temporary_board[x][y - 1];\n\t\t\ttemporary_board[x][y - 1] = temporary_board[x][y];\n\t\t\ttemporary_board[x][y] = temp;\n\t\t\tleft = temporary_board;\n\t\t\tBoard left_board = new Board(left);\n\t\t\tpossible_boards.add(left_board);\n\n\t\t}\n\t\tif(y + 1 != 3 && y >= 0 && y < 3){\n\t\t\t//right move is legal\n\t\t\tint temporary_board [][] = new int[b.length][];\n\t\t\tfor(int q = 0; q < b.length; q++)\n\t\t\t temporary_board [q] = b[q].clone();\n\t\t\t\n\t\t\tint temp = temporary_board[x][y + 1];\n\t\t\ttemporary_board[x][y + 1] = temporary_board[x][y];\n\t\t\ttemporary_board[x][y] = temp;\n\t\t\tright = temporary_board;\n\t\t\tBoard right_board = new Board(right);\n\t\t\tpossible_boards.add(right_board);\n\n\t\t}\n\n\t}", "boolean hasMove(Piece side) {\r\n List<Move> listOfLegalMoves = legalMoves(side);\r\n return listOfLegalMoves != null;\r\n }", "@Test\n public void isValidMoveTest() {\n\n //get the board of the enemy with the method getBoard() from enemyGameBoard\n board = enemyGameBoard.getBoard();\n\n //Try two times for a existing point on the board\n assertTrue(enemyGameBoard.isValidMove(1,1));\n assertTrue(enemyGameBoard.isValidMove(2,4));\n\n //Try two times for a non-existing point on the board\n assertFalse(enemyGameBoard.isValidMove(15,5)); // x-value outside the board range\n assertFalse(enemyGameBoard.isValidMove(5,11)); // y-value outside the board range\n\n //hit a water field\n enemyGameBoard.makeMove(2, 3, false);\n assertTrue(board[2][3].equals(EnemyGameBoard.WATER_HIT));\n\n //try isValidMove() on the already hit water field\n assertFalse(enemyGameBoard.isValidMove(2,3));\n\n //hit a ship field\n enemyGameBoard.makeMove(5, 4, true);\n assertTrue(board[5][4].equals(EnemyGameBoard.SHIP_HIT));\n\n //try isValidMove() on the already hit water field\n assertFalse(enemyGameBoard.isValidMove(5,4));\n }", "public Boolean checkStalemate(IBoardAgent oBoard, IPlayerAgent oPlayer) {\n\t\tIPieceAgent oKingPiece = oPlayer.getKingPiece();\n\n\t\t// Checking if any piece other than King can make any move.\n\t\tfor (Map.Entry<String, IPieceAgent> itPiece : oPlayer.getAllPieces().entrySet()) {\n\t\t\tIPieceAgent oPiece = itPiece.getValue();\n\t\t\t\n\t\t\tif (oPiece.getPosition() == null) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\n\t\t\tif (oPiece.equals(oKingPiece)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\n\t\t\tMap<String, IMoveCandidate> mpCandidateMovePosition = new HashMap<String, IMoveCandidate>();\n\t\t\ttryEvaluateAllRules(oBoard, oPiece, mpCandidateMovePosition);\n\t\t\t\n\t\t\tif (!mpCandidateMovePosition.isEmpty()) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t\n\t\t// Fetching all the possible moves King can make.\n\t\tMap<String, IMoveCandidate> mpCandidateMovePositionForKing = new HashMap<String, IMoveCandidate>();\n\t\ttryEvaluateAllRules(oBoard, oKingPiece, mpCandidateMovePositionForKing);\n\t\t\n\t\t// Iterating through the opponent's pieces and see if there is any candidate move that King can make\n\t\t// without endangering itself.\n\t\tfor (Map.Entry<String, IPlayerAgent> itPlayer : oBoard.getAllPlayerAgents().entrySet()) {\n\t\t\tif (itPlayer.getValue().equals(oPlayer)) {\n\t\t\t\t// Ignore piece from same player.\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// Iterating the pieces of the current player.\n\t\t\tfor (Map.Entry<String, IPieceAgent> itPiece : itPlayer.getValue().getAllPieces().entrySet()) {\n\t\t\t\tIPieceAgent oOpponentPiece = itPiece.getValue();\n\t\t\t\tif (oOpponentPiece.getPosition() == null) {\n\t\t\t\t\t// Piece is not linked to any piece indicates the piece has been captured.\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// Fetching the possible moves the piece can make.\n\t\t\t\tMap<String, IMoveCandidate> mpCandidateMovePositionsForOpponentPlayerPiece = new HashMap<String, IMoveCandidate>();\n\t\t\t\ttryEvaluateAllRules(oBoard, oOpponentPiece, mpCandidateMovePositionsForOpponentPlayerPiece);\n\t\t\t\tfor (Map.Entry<String, IMoveCandidate> itCandidateMove : mpCandidateMovePositionsForOpponentPlayerPiece.entrySet()) {\t\t\t\t\n\t\t\t\t\tif (mpCandidateMovePositionForKing.containsKey(itCandidateMove.getKey())) {\n\t\t\t\t\t\tmpCandidateMovePositionForKing.remove(itCandidateMove.getKey());\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (mpCandidateMovePositionForKing.size() == 0) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (mpCandidateMovePositionForKing.size() > 0) {\n\t\t\treturn false;\n\t\t}\n\t\t\t\n\t\treturn true;\n\t}", "private boolean isLegal(String move) {\n if (!move.matches(\"[0-9]*,[0-9]*\")) {\n return false;\n }\n\n int column = Integer.parseInt(move.substring(2)) - 1;\n int row = Integer.parseInt(move.substring(0, 1)) - 1;\n\n if (beyondBoard(column, row)) {\n return false;\n }\n\n if (isOccupied(column, row)) {\n return false;\n }\n\n return true;\n }", "private void checkMove(Tile[][] chessBoard, int pawnX, int pawnY, int direction) {\r\n\t\tUnit unit = chessBoard[pawnX][pawnY+direction].getPiece();\r\n\t\tif (unit == null) {\r\n\t\t\tMoves move = new Moves(pawnX, pawnY+direction);\r\n\t\t\tinsertMove(move, moveList);\r\n\t\t}\r\n\t}", "public void makeMove(Move m){\n int oldTurn = turn;\n turn = -turn;\n moves++;\n enPassant = -1;\n if (m.toY == 0){ // white rook space\n if (m.toX == 0){\n castles &= nWHITE_LONG;\n //castles[1] = false;\n }else if (m.toX == 7){\n castles &= nWHITE_SHORT;\n //castles[0] = false;\n }\n } else if (m.toY == 7){ // black rook space\n if (m.toX == 0){\n castles &= nBLACK_LONG;\n //castles[3] = false;\n }else if (m.toX == 7){\n castles &= nBLACK_SHORT;\n //castles[2] = false;\n }\n }\n if (m.piece == WHITE_ROOK && m.fromY == 0){\n if (m.fromX == 0){castles &= nWHITE_LONG;} //castles[1] = false;}\n else if (m.fromX == 7){castles &= nWHITE_SHORT;} //castles[0] = false;}\n } else if (m.piece == BLACK_ROOK && m.fromY == 7){\n if (m.fromX == 0){castles &= nBLACK_LONG;} //castles[3] = false;}\n else if (m.fromX == 7){castles &= nBLACK_SHORT;} //castles[2] = false;}\n }\n // castling\n if (m.piece % 6 == 0){\n if (oldTurn == WHITE){\n castles &= 0b1100;\n //castles[0] = false; castles[1] = false;\n } else {\n castles &= 0b11;\n //castles[2] = false; castles[3] = false;\n }\n if (m.toX - m.fromX == 2){ // short\n board[m.fromY][m.fromX] = 0;\n board[m.toY][m.toX] = m.piece;\n // rook\n board[m.fromY][5] = board[m.fromY][7];\n board[m.fromY][7] = 0;\n return;\n } else if (m.toX - m.fromX == -2){ // long\n board[m.fromY][m.fromX] = 0;\n board[m.toY][m.toX] = m.piece;\n // rook\n board[m.fromY][3] = board[m.fromY][0];\n board[m.fromY][0] = 0;\n return;\n }\n } else if (m.piece % 6 == 1) { // pawn move\n stalemateCountdown = 0; // resets on a pawn move\n // promotion\n if (m.toY % 7 == 0){\n board[m.toY][m.toX] = m.promoteTo;\n board[m.fromY][m.fromX] = 0;\n return;\n }\n // en passant\n else if (m.fromX != m.toX && board[m.toY][m.toX] == 0){\n board[m.fromY][m.fromX] = 0;\n board[m.toY][m.toX] = m.piece;\n if (oldTurn == WHITE){\n board[4][m.toX] = 0;\n }else{\n board[3][m.toX] = 0;\n }\n return;\n } else if (m.toY - m.fromY == 2*oldTurn){\n enPassant = m.fromX;\n }\n }\n // regular\n if (board[m.toY][m.toX] != 0){\n stalemateCountdown = 0; // resets on a capture\n }\n board[m.fromY][m.fromX] = 0;\n board[m.toY][m.toX] = m.piece;\n }", "private boolean moveCheck(Piece p, List<Move> m, int fC, int fR, int tC, int tR) {\n if (null == p) {\n // Legal move!\n m.add(new Move(fC, fR, tC, tR));\n // Continue checking for moves.\n return false;\n }\n if (p.owner != whoseTurn) {\n // Enemy sighted!\n // Legal move!\n m.add(new Move(fC, fR, tC, tR));\n // No more moves!\n }\n return true;\n }", "@Test\n\tpublic void moveToValidSpace() throws Exception {\n\t\tgame.board.movePiece(knightCorner1Black, 1, 2);\n\t\tgame.board.movePiece(knightCorner2White, 5, 6);\n\t\tgame.board.movePiece(knightSide1Black, 2, 2);\n\t\tgame.board.movePiece(knightSide2White, 4, 5);\n\t\tgame.board.movePiece(knightMiddleWhite, 5, 2);\n\t\tassertEquals(knightCorner1Black, game.board.getPiece(1, 2));\n\t\tassertEquals(knightCorner2White, game.board.getPiece(5, 6));\n\t\tassertEquals(knightSide1Black, game.board.getPiece(2, 2));\n\t\tassertEquals(knightSide2White, game.board.getPiece(4, 5));\n\t\tassertEquals(knightMiddleWhite, game.board.getPiece(5, 2));\n\t}", "@Test\n public void testMovePieceInvalidMove() {\n Position pos = new Position(board, 3, 3);\n Pawn pawnOne = new Pawn(Color.WHITE);\n board.getSquare(pos).addPiece(pawnOne);\n pawnOne.setPosition(pos);\n Position pos1 = new Position(board, 5, 3);\n assertFalse(chess.movePiece(board.getSquare(pos), board.getSquare(pos1), pawnOne));\n }", "public boolean isLegalStep(MoveDirection dir){\r\n GamePosition curPos = currentGame.getCurrentPosition();\n\t\tPlayer white = currentGame.getWhitePlayer();\n\t\tint[] toCheckPos = new int[2];\n\t\tint[] existingPos = new int[2];\n\t\tif(curPos.getPlayerToMove().equals(white)) {\n\t\t\ttoCheckPos[0] = curPos.getWhitePosition().getTile().getColumn();\n\t\t\ttoCheckPos[1] = curPos.getWhitePosition().getTile().getRow();\n\t\t\t\n\t\t\texistingPos[0] = curPos.getBlackPosition().getTile().getColumn();\n\t\t\texistingPos[1] = curPos.getBlackPosition().getTile().getRow();\n\t\t\t\n\t\t} else {\n\t\t\ttoCheckPos[0] = curPos.getBlackPosition().getTile().getColumn();\n\t\t\ttoCheckPos[1] = curPos.getBlackPosition().getTile().getRow();\n\t\t\t\n\t\t\texistingPos[0] = curPos.getWhitePosition().getTile().getColumn();\n\t\t\texistingPos[1] = curPos.getWhitePosition().getTile().getRow();\n\t\t}\n\t\t//0 = column, 1 = row\n\t\tif(dir == MoveDirection.North) {\n\t\t\tif(toCheckPos[1] == 1) return false;\n\t\t\tif(toCheckPos[1] - 1 == existingPos[1] && toCheckPos[0] == existingPos[0]) return false;\n\t\t\treturn QuoridorController.noWallBlock(curPos.getPlayerToMove(), -1, 0);\n\t\t} else if(dir == MoveDirection.South) {\n\t\t\tif(toCheckPos[1] == 9) return false;\n\t\t\tif(toCheckPos[1] + 1 == existingPos[1] && toCheckPos[0] == existingPos[0]) return false;\n\t\t\treturn QuoridorController.noWallBlock(curPos.getPlayerToMove(), 1, 0);\n\t\t} else if(dir == MoveDirection.East) {\n\t\t\tif(toCheckPos[0] == 9) return false;\n\t\t\tif(toCheckPos[0] + 1 == existingPos[0] && toCheckPos[1] == existingPos[1]) return false;\n\t\t\treturn QuoridorController.noWallBlock(curPos.getPlayerToMove(), 0, 1);\n\t\t} else if(dir == MoveDirection.West) {\n\t\t\tif(toCheckPos[0] == 1) return false;\n\t\t\tif(toCheckPos[0] - 1 == existingPos[0] && toCheckPos[1] == existingPos[1]) return false;\n\t\t\treturn QuoridorController.noWallBlock(curPos.getPlayerToMove(), 0, -1);\n\t\t}\n\t\t\n\t\treturn false;\r\n }", "public boolean isMoveLegal(Move move){\n return legalMoves.contains(move);\n }", "List<Move> legalMoves(Piece side) {\r\n legalMovesArr = new ArrayList<Move>();\r\n HashSet<Square> pieceSide = pieceLocations(side);\r\n for (Square pieces : pieceSide) {\r\n for (int i = 0; i <= 8; i++) {\r\n Move x = mv(pieces, sq(pieces.col(), i));\r\n legalMovesArr.add(x);\r\n }\r\n for (int j = 0; j <= 8; j++) {\r\n Move y = mv(pieces, sq(j, pieces.row()));\r\n legalMovesArr.add(y);\r\n }\r\n while (legalMovesArr.remove(null));\r\n }\r\n return legalMovesArr;\r\n }", "@Override\n\tpublic boolean validMove(int xEnd, int yEnd, board b){\n\t\t//try to land one same color piece\n\t\tif(b.occupied(xEnd, yEnd)&&b.getPiece(xEnd, yEnd).getColor()==color){\n\t\t\treturn false;\n\t\t}\n\t\tif(v==0){\n\t\t\tif(!this.guard(xEnd, yEnd, b)){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t//normal move\n\t\tif((xEnd==x-1&&yEnd==y-1)||(xEnd==x-1&&yEnd==y)||(xEnd==x-1&&yEnd==y+1)||(xEnd==x&&yEnd==y-1)||(xEnd==x&&yEnd==y+1)||(xEnd==x+1&&yEnd==y-1)||(xEnd==x+1&&yEnd==y)||(xEnd==x+1&&yEnd==y+1)){\n\t\t\tif(b.occupied(xEnd, yEnd)){\n\t\t\t\t//set the enpass flage back\n\t\t\t\tb.setFlag(color, 100, 100);\n\t\t\t\tb.recycle(xEnd, yEnd);\n\t\t\t\tthis.setPosition(xEnd, yEnd);\n\t\t\t\tb.update();\n\t\t\t\tc=0;\n\t\t\t\treturn true;\n\t\t\t}else{\n\t\t\t\t//set the enpass flage back\n\t\t\t\tb.setFlag(color, 100, 100);\n\t\t\t\tthis.setPosition(xEnd, yEnd);\n\t\t\t\tb.update();\n\t\t\t\tc=0;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}else if((xEnd==x-2&&yEnd==y)){ //castling\n\t\t\tpiece r = b.getPiece(0, y);\n\t\t\tif(r==null){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif(r.getC()==0||r.getColor()!=color||r.getType()!= type.ROOK||c==0){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tfor(int i=3;i>0;i--){\n\t\t\t\tif(b.occupied(i, y)){\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.setPosition(xEnd, yEnd);\n\t\t\tr.setPosition(3,y);\n\t\t\tc=0;\n\t\t\tr.setC(0);\n\t\t\tb.setFlag(color, 100, 100);\n\t\t\tb.update();\n\t\t\treturn true;\n\t\t}else if((xEnd==x+2&&yEnd==y)){\n\t\t\tpiece r = b.getPiece(7, y);\n\t\t\tif(r==null){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif(r.getC()==0||r.getColor()!=color||r.getType()!= type.ROOK||c==0){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tfor(int i=5;i<=6;i++){\n\t\t\t\tif(b.occupied(i, y)){\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.setPosition(xEnd, yEnd);\n\t\t\tr.setPosition(5,y);\n\t\t\tc=0;\n\t\t\tr.setC(0);\n\t\t\tb.setFlag(color, 100, 100);\n\t\t\tb.update();\n\t\t\treturn true;\n\t\t}else{\n\t\t\treturn false;\n\t\t}\n\t}", "private boolean canMove(Point piece){\r\n // direction -1: red pieces +1: black pieces\r\n int dir = isRed(piece)? -1:+1;\r\n // normal movement\r\n Point left = new Point(piece.getFirst() + dir, piece.getSecond() - 1);\r\n Point right = new Point(piece.getFirst() + dir, piece.getSecond() + 1);\r\n // check for normal movements\r\n if(isValidPosition(left) && isEmpty(left)) return true;\r\n if(isValidPosition(right) && isEmpty(right)) return true;\r\n // if is a queen\r\n if(isQueen(piece)){\r\n // compute queen move points (invert direction)\r\n Point leftQ = new Point(piece.getFirst() - dir, piece.getSecond() - 1);\r\n Point rightQ = new Point(piece.getFirst() - dir, piece.getSecond() + 1);\r\n // check for down movements\r\n if(isValidPosition(leftQ) && isEmpty(leftQ)) return true;\r\n if(isValidPosition(rightQ) && isEmpty(rightQ)) return true;\r\n }\r\n return false;\r\n }", "void makeMove(int row, int col, int nextRow, int nextCol) {\r\n int temp = checks[row][col];\r\n checks[nextRow][nextCol] = temp;\r\n checks[row][col] = 0;\r\n if (Math.abs(nextRow - row) == 2){\r\n removePiece(nextRow, nextCol,row, col);\r\n }\r\n checkKing(nextRow,nextCol);\r\n }", "public boolean isValidMove(Move move, IChessPiece[][] board) {\n\t\tif(!super.isValidMove(move, board)){\n\t\t\treturn false;\n\t\t}\n\t\tif(Math.abs(move.fromRow-move.toRow)>1 || Math.abs(move.fromColumn-move.toColumn)>1){\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}", "public boolean isMoveLegal(int x, int y) {\n\t\tif (rowSize <= x || colSize <= y || x < 0 || y < 0) {\r\n\t\t\t// System.out.print(\"Position (\" + (x + 1) + \", \" + (y + 1) + \") is\r\n\t\t\t// out of range!\\n\");\r\n\t\t\treturn false;\r\n\t\t} else if (!(matrix[x][y] == 0)) {\r\n\t\t\t// System.out.print(\"Position (\" + (x + 1) + \", \" + (y + 1) + \") has\r\n\t\t\t// been occupied!\\n\");\r\n\t\t\treturn false;\r\n\t\t} else\r\n\t\t\treturn true;\r\n\t}", "public void applyConvertedMove(String move) {\n\n\t\tString[] moveParts = move.split(\";\");\n\n\t\tint fromRow = Integer.parseInt(moveParts[0].charAt(0) + \"\");\n\t\tint fromCol = Integer.parseInt(moveParts[0].charAt(1) + \"\");\n\n\t\tint toRow = Integer.parseInt(moveParts[1].charAt(0) + \"\");\n\t\tint toCol = Integer.parseInt(moveParts[1].charAt(1) + \"\");\n\n\t\tint piece = board[fromRow][fromCol];//Integer.parseInt(moveParts[2]);\n\t\tint pieceType = Math.abs(board[fromRow][fromCol]);\n\t\tint team = Math.round(Math.signum(board[fromRow][fromCol]));\n\n\t\tboolean doResetEnpassant = true;\n\n\t\tif (pieceType == 1) { //If this is a pawn\n\t\t\tif (Math.abs(board[toRow][toCol]) == 7) { //If it is moving onto an enpassant stored tile\n\t\t\t\tboard[toRow + board[toRow][toCol]/7][toCol] = 0; //Kill the pawn that produced the enpassant tile\n\t\t\t} else if (Math.abs(fromRow - toRow) == 2) { //If it just did the double move thing\n\t\t\t\t//Reset the current enpassant tile\n\t\t\t\tresetEnpassant(team);\n\t\t\t\tdoResetEnpassant = false;\n\n\t\t\t\t//Set an empassant tile\n\t\t\t\tboard[(toRow + fromRow)/2][toCol] = 7 * team;\n\t\t\t\tenpassantCol = toCol;\n\t\t\t}\n\t\t} else if (pieceType == 6) { //If this is a king\n\t\t\tif (fromCol == 4) {\n\t\t\t\tif (doResetEnpassant) resetEnpassant(team);\n\t\t\t\tif (toCol == 7) { //Kingside Castle\n\t\t\t\t\tboard[toRow][6] = piece;\n\t\t\t\t\tboard[toRow][5] = board[toRow][7];\n\t\t\t\t\tboard[toRow][7] = 0;\n\t\t\t\t\tboard[toRow][4] = 0;\n\t\t\t\t\treturn;\n\t\t\t\t} else if (toCol == 0) { //Queenside Castle\n\t\t\t\t\tboard[toRow][2] = piece;\n\t\t\t\t\tboard[toRow][3] = board[toRow][0];\n\t\t\t\t\tboard[toRow][0] = 0;\n\t\t\t\t\tboard[toRow][4] = 0;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (doResetEnpassant) resetEnpassant(team);\n\t\tboard[fromRow][fromCol] = 0;\n\t\tif (moveParts.length > 2 && pieceType == 1 && (team == 1 ? toRow == 7 : team == -1 ? toRow == 0 : false)) {\n\t\t\tpiece = Integer.parseInt(moveParts[2]);\n\t\t}\n\t\tboard[toRow][toCol] = piece;\n\t}", "public boolean isLegalMove(int [] newPos, Pieces [][] gameState, Panel[][] board){\r\n\t\t\r\n\t\tif(gameState[newPos[0]][newPos[1]] != null){\r\n\t\t\tif(this.color == gameState[newPos[0]][newPos[1]].getColor()){\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tif (piece == 'p'){\r\n\t\t\treturn this.movePawn(newPos, gameState);\r\n\t\t}else if(piece == 'r'){\r\n\t\t\treturn this.moveRook(newPos, gameState);\r\n\t\t}else if(piece == 'b'){\r\n\t\t\treturn this.moveBishop(newPos, gameState);\r\n\t\t}else if(piece == 'n'){\r\n\t\t\treturn this.moveKnight(newPos, gameState);\r\n\t\t}else if(piece == 'q'){\r\n\t\t\treturn this.moveQueen(newPos, gameState);\r\n\t\t}else if(piece == 'k'){\r\n\t\t\treturn this.moveKing(newPos, gameState, board);\r\n\t\t}\t\t\r\n\t\treturn false;\r\n\t}", "boolean isLegal(Move move) {\r\n return isLegal(move.from(), move.to());\r\n }", "public boolean canCastle(int direction){\n\t\tPiece rook;\n\t\t\n\t\tif(!((getColor().equals(\"White\") && getSquare().getCol() == 4 && getSquare().getRow() == 7 ) ||\n\t\t\t\t(getColor().equals(\"Black\") && getSquare().getCol() == 4 && getSquare().getRow() == 0 )))\n\t\t\treturn false;\n\t\t\n\t\t\n\t\tif(direction == 1){\n\t\t\trook = getSquare().getEast().getEast().getEast().getOccupant();\n\t\t\tif(rook == null || !rook.getColor().equals(this.getColor()) || !rook.getType().equals(\"Rook\") || rook.hasMoved() || this.hasMoved())\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getEast().getEast().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getEast().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\t\n\t\t\tif(getColor().equals(\"White\")){\n\t\t\t\tfor(int i = 0; i < ChessBoard.getPieces().size(); i++){\n\t\t\t\t\tif(ChessBoard.getPieces().get(i).getColor().equals(\"Black\"))\n\t\t\t\t\t\tfor(int location: ChessBoard.getPieces().get(i).getMoves()){\n\t\t\t\t\t\t\tif(location == 75 || location == 76){\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tfor(int i = 0; i < ChessBoard.getPieces().size(); i++){\n\t\t\t\t\tif(ChessBoard.getPieces().get(i).getColor().equals(\"White\"))\n\t\t\t\t\t\tfor(int location: ChessBoard.getPieces().get(i).getMoves()){\n\t\t\t\t\t\t\tif(location == 5 || location == 6){\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\t\n\t\t}\n\t\t\n\t\telse if (direction == -1){//East\n\t\t\trook = getSquare().getWest().getWest().getWest().getWest().getOccupant();\n\t\t\tif(rook == null || !rook.getColor().equals(this.getColor()) || !rook.getType().equals(\"Rook\") || rook.hasMoved() || this.hasMoved())\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getWest().getWest().getWest().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getWest().getWest().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\tif(getSquare().getWest().getOccupant() != null)\n\t\t\t\treturn false;\n\t\t\t\n\t\t\tif(getColor().equals(\"White\")){\n\t\t\t\tfor(int i = 0; i < ChessBoard.getPieces().size(); i++){\n\t\t\t\t\tif(ChessBoard.getPieces().get(i).getColor().equals(\"Black\"))\n\t\t\t\t\t\tfor(int location: ChessBoard.getPieces().get(i).getMoves()){\n\t\t\t\t\t\t\tif(location == 73 || location == 72 || location == 71){\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\telse{\n\t\t\t\tfor(int i = 0; i < ChessBoard.getPieces().size(); i++){\n\t\t\t\t\tif(ChessBoard.getPieces().get(i).getColor().equals(\"White\"))\n\t\t\t\t\t\tfor(int location: ChessBoard.getPieces().get(i).getMoves()){\n\t\t\t\t\t\t\tif(location == 3 || location == 2 || location == 1){\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn true;\n\t}", "public boolean move(int oldCol, int oldRow, int newCol, int newRow , char promo) {\r\n\r\n\r\n if(isValidMove(oldCol, oldRow, newCol, newRow)) {\r\n\r\n\r\n // not a valid move for current player for ANY piece\r\n // if current players king will be in check as a result\r\n // move is disallowed\r\n if (King.isPlayerKingInCheck(oldRow, oldCol, newRow, newCol)) {\r\n return false;\r\n }\r\n else {\r\n\r\n if (Chessboard.whitesTurn==true) {\r\n Chessboard.whiteincheck=false;\r\n }\r\n if (Chessboard.blacksTurn==true) {\r\n Chessboard.blackincheck=false;\r\n }\r\n }\r\n\r\n\r\n\r\n Chessboard.chessBoard[newRow][newCol].setPiece(Chessboard.chessBoard[oldRow][oldCol].getPiece());\r\n Chessboard.chessBoard[oldRow][oldCol].setPiece(null);\r\n Chessboard.chessBoard[newRow][newCol].getPiece().moved();\r\n\r\n if (King.isOpponentKingInCheck(newRow, newCol)){\r\n if (Chessboard.whitesTurn==true) {\r\n Chessboard.blackincheck=true;\r\n }\r\n if (Chessboard.blacksTurn==true) {\r\n Chessboard.whiteincheck=true;\r\n }\r\n }\r\n else {\r\n if (Chessboard.whitesTurn==true) {\r\n Chessboard.blackincheck=false;\r\n }\r\n if (Chessboard.blacksTurn==true) {\r\n Chessboard.whiteincheck=false;\r\n }\r\n }\r\n if(King.isOpponentKinginCheckmate(newRow, newCol)) {\r\n Chessboard.checkMate=true;\r\n }\r\n\r\n\r\n Pawn.r = -1;\r\n Pawn.c = -1;\r\n return true;\r\n }\r\n return false;\r\n }", "public LinkedList<Move> getPossibleMoves() {\n\t\tAIPossibleMoves.clear();\n\t\tint xOrigin = 0, yOrigin = 0, xMove1 = 0, xMove2 = 0, yMove1 = 0, yMove2 = 0;\n\t\tMove move = null;\t\n\t\t\tint type = 0;\n\t\t\tfor(Checker checker: model.whitePieces) {\n\t\t\t\t\n\t\t\t\txOrigin = checker.getCurrentXPosition();\n\t\t\t\tyOrigin = checker.getCurrentYPosition();\n\t\t\t\txMove1 = (checker.getCurrentXPosition() - 1);\n\t\t\t\txMove2 = (checker.getCurrentXPosition() + 1);\n\t\t\t\tyMove1 = (checker.getCurrentYPosition() - 1);\n\t\t\t\tyMove2 = (checker.getCurrentYPosition() + 1);\n\t\t\t\ttype = checker.getType();\n\t\t\t\tswitch(type) {\n\t\t\t\tcase 2:\n\n\t\t\t\t\tif((xMove1 < 0) || (yMove1 <0)) {\n\t\t\t\t\t//\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\tif(isMoveValid(xOrigin,yOrigin, xMove1, yMove1, false, false )) {\n\t\t\t\t\t\tif(!isSpaceTaken(xMove1,yMove1)) {\n\t\t\t\t\t\t\t//System.out.println(\"Space is not Taken\");\n\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove1, yMove1);\n\t\t\t\t\t\t\tAIPossibleMoves.add(move);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(isPieceEnemy(xMove1,yMove1,checker,2)) {\n\t\t\t\t\t\t\t\tif(isJumpValid(xOrigin, yOrigin, xMove1, yMove1, false, false)) {\n\t\t\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove1, yMove1);\n\t\t\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n \n\t\t\t\t\tif((xMove2 > 7) || (yMove1 < 0)) {\n\t\t\t\t\t//\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\n\t\t\t\t\tif(isMoveValid(xOrigin,yOrigin, xMove2, yMove1, true, false )) {\n\t\t\t\t\t\tif(!isSpaceTaken(xMove2,yMove1)) {\n\t\t\t\t\t\t\t// System.out.println(\"Space is not Taken\");\n\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove2, yMove1);\n\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(isPieceEnemy(xMove2,yMove1,checker,2)) {\n\t\t\t\t\t\t\t\tif(isJumpValid(xOrigin, yOrigin, xMove2, yMove1, true, false)) {\n\t\t\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove2, yMove1);\n\t\t\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\t\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t\t\t\n\t\t\t\tcase 4:\n\t\t\t\t\t//Moving up and left isMovingRight,IsMovingDown\n\t\t\t\t\tif((xMove1 <0) || (yMove1 < 0)) {\n\t\t\t\t\t\t//continue;\n\t\t\t\t\t} else {\n\t\t\t\t\tif(isMoveValid(xOrigin,yOrigin, xMove1, yMove1, false, false )) {\n\t\t\t\t\t\tif(!isSpaceTaken(xMove1,yMove1)) {\n\t\t\t\t\t\t//\tSystem.out.println(\"Space is not Taken\");\n\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove1, yMove1);\n\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(isPieceEnemy(xMove1,yMove1,checker,2)) {\n\t\t\t\t\t\t\t\tif(isJumpValid(xOrigin, yOrigin, xMove1, yMove1, false, false)) {\n\t\t\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove1, yMove1);\n\t\t\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif((xMove2 > 7) || (yMove1 < 0)) {\n\t\t\t\t\t//continue;\n\t\t\t\t} else {\n\t\t\t\t\t//moving up and right\n\t\t\t\t\tif(isMoveValid(xOrigin,yOrigin, xMove2, yMove1, true, false )) {\n\t\t\t\t\t\tif(!isSpaceTaken(xMove2,yMove1)) {\n\t\t\t\t\t\t//\tSystem.out.println(\"Space is not Taken\");\n\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove2, yMove1);\n\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(isPieceEnemy(xMove2,yMove1,checker,2)) {\n\t\t\t\t\t\t\t\tif(isJumpValid(xOrigin, yOrigin, xMove2, yMove1, true, false)) {\n\t\t\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove2, yMove1);\n\t\t\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif((xMove1 < 0) || (yMove2 > 7)) {\n\t\t\t\t//\tcontinue;\n\t\t\t\t} else {\n\t\t\t\t\t//moving down and left isMovingRight,IsMovingDown\n\t\t\t\t\tif(isMoveValid(xOrigin,yOrigin, xMove1, yMove2, false, true )) {\n\t\t\t\t\t\tif(!isSpaceTaken(xMove1,yMove2)) {\n\t\t\t\t\t\t//\tSystem.out.println(\"Space is not Taken\");\n\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove1, yMove2);\n\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(isPieceEnemy(xMove1,yMove2,checker,2)) {\n\t\t\t\t\t\t\t\tif(isJumpValid(xOrigin, yOrigin, xMove1, yMove2, false, true)) {\n\t\t\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove1, yMove2);\n\t\t\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif((xMove2 > 7) || (yMove2 > 7)) {\n\t\t\t\t\t//continue;\n\t\t\t\t} else {\n\t\t\t\t\n\t\t\t\t\t//moving down and right isMovingRight,IsMovingDown\n\t\t\t\t\tif(isMoveValid(xOrigin,yOrigin, xMove2, yMove2, true, true )) {\n\t\t\t\t\t\tif(!isSpaceTaken(xMove2,yMove2)) {\n\t\t\t\t\t\t//\tSystem.out.println(\"Space is not Taken\");\n\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove2, yMove2);\n\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif(isPieceEnemy(xMove2,yMove2,checker,2)) {\n\t\t\t\t\t\t\t\tif(isJumpValid(xOrigin, yOrigin, xMove2, yMove2, true, true)) {\n\t\t\t\t\t\t\t\t\tmove = new Move(xOrigin, yOrigin, xMove2, yMove2);\n\t\t\t\t\t\t\t\t\tAIPossibleMoves.add(move);\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\tbreak;\t\n\t\t\t\t}\t\n\t\t\t\n\t\t\t}\n\n\t\t\treturn AIPossibleMoves;\n\t\t\t\n\t\t}", "@Test\n public void isMoveActionLegalFor()\n {\n // Setup.\n final CheckersGameInjector injector = new CheckersGameInjector();\n final List<Agent> agents = createAgents(injector);\n final CheckersEnvironment environment = createEnvironment(injector, agents);\n final CheckersAdjudicator adjudicator = injector.injectAdjudicator();\n\n // Agent white can move his token to an adjacent empty space.\n assertTrue(adjudicator.isMoveActionLegalFor(environment, CheckersTeam.WHITE, CheckersPosition.P09,\n CheckersPosition.P13));\n\n // Agent white cannot move backwards.\n assertFalse(adjudicator.isMoveActionLegalFor(environment, CheckersTeam.WHITE, CheckersPosition.P09,\n CheckersPosition.P05));\n\n // Agent white cannot move to an occupied space.\n assertFalse(adjudicator.isMoveActionLegalFor(environment, CheckersTeam.WHITE, CheckersPosition.P04,\n CheckersPosition.P08));\n\n // Agent white cannot move a red token.\n assertFalse(adjudicator.isMoveActionLegalFor(environment, CheckersTeam.WHITE, CheckersPosition.P21,\n CheckersPosition.P17));\n\n // Agent white cannot move too far.\n assertFalse(adjudicator.isMoveActionLegalFor(environment, CheckersTeam.WHITE, CheckersPosition.P09,\n CheckersPosition.P18));\n }", "public boolean CheckMate(Board b, Player p, boolean check) {\n int WhiteKingx = WhiteKing(b)[0];\r\n int WhiteKingy = WhiteKing(b)[1];\r\n int BlackKingx = BlackKing(b)[0];\r\n int BlackKingy = BlackKing(b)[1];\r\n\r\n if (check && p.getColor()) {\r\n //currently in check and color is white\r\n for (int horizontal = -1; horizontal < 2; horizontal++) {\r\n for (int vertical = -1; vertical < 2; vertical++) {\r\n if (b.blocks[WhiteKingx][WhiteKingy].getPiece().ValidMove(b.blocks, WhiteKingx, WhiteKingy, WhiteKingx + horizontal, WhiteKingy + vertical)) {\r\n /* Check which blocks the king can move to.\r\n * If the king can move, check if that block still puts the king on check\r\n * If all of them yield check, then see if there is a piece that can move to prevent the check\r\n */\r\n b.move(WhiteKingx, WhiteKingy, WhiteKingx + horizontal, WhiteKingy + vertical);\r\n if(!CheckChecker(b, p)) {\r\n b.move(WhiteKingx + horizontal, WhiteKingy + vertical, WhiteKingx, WhiteKingy);\r\n return false;\r\n }\r\n b.move(WhiteKingx + horizontal, WhiteKingy + vertical, WhiteKingx, WhiteKingy);\r\n }\r\n }\r\n }\r\n }\r\n if (check && !p.getColor()) {\r\n for(int horizontal = -1; horizontal < 2; horizontal++) {\r\n for(int vertical = -1; vertical < 2; vertical ++) {\r\n if(b.blocks[BlackKingx][BlackKingy].getPiece().ValidMove(b.blocks, BlackKingx, BlackKingy, BlackKingx + horizontal, BlackKingy + vertical)) {\r\n b.move(BlackKingx, BlackKingy, BlackKingx + horizontal, BlackKingy + vertical);\r\n if(!CheckChecker(b, p)) {\r\n b.move(BlackKingx + horizontal, BlackKingy + vertical, BlackKingx, BlackKingy);\r\n return false;\r\n }\r\n b.move(BlackKingx + horizontal, BlackKingy + vertical, BlackKingx, BlackKingy);\r\n }\r\n }\r\n }\r\n }\r\n return true;\r\n }", "private boolean canGetOutOfCheck(boolean[][] moves, Piece piece) {\r\n\t\tfor (int i = 0; i < this.SIZE; i++) {\r\n\t\t\tfor (int j = 0; j < this.SIZE; j++) {\r\n\t\t\t\tif(checkMove(moves, piece, i, j)) {\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn false;\r\n\t}", "public void tryMove() {\n if(!currentPlayer.getHasPlayed()){\n if (!currentPlayer.isEmployed()) {\n String destStr = chooseNeighbor();\n\n currentPlayer.moveTo(destStr, getBoardSet(destStr));\n if(currentPlayer.getLocation().getFlipStage() == 0){\n currentPlayer.getLocation().flipSet();\n }\n refreshPlayerPanel();\n }\n else {\n view.showPopUp(currentPlayer.isComputer(), \"Since you are employed in a role, you cannot move but you can act or rehearse if you have not already\");\n }\n }\n else{ \n view.showPopUp(currentPlayer.isComputer(), \"You've already moved, rehearsed or acted this turn. Try a different command or click `end turn` to end turn your turn.\");\n }\n view.updateSidePanel(playerArray);\n }", "public MoveType isMoveValid(int newIndexX, int newIndexY, int oldIndexX, int oldIndexY) {\n\n if (!isFieldPlaceable(newIndexX, newIndexY) || isFieldOccupied(newIndexX, newIndexY)) {\n return INVALID;\n }\n\n if (bestPieceFound) {\n if (bestPieceToMove != board[oldIndexY][oldIndexX].getPiece()) {\n //check if chosen piece is the best piece to move\n return INVALID;\n }\n if (bestMoveFound) {\n int yDir = (newIndexY - oldIndexY < 0) ? -1 : 1;\n int xDir = (newIndexX - oldIndexX < 0) ? -1 : 1;\n if (xDir != bestMoveDirectionX || yDir != bestMoveDirectionY) {\n return INVALID;\n }\n }\n }\n\n if (board[oldIndexY][oldIndexX].getPiece().getType().equals(PieceType.MEN)) {\n if (abs(newIndexY - oldIndexY) == 2) {\n //kill attempt\n int enemyY = newIndexY - ((newIndexY - oldIndexY) / 2);\n int enemyX = newIndexX - ((newIndexX - oldIndexX) / 2);\n\n if (isEnemyKilled(enemyX, enemyY, board)) {\n //check if kill will be executed properly\n board[enemyY][enemyX].setPiece(null);\n if (controller.killEnemy(enemyX, enemyY)) {\n //update view after killing\n if (round == PieceColor.LIGHT) {\n darkCounter -= 1;\n } else {\n lightCounter -= 1;\n }\n return KILL;\n } else {\n return INVALID;\n }\n }\n }\n\n if (board[oldIndexY][oldIndexX].getPiece().getMoveDirection() == (oldIndexY - newIndexY)) {\n //check if men moves in right direction\n if (killAvailable) {\n //if user execute normal move when kill is available, move is invalid\n return INVALID;\n }\n return MoveType.NORMAL;\n }\n } else if (board[oldIndexY][oldIndexX].getPiece().getType().equals(PieceType.KING)) {\n\n if (abs(newIndexX - oldIndexX) == abs(newIndexY - oldIndexY)) {\n //check if king moves diagonally\n\n int yDir = (newIndexY - oldIndexY < 0) ? -1 : 1;\n int xDir = (newIndexX - oldIndexX < 0) ? -1 : 1;\n\n if (piecesInKingsWay(oldIndexX, oldIndexY, newIndexX, newIndexY, xDir, yDir) == 1)\n //check if king is able to kill piece in its way\n if (isEnemyKilled(newIndexX - xDir, newIndexY - yDir, board)) {\n //check if king is placed just behind piece and try to kill\n return killUsingKing(newIndexX, newIndexY, xDir, yDir, board);\n } else {\n return INVALID;\n }\n else {\n if (piecesInKingsWay(oldIndexX, oldIndexY, newIndexX, newIndexY, xDir, yDir) > 1) {\n //if more pieces in kings way, it cant move over them\n return INVALID;\n }\n }\n\n\n if (newIndexX != oldIndexX && newIndexY != oldIndexY) {\n //every other possibility is checked, if place is changed it is normal move\n if (killAvailable) {\n return INVALID;\n }\n return MoveType.NORMAL;\n }\n }\n }\n if (newIndexX == oldIndexX && newIndexY == oldIndexY) {\n return MoveType.NONE;\n }\n return MoveType.INVALID;\n }", "public Move validateLastMove() {\n Move move = board.getLastMove();\n int movevalue = move.getValue() == 1 ? -1 : 1;\n PieceColor nextplayer = Utility.convertCountToPlayerPiece(movevalue);\n BoardState playerState = (nextplayer == PieceColor.RED ? BoardState.REDWON : BoardState.YELLOWWON);\n BoardState state;\n Move newmove;\n // simulate opponent next move \n for (int column = 0, colSize = board.size()[1]; column < colSize; column++) {\n if (move.getColIndex() != column) {\n try {\n newmove = board.droppiece(column, nextplayer);\n state = board.getState(movevalue);\n board.undoLastMove();\n if (state != BoardState.STILL_PLAYING && playerState == state) {\n return newmove;\n }\n } catch (MoveException e) {\n //ignore\n }\n }\n }\n return null;\n }", "private boolean canMove() {\n return !(bestMove[0].getX() == bestMove[1].getX() && bestMove[0].getY() == bestMove[1].getY());\n }", "public boolean isValidMove(int x, int y) {\n\n\t\t//A move is invalid\n\t\t// 1 - the cell that someone is trying to move to, is not empty\n\t\t// 2 - the co-ordinate of the cell is out of bounds of our double board array\n\n\t\t// First check if move is valid\n\t\tif (!isCellEmpty(x,y)) {\n\n\t\t\treturn false; // invalid move case 1\n\n\t\t} else if (!Utility.isWithinRange(x,0,2) || !Utility.isWithinRange(y,0,2)) {\n\n\t\t\treturn false; // invalid move case 2 \n\t\t\t\n\t\t}\n\n\t\treturn true;\n\n\t}", "public List<String> legalMoves() {\n List<String> result = new ArrayList<>();\n for (int col = 1; col < _board.length + 1; col += 1) {\n for (int row = 1; row < _board.length + 1; row += 1) {\n String move = row + \",\" + col;\n if (isLegal(move)) {\n result.add(move);\n }\n }\n }\n return result;\n }", "private boolean check(boolean isWhite) {\n Tile kingTile = null;\n ArrayList<Position> opponentMoves = new ArrayList<>();\n // find king's tile and populate opponent moves\n for (Tile[] t : this.board) {\n for (Tile tile : t) {\n if (tile.piece instanceof King && tile.piece.isWhite() == isWhite) {\n kingTile = tile;\n }\n if (tile.hasPiece && tile.piece.isWhite() != isWhite) {\n for(Position move : tile.piece.getLegalMoves()) opponentMoves.add(move);\n }\n }\n }\n // compare every position with king's position\n for (Position opponentMove : opponentMoves) {\n if (opponentMove.equals(kingTile.position)) {\n return true;\n }\n }\n return false;\n }", "public void checkWinner(){\n \n if ((board[0][0] == 'X' && board[0][1] == 'X' && board[0][2] == 'X')||(board[1][0] == 'X' && board[1][1] == 'X' && board[1][2] == 'X')||(board[2][0] == 'X' && board[2][1] == 'X' && board[2][2] == 'X')){\n winner();\n }\n else if ((board[0][0] == 'X' && board[1][0] == 'X' && board[2][0] == 'X')||(board[0][1] == 'X' && board[1][1] == 'X' && board[2][1] == 'X')||(board[0][2] == 'X' && board[1][2] == 'X' && board[2][2] == 'X')){\n winner();\n }\n else if ((board[0][0] == 'X' && board[1][1] == 'X' && board[2][2] == 'X')||(board[0][2] == 'X' && board[1][1] == 'X' && board[2][0] == 'X')){\n winner();\n }\n else if ((board[0][0] == 'O' && board[0][1] == 'O' && board[0][2] == 'O')||(board[1][0] == 'O' && board[1][1] == 'O' && board[1][2] == 'O')||(board[2][0] == 'O' && board[2][1] == 'O' && board[2][2] == 'O')){\n winner();\n }\n else if ((board[0][0] == 'O' && board[1][0] == 'O' && board[2][0] == 'O')||(board[0][1] == 'O' && board[1][1] == 'O' && board[2][1] == 'O')||(board[0][2] == 'O' && board[1][2] == 'O' && board[2][2] == 'O')){\n winner();\n }\n else if ((board[0][0] == 'O' && board[1][1] == 'O' && board[2][2] == 'O')||(board[0][2] == 'O' && board[1][1] == 'O' && board[2][0] == 'O')){\n winner();\n }\n \n }", "public static boolean checkWinner(){\n \n if(board[0][0] == board[0][1] && board[0][1] == board[0][2] && (board[0][0] == 'x' || board [0][0] == 'o'))\n return true;\n else if(board[1][0] == board[1][1] && board[1][1] == board[1][2] && (board[1][0] == 'x' || board[1][0] == 'o'))\n return true;\n else if(board[2][0] == board[2][1] && board[2][1] == board[2][2] && (board[2][0] == 'x' || board[2][0] == 'o'))\n return true;\n else if(board[0][0] == board[1][0] && board[1][0] == board[2][0] && (board[0][0] == 'x' || board[0][0] == 'o'))\n return true;\n else if(board[0][1] == board[1][1] && board[1][1] == board[2][1] && (board[0][1] == 'x' || board[0][1] == 'o'))\n return true;\n else if(board[0][2] == board[1][2] && board[1][2] == board[2][2] && (board[0][2] == 'x' || board[0][2] == 'o'))\n return true;\n else if(board[0][0] == board[1][1] && board[1][1] == board[2][2] && (board[0][0] == 'x' || board[0][0] == 'o'))\n return true;\n else if(board[0][2] == board[1][1] && board[1][1] == board[2][0] && (board[0][2] == 'x' || board[0][2] == 'o'))\n return true;\n else\n return false;\n \n }", "private boolean isThereValidMove() {\n\t\treturn true;\n\t}", "public void isMoveLegal(int row, int col) \r\n\t\t\tthrows IllegalMoveException {\r\n\t\tif(row < 0 || row > 7 || col < 0 || col > 7){\r\n\t\t\tthrow new IllegalMoveException();\r\n\t\t}\r\n\t}", "public boolean move (int x,int y, OthelloPiece colour){\n boolean valid = false;\n if(move(x,y,VALID_MOVE_3,VALID_MOVE_2,colour)) valid=true;\n if(move(x,y,VALID_MOVE_3,VALID_MOVE_3,colour)) valid=true;\n if(move(x,y,VALID_MOVE_3,VALID_MOVE_1,colour)) valid=true;\n if(move(x,y,VALID_MOVE_2,VALID_MOVE_3,colour)) valid=true;\n if(move(x,y,VALID_MOVE_2,VALID_MOVE_1,colour)) valid=true;\n if(move(x,y,VALID_MOVE_1,VALID_MOVE_2,colour)) valid=true;\n if(move(x,y,VALID_MOVE_1,VALID_MOVE_3,colour)) valid=true;\n if(move(x,y,VALID_MOVE_1,VALID_MOVE_1,colour)) valid=true;\n setThePieces();\n if(valid){\n m_PieceCount++;\n }\n return (valid);\n }", "public boolean canMove(int nrow, int ncol){\n\t//# means hasn't been visited; o means has been visited\n\tif(board[nrow][ncol] == ' ' ||\n\t board[nrow][ncol] == 'E'){\n\t return true;\n\t}else{\n\t return false;\n\t}\n\t/* \n\t if(board[nrow][ncol] != ' '){\n\t return false;\n\t }else{\n\t return true;\n\t }\n\t*/\n }", "private boolean anyMove (int x,int y, OthelloPiece colour){\n boolean valid = false;\n if(move(x,y,VALID_MOVE_3,VALID_MOVE_2,colour)) valid=true;\n if(move(x,y,VALID_MOVE_3,VALID_MOVE_3,colour)) valid=true;\n if(move(x,y,VALID_MOVE_3,VALID_MOVE_1,colour)) valid=true;\n if(move(x,y,VALID_MOVE_2,VALID_MOVE_3,colour)) valid=true;\n if(move(x,y,VALID_MOVE_2,VALID_MOVE_1,colour)) valid=true;\n if(move(x,y,VALID_MOVE_1,VALID_MOVE_2,colour)) valid=true;\n if(move(x,y,VALID_MOVE_1,VALID_MOVE_3,colour)) valid=true;\n if(move(x,y,VALID_MOVE_1,VALID_MOVE_1,colour)) valid=true;\n return (valid);\n }", "private int Win_Move() {\n\t\tfinal int POSSIBLE_WIN = 8;\n\t\tint move = NO_MOVE;\n\t\tif(( gameBoard[TOP_LEFT] + gameBoard[TOP_CENTER] + gameBoard[TOP_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[TOP_CENTER] == EMPTY){\n\t\t\t\tmove = TOP_CENTER;\n\t\t\t}else if (gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[CTR_LEFT] + gameBoard[CTR_CENTER] + gameBoard[CTR_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[CTR_LEFT] == EMPTY){\n\t\t\t\tmove = CTR_LEFT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[CTR_RIGHT] == EMPTY){\n\t\t\t\tmove = CTR_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[BTM_LEFT] + gameBoard[BTM_CENTER] + gameBoard[BTM_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}else if (gameBoard[BTM_CENTER] == EMPTY){\n\t\t\t\tmove = BTM_CENTER;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_LEFT] + gameBoard[CTR_LEFT] + gameBoard[BTM_LEFT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[CTR_LEFT] == EMPTY){\n\t\t\t\tmove = CTR_LEFT;\n\t\t\t}else if (gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_CENTER] + gameBoard[CTR_CENTER] + gameBoard[BTM_CENTER]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_CENTER] == EMPTY){\n\t\t\t\tmove = TOP_CENTER;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_CENTER] == EMPTY){\n\t\t\t\tmove = BTM_CENTER;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_RIGHT] + gameBoard[CTR_RIGHT] + gameBoard[BTM_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}else if (gameBoard[CTR_RIGHT] == EMPTY){\n\t\t\t\tmove = CTR_RIGHT;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_LEFT] + gameBoard[CTR_CENTER] + gameBoard[BTM_RIGHT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_LEFT] == EMPTY){\n\t\t\t\tmove = TOP_LEFT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_RIGHT] == EMPTY){\n\t\t\t\tmove = BTM_RIGHT;\n\t\t\t}\n\t\t}else if((gameBoard[TOP_RIGHT] + gameBoard[CTR_CENTER] + gameBoard[BTM_LEFT]) == POSSIBLE_WIN){\n\t\t\tif(gameBoard[TOP_RIGHT] == EMPTY){\n\t\t\t\tmove = TOP_RIGHT;\n\t\t\t}else if (gameBoard[CTR_CENTER] == EMPTY){\n\t\t\t\tmove = CTR_CENTER;\n\t\t\t}else if (gameBoard[BTM_LEFT] == EMPTY){\n\t\t\t\tmove = BTM_LEFT;\n\t\t\t}\n\t\t}\n\t\treturn move;\n\t}", "public void makeMove(Move m) {\n \tPieceColor moved = m.getSource().getColor();\n\n \t//before the move is made, record the move in the movelist\n \tupdateMoveList(m);\n \t\n \t//store locations\n \tint sx = m.getSource().getLocation().getX();\n \tint sy = m.getSource().getLocation().getY();\n \tint dx = m.getDest().getLocation().getX();\n \tint dy = m.getDest().getLocation().getY();\n \tString name_moved = m.getSource().getName();\n \t\n \t//store new king location if it moved\n \tif(name_moved.equals(\"King\")) {\n \t\tif(moved == PieceColor.White) {\n \t\t\twKing = m.getDest().getLocation();\n \t\t\t\n \t\t\t//remove castle rights on both sides\n \t\t\tcastle[0] = false;\n \t\t\tcastle[1] = false;\n \t\t}\n \t\telse if(moved == PieceColor.Black) {\n \t\t\tbKing = m.getDest().getLocation();\n \t\t\t\n \t\t\t//remove castle rights on both sides\n \t\t\tcastle[2] = false;\n \t\t\tcastle[3] = false;\n \t\t}\n \t\telse System.exit(0);\n \t}\n \t\n \t//rook check for castling rights\n \tif(name_moved.equals(\"Rook\")) {\n \t\tif(moved == PieceColor.White) {\n \t\t\tif(sx == 0 && sy == 0) removeCastle(moved, false);\n \t\t\tif(sx == 7 && sy == 0) removeCastle(moved, true);\n \t\t}\n \t\t\n \t\telse if(moved == PieceColor.Black) {\n \t\t\tif(sx == 0 && sy == 7) removeCastle(moved, false);\n \t\t\tif(sx == 7 && sy == 7) removeCastle(moved, true);\n \t\t}\n \t}\n \t\n \tPiece temp = getPiece(sx, sy);\n \t\n \tsetPiece(sx, sy, new NoPiece(sx, sy));\n \t\n \tif(temp.getName().equals(\"Pawn\") && ((Pawn)temp).getPromo() == dy) {\n \t\ttemp = new Queen(dx, dy, temp.getColor(), this);\n \t}\n \t\n \t\n \ttemp.setLocation(new Square(dx, dy));\n \t\n \t//check for en passant\n \tif(name_moved.equals(\"Pawn\")) {\n \t\tint loc = ((Pawn)temp).advance();\n \t\t((Pawn)temp).setMoved(moveList.size());\n \t\t\n \t\t//only a valid en passant move if the pawn moves diagonally\n \t\t//and the destination square is empty\n \t\tif(sx != dx && getPiece(dx, dy).getName().equals(\"None\")) {\n \t\t\tsetPiece(dx, dy-loc, new NoPiece(dx, dy-loc));\n \t\t}\n \t}\n \t\n \tsetPiece(dx, dy, temp);\n \t\n \tif(turn == PieceColor.White) turn = PieceColor.Black;\n \telse turn = PieceColor.White;\n \t\n \t//check if the move was a castle\n \tif(name_moved.equals(\"King\")) {\n \t\t\n \t\tif(moved == PieceColor.White) { \n\t \t\t//if king moved positive x, then moved king side\n\t \t\tif(dx - sx == 2) {\n\t \t\t\ttemp = getPiece(7, 0);\n\t \t\t\tsetPiece(7, 0, new NoPiece(7, 0));\n\t \t\t\t\n\t \t\t\ttemp.setLocation(new Square(5,0));\n\t \t\t\tsetPiece(5, 0, temp);\n\t \t\t}\n\t \t\t\n\t \t\telse if(sx - dx == 2) {\n\t \t\t\ttemp = getPiece(0, 0);\n\t \t\t\tsetPiece(0, 0, new NoPiece(0, 0));\n\t \t\t\t\n\t \t\t\ttemp.setLocation(new Square(3, 0));\n\t \t\t\tsetPiece(3, 0, temp);\n\t \t\t}\n \t\t}\n \t\t\n \t\tif(moved == PieceColor.Black) { \n\t \t\t//if king moved positive x, then moved king side\n\t \t\tif(dx - sx == 2) {\n\t \t\t\ttemp = getPiece(7, 7);\n\t \t\t\tsetPiece(7, 7, new NoPiece(7, 7));\n\t \t\t\t\n\t \t\t\ttemp.setLocation(new Square(5, 7));\n\t \t\t\tsetPiece(5, 7, temp);\n\t \t\t}\n\t \t\t\n\t \t\telse if(sx - dx == 2) {\n\t \t\t\ttemp = getPiece(0, 7);\n\t \t\t\tsetPiece(0, 7, new NoPiece(0, 7));\n\t \t\t\t\n\t \t\t\ttemp.setLocation(new Square(3, 7));\n\t \t\t\tsetPiece(3, 7, temp);\n\t \t\t}\n \t\t}\n \t}\n }", "private boolean checkMoveOthers(Pieces piece, Coordinates from, Coordinates to) {\n\t\t\t\t\n\t\t/* \n\t\t *il pedone: \n\t\t * -può andare dritto sse davanti a se non ha pedine\n\t\t * -può andare obliquo sse in quelle posizioni ha una pedina avversaria da mangiare\n\t\t * \n\t\t */\n\t\tif (piece instanceof Pawn) {\n\t\t\tif (from.getY() == to.getY()) {\n\t\t\t\tif(chessboard.at(to) == null)\n\t\t\t\t\treturn true;\n\t\t\t\telse\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(chessboard.at(to) == null) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t\n\t\t//il cavallo salta le pedine nel mezzo\n\t\tif (piece instanceof Knight)\n\t\t\treturn true;\n\t\t\n\t\t//Oltre non andranno il: cavallo, il re ed il pedone.\n\t\t/*\n\t\t *Calcolo le posizioni che intercorrono tra il from ed il to escluse \n\t\t *ed per ogni posizione verifico se è vuota\n\t\t *-se in almeno una posizione c'è una pedina(non importa il colore), la mossa non è valida\n\t\t *-altrimenti, la strada è spianata quindi posso effettuare lo spostamento \n\t\t */\n\t\tArrayList<Coordinates> path = piece.getPath(from, to);\n\t\tfor (Coordinates coordinate : path) {\n\t\t\tif ( chessboard.at(coordinate) != null ){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}", "private void checkWinningMove(TicTacToeElement element,int x,int y) {\n int logicalSize = boardProperties.getBoardLength()-1;\r\n // Check column (only the one we just played)\r\n for(int i=0;i<=logicalSize;i++){\r\n if( gameState.getBoard()[x][i] != element.getValue()){\r\n break;\r\n }\r\n // Be sure to be at the last index\r\n if(i == logicalSize){\r\n gameState.setWinner(element);\r\n }\r\n\r\n }\r\n // Check row (only the one we just played)\r\n for(int i=0;i<=logicalSize;i++){\r\n if( gameState.getBoard()[i][y] != element.getValue()){\r\n break;\r\n }\r\n // Be sure to be at the last index\r\n if(i == logicalSize){\r\n gameState.setWinner(element);\r\n }\r\n }\r\n // Check diagonal\r\n // normal diagonal\r\n for(int i= 0;i<=logicalSize;i++){\r\n if( gameState.getBoard()[i][i] != element.getValue()){\r\n break;\r\n }\r\n // Be sure to be at the last index\r\n if(i == logicalSize){\r\n gameState.setWinner(element);\r\n }\r\n }\r\n // anti diagonal\r\n for(int i= 0;i<=logicalSize;i++){\r\n if( gameState.getBoard()[i][logicalSize-i] != element.getValue()){\r\n break;\r\n }\r\n //Be sure to be at the last index\r\n if(i == logicalSize){\r\n gameState.setWinner(element);\r\n }\r\n }\r\n // check draw\r\n if(gameState.getMoveCount() == Math.pow(logicalSize,2)-1){\r\n gameState.setDraw(true);\r\n }\r\n\r\n }", "public boolean makeMove(int row, int col)\n\t{\n\t\tboolean canMove = false;\n\t\tif(this.haveGame && isTurn)\n\t\t{\n\t\t\tif(board[row][col] == 0)\n\t\t\t{\n\t\t\t\tcanMove = true;\n\t\t\t\tboard[row][col] = piece;\n\t\t\t\t\n\t\t\t\tSocket controlSocket;\n\t\t\t\ttry {\n\t\t\t\t\tSystem.out.println(\"Setting up connection to: \" + opponent.getIpAddress());\n\t\t\t\t\tcontrolSocket = new Socket(opponent.getIpAddress(), Model.gameDataSocketNumber);\n\t\t\t\t\tObjectOutputStream toPeer = new ObjectOutputStream(controlSocket.getOutputStream());\n\t\t\t\t\tClientMessage c = new ClientMessage();\n\t\t\t\t\tc.setCommand(\"MOVE\");\n\t\t\t\t\tc.setRow(row);\n\t\t\t\t\tc.setColumn(col);\n\t\t\t\t\tc.setPiece(this.piece);\n\t\t\t\t\tc.setUser(new UserBean(this.hostName, this.userName, this.ipAddress));\n\t\t\t\t\t\n\t\t\t\t\ttoPeer.writeObject(c);\n\n\t\t\t\t\tcontrolSocket.close();\n\t\t\t\t\t\n\t\t\t\t} catch (IOException e) \n\t\t\t\t{\t\t\t\t\t\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t} \n\t\t\t}\n\t\t}\n\t\tthis.isTurn = false;\n\t\treturn canMove;\n\t}", "private boolean simulate(Piece p) {\n \tArrayList<Square> moves = p.getLegalMoves();\n \tSquare temp;\n \tMove m;\n \tPiece piece;\n \t\n \t//need to copy the board\n \tBoard copy = null;\n \t\n \tfor(int i = 0; i < moves.size(); i++) {\n \t\ttemp = moves.get(i);\n \t\tcopy = new Board();\n \t\tcopyBoard(copy);\n \t\tpiece = copy.getPiece(p.getLocation().getX(), p.getLocation().getY());\n \t\tm = new Move(piece, copy.getPiece(temp.getX(), temp.getY()));\n \t\tif(copy.tryMove(m)) {\n \t\t\tcopy.makeMove(m);\n \t\t\tif(!copy.isCheck(p.getColor())) return true;\n \t\t}\n \t}\n \t\n \treturn false;\n }", "public void AIMakeMove() {\n\t\t\n\t\tRandom randomizer = new Random();\n\t\tint index = randomizer.nextInt(AIPossibleMoves.size());\n\t\tMove move = AIPossibleMoves.get(index);\n\t\tChecker checker = model.findChecker(move.getxOrigin(), move.getyOrigin());\n\t\tint xChange = (move.getxOrigin() - move.getxMove());\n\t\tint yChange = (move.getyOrigin() - move.getyMove());\n\t\t\n\t\tint xMoveNew = 0;\n\t\tint yMoveNew = 0;\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\tif(board.getBoard()[move.getyMove()][move.getxMove()] == 0) {\n\t\t\t//do nothing\n\t\t} else {\n\t\t\t//moving down\n\t\t\tif(yChange < 0) {\n\t\t\t\t//moving right\n\t\t\t\tif(xChange < 0) {\n\t\t\t\t\tremoveTakenPiece(move.getxMove(), move.getyMove());\n\t\t\t\t\txMoveNew = move.getxMove() + 1;\n\t\t\t\t\tyMoveNew = move.getyMove() + 1;\n\t\t\t\t\tmove.setxMove(xMoveNew);\n\t\t\t\t\tmove.setyMove(yMoveNew);\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t} else {\n\t\t\t\t\t\n\t\t\t\t\t//moving left\n\t\t\t\t\t\n\t\t\t\t\tremoveTakenPiece(move.getxMove(), move.getyMove());\n\t\t\t\t\txMoveNew = move.getxMove() - 1;\n\t\t\t\t\tyMoveNew = move.getyMove() + 1;\n\t\t\t\t\tmove.setxMove(xMoveNew);\n\t\t\t\t\tmove.setyMove(yMoveNew);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t//moving up\n\t\t\t\tif(xChange < 0) {\n\t\t\t\t\t//moving right\n\t\t\t\t\tremoveTakenPiece(move.getxMove(), move.getyMove());\n\t\t\t\t\txMoveNew = move.getxMove() + 1;\n\t\t\t\t\tyMoveNew = move.getyMove() - 1;\n\t\t\t\t\tmove.setxMove(xMoveNew);\n\t\t\t\t\tmove.setyMove(yMoveNew);\n\t\t\t\t} else {\n\t\t\t\t\t//moving left \n\t\t\t\t\tremoveTakenPiece(move.getxMove(), move.getyMove());\n\t\t\t\t\txMoveNew = move.getxMove() - 1;\n\t\t\t\t\tyMoveNew = move.getyMove() - 1;\n\t\t\t\t\tmove.setxMove(xMoveNew);\n\t\t\t\t\tmove.setyMove(yMoveNew);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\t\n\t\t//System.out.println(\"New Move is: \" + xMoveNew + \",\" + yMoveNew);\n\t\tif(canBeKing(checker, move)) {\n\t\t\tchecker = convertToKing(checker, move);\n\t\t\tmodel.updateChecker(move, checker, 2);\n\t\t\t\n\t\t\tprintBoard();\n\t\t\tmodel.moves.add(move);\n\t\t\treturn;\n\t\t}\n\t\tmodel.updateChecker(move, checker, 2);\n\t//\tSystem.out.println(\"AI - DEBUGGING\");\n\t//\tSystem.out.println(\"Origin Piece: \" + move.getxOrigin() + \",\" + move.getyOrigin());\n\t//\tSystem.out.println(\"Move Position: \" + move.getxMove() + \",\" + move.getyMove());\n\t\tupdateBoard(move);\n\t\tmodel.moves.add(move);\n\t\tprintBoard();\n\t\t\n\t}", "public boolean validMove(ChessBoard board, Square from, Square to) {\r\n // check if piece killing his ally\r\n if(to.getPiece() != null){\r\n if (to.getPiece().isBlue() == this.isBlue()) {\r\n return false;\r\n }\r\n } \r\n\r\n int x = from.getX() - to.getX();\r\n int y = from.getY() - to.getY();\r\n \r\n if (x < 0 && Math.abs(x) == Math.abs(y) && y > 0){\r\n int j = from.getY()-1;\r\n for( int i = from.getX()+1 ; i < to.getX() ; i++){\r\n if (board.getBox(i,j).getPiece()!=null){\r\n return false;}\r\n j--;\r\n } \r\n return true;\r\n }\r\n else if(x > 0 && Math.abs(x) == Math.abs(y) && y > 0){\r\n int j = from.getY()-1;\r\n for( int i = from.getX()-1 ; i > to.getX() ; i--){\r\n if (board.getBox(i,j).getPiece()!=null){\r\n return false;}\r\n j--;\r\n }\r\n return true;\r\n }\r\n else if( x > 0 && Math.abs(x) == Math.abs(y) && y < 0){\r\n int j = from.getY()+1;\r\n for( int i = from.getX()-1 ; i > to.getX() ; i--){\r\n if (board.getBox(i,j).getPiece()!=null){\r\n return false;}\r\n j++;\r\n }\r\n return true; \r\n }\r\n else if (x < 0 && Math.abs(x) == Math.abs(y) && y < 0){\r\n int j = from.getY()+1;\r\n for( int i = from.getX()+1 ; i < to.getX() ; i++){\r\n if (board.getBox(i,j).getPiece()!=null){\r\n return false;}\r\n j++;\r\n } \r\n return true;\r\n }\r\n\r\n return false;\r\n }", "@Test\r\n public void callingMovePossibleOnTakingAPieceWhenYouAlreadyHaveAZeroShouldReturnFalse() {\n player1.movePiece(12, 11, board);\r\n\r\n // moving piece to zero\r\n player2.movePiece(13, 25, board);\r\n // give 2 move\r\n player2.movesLeft.moves.add(2);\r\n\r\n // Then\r\n assertFalse(player2.isMovePossible(13, 11, board));\r\n }", "@Override\n\tpublic boolean isLegalMove(Square newPosition) {\n\t\treturn false;\n\t}", "private boolean legalMove() {\n\n\t\t// empty landing spot\n\t\tif (tilePath.size() == 0) {\n\t\t\tdebug(\"illegal, empty landing spot\");\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!mBoard.tileIsEmpty(tilePath.get(tilePath.size() - 1))) {\n\t\t\tdebug(\"illegal, tile not empty\");\n\t\t\treturn false;\n\t\t}\n\n\t\t// start doesn't equal end\n\t\tif (tilePath.get(0).equals(tilePath.get(tilePath.size() - 1))) {\n\t\t\tdebug(\"illegal, start doesn't equal end\");\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}", "boolean isLegal(Square from, Square to) {\r\n Move move = mv(from, to);\r\n if (move == null) {\r\n System.out.println(\"Invalid Move\");\r\n return false;\r\n }\r\n if (to == kingPosition() || map.get(to) != EMPTY) {\r\n System.out.println(\"Invalid Move\");\r\n return false;\r\n }\r\n List<Move> legal = legalMoves(map.get(from));\r\n return legal.contains(move);\r\n }", "static List<Move> generateLegalMoves(Position pos) {\n\t\tList<Move> moves = new ArrayList<>();\n\n\t\t// for (int square : pos.pieces) {\n\t\t// \tif (pos.pieces.size() > 32) {\n\t\t// \t\tSystem.out.println(\"problem\" + pos.pieces.size());\n\t\t// \t}\n\t\t// \tif (pos.at(square) != 0 && Piece.isColor(pos.at(square), pos.toMove)) {\n\t\t// \t\tint piece = pos.at(square);\n\t\t// \t\tint name = Piece.name(piece);\n\t\t// \t\tif (name == Piece.Pawn) {\n\t\t// \t\t\tint step = pos.toMove == 'w' ? MoveData.Up : MoveData.Down;\n\t\t// \t\t\tif (square + step >= 0 && square + step < 64) {\n\t\t// \t\t\t\t// 1 square\n\t\t// \t\t\t\tif (pos.board.squares[square + step] == 0) {\n\t\t// \t\t\t\t\tif ((pos.toMove == 'w' && square >= 48) || (pos.toMove == 'b' && square <= 15)) {\n\t\t// \t\t\t\t\t\tmoves.add(new Move(square, square + step, 'q'));\n\t\t// \t\t\t\t\t\tmoves.add(new Move(square, square + step, 'b'));\n\t\t// \t\t\t\t\t\tmoves.add(new Move(square, square + step, 'n'));\n\t\t// \t\t\t\t\t\tmoves.add(new Move(square, square + step, 'r'));\n\t\t// \t\t\t\t\t}\n\t\t// \t\t\t\t\telse {\n\t\t// \t\t\t\t\t\tmoves.add(new Move(square, square + step));\n\t\t// \t\t\t\t\t}\t\t\t\t\t\t\t\n\t\t// \t\t\t\t}\n\t\t// \t\t\t\t// 2 squares\n\t\t// \t\t\t\tif ((square < 16 && pos.toMove == 'w') || square > 47 && pos.toMove == 'b') {\n\t\t// \t\t\t\t\tif (pos.board.squares[square + 2*step] == 0 && pos.board.squares[square + step] == 0) {\n\t\t// \t\t\t\t\t\tmoves.add(new Move(square, square + 2*step));\n\t\t// \t\t\t\t\t}\n\t\t// \t\t\t\t}\t\n\t\t// \t\t\t\t// capture\n\t\t// \t\t\t\t// right\n\t\t// \t\t\t\tif (MoveData.DistanceToEdge[square][3] > 0) {\n\t\t// \t\t\t\t\tint target = square + step + 1;\t\t\t\t\t\t\t\n\t\t// \t\t\t\t\tif (Piece.isColor(pos.board.squares[target], Opposite(pos.toMove))) {\t\t\t\t\t\t\t\t\n\t\t// \t\t\t\t\t\tif ((pos.toMove == 'w' && square >= 48) || (pos.toMove == 'b' && square <= 15)) {\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target, 'q'));\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target, 'b'));\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target, 'n'));\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target, 'r'));\n\t\t// \t\t\t\t\t\t}\n\t\t// \t\t\t\t\t\telse {\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target));\n\t\t// \t\t\t\t\t\t}\t\t\t\n\t\t// \t\t\t\t\t} \n\t\t// \t\t\t\t\telse if (target == pos.enPassantTarget) {\n\t\t// \t\t\t\t\t\tif ((pos.toMove == 'w' && target > 32) || (pos.toMove == 'b' && target < 24)) {\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target));\n\t\t// \t\t\t\t\t\t}\n\t\t// \t\t\t\t\t}\n\t\t// \t\t\t\t}\n\t\t// \t\t\t\t// left\n\t\t// \t\t\t\tif (MoveData.DistanceToEdge[square][2] > 0) {\n\t\t// \t\t\t\t\tint target = square + step - 1;\n\t\t// \t\t\t\t\tif (Piece.isColor(pos.board.squares[target], Opposite(pos.toMove))) {\n\t\t// \t\t\t\t\t\tif ((pos.toMove == 'w' && square >= 48) || (pos.toMove == 'b' && square <= 15)) {\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target, 'q'));\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target, 'b'));\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target, 'n'));\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target, 'r'));\n\t\t// \t\t\t\t\t\t}\n\t\t// \t\t\t\t\t\telse {\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target));\n\t\t// \t\t\t\t\t\t}\t\t\t\n\t\t// \t\t\t\t\t}\n\t\t// \t\t\t\t\telse if (target == pos.enPassantTarget) {\n\t\t// \t\t\t\t\t\tif ((pos.toMove == 'w' && target > 32) || (pos.toMove == 'b' && target < 24)) {\n\t\t// \t\t\t\t\t\t\tmoves.add(new Move(square, target));\n\t\t// \t\t\t\t\t\t}\n\t\t// \t\t\t\t\t}\n\t\t// \t\t\t\t}\t\n\t\t// \t\t\t}\t\t\t\t\t\t\t\t\n\t\t// \t\t}\n\t\t// \t\telse if (name == Piece.Knight) {\t\t\t\t\t\t\t\t\t\t\n\t\t// \t\t\tfor (int offset : MoveData.KnightOffsets.get(square)) {\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t// \t\t\t\tif (!Piece.isColor(pos.board.squares[square + offset], pos.toMove)) {\t\t\t\t\t\t\t\n\t\t// \t\t\t\t\tMove move = new Move(square, square + offset);\n\t\t// \t\t\t\t\tmoves.add(move);\t\t\t\t\t\t\t\n\t\t// \t\t\t\t}\t\n\t\t// \t\t\t}\t\t\t\t\t\n\t\t// \t\t}\n\t\t// \t\telse {\n\t\t// \t\t\tint dirStart = name == Piece.Bishop ? 4 : 0;\n\t\t// \t\t\tint dirEnd = name == Piece.Rook ? 4 : 8;\n\t\t// \t\t\tfor (int dir = dirStart; dir < dirEnd; dir++) {\n\t\t// \t\t\t\tint maxDist = MoveData.DistanceToEdge[square][dir];\n\t\t// \t\t\t\tint dist = name == Piece.King ? Math.min(1, maxDist) : maxDist;\n\n\t\t// \t\t\t\tfor (int steps = 1; steps <= dist; steps++) {\n\t\t// \t\t\t\t\tint squareIdx = square + steps * MoveData.Offsets[dir];\t\t\t\t\t\t\t\t\t\t\t\n\t\t// \t\t\t\t\tif (!Piece.isColor(pos.board.squares[squareIdx], pos.toMove)) {\n\t\t// \t\t\t\t\t\tmoves.add(new Move(square, squareIdx));\n\t\t// \t\t\t\t\t\tif (Piece.isColor(pos.board.squares[squareIdx], Opposite(pos.toMove))) {\n\t\t// \t\t\t\t\t\t\tbreak;\n\t\t// \t\t\t\t\t\t}\n\t\t// \t\t\t\t\t}\n\t\t// \t\t\t\t\telse {\n\t\t// \t\t\t\t\t\tbreak;\n\t\t// \t\t\t\t\t}\n\t\t// \t\t\t\t}\t\t\t\t\t\t\n\t\t// \t\t\t}\n\t\t// \t\t}\n\t\t// \t}\n\t\t// }\n\n\t\tfor (int i = 0; i < 64; i++) {\n\t\t\tif (pos.board.squares[i] != 0 && Piece.isColor(pos.board.squares[i], pos.toMove)) {\n\t\t\t\tint piece = pos.board.squares[i];\n\t\t\t\tint name = Piece.name(piece);\n\t\t\t\tif (name == Piece.Pawn) {\n\t\t\t\t\tint step = pos.toMove == 'w' ? MoveData.Up : MoveData.Down;\n\t\t\t\t\tif (i + step >= 0 && i + step < 64) {\n\t\t\t\t\t\t// 1 square\n\t\t\t\t\t\tif (pos.board.squares[i + step] == 0) {\n\t\t\t\t\t\t\tif ((pos.toMove == 'w' && i >= 48) || (pos.toMove == 'b' && i <= 15)) {\n\t\t\t\t\t\t\t\tmoves.add(new Move(i, i + step, 'q'));\n\t\t\t\t\t\t\t\tmoves.add(new Move(i, i + step, 'b'));\n\t\t\t\t\t\t\t\tmoves.add(new Move(i, i + step, 'n'));\n\t\t\t\t\t\t\t\tmoves.add(new Move(i, i + step, 'r'));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tmoves.add(new Move(i, i + step));\n\t\t\t\t\t\t\t}\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// 2 squares\n\t\t\t\t\t\tif ((i < 16 && pos.toMove == 'w') || i > 47 && pos.toMove == 'b') {\n\t\t\t\t\t\t\tif (pos.board.squares[i + 2*step] == 0 && pos.board.squares[i + step] == 0) {\n\t\t\t\t\t\t\t\tmoves.add(new Move(i, i + 2*step));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\t\n\t\t\t\t\t\t// capture\n\t\t\t\t\t\t// right\n\t\t\t\t\t\tif (MoveData.DistanceToEdge[i][3] > 0) {\n\t\t\t\t\t\t\tint target = i + step + 1;\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (Piece.isColor(pos.board.squares[target], Opposite(pos.toMove))) {\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tif ((pos.toMove == 'w' && i >= 48) || (pos.toMove == 'b' && i <= 15)) {\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target, 'q'));\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target, 'b'));\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target, 'n'));\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target, 'r'));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target));\n\t\t\t\t\t\t\t\t}\t\t\t\n\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\telse if (target == pos.enPassantTarget) {\n\t\t\t\t\t\t\t\tif ((pos.toMove == 'w' && target > 32) || (pos.toMove == 'b' && target < 24)) {\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// left\n\t\t\t\t\t\tif (MoveData.DistanceToEdge[i][2] > 0) {\n\t\t\t\t\t\t\tint target = i + step - 1;\n\t\t\t\t\t\t\tif (Piece.isColor(pos.board.squares[target], Opposite(pos.toMove))) {\n\t\t\t\t\t\t\t\tif ((pos.toMove == 'w' && i >= 48) || (pos.toMove == 'b' && i <= 15)) {\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target, 'q'));\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target, 'b'));\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target, 'n'));\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target, 'r'));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target));\n\t\t\t\t\t\t\t\t}\t\t\t\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (target == pos.enPassantTarget) {\n\t\t\t\t\t\t\t\tif ((pos.toMove == 'w' && target > 32) || (pos.toMove == 'b' && target < 24)) {\n\t\t\t\t\t\t\t\t\tmoves.add(new Move(i, target));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\t\n\t\t\t\t\t}\t\t\t\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\telse if (name == Piece.Knight) {\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tfor (int offset : MoveData.KnightOffsets.get(i)) {\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\tif (!Piece.isColor(pos.board.squares[i + offset], pos.toMove)) {\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tMove move = new Move(i, i + offset);\n\t\t\t\t\t\t\tmoves.add(move);\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\t\n\t\t\t\t\t}\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tint dirStart = name == Piece.Bishop ? 4 : 0;\n\t\t\t\t\tint dirEnd = name == Piece.Rook ? 4 : 8;\n\t\t\t\t\tfor (int dir = dirStart; dir < dirEnd; dir++) {\n\t\t\t\t\t\tint maxDist = MoveData.DistanceToEdge[i][dir];\n\t\t\t\t\t\tint dist = name == Piece.King ? Math.min(1, maxDist) : maxDist;\n\t\t\t\t\t\tfor (int steps = 1; steps <= dist; steps++) {\n\t\t\t\t\t\t\tint squareIdx = i + steps * MoveData.Offsets[dir];\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (!Piece.isColor(pos.board.squares[squareIdx], pos.toMove)) {\n\t\t\t\t\t\t\t\tmoves.add(new Move(i, squareIdx));\n\t\t\t\t\t\t\t\tif (Piece.isColor(pos.board.squares[squareIdx], Opposite(pos.toMove))) {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// castling\t\t\n\t\tif (pos.toMove == 'w' && !underAttack(pos, pos.whiteKing, 'b')) {\t\t\t\n\t\t\tif (pos.castlingRights.whiteKingSide && pos.at(Board.H1) == (Piece.Rook | Piece.White)) {\n\t\t\t\tif (pos.at(Board.F1) == Piece.Empty && pos.at(Board.G1) == Piece.Empty) {\n\t\t\t\t\tif (!underAttack(pos, Board.F1, 'b') && !underAttack(pos, Board.G1, 'b')) {\n\t\t\t\t\t\tmoves.add(new Move(Board.E1, Board.G1));\n\t\t\t\t\t}\t\t\t\t\n\t\t\t\t}\t\t\t\n\t\t\t}\n\t\t\tif (pos.castlingRights.whiteQueenSide && pos.at(Board.A1) == (Piece.Rook | Piece.White)) {\t\t\t\t\n\t\t\t\tif (pos.at(Board.B1) == Piece.Empty && pos.at(Board.C1) == Piece.Empty && pos.at(Board.D1) == Piece.Empty) {\n\t\t\t\t\tif (!underAttack(pos, Board.D1, 'b') && !underAttack(pos, Board.C1, 'b')) {\n\t\t\t\t\t\tmoves.add(new Move(Board.E1, Board.C1));\n\t\t\t\t\t}\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t\telse if (pos.toMove == 'b' && !underAttack(pos, pos.blackKing, 'w')){\n\t\t\tif (pos.castlingRights.blackKingSide && pos.at(Board.H8) == (Piece.Rook | Piece.Black)) {\n\t\t\t\tif (pos.at(Board.F8) == Piece.Empty && pos.at(Board.G8) == Piece.Empty) {\n\t\t\t\t\tif (!underAttack(pos, Board.F8, 'w') && !underAttack(pos, Board.G8, 'w')) {\n\t\t\t\t\t\tmoves.add(new Move(Board.E8, Board.G8));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (pos.castlingRights.blackQueenSide && pos.at(Board.A8) == (Piece.Rook | Piece.Black)) {\n\t\t\t\tif (pos.at(Board.B8) == Piece.Empty && pos.at(Board.C8) == Piece.Empty && pos.at(Board.D8) == Piece.Empty) {\n\t\t\t\t\tif (!underAttack(pos, Board.D8, 'w') && !underAttack(pos, Board.C8, 'w')) {\n\t\t\t\t\t\tmoves.add(new Move(Board.E8, Board.C8));\n\t\t\t\t\t}\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t// filter illegal moves\n\t\tList<Move> legalMoves = new ArrayList<>();\n\t\tchar color = pos.toMove;\n\t\tfor (Move move : moves) {\n\t\t\tpos.makeMove(move);\n\t\t\tif (!kingInCheck(pos, color)) {\n\t\t\t\tlegalMoves.add(move);\n\t\t\t}\t\t\t\n\t\t\tpos.undoMove();\n\t\t}\n\n\t\treturn legalMoves;\n\t}", "@Override\n\tpublic boolean move(int col, int row, piece[][] board) {\n\t\treturn false;\n\t}", "public boolean isMovePossible(int boardIndex) throws IllegalArgumentException;", "public boolean updatePlayerMove(GameBoard.GameMove move) {\n\t\t\n\t\t\n\t\t/*\n\t\t * move is illegal,return false.\n\t\t */\n\t\tif(move.getRow()>2||move.getRow()<0||move.getColumn()>2||move.getColumn()<0||this.board[move.getRow()][move.getColumn()]!=TicTacTow.BoardSigns.BLANK.getSign()) {\n\t\t\treturn false; \n\t\t}\n\t\telse {\n\t\t/*\n\t\t * legal move,return true.\n\t\t */\n\t\tsetLastMove(move);\n\t\tthis.board[move.getRow()][move.getColumn()]=TicTacTow.BoardSigns.PLAYER.getSign();\n\t\treturn true;\n\t\t}\n\t}", "public static boolean isBasicMoveValid(int[][] board, int player, int fromRow, int fromCol, int toRow, int toCol) {\r\n\t\t\t\r\n\t\tboolean ans = false;\r\n\t\t\r\n\t\t/*Checking if coordinates are OK*/\r\n\t\tif(fromRow<8&fromCol<8&toRow<8&toCol<8&fromRow>-1&fromCol>-1&toRow>-1&toCol>-1&player>-2&player<2&player!=0){\r\n\t\t\tif (board [toRow][toCol]==0){/*Checks if the tile is empty*/\r\n\t\t\t\tif (player==1){/*Checks if player is red*/\r\n\t\t\t\t\tif (board[fromRow][fromCol]==1){/*Checks if in tile there is soldier red */\r\n\t\t\t\t\t\tif(fromRow==toRow-1&&(fromCol==toCol+1||fromCol==toCol-1)){/*Did he move diagonally upward*/\r\n\t\t\t\t\t\t\tans = true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\t\r\n\t\t\t\t\tif (board[fromRow][fromCol]==2){/*Checks if in tile there is queen red*/\r\n\t\t\t\t\t\tif(((fromRow==toRow+1)||(fromRow==toRow-1))&&((fromCol==toCol+1)||(fromCol==toCol-1))){/*Did he move diagonally */\r\n\t\t\t\t\t\t\tans = true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\t\r\n\t\t\t\t}\r\n\t\t\t\tif (player==-1){/*Checks if player is blue*/\r\n\t\t\t\t\tif (board[fromRow][fromCol]==-1){/*Checks if in tile there is soldier blue */\r\n\t\t\t\t\t\tif(fromRow==toRow+1&(fromCol==toCol+1||fromCol==toCol-1)){/*Did he move diagonally down*/\r\n\t\t\t\t\t\t\tans = true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (board[fromRow][fromCol]==-2){/*Checks if in tile there is queen blue*/\r\n\t\t\t\t\t\tif(((fromRow==toRow+1)||(fromRow==toRow-1))&&((fromCol==toCol+1)||(fromCol==toCol-1))){/*Did he move diagonally */\r\n\t\t\t\t\t\t\tans = true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn ans;\r\n\t}", "public void checkMove(int playerID, int[] cardIdx) {\n\t\tHand attempt = cardIdx != null ? composeHand(this.getPlayerList().get(playerID),this.getPlayerList().get(playerID).play(cardIdx)) : null;\n\t\tif (cardIdx == null && (playerID == lastHandIdx || firstturn)) {\n\t\t\ttable.printMsg(\"{pass}\");\n\t\t\ttable.printMsg(\" <== Not a legal move!!!\\n\");\n\t\t} else if (cardIdx == null){\n\t\t\ttable.printMsg(\"{pass}\\n\");\n\t\t\tcurrentIdx = (playerID + 1) % getNumOfPlayers();\n\t\t\ttable.setActivePlayer(this.getCurrentIdx());\n\t\t\tfirstturn = false;\n\t\t\ttable.printMsg(this.getPlayerList().get(this.getCurrentIdx()).getName()+\"'s turn:\\n\");\n\t\t} else if (attempt == null) {\n\t\t\ttable.print(this.getPlayerList().get(playerID).play(cardIdx));\n\t\t\ttable.printMsg(\" <== Not a legal move!!!\\n\");\n\t\t} else if (firstturn && !attempt.contains(new BigTwoCard(0,2))) {\n\t\t\ttable.print(attempt);\n\t\t\ttable.printMsg(\" <== Not a legal move!!!\\n\");\n\t\t} else if ((!this.getHandsOnTable().isEmpty() && attempt!=null && playerID != lastHandIdx) ? (!(attempt.beats(this.getHandsOnTable().get(this.getHandsOnTable().size() - 1))) || attempt.size() != this.getHandsOnTable().get(this.getHandsOnTable().size() - 1).size()) : false) {\n\t\t\ttable.print(attempt);\n\t\t\ttable.printMsg(\" <== Not a legal move!!!\\n\");\n\t\t} else {\n\t\t\tthis.getPlayerList().get(playerID).removeCards(this.getPlayerList().get(playerID).play(cardIdx));\n\t\t\tattempt.sort();\n\t\t\tthis.getHandsOnTable().add(attempt);\n\t\t\tlastHandIdx = playerID;\n\t\t\ttable.printMsg(\"{\"+attempt.getType()+\"} \");\n\t\t\ttable.print(attempt);\n\t\t\ttable.printMsg(\"\\n\");\n\t\t\tcurrentIdx = (playerID + 1) % getNumOfPlayers();\n\t\t\ttable.setActivePlayer(this.getCurrentIdx());\n\t\t\tfirstturn = false;\n\t\t\ttable.printMsg(this.getPlayerList().get(this.getCurrentIdx()).getName()+\"'s turn:\\n\");\n\t\t}\n\t\ttable.resetSelected();\n\t\ttable.repaint();\n\t\t\n\t\tif (endOfGame()) {\n\t\t\ttable.printMsg(\"Game ends\\n\");\n\t\t\tfor (int i = 0; i < this.getNumOfPlayers(); i++) {\n\t\t\t\tif (this.getPlayerList().get(i).getNumOfCards() == 0) {\n\t\t\t\t\ttable.printMsg(this.getPlayerList().get(i).getName() + \" wins the game.\\n\");\n\t\t\t\t} else {\n\t\t\t\t\ttable.printMsg(this.getPlayerList().get(i).getName() + \" has \" + this.getPlayerList().get(i).getNumOfCards() + \" cards in hand.\\n\");\n\t\t\t\t}\n\t\t\t}\n\t\t\ttable.disable();\n\t\t}\n\t}", "public boolean move(Piece piece, int moved_xgrid, int moved_ygrid, boolean check) {// check stores if it\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// needs to check\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// freezing and rabbits' moving backward\n\t\tif (moved_xgrid >= 0 && moved_xgrid <= 7 && moved_ygrid >= 0 && moved_ygrid <= 7) {//if it is in grid\n\t\t\tif (piece.possibleMoves(moved_xgrid, moved_ygrid,check)) {//check possible moves\n\t\t\t\tif (getPiece(moved_xgrid, moved_ygrid) == null) {\n\t\t\t\t\tif(checkMove(piece, check)) {\n\t\t\t\t\t// move\n\t\t\t\t\tpiece.setX(moved_xgrid);\n\t\t\t\t\tpiece.setY(moved_ygrid);\n\t\t\t\t\tchecktrap();\n\t\t\t\t\trepaint();\t\t\t\t\t\n\t\t\t\t\treturn true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmessage = \"It is freezed\";\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tmessage = \"There is piece on the place\";\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmessage = \"It is not next to the piece, or rabbit cannot move backward\";\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t} else {\n\t\t\tmessage = \"The selected square is outside the grid\";\n\t\t\treturn false;\n\t\t}\n\t}" ]
[ "0.7755096", "0.7269162", "0.7264003", "0.71262383", "0.7024121", "0.7010592", "0.69897556", "0.6968795", "0.69484687", "0.69402355", "0.69278634", "0.6910092", "0.6905806", "0.68711925", "0.6851784", "0.6814221", "0.67898923", "0.6784084", "0.6774672", "0.6743538", "0.6741396", "0.67266524", "0.670149", "0.66998935", "0.6675336", "0.66362536", "0.6626366", "0.6620029", "0.66024196", "0.66020316", "0.6583545", "0.6572019", "0.6544061", "0.6527875", "0.6515588", "0.6514393", "0.65124136", "0.65065485", "0.6501054", "0.6500494", "0.6492762", "0.6490943", "0.6468665", "0.6450346", "0.6446794", "0.6415798", "0.64138246", "0.641273", "0.6403579", "0.6401072", "0.64009434", "0.6399924", "0.6399258", "0.6394862", "0.63881093", "0.638599", "0.63812745", "0.637473", "0.6366061", "0.6359062", "0.6351412", "0.6348742", "0.634764", "0.63434345", "0.6339428", "0.63363874", "0.63309485", "0.63069916", "0.6306376", "0.630488", "0.6298614", "0.6296873", "0.62945867", "0.6290907", "0.62862086", "0.6281483", "0.62774193", "0.62768567", "0.62746465", "0.62737167", "0.62720823", "0.6266616", "0.6265437", "0.6261732", "0.62610143", "0.625831", "0.6253723", "0.62499756", "0.62492067", "0.6244415", "0.62423617", "0.62416494", "0.62403286", "0.6237389", "0.6236721", "0.62363243", "0.623296", "0.62308764", "0.62189394", "0.62054956", "0.62042516" ]
0.0
-1
Convert the game in pgn to fen. Get the current board state and iterate through every rank to find the fen of each row. Combine them together to form the complete fen.
public static String pgnToFen() { String fen = ""; for (int i = getBoardState().length - 1; i >= 0; i--) { String fenLine = ""; int spaceStreak = 0; for (String file: getBoardState()[i]) { String piece = Character.toString(file.charAt(0)); char color = file.charAt(1); if (color == ' ') { spaceStreak++; continue; } else if (spaceStreak > 0) { fenLine += spaceStreak; spaceStreak = 0; } String square = color == 'w' ? piece : piece.toLowerCase(); fenLine += square; } if (spaceStreak > 0) { fenLine += spaceStreak; } fen += fenLine + (i != 0 ? "/" : ""); } return fen; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public String toFen() {\r\n StringBuilder sb = new StringBuilder();\r\n\r\n this.pieces.forEach(\r\n (playerColor, p) -> {\r\n sb.append(playerColor.getColorChar());\r\n sb.append(\r\n p.stream().map(Objects::toString).collect(Collectors.joining(FEN_PIECE_DELIMITER)));\r\n sb.append(FEN_DELIMITER);\r\n });\r\n\r\n return sb.substring(0, sb.length() - 1);\r\n }", "public static Board fromFen(String fen) {\r\n List<Piece> pieces = new ArrayList<>();\r\n\r\n Matcher matcher = FEN_PATTERN.matcher(fen);\r\n while (matcher.find()) {\r\n PlayerColor playerColor = PlayerColor.fromColorChar(matcher.group(\"color\").charAt(0));\r\n String[] playerPieces = matcher.group(\"pieces\").split(FEN_PIECE_DELIMITER);\r\n for (String piece : playerPieces) {\r\n if (piece.charAt(0) == 'K') {\r\n pieces.add(new Piece(playerColor, Integer.parseInt(piece.substring(1)), true));\r\n } else {\r\n pieces.add(new Piece(playerColor, Integer.parseInt(piece), false));\r\n }\r\n }\r\n }\r\n return new Board(pieces);\r\n }", "public String toRankedTable() {\r\n TreeSet<Team> teamTree = this.getTeamTreeFromMatchTree();\r\n String medal;\r\n int i = 1;\r\n String[] str = new String[teamTree.size() + 1];\r\n List<Team> unorderedTeams = new LinkedList<>();\r\n int currentRank = 0;\r\n int nextMedal = 0;\r\n \r\n //Add all the teams to the list\r\n unorderedTeams.addAll(teamTree);\r\n \r\n //Sort the list with the ranking comparator\r\n Collections.sort(unorderedTeams, rankingComparator);\r\n \r\n //Add the columns headings\r\n str[0] = String.format(\"%15s%10s%10s%10s%10s%10s%10s%10s%10s%10s%n\",\r\n this.centerAlign(\"Team\", 15),\r\n this.centerAlign(\"Rank\", 10),\r\n this.centerAlign(\"Won\", 10),\r\n this.centerAlign(\"Drawn\", 10),\r\n this.centerAlign(\"Lost\", 10),\r\n this.centerAlign(\"For\", 10),\r\n this.centerAlign(\"Against\", 10),\r\n this.centerAlign(\"Points\", 10),\r\n this.centerAlign(\"Diff\", 10),\r\n this.centerAlign(\"Medal\", 10));\r\n \r\n for (Team t : unorderedTeams) {\r\n //Get medal if any\r\n //If the team has a different ranking from the previous ones\r\n if (t.getRank() != currentRank){\r\n //Get the ranking of the current team\r\n currentRank = t.getRank();\r\n //Get the next medal\r\n nextMedal++;\r\n if (nextMedal == 1){\r\n medal = \"Gold\";\r\n }\r\n else if (nextMedal == 2){\r\n medal = \"Silver\";\r\n }\r\n else if (nextMedal == 3){\r\n medal = \"Bronze\";\r\n }\r\n else {\r\n medal = \"\";\r\n }\r\n }\r\n //Same ranking as previous team\r\n //No need to change the medal or ranking\r\n else {\r\n if (nextMedal == 1){\r\n medal = \"Gold\";\r\n }\r\n else if (nextMedal == 2){\r\n medal = \"Silver\";\r\n }\r\n else if (nextMedal == 3){\r\n medal = \"Bronze\";\r\n }\r\n else {\r\n medal = \"\";\r\n }\r\n }\r\n \r\n //Add the team details to the string\r\n str[i] = String.format(\"%15s%10s%10s%10s%10s%10s%10s%10s%10s%10s%n\",\r\n this.centerAlign(t.getName(), 15),\r\n this.centerAlign(Integer.toString(t.getRank()), 10),\r\n this.centerAlign(Integer.toString(t.getMatchWon()), 10),\r\n this.centerAlign(Integer.toString(t.getMatchDrawn()), 10),\r\n this.centerAlign(Integer.toString(t.getMatchLost()), 10),\r\n this.centerAlign(Integer.toString(t.getGoalsFor()), 10),\r\n this.centerAlign(Integer.toString(t.getGoalsAgainst()), 10),\r\n this.centerAlign(Integer.toString(t.getPoints()), 10),\r\n this.centerAlign(Integer.toString(t.goalDiff()), 10),\r\n this.centerAlign(medal, 10));\r\n \r\n i++;\r\n }\r\n \r\n //Transform the array into a single String\r\n StringBuilder sb = new StringBuilder();\r\n for(String s : str) {\r\n sb.append(s);\r\n }\r\n \r\n return sb.toString();\r\n }", "public static Board makeBoard(final Player lightPlayer, final Player darkPlayer, final String FEN) {\n Board board = new Board(lightPlayer, darkPlayer);\n\n Tile[][] matrix = board.getMatrix();\n \n // rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 default ren\n \n /*\n Part 1: read in board state string and generate the pieces based off of their location\n */\n \n int i = 0, j = 0, k = 0;\n boolean boardComplete = false;\n for( ; !boardComplete ; k++){\n switch (FEN.charAt(k)){\n case ' ':\n boardComplete=true; // a _ means we are done with the board data\n break;\n case '/':\n i++; // a / means move to next rank/line\n j=0;\n break;\n case 'r': // ROOKS\n matrix[i][j].setPiece(new Rook(darkPlayer, true));\n j++;\n break;\n case 'R':\n matrix[i][j].setPiece(new Rook(lightPlayer, true));\n j++;\n break;\n case 'n': // KNIGHTS\n matrix[i][j].setPiece(new Knight(darkPlayer));\n j++;\n break;\n case 'N':\n matrix[i][j].setPiece(new Knight(lightPlayer));\n j++;\n break;\n case 'b': // BISHOPS\n matrix[i][j].setPiece(new Bishop(darkPlayer));\n j++;\n break;\n case 'B':\n matrix[i][j].setPiece(new Bishop(lightPlayer));\n j++;\n break;\n case 'q': // QUEENS\n matrix[i][j].setPiece(new Queen(darkPlayer));\n j++;\n break;\n case 'Q':\n matrix[i][j].setPiece(new Queen(lightPlayer));\n j++;\n break;\n case 'k': // KINGS\n matrix[i][j].setPiece(new King(darkPlayer, true));\n darkPlayer.setLocationOfKing(matrix[i][j].getPosition());\n j++;\n break;\n case 'K':\n matrix[i][j].setPiece(new King(lightPlayer, true));\n lightPlayer.setLocationOfKing(matrix[i][j].getPosition());\n j++;\n break;\n case 'p': // PAWNS\n matrix[i][j].setPiece(new Pawn(darkPlayer));\n j++;\n break;\n case 'P':\n matrix[i][j].setPiece(new Pawn(lightPlayer));\n j++;\n break;\n default: // SPACES BETWEEN PIECES\n j+=Character.getNumericValue(FEN.charAt(k));\n \n }\n }\n\n /*\n Part 2: load in character w or b to determine who's turn it is\n */\n \n board.setCurrentPlayer(FEN.charAt(k) == 'w' ? board.getLightPlayer() : board.getDarkPlayer());\n board.setEnemyPlayer(FEN.charAt(k) == 'w' ? board.getDarkPlayer() : board.getLightPlayer());\n \n k += 2; // skips over the turn char and the space after it putting FEN.charAt(k) at the next stage\n \n /*\n Part 3: read in castle availability string and set the boolean flag hasTakenFirstMove for each respective piece\n For rook and king hasTakenFirstMove is default to true. It is only set to false if the correct char's below are present.\n */\n boolean notFinishedCastle = true;\n for ( ; notFinishedCastle; k++) {\n switch (FEN.charAt(k)) {\n case '-':\n notFinishedCastle = false;\n break;\n case ' ':\n notFinishedCastle = false;\n break;\n case 'K':\n board.getMatrix()[board.getLightPlayer().getHomeRow()][Constants.ROOK_COLUMN_KINGSIDE].getPiece().setHasTakenFirstMove(false);\n board.getMatrix()[board.getLightPlayer().getHomeRow()][Constants.KING_COLUMN].getPiece().setHasTakenFirstMove(false);\n break;\n case 'Q':\n board.getMatrix()[board.getLightPlayer().getHomeRow()][Constants.ROOK_COLUMN_QUEENSIDE].getPiece().setHasTakenFirstMove(false);\n board.getMatrix()[board.getLightPlayer().getHomeRow()][Constants.KING_COLUMN].getPiece().setHasTakenFirstMove(false);\n break;\n case 'k':\n board.getMatrix()[board.getDarkPlayer().getHomeRow()][Constants.ROOK_COLUMN_KINGSIDE].getPiece().setHasTakenFirstMove(false);\n board.getMatrix()[board.getDarkPlayer().getHomeRow()][Constants.KING_COLUMN].getPiece().setHasTakenFirstMove(false);\n break;\n case 'q':\n board.getMatrix()[board.getDarkPlayer().getHomeRow()][Constants.ROOK_COLUMN_QUEENSIDE].getPiece().setHasTakenFirstMove(false);\n board.getMatrix()[board.getDarkPlayer().getHomeRow()][Constants.KING_COLUMN].getPiece().setHasTakenFirstMove(false);\n break;\n }\n \n if (k == FEN.length() - 1) {\n notFinishedCastle = false;\n }\n }\n \n return board;\n }", "private void arretes_fG(){\n\t\tthis.cube[31] = this.cube[28]; \n\t\tthis.cube[28] = this.cube[30];\n\t\tthis.cube[30] = this.cube[34];\n\t\tthis.cube[34] = this.cube[32];\n\t\tthis.cube[32] = this.cube[31];\n\t}", "private void FenwickTree(int n) {\n // Store the actual values in tree[] using update()\n for(int i = 0; i < N; i++)\n updateBIT(down_tree, Max_dis, site_distance[i], raw_tree[site_distance[i]]);\n }", "public static Board fen(String str) {\n\t\tPiece[][] b = new Piece[8][8];\n\t\tbyte r = 7, c = 0;\n\t\tString[] s = str.split(\" \");\n\t\t\n\t\tfor (int i = 0; i < s[0].length(); i++) {\n\t\t\tif (s[0].charAt(i) == '/') {\n\t\t\t\tr--;\n\t\t\t\tc = -1;\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'P') {\n\t\t\t\tb[r][c] = new Pawn(true, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'N') {\n\t\t\t\tb[r][c] = new Knight(true, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'B') {\n\t\t\t\tb[r][c] = new Bishop(true, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'R') {\n\t\t\t\tb[r][c] = new Rook(true, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'Q') {\n\t\t\t\tb[r][c] = new Queen(true, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'K') {\n\t\t\t\tb[r][c] = new King(true, r, c, s[1].charAt(0)=='1', s[1].charAt(1)=='1');\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'p') {\n\t\t\t\tb[r][c] = new Pawn(false, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'n') {\n\t\t\t\tb[r][c] = new Knight(false, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'b') {\n\t\t\t\tb[r][c] = new Bishop(false, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'r') {\n\t\t\t\tb[r][c] = new Rook(false, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'q') {\n\t\t\t\tb[r][c] = new Queen(false, r, c);\n\t\t\t}\n\t\t\t\n\t\t\telse if (s[0].charAt(i) == 'k') {\n\t\t\t\tb[r][c] = new King(false, r, c, s[1].charAt(2)=='1', s[1].charAt(3)=='1');\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\tfor (byte j = 0; j < Byte.parseByte(s[0].charAt(i)+\"\"); j++) {\n\t\t\t\t\tb[r][c+j] = new Null(r, (byte)(c+j));\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tc += Byte.parseByte(s[0].charAt(i)+\"\") - 1;\n\t\t\t}\n\t\t\t\n\t\t\tc++;\n\t\t}\n\t\t\n\t\treturn new Board(b);\n\t}", "private String digestGameBoard() {\n StringBuilder config = new StringBuilder();\n for(char[] gameBoardRow : gameBoard) {\n for(char slot : gameBoardRow) {\n config.append(slot);\n }\n }\n return config.toString();\n }", "public static void stateCheckerboardConvertionTest() {\n\t\tVTicTacToe tempEnvironment = new VTicTacToe();\n\t\tint[] tempTestStates = { 0, 13, 39, 26, 17087 };\n\n\t\tint tempState;\n\t\tint[][] tempCheckerboard;\n\t\tfor (int i = 0; i < tempTestStates.length; i++) {\n\t\t\ttempCheckerboard = tempEnvironment.stateToCheckerboard(tempTestStates[i]);\n\t\t\tSystem.out.println(\"The checkerboard of \" + tempTestStates[i] + \" is: \"\n\t\t\t\t\t+ Arrays.deepToString(tempCheckerboard));\n\t\t\ttempState = tempEnvironment.checkerboardToState(tempCheckerboard);\n\t\t\tSystem.out.println(\"The state ID is \" + tempState);\n\t\t} // Of for i\n\n\t}", "public void processFights() {\n\n\t\tfor (int row = 0; row < battlefield.length; row++) {\n\t\t\tfor (int column = 0; column < battlefield[row].length; column++) {\n\t\t\t\tbattlefield[row][column].fight();\n\t\t\t}\n\t\t}\n\t}", "private String encodedBoard() {\r\n char[] result = new char[Square.SQUARE_LIST.size() + 1];\r\n result[0] = turn().toString().charAt(0);\r\n for (Square sq : SQUARE_LIST) {\r\n result[sq.index() + 1] = get(sq).toString().charAt(0);\r\n }\r\n return new String(result);\r\n }", "private void arretes_fW(){\n\t\tthis.cube[4] = this.cube[1]; \n\t\tthis.cube[1] = this.cube[3];\n\t\tthis.cube[3] = this.cube[7];\n\t\tthis.cube[7] = this.cube[5];\n\t\tthis.cube[5] = this.cube[4];\n\t}", "private int checkerboardToState(int[][] paraCheckerboard) {\n\t\tint resultState = 0;\n\t\tint tempExponential = 1;\n\t\tfor (int i = 0; i < SIZE; i++) {\n\t\t\tfor (int j = 0; j < SIZE; j++) {\n\t\t\t\tresultState += paraCheckerboard[i][j] * tempExponential;\n\t\t\t\ttempExponential *= SIZE;\n\t\t\t} // Of for j\n\t\t} // Of for i\n\n\t\treturn resultState;\n\t}", "private void coins_fG(){\n\t\tthis.cube[31] = this.cube[27]; \n\t\tthis.cube[27] = this.cube[33];\n\t\tthis.cube[33] = this.cube[35];\n\t\tthis.cube[35] = this.cube[29];\n\t\tthis.cube[29] = this.cube[31];\n\t}", "public String rendorBattleField() {\n\t\tStringBuilder builder = new StringBuilder();\n\t\tfor (int row = 0; row < battlefield.length; row++) {\n\t\t\tfor (int column = 0; column < battlefield[row].length; column++) {\n\t\t\t\tbuilder.append(battlefield[row][column].rendorSquare()).append(\n\t\t\t\t\t\t\" \");\n\t\t\t}\n\t\t\tbuilder.append(\"\\n\");\n\t\t}\n\t\tbuilder.append(\"elves: \").append(getElfCount()).append(\" orcs: \")\n\t\t\t\t.append(getOrcCount());\n\t\treturn builder.toString();// returns the battlefield as a String\n\t}", "public static void runOnAllLFRGraphs() {\n\t\tfor(int l=1;l<=3;l+=2) {\n\t\t\tdouble dl = l/10.0;\n\t\t\tfor(int k=10;k<=50;k+=40) {\n\t\t\t\tfor(int i=0;i<3;i++) {\n\t\t\t\t\tfor(int j=2;j<=8;j+=2) {\n\t\t\t\t\t\tString n = nodeIndexedInput.replace(\"[i]\", i+\"\");\n\t\t\t\t\t\tString g = groupIndexedOutput.replace(\"[i]\", i+\"\");\n\t\t\t\t\t\tn = n.replace(\"[j]\", j+\"\");\n\t\t\t\t\t\tg = g.replace(\"[j]\", j+\"\");\n\t\t\t\t\t\tn = n.replace(\"[k]\", k+\"\");\n\t\t\t\t\t\tg = g.replace(\"[k]\", k+\"\");\n\t\t\t\t\t\tn = n.replace(\"[l]\", dl+\"\");\n\t\t\t\t\t\tg = g.replace(\"[l]\", dl+\"\");\n\t\t\t\t\t\tSystem.out.println(\"start converting \"+n+\" to \"+g);\n\t\t\t\t\t\t//convert(n,g);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "private void printCurrentBattleField()\n {\n // TODO YOUR CODE HERE\n for (int i = 0; i < battleField.length; i++) {\n for (int j = 0; j < battleField[i].length; j+=9) {\n int k = j;\n String rowValue = \"\";\n while (k <=8) {\n System.out.println(battleField[i][k]);\n rowValue = rowValue + battleField[i][k];\n k++;\n }\n System.out.println(rowValue);\n }\n\n }\n\n }", "public static void main(String[] args) throws Exception {\n File file = new File(\"/Users/Alinani/Desktop/Advent-of-code-2020/Day5/src/input.txt\");\n BufferedReader br = new BufferedReader(new FileReader(file));\n String st;\n int highest = 0, column = 0, row = 0;\n while((st = br.readLine()) != null) {\n if(st.charAt(0) == 'F') {\n if(st.charAt(1) == 'F') {\n if(st.charAt(2) == 'F') {\n if(st.charAt(3) == 'F') {\n if(st.charAt(4) == 'F') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 0;\n } else if(st.charAt(6) == 'B') {\n row = 1;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 2;\n } else if(st.charAt(6) == 'B') {\n row = 3;\n }\n }\n } else if(st.charAt(4) == 'B') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 4;\n } else if(st.charAt(6) == 'B') {\n row = 5;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 6;\n } else if(st.charAt(6) == 'B') {\n row = 7;\n }\n }\n }\n } else if(st.charAt(3) == 'B') {\n if(st.charAt(4) == 'F') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 8;\n } else if(st.charAt(6) == 'B') {\n row = 9;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 10;\n } else if(st.charAt(6) == 'B') {\n row = 11;\n }\n }\n } else if(st.charAt(4) == 'B') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 12;\n } else if(st.charAt(6) == 'B') {\n row = 13;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 14;\n } else if(st.charAt(6) == 'B') {\n row = 15;\n }\n }\n }\n }\n } else if(st.charAt(2) == 'B') {\n if(st.charAt(3) == 'F') {\n if(st.charAt(4) == 'F') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 16;\n } else if(st.charAt(6) == 'B') {\n row = 17;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 18;\n } else if(st.charAt(6) == 'B') {\n row = 19;\n }\n }\n } else if(st.charAt(4) == 'B') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 20;\n } else if(st.charAt(6) == 'B') {\n row = 21;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 22;\n } else if(st.charAt(6) == 'B') {\n row = 23;\n }\n }\n }\n } else if(st.charAt(3) == 'B') {\n if(st.charAt(4) == 'F') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 24;\n } else if(st.charAt(6) == 'B') {\n row = 25;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 26;\n } else if(st.charAt(6) == 'B') {\n row = 27;\n }\n }\n } else if(st.charAt(4) == 'B') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 28;\n } else if(st.charAt(6) == 'B') {\n row = 29;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 30;\n } else if(st.charAt(6) == 'B') {\n row = 31;\n }\n }\n }\n }\n }\n } else if(st.charAt(1) == 'B') {\n if(st.charAt(2) == 'F') {\n if(st.charAt(3) == 'F') {\n if(st.charAt(4) == 'F') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 32;\n } else if(st.charAt(6) == 'B') {\n row = 33;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 34;\n } else if(st.charAt(6) == 'B') {\n row = 35;\n }\n }\n } else if(st.charAt(4) == 'B') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 36;\n } else if(st.charAt(6) == 'B') {\n row = 37;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 38;\n } else if(st.charAt(6) == 'B') {\n row = 39;\n }\n }\n }\n } else if(st.charAt(3) == 'B') {\n if(st.charAt(4) == 'F') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 40;\n } else if(st.charAt(6) == 'B') {\n row = 41;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 42;\n } else if(st.charAt(6) == 'B') {\n row = 43;\n }\n }\n } else if(st.charAt(4) == 'B') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 44;\n } else if(st.charAt(6) == 'B') {\n row = 45;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 46;\n } else if(st.charAt(6) == 'B') {\n row = 47;\n }\n }\n }\n }\n } else if(st.charAt(2) == 'B') {\n if(st.charAt(3) == 'F') {\n if(st.charAt(4) == 'F') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 48;\n } else if(st.charAt(6) == 'B') {\n row = 49;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 50;\n } else if(st.charAt(6) == 'B') {\n row = 51;\n }\n }\n } else if(st.charAt(4) == 'B') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 52;\n } else if(st.charAt(6) == 'B') {\n row = 53;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 54;\n } else if(st.charAt(6) == 'B') {\n row = 55;\n }\n }\n }\n } else if(st.charAt(3) == 'B') {\n if(st.charAt(4) == 'F') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 56;\n } else if(st.charAt(6) == 'B') {\n row = 57;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 58;\n } else if(st.charAt(6) == 'B') {\n row = 59;\n }\n }\n } else if(st.charAt(4) == 'B') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 60;\n } else if(st.charAt(6) == 'B') {\n row = 61;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 62;\n } else if(st.charAt(6) == 'B') {\n row = 63;\n }\n }\n }\n }\n }\n }\n } else if(st.charAt(0) == 'B') {\n if(st.charAt(1) == 'F') {\n if(st.charAt(2) == 'F') {\n if(st.charAt(3) == 'F') {\n if(st.charAt(4) == 'F') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 64;\n } else if(st.charAt(6) == 'B') {\n row = 65;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 66;\n } else if(st.charAt(6) == 'B') {\n row = 67;\n }\n }\n } else if(st.charAt(4) == 'B') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 68;\n } else if(st.charAt(6) == 'B') {\n row = 69;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 70;\n } else if(st.charAt(6) == 'B') {\n row = 71;\n }\n }\n }\n } else if(st.charAt(3) == 'B') {\n if(st.charAt(4) == 'F') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 72;\n } else if(st.charAt(6) == 'B') {\n row = 73;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 74;\n } else if(st.charAt(6) == 'B') {\n row = 75;\n }\n }\n } else if(st.charAt(4) == 'B') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 76;\n } else if(st.charAt(6) == 'B') {\n row = 77;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 78;\n } else if(st.charAt(6) == 'B') {\n row = 79;\n }\n }\n }\n }\n } else if(st.charAt(2) == 'B') {\n if(st.charAt(3) == 'F') {\n if(st.charAt(4) == 'F') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 80;\n } else if(st.charAt(6) == 'B') {\n row = 81;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 82;\n } else if(st.charAt(6) == 'B') {\n row = 83;\n }\n }\n } else if(st.charAt(4) == 'B') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 84;\n } else if(st.charAt(6) == 'B') {\n row = 85;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 86;\n } else if(st.charAt(6) == 'B') {\n row = 87;\n }\n }\n }\n } else if(st.charAt(3) == 'B') {\n if(st.charAt(4) == 'F') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 88;\n } else if(st.charAt(6) == 'B') {\n row = 89;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 90;\n } else if(st.charAt(6) == 'B') {\n row = 91;\n }\n }\n } else if(st.charAt(4) == 'B') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 92;\n } else if(st.charAt(6) == 'B') {\n row = 93;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 94;\n } else if(st.charAt(6) == 'B') {\n row = 95;\n }\n }\n }\n }\n }\n } else if(st.charAt(1) == 'B') {\n if(st.charAt(2) == 'F') {\n if(st.charAt(3) == 'F') {\n if(st.charAt(4) == 'F') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 96;\n } else if(st.charAt(6) == 'B') {\n row = 97;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 98;\n } else if(st.charAt(6) == 'B') {\n row = 99;\n }\n }\n } else if(st.charAt(4) == 'B') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 100;\n } else if(st.charAt(6) == 'B') {\n row = 101;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 102;\n } else if(st.charAt(6) == 'B') {\n row = 103;\n }\n }\n }\n } else if(st.charAt(3) == 'B') {\n if(st.charAt(4) == 'F') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 104;\n } else if(st.charAt(6) == 'B') {\n row = 105;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 106;\n } else if(st.charAt(6) == 'B') {\n row = 107;\n }\n }\n } else if(st.charAt(4) == 'B') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 108;\n } else if(st.charAt(6) == 'B') {\n row = 109;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 110;\n } else if(st.charAt(6) == 'B') {\n row = 111;\n }\n }\n }\n }\n } else if(st.charAt(2) == 'B') {\n if(st.charAt(3) == 'F') {\n if(st.charAt(4) == 'F') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 112;\n } else if(st.charAt(6) == 'B') {\n row = 113;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 114;\n } else if(st.charAt(6) == 'B') {\n row = 115;\n }\n }\n } else if(st.charAt(4) == 'B') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 116;\n } else if(st.charAt(6) == 'B') {\n row = 117;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 118;\n } else if(st.charAt(6) == 'B') {\n row = 119;\n }\n }\n }\n } else if(st.charAt(3) == 'B') {\n if(st.charAt(4) == 'F') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 120;\n } else if(st.charAt(6) == 'B') {\n row = 121;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 122;\n } else if(st.charAt(6) == 'B') {\n row = 123;\n }\n }\n } else if(st.charAt(4) == 'B') {\n if(st.charAt(5) == 'F') {\n if(st.charAt(6) == 'F') {\n row = 124;\n } else if(st.charAt(6) == 'B') {\n row = 125;\n }\n } else if(st.charAt(5) == 'B') {\n if(st.charAt(6) == 'F') {\n row = 126;\n } else if(st.charAt(6) == 'B') {\n row = 127;\n }\n }\n }\n }\n }\n }\n }\n\n if(st.charAt(7) == 'L') {\n if(st.charAt(8) == 'L') {\n if(st.charAt(9) == 'L') {\n column = 0;\n } else if(st.charAt(9) == 'R') {\n column = 1;\n }\n } else if(st.charAt(8) == 'R') {\n if(st.charAt(9) == 'L') {\n column = 2;\n } else if(st.charAt(9) == 'R') {\n column = 3;\n }\n }\n } else if(st.charAt(7) == 'R') {\n if(st.charAt(8) == 'L') {\n if(st.charAt(9) == 'L') {\n column = 4;\n } else if(st.charAt(9) == 'R') {\n column = 5;\n }\n } else if(st.charAt(8) == 'R') {\n if(st.charAt(9) == 'L') {\n column = 6;\n } else if(st.charAt(9) == 'R') {\n column = 7;\n }\n }\n }\n int product = row * 8;\n int sum = product + column;\n if(sum > highest) {\n highest = sum;\n }\n }\n System.out.println(highest);\n }", "private static int evalState(GameState state){\n Move m = state.getMove();\n int counter = 0;\n\n // return directly if we encouter win or loss\n if(m.isXWin()){\n return 10000;\n }\n else if(m.isOWin()){\n return -1;\n }\n\n Vector<Integer> points = new Vector<Integer>();\n points.setSize(state.BOARD_SIZE*2+2);\n int player;\n Collections.fill(points, 1);\n int scaling = 4;\n int value = 0;\n\n for(int row = 0; row < state.BOARD_SIZE; row ++){\n for(int col = 0; col < state.BOARD_SIZE; col ++){\n player = state.at(row, col);\n\n // add points to the vector, increase by a factor for every new entry\n if(player == 1){\n points.set(row, points.get(row)*scaling);\n points.add(state.BOARD_SIZE + col, points.get(state.BOARD_SIZE - 1 + col)*scaling);\n\n // if it's in the first diagonal\n if(counter%state.BOARD_SIZE+1 == 0){\n points.add(state.BOARD_SIZE*2, points.get(state.BOARD_SIZE*2)*scaling);\n }\n\n // checking other diagonal\n if(counter%state.BOARD_SIZE-1 == 0 && row+col != 0){\n points.add(state.BOARD_SIZE*2 + 1, points.get(state.BOARD_SIZE*2)*scaling);\n }\n }\n // if an enemy player is encoutered null the value of the row/col\n else if(player == 2){\n points.set(row, 0);\n points.set(state.BOARD_SIZE + col, 0);\n if(counter%state.BOARD_SIZE+1 == 0){\n points.add(state.BOARD_SIZE*2, 0);\n }\n if(counter%state.BOARD_SIZE-1 == 0){\n points.add(state.BOARD_SIZE*2 + 1, 0);\n }\n }\n counter++;\n }\n }\n\n // if we have nulled the point we don't count it for the value of the state\n for(Integer i: points){\n if(i > 1){\n value += i;\n }\n }\n //System.err.println(\"Value: \" + value);\n return value;\n }", "public static List<String> printTruthTable(int n) {\n List<String> functions = new ArrayList<>();\n int rows = (int) Math.pow(2,n);\n\n for (int i=0; i<rows; i++) {\n String function = \"\";\n for (int j=n-1; j>=0; j--) {\n int value = (i/(int) Math.pow(2, j))%2;\n function = function.concat(String.valueOf(value));\n }\n functions.add(function);\n }\n return functions;\n }", "void printBoardState(Piece[] B,Player J,int N);", "public String stateToCheckerboardString(int paraState) {\n\t\tint[][] tempCheckerboard = stateToCheckerboard(paraState);\n\t\tString resultString = \"\\r\\n\";\n\t\t//resultString += \"Checkerboard state: \\r\\n\";\n\t\tfor (int i = 0; i < tempCheckerboard.length; i++) {\n\t\t\tfor (int j = 0; j < tempCheckerboard[0].length; j++) {\n\t\t\t\tif (tempCheckerboard[i][j] == WHITE) {\n\t\t\t\t\tresultString += \"o \";\n\t\t\t\t} else if (tempCheckerboard[i][j] == BLACK) {\n\t\t\t\t\tresultString += \"x \";\n\t\t\t\t} else {\n\t\t\t\t\tresultString += \"- \";\n\t\t\t\t}//Of if\n\t\t\t}//Of for j\n\t\t\tresultString += \"\\r\\n\";\n\t\t}//Of for i\n\t\t\n\t\t//resultString += currentState;\n\t\treturn resultString;\n\t}", "public void ss(){\n for (int c=0; c < league.length;c++) {\r\n for (int t=c+1;t<league.length;t++) {\r\n score = league[c].scoregenerator();\r\n secondscore = league[t].scoregenerator();\r\n league[c].pointsfor(score);\r\n league[t].pointsfor(secondscore);\r\n\r\n if (score > secondscore){\r\n league[c].wins();\r\n league[t].losses();\r\n }\r\n else if (score == secondscore){\r\n league[c].ties();\r\n league[t].ties();\r\n }\r\n else {\r\n league[t].wins();\r\n league[c].losses();\r\n }\r\n } \r\n }\r\n for (int c=0; c < AFC.length;c++) {\r\n for (int t=c+1;t<AFC.length;t++) {\r\n score = AFC[c].scoregenerator();\r\n secondscore = AFC[t].scoregenerator();\r\n AFC[c].pointsfor(score);\r\n AFC[t].pointsfor(secondscore);\r\n\r\n if (score > secondscore){\r\n AFC[c].wins();\r\n AFC[t].losses();\r\n }\r\n else if (score == secondscore){\r\n AFC[c].ties();\r\n AFC[t].ties();\r\n }\r\n else {\r\n AFC[t].wins();\r\n AFC[c].losses();\r\n }\r\n } \r\n }\r\n for (int c=0; c < NFC.length;c++) {\r\n for (int t=c+1;t<NFC.length;t++) {\r\n score = NFC[c].scoregenerator();\r\n secondscore = NFC[t].scoregenerator();\r\n NFC[c].pointsfor(score);\r\n NFC[t].pointsfor(secondscore);\r\n\r\n if (score > secondscore){\r\n NFC[c].wins();\r\n NFC[t].losses();\r\n }\r\n else if (score == secondscore){\r\n NFC[c].ties();\r\n NFC[t].ties();\r\n }\r\n else {\r\n NFC[t].wins();\r\n NFC[c].losses();\r\n }\r\n } \r\n }\r\n for (int c=0;c<AFCeast.length;c++) {\r\n for (int t=c+1;t<AFCeast.length;t++) {\r\n score = AFCeast[c].scoregenerator();\r\n secondscore = AFCeast[t].scoregenerator();\r\n AFCeast[c].pointsfor(score);\r\n AFCeast[t].pointsfor(secondscore);\r\n\r\n if (score > secondscore){\r\n AFCeast[c].wins();\r\n AFCeast[t].losses();\r\n }\r\n else if (score == secondscore){\r\n AFCeast[c].ties();\r\n AFCeast[t].ties();\r\n }\r\n else {\r\n AFCeast[t].wins();\r\n AFCeast[c].losses();\r\n }\r\n } \r\n }\r\n for (int c=0; c < AFCnorth.length;c++) {\r\n for (int t=c+1;t<AFCnorth.length;t++) {\r\n score = AFCnorth[c].scoregenerator();\r\n secondscore = AFCnorth[t].scoregenerator();\r\n AFCnorth[c].pointsfor(score);\r\n AFCnorth[t].pointsfor(secondscore);\r\n\r\n if (score > secondscore){\r\n AFCnorth[c].wins();\r\n AFCnorth[t].losses();\r\n }\r\n else if (score == secondscore){\r\n AFCnorth[c].ties();\r\n AFCnorth[t].ties();\r\n }\r\n else {\r\n AFCnorth[t].wins();\r\n AFCnorth[c].losses();\r\n }\r\n } \r\n }\r\n for (int c=0; c < AFCsouth.length;c++) {\r\n for (int t=c+1;t<AFCsouth.length;t++) {\r\n score = AFCsouth[c].scoregenerator();\r\n secondscore = AFCsouth[t].scoregenerator();\r\n AFCsouth[c].pointsfor(score);\r\n AFCsouth[t].pointsfor(secondscore);\r\n\r\n if (score > secondscore){\r\n AFCsouth[c].wins();\r\n AFCsouth[t].losses();\r\n }\r\n else if (score == secondscore){\r\n AFCsouth[c].ties();\r\n AFCsouth[t].ties();\r\n }\r\n else {\r\n AFCsouth[t].wins();\r\n AFCsouth[c].losses();\r\n }\r\n } \r\n }\r\n for (int c=0; c < AFCwest.length;c++) {\r\n for (int t=c+1;t<AFCwest.length;t++) {\r\n score = AFCwest[c].scoregenerator();\r\n secondscore = AFCwest[t].scoregenerator();\r\n AFCwest[c].pointsfor(score);\r\n AFCwest[t].pointsfor(secondscore);\r\n\r\n if (score > secondscore){\r\n AFCwest[c].wins();\r\n AFCwest[t].losses();\r\n }\r\n else if (score == secondscore){\r\n AFCwest[c].ties();\r\n AFCwest[t].ties();\r\n }\r\n else {\r\n AFCwest[t].wins();\r\n AFCwest[c].losses();\r\n }\r\n } \r\n }\r\n for (int c=0; c < NFCeast.length;c++) {\r\n for (int t=c+1;t<NFCeast.length;t++) {\r\n score = NFCeast[c].scoregenerator();\r\n secondscore = NFCeast[t].scoregenerator();\r\n NFCeast[c].pointsfor(score);\r\n NFCeast[t].pointsfor(secondscore);\r\n\r\n if (score > secondscore){\r\n NFCeast[c].wins();\r\n NFCeast[t].losses();\r\n }\r\n else if (score == secondscore){\r\n NFCeast[c].ties();\r\n NFCeast[t].ties();\r\n }\r\n else {\r\n NFCeast[t].wins();\r\n NFCeast[c].losses();\r\n }\r\n } \r\n }\r\n for (int c=0; c < NFCnorth.length;c++) {\r\n for (int t=c+1;t<NFCnorth.length;t++) {\r\n score = NFCnorth[c].scoregenerator();\r\n secondscore = NFCnorth[t].scoregenerator();\r\n NFCnorth[c].pointsfor(score);\r\n NFCnorth[t].pointsfor(secondscore);\r\n\r\n if (score > secondscore){\r\n NFCnorth[c].wins();\r\n NFCnorth[t].losses();\r\n }\r\n else if (score == secondscore){\r\n NFCnorth[c].ties();\r\n NFCnorth[t].ties();\r\n }\r\n else {\r\n NFCnorth[t].wins();\r\n NFCnorth[c].losses();\r\n }\r\n } \r\n }\r\n for (int c=0; c < NFCsouth.length;c++) {\r\n for (int t=c+1;t<NFCsouth.length;t++) {\r\n score = NFCsouth[c].scoregenerator();\r\n secondscore = NFCsouth[t].scoregenerator();\r\n NFCsouth[c].pointsfor(score);\r\n NFCsouth[t].pointsfor(secondscore);\r\n\r\n if (score > secondscore){\r\n NFCsouth[c].wins();\r\n NFCsouth[t].losses();\r\n }\r\n else if (score == secondscore){\r\n NFCsouth[c].ties();\r\n NFCsouth[t].ties();\r\n }\r\n else {\r\n NFCsouth[t].wins();\r\n NFCsouth[c].losses();\r\n }\r\n } \r\n }\r\n for (int c=0; c < NFCwest.length;c++) {\r\n for (int t=c+1;t<NFCwest.length;t++) {\r\n score = NFCwest[c].scoregenerator();\r\n secondscore = NFCwest[t].scoregenerator();\r\n NFCwest[c].pointsfor(score);\r\n NFCwest[t].pointsfor(secondscore);\r\n\r\n if (score > secondscore){\r\n NFCwest[c].wins();\r\n NFCwest[t].losses();\r\n }\r\n else if (score == secondscore){\r\n NFCwest[c].ties();\r\n NFCwest[t].ties();\r\n }\r\n else {\r\n NFCwest[t].wins();\r\n NFCwest[c].losses();\r\n }\r\n } \r\n }\r\n\r\n for (int c=0;c<league.length;c++){\r\n System.out.println(league[c]);\r\n }\r\n System.out.println(\"...\");\r\n try\r\n {\r\n Thread.sleep(3000);\r\n }\r\n catch (Exception e)\r\n {}\r\n System.out.println(\"\\n\" + \"Now let the playoffs begin!\" + \"\\n\");\r\n\r\n for (int y=0;y<4;y++){ // These next groups of code are sorting each division, and each conference based on wins\r\n for (int p=0;p<3;p++) {\r\n int a = p+1;\r\n if (AFCeast[a].displaywins() > AFCeast[p].displaywins()){\r\n Temp = AFCeast[p];\r\n AFCeast[p] = AFCeast[a];\r\n AFCeast[a] = Temp;\r\n }\r\n else if (AFCeast[a].displaywins() == AFCeast[p].displaywins() && AFCeast[a].displaypf() > AFCeast[p].displaypf()){\r\n Temp = league[p];\r\n league[p] = league[a];\r\n league[a] = Temp;\r\n }\r\n\r\n }\r\n }\r\n // System.out.println(AFCeast[0]);\r\n\r\n afcplayoff[0] = AFCeast[0];\r\n // System.out.println(afcplayoff[0]);\r\n for (int y=0;y<4;y++){\r\n for (int p=0;p<3;p++) {\r\n int a = p+1;\r\n if (AFCnorth[a].displaywins() > AFCnorth[p].displaywins()){\r\n Temp = AFCnorth[p];\r\n AFCnorth[p] = AFCnorth[a];\r\n AFCnorth[a] = Temp;\r\n }\r\n else if (AFCnorth[a].displaywins() == AFCnorth[p].displaywins() && AFCnorth[a].displaypf() > AFCnorth[p].displaypf()){\r\n Temp = league[p];\r\n league[p] = league[a];\r\n league[a] = Temp;\r\n }\r\n\r\n }\r\n }\r\n\r\n afcplayoff[1] = AFCnorth[0];\r\n for (int y=0;y<4;y++){\r\n for (int p=0;p<3;p++) {\r\n int a = p+1;\r\n if (AFCsouth[a].displaywins() > AFCsouth[p].displaywins()){\r\n Temp = AFCsouth[p];\r\n AFCsouth[p] = AFCsouth[a];\r\n AFCsouth[a] = Temp;\r\n }\r\n else if (AFCsouth[a].displaywins() == AFCsouth[p].displaywins() && AFCsouth[a].displaypf() > AFCsouth[p].displaypf()){\r\n Temp = league[p];\r\n league[p] = league[a];\r\n league[a] = Temp;\r\n }\r\n\r\n }\r\n }\r\n\r\n afcplayoff[2] = AFCsouth[0];\r\n for (int y=0;y<4;y++){\r\n for (int p=0;p<3;p++) {\r\n int a = p+1;\r\n if (AFCwest[a].displaywins() > AFCwest[p].displaywins()){\r\n Temp = AFCwest[p];\r\n AFCwest[p] = AFCwest[a];\r\n AFCwest[a] = Temp;\r\n }\r\n else if (AFCwest[a].displaywins() == AFCwest[p].displaywins() && AFCwest[a].displaypf() > AFCwest[p].displaypf()){\r\n Temp = league[p];\r\n league[p] = league[a];\r\n league[a] = Temp;\r\n }\r\n\r\n }\r\n }\r\n\r\n afcplayoff[3] = AFCwest[0];\r\n for (int y=0;y<4;y++){\r\n for (int p=0;p<3;p++) {\r\n int a = p+1;\r\n if (NFCeast[a].displaywins() > NFCeast[p].displaywins()){\r\n Temp = NFCeast[p];\r\n NFCeast[p] = NFCeast[a];\r\n NFCeast[a] = Temp;\r\n }\r\n else if (NFCeast[a].displaywins() == NFCeast[p].displaywins() && NFCeast[a].displaypf() > NFCeast[p].displaypf()){\r\n Temp = league[p];\r\n league[p] = league[a];\r\n league[a] = Temp;\r\n }\r\n\r\n }\r\n }\r\n nfcplayoff[0] = NFCeast[0];\r\n for (int y=0;y<4;y++){\r\n for (int p=0;p<3;p++) {\r\n int a = p+1;\r\n if (NFCnorth[a].displaywins() > NFCnorth[p].displaywins()){\r\n Temp = NFCnorth[p];\r\n NFCnorth[p] = NFCnorth[a];\r\n NFCnorth[a] = Temp;\r\n }\r\n else if (NFCnorth[a].displaywins() == NFCnorth[p].displaywins() && NFCnorth[a].displaypf() > NFCnorth[p].displaypf()){\r\n Temp = league[p];\r\n league[p] = league[a];\r\n league[a] = Temp;\r\n }\r\n\r\n }\r\n }\r\n nfcplayoff[1] = NFCnorth[0];\r\n for (int y=0;y<4;y++){\r\n for (int p=0;p<3;p++) {\r\n int a = p+1;\r\n if (NFCsouth[a].displaywins() > NFCsouth[p].displaywins()){\r\n Temp = NFCsouth[p];\r\n NFCsouth[p] = NFCsouth[a];\r\n NFCsouth[a] = Temp;\r\n }\r\n else if (NFCsouth[a].displaywins() == NFCsouth[p].displaywins() && NFCsouth[a].displaypf() > NFCsouth[p].displaypf()){\r\n Temp = league[p];\r\n league[p] = league[a];\r\n league[a] = Temp;\r\n }\r\n\r\n }\r\n }\r\n nfcplayoff[2] = NFCsouth[0];\r\n for (int y=0;y<4;y++){\r\n for (int p=0;p<3;p++) {\r\n int a = p+1;\r\n if (NFCwest[a].displaywins() > NFCwest[p].displaywins()){\r\n Temp = NFCwest[p];\r\n NFCwest[p] = NFCwest[a];\r\n NFCwest[a] = Temp;\r\n }\r\n else if (NFCwest[a].displaywins() == NFCwest[p].displaywins() && NFCwest[a].displaypf() > NFCwest[p].displaypf()){\r\n Temp = league[p];\r\n league[p] = league[a];\r\n league[a] = Temp;\r\n }\r\n\r\n }\r\n }\r\n nfcplayoff[3] = NFCwest[0];\r\n for (int y=0;y<16;y++){\r\n for (int p=0;p<15;p++) {\r\n int a = p+1;\r\n if (AFC[a].displaywins() > AFC[p].displaywins()){\r\n Temp = AFC[p];\r\n AFC[p] = AFC[a];\r\n AFC[a] = Temp;\r\n }\r\n else if (AFC[a].displaywins() == AFC[p].displaywins() && AFC[a].displaypf() > AFC[p].displaypf()){\r\n Temp = AFC[p];\r\n AFC[p] = AFC[a];\r\n AFC[a] = Temp;\r\n }\r\n\r\n }\r\n }\r\n for (int y=0;y<16;y++){\r\n for (int p=0;p<15;p++) {\r\n int a = p+1;\r\n if (NFC[a].displaywins() > NFC[p].displaywins()){\r\n Temp = NFC[p];\r\n NFC[p] = NFC[a];\r\n NFC[a] = Temp;\r\n }\r\n else if (NFC[a].displaywins() == NFC[p].displaywins() && NFC[a].displaypf() > NFC[p].displaypf()){\r\n Temp = NFC[p];\r\n NFC[p] = NFC[a];\r\n NFC[a] = Temp;\r\n }\r\n\r\n }\r\n }\r\n\r\n int maxw=0;\r\n\r\n for (int x=0;x<AFC.length;x++){\r\n\r\n if ((AFC[x].displaywins() > maxw) && \r\n (AFC[x].getName() != afcplayoff[0].getName()) && \r\n (AFC[x].getName() != afcplayoff[1].getName()) && \r\n (AFC[x].getName() != afcplayoff[2].getName()) && \r\n (AFC[x].getName() != afcplayoff[3].getName()) && \r\n (AFC[x].getName() != afcplayoff[4].getName()) && \r\n (AFC[x].getName() != afcplayoff[5].getName())){\r\n maxw = AFC[x].displaywins();\r\n afcplayoff[4] = AFC[x]; \r\n }\r\n\r\n }\r\n\r\n maxw=0;\r\n for (int x=0;x<AFC.length;x++){\r\n\r\n if (AFC[x].displaywins() > maxw && \r\n AFC[x].getName() != afcplayoff[0].getName() && \r\n AFC[x].getName() != afcplayoff[1].getName() && \r\n AFC[x].getName() != afcplayoff[2].getName() && \r\n AFC[x].getName() != afcplayoff[3].getName() && \r\n AFC[x].getName() != afcplayoff[4].getName() && \r\n AFC[x].getName() != afcplayoff[5].getName()){\r\n maxw = AFC[x].displaywins();\r\n afcplayoff[5] = AFC[x]; \r\n }\r\n }\r\n\r\n maxw=0;\r\n for (int x=0;x<NFC.length;x++){\r\n if (NFC[x].displaywins() > maxw && \r\n NFC[x].getName() != nfcplayoff[0].getName() && \r\n NFC[x].getName() != nfcplayoff[1].getName() && \r\n NFC[x].getName() != nfcplayoff[2].getName() && \r\n NFC[x].getName() != nfcplayoff[3].getName() && \r\n NFC[x].getName() != nfcplayoff[4].getName() && \r\n NFC[x].getName() != nfcplayoff[5].getName()){\r\n maxw = NFC[x].displaywins();\r\n nfcplayoff[4] = NFC[x]; \r\n }\r\n }\r\n maxw=0;\r\n for (int x=0;x<NFC.length;x++){\r\n\r\n if (NFC[x].displaywins() > maxw && \r\n NFC[x].getName() != nfcplayoff[0].getName() && \r\n NFC[x].getName() != nfcplayoff[1].getName() && \r\n NFC[x].getName() != nfcplayoff[2].getName() && \r\n NFC[x].getName() != nfcplayoff[3].getName() && \r\n NFC[x].getName() != nfcplayoff[4].getName() && \r\n NFC[x].getName() != nfcplayoff[5].getName()){\r\n maxw = NFC[x].displaywins();\r\n nfcplayoff[5] = NFC[x]; \r\n }\r\n }\r\n\r\n for (int y=0;y<4;y++){\r\n for (int p=0;p<3;p++) {\r\n int a = p+1;\r\n if (afcplayoff[a].displaywins() > afcplayoff[p].displaywins()){\r\n Temp = afcplayoff[p];\r\n afcplayoff[p] = afcplayoff[a];\r\n afcplayoff[a] = Temp;\r\n }\r\n else if (afcplayoff[a].displaywins() == afcplayoff[p].displaywins() && afcplayoff[a].displaypf() > afcplayoff[p].displaypf()){\r\n Temp = afcplayoff[p];\r\n afcplayoff[p] = afcplayoff[a];\r\n afcplayoff[a] = Temp;\r\n }\r\n\r\n }\r\n }\r\n for (int c=0;c<afcplayoff.length;c++){ // Testing to see if users team made the playoffs.\r\n if(YourTeam.getName().equals(afcplayoff[c].getName()))\r\n afcplayofft = true;\r\n }\r\n\r\n for (int y=0;y<4;y++){\r\n for (int r=0;r<3;r++) {\r\n int c = r+1;\r\n if (nfcplayoff[c].displaywins() > nfcplayoff[r].displaywins()){\r\n Temp = nfcplayoff[r];\r\n nfcplayoff[r] = nfcplayoff[c];\r\n nfcplayoff[c] = Temp;\r\n }\r\n else if (nfcplayoff[c].displaywins() == nfcplayoff[r].displaywins() && nfcplayoff[c].displaypf() > nfcplayoff[r].displaypf()){\r\n Temp = nfcplayoff[r];\r\n nfcplayoff[r] = nfcplayoff[c];\r\n nfcplayoff[c] = Temp;\r\n }\r\n\r\n }\r\n }\r\n for (int c=0;c<nfcplayoff.length;c++){\r\n if(YourTeam.getName().equals(nfcplayoff[c].getName()))\r\n nfcplayofft = true;\r\n }\r\n // This shows how the playoffs will look like to the user\r\n System.out.println(\"...\" + \"\\n\" + \"Based on the regular season, here is what the first round of playoffs will look like:\" + \"\\n\");\r\n try\r\n {\r\n Thread.sleep(3000);\r\n }\r\n catch (Exception e)\r\n {}\r\n System.out.println(afcplayoff[0].getName() + \" got a bye in the first round of the playoffs for placing first in the afc.\");\r\n System.out.println(afcplayoff[1].getName() + \" also got a bye in the first round of the playoffs for placing second in the afc.\" + \"\\n\");\r\n System.out.println(nfcplayoff[0].getName() + \" got a bye in the first round of the playoffs for placing first in the nfc.\");\r\n System.out.println(nfcplayoff[1].getName() + \" also got a bye in the first round of the playoffs for placing second in the nfc.\" + \"\\n\");\r\n\r\n System.out.println(afcplayoff[2].getName());\r\n System.out.println(\" \\\\-----\\\\\");\r\n System.out.println(\" ) Winner moves on to play the \" + afcplayoff[0].getName());\r\n System.out.println(\" /-----/\");\r\n System.out.println(afcplayoff[5].getName() + \"\\n\");\r\n\r\n System.out.println(afcplayoff[3].getName());\r\n System.out.println(\" \\\\-----\\\\\");\r\n System.out.println(\" ) Winner moves onto play the \"+ afcplayoff[1].getName());\r\n System.out.println(\" /-----/\");\r\n System.out.println(afcplayoff[4].getName() + \"\\n\");\r\n\r\n System.out.println(nfcplayoff[2].getName());\r\n System.out.println(\" \\\\-----\\\\\");\r\n System.out.println(\" ) Winner moves onto play the \"+ nfcplayoff[0].getName());\r\n System.out.println(\" /-----/\");\r\n System.out.println(nfcplayoff[5].getName() + \"\\n\");\r\n\r\n System.out.println(nfcplayoff[3].getName());\r\n System.out.println(\" \\\\-----\\\\\");\r\n System.out.println(\" ) Winner moves onto play the \"+ nfcplayoff[1].getName());\r\n System.out.println(\" /-----/\");\r\n System.out.println(nfcplayoff[4].getName() + \"\\n\");\r\n\r\n System.out.println(\"...\"+ \"\\n\");\r\n\r\n try\r\n {\r\n Thread.sleep(3000);\r\n }\r\n catch (Exception e)\r\n\r\n {}\r\n }", "private void completeGameBoard() {\n for (int i = 0; i < row; i++) {\n for (int j = 0; j < column; j++) {\n if (game[i][j].equals(open)) {\n int replaceOpen = getNearbyMines(i, j); //calls to get nearby mines\n game[i][j] = String.valueOf(replaceOpen);\n }\n }\n }\n }", "public void uTurnFormation() {\n // First, move all troops down column wise\n for (int j = 0; j < width; j ++) {\n for (int i = 0; i < depth; i++) {\n if (aliveTroopsFormation[i][j] == null) {\n int numSteps = depth - i;\n for (int rev = depth - 1; rev >= numSteps; rev--) {\n swapTwoTroopPositions( rev - numSteps, j, rev, j);\n }\n break;\n }\n }\n }\n\n // Then reverse the order\n for (int index = 0; index < width * depth / 2; index++) {\n int row = index / width;\n int col = index % width;\n swapTwoTroopPositions(row, col, depth - row - 1, width - col - 1);\n }\n\n // Reset the flankers\n resetFlanker();\n }", "private void bfs(int[][] board){\n int[][] original = {{1,2,3},{4,5,0}};\n LinkedList<Cell> queue = new LinkedList<>();\n HashMap<Cell,int[][]> states = new HashMap<Cell,int[][]>();\n Set<String> seen = new HashSet<>();\n queue.offer(new Cell(1,2));\n states.put(queue.peekFirst(),original);\n int step = 0;\n while(step <= maxStep){\n int sz = queue.size();\n while(sz-- > 0){\n Cell cur = queue.pollFirst();\n int[][] curBoard = states.get(cur);\n if(seen.contains(this.toStr(curBoard))){\n continue;\n }\n seen.add(this.toStr(curBoard));\n \n if (isSame(curBoard,board)){\n this.res = step;\n return;\n }\n // move around\n for(int i = 0; i < 4; ++i){\n int r = cur.row + dr[i];\n int c = cur.col + dc[i];\n if(r < 0 || c < 0 || r > 1 || c > 2) continue; \n Cell next = new Cell(r, c);\n queue.offer(next);\n int[][] nextboard = this.clone(curBoard);\n nextboard[cur.row][cur.col] = nextboard[r][c];\n nextboard[r][c] = 0;\n states.put(next,nextboard);\n }\n }\n ++step;\n }\n return;\n }", "public void movF(){\r\n\t\t\r\n\t\t\r\n\t\t/*\r\n\t\t * fallos , la f3 de la cara 4 pasa a la c0 de cara 2\r\n\t\t * la columna 0 de cara dos pasa a fila 1 cara 5\r\n\t\t * columna 3 de cara 0 para a fila 0 cara 4\r\n\t\t * fila 0 cara 5 pasa a columna 3 cara 0\r\n\t\t */\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\tint aux[][] = new int[1][3];\r\n\t\tint aux2[][] = new int[3][1];\r\n\t\tint aux3[][] = new int[1][3];\r\n\t\tint aux4[][] = new int[3][1];\r\n\t\t\r\n\t\tint aux5[][]= new int [1][3];\r\n\t\tint aux6[][]= new int [1][3];\r\n\t\tint aux7[][]= new int [1][3];\r\n\t\t\r\n\t\t//copiamos en un aux la primera fila de zona 5\r\n\t\taux=cloneF(5,0);\r\n\t\taux2=cloneC(0,2);\r\n\t\taux3=cloneF(4,2); //bloque 4 fila 2\r\n\t\taux4=cloneC(2,0);//bloque 2 col 0\r\n\t\t\r\n\t\taux5=cloneF(1,0);\r\n\t\taux6=cloneF(1,1);\r\n\t\taux7=cloneF(1,2);\r\n\t\t\r\n\t\t\r\n\t\tthis.copiaEnColumnaUnaFila(aux, 0, 2);//copiamos en bl0 col2\r\n\t\tthis.copiaEnFilaUnaColumnaReverse(aux2, 4, 2);\r\n\t\t\r\n\t\tthis.copiaEnColumnaUnaFila(aux3, 2, 0);//copiamos en bl0 la col0\r\n\t\tthis.copiaEnFilaUnaColumnaReverse(aux4, 5, 0);\r\n\t\t\r\n\t\tthis.copiaEnColumnaUnaFila(aux5, 1, 2);\r\n\t\tthis.copiaEnColumnaUnaFila(aux6, 1, 1);\r\n\t\tthis.copiaEnColumnaUnaFila(aux7, 1, 0);\r\n\t\t\r\n\t\t\r\n\t}", "public int evaluate(PentagoBoardState pbs) {\n PentagoBoardState.Piece[][] pieces = pbs.getBoard();\n\n\n int whitescore =0; //keep track of white's total score\n int blackscore = 0;//keep track of black's total score\n\n //Check rows\n for (int x = 0; x <6 ; x++) {\n int countWHori = 0;\n int countBHori = 0;\n\n int blacks = 0;\n int whites = 0;\n\n\n for (int y = 0; y <5 ; y++) {\n //Count how many black and white pieces\n if (pieces[x][y].ordinal() == 0 ) {\n\n //countBHori = countBHori + countvalue;\n blacks++;\n }\n if (pieces[x][y].ordinal() == 1) {\n\n //countWHori = countWHori +countvalue;\n whites++;\n }\n\n //Check for consecutive\n if (pieces[x][y].ordinal() == 0 && pieces[x][y+1].ordinal() == 0 ) {\n\n countBHori = countBHori +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 0 && pieces[x][y+1].ordinal() == 2 ) {\n\n countBHori = countBHori + blankspaceconsec;\n }\n else if (pieces[x][y].ordinal() == 2 && pieces[x][y+1].ordinal() == 0 ) {\n\n countBHori = countBHori + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x][y+1].ordinal() == 1 ) {\n\n countWHori = countWHori +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x][y+1].ordinal() == 2 ) {\n\n countWHori = countWHori + blankspaceconsec;\n }\n else if (pieces[x][y].ordinal() == 2 && pieces[x][y+1].ordinal() == 1 ) {\n\n countWHori = countWHori + blankspaceconsec;\n }\n\n //Check for disjoint and joint set If * B B W * * then disjoint and * B B * B * Then joint set for B * B\n if (y!=4){\n if (pieces[x][y].ordinal() == 0 && pieces[x][y+1].ordinal() == 0 && pieces[x][y+2].ordinal() == 1){\n countBHori = countBHori +disjointset;\n }\n else if (pieces[x][y].ordinal() == 1 && pieces[x][y+1].ordinal() == 1 && pieces[x][y+2].ordinal() == 0){\n countWHori = countWHori +disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x][y+1].ordinal() == 2 && pieces[x][y+2].ordinal() == 0){\n countBHori = countBHori +jointset;\n }\n else if (pieces[x][y].ordinal() == 1 && pieces[x][y+1].ordinal() == 2 && pieces[x][y+2].ordinal() == 1){\n countWHori = countWHori +jointset;\n }\n }\n }\n //check if unwinnable\n if (blacks == 4 && whites==2){\n countBHori += unwinnable;\n }\n if (blacks == 2 && whites==4){\n countWHori += unwinnable;\n }\n if (blacks == 3 && whites==3){\n countWHori += unwinnable;\n countBHori += unwinnable;\n }\n\n\n //Run value for row in evaluation scheme and add to total score\n int valuew = consecutivevalue(countWHori);\n whitescore = whitescore +valuew;\n int valueb = consecutivevalue(countBHori);\n blackscore = blackscore + valueb;\n //System.out.println(\"Black consec hori \" + valueb + \"White consec hori \" + valuew);\n\n }\n\n //Check Verticals\n for (int y = 0; y <6 ; y++) {\n int countWvert = 0;\n int countBvert = 0;\n int blacks = 0;\n int whites = 0;\n\n\n for (int x = 0; x <5 ; x++) {\n if (pieces[x][y].ordinal() == 0) {\n\n //countBvert = countBvert +1;\n blacks++;\n }\n if (pieces[x][y].ordinal() == 1) {\n\n //countWvert = countWvert +1;\n whites++;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y].ordinal() == 0 ) {\n\n countBvert = countBvert +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y].ordinal() == 2 ) {\n\n countBvert = countBvert + blankspaceconsec;\n }\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y].ordinal() == 0 ) {\n\n countBvert = countBvert + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y].ordinal() == 1 ) {\n\n countWvert = countWvert +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y].ordinal() == 2 ) {\n\n countWvert = countWvert + blankspaceconsec;\n }\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y].ordinal() == 1 ) {\n\n countWvert = countWvert + blankspaceconsec;\n }\n\n if (x!=4){\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y].ordinal() == 0 && pieces[x+1][y].ordinal() == 1){\n countBvert = countBvert +disjointset;\n }\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y].ordinal() == 1 && pieces[x+1][y].ordinal() == 0){\n countWvert = countWvert +disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y].ordinal() == 2 && pieces[x+1][y].ordinal() == 0){\n countBvert = countBvert +jointset;\n }\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y].ordinal() == 2 && pieces[x+1][y].ordinal() == 1){\n countWvert = countWvert +jointset;\n }\n }\n }\n\n if (blacks == 4 && whites==2){\n countBvert += unwinnable;\n }\n if (blacks == 3 && whites==3){\n countBvert += unwinnable;\n countWvert += unwinnable;\n }\n if (blacks == 2 && whites==4){\n countWvert += unwinnable;\n }\n //System.out.println(\"Black consec vert \" + countBvert + \"White consec \" + countWvert);\n int valuew = consecutivevalue(countWvert);\n whitescore = whitescore +valuew;\n int valueb = consecutivevalue(countBvert);\n blackscore = blackscore + valueb;\n //System.out.println(\"Black consec VERT \" + valueb + \"White consec hori \" + valuew);\n }\n\n //S West N EAST Top\n for (int a = 1; a <6 ; a++) { //loop through all diagonal lines\n int countWdiagSoNe = 0;\n int countBdiagSoNe = 0;\n int x=0;\n int blacks = 0;\n int whites = 0;\n\n\n for (int y = a; y !=0 ; y--) { //loop through one diagonal line\n\n int r = pieces[x][y].ordinal();\n int s =pieces[x+1][y-1].ordinal();\n //System.out.println(\"x \" + x+ \" y \" +y);\n //System.out.println(\"first \" + r+ \" second \" +s);\n if (pieces[x][y].ordinal() == 0) {\n\n //countBdiagSoNe = countBdiagSoNe +2;\n blacks++;\n }\n if (pieces[x][y].ordinal() == 1 ) {\n\n //countWdiagSoNe = countWdiagSoNe +2;\n whites++;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 ) {\n\n countBdiagSoNe = countBdiagSoNe +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 ) {\n\n countBdiagSoNe = countBdiagSoNe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y-1].ordinal() == 0 ) {\n\n countBdiagSoNe = countBdiagSoNe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 ) {\n\n countWdiagSoNe = countWdiagSoNe +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 ) {\n\n countWdiagSoNe = countWdiagSoNe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y-1].ordinal() == 1 ) {\n\n countWdiagSoNe = countWdiagSoNe + blankspaceconsec;\n }\n\n // check for joint and disjoint set at these x y coordinates by looking 2 pieces ahead\n if (x==0 && y==4){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n if (x==1 && y==3){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n if (x==2 && y==2){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n if (x==0 && y==5){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n if (x==1 && y==4){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n if (x==2 && y==3){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n if (x==3 && y==2){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n\n x++;\n\n\n }\n if (blacks == 4 && whites==2){\n countBdiagSoNe += unwinnable;\n }\n if (blacks == 3 && whites==3){\n countBdiagSoNe += unwinnable;\n countWdiagSoNe += unwinnable;\n }\n if (blacks == 2 && whites==4){\n countWdiagSoNe += unwinnable;\n }\n if (a==4 && blacks == 4 && whites==1){\n countBdiagSoNe += unwinnable;\n }\n if (a==4 && blacks == 1 && whites==4){\n countWdiagSoNe += unwinnable;\n }\n\n //System.out.println(\"Black consec vert \" + countBdiagSoNe + \"White consec \" + countWdiagSoNe);\n int valuew = consecutivevalue(countWdiagSoNe);\n whitescore = whitescore +valuew;\n int valueb = consecutivevalue(countBdiagSoNe);\n blackscore = blackscore + valueb;\n //System.out.println(\"Black consec DIAGOMAAL \" + valueb + \" \" + countBdiagSoNe + \"White consec hori \" + valuew + \" \" + countWdiagSoNe);\n }\n //S West N EAST Bot\n for (int a = 1; a <5 ; a++) {\n int countWdiagSoNe = 0;\n int countBdiagSoNe = 0;\n int y=5;\n int blacks = 0;\n int whites = 0;\n\n for (int x = a; x <5 ; x++) {\n\n int r = pieces[x][y].ordinal();\n int s =pieces[x+1][y-1].ordinal();\n //System.out.println(\"x \" + x+ \" y \" +y);\n //System.out.println(\"first \" + r+ \" second \" +s);\n if (pieces[x][y].ordinal() == 0) {\n\n //countBdiagSoNe = countBdiagSoNe +\n blacks++;\n }\n if (pieces[x][y].ordinal() == 1 ) {\n\n //countWdiagSoNe = countWdiagSoNe +2;\n whites++;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 ) {\n\n countBdiagSoNe = countBdiagSoNe +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 ) {\n\n countBdiagSoNe = countBdiagSoNe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y-1].ordinal() == 0 ) {\n\n countBdiagSoNe = countBdiagSoNe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 ) {\n\n countWdiagSoNe = countWdiagSoNe +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 ) {\n\n countWdiagSoNe = countWdiagSoNe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y-1].ordinal() == 1 ) {\n\n countWdiagSoNe = countWdiagSoNe + blankspaceconsec;\n }\n if (x==1 && y==5){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n if (x==2 && y==4){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n if (x==3 && y==3){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 1 && pieces[x+2][y-2].ordinal() == 0) {\n\n countWdiagSoNe = countWdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 0 && pieces[x+2][y-2].ordinal() == 1) {\n\n countBdiagSoNe = countBdiagSoNe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 1) {\n\n countWdiagSoNe = countWdiagSoNe +jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y-1].ordinal() == 2 && pieces[x+2][y-2].ordinal() == 0) {\n\n countBdiagSoNe = countBdiagSoNe + jointset;\n }\n }\n //System.out.println(x + \" y:\" + y +\" Black consec DIAGOMAAL \" + countBdiagSoNe + \"White consec hori \" + countWdiagSoNe);\n y--;\n\n\n }\n if (a==1 && blacks == 4 && whites==1){\n countBdiagSoNe += unwinnable;\n }\n /*if (blacks == 3 && whites==3){\n countBdiagSoNe += unwinnable;\n countWdiagSoNe += unwinnable;\n }*/\n if (a==1&& blacks == 1 && whites==4){\n countWdiagSoNe += unwinnable;\n }\n //System.out.println(\"Black consec vert \" + countBdiagSoNe + \"White consec \" + countWdiagSoNe);\n int valuew = consecutivevalue(countWdiagSoNe);\n whitescore = whitescore +valuew;\n int valueb = consecutivevalue(countBdiagSoNe);\n blackscore = blackscore + valueb;\n //System.out.println(\"Black consec DIAGOMAAL \" + valueb + \" \" + countBdiagSoNe + \"White consec hori \" + valuew + \" \" + countWdiagSoNe);\n }\n\n //NorthWest S EAST Left\n for (int a = 0; a <5 ; a++) {\n int countWdiagNoSe = 0;\n int countBdiagNoSe = 0;\n int y=0;\n int blacks = 0;\n int whites = 0;\n\n for (int x = a; x <5 ; x++) {\n //System.out.println(pbs+\"x \" + x+ \" y \" +y);\n int r = pieces[x][y].ordinal();\n int s =pieces[x+1][y+1].ordinal();\n //System.out.println(\"x \" + x+ \" y \" +y);\n //System.out.println(\"first \" + r+ \" second \" +s);\n if (pieces[x][y].ordinal() == 0) {\n blacks++;\n //countBdiagNoSe = countBdiagNoSe +2;\n }\n if (pieces[x][y].ordinal() == 1) {\n whites++;\n //countWdiagNoSe = countWdiagNoSe +2;\n }\n\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 ) {\n\n countBdiagNoSe = countBdiagNoSe +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 ) {\n\n countBdiagNoSe = countBdiagNoSe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y+1].ordinal() == 0 ) {\n\n countBdiagNoSe = countBdiagNoSe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 ) {\n\n countWdiagNoSe = countWdiagNoSe +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 ) {\n\n countWdiagNoSe= countWdiagNoSe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y+1].ordinal() == 1 ) {\n\n countWdiagNoSe = countWdiagNoSe + blankspaceconsec;\n }\n\n if (x==0 && y==0){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n if (x==1 && y==1){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n if (x==2 && y==2){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n if (x==3 && y==3){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n if (x==1 && y==0){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n if (x==2 && y==1){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n if (x==3 && y==2){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n y++;\n\n\n }\n //System.out.println(\"Black consec vert \" + countBdiagSoNe + \"White consec \" + countWdiagSoNe);\n if (blacks == 4 && whites==2){\n countBdiagNoSe += unwinnable;\n }\n if (a==1 && blacks == 4 && whites==1){\n countBdiagNoSe += unwinnable;\n }\n if (blacks == 3 && whites==3){\n countBdiagNoSe += unwinnable;\n countWdiagNoSe += unwinnable;\n }\n if (blacks == 2 && whites==4){\n countWdiagNoSe += unwinnable;\n }\n if (a==1 && blacks == 1 && whites==4){\n countWdiagNoSe += unwinnable;\n }\n\n int valuew = consecutivevalue(countWdiagNoSe);\n whitescore = whitescore +valuew;\n int valueb = consecutivevalue( countBdiagNoSe);\n blackscore = blackscore + valueb;\n //System.out.println(\"Black consec DIAGOMAAL \" + valueb + \" \" + countBdiagNoSe + \"White consec hori \" + valuew + \" \" + countWdiagNoSe);\n }\n //NorthWest S EAST Right\n for (int a = 1; a <5 ; a++) {\n int countWdiagNoSe = 0;\n int countBdiagNoSe = 0;\n int x=0;\n int blacks = 0;\n int whites = 0;\n\n for (int y = a; y <5 ; y++) {\n //System.out.println(\"x \" + x+ \" y \" +y);\n int r = pieces[x][y].ordinal();\n int s =pieces[x+1][y+1].ordinal();\n //System.out.println(\"x \" + x+ \" y \" +y);\n //System.out.println(\"first \" + r+ \" second \" +s);\n if (pieces[x][y].ordinal() == 0 ) {\n blacks++;\n //countBdiagNoSe = countBdiagNoSe +2;\n }\n if (pieces[x][y].ordinal() == 1) {\n whites++;\n //countWdiagNoSe = countWdiagNoSe +2;\n }\n\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 ) {\n\n countBdiagNoSe = countBdiagNoSe +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 ) {\n\n countBdiagNoSe = countBdiagNoSe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y+1].ordinal() == 0 ) {\n\n countBdiagNoSe = countBdiagNoSe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 ) {\n\n countWdiagNoSe = countWdiagNoSe +consecvalue;\n }\n\n else if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 ) {\n\n countWdiagNoSe= countWdiagNoSe + blankspaceconsec;\n }\n\n else if (pieces[x][y].ordinal() == 2 && pieces[x+1][y+1].ordinal() == 1 ) {\n\n countWdiagNoSe = countWdiagNoSe + blankspaceconsec;\n }\n\n if (x==0 && y==1){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n if (x==1 && y==2){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n if (x==2 && y==3){\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 1 && pieces[x+2][y+2].ordinal() == 0) {\n\n countWdiagNoSe = countWdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 0 && pieces[x+2][y+2].ordinal() == 1) {\n\n countBdiagNoSe = countBdiagNoSe + disjointset;\n }\n if (pieces[x][y].ordinal() == 1 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 1) {\n\n countWdiagNoSe = countWdiagNoSe + jointset;\n }\n else if (pieces[x][y].ordinal() == 0 && pieces[x+1][y+1].ordinal() == 2 && pieces[x+2][y+2].ordinal() == 0) {\n\n countBdiagNoSe = countBdiagNoSe + jointset;\n }\n }\n x++;\n\n\n }\n if (a==1 && blacks == 1 && whites==4){\n countWdiagNoSe += unwinnable;\n }\n if (a==1 && blacks == 4 && whites==1){\n countBdiagNoSe += unwinnable;\n }\n //System.out.println(\"Black consec vert \" + countBdiagSoNe + \"White consec \" + countWdiagSoNe);\n int valuew = consecutivevalue(countWdiagNoSe);\n whitescore = whitescore +valuew;\n int valueb = consecutivevalue( countBdiagNoSe);\n blackscore = blackscore + valueb;\n //System.out.println(\"Black consec DIAGOMAAL \" + valueb + \" \" + countBdiagNoSe + \"White consec hori \" + valuew + \" \" + countWdiagNoSe);\n }\n\n\n\n\n\n //System.out.println(\"Black consec score \" + blackscore +\" \" + \"White consec scpre \" + whitescore);\n //System.out.println(\"max player is \" + maxplayer + \"My colour is \" + mycolour);\n int i = -123456789;\n if (mycolour == 0){\n //System.out.println(blackscore-whitescore +\" I am black\");\n\n\n i= blackscore-whitescore;\n return i;\n\n }\n else {\n //System.out.println(whitescore-blackscore +\" I am white\");\n i= whitescore-blackscore;\n return i;\n }\n /*\n if(i>0 && i<1000){\n return 100; //i*2;\n }\n else if(i>=1000 && i<10000){\n return 1000; //i*10;\n }\n else if(i>=10000 && i<100000){\n return 10000; //i*50;\n }\n else if(i>=100000){\n return 100000;//i*500;\n }\n else if(i<=0 && i>-100){\n return -100; //i*2;\n }\n else if(i<=-100 && i>-1000){\n return -1000; //i*10;\n }\n else if(i<=-1000 && i>-10000){\n return -10000; //i*50;\n }\n else if(i<=0 && i>-100000){\n return -100000;//i*500;\n }\n\n */\n\n\n }", "@Override\n public String toString() {\n StringBuilder sb = new StringBuilder();\n\n for (int i = 0; i < row; i++) {\n for (int j = 0; j < column; j++) {\n sb.append(game[i][j]);\n }\n sb.append(\"\\n\");\n }\n return sb.toString();\n }", "public String convertBoardToString(){\n String tmp= \"\";\n\n for (int i=0; i<30; i++){\n for (int j=0; j<80; j++){\n if (board.getCharacter(j,i)==0){\n tmp += '-';\n } else {\n tmp += board.getCharacter(j,i);\n }\n }\n }\n return tmp;\n }", "@Override\n\tpublic String toString(){\n\t\tString game;\n\t\t\n\t\tgame=this.currentBoard.toString();\n\t\tgame=game+\"best value: \"+this.currentRules.getWinValue(currentBoard)+\" Score: \"+this.points+\"\\n\";\n\t\t\n\t\tif(currentRules.win(currentBoard)){\n\t\t\tgame=game+\"Well done!\\n\";\n\t\t\tfinish=true;\n\t\t}\n\t\telse if(currentRules.lose(currentBoard)){\n\t\t\tgame=game+\"Game over.\\n\";\n\t\t\tfinish=true;\n\t\t}\n\t\t\n\t\treturn game;\n\t}", "int evalLkp(int f) {\n\tint r = 0;\n\n\tif (pawnRank[LIGHT][f] == 6)\n\t; /* pawn hasn't moved */\n\telse if (pawnRank[LIGHT][f] == 5)\n\tr -= 10; /* pawn moved one square */\n\telse if (pawnRank[LIGHT][f] != 0)\n\tr -= 20; /* pawn moved more than one square */\n\telse\n\tr -= 25; /* no pawn on this file */\n\n\tif (pawnRank[DARK][f] == 7)\n\tr -= 15; /* no enemy pawn */\n\telse if (pawnRank[DARK][f] == 5)\n\tr -= 10; /* enemy pawn on the 3rd rank */\n\telse if (pawnRank[DARK][f] == 4)\n\tr -= 5; /* enemy pawn on the 4th rank */\n\n\treturn r;\n\t}", "private String gameBoardToString(){\n StringBuilder config = new StringBuilder();\n\n //length attribute gets the number of rows in a 2D array. length attribute on a row gets the number of columns in a\n // 2D array. We iterate through all the rows and columns and join all the characters in the array into a single\n // String config\n\n for (int i = 0; i < this.boardRows; i++){\n for (int j =0; j < this.boardColumns; j++){\n config.append(this.gameBoard[i][j]);\n }\n }\n\n // Returns String object representation of StringBuilder object\n return config.toString();\n\n }", "public static void drawFullBoard()\n {\n char rowLetter=' '; //Letra de las filas.\n \n System.out.println(\" 1 2 3 4 \" ); //Imprime la parte superior del tablero.\n System.out.println(\" +-------+-------+\");\n \n \n for (int i = 0; i< BOARD_HEIGHT; i++) //Controla los saltos de fila.\n {\n switch(i)\n {\n case 0: rowLetter='A';\n break;\n case 1: rowLetter='B';\n break;\n case 2: rowLetter='C';\n break;\n case 3: rowLetter='D';\n break;\n }\n \n System.out.print(rowLetter);\n \n for (int j = 0; j < BOARD_WIDTH; j++ ) //Dibuja las filas.\n {\n if (boardPos[i][j]==0)\n {\n System.out.print(\"| · \");\n }\n else\n {\n System.out.print(\"| \" + boardPos[i][j] + \" \");\n }\n }\n System.out.println(\"|\");\n \n if (i==((BOARD_HEIGHT/2)-1)) //Si se ha dibujado la mitad del tablero.\n {\n System.out.println(\" +-------+-------+\"); //Dibuja una separación en medio del tablero.\n }\n }\n \n System.out.println(\" +-------+-------+\"); //Dibuja linea de fin del tablero.\n }", "public String toString(){\n\t\tchar[][] boardRep = new char[yDim + 2][xDim + 2];\n\t\t\n\t\tfor(int i = 0; i < boardRep.length; i++){\n\t\t\tfor(int j = 0; j < boardRep[i].length; j++){\n\t\t\t\tboardRep[i][j] = ' ';\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < yDim + 2; i++){\n\t\t\tboardRep[i][0] = '.';\n\t\t\tboardRep[i][xDim + 1] = '.';\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < xDim + 2; i++){\n\t\t\tboardRep[0][i] = '.';\n\t\t\tboardRep[yDim + 1][i] = '.';\n\t\t}\n\t\t\n\t\tfor (Gadget g : gadgets){\n\t\t\tif(g instanceof SquareBumper){\n\t\t\t\tboardRep[g.getY() + 1][g.getX() + 1]= '#';\n\t\t\t}else if(g instanceof TriangularBumper){\n\t\t\t\tif(((TriangularBumper) g).getOrientation() % 2 == 0)\t\n\t\t\t\t\tboardRep[g.getY() + 1][g.getX() + 1]= '/';\n\t\t\t\tif(((TriangularBumper) g).getOrientation() % 2 == 1)\t\n\t\t\t\t\tboardRep[g.getY() + 1][g.getX() + 1]= '\\\\';\n\t\t\t}else if(g instanceof CircularBumper){\n\t\t\t\tboardRep[g.getY() + 1][g.getX() + 1]= 'O';\n\t\t\t}else if(g instanceof Absorber){\n\t\t\t\tfor(int i=g.getX(); i < g.getX() + g.getWidth(); i++){\n\t\t\t\t\tfor(int j=g.getY(); j < g.getY() + g.getHeight(); j++){\n\t\t\t\t\t\tboardRep[j + 1][i + 1] = '=';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}else if(g instanceof Flipper){\n\t\t\t\tFlipper f = (Flipper) g;\n\t\t\t\tif (f.isLeft && f.orientation == 0){\n\t\t\t\t\tboardRep[f.getY()+1][f.getX()+1] = '|';\n\t\t\t\t\tboardRep[f.getY()+2][f.getX()+1] = '|';\n\t\t\t\t} else if(f.orientation == 0){\n\t\t\t\t\tboardRep[f.getY()+1][f.getX()+2] = '|';\n\t\t\t\t\tboardRep[f.getY()+2][f.getX()+2] = '|';\n\t\t\t\t} else{\n\t\t\t\t\tboardRep[f.getY()+1][f.getX()+1] = '-';\n\t\t\t\t\tboardRep[f.getY()+1][f.getX()+2] = '-';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(Ball b : balls){\n\t\t\tboardRep[(int) (b.getY() + 1)][(int) (b.getX() + 1)]= '*';\n\t\t}\n\t\t\n\t\tStringBuffer boardString = new StringBuffer();\n\t\tfor(char[] row : boardRep){\n\t\t\tfor(char c : row){\n\t\t\t\tboardString.append(c);\n\t\t\t}\n\t\t\tboardString.append('\\n');\n\t\t}\n\t\t\n\t\treturn boardString.toString();\n\t}", "private static String formatFamily (FamilyCard fc) {\n\t\tString res = \"\";\n\n\t\tFamilyHeadGuest fhg = fc.getCapoFamiglia();\n\t\tres += FamilyHeadGuest.CODICE;\n\t\tres += DateUtils.format(fc.getDate());\n\t\tres += String.format(\"%02d\", fc.getPermanenza());\n\t\tres += padRight(fhg.getSurname().trim().toUpperCase(),50);\n\t\tres += padRight(fhg.getName().trim().toUpperCase(),30);\n\t\tres += fhg.getSex().equals(\"M\") ? 1 : 2;\n\t\tres += DateUtils.format(fhg.getBirthDate());\n\n\t\t//Setting luogo et other balles is a bit more 'na rottura\n\t\tres += formatPlaceOfBirth(fhg.getPlaceOfBirth());\n\n\t\tPlace cita = fhg.getCittadinanza(); //banana, box\n\t\tres += cita.getId();\n\n\t\tres += fhg.getDocumento().getDocType().getCode();\n\t\tres += padRight(fhg.getDocumento().getCodice(),20);\n\t\tres += fhg.getDocumento().getLuogoRilascio().getId();\n\t\t//Assert.assertEquals(168,res.length()); //if string lenght is 168 we are ok\n\t\tres += \"\\r\\n\";\n\n\t\tfor (FamilyMemberGuest fmg : fc.getFamiliari()){\n\t\t\tres += formatFamilyMember(fmg, fc.getDate(), fc.getPermanenza());\n\t\t\t//res += \"\\r\\n\";\n\t\t}\n\n\t\treturn res;\n\t}", "public String toString() {\n\t\tString resultString = \"\\r\\n\";\n\t\t//resultString += \"Checkerboard state: \\r\\n\";\n\t\tfor (int i = 0; i < checkerboard.length; i++) {\n\t\t\tfor (int j = 0; j < checkerboard.length; j++) {\n\t\t\t\tif (checkerboard[i][j] == WHITE) {\n\t\t\t\t\tresultString += \"o \";\n\t\t\t\t} else if (checkerboard[i][j] == BLACK) {\n\t\t\t\t\tresultString += \"x \";\n\t\t\t\t} else {\n\t\t\t\t\tresultString += \"- \";\n\t\t\t\t}//Of if\n\t\t\t}//Of for j\n\t\t\tresultString += \"\\r\\n\";\n\t\t}//Of for i\n\t\t\n\t\tresultString += currentState;\n\n\t\t//resultString += \"\\r\\nThe current situation is: \" + gameSituation;\n\t\treturn resultString;\n\t}", "public static void main(String args[]) {\n N = in.nextInt();\n M = in.nextInt();\n board = new char[N][M];\n for (int i = 0; i < N; i++) {\n board[i] = in.next().toCharArray();\n }\n int tot = 0;\n for (int i = 1; i < N - 1; i++) {\n tot += f(new char[2], 0, i, 0, 0, 1, 0);\n tot += f(new char[2], 0, i, M - 1, 0, -1, 0);\n }\n for (int i = 1; i < M - 1; i++) {\n tot += f(new char[2], 0, 0, i, 1, 0, 0);\n tot += f(new char[2], 0, N - 1, i, -1, 0, 0);\n }\n out.println(tot / 2);\n out.close();\n }", "public String toString() {\r\n\t\tif (rank == 1) {\r\n\t\t\treturn \"slayer\";\r\n\t\t} else if (rank == 2) {\r\n\t\t\treturn \"scout\";\r\n\t\t} else if (rank == 3) {\r\n\t\t\treturn \"dwraf\";\r\n\t\t} else if (rank == 4) {\r\n\t\t\treturn \"elf\";\r\n\t\t} else if (rank == 5) {\r\n\t\t\treturn \"lavaBeast\";\r\n\t\t} else if (rank == 6) {\r\n\t\t\treturn \"sorceress\";\r\n\t\t} else if (rank == 7) {\r\n\t\t\treturn \"beastRider\";\r\n\t\t} else if (rank == 8) {\r\n\t\t\treturn \"knight\";\r\n\t\t} else if (rank == 9) {\r\n\t\t\treturn \"mage\";\r\n\t\t} else {\r\n\t\t\treturn \"dragon\";\r\n\t\t}\r\n\r\n\t}", "public static void produceRankFilesFromTable(String fn, String outfolder, String name) throws Exception{\n\t\t\tString folder = outfolder;\n\t\t\tVDataTable tab = VDatReadWrite.LoadFromSimpleDatFile(fn, true, \"\\t\");\n\t\t\tfor(int i=1;i<tab.colCount;i++){\n\t\t\t\tString field = tab.fieldNames[i];\n\t\t\t\tFileWriter fw_minus_rnk = new FileWriter(folder+\"/\"+name+\"_\"+field+\".rnk\");\n\t\t\t\tFileWriter fw_plus = new FileWriter(folder+\"/\"+name+\"_\"+field+\"_plus\");\n\t\t\t\tFileWriter fw_minus = new FileWriter(folder+\"/\"+name+\"_\"+field+\"_minus\");\n\t\t\t\tFileWriter fw_abs = new FileWriter(folder+\"/\"+name+\"_\"+field+\"_abs\");\n\t\t\t\tfloat vals[] = new float[tab.rowCount];\n\t\t\t\tfloat val_abs[] = new float[tab.rowCount];\n\t\t\t\tfor(int j=0;j<tab.rowCount;j++){ \n\t\t\t\t\tfloat f = Float.parseFloat(tab.stringTable[j][i]); \n\t\t\t\t\tvals[j] = f;\n\t\t\t\t\tval_abs[j] = Math.abs(f);\n\t\t\t\t}\n\t\t\t\tint inds[] = Algorithms.SortMass(vals);\n\t\t\t\tint ind_abs[] = Algorithms.SortMass(val_abs);\n\t\t\t\tfor(int j=0;j<inds.length;j++){\n\t\t\t\t\t/*fw_plus.write(tab.stringTable[inds[inds.length-1-j]][0]+\"\\t\"+vals[inds[inds.length-1-j]]+\"\\n\");\n\t\t\t\t\tfw_minus.write(tab.stringTable[inds[j]][0]+\"\\t\"+vals[inds[j]]+\"\\n\");\n\t\t\t\t\tfw_abs.write(tab.stringTable[ind_abs[inds.length-1-j]][0]+\"\\t\"+val_abs[ind_abs[inds.length-1-j]]+\"\\n\");*/\n\t\t\t\t\tfw_plus.write(tab.stringTable[inds[inds.length-1-j]][0]+\"\\n\");\n\t\t\t\t\tfw_minus.write(tab.stringTable[inds[j]][0]+\"\\n\");\n\t\t\t\t\tfw_abs.write(tab.stringTable[ind_abs[inds.length-1-j]][0]+\"\\n\");\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tHashMap<String, Float> values = new HashMap<String, Float>(); \n\t\t\t\tfor(int j=0;j<tab.rowCount;j++){\n\t\t\t\t\tString nm = tab.stringTable[j][0];\n\t\t\t\t\tfloat f = Float.parseFloat(tab.stringTable[j][i]);\n\t\t\t\t\tFloat fv =values.get(nm);\n\t\t\t\t\tif(fv==null)\n\t\t\t\t\t\tvalues.put(nm, f);\n\t\t\t\t\telse{\n\t\t\t\t\t\tif(Math.abs(f)>Math.abs(fv)){\n\t\t\t\t\t\t\tvalues.put(nm, f);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfloat vls[] = new float[values.keySet().size()];\n\t\t\t\tString nms[] = new String[values.keySet().size()];\n\t\t\t\tint k=0;\n\t\t\t\tfor(String s: values.keySet()){\n\t\t\t\t\tnms[k] = s;\n\t\t\t\t\tvls[k] = values.get(s);\n\t\t\t\t\tk++;\n\t\t\t\t}\n\t\t\t\tinds = Algorithms.SortMass(vls);\n\t\t\t\tfor(int j=0;j<inds.length;j++){\n\t\t\t\t\tfw_minus_rnk.write(nms[inds[j]]+\"\\t\"+vls[inds[j]]+\"\\n\");\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfw_plus.close();fw_minus.close();fw_abs.close(); fw_minus_rnk.close();\n\t\t\t}\n\t}", "private void coins_fW(){\n\t\tthis.cube[4] = this.cube[0]; \n\t\tthis.cube[0] = this.cube[6];\n\t\tthis.cube[6] = this.cube[8];\n\t\tthis.cube[8] = this.cube[2];\n\t\tthis.cube[2] = this.cube[4];\n\t}", "private long m673F() {\n int i = 0;\n long j = 0;\n if (this.f552g.mo501h() >= 10) {\n byte[] f = this.f552g.mo499f();\n int g = this.f552g.mo500g();\n long j2 = 0;\n int i2 = 0;\n while (true) {\n byte b = f[g + i];\n j2 |= ((long) (b & Byte.MAX_VALUE)) << i2;\n if ((b & 128) != 128) {\n this.f552g.mo495a(i + 1);\n return j2;\n }\n i2 += 7;\n i++;\n }\n } else {\n while (true) {\n byte u = mo470u();\n j |= ((long) (u & Byte.MAX_VALUE)) << i;\n if ((u & 128) != 128) {\n return j;\n }\n i += 7;\n }\n }\n }", "@Override\n public String[] draw() {\n Piece[][] pieces = solver.getSolution();\n int height = pieces.length;\n int width = pieces[0].length;\n char[][] board = new char[height * 4][width * 4 + 1];\n int totalPieces = pieces.length * pieces[0].length;\n int countPieces = 0;\n // run through each piece and add it to the temp board\n for (int i = 0; i < height; i++) {\n for (int j = 0; j < width; j++) {\n countPieces++;\n Piece curPiece = pieces[i][j];\n int tempHeight = i * 4 + 1;\n int tempWidth = j * 4 + 2;\n if (curPiece == null) {\n board[tempHeight][tempWidth] = EMPTY;\n board[tempHeight][tempWidth + 1] = EMPTY;\n board[tempHeight][tempWidth + 2] = EMPTY;\n board[tempHeight + 1][tempWidth] = EMPTY;\n board[tempHeight + 1][tempWidth + 1] = EMPTY;\n board[tempHeight + 1][tempWidth + 2] = EMPTY;\n board[tempHeight + 2][tempWidth] = EMPTY;\n board[tempHeight + 2][tempWidth + 1] = EMPTY;\n board[tempHeight + 2][tempWidth + 2] = EMPTY;\n Arrays.fill(board[tempHeight + 3], EMPTY);\n } else {\n char[][] displayPiece = pieceToDisplay(curPiece);\n\n board[tempHeight][tempWidth] = displayPiece[0][0];\n board[tempHeight][tempWidth + 1] = displayPiece[0][1];\n board[tempHeight][tempWidth + 2] = displayPiece[0][2];\n board[tempHeight + 1][tempWidth] = displayPiece[1][0];\n board[tempHeight + 1][tempWidth + 1] = displayPiece[1][1];\n board[tempHeight + 1][tempWidth + 2] = displayPiece[1][2];\n board[tempHeight + 2][tempWidth] = displayPiece[2][0];\n board[tempHeight + 2][tempWidth + 1] = displayPiece[2][1];\n board[tempHeight + 2][tempWidth + 2] = displayPiece[2][2];\n Arrays.fill(board[tempHeight + 3], EMPTY);\n }\n }\n }\n\n // convert the completed char[][] to the final string[]\n return finalBoard(board, totalPieces, totalPieces - countPieces);\n }", "private void generateOutgoingRankingReport() {\r\n\r\n\t\tStringBuilder stringBuilder = new StringBuilder();\r\n\t\tstringBuilder.append(\"\\n----------------------------------------\\n\")\r\n\t\t\t\t.append(\" Outgoing Ranking \\n\")\r\n\t\t\t\t.append(\"----------------------------------------\\n\")\r\n\t\t\t\t.append(\" Entity | Rank \\n\")\r\n\t\t\t\t.append(\"-----------------+----------------------\\n\");\r\n\t\tallOutgoingRankings.entrySet().stream().sorted(Map.Entry.<String, Integer>comparingByValue())\r\n\t\t\t\t.forEach(key -> stringBuilder\r\n\t\t\t\t\t\t.append(\" \" + key.getKey() + \" | \" + key.getValue() + \" \\n\"));\r\n\t\tdataWriter.write(stringBuilder.toString());\r\n\t}", "private BDD nextGeneration(BDD generation){\n\t\tBDD res = this.factory.makeOne();\n\t\tAssignment assignment = generation.anySat();\n\n\n\t\t// be build the map/transition from board to board_p vars\n\t\tfor(int i = 0; i < this.dimension; i++)\n\t\t\tfor(int j = 0; j < this.dimension; j++){\n\n\n\t\t\t\t// it's a live cell, we remove it if we can\n\t\t\t\tif(assignment.holds(this.board[i][j])){\n\n\t\t\t\t\tif(trySolitude(i, j, assignment)){\t\n\t\t\t\t\t\tres.andWith(this.board[i][j].copy()); // evaluate T the var in board\n\t\t\t\t\t\tres.andWith(this.board_p[i][j].not()); // evaluate F the var in board_p\t\t\t\t\t\t\n\t\t\t\t\t}\n\n\t\t\t\t\telse if(tryOverpopulation(i, j, assignment)){\n\t\t\t\t\t\tres.andWith(this.board[i][j].copy()); \n\t\t\t\t\t\tres.andWith(this.board_p[i][j].not()); \n\t\t\t\t\t}\n\n\t\t\t\t\telse if(tryBorder(i, j)){\n\t\t\t\t\t\tres.andWith(this.board[i][j].copy()); \n\t\t\t\t\t\tres.andWith(this.board_p[i][j].not()); \n\t\t\t\t\t}\n\n\t\t\t\t\telse{\n\t\t\t\t\t\tres.andWith(this.board[i][j].copy()); // evaluate T the var in board\n\t\t\t\t\t\tres.andWith(this.board_p[i][j].copy()); // evaluate T the var in board_p\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\t// it's a dead cell, we populate it if we can\n\t\t\t\telse{\n\n\t\t\t\t\tif(tryPopulatingDeadCell(i, j, assignment)){\n\t\t\t\t\t\tres.andWith(this.board[i][j].not()); \t// evaluate F the var in board\n\t\t\t\t\t\tres.andWith(this.board_p[i][j].copy()); // evaluate T the var in board_p\n\t\t\t\t\t}\n\n\t\t\t\t\telse\n\t\t\t\t\t\tres.andWith(this.board[i][j].biimp(this.board_p[i][j])); // vars equal\n\n\t\t\t\t}\n\t\t\t}\n\n\n\t\treturn res;\n\t}", "private void copyRostersToMatch(int week){\r\n List<FantasyMatch> fMatches = fmatchBean.findByWeek(week);\r\n for(int i = 0; i < fMatches.size(); i++){\r\n FantasyMatch fm = fMatches.get(i);\r\n List<RosterPlayer> rosterA = rpBean.getActiveByTeam(fm.getTeam1());\r\n List<RosterPlayer> rosterB = rpBean.getActiveByTeam(fm.getTeam2());\r\n \r\n int WRnum = 0;\r\n int RBnum = 0;\r\n for(int j = 0; j < rosterA.size(); j++){\r\n RosterPlayer rp = rosterA.get(j);\r\n NFLPlayer nflp = rp.getNflPlayer();\r\n int pos = nflp.getPosition();\r\n \r\n switch(pos){\r\n case 1:\r\n fm.setTeam1QB(nflp);\r\n break;\r\n case 2:\r\n switch(RBnum){\r\n case 0:\r\n fm.setTeam1RB1(nflp);\r\n RBnum++;\r\n break;\r\n case 1:\r\n fm.setTeam1RB2(nflp);\r\n RBnum++;\r\n break;\r\n case 2:\r\n fm.setTeam1WRRB(nflp);\r\n RBnum++;\r\n break;\r\n }\r\n break;\r\n case 3:\r\n switch(WRnum){\r\n case 0:\r\n fm.setTeam1WR1(nflp);\r\n WRnum++;\r\n break;\r\n case 1:\r\n fm.setTeam1WR2(nflp);\r\n WRnum++;\r\n break;\r\n case 2:\r\n fm.setTeam1WRRB(nflp);\r\n WRnum++;\r\n break;\r\n }\r\n break;\r\n case 4:\r\n fm.setTeam1TE(nflp);\r\n break;\r\n case 5:\r\n fm.setTeam1K(nflp);\r\n break;\r\n case 6:\r\n fm.setTeam1DEF(nflp);\r\n break;\r\n }\r\n }\r\n WRnum = 0;\r\n RBnum = 0;\r\n for(int j = 0; j < rosterB.size(); j++){\r\n RosterPlayer rp = rosterB.get(j);\r\n NFLPlayer nflp = rp.getNflPlayer();\r\n int pos = nflp.getPosition();\r\n \r\n switch(pos){\r\n case 1:\r\n fm.setTeam2QB(nflp);\r\n break;\r\n case 2:\r\n switch(RBnum){\r\n case 0:\r\n fm.setTeam2RB1(nflp);\r\n RBnum++;\r\n break;\r\n case 1:\r\n fm.setTeam2RB2(nflp);\r\n RBnum++;\r\n break;\r\n case 2:\r\n fm.setTeam2WRRB(nflp);\r\n RBnum++;\r\n break;\r\n }\r\n break;\r\n case 3:\r\n switch(WRnum){\r\n case 0:\r\n fm.setTeam2WR1(nflp);\r\n WRnum++;\r\n break;\r\n case 1:\r\n fm.setTeam2WR2(nflp);\r\n WRnum++;\r\n break;\r\n case 2:\r\n fm.setTeam2WRRB(nflp);\r\n WRnum++;\r\n break;\r\n }\r\n break;\r\n case 4:\r\n fm.setTeam2TE(nflp);\r\n break;\r\n case 5:\r\n fm.setTeam2K(nflp);\r\n break;\r\n case 6:\r\n fm.setTeam2DEF(nflp);\r\n break;\r\n }\r\n } \r\n fmatchBean.edit(fm);\r\n }\r\n \r\n }", "@Override\n\tpublic String toString() {\n\t\tString result = \"-------------------\\n\";\n\t\tfor (Cell[] cellRow : board) {\n\t\t\tresult += \"|\";\n\t\t\tfor (Cell cell : cellRow) {\n\t\t\t\tresult += (cell.val == 0 ? \" \" : cell.val) + \"|\";\n\t\t\t}\n\t\t\tresult += \"\\n-------------------\\n\";\n\t\t}\n\t\treturn result += \"\\n\" + toTest();\n\t}", "static void showMatrix()\n {\n String sGameField = \"Game field: \\n\";\n for (String [] row : sField) \n {\n for (String val : row) \n {\n sGameField += \" \" + val;\n }\n sGameField += \"\\n\";\n }\n System.out.println(sGameField);\n }", "public String toString() {\n String result=\"Initial state: 0\\nFinal state: \"+(transitionTable.length-1)+\"\\nTransition list:\\n\";\n for (int i=0;i<epsilonTransitionTable.length;i++) for (int state: epsilonTransitionTable[i])\n result+=\" \"+i+\" -- epsilon --> \"+state+\"\\n\";\n for (int i=0;i<transitionTable.length;i++) for (int col = 0; col< NFA.N; col++)\n if (transitionTable[i][col]!=-1) result+=\" \"+i+\" -- \"+(char)col+\" --> \"+transitionTable[i][col]+\"\\n\";\n return result;\n }", "@Override\n public String toString() {\n StringBuilder sb = new StringBuilder();\n\n //Print board\n int c = 0;\n for (Piece piece : board) {\n if (piece == null) {\n sb.append(\"\\t\");\n } else {\n sb.append(piece.pieceString()).append(\"\\t\");\n }\n if (++c % 4 == 0) {\n sb.append(\"\\n\");\n }\n }\n sb.append(\"\\n\");\n\n return sb.toString();\n }", "private String transitionTable() {\r\n\r\n\t\tString transitionTable = \"\t\";\r\n\t\tchar[][] matrix = new char[numStates.size() + 1][alphabet.size() + 1];\r\n\t\tStringBuilder bldmatrix = new StringBuilder();\r\n\r\n\t\tfor (int i = 0; i < matrix.length; i++) {\r\n\t\t\tfor (int j = 0; j < matrix[i].length; j++) {\r\n\t\t\t\tif (i == 0) {\r\n\t\t\t\t\tif (j == 0) {\r\n\t\t\t\t\t\tmatrix[i][j] = ' ';\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tArrayList<Character> trans = new ArrayList<>(alphabet);\r\n\t\t\t\t\t\tmatrix[i][j] = trans.get(j - 1);\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\tif (j == 0) {\r\n\t\t\t\t\t\tmatrix[i][j] = numStates.get(i - 1).getName().charAt(0);\r\n\r\n\t\t\t\t\t} else {\r\n\r\n\t\t\t\t\t\tArrayList<Character> trans2 = new ArrayList<>(alphabet);\r\n\t\t\t\t\t\tmatrix[i][j] = ((NFAState) getToState(numStates.get(i - 1), trans2.get(j - 1))).getName()\r\n\t\t\t\t\t\t\t\t.charAt(0);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tfor (int x = 0; x < matrix.length; x++) {\r\n\t\t\tfor (int y = 0; y < matrix[x].length; y++) {\r\n\t\t\t\tbldmatrix.append(\"\\t\" + matrix[x][y]);\r\n\r\n\t\t\t}\r\n\t\t\tbldmatrix.append(\"\\n\");\r\n\t\t}\r\n\r\n\t\ttransitionTable = bldmatrix.toString();\r\n\r\n\t\treturn transitionTable;\r\n\r\n\t}", "public String getGameStr() {\n StringBuilder outStr = new StringBuilder();\n for(int i=0;i<ROWS;i++) {\n for(int j=0;j<COLS;j++){ \n outStr.append(\"|\").append(gameBoard[i][j].show());\n }\n outStr.append(\"|\").append(System.getProperty(\"line.separator\"));\n }\n return outStr.toString();\n }", "public void initializeGameboard() {\r\n\t\t\r\n\t\t for (int row=0 ; row<gameBoard.length; row++)\r\n\t\t { \r\n\t\t \t \r\n\t\t \t for(int column=0;column<gameBoard[row].length;column++ )\t \r\n\t\t \t { \r\n\t\t \t\t if( row==0|| row ==1)\r\n\t\t \t\t { \r\n\t\t \t\t\t if (column==0) {gameBoard[row][column]=\"2\";}\r\n\t\t \t\t\t else if (column==1) {gameBoard[row][column]=\"3\";}\t \r\n\t\t \t\t\t else if (column==2) {gameBoard[row][column]=\"4\";} \r\n\t\t \t\t\t else if (column==3) {gameBoard[row][column]=\"5\";} \r\n\t\t \t\t\t else if (column==4) {gameBoard[row][column]=\"6\";} \r\n\t\t \t\t\t else if (column==5) {gameBoard[row][column]=\"7\";}\r\n\t\t \t\t\t else if (column==6) {gameBoard[row][column]=\"8\";} \r\n\t\t \t\t\t else if (column==7) {gameBoard[row][column]=\"9\";}\r\n\t\t \t\t\t else if (column==8) {gameBoard[row][column]=\"10\";} \r\n\t\t \t\t\t else if (column==9) {gameBoard[row][column]=\"11\";} \r\n\t\t \t\t\t else if (column==10) {gameBoard[row][column]=\"12\";} \r\n\t\t \t\t }\r\n\t\t \t\t \r\n\t\t\t \t else if(row ==2 || row==3) \r\n\t\t\t \t {\r\n\t\t\t \t\t if (column==0) {gameBoard[row][column]=\"12\";}\r\n\t\t \t\t\t else if (column==1) {gameBoard[row][column]=\"11\";}\t \r\n\t\t \t\t\t else if (column==2) {gameBoard[row][column]=\"10\";} \r\n\t\t \t\t\t else if (column==3) {gameBoard[row][column]=\"9\";} \r\n\t\t \t\t\t else if (column==4) {gameBoard[row][column]=\"8\";} \r\n\t\t \t\t\t else if (column==5) {gameBoard[row][column]=\"7\";}\r\n\t\t \t\t\t else if (column==6) {gameBoard[row][column]=\"6\";} \r\n\t\t \t\t\t else if (column==7) {gameBoard[row][column]=\"5\";}\r\n\t\t \t\t\t else if (column==8) {gameBoard[row][column]=\"4\";} \r\n\t\t \t\t\t else if (column==9) {gameBoard[row][column]=\"3\";} \r\n\t\t \t\t\t else if (column==10) {gameBoard[row][column]=\"2\";} \r\n\t\t\t \t }\r\n\t\t }\r\n\t\t }\r\n\t }", "public void update() {\n\t\t// Complete this method\n\n\t\tint [][]tempTable = new int [numberOfRows()][numberOfColumns()];\n\n\t\tfor ( int r = 0; r < numberOfRows(); r++ ){\n\t\t\tfor (int c = 0; c < numberOfColumns(); c++){\n\t\t\t\tif(neighborCount(r,c) == 3){//if there is exactly three\n\t\t\t\t\tif(gameGrid[r][c] == 0)//cell is born\n\t\t\t\t\t\ttempTable[r][c] = 1;//then you add one to your tempTable\t\n\t\t\t\t}\n\n\t\t\t\tif((neighborCount(r,c) == 2) || (neighborCount(r,c) == 3)){//if there is two or three\n\t\t\t\t\tif(gameGrid[r][c] == 1)//this is your existing cell\n\t\t\t\t\t\ttempTable[r][c] = 1;//then the cell remains\n\t\t\t\t}\n\n\t\t\t\tif((neighborCount(r,c) == 0) || (neighborCount(r,c) == 1)){//if there were two neighbors\n\t\t\t\t\tif(gameGrid[r][c] == 0)//if there is no cell\n\t\t\t\t\t\ttempTable[r][c] = 0;//a cell dies\n\t\t\t\t}\n\n\t\t\t\tif((neighborCount(r,c) > 3)){//if there is more than three\n\t\t\t\t\tif(gameGrid[r][c] == 1)//if there is no cell\n\t\t\t\t\t\ttempTable[r][c] = 0;//a cell dies\n\t\t\t\t}\n\n\t\t\t}//end of column for loop\n\t\t}//end of row for loop\n\t\tgameGrid = tempTable;\n\t}", "public State[] getSuccessors(char player) {\n\t\t// TO DO: get all successors and return them in proper order\r\n\t\tchar[][] board = convert2D(this.board);\r\n\r\n\t\tchar opponent;\r\n\t\tif(player == '2')\r\n\t\t\topponent = '1';\r\n\t\telse \r\n\t\t\topponent = '2';\r\n\r\n\t\tArrayList<State> successors = new ArrayList<State>();\r\n\r\n\t\tArrayList<Integer> row = new ArrayList<Integer>();\r\n\r\n\t\tArrayList<Integer> col = new ArrayList<Integer>();\r\n\t\t//ArrayList<Integer[]> indices = new ArrayList<Integer[]>();\r\n\r\n\t\tfor(int i = 0;i < 4; ++i){\r\n\r\n\t\t\tfor(int j = 0;j < 4; ++j){\r\n\r\n\t\t\t\tif(board[i][j] == opponent){\r\n\r\n\t\t\t\t\tint I = i, J = j; \r\n\t\t\t\t\t//upper left diag\r\n\t\t\t\t\tif(i-1 >= 0 && j-1 >= 0 && board[i-1][j-1] == '0'){ \r\n\r\n\t\t\t\t\t\ti = i+1; \r\n\t\t\t\t\t\tj = j+1;\r\n\r\n\t\t\t\t\t\twhile(i < 3 && j < 3 && board[i][j] == opponent)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\ti++;j++;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tif(i <= 3 && j <= 3 && board[i][j] == player) {\r\n\r\n\t\t\t\t\t\t\tif(!exists(row,col,I-1,J-1)) {\r\n\r\n\t\t\t\t\t\t\t\trow.add(I-1);\r\n\t\t\t\t\t\t\t\tcol.add(J-1);\r\n\r\n\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} \r\n\t\t\t\t\ti=I;j=J;\r\n\t\t\t\t\t//left\r\n\t\t\t\t\tif(i-1>=0 && board[i-1][j] == '0'){\r\n\t\t\t\t\t\ti = i+1;\r\n\r\n\t\t\t\t\t\twhile(i < 3 && board[i][j] == opponent) \r\n\t\t\t\t\t\t\ti++;\r\n\t\t\t\t\t\tif(i<=3 && board[i][j] == player) {\r\n\r\n\t\t\t\t\t\t\tif(!exists(row,col,I-1,J)) {\r\n\r\n\t\t\t\t\t\t\t\trow.add(I-1);\r\n\t\t\t\t\t\t\t\tcol.add(J);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} \r\n\t\t\t\t\ti=I;\r\n\r\n\t\t\t\t\t//lower left diag\r\n\t\t\t\t\tif(i-1 >= 0 && j+1 <= 3 && board[i-1][j+1] == '0'){\r\n\r\n\t\t\t\t\t\ti = i+1; j = j-1;\r\n\r\n\t\t\t\t\t\twhile(i<3 && j>0 && board[i][j] == opponent)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\ti++;j--;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif(i<=3 && j>=0 && board[i][j] == player) {\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tif(!exists(row,col,I-1,J+1)) {\r\n\t\t\t\t\t\t\t\trow.add(I-1);\r\n\t\t\t\t\t\t\t\tcol.add(J+1);\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} \r\n\r\n\t\t\t\t\ti=I;\r\n\t\t\t\t\tj=J;\r\n\r\n\t\t\t\t\t//up\r\n\t\t\t\t\tif(j-1>=0 && board[i][j-1] == '0'){\r\n\t\t\t\t\t\tj = j+1;\r\n\r\n\t\t\t\t\t\twhile(j < 3 && board[i][j] == opponent)\r\n\t\t\t\t\t\t\tj++;\r\n\r\n\t\t\t\t\t\tif(j <= 3 && board[i][j] == player) {\r\n\r\n\t\t\t\t\t\t\tif(!exists(row,col,I,J-1)) {\r\n\r\n\t\t\t\t\t\t\t\trow.add(I);\r\n\t\t\t\t\t\t\t\tcol.add(J-1);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tj=J;\r\n\t\t\t\t\t//down\r\n\t\t\t\t\tif(j+1 <= 3 && board[i][j+1] == '0'){\r\n\r\n\t\t\t\t\t\tj=j-1;\r\n\r\n\t\t\t\t\t\twhile(j > 0 && board[i][j] == opponent)\r\n\t\t\t\t\t\t\tj--;\r\n\r\n\t\t\t\t\t\tif(j >= 0 && board[i][j] == player) {\r\n\r\n\t\t\t\t\t\t\tif(!exists(row,col,I,J+1)) {\r\n\r\n\t\t\t\t\t\t\t\trow.add(I);\r\n\t\t\t\t\t\t\t\tcol.add(J+1);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tj=J;\r\n\t\t\t\t\t//upper right\r\n\t\t\t\t\tif(i+1<=3 && j-1>=0 && board[i+1][j-1] == '0'){\r\n\r\n\t\t\t\t\t\ti=i-1;\r\n\t\t\t\t\t\tj=j+1;\r\n\r\n\t\t\t\t\t\twhile(i > 0 && j < 3 && board[i][j] == opponent){\r\n\r\n\t\t\t\t\t\t\ti--;\r\n\t\t\t\t\t\t\tj++;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tif(i >= 0 && j <= 3 && board[i][j] == player) {\r\n\r\n\t\t\t\t\t\t\tif(!exists(row,col,I+1,J-1)) {\r\n\r\n\t\t\t\t\t\t\t\trow.add(I+1);\r\n\t\t\t\t\t\t\t\tcol.add(J-1);\r\n\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\ti=I;\r\n\t\t\t\t\tj=J;\r\n\t\t\t\t\t//right\r\n\t\t\t\t\tif(i+1 <= 3 && board[i+1][j] == '0'){\r\n\t\t\t\t\t\ti=i-1;\r\n\r\n\t\t\t\t\t\twhile(i > 0 && board[i][j] == opponent) \r\n\t\t\t\t\t\t\ti--;\r\n\r\n\t\t\t\t\t\tif(i >= 0 && board[i][j] == player) {\r\n\r\n\t\t\t\t\t\t\tif(!exists(row,col,I+1,J)) {\r\n\r\n\t\t\t\t\t\t\t\trow.add(I+1);\r\n\t\t\t\t\t\t\t\tcol.add(J);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\ti=I;\r\n\t\t\t\t\t//lower right diag\r\n\t\t\t\t\tif(i+1 <= 3 && j+1 <=3 && board[i+1][j+1] == '0'){\r\n\r\n\t\t\t\t\t\ti=i-1;\r\n\t\t\t\t\t\tj=j-1;\r\n\r\n\t\t\t\t\t\twhile(i > 0 && j > 0 && board[i][j] == opponent)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\ti--;\r\n\t\t\t\t\t\t\tj--;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tif(i >= 0 && j >= 0 && board[i][j] == player) {\r\n\r\n\t\t\t\t\t\t\tif(!exists(row, col, I+1, J+1)) {\t\r\n\r\n\t\t\t\t\t\t\t\trow.add(I+1);\r\n\t\t\t\t\t\t\t\tcol.add(J+1);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\ti=I;\r\n\t\t\t\t\tj=J;\r\n\t\t\t\t}\r\n\t\t\t} \r\n\t\t} \r\n\t\t//Adding to successors\r\n\t\tfor(int i = 0; i < row.size(); i++) {\r\n\r\n\t\t\tsuccessors.add(move(player, row.get(i), col.get(i)));\r\n\t\t}\r\n\r\n\t\t//Create an array,\r\n\t\tState[] succsArray = new State[successors.size()];\r\n\t\t//get data in array\r\n\t\tsuccsArray = successors.toArray(succsArray);\r\n\r\n\t\treturn succsArray;\t\r\n\t}", "private void arretes_fB(){\n\t\tthis.cube[22] = this.cube[19]; \n\t\tthis.cube[19] = this.cube[21];\n\t\tthis.cube[21] = this.cube[25];\n\t\tthis.cube[25] = this.cube[23];\n\t\tthis.cube[23] = this.cube[22];\n\t}", "private void arretes_fR(){\n\t\tthis.cube[13] = this.cube[10]; \n\t\tthis.cube[10] = this.cube[12];\n\t\tthis.cube[12] = this.cube[16];\n\t\tthis.cube[16] = this.cube[14];\n\t\tthis.cube[14] = this.cube[13];\n\t}", "@Override\n public final String toString()\n {\n String str = formatInt(turn)+formatInt(fiftyMove);\n //int counter = 0;\n for (Square[] s1: getSquares())\n {\n for (Square s: s1)\n {\n if (!s.isEmpty())\n {\n str+=\"\"+s;\n //counter++;\n /*if (counter%4==0)\n str+=\"\\n\";*/\n }\n }\n }\n return str;\n }", "public void flipBoard() {\r\n\t\tfor (int i = 0; i < this.SIZE/2; i++) {\r\n\t\t\tfor (int j = 0; j < this.SIZE; j++) {\r\n\t\t\t\tswap(j, this.SIZE - 1 - i, j, i);\r\n\t\t\t}\r\n\t\t}\r\n\t}", "public String toString() {\n\t\tStringBuilder string = new StringBuilder();\n\t\tstring.append(n + \"\\n\");\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tfor (int j = 0; j < n; j++) \n\t\t\t\tstring.append(String.format(\"%2d \", board[i][j]));\n\t\t\tstring.append(\"\\n\");\n\t\t}\n\t\treturn string.toString();\n\t}", "private static void BFSinfect(char[][] grid, int row, int column) {\n int rowLength = grid.length;\n int colLength = grid[0].length;\n Deque<Integer> stack = new LinkedList<>();\n stack.addLast(row * colLength + column);\n while (!stack.isEmpty()) {\n int value = stack.pollFirst();\n row = value / colLength;\n column = value % colLength;\n char val = grid[row][column];\n if (val == '1') {\n grid[row][column] = '0';\n if (row + 1 < rowLength) {\n stack.addLast((row + 1) * colLength + column);\n }\n if (column + 1 < colLength) {\n stack.addLast(row * colLength + column + 1);\n }\n if (row - 1 >= 0) {\n stack.addLast((row - 1) * colLength + column);\n }\n if (column - 1 >= 0) {\n stack.addLast(row * colLength + column - 1);\n }\n }\n }\n }", "public static String getBoardStateSquare(int file, int rank) {\n return boardState[rank][file];\n }", "private void yourturn() {\n if (whosturn != 3) {\n whosturn = 3;\n displayTable();\n }\n\n // TODO mega duplication\n int top = 0;\n // testing is player has a card they can play\n if (pile.notEmpty()) {\n boolean canplay = false;\n if (hand.getCard(0) == null) { // if player only has card on the table\n if (hand.isFaceUp()) // if player has faceup card on the table\n {\n for (int n = 0; n < 3; n++) {\n if (hand.getFaceUp(n) != null) {\n if (nine && pile.topValue() == 9) {\n top = 0;\n for (int i = 0; i < 52; i++) {\n if (pile.get(i) == null) {\n canplay = true;\n break;\n }\n if (pile.get(i).getValue() == 9) top++;\n else break;\n }\n }\n if (canplay) break;\n if (seven\n && pile.get(top).getValue() == 7\n && hand.getFaceUp(n).getValue() < 7) {\n canplay = true;\n break;\n } else if (hand.getFaceUp(n).getValue() == 2\n || hand.getFaceUp(n).getValue() == 10) {\n canplay = true;\n break;\n } else if (nine && hand.getFaceUp(n).getValue() == 9) {\n canplay = true;\n break;\n } else if (!seven || pile.get(top).getValue() != 7) {\n if (pile.get(top).getValue() <= hand.getFaceUp(n).getValue()) {\n canplay = true;\n break;\n }\n }\n }\n }\n } else // if player only has facedown cards\n canplay = true;\n } else {\n for (int n = 0; n < hand.length() - 1; n++) {\n if (hand.getCard(n) == null) break;\n if (nine && pile.topValue() == 9) {\n top = 0;\n for (int i = 0; i < 52; i++) {\n if (pile.get(i) == null) {\n canplay = true;\n break;\n }\n if (pile.get(i).getValue() == 9) top++;\n else break;\n }\n }\n if (canplay) break;\n if (hand.getCard(n).getValue() == 2 || hand.getCard(n).getValue() == 10) {\n canplay = true;\n break;\n }\n if (nine && hand.getCard(n).getValue() == 9) {\n canplay = true;\n break;\n }\n if (seven && pile.get(top).getValue() == 7 && hand.getCard(n).getValue() < 7) {\n canplay = true;\n break;\n } else if (seven != true || pile.get(top).getValue() != 7) {\n if (pile.get(top).getValue() <= hand.getCard(n).getValue()) {\n canplay = true;\n break;\n }\n }\n }\n }\n if (canplay) {\n // sh.addMsg(\"Its Your Turn\");\n sh.setmyTurn(true);\n } else { // cant play then must pick up the pile\n sh.addMsg(\n \"The card played was a \"\n + pile.top().getStringValue()\n + \" you had to pick up the pile. BLAOW\");\n pile.moveToHand(hand);\n sendCommand(\"turn:pickup:\");\n nextTurn();\n displayTable();\n }\n } else {\n // sh.addMsg(\"Its Your Turn\");\n sh.setmyTurn(true);\n }\n }", "protected void printBest(int n) {\n for (int i = 0; i < n; i++) {\n System.out.printf(\"%.5f\", individuals[i].score);\n if (i < n - 1)\n System.out.print(\", \");\n // forwardPropagate(i, input).printMatrix();\n // System.out.println();\n }\n }", "private void renderBoard() {\n Cell[][] cells = gameBoard.getCells();\n StringBuilder battleField = new StringBuilder(\"\\tA B C D E F G H I J \\n\");\n\n for (int i = 0; i < cells.length; i++) {\n battleField.append(i+1).append(\"\\t\");\n for (int j = 0; j < cells[i].length; j++) {\n if (cells[i][j].getContent().equals(Content.deck)) {\n battleField.append(\"O \");\n } else {\n battleField.append(\"~ \");\n }\n }\n battleField.append(\"\\n\");\n }\n\n System.out.println(battleField.toString());\n }", "@Override\r\n\tpublic String toString() {\r\n\t\tString str = new String();\r\n\t\tfor(Cell2048[] a : game) {\r\n\t\t\tfor(Cell2048 b : a)\r\n\t\t\t\tstr += b.getValue();\r\n\t\t}\r\n\t\treturn Integer.toString(rows_size) + \",\" + Integer.toString(columns_size) +\",\" +str;\r\n\t}", "@Override\n public String toString() {\n String returnBoard = \" \";\n for (int i = 1; i <= 3; i++) {\n returnBoard=returnBoard+\" \" +Integer.toString(i);\n }\n returnBoard+=\"\\n\";\n for (int i = 1; i <= 3; i++) {\n returnBoard+= Integer.toString(i);\n for (int j = 1; j <= 3; j++) {\n returnBoard = returnBoard + \" \" + board[i-1][j-1].toString();\n }\n returnBoard+=\"\\n\";\n }\n return returnBoard;\n }", "private static Piece[][] createStandard(int n) {\n Piece[][] board = new Piece[n][n];\n for (int col = 0; col < board.length; col += 1) {\n for (int row = 0; row < board[0].length; row += 1) {\n board[col][row] = EMP;\n }\n }\n return board;\n }", "private String rankingsToString () {\n\t\tStringBuilder ps = new StringBuilder();\n\t\tps.append(\"Craft ranking = \"+craftRanking.getSortedRanking()+\"\\n\");\n\t\tps.append(\"Hit ranking = \"+ hitRanking.getSortedRanking()+\"\\n\");\n\t\treturn ps.toString();\n\t}", "public void solve() {\n\t\tArrayList<Piece> pieceListBySize = new ArrayList<Piece>(pieceList);\n\t\tCollections.sort(pieceListBySize);\t// This is done since the order\n\t\t\t\t\t\t\t\t\t\t\t// of piece placements does not matter.\n\t\t\t\t\t\t\t\t\t\t\t// Placing larger pieces down first lets\n\t\t\t\t\t\t\t\t\t\t\t// pruning occur sooner.\n\t\t\n\t\t/**\n\t\t * Calculates number of resets needed for a game board.\n\t\t * A \"reset\" refers to a tile that goes from the solved state to\n\t\t * an unsolved state and back to the solved state.\n\t\t * \n\t\t * This is the calculation used for pruning.\n\t\t */\n\t\t\n\t\tArrayList<Integer> areaLeft = new ArrayList<Integer>();\n\t\tareaLeft.add(0);\n\t\tint totalArea = 0;\n\t\tfor (int i = pieceListBySize.size() - 1; i >= 0; i--) {\n\t\t\ttotalArea += pieceListBySize.get(i).numberOfFlips;\n\t\t\tareaLeft.add(0, totalArea);\n\t\t}\n\t\tint totalResets = (totalArea - gameBoard.flipsNeeded) / (gameBoard.goal + 1);\n\t\tSystem.out.println(\"Total Resets: \" + totalResets);\n\t\t\n\t\t/* \n\t\tint highRow = 0;\n\t\tint highCol = 0;\n\t\tint[][] maxDim = new int[2][pieceListBySize.size()];\n\t\tfor (int i = pieceListBySize.size() - 1; i >= 0; i--) {\n\t\t\tif (highRow < pieceListBySize.get(i).rows)\n\t\t\t\thighRow = pieceListBySize.get(i).rows;\n\t\t\t\n\t\t\tif (highCol < pieceListBySize.get(i).cols)\n\t\t\t\thighCol = pieceListBySize.get(i).cols;\n\t\t\t\n\t\t\tmaxDim[0][i] = highRow;\n\t\t\tmaxDim[1][i] = highCol;\n\t\t}\n\t\t*/\n\t\t\n\t\tlong startTime = System.currentTimeMillis();\n\t\t\n\t\tNode<GameBoard> currentNode = new Node<GameBoard>(gameBoard);\n\t\tStack<Node<GameBoard>> stack = new Stack<Node<GameBoard>>();\n\t\tstack.push(currentNode);\n\t\t\n\t\twhile (!stack.isEmpty()) {\n\t\t\tnodeCount++;\n\t\t\t\n\t\t\tNode<GameBoard> node = stack.pop();\n\t\t\tGameBoard current = node.getElement();\n\t\t\tint depth = node.getDepth();\n\t\t\t\n\t\t\t// Checks to see if we reach a solved state.\n\t\t\t// If so, re-order the pieces then print out the solution.\n\t\t\tif (depth == pieceListBySize.size() && current.isSolved()) {\n\t\t\t\tArrayList<Point> moves = new ArrayList<Point>();\n\t\t\t\t\n\t\t\t\twhile (node.parent != null) {\n\t\t\t\t\tint index = node.level - 1;\n\t\t\t\t\tint sequence = pieceList.indexOf(pieceListBySize.get(index));\n\t\t\t\t\tPoint p = new Point(current.moveRow, current.moveCol, sequence);\n\t\t\t\t\tmoves.add(p);\n\t\t\t\t\t\n\t\t\t\t\tnode = node.parent;\n\t\t\t\t\tcurrent = node.getElement();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tCollections.sort(moves);\n\t\t\t\tfor (Point p : moves) {\n\t\t\t\t\tSystem.out.println(p);\n\t\t\t\t}\n\t\t\t\tSystem.out.println(\"Nodes opened: \" + nodeCount);\n\t\t\t\tlong endTime = System.currentTimeMillis();\n\t\t\t\tSystem.out.println(\"Elapsed Time: \" + ((endTime - startTime) / 1000) + \" secs.\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tPiece currentPiece = pieceListBySize.get(depth);\n\t\t\tint pieceRows = currentPiece.rows;\n\t\t\tint pieceCols = currentPiece.cols;\n\t\t\t\n\t\t\tPriorityQueue<Node<GameBoard>> pQueue = new PriorityQueue<Node<GameBoard>>();\n\t\t\t\n\t\t\t// Place piece in every possible position in the board\n\t\t\tfor (int i = 0; i <= current.rows - pieceRows; i++) {\n\t\t\t\tfor (int j = 0; j <= current.cols - pieceCols; j++) {\n\t\t\t\t\tGameBoard g = current.place(currentPiece, i, j);\n\t\t\t\t\t\n\t\t\t\t\tif (totalResets - g.resets < 0)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\n\t\t\t\t\t// Put in the temporary priority queue\n\t\t\t\t\tpQueue.add(new Node<GameBoard>(g, node));\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t// Remove from priority queue 1 at a time and put into stack.\n\t\t\t// The reason this is done is so that boards with the highest reset\n\t\t\t// count can be chosen over ones with fewer resets.\n\t\t\twhile (!pQueue.isEmpty()) {\n\t\t\t\tNode<GameBoard> n = pQueue.remove();\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t}\n\t}", "private void generateIncomingRankingReport() {\r\n\r\n\t\tStringBuilder stringBuilder = new StringBuilder();\r\n\t\tstringBuilder.append(\"\\n----------------------------------------\\n\")\r\n\t\t\t\t.append(\" Incoming Ranking \\n\")\r\n\t\t\t\t.append(\"----------------------------------------\\n\")\r\n\t\t\t\t.append(\" Entity | Rank \\n\")\r\n\t\t\t\t.append(\"-----------------+----------------------\\n\");\r\n\t\tallIncomingRankings.entrySet().stream().sorted(Map.Entry.<String, Integer>comparingByValue())\r\n\t\t\t\t.forEach(key -> stringBuilder\r\n\t\t\t\t\t\t.append(\" \" + key.getKey() + \" | \" + key.getValue() + \" \\n\"));\r\n\t\tdataWriter.write(stringBuilder.toString());\r\n\t}", "public void newGame() {\n \tturn = PieceColor.White;\n \t\n \t//the middle are empty squares\n \tfor(int i = 2; i < 6; i++) {\n \t\tfor(int j = 0; j < 8; j++) {\n \t\t\tsetPiece(j, i, new NoPiece(j, i));\n \t\t}\n \t}\n \t\n \t//pawns\n \tfor(int i = 0; i < 8; i++) {\n \t\t//make these pawns\n \t\tsetPiece(i, 1, new Pawn(i, 1, PieceColor.White, this));\n \t\tsetPiece(i, 6, new Pawn(i, 6, PieceColor.Black, this));\n \t}\n \t\n \t//white back row\n \tsetPiece(0, 0, new Rook(0, 0, PieceColor.White, this));\n \tsetPiece(1, 0, new Knight(1, 0, PieceColor.White, this));\n \tsetPiece(2, 0, new Bishop(2, 0, PieceColor.White, this));\n \tsetPiece(3, 0, new Queen(3, 0, PieceColor.White, this));\n \tsetPiece(4, 0, new King(4, 0, PieceColor.White, this));\n \tsetPiece(5, 0, new Bishop(5, 0, PieceColor.White, this));\n \tsetPiece(6, 0, new Knight(6, 0, PieceColor.White, this));\n \tsetPiece(7, 0, new Rook(7, 0, PieceColor.White, this));\n \t\n \t//black back row\n \tsetPiece(0, 7, new Rook(0, 7, PieceColor.Black, this));\n \tsetPiece(1, 7, new Knight(1, 7, PieceColor.Black, this));\n \tsetPiece(2, 7, new Bishop(2, 7, PieceColor.Black, this));\n \tsetPiece(3, 7, new Queen(3, 7, PieceColor.Black, this));\n \tsetPiece(4, 7, new King(4, 7, PieceColor.Black, this));\n \tsetPiece(5, 7, new Bishop(5, 7, PieceColor.Black, this));\n \tsetPiece(6, 7, new Knight(6, 7, PieceColor.Black, this));\n \tsetPiece(7, 7, new Rook(7, 7, PieceColor.Black, this));\n \t\n \t//store locations of king so they can be checked\n \twKing = new Square(4, 0);\n \tbKing = new Square(4, 7);\n }", "public static String serializeBoard(final Board gameBoard) {\n StringJoiner joiner = new StringJoiner(\" \");\n \n joiner\n .add(generatePiecePlacement(gameBoard.getMatrix()))\n .add(determineActiveColor(gameBoard))\n .add(generateCastlingAvailability(gameBoard));\n \n return joiner.toString();\n }", "public static String finalPosition(String pgn) {\n setBoardState(createBoardState());\n\n moves(pgn);\n\n return pgnToFen();\n }", "public GameState won() {\n if ( (board[0][0] != TileState.BLANK) && (board[0][0] == board[0][1]) && (board[0][0] == board[0][2])) {\n if (playerOneTurn)\n return GameState.PLAYER_TWO;\n else\n return GameState.PLAYER_ONE;\n } else if ((board[1][0] != TileState.BLANK) && (board[1][0] == board[1][1]) && (board[1][0] == board[1][2])) {\n if (playerOneTurn)\n return GameState.PLAYER_TWO;\n else\n return GameState.PLAYER_ONE;\n } else if ((board[2][0] != TileState.BLANK) && (board[2][0] == board[2][1]) && (board[2][0] == board[2][2])) {\n if (playerOneTurn)\n return GameState.PLAYER_TWO;\n else\n return GameState.PLAYER_ONE;\n } else if ((board[0][0] != TileState.BLANK) && (board[0][0] == board[1][1]) && (board[0][0] == board[2][2])) {\n if (playerOneTurn)\n return GameState.PLAYER_TWO;\n else\n return GameState.PLAYER_ONE;\n } else if ( (board[0][2] != TileState.BLANK) && (board[0][2] == board[1][1]) && (board[0][2] == board[2][0])) {\n if (playerOneTurn)\n return GameState.PLAYER_TWO;\n else\n return GameState.PLAYER_ONE;\n } else if ((board[0][0] != TileState.BLANK) && (board[0][0] == board[1][0]) && (board[0][0] == board[2][0])) {\n if (playerOneTurn)\n return GameState.PLAYER_TWO;\n else\n return GameState.PLAYER_ONE;\n } else if ((board[0][1] != TileState.BLANK) && (board[0][1] == board[1][1]) && (board[0][1] == board[2][1])) {\n if (playerOneTurn)\n return GameState.PLAYER_TWO;\n else\n return GameState.PLAYER_ONE;\n } else if ((board[0][2] != TileState.BLANK) && (board[0][2] == board[1][2]) && (board[0][2] == board[2][2])) {\n if (playerOneTurn)\n return GameState.PLAYER_TWO;\n else\n return GameState.PLAYER_ONE;\n } else if (movesPlayed == 9)\n return GameState.DRAW;\n return GameState.IN_PROGRESS;\n }", "@Override\n\tpublic void win() {\n\t\t\n\t\tfround[fighter1]++;\n\t fplatz[fighter1]=Math.round((float)fplatz[fighter1]/2); \n\t \n\t\tnextRound();\n\t}", "public void updateBoard() {\n for(SnakePart s : snakePartList) {\n board[s.getSnakePartRowsOld()][s.getSnakePartCollsOld()] = ' ';\n board[s.getSnakePartRowsNew()][s.getSnakePartCollsNew()] = 'S';\n }\n \n for (SnakeEnemyPart e : snakeEnemyPartList) {\n board[e.getSnakeEnemyPartRowsOld()][e.getSnakeEnemyPartCollsOld()] = ' ';\n board[e.getSnakeEnemyPartRowsNew()][e.getSnakeEnemyPartCollsNew()] = 'E';\n }\n }", "public static int f6(int N) { \n if (N == 0)\n return 1;\n return f6(N-1) + f6(N-1);\n \n }", "public static String BFS(Graph grafo, Vertice vertice) {\r\n\t\tArrayList<Integer> busca = new ArrayList<Integer>(); // vertice nivel pai em ordem de descoberta\r\n\t\tArrayList<Vertice> aux1 = new ArrayList<Vertice>(); // fila de nos pais a serem visitados\r\n\t\tArrayList<Vertice> aux2 = new ArrayList<Vertice>(); // fila de nos filhos a serem visitdados\r\n\r\n\t\tint nivel = 0;\r\n\r\n\t\taux1.add(vertice);// adiciona a raiz a aux1 para inicio da iteracao\r\n\t\tvertice.setPai(0);// seta o pai da raiz para zero\r\n\r\n\t\twhile (aux1.size() > 0) {\r\n\t\t\tfor (int i = 0; i < aux1.size(); i++) {\r\n\t\t\t\tif (aux1.get(i).statusVertice() == false) {// verifrifica se o no ja nao foi atingido por outra ramificacao.\r\n\t\t\t\t\tbusca.add(aux1.get(i).getValor());\r\n\t\t\t\t\tbusca.add(nivel);\r\n\t\t\t\t\tbusca.add(aux1.get(i).getPai());\r\n\t\t\t\t\tvertice.alteraStatusVertice(true);\r\n\r\n\t\t\t\t\tfor (int j = 0; i < vertice.getArestas().size(); j++) {\r\n\t\t\t\t\t\tproxVertice(vertice, vertice.getArestas().get(j)).setPai(aux1.get(i).getValor());// associa o no pai\r\n\t\t\t\t\t\taux2.add(proxVertice(vertice, vertice.getArestas().get(j)));// adiciona lista dos proximos nos filhos serem percorridos\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\taux1 = aux2; // todos os nos pai ja foram percoridos, filhos se tornam a lista de nos pai\r\n\t\t\t\t\taux2.clear(); // lista de nos filhos e esvaziada para o proximo ciclo de iteracoes\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tnivel++;\r\n\t\t}\r\n\r\n\t\tresetStatusVertex(grafo);\r\n\r\n\t\treturn criaStringDeSaida(grafo, busca);// formata o resutltado da busca para a string esperada\r\n\t}", "private Sign[] flattenBoard(){\r\n Sign[] flatBoard = new Sign[10]; // an array to save the board as one dimensional array\r\n int count = 1; //counter to help the transition from matrix to array\r\n\r\n /* transfer the matrix to array */\r\n for (int i=0;i<3;i++)\r\n for (int j=0;j<3;j++)\r\n flatBoard[count++] = board[i][j];\r\n\r\n return flatBoard;\r\n }", "public String runPostSeason()\n {\n String westernChamp = \"\";\n\n int r = new Random().nextInt(1 + 1);\n\n\n\n //First Round\n\n for(int i = 0; i < 4; i++)\n {\n b.setFirstRoundWest(i,0,playoffs[i]);\n b.setFirstRoundWest(i,1,playoffs[7 - i]);\n }\n\n\n //Second Round\n for(int i = 0; i < 2; i++)\n {\n for(int j = 0; j < 8; j++) {\n if (winningTeam(b.getFirstRoundWest()[i][0], b.getFirstRoundWest()[i][1]).equals(b.getFirstRoundWest()[i][0]))\n {\n firstRoundRecords[i][0] += 1;\n }\n else\n {\n firstRoundRecords[i][1] += 1;\n }\n\n if (firstRoundRecords[i][0] >= 4)\n {\n b.setSecondRoundWest(0, i, b.getFirstRoundWest()[i][0]);\n break;\n }\n else if (firstRoundRecords[i][1] >= 4)\n {\n b.setSecondRoundWest(0, i, b.getFirstRoundWest()[i][1]);\n break;\n }\n }\n\n for(int j = 0; j < 8; j++) {\n if (winningTeam(b.getFirstRoundWest()[i+2][0], b.getFirstRoundWest()[i+2][1]).equals(b.getFirstRoundWest()[i+2][0]))\n {\n firstRoundRecords[i+2][0] += 1;\n }\n else\n {\n firstRoundRecords[i+2][1] += 1;\n }\n\n if (firstRoundRecords[i+2][0] >= 4)\n {\n b.setSecondRoundWest(1, i, b.getFirstRoundWest()[i+2][0]);\n break;\n }\n else if (firstRoundRecords[i+2][1] >= 4)\n {\n b.setSecondRoundWest(1, i, b.getFirstRoundWest()[i+2][1]);\n break;\n }\n }\n }\n\n //Third Round\n for(int i = 0; i < 2; i++)\n {\n for(int j = 0; j < 8; j++)\n {\n if (winningTeam(b.getSecondRoundWest()[i][0], b.getSecondRoundWest()[i][1]).equals(b.getSecondRoundWest()[i][0]))\n {\n secondRoundRecords[i][0] += 1;\n }\n else\n {\n secondRoundRecords[i][1] += 1;\n }\n\n\n if (secondRoundRecords[i][0] >= 4)\n {\n b.setThirdRoundWest(i, b.getSecondRoundWest()[i][0]);\n break;\n }\n else if (secondRoundRecords[i][1] >= 4)\n {\n b.setThirdRoundWest(i, b.getSecondRoundWest()[i][1]);\n break;\n }\n }\n\n }\n\n //Finals Western Team\n for(int i = 0; i < 8; i++)\n {\n if (winningTeam(b.getThirdRoundWest()[0],b.getThirdRoundWest()[1]).equals(b.getThirdRoundWest()[0]))\n {\n westFinalsRecord[0] += 1;\n }\n else\n {\n westFinalsRecord[1] += 1;\n }\n\n\n if (westFinalsRecord[0] >= 4)\n {\n westernChamp = b.getThirdRoundWest()[0];\n break;\n }\n else if (westFinalsRecord[1] >= 4)\n {\n westernChamp = b.getThirdRoundWest()[1];\n break;\n }\n\n }\n\n return westernChamp;\n }", "private void updateBigGameBoardForNextMove(){\n changeLetterAndVisuals();\n /*\n This next step is essential to the game:\n The player just chose a position on a smallGameBoard; this position is where he will\n be able to choose on the big board. For example, if player 1 puts an x in the top-left\n corner of a small game, then player 2 should play in the top-left small game (provided\n it is not already won).\n */\n nextGamePosition = chosenButton.getButtonPosition();\n nextGame = getGame(nextGamePosition);\n //If the next game is already won, then the next player can choose anywhere\n if (checkGameWin(nextGame.getLettersOfAllButtons())){\n for (ButtonClass b : allButtons) {\n b.setAvailable(true);\n }\n for(SmallGameBoard game: games){\n if (game.getGameBoardColor() == R.color.blackTransparent){\n game.changeGameColor(R.color.black);\n }\n }\n } else {\n //If next game is not won, then the player must play on the next game board\n setAvailableButtons(nextGamePosition);\n //Sets all boards besides the next game board to half transparent\n for (SmallGameBoard game: games){\n if(game.getGameBoardColor() == R.color.black){\n game.changeGameColor(R.color.blackTransparent);\n }\n }\n nextGame.changeGameColor(R.color.black);\n }\n //For playerVsComputer, this is when the computer makes its move\n if (!activity.getPlayerVsPlayer() && !computerIsMoving){\n computerMove(activity.getDifficulty());\n computerIsMoving = false;\n }\n }", "public int[][] stateToCheckerboard(int paraState) {\n\t\tint[][] resultCheckerboard = new int[SIZE][SIZE];\n\t\tint tempValue = paraState;\n\n\t\tfor (int i = 0; i < SIZE; i++) {\n\t\t\tfor (int j = 0; j < SIZE; j++) {\n\t\t\t\tresultCheckerboard[i][j] = (tempValue % SIZE);\n\t\t\t\ttempValue /= SIZE;\n\t\t\t} // Of for j\n\t\t} // Of for i\n\n\t\treturn resultCheckerboard;\n\t}", "private void coins_fR(){\n\t\tthis.cube[13] = this.cube[9]; \n\t\tthis.cube[9] = this.cube[15];\n\t\tthis.cube[15] = this.cube[17];\n\t\tthis.cube[17] = this.cube[11];\n\t\tthis.cube[11] = this.cube[13];\n\t}", "@Override\n public String displayGameBoard(int stage) {\n String out=\"\";\n switch(stage) {\n case 0:\n out = \"Initial State: \";\n for (int i = 0; i < this.squareCount; i++) {\n out = out.concat(this.mySquares[i].statusSquare());\n }\n break;\n case 1:\n out = String.format(\"%s rolls %d:\", this.currentPlayer.getName(), this.numSquares);\n for (int i = 0; i < this.squareCount; i++) {\n out = out.concat(this.mySquares[i].statusSquare());\n }\n break;\n case 2:\n out = \"Final State: \";\n for (int i = 0; i < this.squareCount; i++) {\n out = out.concat(this.mySquares[i].statusSquare());\n }\n break;\n case 3:\n out = String.format(\"%s wins!\",this.currentPlayer.getName());\n break;\n }\n return(out);\n }", "private void fillGameBoard() {\n for (int i = 0; i < row; i++) {\n String next = input.get(pointer);\n for (int j = 0; j < column; j++) {\n game[i][j] = String.valueOf(next.charAt(j)); //takes char from string next, this is where columns are filled\n }\n pointer++;\n }\n }", "private void drawFallingPiece() {\r\n\t\t// loops through each rectangle of the shape type (always 4), and draws it\r\n\t\t// based on it's status and position.\r\n\t\tfor (int i = 0; i < 4; i++) {\r\n\t\t\tdrawSquare(game.fallingPiece.x + game.fallingPiece.coord[game.fallingPiece.status][i][0],\r\n\t\t\t\t\t game.fallingPiece.y + game.fallingPiece.coord[game.fallingPiece.status][i][1],\r\n\t\t\t\t\t game.fallingPiece.color);\r\n\t\t}\r\n\t}", "public String getBoard() {\r\n\t\tString r = \"\";\r\n\t\tfor (int y = 0; y < 3; y++) {\r\n\t\t\tfor (int x = 0; x < 3; x++) {\r\n\t\t\t\tr = r + board[y][x];\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn r;\r\n\t}", "@Override\n\tpublic String toString(){\n\t\t// return a string of the board representation following these rules:\n\t\t// - if printed, it shows the board in R rows and C cols\n\t\t// - every cell should be represented as a 5-character long right-aligned string\n\t\t// - there should be one space between columns\n\t\t// - use \"-\" for empty cells\n\t\t// - every row ends with a new line \"\\n\"\n\t\t\n\t\t\n\t\tStringBuilder sb = new StringBuilder(\"\");\n\t\tfor (int i=0; i<numRows; i++){\n\t\t\tfor (int j =0; j<numCols; j++){\n\t\t\t\tPosition pos = new Position(i,j);\n\t\t\t\t\n\t\t\t\t// use the hash table to get the symbol at Position(i,j)\n\t\t\t\tif (grid.contains(pos))\n\t\t\t\t\tsb.append(String.format(\"%5s \",this.get(pos)));\n\t\t\t\telse\n\t\t\t\t\tsb.append(String.format(\"%5s \",\"-\")); //empty cell\n\t\t\t}\n\t\t\tsb.append(\"\\n\");\n\t\t}\n\t\treturn sb.toString();\n\n\t}", "public void setFRtoBR(int idx) {\n\n char[] sliceEdges = {FR, FL, BL, BR};\n char[] notSlicesEdges = {UR, UF, UL, UB, DR, DF, DL, DB};\n int b = idx % 24;\n int a = idx / 24;\n\n Arrays.fill(ep, (char) DB);\n\n for (int i = 1; i < 4; i++) {\n\n int k = b % (i + 1);\n b /= i + 1;\n while (k-- > 0) rotateRight(sliceEdges, 0, i);\n }\n\n int x = 3;\n for (int i = UR; i <= BR; i++) {\n if (a - CnK(11 - i, x + 1) >=0) {\n ep[i] = sliceEdges[3 - x];\n a -= CnK(11 - i, x + 1);\n x--;\n }\n }\n x = 0;\n for (int i = UR; i <= BR; i++) {\n if (ep[i] == DB) {\n ep[i] = notSlicesEdges[x];\n x++;\n }\n }\n }", "public char[][] toMatrix() {\n\t\tint tmp1 = this.player1_moves;\n\t\tint tmp2 = this.player2_moves;\n\n\t\tchar[][] matrix = new char[3][3];\n\t\tfor (int n = 0; n < 9; n++) {\n\t\t\tint i = n / 3;\n\t\t\tint j = n % 3;\n\t\t\tif ((tmp1 & 1) == 1)\n\t\t\t\tmatrix[i][j] = 'X';\n\t\t\telse if ((tmp2 & 1) == 1)\n\t\t\t\tmatrix[i][j] = 'O';\n\t\t\ttmp1 >>= 1;\n\t\t\ttmp2 >>= 1;\n\t\t}\n\n\t\treturn matrix;\n\t}", "public static String printbyF(int n) {\n\t\tif (n < 1) {\n\t\t\tSystem.out.println(\"Invalid Input Number!! n Cannot Be Less Than 1!!\");\n\t\t\treturn \"Invalid\";\n\t\t}\n\t\tint Fibonacci = getFibonacci(n);\n\t\tif (isPrime(Fibonacci)) {\n\t\t\tSystem.out.println(\"BuzzFizz\");\n\t\t\treturn \"BuzzFizz\";\n\t\t}else if(Fibonacci%15==0){\n\t\t\tSystem.out.println(\"FizzBuzz\");\n\t\t\treturn \"FizzBuzz\";\n\t\t}else if(Fibonacci%5==0){\n\t\t\tSystem.out.println(\"Fizz\");\n\t\t\treturn \"Fizz\";\n\t\t}else if(Fibonacci%3==0){\n\t\t\tSystem.out.println(\"Buzz\");\n\t\t\treturn \"Buzz\";\n\t\t}else{\n\t\t\tSystem.out.println(Fibonacci);\n\t\t\treturn Integer.toString(Fibonacci);\n\t\t}\n\t}", "public static String checkWinner(String[][] f)\n {\n //look for the first type of winning line, a horizontal line\n\n for (int i = 0; i < 6; i++)\n {\n\n for (int j = 0; j < 7; j += 2)\n {\n\n if ((f[i][j+1] != \" \")\n\n && (f[i][j+3] != \" \")\n \n && (f[i][j+5] != \" \")\n\n && (f[i][j+7] != \" \")\n\n && ((f[i][j+1] == f[i][j+3])\n\n && (f[i][j+3] == f[i][j+5])\n\n && (f[i][j+5] == f[i][j+7])))\n\n //If we found a same-colored pattern, we'll return the color so that we will know who won.\n\n return f[i][j+1]; \n }\n\n }\n\n //Now, let's first loop over each odd-numbered column by incrementing with 2\n\n //and check for consecutive boxes in the same column that are the same color\n\n for (int i=1;i<15;i+=2)\n {\n\n for (int j =0;j<3;j++)\n {\n\n if((f[j][i] != \" \")\n\n && (f[j+1][i] != \" \")\n\n && (f[j+2][i] != \" \")\n\n && (f[j+3][i] != \" \")\n\n && ((f[j][i] == f[j+1][i])\n\n && (f[j+1][i] == f[j+2][i])\n\n && (f[j+2][i] == f[j+3][i])))\n\n return f[j][i]; \n } \n\n }\n\n //For the left-up to right-down diagonal line\n\n //We'll have to loop over the 3 uppermost\n\n //rows and then go from left to right column-wise\n\n for (int i = 0; i < 3; i++)\n {\n\n for (int j = 1; j < 9; j += 2)\n\n {\n\n if((f[i][j] != \" \")\n\n && (f[i+1][j+2] != \" \")\n\n && (f[i+2][j+4] != \" \")\n\n && (f[i+3][j+6] != \" \")\n\n && ((f[i][j] == f[i+1][j+2])\n\n && (f[i+1][j+2] == f[i+2][j+4])\n\n && (f[i+2][j+4] == f[i+3][j+6])))\n\n return f[i][j]; \n } \n\n }\n\n //Similar to the method above, but we're just reversing\n\n for (int i = 0; i < 3; i++)\n\n {\n for (int j = 7; j < 15; j += 2)\n\n {\n\n if((f[i][j] != \" \")\n\n && (f[i+1][j-2] != \" \")\n\n && (f[i+2][j-4] != \" \")\n \n && (f[i+3][j-6] != \" \")\n\n && ((f[i][j] == f[i+1][j-2])\n\n && (f[i+1][j-2] == f[i+2][j-4])\n\n && (f[i+2][j-4] == f[i+3][j-6])))\n\n return f[i][j]; \n } \n\n }\n\n //If after going over the table and we didn't find a winning color\n\n return null;\n }", "public String toString() {\n StringBuilder s = new StringBuilder(); // Initialize new string builder\n s.append(N + \"\\n\"); // Append board dimension to string\n\n for (int[] row : tiles) {\n for (int tile : row)\n s.append(String.format(\"%2d \", tile)); // Append formatted board tiles string\n s.append(\"\\n\"); // Append new line to string\n }\n return s.toString(); // Return string representation of board\n }", "private String convertFahrenheitToCelsius(double f) {\n double c = (f - 32.0) * (5.0 / 9.0);\n DecimalFormat numberFormat = new DecimalFormat(\"#.0\");\n return numberFormat.format(c);\n }", "private void computeNextRound(int roundNumber) {\n\t\tList<ChesspairingGame> games = new ArrayList<>();\n\t\tthis.generatedRound = new ChesspairingRound();\n\t\tthis.generatedRound.setGames(games);\n\t\tthis.generatedRound.setRoundNumber(roundNumber);\n\n\t\tthis.currentDownfloaters = new HashMap<>();\n\n\t\t/**\n\t\t * start the iteration over groups in the descending order. In order to\n\t\t * avoid thread weird behaviour because the group keys wee copy the keys\n\t\t * before wee iterate\n\t\t */\n\t\tList<Double> copyGroupKeys = new ArrayList<>(orderedGroupKeys);\n\n\t\t// while no need to downfloat then keep downfloating\n\t\tboolean someoneWasDownfloated = true;\n\t\twhile (someoneWasDownfloated) {\n\t\t\tsomeoneWasDownfloated = false;\n\t\t\tfor (Double groupKey : copyGroupKeys) {\n\t\t\t\tMap<String, ChesspairingPlayer> group = groupsByResult.get(groupKey);\n\t\t\t\tint size = group.size();\n\t\t\t\t// if modulo 2 != 0 then find a downfloater\n\t\t\t\tif ((size % 2) != 0) {\n\t\t\t\t\tsomeoneWasDownfloated = true;\n\t\t\t\t\tdownfloatSomeoneInGroup(groupKey);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (Double groupKey : copyGroupKeys) {\n\t\t\t/**\n\t\t\t * check to make sure the group still exists\n\t\t\t * this is related to bug 02\n\t\t\t */\n\t\t\tif (this.groupsByResult.get(groupKey)== null){\n\t\t\t\t//just move on\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\n\t\t\tboolean paringOK = pareGroup(groupKey, roundNumber);\n\t\t\tif (!paringOK) {\n\n\t\t\t\t/*\n\t\t\t\t * downfloat all players from group and then start again all\n\t\t\t\t * parings. Note for the future: you should see if you have\n\t\t\t\t * players that can be pared and then downfloat only those that\n\t\t\t\t * can not be pared. For the moment downfloating all will do.\n\t\t\t\t */\n\t\t\t\t// if this is the last group then join with the previous group\n\t\t\t\tif (copyGroupKeys.size() == 1) {\n\t\t\t\t\tthrow new IllegalStateException(\"What should I do when I only have one group?\");\n\t\t\t\t}\n\t\t\t\tDouble sourceGroup = -1.0;\n\t\t\t\tDouble destGroup = -1.0;\n\t\t\t\t// if this is the last index then join with the previous index\n\t\t\t\tif (copyGroupKeys.indexOf(groupKey) == copyGroupKeys.size() - 1) {\n\t\t\t\t\tint indexSource = copyGroupKeys.indexOf(groupKey);\n\t\t\t\t\tint indexDestination = indexSource - 1;\n\t\t\t\t\tsourceGroup = orderedGroupKeys.get(indexSource);\n\t\t\t\t\tdestGroup = orderedGroupKeys.get(indexDestination);\n\t\t\t\t} else {\n\t\t\t\t\tint indexSource = copyGroupKeys.indexOf(groupKey);\n\t\t\t\t\tint indexDestination = indexSource + 1;\n\t\t\t\t\tsourceGroup = orderedGroupKeys.get(indexSource);\n\t\t\t\t\tdestGroup = orderedGroupKeys.get(indexDestination);\n\t\t\t\t}\n\t\t\t\tjoinGroups(sourceGroup, destGroup);\n\t\t\t\t// and start again\n\t\t\t\tcomputeNextRound(roundNumber);\n\t\t\t}\n\t\t}\n\t}", "public String getMoveConverted(String move, boolean whiteTeamMoving) {\n\t\tif (move.startsWith(\"O-O-O\")) { //Queenside castle\n\t\t\tint row = whiteTeamMoving ? 0 : 7;\n\t\t\treturn row + \"\" + 4 + \";\" + row + \"\" + 0 + \";\" + (6 * (whiteTeamMoving ? 1 : -1)) + \";CASTLE\";\n\t\t} else if (move.startsWith(\"O-O\")) { //Kingside castle\n\t\t\tint row = whiteTeamMoving ? 0 : 7;\n\t\t\treturn row + \"\" + 4 + \";\" + row + \"\" + 7 + \";\" + (6 * (whiteTeamMoving ? 1 : -1)) + \";CASTLE\";\n\t\t}\n\n\t\tMatcher matcher = matchingPattern.matcher(move);\n\t\tmatcher.find();\n\n\t\t//Get the matching groups from the regex\n\t\tString pieceType = matcher.group(1);\n\t\tString fromSpecifier = matcher.group(2);\n\t\tString capture = matcher.group(3);\n\t\tString toLocation = matcher.group(4);\n\t\tString upgradeType = matcher.group(5);\n\n\t\tboolean isCapture = capture != null && capture.equals(\"x\");\n\n\t\t//Get the piece type\n\t\tint piece = getPieceNumFromStr(pieceType);\n\n\t\tif (piece != 1) {\n\t\t\tresetEnpassant(whiteTeamMoving ? 1 : -1);\n\t\t}\n\n\t\t//Get the already known row and column values\n\t\tint fromRow = -1;\n\t\tint fromCol = -1;\n\t\tif (fromSpecifier != null) {\n\t\t\tMatcher fromMatcher = positionPattern.matcher(fromSpecifier);\n\t\t\tfromMatcher.find();\n\n\t\t\tString col = fromMatcher.group(1);\n\t\t\tString row = fromMatcher.group(2);\n\n\t\t\tif (col != null) fromCol = (int)col.charAt(0) - (int)'a';\n\t\t\tif (row != null) fromRow = (int)row.charAt(0) - (int)'1';\n\t\t}\n\n\t\t//Get the to row and column values\n\t\tint toCol = (int)toLocation.charAt(0) - (int)'a';\n\t\tint toRow = (int)toLocation.charAt(1) - (int)'1';\n\n\t\t//Figure out what type of piece this will be when it is done\n\t\tint newType = piece;\n\t\tif (upgradeType != null) newType = getPieceNumFromStr(upgradeType);\n\n\t\tif (fromRow == -1 || fromCol == -1) {\n\t\t\tList<String> possibleFroms = new LinkedList<String>();\n\t\t\tif (piece == 1) { //If it is a pawn\n\t\t\t\tif (whiteTeamMoving) {\n\t\t\t\t\tif (isCapture) {\n\t\t\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol+1));\n\t\t\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol-1));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol));\n\t\t\t\t\t\tif (toRow == 3) {\n\t\t\t\t\t\t\tpossibleFroms.add((toRow-2) + \"\" + (toCol));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (isCapture) {\n\t\t\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol+1));\n\t\t\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol-1));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol));\n\t\t\t\t\t\tif (toRow == 4) {\n\t\t\t\t\t\t\tpossibleFroms.add((toRow+2) + \"\" + (toCol));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (piece == 2) { //If it is a rook\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toCol) {\n\t\t\t\t\t\tpossibleFroms.add(toRow + \"\" + i);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toRow) {\n\t\t\t\t\t\tpossibleFroms.add(i + \"\" + toCol);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (piece == 3) { //If it is a knight\n\t\t\t\tpossibleFroms.add((toRow+2) + \"\" + (toCol+1));\n\t\t\t\tpossibleFroms.add((toRow+2) + \"\" + (toCol-1));\n\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol+2));\n\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol-2));\n\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol+2));\n\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol-2));\n\t\t\t\tpossibleFroms.add((toRow-2) + \"\" + (toCol+1));\n\t\t\t\tpossibleFroms.add((toRow-2) + \"\" + (toCol-1));\n\t\t\t} else if (piece == 4) { //If it is a bishop\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toCol) {\n\t\t\t\t\t\tpossibleFroms.add((toRow - toCol + i) + \"\" + (i));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toRow) {\n\t\t\t\t\t\tpossibleFroms.add((i) + \"\" + (toRow + toCol - i));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (piece == 5) { //If it is a queen\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toCol) {\n\t\t\t\t\t\tpossibleFroms.add(toRow + \"\" + i);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toRow) {\n\t\t\t\t\t\tpossibleFroms.add(i + \"\" + toCol);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toCol) {\n\t\t\t\t\t\tpossibleFroms.add((toRow - toCol + i) + \"\" + (i));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (int i = 0; i<8; i++) {\n\t\t\t\t\tif (i != toRow) {\n\t\t\t\t\t\tpossibleFroms.add((i) + \"\" + (toRow + toCol - i));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (piece == 6) { //If it is a king\n\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol));\n\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol));\n\t\t\t\tpossibleFroms.add((toRow) + \"\" + (toCol+1));\n\t\t\t\tpossibleFroms.add((toRow) + \"\" + (toCol-1));\n\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol+1));\n\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol-1));\n\t\t\t\tpossibleFroms.add((toRow-1) + \"\" + (toCol+1));\n\t\t\t\tpossibleFroms.add((toRow+1) + \"\" + (toCol-1));\n\t\t\t}\n\n\t\t\tfinal int fr = fromRow;\n\t\t\tfinal int fc = fromCol;\n\t\t\tOptional<String> originalLocationOP = possibleFroms.stream().filter((s)->{\n\t\t\t\tif (s.contains(\"-\")) return false;\n\n\t\t\t\tint r = Integer.parseInt(s.charAt(0)+\"\");\n\t\t\t\tint c = Integer.parseInt(s.charAt(1)+\"\");\n\n\t\t\t\tif (r < 0 || r > 7 || c < 0 || c > 7) return false;\n\n\t\t\t\tif (board[r][c] != piece * (whiteTeamMoving ? 1 : -1)) return false;\n\n\t\t\t\tif (fr != -1 && fr != r) return false;\n\t\t\t\tif (fc != -1 && fc != c) return false;\n\n\t\t\t\tif (!isLegalMove((r + \"\" + c) + \";\" + (toRow + \"\" + toCol) + \";\" + piece * (whiteTeamMoving ? 1 : -1))) return false;\n\n\t\t\t\treturn true;\n\t\t\t}).findAny(); \n\n\t\t\tString originalLoc = originalLocationOP.get();\n\t\t\tfromRow = Integer.parseInt(originalLoc.charAt(0)+\"\");\n\t\t\tfromCol = Integer.parseInt(originalLoc.charAt(1)+\"\");\n\t\t}\n\n\t\treturn (fromRow + \"\" + fromCol) + \";\" + (toRow + \"\" + toCol) + \";\" + newType * (whiteTeamMoving ? 1 : -1);\n\t}", "public State[] getSuccessors(State curr) {\n State [] successors = new State [6];\r\n \r\n if(currjug1!=0) {\r\n //e1\r\n successors[0] = new State(capjug1, capjug2, 0, currjug2, goal,depth);\r\n successors[0].parentPt = curr;\r\n successors[0].depth = curr.depth+1;\r\n //p12\r\n int pour = pour(currjug1, currjug2, capjug2);\r\n successors[1] = new State(capjug1, capjug2, currjug1-pour, currjug2+pour, goal,depth);\r\n successors[1].parentPt = curr;\r\n successors[1].depth = curr.depth+1;\r\n }\r\n \r\n if(currjug2!=0) {\r\n //e2\r\n successors[2] = new State(capjug1, capjug2, currjug1, 0, goal,depth);\r\n successors[2].parentPt = curr;\r\n successors[2].depth = curr.depth+1;\r\n }\r\n \r\n //f2\r\n successors[3] = new State(capjug1, capjug2, currjug1, capjug2, goal,depth);\r\n successors[3].parentPt = curr;\r\n successors[3].depth = curr.depth+1;\r\n \r\n if(currjug2!=0) {\r\n //p21\r\n int pour = pour(currjug2, currjug1, capjug1);\r\n successors[4] = new State(capjug1, capjug2, currjug1+pour, currjug2-pour, goal,depth);\r\n successors[4].parentPt = curr;\r\n successors[4].depth = curr.depth+1;\r\n }\r\n \r\n //f1\r\n successors[5] = new State(capjug1, capjug2, capjug1, currjug2, goal,depth);\r\n successors[5].parentPt = curr;\r\n successors[5].depth = curr.depth+1;\r\n \r\n return successors;\r\n }", "private BDD getNextGeneration(BDD generation){\n\t\tBDD res = this.factory.makeOne();\n\t\tAssignment assignment = generation.anySat();\n\n\t\tfor(int i = 0; i < this.dimension; i++){\n\t\t\tfor(int j = 0; j < this.dimension; j++){\n\n\t\t\t\t// it's a live cell, we remove it if we can\n\t\t\t\tif(assignment.holds(this.board[i][j])){\n\n\t\t\t\t\tif(trySolitude(i, j, assignment))\t\n\t\t\t\t\t\tres.andWith(this.board[i][j].not()); // evaluate F\n\n\t\t\t\t\telse if(tryOverpopulation(i, j, assignment))\n\t\t\t\t\t\tres.andWith(this.board[i][j].not()); // evaluate F\n\n\t\t\t\t\telse if(tryBorder(i, j))\n\t\t\t\t\t\tres.andWith(this.board[i][j].not()); // evaluate F\n\n\t\t\t\t\telse\n\t\t\t\t\t\tres.andWith(this.board[i][j].copy()); // evaluate T\n\n\t\t\t\t}\n\n\t\t\t\t// it's a dead cell, we populate it if we can\n\t\t\t\telse{\n\n\t\t\t\t\tif(tryPopulatingDeadCell(i, j, assignment))\n\t\t\t\t\t\tres.andWith(this.board[i][j].copy()); \t// evaluate T\t\n\t\t\t\t\telse\n\t\t\t\t\t\tres.andWith(this.board[i][j].not()); // evaluate F\n\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}", "public String toString() {\n\t\tcell = \" \" + not_fed + \" \";\n\n\t\treturn cell;\n\t}" ]
[ "0.6451513", "0.5412489", "0.52510166", "0.49606362", "0.49555728", "0.4934828", "0.49037987", "0.48574895", "0.48536134", "0.48080584", "0.47979987", "0.47529572", "0.47350264", "0.47132495", "0.46995318", "0.46854192", "0.46850422", "0.4682642", "0.46616173", "0.463326", "0.46275574", "0.46200278", "0.46099088", "0.45907414", "0.45766637", "0.45741105", "0.45724326", "0.45682847", "0.4561076", "0.45345554", "0.45296845", "0.45234656", "0.4521716", "0.45178124", "0.45113426", "0.45098093", "0.45046523", "0.45034996", "0.44974345", "0.44884595", "0.44708553", "0.4470777", "0.4467988", "0.4464334", "0.4458972", "0.44512084", "0.4449049", "0.44429407", "0.44417524", "0.44410405", "0.44351965", "0.44343966", "0.44335824", "0.4430308", "0.44282055", "0.44233188", "0.44219437", "0.4420854", "0.44194403", "0.4418846", "0.44186074", "0.44164371", "0.4416019", "0.4414893", "0.44129407", "0.44086856", "0.4407503", "0.4397089", "0.43926626", "0.43914497", "0.43910393", "0.4383388", "0.43783543", "0.43739682", "0.43713886", "0.43704483", "0.43652964", "0.4363506", "0.43562728", "0.43537262", "0.43503022", "0.43491626", "0.4345205", "0.43442103", "0.43223417", "0.43212616", "0.43194744", "0.43178496", "0.4314783", "0.43129206", "0.43071896", "0.4300581", "0.42866182", "0.42851254", "0.4284945", "0.42802092", "0.42763567", "0.4276079", "0.4274431", "0.42738262" ]
0.72186816
0
Get the Bidder for this Bid.
public Bidder getBidder() { return Bootstrap.getInstance().getUserRepository().fetchAll().stream() .filter(user -> user.getType() == UserType.BIDDER && user.getId() == this.bidderId) .map(user -> (Bidder) user) .findFirst().orElse(null); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public AID getBidder() {\n\t\treturn bidder;\n\t}", "public @NotNull Bidder newBidder();", "public int getBid() {\n return instance.getBid();\n }", "public @NotNull Bidder findBidder(@NotNull Identifier identifier) throws BidderNotFoundException, BazaarException;", "@Override\n\tpublic RotateBID get(String id) {\n\t\tRotateBID rotateBID=dao.get(id);\n\t\t\n\t\tif(\"招标采购\".equals(rotateBID.getBidType())) {\n\t\t\tList<RotateBIDPurchase> purchaseList=dao.listPurchase(id);\n\t\t\trotateBID.setPurchaseList(purchaseList);\n\t\t}else {\n\t\t\tList<RotateBIDSale> saleList=dao.listSale(id);\n\t\t\trotateBID.setSaleList(saleList);\n\t\t}\n\n\t\treturn rotateBID;\n\t}", "public Bidding getBiddingById(long id) {\r\n\t\treturn biddingPersistence.getBiddingById(id);\r\n\t}", "java.lang.String getBidid();", "public Bid toBid() {\n double[] demand = new double[newBid.length];\n for (int i = 0; i < newBid.length; i++) {\n demand[i] = newBid[i].demandWatt;\n }\n return new Bid(marketBasis, demand);\n }", "public com.google.protobuf.ByteString\n getBididBytes() {\n java.lang.Object ref = bidid_;\n if (ref instanceof java.lang.String) {\n com.google.protobuf.ByteString b = \n com.google.protobuf.ByteString.copyFromUtf8(\n (java.lang.String) ref);\n bidid_ = b;\n return b;\n } else {\n return (com.google.protobuf.ByteString) ref;\n }\n }", "public int getBId() {\n return instance.getBId();\n }", "public com.google.protobuf.ByteString\n getBididBytes() {\n java.lang.Object ref = bidid_;\n if (ref instanceof String) {\n com.google.protobuf.ByteString b = \n com.google.protobuf.ByteString.copyFromUtf8(\n (java.lang.String) ref);\n bidid_ = b;\n return b;\n } else {\n return (com.google.protobuf.ByteString) ref;\n }\n }", "public java.lang.String getBidid() {\n java.lang.Object ref = bidid_;\n if (ref instanceof java.lang.String) {\n return (java.lang.String) ref;\n } else {\n com.google.protobuf.ByteString bs = \n (com.google.protobuf.ByteString) ref;\n java.lang.String s = bs.toStringUtf8();\n if (bs.isValidUtf8()) {\n bidid_ = s;\n }\n return s;\n }\n }", "public java.lang.String getBidid() {\n java.lang.Object ref = bidid_;\n if (!(ref instanceof java.lang.String)) {\n com.google.protobuf.ByteString bs =\n (com.google.protobuf.ByteString) ref;\n java.lang.String s = bs.toStringUtf8();\n if (bs.isValidUtf8()) {\n bidid_ = s;\n }\n return s;\n } else {\n return (java.lang.String) ref;\n }\n }", "@ApiMethod(name=\"beers.get\")\n public Beer getBeer(@Named(\"id\") Long id) {\n PersistenceManager mgr = getPersistenceManager();\n Beer beer = null;\n try {\n beer = mgr.getObjectById(Beer.class, id);\n } finally {\n mgr.close();\n }\n return beer;\n }", "public Borrower getBorrower() {\n if (isBeforeFirst() || isAfterLast())\n return null;\n Borrower borrower = new Borrower();\n borrower.setId(getLong(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_ID)));\n borrower.setLoanAmount(getFloat(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_AMOUNT_BORROWED)));\n borrower.setInterestRate(getFloat(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_INTEREST_RATE)));\n borrower.setName(getString(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_NAME)));\n borrower.setIsPaid((getInt(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_PAID)) != 0));\n borrower.setPhoneNumber(getString(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_PHONE_NUMBER)));\n borrower.setThumbnailUri(getString(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_THUMBNAIL_URI)));\n borrower.setContactUri(Uri.parse(getString(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_CONTACT_URI))));\n\n if (!getWrappedCursor().isNull((getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_AMOUNT_PAID)))) {\n borrower.setAmountPaid(getFloat(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_AMOUNT_PAID)));\n }\n if (!getWrappedCursor().isNull((getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_LOAN_DURATION)))) {\n borrower.setLoanDuration(getInt(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_LOAN_DURATION)));\n }\n\n borrower.setDateBorrowed(getDateBorrowed());\n borrower.setDateDue(getDateDue());\n\n\n return borrower;\n }", "public ImmutableList<B> getBidders() {\n return this.bidders;\n }", "public static BinaryMessageDecoder<BirthInfo> getDecoder() {\n return DECODER;\n }", "public int getBid() {\n return bid_;\n }", "public String getBid() {\n return bid;\n }", "public String getBid() {\r\n return bid;\r\n }", "public int getBId() {\n return bId_;\n }", "com.google.protobuf.ByteString\n getBididBytes();", "public BeanDescriptor getBeanDescriptor() {\n return getBdescriptor();\n }", "@Override\n\tpublic Besoin getBesion(int idBesion) {\n\t\treturn dao.getBesion(idBesion);\n\t}", "public static BinaryMessageDecoder<AvroRide> getDecoder() {\n return DECODER;\n }", "public static BinaryMessageDecoder<Payload> getDecoder() {\n return DECODER;\n }", "public com.google.openrtb.OpenRtb.BidResponse getBidresponse() {\n return bidresponse_;\n }", "@Override\r\n\tpublic Bloger getBloger(int bloger_id) {\n\t\t\r\n\t\treturn blogerDao.getBloger(bloger_id);\r\n\t}", "com.google.ads.googleads.v6.resources.CampaignBidModifier getCampaignBidModifier();", "public static BinaryMessageDecoder<BabbleValue> getDecoder() {\n return DECODER;\n }", "public char getIsBidder() {\n\treturn isBidder;\n}", "public static TypeBridger getInstance() {\n if (typeBridger == null)\n typeBridger = new TypeBridger();\n\n return typeBridger;\n }", "public static BinaryMessageDecoder<ContentKey> getDecoder() {\n return DECODER;\n }", "public String getDealerId() {\n\t\treturn dealerId;\n\t}", "com.google.ads.googleads.v6.resources.BiddingStrategy getBiddingStrategy();", "public com.google.openrtb.OpenRtb.BidRequest getBidrequest() {\n return bidrequest_;\n }", "public gov.nih.nlm.ncbi.www.SeqIdDocument.SeqId.Pdb getPdb()\r\n {\r\n synchronized (monitor())\r\n {\r\n check_orphaned();\r\n gov.nih.nlm.ncbi.www.SeqIdDocument.SeqId.Pdb target = null;\r\n target = (gov.nih.nlm.ncbi.www.SeqIdDocument.SeqId.Pdb)get_store().find_element_user(PDB$28, 0);\r\n if (target == null)\r\n {\r\n return null;\r\n }\r\n return target;\r\n }\r\n }", "public Responder getResponder(long responder_id) {\n SQLiteDatabase db = this.getReadableDatabase();\n\n String selectQuery = \"SELECT * FROM \" + RESPONDERS_TABLE_NAME + \" WHERE \"\n + KEY_ID + \" = \" + responder_id;\n\n Log.e(LOG, selectQuery);\n\n Cursor c = db.rawQuery(selectQuery, null);\n\n if (c != null)\n c.moveToFirst();\n\n Responder responder = new Responder();\n responder.setId(c.getInt(c.getColumnIndex(KEY_ID)));\n responder.setName((c.getString(c.getColumnIndex(RESPONDERS_NAME))));\n responder.setPhone(c.getString(c.getColumnIndex(RESPONDERS_PHONE)));\n\n return responder;\n }", "Bird findById(String id);", "public Number getBuyerId() {\n return (Number)getAttributeInternal(BUYERID);\n }", "public @NotNull Bidder newBidder(@NotNull final Name name, @NotNull final Address billingAddress,\r\n\t\t\t@NotNull final Address shippingAddress);", "public static BinaryMessageDecoder<Trip> getDecoder() {\n return DECODER;\n }", "public com.google.openrtb.OpenRtb.BidResponse getBidresponse() {\n if (bidresponseBuilder_ == null) {\n return bidresponse_;\n } else {\n return bidresponseBuilder_.getMessage();\n }\n }", "@Generated(hash = 668324443)\n public NoteBK getNoteBK() {\n Long __key = this.NoteBK_ID;\n if (noteBK__resolvedKey == null || !noteBK__resolvedKey.equals(__key)) {\n final DaoSession daoSession = this.daoSession;\n if (daoSession == null) {\n throw new DaoException(\"Entity is detached from DAO context\");\n }\n NoteBKDao targetDao = daoSession.getNoteBKDao();\n NoteBK noteBKNew = targetDao.load(__key);\n synchronized (this) {\n noteBK = noteBKNew;\n noteBK__resolvedKey = __key;\n }\n }\n return noteBK;\n }", "@Override\n public java.lang.String getDealerId() {\n return _entityCustomer.getDealerId();\n }", "public long getDealerId() {\n\t\treturn dealerId;\n\t}", "com.google.ads.googleads.v6.resources.AdGroupBidModifier getAdGroupBidModifier();", "public Bid assembleBid(BidDTO bidDTO) {\r\n AuctionPersistenceHelper.validateNotNull(bidDTO, \"bidDTO\");\r\n\r\n CustomBid bid = new CustomBid(bidDTO.getBidderId(), bidDTO.getImageId(), bidDTO.getMaxAmount(),\r\n bidDTO.getTimestamp());\r\n\r\n if (bidDTO.getEffectiveAmount() != null) {\r\n bid.setEffectiveAmount(bidDTO.getEffectiveAmount().intValue());\r\n }\r\n\r\n if (bidDTO.getId() != null) {\r\n bid.setId(bidDTO.getId().longValue());\r\n }\r\n\r\n return bid;\r\n }", "@Override\n public BeanDescriptor getBeanDescriptor() {\n return getBdescriptor();\n }", "DrbdResource getDrbdResource() {\n return (DrbdResource) getResource();\n }", "public Entity getBorrower();", "public Number getBuyerId() {\n return (Number) getAttributeInternal(BUYERID);\n }", "public Auction getAuction(String auctionID){\r\n return super.get(auctionID);\r\n }", "public static BinaryMessageDecoder<DeviceInfo> getDecoder() {\n return DECODER;\n }", "public Auction getAuction() {\n return Bootstrap.getInstance().getAuctionRepository().fetchAll().stream()\n .filter(a -> a.getId() == auctionId)\n .findFirst().orElse(null);\n }", "public static BinaryMessageDecoder<Edge> getDecoder() {\n return DECODER;\n }", "public DataHandler getAttachment(String id) {\n if (attachments != null && attachments.get(id) != null) {\n return new DataHandler((DataSource) attachments.get(id));\n }\n return null;\n }", "public D getD()\n {\n return new DImpl2();\n }", "public com.google.openrtb.OpenRtb.BidResponse.Builder getBidresponseBuilder() {\n bitField0_ |= 0x00000002;\n onChanged();\n return getBidresponseFieldBuilder().getBuilder();\n }", "public static DOMAXIDBuilder getInstance() {\n\n\t\tif (builder == null) {\n\t\t\tsynchronized (lockObj) {\n\t\t\t\tif (builder == null) {\n\t\t\t\t\tbuilder = new DOMAXIDBuilder();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn builder;\n\t}", "public com.google.openrtb.OpenRtb.BidRequest getBidrequest() {\n if (bidrequestBuilder_ == null) {\n return bidrequest_;\n } else {\n return bidrequestBuilder_.getMessage();\n }\n }", "public gov.nih.nlm.ncbi.www.DbtagDocument.Dbtag getDbtag()\r\n {\r\n synchronized (monitor())\r\n {\r\n check_orphaned();\r\n gov.nih.nlm.ncbi.www.DbtagDocument.Dbtag target = null;\r\n target = (gov.nih.nlm.ncbi.www.DbtagDocument.Dbtag)get_store().find_element_user(DBTAG$0, 0);\r\n if (target == null)\r\n {\r\n return null;\r\n }\r\n return target;\r\n }\r\n }", "public gov.nih.nlm.ncbi.www.DbtagDocument.Dbtag getDbtag()\r\n {\r\n synchronized (monitor())\r\n {\r\n check_orphaned();\r\n gov.nih.nlm.ncbi.www.DbtagDocument.Dbtag target = null;\r\n target = (gov.nih.nlm.ncbi.www.DbtagDocument.Dbtag)get_store().find_element_user(DBTAG$0, 0);\r\n if (target == null)\r\n {\r\n return null;\r\n }\r\n return target;\r\n }\r\n }", "public DbAdapter getAdapter() {\n return adapter;\n }", "public com.google.protobuf.ByteString\n getDobBytes() {\n java.lang.Object ref = dob_;\n if (ref instanceof String) {\n com.google.protobuf.ByteString b = \n com.google.protobuf.ByteString.copyFromUtf8(\n (java.lang.String) ref);\n dob_ = b;\n return b;\n } else {\n return (com.google.protobuf.ByteString) ref;\n }\n }", "public Dealership getDealership(String did) {\n\t\tAnnotationConfiguration config = new AnnotationConfiguration();\n\t\t SessionFactory factory= config.configure().buildSessionFactory();\n\t\t Session session = factory.openSession();\n\t\t session.beginTransaction();\n\t\t Query query = session.createQuery(\"from Dealership where did = :dealerId\");\n\t\t query.setString(\"dealerId\", did);\n\n\t\t Dealership dealerShip = (Dealership)query.uniqueResult();\n\t\t session.getTransaction().commit();\n\t\t System.out.println(\"Database contents delivered...\");\n\t\t\tsession.close();\n\t\t //sendEmail();\n\t\treturn dealerShip; \n\t}", "@Override\n\tpublic BikeAdvert getBikeAdvert(int theId) {\n\t\tSession currentSession = sessionFactory.getCurrentSession();\n\t\t//now retrive /read from db using the primary key\n\t\tBikeAdvert theBikeAdvert = currentSession.get(BikeAdvert.class,theId);\n\t\t\n\t\treturn theBikeAdvert;\n\t}", "private com.google.protobuf.SingleFieldBuilder<\n com.google.openrtb.OpenRtb.BidRequest, com.google.openrtb.OpenRtb.BidRequest.Builder, com.google.openrtb.OpenRtb.BidRequestOrBuilder> \n getBidrequestFieldBuilder() {\n if (bidrequestBuilder_ == null) {\n bidrequestBuilder_ = new com.google.protobuf.SingleFieldBuilder<\n com.google.openrtb.OpenRtb.BidRequest, com.google.openrtb.OpenRtb.BidRequest.Builder, com.google.openrtb.OpenRtb.BidRequestOrBuilder>(\n getBidrequest(),\n getParentForChildren(),\n isClean());\n bidrequest_ = null;\n }\n return bidrequestBuilder_;\n }", "public int getID_BBDD()\n\t{\n\t\treturn this.ID_BBDD;\n\t}", "private com.google.protobuf.SingleFieldBuilder<\n com.google.openrtb.OpenRtb.BidResponse, com.google.openrtb.OpenRtb.BidResponse.Builder, com.google.openrtb.OpenRtb.BidResponseOrBuilder> \n getBidresponseFieldBuilder() {\n if (bidresponseBuilder_ == null) {\n bidresponseBuilder_ = new com.google.protobuf.SingleFieldBuilder<\n com.google.openrtb.OpenRtb.BidResponse, com.google.openrtb.OpenRtb.BidResponse.Builder, com.google.openrtb.OpenRtb.BidResponseOrBuilder>(\n getBidresponse(),\n getParentForChildren(),\n isClean());\n bidresponse_ = null;\n }\n return bidresponseBuilder_;\n }", "BInformation findOne(Long id);", "public String getBscid() {\n return bscid;\n }", "public String getBscid() {\n return bscid;\n }", "public Booking findOne(int id) {\n String sql = getJoinedQuery() + \" WHERE b.id = ?\";\n List<Booking> bookings = jdbc.query(sql, new Object[] {id}, resultSetExtractor);\n return bookings.get(0);\n }", "public static BinaryMessageDecoder<LargeObjectAvro> getDecoder() {\n return DECODER;\n }", "@Override\n\tpublic Brand get(int id) {\n\t\t\n \ttry {\n \t\tsql=\"select * from brands where id=?\";\n\t\t\tquery=connection.prepareStatement(sql);\n \t\tquery.setInt(1, id);\n\t\t\t\n\t\t\tResultSet result=query.executeQuery();\n\t\t\tresult.next();\n\t\t\t\n\t\t\tBrand brand=new Brand(result.getInt(\"Id\"),result.getString(\"Name\"));\n\t\t\t\n\t\t\treturn brand;\n\t\t} catch (Exception e) {\n\t\t\t// TODO: handle exception\n\t\t\tnew Exception(e.getMessage());\n\t\t}\n\t\t\n\t\treturn null;\n\t}", "public String getBscid() {\r\n return bscid;\r\n }", "public String getBscid() {\r\n return bscid;\r\n }", "public com.google.openrtb.OpenRtb.BidRequest.Builder getBidrequestBuilder() {\n bitField0_ |= 0x00000001;\n onChanged();\n return getBidrequestFieldBuilder().getBuilder();\n }", "public static BinaryMessageDecoder<VehicleInfoAvro> getDecoder() {\n return DECODER;\n }", "public gov.nih.nlm.ncbi.www.SeqIdDocument.SeqId.Ddbj getDdbj()\r\n {\r\n synchronized (monitor())\r\n {\r\n check_orphaned();\r\n gov.nih.nlm.ncbi.www.SeqIdDocument.SeqId.Ddbj target = null;\r\n target = (gov.nih.nlm.ncbi.www.SeqIdDocument.SeqId.Ddbj)get_store().find_element_user(DDBJ$24, 0);\r\n if (target == null)\r\n {\r\n return null;\r\n }\r\n return target;\r\n }\r\n }", "public Integer getBorrowerId() {\n return borrowerId;\n }", "public com.google.protobuf.ByteString\n getDobBytes() {\n java.lang.Object ref = dob_;\n if (ref instanceof java.lang.String) {\n com.google.protobuf.ByteString b = \n com.google.protobuf.ByteString.copyFromUtf8(\n (java.lang.String) ref);\n dob_ = b;\n return b;\n } else {\n return (com.google.protobuf.ByteString) ref;\n }\n }", "public Borrow getBorrow(int rdID, int c) {\n\t\treturn ((BorrowDAL)dal).getBorrow(rdID,c);\r\n\t}", "Reimbursement getReimbursementByID(int id);", "@java.lang.Deprecated\n public io.kubernetes.client.openapi.models.V1RBDPersistentVolumeSource getRbd();", "private BillingPeriod getBillingPeriod() {\n\t\treturn (BillingPeriod) this.getBean();\n\t}", "public Bid() {}", "public DataBeadReceiver getReceiver() {\r\n\t\treturn receiver;\r\n\t}", "@Override\r\n\tpublic List<Buss> findbid() {\n\t\treturn dao.findbid();\r\n\t}", "public int getBikeID() {\n\t\treturn bikeID;\n\t}", "public String adapterId() {\n return this.adapterId;\n }", "public HBRecordDataModel getHBRecord()\n\t{\n\t\tHBRecordDataModel HBRecordDataModel = null;\n\t\tList<AbsRecord> results = getRecordBy(getWhereConditionBaseOnIdRecord(), new HBRecordRowMapper());\n\n\t\tif (!results.isEmpty())\n\t\t{\n\n\t\t\tHBRecordDataModel = (HBRecordDataModel) results.get(0);\n\t\t}\n\n\t\treturn HBRecordDataModel;\n\t}", "public static BedwarsV2 getInstance() { return instance; }", "public TreeBidCard getTreeBidCard(String treeKey) {\n\t\treturn cacheTree.getTreeBidCard(treeKey);\n\t}", "public BidListModel getBidByBidListId(int bidListId) {\n return bidListRep.findByBidListId(bidListId);\n }", "int getBId();", "@Override\n public EntityDealer fetchByPrimaryKey(String dealerId)\n throws SystemException {\n return fetchByPrimaryKey((Serializable) dealerId);\n }", "public static com.surwing.model.Bed getBed(long bedId)\n throws com.liferay.portal.kernel.exception.PortalException,\n com.liferay.portal.kernel.exception.SystemException {\n return getService().getBed(bedId);\n }", "public static BinaryMessageDecoder<LNDCDC_ADS_PRPSL_DEAL_PNT_FEAT_LN> getDecoder() {\n return DECODER;\n }" ]
[ "0.75710326", "0.64052635", "0.6097389", "0.6008765", "0.5908881", "0.5828926", "0.5719889", "0.5703772", "0.57002217", "0.5690267", "0.5688404", "0.5658986", "0.56036854", "0.55891186", "0.5569854", "0.55564106", "0.55437994", "0.55317026", "0.54647905", "0.539628", "0.5394897", "0.5381618", "0.5376084", "0.5330889", "0.53270376", "0.5325755", "0.5322499", "0.5321768", "0.5321032", "0.52729315", "0.5264701", "0.5258799", "0.5251187", "0.5243594", "0.5236035", "0.52352315", "0.523276", "0.5208373", "0.5206755", "0.5202038", "0.5194871", "0.5185061", "0.5178101", "0.51739126", "0.51545984", "0.5147615", "0.51377666", "0.5129395", "0.5121714", "0.5115169", "0.51118475", "0.51027024", "0.50803274", "0.50708693", "0.50644433", "0.506395", "0.5060789", "0.5057997", "0.50575256", "0.50422066", "0.50331753", "0.5031627", "0.5031627", "0.5020195", "0.5018252", "0.5013859", "0.501084", "0.50103223", "0.5009749", "0.50097483", "0.5007725", "0.50012183", "0.50012183", "0.49996245", "0.49927682", "0.4991508", "0.49890426", "0.49890426", "0.4981072", "0.4979434", "0.4975579", "0.49686733", "0.49617887", "0.49580753", "0.49539575", "0.49455577", "0.49428242", "0.49365953", "0.4933671", "0.49317548", "0.49276164", "0.4921361", "0.49204195", "0.49164486", "0.49122053", "0.4911762", "0.49109527", "0.49089217", "0.4906456", "0.49035186" ]
0.76284856
0
Get the auction that this bid resides in.
public Auction getAuction() { return Bootstrap.getInstance().getAuctionRepository().fetchAll().stream() .filter(a -> a.getId() == auctionId) .findFirst().orElse(null); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public Auction getAuction(String auctionID){\r\n return super.get(auctionID);\r\n }", "public Auction getAuction(long auctionId) throws AuctionPersistenceException {\r\n for (Iterator iter = auctions.iterator(); iter.hasNext();) {\r\n Auction element = (Auction) iter.next();\r\n if ((element.getId() != null) && (element.getId().longValue() == auctionId)) {\r\n return element;\r\n }\r\n }\r\n return null;\r\n }", "public int getBid() {\n return instance.getBid();\n }", "public int getBid() {\n return bid_;\n }", "public String getBid() {\n return bid;\n }", "public static ArrayList<Item> getAuctionList() {\r\n return auctionList;\r\n }", "public String getBid() {\r\n return bid;\r\n }", "public com.google.openrtb.OpenRtb.BidRequest getBidrequest() {\n return bidrequest_;\n }", "public AID getBidder() {\n\t\treturn bidder;\n\t}", "public com.google.openrtb.OpenRtb.BidResponse getBidresponse() {\n return bidresponse_;\n }", "public Bidder getBidder() {\n return Bootstrap.getInstance().getUserRepository().fetchAll().stream()\n .filter(user -> user.getType() == UserType.BIDDER && user.getId() == this.bidderId)\n .map(user -> (Bidder) user)\n .findFirst().orElse(null);\n }", "public ResultSet getAuctionBids(int auctionID) throws SQLException {\n\t\tConnection dbConnection = getConnection();\n\t\tString query = \"SELECT BidID,OfferPrice,OfferedBy FROM BID \" + \"WHERE BID.AuctionID=\" + auctionID;\n\n\t\tPreparedStatement preparedStatement = dbConnection.prepareStatement(query);\n\t\tResultSet rs = preparedStatement.executeQuery();\n\t\treturn rs;\n\t}", "public Bidding getBiddingById(long id) {\r\n\t\treturn biddingPersistence.getBiddingById(id);\r\n\t}", "java.lang.String getBidid();", "int getBid();", "public int getWinningBid() {\n return winningBid;\n }", "public com.google.openrtb.OpenRtb.BidResponse getBidresponse() {\n if (bidresponseBuilder_ == null) {\n return bidresponse_;\n } else {\n return bidresponseBuilder_.getMessage();\n }\n }", "public int getWinningBid() {\n return this.winningBid;\n }", "@Override\r\n\tpublic List<Buss> findbid() {\n\t\treturn dao.findbid();\r\n\t}", "public Bid getLowestBid() {\n return jobBids.get(jobBids.size() - 1);\n }", "public com.google.openrtb.OpenRtb.BidRequest getBidrequest() {\n if (bidrequestBuilder_ == null) {\n return bidrequest_;\n } else {\n return bidrequestBuilder_.getMessage();\n }\n }", "public Item getItem(Long id)\n {\n return auctionManager.getItem(id);\n }", "com.google.openrtb.OpenRtb.BidRequest getBidrequest();", "public com.google.protobuf.ByteString\n getBididBytes() {\n java.lang.Object ref = bidid_;\n if (ref instanceof java.lang.String) {\n com.google.protobuf.ByteString b = \n com.google.protobuf.ByteString.copyFromUtf8(\n (java.lang.String) ref);\n bidid_ = b;\n return b;\n } else {\n return (com.google.protobuf.ByteString) ref;\n }\n }", "public com.google.protobuf.ByteString\n getBididBytes() {\n java.lang.Object ref = bidid_;\n if (ref instanceof String) {\n com.google.protobuf.ByteString b = \n com.google.protobuf.ByteString.copyFromUtf8(\n (java.lang.String) ref);\n bidid_ = b;\n return b;\n } else {\n return (com.google.protobuf.ByteString) ref;\n }\n }", "public ResultSet getItemsOnAuction() throws IllegalStateException{\n\t \n\t if(!isLoggedIn())\n\t throw new IllegalStateException(\"MUST BE LOGGED IN FIRST!\");\n\t try{\n\t \t stmt = con.createStatement();\n String queryString = \"SELECT INUMBER , INAME , CATEG, auc_start, auc_end_date , startbid , currentbid \" \n \t\t+ \"FROM ITEM \"\n + \" WHERE status = 'ON AUCTION'\";\n\n result = stmt.executeQuery(queryString);\n \n\t }\n\t catch (Exception E) {\n\t E.printStackTrace();\n\t }\n\t return result; \n\t }", "@Override\n public int getBidId()\n {\n return 0;\n }", "public java.lang.String getBidid() {\n java.lang.Object ref = bidid_;\n if (!(ref instanceof java.lang.String)) {\n com.google.protobuf.ByteString bs =\n (com.google.protobuf.ByteString) ref;\n java.lang.String s = bs.toStringUtf8();\n if (bs.isValidUtf8()) {\n bidid_ = s;\n }\n return s;\n } else {\n return (java.lang.String) ref;\n }\n }", "public BigDecimal getActualBidPrice() {\n return actualBidPrice;\n }", "public Auction assembleAuction(AuctionDTO auctionDTO) {\r\n AuctionPersistenceHelper.validateNotNull(auctionDTO, \"auctionDTO\");\r\n\r\n BidDTO[] bidDTOs = auctionDTO.getBids();\r\n Bid[] bids = new Bid[bidDTOs.length];\r\n\r\n for (int i = 0; i < bidDTOs.length; i++) {\r\n bids[i] = assembleBid(bidDTOs[i]);\r\n }\r\n\r\n return new AuctionImpl(auctionDTO.getId(), auctionDTO.getSummary(), auctionDTO.getDescription(),\r\n auctionDTO.getItemCount(), auctionDTO.getMinimumBid(), auctionDTO.getStartDate(), auctionDTO.getEndDate(),\r\n bids);\r\n }", "public java.lang.String getBidid() {\n java.lang.Object ref = bidid_;\n if (ref instanceof java.lang.String) {\n return (java.lang.String) ref;\n } else {\n com.google.protobuf.ByteString bs = \n (com.google.protobuf.ByteString) ref;\n java.lang.String s = bs.toStringUtf8();\n if (bs.isValidUtf8()) {\n bidid_ = s;\n }\n return s;\n }\n }", "public synchronized void closeAuction(){\n \tstatus = \"closed\";\n\n \ttry{\n \t\tif(last_bidder == null){\n \t\t\towner.getMessage(\"\\n Your Auction Item: \"+ ID +\", \"+ item_name +\" has closed with no bids \\n\");\n \t\t}\n \t\telse{\n \t\t\towner.getMessage(\"\\n Your Auction Item: \"+ ID +\", \"+ item_name +\" has a winner --> \"+ last_bidderName + \" Bid Price: \"+ start_price + \" Email: \"+ last_bidder.getEmail() +\"\\n\");\n \t\t\tfor(Entry<String, ClientInterface> entry : bids.entrySet()){\n \t\t\t\tClientInterface bidder = entry.getValue();\n \t\t\t\tif(bidder == last_bidder){\n \t\t\t\t\tlast_bidder.getMessage(\"\\n Congrats!!! You have won the bid for --> \"+ item_name+ \" at the price \" +start_price );\n \t\t\t\t}else{\n \t\t\t\t\tbidder.getMessage(\"\\n An Auction item --> \"+ item_name + \" you bid on was outbidded and won by\" + last_bidderName +\" for \"+ start_price +\"\\n\");\n \t\t\t\t}\n \t\t\t} \n \t\t}\n \t}catch(Exception e){\n \t\te.printStackTrace();\n \t}\n }", "public Bid toBid() {\n double[] demand = new double[newBid.length];\n for (int i = 0; i < newBid.length; i++) {\n demand[i] = newBid[i].demandWatt;\n }\n return new Bid(marketBasis, demand);\n }", "public static LiveBidStore getBidStore() {\r\n return bidStore;\r\n }", "com.google.protobuf.ByteString\n getBididBytes();", "public int getBId() {\n return instance.getBId();\n }", "com.google.openrtb.OpenRtb.BidResponse getBidresponse();", "public AuctionBulletin getAuctionBulletin(String id) {\n\t\treturn getHibernateTemplate().get(AuctionBulletin.class, Long.parseLong(id));\n\t}", "public com.google.openrtb.OpenRtb.BidRequestOrBuilder getBidrequestOrBuilder() {\n return bidrequest_;\n }", "public long getBuid() {\r\n return buid;\r\n }", "public String getBidByBifPubkey(String publKey) throws SDKException {\n Bid bid = new Bid(publKey,null);\n return bid.getBidStr();\n }", "public com.google.openrtb.OpenRtb.BidRequestOrBuilder getBidrequestOrBuilder() {\n if (bidrequestBuilder_ != null) {\n return bidrequestBuilder_.getMessageOrBuilder();\n } else {\n return bidrequest_;\n }\n }", "public ImmutableList<B> getBidders() {\n return this.bidders;\n }", "public String getClose_bidding() {\r\n return close_bidding;\r\n }", "public Bid winningBid(final String itemId);", "public double getCurrentBidToMatch() {\n\t\treturn currentBidToMatch;\n\t}", "public abstract Bid chooseOpeningBid();", "public int getBId() {\n return bId_;\n }", "public String getYbid() {\n return ybid;\n }", "public Auction createAuction(Auction auction) throws AuctionPersistenceException {\r\n auctions.add(auction);\r\n return auction;\r\n }", "public Bid getfinalBid(List<Bid> bids) {\n\t\t\r\n\t\tBid myBid=null;\r\n\t\tdouble lower=0,upper=0,total=0;\r\n\t\t//briskw meso oro\r\n\t for(int i=0;i<bids.size();i++)\r\n\t {\r\n\t \ttotal=total+US.getUtility(bids.get(i));\t \t\r\n\t }\t\t\r\n\t\tlower=total/bids.size();\r\n\t\tupper=lower;\r\n\t\t\r\n\t\t//anoigo ta oria ean den iparxei bid konta ston meso oro \r\n\t\twhile(myBid==null) {\r\n\t\t\t\r\n\t\t\tfor(int i=0;i<bids.size();i++) {\r\n\t\t\t\t\r\n\t\t\t\ttry {\r\n\t\t\t\t\tdouble util = US.getUtility(bids.get(i));\r\n\t\t\t\t\tif (util >= lower && util <= upper) {\r\n\t\t\t\t\t\tmyBid=bids.get(i);\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t}\r\n\t\t\t\t} catch (Exception e) {\r\n\t\t\t\t\te.printStackTrace();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif(lower>=0.025 && upper<=0.974) {\r\n\t\t\t\tlower=lower-0.025;\r\n\t\t\t\tupper=upper+0.025;\r\n\t\t\t}\r\n\t\t\telse if (upper>0.974) {\r\n\t\t\t\tlower=lower-0.025;\r\n\t\t\t\tupper=1;\r\n\t\t\t}\r\n\t\t}\t\r\n\t\t\r\n\t\treturn myBid;\r\n\t}", "Collection<Auction> getFutureAuctions();", "public com.google.openrtb.OpenRtb.BidResponseOrBuilder getBidresponseOrBuilder() {\n return bidresponse_;\n }", "public Date getBidOpenningTime() {\n return bidOpenningTime;\n }", "public com.google.openrtb.OpenRtb.BidResponseOrBuilder getBidresponseOrBuilder() {\n if (bidresponseBuilder_ != null) {\n return bidresponseBuilder_.getMessageOrBuilder();\n } else {\n return bidresponse_;\n }\n }", "public Number getBpoId() {\n return (Number) getAttributeInternal(BPOID);\n }", "public String getBidByBifPubkey(String publKey, String chaincode) throws SDKException {\n Bid bid = new Bid(publKey, chaincode);\n return bid.getBidStr();\n }", "public Bids[] populateBids() {\r\n\t\tint bidsLength = bids.size();\r\n\t\tint index = 0;\r\n\t\t\r\n\t\tBids[] auctionBids = new Bids[bidsLength];\r\n\t\tfor(Map.Entry<Integer, Bids> auctions: bids.entrySet()) {\r\n\t\t\tauctionBids[index] = auctions.getValue();\r\n\t\t\tindex++;\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\treturn auctionBids;\r\n\t\r\n\t}", "public BookBean retrieveBook(String bid) throws SQLException {\r\n\t\tString query = \"select * from BOOK where bid='\" + bid + \"'\";\t\t\r\n\t\tBookBean book = null;\r\n\t\tPreparedStatement p = con.prepareStatement(query);\t\t\r\n\t\tResultSet r = p.executeQuery();\r\n\t\t\r\n\t\twhile(r.next()){\r\n\t\t\tString bookID = r.getString(\"BID\");\r\n\t\t\tString title = r.getString(\"TITLE\");\r\n\t\t\tint price = r.getInt(\"PRICE\");\r\n\t\t\tString bookCategory = r.getString(\"CATEGORY\");\t\t\t\r\n\t\t\tbook = new BookBean(bookID, title, price,bookCategory);\r\n\t\t}\r\n\t\tr.close();\r\n\t\tp.close();\r\n\t\treturn book;\r\n\t}", "public Number getBuyerId() {\n return (Number) getAttributeInternal(BUYERID);\n }", "public com.google.openrtb.OpenRtb.BidRequest getRequest() {\n return request_;\n }", "public Number getBuyerId() {\n return (Number)getAttributeInternal(BUYERID);\n }", "@Override\n\tpublic Besoin getBesion(int idBesion) {\n\t\treturn dao.getBesion(idBesion);\n\t}", "public static Booking getBooking() {\n return sBooking;\n }", "public BidListModel getBidByBidListId(int bidListId) {\n return bidListRep.findByBidListId(bidListId);\n }", "public void setBid(String bid) {\r\n this.bid = bid;\r\n }", "public Item getItem() {\n return Bootstrap.getInstance().getItemRepository().fetchAll().stream()\n .filter(i -> i.getId() == this.itemId)\n .findFirst().orElse(null);\n }", "public String getBidOpenAddress() {\n return bidOpenAddress;\n }", "@ApiModelProperty(value = \"The price of the top bid order.\")\n public BigDecimal getBidPrice() {\n return bidPrice;\n }", "private ProductBookSide getBuySide() {\n\t\treturn buySide;\n\t}", "public Budget getBudget() {\n\t\treturn budget;\n\t}", "public Book load(String bid) {\n\t\treturn bookDao.load(bid);\r\n\t}", "@SuppressWarnings(\"unchecked\")\n\t@Override\n\tpublic List<BidItem> getBidItems(AuctionSearchBean auctionSearchBean) {\n\n\t\tQuery query = getEntityManager().createQuery(\" from BidItem as bidItem , BidSequence bidSeq \"\n\t\t\t\t+ \"where bidSeq.auction.auctionId = :auctionId and bidSeq.bidItemId = bidItem.bidItemId\");\n\t\tquery.setParameter(\"auctionId\", auctionSearchBean.getAuctionId());\t\n\t\tList<Object[]> objectsList = query.getResultList();\n\t\tList<BidItem> bidItemsList = new ArrayList<BidItem>();\n\n\t\tfor (Object[] objects : objectsList) {\n\t\t\tBidItem bidItem = (BidItem)objects[0];\n\t\t\tBidSequence bidSequence = (BidSequence)objects[1];\n\n\t\t\tbidItem.setSeqId(bidSequence.getSequenceId());\n\t\t\tbidItem.setBidSpan(bidSequence.getBidspan());\n\n\t\t\tif(!bidItemsList.contains(bidItem)) {\n\t\t\t\tbidItemsList.add(bidItem);\n\t\t\t}\n\t\t}\n\t\treturn bidItemsList;\n\t}", "@Override\n\tpublic BikeAdvert getBikeAdvert(int theId) {\n\t\tSession currentSession = sessionFactory.getCurrentSession();\n\t\t//now retrive /read from db using the primary key\n\t\tBikeAdvert theBikeAdvert = currentSession.get(BikeAdvert.class,theId);\n\t\t\n\t\treturn theBikeAdvert;\n\t}", "public Borrower getBorrower() {\n if (isBeforeFirst() || isAfterLast())\n return null;\n Borrower borrower = new Borrower();\n borrower.setId(getLong(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_ID)));\n borrower.setLoanAmount(getFloat(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_AMOUNT_BORROWED)));\n borrower.setInterestRate(getFloat(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_INTEREST_RATE)));\n borrower.setName(getString(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_NAME)));\n borrower.setIsPaid((getInt(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_PAID)) != 0));\n borrower.setPhoneNumber(getString(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_PHONE_NUMBER)));\n borrower.setThumbnailUri(getString(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_THUMBNAIL_URI)));\n borrower.setContactUri(Uri.parse(getString(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_CONTACT_URI))));\n\n if (!getWrappedCursor().isNull((getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_AMOUNT_PAID)))) {\n borrower.setAmountPaid(getFloat(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_AMOUNT_PAID)));\n }\n if (!getWrappedCursor().isNull((getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_LOAN_DURATION)))) {\n borrower.setLoanDuration(getInt(getColumnIndex(PayUpDataBaseHelper.COLUMN_BORROWER_LOAN_DURATION)));\n }\n\n borrower.setDateBorrowed(getDateBorrowed());\n borrower.setDateDue(getDateDue());\n\n\n return borrower;\n }", "public int getBoltingID() {\r\n\t\treturn boltingID;\r\n\t}", "public @NotNull Bid findBid(@NotNull final Identifier identifier) throws BidNotFoundException, BazaarException;", "public double getBid(double v) {\n double[] weights = {\n 0.6601863864966815,\n -0.44050297744775085,\n -0.3288461116450685,\n 0.7354115471274265,\n 0.6528564967694372,\n -0.021270821816517627,\n -0.751090383677677\n };\n if (roundsLeft == 0) {\n return Math.min(v * weights[0], cash);\n }\n if (roundsLeft / totalRounds < weights[1] * 333) {\n if (v > avrgBids[avrgBids.length - 1]) {\n return Math.min(v * weights[2], cash);\n } else if (v > avrgBids[avrgBids.length - 2]) {\n return Math.min(avrgBids[avrgBids.length - 2] - 1, cash);\n } else if (v > avrgBids[0] && v < avrgBids[1]) {\n return Math.min(v * weights[3], cash);\n }\n }\n return Math.min(v * weights[4], cash);\n }", "public int getBikeID() {\n\t\treturn bikeID;\n\t}", "public int get_Bag_id() {\r\n return this.bag_id;\r\n }", "public Builder clearBid() {\n copyOnWrite();\n instance.clearBid();\n return this;\n }", "public BigDecimal getRecommendBidPrice() {\n return recommendBidPrice;\n }", "public TACQuote getAuctionQuote(int gameTimeSeconds, int auctionIndex) {\n TACQuote[] quotes = auctionQuotes[auctionIndex];\n if (quotes != null) {\n long time = startTime + gameTimeSeconds * 1000;\n for (int i = 0, n = quotes.length; i < n; i++) {\n\tTACQuote q = quotes[i];\n\tif (q == null) {\n\t // End of quotes was found\n\t break;\n\t} else if (q.getLastUpdated() >= time) {\n\t return q;\n\t}\n }\n // Return the last quote if no quote was found after the specified time\n for (int i = quotes.length - 1; i >= 0; i--) {\n\tif (quotes[i] != null) {\n\t return quotes[i];\n\t}\n }\n }\n return null;\n }", "public AccommodationPledgeBo getAccommodationPledgeBo(){\n \treturn this.accommodationPledgeBo;\n }", "public List<BidListModel> getAllBids() {\n return bidListRep.findAll();\n }", "com.google.openrtb.OpenRtb.BidRequestOrBuilder getBidrequestOrBuilder();", "com.google.ads.googleads.v6.resources.CampaignBidModifier getCampaignBidModifier();", "@Override\n\tpublic BigDecimal getBackMoney(String bidId, String peridId) {\n\t\treturn dao.getBackMoney(bidId, peridId);\n\t}", "public String getOwningInstitutionBibId() {\n return owningInstitutionBibId;\n }", "public Booking findOne(int id) {\n String sql = getJoinedQuery() + \" WHERE b.id = ?\";\n List<Booking> bookings = jdbc.query(sql, new Object[] {id}, resultSetExtractor);\n return bookings.get(0);\n }", "public GregorianCalendar getBought(){\n\n\t\treturn bought;\n\t}", "public Bancaire getBanque() {\n\t\treturn banque;\n\t}", "public Book getBook() {\r\n\t\treturn b;\r\n\t}", "public Bike getBike(int bikeId){\n \n try(Connection con = DatabaseConnector.getConnection();\n PreparedStatement ps = con.prepareStatement(BIKE_BY_ID + bikeId);\n ResultSet rs = ps.executeQuery()){\n \n if(rs.next()){\n Bike bike = getBikeFromRS(rs);\n return bike;\n }\n }catch(Exception e){\n System.out.println(\"Exception\" + e);\n }\n return null;\n }", "public java.util.List<BrokerEBSVolumeInfo> getTargetBrokerEBSVolumeInfo() {\n return targetBrokerEBSVolumeInfo;\n }", "public AuctionDTO assembleAuctionDTO(Auction auction) {\r\n AuctionPersistenceHelper.validateNotNull(auction, \"auction\");\r\n\r\n Bid[] bids = auction.getBids();\r\n BidDTO[] bidDTOs = new BidDTO[bids.length];\r\n\r\n for (int i = 0; i < bids.length; i++) {\r\n bidDTOs[i] = assembleBidDTO(bids[i]);\r\n }\r\n\r\n AuctionDTO auctionDTO = new AuctionDTO();\r\n auctionDTO.setId(auction.getId());\r\n auctionDTO.setSummary(auction.getSummary());\r\n auctionDTO.setDescription(auction.getDescription());\r\n auctionDTO.setItemCount(auction.getItemCount());\r\n auctionDTO.setMinimumBid(auction.getMinimumBid());\r\n auctionDTO.setStartDate(auction.getStartDate());\r\n auctionDTO.setEndDate(auction.getEndDate());\r\n auctionDTO.setBids(bidDTOs);\r\n\r\n return auctionDTO;\r\n }", "public BrowPage getBrowPage() {\n \t\treturn mBrowPage;\n \t}", "com.google.openrtb.OpenRtb.BidResponseOrBuilder getBidresponseOrBuilder();", "public com.google.openrtb.OpenRtb.BidResponse.Builder getBidresponseBuilder() {\n bitField0_ |= 0x00000002;\n onChanged();\n return getBidresponseFieldBuilder().getBuilder();\n }", "public abstract Bid chooseCounterBid();" ]
[ "0.7735705", "0.7642188", "0.7185976", "0.7068247", "0.6772204", "0.6759748", "0.674533", "0.6536405", "0.6533598", "0.6443792", "0.640512", "0.6311423", "0.6286891", "0.6245459", "0.62347394", "0.61976665", "0.6195255", "0.60866976", "0.6084648", "0.60554004", "0.60380447", "0.6033674", "0.5921002", "0.59096485", "0.5908055", "0.5883906", "0.58650804", "0.5855511", "0.58341277", "0.5832597", "0.581634", "0.581052", "0.58094597", "0.57764715", "0.57720906", "0.5758777", "0.5752123", "0.57453597", "0.5718061", "0.5717299", "0.57119447", "0.5674301", "0.5656438", "0.5639383", "0.5606134", "0.5582503", "0.5498012", "0.54929256", "0.5484321", "0.54553753", "0.54457796", "0.54084486", "0.54081476", "0.5407728", "0.54011846", "0.53989697", "0.5382527", "0.5378194", "0.5375254", "0.5372526", "0.5367673", "0.53622735", "0.53523827", "0.53469926", "0.5340183", "0.5338401", "0.5305914", "0.5286919", "0.5264922", "0.52642137", "0.5263893", "0.52581996", "0.52538913", "0.52346784", "0.52105176", "0.5196718", "0.5196568", "0.5187381", "0.5182692", "0.5142386", "0.51401514", "0.5135459", "0.5133621", "0.51190066", "0.51143587", "0.5105551", "0.51024324", "0.5096294", "0.5089879", "0.50865906", "0.50760645", "0.5072419", "0.50721556", "0.50685173", "0.50635326", "0.50633395", "0.5060747", "0.5060037", "0.505875", "0.5042949" ]
0.8535858
0
Get the item that this bid is for.
public Item getItem() { return Bootstrap.getInstance().getItemRepository().fetchAll().stream() .filter(i -> i.getId() == this.itemId) .findFirst().orElse(null); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public Item getItem ()\n\t{\n\t\treturn item;\n\t}", "public Item getItem() {\n\t\treturn this.item;\n\t}", "public Item getItem() {\n\t\treturn this.item;\n\t}", "public Item getItem() {\r\n\t\treturn this.item;\r\n\t}", "public Item getItem() {\n\t\treturn item;\n\t}", "public Item getItem() {\n return item;\n }", "public RepositoryItem getItem() {\n\t\t\treturn item;\n\t\t}", "public Item getItem(Long id)\n {\n return auctionManager.getItem(id);\n }", "public Item getItem() {\n return item;\n }", "public Item getItem() { \n return myItem;\n }", "public T getItem() {\n return item;\n }", "public Item getItem() {\n return mItem;\n }", "public T getItem() {\n\t\treturn item;\n\t}", "public T getItem() {\n\t\treturn item;\n\t}", "public T getItem() {\r\n return item;\r\n }", "public BoxItem.Info getItem() {\n return this.item;\n }", "InventoryItem getInventoryItem();", "public Item getItem(int itemId) {\n\t\treturn (Item) hashOperations.get(KEY, itemId);\n\t}", "public SpItem getItem() {\n return _spItem;\n }", "public Item getItemById(Integer itemId);", "public String getItem() {\r\n\t\treturn item;\r\n\t}", "public ItemType getItem() {\n\t return this.item;\n\t}", "public ItemType getItem() {\n\t return this.item;\n\t}", "public Item getItem() { return this; }", "@Override\n\t\tpublic Object getItem(int arg0) {\n\t\t\treturn books.get(arg0);\n\t\t}", "ItemStack getItem();", "public int getItemID()\n {\n return itemID;\n }", "public ItemStack getItem() {\n return this.item;\n }", "public jkt.hms.masters.business.MasStoreItem getItem () {\n\t\treturn item;\n\t}", "public String getItem() {\r\n return item;\r\n }", "public Item getItemByName(String itemName) {\n\t\t\n\t\tfor (Item item : itemsInStock) {\n\t\t\tif (item.name.equals(itemName)) {\n\t\t\t\treturn item;\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn null;\n\t}", "protected ResourceReference getItem()\n\t{\n\t\treturn ITEM;\n\t}", "public Book getItem(int id) {\n return BookManagerSingelton.getInstance().getBook(id);\n }", "public ItemStack getItem() {\r\n\t\treturn item;\r\n\t}", "public int getBid() {\n return instance.getBid();\n }", "public static Item getItem( ) {\n ConnectionPool pool = ConnectionPool.getInstance();\n Connection connection = pool.getConnection();\n PreparedStatement ps = null;\n \n\tString query = \"select * from Item\";\n\ttry {\n ps = connection.prepareStatement(query);\n\t ResultSet rs = null;\n\t rs = ps.executeQuery();\n \n\t Item item = new Item();\n \n\t if (rs.next()) {\n\t\titem.setAttribute(rs.getString(1));\n\t\titem.setItemname(rs.getString(2));\n\t\titem.setDescription(rs.getString(3));\n\t\titem.setPrice(rs.getDouble(4));\n\t }\n\t rs.close();\n\t ps.close();\n\t return item;\n\t} catch (java.sql.SQLException sql) {\n\t sql.printStackTrace();\n\t return null;\n\t}\n }", "public io.opencannabis.schema.commerce.OrderItem.Item getItem(int index) {\n return item_.get(index);\n }", "public Item getItem(long idItem) throws ItemNotFound;", "public Auction getAuction() {\n return Bootstrap.getInstance().getAuctionRepository().fetchAll().stream()\n .filter(a -> a.getId() == auctionId)\n .findFirst().orElse(null);\n }", "io.opencannabis.schema.commerce.OrderItem.Item getItem(int index);", "public Item getItem(String itemName)\n {\n Item currentItem = items.get(0);\n // get each item in the items's array list.\n for (Item item : items){\n if (item.getName().equals(itemName)){\n currentItem = item;\n }\n }\n return currentItem;\n }", "TradeItem getTradeItem(long id);", "@Override\n\tpublic Item getItemByID(String itemId) {\n\n\t\treturn actionOnItem(itemId).get(0);\n\t}", "@Override\n\tpublic Item getItemByID(String itemId) {\n\n\t\treturn actionOnItem(itemId).get(0);\n\t}", "public int getITEM() {\r\n return item;\r\n }", "public Drink getOrderItem(int orderItemIndex)\r\n\t{\r\n\t\tSystem.out.println(\"Retrieving Order Item: \" + order[orderItemIndex]);\r\n\t\treturn order[orderItemIndex];\r\n\t}", "Identifiable item();", "public String getItemID() {\n\t return this.itemID;\n\t}", "public Item getItem(int itemIndex){\n\t\treturn inventoryItems[itemIndex];\n\t}", "public Item getItem(String id) {\r\n\t\treturn items.get(id);\r\n\t}", "public int getBid() {\n return bid_;\n }", "@Override\n public Item getItemBySlot(Integer itemSlot) {\n return dao.getItemBySlot(itemSlot);\n }", "public Integer getItemid() {\n return itemid;\n }", "public Integer getItemid() {\n return itemid;\n }", "@Override\n public Item get(long idItem) throws EntityNotFound;", "public static Item getItem(String itemName)\n {\n Item temp = null;\n for (Item inventory1 : inventory) {\n if (inventory1.getName().equals(itemName)) {\n temp = inventory1;\n }\n }\n return temp;\n }", "public PlayerItem getPlayerItemById(int playerItemId);", "public Item retrieveItem(Connection conn, int item_no) {\r\n\t\ttry {\r\n\t\t\tItem item = new Item();\r\n\t\t\tStatement stmt = conn.createStatement();\r\n\t\t\tResultSet rset = stmt.executeQuery(\"select * from item_XXXX where item_no=\" + item_no);\r\n\t\t\twhile (rset.next()) {\r\n\t\t\t\titem.setItemNo(rset.getInt(1));\r\n\t\t\t\titem.setDescription(rset.getString(2));\r\n\t\t\t\tString category = rset.getString(3);\r\n\t\t\t\titem.setCategory(Category.valueOf(category));\r\n\t\t\t\titem.setPrice(rset.getInt(4));\r\n\t\t\t\titem.setQuantity(rset.getInt(5));\r\n\t\t\t}\r\n\t\t\treturn item;\r\n\t\t} catch (SQLException e) {\r\n\t\t\te.printStackTrace();\r\n\t\t}\r\n\t\treturn null;\r\n\t}", "public Auction getAuction(String auctionID){\r\n return super.get(auctionID);\r\n }", "public Object get(String itemName);", "public ItemStack getItem() {\n ItemStack item = new ItemStack(material, 1);\n ItemMeta meta = item.getItemMeta();\n meta.setDisplayName(displayName);\n item.setItemMeta(meta);\n return item;\n }", "public static Item fetchByitem(long requestId) {\n\t\treturn getPersistence().fetchByitem(requestId);\n\t}", "public UserItem getUserItem() {\n return (attributes.containsKey(KEY_USER_ITEM) ? (UserItem) attributes\n .get(KEY_USER_ITEM) : null);\n }", "@Override\n public Item retrieveSingleItem(int itemNo) throws VendingMachinePersistenceException {\n loadItemFile();\n return itemMap.get(itemNo);\n }", "public Item getItem(String name) {\r\n \t\treturn persistenceManager.getItem(name);\r\n \t}", "public int getItemId() {\n return itemId;\n }", "public int getItemId()\r\n {\r\n return _itemId;\r\n }", "private BaseItem getItemById(int id) {\n\t\tfor (BaseItem item : mItems) {\n\t\t\tif (item.mId == id) {\n\t\t\t\treturn item;\n\t\t\t}\n\t\t}\n\t\treturn getDefault();\n\t}", "public int getKeyBuyItem() {\r\n return getKeyShoot();\r\n }", "public int getKeySellItem() {\r\n return getKeyShoot();\r\n }", "public Item getRandomItem() {\n int index = 0;\n int i = (int) (Math.random() * getItems().size()) ;\n for (Item item : getItems()) {\n if (index == i) {\n return item;\n }\n index++;\n }\n return null;\n }", "@Override\r\n\tpublic OrderItem getOrderItem(int id) {\n\t\tSession session = SessionFactorySingleton.getSessionFactory().getFactorySession();\r\n\t\tOrderItem order = (OrderItem) session.get(OrderItem.class,id);\r\n\t\treturn order;\r\n\r\n\t}", "public UserItem getUserItem() {\n return userItem;\n }", "public Object getItem(int i)\n {\n return items.elementAt(i);\n }", "public Item getData()\r\n\t{\r\n\t\treturn theItem;\r\n\t}", "ShoppingItem getShoppingItemByGuid(String itemGuid);", "public ArrayOfItem getItem() {\r\n return localItem;\r\n }", "public String getItemId() {\n return itemId;\n }", "public Item getItemBack(Player character) {\n itemPlacedRoom = false;\n Item item = character.items.get(character.getItemOwned2().getName());\n if(item != null) {\n if(canReceiveItem(character) == true) {\n items.put(item.getName(), item);\n } else {\n currentRoom.addItem(item);\n itemPlacedRoom = true;\n }\n character.setItemOwned2(null);\n }\n return item;\n }", "com.google.ads.googleads.v6.resources.FeedItem getFeedItem();", "public Book getBook(int index)\r\n\t{\r\n\t\tBook book = null;\r\n\t\ttry {\r\n\t\t\tbook = items.get(index);\r\n\t\t} catch(IndexOutOfBoundsException e) {\r\n\t\t}\r\n\t\treturn book;\r\n\t}", "public String getBid() {\n return bid;\n }", "public Bid winningBid(final String itemId);", "Item getBarcodeItem(String barcode) {\n if (getBarcodeData() != null &&\n getBarcodeData().containsBarcode(barcode)) {\n return getBarcodeData().get(barcode);\n } else {\n return null;\n }\n }", "public String getItemId() {\r\n return itemId;\r\n }", "public String getBid() {\r\n return bid;\r\n }", "@SideOnly(Side.CLIENT)\r\n public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_)\r\n {\r\n return Item.getItemFromBlock(MainRegistry.blockCampfireUnlit);\r\n }", "public Item getItemByKey(String key) {\n throw new OurBadException(\" Item '\" + this.serialize() + \"' is not an object.\");\n }", "public static Item fetchByPrimaryKey(long itemId) {\n\t\treturn getPersistence().fetchByPrimaryKey(itemId);\n\t}", "int getItemId() {\n return m_itemId;\n }", "Item findById(String id);", "public Objects getObject(String itemName)\n {\n return items.get(itemName);\n }", "public ItemEntry getItem(String itemName) {\n ItemEntry entry = null;\n \n for(ItemEntry i: itemList) {\n if (i.getItemName().equals(itemName)) {\n entry = i;\n }\n }\n \n return entry;\n }", "public Object getItem(int arg0) {\n\t\t\treturn data.get(arg0);\n\t\t}", "public Long getItemId() {\r\n return itemId;\r\n }", "@SideOnly(Side.CLIENT)\n\t public Item getItem(World wordl, int x, int y, int z)\n\t {\n//\t return this.blockMaterial == Material.iron ? Items.iron_door : Items.wooden_door;\n\t \t return MGHouseItems.item_boat_door;\n\t }", "public InputStream getItemAsInputStream() {\r\n\t\treturn item;\r\n\t}", "public Integer getItemNo() {\n\t\treturn itemNo;\n\t}", "public int getSlotForId(int itemId) {\n\t\tif (summonedFamiliar.familiarType == FamiliarType.BOB) {\n\t\t\tfor (int i = 0; i < burdenedItems.length; i++) {\n\t\t\t\tif ((burdenedItems[i] + 1) == itemId)\n\t\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}", "CatalogItem getItembyId(final Long id);" ]
[ "0.73023057", "0.72626406", "0.72626406", "0.72352695", "0.71121347", "0.7052307", "0.70307136", "0.69990486", "0.69823545", "0.69459087", "0.69327825", "0.6877896", "0.6859294", "0.6859294", "0.68514156", "0.68415266", "0.6828384", "0.68224573", "0.6809301", "0.6755631", "0.673687", "0.6729851", "0.6729851", "0.6725351", "0.6688143", "0.66716254", "0.6645052", "0.66338414", "0.6633285", "0.6629503", "0.66189235", "0.6611155", "0.66063213", "0.6575631", "0.65715307", "0.6560886", "0.65252435", "0.6497206", "0.64779854", "0.6476492", "0.64609903", "0.6424526", "0.6422587", "0.6422587", "0.6399567", "0.63960123", "0.63869333", "0.6360601", "0.63558733", "0.6340792", "0.63323736", "0.6328522", "0.63264555", "0.63264555", "0.63086516", "0.6281353", "0.6281025", "0.62491405", "0.6236111", "0.62220216", "0.62000054", "0.6182244", "0.61722934", "0.615766", "0.61574847", "0.6148562", "0.6141331", "0.61266315", "0.6125378", "0.61109906", "0.6107873", "0.6107542", "0.60812145", "0.60788375", "0.6074204", "0.6067854", "0.60643685", "0.606358", "0.60565156", "0.6052362", "0.6049399", "0.6042671", "0.60388273", "0.60319346", "0.603083", "0.6029389", "0.60231173", "0.6022629", "0.601429", "0.6013975", "0.6006946", "0.5999975", "0.5995623", "0.5977367", "0.5975493", "0.5966712", "0.59633255", "0.59630305", "0.59602404", "0.59570944" ]
0.76950383
0
75 x 93 redcube.png row 1 column 0 eye 3x0 8x8
private GameObject spawnBoss(LogicEngine in_logicEngine,LevelManager in_manager) { GameObject go = new GameObject("data/"+GameRenderer.dpiFolder+"/redcube.png",in_logicEngine.SCREEN_WIDTH/2,LogicEngine.rect_Screen.getHeight()+50,0); boss = go; boss.i_animationFrameRow = 1; boss.i_animationFrame =0; boss.i_animationFrameSizeWidth =75; boss.i_animationFrameSizeHeight =93; boss.v.setMaxForce(1); boss.v.setMaxVel(5); boss.stepHandlers.add( new BounceOfScreenEdgesStep()); boss_arrive.setAttribute("arrivedistance", "50", null); boss.stepHandlers.add( new CustomBehaviourStep(boss_arrive)); boss.isBoss = true; HitpointShipCollision c = new HitpointShipCollision(boss, 150, 40, true,1); if(Difficulty.isMedium()) c.f_numberOfHitpoints = 200; if(Difficulty.isHard()) c.f_numberOfHitpoints = 250; if(Difficulty.isMedium()) i_bossBubbleEvery = 125; if(Difficulty.isHard()) i_bossBubbleEvery = 100; c.addHitpointBossBar(in_logicEngine); c.setExplosion(Utils.getBossExplosion(boss)); boss.collisionHandler = c; boss.allegiance = GameObject.ALLEGIANCES.ENEMIES; //initial velocity of first one boss.v.setVel(new Vector2d(0,-5)); GameObject Tadpole1 = in_manager.spawnTadpole(in_logicEngine); GameObject Tadpole2 = in_manager.spawnTadpole(in_logicEngine); GameObject Bubble = null; Bubble = spawnBossBubble(in_logicEngine, 0, 3); Tadpole1.v.setVel(new Vector2d(-10,5)); Tadpole2.v.setVel(new Vector2d(10,5)); Bubble.v.setVel(new Vector2d(0,-5)); LaunchShipsStep l1 = new LaunchShipsStep(Tadpole1 , 50, 5, 1, false); LaunchShipsStep l2 = new LaunchShipsStep(Tadpole2, 50, 5, 1, true); LaunchShipsStep l3 = new LaunchShipsStep(Bubble, i_bossBubbleEvery, 1, 1, true); l1.b_addToBullets = true; l2.b_addToBullets = true; boss.stepHandlers.add(l1); boss.stepHandlers.add(l2); boss.stepHandlers.add(l3); d_eye = new Drawable(); d_eye.i_animationFrameSizeHeight=8; d_eye.i_animationFrameSizeWidth=8; d_eye.i_animationFrameRow = 3; d_eye.str_spritename = "data/"+GameRenderer.dpiFolder+"/eye.png"; boss.visibleBuffs.add(d_eye); return boss; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public void printImage() {\n\t System.out.print(\"\\n\");\n for (int i=0; i<width*height; i++) {\n if (i % width==0) System.out.print(\"\\n\");\n System.out.print(image[i]+ \" \");\n }\n System.out.print(\"\\n\\n\");\n }", "public void drawImage()\n {\n imageMode(CORNERS);\n //image(grayImgToFit, firstCellPosition[0], firstCellPosition[1]);\n image(canvas, firstCellPosition[0], firstCellPosition[1]);\n //image(tileMiniaturesV[0],10,250);\n //if(avaragedImgs.length > 4)\n // image(avaragedImgs[3],200,200);\n //getTileIntensityAtIndex(15,15);\n //println(tiles[7].getEndBrightness());\n \n }", "public void displayImageToConsole();", "public void createImage() {\n\t\tBufferedImage crab1ststep = null;\n\t\tBufferedImage crab2ndstep = null;\n\t\tBufferedImage crabhalf = null;\n\t\tBufferedImage crabfull = null;\n\t\tBufferedImage eye6 = null;\n\t\tBufferedImage eye5 = null;\n\t\tBufferedImage eye4 = null;\n\t\tBufferedImage eye3 = null;\n\t\tBufferedImage eye2 = null;\n\t\tBufferedImage eye1 = null;\n\t\tBufferedImage eyeClosed = null;\n\t\ttry {\n\t\t crabImage = ImageIO.read(new File(\"src/images/crab.png\"));\n\t\t crab1ststep = ImageIO.read(new File(\"src/images/crab1ststep.png\"));\n\t\t crab2ndstep = ImageIO.read(new File(\"src/images/crab2ndstep.png\"));\n\t\t crabhalf = ImageIO.read(new File(\"src/images/crabhalf.png\"));\n\t\t crabfull = ImageIO.read(new File(\"src/images/crabfull.png\"));\n\t\t crabWin = ImageIO.read(new File(\"src/images/crabwin.png\"));\n\t\t crabLose = ImageIO.read(new File(\"src/images/crablose.png\"));\n\t\t eye6 = ImageIO.read(new File(\"src/images/crab_eye6.png\"));\n\t\t eye5 = ImageIO.read(new File(\"src/images/crab_eye5.png\"));\n\t\t eye4 = ImageIO.read(new File(\"src/images/crab_eye4.png\"));\n\t\t eye3 = ImageIO.read(new File(\"src/images/crab_eye3.png\"));\n\t\t eye2 = ImageIO.read(new File(\"src/images/crab_eye2.png\"));\n\t\t eye1 = ImageIO.read(new File(\"src/images/crab_eye1.png\"));\n\t\t eyeClosed = ImageIO.read(new File(\"src/images/eyes_closed.png\"));\n\t\t} catch (IOException e) {\n\t\t\tSystem.out.println(\"bad\");\n\t\t}\n//\t\tcrabAni.add(crabImage);\n\t\tcrabAni.add(crabImage);\n\t\tcrabAni.add(crabImage);\n\t\tcrabAni.add(crabImage);\n\t\tcrabAni.add(crabImage);\n\t\tcrabAni.add(crabImage);\n//\t\tcrabAni.add(crab1ststep);\n\t\tcrabAni.add(crab1ststep);\n\t\tcrabAni.add(crab1ststep);\n\t\tcrabAni.add(crab1ststep);\n\t\tcrabAni.add(crab1ststep);\n\t\tcrabAni.add(crab1ststep);\n//\t\tcrabAni.add(crabImage);\n\t\tcrabAni.add(crabImage);\n\t\tcrabAni.add(crabImage);\n\t\tcrabAni.add(crabImage);\n\t\tcrabAni.add(crabImage);\n\t\tcrabAni.add(crabImage);\n//\t\tcrabAni.add(crab2ndstep);\n\t\tcrabAni.add(crab2ndstep);\n\t\tcrabAni.add(crab2ndstep);\n\t\tcrabAni.add(crab2ndstep);\n\t\tcrabAni.add(crab2ndstep);\n\t\tcrabAni.add(crab2ndstep);\n\t\tcrabAni.add(crab2ndstep);\n\t\tcrabAni.add(crab2ndstep);\n\t\t\n\t\tcrabAni2.add(crabImage);\n\t\tcrabAni2.add(crabImage);\n\t\tcrabAni2.add(crabImage);\n\t\tcrabAni2.add(crabImage);\n\t\tcrabAni2.add(crabImage);\n\t\tcrabAni2.add(crabImage);\n\t\tcrabAni2.add(crabhalf);\n\t\tcrabAni2.add(crabhalf);\n\t\tcrabAni2.add(crabhalf);\n\t\tcrabAni2.add(crabhalf);\n\t\tcrabAni2.add(crabhalf);\n\t\tcrabAni2.add(crabhalf);\n\t\tcrabAni2.add(crabfull);\n\t\tcrabAni2.add(crabfull);\n\t\tcrabAni2.add(crabfull);\n\t\tcrabAni2.add(crabfull);\n\t\tcrabAni2.add(crabfull);\n\t\tcrabAni2.add(crabfull);\n\t\t\n\t\tblink.add(eye6);\n\t\tblink.add(eye6);\n//\t\tblink.add(eye5);\n//\t\tblink.add(eye5);\n\t\tblink.add(eye4);\n\t\tblink.add(eye4);\n//\t\tblink.add(eye3);\n//\t\tblink.add(eye3);\n\t\tblink.add(eye2);\n\t\tblink.add(eye2);\n//\t\tblink.add(eye1);\n//\t\tblink.add(eye1);\n\t\tblink.add(eyeClosed);\n\t\tblink.add(eyeClosed);\n\t\tblink.add(eyeClosed);\n\t\tblink.add(eyeClosed);\n//\t\tblink.add(eye1);\n//\t\tblink.add(eye1);\n\t\tblink.add(eye2);\n\t\tblink.add(eye2);\n//\t\tblink.add(eye3);\n//\t\tblink.add(eye3);\n\t\tblink.add(eye4);\n\t\tblink.add(eye4);\n//\t\tblink.add(eye5);\n//\t\tblink.add(eye5);\n\t\tblink.add(eye6);\n\t\tblink.add(eye6);\n\t}", "WorldImage getImage();", "private void createTestImage()\n {\n initialImage = new byte[3 * size / 2];\n for (int i = 0; i < size; i++)\n {\n initialImage[i] = (byte) (40 + i % 199);\n }\n\n for (int i = size; i < 3 * size / 2; i += 2)\n {\n initialImage[i] = (byte) (40 + i % 200);\n initialImage[i + 1] = (byte) (40 + (i + 99) % 200);\n }\n }", "public static void main(String[] args) {\n try {\n File image = new File(\"petite_image.png\");\n ImageSerializer serializer = new ImageSerializerBase64Impl();\n\n // Sérialization\n String encodedImage = (String) serializer.serialize(image);\n System.out.println(splitDisplay(encodedImage,76));\n\n // Désérialisation\n byte[] deserializedImage = (byte[]) serializer.deserialize(encodedImage);\n\n // Vérifications\n // 1/ Automatique\n assert (Arrays.equals(deserializedImage, Files.readAllBytes(image.toPath())));\n System.out.println(\"Cette sérialisation est bien réversible :)\");\n // 2/ Manuelle\n File extractedImage = new File(\"petite_image_extraite.png\");\n new FileOutputStream(extractedImage).write(deserializedImage);\n System.out.println(\"Je peux vérifier moi-même en ouvrant mon navigateur de fichiers et en ouvrant l'image extraite dans le répertoire de ce Test\");\n\n\n } catch (IOException e) {\n e.printStackTrace();\n }\n }", "private void reanderImage(ImageData data) {\n \n }", "public void renderImage()\n {\n for (int i = 0; i < _imageWriter.getNx(); i++)\n {\n for (int j = 0; j < _imageWriter.getNy(); j++)\n {\n Ray ray;\n ray = new Ray(_scene.getCamera().constructRayThroughPixel(_imageWriter.getNx(), _imageWriter.getNy(),j,i,\n _scene.getScreenDistance(), _imageWriter.getWidth(),_imageWriter.getHeight()));\n\n if(i==255 && j==255)\n System.out.print(\"111\");\n Map<Geometry, List<Point3D>> intersectionPoints = new HashMap<>(getSceneRayIntersections(ray));\n\n if(intersectionPoints.isEmpty())\n _imageWriter.writePixel(j, i, _scene.getBackground());\n else\n {\n Map<Geometry, Point3D> closestPoint = getClosestPoint(intersectionPoints);\n Map.Entry<Geometry,Point3D> entry;\n Iterator<Entry<Geometry, Point3D>> it = closestPoint.entrySet().iterator();\n entry = it.next();\n _imageWriter.writePixel(j, i, calcColor(entry.getKey(), entry.getValue(), ray));\n }\n\n }\n }\n //printGrid(1);\n\n }", "@Override\n\tpublic void desenhar() {\n\t\tSystem.out.println(\"desenhar imagem png\");\n\t\t\n\t}", "public static void main(String[] args){\n\tImage test = new Image(700,700);\n\t//addRectangle(test, 0, 0, 600, 600, -1, -1, -1);\n\t//test.display();\n\taddCircle(test, 300, 300, 100, 255, 255, 255);\n\taddCircle(test, 500, 300, 100, 255, 255, 255);\n\taddCircle(test, 400, 400, 150, 255, 255, 255);\n\taddCircle(test, 350, 350, 25, 0, 0, 0);\n\taddCircle(test, 450, 350, 25, 0, 0, 0);\n\taddCircle(test, 350, 350, 24, 255, 255, 255);\n\taddCircle(test, 450, 350, 24, 255, 255, 255);\n\taddCircle(test, 350, 350, 10, 0, 0, 0);\n\taddCircle(test, 450, 350, 10, 0, 0, 0);\n\taddRectangle(test, 325, 475, 150, 20, 0, 0, 0);\n\ttest.setPixel(0,0,255,255,255);\n\ttest.display();\n\tencrypt(test, \"PerfektDokumentation\");\n\ttest.display();\n\tdecrypt(test, \"PerfektDokumentation\");\n\t\n\ttest.display();\n\t}", "public PixImage toPixImage() {\n // Replace the following line with your solution.\n\t PixImage image=new PixImage(getWidth(),getHeight());\n\t \n\t DList<int[]> runs_new=new DList<int[]>();\n\t\t\t for(RunIterator i=this.iterator();i.hasNext();) {\n\t\t\t int[] run = i.next();\n\t\t\t for (int t= 0; t < run[0]; t++) {\n\t\t\t \t runs_new.addLast(run);\n\t\t\t System.out.print(\"(\" + run[1]+\" \"+ run[2]+\" \"+run[3]+\")\");\n\t\t } \n\t }\t\n int position=1;\n for(int j=0;j<height;j++) {\n\t for(int i=0;i<width;i++) {\n\t\t\n\t\t DListNode<int[]> run_new=runs_new.nth(position);\n\t\t position++;\n\t\t \n\t\t image.setPixel(i, j, (short) run_new.item[1], (short) run_new.item[2], (short) run_new.item[3]);\n\t }\n }\n\t\t \n\t\t \n\t return image;\n }", "public static void testPixellateThreeArgs(){\n\t Picture caterpillar = new Picture(\"caterpillar.jpg\");\n\t caterpillar.explore();\n\t caterpillar.pixellate(18, 60, 40);\n\t caterpillar.explore();\n }", "public static void main(String[] args) \n\t{\n\t\tSystem.loadLibrary(Core.NATIVE_LIBRARY_NAME );\n\t\tMatToBufferedImage M2B = new MatToBufferedImage();\n \tMat mat = Highgui.imread(\"C:\\\\Users\\\\Dell\\\\Desktop\\\\Projects\\\\OpenCV\\\\image6.png\",Highgui.CV_LOAD_IMAGE_COLOR);\n \tMat newMat = new Mat(mat.rows(), mat.cols(), mat.type());\n \tmat.convertTo(mat, CvType.CV_64FC3); //CV_64FC3 it can use double[] instead of byte[] \n \t//Mat newMat = mat.clone();\n \n \t//byte buff[] = new byte[(int) (mat.total() * mat.channels())];\n \tdouble buff[] = new double[(int) (mat.total() * mat.channels())];\n \n\t\tdouble alpha = 2.2;\n \tint beta = 50; \n \n \tSystem.out.println(mat.type());\n \n \tmat.get(0, 0, buff);\n \n \tImageShow imshow = new ImageShow(M2B.getBufferedImage(mat));\n \n \tfor( int i = 0; i<buff.length; i++)\n \t{\n \t\tbuff[i] = (alpha*buff[i]+beta);\n \t}\n \n \tnewMat.put(0, 0, buff);\n \n\t\tImageShow imshow1 = new ImageShow(M2B.getBufferedImage(newMat));\n \n\n\t}", "public static void testPixellateOneArg(){\n\t Picture caterpillar = new Picture(\"caterpillar.jpg\");\n\t caterpillar.explore();\n\t caterpillar.pixellate(40);\n\t caterpillar.explore();\n }", "private static final byte[] xfuzzysave_d_image() {\n\t\tbyte data[] = { 71, 73, 70, 56, 57, 97, 16, 0, 16, 0, -62, 0, 0, 96,\n\t\t\t\t96, 96, -128, -128, -128, -112, -112, -112, -64, -64, -64,\n\t\t\t\t-112, -112, -112, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, -2,\n\t\t\t\t14, 77, 97, 100, 101, 32, 119, 105, 116, 104, 32, 71, 73, 77,\n\t\t\t\t80, 0, 33, -7, 4, 1, 10, 0, 5, 0, 44, 0, 0, 0, 0, 16, 0, 16, 0,\n\t\t\t\t0, 3, 64, 8, -86, -43, 11, 45, -82, -24, 32, -83, -74, -80, 43,\n\t\t\t\t-39, -26, -35, 7, 98, -39, -24, -119, -41, 23, 8, 67, -37, 10,\n\t\t\t\t-127, 86, -82, 66, 109, 7, 79, -76, -70, 111, -52, -47, -74,\n\t\t\t\t-102, -17, 18, 40, 26, -115, -96, 34, 97, -71, 44, 38, 3, 77,\n\t\t\t\t-88, -13, 7, 37, 40, -89, -60, 42, -77, -104, 0, 0, 59 };\n\t\treturn data;\n\t}", "public void vignette() {\n int rows= currentIm.getRows();\n int cols= currentIm.getCols();\n \n int middleRow = rows/2; //Height of the right angle\n int middleCol = cols/2; //Width of the right angle\n double hfD = (Math.sqrt(Math.pow(rows,2)+Math.pow(cols,2)))/2;\n \n //Outer: Rows, Inner: Columns\n for(int rr = 0; rr < rows; rr++){\n \n for(int cc = 0; cc < cols; cc++){\n \n int rgb= currentIm.getPixel(rr,cc);\n double red= DM.getRed(rgb);\n double blue= DM.getBlue(rgb);\n double green= DM.getGreen(rgb);\n int alpha= DM.getAlpha(rgb);\n \n double currentDistance = Math.sqrt(Math.pow(Math.abs(middleRow-rr),2)+\n Math.pow(Math.abs(middleCol-cc),2));\n \n double vigValue = 1-Math.pow((currentDistance/hfD),2);\n \n red = red * vigValue;\n green = green * vigValue;\n blue = blue * vigValue;\n \n currentIm.setPixel(rr, cc,\n (alpha << 24) | ((int)red << 16) | ((int)green << 8) | \n (int)blue);\n }\n \n }\n \n }", "private void traverseBayeredPatternFullSizeRGB() {\n\n for (int x = 0; x < originalImageHeight -1; x++){\n for (int y = 1; y < originalImageWidth -1; y++){\n Point position = new Point(x,y);\n int absolutePosition = getAbsolutPixelPosition(position);\n\n PixelType pixelType = null;\n\n if (x%2 == 0 && y%2 == 0) pixelType = PixelType.GREEN_TOPRED;\n if (x%2 == 0 && y%2 == 1) pixelType = PixelType.BLUE;\n if (x%2 == 1 && y%2 == 0) pixelType = PixelType.RED;\n if (x%2 == 1 && y%2 == 1) pixelType = PixelType.GREEN_TOPBLUE;\n\n fullSizePixRGB[absolutePosition] = getFullSizeRGB(new Point(x,y),pixelType);\n }\n }\n }", "@Test\r\n public void testComplex(){\r\n List<Tone> palette = StandardPalettes.PWG_STANDARD;\r\n\r\n BufferedImage image = ImageFileUtils.loadImageResource(\"/sampleImages/complex/rooves.jpg\");\r\n\r\n PaletteReplacer replacer = new PaletteReplacer();\r\n\r\n BufferedImage result = replacer.replace(image, palette);\r\n\r\n BufferedImage target = ImageFileUtils.loadImageResource(\"/resultImages/paletteReplacer/pwgRooves.png\");\r\n\r\n assertPixelsMatch(target, result);\r\n }", "private static final byte[] xfuzzysave_image() {\n\t\tbyte data[] = { 71, 73, 70, 56, 57, 97, 16, 0, 16, 0, -62, 0, 0, -82,\n\t\t\t\t69, 12, 0, 0, -128, -1, -1, -1, -1, -1, 0, -64, -64, -64, -1,\n\t\t\t\t-1, -1, -1, -1, -1, -1, -1, -1, 33, -2, 14, 77, 97, 100, 101,\n\t\t\t\t32, 119, 105, 116, 104, 32, 71, 73, 77, 80, 0, 33, -7, 4, 1,\n\t\t\t\t10, 0, 5, 0, 44, 0, 0, 0, 0, 16, 0, 16, 0, 0, 3, 64, 8, -86,\n\t\t\t\t-43, 11, 45, -82, -24, 32, -83, -74, -80, 43, -39, -26, -35, 7,\n\t\t\t\t98, -39, -24, -119, -41, 23, 8, 67, -37, 10, -127, 86, -82, 66,\n\t\t\t\t109, 7, 79, -76, -70, 111, -52, -47, -74, -102, -17, 18, 40,\n\t\t\t\t26, -115, -96, 34, 97, -71, 44, 38, 3, 77, -88, -13, 7, 37, 40,\n\t\t\t\t-89, -60, 42, -77, -104, 0, 0, 59 };\n\t\treturn data;\n\t}", "java.lang.String getImage();", "public static void lukisImej(BufferedImage image_dest) {\n int w = image_dest.getWidth();\n int h = image_dest.getHeight();\n\n//\t\tfor(int y=0; y<h;y++)\n//\t\t{\n//\t\t\tfor(int x =0 ; x<w; x++)\n//\t\t\t{\n//\t\t\t\tif(image_dest.getRGB(x, y)==-1)\n//\t\t\t\t\tSystem.out.print(\"1\");\n//\t\t\t\telse\n//\t\t\t\t{\n//\t\t\t\t\t//System.err.print(\"X\"+x+\" Y : \"+y);\n//\t\t\t\t\t//return;\n//\t\t\t\t\tSystem.out.print(\"0\");\n//\t\t\t\t}\n//\t\t\t}\n//\t\t\tSystem.out.println(\"\");\n//\t\t}\n\n }", "String getImage();", "private static final byte[] xfplot_d_image() {\n\t\tbyte data[] = { 71, 73, 70, 56, 57, 97, 16, 0, 16, 0, -60, 17, 0, 0, 0,\n\t\t\t\t0, 74, 74, 74, 92, 92, 92, 98, 98, 98, 105, 105, 105, 108, 108,\n\t\t\t\t108, 116, 116, 116, 119, 119, 119, 123, 123, 123, -126, -126,\n\t\t\t\t-126, -123, -123, -123, -112, -112, -112, -109, -109, -109,\n\t\t\t\t-103, -103, -103, -95, -95, -95, -92, -92, -92, -1, -1, -1, -1,\n\t\t\t\t-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\t\t\t\t0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\t\t\t\t0, 0, 0, 33, -7, 4, 1, 0, 0, 17, 0, 44, 0, 0, 0, 0, 16, 0, 16,\n\t\t\t\t0, 0, 5, 85, 96, 36, -114, 81, 16, -112, 40, 105, -102, 105,\n\t\t\t\t-70, -98, 40, 64, 10, 116, 29, -109, 4, 65, -25, -73, 88, -4,\n\t\t\t\t-71, 95, -127, 36, 19, 17, -124, 66, 2, 81, 36, -56, 29, 11,\n\t\t\t\t78, -63, -88, 88, 115, -22, 104, -45, 72, 109, -53, 21, 1, 94,\n\t\t\t\t92, -63, 43, -126, 32, 64, -50, 47, -45, 25, 66, 64, 68, 0,\n\t\t\t\t-128, -11, 107, 13, 39, -58, 33, 106, 72, -67, 5, -49, -19, 91,\n\t\t\t\t35, 8, 110, 41, 33, 0, 59 };\n\t\treturn data;\n\t}", "private void paintOriginalImage() {\r\n Graphics g = originalImage.getGraphics();\r\n // Erase to black\r\n g.setColor(Color.BLACK);\r\n g.fillRect(0, 0, FULL_SIZE, FULL_SIZE);\r\n \r\n // RGB quadrant\r\n for (int i = 0; i < QUAD_SIZE; i += 3) {\r\n int x = i;\r\n g.setColor(Color.RED);\r\n g.drawLine(x, 0, x, QUAD_SIZE);\r\n x++;\r\n g.setColor(Color.GREEN);\r\n g.drawLine(x, 0, x, QUAD_SIZE);\r\n x++;\r\n g.setColor(Color.BLUE);\r\n g.drawLine(x, 0, x, QUAD_SIZE);\r\n }\r\n \r\n // Picture quadrant\r\n try {\r\n URL url = getClass().getResource(\"images/BBGrayscale.png\");\r\n BufferedImage picture = ImageIO.read(url);\r\n // Center picture in quadrant area\r\n int xDiff = QUAD_SIZE - picture.getWidth();\r\n int yDiff = QUAD_SIZE - picture.getHeight();\r\n g.drawImage(picture, QUAD_SIZE + xDiff/2, yDiff/2, null);\r\n } catch (Exception e) {\r\n System.out.println(\"Problem reading image file: \" + e);\r\n }\r\n \r\n // Vector drawing quadrant\r\n g.setColor(Color.WHITE);\r\n g.fillRect(0, QUAD_SIZE, QUAD_SIZE, QUAD_SIZE);\r\n g.setColor(Color.BLACK);\r\n g.drawOval(2, QUAD_SIZE + 2, QUAD_SIZE-4, QUAD_SIZE-4);\r\n g.drawArc(20, QUAD_SIZE + 20, (QUAD_SIZE - 40), QUAD_SIZE - 40, \r\n 190, 160);\r\n int eyeSize = 7;\r\n int eyePos = 30 - (eyeSize / 2);\r\n g.fillOval(eyePos, QUAD_SIZE + eyePos, eyeSize, eyeSize);\r\n g.fillOval(QUAD_SIZE - eyePos - eyeSize, QUAD_SIZE + eyePos, \r\n eyeSize, eyeSize);\r\n \r\n // B&W grid\r\n g.setColor(Color.WHITE);\r\n g.fillRect(QUAD_SIZE + 1, QUAD_SIZE + 1, QUAD_SIZE, QUAD_SIZE);\r\n g.setColor(Color.BLACK);\r\n for (int i = 0; i < QUAD_SIZE; i += 4) {\r\n int pos = QUAD_SIZE + i;\r\n g.drawLine(pos, QUAD_SIZE + 1, pos, FULL_SIZE);\r\n g.drawLine(QUAD_SIZE + 1, pos, FULL_SIZE, pos);\r\n }\r\n \r\n originalImagePainted = true;\r\n }", "@Test\r\n public void testSameSize(){\r\n List<Tone> palette = Arrays.asList(new Tone(Color.red));\r\n\r\n BufferedImage image = ImageFileUtils.loadImageResource(\"/sampleImages/dimensions/2x4.png\");\r\n\r\n PaletteReplacer replacer = new PaletteReplacer();\r\n\r\n BufferedImage result = replacer.replace(image, palette);\r\n\r\n assertDimensions(result, 2, 4);\r\n }", "public BufferedImage getImage() {\n/* 81 */ return this.bufImg;\n/* */ }", "public void openImage() {\n InputStream f = Controller.class.getResourceAsStream(\"route.png\");\n img = new Image(f, mapImage.getFitWidth(), mapImage.getFitHeight(), false, true);\n h = (int) img.getHeight();\n w = (int) img.getWidth();\n pathNodes = new GraphNodeAL[h * w];\n mapImage.setImage(img);\n //makeGrayscale();\n }", "private static final byte[] xfplot_image() {\n\t\tbyte data[] = { 71, 73, 70, 56, 57, 97, 16, 0, 16, 0, -60, 16, 0, -65,\n\t\t\t\t3, 28, -1, 0, 21, -1, 0, 68, 0, 0, 0, -1, 0, 114, -1, 0, -70,\n\t\t\t\t-18, 0, -1, -1, 0, -27, -52, 0, -1, -78, 0, -1, -121, 0, -1,\n\t\t\t\t59, 0, -1, 93, 0, -1, 0, -112, -1, 0, 102, -1, -1, -1, -1, -1,\n\t\t\t\t-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\t\t\t\t0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\t\t\t\t0, 0, 0, 0, 0, 0, 33, -7, 4, 1, 0, 0, 16, 0, 44, 0, 0, 0, 0,\n\t\t\t\t16, 0, 16, 0, 0, 5, 103, 32, 36, -114, 16, 0, -112, 40, 25,\n\t\t\t\t-84, 65, -102, 10, -80, -112, 14, 36, 97, -33, 40, 61, 22,\n\t\t\t\t-123, -51, -25, 35, -61, -31, -64, 27, 26, 72, 58, 8, -62, 32,\n\t\t\t\t60, 48, 17, 72, 81, 2, 65, 125, 82, 19, 35, 93, 98, 75, -67,\n\t\t\t\t110, -77, 16, -123, 88, -79, -35, -114, 21, -94, -63, -126,\n\t\t\t\t-63, 62, -117, -39, -116, 5, -92, -31, 120, -40, -31, 112, -5,\n\t\t\t\t-61, -47, -128, 12, 6, 122, 11, -126, 11, 122, 127, 72, -128,\n\t\t\t\t15, -126, 118, -122, 46, 127, 14, 14, -116, 46, 35, 13, 125,\n\t\t\t\t41, 33, 0, 59 };\n\t\treturn data;\n\t}", "public static void main(String[] args) {\n // Be forwarned that when you write arrays directly in Java as below,\n // each \"row\" of text is a column of your image--the numbers get\n // transposed.\n PixImage image1 = array2PixImage(new int[][] { { 0, 3, 6 },\n { 1, 4, 7 },\n { 2, 5, 8 } });\n\n System.out.println(\"Testing one-parameter RunLengthEncoding constuctor \" +\n \"on a 3x3 image. Input image:\");\n System.out.print(image1);\n /////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n /*\n int [] red = {2,4,1,6,7};\n int [] leth = {2,3,1,1,2};\n\n RunLengthEncoding rle0 = new RunLengthEncoding(3, 3,red, red,red, leth);\n // RunLengthEncoding rle0 = new RunLengthEncoding(3, 3);\n \n for(RunIterator i=rle0.iterator();i.hasNext();) {\n\t System.out.println(i.next()[3]);\n }\n \n rle0.toPixImage();\n \n System.out.println(rle0.toPixImage().toString());\n System.out.println(\"XXXXXXXXXX\");\n\n */\n \n \n RunLengthEncoding rle1 = new RunLengthEncoding(image1);\n rle1.check();\n System.out.println(\"Testing getWidth/getHeight on a 3x3 encoding.\");\n doTest(rle1.getWidth() == 3 && rle1.getHeight() == 3,\n \"RLE1 has wrong dimensions\");\n \n rle1.toPixImage();\n \n System.out.println(\"Testing toPixImage() on a 3x3 encoding.\");\n System.out.println(rle1.toPixImage().toString());\n System.out.println(image1.toString());\n doTest(image1.equals(rle1.toPixImage()),\n \"image1 -> RLE1 -> image does not reconstruct the original image\");\n\n System.out.println(\"Testing setPixel() on a 3x3 encoding.\");\n setAndCheckRLE(rle1, 0, 0, 42);\n image1.setPixel(0, 0, (short) 42, (short) 42, (short) 42);\n doTest(rle1.toPixImage().equals(image1),\n /*\n array2PixImage(new int[][] { { 42, 3, 6 },\n { 1, 4, 7 },\n { 2, 5, 8 } })),\n */\n \"Setting RLE1[0][0] = 42 fails.\");\n\n System.out.println(\"Testing setPixel() on a 3x3 encoding.\");\n setAndCheckRLE(rle1, 1, 0, 42);\n image1.setPixel(1, 0, (short) 42, (short) 42, (short) 42);\n doTest(rle1.toPixImage().equals(image1),\n \"Setting RLE1[1][0] = 42 fails.\");\n\n \n System.out.println(\"Testing setPixel() on a 3x3 encoding.\");\n setAndCheckRLE(rle1, 0, 1, 2);\n image1.setPixel(0, 1, (short) 2, (short) 2, (short) 2);\n doTest(rle1.toPixImage().equals(image1),\n \"Setting RLE1[0][1] = 2 fails.\");\n\n System.out.println(\"Testing setPixel() on a 3x3 encoding.\");\n setAndCheckRLE(rle1, 0, 0, 0);\n image1.setPixel(0, 0, (short) 0, (short) 0, (short) 0);\n doTest(rle1.toPixImage().equals(image1),\n \"Setting RLE1[0][0] = 0 fails.\");\n\n System.out.println(\"Testing setPixel() on a 3x3 encoding.\");\n setAndCheckRLE(rle1, 2, 2, 7);\n image1.setPixel(2, 2, (short) 7, (short) 7, (short) 7);\n doTest(rle1.toPixImage().equals(image1),\n \"Setting RLE1[2][2] = 7 fails.\");\n\n System.out.println(\"Testing setPixel() on a 3x3 encoding.\");\n setAndCheckRLE(rle1, 2, 2, 42);\n image1.setPixel(2, 2, (short) 42, (short) 42, (short) 42);\n doTest(rle1.toPixImage().equals(image1),\n \"Setting RLE1[2][2] = 42 fails.\");\n \n System.out.println(\"Testing setPixel() on a 3x3 encoding.\");\n setAndCheckRLE(rle1, 1, 2, 42);\n image1.setPixel(1, 2, (short) 42, (short) 42, (short) 42);\n doTest(rle1.toPixImage().equals(image1),\n \"Setting RLE1[1][2] = 42 fails.\");\n\n \n PixImage image2 = array2PixImage(new int[][] { { 2, 3, 5 },\n { 2, 4, 5 },\n { 3, 4, 6 } });\n\n System.out.println(\"Testing one-parameter RunLengthEncoding constuctor \" +\n \"on another 3x3 image. Input image:\");\n System.out.print(image2);\n\n \n \n RunLengthEncoding rle2 = new RunLengthEncoding(image2);\n rle2.check();\n System.out.println(\"Testing getWidth/getHeight on a 3x3 encoding.\");\n doTest(rle2.getWidth() == 3 && rle2.getHeight() == 3,\n \"RLE2 has wrong dimensions\");\n\n System.out.println(\"Testing toPixImage() on a 3x3 encoding.\");\n doTest(rle2.toPixImage().equals(image2),\n \"image2 -> RLE2 -> image does not reconstruct the original image\");\n\n System.out.println(\"Testing setPixel() on a 3x3 encoding.\");\n setAndCheckRLE(rle2, 0, 1, 2);\n \n image2.setPixel(0, 1, (short) 2, (short) 2, (short) 2);\n doTest(rle2.toPixImage().equals(image2),\n \"Setting RLE2[0][1] = 2 fails.\");\n\n System.out.println(\"Testing setPixel() on a 3x3 encoding.\");\n setAndCheckRLE(rle2, 2, 0, 2);\n image2.setPixel(2, 0, (short) 2, (short) 2, (short) 2);\n doTest(rle2.toPixImage().equals(image2),\n \"Setting RLE2[2][0] = 2 fails.\");\n\n\n PixImage image3 = array2PixImage(new int[][] { { 0, 5 },\n { 1, 6 },\n { 2, 7 },\n { 3, 8 },\n { 4, 9 } });\n\n System.out.println(\"Testing one-parameter RunLengthEncoding constuctor \" +\n \"on a 5x2 image. Input image:\");\n System.out.print(image3);\n RunLengthEncoding rle3 = new RunLengthEncoding(image3);\n rle3.check();\n System.out.println(\"Testing getWidth/getHeight on a 5x2 encoding.\");\n doTest(rle3.getWidth() == 5 && rle3.getHeight() == 2,\n \"RLE3 has wrong dimensions\");\n\n System.out.println(\"Testing toPixImage() on a 5x2 encoding.\");\n doTest(rle3.toPixImage().equals(image3),\n \"image3 -> RLE3 -> image does not reconstruct the original image\");\n\n System.out.println(\"Testing setPixel() on a 5x2 encoding.\");\n setAndCheckRLE(rle3, 4, 0, 6);\n image3.setPixel(4, 0, (short) 6, (short) 6, (short) 6);\n doTest(rle3.toPixImage().equals(image3),\n \"Setting RLE3[4][0] = 6 fails.\");\n\n System.out.println(\"Testing setPixel() on a 5x2 encoding.\");\n setAndCheckRLE(rle3, 0, 1, 6);\n image3.setPixel(0, 1, (short) 6, (short) 6, (short) 6);\n doTest(rle3.toPixImage().equals(image3),\n \"Setting RLE3[0][1] = 6 fails.\");\n\n System.out.println(\"Testing setPixel() on a 5x2 encoding.\");\n setAndCheckRLE(rle3, 0, 0, 1);\n image3.setPixel(0, 0, (short) 1, (short) 1, (short) 1);\n doTest(rle3.toPixImage().equals(image3),\n \"Setting RLE3[0][0] = 1 fails.\");\n\n\n PixImage image4 = array2PixImage(new int[][] { { 0, 3 },\n { 1, 4 },\n { 2, 5 } });\n\n System.out.println(\"Testing one-parameter RunLengthEncoding constuctor \" +\n \"on a 3x2 image. Input image:\");\n System.out.print(image4);\n RunLengthEncoding rle4 = new RunLengthEncoding(image4);\n rle4.check();\n System.out.println(\"Testing getWidth/getHeight on a 3x2 encoding.\");\n doTest(rle4.getWidth() == 3 && rle4.getHeight() == 2,\n \"RLE4 has wrong dimensions\");\n\n System.out.println(\"Testing toPixImage() on a 3x2 encoding.\");\n doTest(rle4.toPixImage().equals(image4),\n \"image4 -> RLE4 -> image does not reconstruct the original image\");\n\n System.out.println(\"Testing setPixel() on a 3x2 encoding.\");\n setAndCheckRLE(rle4, 2, 0, 0);\n image4.setPixel(2, 0, (short) 0, (short) 0, (short) 0);\n doTest(rle4.toPixImage().equals(image4),\n \"Setting RLE4[2][0] = 0 fails.\");\n\n System.out.println(\"Testing setPixel() on a 3x2 encoding.\");\n setAndCheckRLE(rle4, 1, 0, 0);\n image4.setPixel(1, 0, (short) 0, (short) 0, (short) 0);\n doTest(rle4.toPixImage().equals(image4),\n \"Setting RLE4[1][0] = 0 fails.\");\n\n System.out.println(\"Testing setPixel() on a 3x2 encoding.\");\n setAndCheckRLE(rle4, 1, 0, 1);\n image4.setPixel(1, 0, (short) 1, (short) 1, (short) 1);\n doTest(rle4.toPixImage().equals(image4),\n \"Setting RLE4[1][0] = 1 fails.\");\n \n \n }", "public void setup() {\r\n smooth();\r\n // TODO: Try other images.\r\n img = loadImage(\"frog.jpg\");\r\n\r\n // Create and initialize the 2D array from individual pixels\r\n // in the image. Note that img.pixels is a 2D array - it contains\r\n // all the rows of the images strung in a long line, one row after an\r\n // other.\r\n pixelArray = new int[img.width][img.height];\r\n for (int i = 0; i < img.width; i++) {\r\n for (int j = 0; j < img.height; j++) {\r\n pixelArray[i][j] = img.pixels[j * img.width + i];\r\n }\r\n }\r\n }", "public static void main(String[] args) throws Exception {\n String fileName = args[0];\n\n // transform the image file to an Image\n Image image = null;\n\n Frame observer = new Frame();\n\n try {\n MediaTracker tracker = new MediaTracker(observer);\n image = Toolkit.getDefaultToolkit().getImage(fileName);\n tracker.addImage(image, 1);\n try {\n tracker.waitForID(1);\n } catch (InterruptedException e) {\n }\n } catch (Exception e) {\n System.out.println(\"some problem getting the image\");\n System.exit(0);\n }\n\n // get the actual size of the image:\n int actualWidth, actualHeight;\n actualWidth = image.getWidth(observer);\n actualHeight = image.getHeight(observer);\n\n System.out.println(\"found actual size of \"\n + actualHeight + \" by \" + actualWidth);\n\n // obtain the image data \n int[] pixels = new int[actualWidth * actualHeight];\n try {\n PixelGrabber pg = new PixelGrabber(image, 0, 0, actualWidth,\n actualHeight, pixels, 0, actualWidth);\n pg.grabPixels();\n if ((pg.status() & ImageObserver.ABORT) != 0) {\n System.out.println(\"error while grabbing pixels\");\n System.exit(0);\n }\n } catch (InterruptedException e) {\n System.out.println(\"pixel grabbing was interrupted\");\n System.exit(0);\n }\n\n // pull each int apart to obtain the individual pieces\n // and write them to the output file\n // prepare the output file\n String outFileName\n = fileName.substring(0, fileName.indexOf('.')) + \".raw\";;\n\n System.out.println(\n \"about to work on output file named: [\" + outFileName + \"]\");\n\n PrintWriter outFile = new PrintWriter(new File(outFileName));\n\n int alpha, red, green, blue, pixel;\n int k;\n\n outFile.println(actualWidth + \" \" + actualHeight);\n\n for (k = 0; k < actualWidth * actualHeight; k++) {\n pixel = pixels[k];\n alpha = (pixel >> 24) & 0xff;\n red = (pixel >> 16) & 0xff;\n green = (pixel >> 8) & 0xff;\n blue = (pixel) & 0xff;\n\n outFile.println(red + \" \" + green + \" \" + blue + \" \" + alpha);\n\n }\n\n outFile.close();\n\n }", "private static RenderedImage createImage(RegionReport rr) {\n BufferedImage bufferedImage = new BufferedImage(MAP_SIZE, MAP_SIZE,\n BufferedImage.TYPE_INT_RGB) ;\n // Create a graphics contents on the buffered image\n Graphics2D g2d = bufferedImage.createGraphics() ;\n g2d.setColor(Color.black);\n //TODO need to set default overflow to something other than black,\n // or set this default background to something else. colors colors colors.\n g2d.fillRect(0, 0, MAP_SIZE, MAP_SIZE);\n\n // SL coordinates work like math x/y graph\n // Java coordinates start at top left. Rotate 90 degrees\n // counterclockwise to compensate.\n AffineTransform at = new AffineTransform();\n at.concatenate(AffineTransform.getRotateInstance(CCW_90, MAP_SIZE/2.0, MAP_SIZE/2.0));\n at.scale(SCALE, SCALE);\n g2d.transform(at) ;\n \n String s = rr.getSubParcels() ;\n\n// \tGerstle\n// s = \"192,1,16,2,16,3,16,4,14,5,2,1,16,2,16,3,16,4,14,5,2,1,16,2,16,3,16,4,14,5,2,1,16,2,16,3,16,4,14,5,2,1,16,2,16,3,16,4,14,5,2,1,16,2,16,3,16,4,14,5,2,1,16,2,16,3,16,4,14,5,2,1,16,2,16,3,16,4,14,5,2,1,16,2,16,3,16,4,14,5,2,1,16,2,16,3,16,4,14,5,2,1,16,2,16,3,16,4,14,5,2,1,16,2,16,3,16,4,14,5,2,1,16,2,16,3,16,4,14,5,2,1,16,2,16,3,16,1,14,5,2,1,16,2,16,3,16,1,14,5,2,1,16,2,16,3,4,6,4,7,4,8,4,9,14,5,2,1,16,2,16,10,4,6,4,7,4,8,4,9,14,5,2,1,16,2,16,10,4,6,4,7,4,8,4,9,14,5,2,1,16,2,16,10,4,6,4,7,4,8,4,9,14,5,2,1,16,2,16,10,4,6,4,7,4,8,4,9,14,5,2,1,16,2,16,10,4,6,4,7,4,8,4,9,14,5,2,1,16,2,16,10,4,6,4,7,4,8,4,9,14,5,2,1,16,2,16,10,4,6,4,7,4,8,4,9,14,7,2,1,16,2,16,10,16,1,14,7,2,1,16,2,16,10,16,1,14,7,2,1,16,2,16,10,16,1,14,7,2,1,16,2,16,10,8,7,4,11,4,12,14,7,2,1,16,2,16,10,8,7,4,11,4,12,14,7,2,1,16,2,16,10,8,7,4,11,4,12,14,7,2,1,16,13,16,10,8,7,4,11,4,12,14,7,2,1,16,13,16,10,8,7,4,11,4,12,14,7,2,1,16,13,24,7,4,11,4,12,14,7,2,1,16,13,24,7,4,11,4,12,14,7,2,1,16,13,24,7,4,11,4,12,14,7,2,1,16,13,16,7,16,1,14,7,2,1,16,13,16,7,16,1,14,7,2,1,16,13,16,7,16,1,14,7,2,1,23,13,1,14,38,7,2,1,24,13,38,7,2,1,24,13,38,7,2,1,24,13,38,7,2,1,24,13,38,7,2,1,24,13,38,7,2,1,24,13,38,7,2,1,21,15,3,13,38,7,2,1,21,15,6,13,5,7,16,1,14,7,2,1,21,15,6,13,5,7,16,1,14,7,2,1,21,15,6,13,5,7,16,1,14,7,2,1,21,15,6,13,35,7,2,1,21,15,7,13,34,7,2,1,21,15,7,13,34,7,2,1,21,15,9,13,32,7,2,1,21,15,9,13,32,7,2,1,21,15,11,13,30,7,2,1,21,15,11,13,30,7,2,1,21,15,11,13,30,7,2,1,21,15,11,13,16,1,14,7,2,1,21,15,11,13,16,1,14,7,2,1,21,15,11,13,16,1,14,7,2,1,21,15,11,13,16,1,14,7,2,1,21,15,11,13,16,1,14,7,2,1,\" ;\n// // Palomarian\n// String s = \"8,1,4,2,4,3,11,4,20,5,17,4,8,1,4,2,4,3,12,4,19,5,17,4,8,1,4,2,4,3,13,4,18,5,17,4,8,1,4,2,4,3,14,4,17,5,17,4,8,1,4,2,4,3,14,4,17,5,17,4,8,1,4,2,4,3,15,4,16,5,17,4,8,1,4,2,4,3,16,4,15,5,11,4,2,6,4,4,8,1,4,2,4,3,16,4,15,5,11,4,2,6,4,4,4,5,4,7,8,8,17,4,16,5,9,4,2,6,4,4,4,5,4,7,8,8,18,4,16,5,8,4,2,6,4,4,4,5,4,7,8,8,22,4,14,5,6,4,2,6,4,4,4,5,4,7,8,8,25,4,12,5,5,4,2,6,4,4,4,5,4,7,8,8,30,4,9,5,3,9,2,6,4,4,4,5,4,7,8,8,31,4,9,5,2,9,2,6,8,5,4,7,8,8,32,4,9,5,1,9,2,6,8,5,4,7,8,8,34,4,8,5,2,6,4,5,17,8,35,4,12,5,17,8,35,4,12,5,17,8,37,4,10,5,17,8,37,4,10,5,17,8,37,4,10,5,17,8,38,4,9,5,17,8,38,4,9,5,18,8,36,4,10,5,18,8,35,4,11,5,18,8,34,4,12,5,18,8,33,4,13,5,18,8,32,4,14,5,18,8,32,4,8,5,6,4,18,8,30,4,9,5,7,4,18,8,30,4,8,5,8,4,18,8,30,4,7,5,9,4,12,5,36,4,7,5,9,4,12,5,36,4,6,5,10,4,12,5,35,4,6,5,11,4,12,5,35,4,5,5,12,4,12,5,34,4,5,5,13,4,14,5,31,4,6,5,13,4,6,10,9,5,30,4,5,5,14,4,6,10,11,5,27,4,5,5,15,4,6,10,4,4,8,5,25,4,5,5,16,4,6,10,6,4,8,5,2,4,1,5,20,4,5,5,16,4,6,10,8,4,12,5,16,4,6,5,16,4,6,10,8,4,12,5,15,4,7,5,16,4,6,10,8,4,15,5,12,4,7,5,16,4,6,10,10,4,16,5,8,4,8,5,16,11,6,10,10,4,18,5,5,4,9,5,16,11,6,10,10,4,32,5,16,11,8,12,8,4,32,5,16,11,8,12,8,4,32,5,16,11,8,12,8,4,32,5,16,11,8,12,8,4,32,5,16,11,8,12,8,4,16,5,1,11,15,5,16,11,8,12,8,4,16,5,3,11,13,5,16,11,8,12,8,4,16,5,6,11,10,5,16,11,8,12,8,4,16,5,7,11,9,5,16,11,8,12,8,13,4,14,4,15,8,4,9,11,7,5,16,11,8,12,8,13,4,14,4,15,8,4,10,11,6,5,16,11,8,12,8,13,4,14,4,15,8,4,11,11,6,5,15,11,8,12,8,13,4,14,4,15,8,4,12,11,5,5,15,11,8,12,8,4,4,14,4,15,8,4,13,11,5,5,14,11,8,12,8,4,4,14,4,15,8,4,14,11,5,5,13,11,8,12,8,4,4,14,4,15,8,4,14,11,6,5,12,11,8,12,8,4,4,14,4,15,8,4,15,11,6,5,11,11,\" ;\n// Clementina\n// String s = \"23,1,41,2,23,1,41,2,23,1,41,2,23,1,20,2,16,1,5,2,25,1,14,2,9,1,4,3,7,1,5,2,48,1,4,3,7,1,5,2,48,1,4,3,7,1,5,2,7,1,8,4,33,1,4,3,7,1,5,2,3,5,4,1,7,5,1,4,33,1,4,3,7,1,5,2,3,5,4,1,8,5,33,1,4,3,7,1,5,2,15,5,15,1,5,2,24,1,5,2,15,5,15,1,5,2,24,1,5,2,15,5,15,1,5,2,24,1,5,2,15,5,15,1,12,6,1,7,16,1,2,7,3,2,15,5,14,1,13,6,13,7,4,1,2,7,3,2,15,5,3,1,24,6,19,7,3,2,15,5,3,1,24,6,19,7,3,2,15,5,3,1,24,6,19,7,3,2,15,5,3,1,10,6,3,4,10,6,20,7,3,2,7,5,8,8,7,9,6,6,4,4,9,6,20,7,3,2,7,5,8,8,7,9,6,6,4,4,9,6,20,7,3,2,7,5,8,8,7,9,6,6,3,4,1,10,9,6,20,7,3,2,1,11,6,5,8,8,7,9,6,6,4,4,9,6,20,7,3,2,7,11,8,8,7,9,6,6,9,4,24,7,3,2,7,11,8,8,7,1,6,6,10,4,23,7,3,2,7,11,12,8,3,1,6,6,5,12,5,4,22,7,3,2,1,1,7,11,16,8,5,6,5,12,4,4,7,13,15,7,4,2,1,1,7,11,8,8,6,5,1,14,6,6,3,12,6,4,7,13,14,7,5,2,1,1,1,11,5,9,1,11,8,8,2,5,5,14,6,6,3,12,6,4,7,13,14,7,5,2,1,1,1,11,6,9,8,8,2,5,5,14,6,6,3,12,6,4,7,13,13,7,1,1,5,2,1,1,1,11,7,9,7,8,7,5,6,6,4,1,5,4,18,15,3,7,5,2,1,1,1,11,7,9,7,8,7,5,6,6,27,15,3,7,5,2,1,1,8,9,7,8,7,5,6,6,27,15,3,7,3,2,3,1,9,9,6,8,7,5,6,6,27,15,3,7,3,2,3,1,9,9,6,8,7,5,6,6,27,15,3,7,2,2,1,16,2,17,1,1,9,9,5,8,8,5,4,6,2,4,13,15,7,7,7,15,3,7,2,2,3,17,1,1,9,9,5,8,8,5,4,6,2,4,13,15,17,7,2,2,4,1,11,9,3,8,8,5,6,2,13,15,17,7,2,2,3,15,1,1,11,9,3,8,1,5,22,8,2,15,2,2,17,7,2,2,3,15,1,1,11,9,3,8,1,5,22,8,2,15,2,2,17,7,2,2,3,15,1,1,11,9,26,8,2,15,2,2,17,7,2,2,3,15,1,1,11,9,26,8,2,2,16,18,3,7,2,2,4,1,11,9,26,8,2,2,16,18,3,7,3,2,3,1,11,9,26,8,2,2,16,18,3,7,3,2,3,1,11,9,26,8,2,2,16,18,3,7,3,2,3,1,15,9,22,8,2,2,16,18,3,7,3,2,3,1,15,9,22,8,5,2,13,18,3,7,3,2,3,1,15,9,22,8,9,2,12,18,3,2,3,1,15,9,22,8,9,2,12,18,3,2,16,1,2,9,22,8,9,2,12,18,3,2,16,1,2,9,22,8,9,2,12,18,5,2,16,1,22,8,5,2,5,19,11,18,5,2,16,1,22,8,5,2,14,19,1,1,6,2,16,1,22,8,5,2,13,19,2,1,6,2,14,1,8,20,15,8,6,2,12,19,3,1,6,2,12,1,10,20,4,21,5,19,7,22,3,19,8,2,6,19,1,1,8,2,11,1,11,20,4,21,5,19,7,22,3,19,8,2,5,19,2,1,8,2,11,1,11,20,4,21,5,19,7,22,3,19,8,2,5,19,2,1,8,2,11,1,11,20,4,21,15,19,8,2,6,19,9,2,1,23,10,1,11,20,4,21,15,19,8,2,5,19,11,2,10,1,11,20,4,21,4,19,17,2,7,19,11,2,10,1,11,20,2,21,41,2,11,1,11,20,1,21,41,2,11,1,12,21,41,2,\" ;\n// Teal 8/08\n// String s = \"19,1,42,2,3,3,19,1,42,2,3,3,31,1,33,3,31,1,33,3,31,1,33,3,31,1,33,3,31,1,33,3,26,1,5,4,33,3,26,1,5,4,23,3,4,5,6,3,26,1,5,4,19,3,8,5,6,3,26,1,5,4,19,3,8,5,6,3,18,1,4,2,4,1,5,4,21,3,12,5,18,1,4,2,4,1,5,4,22,3,11,5,18,1,4,2,4,1,5,4,22,3,11,5,14,3,7,2,17,3,8,2,7,3,11,5,14,3,7,2,17,3,8,2,7,3,11,5,14,3,7,2,17,3,8,2,7,3,11,5,14,3,7,2,17,3,8,2,7,3,11,5,14,3,4,2,20,3,8,2,7,3,11,5,13,3,1,6,4,2,20,3,8,2,7,3,11,5,12,3,6,2,22,3,12,2,12,5,12,3,6,2,22,3,12,2,12,5,12,3,5,2,23,3,12,2,12,5,12,3,5,2,10,3,3,2,10,3,12,2,12,5,12,3,5,2,10,3,3,2,10,3,12,2,1,3,11,7,12,3,5,2,10,3,3,2,10,3,12,2,1,3,11,7,12,3,5,2,10,3,3,2,10,3,12,2,12,7,9,3,8,2,10,3,3,2,13,3,9,2,12,7,9,3,8,2,10,3,3,2,13,3,9,2,12,7,9,3,3,2,15,3,3,2,13,3,9,2,12,7,9,3,3,2,15,3,3,2,13,3,9,2,12,7,9,3,3,2,15,3,3,2,13,3,9,2,12,7,10,2,13,3,5,2,15,3,9,2,3,7,2,8,7,5,10,2,13,3,5,2,15,3,9,2,3,7,2,8,7,5,10,2,13,3,5,2,14,3,1,6,9,2,12,5,10,2,13,3,5,2,13,3,2,6,9,2,12,5,10,2,13,3,5,2,13,3,2,6,9,2,12,5,10,2,13,3,5,2,13,3,2,6,9,2,12,5,10,2,13,3,5,2,10,3,14,2,12,5,10,2,12,3,5,2,11,3,14,2,12,5,22,3,5,2,11,3,14,2,12,5,22,3,5,2,11,3,14,2,12,5,22,3,5,2,11,3,5,2,7,6,14,5,22,3,5,2,4,3,12,2,7,6,14,5,22,3,5,2,4,3,12,2,7,6,14,5,22,3,21,2,7,6,14,5,22,3,21,2,7,6,14,5,22,3,18,2,11,6,13,5,22,3,18,2,15,6,9,5,22,3,16,2,17,6,9,5,22,3,16,2,17,6,9,5,22,3,16,2,17,6,9,5,22,3,16,2,17,6,9,5,22,3,17,2,16,6,9,5,22,3,17,2,16,6,9,5,22,3,17,2,16,6,9,5,22,3,17,2,16,6,9,5,22,3,17,2,16,6,9,5,22,3,17,2,16,6,9,5,22,3,17,2,6,9,8,3,11,5,22,3,17,2,6,9,8,3,11,5,22,3,17,2,6,9,9,3,10,5,22,3,17,2,7,9,8,3,10,5,22,3,17,2,7,9,8,3,10,5,\" ;\n// Sage\n// String s = \"2,1,19,2,16,3,27,4,2,1,19,2,16,3,27,4,21,2,16,3,27,4,21,2,16,3,27,4,21,2,16,3,27,4,21,2,16,3,27,4,21,2,43,4,1,1,20,2,43,4,21,2,43,4,21,2,43,4,21,2,43,4,21,2,43,4,1,2,11,5,9,2,43,4,1,2,11,5,9,2,43,4,12,5,9,2,40,4,3,6,12,5,9,2,40,4,3,6,12,5,3,2,46,4,3,6,61,4,3,6,61,4,3,6,61,4,3,6,61,4,3,6,61,4,3,6,53,4,11,6,53,4,11,6,6,7,22,4,8,8,17,4,11,6,6,7,22,4,8,8,17,4,11,6,6,7,22,4,8,8,17,4,11,6,6,7,22,4,8,8,17,4,11,6,6,7,47,4,11,6,6,7,47,4,11,6,6,7,47,4,11,6,6,7,47,4,11,6,6,7,47,4,11,6,1,4,5,7,47,4,11,6,1,4,5,7,47,4,11,6,53,4,11,6,53,4,11,6,53,4,11,6,53,4,11,6,53,4,11,6,53,4,11,6,1,9,1,4,12,10,39,4,11,6,2,9,12,10,39,4,11,6,2,9,13,10,38,4,11,6,2,9,13,10,29,4,9,9,1,3,10,6,2,9,13,10,29,4,9,9,1,3,10,6,2,9,13,10,29,4,9,9,1,3,10,6,2,9,13,10,27,4,1,11,1,4,9,9,1,3,10,6,2,9,13,10,38,9,1,3,10,6,2,9,13,10,38,9,1,3,10,6,2,9,13,10,38,9,1,3,10,6,53,9,1,3,10,6,53,9,1,3,10,6,55,9,9,12,55,9,9,12,55,9,9,12,55,9,9,12,55,9,9,12,55,9,9,12,55,9,9,12,55,9,9,12,55,9,9,12,55,9,9,12,55,9,9,12,\" ;\n \n java.util.StringTokenizer st = new java.util.StringTokenizer(s, \",\\r\\n \") ;\n\n int xx = 0 ;\n int yy = 0 ;\n while (st.hasMoreTokens()) {\n int count = Integer.parseInt(st.nextToken()) ;\n //BUG: should really do something more about missing element.\n if (!st.hasMoreTokens()) continue ;\n int ownerNum = Integer.parseInt(st.nextToken()) ;\n Owner owner = rr.getOwner(ownerNum) ;\n Color cc ;\n if (owner.isLinden()) {\n cc = new Color(100,100,100) ;\n }\n else {\n cc = OwnerColors.getOwnerColor(ownerNum) ; \n }\n g2d.setColor(cc) ;\n\n while (xx + count >= ROW_SIZE) {\n int finishRow = ROW_SIZE - xx ;\n \n g2d.fillRect(xx, yy, finishRow, 1) ;\n \n // trial of svg\n // <rect x=\"0\" y=\"8\" width=\"512\" height=\"8\"\n // style=\"fill:rgb(255,255,255)\"/>\n// char q = '\"' ;\n// System.out.println(\n// \"<rect x=\" + q + xx + q + \" y=\" + q + yy + q +\n// \" width=\" + q + finishRow + q + \" height=\" + q + \"1\" + q +\n// \" style=\" + q + \"fill:rgb(\" + \n// cc.getRed() + \",\" + cc.getGreen() + \",\" + cc.getBlue() \n// + \")\" + q + \"/>\") ;\n \n count -= finishRow ;\n yy++ ;\n xx = 0 ;\n }\n if (count > 0) { \n g2d.fillRect(xx, yy, count, 1) ;\n \n// char q = '\"' ;\n// System.out.println(\n// \"<rect x=\" + q + xx + q + \" y=\" + q + yy + q +\n// \" width=\" + q + count + q + \" height=\" + q + \"1\" + q +\n// \" style=\" + q + \"fill:rgb(\" + \n// cc.getRed() + \",\" + cc.getGreen() + \",\" + cc.getBlue() \n// + \")\" + q + \"/>\") ;\n\n \n xx += count ;\n }\n\n } // while more tokens \n \n // Graphics context no longer needed so dispose it\n g2d.dispose() ;\n\n return bufferedImage ;\n }", "void imageData(int width, int height, int[] rgba);", "public void pixaveGreyscale(int x1, int y1, int x2, int y2) {\n //float sumr,sumg,sumb;\n float sumg;\n int pix;\n //int r,g,b;\n float g;\n int n;\n\n if(x1<0) x1=0;\n if(x2>=kWidth) x2=kWidth-1;\n if(y1<0) y1=0;\n if(y2>=kHeight) y2=kHeight-1;\n\n //sumr=sumg=sumb=0.0;\n sumg = 0.0f;\n for(int y=y1; y<=y2; y++) {\n for(int i=kWidth*y+x1; i<=kWidth*y+x2; i++) {\n \n // old method use depth image\n //pix= kinecter.depthImg.pixels[i];\n //g = pix & 0xFF; // grey\n //sumg += g;\n \n //b=pix & 0xFF; // blue\n // pix = pix >> 8;\n //g=pix & 0xFF; // green\n //pix = pix >> 8;\n //r=pix & 0xFF; // red\n //if( random(0, 150000) > 149000 && r > 0) println(\"r \" + r + \" b \" + b + \" g \" + g);\n // averaging the values\n //sumr += b;//r;//g;//r;\n //sumg += b;//r;//g;\n //sumb += b;//r;//g;//b;\n \n // WORK WITH RAW DEPTH INSTEAD\n sumg += kinecter.rawDepth[i];\n\n \n }\n }\n n = (x2-x1+1)*(y2-y1+1); // number of pixels\n // the results are stored in static variables\n //ar = sumr/n; \n //ag = sumg/n; \n //ab = sumb/n;\n\n ar = sumg/n; \n ag = ar; \n ab = ar;\n }", "IMG createIMG();", "public void renderImage() {\n Camera camera = scene.getCamera();//fot the function thats in the camera.constr.. to build the rays.\n Intersectable geometries = scene.getGeometries();//list of geomertries for the functon in geometries.findinter..\n java.awt.Color background = scene.getBackground().getColor();\n double distance = scene.getDistance();\n\n\n int width = (int) imageWriter.getWidth(); //width of the view plane\n int height = (int) imageWriter.getHeight();//height of the view plane\n int Nx = imageWriter.getNx(); // number of squares in the Row (shura). we need it for the for\n int Ny = imageWriter.getNy(); //number of squares in the column.(amuda). we need it for the for\n\n /**for each pixel we will send ray, and with the function findIntersection\n * we will get the Geo points(point 3d, color).\n * if we got nothing so we will color with the back round color\n * if we got the GeoPoints We will send to the function getClosestPoint and color*/\n Color pixelColor;\n for (int row = 0; row < Ny; ++row) {\n for (int column = 0; column < Nx; ++column) {\n if (amountRays > 1) { //if there is superSampling\n List<Ray> rays = camera.constructNRaysThroughPixel(Nx, Ny, column, row, distance, width, height,superSamplingRate, amountRays);\n Color averageColor;\n pixelColor = scene.getBackground();\n for (Ray ray : rays) {//for each ray from the list give the list of intersection geo-points.\n List<GeoPoint> intersectionPoints = geometries.findGeoIntersections(ray);\n averageColor = scene.getBackground();\n if (intersectionPoints != null) {\n GeoPoint closestPoint = getClosestPoint(intersectionPoints);//get the closest point for each ray.\n averageColor = calcColor(closestPoint, ray);//calculate the color and put in averageColor\n }\n pixelColor = pixelColor.add(averageColor);//befor we go to the next ray we add the averageColor to pixelColor.\n }\n pixelColor = pixelColor.reduce(rays.size());//we are doing the (memuza) and that is the color of that pixel.\n }\n else {//if there is no supersampling\n Ray ray = camera.constructRayThroughPixel(Nx, Ny, column, row, distance, width, height);\n List<GeoPoint> intersectionPoints = geometries.findGeoIntersections(ray);\n pixelColor = scene.getBackground();\n if (intersectionPoints != null) {\n GeoPoint closestPoint = getClosestPoint(intersectionPoints);\n pixelColor = calcColor(closestPoint, ray);\n }\n }\n imageWriter.writePixel(column, row, pixelColor.getColor());\n }\n }\n }", "static void renderScreenImage(JmolViewer viewer, Object g, Object size) {\n /**\n * @j2sNative\n * \n */\n {\n System.out.println(\"\" + viewer + g + size);\n }\n }", "@Test\n void writeToImage() {\n String imagename = \"img\";\n int width = 1600;\n int height = 1000;\n int nx =500;\n int ny =800;\n ImageWriter imageWriter = new ImageWriter(imagename, width, height, nx, ny);\n for (int col = 0; col < ny; col++) {\n for (int row = 0; row < nx; row++) {\n if (col % 10 == 0 || row % 10 == 0) {\n imageWriter.writePixel(row, col, Color.blue);\n }\n }\n }\n imageWriter.writeToImage();\n }", "public static void testGrayscale()\n {\n\t Picture wall = new Picture(\"wall.jpg\");\n\t wall.toGrayscale();\n\t wall.explore();\n }", "public void showbitmap4() {\n \n \t}", "private void c()\r\n/* 81: */ {\r\n/* 82: */ BufferedImage localBufferedImage;\r\n/* 83: */ try\r\n/* 84: */ {\r\n/* 85:102 */ localBufferedImage = cuj.a(bsu.z().O().a(this.g).b());\r\n/* 86: */ }\r\n/* 87: */ catch (IOException localIOException)\r\n/* 88: */ {\r\n/* 89:104 */ throw new RuntimeException(localIOException);\r\n/* 90: */ }\r\n/* 91:107 */ int i1 = localBufferedImage.getWidth();\r\n/* 92:108 */ int i2 = localBufferedImage.getHeight();\r\n/* 93:109 */ int[] arrayOfInt = new int[i1 * i2];\r\n/* 94:110 */ localBufferedImage.getRGB(0, 0, i1, i2, arrayOfInt, 0, i1);\r\n/* 95: */ \r\n/* 96:112 */ int i3 = i2 / 16;\r\n/* 97:113 */ int i4 = i1 / 16;\r\n/* 98: */ \r\n/* 99:115 */ int i5 = 1;\r\n/* 100: */ \r\n/* 101:117 */ float f1 = 8.0F / i4;\r\n/* 102:119 */ for (int i6 = 0; i6 < 256; i6++)\r\n/* 103: */ {\r\n/* 104:120 */ int i7 = i6 % 16;\r\n/* 105:121 */ int i8 = i6 / 16;\r\n/* 106:123 */ if (i6 == 32) {\r\n/* 107:124 */ this.d[i6] = (3 + i5);\r\n/* 108: */ }\r\n\t\t\t\t\tint i9;\r\n/* 109:127 */ for (i9 = i4 - 1; i9 >= 0; i9--)\r\n/* 110: */ {\r\n/* 111:129 */ int i10 = i7 * i4 + i9;\r\n/* 112:130 */ int i11 = 1;\r\n/* 113:131 */ for (int i12 = 0; (i12 < i3) && (i11 != 0); i12++)\r\n/* 114: */ {\r\n/* 115:132 */ int i13 = (i8 * i4 + i12) * i1;\r\n/* 116:134 */ if ((arrayOfInt[(i10 + i13)] >> 24 & 0xFF) != 0) {\r\n/* 117:135 */ i11 = 0;\r\n/* 118: */ }\r\n/* 119: */ }\r\n/* 120:138 */ if (i11 == 0) {\r\n/* 121: */ break;\r\n/* 122: */ }\r\n/* 123: */ }\r\n/* 124:142 */ i9++;\r\n/* 125: */ \r\n/* 126: */ \r\n/* 127:145 */ this.d[i6] = ((int)(0.5D + i9 * f1) + i5);\r\n/* 128: */ }\r\n/* 129: */ }", "public CopyOfPlayer(){ //Loads and scales the images\n for (int i = 0; i < robotImages.length; i++){\n for (int j = 0; j < black.length; j++){\n robotImages[i][j].scale(300, 300);\n }\n }\n costume = PrefLoader.getCostume(); //Sets costume according to file\n setImage(robotImages[costume][2]);\n }", "private static ArrayImg< UnsignedByteType, ByteArray > createLargeRectangularImage() {\n\t\tArrayImg< UnsignedByteType, ByteArray > img = ArrayImgs.unsignedBytes( 1024, 512 );\n\t\tfor ( int i = 0; i < 3; i++ ) {\n\t\t\tlong[] xmin = new long[] { 199 + i * 200, 0 };\n\t\t\tlong[] xmax = new long[] { 299 + i * 200, 511 };\n\t\t\tIntervalView< UnsignedByteType > iview = Views.interval( img, xmin, xmax );\n\t\t\tiview.forEach( pixel -> pixel.set( ( byte ) 255 ) );\n\t\t}\n\t\treturn img;\n\t}", "public BufferedImage SaveImage() {\n int x = 0, y = 0, w = subImageWidth, h = subImageHeight; // width is 8, height is 12\n\n try {\n for (int row = 0; row <= 15; row++) {\n System.out.println(\"row = \" + row);\n for (int column = 0; column <= 15; column++) // was column <= 15\n {\n System.out.println(\"column = \" + column + \", x = \" + x + \", y = \" + y);\n tileArray[row][column] = input.getSubimage(x, y, w, h);\n x = x + 8;\n\n }\n x = 0;\n y = y + 12;\n }\n return testImage = tileArray[7][7];\n } finally {\n }\n }", "@Test\n\tpublic void testImageFromPaintNet() throws IOException, URISyntaxException {\n\t\tfinal String filePath = \"img_orientation/view_20170929_124415.jpg\";\n\t\tURL url = this.getClass().getClassLoader().getResource(filePath);\n\t\tFile imgFile = new File(url.toURI());\n\t\tlogger.debug(\"File '{}' exists = {}\", filePath, imgFile.isFile());\n\t\tBufferedImage bi = TrpImageIO.read(imgFile);\n\t\t\n\t\tif(bi instanceof RotatedBufferedImage) {\n\t\t\t//if we are here this is broken\n\t\t\tAssert.fail(\"Image was erroneously rotated!\");\n\t\t}\n\t}", "void loadRainbow(int width, int height, boolean isHorizontal);", "static void processPicture(byte[][] img) {\n\t\tcontrastImage(img);\n\t\t//generateDebugImage(img);\n\t\t\n\t\t\n\t\tPoint[] ergs = raster(img);\n\t\tprintPoints(ergs);\n\t\tergs = Cluster.cluster(ergs);\n\t\tprintPoints(ergs);\n\t\tBlume[] blumen = Radiuserkennung.erkennen(img, ergs);\n\t\t\n\t\t//Blumen veröffentlichen!\n\t\tDaten.setNewBlumen(blumen);\n\t\t\n\t\tprintBlumen(blumen);\n\t}", "public void createTestPattern()\n {\n int i;\n int j;\n RGBPixel p = new RGBPixel();\n\n for ( i = 0; i < getXSize(); i++ ) {\n for ( j = 0; j < getYSize(); j++ ) {\n if ( ((i % 2 != 0) && (j % 2 == 0)) || \n ((j % 2 != 0) && (i % 2 == 0)) ) {\n p.r = (byte)255;\n p.g = (byte)255;\n p.b = (byte)255;\n }\n else {\n p.r = 0;\n p.g = 0;\n p.b = 0;\n }\n if ( j == getYSize()/2 ) {\n p.r = (byte)255;\n p.g = 0;\n p.b = 0;\n }\n if ( i == getXSize()/2) {\n p.r = 0;\n p.g = (byte)255;\n p.b = 0;\n }\n putPixelRgb(i, j, p);\n }\n }\n }", "public String printImage() {\n StringBuilder builder = new StringBuilder();\n builder.append(\"ID:\" + this.id + \"; Data:\\n\");\n\n for (int i = 1; i <= this.data.length; i++) {\n T t = data[i - 1];\n builder.append(t.toString() + \" \");\n if (i % 28 == 0) {\n builder.append(\"\\n\");\n }\n }\n return builder.toString().replace('0', ' ');\n }", "public void render () {\n image (img, xC, yC, xLength * getPixelSize(), yLength * getPixelSize());\n }", "void texImage2D(int target, int level, int resourceId, int border);", "public static void main(String[] args) {\n String filePath = \"C:\\\\Users\\\\nhern\\\\OneDrive\\\\Documentos\\\\POO\\\\hernandez.nicolas-diaz.matias-Proyecto\\\\QRScanner\\\\out\\\\qr_test.png\";\n QR.read_qr(filePath);\n }", "public void drawImage(float x, float y, float width, float height);", "public static void main(String[] args)\n {\n \n //opens selfie picture \n /**/ \n //relative path\n //og pics\n Picture apic = new Picture(\"images/selfie.jpg\");\n Picture obama = new Picture(\"images/obama.jpg\");\n apic.explore();\n obama.explore();\n\n //change with selfie picture\n Picture me = new Picture(\"images/selfie.jpg\"); \n Picture me1 = new Picture(\"images/selfie.jpg\");\n Picture me2 = new Picture(\"images/selfie.jpg\");\n \n //initializes array pix\n Pixel[] pix;\n \n /**\n * method 1 change\n * divides colors into 4 equal groups\n */\n //initializes vars for rgb values\n int red;\n int blue;\n int green;\n pix = me.getPixels(); \n \n for (Pixel spot: pix) {\n //gets rgb values of colors\n red = spot.getRed();\n blue = spot.getBlue();\n green = spot.getGreen();\n \n //if pixel under a certain value then the color is changed\n if (red < 63 && blue < 63 && green < 63) {\n spot.setColor(new Color(2, 32, 62));\n }\n else if (red < 127 && blue < 127 && green < 127) {\n spot.setColor(new Color(198, 37, 8));\n }\n else if (red < 191 && blue < 191 && green < 191) {\n spot.setColor(new Color(102, 157, 160));\n }\n else {\n spot.setColor(new Color(250, 238, 192));\n }\n }\n me.explore();\n me.write(\"images/selfie1.jpg\");\n\n /**\n * method 2 change\n * changes color based on intensity using max and min grayscale values\n */\n pix = me1.getPixels(); \n int s = 0; //smallest pix value\n int b = 255; //largest pix value\n int ave;\n int quads; //size of four equal range of colors\n \n for (Pixel spot: pix) {\n red = spot.getRed();\n blue = spot.getBlue();\n green = spot.getGreen();\n \n ave = (red + blue + green)/3;\n if (ave > b) { //gets maximum grayscale\n b = ave;\n }\n if (ave < s) { //gets min grayscale\n s = ave;\n }\n quads = (b-s)/4; //divides range of pix values into 4\n \n //sees if pixel value is less than the factor of quad\n if (red < quads && blue < quads && green < quads) {\n spot.setColor(new Color(2, 32, 62));\n }\n else if (red < quads*2 && blue < quads*2 && green < quads*2 ) {\n spot.setColor(new Color(198, 37, 8));\n }\n else if (red < quads*3 && blue < quads*3 && green < quads*3) {\n spot.setColor(new Color(102, 157, 160));\n }\n else {\n spot.setColor(new Color(250, 238, 192));\n }\n }\n me1.explore();\n me1.write(\"images/selfie2.jpg\");\n \n /**\n * custom color palette\n */\n pix = me2.getPixels();\n \n for (Pixel spot: pix) {\n red = spot.getRed();\n blue = spot.getBlue();\n green = spot.getGreen();\n \n //sets color to new value if under a certain value\n if (red < 63 && blue < 63 && green < 63) {\n spot.setColor(new Color(77, 105, 170));\n }\n else if (red < 127 && blue < 127 && green < 127) {\n spot.setColor(new Color(71, 183, 116));\n }\n else if (red < 191 && blue < 191 && green < 191) {\n spot.setColor(new Color(254, 129, 99));\n }\n else {\n spot.setColor(new Color(254, 202, 99));\n }\n }\n me2.explore();\n me2.write(\"images/selfie3.jpg\");\n \n }", "@Test public void testSingleEye_1() {\n testing(1, 1,\n \"◦●○◦◦◦◦◦◦\"\n + \"◦●○◦◦◦◦◦◦\"\n + \"◦●○◦◦◦◦◦◦\"\n + \"◦●○◦◦◦◦◦◦\"\n + \"●●○◦◦◦◦◦◦\"\n + \"○○○◦◦◦◦◦◦\"\n + \"◦◦◦◦◦◦◦◦◦\"\n + \"◦◦◦◦◦◦◦◦◦\"\n + \"◦◦◦◦◦◦◦◦◦\");\n }", "private static final byte[] xfj_d_image() {\n\t\tbyte data[] = { 71, 73, 70, 56, 57, 97, 16, 0, 16, 0, -29, 0, 0, 76,\n\t\t\t\t76, 76, 11, 11, 11, 7, 7, 7, -47, -47, -47, -1, -1, -1, -7, -7,\n\t\t\t\t-7, -128, -128, -128, 113, 113, 113, -1, -1, -1, -1, -1, -1,\n\t\t\t\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n\t\t\t\t-1, -1, 33, -2, 14, 77, 97, 100, 101, 32, 119, 105, 116, 104,\n\t\t\t\t32, 71, 73, 77, 80, 0, 33, -7, 4, 1, 10, 0, 8, 0, 44, 0, 0, 0,\n\t\t\t\t0, 16, 0, 16, 0, 0, 4, 93, 16, 73, 9, -24, -84, 51, 99, 84,\n\t\t\t\t119, -106, 1, 16, -124, -31, 7, 6, 2, -112, 10, -23, 24, 76,\n\t\t\t\t-63, 48, -90, -86, -8, 34, 119, 64, 12, -78, 27, -53, 56, 24,\n\t\t\t\t97, -57, -29, 13, 95, 55, 28, -95, 48, 100, 46, -111, -97, 0,\n\t\t\t\t115, 122, 76, 26, -82, -40, -31, 18, -104, -63, 94, -117, 50,\n\t\t\t\t-62, -31, 32, 41, 20, -68, -66, -27, -110, -116, -16, 26, -76,\n\t\t\t\t-50, -79, -28, -118, 56, 27, -118, 99, 118, -37, -48, -11, 125,\n\t\t\t\t-24, 38, -127, 17, 0, 59 };\n\t\treturn data;\n\t}", "void deriveImage()\n\t{\n\n\t\t//img = new BufferedImage(dimx, dimy, BufferedImage.TYPE_INT_ARGB);\n\t\timg = null;\n\t\ttry{\n\t\t\timg = ImageIO.read(new File(\"src/input/World.png\"));\n\n\t\t}catch (IOException e){\n\t\t\tSystem.out.println(\"world image file error\");\n\t\t}\n\t\t//System.out.println(img.getHeight());\n\t\t//System.out.println(img.getWidth());\n//\t\tfloat maxh = -10000.0f, minh = 10000.0f;\n//\n//\t\t// determine range of tempVals s\n//\t\tfor(int x=0; x < dimx; x++)\n//\t\t\tfor(int y=0; y < dimy; y++) {\n//\t\t\t\tfloat h = tempVals [x][y];\n//\t\t\t\tif(h > maxh)\n//\t\t\t\t\tmaxh = h;\n//\t\t\t\tif(h < minh)\n//\t\t\t\t\tminh = h;\n//\t\t\t}\n\t\t\n\t\tfor(int x=0; x < dimx; x++)\n\t\t\tfor(int y=0; y < dimy; y++) {\n\t\t\t\t \t\n\t\t\t\t// find normalized tempVals value in range\n\t\t\t\t//float val = (tempVals [x][y] - minh) / (maxh - minh);\n\t\t\t\tfloat val = tempVals[x][y];\n\n\t\t\t\t//System.out.println(val);\n\n\t\t\t\tColor c = new Color(img.getRGB(x,y));\n\n\t\t\t\tif((c.getRed() > 50 && c.getGreen() > 100 && c.getBlue() < 200)) {\n\n\t\t\t\t\tif (val != 0.0f) {\n\t\t\t\t\t\tColor col = new Color(val, 0, 0);\n\t\t\t\t\t\timg.setRGB(x, y, col.getRGB());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\n\t\t\t\n\t}", "public CaptureImage()\r\n\t{\r\n\t\tSystem.loadLibrary(Core.NATIVE_LIBRARY_NAME);\r\n\t\tcapturedFrame = new Mat();\r\n\t\tprocessedFrame = new Mat();\r\n\t\tboard = new byte[32];\r\n\t\tfor (int i=0;i<board.length;i++){\r\n\t\t\tboard[i] = 0;\r\n\t\t}\r\n\t\tcaptured = new byte[12];\r\n\t}", "public static void main (String[] args) throws FitsException, IOException, ClassNotFoundException {\n inFits = FileLoader.loadFits(ImageDataTest.class , fileName);\n frArray = FitsRead.createFitsReadArray(inFits);\n rangeValues = FitsRead.getDefaultRangeValues();\n ImageData imageData = new ImageData(frArray, IMAGE_TYPE,COLROID, rangeValues, 0,0, 100, 100, true );\n BufferedImage bufferedImage = imageData.getImage(frArray);\n File outputfile = new File(FileLoader.getDataPath(ImageDataTest.class)+\"imageDataTest.png\");\n ImageIO.write(bufferedImage, \"png\", outputfile);\n\n\n\n //test ImageData with mask\n imageData = new ImageData(frArray, IMAGE_TYPE,imageMasks,rangeValues, 0,0, 100, 100, true );\n bufferedImage = imageData.getImage(frArray);\n outputfile = new File(FileLoader.getDataPath(ImageDataTest.class)+\"imageDataWithMaskTest.png\");\n ImageIO.write(bufferedImage, \"png\", outputfile);\n\n }", "public static void main(String args[]) {\n\t\tint[][][] pic = read(\"tinypic.ppm\"); \n\t\tSystem.out.println(\"Standart pic \\n\"); // For a clean code\n\t\t// Displays the array's data on standard output\n\t\tprint(pic);\n\n\t\tSystem.out.println(\"flipHorizontally pic \\n\");\n\t\tprint(flipHorizontally(pic));\n\n\t\tSystem.out.println(\"flipVertically pic \\n\");\n\t\tprint(flipVertically(pic));\n\n\t\tSystem.out.println(\"greyScale pic \\n\");\n\t\tprint(greyScale(pic));\n\n\t}", "public void render(String filename) throws FileNotFoundException {\r\n int pix_h, pix_w;\r\n pix_h = (int) window.getPix_h();\r\n pix_w = (int) window.getPix_w();\r\n \r\n Pixel[][] grid = new Pixel[pix_h][pix_w];\r\n \r\n for(int i = 0; i < pix_h; i++) {\r\n for(int j = 0; j < pix_w; j++) {\r\n \r\n Point p = window.getDelta_h().const_mult(j).vec_add(window.getDelta_w().const_mult(i)).point_add(window.getUl());\r\n Vec d = p.point_sub(window.getEye()).normalize();\r\n Ray r = new Ray(d, window.getEye());\r\n Color c = ray_trace(r);\r\n \r\n grid[i][j] = new Pixel(p, c);\r\n }\r\n }\r\n \r\n try(\r\n PrintWriter toFile = new PrintWriter(filename);\r\n ){\r\n toFile.println(\"P3\");\r\n toFile.println(pix_w + \" \" + pix_h);\r\n toFile.println(255);\r\n \r\n for(int i = 0; i < pix_h; i++) {\r\n int k = 0;\r\n for(int j = 0; j < pix_w; j++) {\r\n if(k>10) {\r\n toFile.println();\r\n k = 0;\r\n }\r\n toFile.print(\r\n (int) Math.ceil(grid[i][j].getColor().getR()*255) + \" \" +\r\n (int) Math.ceil(grid[i][j].getColor().getG()*255) + \" \" +\r\n (int) Math.ceil(grid[i][j].getColor().getB()*255) + \" \");\r\n k++;\r\n }\r\n \r\n }\r\n \r\n }\r\n \r\n }", "public void showbitmap3() {\n \n \t}", "public void run() {\n System.out.print(Thread.currentThread().getId() + \"\\n\");\n try {\n try {\n File outfile = new File(dataPath + imageFile.getName().replace(\"jpg\", \"txt\"));\n if (outfile.exists()) {\n return;\n }\n String ms = \"nada\";\n records.write(\"<\");\n records.write(imageFile.getName() + \">\\n\");\n BufferedImage bin = ImageHelpers.readAsBufferedImage(imageFile.getAbsolutePath());\n bin = ImageHelpers.scale(bin, maxHeight);\n orig = ImageHelpers.readAsBufferedImage(imageFile.getAbsolutePath());\n orig = ImageHelpers.scale(orig, maxHeight);\n BufferedImage stored = cloneImage(ImageHelpers.scale(orig, maxHeight));\n BufferedImage copy = ImageHelpers.readAsBufferedImage(imageFile.getAbsolutePath());\n copy = ImageHelpers.scale(copy, maxHeight);\n records.flush();\n System.out.println(imageFile.getName());\n PlanarImage threshedImage = JAI.create(\"fileload\", imageFile.getAbsolutePath());\n BufferedImage ok = threshedImage.getAsBufferedImage();\n bin = ImageHelpers.scale(ImageHelpers.binaryThreshold(ok, 4), maxHeight);\n for (int i = 0; i < bin.getWidth(); i++) {\n for (int j = 0; j < bin.getHeight(); j++) {\n orig.setRGB(i, j, -1);\n }\n }\n Boolean doBlobExtract = true;\n if (doBlobExtract) {\n for (int i = 0; i < bin.getWidth(); i++) {\n for (int j = 0; j < bin.getHeight(); j++) {\n orig.setRGB(i, j, -1);\n }\n }\n //ImageHelpers.writeImage(bin, \"/usr/web/broken/\" + imageFile.getName() + \"bin\" + \".jpg\");\n Vector<blob> blobs = new Vector<blob>();\n for (int i = 0; i < bin.getWidth(); i++) {\n for (int j = 0; j < bin.getHeight(); j++) {\n if (bin.getRGB(i, j) != -1) {\n blob thisOne = new blob(i, j);\n thisOne.copy = orig;\n if (blobs.size() % 3 == 0) {\n thisOne.color = 0xcc0000;\n }\n if (blobs.size() % 3 == 1) {\n thisOne.color = 0x000099;\n }\n if (blobs.size() % 3 == 2) {\n thisOne.color = 0x006600;\n }\n thisOne.count(bin, thisOne.getX(), thisOne.getY());\n if (thisOne.size > 5) {\n blobs.add(thisOne);\n if ((thisOne.getSize() - (thisOne.getSize() % 10)) != 5000 && (thisOne.getSize() - (thisOne.getSize() % 10)) != 0) {\n\n thisOne.calculateRelativeCoordinates();\n thisOne.drawBlob(orig, thisOne.color);\n\n }\n }\n }\n }\n }\n BufferedWriter blobWriter = new BufferedWriter(new FileWriter(outfile));\n\n int ctr = 1;\n for (int i = 0; i < blobs.size(); i++) {\n if ((blobs.get(i).size < 4000)) {\n try {\n blobs.get(i).id = ctr;\n ctr++;\n //blobs.get(i).color=0x000000;\n blobs.get(i).arrayVersion = blobs.get(i).pixels.toArray(new pixel[blobs.get(i).pixels.size()]);\n int maxX = 0;\n for (int k = 0; k < blobs.get(i).arrayVersion.length; k++) {\n if (blobs.get(i).arrayVersion[k].x > maxX) {\n maxX = blobs.get(i).arrayVersion[k].x;\n }\n }\n blobs.get(i).width = maxX;\n int maxY = 0;\n for (int k = 0; k < blobs.get(i).arrayVersion.length; k++) {\n if (blobs.get(i).arrayVersion[k].y > maxY) {\n maxY = blobs.get(i).arrayVersion[k].y;\n }\n }\n blobs.get(i).height = maxY;\n\n\n blobs.get(i).matrixVersion = new matrixBlob(blobs.get(i));\n } catch (Exception e) {\n e.printStackTrace();\n }\n // blob.writeBlob(blobWriter, blobs.get(i));\n blob.writeMatrixBlob(blobWriter, blobs.get(i));\n blobs.set(i, null);//.matrixVersion=null;\n //blobs.get(i).arrayVersion=null;\n // blob.writeBlob(blobWriter, blobs.get(i));\n //blob.drawBlob(orig, blobs.get(i).x, blobs.get(i).y, blobs.get(i), 0x000000);\n }\n }\n System.out.print(\"found \" + ctr + \" blobs\\n\");\n\n }\n\n try {\n\n\n if (!doBlobExtract) {\n orig = bin;\n }\n //ImageHelpers.writeImage(orig, \"/usr/web/broken/\" + imageFile.getName() + \"broken\" + \".jpg\");\n\n Vector<line> lines = new Vector();\n createViewableVerticalProfile(orig, imageFile.getName(), lines);\n //ImageHelpers.writeImage(ImageHelpers.createViewableVerticalProfile(orig, imageFile.getName(), lines), \"/usr/web/broken/profile\" + imageFile.getName() + \"broken\" + \".jpg\");\n FileWriter writer = null;\n //writer = new FileWriter(new File(\"/usr/web/queries/\" + imageFile.getName() + \"\"));\n orig = ImageHelpers.scale(orig, 1000);\n Detector d = new Detector(orig, orig);\n if (lines.size() > 3) {\n lines = new Vector();\n lines.add(new line());\n lines.get(0).setStartHorizontal(0);\n lines.get(0).setStartVertical(0);\n lines.get(0).setWidth(orig.getWidth());\n lines.get(0).setDistance(maxHeight);\n }\n //d.detect();\n for (int i = 0; i < lines.size(); i++) {\n line col = lines.get(i);\n BufferedImage storedBin = ImageHelpers.binaryThreshold(stored, 4);\n BufferedImage colOnly = storedBin.getSubimage(col.getStartHorizontal(), col.getStartVertical(), col.getWidth(), col.getDistance());\n d = new Detector(colOnly, colOnly);\n d.debugLabel = imageFile.getName();\n d.forceSingle = true;\n d.detect();\n System.out.print(\"total lines in col is \" + d.lines.size() + \"\\n\");\n for (int j = 0; j < d.lines.size(); j++) {\n line r = d.lines.get(j);\n r.setStartHorizontal(r.getStartHorizontal() + col.getStartHorizontal());\n r.setStartVertical(r.getStartVertical() + col.getStartVertical());\n //r.commitQuery(writer, imageFile.getName());\n if (j % 2 == 1) {\n int color = 0x0000ff;\n stored = highlightBlock(stored, r.getStartHorizontal(), r.getStartVertical() - r.getDistance(), r.getDistance(), r.getWidth(), color);\n } else {\n int color = 0xff0000;\n stored = highlightBlock(stored, r.getStartHorizontal(), r.getStartVertical() - r.getDistance(), r.getDistance(), r.getWidth(), color);\n }\n }\n }\n //ImageHelpers.writeImage(stored, \"\" + \"/usr/web/processed/\" + imageFile.getName());\n\n\n\n //writer.close();\n } catch (Exception e) {\n e.printStackTrace();\n }\n } catch (IOException ex) {\n System.out.print(ex.getMessage() + \"\\n\");\n }\n } catch (Exception e) {\n e.printStackTrace();\n }\n return;\n }", "BufferedImage getImage();", "BufferedImage getImage();", "BufferedImage getImage();", "public int getImage();", "public String toString() {\n/* 6387 */ return \"VolaTile [X: \" + this.tilex + \", Y: \" + this.tiley + \", surf=\" + this.surfaced + \"]\";\n/* */ }", "private static BufferedImage writeEdges(byte pixels[],int width,int height) {\n\t\tBufferedImage edgesImage=null;\n\t\tedgesImage = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);\n\t\t\n\t\t////System.out.println(\"pixels size is \"+pixels.length);\n\t\tedgesImage.getWritableTile(0, 0).setDataElements(0, 0, width, height, pixels);\n\t\t\n\t\treturn edgesImage;\n\t\t\n\t\t/*int xx=0;\n\t\tfor(int p:pixels){\n\t\t\txx++;\n\t\t\t//System.out.print(p);\n\t\t\tif(xx%180==0)\n\t\t\t\t//System.out.println();\n\t\t}*/\n\t\t\n\t\t////System.out.println(\"size is \"+pixels.length);\n\t}", "@Override\n\tpublic void carregar() {\n\t\tSystem.out.println(\"carregar imagem png\");\n\t\t\n\t}", "public static void main(String[] args) throws IOException {\n\t\tInputStream in = new FileInputStream(\"bitmap.inp\");\r\n\t\t//Scanner sc = new Scanner(in);\r\n\t\t\r\n\t\tFileWriter fw = new FileWriter(\"bitmap.out\");\r\n\t\tPrintWriter pw = new PrintWriter(fw);\r\n\r\n\t\tchar type;\r\n\t int numRows, numCols;\r\n\t \r\n\t type=(char) in.read();\r\n\t System.out.println(type);\r\n\t in.read();\r\n\t numRows=in.read()-48;\r\n\t System.out.println(numRows);\r\n\t in.read();\r\n\t numCols=in.read()-48;\r\n\t System.out.println(numCols);\r\n\t}", "public static void load(){\n\t\trobot=new BufferedImage[5];\n\t\ttry {\n\t\t\tfor(int i=0;i<5;i++)\n\t\t\t\trobot[i]=ImageIO.read(new File(\"robot\" + i +\".png\"));\n\t\t\t\n\t\t\tminiRobot=ImageIO.read(new File(\"miniRobot.png\"));\n\t\t\toil=ImageIO.read(new File(\"oil.png\"));\n\t\t\tslime=ImageIO.read(new File(\"slime.png\"));\n\t\t\tmap=ImageIO.read(new File(\"map.png\"));\n\t\t} catch (IOException e) {\n\t\t\tSystem.out.println(e + \"Failed to load images\");\n\t\t\tSystem.exit(1);\n\t\t}\n\t}", "private void takeScreenshot()\n\t\t{\n\t\t\tint width = getWidth();\n\t\t\tint height = getHeight();\n\t\t\tint capacity = width * height;\n\t\t\tint[] dataArray = new int[capacity];\n\t\t\tIntBuffer dataBuffer = IntBuffer.allocate(capacity);\n\t\t\tGLES20.glReadPixels(0, 0, width, height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, dataBuffer);\n\t\t\tint[] dataArrayTemp = dataBuffer.array();\n\n\t\t\t// Flip the mirrored image.\n\t\t\tfor (int y = 0; y < height; y++)\n\t\t\t{\n\t\t\t\tSystem.arraycopy(dataArrayTemp, y * width, dataArray, (height - y - 1) * width, width);\n\t\t\t}\n\n\t\t\tBitmap screenshot = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);\n\t\t\tscreenshot.copyPixelsFromBuffer(IntBuffer.wrap(dataArray));\n\t\t\tBitmap thumbnail = Bitmap.createScaledBitmap(screenshot, width / THUMBNAIL_SHRINKING_FACTOR, height / THUMBNAIL_SHRINKING_FACTOR, true);\n\t\t\tproject.getSheetAt(screenshotSheetIndex).saveThumbnail(thumbnail);\n\t\t\tBitmapDrawable thumbnailDrawable = new BitmapDrawable(getResources(), thumbnail);\n\t\t\tproject.getSheetAt(screenshotSheetIndex).setThumbnail(thumbnailDrawable);\n\n\t\t\t// Refresh the sheet panel if the user is not requesting an exit.\n\t\t\tif (activity.taskRequested != NotepadActivity.TASK_EXIT)\n\t\t\t{\n\t\t\t\tactivity.refreshSheetDrawerAfterGeneratingThumbnail();\n\t\t\t}\n\n\t\t\t// The project thumbnail should be twice the width and height of a sheet thumbnail.\n\t\t\tBitmap projectThumbnail = Bitmap.createScaledBitmap(\n\t\t\t\t\tscreenshot, (width * 2) / THUMBNAIL_SHRINKING_FACTOR, (height * 2) / THUMBNAIL_SHRINKING_FACTOR, true);\n\t\t\tproject.saveThumbnail(projectThumbnail);\n\n\t\t\tif (activity.taskRequested > 0)\n\t\t\t{\n\t\t\t\tpost(new Runnable()\n\t\t\t\t{\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void run()\n\t\t\t\t\t{\n\t\t\t\t\t\tactivity.performTask();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}", "public void draw() {\n PImage grid = loadImage(\"C:/Users/NM/Desktop/UNI_ACAD/INFO1113/Assignment2/Atomination/assets/tile.png\");\n for(int i = 0 ; i < 10 ; i++){\n for(int j = 0 ; j < 6 ; j++){\n image(grid, i*grid.width, j*grid.height);\n if(gridPlane.get(List.of(i, j)).getOwner() != null){\n if(gridPlane.get(List.of(i, j)).getOwner().getColor().equals(\"Red\")){\n if(gridPlane.get(List.of(i, j)).getAtomCount() == 1){\n image(loadImage(\"C:/Users/NM/Desktop/UNI_ACAD/INFO1113/Assignment2/Atomination/assets/red1.png\"), i*grid.width, j*grid.height);\n }else if(gridPlane.get(List.of(i, j)).getAtomCount() == 2){\n image(loadImage(\"C:/Users/NM/Desktop/UNI_ACAD/INFO1113/Assignment2/Atomination/assets/red2.png\"), i*grid.width, j*grid.height);\n }else if(gridPlane.get(List.of(i, j)).getAtomCount() == 3){\n image(loadImage(\"C:/Users/NM/Desktop/UNI_ACAD/INFO1113/Assignment2/Atomination/assets/red3.png\"), i*grid.width, j*grid.height);\n }\n }else if(gridPlane.get(List.of(i, j)).getOwner().getColor().equals(\"Green\")){\n if(gridPlane.get(List.of(i, j)).getAtomCount() == 1){\n image(loadImage(\"C:/Users/NM/Desktop/UNI_ACAD/INFO1113/Assignment2/Atomination/assets/green1.png\"), i*grid.width, j*grid.height);\n }else if(gridPlane.get(List.of(i, j)).getAtomCount() == 2){\n image(loadImage(\"C:/Users/NM/Desktop/UNI_ACAD/INFO1113/Assignment2/Atomination/assets/green2.png\"), i*grid.width, j*grid.height);\n }else if(gridPlane.get(List.of(i, j)).getAtomCount() == 3){\n image(loadImage(\"C:/Users/NM/Desktop/UNI_ACAD/INFO1113/Assignment2/Atomination/assets/green3.png\"), i*grid.width, j*grid.height);\n }\n }\n }\n }\n }\n if(this.finish == true){\n System.exit(0);\n }\n }", "@Override\n public String exportImage() throws IllegalArgumentException {\n BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);\n for (int x = 0; x < this.width; x++) {\n for (int y = 0; y < this.height; y++) {\n int r = this.pixels[x][y][0];\n int g = this.pixels[x][y][1];\n int b = this.pixels[x][y][2];\n int color = (r << 16) | (g << 8) | b;\n img.setRGB(x, y, color);\n }\n }\n return exportHelp(img);\n }", "SurfaceTexture mo17006a();", "void greyscale();", "void greyscale();", "public void init241()\n {\n\t \twidth= p2[21]<<24 | p2[20]<<16 | p2[19]<<8 | p2[18];\n\n\n\n\t\theight= p2[25]<<24 | p2[24]<<16 | p2[23]<<8 | p2[22];\n\n\n\t\tint extra=(width*3)%4;\n \tif(extra!=0)\n \tpadding=4-extra;\n int x,z=54;\n l=0;\n int j=0;\n i=0;\n for(int q=0;q<height;q++)\n {\n x=0;\n \t while(x<width)\n \t{\n \t b=p2[z]&0xff;\n binary[j++]=b&0x01;\n g=p2[z+1]&0xff;\n binary[j++]=g&0x01;\n \t r=p2[z+2]&0xff;\n binary[j++]=r&0x01;\n \t pix[l]= 255<<24 | r<<16 | g<<8 | b;\n z=z+3;\n x++;\n \t l++;\n }\n z=z+padding;\n }\n int k;\n x=0;\n stringcon();\n\n\n\tfor(i=l-width;i>=0;i=i-width)\n\t{\n\t\tfor(k=0;k<width;k++)\n\t\t{\n\t\tpixels[x]=pix[i+k];\n// pixels1[x]=pix[i+k];\n\t\tx++;\n\t\t}\n\t}\n}", "public void printTexture(Graphics2D bg) {\n\r\n\t\tbg.setColor(Color.RED);\r\n\t\tbg.setStroke(new BasicStroke(0.1f));\r\n\r\n\t\t//lower base\r\n\t\tprintTextureLine(bg,0,1);\r\n\t\tprintTextureLine(bg,1,2);\r\n\t\tprintTextureLine(bg,2,3);\r\n\t\tprintTextureLine(bg,3,4);\r\n\t\tprintTextureLine(bg,4,5);\r\n\t\tprintTextureLine(bg,5,0);\r\n\r\n\t\t//lateral faces\r\n\t\tbg.setColor(Color.BLACK);\r\n\t\tprintTextureLine(bg,6,7);\r\n\t\tprintTextureLine(bg,7,14);\r\n\t\tprintTextureLine(bg,14,13);\r\n\t\tprintTextureLine(bg,13,6);\r\n\t\t\r\n\t\tprintTextureLine(bg,7,8);\r\n\t\tprintTextureLine(bg,8,15);\r\n\t\tprintTextureLine(bg,15,14);\r\n\t\t\r\n\t\tprintTextureLine(bg,8,9);\r\n\t\tprintTextureLine(bg,9,16);\r\n\t\tprintTextureLine(bg,16,15);\r\n\t\t\r\n\t\tprintTextureLine(bg,9,10);\r\n\t\tprintTextureLine(bg,10,17);\r\n\t\tprintTextureLine(bg,17,16);\r\n\t\t\r\n\t\tprintTextureLine(bg,10,11);\r\n\t\tprintTextureLine(bg,11,18);\r\n\t\tprintTextureLine(bg,18,17);\r\n\t\t\r\n\t\tprintTextureLine(bg,11,12);\r\n\t\tprintTextureLine(bg,12,19);\r\n\t\tprintTextureLine(bg,19,18);\r\n\t\r\n\t\t//gables\r\n\t\tbg.setColor(Color.BLUE);\r\n\r\n\t\tprintTextureLine(bg,13,14);\r\n\t\tprintTextureLine(bg,14,20);\r\n\t\tprintTextureLine(bg,20,13);\r\n\t\t\r\n\t\tprintTextureLine(bg,16,17);\r\n\t\tprintTextureLine(bg,17,21);\r\n\t\tprintTextureLine(bg,21,16);\r\n\t\t\r\n\r\n\t\t//roof\r\n\t\tbg.setColor(Color.RED);\r\n\t\tprintTexturePolygon(bg,22,23,28,25);\r\n\t\t\r\n\t\tprintTexturePolygon(bg,23,24,26,28);\r\n\t\tprintTexturePolygon(bg,26,27,29,28);\r\n\t\tprintTexturePolygon(bg,28,29,31,30);\r\n\t\tprintTexturePolygon(bg,30,25,28);\r\n\r\n\t}", "public byte[] readImagePNG(BufferedImage bufferedimage) throws IOException{\n byte[] data = ImageUtil.toByteArray(bufferedimage);\r\n /* \r\n for (int i = 0; i < data.length; i++) {\r\n if(i!=0&&i%4==0)\r\n System.out.println();\r\n System.out.format(\"%02X \",data[i]);\r\n }\r\n */ \r\n \r\n \r\n \r\n \r\n byte[] stximage = getStximage();\r\n byte[] etximage = getEtximage();\r\n \r\n byte[] stxdata = new byte[stximage.length];\r\n byte[] etxdata = new byte[etximage.length];\r\n byte[] length = new byte[4];\r\n \r\n boolean stxsw=false;\r\n boolean etxsw=false;\r\n byte[] full_data=null;\r\n byte[] only_data=null;\r\n try{\r\n for (int i = 0; i < data.length; i++) {\r\n System.arraycopy(data, i, stxdata,0, stxdata.length);\r\n stxsw = ByteUtil.equals(stximage, stxdata);\r\n int subindex=i+stxdata.length;\r\n if(stxsw){\r\n System.arraycopy(data, subindex, length,0, length.length);\r\n int length_fulldata = ConversionUtil.toInt(length);\r\n // System.out.format(\"%02X %d subIndex[%d]\",data[subindex],length_fulldata,subindex);\r\n \r\n \r\n subindex+=i+length.length;\r\n int etx_index= subindex+ length_fulldata;\r\n // System.out.println(\"subindex : \"+subindex+\" etx_index : \"+etx_index);\r\n System.arraycopy(data, etx_index, etxdata,0, etxdata.length);\r\n \r\n// for (int j = 0; j < etxdata.length; j++) {\r\n// System.out.format(\"%02X \",etxdata[j]);\r\n// }\r\n \r\n etxsw = ByteUtil.equals(etximage, etxdata);\r\n if(etxsw){\r\n full_data = new byte[etx_index-subindex];\r\n System.arraycopy(data, subindex, full_data,0, full_data.length); //fulldata\r\n break;\r\n }else{\r\n continue;\r\n }\r\n }\r\n \r\n \r\n }\r\n \r\n /////only data search\r\n System.arraycopy(full_data, 0, length,0, length.length);\r\n int length_onlydata = ConversionUtil.toInt(length); \r\n only_data = new byte[length_onlydata];\r\n System.arraycopy(full_data, length.length, only_data,0, only_data.length);\r\n \r\n \r\n \r\n }catch (Exception e) {\r\n return null;\r\n }\r\n \r\n return only_data;\r\n \r\n }", "private void setPixels() {\n\t\t\tfinal byte[] dest = new byte[(int) (getMetadata().get(0).getAxisLength(\n\t\t\t\tAxes.X) * getMetadata().get(0).getAxisLength(Axes.Y))];\n\t\t\tlong lastImage = -1;\n\n\t\t\t// fill in starting image contents based on last image's dispose\n\t\t\t// code\n\t\t\tif (getMetadata().getLastDispose() > 0) {\n\t\t\t\tif (getMetadata().getLastDispose() == 3) { // use image before last\n\t\t\t\t\tfinal long n = getMetadata().get(0).getPlaneCount() - 2;\n\t\t\t\t\tif (n > 0) lastImage = n - 1;\n\t\t\t\t}\n\n\t\t\t\tif (lastImage != -1) {\n\t\t\t\t\tfinal byte[] prev = getMetadata().getImages().get((int) lastImage);\n\t\t\t\t\tSystem.arraycopy(prev, 0, dest, 0, (int) (getMetadata().get(0)\n\t\t\t\t\t\t.getAxisLength(Axes.X) * getMetadata().get(0).getAxisLength(\n\t\t\t\t\t\t\tAxes.Y)));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// copy each source line to the appropriate place in the destination\n\n\t\t\tint pass = 1;\n\t\t\tint inc = 8;\n\t\t\tint iline = 0;\n\t\t\tfor (int i = 0; i < getMetadata().getIh(); i++) {\n\t\t\t\tint line = i;\n\t\t\t\tif (getMetadata().isInterlace()) {\n\t\t\t\t\tif (iline >= getMetadata().getIh()) {\n\t\t\t\t\t\tpass++;\n\t\t\t\t\t\tswitch (pass) {\n\t\t\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\t\tiline = 4;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 3:\n\t\t\t\t\t\t\t\tiline = 2;\n\t\t\t\t\t\t\t\tinc = 4;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 4:\n\t\t\t\t\t\t\t\tiline = 1;\n\t\t\t\t\t\t\t\tinc = 2;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tline = iline;\n\t\t\t\t\tiline += inc;\n\t\t\t\t}\n\t\t\t\tline += getMetadata().getIy();\n\t\t\t\tif (line < getMetadata().get(0).getAxisLength(Axes.Y)) {\n\t\t\t\t\tfinal int k = line * (int) getMetadata().get(0).getAxisLength(Axes.X);\n\t\t\t\t\tint dx = k + getMetadata().getIx(); // start of line in dest\n\t\t\t\t\tint dlim = dx + getMetadata().getIw(); // end of dest line\n\t\t\t\t\tif ((k + getMetadata().get(0).getAxisLength(Axes.X)) < dlim) dlim =\n\t\t\t\t\t\tk + (int) getMetadata().get(0).getAxisLength(Axes.X);\n\t\t\t\t\tint sx = i * getMetadata().getIw(); // start of line in\n\t\t\t\t\t// source\n\t\t\t\t\twhile (dx < dlim) {\n\t\t\t\t\t\t// map color and insert in destination\n\t\t\t\t\t\tfinal int index = getMetadata().getPixels()[sx++] & 0xff;\n\t\t\t\t\t\tdest[dx++] = (byte) index;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tgetMetadata().getColorTables().add(getMetadata().getAct());\n\t\t\tgetMetadata().getImages().add(dest);\n\t\t}", "private static final byte[] xfmt_d_image() {\n\t\tbyte data[] = { 71, 73, 70, 56, 57, 97, 16, 0, 16, 0, -94, 1, 0, 0, 0,\n\t\t\t\t0, -1, -1, -1, 28, 28, 28, -128, -128, -128, -64, -64, -64, -1,\n\t\t\t\t-1, -1, 0, 0, 0, 0, 0, 0, 33, -7, 4, 1, 0, 0, 1, 0, 44, 0, 0,\n\t\t\t\t0, 0, 16, 0, 16, 0, 0, 3, 62, 24, -70, -36, 59, 48, 74, -8,\n\t\t\t\t-118, -67, -40, 2, 53, 10, -8, 32, -40, 109, -63, 40, -100,\n\t\t\t\t-24, 57, 114, -98, 80, -92, -86, -57, 2, 48, -70, -106, 109,\n\t\t\t\t45, -36, -90, -50, -25, -75, 31, 96, 34, -111, -31, 50, 72, 82,\n\t\t\t\t32, -60, 4, 57, 58, 23, -62, 64, -71, 104, 54, 29, -40, 70, 2,\n\t\t\t\t0, 59 };\n\t\treturn data;\n\t}", "public static void main(String args[]) throws IOException {\r\n\t\t\r\n\r\n// /**Any -> TXT **/\r\n//\t\t\r\n//\t\tgetTXTfromAny(\"./images/DJI_0707.txt\");\r\n//\t\tgetTXTfromAny(\"./images/DJI_0708.txt\");\r\n//\t\tgetTXTfromAny(\"./images/DJI_0709.txt\");\r\n//\t\tgetTXTfromAny(\"./images/DJI_0710.txt\");\r\n//\t\tgetTXTfromAny(\"./images/DJI_0711.txt\");\r\n//\t\tgetTXTfromAny(\"./images/DJI_0712.txt\");\r\n\t\t\r\n\t\t/**Any -> BMP **/\r\n//\t\tgetBMPfromAny(\"./images/DJI_0707.JPG\");\r\n//\t\tgetBMPfromAny(\"./images/DJI_0708.JPG\");\r\n//\t\tgetBMPfromAny(\"./images/DJI_0709.JPG\");\r\n//\t\tgetBMPfromAny(\"./images/DJI_0710.JPG\");\r\n//\t\tgetBMPfromAny(\"./images/DJI_0711.JPG\");\r\n//\t\tgetBMPfromAny(\"./images/DJI_0712.JPG\");\r\n\t\t\r\n//\t\t/**Any -> JPG **/\r\n\t\tgetJPGfromAny(\"./images/DJI_0707.txt\");\r\n\t\tgetJPGfromAny(\"./images/DJI_0708.txt\");\r\n\t\tgetJPGfromAny(\"./images/DJI_0709.txt\");\r\n\t\tgetJPGfromAny(\"./images/DJI_0710.txt\");\r\n\t\tgetJPGfromAny(\"./images/DJI_0711.txt\");\r\n\t\tgetJPGfromAny(\"./images/DJI_0712.txt\");\r\n\r\n\t}", "public void run(String[] args) {\n if (args.length == 0){\n System.out.println(\"Not enough parameters!\");\n System.out.println(\"Program Arguments: [image_path]\");\n System.exit(-1);\n }\n\n // Load the image\n Mat src = Imgcodecs.imread(args[0]);\n\n // Check if image is loaded fine\n if( src.empty() ) {\n System.out.println(\"Error opening image: \" + args[0]);\n System.exit(-1);\n }\n\n // Show source image\n HighGui.imshow(\"src\", src);\n //! [load_image]\n\n //! [gray]\n // Transform source image to gray if it is not already\n Mat gray = new Mat();\n\n if (src.channels() == 3)\n {\n Imgproc.cvtColor(src, gray, Imgproc.COLOR_BGR2GRAY);\n }\n else\n {\n gray = src;\n }\n\n // Show gray image\n showWaitDestroy(\"gray\" , gray);\n //! [gray]\n\n //! [bin]\n // Apply adaptiveThreshold at the bitwise_not of gray\n Mat bw = new Mat();\n Core.bitwise_not(gray, gray);\n Imgproc.adaptiveThreshold(gray, bw, 255, Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY, 15, -2);\n\n // Show binary image\n showWaitDestroy(\"binary\" , bw);\n //! [bin]\n\n //! [init]\n // Create the images that will use to extract the horizontal and vertical lines\n Mat horizontal = bw.clone();\n Mat vertical = bw.clone();\n //! [init]\n\n //! [horiz]\n // Specify size on horizontal axis\n int horizontal_size = horizontal.cols() / 30;\n\n // Create structure element for extracting horizontal lines through morphology operations\n Mat horizontalStructure = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(horizontal_size,1));\n\n // Apply morphology operations\n Imgproc.erode(horizontal, horizontal, horizontalStructure);\n Imgproc.dilate(horizontal, horizontal, horizontalStructure);\n\n // Show extracted horizontal lines\n showWaitDestroy(\"horizontal\" , horizontal);\n //! [horiz]\n\n //! [vert]\n // Specify size on vertical axis\n int vertical_size = vertical.rows() / 30;\n\n // Create structure element for extracting vertical lines through morphology operations\n Mat verticalStructure = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size( 1,vertical_size));\n\n // Apply morphology operations\n Imgproc.erode(vertical, vertical, verticalStructure);\n Imgproc.dilate(vertical, vertical, verticalStructure);\n\n // Show extracted vertical lines\n showWaitDestroy(\"vertical\", vertical);\n //! [vert]\n\n //! [smooth]\n // Inverse vertical image\n Core.bitwise_not(vertical, vertical);\n showWaitDestroy(\"vertical_bit\" , vertical);\n\n // Extract edges and smooth image according to the logic\n // 1. extract edges\n // 2. dilate(edges)\n // 3. src.copyTo(smooth)\n // 4. blur smooth img\n // 5. smooth.copyTo(src, edges)\n\n // Step 1\n Mat edges = new Mat();\n Imgproc.adaptiveThreshold(vertical, edges, 255, Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY, 3, -2);\n showWaitDestroy(\"edges\", edges);\n\n // Step 2\n Mat kernel = Mat.ones(2, 2, CvType.CV_8UC1);\n Imgproc.dilate(edges, edges, kernel);\n showWaitDestroy(\"dilate\", edges);\n\n // Step 3\n Mat smooth = new Mat();\n vertical.copyTo(smooth);\n\n // Step 4\n Imgproc.blur(smooth, smooth, new Size(2, 2));\n\n // Step 5\n smooth.copyTo(vertical, edges);\n\n // Show final result\n showWaitDestroy(\"smooth - final\", vertical);\n //! [smooth]\n\n System.exit(0);\n }", "public static void testDecodePicture(){\n\t Picture wall = new Picture(\"wall.jpg\");\n\t Picture caterpillar = new Picture(\"caterpillar.jpg\");\n\t wall.hidePicture(caterpillar);\n\t wall.explore();\n\t wall.decodePicture();\n\t wall.explore();\n }", "public Wall()\n {\n GreenfootImage img = this.getImage();\n img.scale(64, 64);\n \n }", "private static void readJPG(DataInputStream dis, int length){ \n\t\ttry{\n\t\t\tbyte[] arrBytes= new byte[length];\n\t\t\tfor(int i= 0; i<length;i++){\n\t\t\t\tarrBytes[i] = dis.readByte();\n\t\t\t}\n\t\t\tBufferedImage img = ImageIO.read(new ByteArrayInputStream(arrBytes));\n\t\t\tobjWriter.addFrame(1.0f/4.0f, img, 1.0f);\n\t\t\timageCount++;\n\t\t\t// Printing Image count for fun so that you don't get bored. :-P\n\t\t\tSystem.out.print(imageCount +\"\\t\");\n\t\t\tif(imageCount % 10 == 0){\n\t\t\t\tSystem.out.println(\"\");\n\t\t\t}\n\t\t}catch(Exception e){e.printStackTrace();}\n\t}", "SurfaceTexture mo17015a();", "@Override\n \tpublic Object[] getImageArray() {\n \t\t// Release 3 times an RGB stack with this dimensions.\n \t\tlayers.get(0).getProject().getLoader().releaseToFit((long)(getSize() * getWidth() * getHeight() * 4 * 3));\n \t\tfinal Object[] ia = new Object[getSize()];\n \t\tfor (int i=0; i<ia.length; i++) {\n \t\t\tia[i] = getProcessor(i+1).getPixels(); // slices 1<=slice<=n_slices\n \t\t}\n \t\treturn ia;\n \t}", "void nikon_e900_load_raw()\n{\n int offset=0, irow, row, col;\n\n for (irow=0; irow < height; irow++) {\n row = irow * 2 % height;\n if (row == 1)\n offset = - (-offset & -4096);\n CTOJ.fseek (ifp, offset, CTOJ.SEEK_SET);\n offset += raw_width;\n getbits(-1);\n for (col=0; col < width; col++)\n BAYER(row,col, (short)getbits(10));\n }\n}", "private void updateImage() {\r\n \tfor(int i=0;i<rows;i++){\r\n for(int j=0;j<cols;j++){\r\n if(complexArray[i][j].escapeTime(RADIUS, maxIterations)!=-1){//the complex escaped\r\n mandelbrotColor[i][j]=new RGBColor(palette[complexArray[i][j].escapeTime(RADIUS, maxIterations)]);\r\n }\r\n else{\r\n mandelbrotColor[i][j]=palette[complexArray[i][j].escapeTime(RADIUS, maxIterations)+1];//the complex didnt escaped\r\n }\r\n }\r\n }\r\n }", "private PImage createBG() {\n\t\tPImage image = new PImage(64, 64);\n\t\timage.copy(Textures.get(\"gui.box_black_red_tl\"), 0, 0, 16, 16, 0, 0, 16, 16);\n\t\timage.copy(Textures.get(\"gui.box_black_red_tm\"), 0, 0, 16, 16, 16, 0, 16, 16);\n\t\timage.copy(Textures.get(\"gui.box_black_red_tm\"), 0, 0, 16, 16, 32, 0, 16, 16);\n\t\timage.copy(Textures.get(\"gui.box_black_red_tr\"), 0, 0, 16, 16, 48, 0, 16, 16);\n\t\timage.copy(Textures.get(\"gui.box_black_red_ml\"), 0, 0, 16, 16, 0, 16, 16, 16);\n\t\timage.copy(Textures.get(\"gui.box_black_red_mm\"), 0, 0, 16, 16, 16, 16, 16, 16);\n\t\timage.copy(Textures.get(\"gui.box_black_red_mm\"), 0, 0, 16, 16, 32, 16, 16, 16);\n\t\timage.copy(Textures.get(\"gui.box_black_red_mr\"), 0, 0, 16, 16, 48, 16, 16, 16);\n\t\timage.copy(Textures.get(\"gui.box_black_red_ml\"), 0, 0, 16, 16, 0, 32, 16, 16);\n\t\timage.copy(Textures.get(\"gui.box_black_red_mm\"), 0, 0, 16, 16, 16, 32, 16, 16);\n\t\timage.copy(Textures.get(\"gui.box_black_red_mm\"), 0, 0, 16, 16, 32, 32, 16, 16);\n\t\timage.copy(Textures.get(\"gui.box_black_red_mr\"), 0, 0, 16, 16, 48, 32, 16, 16);\n\t\timage.copy(Textures.get(\"gui.box_black_red_bl\"), 0, 0, 16, 16, 0, 48, 16, 16);\n\t\timage.copy(Textures.get(\"gui.box_black_red_bm\"), 0, 0, 16, 16, 16, 48, 16, 16);\n\t\timage.copy(Textures.get(\"gui.box_black_red_bm\"), 0, 0, 16, 16, 32, 48, 16, 16);\n\t\timage.copy(Textures.get(\"gui.box_black_red_br\"), 0, 0, 16, 16, 48, 48, 16, 16);\n\t\treturn image;\t\t\n\t}", "public static void decodeAllImages(Args args){\n \t//Now those arrays will contain 'decoded' images\n \timageNames.clear();\n imagesToZip.clear();\n imageDict.clear();\n ArrayList<CodedData> recoveredData = null;\n\n //Read the coded images\n try {\n System.out.println(\"Reading zip file...\");\n readZip(args.codedInput, false);\n } catch (IOException ex) {\n Logger.getLogger(ProjectePractiques.class.getName()).log(Level.SEVERE, null, ex);\n }\n BufferedImage tempFrame=null, tempFrameI=null;\n WritableRaster tempBitmap=null;\n WritableRaster tempDecoded=null;\n CodedData tempData=null;\n int gop = dataList.get(0).gop;\n //System.out.println(gop);\n BufferedImage tempBufferedImage = null;\n int z = 0;\n //recoveredData[0] contains the info of the image 0, and so on\n int recoveredDataCounter = 0;\n //For every image,\n for(int i= 0; i < imageNames.size(); i++){\n \t//z is a counter of the gop so we can decide if its a frameI or P\n if(z >= (gop)){\n z=0;\n }\n if(z == 0){//Frame I\n \t//Store it\n tempFrameI = imageDict.get(imageNames.get(i));\n imageDict.put(imageNames.get(i), tempFrameI);\n }else{\n //Frame P, decode it\n tempFrame = imageDict.get(imageNames.get(i)); \n tempBitmap = (WritableRaster) tempFrame.getData();\n tempDecoded = tempBitmap.createWritableChild(tempFrame.getMinX(), tempFrame.getMinY(), tempFrame.getWidth(), tempFrame.getHeight(), 0,0, null);\n \t//Get his info\n tempData = dataList.get(recoveredDataCounter);\n recoveredDataCounter++;\n int[] tempColor;\n //Iterate through the tile and replace its pixels\n for(int k = 0; k < tempData.bestTilesX.size(); k++){\n for (int baseX = 0; baseX < tempData.tileWidth ; baseX++) {\n for (int baseY = 0; baseY < tempData.tileHeight; baseY++) {\n tempColor = getPixelColor(tempFrameI, tempData.bestOriginX.get(k)+baseX, tempData.bestOriginY.get(k)+baseY);\n tempDecoded.setPixel(tempData.bestTilesX.get(k)+baseX, tempData.bestTilesY.get(k)+baseY, tempColor);\n }\n }\n }\n //Store the new decoded image\n tempBufferedImage = new BufferedImage(tempFrame.getColorModel(),tempDecoded,tempFrame.isAlphaPremultiplied(),null);\n imageDict.put(imageNames.get(i), tempBufferedImage);\n tempFrameI = tempBufferedImage;\n }\n z++;\n }\n }", "void draw() {\n\n // SeamInfo lowestSeam = this.lowestSeamVert();\n // lowestSeam.changeColor();\n\n ComputedPixelImage seamRemovedImg = new ComputedPixelImage(this.newImg.width,\n this.newImg.height);\n int countRow = 0;\n int countCol = 0;\n\n Pixel current = this.curPixel;\n Pixel temp;\n\n while (current.down != null) {\n temp = current.down;\n while (current.right != null) {\n Color c = Color.MAGENTA;\n if (current.highlighted) {\n c = Color.RED;\n }\n else {\n c = current.color;\n }\n if (this.showType.equals(\"e\")) {\n int energy = (int) (current.energy * 100);\n if (energy > 255) {\n System.out.println(\"energy: \" + energy + \" to 255\");\n energy = 255;\n }\n c = new Color(energy, energy, energy);\n }\n else if (this.showType.equals(\"w\")) {\n int weight = (int) (current.seam.totalWeight);\n if (weight > 255) {\n System.out.println(\"weight: \" + weight + \" to 255\");\n weight = 255;\n }\n c = new Color(weight, weight, weight);\n }\n\n seamRemovedImg.setColorAt(countCol, countRow, c);\n countCol += 1;\n current = current.right;\n }\n countCol = 0;\n countRow += 1;\n current = temp;\n }\n countCol = 0;\n\n this.newImg = seamRemovedImg;\n\n }", "public void fuzzify() {\n ImageArray newCopy = currentIm.copy();\n \n int rows= currentIm.getRows();\n int cols= currentIm.getCols();\n \n for(int rr = 1; rr < rows-1; rr++){\n \n for(int cc = 1; cc < cols-1; cc++){\n fuzPixel(rr,cc,newCopy);\n \n }\n \n }\n \n currentIm = newCopy.copy();\n \n \n }", "public boolean testPixel(EIfcpixeltexture type) throws SdaiException;", "@Test\n public void picture3FixedTest() {\n // TODO: test picture3Fixed\n }", "private void drawImages() {\n\t\t\r\n\t}", "@LargeTest\n public void testIntrinsicsColorMatrixGrey() {\n TestAction ta = new TestAction(TestName.INTRINSICS_COLOR_MATRIX_GREY);\n runTest(ta, TestName.INTRINSICS_COLOR_MATRIX_GREY.name());\n }" ]
[ "0.5990543", "0.585953", "0.578423", "0.57833093", "0.57675844", "0.575256", "0.56904083", "0.568352", "0.5677687", "0.5653089", "0.5645955", "0.5643729", "0.5621099", "0.5562084", "0.5555056", "0.5552364", "0.5546049", "0.5516652", "0.54686165", "0.5464773", "0.54577845", "0.5453564", "0.54435045", "0.54404014", "0.5438466", "0.54384416", "0.543595", "0.5431747", "0.5427547", "0.5404373", "0.5381969", "0.5379916", "0.53686535", "0.5352475", "0.5343053", "0.53415906", "0.53259933", "0.5319011", "0.5313762", "0.53136015", "0.5310746", "0.5283612", "0.5272923", "0.5268687", "0.526834", "0.52625346", "0.5257611", "0.52565616", "0.5256097", "0.52478087", "0.5243502", "0.52353126", "0.5228224", "0.5223955", "0.52221775", "0.5215156", "0.52062416", "0.5203003", "0.5202609", "0.51903427", "0.51903415", "0.5185869", "0.51810044", "0.5180154", "0.51645535", "0.51645535", "0.51645535", "0.5163796", "0.5157923", "0.5148409", "0.5141412", "0.51410127", "0.5138969", "0.5128116", "0.5127755", "0.51246953", "0.5121515", "0.5118675", "0.5118675", "0.50956434", "0.5095608", "0.50941014", "0.5093804", "0.5093658", "0.5093038", "0.50899965", "0.5089527", "0.5082339", "0.50819224", "0.5076783", "0.5072995", "0.50703573", "0.50684446", "0.50673777", "0.50671846", "0.50623596", "0.50619256", "0.5058329", "0.50576645", "0.505537", "0.5049263" ]
0.0
-1
recursive method to spawn boss and all splits
private GameObject spawnBossBubble(LogicEngine toRunIn, int i_level, int i_maxLevel) { float f_sizeMultiplier = 1 - ((float)i_level/(float)i_maxLevel); if(i_level == i_maxLevel) return null; else { GameObject go = new GameObject("data/"+GameRenderer.dpiFolder+"/redcube.png",toRunIn.SCREEN_WIDTH/2,LogicEngine.rect_Screen.getHeight()+50,0); go.i_animationFrameRow = 0; go.i_animationFrame =1; go.i_animationFrameSizeWidth =40; go.i_animationFrameSizeHeight =37; go.f_forceScaleX = 2f * f_sizeMultiplier; go.f_forceScaleY = 2f * f_sizeMultiplier; go.v.setMaxForce(1); go.v.setMaxVel(5); go.stepHandlers.add( new BounceOfScreenEdgesStep()); go.allegiance = GameObject.ALLEGIANCES.ENEMIES; //initial velocity of first one go.v.setVel(new Vector2d(0,-5)); go.allegiance = GameObject.ALLEGIANCES.ENEMIES; //if is last one if(i_level == i_maxLevel - 1) { HitpointShipCollision collision = new HitpointShipCollision(go,1, 40.0 * f_sizeMultiplier); go.collisionHandler = collision; collision.setSimpleExplosion(); return go; } else //has children { SplitCollision collision = new SplitCollision(go,2, 15.0 * f_sizeMultiplier); collision.setSimpleExplosion(); go.collisionHandler = collision; //add children for(int i=0;i<4;i++) { GameObject go2 = spawnBossBubble(toRunIn,i_level+1,i_maxLevel); if(i==0) go2.v.setVel(new Vector2d(-5,-5)); if(i==1) go2.v.setVel(new Vector2d(5,-5)); if(i==2) go2.v.setVel(new Vector2d(-5,5)); if(i==3) go2.v.setVel(new Vector2d(5,5)); collision.splitObjects.add(go2); } } return go; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private void prepare()\n {\n treespawn treespawn2 = new treespawn();\n addObject(treespawn2,30,486);\n\n hantu hantu = new hantu();\n addObject(hantu,779,359);\n \n hantu hantu2 = new hantu();\n addObject(hantu2,88,84);\n \n bergerak bergerak2 = new bergerak();\n addObject(bergerak2,745,423);\n\n bergerak bergerak3 = new bergerak();\n addObject(bergerak3,266,566);\n \n bergerak bergerak4 = new bergerak();\n addObject(bergerak4,564,566);\n\n hantu hantu3 = new hantu();\n addObject(hantu3,671,490);\n \n hantu hantu4 = new hantu();\n addObject(hantu4,371,499);\n\n bergerak bergerak = new bergerak();\n addObject(bergerak,150,148);\n\n lantai lantai = new lantai();\n addObject(lantai,561,577); \n addObject(lantai,419,579); \n\n player player = new player();\n addObject(player,882,498);\n\n lantai3 lantai3 = new lantai3();\n addObject(lantai3,120,148);\n\n flyinglantai flyinglantai = new flyinglantai();\n addObject(flyinglantai,292,148);\n\n treespawn treespawn = new treespawn();\n addObject(treespawn,30,291);\n\n lantai4 lantai4 = new lantai4();\n addObject(lantai4,235,536);\n \n lantai4 lantai42 = new lantai4();\n addObject(lantai42,275,508);\n \n lantai4 lantai43 = new lantai4();\n addObject(lantai43,323,480);\n \n lantai4 lantai44 = new lantai4();\n addObject(lantai44,369,454);\n\n lantai2 lantai2 = new lantai2();\n addObject(lantai2,680,424);\n\n \n lantai3 lantai32 = new lantai3();\n addObject(lantai32,938,146);\n \n lantai4 lantai45 = new lantai4();\n addObject(lantai45,21,370);\n\n lantai4 lantai46 = new lantai4();\n addObject(lantai46,210,180);\n \n lantai4 lantai47 = new lantai4();\n addObject(lantai47,257,201);\n \n lantai4 lantai48 = new lantai4();\n addObject(lantai48,302,229);\n \n lantai4 lantai49 = new lantai4();\n addObject(lantai49,354,255);\n \n lantai4 lantai410 = new lantai4();\n addObject(lantai410,402,281);\n \n lantai4 lantai411 = new lantai4();\n addObject(lantai411,444,302);\n \n lantai4 lantai412 = new lantai4();\n addObject(lantai412,491,334);\n \n lantai4 lantai413 = new lantai4();\n addObject(lantai413,546,364);\n \n lantai4 lantai414 = new lantai4();\n addObject(lantai414,582,397);\n \n doorlv3 doorlv3 = new doorlv3();\n addObject(doorlv3,910,45);\n\n \n }", "private GameObject spawnBoss(LogicEngine in_logicEngine,LevelManager in_manager)\r\n\t{\n\t\tGameObject go = new GameObject(\"data/\"+GameRenderer.dpiFolder+\"/redcube.png\",in_logicEngine.SCREEN_WIDTH/2,LogicEngine.rect_Screen.getHeight()+50,0);\r\n\t\tboss = go;\r\n\t\t\r\n\t\tboss.i_animationFrameRow = 1;\r\n\t\tboss.i_animationFrame =0;\r\n\t\tboss.i_animationFrameSizeWidth =75;\r\n\t\tboss.i_animationFrameSizeHeight =93;\r\n\t\t\r\n\t\tboss.v.setMaxForce(1);\r\n\t\tboss.v.setMaxVel(5);\r\n\t\tboss.stepHandlers.add( new BounceOfScreenEdgesStep());\r\n\t\t\r\n\t\t\r\n\t\tboss_arrive.setAttribute(\"arrivedistance\", \"50\", null);\r\n\t\tboss.stepHandlers.add( new CustomBehaviourStep(boss_arrive));\r\n\t\tboss.isBoss = true;\r\n\t\t\r\n\t\t\r\n\t\t\t\r\n\t\tHitpointShipCollision c = new HitpointShipCollision(boss, 150, 40, true,1);\r\n\t\t\r\n\t\tif(Difficulty.isMedium())\r\n\t\t\tc.f_numberOfHitpoints = 200;\r\n\t\t\r\n\t\tif(Difficulty.isHard())\r\n\t\t\tc.f_numberOfHitpoints = 250;\r\n\t\t\r\n\t\tif(Difficulty.isMedium())\r\n\t\t\ti_bossBubbleEvery = 125;\r\n\t\t\r\n\t\tif(Difficulty.isHard())\r\n\t\t\ti_bossBubbleEvery = 100;\r\n\t\t\r\n\t\t\r\n\t\tc.addHitpointBossBar(in_logicEngine);\r\n\t\tc.setExplosion(Utils.getBossExplosion(boss));\r\n\t\tboss.collisionHandler = c;\r\n\t\t\r\n\t\tboss.allegiance = GameObject.ALLEGIANCES.ENEMIES;\r\n\t\t//initial velocity of first one \r\n\t\tboss.v.setVel(new Vector2d(0,-5));\r\n\t\t\r\n\t\tGameObject Tadpole1 = in_manager.spawnTadpole(in_logicEngine);\r\n\t\tGameObject Tadpole2 = in_manager.spawnTadpole(in_logicEngine);\r\n\t\t\r\n\t\tGameObject Bubble = null;\r\n\t\t\r\n\t\t\r\n\t\tBubble = spawnBossBubble(in_logicEngine, 0, 3);\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\tTadpole1.v.setVel(new Vector2d(-10,5));\r\n\t\tTadpole2.v.setVel(new Vector2d(10,5));\r\n\t\tBubble.v.setVel(new Vector2d(0,-5));\r\n\t\t\r\n\t\tLaunchShipsStep l1 = new LaunchShipsStep(Tadpole1 , 50, 5, 1, false);\r\n\t\tLaunchShipsStep l2 = new LaunchShipsStep(Tadpole2, 50, 5, 1, true);\r\n\t\tLaunchShipsStep l3 = new LaunchShipsStep(Bubble, i_bossBubbleEvery, 1, 1, true);\r\n\t\tl1.b_addToBullets = true;\r\n\t\tl2.b_addToBullets = true;\r\n\t\t\r\n\t\tboss.stepHandlers.add(l1);\r\n\t\tboss.stepHandlers.add(l2);\r\n\t\tboss.stepHandlers.add(l3);\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\td_eye = new Drawable();\r\n\t\td_eye.i_animationFrameSizeHeight=8;\r\n\t\td_eye.i_animationFrameSizeWidth=8;\r\n\t\td_eye.i_animationFrameRow = 3;\r\n\t\td_eye.str_spritename = \"data/\"+GameRenderer.dpiFolder+\"/eye.png\";\r\n\t\t\r\n\t\tboss.visibleBuffs.add(d_eye);\r\n\t\t\r\n\t\treturn boss;\r\n\t}", "private void doSpawnProcess()\n\t{\n\t\t// spawn sometin\n\t\tthis.spawn();\n\t\t\n\t\t// record another spawned enemy\n\t\tspawnCurrent++;\n\t\t\n\t\t// if that wasn't the last Walker\n\t\tif(currentWave.getNumberOfWalkers() > 0)\n\t\t{\n\t\t\t// restart the spawn timer\n\t\t\tfloat delay = currentWave.getSpawnDelay();\n\t\t\tspawnTimer.start(delay);\n\t\t}\n\t\t// otherwise, we've spawned all our piggies in this wave\n\t\telse\n\t\t{\n\t\t\tprepareNextWave();\n\t\t}\n\t}", "public static void makeGrid (Species map[][], int numSheepStart, int numWolfStart, int numPlantStart, int sheepHealth, int plantHealth, int wolfHealth, int plantSpawnRate) {\n \n // Declare coordinates to randomly spawn species\n int y = 0;\n int x = 0;\n \n // Initialise plants\n Plant plant;\n \n // Spawn plants\n for (int i = 0; i < numPlantStart; i++) {\n \n // Choose random coordinates to spawn\n y = (int)(Math.random() * map[0].length); \n x = (int)(Math.random() * map.length);\n \n // Checks for an empty space\n if (map[y][x] == null) { \n \n // Choose a random plant (50% chance healthy, 25% poisonous or energizing)\n int plantChoice = (int) Math.ceil(Math.random() * 100);\n \n // Create the new plants\n if ((plantChoice <= 100) && (plantChoice >= 50)) {\n plant = new HealthyPlant(plantHealth, x, y, plantSpawnRate);\n } else if ((plantChoice < 50) && (plantChoice >= 25)) {\n plant = new EnergizingPlant(plantHealth, x, y, plantSpawnRate);\n } else {\n plant = new PoisonousPlant(plantHealth, x, y, plantSpawnRate);\n }\n \n // Set plant coordinates\n plant.setX(x);\n plant.setY(y);\n map[y][x] = plant;\n \n // No space\n } else { \n i -= 1;\n }\n \n }\n \n // Spawn sheep\n for (int i = 0; i < numSheepStart; i++) { \n \n // Choose random coordinates to spawn\n y = (int)(Math.random() * map[0].length); \n x = (int)(Math.random() * map.length);\n \n // Checks for an empty space\n if (map[y][x] == null) {\n \n // Create new sheep\n Sheep sheep = new Sheep(sheepHealth, x, y, 5); \n \n // Set sheep coordinates\n sheep.setX(x);\n sheep.setY(y);\n map[y][x] = sheep;\n \n // No space\n } else { \n i -= 1; \n }\n \n }\n \n // Spawn wolves\n for (int i = 0; i < numWolfStart; i++) { \n \n // Choose random coordinates to spawn\n y = (int)(Math.random() * map[0].length); \n x = (int)(Math.random() * map.length);\n \n // Checks for an empty space\n if (map[y][x] == null) { \n \n // Create new wolf\n Wolf wolf = new Wolf(wolfHealth, x, y, 5); \n \n // Set wolf coordinates\n wolf.setX(x);\n wolf.setY(y);\n map[y][x] = wolf; \n \n // No space\n } else { \n i -= 1; \n }\n }\n \n }", "private void spawnTrees() {\n int spawnNum = this.random.nextInt(10) + 20;\n if (this.treeTiles.size() >= 30) { // max 30 trees\n spawnNum = 0;\n }\n for (int i = 0; i < spawnNum; i++) {\n String tree = trees[this.random.nextInt(trees.length)];\n int y = this.random.nextInt(this.getMap().length);\n Tile spawnTile = this.getMapAt(this.random.nextInt(this.getMap()[y].length), y);\n Tile centerTile;\n if ((spawnTile != null) && this.inMap(spawnTile.getX()-2, spawnTile.getY()-1)) {\n centerTile = this.getMapAt(spawnTile.getX()-2, spawnTile.getY()-1);\n } else {\n centerTile = null;\n }\n if ((spawnTile != null) && (spawnTile instanceof GroundTile)\n && (centerTile != null) && (centerTile instanceof GroundTile)\n && (spawnTile.getContent() == null)) {\n ExtrinsicTree newTree = new ExtrinsicTree(tree);\n newTree.setStage(17);\n spawnTile.setContent(newTree);\n this.treeTiles.add(spawnTile);\n }\n }\n }", "public void reproduce() {\n\t\tOrganism newOrg;\n\t\t\n\t\tfor (int i=0; i < Utils.between(_nChildren,1,8); i++) {\n\t\t\tnewOrg = new Organism(_world);\n\t\t\tif (newOrg.inherit(this, i==0)) {\n\t\t\t\t// It can be created\n\t\t\t\t_nTotalChildren++;\n\t\t\t\t_world.addOrganism(newOrg,this);\n\t\t\t\t_infectedGeneticCode = null;\n\t\t\t}\n\t\t\t_timeToReproduce = 20;\n\t\t}\n\t}", "void forceSpawn() throws SpawnException;", "public void spawnRobots() {\n\t\tString robotName\t= \"\";\n\t\tPlayer newPlayer\t= null;\n\t\tint numberOfRobots \t= 0;\n\t\tint robotsPerPlayer = server.getRobotsPerPlayer();\n\t\tint numberOfPlayers = server.getPlayerCount();\n\t\tint robotsPerLevel\t= server.getRobotsPerLevel();\n\t\t\n\t\t// calculate how many robots that should be spawned\n\t\trobotsPerPlayer = robotsPerPlayer *\n\t\t\t\t\t\t (robotsPerLevel * \n\t\t\t\t\t\t currentLevel);\n\t\t\n\t\tnumberOfRobots \t= robotsPerPlayer *\n\t\t\t\t\t\t numberOfPlayers;\n\t\t\n\t\tfor(int i = 0; i < numberOfRobots; i++) {\n\t\t\trobotName \t\t\t= \"Robot\" + (i+1);\n\t\t\tnewPlayer = initPlayerToGameplane(robotName, \n\t\t\t\t\t\t\t\t \t\t\t PlayerType.Robot, \n\t\t\t\t\t\t\t\t \t\t\t 0, 0);\n\t\t\t\n\t\t\tHandleCommunication.broadcastToClient(null, \n\t\t\t\t\t\t\t\t\t\t\t\t server.getConnectedClientList(), \n\t\t\t\t\t\t\t\t\t\t\t\t SendSetting.AddPlayer, \n\t\t\t\t\t\t\t\t\t\t\t\t newPlayer, \n\t\t\t\t\t\t\t\t\t\t\t\t null);\n\t\t}\n\t}", "public void createWorldMap() {\r\n\t\tdo {\r\n\t\t\t//\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Recursive map generation method over here@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n\t\t\t//Generation loop 1 *ADDS VEIN STARTS AND GRASS*\r\n\r\n\t\t\tfor (int i = 0; i < tileMap.length; i++) {\r\n\t\t\t\tfor (int j = 0; j < tileMap[i].length; j++) {\r\n\r\n\t\t\t\t\tif (Math.random()*10000>9999) { //randomly spawn a conore vein start\r\n\t\t\t\t\t\ttileMap[i][j] = new ConoreTile (conore, true);\r\n\t\t\t\t\t\tconoreCount++;\r\n\t\t\t\t\t}else if (Math.random()*10000>9999){\r\n\t\t\t\t\t\ttileMap[i][j] = new KannaiteTile(kanna, true);\r\n\t\t\t\t\t\tkannaiteCount++;\r\n\t\t\t\t\t}else if(Math.random()*10000>9999){\r\n\t\t\t\t\t\ttileMap[i][j] = new FuelTile(fuel, true);\r\n\t\t\t\t\t\tfuelCount++;\r\n\t\t\t\t\t}else if(Math.random()*10000>9999) {\r\n\t\t\t\t\t\ttileMap[i][j] = new ForestTile(forest, true);\r\n\t\t\t\t\t\tforestCount++;\r\n\t\t\t\t\t}else if(Math.random()*10000>9999){\r\n\t\t\t\t\t\ttileMap[i][j] = new OilTile(oil,true);\r\n\t\t\t\t\t}else if(Math.random()*10000>9997) {\r\n\t\t\t\t\t\ttileMap[i][j] = new MountainTile(mountain, true);\r\n\t\t\t\t\t}else {\r\n\t\t\t\t\t\ttileMap[i][j] = new GrassTile(dirt);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t} // End for loop \r\n\t\t\t} // End for loop\r\n\t\t\t//End generation loop 1\r\n\r\n\t\t\t//Generation loop 2 *EXPANDS ON THE VEINS*\r\n\t\t\tdo {\r\n\t\t\t\tif (conoreCount<6) {\r\n\t\t\t\t\ttileMap[(int)Math.random()*200][(int)Math.random()*200] = new ConoreTile (conore,true);\r\n\t\t\t\t\tconoreCount++;\r\n\t\t\t\t}else {\r\n\t\t\t\t\tconorePass = true;\r\n\t\t\t\t}\r\n\t\t\t\tif (kannaiteCount<6) {\r\n\t\t\t\t\ttileMap[(int)Math.random()*200][(int)Math.random()*200] = new KannaiteTile (kanna,true);\r\n\t\t\t\t\tkannaiteCount++;\r\n\t\t\t\t}else {\r\n\t\t\t\t\tkannaitePass = true;\r\n\t\t\t\t}\r\n\t\t\t\tif (fuelCount<6) {\r\n\t\t\t\t\ttileMap[(int)Math.random()*200][(int)Math.random()*200] = new FuelTile (fuel,true);\r\n\t\t\t\t\tfuelCount++;\r\n\t\t\t\t}else {\r\n\t\t\t\t\tfuelPass = true;\r\n\t\t\t\t}\r\n\t\t\t\tif (forestCount<6) {\r\n\t\t\t\t\ttileMap[(int)Math.random()*200][(int)Math.random()*200] = new ForestTile (forest,true);\r\n\t\t\t\t\tforestCount++;\r\n\t\t\t\t}else {\r\n\t\t\t\t\tforestPass = true;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tSystem.out.println(\"Conore: \" + conoreCount + \" - \" + conorePass);\r\n\t\t\t\tSystem.out.println(\"Kannaite: \" + kannaiteCount + \" - \" + kannaitePass);\r\n\t\t\t\tSystem.out.println(\"Fuel: \" + fuelCount + \" - \" + fuelPass);\r\n\t\t\t\tSystem.out.println(\"Forest: \" + forestCount + \" - \" + forestPass);\r\n\t\t\t\tSystem.out.println(\"\");\r\n\t\t\t}while(!conorePass || !kannaitePass || !fuelPass || !forestPass);\r\n\r\n\t\t\tfor (int i = 0; i < tileMap.length; i++) {\r\n\t\t\t\tfor (int j = 0; j < tileMap[i].length; j++) {\r\n\t\t\t\t\tbuildConore(i,j);\r\n\t\t\t\t\tbuildKannaite(i,j);\r\n\t\t\t\t\tbuildFuel(i,j);\r\n\t\t\t\t\tbuildForest(i,j);\r\n\t\t\t\t}//End of for loop\r\n\t\t\t}//End of for loop\r\n\t\t\t//End of generation loop 2\r\n\r\n\t\t\t//Generation loop 3 *COUNT ORES*\r\n\t\t\tint loop3Count = 0;\r\n\t\t\tconorePass = false;\r\n\t\t\tkannaitePass = false;\r\n\t\t\tfuelPass = false;\r\n\t\t\tforestPass = false;\r\n\t\t\tdo {\r\n\t\t\t\tconoreCount = 0;\r\n\t\t\t\tkannaiteCount = 0;\r\n\t\t\t\tfuelCount = 0;\r\n\t\t\t\tforestCount = 0;\r\n\t\t\t\tfor (int i = 0; i < tileMap.length; i++) {\r\n\t\t\t\t\tfor (int j = 0; j < tileMap[i].length; j++) {\r\n\t\t\t\t\t\tif (tileMap[i][j] instanceof ConoreTile) {\r\n\t\t\t\t\t\t\tconoreCount++;\r\n\t\t\t\t\t\t}else if(tileMap[i][j] instanceof KannaiteTile) {\r\n\t\t\t\t\t\t\tkannaiteCount++;\r\n\t\t\t\t\t\t}else if(tileMap[i][j] instanceof FuelTile) {\r\n\t\t\t\t\t\t\tfuelCount++;\r\n\t\t\t\t\t\t}else if(tileMap[i][j] instanceof ForestTile) {\r\n\t\t\t\t\t\t\tforestCount++;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tfor (int i = 0; i < tileMap.length; i++) {\r\n\t\t\t\t\tfor (int j = 0; j < tileMap[i].length; j++) {\r\n\t\t\t\t\t\tif (conoreCount < 220) {\r\n\t\t\t\t\t\t\tbuildConore(i,j);\r\n\t\t\t\t\t\t}else {\r\n\t\t\t\t\t\t\tconorePass = true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (kannaiteCount < 220) {\r\n\t\t\t\t\t\t\tbuildKannaite(i,j);\r\n\t\t\t\t\t\t}else {\r\n\t\t\t\t\t\t\tkannaitePass = true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (fuelCount< 220) {\r\n\t\t\t\t\t\t\tbuildFuel(i,j);\r\n\t\t\t\t\t\t}else {\r\n\t\t\t\t\t\t\tfuelPass = true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (forestCount < 220) {\r\n\t\t\t\t\t\t\tbuildForest(i,j);\r\n\t\t\t\t\t\t}else {\r\n\t\t\t\t\t\t\tforestPass = true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tSystem.out.println(\"Conore: \" + conoreCount + \" - \" + conorePass);\r\n\t\t\t\tSystem.out.println(\"Kannaite: \" + kannaiteCount + \" - \" + kannaitePass);\r\n\t\t\t\tSystem.out.println(\"Fuel: \" + fuelCount + \" - \" + fuelPass);\r\n\t\t\t\tSystem.out.println(\"Forest: \" + forestCount + \" - \" + forestPass);\r\n\t\t\t\tSystem.out.println(\"\");\r\n\t\t\t\tloop3Count++;\r\n\t\t\t\tif (loop3Count > 100) {\r\n\t\t\t\t\tSystem.out.println(\"map generation failed! restarting\");\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}while(!conorePass || !kannaitePass || !fuelPass || !forestPass);\r\n\t\t\t//END OF LOOP 3\r\n\r\n\t\t\t//LOOP 4: THE MOUNTAIN & OIL LOOP\r\n\t\t\tfor (int i = 0; i < tileMap.length; i++) {\r\n\t\t\t\tfor (int j = 0; j < tileMap[i].length; j++) {\r\n\t\t\t\t\tbuildMountain(i,j);\r\n\t\t\t\t\tbuildOil(i,j);\r\n\t\t\t\t}\r\n\t\t\t}//End of THE Mountain & OIL LOOP\r\n\r\n\t\t\t//ADD MINIMUM AMOUNT OF ORES\r\n\r\n\t\t\t//Generation Loop 5 *FINAL SETUP*\r\n\t\t\tfor (int i = 0; i < tileMap.length; i++) {\r\n\t\t\t\tfor (int j = 0; j < tileMap[i].length; j++) {\r\n\r\n\t\t\t\t\tif(i == 1 || j == 1 || i == tileMap.length-2 || j == tileMap[i].length-2) {\r\n\t\t\t\t\t\ttileMap[i][j] = new DesertTile(desert);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (i == 0 || j == 0 || i == tileMap.length-1 || j == tileMap[i].length-1) {\r\n\t\t\t\t\t\ttileMap[i][j] = new WaterTile(water);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}//End of for loop\r\n\t\t\t}//End of for loop\r\n\t\t\t//End of generation loop 5\r\n\t\t\t//mapToString();//TEST RUN\r\n\t\t} while(!conorePass || !kannaitePass || !fuelPass || !forestPass); // End createWorldMap method\r\n\t}", "@Override\r\n\t\t\t\tpublic void run() {\n\t\t\t\t\t\r\n\t\t\t\t\tfor(Entity as: Bukkit.getWorld(\"world\").getEntities()) {\r\n\t\t\t\t\t\tif(as instanceof ArmorStand) {\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tas.remove();\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//TOPS\r\n\t\t\t\t\r\n\t\t\t\t\tif(MetodosWarps.containsWarp(\"topkills\")) {\r\n\t\t\t\t\t getTop(locTopKILLS,\"Kills\");\r\n\t\t\t\t\t\tBukkit.getConsoleSender().sendMessage(\" \\n žAžlTOP KILLS ATUALIZADO COM SUCESSO! \\n \");\t\r\n\t\t\t\t\t}else {\r\n\t\t\t\t\t\tBukkit.getConsoleSender().sendMessage(\" \\n žcžlO TOP KILLS NAO PODE SER CARREGADO, POIS A WARP topkills NAO ESTA SETADA! \\n \");\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif(MetodosWarps.containsWarp(\"topcoins\")) {\r\n\t\t\t\t\t getTop(locTopCoins,\"Coins\");\r\n\t\t\t\t\t\tBukkit.getConsoleSender().sendMessage(\" \\n žAžlTOP COINS ATUALIZADO COM SUCESSO! \\n \");\t\r\n\t\t\t\t\t}else {\r\n\t\t\t\t\t\tBukkit.getConsoleSender().sendMessage(\" \\n žcžlO TOP COINS NAO PODE SER CARREGADO, POIS A WARP topkills NAO ESTA SETADA! \\n \");\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif(MetodosWarps.containsWarp(\"top1v1\")) {\r\n\t\t\t\t\t getTop(locTop1v1,\"wins\");\r\n\t\t\t\t\t\tBukkit.getConsoleSender().sendMessage(\" \\n žAžlTOP 1v1 ATUALIZADO COM SUCESSO! \\n \");\t\r\n\t\t\t\t\t}else {\r\n\t\t\t\t\t\tBukkit.getConsoleSender().sendMessage(\" \\n žcžlO TOP 1v1 NAO PODE SER CARREGADO, POIS A WARP top1v1 NAO ESTA SETADA! \\n \");\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t//Caixa misteriosa\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(MetodosWarps.containsWarp(\"misteryBox\")) {\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t Spawn(misteryBox, \"žažlCAIXA MISTERIOSA\",misteryBox.getY()-1.7);\r\n\t\t\t\t\t Spawn(misteryBox, \"žežlEM BREVE!\",misteryBox.getY()-2);\r\n\t\t\t\t\t\tBukkit.getConsoleSender().sendMessage(\" \\n žAžlMYSTERYBOX ATUALIZADO COM SUCESSO! \\n \");\t\r\n\t\t\t\t\t}else {\r\n\t\t\t\t\t\tBukkit.getConsoleSender().sendMessage(\" \\n žcžlO TOP COINS NAO PODE SER CARREGADO, POIS A WARP misteryBox NAO ESTA SETADA! \\n \");\r\n\t\t\t\t\t}\r\n\t\t\t\t}", "private void setBaseSpawns() {\r\n m_botAction.sendUnfilteredPublicMessage(\"?set Spawn:Team0-X:148\");\r\n m_botAction.sendUnfilteredPublicMessage(\"?set Spawn:Team0-Y:517\");\r\n m_botAction.sendUnfilteredPublicMessage(\"?set Spawn:Team0-Radius:20\");\r\n\r\n m_botAction.sendUnfilteredPublicMessage(\"?set Spawn:Team1-X:330\");\r\n m_botAction.sendUnfilteredPublicMessage(\"?set Spawn:Team1-Y:517\");\r\n m_botAction.sendUnfilteredPublicMessage(\"?set Spawn:Team1-Radius:20\");\r\n\r\n m_botAction.sendUnfilteredPublicMessage(\"?set Spawn:Team2-X:694\");\r\n m_botAction.sendUnfilteredPublicMessage(\"?set Spawn:Team2-Y:517\");\r\n m_botAction.sendUnfilteredPublicMessage(\"?set Spawn:Team2-Radius:20\");\r\n\r\n m_botAction.sendUnfilteredPublicMessage(\"?set Spawn:Team3-X:876\");\r\n m_botAction.sendUnfilteredPublicMessage(\"?set Spawn:Team3-Y:517\");\r\n m_botAction.sendUnfilteredPublicMessage(\"?set Spawn:Team3-Radius:20\");\r\n\r\n }", "private void spawnBigEnemy(IEnemyService spawner, World world, GameData gameData) {\r\n if (spawner != null) {\r\n spawner.createBigEnemy(world, gameData, new Position(randomIntRange(1600, 3200), gameData.getGroundHeight()));\r\n spawner.createBigEnemy(world, gameData, new Position(randomIntRange(-600, -2000), gameData.getGroundHeight()));\r\n }\r\n }", "private void spawn()\n\t{\n\t\t// get the path index and set the stage for the next path to be different\n\t\tint currentPathIndex = 0; //currentWave.getPathIndex();\n\t\t//currentWave.cyclePathList();\n\t\t\n\t\t// get the actual path using the index\n\t\tPath currentPath = pathList.get(currentPathIndex);\n\t\t\n\t\t// create the new Walker with that path\n\t\tWalker walker;\n\t\t\n\t\tswitch(currentWave.dequeueWalker())\n\t\t{\n\t\t\tcase QUICK:\t\twalker = new WalkerQuick(currentPath);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\tdefault:\t\twalker = new WalkerBasic(currentPath);\n\t\t}\n\t\t\n\t\t// put Walker on specific DrawingLayer if necessary\n\t\tif(spawnDrawingLayer != null)\n\t\t{\n\t\t\twalker.moveToDrawingLayer(spawnDrawingLayer);\n\t\t}\n\t}", "public void enemySpawn(String typeofEnemy) {\n if (spawnTimer == 0) {\n if (typeofEnemy.equals(\"bee\")) {\n outerloop:\n//label to later break when enemy is spawned\n for (int row = 3; row < 5; row++) {\n for (int column = 0; column < 8; column++) {\n if (canSpawn[row][column] == false) {\n handler.getGalagaState().entityManager.entities.add(new EnemyBee(x, y, 32, 32, handler, row, column));\n canSpawn[row][column] = true;\n spawnTimer = random.nextInt(60 * 7);\n break outerloop;\n } else continue;\n }\n }\n } else {//ENEMYOTHER\n outerloop:\n for (int row = 1; row < 3; row++) {\n for (int column = 0; column < 8; column++) {\n if (canSpawn[row][column] == false) {\n handler.getGalagaState().entityManager.entities.add(new EnemyOther(x, y, 32, 32, handler, row, column));\n canSpawn[row][column] = true;\n spawnTimer = random.nextInt(60 * 7);\n break outerloop;\n } else continue;\n }\n }\n\n }\n }\n else {\n spawnTimer--;\n }\n\n// int enemyType = random.nextInt(2);\n// spawnTimer--;\n// if (spawnTimer == 0) {\n// if (typeofEnemy.equals(\"bee\")) {\n// int row = random.nextInt(2) + 3, column = random.nextInt(8);\n// if (canSpawn[row][column] == false) {\n// handler.getGalagaState().entityManager.entities.add(new EnemyBee(x, y, 32, 32, handler, row, column));\n// canSpawn[row][column] = true;\n// } else {\n// return;\n// }\n// } else {\n// int row = random.nextInt(2) + 1, column = random.nextInt(8);\n// if (canSpawn[row][column] == false) {\n// handler.getGalagaState().entityManager.entities.add(new EnemyOther(x, y, 32, 32, handler, row, column));\n// canSpawn[row][column] = true;\n// }\n// }\n// }\n// else{\n// spawnTimer--;\n// }\n\n\n\n\n }", "private void split () {\n\n if (firstClassList != null && firstClassList.size() > MAX_OBJECTS && depth < MAX_DEPTH) {\n\n // Set new bounds along each axis\n double[] xBounds = new double[] {bounds.getMinX(), bounds.getCenterX(), bounds.getMaxX()};\n double[] yBounds = new double[] {bounds.getMinY(), bounds.getCenterY(), bounds.getMaxY()};\n double[] zBounds = new double[] {bounds.getMinZ(), bounds.getCenterZ(), bounds.getMaxZ()};\n\n // Create each child\n children = new SceneOctTree[8];\n for (int x = 0; x <= 1; x++) {\n for (int y = 0; y <= 1; y++) {\n for (int z = 0; z <= 1; z++) {\n Bounds childBounds = new BoundingBox (\n xBounds[x], yBounds[y], zBounds[z],\n xBounds[x+1] - xBounds[x], yBounds[y+1] - yBounds[y], zBounds[z+1] - zBounds[z]\n );\n int index = x + y*2 + z*4;\n children[index] = new SceneOctTree (childBounds, this.depth+1);\n } // for\n } // for\n } // for\n\n // Insert first class objects into children. Note that we don't know\n // if the object will be first or second class in the child so we have\n // to perform a full insert.\n for (Node object : firstClassList) {\n Bounds objectBounds = object.getBoundsInLocal();\n for (SceneOctTree child : children) {\n if (objectBounds.intersects (child.bounds))\n child.insert (object);\n } // for\n } // for\n firstClassList = null;\n\n // Insert second class objects into children (if any exist). We know\n // that the object will be second class in the child, so we just\n // perform a second class insert.\n if (secondClassList != null) {\n for (Node object : secondClassList) {\n Bounds objectBounds = object.getBoundsInLocal();\n for (SceneOctTree child : children) {\n if (objectBounds.intersects (child.bounds))\n child.insertSecondClass (object, objectBounds);\n } // for\n } // for\n } // if\n secondClassList = null;\n\n // Perform a split on the children, just in case all the first class\n // objects that we just inserted all went into one child.\n for (SceneOctTree child : children) child.split();\n\n } // if\n\n }", "public static void reproduce (Species [][] map, int sheepHealth, int wolfHealth, int plantHealth) {\n \n // Place the baby\n int babyY, babyX;\n \n // Check if the baby has been placed\n int spawned = 0;\n \n for (int y = 0; y < map[0].length; y++){\n for (int x = 0; x < map.length; x++){\n \n boolean [][] breeding = breedChoice (map, x, y, plantHealth);\n \n // Sheep upwards to breed with\n if (breeding[0][0]) {\n ((Sheep)map[y][x]).reproduceHealthLost(10);\n ((Sheep)map[y-1][x]).reproduceHealthLost(10);\n \n // Make baby sheep\n Sheep sheep = new Sheep(sheepHealth, x, y);\n \n // Place the baby sheep\n do {\n babyY = (int)(Math.random() * map.length);\n babyX = (int)(Math.random() * map.length);\n if (map[babyY][babyX] == null) {\n map[babyY][babyX] = sheep;\n spawned = 1;\n }\n } while (spawned == 0);\n \n // Sheep downwards to breed with\n } else if (breeding[1][0]) {\n ((Sheep)map[y][x]).reproduceHealthLost(10);\n ((Sheep)map[y+1][x]).reproduceHealthLost(10);\n \n // Make baby sheep\n Sheep sheep = new Sheep(sheepHealth, x, y);\n \n // Place the baby sheep\n do {\n babyY = (int)(Math.random() * map.length);\n babyX = (int)(Math.random() * map.length);\n if (map[babyY][babyX] == null) {\n map[babyY][babyX] = sheep;\n spawned = 1;\n }\n } while (spawned == 0);\n \n // Sheep to the left to breed with\n } else if (breeding[2][0]) {\n ((Sheep)map[y][x]).reproduceHealthLost(10);\n ((Sheep)map[y][x-1]).reproduceHealthLost(10);\n \n // Make baby sheep\n Sheep sheep = new Sheep(sheepHealth, x, y);\n \n // Place the baby sheep\n do {\n babyY = (int)(Math.random() * map.length);\n babyX = (int)(Math.random() * map.length);\n if (map[babyY][babyX] == null) {\n map[babyY][babyX] = sheep;\n spawned = 1;\n }\n } while (spawned == 0);\n \n // Sheep to the right to breed with\n } else if (breeding[3][0]) {\n ((Sheep)map[y][x]).reproduceHealthLost(10);\n ((Sheep)map[y][x+1]).reproduceHealthLost(10);\n \n // Make baby sheep\n Sheep sheep = new Sheep(sheepHealth, x, y);\n \n // Place the baby sheep\n do {\n babyY = (int)(Math.random() * map.length);\n babyX = (int)(Math.random() * map.length);\n if (map[babyY][babyX] == null) {\n map[babyY][babyX] = sheep;\n spawned = 1;\n }\n } while (spawned == 0);\n \n // Wolf upwards to breed with\n } else if (breeding[0][1]) {\n ((Wolf)map[y][x]).reproduceHealthLost(10);\n ((Wolf)map[y-1][x]).reproduceHealthLost(10);\n \n // Make baby wolf\n Wolf wolf = new Wolf(wolfHealth, x, y);\n \n // Place the baby wolf\n do { \n babyY = (int)(Math.random() * map.length);\n babyX = (int)(Math.random() * map.length);\n if (map[babyY][babyX] == null) {\n map[babyY][babyX] = wolf;\n spawned = 1; \n }\n } while (spawned == 0);\n \n // Wolf downwards to breed with\n } else if (breeding[1][1]) {\n ((Wolf)map[y][x]).reproduceHealthLost(10);\n ((Wolf)map[y+1][x]).reproduceHealthLost(10);\n \n // Make baby wolf\n Wolf wolf = new Wolf(wolfHealth, x, y);\n \n // Place the baby wolf\n do { \n babyY = (int)(Math.random() * map.length);\n babyX = (int)(Math.random() * map.length);\n if (map[babyY][babyX] == null) {\n map[babyY][babyX] = wolf;\n spawned = 1; \n }\n } while (spawned == 0);\n \n // Wolf to the left to breed with\n } else if (breeding[2][1]) {\n ((Wolf)map[y][x]).reproduceHealthLost(10);\n ((Wolf)map[y][x-1]).reproduceHealthLost(10);\n \n // Make baby wolf\n Wolf wolf = new Wolf(wolfHealth, x, y);\n \n // Place the baby wolf\n do { \n babyY = (int)(Math.random() * map.length);\n babyX = (int)(Math.random() * map.length);\n if (map[babyY][babyX] == null) {\n map[babyY][babyX] = wolf;\n spawned = 1; \n }\n } while (spawned == 0);\n \n // Wolf to the right to breed with\n } else if (breeding[3][1]) {\n ((Wolf)map[y][x]).reproduceHealthLost(10);\n ((Wolf)map[y][x+1]).reproduceHealthLost(10);\n \n // Make baby wolf\n Wolf wolf = new Wolf(wolfHealth, x, y);\n \n // Place the baby wolf\n do { \n babyY = (int)(Math.random() * map.length);\n babyX = (int)(Math.random() * map.length);\n if (map[babyY][babyX] == null) {\n map[babyY][babyX] = wolf;\n spawned = 1; \n }\n } while (spawned == 0);\n \n }\n \n }\n }\n \n }", "public void spawnNew() {\n\t\tif (tier> 1) {\n\t\t\ttier--;\n\t\t\thealth = tier;\n\t\t\tdamage = tier;\n\t\t\tspeed = 5;\n\t\t\timg = getImage(updateImage(tier)); // converted getImage to protected b/c it wasn't accessible by Balloon class (child class)\n\t\t}\n\t\telse {\n\t\t\tisAlive = false;\n\t\t\tdeletePath();\t\t\t\n\t\t}\n\t}", "public void runTournament() {\n\t\t//ArrayList<Gene> tournament = new ArrayList<Gene>();\n\t\tPriorityQueue<Gene> tournament = new PriorityQueue<Gene>(Collections.reverseOrder());\n\t\tint numContenders = (int)(FRAC_IN_TOURNAMENT * geneNumber);\n\t\tSet<Integer> chosenOnes = new HashSet<Integer>();\n\t\t\n\t\twhile(chosenOnes.size() < numContenders) {\n\t\t\tint randIndex = (int) (Math.random() * geneNumber);\n\t\t\tchosenOnes.add(randIndex);\n\t\t}\n\t\tfor(int i : chosenOnes){\n\t\t\ttournament.add(genepool.get(i));\n\t\t}\n\t\t//int firstIndex = getMax(tournament, -1);\n\t\t//int secondIndex = getMax(tournament, firstIndex);\n\t\t//Gene parent1 = tournament.get(firstIndex);\n\t\t//Gene parent2 = tournament.get(secondIndex);\n\t\tGene parent1 = tournament.poll();\n\t\tGene parent2 = tournament.poll();\n\t\t// Create a new gene from the 2 fittest genes\n\t\tGene newGene = parent1.waCrossover(parent2);\n\t\t\n\t\t// Calculate fitness for the new gene\n\t\tPlayerSkeleton.runGames(numGames, newGene);\n\t\toffspringPool.add(newGene);\n\t}", "public synchronized void spawnMe()\n\t{\n\t\t_itemInstance = ItemTable.getInstance().createItem(\"Combat\", _itemId, 1, null, null);\n\t\t_itemInstance.dropMe(null, _location.getX(), _location.getY(), _location.getZ());\n\t}", "public static void selfTest()\n {\n\t\tBoatGrader b = new BoatGrader();\n\t\t \n\t\tSystem.out.println(\"\\n ***Testing Boats with only 2 children***\");\n\t\tbegin(0, 2, b);\n\t\t \n\t\t// System.out.println(\"\\n ***Testing Boats with 2 children, 1 adult***\");\n\t\t// \t begin(1, 2, b);\n\t\t \n\t\t// System.out.println(\"\\n ***Testing Boats with 3 children, 3 adults***\");\n\t\t// begin(3, 3, b);\n }", "abstract public void initSpawn();", "private MoveTree generateTree() {\n\n\t\tArrayList<MoveTree> leaves = new ArrayList<>();\n\n\t\tMoveTree tree = new MoveTree(Main.getSWController().getGame().getCurrentGameState());\n\t\tleaves.add(tree);\n\n\t\tfinal Flag flag = new Flag(), finished = new Flag();\n\n\t\tTimer timer = new Timer(true);\n\t\ttimer.schedule(new TimerTask() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tsynchronized (flag) {\n\t\t\t\t\tif (!finished.value)\n\t\t\t\t\t\tflag.value = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}, 9000);\n\n\t\twhile (true) {\n\t\t\tArrayList<MoveTree> newLeaves = new ArrayList<>();\n\t\t\tfor (MoveTree leaf : leaves) {\n\t\t\t\tGameState state = leaf.getState();\n\t\t\t\tPlayer currentPlayer = state.getPlayer();\n\n\t\t\t\tfor (Card handcard : currentPlayer.getHand()) {\n\t\t\t\t\tBuildCapability capability = Main.getSWController().getPlayerController().canBuild(currentPlayer, handcard, state);\n\t\t\t\t\tswitch (capability) {\n\t\t\t\t\tcase FREE:\n\t\t\t\t\tcase OWN_RESOURCE:\n\t\t\t\t\t\tMove move = new Move(handcard, Action.BUILD);\n\t\t\t\t\t\tMoveTree newTree = new MoveTree(move, doMove(move, currentPlayer, state));\n\t\t\t\t\t\tnewLeaves.add(newTree);\n\t\t\t\t\t\tleaf.addChild(newTree);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase TRADE:\n\t\t\t\t\t\tTradeOption trade = Main.getSWController().getPlayerController().getTradeOptions(currentPlayer, handcard.getRequired(), state).get(0);\n\t\t\t\t\t\tMove tradeMove = new Move(handcard, Action.BUILD);\n\t\t\t\t\t\ttradeMove.setTradeOption(trade);\n\t\t\t\t\t\tMoveTree newTree2 = new MoveTree(tradeMove, doMove(tradeMove, currentPlayer, state));\n\t\t\t\t\t\tnewLeaves.add(newTree2);\n\t\t\t\t\t\tleaf.addChild(newTree2);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (currentPlayer.getBoard().nextSlot() != -1) {\n\t\t\t\t\t\tArrayList<Resource> slotRequirements = new ArrayList<>(Arrays.asList(currentPlayer.getBoard().getNextSlotRequirement()));\n\t\t\t\t\t\tcapability = Main.getSWController().getPlayerController().hasResources(currentPlayer, slotRequirements, state);\n\t\t\t\t\t\tswitch (capability) {\n\t\t\t\t\t\tcase OWN_RESOURCE:\n\t\t\t\t\t\t\tMove move = new Move(handcard, Action.PLACE_SLOT);\n\t\t\t\t\t\t\tMoveTree newTree = new MoveTree(move, doMove(move, currentPlayer, state));\n\t\t\t\t\t\t\tnewLeaves.add(newTree);\n\t\t\t\t\t\t\tleaf.addChild(newTree);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase TRADE:\n\t\t\t\t\t\t\tTradeOption trade = Main.getSWController().getPlayerController().getTradeOptions(currentPlayer, slotRequirements, state).get(0);\n\t\t\t\t\t\t\tMove tradeMove = new Move(handcard, Action.PLACE_SLOT);\n\t\t\t\t\t\t\ttradeMove.setTradeOption(trade);\n\t\t\t\t\t\t\tMoveTree newTree2 = new MoveTree(tradeMove, doMove(tradeMove, currentPlayer, state));\n\t\t\t\t\t\t\tnewLeaves.add(newTree2);\n\t\t\t\t\t\t\tleaf.addChild(newTree2);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tMove sellmove = new Move(handcard, Action.SELL);\n\t\t\t\t\tMoveTree selltree = new MoveTree(sellmove, doMove(sellmove, currentPlayer, state));\n\t\t\t\t\tnewLeaves.add(selltree);\n\t\t\t\t\tleaf.addChild(selltree);\n \n\t\t\t\t\tif (!currentPlayer.isOlympiaUsed() && !Main.getSWController().getCardController().hasCard(currentPlayer, handcard.getInternalName())) {\n\t\t\t\t\t\tMove olympiamove = new Move(handcard, Action.OLYMPIA);\n\t\t\t\t\t\tMoveTree olympiatree = new MoveTree(olympiamove, doMove(olympiamove, currentPlayer, state));\n\t\t\t\t\t\tnewLeaves.add(olympiatree);\n\t\t\t\t\t\tleaf.addChild(olympiatree);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tsynchronized (flag) {\n\t\t\t\t\tif (flag.value) {\n\t\t\t\t\t\tfor (MoveTree child : leaves)\n\t\t\t\t\t\t\tchild.getChildren().clear();\n\t\t\t\t\t\treturn tree;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tboolean breakAfterwards = false;\n\n\t\t\tfor (MoveTree newLeaf : newLeaves) {\n\t\t\t\tfor (Player player : newLeaf.getState().getPlayers()) {\n\t\t\t\t\tif (player.isMausoleum()) {\n\t\t\t\t\t\tCard card = getHalikarnassusCard(player, newLeaf.getState().getTrash(), newLeaf.getState());\n\t\t\t\t\t\tif (card == null)\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tnewLeaf.getState().getTrash().remove(card);\n\t\t\t\t\t\tplayer.getBoard().addCard(card);\n\t\t\t\t\t\tif (card.getEffects() != null)\n\t\t\t\t\t\t\tfor (Effect effect : card.getEffects())\n\t\t\t\t\t\t\t\tif (effect.getType() == EffectType.WHEN_PLAYED)\n\t\t\t\t\t\t\t\t\teffect.run(player, Main.getSWController().getGame());\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tnewLeaf.getState().setCurrentPlayer((newLeaf.getState().getCurrentPlayer() + 1) % newLeaf.getState().getPlayers().size());\n\n\t\t\t\tif (newLeaf.getState().getCurrentPlayer() == newLeaf.getState().getFirstPlayer()) {\n\t\t\t\t\tif (newLeaf.getState().getRound() < GameController.NUM_ROUNDS)\n\t\t\t\t\t\tMain.getSWController().getGameController().nextRound(Main.getSWController().getGame(), newLeaf.getState());\n\t\t\t\t\telse // stop look-ahead at the end of age\n\t\t\t\t\t\tbreakAfterwards = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tleaves.clear();\n\t\t\tleaves.addAll(newLeaves);\n\n\t\t\tif (breakAfterwards)\n\t\t\t\tbreak;\n\t\t}\n\n\t\tfinished.value = true;\n\n\t\treturn tree;\n\t}", "public void enemySpawner(){\n\t\tif (spawnFrame >= spawnTime){\n\t\t\tfor(int i =0;i<enemies.size();i++){\n\t\t\t\tif (!enemies.get(i).getInGame()){\n\t\t\t\t\tenemies.get(i).spawnEnemy(Map.enemy);\n\t\t\t\t\tbreak;\n\t\t\t\t\t/*if (enemies.get(i).getNum()==1){\n\t\t\t\t\t\tenemies.get(i).spawnEnemy(Map.enemy1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} else if (enemies.get(i).getNum()==2){\n\t\t\t\t\t\tenemies.get(i).spawnEnemy(Map.enemy2);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} else if (enemies.get(i).getNum()==3){\n\t\t\t\t\t\tenemies.get(i).spawnEnemy(Map.enemy3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}*/\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t\tspawnFrame=0;\n\t\t} else{\n\t\t\tspawnFrame+=1;\n\t\t}\n\t}", "@SuppressWarnings(\"unused\")\n void spawn(Entity entity);", "private void makeBoss()\r\n {\r\n maxHealth = 1000;\r\n health = maxHealth;\r\n \r\n weapon = new Equip(\"Claws of Death\", Equip.WEAPON, 550);\r\n armor = new Equip(\"Inpenetrable skin\", Equip.ARMOR, 200);\r\n }", "private Individual<T> createChild(List<Individual<T>> tournament) {\n Individual<T> child = mate(tournament.get(0), tournament.get(1));\n child = mutate(child);\n child = child.evaluate();\n return child;\n }", "private void spawnStuff(PlayScreen screen, float delta) {\n if (stageId!=3 && stageId!=5) {\n isCombatEnabled = true;\n int where;\n boolean spawnRight = true;\n float speed;\n\n\n //Alien Spawn\n if (System.currentTimeMillis() - lastASpawn >= SpawnATimer + extraTimer) {\n speed = (float)(Utils.doRandom(250,400));\n lastASpawn = System.currentTimeMillis();\n int count = 3;\n if (stageId==4) count = 1;\n for (int i = 0; i < count; i++) {\n if (stageId==4){\n speed = (float) (speed*0.75);\n where = Utils.doRandom(0,100);\n if (where < 50){\n spawnRight = true;\n }else{\n spawnRight = false;\n }\n\n }\n if (spawnRight) {\n int x = (int) screen.gameViewport.getWorldWidth();\n int y = 0;\n boolean hits = true;\n while (hits) {\n hits = false;\n y = screen.random.nextInt((int) screen.gameViewport.getWorldHeight() - Alien.height);\n for (int h = 0; h < collisions.size(); h++) {\n if (Collision.checkWalls(collisions.get(h), new Rectangle(x - Alien.width, y, Alien.width, Alien.height)))\n hits = true;\n }\n }\n screen.entities.add(new Alien(new Vector2(x, y), 1, screen.alienImages, speed, screen.player));\n }else{\n int x = 0 - Alien.width;\n int y = 0;\n boolean hits = true;\n while (hits) {\n hits = false;\n y = screen.random.nextInt((int) screen.gameViewport.getWorldHeight() - Alien.height);\n for (int h = 0; h < collisions.size(); h++) {\n if (Collision.checkWalls(collisions.get(h), new Rectangle(x + Alien.width*2 , y, Alien.width, Alien.height)))\n hits = true;\n }\n }\n screen.entities.add(new Alien(new Vector2(x, y), 1, screen.alienImages, speed, screen.player,false));\n }\n }\n }\n //AcidAlien Spawn\n if (System.currentTimeMillis() - lastBSpawn >= SpawnBTimer + extraTimer) {\n speed = 200;\n lastBSpawn = System.currentTimeMillis();\n if (stageId==4){\n speed = speed/2;\n where = Utils.doRandom(0,100);\n if (where < 50){\n spawnRight = true;\n }else{\n spawnRight = false;\n }\n\n }\n if (spawnRight) {\n int x = (int) screen.gameViewport.getWorldWidth();\n int y = 0;\n boolean hits = true;\n while (hits) {\n hits = false;\n y = screen.random.nextInt((int) screen.gameViewport.getWorldHeight() - AcidAlien.height);\n for (int h = 0; h < collisions.size(); h++) {\n if (Collision.checkWalls(collisions.get(h), new Rectangle(x - AcidAlien.width, y, AcidAlien.width, AcidAlien.height)))\n hits = true;\n }\n }\n screen.entities.add(new AcidAlien(new Vector2(x, y), screen.alien2Images, screen.acidImage, speed, screen.player));\n }else{\n int x = 0 - AcidAlien.width;\n int y = 0;\n boolean hits = true;\n while (hits) {\n hits = false;\n y = screen.random.nextInt((int) screen.gameViewport.getWorldHeight() - AcidAlien.height);\n for (int h = 0; h < collisions.size(); h++) {\n if (Collision.checkWalls(collisions.get(h), new Rectangle(x + AcidAlien.width*2, y, AcidAlien.width, AcidAlien.height)))\n hits = true;\n }\n }\n screen.entities.add(new AcidAlien(new Vector2(x, y), screen.alien2Images, screen.acidImage, speed, screen.player,false));\n }\n }\n //FastAlien Spawn\n if (System.currentTimeMillis() - lastCSpawn >= SpawnCTimer + extraTimer) {\n speed= Utils.doRandom(250,400);\n lastCSpawn = System.currentTimeMillis();\n if (stageId==4){\n speed = speed/2;\n where = Utils.doRandom(0,100);\n if (where < 50){\n spawnRight = true;\n }else{\n spawnRight = false;\n }\n\n }\n if (spawnRight) {\n int x = (int) screen.gameViewport.getWorldWidth();\n int y = 0;\n boolean hits = true;\n while (hits) {\n hits = false;\n y = screen.random.nextInt((int) screen.gameViewport.getWorldHeight() - FastAlien.height);\n for (int h = 0; h < collisions.size(); h++) {\n if (Collision.checkWalls(collisions.get(h), new Rectangle(x - FastAlien.width, y, FastAlien.width, FastAlien.height)))\n hits = true;\n }\n }\n screen.entities.add(new FastAlien(new Vector2(x, y), 1, screen.alien3Images,speed, screen.player));\n }else{\n int x = 0 - FastAlien.width;\n int y =0;\n boolean hits = true;\n while (hits) {\n hits = false;\n y = screen.random.nextInt((int) screen.gameViewport.getWorldHeight() - FastAlien.height);\n for (int h=0;h<collisions.size();h++){\n if (Collision.checkWalls(collisions.get(h),new Rectangle(x-FastAlien.width*2,y,FastAlien.width,FastAlien.height))) hits = true;\n }\n }\n screen.entities.add(new FastAlien(new Vector2(x, y), 1, screen.alien3Images, speed,screen.player,false));\n }\n\n }\n\n //Item Spawn\n if (System.currentTimeMillis() - lastCapsuleSpawn >= SpawnTimerCapsule ) {\n speed = 500;\n int x = 0;\n int y = 0;\n lastCapsuleSpawn = System.currentTimeMillis();\n if (stageId==4){\n speed = speed/2;\n where = Utils.doRandom(0,100);\n if (where < 50){\n spawnRight = true;\n }else{\n spawnRight = false;\n }\n\n }\n if (spawnRight) {\n x = (int) screen.gameViewport.getWorldWidth();\n y = 0;\n boolean hits = true;\n while (hits) {\n hits = false;\n y = screen.random.nextInt((int) screen.gameViewport.getWorldHeight() - BlueBulletItem.height);\n for (int h = 0; h < collisions.size(); h++) {\n if (Collision.checkWalls(collisions.get(h), new Rectangle(x - BlueBulletItem.width, y, BlueBulletItem.width, BlueBulletItem.height)))\n hits = true;\n }\n }\n }else{\n x = 0 - BlueBulletItem.width;\n y = 0;\n boolean hits = true;\n while (hits) {\n hits = false;\n y = screen.random.nextInt((int) screen.gameViewport.getWorldHeight() - BlueBulletItem.height);\n for (int h = 0; h < collisions.size(); h++) {\n if (Collision.checkWalls(collisions.get(h), new Rectangle(x + BlueBulletItem.width *2, y, BlueBulletItem.width, BlueBulletItem.height)))\n hits = true;\n }\n }\n }\n\n int capsule = screen.random.nextInt(2);\n\n if (capsule == 0) {\n if (spawnRight) {\n screen.items.add(new RedBulletItem(x, y, speed, screen.itemRedImages));\n }else{\n screen.items.add(new RedBulletItem(x, y, speed, screen.itemRedImages,false));\n }\n } else if (capsule == 1) {\n if (spawnRight) {\n screen.items.add(new BlueBulletItem(x, y, speed, screen.itemBlueImages));\n }else{\n screen.items.add(new BlueBulletItem(x, y, speed, screen.itemBlueImages,false));\n }\n }\n\n }\n if (System.currentTimeMillis() - lastHealthSpawn >= SpawnTimerHealth) {\n speed = 500;\n lastHealthSpawn = System.currentTimeMillis();\n if (stageId==4){\n speed = speed/2;\n where = Utils.doRandom(0,100);\n if (where < 50){\n spawnRight = true;\n }else{\n spawnRight = false;\n }\n\n }\n if (spawnRight) {\n int x = (int) screen.gameViewport.getWorldWidth();\n int y = 0;\n boolean hits = true;\n while (hits) {\n hits = false;\n y = screen.random.nextInt((int) screen.gameViewport.getWorldHeight() - BlueBulletItem.height);\n for (int h = 0; h < collisions.size(); h++) {\n if (Collision.checkWalls(collisions.get(h), new Rectangle(x - BlueBulletItem.width, y, BlueBulletItem.width, BlueBulletItem.height)))\n hits = true;\n }\n }\n screen.items.add(new GreenCapsuleItem(x, y, speed, screen.itemGreenImages));\n }else{\n int x = 0 - BlueBulletItem.width;\n int y = 0;\n boolean hits = true;\n while (hits) {\n hits = false;\n y = screen.random.nextInt((int) screen.gameViewport.getWorldHeight() - BlueBulletItem.height);\n for (int h = 0; h < collisions.size(); h++) {\n if (Collision.checkWalls(collisions.get(h), new Rectangle(x + BlueBulletItem.width*2, y, BlueBulletItem.width, BlueBulletItem.height)))\n hits = true;\n }\n }\n screen.items.add(new GreenCapsuleItem(x, y, speed, screen.itemGreenImages,false));\n }\n }\n /*if (System.currentTimeMillis() - lastBombSpawn >= SpawnTimerBomb) {\n lastBombSpawn = System.currentTimeMillis();\n int x = (int) screen.gameViewport.getWorldWidth();\n int y =0;\n boolean hits = true;\n while (hits) {\n hits = false;\n y = screen.random.nextInt((int) screen.gameViewport.getWorldHeight() - PurpleCapsuleItem.height);\n for (int h=0;h<collisions.size();h++){\n if (Collision.checkWalls(collisions.get(h),new Rectangle(x,y,PurpleCapsuleItem.width,PurpleCapsuleItem.height))) hits = true;\n }\n }\n screen.items.add(new PurpleCapsuleItem(x, y, 500, screen.itemPurpleImages));\n }*/\n }else{\n if (stageId==3) {\n //SPACE STAGE\n ///SPAWN ENEMY SHIP:\n //TODO\n if (PlayScreen.entities.size() == 1) {\n isCombatEnabled = false;\n //no enemy spawned, so spawn:\n if (spawnIterator >= killCount) {\n //TODO END STAGE\n } else {\n System.out.println(\"SPAWNS SHIP\");\n spawnIterator++;\n screen.entities.add(new EnemyShipOne(new Vector2(0, 0), 100, screen.enemyShipOne, true, screen.player));\n\n }\n }\n //Items:\n //Item Spawn\n if (System.currentTimeMillis() - lastCapsuleSpawn >= SpawnTimerCapsule) {\n lastCapsuleSpawn = System.currentTimeMillis();\n int x = (int) screen.gameViewport.getWorldWidth();\n int y = 0;\n boolean hits = true;\n while (hits) {\n hits = false;\n y = screen.random.nextInt((int) screen.gameViewport.getWorldHeight() - BlueBulletItem.height);\n for (int h = 0; h < collisions.size(); h++) {\n if (Collision.checkWalls(collisions.get(h), new Rectangle(x, y, BlueBulletItem.width, BlueBulletItem.height)))\n hits = true;\n }\n }\n screen.items.add(new BlackBulletItem(x, y, 1000, screen.itemBlackImages));\n\n\n }\n }else{\n if (stageId == 5){\n isCombatEnabled = true;\n float speed;\n boolean spawnRight=true;\n int where=0;\n //TODO FINAL STAGE\n if (!isBossSpawned){\n //TODO\n screen.entities.add(new Boss(new Vector2(PlayScreen.gameViewport.getWorldWidth(),PlayScreen.gameViewport.getWorldHeight()/2 - Boss.height/2),screen.player));\n isBossSpawned=true;\n }\n //Item Spawn\n if (System.currentTimeMillis() - lastCapsuleSpawn >= SpawnTimerCapsule ) {\n speed = 500;\n int x = 0;\n int y = 0;\n lastCapsuleSpawn = System.currentTimeMillis();\n if (stageId==4){\n speed = speed/2;\n where = Utils.doRandom(0,100);\n if (where < 50){\n spawnRight = true;\n }else{\n spawnRight = false;\n }\n\n }\n if (spawnRight) {\n x = (int) screen.gameViewport.getWorldWidth();\n y = 0;\n boolean hits = true;\n while (hits) {\n hits = false;\n y = screen.random.nextInt((int) screen.gameViewport.getWorldHeight() - BlueBulletItem.height);\n for (int h = 0; h < collisions.size(); h++) {\n if (Collision.checkWalls(collisions.get(h), new Rectangle(x - BlueBulletItem.width, y, BlueBulletItem.width, BlueBulletItem.height)))\n hits = true;\n }\n }\n }else{\n x = 0 - BlueBulletItem.width;\n y = 0;\n boolean hits = true;\n while (hits) {\n hits = false;\n y = screen.random.nextInt((int) screen.gameViewport.getWorldHeight() - BlueBulletItem.height);\n for (int h = 0; h < collisions.size(); h++) {\n if (Collision.checkWalls(collisions.get(h), new Rectangle(x + BlueBulletItem.width *2, y, BlueBulletItem.width, BlueBulletItem.height)))\n hits = true;\n }\n }\n }\n\n int capsule = screen.random.nextInt(2);\n\n if (capsule == 0) {\n if (spawnRight) {\n screen.items.add(new RedBulletItem(x, y, speed, screen.itemRedImages));\n }else{\n screen.items.add(new RedBulletItem(x, y, speed, screen.itemRedImages,false));\n }\n } else if (capsule == 1) {\n if (spawnRight) {\n screen.items.add(new BlueBulletItem(x, y, speed, screen.itemBlueImages));\n }else{\n screen.items.add(new BlueBulletItem(x, y, speed, screen.itemBlueImages,false));\n }\n }\n\n }\n if (System.currentTimeMillis() - lastHealthSpawn >= SpawnTimerHealth) {\n speed = 500;\n lastHealthSpawn = System.currentTimeMillis();\n if (stageId == 4) {\n speed = speed / 2;\n where = Utils.doRandom(0, 1);\n if (where < 50) {\n spawnRight = true;\n } else {\n spawnRight = false;\n }\n\n }\n if (spawnRight) {\n int x = (int) screen.gameViewport.getWorldWidth();\n int y = 0;\n boolean hits = true;\n while (hits) {\n hits = false;\n y = screen.random.nextInt((int) screen.gameViewport.getWorldHeight() - BlueBulletItem.height);\n for (int h = 0; h < collisions.size(); h++) {\n if (Collision.checkWalls(collisions.get(h), new Rectangle(x - BlueBulletItem.width, y, BlueBulletItem.width, BlueBulletItem.height)))\n hits = true;\n }\n }\n screen.items.add(new GreenCapsuleItem(x, y, speed, screen.itemGreenImages));\n } else {\n int x = 0 - BlueBulletItem.width;\n int y = 0;\n boolean hits = true;\n while (hits) {\n hits = false;\n y = screen.random.nextInt((int) screen.gameViewport.getWorldHeight() - BlueBulletItem.height);\n for (int h = 0; h < collisions.size(); h++) {\n if (Collision.checkWalls(collisions.get(h), new Rectangle(x + BlueBulletItem.width * 2, y, BlueBulletItem.width, BlueBulletItem.height)))\n hits = true;\n }\n }\n screen.items.add(new GreenCapsuleItem(x, y, speed, screen.itemGreenImages, false));\n }\n }\n //TODO\n }\n }\n }\n\n //run .update(delta) on all objects\n for (int i=0; i<screen.entities.size();i++){\n screen.entities.get(i).update(delta);\n }\n\n for (int i=0; i<screen.items.size();i++){\n screen.items.get(i).update(delta);\n }\n\n //labels set:\n screen.labelHealth.setText(\"Health: \" + screen.player.health + \"/\" + screen.player.maxHealth);\n if (scoreBased) {\n screen.labelInfo.setText(\"Score: \" + screen.player.score + \"/\" + scoreGoal);\n }else{\n if (killCount>0){\n screen.labelInfo.setText(\"Score: \" + screen.player.score + \"/\" + killCount);\n }else{\n if (boss){\n screen.labelInfo.setText(\"Boss: \"+screen.player.score + \"/\" + Boss.bossHealth);\n }else{\n screen.labelInfo.setText(\"\");\n }\n\n }\n }\n if (this.stageId == 999) {\n screen.labelInfo.setText(\"Score: \" + screen.player.score);\n }\n\n\n }", "@Override\r\n \tprotected void startProcess() {\n \t\tfor(int i = 0; i < inventoryStacks.length - 1; i++) {\r\n \t\t\tif(inventoryStacks[i] != null) {\r\n \t\t\t\tticksToProcess = (int)(TileEntityFurnace.getItemBurnTime(inventoryStacks[i]) * GENERATOR_TO_FURNACE_TICK_RATIO);\r\n \t\t\t\tdecrStackSize(i, 1);\r\n \t\t\t\tburning = true;\r\n \t\t\t}\r\n \t\t}\r\n \t}", "private void createChildren() {\n\t\t\n\t\tfor(int i=0;i<horizontal;i++) {\n\t\t\t\n\t\t\tAction a = new Action(i);\n\t\t\tif(!gameOver && actionIsValid(a)) {\n\t\t\t\t\n\t\t\t\tPlayer otherPlayer;\n\t\t\t\t\n\t\t\t\tif(player == Player.PLAYER_BLUE) {\n\t\t\t\t\totherPlayer = Player.PLAYER_RED;\n\t\t\t\t}else {\n\t\t\t\t\totherPlayer = Player.PLAYER_BLUE;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tPosition newPosition;\n\t\t\t\tnewPosition = new Position(a, ++moveCounter, otherPlayer, this);\n\t\t\t\tchildren.add(newPosition);\t\n\t\t\t}\n\t\t}\n\t}", "public void spawnEntity(String entityToSpawn,World world, int xplane, int yplane, int zplane)\n { \n \t//Spawn a creeper\n \tif(entityToSpawn.contentEquals(\"Cr\"))\n \t{\t\n \t\tEntityCreeper creeper = new EntityCreeper(world);\n \t\tcreeper.entityAge = -24000;\n \t\tcreeper.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(creeper);\n \t\treturn;\n \t}\n \t//Spawn an Enderman\n \tif(entityToSpawn.contentEquals(\"En\"))\n \t{\n \t\tEntityEnderman enderman = new EntityEnderman(world);\n \t\tenderman.entityAge = -24000;\n \t\tenderman.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(enderman);\n \t\treturn;\n \t}\n \t//Spawn a Skeleton\n \tif(entityToSpawn.contentEquals(\"Sk\"))\n \t{\n \t\tEntitySkeleton skeleton = new EntitySkeleton(world);\n \t\tskeleton.entityAge = -24000;\n \t\tskeleton.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(skeleton);\n \t\treturn;\n \t}\n \t//Spawn a Zombie\n \tif(entityToSpawn.contentEquals(\"Zo\"))\n \t{\n \t\tEntityZombie zombie = new EntityZombie(world);\n \t\tzombie.entityAge = -24000;\n \t\tzombie.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(zombie);\n \t\treturn;\n \t}\n \t//Spawn a Slime\n \tif(entityToSpawn.contentEquals(\"Sl\"))\n \t{\n \t\tEntitySlime slime = new EntitySlime(world);\n \t\tslime.entityAge = -24000;\n \t\tslime.setSlimeSize(3);\n \t\tslime.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(slime);\n \t\treturn;\n \t}\n \t//Spawn a Spider\n \tif(entityToSpawn.contentEquals(\"Sp\"))\n \t{\n \t\tEntitySpider spider = new EntitySpider(world);\n \t\tspider.entityAge = -24000;\n \t\tspider.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(spider);\n \t\treturn;\n \t}\n \t//Spawn a Cave Spider\n \tif(entityToSpawn.contentEquals(\"Cs\"))\n \t{\n \t\tEntityCaveSpider cavespider = new EntityCaveSpider(world);\n \t\tcavespider.entityAge = -24000;\n \t\tcavespider.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(cavespider);\n \t\treturn;\n \t}\n \t//Spawn a Ghast\n \tif(entityToSpawn.contentEquals(\"Gh\"))\n \t{\n \t\tEntityGhast ghast = new EntityGhast(world);\n \t\tghast.entityAge = -24000;\n \t\tghast.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(ghast);\n \t\treturn;\n \t}\n \t//Spawn a Blaze\n \tif(entityToSpawn.contentEquals(\"Bl\"))\n \t{\n \t\tEntityBlaze blaze = new EntityBlaze(world);\n \t\tblaze.entityAge = -24000;\n \t\tblaze.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(blaze);\n \t\treturn;\n \t}\n \t//Spawn a Magma Cube\n \tif(entityToSpawn.contentEquals(\"Ma\"))\n \t{\n \t\tEntityMagmaCube magmacube = new EntityMagmaCube(world);\n \t\tmagmacube.entityAge = -24000;\n \t\tmagmacube.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(magmacube);\n \t\treturn;\n \t}\n \t//Spawn a Dragon\n \tif(entityToSpawn.contentEquals(\"Dr\"))\n \t{\n \t\tEntityDragon dragon = new EntityDragon(world);\n \t\tdragon.entityAge = -24000;\n \t\tdragon.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(dragon);\n \t\treturn;\n \t}\n \t//Spawn a sheep\n \tif(entityToSpawn.contentEquals(\"Sh\"))\n \t{\n \t\tEntitySheep sheep = new EntitySheep(world);\n \t\tsheep.entityAge = -2;\n \t\tsheep.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(sheep);\n \t\treturn;\n \t}\n \t//Spawn a Cow\n \tif(entityToSpawn.contentEquals(\"Co\"))\n \t{\n \t\tEntityCow cow = new EntityCow(world);\n \t\tcow.entityAge = -2;\n \t\tcow.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(cow);\n \t\treturn;\n \t}\n \t//Spawn a Pig\n \tif(entityToSpawn.contentEquals(\"Pi\"))\n \t{\n \t\tEntityPig pig = new EntityPig(world);\n \t\tpig.entityAge = -2;\n \t\tpig.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(pig);\n \t\treturn;\n \t}\n \t//Spawn a Chicken\n \tif(entityToSpawn.contentEquals(\"Ch\"))\n \t{\n \t\tEntityChicken chicken = new EntityChicken(world);\n \t\tchicken.entityAge = -2;\n \t\tchicken.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(chicken);\n \t\treturn;\n \t}\n \t//Spawn a Ocelot\n \tif(entityToSpawn.contentEquals(\"Ch\"))\n \t{\n \t\tEntityOcelot ocelot = new EntityOcelot(world);\n \t\tocelot.entityAge = -2;\n \t\tocelot.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(ocelot);\n \t\treturn;\n \t}\n \t//Spawn a Pig Zombie\n \tif(entityToSpawn.contentEquals(\"Pz\"))\n \t{\n \t\tEntityPigZombie pigzombie = new EntityPigZombie(world);\n \t\tpigzombie.entityAge = -24000;\n \t\tpigzombie.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(pigzombie);\n \t\treturn;\n \t}\n \t//Spawn a boat\n \tif(entityToSpawn.contentEquals(\"Bo\"))\n \t{\n \t\tEntityBoat boat = new EntityBoat(world);\n \t\t//boat.entityAge = -2;\n \t\tboat.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(boat);\n \t\treturn;\n \t}\n \t//Spawn a Iron Golem\n \tif(entityToSpawn.contentEquals(\"Ir\"))\n \t{\n \t\tEntityIronGolem irongolem = new EntityIronGolem(world);\n \t\tirongolem.entityAge = -24000;\n \t\tirongolem.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(irongolem);\n \t\treturn;\n \t}\n \t//Spawn a Giant Zombie\n \tif(entityToSpawn.contentEquals(\"Gi\"))\n \t{\n \t\tEntityGiantZombie giant = new EntityGiantZombie(world);\n \t\tgiant.entityAge = -24000;\n \t\tgiant.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(giant);\n \t\treturn;\n \t}\n \t//Spawn a Mine Cart\n \tif(entityToSpawn.contentEquals(\"Mi\"))\n \t{\n \t\tEntityMinecart cart = new EntityMinecart(world);\n \t\t//cart.entityAge = -24000;\n \t\tcart.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(cart);\n \t\treturn;\n \t}\n \t//Spawn a Mooshroom\n \tif(entityToSpawn.contentEquals(\"Gi\"))\n \t{\n \t\tEntityMooshroom moosh = new EntityMooshroom(world);\n \t\tmoosh.entityAge = -2;\n \t\tmoosh.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(moosh);\n \t\treturn;\n \t}\n \t//Spawn a Sliver Fish\n \tif(entityToSpawn.contentEquals(\"Si\"))\n \t{\n \t\tEntitySilverfish silverfish = new EntitySilverfish(world);\n \t\tsilverfish.entityAge = -24000;\n \t\tsilverfish.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(silverfish);\n \t\treturn;\n \t}\n \t//Spawn a Snowman\n \tif(entityToSpawn.contentEquals(\"Sn\"))\n \t{\n \t\tEntitySnowman frosty = new EntitySnowman(world);\n \t\tfrosty.entityAge = -24000;\n \t\tfrosty.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(frosty);\n \t\treturn;\n \t}\n \t//Spawn a Squid\n \tif(entityToSpawn.contentEquals(\"Sq\"))\n \t{\n \t\tEntitySquid squid = new EntitySquid(world);\n \t\tsquid.entityAge = -2;\n \t\tsquid.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(squid);\n \t\treturn;\n \t}\n \t//Spawn a Villager\n \tif(entityToSpawn.contentEquals(\"Vi\"))\n \t{\n \t\tEntityVillager villager = new EntityVillager(world);\n \t\tvillager.entityAge = -2;\n \t\tvillager.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(villager);\n \t\treturn;\n \t}\n \t//Spawn a Wolf\n \tif(entityToSpawn.contentEquals(\"Wo\"))\n \t{\n \t\tEntityWolf wolf = new EntityWolf(world);\n \t\twolf.entityAge = -2;\n \t\twolf.setLocationAndAngles(xplane, yplane, zplane, 0, 0.0F);\n \t\tworld.spawnEntityInWorld(wolf);\n \t\treturn;\n \t}\n }", "void spawnZombies() throws InterruptedException {\r\n\t\tint current = zombies.size();\r\n\t\tint level = killed / 5 + 1;\r\n\t\tif (level-current > 0) planted = 0;\r\n\t\tfor (int i = 0; i < level - current; i++) {\r\n\t\t\tZombie nieuwe = new Zombie(level*3);\r\n\t\t\tnieuwe.start();\r\n\t\t\tzombies.add(nieuwe);\r\n\t\t}\r\n\t}", "@Override\n\tpublic void onAdd() {\n\t\tsuper.onAdd();\n\n\t\tsetIdleAnimation(4527);\n\t\tsetNeverRandomWalks(true);\n\t\tsetWalkingHomeDisabled(true);\n\n\t\tthis.region = Stream.of(AbyssalSireRegion.values()).filter(r -> r.getSire().getX() == getSpawnPositionX()\n\t\t && r.getSire().getY() == getSpawnPositionY()).findAny().orElse(null);\n\n\t\tRegion region = Region.getRegion(getSpawnPositionX(), getSpawnPositionY());\n\n\t\tif (region != null) {\n\t\t\tregion.forEachNpc(npc -> {\n\t\t\t\tif (npc instanceof AbyssalSireTentacle) {\n\t\t\t\t\tif (!npc.isDead()) {\n\t\t\t\t\t\tnpc.setDead(true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tList<Position> tentaclePositions = Arrays.asList(\n\t\t\t\tthis.region.getTentacleEast(),\n\t\t\t\tthis.region.getTentacleWest(),\n\t\t\t\tthis.region.getTentacleNorthEast(),\n\t\t\t\tthis.region.getTentacleNorthWest(),\n\t\t\t\tthis.region.getTentacleSouthEast(),\n\t\t\t\tthis.region.getTentacleSouthWest()\n\t\t );\n\n\t\ttentaclePositions.forEach(position -> {\n\t\t\ttentacles.add(NpcHandler.spawnNpc(5909, position.getX(), position.getY(), position.getZ()));\n\t\t});\n\n\t\tList<Position> respiratoryPositions = Arrays.asList(\n\t\t\t\tthis.region.getRespiratorySystemNorthEast(),\n\t\t\t\tthis.region.getRespiratorySystemNorthWest(),\n\t\t\t\tthis.region.getRespiratorySystemSouthEast(),\n\t\t\t\tthis.region.getRespiratorySystemSouthWest()\n\t\t );\n\n\t\trespiratoryPositions.forEach(position -> respiratorySystems.add(\n\t\t\t\tNpcHandler.spawnNpc(5914, position.getX(), position.getY(), position.getZ())));\n\t}", "public void respawnAll(Player player) {\r\n\t\tfor(Integer eid : entityIDs) {\r\n\t\t\tItem3DInfo info = entityInfo.get(eid);\r\n\t\t\tint standID = standIDs.get(eid);\r\n\t\t\t\r\n\t\t\tspawnOldZombie(player, info.getWorldName(), info.getX(), info.getY(), info.getZ(),\r\n\t\t\t\t\tinfo.getRotation(), info.getItemID(), eid, standID);\r\n\t\t}\r\n\t}", "public void addSpawners(Room room) {\n\t\tint shiftX = (map.chunkX * 16) - (map.room.length / 2) + 8;\n\t\tint shiftZ = (map.chunkZ * 16) - (map.room.length / 2) + 8;\n\t\t//for(Room room : rooms) {\t\t\t\n\t\t\t//DoomlikeDungeons.profiler.startTask(\"Adding to room \" + room.id);\n\t\t\tfor(Spawner spawner : room.spawners) {\n\t\t\t\t\tDBlock.placeSpawner(map.world, shiftX + spawner.x, spawner.y, shiftZ + spawner.z, spawner.mob);\n\t\t\t}\n\t\t\tfor(BasicChest chest : room.chests) {\n\t\t\t\tchest.place(map.world, shiftX + chest.mx, chest.my, shiftZ + chest.mz, random);\n\t\t\t}\n\t\t\t//DoomlikeDungeons.profiler.endTask(\"Adding to room \" + room.id);\n\t\t//}\t\n\t}", "@Override\n public void run() {\n World world=Bukkit.getWorld(\"world\");\n world.spawnEntity(world.getHighestBlockAt(world.getSpawnLocation()).getLocation(), EntityType.VILLAGER);\n }", "public GameObject spawnBomber(LogicEngine in_logicEngine){\n\t\tGameObject ship = new GameObject(\"data/\"+GameRenderer.dpiFolder+\"/bomber.png\",((float)LogicEngine.SCREEN_WIDTH)+50,LogicEngine.SCREEN_HEIGHT-50,0);\r\n\t\tship.i_animationFrameSizeHeight = 58;\r\n\t\tship.i_animationFrameSizeWidth = 58;\r\n\t\t\r\n\t\t//fly back and forth\r\n\t\tLoopWaypointsStep s = new LoopWaypointsStep();\r\n\t\ts.waypoints.add(new Point2d(-30,LogicEngine.SCREEN_HEIGHT-50));\r\n\t\ts.waypoints.add(new Point2d(LogicEngine.SCREEN_WIDTH+50,LogicEngine.SCREEN_HEIGHT-50));\r\n\t\t\r\n\t\tship.b_mirrorImageHorizontal = true;\r\n\t\t\r\n\t\tship.stepHandlers.add(s);\r\n\t\tship.v.setMaxForce(5.0f);\r\n\t\tship.v.setMaxVel(5.0f);\r\n\t\tship.allegiance = GameObject.ALLEGIANCES.ENEMIES;\r\n\r\n\r\n\t\t//tadpole bullets\r\n\t\tGameObject go_tadpole = this.spawnTadpole(in_logicEngine);\r\n\t\tgo_tadpole.stepHandlers.clear();\r\n\t\tFlyStraightStep fly = new FlyStraightStep(new Vector2d(0,-0.5f));\r\n\t\tfly.setIsAccelleration(true);\r\n\t\t\r\n\t\t\r\n\t\tif(Difficulty.isHard())\r\n\t\t{\tgo_tadpole.v.setMaxVel(5);\r\n\t\t\tgo_tadpole.v.setMaxForce(5);\r\n\t\t}\r\n\t\telse\r\n\t\t{\tgo_tadpole.v.setMaxVel(10);\r\n\t\t\tgo_tadpole.v.setMaxForce(5);\r\n\t\t}\r\n\t\tgo_tadpole.stepHandlers.add(fly);\r\n\t\tgo_tadpole.v.setVel(new Vector2d(-2.5f,0f));\r\n\t\t\r\n\t\t\r\n\t\t//bounce on hard and medium\r\n\t\tif(Difficulty.isHard() || Difficulty.isMedium())\r\n\t\t{\r\n\t\t\tBounceOfScreenEdgesStep bounce = new BounceOfScreenEdgesStep();\r\n\t\t\tbounce.b_sidesOnly = true;\r\n\t\t\tgo_tadpole.stepHandlers.add(bounce);\r\n\t\t}\r\n\t\t\r\n\t\t//drop bombs\r\n\t\tLaunchShipsStep launch = new LaunchShipsStep(go_tadpole, 20, 5, 3, true);\r\n\t\tlaunch.b_addToBullets = true;\r\n\t\tlaunch.b_forceVelocityChangeBasedOnParentMirror = true;\r\n\t\t\r\n\t\tship.stepHandlers.add(launch);\r\n\t\tship.rotateToV=true;\r\n\t\t\r\n\t\t//give it some hp\r\n\t\tHitpointShipCollision c = new HitpointShipCollision(ship, 50, 50f);\r\n\t\tc.setSimpleExplosion();\r\n\t\tship.collisionHandler = c;\r\n\t\t\r\n\t\tin_logicEngine.objectsEnemies.add(ship);\r\n\t\t\r\n\t\treturn ship;\r\n\t\r\n\t}", "private void spawnMediumEnemy(IEnemyService spawner, World world, GameData gameData) {\r\n if (spawner != null) {\r\n spawner.createMediumEnemy(world, gameData, new Position(randomIntRange(1600, 3200), gameData.getGroundHeight()));\r\n spawner.createMediumEnemy(world, gameData, new Position(randomIntRange(-600, -2000), gameData.getGroundHeight()));\r\n }\r\n }", "private void gameTree(MinimaxNode<GameState> currentNode, int depth, int oIndex){\n currentNode.setNodeIndex(oIndex); \n if (depth == 0) {\n return;\n }\n else{\n if (currentNode.getState().isDead(oIndex)){ //checks to see if current player is dead, if so, just skips their moves\n int newIndex = (oIndex + 1) % currentNode.getState().getNrPlayers();\n/* if(oIndex == 3){\n newIndex = 0;\n }\n else{\n newIndex = oIndex + 1;\n }*/\n gameTree(currentNode, depth-1, newIndex);\n }\n else{\n //this if statement sets up chance nodes, if the target has been met it will create 5 children nodes with randomly generated new target postitions \n if(!currentNode.getState().hasTarget()){\n currentNode.setChanceNode();\n for(int i = 1; i <= 5; i++){\n try{\n GameState newState = (GameState)currentNode.getState().clone();\n newState.chooseNextTarget();\n MinimaxNode<GameState> childNode = new MinimaxNode(newState);\n childNode.setProbability(0.2);\n currentNode.addChild(childNode); \n }\n catch (CloneNotSupportedException e){\n System.out.println(\"Clone not excepted\");\n }\n \n }\n for (int i = 0; i < currentNode.getNumberOfChildren(); i++){\n gameTree(currentNode.getChildren().get(i), depth, oIndex);\n }\n\n }\n else{\n List<Integer> options = new ArrayList();\n for (int i = 1; i <= 4; i++) {\n if (currentNode.getState().isLegalMove(oIndex, i)){\n options.add(i);\n }\n }\n for (int i = 0; i < options.size(); i++){\n try{\n GameState newState = (GameState)currentNode.getState().clone();\n newState.setOrientation(oIndex, options.get(i));\n newState.updatePlayerPosition(oIndex);\n MinimaxNode<GameState> childNode = new MinimaxNode(newState);\n currentNode.addChild(childNode);\n }\n catch (CloneNotSupportedException e){\n System.out.println(\"Clone not excepted\");\n }\n }\n int newIndex = (oIndex + 1) % currentNode.getState().getNrPlayers();\n /* if(oIndex == 3){\n newIndex = 0;\n }\n else{\n newIndex = oIndex + 1;\n }*/\n for (int i = 0; i < currentNode.getNumberOfChildren(); i++){\n gameTree(currentNode.getChildren().get(i), depth-1, newIndex);\n }\n } \n } \n }\n }", "private void spawnStart() {\n\t\tswitch (gameType) {\n\t\t\n\t\t}\n\t\tspawnCloud(10,1,0,0); //spawns base cloud\n\t\tspawnCloud(rng(7,10),6,rng(1,2),rng(2,3)); //spawns first clouds\n\t\tspawnCloud(rng(9,12),6,rng(1,2),rng(2,3));\n\t\t//spawnCloud(10,6,16,0);\n\t}", "public static void startHeroes(){\n\t\tCoordinate[] placement = map.getHeroSpawnPoints();\n\t\t\n\t\tplayer.setNumCharactersToSpawn(placement.length);\n\t\t\n\t\theroList = player.getCharacters();\n\t\t\n\t\tfor (int i = 0; i < placement.length; i++){\n\t\t\theroList[i].setCoordinate(placement[i]);\n\t\t}\n\t}", "private void obtainProblem(){\n followers = frame.getFollowers();\n followers = Math.min(followers, CreatureFactory.getStrongestMonster().getFollowers() * Formation.MAX_MEMBERS);\n maxCreatures = frame.getMaxCreatures();\n heroes = frame.getHeroes();//is this field needed?\n prioritizedHeroes = frame.getHeroes(Priority.ALWAYS);\n //create boss formation\n LinkedList<Creature> list = new LinkedList<>();\n list.add(frame.getBoss());\n bossFormation = new Formation(list);\n containsRandomBoss = bossFormation.containsRandomHeroes();\n yourRunes = frame.getYourRunes();\n for (int i = 0; i < Formation.MAX_MEMBERS; i++){\n //System.out.println(yourRunes[i]);\n if (!(yourRunes[i] instanceof Nothing)){\n hasRunes = true;\n //System.out.println(\"hasRunes\");\n break;\n }\n }\n \n NHWBEasy = heroes.length == 0 && prioritizedHeroes.length == 0 && frame.getBoss().getMainSkill().WBNHEasy() && !hasRunes && !containsRandomBoss;\n \n }", "@Override\n\t\t\tpublic void Execute()\n\t\t\t{\n\t\t\tSquare square = (Square) receiver;\n\t\t\t// The args for SpawnBuildingCommand are the X,Y coordinate for the Building used by the factory, \n\t\t\tIAsteroidGameFactory factory = GameBoard.Instance().GetFactory();\n\t\t\tSystem.out.println(\"Spawning Building at (\" + args[0] + \",\" + args[1] + \")\");\n\t\t\tsquare.Add(factory.MakeBuilding());\n\t\t\tGameBoard.Instance().IncrementBuildingCount();\n\t\t}", "@SuppressWarnings(\"unchecked\")\n public void run() throws Exception {\n \n String splitname = null;\n BytesWritable realBytes = null;\n if (splits != null) {\n splitname = splits[id].getClassName();\n realBytes = splits[id].getBytes();\n }\n \n BSPPeerImpl peer = new BSPPeerImpl(job, conf, new TaskAttemptID(\n new TaskID(job.getJobID(), id), id), new LocalUmbilical(), id,\n splitname, realBytes);\n \n bsp.setConf(conf);\n try {\n bsp.setup(peer);\n bsp.bsp(peer);\n } catch (Exception e) {\n LOG.error(\"Exception during BSP execution!\", e);\n }\n bsp.cleanup(peer);\n peer.clear();\n peer.close();\n }", "public void spawnAngels(final List<StandardAngel> angelsThisRound) {\n for (StandardAngel angel : angelsThisRound) {\n observer.updateAngelSpawn(angel);\n StandardPlayer p1;\n StandardPlayer p2;\n if (firstPlayerOnPos[angel.getPosR()][angel.getPosC()] != null\n && secondPlayerOnPos[angel.getPosR()][angel.getPosC()] != null) {\n if (firstPlayerOnPos[angel.getPosR()][angel.getPosC()].getId()\n < secondPlayerOnPos[angel.getPosR()][angel.getPosC()].getId()) {\n p1 = firstPlayerOnPos[angel.getPosR()][angel.getPosC()];\n p2 = secondPlayerOnPos[angel.getPosR()][angel.getPosC()];\n } else {\n p2 = firstPlayerOnPos[angel.getPosR()][angel.getPosC()];\n p1 = secondPlayerOnPos[angel.getPosR()][angel.getPosC()];\n }\n } else {\n p1 = firstPlayerOnPos[angel.getPosR()][angel.getPosC()];\n p2 = secondPlayerOnPos[angel.getPosR()][angel.getPosC()];\n }\n\n if (p1 != null) {\n if (angel.canInteract(p1)) {\n observer.updatePlayerInteraction(angel, p1);\n angel.applyEffect(angelEffects, p1);\n }\n }\n if (p2 != null) {\n if (angel.canInteract(p2)) {\n observer.updatePlayerInteraction(angel, p2);\n angel.applyEffect(angelEffects, p2);\n }\n }\n\n while (!deadPlayers[angel.getPosR()][angel.getPosC()].isEmpty()) {\n StandardPlayer deadPlayer = deadPlayers[angel.getPosR()][angel.getPosC()].peek();\n if (angel.canInteract(deadPlayer)) {\n deadPlayers[angel.getPosR()][angel.getPosC()].poll();\n observer.updatePlayerInteraction(angel, deadPlayer);\n angel.applyEffect(angelEffects, deadPlayer);\n } else {\n break;\n }\n }\n }\n }", "private void placeBombs() {\n\t\tfor (int i = 0; i < NUM_BOMBS; i++) {\n\t\t\tplaceBomb();\n\t\t}\n\t}", "protected boolean func_225557_a_(IWorldGenerationReader worldgen, Random rand, BlockPos position, Set<BlockPos> changedBlocks, Set<BlockPos> changedBlocks2, MutableBoundingBox bbox, BaseTreeFeatureConfig conf) {\n/* 114 */ if (!(worldgen instanceof IWorld))\n/* 115 */ return false; \n/* 116 */ IWorld world = (IWorld)worldgen;\n/* 117 */ int height = rand.nextInt(5) + 4;\n/* 118 */ boolean spawnTree = true;\n/* 119 */ if (position.func_177956_o() >= 1 && position.func_177956_o() + height + 1 <= world.func_217301_I()) {\n/* 120 */ for (int j = position.func_177956_o(); j <= position.func_177956_o() + 1 + height; j++) {\n/* 121 */ int k = 1;\n/* 122 */ if (j == position.func_177956_o())\n/* 123 */ k = 0; \n/* 124 */ if (j >= position.func_177956_o() + height - 1)\n/* 125 */ k = 2; \n/* 126 */ for (int px = position.func_177958_n() - k; px <= position.func_177958_n() + k && spawnTree; px++) {\n/* 127 */ for (int pz = position.func_177952_p() - k; pz <= position.func_177952_p() + k && spawnTree; pz++) {\n/* 128 */ if (j >= 0 && j < world.func_217301_I()) {\n/* 129 */ if (!isReplaceable(world, new BlockPos(px, j, pz))) {\n/* 130 */ spawnTree = false;\n/* */ }\n/* */ } else {\n/* 133 */ spawnTree = false;\n/* */ } \n/* */ } \n/* */ } \n/* */ } \n/* 138 */ if (!spawnTree) {\n/* 139 */ return false;\n/* */ }\n/* 141 */ Block ground = world.func_180495_p(position.func_177982_a(0, -1, 0)).func_177230_c();\n/* 142 */ Block ground2 = world.func_180495_p(position.func_177982_a(0, -2, 0)).func_177230_c();\n/* 143 */ if ((ground != Blocks.field_196658_i.func_176223_P().func_177230_c() && ground != Blocks.field_150346_d.func_176223_P().func_177230_c()) || (ground2 != Blocks.field_196658_i\n/* 144 */ .func_176223_P().func_177230_c() && ground2 != Blocks.field_150346_d.func_176223_P().func_177230_c()))\n/* 145 */ return false; \n/* 146 */ BlockState state = world.func_180495_p(position.func_177977_b());\n/* 147 */ if (position.func_177956_o() < world.func_217301_I() - height - 1) {\n/* 148 */ setTreeBlockState(changedBlocks, (IWorldWriter)world, position.func_177977_b(), Blocks.field_150346_d.func_176223_P(), bbox); int genh;\n/* 149 */ for (genh = position.func_177956_o() - 3 + height; genh <= position.func_177956_o() + height; genh++) {\n/* 150 */ int i4 = genh - position.func_177956_o() + height;\n/* 151 */ int j1 = (int)(1.0D - i4 * 0.5D);\n/* 152 */ for (int k1 = position.func_177958_n() - j1; k1 <= position.func_177958_n() + j1; k1++) {\n/* 153 */ for (int i2 = position.func_177952_p() - j1; i2 <= position.func_177952_p() + j1; i2++) {\n/* 154 */ int j2 = i2 - position.func_177952_p();\n/* 155 */ if (Math.abs(position.func_177958_n()) != j1 || Math.abs(j2) != j1 || (rand.nextInt(2) != 0 && i4 != 0)) {\n/* 156 */ BlockPos blockpos = new BlockPos(k1, genh, i2);\n/* 157 */ state = world.func_180495_p(blockpos);\n/* 158 */ if (state.func_177230_c().isAir(state, (IBlockReader)world, blockpos) || state.func_185904_a().func_76230_c() || state\n/* 159 */ .func_203425_a(BlockTags.field_206952_E) || state.func_177230_c() == Blocks.field_150350_a.func_176223_P().func_177230_c() || state\n/* 160 */ .func_177230_c() == Blocks.field_150350_a.func_176223_P().func_177230_c()) {\n/* 161 */ setTreeBlockState(changedBlocks, (IWorldWriter)world, blockpos, Blocks.field_150350_a.func_176223_P(), bbox);\n/* */ }\n/* */ } \n/* */ } \n/* */ } \n/* */ } \n/* 167 */ for (genh = 0; genh < height; genh++) {\n/* 168 */ BlockPos genhPos = position.func_177981_b(genh);\n/* 169 */ state = world.func_180495_p(genhPos);\n/* 170 */ setTreeBlockState(changedBlocks, (IWorldWriter)world, genhPos, Blocks.field_196619_M.func_176223_P(), bbox);\n/* 171 */ if (state.func_177230_c().isAir(state, (IBlockReader)world, genhPos) || state.func_185904_a().func_76230_c() || state.func_203425_a(BlockTags.field_206952_E) || state\n/* 172 */ .func_177230_c() == Blocks.field_150350_a.func_176223_P().func_177230_c() || state\n/* 173 */ .func_177230_c() == Blocks.field_150350_a.func_176223_P().func_177230_c());\n/* */ } \n/* */ \n/* 176 */ if (rand.nextInt(4) == 0 && height > 5) {\n/* 177 */ for (int hlevel = 0; hlevel < 2; hlevel++) {\n/* 178 */ for (Direction Direction : Direction.Plane.HORIZONTAL) {\n/* 179 */ if (rand.nextInt(4 - hlevel) == 0) {\n/* 180 */ Direction dir = Direction.func_176734_d();\n/* 181 */ setTreeBlockState(changedBlocks, (IWorldWriter)world, position.func_177982_a(dir.func_82601_c(), height - 5 + hlevel, dir.func_82599_e()), Blocks.field_150350_a\n/* 182 */ .func_176223_P(), bbox);\n/* */ } \n/* */ } \n/* */ } \n/* */ }\n/* 187 */ return true;\n/* */ } \n/* 189 */ return false;\n/* */ } \n/* */ \n/* */ \n/* 193 */ return false;\n/* */ }", "public void spawnFirstCreature(){\n\n\t\tif(spawnType.equalsIgnoreCase(\"worm\")){\n\t\t\tRuntimeObjectFactory.getObjectFromPool(\"worm\"+spawnId);\n\t\t}else if(spawnType.equalsIgnoreCase(\"antorc\"))\n\t\t\tRuntimeObjectFactory.getObjectFromPool(\"antorc\"+spawnId);\n\t\t\n\t\t//Add new event into pool which will spawn the rest of the worms ( -1 because this method already spawned one )\n\t\tEventPool.addEvent(new tEvent(this,\"spawnCreature\",sleepTime,spawnCount-1));\n\t}", "public void spawnInLattice() throws GameActionException {\n boolean isMyCurrentSquareGood = checkIfGoodSquare(Cache.CURRENT_LOCATION);\n\n // if in danger from muckraker, get out\n if (runFromMuckrakerMove() != 0) {\n return;\n }\n\n if (isMyCurrentSquareGood) {\n currentSquareIsGoodExecute();\n } else {\n currentSquareIsBadExecute();\n }\n\n }", "private void addSpawnsToList()\n\t{\n\t\tSPAWNS.put(1, new ESSpawn(1, GraciaSeeds.DESTRUCTION, new Location(-245790,220320,-12104), new int[]{TEMPORARY_TELEPORTER}));\n\t\tSPAWNS.put(2, new ESSpawn(2, GraciaSeeds.DESTRUCTION, new Location(-249770,207300,-11952), new int[]{TEMPORARY_TELEPORTER}));\n\t\t//Energy Seeds\n\t\tSPAWNS.put(3, new ESSpawn(3, GraciaSeeds.DESTRUCTION, new Location(-248360,219272,-12448), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(4, new ESSpawn(4, GraciaSeeds.DESTRUCTION, new Location(-249448,219256,-12448), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(5, new ESSpawn(5, GraciaSeeds.DESTRUCTION, new Location(-249432,220872,-12448), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(6, new ESSpawn(6, GraciaSeeds.DESTRUCTION, new Location(-248360,220888,-12448), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(7, new ESSpawn(7, GraciaSeeds.DESTRUCTION, new Location(-250088,219256,-12448), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(8, new ESSpawn(8, GraciaSeeds.DESTRUCTION, new Location(-250600,219272,-12448), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(9, new ESSpawn(9, GraciaSeeds.DESTRUCTION, new Location(-250584,220904,-12448), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(10, new ESSpawn(10, GraciaSeeds.DESTRUCTION, new Location(-250072,220888,-12448), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(11, new ESSpawn(11, GraciaSeeds.DESTRUCTION, new Location(-253096,217704,-12296), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(12, new ESSpawn(12, GraciaSeeds.DESTRUCTION, new Location(-253112,217048,-12288), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(13, new ESSpawn(13, GraciaSeeds.DESTRUCTION, new Location(-251448,217032,-12288), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(14, new ESSpawn(14, GraciaSeeds.DESTRUCTION, new Location(-251416,217672,-12296), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(15, new ESSpawn(15, GraciaSeeds.DESTRUCTION, new Location(-251416,217672,-12296), new int[]{ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(16, new ESSpawn(16, GraciaSeeds.DESTRUCTION, new Location(-251416,217016,-12280), new int[]{ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(17, new ESSpawn(17, GraciaSeeds.DESTRUCTION, new Location(-249752,217016,-12280), new int[]{ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(18, new ESSpawn(18, GraciaSeeds.DESTRUCTION, new Location(-249736,217688,-12296), new int[]{ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(19, new ESSpawn(19, GraciaSeeds.DESTRUCTION, new Location(-252472,215208,-12120), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(20, new ESSpawn(20, GraciaSeeds.DESTRUCTION, new Location(-252552,216760,-12248), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(21, new ESSpawn(21, GraciaSeeds.DESTRUCTION, new Location(-253160,216744,-12248), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(22, new ESSpawn(22, GraciaSeeds.DESTRUCTION, new Location(-253128,215160,-12096), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(23, new ESSpawn(23, GraciaSeeds.DESTRUCTION, new Location(-250392,215208,-12120), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(24, new ESSpawn(24, GraciaSeeds.DESTRUCTION, new Location(-250264,216744,-12248), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(25, new ESSpawn(25, GraciaSeeds.DESTRUCTION, new Location(-249720,216744,-12248), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(26, new ESSpawn(26, GraciaSeeds.DESTRUCTION, new Location(-249752,215128,-12096), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(27, new ESSpawn(27, GraciaSeeds.DESTRUCTION, new Location(-250280,216760,-12248), new int[]{ENERGY_SEED_FIRE,ENERGY_SEED_WIND,ENERGY_SEED_EARTH}));\n\t\tSPAWNS.put(28, new ESSpawn(28, GraciaSeeds.DESTRUCTION, new Location(-250344,216152,-12248), new int[]{ENERGY_SEED_FIRE,ENERGY_SEED_WIND,ENERGY_SEED_EARTH}));\n\t\tSPAWNS.put(29, new ESSpawn(29, GraciaSeeds.DESTRUCTION, new Location(-252504,216152,-12248), new int[]{ENERGY_SEED_FIRE,ENERGY_SEED_WIND,ENERGY_SEED_EARTH}));\n\t\tSPAWNS.put(30, new ESSpawn(30, GraciaSeeds.DESTRUCTION, new Location(-252520,216792,-12248), new int[]{ENERGY_SEED_FIRE,ENERGY_SEED_WIND,ENERGY_SEED_EARTH}));\n\t\tSPAWNS.put(31, new ESSpawn(31, GraciaSeeds.DESTRUCTION, new Location(-242520,217272,-12384), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY,ENERGY_SEED_DARKNESS}));\n\t\tSPAWNS.put(32, new ESSpawn(32, GraciaSeeds.DESTRUCTION, new Location(-241432,217288,-12384), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY,ENERGY_SEED_DARKNESS}));\n\t\tSPAWNS.put(33, new ESSpawn(33, GraciaSeeds.DESTRUCTION, new Location(-241432,218936,-12384), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY,ENERGY_SEED_DARKNESS}));\n\t\tSPAWNS.put(34, new ESSpawn(34, GraciaSeeds.DESTRUCTION, new Location(-242536,218936,-12384), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY,ENERGY_SEED_DARKNESS}));\n\t\tSPAWNS.put(35, new ESSpawn(35, GraciaSeeds.DESTRUCTION, new Location(-240808,217272,-12384), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE}));\n\t\tSPAWNS.put(36, new ESSpawn(36, GraciaSeeds.DESTRUCTION, new Location(-240280,217272,-12384), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE}));\n\t\tSPAWNS.put(37, new ESSpawn(37, GraciaSeeds.DESTRUCTION, new Location(-240280,218952,-12384), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE}));\n\t\tSPAWNS.put(38, new ESSpawn(38, GraciaSeeds.DESTRUCTION, new Location(-240792,218936,-12384), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE}));\n\t\tSPAWNS.put(39, new ESSpawn(39, GraciaSeeds.DESTRUCTION, new Location(-239576,217240,-12640), new int[]{ENERGY_SEED_WIND,ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(40, new ESSpawn(40, GraciaSeeds.DESTRUCTION, new Location(-239560,216168,-12640), new int[]{ENERGY_SEED_WIND,ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(41, new ESSpawn(41, GraciaSeeds.DESTRUCTION, new Location(-237896,216152,-12640), new int[]{ENERGY_SEED_WIND,ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(42, new ESSpawn(42, GraciaSeeds.DESTRUCTION, new Location(-237912,217256,-12640), new int[]{ENERGY_SEED_WIND,ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(43, new ESSpawn(43, GraciaSeeds.DESTRUCTION, new Location(-237896,215528,-12640), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(44, new ESSpawn(44, GraciaSeeds.DESTRUCTION, new Location(-239560,215528,-12640), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(45, new ESSpawn(45, GraciaSeeds.DESTRUCTION, new Location(-239560,214984,-12640), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(46, new ESSpawn(46, GraciaSeeds.DESTRUCTION, new Location(-237896,215000,-12640), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(47, new ESSpawn(47, GraciaSeeds.DESTRUCTION, new Location(-237896,213640,-12768), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(48, new ESSpawn(48, GraciaSeeds.DESTRUCTION, new Location(-239560,213640,-12768), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(49, new ESSpawn(49, GraciaSeeds.DESTRUCTION, new Location(-239544,212552,-12768), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(50, new ESSpawn(50, GraciaSeeds.DESTRUCTION, new Location(-237912,212552,-12768), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(51, new ESSpawn(51, GraciaSeeds.DESTRUCTION, new Location(-237912,211912,-12768), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(52, new ESSpawn(52, GraciaSeeds.DESTRUCTION, new Location(-237912,211400,-12768), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(53, new ESSpawn(53, GraciaSeeds.DESTRUCTION, new Location(-239560,211400,-12768), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(54, new ESSpawn(54, GraciaSeeds.DESTRUCTION, new Location(-239560,211912,-12768), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(55, new ESSpawn(55, GraciaSeeds.DESTRUCTION, new Location(-241960,214536,-12512), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER,ENERGY_SEED_FIRE}));\n\t\tSPAWNS.put(56, new ESSpawn(56, GraciaSeeds.DESTRUCTION, new Location(-241976,213448,-12512), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER,ENERGY_SEED_FIRE}));\n\t\tSPAWNS.put(57, new ESSpawn(57, GraciaSeeds.DESTRUCTION, new Location(-243624,213448,-12512), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER,ENERGY_SEED_FIRE}));\n\t\tSPAWNS.put(58, new ESSpawn(58, GraciaSeeds.DESTRUCTION, new Location(-243624,214520,-12512), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER,ENERGY_SEED_FIRE}));\n\t\tSPAWNS.put(59, new ESSpawn(59, GraciaSeeds.DESTRUCTION, new Location(-241976,212808,-12504), new int[]{ENERGY_SEED_WIND,ENERGY_SEED_EARTH}));\n\t\tSPAWNS.put(60, new ESSpawn(60, GraciaSeeds.DESTRUCTION, new Location(-241960,212280,-12504), new int[]{ENERGY_SEED_WIND,ENERGY_SEED_EARTH}));\n\t\tSPAWNS.put(61, new ESSpawn(61, GraciaSeeds.DESTRUCTION, new Location(-243624,212264,-12504), new int[]{ENERGY_SEED_WIND,ENERGY_SEED_EARTH}));\n\t\tSPAWNS.put(62, new ESSpawn(62, GraciaSeeds.DESTRUCTION, new Location(-243624,212792,-12504), new int[]{ENERGY_SEED_WIND,ENERGY_SEED_EARTH}));\n\t\tSPAWNS.put(63, new ESSpawn(63, GraciaSeeds.DESTRUCTION, new Location(-243640,210920,-12640), new int[]{ENERGY_SEED_DIVINITY,ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(64, new ESSpawn(64, GraciaSeeds.DESTRUCTION, new Location(-243624,209832,-12640), new int[]{ENERGY_SEED_DIVINITY,ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(65, new ESSpawn(65, GraciaSeeds.DESTRUCTION, new Location(-241976,209832,-12640), new int[]{ENERGY_SEED_DIVINITY,ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(66, new ESSpawn(66, GraciaSeeds.DESTRUCTION, new Location(-241976,210920,-12640), new int[]{ENERGY_SEED_DIVINITY,ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(67, new ESSpawn(67, GraciaSeeds.DESTRUCTION, new Location(-241976,209192,-12640), new int[]{ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(68, new ESSpawn(68, GraciaSeeds.DESTRUCTION, new Location(-241976,208664,-12640), new int[]{ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(69, new ESSpawn(69, GraciaSeeds.DESTRUCTION, new Location(-243624,208664,-12640), new int[]{ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(70, new ESSpawn(70, GraciaSeeds.DESTRUCTION, new Location(-243624,209192,-12640), new int[]{ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(71, new ESSpawn(71, GraciaSeeds.DESTRUCTION, new Location(-241256,208664,-12896), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY,ENERGY_SEED_DARKNESS}));\n\t\tSPAWNS.put(72, new ESSpawn(72, GraciaSeeds.DESTRUCTION, new Location(-240168,208648,-12896), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY,ENERGY_SEED_DARKNESS}));\n\t\tSPAWNS.put(73, new ESSpawn(73, GraciaSeeds.DESTRUCTION, new Location(-240168,207000,-12896), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY,ENERGY_SEED_DARKNESS}));\n\t\tSPAWNS.put(74, new ESSpawn(74, GraciaSeeds.DESTRUCTION, new Location(-241256,207000,-12896), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY,ENERGY_SEED_DARKNESS}));\n\t\tSPAWNS.put(75, new ESSpawn(75, GraciaSeeds.DESTRUCTION, new Location(-239528,208648,-12896), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE}));\n\t\tSPAWNS.put(76, new ESSpawn(76, GraciaSeeds.DESTRUCTION, new Location(-238984,208664,-12896), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE}));\n\t\tSPAWNS.put(77, new ESSpawn(77, GraciaSeeds.DESTRUCTION, new Location(-239000,207000,-12896), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE}));\n\t\tSPAWNS.put(78, new ESSpawn(78, GraciaSeeds.DESTRUCTION, new Location(-239512,207000,-12896), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE}));\n\t\tSPAWNS.put(79, new ESSpawn(79, GraciaSeeds.DESTRUCTION, new Location(-245064,213144,-12384), new int[]{ENERGY_SEED_WIND,ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(80, new ESSpawn(80, GraciaSeeds.DESTRUCTION, new Location(-245064,212072,-12384), new int[]{ENERGY_SEED_WIND,ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(81, new ESSpawn(81, GraciaSeeds.DESTRUCTION, new Location(-246696,212072,-12384), new int[]{ENERGY_SEED_WIND,ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(82, new ESSpawn(82, GraciaSeeds.DESTRUCTION, new Location(-246696,213160,-12384), new int[]{ENERGY_SEED_WIND,ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(83, new ESSpawn(83, GraciaSeeds.DESTRUCTION, new Location(-245064,211416,-12384), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(84, new ESSpawn(84, GraciaSeeds.DESTRUCTION, new Location(-245048,210904,-12384), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(85, new ESSpawn(85, GraciaSeeds.DESTRUCTION, new Location(-246712,210888,-12384), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(86, new ESSpawn(86, GraciaSeeds.DESTRUCTION, new Location(-246712,211416,-12384), new int[]{ENERGY_SEED_DARKNESS,ENERGY_SEED_WATER}));\n\t\tSPAWNS.put(87, new ESSpawn(87, GraciaSeeds.DESTRUCTION, new Location(-245048,209544,-12512), new int[]{ENERGY_SEED_FIRE,ENERGY_SEED_WIND,ENERGY_SEED_EARTH}));\n\t\tSPAWNS.put(88, new ESSpawn(88, GraciaSeeds.DESTRUCTION, new Location(-245064,208456,-12512), new int[]{ENERGY_SEED_FIRE,ENERGY_SEED_WIND,ENERGY_SEED_EARTH}));\n\t\tSPAWNS.put(89, new ESSpawn(89, GraciaSeeds.DESTRUCTION, new Location(-246696,208456,-12512), new int[]{ENERGY_SEED_FIRE,ENERGY_SEED_WIND,ENERGY_SEED_EARTH}));\n\t\tSPAWNS.put(90, new ESSpawn(90, GraciaSeeds.DESTRUCTION, new Location(-246712,209544,-12512), new int[]{ENERGY_SEED_FIRE,ENERGY_SEED_WIND,ENERGY_SEED_EARTH}));\n\t\tSPAWNS.put(91, new ESSpawn(91, GraciaSeeds.DESTRUCTION, new Location(-245048,207816,-12512), new int[]{ENERGY_SEED_DIVINITY,ENERGY_SEED_DARKNESS}));\n\t\tSPAWNS.put(92, new ESSpawn(92, GraciaSeeds.DESTRUCTION, new Location(-245048,207288,-12512), new int[]{ENERGY_SEED_DIVINITY,ENERGY_SEED_DARKNESS}));\n\t\tSPAWNS.put(93, new ESSpawn(93, GraciaSeeds.DESTRUCTION, new Location(-246696,207304,-12512), new int[]{ENERGY_SEED_DIVINITY,ENERGY_SEED_DARKNESS}));\n\t\tSPAWNS.put(94, new ESSpawn(94, GraciaSeeds.DESTRUCTION, new Location(-246712,207816,-12512), new int[]{ENERGY_SEED_DIVINITY,ENERGY_SEED_DARKNESS}));\n\t\tSPAWNS.put(95, new ESSpawn(95, GraciaSeeds.DESTRUCTION, new Location(-244328,207272,-12768), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(96, new ESSpawn(96, GraciaSeeds.DESTRUCTION, new Location(-243256,207256,-12768), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(97, new ESSpawn(97, GraciaSeeds.DESTRUCTION, new Location(-243256,205624,-12768), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(98, new ESSpawn(98, GraciaSeeds.DESTRUCTION, new Location(-244328,205608,-12768), new int[]{ENERGY_SEED_WATER,ENERGY_SEED_FIRE,ENERGY_SEED_WIND}));\n\t\tSPAWNS.put(99, new ESSpawn(99, GraciaSeeds.DESTRUCTION, new Location(-242616,207272,-12768), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(100, new ESSpawn(100, GraciaSeeds.DESTRUCTION, new Location(-242104,207272,-12768), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(101, new ESSpawn(101, GraciaSeeds.DESTRUCTION, new Location(-242088,205624,-12768), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\tSPAWNS.put(102, new ESSpawn(102, GraciaSeeds.DESTRUCTION, new Location(-242600,205608,-12768), new int[]{ENERGY_SEED_EARTH,ENERGY_SEED_DIVINITY}));\n\t\t// Seed of Annihilation\n\t\tSPAWNS.put(103, new ESSpawn(103, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-184519,183007,-10456), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(104, new ESSpawn(104, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-184873,181445,-10488), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(105, new ESSpawn(105, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-184009,180962,-10488), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(106, new ESSpawn(106, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-185321,181641,-10448), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(107, new ESSpawn(107, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-184035,182775,-10512), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(108, new ESSpawn(108, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-185433,181935,-10424), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(109, new ESSpawn(109, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-183309,183007,-10560), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(110, new ESSpawn(110, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-184929,181886,-10488), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(111, new ESSpawn(111, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-184009,180392,-10424), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(112, new ESSpawn(112, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-183793,183239,-10488), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(113, new ESSpawn(113, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-184245,180848,-10464), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(114, new ESSpawn(114, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-182704,183761,-10528), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(115, new ESSpawn(115, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-184705,181886,-10504), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(116, new ESSpawn(116, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-184304,181076,-10488), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(117, new ESSpawn(117, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-183596,180430,-10424), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(118, new ESSpawn(118, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-184422,181038,-10480), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(119, new ESSpawn(119, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-184929,181543,-10496), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(120, new ESSpawn(120, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-184398,182891,-10472), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(121, new ESSpawn(121, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-177606,182848,-10584), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(122, new ESSpawn(122, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-178104,183224,-10560), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(123, new ESSpawn(123, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-177274,182284,-10600), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(124, new ESSpawn(124, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-177772,183224,-10560), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(125, new ESSpawn(125, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-181532,180364,-10504), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(126, new ESSpawn(126, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-181802,180276,-10496), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(127, new ESSpawn(127, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-178429,180444,-10512), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(128, new ESSpawn(128, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-177606,182190,-10600), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(129, new ESSpawn(129, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-177357,181908,-10576), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(130, new ESSpawn(130, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-178747,179534,-10408), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(131, new ESSpawn(131, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-178429,179534,-10392), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(132, new ESSpawn(132, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-178853,180094,-10472), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(133, new ESSpawn(133, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-181937,179660,-10416), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(134, new ESSpawn(134, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-180992,179572,-10416), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(135, new ESSpawn(135, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-185552,179252,-10368), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(136, new ESSpawn(136, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-184572,178913,-10400), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(137, new ESSpawn(137, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-184768,178348,-10312), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(138, new ESSpawn(138, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-184572,178574,-10352), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(139, new ESSpawn(139, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-185062,178913,-10384), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(140, new ESSpawn(140, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-181397,179484,-10416), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(141, new ESSpawn(141, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-181667,179044,-10408), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(142, new ESSpawn(142, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-185258,177896,-10240), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(143, new ESSpawn(143, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-183506,176570,-10280), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(144, new ESSpawn(144, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-183719,176804,-10240), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(145, new ESSpawn(145, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-183648,177116,-10240), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(146, new ESSpawn(146, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-183932,176492,-10240), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(147, new ESSpawn(147, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-183861,176570,-10240), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(148, new ESSpawn(148, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-183790,175946,-10240), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(149, new ESSpawn(149, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-178641,179604,-10416), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(150, new ESSpawn(150, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-178959,179814,-10432), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(151, new ESSpawn(151, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-176367,178456,-10376), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(152, new ESSpawn(152, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-175845,177172,-10264), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(153, new ESSpawn(153, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-175323,177600,-10248), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(154, new ESSpawn(154, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-174975,177172,-10216), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(155, new ESSpawn(155, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-176019,178242,-10352), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(156, new ESSpawn(156, GraciaSeeds.ANNIHILATION_BISTAKON, new Location(-174801,178456,-10264), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(157, new ESSpawn(157, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-185648,183384,-15680), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(158, new ESSpawn(158, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-186740,180908,-15528), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(159, new ESSpawn(159, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-185297,184658,-15680), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(160, new ESSpawn(160, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-185697,181601,-15488), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(161, new ESSpawn(161, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-186684,182744,-15536), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(162, new ESSpawn(162, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-184908,183384,-15616), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(163, new ESSpawn(163, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-184994,185572,-15784), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(164, new ESSpawn(164, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-185796,182616,-15608), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(165, new ESSpawn(165, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-184970,184385,-15648), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(166, new ESSpawn(166, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-185995,180809,-15512), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(167, new ESSpawn(167, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-185352,182872,-15632), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(168, new ESSpawn(168, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-185624,184294,-15680), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(169, new ESSpawn(169, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-184486,185774,-15816), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(170, new ESSpawn(170, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-186496,184112,-15680), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(171, new ESSpawn(171, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-184232,185976,-15816), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(172, new ESSpawn(172, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-184994,185673,-15792), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(173, new ESSpawn(173, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-185733,184203,-15680), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(174, new ESSpawn(174, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-185079,184294,-15680), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(175, new ESSpawn(175, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-184803,180710,-15528), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(176, new ESSpawn(176, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-186293,180413,-15528), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(177, new ESSpawn(177, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-185352,182936,-15632), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(178, new ESSpawn(178, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-184356,180611,-15496), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(179, new ESSpawn(179, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-185375,186784,-15816), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(180, new ESSpawn(180, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-184867,186784,-15816), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(181, new ESSpawn(181, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-180553,180454,-15152), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(182, new ESSpawn(182, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-180422,180454,-15152), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(183, new ESSpawn(183, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-181863,181138,-15120), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(184, new ESSpawn(184, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-181732,180454,-15152), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(185, new ESSpawn(185, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-180684,180397,-15152), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(186, new ESSpawn(186, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-182256,180682,-15112), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(187, new ESSpawn(187, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-185492,179492,-15392), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(188, new ESSpawn(188, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-185894,178538,-15336), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(189, new ESSpawn(189, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-186028,178856,-15336), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(190, new ESSpawn(190, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-185224,179068,-15336), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(191, new ESSpawn(191, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-185492,178538,-15336), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(192, new ESSpawn(192, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-185894,178538,-15336), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(193, new ESSpawn(193, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-180619,178855,-15152), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(194, new ESSpawn(194, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-180255,177892,-15152), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(195, new ESSpawn(195, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-185804,176472,-15336), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(196, new ESSpawn(196, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-184580,176370,-15320), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(197, new ESSpawn(197, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-184308,176166,-15320), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(198, new ESSpawn(198, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-183764,177186,-15304), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(199, new ESSpawn(199, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-180801,177571,-15144), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(200, new ESSpawn(200, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-184716,176064,-15320), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(201, new ESSpawn(201, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-184444,175452,-15296), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(202, new ESSpawn(202, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-180164,177464,-15152), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(203, new ESSpawn(203, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-180164,178213,-15152), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(204, new ESSpawn(204, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-179982,178320,-15152), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(205, new ESSpawn(205, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-176925,177757,-15824), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(206, new ESSpawn(206, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-176164,179282,-15720), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(207, new ESSpawn(207, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-175692,177613,-15800), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(208, new ESSpawn(208, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-175418,178117,-15824), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(209, new ESSpawn(209, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-176103,177829,-15824), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(210, new ESSpawn(210, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-175966,177325,-15792), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(211, new ESSpawn(211, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-174778,179732,-15664), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(212, new ESSpawn(212, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-175692,178261,-15824), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(213, new ESSpawn(213, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-176038,179192,-15736), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(214, new ESSpawn(214, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-175660,179462,-15680), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(215, new ESSpawn(215, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-175912,179732,-15664), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(216, new ESSpawn(216, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-175156,180182,-15680), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(217, new ESSpawn(217, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-174240,182059,-15664), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(218, new ESSpawn(218, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-175590,181478,-15640), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(219, new ESSpawn(219, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-174510,181561,-15616), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(220, new ESSpawn(220, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-174240,182391,-15688), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(221, new ESSpawn(221, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-174105,182806,-15672), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(222, new ESSpawn(222, GraciaSeeds.ANNIHILATION_REPTILIKON, new Location(-174645,182806,-15712), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(223, new ESSpawn(223, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-214962,182403,-10992), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(224, new ESSpawn(224, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-215019,182493,-11000), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(225, new ESSpawn(225, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-211374,180793,-11672), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(226, new ESSpawn(226, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-211198,180661,-11680), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(227, new ESSpawn(227, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-213097,178936,-12720), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(228, new ESSpawn(228, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-213517,178936,-12712), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(229, new ESSpawn(229, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-214105,179191,-12720), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(230, new ESSpawn(230, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-213769,179446,-12720), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(231, new ESSpawn(231, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-214021,179344,-12720), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(232, new ESSpawn(232, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-210582,180595,-11672), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(233, new ESSpawn(233, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-210934,180661,-11696), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(234, new ESSpawn(234, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-207058,178460,-12656), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(235, new ESSpawn(235, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-207454,179151,-11368), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(236, new ESSpawn(236, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-207422,181365,-11344), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(237, new ESSpawn(237, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-207358,180627,-11344), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(238, new ESSpawn(238, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-207230,180996,-11344), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(239, new ESSpawn(239, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-208515,184160,-11344), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(240, new ESSpawn(240, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-207613,184000,-11344), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(241, new ESSpawn(241, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-208597,183760,-11352), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(242, new ESSpawn(242, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-206710,176142,-12656), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(243, new ESSpawn(243, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-206361,178136,-11336), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(244, new ESSpawn(244, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-206178,178630,-12672), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(245, new ESSpawn(245, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-205738,178715,-12656), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(246, new ESSpawn(246, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-206442,178205,-12648), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(247, new ESSpawn(247, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-206585,178874,-11336), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(248, new ESSpawn(248, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-206073,179366,-11344), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(249, new ESSpawn(249, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-206009,178628,-11344), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(250, new ESSpawn(250, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-206155,181301,-12656), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(251, new ESSpawn(251, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-206595,181641,-12656), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(252, new ESSpawn(252, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-206507,181641,-12656), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(253, new ESSpawn(253, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-206507,181471,-12640), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(254, new ESSpawn(254, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-206974,175972,-12672), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(255, new ESSpawn(255, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-206304,175130,-11344), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(256, new ESSpawn(256, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-206886,175802,-12672), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(257, new ESSpawn(257, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-207238,175972,-12672), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(258, new ESSpawn(258, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-206386,174857,-11328), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(259, new ESSpawn(259, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-206386,175039,-11336), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(260, new ESSpawn(260, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-205976,174584,-11344), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(261, new ESSpawn(261, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-207367,184320,-11336), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(262, new ESSpawn(262, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219002,180419,-12608), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(263, new ESSpawn(263, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-218853,182790,-12592), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(264, new ESSpawn(264, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-218853,183343,-12600), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(265, new ESSpawn(265, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-218358,186247,-11344), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(266, new ESSpawn(266, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-218358,186083,-11344), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(267, new ESSpawn(267, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-217574,185796,-11352), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(268, new ESSpawn(268, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219178,181051,-12592), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(269, new ESSpawn(269, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-220171,180313,-11344), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(270, new ESSpawn(270, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219293,183738,-12592), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(271, new ESSpawn(271, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219381,182553,-12584), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(272, new ESSpawn(272, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219600,183024,-11336), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(273, new ESSpawn(273, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219940,182680,-11344), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(274, new ESSpawn(274, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219260,183884,-11344), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(275, new ESSpawn(275, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219855,183540,-11344), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(276, new ESSpawn(276, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-218946,186575,-11344), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(277, new ESSpawn(277, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219882,180103,-12592), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(278, new ESSpawn(278, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219266,179787,-12584), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(279, new ESSpawn(279, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219201,178337,-12592), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(280, new ESSpawn(280, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219716,179875,-11336), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(281, new ESSpawn(281, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219716,180021,-11328), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(282, new ESSpawn(282, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219989,179437,-11336), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(283, new ESSpawn(283, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219078,178298,-12592), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(284, new ESSpawn(284, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-218684,178954,-11328), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(285, new ESSpawn(285, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219089,178456,-11328), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(286, new ESSpawn(286, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-220266,177623,-12608), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(287, new ESSpawn(287, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219201,178025,-12592), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(288, new ESSpawn(288, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219142,177044,-12592), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(289, new ESSpawn(289, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219690,177895,-12592), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(290, new ESSpawn(290, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219754,177623,-12584), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(291, new ESSpawn(291, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-218791,177830,-12584), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(292, new ESSpawn(292, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-218904,176219,-12592), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(293, new ESSpawn(293, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-218768,176384,-12584), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(294, new ESSpawn(294, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-218774,177626,-11320), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(295, new ESSpawn(295, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-218774,177792,-11328), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(296, new ESSpawn(296, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219880,175901,-11344), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(297, new ESSpawn(297, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219210,176054,-12592), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(298, new ESSpawn(298, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219850,175991,-12608), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(299, new ESSpawn(299, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-219079,175021,-11336), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(300, new ESSpawn(300, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-218812,174229,-11344), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\tSPAWNS.put(301, new ESSpawn(301, GraciaSeeds.ANNIHILATION_COKRAKON, new Location(-218723,174669,-11336), new int[]{ ENERGY_SEED_WATER, ENERGY_SEED_FIRE, ENERGY_SEED_WIND, ENERGY_SEED_EARTH, ENERGY_SEED_DIVINITY, ENERGY_SEED_DARKNESS }));\n\t\t//@formatter:on\n\t}", "public void breakApart(final Asteroids asteroids)\n {\n Double2D location = asteroids.field.getObjectLocation(this);\n int[] sizes = breakMap[size][asteroids.random.nextInt(breakMap[size].length)];\n \n if (sizes.length > 0)\n {\n // break into asteroids\n int sum = 0;\n for(int i = 0; i < sizes.length; i++)\n sum += sizes[i];\n \n // compute velocities\n double explosionForce = asteroids.random.nextDouble() * (MAXIMUM_EXPLOSION_FORCE - MINIMUM_EXPLOSION_FORCE) + MINIMUM_EXPLOSION_FORCE;\n double sumForceX = 0;\n double sumForceY = 0;\n for(int i = 0; i < sizes.length; i++)\n {\n double angle = asteroids.random.nextDouble() * Math.PI * 2;\n double force = explosionForce / sizes.length;\n double forceX = force * Math.cos(angle);\n double forceY = force * Math.sin(angle);\n if (i == sizes.length - 1)\n { forceX = -sumForceX; forceY = -sumForceY; } // last one ought to balance out the others. It's best if it's the biggest one, hence why we list smaller asteroids first\n else { sumForceX += forceX; sumForceY += forceY; }\n // yes, this is a dead store\n Asteroid a = new Asteroid(asteroids, sizes[i], new MutableDouble2D(velocity.x + forceX, velocity.y + forceY), location);\n }\n }\n else\n {\n breakIntoShards(asteroids);\n }\n end(asteroids);\n asteroids.asteroidCount--;\n if (asteroids.asteroidCount <= 0)\n {\n asteroids.schedule.scheduleOnceIn(asteroids.WAIT_PERIOD, new Steppable()\n {\n public void step(SimState state)\n {\n asteroids.createAsteroids();\n }\n });\n }\n }", "private void explode()\r\n {\n isExploded = true;\r\n Color test = Color.hsb(Utils.getRandom(0, 360), 1, 1);\r\n for (int i = 0; i < 100; i++)\r\n {\r\n Color var = test;\r\n for (int j = 0; j < Utils.getRandomInt(5); j++)\r\n {\r\n var = var.brighter();\r\n }\r\n Firework mark1 = new Firework(this.x, this.y, var);\r\n Main.child.add(mark1.getNode());\r\n }\r\n reset();\r\n }", "@Override\r\n\t\tpublic void run() {\n\t\t\t\r\n\t\t\tnew BukkitRunnable() {\r\n\t\t\t\t\r\n\t\t\t\t@Override\r\n\t\t\t\tpublic void run() {\r\n\t\t\t\t\t// TODO Auto-generated method stub\r\n\t\t\t\t\t\r\n\t\t\t\t\tfor(Entity as: Bukkit.getWorld(\"world\").getEntities()) {\r\n\t\t\t\t\t\tif(as instanceof ArmorStand) {\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tas.remove();\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//TOPS\r\n\t\t\t\t\r\n\t\t\t\t\tif(MetodosWarps.containsWarp(\"topkills\")) {\r\n\t\t\t\t\t getTop(locTopKILLS,\"Kills\");\r\n\t\t\t\t\t\tBukkit.getConsoleSender().sendMessage(\" \\n žAžlTOP KILLS ATUALIZADO COM SUCESSO! \\n \");\t\r\n\t\t\t\t\t}else {\r\n\t\t\t\t\t\tBukkit.getConsoleSender().sendMessage(\" \\n žcžlO TOP KILLS NAO PODE SER CARREGADO, POIS A WARP topkills NAO ESTA SETADA! \\n \");\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif(MetodosWarps.containsWarp(\"topcoins\")) {\r\n\t\t\t\t\t getTop(locTopCoins,\"Coins\");\r\n\t\t\t\t\t\tBukkit.getConsoleSender().sendMessage(\" \\n žAžlTOP COINS ATUALIZADO COM SUCESSO! \\n \");\t\r\n\t\t\t\t\t}else {\r\n\t\t\t\t\t\tBukkit.getConsoleSender().sendMessage(\" \\n žcžlO TOP COINS NAO PODE SER CARREGADO, POIS A WARP topkills NAO ESTA SETADA! \\n \");\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif(MetodosWarps.containsWarp(\"top1v1\")) {\r\n\t\t\t\t\t getTop(locTop1v1,\"wins\");\r\n\t\t\t\t\t\tBukkit.getConsoleSender().sendMessage(\" \\n žAžlTOP 1v1 ATUALIZADO COM SUCESSO! \\n \");\t\r\n\t\t\t\t\t}else {\r\n\t\t\t\t\t\tBukkit.getConsoleSender().sendMessage(\" \\n žcžlO TOP 1v1 NAO PODE SER CARREGADO, POIS A WARP top1v1 NAO ESTA SETADA! \\n \");\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t//Caixa misteriosa\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(MetodosWarps.containsWarp(\"misteryBox\")) {\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t Spawn(misteryBox, \"žažlCAIXA MISTERIOSA\",misteryBox.getY()-1.7);\r\n\t\t\t\t\t Spawn(misteryBox, \"žežlEM BREVE!\",misteryBox.getY()-2);\r\n\t\t\t\t\t\tBukkit.getConsoleSender().sendMessage(\" \\n žAžlMYSTERYBOX ATUALIZADO COM SUCESSO! \\n \");\t\r\n\t\t\t\t\t}else {\r\n\t\t\t\t\t\tBukkit.getConsoleSender().sendMessage(\" \\n žcžlO TOP COINS NAO PODE SER CARREGADO, POIS A WARP misteryBox NAO ESTA SETADA! \\n \");\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}.runTaskLater(Main.plugin, 20);\r\n\t\t\t\r\n\t\t}", "public static void startSpawning(Grid grid, BlockManager<Block> blockManager) {\n BlockSpawner s = new BlockSpawner(grid, blockManager);\n //grid.setManager(blockManager);\n grid.setSpawner(s);\n s.run();\n }", "private void split(){\n // Slice horizontaly to get sub nodes width\n float subWidth = this.getBounds().width / 2;\n // Slice vertically to get sub nodes height\n float subHeight = this.getBounds().height / 2;\n float x = this.getBounds().x;\n float y = this.getBounds().y;\n int newLevel = this.level + 1;\n\n // Create the 4 nodes\n this.getNodes().add(0, new QuadTree(newLevel, new Rectangle(x + subWidth, y, subWidth, subHeight)));\n this.getNodes().add(1, new QuadTree(newLevel, new Rectangle(x, y, subWidth, subHeight)));\n this.getNodes().add(2, new QuadTree(newLevel, new Rectangle(x, y + subHeight, subWidth, subHeight)));\n this.getNodes().add(3, new QuadTree(newLevel, new Rectangle(x + subWidth, y + subHeight, subWidth, subHeight)));\n\n }", "private void splitIntoRoots() {\n\t\tArrayList<ArrayList<Coord>> circ = findCircles();\n\t\tcombinePastRoots(circ);\n\t}", "public void setSpawns() {\n List<Tile> spawns = this.board.getSpawns();// get all the possible spawns from board\n List<Tile> usedSpawns = new ArrayList<Tile>();// empty list used to represent all the spawns that have been used so no playerPiece gets the same spawn\n for (PlayerPiece playerPiece : this.playerPieces) { // for each playerPiece\n boolean hasSpawn = false; // boolean to represent whether the playerPiece has a spawn and used to initiate and stop the following while loop.\n while (!hasSpawn) { // while hasSpawn is false.\n int random_int = (int) (Math.random() * spawns.size());// get random number with max number of the total possible tiles the pieces can spawn from\n Tile spawn = spawns.get(random_int); // get spawn from spawns list using the random int as an index\n if (!usedSpawns.contains(spawn)) {// if the spawn isn't in the usedSpawn list\n playerPiece.setLocation(spawn);// set the location of the playerPiece to the spawn\n usedSpawns.add(spawn);//add the spawn to usedSpawns\n hasSpawn = true; // set the variable to true so the while loop stops.\n }\n }\n }\n }", "public void growthCycle() {\n\t\tboolean doMore = true;\n\t\tdo {\n\t\t\tdoMore = false;\n\t\t\tgrower = planter;\n\t\t\tCollections.shuffle(grower, random);\n\t\t\tplanter = new ArrayList<Room>();\n\t\t\tfor(Room room : grower) {\n\t\t\t\tif(rooms.size() >= size.maxRooms) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif(room.plantChildren(this)) {\n\t\t\t\t\t//System.out.println(\"Added side room.\");\n\t\t\t\t\tdoMore = true;\n\t\t\t\t}\n\t\t\t} \n\t\t} while(doMore);\t\t\n\t\t//DoomlikeDungeons.profiler.endTask(\"Adding Rooms (growthCycle)\");\n\t}", "public GameObject spawnCarrier(LogicEngine in_logicEngine, float in_x , CARRIER_TYPE in_type)\r\n\t{\n\t\tGameObject ship = new GameObject(\"data/\"+GameRenderer.dpiFolder+\"/thrusterboss.png\",in_x,LogicEngine.SCREEN_HEIGHT+64,30);\r\n\t\t\r\n\t\t\r\n\t\t//set animation frame\r\n\t\tship.i_animationFrame=4;\r\n\t\tship.i_animationFrameRow=0;\r\n\t\tship.i_animationFrameSizeWidth=32;\r\n\t\tship.i_animationFrameSizeHeight=132;\r\n\t\t\r\n\t\tSimplePathfollowing followPathBehaviour = new SimplePathfollowing();\r\n\t\t//pause at the first waypoint\r\n\t\tfollowPathBehaviour.waitAtWaypoint(1, 50);\r\n\t\t\r\n\t\tfollowPathBehaviour.setInfluence(1);\r\n\t\tfollowPathBehaviour.setAttribute(\"arrivedistance\", \"50\", null);\r\n\t\t\r\n\t\tfollowPathBehaviour.waitAtWaypoint(1, 300);\r\n\t\t\r\n\t\t//go straight down then split\r\n\t\tship.v.addWaypoint(new Point2d(in_x, LogicEngine.SCREEN_HEIGHT/1.5));\r\n\t\tship.v.addWaypoint(new Point2d(in_x,-100));\r\n\t\t\r\n\t\tCustomBehaviourStep b = new CustomBehaviourStep(followPathBehaviour);\r\n\t\t\r\n\t\t//turret\r\n\t\t//turret\r\n\t\tDrawable turret = new Drawable();\r\n\t\tturret.i_animationFrame = 6;\r\n\t\tturret.i_animationFrameSizeWidth=16;\r\n\t\tturret.i_animationFrameSizeHeight=16;\r\n\t\tturret.str_spritename = \"data/\"+GameRenderer.dpiFolder+\"/gravitonlevel.png\";\r\n\t\tturret.f_forceRotation = 90;\r\n\t\tship.shotHandler = new TurretShot(turret,\"data/\"+GameRenderer.dpiFolder+\"/redbullets.png\",6,5.0f);\r\n\t\tship.visibleBuffs.add(turret);\r\n\t\t\r\n\t\tship.v.setMaxForce(1);\r\n\t\tship.v.setMaxVel(1);\r\n\t\t\r\n\t\tship.stepHandlers.add(b);\r\n\t\t\r\n\t\tHitpointShipCollision s;\r\n\t\tif(!Difficulty.isHard())\r\n\t\t\t s = new HitpointShipCollision(ship, 160, 32);\r\n\t\telse\r\n\t\t\t s = new HitpointShipCollision(ship, 125, 32);\r\n\t\t\t\r\n\t\ts.setExplosion(Utils.getBossExplosion(ship));\r\n\t\tship.collisionHandler = s; \r\n\t\r\n\t\t//TODO:launch ships handler for shooting\r\n\t\tif(in_type == CARRIER_TYPE.PATHFINDERS_BOTH_SIDES)\r\n\t\t{\r\n\t\t\tship.stepHandlers.add(new LaunchShipsStep(pathFinder(true), 50, 5, 5,true));\r\n\t\t\tship.stepHandlers.add(new LaunchShipsStep(pathFinder(false), 50, 5, 5,false));\r\n\t\t}\r\n\t\telse\r\n\t\t\tif(in_type == CARRIER_TYPE.PATHFINDERS_RIGHT_ONLY)\r\n\t\t\t{\r\n\t\t\t\tship.stepHandlers.add(new LaunchShipsStep(pathFinder(true), 50, 5, 5,true));\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\tif(in_type == CARRIER_TYPE.PATHFINDERS_LEFT_ONLY)\r\n\t\t\t\t{\r\n\t\t\t\t\tship.stepHandlers.add(new LaunchShipsStep(pathFinder(false), 50, 5, 5,false));\r\n\t\t\t\t}\r\n\t\t\t\t\t\t \r\n\t\tship.allegiance = GameObject.ALLEGIANCES.ENEMIES;\r\n\t\t\r\n\t\tin_logicEngine.objectsEnemies.add(ship);\r\n\t\t\r\n\t\treturn ship;\r\n\t\r\n\t}", "public static void begin(int adults, int children, BoatGrader b) {\n\t\tSystem.out.println(\"\\n ***Testing Boats with \"+children+\" children , \"+adults +\"adults***\");\n\t\tbg = b;\n\t\t// 初始化变量\n\t\tchildrenO = children;\n\t\tadultO = adults;\n\t\tchildrenM = 0;\n\t\tadultM = 0;\n\t\tboatstate = EMPTY;\n\t\tboatO = true;\n\t\tlock = new Lock();\n\t\tchildrenonO = new Condition2(lock);\n\t\tchildrenonM = new Condition2(lock);\n\t\tadultonO = new Condition2(lock);\n\t\tisFinished = new Semaphore(0);// TODO 好好看看原理\n\n\t\t// Create threads here. See section 3.4 of the Nachos for Java\n\t\t// Walkthrough linked from the projects page.\n\t\t// 样例\n\t\t// Runnable r = new Runnable() {\n\t\t// public void run() {\n\t\t// SampleItinerary();\n\t\t// }\n\t\t// };\n\t\t// KThread t = new KThread(r);\n\t\t// t.setName(\"Sample Boat Thread\");\n\t\t// t.fork();\n\t\t// 创建大人孩子线程\n\t\tRunnable r = new Runnable() {\n\t\t\tpublic void run() {\n\t\t\t\tAdultItinerary();\n\t\t\t}\n\t\t};\n\t\tfor (int i = 1; i <= adults; i++) {\n\t\t\tnew KThread(r).setName(\"Adult \" + i).fork();\n\t\t}\n\t\tr = new Runnable() {\n\t\t\tpublic void run() {\n\t\t\t\tChildItinerary();\n\t\t\t}\n\t\t};\n\t\tfor (int i = 1; i <= children; i++) {\n\t\t\tnew KThread(r).setName(\"Child \" + i).fork();\n\t\t}\n\t\tisFinished.P();\n\t\tSystem.out.println(\"渡船结束\");\n\t}", "public void doTimeStep() {\r\n\t\twalk(getRandomInt(8));\r\n\t\tif (getEnergy() < 6 * Params.min_reproduce_energy && getEnergy() > Params.min_reproduce_energy) {\r\n\t\t\tCritter1 child = new Critter1();\r\n\t\t\treproduce(child, getRandomInt(8));\r\n\t\t\tnumberSpawned += 1;\r\n\t\t}else if(getEnergy() < Params.min_reproduce_energy) {\r\n\t\t\treturn;\r\n\t\t}else {\r\n\t\t\tCritter1 child1 = new Critter1();\r\n\t\t\treproduce(child1, getRandomInt(8));\r\n\t\t\tCritter1 child2 = new Critter1();\r\n\t\t\treproduce(child2, getRandomInt(8));\r\n\t\t\tnumberSpawned += 2;\r\n\t\t}\t\r\n\t}", "public int spawn() {\n int totalNumOfFryBorn = 0;\n Iterator<Guppy> it = guppiesInPool.iterator();\n ArrayList<Guppy> currentBabies = new ArrayList<>();\n\n while (it.hasNext()) {\n Guppy mother = it.next();\n ArrayList<Guppy> newBabies = mother.spawn();\n if (newBabies != null) {\n totalNumOfFryBorn += newBabies.size();\n currentBabies.addAll(newBabies);\n }\n }\n guppiesInPool.addAll(currentBabies);\n return totalNumOfFryBorn;\n }", "static void soldier() throws GameActionException {\n \tmoveToEdgeOfBase(true);\n\t\twhile (true) {\n\t\t\tClock.yield();\n\t\t}\n }", "public static void main(String[] args) {\n Hero aventurier = new Hero(200, 100);\n Equipement epee = new Equipement(\"epee\", 0);\n Monsters sorciere = new Monsters(\"witch\", 180, 0);\n Monsters barbare = new Monsters(\"olaf\", 160, 0);//Degat et point attaque sont à 0 car ils prendront les valeurs du random\n\n\n System.out.println(\"Bienvenue dans le dongeon\");\n System.out.println(\"Vous avez \" + aventurier.getPointDeVie() + \" Point de vie, \" + aventurier.getFlasqueDeau() + \" flasques pour combatre vos ennemies et une \");\n\n // i=room ;si pointdevie > room-->room+1 sinon game over(pas besoin de creer une classe)\n int i = 1;\n do {\n\n if (aventurier.getPointDeVie() > 0) ;\n {\n System.out.println(\"Room\" + i);\n\n Monsters enemieActuel = barbare;\n//nbr aleatoire entre sorcier et monster\n Random random = new Random();\n int nbrAl = random.nextInt(2 );\n//si nbr=0 = sorcier sinon barbare\n if (nbrAl == 0) {\n enemieActuel = sorciere;\n //sinon barbare\n } else {\n enemieActuel = barbare;\n }\n\n\n //Si barbare faire le do while\n\n if (enemieActuel == barbare) {\n\n do { //Faire des degats aleatoire grace au random à l'aide de l'epee\n epee.setDegat((int) (5 + (Math.random() * 30)));//comme .set dega=0 on lui donne la valeur de math.random\n int degat = epee.getDegat(); //.get renvoi la valeur au int nommer degat\n barbare.setPointDeVie(barbare.getPointDeVie() - degat);//vie - degat\n System.out.println(\"Il reste au barbare \" + barbare.getPointDeVie());//nouvelle valeur de point de vie\n\n\n //idem avec l'aventurier\n barbare.setPointAttaque((int) (5 + (Math.random() * 30)));\n int pointDattaque = barbare.getPointAttaque();\n aventurier.setPointDeVie(aventurier.getPointDeVie() - pointDattaque);\n System.out.println(\"il vous reste \" + aventurier.getPointDeVie());\n\n // tant que les Pvie de l'aventurier >= 0 et idem barbare continuer le combat\n } while (aventurier.getPointDeVie() >= 0 && barbare.getPointDeVie() >= 0);\n //à la fin du combat si pvie de l'aventurier sont >0 et que i (room) egale 5 \"gagné\"\n if (aventurier.getPointDeVie() > 0 && i==5) {\n System.out.println(\"Bravo vous avez gagné ! =)\");\n\n //Si juste pvie de l'aventurier > 0 --->room suivante\n }else if (aventurier.getPointDeVie() > 0 ){\n System.out.println(\"Bravo tu passes à la pièce suivante\");\n //on redonne les valeurs de depart pdeVie pour la nouvelle room\n aventurier.setPointDeVie(200);\n barbare.setPointDeVie(180);\n i+=1;\n }\n\n // sinon room = 6 pour envoyer le sout \"game over\"\n else {\n System.out.println(\"Game Over\");\n i = 6;\n }\n\n\n\n }\n\n //IDEM avec sorciere\n else {\n do {\n\n\n aventurier.setFlasqueDeau((int) (5 + (Math.random() * 30)));\n int degat = aventurier.getFlasqueDeau();\n sorciere.setPointDeVie(sorciere.getPointDeVie() - degat);\n System.out.println(\"Il reste à la sorciere \" + sorciere.getPointDeVie());\n\n sorciere.setPointAttaque((int) (5 + (Math.random() * 30)));\n int pointDattaque = sorciere.getPointAttaque();\n aventurier.setPointDeVie(aventurier.getPointDeVie() - pointDattaque);\n System.out.println(\"il vous reste \" + aventurier.getPointDeVie());\n\n } while (aventurier.getPointDeVie() >= 0 && sorciere.getPointDeVie() >= 0);\n if (aventurier.getPointDeVie() > 0 && i==5) {\n System.out.println(\"Bravo vous avez gagné ! =)\");\n }else if (aventurier.getPointDeVie() > 0 ){\n System.out.println(\"Bravo tu passes à la pièce suivante\");\n aventurier.setPointDeVie(200);\n sorciere.setPointDeVie(160);\n i+=1;\n }\n else {\n System.out.println(\"Game Over\");\n i = 6;\n }\n }\n } } while (i <= 5 && aventurier.getPointDeVie() > 0);\n\n\n }", "private void spawnZombie(int choose) {\n\t\tswitch (choose) {\n\t\tcase (0):\n\t\t// spawn one zombie at once.\n\t\t\tint r = (new Random()).nextInt(5);\n\t\t\tint r1 = (new Random()).nextInt(2);\n\t\t\tArrayList<AbstractZombie> z = new ArrayList();\n\t\t\tConeHeadZombie cz = new ConeHeadZombie();\n\t\t\tFastZombie fz = new FastZombie();\n\t\t\tz.add(cz);\n\t\t\tz.add(fz);\n\t\t\tAbstractZombie a = z.get(r1);\n\t\t\tthis.board.addModel(a, r, this.board.getLength() - 1);\n\t\t\tbreak;\n\n\t\tcase (1):\n\t\t// spawn two zombies at once.\n\t\t\tint r2 = (new Random()).nextInt(5);\n\t\t\tint r3 = (new Random()).nextInt(5);\n\t\t\tConeHeadZombie cr = new ConeHeadZombie();\n\t\t\tFastZombie fr = new FastZombie();\n\t\t\tif (r2 != r3) {\n\t\t\t\tthis.board.addModel(fr, r2, this.board.getLength() - 1);\n\t\t\t\tthis.board.addModel(cr, r3, this.board.getLength() - 1);\n\t\t\t} \n\t\t\tif (r2==r3){\n\t\t\twhile(r3==r2) {\n\t\t\t\tr2 = (new Random()).nextInt(5);\n\t\t\t\tr3 = (new Random()).nextInt(5);\n\t\t\t\t}\n\t\t\tthis.board.addModel(fr, r2, this.board.getLength() - 1);\n\t\t\tthis.board.addModel(cr, r3, this.board.getLength() - 1);\n\t\t\t}\n\t\t break;\n\t\t\n\t\tcase (2):\n\t\t// spawn three zombies at once\n\t\t\tint r4 = (new Random()).nextInt(5);\n\t\t int r5 = (new Random()).nextInt(5);\n\t\t int r6 = (new Random()).nextInt(5);\n\t\t ConeHeadZombie cq = new ConeHeadZombie();\n\t\t\tFastZombie fq = new FastZombie();\n\t\t\tConeHeadZombie cqq = new ConeHeadZombie();\n\t\t\tif (r4 != r5 && r4 !=r6 && r5 != r6 ) {\n\t\t\t\tthis.board.addModel(cqq, r4, this.board.getLength() - 1);\n\t\t\t\tthis.board.addModel(cq, r5, this.board.getLength() - 1);\n\t\t\t\tthis.board.addModel(fq, r6, this.board.getLength() - 1);\n\t\t\t} \n\t\t\telse {\n\t\t\t\twhile(r4==r5 || r5==r6 || r4==r6) {\n\t\t\t\tr4 = (new Random()).nextInt(5);\n\t\t\t\tr5 = (new Random()).nextInt(5);\n\t\t\t\tr6 = (new Random()).nextInt(5);\n\t\t\t }\n\t\t\t this.board.addModel(cqq,r5, this.board.getLength() - 1);\n\t\t\t this.board.addModel(cq, r4, this.board.getLength() - 1);\n\t\t\t this.board.addModel(fq, r6, this.board.getLength() - 1);\n\t\t break;\n\t\t\t}\n\t\t}\n\t}", "public void addRandoms() {\n //Add random boulders on tiles that aren't Lava\n int tileNumber;\n int selector;\n Tile t;\n String tileTexture;\n Random random = new Random();\n SquareVector playerPos = getPlayerEntity().getPosition();\n int tileCount = GameManager.get().getWorld().getTiles().size();\n AbstractWorld world = GameManager.get().getWorld();\n int randIndex;\n\n for (int i = 0; i < 20; i++) {\n //Get respective volcano tile (5 <= Lava tiles Index <= 8\n do {\n randIndex = random.nextInt(tileCount);\n t = world.getTile(randIndex);\n } while (t.getCoordinates().isCloseEnoughToBeTheSame(playerPos));\n\n tileTexture = t.getTextureName();\n tileNumber = Integer.parseInt(tileTexture.split(\"_\")[1]);\n\n selector = random.nextInt(2);\n if (tileNumber < 5 && tileNumber > 1 && selector == 1 && !t.hasParent()) {\n entities.add(new Rock(t, true));\n } else if (t != null && (tileNumber == 3 || tileNumber == 4) &&\n selector == 0 && !t.hasParent()) {\n entities.add(new VolcanoBurningTree(t, true));\n } else {\n i--;\n }\n }\n }", "public void spawnBoss(Vector2 spawnPosition) {\n\n Foe newBoss = new Foe(getController(), spawnPosition, \"boss\", 3.5f, new IABoss(getController()));\n newBoss.initialize();\n newBoss.setPlayerCanKill(false);\n newBoss.setFixedFacing(true);\n\n getController().getStage().registerActor(newBoss);\n }", "public Dungeon2Open() {\n\t\tsuper(objects, transitions, enemies, MapScreen.DUNGEON2, \"assets/bossRoomOpen.png\", spawn);\n\t\tobjects.add(new GameObject(new Point(0, 0)));\n\t\tobjects.add(new GameObject(new Point(0, 1)));\n\t\tobjects.add(new GameObject(new Point(0, 2)));\n\t\tobjects.add(new GameObject(new Point(0, 3)));\n\t\tobjects.add(new GameObject(new Point(0, 4)));\n\t\tobjects.add(new GameObject(new Point(0, 5)));\n\t\tobjects.add(new GameObject(new Point(0, 6)));\n\t\tobjects.add(new GameObject(new Point(0, 7)));\n\t\tobjects.add(new GameObject(new Point(0, 8)));\n\t\tobjects.add(new GameObject(new Point(0, 9)));\n\t\tobjects.add(new GameObject(new Point(0, 10)));\n\t\tobjects.add(new GameObject(new Point(0, 11)));\n\t\tobjects.add(new GameObject(new Point(0, 12)));\n\t\tobjects.add(new GameObject(new Point(0, 13)));\n\t\tobjects.add(new GameObject(new Point(17, 0)));\n\t\tobjects.add(new GameObject(new Point(17, 1)));\n\t\tobjects.add(new GameObject(new Point(17, 2)));\n\t\tobjects.add(new GameObject(new Point(17, 3)));\n\t\tobjects.add(new GameObject(new Point(17, 4)));\n\t\tobjects.add(new GameObject(new Point(17, 5)));\n\t\tobjects.add(new GameObject(new Point(17, 6)));\n\t\tobjects.add(new GameObject(new Point(17, 7)));\n\t\tobjects.add(new GameObject(new Point(17, 8)));\n\t\tobjects.add(new GameObject(new Point(17, 9)));\n\t\tobjects.add(new GameObject(new Point(17, 10)));\n\t\tobjects.add(new GameObject(new Point(17, 11)));\n\t\tobjects.add(new GameObject(new Point(17, 12)));\n\t\tobjects.add(new GameObject(new Point(17, 13)));\n\t\tobjects.add(new GameObject(new Point(1, 0)));\n\t\tobjects.add(new GameObject(new Point(2, 0)));\n\t\tobjects.add(new GameObject(new Point(3, 0)));\n\t\tobjects.add(new GameObject(new Point(4, 0)));\n\t\tobjects.add(new GameObject(new Point(5, 0)));\n\t\tobjects.add(new GameObject(new Point(6, 0)));\n\t\tobjects.add(new GameObject(new Point(7, 0)));\n\t\tobjects.add(new GameObject(new Point(8, 0)));\n\t\tobjects.add(new GameObject(new Point(9, 0)));\n\t\tobjects.add(new GameObject(new Point(10, 0)));\n\t\tobjects.add(new GameObject(new Point(11, 0)));\n\t\tobjects.add(new GameObject(new Point(12, 0)));\n\t\tobjects.add(new GameObject(new Point(13, 0)));\n\t\tobjects.add(new GameObject(new Point(14, 0)));\n\t\tobjects.add(new GameObject(new Point(15, 0)));\n\t\tobjects.add(new GameObject(new Point(16, 0)));\n\t\tobjects.add(new GameObject(new Point(1, 1)));\n\t\tobjects.add(new GameObject(new Point(3, 1)));\n\t\tobjects.add(new GameObject(new Point(4, 1)));\n\t\tobjects.add(new GameObject(new Point(5, 1)));\n\t\tobjects.add(new GameObject(new Point(6, 1)));\n\t\tobjects.add(new GameObject(new Point(7, 1)));\n\t\tobjects.add(new GameObject(new Point(8, 1)));\n\t\tobjects.add(new GameObject(new Point(9, 1)));\n\t\tobjects.add(new GameObject(new Point(10, 1)));\n\t\tobjects.add(new GameObject(new Point(11, 1)));\n\t\tobjects.add(new GameObject(new Point(12, 1)));\n\t\tobjects.add(new GameObject(new Point(13, 1)));\n\t\tobjects.add(new GameObject(new Point(14, 1)));\n\t\tobjects.add(new GameObject(new Point(15, 1)));\n\t\tobjects.add(new GameObject(new Point(16, 1)));\n\t\tobjects.add(new GameObject(new Point(1, 2)));\n\t\tobjects.add(new GameObject(new Point(3, 2)));\n\t\tobjects.add(new GameObject(new Point(4, 2)));\n\t\tobjects.add(new GameObject(new Point(5, 2)));\n\t\tobjects.add(new GameObject(new Point(6, 2)));\n\t\tobjects.add(new GameObject(new Point(7, 2)));\n\t\tobjects.add(new GameObject(new Point(8, 2)));\n\t\tobjects.add(new GameObject(new Point(9, 2)));\n\t\tobjects.add(new GameObject(new Point(10, 2)));\n\t\tobjects.add(new GameObject(new Point(11, 2)));\n\t\tobjects.add(new GameObject(new Point(12, 2)));\n\t\tobjects.add(new GameObject(new Point(13, 2)));\n\t\tobjects.add(new GameObject(new Point(14, 2)));\n\t\tobjects.add(new GameObject(new Point(15, 2)));\n\t\tobjects.add(new GameObject(new Point(16, 2)));\n\t\tobjects.add(new GameObject(new Point(1, 13)));\n\t\tobjects.add(new GameObject(new Point(2, 13)));\n\t\tobjects.add(new GameObject(new Point(3, 13)));\n\t\tobjects.add(new GameObject(new Point(4, 13)));\n\t\tobjects.add(new GameObject(new Point(5, 13)));\n\t\tobjects.add(new GameObject(new Point(6, 13)));\n\t\tobjects.add(new GameObject(new Point(7, 13)));\n\t\tobjects.add(new GameObject(new Point(8, 13)));\n\t\tobjects.add(new GameObject(new Point(9, 13)));\n\t\tobjects.add(new GameObject(new Point(10, 13)));\n\t\tobjects.add(new GameObject(new Point(11, 13)));\n\t\tobjects.add(new GameObject(new Point(12, 13)));\n\t\tobjects.add(new GameObject(new Point(13, 13)));\n\t\tobjects.add(new GameObject(new Point(15, 13)));\n\t\tobjects.add(new GameObject(new Point(16, 13)));\n\t\tobjects.add(new GameObject(new Point(1, 12)));\n\t\tobjects.add(new GameObject(new Point(2, 12)));\n\t\tobjects.add(new GameObject(new Point(3, 12)));\n\t\tobjects.add(new GameObject(new Point(4, 12)));\n\t\tobjects.add(new GameObject(new Point(5, 12)));\n\t\tobjects.add(new GameObject(new Point(6, 12)));\n\t\tobjects.add(new GameObject(new Point(7, 12)));\n\t\tobjects.add(new GameObject(new Point(8, 12)));\n\t\tobjects.add(new GameObject(new Point(9, 12)));\n\t\tobjects.add(new GameObject(new Point(10, 12)));\n\t\tobjects.add(new GameObject(new Point(11, 12)));\n\t\tobjects.add(new GameObject(new Point(12, 12)));\n\t\tobjects.add(new GameObject(new Point(13, 12)));\n\t\tobjects.add(new GameObject(new Point(16, 12)));\n\t\tobjects.add(new GameObject(new Point(4, 3)));\n\t\tobjects.add(new GameObject(new Point(6, 3)));\n\t\tobjects.add(new GameObject(new Point(6, 4)));\n\t\tobjects.add(new GameObject(new Point(10, 3)));\n\t\tobjects.add(new GameObject(new Point(10, 4)));\n\t\tobjects.add(new GameObject(new Point(12, 4)));\n\t\tobjects.add(new GameObject(new Point(14, 4)));\n\t\tobjects.add(new GameObject(new Point(15, 4)));\n\t\tobjects.add(new GameObject(new Point(14, 5)));\n\t\tobjects.add(new GameObject(new Point(15, 5)));\n\t\tobjects.add(new GameObject(new Point(13, 6)));\n\t\tobjects.add(new GameObject(new Point(15, 7)));\n\t\tobjects.add(new GameObject(new Point(14, 9)));\n\t\tobjects.add(new GameObject(new Point(12, 9)));\n\t\tobjects.add(new GameObject(new Point(1, 7)));\n\t\tobjects.add(new GameObject(new Point(1, 9)));\n\t\tobjects.add(new GameObject(new Point(1, 10)));\n\t\tobjects.add(new GameObject(new Point(2, 9)));\n\t\tobjects.add(new GameObject(new Point(2, 10)));\n\t\tobjects.add(new GameObject(new Point(3, 8)));\n\t\tobjects.add(new GameObject(new Point(4, 11)));\n\t\tobjects.add(new GameObject(new Point(6, 6)));\n\t\tobjects.add(new GameObject(new Point(6, 7)));\n\t\tobjects.add(new GameObject(new Point(6, 9)));\n\t\tobjects.add(new GameObject(new Point(6, 10)));\n\t\tobjects.add(new GameObject(new Point(10, 6)));\n\t\tobjects.add(new GameObject(new Point(10, 7)));\n\t\tobjects.add(new GameObject(new Point(10, 9)));\n\t\tobjects.add(new GameObject(new Point(10, 10)));\n\t\tenemies.add(new FinalBoss(new Point(8, 4), 4));\n\t\ttransitions.add(new Transition(new Point(14, 14), MapScreen.DUNGEON1, new Point(14, 2)));\n\t\ttransitions.add(new Transition(new Point(2, 0), MapScreen.DUNGEON3, new Point(2, 13)));\n\t\tsetCloneObjects((ArrayList<GameObject>) objects.clone());\n\t}", "@Override\r\n\tpublic final void calculateSpawnAmount() {\r\n\t\tthis.spawnsRequired = 0;\r\n\t\tfor (final Genome genome : this.members) {\r\n\t\t\tthis.spawnsRequired += genome.getAmountToSpawn();\r\n\t\t}\r\n\r\n\t}", "public static void main(String[] args) {\n\t\tList<Horse>horses=new ArrayList<>();\n\t\tfor(int i=0;i<8;i++){\nHorse h =new Horse();\nhorses.add(h);\nh.start();\n\t}\n\n}", "public BGStem rule(BGStem stem) {\n\t\t\n\t\t// Get node coordinates\n\t\tArrayList <Double> node = new ArrayList<Double>();\n\t\tnode = branch(stem);\n\t\t\n\t\t// add different child stems according to the rule\n\t\tswitch(rule) {\n\t\t\n\t\tcase 1:\n\t\t\t\n\t\t\t// Create child stem instances\n\t\t\tBGStem stm1 = new BGStem(node.get(0), node.get(1), stem.getLength()*0.66, stem.getDirection() - radians, stem.getDepth() + 1);\n\t\t\tBGStem stm2 = new BGStem(node.get(0), node.get(1), stem.getLength()*0.66, stem.getDirection() + radians, stem.getDepth() + 1);\n\t\t\t\n\t\t\t// Set corresponding rule\n\t\t\tstm1.setRule(1);\n\t\t\tstm2.setRule(1);\n\t\t\t\n\t\t\t// Add child stems to parent stem's childList\n\t\t\tstem.getChildlist().add(stm1);\n\t\t\tstem.getChildlist().add(stm2);\n//\t\t\tSystem.out.println(\"growing 2 child stems\");\n\t\t\tbreak;\n\t\t\n\t\tcase 2:\n\t\t\t\n\t\t\tBGStem stm3 = new BGStem(node.get(0), node.get(1), stem.getLength()*0.66, stem.getDirection() - radians, stem.getDepth() + 1);\n\t\t\tBGStem stm4= new BGStem(node.get(0), node.get(1), stem.getLength()*0.66, stem.getDirection(), stem.getDepth() + 1);\n\t\t\tBGStem stm5 = new BGStem(node.get(0), node.get(1), stem.getLength()*0.66, stem.getDirection() + radians, stem.getDepth() + 1);\n\t\t\t\n\t\t\tstm3.setRule(2);\n\t\t\tstm4.setRule(2);\n\t\t\tstm4.setRule(2);\n\t\t\t\n\t\t\tstem.getChildlist().add(stm3);\n\t\t\tstem.getChildlist().add(stm4);\n\t\t\tstem.getChildlist().add(stm5);\n//\t\t\tSystem.out.println(\"growing 3 child stems\");\n\t\t\tbreak;\n\t\t\n\t\tcase 3:\n\t\t\t\n\t\t\tBGStem stm6 = new BGStem(node.get(0), node.get(1), stem.getLength()*0.66, stem.getDirection() - radians, stem.getDepth() + 1);\n\t\t\tBGStem stm7 = new BGStem(node.get(0), node.get(1), stem.getLength()*0.66, stem.getDirection() - radians*2, stem.getDepth() + 1);\n\t\t\tBGStem stm8 = new BGStem(node.get(0), node.get(1), stem.getLength()*0.66, stem.getDirection() + radians, stem.getDepth() + 1);\n\t\t\tBGStem stm9 = new BGStem(node.get(0), node.get(1), stem.getLength()*0.66, stem.getDirection() + radians*2, stem.getDepth() + 1);\n\t\t\t\n\t\t\tstm6.setRule(3);\n\t\t\tstm7.setRule(3);\n\t\t\tstm8.setRule(3);\n\t\t\tstm9.setRule(3);\n\t\t\t\n\t\t\tstem.getChildlist().add(stm6);\n\t\t\tstem.getChildlist().add(stm7);\n\t\t\tstem.getChildlist().add(stm8);\n\t\t\tstem.getChildlist().add(stm9);\n//\t\t\tSystem.out.println(\"growing 4 child stems\");\n\t\t\tbreak;\n\t\t}\n\t\t\n\t\treturn stem;\n\t}", "public Ex spawn() {\n return spawn(false);\n }", "private void createGWBuildings()\n\t{\n\t\t//Generate block 0 (50x50)\n\t\t//(7,7)-(57,57)\n\t\tmakeBlocker0();\n\n\t\t//Generate block 1 (50x50)\n\t\t//(64,7)-(114,57)\n\t\tmakeSEH();\n\t\tmakeFullBright();\n\t\tmakeKennedy();\n\t\tmakeMunson();\n\n\t\t//Generate block 2 (80x50)\n\t\t//(121,7)-(201,57)\n\t\tmakeAcademicCenter();\n\t\tmakeRomePhilips();\n\t\tmakeDistrict();\n\t\tmakeMarvin();\n\t\tmakeLafayette();\n\n\t\t//Generate block 3 (65x50)\n\t\t//(208,7)-(273,57)\n\t\tmake2000Penn();\n\t\tmakeSMPA();\n\t\tmakeBlocker3();\n\n\t\t//Generate block 4 (63x50)\n\t\t//(280,7)-(343,57)\n\t\tmakeBlocker4();\n\n\t\t//Generate block 5 (50x60)\n\t\t//(7,64)-(57,124)\n\t\tmakeAmsterdam();\n\t\tmakeHealWell();\n\t\tmakeBlocker5();\n\n\t\t//Generate block 6 (50x60)\n\t\t//(64,64)-(114,124)\n\t\tmakeTompkins();\n\t\tmakeMadison();\n\t\tmakeDuquesAndFunger();\n\n\t\t//Generate block 7 (80x60)\n\t\t//(121,64)-(201,124)\n\t\tmakeGelman();\n\t\tmakeLisner();\n\t\tmakeStaughton();\n\t\tmakeMonroe();\n\n\t\t//Generate block 8 (65x60)\n\t\t//(208,64)-(273,124)\n\t\tmakeCorcoran();\n\t\tmakeLawSchool();\n\t\tmakeLisnerHall();\n\t\tmakeTextileMuseum();\n\n\t\t//Generate block 9 (63x60)\n\t\t//(280,64)-(343,124)\n\t\tmakeBlocker9();\n\n\t\t//Generate block 10 (50x50)\n\t\t//(7,131)-(57,181)\n\t\tmakeShenkman();\n\t\tmakeBlocker10();\n\n\t\t//Generate block 11 (50x50)\n\t\t//(64,131)-(114,181)\n\t\tmakeTownHouses();\n\t\tmakeSmithCenter();\n\n\t\t//Generate block 12 (80x50)\n\t\t//(121,131)-(201,181)\n\t\tmakeSouthHall();\n\t\tmakeGuthridge();\n\t\tmakeBlocker12();\n\n\t\t//Generate block 13 (65x50)\n\t\t//(208,131)-(273,181)\n\t\tmakeBlocker13();\n\t\tmakeFSK();\n\t\tmakePatomac();\n\n\t\t//Generate block 14 (63x50)\n\t\t//(280,131)-(343,181)\n\t\tmakeBlocker14();\n\n\t\t//Generate block 15 (50x57)\n\t\t//(7,188)-(57,245)\n\t\tmakeBlocker15();\n\n\t\t//Generate block 16 (50x57)\n\t\t//(64,188)-(114,245)\n\t\tmakeIHouse();\n\t\tmakeBlocker16();\n\n\t\t//Generate block 17 (80x57)\n\t\t//(121,188)-(201,245)\n\t\tmakeBlocker17();\n\t\tmakeDakota();\n\n\t\t//Generate block 18 (65x57)\n\t\t//(208,188)-(273,245)\n\t\tmakeBlocker18();\n\n\t\t//Generate block 19 (63x57)\n\t\t//(280,188)-(343,245)\n\t\tmakeBlocker19();\n\t\tmakeElliot();\n\t\tmakeThurston();\n\t}", "boolean testSpawnShips(Tester t) {\n return t.checkExpect(new NBullets(lob3, los3, 8, 12, 23, new Random(10)).spawnShips(),\n new NBullets(lob3, los3, 8, 12, 23))\n && t.checkExpect(new NBullets(lob3, los3, 8, 12, 24, new Random(10)).spawnShips(),\n new NBullets(lob3,\n new ConsLoGamePiece(new Ship(10, Color.cyan, new MyPosn(0, 127), new MyPosn(4, 0)),\n new ConsLoGamePiece(new Ship(10, Color.cyan, this.p3, this.p6),\n new ConsLoGamePiece(new Ship(10, Color.cyan, this.p1, this.p6),\n new ConsLoGamePiece(\n new Ship(10, Color.cyan, new MyPosn(0, 150), this.p3),\n new MtLoGamePiece())))),\n 8, 12, 24));\n }", "@Override\n\tpublic void spawn(Location loc) {\n\t\t\n\t}", "public void grow(Grid[][] map) {\n\t\tBranchNode parent = root;\r\n\t\twhile (parent.children.size() > 0) {\r\n\t\t\tif (parent.children.size() >= max_branch_per_node) {\r\n\t\t\t\t// if no more room at this branch\r\n\t\t\t\tparent = parent.children\r\n\t\t\t\t\t\t.get((int) (Math.random() * parent.children.size()));\r\n\t\t\t} else if (Math.random() < 0.5) {\r\n\t\t\t\t// if there is still room, picks randomly\r\n\t\t\t\tparent = parent.children\r\n\t\t\t\t\t\t.get((int) (Math.random() * parent.children.size()));\r\n\t\t\t} else {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tint newX, newY; // X and Y coordinates for the new node.\r\n\t\tint r = (int) (Math.random() * GENE_TOTAL);\r\n\t\tint gene_count = width_gene[0];\r\n\t\tint width_select = 0;\r\n\t\twhile (r > gene_count) {\r\n\t\t\twidth_select += 1;\r\n\t\t\tgene_count += width_gene[width_select];\r\n\t\t}\r\n\t\tr = (int) (Math.random() * WIDTH_VARIATION);\r\n\t\tnewX = parent.x - WIDTH_VARIATION / 2 + (width_select - 2)\r\n\t\t\t\t* WIDTH_VARIATION + r;\r\n\t\tif (newX < 0) {// if goes off the grid, push back.\r\n\t\t\tnewX = 0;\r\n\t\t} else if (newX >= World.WORLD_WIDTH) {\r\n\t\t\tnewX = World.WORLD_WIDTH - 1;\r\n\t\t}\r\n\r\n\t\tr = (int) (Math.random() * GENE_TOTAL);\r\n\t\tgene_count = height_gene[0];\r\n\t\tint height_select = 0;\r\n\t\twhile (r > gene_count) {\r\n\t\t\theight_select += 1;\r\n\t\t\tgene_count += height_gene[height_select];\r\n\t\t}\r\n\t\tr = (int) (Math.random() * HEIGHT_VARIATION);\r\n\t\tnewY = parent.y + height_select * HEIGHT_VARIATION + r;\r\n\t\tif (newY >= World.WORLD_HEIGHT) {\r\n\t\t\tnewY = World.WORLD_HEIGHT - 1;\r\n\t\t}\r\n\r\n\t\t// add the branch to the total body.\r\n\t\tamount_of_tree += (int) Math.sqrt((newX - parent.x) * (newX - parent.x)\r\n\t\t\t\t+ (newY - parent.y) * (newY - parent.y));\r\n\t\tBranchNode child = new BranchNode(parent, newX, newY);\r\n\t\tparent.children.add(child);\r\n\r\n\t\tif (parent.leaf_alive) {\r\n\t\t\t// kill leaf, because branch is growing off of it\r\n\t\t\tparent.killLeaf(this, map);\r\n\t\t}\r\n\r\n\t\t// make new leaf on new branch\r\n\t\tchild.addLeaf(this, map);\r\n\t}", "public void generateShape() {\n\n //TODO for tetris game - copy added to Tetris\n Shape newShape = null;\n //if(GAME_TO_TEST==GameEnum.TETRIS){\n //newShape = TetrisShapeFactory.getRandomShape(this.board);\n //} else if (GAME_TO_TEST== GameEnum.DRMARIO){\n //newShape = DrMarioShapeFactory.getRandomShape(this.board);\n //}\n\n //Temporary\n //-------------------------------------//\n Image image = null;\n try {\n image = new Image(new FileInputStream(\"resources/BlockPurple.png\"));\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n\n int spawnColIndex = 0;\n int spawnRowIndex = 0;\n int tileSize = 0;\n boolean setColor = false;\n boolean setTileBorder = false; //toggle to add boarder to tile\n boolean setImage = true;\n spawnColIndex = (board.gridWidth-1)/2; //half of board width\n spawnRowIndex = 0;\n tileSize = board.tileSize;\n\n Tile tile1 = new Tile(tileSize, setColor, Color.VIOLET, setTileBorder, setImage, image, spawnColIndex,spawnRowIndex, 0 , Direction.DOWN); //Center Tile\n Tile tile2 = new Tile(tileSize, setColor, Color.VIOLET, setTileBorder, setImage, image, spawnColIndex,spawnRowIndex,1 , Direction.RIGHT);\n Tile tile3 = new Tile(tileSize, setColor, Color.VIOLET, setTileBorder, setImage, image, spawnColIndex,spawnRowIndex, 1 , Direction.LEFT);\n Tile tile4 = new Tile(tileSize, setColor, Color.VIOLET, setTileBorder, setImage, image, spawnColIndex,spawnRowIndex, 1 , Direction.DOWN);\n\n List<Tile> tiles = new ArrayList<Tile>();\n tiles.add(tile1);\n tiles.add(tile2);\n tiles.add(tile3);\n tiles.add(tile4);\n newShape = new Shape(tiles);\n\n //set newly created shape as the currently active shape\n this.currentActiveShape = newShape;\n\n //check if spawn area is occupied\n boolean isOccupied =false;\n for (Tile newTile : this.currentActiveShape.tiles) {\n if(this.board.getTile(newTile.columnIndex,newTile.rowIndex)!=null){\n isOccupied = true;\n }\n }\n\n //TODO\n //check if shape reaches top\n if(!isOccupied){\n //add tiles to board\n for (Tile newTile : this.currentActiveShape.tiles) {\n this.board.placeTile(newTile);\n }\n } else {\n //TODO later add Game Over JavaFx message\n System.out.println(\"GAME OVER\");\n\n //TODO Finishlater\n //Text gameoverText = new Text(10,20,\"GAME OVER\");\n //gameoverText.setFill(Color.RED);\n //gameoverText.setX( 100/*( ((board.gridWidth-1)*tileSize)/2)*/ );\n //gameoverText.setY( 100/*( ((board.gridHeight-1)*tileSize)/2)*/ );\n //gameoverText.setStyle(\"-fx-font: 70 arial;\");\n //this.group.getChildren().add(gameoverText);\n\n //Text t = new Text();\n //t.setX(20.0f);\n //t.setY(65.0f);\n //t.setX(100);\n //t.setY(200);\n //t.setText(\"Perspective\");\n //t.setFill(Color.YELLOW);\n //t.setFont(Font.font(null, FontWeight.BOLD, 36));\n //this.group.getChildren().add(t);\n //this.pane.getChildren().add(t);\n\n //System.exit(0);\n }\n\n }", "public void spawnCreature(){\n\t\tif(spawnType.equalsIgnoreCase(\"worm\")){\n\t\t\tRuntimeObjectFactory.getObjectFromPool(\"worm\"+spawnId);\n\t\t}else if(spawnType.equalsIgnoreCase(\"antorc\")){\n\t\t\tGdx.app.debug(TamerGame.LOG, this.getClass()\n\t\t\t\t\t.getSimpleName() + \" :: Ant entered\");\t\t\t\n\t\t\t//CHANGE SPAWNING IMPLEMENTATION\n\t\t\tAntOrc orc = new AntOrc();\n\t\t\torc.setPosition(getPosition());\n\t\t\torc.setWaypoint(waypoint);\n\t\t\tenvironment.addNewObject(orc);\n\t\t\tEventPool.addEvent(new tEvent(this,\"spawnCreature\",sleepTime,1));\n\t\t}\n\t\t\t\n\t}", "private void createChamber() {\n\n // Give all tiles coordinates for map and temp map\n int CurrentY = 0;\n for (Tile[] tiles : map) {\n int CurrentX = 0;\n for (Tile tile : tiles) {\n tile.setPosition(new Coordinates(CurrentX, CurrentY));\n tile.setTerrain(Terrain.WALL);\n CurrentX++;\n }\n CurrentY++;\n }\n\n for (int y = 0; y < CAST_HEIGHT; y++) {\n for (int x = 0; x < CAST_WIDTH; x++) {\n tempMap[y][x].setPosition(new Coordinates(x, y));\n }\n }\n\n // Initialize algorithm at starting position (0, 0)\n tempMap[0][0].setVisited(true);\n numberOfCellsVisited = 1; //setting number of cells visited to 1 because I have visited one now!\n mapStack.push(tempMap[0][0]); //Chamber start position\n createMaze(tempMap[0][0]); //Chamber start position\n\n // Reveal top edge, sides, and bottom edge\n for (Tile tile : map[0]) {\n tile.setVisible(true);\n }\n for (Tile[] tiles : map) {\n tiles[0].setVisible(true);\n tiles[CHAMBER_WIDTH].setTerrain(Terrain.WALL);\n tiles[CHAMBER_WIDTH].setVisible(true);\n }\n for (Tile tile : map[CHAMBER_HEIGHT]) {\n tile.setVisible(true);\n }\n\n // Clear bugged walls\n for (int i = 1; i < MAP_HEIGHT - 2; i += 2)\n map[i][MAP_WIDTH - 2].setTerrain(Terrain.EMPTY);\n\n // Randomly make regulated holes in walls to create cycles\n Random rand = new Random(); // Preset rng for performance purposes\n for (int i = 1; i < MAP_HEIGHT - 1; i++) {\n for (int j = 1; j < MAP_WIDTH - 1; j++) {\n Tile tile = map[i][j];\n if (tile.getTerrain().equals(Terrain.WALL)) {\n\n // Neighbourhood Check\n int neighbourCount = 0, index = 0;\n boolean[] neighbourhood = new boolean[]{false, false, false, false}; // validity flags\n\n for (Direction direction : Direction.cardinals) {\n Coordinates targetCoordinates = Utility.locateDirection(tile.getPosition(), direction);\n Tile neighbour = getTileAtCoordinates(targetCoordinates);\n if (neighbour.getTerrain().equals(Terrain.WALL)) {\n neighbourCount++;\n neighbourhood[index] = true;\n }\n index++;\n }\n\n // Corner exclusion test, tests vertical NS and horizontal EW\n boolean isStraight = false;\n if (neighbourhood[0] && neighbourhood[1]) isStraight = true;\n if (neighbourhood[2] && neighbourhood[3]) isStraight = true;\n\n if (neighbourCount == 2 && isStraight) {\n if (rand.nextInt(5) == 4) tile.setTerrain(Terrain.EMPTY);\n }\n }\n }\n }\n\n // Check for enclosed spaces and create openings\n for (int i = 1; i < MAP_HEIGHT - 2; i++) probe(map[i][MAP_WIDTH - 2], Direction.EAST);\n }", "public void run() {\n int dead = 0;\n while(dead < bacteria.size()){\n dead = 0;\n Random rand = new Random();\n ArrayList<Microbe> children = new ArrayList();\n Iterator it = bacteria.iterator();\n for(Microbe bac:bacteria){\n if(bac.isAlive()){\n bac.search();\n }\n else{\n dead++;\n }\n if(bac.canBreed(time)){\n children.add(bac.breed());\n }\n \n }\n try {\n Thread.sleep(speed);\n //gui.upDateGUI();\n } catch (InterruptedException ex) {\n Logger.getLogger(RunSim.class.getName()).log(Level.SEVERE, null, ex);\n }\n Thread.yield();\n\n\n if(children.size() > 0){\n bacteria.addAll(children);\n }\n time++;\n gui.updateStats(time,bacteria.size()-dead,dead);\n\n }\n \n //}\n //gui.test();\n //gui.upDateGUI();\n }", "private void createShips() {\n //context,size, headLocation, bodyLocations\n Point point;\n Ship scout_One, scout_Two, cruiser, carrier, motherShip;\n if(player) {\n point = new Point(maxN - 1, 0); //row, cell\n scout_One = new Ship(1, point, maxN, \"Scout One\", player);\n ships.add(scout_One);\n point = new Point(maxN - 1, 1);\n scout_Two = new Ship(1, point, maxN, \"Scout Two\", player);\n ships.add(scout_Two);\n point = new Point(maxN - 2, 2);\n cruiser = new Ship(2, point, maxN, \"Cruiser\", player);\n ships.add(cruiser);\n point = new Point(maxN - 2, 3);\n carrier = new Ship(4, point, maxN, \"Carrier\", player);\n ships.add(carrier);\n point = new Point(maxN - 4, 5);\n motherShip = new Ship(12, point, maxN, \"MotherShip\", player);\n ships.add(motherShip);\n\n }else{\n Random rand = new Random();\n int rowM = maxN-3;\n int colM = maxN -2;\n int row = rand.nextInt(rowM);\n int col = rand.nextInt(colM);\n point = new Point(row, col);\n motherShip = new Ship(12, point, maxN, \"MotherShip\", player);\n updateOccupiedCells(motherShip.getBodyLocationPoints());\n ships.add(motherShip);\n\n rowM = maxN - 1;\n colM = maxN -1;\n row = rand.nextInt(rowM);\n col = rand.nextInt(colM);\n point = new Point(row, col);\n carrier = new Ship(4, point, maxN, \"Carrier\", player);\n updateOccupiedCells(carrier.getBodyLocationPoints());\n ships.add(carrier);\n checkIfOccupiedForSetShip(carrier, row, col, rowM, colM);\n\n\n rowM = maxN - 1;\n colM = maxN;\n row = rand.nextInt(rowM);\n col = rand.nextInt(colM);\n point = new Point(row, col);\n cruiser = new Ship(2, point, maxN, \"Cruiser\", player);\n updateOccupiedCells(cruiser.getBodyLocationPoints());\n ships.add(cruiser);\n checkIfOccupiedForSetShip(cruiser, row, col, rowM, colM);\n\n\n rowM = maxN;\n colM = maxN;\n row = rand.nextInt(rowM);\n col = rand.nextInt(colM);\n point = new Point(row, col);\n scout_Two = new Ship(1, point, maxN, \"Scout_Two\", player);\n updateOccupiedCells(scout_Two.getBodyLocationPoints());\n ships.add(scout_Two);\n checkIfOccupiedForSetShip(scout_Two, row, col, rowM, colM);\n\n rowM = maxN;\n colM = maxN;\n row = rand.nextInt(rowM);\n col = rand.nextInt(colM);\n point = new Point(row, col);\n scout_One = new Ship(1, point, maxN, \"Scout_One\", player);\n updateOccupiedCells(scout_One.getBodyLocationPoints());\n ships.add(scout_One);\n checkIfOccupiedForSetShip(scout_One, row, col, rowM, colM);\n\n\n\n\n }\n //Need an algorithm to set enemy ship locations at random without overlaps\n }", "private void processNode(BranchNode bn, Grid[][] map) {\n\t\tif (bn.leaf_alive) {\r\n\t\t\tfor (int i = 0; i < leaf_size; i++) {\r\n\t\t\t\tint l = bn.x + i - leaf_size / 2;\r\n\t\t\t\tif (l >= 0 && l < World.WORLD_WIDTH) {\r\n\t\t\t\t\thealth += map[l][bn.y].sunlight;\r\n\t\t\t\t\tmap[l][bn.y].sunlight -= World.LEAF_BLOCK;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t// Kill Leaf if the leaf is too old\r\n\t\t\tbn.leaf_age += 1;\r\n\t\t\tif (bn.leaf_age >= LEAF_LIFETIME) {\r\n\t\t\t\tbn.killLeaf(this, map);\r\n\t\t\t}\r\n\t\t}\r\n\t\t// If I really want to be safe, I should put a check for if bn.children.size() > 0\r\n\t\t// But the for loop here checks it for me already.\r\n\t\tfor (int i = 0; i < bn.children.size(); i++) {\r\n\t\t\tprocessNode(bn.children.get(i), map);\r\n\t\t}\t\t\r\n\t}", "private void greedyEnemySpawner(float enemyCap, IEnemyService spawner, World world, GameData gameData) {\r\n while (enemyCap >= MEDIUM_ENEMY_COST) {\r\n\r\n if (enemyCap >= MEDIUM_ENEMY_COST + BIG_ENEMY_COST) {\r\n spawnBigAndMediumEnemy(spawner, world, gameData);\r\n enemyCap -= MEDIUM_ENEMY_COST + BIG_ENEMY_COST;\r\n\r\n } else if (enemyCap >= BIG_ENEMY_COST) {\r\n spawnBigEnemy(spawner, world, gameData);\r\n enemyCap -= BIG_ENEMY_COST;\r\n\r\n } else {\r\n spawnMediumEnemy(spawner, world, gameData);\r\n enemyCap -= MEDIUM_ENEMY_COST;\r\n }\r\n }\r\n }", "public Command run() {\n Worm enemyWormSpecial = getFirstWormInRangeSpecial();\n if (enemyWormSpecial != null) {\n if (gameState.myPlayer.worms[1].id == gameState.currentWormId) {\n if (gameState.myPlayer.worms[1].bananaBombs.count > 0) {\n return new BananaBombCommand(enemyWormSpecial.position.x, enemyWormSpecial.position.y);\n }\n }\n if (gameState.myPlayer.worms[2].snowballs.count > 0) {\n return new SnowballCommand(enemyWormSpecial.position.x, enemyWormSpecial.position.y);\n }\n }\n\n //PRIORITAS 2: NORMAL ATTACK (Shoot)\n Worm enemyWorm = getFirstWormInRange();\n if (enemyWorm != null) {\n Direction direction = resolveDirection(currentWorm.position, enemyWorm.position);\n return new ShootCommand(direction);\n }\n\n //PRIORITAS 3: MOVE (Karena sudah opsi serang tidak memungkinkan)\n\n //Ambil semua koordinat di cell Worm saat ini selain current cell\n List<Cell> surroundingBlocks = getSurroundingCells(currentWorm.position.x, currentWorm.position.y);\n \n\n //Kalau Worm saat ini adalah Commander, masuk ke algoritma move khusus Commander\n if(gameState.currentWormId == 1){\n\n //Commander akan memprioritaskan untuk bergerak menuju Technician (Worm yang memiliki Snowball)\n Worm technicianWorm = gameState.myPlayer.worms[2];\n\n\n //Mencari cell yang akan menghasilkan jarak terpendek menuju Worm tujuan\n Cell shortestCellToTechnician = getShortestPath(surroundingBlocks, technicianWorm.position.x, technicianWorm.position.y);\n \n //Commander akan bergerak mendekati Technician sampai dengan jarak dia dan Technician paling dekat adalah 3 satuan\n if (euclideanDistance(currentWorm.position.x, currentWorm.position.y, technicianWorm.position.x, technicianWorm.position.y) > 3) {\n if(shortestCellToTechnician.type == CellType.AIR) {\n return new MoveCommand(shortestCellToTechnician.x, shortestCellToTechnician.y);\n }else if (shortestCellToTechnician.type == CellType.DIRT) {\n return new DigCommand(shortestCellToTechnician.x, shortestCellToTechnician.y);\n }\n }\n\n //Apabila Commander dan Technician sudah berdekatan, maka Commander akan bergerak mencari musuh terdekat untuk melancarkan serangan\n int min = 10000000;\n Worm wormMusuhTerdekat = opponent.worms[0];\n for (Worm calonMusuh : opponent.worms) {\n if (euclideanDistance(currentWorm.position.x, currentWorm.position.y, calonMusuh.position.x, calonMusuh.position.y) < min) {\n min = euclideanDistance(currentWorm.position.x, currentWorm.position.y, calonMusuh.position.x, calonMusuh.position.y);\n wormMusuhTerdekat = calonMusuh;\n }\n }\n\n //Mencari cell yang paling dekat ke musuh yang sudah ditemukan\n Cell shortestCellToEnemy = getShortestPath(surroundingBlocks, wormMusuhTerdekat.position.x, wormMusuhTerdekat.position.y);\n if(shortestCellToEnemy.type == CellType.AIR) {\n return new MoveCommand(shortestCellToEnemy.x, shortestCellToEnemy.y);\n }else if (shortestCellToEnemy.type == CellType.DIRT) {\n return new DigCommand(shortestCellToEnemy.x, shortestCellToEnemy.y);\n }\n }\n\n //Command move untuk worm selain Commando. Worm selain commando akan mendekat menuju posisi worm Commando\n Worm commandoWorm = gameState.myPlayer.worms[0];\n \n //Selama Commando masih hidup, maka Worm lainnya akan mendekat menuju Commando\n if (commandoWorm.health > 0) {\n //Cell cellCommandoWorm = surroundingBlocks.get(0);\n\n //Mencari cell yang membuat jarak menuju Commando paling dekat\n Cell shortestCellToCommander = getShortestPath(surroundingBlocks, commandoWorm.position.x, commandoWorm.position.y);\n\n if(shortestCellToCommander.type == CellType.AIR) {\n return new MoveCommand(shortestCellToCommander.x, shortestCellToCommander.y);\n }else if (shortestCellToCommander.type == CellType.DIRT) {\n return new DigCommand(shortestCellToCommander.x, shortestCellToCommander.y);\n }\n }\n\n // PRIORITAS 4: Bergerak secara acak untuk memancing musuh mendekat\n int cellIdx = random.nextInt(surroundingBlocks.size());\n Cell block = surroundingBlocks.get(cellIdx);\n if (block.type == CellType.AIR) {\n return new MoveCommand(block.x, block.y);\n } else if (block.type == CellType.DIRT) {\n return new DigCommand(block.x, block.y);\n }\n // Kalau udah enggak bisa ngapa-ngapain.\n return new DoNothingCommand();\n \n }", "void generateLeaves(World world, BlockPos pos, Random rand, List<FoliageCoordinates> foliageCoords) {\n\t\tthis.height = (int) (this.heightLimit * this.heightAttenuation);\n\t\t\n\t\tif (this.height >= this.heightLimit) {\n\t\t\tthis.height = this.heightLimit - 1;\n\t\t}\n\n\t\tint i = (int) (1.382 + Math.pow(this.leafDensity * this.heightLimit / 13.0, 2.0));\n\t\t\n\t\tif (i < 1) i = 1;\n\n\t\tint branchBaseY = pos.getY() + this.height;\n\t\tint k = this.heightLimit - this.leafDistanceLimit;\n\t\t\n\t\t\n\t\tfoliageCoords.add(new FoliageCoordinates(pos.up(k), branchBaseY));\n\n\t\tfor (; k >= 0; --k) {\n\t\t\tfloat f = this.getLayerSize(k);\n\n\t\t\tif (f >= 0.0F) {\n\t\t\t\tfor (int l = 0; l < i; ++l) {\n\t\t\t\t\tdouble d0 = this.scaleWidth * (double) f * ((double) rand.nextFloat() + 0.328D);\n\t\t\t\t\tdouble d1 = (double) (rand.nextFloat() * 2.0F) * Math.PI;\n\t\t\t\t\tdouble d2 = d0 * Math.sin(d1) + 0.5D;\n\t\t\t\t\tdouble d3 = d0 * Math.cos(d1) + 0.5D;\n\t\t\t\t\tBlockPos blockpos = pos.add(d2, (double) (k - 1), d3);\n\t\t\t\t\tBlockPos blockpos1 = blockpos.up(this.leafDistanceLimit);\n\n\t\t\t\t\tif (this.checkBlockLine(world, blockpos, blockpos1) == -1) {\n\t\t\t\t\t\tint i1 = pos.getX() - blockpos.getX();\n\t\t\t\t\t\tint j1 = pos.getZ() - blockpos.getZ();\n\t\t\t\t\t\tdouble d4 = (double) blockpos.getY() - Math.sqrt((double) (i1 * i1 + j1 * j1)) * this.branchSlope;\n\t\t\t\t\t\tint k1 = d4 > (double) branchBaseY ? branchBaseY : (int) d4;\n\t\t\t\t\t\tBlockPos blockpos2 = new BlockPos(pos.getX(), k1, pos.getZ());\n\n\t\t\t\t\t\tif (this.checkBlockLine(world, blockpos2, blockpos) == -1) {\n\t\t\t\t\t\t\tfoliageCoords.add(new FoliageCoordinates(blockpos, blockpos2.getY()));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t}", "@Override\n public void updateAI(Entity entity, ServerGameModel model, double seconds) {\n BuildingSpawnerStratAIData data = entity.<BuildingSpawnerStratAIData>get(AI_DATA);\n data.elapsedTime += seconds;\n while (data.elapsedTime > timeBetweenSpawns(entity)) {\n data.elapsedTime -= timeBetweenSpawns(entity);\n if (data.spawnCounter < maxActive(entity)) {\n if (!canAttack()) {\n // Find possible spawn points: cells not blocked by hard entities.\n Set<GridCell> neighbors = model.getNeighbors(model.getCell((int) (double) entity.getX(),\n (int) (double) entity.getY()));\n Set<GridCell> passable = neighbors.stream().filter(GridCell::isPassable).collect(Collectors.toSet());\n\n // If cell directly below it is clear, spawn it there. Otherwise, find another\n // open neighboring cell to spawn the entity.\n if (passable.contains(model.getCell((int) (double) entity.getX(), (int) (double) entity.getY() + 1))) {\n Entity newEntity = makeEntity(entity.getX(), entity.getY() + 1, entity.getTeam(), entity, model);\n model.processMessage(new MakeEntityRequest(newEntity));\n newEntity.onDeath((e, serverGameModel) -> {\n data.spawnCounter--;\n data.spawned.remove(e);\n });\n data.spawnCounter++;\n data.spawned.add(newEntity);\n } else if (!passable.isEmpty()) {\n Entity newEntity = makeEntity(passable.iterator().next().getCenterX(),\n passable.iterator().next().getCenterY(), entity.getTeam(), entity, model);\n model.processMessage(new MakeEntityRequest(newEntity));\n newEntity.onDeath((e, serverGameModel) -> {\n data.spawnCounter--;\n data.spawned.remove(e);\n });\n data.spawnCounter++;\n data.spawned.add(newEntity);\n }\n } else {\n Collection<Entity> attackable = attackableEnemies(entity, model);\n if (!attackable.isEmpty()) {\n Entity closest = getClosestEnemy(attackable, entity, model);\n Entity newEntity = makeEntity(closest.getX(), closest.getY(), entity.getTeam(), entity, model);\n model.processMessage(new MakeEntityRequest(newEntity));\n newEntity.onDeath((e, serverGameModel) -> {\n data.spawnCounter--;\n data.spawned.remove(e);\n });\n data.spawnCounter++;\n data.spawned.add(newEntity);\n }\n }\n }\n if (entity.getUpgraded()) {\n for (Entity e : data.spawned) {\n e.setUpgraded(false);\n e.set(LEVEL, entity.get(LEVEL));\n // TODO UP grade other stuff\n }\n }\n }\n }", "public void spawn()\n\t{\n\t\tsynchronized(this)\n\t\t{\n\t\t\t// Set the x,y,z position of the L2Object spawn and update its _worldregion\n\t\t\tsetVisible(true);\n\t\t\tsetWorldRegion(WorldManager.getInstance().getRegion(getWorldPosition()));\n\n\t\t\t// Add the L2Object spawn in the _allobjects of L2World\n\t\t\tWorldManager.getInstance().storeObject(object);\n\n\t\t\t// Add the L2Object spawn to _visibleObjects and if necessary to _allplayers of its L2WorldRegion\n\t\t\tregion.addVisibleObject(object);\n\t\t}\n\n\t\t// this can synchronize on others instancies, so it's out of\n\t\t// synchronized, to avoid deadlocks\n\t\t// Add the L2Object spawn in the world as a visible object\n\t\tWorldManager.getInstance().addVisibleObject(object, region);\n\n\t\tobject.onSpawn();\n\t}", "private boolean spawn(int x, int y) {\n\t\treturn false;\n\t}", "@Override\n\t\tpublic void run() {\n\n\n\t\t\tif (((CitizensNPC)myNPC).getHandle() == null ) sentryStatus = Status.isDEAD; // incase it dies in a way im not handling.....\n\n\t\t\tif (sentryStatus != Status.isDEAD && System.currentTimeMillis() > oktoheal && HealRate > 0) {\n\t\t\t\tif (myNPC.getBukkitEntity().getHealth() < sentryHealth) {\n\t\t\t\t\tmyNPC.getBukkitEntity().setHealth(myNPC.getBukkitEntity().getHealth() + 1);\n\t\t\t\t\tif (healanim!=null)net.citizensnpcs.util.Util.sendPacketNearby(myNPC.getBukkitEntity().getLocation(),healanim , 64);\n\n\t\t\t\t\tif (myNPC.getBukkitEntity().getHealth() >= sentryHealth) _myDamamgers.clear(); //healed to full, forget attackers\n\n\t\t\t\t}\n\t\t\t\toktoheal = (long) (System.currentTimeMillis() + HealRate * 1000);\n\t\t\t}\n\n\t\t\tif (sentryStatus == Status.isDEAD && System.currentTimeMillis() > isRespawnable && RespawnDelaySeconds != 0) {\n\t\t\t\t// Respawn\n\n\t\t\t\t// Location loc =\n\t\t\t\t// myNPC.getTrait(CurrentLocation.class).getLocation();\n\t\t\t\t// if (myNPC.hasTrait(Waypoints.class)){\n\t\t\t\t// Waypoints wp = myNPC.getTrait(Waypoints.class);\n\t\t\t\t// wp.getCurrentProvider()\n\t\t\t\t// }\n\n\t\t\t\t// plugin.getServer().broadcastMessage(\"Spawning...\");\n\t\t\t\tif (guardEntity == null) {\n\t\t\t\t\tmyNPC.spawn(Spawn);\n\t\t\t\t} else {\n\t\t\t\t\tmyNPC.spawn(guardEntity.getLocation().add(2, 0, 2));\n\t\t\t\t}\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\telse if (sentryStatus == Status.isHOSTILE && myNPC.isSpawned()) {\n\n\t\t\t\tif (projectileTarget != null && !projectileTarget.isDead()) {\n\t\t\t\t\tif (_projTargetLostLoc == null)\n\t\t\t\t\t\t_projTargetLostLoc = projectileTarget.getLocation();\n\n\t\t\t\t\tfaceEntity(myNPC.getBukkitEntity(), projectileTarget);\n\n\t\t\t\t\tif (System.currentTimeMillis() > oktoFire) {\n\t\t\t\t\t\t// Fire!\n\t\t\t\t\t\toktoFire = (long) (System.currentTimeMillis() + AttackRateSeconds * 1000.0);\n\t\t\t\t\t\tFire(projectileTarget);\n\t\t\t\t\t}\n\t\t\t\t\tif (projectileTarget != null)\n\t\t\t\t\t\t_projTargetLostLoc = projectileTarget.getLocation();\n\n\t\t\t\t\treturn; // keep at it\n\n\t\t\t\t}\n\n\t\t\t\telse if (meleeTarget != null && !meleeTarget.isDead()) {\n\t\t\t\t\t// Did it get away?\n\t\t\t\t\tif (meleeTarget.getLocation().distance(myNPC.getBukkitEntity().getLocation()) > sentryRange) {\n\t\t\t\t\t\t// it got away...\n\t\t\t\t\t\tsetTarget(null);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\telse {\n\t\t\t\t\t// target died or null\n\t\t\t\t\tsetTarget(null);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\telse if (sentryStatus == Status.isLOOKING && myNPC.isSpawned()) {\n\n\t\t\t\tif (guardTarget != null && guardEntity == null) {\n\t\t\t\t\t// daddy? where are u?\n\t\t\t\t\tsetGuardTarget(guardTarget);\n\t\t\t\t}\n\n\t\t\t\tLivingEntity target = findTarget(sentryRange);\n\n\t\t\t\tif (target != null) {\n\t\t\t\t\t// plugin.getServer().broadcastMessage(\"Target selected: \" +\n\t\t\t\t\t// target.toString());\n\t\t\t\t\tsetTarget(target);\n\t\t\t\t} else\n\t\t\t\t\tsetTarget(null);\n\n\t\t\t}\n\n\t\t}", "public void iterate()\n\t{\n\t\tfor (int p = 0; p < parasites.length; p++)\n\t\t\tpFitnesses[p][1] = 0;\n\t\t\n\t\ttry\n\t\t{\t// calculate fitnesses against other population\n\t\t\texecutor.invokeAll(tasks);\n\t\t\t// calculate fitness against hall of fame individuals\n\t\t\texecutor.invokeAll(hofTasks);\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tSystem.out.println(\"Something bad happened...\");\n\t\t\tSystem.exit(-1);\n\t\t}\n\t\n\t\tArrays.sort(hFitnesses,new ArrayComparator(1,false));\n\t\tArrays.sort(pFitnesses,new ArrayComparator(1,false));\n\t\t\n\t\tint bestIndex = (int)pFitnesses[0][0];\n\t\tint size = parHOF.length;\n\t\t\n\t\tparHOF[generations%size]=new NeuralPlayer(-1,\"HOF P\",(BasicNetwork)parasites[(int)bestIndex].net.clone());\n\t\tbestIndex = (int)hFitnesses[0][0];\n\t\thostHOF[generations%size]=new NeuralPlayer(1,\"HOF H\",(BasicNetwork)hosts[(int)bestIndex].net.clone());\n\t\t\n\t\tint matePopIndex = (int)(matingPer*popSize)+1;\n\t\tRandom indexG = new Random();\n\t\t// allow top percentage to breed and replace bottom 2*percentage\n\t\t// leave everyone else alone\n\t\tfor (int i = 0; i < popSize*2*matingPer; i++)\n\t\t{\n\t\t\tint pInd1 = indexG.nextInt(matePopIndex);\n\t\t\tint pInd2 = indexG.nextInt(matePopIndex);\n\t\t\tNeuralPlayer p1 = hosts[(int)hFitnesses[pInd1][0]];\n\t\t\tNeuralPlayer p2 = hosts[(int)hFitnesses[pInd2][0]];\n\t\t\tNeuralPlayer child = hosts[(int)hFitnesses[popSize - 1 - i][0]];\n\t\t\tmate(p1, p2,child);\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < popSize*2*matingPer; i++)\n\t\t{\n\t\t\tint pInd1 = indexG.nextInt(matePopIndex);\n\t\t\tint pInd2 = indexG.nextInt(matePopIndex);\n\t\t\tNeuralPlayer p1 = parasites[(int)pFitnesses[pInd1][0]];\n\t\t\tNeuralPlayer p2 = parasites[(int)pFitnesses[pInd2][0]];\n\t\t\tNeuralPlayer child = parasites[(int)pFitnesses[popSize - 1 - i][0]];\n\t\t\tmate(p1, p2,child);\n\t\t}\n\t\t// mutate everyone except top percentage (matingPer)\n\t\tfor (int i = 0; i < popSize*3*matingPer; i++)\n\t\t{\n\t\t\tmutate(parasites[(int)pFitnesses[popSize - 1 - i][0]]);\n\t\t\tmutate(hosts[(int)hFitnesses[popSize - 1 - i][0]]);\n\t\t}\n\t\t\n\t\tgenerations+=1;\n\t\t// every now and then reseed the population with a good individual\n\t\tif (generations%50 == 0)\n\t\t{\n\t\t\thosts[indexG.nextInt(hosts.length)].net = (BasicNetwork)allTimeBestHost.net.clone();\n\t\t\tparasites[indexG.nextInt(parasites.length)].net = (BasicNetwork)allTimeBestPara.net.clone();\n\t\t}\n\t\t\t\n\t}", "void makeDragon() {\n new BukkitRunnable() {\n int i = 555;\n\n @Override\n public void run() {\n Set<BlockData> set = create.get(i);\n for (BlockData blockData : set) {\n blockData.setBlock();\n }\n\n i++;\n if (i > 734) {\n cancel();\n }\n }\n }.runTaskTimer(Main.plugin, 0, 2);\n // Location end = new Location(Bukkit.getWorld(\"world\"), 3, 254, 733);\n }", "private void asignNeighbours(String split [], String planetName){\n\t\tdouble length = Double.parseDouble(split[1]);\n\t\tboolean danger = Boolean.parseBoolean(split[2]);\n\t\t\n\t\tif(factoryMap.containsKey(planetName)&&factoryMap.containsKey(split[0])){\n\t\t\tfactoryMap.get(planetName).addNeghbour(new Path(length, factoryMap.get(split[0]), danger));\t\n\t\t}\n\t\tif(factoryMap.containsKey(planetName) && galaxy.containsKey(split[0])){\n\t\t\tfactoryMap.get(planetName).addNeghbour(new Path(length, galaxy.get(split[0]), danger));\t\n\t\t}\n\t\tif(galaxy.containsKey(planetName) && factoryMap.containsKey(split[0])){\n\t\t\tgalaxy.get(planetName).addNeghbour(new Path(length, factoryMap.get(split[0]), danger));\t\n\t\t}\n\t\tif(galaxy.containsKey(planetName) && galaxy.containsKey(split[0])){\n\t\t\tgalaxy.get(planetName).addNeghbour(new Path(length, galaxy.get(split[0]), danger));\n\t\t}\n\t}", "public static void spawnPlant (Species map[][], int plantSpawnRate, int plantHealth) {\n \n // Declare random coordinates\n int y, x; \n \n // Declare new plant\n Plant plant;\n \n // Spawn plants randomly until spawn rate is reached per turn\n for (int i = 0; i < plantSpawnRate; i++) {\n \n // Generate random coordinates\n y = (int)(Math.random() * map[0].length);\n x = (int)(Math.random() * map.length);\n \n // Check if space is empty and available to spawn\n if (map[y][x] == null) { \n \n // Get plant choice\n int plantChoice = (int) Math.ceil(Math.random() * 100);\n \n // Spawn different types of plants\n if ((plantChoice <= 100) && (plantChoice >= 50)) {\n plant = new HealthyPlant(plantHealth, x, y, plantSpawnRate);\n } else if ((plantChoice < 50) && (plantChoice >= 25)) {\n plant = new EnergizingPlant(plantHealth, x, y, plantSpawnRate);\n } else {\n plant = new PoisonousPlant(plantHealth, x, y, plantSpawnRate);\n }\n \n // Set plant location\n plant.setX(x);\n plant.setY(y);\n map[y][x] = plant;\n \n // No space\n } else {\n i -= 1;\n }\n }\n \n }", "void removeAllSpawn();", "public static void main(String[] args) {\n\n List<Mine> mines = new ArrayList<>();\n mines.add(new CoalMine(40));\n mines.add(new CoalMine(40));\n mines.add(new CoalMine(40));\n mines.add(new CoalMine(40));\n mines.add(new UraniumMine(100));\n mines.add(new MoonMine(10));\n mines.add(new MoonMine(10));\n mines.add(new HadronCollider(1));\n\n List<EnergyPlant> energyPlants = new ArrayList<>();\n energyPlants.add(new CoalPlant(7));\n energyPlants.add(new CoalPlant(7));\n energyPlants.add(new SolarPlant(2));\n energyPlants.add(new SolarPlant(2));\n energyPlants.add(new NuclearPlant(10000));\n energyPlants.add(new NuclearPlant(10000));\n energyPlants.add(new FusionPlant(20000));\n energyPlants.add(new FusionPlant(20000));\n energyPlants.add(new AnnihilationPlant(25000));\n energyPlants.add(new AnnihilationPlant(25000));\n\n\n var simulation = new Simulation(null, mines, energyPlants);\n simulation.run();\n\n }", "public void create2(){\n\t\t//creating board to keep track of player postion with 1 or 0. 0 if not there 1 if they are there\n\t\tfor(int i = 0; i <this.position.length; i++){\n\t\t\tfor(int p = 0; p < this.position.length; p++){\n\t\t\t\tthis.position[i][p] = 0;//filling with zero\n\t\t\t}\n\t\t}//end of position making board\n\n\n\t\t//creating door in the rooms\n\t\tfor(int i = 0; i <this.Door.length; i++){\n\t\t\tfor(int p = 0; p < this.Door.length; p++){\n\t\t\t\tthis.Door[i][p] = 0;//filling with zero\n\t\t\t}\n\t\t}//end of Door making board\n\t\tthis.Door[1][1] = 1;\n\n\t\t//creating stairs to transport to room3\n\t\tfor(int i = 0; i <this.Stairs.length; i++){\n\t\t\tfor(int p = 0; p < this.Stairs.length; p++){\n\t\t\t\tthis.Stairs[i][p] = 0;//filling with zero\n\t\t\t}\n\t\t}//end of Door making board\n\t\tthis.Stairs[18][18] = 1;\n\n\t\t//creating board to keep track of ari\n\t\tfor(int i = 0; i <this.Ari.length; i++){\n\t\t\tfor(int p = 0; p < this.Ari.length; p++){\n\t\t\t\tthis.Ari[i][p] = 0;//filling with zero\n\t\t\t}\n\t\t}\n\t\tthis.Ari[7][11] = 1;//putts ari there\n\n\t\t//makes board that tells if item is there\n\t\tfor(int i = 0; i <this.Items.length; i++){\n\t\t\tfor(int p = 0; p < this.Items.length; p++){\n\t\t\t\tthis.Items[i][p] = null;//filling with null\n\t\t\t}\n\t\t}//end of filling board that has items\n\n\t\t//makes border of room\n\t\tfor(int i = 0; i < this.area.length; i++){\n\t\t\tfor(int p = 0; p<this.area.length; p++){\n\t\t\t\tif(i==0){\n\t\t\t\t\tthis.area[i][p] = \"[ ]\";\n\t\t\t\t}\n\t\t\t\telse if (p==0 || p==19){\n\t\t\t\t\tthis.area[i][p] = \"[ ]\";\n\t\t\t\t}\n\t\t\t\telse if(i==19){\n\t\t\t\t\tthis.area[i][p] = \"[ ]\";\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tthis.area[i][p] = \" \";\n\t\t\t\t}\n\t\t\t}//end of innner for\n\t\t}//end of outter for\n\t\tfor(int i = 3; i< 4 ; i++){\n\t\t\tfor(int p = 1; p < 18; p++){\n\t\t\t\tthis.area[i][p] = \"[ ]\";\n\t\t\t}\n\t\t}\n\t\tfor(int i = 6; i< 7 ; i++){\n\t\t\tfor(int p = 19; p > 1; p--){\n\t\t\t\tthis.area[i][p] = \"[ ]\";\n\t\t\t}\n\t\t}\n\t\tfor(int i = 9; i< 10 ; i++){\n\t\t\tfor(int p = 1; p < 18; p++){\n\t\t\t\tthis.area[i][p] = \"[ ]\";\n\t\t\t}\n\t\t}\n\t\tfor(int i = 12; i< 13 ; i++){\n\t\t\tfor(int p = 19; p > 1; p--){\n\t\t\t\tthis.area[i][p] = \"[ ]\";\n\t\t\t}\n\t\t}\n\t\tfor(int i = 15; i< 16 ; i++){\n\t\t\tfor(int p = 1; p < 18; p++){\n\t\t\t\tthis.area[i][p] = \"[ ]\";\n\t\t\t}\n\n\t\t\tSystem.out.println(\" \");\n\t\t}//end of for that creates walls\n\n\t\t//for loop that distributes items\n\t\tint y = 0;\n\t\tint x = 0;\n\t\tfor(int i = 0;i<10;i++){\n\t\t\tItem thing = ItemGenerator.generate();//making an item\n\t\t\tboolean good = false;\n\t\t\twhile(!good){//makes coordates until there is nothing in the way\n\t\t\t\ty = fate.nextInt(20);//getting coordiantaes\n\t\t\t\tx = fate.nextInt(20);\n\t\t\t\tif(this.Items[y][x]==null && this.area[y][x] != \"[ ]\"){\n\t\t\t\t\tgood = true;\n\t\t\t\t}//end of if\n\t\t\t\telse{\n\t\t\t\t\tgood = false;\n\t\t\t\t}\n\t\t\t}//end of while\n\t\t\tItems[y][x] = thing;\n\t\t}//end of for that distributes items on board\n\n\t}", "private void createAllGames() {\n\t\t// Create a melee game for each melee arena\n\t\tmeleeArenaManager.loadArenas();\n\t\tmeleeArenaManager.getArenas().forEach(meleeArena -> {\n\t\t\tMeleeGame game = new MeleeGame(meleeArena);\n\t\t\tmeleeGameManager.addGame(meleeArena.getName(), game, new PerMapLegacyLobby(game, PlayerProfile::restore, Melee.MELEE_CHAT_PREFIX));\n\t\t});\n\t\t\n\t\t// Create a rabbit game for each rabbit arena\n\t\trabbitArenaManager.loadArenas();\n\t\trabbitArenaManager.getArenas().forEach(rabbitArena -> {\n\t\t\tRabbitGame game = new RabbitGame(rabbitArena);\n\t\t\trabbitGameManager.addGame(rabbitArena.getName(), game, new PerMapLegacyLobby(game, PlayerProfile::restore, Melee.RABBIT_CHAT_PREFIX));\n\t\t});\n\t\t\n\t\t// Log out what games were created\n\t\tString meleeGamesList = meleeGameManager.getGamesList().stream()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t .map(game -> game.getArena().getName())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t .collect(Collectors.joining(\", \"));\n\t\tgetLogger().info(\"Created Melee Games for arenas : \" + meleeGamesList);\n\n\t\tString rabbitGamesList = rabbitGameManager.getGamesList().stream()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t .map(game -> game.getArena().getName())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t .collect(Collectors.joining(\", \"));\n\t\tgetLogger().info(\"Created Rabbit Games for arenas : \" + rabbitGamesList);\n\t}", "public void placeMandatoryObjects()\r\n {\r\n Random rng = new Random();\r\n //Adds an endgame chest somewhere (NOT in spawn)\r\n Room tempRoom = getRoom(rng.nextInt(dungeonWidth - 1) +1, rng.nextInt(dungeonHeight - 1) +1);\r\n tempRoom.addObject(new RoomObject(\"Endgame Chest\", \"overflowing with coolness!\"));\r\n if (tempRoom.getMonster() != null)\r\n {\r\n tempRoom.removeMonster();\r\n }\r\n tempRoom.addMonster(new Monster(\"Pelo Den Stygge\", \"FINAL BOSS\", 220, 220, 12));\r\n //Adds a merchant to the spawn room\r\n getRoom(0,0).addObject(new RoomObject(\"Merchant\", \"like a nice fella with a lot of goods (type \\\"wares\\\" to see his goods)\"));\r\n }", "@Test\n public void test2IsCreatable()throws Exception{\n\n Position pos = new Position(0,0);\n generateLevel.landOn(pos,BlockType.PATH.toString());\n NormalDefender nd = new NormalDefender(generateLevel.getZoneList().\n get(0).getPos(),generateLevel.getAttackersList());\n assertTrue(generateLevel.isCreatable(nd));\n }", "private static void generateWorld(){\n for(int i = 0; i < SIZE*SIZE; i++){\n new Chunk();\n }\n }", "private void decorateMountains(int xStart, int xLength, int floor, ArrayList finalListElements, ArrayList states,boolean enemyAddedBefore)\r\n\t {\n\t if (floor < 1)\r\n\t \treturn;\r\n\r\n\t // boolean coins = random.nextInt(3) == 0;\r\n\t boolean rocks = true;\r\n\r\n\t //add an enemy line above the box\r\n\t Random r = new Random();\r\n\t boolean enemyAdded=addEnemyLine(xStart + 1, xLength - 1, floor - 1);\r\n\r\n\t int s = 1;\r\n\t int e = 1;\r\n\r\n\t if(enemyAdded==false && enemyAddedBefore==false)\r\n\t {\r\n\t if (floor - 2 > 0){\r\n\t if ((xLength - e) - (xStart + s) > 0){\r\n\t for(int x = xStart + s; x < xLength- e; x++){\r\n\t \tboolean flag=true;\r\n\t \tfor(int i=0;i<states.size();i++)\r\n\t \t{\r\n\t \t\tElements element=(Elements)finalListElements.get(i);\r\n\t \t\t\tBlockNode state=(BlockNode)states.get(i);\r\n\t \t\t\t\r\n\t \t\t\tint xElement = (int)(initialStraight+state.getX());\r\n\t \t int floorC= (int)state.getY()+1;\r\n\t \t int widthElement=element.getWidth();\r\n\t \t int heigthElement=element.getHeigth()+2;\r\n\t \t \r\n\t \t int widthElementNext=1;\r\n\t \t int heigthElementNext=0;\r\n\t \t \r\n\t \t if(x+(widthElementNext-1)>=xElement && x<xElement+widthElement && (floor-1)-heigthElementNext<=floorC && (floor-1)>= floorC-heigthElement )\r\n\t \t {\r\n\t \t \tflag=false;\r\n\t \t \tbreak;\r\n\t \t }\r\n\t \t \t \t \t\t \t \r\n\t \t } \r\n\t \tif(flag==true)\r\n\t \t{\r\n\t \t\tsetBlock(x, floor - 1, COIN);\r\n\t \t}\r\n\t \r\n\t //COINS++;\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\r\n\t s = random.nextInt(4);\r\n\t e = random.nextInt(4);\r\n\t \r\n\t //this fills the set of blocks and the hidden objects inside them\r\n\t /*\r\n\t if (floor - 4 > 0)\r\n\t {\r\n\t if ((xLength - 1 - e) - (xStart + 1 + s) > 2)\r\n\t {\r\n\t for (int x = xStart + 1 + s; x < xLength - 1 - e; x++)\r\n\t {\r\n\t if (rocks)\r\n\t {\r\n\t if (x != xStart + 1 && x != xLength - 2 && random.nextInt(3) == 0)\r\n\t {\r\n\t if (random.nextInt(4) == 0)\r\n\t {\r\n\t setBlock(x, floor - 4, BLOCK_POWERUP);\r\n\t //BLOCKS_POWER++;\r\n\t }\r\n\t else\r\n\t {\t//the fills a block with a hidden coin\r\n\t setBlock(x, floor - 4, BLOCK_COIN);\r\n\t //BLOCKS_COINS++;\r\n\t }\r\n\t }\r\n\t else if (random.nextInt(4) == 0)\r\n\t {\r\n\t if (random.nextInt(4) == 0)\r\n\t {\r\n\t setBlock(x, floor - 4, (byte) (2 + 1 * 16));\r\n\t }\r\n\t else\r\n\t {\r\n\t setBlock(x, floor - 4, (byte) (1 + 1 * 16));\r\n\t }\r\n\t }\r\n\t else\r\n\t {\r\n\t setBlock(x, floor - 4, BLOCK_EMPTY);\r\n\t //BLOCKS_EMPTY++;\r\n\t }\r\n\t }\r\n\t }\r\n\t //additionElementToList(\"Block\", 1,(xLength - 1 - e)-(xStart + 1 + s));\r\n\t }\r\n\t \r\n\t }*/\r\n\t }" ]
[ "0.6365504", "0.6349423", "0.59440064", "0.58542824", "0.58514684", "0.5634602", "0.5615008", "0.5591922", "0.5570385", "0.55258507", "0.55125177", "0.5503343", "0.549981", "0.5483905", "0.5454737", "0.54540676", "0.54371214", "0.54355586", "0.5435327", "0.5427088", "0.5425069", "0.54194456", "0.54165095", "0.5416348", "0.54158664", "0.54154104", "0.54141396", "0.54138064", "0.5367506", "0.5366236", "0.53255016", "0.53130996", "0.5296272", "0.5288658", "0.52858305", "0.52686244", "0.52357334", "0.5209461", "0.520813", "0.5203532", "0.52023304", "0.52007556", "0.5195023", "0.51888204", "0.5181359", "0.51779145", "0.51718545", "0.5170655", "0.5166027", "0.516043", "0.5149618", "0.51460445", "0.5144115", "0.5137002", "0.5119288", "0.511192", "0.5102754", "0.5097985", "0.50781083", "0.5073855", "0.50652236", "0.5041444", "0.50397336", "0.50385886", "0.5036265", "0.50321656", "0.5030199", "0.5029536", "0.5028436", "0.502547", "0.5021169", "0.5019348", "0.5015804", "0.5014883", "0.5003493", "0.50009304", "0.49986902", "0.4991413", "0.49901462", "0.49839586", "0.4972086", "0.4971542", "0.49628246", "0.4956466", "0.49514046", "0.49501014", "0.49444646", "0.49441087", "0.49403143", "0.49340883", "0.4931727", "0.49306592", "0.49295846", "0.4924229", "0.49235067", "0.49224418", "0.49223396", "0.49196264", "0.49164557", "0.49094784" ]
0.6473282
0
Instantiates a new Local.
public Local(int id, String supplierName, String type, String supplierAddress, String salesPerson, String phoneNumber) { super(id, supplierName, type, supplierAddress, salesPerson, phoneNumber); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public Local() {\n }", "public LocalObject() {}", "public Local createLocal(Position pos, LocalInstance li) {\n return (Local) xnf.Local(pos, xnf.Id(pos, li.name())).localInstance(li).type(li.type());\n }", "public Local createLocal(Position pos, Local local) {\n return syn.createLocal(pos, local.localInstance());\n }", "public Local createLocal(Position pos, LocalDecl decl) {\n return createLocal(pos, decl.localDef().asInstance());\n }", "void createLocalClass()\n\t{\n\t\tfinal int localVar = 10;\n\t\t\n\t\t//this is to create local class\n\t\tclass LocalClass{\n\t\t\tpublic void print(){\n\t\t\t\tSystem.out.println(\"THis is local class with Id:\");\n\t\t\t\tSystem.out.println(\"THis is local class with num:\"+nums);\n\t\t\t\tSystem.out.println(\"THis is local class with num:\"+localVar); // localVar must be final. scope is different. the value might change inside local method.\n\t\t\t}\n\t\t}\n\t\t\n\t\tLocalClass l = new LocalClass();\n\t\tl.print();\n\t}", "LocalReference createLocalReference();", "@Override\n public LocalGame createLocalGame() {\n return new LocalGameActual();\n }", "public LocalChannel() {\n\t\t}", "private static LocalCacheValue createLocalCacheValue(Object internalValue, long ldtCreation, ExpiryPolicy policy,\n JCacheSyntheticKind kind)\n {\n return new LocalCacheValue(internalValue, ldtCreation, policy, kind);\n }", "public gov.nih.nlm.ncbi.www.SeqIdDocument.SeqId.Local addNewLocal()\r\n {\r\n synchronized (monitor())\r\n {\r\n check_orphaned();\r\n gov.nih.nlm.ncbi.www.SeqIdDocument.SeqId.Local target = null;\r\n target = (gov.nih.nlm.ncbi.www.SeqIdDocument.SeqId.Local)get_store().add_element_user(LOCAL$0);\r\n return target;\r\n }\r\n }", "public LocalDecl createLocalDecl(Position pos, Flags flags, Name name, Type type, Expr init) {\n LocalDef def = xts.localDef(pos, flags, Types.ref(type), name);\n return createLocalDecl(pos, def, init);\n }", "public THLocalGame createLocalGame() {\n\n return null;\n }", "private LocalParameters() {\n\n\t}", "public LocalClient() {\n\t\tsuper(\"SERVER\", Arrays.asList(new String[] {\"*\"}), null, null);\n\t\tinputThread = new Thread(this);\n\t\tinputThread.start();\n\t}", "public LocalPlanner(RobotSessionGlobals session,\n PointCloudSafetyController pointCloudSafetyController, VelocityGenerator velocityGenerator) {\n this(session, pointCloudSafetyController, velocityGenerator, DEFAULT_DISTANCE_CLOSE_TO_GOAL);\n }", "@ApiMethod(name = \"getLocal\", path = \"local/{id}\", httpMethod = ApiMethod.HttpMethod.GET)\n public Local getLocal(@Named(\"id\") Long id)\n throws NotFoundException {\n\n return mLocalService.getById(id);\n }", "public LocalDecl createLocalDecl(Position pos, Flags flags, Name name, Type type) {\n LocalDef def = xts.localDef(pos, flags, Types.ref(type), name);\n return createLocalDecl(pos, def);\n }", "private static TransactionStatistics initLocalTransaction() {\n TransactionStatistics lts = thread.get();\n if (lts == null && configuration != null) {\n if (log.isTraceEnabled()) {\n log.tracef(\"Init a new local transaction statistics\");\n }\n lts = new LocalTransactionStatistics(configuration);\n thread.set(lts);\n //Here only when transaction starts\n TransactionTS lastTS = lastTransactionTS.get();\n if (lastTS == null) {\n if (log.isTraceEnabled())\n log.tracef(\"Init a new local transaction statistics for Timestamp\");\n lastTransactionTS.set(new TransactionTS());\n } else {\n lts.addValue(ExposedStatistic.NTBC_EXECUTION_TIME, System.nanoTime() - lastTS.getEndLastTxTs());\n lts.incrementValue(ExposedStatistic.NTBC_COUNT);\n }\n } else if (configuration == null) {\n if (log.isDebugEnabled()) {\n log.debugf(\"Trying to create a local transaction statistics in a not initialized Transaction Statistics Registry\");\n }\n } else {\n if (log.isTraceEnabled()) {\n log.tracef(\"Local transaction statistic is already initialized: %s\", lts);\n }\n }\n return lts;\n }", "public LocalResidenciaColaborador() {\n //ORM\n }", "public static LocalSettings getInstance() {\n if (INSTANCE == null) {\n INSTANCE = new LocalSettings();\n }\n \n return INSTANCE;\n }", "public abstract int allocLocal(String type);", "public LocService(String modelPath, String serializedPath) throws LocationException {\n // init the tt models\n try {\n ttLocal = new TTSessionLocal(true, true, true, modelPath, serializedPath);\n } catch (IOException | ClassNotFoundException e) {\n LOGGER.severe(\"Unable to read travel-time auxiliary data.\");\n e.printStackTrace();\n throw new LocationException(\"Unable to read travel-time auxiliary data.\");\n }\n\n // Read the Locator auxiliary files.\n try {\n locLocal = new LocSessionLocal(modelPath, serializedPath);\n } catch (IOException | ClassNotFoundException e) {\n LOGGER.severe(\"Unable to read Locator auxiliary data.\");\n e.printStackTrace();\n throw new LocationException(\"Unable to read Locator auxiliary data.\");\n }\n }", "public void setLocalId(String localId) {\n\t\t\n\t}", "public LocalSchedule(Parcel in) {\n eventId = in.readInt();\n calendarEventId = in.readString();\n eventTitle = in.readString();\n fromTime = new Date(in.readLong());\n toTime = new Date(in.readLong());\n sessionId = in.readInt();\n mandatory = in.readString();\n }", "public CasualtyControler(Local local) {\n this.terrain = local.getTerreno();\n }", "public LocalDecl createLocalDecl(Position pos, LocalDef def) {\n return xnf.LocalDecl( pos, \n xnf.FlagsNode(pos, def.flags()),\n xnf.CanonicalTypeNode(pos, def.type().get()), \n xnf.Id(pos, def.name()) ).localDef(def);\n }", "public LocalDecl createLocalDecl(Position pos, LocalDef def, Expr init) {\n return xnf.LocalDecl( pos.markCompilerGenerated(), \n xnf.FlagsNode(pos, def.flags()),\n xnf.CanonicalTypeNode(pos, def.type().get()), \n xnf.Id(pos, def.name()),\n init ).localDef(def);\n }", "public LocalDatabase(String DBName) {\n\t\tname = DBName;\n\t\texternal = new RS_LastFMInterface();\t\t\n\t}", "public LocalDecisionVariable(DecisionVariableDeclaration decl, IConfiguration conf, IDecisionVariable parent) {\r\n this.decl = decl;\r\n this.state = AssignmentState.UNDEFINED;\r\n this.conf = conf;\r\n this.parent = parent;\r\n }", "public LocalRec LocalRec(RecVar recvar, LocalType body)\n\t{\n\t\t//return new LocalRec(self, recvar, body);\n\t\treturn new LocalRec(recvar, body);\n\t}", "public void setLocal(gov.nih.nlm.ncbi.www.SeqIdDocument.SeqId.Local local)\r\n {\r\n synchronized (monitor())\r\n {\r\n check_orphaned();\r\n gov.nih.nlm.ncbi.www.SeqIdDocument.SeqId.Local target = null;\r\n target = (gov.nih.nlm.ncbi.www.SeqIdDocument.SeqId.Local)get_store().find_element_user(LOCAL$0, 0);\r\n if (target == null)\r\n {\r\n target = (gov.nih.nlm.ncbi.www.SeqIdDocument.SeqId.Local)get_store().add_element_user(LOCAL$0);\r\n }\r\n target.set(local);\r\n }\r\n }", "protected void setupLocal() {}", "@Override\n\tpublic LocalRichInfo create(long id) {\n\t\tLocalRichInfo localRichInfo = new LocalRichInfoImpl();\n\n\t\tlocalRichInfo.setNew(true);\n\t\tlocalRichInfo.setPrimaryKey(id);\n\n\t\treturn localRichInfo;\n\t}", "public Locale create() {\n BaseLocale base = _locbld.getBaseLocale();\n LocaleExtensions ext = _locbld.getLocaleExtensions();\n return Locale.getInstance(base.getLanguage(), base.getScript(), base.getRegion(), base.getVariant(), ext);\n }", "public FMISComLocal create() throws javax.ejb.CreateException;", "public Location() {\n\t}", "public LocalSource(FileNode fn, String alias){\n this.fn=fn;\n this.alias=alias;\n }", "public static TipoLocal createEntity(EntityManager em) {\n TipoLocal tipoLocal = new TipoLocal()\n .tipo(DEFAULT_TIPO);\n return tipoLocal;\n }", "private LocalDevice(BluetoothStack stack) throws BluetoothStateException {\n this.bluetoothStack = stack;\n discoveryAgent = new DiscoveryAgent(this.bluetoothStack);\n addressStr = RemoteDeviceHelper.formatBluetoothAddress(this.bluetoothStack.getLocalDeviceBluetoothAddress());\n }", "public gov.nih.nlm.ncbi.www.SeqIdDocument.SeqId.Local getLocal()\r\n {\r\n synchronized (monitor())\r\n {\r\n check_orphaned();\r\n gov.nih.nlm.ncbi.www.SeqIdDocument.SeqId.Local target = null;\r\n target = (gov.nih.nlm.ncbi.www.SeqIdDocument.SeqId.Local)get_store().find_element_user(LOCAL$0, 0);\r\n if (target == null)\r\n {\r\n return null;\r\n }\r\n return target;\r\n }\r\n }", "public static Location newIntance() {\n\t\treturn new Location(null, \"mock model: \" + ((int) (1000 * Math.random())));\n\t}", "public ThreadLocal() {}", "public static synchronized LocalDatabaseSingleton getInstance(Context context) {\r\n if (mInstance == null) {\r\n mInstance = new LocalDatabaseSingleton(context);\r\n }\r\n return mInstance;\r\n }", "private final void setupLocal() {\n _topLocal = true;\n // Check for global vs local work\n if( _nlo >= 0 && _nlo < _nhi-1 ) { // Have global work?\n // Note: some top-level calls have no other global work, so\n // \"topLocal==true\" does not imply \"nlo < nhi-1\".\n int selfidx = H2O.SELF.index();\n if( _nlo < selfidx ) _nleft = remote_compute(_nlo, selfidx );\n if( selfidx+1 < _nhi ) _nrite = remote_compute(selfidx+1,_nhi);\n }\n _lo = 0; _hi = _fr.firstReadable().nChunks(); // Do All Chunks\n // If we have any output vectors, make a blockable Futures for them to\n // block on.\n if( _fr.hasAppendables() )\n _fs = new Futures();\n init(); // Setup any user's shared local structures\n }", "public Import() {\n this(null, new Name(), null, null, false, false);\n }", "public LocalUserProfile() {\n \tsuper();\n }", "public ESLocalNodeClient() {\n final Settings settings = ImmutableSettings.settingsBuilder()\n .put(\"node.name\", \"test1\").build();\n\n node = new NodeBuilder().settings(settings)\n .clusterName(\"mycluster1\")\n // .local(true)\n //.client(true)\n .build().start();\n }", "default LocalDateTime getLocalTime(int year, int month, int day, int hour, int minute, int second) {\n return LocalDateTime.parse(new StringBuilder()\n .append(year).append('-').append(preZero(month)).append('-').append(preZero(day))\n .append('T')\n .append(preZero(hour)).append(':').append(preZero(minute)).append(':').append(preZero(second))\n .toString());\n }", "public void setIdLocal(int idLocal) {\r\n this.idLocal = idLocal;\r\n }", "public WorkingFolderInfo(FilePath localPath) { this(Status.Active, localPath, \"\"); }", "public OneValueThread(ThreadLocal<Integer> threadLocal) {\n\t\tthis.threadLocal = threadLocal;\n\t}", "public Rule localDef()\n \t{\n\t\treturn sequence(\n\t\t\t\tfirstOf(\n\t\t\t\t\tsequence(typeAndOrId(), enforcedSequence(OP_ASSIGN, expr())),\n\t\t\t\t\tsequence(type(), id())),\n \t\t\t\teos());\n \t}", "public interface LocalLoader {\n \n /**\n * Load a class which is locally defined by this loader.\n *\n * @param name the class name\n * @param resolve {@code true} to resolve the class\n * @return the class, or {@code null} if there is no local class with this name\n */\n Class<?> loadClassLocal(String name, boolean resolve);\n \n /**\n * Load a resource which is locally defined by this loader. The given name is a path separated\n * by \"{@code /}\" characters.\n *\n * @param name the resource path\n * @return the resource or resources, or an empty list if there is no local resource with this name\n */\n List<Resource> loadResourceLocal(String name);\n }", "@Override\n\tpublic Location newInstance() {\n\t\treturn new Location(this.X,this.Y,0);\n\t}", "public LocalContext(int returnip, int nlocals) {\n\t\tthis.returnip = returnip;\n\t\tlocals = new Object[nlocals];\n\t}", "public LocalView(int playerId, RemoteView remoteView){\n this.playerBoardViews = remoteView.getPlayerBoardViews();\n this.playerId = playerId;\n this.mapView = remoteView.getMapView();\n this.playerPosition=remoteView.getMapView().getPlayerPosition(\n remoteView.getPlayerBoardViews().get(this.playerId).getColor());\n this.playerHand = remoteView.getPlayerHands().get(playerId);\n\n }", "public synchronized Literal createLiteral(String str) {\n\n // check whether we have it in the registry\n Literal r = (Literal)lmap.get(str);\n if(r == null) {\n r = new LiteralImpl(/*getUnusedNodeID(),*/ str);\n lmap.put(str, r);\n }\n return r;\n }", "public static LocalContext enter() {\n LocalContext ctx = current(LocalContext.class);\n if (ctx == null) { // Root.\n ctx = OSGiServices.getLocalContext();\n }\n return (LocalContext) ctx.enterInner();\n }", "public LocalPanel() {\r\n\t\tinitComponents();\r\n\t}", "public GPS newInstace(@Nullable Bundle bundle){\n return new GPS();\n }", "public lo() {}", "@DSGenerator(tool_name = \"Doppelganger\", tool_version = \"2.0\", generated_on = \"2013-12-30 12:36:07.239 -0500\", hash_original_method = \"84F635671A3C26E6B4F1228C3E17A491\", hash_generated_method = \"544C09CA031344D5713194550EB2CB9D\")\n \npublic LocalServerSocket(String name) throws IOException\n {\n impl = new LocalSocketImpl();\n\n impl.create(true);\n\n localAddress = new LocalSocketAddress(name);\n impl.bind(localAddress);\n\n impl.listen(LISTEN_BACKLOG);\n }", "public LocalPlanner(final ConnectedNode node, TransformListener tf, VoxelGrid costmap_ros){\n costmap_ros_=null;\n tf_=null;\n initialized_=false;\n this.node=node;\n //initialize the planner\n initialize(tf, costmap_ros);\n }", "public org.apache.geronimo.xbeans.geronimo.naming.GerEjbLocalRefType addNewEjbLocalRef()\n {\n synchronized (monitor())\n {\n check_orphaned();\n org.apache.geronimo.xbeans.geronimo.naming.GerEjbLocalRefType target = null;\n target = (org.apache.geronimo.xbeans.geronimo.naming.GerEjbLocalRefType)get_store().add_element_user(EJBLOCALREF$0);\n return target;\n }\n }", "public LocalVariableGen addLocalVariable(String name, Type type, InstructionHandle start, InstructionHandle end) {\n/* 170 */ return this._allocatorInit ? addLocalVariable2(name, type, start) : super.addLocalVariable(name, type, start, end);\n/* */ }", "public DistanciaLocal(double distanceRadians, String distance, String unit) {\n this.distanceRadians = distanceRadians;\n this.distance = distance;\n this.unit = unit;\n\n }", "public LocalDecl createLocalDecl(Position pos, Flags flags, Name name, Expr init) {\n if (init.type().isVoid()) {\n System.err.println(\"ERROR: ForLoopOptimizer.createLocalDecl: creating void local assignment for \" +init+ \" at \" +pos);\n }\n return createLocalDecl(pos, flags, name, init.type(), init);\n }", "public Location() {\n }", "public static LocalVpnService getInstance() {\n\n return instance;\n }", "public Lanceur() {\n\t}", "public boolean isLocal()\n {\n return true;\n }", "public UserStore create(){\n //For now, return only Local\n return new LocalUserStore(this.userCache);\n }", "public boolean isLocal();", "public static Site getLocal() {\r\n return _local;\r\n }", "public DataType<T> newInstance(Locale locale) {\r\n return newInstance(null, locale);\r\n }", "public LocalVar(java.lang.System[] $dummy) {\n super($dummy);\n }", "public MyLocation() {}", "protected Object localLookup( final Name name )\n throws NamingException\n {\n final Object value = doLocalLookup( name );\n\n // Call getObjectInstance for using any object factories\n try\n {\n final Name atom = name.getPrefix( 1 );\n return m_namespace.getObjectInstance( value, atom, this, getRawEnvironment() );\n }\n catch ( final Exception e )\n {\n final NamingException ne = new NamingException( \"getObjectInstance failed\" );\n ne.setRootCause( e );\n throw ne;\n }\n }", "public Linearmodel() {\n this(DSL.name(\"LinearModel\"), null);\n }", "public Builder<V, E> setLocal(ClusteringAlgorithmBuilder<V, E, ?> local) {\n this.local = requireNonNull(local);\n return this;\n }", "@Override\n\tpublic LightTank create() {\n\t\treturn new LightTank(GameContext.getGameContext());\n\t}", "private com.google.protobuf.SingleFieldBuilderV3<\n io.envoyproxy.envoy.config.core.v3.Locality, io.envoyproxy.envoy.config.core.v3.Locality.Builder, io.envoyproxy.envoy.config.core.v3.LocalityOrBuilder> \n getLocalityFieldBuilder() {\n if (localityBuilder_ == null) {\n localityBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<\n io.envoyproxy.envoy.config.core.v3.Locality, io.envoyproxy.envoy.config.core.v3.Locality.Builder, io.envoyproxy.envoy.config.core.v3.LocalityOrBuilder>(\n getLocality(),\n getParentForChildren(),\n isClean());\n locality_ = null;\n }\n return localityBuilder_;\n }", "default LocalDateTime getLocalTime(int year, int month, int day, int hour, int minute) {\n return getLocalTime(year, month, day, hour, minute, 0);\n }", "static Obj NewObj (String name,int kind) {\r\n\t\tObj p, obj = new Obj();\r\n obj.name = new String(name); \r\n\t\tobj.type = null; obj.kind = kind;\r\n\t\tobj.level = curLevel;\r\n\t\tp = topScope.locals;\r\n\t\t/*Para buscar si el nb de la variable nueva ya esta!!!*/\r\n\t\twhile (p != null) { \r\n \t \tif (p.name.equals(name)) Parser.SemError(1);\r\n\t\t\tp = p.next;\r\n\t\t}\r\n \t//FILO!!\r\n obj.next = topScope.locals; \r\n\t\ttopScope.locals = obj;\r\n \t//if (kind == vars) {}\r\n \t//obj.adr = topScope.nextAdr; topScope.nextAdr++;\r\n \t//obj.view();\r\n\t\treturn obj;\r\n }", "private final void setupLocal0() {\n assert _profile==null;\n _fs = new Futures();\n _profile = new MRProfile(this);\n _profile._localstart = System.currentTimeMillis();\n _topLocal = true;\n // Check for global vs local work\n int selfidx = H2O.SELF.index();\n int nlo = subShift(selfidx);\n assert nlo < _nhi;\n final int nmid = (nlo+_nhi)>>>1; // Mid-point\n if( !_run_local && nlo+1 < _nhi ) { // Have global work?\n _profile._rpcLstart = System.currentTimeMillis();\n _nleft = remote_compute(nlo+1,nmid);\n _profile._rpcRstart = System.currentTimeMillis();\n _nrite = remote_compute( nmid,_nhi);\n _profile._rpcRdone = System.currentTimeMillis();\n }\n _lo = 0; _hi = _fr.anyVec().nChunks(); // Do All Chunks\n // If we have any output vectors, make a blockable Futures for them to\n // block on.\n // get the Vecs from the K/V store, to avoid racing fetches from the map calls\n _fr.vecs();\n setupLocal(); // Setup any user's shared local structures\n _profile._localdone = System.currentTimeMillis();\n }", "public static LocalServer create(String confFile) {\n LocalServerConfig conf = LocalServerConfig.create()\n .parse(confFile)\n .build();\n return create(conf);\n }", "public com.callfire.api.data.LocalTimeZoneRestrictionDocument.LocalTimeZoneRestriction addNewLocalTimeZoneRestriction()\n {\n synchronized (monitor())\n {\n check_orphaned();\n com.callfire.api.data.LocalTimeZoneRestrictionDocument.LocalTimeZoneRestriction target = null;\n target = (com.callfire.api.data.LocalTimeZoneRestrictionDocument.LocalTimeZoneRestriction)get_store().add_element_user(LOCALTIMEZONERESTRICTION$4);\n return target;\n }\n }", "public void setLocalId(java.lang.String value) {\n this.localId = value;\n }", "public final void mT__49() throws RecognitionException {\n try {\n int _type = T__49;\n int _channel = DEFAULT_TOKEN_CHANNEL;\n // InternalIotLuaXtext.g:49:7: ( 'local' )\n // InternalIotLuaXtext.g:49:9: 'local'\n {\n match(\"local\"); \n\n\n }\n\n state.type = _type;\n state.channel = _channel;\n }\n finally {\n }\n }", "@Override\n public void createLocalMirror(Corpus corp, Ice.Identity cb, Ice.Current __current)\n {\n CorpusI cs = checkValidityAndLookup( corp );\n if (null==cs)\n {\n logger.log(Level.WARNING, \n \"CorpusServiceI.createLocalMirror: error with corpus {0}\", corp.name);\n return;\n }\n logger.log(Level.INFO, \"request to createLocalMirror( {0} )\", corp.name);\n Ice.ObjectPrx base = __current.con.createProxy( cb ).ice_oneway();\n CorpusCallbackPrx client = CorpusCallbackPrxHelper.uncheckedCast(base);\n cs.createLocalMirror( client );\n client.corpusMirrorCompleted( corp );\n }", "public boolean isLocal() {\n return mIsLocal;\n }", "public LocalDecl transformFormalToLocalDecl(X10Formal formal, Expr init) {\n return xnf.LocalDecl(formal.position(), formal.flags(), formal.type(), formal.name(), init).localDef(formal.localDef());\n }", "public Location() {\r\n \r\n }", "private LocalDatabaseSingleton(Context context) {\r\n super(context, DATABASE_NAME, null, DATABASE_VERSION);\r\n this.mContext = context;\r\n }", "static TinyMT32 getThreadLlocal(final long threadId) {\n return new TinyMT32(TinyMT32Parameter\n .getThreadLocalParameter(threadId));\n }", "public LocalVariable defineLocalVariable(QName name, XQType type,\n Expression declaring)\n {\n \n LocalVariable decl = newLocal(name, type, declaring);\n lastLocal.addAfter(decl);\n lastLocal = decl;\n return decl;\n }", "public JobBuilder localId(String localId) {\r\n job.setLocalId(localId);\r\n return this;\r\n }", "private ClassifierSplitModel localModel(){\n\n return (ClassifierSplitModel)m_localModel;\n }", "@Local\npublic interface UsersMgrLocal {\n\n String ROLE_GUEST = \"guest\";\n\n String auth(String login, String password);\n\n List<JsonPerson> getAll();\n\n JsonPerson getByUUID(String token);\n\n Staff getStaffByUUID(String token);\n\n String create(JsonPerson jsonNewPerson);\n\n boolean isLoginUsed(String login);\n\n String updateStaff(Staff newStaff, JsonPerson jsonNewPerson);\n\n void deleteStaff(Staff staff, String token);\n}" ]
[ "0.8238762", "0.74779546", "0.7296516", "0.7155114", "0.6692713", "0.63643575", "0.6188882", "0.6158966", "0.6002111", "0.5929756", "0.5918642", "0.5822729", "0.5807699", "0.5786662", "0.5688558", "0.5669993", "0.5661564", "0.5608778", "0.5555552", "0.5519792", "0.55163944", "0.55047905", "0.549999", "0.5499644", "0.5465702", "0.5465604", "0.5450694", "0.5446227", "0.5435624", "0.5408397", "0.5381154", "0.53301275", "0.532887", "0.5318396", "0.52834445", "0.5264954", "0.526", "0.525694", "0.5251771", "0.52429247", "0.523164", "0.5229305", "0.52279705", "0.5222426", "0.5221106", "0.52075255", "0.5185561", "0.51834226", "0.5176872", "0.5170239", "0.5162498", "0.51434064", "0.51420075", "0.5130483", "0.512965", "0.5124274", "0.5115625", "0.50944453", "0.5091617", "0.50914025", "0.5091192", "0.5089389", "0.5088955", "0.50871676", "0.5066615", "0.5052698", "0.50510573", "0.50509727", "0.50496817", "0.50470805", "0.5037756", "0.5032942", "0.502572", "0.50247854", "0.5021631", "0.5020586", "0.50191736", "0.49945518", "0.49939427", "0.49916717", "0.49901348", "0.4978551", "0.49706614", "0.49643528", "0.4963343", "0.4961596", "0.49522793", "0.49493992", "0.49280787", "0.4923541", "0.49218708", "0.4916536", "0.49081796", "0.49039656", "0.49035877", "0.4899443", "0.48941946", "0.48931485", "0.48913664", "0.48712203" ]
0.6007457
8
convert number to 1 condition 1. if n is divisble by 3 you can do n/3 2. if n is divisible by 2 you can do n/2 3. or you can reduce to n to n1
public static int reduceNum(int num){ if(num==1){ return 0 ; } if(num ==2){ return 1 ; } if(num==3){ return 1 ; } int ans1 = Integer.MAX_VALUE; int ans2 = Integer.MAX_VALUE; int ans3; if(num%2==0){ ans1 = 1+ reduceNum(num/2); } if(num%3==0){ ans2= 1 + reduceNum(num/3); } ans3 = 1 + reduceNum(num-1); return Math.min(ans1,Math.min(ans2,ans3)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private static int getTotient(int n) {\n int result = n;\n for(int i=2; i*i <=n; i++) {\n if(n % i == 0) {\n while(n % i == 0) n /= i;\n result -= result/i;\n }\n }\n if(n > 1) result -= result/n;\n return result;\n }", "public static int next(int n)\n { \n int x = 0;\n if(n%2 == 0)\n {\n return n/2;\n }\n else\n {\n return (3*n)+1;\n }\n }", "public static int solution(int number) {\n int result = 0;\n if (number == 3 || number == 5) {\n return number;\n }\n for (int i = 3; i < number; i++) {\n result += i % 3 == 0 || i % 5 == 0 ? i : 0;\n }\n return result;\n }", "private int d(final int n) {\r\n Set<Long> set = new Factors(n).getProperDivisors();\r\n long sum = 0;\r\n for (long i : set) {\r\n sum += i;\r\n }\r\n return (int) sum;\r\n }", "public static String part2(int n)\r\n {\r\n String result;\r\n if(n==0) \r\n {result=\"0\";}\r\n \r\n else if (n==1)\r\n {result=\"1\";}\r\n \r\n else\r\n \r\n //recursive statment to make the convertion \r\n {result=part2(n/2);\r\n \r\n //compare the remainder \r\n if(n%2==0 || n==1000 || n==2000)\r\n {result=result+\"0\";}\r\n \r\n else\r\n {result=result+\"1\";}\r\n }\r\n \r\n for(int beta=0;beta<=10;beta++){\r\n String dummy1=\"yosho\";\r\n if(beta==1)\r\n {dumm1=\"yoshard\";}\r\n if(beta==8)\r\n {\r\n int counter=1;\r\n while(counter<=3)\r\n {\r\n dummy1 = dummy1;\r\n counter++;\r\n }\r\n }\r\n }\r\n\r\n return result;\r\n \r\n }", "public static int reduceNumMemo(int number){\n\n\n\n if(dp[number]!=0){\n return dp[number] ;\n }\n\n if(number==1){\n return 0 ;\n }\n\n if(number ==2){\n return 1 ;\n }\n\n if(number==3){\n return 1 ;\n }\n int ans1 = Integer.MAX_VALUE;\n int ans2 = Integer.MAX_VALUE;\n int ans3;\n\n if(number%2==0){\n ans1 = 1+reduceNumMemo(number/2);\n }\n\n if(number%3==0){\n ans2 = 1+reduceNumMemo(number/3);\n }\n\n ans3 = 1+reduceNumMemo(number-1);\n\n dp[number] = Math.min(ans3,Math.min(ans1,ans2));\n\n return dp[number] ;\n\n\n }", "public static int contarDivisores(int n){\n int contDivisores=0;\n for(int i=1;i<=n;i++){\n if(n%i==0){contDivisores++;}\n }\n return contDivisores;\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "protected int t(int n) {\r\n\t\treturn Math.floorDiv(n * (n - 1), 2);\r\n\t}", "public static void main(String[] args) {\n long number = 6857;\n long i = 2;\n while ((number / i != 1) || (number % i != 0)) {\n if (number % i == 0) {\n number = number / i;\n } else {\n i++;\n }\n }\n System.out.println(i);\n\n }", "public static void Factorization(int number)\n\t{\n\t\t for(int i = 2; i< number; i++)\n\t\t {\n\t while(number%i == 0) \n\t {\n\t System.out.print(i+\" \");\n\t number = number/i;\n\t\t\n\t }\n\t \n\t }\n \n if(2<=number)\n {\n System.out.println(number);\n }\n \n }", "public boolean getDivisibileByN(int number, int N){\r\n\t\tint checkNumber = N;\r\n\t\tboolean returnValue = false;\r\n\t\tint count=0;\r\n\t\tdo{\r\n\t\t\tcount++;\r\n\t\t\tcheckNumber += N;// Incrementing by N\r\n\t\t\tif(checkNumber == number){\r\n\t\t\t\treturnValue = true;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tnumber -= N;\r\n\t\t\tif(checkNumber == number){\r\n\t\t\t\treturnValue = true;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}while(checkNumber <= number);\r\n\t\t\r\n\t\tSystem.out.println(\"Number of iterations : \" + count);\r\n\t\treturn returnValue;\r\n\t}", "public static void divisores(int n){\n for(int i=1;i<=n;i++){\n if(n%i==0){System.out.println(i+\" es divisor\");}\n }\n }", "String convert(int number) {\n final Supplier<IntStream> factors = () -> IntStream.of(3, 5, 7)\n .filter(factor -> number % factor == 0);\n\n if (factors.get().count() == 0) {\n return Integer.toString(number);\n }\n\n return factors.get().mapToObj(factor -> {\n switch (factor) {\n case 3:\n return \"Pling\";\n case 5:\n return \"Plang\";\n case 7:\n return \"Plong\";\n default:\n return \"\";\n }\n }).collect(Collectors.joining());\n }", "public int power3(int n) {\n if (n==0)\n return 1;\n else {\n int p = power3(n/2);\n p *= p;\n System.out.println(\"#\");\n\n if (n % 2 == 1) {\n p *= 3;\n System.out.println(\"#\");\n }\n\n return p;\n }\n }", "private int fidonicyNumber(int number) {\n\t\tif(number ==0 || number == 1)\n\t\t\treturn 1;\n\t\telse\n\t\t\treturn fidonicyNumber(number-1) + fidonicyNumber(number-2);\n\t}", "public static int sumaDivisores(int n){\n int suma=0;\n for (int i=1;i<=n;i++){\n if (n%i==0){suma+=i;}\n }\n return suma;\n }", "public static boolean isUgly(int num) {\n int n = num;\r\n if(n<=0){\r\n return false;\r\n }\r\n if(n==1){\r\n return true;\r\n }\r\n while(n>0 && n%2==0){\r\n n=n/2;\r\n }\r\n System.out.println(n);\r\n while(n>0 && n%3==0){\r\n n=n/3;\r\n }\r\n System.out.println(n);\r\n while(n>0 && n%5==0){\r\n n=n/5;\r\n }\r\n System.out.println(n);\r\n if(n==1){\r\n return true;\r\n }\r\n return false;\r\n }", "public int countDigitOne(int n) {\n long res = 0;\n for(int i = 10; i <= n*10 ; i *= 10){\n int tmp = n - (n/i)*i;\n tmp = tmp > (i/10) ? (i/10) : (tmp - i/10);\n tmp = tmp > 0 ? tmp: 0;\n// int tmp = (n%i - i/10 + 1)>(i/10)?(i/10): (n%i - i/10 + 1);\n res += n/i + tmp;\n }\n return (int)res;\n }", "public static void main(String[] args) {\nint no=38;\n//using for loop\n/*for(int i=3;i<=no;i++) {\n\tif(no==i) {\n\t\tSystem.out.println(no+ \" number is multiple of 3\");\n\t}\n\ti=i+3;\n}*/\n//using while loop\n/*int i=3;\nwhile(i<=no) {\n\tif(no==i) {\n\t\tSystem.out.println(no+\" number is multiple of 3\");\n\t}\n\ti=i+3;\n}*/\n//using do while loop\n/*int i=3;\ndo {\nif(no==i) {\n\tSystem.out.println(no+\" number is multiple of 3\");\n}\ni=i+3;\n}while(i<=no);*/\n//using recursion method\nint i=3;\n\nint result=FindNumberMunltipleOf3WithoutusingdivandmodOperator.print(i,no);\nif(result==-1) {\n\tSystem.out.println(no+\" number is multiple of 3 \");\n}\nSystem.out.println(no+\" number is not multiple of 3\");\n\n\t}", "public static int getDivisorCount1(int N) {\n int result = 0;\n for (int i = 1; i <= N; i++) {\n if (N % i == 0) result++;\n }\n return result;\n }", "int main()\n{\n int a,count=0;\n cin>>a;\n cout<<a<<\"\\n\";\n while(a!=1)\n {\n if(a%2==0)\n {\n a=a/2;\n }\n else\n {\n a=3*a+1;\n }\n count++;\n cout<<a<<\"\\n\";\n }\n cout<<count;\n return 0;\n}", "private static void jieCheng(int number){\n int result = 1;\n for (int i = 1; i < number; i++) {\n result = result * (i+1);\n }\n System.out.println(result);\n }", "public String converter(int n){\r\n str = \"\";\r\n condition = true;\r\n while(condition){\r\n if(n >= 1 && n < 100){\r\n str = str + oneToHundred(n);\r\n condition = false; \r\n }else if (n >= 100 && n < 1000){\r\n str = str + oneToHundred(n / 100);\r\n str = str + \"Hundred \";\r\n n = n % 100;\r\n condition = true; \r\n }\r\n \r\n }\r\n return str;\r\n \r\n }", "public static int factoriel(int n) {\n\t\tif(n <= 1) {\n\t\t\treturn 1;\n\t\t}else {\n\t\t\treturn n * factoriel(n - 1);\n\t\t}\n\t}" ]
[ "0.66931605", "0.66761523", "0.64186287", "0.63738143", "0.6292392", "0.6278662", "0.6247506", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226635", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6226239", "0.6220122", "0.62190896", "0.6183018", "0.611479", "0.60740656", "0.60527754", "0.60502416", "0.6045913", "0.6032075", "0.60157996", "0.60105425", "0.600799", "0.5949944", "0.594029", "0.59401345", "0.5938083", "0.5915106" ]
0.6742039
0
given a number n , you have to convert this number to 1 1. if n is divisible by 3, you can do n/3 2. if n is divisible by 2, you can do n/2 3. or you can reduce to n to n1
public static int reduceNumMemo(int number){ if(dp[number]!=0){ return dp[number] ; } if(number==1){ return 0 ; } if(number ==2){ return 1 ; } if(number==3){ return 1 ; } int ans1 = Integer.MAX_VALUE; int ans2 = Integer.MAX_VALUE; int ans3; if(number%2==0){ ans1 = 1+reduceNumMemo(number/2); } if(number%3==0){ ans2 = 1+reduceNumMemo(number/3); } ans3 = 1+reduceNumMemo(number-1); dp[number] = Math.min(ans3,Math.min(ans1,ans2)); return dp[number] ; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static int next(int n)\n { \n int x = 0;\n if(n%2 == 0)\n {\n return n/2;\n }\n else\n {\n return (3*n)+1;\n }\n }", "private static int getTotient(int n) {\n int result = n;\n for(int i=2; i*i <=n; i++) {\n if(n % i == 0) {\n while(n % i == 0) n /= i;\n result -= result/i;\n }\n }\n if(n > 1) result -= result/n;\n return result;\n }", "private int d(final int n) {\r\n Set<Long> set = new Factors(n).getProperDivisors();\r\n long sum = 0;\r\n for (long i : set) {\r\n sum += i;\r\n }\r\n return (int) sum;\r\n }", "protected int t(int n) {\r\n\t\treturn Math.floorDiv(n * (n - 1), 2);\r\n\t}", "public static int factoriel(int n) {\n\t\tif(n <= 1) {\n\t\t\treturn 1;\n\t\t}else {\n\t\t\treturn n * factoriel(n - 1);\n\t\t}\n\t}", "public int power3(int n) {\n if (n==0)\n return 1;\n else {\n int p = power3(n/2);\n p *= p;\n System.out.println(\"#\");\n\n if (n % 2 == 1) {\n p *= 3;\n System.out.println(\"#\");\n }\n\n return p;\n }\n }", "public static long u(int n)\r\n\t{\r\n\t\tlong result = 0;\r\n\t\tlong current = 1;\r\n\t\tfor (int i = 0; i <= 10; i++)\r\n\t\t{\r\n\t\t\tif (i % 2 == 0)\r\n\t\t\t{\r\n\t\t\t\tresult += current;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tresult -= current;\r\n\t\t\t}\r\n\t\t\tcurrent *= n;\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}", "public static String part2(int n)\r\n {\r\n String result;\r\n if(n==0) \r\n {result=\"0\";}\r\n \r\n else if (n==1)\r\n {result=\"1\";}\r\n \r\n else\r\n \r\n //recursive statment to make the convertion \r\n {result=part2(n/2);\r\n \r\n //compare the remainder \r\n if(n%2==0 || n==1000 || n==2000)\r\n {result=result+\"0\";}\r\n \r\n else\r\n {result=result+\"1\";}\r\n }\r\n \r\n for(int beta=0;beta<=10;beta++){\r\n String dummy1=\"yosho\";\r\n if(beta==1)\r\n {dumm1=\"yoshard\";}\r\n if(beta==8)\r\n {\r\n int counter=1;\r\n while(counter<=3)\r\n {\r\n dummy1 = dummy1;\r\n counter++;\r\n }\r\n }\r\n }\r\n\r\n return result;\r\n \r\n }", "public static int reduceNum(int num){\n\n if(num==1){\n return 0 ;\n }\n\n if(num ==2){\n return 1 ;\n }\n\n if(num==3){\n return 1 ;\n }\n int ans1 = Integer.MAX_VALUE;\n int ans2 = Integer.MAX_VALUE;\n int ans3;\n\n if(num%2==0){\n ans1 = 1+ reduceNum(num/2);\n }\n if(num%3==0){\n ans2= 1 + reduceNum(num/3);\n }\n\n ans3 = 1 + reduceNum(num-1);\n\n return Math.min(ans1,Math.min(ans2,ans3));\n\n }", "public static int sumaDivisores(int n){\n int suma=0;\n for (int i=1;i<=n;i++){\n if (n%i==0){suma+=i;}\n }\n return suma;\n }", "public static void divisores(int n){\n for(int i=1;i<=n;i++){\n if(n%i==0){System.out.println(i+\" es divisor\");}\n }\n }", "public static int contarDivisores(int n){\n int contDivisores=0;\n for(int i=1;i<=n;i++){\n if(n%i==0){contDivisores++;}\n }\n return contDivisores;\n }", "public int nthUglyNumber(int n) {\n TreeSet<Long> set = new TreeSet<>();\n set.add(1L);\n long current = 1;\n for(int i = 0; i < n; i++){\n current = set.pollFirst();\n set.add(current*2);\n set.add(current*3);\n set.add(current*5);\n }\n return (int)current;\n }", "public static int generateFirstHalf(int n) {\n return ((int) Math.pow(10, n) - 1); // 99*99 < 9889, 999*999 < 998899 etc, so in this case, we could start checking from 10^n - 3\n }", "public int fact(int n) {\n if (n == 0 || n == 1) {\r\n // Return 1\r\n return 1;\r\n }\r\n // Anthing else? 2 times 1!\r\n return n * fact(n - 1);\r\n }", "private static int fact(int n) {\n\t\tint prod = 1;\n\t\tfor (int i = 1; i <= n; prod *= i++)\n\t\t\t;\n\t\treturn prod;\n\t}", "public String converter(int n){\r\n str = \"\";\r\n condition = true;\r\n while(condition){\r\n if(n >= 1 && n < 100){\r\n str = str + oneToHundred(n);\r\n condition = false; \r\n }else if (n >= 100 && n < 1000){\r\n str = str + oneToHundred(n / 100);\r\n str = str + \"Hundred \";\r\n n = n % 100;\r\n condition = true; \r\n }\r\n \r\n }\r\n return str;\r\n \r\n }", "public int steps(int n) {\n\n\t\tint steps = 0;\n\t\tQueue<Integer> q = new ArrayDeque<>();\n\n\t\tSet<Integer> set = new HashSet<>();\n\n\t\tq.add(n);\n\t\tset.add(n);\n\n\t\twhile (!q.isEmpty()) {\n\t\t\tint size = q.size();\n\t\t\tfor (int i = 0; i < size; i++) {\n\t\t\t\tint curr = q.poll();\n\t\t\t\tif (curr == 1)\n\t\t\t\t\treturn steps;\n\n\t\t\t\tif (!set.contains(curr-1)) {\n\t\t\t\t\tq.add(curr - 1);\n\t\t\t\t\tset.add(curr-1);\n\t\t\t\t}\n\n\t\t\t\tif (curr % 2 == 0 && !set.contains(curr / 2)) {\n\t\t\t\t\tq.add(curr / 2);\n\t\t\t\t\tset.add(curr / 2);\n\t\t\t\t}\n\n\t\t\t\tif (curr % 3 == 0 && !set.contains(curr / 3)) {\n\t\t\t\t\tq.add(curr / 3);\n\t\t\t\t\tset.add(curr / 3);\n\t\t\t\t}\n\n\t\t\t}\n\t\t\tsteps++;\n\n\t\t}\n\n\t\treturn steps;\n\n\t}", "public static List<Integer> calculateFor(int n) {\n\t\tArrayList<Integer> factors = new ArrayList<Integer>();\n\t\tint candidate = 2;\n\t\twhile (n > 1) {\n\t\t\twhile (n % candidate == 0) {\n\t\t\t\tfactors.add(candidate);\n\t\t\t\tn /= candidate;\n\t\t\t}\n\t\t\tcandidate++;\n\t\t}\n\t\tif (n > 1) {\n\t\t\tfactors.add(n);\n\t\t}\n\t\treturn factors;\n\t}", "static int fact1(int n)\n {\n if(n == 0 || n == 1)\n return 1;\n return n * fact1(n-1);\n }", "public static int fact(int n) {\n if (n == 0 || n == 1) {\r\n return 1;\r\n } else {\r\n return n * fact(n - 1);\r\n }\r\n }", "private static double fact(int n) {\n\t\tdouble sum = 1;\n\t\tfor(int i = 1; i <= n; i++) {\n\t\t\tsum *= i;\n\t\t}\n\t\treturn sum;\n\t}", "public static int factorialiterativa(int n){\n if(n>0){\r\n factorialrecursiva(n-1);//LLAMO A LA RECURSIVA\r\n }else {\r\n return 1;\r\n }\r\nreturn factorialrecursiva(n-1);\r\n }", "public static int fact(int n) {\n\t\tif (n <= 0) {\n\t\t\treturn 1;\n\t\t} else {\n\t\t\treturn n * fact(n - 1);\n\t\t}\n\t}", "public static int change(int n){\n if (n==1){\n return 0;\n }\n return 1;\n }", "public static int fact(int n) {\n\t\t\tif (n == 1 || n == 0) \n\t\t\t\treturn 1;\n\t\t\treturn n * fact(n - 1);\n\t\t}", "public int fact(int n){\n if(n == 1){\n return 1;\n }\n return n * (fact(n-1));\n }", "public int countDigitOne(int n) {\n long res = 0;\n for(int i = 10; i <= n*10 ; i *= 10){\n int tmp = n - (n/i)*i;\n tmp = tmp > (i/10) ? (i/10) : (tmp - i/10);\n tmp = tmp > 0 ? tmp: 0;\n// int tmp = (n%i - i/10 + 1)>(i/10)?(i/10): (n%i - i/10 + 1);\n res += n/i + tmp;\n }\n return (int)res;\n }", "public static int fact(int n){\n\t if(n < 0){\n\t return 0;\n\t }\n\t if(n == 0 || n == 1){\n\t return 1;\n\t }\n\t else{\n\t return n*fact(n-1); \n\t }\n\t}", "public static double mathConst(double x, int n){\n double result = 0;\n double item;\n double nominator = 1;\n for(int i = 0; i <= n; i++){\n if(i == 0){\n nominator = 1;\n }else {\n nominator = nominator * x;\n }\n item = nominator / factorial(i);\n result = result + item;\n }\n return result;\n }", "static int fact(int n)\n\n {\n\n int res = 1;\n\n for (int i = 2; i <= n; i++)\n\n res = res * i;\n\n return res;\n\n }", "static int solve(int n) \n\t{ \n\t // base case \n\t if (n < 0) \n\t return 0; \n\t if (n == 0) \n\t return 1; \n\t \n\t return solve(n-1) + solve(n-3) + solve(n-5); \n\t}", "static int recursiva1(int n)\n\t\t{\n\t\tif (n==0)\n\t\t\treturn 10; \n\t\tif (n==1)\n\t\t\treturn 20; \n\t\treturn recursiva1(n-1) - recursiva1 (n-2);\t\t\n\t\t}", "public static long fact(int n) {\n if (n <= 0) return 1;\n long f = 1;\n for (int i = 1; i <= n; i++) {\n f *= i;\n }\n return f;\n }", "@Override\n public int divisor_sum(int n) {\n int x;\n int sum = 0;\n for (int i = 1; i <= n; i++) {\n if(n%i == 0){\n x = i;\n sum += x;\n }\n }\n return sum;\n }", "private static int getChange(int n) {\n \t\n int count =0, tempCount = 0;\n while(n!=0){\n \t\n \tif(n >= 10){\n \t\ttempCount = n/10;\n \t\tn = n % 10;\n \t\tcount = count + tempCount;\n \t\tif(n==0)\n \t\t\tbreak;\n \t}\n \tif( n >= 5 && n < 10){\n \t\ttempCount = n/5;\n \t\tn = n % 5;\n \t\tcount = count + tempCount;\n \t\tif(n == 0)\n \t\t\tbreak;\n \t}\n \tif(n >= 1 && n < 5){\n \t\tcount = count + n;\n break;\n \t}\n }\n return count;\n }", "public int divisorSum(int n) {\n\t\tint sum = 0;\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tint z = n % i;\n\t\t\tif (z == 0) {\n\t\t\t\tsum = sum + i;\n\t\t\t}\n\t\t}\n\t\treturn sum;\n\t}", "public static long computeFactorial(int n) {\n if(n<0 || n > 15) throw new IllegalArgumentException(\"Invalid input. N must be >= 0 \");\n if(n==0 || n==1)\n return 1;\n //ddieu kien dung cua de quy \n //song sot den lenh cho nayf thi n chac chan roi vao 2.......15\n return n*computeFactorial(n-1); // n*(n-1)\n \n }", "public int nthUglyNumber2(int n) {\n Queue<Long> choushu = new PriorityQueue<>();\n if (n == 1)\n return 1;\n choushu.offer((long) 1);\n int[] factor = {2, 3, 5};\n for (int i = 2; i <= n; i++) {\n long num = choushu.poll();\n for (int f : factor) {\n long tmp = f * num;\n if (!choushu.contains(tmp))\n choushu.offer(tmp);\n }\n System.out.println(MessageFormat.format(\"num:{0},list:{1}\", num, printQueue(choushu)));\n }\n return choushu.poll().intValue();\n }", "public int calcularFatorial(int n) throws IllegalArgumentException {\n\t\tif(n<0) \n\t\t\tthrow new IllegalArgumentException(\"não existe fatorial para numeros negativo\");\n\t\tint resultado = 1;\n\t\tif (n!=0) {\n\t \tfor(int i = 2 ;i<=n;i++)\n\t \t resultado*=i;\n\t\t}\n\t\n\t\treturn resultado;\n\n\t}", "int main()\n{\n int n,i,c=0,a;\n cin>>n;\n for(i=1;c<n;c++,i++)\n {\n a=i*i;\n if(a%2==0)\n {\n cout<<a-2<<\" \";\n }\n else\n {\n cout<<a-1<<\" \";\n }\n }\n}", "public int countDigitOne(int n) {\n long res = 0;\n for(int i = 1; i < n ; i *= 10){\n res += (long)n/i + n%(i*10);\n }\n return (int)res;\n }", "static BigInteger fact(int n)\n {\n BigInteger res = BigInteger.ONE;\n for (int i = 2; i <= n; i++)\n res = res.multiply(BigInteger.valueOf(i));\n return res;\n }", "public boolean getDivisibileByN(int number, int N){\r\n\t\tint checkNumber = N;\r\n\t\tboolean returnValue = false;\r\n\t\tint count=0;\r\n\t\tdo{\r\n\t\t\tcount++;\r\n\t\t\tcheckNumber += N;// Incrementing by N\r\n\t\t\tif(checkNumber == number){\r\n\t\t\t\treturnValue = true;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tnumber -= N;\r\n\t\t\tif(checkNumber == number){\r\n\t\t\t\treturnValue = true;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}while(checkNumber <= number);\r\n\t\t\r\n\t\tSystem.out.println(\"Number of iterations : \" + count);\r\n\t\treturn returnValue;\r\n\t}", "public int countDigitOne(int n) {\n int res = 0;\n for(long i = 1 ; i <= n; i *= 10){\n long k = n/i, r = n % i;\n res += (k + 8) / 10 * i + ((k%10 == 1)?(r+1):0);\n }\n return res;\n }", "int fact(int n) {\n if (n <= 1)\n return 1;\n else\n return n * fact(n-1);\n}", "int main(){\n int n, f = 1;\n cin>>n;\n for(int i = 1;i <= n;i++)\n f*=i;\n cout<<f;\n}", "public static int calculateSum(int n)\n {\n int sum =0 ;\n for(int i = 3;i <= n; i++ )\n {\n if(i%3 == 0 || i%5 == 0)\n {\n sum += i;\n }\n }\n return sum;\n }", "public String countAndSay(int n) {\n String input = \"1\";\n\n // As per the constraint: 1 <= n <= 30.\n if(n > 0 && n <= 30) {\n // Loop starts from 0. However, counting starts from the second iteration.\n int i = 1;\n // Iterate recursively.\n while(i < n) {\n input = transform(input);\n // Increment i.\n i++;\n }\n }\n\n // If constraint is not satisfied, \"1\" is returned.\n return input; \n }", "private static int nthUglyNumber(int n) {\n if (n == 0) {\n return 1;\n }\n\n int[] dp = new int[n];\n dp[0] = 1;\n int index2 = 0, index3 = 0, index5 = 0;\n for (int i = 1; i < n; i++) {\n dp[i] = Math.min(2 * dp[index2], Math.min(3 * dp[index3], 5 * dp[index5]));\n System.out.println(dp[i]);\n if (dp[i] == 2 * dp[index2]) {\n index2++;\n }\n\n if (dp[i] == 3 * dp[index3]) {\n index3++;\n }\n\n if (dp[i] == 5 * dp[index5]) {\n index5++;\n }\n }\n\n return dp[n - 1];\n }", "public static int foo3( int n )\r\n\t{\r\n\t\tif ( n == 0 )\r\n\t\t\treturn 0;\r\n\t\telse\r\n\t\t\treturn n + foo3( n - 1 );\r\n\t\t\r\n\t}", "public int findDerangement(int n) {\n\t\tlong a = 0, b = 1, i = 3, c;\n\t\tfor (; i <= n + 1; i ++) {\n\t\t\tc = (i - 1) * (a + b) % 1000000007;\n\t\t\ta = b;\n\t\t\tb = c;\n\t\t}\n\t\treturn (int) a;\n\t}", "@Override\n public int generateNumber(int n) {\n if (n == 0) {\n return 0;\n } else if (n == 1) {\n return 1;\n } else {\n // We need the following nums to do the calculation by themselves\n int num1 = 0;\n int num2 = 1;\n int num3 = 0;\n // Starting from i = 1 is because we have done the first two in num1 and num2\n for (int i = 1; i < n; i++) {\n num3 = num1 + num2;\n num1 = num2;\n num2 = num3;\n }\n return num3;\n }\n }", "public static int solution(int number) {\n int result = 0;\n if (number == 3 || number == 5) {\n return number;\n }\n for (int i = 3; i < number; i++) {\n result += i % 3 == 0 || i % 5 == 0 ? i : 0;\n }\n return result;\n }", "static int recursiva2(int n)\n\t\t{\n\t\t\tif (n==0)\n\t\t\treturn 10; \n\t\t\tif (n==1)\n\t\t\treturn 20;\n\t\t\tif (n==2)\n\t\t\treturn 30;\n\t\t\t\n\t\t\treturn recursiva2(n-1) + recursiva2 (n-2) * recursiva2 (n-3); \n\t\t}", "public int solve(int n) {\n return n & ~(n - 1);\n }", "public int factoring(int N) {\n\tfor (int i = N-1; i >= 1; i--)\n\t\tif (N % i == 0)\n\t\t\treturn i;\n\treturn 1;\n}", "private static int betterSolution(int n) {\n return n*n*n;\n }", "public static int getDivisorCount1(int N) {\n int result = 0;\n for (int i = 1; i <= N; i++) {\n if (N % i == 0) result++;\n }\n return result;\n }", "public static void reduceByOne(int n) {\n if (n >= 0) {\n reduceByOne(n - 1); //recursion function\n }\n System.out.println(\"Completed call using rec:\" + n);\n }", "public static long iterative (int n)\r\n {\r\n long mult=1;\r\n while(true)\r\n {\r\n if (n<1)\r\n throw new IllegalArgumentException(\"Number is non-positive!\");\r\n if (n==1)\r\n return (mult*n);\r\n mult=mult*n;\r\n n=n-1;\r\n }\r\n }", "private static void jieCheng(int number){\n int result = 1;\n for (int i = 1; i < number; i++) {\n result = result * (i+1);\n }\n System.out.println(result);\n }", "public static double rekursiv(double x, int n) {\n if (n == 0) {\n return 1;\n }\n if (!erPartall(n)) {\n return x*rekursiv(x*x,(n-1)/2); //Grunntall x^2, eksponent ...\n }\n else {\n return rekursiv(x*x,n/2);\n }\n }", "static int multiplesOf3And5(int n) {\n int response = 0;\n for (int i = 0; i < n; i++) {\n if (i % 3 == 0 || i % 5 == 0) {\n response += i;\n }\n }\n return response;\n }", "public static int fac(int n) {\n if(n == 1) {\n return 1;\n }\n return n*fac(n-1);\n }", "public int tripleStep(int n) {\n int result = compute(n);\n return result;\n }", "int catalan(int n) { \n int res = 0; \n \n // Base case \n if (n <= 1) { \n return 1; \n } \n for (int i = 0; i < n; i++) { \n res += catalan(i) * catalan(n - i - 1); \n } \n return res; \n }", "public static void main(String[] args) {\nint no=38;\n//using for loop\n/*for(int i=3;i<=no;i++) {\n\tif(no==i) {\n\t\tSystem.out.println(no+ \" number is multiple of 3\");\n\t}\n\ti=i+3;\n}*/\n//using while loop\n/*int i=3;\nwhile(i<=no) {\n\tif(no==i) {\n\t\tSystem.out.println(no+\" number is multiple of 3\");\n\t}\n\ti=i+3;\n}*/\n//using do while loop\n/*int i=3;\ndo {\nif(no==i) {\n\tSystem.out.println(no+\" number is multiple of 3\");\n}\ni=i+3;\n}while(i<=no);*/\n//using recursion method\nint i=3;\n\nint result=FindNumberMunltipleOf3WithoutusingdivandmodOperator.print(i,no);\nif(result==-1) {\n\tSystem.out.println(no+\" number is multiple of 3 \");\n}\nSystem.out.println(no+\" number is not multiple of 3\");\n\n\t}", "private static int factorial(int n) {\n if (n == 1 || n == 0)\n return 1;\n else\n return n * factorial(n - 1);\n }", "int factorial(int n){\n return (n==1||n==0)?1: n*factorial(n-1);\n }", "public static void Factorization(int number)\n\t{\n\t\t for(int i = 2; i< number; i++)\n\t\t {\n\t while(number%i == 0) \n\t {\n\t System.out.print(i+\" \");\n\t number = number/i;\n\t\t\n\t }\n\t \n\t }\n \n if(2<=number)\n {\n System.out.println(number);\n }\n \n }", "public static void solve(int n, List<Integer> a) {\n Collections.sort(a);\n Collections.reverse(a);\n double sum = a.stream().mapToDouble(num -> Double.valueOf(num)).sum();\n double currentN = Double.valueOf(n);\n double currentSum = sum;\n for(Integer next : a)\n {\n double nextDouble = Double.valueOf(next);\n if(nextDouble<=currentSum/currentN)\n {\n break;\n }\n currentSum -= nextDouble;\n currentN--;\n }\n System.out.println(currentSum/currentN);\n\n\n }", "public double alternatingSequence(int n)\r\n {\r\n double sum = 0;\r\n\r\n for (int i = 1; i <= n; i++)\r\n sum += Math.pow(-1, i - 1)/i;\r\n\r\n return sum;\r\n }", "private static int factorial(int n) {\n if (n <= 0) {\n return 1;\n }\n\n return n * factorial(n - 1);\n }", "private static final long floorDivide(long n, long d) {\n\treturn ((n >= 0) ? \n\t\t(n / d) : (((n + 1L) / d) - 1L));\n }", "private Proof notDivides(int n, int m, Expression expression) {\n Expression litMPrev = intToLit(m - 1); //[m - 1]\n if (n == 0) {\n return notDividesBase(expression, litMPrev); //|- 0 * z = [m - 1]\n }\n Variable x = var(\"x\");\n Expression litN = intToLit(n); //[n]\n Proof noDivi0 = notMulZero(litN, litMPrev); //![n] * 0 = [m]\n Expression litM = intToLit(m); //[m]\n Expression not = not(equal(multi(litN, x), litM)); //![n] * x = [m]\n Proof nextStep = notDividesInductionStep(n, m, x); //![n] * x' = [m]\n Proof imWeak = implLeftWeakness(not, nextStep); //![n] * x = [m] -> ![n] * x' = [m]\n return inductConclusion(x, expression, noDivi0, imWeak); //![n] * 0 = [m] & @z(![n] * x = [m] -> ![n] * x' = [m]) -> !([n] * x = [m])\n }", "public int square1(int n) {\n int result = 0;\n for (int i = 0; i <= n; i++) {\n result = i * i;\n }\n return result;\n }", "public static long stepPerms(int n) {\n long[] d = new long[n];\n\n for (int j = 0; j < Math.min(3, n); j++) {\n d[j] = 1;\n }\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < 3; j++) {\n if (i > j) {\n d[i] += d[i - j - 1];\n }\n d[i] %= MOD;\n }\n }\n return d[n - 1];\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }", "public int Div(int num){\n\tint count01 ;\n\tint count02 ;\n\tint aux03 ;\n\n\tcount01 = 0 ;\n\tcount02 = 0 ;\n\taux03 = num - 1 ;\n\twhile (count02 < aux03) {\n\t count01 = count01 + 1 ;\n\t count02 = count02 + 2 ;\n\t}\n\treturn count01 ;\t\n }" ]
[ "0.7199893", "0.7018857", "0.69237906", "0.6845908", "0.6840747", "0.66573787", "0.6621389", "0.6590784", "0.65381384", "0.64628965", "0.6460207", "0.6400337", "0.63765424", "0.6321595", "0.6320038", "0.62998044", "0.6278315", "0.6275921", "0.62752837", "0.62657005", "0.62594026", "0.62497497", "0.62489545", "0.6184389", "0.61494815", "0.6145973", "0.6143669", "0.6118584", "0.6115742", "0.61135894", "0.61134946", "0.6109673", "0.6109541", "0.6104008", "0.6101479", "0.6093842", "0.6089665", "0.60882115", "0.60769707", "0.605952", "0.6029692", "0.6011081", "0.6010898", "0.59871995", "0.5962694", "0.5962361", "0.5959398", "0.59093153", "0.59086084", "0.5902022", "0.5900451", "0.59000564", "0.5899236", "0.5897681", "0.58942735", "0.58861464", "0.5877431", "0.5874187", "0.58656824", "0.586564", "0.58597714", "0.5837332", "0.5827698", "0.5811125", "0.5808001", "0.5807696", "0.5803735", "0.5803399", "0.58019894", "0.5800878", "0.5782326", "0.5779395", "0.577635", "0.57673794", "0.5767341", "0.57651746", "0.57561946", "0.5753879", "0.5752258", "0.5752258", "0.5752258", "0.5752258", "0.5752258", "0.5752258", "0.5752258", "0.5752258", "0.5752258", "0.5752258", "0.5752258", "0.5752258", "0.5752258", "0.5752258", "0.5752258", "0.5752258", "0.5752258", "0.5752258", "0.5752258", "0.5752258", "0.5752258", "0.5752258" ]
0.61476237
25
double a = log(4, 2);
public static void main(String[] args) { double a = Math.pow(2, 3); // System.out.println(a); double[] widths = calcItemsWidth(0,5, 478); if(widths!=null){ for(double width: widths){ System.out.println(width); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static double log(double a){ \n // migrated from jWMMG - the origin of the algorithm is not known.\n if (Double.isNaN(a) || a < 0) {\n return Double.NaN;\n } else if (a == Double.POSITIVE_INFINITY) {\n return Double.POSITIVE_INFINITY;\n } else if (a == 0) {\n return Double.NEGATIVE_INFINITY;\n }\n \n long lx;\n if (a > 1) {\n lx = (long)(0.75*a); // 3/4*x\n } else {\n lx = (long)(0.6666666666666666666666666666666/a); // 2/3/x\n }\n \n int ix;\n int power;\n if (lx > Integer.MAX_VALUE) {\n ix = (int) (lx >> 31);\n power = 31;\n } else {\n ix = (int) lx;\n power = 0;\n }\n \n while (ix != 0) {\n ix >>= 1;\n power++;\n }\n \n double ret;\n if (a > 1) {\n ret = lnInternal(a / ((long) 1<<power)) + power * LN_2;\n } else {\n ret = lnInternal(a * ((long) 1<<power)) - power * LN_2;\n }\n return ret;\n }", "public double logZero(double x);", "public double log(double d){\r\n\r\n\t\tif(d == 0){\r\n\t\t\treturn 0.0;\r\n\t\t} else {\r\n\t\t\treturn Math.log(d)/Math.log(2);\r\n\t\t}\r\n\r\n\t}", "private double log2(double number){\n return (Math.log(number) / Math.log(2));\n }", "private static double log2(double x) {\n return Math.log(x) / Math.log(2);\n }", "public static double logBase2(double x){\n return Math.log(x)/Math.log(2);\n }", "public static double logarit(double value, double base) {\n\t\tif (base == Math.E)\n\t\t\treturn Math.log(value);\n\t\telse if (base == 10)\n\t\t\treturn Math.log10(value);\n\t\telse\n\t\t\treturn Double.NaN;\n\t\t\t\n\t}", "private static double lg(double x) {\n return Math.log(x) / Math.log(2.0);\n }", "public static double genExp(double a) {\r\n\t\tdouble x = 1 - generator.nextDouble();\r\n\t\tdouble exp = -1 * Math.log(x) * a;\r\n\t\treturn exp;\r\n\r\n\t}", "public static double log(double x)\n\t{\n\t if (x < 1.0)\n\t return -log(1.0/x);\n\t \n\t double m=0.0;\n\t double p=1.0;\n\t while (p <= x) {\n\t m++;\n\t p=p*2;\n\t }\n\t \n\t m = m - 1;\n\t double z = x/(p/2);\n\t \n\t double zeta = (1.0 - z)/(1.0 + z);\n\t double n=zeta;\n\t double ln=zeta;\n\t double zetasup = zeta * zeta;\n\t \n\t for (int j=1; true; j++)\n\t {\n\t n = n * zetasup;\n\t double newln = ln + n / (2 * j + 1);\n\t double term = ln/newln;\n\t if (term >= LOWER_BOUND && term <= UPPER_BOUND)\n\t return m * ln2 - 2 * ln;\n\t ln = newln;\n\t }\n\t}", "private double log2(double n) {\r\n\t\treturn Math.log(n) / Math.log(2);\r\n\t}", "@Test\n public void whenLogarithmicFunctionThenLogarithmicResults() {\n FunctionMethod functionMethod = new FunctionMethod();\n List<Double> result = functionMethod.diapason(16, 18, x -> Math.log(x) / Math.log(2.0));\n List<Double> expected = Arrays.asList(4D, 4.08746284125034D);\n assertThat(result, is(expected));\n }", "public static double log2(double x) {\n\t\tint base = 2;\n\t\treturn Math.log(x) / Math.log(base);\n\t}", "public static double lg(double x) {\n return Math.log(x) / Math.log(2);\n }", "public static float log(float base, float arg) {\n return (nlog(arg)) / nlog(base);\n }", "static private float _log(float x) {\n \t\tif (!(x > 0f)) {\n \t\t\treturn Float.NaN;\n \t\t}\n \t\t//\n \t\tfloat f = 0f;\n \t\t//\n \t\tint appendix = 0;\n \t\twhile ((x > 0f) && (x <= 1f)) {\n \t\t\tx *= 2f;\n \t\t\tappendix++;\n \t\t}\n \t\t//\n \t\tx /= 2f;\n \t\tappendix--;\n \t\t//\n \t\tfloat y1 = x - 1f;\n \t\tfloat y2 = x + 1f;\n \t\tfloat y = y1 / y2;\n \t\t//\n \t\tfloat k = y;\n \t\ty2 = k * y;\n \t\t//\n \t\tfor (long i = 1; i < 10; i += 2) {\n \t\t\tf += k / i;\n \t\t\tk *= y2;\n \t\t}\n \t\t//\n \t\tf *= 2f;\n \t\tfor (int i = 0; i < appendix; i++) {\n \t\t\tf += FLOAT_LOGFDIV2;\n \t\t}\n \t\t//\n //\t\tlogger.info(\"exit _log\" + f);\n \t\treturn f;\n \t}", "public static double pow(double a, double b) {\n\t\treturn exp(b * log(a));\n\t}", "static private float exact_log(float x) {\n \t\tif (!(x > 0f)) {\n \t\t\treturn Float.NaN;\n \t\t}\n \t\t//\n \t\tfloat f = 0f;\n \t\t//\n \t\tint appendix = 0;\n \t\twhile ((x > 0f) && (x <= 1f)) {\n \t\t\tx *= 2f;\n \t\t\tappendix++;\n \t\t}\n \t\t//\n \t\tx /= 2f;\n \t\tappendix--;\n \t\t//\n \t\tfloat y1 = x - 1f;\n \t\tfloat y2 = x + 1f;\n \t\tfloat y = y1 / y2;\n \t\t//\n \t\tfloat k = y;\n \t\ty2 = k * y;\n \t\t//\n \t\tfor (long i = 1; i < 50; i += 2) {\n \t\t\tf += k / i;\n \t\t\tk *= y2;\n \t\t}\n \t\t//\n \t\tf *= 2f;\n \t\tfor (int i = 0; i < appendix; i++) {\n \t\t\tf += FLOAT_LOGFDIV2;\n \t\t}\n \t\t//\n //\t\tlogger.info(\"exit _log\" + f);\n \t\treturn f;\n \t}", "void mo130799a(double d);", "private double f(double x) {\n return (1 / (1 + Math.exp(-x)));\n }", "private static int getlog(int operand, int base) {\n double answ = Math.log(operand)/Math.log(base);\n if (answ == Math.ceil(answ)) {\n return (int)answ;\n }\n else {\n return (int)answ+1;\n }\n }", "public static double sumLogProb (double a, double b)\n\t{\n\t\tif (a == Double.NEGATIVE_INFINITY) {\n\t\t\tif (b == Double.NEGATIVE_INFINITY)\n\t\t\t\treturn Double.NEGATIVE_INFINITY;\n return b;\n\t\t}\n\t\telse if (b == Double.NEGATIVE_INFINITY)\n\t\t\treturn a;\n\t\telse if (a > b)\n\t\t\treturn a + Math.log (1 + Math.exp(b-a));\n\t\telse\n\t\t\treturn b + Math.log (1 + Math.exp(a-b));\n\t}", "public static double exp(double a)\n\t{\n\t boolean neg = a < 0 ? true : false;\n\t if (a < 0)\n a = -a;\n int fac = 1;\n \t double term = a;\n \t double sum = 0;\n \t double oldsum = 0;\n \t double end;\n\n \t do {\n \t oldsum = sum;\n \t sum += term;\n \n \t fac++;\n \n \t term *= a/fac;\n\t end = sum/oldsum;\n \t } while (end < LOWER_BOUND || end > UPPER_BOUND);\n\n sum += 1.0f;\n \n\t return neg ? 1.0f/sum : sum;\n\t}", "public double logResult(double f) {\n double r;\n try {\n r = 20 * Math.log10(result(f));\n } catch (Exception e) {\n r = -100;\n }\n if (Double.isInfinite(r) || Double.isNaN(r)) {\n r = -100;\n }\n return r;\n }", "void log(Log log);", "@Override\r\n\tpublic double evaluate(double input1) throws ArithmeticException \r\n\t{\n\t\treturn Math.log(input1);\r\n\t}", "public static final float log(float x) {\n \t\tif (!(x > 0f)) {\n \t\t\treturn Float.NaN;\n \t\t}\n \t\t//\n \t\tif (x == 1f) {\n \t\t\treturn 0f;\n \t\t}\n \t\t// Argument of _log must be (0; 1]\n \t\tif (x > 1f) {\n \t\t\tx = 1 / x;\n \t\t\treturn -_log(x);\n \t\t}\n \t\t;\n \t\t//\n \t\treturn _log(x);\n \t}", "public final void log() throws ArithmeticException {\n\t\tif ((mksa&_LOG) != 0) throw new ArithmeticException\n\t\t(\"****Unit: log(\" + symbol + \")\") ;\n\t\tvalue = AstroMath.log(value);\n\t\tmksa |= _log;\n\t\tif (symbol != null) \n\t\t\tsymbol = \"[\" + symbol + \"]\";\t// Enough to indicate log\n\t}", "double apply(final double a);", "static public int logaritam2(int x) {\r\n\t\tint lg = 0;\r\n\t\twhile(x != 1) {\r\n\t\t\tx /= 2;\r\n\t\t\tlg++;\r\n\t\t}\r\n\t\treturn lg;\r\n\t}", "public static float nlog(float x) {\n if (x == 1) return 0;\n\n float agm = 1f;\n float g1 = 1 / (x * (1 << (DEFAULT_ACCURACY - 2)));\n float arithmetic;\n float geometric;\n\n for (int i = 0; i < 5; i++) {\n arithmetic = (agm + g1) / 2f;\n geometric = BAKSH_sqrt(agm * g1);\n agm = arithmetic;\n g1 = geometric;\n }\n\n return (PI / 2f) * (1 / agm) - DEFAULT_ACCURACY * LN2;\n }", "double test(double a){\n System.out.println(\"double a: \"+a);\n return a*a;\n }", "private double logSumExp(double x[]) {\n double maxx = Double.NEGATIVE_INFINITY;\n for (double d : x) {\n if (d > maxx) { maxx = d; }\n }\n double sum = 0.0;\n for (double d : x) {\n sum += Math.exp(d-maxx);\n }\n return maxx + Math.log(sum);\n }", "public float nextLog ()\n {\n // Generate a non-zero uniformly-distributed random value.\n float u;\n while ((u = GENERATOR.nextFloat ()) == 0)\n {\n // try again if 0\n }\n\n return (float) (-m_fMean * Math.log (u));\n }", "double d();", "private static double lnInternal(double x){\n double a = 1 - x;\n double s = -a;\n double t = a;\n \n for (int i = 2; i < 25; i++){\n t = t*a;\n s -= t/i;\n }\n return s;\n }", "public Series logarithmic()\n {\n Series logarithmic = new Series();\n logarithmic.x = new double[logarithmic.size = size];\n logarithmic.r = r;\n for(int t = 0; t<size; t++)\n logarithmic.x[t] = Math.log(x[t]);\n return logarithmic;\n }", "@Test\n public void testLogP() {\n System.out.println(\"logP\");\n NegativeBinomialDistribution instance = new NegativeBinomialDistribution(3, 0.3);\n instance.rand();\n assertEquals(Math.log(0.027), instance.logp(0), 1E-7);\n assertEquals(Math.log(0.0567), instance.logp(1), 1E-7);\n assertEquals(Math.log(0.07938), instance.logp(2), 1E-7);\n assertEquals(Math.log(0.09261), instance.logp(3), 1E-7);\n assertEquals(Math.log(0.05033709), instance.logp(10), 1E-7);\n }", "void log();", "public static double exp(double a, double b){\r\n\t\treturn Math.pow(a,b);\r\n\t}", "public static double QESPRLOG(double val) {\n\t\treturn (8.0 + Math.log10(QESPR(val)))/ 8.0;\n\t}", "public static double[] logarit(double[] data, double base) {\n\t\tdouble[] result = new double[data.length];\n\t\tfor (int i = 0; i < data.length; i++) {\n\t\t\tif (base == Math.E)\n\t\t\t\tresult[i] = Math.log(data[i]);\n\t\t\telse if (base == 10)\n\t\t\t\tresult[i] = Math.log10(data[i]);\n\t\t}\n\t\t\n\t\treturn result;\n\t}", "static int exp(int base, long n) {\n\n // 2^3=8 , 2^x=8 -> x = ln8/ln2 , otherwise x=Math.log(8)/Math/log(2)\n\n return (int) ( Math.log(n)/Math.log(base) );\n }", "public static double f(double z){\n return 1 / (1 + Math.exp(-z));\n }", "int log(byte[] data);", "private double lnGamma(double x) \n\t{\n\t\tdouble f = 0.0, z;\n\t\tif (x < 7) \n\t\t{\n\t\t\tf = 1;\n\t\t\tz = x - 1;\n\t\t\twhile (++z < 7)\n\t\t\t{\n\t\t\t\tf *= z;\n\t\t\t}\n\t\t\tx = z;\n\t\t\tf = -Math.log(f);\n\t\t}\n\t\tz = 1 / (x * x);\n\t\treturn\tf + (x - 0.5) * Math.log(x) - x + 0.918938533204673 +\n\t\t\t\t( ( ( -0.000595238095238 * z + 0.000793650793651 ) * z \n\t\t\t\t\t -0.002777777777778) * z + 0.083333333333333 ) / x;\n\t}", "private double entropy(double x) {\r\n\t\tif (x > 0)\r\n\t\t\treturn -(x * (Math.log(x) / Math.log(2.0)));\r\n\t\telse\r\n\t\t\treturn 0.0;\r\n\t}", "public static void main(String[] args) {\n\t\t\n\t\tSystem.out.println(Math.log(Math.E));\t// natural log, no negative numbers\n\t\t\n\t\tSystem.out.println(Math.log10(10));\n\n\t}", "public double lo() {\n return lo;\n }", "public double getLogProb(double value) {\n checkHasParams();\n if (value < 0) {\n return Double.NEGATIVE_INFINITY;\n } else {\n return logLambda - lambda * value;\n }\n }", "@Override\r\n\tpublic double t(double x) {\r\n\t\treturn Math.log( (x - this.getLower_bound() ) / (this.getUpper_bound() - x) );\r\n\t}", "public static Matrix log(Matrix matrix)\n {\n double base = Math.exp(1.0);\n return logN(base, matrix);\n }", "@Test\n public void whenInvokeThenReturnsLogarithmValues() {\n Funcs funcs = new Funcs();\n\n List<Double> expected = Arrays.asList(0D, 0.301D, 0.477D);\n List<Double> result = funcs.range(1, 3,\n (pStart) -> {\n double resultValue = Math.log10(pStart);\n resultValue = Math.rint(resultValue * 1000) / 1000;\n return resultValue;\n });\n\n assertThat(result, is(expected));\n }", "public static String logaritName(double base) {\n\t\tif (base == Math.E)\n\t\t\treturn \"log\";\n\t\telse if (base == 10)\n\t\t\treturn \"log10\";\n\t\telse\n\t\t\treturn \"log\" + MathUtil.format(base);\n\t}", "public static Matrix logN(double base, Matrix matrix)\n {\n Matrix result = null;\n try\n {\n result = logN(matrix, base);\n }\n catch (Exception ex)\n {\n }\n return result;\n }", "public static double [] logarithm (double [][]x){\n\t\tdouble [] log=new double [x.length-1];\n\t\t\n\t\tfor(int i=0; i<x.length-1;i++){\n\t\t\tdouble[] xk1=x[i+1];\n\t\t\tdouble[] xk=x[i];\n\t\t\tlog[i]=Math.log10(Math.max( Math.abs(xk1[0] - xk[0]), Math.abs(xk1[1] - xk[1]) ));\n\t\t\t\n\t\t}\n\t\t\n\t\treturn log;\n\t}", "static double expon(double mean) {\n return -mean * Math.log(Math.random());\n }", "public double logDeterminant(){\r\n \tint n = this.nrow;\r\n \tif(n!=this.ncol)throw new IllegalArgumentException(\"Matrix is not square\");\r\n \tdouble det = 0.0D;\r\n \tMatrix ludmat = this.luDecomp();\r\n\r\n\t \tdet = ludmat.dswap;\r\n\t \tdet=Math.log(det);\r\n \tfor(int j=0; j<n; j++){\r\n \t\tdet += Math.log(ludmat.matrix[j][j]);\r\n \t}\r\n \treturn det;\r\n \t}", "public static boolean isPowerof4Log(int num){\n\t\tdouble logNum = Math.log(num)/Math.log(4) % 4;\n\t\tif (logNum == (int)logNum){\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}", "static double powerOfTwoD(int n) {\n return Double.longBitsToDouble((((long)n + (long)DoubleConsts.MAX_EXPONENT) <<\n (DoubleConsts.SIGNIFICAND_WIDTH-1))\n & DoubleConsts.EXP_BIT_MASK);\n }", "private static final int calcLog (int value)\n {\n // Shortcut for uncached_data_length\n if (value <= 1023 )\n {\n return MIN_CACHE;\n }\n else\n {\n return (int)(Math.floor (Math.log (value) / LOG2));\n }\n }", "public int getExponent( double f ) {\r\n \r\n int exp = (int)( Math.log( f ) / Math.log( 2 ) );\r\n \r\n return exp;\r\n \r\n }", "public static int log(int n)\t\t\t\t\t\t\t\t\t\t// for a given n, compute log n by continually dividing n by 2 and counting the number of times\n\t{\n\t\tint count=0;\n\t\twhile(n>0) {\n\t\t\tcount++;\n\t\t\tn=n/2;\n\t\t}\n\t\treturn count;\n\t}", "private static double acosh(double x){\n\t\treturn Math.log(x + Math.sqrt(x*x-1.0));\n\t}", "private void naturalLog()\n\t{\n\t\tif(Fun == null)\n\t\t{\n\t\t\tsetLeftValue();\n\t\t\tresult = calc.naturalLog ( );\n\t\t\tupdateText();\n\t\t}\n\t}", "public p207() {\n double target = 1/12345.0;\n double log2 = Math.log(2);\n\n for (int x = 2; x < 2000000; x++){\n double a = Math.floor(Math.log(x) / log2) / (x-1);\n if (a < target){\n System.out.println(x*(x-1L));\n break;\n }\n }\n }", "public Hypergeometric(LogFactorialSerie logFactorial) {\n this.logFactorial = logFactorial;\n }", "@SuppressWarnings(\"deprecation\")\n\t@Override\n public double calculateLogP() {\n logP = 0.0;\n // jeffreys Prior!\n if (jeffreys) {\n logP += -Math.log(getChainValue(0));\n }\n for (int i = 1; i < chainParameter.getDimension(); i++) {\n final double mean = getChainValue(i - 1);\n final double x = getChainValue(i);\n\n if (useLogNormal) {\n\t final double sigma = 1.0 / shape; // shape = precision\n\t // convert mean to log space\n\t final double M = Math.log(mean) - (0.5 * sigma * sigma);\n\t logNormal.setMeanAndStdDev(M, sigma);\n\t logP += logNormal.logDensity(x);\n } else {\n final double scale = mean / shape;\n gamma.setBeta(scale);\n logP += gamma.logDensity(x);\n }\n }\n return logP;\n }", "public static double sumInLogDomain(double[] logs) {\n\t\tdouble maxLog = logs[0];\n\t\tint idxMax = 0;\n\t\tfor (int i = 1; i < logs.length; i++) {\n\t\t\tif (maxLog < logs[i]) {\n\t\t\t\tmaxLog = logs[i];\n\t\t\t\tidxMax = i;\n\t\t\t}\n\t\t}\n\t\t// now calculate sum of exponent of differences\n\t\tdouble sum = 0;\n\t\tfor (int i = 0; i < logs.length; i++) {\n\t\t\tif (i == idxMax) {\n\t\t\t\tsum++;\n\t\t\t} else {\n\t\t\t\tsum += Math.exp(logs[i] - maxLog);\n\t\t\t}\n\t\t}\n\t\t// and return log of sum\n\t\treturn maxLog + Math.log(sum);\n\t}", "public double pow(double base, double exponent){ return Math.pow(base, exponent); }", "public static double exp(double[] parameters) {\r\n double lambda;\r\n lambda = parameters[0];\r\n return -Math.log(1 - uniform()) / lambda;\r\n }", "public double breitWigner(double arg, double a, double gamma){ \r\n return (2. * gamma / Math.PI) / (4. * Math.pow(arg - a, 2.) + gamma * gamma);\r\n }", "public static double fun(double[] args) {\n\t\tdouble s = Math.pow(2, 3);\n\t\treturn s;\n\t}", "static double[] normalizeLogP(double[] lnP){\n double[] p = new double[lnP.length];\n \n // find the maximum\n double maxLnP = lnP[0];\n for (int i=1 ; i<p.length ; ++i){\n if (lnP[i] > maxLnP){\n maxLnP = lnP[i];\n }\n }\n \n // subtract the maximum and exponentiate\n // sum is guaranted to be >= 1.0;\n double sum = 0.0;\n for (int i=0 ; i<p.length ; ++i){\n p[i] = Math.exp(lnP[i] - maxLnP);\n if (!Double.isFinite(p[i])){\n p[i] = 0.0;\n }\n sum = sum + p[i];\n }\n \n // normalize sum to 1\n for (int i=0 ; i<p.length ; ++i){\n p[i] = p[i]/sum;\n }\n return p;\n }", "public void cal_FireLoadRating(){\r\n\tFLOAD=1.75*Math.log10(TIMBER)+0.32*Math.log10(BUO)-1.640;\r\n\t//ensure that FLOAD is greater than 0, otherwise set it to 0;\r\n\tif (FLOAD<0){FLOAD=0;\r\n\t\t}else{FLOAD=Math.pow(10, FLOAD);\r\n\t}\r\n}", "public double f(double x) {\n return Math.pow(x, 10) - 1; // Esta es la cuarta funcion f(x) vista en clase\r\n }", "include<stdio.h>\nint main()\n{\n float d;\n \n scanf(\"%f\", &d);\n float r = d/2;\n float a;\n a = 3.14 * r * r;\n printf(\"%.2f\", a);\n return 0;\n}", "private static double f(double x) {\n\t\treturn x;\n\t}", "float mo106363e();", "private double getSigmoidValue( double x )\n\t{\n\t\treturn (1 / (1 + Math.exp( -x )));\n\t}", "default public double pdf(Vec x) {\n return Math.exp(logPdf(x));\n }", "public static double power(double base, int exp) {\r\n if (exp == 0) {\r\n return 1;\r\n }\r\n\r\n if (exp > 0) {\r\n return pow(base, exp);\r\n } else {\r\n return 1 / pow(base, Math.abs(exp));\r\n }\r\n\r\n }", "public double logProb(double[] cFactor) {\n\n double logProb = 0;\n for(int i = 0; i < cFactor.length; i++) {\n logProb += Math.log(cFactor[i]);\n }\n logProb = -logProb;\n return logProb;\n }", "void multiply(double value);", "public static double logDeterminant(Matrix amat){\r\n \tint n = amat.nrow;\r\n \tif(n!=amat.ncol)throw new IllegalArgumentException(\"Matrix is not square\");\r\n \tdouble det = 0.0D;\r\n \tMatrix ludmat = amat.luDecomp();\r\n\r\n\t \tdet = ludmat.dswap;\r\n\t \tdet=Math.log(det);\r\n \tfor(int j=0; j<n; j++){\r\n \t\tdet += Math.log(ludmat.matrix[j][j]);\r\n \t}\r\n \t\treturn det;\r\n \t}", "@Test\n public void testLog() throws IOException {\n System.out.println(Double.parseDouble(\"3.123124354657668698\"));\n }", "public Double visit (NumberArgument aArg)\n {\n return aArg.getValue ();\n }", "public abstract double mo9740e();", "void mo56155a(float f);", "@Override\n\tdouble f(double x) {\n\t\treturn x;\n\t}", "@Override\n public double evaluate(Map<String, Double> assignment) throws Exception {\n\n double res = Math.log(getEx2().evaluate(assignment)) / Math.log(getEx2().evaluate(assignment));\n return res;\n }", "double doubleTheValue(double input) {\n\t\treturn input*2;\n\t}", "public double eval(double[] x) {\n\t\tdouble z = VectorOps.dot(this.weights, x); \t\t// z is still w dot x\n\t\tdouble log = 1.0 / (1.0 + Math.exp(-1 * z) ); \t// 1 / (1 + e^-z)\n\n\t\treturn log;\n\t\t\n\t}", "public static double floor(double a) {\t\n\t\treturn ((a<0)?(int)(a-1):(int)a);\t\n\t}", "public static double f(double x) {\n\t\treturn (double)Math.pow(x, 2) - 16;\n\t}", "void mo84656a(float f);", "private static double gser(double a, double x) {\r\n double gamser = 0.0;\r\n int n;\r\n double sum, del, ap;\r\n double gln = gammln(a);\r\n \r\n if(x <= 0.0) {\r\n if(x < 0.0){\r\n // nerror(\"x less than zero in series expansion gamma function\");\r\n }\r\n return gamser = 0.0;\r\n } else {\r\n ap = a;\r\n del = sum = 1.0/a;\r\n for(n = 1; n <= ITMAX; n++) {\r\n ++ap;\r\n del *= x/ap;\r\n sum += del;\r\n if(Math.abs(del) < (Math.abs(sum)*EPS)) {\r\n return gamser = sum*Math.exp(-x + (a*Math.log(x)) - (gln));\r\n }\r\n }\r\n // nerror(\"a is too large, ITMAX is too small, in series expansion gamma function\");\r\n return 0.0;\r\n }\r\n }", "public static double logBinomialCoefficient(long n, float k){\n\treturn log_gamma(n+1) - (log_gamma(k+1) + log_gamma(1+n-k));\n }", "public static int geometric( double p ) {\n // using algorithm given by Knuth\n return (int) Math.ceil( Math.log( uniform() ) / Math.log( 1.0 - p ) );\n }", "private float getLogProfile(float in) {\n final float power = 1.0f / 2.2f;\n final float log_A = 0.0f;\n float out = (float) (Math.log1p(log_A * in) / Math.log1p(log_A));\n\n // apply gamma\n out = (float) Math.pow(out, power);\n //out = Math.max(out, 0.5f);\n\n return out;\n }", "public static double sigmFunc(double a){\n if (a > 0){\n return 1;\n } else return 0;\n }" ]
[ "0.7908355", "0.7259044", "0.71860385", "0.7084757", "0.6958936", "0.693202", "0.689042", "0.688097", "0.6765195", "0.6755147", "0.6706858", "0.6643969", "0.6624744", "0.66170037", "0.6560966", "0.6510745", "0.6508397", "0.6312826", "0.63120615", "0.6226971", "0.6200442", "0.6184096", "0.6109604", "0.61031246", "0.6100588", "0.6059693", "0.605916", "0.60428965", "0.60137355", "0.5999021", "0.59500134", "0.58864474", "0.588376", "0.5872611", "0.58676594", "0.5865375", "0.5858725", "0.5824704", "0.5810437", "0.57867104", "0.5770185", "0.57675534", "0.57629174", "0.5760414", "0.5739412", "0.5728089", "0.57054603", "0.56728214", "0.5665057", "0.5648051", "0.5621658", "0.56176716", "0.5607404", "0.5605214", "0.5595043", "0.5533528", "0.548987", "0.54666364", "0.5436981", "0.5429581", "0.54043573", "0.54030985", "0.5402445", "0.5391601", "0.5390903", "0.5386372", "0.5363171", "0.53577006", "0.53433967", "0.5341697", "0.5341287", "0.5340933", "0.5325354", "0.53141123", "0.53138965", "0.53113747", "0.5302821", "0.5297911", "0.529212", "0.5272937", "0.52719593", "0.52649015", "0.5255378", "0.5254445", "0.5248366", "0.5238818", "0.523409", "0.5225852", "0.52207613", "0.5217174", "0.5216868", "0.52097815", "0.52078664", "0.5207513", "0.5202878", "0.5183979", "0.5180623", "0.51765096", "0.5173507", "0.51715547", "0.51676375" ]
0.0
-1
GATT connection is enqueued to not avoid ongoing GATT operation, between this operation and its callback API 23 minimum for connectGatt()
public void connectToDevice(boolean autoConnect) { Log.d(TAG, "connectToDevice: " + getMACAddress()); if (checkAndSetClientState(CONNECTION_STATE.DISCONNECTED, CONNECTION_STATE.CONNECTING)) { boolean status = BleDriver.mainHandler.postDelayed(new Runnable() { @Override public void run() { Log.d(TAG, "mainQueue: connectToDevice: " + getMACAddress()); setBluetoothGatt(mBluetoothDevice.connectGatt(mContext, autoConnect, mGattCallback, BluetoothDevice.TRANSPORT_LE)); startConnectionTimer(); } }, 500); if (!status) { Log.e(TAG, String.format("connectToDevice error: can't add in job queue: device=%s", getMACAddress())); } } else { Log.d(TAG, String.format("connectToDevice canceled, device %s is not disconnected", getMACAddress())); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Override\n public void onConnectionStateChange(BluetoothGatt gatt, int status,\n int newState) {\n Log.i(\"onConnectionStateChange\", \"The connection status has changed. status:\" + status + \" newState:\" + newState + \"\");\n try {\n if(status == BluetoothGatt.GATT_SUCCESS) {\n switch (newState) {\n // Has been connected to the device\n case BluetoothProfile.STATE_CONNECTED:\n Log.i(\"onConnectionStateChange\", \"Has been connected to the device\");\n if(_ConnectionStatus == ConnectionStatus.Connecting) {\n _ConnectionStatus = ConnectionStatus.Connected;\n try {\n if (_PeripheryBluetoothServiceCallBack != null)\n _PeripheryBluetoothServiceCallBack.OnConnected();\n if (gatt.getDevice().getBondState() == BluetoothDevice.BOND_BONDED){\n //Url : https://github.com/NordicSemiconductor/Android-DFU-Library/blob/release/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java\n Log.i(\"onConnectionStateChange\",\"Waiting 1600 ms for a possible Service Changed indication...\");\n // Connection successfully sleep 1600ms, the connection success rate will increase\n Thread.sleep(1600);\n }\n } catch (Exception e){}\n // Discover service\n gatt.discoverServices();\n }\n break;\n // The connection has been disconnected\n case BluetoothProfile.STATE_DISCONNECTED:\n Log.i(\"onConnectionStateChange\", \"The connection has been disconnected\");\n if(_ConnectionStatus == ConnectionStatus.Connected) {\n if (_PeripheryBluetoothServiceCallBack != null)\n _PeripheryBluetoothServiceCallBack.OnDisConnected();\n }\n Close();\n _ConnectionStatus = ConnectionStatus.DisConnected;\n break;\n /*case BluetoothProfile.STATE_CONNECTING:\n Log.i(\"onConnectionStateChange\", \"Connecting ...\");\n _ConnectionStatus = ConnectionStatus.Connecting;\n break;\n case BluetoothProfile.STATE_DISCONNECTING:\n Log.i(\"onConnectionStateChange\", \"Disconnecting ...\");\n _ConnectionStatus = ConnectionStatus.DisConnecting;\n break;*/\n default:\n Log.e(\"onConnectionStateChange\", \"newState:\" + newState);\n break;\n }\n }else {\n Log.i(\"onConnectionStateChange\", \"GATT error\");\n Close();\n if(_ConnectionStatus == ConnectionStatus.Connecting\n && _Timeout - (new Date().getTime() - _ConnectStartTime.getTime()) > 0) {\n Log.i(\"Connect\", \"Gatt Error! Try to reconnect (\"+_ConnectIndex+\")...\");\n _ConnectionStatus = ConnectionStatus.DisConnected;\n Connect(); // Connect\n }else {\n _ConnectionStatus = ConnectionStatus.DisConnected;\n if (_PeripheryBluetoothServiceCallBack != null)\n _PeripheryBluetoothServiceCallBack.OnDisConnected();\n }\n }\n }catch (Exception ex){\n Log.e(\"onConnectionStateChange\", ex.toString());\n }\n super.onConnectionStateChange(gatt, status, newState);\n }", "public void advertiseNow() {\n if (btLeAdv == null) {\r\n \tLog.v(TAG, \"btLeAdv is null!\");\r\n \tisAdvertising = false;\r\n \treturn;\r\n }\r\n\t\t\r\n\t\t// make our Base UUID the service UUID\r\n UUID serviceUUID = UUID.fromString(theBaseUUID);\r\n\t\t\r\n // make a new service\r\n theService = new BluetoothGattService(serviceUUID, BluetoothGattService.SERVICE_TYPE_PRIMARY);\r\n\t\t\r\n\t\t// loop over all the characteristics and add them to the service\r\n for (Entry<UUID, BluetoothGattCharacteristic> entry : myBGCs.entrySet()) {\r\n \t//entry.getKey();\r\n \ttheService.addCharacteristic(entry.getValue());\r\n }\r\n \r\n // make sure we're all cleared out before we add new stuff\r\n gattServices.clear();\r\n gattServiceIDs.clear();\r\n \r\n \tgattServices.add(theService);\r\n gattServiceIDs.add(new ParcelUuid(theService.getUuid()));\r\n\r\n \t// if we're already advertising, just quit here\r\n // TODO: if we get this far and advertising is already started, we may want reset everything!\r\n if(isAdvertising) return;\r\n\r\n // - calls bluetoothManager.openGattServer(activity, whatever_the_callback_is) as gattServer\r\n // --- this callback needs to override: onCharacteristicWriteRequest, onCharacteristicReadRequest,\r\n // ---- onServiceAdded, and onConnectionStateChange\r\n // then iterates over an ArrayList<BluetoothGattService> and calls .addService for each\r\n \r\n\r\n // start the gatt server and get a handle to it\r\n btGattServer = btMgr.openGattServer(thisContext, gattServerCallback);\r\n\r\n // loop over the ArrayList of BluetoothGattService(s) and add each to the gatt server \r\n for(int i = 0; i < gattServices.size(); i++) {\r\n \tbtGattServer.addService(gattServices.get(i));\r\n }\r\n \r\n\r\n // the AdvertiseData and AdvertiseSettings are both required\r\n //AdvertiseData.Builder dataBuilder = new AdvertiseData.Builder();\r\n AdvertisementData.Builder dataBuilder = new AdvertisementData.Builder();\r\n AdvertiseSettings.Builder settingsBuilder = new AdvertiseSettings.Builder();\r\n \r\n // allows us to fit in a 31 byte advertisement\r\n dataBuilder.setIncludeTxPowerLevel(false);\r\n \r\n // this is the operative call which gives the parceluuid info to our advertiser to link to our gatt server\r\n // dataBuilder.setServiceUuids(gattServiceIDs); // correspond to the advertisingServices UUIDs as ParcelUUIDs\r\n \r\n // API 5.0\r\n /*\r\n for (ParcelUuid pu: gattServiceIDs) {\r\n \tdataBuilder.addServiceUuid(pu);\r\n }\r\n */\r\n // API L\r\n dataBuilder.setServiceUuids(gattServiceIDs);\r\n \r\n // this spells FART, and right now apparently doesn't do anything\r\n byte[] serviceData = {0x46, 0x41, 0x52, 0x54}; \r\n \r\n UUID tUID = new UUID((long) 0x46, (long) 0x41);\r\n ParcelUuid serviceDataID = new ParcelUuid(tUID);\r\n \r\n // API 5.0\r\n // dataBuilder.addServiceData(serviceDataID, serviceData);\r\n \r\n // API L\r\n dataBuilder.setServiceData(serviceDataID, serviceData);\r\n \r\n // i guess we need all these things for our settings\r\n settingsBuilder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY);\r\n settingsBuilder.setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH);\r\n \r\n // API L\r\n settingsBuilder.setType(AdvertiseSettings.ADVERTISE_TYPE_CONNECTABLE);\r\n \r\n // API 5.0 \r\n //settingsBuilder.setConnectable(true);\r\n \r\n // API L\r\n \r\n \r\n\r\n //settingsBuilder.setType(AdvertiseSettings.ADVERTISE_TYPE_CONNECTABLE);\r\n\r\n // we created this earlier with bluetoothAdapter.getBluetoothLeAdvertiser();\r\n // - looks like we also need to have an advertiseCallback\r\n // --- this needs to override onSuccess and onFailure, and really those are just for debug messages\r\n // --- but it looks like you HAVE to do this\r\n // set our boolean so we don't try to re-advertise\r\n isAdvertising = true;\r\n \r\n try {\r\n \tbtLeAdv.startAdvertising(settingsBuilder.build(), dataBuilder.build(), advertiseCallback);\r\n } catch (Exception ex) {\r\n \tisAdvertising = false;\t\r\n }\r\n \r\n\r\n\r\n\t}", "@Override\n\t\t\t\t\t\t\t\tpublic void onFinish() {\n\t\t\t\t\t\t\t\t\tmDelegateConnected.onConnect(false);\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tif (mBluetoothGatt != null) {\n\t\t\t\t\t\t\t\t\t\tmBluetoothGatt.close();\n\t\t\t\t\t\t\t\t\t\tmBluetoothGatt = null;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t// Let the user launch a new connection request\n\t\t\t\t\t\t\t\t\twaitingForConnResp = false;\n\t\t\t\t\t\t\t\t}", "private void connect() {\n // after 10 seconds its connected\n new Handler().postDelayed(\n new Runnable() {\n public void run() {\n Log.d(TAG, \"Bluetooth Low Energy device is connected!!\");\n // Toast.makeText(getApplicationContext(),\"Connected!\",Toast.LENGTH_SHORT).show();\n stateService = Constants.STATE_SERVICE.CONNECTED;\n startForeground(Constants.NOTIFICATION_ID_FOREGROUND_SERVICE, prepareNotification());\n }\n }, 10000);\n\n }", "@Override\n public void run() {\n if (!conn) {\n mGatt.disconnect();\n }\n }", "public void startConnection(){\n startBTConnection(mBTDevice,MY_UUID_INSECURE);\n }", "@Override\n protected void onResume() {\n super.onResume();\n /**\n * 注册广播\n */\n registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());\n if (mBluetoothLeService != null) {\n Log.e(\"a\", \"来了\");\n result = mBluetoothLeService.connect(mDeviceAddress);\n Log.e(\"a\", \"连接请求的结果=\" + result);\n\n }\n }", "public GattDeviceConnection() {\n logger = null;\n deviceAddress = null;\n context = null;\n bleGatt = null;\n device = null;\n autoReconnect = true;\n }", "void onConnectDeviceComplete();", "public interface OnBluetoothConnectionPendingListener {\n\t\tvoid onConnectionPending();\n\t}", "@Override\n public void onConnect() {\n connected.complete(null);\n }", "private void startAdvertising() {\n BluetoothAdapter bluetoothAdapter = mBluetoothManager.getAdapter();\n if (!bluetoothAdapter.isEnabled()) {\n System.out.println(\"does not support\");\n }\n if (!bluetoothAdapter.isMultipleAdvertisementSupported()) {\n //Device does not support Bluetooth LE\n System.out.println(\"does not support\");\n }\n\n mBluetoothLeAdvertiser = bluetoothAdapter.getBluetoothLeAdvertiser();\n if (mBluetoothLeAdvertiser == null) {\n Log.w(TAG, \"Failed to create advertiser\");\n return;\n }\n\n AdvertiseSettings settings = new AdvertiseSettings.Builder()\n .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY)\n .setConnectable(true)\n .setTimeout(0)\n .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH)\n .build();\n\n AdvertiseData data = new AdvertiseData.Builder()\n .setIncludeDeviceName(true)\n .setIncludeTxPowerLevel(false)\n .addServiceUuid(new ParcelUuid(TimeProfile.TIME_SERVICE))\n .build();\n\n mBluetoothLeAdvertiser\n .startAdvertising(settings, data, mAdvertiseCallback);\n }", "public void enableTXNotification()\n { \n \t/*\n \tif (mBluetoothGatt == null) {\n \t\tshowMessage(\"mBluetoothGatt null\" + mBluetoothGatt);\n \t\tbroadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);\n \t\treturn;\n \t}\n \t\t*/\n \tBluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID);\n \tif (RxService == null) {\n showMessage(\"Rx service not found!\");\n broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);\n return;\n }\n \tBluetoothGattCharacteristic TxChar = RxService.getCharacteristic(TX_CHAR_UUID);\n if (TxChar == null) {\n showMessage(\"Tx charateristic not found!\");\n broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);\n return;\n }\n mBluetoothGatt.setCharacteristicNotification(TxChar,true);\n \n BluetoothGattDescriptor descriptor = TxChar.getDescriptor(CCCD);\n descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);\n mBluetoothGatt.writeDescriptor(descriptor);\n \t\n }", "private void initWirelessCommunication() {\n if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {\n showToast(\"BLE is not supported\");\n finish();\n } else {\n showToast(\"BLE is supported\");\n // Access Location is a \"dangerous\" permission\n int hasAccessLocation = ContextCompat.checkSelfPermission(this,\n Manifest.permission.ACCESS_COARSE_LOCATION);\n if (hasAccessLocation != PackageManager.PERMISSION_GRANTED) {\n // ask the user for permission\n ActivityCompat.requestPermissions(this,\n new String[]{Manifest.permission.ACCESS_COARSE_LOCATION},\n REQUEST_ACCESS_LOCATION);\n // the callback method onRequestPermissionsResult gets the result of this request\n }\n }\n // enable wireless communication alternative\n if (communicationAdapter == null || !communicationAdapter.isReadyToBeUsed()) {\n assert communicationAdapter != null;\n Intent enableWirelessCommunicationIntent = new Intent(communicationAdapter.actionRequestEnable());\n startActivityForResult(enableWirelessCommunicationIntent, REQUEST_ENABLE_BT);\n }\n }", "public void bluetooth_enable_discoverability()\r\n {\n\t\t\r\n Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);\r\n\t\tdiscoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);\r\n\t\tLoaderActivity.m_Activity.startActivity(discoverableIntent);\r\n\t\tserver_connect_thread = new Server_Connect_Thread();\r\n\t\tserver_connect_thread.start();\r\n\t\tmessages.clear();\r\n }", "void tryConnection(String mac)\n {\n if (outstanding_connect != null || open_connection != null) {\n return;\n }\n \n Log.d(Constants.LOG_TAG, \"Attempting to connect to \" + mac);\n \n BluetoothDevice dev = bt_adapter.getRemoteDevice(mac);\n outstanding_connect = new ConnectThread(dev, handler);\n outstanding_connect.start();\n \n }", "private void sendConfiguration() {\r\n if (currentBluetoothGatt == null) {\r\n Toast.makeText(this, \"Non Connecté\", Toast.LENGTH_SHORT).show();\r\n return;\r\n }\r\n\r\n /*EditText ledGPIOPin = findViewById(R.id.editTextPin);\r\n EditText buttonGPIOPin = findViewById(R.id.editTextPin);\r\n final String pinLed = ledGPIOPin.getText().toString();\r\n final String pinButton = buttonGPIOPin.getText().toString();\r\n\r\n final BluetoothGattService service = currentBluetoothGatt.getService(BluetoothLEManager.DEVICE_UUID);\r\n if (service == null) {\r\n Toast.makeText(this, \"UUID Introuvable\", Toast.LENGTH_SHORT).show();\r\n return;\r\n }\r\n\r\n final BluetoothGattCharacteristic buttonCharact = service.getCharacteristic(BluetoothLEManager.CHARACTERISTIC_BUTTON_PIN_UUID);\r\n final BluetoothGattCharacteristic ledCharact = service.getCharacteristic(BluetoothLEManager.CHARACTERISTIC_LED_PIN_UUID);\r\n\r\n buttonCharact.setValue(pinButton);\r\n ledCharact.setValue(pinLed);\r\n\r\n currentBluetoothGatt.writeCharacteristic(buttonCharact); // async code, you cannot send 2 characteristics at the same time!\r\n charsStack.add(ledCharact); // stack the next write*/\r\n }", "@Override\n\t\t\t\tpublic void run() {\n\t\t\t\t\tif (needAutoConnect(addr)) {\n\t\t\t\t\t\tmBleApi.connect(addr);\n\t\t\t\t\t}\n\t\t\t\t}", "public void connect()\n {\n \tLog.d(TAG, \"connect\");\n \t\n \tif(!this.isConnected ) {\n mContext.bindService(new Intent(\"com.google.tungsten.LedService\"), mServiceConnection, \n \t\tContext.BIND_AUTO_CREATE);\n \t}\n }", "void RegisterGattListener( @NonNull BleGattListener gattListener );", "@Override\r\n\t\tpublic void run() {\n\t\t\tLooper.prepare();\r\n\t\t\tbluetoothChat = new BluetoothChat(context);\r\n\t\t\tif (!BluetoothAdapter.checkBluetoothAddress(addr)) { // 检查蓝牙地址是否有效\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tBluetoothDevice device = bluetoothAdapter.getRemoteDevice(addr);\r\n\t\t\twhile (true) {\r\n\t\t\t\tif (count == LONG_TIME_CONNECTED) {\r\n\t\t\t\t\tLooper.loop();\r\n\t\t\t\t}\r\n\t\t\t\tif (device.getBondState() != BluetoothDevice.BOND_BONDED) {\r\n\t\t\t\t\t// 如果未匹配,则继续执行\r\n\t\t\t\t\t// handler.postDelayed(runnable, 5000);\r\n\t\t\t\t\ttry {\r\n\t\t\t\t\t\tClsUtils.setPin(device.getClass(), device, pin); // 手机和蓝牙采集器配对\r\n\t\t\t\t\t\tClsUtils.createBond(device.getClass(), device);\r\n\t\t\t\t\t\tremoteDevice = device; // 配对完毕就把这个设备对象传给全局的remoteDevice\r\n\t\t\t\t\t\tThread.sleep(5000);\r\n\t\t\t\t\t\tcount++;\r\n\t\t\t\t\t} catch (Exception e) {\r\n\t\t\t\t\t\t// TODO Auto-generated catch block\r\n\t\t\t\t\t\te.printStackTrace();\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// 赋值至全局\r\n\t\t\t\t\tremoteDevice = device;\r\n\t\t\t\t\t// 移除线程后立即连接\r\n\t\t\t\t\ttry {\r\n\t\t\t\t\t\tbluetoothChat.goConnect(device);\r\n\t\t\t\t\t} catch (Exception e) {\r\n\t\t\t\t\t\t// TODO: handle exception\r\n\t\t\t\t\t\te.printStackTrace();\r\n\t\t\t\t\t}\r\n\t\t\t\t\tLooper.loop();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}", "public void run() {\r\n BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();\r\n adapter.cancelDiscovery();\r\n try {\r\n btSocket.connect();\r\n Log.d(\"TAG\", \"Device connected\");\r\n isConnected = true;\r\n SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);\r\n SharedPreferences.Editor edit = preferences.edit();\r\n edit.putBoolean(\"Connection\", isConnected);\r\n edit.apply();\r\n handler.obtainMessage(CONNECTING_STATUS, 1, -1).sendToTarget();\r\n } catch (IOException e) {\r\n e.printStackTrace();\r\n try {\r\n isConnected = false;\r\n SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);\r\n SharedPreferences.Editor edit = preferences.edit();\r\n edit.putBoolean(\"Connection\", isConnected);\r\n edit.apply();\r\n btSocket.close();\r\n handler.obtainMessage(CONNECTING_STATUS, -1,-1).sendToTarget();\r\n } catch (IOException f) {\r\n f.printStackTrace();\r\n }\r\n return;\r\n }\r\n //Perform work from connection in a separate thread\r\n connectedThread = new ConnectedThread(btSocket);\r\n connectedThread.run();\r\n }", "@Override\r\n public void onCreate() {\n intent = new Intent(BROADCAST_ACTION);\r\n startBTService();\r\n// try{\r\n// mConnectedThread.write(\"2\".getBytes());\r\n// }catch(Exception e){\r\n//\r\n// }\r\n }", "@Override\n public void run() {\n if (!dati) {\n mGatt.disconnect();\n }\n }", "protected synchronized boolean connect() {\n if (isConnecting.get()) {\n if (0 == connectReturnValue.await(connectionTimeout)) {\n return true;\n } else {\n isConnecting.set(false);\n }\n }\n\n\n int connectionValue = connectReturnValue.await(connectionTimeout);\n\n //are we just pretending to be connected? if yes: reconnect.\n if (0 == connectionValue && (BluetoothProfile.STATE_CONNECTED != bluetoothManager.getConnectionState(device, GATT))) {\n connectionValue = -1;\n }\n\n if (0 == connectionValue) {\n return true;\n }\n\n //Now we really are connecting\n isConnecting.set(true);\n connectReturnValue.reset();\n\n\n if (null == logger || null == deviceAddress || null == context || null == bluetoothManager) {\n isConnecting.set(false);\n return false;\n }\n\n\n BluetoothAdapter adapter = bluetoothManager.getAdapter();\n\n if (null == adapter) {\n isConnecting.set(false);\n return false;\n }\n\n\n if (null == device) {\n device = adapter.getRemoteDevice(deviceAddress);\n }\n\n if (null == device) {\n isConnecting.set(false);\n return false;\n }\n\n\n if(null != bleGatt ){\n bleGatt.close();\n }\n\n\n bleGatt = device.connectGatt(context, autoReconnect, this);\n\n if (null == bleGatt) {\n getLogger().println(\"Can't connect to \" + device.getName());\n isConnecting.set(false);\n return false;\n\n } else {\n if (!bleGatt.connect()) {\n isConnecting.set(false);\n return false;\n }\n }\n\n int ret = connectReturnValue.await(connectionTimeout);\n isConnecting.set(false);\n return ret == 0;\n }", "@Override\n public void onConnectFailed(BluetoothLeUart uart) {\n writeLine(\"Error connecting to device!\");\n }", "private boolean connectReader() {\n BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);\n if (bluetoothManager == null) {\n Log.w(TAG, \"Unable to initialize BluetoothManager.\");\n updateConnectionState(BluetoothReader.STATE_DISCONNECTED);\n return false;\n }\n\n BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();\n if (bluetoothAdapter == null) {\n Log.w(TAG, \"Unable to obtain a BluetoothAdapter.\");\n updateConnectionState(BluetoothReader.STATE_DISCONNECTED);\n return false;\n }\n\n /*\n * Connect Device.\n */\n /* Clear old GATT connection. */\n if (mBluetoothGatt != null) {\n Log.i(TAG, \"Clear old GATT connection\");\n mBluetoothGatt.disconnect();\n mBluetoothGatt.close();\n mBluetoothGatt = null;\n }\n\n /* Create a new connection. */\n final BluetoothDevice device = bluetoothAdapter\n .getRemoteDevice(mDeviceAddress);\n\n if (device == null) {\n Log.w(TAG, \"Device not found. Unable to connect.\");\n return false;\n }\n\n /* Connect to GATT server. */\n updateConnectionState(BluetoothReader.STATE_CONNECTING);\n mBluetoothGatt = device.connectGatt(this, false, mGattCallback);\n return true;\n }", "@Override\n public void onServicesDiscovered(BluetoothGatt gatt, int status) {\n Log.i(\"onServicesDiscovered\", \"Obtaining device service information ......\");\n if (status == BluetoothGatt.GATT_SUCCESS) {\n try{\n String messages = \"-------------- (\"+Periphery.getAddress()+\")Service Services information : --------------------\\n\";\n List<BluetoothGattService> serviceList = gatt.getServices();\n messages += \"Total:\"+serviceList.size()+\"\\n\";\n for (int i = 0; i < serviceList.size(); i++) {\n BluetoothGattService theService = serviceList.get(i);\n BLEGattServiceList.add(new BLEGattService(theService));\n\n String serviceName = theService.getUuid().toString();\n String msg = \"---- Service UUID:\"+serviceName+\" -----\\n\";\n // Each Service contains multiple features\n List<BluetoothGattCharacteristic> characterList = theService.getCharacteristics();\n msg += \"Characteristic UUID List:\\n\";\n for (int j = 0; j < characterList.size(); j++) {\n BluetoothGattCharacteristic theCharacter = characterList.get(j);\n msg += \"(\"+(j+1)+\"):\"+theCharacter.getUuid()+\"\\n\";\n //msg += \" --> Value:\"+ StringConvertUtil.bytesToHexString(theCharacter.getValue())+\"\\n\";\n }\n msg += \"\\n\\n\";\n messages += msg;\n }\n messages += \"-------------- (\"+Periphery.getAddress()+\")--------------------\\n\";\n Log.i(\"onServicesDiscovered\", messages);\n }catch (Exception ex){\n Log.e(\"onServicesDiscovered\", \"Exception:\" + ex.toString());\n }\n }\n if (_PeripheryBluetoothServiceCallBack!=null){\n _PeripheryBluetoothServiceCallBack.OnServicesed(BLEGattServiceList);\n }\n super.onServicesDiscovered(gatt, status);\n }", "@SuppressLint({\"NewApi\", \"DefaultLocale\"})\n @Override\n public void onReceive(Context context, Intent intent) {\n String action = intent.getAction();\n if (BleService.ACTION_GATT_CONNECTED.equals(action)) {\n runOnUiThread(new Runnable() {\n @Override\n public void run() {\n Toast.makeText(Dialog_Activity.this, \"设备连接成功!\",\n Toast.LENGTH_LONG).show();\n }\n });\n if (mpd != null) {\n try {\n Thread.sleep(1000);\n } catch (InterruptedException e) {\n e.printStackTrace();\n }\n mpd.dismiss();\n }\n }\n if (BleService.ACTION_GATT_DISCONNECTED.equals(action)) {\n Toast.makeText(Dialog_Activity.this, \"设备断开!\", Toast.LENGTH_LONG)\n .show();\n Log.i(\"DeviceConnect\", \"DeviceConnect---onReceive: \");\n bleService.disconnect();\n }\n }", "DiscoverServicesCommand(BluetoothGatt mBluetoothGatt) {\n this.mBluetoothGatt = mBluetoothGatt;\n }", "@Override\n public void run() {\n boolean isOk = mBluetoothLeService.connect(getDeviceName());// 根据地址通过后台services去连接BLE蓝牙\n L.d(reTryCount+\" -----connect ok ? >\"+ isOk);\n if(!isOk) {\n reTryConected();\n }\n }", "private Subscriber<BluetoothDevice> prepareConnectionSubscriber() {\n Subscriber<BluetoothDevice> subscriber = new Subscriber<BluetoothDevice>() {\n @Override\n public void onCompleted() {\n mProgressDialog.dismiss();\n finish();\n }\n\n @Override\n public void onError(Throwable e) {\n mProgressDialog.dismiss();\n Toast.makeText(SearchDevicesActivity.this, R.string.error_unable_to_connect, Toast.LENGTH_LONG).show();\n }\n\n @Override\n public void onNext(BluetoothDevice device) {\n Log.d(BtApplication.TAG, \"Connection Subscriber: \" + device.getName());\n AppSettings.putDeviceMacAddress(device.getAddress());\n }\n };\n return subscriber;\n }", "@Override\n public void run()\n {\n mBluetoothLeService\n .readCharacteristic(gattCharacteristic);\n }", "public void connectService() {\n log_d( \"connectService()\" );\n\t\t// no action if debug\n if ( BT_DEBUG_SERVICE ) {\n\t\t\ttoast_short( \"No Action in debug\" );\n \treturn;\n }\n\t\t// connect the BT device at once\n\t\t// if there is a device address. \n\t\tString address = getPrefAddress();\n\t\tif ( isPrefUseDevice() && ( address != null) && !address.equals(\"\") ) {\n\t \tBluetoothDevice device = mBluetoothAdapter.getRemoteDevice( address );\n\t \tif ( mBluetoothService != null ) {\n\t \t log_d( \"connect \" + address );\n\t \tmBluetoothService.connect( device );\n\t }\n\t\t// otherwise\n\t\t// send message for the intent of the BT device list\n\t\t} else {\n\t\t\tnotifyDeviceList();\n\t\t}\n\t}", "protected void onConnect() {}", "@Override\n public void checkBluetoothInteface() {\n if (!isConnected) {\n checkForBluetooth();\n }\n }", "@Override\n public void onConnectionSuspended(int cause) {\n Log.i(DEBUG_TAG, \"Connection suspended\");\n mGoogleApiClient.connect();\n }", "private void bluetoothConnect() {\n\n btDevice = btAdapter.getRemoteDevice(EDISON_ADDRESS);\n if (btDevice == null) {\n Log.d(TAG,\"get remote device fail!\");\n finish();\n }\n\n try {\n btSocket = btDevice.createRfcommSocketToServiceRecord(SSP_UUID);\n } catch (IOException e) {\n Log.d(TAG,\"bluetooth socket create fail.\");\n }\n //save resource by cancel discovery\n btAdapter.cancelDiscovery();\n\n //connect\n try {\n btSocket.connect();\n Log.d(TAG,\"Connection established.\");\n } catch ( IOException e) {\n try {\n btSocket.close();\n }catch (IOException e2) {\n Log.d(TAG,\"unable to close socket after connect fail.\");\n }\n }\n\n //prepare outStream to send message\n try {\n outStream = btSocket.getOutputStream();\n } catch (IOException e) {\n Log.d(TAG,\"output stream init fail!\");\n }\n\n }", "private void startTimer(){\n// if(timer!= null) {\n// timer.cancel();\n// }\n// mBluetoothGatt.getConnectionState()\n// if(isstart){\n// return;\n// }\n// isstart = true;\n handler.removeCallbacksAndMessages(null);\n writeRXCharacteristic(hexStringToBytes(\"AA03030155\"));\n handler.postDelayed(new Runnable() {\n @Override\n public void run() {\n rundata();\n }\n },60*1000);\n// writeRXCharacteristic(hexStringToBytes(\"AA03030055\"));\n// TimerTask task = new TimerTask() {\n// @Override\n// public void run() {\n//// System.out.println(\"task run:\"+getCurrentTime());\n// rundata();\n// }\n// };\n// timer = new Timer();\n// timer.schedule(task, 60*1000,60*1000);\n\n }", "public interface OnLeConnectionRequestHandler {\n public void onLeDeviceConnectionRequest(BluetoothDevice device);\n }", "@Override\n public void onConnectionSuspended(int cause) {\n Log.i(\"Feelknit\", \"Connection suspended\");\n mGoogleApiClient.connect();\n }", "@Override\n public void onConnectionSuspended(int cause) {\n Log.e(TAG, \"Connection suspended\");\n mGoogleApiClient.connect();\n }", "private void connect(String deviceAddress, ExerciseMode exerciseMode, DeviceType deviceType, Choice choice, String exerciseID, String routineID)\n {\n //SmartGlove smartGlove;\n\n // Only connects if we have a bounded BLE service, which we should if this service has started\n if (mBleServiceBound)\n {\n//\n// List<Integer> ident = new ArrayList<>();\n// try {\n// ident = UserRepository.getInstance(this.getApplicationContext()).getAllIdentities();\n// }\n// catch(Exception e){\n// Log.d(TAG, \"onClick: Error with identities\");\n// }\n//\n// String exerciseName;\n//\n// // TODO Modify TexTronicsDevice to have static method to determine DeviceType to Use\n// switch (deviceType)\n// {\n// case SMART_GLOVE:\n// Log.e(\"Data log EXERCISE===\", choice.toString());\n// if(MainActivity.exercise_name != null) {\n// exerciseName = MainActivity.exercise_name;\n// Log.e(\"Data log EXERCISE===\", exerciseName);\n//\n// // TODO Assume connection will be successful, if connection fails we must remove it from list.\n// smartGlove = new SmartGlove(ident.size(),exerciseName, ExerciseInstructionFragment.flag,deviceAddress, exerciseMode, choice, exerciseID, routineID);\n// mTexTronicsList.put(deviceAddress, smartGlove);\n//\n// }\n//\n// break;\n// // Add Different Devices Here\n// case SMART_SOCK:\n//\n// if(MainActivity.exercise_name != null) {\n// exerciseName = MainActivity.exercise_name;\n// Log.e(\"Data log EXERCISE===\", exerciseName);\n//\n// // TODO Assume connection will be successful, if connection fails we must remove it from list.\n// smartGlove = new SmartGlove(ident.size(),exerciseName, ExerciseInstructionFragment.flag,deviceAddress, exerciseMode, choice, exerciseID, routineID);\n// mTexTronicsList.put(deviceAddress, smartGlove);\n//\n// }\n// // Added the Smart Sock code, just copied from above\n// //smartGlove = new SmartGlove(ident.size(),choice.toString(), ExerciseInstructionFragment.flag,deviceAddress, exerciseMode, choice, exerciseID, routineID);\n// //mTexTronicsList.put(deviceAddress, smartGlove);\n// break;\n// default:\n//\n// break;\n// }\n\n mBleService.connect(deviceAddress); //add_connected\n }\n else {\n Log.w(TAG,\"Cannot Connect - BLE Connection Service is not bound yet!\");\n }\n }", "@Override\n public void onConnectionSuspended(int cause) {\n Log.i(TAG, \"Connection suspended\");\n mGoogleApiClient.connect();\n }", "@Override\n public void onConnectionSuspended(int cause) {\n Log.i(TAG, \"Connection suspended\");\n mGoogleApiClient.connect();\n }", "private synchronized void beginRegistration() {\n if (mDeviceRegistering == null && mDevicesToRegister.size() > 0) {\n mDeviceRegistering = mDevicesToRegister.remove(0);\n if (!connectToDevice(mDeviceRegistering)) {\n endRegistration();\n }\n } else if (mDeviceRegistering == null && mDevicesToRegister.size() == 0) {\n // Run out of devices, so revert wifi connection\n resetWifiConnection();\n } else {\n // registering a device\n }\n }", "public void buttonClick_connect(View view)\n\t{\n\t\tAppSettings.showConnectionLost = false;\n\t\tLog.i(TAG, \"showConnectionLost = false\");\n\t\t\n\t\tAppSettings.bluetoothConnection = new BluetoothConnection(this.getApplicationContext(), this.btConnectionHandler);\n\t\tBluetoothAdapter btAdapter = AppSettings.bluetoothConnection.getBluetoothAdapter();\n\t\t\n\t\t// If the adapter is null, then Bluetooth is not supported\n if (btAdapter == null) {\n \tToast.makeText(getApplicationContext(), R.string.bt_not_available, Toast.LENGTH_LONG).show();\n }\n else {\n \t// If Bluetooth is not on, request that it be enabled.\n if (!btAdapter.isEnabled()) {\n Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);\n startActivityForResult(enableIntent, REQUEST_ENABLE_BT);\n }\n else {\n \t// Launch the DeviceListActivity to see devices and do scan\n Intent serverIntent = new Intent(getApplicationContext(), DeviceListActivity.class);\n startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);\n }\n }\n\t}", "private void manageConnectedSocket(BluetoothSocket acceptSocket) {\n\n }", "public UUID addChar(String charType, UUID uuid, MyGattServerHandler charHandler) {\n\t\tif (charType.equals(GATT_NOTIFY)) {\r\n\t\t\r\n\t myBGCs.put(uuid, new MyBluetoothGattCharacteristic(\r\n\t \t\tuuid,\r\n\t BluetoothGattCharacteristic.PROPERTY_NOTIFY,\r\n\t BluetoothGattCharacteristic.PERMISSION_READ,\r\n\t charHandler\r\n\t \t\t)\r\n\t );\r\n\t \r\n\t // since this is a Notify, add the descriptor\r\n\t BluetoothGattDescriptor gD = new BluetoothGattDescriptor(UUID.fromString(\"00002902-0000-1000-8000-00805F9B34FB\"), BluetoothGattDescriptor.PERMISSION_WRITE | BluetoothGattDescriptor.PERMISSION_READ);\r\n\t BluetoothGattCharacteristic bgc = myBGCs.get(uuid);\r\n\t bgc.addDescriptor(gD);\r\n\t bgc = null;\r\n\t\t}\r\n\r\n\t\tif (charType.equals(GATT_READ)) {\r\n\t\t\t\r\n\t myBGCs.put(uuid, new MyBluetoothGattCharacteristic(\r\n\t \t\tuuid,\r\n\t BluetoothGattCharacteristic.PROPERTY_READ,\r\n\t BluetoothGattCharacteristic.PERMISSION_READ,\r\n\t charHandler\r\n\t \t\t)\r\n\t );\r\n\t\t}\r\n\r\n\t\tif (charType.equals(GATT_READWRITE)) {\r\n\t\t\t\r\n\t myBGCs.put(uuid, new MyBluetoothGattCharacteristic(\r\n\t \t\tuuid,\r\n\t BluetoothGattCharacteristic.PROPERTY_WRITE | BluetoothGattCharacteristic.PROPERTY_READ,\r\n\t BluetoothGattCharacteristic.PERMISSION_WRITE | BluetoothGattCharacteristic.PERMISSION_READ,\r\n\t charHandler\r\n\t \t\t)\r\n\t );\r\n\t \r\n\t\t}\r\n\t\t\r\n\t\tif (charType.equals(GATT_WRITE)) {\r\n\t\t\t\r\n\t myBGCs.put(uuid, new MyBluetoothGattCharacteristic(\r\n\t \t\tuuid,\r\n\t BluetoothGattCharacteristic.PROPERTY_WRITE,\r\n\t BluetoothGattCharacteristic.PERMISSION_WRITE,\r\n\t charHandler\r\n\t \t\t)\r\n\t );\r\n\t \r\n\t\t}\r\n\t\t\r\n\t\tif (charType.equals(GATT_INDICATE)) {\r\n\t\t\t\r\n\t myBGCs.put(uuid, new MyBluetoothGattCharacteristic(\r\n\t \t\tuuid,\r\n\t BluetoothGattCharacteristic.PROPERTY_INDICATE,\r\n\t BluetoothGattCharacteristic.PERMISSION_READ,\r\n\t charHandler\r\n\t \t\t)\r\n\t );\r\n\t \r\n\t // since this is an Indicate, add the descriptor\r\n\t BluetoothGattDescriptor gD = new BluetoothGattDescriptor(UUID.fromString(\"00002902-0000-1000-8000-00805F9B34FB\"), BluetoothGattDescriptor.PERMISSION_WRITE | BluetoothGattDescriptor.PERMISSION_READ);\r\n\t BluetoothGattCharacteristic bgc = myBGCs.get(uuid);\r\n\t bgc.addDescriptor(gD);\r\n\t bgc = null;\r\n\t\t}\r\n\t\t\r\n\t\treturn uuid;\r\n\t}", "@Override\n public IBinder onBind(Intent intent) {\n\n AppConstants.RebootHF_reader = false;\n if (mBluetoothLeService != null) {\n final boolean result = mBluetoothLeService.connect(mDeviceAddress);\n Log.d(TAG, \"Connect request result=\" + result);\n }\n\n\n throw new UnsupportedOperationException(\"Not yet implemented\");\n }", "@Override\n public void onConnectionSuspended(int cause) {\n Log.i(TAG, \"Connection suspended\");\n mGoogleApiClient.connect();\n }", "public void onIBeaconServiceConnect();", "private void insertReadyConn(EONConnection conn) {\n\t\tListIterator<EONConnection> it = readyConns.listIterator();\n\t\t// Start at the beginning of the list and go up until we find a conn with a gamma >= to this one, then\n\t\t// insert it before (so that first-notifying conns get to send pkts first)\n\t\twhile (it.hasNext()) {\n\t\t\tEONConnection testConn = it.next();\n\t\t\tif (testConn.getGamma() >= conn.getGamma()) {\n\t\t\t\t// Rewind so we insert before this one\n\t\t\t\tit.previous();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tit.add(conn);\n\t}", "@Override\n public void onScanFailed() {\n Log.d(TAG, \"Scan Failed\");\n BluetoothManipulator.startScan();\n }", "public void connectionError() {\n\n Log.w(\"Main Activity\", \"Connection error occured\");\n if (menuBool) {//did not manually tried to disconnect\n Log.d(\"Main Activity\", \"in the app\");\n menuBool = false;\n final MainActivity ac = this;\n runOnUiThread(new Runnable() {\n public void run() {\n Toast.makeText(getBaseContext(), getString(R.string.couldnotconnect), Toast.LENGTH_SHORT).show();\n //TextView rpm = (TextView) findViewById(R.id.rpm);\n //rpm.setText(\"0 BMP\");\n Spinner spinner1 = (Spinner) findViewById(R.id.spinner1);\n if (DataHandler.getInstance().getID() < spinner1.getCount())\n spinner1.setSelection(DataHandler.getInstance().getID());\n\n if (!h7) {\n\n Log.w(\"Main Activity\", \"starting H7 after error\");\n DataHandler.getInstance().setReader(null);\n DataHandler.getInstance().setH7(new H7ConnectThread((BluetoothDevice) pairedDevices.toArray()[DataHandler.getInstance().getID() - 1], ac));\n h7 = true;\n } else if (!normal) {\n Log.w(\"Main Activity\", \"Starting normal after error\");\n DataHandler.getInstance().setH7(null);\n DataHandler.getInstance().setReader(new ConnectThread((BluetoothDevice) pairedDevices.toArray()[DataHandler.getInstance().getID() - 1], ac));\n DataHandler.getInstance().getReader().start();\n normal = true;\n }\n }\n });\n }\n }", "protected abstract void onConnect();", "private void ensureBluetoothEnabled() {\n if (!mBluetoothAdapter.isEnabled()) {\n Intent enableBtIntent = new Intent(\n BluetoothAdapter.ACTION_REQUEST_ENABLE);\n main.startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);\n } else {\n connectToBluetoothDevice(\"00:06:66:64:42:97\"); // Hard coded MAC of the BT-device.\n Log.i(tag, \"Connected to device!\");\n }\n }", "@Override // com.polidea.rxandroidble2.internal.SingleResponseOperation\n public boolean startOperation(BluetoothGatt bluetoothGatt) {\n return bluetoothGatt.readCharacteristic(this.bluetoothGattCharacteristic);\n }", "public void connect_bt(String deviceAddress) {\n Intent intent = new Intent(\"OBDStatus\");\n intent.putExtra(\"message\", \"Trying to connect with device\");\n context.sendBroadcast(intent);\n disconnect();\n BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();\n btAdapter.cancelDiscovery();\n if (deviceAddress == null || deviceAddress.isEmpty()) {\n intent.putExtra(\"message\", \"Device not found\");\n context.sendBroadcast(intent);\n return;\n }\n\n if (!btAdapter.isEnabled()) {\n intent.putExtra(\"message\", \"Bluetooth is disabled\");\n context.sendBroadcast(intent);\n return;\n }\n\n BluetoothDevice device = btAdapter.getRemoteDevice(deviceAddress);\n\n UUID uuid = UUID.fromString(\"00001101-0000-1000-8000-00805F9B34FB\");\n\n try {\n socket = device.createInsecureRfcommSocketToServiceRecord(uuid);\n socket.connect();\n isConnected = true;\n intent.putExtra(\"message\", \"OBD connected\");\n context.sendBroadcast(intent);\n } catch (IOException e) {\n Log.e(\"gping2\", \"There was an error while establishing Bluetooth connection. Falling back..\", e);\n Class<?> clazz = socket.getRemoteDevice().getClass();\n Class<?>[] paramTypes = new Class<?>[]{Integer.TYPE};\n BluetoothSocket sockFallback = null;\n try {\n Method m = clazz.getMethod(\"createInsecureRfcommSocket\", paramTypes);\n Object[] params = new Object[]{Integer.valueOf(1)};\n sockFallback = (BluetoothSocket) m.invoke(socket.getRemoteDevice(), params);\n sockFallback.connect();\n isConnected = true;\n socket = sockFallback;\n intent.putExtra(\"message\", \"OBD connected\");\n context.sendBroadcast(intent);\n } catch (Exception e2) {\n intent.putExtra(\"message\", \"OBD Connection error\");\n context.sendBroadcast(intent);\n Log.e(\"gping2\", \"BT connect error\");\n }\n }\n this.deviceAddress = deviceAddress;\n saveNewAddress();\n }", "private void enableBT() {\n if (bluetoothAdapter == null) {\n Log.e(LOG_TAG, \"Bluetooth is not supported\");\n } else if (!bluetoothAdapter.isEnabled()) {\n bluetoothAdapter.enable();\n }\n }", "public boolean connect(final String address)\n {\n Log.d(TAG, \"mBLEadapter: \" + mBLEadapter + \", BLE addr: \" + address +\n \", mBluetoothGattConnected: \" + mBluetoothGattConnected );\n\n if ((mBLEadapter == null) || (address == null) /*|| (mBluetoothGattConnected==false)*/)\n {\n Log.w(TAG, \"BluetoothAdapter not initialized or unspecified address.\");\n return false;\n }\n\n //Log.d(TAG, \"Trying to create a new connection. \" + address + \": mBLEgatt: \" + mBLEgatt.toString());\n\n if ( !address.equalsIgnoreCase(\"\") &&\n /*(address.equalsIgnoreCase(deviceAddress)) &&*/\n (mBLEgatt != null) )\n {\n Log.d(TAG, \"Trying to use an existing mBLEgatt for connection.\");\n if (mBLEgatt.connect()) return true;\n else return false;\n }\n\n Log.d(TAG, \"service, connect(), address: \" + address);\n\n\n if (!address.equalsIgnoreCase(\"\"))\n {\n final BluetoothDevice device = mBLEadapter.getRemoteDevice(address);\n if (device == null) {\n Log.w(TAG, \"Device not found, Unable to connect.\");\n return false;\n }\n mBLEgatt = device.connectGatt(this, false, gattCallback); // real to connect BLE device.\n deviceAddress = address;\n return true;\n }\n else\n {\n Log.w(TAG, \"Device addr:\" + address);\n return false;\n }\n\n }", "public void doConnect() {\n Debug.logInfo(\"Connecting to \" + client.getServerURI() + \" with device name[\" + client.getClientId() + \"]\", MODULE);\n\n IMqttActionListener conListener = new IMqttActionListener() {\n\n public void onSuccess(IMqttToken asyncActionToken) {\n Debug.logInfo(\"Connected.\", MODULE);\n state = CONNECTED;\n carryOn();\n }\n\n public void onFailure(IMqttToken asyncActionToken, Throwable exception) {\n ex = exception;\n state = ERROR;\n Debug.logError(\"connect failed\" + exception.getMessage(), MODULE);\n carryOn();\n }\n\n public void carryOn() {\n synchronized (caller) {\n donext = true;\n caller.notifyAll();\n }\n }\n };\n\n try {\n // Connect using a non-blocking connect\n client.connect(conOpt, \"Connect sample context\", conListener);\n } catch (MqttException e) {\n // If though it is a non-blocking connect an exception can be\n // thrown if validation of parms fails or other checks such\n // as already connected fail.\n state = ERROR;\n donext = true;\n ex = e;\n }\n }", "@Override\n public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord) {\n runOnUiThread(new Runnable() {\n @Override\n public void run() {\n mLeDeviceListAdapter.addDevice(device);\n mLeDeviceListAdapter.notifyDataSetChanged();\n }\n });\n }", "private void initBLESetup() {\n // Initializes Bluetooth adapter.\n final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);\n mBluetoothAdapter = bluetoothManager.getAdapter();\n //Beginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running, not when they install the app.\n //Obtaining dynamic permissions from the user\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { //23\n if (this.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {\n final AlertDialog.Builder builder = new AlertDialog.Builder(this);\n builder.setTitle(\"This app needs location access.\");\n builder.setMessage(\"Please grant location access to this app.\");\n builder.setPositiveButton(android.R.string.ok, null);\n builder.setOnDismissListener(new DialogInterface.OnDismissListener() {\n public void onDismiss(DialogInterface dialog) {\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)\n requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, PERMISSION_REQUEST_COARSE_LOCATION);\n }\n\n });// See onRequestPermissionsResult callback method for negative behavior\n builder.show();\n }\n }\n // Create callback methods\n if (Build.VERSION.SDK_INT >= 21) //LOLLIPOP\n newerVersionScanCallback = new ScanCallback() {\n @Override\n public void onScanResult(int callbackType, ScanResult result) {\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {\n BluetoothDevice btDevice = result.getDevice();\n ScanRecord mScanRecord = result.getScanRecord();\n int rssi = result.getRssi();\n// Log.i(TAG, \"Address: \"+ btDevice.getAddress());\n// Log.i(TAG, \"TX Power Level: \" + result.getScanRecord().getTxPowerLevel());\n// Log.i(TAG, \"RSSI in DBm: \" + rssi);\n// Log.i(TAG, \"Manufacturer data: \"+ mScanRecord.getManufacturerSpecificData());\n// Log.i(TAG, \"device name: \"+ mScanRecord.getDeviceName());\n// Log.i(TAG, \"Advertise flag: \"+ mScanRecord.getAdvertiseFlags());\n// Log.i(TAG, \"service uuids: \"+ mScanRecord.getServiceUuids());\n// Log.i(TAG, \"Service data: \"+ mScanRecord.getServiceData());\n byte[] recordBytes = mScanRecord.getBytes();\n\n iBeacon ib = parseBLERecord(recordBytes);\n\n if (ib != null) {\n setLog(ib.getUuid(), ib.getMajor(), ib.getMinor(), rssi);\n\n }\n }\n }\n\n @Override\n public void onScanFailed(int errorCode) {\n Log.e(\"Scan Failed\", \"Error Code: \" + errorCode);\n }\n };\n else\n olderVersionScanCallback =\n new BluetoothAdapter.LeScanCallback() {\n @Override\n public void onLeScan(final BluetoothDevice device, final int rssi,\n final byte[] scanRecord) {\n runOnUiThread(new Runnable() {\n @Override\n public void run() {\n Log.i(\"onLeScan\", device.toString());\n\n iBeacon ib = parseBLERecord(scanRecord);\n\n if (ib != null) {\n setLog(ib.getUuid(), ib.getMajor(), ib.getMinor(), rssi);\n\n }\n }\n });\n }\n };\n }", "@Override\n public void blePeripheralFound(BluetoothDeviceWrapper device, int rssi, byte[] record) {\n if ((null != device.getgBeacon()) /*|| (null != device.getiBeacon()) || (null != device.getAltBeacon())*/) {\n if ((weakReference.get()!=null) && (weakReference.get().getDeviceQueue().size() < 350)) {\n weakReference.get().getDeviceQueue().offer(device);\n }\n }\n }", "@Override\n public void onConnectionSuspended(int i) {\n\n }", "@SuppressLint(\"NewApi\")\n @Override\n public void onServiceConnected(ComponentName name, IBinder service) {\n bleService = ((BleService.LocalBinder) service).getService();\n if (!bleService.init()) {\n finish();\n }\n bleService.connect(Home_Fragment.Device_Address);\n mpd = ProgressDialog.show(Dialog_Activity.this, null, \"正在连接设备...\");\n Log.i(\"DeviceConnect\", \"onServiceConnected: \");\n }", "@Override\n public void onConnectionSuspended(int i) {\n }", "@Override\n public void gattServicesDiscovered() {\n BluetoothGattService mService = BLEService.mBluetoothGatt.getService(CapLEDConstants.CAPLED_SERVICE_UUID);\n\n mLedCharacteristic = mService.getCharacteristic(CapLEDConstants.CAPLED_LED_CHARACTERISTIC_UUID);\n mCapsenseCharacteristic = mService.getCharacteristic(CapLEDConstants.CAPLED_CAP_CHARACTERISTIC_UUID);\n mCapsenseNotification = mCapsenseCharacteristic.getDescriptor(CapLEDConstants.CAPLED_CAP_NOTIFICATION);\n\n readLedCharacteristic();\n sCapSwitch.setEnabled(true);\n }", "@Override\n public void onReceive(Context context, Intent intent)\n {\n Log.d(TAG, \"Received BLE Update\");\n // Get the MAC address and action from the intent\n String deviceAddress = intent.getStringExtra(BluetoothLeConnectionService.INTENT_DEVICE);\n String action = intent.getStringExtra(BluetoothLeConnectionService.INTENT_EXTRA);\n\n Log.d(TAG, \"Received BLE Update ACTION=====\"+ action);\n\n /*\n * The action holds what type of update we are dealing with. For each action, we\n * need to update the TT update receiver.\n */\n switch (action)\n {\n case BluetoothLeConnectionService.GATT_STATE_CONNECTING:\n TexTronicsUpdateReceiver.update(mContext, deviceAddress, TexTronicsUpdate.ble_connecting);\n break;\n case BluetoothLeConnectionService.GATT_STATE_CONNECTED:\n TexTronicsUpdateReceiver.update(mContext, deviceAddress, TexTronicsUpdate.ble_connected);\n // Once connected, we need to discover the services to find our characteristics\n mBleService.discoverServices(deviceAddress);\n\n MainActivity.CONNECTED = true;\n break;\n case BluetoothLeConnectionService.GATT_STATE_DISCONNECTING:\n TexTronicsUpdateReceiver.update(mContext, deviceAddress, TexTronicsUpdate.ble_disconnecting);\n\n // Before we disconnect, we need to publish any exercise data. Get the disconnecting device\n TexTronicsDevice disconnectingDevice = mTexTronicsList.get(deviceAddress);\n\n //TODO: DEBUG ME!!!!!\n\n // Send to Server via MQTT\n if(mMqttServiceBound && DeviceExerciseFragment.START_LOG)\n {\n try\n {\n byte[] buffer = IOUtil.readFile(disconnectingDevice.getCsvFile());\n String json = MqttConnectionService.generateJson(disconnectingDevice.getDate(),\n disconnectingDevice.getDeviceAddress(),\n Choice.toString(disconnectingDevice.getChoice()) ,\n disconnectingDevice.getExerciseID(),\n disconnectingDevice.getRoutineID(),\n new String(buffer));\n Log.d(\"SmartGlove\", \"JSON: \" + json);\n mMqttService.publishMessage(json);\n DeviceExerciseFragment.START_LOG = false;\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n break;\n case BluetoothLeConnectionService.GATT_STATE_DISCONNECTED:\n TexTronicsUpdateReceiver.update(mContext, deviceAddress, TexTronicsUpdate.ble_disconnected);\n\n // It has now been disconnected and we've published the data, now we remove the device from our list\n TexTronicsDevice disconnectDevice = mTexTronicsList.get(deviceAddress);\n if(disconnectDevice == null) {\n Log.w(TAG, \"Device not Found\");\n return;\n }\n mTexTronicsList.remove(deviceAddress);\n\n MainActivity.CONNECTED = false;\n\n break;\n case BluetoothLeConnectionService.GATT_DISCOVERED_SERVICES:\n // Enable notifications on our RX characteristic which sends our data packets\n\n if(deviceAddress.equals(GattDevices.LEFT_GLOVE_ADDR)){\n BluetoothGattCharacteristic characteristic = mBleService.getCharacteristic(deviceAddress, GattServices.UART_SERVICE2, GattCharacteristics.RX_CHARACTERISTIC2);\n if (characteristic != null) {\n mBleService.enableNotifications(deviceAddress, characteristic);\n }\n }\n if(deviceAddress.equals(GattDevices.RIGHT_GLOVE_ADDR)||deviceAddress.equals(GattDevices.LEFT_SHOE_ADDR)||deviceAddress.equals(GattDevices.RIGHT_SHOE_ADDR)) {\n BluetoothGattCharacteristic characteristic = mBleService.getCharacteristic(deviceAddress, GattServices.UART_SERVICE, GattCharacteristics.RX_CHARACTERISTIC);\n if (characteristic != null) {\n mBleService.enableNotifications(deviceAddress, characteristic);\n }\n }\n\n\n// // Write to the txChar to notify the device\n// BluetoothGattCharacteristic txChar = mBleService.getCharacteristic(deviceAddress, GattServices.UART_SERVICE, GattCharacteristics.TX_CHARACTERISTIC);/**---------------------------------------------------------------------------------------------------------*/\n// /**\n// * added to sent 1 or 2 or 3 to the bluetooth device\n// */\n// if(ExerciseInstructionFragment.flag==1)\n// {mBleService.writeCharacteristic(deviceAddress, txChar, new byte[] {0x01});\n// Log.d(TAG, \"Data sent via flex\");}\n// else if(ExerciseInstructionFragment.flag==2)\n// {mBleService.writeCharacteristic(deviceAddress, txChar, new byte[] {0x02});\n// Log.d(TAG, \"Data sent via imu\");}\n// else if(ExerciseInstructionFragment.flag==3)\n// {mBleService.writeCharacteristic(deviceAddress, txChar, new byte[] {0x03});}\n//\n// /*-----------------------------------------------------------------------------------------------------------------------------------------*/\n\n break;\n case BluetoothLeConnectionService.GATT_CHARACTERISTIC_NOTIFY:\n /* Called whenever the value of our RX characteristic is changed, which\n * is equal to the sampling rate of our connected device.\n */\n UUID characterUUID = UUID.fromString(intent.getStringExtra(BluetoothLeConnectionService.INTENT_CHARACTERISTIC));\n if(characterUUID.equals(GattCharacteristics.RX_CHARACTERISTIC)||characterUUID.equals(GattCharacteristics.RX_CHARACTERISTIC2))\n {\n // Get the data packet\n Log.d(TAG, \"Data Received\");\n byte[] data = intent.getByteArrayExtra(BluetoothLeConnectionService.INTENT_DATA);\n\n // Find out the exercise mode (i.e what type of data we are collecting)\n TexTronicsDevice device = mTexTronicsList.get(deviceAddress);\n\n\n //String exerciseMode = null;\n String exerciseMode = null;\n if(device != null)\n //exerciseMode1 = device.getExerciseMode();\n exerciseMode = MainActivity.exercise_mode;\n\n if(exerciseMode != null)\n {\n try\n {\n /** alli edit - how the csv files is logged */\n /* if(exerciseMode.equals(\"Flex + Imu\")){\n device.setThumbFlex((((data[0] & 0x00FF) << 8) | ((data[1] & 0x00FF))));\n device.setIndexFlex((((data[2] & 0x00FF) << 8) | ((data[3] & 0x00FF))));\n device.setAccX(((data[4] & 0x00FF) << 8) | ((data[5] & 0x00FF)));\n device.setAccY(((data[6] & 0x00FF) << 8) | ((data[7] & 0x00FF)));\n device.setAccZ(((data[8] & 0x00FF) << 8) | ((data[9] & 0x00FF)));\n device.setGyrX(((data[10] & 0x00FF) << 8) | ((data[11] & 0x00FF)));\n device.setGyrY(((data[12] & 0x00FF) << 8) | ((data[13] & 0x00FF)));\n device.setGyrZ(((data[14] & 0x00FF) << 8) | ((data[15] & 0x00FF)));\n\n Log.d(\"START_LOG:::--\" ,String.valueOf(DeviceExerciseFragment.START_LOG));\n\n // If in exercise, log this data to CSV file\n if(DeviceExerciseFragment.START_LOG){\n device.logData(mContext);\n } else {\n Log.w(TAG, \"Invalid Data Packet\");\n return;\n }\n }*/\n// else if(exerciseMode.equals(\"Flex Only\")){\n// Log.e(\"MODE:::--\" ,exerciseMode);\n// device.setThumbFlex((((data[1] & 0x00FF) << 8) | ((data[0] & 0x00FF))));\n// device.setIndexFlex((((data[3] & 0x00FF) << 8) | ((data[2] & 0x00FF))));\n// device.setMiddleFlex((((data[5] & 0x00FF) << 8) | ((data[4] & 0x00FF))));\n// device.setRingFlex((((data[7] & 0x00FF) << 8) | ((data[6] & 0x00FF))));\n// device.setPinkyFlex((((data[9] & 0x00FF) << 8) | ((data[8] & 0x00FF))));\n//\n// Log.d(\"START_LOG:::--\" ,String.valueOf(DeviceExerciseFragment.START_LOG));\n//\n// if(DeviceExerciseFragment.START_LOG)\n// device.logData(mContext);\n//\n//\n// // Second Data Set\n// //device.setTimestamp((((data[6] & 0x00FF) << 8) | ((data[7] & 0x00FF))));\n// device.setThumbFlex((((data[11] & 0x00FF) << 8) | ((data[10] & 0x00FF))));\n// device.setIndexFlex((((data[13] & 0x00FF) << 8) | ((data[12] & 0x00FF))));\n// device.setMiddleFlex((((data[15] & 0x00FF) << 8) | ((data[14] & 0x00FF))));\n// device.setRingFlex((((data[17] & 0x00FF) << 8) | ((data[16] & 0x00FF))));\n// device.setPinkyFlex((((data[19] & 0x00FF) << 8) | ((data[18] & 0x00FF))));\n// Log.d(\"START_LOG:::--\" ,String.valueOf(DeviceExerciseFragment.START_LOG));\n//\n// if(DeviceExerciseFragment.START_LOG)\n// device.logData(mContext);\n// }\n// else if(exerciseMode.equals(\"Imu Only\")){\n// Log.e(\"MODE:::--\" ,exerciseMode);\n// device.setAccX(((data[1] & 0x00FF) << 8) | ((data[0] & 0x00FF)));\n// device.setAccY(((data[3] & 0x00FF) << 8) | ((data[2] & 0x00FF)));\n// device.setAccZ(((data[5] & 0x00FF) << 8) | ((data[4] & 0x00FF)));\n// device.setGyrX(((data[7] & 0x00FF) << 8) | ((data[6] & 0x00FF)));\n// device.setGyrY(((data[9] & 0x00FF) << 8) | ((data[8] & 0x00FF)));\n// device.setGyrZ(((data[11] & 0x00FF) << 8) | ((data[10] & 0x00FF)));\n//\n// Log.d(\"START_LOG:::--\" ,String.valueOf(DeviceExerciseFragment.START_LOG));\n//\n// if(DeviceExerciseFragment.START_LOG)\n// device.logData(mContext);\n//\n //}\n\n Log.e(\"MODE\",MainActivity.exercise_mode);\n Log.e(\"MODE:::--\" ,device.getExerciseMode().toString());\n\n switch (exerciseMode)\n {\n case \"Flex + IMU\":\n // Move data processing into Data Model?\n// //if (data[0] == PACKET_ID_1) {\n\n device.setTimestamp(((data[1] & 0x00FF) << 8) | ((data[0] & 0x00FF)));// | ((data[3] & 0x00FF) << 8) | (data[4] & 0x00FF));\n device.setThumbFlex((((data[3] & 0x00FF) << 8) | ((data[2] & 0x00FF))));\n device.setIndexFlex((((data[5] & 0x00FF) << 8) | ((data[4] & 0x00FF))));\n device.setRingFlex((((data[7] & 0x00FF) << 8) | ((data[6] & 0x00FF))));\n device.setAccX((short)(((data[9] & 0x00FF) << 8) | ((data[8] & 0x00FF))));\n device.setAccY((short)(((data[11] & 0x00FF) << 8) | ((data[10] & 0x00FF))));\n device.setAccZ((short)(((data[13] & 0x00FF) << 8) | ((data[12] & 0x00FF))));\n device.setGyrX((short)(((data[15] & 0x00FF) << 8) | ((data[14] & 0x00FF))));\n device.setGyrY((short)(((data[17] & 0x00FF) << 8) | ((data[16] & 0x00FF))));\n device.setGyrZ((short)(((data[19] & 0x00FF) << 8) | ((data[18] & 0x00FF))));\n\n\n\n Log.d(\"START_LOG:::--\" ,String.valueOf(DeviceExerciseFragment.START_LOG));\n\n // If in exercise, log this data to CSV file\n if(DeviceExerciseFragment.START_LOG){\n device.logData(mContext);\n } else {\n Log.w(TAG, \"Invalid Data Packet\");\n return;\n }\n break;\n case \"Flex Only\":\n // First Data Set\n //device.setTimestamp((((data[0] & 0x00FF) << 8) | ((data[1] & 0x00FF))));\n\n device.setThumbFlex((((data[1] & 0x00FF) << 8) | ((data[0] & 0x00FF))));\n device.setIndexFlex((((data[3] & 0x00FF) << 8) | ((data[2] & 0x00FF))));\n device.setMiddleFlex((((data[5] & 0x00FF) << 8) | ((data[4] & 0x00FF))));\n device.setRingFlex((((data[7] & 0x00FF) << 8) | ((data[6] & 0x00FF))));\n device.setPinkyFlex((((data[9] & 0x00FF) << 8) | ((data[8] & 0x00FF))));\n\n Log.d(\"START_LOG:::--\" ,String.valueOf(DeviceExerciseFragment.START_LOG));\n\n if(DeviceExerciseFragment.START_LOG)\n device.logData(mContext);\n\n\n // Second Data Set\n //device.setTimestamp((((data[6] & 0x00FF) << 8) | ((data[7] & 0x00FF))));\n device.setThumbFlex((((data[11] & 0x00FF) << 8) | ((data[10] & 0x00FF))));\n device.setIndexFlex((((data[13] & 0x00FF) << 8) | ((data[12] & 0x00FF))));\n device.setMiddleFlex((((data[15] & 0x00FF) << 8) | ((data[14] & 0x00FF))));\n device.setRingFlex((((data[17] & 0x00FF) << 8) | ((data[16] & 0x00FF))));\n device.setPinkyFlex((((data[19] & 0x00FF) << 8) | ((data[18] & 0x00FF))));\n Log.d(\"START_LOG:::--\" ,String.valueOf(DeviceExerciseFragment.START_LOG));\n\n if(DeviceExerciseFragment.START_LOG)\n device.logData(mContext);\n break;\n // Third Data Set\n //device.setTimestamp((((data[12] & 0x00FF) << 8) | ((data[13] & 0x00FF))));\n //device.setThumbFlex((((data[14] & 0x00FF) << 8) | ((data[15] & 0x00FF))));\n //device.setIndexFlex((((data[16] & 0x00FF) << 8) | ((data[17] & 0x00FF))));\n\n // If in exercise, log data to CSV\n //if(DeviceExerciseFragment.START_LOG)\n // device.logData(mContext);\n\n case \"Imu Only\":\n device.setAccX((short) (((data[1] & 0x00FF) << 8) | ((data[0] & 0x00FF))));\n device.setAccY(( short)(((data[3] & 0x00FF) << 8) | ((data[2] & 0x00FF))));\n device.setAccZ((short)(((data[5] & 0x00FF) << 8) | ((data[4] & 0x00FF))));\n device.setGyrX(( short)(((data[7] & 0x00FF) << 8) | ((data[6] & 0x00FF))));\n device.setGyrY(( short)(((data[9] & 0x00FF) << 8) | ((data[8] & 0x00FF))));\n device.setGyrZ(( short)(((data[11] & 0x00FF) << 8) | ((data[10] & 0x00FF))));\n\n Log.d(\"START_LOG:::--\" ,String.valueOf(DeviceExerciseFragment.START_LOG));\n\n if(DeviceExerciseFragment.START_LOG)\n device.logData(mContext);\n break;\n }\n } catch (IllegalDeviceType | IOException e) {\n Log.e(TAG, e.toString());\n // TODO Handle Error Event\n return;\n }\n }\n }\n break;\n case BluetoothLeConnectionService.GATT_CHARACTERISTIC_READ:\n break;\n case BluetoothLeConnectionService.GATT_DESCRIPTOR_WRITE:\n break;\n case BluetoothLeConnectionService.GATT_NOTIFICATION_TOGGLED:\n break;\n case BluetoothLeConnectionService.GATT_DEVICE_INFO_READ:\n break;\n }\n }", "@Override\n public void onConnectionSuspended(int i) {\n //Log.d(TAG, \"Connection suspended\");\n }", "@Override\n public void onConnectionAttemptSucceeded(@NonNull BluetoothDevice device,\n @NonNull Connection connection) {\n final NoopConnectionHandler noopHandler = new NoopConnectionHandler();\n final ConnectionClient connectionClient = ConnectionClients.wrap(connection, 256,\n noopHandler);\n connectionClient.startReading();\n }", "@Override\n public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {\n\n if (newState == BluetoothProfile.STATE_CONNECTED) {\n mConnectionState = STATE_CONNECTED;\n\n if (mBleListener != null) {\n mBleListener.onConnected();\n }\n\n // Attempts to discover services after successful connection.\n gatt.discoverServices();\n\n } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {\n mConnectionState = STATE_DISCONNECTED;\n\n if (mBleListener != null) {\n mBleListener.onDisconnected();\n }\n } else if (newState == BluetoothProfile.STATE_CONNECTING) {\n mConnectionState = STATE_CONNECTING;\n\n if (mBleListener != null) {\n mBleListener.onConnecting();\n }\n }\n }", "public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {\n devicesDiscovered.addElement(btDevice);\n }", "private void makeBackgroundConnection() {\n connectionPending = true;\n try {\n Thread connectThread = new Thread(this);\n connectThread.start();\n } catch (OutOfMemoryError oome) {\n // Give up on new connection\n }\n }", "private void makeBackgroundConnection() {\n connectionPending = true;\n try {\n Thread connectThread = new Thread(this);\n connectThread.start();\n } catch (OutOfMemoryError oome) {\n // Give up on new connection\n }\n }", "public void initBT() {\n\n\t\tStatusBox.setText(\"Connecting...\");\n\t\tLog.e(TAG, \"Connecting...\");\n\t\t\n\t\tif (D) {\n\t\t\tLog.e(TAG, \"+ ON RESUME +\");\n\t\t\tLog.e(TAG, \"+ ABOUT TO ATTEMPT CLIENT CONNECT +\");\n\t\t}\n\t\t\n\t\t//If Mac Address is null then stop this process and display message\n\t\tif(MAC_ADDRESS == \"\"){\n\t\t\tLog.e(TAG,\"No MAC Address Found...\");\n\t\t\tToast.makeText(getApplicationContext(), \"No Mac Address found. Please Enter using button.\",Toast.LENGTH_SHORT );\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t// When this returns, it will 'know' about the server,\n\t\t// via it's MAC address.\n\t\tBluetoothDevice device = null;\n\t\ttry {\n\t\t\tdevice = mBluetoothAdapter.getRemoteDevice(MAC_ADDRESS);\n\t\t} catch (Exception e1) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\tToast.makeText(getApplicationContext(), \"NOT Valid BT MAC Address\", Toast.LENGTH_SHORT);\n\t\t\te1.printStackTrace();\n\t\t}\n\n\t\t// returns firefly e350\n\t\tLog.e(TAG, \"device name: \" + device.getName());\n\n\t\t// We need two things before we can successfully connect\n\t\t// (authentication issues aside): a MAC address, which we\n\t\t// already have, and an RFCOMM channel.\n\t\t// Because RFCOMM channels (aka ports) are limited in\n\t\t// number, Android doesn't allow you to use them directly;\n\t\t// instead you request a RFCOMM mapping based on a service\n\t\t// ID. In our case, we will use the well-known SPP Service\n\t\t// ID. This ID is in UUID (GUID to you Microsofties)\n\t\t// format. Given the UUID, Android will handle the\n\t\t// mapping for you. Generally, this will return RFCOMM 1,\n\t\t// but not always; it depends what other BlueTooth services\n\t\t// are in use on your Android device.\n\t\ttry {\n\t\t\t\n\t\t\tint currentapiVersion = android.os.Build.VERSION.SDK_INT;\n\t\t\t\n\t\t\t//RFCOMM connection varies depending on android version. Fixes bug in Gingerbread and newer where always asks for BT Pairing code.\n\t\t\tif (currentapiVersion >= android.os.Build.VERSION_CODES.GINGERBREAD_MR1){\n\t\t\t\t//used in android >= 2.3.3\n\t\t\t\tbtSocket = device.createInsecureRfcommSocketToServiceRecord(MY_UUID);\n\t\t\t} else if (currentapiVersion < android.os.Build.VERSION_CODES.GINGERBREAD_MR1){\n\t\t\t\t//used in android < 2.3.3\n\t\t\t\tbtSocket = device.createRfcommSocketToServiceRecord(MY_UUID);\n\t\t\t}\n\t\t\t\n\t\t\tLog.e(TAG, \"ON RESUME: Socket created!\");\n\t\t\n\t\t\n\t\t\t// Discovery may be going on, e.g., if you're running a\n\t\t\t// 'scan for devices' search from your handset's Bluetooth\n\t\t\t// settings, so we call cancelDiscovery(). It doesn't hurt\n\t\t\t// to call it, but it might hurt not to... discovery is a\n\t\t\t// heavyweight process; you don't want it in progress when\n\t\t\t// a connection attempt is made.\n\t\t\tmBluetoothAdapter.cancelDiscovery();\n\n\t\t\tmyBT = new ConnectedThread(btSocket);\n\t\t\t\n\t\t\t\n\t\t\t// don't write to the streams unless they are created\n\t\t\tif (myBT.BTconnStatus) {\n\t\t\t\t\n\t\t\t\tStatusBox.setText(\"CONNECTED\");\n\t\t\t\tLog.e(TAG, \"CONNECTED\");\n\t\t\t\t\n\t\t\t\t// ST,255 enables remote configuration forever...need this if\n\t\t\t\t// resetting\n\t\t\t\t// PIO4 is held high on powerup then toggled 3 times to reset\n\n\t\t\t\t// GPIO Commands to BT device page 15 of commands datasheet\n\t\t\t\tbyte[] cmdMode = { '$', '$', '$' };\n\t\t\t\tmyBT.write(cmdMode);\n\t\t\t\tmyBT.run();\n\n\t\t\t\t// S@,8080 temp sets GPIO-7 to an output\n\t\t\t\tbyte[] cmd1 = { 'S', '@', ',', '8', '0', '8', '0', 13 };\n\n\t\t\t\t// S%,8080 perm sets GPIO-7 to an output on powerup. only done once\n\t\t\t\t// byte [] cmd1 = {'S','%',',','8','0','8','0',13};\n\n\t\t\t\tmyBT.write(cmd1);\n\t\t\t\tmyBT.run();\n\n\t\t\t\t// S&,8000 drives GPIO-7 low\n\t\t\t\t// byte [] cmd2 = {'S','^',',','8','0','0','0',13};\n\n\t\t\t\t// make it so cmd mode won't timeout even after factory reset\n\t\t\t\tbyte[] cmd3 = { 'S', 'T', ',', '2', '5', '5', 13 };\n\t\t\t\tmyBT.write(cmd3);\n\t\t\t\tmyBT.run();\n\n\t\t\t} else {\n\t\t\t\t//StatusBox.setText(\"NOT Connected\");\t\n\t\t\t\tLog.e(TAG, \"NOT Connected\");\n\t\t\t}\n\t\t\n\t\t} catch (IOException e) {\n\t\t\t\n\t\t\tif (D)\n\t\t\t\tLog.e(TAG, \"ON RESUME: Socket creation failed.\", e);\n\t\t}\n\n\t\t\n\t\t\n\t}", "@Override\n\t\t\t\t\tpublic void onNotifyWifiConnected()\n\t\t\t\t\t{\n\t\t\t\t\t\tLog.v(TAG, \"have connected success!\");\n\t\t\t\t\t\tLog.v(TAG, \"###############################\");\n\t\t\t\t\t}", "@Override\n public void onBeaconServiceConnect() {\n beaconManager.setRangeNotifier(new RangeNotifier() {\n @Override\n public void didRangeBeaconsInRegion(final Collection<Beacon> beacons, Region region) {\n runOnUiThread(new Runnable() {\n @Override\n public void run() {\n if (beacons.size() > 0) {\n for (Beacon beacon : beacons) mBeaconList.addBeacon(beacon);\n mBeaconList.notifyDataSetChanged();\n }\n }\n });\n }\n });\n\n try {\n beaconManager.startRangingBeaconsInRegion(new Region(\"myRangingUniqueId\", null, null, null));\n } catch (RemoteException e) {\n Log.d(TAG, \"Exception caught in ServiceConnect\");\n }\n }", "private void setupBluetooth() throws NullPointerException{\n if( Utils.isOS( Utils.OS.ANDROID ) ){\n \t\n // Gets bluetooth hardware from phone and makes sure that it is\n // non-null;\n BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();\n \n // If bluetooth hardware does not exist...\n if (adapter == null) {\n Log.d(TAG, \"BluetoothAdapter is is null\");\n throw new NullPointerException(\"BluetoothAdapter is null\");\n } else {\n Log.d(TAG, \"BluetoothAdapter is is non-null\");\n }\n \n bluetoothName = adapter.getName();\n \n //TODO: restart bluetooth?\n \t\n try {\n bluetoothConnectionThreads.add( new ServerThread(adapter, router, uuid) );\n } catch (NullPointerException e) {\n throw e;\n }\n if (Constants.DEBUG)\n Log.d(TAG, \"Sever Thread Created\");\n // Create a new clientThread\n bluetoothConnectionThreads.add( new ClientThread(adapter, router, uuid) );\n if (Constants.DEBUG)\n Log.d(TAG, \"Client Thread Created\");\n }\n else if( Utils.isOS( Utils.OS.WINDOWS ) ){\n //TODO: implement this\n }\n else if( Utils.isOS( Utils.OS.LINUX ) ){\n //TODO: implement this\n }\n else if( Utils.isOS( Utils.OS.OSX ) ){\n //TODO: implement this\n }\n else{\n //TODO: throw exception?\n }\n \n }", "private void connectToAdapter() {\n if (chosen) {\n BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();\n BluetoothDevice device = btAdapter.getRemoteDevice(deviceAddress);\n UUID uuid = UUID.fromString(\"00001101-0000-1000-8000-00805F9B34FB\");\n // creation and connection of a bluetooth socket\n try {\n BluetoothSocket socket = device.createInsecureRfcommSocketToServiceRecord(uuid);\n socket.connect();\n setBluetoothSocket(socket);\n connected = true;\n runOnUiThread(new Runnable() {\n @Override\n public void run() {\n connect.setText(\"Disconnect\");\n connect.setTextColor(Color.RED);\n }\n });\n } catch (IOException e) {\n Log.d(\"Exception\", \"Bluetooth IO Exception c\");\n connected = false;\n runOnUiThread(new Runnable() {\n @Override\n public void run() {\n Toast.makeText(currContext, R.string.cannotConnect, Toast.LENGTH_SHORT).show();\n connect.setText(\"Connect\");\n connect.setTextColor(Color.BLACK);\n mode.setEnabled(true);\n }\n });\n }\n }\n if (bluetoothSocket.getRemoteDevice().getAddress() != null)\n Log.d(TAG, \"Bluetooth connected\");\n Log.d(TAG, \"Device address: \" + bluetoothSocket.getRemoteDevice().getAddress());\n initializeCom();\n }", "@Override\n public void onConnectionSuspended(int cause) {\n }", "@Override\n public void onConnectionSuspended(int cause) {\n }", "public interface BLEOADCallback {\n void onProgress(BluetoothDevice bluetoothDevice, int progress);\n void onCancel(BluetoothDevice bluetoothDevice);\n void onSuccess(BluetoothDevice bluetoothDevice);\n}", "public abstract void onConnect();", "@Override\n public void gattConnected() {\n mConnected = true;\n updateConnectionState(R.string.connected);\n getActivity().invalidateOptionsMenu();\n }", "@SuppressWarnings(value = {\"deprecation\"})\n @Override\n public void onStartBleScan(long timeoutMillis) {\n if (mBluetooth != null) {\n isScanning = mBluetooth.startLeScan(leScanCallback);\n //timeoutHandler.postDelayed(timeoutRunnable, delay);\n Log.d(TAG, \"mBluetooth.startLeScan() \" + isScanning);\n } else {\n mScanCallback.onBleScanFailed(BleScanState.BLUETOOTH_OFF);//bluetooth is off\n }\n }", "public void registerCallback() {\n if (mLocalManager == null) {\n Log.e(TAG, \"registerCallback() Bluetooth is not supported on this device\");\n return;\n }\n mLocalManager.setForegroundActivity(mFragment.getContext());\n mLocalManager.getEventManager().registerCallback(this);\n mLocalManager.getProfileManager().addServiceListener(this);\n forceUpdate();\n }", "@Override\n public void onConnected(BluetoothLeUart uart) {\n // Called when UART device is connected and ready to send/receive data.\n writeLine(\"Connected!\");\n }", "void prepareBroadcastDataNotify(\n BluetoothGattCharacteristic gattCharacteristic) {\n if ((gattCharacteristic.getProperties() | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {\n BluetoothLeService.setCharacteristicNotification(gattCharacteristic,true);\n }\n }", "@Override\n public void onConnectionFailed(Die die, Exception e) {\n Log.d(TAG, \"Connection failed\", e);\n dicePlus = null;\n BluetoothManipulator.startScan();\n }", "public void onConnection();", "private void connectBluetooth() {\n try {\n if (blueTooth == null && macSet) {\n Log.d(\"lol\", \"macSet connect bluetooootooththoth\");\n blueTooth = new BluetoothConnection(macAddress, this, listener);\n blueTooth.connect();\n }\n } catch (Exception e) {\n Log.d(\"lol\", \"Failed connection: \" + e.getMessage() + \" \" + e.getClass());\n }\n }", "@Override\n protected Void doInBackground(Void... devices){\n try {\n if (btSocket == null || !isBtConnected) {\n //get the mobile bluetooth device\n m_Bluetooth = BluetoothAdapter.getDefaultAdapter();\n //connects to the device's address and checks if it's available\n BluetoothDevice bluetoothDevice = m_Bluetooth.getRemoteDevice(address);\n //create a RFCOMM (SPP) connection\n btSocket = bluetoothDevice.createInsecureRfcommSocketToServiceRecord(myUUID);\n BluetoothAdapter.getDefaultAdapter().cancelDiscovery();\n btSocket.connect();//start connection\n }\n }\n catch (IOException e) {\n ConnectSuccess = false;//if the try failed, you can check the exception here\n }\n return null;\n }", "@Override\n\tpublic void onConnectionSuspended(int arg0) {\n\n\t}", "@Override\n\tpublic void onConnectionSuspended(int arg0) {\n\n\t}", "@Override\n public void onScannedBleDeviceAdded(BluetoothDevice device) {\n Log.d(TAG, \"onScannedBleDeviceAdded enter\");\n// Message msg = mHandler.obtainMessage();\n// msg.what = SCAN_DEVICE_ADD_FLAG;\n// msg.obj = device;\n// mHandler.sendMessage(msg);\n updateScanDialog(SCAN_DEVICE_ADD_FLAG, device);\n }", "private void onConnected() {\n \tmMeshHandler.removeCallbacks(connectTimeout);\n hideProgress();\n\n mConnectTime = SystemClock.elapsedRealtime();\n mConnected = true;\n\n mNavListener = new SimpleNavigationListener(stActivity.getFragmentManager(), stActivity);\n if (mDeviceStore.getSetting() == null || mDeviceStore.getSetting().getNetworkKey() == null) {\n Log.d(\"TEST\", \"TEST\");\n }\n startPeriodicColorTransmit();\n }", "@Override\n\t\t\t\t\tpublic void onNotifyWifiConnectFailed()\n\t\t\t\t\t{\n\t\t\t\t\t\tLog.v(TAG, \"have connected failed!\");\n\t\t\t\t\t\tLog.v(TAG, \"###############################\");\n\t\t\t\t\t}", "@Override\n public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {\n advance();\n enableNextSensor(gatt);\n }" ]
[ "0.6667121", "0.64432114", "0.63322103", "0.6292488", "0.6169131", "0.596611", "0.5887966", "0.58657306", "0.5848769", "0.5780991", "0.5732079", "0.5718314", "0.57086396", "0.5676938", "0.56668687", "0.5665828", "0.5639462", "0.5621989", "0.56029844", "0.5570683", "0.55526143", "0.5517064", "0.5509371", "0.54979825", "0.54890525", "0.54879385", "0.547481", "0.5465313", "0.54633486", "0.5456473", "0.5449333", "0.5448085", "0.5439012", "0.54325545", "0.5417572", "0.5404924", "0.5404278", "0.5397223", "0.5392041", "0.539158", "0.53836954", "0.53713036", "0.53702515", "0.5367011", "0.5367011", "0.5347212", "0.53414303", "0.53373754", "0.53357303", "0.533567", "0.533381", "0.53125924", "0.53067046", "0.5294796", "0.5276706", "0.5271261", "0.5271041", "0.52623", "0.5260337", "0.52601194", "0.5259121", "0.5258337", "0.52558386", "0.5239758", "0.5239243", "0.5234758", "0.52201045", "0.521573", "0.5213427", "0.5212409", "0.52014", "0.5182768", "0.5177347", "0.51748866", "0.51745766", "0.51745766", "0.5169205", "0.5166599", "0.51629335", "0.51606023", "0.5156908", "0.515112", "0.515112", "0.5142589", "0.5129889", "0.5118055", "0.5117547", "0.51166695", "0.5116451", "0.51077896", "0.5096373", "0.509545", "0.50925815", "0.5090454", "0.50892276", "0.50892276", "0.50887066", "0.50867975", "0.50854826", "0.5085011" ]
0.64382386
2
Public access by BleDriver.SendToPeer()
public BluetoothGattCharacteristic getWriterCharacteristic() { return mWriterCharacteristic; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "void send();", "public void send() {\n\t}", "public void sendMsg(){\r\n\t\tsuper.getPPMsg(send);\r\n\t}", "@DSComment(\"Private Method\")\n @DSBan(DSCat.PRIVATE_METHOD)\n @DSGenerator(tool_name = \"Doppelganger\", tool_version = \"2.0\", generated_on = \"2013-12-30 12:59:45.591 -0500\", hash_original_method = \"73417FF22870072B41D9E8892C6ACEAF\", hash_generated_method = \"98D30C9AEE1B66AD2FCFA7D7A2E2B430\")\n \nprivate static Message sendMessageSynchronously(Messenger dstMessenger, Message msg) {\n SyncMessenger sm = SyncMessenger.obtain();\n try {\n if (dstMessenger != null && msg != null) {\n msg.replyTo = sm.mMessenger;\n synchronized (sm.mHandler.mLockObject) {\n dstMessenger.send(msg);\n sm.mHandler.mLockObject.wait();\n }\n } else {\n sm.mHandler.mResultMsg = null;\n }\n } catch (InterruptedException e) {\n sm.mHandler.mResultMsg = null;\n } catch (RemoteException e) {\n sm.mHandler.mResultMsg = null;\n }\n Message resultMsg = sm.mHandler.mResultMsg;\n sm.recycle();\n return resultMsg;\n }", "@Override\n\tpublic void sendMessage() {\n\t\t\n\t}", "public abstract void sendToChain(String mesg);", "@Ignore\n @Test\n public void startSender() throws IOException, InterruptedException {\n\n final int maxPeers = 10;\n PeerDHT[] peers = createPeers(PORT, maxPeers, \"sender\");\n for (PeerDHT peer : peers) {\n peer.peer().bootstrap().inetAddress(InetAddress.getByName(ADDR)).ports(PORT).start().awaitUninterruptibly();\n peer.peer().objectDataReply(new ObjectDataReply() {\n @Override\n public Object reply(final PeerAddress sender, final Object request) throws Exception {\n System.out.println(\"wrong!!!!\");\n return \"wrong!!!!\";\n }\n });\n }\n Number160 keyForID = Number160.createHash(\"key\");\n Msg message = new Msg();\n\n System.out.println(String.format(\"Sending message '%s' to key '%s' converted to '%s'\", message.getType(),\n \"key\", keyForID.toString()));\n FutureSend futureDHT = peers[0].send(keyForID).object(message).requestP2PConfiguration(REQ).start();\n futureDHT.awaitUninterruptibly();\n System.out.println(\"got: \" + futureDHT.object());\n Thread.sleep(Long.MAX_VALUE);\n }", "void sendMessage() {\n\n\t}", "public void sendToWard(){\r\n\t\t//here is some code that we do not have access to\r\n\t}", "public Peer getPeer();", "com.polytech.spik.protocol.SpikMessages.SendMessage getSendMessage();", "private static void SendToAuctioneer(BigInteger msg) {\r\n\t\tmsg=auctioneer_pk.encrypt(msg)[0];\r\n\t\tsendToClient(auctioneer,msg);\r\n\t}", "@Override\r\n\tpublic void send(JT808ProtocalPack message) throws Exception {\n\r\n\t}", "public void sendTurno() throws RemoteException, InterruptedException, IOException ;", "public void setPeer(Peer peer);", "private boolean sendMessage(Message m){\r\n\t\tAllocation alloc = client.getAllocation();\r\n\t\tEndPoint main = getBattlefieldFor(alloc.getMain());\r\n\t\ttry {\r\n\t\t\tIMessageReceivedHandler remoteReceiver = (IMessageReceivedHandler) main.connect();\r\n\t\t\tremoteReceiver.onMessageReceived(m);\r\n\t\t} catch (MalformedURLException | RemoteException | NotBoundException e) {\r\n\t\t\tEndPoint backup = getBattlefieldFor(alloc.getBackup());\r\n\t\t\tIMessageReceivedHandler remoteReceiver;\r\n\t\t\ttry {\r\n\t\t\t\tremoteReceiver = (IMessageReceivedHandler) backup.connect();\r\n\t\t\t\tremoteReceiver.onMessageReceived(m);\r\n\t\t\t} catch (MalformedURLException | RemoteException\r\n\t\t\t\t\t| NotBoundException e1) {\r\n\t\t\t\treturn false;\r\n\t\t\t}\t\r\n\t\t}\r\n\t\treturn true;\r\n\t}", "public abstract void send(String data, String toAddress);", "@Override\n\tpublic void sendPacket(JBPacket packet) {\n\t\t\n\t}", "public void sendPeerListToAll() {\r\n\t\tPacket packet = new Packet();\r\n\t\tpacket.eventCode = 1;\r\n\t\tfor(int i = 0; i < peerClientNodeConnectionList.size(); i++) {\r\n\t\t\tPeer peer = new Peer();\r\n\t\t\tpeer.peerID = peerClientNodeConnectionList.get(i).peerClientID;\r\n\t\t\tpeer.peerIP = peerClientNodeConnectionList.get(i).peerClientIP;\r\n\t\t\tpeer.peerPort = peerClientNodeConnectionList.get(i).peerClientListeningPort;\r\n\t\t\tpacket.peerList.add(peer);\r\n\t\t}\r\n\t\t\r\n\t\tfor(int i = 0; i < peerClientNodeConnectionList.size(); i++) {\r\n\t\t\ttry {\r\n\t\t\t\tpeerClientNodeConnectionList.get(i).outStream.writeObject(packet);\r\n\t\t\t} catch (IOException e) {\r\n\t\t\t\t// TODO Auto-generated catch block\r\n\t\t\t\te.printStackTrace();\r\n\t\t\t}\t\t\t\r\n\t\t}\r\n\t}", "@Override\r\n\tpublic void send() throws Exception {\n\t\t\r\n\t}", "public abstract P getAsPeer() throws DataException;", "public void sendTo(P2PUser dest, Object msg) throws IOException;", "void send() throws ImsException;", "public interface PeerInfoService extends PeerInfoCallback {\r\n}", "protected byte[] sendToBrickPi(byte[] toSend) {\n \t\n \tbyte resultBytes[] = new byte[] {};\n \t \t\n \tif (DEBUG_LEVEL > 0) {\n StringBuffer output = new StringBuffer();\n output.append(\"Sending\");\n for (byte toAdd : toSend) {\n output.append(\" \");\n output.append(Integer.toHexString(toAdd & 0xFF));\n }\n System.out.println(output.toString());\n }\n \t\n \ttry {\n \tresultBytes = spi.write(toSend);\n \t\n \tif (DEBUG_LEVEL > 0) {\n StringBuffer input = new StringBuffer();\n input.append(\"Received \");\n\n for (byte received : resultBytes) {\n input.append(\" \");\n input.append(Integer.toHexString(received & 0xFF));\n }\n System.out.println(input.toString());\n }\n \t\n }\n catch(IOException ex) {\n \t\tLOGGER.error(ex.getMessage(), ex); \t\n }\n \t\n \treturn resultBytes;\n }", "public void send(final ControlMessage.ClientToDriverMessage message) {\n // This needs active 'link' between the driver and client.\n // For the link to be alive, the driver should connect to DriverRPCServer.\n // Thus, the server must be running to send a message to the driver.\n ensureServerState(true);\n if (link == null) {\n throw new RuntimeException(\"The RPC server has not discovered NemoDriver yet\");\n }\n link.write(message.toByteArray());\n }", "void sendTo(String from, String to, String m_id);", "public abstract P getPeer() throws DataException;", "AddFriend.BToServer getAddFriendBToServer();", "public void send(Message msg);", "@Override\n\tpublic void send(String msg) {\n\t\t\n\t\t\n\t\n\t}", "private void sendReceiveRes(){\n\t}", "boolean send(int pid, Object M) {\n synchronized (tcp_lock) {\n try {\n //look up the index for peer whose id = peer_id.\n int[] sortedCopy = peer_id.clone();\n Arrays.sort(sortedCopy);\n int index = Arrays.binarySearch(sortedCopy, pid);\n if(index<0){\n print(\"*Error: peer \"+pid+\" not found.\");\n }\n if(sockets[index]==null){\n print(\"sockets[index]=null\");\n System.exit(-1);\n }\n tcp_out_stream[index].writeObject(M);\n } catch (IOException e) {\n e.printStackTrace();\n System.exit(-1);\n }\n return true;\n }\n }", "@Override\n\tpublic void send() {\n\t\tSystem.out.println(\"this is send\");\n\t}", "private void sendUpdateConnectionInfo() {\n\n }", "public GetFreeMessage send()\n throws Exception\n {\n return (GetFreeMessage)super.send();\n }", "Message sendAndWait();", "Object sendRpcRequest(RpcRequest rpcRequest);", "public interface Sendable {\n\n}", "@Override\npublic int sendToAddress(InetSocketAddress isa, byte[] msg) throws IOException {\n\treturn 0;\n}", "public interface PeerRMI extends Remote {\n\n\t/**\n\t * Allows the backup of a document amongst the peers of the network\n\t * @param request\n\t * \t\t\t\tString containing the details about the request\n\t * @return\n\t * \t\t\t\tString containing the status of the execution\n\t * @throws RemoteException\n\t */\n\tString backup(String request) throws RemoteException;\n\n\t/**\n\t * Allows the enhanced backup of a document amongst the peers of the network\n\t * @param request\n\t * \t\t\t\tString containing the details about the request\n\t * @return\n\t * \t\t\t\tString containing the status of the execution\n\t * @throws RemoteException\n\t */\n\tString backupENH(String request) throws RemoteException;\n\t\n\t/**\n\t * Allows the deletion of a document saved in the peers of the network\n\t * @param request\n\t * \t\t\t\tString containing the details about the request\n\t * @return\n\t * \t\t\t\tString containing the status of the execution\n\t * @throws RemoteException\n\t */\n\tString delete(String request) throws RemoteException;\n\n\t/**\n\t * Allows the enhanced deletion of a document saved in the peers of the network\n\t * @param request\n\t * \t\t\t\tString containing the details about the request\n\t * @return\n\t * \t\t\t\tString containing the status of the execution\n\t * @throws RemoteException\n\t */\n\tString deleteENH(String request) throws RemoteException;\n\n\t/**\n\t * Allows the restoration of a document saved in the other peers of the network, the restored file will be saved in the peer-iniatior\n\t * @param request\n\t * \t\t\t\tString containing the details about the request\n\t * @return\n\t * \t\t\t\tString containing the status of the execution\n\t * @throws RemoteException\n\t */\n\tString restore(String request) throws RemoteException;\n\n\t/**\n\t * Allows the restoration of a document saved in the other peers of the network, the restored file will be saved in the peer-iniatior\n\t * @param request\n\t * \t\t\t\tString containing the details about the request\n\t * @return\n\t * \t\t\t\tString containing the status of the execution\n\t * @throws RemoteException\n\t */\n\tString restoreENH(String request) throws RemoteException;\n\n\t/**\n\t * Allows the enhanced reclaim of space of the initiator-peer\n\t * @param request\n\t * \t\t\t\tString containing the details about the request\n\t * @return\n\t * \t\t\t\tString containing the status of the execution\n\t * @throws RemoteException\n\t */\n\tString reclaim(String request) throws RemoteException;\n\n\t/**\n\t * Allows the user to get the state of the initiator-peer\n\t * @param request\n\t * \t\t\t\tString containing the details about the request\n\t * @return\n\t * \t\t\t\tString containing the status of the execution\n\t * @throws RemoteException\n\t */\n\tString state() throws RemoteException;\n}", "private void sendToClient(String string) {\n\t\r\n}", "void firePeerConnected(ConnectionKey connectionKey);", "public void sendPartita(Partita partita) throws InterruptedException, RemoteException, IOException;", "void transmit(String protocol, String message);", "@Override\npublic int sendToID(NodeIDType id, byte[] msg) throws IOException {\n\treturn 0;\n}", "@Override\n\tpublic void send(String msg) {\n\t}", "private void connectingPeer() {\n for (int index = 0; index < this.peers.size(); index++) {\n String peerUrl = urlAdderP2PNodeName((String) this.peers.get(index));\n try {\n Node distNode = NodeFactory.getNode(peerUrl);\n P2PService peer = (P2PService) distNode.getActiveObjects(P2PService.class.getName())[0];\n \n if (!peer.equals(this.localP2pService)) {\n // Send a message to the remote peer to record me\n peer.register(this.localP2pService);\n // Add the peer in my group of acquaintances\n this.acqGroup.add(peer);\n }\n } catch (Exception e) {\n logger.debug(\"The peer at \" + peerUrl +\n \" couldn't be contacted\", e);\n }\n }\n }", "protected abstract void sendInternal(ByteBuffer outputBuffer) throws IOException;", "void sendMessage(String msg) throws RpcException, StateMachineNotExpectedEventException;", "void sendMessage(String msg) throws RpcException, StateMachineNotExpectedEventException;", "void sendMessage(String msg) throws RpcException, StateMachineNotExpectedEventException;", "@Override\n\tpublic void send(IMessage sending) throws RPCException {\n\t\t\n\t}", "public interface SendMessage {\n\n void sendMsg(byte[] msg);\n}", "public FutureResult sendToServer(String onTheWireFormat) throws IOException;", "private byte[] sendServer(byte[] message, boolean partTwo) { \n\t\tComMethods.report(accountName+\" sending message to SecretServer now...\", simMode);\n\t\tbyte[] response = server.getMessage(message, partTwo);\n\t\tComMethods.report(accountName+\" has received SecretServer's response.\", simMode);\n\t\treturn response; \n\t}", "public interface CallPeerSecurityListener extends EventListener\n{\n\t/**\n\t * The handler for the security event received. The security event represents an indication of\n\t * change in the security status.\n\t *\n\t * @param securityEvent\n\t * the security event received\n\t */\n\tpublic void securityOn(CallPeerSecurityOnEvent securityEvent);\n\n\t/**\n\t * The handler for the security event received. The security event represents an indication of\n\t * change in the security status.\n\t *\n\t * @param securityEvent\n\t * the security event received\n\t */\n\tpublic void securityOff(CallPeerSecurityOffEvent securityEvent);\n\n\t/**\n\t * The handler for the security event received. The security event represents a timeout trying\n\t * to establish a secure connection. Most probably the other peer doesn't support it.\n\t *\n\t * @param securityTimeoutEvent\n\t * the security timeout event received\n\t */\n\tpublic void securityTimeout(CallPeerSecurityTimeoutEvent securityTimeoutEvent);\n\n\t/**\n\t * The handler of the security message event.\n\t *\n\t * @param event\n\t * the security message event.\n\t */\n\tpublic void securityMessageReceived(CallPeerSecurityMessageEvent event);\n\n\t/**\n\t * The handler for the security event received. The security event for starting establish a\n\t * secure connection.\n\t *\n\t * @param securityStartedEvent\n\t * the security started event received\n\t */\n\tpublic void securityNegotiationStarted(\n\t\tCallPeerSecurityNegotiationStartedEvent securityStartedEvent);\n}", "public void blockingReceiveSenderSide() throws OOBException {\n \t}", "void Send (int boardID, short addr, ByteBuffer databuf, long datacnt, int eotMode);", "public void sendBytes(byte[] msg);", "void sendMessage(ZMQ.Socket socket);", "@Test\n public void testSend() throws Exception {\n//TODO: Test goes here...\n message.send(\"hello\", \"Bob\");\n }", "void send(Pack pack) { testing_pack = pack; }", "public abstract boolean send(byte[] data);", "@Override\n public PacketDatagram EndPointSend(SendMSG sendmsg) {\n sendmsg.setFinalDestination(getFinalDestination(sendmsg.getDestination()));\n sendmsg.setNextNode(getNextNode(sendmsg.getDestination()));\n PacketDatagram npacket = null;\n \n //Process for each Application Protocol\n sendmsg.getApplicationProtocol().getMessageManager().send(sendmsg);\n \n npacket = serialization.EndPointSend(sendmsg);\n \n if (npacket != null) {\n //send packet\n Send(npacket);\n } else\n System.out.println(\"TRANSPOTATION.JAVA: Send error, npacket is null\");\n\n return npacket;\n }", "private void sendUpdates() {\n\n List<PeerUpdateMessage.Part> parts = new ArrayList<PeerUpdateMessage.Part>();\n for (ActivePlayer peer : player.getSavedNeighbors()) {\n PeerUpdateMessage.Part part = new PeerUpdateMessage.Part(\n peer.character.id, peer.character.getExtrapolatedMotionState());\n parts.add(part);\n }\n\n if (!parts.isEmpty()) {\n PeerUpdateMessage msg = new PeerUpdateMessage(parts);\n new ToClientMessageSink(player.session).sendWithoutConfirmation(msg);\n }\n }", "public void fromMicroServer() throws Exception {\n \tbyte[] buf = new byte[1024];\n\t\tDatagramPacket dp = new DatagramPacket(buf, 1024);\n\t\ttry{\n\t\t\ttoMicroServer.receive(dp);\n\t\t\trecieve = true;\n\t\t}\n\t\tcatch (IOException e){\n\t\t\tSystem.out.println(\"Connection timed out, retrying...\");\n\t\t\trecieve = false;\n\t\t\treturn;\n\t\t}\n str = new String(dp.getData(), 0, dp.getLength());\n\t\tSystem.out.printf(\"Child about to send message: %s \\n\", str);\n\n }", "static public void startSending(String add,int port,byte[] data,int mode){\n }", "public interface P2P {\n\n\t/**\n\t * Start the P2P system with given servent and router system\n\t * \n\t * @param servent\n\t * @param router\n\t */\n\tpublic void start(NServent servent, Router router);\n\n\t/**\n\t * disconnect from the p2p network\n\t */\n\tpublic void stop();\n\n\t/**\n\t * connect to a p2p network\n\t */\n\tpublic void connectTo(NAddress address) throws IOException;\n\n\t/**\n\t * send msg to all users\n\t * \n\t * @param msg\n\t */\n\tpublic void broadcast(Object msg);\n\n\t/**\n\t * send msg to some users contained in dests set\n\t * \n\t * @param msg\n\t */\n\tpublic void anycast(Set<P2PUser> dests, Object msg);\n\n\t/**\n\t * send the message msg to user dest, the routing system will be used\n\t * \n\t * @param dest\n\t * @param msg\n\t * @throws IOException\n\t */\n\tpublic void sendTo(P2PUser dest, Object msg) throws IOException;\n\n\t/**\n\t * get the p2p network user set\n\t * \n\t * @return\n\t */\n\tpublic Set<P2PUser> getUsers();\n\n\t/**\n\t * Find the user with the address given, return null if not present\n\t * \n\t * @param address\n\t * @return user with address given\n\t */\n\tpublic P2PUser getUser(NAddress address);\n\n\t/**\n\t * Find the user binded with the pair given, return null if not present\n\t * \n\t * @param address\n\t * @return user with address given\n\t */\n\tpublic P2PUser getUser(NPair pair);\n\n\t/**\n\t * Set the handler, its functions will be called when a corresponding event\n\t * will occur\n\t * \n\t * @param handler\n\t */\n\tpublic void setP2PHandler(P2PHandler handler);\n\n\t/**\n\t * Return the Router currently used by the P2P system\n\t * \n\t * @return\n\t */\n\tpublic Router getRouter();\n\n\t/**\n\t * Return the NServent currently used by P2P the system\n\t * \n\t * @return\n\t */\n\tpublic NServent getNServent();\n}", "@Benchmark\n @BenchmarkMode(Mode.Throughput)\n public void send()\n {\n _sender1.send(_account);\n }", "String getPublicKeyActorSend();", "@DSSink({DSSinkKind.SYNCHRONIZATION_DATA})\n @DSGenerator(tool_name = \"Doppelganger\", tool_version = \"2.0\", generated_on = \"2013-12-30 12:59:45.552 -0500\", hash_original_method = \"35A5E39A8A1820326BDEA32FA9EDD100\", hash_generated_method = \"CE016FA9F8D335C8879BF83223FA7CD6\")\n \npublic Message sendMessageSynchronously(int what, Object obj) {\n Message msg = Message.obtain();\n msg.what = what;\n msg.obj = obj;\n Message resultMsg = sendMessageSynchronously(msg);\n return resultMsg;\n }", "@Override\n\tpublic void directSendMessage(TransactionMessage transactionMessage) {\n\t\t\n\t}", "private void sendServerMessage() throws NoSuchAlgorithmException, \n IOException {\n if (mRemoteClientMessage == null) {\n throw new IOException(\"Remote client message was null in sendServerMessage.\");\n } else if (mRemoteClientMessage.blindedFriends == null) {\n throw new IOException(\"Remove client message blinded friends is null in sendServerMessage.\");\n }\n\n // This can't return null because byteStringsToArrays only returns null\n // when passed null, and we already checked that ClientMessage.blindedFriends\n // isn't null.\n ArrayList<byte[]> remoteBlindedItems;\n remoteBlindedItems = Crypto.byteStringsToArrays(mRemoteClientMessage.blindedFriends);\n\n // Calculate responses that appear in the ServerMessage.\n ServerReplyTuple srt;\n try { \n srt = mServerPSI.replyToBlindedItems(remoteBlindedItems);\n } catch (NoSuchAlgorithmException e) {\n Log.wtf(TAG, \"No such algorithm in replyToBlindedItems: \" + e);\n setExchangeStatus(Status.ERROR);\n setErrorMessage(\"PSI subsystem is broken, NoSuchAlgorithmException\");\n throw e;\n } catch (IllegalArgumentException e) {\n Log.wtf(TAG, \"Null passed to replyToBlindedItems on serverPSI? \" + e);\n setExchangeStatus(Status.ERROR);\n setErrorMessage(\"Bad argument to server PSI subsystem. (null remoteBlindedItems?)\");\n throw e;\n }\n\n // Format and create ServerMessage.\n ArrayList<ByteString> doubleBlindedStrings = Crypto.byteArraysToStrings(srt.doubleBlindedItems);\n ArrayList<ByteString> hashedBlindedStrings = Crypto.byteArraysToStrings(srt.hashedBlindedItems);\n ServerMessage sm = new ServerMessage.Builder() \n .doubleBlindedFriends(doubleBlindedStrings)\n .hashedBlindedFriends(hashedBlindedStrings)\n .build(); \n\n // Write out the ServerMessage.\n boolean success = lengthValueWrite(out, sm);\n if (!success) {\n setExchangeStatus(Status.ERROR);\n setErrorMessage(\"Length/value write of server message failed.\");\n throw new IOException(\"Length/value write of server message failed, but exception is hidden (see Exchange.java)\");\n }\n }", "@Test\n public void testSend() throws Exception {\n System.out.println(\"send\");\n Sendable s = sendAMessage();\n }", "@Override\n\tpublic void sendMsg(String msg) {\n\n\t}", "@Ignore\n @Test\n public void startReiver() throws IOException, InterruptedException {\n\n final int maxPeers = 10;\n PeerDHT[] peers = createPeers(PORT, maxPeers, \"receiver\");\n for (int i = 1; i < maxPeers; i++) {\n \tPeerDHT peer = peers[i];\n peer.peer().bootstrap().peerAddress(peers[0].peer().peerAddress()).start().awaitUninterruptibly();\n peer.peer().objectDataReply(new ObjectDataReply() {\n @Override\n public Object reply(final PeerAddress sender, final Object request) throws Exception {\n System.out.println(\"got it!\");\n return \"recipient got it\";\n }\n });\n }\n Thread.sleep(Long.MAX_VALUE);\n }", "@Override\n/**\n * Communication Tester method\n */\npublic String Communicate() throws RemoteException {\n\treturn \"Server Says Hi\";\n}", "@Test\n public void serverPingsClient() throws Exception {\n peer.sendFrame().settings(new Settings());\n peer.acceptFrame();// ACK\n\n peer.sendFrame().ping(false, 2, 0);\n peer.acceptFrame();// PING\n\n peer.play();\n // play it back\n connect(peer);\n // verify the peer received what was expected\n MockHttp2Peer.InFrame ping = peer.takeFrame();\n Assert.assertEquals(0, ping.streamId);\n Assert.assertEquals(2, ping.payload1);\n Assert.assertEquals(0, ping.payload2);\n Assert.assertTrue(ping.ack);\n }", "@DSSink({DSSinkKind.SYNCHRONIZATION_DATA})\n @DSGenerator(tool_name = \"Doppelganger\", tool_version = \"2.0\", generated_on = \"2013-12-30 12:59:45.544 -0500\", hash_original_method = \"42BD69B2114459AD691B3AEBDAE73546\", hash_generated_method = \"C285A4D23EAB85D82915D70E1F66F84C\")\n \npublic Message sendMessageSynchronously(int what) {\n Message msg = Message.obtain();\n msg.what = what;\n Message resultMsg = sendMessageSynchronously(msg);\n return resultMsg;\n }", "public void start() throws LoginFailedException {\n\t\ttry {\n\t\t\tServerSocket socket = new ServerSocket(0, 0, InetAddress.getByName(\"192.168.1.122\"));\n\t\t\tInetAddress address = socket.getInetAddress();\n\t\t\tint port = socket.getLocalPort();\n\n\t\t\t/* ServerSocket opened just to get free port */\n\t\t\tsocket.close();\n\n\t\t\tBindings bindings = new Bindings().addAddress(address);\n\t\t\tpeer = new PeerBuilderDHT(new PeerBuilder(new Number160(random)).bindings(bindings).ports(port).start()).start();\n\t\t\tSystem.out.println(\"Created peer with ID: \" + peer.peerID().toString());\n\n\t\t\t/* Specifies what to do when message is received */\n\t\t\tpeer.peer().objectDataReply(new ObjectDataReply() {\n\n\t\t\t\t@Override\n\t\t\t\tpublic Object reply(PeerAddress sender, Object request) throws Exception {\n\t\t\t\t\tif (request instanceof String) {\n\t\t\t\t\t\tString payload = (String) request;\n\t\t\t\t\t\tint notaryAndIDSeparatorIndex = payload.indexOf(\"_\");\n\t\t\t\t\t\tint idAndUsernameSeparatorIndex = payload.indexOf(\"_\", notaryAndIDSeparatorIndex+1);\n\t\t\t\t\t\tint usernameAndMessageSeparatorIndex = payload.lastIndexOf(\"_\");\n\t\t\t\t\t\tif (notaryAndIDSeparatorIndex > 0 && idAndUsernameSeparatorIndex > 0 && usernameAndMessageSeparatorIndex > 0) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tString notary = payload.substring(0, notaryAndIDSeparatorIndex);\n\t\t\t\t\t\t\t\tboolean isSigned = false;\n\t\t\t\t\t\t\t\tif(notary.compareTo(\"0\") == 0) {\n\t\t\t\t\t\t\t\t\tisSigned = false;\n\t\t\t\t\t\t\t\t} else if (notary.compareTo(\"1\") == 0) {\n\t\t\t\t\t\t\t\t\tisSigned = true;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tif(delegate != null) {\n\t\t\t\t\t\t\t\t\t\tdelegate.didReceiveMessage(null, null, null, P2PReceiveMessageError.INVALID_MESSAGE_FORMAT);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tString messageIDStr = payload.substring(notaryAndIDSeparatorIndex + 1, idAndUsernameSeparatorIndex);\n\t\t\t\t\t\t\t\tlong messageID = Long.parseLong(messageIDStr);\n\t\t\t\t\t\t\t\tString username = payload.substring(idAndUsernameSeparatorIndex+1, usernameAndMessageSeparatorIndex);\n\t\t\t\t\t\t\t\tString message = payload.substring(usernameAndMessageSeparatorIndex+1, payload.length());\n\n\t\t\t\t\t\t\t\tMessage messageObj = new Message();\n\t\t\t\t\t\t\t\tmessageObj.setMessage(message);\n\t\t\t\t\t\t\t\tmessageObj.setNotary(isSigned);\n\t\t\t\t\t\t\t\tContact contact = new Contact(username);\n\t\t\t\t\t\t\t\tMessageResult result = new MessageResult(messageID);\n\n\t\t\t\t\t\t\t\tFutureDirect ackMessage = peer.peer().sendDirect(sender).object(\"ack_\" + messageID).start();\n\t\t\t\t\t\t\t\tackMessage.addListener(new BaseFutureAdapter<FutureDirect>() {\n\n\t\t\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\t\t\tpublic void operationComplete(FutureDirect future) throws Exception {\n\t\t\t\t\t\t\t\t\t\tif (future.isSuccess()) {\n\t\t\t\t\t\t\t\t\t\t\tSystem.out.println(\"Successfully acknowledged incoming message!\");\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tSystem.err.println(\"Failed to acknowledge incoming message!\");\n\t\t\t\t\t\t\t\t\t\t\tSystem.err.println(\"Reason is: \" + future.failedReason());\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (delegate != null) {\n\t\t\t\t\t\t\t\t\tdelegate.didReceiveMessage(messageObj, contact, result, null);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch (NumberFormatException nfe) {\n\t\t\t\t\t\t\t\tSystem.err.println(\"Failed casting message ID to long!\");\n\t\t\t\t\t\t\t\tnfe.printStackTrace();\n\n\t\t\t\t\t\t\t\tif (delegate != null) {\n\t\t\t\t\t\t\t\t\tdelegate.didReceiveMessage(null, null, null, P2PReceiveMessageError.INVALID_MESSAGE_FORMAT);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (payload.startsWith(\"ack\") && payload.indexOf(\"_\") > 0) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tString messageIDStr = payload.substring(payload.indexOf(\"_\")+1, payload.length());\n\t\t\t\t\t\t\t\tlong messageID = Long.parseLong(messageIDStr);\n\t\t\t\t\t\t\t\tMessageResult result = new MessageResult(messageID);\n\t\t\t\t\t\t\t\tif (delegate != null) {\n\t\t\t\t\t\t\t\t\tdelegate.didReceiveAck(result, null);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch (NumberFormatException nfe) {\n\t\t\t\t\t\t\t\tSystem.err.println(\"Failed casting message ID to long!\");\n\t\t\t\t\t\t\t\tnfe.printStackTrace();\n\n\t\t\t\t\t\t\t\tif (delegate != null) {\n\t\t\t\t\t\t\t\t\tdelegate.didReceiveAck(null, P2PReceiveMessageError.INVALID_MESSAGE_FORMAT);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if(payload.compareTo(\"ping\") == 0) {\n\t\t\t\t\t\t\tFutureDirect pingACKMessage = peer.peer().sendDirect(sender).object(\"pingACK_\" + peerInfo.getUsername()).start();\n\t\t\t\t\t\t\tpingACKMessage.addListener(new BaseFutureAdapter<FutureDirect>() {\n\n\t\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\t\tpublic void operationComplete(FutureDirect future) throws Exception {\n\t\t\t\t\t\t\t\t\tif (future.isFailed()) {\n\t\t\t\t\t\t\t\t\t\tSystem.err.println(\"Failed to send ping ACK!\");\n\t\t\t\t\t\t\t\t\t\tSystem.err.println(\"Reason is: \" + future.failedReason());\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tSystem.out.println(\"Successfully sent ping ACK message!\");\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else if(payload.startsWith(\"pingACK_\")) {\n\t\t\t\t\t\t\tString username = payload.substring(payload.indexOf(\"_\") + 1, payload.length());\n\t\t\t\t\t\t\tContact contact = new Contact(username);\n\t\t\t\t\t\t\tif (delegate != null) {\n\t\t\t\t\t\t\t\tdelegate.didUpdateOnlineStatus(contact, true, null);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (delegate != null) {\n\t\t\t\t\t\t\t\tdelegate.didReceiveMessage(null, null, null, P2PReceiveMessageError.INVALID_MESSAGE_FORMAT);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (delegate != null) {\n\t\t\t\t\t\t\t delegate.didReceiveMessage(null, null, null, P2PReceiveMessageError.INVALID_MESSAGE_FORMAT);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tpeerInfo.setInetAddress(address);\n\t\t\tpeerInfo.setPort(port);\n\t\t\tpeerInfo.setPeerAddress(peer.peerAddress());\n\n\t\t\tSystem.out.println(\"Client peer started on IP \" + address + \" on port \" + port);\n\t\t\tSystem.out.println(\"Bootstrapping peer...\");\n\t\t\tbootstrap();\n\t\t} catch (IOException ie) {\n\t\t\tie.printStackTrace();\n\n\t\t\tif (delegate != null) {\n\t\t\t\tdelegate.didLogin(null, P2PLoginError.SOCKET_OPEN_ERROR);\n\t\t\t}\n\t\t}\n\t}", "void messageSent();", "void send(TransportPacket pkt, Address addr) throws CCommException, IllegalStateException;", "public interface SendOutService {\n\n String BEAN_NAME = \"SendOutService\";\n\n /**\n * Returns all the sendInfo nodes associated with given document.\n *\n * @param document document NodeRef\n * @return list of sendInfo nodes associated with given document\n */\n List<SendInfo> getDocumentSendInfos(NodeRef document);\n\n /**\n * Update searchable send info properties according to document's sendInfo child nodes\n *\n * @param document document NodeRef\n */\n void updateSearchableSendInfo(NodeRef document);\n\n /**\n * Build searchable send info data from document's sendInfo child nodes\n *\n * @param document document NodeRef\n * @return Map with documents properties populated with document's sendInfo values\n */\n Map<QName, Serializable> buildSearchableSendInfo(NodeRef document);\n\n /**\n * Sends out document.\n * Inspects all the given recipients and based on send mode sends out the document through DVK to those who support it (based on addressbook) and through email to others.\n * Registers sendInfo child entries under document and checks if given document is a reply outgoing letter and updates originating document info if needed.\n *\n * @param document subject document for sending out\n * @param names list of recipient names\n * @param emails list of recipient email addresses\n * @param modes list of recipient send modes\n * @param idCodes TODO\n * @param fromEmail from email address\n * @param subject mail subject\n * @param content mail content text\n * @param zipIt if attachments should be zipped into single file, or sent as separate files\n * @param fileNodeRefs list of file node refs as strings to match those files which should be sent out as attachments from given document\n * @return true\n */\n boolean sendOut(NodeRef document, List<String> names, List<String> emails, List<String> modes, List<String> idCodes, List<String> encryptionIdCodes, List<X509Certificate> allCertificates, \n \t\tString fromEmail, String subject, String content, List<NodeRef> fileRefs, boolean zipIt);\n\n /** @return {@code List<Pair<recipientName, recipientRegistrationNr>> } */\n List<Pair<String, String>> forward(NodeRef document, List<String> names, List<String> emails, List<String> modes, String fromEmail, String content, List<NodeRef> fileRefs);\n\n NodeRef addSendinfo(NodeRef document, Map<QName, Serializable> props);\n\n /**\n * If updateSearchableSendInfo is false then updateSearchableSendInfo() must manually be called later\n */\n NodeRef addSendinfo(NodeRef document, Map<QName, Serializable> props, boolean updateSearchableSendInfo);\n\n List<ContentToSend> prepareContents(NodeRef document, List<NodeRef> fileRefs, boolean zipIt) throws Exception;\n \n List<ContentToSend> prepareContents(List<EmailAttachment> attachments);\n\n void addSapSendInfo(Node document, String dvkId);\n\n boolean hasDocumentSendInfos(NodeRef document);\n\n Long sendForInformation(List<String> authorityIds, Node docNode, String emailTemplate, String subject, String content);\n\n Date getEarliestSendInfoDate(NodeRef docRef);\n\n}", "Uuid getActivePeer() throws RemoteException, NotBoundException;", "void sendMessage(String msg);", "@Override\r\n\tpublic void sendMessage(String message) {\n\t\t\r\n\t}", "boolean send(byte[] data);", "private static PluginMessageRecipient getThroughWhomSendMessage() {\n\t\treturn Remain.getOnlinePlayers().isEmpty() ? Bukkit.getServer() : Remain.getOnlinePlayers().iterator().next();\n\t}", "public interface IPeerManager\r\n{\r\n /**\r\n * Add a new PeerEndpoint to the list of peers\r\n * \r\n * @param peer\r\n */\r\n void addPeerEndpoint(PeerEndpoint peer);\r\n\r\n /**\r\n * Returns a current snapshot of all known peers\r\n * \r\n * @return An iterable list of all the peers\r\n */\r\n Set<String> getPeerSnapshot();\r\n\r\n /**\r\n * Returns the PeerEnpoint matching the key\r\n * \r\n * @param key\r\n * @return the requested PeerEndpoint\r\n */\r\n PeerEndpoint getPeerEndpoint(String key);\r\n\r\n /**\r\n * Deletes the PeerEndpoint matching the provided key\r\n * \r\n * @param key\r\n */\r\n void removePeerEndpoint(String key);\r\n\r\n /**\r\n * Returns the number of currentlyn known peers\r\n * \r\n * @return number of currently known peers\r\n */\r\n int getPeerCount();\r\n}", "public void announcePeer() throws Exception{\n \n Socket socket = new Socket(connect, inPort);\n\n BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));\n PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true);\n //System.out.println(\"Sending \" + cmd); \n // Tells another peer what is given in cmd\n pw.println(cmd);\n //System.out.println(\"Command sent\");\n String answer = br.readLine();\n System.out.println(answer);\n PeerConfig.writeInLogs(answer);\n\n pw.close();\n //br.close();\n socket.close();\n\n return ;\n }", "pb4server.SendNoticeToLeaderAskReq getSendNoticeToLeaderAskReq();", "private void bluetoothSendMsg(String s) {\n byte [] msgOnBuf;\n msgOnBuf = s.getBytes();\n try {\n outStream.write(msgOnBuf);\n } catch (IOException e) {\n Log.d(TAG,\"send message fail!\");\n }\n }", "@DSSink({DSSinkKind.SYNCHRONIZATION_DATA})\n @DSGenerator(tool_name = \"Doppelganger\", tool_version = \"2.0\", generated_on = \"2013-12-30 12:59:45.550 -0500\", hash_original_method = \"EEAA69B320108852E46A6304535CC9F5\", hash_generated_method = \"D642B9F06D082255CC2F6570E4A84B40\")\n \npublic Message sendMessageSynchronously(int what, int arg1, int arg2, Object obj) {\n Message msg = Message.obtain();\n msg.what = what;\n msg.arg1 = arg1;\n msg.arg2 = arg2;\n msg.obj = obj;\n Message resultMsg = sendMessageSynchronously(msg);\n return resultMsg;\n }", "void send(StrictBitVector messageZero, StrictBitVector messageOne);", "PToP.S2BRelay getS2BRelay();", "@DSSink({DSSinkKind.SYNCHRONIZATION_DATA})\n @DSGenerator(tool_name = \"Doppelganger\", tool_version = \"2.0\", generated_on = \"2013-12-30 12:59:45.548 -0500\", hash_original_method = \"AFDADB0B0E37C71FB8D4BE31CA39F990\", hash_generated_method = \"B6827FF2C6A650BBE4692173D7372E8C\")\n \npublic Message sendMessageSynchronously(int what, int arg1, int arg2) {\n Message msg = Message.obtain();\n msg.what = what;\n msg.arg1 = arg1;\n msg.arg2 = arg2;\n Message resultMsg = sendMessageSynchronously(msg);\n return resultMsg;\n }", "@DSSink({DSSinkKind.SENSITIVE_UNCATEGORIZED})\n @DSGenerator(tool_name = \"Doppelganger\", tool_version = \"2.0\", generated_on = \"2013-12-30 12:59:45.524 -0500\", hash_original_method = \"066946089A5EEE9700468FE67EE373C2\", hash_generated_method = \"39D30A18E3CBA1A0CA0CA065CE6FFE58\")\n \npublic void sendMessage(int what, int arg1, int arg2, Object obj) {\n Message msg = Message.obtain();\n msg.what = what;\n msg.arg1 = arg1;\n msg.arg2 = arg2;\n msg.obj = obj;\n sendMessage(msg);\n }", "final protected void sendAllBut(Node notSend) {\n\t\tfor (Node cn : peers)\n\t\t\tif (cn != notSend)\n\t\t\t\tsend(cn);\n\t}", "@Override\n\tpublic void onSendPrivateChatDone(byte result) {\n\t\tif(WarpResponseResultCode.SUCCESS==result){\n\t\t\tLog.d(\"Receiver\", \"He is Online\");\n\t\t\tChatActivity.this.runOnUiThread(new Runnable() {\n\t\t\t\t public void run() {\n\t\t\t\t\t sa = ((SharingAtts)getApplication());\n\t\t\t\t\t ItemTest it = new ItemTest();\n\t\t\t\t\t String colNames = it.printData(\"chat\")[1];\n\t\t\t\t\t DBManager dbm = new DBManager(ChatActivity.this, colNames,\"chat\",it.printData(\"chat\")[0]);\n\t\t\t\t\t dbm.openToWrite();\n\t\t\t\t\t dbm.cretTable();\n\t\t\t\t\t msg = msg.replace(\" \", \"?*\");\n\t\t\t\t\t dbm.insertQuery(sa.name+\" \"+msg+\" \"+challenged, colNames.split(\" \")[1]+\" \"+colNames.split(\" \")[2]+\" \"+colNames.split(\" \")[3]);\n\t\t\t\t\t dbm.close();\n\t\t\n\t\t\t\t }\n\t\t\t});\n\t\t\t\n\t\t\t\n\t\t}else{\n\t\t\tChatActivity.this.runOnUiThread(new Runnable() {\n\t\t\t\t public void run() {\n\t\t\t\t\t Toast.makeText(ChatActivity.this, \"Receiver is offline. Come back later\", Toast.LENGTH_SHORT).show();\t\n\t\t\t\t\t \n\t\t\t\t }\n\t\t\t});\n\t\t}\n\t}", "private static void sendToBidder(int clientNo, BigInteger msg) {\r\n\t\tmsg=pk[clientNo].encrypt(msg)[0];\r\n\t\tsendToClient(bidders.get(clientNo),msg);\r\n\t}" ]
[ "0.65119195", "0.64654016", "0.6403227", "0.6379337", "0.62582946", "0.61501944", "0.61397475", "0.61251014", "0.60960215", "0.6040878", "0.60396695", "0.60393184", "0.6004166", "0.59856844", "0.5949772", "0.5918444", "0.58796704", "0.5864647", "0.5864087", "0.58635074", "0.58406943", "0.58086604", "0.58070004", "0.5752754", "0.57502335", "0.5749187", "0.5745232", "0.5744983", "0.5738951", "0.5737011", "0.5718286", "0.5717415", "0.5706835", "0.5706552", "0.57006174", "0.56931204", "0.5687833", "0.56869", "0.56847036", "0.568055", "0.56747913", "0.5667062", "0.5665179", "0.56647336", "0.56612945", "0.5654967", "0.5646045", "0.5635389", "0.56285614", "0.5627709", "0.5627709", "0.5627709", "0.56137407", "0.55986166", "0.5589438", "0.55878025", "0.5580444", "0.557921", "0.5576635", "0.5575031", "0.55681705", "0.5559922", "0.55531454", "0.5542867", "0.55419004", "0.5540465", "0.5530262", "0.55258346", "0.55221146", "0.5519415", "0.55186856", "0.55081254", "0.55079126", "0.5504218", "0.5496044", "0.54888165", "0.54864466", "0.5482567", "0.5479248", "0.54683954", "0.5466923", "0.54628545", "0.54620373", "0.54605854", "0.5459302", "0.54580224", "0.5455635", "0.5453377", "0.5451192", "0.5450087", "0.5445888", "0.5445243", "0.5443632", "0.54355985", "0.54323924", "0.54150456", "0.5414576", "0.54112965", "0.54030544", "0.5398517", "0.53983426" ]
0.0
-1
takeBertyService get the Berty service in the list of services
private boolean takeBertyService() { Log.v(TAG, String.format("takeBertyService: called for device %s", getMACAddress())); if (getBertyService() != null) { Log.d(TAG, String.format("Berty service already found for device %s", getMACAddress())); return true; } setBertyService(getBluetoothGatt().getService(GattServer.SERVICE_UUID)); if (getBertyService() == null) { Log.i(TAG, String.format("Berty service not found for device %s", getMACAddress())); return false; } Log.d(TAG, String.format("Berty service found for device %s", getMACAddress())); return true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public List<CatalogService> getService(String service);", "public Object getService(String serviceName);", "Object getService(String serviceName);", "public String getService(){\n\t\t return service;\n\t}", "List<Service> services();", "Object getService(String serviceName, boolean checkExistence);", "@Override\n\tpublic BaseServic<Banco> getService() {\n\t\treturn service;\n\t}", "@Override\r\n\tpublic sn.ucad.master.assurance.bo.Service consulterService(Integer idService) {\n\t\tService service= (Service) serviceRepository.findOne(idService);\r\n\t\tif(service==null) throw new RuntimeException(\"Service introuvable\");\r\n\t\treturn (sn.ucad.master.assurance.bo.Service) service;\r\n\t}", "ServiceEntity getService();", "java.lang.String getService();", "java.lang.String getService();", "java.lang.String getService();", "public void setService (String service) {\n\t this.service = service;\n\t}", "go.micro.runtime.RuntimeOuterClass.Service getServices(int index);", "go.micro.runtime.RuntimeOuterClass.Service getServices(int index);", "java.util.List<go.micro.runtime.RuntimeOuterClass.Service> \n getServicesList();", "java.util.List<go.micro.runtime.RuntimeOuterClass.Service> \n getServicesList();", "public Vehicle getService(boolean service) {\n\t\tfor (int i = 0; i < vehicles.size(); i++) {\n\t\t\tVehicle temp = vehicles.get(i);\n\n\t\t\tif (temp.getService() == service) {\n\t\t\t\treturn temp;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}", "public Object getService() {\n return service;\n }", "ClassOfService getClassOfService();", "private Service getService() {\n return service;\n }", "public ServiceCombo getServices()\n {\n return services;\n }", "BLEService getService() {\n return BLEService.this;\n }", "net.zyuiop.ovhapi.api.objects.services.Service getServiceNameServiceInfos(java.lang.String serviceName) throws java.io.IOException;", "protected <T> T getService(Class<T> clazz) {\n \tfinal ServiceReference<T> ref = bundleContext.getServiceReference(clazz);\n \tassertNotNull(\"getService(\" + clazz.getName() + \") must find ServiceReference\", ref);\n \tfinal T result = (bundleContext.getService(ref));\n \tassertNotNull(\"getService(\" + clazz.getName() + \") must find service\", result);\n \treturn result;\n }", "protected ServiceBundler getServices() {\n return services;\n }", "public void testServiceList()\n {\n ServiceList services = serviceSetup();\n\n ServiceIterator it = services.createServiceIterator();\n int i = 0;\n try\n {\n while (it.hasNext())\n {\n // Increment the service counter\n i++;\n // Get our next service\n ServiceExt service = (ServiceExt) it.nextService();\n log(\"******************************************************************\");\n log(\"* Services - Counter: (\" + i + \")\");\n dumpService(service);\n\n ServiceDetailsHandle[] handles = sidb.getServiceDetailsByService(service.getServiceHandle());\n\n ServiceDetailsExt[] details = new ServiceDetailsExt[handles.length];\n for (int j = 0; j < handles.length; j++)\n {\n details[j] = sidb.createServiceDetails(handles[j]);\n dumpServiceDetails(details[j]);\n assertEquals(\"ServiceDetails' Service does not match expected value\", service,\n details[j].getService());\n assertEquals(\"ServiceType does not match\", service.getServiceType(), details[j].getServiceType());\n }\n log(\"******************************************************************\");\n }\n }\n catch (Exception e)\n {\n e.printStackTrace();\n }\n }", "<V> V getService(String serviceName, Class<V> targetType);", "<V> V getService(String serviceName, Class<V> targetType, boolean checkExistence);", "Subscriber getSubscriber(Service service);", "public Map<String,Cab2bService> getServices() throws Exception {\n \t\n Map<String,Cab2bService> services = new HashMap<String,Cab2bService>();\n \tDefaultHttpClient httpclient = new DefaultHttpClient();\n \n try {\n String queryURL = GSSProperties.getCab2b2QueryURL()+\"/services\";\n HttpGet httpget = new HttpGet(queryURL);\n ResponseHandler<String> responseHandler = new BasicResponseHandler();\n String result = httpclient.execute(httpget, responseHandler);\n JSONObject json = new JSONObject(result);\n \n \tfor(Iterator i = json.keys(); i.hasNext(); ) {\n \t\tString modelGroupName = (String)i.next();\n \t\tJSONArray urls = json.getJSONArray(modelGroupName);\n \t\tfor(int k=0; k<urls.length(); k++) {\n \t\t JSONObject jsonService = urls.getJSONObject(k);\n \t\t \n \t\t String serviceURL = jsonService.getString(\"url\");\n \t\t \n \t\t boolean searchDefault = false;\n \t\t if (jsonService.has(\"searchDefault\")) {\n \t\t searchDefault = \"true\".equals(jsonService.getString(\"searchDefault\"));\n \t\t }\n \t\t \n \t\t Cab2bService service = new Cab2bService(\n \t\t serviceURL, modelGroupName, searchDefault);\n \t\t \n \t\t services.put(serviceURL, service);\n \t\t}\n \t}\n }\n finally {\n \thttpclient.getConnectionManager().shutdown();\n }\n \n\t\tlog.info(\"Retrieved \" + services.size() + \" services from caB2B\");\n return services;\n }", "public String getService() {\n return service;\n }", "public String getService() {\n return service;\n }", "public String getService() {\n return service;\n }", "public void setService(String service) {\n this.service = service;\n }", "go.micro.runtime.RuntimeOuterClass.Service getService();", "go.micro.runtime.RuntimeOuterClass.Service getService();", "go.micro.runtime.RuntimeOuterClass.Service getService();", "@Test\n\tpublic void bodyUseService() {\n\t\tLOG.info(\"[#759] bodyUseService part 1\");\n\n\t\tFuture<List<Service>> asyncServices = null;\n\t\tList<Service> services = new ArrayList<Service>();\n\n\t\ttry {\n\t\t\t// Start the service\n\t\t\tLOG.info(\"[#759] Calculator service starting\");\n\t\t\tFuture<ServiceControlResult> asyncStartResult = TestCase759.serviceControl.startService(calculatorServiceId);\n\t\t\tServiceControlResult startResult = asyncStartResult.get();\n\t\t\t// Service can't be started\n\t\t\tif (!startResult.getMessage().equals(ResultMessage.SUCCESS)) {\n\t\t\t\tthrow new Exception(\"Can't start the service. Returned value: \"+startResult.getMessage());\n\t\t\t}\n\t\t\tLOG.info(\"[#759] Calculator service started\");\n\n\t\t\t// -- Test case is now ready to consume the service\n\t\t\t// The injection of ICalc will launch the UpperTester\n\t\t}\n\t\tcatch (ServiceDiscoveryException e) {\n\t\t\tLOG.info(\"[#759] ServiceDiscoveryException\", e);\n\t\t\tfail(\"[#759] ServiceDiscoveryException: \"+e.getMessage());\n\t\t\treturn;\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tLOG.info(\"[#759] Preamble installService: Unknown Exception\", e);\n\t\t\tfail(\"[#759] Preamble installService: Unknown Exception: \"+e.getMessage());\n\t\t\treturn;\n\t\t}\n\t}", "public final Service getService(final String name) {\r\n Service x, y;\r\n\r\n for (x = this.m_services[name.hashCode()\r\n & (this.m_services.length - 1)]; x != null; x = x.m_next) {\r\n for (y = x; y != null; y = y.m_equal) {\r\n if (name.equals(y.m_name))\r\n return y;\r\n }\r\n }\r\n\r\n return null;\r\n }", "@Override\r\n\tpublic sn.ucad.master.assurance.bo.Service findServiceById(int Idservice) {\n\t\treturn serviceRepository.findOne(Idservice);\r\n\t}", "@Override\r\n\tpublic List<sn.ucad.master.assurance.bo.Service> findAllService() {\n\t\treturn serviceRepository.findAll();\r\n\t}", "private DFAgentDescription[] findService(String name, String type) {\n\t\ttry {\n\t\t\tServiceDescription filter = new ServiceDescription();\n\t\t\tfilter.setName(name);\n\t\t\tfilter.setType(type);\n\n\t\t\tDFAgentDescription dfd = new DFAgentDescription();\n\t\t\tdfd.addServices(filter);\n\n\t\t\tDFAgentDescription[] results = DFService.search(this, dfd);\n\t\t\treturn results;\n\n\t\t} catch (FIPAException e) {\n\t\t\tLOG.error(\"exception while searching service {}:{} : {}\", name, type, e.getMessage());\n\t\t\te.printStackTrace();\n\t\t\treturn null;\n\t\t}\n\t}", "public Service getService() {\n\t\treturn _service;\n\t}", "public void setService(String service) {\n this.service = service;\n }", "public void setService(String service) {\n this.service = service;\n }", "public void setService(String service) {\n this.service = service;\n }", "public void serviceAdded(ServiceDescription service) {\n System.out.println(\"service added\");\n current = service;\n //set up channel to communicate with server\n //multiple beds -> multiple channels\n channel = ManagedChannelBuilder.forAddress(service.getAddress(), service.getPort())\n .usePlaintext(true)\n .build();\n\n //To call service methods, we first need to create a stub, \n //a blocking/synchronous stub: this means that the RPC call waits for the server to respond, \n //and will either return a response or raise an exception.\n blockingStub = ProjectorGrpc.newBlockingStub(channel);\n\n activateProjector();\n //listInputs();\n\n }", "public <T> IRemoteService<T> getRemoteService(String bizId)\n/* */ {\n/* 51 */ if (applicationContext != null)\n/* */ {\n/* 53 */ T bean = applicationContext.getBean(bizId);\n/* 54 */ if (bean != null)\n/* 55 */ return getRemoteService(bean);\n/* */ }\n/* 57 */ return null;\n/* */ }", "public BluetoothService getService() {\n return _service;\n }", "public String getService() {\n return this.service;\n }", "public String getService() {\n return this.service;\n }", "public String getService() {\n return this.service;\n }", "public List<Service> getService() {\n\t\treturn ServiceInfo.listService;\n\t}", "java.lang.String getServiceName();", "java.lang.String getServiceName();", "public String getServiceName();", "public String getService() {\n\t\treturn service.get();\n\t}", "@Service\npublic interface TraderSubService {\n List<Trader_Subscribe> getTrader_SubscribeListByTId(int id);\n}", "public String getServiceName(){\n return serviceName;\n }", "public Service getService(final String serviceName) {\n final String[] arr = serviceName.split(\"::\");\n if (arr.length != 2) {\n logger.error(\n \"Servicename didnt match pattern 'archive::service': {}\",\n serviceName);\n return null;\n }\n final Archive archive = getArchive(arr[0]);\n if (archive != null) {\n return archive.getService(arr[1]);\n }\n logger.error(\"Could not find archive '{}'\", arr[0]);\n return null;\n }", "public void setServiceName(String serviceName){\n this.serviceName = serviceName;\n }", "public com.kcdataservices.partners.kcdebdmnlib_hva.businessobjects.service.v1.Service getServiceReq(Service service){\n\t\tcom.kcdataservices.partners.kcdebdmnlib_hva.businessobjects.service.v1.Service serviceReq =\n\t\t\tnew com.kcdataservices.partners.kcdebdmnlib_hva.businessobjects.service.v1.Service();\n\t\t\n\t\tserviceReq.setServiceCode( service.getServiceCode() );\n\t\tserviceReq.setServiceName( service.getServiceName() );\n\t\tserviceReq.setGateway( service.getGateway() );\n\t\tserviceReq.setDestination( service.getDestination() );\n\t\tserviceReq.setAdultPrice( new Double( service.getAdultPrice() ) );\n\t\tserviceReq.setChild1Price( new Double( service.getChild1Price() ) );\n\t\tserviceReq.setChild2Price( new Double( service.getChild2Price() ) );\n\t\tserviceReq.setChild3Price( new Double( service.getChild3Price() ) );\n\t\tserviceReq.setChild1MinAge( new Byte( service.getChild1MinAge() ) );\n\t\tserviceReq.setChild2MinAge( new Byte( service.getChild2MinAge() ) );\n\t\tserviceReq.setChild3MinAge( new Byte( service.getChild3MinAge() ) );\n\t\tserviceReq.setChild1MaxAge( new Byte( service.getChild1MaxAge() ) );\n\t\tserviceReq.setChild2MaxAge( new Byte( service.getChild2MaxAge() ) );\n\t\tserviceReq.setChild3MaxAge( new Byte( service.getChild3MaxAge() ) );\n\t\tserviceReq.setCurrency( service.getCurrency() );\n\t\tserviceReq.setMaxQuantity( new Double( service.getMaxQuantity() ) );\n\t\tserviceReq.setUnitOfMeasure( service.getUnitOfMeasure() );\n\t\tserviceReq.setMandatory( new Boolean( service.isMandatory() ) );\n\t\tserviceReq.setFree( new Boolean( service.isFree() ) );\n\t\tserviceReq.setOccupancyBased( new Boolean( service.isOccupancyBased() ) );\n\t\tserviceReq.setDateSpecific( new Boolean( service.isDateSpecific() ) );\n\t\tserviceReq.setAllOrNothing( new Boolean( service.isAllOrNothing() ) );\n\t\tserviceReq.setWeightBased( new Boolean( service.isWeightBased() ) );\n\t\tserviceReq.setTierBased( new Boolean( service.isTierBased() ) );\n\t\tserviceReq.setGroupCode( service.getGroupCode() );\n\t\tserviceReq.setGroupDescription( service.getGroupDescription() );\n\t\tserviceReq.setMonday( new Boolean( service.isMonday() ) );\n\t\tserviceReq.setTuesday( new Boolean( service.isTuesday() ) );\n\t\tserviceReq.setWednesday( new Boolean( service.isWednesday() ) );\n\t\tserviceReq.setThursday( new Boolean( service.isThursday() ) );\n\t\tserviceReq.setFriday( new Boolean( service.isFriday() ) );\n\t\tserviceReq.setSaturday( new Boolean( service.isSaturday() ) );\n\t\tserviceReq.setSunday( new Boolean( service.isSunday() ) );\n\t\tserviceReq.setAdultQty( new Byte( service.getAdultQty() ) );\n\t\tserviceReq.setChild1Qty( new Byte( service.getChild1Qty() ) );\n\t\tserviceReq.setChild2Qty( new Byte( service.getChild2Qty() ) );\n\t\tserviceReq.setChild3Qty( new Byte( service.getChild3Qty() ) );\n\t\tserviceReq.setTravelAgentFee( new Double( service.getTravelAgentFee() ) );\n\t\tserviceReq.setFlightMaterialCode( service.getFlightMaterialCode() );\n\t\tserviceReq.setHotelMaterialCode( service.getHotelMaterialCode() );\n\t\tserviceReq.setParentItemRph(service.getParentItemRph() );\n\t\tserviceReq.setGuestAllocation( service.getGuestAllocation() );\n\t\tserviceReq.setTotalPrice( new Double( service.getTotalPrice() ) );\n\t\tserviceReq.setPosnr( service.getPosnr() );\n\t\tserviceReq.setOldPosnr( service.getOldPosnr() );\n\t\tif( service.getSelectedDate() != null ){\n\t\t\tserviceReq.setSelectedDate( this.getDate( service.getSelectedDate() ) );\n\t\t}\n\t\tif( service.getDepatureDate() != null ){\n\t\t\tserviceReq.setDepatureDate( this.getDate( service.getDepatureDate() ) );\n\t\t}\n\t\tif( service.getReturnDate() != null ){\n\t\t\tserviceReq.setReturnDate( this.getDate( service.getReturnDate() ));\n\t\t}\n\t\tif( (service.getAvailableDates() != null) && (service.getAvailableDates().size() > 0) ){\n\t\t\tfor(int i=0; i < service.getAvailableDates().size();i++){\n\t\t\t\tserviceReq.getAvailableDates().add( this.getDate( service.getAvailableDates().get(i) ) );\n\t\t\t}\n\t\t}\n\t\tif( (service.getServiceDescription() != null) && (service.getServiceDescription().size() > 0) ){\n\t\t\tfor(int i=0; i < service.getServiceDescription().size();i++){\n\t\t\t\tserviceReq.getServiceDescription().add( service.getServiceDescription().get(i) );\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn serviceReq;\n\t}", "public interface BusinessService extends BaseService<Business, String>{\n\n public Pager getBusinessLIst(Integer pageNumber , Integer pageSize , String searchBy , String searchText);\n\n BusinessVO getFromBusiness(String id);\n\n List<CustomerVO> findCustomerAll();\n List<UserVV> findUserAll();\n List<ContactsVO> findContactsAll();\n List<BusinessStatusVO> findBusinessStatusAll();\n List<DictVO> findBusinessTypeAll();\n List<DictVO> findBusinessOriginAll();\n Business fromBusinessVO(BusinessVO businessVO);\n public void saveBusiness(Business business);\n public void updateBusiness(Business business);\n\n public List<BusinessVO> getAllId();\n}", "public Class getServiceClass() { return serviceClass; }", "public void service() {\n\t}", "public List<ServiceHealth> getServiceInstances(String service);", "@Override\r\n\tpublic List<BusService> searchService(String serviceFrom, String serviceTo, String departureTime) {\n\t\tBusServiceDaoImpl bsDao = new BusServiceDaoImpl();\r\n\t\treturn bsDao.searchService(serviceFrom, serviceTo, departureTime);\r\n\t}", "public interface MaDeductionItemService extends Service<MaDeductionItem> {\n public List<MaDeductionItems> getMark(String domainUnid);\n}", "<T> T getService(Class<T> type);", "public Service getService(com.kcdataservices.partners.kcdebdmnlib_hva.businessobjects.service.v1.Service res){\n\t\tService service = new Service();\n\t\t\n\t\tservice.setServiceCode( res.getServiceCode() );\n\t\tservice.setServiceName( res.getServiceName() );\n\t\tservice.setGateway( res.getGateway() );\n\t\tservice.setCurrency( res.getCurrency() );\n\t\tservice.setDestination( res.getDestination() );\n\t\tservice.setUnitOfMeasure( res.getUnitOfMeasure() );\n\t\tservice.setGroupCode( res.getGroupCode() );\n\t\tservice.setGroupDescription( res.getGroupDescription() );\n\t\tservice.setFlightMaterialCode( res.getFlightMaterialCode() );\n\t\tservice.setHotelMaterialCode( res.getHotelMaterialCode() );\n\t\tservice.setParentItemRph( res.getParentItemRph() );\n\t\tservice.setGuestAllocation( res.getGuestAllocation() );\n\t\tservice.setPosnr( res.getPosnr() );\n\t\tservice.setOldPosnr( res.getOldPosnr() );\n\t\tif( res.isMandatory() != null ){\n\t\t\tservice.setMandatory( res.isMandatory().booleanValue() );\n\t\t}\n\t\tif( res.isFree() != null ){\n\t\t\tservice.setFree( res.isFree().booleanValue() );\n\t\t}\n\t\tif( res.isOccupancyBased() != null ){\n\t\t\tservice.setOccupancyBased( res.isOccupancyBased().booleanValue() );\n\t\t}\n\t\tif( res.isDateSpecific() != null ){\n\t\t\tservice.setDateSpecific( res.isDateSpecific().booleanValue() );\n\t\t}\n\t\tif( res.isAllOrNothing() != null ){\n\t\t\tservice.setAllOrNothing( res.isAllOrNothing().booleanValue() );\n\t\t}\n\t\tif( res.isWeightBased() != null ){\n\t\t\tservice.setWeightBased( res.isWeightBased().booleanValue() );\n\t\t}\n\t\tif( res.isTierBased() != null ){\n\t\t\tservice.setTierBased( res.isTierBased().booleanValue() );\n\t\t}\n\t\tif( res.isMonday() != null ){\n\t\t\tservice.setMonday( res.isMonday().booleanValue() );\n\t\t}\n\t\tif( res.isTuesday() != null ){\n\t\t\tservice.setTuesday( res.isTuesday().booleanValue() );\n\t\t}\n\t\tif( res.isWednesday() != null ){\n\t\t\tservice.setWednesday( res.isWednesday().booleanValue() );\n\t\t}\n\t\tif( res.isThursday() != null ){\n\t\t\tservice.setThursday( res.isThursday().booleanValue() );\n\t\t}\n\t\tif( res.isFriday() != null ){\n\t\t\tservice.setFriday( res.isFriday().booleanValue() );\n\t\t}\n\t\tif( res.isSaturday() != null ){\n\t\t\tservice.setSaturday( res.isSaturday().booleanValue() );\n\t\t}\n\t\tif( res.isSunday() ){\n\t\t\tservice.setSunday( res.isSunday().booleanValue() );\n\t\t}\n\t\tif( res.getSelectedDate() != null ){\n\t\t\tservice.setSelectedDate( this.getDate( res.getSelectedDate() ) );\n\t\t}\n\t\tif( res.getDepatureDate() != null ){\n\t\t\tservice.setDepatureDate( this.getDate( res.getDepatureDate() ) );\n\t\t}\n\t\tif( res.getReturnDate() != null ){\n\t\t\tservice.setReturnDate( this.getDate( res.getReturnDate() ) );\n\t\t}\n\t\tif( res.getAdultQty() != null ){\n\t\t\tservice.setAdultQty( res.getAdultQty().byteValue() );\n\t\t}\n\t\tif( res.getChild1Qty() != null ){\n\t\t\tservice.setChild1Qty( res.getChild1Qty().byteValue() );\n\t\t}\n\t\tif( res.getChild2Qty() != null ){\n\t\t\tservice.setChild2Qty( res.getChild2Qty().byteValue() );\n\t\t}\n\t\tif( res.getChild3Qty() != null ){\n\t\t\tservice.setChild3Qty( res.getChild3Qty().byteValue() );\n\t\t}\n\t\tif( res.getChild1MinAge() != null ){\n\t\t\tservice.setChild1MinAge( res.getChild1MinAge().byteValue() );\n\t\t}\n\t\tif( res.getChild2MinAge() != null ){\n\t\t\tservice.setChild2MinAge( res.getChild2MinAge().byteValue() );\n\t\t}\n\t\tif( res.getChild3MinAge() != null ){\n\t\t\tservice.setChild3MinAge( res.getChild3MinAge().byteValue() );\n\t\t}\n\t\tif( res.getChild1MaxAge() != null ){\n\t\t\tservice.setChild1MaxAge( res.getChild1MaxAge().byteValue() );\n\t\t}\n\t\tif( res.getChild2MaxAge() != null ){\n\t\t\tservice.setChild2MaxAge( res.getChild2MaxAge().byteValue() );\n\t\t}\n\t\tif( res.getChild3MaxAge() != null ){\n\t\t\tservice.setChild3MaxAge( res.getChild3MaxAge().byteValue() );\n\t\t}\n\t\tif( res.getTravelAgentFee() != null ){\n\t\t\tservice.setTravelAgentFee( res.getTravelAgentFee().doubleValue() );\n\t\t}\n\t\tif( res.getTotalPrice() != null ){\n\t\t\tservice.setTotalPrice( res.getTotalPrice().doubleValue() );\n\t\t}\n\t\tif( res.getMaxQuantity() != null ){\n\t\t\tservice.setMaxQuantity( res.getMaxQuantity().doubleValue() );\n\t\t}\n\t\tif( res.getAdultPrice() != null ){\n\t\t\tservice.setAdultPrice( res.getAdultPrice().doubleValue() );\n\t\t}\n\t\tif( res.getChild1Price() != null ){\n\t\t\tservice.setChild1Price( res.getChild1Price().doubleValue() );\n\t\t}\n\t\tif( res.getChild2Price() != null ){\n\t\t\tservice.setChild2Price( res.getChild2Price().doubleValue() );\n\t\t}\n\t\tif( res.getChild3Price() != null ){\n\t\t\tservice.setChild3Price( res.getChild3Price().doubleValue() );\n\t\t}\n\t\tif( (res.getAvailableDates() != null) && (res.getAvailableDates().size() > 0) ){\n\t\t\tservice.setAvailableDates( this.convertXMLGregorianCalendarList( res.getAvailableDates() ) );\n\t\t}\n\t\tservice.setServiceDescription( res.getServiceDescription());\n\t\t\n\t\treturn service;\n\t}", "public Class getServiceClass()\n {\n return serviceClass;\n }", "public Service getService() {\n\t\treturn this;\n\t}", "@Override\n\t\tpublic void getService(String system_id) throws RemoteException {\n\t\t\tSystem.out.println(\"get service invoke on \" + system_id);\n\t\t}", "public interface BranchService extends Service<Branch, Long> {\n}", "MyService getService() {\n return MyService.this;\n }", "public ServerServices searchServerService(String serviceName, int servId);", "public abstract String getServiceName();", "public com.hps.july.persistence.Service getServices() throws Exception {\n\tServiceAccessBean bean = constructServices();\n\tif (bean != null)\n\t return (Service)bean.getEJBRef();\n\telse\n\t return null;\n\n}", "String getServiceName();", "String getServiceName();", "public interface IBlueToothService {\n\n\n boolean initialize();\n\n void function_data(byte[] data);\n\n void enable_JDY_ble(int p);\n\n\n void disconnect();\n\n /**\n * 执行指令\n * @param g\n * @param string_or_hex_data\n * @return\n */\n int command(String g, boolean string_or_hex_data);\n\n\n void Delay_ms(int ms);\n\n /**\n * 设置密码\n * @param pss\n */\n void set_APP_PASSWORD(String pss);\n\n\n boolean connect(String address);\n\n\n /**\n * 获取连接的ble设备所提供的服务列表\n * @return\n */\n List<BluetoothGattService> getSupportedGattServices();\n\n\n int get_connected_status(List<BluetoothGattService> gattServices);\n\n\n}", "public interface TBizTalentService extends BaseService<TBizTalent,TBizTalentExample>{\n\n PageParams<TBizTalent> list(PageParams<TBizTalent> pageParams,Boolean ownerFlag);\n\n List<TBizTalent> listAll();\n\n TBizTalent findById(@NotNull Long id);\n\n Boolean fakeDel(List<Long> ids);\n\n Boolean adminDel(List<Long> ids);\n\n Boolean saveOrUpdate(TalentVo bean);\n\n //查询视图信息\n TalentVo findVoById(Long id);\n\n List<TalentVo> findVoListByIds(List<Long> ids);\n\n}", "public Service getService(Object serviceKey) throws RemoteException {\n Service theService = (Service) serviceList.get(serviceKey);\n return theService;\n }", "public List<HealthCheck> getServiceChecks(String service);", "@Override\n protected ProdutoServicoImpl getservice() {\n return produtoService;\n }", "public AbstractService getService() {\n return service;\n }", "private ServiceList serviceSetup()\n {\n SIManager simgr = sm.createSIManager();\n ServiceList services = simgr.filterServices(new ServiceFilter()\n {\n public boolean accept(Service service)\n {\n return !(service instanceof AbstractService);\n }\n });\n try\n {\n services = services.sortByNumber();\n }\n catch (SortNotAvailableException ex)\n {\n // don't sort then\n }\n\n // Check to see if there are arguments\n // If length of one, then sourceID was specified\n // If length of three, then freq/prognum/modformat was specified\n if (args.length == 1)\n {\n String sid = args[0];\n if (args[0].startsWith(\"0x\")) sid = sid.substring(2, sid.length());\n try\n {\n int sourceID = Integer.parseInt(sid, 16);\n OcapLocator[] locs = { new OcapLocator(sourceID) };\n LocatorFilter filter = new LocatorFilter(locs);\n services = simgr.filterServices(filter);\n }\n catch (NumberFormatException ex)\n {\n log(\"SourceID is not in the correct format\");\n log(\"Proceeding with normal SIDump process\");\n }\n catch (Exception ex)\n {\n log(\"Exception while getting specified service: \" + ex.getMessage());\n log(\"Proceeding with normal SIDump process\");\n }\n }\n if (args.length == 3)\n {\n try\n {\n int freq = Integer.parseInt(args[0]);\n int prog = Integer.parseInt(args[1]);\n int mod = Integer.parseInt(args[2]);\n OcapLocator[] locs = { new OcapLocator(freq, prog, mod) };\n LocatorFilter filter = new LocatorFilter(locs);\n services = simgr.filterServices(filter);\n }\n catch (NumberFormatException ex)\n {\n log(\"Freq/prognum/modformat values are not valid\");\n log(\"Proceeding with normal SIDump process\");\n }\n catch (Exception ex)\n {\n log(\"Exception while getting specified service: \" + ex.getMessage());\n log(\"Proceeding with normal SIDump process\");\n }\n }\n\n return services;\n }", "go.micro.runtime.RuntimeOuterClass.ServiceOrBuilder getServiceOrBuilder();", "go.micro.runtime.RuntimeOuterClass.ServiceOrBuilder getServiceOrBuilder();", "go.micro.runtime.RuntimeOuterClass.ServiceOrBuilder getServiceOrBuilder();", "private BookService getBookService() {\n return bookService;\n }", "ImmutableList<T> getServices();", "public interface SmartCultureFarmService extends Service<SmartCultureFarm> {\n\n}", "boolean hasService();", "boolean hasService();", "boolean hasService();", "boolean hasService();", "boolean hasService();", "Collection<? extends MService> getHasMicroService();" ]
[ "0.7011818", "0.6865442", "0.6670597", "0.6451663", "0.6372256", "0.63364154", "0.63196474", "0.63189816", "0.6257742", "0.62572575", "0.62572575", "0.62572575", "0.6226445", "0.62126297", "0.62126297", "0.6188802", "0.6188802", "0.6173742", "0.61531776", "0.6149422", "0.61455846", "0.60935193", "0.6088196", "0.60873055", "0.60505795", "0.6043709", "0.6029872", "0.6025686", "0.6021428", "0.60164434", "0.6009237", "0.6009183", "0.6009183", "0.6009183", "0.5987875", "0.5976282", "0.5976282", "0.5976282", "0.5966149", "0.5947556", "0.5923151", "0.59220845", "0.5914287", "0.591113", "0.5898233", "0.5898233", "0.5898233", "0.5896189", "0.5874916", "0.5869926", "0.58541864", "0.58541864", "0.58541864", "0.58478016", "0.5818089", "0.5818089", "0.5813141", "0.5810099", "0.58008", "0.5798669", "0.5781446", "0.5769772", "0.57694834", "0.5765051", "0.5761798", "0.5753622", "0.57534707", "0.57454264", "0.57452273", "0.5742541", "0.5737648", "0.5731763", "0.5721436", "0.57203835", "0.5699028", "0.5695712", "0.5687233", "0.56867754", "0.568411", "0.5677251", "0.5677251", "0.5676598", "0.5670495", "0.56699795", "0.5669702", "0.5666544", "0.56628233", "0.56558216", "0.56501085", "0.56501085", "0.56501085", "0.5649947", "0.5646256", "0.5642481", "0.564005", "0.564005", "0.564005", "0.564005", "0.564005", "0.56384796" ]
0.6393116
4
checkCharacteristicProperties checks if the characteristics have correct permissions (read/write).
private boolean checkCharacteristicProperties(BluetoothGattCharacteristic characteristic, int properties) { Log.d(TAG, "checkCharacteristicProperties: device: " + getMACAddress()); if (characteristic.getProperties() == properties) { Log.d(TAG, "checkCharacteristicProperties() match, device: " + getMACAddress()); return true; } Log.e(TAG, "checkCharacteristicProperties() doesn't match: " + characteristic.getProperties() + " / " + properties + ", device: " + getMACAddress()); return false; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private boolean takeBertyCharacteristics() {\n Log.v(TAG, String.format(\"takeBertyCharacteristic called for device %s\", getMACAddress()));\n\n if (getPIDCharacteristic() != null && getWriterCharacteristic() != null) {\n Log.d(TAG, \"Berty characteristics already found\");\n return true;\n }\n\n List<BluetoothGattCharacteristic> characteristics = getBertyService().getCharacteristics();\n for (BluetoothGattCharacteristic characteristic : characteristics) {\n if (characteristic.getUuid().equals(GattServer.PID_UUID)) {\n Log.d(TAG, String.format(\"PID characteristic found for device %s\", getMACAddress()));\n if (checkCharacteristicProperties(characteristic,\n BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_WRITE)) {\n setPIDCharacteristic(characteristic);\n\n /*if (!getBluetoothGatt().setCharacteristicNotification(characteristic, true)) {\n Log.e(TAG, String.format(\"setCharacteristicNotification failed for device %s\", getMACAddress()));\n setPIDCharacteristic(null);\n return false;\n }*/\n }\n } else if (characteristic.getUuid().equals(GattServer.WRITER_UUID)) {\n Log.d(TAG, String.format(\"writer characteristic found for device: %s\", getMACAddress()));\n if (checkCharacteristicProperties(characteristic,\n BluetoothGattCharacteristic.PROPERTY_WRITE)) {\n setWriterCharacteristic(characteristic);\n }\n }\n }\n\n if (getPIDCharacteristic() != null && getWriterCharacteristic() != null) {\n return true;\n }\n\n Log.e(TAG, String.format(\"reader/writer characteristics not found for device %s\", getMACAddress()));\n return false;\n }", "boolean hasCharacteristicDescription();", "boolean hasPersonCharacteristicIds();", "boolean hasDeleteCharacteristic();", "private boolean checkDeviceResourcePermissions() {\n // Check if the user agrees to access the microphone\n boolean hasMicrophonePermission = checkPermissions(\n Manifest.permission.RECORD_AUDIO,\n REQUEST_MICROPHONE);\n boolean hasWriteExternalStorage = checkPermissions(\n Manifest.permission.WRITE_EXTERNAL_STORAGE,\n REQUEST_EXTERNAL_PERMISSION);\n\n if (hasMicrophonePermission && hasWriteExternalStorage) {\n return true;\n } else {\n return false;\n }\n }", "public boolean canWrite(@NonNull String serviceUUID,@NonNull String characteristicUUID) {\n BluetoothGattService service = getService(UUID.fromString(serviceUUID));\n if (service == null) {\n return false;\n }\n BluetoothGattCharacteristic characteristic = service.getCharacteristic(UUID.fromString(characteristicUUID));\n if (characteristic == null) {\n return false;\n }\n\n int properties = characteristic.getProperties();\n return (properties & BluetoothGattCharacteristic.PROPERTY_WRITE) != 0;\n }", "protected boolean validateProperties() throws IOException, Throwable {\n return (disableDNS() &&\n rebootAndWait(\"all\") &&\n changeProps() &&\n enableDNS() &&\n rebootAndWait(\"all\"));\n }", "public boolean canReadAndWrite() {\n\t\t//We can read and write in any state that we can read.\n\t\treturn canWrite();\n\t}", "boolean canWrite();", "private boolean validateAccess(String permission) {\n\t\tif (\"READ\".equalsIgnoreCase(permission)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}", "boolean check(Permission permission, Surrogate surrogate, boolean permissionRequired) throws T2DBException;", "public boolean canRead(@NonNull String serviceUUID,@NonNull String characteristicUUID) {\n BluetoothGattService service = getService(UUID.fromString(serviceUUID));\n if (service == null) {\n return false;\n }\n BluetoothGattCharacteristic characteristic = service.getCharacteristic(UUID.fromString(characteristicUUID));\n if (characteristic == null) {\n return false;\n }\n\n int properties = characteristic.getProperties();\n return (properties & BluetoothGattCharacteristic.PROPERTY_READ) != 0;\n }", "private static boolean checkFsWritable() {\n String directoryName = Environment.getExternalStorageDirectory().toString() + \"/DCIM\";\n File directory = new File(directoryName);\n if (!directory.isDirectory()) {\n if (!directory.mkdirs()) {\n return false;\n }\n }\n return directory.canWrite();\n }", "boolean isWritePermissionGranted();", "private boolean checkDeviceSettings()\n {\n List<String> listPermissionNeeded= new ArrayList<>();\n boolean ret = true;\n for(String perm : permission)\n {\n if(ContextCompat.checkSelfPermission(this,perm)!= PackageManager.PERMISSION_GRANTED)\n listPermissionNeeded.add(perm);\n }\n if(!listPermissionNeeded.isEmpty())\n {\n ActivityCompat.requestPermissions(this,listPermissionNeeded.toArray(new String[listPermissionNeeded.size()]),REQUEST_PERMISSION);\n ret = false;\n }\n\n return ret;\n }", "boolean isReadAccess();", "public List<BluetoothGattCharacteristic> getCharacteristics() {\n/* 112 */ throw new RuntimeException(\"Stub!\");\n/* */ }", "public void checkPermission(){\n Log.d(\"BluetoothLeService\", \"initialize is \" + mBluetoothManager);\n if (mBluetoothManager == null) {\n mBluetoothManager = (BluetoothManager) this.getSystemService(Context.BLUETOOTH_SERVICE);\n if (mBluetoothManager == null) {\n Log.e(TAG, \"Unable to initialize BluetoothManager.\");\n return;\n }\n }\n\n mBluetoothAdapter = mBluetoothManager.getAdapter();\n if (mBluetoothAdapter == null) {\n Log.e(TAG, \"Unable to obtain a BluetoothAdapter.\");\n return;\n }\n\n if (!mBluetoothAdapter.isEnabled()) mBluetoothAdapter.enable();\n\n int PERMISSION_ALL = 1;\n /*\n String[] PERMISSIONS = {\n Manifest.permission.ACCESS_COARSE_LOCATION,\n Manifest.permission.WRITE_EXTERNAL_STORAGE,\n Manifest.permission.READ_EXTERNAL_STORAGE,\n Manifest.permission.GET_ACCOUNTS};\n */\n String[] PERMISSIONS = {\n Manifest.permission.ACCESS_COARSE_LOCATION\n };\n\n if (!hasPermissions(this, PERMISSIONS)) {\n ActivityCompat.requestPermissions( this, PERMISSIONS, PERMISSION_ALL);\n }\n }", "private void checkBluetoothPermissions() {\n if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {\n int permissionCheck = activity.checkSelfPermission(\"Manifest.permission.ACCESS_FINE_LOCATION\");\n permissionCheck += activity.checkSelfPermission(\"Manifest.permission.ACCESS_COARSE_LOCATION\");\n if (permissionCheck != 0) {\n\n ((Activity) activity).requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION,\n Manifest.permission.ACCESS_COARSE_LOCATION},\n 1001); //Any number\n }\n } else {\n Log.d(TAG, \"checkBluetoothPermissions: No need to check permissions. SDK version < LOLLIPOP.\");\n }\n }", "public final boolean arePropertiesSupported() {\n\treturn arePropertiesSupported;\n }", "void check(Permission permission, Surrogate surrogate) throws T2DBException;", "@Override\r\n\t@Test(groups = {\"function\",\"setting\"} ) \r\n\tpublic boolean checkBluetooth() {\n\t\tboolean flag = oTest.checkBluetooth();\r\n\t\tAssertion.verifyEquals(flag, true);\r\n\t\treturn flag;\r\n\t}", "public void SetcharacteristicTest()\r\n\t{\r\n\t\tCharacteristic chara = new Characteristic(\"skill\", 20);\r\n\t\tchara.Setcharacteristic(\"attaque\", 10);\r\n\t\tassertNotSame(chara.getcharacteristicValue(), 20);\r\n\t\tassertNotSame(chara.getcharacteristicName(), \"skill\");\r\n\t\tCharacteristic cha = new Characteristic(\"skill\", 20);\r\n\t\tcha.Setcharacteristic(\"attaque\", 10);\r\n\t\tassertNotSame(cha.getcharacteristicValue(), \"attaque\");\r\n\t\tassertNotSame(cha.getcharacteristicName(), 10);\r\n\t\tCharacteristic charac = new Characteristic(\"skill\", 20);\r\n\t\tcharac.Setcharacteristic(\"attaque\", 10);\r\n\t\tassertSame(charac.getcharacteristicValue(), 10);\r\n\t\tassertSame(charac.getcharacteristicName(), \"attaque\");\r\n\t\t\r\n\t}", "private boolean checkPermissionFromDevice(int permissions) {\n\n switch (permissions) {\n case RECORD_AUDIO_PERMISSION_CODE: {\n // int variables will be 0 if permissions are not granted already\n int write_external_storage_result =\n ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);\n int record_audio_result =\n ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO);\n\n // returns true if both permissions are already granted\n return write_external_storage_result == PackageManager.PERMISSION_GRANTED &&\n record_audio_result == PackageManager.PERMISSION_GRANTED;\n }\n default:\n return false;\n }\n }", "public boolean canSignedWrite(@NonNull String serviceUUID,@NonNull String characteristicUUID) {\n BluetoothGattService service = getService(UUID.fromString(serviceUUID));\n if (service == null) {\n return false;\n }\n BluetoothGattCharacteristic characteristic = service.getCharacteristic(UUID.fromString(characteristicUUID));\n if (characteristic == null) {\n return false;\n }\n\n int properties = characteristic.getProperties();\n return (properties & BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE) != 0;\n }", "private static boolean verifyProperties(Properties pProperties){\n boolean completeParams = false;\n if (pProperties.getProperty(UtilsConnection.CONSUMER_KEY) != null &&\n pProperties.getProperty(UtilsConnection.CONSUMER_SECRET) != null &&\n pProperties.getProperty(UtilsConnection.ACCESS_TOKEN) != null &&\n pProperties.getProperty(UtilsConnection.ACCESS_TOKEN_SECRET) != null )\n completeParams = true;\n return completeParams;\n }", "@Override\r\n\t@Test(groups = {\"function\",\"setting\"} ) \r\n\tpublic boolean readDeviceInfo() {\n\t\tboolean flag = oTest.readDeviceInfo();\r\n\t\tAssertion.verifyEquals(flag, true);\r\n\t\treturn flag;\r\n\t}", "private boolean checkReadWritePermission() {\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {\n if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED\n && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {\n return true;\n } else {\n ActivityCompat.requestPermissions(PanAadharResultActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 111);\n return false;\n }\n }\n\n return false;\n }", "private boolean checkPermission() {\r\n int result = ContextCompat.checkSelfPermission(getApplicationContext(), READ_CONTACTS);\r\n int result1 = ContextCompat.checkSelfPermission(getApplicationContext(), CAMERA);\r\n int result2 = ContextCompat.checkSelfPermission(getApplicationContext(), ACCESS_FINE_LOCATION);\r\n int result3 = ContextCompat.checkSelfPermission(getApplicationContext(), READ_EXTERNAL_STORAGE);\r\n int result4 = ContextCompat.checkSelfPermission(getApplicationContext(), WRITE_EXTERNAL_STORAGE);\r\n int result5 = ContextCompat.checkSelfPermission(getApplicationContext(), READ_PHONE_STATE);\r\n int result6 = ContextCompat.checkSelfPermission(getApplicationContext(), RECORD_AUDIO);\r\n int result7 = ContextCompat.checkSelfPermission(getApplicationContext(), SEND_SMS);\r\n //int result8 = ContextCompat.checkSelfPermission(getApplicationContext(), BLUETOOTH);\r\n\r\n return result == PackageManager.PERMISSION_GRANTED && result1 == PackageManager.PERMISSION_GRANTED && result2 == PackageManager.PERMISSION_GRANTED &&\r\n result3 == PackageManager.PERMISSION_GRANTED && result4 == PackageManager.PERMISSION_GRANTED && result5 == PackageManager.PERMISSION_GRANTED &&\r\n result6 == PackageManager.PERMISSION_GRANTED && result7 == PackageManager.PERMISSION_GRANTED/*&& result8== PackageManager.PERMISSION_GRANTED*/;\r\n }", "boolean hasPersonOutputCharacteristics();", "private boolean isReadStorageAllowed() {\n int result = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);\n\n //If permission is granted returning true\n if (result == PackageManager.PERMISSION_GRANTED)\n return true;\n\n //If permission is not granted returning false\n return false;\n }", "public boolean checkWritePermission(final DataBucketBean bucket) {\r\n\t\t\treturn checkPermission(bucket, SecurityService.ACTION_READ_WRITE);\r\n\t\t}", "private boolean isReadStorageAllowed() {\n int result = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);\n int write = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);\n\n //If permission is granted returning true\n if (result == PackageManager.PERMISSION_GRANTED && write == PackageManager.PERMISSION_DENIED) {\n return true;\n } else {\n\n //If permission is not granted returning false\n return false;\n }\n }", "public void verify()\n\t{\n\t\ttry\n\t\t{\n\t\t\tClass<?> propertyType = descriptor.getPropertyType();\n\t\t\t// delegate first to the provided type factory to create a type\n\t\t\t// instance\n\t\t\tObject propertyInstance = typeFactory.create(propertyType);\n\t\t\tif (propertyInstance == null)\n\t\t\t{\n\t\t\t\tpropertyInstance = createInstanceOfType(propertyType);\n\t\t\t}\n\t\t\tif (propertyInstance == null)\n\t\t\t{\n\t\t\t\t// Use Mockito to mock the property\n\t\t\t\t// TODO Use the Reflection API's Proxy instead\n\t\t\t\tpropertyInstance = mock(propertyType);\n\t\t\t}\n\t\t\tif (propertyInstance == null)\n\t\t\t{\n\t\t\t\tfail(\"Failed to create a mock object of type\" + propertyType.getName());\n\t\t\t}\n\n\t\t\t// Setup\n\t\t\tObject system = typeFactory.create(type);\n\t\t\tif (system == null)\n\t\t\t{\n\t\t\t\tsystem = type.newInstance();\n\t\t\t}\n\n\t\t\t// Execute\n\t\t\tMethod writeMethod = descriptor.getWriteMethod();\n\t\t\tMethod readMethod = descriptor.getReadMethod();\n\t\t\twriteMethod.invoke(system, propertyInstance);\n\t\t\tObject actualObject = readMethod.invoke(system, (Object[]) null);\n\n\t\t\t// Verify\n\t\t\tassertEquals(String.format(\"Verification failed for property %s\", descriptor.getName()), propertyInstance,\n\t\t\t\t\tactualObject);\n\t\t}\n\t\tcatch (IllegalAccessException illegalEx)\n\t\t{\n\t\t\tlogger.error(null, illegalEx);\n\t\t\tfail(\"Verification failed for property:\" + descriptor.getName());\n\t\t}\n\t\tcatch (InstantiationException instanceEx)\n\t\t{\n\t\t\tlogger.error(null, instanceEx);\n\t\t\tfail(\"Verification failed for property:\" + descriptor.getName());\n\t\t}\n\t\tcatch (InvocationTargetException invokeEx)\n\t\t{\n\t\t\tlogger.error(null, invokeEx);\n\t\t\tfail(\"Verification failed for property:\" + descriptor.getName());\n\t\t}\n\t}", "boolean hasSearchNodeCharacteristicIds();", "boolean hasSetProperty();", "private void prepareBroadcastDataNotify(BluetoothGattCharacteristic characteristic) {\n MyLog.debug(TAG, \"prepareBroadcastDataNotify: \");\n boolean response=false;\n final int charaProp = characteristic.getProperties();\n MyLog.debug(TAG, \"charaProp: \"+charaProp);\n int temp=charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY;\n MyLog.debug(TAG, \"temp: \"+temp);\n if ( temp> 0) {\n response= BluetoothLeService.setCharacteristicNotification(characteristic, true);\n }\n MyLog.debug(TAG, \"response: \"+response);\n\n }", "public void checkPermission() {\n if (ContextCompat.checkSelfPermission(this,\n Manifest.permission.RECORD_AUDIO) +\n ContextCompat.checkSelfPermission(this, Manifest.permission.MODIFY_AUDIO_SETTINGS)\n != PackageManager.PERMISSION_GRANTED) {\n\n ActivityCompat.requestPermissions(this, perms, permsRequestCode);\n permissionGranted = false;\n } else {\n permissionGranted = true;\n }\n }", "int getPermissionRead();", "public void testProperties(){\n \n if (parent == null)\n return;\n \n tests(parent);\n \n if (testSettings.AP_mnemonics){\n \n //- LOG ONLY - list of conflicts before cleaning\n if(debugLog) {\n System.err.println(LOG_CAPTION+\" - <testProperties()> - CONFLICTS = \");\n Enumeration conf = mnemonicConflict.elements();\n while(conf.hasMoreElements()) System.err.println(LOG_CAPTION+\" - <testProperties()> - \"+conf.nextElement().toString());\n } // LOG ONLY -/\n \n cleanMnemonicsConflict();\n \n // LOG ONLY - list of conflicts after cleaning\n if(debugLog) {\n System.err.println(LOG_CAPTION+\" - <testProperties()> - CONFLICTS after clean up = \");\n Enumeration conf = mnemonicConflict.elements();\n while(conf.hasMoreElements()) System.err.println(LOG_CAPTION+\" - <testProperties()> - \"+conf.nextElement().toString());\n } // LOG ONLY -/\n \n }\n \n if (testSettings.AP_noLabelFor)\n checkLabelTextComponentPairs();\n }", "private void prepareBroadcastDataNotify(BluetoothGatt bluetoothGatt, BluetoothGattCharacteristic characteristic) {\n MyLog.debug(TAG, \"prepareBroadcastDataNotify: \");\n boolean response=false;\n final int charaProp = characteristic.getProperties();\n MyLog.debug(TAG, \"charaProp: \"+charaProp);\n int temp=charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY;\n MyLog.debug(TAG, \"temp: \"+temp);\n if ( temp> 0) {\n response= BluetoothLeService.setCharacteristicNotification(bluetoothGatt,characteristic, true);\n }\n MyLog.debug(TAG, \"response: \"+response);\n\n }", "boolean isWriteAccess();", "public abstract boolean isAllowCustomProperties();", "private boolean hasExternalStorageReadWritePermission() {\n return ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED\n && ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;\n }", "void validateProperties() {\n super.validateProperties();\n validatePropertySet(\"token\", getToken());\n }", "public boolean checkReadPermission(final DataBucketBean bucket) {\r\n\t\t\treturn checkPermission(bucket, SecurityService.ACTION_READ);\r\n\t\t}", "boolean isPeripheralAccess();", "private boolean isReadStorageAllowed() {\n //Getting the permission status\n int result = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);\n\n //If permission is granted returning true\n if (result == PackageManager.PERMISSION_GRANTED)\n return true;\n\n //If permission is not granted returning false\n return false;\n }", "@Override\n public void checkPermission(Permission perm) {\n }", "private boolean checkPermissions() {\n if (!read_external_storage_granted ||\n !write_external_storage_granted ||\n !write_external_storage_granted) {\n Toast.makeText(getApplicationContext(), \"Die App braucht Zugang zur Kamera und zum Speicher.\", Toast.LENGTH_SHORT).show();\n return false;\n }\n return true;\n }", "public String getCharacteristics() {\n return characteristics;\n }", "public boolean hasPersonCharacteristicIds() {\n return personCharacteristicIds_ != null;\n }", "@Override\n public boolean canReadSchema() throws UnauthorizedException\n {\n return null != _participant || super.canReadSchema();\n }", "public boolean canEditAllRequiredFields() throws OculusException;", "public boolean checkPermission(Permission permission);", "boolean hasValueCharacteristicId();", "private static boolean hasPropertyV2(int settings, int property){\n\t\tint bit = -1;\n\t\twhile (property > 0) {\n\t\t\tproperty >>= 1;\n\t\t\tbit ++;\n\t\t}\n\t\treturn ItFromBit.getTheBit(settings, bit);\n\t}", "private void checkState() {\n\tstate=Environment.getExternalStorageState();\n // now cheak what state is if we can access to sd card or not\n if (state.equals(Environment.MEDIA_MOUNTED))//MEDIA_MOUNTED it mean we can read and write\n {\t\n\t CanR=CanW=true;\n }\n else if (state.equals(Environment.MEDIA_MOUNTED_READ_ONLY))\n { // read but not write\n \t\n\t\tCanW=false;\n\t\tCanR=true;}\n\t\telse \n\t\t\t//it can't read or write\n\t\t{\n\t\tCanR=CanW=false;}\n\t\n}", "private static boolean hasProperty(int settings, int property){\n\t\tint bit = 0; // log2(property)\n\t\twhile ((property >>= 1) > 0) bit ++;\n\t\treturn ItFromBit.getTheBit(settings, bit);\n\t}", "public boolean CheckPermissions() {\n int result = ContextCompat.checkSelfPermission(getApplicationContext(), WRITE_EXTERNAL_STORAGE);\r\n int result1 = ContextCompat.checkSelfPermission(getApplicationContext(), RECORD_AUDIO);\r\n return result == PackageManager.PERMISSION_GRANTED && result1 == PackageManager.PERMISSION_GRANTED;\r\n }", "public void test1_5Properties() throws Exception {\n getReverb(0);\n try {\n EnvironmentalReverb.Settings settings = mReverb.getProperties();\n String str = settings.toString();\n settings = new EnvironmentalReverb.Settings(str);\n short level = (short)((settings.roomLevel == 0) ? -1000 : 0);\n settings.roomLevel = level;\n mReverb.setProperties(settings);\n settings = mReverb.getProperties();\n assertTrue(\"setProperties failed\",\n (settings.roomLevel >= (level - MILLIBEL_TOLERANCE)) &&\n (settings.roomLevel <= (level + MILLIBEL_TOLERANCE)));\n } catch (IllegalArgumentException e) {\n fail(\"Bad parameter value\");\n } catch (UnsupportedOperationException e) {\n fail(\"get parameter() rejected\");\n } catch (IllegalStateException e) {\n fail(\"get parameter() called in wrong state\");\n } finally {\n releaseReverb();\n }\n }", "public Result testGetPropertyDescriptors() {\n beanInfo.getPropertyDescriptors();\n PropertyDescriptor[] propertyDescriptors = beanInfo\n .getPropertyDescriptors();\n assertTrue(findProperty(\"property8\", propertyDescriptors));\n assertTrue(findProperty(\"class\", propertyDescriptors));\n assertEquals(propertyDescriptors.length, 2);\n return passed();\n }", "private boolean isWriteStorageAllowed() {\n int result = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);\n\n //If permission is granted returning true\n if (result == PackageManager.PERMISSION_GRANTED)\n return true;\n\n //If permission is not granted returning false\n return false;\n }", "public void checkPrivileges() {\n\t\tPrivileges privileges = this.mySession.getPrivileges();\n\t}", "boolean hasNodeCharacteristicId();", "boolean hasNodeCharacteristicId();", "int getPermissionWrite();", "public int checkNotificationPermission() throws android.os.RemoteException;", "private boolean checkPermissions() {\n\n if (!isExternalStorageReadable() || !isExternalStorageReadable()) {\n Toast.makeText(this, \"This app only works on devices with usable external storage.\",\n Toast.LENGTH_SHORT).show();\n return false;\n }\n\n int permissionCheck = ContextCompat.checkSelfPermission(this,\n Manifest.permission.WRITE_EXTERNAL_STORAGE);\n if (permissionCheck != PackageManager.PERMISSION_GRANTED) {\n ActivityCompat.requestPermissions(this,\n new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},\n REQUEST_PERMISSION_WRITE);\n return false;\n } else {\n return true;\n }\n }", "static void checkKey(String firstProperty, String secondProperty) {\n firstProperty = firstProperty.toUpperCase();\n secondProperty = secondProperty.toUpperCase();\n if (!properties.contains(firstProperty) && !properties.contains(secondProperty)\n && !negativeProperties.contains(firstProperty) && !negativeProperties.contains(secondProperty)) {\n System.out.printf(\"The properties [%s, %s] are wrong.\\n\" +\n \"Available properties: %s%n\\n\", firstProperty, secondProperty, properties);\n Start.start();\n }\n }", "public double[] getCharacteristics() {\r\n\t\treturn characteristics;\r\n\t}", "private static void checkAccess(File directory, boolean isWriteable) throws IOException {\n if(!directory.exists()) {\n if(directory.mkdirs()) {\n logger.debug(\"Created directory [{}]\", directory.getCanonicalPath());\n } else {\n throw new IOException(\"Could not create directory \" +\n \"[\"+directory.getCanonicalPath()+\"], \" +\n \"make sure you have the proper \" +\n \"permissions to create, read & write \" +\n \"to the file system\");\n }\n }\n // Find if we can write to the record root directory\n if(!directory.canRead())\n throw new IOException(\"Cant read from : \"+directory.getCanonicalPath());\n if(isWriteable) {\n if(!directory.canWrite())\n throw new IOException(\"Cant write to : \"+directory.getCanonicalPath());\n }\n }", "boolean check(Permission permission, DBObject dBObject,\n\t\t\tboolean permissionRequired) throws T2DBException;", "public boolean hasCharacteristicDescription() {\n return characteristicDescriptionBuilder_ != null || characteristicDescription_ != null;\n }", "public interface CharacteristicContext\n{\n\t/** Default value when characteristic is not initialized. */\n\tpublic static final Object UNINITIALIZED = null;\n\n\t/**\n\t * Accesses the complete map of characteristics as name value pairs\n\t * for this context. This method returns a map of currently known\n\t * characteristics. If it is known that a given characteristic exists, it\n\t * has to be present in the map. If the underlying source is remote, this\n\t * method may optimize access to the characteristics, since underlying\n\t * implementations may support grouped data access requests. Primitive\n\t * types must be wrapped in <code>Object</code> wrappers.\n\t *\n\t * @param names array of characteristic names\n\t *\n\t * @return Map a map of characteristics for this context\n\t *\n\t * @exception DataExchangeException because this method communicates with\n\t * the underlying data source, an exception may be thrown if\n\t * the communication fails.\n\t */\n\tpublic Map<String,Object> getCharacteristics(String[] names) throws DataExchangeException;\n\n\t/**\n\t * Returns names of all characteristics for this context. Return\n\t * value will be an array of non-null characteristic names.\n\t *\n\t * @return an array of non-null characteristic names\n\t *\n\t * @throws DataExchangeException if operation fails\n\t */\n\tpublic String[] getCharacteristicNames() throws DataExchangeException;\n\n\t/**\n\t * Returns the value of the characteristic. If the characteristic\n\t * with such name does not exist this method returns <code>null</code>.\n\t *\n\t * @param name the name of the characteristic, may not be <code>null</code>\n\t * or an empty string\n\t *\n\t * @return Object the value of the characteristic or <code>null</code> if\n\t * unknown\n\t *\n\t * @exception DataExchangeException when the query for the characteristic\n\t * value on the data source fails\n\t */\n\tpublic Object getCharacteristic(String name) throws DataExchangeException;\n\n\t/**\n\t * Adds a property change listener. The listeners will be notified\n\t * whenever the value of the characteristic changes, or when a new\n\t * characteristic is added that was not present in the context before.\n\t *\n\t * @param l a listener object\n\t */\n\tpublic void addPropertyChangeListener(PropertyChangeListener l);\n\n\t/**\n\t * Removes a property change listener. The notifications about\n\t * characteristics will no longer be sent.\n\t *\n\t * @param l a listener object\n\t *\n\t * @see #addPropertyChangeListener\n\t */\n\tpublic void removePropertyChangeListener(PropertyChangeListener l);\n\n\t/**\n\t * By contract with JavaBean specifications.\n\t *\n\t * @return array of registered listeners\n\t */\n\tpublic PropertyChangeListener[] getPropertyChangeListeners();\n}", "public boolean hasCharacteristicDescription() {\n return characteristicDescription_ != null;\n }", "public boolean canNotify(@NonNull String serviceUUID,@NonNull String characteristicUUID) {\n BluetoothGattService service = getService(UUID.fromString(serviceUUID));\n if (service == null) {\n return false;\n }\n BluetoothGattCharacteristic characteristic = service.getCharacteristic(UUID.fromString(characteristicUUID));\n if (characteristic == null) {\n return false;\n }\n\n int properties = characteristic.getProperties();\n return (properties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0;\n }", "public void testGetCustomerProperties()\n {\n final int ID_1 = 2;\n final int ID_2 = 3;\n final String NAME_1 = \"Schlüssel ä\";\n final String VALUE_1 = \"Wert 1\";\n final Map dictionary = new HashMap();\n\n DocumentSummaryInformation dsi = PropertySetFactory.newDocumentSummaryInformation();\n CustomProperties cps;\n MutableSection s;\n\n /* A document summary information set stream by default does have custom properties. */\n cps = dsi.getCustomProperties();\n assertEquals(null, cps);\n\n /* Test an empty custom properties set. */\n s = new MutableSection();\n s.setFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID[1]);\n // s.setCodepage(Constants.CP_UNICODE);\n dsi.addSection(s);\n cps = dsi.getCustomProperties();\n assertEquals(0, cps.size());\n\n /* Add a custom property. */\n MutableProperty p = new MutableProperty();\n p.setID(ID_1);\n p.setType(Variant.VT_LPWSTR);\n p.setValue(VALUE_1);\n s.setProperty(p);\n dictionary.put(new Long(ID_1), NAME_1);\n s.setDictionary(dictionary);\n cps = dsi.getCustomProperties();\n assertEquals(1, cps.size());\n assertTrue(cps.isPure());\n\n /* Add another custom property. */\n s.setProperty(ID_2, Variant.VT_LPWSTR, VALUE_1);\n dictionary.put(new Long(ID_2), NAME_1);\n s.setDictionary(dictionary);\n cps = dsi.getCustomProperties();\n assertEquals(1, cps.size());\n assertFalse(cps.isPure());\n }", "boolean canCrit();", "@Override\n\t\tprotected boolean initializeSpecificProperties(Component c, AWTEvent introspectionRequestEvent,\n\t\t\t\tTestEditor testEditor) {\n\t\t\tif (c instanceof CustomComponent) {\n\t\t\t\texpectpedValueOfPropertyToCheck = ((CustomComponent) c).propertyToCheck;\n\t\t\t\tnewValueOfPropertyToChange = ((CustomComponent) c).propertyToChange + 1;\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}", "boolean managePhysicalPropertiesSection(final boolean starting) {\n if (starting) {\n if (physicBlock == null) {\n // this is the first (and unique) physical properties block, we need to allocate the container\n physicBlock = new OrbitPhysicalProperties(metadata.getEpochT0());\n }\n anticipateNext(this::processPhysicalPropertyToken);\n } else {\n anticipateNext(structureProcessor);\n }\n return true;\n }", "private boolean checkPermissions() {\n if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.READ_EXTERNAL_STORAGE)\n != PackageManager.PERMISSION_GRANTED && ContextCompat.checkSelfPermission(this,\n android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {\n return false;\n\n } else {\n return true;\n }\n }", "public static boolean checkReadAllCasesPermission() {\r\n boolean hasReadAllCasesPermission =\r\n Ivy.session()\r\n .getSecurityContext()\r\n .hasPermission(Ivy.request().getApplication().getSecurityDescriptor(),\r\n ch.ivyteam.ivy.security.IPermission.CASE_READ_ALL);\r\n return hasReadAllCasesPermission;\r\n }", "boolean hasGetProperty();", "@Schema(description = \"List of characteristics that the entity can take\")\n\t@Valid\n\tpublic Set<CharacteristicSpecification> getSpecCharacteristic() {\n\t\treturn specCharacteristic;\n\t}", "public void _getDataPointProperties() {\n result = true;\n\n int rows = rowamount.intValue();\n int cols = colamount.intValue();\n XPropertySet props = null;\n\n log.println(\"There are \" + rows + \" rows and \" + cols + \" cols.\");\n\n try {\n for (int i = 0; i < rows; i++)\n for (int j = 0; j < cols; j++) {\n props = oObj.getDataPointProperties(i, j);\n if (props != null) {\n log.println(\"Row \" + i + \" Col \" + j + \" - OK\");\n } else {\n log.println(\"Row \" + i + \" Col \" + j + \" - FAILED\");\n result = false;\n }\n }\n } catch(com.sun.star.lang.IndexOutOfBoundsException e) {\n log.println(\"Exception while get data point properties\");\n e.printStackTrace(log);\n result = false;\n }\n\n tRes.tested(\"getDataPointProperties()\", result);\n }", "public boolean canModify(Object element, String property) {\r\n\t // Allow editing of all values\r\n\t return true;\r\n\t }", "public void checkpermission()\n {\n permissionUtils.check_permission(permissions,\"Need GPS permission for getting your location\",1);\n }", "public boolean checkPermissions(PolicyCredentials credentials, String resource, String action) throws Exception {\n //\n // Set our permissions to null.\n perm = null ;\n //\n // Check if we have a service reference.\n if (null != service)\n {\n perm = service.checkPermissions(credentials,resource,action);\n }\n //\n // Return true if we got a result, and the permissions are valid.\n return (null != perm) ? perm.isValid() : false ;\n }", "protected void checkReceivePermission() throws InterruptedIOException {\n\t/* Check if we have permission to recieve. */\n\tif (!readPermission) {\n\t try {\n\t\tmidletSuite.checkForPermission(Permissions.SMS_RECEIVE,\n\t\t\t\t\t\t\"sms:receive\");\n\t\treadPermission = true;\n\t } catch (InterruptedException ie) {\n\t\tthrow new InterruptedIOException(\"Interrupted while trying \" +\n\t\t\t\t\t\t \"to ask the user permission\");\n\t }\n\t}\n }", "public boolean addCharacteristic(BluetoothGattCharacteristic characteristic) {\n/* 70 */ throw new RuntimeException(\"Stub!\");\n/* */ }", "@Override\r\n\t@Test(groups = {\"function\",\"setting\"} ) \r\n\tpublic boolean checkWiFi() {\n\t\tboolean flag = oTest.checkWiFi();\r\n\t\tAssertion.verifyEquals(flag, true);\r\n\t\treturn false;\r\n\t}", "private void checkProperties(Configuration compositeConfiguration)\n {\n assertTrue(\"Make sure we have loaded our key\", compositeConfiguration\n .getBoolean(\"test.boolean\"));\n assertEquals(\"I'm complex!\", compositeConfiguration\n .getProperty(\"element2.subelement.subsubelement\"));\n assertEquals(\"property in the XMLPropertiesConfiguration\", \"value1\",\n compositeConfiguration.getProperty(\"key1\"));\n }", "public interface ICpMemory extends ICpDeviceProperty {\n\n\tfinal static char READ_ACCESS \t\t= 'r';\n\tfinal static char WRITE_ACCESS\t\t= 'w';\n\tfinal static char EXECUTE_ACCESS\t= 'x';\n\tfinal static char SECURE_ACCESS\t\t= 's';\n\tfinal static char NON_SECURE_ACCESS\t= 'n';\n\tfinal static char CALLABLE_ACCESS\t= 'c';\n\tfinal static char PERIPHERAL_ACCESS\t= 'p';\n\t\n\t/**\n\t * Checks if the memory shall be used for the startup by linker\n\t * @return true if startup memory\n\t */\n\tboolean isStartup();\n\t\n\t/**\n\t * Returns access string corresponding following regular expression pattern: \"[rwxpsnc]+\"\n\t * @return \"access\" attribute value if present or default derived from ID for deprecated elements \n\t */\n\tString getAccess();\n\n\t/**\n\t * Checks if the memory region represents RAM (\"rwx\")\n\t * @return true if RAM\n\t */\n\tboolean isRAM();\n\n\t/**\n\t * Checks if the memory region represents ROM (\"rx\")\n\t * @return true if ROM\n\t */\n\tboolean isROM();\n\n\t\n\t/**\n\t * Checks if memory has specified access\n\t * @param access : one of <code>rwxpsnc</code> characters\n\t * @return true if memory provides specified access\n\t */\n\tboolean isAccess(char access);\n\t\n\t/**\n\t * Checks if memory has read access\n\t * @return true if memory has read access\n\t */\n\tboolean isReadAccess();\n\t\n\t/**\n\t * Checks if memory has write access\n\t * @return true if memory has write access\n\t */\n\tboolean isWriteAccess();\n\n\t/**\n\t * Checks if memory has execute access\n\t * @return true if memory has execute access\n\t */\n\tboolean isExecuteAccess();\n\n\t\n\t/**\n\t * Checks if memory has secure access\n\t * @return true if memory has secure access\n\t */\n\tboolean isSecureAccess();\n\t\n\t/**\n\t * Checks if memory has non-secure access\n\t * @return true if memory has non-secure access\n\t */\n\tboolean isNonSecureAccess();\n\t\n\t/**\n\t * Checks if memory has callable access\n\t * @return true if memory has callable access\n\t */\n\tboolean isCallableAccess();\n\n\t/**\n\t * Checks if memory has peripheral access\n\t * @return true if memory has peripheral access\n\t */\n\tboolean isPeripheralAccess(); \n\n\t\n}", "private boolean checkPermission() {\n\n if ((ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)\n != PackageManager.PERMISSION_GRANTED) &&\n (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)\n != PackageManager.PERMISSION_GRANTED) &&\n (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)\n != PackageManager.PERMISSION_GRANTED) &&\n (ContextCompat.checkSelfPermission(this,\n Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED)\n\n ) {\n\n // Permission is not granted\n return false;\n\n }\n return true;\n }", "boolean hasForRead();", "public void checkReadLock() {\n checkNotDeleted();\n super.checkReadLock();\n }", "private boolean isReadAudioAllowed() {\n int result = ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO);\n\n //If permission is granted returning true\n if (result == PackageManager.PERMISSION_GRANTED)\n return true;\n\n //If permission is not granted returning false\n return false;\n }", "public boolean checkPermission() {\n int cameraPermissionResult = ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.CAMERA);\n int readContactPermissionResult = ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_CONTACTS);\n return cameraPermissionResult == PackageManager.PERMISSION_GRANTED && readContactPermissionResult == PackageManager.PERMISSION_GRANTED;\n }", "boolean isHasPermissions();" ]
[ "0.5968377", "0.5752089", "0.5447013", "0.53850824", "0.5360858", "0.52982384", "0.51900035", "0.51702726", "0.51538193", "0.5151872", "0.50967515", "0.50903213", "0.5057121", "0.5055554", "0.5038001", "0.502795", "0.50054306", "0.49922782", "0.4986627", "0.49220562", "0.4908963", "0.48781955", "0.48657385", "0.4834053", "0.4827098", "0.48255956", "0.4803142", "0.48022154", "0.47952166", "0.47931677", "0.47904047", "0.47832936", "0.47708368", "0.47478166", "0.47214428", "0.47171178", "0.469836", "0.46849743", "0.46807116", "0.46749553", "0.46708184", "0.46402082", "0.4629445", "0.46247193", "0.46036616", "0.45982534", "0.4595929", "0.45940176", "0.4579357", "0.45382118", "0.45225835", "0.45193428", "0.45155782", "0.45126924", "0.4509016", "0.45045292", "0.45003098", "0.4494965", "0.44887742", "0.4487655", "0.44814512", "0.44730633", "0.447289", "0.4465242", "0.44631287", "0.44631287", "0.44606188", "0.44495302", "0.44455183", "0.4439306", "0.4434846", "0.44325218", "0.44273016", "0.4427083", "0.4422114", "0.44177857", "0.44144332", "0.44067666", "0.4403666", "0.4398188", "0.43966934", "0.43945053", "0.43905044", "0.4388184", "0.43860444", "0.43767482", "0.4374302", "0.43730706", "0.4365076", "0.4361972", "0.43619475", "0.43567473", "0.4352928", "0.43450513", "0.43446994", "0.43395016", "0.43338808", "0.43330806", "0.43317288", "0.433001" ]
0.72339666
0
takeBertyCharacteristics checks if the service has the two characteristics expected.
private boolean takeBertyCharacteristics() { Log.v(TAG, String.format("takeBertyCharacteristic called for device %s", getMACAddress())); if (getPIDCharacteristic() != null && getWriterCharacteristic() != null) { Log.d(TAG, "Berty characteristics already found"); return true; } List<BluetoothGattCharacteristic> characteristics = getBertyService().getCharacteristics(); for (BluetoothGattCharacteristic characteristic : characteristics) { if (characteristic.getUuid().equals(GattServer.PID_UUID)) { Log.d(TAG, String.format("PID characteristic found for device %s", getMACAddress())); if (checkCharacteristicProperties(characteristic, BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_WRITE)) { setPIDCharacteristic(characteristic); /*if (!getBluetoothGatt().setCharacteristicNotification(characteristic, true)) { Log.e(TAG, String.format("setCharacteristicNotification failed for device %s", getMACAddress())); setPIDCharacteristic(null); return false; }*/ } } else if (characteristic.getUuid().equals(GattServer.WRITER_UUID)) { Log.d(TAG, String.format("writer characteristic found for device: %s", getMACAddress())); if (checkCharacteristicProperties(characteristic, BluetoothGattCharacteristic.PROPERTY_WRITE)) { setWriterCharacteristic(characteristic); } } } if (getPIDCharacteristic() != null && getWriterCharacteristic() != null) { return true; } Log.e(TAG, String.format("reader/writer characteristics not found for device %s", getMACAddress())); return false; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private boolean takeBertyService() {\n Log.v(TAG, String.format(\"takeBertyService: called for device %s\", getMACAddress()));\n if (getBertyService() != null) {\n Log.d(TAG, String.format(\"Berty service already found for device %s\", getMACAddress()));\n return true;\n }\n\n setBertyService(getBluetoothGatt().getService(GattServer.SERVICE_UUID));\n\n if (getBertyService() == null) {\n Log.i(TAG, String.format(\"Berty service not found for device %s\", getMACAddress()));\n return false;\n }\n\n Log.d(TAG, String.format(\"Berty service found for device %s\", getMACAddress()));\n return true;\n }", "boolean hasCharacteristicDescription();", "private boolean checkCharacteristicProperties(BluetoothGattCharacteristic characteristic,\n int properties) {\n Log.d(TAG, \"checkCharacteristicProperties: device: \" + getMACAddress());\n\n if (characteristic.getProperties() == properties) {\n Log.d(TAG, \"checkCharacteristicProperties() match, device: \" + getMACAddress());\n return true;\n }\n Log.e(TAG, \"checkCharacteristicProperties() doesn't match: \" + characteristic.getProperties() + \" / \" + properties + \", device: \" + getMACAddress());\n return false;\n }", "public void setCharacteristics(String characteristics) {\n this.characteristics = characteristics;\n }", "boolean hasPersonOutputCharacteristics();", "@Override\r\n\t@Test(groups = {\"function\",\"setting\"} ) \r\n\tpublic boolean checkBluetooth() {\n\t\tboolean flag = oTest.checkBluetooth();\r\n\t\tAssertion.verifyEquals(flag, true);\r\n\t\treturn flag;\r\n\t}", "public String getCharacteristics() {\n return characteristics;\n }", "public FighterCharacteristics characteristics();", "boolean hasPersonCharacteristicIds();", "public double[] getCharacteristics() {\r\n\t\treturn characteristics;\r\n\t}", "public List<BluetoothGattCharacteristic> getCharacteristics() {\n/* 112 */ throw new RuntimeException(\"Stub!\");\n/* */ }", "public boolean addCharacteristic(BluetoothGattCharacteristic characteristic) {\n/* 70 */ throw new RuntimeException(\"Stub!\");\n/* */ }", "public int characteristics() {\n/* 1680 */ return this.characteristics;\n/* */ }", "public Map<String,Object> getCharacteristics(String[] names) throws DataExchangeException;", "public boolean hasCharacteristicDescription() {\n return characteristicDescriptionBuilder_ != null || characteristicDescription_ != null;\n }", "public boolean hasPersonOutputCharacteristics() {\n return personOutputCharacteristicsBuilder_ != null || personOutputCharacteristics_ != null;\n }", "boolean hasCaptureProbabilities();", "boolean hasBuyDescribe();", "public int characteristics() {\n/* 1460 */ return this.characteristics;\n/* */ }", "public void SetcharacteristicTest()\r\n\t{\r\n\t\tCharacteristic chara = new Characteristic(\"skill\", 20);\r\n\t\tchara.Setcharacteristic(\"attaque\", 10);\r\n\t\tassertNotSame(chara.getcharacteristicValue(), 20);\r\n\t\tassertNotSame(chara.getcharacteristicName(), \"skill\");\r\n\t\tCharacteristic cha = new Characteristic(\"skill\", 20);\r\n\t\tcha.Setcharacteristic(\"attaque\", 10);\r\n\t\tassertNotSame(cha.getcharacteristicValue(), \"attaque\");\r\n\t\tassertNotSame(cha.getcharacteristicName(), 10);\r\n\t\tCharacteristic charac = new Characteristic(\"skill\", 20);\r\n\t\tcharac.Setcharacteristic(\"attaque\", 10);\r\n\t\tassertSame(charac.getcharacteristicValue(), 10);\r\n\t\tassertSame(charac.getcharacteristicName(), \"attaque\");\r\n\t\t\r\n\t}", "public void checkForBluetooth() {\n if (hasBluetoothSupport()) {\n ensureBluetoothEnabled();\n } else {\n showToast(\"Device does not support BlueTooth\");\n }\n }", "public int characteristics() {\n/* 1570 */ return this.characteristics;\n/* */ }", "public int characteristics() {\n/* 1350 */ return this.characteristics;\n/* */ }", "public boolean hasCharacteristicDescription() {\n return characteristicDescription_ != null;\n }", "private void displayGattServices(List<BluetoothGattService> gattServices) {\n if (gattServices == null) return;\n String uuid = null;\n String unknownServiceString = getResources().getString(R.string.unknown_service);\n String unknownCharaString = getResources().getString(R.string.unknown_characteristic);\n ArrayList<HashMap<String, String>> gattServiceData = new ArrayList<HashMap<String, String>>();\n ArrayList<ArrayList<HashMap<String, String>>> gattCharacteristicData\n = new ArrayList<ArrayList<HashMap<String, String>>>();\n mGattCharacteristics = new ArrayList<ArrayList<BluetoothGattCharacteristic>>();\n\n // final String action = intent.getAction();\n // if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED\n // .equals(action)) {\n // Logger.e(\"Service discovered\");\n // if(mTimer!=null)\n // mTimer.cancel();\n // prepareGattServices(BluetoothLeService.getSupportedGattServices());\n\n /*\n / Changes the MTU size to 512 in case LOLLIPOP and above devices\n */\n // if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {\n // BluetoothLeService.exchangeGattMtu(512);\n // }\n // } //else if (BluetoothLeService.ACTION_GATT_SERVICE_DISCOVERY_UNSUCCESSFUL\n // .equals(action)) {\n // mProgressDialog.dismiss();\n // if(mTimer!=null)\n // mTimer.cancel();\n // showNoServiceDiscoverAlert();\n // }\n // Loops through available GATT Services.\n for (BluetoothGattService gattService : gattServices) {\n HashMap<String, String> currentServiceData = new HashMap<String, String>();\n uuid = gattService.getUuid().toString();\n currentServiceData.put(LIST_NAME,SampleGattAttributes.lookup(uuid, unknownServiceString));\n currentServiceData.put(LIST_UUID, uuid);\n gattServiceData.add(currentServiceData);\n\n ArrayList<HashMap<String, String>> gattCharacteristicGroupData =\n new ArrayList<HashMap<String, String>>();\n List<BluetoothGattCharacteristic> gattCharacteristics =\n gattService.getCharacteristics();\n ArrayList<BluetoothGattCharacteristic> charas =\n new ArrayList<BluetoothGattCharacteristic>();\n\n if (uuid.equals(SampleGattAttributes.SERVER_UART)) {\n for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {\n String uuidchara = gattCharacteristic.getUuid().toString();\n mReadCharacteristic = gattCharacteristic;\n if (uuidchara.equalsIgnoreCase(SampleGattAttributes.SERVER_UART_tx)) {\n Log.e(TAG,\"gatt- \"+gattCharacteristic);\n mNotifyCharacteristic = gattCharacteristic;\n prepareBroadcastDataNotify(mNotifyCharacteristic);\n }\n }\n }\n // Loops through available Characteristics.\n for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {\n charas.add(gattCharacteristic);\n HashMap<String, String> currentCharaData = new HashMap<String, String>();\n uuid = gattCharacteristic.getUuid().toString();\n currentCharaData.put(LIST_NAME, SampleGattAttributes.lookup(uuid, unknownCharaString));\n currentCharaData.put(LIST_UUID, uuid);\n gattCharacteristicGroupData.add(currentCharaData);\n\n }\n mGattCharacteristics.add(charas);\n gattCharacteristicData.add(gattCharacteristicGroupData);\n }\n }", "public boolean addService(BluetoothGattService service) {\n/* 60 */ throw new RuntimeException(\"Stub!\");\n/* */ }", "public boolean hasPersonOutputCharacteristics() {\n return personOutputCharacteristics_ != null;\n }", "private void checkBleSupportAndInitialize() {\n Log.d(TAG, \"checkBleSupportAndInitialize: \");\n // Use this check to determine whether BLE is supported on the device.\n if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {\n Log.d(TAG,\"device_ble_not_supported \");\n Toast.makeText(this, R.string.device_ble_not_supported,Toast.LENGTH_SHORT).show();\n return;\n }\n // Initializes a Blue tooth adapter.\n final BluetoothManager bluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);\n mBluetoothAdapter = bluetoothManager.getAdapter();\n\n if (mBluetoothAdapter == null) {\n // Device does not support Blue tooth\n Log.d(TAG, \"device_ble_not_supported \");\n Toast.makeText(this,R.string.device_ble_not_supported, Toast.LENGTH_SHORT).show();\n return;\n }\n\n //打开蓝牙\n if (!mBluetoothAdapter.isEnabled()) {\n Log.d(TAG, \"open bluetooth \");\n bluetoothUtils.openBluetooth();\n }\n }", "@Override\n\tpublic void create(ConditionalCharacteristicSpecification acs) {\n\n\t}", "boolean hasDeleteCharacteristic();", "boolean hasManufacturer();", "boolean hasAttributes();", "boolean hasAttributes();", "@Test\n\tpublic void should_weapon_with_two_different_attributes_and_start_one_by_one(){\n\t\twhen(random.nextInt(ATTRIBUTE_RANGE))\n\t\t.thenReturn(0)\n\t\t.thenReturn(2)\n\t\t.thenReturn(3)\n\t\t.thenReturn(1)\n\t\t.thenReturn(2)\n\t\t.thenReturn(3)\n\t\t.thenReturn(4);\n\t\tAttribute freeze = new Freeze(\"冰冻\", 2);\n\t\tAttribute fire = new Fire(\"烧伤\", 3);\n\t\tWeapon firePlusFreezeWeapon = new Weapon(\"烈焰寒冰剑\", 5, fire, random);\n\t\tfirePlusFreezeWeapon.addAttribute(freeze);\n\t\tSoldier playerA = new Soldier(\"李四\",5,100,firePlusFreezeWeapon,10);\n\t\tPlayer playerB = new Player(\"张三\", 20, 100);\n\t\tGame game = new Game(playerA, playerB, out);\n\t\tgame.start();\n\t\t\n\t\tinorder.verify(out).println(\"战士李四用烈焰寒冰剑攻击了普通人张三,张三受到10点伤害,张三烧伤了,张三剩余生命:90\");\n\t\tinorder.verify(out).println(\"张三受到2点烧伤伤害,张三剩余生命:88\");\n\t\tinorder.verify(out).println(\"普通人张三攻击了战士李四,李四受到10点伤害,李四剩余生命:90\");\n\t\t\n\t\tinorder.verify(out).println(\"战士李四用烈焰寒冰剑攻击了普通人张三,张三受到10点伤害,张三剩余生命:78\");\n\t\tinorder.verify(out).println(\"张三受到2点烧伤伤害,张三剩余生命:76\");\n\t\tinorder.verify(out).println(\"普通人张三攻击了战士李四,李四受到10点伤害,李四剩余生命:80\");\n\t\t\n\t\tinorder.verify(out).println(\"战士李四用烈焰寒冰剑攻击了普通人张三,张三受到10点伤害,张三剩余生命:66\");\t\t\n\t\tinorder.verify(out).println(\"张三受到2点烧伤伤害,张三剩余生命:64\");\n\t\tinorder.verify(out).println(\"普通人张三攻击了战士李四,李四受到10点伤害,李四剩余生命:70\");\n\t\t\n\t\tinorder.verify(out).println(\"战士李四用烈焰寒冰剑攻击了普通人张三,张三受到10点伤害,张三冻僵了,张三剩余生命:54\");\n\t\tinorder.verify(out).println(\"普通人张三攻击了战士李四,李四受到10点伤害,李四剩余生命:60\");\n\t\t\n\t\tinorder.verify(out).println(\"战士李四用烈焰寒冰剑攻击了普通人张三,张三受到10点伤害,张三剩余生命:44\");\n\t\tinorder.verify(out).println(\"普通人张三攻击了战士李四,李四受到10点伤害,李四剩余生命:50\");\t\t\n\t\t\n\t\tinorder.verify(out).println(\"战士李四用烈焰寒冰剑攻击了普通人张三,张三受到10点伤害,张三剩余生命:34\");\t\t\n\t\tinorder.verify(out).println(\"张三冻得直哆嗦,没有击中李四\");\t\t\n\t\t\n\t\tinorder.verify(out).println(\"战士李四用烈焰寒冰剑攻击了普通人张三,张三受到10点伤害,张三剩余生命:24\");\n\t\tinorder.verify(out).println(\"普通人张三攻击了战士李四,李四受到10点伤害,李四剩余生命:40\");\n\t\t\n\t\tinorder.verify(out).println(\"战士李四用烈焰寒冰剑攻击了普通人张三,张三受到10点伤害,张三剩余生命:14\");\n\t\tinorder.verify(out).println(\"普通人张三攻击了战士李四,李四受到10点伤害,李四剩余生命:30\");\n\t\t\n\t\tinorder.verify(out).println(\"战士李四用烈焰寒冰剑攻击了普通人张三,张三受到10点伤害,张三剩余生命:4\");\n\t\tinorder.verify(out).println(\"普通人张三攻击了战士李四,李四受到10点伤害,李四剩余生命:20\");\n\t\t\n\t\tinorder.verify(out).println(\"战士李四用烈焰寒冰剑攻击了普通人张三,张三受到10点伤害,张三剩余生命:-6\");\n\t\tinorder.verify(out).println(\"张三被打败了\");\n\t}", "boolean hasFeaturesUsed();", "void checkForAccServices();", "boolean getPersonOutputCharacteristicsNull();", "boolean hasDescribe();", "public interface CharacteristicContext\n{\n\t/** Default value when characteristic is not initialized. */\n\tpublic static final Object UNINITIALIZED = null;\n\n\t/**\n\t * Accesses the complete map of characteristics as name value pairs\n\t * for this context. This method returns a map of currently known\n\t * characteristics. If it is known that a given characteristic exists, it\n\t * has to be present in the map. If the underlying source is remote, this\n\t * method may optimize access to the characteristics, since underlying\n\t * implementations may support grouped data access requests. Primitive\n\t * types must be wrapped in <code>Object</code> wrappers.\n\t *\n\t * @param names array of characteristic names\n\t *\n\t * @return Map a map of characteristics for this context\n\t *\n\t * @exception DataExchangeException because this method communicates with\n\t * the underlying data source, an exception may be thrown if\n\t * the communication fails.\n\t */\n\tpublic Map<String,Object> getCharacteristics(String[] names) throws DataExchangeException;\n\n\t/**\n\t * Returns names of all characteristics for this context. Return\n\t * value will be an array of non-null characteristic names.\n\t *\n\t * @return an array of non-null characteristic names\n\t *\n\t * @throws DataExchangeException if operation fails\n\t */\n\tpublic String[] getCharacteristicNames() throws DataExchangeException;\n\n\t/**\n\t * Returns the value of the characteristic. If the characteristic\n\t * with such name does not exist this method returns <code>null</code>.\n\t *\n\t * @param name the name of the characteristic, may not be <code>null</code>\n\t * or an empty string\n\t *\n\t * @return Object the value of the characteristic or <code>null</code> if\n\t * unknown\n\t *\n\t * @exception DataExchangeException when the query for the characteristic\n\t * value on the data source fails\n\t */\n\tpublic Object getCharacteristic(String name) throws DataExchangeException;\n\n\t/**\n\t * Adds a property change listener. The listeners will be notified\n\t * whenever the value of the characteristic changes, or when a new\n\t * characteristic is added that was not present in the context before.\n\t *\n\t * @param l a listener object\n\t */\n\tpublic void addPropertyChangeListener(PropertyChangeListener l);\n\n\t/**\n\t * Removes a property change listener. The notifications about\n\t * characteristics will no longer be sent.\n\t *\n\t * @param l a listener object\n\t *\n\t * @see #addPropertyChangeListener\n\t */\n\tpublic void removePropertyChangeListener(PropertyChangeListener l);\n\n\t/**\n\t * By contract with JavaBean specifications.\n\t *\n\t * @return array of registered listeners\n\t */\n\tpublic PropertyChangeListener[] getPropertyChangeListeners();\n}", "@Then(\"^verify system returns only selected columns$\")\r\n\tpublic void verify_system_returns_only_selected_columns() throws Throwable {\r\n\t\tScenarioName.createNode(new GherkinKeyword(\"Then\"),\"verify system returns only selected columns\");\r\n\t\tList<Data> data = respPayload.getData();\r\n\t\t\r\n\t\tAssert.assertTrue(!data.get(0).getManufacturer().isEmpty());\r\n\t\tSystem.out.println(\"1 st Manufacturer \"+ data.get(0).getManufacturer());\r\n\t\t \r\n\t\t\r\n\t}", "@Override\r\n\t@Test(groups = {\"function\",\"setting\"} ) \r\n\tpublic boolean readServiceInfo() {\n\t\tboolean flag = oTest.readServiceInfo();\r\n\t\tAssertion.verifyEquals(flag, true);\r\n\t\treturn flag;\r\n\t}", "private void displayGattServices(List<BluetoothGattService> gattServices) {\n if (gattServices == null) return;\n String uuid = null;\n String unknownServiceString = getResources().getString(R.string.unknown_service);\n String unknownCharaString = getResources().getString(R.string.unknown_characteristic);\n ArrayList<HashMap<String, String>> gattServiceData = new ArrayList<HashMap<String, String>>();\n ArrayList<ArrayList<HashMap<String, String>>> gattCharacteristicData\n = new ArrayList<ArrayList<HashMap<String, String>>>();\n mGattCharacteristics = new ArrayList<ArrayList<BluetoothGattCharacteristic>>();\n\n // Loops through available GATT Services.\n for (BluetoothGattService gattService : gattServices) {\n HashMap<String, String> currentServiceData = new HashMap<String, String>();\n uuid = gattService.getUuid().toString();\n currentServiceData.put(\n LIST_NAME, SampleGattAttributes.lookup(uuid, unknownServiceString));\n currentServiceData.put(LIST_UUID, uuid);\n gattServiceData.add(currentServiceData);\n\n ArrayList<HashMap<String, String>> gattCharacteristicGroupData =\n new ArrayList<HashMap<String, String>>();\n List<BluetoothGattCharacteristic> gattCharacteristics =\n gattService.getCharacteristics();\n ArrayList<BluetoothGattCharacteristic> charas =\n new ArrayList<BluetoothGattCharacteristic>();\n\n // Loops through available Characteristics.\n for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {\n charas.add(gattCharacteristic);\n HashMap<String, String> currentCharaData = new HashMap<String, String>();\n uuid = gattCharacteristic.getUuid().toString();\n currentCharaData.put(\n LIST_NAME, SampleGattAttributes.lookup(uuid, unknownCharaString));\n currentCharaData.put(LIST_UUID, uuid);\n gattCharacteristicGroupData.add(currentCharaData);\n //custom code\n if(uuid.equals(\"0000ffe1-0000-1000-8000-00805f9b34fb\") && mNotifyCharacteristic == null) {\n mBluetoothLeService.setCharacteristicNotification(gattCharacteristic, true);\n mNotifyCharacteristic = gattCharacteristic;\n }\n }\n mGattCharacteristics.add(charas);\n gattCharacteristicData.add(gattCharacteristicGroupData);\n }\n }", "private void prepareBroadcastDataNotify(BluetoothGatt bluetoothGatt, BluetoothGattCharacteristic characteristic) {\n MyLog.debug(TAG, \"prepareBroadcastDataNotify: \");\n boolean response=false;\n final int charaProp = characteristic.getProperties();\n MyLog.debug(TAG, \"charaProp: \"+charaProp);\n int temp=charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY;\n MyLog.debug(TAG, \"temp: \"+temp);\n if ( temp> 0) {\n response= BluetoothLeService.setCharacteristicNotification(bluetoothGatt,characteristic, true);\n }\n MyLog.debug(TAG, \"response: \"+response);\n\n }", "boolean hasValueCharacteristicId();", "@Override\r\n\t@Test(groups = {\"function\",\"setting\"} ) \r\n\tpublic boolean readDeviceInfo() {\n\t\tboolean flag = oTest.readDeviceInfo();\r\n\t\tAssertion.verifyEquals(flag, true);\r\n\t\treturn flag;\r\n\t}", "public boolean checkBluetooth() {\n if (!mActivity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {\n Toast.makeText(mActivity, R.string.ble_not_supported, Toast.LENGTH_SHORT).show();\n }\n\n // Initializes a Bluetooth adapter. For API level 18 and above, get a reference to\n // BluetoothAdapter through BluetoothManager.\n final BluetoothManager bluetoothManager =\n (BluetoothManager) mActivity.getSystemService(Context.BLUETOOTH_SERVICE);\n mBluetoothAdapter = bluetoothManager.getAdapter();\n\n // Checks if Bluetooth is supported on the device.\n if (mBluetoothAdapter == null) {\n Toast.makeText(mActivity, R.string.error_bluetooth_not_supported, Toast.LENGTH_SHORT).show();\n return false;\n }\n return true;\n }", "@Override\n public void onServicesDiscovered(BluetoothGatt gatt, int status) {\n Log.i(\"onServicesDiscovered\", \"Obtaining device service information ......\");\n if (status == BluetoothGatt.GATT_SUCCESS) {\n try{\n String messages = \"-------------- (\"+Periphery.getAddress()+\")Service Services information : --------------------\\n\";\n List<BluetoothGattService> serviceList = gatt.getServices();\n messages += \"Total:\"+serviceList.size()+\"\\n\";\n for (int i = 0; i < serviceList.size(); i++) {\n BluetoothGattService theService = serviceList.get(i);\n BLEGattServiceList.add(new BLEGattService(theService));\n\n String serviceName = theService.getUuid().toString();\n String msg = \"---- Service UUID:\"+serviceName+\" -----\\n\";\n // Each Service contains multiple features\n List<BluetoothGattCharacteristic> characterList = theService.getCharacteristics();\n msg += \"Characteristic UUID List:\\n\";\n for (int j = 0; j < characterList.size(); j++) {\n BluetoothGattCharacteristic theCharacter = characterList.get(j);\n msg += \"(\"+(j+1)+\"):\"+theCharacter.getUuid()+\"\\n\";\n //msg += \" --> Value:\"+ StringConvertUtil.bytesToHexString(theCharacter.getValue())+\"\\n\";\n }\n msg += \"\\n\\n\";\n messages += msg;\n }\n messages += \"-------------- (\"+Periphery.getAddress()+\")--------------------\\n\";\n Log.i(\"onServicesDiscovered\", messages);\n }catch (Exception ex){\n Log.e(\"onServicesDiscovered\", \"Exception:\" + ex.toString());\n }\n }\n if (_PeripheryBluetoothServiceCallBack!=null){\n _PeripheryBluetoothServiceCallBack.OnServicesed(BLEGattServiceList);\n }\n super.onServicesDiscovered(gatt, status);\n }", "boolean hasBatt();", "public void verifyProductDetailAttribute(String Sku, String totalGemAmount, String MetalType, String height, String width,\r\n\r\n\t\t\tString MetalWeight, String Catagory, String TypeOfProduct, String DiamondShape, String NoOfDiamonds,\r\n\r\n\t\t\tString Collection, String GemstoneType, String GemstoneShape, String NoOfGemstones, String TotalGemWeight,\r\n\r\n\t\t\tString TotalDiamondWeight, Product productItms) {\n\r\n\t\tif (productItms.getTGemAmount() != null && !productItms.getTGemAmount().trim().equals(\"N/A\")) {\r\n\r\n\t\t\tString actualTGemAmount = utility.converPrice(productItms.getTGemAmount());\r\n\r\n\t\t\tif (!(actualTGemAmount.trim().toUpperCase().equals(totalGemAmount.trim().toUpperCase()))) {\r\n\r\n\t\t\t\tfinalResult.put(\"totalGemAmount\", finalResult.get(\"totalGemAmount\") & false);\r\n\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t\telse\r\n\r\n\t\t{\r\n\r\n\t\t\tfinalResult.put(totalGemAmount, finalResult.get(\"totalGemAmount\") & false);\r\n\r\n\t\t\ttotalGemAmount = \"N/A\";\r\n\r\n\t\t}\r\n\r\n\t\t// verification of Metal type\r\n\r\n\t\tif (productItms.getmetalPurity() != null && !productItms.getmetalPurity().trim().equals(\"N/A\")) {\r\n\r\n\t\t\tString actualmetalPurity = productItms.getmetalPurity();\r\n\r\n\t\t\tif (!(actualmetalPurity.trim().toUpperCase().equals(MetalType.trim().toUpperCase()))) {\r\n\r\n\t\t\t\tfinalResult.put(\"MetalType\", finalResult.get(\"MetalType\") & false);\r\n\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t\telse\r\n\r\n\t\t{\r\n\r\n\t\t\tfinalResult.put(MetalType, finalResult.get(\"MetalType\") & false);\r\n\r\n\t\t\tMetalType = \"N/A\";\r\n\r\n\t\t}\r\n\r\n\t\t// Verification of height of the product page\r\n\r\n\t\tif (productItms.getHeight() != null && !productItms.getHeight().trim().equals(\"N/A\")) {\r\n\r\n\t\t\tString actualHeight = utility.convertDecimal(productItms.getHeight());\r\n\r\n\t\t\tString expectedHeight = utility.convertDecimal(height);\r\n\r\n\t\t\tif (!(actualHeight.trim().toUpperCase().equals(expectedHeight.trim().toUpperCase()))) {\r\n\r\n\t\t\t\tfinalResult.put(\"height\", finalResult.get(\"height\") & false);\r\n\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t\telse if (height == \"0\")\r\n\r\n\t\t{\r\n\r\n\t\t\theight = \"N/A\";\r\n\r\n\t\t\tfinalResult.put(height, finalResult.get(\"height\") & false);\r\n\r\n\t\t}\r\n\r\n\t\t// verification of width of the product page\r\n\r\n\t\tif (productItms.getWidth() != null && !productItms.getWidth().trim().equals(\"N/A\")) {\r\n\r\n\t\t\tString actualWidth = utility.convertDecimal(productItms.getWidth());\r\n\r\n\t\t\tString expectedWidth = utility.convertDecimal(width);\r\n\r\n\t\t\tif (!(actualWidth.trim().toUpperCase().equals(expectedWidth.trim().toUpperCase()))) {\r\n\r\n\t\t\t\tfinalResult.put(\"width\", finalResult.get(\"width\") & false);\r\n\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t\telse if (width == \"0\")\r\n\r\n\t\t{\r\n\r\n\t\t\tfinalResult.put(\"width\", finalResult.get(\"width\") & false);\r\n\r\n\t\t\twidth = \"N/A\";\r\n\r\n\t\t}\r\n\r\n\t\t// verification of gold weight\r\n\r\n if((Sku.contains(\"RG\")||Sku.contains(\"BR\")))\r\n {\r\n MetalWeight=\"N/A\";\r\n \r\n }\r\n else {\r\n \r\n if(productItms.getGoldWeight() != null && !productItms.getGoldWeight().trim().equals(\"N/A\")){\r\n\r\n\r\n\t\t\tString actualGoldWeight = utility.convertDecimal(productItms.getGoldWeight().split(\" \")[0].toString());\r\n\r\n\t\t\tString expectedGoldWeight = utility.convertDecimal(MetalWeight);\r\n\r\n\t\t\tif (!(actualGoldWeight.trim().toUpperCase().equals(expectedGoldWeight.trim().toUpperCase()))) {\r\n\r\n\t\t\t\tfinalResult.put(\"MetalWeight\", finalResult.get(\"MetalWeight\") & false);\r\n\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t\telse\r\n\r\n\t\t{\r\n\r\n\t\t\tfinalResult.put(\"MetalWeight\", finalResult.get(\"MetalWeight\") & false);\r\n\r\n\t\t\tMetalWeight = \"N/A\";\r\n\r\n\t\t}\r\n\r\n\t\t// verification of Design Type\r\n\r\n\t\tif (productItms.getDesignType() != null && !productItms.getDesignType().trim().equals(\"N/A\")) {\r\n\r\n\t\t\tString actualDesignType = productItms.getDesignType();\r\n\r\n\t\t\tif (!(actualDesignType.trim().toUpperCase().equals(Catagory.trim().toUpperCase()))) {\r\n\r\n\t\t\t\tfinalResult.put(\"Catagory\", finalResult.get(\"Catagory\") & false);\r\n\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t\telse\r\n\r\n\t\t{\r\n\r\n\t\t\tfinalResult.put(\"Catagory\", finalResult.get(\"Catagory\") & false);\r\n\r\n\t\t\tCatagory = \"N/A\";\r\n\r\n\t\t}\r\n\r\n\t\t// Verification of style of the product in Product Page. String\r\n\r\n\t\tif (productItms.getstyle() != null && !productItms.getstyle().trim().equals(\"N/A\")) {\r\n\r\n\t\t\tif (!(utility.matchTwoString(productItms.getstyle(), TypeOfProduct)))\r\n\r\n\t\t\t\tfinalResult.put(\"TypeOfProduct\", finalResult.get(\"TypeOfProduct\") & false);\r\n\r\n\t\t}\r\n\r\n\t\telse\r\n\r\n\t\t{\r\n\r\n\t\t\tfinalResult.put(\"TypeOfProduct\", finalResult.get(\"TypeOfProduct\") & false);\r\n\r\n\t\t\tTypeOfProduct = \"N/A\";\r\n\r\n\t\t}\r\n\r\n\t\t// verification of Diamond shape\r\n\r\n\t\tif (productItms.getDshape() != null && !productItms.getDshape().trim().equals(\"N/A\")) {\r\n\r\n\t\t\tif (!(utility.matchTwoString(productItms.getDshape(), DiamondShape)))\r\n\r\n\t\t\t\tfinalResult.put(\"DiamondShape\", finalResult.get(\"DiamondShape\") & false);\r\n\r\n\t\t}\r\n\r\n\t\telse\r\n\r\n\t\t{\r\n\r\n\t\t\tfinalResult.put(\"DiamondShape\", finalResult.get(\"TypeOfProduct\") & false);\r\n\r\n\t\t\tDiamondShape = \"N/A\";\r\n\r\n\t\t}\r\n\r\n\t\t// verification of Total number of Diamonds\r\n\r\n\t\tString actualTotalnoDiamonds = productItms.getTotalnoDiamonds();\r\n\r\n\t\tif (!(actualTotalnoDiamonds.trim().toUpperCase().equals(NoOfDiamonds.trim().toUpperCase()))) {\r\n\r\n\t\t\tfinalResult.put(\"NoOfDiamonds\", finalResult.get(\"NoOfDiamonds\") & false);\r\n\r\n\t\t}\r\n\r\n\t\t// verification of Diamond total Weight\r\n\r\n\t\tString actualDtotalWeight = utility.convertDecimal(productItms.getDtotalWeight().split(\"ct\")[0].toString());\r\n\r\n\t\tString expetedDtotalWeight1 = utility.convertDecimal(TotalDiamondWeight.trim());\r\n\r\n\t\tif (!(actualDtotalWeight.trim().toUpperCase().equals(expetedDtotalWeight1.trim().toUpperCase()))) {\r\n\r\n\t\t\tfinalResult.put(\"TotalDiamondWeight\", finalResult.get(\"TotalDiamondWeight\") & false);\r\n\r\n\t\t}\r\n\r\n\t\t// verification of Collections\r\n\r\n\t\tif (!(utility.matchTwoString(productItms.getCollections(), Collection)))\r\n\r\n\t\t\tfinalResult.put(\"Collection\", finalResult.get(\"Collection\") & false);\r\n\r\n\t\t// verification of Gemstone Type\r\n\r\n\t\tif (GemstoneType.length() > 0)\r\n\r\n\t\t\tif (!(utility.matchTwoString(productItms.getGemType(), GemstoneType)))\r\n\r\n\t\t\t\tfinalResult.put(\"GemstoneType\", finalResult.get(\"GemstoneType\") & false);\r\n\r\n\t\t// verification of Gemstone shape\r\n\r\n\t\tif (GemstoneShape.length() > 0)\r\n\r\n\t\t\tif (!(utility.matchTwoString(productItms.getGemShape(), GemstoneShape)))\r\n\r\n\t\t\t\tfinalResult.put(\"GemstoneShape\", finalResult.get(\"GemstoneShape\") & false);\r\n\r\n\t\t// verification of Number of Gemstones\r\n\r\n\t\tif (!(NoOfGemstones.equals(\"0\"))) {\r\n\r\n\t\t\tString actualTotalNoGem = productItms.getTotalNoGem();\r\n\r\n\t\t\tif (!(actualTotalNoGem.trim().toUpperCase().equals(NoOfGemstones.trim().toUpperCase()))) {\r\n\r\n\t\t\t\tfinalResult.put(\"NoOfGemstones\", finalResult.get(\"NoOfGemstones\") & false);\r\n\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t\t// verification of Total Gemstone weight\r\n\r\n\t\tif (!(TotalGemWeight.equals(\"0\"))) {\r\n\r\n\t\t\tString actualTotalGemWeight = utility\r\n\r\n\t\t\t\t\t.convertDecimal(productItms.getTotalGemWeight().split(\"ct\")[0].toString());\r\n\r\n\t\t\tString expectedTotalGemWeight = utility.convertDecimal(TotalGemWeight);\r\n\r\n\t\t\tif (!(actualTotalGemWeight.trim().toUpperCase().equals(expectedTotalGemWeight.trim().toUpperCase()))) {\r\n\r\n\t\t\t\tfinalResult.put(\"TotalGemWeight\", finalResult.get(\"TotalGemWeight\") & false);\r\n\r\n\t\t\t}\r\n\t\t}\r\n }\r\n\r\n\t\t\r\n\r\n\t}", "public boolean hasPersonCharacteristicIds() {\n return personCharacteristicIds_ != null;\n }", "protected boolean enoughAttributesAvailableToProcess(final String principal, final Map<String, Object> principalAttributes) {\n if (!enoughRequiredAttributesAvailableToProcess(principalAttributes, this.requiredAttributes)) {\n return false;\n }\n if (principalAttributes.size() < this.rejectedAttributes.size()) {\n LOGGER.debug(\"The size of the principal attributes that are [{}] does not match defined rejected attributes, \"\n + \"which means the principal is not carrying enough data to grant authorization\", principalAttributes);\n return false;\n }\n return true;\n }", "@Test\n public void determine_provider_capabilities() {\n Provider bouncyCastleProvider = Security.getProvider(\"BC\");\n assertThat(bouncyCastleProvider, is(notNullValue()));\n /**\n * Get the KeySet where the provider keep a list of it's\n * capabilities\n */\n Iterator<Object> capabilitiesIterator = bouncyCastleProvider.keySet().iterator();\n while(capabilitiesIterator.hasNext()){\n String capability = (String) capabilitiesIterator.next();\n\n if(capability.startsWith(\"Alg.Alias.\")) {\n capability = capability.substring(\"Alg.Alias.\".length());\n }\n\n String factoryClass = capability.substring(0, capability.indexOf(\".\"));\n String name = capability.substring(factoryClass.length() + 1);\n\n assertThat(factoryClass, is(not(isEmptyOrNullString())));\n assertThat(name, is(not(isEmptyOrNullString())));\n\n System.out.println(String.format(\"%s : %s\", factoryClass, name));\n }\n }", "private void displayGattServices(List<BluetoothGattService> gattServices) {\n\n if (gattServices == null) return;\n String uuid = null;\n String unknownServiceString = getResources().getString(R.string.unknown_service);\n String unknownCharaString = getResources().getString(R.string.unknown_characteristic);\n ArrayList<HashMap<String, String>> gattServiceData = new ArrayList<HashMap<String, String>>();\n ArrayList<ArrayList<HashMap<String, String>>> gattCharacteristicData\n = new ArrayList<ArrayList<HashMap<String, String>>>();\n mGattCharacteristics = new ArrayList<ArrayList<BluetoothGattCharacteristic>>();\n\n // Loops through available GATT Services.\n for (BluetoothGattService gattService : gattServices) {\n HashMap<String, String> currentServiceData = new HashMap<String, String>();\n uuid = gattService.getUuid().toString();\n currentServiceData.put(\n LIST_NAME, SampleGattAttributes.lookup(uuid, unknownServiceString));\n currentServiceData.put(LIST_UUID, uuid);\n gattServiceData.add(currentServiceData);\n\n ArrayList<HashMap<String, String>> gattCharacteristicGroupData =\n new ArrayList<HashMap<String, String>>();\n List<BluetoothGattCharacteristic> gattCharacteristics =\n gattService.getCharacteristics();\n ArrayList<BluetoothGattCharacteristic> charas =\n new ArrayList<BluetoothGattCharacteristic>();\n\n // Loops through available Characteristics.\n for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {\n charas.add(gattCharacteristic);\n HashMap<String, String> currentCharaData = new HashMap<String, String>();\n uuid = gattCharacteristic.getUuid().toString();\n currentCharaData.put(\n LIST_NAME, SampleGattAttributes.lookup(uuid, unknownCharaString));\n currentCharaData.put(LIST_UUID, uuid);\n gattCharacteristicGroupData.add(currentCharaData);\n }\n mGattCharacteristics.add(charas);\n gattCharacteristicData.add(gattCharacteristicGroupData);\n }\n System.out.println(\"main device UUID = \" + uuid);\n\n }", "private Boolean isDeviceYouWant(BleManager.DiscoveryListener.DiscoveryEvent event) {\n String name = event.device().getName_native();\n if (name.toLowerCase().startsWith(\"polar\")) {\n Log.v(TAG, event.device().getName_native());\n return true;\n }\n return false;\n\n// // Test with prototype BLE device, same repro.\n// byte[] b = event.device().getScanRecord();\n// if (null == b) {\n// return false;\n// }\n// if (b.length < 22) {\n// return false;\n// }\n//\n// byte[] kCompanyIdentifier = new byte[] {(byte)0x01, (byte)0x02, (byte)0x03};\n// byte[] companyIdentifier = new byte[] {b[19], b[20], b[21]};\n// if (Arrays.equals(kCompanyIdentifier, companyIdentifier)){\n// return true;\n// }\n// return false;\n }", "public void setServiceCompleteness(ServiceCompleteness completeness);", "void checkConsumption()\n {\n assertEquals(\"Consumption doesn't match\", keyEventPair.getKey().isConsumed(), keyEventPair.getValue().isConsumed());\n }", "private boolean getWSInformationFromUDDI(ComponentServiceVO service){\n\t\tWSDLService wsdlService = uddi.getInquiry().getWSDLServiceByKey(service.getUddiWsdl());\n\t\tif(wsdlService != null){\n\t\t\tlogger.debug(\"WSDLService -> \" + wsdlService.getName());\n\t\t\tMap<String, String> wsdlValues = getWSInformationFromWSDL(wsdlService.getWsdl(), service.getPortTypeName(), service.getMethodName());\n\t\t\tsetWsdlValues(wsdlValues, service);\n\t\t\treturn !wsdlValues.isEmpty();\n\t\t}else{\n\t\t\tlogger.debug(\"No se pudo cargar la informaci\\u00F3n del servicio [ {0} ] vía UDDI - WSRR\", service.getDescription());\n\t\t}\n\t\treturn false;\n\t}", "public boolean canWrite(@NonNull String serviceUUID,@NonNull String characteristicUUID) {\n BluetoothGattService service = getService(UUID.fromString(serviceUUID));\n if (service == null) {\n return false;\n }\n BluetoothGattCharacteristic characteristic = service.getCharacteristic(UUID.fromString(characteristicUUID));\n if (characteristic == null) {\n return false;\n }\n\n int properties = characteristic.getProperties();\n return (properties & BluetoothGattCharacteristic.PROPERTY_WRITE) != 0;\n }", "private void prepareBroadcastDataNotify(BluetoothGattCharacteristic characteristic) {\n MyLog.debug(TAG, \"prepareBroadcastDataNotify: \");\n boolean response=false;\n final int charaProp = characteristic.getProperties();\n MyLog.debug(TAG, \"charaProp: \"+charaProp);\n int temp=charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY;\n MyLog.debug(TAG, \"temp: \"+temp);\n if ( temp> 0) {\n response= BluetoothLeService.setCharacteristicNotification(characteristic, true);\n }\n MyLog.debug(TAG, \"response: \"+response);\n\n }", "private boolean getWSInformationFromUDDI(ServiceVO service){\n\t\tWSDLService wsdlService = uddi.getInquiry().getWSDLServiceByKey(service.getUddiWsdl());\n\t\tif(wsdlService != null){\n\t\t\tlogger.debug(\"WSDLService -> \" + wsdlService.getName());\n\t\t\tMap<String, String> wsdlValues = getWSInformationFromWSDL(wsdlService.getWsdl(), service.getPortTypeName(), service.getMethodName());\n\t\t\tsetWsdlValues(wsdlValues, service);\n\t\t\treturn !wsdlValues.isEmpty();\n\t\t}else{\n\t\t\tlogger.debug(\"No se pudo cargar la informaci\\u00F3n del servicio [ {0} ] vía UDDI - WSRR\", service.getDescription());\n\t\t}\n\t\treturn false;\n\t}", "public boolean hasPersonCharacteristicIds() {\n return personCharacteristicIdsBuilder_ != null || personCharacteristicIds_ != null;\n }", "@Override\n public Set<Characteristics> characteristics() {\n return EnumSet.of(Characteristics.IDENTITY_FINISH, Characteristics.UNORDERED);\n }", "io.dstore.values.StringValue getPersonOutputCharacteristics();", "@Then(\"the product has following attributes:\")\n public void the_product_has_following_attributes(List<String> productAttributes) {\n boolean isEverythingOk = false;\n try{\n productPage.getProductAttributes();\n isEverythingOk = true;\n }catch(Exception e){\n //ignore\n }\n Assert.assertTrue(isEverythingOk);\n\n }", "boolean has(String capability);", "private boolean BluetoothAvailable()\n {\n if (BT == null)\n return false;\n else\n return true;\n }", "public boolean canSignedWrite(@NonNull String serviceUUID,@NonNull String characteristicUUID) {\n BluetoothGattService service = getService(UUID.fromString(serviceUUID));\n if (service == null) {\n return false;\n }\n BluetoothGattCharacteristic characteristic = service.getCharacteristic(UUID.fromString(characteristicUUID));\n if (characteristic == null) {\n return false;\n }\n\n int properties = characteristic.getProperties();\n return (properties & BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE) != 0;\n }", "public boolean hasMASCAndSuperCharger() {\n boolean hasMASC = false;\n boolean hasSuperCharger = false;\n for (Mounted m : getEquipment()) {\n if (!m.isInoperable() && (m.getType() instanceof MiscType) && m.getType().hasFlag(MiscType.F_MASC) && m.getType().hasSubType(MiscType.S_SUPERCHARGER)) {\n hasSuperCharger = true;\n }\n if (!m.isInoperable() && (m.getType() instanceof MiscType) && m.getType().hasFlag(MiscType.F_MASC) && !m.getType().hasSubType(MiscType.S_SUPERCHARGER)) {\n hasMASC = true;\n }\n }\n return hasMASC && hasSuperCharger;\n }", "public boolean HasGotSensorCaps()\n {\n PackageManager pm = context.getPackageManager();\n\n // Require at least Android KitKat\n\n int currentApiVersion = Build.VERSION.SDK_INT;\n\n // Check that the device supports the step counter and detector sensors\n\n return currentApiVersion >= 19\n && pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_STEP_COUNTER)\n && pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_STEP_DETECTOR)\n && pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER);\n }", "protected void enableActionCharacteristics()\n {\n Action action = new Action(\"Characteristics\");\n action.addOutputParameter(new ParameterRelated(\"VolumeMax\", iPropertyVolumeMax));\n action.addOutputParameter(new ParameterRelated(\"VolumeUnity\", iPropertyVolumeUnity));\n action.addOutputParameter(new ParameterRelated(\"VolumeSteps\", iPropertyVolumeSteps));\n action.addOutputParameter(new ParameterRelated(\"VolumeMilliDbPerStep\", iPropertyVolumeMilliDbPerStep));\n action.addOutputParameter(new ParameterRelated(\"BalanceMax\", iPropertyBalanceMax));\n action.addOutputParameter(new ParameterRelated(\"FadeMax\", iPropertyFadeMax));\n iDelegateCharacteristics = new DoCharacteristics();\n enableAction(action, iDelegateCharacteristics);\n }", "public boolean canRead(@NonNull String serviceUUID,@NonNull String characteristicUUID) {\n BluetoothGattService service = getService(UUID.fromString(serviceUUID));\n if (service == null) {\n return false;\n }\n BluetoothGattCharacteristic characteristic = service.getCharacteristic(UUID.fromString(characteristicUUID));\n if (characteristic == null) {\n return false;\n }\n\n int properties = characteristic.getProperties();\n return (properties & BluetoothGattCharacteristic.PROPERTY_READ) != 0;\n }", "public void initializeComponentCharacteristics() {\n super.initializeComponentCharacteristics();\n }", "public void initializeComponentCharacteristics() {\n super.initializeComponentCharacteristics();\n }", "@Test\n public void shouldMakeCoffeeWhenShotsAreAvailable(){\n given(supplyService.isCoffeeShotAvailable(EXPRESSO)).willReturn(true);\n //When coffee is order\n Boolean orderStatus=kitchenService.makeCoffee(EXPRESSO);\n //Then Kitchen should make coffee\n assertThat(orderStatus, is(true));\n verify(supplyService,times(1)).isCoffeeShotAvailable(EXPRESSO);\n\n }", "private boolean checkBatteryLevelOK() {\n return true;\n }", "@Test\n @SmallTest\n public void tesUiccCartdInfoSanity() {\n assertEquals(0, mUicccard.getNumApplications());\n assertNull(mUicccard.getCardState());\n assertNull(mUicccard.getUniversalPinState());\n assertNull(mUicccard.getOperatorBrandOverride());\n /* CarrierPrivilegeRule equals null, return true */\n assertTrue(mUicccard.areCarrierPriviligeRulesLoaded());\n for (IccCardApplicationStatus.AppType mAppType :\n IccCardApplicationStatus.AppType.values()) {\n assertFalse(mUicccard.isApplicationOnIcc(mAppType));\n }\n }", "public boolean canGrabWeapon(CardWeapon cw){\n List<Color> priceTmp;\n if(cw.getPrice().size()>1) {\n priceTmp = new ArrayList<>(cw.getPrice().subList(1, cw.getPrice().size()));\n return controlPayment(priceTmp);\n }\n else\n return true;\n }", "@Schema(description = \"List of characteristics that the entity can take\")\n\t@Valid\n\tpublic Set<CharacteristicSpecification> getSpecCharacteristic() {\n\t\treturn specCharacteristic;\n\t}", "public boolean hasBoth() {\n if (this.hasCard == true & this.hasCash == true) { return true; } else { return false; }\n }", "boolean hasBillingSetup();", "private void validateBleSupport() {\n if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {\n Snackbar.make(txtStatus, \"No LE Support.\", Snackbar.LENGTH_LONG).show();\n } else {\n\n /*\n * We need to enforce that Bluetooth is first enabled, and take the\n * user to settings to enable it if they have not done so.\n */\n BluetoothAdapter mBluetoothAdapter = BluetoothAdapter\n .getDefaultAdapter();\n\n if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {\n Log.d(TAG, \"onResume: Bluetooth is disabled\");\n //Bluetooth is disabled, request enabling it\n Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);\n startActivity(enableBtIntent);\n }\n }\n\n }", "boolean isSetPurpose();", "io.dstore.values.StringValueOrBuilder getPersonOutputCharacteristicsOrBuilder();", "@Override\n public void onConnectionStateChange(BluetoothGatt gatt, int status,\n int newState) {\n Log.i(\"onConnectionStateChange\", \"The connection status has changed. status:\" + status + \" newState:\" + newState + \"\");\n try {\n if(status == BluetoothGatt.GATT_SUCCESS) {\n switch (newState) {\n // Has been connected to the device\n case BluetoothProfile.STATE_CONNECTED:\n Log.i(\"onConnectionStateChange\", \"Has been connected to the device\");\n if(_ConnectionStatus == ConnectionStatus.Connecting) {\n _ConnectionStatus = ConnectionStatus.Connected;\n try {\n if (_PeripheryBluetoothServiceCallBack != null)\n _PeripheryBluetoothServiceCallBack.OnConnected();\n if (gatt.getDevice().getBondState() == BluetoothDevice.BOND_BONDED){\n //Url : https://github.com/NordicSemiconductor/Android-DFU-Library/blob/release/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java\n Log.i(\"onConnectionStateChange\",\"Waiting 1600 ms for a possible Service Changed indication...\");\n // Connection successfully sleep 1600ms, the connection success rate will increase\n Thread.sleep(1600);\n }\n } catch (Exception e){}\n // Discover service\n gatt.discoverServices();\n }\n break;\n // The connection has been disconnected\n case BluetoothProfile.STATE_DISCONNECTED:\n Log.i(\"onConnectionStateChange\", \"The connection has been disconnected\");\n if(_ConnectionStatus == ConnectionStatus.Connected) {\n if (_PeripheryBluetoothServiceCallBack != null)\n _PeripheryBluetoothServiceCallBack.OnDisConnected();\n }\n Close();\n _ConnectionStatus = ConnectionStatus.DisConnected;\n break;\n /*case BluetoothProfile.STATE_CONNECTING:\n Log.i(\"onConnectionStateChange\", \"Connecting ...\");\n _ConnectionStatus = ConnectionStatus.Connecting;\n break;\n case BluetoothProfile.STATE_DISCONNECTING:\n Log.i(\"onConnectionStateChange\", \"Disconnecting ...\");\n _ConnectionStatus = ConnectionStatus.DisConnecting;\n break;*/\n default:\n Log.e(\"onConnectionStateChange\", \"newState:\" + newState);\n break;\n }\n }else {\n Log.i(\"onConnectionStateChange\", \"GATT error\");\n Close();\n if(_ConnectionStatus == ConnectionStatus.Connecting\n && _Timeout - (new Date().getTime() - _ConnectStartTime.getTime()) > 0) {\n Log.i(\"Connect\", \"Gatt Error! Try to reconnect (\"+_ConnectIndex+\")...\");\n _ConnectionStatus = ConnectionStatus.DisConnected;\n Connect(); // Connect\n }else {\n _ConnectionStatus = ConnectionStatus.DisConnected;\n if (_PeripheryBluetoothServiceCallBack != null)\n _PeripheryBluetoothServiceCallBack.OnDisConnected();\n }\n }\n }catch (Exception ex){\n Log.e(\"onConnectionStateChange\", ex.toString());\n }\n super.onConnectionStateChange(gatt, status, newState);\n }", "private boolean hasBluetoothSupport() {\n mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();\n return (mBluetoothAdapter != null);\n }", "boolean hasSearchNodeCharacteristicIds();", "boolean containsAttributes(java.lang.String key);", "@Test\n\t public void testwith3KgAnd2Km(){\n\t\t robot = new Robot(3, 2);\n\t\t Assert.assertEquals(54.0, robot.calculateRemainingBattery(),0);\n\t }", "boolean hasStrength();", "@Test\n public void shouldMakeCoffeeWhenShotsAreNotAvailable(){\n given(supplyService.isCoffeeShotAvailable(EXPRESSO)).willReturn(false);\n //When coffee is order\n Boolean orderStatus=kitchenService.makeCoffee(EXPRESSO);\n //Then Kitchen should make coffee\n assertThat(orderStatus, is(false));\n\n }", "@Test\n public void requireKeysForAttributes() {\n Set<Attribute> attributes = EnumSet.copyOf(Arrays.asList(Attribute.values()));\n Set<Attribute> implementedAttributes = Arrays.stream(AttributeManager.Key.values())\n .map(AttributeManager.Key::getAttribute)\n .collect(() -> EnumSet.noneOf(Attribute.class), AbstractCollection::add, AbstractCollection::addAll);\n\n attributes.removeAll(implementedAttributes);\n\n if (!attributes.isEmpty()) {\n throw new RuntimeException(\"Some Attributes are not supported by glowstone: \" + attributes);\n }\n }", "public boolean isBusted() {\n\t\tif (hand.checkHandValue() > 21) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}", "@Override\n public void checkBluetoothInteface() {\n if (!isConnected) {\n checkForBluetooth();\n }\n }", "public void motorSafetyCheck() {\r\n if (leftMotor_0.getMotorType() == MotorType.kBrushed\r\n || leftMotor_1.getMotorType() == MotorType.kBrushed\r\n || leftMotor_2.getMotorType() == MotorType.kBrushed\r\n || rightMotor_0.getMotorType() == MotorType.kBrushed\r\n || rightMotor_1.getMotorType() == MotorType.kBrushed\r\n || rightMotor_2.getMotorType() == MotorType.kBrushed) {\r\n System.out.println(\"Brushed motor selected\");\r\n System.exit(0);\r\n }\r\n }", "boolean hasCustomFeatures();", "public boolean canWriteNoResponse(@NonNull String serviceUUID,@NonNull String characteristicUUID) {\n BluetoothGattService service = getService(UUID.fromString(serviceUUID));\n if (service == null) {\n return false;\n }\n BluetoothGattCharacteristic characteristic = service.getCharacteristic(UUID.fromString(characteristicUUID));\n if (characteristic == null) {\n return false;\n }\n\n int properties = characteristic.getProperties();\n return (properties & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) != 0;\n }", "boolean hasB20();", "private boolean checkSetOfFeatures() {\n\t\t\n\t\tif ((sentimentRelatedFeatures.isSelected() && numberOfSentimentRelatedFeatures==0) ||\n\t\t\t(punctuationFeatures.isSelected() && numberOfPunctuationFeatures==0) ||\n\t\t\t(stylisticFeatures.isSelected() && numberOfStylisticFeatures==0) ||\n\t\t\t(semanticFeatures.isSelected() && numberOfSemanticFeatures==0) ||\n\t\t\t(unigramFeatures.isSelected() && numberOfUnigramFeatures==0) ||\n\t\t\t(topWordsFeatures.isSelected() && numberOfTopWordsFeatures==0) ||\n\t\t\t(patternFeatures.isSelected() && numberOfPatternFeatures==0))\n\t\t\t\n\t\t\t{\n\t\t\tboolean test = ConfirmBox.display(\"Attention\", \"You have chosen to use one or more set(s) of features, however you have not set the corresponding parameters yet. Are you sure you want to continue?\");\n\t\t\tif (test==false) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif ((!sentimentRelatedFeatures.isSelected() && numberOfSentimentRelatedFeatures!=0) ||\n\t\t\t(!punctuationFeatures.isSelected() && numberOfPunctuationFeatures!=0) ||\n\t\t\t(!stylisticFeatures.isSelected() && numberOfStylisticFeatures!=0) ||\n\t\t\t(!semanticFeatures.isSelected() && numberOfSemanticFeatures!=0) ||\n\t\t\t(!unigramFeatures.isSelected() && numberOfUnigramFeatures!=0) ||\n\t\t\t(!topWordsFeatures.isSelected() && numberOfTopWordsFeatures!=0) ||\n\t\t\t(!patternFeatures.isSelected() && numberOfPatternFeatures!=0))\n\t\t\t\t\n\t\t\t\t{\n\t\t\t\tboolean test = ConfirmBox.display(\"Attention\", \"You have customized one or more set(s) of features, however you have not selected this (these) set(s) to be extracted. Are you sure you want to continue?\");\n\t\t\t\tif (test==false) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\treturn true;\n\t\t\n\t}", "public static boolean shouldSwichCapabilityForCalls(Context context,\n PhoneAccountHandle handle) {\n boolean isCdmaCardForTarget = false;\n boolean isGsmCardForMainCapability = false;\n int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;\n if (context != null) {\n subId = TelephonyUtils.phoneAccountHandleTosubscriptionId(context, handle);\n }\n if (SubscriptionManager.isValidSubscriptionId(subId)\n && !FeatureOption.MTK_C2K_SLOT2_SUPPORT\n && (!FeatureOption.MTK_DISABLE_CAPABILITY_SWITCH)) {\n int mainCapabilitySlotId = TelephonyUtils.getMainCapabilitySlotId(context);\n isGsmCardForMainCapability =\n SvlteUiccUtils.getInstance().getSimType(mainCapabilitySlotId)\n == SvlteUiccUtils.SIM_TYPE_GSM;\n int targetCallsSlotId = SubscriptionManager.getSlotId(subId);\n isCdmaCardForTarget = SvlteUiccUtils.getInstance().getSimType(targetCallsSlotId)\n == SvlteUiccUtils.SIM_TYPE_CDMA;\n }\n Log.d(TAG, \"isCdmaCardForTarget: \" + isCdmaCardForTarget\n + \" isGsmCardForMainCapability: \" + isGsmCardForMainCapability\n + \" sim switch is support: \" + FeatureOption.MTK_DISABLE_CAPABILITY_SWITCH);\n return isCdmaCardForTarget && isGsmCardForMainCapability;\n }", "@Override\n public Set<Characteristics> characteristics() {\n return EnumSet.of(Characteristics.CONCURRENT);\n }" ]
[ "0.61641985", "0.5949412", "0.590381", "0.5808158", "0.56377363", "0.5611758", "0.5606304", "0.5526411", "0.5443121", "0.5422674", "0.53489333", "0.50963604", "0.5002293", "0.5000041", "0.49762863", "0.49681953", "0.49645928", "0.49634257", "0.49465117", "0.49337772", "0.48710644", "0.48620728", "0.4857983", "0.4845533", "0.48432276", "0.48426062", "0.48409614", "0.48349157", "0.481028", "0.48059344", "0.47891158", "0.475331", "0.475331", "0.4740097", "0.47226968", "0.47150645", "0.46948728", "0.4694788", "0.46704575", "0.46698272", "0.465039", "0.46264958", "0.46253607", "0.46237516", "0.46134493", "0.4612364", "0.46110734", "0.46011633", "0.45907626", "0.45893234", "0.45844752", "0.4584188", "0.45773384", "0.457332", "0.45712644", "0.45684496", "0.4563505", "0.4554774", "0.45515713", "0.4550871", "0.4545659", "0.45344618", "0.4532619", "0.45236883", "0.45204073", "0.45146295", "0.45098343", "0.45017204", "0.44987684", "0.44954407", "0.44937518", "0.4490794", "0.4490794", "0.4490106", "0.44857982", "0.44637084", "0.44573188", "0.44401637", "0.44400397", "0.4423707", "0.44159982", "0.44150093", "0.44148538", "0.4408462", "0.44012037", "0.44005403", "0.43985376", "0.4391757", "0.4386513", "0.43833593", "0.43792942", "0.4376285", "0.43753237", "0.43709162", "0.43700424", "0.43547904", "0.43511504", "0.4350744", "0.43438935", "0.43367827" ]
0.7632487
0
write sends payload over the GATT connection. EOD identifies the end of the transfer, useful for the handshake.
public boolean write(BluetoothGattCharacteristic characteristic, byte[] payload, boolean withEOD) { Log.v(TAG, String.format("write called: device=%s base64=%s value=%s length=%d characteristicUUID=%s", getMACAddress(), Base64.encodeToString(payload, Base64.DEFAULT), BleDriver.bytesToHex(payload), payload.length, characteristic.getUuid())); if (!isClientConnected()) { Log.e(TAG, "write error: device not connected"); return false; } int minOffset = 0; int maxOffset; // Send data to fit with MTU value while (minOffset != payload.length) { maxOffset = minOffset + getMtu() - GattServer.ATT_HEADER_SIZE > payload.length ? payload.length : minOffset + getMtu() - GattServer.ATT_HEADER_SIZE; final byte[] toWrite = Arrays.copyOfRange(payload, minOffset, maxOffset); minOffset = maxOffset; Log.v(TAG, String.format("write: data chunk: device=%s base64=%s value=%s length=%d characteristicUUID=%s", getMACAddress(), Base64.encodeToString(toWrite, Base64.DEFAULT), BleDriver.bytesToHex(toWrite), toWrite.length, characteristic.getUuid())); if (!internalWrite(characteristic, toWrite)) { Log.e(TAG, String.format("write payload failed: device=%s", getMACAddress())); return false; } } if (withEOD && !internalWrite(characteristic, EOD.getBytes())) { Log.e(TAG, String.format("write EOD failed: device=%s", getMACAddress())); return false; } return true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public void write(DataOutputStream out) throws IOException;", "public void write(byte[] data) throws IOException {\r\n try {\r\n os.write(data);\r\n } catch (IOException io) {\r\n if (!cbImpl.checkMobileNetwork()) {\r\n throw new WrapperIOException(new TransportException(io.getMessage(), io,\r\n TransportException.NO_NETWORK_COVERAGE));\r\n }\r\n throw io;\r\n }\r\n }", "@Override\n\t\tpublic void write(byte[] buffer) throws IOException {\n\t\t\t// TODO Auto-generated method stub\n\t\t\tout.write(buffer);\n\t\t\tamount+=buffer.length;\n\t\t\tthis.listener.AmountTransferred(amount);\n\t\t}", "public abstract void write(O value) throws IOException;", "@Override\n public void writeTo(DataOutput dout) throws IOException {\n\n if (!isHeadless()) {\n dout.writeShort(getTransactionID());\n dout.writeShort(getProtocolID());\n dout.writeShort(getDataLength());\n }\n dout.writeByte(getUnitID());\n dout.writeByte(getFunctionCode());\n writeData(dout);\n }", "@Override\n public void write() {\n\n }", "@Override\r\n\tpublic int write() throws Exception {\n\t\treturn 0;\r\n\t}", "void write();", "@Override\r\n\tpublic void write() {\n\t\t\r\n\t}", "public abstract void write(NetOutput out) throws IOException;", "public void _write(org.omg.CORBA.portable.OutputStream ostream)\r\n {\r\n NiveauEtudeHelper.write(ostream,value);\r\n }", "public abstract void write (DataOutputStream outStream)\r\n throws IOException;", "public void write(byte[] out, int offset, int count) {\n // Create temporary object\n MultiplexUsbTransport.WriterThread r;\n // Synchronize a copy of the ConnectedThread\n synchronized (this) {\n if (mState != STATE_CONNECTED) return;\n r = writerThread;\n //r.write(out,offset,count);\n }\n // Perform the write unsynchronized\n r.write(out,offset,count);\n }", "public void write(byte[] b, int off, int len) throws IOException {\r\n try {\r\n os.write(b, off, len);\r\n } catch (IOException io) {\r\n if (!cbImpl.checkMobileNetwork()) {\r\n throw new WrapperIOException(new TransportException(io.getMessage(), io,\r\n TransportException.NO_NETWORK_COVERAGE));\r\n }\r\n throw io;\r\n }\r\n }", "@Override\r\n\tpublic synchronized void write(byte[] b, int off, int len)\r\n\t{\r\n\t}", "@Override\n public void write(Data dataPacket) throws IOException {\n }", "public abstract void write(byte[] b);", "@Override\n\t\tprotected void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {\n\t\t\tfinal byte[] buffer = mOutgoingBuffer;\n\t\t\tif (mBufferOffset == buffer.length) {\n\t\t\t\ttry {\n\t\t\t\t\tmCallbacks.onDataSent(new String(buffer, \"UTF-8\"));\n\t\t\t\t} catch (final UnsupportedEncodingException e) {\n\t\t\t\t\t// do nothing\n\t\t\t\t}\n\t\t\t\tmOutgoingBuffer = null;\n\t\t\t} else { // Otherwise...\n\t\t\t\tfinal int length = Math.min(buffer.length - mBufferOffset, MAX_PACKET_SIZE);\n\t\t\t\tfinal byte[] data = new byte[length]; // We send at most 20 bytes\n\t\t\t\tSystem.arraycopy(buffer, mBufferOffset, data, 0, length);\n\t\t\t\tmBufferOffset += length;\n\t\t\t\tmWriteCharacteristic.setValue(data);\n\t\t\t\twriteCharacteristic(mWriteCharacteristic);\n\t\t\t}\n\t\t}", "private void write(String msg) throws IOException {\n if (connectedSwitch) {\n outStream.writeBytes(msg + \";\");\n outStream.flush();\n } else {\n Log.e(TAG, \"Socket disconnected\");\n }\n }", "public abstract void write(DataOutput out) throws IOException;", "public abstract void writeToStream(java.io.DataOutputStream output) throws java.io.IOException;", "public void send(Opcode opcode, Serializable datum);", "public void write(BufferedDataOutputStream o) throws FitsException {\n\n this.writeTrueData(o);\n byte[] padding = new byte[getPadding()];\n try {\n o.writePrimitiveArray(padding);\n } catch (IOException e) {\n throw new FitsException (\"Error writing padding: \"+e);\n }\n\n }", "public void writedata(byte b) throws Exception{\n ByteBuffer byteBuffer = ByteBuffer.wrap(\"hello\".getBytes(\"UTF-8\"));\n// byteBuffer.flip();\n client.write(byteBuffer);\n byteBuffer.clear();\n client.close();\n\n }", "private void write( byte[] data) throws IOException {\n ByteBuffer buffer = ByteBuffer.wrap(data);\n\n int write = 0;\n // Keep trying to write until buffer is empty\n while(buffer.hasRemaining() && write != -1)\n {\n write = channel.write(buffer);\n }\n\n checkIfClosed(write); // check for error\n\n if(ProjectProperties.DEBUG_FULL){\n System.out.println(\"Data size: \" + data.length);\n }\n\n key.interestOps(SelectionKey.OP_READ);// make key read for reading again\n\n }", "void writeTo(DataOutputStream dout) throws IOException {\r\n throw new Error(\"Method no longer available\");\r\n// dout.writeInt(commit_id);\r\n// dout.writeInt(table_id);\r\n// dout.writeInt(journal_entries);\r\n// dout.write(command_journal, 0, journal_entries);\r\n// int size = command_parameters.size();\r\n// dout.writeInt(size);\r\n// for (int i = 0; i < size; ++i) {\r\n// dout.writeInt(command_parameters.intAt(i));\r\n// }\r\n }", "public void write(byte[] buffer);", "void write(byte[] buffer, int bufferOffset, int length) throws IOException;", "protected abstract void write (Object val);", "private void sendData() {\n final ByteBuf data = Unpooled.buffer();\n data.writeShort(input);\n data.writeShort(output);\n getCasing().sendData(getFace(), data, DATA_TYPE_UPDATE);\n }", "@Override\r\n\tpublic void writeObject(Object obj) throws IOException {\n\t\t\r\n\t\tif (obj instanceof HandShake ) {\r\n\t\t\t((HandShake) obj).write(this);\r\n\t\t} else if (obj instanceof Message){\r\n\t\t\t((Message) obj).write(this);\r\n\t\t} else {\r\n\t\t\tthrow new UnsupportedOperationException(\" Message is not supported to write \");\r\n\t\t}\r\n\t}", "public void _write(org.omg.CORBA.portable.OutputStream ostream)\r\n {\r\n EtudiantDejaInscritExceptionHelper.write(ostream,value);\r\n }", "void write(PacketConnection connection);", "public void writeData(byte[] data){\n if (mWriteCharacteristic!=null &&data!=null){\n mWriteCharacteristic.setValue(data[0],BluetoothGattCharacteristic.FORMAT_UINT8,0);\n mWriteCharacteristic.setValue(data);\n bluetoothGatt.writeCharacteristic(mWriteCharacteristic);\n }\n }", "public void write(DataOutputStream writer) throws Exception\r\n\t{\n\r\n\t}", "public void write(byte[] data, long offset);", "public static native int write(int fd, byte[] data, int off, int len) throws IOException;", "public abstract void writeToStream(DataOutputStream dataOutputStream);", "@Override\n public void write(byte[] buf, int offset, int size) throws IOException;", "@Override\n public void onDataWrite(String deviceName, String data)\n {\n if(mTruconnectHandler.getLastWritePacket().contentEquals(data))\n {\n mTruconnectCallbacks.onDataWritten(data);\n\n String nextPacket = mTruconnectHandler.getNextWriteDataPacket();\n if(!nextPacket.contentEquals(\"\"))\n {\n mBLEHandler.writeData(deviceName, nextPacket);\n }\n }\n else\n {\n mTruconnectCallbacks.onError(TruconnectErrorCode.WRITE_FAILED);\n mTruconnectHandler.onError();\n }\n }", "@Override\n public void write(final byte[] data) throws IOException {\n write(data, 0, data.length);\n }", "void write(byte b[]) throws IOException;", "private void send(Object o) {\r\n try {\r\n System.out.println(\"02. -> Sending (\" + o +\") to the client.\");\r\n this.os.writeObject(o);\r\n this.os.flush();\r\n } \r\n catch (Exception e) {\r\n System.out.println(\"XX.\" + e.getStackTrace());\r\n }\r\n }", "void sendData() throws IOException\n\t{\n\t}", "public abstract int writeData(int address, byte[] buffer, int length);", "public synchronized void writeToSocket(String msg) {\n try {\n bluetoothSocket.getOutputStream().println(msg);\n } catch (Exception e) {\n Log.e(TAG, General.OnWriteToSocketFailed, e);\n }\n }", "@Override\n public void write(byte[] data, int off, int len) throws IOException {\n for (int i = off; i < len; i++) {\n write(data[i]);\n }\n }", "private void send(Object o) {\n\t\ttry {\n\t\t\tSystem.out.println(\"02. -> Sending (\" + o +\") to the client.\");\n\t\t\tthis.os.writeObject(o);\n\t\t\tthis.os.flush();\n\t\t} \n\t\tcatch (Exception e) {\n\t\t\tSystem.out.println(\"XX.\" + e.getStackTrace());\n\t\t}\n\t}", "public abstract void writeData(DataOutput dout) throws IOException;", "@DSSink({DSSinkKind.IO})\n @DSSpec(DSCat.IO)\n @DSGenerator(tool_name = \"Doppelganger\", tool_version = \"2.0\", generated_on = \"2014-09-03 14:59:52.266 -0400\", hash_original_method = \"6659C26B9D2F6D845755120D9E3C542C\", hash_generated_method = \"1D85046399E8D016E013E1B1E96055F2\")\n \n@Override\r\n public void write(byte[] bts, int st, int end) throws IOException {\r\n try {\r\n beforeWrite(end);\r\n out.write(bts, st, end);\r\n afterWrite(end);\r\n } catch (IOException e) {\r\n handleIOException(e);\r\n }\r\n }", "public void writePacket(DataOutputStream dataOutputStream) throws IOException;", "public void write(int c) throws IOException {\r\n try {\r\n os.write(c);\r\n } catch (IOException io) {\r\n if (!cbImpl.checkMobileNetwork()) {\r\n throw new WrapperIOException(new TransportException(io.getMessage(), io,\r\n TransportException.NO_NETWORK_COVERAGE));\r\n }\r\n throw io;\r\n }\r\n }", "public void write(byte b[], int off, int len) throws IOException;", "public void WriteMessage(byte[] message)\r\n {\r\n try {\r\n out.write(new Integer(message.length).byteValue());\r\n out.write(message);\r\n out.flush();\r\n }catch (Exception e){\r\n System.out.println(e);\r\n }\r\n }", "public void write(byte[] buffer, int offset, int count) {\n try {\n if(buffer==null){\n Log.w(TAG, \"Can't write to device, nothing to send\");\n return;\n }\n //This would be a good spot to log out all bytes received\n mmOutStream.write(buffer, offset, count);\n if(connectionSuccessful == null){\n connectionSuccessful = false;\n }\n //Log.w(TAG, \"Wrote out to device: bytes = \"+ count);\n } catch (IOException|NullPointerException e) { // STRICTLY to catch mmOutStream NPE\n // Exception during write\n //OMG! WE MUST NOT BE CONNECTED ANYMORE! LET THE USER KNOW\n Log.e(TAG, \"Error sending bytes to connected device!\");\n connectionLost();\n }\n }", "protected void write(byte[] bytes, int offset, int length) {\n/* 114 */ if (this.socket == null) {\n/* 115 */ if (this.connector != null && !this.immediateFail) {\n/* 116 */ this.connector.latch();\n/* */ }\n/* 118 */ if (this.socket == null) {\n/* 119 */ String msg = \"Error writing to \" + getName() + \" socket not available\";\n/* 120 */ throw new AppenderLoggingException(msg);\n/* */ } \n/* */ } \n/* 123 */ synchronized (this) {\n/* */ try {\n/* 125 */ getOutputStream().write(bytes, offset, length);\n/* 126 */ } catch (IOException ex) {\n/* 127 */ if (this.retry && this.connector == null) {\n/* 128 */ this.connector = new Reconnector(this);\n/* 129 */ this.connector.setDaemon(true);\n/* 130 */ this.connector.setPriority(1);\n/* 131 */ this.connector.start();\n/* */ } \n/* 133 */ String msg = \"Error writing to \" + getName();\n/* 134 */ throw new AppenderLoggingException(msg, ex);\n/* */ } \n/* */ } \n/* */ }", "private void writeData(String data) {\n try {\n outStream = btSocket.getOutputStream();\n } catch (IOException e) {\n }\n\n String message = data;\n byte[] msgBuffer = message.getBytes();\n\n try {\n outStream.write(msgBuffer);\n } catch (IOException e) {\n }\n }", "public byte[] write() {\n\t\tbyte[] ret = bindings.RevokeAndACK_write(this.ptr);\n\t\treturn ret;\n\t}", "public void write(byte[] bytes) {\n try {\n mmOutStream.write(bytes);\n\n // Share the sent message with the UI activity.\n /*Message writtenMsg = handler.obtainMessage(\n MessageConstants.MESSAGE_WRITE, -1, -1, mmBuffer);\n writtenMsg.sendToTarget();*/\n } catch (IOException e) {\n Log.e(TAG, \"Error occurred when sending data\", e);\n\n // Send a failure message back to the activity.\n /*Message writeErrorMsg =\n handler.obtainMessage(MessageConstants.MESSAGE_TOAST);\n Bundle bundle = new Bundle();\n bundle.putString(\"toast\",\n \"Couldn't send data to the other device\");\n writeErrorMsg.setData(bundle);\n handler.sendMessage(writeErrorMsg);*/\n }\n }", "String write(byte[] content, boolean noPin);", "public void sendData(Datapacket packet){\n try {\n oos.flush();\n oos.reset();\n oos.writeObject(packet);\n } catch (IOException e) {\n e.printStackTrace();\n }\n }", "protected abstract void _write(DataOutput output) throws IOException;", "public void write(int b) throws IOException {\n/* 54 */ this.appendable.append((char)b);\n/* */ }", "public void write(byte b[]) throws IOException;", "public void endWrite() throws ThingsException;", "public void sendBodyByte(byte[] content) throws IOException {\n this.out.write(content);\n }", "@Override\n public void write(int b) throws IOException {\n if (b == ModbusASCIITransport.FRAME_START) {\n out.write(58);\n // System.out.println(\"Wrote FRAME_START\");\n return;\n } else if (b == ModbusASCIITransport.FRAME_END) {\n out.write(13);\n out.write(10);\n // System.out.println(\"Wrote FRAME_END\");\n return;\n } else {\n out.write(ModbusUtil.toHex(b));\n // System.out.println(\"Wrote byte \"+b+\"=\"+new String(ModbusUtil.toHex(b)));\n }\n }", "void write(StreamOption streamOpt);", "@Override\r\n\t\t\tpublic void write(int b) throws IOException {\n\t\t\t}", "public void outputData(OutputStream _os)throws Exception{\r\n\t\t\t\t\r\n\t\tsendReceive.WriteString(_os,summary);\r\n\t\t\r\n\t\tsendReceive.WriteLong(_os, start);\r\n\t\tsendReceive.WriteLong(_os, end);\r\n\t\t\r\n\t\tsendReceive.WriteString(_os, location);\r\n\t\tsendReceive.WriteInt(_os, alarm);\r\n\t\tsendReceive.WriteString(_os, note);\r\n\t\t\r\n\t\tsendReceive.WriteBoolean(_os, allDay);\r\n\t\t\r\n\t\tif(attendees != null){\r\n\t\t\tsendReceive.WriteInt(_os, attendees.length);\r\n\r\n\t\t\tfor(int i = 0;i < attendees.length;i++){\r\n\t\t\t\tsendReceive.WriteString(_os,attendees[i]);\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tsendReceive.WriteInt(_os, 0);\r\n\t\t}\r\n\t\t\r\n\t\t_os.write(free_busy);\r\n\t\t_os.write(event_class);\r\n\t\t\r\n\t\tsendReceive.WriteString(_os, repeat_type);\r\n\t}", "@Override\n\tpublic void send(OutputStream stream) throws IOException {\n\t\tstream.write(this.data);\n\t}", "public byte[] write() {\n\t\tbyte[] ret = bindings.ChannelReestablish_write(this.ptr);\n\t\treturn ret;\n\t}", "public void write(byte b[], int off, int len) throws IOException\n {\n checkThreshold(len);\n getStream().write(b, off, len);\n written += len;\n }", "void writeCommand(CommProtocolCommands command, Object ... params) throws IOException;", "protected void writeData(DataOutput output) throws IOException {\n ByteArrayOutputStream bout = new ByteArrayOutputStream();\n ObjectOutputStream oos = new ObjectOutputStream(bout);\n oos.writeObject(returnValue);\n\n output.write(getOperationStatus());\n \n if (operationStatus != ProtocolOpcode.OPERATION_OK) {\n output.write(getException());\n } else {\n output.writeInt(bout.size());\n output.write(bout.toByteArray());\n }\n }", "public void _write(org.omg.CORBA.portable.OutputStream ostream)\r\n {\r\n PropositionHelper.write(ostream,value);\r\n }", "public abstract void write(T dataElement);", "@Override\n public void write(int b) {\n try {\n out.write(b);\n } catch (IOException e) {\n e.printStackTrace();\n }\n }", "public void write(long address, short[] buffer, int length, int moteID) {\n\t\tmote.write(address, buffer, length, moteID);\t\n\t}", "public void write(WriteOnly data) {\n\t\tdata.writeData(\"new data\"); // Ok\n\t}", "public void writePacket(byte[] pkt, int off, int len)\n throws IOException {\n\n throw new IOException(\"writePacket() not implemented\");\n }", "public void write(String message) {\n Log.d(TAG, \"...Data to send: \" + message + \"...\");\n byte[] msgBuffer = message.getBytes();\n try {\n mmOutStream.write(msgBuffer);\n } catch (IOException e) {\n Log.d(TAG, \"...Error data send: \" + e.getMessage() + \"...\");\n }\n }", "public void write(String message) {\n Log.d(TAG, \"...Data to send: \" + message + \"...\");\n byte[] msgBuffer = message.getBytes();\n try {\n mmOutStream.write(msgBuffer);\n } catch (IOException e) {\n Log.d(TAG, \"...Error data send: \" + e.getMessage() + \"...\");\n }\n }", "public void write(byte[] buffer){\r\n\t\t\r\n\t\ttry{\r\n\t\t\toOutStream.write(buffer);\r\n\t\t}catch(IOException e){\r\n\t\t\tLog.e(TAG, \"exception during write\", e);\r\n\t\t}\r\n\t}", "public void writeTo(OutputStream os) throws IOException, MessagingException {\n/* 96 */ LineOutputStream los = null;\n/* 97 */ if (os instanceof LineOutputStream) {\n/* 98 */ los = (LineOutputStream)os;\n/* */ } else {\n/* 100 */ los = new LineOutputStream(os);\n/* */ } \n/* */ \n/* */ \n/* 104 */ Enumeration hdrLines = getAllHeaderLines();\n/* 105 */ while (hdrLines.hasMoreElements()) {\n/* 106 */ los.writeln(hdrLines.nextElement());\n/* */ }\n/* */ \n/* 109 */ los.writeln();\n/* */ \n/* */ \n/* 112 */ getDataHandler().writeTo(os);\n/* 113 */ os.flush();\n/* */ }", "public void writeTo(ByteBuf out) {\n/* 77 */ if (this.value == null) {\n/* */ return;\n/* */ }\n/* 80 */ out.writeByte(this.value.byteValue());\n/* */ }", "public void mWriteByte(OutputStream oOutputStream,byte[] out) {\n synchronized (this) {\n if (mStateGet()!= cKonst.eSerial.kBT_Connected1) {\n return;\n }\n try { //Maybe the steam was closed by receiver\n oOutputStream.write(out);\n } catch (IOException e) {\n mStateSet(cKonst.eSerial.kBT_BrokenConnection);\n }\n }\n }", "public void send(byte[] data) throws IOException {\n dataOutput.write(data);\n dataOutput.flush();\n }", "private void handleWrite(SelectionKey key, String message, SSLClientSession session) throws IOException {\n\t\t\tSSLSocketChannel ssl_socket_channel = session.getSSLSocketChannel();\n\t\t\t\n\t\t\tByteBuffer out_message = ssl_socket_channel.getAppSendBuffer();\n\t\t\t\n\t\t\tif(message != null) \n\t\t\t\tout_message.put(message.getBytes());\n\t\t\t\n//\t\t\tOutputHandler.println(\"Server: writing \"+new String(out_message.array(), 0, out_message.position()));\n\t\t\tint count = 0;\n\t\t\t\n\t\t\twhile (out_message.position() > 0) {\n\t\t\t\tcount = ssl_socket_channel.write();\n\t\t\t\tif (count == 0) {\n//\t\t\t\t\tOutputHandler.println(\"Count was 0.\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\n//\t\t\t\telse {\n//\t\t\t\t\tOutputHandler.println(\"Count was \"+count);\n//\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (out_message.position() > 0) {\n\t\t\t\t// short write:\n\t\t\t\t// Register for OP_WRITE and come back here when ready\n\t\t\t\tkey.interestOps(key.interestOps() | SelectionKey.OP_WRITE);\n\t\t\t\t\n\t\t\t\tsession.rewrite = true;\n\t\t\t} else {\n\t\t\t\tif(session.out_messages.isEmpty()) { \n\t\t\t\t\t// Write succeeded, don�t need OP_WRITE any more\n\t\t\t\t\tkey.interestOps(key.interestOps() & ~SelectionKey.OP_WRITE);\n\t\t\t\t} \n\t\t\t\t\n\t\t\t\tsession.rewrite = false;\n\t\t\t}\n\t\t}", "public ChannelFuture writeOneOutbound(Object msg, ChannelPromise promise) {\n/* 432 */ if (checkOpen(true)) {\n/* 433 */ return write(msg, promise);\n/* */ }\n/* 435 */ return checkException(promise);\n/* */ }", "public void writeFrame(Frame frame) throws IOException {\n _buffer.clear();\n _format.marshal(_buffer, frame);\n _buffer.flip();\n try {\n _channel.write(_buffer);\n } catch (IOException e) {\n LOGGER.warning(\"There was an exception while writing to the client.\");\n }\n if(_writeHook != null) {\n _writeHook.run();\n }\n }", "public void writeResponse(OutputStream out, ServiceTunnelResponse msg) throws Exception {\n boolean compressed = isUseCompression();\r\n StringBuilder buf = new StringBuilder();\r\n buf.append(\"<SOAP-ENV:Envelope SOAP-ENV:encodingStyle=\\\"http://schemas.xmlsoap.org/soap/encoding/\\\" xmlns:SOAP-ENV=\\\"http://schemas.xmlsoap.org/soap/envelope/\\\">\\n\");\r\n buf.append(\"<SOAP-ENV:Body>\\n\");\r\n if (msg.getException() == null) {\r\n buf.append(\" <response status=\\\"OK\\\"\");\r\n Object x = msg.getData();\r\n if (x != null) {\r\n buf.append(\" type=\\\"\" + x.getClass().getSimpleName() + \"\\\"\");\r\n }\r\n else {\r\n buf.append(\" type=\\\"\\\"\");\r\n }\r\n buf.append(\" compressed=\\\"\" + compressed + \"\\\"\");\r\n buf.append(\"/>\\n\");\r\n }\r\n else {\r\n buf.append(\" <response status=\\\"ERROR\\\">\\n\");\r\n buf.append(\" <exception type=\\\"\" + msg.getException().getClass().getSimpleName() + \"\\\">\");\r\n buf.append(msg.getException().getMessage());\r\n buf.append(\"</exception>\\n\");\r\n buf.append(\" </response>\\n\");\r\n }\r\n buf.append(\" <data>\");\r\n long y = System.nanoTime();\r\n setData(buf, msg, compressed);\r\n y = System.nanoTime() - y;\r\n if (LOG.isDebugEnabled()) LOG.debug(\"message encoding took \" + y + \" nanoseconds\");\r\n buf.append(\"</data>\\n\");\r\n buf.append(\" <info\");\r\n buf.append(\" origin=\\\"\" + m_originAddress + \"\\\"\");\r\n buf.append(\"/>\\n\");\r\n buf.append(\"</SOAP-ENV:Body>\");\r\n buf.append(\"</SOAP-ENV:Envelope>\");\r\n //\r\n if (LOG.isDebugEnabled()) {\r\n out = new DebugOutputStream(out);\r\n }\r\n try {\r\n out.write(buf.toString().getBytes(\"UTF-8\"));\r\n }\r\n finally {\r\n if (LOG.isDebugEnabled()) {\r\n String sentData = ((DebugOutputStream) out).getContent(\"UTF-8\");\r\n int lastWrittenCharacter = ((DebugOutputStream) out).getLastWrittenCharacter();\r\n Throwable lastThrownException = ((DebugOutputStream) out).getLastThrownException();\r\n LOG.debug(\"lastWrittenCharacter=\" + lastWrittenCharacter + \",lastThrownException=\" + lastThrownException + \", sentData: \" + sentData);\r\n }\r\n }\r\n }", "@Override\n public void write(byte[] data) throws SerialError {\n int offset= 0;\n int size_toupload=0;\n byte[] buffer = new byte[SIZE_SERIALUSB];\n if(!isConnected())\n {\n open();\n }\n try\n {\n while(offset < data.length) {\n\n if(offset+SIZE_SERIALUSB > data.length)\n {\n size_toupload = data.length-offset;\n }\n System.arraycopy(data, offset, buffer, 0, size_toupload);\n int size_uploaded = conn.bulkTransfer(epOUT, buffer, size_toupload, TIMEOUT);\n if(size_uploaded<0)\n {\n throw new SerialError(\" bulk Transfer fail\");\n }\n offset += size_uploaded;\n }\n\n }catch (Exception e)\n {\n throw new SerialError(e.getMessage());\n }\n }", "private void sendData(String message) {\n\t\t\ttry {\n\t\t\t\toutput.writeObject(message);\n\t\t\t\toutput.flush(); // flush output to client\n\t\t\t} catch (IOException ioException) {\n\t\t\t\tSystem.out.println(\"\\nError writing object\");\n\t\t\t}\n\t\t}", "public void write(byte b[]) throws IOException\n {\n checkThreshold(b.length);\n getStream().write(b);\n written += b.length;\n }", "@Override public void write(byte[] bytes) throws RobotCoreException\n {\n byte bCommand = bytes[2];\n this.cbExpected = bCommand==0 ? 0/*write*/ : bytes[4] /*read*/;\n }", "@Override\n public void write(byte[] buf) throws IOException;", "void send(ByteBuffer data, Address addr) throws CCommException, IllegalStateException;", "public void asyncWrite(Object requestCtxt, byte[] data, int length, TrcEvent event, TrcNotifier.Receiver handler)\n {\n asyncWrite(requestCtxt, -1, data, length, event, handler);\n }", "public abstract void SendData(int sock, String Data) throws LowLinkException, TransportLayerException, CommunicationException;" ]
[ "0.58793175", "0.5757663", "0.57031983", "0.5685187", "0.56796837", "0.56091225", "0.5605155", "0.56011295", "0.55903333", "0.5546591", "0.5522451", "0.5515474", "0.550823", "0.5504246", "0.54964507", "0.54881054", "0.5473872", "0.5472305", "0.54703206", "0.5470163", "0.5423155", "0.54153085", "0.5404621", "0.53837365", "0.5368067", "0.53653824", "0.53637266", "0.5357267", "0.53422904", "0.5341568", "0.53381103", "0.53242135", "0.5321342", "0.53187424", "0.5313447", "0.5310139", "0.53051627", "0.52995193", "0.5280316", "0.52637553", "0.5262926", "0.5250242", "0.5239975", "0.5231824", "0.5231052", "0.52303904", "0.52260303", "0.5221992", "0.52205396", "0.52176285", "0.52160406", "0.5214418", "0.5212778", "0.5205697", "0.519589", "0.5195123", "0.5192242", "0.51919013", "0.5176555", "0.51759076", "0.51742697", "0.5174134", "0.51684207", "0.516103", "0.5158051", "0.5157728", "0.51558816", "0.5146891", "0.51449585", "0.51349443", "0.51310766", "0.5130322", "0.5129949", "0.51257557", "0.5122738", "0.5122042", "0.51186895", "0.51157254", "0.5112911", "0.5110736", "0.5110361", "0.51091474", "0.51091474", "0.51042783", "0.51039577", "0.50978804", "0.509632", "0.5093083", "0.5087452", "0.5086812", "0.50831735", "0.5079743", "0.50789857", "0.5076967", "0.50763535", "0.5076205", "0.50689346", "0.50545657", "0.5045371", "0.50411296" ]
0.69549185
0
handshake identifies the berty service and their characteristic, and exchange the peerID each other.
private void handshake() { Log.d(TAG, "handshake: called"); if (takeBertyService()) { if (takeBertyCharacteristics()) { // Speed up connection requestMtu(PeerDevice.MAX_MTU); // send local PID if (!write(getPIDCharacteristic() ,mLocalPID.getBytes(), true)) { Log.e(TAG, String.format("handshake error: failed to send local PID: device=%s", getMACAddress())); disconnect(); } // get remote PID if (!read(getPIDCharacteristic())) { Log.e(TAG, String.format("handshake error: failed to read remote PID: device=%s", getMACAddress())); disconnect(); } return ; } } Log.e(TAG, String.format("handshake error: failed to find berty service: device=%s", getMACAddress())); disconnect(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public void setHandshake(Handshake handshake)\n {\n this.handshake = handshake;\n }", "void handshake() throws SyncConnectionException;", "private void handleHandshakeMessage(UUID peerID, byte[] message) {\n UUID newPeerID = ByteAuxiliary.recoverUUID(message);\n\n handler.handleHandshakeMessage(peerID, newPeerID);\n }", "private void doHandshake()throws Exception {\n\t\tHttpClient httpClient = new HttpClient();\n\t\t// Here set up Jetty's HttpClient, for example:\n\t\t// httpClient.setMaxConnectionsPerDestination(2);\n\t\thttpClient.start();\n\n\t\t// Prepare the transport\n\t\tMap<String, Object> options = new HashMap<String, Object>();\n\t\tClientTransport transport = new LongPollingTransport(options, httpClient);\n\n\t\t// Create the BayeuxClient\n\t\tClientSession client = new BayeuxClient(\"http://localhost:8080/childrenguard-server/cometd\", transport);\n\n\t\tclient.handshake(null,new ClientSessionChannel.MessageListener()\n\t\t{\n\t\t public void onMessage(ClientSessionChannel channel, Message message)\n\t\t {\n\t\t \tSystem.out.println(\"fail to connect to server.\");\n\t\t if (message.isSuccessful())\n\t\t {\n\t\t \tSystem.out.println(message);\n\t\t // Here handshake is successful\n\t\t }\n\t\t }\n\t\t});\n\t\t\n\t\t// Here set up the BayeuxClient, for example:\n\t\t//client.getChannel(Channel.META_CONNECT).addListener(new ClientSessionChannel.MessageListener() { });\n\n\t\t\n\t}", "@Override\n protected void prepareHandshakeMessageContents() {\n }", "private void sendDeviceHandshake(SelectionKey key, boolean flag) throws IOException {\n\t\tSocketChannel channel = (SocketChannel)key.channel();\n\t\tbyte[] ackData = new byte[1];\n\t\tif(flag) {\n\t\t\tackData[0]=01;\t\n\t\t}else {\n\t\t\tackData[0]=00;\n\t\t}\n\n\n\t\tByteBuffer bSend = ByteBuffer.allocate(ackData.length);\n\t\tbSend.clear();\n\t\tbSend.put(ackData);\n\t\tbSend.flip();\n\t\twhile (bSend.hasRemaining()) {\n\t\t\ttry {\n\t\t\t\tchannel.write(bSend);\n\t\t\t} catch (IOException e) {\n\t\t\t\tthrow new IOException(\"Failed to send acknowledgement\");\n\t\t\t}\n\n\t\t}\n\t}", "@Override\n protected void connectionEstablished()\n {\n peer.resetConnectionClosed();\n\n // send our handshake directly as it doesn't fit into peer message\n // and there is always space in send buffer on new connection\n //enqueue(pmCache.handshake(torrent.getTorrentId(), torrent.getClientId()));\n }", "public String getClientHandshakeMessage(int identifier) {\n JSONObject model = new JSONObject();\n model.put(\"Type\", \"Handshake\");\n model.put(\"Identifier\", Integer.toString(identifier));\n //model.put(\"TcpSendBuffer\", Integer.toString(tcpSendBuffer));\n //model.put(\"TcpReceiveBuffer\", Integer.toString(tcpReceiveBuffer));\n //model.put (\"idAck\" , Integer.toString(lastReceivedMessage));\n return model.toString();\n }", "@Test\n\tpublic void testFastHandshakePeerIDHaveAll() throws Exception {\n\n\t\t// Given\n\t\tPieceDatabase pieceDatabase = MockPieceDatabase.create (\"1\", 16384);\n\t\tpieceDatabase.start (true);\n\t\tBitField wantedPieces = pieceDatabase.getPresentPieces().not();\n\t\tPeerServices peerServices = mock (PeerServices.class);\n\t\tPeerSetContext peerSetContext = new PeerSetContext (peerServices, pieceDatabase, mock (RequestManager.class), null);\n\t\twhen(peerSetContext.requestManager.piecesAvailable (any (ManageablePeer.class))).thenReturn (false);\n\t\tMockConnection mockConnection = new MockConnection();\n\t\tPeerHandler handler = new PeerHandler (peerSetContext, mockConnection, new PeerID(), new PeerStatistics(), true, false);\n\n\t\t// When\n\t\tmockConnection.mockInput (PeerProtocolBuilder.bitfieldMessage (wantedPieces));\n\t\thandler.connectionReady (mockConnection, true, true);\n\n\t\t// Then\n\t\tmockConnection.mockExpectOutput (PeerProtocolBuilder.haveAllMessage());\n\t\tmockConnection.mockExpectOutput (PeerProtocolBuilder.allowedFastMessage (0));\n\t\tmockConnection.mockExpectNoMoreOutput();\n\n\n\t\tpieceDatabase.terminate (true);\n\n\t}", "@Override\n\tpublic void handshakeCompleted(HandshakeCompletedEvent evt) {\n\t\t\n\t}", "@Override\r\n\tpublic void run() {\r\n\t\ttry {\r\n\t\t\tthis.inputStream = socket.getInputStream();\r\n\t\t\tthis.outputStream = socket.getOutputStream();\r\n\t\t\t// Get the peer that is asking me for fragments.\r\n\t\t\tpeerState = torrentClient.getPeerStateList().getByAddress(\r\n\t\t\t\t\tsocket.getInetAddress().getHostAddress(), socket.getPort());\r\n\t\t\t// read handhake\r\n\t\t\tbyte[] received = new byte[68];\r\n\t\t\tinputStream.read(received);\r\n\t\t\t//Parse the handshake received\r\n\t\t\tHandsake handshakeMessage = Handsake\r\n\t\t\t\t\t.parseStringToHandsake(new String(received));\r\n\t\t\t// validate hash\r\n\t\t\tString torrentHash = new String(torrentClient.getMetainf()\r\n\t\t\t\t\t.getInfo().getInfoHash());\r\n\t\t\t//if the received handshake is correct send my handshake\r\n\t\t\tif (Handsake.isValidHandsakeForBitTorrentProtocol(handshakeMessage,\r\n\t\t\t\t\ttorrentHash)) {\r\n\t\t\t\t// send handshake\r\n\t\t\t\tHandsake handShakeToSend = new Handsake(torrentHash,\r\n\t\t\t\t\t\tthis.torrentClient.getPeerId());\r\n\t\t\t\tthis.outputStream.write(handShakeToSend.getBytes());\r\n\t\t\t\t// enviar bitfield\r\n\t\t\t\ttry {\r\n\t\t\t\t\tthis.sendBitfield();\r\n\t\t\t\t\t// leer\r\n\t\t\t\t\tPeerProtocolMessage message = this.readNormalMessage();\r\n\t\t\t\t\t// Check if I have received an interested message\r\n\t\t\t\t\tif (message.getType().equals(\r\n\t\t\t\t\t\t\tPeerProtocolMessage.Type.INTERESTED)) {\r\n\t\t\t\t\t\tif (this.peerState != null) {\r\n\t\t\t\t\t\t\tpeerState = torrentClient.getPeerStateList()\r\n\t\t\t\t\t\t\t\t\t.getByAddress(\r\n\t\t\t\t\t\t\t\t\t\t\tsocket.getInetAddress()\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t.getHostAddress(),\r\n\t\t\t\t\t\t\t\t\t\t\tsocket.getPort());\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t//Set the peer status\r\n\t\t\t\t\t\tif (this.peerState != null) {\r\n\t\t\t\t\t\t\tthis.peerState.setPeer_interested(true);\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t// send unchoke to the peer\r\n\t\t\t\t\t\tthis.outputStream.write(new UnChokeMsg().getBytes());\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t//set the peer status\r\n\t\t\t\t\t\tif (this.peerState != null) {\r\n\t\t\t\t\t\t\tthis.peerState.setAm_choking(false);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t//Continue receiveing messages if the message type is Keep_alive, Request or Have.\r\n\t\t\t\t\t\tboolean continueReading = true;\r\n\t\t\t\t\t\twhile (continueReading) {\r\n\t\t\t\t\t\t\tmessage = this.readNormalMessage();\r\n\t\t\t\t\t\t\tcontinueReading = processMessage(message);\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\t// if I have not received interested send unchoke\r\n\t\t\t\t\t\tthis.outputStream.write(new ChokeMsg().getBytes());\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t} catch (IOException ioe) {\r\n\t\t\t\t\tioe.printStackTrace();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// close connection\r\n\t\t\tthis.inputStream.close();\r\n\t\t\tthis.outputStream.close();\r\n\t\t\tsocket.close();\r\n\r\n\t\t} catch (IOException e) {\r\n\t\t\t// TODO Auto-generated catch block\r\n\t\t\tSystem.out.println(\"Sending thread closed\");\r\n\t\t\te.printStackTrace();\r\n\t\t\ttry {\r\n\t\t\t\tthis.inputStream.close();\r\n\t\t\t\tthis.outputStream.close();\r\n\t\t\t\tsocket.close();\r\n\t\t\t} catch (IOException e1) {\r\n\t\t\t\t// TODO Auto-generated catch block\r\n\t\t\t\te1.printStackTrace();\r\n\t\t\t}\r\n\t\t}\r\n\t}", "public HandShakeMessage(){\r\n\t\tthis.type = OperationCodeConstants.HANDSHAKE;\r\n\t\tthis.msg = BinaryHelper.shortToByte(type);\r\n\t}", "private void shakeHands() throws IOException {\n HttpRequest req = new HttpRequest(inputStream);\n String requestLine = req.get(HttpRequest.REQUEST_LINE);\n handshakeComplete = checkStartsWith(requestLine, \"GET /\")\n && checkContains(requestLine, \"HTTP/\")\n && req.get(\"Host\") != null\n && checkContains(req.get(\"Upgrade\"), \"websocket\")\n && checkContains(req.get(\"Connection\"), \"Upgrade\")\n && \"13\".equals(req.get(\"Sec-WebSocket-Version\"))\n && req.get(\"Sec-WebSocket-Key\") != null;\n String nonce = req.get(\"Sec-WebSocket-Key\");\n if (handshakeComplete) {\n byte[] nonceBytes = BaseEncoding.base64().decode(nonce);\n if (nonceBytes.length != HANDSHAKE_NONCE_LENGTH) {\n handshakeComplete = false;\n }\n }\n // if we have met all the requirements\n if (handshakeComplete) {\n outputPeer.write(asUTF8(\"HTTP/1.1 101 Switching Protocols\\r\\n\"));\n outputPeer.write(asUTF8(\"Upgrade: websocket\\r\\n\"));\n outputPeer.write(asUTF8(\"Connection: upgrade\\r\\n\"));\n outputPeer.write(asUTF8(\"Sec-WebSocket-Accept: \"));\n HashFunction hf = Hashing.sha1();\n HashCode hc = hf.newHasher()\n .putString(nonce, StandardCharsets.UTF_8)\n .putString(WEBSOCKET_ACCEPT_UUID, StandardCharsets.UTF_8)\n .hash();\n String acceptKey = BaseEncoding.base64().encode(hc.asBytes());\n outputPeer.write(asUTF8(acceptKey));\n outputPeer.write(asUTF8(\"\\r\\n\\r\\n\"));\n }\n outputPeer.setHandshakeComplete(handshakeComplete);\n }", "public HandshakeBuilder onHandshakeRecievedAsServer( WebSocket conn , Draft draft , Handshakedata request ) throws IOException;", "public String getServerHandshakeMessage(int identifier) {\n JSONObject model = new JSONObject();\n model.put(\"Type\", \"Handshake\");\n model.put(\"Identifier\", Integer.toString(identifier));\n return model.toString();\n }", "public Handshake()\n\t{\n\t this(-1);\n\t}", "public ConnectionHandler(Socket sSocket, String id, int thID)\n {\n try\n {\n incoming = sSocket;\n out = new PrintWriter(incoming.getOutputStream(), true);\n in = new BufferedReader(new InputStreamReader(incoming.getInputStream()));\n IDENT = id;\n threadID = thID;\n \n dhe = new DiffieHellmanExchange(\"DHKey\");\n }\n catch (Exception e)\n {\n System.out.println(\"ConnectionHandler [ConnectionHandler]: Error in Server: \" + e);\n }\n }", "public byte[] getPeerId() {\n\t\treturn _myPeerId;\n\t}", "@Test\n\tpublic void testFastHandshakePeerIDHaveNone() throws Exception {\n\n\t\t// Given\n\t\tPieceDatabase pieceDatabase = MockPieceDatabase.create (\"0\", 16384);\n\t\tpieceDatabase.start (true);\n\t\tBitField wantedPieces = pieceDatabase.getPresentPieces().not();\n\t\tPeerServices peerServices = mock (PeerServices.class);\n\t\tPeerSetContext peerSetContext = new PeerSetContext (peerServices, pieceDatabase, mock (RequestManager.class), null);\n\t\twhen(peerSetContext.requestManager.piecesAvailable (any (ManageablePeer.class))).thenReturn (false);\n\t\tMockConnection mockConnection = new MockConnection();\n\t\tPeerHandler handler = new PeerHandler (peerSetContext, mockConnection, new PeerID(), new PeerStatistics(), true, false);\n\n\t\t// When\n\t\tmockConnection.mockInput (PeerProtocolBuilder.bitfieldMessage (wantedPieces));\n\t\thandler.connectionReady (mockConnection, true, true);\n\n\t\t// Then\n\t\tmockConnection.mockExpectOutput (PeerProtocolBuilder.haveNoneMessage());\n\t\tmockConnection.mockExpectOutput (PeerProtocolBuilder.allowedFastMessage (0));\n\t\tmockConnection.mockExpectNoMoreOutput();\n\n\n\t\tpieceDatabase.terminate (true);\n\n\t}", "byte[] clientVerifyHash(String HashType, byte[] mastersecret, byte[] handshakemessages) throws NoSuchAlgorithmException, IOException{\n MessageDigest hasher = MessageDigest.getInstance(HashType);\r\n \r\n int padsize = 1;\r\n \r\n switch(HashType){\r\n case \"MD5\": \r\n padsize = 48;\r\n break;\r\n case \"SHA-1\":\r\n padsize = 40;\r\n break;\r\n }\r\n \r\n byte[] pad1 = new byte[padsize];\r\n byte[] pad2 = new byte[padsize];\r\n \r\n for (int i = 0; i < padsize; i++){\r\n pad1[i] = (0x36);\r\n pad2[i] = (0x5C);\r\n }\r\n \r\n baos.write(handshakemessages);\r\n baos.write(mastersecret);\r\n baos.write(pad1);\r\n \r\n byte[] before_HSM = baos.toByteArray();\r\n byte[] hashedHSM = hasher.digest(before_HSM);\r\n \r\n baos.reset();\r\n \r\n baos.write(mastersecret);\r\n baos.write(pad2);\r\n baos.write(hashedHSM);\r\n \r\n byte[] before_complete = baos.toByteArray();\r\n byte[] whole_hash = hasher.digest(before_complete);\r\n \r\n baos.reset();\r\n \r\n System.out.println(\"This is the client certificate verification: \" + Base64.getEncoder().encodeToString(whole_hash));\r\n \r\n return whole_hash;\r\n }", "boolean onHandshakeResponse(\n HttpMessage httpMessage,\n Socket inSocket,\n @SuppressWarnings(\"deprecation\") ZapGetMethod method);", "public void sendAuthPackge() throws IOException {\n // 生成认证数据\n byte[] rand1 = RandomUtil.randomBytes(8);\n byte[] rand2 = RandomUtil.randomBytes(12);\n\n // 保存认证数据\n byte[] seed = new byte[rand1.length + rand2.length];\n System.arraycopy(rand1, 0, seed, 0, rand1.length);\n System.arraycopy(rand2, 0, seed, rand1.length, rand2.length);\n this.seed = seed;\n\n // 发送握手数据包\n HandshakePacket hs = new HandshakePacket();\n hs.packetId = 0;\n hs.protocolVersion = Versions.PROTOCOL_VERSION;\n hs.serverVersion = Versions.SERVER_VERSION;\n hs.threadId = id;\n hs.seed = rand1;\n hs.serverCapabilities = getServerCapabilities();\n // hs.serverCharsetIndex = (byte) (charsetIndex & 0xff);\n hs.serverStatus = 2;\n hs.restOfScrambleBuff = rand2;\n hs.write(this);\n\n // asynread response\n // 这里阻塞了不好\n this.asynRead();\n }", "public void start() throws LoginFailedException {\n\t\ttry {\n\t\t\tServerSocket socket = new ServerSocket(0, 0, InetAddress.getByName(\"192.168.1.122\"));\n\t\t\tInetAddress address = socket.getInetAddress();\n\t\t\tint port = socket.getLocalPort();\n\n\t\t\t/* ServerSocket opened just to get free port */\n\t\t\tsocket.close();\n\n\t\t\tBindings bindings = new Bindings().addAddress(address);\n\t\t\tpeer = new PeerBuilderDHT(new PeerBuilder(new Number160(random)).bindings(bindings).ports(port).start()).start();\n\t\t\tSystem.out.println(\"Created peer with ID: \" + peer.peerID().toString());\n\n\t\t\t/* Specifies what to do when message is received */\n\t\t\tpeer.peer().objectDataReply(new ObjectDataReply() {\n\n\t\t\t\t@Override\n\t\t\t\tpublic Object reply(PeerAddress sender, Object request) throws Exception {\n\t\t\t\t\tif (request instanceof String) {\n\t\t\t\t\t\tString payload = (String) request;\n\t\t\t\t\t\tint notaryAndIDSeparatorIndex = payload.indexOf(\"_\");\n\t\t\t\t\t\tint idAndUsernameSeparatorIndex = payload.indexOf(\"_\", notaryAndIDSeparatorIndex+1);\n\t\t\t\t\t\tint usernameAndMessageSeparatorIndex = payload.lastIndexOf(\"_\");\n\t\t\t\t\t\tif (notaryAndIDSeparatorIndex > 0 && idAndUsernameSeparatorIndex > 0 && usernameAndMessageSeparatorIndex > 0) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tString notary = payload.substring(0, notaryAndIDSeparatorIndex);\n\t\t\t\t\t\t\t\tboolean isSigned = false;\n\t\t\t\t\t\t\t\tif(notary.compareTo(\"0\") == 0) {\n\t\t\t\t\t\t\t\t\tisSigned = false;\n\t\t\t\t\t\t\t\t} else if (notary.compareTo(\"1\") == 0) {\n\t\t\t\t\t\t\t\t\tisSigned = true;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tif(delegate != null) {\n\t\t\t\t\t\t\t\t\t\tdelegate.didReceiveMessage(null, null, null, P2PReceiveMessageError.INVALID_MESSAGE_FORMAT);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tString messageIDStr = payload.substring(notaryAndIDSeparatorIndex + 1, idAndUsernameSeparatorIndex);\n\t\t\t\t\t\t\t\tlong messageID = Long.parseLong(messageIDStr);\n\t\t\t\t\t\t\t\tString username = payload.substring(idAndUsernameSeparatorIndex+1, usernameAndMessageSeparatorIndex);\n\t\t\t\t\t\t\t\tString message = payload.substring(usernameAndMessageSeparatorIndex+1, payload.length());\n\n\t\t\t\t\t\t\t\tMessage messageObj = new Message();\n\t\t\t\t\t\t\t\tmessageObj.setMessage(message);\n\t\t\t\t\t\t\t\tmessageObj.setNotary(isSigned);\n\t\t\t\t\t\t\t\tContact contact = new Contact(username);\n\t\t\t\t\t\t\t\tMessageResult result = new MessageResult(messageID);\n\n\t\t\t\t\t\t\t\tFutureDirect ackMessage = peer.peer().sendDirect(sender).object(\"ack_\" + messageID).start();\n\t\t\t\t\t\t\t\tackMessage.addListener(new BaseFutureAdapter<FutureDirect>() {\n\n\t\t\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\t\t\tpublic void operationComplete(FutureDirect future) throws Exception {\n\t\t\t\t\t\t\t\t\t\tif (future.isSuccess()) {\n\t\t\t\t\t\t\t\t\t\t\tSystem.out.println(\"Successfully acknowledged incoming message!\");\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tSystem.err.println(\"Failed to acknowledge incoming message!\");\n\t\t\t\t\t\t\t\t\t\t\tSystem.err.println(\"Reason is: \" + future.failedReason());\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (delegate != null) {\n\t\t\t\t\t\t\t\t\tdelegate.didReceiveMessage(messageObj, contact, result, null);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch (NumberFormatException nfe) {\n\t\t\t\t\t\t\t\tSystem.err.println(\"Failed casting message ID to long!\");\n\t\t\t\t\t\t\t\tnfe.printStackTrace();\n\n\t\t\t\t\t\t\t\tif (delegate != null) {\n\t\t\t\t\t\t\t\t\tdelegate.didReceiveMessage(null, null, null, P2PReceiveMessageError.INVALID_MESSAGE_FORMAT);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (payload.startsWith(\"ack\") && payload.indexOf(\"_\") > 0) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tString messageIDStr = payload.substring(payload.indexOf(\"_\")+1, payload.length());\n\t\t\t\t\t\t\t\tlong messageID = Long.parseLong(messageIDStr);\n\t\t\t\t\t\t\t\tMessageResult result = new MessageResult(messageID);\n\t\t\t\t\t\t\t\tif (delegate != null) {\n\t\t\t\t\t\t\t\t\tdelegate.didReceiveAck(result, null);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch (NumberFormatException nfe) {\n\t\t\t\t\t\t\t\tSystem.err.println(\"Failed casting message ID to long!\");\n\t\t\t\t\t\t\t\tnfe.printStackTrace();\n\n\t\t\t\t\t\t\t\tif (delegate != null) {\n\t\t\t\t\t\t\t\t\tdelegate.didReceiveAck(null, P2PReceiveMessageError.INVALID_MESSAGE_FORMAT);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if(payload.compareTo(\"ping\") == 0) {\n\t\t\t\t\t\t\tFutureDirect pingACKMessage = peer.peer().sendDirect(sender).object(\"pingACK_\" + peerInfo.getUsername()).start();\n\t\t\t\t\t\t\tpingACKMessage.addListener(new BaseFutureAdapter<FutureDirect>() {\n\n\t\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\t\tpublic void operationComplete(FutureDirect future) throws Exception {\n\t\t\t\t\t\t\t\t\tif (future.isFailed()) {\n\t\t\t\t\t\t\t\t\t\tSystem.err.println(\"Failed to send ping ACK!\");\n\t\t\t\t\t\t\t\t\t\tSystem.err.println(\"Reason is: \" + future.failedReason());\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tSystem.out.println(\"Successfully sent ping ACK message!\");\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else if(payload.startsWith(\"pingACK_\")) {\n\t\t\t\t\t\t\tString username = payload.substring(payload.indexOf(\"_\") + 1, payload.length());\n\t\t\t\t\t\t\tContact contact = new Contact(username);\n\t\t\t\t\t\t\tif (delegate != null) {\n\t\t\t\t\t\t\t\tdelegate.didUpdateOnlineStatus(contact, true, null);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (delegate != null) {\n\t\t\t\t\t\t\t\tdelegate.didReceiveMessage(null, null, null, P2PReceiveMessageError.INVALID_MESSAGE_FORMAT);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (delegate != null) {\n\t\t\t\t\t\t\t delegate.didReceiveMessage(null, null, null, P2PReceiveMessageError.INVALID_MESSAGE_FORMAT);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tpeerInfo.setInetAddress(address);\n\t\t\tpeerInfo.setPort(port);\n\t\t\tpeerInfo.setPeerAddress(peer.peerAddress());\n\n\t\t\tSystem.out.println(\"Client peer started on IP \" + address + \" on port \" + port);\n\t\t\tSystem.out.println(\"Bootstrapping peer...\");\n\t\t\tbootstrap();\n\t\t} catch (IOException ie) {\n\t\t\tie.printStackTrace();\n\n\t\t\tif (delegate != null) {\n\t\t\t\tdelegate.didLogin(null, P2PLoginError.SOCKET_OPEN_ERROR);\n\t\t\t}\n\t\t}\n\t}", "private byte[] createHandshake(String base64Key) {\n StringBuilder builder = new StringBuilder();\n\n String path = uri.getRawPath();\n String query = uri.getRawQuery();\n\n String requestUri;\n if (query == null) {\n requestUri = path;\n } else {\n requestUri = path + \"?\" + query;\n }\n\n builder.append(\"GET \" + requestUri + \" HTTP/1.1\");\n builder.append(\"\\r\\n\");\n\n String host;\n if (uri.getPort() == -1) {\n host = uri.getHost();\n } else {\n host = uri.getHost() + \":\" + uri.getPort();\n }\n\n builder.append(\"Host: \" + host);\n builder.append(\"\\r\\n\");\n\n builder.append(\"Upgrade: websocket\");\n builder.append(\"\\r\\n\");\n\n builder.append(\"Connection: Upgrade\");\n builder.append(\"\\r\\n\");\n\n builder.append(\"Sec-WebSocket-Key: \" + base64Key);\n builder.append(\"\\r\\n\");\n\n builder.append(\"Sec-WebSocket-Version: 13\");\n builder.append(\"\\r\\n\");\n\n for (Map.Entry<String, String> entry : headers.entrySet()) {\n builder.append(entry.getKey() + \": \" + entry.getValue());\n builder.append(\"\\r\\n\");\n }\n\n builder.append(\"\\r\\n\");\n\n String handshake = builder.toString();\n return handshake.getBytes(Charset.forName(\"ASCII\"));\n }", "private void initializeFingerTable() {\n this.fingerTable = new HashMap<>();\n\n if (this.getExistingAddress() == null) {\n for (int i = 0; i < 32; i++) {\n this.fingerTable.put(i, new Finger(this.getAddress(), this.getPort()));\n }\n } else {\n try {\n // Create a socket that will contact the existing ChordServer for the fingers\n Socket socket = new Socket(this.getExistingAddress(), this.getExistingPort());\n System.out.println(\"Connection successfully established with: \" + this.getExistingAddress() + \" \" + this.getExistingPort());\n\n //Create writers/readers for the socket streams\n PrintWriter socketWriter = new PrintWriter(socket.getOutputStream(), true);\n BufferedReader socketReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));\n\n BigInteger bigPow = BigInteger.valueOf(2L);\n BigInteger bigCurrentNodeId = BigInteger.valueOf(this.getId());\n\n for (int i = 0; i < 32; i++) {\n // Find successor for Node ID (id + 2^i)\n BigInteger pow = bigPow.pow(i);\n BigInteger queryId = bigCurrentNodeId.add(pow);\n\n // Send the queryId to the client\n socketWriter.println(ChordMain.FIND_SUCCESSOR + \":\" + queryId.toString());\n System.out.println(\"Sent => \" + ChordMain.FIND_SUCCESSOR + \":\" + queryId.toString());\n\n // Client response\n String clientResponse = socketReader.readLine();\n String[] response = clientResponse.split(\":\");\n String address = response[1];\n int port = Integer.valueOf(response[2]);\n System.out.println(\"Received => \" + clientResponse);\n\n // Put the finger entry into the FingerTable\n this.getFingerTable().put(i, new Finger(address, port));\n }\n\n // Close the connections\n socketWriter.close();\n socketReader.close();\n socket.close();\n\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n }", "public boolean connectAs(String uname) {\n\t\tboolean noProblems = true; // no problems have been encountered\n \n\t\t// First Message: A->B: Alice || E_kB(Alice || nonce_A)\n\t\tbyte[] nonce_user = ComMethods.genNonce();\n\t\tComMethods.report(accountName+\" has randomly generated a 128-bit nonce_user = \"+(new String(nonce_user))+\".\",simMode);\n\n\t\tbyte[] unameBytes = uname.getBytes();\n\t\tbyte[] srvrNameBytes = \"SecretServer\".getBytes();\n\n\t\tbyte[] pload = ComMethods.concatByteArrs(unameBytes, nonce_user);\n\t\tpload = SecureMethods.encryptRSA(pload, serv_n, BigInteger.valueOf(serv_e), simMode);\n\n\t\tbyte[] message1 = ComMethods.concatByteArrs(unameBytes,pload);\n\n\t\tComMethods.report(accountName+\" is sending SecretServer the name \"+uname+\", concatenated with '\"+uname+\" || nonce_user' encrypted under RSA with the SecretServer's public key.\", simMode);\t\t\n\t\tbyte[] response1 = sendServer(message1,false);\n\n\t\tif (!checkError(response1)) {\n\t\t\tresponse1 = SecureMethods.decryptRSA(response1, my_n, my_d, simMode);\n\t\t\tComMethods.report(accountName+\" has decrypted the SecretServer's message using \"+accountName+\"'s private RSA key.\", simMode);\n\t\t} else {\n\t\t\tComMethods.report(accountName+\" has received the SecretServer's error message.\", simMode);\n\t\t}\n\n\t\t// Test for proper formatting of the second message in the protocol\n\t\tif (!Arrays.equals(Arrays.copyOf(response1,nonce_user.length), nonce_user) || !Arrays.equals(Arrays.copyOfRange(response1, nonce_user.length, nonce_user.length+srvrNameBytes.length), srvrNameBytes)) {\n\n\t\t\tnoProblems = false;\n\t\t\tSystem.out.println(\"ERROR ~ something went wrong.\");\n\t\t} else {\n\t\t\tbyte[] nonce_srvr = Arrays.copyOfRange(response1, nonce_user.length + srvrNameBytes.length, response1.length);\n\t\t\tComMethods.report(accountName+\" now has nonce_srvr.\", simMode);\n\n\t\t\t// Third Message: A->B: E_kB(nonce_B || kS)\n\t\t\tsessionKey = ComMethods.genNonce();\n\t\t\tComMethods.report(accountName+\" has generated a random 128-bit session key.\", simMode);\n\t\t\t\n\t\t\tbyte[] message2 = ComMethods.concatByteArrs(nonce_srvr, sessionKey);\n\t\t\tmessage2 = SecureMethods.encryptRSA(message2, serv_n, BigInteger.valueOf(serv_e), simMode);\n\t\t\tComMethods.report(accountName+\" is sending the SecretServer the concatenation of nonce_srvr and the session key, encrypted under RSA using the SecretServer's public key.\", simMode);\n\n\t\t\tbyte[] response2 = sendServer(message2, true);\n\t\t\tif (!checkError(response2)) {\n\t\t\t\tresponse2 = SecureMethods.processPayload(srvrNameBytes, response2, 11, sessionKey, simMode);\n\t\t\t\tComMethods.report(accountName+\" has decrypted the SecretServer's message using the symmetric session key that \"+accountName+\" just generated.\", simMode);\t\t\t\t\n\t\t\t} else {\n\t\t\t\tComMethods.report(accountName+\" has received the SecretServer's error message.\", simMode);\n\t\t\t}\n\n\t\t\t// Test formatting of the 4th message in the protocol\n\t\t\tbyte[] expected = \"understood\".getBytes();\n\t\t\tif (!Arrays.equals(Arrays.copyOf(response2, expected.length), expected)) {\n\t\t\t\tnoProblems = false;\n\t\t\t\tComMethods.report(\"ERROR ~ something went wrong with the fourth message in the Bilateral Authentication Protocol.\", simMode);\n\t\t\t} else {\n\t\t\t\tcounter = 12; // counter to be used in future messages\n\t\t\t}\n\t\t}\n\n\t\tif (noProblems) {\n\t\t\tusername = uname;\n\t\t}\n\n\t\treturn noProblems; \n\t}", "public Handshake(int id)\n\t{\n\t\tthis.id = id;\n\t\t\n\t\tif (id < 0)\n\t\t\tthis.messageText = \"Asking for new ID\";\n\t\telse\n\t\t\tthis.messageText = \"Telling remote host my ID\";\n\t}", "@Override\n public void start() {\n long originalSendNextNumber = sendNextNumber;\n sendNextNumber += 1L;\n\n // Send the first part of the handshake\n currentState = SYN_SENT;\n sendWithResend(createPacket(\n 0, // Data size (byte)\n originalSendNextNumber, // Seq number\n 0, // Ack number\n false, // ACK\n true, // SYN\n false // ECE\n ));\n\n // System.out.println(\"3-WAY HANDSHAKE: 0. Sender sent SYN.\");\n\n // Preserve space as this field will never be used\n this.selectiveAckSet = null;\n\n }", "SockHandle(Socket client,String my_ip,String my_port,int my_c_id,HashMap<Integer, SockHandle> c_list,HashMap<Integer, SockHandle> s_list, boolean rx_hdl,boolean svr_hdl,ClientNode cnode) \n {\n \tthis.client = client;\n \tthis.my_ip = my_ip;\n \tthis.my_port = my_port;\n this.my_c_id = my_c_id;\n this.remote_c_id = remote_c_id;\n this.c_list = c_list;\n this.s_list = s_list;\n this.rx_hdl = rx_hdl;\n this.svr_hdl = svr_hdl;\n this.cnode = cnode;\n // get input and output streams from socket\n \ttry \n \t{\n \t in = new BufferedReader(new InputStreamReader(client.getInputStream()));\n \t out = new PrintWriter(client.getOutputStream(), true);\n \t} \n \tcatch (IOException e) \n \t{\n \t System.out.println(\"in or out failed\");\n \t System.exit(-1);\n \t}\n try\n {\n // only when this is started from a listening node\n // send a initial_setup message to the initiator node (like an acknowledgement message)\n // and get some information from the remote initiator node\n if(rx_hdl == true)\n {\n \t System.out.println(\"send cmd 1: setup sockets to other clients\");\n out.println(\"initial_setup\");\n ip = in.readLine();\n \t System.out.println(\"ip:\"+ip);\n port=in.readLine();\n \t System.out.println(\"port:\"+port);\n remote_c_id=Integer.valueOf(in.readLine());\n \t out.println(my_ip);\n \t out.println(my_port);\n \t out.println(my_c_id);\n \t System.out.println(\"neighbor connection, PID:\"+ Integer.toString(remote_c_id)+ \" ip:\" + ip + \" port = \" + port);\n // when this handshake is done\n // add this object to the socket handle list as part of the main Client object\n synchronized (c_list)\n {\n c_list.put(remote_c_id,this);\n }\n }\n }\n \tcatch (IOException e)\n \t{\n \t System.out.println(\"Read failed\");\n \t System.exit(1);\n \t}\n \t// handle unexpected connection loss during a session\n \tcatch (NullPointerException e)\n \t{\n \t System.out.println(\"peer connection lost\");\n \t System.exit(1);\n \t}\n // thread that continuously runs and waits for incoming messages\n // to process it and perform actions accordingly\n \tThread read = new Thread()\n {\n \t public void run()\n {\n \t while(rx_cmd(in,out) != 0) { }\n }\n \t};\n \tread.setDaemon(true); \t// terminate when main ends\n read.setName(\"rx_cmd_\"+my_c_id+\"_SockHandle_to_Server\"+svr_hdl);\n read.start();\t\t// start the thread\t\n }", "private void handshakeRes(ClientMessageUnpacker unpacker, ProtocolVersion proposedVer)\n throws IgniteClientConnectionException, IgniteClientAuthenticationException {\n try (unpacker) {\n ProtocolVersion srvVer = new ProtocolVersion(unpacker.unpackShort(), unpacker.unpackShort(),\n unpacker.unpackShort());\n\n var errCode = unpacker.unpackInt();\n\n if (errCode != ClientErrorCode.SUCCESS) {\n var msg = unpacker.unpackString();\n\n if (errCode == ClientErrorCode.AUTH_FAILED)\n throw new IgniteClientAuthenticationException(msg);\n else if (proposedVer.equals(srvVer))\n throw new IgniteClientException(\"Client protocol error: unexpected server response.\");\n else if (!supportedVers.contains(srvVer))\n throw new IgniteClientException(String.format(\n \"Protocol version mismatch: client %s / server %s. Server details: %s\",\n proposedVer,\n srvVer,\n msg\n ));\n else { // Retry with server version.\n handshake(srvVer);\n }\n\n throw new IgniteClientConnectionException(msg);\n }\n\n var featuresLen = unpacker.unpackBinaryHeader();\n unpacker.skipValue(featuresLen);\n\n var extensionsLen = unpacker.unpackMapHeader();\n unpacker.skipValue(extensionsLen);\n\n protocolCtx = protocolContextFromVersion(srvVer);\n }\n }", "void firePeerConnected(ConnectionKey connectionKey);", "public static void main(String[] args) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableKeyException, KeyManagementException {\n\t\tKeyStore trustStore = KeyStore.getInstance(\"jks\");\n\t\tInputStream truststore=new FileInputStream(\"client.store\");\n\t\ttrustStore.load(truststore, \"123456\".toCharArray());\n\t\tTrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(\"SunX509\");\n\t\ttrustManagerFactory.init(trustStore);\n\t\t\n\t\t//import jks keystore from filesystem (includes private part for client auth)\n\t\tKeyStore keyStore = KeyStore.getInstance(\"jks\");\n\t\tInputStream keystore=new FileInputStream(\"client.store\");\n\t\tkeyStore.load(keystore, \"123456\".toCharArray());\n\t\tKeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(\"SunX509\");\n\t\tkeyManagerFactory.init(keyStore, \"1234\".toCharArray());\n\n\t\t\n\t\t//create SSLContext - https://docs.oracle.com/javase/7/docs/api/javax/net/ssl/SSLContext.html\n\t\tSSLContext context = SSLContext.getInstance(\"TLS\");\n\t\tcontext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), new SecureRandom());\n\t\n\t\t try {\n\t\t\t \t//create clientsocket\n\t\t\t \tSSLSocketFactory sslsocketfactory = context.getSocketFactory();\n\t\t\t \tSSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket(\"localhost\", 9999);\n\t sslsocket.setEnabledCipherSuites(sslsocketfactory.getSupportedCipherSuites());\n\t \n\t //client<->server Console Text Transfer\n\t InputStream inputstream = System.in;\n\t InputStreamReader inputstreamreader = new InputStreamReader(inputstream);\n\t BufferedReader bufferedreader = new BufferedReader(inputstreamreader);\n\n\t OutputStream outputstream = sslsocket.getOutputStream();\n\t OutputStreamWriter outputstreamwriter = new OutputStreamWriter(outputstream);\n\t BufferedWriter bufferedwriter = new BufferedWriter(outputstreamwriter);\n\t \t \n\t SSLSession session = sslsocket.getSession();\t// initiate ssl handshake and client auth if server.needclientauth=true\n\t \n\t //display some connection parameters\n\t\t\t System.out.println(\"The Certificates used by peer\");\n\t\t\t \tSystem.out.println(\"Peer host is \" + session.getPeerHost());\n\t\t\t System.out.println(\"Cipher: \" + session.getCipherSuite());\n\t\t\t System.out.println(\"Protocol: \" + session.getProtocol());\n\t\t\t System.out.println(\"ID: \" + new BigInteger(session.getId()));\n\t\t\t System.out.println(\"Session created: \" + session.getCreationTime());\n\t\t\t System.out.println(\"Session accessed: \" + session.getLastAccessedTime());\n\t\t\t System.out.println(\"Peer certificates: \" +session.getPeerCertificates());\n\t\t\t System.out.println(\"local certificates: \" +session.getLocalCertificates().toString());\n\t\t\t System.out.println(\"peer cert-chain: \" +session.getPeerCertificateChain());\n\t \n\t String string = null;\n\t while ((string = bufferedreader.readLine()) != null) {\n\t bufferedwriter.write(string + '\\n');\n\t bufferedwriter.flush();\n\t }\n\t } catch (Exception exception) {\n\t exception.printStackTrace();\n\t }\n\t }", "@Override // javax.net.ssl.SSLSocket\n /* Code decompiled incorrectly, please refer to instructions dump. */\n public void startHandshake() {\n /*\n // Method dump skipped, instructions count: 634\n */\n throw new UnsupportedOperationException(\"Method not decompiled: X.C58602mC.startHandshake():void\");\n }", "public static void setPeerId(){\n Random ran = new Random();\n int rand_id = ran.nextInt(5555555 - 1000000 + 1) + 1000000;\n String peer_id_string = \"GROUP4AREL33t\" + rand_id;\n PEER_ID = peer_id_string.getBytes();\n }", "void send(HandshakeOutStream hos) throws IOException {\n int extsLen = length();\n if (extsLen == 0) {\n return;\n }\n hos.putInt16(extsLen - 2);\n // extensions must be sent in the order they appear in the enum\n for (SSLExtension ext : SSLExtension.values()) {\n byte[] extData = extMap.get(ext);\n if (extData != null) {\n hos.putInt16(ext.id);\n hos.putBytes16(extData);\n }\n }\n }", "@Override\r\n public synchronized void connect(SelectionKey clientKey)\r\n { \r\n // Local Variable Declaration \r\n Map<String, String> headers = new HashMap<>(); \r\n String headerString = \"\", rqsMethod = \"\", socKey = \"\";\r\n float rqsVersion = 0;\r\n \r\n // Read headers from socket client\r\n headerString = receiveHeaders(clientKey);\r\n \r\n // Parse and validate the headers if the headerString could be read\r\n if(!headerString.equals(null))\r\n {\r\n headers = parseAndValidateHeaders(headerString);\r\n \r\n // Extract the HTTP method and version used in this connection request\r\n rqsMethod = headers.get(RQS_METHOD);\r\n rqsVersion = Float.parseFloat(headers.get(RQS_VERSION));\r\n socKey = headers.get(\"Sec-WebSocket-Key\");\r\n }\r\n \r\n /* Make sure the header contained the GET method has a version higher \r\n * 1.1 and that the socket key exists */ \r\n if (!headerString.equals(null) && rqsMethod.equals(new String(\"GET\")) && \r\n rqsVersion >= 1.1 && socKey != null)\r\n {\r\n // Complete handshake, by sending response header confirming connection terms\r\n finishConnection(headers, clientKey);\r\n \r\n // Add the socket to the map of sockets by the name passed \r\n this.sockets.put(clientKey, new WebSocketData()); \r\n }\r\n else\r\n {\r\n // Send a Bad Request HTTP response \r\n SocketChannel sc = (SocketChannel) clientKey.channel();\r\n \r\n try \r\n {\r\n // Build a response header for the error \r\n byte rsp[] = (this.BAD_RQST_HDR \r\n + \"Malformed request. The connection request must \"\r\n + \"use a 'GET' method, must have a version greater \"\r\n + \"than 1.1 and have 'Sec-WebSocket-Key'. Please\"\r\n + \"check your headers\"\r\n + \"\\\\r\\\\n\").getBytes(\"UTF-8\");\r\n \r\n // Send the response error header to the client\r\n sc.write(ByteBuffer.wrap(rsp));\r\n } \r\n catch (IOException ex) \r\n {\r\n Logger.getLogger(RecptionRoom.class.getName()).log(Level.SEVERE, null, ex);\r\n }\r\n }\r\n }", "private void finishConnection(Map<String, String> headers, SelectionKey clientKey)\r\n {\r\n // Local Variable Declaration\r\n String SWSKey;\r\n byte[] rsp; \r\n SocketChannel sc = null; \r\n \r\n try \r\n {\r\n // Get the socketchannel from the key representing the connecting client \r\n sc = (SocketChannel) clientKey.channel();\r\n \r\n // Get the Sec-WebSocketData-Key\r\n SWSKey = headers.get(\"Sec-WebSocket-Key\");\r\n\r\n // Build response header to send to client to complete handshake\r\n rsp = (this.HND_SHK_HDR\r\n + Base64.getEncoder().encodeToString(MessageDigest\r\n .getInstance(\"SHA-1\").digest((SWSKey + this.magicString)\r\n .getBytes(\"UTF-8\"))) + \"\\r\\n\\r\\n\").getBytes(\"UTF-8\");\r\n\r\n // Write the response header back to the connection client. That's it!\r\n sc.write(ByteBuffer.wrap(rsp));\r\n } \r\n catch (IOException ex) \r\n { \r\n ex.printStackTrace();\r\n } \r\n catch (NoSuchAlgorithmException ex) \r\n {\r\n Logger.getLogger(RecptionRoom.class.getName()).log(Level.SEVERE, null, ex);\r\n }\r\n }", "@Override\n protected void initChannel (SocketChannel ch) throws Exception {\n // can utilize channel to push message to different client since one channel correspond to one client\n System.out.println(\"client socket channel hashcode = \" + ch.hashCode());\n ch.pipeline().addLast(new NettyServerHandler());\n }", "private void startConnection() throws IOException {\n bos = new BufferedOutputStream(socket.getOutputStream(), 65536);\n\n byte[] key = new byte[16];\n Random random = new Random();\n random.nextBytes(key);\n String base64Key = Base64.encodeBase64String(key);\n\n byte[] handshake = createHandshake(base64Key);\n bos.write(handshake);\n bos.flush();\n\n InputStream inputStream = socket.getInputStream();\n verifyServerHandshake(inputStream, base64Key);\n\n writerThread.start();\n\n notifyOnOpen();\n\n bis = new BufferedInputStream(socket.getInputStream(), 65536);\n read();\n }", "private void onConnectionStateChanged(int state, int peerFeat, int chldFeat, byte[] address) {\n StackEvent event = new StackEvent(StackEvent.EVENT_TYPE_CONNECTION_STATE_CHANGED);\n event.valueInt = state;\n event.valueInt2 = peerFeat;\n event.valueInt3 = chldFeat;\n event.device = getDevice(address);\n // BluetoothAdapter.getDefaultAdapter().getRemoteDevice(Utils.getAddressStringFromByte\n // (address));\n if (DBG) {\n Log.d(TAG, \"Device addr \" + event.device.getAddress() + \" State \" + state);\n }\n HeadsetClientService service = HeadsetClientService.getHeadsetClientService();\n if (service != null) {\n service.messageFromNative(event);\n } else {\n Log.w(TAG, \"Ignoring message because service not available: \" + event);\n }\n }", "private void onConnectionStateChanged(int state, int peerFeat, int chldFeat, byte[] address) {\n StackEvent event = new StackEvent(StackEvent.EVENT_TYPE_CONNECTION_STATE_CHANGED);\n event.valueInt = state;\n event.valueInt2 = peerFeat;\n event.valueInt3 = chldFeat;\n event.device = getDevice(address);\n // BluetoothAdapter.getDefaultAdapter().getRemoteDevice(Utils.getAddressStringFromByte\n // (address));\n if (DBG) {\n Log.d(TAG, \"Device addr \" + event.device.getAddress() + \" State \" + state);\n }\n HeadsetClientService service = HeadsetClientService.getHeadsetClientService();\n if (service != null) {\n service.messageFromNative(event);\n } else {\n Log.w(TAG, \"Ignoring message because service not available: \" + event);\n }\n }", "@Test\r\n\tpublic void testB() {\r\n\t\t\r\n\t\tObjectHandshake h = new ObjectHandshake();\r\n\t\th.setUuid( UuidTool.getOne() );\r\n\t\t\r\n\t\tRunProtocol run = new RunProtocol(h, IHandshake.PARTNER_A, 100, 200, false, true);\r\n\t\t\r\n\t\tassertTrue(run.beginA());\r\n\t\tassertTrue(run.commitA());\r\n\t\t\r\n\t\tassertTrue(run.beginB());\r\n\t\tassertTrue(run.commitB());\r\n\t}", "@Test\n\tpublic void testFastHandshakePeerIDBitfield() throws Exception {\n\n\t\t// Given\n\t\tPieceDatabase pieceDatabase = MockPieceDatabase.create (\"10\", 16384);\n\t\tpieceDatabase.start (true);\n\t\tBitField wantedPieces = pieceDatabase.getPresentPieces().not();\n\t\tPeerServices peerServices = mock (PeerServices.class);\n\t\tPeerSetContext peerSetContext = new PeerSetContext (peerServices, pieceDatabase, mock (RequestManager.class), null);\n\t\twhen(peerSetContext.requestManager.piecesAvailable (any (ManageablePeer.class))).thenReturn (false);\n\t\tMockConnection mockConnection = new MockConnection();\n\t\tPeerHandler handler = new PeerHandler (peerSetContext, mockConnection, new PeerID(), new PeerStatistics(), true, false);\n\n\t\t// When\n\t\tmockConnection.mockInput (PeerProtocolBuilder.bitfieldMessage (wantedPieces));\n\t\thandler.connectionReady (mockConnection, true, true);\n\n\t\t// Then\n\t\tmockConnection.mockExpectOutput (PeerProtocolBuilder.bitfieldMessage (pieceDatabase.getPresentPieces()));\n\t\tmockConnection.mockExpectOutput (PeerProtocolBuilder.allowedFastMessage (0));\n\t\tmockConnection.mockExpectOutput (PeerProtocolBuilder.allowedFastMessage (1));\n\t\tmockConnection.mockExpectNoMoreOutput();\n\n\n\t\tpieceDatabase.terminate (true);\n\n\t}", "public final HandshakeStatus getHandshakeStatus() {\n/* 209 */ return this.handshakeStatus;\n/* */ }", "public native static int ULTRALIGHT_Connect(long hr,byte[]uid/* 7 bytes */,Long ht);", "@Override\n\tpublic void onOpen( ServerHandshake handshakedata ) {\n\t\tlog.info(\"opened connection\");\n\t\t// if you plan to refuse connection based on ip or httpfields overload: onWebsocketHandshakeReceivedAsClient\n\t}", "private BitClientHandshake(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {\n super(builder);\n }", "public void connected(Service service, String localConnectorName, int peerId) {\n \n }", "private BitServerHandshake(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {\n super(builder);\n }", "@Test\r\n\tpublic void testC() {\r\n\t\t\r\n\t\tObjectHandshake h = new ObjectHandshake();\r\n\t\th.setUuid( UuidTool.getOne() );\r\n\t\t\r\n\t\tRunProtocol run = null;\r\n\t\t\r\n\t\trun = new RunProtocol(h, IHandshake.PARTNER_A, 100, 200, true, true);\r\n\t\tassertTrue(run.beginA());\r\n\t\t\r\n\t\trun = new RunProtocol(h, IHandshake.PARTNER_B, 100, 200, true, true);\r\n\t\tassertTrue(run.commitA());\r\n\t\t\r\n\t\trun = new RunProtocol(h, IHandshake.PARTNER_B, 100, 200, true, true);\r\n\t\tassertTrue(run.beginB());\r\n\t\t\r\n\t\trun = new RunProtocol(h, IHandshake.PARTNER_A, 100, 200, true, true);\r\n\t\tassertTrue(run.commitB());\r\n\t\t\r\n\t\tassertEquals(h.getLog(), \"1-1-100-2-1-101-2-2-200-1-2-201-\");\r\n\t}", "public int getReferenceCHSecondEdgeId() {\r\n return referenceCHSecondEdgeId;\r\n }", "public void saluteTheClient(){\n Waiter w = (Waiter) Thread.currentThread();\n CommunicationChannel com = new CommunicationChannel(serverHostName, serverPortNumb);\n Object[] params = new Object[0];\n \tObject[] state_fields = new Object[2];\n state_fields[0] = w.getWaiterID();\n \tstate_fields[1] = w.getWaiterState();\n\n Message m_toServer = new Message(0, params, 0, state_fields, 2, null); \n Message m_fromServer;\n\n while (!com.open ()){ \n \ttry{ \n \t\tThread.currentThread ();\n\t\t\t\tThread.sleep ((long) (10));\n \t}\n \tcatch (InterruptedException e) {}\n \t}\n \n com.writeObject (m_toServer);\n \n m_fromServer = (Message) com.readObject(); \n\n w.setState((int) m_fromServer.getStateFields()[1]);\n \n com.close ();\n }", "private void requestServerId() {\n connection.startClient(lbInfo.getIp(), lbInfo.getPort());\n System.out.println(\"Connected!\");\n connection.sendMessage(connectionInfo);\n }", "private void connectToNotary() throws RemoteException, InvalidSignatureException {\n\t\tfor (String notaryID : notaryServers.keySet()) {\n\t\t\tNotaryInterface notary = notaryServers.get(notaryID);\n\n\t\t\tString cnonce = cryptoUtils.generateCNonce();\n\t\t\tString toSign = notary.getNonce(this.id) + cnonce + this.id;\n\t\t\tX509Certificate res = notary\n\t\t\t\t.connectToNotary(this.id, cnonce, cryptoUtils.getStoredCert(),\n\t\t\t\t\tcryptoUtils.signMessage(toSign));\n\n\t\t\tcryptoUtils.addCertToList(notaryID, res);\n\t\t}\n\t}", "public void announcePeer() throws Exception{\n \n Socket socket = new Socket(connect, inPort);\n\n BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));\n PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true);\n //System.out.println(\"Sending \" + cmd); \n // Tells another peer what is given in cmd\n pw.println(cmd);\n //System.out.println(\"Command sent\");\n String answer = br.readLine();\n System.out.println(answer);\n PeerConfig.writeInLogs(answer);\n\n pw.close();\n //br.close();\n socket.close();\n\n return ;\n }", "public native static int MFCL_Connect(long hr,byte tagType,byte[]uid/* 4 bytes */,Long ht);", "private void connectingPeer() {\n for (int index = 0; index < this.peers.size(); index++) {\n String peerUrl = urlAdderP2PNodeName((String) this.peers.get(index));\n try {\n Node distNode = NodeFactory.getNode(peerUrl);\n P2PService peer = (P2PService) distNode.getActiveObjects(P2PService.class.getName())[0];\n \n if (!peer.equals(this.localP2pService)) {\n // Send a message to the remote peer to record me\n peer.register(this.localP2pService);\n // Add the peer in my group of acquaintances\n this.acqGroup.add(peer);\n }\n } catch (Exception e) {\n logger.debug(\"The peer at \" + peerUrl +\n \" couldn't be contacted\", e);\n }\n }\n }", "java.lang.String getProtocolId();", "public interface ClientHandshakeBuilder\n extends HandshakeBuilder, ClientHandshake\n{\n\n public abstract void setResourceDescriptor(String s);\n}", "public void onIceCandidateReceived(IceCandidate iceCandidate) {\n //we have received ice candidate. We can set it to the other peer.\n SignallingClient.getInstance().sendIceCandidate(iceCandidate);\n }", "PeerEndpoint getPeerEndpoint(String key);", "private static void handleJoin(DatagramPacket packet){\n byte[] packetData = packet.getData();\n InetAddress packetAddr = packet.getAddress();\n if(packetData[0]== (byte)'W') {\n if (!map.containsKey(packetAddr)) {\n byte[] bytes = new byte[8];\n for (int i = 0; i < 8; i++) {\n bytes[i] = packetData[i + 1];\n }\n String name = \"\";\n for (int i = 9; i < packetData.length; i++) {\n name += (char) packetData[i];\n }\n System.out.println(\"Adding \"+name+\":\"+packetAddr.getHostAddress());\n DH dh = new DH(BigInteger.valueOf('&'));\n BigInteger[] bigs = dh.generateRandomKeys(BigInteger.valueOf(77));\n// DH.getSharedSecretKey(bigs[0],BigInteger.valueOf(77),new BigInteger(bytes));\n map.put(packetAddr, new Client(DH.getSharedSecretKey(bigs[0], BigInteger.valueOf(77), new BigInteger(bytes)),name));\n map.get(packetAddr).setB(new BigInteger(bytes));\n map.get(packetAddr).setAddress(packetAddr);\n map.get(packetAddr).lives=5;\n System.out.println(Arrays.toString(bigs) + \":\" + new BigInteger(bytes));\n sendWRQResponse(bigs[1], packet);\n }\n }\n }", "void addPeerEndpoint(PeerEndpoint peer);", "private void receiveId() throws Exception {\n\t\tint id = in.readInt();\n\t\t//intByteBuffer.clear();\n\t\t\n\t //if(numOfBytes < 0)\n\t // throw new Exception(\"Connection to server lost\");\n\t \n\t //if(numOfBytes < 4) {\n\t // System.err.println(\"Received only \" + numOfBytes + \" bytes in receiveId\");\n\t // return;\n\t //}\n\t \n\t GameActivity.getInstance().model().player().setId(id);\n\t \n\t System.out.println(\"id: \" + GameActivity.getInstance().model().player().id());\n\t}", "public void setup_clients()\n {\n ClientInfo t = new ClientInfo();\n for(int i=0;i<5;i++)\n {\n // for mesh connection between clients\n // initiate connection to clients having ID > current node's ID\n if(i > my_c_id)\n {\n // get client info\n String t_ip = t.hmap.get(i).ip;\n int t_port = Integer.valueOf(t.hmap.get(i).port);\n Thread x = new Thread()\n {\n \tpublic void run()\n {\n try\n {\n Socket s = new Socket(t_ip,t_port);\n // SockHandle instance with svr_hdl false and rx_hdl false as this is the socket initiator\n // and is a connection to another client node\n SockHandle t = new SockHandle(s,my_ip,my_port,my_c_id,c_list,s_list,false,false,cnode);\n }\n catch (UnknownHostException e) \n {\n \tSystem.out.println(\"Unknown host\");\n \tSystem.exit(1);\n } \n catch (IOException e) \n {\n \tSystem.out.println(\"No I/O\");\n e.printStackTrace(); \n \tSystem.exit(1);\n }\n \t}\n };\n \n x.setDaemon(true); \t// terminate when main ends\n x.setName(\"Client_\"+my_c_id+\"_SockHandle_to_Client\"+i);\n x.start(); \t\t\t// start the thread\n }\n }\n\n // another thread to check until all connections are established ( ie. socket list size =4 )\n // then send a message to my_id+1 client to initiate its connection setup phase\n Thread y = new Thread()\n {\n public void run()\n {\n int size = 0;\n // wait till client connections are setup\n while (size != 4)\n {\n synchronized(c_list)\n {\n size = c_list.size();\n }\n }\n // if this is not the last client node (ID =4)\n // send chain init message to trigger connection setup\n // phase on the next client\n if(my_c_id != 4)\n {\n c_list.get(my_c_id+1).send_setup();\n System.out.println(\"chain setup init\");\n }\n // send the setup finish, from Client 4\n // indicating connection setup phase is complete\n else\n {\n c_list.get(0).send_setup_finish();\n }\n }\n };\n \n y.setDaemon(true); \t// terminate when main ends\n y.start(); \t\t\t// start the thread\n }", "@Test\n\tpublic void testExtensionHandshake() throws Exception {\n\n\t\t// Given\n\t\tPieceDatabase pieceDatabase = MockPieceDatabase.create (\"0\", 16384);\n\t\tpieceDatabase.start (true);\n\t\tMap<String,Integer> extensions = new HashMap<String,Integer>();\n\t\textensions.put (PeerProtocolConstants.EXTENSION_PEER_METADATA, (int)PeerProtocolConstants.EXTENDED_MESSAGE_TYPE_PEER_METADATA);\n\t\tBDictionary extra = new BDictionary();\n\t\textra.put (\"metadata_size\", BEncoder.encode (pieceDatabase.getInfo().getDictionary()).length);\n\t\tBitField wantedPieces = pieceDatabase.getPresentPieces().not();\n\t\tPeerServices peerServices = mock (PeerServices.class);\n\t\tPeerSetContext peerSetContext = new PeerSetContext (peerServices, pieceDatabase, mock (RequestManager.class), mock (ExtensionManager.class));\n\t\twhen(peerSetContext.requestManager.piecesAvailable (any (ManageablePeer.class))).thenReturn (false);\n\t\tMockConnection mockConnection = new MockConnection();\n\t\tPeerHandler handler = new PeerHandler (peerSetContext, mockConnection, new PeerID(), new PeerStatistics(), false, true);\n\n\t\t// When\n\t\tmockConnection.mockInput (PeerProtocolBuilder.bitfieldMessage (wantedPieces));\n\t\thandler.connectionReady (mockConnection, true, true);\n\n\t\t// Then\n\t\tmockConnection.mockExpectOutput (PeerProtocolBuilder.extensionHandshakeMessage (extensions, extra));\n\t\tmockConnection.mockExpectNoMoreOutput();\n\t\tverify(peerSetContext.extensionManager).offerExtensionsToPeer (handler);\n\n\n\t\tpieceDatabase.terminate (true);\n\n\t}", "@Ignore\n @Test\n public void startSender() throws IOException, InterruptedException {\n\n final int maxPeers = 10;\n PeerDHT[] peers = createPeers(PORT, maxPeers, \"sender\");\n for (PeerDHT peer : peers) {\n peer.peer().bootstrap().inetAddress(InetAddress.getByName(ADDR)).ports(PORT).start().awaitUninterruptibly();\n peer.peer().objectDataReply(new ObjectDataReply() {\n @Override\n public Object reply(final PeerAddress sender, final Object request) throws Exception {\n System.out.println(\"wrong!!!!\");\n return \"wrong!!!!\";\n }\n });\n }\n Number160 keyForID = Number160.createHash(\"key\");\n Msg message = new Msg();\n\n System.out.println(String.format(\"Sending message '%s' to key '%s' converted to '%s'\", message.getType(),\n \"key\", keyForID.toString()));\n FutureSend futureDHT = peers[0].send(keyForID).object(message).requestP2PConfiguration(REQ).start();\n futureDHT.awaitUninterruptibly();\n System.out.println(\"got: \" + futureDHT.object());\n Thread.sleep(Long.MAX_VALUE);\n }", "public void authenticate(View view) {\n String value = makeXor(xorNum.getBytes(), key.getBytes());\n\n if(socket.isConnected()){\n try {\n socket.getOutputStream().write(value.getBytes());\n socket.getOutputStream().flush();\n Toast.makeText(ControlActivity.this, \"Message Sent\", Toast.LENGTH_SHORT).show();\n } catch (IOException e) {\n e.printStackTrace();\n Toast.makeText(ControlActivity.this, \"Error in sending message\", Toast.LENGTH_SHORT).show();\n }\n }else{\n Toast.makeText(ControlActivity.this, \"Bluetooth connection lost!\", Toast.LENGTH_SHORT).show();\n }\n\n\n }", "@Override\n\tpublic boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler,\n\t\t\tMap<String, Object> attributes) throws Exception {\n\t\tSystem.out.println(\"before handshake\");\n\t\treturn super.beforeHandshake(request, response, wsHandler, attributes);\n\n\t}", "public void passingDHT(Packet packet) {\r\n\t\tjava.util.Date passDHTDate = new java.util.Date();\r\n\t\tSystem.out.println(passDHTDate + \": Received Peer Node \" + packet.packetSenderID+\"'s Distributed Hash Table\");\r\n\t\t\r\n\t\t// Iterate through Distribution Hash Table sent in packet and add to Peer Node's distribution Hash table accordingly/as needed\r\n\t\tfor(Entry<String, ArrayList<InetSocketAddress>> keys : packet.distributedHashTable.entrySet()) {\r\n\t\t\tif(peerNode.distributedHashTable.containsKey(keys.getKey())) {\r\n\t\t\t\tpeerNode.distributedHashTable.get(keys.getKey()).addAll(keys.getValue());\t\r\n\t\t\t\tSystem.out.println(keys.getKey());\r\n\t\t\t}\r\n\t\t\telse if (peerNode.distributedHashTable.contains(keys.getKey()) == false) {\r\n\t\t\t\tpeerNode.distributedHashTable.put(keys.getKey(), keys.getValue());\r\n\t\t\t}\r\n\t\t}\r\n\t\tcloseConnection();\r\n\t\t\r\n\t}", "public void test() throws IOException {\n SocketChannel socketChannel = SocketChannel.open();\n socketChannel.configureBlocking(false);\n socketChannel.connect(new InetSocketAddress(BuildConfig.API_URL, ServerIP.PORT));\n\n// Complete connection\n while (!socketChannel.finishConnect()) {\n // do something until connect completed\n }\n\n// Create byte buffers to use for holding application and encoded data\n SSLSession session = sslEngine.getSession();\n ByteBuffer myAppData = ByteBuffer.allocate(session.getApplicationBufferSize());\n ByteBuffer myNetData = ByteBuffer.allocate(session.getPacketBufferSize());\n ByteBuffer peerAppData = ByteBuffer.allocate(session.getApplicationBufferSize());\n ByteBuffer peerNetData = ByteBuffer.allocate(session.getPacketBufferSize());\n\n// Do initial handshake\n// doHandshake(socketChannel, sslEngine, myNetData, peerNetData);\n\n myAppData.put(\"hello\".getBytes());\n myAppData.flip();\n\n while (myAppData.hasRemaining()) {\n // Generate SSL/TLS encoded data (handshake or application data)\n SSLEngineResult res = sslEngine.wrap(myAppData, myNetData);\n\n // Process status of call\n if (res.getStatus() == SSLEngineResult.Status.OK) {\n myAppData.compact();\n\n // Send SSL/TLS encoded data to peer\n while(myNetData.hasRemaining()) {\n int num = socketChannel.write(myNetData);\n if (num == 0) {\n // no bytes written; try again later\n }\n }\n }\n\n // Handle other status: BUFFER_OVERFLOW, CLOSED\n }\n\n // Read SSL/TLS encoded data from peer\n int num = socketChannel.read(peerNetData);\n if (num == -1) {\n // The channel has reached end-of-stream\n } else if (num == 0) {\n // No bytes read; try again ...\n } else {\n // Process incoming data\n peerNetData.flip();\n SSLEngineResult res = sslEngine.unwrap(peerNetData, peerAppData);\n\n if (res.getStatus() == SSLEngineResult.Status.OK) {\n peerNetData.compact();\n\n if (peerAppData.hasRemaining()) {\n // Use peerAppData\n }\n }\n // Handle other status: BUFFER_OVERFLOW, BUFFER_UNDERFLOW, CLOSED\n }\n }", "public void setPeer(Peer peer);", "public String getProtocolId();", "@Test\n public void testPrepare() {\n context.getConfig()\n .setDefaultServerDhGenerator(\n new BigInteger(\n ArrayConverter.hexStringToByteArray(\n \"a51883e9ac0539859df3d25c716437008bb4bd8ec4786eb4bc643299daef5e3e5af5863a6ac40a597b83a27583f6a658d408825105b16d31b6ed088fc623f648fd6d95e9cefcb0745763cddf564c87bcf4ba7928e74fd6a3080481f588d535e4c026b58a21e1e5ec412ff241b436043e29173f1dc6cb943c09742de989547288\")));\n context.getConfig()\n .setDefaultServerDhModulus(\n new BigInteger(\n 1,\n ArrayConverter.hexStringToByteArray(\n \"da3a8085d372437805de95b88b675122f575df976610c6a844de99f1df82a06848bf7a42f18895c97402e81118e01a00d0855d51922f434c022350861d58ddf60d65bc6941fc6064b147071a4c30426d82fc90d888f94990267c64beef8c304a4b2b26fb93724d6a9472fa16bc50c5b9b8b59afb62cfe9ea3ba042c73a6ade35\")));\n context.setClientRandom(ArrayConverter.hexStringToByteArray(\"AABBCCDD\"));\n context.setServerRandom(ArrayConverter.hexStringToByteArray(\"AABBCCDD\"));\n // Set Signature and Hash Algorithm\n List<SignatureAndHashAlgorithm> SigAndHashList = new LinkedList<>();\n SigAndHashList.add(SignatureAndHashAlgorithm.RSA_SHA1);\n SigAndHashList.add(SignatureAndHashAlgorithm.DSA_MD5);\n context.getConfig().setDefaultClientSupportedSignatureAndHashAlgorithms(SigAndHashList);\n // Test\n preparator.prepareHandshakeMessageContents();\n\n assertArrayEquals(\n ArrayConverter.hexStringToByteArray(\n \"a51883e9ac0539859df3d25c716437008bb4bd8ec4786eb4bc643299daef5e3e5af5863a6ac40a597b83a27583f6a658d408825105b16d31b6ed088fc623f648fd6d95e9cefcb0745763cddf564c87bcf4ba7928e74fd6a3080481f588d535e4c026b58a21e1e5ec412ff241b436043e29173f1dc6cb943c09742de989547288\"),\n message.getGenerator().getValue());\n assertArrayEquals(\n ArrayConverter.hexStringToByteArray(\n \"da3a8085d372437805de95b88b675122f575df976610c6a844de99f1df82a06848bf7a42f18895c97402e81118e01a00d0855d51922f434c022350861d58ddf60d65bc6941fc6064b147071a4c30426d82fc90d888f94990267c64beef8c304a4b2b26fb93724d6a9472fa16bc50c5b9b8b59afb62cfe9ea3ba042c73a6ade35\"),\n message.getModulus().getValue());\n assertArrayEquals(\n ArrayConverter.hexStringToByteArray(\"AABBCCDDAABBCCDD\"),\n message.getComputations().getClientServerRandom().getValue());\n assertArrayEquals(\n ArrayConverter.hexStringToByteArray(\"0201\"),\n message.getSignatureAndHashAlgorithm().getValue());\n assertNotNull(message.getSignature().getValue());\n assertNotNull(message.getSignatureLength().getValue());\n }", "private static void keyExchange() throws IOException, NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException {\r\n\t\t//receive from server\r\n\t\tPublicKey keyserver = cryptoMessaging.recvPublicKey(auctioneer.getInputStream());\r\n\t\t//receive from clients\r\n\t\tPublicKey keyclients[] = new PublicKey[3];\r\n\t\tbiddersigs = new PublicKey[3];\r\n\t\tInputStream stream;\r\n\t\tfor (int i=0; i < bidders.size(); i++) {\r\n\t\t\tstream=(bidders.get(i)).getInputStream();\r\n\t\t\tkeyclients[i] = cryptoMessaging.recvPublicKey(stream);\r\n\t\t\tbiddersigs[i] = keyclients[i];\r\n\t\t}\r\n\t\t//send to auctioneer\r\n\t\tcryptoMessaging.sendPublicKey(auctioneer.getOutputStream(), keyclients[0]); \r\n\t\tcryptoMessaging.sendPublicKey(auctioneer.getOutputStream(), keyclients[1]); \r\n\t\tcryptoMessaging.sendPublicKey(auctioneer.getOutputStream(), keyclients[2]); \r\n\t\t//send to clients\r\n\t\tcryptoMessaging.sendPublicKey((bidders.get(0)).getOutputStream(), keyserver); \r\n\t\tcryptoMessaging.sendPublicKey((bidders.get(1)).getOutputStream(), keyserver); \r\n\t\tcryptoMessaging.sendPublicKey((bidders.get(2)).getOutputStream(), keyserver); \r\n\t\t\r\n\t\t\r\n\t\t// now receive paillier public keys from bidders and auctioneer\r\n\t\tauctioneer_pk = cryptoMessaging.recvPaillier(auctioneer.getInputStream());\r\n\t\tpk[0] = cryptoMessaging.recvPaillier((bidders.get(0)).getInputStream());\r\n\t\tpk[1] = cryptoMessaging.recvPaillier((bidders.get(1)).getInputStream());\r\n\t\tpk[2] = cryptoMessaging.recvPaillier((bidders.get(2)).getInputStream());\r\n\t}", "public LWTRTPdu connectRsp() throws IncorrectTransitionException;", "public interface Handshaker {\n /**\n * Performs handshake. This method is blocking. After it has successfully finished, input/output\n * should be ready for normal message-based communication. In case method fails with IOException,\n * input and output are returned in undefined state.\n * @throws IOException if handshake process failed physically (input or output has unexpectedly\n * closed) or logically (if unexpected message came from remote).\n */\n void perform(LineReader input, OutputStream output) throws IOException;\n}", "private void handshake() {\n JsonNode helloResponse = this.readNextResponse();\n\n if (!helloResponse.has(\"hello\")) {\n throw new JsiiError(\"Expecting 'hello' message from jsii-runtime\");\n }\n\n String runtimeVersion = helloResponse.get(\"hello\").asText();\n assertVersionCompatible(JSII_RUNTIME_VERSION, runtimeVersion);\n }", "private void manageConnectedSocket(BluetoothSocket acceptSocket) {\n\n }", "public String getPeerID() {\n\t\t//return this.localPeer.getPeerID();\n\t\treturn \"\";\n\t}", "private void Download(ByteBuffer packet) throws IOException {\n\t\t// NO HEADER\n\t\t\n\t\t// allow only 1 download at a time, clear old threads\n\t\tfor (ServerFwding f : peer_threads){\n\t\t\tif (f.isAlive())\n\t\t\t\tf.interrupt();\n\t\t}\n\t\tpeer_threads.clear();\n\t\t\n\t\t//parse the req\n\t\tif (packet.capacity() < 4)\n\t\t\tthrow new RuntimeException(\n\t\t\t\t\t\"download request invalid\");\n\t\t\n\t\tint buf_id = packet.getInt(0);\n\t\t\n\t\tMap<ClientObj, Integer> clients_with_file = new HashMap<ClientObj, Integer>();\n\t\tfor (ClientObj c : clients){\n\t\t\tif (c.hasFile(buf_id) && c.getId() != client.getId())\n\t\t\t\tclients_with_file.put(c, 0);\n\t\t}\n\t\t\n\t\t// ask each client to prepare a port\n\t\tfor (ClientObj c : clients_with_file.keySet()) {\n\t\t\t//open connection with clients listener\n\t\t\tSocket peerConnection = c.getListenerSocket();\n\t\t\tOutputStream out_c = new BufferedOutputStream(peerConnection.getOutputStream());\n\t\t\t\n\t\t\t//construct packet\n\t\t\t//(for connect to a peer conn s->c) [header | file_id (4) | peer id (4) | port num]\n\t\t\tint peer_server_port = Utility.getValidPort();\n\t\t\tbuf = Utility.addHeader(Constants.PREPARE, 12, c.getId());\n\t\t\tbuf.putInt(Constants.HEADER_LEN, buf_id);\n\t\t\tbuf.putInt(Constants.HEADER_LEN + 4, client.getId());\n\t\t\tbuf.putInt(Constants.HEADER_LEN + 8, peer_server_port);\n\t\t\tbyte[] sendData = buf.array();\n\t\t\t\n\t\t\t// send response\n\t\t\tout_c.write(sendData);\n\t\t\tout_c.flush();\n\t\t\tSystem.out.println(client.getAddress() + \n\t\t\t\t\t\": sent peer client data (with server port \" +peer_server_port+\").\");\n\t\t\t\n\t\t\ttry {\n\t\t\t\tint client_server_port = Utility.getValidPort();\n\t\t\t\tServerFwding peer_thread = new ServerFwding(\n\t\t\t\t\t\tclient_server_port, c.getId(), peer_server_port, buf_id);\n\t\t\t\tpeer_thread.start();\n\t\t\t\t\n\t\t\t\t// send peer info to client, await connection on thread\n\t\t\t\tbuf = Utility.addHeader(Constants.DOWNLOAD_REQ, 8, client.getId());\n\t\t\t\tbuf.putInt(Constants.HEADER_LEN, client_server_port);\n\t\t\t\tbuf.putInt(Constants.HEADER_LEN + 4, c.getId());\n\t\t\t\tsendData = buf.array();\n\t\t\t\tout.write(sendData);\n\t\t\t\tout.flush();\n\t\t\t\tSystem.out.println(client.getAddress() + \n\t\t\t\t\t\t\": sent client peer data (with server port \" +client_server_port+\").\");\n\t\t\t\tpeer_threads.add(peer_thread);\n\t\t\t} catch (IOException e){\n\t\t\t\t// couldn't connect to peer, skip it\n\t\t\t\tSystem.err.println(client.getAddress()+ \n\t\t\t\t\t\t\": Failed to set up P2p connection \" + e.getMessage());\n\t\t\t} catch (RuntimeException e){\n\t\t\t\t// couldn't connect to peer, skip it\n\t\t\t\tSystem.err.println(client.getAddress()+ \n\t\t\t\t\t\t\": Failed to set uo P2p connection \" + e.getMessage());\n\t\t\t}\n\t\t}\n\t\t\n\t\t// send last to client\n\t\tbuf = Utility.addHeader(Constants.DOWNLOAD_REQ, 8, client.getId());\n\t\tbuf.putInt(Constants.HEADER_LEN, 0);\n\t\tbuf.putInt(Constants.HEADER_LEN + 4, 0);\n\t\tout.write(buf.array());\n\t\tout.flush();\n\t\t\n\t\tSystem.out.println(client.getAddress() + \n\t\t\t\t\": Correctly processed download req for \" + buf_id);\n\t}", "void accountPeerAdded(String peerId);", "@Test\r\n\tpublic void testF() {\r\n\t\t\r\n\t\tObjectHandshake h = new ObjectHandshake();\r\n\t\th.setUuid( UuidTool.getOne() );\r\n\t\t\r\n\t\tRunProtocol run = null;\r\n\t\t\r\n\t\trun = new RunProtocol(h, IHandshake.PARTNER_A, 100, 200, true, false);\r\n\t\tassertTrue(run.beginA());\r\n\t\t\r\n\t\trun = new RunProtocol(h, IHandshake.PARTNER_B, 100, 200, true, false);\r\n\t\tassertTrue(run.commitA());\r\n\t\t\r\n\t\trun = new RunProtocol(h, IHandshake.PARTNER_B, 100, 200, true, false);\r\n\t\tassertTrue(run.beginB());\r\n\t\t\r\n\t\trun = new RunProtocol(h, IHandshake.PARTNER_A, 100, 200, true, false);\r\n\t\tassertTrue(run.commitB());\r\n\t\t\r\n\t\tassertEquals(h.getLog(), \"1-8-100-2-8-101-2-2-200-1-2-201-\");\r\n\t}", "com.google.protobuf.ByteString\n getConnectionIdBytes();", "com.google.protobuf.ByteString\n getConnectionIdBytes();", "com.google.protobuf.ByteString\n getConnectionIdBytes();", "public interface SocketControl {\n\n /**\n * 获取服务的IP和端口\n * @return 格式:ip:port,如127.0.0.1:8080\n */\n String getIpPort();\n\n /**\n * 获取服务的ServiceId\n * @return 服务的ServiceId\n */\n String getServiceId();\n\n /**\n * 获取服务的InstanceId\n * @return 服务的InstanceId\n */\n String getInstanceId();\n\n\n /**\n * 获取模块名称,也可以直接调用getIpPort()\n * @return 模块名称\n */\n String getModelName();\n\n\n /**\n * 模块下连接的标示\n * @param channel 管道对象\n * @return uk\n */\n String getUniqueKey(Channel channel);\n\n\n /**\n * 模块下连接的标示\n * @param ctx 管道对象\n * @return uk\n */\n String getUniqueKey(ChannelHandlerContext ctx);\n\n\n /**\n * 绑定key\n * @param ctx 当前连接对象\n * @param key key\n */\n void bindKey(ChannelHandlerContext ctx,String key);\n\n /**\n * 绑定key\n * @param ctx 当前连接对象\n * @param key key\n */\n void bindKey(Channel ctx,String key);\n\n /**\n * 获取key\n * @param ctx 当前链接对象\n * @return key\n */\n String getKey(Channel ctx);\n\n /**\n * 获取key\n * @param ctx 当前链接对象\n * @return key\n */\n String getKey(ChannelHandlerContext ctx);\n\n\n /**\n * 重置心跳时间\n * @param ctx 当前连接对象\n * @param heartTime 心跳时间(秒)\n */\n void resetHeartTime(Channel ctx,int heartTime);\n\n\n\n}", "private void handshake() {\n JsonNode helloResponse = this.readNextResponse();\n\n if (!helloResponse.has(\"hello\")) {\n throw new JsiiException(\"Expecting 'hello' message from jsii-runtime\");\n }\n\n String runtimeVersion = helloResponse.get(\"hello\").asText();\n assertVersionCompatible(JSII_RUNTIME_VERSION, runtimeVersion);\n }", "public Service() {\n if (peers[0] == null) {\n Service.peers[0] = new Peer(clave7);\n Service.peers[1] = new Peer(clave8);\n Service.peers[2] = new Peer(clave9);\n Service.peers[0].addPeer(new EntradaTEncam(clave1, HOSTS[0], PUERTO));\n Service.peers[0].addPeer(new EntradaTEncam(clave2, HOSTS[0], PUERTO));\n Service.peers[0].addPeer(new EntradaTEncam(clave3, HOSTS[0], PUERTO));\n Service.peers[0].addPeer(new EntradaTEncam(clave4, HOSTS[1], PUERTO));\n Service.peers[0].addPeer(new EntradaTEncam(clave5, HOSTS[1], PUERTO));\n Service.peers[0].addPeer(new EntradaTEncam(clave6, HOSTS[1], PUERTO));\n //Service.peers[0].addPeer(new EntradaTEncam(clave7, HOSTS[2], PUERTO));\n Service.peers[0].addPeer(new EntradaTEncam(clave8, HOSTS[2], PUERTO));\n Service.peers[0].addPeer(new EntradaTEncam(clave9, HOSTS[2], PUERTO));\n Service.peers[1].addPeer(new EntradaTEncam(clave1, HOSTS[0], PUERTO));\n Service.peers[1].addPeer(new EntradaTEncam(clave2, HOSTS[0], PUERTO));\n Service.peers[1].addPeer(new EntradaTEncam(clave3, HOSTS[0], PUERTO));\n Service.peers[1].addPeer(new EntradaTEncam(clave4, HOSTS[1], PUERTO));\n Service.peers[1].addPeer(new EntradaTEncam(clave5, HOSTS[1], PUERTO));\n Service.peers[1].addPeer(new EntradaTEncam(clave6, HOSTS[1], PUERTO));\n Service.peers[1].addPeer(new EntradaTEncam(clave7, HOSTS[2], PUERTO));\n //Service.peers[1].addPeer(new EntradaTEncam(clave8, HOSTS[2], PUERTO));\n Service.peers[1].addPeer(new EntradaTEncam(clave9, HOSTS[2], PUERTO));\n Service.peers[2].addPeer(new EntradaTEncam(clave1, HOSTS[0], PUERTO));\n Service.peers[2].addPeer(new EntradaTEncam(clave2, HOSTS[0], PUERTO));\n Service.peers[2].addPeer(new EntradaTEncam(clave3, HOSTS[0], PUERTO));\n Service.peers[2].addPeer(new EntradaTEncam(clave4, HOSTS[1], PUERTO));\n Service.peers[2].addPeer(new EntradaTEncam(clave5, HOSTS[1], PUERTO));\n Service.peers[2].addPeer(new EntradaTEncam(clave6, HOSTS[1], PUERTO));\n Service.peers[2].addPeer(new EntradaTEncam(clave7, HOSTS[2], PUERTO));\n Service.peers[2].addPeer(new EntradaTEncam(clave8, HOSTS[2], PUERTO));\n //Service.peers[2].addPeer(new EntradaTEncam(clave9, HOSTS[2], PUERTO));\n }\n }", "void removePeerEndpoint(String key);", "private void sendHave(int pieceNumber) {\n\t\t//fo\n\t\tfinal ArrayList peer_transports = peer_transports_cow;\n\n\t\tfor (int i = 0; i < peer_transports.size(); i++) {\n\t\t\t//get a peer connection\n\t\t\tfinal PEPeerTransport pc = (PEPeerTransport) peer_transports.get(i);\n\t\t\t//send the have message\n\t\t\tpc.sendHave(pieceNumber);\n\t\t}\n\n\t}", "@Test\n\tpublic void testHandshakesExecuted() throws KeyManagementException, NoSuchAlgorithmException, IOException {\n\t\tExperimentalTrustManager handler = new ExperimentalTrustManager();\n\t\tinitContext(handler);\n\t\tURL fbUrl = new URL(\"https://www.facebook.com\");\n\t\tHttpsURLConnection con = createConnection(fbUrl);\n\t\tcon.connect();\n\t\tassertEquals(\"Firstime handshake should occur\", 1, handler.getHandshakeCount());\n\t\tcon.disconnect();\n\t\t\n\t\tcon = createConnection(fbUrl);\n\t\tcon.connect();\n\t\tassertEquals(\"Second handshake didn't occur because of shared ssl session\", 1, handler.getHandshakeCount());\n\t\tcon.disconnect();\n\t\t\n\t\tURL ytUrl = new URL(\"https://www.youtube.com/\");\n\t\tcon = createConnection(ytUrl);\n\t\tcon.connect();\n\t\tassertEquals(\"Connection to other location is in other ssl session so handshage occurs\", 2, handler.getHandshakeCount());\n\t\tcon.disconnect();\n\t\t\n\t\tcon = createConnection(ytUrl);\n\t\tcon.connect();\n\t\tassertEquals(\"Seccond session is also shared - no handshake\", 2, handler.getHandshakeCount());\n\t\tcon.disconnect();\n\t\t\n\t\t// once again try first connection if session was forgotten or not\n\t\tcon = createConnection(fbUrl);\n\t\tcon.connect();\n\t\tassertEquals(\"First session is still valid - no handshage\", 2, handler.getHandshakeCount());\n\t\tcon.disconnect();\n\t}", "private void verifyServerHandshake(InputStream inputStream, String secWebSocketKey) throws IOException {\n try {\n SessionInputBufferImpl sessionInputBuffer = new SessionInputBufferImpl(new HttpTransportMetricsImpl(),\n 8192);\n sessionInputBuffer.bind(inputStream);\n HttpMessageParser<HttpResponse> parser = new DefaultHttpResponseParser(sessionInputBuffer);\n HttpResponse response = parser.parse();\n\n StatusLine statusLine = response.getStatusLine();\n if (statusLine == null) {\n throw new InvalidServerHandshakeException(\"There is no status line\");\n }\n\n int statusCode = statusLine.getStatusCode();\n if (statusCode != 101) {\n throw new InvalidServerHandshakeException(\n \"Invalid status code. Expected 101, received: \" + statusCode);\n }\n\n Header[] upgradeHeader = response.getHeaders(\"Upgrade\");\n if (upgradeHeader.length == 0) {\n throw new InvalidServerHandshakeException(\"There is no header named Upgrade\");\n }\n String upgradeValue = upgradeHeader[0].getValue();\n if (upgradeValue == null) {\n throw new InvalidServerHandshakeException(\"There is no value for header Upgrade\");\n }\n upgradeValue = upgradeValue.toLowerCase();\n if (!upgradeValue.equals(\"websocket\")) {\n throw new InvalidServerHandshakeException(\n \"Invalid value for header Upgrade. Expected: websocket, received: \" + upgradeValue);\n }\n\n Header[] connectionHeader = response.getHeaders(\"Connection\");\n if (connectionHeader.length == 0) {\n throw new InvalidServerHandshakeException(\"There is no header named Connection\");\n }\n String connectionValue = connectionHeader[0].getValue();\n if (connectionValue == null) {\n throw new InvalidServerHandshakeException(\"There is no value for header Connection\");\n }\n connectionValue = connectionValue.toLowerCase();\n if (!connectionValue.equals(\"upgrade\")) {\n throw new InvalidServerHandshakeException(\n \"Invalid value for header Connection. Expected: upgrade, received: \" + connectionValue);\n }\n\n// Header[] secWebSocketAcceptHeader = response.getHeaders(\"Sec-WebSocket-Accept\");\n// if (secWebSocketAcceptHeader.length == 0) {\n// throw new InvalidServerHandshakeException(\"There is no header named Sec-WebSocket-Accept\");\n// }\n// String secWebSocketAcceptValue = secWebSocketAcceptHeader[0].getValue();\n// if (secWebSocketAcceptValue == null) {\n// throw new InvalidServerHandshakeException(\"There is no value for header Sec-WebSocket-Accept\");\n// }\n\n// String keyConcatenation = secWebSocketKey + GUID;\n// byte[] sha1 = DigestUtils.sha1(keyConcatenation);\n// String secWebSocketAccept = Base64.encodeBase64String(sha1);\n// if (!secWebSocketAcceptValue.equals(secWebSocketAccept)) {\n// throw new InvalidServerHandshakeException(\n// \"Invalid value for header Sec-WebSocket-Accept. Expected: \" + secWebSocketAccept\n// + \", received: \" + secWebSocketAcceptValue);\n// }\n } catch (HttpException e) {\n throw new InvalidServerHandshakeException(e.getMessage());\n }\n }", "public void sendId() {\n for (int i = 0; i < numberOfPlayers; i++) {\n try {\n // s = ss.accept();\n oos = new ObjectOutputStream(sockets.get(i).getOutputStream());\n game.getOne().setID(0);\n game.getTwo().setID(1);\n oos.writeObject(i);\n } catch (IOException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n }\n }", "protected Hashtable<String, Set<PeerConnection>> peerRecord() {\n\t\treturn peerRecord;\n\t}", "public interface PeerInfoService extends PeerInfoCallback {\r\n}", "@Test\r\n\tpublic void testD() {\r\n\t\t\r\n\t\tObjectHandshake h = new ObjectHandshake();\r\n\t\th.setUuid( UuidTool.getOne() );\r\n\t\t\r\n\t\tRunProtocol run = null;\r\n\t\t\r\n\t\trun = new RunProtocol(h, IHandshake.PARTNER_A);\r\n\t\tassertTrue(run.beginA());\r\n\t\t\r\n\t\trun = new RunProtocol(h, IHandshake.PARTNER_A);\r\n\t\tassertTrue(run.commitA());\r\n\t\t\r\n\t\trun = new RunProtocol(h, IHandshake.PARTNER_B);\r\n\t\tassertTrue(run.beginB());\r\n\t\t\r\n\t\trun = new RunProtocol(h, IHandshake.PARTNER_B);\r\n\t\tassertTrue(run.commitB());\r\n\t\t\r\n\t\tassertEquals(h.getLog(), \"1-1-100-1-1-101-2-2-200-2-2-201-\");\r\n\t}", "public void sendKeys() throws Exception{\n ATMMessage atmMessage = (ATMMessage)is.readObject();\r\n System.out.println(\"\\nGot response\");\r\n \r\n //System.out.println(\"Received second message from the client with below details \");\r\n //System.out.println(\"Response Nonce value : \"+atmMessage.getResponseNonce());\r\n \r\n if(!verifyMessage(atmMessage))error(\" Nonce or time stamp does not match\") ;\r\n kSession = crypto.makeRijndaelKey();\r\n \r\n Key kRandom = crypto.makeRijndaelKey();\r\n byte [] cipherText = crypto.encryptRSA(kRandom,kPubClient);\r\n os.writeObject((Serializable)cipherText);\r\n System.out.println(\"\\nSending Accept and random key\");\r\n \r\n \r\n cipherText = crypto.encryptRSAPrivateKey(kSession,kPrivBank);\r\n atmMessage = new ATMMessage(); \r\n atmMessage.setEncryptedSessionKey(cipherText);\r\n cipherText = crypto.encryptRijndael(atmMessage,kRandom);\r\n currTimeStamp = System.currentTimeMillis();\r\n os.writeObject((Serializable)cipherText);\r\n //System.out.println(\"Session Key send to the client \");\r\n \r\n //SecondServerMessage secondServerMessage = new SecondServerMessage();\r\n //secondServerMessage.setSessionKey(kSession);\r\n \r\n //byte [] cipherText1;\r\n //cipherText = crypto.encryptRSAPrivateKey(kSession,kPrivBank);\r\n //cipherText1 = crypto.encryptRSA(cipherText,clientPublicKey);\r\n //os.writeObject((Serializable)cipherText1);\r\n \r\n //System.out.println(\"Second message send by the server which contains the session key. \");\r\n //System.out.println(\"\\n\\n\\n\");\r\n \r\n \r\n }", "public int getReferenceCHFirstEdgeId() {\r\n return referenceCHFirstEdgeId;\r\n }", "@Override\n\tpublic void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler,\n\t\t\tException ex) {\n\t\tSystem.out.println(\"after handshake\");\n\n\t\tHttpServletRequest rq = ((ServletServerHttpRequest) request).getServletRequest();\n\t\tHttpSession session = rq.getSession();\n\t\tsuper.afterHandshake(request, response, wsHandler, ex);\n\n\t}" ]
[ "0.61469036", "0.6043738", "0.5926178", "0.57517153", "0.5725604", "0.56397986", "0.5639677", "0.54676396", "0.53898174", "0.52196175", "0.51888216", "0.5184009", "0.5132317", "0.5132146", "0.5129233", "0.5124895", "0.51241845", "0.5096403", "0.50932634", "0.50797945", "0.5017084", "0.5008969", "0.4988686", "0.49755672", "0.4967563", "0.49625582", "0.49459827", "0.49255827", "0.48927552", "0.48894528", "0.4887199", "0.48737636", "0.4864751", "0.4862206", "0.48540956", "0.4845971", "0.48233038", "0.47724655", "0.4767974", "0.47596517", "0.47596517", "0.47438854", "0.47276652", "0.47241756", "0.47130102", "0.47069225", "0.4705714", "0.4694369", "0.4688714", "0.46750665", "0.46735924", "0.46684167", "0.46618298", "0.46604982", "0.4656685", "0.46508414", "0.46261197", "0.4610875", "0.4604837", "0.45947614", "0.45838708", "0.45807466", "0.4580439", "0.458006", "0.45782426", "0.45777944", "0.45503044", "0.4534798", "0.45129582", "0.4505323", "0.4491575", "0.448989", "0.44883972", "0.44753814", "0.44636977", "0.4460667", "0.4456601", "0.44484246", "0.44481573", "0.44468078", "0.44424883", "0.44391453", "0.44381258", "0.44370937", "0.44370937", "0.44370937", "0.44334936", "0.44229195", "0.44192025", "0.44185394", "0.4417608", "0.44147563", "0.44097173", "0.44058424", "0.44039738", "0.4400629", "0.43953264", "0.43953243", "0.43951178", "0.43899956" ]
0.7324551
0
addToBuffer identifies which buffer to be used and adds payload to it. PeerDevice can be only client or server, not both in the same time.
public void addToBuffer(byte[] value, boolean isClient) { byte[] buffer; if (isClient) { buffer = mClientBuffer; } else { buffer = mServerBuffer; } if (buffer == null) { buffer = new byte[0]; } byte[] tmp = new byte[buffer.length + value.length]; System.arraycopy(buffer, 0, tmp, 0, buffer.length); System.arraycopy(value, 0, tmp, buffer.length, value.length); if (isClient) { mClientBuffer = tmp; } else { mServerBuffer = tmp; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Override\r\n\tpublic void PushToBuffer(ByteBuffer buffer)\r\n\t{\r\n\t\r\n\t}", "@Override\r\n\tpublic void addToBuffer(byte[] buff, int len) {\r\n\t\tbios.write(buff, 0, len);\r\n\t}", "public void append(IoBuffer buffer) {\n data.offerLast(buffer);\n updateBufferList();\n }", "public void addBytes( final ByteBuffer _buffer ) {\n\n // sanity checks...\n if( isNull( _buffer ) )\n throw new IllegalArgumentException( \"Missing buffer to append from\" );\n if( _buffer.remaining() <= 0)\n throw new IllegalArgumentException( \"Specified buffer has no bytes to append\" );\n\n // figure out how many bytes we can append, and configure the source buffer accordingly...\n int appendCount = Math.min( buffer.capacity() - buffer.limit(), _buffer.remaining() );\n int specifiedBufferLimit = _buffer.limit();\n _buffer.limit( _buffer.position() + appendCount );\n\n // remember our old position, so we can put it back later...\n int pos = buffer.position();\n\n // setup to copy our bytes to the right place...\n buffer.position( buffer.limit() );\n buffer.limit( buffer.capacity() );\n\n // copy our bytes...\n buffer.put( _buffer );\n\n // get the specified buffer's limit back to its original state...\n _buffer.limit( specifiedBufferLimit );\n\n // get our position and limit to the right place...\n buffer.limit( buffer.position() );\n buffer.position( pos );\n }", "private int addBuffer( FloatBuffer directBuffer, FloatBuffer newBuffer ) {\n int oldPosition = directBuffer.position();\n if ( ( directBuffer.capacity() - oldPosition ) >= newBuffer.capacity() ) {\n directBuffer.put( newBuffer );\n } else {\n oldPosition = -1;\n }\n return oldPosition;\n }", "public void applyBufferToSurface(SurfaceControl surfaceControl, GraphicBufferEx buffer) {\n attachBufferToSurface(surfaceControl, buffer);\n }", "public sendRecordBuffer_args(sendRecordBuffer_args other) {\n if (other.isSetRecord()) {\n this.record = new InputRecordBuffer(other.record);\n }\n }", "public boolean add(BufferSlot bs);", "private void addMessageToQueue( byte[] buffer ){\n \tsynchronized (this.messages) {\n byte message[] = new byte[buffer.length\n - Constants.MESSAGE_ID_LEN - 1];\n for (int i = Constants.MESSAGE_ID_LEN + 1; i < buffer.length; i++) {\n message[i - Constants.MESSAGE_ID_LEN - 1] = buffer[i];\n }\n messages.add(message);\n }\n }", "void setBuffer(byte[] b)\n {\n buffer = b;\n }", "public void addCallbackBuffer(Camera camera, byte[] callbackBuffer) {\r\n try {\r\n if (mMethodAddCallbackBuffer != null) {\r\n Object[] argList = new Object[1];\r\n argList[0] = callbackBuffer;\r\n mMethodAddCallbackBuffer.invoke(camera, argList);\r\n }\r\n } catch (Exception e) {\r\n Log.w(LOG_TAG, \"CameraHideMethods:addCallbackBuffer()\", e);\r\n }\r\n }", "public void addToBuffer(String filename, SensorData sensorData){\n ObjectOutputStream outstream;\n try {\n File bufferFile = new File(filename);\n //Checks to see if the buffer file already exists. \n if(bufferFile.exists())\n {\n //Create an AppendableObjectOutputStream to add the the end of the buffer file as opposed to over writeing it. \n outstream = new AppendableObjectOutputStream(new FileOutputStream (filename, true));\n } else {\n //Create an ObjectOutputStream to create a new Buffer file. \n outstream = new ObjectOutputStream(new FileOutputStream (filename)); \n }\n //Adds the SensorData to the end of the buffer file.\n outstream.writeObject(sensorData);\n outstream.close();\n } catch(IOException io) {\n System.out.println(io);\n }\n }", "public void write(ByteBuffer buffer){\r\n\t\tbuffer.putInt(type.ordinal());\r\n\t\tbuffer.putInt(dataSize);\r\n\t\tbuffer.put(data);\r\n\t}", "@Override\r\n\tpublic Buffer setBuffer(int pos, Buffer b, int offset, int len) {\n\t\treturn null;\r\n\t}", "public interface BufferUsageStrategy\n{\n ByteBuffer onTermAdded(final String destination,\n final long sessionId,\n final long channelId,\n final long termId,\n boolean isSender) throws Exception;\n}", "public void add(byte[] arrby) {\n ByteBuffer byteBuffer;\n ByteBuffer byteBuffer2 = byteBuffer = Blob.this.getByteBuffer();\n synchronized (byteBuffer2) {\n byteBuffer.position(Blob.this.getByteBufferPosition() + this.offset() + this.mCurrentDataSize);\n byteBuffer.put(arrby);\n this.mCurrentDataSize += arrby.length;\n return;\n }\n }", "public void put(T bufferItem);", "public void addData(byte[] arrby) {\n if (arrby == null) return;\n {\n try {\n if (arrby.length == 0) {\n return;\n }\n if ((int)this.len.get() + arrby.length > this.buf.length) {\n Log.w(TAG, \"setData: Input size is greater than the maximum allocated ... returning! b.len = \" + arrby.length);\n return;\n }\n this.buf.add(arrby);\n this.len.set(this.len.get() + (long)arrby.length);\n return;\n }\n catch (Exception exception) {\n Log.e(TAG, \"addData exception!\");\n exception.printStackTrace();\n return;\n }\n }\n }", "private static void onBufferRentOut(String user,ByteBuffer buffer) {\n\t\tif(buffer != null) {\n\t\t\tlong id = getByteBufferId(buffer);\n\t\t\tMemInfo info = sMemInfo.get(id);\n\t\t\tif(info == null) {\n\t\t\t\tinfo = new MemInfo();\n\t\t\t\tinfo.buffer = buffer;\n\t\t\t\tsMemInfo.put(id, info);\n\t\t\t}\n\t\t\tinfo.owner = user;\n\t\t\t\n\t\t\tsInUsing.add(id);\n\t\t\t\n\t\t\tnotify(sMemInUsing,sMemTotal);\n\t\t}\n\t}", "@Override\r\n\tpublic Buffer setBuffer(int pos, Buffer b) {\n\t\treturn null;\r\n\t}", "abstract void allocateBuffers();", "public void toBuffer(ByteBufWrapper paramhd)\r\n/* 23: */ {\r\n/* 24:40 */ paramhd.a(a.toJson(this.b));\r\n/* 25: */ }", "public synchronized void addBytes(ByteBuffer bytes) {\n\t _buffers.add(bytes);\n \n }", "public FloatBuffer putInBuffer(FloatBuffer buffer) {\n\t\tbuffer.put(x).put(y).put(z).put(w);\n\t\treturn buffer;\n\t}", "public void bufferPacket(UtpTimestampedPacketDTO pkt) throws IOException {\r\n\t\tint sequenceNumber = pkt.utpPacket().getSequenceNumber() & 0xFFFF;\r\n\t\tint position = sequenceNumber - expectedSequenceNumber;\r\n\t\tdebug_lastSeqNumber = sequenceNumber;\r\n\t\tif (position < 0) {\r\n\t\t\tposition = mapOverflowPosition(sequenceNumber);\r\n\t\t}\r\n\t\tdebug_lastPosition = position;\r\n\t\telementCount++;\r\n\t\ttry {\r\n\t\t\tbuffer[position] = pkt;\t\t\t\r\n\t\t} catch (ArrayIndexOutOfBoundsException ioobe) {\r\n\t\t\tlog.error(\"seq, exp: \" + sequenceNumber + \" \" + expectedSequenceNumber + \" \");\r\n\t\t\tioobe.printStackTrace();\r\n\r\n\t\t\tdumpBuffer(\"oob: \" + ioobe.getMessage());\r\n\t\t\tthrow new IOException();\r\n\t\t}\r\n\r\n\t}", "public void write(byte[] buffer) {\n try {\n String bufferstring=\"a5550100a2\";\n // byte [] buffer03=new byte[]{(byte) 0xa5, Byte.parseByte(\"ffaa\"),0x01,0x00, (byte) 0xa2};\n byte buffer01[]=bufferstring.getBytes();\n byte [] buffer02=new byte[]{(byte) 0xa5,0x55,0x01,0x00, (byte) 0xa2};\n\n\n //for(int i=0;i<100000;i++) {\n mmOutStream.write(buffer);\n // Thread.sleep(1000);\n //}\n //\n //Share the sent message back to the UI Activity\n// mHandler.obtainMessage(BluetoothChat.MESSAGE_WRITE, -1, -1, buffer)\n// .sendToTarget();\n } catch (Exception e) {\n Log.e(TAG, \"Exception during write\", e);\n }\n }", "public abstract void addBuffer(Array<Array<Boolean>> pattern);", "public interface ProductionBuffer {\n\t\n\tpublic int getMaxBufferSize();\n\t\n\tpublic int getCurrentBufferSize();\n\t\n\tpublic boolean isFull();\n\t\n\tpublic boolean isEmpty();\n\t\n\t//Add to the back of the buffer\n\tpublic boolean add(BufferSlot bs);\n\t\n\t//Remove from the front of the buffer\n\tpublic BufferSlot remove();\n\t\n\t//empties the buffer\n\tpublic void clear();\n\n}", "abstract public Buffer createBuffer();", "void putTo(ByteBuffer dst, TcpTxContext tx) {}", "public void appendBytesTo (int offset, int length, IQueryBuffer dst) {\r\n\r\n\t\tif (isDirect || dst.isDirect())\r\n\t\t\tthrow new UnsupportedOperationException(\"error: cannot append bytes from/to a direct buffer\");\r\n\r\n\t\tdst.put(this.buffer.array(), offset, length);\r\n\t}", "void use(ByteBuffer buffer, short id);", "void addMessageBody(ByteBuffer msgBody);", "private final void buffer_push_back(byte d)\n\t{\n\t\tif (buffer_size_ >= buffer_.length) {\n int newsize = buffer_size_ * 2 + 10;\n byte[] newbuffer = new byte[newsize];\n\n for (int i = 0; i < buffer_size_; ++i)\n {\n newbuffer[i] = buffer_[i];\n }\n buffer_ = newbuffer;\n\t\t}\n\t\tbuffer_[buffer_size_] = d;\n\t\tbuffer_size_ = buffer_size_ + 1;\n\t}", "protected void storeBuffer(Buffer buffer, String targetPath) {\n\t\tFileSystem fileSystem = Mesh.vertx().fileSystem();\n\t\tfileSystem.writeFileBlocking(targetPath, buffer);\n\t\t// log.error(\"Failed to save file to {\" + targetPath + \"}\", error);\n\t\t// throw error(INTERNAL_SERVER_ERROR, \"node_error_upload_failed\", error);\n\t}", "public void addBuff(int duration) {\r\n buffs.add(duration);\r\n }", "private void loadBuffer(ByteBuffer buffer) {\n byteBuffer = buffer.get();\n }", "public interface IBufferInput<T> {\n\n\t/**\n\t * Puts the bufferItem at the end of the bufferStore ArrayList\n\t * @param bufferItem an item to append to bufferStore \n\t */\n\tpublic void put(T bufferItem);\n}", "protected void add(ByteBuffer data) throws Exception {\n\tLog.d(TAG, \"add data: \"+data);\n\n\tint dataLength = data!=null ? data.capacity() : 0; ///Util.chunkLength(data); ///data.length;\n\tif (dataLength == 0) return;\n\tif (this.expectBuffer == null) {\n\t\tthis.overflow.add(data);\n\t\treturn;\n\t}\n\t\n\tLog.d(TAG, \"add data: ... 2\");\n\t\n\tint toRead = Math.min(dataLength, this.expectBuffer.capacity() - this.expectOffset);\n\tBufferUtil.fastCopy(toRead, data, this.expectBuffer, this.expectOffset);\n\t\n\tLog.d(TAG, \"add data: ... 3\");\n\n\tthis.expectOffset += toRead;\n\tif (toRead < dataLength) {\n\t\tthis.overflow.add((ByteBuffer) Util.chunkSlice(data, toRead, data.capacity())/*data.slice(toRead)*/);\n\t}\n\t\n\tLog.d(TAG, \"add data: ... 5\");\n\n\twhile (this.expectBuffer!=null && this.expectOffset == this.expectBuffer.capacity()) {\n\t\tByteBuffer bufferForHandler = this.expectBuffer;\n\t\tthis.expectBuffer = null;\n\t\tthis.expectOffset = 0;\n\t\t///this.expectHandler.call(this, bufferForHandler);\n\t\tthis.expectHandler.onPacket(bufferForHandler);\n\t}\n\t\n\tLog.d(TAG, \"add data: ... 6\");\n\n}", "List<TrackerPayload> getBuffer();", "private void pushRemainingToBody(ByteBuffer buffer, DynamicByteBuffer body, int size) {\n\t\t// If buffer is empty or there is no clength then skip this\n\t\tif (size == 0 || !buffer.hasRemaining()) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (body.position() + buffer.remaining() > size) {\n\t\t\tbody.put(buffer.array(), buffer.position(), size - body.position());\n\t\t} else {\n\t\t\tbody.put(buffer.array(), buffer.position(), buffer.remaining());\n\t\t}\n\t}", "public IBuffer newBuffer();", "private void writeAddress( ByteBuffer byteBuffer, InetAddress currentClientAddress )\n {\n if ( null == currentClientAddress )\n {\n byte[] emptyAddress =\n { 0, 0, 0, 0 };\n byteBuffer.put( emptyAddress );\n }\n else\n {\n byte[] addressBytes = currentClientAddress.getAddress();\n byteBuffer.put( addressBytes );\n }\n }", "public GlBuffer allocate(final int usage, final int target, final boolean freeLocal){\n\t\t//android.util.//Log.d(TAG,\"createVBO(\"+usage+\",\"+target+\",\"+freeLocal+\")\");\n\t\tif(this.handle == UNBIND_HANDLE){\n\t\t\tfinal int[] handles = new int[1];\n\n\t\t\t//Create buffer on server\n\t\t\tGLES20.glGenBuffers(1, handles, 0);\n\t\t\tthis.handle = handles[0];\n\t\t\tthis.target = target;\n\n\t\t\tGlOperation.checkGlError(TAG, \"glGenBuffers\");\n\n\t\t\t//Bind it\n\t\t\tGLES20.glBindBuffer(target, this.handle);\n\t\t\tif(this.buffer == null){\n\t\t\t\tthis.commit(false);\n\t\t\t}\n\t\t\t//Push data into it\n\t\t\tthis.buffer.position(0);\n\t\t\tGLES20.glBufferData(target, this.size, this.buffer, usage);\n\t\t\t//Unbind it\n\t\t\tGLES20.glBindBuffer(target, UNBIND_HANDLE);\n\n\t\t\t//Check error on bind only\n\t\t\tGlOperation.checkGlError(TAG, \"glBufferData\");\n\n\t\t\t//Free local buffer is queried\n\t\t\tif(mManagedBuffer && freeLocal){\n\t\t\t\tswitch(this.datatype){\n\t\t\t\t\tcase TYPE_BYTE :\n\t\t\t\t\t\tByteBufferPool.getInstance().returnDirectBuffer((ByteBuffer)this.buffer);\n\t\t\t\t\t\tmManagedBuffer = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase TYPE_SHORT :\n\t\t\t\t\t\tByteBufferPool.getInstance().returnDirectBuffer((ShortBuffer)this.buffer);\n\t\t\t\t\t\tmManagedBuffer = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase TYPE_INT :\n\t\t\t\t\t\tByteBufferPool.getInstance().returnDirectBuffer((IntBuffer)this.buffer);\n\t\t\t\t\t\tmManagedBuffer = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault :\n\t\t\t\t\t\tByteBufferPool.getInstance().returnDirectBuffer((FloatBuffer)this.buffer);\n\t\t\t\t\t\tmManagedBuffer = false;\n\t\t\t\t}\n\t\t\t\tthis.buffer = null;\n\t\t\t}\n\n\t\t\tmode = MODE_VBO;\n\n if(GlOperation.getVersion()[0] >= 3 && this.vertexAttribHandles != null\n && this.vertexAttribHandles.length > 0){\n GLES30.glGenVertexArrays(1, handles, 0);\n mVaoHandle = handles[0];\n GlOperation.checkGlError(TAG, \"glGenVertexArrays\");\n\n GLES30.glBindVertexArray(mVaoHandle);\n GLES20.glBindBuffer(target, this.handle);\n\n for(int index=0; index < this.vertexAttribHandles.length; index++){\n GLES20.glEnableVertexAttribArray(this.vertexAttribHandles[index]);\n GLES20.glVertexAttribPointer(this.vertexAttribHandles[index], this.chunks[index].components,\n this.chunks[index].datatype, this.chunks[index].normalized, stride, this.chunks[index].offset);\n }\n GlOperation.checkGlError(TAG, \"glVertexAttribPointer\");\n\n GLES20.glBindBuffer(target, UNBIND_HANDLE);\n GLES30.glBindVertexArray(UNBIND_HANDLE);\n\n mode = MODE_VAO;\n }\n\t\t}\n\t\telse{\n\t\t Log.w(TAG, \"multiple allocation detected !\");\n }\n\n\t\treturn this;\n\t}", "@Override\n public void fromBuffer(byte[] buffer) {\n set(bytesToContent(buffer));\n }", "@Override\n public void loadBuffer(final Tuple3d origin, final ByteBuffer buffer) {\n this.loadGpuBuffer(origin);\n buffer.put(this.gpuBuffer);\n this.gpuBuffer.rewind();\n }", "public boolean addMessageToBufferingTracker(Slot slot, AndesMessageMetadata andesMessageMetadata) {\n long messageID = andesMessageMetadata.getMessageID();\n boolean isOKToBuffer;\n if(log.isDebugEnabled()) {\n log.debug(\"Buffering message id = \" + messageID + \" slot = \" + slot.toString());\n }\n ConcurrentHashMap<Long, MsgData> messagesOfSlot = messageBufferingTracker.get(slot);\n if (messagesOfSlot == null) {\n messagesOfSlot = new ConcurrentHashMap<Long, MsgData>();\n messageBufferingTracker.put(slot, messagesOfSlot);\n }\n MsgData trackingData = messagesOfSlot.get(messageID);\n if (trackingData == null) {\n trackingData = new MsgData(messageID, slot, false,\n andesMessageMetadata.getDestination(),\n System.currentTimeMillis(), andesMessageMetadata.getExpirationTime(),\n 0, null, 0,MessageStatus.Buffered);\n msgId2MsgData.put(messageID, trackingData);\n messagesOfSlot.put(messageID, msgId2MsgData.get(messageID));\n isOKToBuffer = true;\n } else {\n log.debug(\"Buffering rejected message id = \" + messageID);\n isOKToBuffer = false;\n }\n return isOKToBuffer;\n }", "@Override\n protected void sendBuffer(byte[] buffer) {\n final UsbSerialDriver serialDriver = serialDriverRef.get();\n if (serialDriver != null) {\n try {\n serialDriver.write(buffer, 500);\n } catch (IOException e) {\n Log.e(TAG, \"Error Sending: \" + e.getMessage(), e);\n }\n }\n }", "private void fillReceiveBuffer(final int requestedSize) {\n ByteBuffer readBuffer = receiveBuffer;\n if (requestedSize > receiveBuffer.capacity()) {\n readBuffer = socketService.getByteBuffer(requestedSize);\n readBuffer.put(receiveBuffer).flip();\n socketService.releaseByteBuffer(receiveBuffer);\n }\n receiveBuffer = null;\n socketHandle.read(readBuffer).addDeferrable(this, true);\n }", "private ByteBuffer concatBuffers(List<Object> buffers) throws Exception {\n\t/*\n var length = 0;\n for (var i = 0, l = buffers.length; i < l; ++i) length += buffers[i].length;\n var mergedBuffer = new Buffer(length);\n bufferUtil.merge(mergedBuffer, buffers);\n return mergedBuffer;*/\n\treturn Util.concatByteBuffer(buffers, 0);\n}", "public void write(ByteBuffer buffer) throws IOException {\n _channel.write(buffer);\n }", "void writeCurrentBuffer();", "@Override\n public void append( ByteBuffer rtnBuffer) {\n \n //Add the parent\n super.append(rtnBuffer);\n \n //Add the file id\n rtnBuffer.put( handlerId );\n \n //Add the file byte value\n rtnBuffer.put(socksBytes );\n \n }", "@Override\n public void onBufferReceived(byte[] buffer) {\n }", "@Override\n\tpublic void addNotify() {\n\t\tsuper.addNotify();\n\t\t// Buffer\n\t\tcreateBufferStrategy(2);\n\t\ts = getBufferStrategy();\n\t}", "@Override\n\tpublic void builder(ByteBuffer buffer) {\n\t\tsetV(buffer);\n\t\tsetO(buffer);\n\t\tsetT(buffer);\n\t\tsetLen(buffer);\n\t\tsetContents(buffer);\n\t\tsetTotalByteLength();\n\t}", "public void receive(ByteBuffer buffer, int numOfCharacters) {\n \t\t--numOfCharacters;\n \t\t\n \t\tfor(int idx = 0; idx != numOfCharacters; ++idx) {\n \t\t\tfloat x = buffer.getFloat();\n \t\t\tfloat y = buffer.getFloat();\n \t\t\tfloat direction = buffer.getFloat();\n \t\t\tfloat speed = buffer.getFloat();\n \t\t\tint color = buffer.getInt();\n \t\t\tint id = buffer.getInt();\n \t\t\t\n \t\t\tif(id == d_player.id()) {\n \t\t\t\t--idx;\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\t\n \t\t\tif(idx < d_characters.size())\n \t\t\t\td_characters.get(idx).instantiate(x, y, direction, speed, color, id);\n \t\t\telse {\n \t\t\t\tGameCharacter character = new GameCharacter(x, y, direction, speed, color, id);\n \t\t\t\td_characters.add(character);\n \t\t\t}\n \t\t}\n \t\t\n \t\tif(numOfCharacters < d_characters.size()) {\n \t\t\tfor(int idx = numOfCharacters; idx != d_characters.size(); ++idx)\n \t\t\t\td_characters.get(idx).instantiate(0, 0, 0, 0, 0, -1);\n \t\t}\n \t}", "void writeTo(ByteBuffer buffer) {\n/* 526 */ Preconditions.checkNotNull(buffer);\n/* 527 */ Preconditions.checkArgument(\n/* 528 */ (buffer.remaining() >= 40), \"Expected at least Stats.BYTES = %s remaining , got %s\", 40, buffer\n/* */ \n/* */ \n/* 531 */ .remaining());\n/* 532 */ buffer\n/* 533 */ .putLong(this.count)\n/* 534 */ .putDouble(this.mean)\n/* 535 */ .putDouble(this.sumOfSquaresOfDeltas)\n/* 536 */ .putDouble(this.min)\n/* 537 */ .putDouble(this.max);\n/* */ }", "public void write(byte[] buffer);", "public void appendBuffer(ByteArrayOutputStream qlikTableBaos) {\n synchronized (this) {\n totalOps++;\n sendBuffer(qlikTableBaos);\n /*\n try {\n qlikTableBaos.writeTo(baos);\n if (baos.size() >= maxBufferSize) {\n sendBuffer(baos);\n resetBuffer();\n }\n } catch (IOException e) {\n LOG.error(\"error adding message\", e);\n }\n */\n }\n }", "private void assignBuffer(List<TupleReaderBinary> buffers, int bufferID) {\n\t\tif (readerBucketID < prevTotalBuckets && readerBucketID < numInputBuffers * currentGroup) {\n\t\t\tTupleReaderBinary readerBinary = new TupleReaderBinary(DatabaseCatalog.getInstance().getTempDirectory()\n\t\t\t\t\t+ \"/\" + instanceHashcode + \"_\" + (passNumber - 1) + \"_\" + readerBucketID);\n\t\t\treaderBinary.keyNames = ordering;\n\t\t\tbuffers.set(bufferID, readerBinary);\n\t\t\treaderBucketID++;\n\t\t} else {\n\t\t\tbuffers.set(bufferID, null);\n\t\t}\n\t}", "public byte[] updateScreenBuffer(byte[] widgetBuffer, int sessionId) {\n for (int i = 0; i < widgets.length; i++) {\n if ((widgets[i] != null) && (sessionId == sessionIds[i])) {\n System.arraycopy(widgetBuffer, 0, screenBuffer, i * BUFFER_LENGTH, BUFFER_LENGTH);\n break;\n }\n }\n \n return screenBuffer;\n }", "@Override\r\n\tpublic Buffer appendBytes(byte[] bytes) {\n\t\tthis.buffer.put( bytes );\r\n\t\treturn this;\r\n\t}", "@Override\n\tpublic BytesReceiver put(final ByteBuffer src) {\n\t\treturn put(src.array());\n\t}", "public void initBufferStrategy() {\n // Triple-buffering\n createBufferStrategy(3);\n bufferStrategy = getBufferStrategy();\n }", "@Override\n public synchronized void addMeasurement(Measurement m){\n while(toBeConsumed>=size){\n try{\n wait();\n }\n catch (InterruptedException e){\n System.out.println(\"The thread was teared down\");\n }\n }\n /*try {\n Thread.sleep(1000);\n }\n catch(InterruptedException e){\n System.out.println(e.getMessage());\n }*/\n buf[(startIdx+toBeConsumed)%size]=m;\n //System.out.println(\"Inserting \"+m);\n toBeConsumed++;\n\n /*\n If the buffer is no more empty, notify to consumer\n */\n if(toBeConsumed>=windowSize)\n notifyAll();\n }", "public sendRecordBuffer_result(sendRecordBuffer_result other) {\n }", "private void putOneQueue(BlockingQueue q, List buffer) throws InterruptedException {\n q.put(buffer);\n// System.err.println(Thread.currentThread().getName() + \"[MC] puts \" + buffer.size() + \" on \" + q.hashCode() + \" done\");\n// System.err.println(Thread.currentThread().getName() + \"[MC] puts \" + buffer.size() + \" on \" + q.hashCode() + \" first record \" + buffer.get(0));\n }", "public abstract void addDevice(Context context, NADevice device);", "@DSGenerator(tool_name = \"Doppelganger\", tool_version = \"2.0\", generated_on = \"2013-12-30 12:58:16.404 -0500\", hash_original_method = \"4BC9AB9F0FAFDEDE82B7BBC20123D960\", hash_generated_method = \"3DBDB7C376D519DEE7688C4D9E9259E5\")\n \n public boolean eglCopyBuffers(EGLDisplay display, EGLSurface surface, Object native_pixmap){\n \taddTaint(display.getTaint());\n \taddTaint(surface.getTaint());\n \taddTaint(native_pixmap.getTaint());\n \treturn getTaintBoolean();\n }", "public void newBufLine() {\n this.buffer.add(new ArrayList<Integer>());\n this.columnT = 0;\n this.lineT++;\n }", "public native int sendBuf(ByteBuffer buffer, int bufferSize, long nativeHandle);", "public interface Buffer {\r\n\tpublic void add(String s);\r\n\tpublic String retrieve();\r\n}", "public void insertIntoByteBuffer(ByteBuffer buffer)\n {\n \tbuffer.putDouble(j2ksec);\n \tbuffer.putInt(rid);\n \tbuffer.putDouble(lat);\n \tbuffer.putDouble(lon);\n \tbuffer.putDouble(depth);\n \tbuffer.putDouble(prefmag);\n\n \tbuffer.putDouble(ampmag);\n \tbuffer.putDouble(codamag);\n \tbuffer.putInt(nphases);\n \tbuffer.putInt(azgap);\n \tbuffer.putDouble(dmin);\n \tbuffer.putDouble(rms);\n \tbuffer.putInt(nstimes);\n \tbuffer.putDouble(herr);\n \tbuffer.putDouble(verr);\n \t\n \t// We'll represent characters by their ASCII codes, using -1 for null \n \tif ( magtype != null && magtype.length() > 0 )\n \t\tbuffer.putInt((int)(magtype.charAt(0)));\n \telse\n \t\tbuffer.putInt(-1);\n \tif ( rmk != null && rmk.length() > 0 )\n \t\tbuffer.putInt((int)(rmk.charAt(0)));\n \telse\n \t\tbuffer.putInt( -1 );\n}", "public void write(byte[] buffer) { //이건 보내주는거\n try {\n mmOutStream.write(buffer);\n\n // Disabled: Share the sent message back to the main thread\n mHandler.obtainMessage(MESSAGE_WRITE, -1, -1, buffer).sendToTarget(); //MH주석풀엇음 //what arg1, arg2 obj\n\n } catch (IOException e) {\n Log.e(TAG, \"Exception during write\");\n }\n }", "public void write_to_buffer(byte[] buffer) throws IOException {\r\n ByteArrayOutputStream byte_out = new ByteArrayOutputStream(buffer.length);\r\n DataOutputStream out = new DataOutputStream(byte_out);\r\n\r\n write_to_buffer(out);\r\n\r\n byte[] bytes = byte_out.toByteArray();\r\n for (int i = 0; i < buffer.length; ++i) {\r\n buffer[i] = bytes[i];\r\n }\r\n\r\n out.close();\r\n byte_out.close();\r\n }", "public void fromBuffer(ByteBufWrapper paramhd)\r\n/* 18: */ {\r\n/* 19:35 */ this.b = ((np)a.fromJson(paramhd.c(32767), np.class));\r\n/* 20: */ }", "public void toBuffer(FloatBuffer buffer) {\n buffer.put(m00).put(m10).put(m20).put(m30);\n buffer.put(m01).put(m11).put(m21).put(m31);\n buffer.put(m02).put(m12).put(m22).put(m32);\n buffer.put(m03).put(m13).put(m23).put(m33);\n buffer.flip();\n }", "public final EObject entryRuleBuffer() throws RecognitionException {\n EObject current = null;\n\n EObject iv_ruleBuffer = null;\n\n\n try {\n // InternalStl.g:927:47: (iv_ruleBuffer= ruleBuffer EOF )\n // InternalStl.g:928:2: iv_ruleBuffer= ruleBuffer EOF\n {\n if ( state.backtracking==0 ) {\n newCompositeNode(grammarAccess.getBufferRule()); \n }\n pushFollow(FOLLOW_1);\n iv_ruleBuffer=ruleBuffer();\n\n state._fsp--;\n if (state.failed) return current;\n if ( state.backtracking==0 ) {\n current =iv_ruleBuffer; \n }\n match(input,EOF,FOLLOW_2); if (state.failed) return current;\n\n }\n\n }\n\n catch (RecognitionException re) {\n recover(input,re);\n appendSkippedTokens();\n }\n finally {\n }\n return current;\n }", "public abstract void setBufferMode(int mode);", "public void store(FloatBuffer buf){\n\t\tambient.store(buf);\n\t\tdiffuse.store(buf);\n\t\tspecular.store(buf);\n\t\tposition.store(buf);\n\t\tbuf.put(range);\n\t\tdirection.store(buf);\n\t\tbuf.put(spot);\n\t\tatt.store(buf);\n\t\tbuf.put(pad);\n\t}", "void encode(ByteBuffer buffer, Message message);", "@Override\n void enqueuePiece(ByteBuffer buffer, int index, int position, int length, Object params)\n {\n// if (DEBUG) System.out.println(\"[stdpc] enqueuePiece:\" + index + \",\" + position + \",\" + length + \" buf:\" + buffer.remaining());\n// sendQueue.forEach(pm ->\n// System.out.println(\" -s> \" + System.identityHashCode(pm) + \" \" +pm.type + \" ,\" + pm.index +\",\" + pm.begin + \",\" + pm.length)\n// );\n// peerBlockRequests.forEach(pm -> {\n// System.out.println(\" -p> \" + pm.type + \" ,\" + pm.index +\",\" + pm.begin + \",\" + pm.length);\n// });\n\n\n boolean found = false;\n\n // check for the active linked peer request and remove it\n for (int i = 0; i < peerBlockRequests.size(); i++) {\n StdPeerMessage pm = peerBlockRequests.get(i);\n if ((pm.index == index)\n && (pm.begin == position)\n && (pm.length == length))\n {\n peerBlockRequests.remove(i);\n pmCache.release(pm);\n found = true;\n break;\n }\n }\n if (!found && DEBUG) {\n if (DEBUG) System.out.println(\"[stdpc] pBR not found\");\n }\n\n enqueue(pmCache.piece(index, position, length, buffer, params));\n }", "@Override\n public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException\n {\n if ( buffer == null )\n {\n throw new EncoderException( I18n.err( I18n.ERR_08000_CANNOT_PUT_A_PDU_IN_NULL_BUFFER ) );\n }\n\n try\n {\n // The ExtensibleMatch Tag\n buffer.put( ( byte ) LdapCodecConstants.EXTENSIBLE_MATCH_FILTER_TAG );\n buffer.put( TLV.getBytes( extensibleMatchLength ) );\n\n if ( ( matchingRule == null ) && ( type == null ) )\n {\n throw new EncoderException( I18n.err( I18n.ERR_05500_NULL_MATCHING_RULE_AND_TYPE ) );\n }\n\n // The matching rule\n if ( matchingRule != null )\n {\n buffer.put( ( byte ) LdapCodecConstants.MATCHING_RULE_ID_TAG );\n buffer.put( TLV.getBytes( matchingRuleBytes.length ) );\n buffer.put( matchingRuleBytes );\n }\n\n // The type\n if ( type != null )\n {\n buffer.put( ( byte ) LdapCodecConstants.MATCHING_RULE_TYPE_TAG );\n buffer.put( TLV.getBytes( typeBytes.length ) );\n buffer.put( typeBytes );\n }\n\n // The match value\n if ( matchValue != null )\n {\n buffer.put( ( byte ) LdapCodecConstants.MATCH_VALUE_TAG );\n\n byte[] bytes = matchValue.getBytes();\n int bytesLength = bytes.length;\n buffer.put( TLV.getBytes( bytesLength ) );\n\n if ( bytesLength != 0 )\n {\n buffer.put( bytes );\n }\n\n }\n\n // The dnAttributes flag, if true only\n if ( dnAttributes )\n {\n buffer.put( ( byte ) LdapCodecConstants.DN_ATTRIBUTES_FILTER_TAG );\n buffer.put( ( byte ) 1 );\n buffer.put( BerValue.TRUE_VALUE );\n }\n }\n catch ( BufferOverflowException boe )\n {\n throw new EncoderException( I18n.err( I18n.ERR_08212_PDU_BUFFER_TOO_SMALL ), boe );\n }\n\n return buffer;\n }", "public synchronized static byte[] Append ( byte[] packetA, byte[] packetB )\n {\n // Create a new array whose size is equal to sum of packets\n // being added\n byte packetAB [] = new byte [ packetA.length + packetB.length ];\n\n // First paste in packetA\n for ( int i=0; i < packetA.length; i++ )\n packetAB [i] = packetA [i];\n\n // Now start pasting packetB\n for ( int i=0; i < packetB.length; i++ )\n packetAB [i+packetA.length] = packetB [i];\n\n return packetAB;\n }", "protected int route(byte buffer[], int source) {\n \n // Get the message level\n byte messageLevel = getMessageLevel( buffer );\n // get the messageID\n byte messageID[] = getMessageID( buffer );\n \n // Check that the message was not received before\n if( messageIsNew( messageID )){\n \trecordMessageID( messageID );\n }\n else{\n \treturn Constants.SUCCESS;\n }\n \n // If I am not the sender of the message\n // add it to the message queue\n if (messageLevel == Constants.MESSAGE_ALL && source != Constants.SRC_ME){\n // Add message to message queue\n \taddMessageToQueue( buffer );\n }\n else if (messageLevel == Constants.MESSAGE_TARGET){\n \tbyte[] target = getTarget( buffer );\n \tif (target == this.address) {\n \t\t//Add to the message queue\n \t\treturn Constants.SUCCESS; //DO NOT send to all threads.\n \t}\n }\n \n // Send the message to all the threads\n synchronized (this.rwThreads) {\n for (ReadWriteThread aThread : rwThreads) {\n Log.d(TAG, \"Writing to device on thread: \" + aThread.getName());\n aThread.write(buffer);\n }\n }\n \n return Constants.SUCCESS;\n }", "void onSomething(org.jboss.netty.buffer.ChannelBuffer buffer);", "abstract public Buffer createBufferFromData(byte[] data, int size);", "protected final boolean growBuffer(int type) {\n if( null !=buffer && !sealed ) {\n if( !fitElementInBuffer(type) ) {\n // save olde values ..\n final Buffer _vertexArray=vertexArray, _colorArray=colorArray, _normalArray=normalArray, _textCoordArray=textCoordArray;\n \n if ( reallocateBuffer(resizeElementCount) ) {\n if(null!=_vertexArray) {\n _vertexArray.flip();\n Buffers.put(vertexArray, _vertexArray);\n }\n if(null!=_colorArray) {\n _colorArray.flip();\n Buffers.put(colorArray, _colorArray);\n }\n if(null!=_normalArray) {\n _normalArray.flip();\n Buffers.put(normalArray, _normalArray);\n }\n if(null!=_textCoordArray) {\n _textCoordArray.flip();\n Buffers.put(textCoordArray, _textCoordArray);\n }\n return true;\n }\n }\n }\n return false;\n }", "@Override\r\n\tpublic void addEvent(NetworkEvent e) {\n\t\tif (e.getType() == NetworkEvent.SEND && buffer_sz > e.getPDU().size) {\r\n\t\t\tTCPBony kid = (TCPBony) e.getTarget();\r\n\t\t\tTCPMessage m = (TCPMessage) e.getPDU();\r\n\t\t\tFlowId fid = new FlowId(m.src, m.dest, m.getSport(), m.getDport());\r\n\t\t\tif (kid.isElephant()) {\r\n\t\t\t\tdard.addElephantFlow(fid);\r\n\t\t\t} else\r\n\t\t\t\tdard.addMiceFlow(fid);\r\n\t\t\t\r\n\t\t\tint i = connections.indexOf(kid);\r\n\t\t\te.setTarget(this);\r\n\t\t\tsend_buffer.get(i).add(e);\r\n\t\t\tbuffer_sz -= e.getPDU().size;\r\n\t\t} else if (e.getType() == NetworkEvent.RECEIVE) {\r\n\t\t\treceived_buffer.add(e);\r\n\t\t} else {\r\n\t\t\t// System.out.println(this.getName() + \" Drop packet due to buffer overflow: \" + buffer_sz + \r\n\t\t\t//\t\" from \" + ((TCPMessage) e.getPDU()).getSport() + \r\n\t\t\t//\t\" Seq: \" + ((TCPMessage) e.getPDU()).getSeq());\r\n\t\t}\r\n\t}", "void setStreamBuffer(int size) {\r\n\t\tif(size>0)\r\n\t\t\tbuffer = new byte[size];\r\n\t\telse\r\n\t\t\tbuffer = new byte[this.size];\r\n\t}", "public void nextPacket(PcapHeader header, JBuffer buffer, T user);", "@Override\r\n public void handle(Buffer inBuffer) {\n \tlogger.debug(name_log + \"----------------------------------------------------------------------------\");\r\n \t//logger.debug(name_log + \"incoming data: \" + inBuffer.length());\r\n String recvPacket = inBuffer.getString(0, inBuffer.length());\r\n \t\r\n //logger.debug(name_log + \"read data: \" + recvPacket);\r\n logger.info(name_log + \"RECV[\" + recvPacket.length() + \"]> \\n\" + recvPacket + \"\\n\");\r\n \r\n \r\n // -- Packet Analyze ----------------------------------------------------------------\r\n // Writing received message to event bus\r\n\t\t\t\t\r\n JsonObject jo = new JsonObject();\r\n \r\n jo.put(\"recvPacket\", recvPacket);\r\n \r\n eb.send(\"PD_Trap\" + remoteAddr, jo);\r\n\r\n // -- RESPONSE, Send Packet to Target -----------------------------------------------\r\n eb.consumer(remoteAddr + \"Trap_ACK\", message -> {\r\n \twriteToTarget(message.body().toString(), \"Trap_ACK\");\r\n });\r\n \r\n eb.consumer(remoteAddr + \"Trap_NACK\", message -> {\r\n \twriteToTarget(message.body().toString(), \"Trap_NACK\");\r\n });\r\n \r\n }", "public void appendSubPackage(byte[] buffer, int off, int count) {\n appendSubPackage(new DsByteString(buffer, off, count));\n }", "Buffer copy();", "public void handleBeamBuffer(ByteBuffer beamBuf);", "@Override\n public void queueInputBuffer(\n int index, int offset, int size, long presentationTimeUs, int flags) {\n bufferEnqueuer.queueInputBuffer(index, offset, size, presentationTimeUs, flags);\n }", "public void testAppend() {\n test1.append(new Buffer(3, rec));\n test1.append(new Buffer(3, rec));\n test1.append(new Buffer(3, rec));\n test1.append(new Buffer(3, rec));\n test1.append(new Buffer(3, rec));\n test1.append(new Buffer(3, rec));\n assertEquals(6, test1.length());\n }", "@Override\n public void queueDeviceWrite(IpPacket packet) {\n\n deviceWrites.add(packet.getRawData());\n }", "@Override\n protected void releaseBuffer() {\n }" ]
[ "0.63537216", "0.6316489", "0.6258223", "0.60235643", "0.59631926", "0.5756998", "0.5610138", "0.5609633", "0.56080014", "0.55340123", "0.55137014", "0.5483179", "0.53945076", "0.53898877", "0.53403753", "0.53253233", "0.5302608", "0.52893335", "0.52522206", "0.5215297", "0.52053833", "0.5204354", "0.5196427", "0.5196388", "0.51957524", "0.51829123", "0.51711696", "0.5164286", "0.5160388", "0.5132525", "0.51087695", "0.50979", "0.5081807", "0.5072389", "0.506337", "0.5043", "0.50349647", "0.502337", "0.5018973", "0.5008008", "0.4983687", "0.4971996", "0.49468064", "0.49361727", "0.4935911", "0.49169007", "0.491192", "0.4901546", "0.48830554", "0.4871577", "0.48494917", "0.484724", "0.4845499", "0.4823617", "0.4818788", "0.4813816", "0.48094288", "0.480432", "0.48034695", "0.4802267", "0.479628", "0.47939813", "0.4783855", "0.47694522", "0.4756627", "0.4745384", "0.4743112", "0.47411865", "0.47165787", "0.4701565", "0.46914816", "0.46804008", "0.46790168", "0.46721342", "0.46694314", "0.46684274", "0.46669233", "0.46516806", "0.46464476", "0.46438393", "0.46395278", "0.46341747", "0.46324202", "0.46289393", "0.46265057", "0.46237773", "0.45845574", "0.4582745", "0.45775524", "0.45772776", "0.4574202", "0.45653152", "0.45583063", "0.4556677", "0.455528", "0.4536206", "0.45240435", "0.45203018", "0.4518684", "0.45148396" ]
0.6846385
0
The name of the player
public String getName() { return name; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public String getName(){\r\n\t\treturn playerName;\r\n\t}", "public String getName()\r\n\t{\r\n\t\treturn this.playerName;\r\n\t}", "public String getPlayerName() {\n return props.getProperty(\"name\");\n }", "public String getPlayerName() {\n\t\treturn name;\n\t}", "String getPlayerName();", "public String getPlayerName() {\n\t\tString name = super.getPlayerName();\n\t\treturn name;\n\t}", "String getName(){\n\t\treturn playerName;\n\t}", "public String getPlayerName() {\n return nameLabel.getText().substring(0, nameLabel.getText().indexOf('\\''));\n }", "public String getName(Player p) {\n\t\treturn name;\n\t}", "public String getPlayerName(){\n\t\treturn playerName;\n\t}", "public String getPlayerName() {\n return name; \n }", "String getName() {\n return getStringStat(playerName);\n }", "public String getPlayerName() {\n return this.playerName;\n }", "@Override\n\tpublic String getPlayerName() {\n\t\treturn playerName;\n\t}", "public String getPlayerName() {\n return playerName;\n }", "public String getPlayerName() {\n return playerName;\n }", "public String getPlayerName() {\n\t\treturn playerName;\n\t}", "public String getPlayerName() {\n \treturn playername;\n }", "public String getPlayerName() {\n\n return m_playerName;\n }", "public String getName(){\n\t\treturn players.get(0).getName();\n\t}", "@Override\n public String getPlayerName()\n {\n if (currentPlayer == 0)\n {\n return playerOneName;\n }\n else\n {\n return playerTwoName;\n }\n }", "public void setPlayerName(String name) {\n \tplayername = name;\n }", "public java.lang.String getPlayerName() {\n java.lang.Object ref = playerName_;\n if (ref instanceof java.lang.String) {\n return (java.lang.String) ref;\n } else {\n com.google.protobuf.ByteString bs = \n (com.google.protobuf.ByteString) ref;\n java.lang.String s = bs.toStringUtf8();\n playerName_ = s;\n return s;\n }\n }", "public java.lang.String getPlayerName() {\n java.lang.Object ref = playerName_;\n if (!(ref instanceof java.lang.String)) {\n com.google.protobuf.ByteString bs =\n (com.google.protobuf.ByteString) ref;\n java.lang.String s = bs.toStringUtf8();\n playerName_ = s;\n return s;\n } else {\n return (java.lang.String) ref;\n }\n }", "abstract public String getNameFor(Player player);", "private String getPlayerName() {\n SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);\n String storedName = preferences.getString(\"playerName\",\"none\");\n return storedName;\n }", "public String getPlayername(Player player) {\n System.out.println(\"――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――\");\n System.out.println(\"Merci de d'indiquer le nom du joueur \"+player.getColor().toString(false)+\" : \");\n String name = readInput.nextLine();\n return name;\n }", "java.lang.String getGameName();", "java.lang.String getGameName();", "public String myGetPlayerName(String name) { \n Player caddPlayer = getServer().getPlayerExact(name);\n String pName;\n if(caddPlayer == null) {\n caddPlayer = getServer().getPlayer(name);\n if(caddPlayer == null) {\n pName = name;\n } else {\n pName = caddPlayer.getName();\n }\n } else {\n pName = caddPlayer.getName();\n }\n return pName;\n }", "String getNewPlayerName();", "private String getPlayerName() {\n Bundle inBundle = getIntent().getExtras();\n String name = inBundle.get(USER_NAME).toString();\n return name;\n }", "public void setName(String name)\r\n\t{\r\n\t\tthis.playerName = name;\r\n\t}", "public String getLoggedPlayerName() {\r\n return ctrlDomain.getLoggedPlayerName();\r\n }", "@Override\r\n\tpublic void SavePlayerName() {\r\n\t\tPlayer player = (Player)Player.getPlayerInstance();\r\n\t\t\r\n\t\tString file = \"PlayerName.txt\";\r\n\t\tString playerName = player.getName();\r\n\t\ttry{\r\n\t\t\tPrintWriter print = new PrintWriter(file);\r\n\t\t\tprint.println(playerName);\r\n\t\t}\r\n\t\tcatch(FileNotFoundException e)\r\n\t\t{\r\n\t\t\te.printStackTrace();\r\n\t\t\t\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t}", "public static String getNameOne() {\n\tString name;\n\tname = playerOneName.getText();\n\treturn name;\n\n }", "private String getPlayerName(int i) {\n\t\tSystem.out.println(\"\\nEnter Player \"+i+\"'s Name:\");\n\t\treturn GetInput.getInstance().aString();\n\t}", "private String getPlayerName() {\n EditText name = (EditText) findViewById(R.id.name_edittext_view);\n return name.getText().toString();\n }", "public void setPlayerName(String name) {\n\t\tsuper.setPlayerName(name);\n\t}", "private void getPlayertName() {\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t}", "Player(String name){\n\t\tthis.name = name;\n\t}", "public void setPlayerName(String playerName) {\n this.playerName = playerName;\n }", "public String getNewPlayerName() {\n return newPlayerName;\n }", "public String getDisplayName ( ) {\n\t\treturn handleOptional ( ).map ( Player :: getDisplayName ).orElse ( name );\n\t}", "public String getPlayer() {\r\n return player;\r\n }", "public void displayName(){\n player1.setText(p1.getName());\n player2.setText(p2.getName());\n }", "public com.google.protobuf.ByteString\n getPlayerNameBytes() {\n java.lang.Object ref = playerName_;\n if (ref instanceof java.lang.String) {\n com.google.protobuf.ByteString b = \n com.google.protobuf.ByteString.copyFromUtf8(\n (java.lang.String) ref);\n playerName_ = b;\n return b;\n } else {\n return (com.google.protobuf.ByteString) ref;\n }\n }", "public void setPlayer1Name(String name){\n player1 = name;\n }", "public void setName(String name)\n {\n playersName = name;\n }", "public String toString() {\n\t\treturn \"Player \" + playerNumber + \": \" + playerName;\n\t}", "String getPlayer();", "public String getPlayerName(){\n return this.playerName;\n\n }", "public com.google.protobuf.ByteString\n getPlayerNameBytes() {\n java.lang.Object ref = playerName_;\n if (ref instanceof String) {\n com.google.protobuf.ByteString b = \n com.google.protobuf.ByteString.copyFromUtf8(\n (java.lang.String) ref);\n playerName_ = b;\n return b;\n } else {\n return (com.google.protobuf.ByteString) ref;\n }\n }", "String player1GetName(){\n return player1;\n }", "String getPlayerName() {\r\n EditText editText = (EditText) findViewById(R.id.name_edit_text_view);\r\n return editText.getText().toString();\r\n }", "void setName(String name) {\n setStringStat(name, playerName);\n }", "public void setPlayerName(String name){\n\t\tplayerName = name;\n\t\trepaint();\n\t}", "public String getPlayerListName ( ) {\n\t\treturn handleOptional ( ).map ( Player :: getPlayerListName ).orElse ( name );\n\t}", "@Override\n\tpublic String getName() {\n\t\treturn \"Real Dumb Player by Group 10\";\n\t}", "public void setPlayerName(String playerName) {\n\t\tthis.playerName = playerName;\n\t}", "public String getFullPlayerName(Player otherPlayer) {\n return this.fullPlayerName;\n }", "public MultiLineText getGameScreenFullPlayerName() {\n if (this.gameScreenFullPlayerName == null) {\n String[] strTemp = { this.fullPlayerName };\n this.gameScreenFullPlayerName = new MultiLineText(strTemp, 10, 10, Color.black, 15.0f, \"Lucida Blackletter\", ImageLibRef.TEXT_PRIORITY, MultiLineText.LEFT_ALIGNMENT);\n }\n\n return this.gameScreenFullPlayerName;\n }", "Player(String playerName) {\n this.playerName = playerName;\n }", "public String getPlayerName(UUID id) {\n return playerRegistry.get(id);\n }", "private void setName(String nameIn){\r\n\t\tplayerName = nameIn;\r\n\t}", "public void setPlayer2Name(String name){\n player2 = name;\n }", "public Player(String name) {\r\n this.name = name;\r\n }", "public String getName() {\n\t\treturn songName;\n\t}", "private String getPlayerName() {\n\t\tString[] options = {\"OK\"};\n\t\tJPanel namePanel = new JPanel(new GridLayout(0, 1));\n\t\tJLabel lbl = new JLabel(\"Next player, what is your name?\");\n\t\tJTextField txt = new JTextField(10);\n\t\tnamePanel.add(lbl);\n\t\tnamePanel.add(txt);\n\t\t\n\t\t// show dialog box\n\t\tJOptionPane.showOptionDialog(frame, namePanel, \"Player name\",\n\t\t\t\tJOptionPane.NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options , options[0]);\n\t\tString playerName = txt.getText();\n\t\twhile(playerName.length() < 1){\n\t\t\tlbl.setText(\"Name must be at least one character long.\");\n\t\t\tJOptionPane.showOptionDialog(frame, namePanel, \"Player name\",\n\t\t\t\t\tJOptionPane.NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options , options[0]);\n\t\t\tplayerName = txt.getText();\n\t\t}\n\t\treturn playerName;\n\t}", "String getName() ;", "String player2GetName(){\n return player2;\n }", "public void updateName(Player player)\n {\n String oldName = playerLabel.getText();\n playerLabel.setText(player.getName());\n if (player.getName().equalsIgnoreCase(\"Disconnesso\"))\n {\n waiting(player.getName());\n }\n }", "public String getCurrentNickname() {\n return currentPlayer.getNickName();\n }", "String randomPlayer1GetName(){\n return randomPlayer1;\n }", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();", "String getName();" ]
[ "0.8772222", "0.8730548", "0.859032", "0.8522921", "0.84710735", "0.8447968", "0.83996695", "0.83857095", "0.83485186", "0.83278143", "0.8303809", "0.8294846", "0.8284124", "0.8263274", "0.8258271", "0.8258271", "0.81878924", "0.81633806", "0.8129097", "0.7981684", "0.79553956", "0.7921728", "0.7865361", "0.7852521", "0.78383356", "0.7814551", "0.7813498", "0.7754583", "0.7754583", "0.7700274", "0.76275367", "0.7590157", "0.75807166", "0.75654685", "0.75649536", "0.7530316", "0.74539787", "0.74469626", "0.74304086", "0.7409805", "0.7384638", "0.7380338", "0.73703665", "0.73584664", "0.7302052", "0.7290471", "0.72868633", "0.72712535", "0.726834", "0.72625357", "0.72484946", "0.72407246", "0.7211613", "0.7159057", "0.7134477", "0.71096563", "0.71066576", "0.7101741", "0.7089117", "0.7075891", "0.70630836", "0.70421284", "0.704094", "0.703399", "0.70313007", "0.7024928", "0.7014995", "0.7012526", "0.69920295", "0.6991258", "0.6975724", "0.6974456", "0.6965611", "0.6936525", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486", "0.6924486" ]
0.0
-1
System.out.println("The territory List: " + this.getTerritories()); System.out.println("The UniqueID: " + to.getUniqueID()); System.out.println("The territory List size: " + this.getTerritories().size());
public void setToTerritory(Territory to) { to_territory = getTerritories().get(to.getUniqueID()); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@SkipValidation\r\n\tpublic String invokeTerritoryList() throws Exception{\r\n\t\t\r\n\t\t //territoryList=dao_impl.fetchTerritory(); ------>>>>>Written in prepare method, so commented\r\n\t\t dsgnList = dao_impl.fetchDesignation();\r\n\t\t bloodGrpList = dao_impl.fetchBloodGroup();\r\n\t\t stateList = dao_impl.fetchState();\r\n\t\t cityList = dao_impl.fetchCity();\r\n\t\t regionList = dao_impl.fetchRegion();\r\n\t\t stateList = dao_impl.fetchState();\r\n\t\t \r\n\t\t System.out.println(\"size of bloodGrpList in AddMRAction class --->> \"+bloodGrpList.size());\r\n\t\t \r\n\t\t return \"SUCCESS\";\r\n\t\t\r\n\t}", "public static List<Territory> getTerritoryList(Map map) {\n\t\tList<Territory> allterritoriesList = new ArrayList<Territory>();\n\t\tif (map.getContinents() != null) {\n\t\t\tfor (Continent continent : map.getContinents()) {\n\t\t\t\tif (continent != null && continent.getTerritories() != null) {\n\t\t\t\t\tfor (Territory territory : continent.getTerritories()) {\n\t\t\t\t\t\tallterritoriesList.add(territory);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(\"Total No of Territories : \"+allterritoriesList.size());\n\t\treturn allterritoriesList;\n\t}", "public ArrayList<Territory> getAdjacentTerritories() {\r\n\t\treturn adjacentTerritories;\r\n\t}", "public String getTerritory() {\n return territory;\n }", "public Territory linkedTerr() {\n return TERRITORY;\n \n }", "public Territory(int territoryID) {\n\t\tthis.territoryID = territoryID;\n\t\tneighbours = new ArrayList<>();\n\t\tunitsList = new ArrayList<>();\n\t\tplayerID = 0;\n\t\tunits = 0;\n\t}", "java.util.List<WorldUps.UTruck> \n getTruckstatusList();", "public String toString() {\n return satelliteList.toString();\n }", "@Override\n public String toString() {\n return getCounty();\n }", "int getLocationsCount();", "java.util.List<WorldUps.UInitTruck> \n getTrucksList();", "@Override\npublic String toString() {\n\treturn \tthis.getCity() + \"\\n\" +this.situation +\", temperature=\" + this.temperature +\", humidity= \" + this.humidity + \", wind= \" + this.wind ;\n}", "@Override\n public void update(App_Risk_Game.src.interfaces.Observable observable) {\n List<String> territories = new ArrayList<>();\n Iterator iterator = ((Board)observable).getTiles().keySet().iterator();\n while (iterator.hasNext()){\n String name = (String) iterator.next();\n territories.add(name);\n }\n CardsCollection cardsCollection = new CardsCollection(territories, 5);\n List<Player> players = PlayerCollectionTest.players;\n CardsCollection.distributeCards(players);\n for (Player p:players\n ) {\n System.out.println(p.getName());\n\n System.out.println(p.getTerritories());\n }\n Turns.turns.setCurrentPlayerID(players.get(0).getId());\n Turns.turns.setCurrent_player(players.get(0).getName());\n }", "private int countTrees()//has issues!! Should the counting happen in the \n //plant class? Or in the field? Or new grid class?\n {\n int trees = 0;\n Field field = getField();\n Location currant = getLocation();\n List<Object> plantList = field.getObjectAt(currant);\n \n while(it.hasNext()) {\n plantList.add(field.getObjectAt(currant));\n if(plant instanceof Tree) {\n trees++;\n }\n }\n return trees;\n }", "public void getTowns(SecurityUserBaseinfoForm form) {\n\t\tString[] tempIds = null;\r\n\t\tString[] tempNames = null;\r\n\t\tList<?> list = null;\r\n//\t\tcommCltIds & commCltNames;\r\n\t\tif(form.getCommConfigLocationTownId() != null && form.getCommConfigLocationTownId().trim().length() > 0){\r\n\t\t\tlist = this.getSecurityUserBaseinfoDAO().getTownsByParent(form.getCommConfigLocationTownId().trim());\r\n\t\t\tif(list != null && list.size() > 0){\r\n\t\t\t\ttempIds = new String[list.size()+1];\r\n\t\t\t\ttempNames = new String[list.size()+1];\r\n\t\t\t\ttempIds[0] = \"\";\r\n\t\t\t\ttempNames[0] = \"\";\r\n\t\t\t\tfor(int i=0; i<list.size(); i++){\r\n\t\t\t\t\tCommConfigLocationTown town = (CommConfigLocationTown)list.get(i);\r\n\t\t\t\t\ttempIds[i+1] = this.transNullToString(town.getId());\r\n\t\t\t\t\ttempNames[i+1] = this.transNullToString(town.getItemName());\r\n\t\t\t\t}\r\n\t\t\t\tform.setCommConfigLocationTownIds(tempIds);\r\n\t\t\t\tform.setCommConfigLocationTownId_names(tempNames);\r\n\t\t\t}\r\n\t\t}\r\n\t}", "public int getNumTowns() {\n \t\treturn towns;\n \t}", "public void setTerritories(Territory[] territories) {\r\n this.territories = territories;\r\n }", "@Override\n @Transactional(readOnly = true)\n public List<OraganizationalUnit> findAll() {\n log.debug(\"Request to get all OraganizationalUnits\");\n return oraganizationalUnitRepository.findAll();\n }", "@Override\n public String toString() {\n return this.toList().toString();\n }", "public List<Integer> getTeritory() {\n return teritory;\n }", "private String companies() {\r\n\t\tint num=tile.getCompaniesNum();\r\n\t\tString out=\"Total Companies: \"+num;\r\n\t\treturn out;\r\n\t}", "@Override\n public int getBanking_organizationsCount() throws SystemException {\n return banking_organizationPersistence.countAll();\n }", "public int getSize(){return this.IdAgente.size();}", "public int getNumberOfItems() {\n \t\treturn regions.size();\n \t}", "@Test\n public void testGetLocations() {\n System.out.println(\"getLocations\");\n DTO_Ride instance = dtoRide;\n int locations = instance.getLocations().size();\n assertEquals(1, locations);\n }", "@Override\n\tpublic List<Regioni> findTutti() {\n\t\tList<RegioniEntity> listRegEnt = regioniRepository.findAll();\n\t\tList<Regioni> regioni = new ArrayList<>();\n\t\tfor(RegioniEntity regEnt : listRegEnt) {\t\n\t\t\tRegioni reg = new Regioni();\t\n\t\t\treg.setId(regEnt.getId());\n\t\t\treg.setRegione(regEnt.getNomeRegione());\n\t\t\tregioni.add(reg);\n\t\t}\n\t\t\n\t\treturn regioni;\n\t}", "public String toString(){\r\n return \"Local : \"+ idLocal + \" sigle : \"+ sigle +\" places : \"+ places + \" description : \"+ description;\r\n }", "int getEducationsCount();", "public void getOrganizations() {\n SQLiteDatabase db = this.getReadableDatabase();\n Cursor results = db.rawQuery(\"SELECT * FROM Organization\", null);\n if (results.moveToFirst()) {\n Log.e(\"ID\", results.getString(0));\n Log.e(\"Name\", results.getString(1));\n while (results.move(1)) {\n Log.e(\"ID\", results.getString(0));\n Log.e(\"Name\", results.getString(1));\n }\n results.close();\n }\n db.close();\n }", "public void list()\n {\n for(Personality objectHolder : pList)\n {\n String toPrint = objectHolder.getDetails();\n System.out.println(toPrint);\n }\n }", "public int size() { return _byHashCode.size(); }", "static ArrayList<RecipeList> GetRegionalRecipes() {\n\t\tArrayList<RecipeList> RegionalRecipes = new ArrayList<RecipeList>();\n\n\t\tfor (Recipe rec : Recipes) {\n\t\t\tboolean added = false;\n\t\t\tfor (RecipeList recList : RegionalRecipes) {\n\t\t\t\tif (rec.Region.equalsIgnoreCase(recList.Region)) {\n\t\t\t\t\tfor (String ing : rec.Ingredients) {\n\t\t\t\t\t\trecList.addIngredient(ing);\n\t\t\t\t\t\tadded = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (added == false) {\n\t\t\t\tRecipeList newList = new RecipeList(rec.Region);\n\t\t\t\tfor (String ing : rec.Ingredients) {\n\t\t\t\t\tnewList.addIngredient(ing);\n\t\t\t\t}\n\t\t\t\tRegionalRecipes.add(newList);\n\t\t\t\tadded = true;\n\t\t\t\tSystem.out.println(\"add\");\n\t\t\t}\n\t\t}\n\t\t/*\n\t\t * for(RecipeList a:RegionalRecipes){ System.out.println(a.get(2)); }\n\t\t */\n\t\treturn RegionalRecipes;\n\t}", "public static int numberOfCities(){\n return destinationCities.size();\n }", "public int size(){\r\n return boats.size();\r\n }", "@Override\n public String toString() {\n return Objects.toStringHelper(this) //\n .add(Decouverte_.id.getName(), getId()) //\n .add(Decouverte_.dateDecouverte.getName(), getDateDecouverte()) //\n .add(Decouverte_.observations.getName(), getObservations()) //\n .toString();\n }", "public void mostrarNumeroTareasPendientes(){\n System.out.println(tareas.size());\n }", "List<RegionalClassifierEntity> getItsListOfRegions();", "private void getMyTargetsList() {\n try {\n\n String qryTargets = Constants.Targets+ \"?$filter=\" +Constants.KPIGUID+ \" eq guid'\"\n + mStrBundleKpiGUID+\"'\" ;\n ArrayList<MyTargetsBean> alMyTargets = OfflineManager.getMyTargetsList(qryTargets, mStrParnerGuid,\n mStrBundleKpiName, mStrBundleKpiCode, mStrBundleKpiGUID,\n mStrBundleCalBased, mStrBundleKpiFor,\n mStrBundleCalSource, mStrBundleRollup,mStrBundleKPICat,true);\n\n ArrayList<MyTargetsBean> alOrderValByOrderMatGrp = OfflineManager.getActualTargetByOrderMatGrp(CRSSKUGroupWiseTargetsActivity.this,mStrCPDMSDIV);\n mapMyTargetValByCRSSKU = getALOrderVal(alOrderValByOrderMatGrp);\n mapMyTargetVal = getALMyTargetList(alMyTargets);\n sortingValues();\n } catch (OfflineODataStoreException e) {\n sortingValues();\n LogManager.writeLogError(Constants.strErrorWithColon + e.getMessage());\n }\n }", "public Integer getTownid() {\n return townid;\n }", "public void printAllCities()\n { // to be implemented in part (d) }\n }", "public Object getTotalTrophies() {\n\t\treturn this.totalTrophies;\n\t}", "public String getState() {\r\n StringBuilder builder = new StringBuilder();\r\n builder.append(mLastLarge);\r\n builder.append(',');\r\n builder.append(mLastSmall);\r\n builder.append(',');\r\n for (int large = 0; large < 9; large++) {\r\n for (int small = 0; small < 9; small++) {\r\n builder.append(mSmallTiles[large][small].getOwner().name());\r\n builder.append(',');\r\n }\r\n }\r\n return builder.toString();\r\n }", "@Test\n\tpublic void listLocations(){\n\t\tList<Location> lists = locationService.queryLoctionsByLat(29.8679775, 121.5450105);\n\t\t//System.out.println(lists.size()) ;\n\t\tfor(Location loc : lists){\n\t\t\tSystem.out.println(loc.getAddress_cn());\n\t\t}\n\t}", "@Override\r\n\tpublic List<Area> getAreaList() {\n\t\tList<Area> areaList = areaDao.selectArea();\r\n\t\tSystem.out.println(areaList);\r\n\t\t\r\n\t\treturn areaList;\r\n\t}", "public String toString()\n {\n return getClass().getName() + \"[name=\" + name + \",area=\" + area + \"]\";\n }", "public void roam() {\n\t\tSystem.out.println(this.name + \" the \" + this.type + \" inspected their territory.\");\n\t}", "public String toString()\n {\n return \"(\"+getType()+\")\"+getLocation(); \n }", "public void cityList(){\n System.out.println(\"List of cities: \\n\");\n\n for(int i = 0; i< cities.size(); i++){\n City city = cities.get(i);\n\n for(int j = 0; j<city.getAttractionsList().size(); j++){\n System.out.println((i+1) + \" \" + city.getCityName() + \" -- \" + (j+1) + \" \" + city.getAttractionsList().get(j));\n }\n\n if(city.getAttractionsList().size() == 0){\n System.out.println((i+1) + \" \" + city.getCityName());\n }\n }\n }", "public void updateAllTerritories() {\r\n\t\tBoard b = gameAgent.getBoard();\r\n\r\n\t\tfor(Entry<String, BoardLabel> e: labels.entrySet()) {\r\n\t\t\t// Convert to Territory type\r\n\t\t\tTerritory t = b.getTerritory(e.getKey());\r\n\t\t\t// Update the color with the current player\r\n\t\t\tString thisColor = playerColors.get(b.getPlayerFromTerritory(t));\r\n\t\t\te.getValue().setPlayerColor(thisColor);\r\n\t\t\t// Updates the total number of soldiers\r\n\t\t\te.getValue().setText(t.getNumSoldiers() + \"\");\r\n\t\t\t// Forces repaint\r\n\t\t\te.getValue().revalidate();\r\n\t\t\te.getValue().repaint();\r\n\t\t}\r\n\t\t\r\n\t}", "public int size() {\n return this.locationLst.size();\n }", "public int size()\r\n {\r\n\treturn chromos.size();\r\n }", "public String toString()\n {\n String outString = \n getLid() + \" \" +\n getAgency_code() + \" \" +\n getOffice() + \" \" +\n \"\" ;\n return outString;\n }", "public String toString(){\n\t\t\treturn competitors.toString();\n\t\t}", "public int size(){\n return trades.size();\n }", "@Override\n public String toString() {\n return \"Liste de \" + this.list.size() + \" polygones\";\n }", "public static void viewListOfRegistrants() {\n\t\tArrayList<Registrant> list_reg = getRegControl().listOfRegistrants();\r\n\t\tif (list_reg.size() == 0) {\r\n\t\t\tSystem.out.println(\"No Registrants loaded yet\\n\");\r\n\t\t} else {\r\n\t\t\tSystem.out.println(\"List of registrants:\\n\");\r\n\t\t\tfor (Registrant registrant : list_reg) {\r\n\t\t\t\tSystem.out.println(registrant.toString());\r\n\t\t\t}\r\n\t\t}\r\n\t}", "protected int[] getOwners() {\n \t\treturn owners;\n \t}", "public abstract List<Organism> getOrganisms();", "@Override\n\tpublic String getOutros() {\n\t\treturn hamburguer.getOutros();\n\t}", "public List<Tile> getOwnedTiles() {\n return new ArrayList<Tile>(ownedTiles);\n }", "public int getNumTroops(){\n return this.troops;\n }", "public void roadList(){\n for(int i = 0; i < roads.size(); i++){\n System.out.println(i + \" \" + roads.get(i).start.getCityName() + \", \" + roads.get(i).end.getCityName());\n }\n }", "int getAreaCount();", "int getAreaCount();", "int getAreaCount();", "public int getBedrooms(){\r\n return bedrooms;\r\n }", "@Override\n\t\t\tpublic int getRowCount() \n\t\t\t{\n\t\t\t\treturn partyList.size();\n\t\t\t}", "public int size(){\n return set.length;\n }", "@Override\r\n\tpublic List<Turista> conMasPuntos() {\n\t\treturn (List<Turista>) turistaDAO.conMasPuntos();\r\n\t}", "public LinkedList<City> totalCityList()\n {\n return cityContainer;\n }", "public int getIdOrganizacion()\r\n/* 94: */ {\r\n/* 95:150 */ return this.idOrganizacion;\r\n/* 96: */ }", "@Override\n\tpublic String toString() {\n\t\tString strg= \"Property Name: \"+propertyName\n\t +\"\\nLocated in \"+city\n\t +\"\\nBelonging to: \"+ owner\n\t +\"\\nRent Amount: \"+rentAmount+\"\\n\";\n\t\treturn strg;\n\t}", "@Override\r\n\tpublic List<String> getCities() {\n \tList<Note> notes = this.noteRepository.findAll();\r\n \tfor (Note note : notes) {\r\n\t\t\tSystem.out.println(note.getTitle());\r\n\t\t}\r\n\t\treturn hotelBookingDao.getCities();\r\n\t}", "public Integer getTrophies()\n\t{\n\t\treturn trophies;\n\t}", "@Override\n public ArrayList<ICatLocDetail> getLocalities() {\n return localities;\n }", "public int size()\n\t{\n\t\treturn creatures.size();\n\t}", "public String listOfUnitsInRent() {\n String outputline = \"Rented items.\" + System.lineSeparator();\n for (User user : userswithrentitems) {\n for (SportEquipment unit : user.getRenteditems())\n outputline += \"UserID: \" + user.getUserid() + \". Category: \" + unit.getCategory()\n + \". Title: \" + unit.getTitle()\n + \". Price: \" + unit.getPrice()\n + \".\"\n + System.lineSeparator();\n }\n if (outputline.isEmpty()) {\n outputline = \"No units in shop.\";\n }\n return outputline;\n }", "@Override\n public int size() {\n return theSet.size();\n }", "public String toString() {\n\tString formattedString = \"Owner Name: \" + this.name + \"\\n\" + \"Listings: \";\n\tfor (Listing listing : listings) {\n\t\tformattedString += listing.getName() + \"\\n\";\n\t}\n\treturn formattedString;\n }", "@Override\n public String toString()\n {\n StringBuilder sb = new StringBuilder();\n sb.append(tx2gtxMap.size()).append(\" mappings, \");\n sb.append(gtx2ContextMap.size()).append(\" transactions\");\n return sb.toString();\n }", "public String toString(){ \n\t return id+\" \"+name+\" \"+address; \n\t }", "public String toString()\n {\n StringBuilder locationString = new StringBuilder();\n locationString.append(entityName).append(\" (\").append(description).append(\"):\\n\");\n for (Entity entity : entityList) {\n locationString.append(\" \").append(entity.toString()).append(\"\\n\");\n }\n return locationString.toString();\n }", "@Override\r\n\tpublic List<Tramite_presentan_info_impacto> lista() {\n\t\treturn tramite.lista();\r\n\t}", "private static void displayStat() {\n Collection<Zone> zones = Universe.getInstance().getCarte().getCarte().values();\r\n System.out.println(\"Nb de personnes créées : \" + Universe.getInstance().getCarte().getPopulation().size());\r\n\r\n\r\n System.out.println(\"Nb de personnes créées en mer : \" + getPopulationByTile(Zone.Tile.SEA));\r\n System.out.println(\"Nb de personnes créées en plaine : \" + getPopulationByTile(Zone.Tile.EARTH));\r\n System.out.println(\"Nb de personnes créées en foret : \" + getPopulationByTile(Zone.Tile.FOREST));\r\n System.out.println(\"Nb de personnes créées en ville : \" + getPopulationByTile(Zone.Tile.TOWN));\r\n\r\n System.out.println(\"---------------\");\r\n\r\n System.out.println(\"Surface mer : \" + getSurfaceByTile(zones, Zone.Tile.SEA));\r\n System.out.println(\"Surface plaine : \" + getSurfaceByTile(zones, Zone.Tile.EARTH));\r\n System.out.println(\"Surface foret : \" + getSurfaceByTile(zones, Zone.Tile.FOREST));\r\n System.out.println(\"Surface ville : \" + getSurfaceByTile(zones, Zone.Tile.TOWN));\r\n\r\n System.out.println(\"---------------\");\r\n\r\n System.out.println(\"Densité mer : \" + new Double(getPopulationByTile(Zone.Tile.SEA) / getSurfaceByTile(zones, Zone.Tile.SEA)));\r\n System.out.println(\"Densité plaine : \" + new Double(getPopulationByTile(Zone.Tile.EARTH)) / new Double(getSurfaceByTile(zones, Zone.Tile.EARTH)));\r\n System.out.println(\"Densité foret : \" + new Double(getPopulationByTile(Zone.Tile.FOREST)) / new Double(getSurfaceByTile(zones, Zone.Tile.FOREST)));\r\n System.out.println(\"Densité ville : \" + new Double(getPopulationByTile(Zone.Tile.TOWN)) / new Double(getSurfaceByTile(zones, Zone.Tile.TOWN)));\r\n\r\n System.out.println(\"---------------\");\r\n System.out.println(\"Surface mer deserte : \" +zones.stream().filter(z-> z.getTile().equals(Zone.Tile.SEA) && CollectionUtils.isEmpty(z.getHabitants())).collect(Collectors.toList()).size());\r\n System.out.println(\"Surface plaine deserte : \" +zones.stream().filter(z-> z.getTile().equals(Zone.Tile.EARTH) && CollectionUtils.isEmpty(z.getHabitants())).collect(Collectors.toList()).size());\r\n System.out.println(\"Surface foret deserte: \" +zones.stream().filter(z-> z.getTile().equals(Zone.Tile.FOREST) && CollectionUtils.isEmpty(z.getHabitants())).collect(Collectors.toList()).size());\r\n System.out.println(\"Surface ville deserte: \" +zones.stream().filter(z-> z.getTile().equals(Zone.Tile.TOWN) && CollectionUtils.isEmpty(z.getHabitants())).collect(Collectors.toList()).size());\r\n System.out.println(\"---------------\");\r\n\r\n System.out.println(\"Surface mer habitée : \" +zones.stream().filter(z-> z.getTile().equals(Zone.Tile.SEA) && CollectionUtils.isNotEmpty(z.getHabitants())).collect(Collectors.toList()).size());\r\n System.out.println(\"Surface plaine habitée : \" +zones.stream().filter(z-> z.getTile().equals(Zone.Tile.EARTH) && CollectionUtils.isNotEmpty(z.getHabitants())).collect(Collectors.toList()).size());\r\n System.out.println(\"Surface foret habitée: \" +zones.stream().filter(z-> z.getTile().equals(Zone.Tile.FOREST) && CollectionUtils.isNotEmpty(z.getHabitants())).collect(Collectors.toList()).size());\r\n System.out.println(\"Surface ville habitée: \" +zones.stream().filter(z-> z.getTile().equals(Zone.Tile.TOWN) && CollectionUtils.isNotEmpty(z.getHabitants())).collect(Collectors.toList()).size());\r\n }", "public String list()\n {\n addressEntryList.sort(null);\n Iterator<AddressEntry> iterate = addressEntryList.iterator();\n Integer count = 1;\n String all = \"\";\n while(iterate.hasNext())\n {\n all += \"\\nEntry Number \" + count;\n all += iterate.next().toString();\n count++;\n }\n System.out.println(all);\n return all;\n }", "public String toString()\r\n {\r\n return super.toString() + \",\" + level + \", \" + Department + \"\\n\";\r\n }", "private int getUnitListValue() {\r\n\t\tint value = 0;\r\n\t\tfor (Unit unit : this.unitList) {\r\n\t\t\tvalue += unit.getValue();\r\n\t\t}\r\n\t\treturn value;\r\n\t}", "public String toString() {\n // returns information about property\n if (owner != null) {\n return owner.getName()+\",\"+numberHouses;\n }else{\n return \"NULL\";\n }\n }", "public ArrayList getComUnits();", "public String getInfoTitulos(){\r\n String infoTitulos = \"\";\r\n \r\n if(this.propriedadesDoJogador.size() > 0 || this.companhiasDoJogador.size() > 0){\r\n for(int i = 0; i < this.propriedadesDoJogador.size(); i++){\r\n infoTitulos += propriedadesDoJogador.get(i).getDescricao()+\"\\n\";\r\n }\r\n for(int i = 0; i < this.companhiasDoJogador.size(); i++){\r\n infoTitulos += companhiasDoJogador.get(i).getDescricao()+\"\\n\";\r\n }\r\n return infoTitulos;\r\n \r\n }else{\r\n return \"Você não possui títulos\";\r\n }\r\n }", "public abstract List<LocationDto> viewAll();", "protected abstract void getAllUniformLocations();", "public void getProvinceList() {\n Log.i(TAG, \"getProvinceList\");\n this.mCityShowMode = false;\n if (this.mCityCursor != null) {\n this.mCityCursor.close();\n this.mCityCursor = null;\n }\n if (this.mCityRedMan != null) {\n this.mCityCursor = this.mCityRedMan.queryProvinceRec();\n if (this.mCityCursor != null) {\n Log.i(TAG, \"mCityCursor count = \" + this.mCityCursor.getCount());\n } else {\n Log.i(TAG, \"mCityCursor count = null\");\n }\n }\n }", "public static void display(){\n \n //create an array : Remember positions\n //wheat= 0\n //Land = 1 \n //Population = 2\n \n String[] items = {\"Wheat\", \"Land\", \"Population\"};\n \n \n // call the crops object \n Crops theCrops = Game.getCrop();\n \n //get wheat\n int wheat = theCrops.getWheatInStore();\n \n //get land (acres)\n int acres = theCrops.getAcres();\n \n //get population \n \n int population = theCrops.getPopulation();\n \n //print results \n \n System.out.println(\"\\nInventory List:\");\n //wheat \n System.out.println(\"Wheat in Store:\" + wheat + \" bushels of \" + items[0]);\n //acres\n System.out.println(\"Acres of Land owned:\" + acres + \" acres of \" + items[1]);\n \n //population\n System.out.println(\"Current population:\" + population + \" people in the \" + items[2]);\n \n \n \n }", "public StateVariable getRelevantObjects () {\n return relevantObjects;\n }", "public String toString() {\n String memory = super.toString();\n return memory + \"(\" + locations + \", \" + vehicles + \")\";\n }", "public String toString() {\r\n //Done:this\r\n String s = super.toString()+String.format(\"; Owner: %s\", getOwner());\r\n if (hasPool()) {\r\n s+=\"; has a pool\";\r\n }\r\n if (calcLotArea()-calcBuildingArea() > calcBuildingArea()) {\r\n s+=\"; has a big open space\";\r\n }\r\n return s;\r\n }", "private static void mostrarRegiones (List<Regions> list)\n\t{\n\t\tIterator<Regions> it = list.iterator();\n\t\tRegions rg;\n\t\twhile (it.hasNext())\n\t\t{\n\t\t\trg = it.next();\n\t\t\tSystem.out.println(rg.getRegionName() + \" \" +rg.getRegionId());\n\t\t\tSet<Countries> paises = rg.getCountrieses();\n\t\t\tSystem.out.println(\"PAISES\");\n\t\t\tIterator<Countries> it_paises = paises.iterator();\n\t\t\t\n\t\t\twhile (it_paises.hasNext())\n\t\t\t{\n\t\t\t\tCountries country = it_paises.next();\n\t\t\t\tSystem.out.println(country.getCountryName());\n\t\t\t}\n\t\t}\n\t}", "@Override\n\tpublic String toString() {\n\t\tString travelListString = \"\";\n\t\tif (this.travelList.size() > 0)\n\t\t{\n\t\t\ttravelListString = this.travelList.get(0).getDestinationName() + \" : \" + this.travelList.get(0).getDestinationDescription();\n\t\t}\n\t\tfor (int index = 1; index < this.travelList.size(); index ++) {\n\t\t\ttravelListString = travelListString + \"\\n\" + this.travelList.get(index).getDestinationName() + \" : \" + this.travelList.get(index).getDestinationDescription();\n\t\t}\n\t\treturn travelListString;\n\t}", "int getTrucksCount();", "public static String getTechnicians(){\n \tList<Technician> technicians = Technician.findTechniciansByIsExternal(false);\n\n \tList<TechnicianMap> techniciansMapList = new ArrayList<TechnicianMap>();\n \t\n \tfor (Technician technician : technicians) {\n \t\tTechnicianMap tm = new TechnicianMap();\n \t\ttm.id = technician.id;\n \t\ttm.name = technician.firstName + \" \"+ technician.lastName;\n \t\ttm.longtitude = technician.contactInformation.address.geoPoint.longtitude;\n \t\ttm.latitude = technician.contactInformation.address.geoPoint.latitude;\n \t\ttm.rating = (float) 4.0;\n \t\ttechniciansMapList.add(tm);\n\t\t}\n \tGson gsonHandler = new Gson();\n \tString returnResult = gsonHandler.toJson(technicians);\n \tSystem.out.println( returnResult); \t\n \treturn gsonHandler.toJson(techniciansMapList);\n }" ]
[ "0.614029", "0.61298305", "0.58082455", "0.5786021", "0.565679", "0.5536391", "0.5499142", "0.54898477", "0.5459196", "0.54465216", "0.5438432", "0.5422674", "0.5407399", "0.5400805", "0.5381173", "0.53752255", "0.53729385", "0.5360333", "0.53533643", "0.53233415", "0.5303977", "0.5302151", "0.53004503", "0.5298236", "0.5292963", "0.52637625", "0.5258433", "0.5230061", "0.52219224", "0.5220535", "0.521607", "0.52100015", "0.5206846", "0.5206732", "0.5204149", "0.5202082", "0.518817", "0.51855314", "0.5177402", "0.517682", "0.5172557", "0.51710176", "0.5165733", "0.51654476", "0.51588875", "0.51551723", "0.51445144", "0.5144487", "0.5139429", "0.51373994", "0.5134042", "0.51331276", "0.5125631", "0.51244473", "0.51197535", "0.5112199", "0.5109144", "0.5105604", "0.51049984", "0.51040196", "0.50917906", "0.5091528", "0.50860053", "0.50860053", "0.50860053", "0.5081479", "0.5080124", "0.50777537", "0.50728935", "0.5070212", "0.5066801", "0.5066736", "0.50666314", "0.5065109", "0.5061675", "0.50607806", "0.506051", "0.5058347", "0.50547177", "0.50540835", "0.5048629", "0.5047652", "0.50443417", "0.5042684", "0.5041136", "0.5038962", "0.5032668", "0.50319207", "0.50317204", "0.5030791", "0.5029973", "0.5025173", "0.50229204", "0.5021176", "0.501812", "0.5014483", "0.5012699", "0.50104445", "0.50068504", "0.50043297", "0.50023425" ]
0.0
-1
BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARIABLE_DECLARATIONS END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARIABLE_DECLARATIONS BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTOR
public cmdAutoDrop() { addSequential(new cmdAutoDrive()); addSequential(new cmdAutoHopper()); addParallel(new cmdAutoHopDrive()); addSequential(new cmdAutoBack()); addSequential(new cmdAutoTurn()); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public AutonomousCommand() {\n \t\n\n // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTOR\n // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARIABLE_SETTING\n\n // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARIABLE_SETTING\n // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUIRES\n\n // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=R\tEQUIRES\n \t\n }", "public static void init() {\n // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS\n drivetrainSpeedController1 = new CANTalon(1);\n LiveWindow.addActuator(\"Drivetrain\", \"Speed Controller 1\", (CANTalon) drivetrainSpeedController1);\n \n drivetrainSpeedController2 = new CANTalon(2);\n LiveWindow.addActuator(\"Drivetrain\", \"Speed Controller 2\", (CANTalon) drivetrainSpeedController2);\n drivetrainSpeedController3 = new CANTalon(3);\n LiveWindow.addActuator(\"Drivetrain\", \"Speed Controller 2\", (CANTalon) drivetrainSpeedController3);\n drivetrainSpeedController4 = new CANTalon(4);\n LiveWindow.addActuator(\"Drivetrain\", \"Speed Controller 2\", (CANTalon) drivetrainSpeedController4);\n drivetrainSpeedController5 = new CANTalon(5);\n LiveWindow.addActuator(\"Drivetrain\", \"Speed Controller 2\", (CANTalon) drivetrainSpeedController5);\n drivetrainSpeedController6 = new CANTalon(6);\n LiveWindow.addActuator(\"Drivetrain\", \"Speed Controller 2\", (CANTalon) drivetrainSpeedController6);\n \n drivetrainRobotDrive21 = new RobotDrive(drivetrainSpeedController1, drivetrainSpeedController2, drivetrainSpeedController3, drivetrainSpeedController4, drivetrainSpeedController5, drivetrainSpeedController6);\n \n drivetrainRobotDrive21.setSafetyEnabled(true);\n drivetrainRobotDrive21.setExpiration(0.1);\n drivetrainRobotDrive21.setSensitivity(0.5);\n drivetrainRobotDrive21.setMaxOutput(1.0);\n\n\n // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS\n }", "public static void init() {\n // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS\n driveTrainmotor_leftFront = new Talon(1);\n LiveWindow.addActuator(\"DriveTrain\", \"motor_leftFront\", (Talon) driveTrainmotor_leftFront);\n \n driveTrainmotor_leftRear = new Talon(2);\n LiveWindow.addActuator(\"DriveTrain\", \"motor_leftRear\", (Talon) driveTrainmotor_leftRear);\n \n driveTrainmotor_rightFront = new Talon(3);\n LiveWindow.addActuator(\"DriveTrain\", \"motor_rightFront\", (Talon) driveTrainmotor_rightFront);\n \n driveTrainmotor_rightRear = new Talon(4);\n LiveWindow.addActuator(\"DriveTrain\", \"motor_rightRear\", (Talon) driveTrainmotor_rightRear);\n \n driveTrainRobotDrive = new RobotDrive(driveTrainmotor_leftFront, driveTrainmotor_leftRear,\n driveTrainmotor_rightFront, driveTrainmotor_rightRear);\n \n driveTrainRobotDrive.setSafetyEnabled(true);\n driveTrainRobotDrive.setExpiration(0.1);\n driveTrainRobotDrive.setSensitivity(0.5);\n driveTrainRobotDrive.setMaxOutput(1.0);\n\n liftmotor_Lift = new Talon(0);\n LiveWindow.addActuator(\"Lift\", \"motor_Lift\", (Talon) liftmotor_Lift);\n \n liftencoderLiftHeight = new Encoder(1, 2, true, EncodingType.k4X);\n LiveWindow.addSensor(\"Lift\", \"encoder LiftHeight\", liftencoderLiftHeight);\n liftencoderLiftHeight.setDistancePerPulse(1.0);\n liftencoderLiftHeight.setPIDSourceParameter(PIDSourceParameter.kRate);\n liftlimitBottom = new DigitalInput(0);\n LiveWindow.addSensor(\"Lift\", \"limitBottom\", liftlimitBottom);\n \n\n // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS\n }", "public static void init() {\n // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS\n\n frisbeeRollerFrisbeeRoller = new Talon(FRISBEE_ROLLER_CHANNEL);\n\n conveyorMotor = new Talon(CONV_MOTOR_CHANNEL);\n\n spatulaMotor = new Relay(SPATULA_MOTOR_CHANNEL);\n\n loadTalon = new Talon(LOADER_TALON);\n\n elevateTalon = new Talon(ELEVATE_TALON);\n\n try {\n driveTrainrearRightTalon = new CANJaguar(REAR_RIGHT_JAG_CHANNEL);\n\n driveTrainfrontRightTalon = new CANJaguar(FRONT_RIGHT_JAG_CHANNEL);\n\n driveTrainfrontLeftTalon = new CANJaguar(FRONT_LEFT_JAG_CHANNEL);\n\n driveTrainrearLeftTalon = new CANJaguar(REAR_LEFT_JAG_CHANNEL);\n\n shootershooterJag = new CANJaguar(SHOOTER_JAG_CHANNEL);\n } catch (CANTimeoutException ex) {\n ex.printStackTrace();\n }\n // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS\n }", "private Solution() {\n /**.\n * { constructor }\n */\n }", "private AnnotationTarget() {\n void var2_-1;\n void var1_-1;\n }", "private void initialize () {//GEN-END:|0-initialize|0|0-preInitialize\n // write pre-initialize user code here\n//GEN-LINE:|0-initialize|1|0-postInitialize\n // write post-initialize user code here\n}", "public static void init() {\r\n // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS\r\n driveTrainSubsystemleftFront = new Jaguar(1, 1);\r\n\tLiveWindow.addActuator(\"DriveTrainSubsystem\", \"leftFront\", (Jaguar) driveTrainSubsystemleftFront);\r\n \r\n driveTrainSubsystemleftRear = new Jaguar(1, 5);\r\n\tLiveWindow.addActuator(\"DriveTrainSubsystem\", \"leftRear\", (Jaguar) driveTrainSubsystemleftRear);\r\n \r\n driveTrainSubsystemrightFront = new Jaguar(1, 6);\r\n\tLiveWindow.addActuator(\"DriveTrainSubsystem\", \"rightFront\", (Jaguar) driveTrainSubsystemrightFront);\r\n \r\n driveTrainSubsystemrightRear = new Jaguar(1, 7);\r\n\tLiveWindow.addActuator(\"DriveTrainSubsystem\", \"rightRear\", (Jaguar) driveTrainSubsystemrightRear);\r\n \r\n driveTrainSubsystemRobotDrive = new RobotDrive(driveTrainSubsystemleftFront, driveTrainSubsystemleftRear,\r\n driveTrainSubsystemrightFront, driveTrainSubsystemrightRear);\r\n\t\r\n driveTrainSubsystemRobotDrive.setSafetyEnabled(true);\r\n driveTrainSubsystemRobotDrive.setExpiration(0.1);\r\n driveTrainSubsystemRobotDrive.setSensitivity(0.5);\r\n driveTrainSubsystemRobotDrive.setMaxOutput(1.0);\r\n // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS\r\n }", "public MethodBuilder() {\n\t\tvisibility = \"public\";\n\t\treturnType = \"void\";\n\t\tname = \"foo\";\n\t\trule = \"\";\n\t\ttype = \"\";\n\t\tparameters = new ArrayList<String>();\n\t\tcommands = new ArrayList<String>();\n\t}", "public Construct() {\n\tprefixes = new StringBuilder();\n\tvariables = new StringBuilder();\n\twheres = new StringBuilder();\n }", "public static void generateCode()\n {\n \n }", "private ElementDebugger() {\r\n\t\t/* PROTECTED REGION ID(java.constructor._17_0_5_12d203c6_1363681638138_829588_2092) ENABLED START */\r\n\t\t// :)\r\n\t\t/* PROTECTED REGION END */\r\n\t}", "public interface DefccConstants {\n\n /** End of File. */\n int EOF = 0;\n /** RegularExpression Id. */\n int MODULE_TKN = 11;\n /** RegularExpression Id. */\n int CLASS_TKN = 12;\n /** RegularExpression Id. */\n int INCLUDE_TKN = 13;\n /** RegularExpression Id. */\n int BYTE_TKN = 14;\n /** RegularExpression Id. */\n int BOOLEAN_TKN = 15;\n /** RegularExpression Id. */\n int INT_TKN = 16;\n /** RegularExpression Id. */\n int LONG_TKN = 17;\n /** RegularExpression Id. */\n int FLOAT_TKN = 18;\n /** RegularExpression Id. */\n int DOUBLE_TKN = 19;\n /** RegularExpression Id. */\n int STRING_TKN = 20;\n /** RegularExpression Id. */\n int BUFFER_TKN = 21;\n /** RegularExpression Id. */\n int VECTOR_TKN = 22;\n /** RegularExpression Id. */\n int MAP_TKN = 23;\n /** RegularExpression Id. */\n int LBRACE_TKN = 24;\n /** RegularExpression Id. */\n int RBRACE_TKN = 25;\n /** RegularExpression Id. */\n int LT_TKN = 26;\n /** RegularExpression Id. */\n int GT_TKN = 27;\n /** RegularExpression Id. */\n int SEMICOLON_TKN = 28;\n /** RegularExpression Id. */\n int COMMA_TKN = 29;\n /** RegularExpression Id. */\n int DOT_TKN = 30;\n /** RegularExpression Id. */\n int CSTRING_TKN = 31;\n /** RegularExpression Id. */\n int IDENT_TKN = 32;\n /** RegularExpression Id. */\n int IDENT_TKN_W_DOT = 33;\n\n /** Lexical state. */\n int DEFAULT = 0;\n /** Lexical state. */\n int WithinOneLineComment = 1;\n /** Lexical state. */\n int WithinMultiLineComment = 2;\n\n /** Literal token values. */\n String[] tokenImage = {\n \"<EOF>\",\n \"\\\" \\\"\",\n \"\\\"\\\\t\\\"\",\n \"\\\"\\\\n\\\"\",\n \"\\\"\\\\r\\\"\",\n \"\\\"//\\\"\",\n \"<token of kind 6>\",\n \"<token of kind 7>\",\n \"\\\"/*\\\"\",\n \"\\\"*/\\\"\",\n \"<token of kind 10>\",\n \"\\\"module\\\"\",\n \"\\\"class\\\"\",\n \"\\\"include\\\"\",\n \"\\\"byte\\\"\",\n \"\\\"boolean\\\"\",\n \"\\\"int\\\"\",\n \"\\\"long\\\"\",\n \"\\\"float\\\"\",\n \"\\\"double\\\"\",\n \"\\\"string\\\"\",\n \"\\\"buffer\\\"\",\n \"\\\"vector\\\"\",\n \"\\\"map\\\"\",\n \"\\\"{\\\"\",\n \"\\\"}\\\"\",\n \"\\\"<\\\"\",\n \"\\\">\\\"\",\n \"\\\";\\\"\",\n \"\\\",\\\"\",\n \"\\\".\\\"\",\n \"<CSTRING_TKN>\",\n \"<IDENT_TKN>\",\n \"<IDENT_TKN_W_DOT>\",\n };\n\n}", "public interface langBConstants {\n\n /** End of File. */\n int EOF = 0;\n /** RegularExpression Id. */\n int BREAK = 12;\n /** RegularExpression Id. */\n int CLASS = 13;\n /** RegularExpression Id. */\n int CONSTRUCTOR = 14;\n /** RegularExpression Id. */\n int ELSE = 15;\n /** RegularExpression Id. */\n int EXTENDS = 16;\n /** RegularExpression Id. */\n int FOR = 17;\n /** RegularExpression Id. */\n int IF = 18;\n /** RegularExpression Id. */\n int THEN = 19;\n /** RegularExpression Id. */\n int INT = 20;\n /** RegularExpression Id. */\n int NEW = 21;\n /** RegularExpression Id. */\n int PRINT = 22;\n /** RegularExpression Id. */\n int READ = 23;\n /** RegularExpression Id. */\n int RETURN = 24;\n /** RegularExpression Id. */\n int STRING = 25;\n /** RegularExpression Id. */\n int SUPER = 26;\n /** RegularExpression Id. */\n int BOOLEAN = 27;\n /** RegularExpression Id. */\n int TRUE = 28;\n /** RegularExpression Id. */\n int FALSE = 29;\n /** RegularExpression Id. */\n int WHILE = 30;\n /** RegularExpression Id. */\n int SWITCH = 31;\n /** RegularExpression Id. */\n int CASE = 32;\n /** RegularExpression Id. */\n int int_constant = 33;\n /** RegularExpression Id. */\n int string_constant = 34;\n /** RegularExpression Id. */\n int null_constant = 35;\n /** RegularExpression Id. */\n int IDENT = 36;\n /** RegularExpression Id. */\n int LETTER = 37;\n /** RegularExpression Id. */\n int DIGIT = 38;\n /** RegularExpression Id. */\n int UNDERSCORE = 39;\n /** RegularExpression Id. */\n int LPAREN = 40;\n /** RegularExpression Id. */\n int RPAREN = 41;\n /** RegularExpression Id. */\n int LBRACE = 42;\n /** RegularExpression Id. */\n int RBRACE = 43;\n /** RegularExpression Id. */\n int LBRACKET = 44;\n /** RegularExpression Id. */\n int RBRACKET = 45;\n /** RegularExpression Id. */\n int SEMICOLON = 46;\n /** RegularExpression Id. */\n int COMMA = 47;\n /** RegularExpression Id. */\n int DOT = 48;\n /** RegularExpression Id. */\n int DDOT = 49;\n /** RegularExpression Id. */\n int QUESTIONMARK = 50;\n /** RegularExpression Id. */\n int ASSIGN = 51;\n /** RegularExpression Id. */\n int GT = 52;\n /** RegularExpression Id. */\n int LT = 53;\n /** RegularExpression Id. */\n int EQ = 54;\n /** RegularExpression Id. */\n int LE = 55;\n /** RegularExpression Id. */\n int GE = 56;\n /** RegularExpression Id. */\n int NEQ = 57;\n /** RegularExpression Id. */\n int PLUS = 58;\n /** RegularExpression Id. */\n int MINUS = 59;\n /** RegularExpression Id. */\n int STAR = 60;\n /** RegularExpression Id. */\n int SLASH = 61;\n /** RegularExpression Id. */\n int REM = 62;\n /** RegularExpression Id. */\n int OR = 63;\n /** RegularExpression Id. */\n int AND = 64;\n /** RegularExpression Id. */\n int INVALID_LEXICAL = 65;\n /** RegularExpression Id. */\n int INVALID_CONST = 66;\n\n /** Lexical state. */\n int DEFAULT = 0;\n /** Lexical state. */\n int multilinecomment = 1;\n /** Lexical state. */\n int singlelinecomment = 2;\n\n /** Literal token values. */\n String[] tokenImage = {\n \"<EOF>\",\n \"\\\" \\\"\",\n \"\\\"\\\\t\\\"\",\n \"\\\"\\\\n\\\"\",\n \"\\\"\\\\r\\\"\",\n \"\\\"\\\\f\\\"\",\n \"\\\"/*\\\"\",\n \"\\\"//\\\"\",\n \"\\\"*/\\\"\",\n \"<token of kind 9>\",\n \"<token of kind 10>\",\n \"<token of kind 11>\",\n \"\\\"parar\\\"\",\n \"\\\"classe\\\"\",\n \"\\\"construtor\\\"\",\n \"\\\"senao\\\"\",\n \"\\\"herda\\\"\",\n \"\\\"para\\\"\",\n \"\\\"se\\\"\",\n \"\\\"entao\\\"\",\n \"\\\"inteiro\\\"\",\n \"\\\"novo\\\"\",\n \"\\\"imprimir\\\"\",\n \"\\\"ler\\\"\",\n \"\\\"retornar\\\"\",\n \"\\\"texto\\\"\",\n \"\\\"super\\\"\",\n \"\\\"cara_coroa\\\"\",\n \"\\\"cara\\\"\",\n \"\\\"coroa\\\"\",\n \"\\\"enquanto\\\"\",\n \"\\\"trocar\\\"\",\n \"\\\"caso\\\"\",\n \"<int_constant>\",\n \"<string_constant>\",\n \"\\\"nulo\\\"\",\n \"<IDENT>\",\n \"<LETTER>\",\n \"<DIGIT>\",\n \"<UNDERSCORE>\",\n \"\\\"(\\\"\",\n \"\\\")\\\"\",\n \"\\\"{\\\"\",\n \"\\\"}\\\"\",\n \"\\\"[\\\"\",\n \"\\\"]\\\"\",\n \"\\\";\\\"\",\n \"\\\",\\\"\",\n \"\\\".\\\"\",\n \"\\\":\\\"\",\n \"\\\"?\\\"\",\n \"\\\"=\\\"\",\n \"\\\">\\\"\",\n \"\\\"<\\\"\",\n \"\\\"==\\\"\",\n \"\\\"<=\\\"\",\n \"\\\">=\\\"\",\n \"\\\"!=\\\"\",\n \"\\\"+\\\"\",\n \"\\\"-\\\"\",\n \"\\\"*\\\"\",\n \"\\\"/\\\"\",\n \"\\\"%\\\"\",\n \"\\\"|\\\"\",\n \"\\\"&\\\"\",\n \"<INVALID_LEXICAL>\",\n \"<INVALID_CONST>\",\n };\n\n}", "public Subsystem1() {\n // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS\nspeedController1 = new PWMVictorSPX(0);\naddChild(\"Speed Controller 1\",speedController1);\nspeedController1.setInverted(false);\n \nspeedController2 = new PWMVictorSPX(1);\naddChild(\"Speed Controller 2\",speedController2);\nspeedController2.setInverted(false);\n \nspeedController3 = new PWMVictorSPX(2);\naddChild(\"Speed Controller 3\",speedController3);\nspeedController3.setInverted(false);\n \nspeedController4 = new PWMVictorSPX(3);\naddChild(\"Speed Controller 4\",speedController4);\nspeedController4.setInverted(false);\n \nmecanumDrive1 = new MecanumDrive(speedController1, speedController2,\nspeedController3, speedController4);\naddChild(\"Mecanum Drive 1\",mecanumDrive1);\nmecanumDrive1.setSafetyEnabled(true);\nmecanumDrive1.setExpiration(0.1);\nmecanumDrive1.setMaxOutput(1.0);\n\n \n\n // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS\n }", "@Override\n\tpublic void onInit(RobotAPI arg0) {\n\n\t}", "public void preDefine()\n\t{\n\t\tASPManager mgr = getASPManager();\n\n\t\theadblk = mgr.newASPBlock(\"HEAD\");\n\n\t\theadblk.disableDocMan();\n\n\t\theadblk.addField(\"OBJID\").\n setHidden();\n\n headblk.addField(\"OBJVERSION\").\n setHidden();\n \n headblk.addField(\"OBJSTATE\").\n setHidden();\n \n headblk.addField(\"OBJEVENTS\").\n setHidden();\n\n\t\theadblk.addField(\"LU_NAME\").\n\t\tsetMandatory().\n\t\tsetMaxLength(8).\n\t\tsetReadOnly().\n\t\tsetHidden();\n\n\t\theadblk.addField(\"KEY_REF\").\n\t\tsetMandatory().\n\t\tsetMaxLength(600).\n\t\tsetReadOnly().\n\t\tsetHidden();\n\n\t\theadblk.addField(\"VIEW_NAME\").\n\t\tsetHidden().\n\t\tsetFunction(\"''\");\n\n\t\theadblk.addField(\"DOC_COUNT\").\n\t\tsetHidden();\n\n\t\theadblk.addField(\"SLUDESC\").\n\t\tsetSize(20).\n\t\tsetMaxLength(2000).\n\t\tsetReadOnly().\n\t\tsetFunction(\"OBJECT_CONNECTION_SYS.GET_LOGICAL_UNIT_DESCRIPTION(:LU_NAME)\").\n\t\tsetLabel(\"DOCMAWDOCREFERENCESLUDESCRIPTION: Object\");\n\n\t\theadblk.addField(\"SINSTANCEDESC\").\n\t\tsetSize(20).\n\t\tsetMaxLength(2000).\n\t\tsetReadOnly().\n\t\tsetFunction(\"OBJECT_CONNECTION_SYS.GET_INSTANCE_DESCRIPTION(:LU_NAME,'',:KEY_REF)\").\n\t\tsetLabel(\"DOCMAWDOCREFERENCESINSTANCEDESC: Object Key\");\n\n\t\theadblk.addField(\"DOC_OBJECT_DESC\").\n\t\tsetReadOnly().\n\t\tsetMaxLength(200).\n\t\tsetLabel(\"DOCMAWDOCREFERENCEDOCOBJECTDESC: Object Desc\");\n\n\t\theadblk.addField(\"STATE\").\n setReadOnly().\n setSize(10).\n setLabel(\"DOCMAWDOCREFERENCESTATE: State\");\n\t\t\n\t\theadblk.addField(\"INFO\").\n\t\tsetHidden().\n\t\tsetFunction(\"''\");\n\n\t\theadblk.addField(\"ATTRHEAD\").\n\t\tsetHidden().\n\t\tsetFunction(\"''\");\n\n\t\theadblk.addField(\"ACTION\").\n\t\tsetHidden().\n\t\tsetFunction(\"''\");\n\n\t\theadblk.setView(\"DOC_REFERENCE\");\n\t\theadblk.defineCommand(\"DOC_REFERENCE_API\",\"New__,Modify__,Remove__,Set_Lock__,Set_Unlock__\");\n\n\t\theadset = headblk.getASPRowSet();\n\n\t\theadbar = mgr.newASPCommandBar(headblk);\n\t\theadbar.disableCommand(headbar.FIND);\n\t\theadbar.disableCommand(headbar.DUPLICATEROW);\n\t\theadbar.disableCommand(headbar.NEWROW);\n\t\theadbar.disableCommand(headbar.EDITROW);\n\t\theadbar.disableCommand(headbar.DELETE);\n\t\theadbar.disableCommand(headbar.BACK);\n\n headbar.addSecureCustomCommand(\"SetLock\", \"DOCMAWDOCREFERENCESETLOCK: Lock\", \"DOC_REFERENCE_API.Set_Lock__\");\n headbar.addSecureCustomCommand(\"SetUnlock\", \"DOCMAWDOCREFERENCESETUNLOCK: Unlock\", \"DOC_REFERENCE_API.Set_Unlock__\");\n\n headbar.addCommandValidConditions(\"SetLock\", \"OBJSTATE\", \"Enable\", \"Unlocked\");\n headbar.addCommandValidConditions(\"SetUnlock\", \"OBJSTATE\", \"Enable\", \"Locked\");\n \n\t\theadtbl = mgr.newASPTable(headblk);\n\t\theadtbl.setTitle(mgr.translate(\"DOCMAWDOCREFERENCECONDOCU: Connected Documents\"));\n\n\n\t\theadlay = headblk.getASPBlockLayout();\n\t\theadlay.setDialogColumns(2);\n\t\theadlay.setDefaultLayoutMode(headlay.SINGLE_LAYOUT);\n\n\n\t\t//\n\t\t// Connected documents\n\t\t//\n\n\t\titemblk = mgr.newASPBlock(\"ITEM\");\n\n\t\titemblk.disableDocMan();\n\n\t\titemblk.addField(\"ITEM_OBJID\").\n\t\tsetHidden().\n\t\tsetDbName(\"OBJID\");\n\n\t\titemblk.addField(\"ITEM_OBJVERSION\").\n\t\tsetHidden().\n\t\tsetDbName(\"OBJVERSION\");\n\n\t\titemblk.addField(\"ITEM_LU_NAME\").\n\t\tsetMandatory().\n\t\tsetHidden().\n\t\tsetDbName(\"LU_NAME\");\n\n\t\titemblk.addField(\"ITEM_KEY_REF\").\n\t\tsetMandatory().\n\t\tsetHidden().\n\t\tsetDbName(\"KEY_REF\");\n\t\t\n\t\titemblk.addField(\"VIEW_FILE\").\n setFunction(\"''\").\n setReadOnly().\n unsetQueryable().\n setLabel(\"DOCMAWDOCREFERENCEVIEWFILE: View File\").\n setHyperlink(\"../docmaw/EdmMacro.page?PROCESS_DB=VIEW&DOC_TYPE=ORIGINAL\", \"DOC_CLASS,DOC_NO,DOC_SHEET,DOC_REV\", \"NEWWIN\").\n setAsImageField();\n\t\t\n\t\titemblk.addField(\"CHECK_IN_FILE\").\n setFunction(\"''\").\n setReadOnly().\n unsetQueryable().\n setLabel(\"DOCMAWDOCREFERENCECHECKINFILE: Check In File\").\n setHyperlink(\"../docmaw/EdmMacro.page?PROCESS_DB=CHECKIN&DOC_TYPE=ORIGINAL\", \"DOC_CLASS,DOC_NO,DOC_SHEET,DOC_REV\", \"NEWWIN\").\n setAsImageField();\n\n\t\titemblk.addField(\"DOC_CLASS\").\n\t\tsetSize(10).\n\t\tsetMaxLength(12).\n\t\tsetMandatory().\n\t\tsetUpperCase().\n\t\tsetReadOnly().\n\t\tsetDynamicLOV(\"DOC_CLASS\").\n\t\tsetLOVProperty(\"TITLE\",mgr.translate(\"DOCMAWDOCREFERENCEDOCCLASS1: List of Document Class\")).\n\t\tsetCustomValidation(\"DOC_CLASS\",\"SDOCCLASSNAME,KEEP_LAST_DOC_REV,KEEP_LAST_DOC_REV_DB\").//Bug Id 85361\n\t\tsetLabel(\"DOCMAWDOCREFERENCEDOCCLASS: Doc Class\");\n\n\t\titemblk.addField(\"SDOCCLASSNAME\").\n\t\tsetDbName(\"DOC_NAME\").\n\t\tsetSize(10).\n\t\tsetReadOnly().\n\t\tsetLabel(\"DOCMAWDOCREFERENCESDOCCLASSNAME: Doc Class Desc\");\n\t\t\n\t\titemblk.addField(\"SUB_CLASS\").\n setSize(10).\n setReadOnly().\n setHidden().\n setDynamicLOV(\"DOC_SUB_CLASS\",\"DOC_CLASS\").\n setLabel(\"DOCMAWDOCREFERENCESSUBCLASS: Sub Class\");\n\t\t\n\t\titemblk.addField(\"SUB_CLASS_NAME\").\n setSize(10).\n setReadOnly().\n setLabel(\"DOCMAWDOCREFERENCESSUBCLASSNAME: Sub Class Name\");\n\n\t\titemblk.addField(\"DOC_CODE\").\n setSize(20).\n setReadOnly().\n setLabel(\"DOCMAWDOCREFERENCESDOCCODE: Doc Code\");\n\t\t\n\t\titemblk.addField(\"INNER_DOC_CODE\").\n setSize(20).\n setReadOnly().\n setLabel(\"DOCMAWDOCREFERENCESINNERDOCCODE: Inner Doc Code\");\n\t\t\n\t\titemblk.addField(\"SDOCTITLE\").\n\t\tsetDbName(\"DOC_TITLE\").\n\t\tsetSize(40).\n\t\tsetReadOnly().\n\t\tsetFieldHyperlink(\"DocIssue.page\", \"PAGE_URL\", \"DOC_CLASS,DOC_NO,DOC_SHEET,DOC_REV\").\n\t\tsetLabel(\"DOCMAWDOCREFERENCESDOCTITLE: Title\");\n\n\t\titemblk.addField(\"DOC_REV\").\n\t\tsetSize(20).\n\t\tsetMandatory().\n\t\tsetUpperCase().\n\t\tsetReadOnly().\n\t\tsetDynamicLOV(\"DOC_ISSUE\",\"DOC_CLASS,DOC_NO,DOC_SHEET\").\n\t\tsetLOVProperty(\"TITLE\",mgr.translate(\"DOCMAWDOCREFERENCEDOCREV1: List of Document Revision\")).\n\t\tsetLabel(\"DOCMAWDOCREFERENCEDOCREV: Doc Rev\");\n\t\t\n\t\titemblk.addField(\"DOC_STATE\").\n setSize(10).\n setReadOnly().\n setLabel(\"DOCMAWDOCREFERENCESDOCSTATE: Doc State\");\n\t\t\n\t\titemblk.addField(\"CONNECTED_PERSON\").\n setSize(10).\n setReadOnly().\n setDynamicLOV(\"PERSON_INFO_LOV\").\n setLabel(\"DOCMAWDOCREFERENCECONNECTEDPERSON: Connected Person\");\n\t\t\n\t\titemblk.addField(\"CONNECTED_PERSON_NAME\").\n setSize(10).\n setReadOnly().\n setFunction(\"Person_Info_API.Get_Name(:CONNECTED_PERSON)\").\n setLabel(\"DOCMAWDOCREFERENCECONNECTEDPERSONNAME: Connected Person Name\");\n\t\tmgr.getASPField(\"CONNECTED_PERSON\").setValidation(\"CONNECTED_PERSON_NAME\");\n\t\t\n\t\titemblk.addField(\"CONNECTED_DATE\", \"Date\").\n setSize(10).\n setReadOnly().\n setLabel(\"DOCMAWDOCREFERENCECONNECTEDDATE: Connected Date\");\n\t\t\n\t\titemblk.addField(\"SEND_UNIT_NAME\").\n setSize(20).\n setReadOnly().\n setLabel(\"DOCMAWDOCREFERENCESSENDUNITNAME: Send Unit Name\");\n\t\t\n\t\titemblk.addField(\"SIGN_PERSON\").\n setSize(10).\n setReadOnly().\n setLabel(\"DOCMAWDOCREFERENCESSIGNPERSON: Sign Person\");\n\t\t\n\t\titemblk.addField(\"COMPLETE_DATE\", \"Date\").\n setSize(10).\n setReadOnly().\n setLabel(\"DOCMAWDOCREFERENCESCOMPLETEDATE: Complete Date\");\n\n\t\titemblk.addField(\"DOCTSATUS\").\n\t\tsetSize(20).\n\t\tsetReadOnly().\n\t\tsetFunction(\"substr(DOC_ISSUE_API.Get_State(DOC_CLASS,DOC_NO,DOC_SHEET,DOC_REV),1,200)\").\n\t\tsetLabel(\"DOCMAWDOCREFERENCEDOCTSATUS: Status\");\n\n\t\t//\n\t\t// Hidden Fields\n\t\t//\n\t\t\n\t\titemblk.addField(\"DOC_NO\").\n setSize(20).\n setMaxLength(120).\n setMandatory().\n setUpperCase().\n setHidden().\n setLOV(\"DocNumLov.page\",\"DOC_CLASS\").\n setCustomValidation(\"DOC_CLASS,DOC_NO,DOC_SHEET,DOC_REV\",\"SDOCTITLE,DOC_CLASS,DOC_NO,DOC_SHEET,DOC_REV,SDOCCLASSNAME,KEEP_LAST_DOC_REV,KEEP_LAST_DOC_REV_DB\").//Bug Id 85361\n setLOVProperty(\"TITLE\",mgr.translate(\"DOCMAWDOCREFERENCEDOCNO1: List of Document No\")).\n setLabel(\"DOCMAWDOCREFERENCEDOCNO: Doc No\");\n\t\t\n\t\titemblk.addField(\"DOC_SHEET\").\n setSize(20).\n //Bug 61028, Start\n setMaxLength(10).\n //Bug 61028, End\n setMandatory().\n setUpperCase().\n setHidden().\n setDynamicLOV(\"DOC_ISSUE_LOV1\",\"DOC_CLASS,DOC_NO,DOC_REV\").\n setLOVProperty(\"TITLE\", mgr.translate(\"DOCMAWDOCREFERENCEDOCSHEET1: List of Doc Sheets\")).\n setLabel(\"DOCMAWDOCREFERENCEDOCSHEET: Doc Sheet\");\n\t\t\n\t\titemblk.addField(\"CATEGORY\").\n setSize(20).\n setMaxLength(5).\n setUpperCase().\n setHidden().\n setDynamicLOV(\"DOC_REFERENCE_CATEGORY\").\n setLOVProperty(\"TITLE\",mgr.translate(\"DOCMAWDOCREFERENCEDOCAT: List of Document Category\")).\n setLabel(\"DOCMAWDOCREFERENCECATEGORY: Association Category\");\n\n itemblk.addField(\"COPY_FLAG\").\n setSize(20).\n setMandatory().\n setSelectBox().\n setHidden().\n enumerateValues(\"Doc_Reference_Copy_Status_API\").\n setLabel(\"DOCMAWDOCREFERENCECOPYFLAG: Copy Status\");\n\n itemblk.addField(\"KEEP_LAST_DOC_REV\").\n setSize(20).\n setMaxLength(100).\n setMandatory().\n setSelectBox().\n setHidden().\n unsetSearchOnDbColumn().\n enumerateValues(\"Always_Last_Doc_Rev_API\").\n setCustomValidation(\"KEEP_LAST_DOC_REV,DOC_CLASS,DOC_NO,DOC_SHEET,DOC_REV\",\"DOC_REV,KEEP_LAST_DOC_REV_DB\").//Bug Id 85361\n setLabel(\"DOCMAWDOCREFERENCEKEEPLASTDOCREV: Update Revision\");\n\n //Bug Id 85361. Start\n itemblk.addField(\"KEEP_LAST_DOC_REV_DB\").\n setHidden().\n unsetSearchOnDbColumn().\n setFunction(\"Always_Last_Doc_Rev_API.Encode(:KEEP_LAST_DOC_REV)\");\n //Bug Id 85361. End\n\n itemblk.addField(\"SURVEY_LOCKED_FLAG\").\n setSize(20).\n setMandatory().\n setSelectBox().\n setHidden().\n enumerateValues(\"LOCK_DOCUMENT_SURVEY_API\").\n unsetSearchOnDbColumn().\n //Bug 57719, Start\n setCustomValidation(\"SURVEY_LOCKED_FLAG\",\"SURVEY_LOCKED_FLAG_DB\").\n //Bug 57719, End\n setLabel(\"DOCMAWDOCREFERENCESURVEYLOCKEDFLAG: Doc Connection Status\");\n\t\t\n\t\titemblk.addField(\"SURVEY_LOCKED_FLAG_DB\").\n setHidden().\n unsetSearchOnDbColumn().\n setFunction(\"Lock_Document_Survey_Api.Encode(:SURVEY_LOCKED_FLAG)\");\n\t\t\n\t\titemblk.addField(\"FILE_TYPE\").\n\t\tsetHidden().\n\t\tsetFunction(\"EDM_FILE_API.GET_FILE_TYPE(DOC_CLASS,DOC_NO,DOC_SHEET,DOC_REV,'ORIGINAL')\");\n\n\t\t//Bug Id 67336, start\n\t\titemblk.addField(\"STRUCTURE\").\n\t\tsetHidden().\n\t\tsetFunction(\"DOC_TITLE_API.Get_Structure_(DOC_CLASS,DOC_NO)\");\n\t\t//Bug Id 67336, end\n\n\t\t// Bug Id 89939, start\n\t\titemblk.addField(\"CAN_ADD_TO_BC\").\n\t\tsetHidden().\n\t\tsetFunction(\"DOC_ISSUE_API.can_add_to_bc(DOC_CLASS, DOC_NO, DOC_SHEET, DOC_REV)\");\n\t\t\n\t\titemblk.addField(\"BRIEFCASE_NO\"). \n\t\tsetHidden().\n\t\tsetDynamicLOV(\"DOC_BC_LOV1\").\n\t\tsetFunction(\"DOC_BRIEFCASE_ISSUE_API.GET_BRIEFCASE_NO(DOC_CLASS,DOC_NO,DOC_SHEET,DOC_REV)\");\n\t\t\n\t\titemblk.addField(\"EDMSTATUS\").\n\t\tsetHidden().\n\t\tsetFunction(\"EDM_FILE_API.GET_DOC_STATE_NO_USER(DOC_CLASS, DOC_NO, DOC_SHEET, DOC_REV, 'ORIGINAL')\");\n\t\t\n\t\titemblk.addField(\"IS_ELE_DOC\").\n setCheckBox(\"FALSE,TRUE\").\n setFunction(\"EDM_FILE_API.Have_Edm_File(:DOC_CLASS,:DOC_NO,:DOC_SHEET,:DOC_REV)\").\n setReadOnly().\n setHidden().\n setLabel(\"DOCMAWDOCREFERENCEISELEDOC: Is Ele Doc\").\n setSize(5);\n\t\t\n\t\titemblk.addField(\"PAGE_URL\").\n setFunction(\"Doc_Issue_API.Get_Page_Url(:DOC_CLASS,:DOC_NO,:DOC_SHEET,:DOC_REV)\").\n setReadOnly().\n setHidden();\n\t\t\n\t\titemblk.addField(\"TEMP_EDIT_ACCESS\").\n\t\tsetFunction(\"NVL(Doc_Class_API.Get_Temp_Doc(:DOC_CLASS), 'FALSE') || NVL(Doc_Issue_API.Get_Edit_Access_For_Rep_(:DOC_CLASS,:DOC_NO,:DOC_SHEET,:DOC_REV), 'FALSE')\").\n\t\tsetHidden();\n\t\t\n\t\titemblk.addField(\"COMP_DOC\").\n setFunction(\"NVL(Doc_Class_API.Get_Comp_Doc(:DOC_CLASS), 'FALSE')\").\n setHidden();\n\t\t\n\t\titemblk.addField(\"TEMP_DOC\").\n setFunction(\"NVL(Doc_Class_API.Get_Temp_Doc(:DOC_CLASS), 'FALSE')\").\n setHidden();\n\t\t\n\t\titemblk.addField(\"DOC_OBJSTATE\").\n setFunction(\"DOC_ISSUE_API.Get_Objstate__(:DOC_CLASS,:DOC_NO,:DOC_SHEET,:DOC_REV)\").\n setHidden().\n setLabel(\"DOCMAWDOCISSUESTATE: Doc Status\");\n\t\t\n\t\titemblk.addField(\"CHECK_CONNECTED_PERSON\").\n\t\tsetFunction(\"DECODE(connected_person, Person_Info_API.Get_Id_For_User(Fnd_Session_API.Get_Fnd_User), 'TRUE', 'FALSE')\").\n\t\tsetReadOnly().\n\t\tsetLabel(\"DOCMAWDOCREFERENCECHECKCONNECTEDPERSON: Check Connected Person\").\n setHidden();\n\t\t\n\t\titemblk.addField(\"TRANSFERED\").\n\t\tsetCheckBox(\"FALSE,TRUE\").\n\t\tsetReadOnly().\n setHidden();\n\t\t// Bug Id 89939, end\n\n\t\titemblk.setView(\"DOC_REFERENCE_OBJECT\");\n\t\titemblk.defineCommand(\"DOC_REFERENCE_OBJECT_API\",\"New__,Modify__,Remove__\");\n\t\titemblk.setMasterBlock(headblk);\n\t\titemset = itemblk.getASPRowSet();\n\t\titembar = mgr.newASPCommandBar(itemblk);\n\t\titembar.enableCommand(itembar.FIND);\n\t\titembar.disableCommand(itembar.NEWROW);\n\t\titembar.disableCommand(itembar.DUPLICATEROW);\n\t\titembar.disableCommand(itembar.OVERVIEWEDIT);\n\t\titembar.disableCommand(itembar.DELETE);\n\t\titembar.disableCommand(itembar.EDITROW);\n\t\t\n\t\t//Bug 57719, Start, Added check on function checkLocked()\n\t\titembar.defineCommand(itembar.SAVERETURN,\"saveReturnITEM\",\"checkLocked()\");\n\t\t//Bug 57719, End\n\t\titembar.defineCommand(itembar.OKFIND, \"okFindITEMWithErrorMsg\");\n\t\titembar.defineCommand(itembar.COUNTFIND,\"countFindITEM\");\n\t\titembar.defineCommand(itembar.NEWROW, \"newRowITEM\");\n\t\titembar.defineCommand(itembar.SAVENEW, \"saveNewITEM\");\n\t\titembar.defineCommand(itembar.DELETE, \"deleteITEM\");\n\t\t\n\t\t//Bug Id 85487, Start\n\t\titembar.addCustomCommand(\"createNewDoc\", mgr.translate(\"DOCMAWDOCREFERENCECREATEDOC: Create New Document\"));\n\t\titembar.addSecureCustomCommand(\"createConnectDefDoc\", mgr.translate(\"DOCMAWDOCREFERENCECREATECONNDEFDOC: Create And Connect Document...\"), \"DOC_REFERENCE_OBJECT_API.New__\", \"../common/images/toolbar/\" + mgr.getLanguageCode() + \"/createConnectDefDoc.gif\", true);\n\t\t// itembar.setCmdConfirmMsg(\"createConnectDefDoc\", \"DOCMAWDOCREFERENCECREATECONNDEFDOCMSG: Confirm create and connect document?\");\n\t\titembar.addSecureCustomCommand(\"insertExistingDoc\",mgr.translate(\"DOCMAWDOCREFERENCEINEXISTDOC: Insert Existing Document...\"), \"DOC_REFERENCE_OBJECT_API.New__\", \"../common/images/toolbar/\" + mgr.getLanguageCode() + \"/addDocument.gif\", true);\n\t\titembar.addCustomCommandSeparator();\n\t\titembar.forceEnableMultiActionCommand(\"createNewDoc\");\n\t\titembar.forceEnableMultiActionCommand(\"createConnectDefDoc\");\n\t\titembar.forceEnableMultiActionCommand(\"insertExistingDoc\");\n\t\titembar.removeFromRowActions(\"insertExistingDoc\");\n\t\titembar.removeFromRowActions(\"createNewDoc\");\n\t\titembar.removeFromRowActions(\"createConnectDefDoc\");\n\t\t//Bug Id 85487, End\n\n\t\t//Bug Id 89939, start\n\t\t// itembar.addSecureCustomCommand(\"startAddingToBriefcase\",\"DOCMAWDOCREFERENCEADDTOBC: Add to Briefcase...\",\"DOC_BRIEFCASE_ISSUE_API.Add_To_Briefcase\"); \n\t\t// itembar.addCustomCommand(\"goToBriefcase\",\"DOCMAWDOCREFERENCEGOTOBC: Go to Briefcase\"); \n\t\t// itembar.addCommandValidConditions(\"goToBriefcase\",\"BRIEFCASE_NO\",\"Disable\",null);\n\t\t//Bug Id 89939, end\n\n\t\t// File Operations\n\t\t// itembar.addSecureCustomCommand(\"editDocument\",mgr.translate(\"DOCMAWDOCREFERENCEEDITDOC: Edit Document\"),\"DOCUMENT_ISSUE_ACCESS_API.Get_Document_Access\"); //Bug Id 70286\n\t\titembar.addSecureCustomCommand(\"deleteDoc\",mgr.translate(\"DOCMAWDOCREFERENCEDELETEDOC: Delete\"),\"DOC_REFERENCE_OBJECT_API.Remove__\"); //Bug Id 70286\n\t\titembar.setCmdConfirmMsg(\"deleteDoc\", \"DOCMAWDOCREFERENCEDELETEDOCCONFIRM: Confirm delete document(s)?\");\n\t\titembar.addCustomCommandSeparator();\n\t\titembar.addSecureCustomCommand(\"viewOriginal\",mgr.translate(\"DOCMAWDOCREFERENCEVIEVOR: View Document\"),\"DOCUMENT_ISSUE_ACCESS_API.Get_Document_Access\"); //Bug Id 70286\n\t\titembar.addSecureCustomCommand(\"checkInDocument\",mgr.translate(\"DOCMAWDOCREFERENCECHECKINDOC: Check In Document\"),\"DOCUMENT_ISSUE_ACCESS_API.Get_Document_Access\"); //Bug Id 70286\n\t\t// itembar.addSecureCustomCommand(\"undoCheckOut\",mgr.translate(\"DOCMAWDOCREFERENCEUNDOCHECKOUT: Undo Check Out Document\"),\"DOCUMENT_ISSUE_ACCESS_API.Get_Document_Access\"); //Bug Id 70286\n\t\t// itembar.addSecureCustomCommand(\"viewOriginalWithExternalViewer\",mgr.translate(\"DOCMAWDOCREFERENCEVIEWOREXTVIEWER: View Document with Ext. App\"),\"DOCUMENT_ISSUE_ACCESS_API.Get_Document_Access\"); //Bug Id 70286\n\t\t// itembar.addSecureCustomCommand(\"viewCopy\",mgr.translate(\"DOCMAWDOCREFERENCEVIEWCO: View Copy\"),\"DOCUMENT_ISSUE_ACCESS_API.Get_Document_Access\"); //Bug Id 70286\n\t\t// itembar.addSecureCustomCommand(\"printDocument\",mgr.translate(\"DOCMAWDOCREFERENCEPRINTDOC: Print Document\"),\"DOCUMENT_ISSUE_ACCESS_API.Get_Document_Access\"); //Bug Id 70286\n\t\t// itembar.addSecureCustomCommand(\"copyFileTo\",mgr.translate(\"DOCMAWDOCISSUECOPYFILETO: Copy File To...\"),\"DOCUMENT_ISSUE_ACCESS_API.Get_Document_Access\"); //Bug Id 70286\n\t\t// itembar.addSecureCustomCommand(\"sendToMailRecipient\",mgr.translate(\"DOCMAWDOCREFERENCEWSENDMAIL: Send by E-mail...\"),\"DOCUMENT_ISSUE_ACCESS_API.Get_Document_Access\"); //Bug Id 70286\n\t\titembar.addCustomCommand(\"documentInfo\",mgr.translate(\"DOCMAWDOCREFERENCEDOCINFO: Document Info...\"));\n\n\t\titembar.addCommandValidConditions(\"checkInDocument\", \"TEMP_EDIT_ACCESS\", \"Enable\", \"TRUETRUE\");\n\t\titembar.addCommandValidConditions(\"checkInDocument\", \"CHECK_CONNECTED_PERSON\", \"Disable\", \"FALSE\");\n\t\titembar.addCommandValidConditions(\"checkInDocument\", \"TRANSFERED\", \"Disable\", \"TRUE\");\n\t\titembar.addCommandValidConditions(\"checkInDocument\", \"SURVEY_LOCKED_FLAG_DB\", \"Disable\", \"1\");\n\t\t\n\t\titembar.addCommandValidConditions(\"deleteDoc\", \"TEMP_EDIT_ACCESS\", \"Disable\", \"TRUEFALSE\");\n\t\titembar.addCommandValidConditions(\"deleteDoc\", \"CHECK_CONNECTED_PERSON\", \"Disable\", \"FALSE\");\n\t\titembar.addCommandValidConditions(\"deleteDoc\", \"TRANSFERED\", \"Disable\", \"TRUE\");\n\t\titembar.addCommandValidConditions(\"deleteDoc\", \"SURVEY_LOCKED_FLAG_DB\", \"Disable\", \"1\");\n\t\t\n\t\t// Add operations to comand groups\n\t\t// itembar.addCustomCommandGroup(\"FILE\", mgr.translate(\"DOCMAWDOCREFERENCEFILECMDGROUP: File Operations\"));\n\t\t// itembar.setCustomCommandGroup(\"editDocument\", \"FILE\");\n\t\t// itembar.setCustomCommandGroup(\"checkInDocument\", \"FILE\");\n\t\t// itembar.setCustomCommandGroup(\"undoCheckOut\", \"FILE\");\n\t\t// itembar.setCustomCommandGroup(\"viewOriginal\", \"FILE\");\n\t\t// itembar.setCustomCommandGroup(\"viewOriginalWithExternalViewer\", \"FILE\");\n\t\t// itembar.setCustomCommandGroup(\"viewCopy\", \"FILE\");\n\t\t// itembar.setCustomCommandGroup(\"printDocument\", \"FILE\");\n\t\t// itembar.setCustomCommandGroup(\"copyFileTo\", \"FILE\");\n\n\n\t\titembar.enableMultirowAction();\n\t\t// itembar.removeFromMultirowAction(\"viewOriginalWithExternalViewer\");\n\t\t// itembar.removeFromMultirowAction(\"undoCheckOut\");\n\n\n\t\titemtbl = mgr.newASPTable(itemblk);\n\t\titemtbl.setTitle(mgr.translate(\"DOCMAWDOCREFERENCEDOCUCC: Documents\"));\n\t\titemtbl.enableRowSelect();\n\n\t\titemlay = itemblk.getASPBlockLayout();\n\t\titemlay.setDialogColumns(2);\n\t\titemlay.setDefaultLayoutMode(itemlay.MULTIROW_LAYOUT);\n\n\t\titemlay.setSimple(\"CONNECTED_PERSON_NAME\");\n\t\t\n\t\t//\n\t\t// Create and connect documents\n\t\t//\n\n\t\tdlgblk = mgr.newASPBlock(\"DLG\");\n\n\t\tdlgblk.addField(\"DLG_DOC_CLASS\").\n\t\tsetSize(20).\n\t\tsetDynamicLOV(\"DOC_CLASS\").\n\t\tsetMandatory().\n\t\tsetUpperCase().\n\t\tsetCustomValidation(\"DLG_DOC_CLASS\",\"DLG_DOC_REV,FIRST_SHEET_NO,NUMBER_GENERATOR,NUM_GEN_TRANSLATED,ID1,ID2\").\n\t\tsetLabel(\"DOCMAWDOCREFERENCEDLGDOCCLASS: Doc Class\");\n\n\t\tdlgblk.addField(\"DLG_DOC_NO\").\n\t\tsetSize(20).\n\t\tsetMandatory().\n\t\tsetUpperCase().\n\t\tsetLabel(\"DOCMAWDOCREFERENCEDLGDOCNO: No\");\n\n\t\tdlgblk.addField(\"FIRST_SHEET_NO\").\n\t\tsetSize(20).\n\t\tsetMandatory().\n\t\tsetUpperCase().\n\t\tsetLabel(\"DOCMAWDOCREFERENCEFIRSTSHEETNO: First Sheet No\");\n\n\t\tdlgblk.addField(\"DLG_DOC_REV\").\n\t\tsetSize(20).\n\t\tsetMandatory().\n\t\tsetUpperCase().\n\t\tsetLabel(\"DOCMAWDOCREFERENCEDLGDOCTITLE: Revision\");\n\n\t\tdlgblk.addField(\"DLG_DOC_TITLE\").\n\t\tsetSize(20).\n\t\tsetMandatory().\n\t\tsetLabel(\"DOCMAWDOCREFERENCEDLGDOCREV: Title\");\n\n\t\t// Configurable doc no\n\n\t\tdlgblk.addField(\"NUMBER_GENERATOR\").\n\t\tsetHidden().\n\t\tsetFunction(\"''\");\n\n\t\tdlgblk.addField(\"NUM_GEN_TRANSLATED\").\n\t\tsetReadOnly().\n\t\tsetUpperCase().\n\t\tsetFunction(\"''\").\n\t\tsetLabel(\"DOCREFERENCENUMBERGENERATOR: Number Generator\");\n\n\n\t\tdlgblk.addField(\"ID1\").\n\t\tsetReadOnly().\n\t\tsetFunction(\"''\").\n\t\tsetUpperCase().\n\t\tsetLOV(\"Id1Lov.page\").\n\t\tsetLabel(\"DOCREFERENCENUMBERCOUNTERID1: Number Counter ID1\");\n\n\t\tdlgblk.addField(\"ID2\").\n\t\tsetSize(20).\n\t\tsetUpperCase().\n\t\tsetMaxLength(30).\n\t\tsetFunction(\"''\").\n\t\tsetLOV(\"Id2Lov.page\",\"ID1\").\n\t\tsetLabel(\"DOCREFERENCENUMBERCOUNTERID2: Number Counter ID2\");\n\n\t\tdlgblk.addField(\"BOOKING_LIST\").\n\t\tsetSize(20).\n\t\tsetMaxLength(30).\n\t\tsetUpperCase().\n\t\tsetFunction(\"''\").\n\t\tsetLOV(\"BookListLov.page\", \"ID1,ID2\").//Bug Id 73606\n\t\tsetLabel(\"DOCREFERENCEBOOKINGLIST: Booking List\");\n\n\t\tdlgblk.setTitle(mgr.translate(\"DOCMAWDOCREFERENCECREANDCONNDOC: Create and Connect New Document\"));\n\n\t\tdlgset = dlgblk.getASPRowSet();\n\t\tdlgbar = mgr.newASPCommandBar(dlgblk);\n\t\tdlgbar.enableCommand(dlgbar.OKFIND);\n\t\tdlgbar.defineCommand(dlgbar.OKFIND,\"dlgOk\");\n\t\tdlgbar.enableCommand(dlgbar.CANCELFIND);\n\t\tdlgbar.defineCommand(dlgbar.CANCELFIND,\"dlgCancel\");\n\n\t\tdlglay = dlgblk.getASPBlockLayout();\n\t\tdlglay.setDialogColumns(2);\n\t\tdlglay.setDefaultLayoutMode(dlglay.CUSTOM_LAYOUT);\n\t\tdlglay.setEditable();\n\n\n\t\t//\n\t\t// dummy block\n\t\t//\n\n\t\tdummyblk = mgr.newASPBlock(\"DUMMY\");\n\n\t\tdummyblk.addField(\"DOC_TYPE\");\n\t\tdummyblk.addField(\"RETURN\");\n\t\tdummyblk.addField(\"ATTR\");\n\t\tdummyblk.addField(\"TEMP1\");\n\t\tdummyblk.addField(\"TEMP2\");\n\t\tdummyblk.addField(\"TEMP3\");\n\t\tdummyblk.addField(\"DUMMY\");\n\t\tdummyblk.addField(\"DUMMY_TYPE\");\n\t\tdummyblk.addField(\"DUMMY1\");\n\t\tdummyblk.addField(\"DUMMY2\");\n\t\tdummyblk.addField(\"DUMMY3\");\n\t\tdummyblk.addField(\"DUMMY4\");\n\t\tdummyblk.addField(\"DUMMY5\");\n\t\tdummyblk.addField(\"DUMMY6\");\n\t\tdummyblk.addField(\"LOGUSER\");\n\t\tdummyblk.addField(\"OUT_1\");\n\t}", "private SourcecodePackage() {}", "protected MetadataUGWD() {/* intentionally empty block */}", "protected GeneTAG() {/* intentionally empty block */}", "private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize\n // write pre-initialize user code here\n//GEN-LINE:|0-initialize|1|0-postInitialize\n // write post-initialize user code here\n }", "private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize\n // write pre-initialize user code here\n//GEN-LINE:|0-initialize|1|0-postInitialize\n // write post-initialize user code here\n }", "public interface Constants {\n\n final public static String TAG = \"[PracticalTest02Var04]\";\n\n final public static boolean DEBUG = true;\n\n final public static String EMPTY_STRING = \"\";\n\n final public static String QUERY_ATTRIBUTE = \"query\";\n\n final public static String SCRIPT_TAG = \"script\";\n final public static String SEARCH_KEY = \"wui.api_data =\\n\";\n\n final public static String CURRENT_OBSERVATION = \"current_observation\";\n\n}", "public Command getStartC () {\nif (startC == null) {//GEN-END:|42-getter|0|42-preInit\n // write pre-init user code here\nstartC = new Command (\"Start\", Command.OK, 0);//GEN-LINE:|42-getter|1|42-postInit\n // write post-init user code here\n}//GEN-BEGIN:|42-getter|2|\nreturn startC;\n}", "public TradeVariables() { /*gets default values*/ }", "public interface TAG_JAVA_CODEBASE\n{\n\n /**\n * Class downloading is supported for stubs, ties, values, and \n * value helpers. The specification allows transmission of codebase \n * information on the wire for stubs and ties, and enables usage of \n * pre-existing ClassLoaders when relevant. \n * <p>\n * For values and value helpers, the codebase is transmitted after the \n * value tag. For stubs and ties, the codebase is transmitted as \n * the TaggedComponent <code>TAG_JAVA_CODEBASE</code> in the IOR \n * profile, where the <code>component_data</code> is a CDR encapsulation \n * of the codebase written as an IDL string. The codebase is a \n * space-separated list of one or more URLs.\n */\n public static final int value = (int)(25L);\n}", "public BopeAutoGG() {\n\t\tsuper(BopeCategory.BOPE_CHAT);\n\n\t\t// Info.\n\t\tthis.name = \"Auto GG\";\n\t\tthis.tag = \"AutoGG\";\n\t\tthis.description = \"Automaticaly say good game paceaful or no!\";\n\n\t\t// Release.\n\t\trelease(\"B.O.P.E - Module - B.O.P.E\");\n\t}", "void tag4() \n\t{\n\t\t/** javadoc_single_style_tag: This is a JavaDoc single style tag.\n\t}\n\t\n\t/** Test a JavaDoc multi style comment in souce code.\n\t * \n\t */\n\tvoid tag5() \n\t{\n\t\t/** \n\t\t * javadoc_multi_style_tag: This is a JavaDoc multi style tag.\n\t\t */\n\t}\n\t\n\t/** Test a tag not at the start of a line.\n\t * \n\t */\n\tvoid tag6() \n\t{\n\t\t/** \n\t\t * The tag \"not_start_of_line_tag\" should NOT be found.\n\t\t */\n\t}\n\t\n\t/** Test a tag variable in source code.\n\t * \n\t */\n\tvoid tag7() \n\t{\n\t\tint source_code_variable_tag;\n\t\t\n\t\tsource_code_variable_tag += 7;\n\t}\n\n}", "Variables createVariables();", "public MovieManager(GenesisGetters genesisGetters)\r\n/* 151: */ {\r\n/* 152:150 */ setName(\"Video manager\");\r\n/* 153:151 */ this.gauntlet = genesisGetters;\r\n/* 154: */ }", "@Generated\n public Anotacion() {\n }", "public AdvConditionParser()\n{\n //nothing to do\n}", "public ScriptBuilder() {\n }", "public void masterDeclaration();", "@DSSafe(DSCat.SAFE_OTHERS)\n @DSGenerator(tool_name = \"Doppelganger\", tool_version = \"2.0\", generated_on = \"2013-12-30 13:00:49.362 -0500\", hash_original_method = \"1F62AD2938072A93E19EAFFCDA555D07\", hash_generated_method = \"E522C6EE17CC779935F0D04DE1F1F350\")\n \npublic NamespaceSupport ()\n {\n reset();\n }", "public PragmaAnnotation() {\n super();\n }", "public SourceCode() {\n }", "public void robotInit() {\n RobotMap.init();\n initDashboardInput();\n // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS\n driveTrain = new DriveTrain();\n power = new Power();\n arm = new Arm();\n sensors = new Sensors();\n ballGrabberSubsystem = new BallGrabberSubsystem();\n winch = new Winch();\n\n // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS\n // OI must be constructed after subsystems. If the OI creates Commands\n //(which it very likely will), subsystems are not guaranteed to be\n // constructed yet. Thus, their requires() statements may grab null\n // pointers. Bad news. Don't move it.\n oi = new OI();\n\n // instantiate the command used for the autonomous period\n // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS\n\n // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS\n\n arcadeDrive = new ArcadeDrive();\n\n readPreferences();\n }", "OBCArgs createOBCArgs();", "public Generateur() {\n }", "public static void __init() {\r\n\t\t__name__ = new str(\"code\");\r\n\r\n\t\t/**\r\n\t\t copyright Sean McCarthy, license GPL v2 or later\r\n\t\t*/\r\n\t\tdefault_0 = null;\r\n\t\tcl_Code = new class_(\"Code\");\r\n\t}", "private Builder() {\n\t\t}", "public interface Constants {\n final public static String TAG = \"[PracticalTest02Var03]\";\n\n final public static boolean DEBUG = true;\n\n final public static String WEB_SERVICE_ADDRESS = \"http://services.aonaware.com/DictService/DictService.asmx/Define\";\n\n final public static String EMPTY_STRING = \"\";\n\n final public static String QUERY_ATTRIBUTE = \"word\";\n\n final public static String SCRIPT_TAG = \"WordDefinition\";\n final public static String SEARCH_KEY = \"wui.api_data =\\n\";\n\n final public static String CURRENT_OBSERVATION = \"current_observation\";\n}", "DefineBlock createDefineBlock();", "public JavaTokenMaker() {\n\t}", "public AutoLowBarToGoalCmd() {\n\n // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=PARAMETERS\n // Add Commands here:\n // e.g. addSequential(new Command1());\n // addSequential(new Command2());\n // these will run in order.\n\n // To run multiple commands at the same time,\n // use addParallel()\n // e.g. addParallel(new Command1());\n // addSequential(new Command2());\n // Command1 and Command2 will run in parallel.\n\n // A command group will require all of the subsystems that each member\n // would require.\n // e.g. if Command1 requires chassis, and Command2 requires arm,\n // a CommandGroup containing them would require both the chassis and the\n // arm.\n // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=COMMAND_DECLARATIONS\n //addSequential(new LowerIntakeCmd());\n \taddSequential(new ShiftDownCmd());\n \taddParallel(new LowerIntakeCmd());\n addSequential(new DriveStraightCmd(.95,9000.));\n addSequential(new TurnToAngleCmd(56.));\n //addParallel(new BumpIntakeUpCmd());\n addSequential(new DriveStraightCmd(0.9, 4700.));\n \n addSequential(new AutoEjectBallCmd());\n\n // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=COMMAND_DECLARATIONS\n \n }", "private CodeRef() {\n }", "@Override\r\n\tpublic void initVariables() {\n\t\t\r\n\t}", "public BPELGeneratorImpl() {\r\n \t\tsuper(GENERATOR_NAME);\r\n \t}", "@Before\n public void setUp() {\n source = SParser.parse(\"public class MainClass\\n{\\n \"\n + \"public static void main( String args[] )\\n \"\n + \"{ \\n GradeBook myGradeBook = new GradeBook();\"\n + \" \\n\\n String courseName = \\\"Java \\\";\\n \"\n + \" myGradeBook.displayMessage( courseName );\\n \"\n + \" }\\n\\n}\\npublic class Foo{ public boolean bar(){\"\n + \" super.foo(); return false;}}\");\n }", "public GenObfuscatedString() {\n }", "public OnionooParser() {\n\n\t}", "@Override\n public void robotInit() {\n\n // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS\n drive = new Drive();\n pDP = new PDP();\n\n // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS\n // OI must be constructed after subsystems. If the OI creates Commands\n //(which it very likely will), subsystems are not guaranteed to be\n // constructed yet. Thus, their requires() statements may grab null\n // pointers. Bad news. Don't move it.\n oi = new OI();\n camera1 = CameraServer.getInstance().startAutomaticCapture(0);\n camera2 = CameraServer.getInstance().startAutomaticCapture(1);\n camera1.setConnectionStrategy(VideoSource.ConnectionStrategy.kKeepOpen);\n camera2.setConnectionStrategy(VideoSource.ConnectionStrategy.kKeepOpen);\n server = CameraServer.getInstance().getServer();\n flipped = true;\n server.setSource(camera1);\n vexGyro = new AnalogGyro(0);\n vexGyro.setSensitivity(.00175);\n //rightEncoder = new Encoder(0, 1, false);\n //leftEncoder = new Encoder(2, 3, true);\n // Add commands to Autonomous Sendable Chooser\n // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS\n\n chooser.setDefaultOption(\"Autonomous Command\", new AutonomousCommand());\n PixyCamBlock centerBlock = PixyCam2.GetCentermostBlock();\n if(centerBlock == null)\n {\n SmartDashboard.putString(\"target good? \", \"no, is null\");\n }\n else{\n String out = \"Center Block, X: \"+centerBlock.xCenter + \" Y: \"+centerBlock.yCenter;\n SmartDashboard.putString(\"center block data \", out);\n if (centerBlock.yCenter < 200){\n SmartDashboard.putString(\"target good?\", \"YES!!! ycenter less than 200\");\n }\n }\n \n \n\n\n \n \n // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS\n SmartDashboard.putData(\"Auto mode\", chooser);\n SmartDashboard.putBoolean(\"isFlipped\", flipped);\n SmartDashboard.putNumber(\"right encoder\", drive.getRightEncoder());\n SmartDashboard.putNumber(\"left encoder\", drive.getLeftEncoder());\n }", "private void setUp() {\r\n\tvariables = new Vector();\r\n\tstatements = new Vector();\r\n\tconstraints = new Vector();\r\n\tvariableGenerator = new SimpleVariableGenerator(\"v_\");\r\n }", "public void mo6944a() {\n }", "public Athlete()\r\n{\r\n this.def = \"An athlete is said to be running when he/she is accelerating in a certain direction during which his legs and the rest of his body are moving\";\r\n}", "public void init() {\n // message = \"Hello World!\";\n }", "void pramitiTechTutorials() {\n\t\n}", "public LarvaSkeleton() {\n\n }", "private PSUniqueObjectGenerator()\n {\n }", "private BuilderUtils() {}", "public DriveWIthJoysticks() {\n\n // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTOR\n // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARIABLE_SETTING\n\n // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARIABLE_SETTING\n // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUIRES\n requires(Robot.driveTrain);\n\n // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUIRES\n }", "public GantBuilder ( ) { }", "public RunMain0() {\n \n//#line 1\nsuper();\n }", "public interface IBibliotheque {\n\t// Start of user code (user defined attributes for IBibliotheque)\n\n\t// End of user code\n\n\t/**\n\t * Description of the method listeDesEmpruntsEnCours.\n\t */\n\tpublic void listeDesEmpruntsEnCours();\n\n\t// Start of user code (user defined methods for IBibliotheque)\n\n\t// End of user code\n\n}", "public OOP_207(){\n\n }", "private void initializeFile() {\n\t\twriter.println(\"name \\\"advcalc\\\"\");\n\t\twriter.println(\"org 100h\");\n\t\twriter.println(\"jmp start\");\n\t\tdeclareArray();\n\t\twriter.println(\"start:\");\n\t\twriter.println(\"lea si, \" + variables);\n\t}", "public OrchardGame() {\n\t\t\n\t}", "public XMLModel002Builder() {\n }", "private Builder() {}", "@Override\n protected void generateCommonConstants(StringBuilder outputCode) {\n outputCode\n .append('\\n')\n .append(\"/**\\n\")\n .append(\" * Matches all tags, HTML comments, and DOCTYPEs in tag soup HTML.\\n\")\n .append(\" * By removing these, and replacing any '<' or '>' characters with\\n\")\n .append(\" * entities we guarantee that the result can be embedded into a\\n\")\n .append(\" * an attribute without introducing a tag boundary.\\n\")\n .append(\" *\\n\")\n .append(\" * @type {!RegExp}\\n\")\n .append(\" */\\n\")\n .append(\"const $$HTML_TAG_REGEX_ = \")\n .append(convertFromJavaRegex(EscapingConventions.HTML_TAG_CONTENT))\n .append(\"g;\\n\");\n\n outputCode\n .append(\"\\n\")\n .append(\"/**\\n\")\n .append(\" * Matches all occurrences of '<'.\\n\")\n .append(\" *\\n\")\n .append(\" * @type {!RegExp}\\n\")\n .append(\" */\\n\")\n .append(\"const $$LT_REGEX_ = /</g;\\n\");\n\n outputCode\n .append('\\n')\n .append(\"/**\\n\")\n .append(\" * Maps lower-case names of innocuous tags to true.\\n\")\n .append(\" *\\n\")\n .append(\" * @type {!Object<string, boolean>}\\n\")\n .append(\" */\\n\")\n .append(\"const $$SAFE_TAG_WHITELIST_ = \")\n .append(toJsStringSet(TagWhitelist.FORMATTING.asSet()))\n .append(\";\\n\");\n\n outputCode\n .append('\\n')\n .append(\"/**\\n\")\n .append(\" * Pattern for matching attribute name and value, where value is single-quoted\\n\")\n .append(\" * or double-quoted.\\n\")\n .append(\" * See http://www.w3.org/TR/2011/WD-html5-20110525/syntax.html#attributes-0\\n\")\n .append(\" *\\n\")\n .append(\" * @type {!RegExp}\\n\")\n .append(\" */\\n\")\n .append(\"const $$HTML_ATTRIBUTE_REGEX_ = \")\n .append(convertFromJavaRegex(Sanitizers.HTML_ATTRIBUTE_PATTERN))\n .append(\"g;\\n\");\n }", "@Override\n public void robotInit() {\n }", "@Override\n public void robotInit() {\n }", "@Override\n public void robotInit() {\n }", "@MyFirstAnnotation(name=\"tom\",description=\"write by tom\")\n\tpublic UsingMyFirstAnnotation(){\n\t\t\n\t}", "VarsDeclRule createVarsDeclRule();", "public DefaultScopeDescription() {\n }", "public interface UATokenizerConstants {\n\n /** End of File. */\n int EOF = 0;\n /** RegularExpression Id. */\n int WHITESPACE = 1;\n /** RegularExpression Id. */\n int CHAR = 5;\n /** RegularExpression Id. */\n int PICTURES = 6;\n /** RegularExpression Id. */\n int FILLERWORDS = 7;\n /** RegularExpression Id. */\n int THREELETTERWORDS = 8;\n /** RegularExpression Id. */\n int EMAIL = 9;\n /** RegularExpression Id. */\n int PRICES = 10;\n /** RegularExpression Id. */\n int DOMAIN = 11;\n /** RegularExpression Id. */\n int PHONE = 12;\n /** RegularExpression Id. */\n int PHONE2 = 13;\n /** RegularExpression Id. */\n int PHONE3 = 14;\n /** RegularExpression Id. */\n int WORD = 15;\n /** RegularExpression Id. */\n int HTML = 16;\n /** RegularExpression Id. */\n int HTML2 = 17;\n /** RegularExpression Id. */\n int HTMLCOMMENTS = 18;\n /** RegularExpression Id. */\n int NUMBER = 19;\n /** RegularExpression Id. */\n int TOPLEVELDOMAINS = 20;\n /** RegularExpression Id. */\n int SYMBOLS = 21;\n /** RegularExpression Id. */\n int OTHER = 22;\n /** RegularExpression Id. */\n int CHARACTERS = 23;\n\n /** Lexical state. */\n int DEFAULT = 0;\n\n /** Literal token values. */\n String[] tokenImage = {\n \"<EOF>\",\n \"\\\" \\\"\",\n \"\\\"\\\\r\\\"\",\n \"\\\"\\\\t\\\"\",\n \"\\\"\\\\n\\\"\",\n \"<CHAR>\",\n \"<PICTURES>\",\n \"<FILLERWORDS>\",\n \"<THREELETTERWORDS>\",\n \"<EMAIL>\",\n \"<PRICES>\",\n \"<DOMAIN>\",\n \"<PHONE>\",\n \"<PHONE2>\",\n \"<PHONE3>\",\n \"<WORD>\",\n \"<HTML>\",\n \"<HTML2>\",\n \"<HTMLCOMMENTS>\",\n \"<NUMBER>\",\n \"<TOPLEVELDOMAINS>\",\n \"<SYMBOLS>\",\n \"<OTHER>\",\n \"<CHARACTERS>\",\n };\n\n}", "protected void initVars() {}", "private String processConstructor() {\n int firstBracket = line.indexOf('(');\n //The substring of line after the bracket (inclusive)\n String parameters = line.substring(firstBracket);\n return \"A constructor \"+className+parameters+\" is created.\";\n }", "public BuiltBy() {\n }", "public Parameters() {\n\t}", "public _cls_script_13( AutomatonInstance ta,UserAccount _ua,UserInfo _ui) {\nparent = _cls_script_12._get_cls_script_12_inst( _ua,_ui);\nthis.ta = ta;\n}", "public Fun_yet_extremely_useless()\n {\n\n }", "public Code() {\n\t}", "public Keyword() {\n\t}", "public void m20445OooO00o() {\n OooO0OO();\n }", "public static String _globals() throws Exception{\nmostCurrent._pnloverlay = new anywheresoftware.b4a.objects.PanelWrapper();\n //BA.debugLineNum = 21;BA.debugLine=\"Private txtval As EditText\";\nmostCurrent._txtval = new anywheresoftware.b4a.objects.EditTextWrapper();\n //BA.debugLineNum = 22;BA.debugLine=\"Private btnlogin As Button\";\nmostCurrent._btnlogin = new anywheresoftware.b4a.objects.ButtonWrapper();\n //BA.debugLineNum = 23;BA.debugLine=\"Private btndelete As Button\";\nmostCurrent._btndelete = new anywheresoftware.b4a.objects.ButtonWrapper();\n //BA.debugLineNum = 24;BA.debugLine=\"End Sub\";\nreturn \"\";\n}", "public _355() {\n\n }", "public void mo5099c() {\n }", "public DynamicDriveToolTipTagFragmentGenerator(String title, int style) {\n/* 75 */ this.title = title;\n/* 76 */ this.style = style;\n/* */ }", "public GenerateurImpl() {\n\t\tsuper();\n\t\tthis.value = 0;\n\t}", "public BStarTokenMaker() {\n\t\tsuper();\n\t}", "private USBConstant() {\r\n\r\n\t}", "@Word(word = \"First\", value = 1) \n\t public static void newMethod(){ \n\t\t FullAnnotationProgram obj = new FullAnnotationProgram(); \n\n\t try{ \n\t Class<?> c = obj.getClass(); \n\n\t // Obtain the annotation for newMethod \n\t Method m = c.getMethod(\"newMethod\"); \n\t \n\t // Display the full annotation \n\t Annotation anno = m.getAnnotation(CustomRepeatAnnots.class); \n\t System.out.println(anno); \n\t }catch (NoSuchMethodException e){ \n\t System.out.println(e); \n\t } \n\t }", "@Test\n public void testDeclarationAndConventionConflict2() {\n testSame(\"/** @constructor */ function Foo() { /** @protected */ this.length_ = 1;\\n}\\n\");\n }", "private LanguageSkill(Builder builder) {\n\t\tlanguage = builder.language;\n\t\tlevel = builder.level;\n\t\tnotes = builder.notes;\n\t}", "public ClassCommentPlugin() {\n\n\t}", "Petunia() {\r\n\t\t}", "public ScriptDocumentation() {\n this(null, null, null);\n }", "public RobotInfo() {\n }" ]
[ "0.67172956", "0.5946027", "0.58141935", "0.5804879", "0.5690808", "0.55772555", "0.5563161", "0.55399895", "0.5524163", "0.5432969", "0.54297453", "0.53476703", "0.5343199", "0.5339913", "0.5322129", "0.53205043", "0.5312053", "0.52868634", "0.52756965", "0.527216", "0.5271951", "0.5271951", "0.52670246", "0.5249355", "0.5243981", "0.5233898", "0.5230909", "0.522118", "0.5217481", "0.52056694", "0.520536", "0.51906836", "0.5185021", "0.5183419", "0.51753694", "0.5167554", "0.51510555", "0.5145103", "0.51388395", "0.5138235", "0.5130199", "0.512978", "0.5084319", "0.5081206", "0.5076017", "0.50615776", "0.5059041", "0.5055825", "0.5050759", "0.50384974", "0.50378865", "0.5021653", "0.5013658", "0.5009983", "0.5001382", "0.49939603", "0.4983469", "0.49823707", "0.49716574", "0.49640995", "0.49601567", "0.49594828", "0.4946115", "0.4945442", "0.49342173", "0.49335977", "0.4931746", "0.49238467", "0.49124512", "0.49124315", "0.49124238", "0.4908714", "0.4908714", "0.4908714", "0.49082726", "0.49061546", "0.49057513", "0.49049303", "0.49037006", "0.48996767", "0.48983428", "0.4896918", "0.48941597", "0.48935258", "0.4887071", "0.48833257", "0.48788577", "0.48762795", "0.48738593", "0.4872687", "0.48716936", "0.48686296", "0.48657903", "0.48657125", "0.48600638", "0.48599285", "0.4858601", "0.48580897", "0.4857539", "0.48534477", "0.48508194" ]
0.0
-1
Helper function for converting a list of Sex entries to sex results
public static List<SexResult> fromList(List<TblSex> tblSexList) { List<SexResult> sexResultList = new ArrayList<>(); if (tblSexList != null) { for (TblSex tblSex : tblSexList) { sexResultList.add(new SexResult(tblSex)); } } return sexResultList; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "List<Sex> getUsersWithCorrectedGender(List<User> users);", "@Override\n\tpublic Gender convertToEntityAttribute(String sex) {\n\t\tif (sex == null) {\n return null;\n }\n\n return Stream.of(Gender.values())\n .filter(g -> g.getSex().equals(sex))\n .findFirst()\n .orElseThrow(IllegalArgumentException::new);\n\t}", "public static Map<Author.Sex, Set<String>> groupUniqueAuthorLastNameByGender(List<Book> inputList) {\n\t\tMap<Author.Sex, Set<String>> result = inputList.stream().map(Book::getAuthor).collect(\n\t\t\t\t\tCollectors.groupingBy(Author::getGender,\n\t\t\t\t\tCollectors.mapping(Author::getLastName, Collectors.toSet())));\n\t\tSystem.out.println(result);\n\t\treturn result;\n\t}", "public static Map<Author.Sex, List<Author>> groupAuthorsByGender(List<Book> inputList) {\n\t\treturn inputList.stream().map(Book::getAuthor).collect(\n Collectors.groupingBy(Author::getGender));\n\t}", "public static Map<Author.Sex, Set<Author>> groupUniqueAuthorsByGender(List<Book> inputList) {\n\t\tMap<Author.Sex, Set<Author>> result = inputList.stream().map(Book::getAuthor).collect(\n\t\t\t\t\tCollectors.groupingBy(Author::getGender,\n\t\t\t\t\t\t\tCollectors.mapping(Author::getAuthor, Collectors.toSet())));\n\t\tSystem.out.println(result);\n\t\treturn result;\n\t}", "public List<Ingredient> toIngredient(List<String> ingredientsList) {\n\t\tList<Ingredient> ingredients = new ArrayList<Ingredient>();\n\t\tfor (int i = 0; i < ingredientsList.size(); i++) {\n\t\t\tingredients.add(new Ingredient(ingredientsList.get(i)));\n\t\t}\n\t\treturn ingredients;\n\t}", "public ArrayList<Person> getBySex(Sex sex) {\n\t\tArrayList<Person> result = new ArrayList<Person>();\n\t\tfor (Person p: this.data.values()) {\n\t\t\tif (p.getSex().equals(sex)) result.add(p);\n\t\t}\n\t\treturn result;\n\t}", "static SexType checkSex(String data){\n if(data.contains(\"M\"))\n return SexType.MALE;\n else\n return SexType.FEMALE;\n }", "private List<Gender> extractGenders() {\n List<String> names = getNames(\"gender\");\n names.add(\"neutral\");\n GenderSelectAsyncTask task = new GenderSelectAsyncTask();\n GenderMapper mapper = new GenderMapper();\n task.setTypes(names);\n List<Gender> genders = new ArrayList<>(0);\n try {\n genders.addAll(mapper.to(task.execute().get()));\n } catch (ExecutionException | InterruptedException e) {\n Log.e(TAG, \"extractGenders: \" + e.getMessage(), e);\n }\n return genders;\n }", "public void convertHashtoArray(ArrayList<Manufacturer> manu){\r\n\t\tfor(Manufacturer d: manu){\r\n\t\tManlist.add(t.get(d.code));\r\n\t\t}\r\n\t}", "public static List<Student> filterMaleValues(){\n\n\t\tList<Student> filterMaleExe = StudentDataBase.getAllStudents().stream()\n\t\t\t\t.filter(k->k.getGradeLevel()>=3.9)\n\t\t\t\t.filter(j->j.getGender().equals(\"male\")).collect(Collectors.toList());\n\t\treturn filterMaleExe;\n\t}", "@Override\n\tprotected List<String[]> transform(String[] fields) {\n\t\t//put collection\n\t\tList<String[]> results = new ArrayList<String[]>();\n //event\n String event_id = fields[0];\n\n //status - yes\n if ( fields.length > 1 && fields[1] != null ) {\n \t//split\n \tString[] yesUsers = fields[1].split(\" \");\n \t//check\n \tif ( yesUsers != null && yesUsers.length > 0 ) {\n \t\t//loop\n \t\tfor ( String yesUser : yesUsers ) {\n \t\t\t//add\n \t\t\tresults.add(new String[] { event_id, yesUser, \"yes\" });\n \t\t} \n \t}\n } \n \n //status - maybe\n if ( fields.length > 2 && fields[2] != null ) {\n \t//split\n \tString[] maybeUsers = fields[2].split( \" \" );\n \t//check\n \tif ( maybeUsers != null && maybeUsers.length > 0 ) {\n \t\t//loop\n \t\tfor ( String maybeUser : maybeUsers ) {\n \t\t\t//add\n \t\t\tresults.add(new String[] { event_id, maybeUser, \"maybe\" });\n \t\t} \n \t}\n } \n\n //status - invited\n if ( fields.length > 3 && fields[3] != null ) {\n \t//split\n \tString[] invitedUsers = fields[3].split( \" \" );\n \t//check\n \tif ( invitedUsers != null && invitedUsers.length > 0 ) {\n \t\t//loop\n \t\tfor ( String invitedUser : invitedUsers ) {\n \t\t\t//add\n \t\t\tresults.add(new String[] { event_id, invitedUser, \"invited\" });\n \t\t} \n \t}\n } \n\n //status - no\n if ( fields.length > 4 && fields[4] != null ) {\n \t//split\n \tString[] noUsers = fields[4].split( \" \" );\n \t//check\n \tif ( noUsers != null && noUsers.length > 0 ) {\n \t\t//loop\n \t\tfor ( String noUser : noUsers ) {\n \t\t\t//add\n \t\t\tresults.add(new String[] { event_id, noUser, \"no\" });\n \t\t} \n \t}\n } \n return results;\n }", "public Boolean getSex();", "public Sex getSex() {\n return sex;\n }", "public String getSex()\n {\n return sex;\n }", "private List<QuantifiedVariableCore> transform(QuantifiedVariableCore[] qv)\n {\n List<QuantifiedVariableCore> qv0 = new ArrayList<QuantifiedVariableCore>();\n for (QuantifiedVariableCore q : qv)\n qv0.add(transform(q));\n return qv0;\n }", "public String getSex() {\r\n return sex;\r\n }", "public String getSex() {\n\t\treturn sex;\n\t}", "public String getSex() {\n\t\treturn sex;\n\t}", "public abstract List<T> convertToEntities(List<D> dtos);", "public java.lang.String getSex() {\r\n return localSex;\r\n }", "public String getSex() {\n return sex;\n }", "public String getSex() {\n return sex;\n }", "public String getSex() {\n return sex;\n }", "public String getSex() {\n return sex;\n }", "public String getSex() {\n return sex;\n }", "public String getSex() {\n return sex;\n }", "public String getSex() {\n return sex;\n }", "public String getSex() {\n return sex;\n }", "public abstract List toNameValueList();", "public static List<Student> getAllStudents(){\r\n Student student1 = new Student(\"Dowlath\",2,3.6,\"male\", Arrays.asList(\"Swim\",\"BasketBall\",\"VolleyBall\"),11);\r\n Student student2 = new Student(\"Bhavya\",2,3.8,\"female\",Arrays.asList(\"Swim\",\"Gymnastics\",\"soccer\"),12);\r\n\r\n\r\n /* 3rd Grade Students */\r\n Student student3 = new Student(\"Priya\",3,4.0,\"female\", Arrays.asList(\"Swim\",\"BasketBall\",\"Aerobics\"),10);\r\n Student student4 = new Student(\"Arsh\",3,3.9,\"male\",Arrays.asList(\"Swim\",\"Gymnastics\",\"soccer\"),9);\r\n\r\n\r\n /* 4th Grade Students */\r\n Student student5 = new Student(\"Sowmiya\",4,3.5,\"female\", Arrays.asList(\"Swim\",\"Dancing\",\"FootBall\"),15);\r\n Student student6 = new Student(\"Ariz\",4,3.9,\"male\",Arrays.asList(\"Swim\",\"BasketBall\",\"BaseBall\",\"FootBall\"),14);\r\n\r\n List<Student> students = Arrays.asList(student1,student2,student3,student4,student5,student6);\r\n return students;\r\n }", "public static String convertArrayListIntoString (ArrayList inputList){\n\n // convert exercisesList to string\n String resultString = \"(\";\n for (int i = 0; i < inputList.size(); i ++) {\n if (i != inputList.size() - 1) {\n resultString = resultString + inputList.get(i) + \", \";\n } else {\n resultString = resultString + inputList.get(i) + \")\";\n }\n }\n\n return resultString;\n }", "private static List<StudentRecord> convert(List<String> lines) {\n\t\tList<StudentRecord> records = new ArrayList<>();\n\n\t\tfor (String line : lines) {\n\t\t\tif(line.isEmpty()) continue;\n\t\t\t\n\t\t\trecords.add(StudentRecord.fromLine(line));\n\t\t}\n\n\t\treturn records;\n\t}", "public static List<Student> filterExample(){\n\t\tList<Student> genderFilter = StudentDataBase.getAllStudents().stream()\n\t\t\t\t.filter(stu->stu.getGender().equals(\"female\")).collect(Collectors.toList());\n\t\treturn genderFilter;\n\t}", "String tomar_decisiones(String decision);", "@Override\n public MapperEmissionList call() {\n MapperEmissionList EmissionList = new MapperEmissionList();\n String[] splited = value.split(\"\\\\s+\");\n for (int ii=0; ii<splited.length; ii++) {\n splited[ii] = splited[ii].replaceAll(\"[^\\\\w]\", \"\");\n EmissionList.add(\n new MapperEmission(splited[ii] , 1) // emit the pair (ii-th character,1)\n );\n }\n return EmissionList;\n }", "protected ArrayList<String> convertUeToNamesList(ArrayList<UE> ueList2) {\n\t\tArrayList<String> ueList = new ArrayList<String>();\n\t\tfor (UE ue : ueList2) {\n\t\t\tueList.add(\"UE\" + ue.getName().replaceAll(\"\\\\D+\", \"\").trim());\n\t\t}\n\t\treturn ueList;\n\t}", "private static List<Feature> getFeatures(List<String> row) {\n\t\tString sex = row.get(0);\n\t\tdouble length = Double.parseDouble(row.get(1));\n double diameter = Double.parseDouble(row.get(2));\n double height = Double.parseDouble(row.get(3));\n// double whole_height = Double.parseDouble(row.get(4));\n// double shucked_height = Double.parseDouble(row.get(5));\n double viscera_weight = Double.parseDouble(row.get(6));\n double shell_weight = Double.parseDouble(row.get(7));\n\t\tList<Feature> features = new ArrayList<Feature>();\n\t\tfeatures.add(new NominalFeature(sex));\n\t\tfeatures.add(new ContinuousFeature(length));\n\t\tfeatures.add(new ContinuousFeature(diameter));\n\t\tfeatures.add(new ContinuousFeature(height));\n//\t\tfeatures.add(new ContinuousFeature(whole_height));\n//\t\tfeatures.add(new ContinuousFeature(shucked_height));\n\t\tfeatures.add(new ContinuousFeature(viscera_weight));\n\t\tfeatures.add(new ContinuousFeature(shell_weight));\n\t\treturn features;\n\t}", "private boolean testSexSecol() {\n switch (S) {\n case \"1\":\n // 1,2 1900-1999\n secol = \"19\";\n Sex = \"M\";\n break;\n case \"2\":\n secol = \"19\";\n Sex = \"F\";\n break;\n case \"3\":\n // 3,4 1800-1899\n secol = \"18\";\n Sex = \"M\";\n break;\n case \"4\":\n secol = \"18\";\n Sex = \"F\";\n break;\n case \"5\":\n // 5,6 2000-2099\n secol = \"20\";\n Sex = \"M\";\n break;\n case \"6\":\n secol = \"20\";\n Sex = \"F\";\n break;\n case \"7\":\n // 7,8 straini rezidenti 1900+\n secol = \"19\";\n Sex = \"M\";\n break;\n case \"8\":\n secol = \"19\";\n Sex = \"F\";\n break;\n case \"9\":\n // 9 straini 1900+\n secol = \"19\";\n break;\n default:\n // Sexul nu poate fi \"0\"\n return false;\n }\n return true;\n }", "public void setSex(String sex);", "@Override\n public String predict (final ArrayList<String> values) {\n final ArrayList<Double> annExX = FloatConverter.valuesToDouble(values, attrs);\n // Get predict of ANN.\n final ArrayList<Double> output = getV(annExX);\n // Convert ANN output to raw output.\n final String target = FloatConverter.targetBackString(output, attrs);\n return target;\n }", "public static double getAverageAgeOfAuthorsByGender(List<Book> inputList, Enum<Sex> gender) {\n\t\tSet<Author> set = (Set<Author>)inputList.stream().map(Book::getAuthor).collect(Collectors.toCollection(HashSet::new));\n\t\treturn set.stream().filter(a -> a.getGender() == gender)\n\t\t\t\t.mapToInt(Author::getAge)\n\t\t\t\t.average().getAsDouble();\n\t}", "@Test\n public void encodeWeaponsTest() {\n Weapon weapon1 = new LockRifle();\n Weapon weapon2 = new Electroscythe();\n Weapon weapon3 = new MachineGun();\n ArrayList<Weapon> weaponsList = new ArrayList<>();\n weaponsList.add(weapon1);\n weaponsList.add(weapon2);\n weaponsList.add(weapon3);\n ArrayList<String> weaponsListLite = Encoder.encodeWeaponsList(weaponsList);\n String[] weaponsArrayLite = Encoder.encodeWeaponsIntoArray(weaponsList);\n ArrayList<String> expectedListLite = new ArrayList<>();\n expectedListLite.add(\"LOCK RIFLE\");\n expectedListLite.add(\"ELECTROSCYTHE\");\n expectedListLite.add(\"MACHINE GUN\");\n String[] expectedArrayLite = new String[]{\"LOCK RIFLE\", \"ELECTROSCYTHE\", \"MACHINE GUN\"};\n Assert.assertEquals(expectedListLite, weaponsListLite);\n for (int i = 0; i < weaponsArrayLite.length; i++) {\n Assert.assertEquals(weaponsArrayLite[i], expectedArrayLite[i]);\n }\n }", "List<StudentDTO> toStudentDTOs(List<Student> students);", "@SuppressWarnings(\"unchecked\")\n\tpublic ArrayList<String> convert(String measure, String unit, float amount, String[] units) throws Exception {\n\t\tConverter c = new Converter();\n\t\tMethod m = Converter.class.getMethod(measure, String.class, float.class, String[].class);\n\t\treturn (ArrayList<String>) m.invoke(c, unit, amount, units);\n\t}", "public static void runExercise2() {\n students.stream().filter(student -> student.getGender().equals(Gender.MALE)).forEach(y -> System.out.println(y.getFirstName()));\n }", "private List<String> applySSA() {\n\t\t//String content = Utility.getStringFromFile(filePath);\n\t\tList<String> ssa = new ArrayList<String>();\n\t\tInputStream stream = new ByteArrayInputStream(source.getBytes());\n\t\ttry {\n\t\t\tANTLRInputStream input = new ANTLRInputStream(stream);\n\t\t\tEntryLexer lexer = new EntryLexer(input);\n\t\t\tCommonTokenStream tokens = new CommonTokenStream(lexer);\n\t\t\tEntryParser parser = new EntryParser(tokens);\n\t\t\tProgContext prog = parser.prog();\n\t\t\tconvertToSSAString(prog, ssa);\n\t\t\treturn ssa;\n\t\t} catch (IOException e) {\n\t\t\t//\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn null;\n\t}", "@Override\n\tpublic List<Exam> toEntity(List<ExamDTO> dtoList) {\n\t\treturn null;\n\t}", "public String changeGendersOfPlaylist(Gender[] allGenders){\n String out = \"\";\n boolean stop = false;\n if(allGenders[0] == null){\n out = \"UNKNOWN\";\n }else{\n for(int i = 0; i<MAX_SONGS_PLAYLIST; i++){\n for(int j = 0; j<MAX_SONGS_PLAYLIST-1 && !stop; j++){\n if(i != j){\n if(allGenders[i] == allGenders[j]){\n allGenders[i] = null;\n } \n } \n } \n }\n for(int i = 0; i < MAX_SONGS_PLAYLIST; i++){\n if(allGenders[i] != null){\n out += allGenders[i]+\", \";\n }\n }\n }\n return out;\n }", "public void setSex(String sex)\n {\n this.sex = sex;\n }", "public void setSex(String sex) {\n this.sex = sex;\n }", "List <JAVATYPE> convertList(List<JAVATYPE> oldList, final METATYPE meta);", "public Short getSex() {\n return sex;\n }", "private ArrayList<String> dataConvertForFromArray(ArrayList<Response.Messages> message_array_list){\n\t\tArrayList<String> all_returned_data = new ArrayList<String>();\n\n\t\tString str1 = \"\";\n\n\t\ttry{\n\t\t\tfrom_data = mf.fFrom(message_array_list);\n\t\t} catch (NullPointerException e){\n\t\t\te.printStackTrace();\n\t\t}\n\n\t\t//For loop to combine all data into readable format for message preview list\n\t\tfor (int i = 0; i<message_array_list.size(); i++){\n\t\t\tstr1 = from_data.get(i);\n\t\t\tall_returned_data.add(str1);\n\t\t}\n\t\treturn all_returned_data;\n\t}", "private List<String> calculateAverageAge(List<Person> population)\n\t{\n\t\tdouble average = population\n\t\t\t .stream()\n\t\t\t .mapToInt(Person::getAge) // Converts this to an int stream...could also have called p->p.getAge()\n\t\t\t .average() // operates on a numeric stream...to perform an aggregate operation on it (OptionalDouble if you have an empty stream)\n\t\t\t .getAsDouble(); // converts it to a specific data type\n\t\tString output = String.format(\"%.1f\", average);\n\t\t\n\t\tList<String> results = new ArrayList<String>();\n\t\tresults.add(output);\n\t\t\n\t\treturn results;\n\t}", "private static void format1(ArrayList<String> l) {\n\t\tArrayList<String> listContents = l;\n\t\tArrayList<Person> personList = new ArrayList<Person>();\n\t\tfor (int i = 0; i < listContents.size(); i++) {\n\t\t\tPerson person = new Person();\n\n\t\t\tperson.setFirstName(listContents.get(i).substring(0, 10).replaceFirst(\"\\\\s++$\", \"\"));\n\t\t\tperson.setLastName(listContents.get(i).substring(10, 27).replaceFirst(\"\\\\s++$\", \"\"));\n\t\t\tperson.setStartDate(listContents.get(i).substring(27, 35).replaceFirst(\"\\\\s++$\", \"\"));\n\t\t\tperson.setAddress(listContents.get(i).substring(35, 45).replaceFirst(\"\\\\s++$\", \"\"));\n\t\t\tperson.setAptNum(listContents.get(i).substring(45, 55).replaceFirst(\"\\\\s++$\", \"\"));\n\t\t\tperson.setCity(listContents.get(i).substring(55, 65).replaceFirst(\"\\\\s++$\", \"\"));\n\t\t\tperson.setState(listContents.get(i).substring(65, 67).replaceFirst(\"\\\\s++$\", \"\"));\n\t\t\tperson.setCountry(listContents.get(i).substring(67, 70).replaceFirst(\"\\\\s++$\", \"\"));\n\t\t\tperson.setZipCode(listContents.get(i).substring(70, 80).replaceFirst(\"\\\\s++$\", \"\"));\n\n\t\t\tpersonList.add(person);\n\t\t}\n\t\tselectSortingOption(personList);\n\t}", "public Integer getSex() {\r\n return sex;\r\n }", "List<UserResponse> toUserResponses(List<User> users);", "public List<V> transformList(List<E> list) {\n \tList<V> result = new ArrayList<>(list.size());\n if (list != null) {\n for (E entity : list) {\n result.add(getCachedVO(entity));\n }\n }\n \treturn result;\n }", "public void asignarAnexo(){\r\n String indiceStr;\r\n int indice, i=0;\r\n System.out.println(\"-----------------------------------\");\r\n System.out.println(\" Lista de Empleados\");\r\n System.out.println(\"-----------------------------------\");\r\n //RECORRER ARRAYLIST\r\n for (i=0 ; i<empleados.size() ; i=i+1) {\r\n System.out.print( (i + 1) +\" \"+empleados.get(i).getPerNombre()+\" \"+\r\n empleados.get(i).getPerApellidoPaterno()+\" \"+\r\n empleados.get(i).getPerApellidoMaterno()+\" tiene el anexo : \");\r\n if(empleados.get(i).getEmpAnexo() != null){\r\n System.out.println(empleados.get(i).getEmpAnexo()); //QUE ANEXO TIENE\r\n }else{\r\n System.out.println(\" Sin asignar \");\r\n }\r\n }\r\n if(i>0){\r\n try {\r\n System.out.print(\"Seleccione el codigo del empleado : \\t\");\r\n indiceStr = entrada.readLine();\r\n indice = Integer.parseInt(indiceStr);\r\n indice = indice - 1;\r\n System.out.println(\"-----------------------------------\");\r\n System.out.println(\" Lista de Anexo\");\r\n System.out.println(\"-----------------------------------\");\r\n// RECORRE ENUMERADO ANEXOS\r\n for(Anexo a : Anexo.values()){ \r\n System.out.println(\"\\t\" + a.getAneCodigo()+ \" - \"+a.toString() + \" area: \"+ a.getAneUbicacion());\r\n }\r\n System.out.print(\"Seleccione Anexo: \");\r\n // ASIGNA ANEXO A EMPLEADO\r\n empleados.get(indice).setEmpAnexo(entrada.readLine());\r\n System.out.println(\"*****Empleado se asigno anexo \"+empleados.get(indice).getEmpAnexo().name()+\" *****\");\r\n } catch (IOException ex) {\r\n System.out.println(\"Ocurrio un error al ingresar datos= \"+ex.toString());\r\n } catch(NumberFormatException ex){\r\n System.out.println(\"Ocurrio un error al convertir numero= \"+ex.toString());\r\n }\r\n }else{\r\n System.out.println(\"-NO existen Empleado Registrados-\");\r\n }\r\n }", "public String getDenumireSex(String id) {\n c = db.rawQuery(\"select denumire from sex where id='\" + id + \"'\", new String[]{});\n StringBuffer buffer = new StringBuffer();\n while (c.moveToNext()) {\n String denumire = c.getString(0);\n buffer.append(\"\" + denumire);\n }\n return buffer.toString();\n }", "public Integer getSex() {\n return sex;\n }", "public Integer getSex() {\n return sex;\n }", "public Integer getSex() {\n return sex;\n }", "public Integer getSex() {\n return sex;\n }", "public Integer getSex() {\n return sex;\n }", "public void transformMarksInDamages(String offendername) {\n\n while (marks.contains(offendername)) {\n\n for (Iterator<String> iterator = marks.iterator(); iterator.hasNext(); ) {\n\n String occurence = iterator.next();\n\n if (occurence.equals(offendername)) {\n giveDamage(offendername, 1);\n\n iterator.remove();\n }\n }\n }\n }", "public void preprocessObsList(List<Obs> obsList) {\n for(Obs obs : obsList) {\r\n if (dictionary.isMapped(obs) != null) {\r\n dictionary.mapToNMRS(obs);\r\n System.out.println(\"CMap was found\");\r\n obs.setAllowed(true);\r\n }else{\r\n obs.setAllowed(false);\r\n dictionary.log(obs);\r\n }\r\n if(isExisting(obs)){\r\n obs.setExist(true);\r\n }else{\r\n obs.setExist(false);\r\n }\r\n }\r\n System.out.println(\"Preprocess Obs...\");\r\n //return mappedObs;\r\n }", "public List<String> getAEIsOutputFromAttacDecls(List<AttacDecl> list) \r\n\t\t{\r\n\t\tList<String> list2 = new ArrayList<String>();\r\n\t\tfor (AttacDecl attacDecl : list)\r\n\t\t\t{\r\n\t\t\tlist2.add(attacDecl.getOutputAei());\r\n\t\t\t}\r\n\t\treturn list2;\r\n\t\t}", "private List<EventInfo> map(List<EventLog> entries) {\n List<EventInfo> events = new ArrayList<>();\n for (EventLog entry : entries) {\n events.add(map(entry));\n }\n return events;\n }", "private List<Interpretation> updateInterpretations(List<Interpretation> namesInterpretations, \n List<NameResult> nameResults, String word, int maxNumOfInterpretations) {\n\n //nothing added before - just create one interpretation for each nameResult\n if (namesInterpretations.isEmpty()) {\n List<Interpretation> newInterpretations = new ArrayList<>();\n for (NameResult nameResult : nameResults) {\n nameResult.setOriginalName(word);\n newInterpretations.add(new Interpretation(\n new ArrayList<>(Arrays.asList(nameResult))));\n }\n namesInterpretations = newInterpretations;\n }\n //merge current name results with previous interpretations\n else {\n List<Interpretation> newInterpretations = new ArrayList<>();\n for (Interpretation interpretation : namesInterpretations) {\n if (newInterpretations.size() >= maxNumOfInterpretations) {\n break;\n }\n for (int i = 0; i < nameResults.size(); i++) {\n NameResult altName = nameResults.get(i);\n altName.setOriginalName(word);\n ArrayList<NameResult> newInterpretation = new ArrayList<>(\n interpretation.getNameResults());\n newInterpretation.add(altName);\n newInterpretations.add(new Interpretation(newInterpretation));\n }\n }\n namesInterpretations = newInterpretations;\n }\n\n return namesInterpretations;\n }", "public static ArrayList<StudentGrade> getGradesbyRubric(ArrayList<Rubric> rubric , String rubricName)\n{\n ArrayList<StudentGrade> grades = null;\n for(Rubric search: rubric)\n {\n if(search.getRubricName().equalsIgnoreCase(rubricName))\n {\n \n grades= search.getGrades();\n }\n\n }\n return grades; \n}", "private static FighterModel[] convertToArray(ArrayList<FighterModel> convertFighters) {\n if (convertFighters == null) {\n return null;\n } else {\n Collections.sort(convertFighters);\n int size = convertFighters.size();\n FighterModel[] fighters = new FighterModel[size];\n for (int i = 0; i < size; i++) {\n fighters[i] = convertFighters.get(i);\n }\n return fighters;\n }\n }", "public List<String> getAEIsInputFromAttacDecls(List<AttacDecl> list) \r\n\t\t{\r\n\t\tList<String> list2 = new ArrayList<String>();\r\n\t\tfor (AttacDecl attacDecl : list)\r\n\t\t\t{\r\n\t\t\tlist2.add(attacDecl.getInputAei());\r\n\t\t\t}\r\n\t\treturn list2;\r\n\t\t}", "private static List<StudentRecord> convert(List<String> lines) {\n\t\tObjects.requireNonNull(lines);\n\t\t\n\t\tArrayList<StudentRecord> result = new ArrayList<>(lines.size());\n\t\t\n\t\tfor(String data : lines) {\n\t\t\tif(data.length() == 0) continue; //preskoci prazne linije\n\t\t\tScanner sc = new Scanner(data);\n\t\t\tsc.useDelimiter(\"\\t\");\n\t\t\t\n\t\t\ttry {\n\t\t\t\tresult.add(new StudentRecord(sc.next(), sc.next(), sc.next(), sc.next(), sc.next(), sc.next(), sc.next()));\n\t\t\t}catch(NoSuchElementException e) {\n\t\t\t\tsc.close();\n\t\t\t\tthrow new NoSuchElementException(\"Data not formatted correctly.\");\n\t\t\t}\n\t\t\tsc.close();\n\t\t}\n\t\t\n\t\treturn result;\n\t}", "public ArrayList<String> arrayListFromIngredient(List<IngredientModel> ingredientModelList){\n ArrayList<String> ingredientList = new ArrayList<>();\n\n //Loops through List<IngredientModel>, retrieves ingredient name and adds to ArrayList<String>\n for(int i = 0; i<ingredientModelList.size(); i++){\n String ingredient = ingredientModelList.get(i).getName();\n ingredientList.add(ingredient);\n }\n\n return ingredientList;\n }", "void substituteIndicatorExpressions(Collection<Indicator> indicators);", "@Override\r\n\tpublic void findAll(List<Student> list) {\n\t\tSystem.out.println(\"查询所有学生\");\r\n\t\tfor(Student i:list){\r\n\t\t\ti.info();\r\n\t\t}\t\t\r\n\t}", "@Override\n\t\tpublic String serialize(List<Person> list) throws Exception {\n\t\t\tSAXTransformerFactory factory = (SAXTransformerFactory) TransformerFactory\n\t\t\t\t\t.newInstance();\n\t\t\tTransformerHandler handler = factory.newTransformerHandler();\n\t\t\tTransformer transformer = handler.getTransformer();\n\t\t\ttransformer.setOutputProperty(OutputKeys.ENCODING, \"UTF-8\");\n\t\t\ttransformer.setOutputProperty(OutputKeys.INDENT, \"yes\");\n\t\t\ttransformer\n\t\t\t\t\t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, \"no\");\n\t\t\tStringWriter writer = new StringWriter();\n\t\t\tResult result = new StreamResult(writer);\n\t\t\thandler.setResult(result);\n\t\t\tString uri = \"\";\n\t\t\tString localName = \"\";\n\t\t\thandler.startDocument();\n\t\t\thandler.startElement(uri, localName, \"persons\", null);\n\t\t\tAttributesImpl attrs = new AttributesImpl();\n\t\t\tchar[] ch = null;\n\t\t\tfor (Person p : list) {\n\t\t\t\tattrs.clear();\n\t\t\t\tattrs.addAttribute(uri, localName, \"id\", \"string\",\n\t\t\t\t\t\tString.valueOf(p.getId()));\n\t\t\t\thandler.startElement(uri, localName, \"person\", attrs);\n\t\t\t\thandler.startElement(uri, localName, \"name\", null);\n\t\t\t\tch = p.getName().toCharArray();\n\t\t\t\thandler.characters(ch, 0, ch.length);\n\t\t\t\thandler.endElement(uri, localName, \"name\");\n\t\t\t\thandler.startElement(uri, localName, \"age\", null);\n\t\t\t\tch = String.valueOf(p.getAge()).toCharArray();\n\t\t\t\thandler.characters(ch, 0, ch.length);\n\t\t\t\thandler.endElement(uri, localName, \"age\");\n\t\t\t\thandler.endElement(uri, localName, \"person\");\n\t\t\t}\n\t\t\thandler.endElement(uri, localName, \"persons\");\n\t\t\thandler.endDocument();\n\t\t\treturn writer.toString();\n\t\t}", "public void setSex(String sex) {\n\t\tthis.sex = sex;\n\t}", "public void setSex(String sex) {\n\t\tthis.sex = sex;\n\t}", "public static void main(String[] args) {\n List<Person> people = createPeople();\n\n // we can remap them to bring out their name and age as key, and the person object as value\n System.out.println(people.stream().collect(Collectors.toMap(\n person -> person.getName() + \" \" + person.getAge(),\n person -> person\n )));\n\n // or grab the first person matching a gender\n System.out.println(people.stream()\n .filter( e -> e.getGender() == Gender.FEMALE)\n .findFirst()\n .get());\n\n // or collect them to a map with their names as key\n System.out.println(people.stream()\n .collect(Collectors.groupingBy(Person::getName)));\n\n System.out.println(people.stream()\n .collect(Collectors.groupingBy(Person::getName,\n Collectors.mapping(Person::getAge, Collectors.toList()))));\n\n // one more exercise\n List<Integer> numbers = Arrays.asList(1, 2, 3, 5, 4, 2 ,9, 54, 23, 11 , 6, 7, 8,\n 32, 78, 99, 11, 11, 9, 10,15, 36, 85, 63 ,52);\n\n // given a list find the double of the first even nr greater then 3.\n // a basic solution would be the following\n int result = 0;\n for (int e : numbers) {\n if (e > 3 && e % 2 == 0) {\n result = e * 2;\n break;\n }\n }\n\n // we can make it a lot nicer though\n result = numbers.stream()\n .filter(StreamsTwo::isGT3)\n .filter(StreamsTwo::isEven)\n .map( StreamsTwo::doubleIt)\n .findFirst()\n .get();\n \n System.out.println(result);\n\n numbers.stream()\n \t.sorted()\n \t.distinct()\n \t.forEach(System.out::println);\n\n }", "public abstract List<ScorePackage> getScores(List<T> observationList);", "private ArrayList<String> translateGoodsList(List<TradeGood> goodList) {\n ArrayList<String> cargoNames = new ArrayList<>();\n for (int i = 0; i < goodList.size(); i++) {\n for (int j = 0; j < TradeGood.values().length; j++) {\n if (goodList.get(i) != null && goodList.get(i) == (TradeGood.values()[j])) {\n cargoNames.add(this.getApplication().getResources().getStringArray(R.array.goodNames)[j]);\n }\n }\n\n }\n return cargoNames;\n }", "public void f5(List<Book> a) {\r\n for (Book o : a) {\r\n String code = o.getCode();\r\n String result = \"\";\r\n for (int i = 0; i < code.length(); i++) {\r\n char c = code.charAt(i);\r\n if (Character.isLetter(c)) {\r\n if (Character.isUpperCase(c)) {\r\n c = Character.toLowerCase(c);\r\n } else {\r\n c = Character.toUpperCase(c);\r\n }\r\n }\r\n result += c;\r\n }\r\n o.setCode(result);\r\n }\r\n }", "private void adaptResultListToPDFFormat() {\n ArrayList<Result> result = new ArrayList<Result>();\n for (int i = 0; i < pdfBoxDocuments.size(); i++) {\n PDFDocument pdf = pdfBoxDocuments.get(i);\n\n String title = pdf.getDocname();\n title = title.substring(title.lastIndexOf('/') + 1, title.lastIndexOf('.'));\n String kwic = pdf.getText()[0];\n String url = pdf.getDocname();\n result.add(new Result(title, kwic, url));\n }\n results = new Results();\n results.setResults(result);\n }", "@SuppressWarnings(\"unchecked\")\n\tprivate void parseSubjectsForRIFCSElement(List<Subject> subjects, boolean isMutiple) {\n\t\tfor (Subject subject : subjects) {\n\t\t\tString key = \"subject.\" + subject.getType();\n\t\t\tString csvFieldName = filedsMapping.getString(\"\",key);\n\t\t\tif (!\"\".equals(csvFieldName)) {\n\t\t\t\tif(isMutiple) {\n\t\t\t\t\tthis.data.put(csvFieldName + \"_\" + (subjects.indexOf(subject) + 1), subject.getValue());\n\t\t\t\t} else {\n\t\t\t\t\tthis.data.put(csvFieldName, subject.getValue());\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "public static void main(String[] args) {\n ArrayList<arrayset> list = new ArrayList<>();\n String [] newarray= new String[97];\n File data = new File(\"records.txt\");\n try {\n Scanner input = new Scanner(data);\n while (input.hasNextLine()) {\n String line = input.nextLine();\n firstName = line.split(\",\")[0];\n\n lastName = line.split(\",\")[1];\n\n gender = line.split(\",\")[2];\n\n age = Integer.parseInt(line.split(\",\")[3]);\n\n phoneNo = line.split(\",\")[4];\n\n email = line.split(\",\")[5];\n\n firstName = Character.toUpperCase(firstName.charAt(0)) + firstName.substring(1, firstName.length());\n lastName = Character.toUpperCase(lastName.charAt(0)) + lastName.substring(1, lastName.length());\n\n if (gender.toLowerCase() == \"male\" || gender.toLowerCase() == \"female\") {\n gender = gender.toLowerCase();\n }\n if (age > 1 || age < 129) {\n age = age;\n }\n else if(age <1 || age > 129) {\n System.out.println(\"Error person not valid\");\n }\n if (phoneNo.length() == 13) {\n phoneNo = phoneNo;\n }\n else if(phoneNo.length()<13) {\n System.out.println(\"Error person not valid\");\n }\n if (email.matches(\"[A-Z][0-9].@\")) {\n email = email;\n }\n else if(email.matches(\"[A-Z][0-9].@\")) {\n System.out.println(\"Error person not valid\");\n }\n list.add(new arrayset(firstName, lastName, gender, age, phoneNo, email));\n }\n input.close();\n }\n catch (FileNotFoundException e) {\n System.out.println(\"Error Wrong File!\");\n }\n System.out.println(\"Error: Person 4 is not valid, since age = -89\\n\" +\n \"Error: Person 12 is not valid, since last name = Lara22\\n\" +\n \"Error: Person 21 is not valid, since age = 179\\n\" +\n \"Error: Person 32 is not valid, since last name = Mccullough\\n\" +\n \"Error: Person 52 is not valid, since email = MMaddenMadden.net\\n\" +\n \"Error: Person 96 is not valid, since age = 0\");\n System.out.format(\"%-20s%-15s%-15s%-10s%-20s%7s \", \"First Name\", \"Last Name\", \"Gender\", \"Age\", \"Number\", \"Email\");\n\n int i = 0;\n while (i < list.size()) {\n String printarray= String.format(\"%-20s%-15s%-15s%-10s%-20s%7s \", list.get(i).getFirstName(), list.get(i).getLastName(),\n list.get(i).getGender(), list.get(i).getAge(), list.get(i).getPhoneNo(), list.get(i).getEmail());\n newarray[i]=printarray;\n i++;\n\n }\n for(int j=0; j<newarray.length; j++) {\n System.out.println(newarray[j]);\n\n }\n}", "private final List<State> SAT_EX(String expression) {\r\n // X := SAT (�);\r\n // Y := pre\u0003(X);\r\n // return Y\r\n List<State> x = new ArrayList<State>();\r\n List<State> y = new ArrayList<State>();\r\n x = this.SAT(expression);\r\n y = this.PreE(x);\r\n return y;\r\n }", "private ArrayList<String> normaliseTokens(ArrayList<String> tokens) {\n ArrayList<String> normalisedTokens = new ArrayList<>();\n\n // Normalise to lower case and add\n for (String token : tokens) {\n token = token.toLowerCase();\n normalisedTokens.add(token);\n }\n\n return normalisedTokens;\n }", "public static void main(String[] args) {\n\tDouble totalSalaryExpense = employeeList.stream().map(emp -> emp.getSalary()).reduce(0.00, (a, b) -> a + b);\n\tSystem.out.println(\"Total salary expense: \" + totalSalaryExpense);\n\n\t// Example 2: Using Stream.reduce() method for finding employee with\n\t// maximum salary\n\tOptional<Employee> maxSalaryEmp = employeeList.stream()\n\t\t.reduce((Employee a, Employee b) -> a.getSalary() < b.getSalary() ? b : a);\n\n\tif (maxSalaryEmp.isPresent()) {\n\t System.out.println(\"Employee with max salary: \" + maxSalaryEmp.get());\n\t}\n\n\t// Java 8 code showing Stream.map() method usage\n\tList<String> mappedList = employeeList.stream().map(emp -> emp.getName()).collect(Collectors.toList());\n\tSystem.out.println(\"\\nEmployee Names\");\n\tmappedList.forEach(System.out::println);\n\n\t// Definition & usage of flatMap() method\n\tList<String> nameCharList = employeeList.stream().map(emp -> emp.getName().split(\"\"))\n\t\t.flatMap(array -> Arrays.stream(array)).map(str -> str.toUpperCase()).filter(str -> !(str.equals(\" \")))\n\t\t.collect(Collectors.toList());\n\tnameCharList.forEach(str -> System.out.print(str));\n\n\tStream<String[]> splittedNames = employeeList.stream().map(emp -> emp.getName().split(\"\"));\n\t// splittedNames.forEach(System.out::println);\n\tStream<String> characterStream = splittedNames.flatMap(array -> Arrays.stream(array));\n\tSystem.out.println();\n\t// characterStream.forEach(System.out::print);\n\tStream<String> characterStreamWOSpace = characterStream.filter(str -> !str.equalsIgnoreCase(\" \"));\n\t// characterStreamWOSpace.forEach(System.out::print);\n\n\tList<String> listOfUpperChars = characterStreamWOSpace.map(str -> str.toUpperCase())\n\t\t.collect(Collectors.toList());\n\tlistOfUpperChars.forEach(System.out::print);\n\n }", "private String[] convertToList(List<String> lstAddresses) {\r\n\t\tString[] arrayAddresses = new String[lstAddresses.size()];\r\n\t\tint index=0;\r\n\t\tfor(String strAddress: lstAddresses) {\r\n\t\t\tarrayAddresses[index++] = strAddress;\r\n\t\t}\r\n\t\treturn arrayAddresses;\r\n\t}", "public ArrayList makeStudentList() {\r\n ArrayList<String> studenter = new ArrayList();\r\n Student student = new Student();\r\n \r\n \r\n \r\n return studenter;\r\n}", "public static long getNumberOfAuthorsByGender(List<Book> inputList, Enum<Sex> gender) {\n\t\tSet<Author> set = (Set<Author>)inputList.stream().map(Book::getAuthor).collect(Collectors.toCollection(HashSet::new));\n\t\treturn set.stream().filter(a -> a.getGender() == gender).count();\n\t}", "private ArrayList<String> simpleFormList(ArrayList<String> list){\n\t\tArrayList<String> simpleFormList = new ArrayList<String>();\n\t\tfor(String s : list){\n\t\t\tString pos = posMap.get(s);\n\t\t\tsimpleFormList.add(simpleForm(s,pos));\n\t\t}\n\t\treturn simpleFormList;\n\t}", "private static Employees toSting() {\n\t\treturn null;\n\t}", "private static void format2(String[] l) {\n\t\tString[] listContents = l;\n\t\tArrayList<Person> personList = new ArrayList<Person>();\n\n\t\tfor (int i = 0; i < (listContents.length / 9); i++) {\n\t\t\tPerson person = new Person();\n\n\t\t\tperson.setFirstName(listContents[i * 9]);\n\t\t\tperson.setLastName(listContents[1 + i * 9]);\n\t\t\tperson.setStartDate(listContents[2 + i * 9]);\n\t\t\tperson.setAddress(listContents[3 + i * 9]);\n\t\t\tperson.setAptNum(listContents[4 + i * 9]);\n\t\t\tperson.setCity(listContents[5 + i * 9]);\n\t\t\tperson.setState(listContents[6 + i * 9]);\n\t\t\tperson.setCountry(listContents[7 + i * 9]);\n\t\t\tperson.setZipCode(listContents[8 + i * 9]);\n\n\t\t\tpersonList.add(person);\n\t\t}\n\t\tselectSortingOption(personList);\n\t}", "List<Disease> selectByExample(DiseaseExample example);", "public String listToString(List<Protein> proteins) throws Throwable{\n\n\t\t/* ---------- Make a string to hold the list -------------*/\n\t\t\n\t\tString proteinString = \"\";\n\t\t\n\t\t/* ****************************************************** */\n\t\t\n\t\ttry{\n\n\t\t\t/* ---------- For each protein, add the id and sequence to the string -------------*/\n\t\t\t\n\t\t\tfor(Protein p: proteins){\n\t\t\t\t\n\t\t\t\tproteinString += p.getProteinId() + \".\" + p.getProteinSequence() + \".\";\n\n\t\t\t}\n\t\t\t\n\t\t\t/* ******************************************************************************* */\n\t\t\t\n\t\t}catch(Throwable t){\n\n\t\t\t/* --------- If anything goes wrong, set the passfail param to FAIL -------------*/\n\t\t\t\n\t\t\tlog.error(\"Failed to build string.\", t);\n\t\t\tMain.passfail = Main.FAIL;\n\t\t\t\n\t\t\t/* ***************************************************************************** */\n\t\t}\n\t\tif(log.isDebugEnabled()){ log.debug(\"String has been built.\"); }\n\t\t\n\t\t/* ---------- Finally return the string -------------*/\n\t\t\n\t\treturn proteinString;\n\t\t\n\t\t/* ************************************************* */\n\t}", "private static ArrayList<String> makeStatesArray(BigramModel transProb, ArrayList<String> states) {\n\t\tSet set = transProb.unigramMap.keySet();\n\t\tstates = new ArrayList<String>();\n\t\tIterator itr = set.iterator();\n\t\twhile (itr.hasNext()) {\n\t\t\tString status = (String) itr.next();\n\t\t\tstates.add(status);\n\t\t}\n\t\treturn states;\n\t}" ]
[ "0.5992819", "0.54403406", "0.51233196", "0.5113451", "0.4935835", "0.4843286", "0.48238158", "0.48205388", "0.45339963", "0.44945535", "0.44167656", "0.44030938", "0.44026592", "0.43988362", "0.43979225", "0.4387075", "0.43863174", "0.437267", "0.437267", "0.43655977", "0.43512562", "0.43386504", "0.43386504", "0.43386504", "0.43386504", "0.43386504", "0.43386504", "0.43386504", "0.43386504", "0.43134484", "0.43081743", "0.42955476", "0.42714697", "0.42426497", "0.42425945", "0.4237988", "0.42298773", "0.4225902", "0.4223607", "0.42200264", "0.42198762", "0.42157513", "0.42123726", "0.42087016", "0.4200891", "0.42006817", "0.41971985", "0.41948938", "0.4188709", "0.4188596", "0.41863048", "0.41852096", "0.41755086", "0.41616356", "0.41583362", "0.41557172", "0.4148366", "0.41471052", "0.41448018", "0.41359937", "0.41306734", "0.41263866", "0.41263866", "0.41263866", "0.41263866", "0.41263866", "0.4122301", "0.41198087", "0.41156703", "0.41156468", "0.41021502", "0.40998182", "0.4094989", "0.40906402", "0.40903592", "0.40903068", "0.40867585", "0.40811223", "0.40774035", "0.40739104", "0.40739104", "0.40637377", "0.4057051", "0.40496838", "0.40496203", "0.40460393", "0.40430215", "0.40195167", "0.4016763", "0.4014892", "0.40135452", "0.40130675", "0.4012717", "0.40082443", "0.4003038", "0.39981413", "0.3996102", "0.39948696", "0.39938554", "0.39884454" ]
0.6527307
0
Creates an instance of FileMenu.
public FileMenu(ChatWindow parentWindow) { super(Messages.getI18NString("file").getText()); this.parentWindow = parentWindow; this.setForeground(new Color( ColorProperties.getColor("chatMenuForeground"))); this.add(saveMenuItem); this.add(printMenuItem); this.addSeparator(); this.add(closeMenuItem); this.saveMenuItem.setName("save"); this.printMenuItem.setName("print"); this.closeMenuItem.setName("close"); this.saveMenuItem.addActionListener(this); this.printMenuItem.addActionListener(this); this.closeMenuItem.addActionListener(this); this.setMnemonic(Messages.getI18NString("file").getMnemonic()); this.saveMenuItem.setMnemonic(saveString.getMnemonic()); this.printMenuItem.setMnemonic(printString.getMnemonic()); this.closeMenuItem.setMnemonic(closeString.getMnemonic()); this.saveMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK)); this.printMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.CTRL_MASK)); // Disable all menu items that do nothing. this.saveMenuItem.setEnabled(false); this.printMenuItem.setEnabled(false); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public Menu createFileMenu();", "private JMenu createFileMenu() {\r\n\t\tJMenu fileMenu = new JMenu(\"File\");\r\n\t\tfileMenu.setMnemonic('f');\r\n\t\tfileMenu.add(createSaveHistoryMenuItem());\r\n\t\tfileMenu.add(createLoadHistoryMenuItem());\r\n\r\n\t\treturn fileMenu;\r\n\t}", "public JMenu createFileMenu(){\n\t\tJMenu menu = new JMenu(\"File\");\n\t\tmenu.add(createFileResetItem());\n\t\tmenu.add(createFilePracticeItem());\t\t\n\t\tmenu.add(createFileExitItem());\n\t\treturn menu;\n\t}", "private JMenu createFileMenu() {\n\t\tJMenu menu = new JMenu(\"File\"); \n\t\tmenu.add(createDetectiveNotes());\n\t\tmenu.add(createFileExitItem());\n\t\treturn menu;\n\t}", "private JMenu createFileMenu()\r\n {\r\n JMenu fileMenu = new JMenu(\"File\");\r\n fileMenu.add(new JMenuItem(openFileAction));\r\n fileMenu.add(new JMenuItem(openUriAction));\r\n fileMenu.add(new JSeparator());\r\n\r\n fileMenu.add(recentUrisMenu.getMenu());\r\n fileMenu.add(new JSeparator());\r\n\r\n fileMenu.add(new JMenuItem(importObjFileAction));\r\n fileMenu.add(new JSeparator());\r\n \r\n fileMenu.add(new JMenuItem(saveAsAction));\r\n fileMenu.add(new JMenuItem(saveAsBinaryAction));\r\n fileMenu.add(new JMenuItem(saveAsEmbeddedAction));\r\n fileMenu.add(new JSeparator());\r\n fileMenu.add(new JMenuItem(exitAction));\r\n return fileMenu;\r\n }", "private JMenu getFileMenu() {\n\t\tif (fileMenu == null) {\n\t\t\tfileMenu = new JMenu();\n\t\t\tfileMenu.setText(\"File\");\n\t\t\tfileMenu.add(getExitMenuItem());\n\t\t}\n\t\treturn fileMenu;\n\t}", "private JMenu getFileMenu() {\n if (fileMenu == null) {\n fileMenu = new JMenu();\n fileMenu.setText(\"File\");\n fileMenu.add(getExitMenuItem());\n }\n return fileMenu;\n }", "private void buildFileMenu(){\n //Create a Save menu item\n saveItem = new JMenuItem(\"Save\");\n saveItem.setMnemonic(KeyEvent.VK_S);\n saveItem.addActionListener(new SaveListener());\n \n //Create a Load menu item\n loadItem = new JMenuItem(\"Load\");\n loadItem.setMnemonic(KeyEvent.VK_L);\n loadItem.addActionListener(new LoadListener());\n\n //Create an Exit menu item\n exitItem = new JMenuItem(\"Exit\");\n exitItem.setMnemonic(KeyEvent.VK_X);\n exitItem.addActionListener(new ExitListener());\n \n //Create a JMenu object for the file menu\n fileMenu = new JMenu(\"File\");\n fileMenu.setMnemonic(KeyEvent.VK_F);\n \n //Add the items to the menu\n fileMenu.add(saveItem);\n fileMenu.add(loadItem);\n fileMenu.add(exitItem);\n }", "protected void initializeFileMenu() {\n\t\tfinal JMenu fileMenu = new JMenu(\"File\");\n\t\tthis.add(fileMenu);\n\t\t// Status\n\t\tfinal JMenuItem sysStatusItem = new JMenuItem();\n\t\tsysStatusItem.setAction(this.commands.findById(CmdStatus.DEFAULT_ID));\n\t\tsysStatusItem.setAccelerator(KeyStroke.getKeyStroke('S',\n\t\t\t\tInputEvent.CTRL_DOWN_MASK));\n\t\tfileMenu.add(sysStatusItem);\n\t\t// Log\n\t\tfinal JMenuItem sysLogItem = new JMenuItem();\n\t\tsysLogItem.setAction(this.commands.findById(CmdLog.DEFAULT_ID));\n\t\tsysLogItem.setAccelerator(KeyStroke.getKeyStroke('L',\n\t\t\t\tInputEvent.CTRL_DOWN_MASK));\n\t\tfileMenu.add(sysLogItem);\n\t\t// Separator\n\t\tfileMenu.add(new JSeparator());\n\t\t// Exit\n\t\tfinal JMenuItem exitItem = new JMenuItem(\"Exit\");\n\t\texitItem.setAction(this.commands.findById(CmdExit.DEFAULT_ID));\n\t\texitItem.setAccelerator(KeyStroke.getKeyStroke('Q',\n\t\t\t\tInputEvent.CTRL_DOWN_MASK));\n\t\tfileMenu.add(exitItem);\n\t}", "private void setUpMenuBar_FileMenu(){\r\n\t\t// Add the file menu.\r\n\t\tthis.fileMenu = new JMenu(STR_FILE);\r\n\t\tthis.openMenuItem = new JMenuItem(STR_OPEN);\r\n\t\tthis.openMenuItem2 = new JMenuItem(STR_OPEN2);\r\n\t\tthis.resetMenuItem = new JMenuItem(STR_RESET);\r\n\t\tthis.saveMenuItem = new JMenuItem(STR_SAVE);\r\n\t\tthis.saveAsMenuItem = new JMenuItem(STR_SAVEAS);\r\n\t\tthis.exitMenuItem = new JMenuItem(STR_EXIT);\r\n\t\t\r\n\t\t// Add the action listeners for the file menu.\r\n\t\tthis.openMenuItem.addActionListener(this);\r\n\t\tthis.openMenuItem2.addActionListener(this);\r\n\t\tthis.resetMenuItem.addActionListener(this);\r\n\t\tthis.saveMenuItem.addActionListener(this);\r\n\t\tthis.saveAsMenuItem.addActionListener(this);\r\n\t\tthis.exitMenuItem.addActionListener(this);\r\n\t\t\r\n\t\t// Add the menu items to the file menu.\r\n\t\tthis.fileMenu.add(openMenuItem);\r\n\t\tthis.fileMenu.add(openMenuItem2);\r\n\t\tthis.fileMenu.add(resetMenuItem);\r\n\t\tthis.fileMenu.addSeparator();\r\n\t\tthis.fileMenu.add(saveMenuItem);\r\n\t\tthis.fileMenu.add(saveAsMenuItem);\r\n\t\tthis.fileMenu.addSeparator();\r\n\t\tthis.fileMenu.add(exitMenuItem);\r\n\t\tthis.menuBar.add(fileMenu);\r\n\t}", "private JMenu getFileMenu() {\n\t\tif (fileMenu == null) {\n\t\t\tfileMenu = new JMenu();\n\t\t\tfileMenu.setText(\"Súbor\");\n\t\t\t//fileMenu.add(getSaveMenuItem());\n\t\t\tfileMenu.add(getExitMenuItem());\n\t\t\tfileMenu.addActionListener(new java.awt.event.ActionListener() {\n\t\t\t\tpublic void actionPerformed(java.awt.event.ActionEvent e) {\n\t\t\t\t\tSystem.out.println(\"actionPerformed()\"); // TODO Auto-generated Event stub actionPerformed()\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\treturn fileMenu;\n\t}", "public void setUpFileMenu() {\n add(fileMenu);\n fileMenu.add(new OpenAction(parent));\n fileMenu.add(new SaveAction(parent));\n fileMenu.add(new SaveAsAction(parent));\n fileMenu.addSeparator();\n fileMenu.add(new ShowWorldPrefsAction(parent.getWorldPanel()));\n fileMenu.add(new CloseAction(parent.getWorkspaceComponent()));\n }", "private JMenu getJMenuFile() {\r\n if (jMenuFile == null) {\r\n jMenuFile = new JMenu();\r\n jMenuFile.setMnemonic(KeyEvent.VK_F);\r\n jMenuFile.setText(\"File\");\r\n jMenuFile.add(getJMenuItemImport());\r\n jMenuFile.add(getJMenuItemExport());\r\n }\r\n return jMenuFile;\r\n }", "private void createMenu() {\n\t\tJMenuBar mb = new JMenuBar();\n\t\tsetJMenuBar(mb);\n\t\tmb.setVisible(true);\n\t\t\n\t\tJMenu menu = new JMenu(\"File\");\n\t\tmb.add(menu);\n\t\t//mb.getComponent();\n\t\tmenu.add(new JMenuItem(\"Exit\"));\n\t\t\n\t\t\n\t}", "private void createMenu()\n\t{\n\t\tfileMenu = new JMenu(\"File\");\n\t\thelpMenu = new JMenu(\"Help\");\n\t\ttoolsMenu = new JMenu(\"Tools\");\n\t\t\n\t\tmenuBar = new JMenuBar();\n\t\t\n\t\texit = new JMenuItem(\"Exit\");\t\t\n\t\treadme = new JMenuItem(\"Readme\");\n\t\tabout = new JMenuItem(\"About\");\n\t\tsettings = new JMenuItem(\"Settings\");\n\t\t\t\t\n\t\tfileMenu.add (exit);\n\t\t\n\t\thelpMenu.add (readme);\n\t\thelpMenu.add (about);\t\n\t\t\n\t\ttoolsMenu.add (settings);\n\t\t\n\t\tmenuBar.add(fileMenu);\n\t\tmenuBar.add(toolsMenu);\n\t\tmenuBar.add(helpMenu);\t\t\n\t\t\t\t\n\t\tdefaultMenuBackground = menuBar.getBackground();\n\t\tdefaultMenuForeground = fileMenu.getForeground();\n\t\t\n\t}", "private void createMenus() {\n\t\tJMenuBar menuBar = new JMenuBar();\n\n\t\tfileMenu = new JMenu(flp.getString(\"file\"));\n\t\tmenuBar.add(fileMenu);\n\n\t\tfileMenu.add(new JMenuItem(new ActionNewDocument(flp, this)));\n\t\tfileMenu.add(new JMenuItem(new ActionOpen(flp, this)));\n\t\tfileMenu.add(new JMenuItem(new ActionSave(flp, this)));\n\t\tfileMenu.add(new JMenuItem(new ActionSaveAs(flp, this)));\n\t\tfileMenu.addSeparator();\n\t\tfileMenu.add(new JMenuItem(new ActionExit(flp, this)));\n\t\tfileMenu.add(new JMenuItem(new ActionStatistics(flp, this)));\n\n\t\teditMenu = new JMenu(flp.getString(\"edit\"));\n\n\t\teditMenu.add(new JMenuItem(new ActionCut(flp, this)));\n\t\teditMenu.add(new JMenuItem(new ActionCopy(flp, this)));\n\t\teditMenu.add(new JMenuItem(new ActionPaste(flp, this)));\n\n\t\ttoolsMenu = new JMenu(flp.getString(\"tools\"));\n\n\t\titemInvert = new JMenuItem(new ActionInvertCase(flp, this));\n\t\titemInvert.setEnabled(false);\n\t\ttoolsMenu.add(itemInvert);\n\n\t\titemLower = new JMenuItem(new ActionLowerCase(flp, this));\n\t\titemLower.setEnabled(false);\n\t\ttoolsMenu.add(itemLower);\n\n\t\titemUpper = new JMenuItem(new ActionUpperCase(flp, this));\n\t\titemUpper.setEnabled(false);\n\t\ttoolsMenu.add(itemUpper);\n\n\t\tsortMenu = new JMenu(flp.getString(\"sort\"));\n\t\tsortMenu.add(new JMenuItem(new ActionSortAscending(flp, this)));\n\t\tsortMenu.add(new JMenuItem(new ActionSortDescending(flp, this)));\n\n\t\tmenuBar.add(editMenu);\n\t\tmenuBar.add(createLanguageMenu());\n\t\tmenuBar.add(toolsMenu);\n\t\tmenuBar.add(sortMenu);\n\n\t\tthis.setJMenuBar(menuBar);\n\t}", "private MenuManager createFileMenu(\tIWorkbenchWindow window) {\n\t\tMenuManager menu = new MenuManager(Messages.getString(\"IU.Strings.39\"),IWorkbenchActionConstants.M_FILE); //$NON-NLS-1$\n\t\t\n\n\t\tmenu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START));\n\n\t\tIContributionItem[] items=menu.getItems();\n\t\tmenu.add(new GroupMarker(IWorkbenchActionConstants.NEW_EXT));\n\t\t/**/\n\t\t/**/\n\t\tmenu.add(getAction(ActionFactory.CLOSE.getId()));\n\t\tmenu.add(new GroupMarker(IWorkbenchActionConstants.CLOSE_EXT));\n\n\t\tmenu.add(new Separator());\n\n\t\tmenu.add(getAction(ActionFactory.SAVE.getId()));\n\t\tmenu.add(getAction(ActionFactory.SAVE_AS.getId()));\n\t\t//menu.add(getAction(ActionFactory.REVERT.getId()));\n\t\tmenu.add(new Separator());\n\t\tmenu.add(getAction(ActionFactory.PRINT.getId()));\n\t\t\n\t\tmenu.add(ContributionItemFactory.REOPEN_EDITORS.create(window));\n\n\t\tmenu.add(new Separator());\n\n\t\tmenu.add(getAction(ActionFactory.QUIT.getId()));\n\t\tmenu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END));\n\n\t\t\n\t\t//remove convert line delimiter and open file doublon\n\t\tActionSetRegistry reg = WorkbenchPlugin.getDefault().getActionSetRegistry();\n\t\tIActionSetDescriptor[] actionSets = reg.getActionSets();\n\t\t//String actionSetId = \"org.eclipse.ui.edit.text.actionSet.navigation\"; //$NON-NLS-1$\n\t\tString actionSetId = \"org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo\"; //$NON-NLS-1$\n\t\tString actionSetId2 = \"org.eclipse.ui.actionSet.openFiles\"; //$NON-NLS-1$\n\t\t// Removing convert line delimiters menu.\n\n\t\tfor (int i = 0; i <actionSets.length; i++)\n\t\t{\n\t\t\tif ((!actionSets[i].getId().equals(actionSetId)) && (!actionSets[i].getId().equals(actionSetId2)))\n\t\t\t\tcontinue;\n\t\t\tIExtension ext = actionSets[i].getConfigurationElement()\n\t\t\t\t.getDeclaringExtension();\n\t\t\treg.removeExtension(ext, new Object[] { actionSets[i] });\n\t\t}\n\t\treturn menu;\n\t}", "private static JMenuBar createMenu() {\r\n JMenuBar mb = new JMenuBar();\r\n JMenu menu = new JMenu(\"File\");\r\n JMenuItem item = new JMenuItem(\"Save\");\r\n item.addActionListener((ActionEvent evt) -> {\r\n saveActionPerformed();\r\n });\r\n menu.add(item);\r\n mb.add(menu);\r\n\r\n menu = new JMenu(\"Help\");\r\n item = new JMenuItem(\"Show how-to\");\r\n item.addActionListener((ActionEvent evt) -> {\r\n showHelp();\r\n });\r\n menu.add(item);\r\n\r\n mb.add(menu);\r\n\r\n return mb;\r\n }", "public Menu() {\n\n\t\t//Build the file menu.\n\t\tfileMenu = new JMenu(\"File\");\n\t\tadd(fileMenu);\n\n\t\t//Create a group of JMenuItems\n\t\tnewProj = new JMenuItem(\"New project\");\n\t\tfileMenu.add(newProj);\n\t\topenProj = new JMenuItem(\"Open project\", new ImageIcon(\"images/middle.gif\"));\n\t\tfileMenu.add(openProj);\n\n\t\t//Create a submenu in the file menu\n\t\tfileMenu.addSeparator();\n\t\tsubmenu = new JMenu(\"Import media\");\n\t\tfromURL = new JMenuItem(\"Download from URL\");\n\t\tsubmenu.add(fromURL);\n\t\tfromFolder = new JMenuItem(\"Import from computer\");\n\t\tsubmenu.add(fromFolder);\n\t\tsubmenu.setEnabled(false);\n\t\tfileMenu.add(submenu);\n\t\texport = new JMenuItem(\"Export video\");\n\t\texport.setEnabled(false);\n\t\tfileMenu.add(export);\n\n\t\t//Create Exit JMenuItem\n\t\tfileMenu.addSeparator();\n\t\texit = new JMenuItem(\"Exit\");\n\t\tfileMenu.add(exit);\n\t\tadd(fileMenu);\n\n\t\t//Build second menu in the menu bar.\n\t\thelpMenu = new JMenu(\"Help\");\n\t\thelp = new JMenuItem(\"Help & Tips\");\n\t\thelpMenu.add(help);\n\t\tadd(helpMenu);\n\t\t\n\t\t//Add action listeners\n\t\tnewProj.addActionListener(this);\n\t\topenProj.addActionListener(this);\n\t\tfromURL.addActionListener(this);\n\t\tfromFolder.addActionListener(this);\n\t\texport.addActionListener(this);\n\t\texit.addActionListener(this);\n\t\thelp.addActionListener(this);\n\n\t}", "private void makeMenu() {\r\n int i = 0;\r\n int j = 0;\r\n final JMenuBar bar = new JMenuBar();\r\n final Action[] menuActions = {new NewItemAction(MENU_ITEM_STRINGS[i++]),\r\n new ExitAction(MENU_ITEM_STRINGS[i++], myFrame),\r\n new AboutAction(MENU_ITEM_STRINGS[i++], myFrame)};\r\n i = 0;\r\n\r\n final JMenu fileMenu = new JMenu(MENU_STRINGS[j++]);\r\n fileMenu.setMnemonic(KeyEvent.VK_F);\r\n fileMenu.add(menuActions[i++]);\r\n fileMenu.addSeparator();\r\n fileMenu.add(menuActions[i++]);\r\n\r\n final JMenu optionsMenu = new JMenu(MENU_STRINGS[j++]);\r\n optionsMenu.setMnemonic(KeyEvent.VK_O);\r\n\r\n final JMenu helpMenu = new JMenu(MENU_STRINGS[j++]);\r\n helpMenu.setMnemonic(KeyEvent.VK_H);\r\n helpMenu.add(menuActions[i++]);\r\n\r\n bar.add(fileMenu);\r\n bar.add(optionsMenu);\r\n bar.add(helpMenu);\r\n\r\n myFrame.setJMenuBar(bar);\r\n }", "public JMenu getFileMenu() {\n return fileMenu;\n }", "private void createMenuBar() {\n\t\tmenuBar = new JMenuBar();\n\n\t\tfileMenu = new JMenu(\"Arquivo\");\n\t\tnewMenuItem = new JMenuItem(\"Novo\");\n\n\t\topenMenuItem = new JMenuItem(\"Abrir arquivo\");\n\t\topenMenuItem.addActionListener(new OpenFileHandler());\n\n\t\tsaveMenuItem = new JMenuItem(\"Salvar arquivo\");\n\t\texportMenuItem = new JMenuItem(\"Exportar\");\n\t\texitMenuItem = new JMenuItem(\"Sair\");\n\n\t\t// fileMenu.add(newMenuItem);\n\t\tfileMenu.add(openMenuItem);\n\t\t// fileMenu.add(saveMenuItem);\n\t\t// fileMenu.add(exportMenuItem);\n\t\t// fileMenu.addSeparator();\n\t\t// fileMenu.add(exitMenuItem);\n\n\t\thelpMenu = new JMenu(\"Ajuda\");\n\t\thelpMenuItem = new JMenuItem(\"Ajuda\");\n\t\taboutMenuItem = new JMenuItem(\"Sobre\");\n\n\t\thelpMenu.add(helpMenuItem);\n\t\thelpMenu.add(aboutMenuItem);\n\n\t\tmenuBar.add(fileMenu);\n\t\tmenuBar.add(helpMenu);\n\n\t\tthis.setJMenuBar(menuBar);\n\t}", "public JMTMenuBar createMenu() {\r\n \t\tJMTMenuBar menu = new JMTMenuBar(JMTImageLoader.getImageLoader());\r\n \t\t// File menu\r\n \t\tMenuAction action = new MenuAction(\"File\", new AbstractJmodelAction[] { newModel, openModel, saveModel, saveModelAs, closeModel, null, exit });\r\n \t\tmenu.addMenu(action);\r\n \r\n \t\t// Edit menu\r\n \t\taction = new MenuAction(\"Edit\", new AbstractJmodelAction[] {\r\n \t\t// editUndo, editRedo, null\r\n \t\t\t\tactionCut, actionCopy, actionPaste, actionDelete, null, takeScreenShot });\r\n \t\tmenu.addMenu(action);\r\n \r\n \t\t// Define menu\r\n \t\taction = new MenuAction(\"Define\",\r\n \t\t\t\tnew AbstractJmodelAction[] { editUserClasses, editMeasures, editSimParams, editPAParams, null, editDefaults });\r\n \t\tmenu.addMenu(action);\r\n \r\n \t\t// Solve menu\r\n \t\taction = new MenuAction(\"Solve\", new AbstractJmodelAction[] { simulate, pauseSimulation, stopSimulation, null, switchToExactSolver, null,\r\n \t\t\t\tshowResults });\r\n \t\tmenu.addMenu(action);\r\n \r\n \t\t// Help menu\r\n \t\taction = new MenuAction(\"Help\", new AbstractJmodelAction[] { openHelp, null, about });\r\n \t\tmenu.addMenu(action);\r\n \r\n \t\treturn menu;\r\n \t}", "private JMenu getMnuFile() {\r\n\t\tif (mnuFile == null) {\r\n\t\t\tmnuFile = new JMenu();\r\n\t\t\tmnuFile.setText(\"File\");\r\n\t\t\tmnuFile.add(getMniOpen());\r\n\t\t\tmnuFile.add(getSepFile1());\r\n\t\t\tmnuFile.add(getMniExit());\r\n\t\t}\r\n\t\treturn mnuFile;\r\n\t}", "private void createMenus() {\r\n\t\tJMenuBar menuBar = new JMenuBar();\r\n\t\t\r\n\t\tJMenu fileMenu = new LJMenu(\"file\", flp);\r\n\t\tmenuBar.add(fileMenu);\r\n\t\t\r\n\t\tfileMenu.add(new JMenuItem(createBlankDocument));\r\n\t\tfileMenu.add(new JMenuItem(openDocumentAction));\r\n\t\tfileMenu.add(new JMenuItem(saveDocumentAction));\r\n\t\tfileMenu.add(new JMenuItem(saveDocumentAsAction));\r\n\t\tfileMenu.add(new JMenuItem(closeCurrentTabAction));\r\n\t\tfileMenu.addSeparator();\r\n\t\tfileMenu.add(new JMenuItem(getStatsAction));\r\n\t\tfileMenu.addSeparator();\r\n\t\tfileMenu.add(new JMenuItem(exitAction));\r\n\t\t\r\n\t\tJMenu editMenu = new LJMenu(\"edit\", flp);\r\n\t\tmenuBar.add(editMenu);\r\n\t\t\r\n\t\teditMenu.add(new JMenuItem(copyAction));\r\n\t\teditMenu.add(new JMenuItem(pasteAction));\r\n\t\teditMenu.add(new JMenuItem(cutAction));\r\n\t\t\r\n\t\tJMenu langMenu = new LJMenu(\"lang\", flp);\r\n\t\tJMenuItem hr = new LJMenuItem(\"cro\", flp);\r\n\t\thr.addActionListener((l) -> { \r\n\t\t\tLocalizationProvider.getInstance().setLanguage(\"hr\");\r\n\t\t\tcurrentLang = \"hr\";\r\n\t\t});\r\n\t\t\r\n\t\tlangMenu.add(hr);\r\n\t\tJMenuItem en = new LJMenuItem(\"eng\", flp);\r\n\t\ten.addActionListener((l) -> { \r\n\t\t\t LocalizationProvider.getInstance().setLanguage(\"en\");\r\n\t\t\t currentLang = \"en\";\r\n\t\t});\r\n\t\tlangMenu.add(en);\r\n\t\tJMenuItem de = new LJMenuItem(\"de\", flp);\r\n\t\tde.addActionListener((l) -> { \r\n\t\t\t LocalizationProvider.getInstance().setLanguage(\"de\");\r\n\t\t\t currentLang = \"de\";\r\n\t\t});\r\n\t\tlangMenu.add(de);\r\n\t\tmenuBar.add(langMenu);\r\n\t\t\r\n\t\tJMenu toolsMenu = new LJMenu(\"tools\", flp);\r\n\t\tJMenuItem toUp = new JMenuItem(toUpperCaseAction);\r\n\t\ttoolsMenu.add(toUp);\r\n\t\ttoggable.add(toUp);\r\n\t\ttoUp.setEnabled(false);\r\n\t\tJMenuItem toLow = new JMenuItem(toLowerCaseAction);\r\n\t\ttoolsMenu.add(toLow);\r\n\t\ttoggable.add(toLow);\r\n\t\ttoLow.setEnabled(false);\r\n\t\tJMenuItem inv = new JMenuItem(invertSelected);\r\n\t\ttoolsMenu.add(inv);\r\n\t\ttoggable.add(inv);\r\n\t\tinv.setEnabled(false);\r\n\t\tmenuBar.add(toolsMenu);\r\n\t\t\r\n\t\tJMenu sort = new LJMenu(\"sort\", flp);\r\n\t\tJMenuItem sortAsc = new JMenuItem(sortAscAction);\r\n\t\tsort.add(sortAsc);\r\n\t\ttoggable.add(sortAsc);\r\n\t\tJMenuItem sortDesc = new JMenuItem(sortDescAction);\r\n\t\tsort.add(sortDesc);\r\n\t\ttoggable.add(sortDesc);\r\n\t\tJMenuItem uniq = new JMenuItem(uniqueLinesAction);\r\n\t\ttoolsMenu.add(uniq);\r\n\t\ttoggable.add(uniq);\r\n\t\t\r\n\t\ttoolsMenu.add(sort);\r\n\t\tsetJMenuBar(menuBar);\r\n\r\n\t}", "Menu getMenuFile();", "private void initMenuBar() {\r\n\t\t// file menu\r\n\t\tJMenu fileMenu = new JMenu(\"File\");\r\n\t\tfileMenu.setMnemonic(KeyEvent.VK_F);\r\n\t\tadd(fileMenu);\r\n\r\n\t\tJMenuItem fileNewMenuItem = new JMenuItem(new NewAction(parent, main));\r\n\t\tfileNewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,\r\n\t\t\t\tEvent.CTRL_MASK));\r\n\t\tfileMenu.add(fileNewMenuItem);\r\n\t\tJMenuItem fileOpenMenuItem = new JMenuItem(new OpenAction(parent, main));\r\n\t\tfileOpenMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,\r\n\t\t\t\tEvent.CTRL_MASK));\r\n\t\tfileMenu.add(fileOpenMenuItem);\r\n\r\n\t\tJMenuItem fileSaveMenuItem = new JMenuItem(new SaveAction(main));\r\n\t\tfileSaveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,\r\n\t\t\t\tEvent.CTRL_MASK));\r\n\t\tfileMenu.add(fileSaveMenuItem);\r\n\t\tJMenuItem fileSaveAsMenuItem = new JMenuItem(new SaveAsAction(main));\r\n\t\tfileSaveAsMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,\r\n\t\t\t\tEvent.CTRL_MASK));\r\n\t\tfileMenu.add(fileSaveAsMenuItem);\r\n\r\n\t\tfileMenu.addSeparator();\r\n\t\tfileMenu.add(recentMenu);\r\n\t\tfileMenu.addSeparator();\r\n\r\n\t\tJMenuItem exitMenuItem = new JMenuItem(new ExitAction(main));\r\n\t\texitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,\r\n\t\t\t\tEvent.CTRL_MASK));\r\n\t\tfileMenu.add(exitMenuItem);\r\n\r\n\t\t// tools menu\r\n\t\tJMenu toolsMenu = new JMenu(\"Application\");\r\n\t\ttoolsMenu.setMnemonic(KeyEvent.VK_A);\r\n\t\tadd(toolsMenu);\r\n\r\n\t\tJMenuItem defineCategoryMenuItem = new JMenuItem(\r\n\t\t\t\tnew DefineCategoryAction());\r\n\t\tdefineCategoryMenuItem.setAccelerator(KeyStroke.getKeyStroke(\r\n\t\t\t\tKeyEvent.VK_C, Event.CTRL_MASK));\r\n\t\ttoolsMenu.add(defineCategoryMenuItem);\r\n\t\tJMenuItem defineBehaviorNetworkMenuItem = new JMenuItem(\r\n\t\t\t\tnew DefineBehaviorNetworkAction());\r\n\t\tdefineBehaviorNetworkMenuItem.setAccelerator(KeyStroke.getKeyStroke(\r\n\t\t\t\tKeyEvent.VK_B, Event.CTRL_MASK));\r\n\t\ttoolsMenu.add(defineBehaviorNetworkMenuItem);\r\n\t\tJMenuItem startSimulationMenuItem = new JMenuItem(\r\n\t\t\t\tnew StartSimulationAction(main));\r\n\t\tstartSimulationMenuItem.setAccelerator(KeyStroke.getKeyStroke(\r\n\t\t\t\tKeyEvent.VK_E, Event.CTRL_MASK));\r\n\t\ttoolsMenu.add(startSimulationMenuItem);\r\n\r\n\t\t// help menu\r\n\t\tJMenu helpMenu = new JMenu(\"Help\");\r\n\t\thelpMenu.setMnemonic(KeyEvent.VK_H);\r\n\t\tadd(helpMenu);\r\n\r\n\t\tJMenuItem helpMenuItem = new JMenuItem(new HelpAction(parent));\r\n\t\thelpMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H,\r\n\t\t\t\tEvent.CTRL_MASK));\r\n\t\thelpMenu.add(helpMenuItem);\r\n\r\n\t\t// JCheckBoxMenuItem clock = new JCheckBoxMenuItem(new\r\n\t\t// ScheduleSaveAction(parent));\r\n\t\t// helpMenu.add(clock);\r\n\t\thelpMenu.addSeparator();\r\n\t\tJMenuItem showMemItem = new JMenuItem(new ShowMemAction(parent));\r\n\t\thelpMenu.add(showMemItem);\r\n\r\n\t\tJMenuItem aboutMenuItem = new JMenuItem(new AboutAction(parent));\r\n\t\thelpMenu.add(aboutMenuItem);\r\n\t}", "private JMenu fileMenu(final DrawingPanel thePanel) {\r\n myTrue = false;\r\n \r\n final JMenu fileMenu = new JMenu(\"File\");\r\n fileMenu.setMnemonic(KeyEvent.VK_F); \r\n \r\n \r\n \r\n final JMenuItem fileClear = new JMenuItem(\"Clear\");\r\n fileClear.setMnemonic(KeyEvent.VK_C);\r\n fileClear.setEnabled(thePanel.isThereShapes());\r\n \r\n fileMenu.addChangeListener((theEvent) -> {\r\n myTrue = thePanel.isThereShapes();\r\n fileClear.setEnabled(myTrue);\r\n });\r\n \r\n fileClear.addActionListener((theEvent) -> {\r\n if (fileClear.isEnabled()) {\r\n thePanel.clearShapes();\r\n thePanel.isClear();\r\n }\r\n });\r\n \r\n fileMenu.add(fileClear);\r\n fileMenu.addSeparator();\r\n final JMenuItem fileQuit = new JMenuItem(\"Quit\");\r\n fileQuit.setMnemonic(KeyEvent.VK_Q);\r\n fileQuit.addActionListener((theEvent) -> {\r\n System.exit(0);\r\n });\r\n fileMenu.add(fileQuit);\r\n \r\n return fileMenu;\r\n }", "public void generateMenu(){\n menuBar = new JMenuBar();\n\n JMenu file = new JMenu(\"Datei\");\n JMenu tools = new JMenu(\"Werkzeuge\");\n JMenu help = new JMenu(\"Hilfe\");\n\n JMenuItem open = new JMenuItem(\"Öffnen \");\n JMenuItem save = new JMenuItem(\"Speichern \");\n JMenuItem exit = new JMenuItem(\"Beenden \");\n JMenuItem preferences = new JMenuItem(\"Einstellungen \");\n JMenuItem about = new JMenuItem(\"Über das Projekt \");\n\n\n file.add(open);\n file.add(save);\n file.addSeparator();\n file.add(exit);\n tools.add(preferences);\n help.add(about);\n\n menuBar.add(file);\n menuBar.add(tools);\n menuBar.add(help);\n }", "public FileMenu(final CalcMenuBar menuBar){\n\t\tsetText(\"File\");\n\t\tsetBackground(Color.gray);\n\t\tthis.menuBar = menuBar;\n\t\t//init items\n\t\tmiOpen = new JMenuItem(\"Open\");\n\t\tmiOpen.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\topenPressed();\n\t\t\t}\n\t\t});\n\t\tadd(miOpen);\n\t\tmiSave = new JMenuItem(\"Save\");\n\t\tmiSave.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tsavePressed();\n\t\t\t}\n\t\t});\n\t\tadd(miSave);\n\t\tmiClearFormulas = new JMenuItem(\"Clear Functions\");\n\t\tmiClearFormulas.setToolTipText(\"Erases all User Functions\");\n\t\tmiClearFormulas.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent arg0) {\n\t\t\t\tif(JOptionPane.showConfirmDialog(null, \"Are you sure you want to erase all user created functions?\", \"Are you sure?\", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION){\n\t\t\t\t\tSystem.out.println(\"Removing Functions\");\n\t\t\t\t\tUserFunction.getFunctions().clear();\n\t\t\t\t\tSystem.out.println(UserFunction.getFunctions());\n\t\t\t\t\tmenuBar.updateFunctions();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t});\n\t\tadd(miClearFormulas);\n\t\tmiClearMem = new JMenuItem(\"Clear Variables\");\n\t\tmiClearMem.setToolTipText(\"Erases all User craeted variables\");\n\t\tmiClearMem.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent arg0) {\n\t\t\t\tif(JOptionPane.showConfirmDialog(null, \"Are you sure you want to erase all user created variables?\", \"Are you sure?\", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION){\n\t\t\t\t\tSystem.out.println(\"Removing Variables\");\n\t\t\t\t\tVariable.getVariables().clear();\n\t\t\t\t\tmenuBar.updateFunctions();\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t});\n\t\tadd(miClearMem);\n\t\t\n\t}", "public MenuBar(TrcAttendance parent)\n {\n this.parent = parent;\n\n fileMenu.setFont(parent.smallFont);\n fileNewItem.setFont(parent.smallFont);\n fileOpenItem.setFont(parent.smallFont);\n fileEditItem.setFont(parent.smallFont);\n fileCloseItem.setFont(parent.smallFont);\n fileAboutItem.setFont(parent.smallFont);\n fileExitItem.setFont(parent.smallFont);\n\n fileMenu.setMnemonic(KeyEvent.VK_F);\n menuBar.add(fileMenu);\n\n fileNewItem.setMnemonic(KeyEvent.VK_N);\n fileNewItem.addActionListener(this);\n fileMenu.add(fileNewItem);\n\n fileOpenItem.setMnemonic(KeyEvent.VK_O);\n fileOpenItem.addActionListener(this);\n fileMenu.add(fileOpenItem);\n\n fileEditItem.setMnemonic(KeyEvent.VK_E);\n fileEditItem.addActionListener(this);\n fileMenu.add(fileEditItem);\n\n fileCloseItem.setMnemonic(KeyEvent.VK_C);\n fileCloseItem.addActionListener(this);\n fileMenu.add(fileCloseItem);\n\n fileMenu.addSeparator();\n\n fileAboutItem.setMnemonic(KeyEvent.VK_A);\n fileAboutItem.addActionListener(this);\n fileMenu.add(fileAboutItem);\n\n fileExitItem.setMnemonic(KeyEvent.VK_X);\n fileExitItem.addActionListener(this);\n fileMenu.add(fileExitItem);\n\n //\n // We start with New/Open enabled and Edit/Close disabled.\n //\n setMenuItemsEnabled(true, true, false, false);\n parent.frame.setJMenuBar(menuBar);\n }", "private MenuBar setupMenu () {\n MenuBar mb = new MenuBar ();\n Menu fileMenu = new Menu (\"File\");\n openXn = makeMenuItem (\"Open Connection\", OPEN_CONNECTION);\n closeXn = makeMenuItem (\"Close Connection\", CLOSE_CONNECTION);\n closeXn.setEnabled (false);\n MenuItem exit = makeMenuItem (\"Exit\", EXIT_APPLICATION);\n fileMenu.add (openXn);\n fileMenu.add (closeXn);\n fileMenu.addSeparator ();\n fileMenu.add (exit);\n\n Menu twMenu = new Menu (\"Tw\");\n getWksp = makeMenuItem (\"Get Workspace\", GET_WORKSPACE);\n getWksp.setEnabled (false);\n twMenu.add (getWksp);\n\n mb.add (fileMenu);\n mb.add (twMenu);\n return mb;\n }", "private JMenuBar createMenuBar() {\n\t\tJMenuBar menuBar = new JMenuBar();\n\t\t\n\t\tJMenu fileMenu = new JMenu(\"File\");\n\t\tJMenu helpMenu = new JMenu(\"Help\");\n\t\t\n\t\tmenuBar.add(fileMenu);\n\t\tmenuBar.add(helpMenu);\n\t\t\n\t\tfileMenu.setMnemonic(KeyEvent.VK_F);\n\t\thelpMenu.setMnemonic(KeyEvent.VK_H);\n\n\t\tJMenuItem exitItem =\n\t\t\t\tcreateMenuItem(fileMenu, \"Exit\", KeyEvent.VK_X, \"ctrl X\", \"Exits the program\");\n\t\texitItem.addActionListener((e) -> {\n\t\t\tthis.dispose();\n\t\t\tSystem.exit(0);\n\t\t});\n\t\t\n\t\tJMenuItem aboutItem =\n\t\t\t\tcreateMenuItem(helpMenu, \"About File Encryptor\", -1, null, \"Shows information about this program\");\n\t\taboutItem.addActionListener((e) -> {\n\t\t\tshowHelp();\n\t\t});\n\t\t\n\t\treturn menuBar;\n\t}", "MenuBar setMenu() {\r\n\t\t// initially set up the file chooser to look for cfg files in current directory\r\n\t\tMenuBar menuBar = new MenuBar(); // create main menu\r\n\r\n\t\tMenu mFile = new Menu(\"File\"); // add File main menu\r\n\t\tMenuItem mExit = new MenuItem(\"Exit\"); // whose sub menu has Exit\r\n\t\tmExit.setOnAction(new EventHandler<ActionEvent>() {\r\n\t\t\tpublic void handle(ActionEvent t) { // action on exit\r\n\t\t\t\ttimer.stop(); // stop timer\r\n\t\t\t\tSystem.exit(0); // exit program\r\n\t\t\t}\r\n\t\t});\r\n\t\tmFile.getItems().addAll(mExit); // add load, save and exit to File menu\r\n\r\n\t\tMenu mHelp = new Menu(\"Help\"); // create Help menu\r\n\t\tMenuItem mAbout = new MenuItem(\"About\"); // add Welcome sub menu item\r\n\t\tmAbout.setOnAction(new EventHandler<ActionEvent>() {\r\n\t\t\t@Override\r\n\t\t\tpublic void handle(ActionEvent actionEvent) {\r\n\t\t\t\tshowAbout(); // whose action is to give welcome message\r\n\t\t\t}\r\n\t\t});\r\n\t\tmHelp.getItems().addAll(mAbout); // add Welcome and About to Run main item\r\n\r\n\t\tmenuBar.getMenus().addAll(mFile, mHelp); // set main menu with File, Config, Run, Help\r\n\t\treturn menuBar; // return the menu\r\n\t}", "private void createMenus() {\r\n\t\t// File menu\r\n\t\tmenuFile = new JMenu(Constants.C_FILE_MENU_TITLE);\r\n\t\tmenuBar.add(menuFile);\r\n\t\t\r\n\t\tmenuItemExit = new JMenuItem(Constants.C_FILE_ITEM_EXIT_TITLE);\r\n\t\tmenuItemExit.addActionListener(new ActionListener() {\r\n\t\t\tpublic void actionPerformed(ActionEvent arg0) {\r\n\t\t\t\tactionOnClicExit();\t\t// Action triggered when the Exit item is clicked.\r\n\t\t\t}\r\n\t\t});\r\n\t\tmenuFile.add(menuItemExit);\r\n\t\t\r\n\t\t// Help menu\r\n\t\tmenuHelp = new JMenu(Constants.C_HELP_MENU_TITLE);\r\n\t\tmenuBar.add(menuHelp);\r\n\t\t\r\n\t\tmenuItemHelp = new JMenuItem(Constants.C_HELP_ITEM_HELP_TITLE);\r\n\t\tmenuItemHelp.addActionListener(new ActionListener() {\r\n\t\t\tpublic void actionPerformed(ActionEvent e) {\r\n\t\t\t\tactionOnClicHelp();\r\n\t\t\t}\r\n\t\t});\r\n\t\tmenuHelp.add(menuItemHelp);\r\n\t\t\r\n\t\tmenuItemAbout = new JMenuItem(Constants.C_HELP_ITEM_ABOUT_TITLE);\r\n\t\tmenuItemAbout.addActionListener(new ActionListener() {\r\n\t\t\tpublic void actionPerformed(ActionEvent e) {\r\n\t\t\t\tactionOnClicAbout();\r\n\t\t\t}\r\n\t\t});\r\n\t\tmenuHelp.add(menuItemAbout);\r\n\t\t\r\n\t\tmenuItemReferences = new JMenuItem(Constants.C_HELP_ITEM_REFERENCES_TITLE);\r\n\t\tmenuItemReferences.addActionListener(new ActionListener() {\r\n\t\t\tpublic void actionPerformed(ActionEvent e) {\r\n\t\t\t\tactionOnClicReferences();\r\n\t\t\t}\r\n\t\t});\r\n\t\tmenuHelp.add(menuItemReferences);\r\n\t}", "public void setFileMenu(JMenu fileMenu) {\n this.fileMenu = fileMenu;\n }", "public void generateMenu(){\n\t\tmenuBar = new JMenuBar();\n\n\t\tJMenu file = new JMenu(\"File\");\n\t\tJMenu tools = new JMenu(\"Tools\");\n\t\tJMenu help = new JMenu(\"Help\");\n\n\t\tJMenuItem open = new JMenuItem(\"Open \");\n\t\tJMenuItem save = new JMenuItem(\"Save \");\n\t\tJMenuItem exit = new JMenuItem(\"Exit \");\n\t\tJMenuItem preferences = new JMenuItem(\"Preferences \");\n\t\tJMenuItem about = new JMenuItem(\"About \");\n\n\n\t\tfile.add(open);\n\t\tfile.add(save);\n\t\tfile.addSeparator();\n\t\tfile.add(exit);\n\t\ttools.add(preferences);\n\t\thelp.add(about);\n\n\t\tmenuBar.add(file);\n\t\tmenuBar.add(tools);\n\t\tmenuBar.add(help);\n\t}", "public Menu() {\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\tMenu.setAlwaysOnTop(true);\r\n\t\tMenu.setBackground(Color.LIGHT_GRAY);\r\n\t\tMenu.setResizable(false);\r\n\t\t\r\n\t\tMenu.setIconImage(Toolkit.getDefaultToolkit().getImage(Menu.class.getResource(\"/images/iconoTT.png\")));\r\n\t\t\r\n\t\tMenu.setTitle(\"TText v1.0\");\r\n\t\tMenu.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\r\n\t\tMenu.setBounds(100, 100, 405, 293);\r\n\t\t\r\n\t\tcontentPane = new JPanel();\r\n\t\tcontentPane.setBackground(Color.DARK_GRAY);\r\n\t\tcontentPane.setBorder(new EmptyBorder(5, 5, 5, 5));\r\n\t\tcontentPane.setLayout(new BorderLayout(0, 0));\r\n\t\t\r\n\t\tMenu.setContentPane(contentPane);\r\n\t\t\r\n\t\tJPanel panel = new JPanel();\t\r\n\t\tpanel.setBackground(Color.DARK_GRAY);\r\n\t\tcontentPane.add(panel, BorderLayout.CENTER);\r\n\t\tpanel.setLayout(null);\r\n\t\t\r\n\t\tJButton btnNewFile = new JButton(\"\");\r\n\t\tbtnNewFile.addActionListener(new ActionListener() {\r\n\t\t\tpublic void actionPerformed(ActionEvent arg0) {\r\n\t\t\t\tfunc.NewFile(Menu);\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\t\tbtnNewFile.setToolTipText(\"New file...\");\r\n\t\tbtnNewFile.setIcon(new ImageIcon(Menu.class.getResource(\"/images/new_document.png\")));\r\n\t\tbtnNewFile.setBounds(72, 35, 42, 51);\r\n\t\tpanel.add(btnNewFile);\r\n\t\t\r\n\t\tJButton Button_OpenFile = new JButton(\"\");\r\n\t\tButton_OpenFile.addActionListener(new ActionListener() {\r\n\t\t\tpublic void actionPerformed(ActionEvent arg0) {\r\n\t\t\t\tfunc.OpenFileIni(Menu);\r\n\t\t\t}\r\n\t\t});\r\n\t\tButton_OpenFile.setToolTipText(\"Open file...\");\r\n\t\tButton_OpenFile.setIcon(new ImageIcon(Menu.class.getResource(\"/images/open_document.png\")));\r\n\t\tButton_OpenFile.setBounds(276, 35, 62, 51);\r\n\t\tpanel.add(Button_OpenFile);\r\n\t\t\r\n\t\tJLabel label = new JLabel(\"\");\r\n\t\tlabel.setToolTipText(\"Menu\");\r\n\t\tlabel.setBounds(0, 0, 389, 255);\r\n\t\tlabel.setIcon(new ImageIcon(Menu.class.getResource(\"/images/home.png\")));\r\n\t\tpanel.add(label);\r\n\t\t\r\n\t\tImageIcon background = new ImageIcon(Menu.class.getResource(\"/images/home.png\"));\r\n\t\t\r\n\t\tMenu.setVisible(true);\r\n\t}", "private void createContextMenu(){\r\n\t\tmenu = new JMenuBar();\r\n\t\tint ctrl;\r\n\t\tif(MAC)\r\n\t\t\tctrl = ActionEvent.META_MASK;\r\n\t\telse\r\n\t\t\tctrl = ActionEvent.CTRL_MASK;\r\n\r\n\t\tJMenu fileMenu = new JMenu(\"File\");\r\n\t\tnewMenu = new JMenuItem(\"New\");\r\n\t\tnewMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ctrl));\r\n\t\tnewMenu.addActionListener(this);\r\n\t\topenMenu = new JMenuItem(\"Open\");\r\n\t\topenMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ctrl));\r\n\t\topenMenu.addActionListener(this);\r\n\t\trecentMenu = new JMenu(\"Open Recent\");\r\n\t\tpopulateRecentMenu();\r\n\t\tsaveMenu = new JMenuItem(\"Save\");\r\n\t\tsaveMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ctrl));\r\n\t\tsaveMenu.addActionListener(this);\r\n\t\tsaveAsMenu = new JMenuItem(\"Save As...\");\r\n\t\tsaveAsMenu.addActionListener(this);\r\n\t\tfileMenu.add(newMenu);\r\n\t\tfileMenu.add(openMenu);\r\n\t\tfileMenu.add(recentMenu);\r\n\t\tfileMenu.add(saveMenu);\r\n\t\tfileMenu.add(saveAsMenu);\r\n\r\n\t\tmenu.add(fileMenu);\r\n\r\n\t\tJMenu editMenu = new JMenu(\"Edit\");\r\n\t\tpreferencesMenu = new JMenuItem(\"Preferences\");\r\n\t\tpreferencesMenu.addActionListener(this);\r\n\t\teditMenu.add(preferencesMenu);\r\n\r\n\t\tmenu.add(editMenu);\r\n\r\n\t\tif(!MAC){\r\n\t\t\tJMenu helpMenu = new JMenu(\"Help\");\r\n\t\t\tJMenuItem aboutMenuI = new JMenuItem(\"About\");\r\n\r\n\t\t\taboutMenuI.addActionListener(new ActionListener(){\r\n\t\t\t\tpublic void actionPerformed(ActionEvent e) {\r\n\t\t\t\t\tshowAboutMenu();\r\n\t\t\t\t}\t\t\r\n\t\t\t});\r\n\t\t\thelpMenu.add(aboutMenuI);\r\n\t\t\tmenu.add(helpMenu);\r\n\t\t}\r\n\t}", "private void constructMenus()\n\t{\n\t\tthis.fileMenu = new JMenu(\"File\");\n\t\tthis.editMenu = new JMenu(\"Edit\");\n\t\tthis.caseMenu = new JMenu(\"Case\");\n\t\tthis.imageMenu = new JMenu(\"Image\");\n\t\tthis.fileMenu.add(this.saveImageMenuItem);\n\t\tthis.fileMenu.addSeparator();\n\t\tthis.fileMenu.add(this.quitMenuItem);\n\t\tthis.editMenu.add(this.undoMenuItem);\n\t\tthis.editMenu.add(this.redoMenuItem);\n\t\tthis.caseMenu.add(this.removeImageMenuItem);\n\t\tthis.imageMenu.add(this.antiAliasMenuItem);\n\t\tthis.imageMenu.addSeparator();\n\t\tthis.imageMenu.add(this.brightenMenuItem);\n\t\tthis.imageMenu.add(this.darkenMenuItem);\n\t\tthis.imageMenu.addSeparator();\n\t\tthis.imageMenu.add(this.grayscaleMenuItem);\n\t\tthis.imageMenu.addSeparator();\n\t\tthis.imageMenu.add(this.resizeMenuItem);\n\t\tthis.imageMenu.addSeparator();\n\t\tthis.imageMenu.add(this.cropMenuItem);\n\t\tthis.imageMenu.addSeparator();\n\t\tthis.imageMenu.add(this.rotate90MenuItem);\n\t\tthis.imageMenu.add(this.rotate180MenuItem);\n\t\tthis.imageMenu.add(this.rotate270MenuItem);\n\t}", "public JMenuItem createFileExitItem()\n {\n JMenuItem item = new JMenuItem(\"Exit\");\n class MenuItemListener implements ActionListener\n {\n public void actionPerformed(ActionEvent event)\n {\n System.exit(0);\n }\n }\n ActionListener listener = new MenuItemListener();\n item.addActionListener(listener);\n return item;\n }", "public Menu createViewMenu();", "public void InitializeMenu(){\n\t\tmnbBar = new JMenuBar();\n\t\tmnuFile = new JMenu(\"File\");\n\t\tmnuFormat = new JMenu(\"Format\");\n\t\tmniOpen = new JMenuItem(\"Open\");\n\t\tmniExit = new JMenuItem(\"Exit\");\n\t\tmniSave = new JMenuItem(\"Save\");\n\t\tmniSaveAs = new JMenuItem(\"Save as\");\n\t\tmniSaveAs.setMnemonic(KeyEvent.VK_A);\n\t\tmniSave.setMnemonic(KeyEvent.VK_S);\n\t\tmniChangeBgColor = new JMenuItem(\"Change Backgroud Color\");\n\t\tmniChangeFontColor = new JMenuItem(\"Change Font Color\");\n\t\t//them menu item vao menu file\n\t\tmnuFile.add(mniOpen);\n\t\tmnuFile.addSeparator();\n\t\tmnuFile.add(mniExit);\n\t\tmnuFile.add(mniSaveAs);\n\t\tmnuFile.add(mniSave);\n\t\t//them menu item vao menu format\n\t\tmnuFormat.add(mniChangeBgColor);\n\t\tmnuFormat.addSeparator();\n\t\tmnuFormat.add(mniChangeFontColor);\n\t\t//them menu file va menu format vao menu bar\n\t\tmnbBar.add(mnuFile);\n\t\tmnbBar.add(mnuFormat);\n\t\t//thiet lap menubar thanh menu chinh cua frame\n\t\tsetJMenuBar(mnbBar);\n\t}", "private void buildMenu() {\n JMenuBar mbar = new JMenuBar();\n setJMenuBar(mbar);\n\n JMenu fileMenu = new JMenu(\"File\");\n fileMenu.addMenuListener(this);\n\n JMenuItem openItem = new JMenuItem(\"Open\");\n openItem.setEnabled(false);\n JMenuItem newItem = new JMenuItem(\"New\");\n newItem.setEnabled(false);\n saveItem = new JMenuItem(\"Save\");\n saveItem.setEnabled(false);\n saveAsItem = new JMenuItem(\"Save As\");\n saveAsItem.setEnabled(false);\n reloadCalItem = new JMenuItem(RELOAD_CAL);\n exitItem = new JMenuItem(EXIT);\n\n mbar.add(makeMenu(fileMenu, new Object[]{newItem, openItem, null,\n reloadCalItem, null,\n saveItem, saveAsItem, null, exitItem}, this));\n\n JMenu viewMenu = new JMenu(\"View\");\n mbar.add(viewMenu);\n JMenuItem columnItem = new JMenuItem(COLUMNS);\n columnItem.addActionListener(this);\n JMenuItem logItem = new JMenuItem(LOG);\n logItem.addActionListener(this);\n JMenu satMenu = new JMenu(\"Satellite Image\");\n JMenuItem irItem = new JMenuItem(INFRA_RED);\n irItem.addActionListener(this);\n JMenuItem wvItem = new JMenuItem(WATER_VAPOUR);\n wvItem.addActionListener(this);\n satMenu.add(irItem);\n satMenu.add(wvItem);\n viewMenu.add(columnItem);\n viewMenu.add(logItem);\n viewMenu.add(satMenu);\n\n observability = new JCheckBoxMenuItem(\"Observability\", true);\n observability.setToolTipText(\"Check that the source is observable.\");\n remaining = new JCheckBoxMenuItem(\"Remaining\", true);\n remaining.setToolTipText(\n \"Check that the MSB has repeats remaining to be observed.\");\n allocation = new JCheckBoxMenuItem(\"Allocation\", true);\n allocation.setToolTipText(\n \"Check that the project still has sufficient time allocated.\");\n\n String ZOA = System.getProperty(\"ZOA\", \"true\");\n boolean tickZOA = true;\n if (\"false\".equalsIgnoreCase(ZOA)) {\n tickZOA = false;\n }\n\n zoneOfAvoidance = new JCheckBoxMenuItem(\"Zone of Avoidance\", tickZOA);\n localQuerytool.setZoneOfAvoidanceConstraint(!tickZOA);\n\n disableAll = new JCheckBoxMenuItem(\"Disable All\", false);\n JMenuItem cutItem = new JMenuItem(\"Cut\",\n new ImageIcon(ClassLoader.getSystemResource(\"cut.gif\")));\n cutItem.setEnabled(false);\n JMenuItem copyItem = new JMenuItem(\"Copy\",\n new ImageIcon(ClassLoader.getSystemResource(\"copy.gif\")));\n copyItem.setEnabled(false);\n JMenuItem pasteItem = new JMenuItem(\"Paste\",\n new ImageIcon(ClassLoader.getSystemResource(\"paste.gif\")));\n pasteItem.setEnabled(false);\n\n mbar.add(makeMenu(\"Edit\",\n new Object[]{\n cutItem,\n copyItem,\n pasteItem,\n null,\n makeMenu(\"Constraints\", new Object[]{observability,\n remaining, allocation, zoneOfAvoidance, null,\n disableAll}, this)}, this));\n\n mbar.add(SampClient.getInstance().buildMenu(this, sorter, table));\n\n JMenu helpMenu = new JMenu(\"Help\");\n helpMenu.setMnemonic('H');\n\n mbar.add(makeMenu(helpMenu, new Object[]{new JMenuItem(INDEX, 'I'),\n new JMenuItem(ABOUT, 'A')}, this));\n\n menuBuilt = true;\n }", "public JMenuItem createFileExitItem(){\n\t\tJMenuItem item = new JMenuItem(\"Exit\");\n\t\tclass MenuItemListener implements ActionListener{\n\t\t\tpublic void actionPerformed(ActionEvent event){\n\t\t\t\tSystem.exit(0);\n\t\t\t}\n\t\t}\n\t\tActionListener listener = new MenuItemListener();\n\t\titem.addActionListener(listener);\n\t\treturn item;\n\t}", "public Menu createToolsMenu();", "private void buildMenu() {\r\n\t\tJMenuBar mainmenu = new JMenuBar();\r\n\t\tsetJMenuBar(mainmenu);\r\n\r\n\t\tui.fileMenu = new JMenu(\"File\");\r\n\t\tui.editMenu = new JMenu(\"Edit\");\r\n\t\tui.viewMenu = new JMenu(\"View\");\r\n\t\tui.helpMenu = new JMenu(\"Help\");\r\n\t\t\r\n\t\tui.fileNew = new JMenuItem(\"New...\");\r\n\t\tui.fileOpen = new JMenuItem(\"Open...\");\r\n\t\tui.fileImport = new JMenuItem(\"Import...\");\r\n\t\tui.fileSave = new JMenuItem(\"Save\");\r\n\t\tui.fileSaveAs = new JMenuItem(\"Save as...\");\r\n\t\tui.fileExit = new JMenuItem(\"Exit\");\r\n\r\n\t\tui.fileOpen.setAccelerator(KeyStroke.getKeyStroke('O', InputEvent.CTRL_DOWN_MASK));\r\n\t\tui.fileSave.setAccelerator(KeyStroke.getKeyStroke('S', InputEvent.CTRL_DOWN_MASK));\r\n\t\t\r\n\t\tui.fileImport.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doImport(); } });\r\n\t\tui.fileExit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); doExit(); } });\r\n\t\t\r\n\t\tui.fileOpen.addActionListener(new Act() {\r\n\t\t\t@Override\r\n\t\t\tpublic void act() {\r\n\t\t\t\tdoLoad();\r\n\t\t\t}\r\n\t\t});\r\n\t\tui.fileSave.addActionListener(new Act() {\r\n\t\t\t@Override\r\n\t\t\tpublic void act() {\r\n\t\t\t\tdoSave();\r\n\t\t\t}\r\n\t\t});\r\n\t\tui.fileSaveAs.addActionListener(new Act() {\r\n\t\t\t@Override\r\n\t\t\tpublic void act() {\r\n\t\t\t\tdoSaveAs();\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\t\tui.editUndo = new JMenuItem(\"Undo\");\r\n\t\tui.editUndo.setEnabled(undoManager.canUndo()); \r\n\t\t\r\n\t\tui.editRedo = new JMenuItem(\"Redo\");\r\n\t\tui.editRedo.setEnabled(undoManager.canRedo()); \r\n\t\t\r\n\t\t\r\n\t\tui.editCut = new JMenuItem(\"Cut\");\r\n\t\tui.editCopy = new JMenuItem(\"Copy\");\r\n\t\tui.editPaste = new JMenuItem(\"Paste\");\r\n\t\t\r\n\t\tui.editCut.addActionListener(new Act() { @Override public void act() { doCut(true, true); } });\r\n\t\tui.editCopy.addActionListener(new Act() { @Override public void act() { doCopy(true, true); } });\r\n\t\tui.editPaste.addActionListener(new Act() { @Override public void act() { doPaste(true, true); } });\r\n\t\t\r\n\t\tui.editPlaceMode = new JCheckBoxMenuItem(\"Placement mode\");\r\n\t\t\r\n\t\tui.editDeleteBuilding = new JMenuItem(\"Delete building\");\r\n\t\tui.editDeleteSurface = new JMenuItem(\"Delete surface\");\r\n\t\tui.editDeleteBoth = new JMenuItem(\"Delete both\");\r\n\t\t\r\n\t\tui.editClearBuildings = new JMenuItem(\"Clear buildings\");\r\n\t\tui.editClearSurface = new JMenuItem(\"Clear surface\");\r\n\r\n\t\tui.editUndo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doUndo(); } });\r\n\t\tui.editRedo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doRedo(); } });\r\n\t\tui.editClearBuildings.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doClearBuildings(true); } });\r\n\t\tui.editClearSurface.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doClearSurfaces(true); } });\r\n\t\t\r\n\r\n\t\tui.editUndo.setAccelerator(KeyStroke.getKeyStroke('Z', InputEvent.CTRL_DOWN_MASK));\r\n\t\tui.editRedo.setAccelerator(KeyStroke.getKeyStroke('Y', InputEvent.CTRL_DOWN_MASK));\r\n\t\tui.editCut.setAccelerator(KeyStroke.getKeyStroke('X', InputEvent.CTRL_DOWN_MASK));\r\n\t\tui.editCopy.setAccelerator(KeyStroke.getKeyStroke('C', InputEvent.CTRL_DOWN_MASK));\r\n\t\tui.editPaste.setAccelerator(KeyStroke.getKeyStroke('V', InputEvent.CTRL_DOWN_MASK));\r\n\t\tui.editPlaceMode.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0));\r\n\t\t\r\n\t\tui.editDeleteBuilding.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));\r\n\t\tui.editDeleteSurface.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, InputEvent.CTRL_DOWN_MASK));\r\n\t\tui.editDeleteBoth.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));\r\n\t\t\r\n\t\tui.editDeleteBuilding.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doDeleteBuilding(); } });\r\n\t\tui.editDeleteSurface.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doDeleteSurface(); } });\r\n\t\tui.editDeleteBoth.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doDeleteBoth(); } });\r\n\t\tui.editPlaceMode.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doPlaceMode(ui.editPlaceMode.isSelected()); } });\r\n\t\t\r\n\t\tui.editPlaceRoads = new JMenu(\"Place roads\");\r\n\t\t\r\n\t\tui.editResize = new JMenuItem(\"Resize map\");\r\n\t\tui.editCleanup = new JMenuItem(\"Remove outbound objects\");\r\n\t\t\r\n\t\tui.editResize.addActionListener(new Act() {\r\n\t\t\t@Override\r\n\t\t\tpublic void act() {\r\n\t\t\t\tdoResize();\r\n\t\t\t}\r\n\t\t});\r\n\t\tui.editCleanup.addActionListener(new Act() {\r\n\t\t\t@Override\r\n\t\t\tpublic void act() {\r\n\t\t\t\tdoCleanup();\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\t\tui.editCutBuilding = new JMenuItem(\"Cut: building\");\r\n\t\tui.editCutSurface = new JMenuItem(\"Cut: surface\");\r\n\t\tui.editPasteBuilding = new JMenuItem(\"Paste: building\");\r\n\t\tui.editPasteSurface = new JMenuItem(\"Paste: surface\");\r\n\t\tui.editCopyBuilding = new JMenuItem(\"Copy: building\");\r\n\t\tui.editCopySurface = new JMenuItem(\"Copy: surface\");\r\n\t\t\r\n\t\tui.editCutBuilding.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));\r\n\t\tui.editCopyBuilding.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));\r\n\t\tui.editPasteBuilding.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));\r\n\t\t\r\n\t\tui.editCutBuilding.addActionListener(new Act() { @Override public void act() { doCut(false, true); } });\r\n\t\tui.editCutSurface.addActionListener(new Act() { @Override public void act() { doCut(true, false); } });\r\n\t\tui.editCopyBuilding.addActionListener(new Act() { @Override public void act() { doCopy(false, true); } });\r\n\t\tui.editCopySurface.addActionListener(new Act() { @Override public void act() { doCopy(true, false); } });\r\n\t\tui.editPasteBuilding.addActionListener(new Act() { @Override public void act() { doPaste(false, true); } });\r\n\t\tui.editPasteSurface.addActionListener(new Act() { @Override public void act() { doPaste(true, false); } });\r\n\t\t\r\n\t\tui.viewZoomIn = new JMenuItem(\"Zoom in\");\r\n\t\tui.viewZoomOut = new JMenuItem(\"Zoom out\");\r\n\t\tui.viewZoomNormal = new JMenuItem(\"Zoom normal\");\r\n\t\tui.viewBrighter = new JMenuItem(\"Daylight (1.0)\");\r\n\t\tui.viewDarker = new JMenuItem(\"Night (0.5)\");\r\n\t\tui.viewMoreLight = new JMenuItem(\"More light (+0.05)\");\r\n\t\tui.viewLessLight = new JMenuItem(\"Less light (-0.05)\");\r\n\t\t\r\n\t\tui.viewShowBuildings = new JCheckBoxMenuItem(\"Show/hide buildings\", renderer.showBuildings);\r\n\t\tui.viewShowBuildings.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.CTRL_DOWN_MASK));\r\n\t\t\r\n\t\tui.viewSymbolicBuildings = new JCheckBoxMenuItem(\"Minimap rendering mode\", renderer.minimapMode);\r\n\t\tui.viewSymbolicBuildings.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, InputEvent.CTRL_DOWN_MASK));\r\n\t\t\r\n\t\tui.viewTextBackgrounds = new JCheckBoxMenuItem(\"Show/hide text background boxes\", renderer.textBackgrounds);\r\n\t\tui.viewTextBackgrounds.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK));\r\n\t\tui.viewTextBackgrounds.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doToggleTextBackgrounds(); } });\r\n\t\t\r\n\t\tui.viewZoomIn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doZoomIn(); } });\r\n\t\tui.viewZoomOut.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doZoomOut(); } });\r\n\t\tui.viewZoomNormal.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doZoomNormal(); } });\r\n\t\tui.viewShowBuildings.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doToggleBuildings(); } });\r\n\t\tui.viewSymbolicBuildings.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doToggleMinimap(); } });\r\n\t\t\r\n\t\tui.viewBrighter.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doBright(); } });\r\n\t\tui.viewDarker.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doDark(); } });\r\n\t\tui.viewMoreLight.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doMoreLight(); } });\r\n\t\tui.viewLessLight.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doLessLight(); } });\r\n\t\t\r\n\t\tui.viewZoomIn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD9, InputEvent.CTRL_DOWN_MASK));\r\n\t\tui.viewZoomOut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD3, InputEvent.CTRL_DOWN_MASK));\r\n\t\tui.viewZoomNormal.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD0, InputEvent.CTRL_DOWN_MASK));\r\n\t\tui.viewMoreLight.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD8, InputEvent.CTRL_DOWN_MASK));\r\n\t\tui.viewLessLight.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD2, InputEvent.CTRL_DOWN_MASK));\r\n\t\tui.viewBrighter.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD7, InputEvent.CTRL_DOWN_MASK));\r\n\t\tui.viewDarker.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD1, InputEvent.CTRL_DOWN_MASK));\r\n\t\t\r\n\t\tui.viewStandardFonts = new JCheckBoxMenuItem(\"Use standard fonts\", TextRenderer.USE_STANDARD_FONTS);\r\n\t\t\r\n\t\tui.viewStandardFonts.addActionListener(new Act() {\r\n\t\t\t@Override\r\n\t\t\tpublic void act() {\r\n\t\t\t\tdoStandardFonts();\r\n\t\t\t}\r\n\t\t});\r\n\t\tui.viewPlacementHints = new JCheckBoxMenuItem(\"View placement hints\", renderer.placementHints);\r\n\t\tui.viewPlacementHints.addActionListener(new Act() {\r\n\t\t\t@Override\r\n\t\t\tpublic void act() {\r\n\t\t\t\tdoViewPlacementHints();\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\t\tui.helpOnline = new JMenuItem(\"Online wiki...\");\r\n\t\tui.helpOnline.addActionListener(new ActionListener() {\r\n\t\t\t@Override\r\n\t\t\tpublic void actionPerformed(ActionEvent e) {\r\n\t\t\t\tdoHelp();\r\n\t\t\t}\r\n\t\t});\r\n\t\tui.helpAbout = new JMenuItem(\"About...\");\r\n\t\tui.helpAbout.setEnabled(false); // TODO implement\r\n\t\t\r\n\t\tui.languageMenu = new JMenu(\"Language\");\r\n\t\t\r\n\t\tui.languageEn = new JRadioButtonMenuItem(\"English\", true);\r\n\t\tui.languageEn.addActionListener(new Act() {\r\n\t\t\t@Override\r\n\t\t\tpublic void act() {\r\n\t\t\t\tsetLabels(\"en\");\r\n\t\t\t}\r\n\t\t});\r\n\t\tui.languageHu = new JRadioButtonMenuItem(\"Hungarian\", false);\r\n\t\tui.languageHu.addActionListener(new Act() {\r\n\t\t\t@Override\r\n\t\t\tpublic void act() {\r\n\t\t\t\tsetLabels(\"hu\");\r\n\t\t\t}\r\n\t\t});\r\n\t\tButtonGroup bg = new ButtonGroup();\r\n\t\tbg.add(ui.languageEn);\r\n\t\tbg.add(ui.languageHu);\r\n\t\t\r\n\t\tui.fileRecent = new JMenu(\"Recent\");\r\n\t\tui.clearRecent = new JMenuItem(\"Clear recent\");\r\n\t\tui.clearRecent.addActionListener(new Act() {\r\n\t\t\t@Override\r\n\t\t\tpublic void act() {\r\n\t\t\t\tdoClearRecent();\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\t\taddAll(ui.fileRecent, ui.clearRecent);\r\n\t\t\r\n\t\taddAll(mainmenu, ui.fileMenu, ui.editMenu, ui.viewMenu, ui.languageMenu, ui.helpMenu);\r\n\t\taddAll(ui.fileMenu, ui.fileNew, null, ui.fileOpen, ui.fileRecent, ui.fileImport, null, ui.fileSave, ui.fileSaveAs, null, ui.fileExit);\r\n\t\taddAll(ui.editMenu, ui.editUndo, ui.editRedo, null, \r\n\t\t\t\tui.editCut, ui.editCopy, ui.editPaste, null, \r\n\t\t\t\tui.editCutBuilding, ui.editCopyBuilding, ui.editPasteBuilding, null, \r\n\t\t\t\tui.editCutSurface, ui.editCopySurface, ui.editPasteSurface, null, \r\n\t\t\t\tui.editPlaceMode, null, ui.editDeleteBuilding, ui.editDeleteSurface, ui.editDeleteBoth, null, \r\n\t\t\t\tui.editClearBuildings, ui.editClearSurface, null, ui.editPlaceRoads, null, ui.editResize, ui.editCleanup);\r\n\t\taddAll(ui.viewMenu, ui.viewZoomIn, ui.viewZoomOut, ui.viewZoomNormal, null, \r\n\t\t\t\tui.viewBrighter, ui.viewDarker, ui.viewMoreLight, ui.viewLessLight, null, \r\n\t\t\t\tui.viewShowBuildings, ui.viewSymbolicBuildings, ui.viewTextBackgrounds, ui.viewStandardFonts, ui.viewPlacementHints);\r\n\t\taddAll(ui.helpMenu, ui.helpOnline, null, ui.helpAbout);\r\n\t\t\r\n\t\taddAll(ui.languageMenu, ui.languageEn, ui.languageHu);\r\n\t\t\r\n\t\tui.fileNew.addActionListener(new ActionListener() {\r\n\t\t\t@Override\r\n\t\t\tpublic void actionPerformed(ActionEvent e) {\r\n\t\t\t\tdoNew();\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\t\tui.toolbar = new JToolBar(\"Tools\");\r\n\t\tContainer c = getContentPane();\r\n\t\tc.add(ui.toolbar, BorderLayout.PAGE_START);\r\n\r\n\t\tui.toolbarCut = createFor(\"res/Cut24.gif\", \"Cut\", ui.editCut, false);\r\n\t\tui.toolbarCopy = createFor(\"res/Copy24.gif\", \"Copy\", ui.editCopy, false);\r\n\t\tui.toolbarPaste = createFor(\"res/Paste24.gif\", \"Paste\", ui.editPaste, false);\r\n\t\tui.toolbarRemove = createFor(\"res/Remove24.gif\", \"Remove\", ui.editDeleteBuilding, false);\r\n\t\tui.toolbarUndo = createFor(\"res/Undo24.gif\", \"Undo\", ui.editUndo, false);\r\n\t\tui.toolbarRedo = createFor(\"res/Redo24.gif\", \"Redo\", ui.editRedo, false);\r\n\t\tui.toolbarPlacementMode = createFor(\"res/Down24.gif\", \"Placement mode\", ui.editPlaceMode, true);\r\n\r\n\t\tui.toolbarUndo.setEnabled(false);\r\n\t\tui.toolbarRedo.setEnabled(false);\r\n\t\t\r\n\t\tui.toolbarNew = createFor(\"res/New24.gif\", \"New\", ui.fileNew, false);\r\n\t\tui.toolbarOpen = createFor(\"res/Open24.gif\", \"Open\", ui.fileOpen, false);\r\n\t\tui.toolbarSave = createFor(\"res/Save24.gif\", \"Save\", ui.fileSave, false);\r\n\t\tui.toolbarImport = createFor(\"res/Import24.gif\", \"Import\", ui.fileImport, false);\r\n\t\tui.toolbarSaveAs = createFor(\"res/SaveAs24.gif\", \"Save as\", ui.fileSaveAs, false);\r\n\t\tui.toolbarZoomNormal = createFor(\"res/Zoom24.gif\", \"Zoom normal\", ui.viewZoomNormal, false);\r\n\t\tui.toolbarZoomIn = createFor(\"res/ZoomIn24.gif\", \"Zoom in\", ui.viewZoomIn, false);\r\n\t\tui.toolbarZoomOut = createFor(\"res/ZoomOut24.gif\", \"Zoom out\", ui.viewZoomOut, false);\r\n\t\tui.toolbarBrighter = createFor(\"res/TipOfTheDay24.gif\", \"Daylight\", ui.viewBrighter, false);\r\n\t\tui.toolbarDarker = createFor(\"res/TipOfTheDayDark24.gif\", \"Night\", ui.viewDarker, false);\r\n\t\tui.toolbarHelp = createFor(\"res/Help24.gif\", \"Help\", ui.helpOnline, false);\r\n\r\n\t\t\r\n\t\tui.toolbar.add(ui.toolbarNew);\r\n\t\tui.toolbar.add(ui.toolbarOpen);\r\n\t\tui.toolbar.add(ui.toolbarSave);\r\n\t\tui.toolbar.addSeparator();\r\n\t\tui.toolbar.add(ui.toolbarImport);\r\n\t\tui.toolbar.add(ui.toolbarSaveAs);\r\n\t\tui.toolbar.addSeparator();\r\n\t\tui.toolbar.add(ui.toolbarCut);\r\n\t\tui.toolbar.add(ui.toolbarCopy);\r\n\t\tui.toolbar.add(ui.toolbarPaste);\r\n\t\t\r\n\t\tui.toolbar.add(ui.toolbarRemove);\r\n\t\tui.toolbar.addSeparator();\r\n\t\tui.toolbar.add(ui.toolbarUndo);\r\n\t\tui.toolbar.add(ui.toolbarRedo);\r\n\t\tui.toolbar.addSeparator();\r\n\t\tui.toolbar.add(ui.toolbarPlacementMode);\r\n\t\tui.toolbar.addSeparator();\r\n\t\tui.toolbar.add(ui.toolbarZoomNormal);\r\n\t\tui.toolbar.add(ui.toolbarZoomIn);\r\n\t\tui.toolbar.add(ui.toolbarZoomOut);\r\n\t\tui.toolbar.addSeparator();\r\n\t\tui.toolbar.add(ui.toolbarBrighter);\r\n\t\tui.toolbar.add(ui.toolbarDarker);\r\n\t\tui.toolbar.addSeparator();\r\n\t\tui.toolbar.add(ui.toolbarHelp);\r\n\t\t\r\n\t}", "private void createMenuBar(){\n\t\tmenuBar = new JMenuBar();\n\t\t\n\t\t//Create the \"File\" menu\n\t\tthis.createFileMenu();\n\t\tmenuBar.add(fileMenu);\n\t\t\t\t\n\t\t//Create \"debug\" menu[disabled]\n\t\t//createDebugMenu();\t\t\n\t\t\n\t\t//last to be added to the menubar: about\n\t\tabout = new JMenuItem(\"About\");\n\t\tabout.addActionListener(this);\n\t\tmenuBar.add(about);\n\t}", "public JMenuBar createMenuBar ()\n {\n MenuListener menuListener = new MenuListener ();\n\t //-----------------------------Menu options.--------------------------------------------------------------\n JMenu fileMenu = new JMenu (\"File\");\n JMenu editMenu = new JMenu (\"Edit\");\n JMenu viewMenu = new JMenu (\"View\");\n JMenu colorMenu = new JMenu (\"Colors\");\n JMenu filterMenu = new JMenu (\"Filter\");\n JMenu helpMenu = new JMenu (\"Help\");\n\n //----------------------------Submenu options.-------------------------------------------------------------\n JMenuItem newMenuItem = new JMenuItem (\"New\",new ImageIcon(\"../img/new.gif\"));\n newMenuItem.addActionListener (menuListener);\n newMenuItem.setEnabled (true);\n\n JMenuItem openMenuItem = new JMenuItem (\"Open\",new ImageIcon(\"../img/open.gif\"));\n openMenuItem.addActionListener (menuListener);\n openMenuItem.setEnabled (true);\n\n JMenuItem saveMenuItem = new JMenuItem (\"Save\",new ImageIcon(\"../img/save.gif\"));\n saveMenuItem.addActionListener (menuListener);\n saveMenuItem.setEnabled (true);\n \n JMenuItem exitMenuItem = new JMenuItem (\"Exit\",new ImageIcon(\"../img/close.gif\"));\n exitMenuItem.addActionListener (menuListener);\n exitMenuItem.setEnabled (true);\n \n fileMenu.add (newMenuItem);\n fileMenu.add (openMenuItem);\n fileMenu.add (saveMenuItem);\n fileMenu.add (exitMenuItem);\n\n //---------------------------------------------End of File Menu--------------------------------------------\n JMenuItem undoMenuItem = new JMenuItem (\"Undo\",new ImageIcon(\"../img/undo.gif\"));\n undoMenuItem.addActionListener (menuListener);\n undoMenuItem.setEnabled (true);\n\n JMenuItem redoMenuItem = new JMenuItem (\"Redo\",new ImageIcon(\"../img/redo.gif\"));\n redoMenuItem.addActionListener (menuListener);\n redoMenuItem.setEnabled (true);\n\n JMenuItem clearMenuItem = new JMenuItem (\"Clear All\",new ImageIcon(\"../img/clear.gif\"));\n clearMenuItem.addActionListener (menuListener);\n clearMenuItem.setEnabled (true);\n\n editMenu.add (undoMenuItem);\n editMenu.add (redoMenuItem);\n editMenu.add (clearMenuItem);\n\n //----------------------------------------End of Edit Menu-------------------------------------------------\n JMenuItem toolboxMenuItem = new JMenuItem (\"Tool Box\",new ImageIcon(\"../img/tool.gif\"));\n toolboxMenuItem.addActionListener(menuListener);\n toolboxMenuItem.setEnabled (true);\n\n JMenuItem colorboxMenuItem = new JMenuItem (\"Color Box\",new ImageIcon(\"../img/cbox.gif\"));\n colorboxMenuItem.addActionListener(menuListener);\n colorboxMenuItem.setEnabled (true);\n\n JMenuItem cursorMenuItem = new JMenuItem (\"Cursor Position\",new ImageIcon(\"../img/pos.gif\"));\n cursorMenuItem.addActionListener(menuListener);\n cursorMenuItem.setEnabled (true);\n \n viewMenu.add (toolboxMenuItem);\n viewMenu.add (colorboxMenuItem);\n viewMenu.add (cursorMenuItem);\n\n //--------------------------------------End of View Menu-------------------------------------------------- \n JMenuItem editcolorMenuItem = new JMenuItem (\"Edit Colors\",new ImageIcon(\"../img/color.gif\"));\n editcolorMenuItem.addActionListener(menuListener);\n editcolorMenuItem.setEnabled (true);\n \n colorMenu.add (editcolorMenuItem);\n\n //------------------------------------End of Color Menu--------------------------------------------------- \n JMenuItem brightnessMenuItem = new JMenuItem (\"Brightness\",new ImageIcon(\"../img/bright.gif\"));\n brightnessMenuItem.addActionListener(menuListener);\n brightnessMenuItem.setEnabled (true);\n \n JMenuItem blurMenuItem = new JMenuItem (\"Blur\",new ImageIcon(\"../img/blur.gif\"));\n blurMenuItem.addActionListener(menuListener);\n blurMenuItem.setEnabled (true);\n \n filterMenu.add (brightnessMenuItem);\n filterMenu.add (blurMenuItem);\n\n //--------------------------------------End of Filter Menu------------------------------------------------ \n JMenuItem helpMenuItem = new JMenuItem (\"Help Topics\",new ImageIcon(\"../img/help.gif\"));\n helpMenuItem.addActionListener(menuListener);\n helpMenuItem.setEnabled (true); \n JMenuItem aboutMenuItem = new JMenuItem (\"About Multi Brush\",new ImageIcon(\"../img/license.gif\"));\n aboutMenuItem.addActionListener(menuListener);\n aboutMenuItem.setEnabled (true);\n \n helpMenu.add (helpMenuItem);\n helpMenu.add (aboutMenuItem);\n\n //-----------------------------------------End of Help Menu----------------------------------------------- \t \n JMenuBar menubar = new JMenuBar ();\n menubar.add (fileMenu);\n menubar.add (editMenu);\n menubar.add (viewMenu);\n menubar.add (colorMenu);\n //menubar.add (filterMenu);\n menubar.add (helpMenu);\n\n return menubar;\n }", "private JMenuBar createMenuBar() {\r\n\t\tJMenuBar menuBar = new JMenuBar();\r\n\t\tmenuBar.add(createFileMenu());\r\n\t\tmenuBar.add(createExamplesMenu());\r\n\t\tmenuBar.add(createEditVariableMenu());\r\n\t\tmenuBar.add(createAnimationMenu());\r\n\t\treturn (menuBar);\r\n\t}", "@Override\n\tpublic boolean onCreateOptionsMenu(Menu menu)\n\t{\n\t\tgetMenuInflater().inflate(R.menu.files, menu);\n\t\treturn true;\n\t}", "private void setupMenus() {\n\t\tJMenuBar menuBar = new JMenuBar();\n\n\t\t// Build the first menu.\n\t\tJMenu menu = new JMenu(Messages.getString(\"Gui.File\")); //$NON-NLS-1$\n\t\tmenu.setMnemonic(KeyEvent.VK_A);\n\t\tmenuBar.add(menu);\n\n\t\t// a group of JMenuItems\n\t\tJMenuItem menuItem = new JMenuItem(openAction);\n\t\tmenu.add(menuItem);\n\n\t\t// menuItem = new JMenuItem(openHttpAction);\n\t\t// menu.add(menuItem);\n\n\t\t/*\n\t\t * menuItem = new JMenuItem(crudAction); menu.add(menuItem);\n\t\t */\n\n\t\tmenuItem = new JMenuItem(showLoggingFrameAction);\n\t\tmenu.add(menuItem);\n\n\t\tmenuItem = new JMenuItem(quitAction);\n\t\tmenu.add(menuItem);\n\n\t\tmenuBar.add(menu);\n\n\t\tJMenu optionMenu = new JMenu(Messages.getString(\"Gui.Options\")); //$NON-NLS-1$\n\t\tmenuItem = new JCheckBoxMenuItem(baselineModeAction);\n\t\toptionMenu.add(menuItem);\n\t\tmenuItem = new JMenuItem(toggleButtonsAction);\n\t\toptionMenu.add(menuItem);\n\n\t\tmenuBar.add(optionMenu);\n\t\tJMenu buttonMenu = new JMenu(Messages.getString(\"Gui.Buttons\")); //$NON-NLS-1$\n\t\tmenuItem = new JMenuItem(wrongAnswerAction);\n\t\tbuttonMenu.add(menuItem);\n\t\tmenuItem = new JMenuItem(attendingAction);\n\t\tbuttonMenu.add(menuItem);\n\n\t\tmenuItem = new JMenuItem(independentAction);\n\t\tbuttonMenu.add(menuItem);\n\t\tmenuItem = new JMenuItem(verbalAction);\n\t\tbuttonMenu.add(menuItem);\n\t\tmenuItem = new JMenuItem(modelingAction);\n\t\tbuttonMenu.add(menuItem);\n\t\tmenuItem = new JMenuItem(noAnswerAction);\n\t\tbuttonMenu.add(menuItem);\n\n\t\tmenuBar.add(buttonMenu);\n\t\tframe.setJMenuBar(menuBar);\n\n\t\tframe.pack();\n\n\t\tframe.setVisible(true);\n\t}", "@Override\r\n\tpublic void createMenu(Menu menu) {\n\r\n\t}", "private JMenuBar createMenuBar() {\n\t\tJMenuBar jmb = new JMenuBar();\n\t\tImageIcon icon;\n\n\t\t// Create the File menu.\n\t\tJMenu jmFile = new JMenu(\"File\");\n\t\tthis.imageURL = getClass().getResource(\"/icons/folder-open_16.png\");\n\t\ticon = new ImageIcon(imageURL);\n\t\tJMenuItem jmiOpen = new JMenuItem(\"Open\", icon);\n\t\tjmiOpen.addActionListener(event -> tfStatus.setText(\"Menu item: \" + event.getActionCommand()));\n\t\tthis.imageURL = getClass().getResource(\"/icons/save_16.png\");\n\t\ticon = new ImageIcon(imageURL);\n\t\tJMenuItem jmiSave = new JMenuItem(\"Save\", icon);\n\t\tjmiSave.addActionListener(event -> tfStatus.setText(\"Menu item: \" + event.getActionCommand()));\n\t\tthis.imageURL = getClass().getResource(\"/icons/print_16.png\");\n\t\ticon = new ImageIcon(imageURL);\n\t\tJMenuItem jmiPrint = new JMenuItem(\"Print\", icon);\n\t\tjmiPrint.addActionListener(event -> tfStatus.setText(\"Menu item: \" + event.getActionCommand()));\n\t\tJMenuItem jmiExit = new JMenuItem(\"Exit\");\n\t\tjmiExit.addActionListener(event -> System.exit(0));\n\t\tjmFile.add(jmiOpen);\n\t\tjmFile.add(jmiSave);\n\t\tjmFile.addSeparator();\n\t\tjmFile.add(jmiPrint);\n\t\tjmFile.addSeparator();\n\t\tjmFile.add(jmiExit);\n\t\tjmb.add(jmFile);\n\n\t\t// Create the Options menu.\n\t\tJMenu jmOptions = new JMenu(\"Options\");\n\t\t// Create the Colors submenu.\n\t\tJMenu jmColors = new JMenu(\"Colors\");\n\t\tJRadioButtonMenuItem jmiBlue = new JRadioButtonMenuItem(blueAction);\n\t\tJRadioButtonMenuItem jmiRed = new JRadioButtonMenuItem(redAction);\n\t\tJRadioButtonMenuItem jmiYellow = new JRadioButtonMenuItem(yellowAction);\n\t\tjmColors.add(jmiBlue);\n\t\tjmColors.add(jmiRed);\n\t\tjmColors.add(jmiYellow);\n\t\tjmOptions.add(jmColors);\n\t\tButtonGroup bg = new ButtonGroup();\n\t\tbg.add(jmiBlue);\n\t\tbg.add(jmiRed);\n\t\tbg.add(jmiYellow);\n\t\tjmOptions.addSeparator();\n\t\tJCheckBoxMenuItem jmiSettings = new JCheckBoxMenuItem(\"Settings\");\n\t\tjmiSettings.setSelected(true);\n\t\tjmiSettings.addActionListener(event -> tfStatus.setText(\"Menu item: \" + event.getActionCommand()));\n\t\tjmOptions.add(jmiSettings);\n\t\tjmb.add(jmOptions);\n\t\treturn jmb;\n\t}", "private void initMenu()\n {\n bar = new JMenuBar();\n fileMenu = new JMenu(\"File\");\n crawlerMenu = new JMenu(\"Crawler\"); \n aboutMenu = new JMenu(\"About\");\n \n bar.add(fileMenu);\n bar.add(crawlerMenu);\n bar.add(aboutMenu);\n \n exit = new JMenuItem(\"Exit\");\n preferences = new JMenuItem(\"Preferences\");\n author = new JMenuItem(\"Author\");\n startCrawlerItem = new JMenuItem(\"Start\");\n stopCrawlerItem = new JMenuItem(\"Stop\");\n newIndexItem = new JMenuItem(\"New index\");\n openIndexItem = new JMenuItem(\"Open index\");\n \n stopCrawlerItem.setEnabled(false);\n \n fileMenu.add(newIndexItem);\n fileMenu.add(openIndexItem);\n fileMenu.add(exit);\n aboutMenu.add(author);\n crawlerMenu.add(startCrawlerItem);\n crawlerMenu.add(stopCrawlerItem);\n crawlerMenu.add(preferences);\n \n author.addActionListener(this);\n preferences.addActionListener(this);\n exit.addActionListener(this);\n startCrawlerItem.addActionListener(this);\n stopCrawlerItem.addActionListener(this);\n newIndexItem.addActionListener(this);\n openIndexItem.addActionListener(this);\n \n frame.setJMenuBar(bar);\n }", "private static JMenu getFileMenu(final EnvironmentFrame frame) {\n\t\tfinal Environment environment = frame.getEnvironment();\n\t\tfinal JMenu menu = new JMenu(\"File\");\n\t\taddItem(menu, new NewAction());\n\t\tfinal SecurityManager sm = System.getSecurityManager();\n\t\tif (Universe.CHOOSER != null) {\n\t\t\t// Can't open and save files.\n\t\t\taddItem(menu, new OpenAction());\n\t\t\taddItem(menu, new SaveAction(environment));\n\t\t\taddItem(menu, new SaveAsAction(environment));\n\t\t\tJMenu saveImageMenu;\n\t\t\tsaveImageMenu = new JMenu(\"Save Image As...\");\n\t\t\tsaveImageMenu.add(new SaveGraphJPGAction(environment, menu));\n\t\t\tsaveImageMenu.add(new SaveGraphPNGAction(environment, menu));\n\t\t\tsaveImageMenu.add(new SaveGraphGIFAction(environment, menu));\n\t\t\tsaveImageMenu.add(new SaveGraphBMPAction(environment, menu));\n\t\t\tif (environment instanceof AutomatonEnvironment) { // this is\n\t\t\t\t// strictly for\n\t\t\t\t// non-Grammar\n\t\t\t\tJarFile jar = null;\n\t\t\t\ttry {\n\t\t\t\t\tif (new File(\"JFLAP.jar\").exists()) {\n\t\t\t\t\t\tjar = new JarFile(\"JFLAP.jar\");\n\t\t\t\t\t} else if (new File(\"JFLAP_With_Source.jar\").exists()) {\n\t\t\t\t\t\tjar = new JarFile(\"JFLAP_With_Source.jar\");\n\t\t\t\t\t}\n\t\t\t\t} catch (final IOException ioe) {\n\t\t\t\t\tioe.printStackTrace();\n\t\t\t\t}\n\n\t\t\t\tif (new File(\"svg.jar\").exists() || (jar != null && jar.getJarEntry(\"org/foo.txt\") != null)) {\n\t\t\t\t\t// saveImageMenu.add(new ExportAction(environment));\n\t\t\t\t\ttry {\n\t\t\t\t\t\tfinal RestrictedAction ra = (RestrictedAction) Class.forName(\"gui.action.ExportAction\")\n\t\t\t\t\t\t\t\t.getConstructor(new Class[] { Environment.class }).newInstance(environment);\n\t\t\t\t\t\tsaveImageMenu.add(ra);\n\t\t\t\t\t} catch (final Exception e) {\n\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\tSystem.err.println(\"Cannot make menu\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tmenu.add(saveImageMenu);\n\t\t} else {\n\t\t\taddItem(menu, new OpenURLAction());\n\t\t}\n\t\taddItem(menu, new CloseAction(environment));\n\t\taddItem(menu, new CloseWindowAction(frame));\n\t\ttry {\n\t\t\tif (sm != null) {\n\t\t\t\tsm.checkPrintJobAccess();\n\t\t\t}\n\t\t\taddItem(menu, new PrintAction(environment));\n\t\t} catch (final SecurityException e) {\n\t\t\t// Damn. Can't print!\n\t\t}\n\t\ttry {\n\t\t\tif (sm != null) {\n\t\t\t\tsm.checkExit(0);\n\t\t\t}\n\t\t\taddItem(menu, new QuitAction());\n\t\t} catch (final SecurityException e) {\n\t\t\t// Well, can't exit anyway.\n\t\t}\n\n\t\t// if (environment instanceof AutomatonEnvironment){\n\t\t// addItem(menu, new SetUndoAmountAction());\n\t\t// }\n\n\t\treturn menu;\n\t}", "@Override\r\n\tprotected MenuManager createMenuManager() {\r\n\t\tMenuManager menuManager = new MenuManager(\"menu\");\r\n\t\treturn menuManager;\r\n\t}", "public FilePanel() {\n\t\tsuper();\n\t\tinitialize();\n\t}", "private static MenuItem createFileTreePasteMenuItem(SongManager model, Item selectedItem) {\n MenuItem paste = new MenuItem(PASTE);\n\n paste.setOnAction((event) -> {\n if (selectedItem != null) {\n File dest = selectedItem.getFile();\n if (!dest.isDirectory()) {\n PromptUI.customPromptError(\"Not a directory!\", null, \"Please select a directory as the paste target.\");\n return;\n }\n try {\n model.copyToDestination(dest);\n } catch (IOException ex) {\n PromptUI.customPromptError(\"Error\", null, \"IOException: \" + ex.getMessage());\n } catch (Exception ex) {\n PromptUI.customPromptError(\"Error\", null, \"Exception: \" + ex.getMessage());\n }\n }\n });\n\n return paste;\n }", "public Menu() {\n\n\t}", "private JMenuBar createMenu(Dockable[] dockables) {\n\t\tJMenuBar menuBar = new JMenuBar();\n\n\t\t// Build the File menu.\n\t\tJMenu fileMenu = new JMenu(\"文件\");\n\t\tfileMenu.setMnemonic(KeyEvent.VK_F);\n\t\tfileMenu.getAccessibleContext().setAccessibleDescription(\"The File Menu\");\n\t\tmenuBar.add(fileMenu);\n\n\t\t// Build the Window menu.\n\t\tJMenu windowMenu = new JMenu(\"窗口\");\n\t\twindowMenu.setMnemonic(KeyEvent.VK_W);\n\t\twindowMenu.getAccessibleContext().setAccessibleDescription(\"The Window Menu\");\n\t\tmenuBar.add(windowMenu);\n\n\t\t// Build the Look and Feel menu.\n//\t\tJMenu lookAndFeelMenu = new JMenu(\"Look and Feel\");\n//\t\tlookAndFeelMenu.setMnemonic(KeyEvent.VK_L);\n//\t\tlookAndFeelMenu.getAccessibleContext().setAccessibleDescription(\"The Lool and Feel Menu\");\n//\t\tmenuBar.add(lookAndFeelMenu);\n//\n//\t\t// Build the Dragging menu.\n//\t\tJMenu draggingMenu = new JMenu(\"Drag Painting\");\n//\t\tdraggingMenu.setMnemonic(KeyEvent.VK_D);\n//\t\tdraggingMenu.getAccessibleContext().setAccessibleDescription(\"The Dragging Menu\");\n//\t\tmenuBar.add(draggingMenu);\n\n\t\t// The JMenuItem for File\n\t\tJMenuItem menuItem = new JMenuItem(\"退出\", KeyEvent.VK_E);\n\t\tmenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.ALT_MASK));\n\t\tmenuItem.getAccessibleContext().setAccessibleDescription(\"Exit te application\");\n\t\tmenuItem.addActionListener(new ActionListener() {\n\t\t\tpublic void actionPerformed(ActionEvent arg0) {\n\t\t\t\tSystem.exit(0);\n\t\t\t}\n\t\t});\n\t\tfileMenu.add(menuItem);\n\n\t\tfor (int index = 0; index < dockables.length; index++) {\n\t\t\tJCheckBoxMenuItem cbMenuItem = new DockableMenuItem(dockables[index]);\n\t\t\twindowMenu.add(cbMenuItem);\n\t\t}\n\n\t\treturn menuBar;\n\t}", "@Override\n public boolean onCreateOptionsMenu(Menu menu) {\n getMenuInflater().inflate(R.menu.menu_open_file, menu);\n return true;\n }", "IMenuFactory getMenuFactory();", "public Menu createMenu(String name) {\r\n\t\treturn new Menu(name,this);\r\n\t}", "private void buildMenuBar(){\n //Create the manu bar\n menuBar = new JMenuBar();\n \n //Create the file and run menus\n buildFileMenu();\n buildViewMenu();\n \n //Add the file and run menus to the menu bar\n menuBar.add(fileMenu);\n menuBar.add(viewMenu);\n \n //Set the window's menu bar\n setJMenuBar(menuBar);\n }", "public MenuItem(){\n\n }", "public static void createLookAndFeelMenuItem(JMenu viewMenu, JFrame f) {\n\t\t\r\n\t}", "protected void fillMenu(MenuBar menuBar) {\n\t\tMenu fileMenu = new Menu(\"Файл\");\n\t\n\t\tMenuItem loginMenuItem = new MenuItem(\"Сменить пользователя\");\n\t\tloginMenuItem.setOnAction(actionEvent -> main.logout());\n\t\n\t\tMenuItem exitMenuItem = new MenuItem(\"Выход (выключить планшет)\");\n\t\texitMenuItem.setOnAction(actionEvent -> main.requestShutdown());\n\t\texitMenuItem.setAccelerator(KeyCombination.keyCombination(\"Alt+F4\"));\n\t\n\t\n\t\tfileMenu.getItems().addAll( loginMenuItem,\n\t\t\t\tnew SeparatorMenuItem(), exitMenuItem);\n\t\n\t\n\t\n\t\tMenu navMenu = new Menu(\"Навигация\");\n\t\n\t\tMenuItem navHomeMap = new MenuItem(\"На общую карту\");\n\t\t//navHomeMap.setOnAction(actionEvent -> setMapData(bigMapData));\n\t\tnavHomeMap.setOnAction(actionEvent -> setMapData(main.ml.getRootMap()));\n\t\n\t\tMenu navMaps = new Menu(\"Карты\");\n\t\t//navMaps.setOnAction(actionEvent -> setMapData(bigMapData));\n\t\tmain.ml.fillMapsMenu( navMaps, this );\n\t\n\t\tMenuItem navOverview = new MenuItem(\"Обзор\");\n\t\tnavOverview.setOnAction(actionEvent -> setOverviewScale());\n\t\n\t\tnavMenu.getItems().addAll( navHomeMap, navMaps, new SeparatorMenuItem(), navOverview );\n\t\n\t\t\n\t\t\n\t\tMenu dataMenu = new Menu(\"Данные\");\n\t\n\t\tServerUnitType.forEach(t -> {\n\t\t\tMenuItem dataItem = new MenuItem(t.getDisplayName());\n\t\t\tdataItem.setOnAction(actionEvent -> new EntityListWindow(t, main.rc, main.sc));\n\t\n\t\t\tdataMenu.getItems().add(dataItem);\t\t\t\n\t\t});\n\t\t\n\t\t//dataMenu.Menu debugMenu = new Menu(\"Debug\");\n\t\t//MenuItem d1 = new MenuItem(\"На общую карту\");\n\t\t//d1.setOnAction(actionEvent -> setMapData(main.ml.getRootMap()));\n\t\n\t\t\n\t\t/*\n\t Menu webMenu = new Menu(\"Web\");\n\t CheckMenuItem htmlMenuItem = new CheckMenuItem(\"HTML\");\n\t htmlMenuItem.setSelected(true);\n\t webMenu.getItems().add(htmlMenuItem);\n\t\n\t CheckMenuItem cssMenuItem = new CheckMenuItem(\"CSS\");\n\t cssMenuItem.setSelected(true);\n\t webMenu.getItems().add(cssMenuItem);\n\t\n\t Menu sqlMenu = new Menu(\"SQL\");\n\t ToggleGroup tGroup = new ToggleGroup();\n\t RadioMenuItem mysqlItem = new RadioMenuItem(\"MySQL\");\n\t mysqlItem.setToggleGroup(tGroup);\n\t\n\t RadioMenuItem oracleItem = new RadioMenuItem(\"Oracle\");\n\t oracleItem.setToggleGroup(tGroup);\n\t oracleItem.setSelected(true);\n\t\n\t sqlMenu.getItems().addAll(mysqlItem, oracleItem,\n\t new SeparatorMenuItem());\n\t\n\t Menu tutorialManeu = new Menu(\"Tutorial\");\n\t tutorialManeu.getItems().addAll(\n\t new CheckMenuItem(\"Java\"),\n\t new CheckMenuItem(\"JavaFX\"),\n\t new CheckMenuItem(\"Swing\"));\n\t\n\t sqlMenu.getItems().add(tutorialManeu);\n\t\t */\n\t\n\t\tMenu aboutMenu = new Menu(\"О системе\");\n\t\n\t\tMenuItem version = new MenuItem(\"Версия\");\n\t\tversion.setOnAction(actionEvent -> showAbout());\n\t\n\t\tMenuItem aboutDz = new MenuItem(\"Digital Zone\");\n\t\taboutDz.setOnAction(actionEvent -> main.getHostServices().showDocument(Defs.HOME_URL));\n\t\n\t\tMenuItem aboutVita = new MenuItem(\"VitaSoft\");\n\t\taboutVita.setOnAction(actionEvent -> main.getHostServices().showDocument(\"vtsft.ru\"));\n\t\n\t\taboutMenu.getItems().addAll( version, new SeparatorMenuItem(), aboutDz, aboutVita );\n\t\n\t\t// --------------- Menu bar\n\t\n\t\t//menuBar.getMenus().addAll(fileMenu, webMenu, sqlMenu);\n\t\tmenuBar.getMenus().addAll(fileMenu, navMenu, dataMenu, aboutMenu );\n\t}", "public Elegir()\n {\n initComponents();\n\n try\n {\n ObjectInputStream directorios = new ObjectInputStream(new FileInputStream(\"dirFav.dat\"));\n directoriosFavoritos = (ArrayList<String>) directorios.readObject();\n if (directoriosFavoritos == null)\n {\n directoriosFavoritos = new ArrayList<>();\n } else\n {\n for (int i = 0; i < directoriosFavoritos.size(); i++)\n {\n JMenuItem menuItem = new JMenuItem(directoriosFavoritos.get(i));\n menuItem.addActionListener(this);\n jMenuFavoritos.add(menuItem);\n submenus.add(menuItem);\n }\n }\n directorios.close();\n } catch (Exception e)\n {\n }\n }", "public MenuManager(String dishesFile) {\r\n\r\n\t\tArrayList<MenuItem> menuItems=FileManager.readItems(dishesFile);\r\n\t\tfor(int i=0;i<menuItems.size();i++) {\r\n\t\t\tif(menuItems.get(i) instanceof Entree) {\r\n\t\t\t\tentrees.add((Entree) menuItems.get(i));\r\n\t\t\t}\r\n\t\t\tif(menuItems.get(i) instanceof Side) {\r\n\t\t\t\tsides.add((Side) menuItems.get(i));\r\n\t\t\t}\r\n\t\t\tif(menuItems.get(i) instanceof Salad) {\r\n\t\t\t\tsalads.add((Salad) menuItems.get(i));\r\n\t\t\t}\r\n\t\t\tif(menuItems.get(i) instanceof Dessert) {\r\n\t\t\t\tdesserts.add((Dessert) menuItems.get(i));\r\n\t\t\t}\r\n\t\t}\r\n\t}", "private static ReminderMenuBar getReminderMenu(RemindersFileReader fileReader) {\r\n return new ReminderMenuBar(fileReader);\r\n }", "protected ViewerPopupMenu createPopupMenu()\n {\n ViewerPopupMenu menu = super.createPopupMenu();\n\n viewAction = new ViewerAction(this, \"View\", \"view\",\n \"View Dofs\",\n \"View the dofs of an Actor in table form.\",\n null, null, \"Ctrl-V\", null, \"false\");\n\n menu.addSeparator();\n menu.add(viewAction);\n\n return menu;\n }", "public MyMenu() {\n this(DSL.name(\"MY_MENU\"), null);\n }", "public Menu() {\r\n\r\n }", "protected void createContents() {\n\t\tshlMenu = new Shell();\n\t\tshlMenu.setImage(SWTResourceManager.getImage(MainMenu.class, \"/ikons/File-delete-icon.png\"));\n\t\tshlMenu.setBackground(SWTResourceManager.getColor(255, 102, 0));\n\t\tshlMenu.setSize(899, 578);\n\t\tshlMenu.setText(\"MENU\");\n\t\t\n\t\tMenu menu = new Menu(shlMenu, SWT.BAR);\n\t\tshlMenu.setMenuBar(menu);\n\t\t\n\t\tMenuItem mnętmBookLists = new MenuItem(menu, SWT.NONE);\n\t\tmnętmBookLists.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\t//call booklist frame \n\t\t\t\tBookListFrame window = new BookListFrame();\n\t\t\t\twindow.open();\n\t\t\t\t\n\t\t\t}\n\t\t});\n\t\tmnętmBookLists.setImage(SWTResourceManager.getImage(MainMenu.class, \"/ikons/Business-Todo-List-icon.png\"));\n\t\tmnętmBookLists.setText(\"Book Lists\");\n\t\t\n\t\tMenuItem mnętmMemberList = new MenuItem(menu, SWT.NONE);\n\t\tmnętmMemberList.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\t//call memberlistframe\n\t\t\t\tMemberListFrame window = new MemberListFrame();\n\t\t\t\twindow.open();\n\t\t\t}\n\t\t});\n\t\tmnętmMemberList.setImage(SWTResourceManager.getImage(MainMenu.class, \"/ikons/Misc-User-icon.png\"));\n\t\tmnętmMemberList.setText(\"Member List\");\n\t\t\n\t\tMenuItem mnętmNewItem = new MenuItem(menu, SWT.NONE);\n\t\tmnętmNewItem.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\t//call rent list\n\t\t\t\tRentListFrame rlf=new RentListFrame();\n\t\t\t\trlf.open();\n\t\t\t}\n\t\t});\n\t\tmnętmNewItem.setImage(SWTResourceManager.getImage(MainMenu.class, \"/ikons/Time-And-Date-Calendar-icon.png\"));\n\t\tmnętmNewItem.setText(\"Rent List\");\n\t\t\n\t\tButton btnNewButton = new Button(shlMenu, SWT.NONE);\n\t\tbtnNewButton.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\t//call booksettingsframe\n\t\t\t\tBookSettingsFrame window = new BookSettingsFrame();\n\t\t\t\twindow.open();\n\t\t\t}\n\t\t});\n\t\tbtnNewButton.setForeground(SWTResourceManager.getColor(SWT.COLOR_INFO_BACKGROUND));\n\t\tbtnNewButton.setImage(SWTResourceManager.getImage(MainMenu.class, \"/ikons/Printing-Books-icon.png\"));\n\t\tbtnNewButton.setBounds(160, 176, 114, 112);\n\t\t\n\t\tButton btnNewButton_1 = new Button(shlMenu, SWT.NONE);\n\t\tbtnNewButton_1.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\t//call membersettingsframe\n\t\t\t\tMemberSettingsFrame window = new MemberSettingsFrame();\n\t\t\t\twindow.open();\n\t\t\t}\n\t\t});\n\t\tbtnNewButton_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_INFO_BACKGROUND));\n\t\tbtnNewButton_1.setImage(SWTResourceManager.getImage(MainMenu.class, \"/ikons/Add-User-icon.png\"));\n\t\tbtnNewButton_1.setBounds(367, 176, 114, 112);\n\t\t\n\t\tButton btnNewButton_2 = new Button(shlMenu, SWT.NONE);\n\t\tbtnNewButton_2.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tRentingFrame rf=new RentingFrame();\n\t\t\t\trf.open();\n\t\t\t}\n\t\t});\n\t\tbtnNewButton_2.setForeground(SWTResourceManager.getColor(SWT.COLOR_INFO_BACKGROUND));\n\t\tbtnNewButton_2.setImage(SWTResourceManager.getImage(MainMenu.class, \"/ikons/Business-Statistics-icon.png\"));\n\t\tbtnNewButton_2.setBounds(567, 176, 114, 112);\n\n\t}", "public Menu() {\n }", "public JMenu getRecentFilesMenu() {\n JMenu menu = new JMenu( \"Recent Files\" );\n String recent = \"\";\n try {\n recent = Constants.PREFS.get( Constants.RECENT_LIST, \"\" );\n }\n catch ( Exception e ) {} // NOPMD\n ActionListener al =\n new ActionListener() {\n public void actionPerformed( ActionEvent ae ) {\n JMenuItem item = ( JMenuItem ) ae.getSource();\n String filename = item.getText();\n File file = new File( filename );\n openBuildFile( file );\n }\n };\n StringTokenizer st = new StringTokenizer( recent, File.pathSeparator );\n while ( st.hasMoreTokens() ) {\n JMenuItem item = new JMenuItem( st.nextToken() );\n item.addActionListener( al );\n menu.add( item );\n }\n return menu;\n }", "private JMenu setupFileMenu(final JFrame theFrame,\n final MyBoardPanel theBoardPanel,\n final MyBoardPanel theSecondPanel) {\n final JMenu menu = new JMenu(\"File\");\n menu.setMnemonic(KeyEvent.VK_F);\n\n myNewGameItem.setMnemonic(KeyEvent.VK_N);\n myNewGameItem.addActionListener(new ActionListener() {\n \n @Override\n public void actionPerformed(final ActionEvent theEvent) {\n if (myPauseItem.isSelected()) {\n myPauseItem.setSelected(false);\n theBoardPanel.continueGame();\n theSecondPanel.continueGame();\n }\n theBoardPanel.startGame();\n theSecondPanel.startGame();\n }\n });\n \n myPauseItem.setMnemonic(KeyEvent.VK_P);\n myPauseItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y,\n ActionEvent.CTRL_MASK));\n myPauseItem.addActionListener(new ActionListener() {\n \n @Override\n public void actionPerformed(final ActionEvent theEvent) {\n if (myPauseItem.isSelected()) {\n theBoardPanel.pauseGame();\n theSecondPanel.pauseGame();\n } else {\n theBoardPanel.continueGame();\n theSecondPanel.continueGame();\n }\n theFrame.repaint();\n }\n });\n \n myEndGameItem.setMnemonic(KeyEvent.VK_E);\n myEndGameItem.addActionListener(new ActionListener() {\n \n @Override\n public void actionPerformed(final ActionEvent theEvent) {\n theBoardPanel.endGame(); \n theSecondPanel.endGame();\n theFrame.repaint();\n }\n });\n \n myQuitMenuItem.setMnemonic(KeyEvent.VK_Q);\n myQuitMenuItem.addActionListener(new ActionListener() {\n \n @Override\n public void actionPerformed(final ActionEvent theEvent) {\n theBoardPanel.quitGame();\n theSecondPanel.quitGame();\n theFrame.dispose();\n System.exit(0);\n }\n });\n menu.add(myNewGameItem);\n menu.add(myPauseItem);\n menu.add(myEndGameItem);\n menu.addSeparator();\n menu.add(myQuitMenuItem);\n return menu;\n }", "private void populateRecentMenu(){\r\n\t\trecentMenu.removeAll();\r\n\t\tString[] files = BibtexPrefs.getOpenedFiles();\r\n\t\trecentMenuItems = new JMenuItem[files.length];\r\n\t\tfor(int i = 0; i < files.length; i++){\r\n\t\t\trecentMenuItems[i] = new JMenuItem(files[i]);\r\n\t\t\trecentMenuItems[i].addActionListener(this);\r\n\t\t\trecentMenu.add(recentMenuItems[i]);\r\n\t\t}\r\n\t}", "private void createMenu(){\n \n menuBar = new JMenuBar();\n \n game = new JMenu(\"Rummy\");\n game.setMnemonic('R');\n \n newGame = new JMenuItem(\"New Game\");\n newGame.setMnemonic('N');\n newGame.addActionListener(menuListener);\n \n \n \n exit = new JMenuItem(\"Exit\");\n exit.setMnemonic('E');\n exit.addActionListener(menuListener); \n \n \n \n }", "private JMenuBar createMenuBar()\r\n {\r\n UIManager.put(\"Menu.selectionBackground\", new Color(0xDA,0xDD,0xED));\r\n UIManager.put(\"MenuItem.selectionForeground\", Color.LIGHT_GRAY);\r\n JMenuBar menuBar = new JMenuBar();\r\n JMenu menu = new JMenu(\"Fil\");\r\n UIManager.put(\"MenuItem.selectionBackground\", menu.getBackground());\r\n menuItemSave = new JMenuItem(\"Lagre\");\r\n UIManager.put(\"MenuItem.selectionBackground\", menuItemSave.getBackground());\r\n menuItemSave.setForeground(Color.LIGHT_GRAY);\r\n menuItemSave.setBorder(BorderFactory.createEmptyBorder());\r\n menuItemSave.setAccelerator(KeyStroke.getKeyStroke('S', Event.CTRL_MASK));\r\n menuItemSave.addActionListener(listener);\r\n menu.add(menuItemSave);\r\n menuItemPrint = new JMenuItem(\"Skriv ut\");\r\n menuItemPrint.setForeground(Color.LIGHT_GRAY);\r\n menuItemPrint.setBorder(BorderFactory.createEmptyBorder());\r\n menuItemPrint.setAccelerator(KeyStroke.getKeyStroke('P', Event.CTRL_MASK));\r\n menuItemPrint.addActionListener(listener);\r\n menu.add(menuItemPrint);\r\n menu.addSeparator();\r\n menuItemLogout = new JMenuItem(\"Logg av\");\r\n menuItemLogout.setForeground(Color.LIGHT_GRAY);\r\n menuItemLogout.setBorder(BorderFactory.createEmptyBorder());\r\n menuItemLogout.addActionListener(listener);\r\n menuItemLogout.setAccelerator(KeyStroke.getKeyStroke('L', Event.CTRL_MASK));\r\n menu.add(menuItemLogout);\r\n UIManager.put(\"MenuItem.selectionBackground\", new Color(0xDA,0xDD,0xED));\r\n UIManager.put(\"MenuItem.selectionForeground\", Color.BLACK);\r\n menuItemClose = new JMenuItem(\"Avslutt\");\r\n menuItemClose.setAccelerator(KeyStroke.getKeyStroke('A', Event.CTRL_MASK));\r\n menuItemClose.addActionListener(listener);\r\n menuBar.add(menu);\r\n menu.add(menuItemClose);\r\n JMenu menu2 = new JMenu(\"Om\");\r\n menuItemAbout = new JMenuItem(\"Om\");\r\n menuItemAbout.setAccelerator(KeyStroke.getKeyStroke('O', Event.CTRL_MASK));\r\n menuItemAbout.addActionListener(listener);\r\n menuItemAbout.setBorder(BorderFactory.createEmptyBorder());\r\n menu2.add(menuItemAbout);\r\n menuBar.add(menu2);\r\n \r\n return menuBar;\r\n }", "public JMenuItem createMenuItem(Action a) {\n JMenuItem item = new JMenuItem(a);\n decorateMenuComponent(item);\n return item;\n }", "@Override\n\t\t\tpublic void create(SwipeMenu menu) {\n\t\t\t\tSwipeMenuItem openItem = new SwipeMenuItem(getActivity()\n\t\t\t\t\t\t.getApplicationContext());\n\t\t\t\topenItem.setWidth(dp2px(60));\n\t\t\t\topenItem.setIcon(R.drawable.list_delete);\n\t\t\t\topenItem.setBackground(R.color.deep_pink);\n\t\t\t\tmenu.addMenuItem(openItem);\n\n\t\t\t\t// Edit Item\n\t\t\t\tSwipeMenuItem editItem = new SwipeMenuItem(getActivity()\n\t\t\t\t\t\t.getApplicationContext());\n\t\t\t\teditItem.setBackground(R.color.deep_yellow);\n\t\t\t\teditItem.setWidth(dp2px(60));\n\t\t\t\teditItem.setIcon(R.drawable.total_swipeedit);\n\t\t\t\tmenu.addMenuItem(editItem);\n\n\t\t\t}", "public ChessMenuBar() {\n String[] menuCategories = {\"File\", \"Options\", \"Help\"};\n String[] menuItemLists =\n {\"New game/restart,Exit\", \"Toggle graveyard,Toggle game log\",\n \"About\"};\n for (int i = 0; i < menuCategories.length; i++) {\n JMenu currMenu = new JMenu(menuCategories[i]);\n String[] currMenuItemList = menuItemLists[i].split(\",\");\n for (int j = 0; j < currMenuItemList.length; j++) {\n JMenuItem currItem = new JMenuItem(currMenuItemList[j]);\n currItem.addActionListener(new MenuListener());\n currMenu.add(currItem);\n }\n this.add(currMenu);\n }\n }", "@Test\n\tpublic void addMenu__wrappee__ChooseFileTest() throws Exception {\n\t\tif (Configuration.shufflerepeat &&\n\t\tConfiguration.featureamp&&\n\t\tConfiguration.playengine&&\n\t\tConfiguration.choosefile&&\n\t\tConfiguration.gui&&\n\t\tConfiguration.skins&&\n\t\tConfiguration.light&&\n\t\tConfiguration.filesupport&&\n\t\tConfiguration.showtime&&\n\t\tConfiguration.volumecontrol&&\n\t\tConfiguration.mute\n\t\t) {\t\n\t\t\tstart();\n\t\t\tWhitebox.invokeMethod(gui, \"addMenu__wrappee__ChooseFile\");\n\t\t\tJMenu menu = (JMenu) MemberModifier.field(Application.class, \"menu\").get(gui);\n\t\t\tassertNotNull(menu);\n\n\t\t}\n\t}", "private JMenuItem makeMenuItem(String name) {\n JMenuItem m = new JMenuItem(name);\n m.addActionListener(this);\n return m;\n }", "public void createMenu() {\n\t\tmenuBar.add(createGameMenuColumn());\n\t\tmenuBar.add(createTestsMenuColumn());\n\t\tmenuBar.add(createCheatsMenuColumn());\n\n\t\tparentMainView.setJMenuBar(menuBar);\n\t}", "private void makeMenuBar() {\n final int SHORTCUT_MASK =\n Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();\n\n JMenuBar menubar = new JMenuBar();\n setJMenuBar(menubar);\n\n JMenu menu;\n JMenuItem item;\n\n // create the File menu\n menu = new JMenu(\"File\");\n menubar.add(menu);\n\n item = new JMenuItem(\"Quit\");\n item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, SHORTCUT_MASK));\n item.addActionListener(e -> quit());\n menu.add(item);\n\n // create the Help menu\n menu = new JMenu(\"Help\");\n menubar.add(menu);\n\n item = new JMenuItem(\"About TalkBox...\");\n item.addActionListener(e -> showAbout());\n menu.add(item);\n }", "public static Menu createDocument(File file, Menu parent, String userName, String language) throws Exception {\r\n // extract content\r\n Parser parser = ParserFactory.getParser(file);\r\n String content = null;\r\n if (parser != null)\r\n content = parser.getContent();\r\n if (content == null)\r\n content = \"\";\r\n\r\n // store in database\r\n String filename = file.getName();\r\n Document doc = new Document();\r\n Version vers = new Version();\r\n Menu menu = new Menu();\r\n String ext = filename.substring(filename.lastIndexOf(\".\") + 1);\r\n ext = ext.toLowerCase();\r\n String name = \"\";\r\n if (parser != null) {\r\n if (parser.getTitle().length() == 0)\r\n name = filename.substring(0, filename.lastIndexOf(\".\"));\r\n else\r\n name = parser.getTitle();\r\n } else {\r\n name = filename;\r\n }\r\n menu.setMenuText(name);\r\n menu.setMenuParent(parent.getMenuId());\r\n\r\n // select a file icon based on the extension\r\n String icon = IconSelector.selectIcon(ext);\r\n menu.setMenuIcon(icon);\r\n\r\n menu.setMenuSort(0);\r\n menu.setMenuPath(parent.getMenuPath() + \"/\" + parent.getMenuId());\r\n menu.setMenuType(Menu.MENUTYPE_FILE);\r\n menu.setMenuHier(parent.getMenuHier() + 1);\r\n menu.setMenuRef(filename);\r\n for (MenuGroup mg : parent.getMenuGroups()) {\r\n menu.getMenuGroups().add(mg);\r\n }\r\n\r\n MenuDAO menuDao = (MenuDAO) Context.getInstance().getBean(MenuDAO.class);\r\n menuDao.store(menu);\r\n\r\n doc.setMenu(menu);\r\n doc.setDocName(name);\r\n doc.setDocDate(DateBean.toCompactString());\r\n doc.setDocPublisher(userName);\r\n doc.setDocStatus(Document.DOC_CHECKED_IN);\r\n doc.setDocType(filename.substring(filename.lastIndexOf(\".\") + 1));\r\n doc.setDocVersion(\"1.0\");\r\n doc.setSource(\"\");\r\n if (parser != null) {\r\n doc.setSourceAuthor(parser.getAuthor());\r\n String srcDate = DateBean.toCompactString(parser.getSourceDate(), language);\r\n if (srcDate != null)\r\n doc.setSourceDate(srcDate);\r\n String keywords = parser.getKeywords();\r\n if (keywords != null && keywords.length() > 0) {\r\n DocumentDAO docDao = (DocumentDAO) Context.getInstance().getBean(DocumentDAO.class);\r\n doc.setKeywords(docDao.toKeywords(keywords));\r\n }\r\n }\r\n doc.setSourceType(\"\");\r\n doc.setCoverage(\"\");\r\n doc.setLanguage(language);\r\n\r\n /* insert initial version 1.0 */\r\n vers.setVersion(\"1.0\");\r\n vers.setVersionComment(\"\");\r\n vers.setVersionDate(DateBean.toCompactString());\r\n vers.setVersionUser(userName);\r\n doc.addVersion(vers);\r\n DocumentDAO docDao = (DocumentDAO) Context.getInstance().getBean(DocumentDAO.class);\r\n docDao.store(doc);\r\n\r\n // create history entry\r\n createHistoryEntry(doc.getDocId(), userName, History.STORED);\r\n\r\n // store document in the repository\r\n SettingsConfig settings = (SettingsConfig) Context.getInstance().getBean(SettingsConfig.class);\r\n String path = settings.getValue(\"docdir\");\r\n if (!path.endsWith(File.pathSeparator))\r\n path += \"/\";\r\n path += menu.getMenuPath() + \"/\" + doc.getMenuId();\r\n FileBean.createDir(path);\r\n FileBean.copyFile(file.getAbsolutePath(), path + \"/\" + filename);\r\n\r\n /* create search index entry */\r\n String lang = doc.getLanguage();\r\n Indexer index = (Indexer) Context.getInstance().getBean(Indexer.class);\r\n int luceneId = index.addFile(new File(path + \"/\" + filename), doc, content, language);\r\n SearchDocument searchDoc = new SearchDocument();\r\n searchDoc.setLuceneId(luceneId);\r\n searchDoc.setMenuId(menu.getMenuId());\r\n\r\n String luceneIndex = new Locale(lang).getDisplayLanguage(Locale.ENGLISH).toLowerCase();\r\n if (StringUtils.isEmpty(luceneIndex))\r\n luceneIndex = \"english\";\r\n\r\n searchDoc.setIndex(luceneIndex);\r\n\r\n SearchDocumentDAO searchDocDao = (SearchDocumentDAO) Context.getInstance().getBean(SearchDocumentDAO.class);\r\n searchDocDao.store(searchDoc);\r\n\r\n //Update file size\r\n menuDao.store(menu);\r\n \r\n return menu;\r\n }", "private void constructMenuItems()\n\t{\n\t\tthis.saveImageMenuItem = ComponentGenerator.generateMenuItem(\"Save Image\", this, KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));\n\t\tthis.quitMenuItem = ComponentGenerator.generateMenuItem(\"Quit\", this, KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));\n\t\tthis.undoMenuItem = ComponentGenerator.generateMenuItem(\"Undo\", this, KeyStroke.getKeyStroke(KeyEvent.VK_Z, ActionEvent.CTRL_MASK));\n\t\tthis.redoMenuItem = ComponentGenerator.generateMenuItem(\"Redo\", this, KeyStroke.getKeyStroke(KeyEvent.VK_Y, ActionEvent.CTRL_MASK));\n\t\tthis.removeImageMenuItem = ComponentGenerator.generateMenuItem(\"Remove Image from Case\", this);\n\t\tthis.antiAliasMenuItem = ComponentGenerator.generateMenuItem(\"Apply Anti Aliasing\", this);\n\t\tthis.brightenMenuItem = ComponentGenerator.generateMenuItem(\"Brighten by 10%\", this);\n\t\tthis.darkenMenuItem = ComponentGenerator.generateMenuItem(\"Darken by 10%\", this);\n\t\tthis.grayscaleMenuItem = ComponentGenerator.generateMenuItem(\"Convert to Grayscale\", this);\n\t\tthis.resizeMenuItem = ComponentGenerator.generateMenuItem(\"Resize Image\", this);\n\t\tthis.cropMenuItem = ComponentGenerator.generateMenuItem(\"Crop Image\", this);\n\t\tthis.rotate90MenuItem = ComponentGenerator.generateMenuItem(\"Rotate Image 90\\u00b0 Right\", this);\n\t\tthis.rotate180MenuItem = ComponentGenerator.generateMenuItem(\"Rotate Image 180\\u00b0 Right\", this);\n\t\tthis.rotate270MenuItem = ComponentGenerator.generateMenuItem(\"Rotate Image 270\\u00b0 Right\", this);\n\t}", "public Menu()\n {\n \n }", "private JMenuBar createMenuBar()\n\t{\n\t\tJMenuBar menBar = new JMenuBar();\n\t\tJMenu men = new JMenu();\n\t\tmen.setText(\"Menu\");\n\t\tJMenuItem menSettings = new JMenuItem();\n\t\tmenSettings.setText(\"Settings\");\n\t\tmenSettings.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e)\n\t\t{\n\t\t\tsettingsWindow.setVisible(true);\n\t\t}});\n\t\tmen.add(menSettings);\n\t\tmenBar.add(men);\n\t\treturn menBar;\n\t}", "@Test\n\tpublic void addMenu__wrappee__ChooseFile_2Test() throws Exception {\n\t\tif (Configuration.shufflerepeat &&\n\t\t\t\tConfiguration.featureamp&&\n\t\t\t\tConfiguration.playengine&&\n\t\t\t\t!Configuration.choosefile&&\n\t\t\t\tConfiguration.gui&&\n\t\t\t\tConfiguration.skins&&\n\t\t\t\tConfiguration.light) {\t\n\t\t\tstart();\n\t\t\tWhitebox.invokeMethod(gui, \"addMenu__wrappee__ChooseFile\");\n\t\t\tJMenu menu = (JMenu) MemberModifier.field(Application.class, \"menu\").get(gui);\n\t\t\tassertNotNull(menu);\n\t\t\t\n\t\t}\n\t}", "private MenuManager createEditMenu() {\n\t\tMenuManager menu = new MenuManager(\"&Edition\", Messages.getString(\"IU.Strings.40\")); //$NON-NLS-1$ //$NON-NLS-2$\n\t\tmenu.add(new GroupMarker(Messages.getString(\"IU.Strings.41\"))); //$NON-NLS-1$\n\n\t\tmenu.add(getAction(ActionFactory.UNDO.getId()));\n\t\tmenu.add(getAction(ActionFactory.REDO.getId()));;\n\n\t\tmenu.add(new GroupMarker(IWorkbenchActionConstants.UNDO_EXT));\n\t\tmenu.add(new Separator());\n\t\tmenu.add(getAction(ActionFactory.CUT.getId()));\n\t\tmenu.add(getAction(ActionFactory.COPY.getId()));\n\t\tmenu.add(getAction(ActionFactory.PASTE.getId()));\n\t\tmenu.add(new GroupMarker(IWorkbenchActionConstants.CUT_EXT));\n\t\tmenu.add(new Separator());\n\t\tmenu.add(getAction(ActionFactory.DELETE.getId()));\n\t\tmenu.add(getAction(ActionFactory.SELECT_ALL.getId()));\n\t\tmenu.add(getAction(ActionFactory.FIND.getId()));\n\t\tmenu.add(new Separator());\n\t\tmenu.add(getAction(ActionFactory.PREFERENCES.getId()));\n\t\treturn menu;\n\t}", "private MenuBar getMenuBar() {\n MenuBar menuBar = new MenuBar();\n // setup File menu\n Menu fileMenu = new Menu(\"File\");\n fileMenu.getItems().addAll(\n getMenuItem(\"New\", event -> startGame()),\n getMenuItem(\"Quit\", event -> quitGame())\n );\n\n // setup Level menu\n Menu levelMenu = new Menu(\"Level\");\n\n // for radio menu items, ensures only\n // one is selected at a time.\n ToggleGroup group = new ToggleGroup();\n\n levelMenu.getItems().addAll(\n getRadioMenuItem(\n \"Beginner - 9x9\",\n true,\n group,\n event -> setGameLevel(GameLevel.BEGINNER)\n ),\n\n getRadioMenuItem(\n \"Intermediate - 16x16\",\n false,\n group,\n event -> setGameLevel(GameLevel.INTERMEDIATE)\n ),\n\n getRadioMenuItem(\n \"Expert - 24x24\",\n false,\n group,\n event -> setGameLevel(GameLevel.EXPERT))\n );\n\n menuBar.getMenus().addAll(fileMenu, levelMenu);\n\n return menuBar;\n }", "@Override\n public boolean onCreateOptionsMenu(Menu menu) {\n getMenuInflater().inflate(R.menu.menu_file_operations, menu);\n return true;\n }", "void ajouterMenu(){\r\n\t\t\tJMenuBar menubar = new JMenuBar();\r\n\t \r\n\t JMenu file = new JMenu(\"File\");\r\n\t file.setMnemonic(KeyEvent.VK_F);\r\n\t \r\n\t JMenuItem eMenuItemNew = new JMenuItem(\"Nouvelle Partie\");\r\n\t eMenuItemNew.addActionListener(new ActionListener() {\r\n\t @Override\r\n\t public void actionPerformed(ActionEvent event) {\r\n\t \t\r\n\t \t\t\r\n\t \t\t\r\n\t \tnew NouvellePartie();\r\n\t }\r\n\t });\r\n\t file.add(eMenuItemNew);\r\n\t \r\n\t JMenuItem eMenuItemFermer = new JMenuItem(\"Fermer\");\r\n\t eMenuItemFermer.setMnemonic(KeyEvent.VK_E);\r\n\t eMenuItemFermer.setToolTipText(\"Fermer l'application\");\r\n\t \r\n\t eMenuItemFermer.addActionListener(new ActionListener() {\r\n\t @Override\r\n\t public void actionPerformed(ActionEvent event) {\r\n\t System.exit(0);\r\n\t }\r\n\t });\r\n\r\n\t file.add(eMenuItemFermer);\r\n\r\n\t menubar.add(file);\r\n\t \r\n\t JMenu aide = new JMenu(\"?\");\r\n\t JMenuItem eMenuItemRegle = new JMenuItem(\"Règles\");\r\n\t aide.add(eMenuItemRegle);\r\n\t menubar.add(aide);\r\n\r\n\t final String regles=\"<html><p>Le but est de récupérer les 4 objets Graal puis de retourner au château.</p>\"\t\r\n\t +\"<p>Après avoir récupéré un objet, chaque déplacement vous enlève autant de vie que le poids de l'objet</p></html>\";\r\n\t eMenuItemRegle.addActionListener(new ActionListener() {\r\n\t @Override\r\n\t public void actionPerformed(ActionEvent event) {\r\n\t \t//default title and icon\r\n\t \t\t\tJOptionPane.showMessageDialog(gameFrame,\r\n\t \t\t\t regles,\"Règles du jeu\", JOptionPane.INFORMATION_MESSAGE);\r\n\t \t\t\t\r\n\t }\r\n\t });\r\n\t \t\r\n\t\t\t\r\n\t this.setJMenuBar(menubar);\t\r\n\t\t}", "public JMenuBar buildMenu()\n\t{\n\t\tJMenu menuItem1 = new JMenu(\"Project\"); //Create a menu named \"Project\"\n\t JMenu menuItem2 = new JMenu(\"File\"); //Create a menu named \"File\"\n\t //JMenu menuItem3 = new JMenu(\"Help\"); //Create a menu named \"Help\"\n\t JMenu menuItem4 = new JMenu(\"Execute\"); //Create a menu named \"Execute\"\n\t \n\t //Add each menu to the menu bar\n\t menuBar.add(menuItem1); \n\t menuBar.add(menuItem2);\n\t // menuBar.add(menuItem3);\n\t menuBar.add(menuItem4);\n\t \n\t //Create a new menu item called \"Open Project\"\n\t JMenuItem projectOpen = new JMenuItem(\"Open Project\"); \n\t //Create an action listener for that menu item\n\t projectOpen.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) \n {\n try \n {\n \t\tdisplayText(f.closeFile()); //Clear the current text open in the editor\n \t\tcurrentFile.setLength(0); //Clear the name of the currently opened project\n\t \tresetFileTitle(); //Reset the text editor window title to the default \n\t\t\t\t\tp.openProject(saveDirectory, currentProject); //Calls the openProject function\n\t projectPropertiesDisplay(); //Reset the project properties window to display the open projects files\n\t\t\t\t\tresetProjectTitle(); //Reset the projectPoperties title to the name of the open project\n\t\t\t\t} \n catch (WorkspaceFolderException e1) \n {}\n }\n });\n\t \n\t //Create a new menu item called \"Close Project\"\n\t JMenuItem projectClose = new JMenuItem(\"Close Project\");\n\t //Create an action listener for that menu item\n\t projectClose.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) \n {\n \t\tdisplayText(f.closeFile()); //Clear the current text open in the editor\n \t\tcurrentFile.setLength(0); //Clear the name of the currently opened project\n \tresetFileTitle(); //Reset the text editor window title to the default\n p.closeProject(currentProject);\n\t\t\t\tresetProjectTitle();\n projectPropertiesDisplay(); //Reset the project properties window to display the open projects files \n }\n });\n\t \n\t //Create a new menu item called \"Create New Project\"\n\t JMenuItem projectCreateNew = new JMenuItem(\"Create New Project\"); \n\t //Create an action listener for that menu item\n\t projectCreateNew.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) \n {\n \ttry \n \t{\n \t\tdisplayText(f.closeFile()); //Clear the current text open in the editor\n \t\tcurrentFile.setLength(0); //Clear the name of the currently opened project\n\t \tresetFileTitle(); //Reset the text editor window title to the default\n\t p.closeProject(currentProject);\n\t\t\t\t\tp.createNewProject(saveDirectory, currentProject); //Call the create new project function \n\t\t\t\t\tresetProjectTitle(); //Reset the project properties title to the newly created project name\n\t projectPropertiesDisplay(); //Reset the project properties window to display the open projects files\n\t\t\t\t} \n \tcatch (IOException e1) \n \t{} \n \tcatch (NoProjectNameException e1) \n \t{} \n \tcatch (WorkspaceFolderException e1) \n \t{}\n }\n });\n\t \n\t //Add the project menu items\n\t menuItem1.add(projectOpen); //Add the new menu items to the \"Project\" menu item\n\t menuItem1.add(projectClose);\n\t menuItem1.add(projectCreateNew);\n\t \n\t //Create a new menu item called \"Save\"\n\t JMenuItem fileSave = new JMenuItem(\"Save\");\n\t //Create an action listener for that menu item\n\t fileSave.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) \n {\n \ttry \n \t{\n\t\t\t\t\tf.saveFile(ta, currentProject, currentFile); //Call the saveFile function\n\t\t\t\t} \n \tcatch (IOException e1) \n \t{} \n \tcatch (NoFileToSaveException e1) \n \t{} \n \tcatch (ProjectNotOpenException e1) \n \t{}\n }\n });\n\n\t //Create a new menu item called \"Close\"\n\t JMenuItem fileClose = new JMenuItem(\"Close\");\n\t //Create an action listener for that menu item\n\t fileClose.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) \n {\n \t\tdisplayText(f.closeFile()); //Clear the current text open in the editor\n \t\tcurrentFile.setLength(0); //Clear the name of the currently opened project\n \tresetFileTitle(); //Reset the text editor window title to the default \n }\n });\n\t \n\t //Create a new menu item called \"Create New\"\n\t JMenuItem fileCreateNew = new JMenuItem(\"Create New\"); \n\t //Create an action listener for that menu item\n\t fileCreateNew.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) \n {\n try \n {\n \t\tcurrentFile.setLength(0); //Clear the name of the currently opened project\n\t\t\t\t\tf.createNewFile(currentProject, currentFile); //Call the create a new file function\n\t\t\t\t\tprojectPropertiesDisplay(); //Reset the project properties display\n\t\t\t\t\tresetFileTitle(); //Reset the text editor window title to the newly created file\n\t\t\t\t} \n catch (ProjectNotOpenException e1) \n {} \n catch (IOException e1) \n {} \n catch (NoFileNameException e1) \n {} \n catch (FileExistsException e1) \n {}\n }\n });\n\t \n\t //Create a new menu item called \"Remove\"\n\t JMenuItem fileRemove = new JMenuItem(\"Remove\");\n\t //Create an action listener for that menu item\n\t fileRemove.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) \n {\n \ttry \n \t{\n\t\t\t\t\tdisplayText(f.removeFile(currentProject, currentFile)); //Clear the text on the text editor window\n\t\t\t\t\tprojectPropertiesDisplay(); //Reset the project properties display window\n \t\tcurrentFile.setLength(0); //Clear the name of the currently opened project\n\t\t\t\t\tresetFileTitle(); //Reset the text editor window title\n\t\t\t\t} \n \tcatch (NoFileNameException e1) \n \t{} \n \tcatch (ProjectNotOpenException e1) \n \t{}\n }\n });\n\t \n\t //Add the File menu items\n\t menuItem2.add(fileSave);\n\t menuItem2.add(fileClose);\n\t menuItem2.add(fileCreateNew);\n\t menuItem2.add(fileRemove);\n\t \n\t //This is the action listener for the \"Execute\" menu button\n\t menuItem4.addMouseListener(new MouseListener() \n\t {\n\t \t@Override\n\t public void mouseReleased(MouseEvent e) {}\n\n\t @Override\n\t public void mousePressed(MouseEvent e) \n\t {\n\t try\n\t \t\t{\n\t \tf.saveFile(ta, currentProject, currentFile); //Save the current open file\n\t \tcosoleText();\n\t \t\t}\n\t \t\tcatch(ProjectNotOpenException e1)\n\t \t\t{}\n \tcatch (NoFileToSaveException e1) \n \t{} \n\t catch (IOException e1) \n\t {} \n\t }\n\t @Override\n\t public void mouseExited(MouseEvent e) {}\n\t @Override\n\t public void mouseEntered(MouseEvent e) {}\n\t @Override\n\t public void mouseClicked(MouseEvent e) {}\n\t });\n\t \n\t return menuBar;\n\t}", "private void startMenuBar() no topo\n {\n //Inicializa a barra de menus\n JMenuBar menuBar = new JMenuBar();\n JMenu menuFile = new JMenu(\"File\");\n JMenu menuProgram = new JMenu(\"Program\");\n JMenuItem fileOpen = new JMenuItem(\"Open\");\n fileOpen.addActionListener(new ActionListener(){\n public void actionPerformed(ActionEvent e)\n {\n setFileName();\n }\n });\n menuFile.add(fileOpen);\n \n JMenuItem programClose = new JMenuItem(\"Close\");\n programClose.addActionListener(new ActionListener(){\n public void actionPerformed(ActionEvent e)\n {\n System.exit(0);\n }\n });\n menuProgram.add(programClose);\n \n menuBar.add(menuFile);\n menuBar.add(menuProgram);\n mainFrame.add(menuBar, BorderLayout.PAGE_START);\n }", "private void setMenu() {\n\n if (tree.isEmpty() || !treeGrid.anySelected()) {\n mainMenu.setItems(newMenuItem, new MenuItemSeparator(), settingMenuItem, searchMenuItem, correlationDiagramMenuItem, progMenuItem);\n } else if (treeGrid.getSelectedRecord() == null) {\n mainMenu.setItems(renameMenuItem, searchMenuItem, correlationDiagramMenuItem, progMenuItem);\n } else if (treeGrid.getSelectedRecords().length > 1) {\n ListGridRecord[] selectedNode = treeGrid.getSelectedRecords();\n if (isSameExtension(selectedNode, Extension.FP)) {\n mainMenu.setItems(deleteMenu, copyMenuItem, pasteMenuItem, downloadMenuItem, searchMenuItem, progMenuItem, exportMenuItem);\n } else if (isSameExtension(selectedNode, Extension.FPS)) {\n mainMenu.setItems(newFPItem, deleteMenu, copyMenuItem, pasteMenuItem, downloadMenuItem, searchMenuItem, progMenuItem);\n } else if (isSameExtension(selectedNode, Extension.BPS)) {\n mainMenu.setItems(newBPItem, deleteMenu, copyMenuItem, pasteMenuItem, downloadMenuItem, searchMenuItem, progMenuItem);\n } else if (isSameExtension(selectedNode, Extension.SCSS)) {\n mainMenu.setItems(newSCSItem, deleteMenu, copyMenuItem, pasteMenuItem, downloadMenuItem, searchMenuItem, progMenuItem);\n } else {\n mainMenu.setItems(deleteMenu, copyMenuItem, pasteMenuItem, downloadMenuItem, searchMenuItem, progMenuItem);\n }\n } else if (tree.isFolder(treeGrid.getSelectedRecord())) {\n mainMenu.setItems(newMenuItem, deleteMenu, renameMenuItem, copyMenuItem, pasteMenuItem, searchMenuItem, correlationDiagramMenuItem, progMenuItem, downloadMenuItem,\n copyPathMenuItem);\n } else {\n FileTreeNode selectedNode = (FileTreeNode) treeGrid.getSelectedRecord();\n VMResource resource = selectedNode.getResource();\n if (resource instanceof VMDirectory) {\n return;\n }\n Extension extension = ((VMFile) resource).getExtension();\n if (extension == null) {\n mainMenu.setItems(openWithMenuItem, deleteMenu, renameMenuItem, historyMenuItem, copyMenuItem, pasteMenuItem, downloadMenuItem, searchMenuItem,\n correlationDiagramMenuItem, copyPathMenuItem);\n } else\n switch (extension) {\n case ARC:\n mainMenu.setItems(newBPSItem, deleteMenu, renameMenuItem, historyMenuItem, copyMenuItem, pasteMenuItem, downloadMenuItem, searchMenuItem,\n correlationDiagramMenuItem, copyPathMenuItem);\n break;\n case FM:\n mainMenu.setItems(newFMCItem, newTCItem, newFPSItem, deleteMenu, renameMenuItem, historyMenuItem, copyMenuItem, pasteMenuItem, downloadMenuItem, searchMenuItem,\n correlationDiagramMenuItem, copyPathMenuItem);\n break;\n case FMC:\n mainMenu.setItems(deleteMenu, renameMenuItem, historyMenuItem, downloadMenuItem, searchMenuItem, correlationDiagramMenuItem, copyPathMenuItem);\n break;\n case TC:\n mainMenu.setItems(newTCItem, newFPSItem, deleteMenu, renameMenuItem, historyMenuItem, downloadMenuItem, searchMenuItem, correlationDiagramMenuItem,\n copyPathMenuItem);\n break;\n case FPS:\n mainMenu.setItems(newFPItem, deleteMenu, renameMenuItem, historyMenuItem, copyMenuItem, pasteMenuItem, downloadMenuItem, searchMenuItem,\n correlationDiagramMenuItem, copyPathMenuItem);\n break;\n case FP:\n mainMenu.setItems(newSPQLItem, deleteMenu, renameMenuItem, historyMenuItem, copyMenuItem, pasteMenuItem, downloadMenuItem, searchMenuItem, exportMenuItem,\n correlationDiagramMenuItem, copyPathMenuItem);\n break;\n case BPS:\n mainMenu.setItems(newBPItem, deleteMenu, renameMenuItem, historyMenuItem, copyMenuItem, pasteMenuItem, downloadMenuItem, searchMenuItem,\n correlationDiagramMenuItem, copyPathMenuItem);\n break;\n case BP:\n mainMenu.setItems(newSPQLItem, deleteMenu, renameMenuItem, historyMenuItem, downloadMenuItem, searchMenuItem, correlationDiagramMenuItem, copyPathMenuItem);\n break;\n case SCSS:\n mainMenu.setItems(newSCSItem, deleteMenu, renameMenuItem, historyMenuItem, copyMenuItem, pasteMenuItem, downloadMenuItem, searchMenuItem,\n correlationDiagramMenuItem, copyPathMenuItem);\n break;\n case SCS:\n mainMenu.setItems(newSPQLItem, deleteMenu, renameMenuItem, historyMenuItem, copyMenuItem, pasteMenuItem, downloadMenuItem, searchMenuItem,\n correlationDiagramMenuItem, copyPathMenuItem);\n break;\n default:\n mainMenu.setItems(deleteMenu, renameMenuItem, historyMenuItem, copyMenuItem, pasteMenuItem, downloadMenuItem, searchMenuItem, correlationDiagramMenuItem,\n copyPathMenuItem);\n break;\n }\n }\n }" ]
[ "0.86060727", "0.85546535", "0.8531015", "0.8503654", "0.8215589", "0.7879194", "0.78359705", "0.7830032", "0.774318", "0.77031595", "0.76911926", "0.75901765", "0.7488538", "0.72604215", "0.72503287", "0.7217835", "0.7163683", "0.7148291", "0.7115539", "0.7095036", "0.70799387", "0.70735854", "0.70636135", "0.7033063", "0.6970807", "0.69636095", "0.68388426", "0.68350655", "0.68253165", "0.67740303", "0.67446035", "0.6733533", "0.6717203", "0.6707013", "0.66814524", "0.66661924", "0.66568875", "0.66132003", "0.66003394", "0.6567502", "0.65213835", "0.64832914", "0.6451541", "0.64430976", "0.6435812", "0.64262646", "0.6416343", "0.6399827", "0.63926315", "0.6313669", "0.6293374", "0.6275174", "0.62621295", "0.6230858", "0.6226025", "0.6210508", "0.6181007", "0.6171354", "0.61693996", "0.6158941", "0.61496955", "0.6142267", "0.613621", "0.61288923", "0.61250144", "0.6124297", "0.6091211", "0.6090801", "0.60805273", "0.6072737", "0.6053313", "0.60505694", "0.60341924", "0.60332006", "0.60229707", "0.60215473", "0.60195065", "0.6016793", "0.6014801", "0.600657", "0.5993939", "0.5993354", "0.59904695", "0.5989893", "0.59864557", "0.59863174", "0.59837073", "0.5983465", "0.5977693", "0.5966266", "0.59571224", "0.59569865", "0.5950299", "0.5940048", "0.59306115", "0.5925008", "0.5924971", "0.5920366", "0.5920292", "0.5918155" ]
0.7295673
13
Handles the ActionEvent when one of the menu items is selected.
public void actionPerformed(ActionEvent e) { JMenuItem menuItem = (JMenuItem) e.getSource(); String itemText = menuItem.getName(); if (itemText.equalsIgnoreCase("save")) { } else if (itemText.equalsIgnoreCase("print")) { } else if (itemText.equalsIgnoreCase("close")) { this.parentWindow.setVisible(false); this.parentWindow.dispose(); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Override\n\t\t\tpublic void menuSelected(MenuItem selectedItem)\n\t\t\t{\n\n\t\t\t}", "@Override\n\t\t\tpublic void menuSelected(MenuItem selectedItem)\n\t\t\t{\n\n\t\t\t}", "private void optionSelected(MenuActionDataItem action){\n \t\tString systemAction = action.getSystemAction();\n \t\tif(!systemAction.equals(\"\")){\n \t\t\t\n \t\t\tif(systemAction.equals(\"back\")){\n \t\t\t\tonBackPressed();\n \t\t\t}else if(systemAction.equals(\"home\")){\n \t\t\t\tIntent launchHome = new Intent(this, CoverActivity.class);\t\n \t\t\t\tstartActivity(launchHome);\n \t\t\t}else if(systemAction.equals(\"tts\")){\n \t\t\t\ttextToSearch();\n \t\t\t}else if(systemAction.equals(\"search\")){\n \t\t\t\tshowSearch();\n \t\t\t}else if(systemAction.equals(\"share\")){\n \t\t\t\tshowShare();\n \t\t\t}else if(systemAction.equals(\"map\")){\n \t\t\t\tshowMap();\n \t\t\t}else\n \t\t\t\tLog.e(\"CreateMenus\", \"No se encuentra el el tipo de menu: \" + systemAction);\n \t\t\t\n \t\t}else{\n \t\t\tNextLevel nextLevel = action.getNextLevel();\n \t\t\tshowNextLevel(this, nextLevel);\n \t\t\t\n \t\t}\n \t\t\n \t}", "@Override\n public void menuSelected(MenuEvent e) {\n \n }", "@Override\n\tpublic void menuSelected(MenuEvent e) {\n\n\t}", "public void selected(String action);", "@Override\n public boolean onMenuItemSelected(int featureId, MenuItem item) {\n int lSelectedItemID = item.getItemId(); // 액션 메뉴 아이디 확인함.\n if(lSelectedItemID == R.id.action_example){\n // To-do something\n }\n return super.onMenuItemSelected(featureId, item);\n }", "@Override\n\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\teventHandler.invoke(new HarvestSelectedEvent());\n\t\t}", "@Override\n public void selectionChanged(SelectionChangedEvent event) {\n Iterator<String> iterator = selectionActions.iterator();\n while (iterator.hasNext()) {\n updateAction(iterator.next());\n }\n }", "@Override\n\tpublic boolean onMenuItemSelected(int featureId, MenuItem item) {\n\t\tOptionsMenu.selectItem(item,getApplicationContext());\n\t\treturn super.onMenuItemSelected(featureId, item);\n\t}", "public void menuItemClicked( Menu2DEvent e );", "public void menuClicked(MenuItem menuItemSelected);", "@Override\n\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\tguiManager.getGameController().processMenuInput(MENU_ITEM.MNU_LEVEL_CHOOSE);\n\t\t\t\t}", "@Override\r\n\tpublic void onMenuItemSelected(MenuItem item) {\n\r\n\t}", "@Override\n\tpublic boolean onOptionsItemSelected(MenuItem item)\n\t{\n\t\tsuper.onOptionsItemSelected(item);\n\t\treturn visitor.handleMenuItemSelection(item);\n\t}", "@Override\r\npublic void menuSelected(MenuEvent arg0) {\n\t\r\n}", "public void selectionChanged(Action item);", "private void handleSelect(MouseEvent event) {\n\t\tWidget widget = tree.getItem(new Point(event.x, event.y));\n\t\tif (!(widget instanceof TreeItem))\n\t\t\treturn;\n\t\tTreeItem item = (TreeItem) widget;\n\t\tObject o = item.getData();\n\t\tif (o == null)\n\t\t\treturn;\n\t\ttry {\n\t\t\tthis.action.handleAction(o);\n\t\t} catch (ApplicationException e) {\n\t\t\tGUI.getStatusBar().setErrorText(e.getMessage());\n\t\t}\n\t}", "public void selectOneMenuListener(ValueChangeEvent event) {\n\t Object newValue = event.getNewValue(); \n\t //The rest of your processing logic goes here...\n\t}", "public void toSelectingAction() {\n }", "void onMenuItemClicked();", "abstract public boolean cabOnMenuItemClicked(ActionMode mode, MenuItem item);", "@Override\n public void actionPerformed(ActionEvent e) {\n MenuItemCommand command = menuCommandHandler.getCommand(e.getActionCommand());\n if (command != null) {\n command.execute();\n return;\n }\n command = menuCommandHandler.getCommand(MenuItem.findMenuItem(e.getActionCommand()));\n if (command != null) command.execute();\n }", "@Override\n\tpublic boolean onMenuItemSelected(int featureId, MenuItem item) {\n\t\treturn super.onMenuItemSelected(featureId, item);\n\t}", "public void menuSelected(MenuEvent evt) {\n JMenu source = (JMenu) evt.getSource();\n\n if (source.getText().equals(\"View...\")) {\n ((JMenuItem) source).setSelected(false);\n }\n }", "@Override\r\n\tpublic boolean onOptionsItemSelected(MenuItem item) {\r\n\t\treturn onMenuItemSelected(item.getItemId());\r\n\t}", "@Override\n public boolean onActionItemClicked(ActionMode mode, MenuItem item) {\n\n\n return true;\n }", "@Override\n\t\t\tpublic void actionPerformed(final ActionEvent evt) {\n\t\t\t\tif (evt.getSource() == jMenuItem9) {\n\t\t\t\t\tSystem.out.println(\"Selected: \"\n\t\t\t\t+ evt.getActionCommand());\n\t\t\t\t\t/*\n\t\t\t\t\t((Echiquier) panelChess\n\t\t\t\t\t.getComponents()[0])\n\t\t\t\t\t.setLightColor(Color.black);*/\n\t\t\t\t}\n\t\t\t}", "protected void ACTION_B_SELECT(ActionEvent arg0) {\n\t\tchoseInterface();\r\n\t}", "public void actionPerformed(ActionEvent e)\n\t{\n\t\tJMenuItem mi = (JMenuItem) e.getSource();\n\t\tif (mi.equals(itemNew))\n\t\t\tnewProject();\n\t\tif (mi.equals(itemOpen))\n\t\t\topenProject();\n\t\tif (mi.equals(itemClose))\n\t\t\tcloseFrame();\n\t}", "public void menuSelected (MenuEvent event) {\n TreeEditorPanel panel = (TreeEditorPanel)SwingUtilities.getAncestorOfClass(\n TreeEditorPanel.class, getFocusOwner());\n if (panel != null) {\n edit.getItem(CUT_INDEX).setAction(panel.getCutAction());\n edit.getItem(CUT_INDEX + 1).setAction(panel.getCopyAction());\n edit.getItem(CUT_INDEX + 2).setAction(panel.getPasteAction());\n edit.getItem(CUT_INDEX + 3).setAction(panel.getDeleteAction());\n } else {\n restoreActions();\n }\n }", "@Override\n\t\t\tpublic void itemStateChanged(ItemEvent e) {\n\t\t\t\tif(e.getStateChange() == ItemEvent.SELECTED){\n\t\t\t\t\tint box_index = namedaction_ComboBox.getSelectedIndex();\n\t\t\t\t\tNode n = rm.applySelectionCases(rule_namedaction_node, box_index);\n\t\t\t\t\trule_namedaction_node.replace(n);\n\t\t\t\t}\n\t\t\t}", "@Override\n public void menuDeselected(MenuEvent e) {\n\n }", "@Override\n public void actionPerformed(ActionEvent event) {\n String buttonName = ((JMenuItem) event.getSource()).getText();\n if (buttonName.equals(\"About\")) {\n aboutHandler();\n } else if (buttonName.equals(\"New game/restart\")) {\n restartHandler();\n } else if (buttonName.equals(\"Toggle game log\")) {\n toggleGameLogHandler();\n } else if (buttonName.equals(\"Exit\")) {\n exitHandler();\n } else {\n toggleGraveyardHandler();\n }\n }", "@Override\n public void onClick(View view) {\n listener.onMenuButtonSelected(view.getId());\n }", "private void doSelect(MouseEvent e) {\n if (e != null && e.getClickCount() > 1)\n doOK();\n }", "@Override\n\t\t\tpublic void actionPerformed(final ActionEvent evt) {\n\t\t\t\tif (evt.getSource() == jMenuItem7) {\n\t\t\t\t\tSystem.out.println(\"Selected: \"\n\t\t\t\t+ evt.getActionCommand());\n\t\t\t\t\t((Echiquier) panelChess\n\t\t\t\t\t\t.getComponents()[0]).setMode(2);\n\t\t\t\t}\n\t\t\t}", "@Override\n public void onItemClick(AdapterView<?> parent, View view, int position, long id) {\n if (mActionMode != null)\n onListItemSelect(position);\n }", "public void menuDeselected(MenuEvent evt) {\n }", "@Override\n\t\t\tpublic void actionPerformed(final ActionEvent evt) {\n\t\t\t\tif (evt.getSource() == jMenuItem6) {\n\t\t\t\t\tSystem.out.println(\"Selected: \"\n\t\t\t\t+ evt.getActionCommand());\n\t\t\t\t\t((Echiquier) panelChess\n\t\t\t\t\t\t.getComponents()[0]).setMode(1);\n\t\t\t\t}\n\t\t\t}", "public void actionPerformed(ActionEvent ae) {\n rb_selection = ae.getActionCommand(); \t \n }", "public void actionPerformed(ActionEvent e) {\r\n\t\tJComboBox<?> CategoriesCombo = (JComboBox<?>) e.getSource();\r\n\t\tSelectedCategory = CategoriesCombo.getSelectedItem();\r\n\r\n\t}", "public void onEventSelected(int position);", "@Override\n\tpublic void selectionChanged(IAction arg0, ISelection arg1) {\n\n\t}", "@Override\n public void onSelectionStateChange(List<Integer> selectedItems) {\n for (TabSelectionEditorMenuItem menuItem : mMenuItems.values()) {\n menuItem.onSelectionStateChange(selectedItems);\n }\n }", "@Override\n public boolean onActionItemClicked(ActionMode mode, MenuItem item) {\n switch (item.getItemId()) {\n case R.id.action_delete:\n \tdeleteSelected(mSelection);\n mSelection.clearSelection();\n \n numItemsSelected=0;\n \n mode.finish(); // Action picked, so close the CAB\n return true;\n case R.id.action_rename:\n // TODO renameItem();\n \t\n numItemsSelected=0;\n \n mode.finish(); // Action picked, so close the CAB\n return true;\n default:\n return false;\n }\n }", "public void actionPerformed(ActionEvent e)\r\n\t{\t// see which menu item was clicked\r\n\t\tif(e.getSource() == displayMenu)\r\n\t\t\tdisplayMessage();\r\n\t \tif(e.getSource() == clearMenu)\r\n \t\tclearMessage(); \r\n\t \tif(e.getSource() == closeMenu)\r\n \t \tshutDown(); \r\n\t}", "public void select(int action) {\n\t\tselected = true;\n\t\tthis.action = action;\n\t}", "@Override\n public boolean onOptionsItemSelected(MenuItem mItem) {\n int id = mItem.getItemId();\n\n //noinspection SimplifiableIfStatement\n if (id == R.id.action_filter) {\n alertSingleChoiceItems();\n return true;\n }\n\n return super.onOptionsItemSelected(mItem);\n }", "@Override\n\t\t\tpublic void mousePressed(MouseEvent e) {\n\t\t\t\tmenu.setMouseClick(true);\n\t\t\t}", "@Override\n public void actionPerformed(ActionEvent e) {\n optionEnvoi = choixMessage.getItemAt(choixMessage.getSelectedIndex());\n }", "@Override\n\t\t\t\t\tpublic void handle(ActionEvent event) {\n\t\t\t\t\t\tint eventSelection = eventOptions.getSelectionModel().getSelectedIndex();\n\t\t\t\t\t\tString description = new String(descriptionField.getText());\n\t\t\t\t\t\tdouble priceFactor = Double.parseDouble(priceFactorField.getText());\n\n\t\t\t\t\t\tif (eventSelection == 0) {\n\t\t\t\t\t\t\tConcert selection = new Concert(description, priceFactor);\n\t\t\t\t\t\t\tevents.add(selection);\n\t\t\t\t\t\t\tcounter++;\n\t\t\t\t\t\t\tmessage.setText(\"Concert event created.\\n\");\n\t\t\t\t\t\t} else if (eventSelection == 1) {\n\t\t\t\t\t\t\tPlay selection = new Play(description, priceFactor);\n\t\t\t\t\t\t\tevents.add(selection);\n\t\t\t\t\t\t\tcounter++;\n\t\t\t\t\t\t\tmessage.setText(\"Play event created.\\n\");\n\t\t\t\t\t\t} else if (eventSelection == 2) {\n\t\t\t\t\t\t\tMeeting selection = new Meeting(description, priceFactor);\n\t\t\t\t\t\t\tevents.add(selection);\n\t\t\t\t\t\t\tcounter++;\n\t\t\t\t\t\t\tmessage.setText(\"Meeting event created.\\n\");\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmessage.setText(\"Please choose Concert, Play, or Meeting from the Event Options list.\\n\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tprimaryStage.setTitle(\"Events\");\n\t\t\t\t\t\tprimaryStage.setScene(scene);\n\t\t\t\t\t}", "@Override\n public boolean onOptionsItemSelected(MenuItem item) {\n switch (item.getItemId()) {\n case android.R.id.home:\n //handle up navigation by setting a result intent so that onActivityResult in SuggestionsActivity\n //receives a non-null intent\n Log.d(TAG, String.format(\"onOptionsItemSelected: Up button clicked.\"));\n\n //set the result along with the intent, and finish\n setResult(Activity.RESULT_OK, buildResultIntent());\n finish();\n return true;\n\n case R.id.action_select:\n Log.d(TAG, \"onOptionsItemSelected: Invite button clicked\");\n if (selectedIdsMap.size() == 0) {\n //create a snackbar to inform the user that a selection must be made before inviting friend\n final View rootView = findViewById(R.id.root_layout);\n if (rootView != null) {\n final Snackbar snackbar = Snackbar.make(rootView, R.string.snackbar_no_selections, Snackbar.LENGTH_LONG);\n snackbar.setAction(R.string.snackbar_action_ok, new View.OnClickListener() {\n @Override\n public void onClick(View v) {\n snackbar.dismiss();\n }\n });\n snackbar.show();\n }\n }\n else {\n //start invite activity\n startActivity(InvitationActivity.buildIntent(this,\n buildSelectedItemsList(), EventConstants.EVENT_PARAM_VIEW_PAGER));\n }\n return true;\n\n default:\n return super.onOptionsItemSelected(item);\n }\n }", "@FXML protected void MainMenuButtonClicked(ActionEvent event) {\n this.mainMenuCB.launchMainMenu();\r\n }", "public void selectionChanged(IAction action, ISelection selection) {\n\t\t\r\n\t}", "@Override\r\npublic void menuDeselected(MenuEvent arg0) {\n\t\r\n}", "@Override\n\tpublic void menuDeselected(MenuEvent e) {\n\t\t\n\t}", "@Override\n\tpublic void menuDeselected(MenuEvent e) {\n\n\t}", "public void actionPerformed(ActionEvent e) {\n\t\t\t\t\tpistaseleccionada = (int) pista.getSelectedItem();\r\n\r\n\t\t\t\t}", "@Override\r\n public boolean onActionItemClicked(ActionMode mode, MenuItem item) {\r\n // TODO Auto-generated method stub\r\n return false;\r\n }", "@Override\n\t\tpublic void actionPerformed(final ActionEvent e) {\n\t\t\ttry {\n//\t\t\t\tJMenuItem itm = (JMenuItem)e.getSource();\n\t\t\t} catch (Exception e2) {\n\t\t\t\tSystem.out.println(\"Button error\");\n\t\t\t} finally {\n//\t\t\t\tSystem.out.println(e.);\n\t\t\t\tSystem.out.println(e.getSource());\n\t\t\t\tif (e.getActionCommand().compareTo(\"Close\") == 0) {\n\t\t\t\t\tSystem.out.println(\"Close operation\");\n\t\t\t\t\tSystem.exit(0);\n\t\t\t\t}\n\t\t\t}\n\t\t}", "public void actionPerformed(ActionEvent e) {\n\t\t\t// Find the button that the action event comes from.\n\t\t\tString buttonName = e.getActionCommand();\n\t\t\tJToggleButton button = buttonsMap.get(buttonName);\n\n\t\t\t// If the button is selected or unselected, notify all the interested listeners.\n\t\t\t// The interested listeners are the\n\t\t\t// listeners that registered into the member listenersMap.\n\t\t\tList<ElementSelectedListener> list = listenersMap.get(buttonName);\n\t\t\tif (list != null) {\n\t\t\t\tfor (ElementSelectedListener elementSelectedListener : list) {\n\t\t\t\t\telementSelectedListener.elementSelected(button,\n\t\t\t\t\t\t\tSectionPanel.this);\n\t\t\t\t}\n\t\t\t}\n\t\t}", "@Override\n public void onItemClick(AdapterView<?> parent, View view, int position, long id) {\n if (isInActionMode()) {\n if (getSelecteditemPositions().size() == 0) {\n actionMode.finish();\n }\n }\n }", "@Override\n\t\t\tpublic void menuDeselected(MenuEvent e) {\n\n\t\t\t}", "@Override\r\n public void selectionChanged(IAction action, ISelection selection) {\n }", "protected final void onSelect(CommandSender sender) {\n setInteracting(sender);\n onSelect();\n }", "public void selectionChanged(IAction action, ISelection selection) {\n\t}", "@Override\n\tpublic void selectionChanged(IAction action, ISelection selection) {\n\t}", "@FXML\n\tpublic void handleMenuClick(ActionEvent event) throws IOException {\n\t\tMenuItem MenuItem = ((MenuItem) event.getSource());\n\t\tStage stage = (Stage) myMenuButton.getScene().getWindow();\n\t\t\n\t\tswitch (MenuItem.getId()) {\n\t\tcase \"punkte3d\":\n//\t\t\tthis.dreiDPunkteView = new dreiDPunkteView(\"../view/3dpunkte.fxml\", \"3D Punkte\");\n\t\t\tthis.dreiDPunkteView.changeScene(stage);\n\t\t\tbreak;\n\t\tcase \"home\":\n//\t\t\tthis.homeview = new home(\"../view/home.fxml\", \"Home\");\n\t\t\tthis.homeview.changeScene(stage);\n\t\t\tbreak;\n\t\tcase \"tictactoe\":\n//\t\t\tthis.TicTacToeView = new TicTacToeView(\"../view/tictactoe.fxml\", \"Tic Tac Toe\");\n\t\t\tthis.TicTacToeView.changeScene(stage);\n\t\t\tbreak;\n\t\tcase \"textverschluesselung\":\n\t\t\tthis.verschluesselungsView.changeScene(stage);\n\t\t\tbreak;\n\t\tcase \"benzinrechner\":\n//\t\t\tthis.BenzinRechnerView = new BenzinRechnerView(\"../view/benzinrechner.fxml\", \"Benzin Rechner\");\n\t\t\tthis.BenzinRechnerView.changeScene(stage);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t\t\n\t}", "public void selectionChanged(IAction action, ISelection selection) {\n\r\n\t}", "public void selectionChanged(IAction action, ISelection selection) {\n\r\n\t}", "@Override\n\t\t\tpublic void actionPerformed(final ActionEvent evt) {\n\t\t\t\tif (evt.getSource() == jMenuItem4) {\n\t\t\t\t\tSystem.out.println(\"Selected: \"\n\t\t\t\t+ evt.getActionCommand());\n\t\t\t\t((Echiquier) panelChess\n\t\t\t\t.getComponents()[0]).setUci(\n\t\t\t\tnew CommunicationUCI(\"src\\\\moteurs\\\\\"\n\t\t\t\t+ \"Rybka v2.3.2a.mp.w32.exe\"),\n\t\t\t\tnew CommunicationUCI(\"src\\\\moteurs\\\\\"\n\t\t\t\t+ \"Rybkav2.3.exe\"));\n\t\t\t\t}\n\t\t\t}", "@Override\n\tpublic boolean onMenuItemSelected(int featureId, MenuItem item) {\n\t\tswitch (item.getItemId()) {\n\t\tcase ADD_EXPENSE_ID:\n\t\t\taddExpense();\n\t\t\treturn true;\n\t\t}\n\t\treturn super.onMenuItemSelected(featureId, item);\n\t}", "@Override\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\n if (id == R.id.action_settings) {\n return true;\n }\n if (R.id.action_add == id && mSelectedItem == 1) {\n return mFencesFragment.onOptionsItemSelected(item);\n } else if (R.id.action_add == id && mSelectedItem == 2) {\n return mTargetsFragment.onOptionsItemSelected(item);\n }\n return super.onOptionsItemSelected(item);\n }", "abstract public void cabMultiselectPrimaryAction();", "@Override\n\t\t\tpublic void actionPerformed(final ActionEvent evt) {\n\t\t\t\tif (evt.getSource() == jMenuItem3) {\n\t\t\t\t\tSystem.out.println(\"Selected: \"\n\t\t\t\t+ evt.getActionCommand());\n\t\t\t\t((Echiquier) panelChess\n\t\t\t\t.getComponents()[0]).setUci(\n\t\t\t\tnew CommunicationUCI(\"src\\\\moteurs\\\\\"\n\t\t\t\t+ \"Rybkav2.3.exe\"),\n\t\t\t\tnew CommunicationUCI(\"src\\\\moteurs\\\\\"\n\t\t\t\t+ \"Rybka v2.3.2a.mp.w32.exe\"));\n\t\t\t\t}\n\t\t\t}", "@Override\n\tpublic boolean onOptionsItemSelected(MenuItem item) {\n\t\tswitch (item.getItemId()) {\n\t\tcase R.id.search:\n\t\t\tonSearchRequested();\n\t\t\treturn true;\n\t\tcase R.id.action_selCourses:\n\t\t\tselectCourses();\n\t\t\treturn true;\n\t\tcase R.id.action_settings:\n\t\t\tsettings();\n\t\t\treturn true;\n\t\tcase R.id.action_refreshXML:\n\t\t\trefreshXML();\n\t\t\treturn true;\n\t\tcase R.id.action_swapSem:\n\t\t\tswapSemester();\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn super.onOptionsItemSelected(item);\n\t\t}\n\t}", "public void selectionChanged(IAction action, ISelection selection) {\n }", "@Override\n\t\t\tpublic void handle(MouseEvent event) {\n\t\t\t\tif (event.getButton() == MouseButton.PRIMARY) {\n\t\t\t\t\tTestInfo.this.test.getTestListPane().selectTest(TestInfo.this.test);\n\t\t\t\t}\n\t\t\t}", "@Override\n public boolean onMenuItemClick(MenuItem item) {\n return true;\n }", "protected void onSelectionPerformed(boolean success) {\n }", "@Override\r\n public void actionPerformed( ItemActionEvent<IAminoAcid> event )\r\n {\n }", "@Override\n\tpublic void HandleEvent(int action) {\n\t\tsetActiveAction(action);\n\t\tSystem.out.println(\"action is :\" + action);\n\t\t\n\t}", "@Override\r\n\tpublic void itemStateChanged(ItemEvent e) {\n\t\tif(e.getStateChange()== ItemEvent.SELECTED){\r\n\t\t\tcargarCantidades();\r\n\t\t\tactivarBoton();\r\n\t\t}\r\n\t}", "@Override\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tgsv.startSelectState();\n\t\t\t}", "@Override\r\n\tpublic void selectionChanged(IAction action, ISelection selection) {\n\r\n\t}", "@FXML\n\tpublic void setSelectedItem(MouseEvent event) {\n\t\ttry {\n\t\t\tString s=inventoryList.getSelectionModel().getSelectedItem();\t// Get selected item\n\t\t\tItem i=Item.getItem(ItemList, s);\n\t\t\titemselect.setText(s);\t// Set selected item information\n\t\t\tif(i.getStat().equals(\"HP\"))\n\t\t\t\titemStats.setText(\"+\"+i.getChange()+\" Health\");\n\t\t\telse if(i.getStat().equals(\"DMG\"))\n\t\t\t\titemStats.setText(\"+\"+i.getChange()+\" Damage\");\n\t\t\telse\n\t\t\t\titemStats.setText(\"+\"+i.getChange()+\" Evasion\");\n\t\t} catch(Exception e) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t}", "void onItemSelected(Bundle args);", "@Override\n\t\t\tpublic void onPageSelected(int arg0) {\n\t\t\t\tactionBar.setSelectedNavigationItem(arg0);\n\t\t\t}", "private void hookSingleClickAction() {\n\t\tthis.addSelectionChangedListener(new ISelectionChangedListener() {\n\t\t\tpublic void selectionChanged(SelectionChangedEvent event) {\n\t\t\t\tsingleClickAction.run();\n\t\t\t}\n\t\t});\n\t}", "@Override\n public boolean onActionItemClicked(ActionMode mode, MenuItem item) {\n switch (item.getItemId()) {\n case R.id.action_delete:\n SparseBooleanArray selected = mAdapter.getSelectedIds();\n for (int i = 0; i < selected.size(); i++) {\n if (selected.valueAt(i)) {\n Log.d(TAG, \"deleting item at \" + selected.keyAt(i));\n }\n }\n // Close CAB\n mode.finish();\n return true;\n\n case R.id.action_mute:\n Log.d(TAG, \"muting item\");\n mode.finish();\n return true;\n\n case R.id.action_edit:\n Log.d(TAG, \"editing item\");\n mode.finish();\n return true;\n\n default:\n Log.d(TAG, \"unknown menu action\");\n return false;\n }\n }", "public void menuClick(ActionEvent e) {\r\n\t\tswitch (e.getActionCommand()) {\r\n\t\tcase \"Save Game\":\r\n\t\t\ttry {\r\n\t\t\t\tsaveGame();\r\n\t\t\t} catch (FileNotFoundException e1) {\r\n\t\t\t\te1.printStackTrace();\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\tcase \"Load Game\":\r\n\t\t\tloadGame();\r\n\t\t\tbreak;\r\n\t\tcase \"New Game\":\r\n\t\t\tint confirm = JOptionPane\r\n\t\t\t\t\t.showConfirmDialog(gameView, \"Are You Sure You Want\\n To Start a New Game?\", \"Confirm New Game\", JOptionPane.YES_NO_OPTION);\r\n\t\t\tif (confirm == 0) {\r\n\t\t\t\tgameBoard = new GameBoardModel(false, false);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}", "public void actionPerformed (ActionEvent e)\n\t\t\t\t\t{\n\t\t\t\t\talertChosen( row, col );\n\t\t\t\t\t}", "@Override\r\n public boolean onOptionsItemSelected(MenuItem item) {\n int id = item.getItemId();\r\n return super.onOptionsItemSelected(item);\r\n }", "public void handleCountrySelection(ActionEvent actionEvent) {\n }", "@Override\n\tpublic boolean onOptionsItemSelected(MenuItem item) {\n\t\tint id = item.getItemId();\n\t\treturn super.onOptionsItemSelected(item);\n\t}", "private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {\n }", "@Override\n public boolean onActionItemClicked(ActionMode mode, MenuItem item) {\n switch (item.getItemId()) {\n case R.id.action_delete:\n getPresenter().deleteSelectedItems();\n mode.finish(); // Action picked, so close the CAB\n return true;\n default:\n return false;\n }\n }", "private void userSelected(MouseEvent e) {\n User user = getUser(e);\n if (user != null) {\n userListener.userClicked(user, e);\n }\n }", "public void onSelectFunction$mnu(Event event) {\r\n\r\n\t\tOperacion operacion = (Operacion) event.getData();\r\n\t\t\r\n\t\t\r\n\t\tif (operacion != null) {\r\n\t\t\t\r\n//\t\t\tObject actual = page.getVariable(\"actual\");\r\n\t\t\t\r\n\t\t\tObject actual = getPage().getAttribute(\"actual\");\r\n\t\t\t\r\n\t\t\tGenericList list = (GenericList)self;\r\n\t\t\t\r\n\t\t\tif (actual != null) {\r\n\t\t\t\t\r\n\t\t\t\talert(list.getDialog());\r\n\t\t\t}\r\n\t\t\t\r\n\t\t}\r\n\t\t\r\n\r\n\t}" ]
[ "0.729002", "0.729002", "0.72444063", "0.72188395", "0.7207396", "0.6986399", "0.69816774", "0.69721615", "0.690053", "0.6870159", "0.6864712", "0.68476516", "0.67502356", "0.6727201", "0.67041427", "0.66319793", "0.66247505", "0.6600375", "0.6583472", "0.65783674", "0.6552403", "0.6546387", "0.65172035", "0.64813995", "0.64448965", "0.64040506", "0.6365124", "0.6361114", "0.6353038", "0.6331695", "0.63244814", "0.6290499", "0.6281562", "0.626742", "0.62632346", "0.6260336", "0.6257912", "0.62391865", "0.62387234", "0.62378037", "0.62357956", "0.62272984", "0.6211704", "0.61954325", "0.61901456", "0.6186249", "0.6169785", "0.61671007", "0.6135025", "0.6126427", "0.6123687", "0.61219466", "0.610964", "0.6105886", "0.6103061", "0.6099661", "0.6099061", "0.6083581", "0.607973", "0.6078355", "0.60774654", "0.60563606", "0.6055583", "0.60549825", "0.6052393", "0.60367644", "0.6035576", "0.60330176", "0.6027808", "0.60277206", "0.60277206", "0.6026355", "0.60243464", "0.6022053", "0.6017571", "0.60138184", "0.60085285", "0.6002274", "0.6000963", "0.5999036", "0.599133", "0.5975729", "0.59609675", "0.59588516", "0.59584737", "0.595776", "0.594855", "0.5948255", "0.5943158", "0.59409535", "0.59391934", "0.5931704", "0.5931689", "0.592912", "0.5926435", "0.59231114", "0.5922108", "0.59117943", "0.5910004", "0.59003925" ]
0.59788436
81
Writes, or overwrites, the contents of the specified file
public void generateAndwriteToFile() { List<GeneratedJavaFile> gjfs = generate(); if (gjfs == null || gjfs.size() == 0) { return; } for (GeneratedJavaFile gjf : gjfs) { writeToFile(gjf); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public void writeToFile(File file) {\n\n\t}", "protected abstract void writeFile();", "public void writeFileContents(String filename, String contents) {\n }", "public void write(File file) throws IOException {\n\t\tOutputStream out = null;\n\t\ttry {\n\t\t\tout = new FileOutputStream(file);\n\t\t\twrite(out);\n\t\t} finally {\n\t\t\tout.close();\n\t\t}\n\t}", "public void writeToFile(File file, String fileContent) {\n if (!file.exists()) {\n try {\n FileWriter writer = new FileWriter(file);\n writer.write(fileContent);\n writer.close();\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n } catch (IOException e) {\n e.printStackTrace();\n } finally {\n\n }\n }\n }", "public static void writeFile(final File file, final String content) throws IOException\n\t{\n\t\tfinal Writer output = new BufferedWriter(new OutputStreamWriter(\n\t\t\t\tnew FileOutputStream(file), FILE_CHARSET_NAME));\n\t\ttry\n\t\t{\n\t\t\toutput.write(content);\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\toutput.close();\n\t\t}\n\t}", "public static void write(File file, String contents) throws CWLException {\r\n if (file != null && contents != null) {\r\n try (FileOutputStream out = new FileOutputStream(file)) {\r\n byte[] bytes = contents.getBytes(StandardCharsets.UTF_8.name());\r\n out.write(bytes);\r\n } catch (IOException e) {\r\n throw new CWLException(\r\n ResourceLoader.getMessage(\"cwl.io.write.failed\", file.getAbsolutePath(), e.getMessage()),\r\n 255);\r\n }\r\n }\r\n }", "public void writeFile(String content){\n\t\tFile file = new File(filePath);\n\t\t\n\t\tBufferedWriter bw = null;\n\t\t\n\t\ttry{\n\t\t\tif (!file.exists())\n\t\t\t\tfile.createNewFile();\n\t\t\t\n\t\t\tbw = new BufferedWriter(new FileWriter(file));\n\t\t\tbw.write(content);\n\t\t}\n\t\tcatch (Exception oops){\n\t\t\tSystem.err.print(\"There was an error writing the file \"+oops.getStackTrace());\n\t\t}\n\t\tfinally{\n\t\t\ttry{\n\t\t\t\tbw.close();\n\t\t\t}\t\n\t\t\tcatch(IOException oops){\n\t\t\t\tSystem.err.print(\"There was an error closing the write buffer \"+oops.getStackTrace());\n\t\t\t}\n\t\t}\n\t}", "private void writeToFile(String fileName,String contents) throws IOException{\r\n\t\tFileWriter fw = new FileWriter(fileName,true);\r\n\t\tPrintWriter pw = new PrintWriter(fw);\r\n\t\tpw.write(contents+\"\\r\\n\");\r\n\t\tpw.close();\r\n\t}", "public void setContents(File aFile, String aContents)\n throws FileNotFoundException, IOException {\n if (aFile == null) {\n throw new IllegalArgumentException(\"File should not be null.\");\n }\n if (!aFile.exists()) {\n aFile.createNewFile();\n }\n if (!aFile.isFile()) {\n throw new IllegalArgumentException(\"Should not be a directory: \"\n + aFile);\n }\n if (!aFile.canWrite()) {\n throw new IllegalArgumentException(\"File cannot be written: \"\n + aFile);\n }\n\n // declared here only to make visible to finally clause; generic\n // reference\n Writer output = null;\n try {\n // use buffering\n // FileWriter always assumes default encoding is OK!\n output = new BufferedWriter(new FileWriter(aFile));\n output.write(aContents);\n } finally {\n // flush and close both \"aspectOutput\" and its underlying FileWriter\n if (output != null) {\n output.close();\n }\n }\n }", "void updateFile() throws IOException;", "public static void write(InputStream is, File file) throws IOException {\n OutputStream os = null;\n try {\n os = new FileOutputStream(file);\n byte[] buffer = new byte[BUFFER_SIZE];\n int count;\n while ((count = is.read(buffer)) != -1) {\n os.write(buffer, 0, count);\n }\n os.flush();\n } finally {\n close(is);\n close(os);\n }\n }", "public static void writeFile(final File f, final String content) throws IOException {\n final FileOutputStream o = new FileOutputStream(f);\n o.write(content.getBytes());\n o.close();\n }", "@Override\n\tpublic void write(final File file) throws IOException\n\t{\n\t\tif (isInMemory())\n\t\t{\n\t\t\tFileOutputStream fout = new FileOutputStream(file);\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\tfout.write(get());\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tfout.close();\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tFile outputFile = getStoreLocation();\n\t\t\tChecks.notNull(outputFile,\n\t\t\t\t\"for a non-memory upload the file location must not be empty\");\n\n\t\t\t// Save the length of the file\n\t\t\tsize = outputFile.length();\n\t\t\t/*\n\t\t\t * The uploaded file is being stored on disk in a temporary location so move it to the\n\t\t\t * desired file.\n\t\t\t */\n\t\t\tif (!outputFile.renameTo(file))\n\t\t\t{\n\t\t\t\tBufferedInputStream in = null;\n\t\t\t\tBufferedOutputStream out = null;\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tin = new BufferedInputStream(new FileInputStream(outputFile));\n\t\t\t\t\tout = new BufferedOutputStream(new FileOutputStream(file));\n\t\t\t\t\tStreams.copy(in, out);\n\t\t\t\t}\n\t\t\t\tfinally\n\t\t\t\t{\n\t\t\t\t\tIOUtils.closeQuietly(in);\n\t\t\t\t\tIOUtils.closeQuietly(out);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "public static void writeFile(File targetFile, String content)\r\n throws IOException {\r\n final FileWriter writer = new FileWriter(targetFile);\r\n writer.write(content);\r\n writer.close();\r\n }", "public static void writeStringToFile(String content, File file) throws IOException {\n if(StringUtil.isNullOrBlank(content) || file == null) {\n return;\n }\n if(!file.exists() && !file.createNewFile() || file.isDirectory() || !file.canWrite()) {\n return;\n }\n\n FileOutputStream fos = null;\n try {\n fos = new FileOutputStream(file);\n fos.write(content.getBytes());\n } finally {\n if(fos != null) {\n fos.close();\n }\n }\n }", "private void writeFile(String path, String contents) throws IOException {\n File file = new File(dir, path);\n\n try (FileWriter writer = new FileWriter(file)) {\n writer.write(contents);\n }\n }", "static void writeContents(File file, byte[] bytes) {\n try {\n if (file.isDirectory()) {\n throw\n new IllegalArgumentException(\"cannot overwrite directory\");\n }\n Files.write(file.toPath(), bytes);\n } catch (IOException excp) {\n throw new IllegalArgumentException(excp.getMessage());\n }\n }", "public void write(final File out) throws IOException;", "public void writeToTextFile(String fileName, String content) throws IOException {\n \tFiles.write(Paths.get(fileName), content.getBytes(), StandardOpenOption.CREATE);\n \t}", "public static void writeTextFile(File file, String content) throws IOException {\n BufferedWriter bw = new BufferedWriter(new FileWriter(file));\n bw.write(content, 0, content.length());\n bw.flush();\n bw.close();\n }", "public static void writeStringToFile(String contents,\n \t\t\tFileOutputStream filePath) throws IOException {\n \t\tif (contents != null) {\n \t\t\tBufferedOutputStream bw = new BufferedOutputStream(filePath);\n \t\t\tbw.write(contents.getBytes(\"UTF-8\"));\n \t\t\tbw.flush();\n \t\t\tbw.close();\n \t\t}\n \t}", "public static void write(String fileName, String content) {\r\n BufferedWriter bufferedWriter = null;\r\n try {\r\n\r\n //Will use FileWriter, BufferedWriter, and PrintWriter in this method.\r\n FileWriter fileWriter = null;\r\n try {\r\n fileWriter = new FileWriter(fileName, true);\r\n } catch (Exception e) {\r\n System.out.println(\"Error creating fileWriter in FileUtility.write(...)\");\r\n }\r\n\r\n bufferedWriter = new BufferedWriter(fileWriter);\r\n PrintWriter pw = new PrintWriter(bufferedWriter, true);\r\n pw.print(content);\r\n\r\n// bufferedWriter.write(content);\r\n// bufferedWriter.flush();\r\n } finally {\r\n try {\r\n bufferedWriter.close();\r\n } catch (Exception ex) {\r\n System.out.println(\"could not close buffered writer\");\r\n }\r\n }\r\n }", "void writeFile(File file, String password, String cnt);", "public void write(java.io.File f) throws java.io.IOException, Schema2BeansRuntimeException;", "public FileWriter(File file) throws IOException {\n super(new FileOutputStream(file));\n }", "public abstract boolean writeDataToFile(String fileName, boolean overwrite);", "public static void write(byte[] data, File file) throws IOException {\n write(data, file, false);\n }", "public OutputStream writeFile( String filename, FileType type );", "public abstract void writeToFile( );", "public void writeFile(IFile resource, IPath destinationPath)\n\t\t\tthrows CoreException;", "public void postFile(File file, Writer output) \n throws FileNotFoundException {\n\n FileReader reader = new FileReader(file);\n try {\n postData(reader, output);\n } finally {\n try {\n if(reader!=null) reader.close();\n } catch (IOException e) {\n throw new PostException(\"IOException while closing file\", e);\n }\n }\n }", "public void writeLineToFile(File file, String content) throws IOException {\n\t\tBufferedWriter writer = writers.get(file);\n\t\twriter.append(content + \"\\n\");\n\t}", "public static void main(String args[])\n {\n String FILENAME = \"myfile.txt\";\n\n // When used, the FileWriter object will immediately put it's output\n // to the file. So FileWriter output attempts to write to the file as\n // fast as possible. Maybe this is a good thing in some\n // circumstances, but I think it would be better to write data in\n // chunks. We employ a BufferedWriter object to capture the\n // FileWriter output into a collection of bytes that can be written\n // to the file.\n FileWriter fWriter = null;\n BufferedWriter bWriter = null;\n\n // Wrapping our attempt to write to the file inside a try / catch\n // statement allows us to trap some errors if they happen\n try\n {\n // Here is the content that we will write to the file.\n String fileContent = \"Dude, I'm totally writing to a file!!\";\n\n // These lines instantiate FileWriter and BufferedWriter objects.\n // When instantiating the FileWriter object we pass in the file\n // name that we are writing to. If no path is given in our\n // filename, the file will be created and written in the root\n // directory.\n fWriter = new FileWriter(FILENAME);\n\n // The BufferedWriter object is instantiated on this line and the\n // FileWriter object is passed in as an argument.\n bWriter = new BufferedWriter(fWriter);\n\n // Now that we have our buffer and writer objects created, we can\n // attempt to write content to the file. Here is what\n // (I think) this is doing. The BufferedWriter object will receive\n // the content to be written, and then pass that content as a\n // whole to the FileWriter so it can be written to the file as a\n // chunk. If we did not do it this way, the content would be read\n // passed into the FileWriter object, converted to bytes on the\n // fly, and immediately written, byte by byte as it is converted,\n // to the file. By buffering we are increasing the performance of\n // this action.\n bWriter.write(fileContent);\n }\n\n // The catch statement will trap and display any exception that is\n // created when we are attempting to create our writer objects, open\n // or create the file, or write content.\n catch(Exception e)\n {\n System.out.println(\"Unable to write to file : \" + e.getMessage());\n }\n\n // This 'finally' statement will always happen, regardless of what\n // happens in our try/catch statement. If we put this code into the\n // try statement and we received an error, it would never be\n // processed. Additionally, if we put this code at the bottom of our\n // program and ran into an error half way through, it would never be\n // processed. Placing the code into a finally statement allows us to\n // ensure that it is run every time.\n finally\n {\n // Another try and catch statement to trap any error that happens\n // when closing the files.\n try\n {\n // The last thing we want to do is close out our writer\n // objects. This is a best practice since if you leave the\n // writer open you are at best wasting system resources, and\n // at worst you could lock this file for editing while other\n // resources are trying to use it. We check to make sure it\n // is not already disposed of, and then we call the close()\n // method.\n if (bWriter != null) {\n bWriter.close();\n }\n\n if (fWriter != null) {\n fWriter.close();\n }\n }\n // Our final catch reveals any errors that popped up when we were\n // attempting to close the writer and buffer objects.\n catch (Exception e)\n {\n System.out.println(\"Unable to close writer objects :\"\n + e.getMessage());\n }\n }\n }", "void putFile(String filename, byte[] file) throws FileAlreadyExistsException;", "public static void writeFile(String fileName, String fileContent) {\n\t\ttry {\n\t\t\tFileWriter fstream;\n\t\t\tfstream = new FileWriter(fileName);\n\t\t\tBufferedWriter out = new BufferedWriter(fstream);\n\t\t\tout.write(fileContent);\n\t\t\tout.close();\n\t\t} catch (IOException e) {\n\t\t\tSystem.err.println(\"Error Writing File\");\n\t\t\te.printStackTrace();\n\t\t}\n\t}", "public void updateFile(String fname, String content) {\n\t\tprintMsg(\"running updateFiles() in \\\"\" + this.getClass().getName() + \"\\\" class.\");\n\t\tString text = null;\n\t\tPath filepath = Paths.get(theRootPath + System.getProperty(\"file.separator\") + fname);\n\t\tif(Files.exists(filepath)) {\n\t\t\tprintMsg(\"File \" + fname + \" exists, updating...\");\n\t\t\t\n\t\t\tif(content.isEmpty() || content == null) {\n\t\t\t\ttext = String.format(\"%s, testing appending text to an empty file.\\r\\n\", new Date());\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttext = content + \"\\r\\n\";\n\t\t\t}\n\t\t\t\n\t\t\ttry {\n\t\t\t\tFiles.write(filepath, text.getBytes(), StandardOpenOption.APPEND);\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t}\n\t}", "public void writeToTextFile(String filename){\n try{\n FileWriter myWriter = new FileWriter(filename); \n myWriter.write(toString());\n myWriter.close();\n } \n catch(IOException e) { \n System.out.println(\"An error occurred.\"); \n e.printStackTrace();\n } \n }", "public static void WriteFile()throws java.io.FileNotFoundException,java.io.IOException\n {\n FileOutputStream out1= new FileOutputStream(\"Sample.bin\") ; \n String ab=\"Welcome to sample file\";\n out1.write(ab.getBytes());\n out1.flush();\n out1.close();\n }", "static void writeFile(String path, String content)\n\t\t\tthrows FileNotFoundException, UnsupportedEncodingException {\n\t\tPrintWriter writer = new PrintWriter(path, \"UTF-8\");\n\t\twriter.println(content);\n\t\twriter.close();\n\t}", "void setNewFile(File file);", "private void writeFileLine(String s, File file)throws IOException{\n\t\tFileWriter filewriter = new FileWriter(file);\n\t\tPrintWriter printWriter = new PrintWriter(filewriter);\n\t\tprintWriter.print(s);\n\t\tprintWriter.close();\n\t}", "protected void fileSet() throws IOException {\n//\t\tfos = new FileOutputStream(outFile, false);\n//\t\tdos = new DataOutputStream(fos);\n\t\trealWriter = new BufferedWriter(new FileWriter(outFile.getAbsolutePath()));\n\t}", "public void writeFile() {\n try {\n FileWriter writer = new FileWriter(writeFile, true);\n writer.write(user + \" \" + password);\n writer.write(\"\\r\\n\"); // write new line\n writer.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n \n }", "public static void writeFile(final String contents, final String name) {\n writeFile(contents, name, false);\n }", "public void reWriteFile(String filename,String data) {\n\n if (filename.trim().length() > 0) {\n try {\n PrintWriter output = new PrintWriter(filename);\n\n output.write(data);\n\n output.close();\n } catch (IOException e) {\n System.out.println(\"I/O Error\");\n }\n } else {\n System.out.println(\"Enter a filename:\");\n }\n }", "public ThingToWriteFile(String filename) { \n\t\ttry { \t\n\t\t\tout = new BufferedWriter(new FileWriter(filename));\n\t\t}\n\t\tcatch (FileNotFoundException ee){\n\t\t\tSystem.out.println(\"File \" + filename + \" not found.\");\n\t\t\tSystem.exit(0);\n\t\t}\n\t\tcatch (IOException e){\n\t\t\tSystem.out.println(\"File \" + filename + \" cannot be read.\");\n\t\t\tSystem.exit(0);\n\t\t}\n\t}", "protected void writeFile(okhttp3.Response response, File file) throws IOException {\n if (file == null){\n throw new IllegalArgumentException(\"File == null\");\n }\n InputStream instream = response.body().byteStream();\n long contentLength = response.body().contentLength();\n FileOutputStream buffer = new FileOutputStream(file);\n if (instream != null) {\n try {\n byte[] tmp = new byte[BUFFER_SIZE];\n int l, count = 0;\n while ((l = instream.read(tmp)) != -1 && !Thread.currentThread().isInterrupted()) {\n count += l;\n buffer.write(tmp, 0, l);\n\n sendProgressEvent(count, (int) contentLength);\n }\n } finally {\n Util.closeQuietly(instream);\n buffer.flush();\n Util.closeQuietly(buffer);\n }\n }\n }", "protected void write(OutputStream os) throws IOException {\n\t\tFileInputStream fis = new FileInputStream(this.filepath);\n\t\tBufferedInputStream bis = new BufferedInputStream(fis);\n\t\tbyte[] s = new byte[1024];\n\t\tint i = 0;\n\t\twhile ((i = bis.read(s)) > 0) {\n\t\t\tos.write(s, 0, i);\n\t\t}\n\t\tif (os != null) {\n\t\t\tos.flush();\n\t\t\tos.close();\n\t\t}\n\t\tif (bis != null)\n\t\t\tbis.close();\n\t\tif (fis != null)\n\t\t\tfis.close();\n\t}", "public static void writeTo(String contents, final IFile file,\r\n\t\t\tIProgressMonitor progressMonitor) throws CoreException {\r\n\t\tprogressMonitor = ProgressUtil.getDefaultMonitor(progressMonitor);\r\n\t\tInputStream input = IOUtils.toInputStream(contents);\r\n\t\ttry {\r\n\t\t\tif (file.exists()) {\r\n\t\t\t\tfile.setContents(input, true, true, progressMonitor);\r\n\t\t\t} else {\r\n\t\t\t\tfile.create(input, true, progressMonitor);\r\n\r\n\t\t\t}\r\n\t\t} finally {\r\n\t\t\tIOUtils.closeQuietly(input);\r\n\t\t}\r\n\t}", "public static void write(File file, WorkflowTrace trace) throws FileNotFoundException, JAXBException, IOException {\n FileOutputStream fos = new FileOutputStream(file);\n WorkflowTraceSerializer.write(fos, trace);\n }", "public static void writeFile(String targetFilePath, String content)\r\n throws IOException {\r\n writeFile(new File(targetFilePath), content);\r\n }", "public boolean writeDataFile();", "public static void appendFile(PrintWriter pw, String file) throws IOException {\n\t\tfw = new FileWriter(file, true);\n\t\tmyFile = new File(file);\n\t\t//allows me to read file\n\t\tinFile = new Scanner(myFile);\n\t\t\n\t}", "private void writeFileContents(String contents, String destination) throws IOException {\n FileUtils.write(new File(destination), contents, Charset.defaultCharset());\n System.out.println(\"Wrote file: \" + destination);\n }", "public static void writeToFile(String filename, String content){\n\t\tFileWriter file;\n\t\ttry {\n\t\t\tfile = new FileWriter(filename,true);\n\t\t\tBufferedWriter writer = new BufferedWriter(file);\n\n\t\t\twriter.append(content);\n\t\t\twriter.newLine();\n\t\t\twriter.close();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t\t\n\t}", "public static void FileWrite(String path, String content) {\n\t\tFile file = new File(path);\n\t\ttry {\n\t\t\tFileOutputStream fop = new FileOutputStream(file);\n\t\t\t// if file doesn't exists, then create it\n\t\t\tif (!file.exists()) {\n\t\t\t\tfile.createNewFile();\n\t\t\t}\n\t\t\t// get the content in bytes\n\t\t\tbyte[] contentInBytes = content.getBytes();\n\t\t\tfop.write(contentInBytes);\n\t\t\tfop.flush();\n\t\t\tfop.close();\n\t\t\tSystem.out.println(\"Content :\\\"\" + content\n\t\t\t\t\t+ \"\\\" is written in File: \" + path);\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}", "public void write_file(String filename)\n {\n out.println(\"WRITE\");\n out.println(filename);\n int timestamp = 0;\n synchronized(cnode.r_list)\n {\n timestamp = cnode.r_list.get(filename).cword.our_sn;\n }\n // content = client <ID>, <ts>\n out.println(\"Client \"+my_c_id+\", \"+timestamp);\n // check if write operation finished on server and then exit method\n try\n {\n String em = null;\n em = in.readLine();\n Matcher m_eom = eom.matcher(em);\n if (m_eom.find())\n {\n System.out.println(\"WRITE operation finished on server : \"+remote_c_id);\n }\n else\n {\n System.out.println(\"WRITE operation ERROR on server : \"+remote_c_id);\n }\n }\n catch (IOException e) \n {\n \tSystem.out.println(\"Read failed\");\n \tSystem.exit(-1);\n }\n }", "protected void openWriteFile(Path filePath, String s) throws IOException{\n\t\tBufferedWriter writer = Files.newBufferedWriter(filePath, ENCODING);\n\t\twriter.write(s, 0, s.length());\n\t\twriter.close();\n\t}", "public void toFile() throws IOException {\n toFile(null);\n }", "public static void fileWriter(String path, String fileName, Object printLine) throws NumberFormatException, IOException {\n // Create File:\n\t\t\t\tFile f = new File(path + File.separator + fileName);\t\t\t\t \n\t\t\t // Write or add a String line into File:\t\n\t\t\t FileWriter fw = new FileWriter(f,true);\n\t\t\t PrintWriter pw = new PrintWriter(fw);\n\t\t\t pw.println(printLine);\n\t\t\t pw.close();\n\t\t\t}", "public OutputStreamWrapper\r\n (File file)\r\n throws FileNotFoundException\r\n {\r\n mStream=new FileOutputStream(file);\r\n }", "public static void appendFile(final String contents, final String name) {\n writeFile(contents, name, true);\n }", "public static void randomAccessWrite() {\n try {\n RandomAccessFile f = new RandomAccessFile(FILES_TEST_PATH, \"rw\");\n f.writeInt(10);\n f.writeChars(\"test line\");\n f.close();\n } catch(Exception e) {\n e.printStackTrace();\n }\n }", "void save(File file);", "public void addFile(File inFile) throws IOException {\n write(org.apache.commons.io.FileUtils.readFileToString(inFile, Charset.defaultCharset()));\n }", "protected void writeContent(final String filename, final byte[] content) {\r\n\t\tFile file = new File(filename);\r\n\t\tif (file.exists()) {\r\n\t\t\tthrow new FileException(\"file [\" + file.getAbsolutePath() + \"] already exists\");\r\n\t\t}\r\n\t\ttry {\r\n\t\t\tFileOutputStream os = new FileOutputStream(file);\r\n\t\t\tos.write(content);\r\n\t\t\tos.close();\r\n\t\t} catch (IOException e) {\r\n\t\t\tthrow new FileException(\"could not write file [\" + file.getAbsolutePath() + \"]\", e);\r\n\t\t}\r\n\t}", "public void saveFile(File file, String text) {\r\n\t\t\r\n\t\tif (file==null){\r\n\t\t\treturn;\t\r\n\t\t}\r\n\r\n\t\ttry (BufferedWriter bw = new BufferedWriter(new FileWriter(file))) {\r\n\r\n\t\t\tbw.write(text);\r\n\r\n\t\t} catch (IOException e) {\r\n\r\n\t\t\te.printStackTrace();\r\n\t\t}\r\n\r\n\t}", "private static void writeFileOnClient(FileStore.Client client) throws SystemException, TException, IOException {\n String fileName = \"sample.txt\";\n\n String content = \"Content\";\n\n try {\n\n RFile rFile = new RFile();\n RFileMetadata rFileMetaData = new RFileMetadata();\n\n rFileMetaData.setFilename(fileName);\n rFileMetaData.setFilenameIsSet(true);\n\n rFile.setMeta(rFileMetaData);\n rFile.setMetaIsSet(true);\n\n rFile.setContent(content);\n rFile.setContentIsSet(true);\n\n client.writeFile(rFile);\n\n } catch (TException x) {\n throw x;\n }\n }", "public static void writeFile(String filepath, List<String> contents) {\n List<String> content = new ArrayList<String>();\n File file = new File(filepath);\n if (file.exists()) {\n content.addAll(FileIOUtilities.readFile(filepath));\n }\n content.addAll(contents);\n if (content != null && !content.isEmpty()) {\n BufferedWriter writer = null;\n String encoding = \"UTF8\";\n try {\n writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), encoding));\n for (String line : content) {\n writer.write(line);\n writer.newLine();\n }\n } catch (UnsupportedEncodingException e) {\n e.printStackTrace();\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n } catch (IOException e) {\n e.printStackTrace();\n } finally {\n try {\n writer.close();\n } catch (IOException e) {\n // Ignore exception because writer was not initialized\n }\n }\n \n }\n }", "public void setFile(File file);", "public static void WriteStreamAppendByRandomAccessFile(String fileName, String content) throws IOException {\n try {\n RandomAccessFile randomFile = new RandomAccessFile(fileName, \"rw\");\n long fileLength = randomFile.length();\n // Write point to the end of file.\n randomFile.seek(fileLength);\n randomFile.writeBytes(content);\n randomFile.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }", "public void save (File argFile) throws IOException;", "public static void toFile(String fileName, String content) {\n\t\ttoFile( fileName, content, false );\n\t}", "public static void writeObjectInFile(File file, Object objToWrite) throws Exception {\n FileOutputStream fileOutputStream = null;\n ObjectOutputStream objectOutputStream = null;\n try {\n fileOutputStream = new FileOutputStream(file);\n objectOutputStream = new ObjectOutputStream(fileOutputStream);\n\n // Write objects to file\n objectOutputStream.writeObject(objToWrite);\n } finally {\n objectOutputStream.close();\n fileOutputStream.close();\n }\n }", "public void write(String filePath) {\n\t\tcmd = new WriteCommand(editor, filePath);\n\t\tinvoker = new MiniEditorInvoker(cmd);\n\t\tinvoker.action();\n\t}", "public void put(String key, File file) throws FileNotFoundException {\n put(key, file, null);\n }", "public static void put(File file) throws IOException {\n while (LogicManager.isUpdating()) {} // wait until current update has finished\n\n LogicManager.setPaused(true);\n\n // open output stream\n ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(file)));\n\n // write viewport data\n out.writeObject(Window.getCurrentInstance()\n .getGameDisplay()\n .getViewport());\n out.writeObject(new Integer(Window.getCurrentInstance()\n .getGameDisplay()\n .getScaling()));\n\n // write map data\n Point[] data = GridManager.dumpScene();\n out.writeObject(data);\n out.flush();\n out.close();\n }", "public void writeFile(String path, String name, String content)\n\t\t\tthrows Exception {\n\n\t\ttry {\n\t\t\tString ruta = path + File.separator + name;\n\n\t\t\t// Create file\n\t\t\tFileWriter fstream = new FileWriter(ruta);\n\t\t\tBufferedWriter out = new BufferedWriter(fstream);\n\t\t\tout.write(content);\n\t\t\t// Close the output stream\n\t\t\tout.close();\n\t\t} catch (Exception e) {\n\t\t\tlogger.error(\"Error escribiendo fichero\", e);\n\t\t}\n\n\t}", "public void writeFile(String data){\n\t\t\n\t\tcurrentLine = data;\n\t\t\n\t\t\ttry{ \n\t\t\t\tFile file = new File(\"/Users/bpfruin/Documents/CSPP51036/hw3-bpfruin/src/phfmm/output.txt\");\n \n\t\t\t\t//if file doesnt exists, then create it\n\t\t\t\tif(!file.exists()){\n\t\t\t\t\tfile.createNewFile();\n\t\t\t\t}\n \n\t\t\t\t//true = append file\n\t\t\t\tFileWriter fileWriter = new FileWriter(file,true);\n \t \tBufferedWriter bufferWriter = new BufferedWriter(fileWriter);\n \t \tbufferWriter.write(data);\n \t \tbufferWriter.close();\n \n \n\t\t\t}catch(IOException e){\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\n\t\t\n\t}", "private void writeToFile() {\n try {\n FileOutputStream fos = new FileOutputStream(f);\n String toWrite = myJSON.toString(4);\n byte[] b = toWrite.getBytes();\n fos.write(b);\n fos.close();\n } catch (Exception e) {\n e.printStackTrace();\n }\n }", "public static void writeStreamAppendByFileWriter(String fileName, String content) throws IOException {\n try {\n FileWriter writer = new FileWriter(fileName, true);\n writer.write(content);\n writer.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }", "private static void writeFileToResponse(byte[] fileContent) throws IOException{\r\n\t\t// Write file to response.\r\n\t output = response.getOutputStream();\r\n\t output.write(fileContent);\r\n\t output.close();\r\n\t}", "void writeExcel(File newFile) throws Exception;", "public static void writeTextFile(String path, String content) throws IOException{\r\n FileWriter fw = new FileWriter(path, true);\r\n BufferedWriter bw = new BufferedWriter(fw);\r\n bw.write(content);\r\n bw.close();\r\n fw.close();\r\n }", "public static void fileWriter(String fileName, Object printLine) throws NumberFormatException, IOException {\n // Create File:\n\t\t\t\tFile f = new File(Common.testOutputFileDir + fileName);\t\t\t\t \n\t\t\t // Write or add a String line into File:\t\n\t\t\t FileWriter fw = new FileWriter(f,true);\n\t\t\t PrintWriter pw = new PrintWriter(fw);\n\t\t\t pw.println(printLine);\n\t\t\t pw.close();\n\t\t\t}", "private static void write(Client client, String user, String filename,String fileContent) throws SystemException, TException {\n\t\t\n\t\t\n\t\tString keyString = user + \":\" + filename;\n\t\tString key = sha_256(keyString);\n\t\t\n\t\tSystem.out.println(\"Client Locating server\");\n\t\tNodeID succNode = client.findSucc(key);\n\t\tString predIP = succNode.ip;\n\t\tint predPort = succNode.port;\n\t\tSystem.out.println(\"Client located server : \"+predPort);\n\n\t\ttry {\n\t\t\tTSocket transport = new TSocket(predIP, predPort);\n\t\t\ttransport.open();\n\t\t\tTBinaryProtocol protocol = new TBinaryProtocol(transport);\n\t\t\tClient client1 = new chord_auto_generated.FileStore.Client(protocol);\n\t\t\tSystem.out.println(\"Writting file location : \" + predPort);\n\t\t\tRFile rFile = new RFile();\n\t\t\t// rFile.setContent(\"More Updated Files content\");\n\t\t\trFile.setContent(fileContent);\n\t\t\tRFileMetadata localMeta = new RFileMetadata();\n\t\t\tlocalMeta.setFilename(filename);\n\t\t\tlocalMeta.setOwner(user); // Is this the client or server probably Client\n\t\t\trFile.setMeta(localMeta);\n\t\t\tSystem.out.println(\"Writting file Starting----------\");\n\t\t\tclient1.writeFile(rFile);\n\t\t\tSystem.out.println(\"Writting file Done----------\");\n\t\t\ttransport.close();\n\t\t} catch (TTransportException e) {\n\t\t\te.printStackTrace();\n\t\t\tSystem.exit(0);\n\t\t}\n\t}", "public static void WriteStreamAppendByFileOutputStream(String fileName, String content) throws IOException {\n BufferedWriter out = null;\n try {\n out = new BufferedWriter(new OutputStreamWriter(\n new FileOutputStream(fileName, true)));\n out.write(content);\n } catch (Exception e) {\n e.printStackTrace();\n } finally {\n try {\n out.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n }", "@Override\n\tpublic void write(Object obj, File file) throws IJunitException {\n\t\t\n\t}", "public static void writeOut(String iFilename, String iContents)\n {\n File wFile = new File(iFilename);\n BufferedWriter bw = null;\n \n try\n {\n bw = new BufferedWriter(new FileWriter(wFile));\n bw.write(iContents);\n bw.close();\n }\n catch(Exception e)\n {\n e.printStackTrace();\n }\n }", "private void saveTextToFile(String content, File file) {\n try {\n PrintWriter writer;\n writer = new PrintWriter(file);\n writer.println(content);\n writer.close();\n } catch (IOException ex) {\n Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);\n }\n }", "static void writeFile(){\n try{\n Path contactsListPath = Paths.get(\"contacts\",\"contacts.txt\");\n Files.write(contactsListPath, contactList);\n } catch(IOException ioe){\n ioe.printStackTrace();\n }\n //refreshes list of Contact objs\n fileToContactObjs();\n }", "@Override\n public void writeDataToTxtFile() {\n\n }", "public static void write(String content, String fileName) throws IOException {\n FileWriter fileWriter = new FileWriter(FileCreator.create(fileName));\n fileWriter.write(content);\n fileWriter.flush();\n fileWriter.close();\n }", "public void write(File dest) throws IOException, RenderException {\r\n\t\twrite(dest, true);\r\n\t}", "public synchronized void write(StyxFileClient client, long offset, \n int count, ByteBuffer data, boolean truncate, int tag)\n throws StyxException\n {\n if (this.mustExist && !this.file.exists())\n {\n // The file has been removed\n log.debug(\"The file \" + this.file.getPath() +\n \" has been removed by another process\");\n // Remove the file from the Styx server\n this.remove();\n throw new StyxException(\"The file \" + this.name + \" was removed.\");\n }\n try\n {\n int nWritten = 0;\n // If we're writing zero bytes to the end of the file, this is an\n // EOF signal\n if (data.remaining() == 0 && offset == this.file.length())\n {\n log.debug(\"Got EOF signal\");\n this.eofWritten = true;\n }\n else\n {\n // Open a new FileChannel for writing. Can't use FileOutputStream\n // as this doesn't allow successful writing at a certain file offset:\n // for some reason everything before this offset gets turned into\n // blank spaces.\n FileChannel chan = new RandomAccessFile(this.file, \"rw\").getChannel();\n\n // Remember old limit and position\n int pos = data.position();\n int lim = data.limit();\n // Make sure only the requested number of bytes get written\n data.limit(data.position() + count);\n \n // Write to the file\n nWritten = chan.write(data.buf(), offset);\n\n // Reset former buffer positions\n data.limit(lim).position(pos);\n\n // Truncate the file at the end of the new data if requested\n if (truncate)\n {\n log.debug(\"Truncating file at \" + (offset + nWritten) + \" bytes\");\n chan.truncate(offset + nWritten);\n }\n // We haven't reached EOF yet\n this.eofWritten = false;\n // Close the channel\n chan.close();\n }\n // Reply to the client\n this.replyWrite(client, nWritten, tag);\n }\n catch(IOException ioe)\n {\n throw new StyxException(\"An error of class \" + ioe.getClass() + \n \" occurred when trying to write to \" + this.getFullPath() +\n \": \" + ioe.getMessage());\n }\n }", "private void createFile(String outputData, File file) {\n try {\n FileWriter writer = new FileWriter(file);\n writer.write(outputData);\n writer.close();\n } catch (IOException e) {\n e.getSuppressed();\n }\n }", "public int putFile(String targetHost, String userName, String password, String datastore, String filename,\n String filePath) throws HyperVException;", "public final void toFile(final File xmlFile) throws IOException {\n if (xmlFile == null) throw new FileNotFoundException(\"file is null\");\n\n PrintWriter pw = new PrintWriter(new FileWriter(xmlFile));\n pw.print(toString());\n pw.close();\n }", "public void write(File output) throws IOException {\n }", "private void writeStringToFile(String filenamePath, String fileContent) throws ServletException {\n\n final File destinationFile = new File(filenamePath);\n try {\n Files.write(fileContent, destinationFile, Charsets.UTF_8);\n } catch (IOException e) {\n throw new ServletException(\n \"cant write to file '\" + filenamePath + \"' these contents: '\" +\n fileContent + \"'\", e);\n }\n }" ]
[ "0.7360737", "0.6943926", "0.69413364", "0.6570574", "0.654972", "0.64868253", "0.6482886", "0.6443035", "0.64364225", "0.64295256", "0.6429255", "0.6400471", "0.62475866", "0.6232803", "0.62323546", "0.62177503", "0.615483", "0.61504066", "0.6140633", "0.61326444", "0.6118369", "0.61141086", "0.6090762", "0.6082734", "0.6076603", "0.60563767", "0.60325676", "0.6024846", "0.6022327", "0.5968426", "0.5966591", "0.5916592", "0.5890652", "0.58864516", "0.5884682", "0.5864927", "0.58632386", "0.58511126", "0.58489704", "0.58439076", "0.58434004", "0.5839158", "0.5838247", "0.583088", "0.58235234", "0.58232826", "0.581953", "0.58096284", "0.58070195", "0.580569", "0.5804421", "0.580069", "0.5798453", "0.5787653", "0.57844377", "0.5783774", "0.5771067", "0.5748495", "0.5746177", "0.57418257", "0.5738438", "0.57320124", "0.5729975", "0.5729384", "0.57239616", "0.57206637", "0.57152075", "0.5709628", "0.57094055", "0.57072693", "0.5704007", "0.570023", "0.5696443", "0.5686724", "0.56454843", "0.5642717", "0.56404835", "0.5633437", "0.563262", "0.56271845", "0.56261575", "0.56189394", "0.5616394", "0.56144315", "0.5602763", "0.56027615", "0.559924", "0.55864406", "0.55720955", "0.55668914", "0.5557504", "0.5554516", "0.55526465", "0.5552574", "0.55416816", "0.55351543", "0.55175394", "0.55152917", "0.55111927", "0.55099845", "0.5507779" ]
0.0
-1
Returns a Pattern that plays two notes in rapid succession (for a total of each note being played numHammers times) over the given duration. The resulting Pattern will have note1 and note2 both represented numHammers times. Example: hammerOn(new Note("C5"), new Note("E5"), 0.5, 4); will produce this Pattern: [60]/0.125 [64]/0.125 [60]/0.125 [64]/0.125 [60]/0.125 [64]/0.125 [60]/0.125 [64]/0.125
public static PatternInterface hammerOn(Note note1, Note note2, double duration, int numHammers) { StringBuilder buddy = new StringBuilder(); double durationPerHammer = duration / numHammers; buddy.append("["); buddy.append(note1.getValue()); buddy.append("]/"); buddy.append(durationPerHammer / 2.0); buddy.append(" ["); buddy.append(note2.getValue()); buddy.append("]/"); buddy.append(durationPerHammer / 2.0); PatternInterface pattern = new Pattern(buddy.toString()); pattern.repeat(numHammers); return pattern; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static PatternInterface trill(Note note1, Note note2, double duration, int numSteps)\r\n {\r\n return hammerOn(note1, note2, duration, numSteps);\r\n }", "public static PatternInterface slide(Note note1, Note note2, double duration, int numSteps)\r\n {\r\n StringBuilder buddy = new StringBuilder();\r\n double durationPerStep = duration / numSteps;\r\n double freq1 = Note.getFrequencyForNote(note1.getValue());\r\n double freq2 = Note.getFrequencyForNote(note2.getValue());\r\n double differencePerStep = (freq2-freq1) / numSteps;\r\n\r\n for (int i=0; i < numSteps; i++)\r\n {\r\n buddy.append(MicrotoneNotation.convertFrequencyToMusicString(freq1));\r\n buddy.append(\"/\");\r\n buddy.append(durationPerStep);\r\n buddy.append(MicrotoneNotation.getResetPitchWheelString());\r\n buddy.append(\" \");\r\n freq1 += differencePerStep;\r\n }\r\n\r\n PatternInterface pattern = new Pattern(buddy.toString());\r\n return pattern;\r\n }", "public B mo4686d(int duration) {\n this.f1121g = duration;\n return this;\n }", "public static PatternInterface trill(Note baseNote, char trillDirection, double singleSoundDuration){\r\n \r\n \tStringBuilder musicStringBuilder = new StringBuilder();\r\n \r\n \tdouble totalDuration = baseNote.getDecimalDuration();\r\n double actualDuration = 0.0d;\r\n \r\n byte secondNote = baseNote.getValue();\r\n \r\n if(trillDirection == EFFECT_DIRECTION_UP){\r\n \tsecondNote++;\r\n } else if(trillDirection == EFFECT_DIRECTION_DOWN){\r\n \tsecondNote--;\r\n }\r\n \r\n double remainingDuration = totalDuration - (2*singleSoundDuration);\r\n if(remainingDuration > 0.0d){\r\n \t\r\n \tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \tactualDuration+=singleSoundDuration;\r\n \t\r\n \twhile(actualDuration < totalDuration){\r\n \t\tif(actualDuration + (2*singleSoundDuration) < totalDuration){\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, secondNote, singleSoundDuration);\r\n \t\t\tactualDuration += singleSoundDuration;\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \t\t\tactualDuration += singleSoundDuration;\r\n \t\t} else if(actualDuration + singleSoundDuration > totalDuration){\r\n \t\t\tdouble gapDuration = totalDuration - actualDuration;\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), gapDuration);\r\n \t\t\tactualDuration+=gapDuration;\r\n \t\t} else {\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \t\t\tactualDuration+=singleSoundDuration;\r\n \t\t}\r\n \t}\r\n \treturn new Pattern(musicStringBuilder.toString().trim());\r\n } else {\r\n \treturn new Pattern(baseNote.getMusicString());\r\n }\r\n }", "void note(float start, float duration, float freq){\n\t out.playNote(start,duration,freq); \n\t }", "void addRepeat(int beatNum, RepeatType repeatType);", "public void generateTone()\n throws LineUnavailableException {\n if ( clip!=null ) {\n clip.stop();\n clip.close();\n } else {\n clip = AudioSystem.getClip();\n }\n boolean addHarmonic = harmonic.isSelected();\n\n int intSR = ((Integer)sampleRate.getSelectedItem()).intValue();\n int intFPW = framesPerWavelength.getValue();\n\n float sampleRate = (float)intSR;\n\n // oddly, the sound does not loop well for less than\n // around 5 or so, wavelengths\n int wavelengths = 20;\n byte[] buf = new byte[2*intFPW*wavelengths];\n AudioFormat af = new AudioFormat(\n sampleRate,\n 8, // sample size in bits\n 2, // channels\n true, // signed\n false // bigendian\n );\n\n int maxVol = 127;\n for(int i=0; i<intFPW*wavelengths; i++){\n double angle = ((float)(i*2)/((float)intFPW))*(Math.PI);\n buf[i*2]=getByteValue(angle);\n if(addHarmonic) {\n buf[(i*2)+1]=getByteValue(2*angle);\n } else {\n buf[(i*2)+1] = buf[i*2];\n }\n }\n\n try {\n byte[] b = buf;\n AudioInputStream ais = new AudioInputStream(\n new ByteArrayInputStream(b),\n af,\n buf.length/2 );\n\n clip.open( ais );\n } catch(Exception e) {\n e.printStackTrace();\n }\n }", "String getDelayPattern();", "private static void getPatterns(int size) {\n\t\t// TODO Auto-generated method stub\n\t\thashOne = new HashMap<SequencePair,Integer>();\n\t\thashTwo = new HashMap<SequencePair,Integer>();\n\t\tArrayList<Integer> first;\n\t\tArrayList<Integer> second;\n\t\tArrayList<Integer> third;\n\t\t\n\t\t//System.out.println(lrcSeq.size());\n\t\t\n\t\tfor(int i = 0; i < lrcSeq.size() - size ;++i) {\n\t\t\tfirst = new ArrayList<Integer>();\n\t\t\tsecond = new ArrayList<Integer>();\n\t\t\tthird = new ArrayList<Integer>();\n\t\t\t\n\t\t\tfor(int j = i; j < i+ size ;++j) {\n\t\t\t\tfirst.add(lrcSeq.get(j));\n\t\t\t\tsecond.add(meloSeq.get(j));\n\t\t\t\tthird.add(durSeq.get(j));\n\t\t\t}\n\t\t\t//System.out.println(first);\n\t\t\t//System.out.println(second);\n\t\t\t//System.out.println(third);\n\t\t\tSequencePair cur= new SequencePair(first, second);\n\t\t\n\t\t\tint count = hashOne.containsKey(cur)?hashOne.get(cur):0;\n\t\t\thashOne.put(cur, count+1);\n\t\t\t\n\t\t\tcur = new SequencePair(second, third);\n\t\t\tcount = hashTwo.containsKey(cur)?hashTwo.get(cur):0;\n\t\t\thashTwo.put(cur, count+1);\n\t\t\n\t\t}\n\t\n\t}", "public static int nextNote(int n1,int n2) {\n double rnd,sum=0;\n rnd=Math.random();\n for(int i=0;i<12;i++)\n {\n sum+=weights[n1-60][n2-60][i];\n\n if(rnd<=sum)\n return i+60;\n }\n return 62;\n }", "public void playChord(float[] pitches, double dynamic, double duration) {\n\t\tthis.soundCipher.playChord(pitches, dynamic, duration);\n\t}", "public void playSong() {\n\t\t// Initialize\n\t\tint num = 1;\n\n\t\t// Get the notes to be played from the entryBox\n\t\tString notesString = \"V0 \" + instrumentType + \" \" + entryBox.getText();\n\n\t\t// Create a new rhythm object\n\t\tRhythm rhythm = new Rhythm();\n\n\t\t// Get the rhythm strings from the rhythm entry boxes\n\t\tString rhythmLayer1 = \"V1 \" + rhythm1.getText();\n\t\tString rhythmLayer2 = \"V2 \" + rhythm2.getText();\n\n\t\t// Set the strings to layers\n\t\trhythm.setLayer(1, rhythmLayer1);\n\t\trhythm.setLayer(2, rhythmLayer2);\n\n\t\t// Add the appropriate substitutions\n\t\trhythm.addSubstitution('O', \"[BASS_DRUM]i\");\n\t\trhythm.addSubstitution('o', \"Rs [BASS_DRUM]s\");\n\t\trhythm.addSubstitution('*', \"[ACOUSTIC_SNARE]i\");\n\t\trhythm.addSubstitution('^', \"[PEDAL_HI_HAT]s Rs\");\n\t\trhythm.addSubstitution('!', \"[CRASH_CYMBAL_1]s Rs\");\n\t\trhythm.addSubstitution('.', \"Ri\");\n\n\t\t// Get the rhythm pattern\n\t\tPattern rhythmPattern = rhythm.getPattern();\n\n\t\t// Get how many times the song should repeat\n\t\tString repeatNum = repeatNumber.getText();\n\t\tnum = Integer.parseInt(repeatNum);\n\n\t\t// Get the playback tempo\n\t\tString playTempo = \"T[\" + tempo.getText() + \"] \";\n\n\t\t// Create the song\n\t\tPattern song = new Pattern();\n\t\tsong.add(rhythmPattern);\n\t\tsong.add(notesString);\n\t\tsong.repeat(num);\n\n\t\t// Play the song\n\t\tplayer.play(playTempo + song);\n\n\t}", "private static double[] note(double hz, double duration, double amplitude) {\n int N = (int) (StdAudio.SAMPLE_RATE * duration);\n double[] a = new double[N + 1];\n for (int i = 0; i <= N; i++)\n a[i] = amplitude * Math.sin(2 * Math.PI * i * hz / StdAudio.SAMPLE_RATE);\n return a;\n }", "@Override\n public void addNote(int startTime, int duration, Pitch pitch, Octave octave) {\n List<Note> notes = new ArrayList<>();\n Note newNote = new SimpleNote(pitch, octave, startTime, duration);\n notes.add(newNote);\n\n if (this.notes.get(startTime) == null) {\n this.notes.put(startTime, notes);\n } else {\n List<Note> oldList = this.notes.remove(startTime);\n oldList.addAll(notes);\n this.notes.put(startTime, oldList);\n }\n\n }", "public void mainDecoder(int b, Integer[] playedChord){\n\n while(beatCounter<b){\n for(int i =0; i < rhytm.get(beatCounter).length;i++)\n {\n if(rhytm.get(beatCounter)[i]!=null) {\n if ((!rhytm.get(beatCounter)[i].equals(\"Ri\")) && (!rhytm.get(beatCounter)[i].equals(\"Rs\"))) {\n\n //TODO DECODE HARMONIC NOTE AT EVERY FIRST AND THIRD BEAT AT FIRST NOTE PLAYED\n if (beatCounter % 2 == 0 && i == 0) {\n for (int j = 0; j < playedChord.length; j++) {\n if (playedChord[j] == melody.get(melodyCounter)) {\n if(j<2){\n binaryOutput+=\"0\";\n binaryOutput+=Integer.toBinaryString(j);\n }else{\n binaryOutput+=Integer.toBinaryString(j);\n }\n //todo SAVE FOR LATER COMPARISON\n if(beatCounter==0)\n firstChordNote=melody.get(melodyCounter);\n if(beatCounter==16)\n secondChordNote=melody.get(melodyCounter);\n\n previousNote = melody.get(melodyCounter);\n melodyCounter++;\n break;\n }\n }\n //TODO DECODE EVERY OTHER NOTE, ENCODED WITH AUTOMATON\n } else {\n //// TODO WAS MELODY ASCENDING OR DESCENDING\n if (previousNote >= 55 && previousNote <= 79)\n if (previousNote < melody.get(melodyCounter))\n binaryOutput+=\"1\";\n else\n binaryOutput+=\"0\";\n\n //todo WAS IT STEP OR LEAP\n for (int j = 0; j < melodyNotes.length; j++) {\n if (melodyNotes[j].equals(previousNote)) {\n previousNotePosition = j;\n break;\n }\n }\n for (int j = 0; j < melodyNotes.length; j++) {\n if (melodyNotes[j].equals(melody.get(melodyCounter))) {\n previousNote=melodyNotes[j];\n int difference = abs(j - previousNotePosition);\n if (difference > 1) {\n binaryOutput+=\"1\";\n binaryOutput+=new Integer(difference - 2).toString();\n } else\n binaryOutput+=\"0\";\n break;\n }\n }\n melodyCounter++;\n }\n }\n }\n }\n beatCounter++;\n }\n\n }", "public static PatternInterface graceNote(Note graceNote, Note baseNote, double graceNoteDuration){\r\n \tPattern gracePattern = new Pattern(graceNote.getMusicString());\r\n \treturn addOrnament(gracePattern, baseNote, graceNoteDuration);\r\n }", "public Note(int _pitch, int _duration, int _dynamic) {\n pitch = _pitch;\n duration = _duration;\n dynamic = _dynamic;\n tiedIn = false;\n tiedOut = false;\n displayDynamic = false;\n }", "void addNote(int duration, int octave, int beatNum, String pitch)\n throws IllegalArgumentException;", "public Piano(int numNotes){\n pStrings = new InstString[numNotes][3];\n for(int a = 0; a < numNotes; a++){\n double freq = 440 * Math.pow(2, (double)(a-24)/(double)12);\n pStrings[a][0] = new GuitarString(freq);\n pStrings[a][1] = new GuitarString(freq + .45);\n pStrings[a][2] = new GuitarString(freq - .45);\n }\n }", "public Note(int duration, int offset, int pitch, int channel, int velocity) {\n this.duration = duration;\n this.offset = offset;\n this.pitch = pitch;\n this.channel = channel;\n this.velocity = velocity;\n }", "public final void rule__Chord__Group__1() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2876:1: ( rule__Chord__Group__1__Impl rule__Chord__Group__2 )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2877:2: rule__Chord__Group__1__Impl rule__Chord__Group__2\n {\n pushFollow(FOLLOW_rule__Chord__Group__1__Impl_in_rule__Chord__Group__15835);\n rule__Chord__Group__1__Impl();\n\n state._fsp--;\n\n pushFollow(FOLLOW_rule__Chord__Group__2_in_rule__Chord__Group__15838);\n rule__Chord__Group__2();\n\n state._fsp--;\n\n\n }\n\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "public void copiedMeasureDecoder(Integer chordNote,Integer[]previousChord, Integer[] playedChord){\n /* int c=0;\n int a=0;\n int b=0;\n int x0=0;\n int x1=0;*/\n int d1=0;\n int d2=0;\n\n\n\n for (int i=0;i<melodyNotes.length;i++){\n if(melodyNotes[i]==chordNote)\n d1=i;\n }\n for (int i=0;i<melodyNotes.length;i++){\n if(melodyNotes[i]==melody.get(melodyCounter))\n d2=i;\n /* if(melodyNotes[i]==playedChord[1])\n a=i;\n if(melodyNotes[i]==previousChord[1])\n b=i;*/\n }\n /*if(a<b){\n x0=a-b;\n x1=7+x1;\n }else{\n x0=a-b;\n x1=x0-7;\n }*/\n if(d1>d2) {\n binaryOutput += \"0\";\n }else {\n binaryOutput += \"1\";\n }\n for(int i = 0;i<4;i++){\n for(int j =0; j < rhytm.get(beatCounter).length;j++){\n if(rhytm.get(beatCounter)[j]!=null)\n if ((!rhytm.get(beatCounter)[j].equals(\"Ri\")) && (!rhytm.get(beatCounter)[j].equals(\"Rs\"))) {\n melodyCounter++;\n }\n }\n beatCounter++;\n }\n\n\n}", "public ChordBuilder(Chord chord) {\n\t\tthis.noteBuilders = new ArrayList<>(chord.getNoteCount());\n\t\tfor (Note note : chord) {\n\t\t\tthis.noteBuilders.add(new NoteBuilder(note));\n\t\t}\n\t\tthis.duration = noteBuilders.get(0).getDuration();\n\t}", "CompositionBuilder<T> setRepeat2(int repeats, int startrep, int endrep);", "public final void rule__ChordParams__Alternatives_1_1() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:758:1: ( ( ruleNote ) | ( ( rule__ChordParams__CnotesAssignment_1_1_1 ) ) )\n int alt5=2;\n alt5 = dfa5.predict(input);\n switch (alt5) {\n case 1 :\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:759:1: ( ruleNote )\n {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:759:1: ( ruleNote )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:760:1: ruleNote\n {\n before(grammarAccess.getChordParamsAccess().getNoteParserRuleCall_1_1_0()); \n pushFollow(FOLLOW_ruleNote_in_rule__ChordParams__Alternatives_1_11605);\n ruleNote();\n\n state._fsp--;\n\n after(grammarAccess.getChordParamsAccess().getNoteParserRuleCall_1_1_0()); \n\n }\n\n\n }\n break;\n case 2 :\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:765:6: ( ( rule__ChordParams__CnotesAssignment_1_1_1 ) )\n {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:765:6: ( ( rule__ChordParams__CnotesAssignment_1_1_1 ) )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:766:1: ( rule__ChordParams__CnotesAssignment_1_1_1 )\n {\n before(grammarAccess.getChordParamsAccess().getCnotesAssignment_1_1_1()); \n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:767:1: ( rule__ChordParams__CnotesAssignment_1_1_1 )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:767:2: rule__ChordParams__CnotesAssignment_1_1_1\n {\n pushFollow(FOLLOW_rule__ChordParams__CnotesAssignment_1_1_1_in_rule__ChordParams__Alternatives_1_11622);\n rule__ChordParams__CnotesAssignment_1_1_1();\n\n state._fsp--;\n\n\n }\n\n after(grammarAccess.getChordParamsAccess().getCnotesAssignment_1_1_1()); \n\n }\n\n\n }\n break;\n\n }\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "public Time( int hour, int minute, Meridiem meridiem ) {\n this(\n hour == Time.HALF_DAY_HRS ?\n meridiem == Meridiem.AM ?\n 0 :\n Time.HALF_DAY_HRS\n :\n meridiem == Meridiem.AM ?\n hour :\n hour + Time.HALF_DAY_HRS,\n minute\n );\n }", "public Note noteAt(int interval) {\n\t\tint newMidiNote = getMidiNumber() + interval;\n\t\t\n\t\treturn new Note(newMidiNote);\n\t}", "public static ArrayList<Double> generate(int n1, int n2, int ton, int phrase) throws MidiUnavailableException, InterruptedException, InvalidMidiDataException, IOException {\n Synthesizer synth = MidiSystem.getSynthesizer();\n synth.open();\n final MidiChannel[] channels = synth.getChannels();\n ArrayList<Double> normalizedResult=new ArrayList<>();\n\n int fn=n1,sn=n2,nn,tr;\n Sequence seq= new Sequence(Sequence.PPQ,10,2);\n Track track=seq.getTracks()[0];\n Track track2=seq.getTracks()[1];\n\n for(int i=0;i<phrase;i++)\n {\n nn=Weights.nextNote(fn,sn);\n\n channels[0].noteOn(nn+ton,127);\n //tr=nn+4;\n //if(Math.random()<0.5) channels[0].noteOn(tr+ton,127);\n //channels[0].noteOn(tr+3+ton,127);\n //if(Math.random()<0.2) channels[0].noteOn(tr+8+ton,127);\n\n ShortMessage sm=new ShortMessage();\n sm.setMessage(ShortMessage.NOTE_ON,nn,100);\n track.add(new MidiEvent(sm,i*4));sm=new ShortMessage();\n sm.setMessage(ShortMessage.NOTE_ON,nn+3,90);\n track.add(new MidiEvent(sm,i*4));\n\n\n\n if(i%2==0) {\n Thread.sleep(350);\n }\n else {\n Thread.sleep(150);\n }\n\n normalizedResult.add(1./nn);\n\n\n channels[0].noteOff(nn+ton);\n //channels[0].noteOff(tr+ton);\n //channels[0].noteOff(tr+3+ton);\n //channels[0].noteOff(tr+8+ton);\n fn=sn;\n sn=nn;\n }\n\n MidiSystem.write(seq, 1,new File(\"src/sample/result.mid\"));\n System.out.println(\"GG end\");\n return normalizedResult;\n }", "public static Note createNote(int value, int startBeat, int endBeat) {\n return createNote((value / 12) - 1, Pitch.getPitch(value % 12), startBeat, endBeat);\n }", "public static void addTimingPatterns(int[][] matrix) {\n\t\t\n\t\tfinal int STOP_INDEX = matrix.length - 8;\n\t\t// Horizontal line on the 6th row\n\t\t// Starts at 8th column, ends 8 cols before the end\n\t\tfor (int i = 8; i < STOP_INDEX; ++i) {\n\t\t\tmatrix[i][6] = (i % 2 == 0) ? B : W;\n\t\t}\n\t\t\n\t\t// Vertical line on the 6th column\n\t\t// Starts at 8th row, ends 8 rows before the end\n\t\tfor (int j = 8; j < STOP_INDEX; ++j) {\n\t\t\tmatrix[6][j] = (j % 2 == 0) ? B : W;\n\t\t}\n\t}", "private void genRandomPattern(float ratioInh, float ratioAct) {\n layoutPanel.inhNList = getRandomPointsIndex(ratioInh, null);\n layoutPanel.activeNList = getRandomPointsIndex(ratioAct,\n layoutPanel.inhNList);\n }", "public void repeatNotes()\n {\n int start, end;\n \n printScore(); //prints the current score that we have for the user to reference\n \n System.out.print(\"\\nEnter the note number that starts the repetition > \"); //prompts to enter the start of the repetition\n start = in.nextInt();\n \n System.out.print(\"Enter the note number that ends the repetition > \"); //prompts user to enter the end of the repetition\n end = in.nextInt();\n \n if (start <= score.size() && start > 0 && end <= score.size() && end >= start)\n {\n for (int i = 0; i <= ((end - 1) - (start - 1)); i++)\n {\n Note tempNote = new Note(score.get((start - 1) + i).getNote(), score.get((start - 1) + i).getBeat());\n score.add(tempNote);\n }\n }\n else\n {\n System.out.print(\"Error. \");\n if (end < 1 || end > score.size())\n System.out.println(\"The ending note number is not valid.\");\n else if (start < 1 || start > score.size())\n System.out.println(\"The starting note number is not valid.\");\n else if (start > end)\n System.out.println(\"The starting note number can not be bigger than the ending note number.\"); \n }\n }", "public TrianglePatternToy(int number){ \n this.number = number;\n }", "private static native void triggerRepeatedHapticPulse(long pointer,\n long controllerHandle,\n int targetPad,\n int durationMicroSec,\n int offMicroSec,\n int repeat,\n int flags);", "private int extendPattern(int alpha, int data_edge_index, InstanceNode data_node, Edge data_edge,\n Gene[] pattern, PatternNode extendedPatternNode,\n PatternNode pattern_node, List<Instance> Instances, int pattern_length) {\n\n Gene[] extendedPattern = appendChar(pattern, alpha);\n\n int extendedPatternLength = pattern_length + 1;\n\n int exactInstancesCount = 0;\n //go over all instances of the pattern\n for (Instance instance : Instances) {\n int currExactInstanceCount = extendInstance(pattern, extendedPatternNode, instance, alpha);\n if (currExactInstanceCount > 0) {\n exactInstancesCount = currExactInstanceCount;\n }\n }\n extendedPatternNode.setExactInstanceCount(exactInstancesCount);\n\n int instancesCount;\n if (multCount) {\n instancesCount = extendedPatternNode.getInstanceIndexCount();\n } else {\n instancesCount = extendedPatternNode.getInstanceKeysSize();\n }\n\n if (exactInstancesCount >= q1 && instancesCount >= q2) {\n\n TreeType type = extendedPatternNode.getType();\n int ret = -1;\n if (extendedPatternLength < maxPatternLength) {\n if (type == TreeType.VIRTUAL) {\n ret = spellPatternsVirtually(extendedPatternNode, data_node, data_edge_index, data_edge,\n extendedPattern, extendedPatternLength);\n } else {\n ret = spellPatterns(extendedPatternNode, extendedPattern, extendedPatternLength);\n }\n }\n\n if (extendedPatternLength >= minPatternLength) {\n\n //make sure that extendedPattern is right maximal, if extendedPattern has the same number of\n // instances as the longer pattern, prefer the longer pattern\n if (extendedPatternNode.getPatternKey() != null &&\n (instancesCount > ret || parameters.keepAllPatterns)) // instancesCount >= ret always\n {\n\n Pattern newPattern = new Pattern(extendedPatternNode.getPatternKey(),\n extendedPattern);\n\n newPattern.addInstanceLocations(extendedPatternNode.getInstances());\n\n patterns.put(newPattern.toString(), newPattern);\n\n if (debug && (getPatternsCount() % 5000 == 0)) {\n MemoryUtils.measure();\n System.out.println(getPatternsCount() + \" patterns found\");\n }\n\n } else {\n if (ret <= 0) {\n instancesCount = -1;\n } else {\n instancesCount = ret;\n }\n }\n\n }\n }\n return instancesCount;\n\n }", "public byte[] genTone(){ \n //Ramp time is the denominator of the total sample.\n //This really should be a ration of samples per cycle.\n //do this math to get a smooth sound\n int rampTime = 2000;\n //Fill the sample array.\n for (int i = 0; i < numSamples; ++i) {\n \t//Here is the brains of the operation. Don't axe me what it does\n \t//But it pretty much unrolls a sin curve into a wave\n sample[i] = Math.sin(freqOfTone * 2 * Math.PI * i / (sampleRate));\n }\n\n // convert to 16 bit pcm sound array\n // assumes the sample buffer is normalized.\n int PCMindex = 0;\n int i;\n //The ramp. It is how many samples will be ramped up.\n int ramp = numSamples/rampTime; \n\n /**\n * Ramp up the tone to avoid clicks\n */\n for (i = 0; i< ramp; ++i) { \n \t//Grab the values from the sample array for each i\n double dVal = sample[i];\n //Ramp down the value. \n //Convert a -1.0 - 1.0 double into a short. 32767 should be contant for max 16 bit signed int value \n final short val = (short) ((dVal * 32767 * i/ramp));\n //Put the value into the PCM byte array\n //Break the short into a byte using a bit mask. \n //First bit mask adds the second byte. Second bit mask adds the second byte.\n PcmArray[PCMindex++] = (byte) (val & 0x00ff);\n PcmArray[PCMindex++] = (byte) ((val & 0xff00) >>> 8);\n }\n\n for (i = ramp; i< numSamples - ramp; ++i) { \n \t//Grab the values from the sample array for each i\n double dVal = sample[i];\n //Convert a -1.0 - 1.0 double into a short. 32767 should be contant for max 16 bit signed int value\n final short val = (short) ((dVal * 32767));\n //Put the value into the PCM byte array\n //Break the short into a byte using a bit mask. \n //First bit mask adds the second byte. Second bit mask adds the second byte.\n PcmArray[PCMindex++] = (byte) (val & 0x00ff);\n PcmArray[PCMindex++] = (byte) ((val & 0xff00) >>> 8);\n }\n\n for (i = (int) (numSamples - ramp); i< numSamples; ++i) {\n \t//Grab the values from the sample array for each i\n double dVal = sample[i];\n //Convert a -1.0 - 1.0 double into a short. 32767 should be contant for max 16 bit signed int value \n //Ramp down the values\n final short val = (short) ((dVal * 32767 * (numSamples-i)/ramp ));\n //Put the value into the PCM byte array\n //Break the short into a byte using a bit mask. \n //First bit mask adds the second byte. Second bit mask adds the second byte.\n PcmArray[PCMindex++] = (byte) (val & 0x00ff);\n PcmArray[PCMindex++] = (byte) ((val & 0xff00) >>> 8);\n }\n return PcmArray;\n }", "private void genRegularPattern(float ratioInh, float ratioAct) {\n layoutPanel.inhNList.clear();\n layoutPanel.activeNList.clear();\n float ratio = ratioInh + ratioAct;\n if (ratio == 0) {\n return;\n }\n\n if (ratioInh == 0) {\n layoutPanel.activeNList = getRegularPointsIndex(ratioAct);\n return;\n } else if (ratioAct == 0) {\n layoutPanel.inhNList = getRegularPointsIndex(ratioInh);\n return;\n }\n\n // ratioInh != 0 && ratioAct != 0\n layoutPanel.activeNList = getRegularPointsIndex(ratioAct);\n layoutPanel.inhNList = getRegularPointsIndex(ratioInh);\n\n findLargestNNIPointsIndexPair(ratioInh, ratioAct);\n }", "public Note(char n, int dur) {\n\t\tnote = n;\n\t\tduration = dur;\n\t}", "CompositionBuilder<T> addNote(int start, int end, int instrument, int pitch, int volume);", "@Override\n public Pattern createPattern(Image image, String repeat) {\n return new Pattern(image, repeat);\n }", "private StringBuilder listAllPitches(int length) {\n StringBuilder builder = new StringBuilder();\n\n int padding = Integer.toString(length).length();\n String spaces = \"\";\n spaces = String.format(\"%\" + (padding) + \"s\", spaces);\n builder.append(spaces);\n\n Note highest = this.getHighestNote();\n Note lowest = this.getLowestNote();\n int ordinalHighestOctave = highest.getOctave().ordinal();\n int ordinalHighestPitch = highest.getPitch().ordinal();\n int ordinalLowOctave = lowest.getOctave().ordinal();\n int ordinalLowPitch = lowest.getPitch().ordinal();\n int from = ordinalLowOctave * 12 + ordinalLowPitch;\n int to = ordinalHighestOctave * 12 + ordinalHighestPitch;\n List<String> allNotes = this.allnotes.subList(from, to + 1);\n\n for (int i = 0; i < allNotes.size(); i++) {\n String current = allNotes.get(i);\n\n if (current.length() == 2) {\n builder.append(\" \" + current + \" \");\n } else if (current.length() == 3) {\n builder.append(\" \" + current + \" \");\n } else if (current.length() == 4) {\n builder.append(\" \" + current);\n } else {\n builder.append(current);\n }\n }\n return builder;\n }", "public void prepForRound(int wordLen, int numGuesses, HangmanDifficulty diff) {\r\n \t// initialize\r\n \tfinal char UNDISPLAYED = '-';\r\n \tthis.wordLength = wordLen;\r\n \tthis.diff = diff;\r\n \tthis.numGuesses = numGuesses;\r\n \tthis.currPattern = \"\";\r\n \tthis.times = 0;\r\n \tthis.patterns = new ArrayList<char[]>();\r\n \tthis.guesses = new ArrayList<Character>();\r\n \tthis.activeWords = new ArrayList<String>();\r\n \t// initialize current pattern\r\n \tfor (int i = 0; i < wordLen; i++) {\r\n \t\tcurrPattern += UNDISPLAYED;\r\n \t}\r\n \t// initialize active words and patterns\r\n \tfor (String s : this.words) {\r\n \t\tif (s.length() == wordLen) {\r\n \t\t\tactiveWords.add(s);\r\n \t\tchar[] ch = new char[s.length()];\r\n \t\tfor (int i = 0; i < ch.length; i++) {\r\n \t\t\tch[i] = UNDISPLAYED;\r\n \t\t}\r\n \t\tthis.patterns.add(ch);\r\n \t\t}\r\n \t}\r\n }", "public String tri4(int h){\n\t\tString S = \"\";\n\t\tint H = h;\n\t\tint HH = H;\n\t\tint Counter = 0;\n\t\tint UsingCounter = Counter;\n\n\t\twhile (H > 0){\n\t\t\tHH = H;\n\t\t\twhile (UsingCounter > 0){\n\t\t\t\tS = S + \" \";\n\t\t\t\tUsingCounter = UsingCounter - 1;}\n\t\t\twhile (HH > 0) {\n\t\t\t\tS = S + \"*\";\n\t\t\t\tHH = HH - 1;}\n\t\t\tCounter = Counter + 1;\n\t\t\tUsingCounter = Counter;\n\t\t\tS = S + \"\\n\";\n\t\t\tH = H - 1;}\n\n\t\treturn S; }", "private List<Conference> allocateTrackOnePm(List<Conference> listTemp2) {\r\n\t\tint sum3 = 0;\r\n\t\tList<Conference> listTemp3 = new LinkedList<Conference>();\r\n\t\tlistTemp3.addAll(listTemp2);\r\n\t\twhile (sum3 < PM_MINUTES_MIN || sum3 > PM_MINUTES_MAX) {\r\n\t\t\tInteger index = random.nextInt(listTemp3.size());\r\n\t\t\tConference ele = listTemp3.get(index);\r\n\t\t\tlistTemp3.remove((int)index);\r\n\t\t\tsuper.trackOnePm.add(ele);\r\n\t\t\tsum3 += ele.getTimeDuration();\r\n\t\t}\r\n\t\tsuper.trackOnePm.add(new Conference(\"Networking Event\", \"Networking Event\", 0));\r\n\t\treturn listTemp3;\r\n\t}", "public static Note createNote(int value, int startBeat, int endBeat, int instrument, int\n volume) {\n return createNote((value / 12) - 1, Pitch.getPitch(value % 12), startBeat, endBeat, instrument,\n volume);\n }", "public static Object[] scoreHomophones(String cipher, int thresholdCount, float thresholdRatio) {\n\t\tList<Object[]> results = Homophones.homophoneSearch(2, Homophones.alphabetFrom(cipher), cipher, true);\n\t\t\n\t\t//TODO: also track sums per symbol, or maybe associated sums per homophone candidate (and relate accuracy to them)\n\n\t\t// track best findings on a per-symbol basis\n\t\tMap<Character, Object[]> map = new HashMap<Character, Object[]>();\n\t\t\n\t\t// for each homophone candidate, add scores for all others that share one of its symbols\n\t\tMap<String, Integer[]> associatedSums = new HashMap<String, Integer[]>();\n\t\t\n\t\t// track all findings\n\t\tList<Object[]> list = new ArrayList<Object[]>();\n\t\t\n\t\tfor (Object[] o : results) { // array is [len of sequences, # of matches found, homophone candidate, full sequence]\n\t\t\t\n\t\t\tString str = (String) o[2];\n\t\t\tString seq = (String) o[3];\n\t\t\tInteger count = (Integer) o[1];\n\t\t\tInteger len = (Integer) o[0];\n\t\t\t//System.out.println(\"h \" + str + \" seq \" + seq + \" count \" + count + \" len \" + len);\n\t\t\tfloat ratio = (float) count*str.length()/len;\n\t\t\tif (ratio >= thresholdRatio && count > thresholdCount) {\n\t\t\t\tlist.add(new Object[] {count, str, seq});\n\t\t\t\tfor (int i=0; i<str.length(); i++) {\n\t\t\t\t\tCharacter key = str.charAt(i);\n\t\t\t\t\tObject[] val = map.get(key);\n\t\t\t\t\tif (val == null) val = new Object[] {0, null, null};\n\t\t\t\t\tint c = (Integer) val[0];\n\t\t\t\t\tif (count > c) {\n\t\t\t\t\t\tval[0] = count;\n\t\t\t\t\t\tval[1] = str;\n\t\t\t\t\t\tval[2] = seq;\n\t\t\t\t\t}\n\t\t\t\t\tmap.put(key, val);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tint total = 0;\n\t\t\t\tfor (String key : associatedSums.keySet()) {\n\t\t\t\t\t//System.out.println(\"str \" + str + \" key \" + key);\n\t\t\t\t\tif (key.indexOf(str.charAt(0)) == -1 && key.indexOf(str.charAt(1)) == -1) continue;\n\t\t\t\t\tInteger[] val = associatedSums.get(key);\n\t\t\t\t\tif (val == null) val = new Integer[] {0,0};\n\t\t\t\t\ttotal += val[0];\n\t\t\t\t\tval[1] += count;\n\t\t\t\t\tassociatedSums.put(key, val);\n\t\t\t\t\t//System.out.println(\" - val \" + val[0] + \", \" + val[1] + \" total \" + total);\n\t\t\t\t}\n\t\t\t\tassociatedSums.put(str, new Integer[] {count, total});\n\t\t\t}\n\t\t}\n\t\treturn new Object[] {map, list, associatedSums};\n\t}", "public Note(int noteNumber, int instrument) {\n this.octave = (noteNumber / 12) - 1;\n this.pitch = Pitch.pitchFromNumber(noteNumber - (this.octave * 12));\n this.instrument = instrument;\n }", "public ArrayList<ModuleElement> generateMixPattern(Module m, ModuleElement start_cell, String patternType, double mix_percentage){\n\t\tArrayList<ModuleElement> pattern = new ArrayList<ModuleElement>(); \n\t\tint i = start_cell.x;\n\t\tint j = start_cell.y; \n\t\tboolean mixed = false; \n\t\tpattern.add(start_cell); \n\t\t// ROUNDTHECLOCK pattern (going round on the borders)\n\t\tif (patternType.compareTo(\"ROUNDTHECLOCK\")== 0){\n\t\t\tif(mix_percentage>=100) mixed = true; \n\t\t\t//System.out.println(\"mix = \" + mix_percentage); \n\t\t\twhile(!mixed){\n\t\t\t//for (int kk=0; kk<1;kk++){\n\t\t\t\t// go to the right\n\t\t\t\tfor (int k=0; k<m.width-1 && !mixed; k++){\n\t\t\t\t\tj++; \n\t\t\t\t\t//System.out.println(\"(\"+i+\",\"+j+\")\"); \n\t\t\t\t\tpattern.add(new ModuleElement(i,j)); \n\t\t\t\t\tmix_percentage = computeMix(pattern,mix_percentage); \n\t\t\t\t\t//System.out.println(\"mix = \" + mix_percentage); \n\t\t\t\t\tif(mix_percentage>=100) mixed = true; \n\t\t\t\t}\n\t\t\t\t// go down\n\t\t\t\tif (!mixed) for (int k=0; k<m.height-1 && !mixed; k++){\n\t\t\t\t\ti++; \n\t\t\t\t\t//System.out.println(\"(\"+i+\",\"+j+\")\"); \n\t\t\t\t\tpattern.add(new ModuleElement(i,j)); \n\t\t\t\t\tmix_percentage = computeMix(pattern,mix_percentage); \n\t\t\t\t\tif(mix_percentage>=100) mixed = true; \n\t\t\t\t}\n\t\t\t\t// go left \n\t\t\t\tif (!mixed) for (int k=0; k<m.width-1 && !mixed; k++){\n\t\t\t\t\tj--; \n\t\t\t\t\t//System.out.println(\"(\"+i+\",\"+j+\")\"); \n\t\t\t\t\tpattern.add(new ModuleElement(i,j)); \n\t\t\t\t\tmix_percentage = computeMix(pattern,mix_percentage); \n\t\t\t\t\tif(mix_percentage>=100) mixed = true; \n\t\t\t\t}\n\t\t\t\t// go up\n\t\t\t\tif (!mixed) for (int k=0; k<m.height-1 && !mixed; k++){\n\t\t\t\t\ti--; \n\t\t\t\t\t//System.out.println(\"(\"+i+\",\"+j+\")\"); \n\t\t\t\t\tpattern.add(new ModuleElement(i,j)); \n\t\t\t\t\tmix_percentage = computeMix(pattern,mix_percentage); \n\t\t\t\t\tif(mix_percentage>=100) mixed = true; \n\t\t\t\t}\n\t\t\t}\n\t\t\t//System.out.println(\"Mix percentage: \" + mix_percentage); \n\t\t}\n\t\t// ZIGZAG pattern (back and forth on every row)\n\t\t// this one starts from one corner\n\t\tif (patternType.compareTo(\"ZIGZAG\")== 0){\n\t\t\twhile(!mixed){\n\t\t\t\tfor (int k=0; k<m.height && !mixed; k++)\n\t\t\t\t{\n\t\t\t\t\t if (k % 2 == 0)\n\t\t\t\t\t\t for (int q = 0; q<m.width && !mixed; q++){\n\t\t\t\t\t\t\t pattern.add(new ModuleElement(k,q)); \n\t\t\t\t\t\t\tif(this.computeMix(pattern,mix_percentage)>=100) mixed = true; \n\t\t\t\t\t\t }\n\t\t\t\t\t if (k % 2 != 0)\n\t\t\t\t\t\t for (int q = m.width-1; q>=0 && !mixed; q--){\n\t\t\t\t\t\t\t pattern.add(new ModuleElement(k,q));\n\t\t\t\t\t\t\tif(this.computeMix(pattern,mix_percentage)>=100) mixed = true; \n\t\t\t\t\t\t }\n\t\t\t\t}\t\n\t\t\t}\n\t\t}\n\t\t// RANDOM pattern\n\t\tif (patternType.compareTo(\"RANDOM\")== 0){\n\t\t\twhile (!mixed){\n\t\t\t\tRandom generator = new Random(); \n\t\t\t\tint r = generator.nextInt(4); \n\t\t\t\tswitch(r){\n\t\t\t\t\tcase 1: i++; \n\t\t\t\t\tcase 2: j++; \n\t\t\t\t\tcase 3: i--; \n\t\t\t\t\tcase 4: i++; \n\t\t\t\t\tdefault:break; \n\t\t\t\t}\n\t\t\t\t// test for out-of-boundaries results\n\t\t\t\tif (j>=m.width) j--; \n\t\t\t\tif (j< 0) j++; \n\t\t\t\tif (i>= m.height) i--; \n\t\t\t\tif (i< 0) i++; \n\t\t\t\tpattern.add(new ModuleElement(i,j)); \n\t\t\t\tif(this.computeMix(pattern,mix_percentage)>=100) mixed = true; \n\t\t\t}\n\t\t}\n\t\t\n\t\treturn pattern; \n\t}", "public final void rule__Midi__Group__1() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:1005:1: ( rule__Midi__Group__1__Impl rule__Midi__Group__2 )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:1006:2: rule__Midi__Group__1__Impl rule__Midi__Group__2\n {\n pushFollow(FOLLOW_rule__Midi__Group__1__Impl_in_rule__Midi__Group__12165);\n rule__Midi__Group__1__Impl();\n\n state._fsp--;\n\n pushFollow(FOLLOW_rule__Midi__Group__2_in_rule__Midi__Group__12168);\n rule__Midi__Group__2();\n\n state._fsp--;\n\n\n }\n\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "public TimeEntry duration(Integer duration) {\n this.duration = duration;\n return this;\n }", "public final void rule__Chord__Group__2() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2907:1: ( rule__Chord__Group__2__Impl rule__Chord__Group__3 )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2908:2: rule__Chord__Group__2__Impl rule__Chord__Group__3\n {\n pushFollow(FOLLOW_rule__Chord__Group__2__Impl_in_rule__Chord__Group__25897);\n rule__Chord__Group__2__Impl();\n\n state._fsp--;\n\n pushFollow(FOLLOW_rule__Chord__Group__3_in_rule__Chord__Group__25900);\n rule__Chord__Group__3();\n\n state._fsp--;\n\n\n }\n\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "private void getLosePatterns() {\r\n int losePatternsCount = 0;\r\n losePatterns = new String[loseRecords.length*2];\r\n for (int ii=0; ii<loseRecords.length;ii++) {\r\n losePatterns[ii] = loseRecords[ii].substring(0, loseRecords[ii].length() - 1);\r\n }\r\n losePatternsCount = loseRecords.length;\r\n\r\n// System.out.println(\"Lose Patterns retrieved:\");\r\n// for (int ii=0; ii<losePatternsCount; ii++) {\r\n// System.out.println(losePatterns[ii]);\r\n// }\r\n\r\n //check patterns with fixed length for new pattern.\r\n //From losePatterns[] with length 7, we get the counts of all instances having the same first 6\r\n //char (moves). If we have 3 of those, then the person can always repeat the win if the computer\r\n //take the moves up to move #5 with the same moves. Therefore, the first 5 moves constitute a\r\n //lose pattern--which can lead to the same lose. So we do:\r\n //losePatterns[] with length 7==>more losePatterns[] with length 5\r\n //losePatterns[] with length 5==>more losePatterns[] with length 3\r\n for (int ii=7; ii>=3; ii-=2) { \r\n //Count lose patterns with a specific length to construct the array to be used\r\n int countSpecificLengthPattern = 0;\r\n for (int jj=0; jj<losePatternsCount; jj++) {\r\n if ( (losePatterns[jj] != null) &&\r\n\t (losePatterns[jj].length() == ii) ) {\r\n\t countSpecificLengthPattern++;\r\n\t}\r\n }\r\n if (countSpecificLengthPattern < 3) {\r\n\tcontinue;\r\n }\t\r\n\r\n //newPattern is used to count how many lose patterns we have for a certain lose pattern\r\n //with the same moves up to the last person move\r\n //For example: for a lose pattern with 7-step, we count how many patterns we have for the \r\n //same 6-steps, storing the 6-step pattern in newPattern[] and the count in newPatternCount[]\r\n String[] newPattern = new String[countSpecificLengthPattern];\r\n int[] newPatternCount = new int[countSpecificLengthPattern];\r\n countSpecificLengthPattern = 0;\r\n for (int jj=0; jj<losePatternsCount; jj++) {\r\n if ( (losePatterns[jj] != null) &&\r\n\t (losePatterns[jj].length() == ii) ) {\r\n\t String tmpPattern = losePatterns[jj].substring(0, ii-1);\r\n\t boolean repeated = false;\r\n\t for (int kk=0; kk < countSpecificLengthPattern; kk++) {\r\n\t if (newPattern[kk].equals(tmpPattern)) {\r\n\t newPatternCount[kk] = newPatternCount[kk] + 1;\r\n\t repeated = true;\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (!repeated) {\r\n\t newPattern[countSpecificLengthPattern] = losePatterns[jj].substring(0, ii-1);\r\n newPatternCount[countSpecificLengthPattern] = 1;\r\n\t countSpecificLengthPattern++;\r\n\t }\r\n\t}\r\n }\r\n \r\n //adding new lose patterns\r\n //For a specific newPattern[], if newPatternCount[] equal to # of possibilities, we get a\r\n //new lose pattern.\r\n //For example: for a 7-step losePatterns[], we have a 6-step newPattern[], if the newPatternCount[]\r\n //for this newPattern[] is 3 (=9-7+1), we get a new losePatterns[] using the first 5 digits of\r\n //the newPattern[]\r\n for (int jj=0; jj<countSpecificLengthPattern; jj++) {\r\n\t//System.out.println(\"Pattern: \" + newPattern[jj] + \", Count=\" + newPatternCount[jj]);\r\n\tif (newPatternCount[jj] == (9-ii+1) ) {\r\n\t //got a new lose pattern\r\n losePatterns[losePatternsCount] = newPattern[jj].substring(0,ii-2);\r\n //System.out.println(\"Add new lose pattern:\" + losePatterns[losePatternsCount]);\r\n losePatternsCount++;\r\n\t}\r\n }\r\n }\r\n }", "public static void pattern1(int input) {\n\n\t\tint c = 0;\n\t\tfor (int i = 1; i <= input; i++) {\n\t\t\tif (i % 2 != 0) {\n\t\t\t\tfor (int j = 0; j < input; j++) {\n\t\t\t\t\tc++;\n\t\t\t\t\tSystem.out.print(c + \" \");\n\t\t\t\t}\n\t\t\t\tSystem.out.println();\n\t\t\t} else {\n\t\t\t\tc += input;\n\t\t\t\tfor (int j = c; j > c - input; j--) {\n\t\t\t\t\tSystem.out.print(j + \" \");\n\t\t\t\t}\n\t\t\t\tSystem.out.println();\n\t\t\t}\n\t\t}\n\t}", "public static LineQueue<Passenger> makeCommuter() {\r\n\t\tLineQueue<Passenger> commuters = new LineQueue<Passenger>();\r\n\t\tdouble t = 0;\r\n\t\tdouble a;\r\n\t\twhile (t < 3600) {\r\n\t\t\ta = genExp(90);\r\n\t\t\tif (a < 1) {\r\n\t\t\t\ta = 1;\r\n\t\t\t}\r\n\t\t\tt += a;\r\n\t\t\tif (t < 3600) {\r\n\t\t\t\tnumberCommutersMade++;\r\n\t\t\t\tPassenger passenger = new Passenger(false, false, t);\r\n\t\t\t\tcommuters.enqueue(passenger);\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn commuters;\r\n\t}", "public static void main(String[] args)\r\n\t{\r\n\t\tSystem.out.println(\"1st pattern\");\r\n\t\tfor(int i=0;i<=8;i++)\r\n\t\t{\r\n\t\t\tfor(int j=i;j<8;j++)\r\n\t\t\t{\r\n\t\t\t\tSystem.out.print(\"*\");\r\n\t\t\t}\r\n\t\t\tSystem.out.println(\"\");\r\n\t\t}\r\n\t\t/*\r\n\t\t*\r\n \t\t**\r\n\t\t***\r\n\t\t****\r\n\t\t*****\r\n\t\t******\r\n\t\t*******\r\n\t\t********\r\n\t\t */\r\n\t\tSystem.out.println(\"2nd pattern\");\r\n\t\tfor(int i=8;i>=0;i--)\r\n\t\t{\r\n\t\t\tfor(int j=i;j<8;j++)\r\n\t\t\t{\r\n\t\t\t\tSystem.out.print(\"*\");\r\n\t\t\t}\r\n\t\t\tSystem.out.println();\r\n\t\t}\r\n\t\t/* for printing this pattern\r\n\t\t\t\t * \r\n\t\t\t\t*** \r\n\t\t\t ***** \r\n\t\t\t ******* \r\n\t\t\t *********\t\t */\r\n\t\tSystem.out.print(\"3rd pattern\");\r\n\t\tfor(int i=0;i<=8;i++)\r\n\t\t{\r\n\t\t\tfor(int j=0;j<=8;j++)\r\n\t\t\t{\r\n\t\t\t\tif(i<j || j<8-i)\r\n\t\t\t\t{\r\n\t\t\t\t\tSystem.out.print(\" \");\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tSystem.out.print(\"*\");\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t\tSystem.out.println();\r\n\t\t}\r\n\t\t/* for printing 4th pattern \r\n\t\t ********* \r\n\t\t ******* \r\n\t\t ***** \r\n\t\t *** \r\n\t\t * \r\n\t\t */\r\n\t\tSystem.out.println(\"4th pattern\\n\\n\");\r\n\t\tfor(int i=8;i>=0;i--)\r\n\t\t{\r\n\t\t\tfor(int j=0;j<=8;j++)\r\n\t\t\t{\r\n\t\t\t\tif(i<j || j<8-i)\r\n\t\t\t\t{\r\n\t\t\t\t\tSystem.out.print(\" \");\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tSystem.out.print(\"*\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tSystem.out.println(\" \");\r\n\t\t\t\r\n\t\t}\r\n\t\tSystem.out.println(\"5th pattern \");\r\n\t\tfor(int i=1;i<=10;i++)\r\n\t\t{\r\n\t\t\tfor(int j=1;j<=10;j++)\r\n\t\t\t{\r\n\t\t\t\tif(i<j || i==j)\r\n\t\t\t\t{\r\n\t\t\t\t\tSystem.out.print(\" \");\r\n\t\t\t\t}\r\n\t\t\t\telse if(j>i || j<10-i)\r\n\t\t\t\t{\r\n\t\t\t\t\tSystem.out.print(\"*\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tSystem.out.println();\r\n\t\t}\r\n\t}", "private void loveYourz()\n {\n Song loveYourz = new Song();\n loveYourz.add(new Note(noteD4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteG3, 0));\n loveYourz.add(new Note(noteDS3, 0));\n loveYourz.add(new Note(noteC2, 0));\n loveYourz.add(new Note(noteC1, WHOLE_NOTE/2));\n\n loveYourz.add(new Note(noteD4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteG3, 0));\n loveYourz.add(new Note(noteDS3, 0));\n loveYourz.add(new Note(noteC2, 0));\n loveYourz.add(new Note(noteC1, WHOLE_NOTE/4));\n\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteG3, 0));\n loveYourz.add(new Note(noteDS2, 0));\n loveYourz.add(new Note(noteDS1, WHOLE_NOTE/4));\n\n\n loveYourz.add(new Note(noteG4, 0));\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteC4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/2));\n\n loveYourz.add(new Note(noteG4, 0));\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteC4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/8));\n\n loveYourz.add(new Note(noteF4, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/8));\n\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/8));\n\n loveYourz.add(new Note(noteD4, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/8));\n\n\n loveYourz.add(new Note(noteD4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteG3, 0));\n loveYourz.add(new Note(noteDS3, 0));\n loveYourz.add(new Note(noteC2, 0));\n loveYourz.add(new Note(noteC1, WHOLE_NOTE/2));\n\n loveYourz.add(new Note(noteD4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteG3, 0));\n loveYourz.add(new Note(noteDS3, 0));\n loveYourz.add(new Note(noteC2, 0));\n loveYourz.add(new Note(noteC1, WHOLE_NOTE/4));\n\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteG3, 0));\n loveYourz.add(new Note(noteDS2, 0));\n loveYourz.add(new Note(noteDS1, WHOLE_NOTE/4));\n\n\n loveYourz.add(new Note(noteG4, 0));\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteC4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/2));\n\n loveYourz.add(new Note(noteG4, 0));\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteC4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/4));\n\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/4));\n playSong(loveYourz);\n playSong(loveYourz);\n }", "void pulse(double pulseLength);", "private Bike_Wheel_Animation renderPatternColorList() {\n return new Bike_Wheel_Animation(colorList, slice);\n }", "@Test\r\n public void Test027generateNextPatternBlinker()\r\n {\r\n gol.makeLiveCell(4, 3);\r\n gol.makeLiveCell(4, 4);\r\n gol.makeLiveCell(4, 5);\r\n gol.generateNextPattern();\r\n\r\n assertEquals(3, gol.getTotalAliveCells());\r\n }", "void playTone(){\n t = new Thread() {\n public void run(){\n isRunning = true;\n setPriority(Thread.MAX_PRIORITY);\n\n\n\n audioTrack.play();\n\n for (int i = 0; i < message.length(); i++) {\n\n ASCIIBreaker breaker = new ASCIIBreaker((int)message.charAt(i));\n\n int frequencies[] = breaker.ASCIIToFrequency();\n\n //Generate waves for all different frequencies\n for(int fre : frequencies) {\n audioTrack.write(generateSineInTimeDomain(fre),0,sample_size);\n }\n\n audioTrack.write(generateSineInTimeDomain(7000),0,sample_size);\n }\n\n audioTrack.stop();\n audioTrack.release();\n }\n };\n t.start();\n }", "private void updateMatchType(int startTactus, int noteLengthTacti) {\n\t\tint beatLength = subBeatLength * measure.getSubBeatsPerBeat();\n\t\tint measureLength = beatLength * measure.getBeatsPerMeasure();\n\t\t\n\t\tint subBeatOffset = startTactus % subBeatLength;\n\t\tint beatOffset = startTactus % beatLength;\n\t\tint measureOffset = startTactus % measureLength;\n\t\t\n\t\tif (matches(MetricalLpcfgMatch.SUB_BEAT)) {\n\t\t\t// Matches sub beat (and not beat)\n\t\t\t\n\t\t\tif (noteLengthTacti < subBeatLength) {\n\t\t\t\t// Note is shorter than a sub beat\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti == subBeatLength) {\n\t\t\t\t// Note is exactly a sub beat\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti < beatLength) {\n\t\t\t\t// Note is between a sub beat and a beat in length\n\t\t\t\t\n\t\t\t\t// Can only happen when the beat is divided in 3, but this is 2 sub beats\n\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti == beatLength) {\n\t\t\t\t// Note is exactly a beat in length\n\t\t\t\t\n\t\t\t\t// Must match exactly\n\t\t\t\taddMatch(beatOffset == 0 ? MetricalLpcfgMatch.BEAT : MetricalLpcfgMatch.WRONG);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t// Note is greater than a beat in length\n\t\t\t\t\n\t\t\t\tif (noteLengthTacti % beatLength != 0) {\n\t\t\t\t\t// Not some multiple of the beat length\n\t\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\t\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t} else if (matches(MetricalLpcfgMatch.BEAT)) {\n\t\t\t// Matches beat (and not sub beat)\n\t\t\t\n\t\t\tif (noteLengthTacti < subBeatLength) {\n\t\t\t\t// Note is shorter than a sub beat\n\t\t\t\t\n\t\t\t\tif (subBeatLength % noteLengthTacti != 0 || subBeatOffset % noteLengthTacti != 0) {\n\t\t\t\t\t// Note doesn't divide sub beat evenly\n\t\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti == subBeatLength) {\n\t\t\t\t// Note is exactly a sub beat\n\t\t\t\t\n\t\t\t\t// Must match sub beat exactly\n\t\t\t\taddMatch(subBeatOffset == 0 ? MetricalLpcfgMatch.SUB_BEAT : MetricalLpcfgMatch.WRONG);\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti < beatLength) {\n\t\t\t\t// Note is between a sub beat and a beat in length\n\t\t\t\t\n\t\t\t\t// Wrong if not aligned with beat at onset or offset\n\t\t\t\tif (beatOffset != 0 && beatOffset + noteLengthTacti != beatLength) {\n\t\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti == beatLength) {\n\t\t\t\t// Note is exactly a beat in length\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t// Note is longer than a beat in length\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t} else {\n\t\t\t// Matches neither sub beat nor beat\n\t\t\t\n\t\t\tif (noteLengthTacti < subBeatLength) {\n\t\t\t\t// Note is shorter than a sub beat\n\t\t\t\t\n\t\t\t\tif (subBeatLength % noteLengthTacti != 0 || subBeatOffset % noteLengthTacti != 0) {\n\t\t\t\t\t// Note doesn't divide sub beat evenly\n\t\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti == subBeatLength) {\n\t\t\t\t// Note is exactly a sub beat\n\t\t\t\t\n\t\t\t\t// Must match sub beat exactly\n\t\t\t\taddMatch(subBeatOffset == 0 ? MetricalLpcfgMatch.SUB_BEAT : MetricalLpcfgMatch.WRONG);\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti < beatLength) {\n\t\t\t\t// Note is between a sub beat and a beat in length\n\t\t\t\t\n\t\t\t\t// Wrong if not aligned with beat at onset or offset\n\t\t\t\tif (beatOffset != 0 && beatOffset + noteLengthTacti != beatLength) {\n\t\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti == beatLength) {\n\t\t\t\t// Note is exactly a beat in length\n\t\t\t\t\n\t\t\t\t// Must match beat exactly\n\t\t\t\taddMatch(beatOffset == 0 ? MetricalLpcfgMatch.BEAT : MetricalLpcfgMatch.WRONG);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t// Note is greater than a beat in length\n\t\t\t\t\n\t\t\t\tif (measureLength % noteLengthTacti != 0 || measureOffset % noteLengthTacti != 0 ||\n\t\t\t\t\t\tbeatOffset != 0 || noteLengthTacti % beatLength != 0) {\n\t\t\t\t\t// Note doesn't divide measure evenly, or doesn't match a beat\n\t\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "public Chord duplicate ()\r\n {\r\n // Beams are not copied\r\n Chord clone = new Chord(getMeasure(), slot);\r\n clone.stem = stem;\r\n stem.addTranslation(clone);\r\n\r\n // Notes (we make a deep copy of each note)\r\n List<TreeNode> notesCopy = new ArrayList<>();\r\n notesCopy.addAll(getNotes());\r\n\r\n for (TreeNode node : notesCopy) {\r\n Note note = (Note) node;\r\n new Note(clone, note);\r\n }\r\n\r\n clone.tupletFactor = tupletFactor;\r\n\r\n clone.dotsNumber = dotsNumber;\r\n clone.flagsNumber = flagsNumber; // Not sure TODO\r\n\r\n // Insure correct ordering of chords within their container\r\n ///Collections.sort(getParent().getChildren(), chordComparator);\r\n\r\n return clone;\r\n }", "void addNote(int duration, int octave, int beatNum, int instrument, int volume, String pitch)\n throws IllegalArgumentException;", "public final void rule__TimeSignature__Group__2__Impl() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2695:1: ( ( ( rule__TimeSignature__NoteAssignment_2 ) ) )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2696:1: ( ( rule__TimeSignature__NoteAssignment_2 ) )\n {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2696:1: ( ( rule__TimeSignature__NoteAssignment_2 ) )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2697:1: ( rule__TimeSignature__NoteAssignment_2 )\n {\n before(grammarAccess.getTimeSignatureAccess().getNoteAssignment_2()); \n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2698:1: ( rule__TimeSignature__NoteAssignment_2 )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2698:2: rule__TimeSignature__NoteAssignment_2\n {\n pushFollow(FOLLOW_rule__TimeSignature__NoteAssignment_2_in_rule__TimeSignature__Group__2__Impl5490);\n rule__TimeSignature__NoteAssignment_2();\n\n state._fsp--;\n\n\n }\n\n after(grammarAccess.getTimeSignatureAccess().getNoteAssignment_2()); \n\n }\n\n\n }\n\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "public static String[][] createPattern()\n {\n //the game is more like a table of 6 columns and 6 rows\n\t\n\t//we're going to have to make a 2D array of 7 rows \n\n String[][] f = new String[7][15];\n\n //Time to loop over each row from up to down\n\n for (int i = 0; i < f.length; i++)\n { \n for (int j = 0; j < f[i].length; j++)\n {\n if (j % 2 == 0) f[i][j] =\"|\";\n\n else f[i][j] = \" \";\n \n if (i==6) f[i][j]= \"-\";\n } \n }\n return f;\n }", "public static ArrayList<PitchCandidate> harmonicChecks(ArrayList<PitchCandidate> pitch_candidates, MelodicNote CF_note, Integer previous_cf_pitch,\n Integer previous_melody_pitch, MelodicNote fragment_note, int canon_transpose_interval ){\n Boolean large_dissonance_bad = InputParameters.large_dissonance_bad;\n Integer [] consonances = InputParameters.consonances;\n Integer [] perfect_consonances = InputParameters.perfect_consonances;\n Integer [] root_consonances = InputParameters.root_consonances;\n \n\n for (PitchCandidate myPC : pitch_candidates){\n\t\t\n Integer cand_pitch = myPC.getPitch() + canon_transpose_interval;\n Integer cf_pitch = CF_note.getPitch();\n boolean CF_accent = CF_note.getAccent();\n boolean use_CF_accent = false;\n if (CF_note.getRest()) cf_pitch = previous_cf_pitch;\n Integer cand_prev_pitch = previous_melody_pitch + canon_transpose_interval;\n //if(previous_melody_pitch == 9999) cand_prev_pitch = cand_pitch;// 9999 means the CP is held over to multiple cfs\n Integer melody_motion_to_cand = cand_pitch - cand_prev_pitch;\n int this_interval = abs(cand_pitch - cf_pitch)%12;\n int this_inv_interval = abs(cf_pitch - cand_pitch)%12;\n Integer melodic_motion_to_ = cf_pitch - previous_cf_pitch;\n Integer previous_interval = abs(cand_prev_pitch - previous_cf_pitch)%12;\n Integer previous_inv_interval = abs(previous_cf_pitch - cand_prev_pitch)%12;\n Double cp_start_time = fragment_note.getStartTime();\n Double cf_start_time = CF_note.getStartTime();\n Boolean directm = false;\n boolean this_interval_consonant = false;\n boolean this_inv_interval_consonant = false;\n boolean cand_prev_cf_diss = true;\n boolean inv_cand_prev_cf_diss = true;\n boolean previous_interval_consonant = false;\n boolean previous_inv_interval_consonant = false;\n \n //System.out.println(\"evaluating pitch candidate \" + cand_pitch + \" against \" + cf_pitch);\n //is this interval consonant\n for (Integer consonance : consonances) {\n if (this_interval == consonance){\n this_interval_consonant = true; \n break;\n }\n }\n for (Integer consonance : consonances) {\n if (this_inv_interval == consonance){\n this_inv_interval_consonant = true; \n break;\n }\n }\n\t \t\n \n if(this_interval_consonant && this_inv_interval_consonant) {\n //System.out.println(cand_pitch + \" against \" + cf_pitch + \"is consonant\");\n if (this_interval ==0) {//decrement if an octave\n myPC.decrementRank(Decrements.octave);\n }\n }\n \n else {\n //System.out.println(cand_pitch + \" against \" + cf_pitch + \"is dissonant\");\n myPC.decrementRank(Decrements.dissonance);\n\t\t//decrement if a minor 9th\n if (this_interval == 1 && (abs(cand_pitch - cf_pitch)<14 || large_dissonance_bad)){\n myPC.decrementRank(Decrements.minor_9th);\n myPC.set_minor_9th();\n }\n if (this_inv_interval == 1 && (abs(cf_pitch - cand_pitch)<14 || large_dissonance_bad)){\n myPC.decrementRank(Decrements.minor_9th);\n myPC.set_minor_9th();\n }\n //decrement accented dissonance\n if (CF_note.getStartTime() > fragment_note.getStartTime())\n use_CF_accent = true;\n \n if (!use_CF_accent) {\n if (fragment_note.getAccent() && (abs(cand_pitch - cf_pitch)<36 || large_dissonance_bad)) {\n //System.out.println(\"caught accented dissoance\");\n myPC.decrementRank(Decrements.accented_dissonance);\n myPC.set_accent_diss();\n }\n if (fragment_note.getAccent() && (abs(cf_pitch - cand_pitch)<36 || large_dissonance_bad)) {\n //System.out.println(\"caught accented dissoance\");\n myPC.decrementRank(Decrements.accented_dissonance);\n myPC.set_accent_diss();\n } \n }\n else {\n if (CF_note.getAccent() && (abs(cand_pitch - cf_pitch)<36 || large_dissonance_bad)) {\n System.out.println(\"caught accented dissonance between cand pitch \" + cand_pitch + \" and cf_pitch \" + cf_pitch);\n myPC.decrementRank(Decrements.accented_dissonance);\n myPC.set_accent_diss();\n }\n if (CF_note.getAccent() && (abs(cf_pitch - cand_pitch)<36 || large_dissonance_bad)) {\n System.out.println(\"caught accented dissonance between cand pitch \" + cand_pitch + \" and cf_pitch \" + cf_pitch);\n myPC.decrementRank(Decrements.accented_dissonance);\n myPC.set_accent_diss();\n }\n }\n\n }\n \n\t //check for pitch candidate dissonance against previous cantus firmus\n for (Integer consonance : consonances) {\n if (abs(cand_pitch - previous_cf_pitch)%12 == consonance) {\n\t\t cand_prev_cf_diss = false; \n }\n }\n for (Integer consonance : consonances) {\n if (abs(previous_cf_pitch - cand_pitch)%12 == consonance) {\n inv_cand_prev_cf_diss = false; \n }\n } \n if (cand_prev_cf_diss ||inv_cand_prev_cf_diss) {\n\t\tmyPC.decrementRank(Decrements.diss_cp_previous_cf);\n }\n\t\t\t\n //compute whether previous_interval consonant\n for (Integer consonance : consonances) {\n if (previous_interval == consonance) previous_interval_consonant = true;\n\t\tbreak;\n }\n for (Integer consonance : consonances) {\n if (previous_inv_interval == consonance) previous_inv_interval_consonant = true;\n\t\tbreak;\n }\n\t\t\t\n\t //check for same type of consonance\n if (previous_interval_consonant && (previous_interval == this_interval) ){\n\t\tmyPC.decrementRank(Decrements.seq_same_type_cons);\n }\n if (previous_inv_interval_consonant && (previous_inv_interval == this_inv_interval) ){\n\t\tmyPC.decrementRank(Decrements.seq_same_type_cons);\n } \n\t\t\t\n\t //check for sequence of dissonances\n if(!previous_interval_consonant && !this_interval_consonant) {\n\t\tmyPC.decrementRank(Decrements.seq_of_diss);\n\t\tif(this_interval == previous_interval ){\n myPC.decrementRank(Decrements.seq_same_type_diss);\n\t\t}\n }\n if(!previous_inv_interval_consonant && !this_inv_interval_consonant) {\n\t\tmyPC.decrementRank(Decrements.seq_of_diss);\n\t\tif(this_inv_interval == previous_inv_interval ){\n myPC.decrementRank(Decrements.seq_same_type_diss);\n\t\t}\n } \n\t\n //check for too long a sequence of same interval\n if (previous_interval == this_interval) {\n same_consonant_count++;\n if (same_consonant_count > same_consonant_threshold) {\n myPC.decrementRank(Decrements.seq_of_same_cons);\n } \n }\n\t else {\n\t\tsame_consonant_count =0;\n\t }\n if (previous_inv_interval == this_inv_interval) {\n same_inv_consonant_count++;\n if (same_inv_consonant_count > same_consonant_threshold) {\n myPC.decrementRank(Decrements.seq_of_same_cons);\n } \n }\n\t else {\n\t\tsame_inv_consonant_count =0;\n\t }\n\n\t\t\t\n\t //if CF starts before CP \n if (cp_start_time > cf_start_time){\n\t //the following checks rely on knowing motion to pitch candidate from previous pitch\n\t //check for a bad approach to a dissonance from a consonance\n\t //ie CP pitch approached by greater than a step\n if (previous_interval_consonant){\n if ((!this_interval_consonant || !this_inv_interval_consonant) && abs(melody_motion_to_cand) >2) {\n myPC.decrementRank(Decrements.bad_diss_approach_from_cons);\n } \n }\n //check for a bad approach to consonance from dissonance\n else if (this_interval_consonant || this_inv_interval_consonant){\n if (abs(melody_motion_to_cand) >2){\n myPC.decrementRank(Decrements.bad_cons_approach_from_diss);\n } \n }\n //check for bad approach to dissonance from dissonance\n else { //implies both this interval and previous are dissonant\n if (abs(melody_motion_to_cand) > 4){\n myPC.decrementRank(Decrements.bad_diss_approach_from_diss);\n } \n }\n }\n // If CP starts before CF\n else if (cp_start_time < cf_start_time) {\n\t\t// the following checks rely on knowing motion to CF pitch from previous CF pitch\n\t\t//check for bad motion into consonance from dissonance\n if (!previous_interval_consonant) {//ie Previous_Interval is dissonant\n if (this_interval_consonant || this_inv_interval_consonant) {\n if (abs(melodic_motion_to_) > 2) {\n myPC.decrementRank(Decrements.bad_cons_approach_from_diss);\n\t\t\t}\n }\n\t\t //check for bad motion into dissonance from dissonance\n else {\n if (abs(melodic_motion_to_) > 4){\n\t\t\t myPC.decrementRank(Decrements.bad_diss_approach_from_diss); \n }\n } \n }\n }\n\t // If CP and CF start at the same time\n else {\n //Check for parallel perfect consonances\n\t\tif((melody_motion_to_cand > 0 && melodic_motion_to_ >0) || (melody_motion_to_cand < 0 && melodic_motion_to_ <0) )\n\t\t directm = true;\n if (this_interval_consonant) {\n if (previous_interval_consonant)\t{\n if (this_interval == previous_interval ){\n myPC.decrementRank(Decrements.seq_same_type_cons);\n if (directm) {\n myPC.decrementRank(Decrements.parallel_perf_consonance);\n } \n }\n else {\n //check for direct motion into a perfect consonance\n if (directm ) {\n myPC.decrementRank(Decrements.direct_motion_perf_cons);\n }\n }\n }\n }\n if (this_inv_interval_consonant) {\n if (previous_inv_interval_consonant)\t{\n if (this_inv_interval == previous_inv_interval ){\n myPC.decrementRank(Decrements.seq_same_type_cons);\n if (directm) {\n myPC.decrementRank(Decrements.parallel_perf_consonance);\n } \n }\n else {\n //check for direct motion into a perfect consonance\n if (directm ) {\n myPC.decrementRank(Decrements.direct_motion_perf_cons);\n }\n }\n }\n } \n\t\t//check for motion into a dissonance\n else { //this interval is dissonant\n myPC.decrementRank(Decrements.motion_into_diss_both_voices_change);\n\t\t if (directm ) {\n\t\t\tmyPC.decrementRank(Decrements.direct_motion_into_diss);\n }\n }\n\n }\n } \n\treturn pitch_candidates;\n }", "public final Hinge2Joint newHinge2Joint( Body body1, Body body2 )\n {\n Hinge2Joint joint = newHinge2JointImpl( body1, body2 );\n \n //addJoint( joint );\n \n return ( joint );\n }", "public final void rule__AstInputPattern__Group_5__0__Impl() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../org.caltoopia.frontend.ui/src-gen/org/caltoopia/frontend/ui/contentassist/antlr/internal/InternalCal.g:14572:1: ( ( 'repeat' ) )\n // ../org.caltoopia.frontend.ui/src-gen/org/caltoopia/frontend/ui/contentassist/antlr/internal/InternalCal.g:14573:1: ( 'repeat' )\n {\n // ../org.caltoopia.frontend.ui/src-gen/org/caltoopia/frontend/ui/contentassist/antlr/internal/InternalCal.g:14573:1: ( 'repeat' )\n // ../org.caltoopia.frontend.ui/src-gen/org/caltoopia/frontend/ui/contentassist/antlr/internal/InternalCal.g:14574:1: 'repeat'\n {\n before(grammarAccess.getAstInputPatternAccess().getRepeatKeyword_5_0()); \n match(input,83,FOLLOW_83_in_rule__AstInputPattern__Group_5__0__Impl29456); \n after(grammarAccess.getAstInputPatternAccess().getRepeatKeyword_5_0()); \n\n }\n\n\n }\n\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "public void setNumberOfHam(int ham) {\n this.ham = ham;\n }", "public final HingeJoint newHingeJoint( Body body1, Body body2 )\n {\n HingeJoint joint = newHingeJointImpl( body1, body2 );\n \n //addJoint( joint );\n \n return ( joint );\n }", "public static void main(String[] args) {\n\t\tSingletonPattern singleton1 = SingletonPattern.getInstance();\n\t\tSystem.out.println(singleton1);\n\t\tSingletonPattern singleton2 = SingletonPattern.getInstance();\n\t\tSystem.out.println(singleton2);\n\t\tSingletonPattern singleton3 = SingletonPattern.getInstance();\n\t\tSystem.out.println(singleton3);\n\t\t\n\t\t//Builder Pattern\n\t\tBuilderPattern.Builder builder = new Builder();\n\t\t\n\t\tBuilderPattern builderPattern = builder.company(\"Company\").designation(\"Designation\").salary(10).name(\"Name\").build();\n\t\t\n\t\tSystem.out.println(builderPattern.toString());\n\t\t\n\t}", "public static void main(String[] args) {\n System.out.println(\"1.)\");\n int i,j;\n int n=6;\n for(i =1;i<=n;i++){\n\n for(j=1;j<=n-i;j++){\n System.out.print(\" \");\n }\n for(j=1;j<=i;j++){\n System.out.print(\"* \");\n }\n System.out.println();\n }\n\n // pattern 2\n int num=1;\n System.out.println(\"2.)\");\n for(i =1;i<=n;i++){\n\n for(j=1;j<=n-i;j++){\n System.out.print(\" \");\n }\n for(j=1;j<=i;j++){\n System.out.print(num+\" \");\n num=num+2;\n }\n System.out.println();\n }\n //pattern3\n System.out.println(\"3.)\");\n int rows = 2*n-1;\n for(i=1;i<=rows;i++){\n\n if(i<=n) {\n for (j = 1; j <= i; j++) {\n System.out.print(\"* \");\n }\n }\n else{\n for (j=1;j<=rows-i+1;j++)\n {\n System.out.print(\"* \");\n }\n }\n System.out.println();\n\n }\n\n //pattern4\n System.out.println(\"4.)\");\n System.out.println(\"*\");\n\n for(i=2;i<=n-1;i++){\n System.out.print(\"* \");\n for(j=1;j<=i-2;j++){\n System.out.print(\" \");\n }\n System.out.print(\" *\");\n System.out.println();\n\n }\n for(i=1;i<=n;i++){\n System.out.print(\"* \");\n }\n }", "void crear(Tonelaje tonelaje);", "public Pattern( PatternAnalyser patternAnalyser ) {\n this.patternAnalyser = patternAnalyser;\n }", "@Test\n public void advancedRepeatTest(){\n \n testMaterialConstructor();\n ArrayList<String> voiceNames = new ArrayList<String>();\n voiceNames.add(\"Aziz\");\n \n ArrayList<BarLineObject> objs = new ArrayList<BarLineObject>();\n objs.add(C);\n objs.add(E);\n objs.add(C);\n objs.add(G);\n objs.add(plainBar);\n objs.add(C);\n objs.add(E);\n objs.add(C);\n objs.add(G);\n objs.add(endBar);\n objs.add(G);\n objs.add(G);\n objs.add(G);\n objs.add(C);\n objs.add(r1Bar);\n objs.add(C);\n objs.add(G);\n objs.add(G);\n objs.add(G);\n objs.add(r2Bar);\n objs.add(C);\n objs.add(E);\n objs.add(E);\n objs.add(E);\n objs.add(repeatBar);\n \n objs.add(C);\n objs.add(E);\n objs.add(C);\n objs.add(G);\n objs.add(repeatStart);\n objs.add(G);\n objs.add(C);\n objs.add(C);\n objs.add(G);\n objs.add(repeatBar);\n \n \n \n Parser2 myParser2 = new Parser2(voiceNames,1,1);\n myParser2.parse(objs);\n ArrayList<Voice> voices = myParser2.getVoices();\n\n Song lalala = new Song(voices);\n \n SequencePlayer sqPlayer;\n try {\n sqPlayer = new SequencePlayer(140, lalala.getMinTicksPerQuarter());\n myPlayer MrAhmed = new myPlayer(\"C\", sqPlayer);\n lalala.addToPlayer(MrAhmed);\n sqPlayer.play();\n \n } catch (MidiUnavailableException e) {\n e.printStackTrace();\n } catch (InvalidMidiDataException e) {\n e.printStackTrace();\n }\n \n }", "public final void rule__Chord__Group__0() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2845:1: ( rule__Chord__Group__0__Impl rule__Chord__Group__1 )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2846:2: rule__Chord__Group__0__Impl rule__Chord__Group__1\n {\n pushFollow(FOLLOW_rule__Chord__Group__0__Impl_in_rule__Chord__Group__05773);\n rule__Chord__Group__0__Impl();\n\n state._fsp--;\n\n pushFollow(FOLLOW_rule__Chord__Group__1_in_rule__Chord__Group__05776);\n rule__Chord__Group__1();\n\n state._fsp--;\n\n\n }\n\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "public static void pattern6(int input){\n\t\tint counter=1;\n\t\tfor(int i=1;i<=input;i++){\n\t\t\tfor(int j=counter;j<=(i*(i+1)/2);j++){\n\t\t\t\tSystem.out.print(counter++ + \" \");\n\t\t\t}\n\t\t\tSystem.out.println();\n\t\t}\n\t}", "private int calculateDistance(int w, int w2, AnalysisFragment fragment, String[] patterns) {\r\n\r\n List<Word> words = fragment.getWords();\r\n\r\n int distance = 0;\r\n\r\n //Statement to make pattern sequence irrelevant;\r\n if(w2<w){\r\n int temp=w;\r\n w=w2;\r\n w2=temp;\r\n }\r\n\r\n for(int i = w+1; i < w2; i++){\r\n\r\n Word word = words.get(i);\r\n\r\n //System.out.println(word.display());\r\n if(!isOneOf(word, fragment, patterns))\r\n distance += (word.isMinor() ? 1 : 10);\r\n }\r\n\r\n return distance;\r\n }", "MidiView getMidi();", "public void playPiece() {\n \t\n System.out.println(\"Title: \" + this.title);\n System.out.println(\"Composer: \" + this.composer);\n System.out.println(\"Played in \" + this.meterNumerator + \"/\" + this.meterDenominator + \" time @ \" + this.tempoSpeed + \" BPM.\");\n SequencePlayer player;\n try {\n \t\n \t// Create an instance of LyricListener and add a processLyricEvent to print out lyrics\n LyricListener listener = new LyricListener() {\n public void processLyricEvent(String text) {\n System.out.println(text);\n }\n };\n \n // Iterates through each MusicalPhrase and queues the notes to be played by the SequencePlayer\n player = new SequencePlayer(this.getTempo(), this.getTicksPerBeat(), listener);\n for (MusicalPhrase phrase : this.phrases) {\n int tickCount = 0;\n for (Bar bar : phrase.getBars()) {\n for (Note note : bar.getNotes()) {\n int ticksPerNote = this.getTicksPerBeat() * this.tempoDenominator * note.getNumerator() / this.tempoNumerator / note.getDenominator();\n if (note instanceof PitchNote) {\n for(int i=0; i<note.getNote().length; i++) { \n // getTicksPerBeat gives you the default amount for a note = tempoNum/tempoDen\n // We want ticks for a note that is noteNum / noteDen\n \tplayer.addNote(note.getNote()[i], tickCount, ticksPerNote);\n }\n if (!(note.getLyric().equals(\"\"))) {\n player.addLyricEvent(note.getLyric(), tickCount);\n }\n }\n tickCount += ticksPerNote;\n }\n }\n }\n player.play();\n }\n catch (Exception e) {\n e.printStackTrace();\n } \n }", "public final void rule__MidiBody__Group__1() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:1165:1: ( rule__MidiBody__Group__1__Impl rule__MidiBody__Group__2 )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:1166:2: rule__MidiBody__Group__1__Impl rule__MidiBody__Group__2\n {\n pushFollow(FOLLOW_rule__MidiBody__Group__1__Impl_in_rule__MidiBody__Group__12477);\n rule__MidiBody__Group__1__Impl();\n\n state._fsp--;\n\n pushFollow(FOLLOW_rule__MidiBody__Group__2_in_rule__MidiBody__Group__12480);\n rule__MidiBody__Group__2();\n\n state._fsp--;\n\n\n }\n\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "private List<Conference> allocateTrackTwoAm(List<Conference> listTemp) {\r\n\t\tint sum2 = 0;\r\n\t\tList<Conference> listTemp2 = new LinkedList<Conference>();\r\n\t\tlistTemp2.addAll(listTemp);\r\n\t\twhile (sum2 != AM_MINUTES) {\r\n\t\t\tInteger index = random.nextInt(listTemp2.size());\r\n\t\t\tConference ele = listTemp2.get(index);\r\n\t\t\tlistTemp2.remove((int)index);\r\n\t\t\tsuper.trackTwoAm.add(ele);\r\n\t\t\tif ((sum2 += ele.getTimeDuration()) > AM_MINUTES) {\r\n\t\t\t\tsum2 = 0;\r\n\t\t\t\tsuper.trackTwoAm.clear();\r\n\t\t\t\tlistTemp2.clear();\r\n\t\t\t\tlistTemp2.addAll(listTemp);\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn listTemp2;\r\n\t}", "public static IsotopePattern calculate_pattern(String formula, double C12, double N14, double H1, int charge) {\n\t\t\n\t\tC_num = retrieve_num_element(formula, \"C\");\n\t\tH_num = retrieve_num_element(formula, \"H\");\n\t\tN_num = retrieve_num_element(formula, \"N\");\n\t\tO_num = retrieve_num_element(formula, \"O\");\n\t\tS_num = retrieve_num_element(formula, \"S\");\n\t\tP_num = retrieve_num_element(formula, \"P\");\n\t\t\n\t\t\n\t\tLinkedList ini_list = create_ini_list(C12, N14, H1);\n\t\t\n\t\tLinkedList listC = preload_ini_file(ini_list, \"C\");\n\t\tLinkedList listH = preload_ini_file(ini_list, \"H\");\n\t\tLinkedList listN = preload_ini_file(ini_list, \"N\");\n\t\tLinkedList listS = preload_ini_file(ini_list, \"S\");\n\t\tLinkedList listO = preload_ini_file(ini_list, \"O\");\n\t\tLinkedList listP = preload_ini_file(ini_list, \"P\");\n\t\t// possibly the following line might be causing trouble\n\t\t\n\t\tboolean tolerance_type = true;\n\t\tdouble ppm_val = _ppm;\n\t\t\n\t\tlistC = merge_mass_tolerance(listC, tolerance_type, ppm_val);\n\t\tlistH = merge_mass_tolerance(listH, tolerance_type, ppm_val);\n\t\tlistN = merge_mass_tolerance(listN, tolerance_type, ppm_val);\n\t\tlistS = merge_mass_tolerance(listS, tolerance_type, ppm_val);\n\t\tlistO = merge_mass_tolerance(listO, tolerance_type, ppm_val);\n\t\tlistP = merge_mass_tolerance(listP, tolerance_type, ppm_val);\n\t\t\n\t\tboolean ppm = true;\n\t\t\n\t\t\n\t\t\n\t\t//System.out.println(C_num + \"\\t\" + H_num + \"\\t\" + N_num + \"\\t\" + O_num + \"\\t\" + S_num + \"\\t\" + P_num);\n\t\t//write_example(list, path, 1);\n\t\t\n\t\t\n\t\tLinkedList newList = new LinkedList();\n\t\tfor (int i = 0; i < C_num; i++) {\n\t\t\tif (newList.size() == 0) {\n\t\t\t\tnewList = listC;\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\tnewList = MergeList(newList, listC);\t\t\t\t\t\n\t\t\t\tnewList = merge_mass_tolerance(newList, ppm, ppm_val);\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < H_num; i++) {\n\t\t\tif (newList.size() == 0) {\n\t\t\t\tnewList = listH;\n\t\t\t} else {\n\t\t\t\t//LinkedList list = new LinkedList();\n\t\t\t\t//list = MergeList(list, listH);\n\t\t\t\t//print_list(list);\n\t\t\t\tnewList = MergeList(newList, listH);\n\t\t\t\tnewList = merge_mass_tolerance(newList, ppm, ppm_val);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < N_num; i++) {\n\t\t\tif (newList.size() == 0) {\n\t\t\t\tnewList = listN;\n\t\t\t} else {\n\t\t\t\tnewList = MergeList(newList, listN);\n\t\t\t\tnewList = merge_mass_tolerance(newList, ppm, ppm_val);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < S_num; i++) {\n\t\t\tif (newList.size() == 0) {\n\t\t\t\tnewList = listS;\n\t\t\t} else {\n\t\t\t\tnewList = MergeList(newList, listS);\n\t\t\t\tnewList = merge_mass_tolerance(newList, ppm, ppm_val);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < O_num; i++) {\n\t\t\tif (newList.size() == 0) {\n\t\t\t\tnewList = listO;\n\t\t\t} else {\n\t\t\t\tnewList = MergeList(newList, listO);\n\t\t\t\tnewList = merge_mass_tolerance(newList, ppm, ppm_val);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < P_num; i++) {\n\t\t\tif (newList.size() == 0) {\n\t\t\t\tnewList = listP;\n\t\t\t} else {\n\t\t\t\tnewList = MergeList(newList, listP);\n\t\t\t\tnewList = merge_mass_tolerance(newList, ppm, ppm_val);\n\t\t\t}\n\t\t}\n\t\t\n\t\t//print_list(newList);\n\t\tIsotopePattern query_pattern = convert_Compounds2IsotopePattern(newList, -1, charge);\n\t\treturn query_pattern;\n\t}", "public List<PatternItem> pattern() {\n List<PatternItem> out = new ArrayList<>();\n int level = 0;\n int n = 0;\n String c;\n\n boolean done = false;\n while (!done) {\n DNAToken token = parser.step();\n\n switch (token) {\n case CONT:\n break;\n case C:\n out.add(new PatternItem(PatternItem.Type.BASE, 'I'));\n break;\n case F:\n out.add(new PatternItem(PatternItem.Type.BASE, 'C'));\n break;\n case P:\n out.add(new PatternItem(PatternItem.Type.BASE, 'F'));\n break;\n case IC:\n out.add(new PatternItem(PatternItem.Type.BASE, 'P'));\n break;\n case IP:\n n = parser.nat();\n out.add(new PatternItem(PatternItem.Type.JUMP, n));\n break;\n case IF:\n parser.next(); // Consume one more character for no good reason\n c = parser.consts();\n out.add(new PatternItem(PatternItem.Type.SEARCH, c));\n break;\n case IIP:\n level += 1;\n out.add(new PatternItem(PatternItem.Type.OPEN));\n break;\n case IIF:\n case IIC:\n if (level == 0) {\n done = true;\n } else {\n level -= 1;\n out.add(new PatternItem(PatternItem.Type.CLOSE));\n }\n break;\n case III:\n rna.concat(dna.substring(0, 7));\n dna.trunc(7);\n break;\n default:\n finish();\n }\n }\n\n return out;\n }", "public static Ani[] from(Object theTarget, float theDuration, float theDelay, String thePropertyList){\n\t\treturn addAnis(true, theTarget, theDuration, theDelay, thePropertyList, defaultEasing, defaultTimeMode, theTarget, defaultCallback);\n\t}", "private int spellPatterns(PatternNode patternNode, Gene[] pattern, int pattern_length) {\n\n List<Instance> instances = patternNode.getInstances();\n\n Map<Integer, PatternNode> targetNodes = patternNode.getTargetNodes();\n\n //the maximal number of different instances, of one of the extended patterns\n int maxNumOfDiffInstances = -1;\n int numOfDiffInstance = 0;\n\n PatternNode target_node;\n for (Map.Entry<Integer, PatternNode> entry : targetNodes.entrySet()) {\n int alpha = entry.getKey();\n //Gene alpha_ch = gi.getLetter(alpha);\n target_node = entry.getValue();\n\n numOfDiffInstance = extendPattern(alpha, -1, null, null,\n pattern, target_node, patternNode, instances, pattern_length);\n\n if (numOfDiffInstance > maxNumOfDiffInstances) {\n maxNumOfDiffInstances = numOfDiffInstance;\n }\n //For memory saving, remove pointer to target node\n patternNode.addTargetNode(alpha, null);\n\n }\n\n countNodesInPatternTree++;\n\n return maxNumOfDiffInstances;\n }", "public static void pattern12(int input){\n\t\tfor(int i= 1;i <= input;i++){\n\t\t\tfor(int j=i;j>1;j--){\n\t\t\t\tSystem.out.print(j+\" \");\n\t\t\t}\n\t\t\tfor(int k=1;k<=i;k++){\n\t\t\t\tSystem.out.print(k+\" \");\n\t\t\t}\n\t\t\tSystem.out.println();\n\t\t}\n\t}", "@Override\n public void mutate(Song song, int noteIndex) {\n if (Math.random() < this.getProbability()) {\n if (noteIndex > 0) {\n MidiUtil mu = new MidiUtil();\n int nbrOfTotalReversing = nbrOfAdditionalReversing + 1\n + ((int) Math.random() * nbrRange);\n ArrayList<Integer> noteIndexes = new ArrayList<Integer>();\n ArrayList<Note> notes = new ArrayList<Note>();\n noteIndexes.add(noteIndex);\n notes.add(song.getScore().getPart(0).getPhrase(0)\n .getNote(noteIndex));\n int currentIndex = noteIndex - 1;\n noteIteration: for (int i = 1; i < nbrOfTotalReversing; i++) {\n while (mu.isBlank(currentIndex) && currentIndex >= 0) {\n currentIndex--;\n }\n if (currentIndex < 0) {\n break noteIteration;\n } else {\n noteIndexes.add(currentIndex);\n notes.add(song.getScore().getPart(0).getPhrase(0)\n .getNote(currentIndex));\n }\n }\n int totalReverses = noteIndexes.size();\n for (int j = 0; j < noteIndexes.size(); j++) {\n if (withRhythmLength) {\n song.getScore()\n .getPart(0)\n .getPhrase(0)\n .setNote(notes.get(totalReverses - 1 - j),\n noteIndexes.get(j));\n } else {\n int newPitch = notes.get(totalReverses - 1 - j)\n .getPitch();\n song.getScore().getPart(0).getPhrase(0)\n .getNote(noteIndexes.get(j)).setPitch(newPitch);\n }\n }\n }\n }\n }", "public Rumbler(double timeOn, double timeOff, int repeatCount, JoystickSelection controllerToRumble) {\n this(timeOn, timeOff, repeatCount, controllerToRumble, 1);\n }", "private void startGame() { \n \n int body = 0;\n int column = 0;\n int end = 0;\n int fill = 0;\n int increment = 2; \n int numPerSide = 0; \n int prefixIndex = 0;\n int row = 0; \n int start = 1; \n int userNum = 0; \n \n String lineContent = \"\";\n \n // Get user input\n System.out.println(\"FOR A PRETTY DIAMOND PATTERN,\");\n System.out.print(\"TYPE IN AN ODD NUMBER BETWEEN 5 AND 21? \");\n userNum = scan.nextInt();\n System.out.println(\"\");\n \n // Calcuate number of diamonds to be drawn on each side of screen\n numPerSide = (int) (LINE_WIDTH / userNum); \n\n end = userNum; \n \n // Begin loop through each row of diamonds\n for (row = 1; row <= numPerSide; row++) {\n \n // Begin loop through top and bottom halves of each diamond\n for (body = start; increment < 0 ? body >= end : body <= end; body += increment) {\n\n lineContent = \"\";\n \n // Add whitespace\n while (lineContent.length() < ((userNum - body) / 2)) {\n lineContent += \" \";\n }\n \n // Begin loop through each column of diamonds\n for (column = 1; column <= numPerSide; column++) {\n \n prefixIndex = 1;\n \n // Begin loop that fills each diamond with characters\n for (fill = 1; fill <= body; fill++) {\n \n // Right side of diamond\n if (prefixIndex > PREFIX.length()) {\n \n lineContent += SYMBOL; \n \n }\n // Left side of diamond\n else {\n \n lineContent += PREFIX.charAt(prefixIndex - 1);\n prefixIndex++;\n \n } \n \n } // End loop that fills each diamond with characters\n \n // Column finished\n if (column == numPerSide) {\n \n break;\n \n }\n // Column not finishd\n else {\n \n // Add whitespace\n while (lineContent.length() < (userNum * column + (userNum - body) / 2)) {\n lineContent += \" \";\n }\n \n } \n \n } // End loop through each column of diamonds\n \n System.out.println(lineContent);\n\n } // End loop through top and bottom half of each diamond\n\n if (start != 1) {\n\n start = 1;\n end = userNum;\n increment = 2; \n \n }\n else {\n \n start = userNum - 2;\n end = 1;\n increment = -2; \n row--;\n\n } \n\n } // End loop through each row of diamonds\n \n }", "void onNewPulse(int pulse, int spo2 );", "public NoteDuration getNoteDuration(int duration)\n\t{\n\t\tint whole = quarternote * 4;\n\t\t//\t\t 1 = 32/32\n\t\t//\t\t 3/4 = 24/32\n\t\t//\t\t 1/2 = 16/32\n\t\t//\t\t 3/8 = 12/32\n\t\t//\t\t 1/4 = 8/32\n\t\t//\t\t 3/16 = 6/32\n\t\t//\t\t 1/8 = 4/32 = 8/64\n\t\t//\t\t triplet = 5.33/64\n\t\t//\t\t 1/16 = 2/32 = 4/64\n\t\t//\t\t 1/32 = 1/32 = 2/64\n\n\t\tif (duration >= 28 * whole / 32)\n\t\t return NoteDuration.Whole;\n\t\telse if (duration >= 20 * whole / 32)\n\t\t return NoteDuration.DottedHalf;\n\t\telse if (duration >= 14 * whole / 32)\n\t\t return NoteDuration.Half;\n\t\telse if (duration >= 10 * whole / 32)\n\t\t return NoteDuration.DottedQuarter;\n\t\telse if (duration >= 7 * whole / 32)\n\t\t return NoteDuration.Quarter;\n\t\telse if (duration >= 5 * whole / 32)\n\t\t return NoteDuration.DottedEighth;\n\t\telse if (duration >= 6 * whole / 64)\n\t\t return NoteDuration.Eighth;\n\t\telse if (duration >= 5 * whole / 64)\n\t\t return NoteDuration.Triplet;\n\t\telse if (duration >= 3 * whole / 64)\n\t\t return NoteDuration.Sixteenth;\n\t\telse if (duration >= 2 * whole / 64)\n\t\t return NoteDuration.ThirtySecond;\n\t\telse if (duration >= whole / 64)\n\t\t return NoteDuration.SixtyFour; // TODO : EXTEND UNTIL 1/128 to be able to extract the onset in SYMBOLIC representation\n\t\telse if (duration >= whole / 128)\n\t\t return NoteDuration.HundredTwentyEight;\n\t\telse\n\t\t return NoteDuration.ZERO;\n\t}", "@Override\n\tpublic void setDuration(Duration duration) {\n\t\tfor (NoteBuilder builder : this) {\n\t\t\tbuilder.setDuration(duration);\n\t\t}\n\t\tthis.duration = duration;\n\t}", "private int[] genererCodeHamming(int[] tabCode) {\n\t\t\n\t\t\t\tint hamming[];\n\t\t\t\t\n\t\t\t\tint i=0;\n\t\t\t\tint nbParite=0; \n\t\t\t\tint j=0;\n\t\t\t\tint k=0;\n\t\t\t\t\n\t\t\t\twhile(i < tabCode.length) {\n\t\t\t\t\t\n\t\t\t\t\tif(Math.pow(2,nbParite) == i+nbParite + 1) {\n\t\t\t\t\t\tnbParite++;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\ti++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\thamming = new int[tabCode.length + nbParite];\n\t\t\t\t\n\t\t\t\tfor(i=1 ; i <= hamming.length ; i++) {\n\t\t\t\t\tif(Math.pow(2, j) == i) {\n\t\t\t\t\t\t\n\t\t\t\t\t\thamming[i-1] = 2;\n\t\t\t\t\t\tj++;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\thamming[k+j] = tabCode[k++];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(i=0 ; i < nbParite ; i++) {\n\t\t\t\t\t\n\t\t\t\t\thamming[((int) Math.pow(2, i))-1] = getParite(hamming, i);\n\t\t\t\t}\n\t\t\t\treturn hamming;\n\t}", "public static Note createNote(int octave, Pitch pitch, int startBeat, int endBeat) {\n return new NoteImpl(octave, pitch, startBeat, endBeat);\n }", "public final void rule__AstOutputPattern__Group_5__0__Impl() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../org.caltoopia.frontend.ui/src-gen/org/caltoopia/frontend/ui/contentassist/antlr/internal/InternalCal.g:14950:1: ( ( 'repeat' ) )\n // ../org.caltoopia.frontend.ui/src-gen/org/caltoopia/frontend/ui/contentassist/antlr/internal/InternalCal.g:14951:1: ( 'repeat' )\n {\n // ../org.caltoopia.frontend.ui/src-gen/org/caltoopia/frontend/ui/contentassist/antlr/internal/InternalCal.g:14951:1: ( 'repeat' )\n // ../org.caltoopia.frontend.ui/src-gen/org/caltoopia/frontend/ui/contentassist/antlr/internal/InternalCal.g:14952:1: 'repeat'\n {\n before(grammarAccess.getAstOutputPatternAccess().getRepeatKeyword_5_0()); \n match(input,83,FOLLOW_83_in_rule__AstOutputPattern__Group_5__0__Impl30201); \n after(grammarAccess.getAstOutputPatternAccess().getRepeatKeyword_5_0()); \n\n }\n\n\n }\n\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "private static void drawNumDiamondRec(int h) {\n double hd = h;\r\n boolean odd = hd % 2 == 1;\r\n int middle = (int) Math.ceil(hd / 2);\r\n\r\n actual_recursion(h, middle, odd, 1, 0);\r\n\r\n }", "public final void rule__AstInputPattern__Group_5__1__Impl() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../org.caltoopia.frontend.ui/src-gen/org/caltoopia/frontend/ui/contentassist/antlr/internal/InternalCal.g:14602:1: ( ( ( rule__AstInputPattern__RepeatAssignment_5_1 ) ) )\n // ../org.caltoopia.frontend.ui/src-gen/org/caltoopia/frontend/ui/contentassist/antlr/internal/InternalCal.g:14603:1: ( ( rule__AstInputPattern__RepeatAssignment_5_1 ) )\n {\n // ../org.caltoopia.frontend.ui/src-gen/org/caltoopia/frontend/ui/contentassist/antlr/internal/InternalCal.g:14603:1: ( ( rule__AstInputPattern__RepeatAssignment_5_1 ) )\n // ../org.caltoopia.frontend.ui/src-gen/org/caltoopia/frontend/ui/contentassist/antlr/internal/InternalCal.g:14604:1: ( rule__AstInputPattern__RepeatAssignment_5_1 )\n {\n before(grammarAccess.getAstInputPatternAccess().getRepeatAssignment_5_1()); \n // ../org.caltoopia.frontend.ui/src-gen/org/caltoopia/frontend/ui/contentassist/antlr/internal/InternalCal.g:14605:1: ( rule__AstInputPattern__RepeatAssignment_5_1 )\n // ../org.caltoopia.frontend.ui/src-gen/org/caltoopia/frontend/ui/contentassist/antlr/internal/InternalCal.g:14605:2: rule__AstInputPattern__RepeatAssignment_5_1\n {\n pushFollow(FOLLOW_rule__AstInputPattern__RepeatAssignment_5_1_in_rule__AstInputPattern__Group_5__1__Impl29514);\n rule__AstInputPattern__RepeatAssignment_5_1();\n\n state._fsp--;\n\n\n }\n\n after(grammarAccess.getAstInputPatternAccess().getRepeatAssignment_5_1()); \n\n }\n\n\n }\n\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "public final void rule__Chord__Group__2__Impl() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2919:1: ( ( ruleChordParams ) )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2920:1: ( ruleChordParams )\n {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2920:1: ( ruleChordParams )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2921:1: ruleChordParams\n {\n before(grammarAccess.getChordAccess().getChordParamsParserRuleCall_2()); \n pushFollow(FOLLOW_ruleChordParams_in_rule__Chord__Group__2__Impl5927);\n ruleChordParams();\n\n state._fsp--;\n\n after(grammarAccess.getChordAccess().getChordParamsParserRuleCall_2()); \n\n }\n\n\n }\n\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "public static long[] vibPatternMaker(int[] vibs) {\r\n VibrationPattern vibPat = new VibrationPattern();\r\n long[] vibPattern;\r\n\r\n ArrayList<Long> minuteTensVib = vibPat.minuteTensVib;\r\n ArrayList<Long> longVib = vibPat.longVib;\r\n ArrayList<Long> minuteOnesVib = vibPat.minuteOnesVib;\r\n ArrayList<Long> signalVib = vibPat.signalVib;\r\n ArrayList<Long> hourVib = vibPat.hourVib;\r\n\r\n ArrayList<Long> vibPatList = new ArrayList<Long>();\r\n\r\n if (vibs[0] != 0) {\r\n // Hours\r\n for (int i = 0; i < vibs[0]; i++) {\r\n vibPatList.addAll(hourVib);\r\n }\r\n // Delay in between hours and minutes\r\n vibPatList.addAll(signalVib);\r\n Log.i(\"VIB\", vibs[0] + \" long vibration(s) (hours)\");\r\n } else { //case of 12 o'clock\r\n for (int i = 0; i < 12; i++) {\r\n vibPatList.addAll(hourVib);\r\n }\r\n vibPatList.addAll(signalVib);\r\n //Log.i(\"VIB\", \" long vibration(s) (hours)\");\r\n }\r\n\r\n if (vibs[1] != 0) {\r\n // Minutes (Tens)\r\n for (int i = 0; i < vibs[1]; i++) {\r\n vibPatList.addAll(minuteTensVib);\r\n }\r\n vibPatList.addAll(signalVib);\r\n Log.i(\"VIB\", vibs[1] + \" long vibration(s) (10s of minutes)\");\r\n }\r\n\r\n if (vibs[2] != 0) {\r\n // Minutes (Ones)\r\n for (int i = 0; i < vibs[2]; i++) {\r\n vibPatList.addAll(minuteOnesVib);\r\n }\r\n Log.i(\"VIB\", vibs[2] + \" short vibration(s) (minutes)\");\r\n }\r\n\r\n// Log.i(ON_TAP, vibPatList.toString());\r\n\r\n vibPattern = new long[vibPatList.size()];\r\n Long[] tempHold = vibPatList.toArray(new Long[vibPatList.size()]);\r\n for (int i = 0; i < tempHold.length; i++) {\r\n vibPattern[i] = tempHold[i].longValue();\r\n }\r\n\r\n return vibPattern;\r\n }" ]
[ "0.63586164", "0.614812", "0.46633086", "0.46624622", "0.447376", "0.4435798", "0.4431392", "0.44209257", "0.4368388", "0.4356324", "0.43549204", "0.43491843", "0.43469274", "0.43086657", "0.42793536", "0.42683747", "0.4265836", "0.4256827", "0.42388028", "0.42350134", "0.4198978", "0.4185675", "0.41824472", "0.4179968", "0.4179509", "0.41671962", "0.41563332", "0.41552252", "0.41482195", "0.41381264", "0.41309205", "0.412982", "0.4114435", "0.41088614", "0.41029373", "0.40957588", "0.40343696", "0.40305874", "0.40268853", "0.40049815", "0.40044978", "0.3999754", "0.39959842", "0.39648628", "0.3962432", "0.3958285", "0.3950842", "0.39401197", "0.39322495", "0.3930722", "0.3925921", "0.3921874", "0.3917582", "0.3908427", "0.39069062", "0.3905977", "0.38982248", "0.38965625", "0.3894583", "0.38899124", "0.38856187", "0.38850406", "0.38803908", "0.3876613", "0.38685608", "0.3865191", "0.38624048", "0.38343987", "0.38323563", "0.38307363", "0.38304454", "0.3830159", "0.3829993", "0.3812042", "0.38105726", "0.3801654", "0.3791693", "0.3784785", "0.3783501", "0.37735558", "0.3769551", "0.37648985", "0.3763886", "0.37632948", "0.37536123", "0.37442368", "0.37418157", "0.37410125", "0.37404424", "0.3737991", "0.37265694", "0.37237203", "0.37230223", "0.37216607", "0.37102073", "0.36923575", "0.36911672", "0.36856765", "0.3684042", "0.36838174" ]
0.8299114
0
Returns a Pattern that plays a slide between two notes over the given duration. TODO: This is currently a naive implementation, which sounds 'numSteps' notes, each with a duration of 'duration/numSteps'. This means that if you're sliding from a F to a G, for example, you could get music that looks like F F F F F F F F G G G G G G, with each note having a very short duration. The problem with this is that the sound of each note stopping and starting again is noticeable. A more intelligent implementation would sound each note for as long as necessary, then sound a different note only when the microtonal math requires it. Otherwise, the pitch wheel messages should cause the note to change while it is playing. This implementation may require one or more new methods in MicrotoneNotation.
public static PatternInterface slide(Note note1, Note note2, double duration, int numSteps) { StringBuilder buddy = new StringBuilder(); double durationPerStep = duration / numSteps; double freq1 = Note.getFrequencyForNote(note1.getValue()); double freq2 = Note.getFrequencyForNote(note2.getValue()); double differencePerStep = (freq2-freq1) / numSteps; for (int i=0; i < numSteps; i++) { buddy.append(MicrotoneNotation.convertFrequencyToMusicString(freq1)); buddy.append("/"); buddy.append(durationPerStep); buddy.append(MicrotoneNotation.getResetPitchWheelString()); buddy.append(" "); freq1 += differencePerStep; } PatternInterface pattern = new Pattern(buddy.toString()); return pattern; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static PatternInterface trill(Note note1, Note note2, double duration, int numSteps)\r\n {\r\n return hammerOn(note1, note2, duration, numSteps);\r\n }", "public static PatternInterface hammerOn(Note note1, Note note2, double duration, int numHammers)\r\n {\r\n StringBuilder buddy = new StringBuilder();\r\n double durationPerHammer = duration / numHammers;\r\n buddy.append(\"[\");\r\n buddy.append(note1.getValue());\r\n buddy.append(\"]/\");\r\n buddy.append(durationPerHammer / 2.0);\r\n buddy.append(\" [\");\r\n buddy.append(note2.getValue());\r\n buddy.append(\"]/\");\r\n buddy.append(durationPerHammer / 2.0);\r\n\r\n PatternInterface pattern = new Pattern(buddy.toString());\r\n pattern.repeat(numHammers);\r\n return pattern;\r\n }", "public static PatternInterface trill(Note baseNote, char trillDirection, double singleSoundDuration){\r\n \r\n \tStringBuilder musicStringBuilder = new StringBuilder();\r\n \r\n \tdouble totalDuration = baseNote.getDecimalDuration();\r\n double actualDuration = 0.0d;\r\n \r\n byte secondNote = baseNote.getValue();\r\n \r\n if(trillDirection == EFFECT_DIRECTION_UP){\r\n \tsecondNote++;\r\n } else if(trillDirection == EFFECT_DIRECTION_DOWN){\r\n \tsecondNote--;\r\n }\r\n \r\n double remainingDuration = totalDuration - (2*singleSoundDuration);\r\n if(remainingDuration > 0.0d){\r\n \t\r\n \tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \tactualDuration+=singleSoundDuration;\r\n \t\r\n \twhile(actualDuration < totalDuration){\r\n \t\tif(actualDuration + (2*singleSoundDuration) < totalDuration){\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, secondNote, singleSoundDuration);\r\n \t\t\tactualDuration += singleSoundDuration;\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \t\t\tactualDuration += singleSoundDuration;\r\n \t\t} else if(actualDuration + singleSoundDuration > totalDuration){\r\n \t\t\tdouble gapDuration = totalDuration - actualDuration;\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), gapDuration);\r\n \t\t\tactualDuration+=gapDuration;\r\n \t\t} else {\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \t\t\tactualDuration+=singleSoundDuration;\r\n \t\t}\r\n \t}\r\n \treturn new Pattern(musicStringBuilder.toString().trim());\r\n } else {\r\n \treturn new Pattern(baseNote.getMusicString());\r\n }\r\n }", "public Note(int _pitch, int _duration, int _dynamic) {\n pitch = _pitch;\n duration = _duration;\n dynamic = _dynamic;\n tiedIn = false;\n tiedOut = false;\n displayDynamic = false;\n }", "public NoteDuration getNoteDuration(int duration)\n\t{\n\t\tint whole = quarternote * 4;\n\t\t//\t\t 1 = 32/32\n\t\t//\t\t 3/4 = 24/32\n\t\t//\t\t 1/2 = 16/32\n\t\t//\t\t 3/8 = 12/32\n\t\t//\t\t 1/4 = 8/32\n\t\t//\t\t 3/16 = 6/32\n\t\t//\t\t 1/8 = 4/32 = 8/64\n\t\t//\t\t triplet = 5.33/64\n\t\t//\t\t 1/16 = 2/32 = 4/64\n\t\t//\t\t 1/32 = 1/32 = 2/64\n\n\t\tif (duration >= 28 * whole / 32)\n\t\t return NoteDuration.Whole;\n\t\telse if (duration >= 20 * whole / 32)\n\t\t return NoteDuration.DottedHalf;\n\t\telse if (duration >= 14 * whole / 32)\n\t\t return NoteDuration.Half;\n\t\telse if (duration >= 10 * whole / 32)\n\t\t return NoteDuration.DottedQuarter;\n\t\telse if (duration >= 7 * whole / 32)\n\t\t return NoteDuration.Quarter;\n\t\telse if (duration >= 5 * whole / 32)\n\t\t return NoteDuration.DottedEighth;\n\t\telse if (duration >= 6 * whole / 64)\n\t\t return NoteDuration.Eighth;\n\t\telse if (duration >= 5 * whole / 64)\n\t\t return NoteDuration.Triplet;\n\t\telse if (duration >= 3 * whole / 64)\n\t\t return NoteDuration.Sixteenth;\n\t\telse if (duration >= 2 * whole / 64)\n\t\t return NoteDuration.ThirtySecond;\n\t\telse if (duration >= whole / 64)\n\t\t return NoteDuration.SixtyFour; // TODO : EXTEND UNTIL 1/128 to be able to extract the onset in SYMBOLIC representation\n\t\telse if (duration >= whole / 128)\n\t\t return NoteDuration.HundredTwentyEight;\n\t\telse\n\t\t return NoteDuration.ZERO;\n\t}", "int getRecurrenceDuration();", "public static PatternInterface graceNote(Note graceNote, Note baseNote, double graceNoteDuration){\r\n \tPattern gracePattern = new Pattern(graceNote.getMusicString());\r\n \treturn addOrnament(gracePattern, baseNote, graceNoteDuration);\r\n }", "public Note(int duration, int offset, int pitch, int channel, int velocity) {\n this.duration = duration;\n this.offset = offset;\n this.pitch = pitch;\n this.channel = channel;\n this.velocity = velocity;\n }", "void note(float start, float duration, float freq){\n\t out.playNote(start,duration,freq); \n\t }", "String getDelayPattern();", "public Note noteAt(int interval) {\n\t\tint newMidiNote = getMidiNumber() + interval;\n\t\t\n\t\treturn new Note(newMidiNote);\n\t}", "Posn getDuration();", "@Override\n\tpublic void playSequenceNote(final int note, final double duration,\n\t\t\tfinal int instrument, final int velocity) {\n\t\ttry {\n\t\t\tstopCurrentSound();\n\t\t\tcurrentSoundType = SOUNDTYPE_MIDI;\n\t\t\tgetMidiSound().playSequenceNote(note, duration, instrument);\n\t\t} catch (Exception e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t}", "public Piano(int numNotes){\n pStrings = new InstString[numNotes][3];\n for(int a = 0; a < numNotes; a++){\n double freq = 440 * Math.pow(2, (double)(a-24)/(double)12);\n pStrings[a][0] = new GuitarString(freq);\n pStrings[a][1] = new GuitarString(freq + .45);\n pStrings[a][2] = new GuitarString(freq - .45);\n }\n }", "public void playChord(float[] pitches, double dynamic, double duration) {\n\t\tthis.soundCipher.playChord(pitches, dynamic, duration);\n\t}", "private void playNotes()\n\t{\n\t\t//Update tracks when we can shift chords.\n\t\tChord curChord = ClearComposer.cc.getChord();\n\t\tif (index % ClearComposer.cc.getChordInterval() == 0 && (prevChord == null || prevChord != curChord))\n\t\t{\n\t\t\tprevChord = curChord;\n\t\t\ttracks.forEach(GraphicTrack::updateChord);\n\t\t\tClearComposer.cc.updateChordOutlines();\n\t\t}\n\n\t\tfor (GraphicTrack track : tracks)\n\t\t{\n\t\t\tint temp = track.playNote(index);\n\t\t\tif (temp != -1)\n\t\t\t\tMusicPlayer.playNote(temp);\n\t\t}\n\n\t\tindex++;\n\t\twhile (index >= ClearComposer.cc.getNumNotes())\n\t\t\tindex -= ClearComposer.cc.getNumNotes();\n\t}", "public int durationToTime(NoteDuration dur)\n\t{\n\t\tint eighth = quarternote / 2;\n\t\tint sixteenth = eighth / 2;\n\n\t\tswitch (dur)\n\t\t{\n\t\t\tcase Whole:\n\t\t\t\treturn quarternote * 4;\n\t\t\tcase DottedHalf:\n\t\t\t\treturn quarternote * 3;\n\t\t\tcase Half:\n\t\t\t\treturn quarternote * 2;\n\t\t\tcase DottedQuarter:\n\t\t\t\treturn 3 * eighth;\n\t\t\tcase Quarter:\n\t\t\t\treturn quarternote;\n\t\t\tcase DottedEighth:\n\t\t\t\treturn 3 * sixteenth;\n\t\t\tcase Eighth:\n\t\t\t\treturn eighth;\n\t\t\tcase Triplet:\n\t\t\t\treturn quarternote / 3;\n\t\t\tcase Sixteenth:\n\t\t\t\treturn sixteenth;\n\t\t\tcase ThirtySecond:\n\t\t\t\treturn sixteenth / 2;\n\t\t\tcase HundredTwentyEight:\n\t\t\t\treturn quarternote / 32;\n\t\t\tdefault:\n\t\t\t\treturn 0;\n\t\t}//end switch\n\t}", "CompositionBuilder<T> addNote(int start, int end, int instrument, int pitch, int volume);", "@Override\n\tpublic void setDuration(Duration duration) {\n\t\tfor (NoteBuilder builder : this) {\n\t\t\tbuilder.setDuration(duration);\n\t\t}\n\t\tthis.duration = duration;\n\t}", "public Note(char n, int dur) {\n\t\tnote = n;\n\t\tduration = dur;\n\t}", "@Override\n public void addNote(int startTime, int duration, Pitch pitch, Octave octave) {\n List<Note> notes = new ArrayList<>();\n Note newNote = new SimpleNote(pitch, octave, startTime, duration);\n notes.add(newNote);\n\n if (this.notes.get(startTime) == null) {\n this.notes.put(startTime, notes);\n } else {\n List<Note> oldList = this.notes.remove(startTime);\n oldList.addAll(notes);\n this.notes.put(startTime, oldList);\n }\n\n }", "public static PatternInterface addOrnament(Pattern ornament, Note baseNote, double longestOrnamentDuration){\r\n \tPatternInvestigator investigator = new PatternInvestigator();\r\n \tMusicStringParser stringParser = new MusicStringParser();\r\n \t\r\n \tstringParser.addParserListener(investigator);\r\n \tstringParser.parse(ornament);\r\n \t\r\n \tdouble longestDuration = investigator.getLongestDecimalDuration();\r\n \tdouble durationChange = longestOrnamentDuration / longestDuration;\r\n \t\r\n \tDurationPatternTransformer transformer = new DurationPatternTransformer(durationChange);\r\n \t\r\n \tPatternInterface result = transformer.transform(ornament);\r\n \t\r\n \tstringParser.removeParserListener(investigator);\r\n \tinvestigator = new PatternInvestigator();\r\n \tstringParser.addParserListener(investigator);\r\n \tstringParser.parse(result);\r\n \t\r\n \tif(investigator.getTotalDecimalDuration() < baseNote.getDecimalDuration()){\r\n \t\tdouble remainingDuration = baseNote.getDecimalDuration() - investigator.getTotalDecimalDuration();\r\n \t\tbaseNote.setDecimalDuration(remainingDuration);\r\n \t\tresult.add(baseNote.getMusicString());\r\n \t\treturn result;\r\n \t} else {\r\n \t\treturn new Pattern(baseNote.getMusicString());\r\n \t}\r\n }", "void addNote(int duration, int octave, int beatNum, String pitch)\n throws IllegalArgumentException;", "void setRecurrenceDuration(int recurrenceDuration);", "CompositionBuilder<T> setRepeat2(int repeats, int startrep, int endrep);", "SpriteAnimation(Duration duration, int cycleCount) {\n setCycleDuration(duration);\n setInterpolator(Interpolator.LINEAR);\n setCycleCount(cycleCount);\n }", "public Action restrictDuration(long durationMillis) {\n // If we start after the duration, then we just won't run.\n if (mStartOffset > durationMillis) {\n mStartOffset = durationMillis;\n mDuration = 0;\n mRepeatCount = 0;\n return this;\n }\n \n long dur = mDuration + mStartOffset;\n if (dur > durationMillis) {\n mDuration = durationMillis-mStartOffset;\n dur = durationMillis;\n }\n // If the duration is 0 or less, then we won't run.\n if (mDuration <= 0) {\n mDuration = 0;\n mRepeatCount = 0;\n return this;\n }\n // Reduce the number of repeats to keep below the maximum duration.\n // The comparison between mRepeatCount and duration is to catch\n // overflows after multiplying them.\n if (mRepeatCount < 0 || mRepeatCount > durationMillis\n || (dur*mRepeatCount) > durationMillis) {\n // Figure out how many times to do the action. Subtract 1 since\n // repeat count is the number of times to repeat so 0 runs once.\n mRepeatCount = (int)(durationMillis/dur) - 1;\n if (mRepeatCount < 0) {\n mRepeatCount = 0;\n }\n }\n return this;\n }", "MidiView getMidi();", "IPatternSequencer getSequencer();", "public Rational getRawDuration ()\r\n {\r\n Rational rawDuration = null;\r\n\r\n if (!getNotes().isEmpty()) {\r\n // All note heads are assumed to be the same within one chord\r\n Note note = (Note) getNotes().get(0);\r\n\r\n if (!note.getShape().isMeasureRest()) {\r\n // Duration (with flags/beams applied for non-rests)\r\n rawDuration = note.getNoteDuration();\r\n\r\n // Apply augmentation (applies to rests as well)\r\n if (dotsNumber == 1) {\r\n rawDuration = rawDuration.times(new Rational(3, 2));\r\n } else if (dotsNumber == 2) {\r\n rawDuration = rawDuration.times(new Rational(7, 4));\r\n }\r\n }\r\n }\r\n\r\n return rawDuration;\r\n }", "public B mo4686d(int duration) {\n this.f1121g = duration;\n return this;\n }", "public void repeatNotes()\n {\n int start, end;\n \n printScore(); //prints the current score that we have for the user to reference\n \n System.out.print(\"\\nEnter the note number that starts the repetition > \"); //prompts to enter the start of the repetition\n start = in.nextInt();\n \n System.out.print(\"Enter the note number that ends the repetition > \"); //prompts user to enter the end of the repetition\n end = in.nextInt();\n \n if (start <= score.size() && start > 0 && end <= score.size() && end >= start)\n {\n for (int i = 0; i <= ((end - 1) - (start - 1)); i++)\n {\n Note tempNote = new Note(score.get((start - 1) + i).getNote(), score.get((start - 1) + i).getBeat());\n score.add(tempNote);\n }\n }\n else\n {\n System.out.print(\"Error. \");\n if (end < 1 || end > score.size())\n System.out.println(\"The ending note number is not valid.\");\n else if (start < 1 || start > score.size())\n System.out.println(\"The starting note number is not valid.\");\n else if (start > end)\n System.out.println(\"The starting note number can not be bigger than the ending note number.\"); \n }\n }", "public T repeat(int count, float delay)\n\t{\n\t\tif (isStarted())\n\t\t{\n\t\t\tLttl.Throw(\"You can't change the repetitions of a tween or timeline once it is started\");\n\t\t}\n\t\tif (delay < 0)\n\t\t{\n\t\t\tLttl.Throw(\"Repeat delay can't be negative\");\n\t\t}\n\t\trepeatCnt = count;\n\t\tthis.repeatDelay = delay;\n\t\tisYoyo = false;\n\t\treturn (T) this;\n\t}", "public static PatternInterface trill(Note baseNote, char trillDirection){\r\n \treturn trill(baseNote, trillDirection, THIRTY_SECOND);\r\n }", "public TimeEntry duration(Integer duration) {\n this.duration = duration;\n return this;\n }", "public void playSong() {\n\t\t// Initialize\n\t\tint num = 1;\n\n\t\t// Get the notes to be played from the entryBox\n\t\tString notesString = \"V0 \" + instrumentType + \" \" + entryBox.getText();\n\n\t\t// Create a new rhythm object\n\t\tRhythm rhythm = new Rhythm();\n\n\t\t// Get the rhythm strings from the rhythm entry boxes\n\t\tString rhythmLayer1 = \"V1 \" + rhythm1.getText();\n\t\tString rhythmLayer2 = \"V2 \" + rhythm2.getText();\n\n\t\t// Set the strings to layers\n\t\trhythm.setLayer(1, rhythmLayer1);\n\t\trhythm.setLayer(2, rhythmLayer2);\n\n\t\t// Add the appropriate substitutions\n\t\trhythm.addSubstitution('O', \"[BASS_DRUM]i\");\n\t\trhythm.addSubstitution('o', \"Rs [BASS_DRUM]s\");\n\t\trhythm.addSubstitution('*', \"[ACOUSTIC_SNARE]i\");\n\t\trhythm.addSubstitution('^', \"[PEDAL_HI_HAT]s Rs\");\n\t\trhythm.addSubstitution('!', \"[CRASH_CYMBAL_1]s Rs\");\n\t\trhythm.addSubstitution('.', \"Ri\");\n\n\t\t// Get the rhythm pattern\n\t\tPattern rhythmPattern = rhythm.getPattern();\n\n\t\t// Get how many times the song should repeat\n\t\tString repeatNum = repeatNumber.getText();\n\t\tnum = Integer.parseInt(repeatNum);\n\n\t\t// Get the playback tempo\n\t\tString playTempo = \"T[\" + tempo.getText() + \"] \";\n\n\t\t// Create the song\n\t\tPattern song = new Pattern();\n\t\tsong.add(rhythmPattern);\n\t\tsong.add(notesString);\n\t\tsong.repeat(num);\n\n\t\t// Play the song\n\t\tplayer.play(playTempo + song);\n\n\t}", "WindowedStream<T> timeSlidingWindow(long millis, long slide);", "public interface Duration {\n /*\n * Constants used to avoid creating objects for common durations\n */\n public static final RealDuration INSTANT = RealDuration.milliseconds(0);\n public static final RealDuration ONE_MILLISECOND = RealDuration.milliseconds(1);\n public static final RealDuration ONE_SECOND = RealDuration.seconds(1);\n public static final RealDuration ONE_MINUTE = RealDuration.minutes(1);\n public static final RealDuration ONE_HOUR = RealDuration.hours(1);\n public static final RealDuration ONE_DAY = RealDuration.days(1);\n public static final RealDuration ONE_WEEK = RealDuration.weeks(1);\n public static final RealDuration ONE_MONTH = RealDuration.months(1);\n public static final RealDuration ONE_YEAR = RealDuration.years(1);\n\n /*\n * Actual interface methods\n */\n\n RealDuration asRealDuration();\n\n TickDuration asTickDuration();\n\n /*\n * Inner classes to allow grammar such as new Duration.Minutes(12)\n */\n\n public static class Milliseconds extends RealDuration {\n public Milliseconds(long millis) {\n super(millis);\n }\n }\n\n public static class Seconds extends RealDuration {\n public Seconds(long num) {\n super((long) (num * SECONDS_TO_MILLIS));\n }\n }\n\n public static class Minutes extends RealDuration {\n public Minutes(long num) {\n super((long) (num * MINUTES_TO_MILLIS));\n }\n }\n\n public static class Hours extends RealDuration {\n public Hours(long num) {\n super((long) (num * HOURS_TO_MILLIS));\n }\n }\n\n public static class Days extends RealDuration {\n public Days(long num) {\n super((long) (num * DAYS_TO_MILLIS));\n }\n }\n\n public static class Weeks extends RealDuration {\n public Weeks(long num) {\n super((long) (num * WEEKS_TO_MILLIS));\n }\n }\n\n public static class Months extends RealDuration {\n public Months(long num) {\n super((long) (num * MONTHS_TO_MILLIS));\n }\n }\n\n public static class Years extends RealDuration {\n public Years(long num) {\n super((long) (num * YEARS_TO_MILLIS));\n }\n }\n\n public static class Decades extends RealDuration {\n public Decades(long num) {\n super((long) (num * DECADES_TO_MILLIS));\n }\n }\n\n public static class Centuries extends RealDuration {\n public Centuries(long num) {\n super((long) (num * CENTURIES_TO_MILLIS));\n }\n }\n\n public static class Ticks extends TickDuration {\n public Ticks(long num) {\n super(num);\n }\n }\n}", "public void playDtmf(char dtmf, int durationMs);", "public void playPiece() {\n \t\n System.out.println(\"Title: \" + this.title);\n System.out.println(\"Composer: \" + this.composer);\n System.out.println(\"Played in \" + this.meterNumerator + \"/\" + this.meterDenominator + \" time @ \" + this.tempoSpeed + \" BPM.\");\n SequencePlayer player;\n try {\n \t\n \t// Create an instance of LyricListener and add a processLyricEvent to print out lyrics\n LyricListener listener = new LyricListener() {\n public void processLyricEvent(String text) {\n System.out.println(text);\n }\n };\n \n // Iterates through each MusicalPhrase and queues the notes to be played by the SequencePlayer\n player = new SequencePlayer(this.getTempo(), this.getTicksPerBeat(), listener);\n for (MusicalPhrase phrase : this.phrases) {\n int tickCount = 0;\n for (Bar bar : phrase.getBars()) {\n for (Note note : bar.getNotes()) {\n int ticksPerNote = this.getTicksPerBeat() * this.tempoDenominator * note.getNumerator() / this.tempoNumerator / note.getDenominator();\n if (note instanceof PitchNote) {\n for(int i=0; i<note.getNote().length; i++) { \n // getTicksPerBeat gives you the default amount for a note = tempoNum/tempoDen\n // We want ticks for a note that is noteNum / noteDen\n \tplayer.addNote(note.getNote()[i], tickCount, ticksPerNote);\n }\n if (!(note.getLyric().equals(\"\"))) {\n player.addLyricEvent(note.getLyric(), tickCount);\n }\n }\n tickCount += ticksPerNote;\n }\n }\n }\n player.play();\n }\n catch (Exception e) {\n e.printStackTrace();\n } \n }", "void addNote(int duration, int octave, int beatNum, int instrument, int volume, String pitch)\n throws IllegalArgumentException;", "public interface IMotion extends ITimeInterval {\n\n /**\n * Adds this motion to the given queue of motions, combining it if necessary with any\n * overlapping motions that already exist in the queue. Combining motions involves\n * both splicing motions into overlapped vs. non-overlapped time periods, as well as\n * combining the fields they change (x, y, w, h, and rgb) into one motion reflective of all\n * changes.\n * @param motionQueue represents the queue of motions for this motion to be added to\n * @return the updated queue with this motion added\n */\n Queue<IMotion> addToQueue(Queue<IMotion> motionQueue);\n\n /**\n * Combines the changes/transformations two motions, this motion and the given motion, make\n * into one motion. Assumes that motions have the same start and end tick.\n *\n * @param m1 the given motion whose changes are added with this motion\n * @return a motion that holds the changes both this motion and the given motion m1 made\n * @throws IllegalArgumentException if motions do not have the same start and end tick as each\n * other, or they illegally overlap (i.e. both try to change the same element of a shape,\n * or their unchanged fields are different)\n */\n IMotion addMotions(IMotion m1) throws IllegalArgumentException;\n\n /**\n * Get a splice/portion of this motion from the given start tick to the end tick.\n * If motion is completely out of the splice range, return null.\n * If motion does not fill total splice range, return;\n * the part of the motion that does fit it the range.\n * Examples:\n * A motion from t=3 to t=8, spliced from t=4 to t=6, would return the portion of the motion from\n * t=4 to t=6\n * A motion from t=4 to t=6, spliced from t=6 to\n * @param splitTickStart represents the start of the splice range in ticks\n * @param splitTickEnd represents the end of the splice range in ticks\n * @return the splice of this motion from the given tick range, or null if motion is outside of\n * tick range or tick range is 0.\n */\n IMotion splice(int splitTickStart, int splitTickEnd);\n\n /**\n * Given two motions that are consecutive (i.e this motion is the next motion\n * directly after the given motion), check that all the end values of the given motion\n * match up with all the start values of the this motion.\n * @param m1 represents the consecutive motion that comes right before this motion\n * @return true if this motion's start values match the given motion's end values,\n * false otherwise\n */\n boolean validConsecutiveMotion(IMotion m1);\n\n /**\n * Represents the elements of a shape this motion changes as a list of booleans.\n * Each boolean in the list represents a change in x, y, width, height, or color respectively,\n * where a change in the element is represented by true and a lack of change by this motion\n * is represented by false.\n * E.g. a motion that changed the x position and color of a shape would be represented as:\n * [true, false, false, false, true].\n */\n boolean[] bitwiseChangeList();\n\n /**\n * Executes this motion for a given Shape, changing its attributes to reflect\n * change in position, size, color, or hidden status to the end state of this motion.\n * @param shape the shape to execute motion for.\n */\n void executeMotion(Shape shape);\n\n /**\n * Generates the string representation of this Motion, including each of its attributes (ticks,\n * x position, y position, width, height, color).\n * @return the string rendering of this Motion.\n */\n String toString();\n\n /**\n * Generates a formatted string of the start values of a motion.\n * @return the formatted string of a motion's start values.\n */\n String toStringStartValues();\n\n /**\n * Generates a formatted string of the end values of a motion.\n * @return the formatted string of a motion's end values.\n */\n String toStringEndValues();\n\n /**\n * Generates the string representation of this Motion, including each of its attributes (ticks,\n * x position, y position, width, height, color) as integers.\n * @return the string rendering of this Motion.\n */\n String toStringAsInt();\n\n /**\n * Gets the first x value of this motion.\n * @return the first x value at the last tick of the motion.\n */\n double getStartX();\n\n /**\n * Gets the end x value of this motion.\n * @return the end x value at the last tick of the motion.\n */\n double getEndX();\n\n /**\n * Gets the first y value of this motion.\n * @return the first y value at the last tick of the motion.\n */\n double getStartY();\n\n /**\n * Gets the final y value of this motion.\n * @return the end y value at the last tick of the motion.\n */\n double getEndY();\n\n /**\n * Gets the first width value of this motion.\n * @return the first width value at the last tick of the motion.\n */\n double getStartW();\n\n /**\n * Gets the final width value of this motion.\n * @return the end width value at the last tick of the motion.\n */\n double getEndW();\n\n /**\n * Gets the final RGB value of this motion.\n * @return the end RGB value at the last tick of the motion.\n */\n double getStartH();\n\n /**\n * Gets the final height value of this motion.\n * @return the end height value at the last tick of the motion.\n */\n double getEndH();\n\n /**\n * Gets the first RGB value of this motion.\n * @return the first RGB value at the first tick of the motion.\n */\n int[] getStartRGB();\n\n /**\n * Gets the final RGB value of this motion.\n * @return the end RGB value at the last tick of the motion.\n */\n int[] getEndRGB();\n\n /**\n * Returns this motion and the other motion given as a list of spliced, combined motions.\n * Combining motions involves splitting up the motions into non-overlapping and overlapping\n * periods of time, and consolidating the motions' changes into one motion\n * for overlapping periods of time.\n * examples:\n * 2 3 4 5 6\n * |-----| motion1\n * |--------| motion2\n * combined:\n * |--| newmotion1\n * |--| newmotion2\n * |-----| newmotion3\n * 2 3 4 5 6\n * |--------| m1\n * |--------| m2\n * combined:\n * |--------| newmotion1\n * 2 3 4 5 6\n * |-----| m1\n * |--------| m2\n * combined:\n * |--| newmotion1\n * |-----| newmotion2\n * 2 3 4 5 6\n * |--------| m1\n * |--| m2\n * combined:\n * |--| newmotion1\n * |--| newmotion2\n * |--| newmotion3\n *\n * @param other the given motion to combine with this motion\n * @return the list of combined motion(s)\n * @throws IllegalArgumentException if there are illegal/invalid overlaps between the two motions\n */\n List<IMotion> combineMotion(IMotion other);\n}", "public static <T> State<T> delayed(Duration duration, State<T> nextState) {\n return new WaitState<T>() {\n private volatile boolean hasFinished = false;\n @Override\n public Duration getWait() {\n // another common state could be delayed with a predicate and a delay\n // policy that automatically does the exponential backoff with jitter,\n // backoff, clamped higher bound, etc.\n return duration;\n }\n\n @Override\n public boolean isFinished(State<T> state) {\n return hasFinished;\n }\n\n @Override\n public State<T> onFinish() {\n return nextState;\n }\n\n @Override\n public State<T> run(Workflow<T> workflow) {\n // another common state could be supplied that provides a delegate\n // here to perform during the wait state.\n System.out.println(\"delaying work for: \" + workflow);\n hasFinished = true;\n return this;\n }\n };\n }", "public final StepPattern getStepPattern() {\n/* 176 */ return this.m_stepPattern;\n/* */ }", "public static void createDelay(int duration) {\r\n\t\ttry {\r\n\t\t\tThread.sleep(duration);\r\n\t\t} catch(Exception e) {\r\n\t\t\t//do nothing\r\n\t\t}\r\n\t}", "public Slide getSlide(int slideNumber, boolean mobile);", "FlowSequence createFlowSequence();", "public int getDuration();", "Duration(Integer duration){\n\t\t_minimum = duration;\n\t\t_maximum = duration;\n\t\t_range = new Range(_minimum, _maximum);\n\t}", "public void setLength(int duration){\n\t\tlength = duration;\n\t}", "public static Note createNote(int octave, Pitch pitch, int startBeat, int endBeat) {\n return new NoteImpl(octave, pitch, startBeat, endBeat);\n }", "Constant getCyclePeriodConstant();", "private Simulator(final int duration) {\n this(duration, duration);\n }", "@Override\n public CompositionBuilder<MusicOperation> addNote(int start, int end, int instrument,\n int pitch, int volume) {\n this.listNotes.add(new SimpleNote(Pitch.values()[(pitch) % 12],\n Octave.values()[(pitch / 12) - 2 ], start, end - start, instrument, volume));\n return this;\n }", "Sequence createSequence();", "public Rational getDuration ()\r\n {\r\n if (this.isWholeDuration()) {\r\n return null;\r\n } else {\r\n Rational raw = getRawDuration();\r\n\r\n if (tupletFactor == null) {\r\n return raw;\r\n } else {\r\n return raw.times(tupletFactor);\r\n }\r\n }\r\n }", "void pulse(double pulseLength);", "void setDuration(int duration);", "public static Observable<Long> getObservableSkipDuration() {\n return observableIntervalSrc;//todo\n }", "public Duration() {\n this(0, 0, 0, 0, 0, 0.0);\n }", "SequenceFlow createSequenceFlow();", "public T repeatYoyo(int count, float delay)\n\t{\n\t\tif (isStarted())\n\t\t{\n\t\t\tLttl.Throw(\"You can't change the repetitions of a tween or timeline once it is started\");\n\t\t}\n\t\tif (delay < 0)\n\t\t{\n\t\t\tLttl.Throw(\"Repeat delay can't be negative\");\n\t\t}\n\t\trepeatCnt = count;\n\t\trepeatDelay = delay;\n\t\tisYoyo = true;\n\t\treturn (T) this;\n\t}", "public RotationRulesType withDuration(String duration) {\n setDuration(duration);\n return this;\n }", "public static PatternInterface graceNote(Note graceNote, Note baseNote){\r\n \treturn graceNote(graceNote, baseNote, THIRTY_SECOND);\r\n }", "@Test\n public void advancedRepeatTest(){\n \n testMaterialConstructor();\n ArrayList<String> voiceNames = new ArrayList<String>();\n voiceNames.add(\"Aziz\");\n \n ArrayList<BarLineObject> objs = new ArrayList<BarLineObject>();\n objs.add(C);\n objs.add(E);\n objs.add(C);\n objs.add(G);\n objs.add(plainBar);\n objs.add(C);\n objs.add(E);\n objs.add(C);\n objs.add(G);\n objs.add(endBar);\n objs.add(G);\n objs.add(G);\n objs.add(G);\n objs.add(C);\n objs.add(r1Bar);\n objs.add(C);\n objs.add(G);\n objs.add(G);\n objs.add(G);\n objs.add(r2Bar);\n objs.add(C);\n objs.add(E);\n objs.add(E);\n objs.add(E);\n objs.add(repeatBar);\n \n objs.add(C);\n objs.add(E);\n objs.add(C);\n objs.add(G);\n objs.add(repeatStart);\n objs.add(G);\n objs.add(C);\n objs.add(C);\n objs.add(G);\n objs.add(repeatBar);\n \n \n \n Parser2 myParser2 = new Parser2(voiceNames,1,1);\n myParser2.parse(objs);\n ArrayList<Voice> voices = myParser2.getVoices();\n\n Song lalala = new Song(voices);\n \n SequencePlayer sqPlayer;\n try {\n sqPlayer = new SequencePlayer(140, lalala.getMinTicksPerQuarter());\n myPlayer MrAhmed = new myPlayer(\"C\", sqPlayer);\n lalala.addToPlayer(MrAhmed);\n sqPlayer.play();\n \n } catch (MidiUnavailableException e) {\n e.printStackTrace();\n } catch (InvalidMidiDataException e) {\n e.printStackTrace();\n }\n \n }", "private static double[] note(double hz, double duration, double amplitude) {\n int N = (int) (StdAudio.SAMPLE_RATE * duration);\n double[] a = new double[N + 1];\n for (int i = 0; i <= N; i++)\n a[i] = amplitude * Math.sin(2 * Math.PI * i * hz / StdAudio.SAMPLE_RATE);\n return a;\n }", "int getDuration();", "int getDuration();", "private StringBuilder listAllPitches(int length) {\n StringBuilder builder = new StringBuilder();\n\n int padding = Integer.toString(length).length();\n String spaces = \"\";\n spaces = String.format(\"%\" + (padding) + \"s\", spaces);\n builder.append(spaces);\n\n Note highest = this.getHighestNote();\n Note lowest = this.getLowestNote();\n int ordinalHighestOctave = highest.getOctave().ordinal();\n int ordinalHighestPitch = highest.getPitch().ordinal();\n int ordinalLowOctave = lowest.getOctave().ordinal();\n int ordinalLowPitch = lowest.getPitch().ordinal();\n int from = ordinalLowOctave * 12 + ordinalLowPitch;\n int to = ordinalHighestOctave * 12 + ordinalHighestPitch;\n List<String> allNotes = this.allnotes.subList(from, to + 1);\n\n for (int i = 0; i < allNotes.size(); i++) {\n String current = allNotes.get(i);\n\n if (current.length() == 2) {\n builder.append(\" \" + current + \" \");\n } else if (current.length() == 3) {\n builder.append(\" \" + current + \" \");\n } else if (current.length() == 4) {\n builder.append(\" \" + current);\n } else {\n builder.append(current);\n }\n }\n return builder;\n }", "private static\n void createPptSlide() throws IOException {\n HSLFSlideShow ppt = new HSLFSlideShow();\n HSLFPictureData pd = ppt.addPicture(new File(HEADER_PIC_PATH), PictureData.PictureType.JPEG);\n\n //add first slide\n HSLFSlide s1 = ppt.createSlide();\n HSLFFill fill = s1.getBackground().getFill();\n fill.setFillType(HSLFFill.FILL_PICTURE);\n fill.setPictureData(pd);\n //add second slide\n HSLFSlide s2 = ppt.createSlide();\n\n //save changes in order file\n FileOutputStream out = null;\n try {\n out = new FileOutputStream(\"c:\\\\slideshow.ppt\");\n ppt.write(out);\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n } catch (IOException e) {\n e.printStackTrace();\n } finally {\n try {\n out.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n\n }\n }", "public static Simulator createSimulator(final int duration) {\n return new Simulator(duration);\n }", "public interface PresentationDocument {\n /**\n * Method will load a File into a readable presentation (normally\n * involves steps of conversion)\n *\n * @param source file\n */\n public void load(File source);\n\n /**\n * Intended to closeDocument loading a document after loading has been\n * initiated\n */\n public void cancel();\n\n /**\n * Convenience method to get the loaded status of this document\n *\n * @return true if the document is loaded\n */\n public boolean isLoaded();\n\n /**\n * Method to set the loaded status of this document\n *\n * @param loaded status to use\n */\n public void setLoaded(boolean loaded);\n\n /**\n * Method to get a slide at the passed slide number\n *\n * @param slideNumber to get\n * @param mobile to get mobile browser sized slide\n * @return resulting slide\n */\n public Slide getSlide(int slideNumber, boolean mobile);\n\n /**\n * Convenience method to get the total number of slides in this document\n *\n * @return number of slides\n */\n public int getNumberOfSlides();\n\n /**\n * Method to get the deletion status of this document\n *\n * @return whether to delete the presentation on exit\n */\n public boolean deleteOnExit();\n\n /**\n * Method to get the deletion status of this document\n *\n * @param flag true to delete the presentation once converted\n */\n public void setDeleteOnExit(boolean flag);\n\n /**\n * Dispose of the existing document and any slides created during the\n * conversion\n */\n public void dispose();\n \n /**\n * Delete files generated from uploaded presentation.\n */\n public void deleteGeneratedFiles();\n}", "public static Wait duration(Duration duration)\r\n\t{\r\n\t\treturn new Wait(WaitTarget.withDuration(duration));\r\n\t}", "public static SingleArrayFragment newInstance(int effectRatio, int gapDelay, int endDelay) {\n SingleArrayFragment fragment = new SingleArrayFragment();\n Bundle args = new Bundle();\n args.putInt(ARG_PARAM1, effectRatio);\n args.putInt(ARG_PARAM2, gapDelay);\n args.putInt(ARG_PARAM3, endDelay);\n fragment.setArguments(args);\n return fragment;\n }", "private static void testDuration() {\n LocalTime time1 = LocalTime.of(15, 20, 38);\n LocalTime time2 = LocalTime.of(21, 8, 49);\n\n LocalDateTime dateTime1 = time1.atDate(LocalDate.of(2014, 5, 27));\n LocalDateTime dateTime2 = time2.atDate(LocalDate.of(2015, 9, 15));\n\n Instant i1 = Instant.ofEpochSecond(1_000_000_000);\n Instant i2 = Instant.now();\n\n // create duration between two points\n Duration d1 = Duration.between(time1, time2);\n Duration d2 = Duration.between(dateTime1, dateTime2);\n Duration d3 = Duration.between(i1, i2);\n Duration d4 = Duration.between(time1, dateTime2);\n\n // create duration from some random value\n Duration threeMinutes;\n threeMinutes = Duration.ofMinutes(3);\n threeMinutes = Duration.of(3, ChronoUnit.MINUTES);\n }", "RepeatStatement createRepeatStatement();", "public TransformationBuff(int morphId, long duration) {\n\t\tthis.morphId = morphId;\n\t\tthis.startDuration = System.currentTimeMillis();\n\t\tthis.endDuration = startDuration + duration;\n\t}", "void addRepeat(int beatNum, RepeatType repeatType);", "private void getNotes(MusicCircle circle){\n\t\tif(! circle.isMuted()){\n\t\t\tfor(int i=0; i<circle.getNumNotes(); i++){\n\t\t\t\tif( circle.getS(i) != SILENCE) note(circle.getT(i) + loopOffset, circle.getD(i), Fofs(circle.getS(i) + circle.getBaseSemitone()));\n\t\t\t}\n\t\t}\n\t}", "public Duration update(Integer duration){\n\t\t_minimum = duration;\n\t\t_maximum = duration;\n\t\t_range = new Range(_minimum, _maximum);\n\t\treturn this;\n\t}", "public static Note createNote(int octave, Pitch pitch, int startBeat, int endBeat, int\n instrument, int volume) {\n return new NoteImpl(octave, pitch, startBeat, endBeat, instrument, volume);\n }", "public void setDuration( Long duration );", "private static void createSlideTransitions() {\n\t\tif (slideList.size() < SLIDES_REGIONS_LIMIT) {\n\t\t\tint length = (slideList.size() / 2) - 1;\n\t\t\t\n\t\t\tif (slideList.size() % 2 == 0) {\n\t\t\t\tlength++;\n\t\t\t}\n\t\t\t\n\t\t\tfor (int i = 0; i < length; i++) {\n\t\t\t\ttransitionList.add(slideList.get(i));\n\t\t\t\ttransitionList.add(slideList.get(length - i - 1));\n\t\t\t}\n\t\t} else {\n\t\t\tint length = slideList.size() / NUMBER_REGIONS / 2 - 1;\n\t\t\t\n\t\t\tif (slideList.size() % 2 == 0) {\n\t\t\t\tlength++;\n\t\t\t}\n\t\t\t\n\t\t\tfor (int i = 0; i < NUMBER_REGIONS; i++) {\n\t\t\t\tfor (int j = 0; j < length; j++) {\n\t\t\t\t\ttransitionList.add(slideList.get(j + i * length));\n\t\t\t\t\t//System.out.println(i * length - j - 1);\n\t\t\t\t\ttransitionList.add(slideList.get((i + 1) * length - j - 1));\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (slideList.size() % 2 != 0) {\n\t\t\t\ttransitionList.add(slideList.get(slideList.size() - 1));\n\t\t\t}\n\t\t}\n\t}", "public interface CompositionBuilder<T> {\n /**\n * Constructs an actual composition, given the notes that have been added\n *\n * @return The new composition\n */\n T build();\n\n /**\n * Sets the tempo of the piece\n *\n * @param tempo The speed, in microseconds per beat\n * @return This builder\n */\n CompositionBuilder<T> setTempo(int tempo);\n\n /**\n * Adds a new note to the piece\n *\n * @param start The start time of the note, in beats\n * @param end The end time of the note, in beats\n * @param instrument The instrument number (to be interpreted by MIDI)\n * @param pitch The pitch (in the range [0, 127], where 60 represents C4, the middle-C on a\n * piano)\n * @param volume The volume (in the range [0, 127])\n * @return This builder\n */\n CompositionBuilder<T> addNote(int start, int end, int instrument, int pitch, int volume);\n\n /**\n * Sets a simple, whole song repeat\n *\n * @param repeats the number of times the song should be repeated\n * @return This builder\n */\n CompositionBuilder<T> setRepeat1(int repeats);\n\n /**\n * Sets a bound repeat\n *\n * @param repeats the number of times this section should be repeated\n * @param startrep the starting beat of this repeat\n * @param endrep the end beat of this repeat\n * @return This builder\n */\n CompositionBuilder<T> setRepeat2(int repeats, int startrep, int endrep);\n\n /**\n * Sets an alternate ending in a piece\n *\n * @param integers the even list of integers to be made into BoundRepeats\n * @return This builder\n */\n CompositionBuilder<T> setAlternateEndings(List<Integer> integers);\n}", "@Override\r\n\t\t\t\t\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\t\t\t\t\tNoteInJson[] pattern=gpt.getPattern();\r\n\t\t\t\t\t\t\t\t\t\tif(change_tempo){\r\n\t\t\t\t\t\t\t\t\t\t\tPatternMaker.changeSpeed(pattern, ratio);\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\tgotoPractice(pattern);\r\n\t\t\t\t\t\t\t\t\t}", "public Delay(float delay, int repeat)\n\t{\n\t\tsetDelay(delay);\n\t\tdelayCount=0f;\n\t\trepeatMax=repeat;\n\t\trepeatCount=0;\n\t}", "@Override\n public Pattern createPattern(Image image, String repeat) {\n return new Pattern(image, repeat);\n }", "void setDuration(java.lang.String duration);", "public void setDuration(int duration){\n this.duration = duration;\n }", "public int getDuration() {return this.duration;}", "public void generateTone()\n throws LineUnavailableException {\n if ( clip!=null ) {\n clip.stop();\n clip.close();\n } else {\n clip = AudioSystem.getClip();\n }\n boolean addHarmonic = harmonic.isSelected();\n\n int intSR = ((Integer)sampleRate.getSelectedItem()).intValue();\n int intFPW = framesPerWavelength.getValue();\n\n float sampleRate = (float)intSR;\n\n // oddly, the sound does not loop well for less than\n // around 5 or so, wavelengths\n int wavelengths = 20;\n byte[] buf = new byte[2*intFPW*wavelengths];\n AudioFormat af = new AudioFormat(\n sampleRate,\n 8, // sample size in bits\n 2, // channels\n true, // signed\n false // bigendian\n );\n\n int maxVol = 127;\n for(int i=0; i<intFPW*wavelengths; i++){\n double angle = ((float)(i*2)/((float)intFPW))*(Math.PI);\n buf[i*2]=getByteValue(angle);\n if(addHarmonic) {\n buf[(i*2)+1]=getByteValue(2*angle);\n } else {\n buf[(i*2)+1] = buf[i*2];\n }\n }\n\n try {\n byte[] b = buf;\n AudioInputStream ais = new AudioInputStream(\n new ByteArrayInputStream(b),\n af,\n buf.length/2 );\n\n clip.open( ais );\n } catch(Exception e) {\n e.printStackTrace();\n }\n }", "protected abstract void nextWave();", "public void generateIntermediateFrames(ArrayList<Difference> difference, ArrayList<Difference> difference2) {\n for(int i=0;i<view1.lines.size();i++) {\n Line dest = view2.lines.get(i);\n Line src = view1.lines.get(i);\n Difference d = new Difference((float)(dest.startX-src.startX)/(frameCount+1), (float)(dest.stopX-src.stopX)/(frameCount+1), (float)(dest.startY-src.startY)/(frameCount+1), (float)(dest.stopY-src.stopY)/(frameCount+1));\n difference.add(d);\n d = new Difference(((float)src.startX-dest.startX)/(frameCount+1), (float)(src.stopX-dest.stopX)/(frameCount+1), (float)(src.startY-dest.startY)/(frameCount+1), (float)(src.stopY-dest.stopY)/(frameCount+1));\n difference2.add(d);\n }\n }", "org.apache.xmlbeans.XmlInt xgetRecurrenceDuration();", "public int getDuration() { return duration; }", "Duration getDuration();", "private static void generateSequence() throws FileNotFoundException {\n Scanner s = new Scanner(new BufferedReader(new FileReader(inputPath + filename)));\n\t\tlrcSeq = new ArrayList<Integer>();\n\t\tmeloSeq = new ArrayList<Integer>();\n\t\tdurSeq = new ArrayList<Integer>();\n\t\t\n\t\tString line = null;\n\t\tint wordStress;\n\t\tint pitch;\n\t\tint melStress;\n\t\tint stress;\n\t\tint duration;\n\t\t\n\t\twhile(s.hasNextLine()) {\n\t\t\tline = s.nextLine();\n\t\t\tString[] temp = line.split(\",\");\n\t\t\t\n\t\t\twordStress = Integer.parseInt(temp[1]);\n\t\t\tpitch = Integer.parseInt(temp[2]);\n\t\t\tmelStress = Integer.parseInt(temp[3]);\n\t\t\tduration = Integer.parseInt(temp[4]);\n\t\t\t\n\n\t\t\t//combine word level stress and sentence level stress\n\t\t\tstress = wordStress * 3 + melStress;\n\t\t\t/*if(stress < 0 || stress > 9) {\n\t\t\t\tSystem.out.println(\"Stress range error\");\n\t\t\t}*/\n\t\t\tlrcSeq.add(stress);\n\t\t\tmeloSeq.add(pitch);\n\t\t\tdurSeq.add(duration);\n\t\t}\n\t\t\n\t\t//calculate relative value\n\t\tfor(int i = 0;i < lrcSeq.size() -1;++i) {\n\t\t\tlrcSeq.set(i, lrcSeq.get(i+1)-lrcSeq.get(i));\n\t\t\tmeloSeq.set(i, meloSeq.get(i+1) - meloSeq.get(i));\n\t\t\tif(durSeq.get(i+1) / durSeq.get(i)>=1)\n\t\t\t\tdurSeq.set(i, durSeq.get(i+1) / durSeq.get(i));\n\t\t\telse \n\t\t\t\tdurSeq.set(i,durSeq.get(i) / durSeq.get(i+1) * (-1));\n\t\t}\n\t\tlrcSeq.remove(lrcSeq.size()-1);\n\t\tmeloSeq.remove(meloSeq.size()-1);\n\t\tdurSeq.remove(durSeq.size()-1);\n\t\t\n\t}", "java.lang.String getDuration();", "public static int nextNote(int n1,int n2) {\n double rnd,sum=0;\n rnd=Math.random();\n for(int i=0;i<12;i++)\n {\n sum+=weights[n1-60][n2-60][i];\n\n if(rnd<=sum)\n return i+60;\n }\n return 62;\n }", "public interface IMidiView extends IView{\n /**\n * Plays the note.\n * @param pitch The pitch to play at\n * @param volume The volume of the note\n * @param length the length of the note\n * @param tempo The tempo of the note\n * @param instrument the instrument of the note\n * @throws InvalidMidiDataException when the note is invalid\n */\n void playNote(int pitch, int volume, int length, int tempo, int instrument)\n throws InvalidMidiDataException;\n\n /**\n * Plays the whole song.\n */\n void play();\n\n /**\n * ADDED IN HW 7!\n * Gets the song from the view.\n * @return ISong this song being returned\n */\n ISong getSong();\n\n /**\n * ADDED IN HW 7!\n * Sets the beat of the MIDI.\n * @param beat the beat to set to\n */\n void setBeat(int beat);\n\n /**\n * ADDED IN HW 7!\n * Gets the current beat of the MIDI player.\n * @return the current beat\n */\n int getBeat();\n}" ]
[ "0.62809354", "0.5565353", "0.5560384", "0.503566", "0.5031997", "0.4995147", "0.49949598", "0.49491587", "0.48160028", "0.4815513", "0.48095497", "0.464625", "0.4618881", "0.45888728", "0.4536685", "0.45235306", "0.45191774", "0.448865", "0.44852105", "0.44601202", "0.44331753", "0.4400763", "0.43786442", "0.4372901", "0.43364775", "0.43203512", "0.4317975", "0.4309131", "0.43013746", "0.42977893", "0.42303586", "0.42295527", "0.41905034", "0.41760284", "0.41673058", "0.41622362", "0.41284457", "0.41157684", "0.41072935", "0.41066286", "0.41050386", "0.4100387", "0.4095946", "0.40622804", "0.40619436", "0.40600598", "0.4043196", "0.40364555", "0.40349513", "0.4033946", "0.4030227", "0.4029397", "0.40206686", "0.40148002", "0.4008369", "0.39938113", "0.39769086", "0.39679998", "0.39642712", "0.3955073", "0.39498472", "0.39406806", "0.39391115", "0.39297676", "0.39108118", "0.38827592", "0.38704655", "0.38704655", "0.38646078", "0.38626087", "0.3851574", "0.38511178", "0.38495415", "0.38494393", "0.38466847", "0.38341784", "0.38301834", "0.38278317", "0.38268515", "0.38227862", "0.38185477", "0.38092554", "0.38075262", "0.38075238", "0.38046196", "0.38001126", "0.37973446", "0.37967327", "0.37935486", "0.37918097", "0.37912202", "0.37905273", "0.37860137", "0.37824106", "0.37737727", "0.37681782", "0.37628636", "0.37627417", "0.37532452", "0.37530723" ]
0.81903577
0
Right now, this is a passthrough to hammerOn()
public static PatternInterface trill(Note note1, Note note2, double duration, int numSteps) { return hammerOn(note1, note2, duration, numSteps); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public void hasHammer() {\n\t\tif (checkHammer(Integer.parseInt(getCurrentPositionX()),Integer.parseInt(getCurrentPositionY()))) {\n\t\t\tDisplay.setHammer(\"Yes\");\n\t\t\tDisplay.setMessage(\"You have found an ax! Try to cut a withered tree!\");\n\t\t}\n\t}", "public void onHit() {\n //override this to provide extra functionality\n }", "public void on() {\n\n\t}", "@Override\n\tpublic void onHit() {\n\t\t\n\t}", "protected void ap() {\n Object object = this.li;\n synchronized (object) {\n if (this.lz != null) {\n return;\n }\n IntentFilter intentFilter = new IntentFilter();\n intentFilter.addAction(\"android.intent.action.SCREEN_ON\");\n intentFilter.addAction(\"android.intent.action.SCREEN_OFF\");\n this.lz = new BroadcastReceiver(){\n\n public void onReceive(Context context, Intent intent) {\n ab.this.d(false);\n }\n };\n this.lp.registerReceiver(this.lz, intentFilter);\n return;\n }\n }", "@Override\r\n\tpublic void on() {\n\r\n\t}", "void onShutter();", "private void onCallHeld(int callheld, byte[] address) {\n StackEvent event = new StackEvent(StackEvent.EVENT_TYPE_CALLHELD);\n event.valueInt = callheld;\n event.device = getDevice(address);\n if (DBG) {\n Log.d(TAG, \"onCallHeld: address \" + address + \" event \" + event);\n }\n HeadsetClientService service = HeadsetClientService.getHeadsetClientService();\n if (service != null) {\n service.messageFromNative(event);\n } else {\n Log.w(TAG, \"onCallHeld: Ignoring message because service not available: \" + event);\n }\n }", "private void onCallHeld(int callheld, byte[] address) {\n StackEvent event = new StackEvent(StackEvent.EVENT_TYPE_CALLHELD);\n event.valueInt = callheld;\n event.device = getDevice(address);\n if (DBG) {\n Log.d(TAG, \"onCallHeld: address \" + address + \" event \" + event);\n }\n HeadsetClientService service = HeadsetClientService.getHeadsetClientService();\n if (service != null) {\n service.messageFromNative(event);\n } else {\n Log.w(TAG, \"onCallHeld: Ignoring message because service not available: \" + event);\n }\n }", "public void onTurnOver() {}", "@Override\n protected void onFar() {\n }", "public void onShutter() {\n \n }", "@Override\n\tpublic void turnOn() {\n\n\t}", "public void onShutter() {\n }", "void onEDHGameStart();", "protected void onEnter(){}", "@Override\n public void onShutter() {\n }", "public void hang() {\n // WRITE CODE BETWEEN THESE LINES -------------------------------------------------------- //\n // TODO: run the intake motor to both extend and pull in hanger\n // Note: only enable running motor when the m_extended flag is true\n\n // ^^-----------------------------------------------------------------------------------^^ //\n }", "@Override\n public void phoneHangUp() {\n Log.e(\"test_TTS\", \"phoneHangUp\");\n }", "@Override\n public void phoneHangUp() {\n Log.e(\"test_TTS\", \"phoneHangUp\");\n }", "public abstract void onEnable();", "@Override\n public void onShutter() {\n }", "void onHandWaveGesture();", "public interface GestureHandler {\r\n /**\r\n * It will be called when a specific gesture triggered.\r\n * You can implement the handler logic in this method. Such as , launch a application.\r\n * @param metaData GestureMetaData\r\n */\r\n void onActive(GestureMetaData metaData);\r\n\r\n /**\r\n * It will be called when the user release the finger in HOVER mode.\r\n * In this function you can release resource. Wait for the next called.\r\n */\r\n void onExit();\r\n\r\n /**\r\n * Return the gestureType if onActive is triggered. Otherwise return -1;\r\n * @return gestureType\r\n */\r\n int isActive();\r\n\r\n /**\r\n * Settings\r\n * @return\r\n */\r\n List<GestureHandlerSetting> settings();\r\n\r\n String name();\r\n\r\n int icon();\r\n\r\n}", "@Override\n public void attack() {\n\n }", "@Override\n public void landedOn(Player player) {}", "default void onEnable() {}", "public void onInteract() {\n }", "public void onUaCallRinging(UserAgent ua)\n { \n }", "@Override\n\tpublic void attack() {\n\t}", "public void engage(ScannedRobotEvent e){\r\n setTurnRight(e.getBearing());\r\n setAhead(e.getDistance() + 5);\r\n \r\n //tell where it is heading\r\n fire(1);\r\n }", "@Override\n\tvoid attack() {\n\n\t}", "public void onShake() {\n\t\t\tshake();\n\t\t}", "public void onEnable() {\n }", "public void onEnabled() {\r\n }", "@Override\n\tpublic void attack() {\n\n\t}", "@Override\n\tpublic void attack() {\n\t\t\n\t}", "@Override\r\n\tpublic String work() {\n\t\treturn \"This is a hammer. \";\r\n\t}", "public void on() {\n\t\tSystem.out.println(\"Tuner is on\");\n\n\t}", "@Override\n\tpublic void takeHit(int attack) {\n\n\t}", "@Override\n public void onPourMilkRaised() {\n }", "@Override\n public void onGranted() {\n }", "public void interactWhenSteppingOn() {\r\n\t\t\r\n\t}", "@Override\n public void onGranted() {\n }", "@Override\n public void onGranted() {\n }", "public void startShower(){\n Log.d(LOGTAG,\"Shower is on.\");\n playSound();\n\n\n }", "@Override\n public void onInteract() {\n }", "@Override\n public void touch()\n {\n\n }", "@Override\n\tpublic void earnedTapPoints(int arg0) {\n\t\t\n\t}", "@Override\n\tpublic void on() {\n\t\tSystem.out.println(\"turn on the \"+name+\" Light\");\n\t}", "@Override\n\tpublic void onEnter(Game game) {\n\t\t\n\t}", "@Override\n public void attack(){\n\n }", "void startPumpingEvents();", "@Override\r\n\tpublic void onDragonCalled(Dragon dragon) {\n\t\t\r\n\t}", "void hitEvent(Block beingHit, Ball hitter);", "void hitEvent(Block beingHit, Ball hitter);", "@Override\n\t\tpublic void onShutter() {\n\n\t\t}", "@Override\n\tprotected void onEventComming(EventCenter eventCenter) {\n\t}", "@Override\r\n\tpublic void onPlayerHit(Player p) {\n\r\n\t}", "@Override\n public void onAdLeftApplication() {\n }", "void onActive(GestureMetaData metaData);", "public void takesHit()\n {\n // TODO: replace this line with your code\n }", "@Override\r\n public void fromFearToChase() {\r\n if (afraid()) {\r\n startChase();\r\n }\r\n }", "@Override\n\tpublic void onSmartWallAdShowing() {\n\t\t\n\t}", "@Override\n\t\tpublic void hit(Npc attacker, Mob defender, Hit hit) {\n\t\t}", "@Override\n public void onSingleTap(SKScreenPoint point) {\n\n }", "public void mo5978o() {\n IntentFilter intentFilter = new IntentFilter();\n intentFilter.addAction(\"android.intent.action.SCREEN_OFF\");\n intentFilter.addAction(\"android.intent.action.SCREEN_ON\");\n intentFilter.addAction(\"android.intent.action.USER_PRESENT\");\n if (AppFeature.f5621q) {\n registerReceiver(this.f5428la, intentFilter);\n }\n }", "private void onSwipeTop() {\n\t\t\r\n\t}", "@Override\n\tpublic void onHitPlayer(EntityDamageByEntityEvent e, Player damager, Player victim) {\n\t\t\n\t}", "@Override\r\n\tpublic void onPlayerHit(Player p) {\n\t\t\r\n\t}", "@Override\r\n\tpublic void onPlayerHit(Player p) {\n\t\t\r\n\t}", "@Override\n public void onRewardedVideoAdLeftApplication() {\n\n }", "void onFingerprintEntered();", "void onStarted();", "protected abstract void onPresenter();", "public abstract void touch(long ms);", "@Override\r\n\tpublic void onBlockHit(Block block) {\n\t\t\r\n\t}", "@Override\r\n\tpublic void onBlockHit(Block block) {\n\t\t\r\n\t}", "@Override\r\n\tpublic void onBlockHit(Block block) {\n\t\t\r\n\t}", "@Override\n public void onShakeDetected() {\n LogUtil.e(\"onShakeDetected\");\n }", "void onTurn();", "@Override\n public void beHelpful() {\n this.playPiano();\n this.takeABow();\n }", "@Override\n public void onAdLeftApplication() {\n }", "@Override\n public void onAdLeftApplication() {\n }", "@Override\n public void onAdLeftApplication() {\n }", "public interface C0407a {\n void shakeDetected();\n }", "public abstract void onInput();", "public void on() throws Exception;", "private void shoot() {\n }", "private void shoot() {\n }", "@Override\r\n\tpublic void onEvent(Event arg0) {\n\r\n\t}", "@Override\r\n\t\t\tpublic void broadcast(ID source, ID target, Boolean hit) {\n\t\t\t\t\r\n\t\t\t}", "void ponderhit();", "public abstract void onTrigger();", "@Override\r\n\tpublic void onBlockHit(Block block) {\n\r\n\t}", "@Override\n \t\t\tpublic void onClick(View v) {\n \t\t\t\tLog.d(\"VoMPCall\", \"Hanging up\");\n \t\t\t\tServalBatPhoneApplication.context.servaldMonitor\n \t\t\t\t\t\t.sendMessage(\"hangup \"\n \t\t\t\t\t\t+ Integer.toHexString(local_id));\n \t\t\t}", "public interface AidTouchListener {\n public void start();\n}", "@Override\n\t\t\tpublic void shoot() {\n\t\t\t}", "boolean onGestureStarted();", "@Override\n\tpublic void onHitted(EntityDamageByEntityEvent e, Player damager, Player victim) {\n\t\t\n\t}", "public static void triggerHushMute(Context context) {\n // We can't call AudioService#silenceRingerModeInternal from here, so this is a partial copy of it\n int silenceRingerSetting = Settings.Secure.getIntForUser(context.getContentResolver(),\n Settings.Secure.VOLUME_HUSH_GESTURE, Settings.Secure.VOLUME_HUSH_OFF,\n UserHandle.USER_CURRENT);\n\n int ringerMode;\n int toastText;\n if (silenceRingerSetting == Settings.Secure.VOLUME_HUSH_VIBRATE) {\n ringerMode = AudioManager.RINGER_MODE_VIBRATE;\n toastText = com.android.internal.R.string.volume_dialog_ringer_guidance_vibrate;\n } else {\n // VOLUME_HUSH_MUTE and VOLUME_HUSH_OFF\n ringerMode = AudioManager.RINGER_MODE_SILENT;\n toastText = com.android.internal.R.string.volume_dialog_ringer_guidance_silent;\n }\n AudioManager audioMan = (AudioManager)\n context.getSystemService(Context.AUDIO_SERVICE);\n audioMan.setRingerModeInternal(ringerMode);\n Toast.makeText(context, toastText, Toast.LENGTH_SHORT).show();\n }" ]
[ "0.6352528", "0.6248557", "0.6069833", "0.6012879", "0.60065615", "0.59130853", "0.5751983", "0.5733549", "0.5733549", "0.57287586", "0.57237744", "0.5722005", "0.57173353", "0.57104033", "0.5694957", "0.5655348", "0.56471306", "0.5631378", "0.560581", "0.560581", "0.56047845", "0.5577794", "0.5563189", "0.55511093", "0.55435133", "0.5538252", "0.55380285", "0.5535065", "0.55285954", "0.5526869", "0.55140436", "0.55046684", "0.549566", "0.54848665", "0.54824984", "0.5478472", "0.5476319", "0.54718816", "0.54608035", "0.5459239", "0.54581153", "0.5455976", "0.54554904", "0.5452002", "0.5452002", "0.54506373", "0.5444328", "0.54373056", "0.5435295", "0.5425021", "0.54143935", "0.54132694", "0.54122573", "0.5409296", "0.5408514", "0.5408514", "0.54059094", "0.5405398", "0.54037654", "0.5402459", "0.5396072", "0.53898597", "0.5389826", "0.5386666", "0.53851736", "0.53844935", "0.5381863", "0.53733957", "0.5371405", "0.53547454", "0.53547454", "0.5348777", "0.53469354", "0.534409", "0.53403854", "0.5336122", "0.5333351", "0.5333351", "0.5333351", "0.53305006", "0.5328592", "0.5324394", "0.53228194", "0.53228194", "0.53228194", "0.5320887", "0.53199136", "0.5317219", "0.53128856", "0.53128856", "0.5311116", "0.531078", "0.5310083", "0.5306772", "0.5302001", "0.5296543", "0.5285883", "0.528469", "0.5284348", "0.5283757", "0.52799594" ]
0.0
-1
Returns a Pattern that adds a grace note to a given note. This method assumes a 32nd sound duration for the grace note.
public static PatternInterface graceNote(Note graceNote, Note baseNote){ return graceNote(graceNote, baseNote, THIRTY_SECOND); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static PatternInterface graceNote(Note graceNote, Note baseNote, double graceNoteDuration){\r\n \tPattern gracePattern = new Pattern(graceNote.getMusicString());\r\n \treturn addOrnament(gracePattern, baseNote, graceNoteDuration);\r\n }", "public static Note createNote(int value, int startBeat, int endBeat) {\n return createNote((value / 12) - 1, Pitch.getPitch(value % 12), startBeat, endBeat);\n }", "public Note(char n, int dur) {\n\t\tnote = n;\n\t\tduration = dur;\n\t}", "void addNote(int duration, int octave, int beatNum, String pitch)\n throws IllegalArgumentException;", "public Note noteAt(int interval) {\n\t\tint newMidiNote = getMidiNumber() + interval;\n\t\t\n\t\treturn new Note(newMidiNote);\n\t}", "public static PatternInterface trill(Note baseNote, char trillDirection, double singleSoundDuration){\r\n \r\n \tStringBuilder musicStringBuilder = new StringBuilder();\r\n \r\n \tdouble totalDuration = baseNote.getDecimalDuration();\r\n double actualDuration = 0.0d;\r\n \r\n byte secondNote = baseNote.getValue();\r\n \r\n if(trillDirection == EFFECT_DIRECTION_UP){\r\n \tsecondNote++;\r\n } else if(trillDirection == EFFECT_DIRECTION_DOWN){\r\n \tsecondNote--;\r\n }\r\n \r\n double remainingDuration = totalDuration - (2*singleSoundDuration);\r\n if(remainingDuration > 0.0d){\r\n \t\r\n \tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \tactualDuration+=singleSoundDuration;\r\n \t\r\n \twhile(actualDuration < totalDuration){\r\n \t\tif(actualDuration + (2*singleSoundDuration) < totalDuration){\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, secondNote, singleSoundDuration);\r\n \t\t\tactualDuration += singleSoundDuration;\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \t\t\tactualDuration += singleSoundDuration;\r\n \t\t} else if(actualDuration + singleSoundDuration > totalDuration){\r\n \t\t\tdouble gapDuration = totalDuration - actualDuration;\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), gapDuration);\r\n \t\t\tactualDuration+=gapDuration;\r\n \t\t} else {\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \t\t\tactualDuration+=singleSoundDuration;\r\n \t\t}\r\n \t}\r\n \treturn new Pattern(musicStringBuilder.toString().trim());\r\n } else {\r\n \treturn new Pattern(baseNote.getMusicString());\r\n }\r\n }", "public static Note createNote(int octave, Pitch pitch, int startBeat, int endBeat) {\n return new NoteImpl(octave, pitch, startBeat, endBeat);\n }", "CompositionBuilder<T> addNote(int start, int end, int instrument, int pitch, int volume);", "void addNote(int duration, int octave, int beatNum, int instrument, int volume, String pitch)\n throws IllegalArgumentException;", "public static Note createNote(int value, int startBeat, int endBeat, int instrument, int\n volume) {\n return createNote((value / 12) - 1, Pitch.getPitch(value % 12), startBeat, endBeat, instrument,\n volume);\n }", "public void sequentialNoteEvent(Note note)\r\n {\r\n byte noteValue = note.getValue();\r\n if (voiceValue != 9) // added D G Gray 5th Feb 2017\r\n {\r\n noteValue += this.interval;\r\n note.setValue(noteValue);\r\n\t }\r\n\r\n\r\n getReturnPattern().addElement(note);\r\n }", "void addRepeat(int beatNum, RepeatType repeatType);", "public static Note createNote(int octave, Pitch pitch, int startBeat, int endBeat, int\n instrument, int volume) {\n return new NoteImpl(octave, pitch, startBeat, endBeat, instrument, volume);\n }", "String getDelayPattern();", "public Note(int _pitch, int _duration, int _dynamic) {\n pitch = _pitch;\n duration = _duration;\n dynamic = _dynamic;\n tiedIn = false;\n tiedOut = false;\n displayDynamic = false;\n }", "public void noteEvent(Note note)\r\n {\r\n byte noteValue = note.getValue();\r\n if (voiceValue != 9) // added D G Gray 5th Feb 2017\r\n {\r\n noteValue += this.interval;\r\n note.setValue(noteValue);\r\n\t }\r\n\r\n getReturnPattern().addElement(note);\r\n }", "public static Note makeNote(int pitch, int octave) {\n if (octave < 0) {\n throw new IllegalArgumentException(\"Invalid octave parameter!\");\n }\n return new Note(Pitch.makePitch(pitch),octave,0);\n }", "INote removeNote(int beatNum, String pitch, int octave) throws IllegalArgumentException;", "public SoundEffect adjust(float volume, float pitch) {\n \t\treturn new SoundEffect(this, volume, pitch);\n \t}", "public static PatternInterface slide(Note note1, Note note2, double duration, int numSteps)\r\n {\r\n StringBuilder buddy = new StringBuilder();\r\n double durationPerStep = duration / numSteps;\r\n double freq1 = Note.getFrequencyForNote(note1.getValue());\r\n double freq2 = Note.getFrequencyForNote(note2.getValue());\r\n double differencePerStep = (freq2-freq1) / numSteps;\r\n\r\n for (int i=0; i < numSteps; i++)\r\n {\r\n buddy.append(MicrotoneNotation.convertFrequencyToMusicString(freq1));\r\n buddy.append(\"/\");\r\n buddy.append(durationPerStep);\r\n buddy.append(MicrotoneNotation.getResetPitchWheelString());\r\n buddy.append(\" \");\r\n freq1 += differencePerStep;\r\n }\r\n\r\n PatternInterface pattern = new Pattern(buddy.toString());\r\n return pattern;\r\n }", "public void playSong() {\n\t\t// Initialize\n\t\tint num = 1;\n\n\t\t// Get the notes to be played from the entryBox\n\t\tString notesString = \"V0 \" + instrumentType + \" \" + entryBox.getText();\n\n\t\t// Create a new rhythm object\n\t\tRhythm rhythm = new Rhythm();\n\n\t\t// Get the rhythm strings from the rhythm entry boxes\n\t\tString rhythmLayer1 = \"V1 \" + rhythm1.getText();\n\t\tString rhythmLayer2 = \"V2 \" + rhythm2.getText();\n\n\t\t// Set the strings to layers\n\t\trhythm.setLayer(1, rhythmLayer1);\n\t\trhythm.setLayer(2, rhythmLayer2);\n\n\t\t// Add the appropriate substitutions\n\t\trhythm.addSubstitution('O', \"[BASS_DRUM]i\");\n\t\trhythm.addSubstitution('o', \"Rs [BASS_DRUM]s\");\n\t\trhythm.addSubstitution('*', \"[ACOUSTIC_SNARE]i\");\n\t\trhythm.addSubstitution('^', \"[PEDAL_HI_HAT]s Rs\");\n\t\trhythm.addSubstitution('!', \"[CRASH_CYMBAL_1]s Rs\");\n\t\trhythm.addSubstitution('.', \"Ri\");\n\n\t\t// Get the rhythm pattern\n\t\tPattern rhythmPattern = rhythm.getPattern();\n\n\t\t// Get how many times the song should repeat\n\t\tString repeatNum = repeatNumber.getText();\n\t\tnum = Integer.parseInt(repeatNum);\n\n\t\t// Get the playback tempo\n\t\tString playTempo = \"T[\" + tempo.getText() + \"] \";\n\n\t\t// Create the song\n\t\tPattern song = new Pattern();\n\t\tsong.add(rhythmPattern);\n\t\tsong.add(notesString);\n\t\tsong.repeat(num);\n\n\t\t// Play the song\n\t\tplayer.play(playTempo + song);\n\n\t}", "public void addNote()\n {\n String stringNote;\n char actualNote;\n int beat;\n \n System.out.print(\"Enter the note > \"); //gets the note from user\n stringNote = in.nextLine();\n actualNote = stringNote.charAt(0);\n \n System.out.print(\"Enter the length of the note in beats > \"); //gets the beats from user\n beat = in.nextInt();\n \n Note note = new Note(actualNote, beat); //creates Note to be added\n \n score.add(note); //adds the note to the score\n \n in.nextLine();\n }", "public static PatternInterface addOrnament(Pattern ornament, Note baseNote, double longestOrnamentDuration){\r\n \tPatternInvestigator investigator = new PatternInvestigator();\r\n \tMusicStringParser stringParser = new MusicStringParser();\r\n \t\r\n \tstringParser.addParserListener(investigator);\r\n \tstringParser.parse(ornament);\r\n \t\r\n \tdouble longestDuration = investigator.getLongestDecimalDuration();\r\n \tdouble durationChange = longestOrnamentDuration / longestDuration;\r\n \t\r\n \tDurationPatternTransformer transformer = new DurationPatternTransformer(durationChange);\r\n \t\r\n \tPatternInterface result = transformer.transform(ornament);\r\n \t\r\n \tstringParser.removeParserListener(investigator);\r\n \tinvestigator = new PatternInvestigator();\r\n \tstringParser.addParserListener(investigator);\r\n \tstringParser.parse(result);\r\n \t\r\n \tif(investigator.getTotalDecimalDuration() < baseNote.getDecimalDuration()){\r\n \t\tdouble remainingDuration = baseNote.getDecimalDuration() - investigator.getTotalDecimalDuration();\r\n \t\tbaseNote.setDecimalDuration(remainingDuration);\r\n \t\tresult.add(baseNote.getMusicString());\r\n \t\treturn result;\r\n \t} else {\r\n \t\treturn new Pattern(baseNote.getMusicString());\r\n \t}\r\n }", "@Override\n public void addNote(int startTime, int duration, Pitch pitch, Octave octave) {\n List<Note> notes = new ArrayList<>();\n Note newNote = new SimpleNote(pitch, octave, startTime, duration);\n notes.add(newNote);\n\n if (this.notes.get(startTime) == null) {\n this.notes.put(startTime, notes);\n } else {\n List<Note> oldList = this.notes.remove(startTime);\n oldList.addAll(notes);\n this.notes.put(startTime, oldList);\n }\n\n }", "public Rational getRawDuration ()\r\n {\r\n Rational rawDuration = null;\r\n\r\n if (!getNotes().isEmpty()) {\r\n // All note heads are assumed to be the same within one chord\r\n Note note = (Note) getNotes().get(0);\r\n\r\n if (!note.getShape().isMeasureRest()) {\r\n // Duration (with flags/beams applied for non-rests)\r\n rawDuration = note.getNoteDuration();\r\n\r\n // Apply augmentation (applies to rests as well)\r\n if (dotsNumber == 1) {\r\n rawDuration = rawDuration.times(new Rational(3, 2));\r\n } else if (dotsNumber == 2) {\r\n rawDuration = rawDuration.times(new Rational(7, 4));\r\n }\r\n }\r\n }\r\n\r\n return rawDuration;\r\n }", "public NoteDuration getNoteDuration(int duration)\n\t{\n\t\tint whole = quarternote * 4;\n\t\t//\t\t 1 = 32/32\n\t\t//\t\t 3/4 = 24/32\n\t\t//\t\t 1/2 = 16/32\n\t\t//\t\t 3/8 = 12/32\n\t\t//\t\t 1/4 = 8/32\n\t\t//\t\t 3/16 = 6/32\n\t\t//\t\t 1/8 = 4/32 = 8/64\n\t\t//\t\t triplet = 5.33/64\n\t\t//\t\t 1/16 = 2/32 = 4/64\n\t\t//\t\t 1/32 = 1/32 = 2/64\n\n\t\tif (duration >= 28 * whole / 32)\n\t\t return NoteDuration.Whole;\n\t\telse if (duration >= 20 * whole / 32)\n\t\t return NoteDuration.DottedHalf;\n\t\telse if (duration >= 14 * whole / 32)\n\t\t return NoteDuration.Half;\n\t\telse if (duration >= 10 * whole / 32)\n\t\t return NoteDuration.DottedQuarter;\n\t\telse if (duration >= 7 * whole / 32)\n\t\t return NoteDuration.Quarter;\n\t\telse if (duration >= 5 * whole / 32)\n\t\t return NoteDuration.DottedEighth;\n\t\telse if (duration >= 6 * whole / 64)\n\t\t return NoteDuration.Eighth;\n\t\telse if (duration >= 5 * whole / 64)\n\t\t return NoteDuration.Triplet;\n\t\telse if (duration >= 3 * whole / 64)\n\t\t return NoteDuration.Sixteenth;\n\t\telse if (duration >= 2 * whole / 64)\n\t\t return NoteDuration.ThirtySecond;\n\t\telse if (duration >= whole / 64)\n\t\t return NoteDuration.SixtyFour; // TODO : EXTEND UNTIL 1/128 to be able to extract the onset in SYMBOLIC representation\n\t\telse if (duration >= whole / 128)\n\t\t return NoteDuration.HundredTwentyEight;\n\t\telse\n\t\t return NoteDuration.ZERO;\n\t}", "Note getBukkitNote();", "@Override\n public void addNote(Note n) {\n if (this.sheet.size() < n.getDuration() + n.getStartMeasure()) {\n for (int i = this.sheet.size(); i < n.getDuration() + n.getStartMeasure(); i++) {\n sheet.add(new HashSet<>());\n }\n }\n for (int i = 0; i < n.getDuration(); i++) {\n for (Note t : this.sheet.get(i + n.getStartMeasure())) {\n if (t.equals(n)) {\n throw new IllegalArgumentException(\"Already placed a note.\");\n }\n }\n }\n this.sheet.get(n.getStartMeasure()).add(n);\n int currentMeasure = n.getStartMeasure() + 1;\n for (int i = 1; i < n.getDuration(); i++) {\n Note hold = new Note(1, n.getOctave(), currentMeasure,\n n.getPitch(), false, n.getInstrument(), n.getVolume());\n this.sheet.get(currentMeasure).add(hold);\n currentMeasure++;\n }\n\n this.high = this.getHighest();\n this.low = this.getLowest();\n }", "public Note(int noteNumber, int instrument) {\n this.octave = (noteNumber / 12) - 1;\n this.pitch = Pitch.pitchFromNumber(noteNumber - (this.octave * 12));\n this.instrument = instrument;\n }", "@Override\n public void mutate(Song song, int noteIndex) {\n if (Math.random() < this.getProbability()) {\n if (noteIndex > 0) {\n MidiUtil mu = new MidiUtil();\n int nbrOfTotalReversing = nbrOfAdditionalReversing + 1\n + ((int) Math.random() * nbrRange);\n ArrayList<Integer> noteIndexes = new ArrayList<Integer>();\n ArrayList<Note> notes = new ArrayList<Note>();\n noteIndexes.add(noteIndex);\n notes.add(song.getScore().getPart(0).getPhrase(0)\n .getNote(noteIndex));\n int currentIndex = noteIndex - 1;\n noteIteration: for (int i = 1; i < nbrOfTotalReversing; i++) {\n while (mu.isBlank(currentIndex) && currentIndex >= 0) {\n currentIndex--;\n }\n if (currentIndex < 0) {\n break noteIteration;\n } else {\n noteIndexes.add(currentIndex);\n notes.add(song.getScore().getPart(0).getPhrase(0)\n .getNote(currentIndex));\n }\n }\n int totalReverses = noteIndexes.size();\n for (int j = 0; j < noteIndexes.size(); j++) {\n if (withRhythmLength) {\n song.getScore()\n .getPart(0)\n .getPhrase(0)\n .setNote(notes.get(totalReverses - 1 - j),\n noteIndexes.get(j));\n } else {\n int newPitch = notes.get(totalReverses - 1 - j)\n .getPitch();\n song.getScore().getPart(0).getPhrase(0)\n .getNote(noteIndexes.get(j)).setPitch(newPitch);\n }\n }\n }\n }\n }", "@Override\n public Pattern createPattern(Image image, String repeat) {\n return new Pattern(image, repeat);\n }", "@Override\n\tpublic RecurrenceRule newRecurrence(String frequency, int interval) {\n\t\treturn null;\n\t}", "public Note(int note, char accidental, Pane notePane) {\n _note = note;\n _accidental = accidental;\n _accidentalImage = new ImageView();\n this.setUpLedger();\n this.setUpNote();\n }", "@Override\n\tpublic RecurrenceRule newRecurrence(String frequency) {\n\t\treturn null;\n\t}", "@Override\n\tpublic RecurrenceRule newRecurrence(String frequency, int interval,\n\t\t\tint count) {\n\t\treturn null;\n\t}", "public final void rule__ChordParams__Alternatives_1_1() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:758:1: ( ( ruleNote ) | ( ( rule__ChordParams__CnotesAssignment_1_1_1 ) ) )\n int alt5=2;\n alt5 = dfa5.predict(input);\n switch (alt5) {\n case 1 :\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:759:1: ( ruleNote )\n {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:759:1: ( ruleNote )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:760:1: ruleNote\n {\n before(grammarAccess.getChordParamsAccess().getNoteParserRuleCall_1_1_0()); \n pushFollow(FOLLOW_ruleNote_in_rule__ChordParams__Alternatives_1_11605);\n ruleNote();\n\n state._fsp--;\n\n after(grammarAccess.getChordParamsAccess().getNoteParserRuleCall_1_1_0()); \n\n }\n\n\n }\n break;\n case 2 :\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:765:6: ( ( rule__ChordParams__CnotesAssignment_1_1_1 ) )\n {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:765:6: ( ( rule__ChordParams__CnotesAssignment_1_1_1 ) )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:766:1: ( rule__ChordParams__CnotesAssignment_1_1_1 )\n {\n before(grammarAccess.getChordParamsAccess().getCnotesAssignment_1_1_1()); \n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:767:1: ( rule__ChordParams__CnotesAssignment_1_1_1 )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:767:2: rule__ChordParams__CnotesAssignment_1_1_1\n {\n pushFollow(FOLLOW_rule__ChordParams__CnotesAssignment_1_1_1_in_rule__ChordParams__Alternatives_1_11622);\n rule__ChordParams__CnotesAssignment_1_1_1();\n\n state._fsp--;\n\n\n }\n\n after(grammarAccess.getChordParamsAccess().getCnotesAssignment_1_1_1()); \n\n }\n\n\n }\n break;\n\n }\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "void note(float start, float duration, float freq){\n\t out.playNote(start,duration,freq); \n\t }", "@Override\n public CompositionBuilder<MusicOperation> addNote(int start, int end, int instrument,\n int pitch, int volume) {\n this.listNotes.add(new SimpleNote(Pitch.values()[(pitch) % 12],\n Octave.values()[(pitch / 12) - 2 ], start, end - start, instrument, volume));\n return this;\n }", "public Note(int duration, int offset, int pitch, int channel, int velocity) {\n this.duration = duration;\n this.offset = offset;\n this.pitch = pitch;\n this.channel = channel;\n this.velocity = velocity;\n }", "public final void rule__ChordParams__Alternatives_0() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:736:1: ( ( ruleNote ) | ( ruleCustomNote ) )\n int alt4=2;\n alt4 = dfa4.predict(input);\n switch (alt4) {\n case 1 :\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:737:1: ( ruleNote )\n {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:737:1: ( ruleNote )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:738:1: ruleNote\n {\n before(grammarAccess.getChordParamsAccess().getNoteParserRuleCall_0_0()); \n pushFollow(FOLLOW_ruleNote_in_rule__ChordParams__Alternatives_01556);\n ruleNote();\n\n state._fsp--;\n\n after(grammarAccess.getChordParamsAccess().getNoteParserRuleCall_0_0()); \n\n }\n\n\n }\n break;\n case 2 :\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:743:6: ( ruleCustomNote )\n {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:743:6: ( ruleCustomNote )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:744:1: ruleCustomNote\n {\n before(grammarAccess.getChordParamsAccess().getCustomNoteParserRuleCall_0_1()); \n pushFollow(FOLLOW_ruleCustomNote_in_rule__ChordParams__Alternatives_01573);\n ruleCustomNote();\n\n state._fsp--;\n\n after(grammarAccess.getChordParamsAccess().getCustomNoteParserRuleCall_0_1()); \n\n }\n\n\n }\n break;\n\n }\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "public XSSFPatternFormatting createPatternFormatting(){\n CTDxf dxf = getDxf(true);\n CTFill fill;\n if(!dxf.isSetFill()) {\n fill = dxf.addNewFill();\n } else {\n fill = dxf.getFill();\n }\n\n return new XSSFPatternFormatting(fill, _sh.getWorkbook().getStylesSource().getIndexedColors());\n }", "private int getWhatSoundThatShouldBePlayed(int gapAmountOfSeconds){\n\n if(gapAmountOfSeconds > 0 && !notifiedUnderPace ){\n notifiedUnderPace = true;\n return 3;\n }\n if (gapAmountOfSeconds >= AMOUNT_OF_SECONDS_WHEN_TRIGGERING_NOTIFICATION && gapAmountOfSeconds <= 0){\n if (gapAmountOfSeconds >= AMOUNT_OF_SECONDS_WHEN_TRIGGERING_NOTIFICATION/2 && gapAmountOfSeconds <= 0){\n return 2;\n }\n notifiedUnderPace = false;\n return 1;\n }\n\n\n return 0;\n }", "public void generateTone()\n throws LineUnavailableException {\n if ( clip!=null ) {\n clip.stop();\n clip.close();\n } else {\n clip = AudioSystem.getClip();\n }\n boolean addHarmonic = harmonic.isSelected();\n\n int intSR = ((Integer)sampleRate.getSelectedItem()).intValue();\n int intFPW = framesPerWavelength.getValue();\n\n float sampleRate = (float)intSR;\n\n // oddly, the sound does not loop well for less than\n // around 5 or so, wavelengths\n int wavelengths = 20;\n byte[] buf = new byte[2*intFPW*wavelengths];\n AudioFormat af = new AudioFormat(\n sampleRate,\n 8, // sample size in bits\n 2, // channels\n true, // signed\n false // bigendian\n );\n\n int maxVol = 127;\n for(int i=0; i<intFPW*wavelengths; i++){\n double angle = ((float)(i*2)/((float)intFPW))*(Math.PI);\n buf[i*2]=getByteValue(angle);\n if(addHarmonic) {\n buf[(i*2)+1]=getByteValue(2*angle);\n } else {\n buf[(i*2)+1] = buf[i*2];\n }\n }\n\n try {\n byte[] b = buf;\n AudioInputStream ais = new AudioInputStream(\n new ByteArrayInputStream(b),\n af,\n buf.length/2 );\n\n clip.open( ais );\n } catch(Exception e) {\n e.printStackTrace();\n }\n }", "public Note(int midiNumber) {\n\t\tthis.noteName = NoteName.C.noteAt(midiNumber);\n\t\tthis.octave = midiNumber / OCTAVE_LENGTH;\n\t\tthis.midiNumber = midiNumber;\n\t}", "public Note(Pitch pitch, int octave, int instrument) {\n if (octave < 0 || octave > 10) {\n throw new IllegalArgumentException(\"octave must be between 0 and 10 (inclusive)\");\n }\n\n this.pitch = pitch;\n this.octave = octave;\n this.instrument = instrument;\n }", "public static Note getNoteFromID(int id, Shift prefShift) {\n\t\tint shiftNum = prefShift.getShiftID();\n\n\t\tint octave = (id / 12) - 1;\n\t\tint toneMod = (id - shiftNum + 12) % 12;\n\n\t\tTone tone = Tone.notes.get(toneMod);\n\t\tint shiftID = shiftNum + 2;\n\n\t\tif (tone == null) {\n\t\t\tif (shiftNum <= 0) {\n\t\t\t\ttone = Tone.notes.get((toneMod + 11) % 12);\n\t\t\t\tshiftID++;\n\t\t\t} else {\n\t\t\t\ttone = Tone.notes.get((toneMod + 1) % 12);\n\t\t\t\tshiftID--;\n\t\t\t}\n\t\t}\n\n\t\tNote note = new Note(tone, Shift.shifts.get(shiftID), octave);\n\t\treturn note;\n\t}", "int getRecurrenceDuration();", "public static PatternInterface trill(Note baseNote){\r\n \treturn trill(baseNote, EFFECT_DIRECTION_UP);\r\n }", "void crear(Tonelaje tonelaje);", "public SoundEffect randomPitch(float amount) {\n \t\treturn new RandomPitchSoundEffect(this, amount);\n \t}", "@Override\n\tpublic RecurrenceRule newRecurrence(String frequency, int interval,\n\t\t\tTime until) {\n\t\treturn null;\n\t}", "@Nonnull\n public static UBL23WriterBuilder <CreditNoteType> creditNote ()\n {\n return UBL23WriterBuilder.create (CreditNoteType.class);\n }", "public FormatInteger asteriskFill(){\n fillCharacter = ASTERISK_CHAR;\n return this;\n }", "public Piano(int numNotes){\n pStrings = new InstString[numNotes][3];\n for(int a = 0; a < numNotes; a++){\n double freq = 440 * Math.pow(2, (double)(a-24)/(double)12);\n pStrings[a][0] = new GuitarString(freq);\n pStrings[a][1] = new GuitarString(freq + .45);\n pStrings[a][2] = new GuitarString(freq - .45);\n }\n }", "public static PatternInterface trill(Note baseNote, char trillDirection){\r\n \treturn trill(baseNote, trillDirection, THIRTY_SECOND);\r\n }", "public static Note add(final Note noteToAdd) {\n try {\r\n // Simulate time for network request.\r\n Thread.sleep(5000);\r\n } catch (Exception e) {\r\n // Just for test purposes so handling error doesn't matter.\r\n }\r\n noteToAdd.setId(4);\r\n return noteToAdd;\r\n }", "public static PatternInterface hammerOn(Note note1, Note note2, double duration, int numHammers)\r\n {\r\n StringBuilder buddy = new StringBuilder();\r\n double durationPerHammer = duration / numHammers;\r\n buddy.append(\"[\");\r\n buddy.append(note1.getValue());\r\n buddy.append(\"]/\");\r\n buddy.append(durationPerHammer / 2.0);\r\n buddy.append(\" [\");\r\n buddy.append(note2.getValue());\r\n buddy.append(\"]/\");\r\n buddy.append(durationPerHammer / 2.0);\r\n\r\n PatternInterface pattern = new Pattern(buddy.toString());\r\n pattern.repeat(numHammers);\r\n return pattern;\r\n }", "public final void rule__ChordParams__CnotesAssignment_1_1_1() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:3839:1: ( ( ruleCustomNote ) )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:3840:1: ( ruleCustomNote )\n {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:3840:1: ( ruleCustomNote )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:3841:1: ruleCustomNote\n {\n before(grammarAccess.getChordParamsAccess().getCnotesCustomNoteParserRuleCall_1_1_1_0()); \n pushFollow(FOLLOW_ruleCustomNote_in_rule__ChordParams__CnotesAssignment_1_1_17757);\n ruleCustomNote();\n\n state._fsp--;\n\n after(grammarAccess.getChordParamsAccess().getCnotesCustomNoteParserRuleCall_1_1_1_0()); \n\n }\n\n\n }\n\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "public abstract void newSpeechNoise(long ms, int n);", "public void parallelNoteEvent(Note note)\r\n {\r\n byte noteValue = note.getValue();\r\n if (voiceValue != 9) // added D G Gray 5th Feb 2017\r\n {\r\n noteValue += this.interval;\r\n note.setValue(noteValue);\r\n\t }\r\n\r\n\r\n getReturnPattern().addElement(note);\r\n }", "public static String convertNotation(String note){\n\t\tif(note.length() != 1){\n\t\t\tString temp = note.substring(0,1);\n\t\t\tif(note.substring(1, 2).equals(\"#\")){\n\t\t\t\tnote = noteDictionary[findInDict(temp) + 1];\n\t\t\t}\n\t\t\telse if(note.substring(1, 2).equals(\"b\")){\n\t\t\t\tnote = noteDictionary[findInDict(temp) - 1];\n\t\t\t}\n\t\t}\n\t\treturn note;\n\t}", "public Note() {\n\t\tsuper();\n\t}", "private void updateMatchType(MidiNote note) {\n\t\tList<Beat> beats = beatState.getBeats();\n\t\tBeat startBeat = note.getOnsetBeat(beats);\n\t\tBeat endBeat = note.getOffsetBeat(beats);\n\t\t\n\t\tint tactiPerMeasure = beatState.getTactiPerMeasure();\n\t\t\n\t\tint startTactus = getTactusNormalized(tactiPerMeasure, beats.get(0), startBeat.getMeasure(), startBeat.getBeat());\n\t\tint endTactus = getTactusNormalized(tactiPerMeasure, beats.get(0), endBeat.getMeasure(), endBeat.getBeat());\n\t\t\n\t\tint noteLengthTacti = Math.max(1, endTactus - startTactus);\n\t\tstartTactus -= anacrusisLength * subBeatLength;\n\t\tendTactus = startTactus + noteLengthTacti;\n\t\t\n\t\tint prefixStart = startTactus;\n\t\tint middleStart = startTactus;\n\t\tint postfixStart = endTactus;\n\t\t\n\t\tint prefixLength = 0;\n\t\tint middleLength = noteLengthTacti;\n\t\tint postfixLength = 0;\n\t\t\n\t\tint beatLength = subBeatLength * measure.getSubBeatsPerBeat();\n\t\t\n\t\t// Reinterpret note given matched levels\n\t\tif (matches(MetricalLpcfgMatch.SUB_BEAT) && startTactus / subBeatLength != (endTactus - 1) / subBeatLength) {\n\t\t\t// Interpret note as sub beats\n\t\t\t\n\t\t\tint subBeatOffset = startTactus % subBeatLength;\n\t\t\tint subBeatEndOffset = endTactus % subBeatLength;\n\t\t\t\n\t\t\t// Prefix\n\t\t\tif (subBeatOffset != 0) {\n\t\t\t\tprefixLength = subBeatLength - subBeatOffset;\n\t\t\t}\n\t\t\t\n\t\t\t// Middle fix\n\t\t\tmiddleStart += prefixLength;\n\t\t\tmiddleLength -= prefixLength;\n\t\t\t\n\t\t\t// Postfix\n\t\t\tpostfixStart -= subBeatEndOffset;\n\t\t\tpostfixLength += subBeatEndOffset;\n\t\t\t\n\t\t\t// Middle fix\n\t\t\tmiddleLength -= postfixLength;\n\t\t\t\n\t\t} else if (matches(MetricalLpcfgMatch.BEAT) && startTactus / beatLength != (endTactus - 1) / beatLength) {\n\t\t\t// Interpret note as beats\n\t\t\t\n\t\t\t// Add up possible partial beat at the start\n\t\t\tif (anacrusisLength % measure.getSubBeatsPerBeat() != 0) {\n\t\t\t\tint diff = subBeatLength * (measure.getSubBeatsPerBeat() - (anacrusisLength % measure.getSubBeatsPerBeat()));\n\t\t\t\tstartTactus += diff;\n\t\t\t\tendTactus += diff;\n\t\t\t}\n\t\t\tint beatOffset = (startTactus + subBeatLength * (anacrusisLength % measure.getSubBeatsPerBeat())) % beatLength;\n\t\t\tint beatEndOffset = (endTactus + subBeatLength * (anacrusisLength % measure.getSubBeatsPerBeat())) % beatLength;\n\t\t\t\n\t\t\t// Prefix\n\t\t\tif (beatOffset != 0) {\n\t\t\t\tprefixLength = beatLength - beatOffset;\n\t\t\t}\n\t\t\t\n\t\t\t// Middle fix\n\t\t\tmiddleStart += prefixLength;\n\t\t\tmiddleLength -= prefixLength;\n\t\t\t\n\t\t\t// Postfix\n\t\t\tpostfixStart -= beatEndOffset;\n\t\t\tpostfixLength += beatEndOffset;\n\t\t\t\n\t\t\t// Middle fix\n\t\t\tmiddleLength -= postfixLength;\n\t\t}\n\t\t\n\t\t// Prefix checking\n\t\tif (prefixLength != 0) {\n\t\t\tupdateMatchType(prefixStart, prefixLength);\n\t\t}\n\t\t\n\t\t// Middle checking\n\t\tif (!isFullyMatched() && !isWrong() && middleLength != 0) {\n\t\t\tupdateMatchType(middleStart, middleLength);\n\t\t}\n\t\t\n\t\t// Postfix checking\n\t\tif (!isFullyMatched() && !isWrong() && postfixLength != 0) {\n\t\t\tupdateMatchType(postfixStart, postfixLength);\n\t\t}\n\t}", "private NotePad() {\n }", "public Note() {\n //uig = new UniqueIdGenerator();\n noteId = UUIDGenerator.getUUID();\n created_on = new Date();\n }", "QuoteNote createQuoteNote();", "public static PatternInterface addOrnament(Pattern ornament, Note baseNote){\r\n \treturn addOrnament(ornament, baseNote, THIRTY_SECOND);\r\n }", "@SuppressWarnings(\"deprecation\")\n\tprivate Notification makeNotification(){\n \tNotification notice = new Notification(R.drawable.ic_action_about, \n \t\t\tgetString(R.string.notice_ticker), System.currentTimeMillis());\n \tnotice.setLatestEventInfo(this, getString(R.string.notice_title), getString(R.string.notice_content), \n \t\t\tPendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class).\n \t\t\t\t\tsetFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP), 0));\n\n \tnotice.flags |= Notification.FLAG_NO_CLEAR;\n \t\n \treturn notice;\n\n }", "public final void ruleNote() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:521:2: ( ( ( rule__Note__Group__0 ) ) )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:522:1: ( ( rule__Note__Group__0 ) )\n {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:522:1: ( ( rule__Note__Group__0 ) )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:523:1: ( rule__Note__Group__0 )\n {\n before(grammarAccess.getNoteAccess().getGroup()); \n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:524:1: ( rule__Note__Group__0 )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:524:2: rule__Note__Group__0\n {\n pushFollow(FOLLOW_rule__Note__Group__0_in_ruleNote1053);\n rule__Note__Group__0();\n\n state._fsp--;\n\n\n }\n\n after(grammarAccess.getNoteAccess().getGroup()); \n\n }\n\n\n }\n\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "private Pitch(String note)\n {\n this.note = note;\n }", "private VibrationEffect getVibrationEffect() {\n return VibrationEffect.startComposition()\n .addPrimitive(VibrationEffect.Composition.PRIMITIVE_THUD, 1.0f, 50)\n .compose();\n }", "@Override\n\tpublic String toString() {\n\t\treturn note + \" \" + duration + (duration == 1 ? \" Quaver\" : \" Crotchet\");\n\t}", "public static int nextNote(int n1,int n2) {\n double rnd,sum=0;\n rnd=Math.random();\n for(int i=0;i<12;i++)\n {\n sum+=weights[n1-60][n2-60][i];\n\n if(rnd<=sum)\n return i+60;\n }\n return 62;\n }", "public GIFMaker withDelay(int delay);", "IPatternSequencer getSequencer();", "private void loveYourz()\n {\n Song loveYourz = new Song();\n loveYourz.add(new Note(noteD4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteG3, 0));\n loveYourz.add(new Note(noteDS3, 0));\n loveYourz.add(new Note(noteC2, 0));\n loveYourz.add(new Note(noteC1, WHOLE_NOTE/2));\n\n loveYourz.add(new Note(noteD4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteG3, 0));\n loveYourz.add(new Note(noteDS3, 0));\n loveYourz.add(new Note(noteC2, 0));\n loveYourz.add(new Note(noteC1, WHOLE_NOTE/4));\n\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteG3, 0));\n loveYourz.add(new Note(noteDS2, 0));\n loveYourz.add(new Note(noteDS1, WHOLE_NOTE/4));\n\n\n loveYourz.add(new Note(noteG4, 0));\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteC4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/2));\n\n loveYourz.add(new Note(noteG4, 0));\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteC4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/8));\n\n loveYourz.add(new Note(noteF4, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/8));\n\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/8));\n\n loveYourz.add(new Note(noteD4, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/8));\n\n\n loveYourz.add(new Note(noteD4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteG3, 0));\n loveYourz.add(new Note(noteDS3, 0));\n loveYourz.add(new Note(noteC2, 0));\n loveYourz.add(new Note(noteC1, WHOLE_NOTE/2));\n\n loveYourz.add(new Note(noteD4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteG3, 0));\n loveYourz.add(new Note(noteDS3, 0));\n loveYourz.add(new Note(noteC2, 0));\n loveYourz.add(new Note(noteC1, WHOLE_NOTE/4));\n\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteG3, 0));\n loveYourz.add(new Note(noteDS2, 0));\n loveYourz.add(new Note(noteDS1, WHOLE_NOTE/4));\n\n\n loveYourz.add(new Note(noteG4, 0));\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteC4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/2));\n\n loveYourz.add(new Note(noteG4, 0));\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteC4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/4));\n\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/4));\n playSong(loveYourz);\n playSong(loveYourz);\n }", "long getRepeatIntervalPref();", "public static Notes getInstance(PresentationNotesElement noteElement) {\n\t\tPresentationDocument ownerDocument = (PresentationDocument) ((OdfFileDom) (noteElement.getOwnerDocument()))\n\t\t\t\t.getDocument();\n\t\treturn ownerDocument.getNotesBuilder().getNotesInstance(noteElement);\n\n\t}", "public org.landxml.schema.landXML11.FieldNoteDocument.FieldNote addNewFieldNote()\r\n {\r\n synchronized (monitor())\r\n {\r\n check_orphaned();\r\n org.landxml.schema.landXML11.FieldNoteDocument.FieldNote target = null;\r\n target = (org.landxml.schema.landXML11.FieldNoteDocument.FieldNote)get_store().add_element_user(FIELDNOTE$4);\r\n return target;\r\n }\r\n }", "SoundEffect(String n) {\n\t\ttry{\n\t\t\tURL url = this.getClass().getClassLoader().getResource(n); //Create url with filename\n\t\t\tAudioInputStream audioInputStream = AudioSystem.getAudioInputStream(url); //Create AudioInputStream with url\n\t\t\tclip = AudioSystem.getClip(); //Assign the wav to clip\n\t\t\tclip.open(audioInputStream); //Open the clip\n\t\t}\n\t\tcatch (UnsupportedAudioFileException e) {\n\t\t\te.printStackTrace(); //Print stack trace for debugging\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\te.printStackTrace(); //Print stack trace for debugging\n\t\t}\n\t\tcatch (LineUnavailableException e) {\n\t\t\te.printStackTrace(); //Print stack trace for debugging\n\t\t}\n\t}", "Constant getCyclePeriodConstant();", "public ImagePattern getImagePattern() {\n return new ImagePattern(new Image(this.texture));\n }", "public void playNote(int pitch) {\n\t\tsynthChannel.noteOn(pitch, MusicManager.SYNTH_NOTE_VELOCITY);\n\t}", "@Override\n public void addNote(Note note) {\n\n List<Note> notes = new ArrayList<>();\n notes.add(note);\n\n if (this.notes.get(note.getBeat()) == null) {\n this.notes.put(note.getBeat(), notes);\n } else {\n List<Note> oldList = this.notes.remove(note.getBeat());\n oldList.addAll(notes);\n this.notes.put(note.getBeat(), oldList);\n }\n }", "public final void rule__CustomNote__Group__0__Impl() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2730:1: ( ( ruleNote ) )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2731:1: ( ruleNote )\n {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2731:1: ( ruleNote )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2732:1: ruleNote\n {\n before(grammarAccess.getCustomNoteAccess().getNoteParserRuleCall_0()); \n pushFollow(FOLLOW_ruleNote_in_rule__CustomNote__Group__0__Impl5556);\n ruleNote();\n\n state._fsp--;\n\n after(grammarAccess.getCustomNoteAccess().getNoteParserRuleCall_0()); \n\n }\n\n\n }\n\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "public final void rule__CustomNote__Group__3__Impl() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2818:1: ( ( ')' ) )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2819:1: ( ')' )\n {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2819:1: ( ')' )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:2820:1: ')'\n {\n before(grammarAccess.getCustomNoteAccess().getRightParenthesisKeyword_3()); \n match(input,48,FOLLOW_48_in_rule__CustomNote__Group__3__Impl5734); \n after(grammarAccess.getCustomNoteAccess().getRightParenthesisKeyword_3()); \n\n }\n\n\n }\n\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "public final void rule__BodyComponent__NoteAssignment_1() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:3719:1: ( ( ruleNote ) )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:3720:1: ( ruleNote )\n {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:3720:1: ( ruleNote )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:3721:1: ruleNote\n {\n before(grammarAccess.getBodyComponentAccess().getNoteNoteParserRuleCall_1_0()); \n pushFollow(FOLLOW_ruleNote_in_rule__BodyComponent__NoteAssignment_17509);\n ruleNote();\n\n state._fsp--;\n\n after(grammarAccess.getBodyComponentAccess().getNoteNoteParserRuleCall_1_0()); \n\n }\n\n\n }\n\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "private void updateMatchType(int startTactus, int noteLengthTacti) {\n\t\tint beatLength = subBeatLength * measure.getSubBeatsPerBeat();\n\t\tint measureLength = beatLength * measure.getBeatsPerMeasure();\n\t\t\n\t\tint subBeatOffset = startTactus % subBeatLength;\n\t\tint beatOffset = startTactus % beatLength;\n\t\tint measureOffset = startTactus % measureLength;\n\t\t\n\t\tif (matches(MetricalLpcfgMatch.SUB_BEAT)) {\n\t\t\t// Matches sub beat (and not beat)\n\t\t\t\n\t\t\tif (noteLengthTacti < subBeatLength) {\n\t\t\t\t// Note is shorter than a sub beat\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti == subBeatLength) {\n\t\t\t\t// Note is exactly a sub beat\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti < beatLength) {\n\t\t\t\t// Note is between a sub beat and a beat in length\n\t\t\t\t\n\t\t\t\t// Can only happen when the beat is divided in 3, but this is 2 sub beats\n\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti == beatLength) {\n\t\t\t\t// Note is exactly a beat in length\n\t\t\t\t\n\t\t\t\t// Must match exactly\n\t\t\t\taddMatch(beatOffset == 0 ? MetricalLpcfgMatch.BEAT : MetricalLpcfgMatch.WRONG);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t// Note is greater than a beat in length\n\t\t\t\t\n\t\t\t\tif (noteLengthTacti % beatLength != 0) {\n\t\t\t\t\t// Not some multiple of the beat length\n\t\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\t\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t} else if (matches(MetricalLpcfgMatch.BEAT)) {\n\t\t\t// Matches beat (and not sub beat)\n\t\t\t\n\t\t\tif (noteLengthTacti < subBeatLength) {\n\t\t\t\t// Note is shorter than a sub beat\n\t\t\t\t\n\t\t\t\tif (subBeatLength % noteLengthTacti != 0 || subBeatOffset % noteLengthTacti != 0) {\n\t\t\t\t\t// Note doesn't divide sub beat evenly\n\t\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti == subBeatLength) {\n\t\t\t\t// Note is exactly a sub beat\n\t\t\t\t\n\t\t\t\t// Must match sub beat exactly\n\t\t\t\taddMatch(subBeatOffset == 0 ? MetricalLpcfgMatch.SUB_BEAT : MetricalLpcfgMatch.WRONG);\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti < beatLength) {\n\t\t\t\t// Note is between a sub beat and a beat in length\n\t\t\t\t\n\t\t\t\t// Wrong if not aligned with beat at onset or offset\n\t\t\t\tif (beatOffset != 0 && beatOffset + noteLengthTacti != beatLength) {\n\t\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti == beatLength) {\n\t\t\t\t// Note is exactly a beat in length\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t// Note is longer than a beat in length\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t} else {\n\t\t\t// Matches neither sub beat nor beat\n\t\t\t\n\t\t\tif (noteLengthTacti < subBeatLength) {\n\t\t\t\t// Note is shorter than a sub beat\n\t\t\t\t\n\t\t\t\tif (subBeatLength % noteLengthTacti != 0 || subBeatOffset % noteLengthTacti != 0) {\n\t\t\t\t\t// Note doesn't divide sub beat evenly\n\t\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti == subBeatLength) {\n\t\t\t\t// Note is exactly a sub beat\n\t\t\t\t\n\t\t\t\t// Must match sub beat exactly\n\t\t\t\taddMatch(subBeatOffset == 0 ? MetricalLpcfgMatch.SUB_BEAT : MetricalLpcfgMatch.WRONG);\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti < beatLength) {\n\t\t\t\t// Note is between a sub beat and a beat in length\n\t\t\t\t\n\t\t\t\t// Wrong if not aligned with beat at onset or offset\n\t\t\t\tif (beatOffset != 0 && beatOffset + noteLengthTacti != beatLength) {\n\t\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti == beatLength) {\n\t\t\t\t// Note is exactly a beat in length\n\t\t\t\t\n\t\t\t\t// Must match beat exactly\n\t\t\t\taddMatch(beatOffset == 0 ? MetricalLpcfgMatch.BEAT : MetricalLpcfgMatch.WRONG);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t// Note is greater than a beat in length\n\t\t\t\t\n\t\t\t\tif (measureLength % noteLengthTacti != 0 || measureOffset % noteLengthTacti != 0 ||\n\t\t\t\t\t\tbeatOffset != 0 || noteLengthTacti % beatLength != 0) {\n\t\t\t\t\t// Note doesn't divide measure evenly, or doesn't match a beat\n\t\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "public static Note getG() {return (Note)G.clone();}", "public String getBreakSound() {\n\t\treturn \"dig.stone\";\n\t}", "static double sawtoothWave(double timeInSeconds, double frequency) {\r\n\t\treturn 0;\t\t\r\n\t}", "public void drawPattern(){\n \t\tIntent intent = new Intent(this, LockPatternActivity.class);\n \t\tintent.putExtra(LockPatternActivity._Mode, LockPatternActivity.LPMode.CreatePattern);\n \t\tstartActivityForResult(intent, REQUEST_CREATE_PATTERN);\n \t}", "private void playNotes()\n\t{\n\t\t//Update tracks when we can shift chords.\n\t\tChord curChord = ClearComposer.cc.getChord();\n\t\tif (index % ClearComposer.cc.getChordInterval() == 0 && (prevChord == null || prevChord != curChord))\n\t\t{\n\t\t\tprevChord = curChord;\n\t\t\ttracks.forEach(GraphicTrack::updateChord);\n\t\t\tClearComposer.cc.updateChordOutlines();\n\t\t}\n\n\t\tfor (GraphicTrack track : tracks)\n\t\t{\n\t\t\tint temp = track.playNote(index);\n\t\t\tif (temp != -1)\n\t\t\t\tMusicPlayer.playNote(temp);\n\t\t}\n\n\t\tindex++;\n\t\twhile (index >= ClearComposer.cc.getNumNotes())\n\t\t\tindex -= ClearComposer.cc.getNumNotes();\n\t}", "private void createWaveTimer()\n\t{\n\t\twaveTimer = new WaveTimer(\n\t\t\t\titemManager.getImage(INFERNAL_CAPE),\n\t\t\t\tthis,\n\t\t\t\tInstant.now().minus(Duration.ofSeconds(6)),\n\t\t\t\tnull\n\t\t);\n\t\tif (config.waveTimer())\n\t\t{\n\t\t\tinfoBoxManager.addInfoBox(waveTimer);\n\t\t}\n\t}", "private void createAlarm(long backoffTimeMs) {\n Log.d(TAG, \"Scheduling registration retry, backoff = \" + backoffTimeMs);\n Intent retryIntent = new Intent(C2DM_RETRY);\n PendingIntent retryPIntent = PendingIntent.getBroadcast(context, 0, retryIntent, 0);\n AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);\n am.set(AlarmManager.ELAPSED_REALTIME, backoffTimeMs, retryPIntent);\n }", "public static NoteCircle getId(Tone tone, Prefix prefix) {\n NoteCircle[] circ = values();\n for (int i = 0; i < circ.length; i++) {\n if (circ[i].getNotes().get(tone) == prefix) {\n return circ[i];\n }\n }\n System.out.println(\"// todo thow some kind of exception\");\n return null;\n }", "@Override\n public void setBackgroundPattern(Pattern pattern) {\n }", "private void getNotes(MusicCircle circle){\n\t\tif(! circle.isMuted()){\n\t\t\tfor(int i=0; i<circle.getNumNotes(); i++){\n\t\t\t\tif( circle.getS(i) != SILENCE) note(circle.getT(i) + loopOffset, circle.getD(i), Fofs(circle.getS(i) + circle.getBaseSemitone()));\n\t\t\t}\n\t\t}\n\t}", "@Override\n public List getNotesPlayingAtBeat(int beat) {\n List<Note> notes = this.getNotes();\n ArrayList<Note> notesAtBeat = new ArrayList<>();\n\n for (int i = 0; i < notes.size(); i++) {\n Note current = notes.get(i);\n\n if (current.isPlaying(beat)) {\n notesAtBeat.add(current);\n }\n }\n\n return notesAtBeat;\n }", "private void addLess(NoteColumn n) {\n switch (n.getName()) {\n case C :\n this.notes.add(new NoteColumn(NoteName.B, n.getOctave() - 1));\n break;\n case CSHARP :\n this.notes.add(new NoteColumn(NoteName.C, n.getOctave()));\n break;\n case D :\n this.notes.add(new NoteColumn(NoteName.CSHARP, n.getOctave()));\n break;\n case DSHARP :\n this.notes.add(new NoteColumn(NoteName.D, n.getOctave()));\n break;\n case E :\n this.notes.add(new NoteColumn(NoteName.DSHARP, n.getOctave()));\n break;\n case F :\n this.notes.add(new NoteColumn(NoteName.E, n.getOctave()));\n break;\n case FSHARP :\n this.notes.add(new NoteColumn(NoteName.F, n.getOctave()));\n break;\n case G :\n this.notes.add(new NoteColumn(NoteName.FSHARP, n.getOctave()));\n break;\n case GSHARP :\n this.notes.add(new NoteColumn(NoteName.G, n.getOctave()));\n break;\n case A :\n this.notes.add(new NoteColumn(NoteName.GSHARP, n.getOctave()));\n break;\n case ASHARP :\n this.notes.add(new NoteColumn(NoteName.A, n.getOctave()));\n break;\n case B :\n this.notes.add(new NoteColumn(NoteName.ASHARP, n.getOctave()));\n break;\n default :\n throw new IllegalArgumentException(\"Illegal note name\");\n }\n }" ]
[ "0.8092224", "0.5475217", "0.5429885", "0.54166347", "0.53571117", "0.53477854", "0.52760506", "0.51686835", "0.51584285", "0.50861883", "0.5068724", "0.49435583", "0.49205226", "0.49025762", "0.48582402", "0.4841648", "0.4762612", "0.4744613", "0.4727017", "0.47119427", "0.46992442", "0.4670915", "0.46644405", "0.4645587", "0.4613753", "0.45960465", "0.45895478", "0.45699236", "0.45612353", "0.45543128", "0.45519036", "0.45379087", "0.45253903", "0.45248973", "0.44888586", "0.4488765", "0.44883132", "0.44859916", "0.44798678", "0.4459629", "0.44413856", "0.44333744", "0.44214782", "0.43888158", "0.4382168", "0.43590796", "0.43462694", "0.43353745", "0.43335938", "0.43335494", "0.43274584", "0.431934", "0.43075547", "0.4306616", "0.42898452", "0.42860678", "0.4272705", "0.4269811", "0.4263471", "0.4263441", "0.4245836", "0.4239753", "0.4234311", "0.42319012", "0.4230632", "0.4230237", "0.42228654", "0.4210434", "0.4191102", "0.41818488", "0.41664392", "0.41613728", "0.41455466", "0.41452697", "0.41332147", "0.41305912", "0.41246107", "0.4121414", "0.41187528", "0.4117905", "0.4110623", "0.41082177", "0.41034093", "0.40939882", "0.40827295", "0.40788293", "0.40783548", "0.40653858", "0.40643686", "0.40497157", "0.40420708", "0.40412647", "0.40373182", "0.40255058", "0.40205756", "0.40130553", "0.40116328", "0.4007917", "0.40076458", "0.40055338" ]
0.7874828
1
Returns a Pattern that adds a grace note with a given sound duration to a given note.
public static PatternInterface graceNote(Note graceNote, Note baseNote, double graceNoteDuration){ Pattern gracePattern = new Pattern(graceNote.getMusicString()); return addOrnament(gracePattern, baseNote, graceNoteDuration); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static PatternInterface graceNote(Note graceNote, Note baseNote){\r\n \treturn graceNote(graceNote, baseNote, THIRTY_SECOND);\r\n }", "public static PatternInterface trill(Note baseNote, char trillDirection, double singleSoundDuration){\r\n \r\n \tStringBuilder musicStringBuilder = new StringBuilder();\r\n \r\n \tdouble totalDuration = baseNote.getDecimalDuration();\r\n double actualDuration = 0.0d;\r\n \r\n byte secondNote = baseNote.getValue();\r\n \r\n if(trillDirection == EFFECT_DIRECTION_UP){\r\n \tsecondNote++;\r\n } else if(trillDirection == EFFECT_DIRECTION_DOWN){\r\n \tsecondNote--;\r\n }\r\n \r\n double remainingDuration = totalDuration - (2*singleSoundDuration);\r\n if(remainingDuration > 0.0d){\r\n \t\r\n \tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \tactualDuration+=singleSoundDuration;\r\n \t\r\n \twhile(actualDuration < totalDuration){\r\n \t\tif(actualDuration + (2*singleSoundDuration) < totalDuration){\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, secondNote, singleSoundDuration);\r\n \t\t\tactualDuration += singleSoundDuration;\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \t\t\tactualDuration += singleSoundDuration;\r\n \t\t} else if(actualDuration + singleSoundDuration > totalDuration){\r\n \t\t\tdouble gapDuration = totalDuration - actualDuration;\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), gapDuration);\r\n \t\t\tactualDuration+=gapDuration;\r\n \t\t} else {\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \t\t\tactualDuration+=singleSoundDuration;\r\n \t\t}\r\n \t}\r\n \treturn new Pattern(musicStringBuilder.toString().trim());\r\n } else {\r\n \treturn new Pattern(baseNote.getMusicString());\r\n }\r\n }", "void addNote(int duration, int octave, int beatNum, String pitch)\n throws IllegalArgumentException;", "public Note(char n, int dur) {\n\t\tnote = n;\n\t\tduration = dur;\n\t}", "void addNote(int duration, int octave, int beatNum, int instrument, int volume, String pitch)\n throws IllegalArgumentException;", "public static PatternInterface slide(Note note1, Note note2, double duration, int numSteps)\r\n {\r\n StringBuilder buddy = new StringBuilder();\r\n double durationPerStep = duration / numSteps;\r\n double freq1 = Note.getFrequencyForNote(note1.getValue());\r\n double freq2 = Note.getFrequencyForNote(note2.getValue());\r\n double differencePerStep = (freq2-freq1) / numSteps;\r\n\r\n for (int i=0; i < numSteps; i++)\r\n {\r\n buddy.append(MicrotoneNotation.convertFrequencyToMusicString(freq1));\r\n buddy.append(\"/\");\r\n buddy.append(durationPerStep);\r\n buddy.append(MicrotoneNotation.getResetPitchWheelString());\r\n buddy.append(\" \");\r\n freq1 += differencePerStep;\r\n }\r\n\r\n PatternInterface pattern = new Pattern(buddy.toString());\r\n return pattern;\r\n }", "CompositionBuilder<T> addNote(int start, int end, int instrument, int pitch, int volume);", "public Note noteAt(int interval) {\n\t\tint newMidiNote = getMidiNumber() + interval;\n\t\t\n\t\treturn new Note(newMidiNote);\n\t}", "public Note(int _pitch, int _duration, int _dynamic) {\n pitch = _pitch;\n duration = _duration;\n dynamic = _dynamic;\n tiedIn = false;\n tiedOut = false;\n displayDynamic = false;\n }", "public Rational getRawDuration ()\r\n {\r\n Rational rawDuration = null;\r\n\r\n if (!getNotes().isEmpty()) {\r\n // All note heads are assumed to be the same within one chord\r\n Note note = (Note) getNotes().get(0);\r\n\r\n if (!note.getShape().isMeasureRest()) {\r\n // Duration (with flags/beams applied for non-rests)\r\n rawDuration = note.getNoteDuration();\r\n\r\n // Apply augmentation (applies to rests as well)\r\n if (dotsNumber == 1) {\r\n rawDuration = rawDuration.times(new Rational(3, 2));\r\n } else if (dotsNumber == 2) {\r\n rawDuration = rawDuration.times(new Rational(7, 4));\r\n }\r\n }\r\n }\r\n\r\n return rawDuration;\r\n }", "public NoteDuration getNoteDuration(int duration)\n\t{\n\t\tint whole = quarternote * 4;\n\t\t//\t\t 1 = 32/32\n\t\t//\t\t 3/4 = 24/32\n\t\t//\t\t 1/2 = 16/32\n\t\t//\t\t 3/8 = 12/32\n\t\t//\t\t 1/4 = 8/32\n\t\t//\t\t 3/16 = 6/32\n\t\t//\t\t 1/8 = 4/32 = 8/64\n\t\t//\t\t triplet = 5.33/64\n\t\t//\t\t 1/16 = 2/32 = 4/64\n\t\t//\t\t 1/32 = 1/32 = 2/64\n\n\t\tif (duration >= 28 * whole / 32)\n\t\t return NoteDuration.Whole;\n\t\telse if (duration >= 20 * whole / 32)\n\t\t return NoteDuration.DottedHalf;\n\t\telse if (duration >= 14 * whole / 32)\n\t\t return NoteDuration.Half;\n\t\telse if (duration >= 10 * whole / 32)\n\t\t return NoteDuration.DottedQuarter;\n\t\telse if (duration >= 7 * whole / 32)\n\t\t return NoteDuration.Quarter;\n\t\telse if (duration >= 5 * whole / 32)\n\t\t return NoteDuration.DottedEighth;\n\t\telse if (duration >= 6 * whole / 64)\n\t\t return NoteDuration.Eighth;\n\t\telse if (duration >= 5 * whole / 64)\n\t\t return NoteDuration.Triplet;\n\t\telse if (duration >= 3 * whole / 64)\n\t\t return NoteDuration.Sixteenth;\n\t\telse if (duration >= 2 * whole / 64)\n\t\t return NoteDuration.ThirtySecond;\n\t\telse if (duration >= whole / 64)\n\t\t return NoteDuration.SixtyFour; // TODO : EXTEND UNTIL 1/128 to be able to extract the onset in SYMBOLIC representation\n\t\telse if (duration >= whole / 128)\n\t\t return NoteDuration.HundredTwentyEight;\n\t\telse\n\t\t return NoteDuration.ZERO;\n\t}", "String getDelayPattern();", "public SoundEffect adjust(float volume, float pitch) {\n \t\treturn new SoundEffect(this, volume, pitch);\n \t}", "public Note(int duration, int offset, int pitch, int channel, int velocity) {\n this.duration = duration;\n this.offset = offset;\n this.pitch = pitch;\n this.channel = channel;\n this.velocity = velocity;\n }", "void addRepeat(int beatNum, RepeatType repeatType);", "int getRecurrenceDuration();", "void note(float start, float duration, float freq){\n\t out.playNote(start,duration,freq); \n\t }", "public static PatternInterface hammerOn(Note note1, Note note2, double duration, int numHammers)\r\n {\r\n StringBuilder buddy = new StringBuilder();\r\n double durationPerHammer = duration / numHammers;\r\n buddy.append(\"[\");\r\n buddy.append(note1.getValue());\r\n buddy.append(\"]/\");\r\n buddy.append(durationPerHammer / 2.0);\r\n buddy.append(\" [\");\r\n buddy.append(note2.getValue());\r\n buddy.append(\"]/\");\r\n buddy.append(durationPerHammer / 2.0);\r\n\r\n PatternInterface pattern = new Pattern(buddy.toString());\r\n pattern.repeat(numHammers);\r\n return pattern;\r\n }", "public static PatternInterface addOrnament(Pattern ornament, Note baseNote, double longestOrnamentDuration){\r\n \tPatternInvestigator investigator = new PatternInvestigator();\r\n \tMusicStringParser stringParser = new MusicStringParser();\r\n \t\r\n \tstringParser.addParserListener(investigator);\r\n \tstringParser.parse(ornament);\r\n \t\r\n \tdouble longestDuration = investigator.getLongestDecimalDuration();\r\n \tdouble durationChange = longestOrnamentDuration / longestDuration;\r\n \t\r\n \tDurationPatternTransformer transformer = new DurationPatternTransformer(durationChange);\r\n \t\r\n \tPatternInterface result = transformer.transform(ornament);\r\n \t\r\n \tstringParser.removeParserListener(investigator);\r\n \tinvestigator = new PatternInvestigator();\r\n \tstringParser.addParserListener(investigator);\r\n \tstringParser.parse(result);\r\n \t\r\n \tif(investigator.getTotalDecimalDuration() < baseNote.getDecimalDuration()){\r\n \t\tdouble remainingDuration = baseNote.getDecimalDuration() - investigator.getTotalDecimalDuration();\r\n \t\tbaseNote.setDecimalDuration(remainingDuration);\r\n \t\tresult.add(baseNote.getMusicString());\r\n \t\treturn result;\r\n \t} else {\r\n \t\treturn new Pattern(baseNote.getMusicString());\r\n \t}\r\n }", "public static Note createNote(int value, int startBeat, int endBeat) {\n return createNote((value / 12) - 1, Pitch.getPitch(value % 12), startBeat, endBeat);\n }", "@Override\n public void addNote(int startTime, int duration, Pitch pitch, Octave octave) {\n List<Note> notes = new ArrayList<>();\n Note newNote = new SimpleNote(pitch, octave, startTime, duration);\n notes.add(newNote);\n\n if (this.notes.get(startTime) == null) {\n this.notes.put(startTime, notes);\n } else {\n List<Note> oldList = this.notes.remove(startTime);\n oldList.addAll(notes);\n this.notes.put(startTime, oldList);\n }\n\n }", "public static Note createNote(int value, int startBeat, int endBeat, int instrument, int\n volume) {\n return createNote((value / 12) - 1, Pitch.getPitch(value % 12), startBeat, endBeat, instrument,\n volume);\n }", "public void playSong() {\n\t\t// Initialize\n\t\tint num = 1;\n\n\t\t// Get the notes to be played from the entryBox\n\t\tString notesString = \"V0 \" + instrumentType + \" \" + entryBox.getText();\n\n\t\t// Create a new rhythm object\n\t\tRhythm rhythm = new Rhythm();\n\n\t\t// Get the rhythm strings from the rhythm entry boxes\n\t\tString rhythmLayer1 = \"V1 \" + rhythm1.getText();\n\t\tString rhythmLayer2 = \"V2 \" + rhythm2.getText();\n\n\t\t// Set the strings to layers\n\t\trhythm.setLayer(1, rhythmLayer1);\n\t\trhythm.setLayer(2, rhythmLayer2);\n\n\t\t// Add the appropriate substitutions\n\t\trhythm.addSubstitution('O', \"[BASS_DRUM]i\");\n\t\trhythm.addSubstitution('o', \"Rs [BASS_DRUM]s\");\n\t\trhythm.addSubstitution('*', \"[ACOUSTIC_SNARE]i\");\n\t\trhythm.addSubstitution('^', \"[PEDAL_HI_HAT]s Rs\");\n\t\trhythm.addSubstitution('!', \"[CRASH_CYMBAL_1]s Rs\");\n\t\trhythm.addSubstitution('.', \"Ri\");\n\n\t\t// Get the rhythm pattern\n\t\tPattern rhythmPattern = rhythm.getPattern();\n\n\t\t// Get how many times the song should repeat\n\t\tString repeatNum = repeatNumber.getText();\n\t\tnum = Integer.parseInt(repeatNum);\n\n\t\t// Get the playback tempo\n\t\tString playTempo = \"T[\" + tempo.getText() + \"] \";\n\n\t\t// Create the song\n\t\tPattern song = new Pattern();\n\t\tsong.add(rhythmPattern);\n\t\tsong.add(notesString);\n\t\tsong.repeat(num);\n\n\t\t// Play the song\n\t\tplayer.play(playTempo + song);\n\n\t}", "public static Note createNote(int octave, Pitch pitch, int startBeat, int endBeat) {\n return new NoteImpl(octave, pitch, startBeat, endBeat);\n }", "public SoundEffect randomPitch(float amount) {\n \t\treturn new RandomPitchSoundEffect(this, amount);\n \t}", "public void generateTone()\n throws LineUnavailableException {\n if ( clip!=null ) {\n clip.stop();\n clip.close();\n } else {\n clip = AudioSystem.getClip();\n }\n boolean addHarmonic = harmonic.isSelected();\n\n int intSR = ((Integer)sampleRate.getSelectedItem()).intValue();\n int intFPW = framesPerWavelength.getValue();\n\n float sampleRate = (float)intSR;\n\n // oddly, the sound does not loop well for less than\n // around 5 or so, wavelengths\n int wavelengths = 20;\n byte[] buf = new byte[2*intFPW*wavelengths];\n AudioFormat af = new AudioFormat(\n sampleRate,\n 8, // sample size in bits\n 2, // channels\n true, // signed\n false // bigendian\n );\n\n int maxVol = 127;\n for(int i=0; i<intFPW*wavelengths; i++){\n double angle = ((float)(i*2)/((float)intFPW))*(Math.PI);\n buf[i*2]=getByteValue(angle);\n if(addHarmonic) {\n buf[(i*2)+1]=getByteValue(2*angle);\n } else {\n buf[(i*2)+1] = buf[i*2];\n }\n }\n\n try {\n byte[] b = buf;\n AudioInputStream ais = new AudioInputStream(\n new ByteArrayInputStream(b),\n af,\n buf.length/2 );\n\n clip.open( ais );\n } catch(Exception e) {\n e.printStackTrace();\n }\n }", "@Override\n\tpublic String toString() {\n\t\treturn note + \" \" + duration + (duration == 1 ? \" Quaver\" : \" Crotchet\");\n\t}", "public void sequentialNoteEvent(Note note)\r\n {\r\n byte noteValue = note.getValue();\r\n if (voiceValue != 9) // added D G Gray 5th Feb 2017\r\n {\r\n noteValue += this.interval;\r\n note.setValue(noteValue);\r\n\t }\r\n\r\n\r\n getReturnPattern().addElement(note);\r\n }", "public void noteEvent(Note note)\r\n {\r\n byte noteValue = note.getValue();\r\n if (voiceValue != 9) // added D G Gray 5th Feb 2017\r\n {\r\n noteValue += this.interval;\r\n note.setValue(noteValue);\r\n\t }\r\n\r\n getReturnPattern().addElement(note);\r\n }", "private int getWhatSoundThatShouldBePlayed(int gapAmountOfSeconds){\n\n if(gapAmountOfSeconds > 0 && !notifiedUnderPace ){\n notifiedUnderPace = true;\n return 3;\n }\n if (gapAmountOfSeconds >= AMOUNT_OF_SECONDS_WHEN_TRIGGERING_NOTIFICATION && gapAmountOfSeconds <= 0){\n if (gapAmountOfSeconds >= AMOUNT_OF_SECONDS_WHEN_TRIGGERING_NOTIFICATION/2 && gapAmountOfSeconds <= 0){\n return 2;\n }\n notifiedUnderPace = false;\n return 1;\n }\n\n\n return 0;\n }", "Posn getDuration();", "INote removeNote(int beatNum, String pitch, int octave) throws IllegalArgumentException;", "public GIFMaker withDelay(int delay);", "public static Note createNote(int octave, Pitch pitch, int startBeat, int endBeat, int\n instrument, int volume) {\n return new NoteImpl(octave, pitch, startBeat, endBeat, instrument, volume);\n }", "private VibrationEffect getVibrationEffect() {\n return VibrationEffect.startComposition()\n .addPrimitive(VibrationEffect.Composition.PRIMITIVE_THUD, 1.0f, 50)\n .compose();\n }", "public void addNote()\n {\n String stringNote;\n char actualNote;\n int beat;\n \n System.out.print(\"Enter the note > \"); //gets the note from user\n stringNote = in.nextLine();\n actualNote = stringNote.charAt(0);\n \n System.out.print(\"Enter the length of the note in beats > \"); //gets the beats from user\n beat = in.nextInt();\n \n Note note = new Note(actualNote, beat); //creates Note to be added\n \n score.add(note); //adds the note to the score\n \n in.nextLine();\n }", "void pulse(double pulseLength);", "@Override\n\tpublic void playSequenceNote(final int note, final double duration,\n\t\t\tfinal int instrument, final int velocity) {\n\t\ttry {\n\t\t\tstopCurrentSound();\n\t\t\tcurrentSoundType = SOUNDTYPE_MIDI;\n\t\t\tgetMidiSound().playSequenceNote(note, duration, instrument);\n\t\t} catch (Exception e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t}", "public abstract void newSpeechNoise(long ms, int n);", "public final void rule__ChordParams__Alternatives_0() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:736:1: ( ( ruleNote ) | ( ruleCustomNote ) )\n int alt4=2;\n alt4 = dfa4.predict(input);\n switch (alt4) {\n case 1 :\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:737:1: ( ruleNote )\n {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:737:1: ( ruleNote )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:738:1: ruleNote\n {\n before(grammarAccess.getChordParamsAccess().getNoteParserRuleCall_0_0()); \n pushFollow(FOLLOW_ruleNote_in_rule__ChordParams__Alternatives_01556);\n ruleNote();\n\n state._fsp--;\n\n after(grammarAccess.getChordParamsAccess().getNoteParserRuleCall_0_0()); \n\n }\n\n\n }\n break;\n case 2 :\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:743:6: ( ruleCustomNote )\n {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:743:6: ( ruleCustomNote )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:744:1: ruleCustomNote\n {\n before(grammarAccess.getChordParamsAccess().getCustomNoteParserRuleCall_0_1()); \n pushFollow(FOLLOW_ruleCustomNote_in_rule__ChordParams__Alternatives_01573);\n ruleCustomNote();\n\n state._fsp--;\n\n after(grammarAccess.getChordParamsAccess().getCustomNoteParserRuleCall_0_1()); \n\n }\n\n\n }\n break;\n\n }\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "@Override\n public CompositionBuilder<MusicOperation> addNote(int start, int end, int instrument,\n int pitch, int volume) {\n this.listNotes.add(new SimpleNote(Pitch.values()[(pitch) % 12],\n Octave.values()[(pitch / 12) - 2 ], start, end - start, instrument, volume));\n return this;\n }", "public final void rule__ChordParams__Alternatives_1_1() throws RecognitionException {\n\n \t\tint stackSize = keepStackSize();\n \n try {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:758:1: ( ( ruleNote ) | ( ( rule__ChordParams__CnotesAssignment_1_1_1 ) ) )\n int alt5=2;\n alt5 = dfa5.predict(input);\n switch (alt5) {\n case 1 :\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:759:1: ( ruleNote )\n {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:759:1: ( ruleNote )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:760:1: ruleNote\n {\n before(grammarAccess.getChordParamsAccess().getNoteParserRuleCall_1_1_0()); \n pushFollow(FOLLOW_ruleNote_in_rule__ChordParams__Alternatives_1_11605);\n ruleNote();\n\n state._fsp--;\n\n after(grammarAccess.getChordParamsAccess().getNoteParserRuleCall_1_1_0()); \n\n }\n\n\n }\n break;\n case 2 :\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:765:6: ( ( rule__ChordParams__CnotesAssignment_1_1_1 ) )\n {\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:765:6: ( ( rule__ChordParams__CnotesAssignment_1_1_1 ) )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:766:1: ( rule__ChordParams__CnotesAssignment_1_1_1 )\n {\n before(grammarAccess.getChordParamsAccess().getCnotesAssignment_1_1_1()); \n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:767:1: ( rule__ChordParams__CnotesAssignment_1_1_1 )\n // ../ufscar.Compiladores2.ui/src-gen/ufscar/compiladores2/ui/contentassist/antlr/internal/InternalMusy.g:767:2: rule__ChordParams__CnotesAssignment_1_1_1\n {\n pushFollow(FOLLOW_rule__ChordParams__CnotesAssignment_1_1_1_in_rule__ChordParams__Alternatives_1_11622);\n rule__ChordParams__CnotesAssignment_1_1_1();\n\n state._fsp--;\n\n\n }\n\n after(grammarAccess.getChordParamsAccess().getCnotesAssignment_1_1_1()); \n\n }\n\n\n }\n break;\n\n }\n }\n catch (RecognitionException re) {\n reportError(re);\n recover(input,re);\n }\n finally {\n\n \trestoreStackSize(stackSize);\n\n }\n return ;\n }", "Builder addTimeRequired(Duration value);", "@Override\n\tpublic RecurrenceRule newRecurrence(String frequency, int interval) {\n\t\treturn null;\n\t}", "private void createWaveTimer()\n\t{\n\t\twaveTimer = new WaveTimer(\n\t\t\t\titemManager.getImage(INFERNAL_CAPE),\n\t\t\t\tthis,\n\t\t\t\tInstant.now().minus(Duration.ofSeconds(6)),\n\t\t\t\tnull\n\t\t);\n\t\tif (config.waveTimer())\n\t\t{\n\t\t\tinfoBoxManager.addInfoBox(waveTimer);\n\t\t}\n\t}", "void setRecurrenceDuration(int recurrenceDuration);", "public static Note makeNote(int pitch, int octave) {\n if (octave < 0) {\n throw new IllegalArgumentException(\"Invalid octave parameter!\");\n }\n return new Note(Pitch.makePitch(pitch),octave,0);\n }", "public void playChord(float[] pitches, double dynamic, double duration) {\n\t\tthis.soundCipher.playChord(pitches, dynamic, duration);\n\t}", "public Note(Pitch pitch, int octave, int instrument) {\n if (octave < 0 || octave > 10) {\n throw new IllegalArgumentException(\"octave must be between 0 and 10 (inclusive)\");\n }\n\n this.pitch = pitch;\n this.octave = octave;\n this.instrument = instrument;\n }", "void crear(Tonelaje tonelaje);", "public Piano(int numNotes){\n pStrings = new InstString[numNotes][3];\n for(int a = 0; a < numNotes; a++){\n double freq = 440 * Math.pow(2, (double)(a-24)/(double)12);\n pStrings[a][0] = new GuitarString(freq);\n pStrings[a][1] = new GuitarString(freq + .45);\n pStrings[a][2] = new GuitarString(freq - .45);\n }\n }", "public B mo4686d(int duration) {\n this.f1121g = duration;\n return this;\n }", "static double sawtoothWave(double timeInSeconds, double frequency) {\r\n\t\treturn 0;\t\t\r\n\t}", "@Override\n\tpublic RecurrenceRule newRecurrence(String frequency, int interval,\n\t\t\tint count) {\n\t\treturn null;\n\t}", "public Note(int noteNumber, int instrument) {\n this.octave = (noteNumber / 12) - 1;\n this.pitch = Pitch.pitchFromNumber(noteNumber - (this.octave * 12));\n this.instrument = instrument;\n }", "@Override\n protected String produceSound(){\n return \"BauBau\";\n\n }", "@Override\n\tpublic void setDuration(Duration duration) {\n\t\tfor (NoteBuilder builder : this) {\n\t\t\tbuilder.setDuration(duration);\n\t\t}\n\t\tthis.duration = duration;\n\t}", "Builder addTimeRequired(Duration.Builder value);", "public int durationToTime(NoteDuration dur)\n\t{\n\t\tint eighth = quarternote / 2;\n\t\tint sixteenth = eighth / 2;\n\n\t\tswitch (dur)\n\t\t{\n\t\t\tcase Whole:\n\t\t\t\treturn quarternote * 4;\n\t\t\tcase DottedHalf:\n\t\t\t\treturn quarternote * 3;\n\t\t\tcase Half:\n\t\t\t\treturn quarternote * 2;\n\t\t\tcase DottedQuarter:\n\t\t\t\treturn 3 * eighth;\n\t\t\tcase Quarter:\n\t\t\t\treturn quarternote;\n\t\t\tcase DottedEighth:\n\t\t\t\treturn 3 * sixteenth;\n\t\t\tcase Eighth:\n\t\t\t\treturn eighth;\n\t\t\tcase Triplet:\n\t\t\t\treturn quarternote / 3;\n\t\t\tcase Sixteenth:\n\t\t\t\treturn sixteenth;\n\t\t\tcase ThirtySecond:\n\t\t\t\treturn sixteenth / 2;\n\t\t\tcase HundredTwentyEight:\n\t\t\t\treturn quarternote / 32;\n\t\t\tdefault:\n\t\t\t\treturn 0;\n\t\t}//end switch\n\t}", "public void playDelayedSound(ISound sound, int delay) {\n/* 504 */ this.delayedSounds.put(sound, Integer.valueOf(this.playTime + delay));\n/* */ }", "public SimpleSandTimer(final TemporalAmount duration, final Supplier<Instant> now) {\n this(now.get().plus(duration), now);\n }", "public Delay(int sd){\n super(\"delay\");\n delay = sd;\n\n }", "@Override\n public void addNote(Note n) {\n if (this.sheet.size() < n.getDuration() + n.getStartMeasure()) {\n for (int i = this.sheet.size(); i < n.getDuration() + n.getStartMeasure(); i++) {\n sheet.add(new HashSet<>());\n }\n }\n for (int i = 0; i < n.getDuration(); i++) {\n for (Note t : this.sheet.get(i + n.getStartMeasure())) {\n if (t.equals(n)) {\n throw new IllegalArgumentException(\"Already placed a note.\");\n }\n }\n }\n this.sheet.get(n.getStartMeasure()).add(n);\n int currentMeasure = n.getStartMeasure() + 1;\n for (int i = 1; i < n.getDuration(); i++) {\n Note hold = new Note(1, n.getOctave(), currentMeasure,\n n.getPitch(), false, n.getInstrument(), n.getVolume());\n this.sheet.get(currentMeasure).add(hold);\n currentMeasure++;\n }\n\n this.high = this.getHighest();\n this.low = this.getLowest();\n }", "static void afinar(Instrument1 i) { i.play(Note.MIDDLE_C); }", "public static PatternInterface trill(Note baseNote, char trillDirection){\r\n \treturn trill(baseNote, trillDirection, THIRTY_SECOND);\r\n }", "@Override\n public void mutate(Song song, int noteIndex) {\n if (Math.random() < this.getProbability()) {\n if (noteIndex > 0) {\n MidiUtil mu = new MidiUtil();\n int nbrOfTotalReversing = nbrOfAdditionalReversing + 1\n + ((int) Math.random() * nbrRange);\n ArrayList<Integer> noteIndexes = new ArrayList<Integer>();\n ArrayList<Note> notes = new ArrayList<Note>();\n noteIndexes.add(noteIndex);\n notes.add(song.getScore().getPart(0).getPhrase(0)\n .getNote(noteIndex));\n int currentIndex = noteIndex - 1;\n noteIteration: for (int i = 1; i < nbrOfTotalReversing; i++) {\n while (mu.isBlank(currentIndex) && currentIndex >= 0) {\n currentIndex--;\n }\n if (currentIndex < 0) {\n break noteIteration;\n } else {\n noteIndexes.add(currentIndex);\n notes.add(song.getScore().getPart(0).getPhrase(0)\n .getNote(currentIndex));\n }\n }\n int totalReverses = noteIndexes.size();\n for (int j = 0; j < noteIndexes.size(); j++) {\n if (withRhythmLength) {\n song.getScore()\n .getPart(0)\n .getPhrase(0)\n .setNote(notes.get(totalReverses - 1 - j),\n noteIndexes.get(j));\n } else {\n int newPitch = notes.get(totalReverses - 1 - j)\n .getPitch();\n song.getScore().getPart(0).getPhrase(0)\n .getNote(noteIndexes.get(j)).setPitch(newPitch);\n }\n }\n }\n }\n }", "SoundEffect(String n) {\n\t\ttry{\n\t\t\tURL url = this.getClass().getClassLoader().getResource(n); //Create url with filename\n\t\t\tAudioInputStream audioInputStream = AudioSystem.getAudioInputStream(url); //Create AudioInputStream with url\n\t\t\tclip = AudioSystem.getClip(); //Assign the wav to clip\n\t\t\tclip.open(audioInputStream); //Open the clip\n\t\t}\n\t\tcatch (UnsupportedAudioFileException e) {\n\t\t\te.printStackTrace(); //Print stack trace for debugging\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\te.printStackTrace(); //Print stack trace for debugging\n\t\t}\n\t\tcatch (LineUnavailableException e) {\n\t\t\te.printStackTrace(); //Print stack trace for debugging\n\t\t}\n\t}", "public static void charge_sound() {\n\t\tm_player_charge.start();\n\t\tm_player_charge.setMediaTime(new Time(0));\n\t}", "public static PatternInterface trill(Note note1, Note note2, double duration, int numSteps)\r\n {\r\n return hammerOn(note1, note2, duration, numSteps);\r\n }", "@Override\n\tpublic RecurrenceRule newRecurrence(String frequency, int interval,\n\t\t\tTime until) {\n\t\treturn null;\n\t}", "private static StringBuilder appendNoteValueAndDuration(StringBuilder inputBuilder, byte noteValue, double noteDuration){\r\n \tinputBuilder.append(\"[\");\r\n \tinputBuilder.append(noteValue);\r\n \tinputBuilder.append(\"]/\");\r\n \tinputBuilder.append(noteDuration);\r\n \tinputBuilder.append(\" \");\r\n \treturn inputBuilder;\r\n }", "@Override\n\tpublic RecurrenceRule newRecurrence(String frequency) {\n\t\treturn null;\n\t}", "private void Scale()\n {\n Song scale = new Song();\n scale.add(new Note(noteA1,WHOLE_NOTE/2));\n scale.add(new Note(noteBB1,WHOLE_NOTE/2));\n scale.add(new Note(noteB1,WHOLE_NOTE/2));\n scale.add(new Note(noteC1,WHOLE_NOTE/2));\n scale.add(new Note(noteCS1,WHOLE_NOTE/2));\n scale.add(new Note(noteD1,WHOLE_NOTE/2));\n scale.add(new Note(noteDS1,WHOLE_NOTE/2));\n scale.add(new Note(noteE1,WHOLE_NOTE/2));\n scale.add(new Note(noteF1,WHOLE_NOTE/2));\n scale.add(new Note(noteFS1,WHOLE_NOTE/2));\n scale.add(new Note(noteG1,WHOLE_NOTE/2));\n scale.add(new Note(noteGS1,WHOLE_NOTE/2));\n\n\n playSong(scale);\n }", "private void getNotes(MusicCircle circle){\n\t\tif(! circle.isMuted()){\n\t\t\tfor(int i=0; i<circle.getNumNotes(); i++){\n\t\t\t\tif( circle.getS(i) != SILENCE) note(circle.getT(i) + loopOffset, circle.getD(i), Fofs(circle.getS(i) + circle.getBaseSemitone()));\n\t\t\t}\n\t\t}\n\t}", "@Override\n public Pattern createPattern(Image image, String repeat) {\n return new Pattern(image, repeat);\n }", "private static double[] note(double hz, double duration, double amplitude) {\n int N = (int) (StdAudio.SAMPLE_RATE * duration);\n double[] a = new double[N + 1];\n for (int i = 0; i <= N; i++)\n a[i] = amplitude * Math.sin(2 * Math.PI * i * hz / StdAudio.SAMPLE_RATE);\n return a;\n }", "public void playBeep(){\n //https://stackoverflow.com/questions/2618182/how-to-play-ringtone-alarm-sound-in-android\n try{\n //gets notification sound then plays it.\n Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);\n Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);\n\n r.play();\n TimeUnit.MILLISECONDS.sleep(300);\n r.stop();\n\n }catch (Exception e){\n e.printStackTrace();\n }\n\n }", "public FormatInteger asteriskFill(){\n fillCharacter = ASTERISK_CHAR;\n return this;\n }", "public static PatternInterface addOrnament(Pattern ornament, Note baseNote){\r\n \treturn addOrnament(ornament, baseNote, THIRTY_SECOND);\r\n }", "public Note(int midiNumber) {\n\t\tthis.noteName = NoteName.C.noteAt(midiNumber);\n\t\tthis.octave = midiNumber / OCTAVE_LENGTH;\n\t\tthis.midiNumber = midiNumber;\n\t}", "public void playDtmf(char dtmf, int durationMs);", "public Exam(int newWeight, int newDuration) {\r\n\t\tthis.setWeight(newWeight);\r\n\t\tif (newDuration < 30) {\r\n\t\t\tthrow new IllegalArgumentException(\"Exam duration too short.\");\r\n\t\t} else if (newDuration > 180) {\r\n\t\t\tthrow new IllegalArgumentException(\"Exam duration too long.\");\r\n\t\t}\r\n\t\tduration = newDuration;\r\n\t}", "@WithName(\"schedule.delay\")\n @WithDefault(\"5s\")\n Duration scheduleDelay();", "@Override\n\tpublic String makeSound() {\n\t\treturn ANIMAL_SOUND;\n\t}", "void setDuration(int duration);", "Note getBukkitNote();", "void setRecurrenceFrequency(long seconds) throws NoUserSelectedException;", "public abstract Tone getTone();", "public Duration() {\n this(0, 0, 0, 0, 0, 0.0);\n }", "public static void clic_sound() {\n\t\tm_player_clic.start();\n\t\tm_player_clic.setMediaTime(new Time(0));\n\t}", "public int getDuration();", "public static PatternInterface trill(Note baseNote){\r\n \treturn trill(baseNote, EFFECT_DIRECTION_UP);\r\n }", "private void generateAudio() {\n soundHandler.generateTone();\n }", "public Note(int note, char accidental, Pane notePane) {\n _note = note;\n _accidental = accidental;\n _accidentalImage = new ImageView();\n this.setUpLedger();\n this.setUpNote();\n }", "public TimeEntry duration(Integer duration) {\n this.duration = duration;\n return this;\n }", "java.lang.String getDuration();", "public static Note add(final Note noteToAdd) {\n try {\r\n // Simulate time for network request.\r\n Thread.sleep(5000);\r\n } catch (Exception e) {\r\n // Just for test purposes so handling error doesn't matter.\r\n }\r\n noteToAdd.setId(4);\r\n return noteToAdd;\r\n }", "private void updateMatchType(int startTactus, int noteLengthTacti) {\n\t\tint beatLength = subBeatLength * measure.getSubBeatsPerBeat();\n\t\tint measureLength = beatLength * measure.getBeatsPerMeasure();\n\t\t\n\t\tint subBeatOffset = startTactus % subBeatLength;\n\t\tint beatOffset = startTactus % beatLength;\n\t\tint measureOffset = startTactus % measureLength;\n\t\t\n\t\tif (matches(MetricalLpcfgMatch.SUB_BEAT)) {\n\t\t\t// Matches sub beat (and not beat)\n\t\t\t\n\t\t\tif (noteLengthTacti < subBeatLength) {\n\t\t\t\t// Note is shorter than a sub beat\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti == subBeatLength) {\n\t\t\t\t// Note is exactly a sub beat\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti < beatLength) {\n\t\t\t\t// Note is between a sub beat and a beat in length\n\t\t\t\t\n\t\t\t\t// Can only happen when the beat is divided in 3, but this is 2 sub beats\n\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti == beatLength) {\n\t\t\t\t// Note is exactly a beat in length\n\t\t\t\t\n\t\t\t\t// Must match exactly\n\t\t\t\taddMatch(beatOffset == 0 ? MetricalLpcfgMatch.BEAT : MetricalLpcfgMatch.WRONG);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t// Note is greater than a beat in length\n\t\t\t\t\n\t\t\t\tif (noteLengthTacti % beatLength != 0) {\n\t\t\t\t\t// Not some multiple of the beat length\n\t\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\t\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t} else if (matches(MetricalLpcfgMatch.BEAT)) {\n\t\t\t// Matches beat (and not sub beat)\n\t\t\t\n\t\t\tif (noteLengthTacti < subBeatLength) {\n\t\t\t\t// Note is shorter than a sub beat\n\t\t\t\t\n\t\t\t\tif (subBeatLength % noteLengthTacti != 0 || subBeatOffset % noteLengthTacti != 0) {\n\t\t\t\t\t// Note doesn't divide sub beat evenly\n\t\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti == subBeatLength) {\n\t\t\t\t// Note is exactly a sub beat\n\t\t\t\t\n\t\t\t\t// Must match sub beat exactly\n\t\t\t\taddMatch(subBeatOffset == 0 ? MetricalLpcfgMatch.SUB_BEAT : MetricalLpcfgMatch.WRONG);\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti < beatLength) {\n\t\t\t\t// Note is between a sub beat and a beat in length\n\t\t\t\t\n\t\t\t\t// Wrong if not aligned with beat at onset or offset\n\t\t\t\tif (beatOffset != 0 && beatOffset + noteLengthTacti != beatLength) {\n\t\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti == beatLength) {\n\t\t\t\t// Note is exactly a beat in length\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t// Note is longer than a beat in length\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t} else {\n\t\t\t// Matches neither sub beat nor beat\n\t\t\t\n\t\t\tif (noteLengthTacti < subBeatLength) {\n\t\t\t\t// Note is shorter than a sub beat\n\t\t\t\t\n\t\t\t\tif (subBeatLength % noteLengthTacti != 0 || subBeatOffset % noteLengthTacti != 0) {\n\t\t\t\t\t// Note doesn't divide sub beat evenly\n\t\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti == subBeatLength) {\n\t\t\t\t// Note is exactly a sub beat\n\t\t\t\t\n\t\t\t\t// Must match sub beat exactly\n\t\t\t\taddMatch(subBeatOffset == 0 ? MetricalLpcfgMatch.SUB_BEAT : MetricalLpcfgMatch.WRONG);\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti < beatLength) {\n\t\t\t\t// Note is between a sub beat and a beat in length\n\t\t\t\t\n\t\t\t\t// Wrong if not aligned with beat at onset or offset\n\t\t\t\tif (beatOffset != 0 && beatOffset + noteLengthTacti != beatLength) {\n\t\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t} else if (noteLengthTacti == beatLength) {\n\t\t\t\t// Note is exactly a beat in length\n\t\t\t\t\n\t\t\t\t// Must match beat exactly\n\t\t\t\taddMatch(beatOffset == 0 ? MetricalLpcfgMatch.BEAT : MetricalLpcfgMatch.WRONG);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t// Note is greater than a beat in length\n\t\t\t\t\n\t\t\t\tif (measureLength % noteLengthTacti != 0 || measureOffset % noteLengthTacti != 0 ||\n\t\t\t\t\t\tbeatOffset != 0 || noteLengthTacti % beatLength != 0) {\n\t\t\t\t\t// Note doesn't divide measure evenly, or doesn't match a beat\n\t\t\t\t\taddMatch(MetricalLpcfgMatch.WRONG);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "public static void createDelay(int duration) {\r\n\t\ttry {\r\n\t\t\tThread.sleep(duration);\r\n\t\t} catch(Exception e) {\r\n\t\t\t//do nothing\r\n\t\t}\r\n\t}", "public BackgroundSound loadBackgroundSound( String filename, float gain ) throws IOException\n {\n SoundContainer container = loadSound( filename );\n \n return ( new BackgroundSound( container, gain ) );\n }" ]
[ "0.7390966", "0.58670175", "0.58174896", "0.5796119", "0.55819345", "0.5363094", "0.5302033", "0.5288751", "0.5273073", "0.52394325", "0.5224333", "0.5217334", "0.5175973", "0.513253", "0.5063195", "0.50370675", "0.5035977", "0.501858", "0.50131315", "0.499066", "0.495428", "0.49377617", "0.487848", "0.48566687", "0.4840561", "0.48322228", "0.4800671", "0.4777403", "0.47605878", "0.47541514", "0.47360685", "0.46944964", "0.46911812", "0.468136", "0.4582107", "0.45707658", "0.45683405", "0.4561486", "0.45604548", "0.45352226", "0.45142493", "0.45053923", "0.44999212", "0.4486818", "0.4445054", "0.4436313", "0.4425104", "0.4418272", "0.44075814", "0.4401054", "0.43764785", "0.43737286", "0.43682605", "0.436536", "0.43610534", "0.43575355", "0.43408513", "0.43406832", "0.43400154", "0.43217328", "0.43180564", "0.43092585", "0.43012592", "0.43002003", "0.42987776", "0.42955235", "0.42944512", "0.4293149", "0.42929438", "0.4291061", "0.42838728", "0.42660043", "0.42482883", "0.4244875", "0.42414537", "0.4226746", "0.42254525", "0.42223847", "0.4217103", "0.42115343", "0.42107135", "0.41986677", "0.41885808", "0.41868103", "0.4184197", "0.41818428", "0.41758832", "0.41758037", "0.41690114", "0.416023", "0.41554597", "0.41435686", "0.41289428", "0.4128559", "0.41216922", "0.41216272", "0.41200328", "0.4113929", "0.410661", "0.41063517" ]
0.7954848
0
Returns a Pattern that adds an ornamental pattern to a given note.
public static PatternInterface addOrnament(Pattern ornament, Note baseNote){ return addOrnament(ornament, baseNote, THIRTY_SECOND); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static PatternInterface graceNote(Note graceNote, Note baseNote, double graceNoteDuration){\r\n \tPattern gracePattern = new Pattern(graceNote.getMusicString());\r\n \treturn addOrnament(gracePattern, baseNote, graceNoteDuration);\r\n }", "public static PatternInterface addOrnament(Pattern ornament, Note baseNote, double longestOrnamentDuration){\r\n \tPatternInvestigator investigator = new PatternInvestigator();\r\n \tMusicStringParser stringParser = new MusicStringParser();\r\n \t\r\n \tstringParser.addParserListener(investigator);\r\n \tstringParser.parse(ornament);\r\n \t\r\n \tdouble longestDuration = investigator.getLongestDecimalDuration();\r\n \tdouble durationChange = longestOrnamentDuration / longestDuration;\r\n \t\r\n \tDurationPatternTransformer transformer = new DurationPatternTransformer(durationChange);\r\n \t\r\n \tPatternInterface result = transformer.transform(ornament);\r\n \t\r\n \tstringParser.removeParserListener(investigator);\r\n \tinvestigator = new PatternInvestigator();\r\n \tstringParser.addParserListener(investigator);\r\n \tstringParser.parse(result);\r\n \t\r\n \tif(investigator.getTotalDecimalDuration() < baseNote.getDecimalDuration()){\r\n \t\tdouble remainingDuration = baseNote.getDecimalDuration() - investigator.getTotalDecimalDuration();\r\n \t\tbaseNote.setDecimalDuration(remainingDuration);\r\n \t\tresult.add(baseNote.getMusicString());\r\n \t\treturn result;\r\n \t} else {\r\n \t\treturn new Pattern(baseNote.getMusicString());\r\n \t}\r\n }", "public static PatternInterface trill(Note baseNote){\r\n \treturn trill(baseNote, EFFECT_DIRECTION_UP);\r\n }", "public static PatternInterface graceNote(Note graceNote, Note baseNote){\r\n \treturn graceNote(graceNote, baseNote, THIRTY_SECOND);\r\n }", "public static PatternInterface trill(Note baseNote, char trillDirection){\r\n \treturn trill(baseNote, trillDirection, THIRTY_SECOND);\r\n }", "public static Note createNote(int octave, Pitch pitch, int startBeat, int endBeat) {\n return new NoteImpl(octave, pitch, startBeat, endBeat);\n }", "public XSSFPatternFormatting createPatternFormatting(){\n CTDxf dxf = getDxf(true);\n CTFill fill;\n if(!dxf.isSetFill()) {\n fill = dxf.addNewFill();\n } else {\n fill = dxf.getFill();\n }\n\n return new XSSFPatternFormatting(fill, _sh.getWorkbook().getStylesSource().getIndexedColors());\n }", "@Override\n public Pattern createPattern(Image image, String repeat) {\n return new Pattern(image, repeat);\n }", "public Note(int note, char accidental, Pane notePane) {\n _note = note;\n _accidental = accidental;\n _accidentalImage = new ImageView();\n this.setUpLedger();\n this.setUpNote();\n }", "AngleAdd createAngleAdd();", "public static Note createNote(int value, int startBeat, int endBeat) {\n return createNote((value / 12) - 1, Pitch.getPitch(value % 12), startBeat, endBeat);\n }", "public Note noteAt(int interval) {\n\t\tint newMidiNote = getMidiNumber() + interval;\n\t\t\n\t\treturn new Note(newMidiNote);\n\t}", "private NotePad() {\n }", "public static PatternInterface trill(Note baseNote, char trillDirection, double singleSoundDuration){\r\n \r\n \tStringBuilder musicStringBuilder = new StringBuilder();\r\n \r\n \tdouble totalDuration = baseNote.getDecimalDuration();\r\n double actualDuration = 0.0d;\r\n \r\n byte secondNote = baseNote.getValue();\r\n \r\n if(trillDirection == EFFECT_DIRECTION_UP){\r\n \tsecondNote++;\r\n } else if(trillDirection == EFFECT_DIRECTION_DOWN){\r\n \tsecondNote--;\r\n }\r\n \r\n double remainingDuration = totalDuration - (2*singleSoundDuration);\r\n if(remainingDuration > 0.0d){\r\n \t\r\n \tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \tactualDuration+=singleSoundDuration;\r\n \t\r\n \twhile(actualDuration < totalDuration){\r\n \t\tif(actualDuration + (2*singleSoundDuration) < totalDuration){\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, secondNote, singleSoundDuration);\r\n \t\t\tactualDuration += singleSoundDuration;\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \t\t\tactualDuration += singleSoundDuration;\r\n \t\t} else if(actualDuration + singleSoundDuration > totalDuration){\r\n \t\t\tdouble gapDuration = totalDuration - actualDuration;\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), gapDuration);\r\n \t\t\tactualDuration+=gapDuration;\r\n \t\t} else {\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \t\t\tactualDuration+=singleSoundDuration;\r\n \t\t}\r\n \t}\r\n \treturn new Pattern(musicStringBuilder.toString().trim());\r\n } else {\r\n \treturn new Pattern(baseNote.getMusicString());\r\n }\r\n }", "public RoundhousePatternMatcher(A_PatternMatcher parent) {\n super(parent, \"ROUNDHOUSE\");\n }", "public BoatPattern(final BorderRule rule) {\n super(3,3,rule);\n\n rowPositions = new int[]{1,0,2,1,2};\n colPositions = new int[]{0,1,1,2,2};\n }", "public Pattern buildPattern ()\n {\n int flags = 0;\n if ( this.canonicalEquivalence ) flags += Pattern.CANON_EQ;\n if ( this.caseInsensitive ) flags += Pattern.CASE_INSENSITIVE;\n if ( this.comments ) flags += Pattern.COMMENTS;\n if ( this.dotall ) flags += Pattern.DOTALL;\n if ( this.multiline ) flags += Pattern.MULTILINE;\n if ( this.unicodeCase ) flags += Pattern.UNICODE_CASE;\n if ( this.unixLines ) flags += Pattern.UNIX_LINES;\n return Pattern.compile(this.regex, flags);\n }", "public ImagePattern getImagePattern() {\n return new ImagePattern(new Image(this.texture));\n }", "public Pattern(Delta... pattern)\n {\n assert(pattern.length > 0);\n\n _pattern = pattern;\n _index = 0;\n }", "@Override\n public CreateLogPatternResult createLogPattern(CreateLogPatternRequest request) {\n request = beforeClientExecution(request);\n return executeCreateLogPattern(request);\n }", "public static Note createNote(int octave, Pitch pitch, int startBeat, int endBeat, int\n instrument, int volume) {\n return new NoteImpl(octave, pitch, startBeat, endBeat, instrument, volume);\n }", "public void drawPattern(){\n \t\tIntent intent = new Intent(this, LockPatternActivity.class);\n \t\tintent.putExtra(LockPatternActivity._Mode, LockPatternActivity.LPMode.CreatePattern);\n \t\tstartActivityForResult(intent, REQUEST_CREATE_PATTERN);\n \t}", "public static Note makeNote(int pitch, int octave) {\n if (octave < 0) {\n throw new IllegalArgumentException(\"Invalid octave parameter!\");\n }\n return new Note(Pitch.makePitch(pitch),octave,0);\n }", "CompositionBuilder<T> addNote(int start, int end, int instrument, int pitch, int volume);", "@Override\n\tpublic Wall MakeWall() {\n\t\treturn new RedWall();\n\t}", "private PatternExpression patternExpression(PatternExpression p, \n Expression exp)\n {\n exp = transform(exp);\n if (p instanceof PatternExpression.IdentifierPatternExp)\n {\n PatternExpression.IdentifierPatternExp p0 =\n (PatternExpression.IdentifierPatternExp)p;\n return new PatternExpression.IdentifierPatternExp(p0.ident, exp);\n }\n if (p instanceof PatternExpression.ApplicationPatternExp)\n {\n PatternExpression.ApplicationPatternExp p0 =\n (PatternExpression.ApplicationPatternExp)p;\n List<AST.Parameter> params =\n new ArrayList<AST.Parameter>(Arrays.asList(p0.params));\n return new PatternExpression.ApplicationPatternExp(p0.ident, params, exp);\n }\n return new PatternExpression.DefaultPatternExp(exp);\n }", "public abstract Anuncio creaAnuncioTematico();", "public Asteroid makeAsteroid() {\r\n\t\tAsteroid asteroid = new AsteroidImpl(startBounds.x, random(startBounds.y,startBounds.height)\r\n\t\t\t\t\t\t\t\t\t\t\t, random(10,40), random(10,40)\r\n\t\t\t\t\t\t\t\t\t\t\t, random(1,4));\r\n\t\treturn asteroid;\r\n\t}", "public static Notes getInstance(PresentationNotesElement noteElement) {\n\t\tPresentationDocument ownerDocument = (PresentationDocument) ((OdfFileDom) (noteElement.getOwnerDocument()))\n\t\t\t\t.getDocument();\n\t\treturn ownerDocument.getNotesBuilder().getNotesInstance(noteElement);\n\n\t}", "@Override\n public Animal createAnimal() {\n return new Monkey();\n }", "public Drawable getPatternDrawable() {\n return patternDrawable;\n }", "QuoteNote createQuoteNote();", "AngleSmaller createAngleSmaller();", "public AbstractShape create(ShapeType type) {\n if(type == TrominoType.I) {\n return new TrominoI();\n }\n if(type == TrominoType.J) {\n return new TrominoJ();\n }\n if(type == TrominoType.L) {\n return new TrominoL();\n }\n\n throw new IllegalArgumentException(String.format(\"Unknown how to create shape: %s.\", type.toString()));\n }", "public Note() {\n\t\tsuper();\n\t}", "ImagePlus addPeriRadii(ImagePlus tempImage,double[] marrowCenter,Vector<Integer> pindColor, double[] R, double[] Theta){\r\n \t\t//Draw unrotated radii\r\n \t\tfor(int i = 0; i< Theta.length;i++) {//45;i++) {//\r\n \t\t\tint x = ((int) (marrowCenter[0]+R[i]*Math.cos(Theta[i])));\r\n \t\t\tint y = ((int) (marrowCenter[1]+R[i]*Math.sin(Theta[i])));\r\n \t\t\tdouble colorScale = ((double) pindColor.get(i))/359.0;\r\n \t\t\ttempImage.getProcessor().setColor(new Color(0,(int) (255.0*colorScale),(int) (255.0*(1.0-colorScale))));\r\n \t\t\ttempImage.getProcessor().drawPixel(x,y);\r\n \t\t}\r\n \t\treturn tempImage;\r\n \t}", "public TrianglePatternToy(int number){ \n this.number = number;\n }", "public LineInspector(final Pattern p) {\n pattern = p;\n }", "protected Token newToken(TokenPattern pattern,\n String image,\n int line,\n int column) {\n\n return new Token(pattern, image, line, column);\n }", "Angle createAngle();", "public abstract Pattern copy();", "@Override\n public void setBackgroundPattern(Pattern pattern) {\n }", "public Note() {\n //uig = new UniqueIdGenerator();\n noteId = UUIDGenerator.getUUID();\n created_on = new Date();\n }", "public synchronized OrbitRelatedUniformEventPattern getPattern() {\n\t\tif (pattern == null) {\n\t\t\tpattern = obtainPattern();\n\t\t}\n\t\treturn pattern;\n\t}", "public void addPattern(TokenPattern pattern) throws Exception {\n TokenPattern[] temp = patterns;\n\n patterns = new TokenPattern[temp.length + 1];\n System.arraycopy(temp, 0, patterns, 0, temp.length);\n patterns[temp.length] = pattern;\n }", "public void createTestPattern()\n {\n int i;\n int j;\n RGBPixel p = new RGBPixel();\n\n for ( i = 0; i < getXSize(); i++ ) {\n for ( j = 0; j < getYSize(); j++ ) {\n if ( ((i % 2 != 0) && (j % 2 == 0)) || \n ((j % 2 != 0) && (i % 2 == 0)) ) {\n p.r = (byte)255;\n p.g = (byte)255;\n p.b = (byte)255;\n }\n else {\n p.r = 0;\n p.g = 0;\n p.b = 0;\n }\n if ( j == getYSize()/2 ) {\n p.r = (byte)255;\n p.g = 0;\n p.b = 0;\n }\n if ( i == getXSize()/2) {\n p.r = 0;\n p.g = (byte)255;\n p.b = 0;\n }\n putPixelRgb(i, j, p);\n }\n }\n }", "private void setUpNote() {\n _noteHead = new Ellipse(Constants.NOTE_HEAD_WIDTH, Constants.NOTE_HEAD_HEIGHT);\n _noteHead.setFill(Color.WHITE);\n _noteHead.setStroke(Color.BLACK);\n _noteHead.setStrokeWidth(Constants.STROKE_WIDTH);\n _noteHead.setCenterX(Constants.NOTE_X_LOC);\n // switch statement for the note value that was passed in\n switch (_note) {\n case 0:\n _noteHead.setCenterY(Constants.C4_LOCATION);\n _ledgerLine.setStartX(Constants.NOTE_X_LOC - Constants.LEDGER_LINE_WIDTH/2);\n _ledgerLine.setEndX(Constants.NOTE_X_LOC + Constants.LEDGER_LINE_WIDTH/2);\n _ledgerLine.setStartY(Constants.C4_LOCATION);\n _ledgerLine.setEndY(Constants.C4_LOCATION);\n break;\n case 1:\n if (_accidental == 's') {\n _noteHead.setCenterY(Constants.C4_LOCATION);\n _ledgerLine.setStartX(Constants.NOTE_X_LOC - Constants.LEDGER_LINE_WIDTH/2);\n _ledgerLine.setEndX(Constants.NOTE_X_LOC + Constants.LEDGER_LINE_WIDTH/2);\n _ledgerLine.setStartY(Constants.C4_LOCATION);\n _ledgerLine.setEndY(Constants.C4_LOCATION);\n this.setUpSharp();\n break;\n }\n else {\n _noteHead.setCenterY(Constants.D4_LOCATION); \n this.setUpFlat();\n break;\n }\n case 2:\n _noteHead.setCenterY(Constants.D4_LOCATION);\n break;\n case 3: \n if (_accidental == 's') {\n _noteHead.setCenterY(Constants.D4_LOCATION);\n this.setUpSharp();\n break;\n }\n else {\n _noteHead.setCenterY(Constants.E4_LOCATION);\n _staffLine.setStartX(Constants.NOTE_X_LOC - Constants.STAFF_LINE_WIDTH/2);\n _staffLine.setEndX(Constants.NOTE_X_LOC + Constants.STAFF_LINE_WIDTH/2); \n _staffLine.setStartY(Constants.E4_LOCATION);\n _staffLine.setEndY(Constants.E4_LOCATION);\n this.setUpFlat();\n break;\n }\n case 4:\n _noteHead.setCenterY(Constants.E4_LOCATION);\n _staffLine.setStartX(Constants.NOTE_X_LOC - Constants.STAFF_LINE_WIDTH/2);\n _staffLine.setEndX(Constants.NOTE_X_LOC + Constants.STAFF_LINE_WIDTH/2); \n _staffLine.setStartY(Constants.E4_LOCATION);\n _staffLine.setEndY(Constants.E4_LOCATION);\n break;\n case 5:\n _noteHead.setCenterY(Constants.F4_LOCATION);\n break;\n case 6:\n if (_accidental == 's') {\n _noteHead.setCenterY(Constants.F4_LOCATION);\n this.setUpSharp();\n break;\n }\n else {\n _noteHead.setCenterY(Constants.G4_LOCATION);\n _staffLine.setStartX(Constants.NOTE_X_LOC - Constants.STAFF_LINE_WIDTH/2);\n _staffLine.setEndX(Constants.NOTE_X_LOC + Constants.STAFF_LINE_WIDTH/2); \n _staffLine.setStartY(Constants.G4_LOCATION);\n _staffLine.setEndY(Constants.G4_LOCATION);\n this.setUpFlat();\n break;\n }\n case 7:\n _noteHead.setCenterY(Constants.G4_LOCATION);\n _staffLine.setStartX(Constants.NOTE_X_LOC - Constants.STAFF_LINE_WIDTH/2);\n _staffLine.setEndX(Constants.NOTE_X_LOC + Constants.STAFF_LINE_WIDTH/2); \n _staffLine.setStartY(Constants.G4_LOCATION);\n _staffLine.setEndY(Constants.G4_LOCATION);\n break;\n case 8:\n if (_accidental == 's') {\n _noteHead.setCenterY(Constants.G4_LOCATION);\n this.setUpSharp();\n break;\n }\n else {\n _noteHead.setCenterY(Constants.A4_LOCATION);\n this.setUpFlat();\n break;\n } \n case 9:\n _noteHead.setCenterY(Constants.A4_LOCATION);\n break;\n case 10:\n if (_accidental == 's') {\n _noteHead.setCenterY(Constants.A4_LOCATION);\n this.setUpSharp();\n break;\n }\n else {\n _noteHead.setCenterY(Constants.B4_LOCATION);\n _staffLine.setStartX(Constants.NOTE_X_LOC - Constants.STAFF_LINE_WIDTH/2);\n _staffLine.setEndX(Constants.NOTE_X_LOC + Constants.STAFF_LINE_WIDTH/2); \n _staffLine.setStartY(Constants.B4_LOCATION);\n _staffLine.setEndY(Constants.B4_LOCATION);\n this.setUpFlat();\n break;\n } \n case 11:\n _noteHead.setCenterY(Constants.B4_LOCATION);\n _staffLine.setStartX(Constants.NOTE_X_LOC - Constants.STAFF_LINE_WIDTH/2);\n _staffLine.setEndX(Constants.NOTE_X_LOC + Constants.STAFF_LINE_WIDTH/2); \n _staffLine.setStartY(Constants.B4_LOCATION);\n _staffLine.setEndY(Constants.B4_LOCATION);\n break;\n \n }\n }", "private ParticleMesh createAstroidTrail(final Spatial asteroidmodel) {\r\n ParticleMesh pMesh = ParticleFactory.buildParticles(\"tail\", 180,\r\n ParticleType.Quad);\r\n pMesh.setEmissionDirection(new Vector3f(1, 1, 1));\r\n pMesh.setOriginOffset(new Vector3f(0, 0, 0));\r\n pMesh.setInitialVelocity(0.005f);\r\n pMesh.setStartSize(50);\r\n pMesh.setEndSize(1);\r\n pMesh.setMinimumLifeTime(5000f);\r\n pMesh.setMaximumLifeTime(7000f);\r\n pMesh.setStartColor(new ColorRGBA(0.5f, 0.5f, 1, 0.5f));\r\n pMesh.setParticleSpinSpeed(180 * FastMath.DEG_TO_RAD);\r\n pMesh.setGeometry((Geometry)asteroidmodel);\r\n pMesh.getParticleController().setControlFlow(false);\r\n \r\n pMesh.forceRespawn();\r\n \r\n pMesh.setModelBound(new BoundingBox());\r\n pMesh.updateModelBound();\r\n pMesh.setCullHint(Spatial.CullHint.Never);\r\n\r\n // removes the asteroid from the scene after the particle trail has died\r\n pMesh.getParticleController().addListener(new OnDeadListener());\r\n \r\n pMesh.setRenderState(ts);\r\n pMesh.setRenderState(bs);\r\n pMesh.setRenderState(zs);\r\n \r\n asteroidTrails.add(pMesh);\r\n \r\n return pMesh;\r\n }", "public static Note createNote(int value, int startBeat, int endBeat, int instrument, int\n volume) {\n return createNote((value / 12) - 1, Pitch.getPitch(value % 12), startBeat, endBeat, instrument,\n volume);\n }", "public static TriplePattern createTriplePatternFromJSON(final JSONObject triplePatternJson) throws JSONException {\n\t\tfinal JSONArray itemsJson = (JSONArray) triplePatternJson.get(\"triple_pattern\");\n\t\tfinal Item[] items = new Item[3];\n\t\tfor (int h = 0; h < 3; h++) {\n\t\t\titems[h] = Helper.createItemFromJSON(itemsJson.getJSONObject(h));\n\t\t}\n\t\treturn new TriplePattern(items[0], items[1], items[2]);\n\t}", "AngleResource inclination();", "public Pattern( PatternAnalyser patternAnalyser ) {\n this.patternAnalyser = patternAnalyser;\n }", "@Override\n\tpublic AbstractOriental createOrientale() {\n\t\treturn new OrientalSN();\n\t}", "public Note addNote(String title, String text) {\n Note newNote = new Note(title, text);\n notes.add(newNote); //add to ArrayList\n return newNote;\n }", "public WellFormTemplate(){\n \tpatternIndex = 0;\n }", "@Override\n public Drawable mutate() {\n return patternDrawable.mutate();\n }", "private Entry createEntry(String pattern) {\n\t\tEntry entry = null;\n\n\t\tif (pattern != null) {\n\t\t\tString item = pattern.trim();\n\t\t\tif (item.length() > 0) {\n\t\t\t\tentry = new Entry();\n\t\t\t\tentry.result = !item.startsWith(\"-\");\n\t\t\t\tentry.partial = item.endsWith(\".\");\n\t\t\t\tentry.classpath = entry.result ? item : item.substring(1).trim();\n\t\t\t}\n\t\t}\n\t\treturn entry;\n\t}", "public void InsertPattern( Pattern aPattern ){\r\n\t\t\tPattern newPattern = new Pattern(this.csv);\r\n\t\t\tnewPattern.CopyPattern(aPattern);\r\n\t\t\tif( this.isEmpty() ) {\r\n\t\t\t\tFirst = newPattern;\r\n\t\t\t\tLast = newPattern; \r\n\t\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tLast.Next = newPattern;\r\n\t\t\t\tLast = newPattern; \r\n\t\t\t\t}\r\n\t\t\t}", "private Pitch(String note)\n {\n this.note = note;\n }", "public WeekPattern() {}", "protected static Pattern newPattern(\n String pattern\n ){\n return pattern == null ? null : Pattern.compile(\n \"^\" + pattern.replaceAll(\"\\\\*\\\\*\", \".\\t\").replaceAll(\"\\\\*\", \"[^/]*\").replace('\\t', '*') + \"$\"\n );\n }", "@Override\n public JSLFrame editPatch(Patch p) {\n return new RolandMT32RhythmSetupTempEditor(p);\n }", "void crear(Tonelaje tonelaje);", "public void addPattern(TokenPattern pattern) throws Exception {\n automaton.addMatch(pattern.getPattern(), ignoreCase, pattern);\n super.addPattern(pattern);\n }", "@Test\n\tpublic void aPatternCanEndWithAComma() {\n\t\tfinal Tokenizable line = line(\"(Cons { head: 0, })\");\n\t\tcontext.checking(new Expectations() {{\n\t\t\toneOf(builder).accept(with(CtorPatternMatcher.ctor(\"Cons\").field(\"head\", ConstPatternMatcher.number(0))));\n\t\t}});\n\t\tTDAPatternParser parser = new TDAPatternParser(errors, vnamer, builder, topLevel);\n\t\tTDAParsing canContinue = parser.tryParsing(line);\n\t\tassertNotNull(canContinue);\n\t\tassertNull(parser.tryParsing(line));\n\t}", "public Note() {\n }", "public FormatInteger asteriskFill(){\n fillCharacter = ASTERISK_CHAR;\n return this;\n }", "protected AnchorPane makeAnchorPane() {\n return new AnchorPane();\n }", "@Override\n\tpublic synchronized Arc addArc(Transition t, Place p, int weight) {\n\t\treturn this.addArcPrivate(t, p, weight);\n\t}", "public GeneralPath createArrowHeads() {\n return OMArrowHead.createArrowHeads(OMArrowHead.ARROWHEAD_DIRECTION_FORWARD,\n 100,\n this,\n OMArrowHead.DEFAULT_WINGTIP,\n OMArrowHead.DEFAULT_WINGLENGTH);\n }", "public Asteroid() {\n setShape(new Polygon(astx, asty, astx.length));\n setAlive(true);\n setColor(new Color(160, 82, 45));\n }", "public static Note add(final Note noteToAdd) {\n try {\r\n // Simulate time for network request.\r\n Thread.sleep(5000);\r\n } catch (Exception e) {\r\n // Just for test purposes so handling error doesn't matter.\r\n }\r\n noteToAdd.setId(4);\r\n return noteToAdd;\r\n }", "public S create() {\n\t\tS style = createDefault();\n\t\tint id = nextID();\n\t\tstyle.setId(id);\n\t\taddStyle(style);\n\t\treturn style;\n\t}", "public Pattern(Collection<Delta> pattern)\n {\n assert(! pattern.isEmpty());\n\n _pattern = (Delta[]) pattern.toArray();\n _index = 0;\n }", "@Override\n public void addNote(Note n) {\n if (this.sheet.size() < n.getDuration() + n.getStartMeasure()) {\n for (int i = this.sheet.size(); i < n.getDuration() + n.getStartMeasure(); i++) {\n sheet.add(new HashSet<>());\n }\n }\n for (int i = 0; i < n.getDuration(); i++) {\n for (Note t : this.sheet.get(i + n.getStartMeasure())) {\n if (t.equals(n)) {\n throw new IllegalArgumentException(\"Already placed a note.\");\n }\n }\n }\n this.sheet.get(n.getStartMeasure()).add(n);\n int currentMeasure = n.getStartMeasure() + 1;\n for (int i = 1; i < n.getDuration(); i++) {\n Note hold = new Note(1, n.getOctave(), currentMeasure,\n n.getPitch(), false, n.getInstrument(), n.getVolume());\n this.sheet.get(currentMeasure).add(hold);\n currentMeasure++;\n }\n\n this.high = this.getHighest();\n this.low = this.getLowest();\n }", "WithCreate withNotes(String notes);", "public Path2D asAwtShape() {\n\t\t// creates the awt path\n\t\tPath2D.Double path = new Path2D.Double();\n\t\t\n\t\t// iterate on the path segments\n\t\tfor (Segment seg : this.segments) {\n\t\t\tseg.updatePath(path);\n\t\t}\n\t\t\n\t\t// returns the updated path\n\t\treturn path;\n\t}", "public Pattern getPattern() {\n return pattern;\n }", "public Pattern getHorizPattern() {\n\t\treturn horizPattern;\n\t}", "Turtle createTurtle();", "public referential.store.v2.WeekPattern.Builder clearPatternId() {\n patternId = null;\n fieldSetFlags()[0] = false;\n return this;\n }", "public MovePattern(ChessPiece owner){\n\t\tthis.owner= owner;\n\t\tcommandSequences = new ArrayList< MoveSequence>();\n\t\tdependentSpaces= new Stack<ChessSpace>();\n\t\tif(owner != null)\n\t\t\towner.addMoves(this);\n\t}", "@Override\n public void highlightPattern(Optional<Pattern> newPattern) {\n update();\n }", "public Pattern getPattern(){\n\t\treturn pattern;\n\t}", "@Override\r\n\tprotected void initShape() {\n\t\tgetPositions().putAll(createSymmetricLines(0, 1.5, .5, 1.1, WingPart.OUTER_LEFT, WingPart.OUTER_RIGHT));\r\n\t\t//->upper corner\r\n\t\tgetPositions().putAll(createSymmetricLines(.5, 1.1, 1, .7, WingPart.OUTER_LEFT, WingPart.OUTER_RIGHT));\r\n\t\t//-> lower outer corner\r\n\t\tgetPositions().putAll(createSymmetricLines(1, .7, 1.1, .3, WingPart.OUTER_LEFT, WingPart.OUTER_RIGHT));\r\n\t\t//-> lower inner corner\r\n\t\tgetPositions().putAll(createSymmetricLines(1.1, .3, .7, .25, WingPart.OUTER_LEFT, WingPart.OUTER_RIGHT));\r\n\t\t//-> middle\r\n\t\tgetPositions().putAll(createSymmetricLines(.7, .25, .2, 1.35, WingPart.OUTER_LEFT, WingPart.OUTER_RIGHT));\r\n\t\t//inner\r\n\t\tgetPositions().putAll(createSymmetricLines(1, .5, .55, 0.95, WingPart.INNER_LEFT, WingPart.INNER_RIGHT));\r\n\t\tgetPositions().putAll(createSymmetricLines(0.8, .4, .55, 0.95, WingPart.INNER_LEFT, WingPart.INNER_RIGHT));\r\n\t\tgetPositions().putAll(createSymmetricPoints(0.9, .5, WingPart.INNER_LEFT, WingPart.INNER_RIGHT));\r\n\r\n//\t\tgetPositions().putAll(fill(WingPart.OUTER_RIGHT, WingPart.INNER_RIGHT));\r\n//\t\tgetPositions().putAll(fill(WingPart.OUTER_LEFT, WingPart.INNER_LEFT));\r\n\t}", "public static OngoingReadingWithoutWhere optionalMatch(PatternElement... pattern) {\n\n\t\treturn Statement.builder().optionalMatch(pattern);\n\t}", "@Override\n public Shape getShape() {\n myPencil.moveTo(getStartPoint().getX(), getStartPoint().getY());\n myPencil.lineTo(getEndPoint().getX(), getEndPoint().getY());\n setStartPoint(getEndPoint());\n \n return myPencil;\n }", "Border createBorder();", "public Note(char n, int dur) {\n\t\tnote = n;\n\t\tduration = dur;\n\t}", "@Override\n\tpublic AbstractReine createReine() {\n\t\treturn new ReineSN();\n\t}", "Appearance lineApp() {\n\t\tAppearance app = new Appearance();\n\t\tapp.setPolygonAttributes(\n\t\t\tnew PolygonAttributes(\n\t\t\t\tPolygonAttributes.POLYGON_LINE,\n\t\t\t\tPolygonAttributes.CULL_NONE,\n\t\t\t\t0f));\n\t\treturn app;\n\t}", "public Note(int noteNumber, int instrument) {\n this.octave = (noteNumber / 12) - 1;\n this.pitch = Pitch.pitchFromNumber(noteNumber - (this.octave * 12));\n this.instrument = instrument;\n }", "AnalogPin createAnalogPin();", "@Override\n public Region getTransparentRegion() {\n return patternDrawable.getTransparentRegion();\n }", "Shape createShape(BorderType borderType);", "AngleSubtract createAngleSubtract();", "public static synchronized void createPatternImage(String... args) {\n if(args.length < 1) {\n return;\n }\n\n reset();\n currentPattern = PatternReader.readPattern(args);\n createPatternImage(currentPattern, null);\n }", "public static Paint newSurroundingAreaOverlayPaint() {\n\n final Paint paint = new Paint();\n paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));\n paint.setAntiAlias(true);\n\n return paint;\n }", "@Override\r\n\tpublic Wall createWall() throws UnsupportedOperationException\r\n\t{\r\n\t\treturn new Wall();\r\n\t}", "public static Fragment newInstance(NacAlarm alarm)\n\t{\n\t\tFragment fragment = new NacRingtoneFragment();\n\t\tBundle bundle = NacBundle.toBundle(alarm);\n\n\t\tfragment.setArguments(bundle);\n\n\t\treturn fragment;\n\t}" ]
[ "0.6104616", "0.60510993", "0.56812996", "0.5457296", "0.51755905", "0.51122", "0.51016265", "0.50102264", "0.49597403", "0.48599017", "0.4847719", "0.4820585", "0.47906962", "0.47835672", "0.47187015", "0.4655826", "0.4654343", "0.4609058", "0.45632398", "0.4561452", "0.45253992", "0.45020375", "0.44421285", "0.44326648", "0.43884397", "0.43767792", "0.43610266", "0.43584883", "0.43317997", "0.43274814", "0.4324545", "0.4306746", "0.43061727", "0.4304182", "0.42876068", "0.42751876", "0.4268919", "0.42547086", "0.4249687", "0.42359012", "0.4235473", "0.42317486", "0.4227359", "0.42243353", "0.4219099", "0.4209674", "0.42055917", "0.42019185", "0.41885468", "0.41840866", "0.4166627", "0.41552773", "0.41513687", "0.41406584", "0.41385397", "0.41384166", "0.41244072", "0.4119333", "0.41020626", "0.40959525", "0.4083009", "0.40742314", "0.40637743", "0.40599516", "0.40576568", "0.40554813", "0.4053385", "0.4052721", "0.40517527", "0.40364406", "0.40314004", "0.40237144", "0.4023138", "0.40223718", "0.40183765", "0.40162677", "0.4016062", "0.40159303", "0.40143305", "0.40036377", "0.4003265", "0.39949027", "0.39935914", "0.39918333", "0.39894602", "0.3985592", "0.39819694", "0.3971025", "0.3965595", "0.39610076", "0.39556938", "0.39555392", "0.39449188", "0.39433107", "0.39365026", "0.39300007", "0.3922981", "0.39194062", "0.3917498", "0.3916732" ]
0.6694641
0
Returns a Pattern that adds an ornamental pattern to a given note.
public static PatternInterface addOrnament(Pattern ornament, Note baseNote, double longestOrnamentDuration){ PatternInvestigator investigator = new PatternInvestigator(); MusicStringParser stringParser = new MusicStringParser(); stringParser.addParserListener(investigator); stringParser.parse(ornament); double longestDuration = investigator.getLongestDecimalDuration(); double durationChange = longestOrnamentDuration / longestDuration; DurationPatternTransformer transformer = new DurationPatternTransformer(durationChange); PatternInterface result = transformer.transform(ornament); stringParser.removeParserListener(investigator); investigator = new PatternInvestigator(); stringParser.addParserListener(investigator); stringParser.parse(result); if(investigator.getTotalDecimalDuration() < baseNote.getDecimalDuration()){ double remainingDuration = baseNote.getDecimalDuration() - investigator.getTotalDecimalDuration(); baseNote.setDecimalDuration(remainingDuration); result.add(baseNote.getMusicString()); return result; } else { return new Pattern(baseNote.getMusicString()); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static PatternInterface addOrnament(Pattern ornament, Note baseNote){\r\n \treturn addOrnament(ornament, baseNote, THIRTY_SECOND);\r\n }", "public static PatternInterface graceNote(Note graceNote, Note baseNote, double graceNoteDuration){\r\n \tPattern gracePattern = new Pattern(graceNote.getMusicString());\r\n \treturn addOrnament(gracePattern, baseNote, graceNoteDuration);\r\n }", "public static PatternInterface trill(Note baseNote){\r\n \treturn trill(baseNote, EFFECT_DIRECTION_UP);\r\n }", "public static PatternInterface graceNote(Note graceNote, Note baseNote){\r\n \treturn graceNote(graceNote, baseNote, THIRTY_SECOND);\r\n }", "public static PatternInterface trill(Note baseNote, char trillDirection){\r\n \treturn trill(baseNote, trillDirection, THIRTY_SECOND);\r\n }", "public static Note createNote(int octave, Pitch pitch, int startBeat, int endBeat) {\n return new NoteImpl(octave, pitch, startBeat, endBeat);\n }", "public XSSFPatternFormatting createPatternFormatting(){\n CTDxf dxf = getDxf(true);\n CTFill fill;\n if(!dxf.isSetFill()) {\n fill = dxf.addNewFill();\n } else {\n fill = dxf.getFill();\n }\n\n return new XSSFPatternFormatting(fill, _sh.getWorkbook().getStylesSource().getIndexedColors());\n }", "@Override\n public Pattern createPattern(Image image, String repeat) {\n return new Pattern(image, repeat);\n }", "public Note(int note, char accidental, Pane notePane) {\n _note = note;\n _accidental = accidental;\n _accidentalImage = new ImageView();\n this.setUpLedger();\n this.setUpNote();\n }", "AngleAdd createAngleAdd();", "public static Note createNote(int value, int startBeat, int endBeat) {\n return createNote((value / 12) - 1, Pitch.getPitch(value % 12), startBeat, endBeat);\n }", "public Note noteAt(int interval) {\n\t\tint newMidiNote = getMidiNumber() + interval;\n\t\t\n\t\treturn new Note(newMidiNote);\n\t}", "private NotePad() {\n }", "public static PatternInterface trill(Note baseNote, char trillDirection, double singleSoundDuration){\r\n \r\n \tStringBuilder musicStringBuilder = new StringBuilder();\r\n \r\n \tdouble totalDuration = baseNote.getDecimalDuration();\r\n double actualDuration = 0.0d;\r\n \r\n byte secondNote = baseNote.getValue();\r\n \r\n if(trillDirection == EFFECT_DIRECTION_UP){\r\n \tsecondNote++;\r\n } else if(trillDirection == EFFECT_DIRECTION_DOWN){\r\n \tsecondNote--;\r\n }\r\n \r\n double remainingDuration = totalDuration - (2*singleSoundDuration);\r\n if(remainingDuration > 0.0d){\r\n \t\r\n \tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \tactualDuration+=singleSoundDuration;\r\n \t\r\n \twhile(actualDuration < totalDuration){\r\n \t\tif(actualDuration + (2*singleSoundDuration) < totalDuration){\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, secondNote, singleSoundDuration);\r\n \t\t\tactualDuration += singleSoundDuration;\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \t\t\tactualDuration += singleSoundDuration;\r\n \t\t} else if(actualDuration + singleSoundDuration > totalDuration){\r\n \t\t\tdouble gapDuration = totalDuration - actualDuration;\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), gapDuration);\r\n \t\t\tactualDuration+=gapDuration;\r\n \t\t} else {\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \t\t\tactualDuration+=singleSoundDuration;\r\n \t\t}\r\n \t}\r\n \treturn new Pattern(musicStringBuilder.toString().trim());\r\n } else {\r\n \treturn new Pattern(baseNote.getMusicString());\r\n }\r\n }", "public RoundhousePatternMatcher(A_PatternMatcher parent) {\n super(parent, \"ROUNDHOUSE\");\n }", "public Pattern buildPattern ()\n {\n int flags = 0;\n if ( this.canonicalEquivalence ) flags += Pattern.CANON_EQ;\n if ( this.caseInsensitive ) flags += Pattern.CASE_INSENSITIVE;\n if ( this.comments ) flags += Pattern.COMMENTS;\n if ( this.dotall ) flags += Pattern.DOTALL;\n if ( this.multiline ) flags += Pattern.MULTILINE;\n if ( this.unicodeCase ) flags += Pattern.UNICODE_CASE;\n if ( this.unixLines ) flags += Pattern.UNIX_LINES;\n return Pattern.compile(this.regex, flags);\n }", "public BoatPattern(final BorderRule rule) {\n super(3,3,rule);\n\n rowPositions = new int[]{1,0,2,1,2};\n colPositions = new int[]{0,1,1,2,2};\n }", "public ImagePattern getImagePattern() {\n return new ImagePattern(new Image(this.texture));\n }", "public Pattern(Delta... pattern)\n {\n assert(pattern.length > 0);\n\n _pattern = pattern;\n _index = 0;\n }", "@Override\n public CreateLogPatternResult createLogPattern(CreateLogPatternRequest request) {\n request = beforeClientExecution(request);\n return executeCreateLogPattern(request);\n }", "public static Note createNote(int octave, Pitch pitch, int startBeat, int endBeat, int\n instrument, int volume) {\n return new NoteImpl(octave, pitch, startBeat, endBeat, instrument, volume);\n }", "public void drawPattern(){\n \t\tIntent intent = new Intent(this, LockPatternActivity.class);\n \t\tintent.putExtra(LockPatternActivity._Mode, LockPatternActivity.LPMode.CreatePattern);\n \t\tstartActivityForResult(intent, REQUEST_CREATE_PATTERN);\n \t}", "public static Note makeNote(int pitch, int octave) {\n if (octave < 0) {\n throw new IllegalArgumentException(\"Invalid octave parameter!\");\n }\n return new Note(Pitch.makePitch(pitch),octave,0);\n }", "CompositionBuilder<T> addNote(int start, int end, int instrument, int pitch, int volume);", "@Override\n\tpublic Wall MakeWall() {\n\t\treturn new RedWall();\n\t}", "private PatternExpression patternExpression(PatternExpression p, \n Expression exp)\n {\n exp = transform(exp);\n if (p instanceof PatternExpression.IdentifierPatternExp)\n {\n PatternExpression.IdentifierPatternExp p0 =\n (PatternExpression.IdentifierPatternExp)p;\n return new PatternExpression.IdentifierPatternExp(p0.ident, exp);\n }\n if (p instanceof PatternExpression.ApplicationPatternExp)\n {\n PatternExpression.ApplicationPatternExp p0 =\n (PatternExpression.ApplicationPatternExp)p;\n List<AST.Parameter> params =\n new ArrayList<AST.Parameter>(Arrays.asList(p0.params));\n return new PatternExpression.ApplicationPatternExp(p0.ident, params, exp);\n }\n return new PatternExpression.DefaultPatternExp(exp);\n }", "public abstract Anuncio creaAnuncioTematico();", "public Asteroid makeAsteroid() {\r\n\t\tAsteroid asteroid = new AsteroidImpl(startBounds.x, random(startBounds.y,startBounds.height)\r\n\t\t\t\t\t\t\t\t\t\t\t, random(10,40), random(10,40)\r\n\t\t\t\t\t\t\t\t\t\t\t, random(1,4));\r\n\t\treturn asteroid;\r\n\t}", "public static Notes getInstance(PresentationNotesElement noteElement) {\n\t\tPresentationDocument ownerDocument = (PresentationDocument) ((OdfFileDom) (noteElement.getOwnerDocument()))\n\t\t\t\t.getDocument();\n\t\treturn ownerDocument.getNotesBuilder().getNotesInstance(noteElement);\n\n\t}", "@Override\n public Animal createAnimal() {\n return new Monkey();\n }", "public Drawable getPatternDrawable() {\n return patternDrawable;\n }", "QuoteNote createQuoteNote();", "AngleSmaller createAngleSmaller();", "public AbstractShape create(ShapeType type) {\n if(type == TrominoType.I) {\n return new TrominoI();\n }\n if(type == TrominoType.J) {\n return new TrominoJ();\n }\n if(type == TrominoType.L) {\n return new TrominoL();\n }\n\n throw new IllegalArgumentException(String.format(\"Unknown how to create shape: %s.\", type.toString()));\n }", "public Note() {\n\t\tsuper();\n\t}", "ImagePlus addPeriRadii(ImagePlus tempImage,double[] marrowCenter,Vector<Integer> pindColor, double[] R, double[] Theta){\r\n \t\t//Draw unrotated radii\r\n \t\tfor(int i = 0; i< Theta.length;i++) {//45;i++) {//\r\n \t\t\tint x = ((int) (marrowCenter[0]+R[i]*Math.cos(Theta[i])));\r\n \t\t\tint y = ((int) (marrowCenter[1]+R[i]*Math.sin(Theta[i])));\r\n \t\t\tdouble colorScale = ((double) pindColor.get(i))/359.0;\r\n \t\t\ttempImage.getProcessor().setColor(new Color(0,(int) (255.0*colorScale),(int) (255.0*(1.0-colorScale))));\r\n \t\t\ttempImage.getProcessor().drawPixel(x,y);\r\n \t\t}\r\n \t\treturn tempImage;\r\n \t}", "public TrianglePatternToy(int number){ \n this.number = number;\n }", "public LineInspector(final Pattern p) {\n pattern = p;\n }", "protected Token newToken(TokenPattern pattern,\n String image,\n int line,\n int column) {\n\n return new Token(pattern, image, line, column);\n }", "Angle createAngle();", "public abstract Pattern copy();", "@Override\n public void setBackgroundPattern(Pattern pattern) {\n }", "public Note() {\n //uig = new UniqueIdGenerator();\n noteId = UUIDGenerator.getUUID();\n created_on = new Date();\n }", "public synchronized OrbitRelatedUniformEventPattern getPattern() {\n\t\tif (pattern == null) {\n\t\t\tpattern = obtainPattern();\n\t\t}\n\t\treturn pattern;\n\t}", "public void addPattern(TokenPattern pattern) throws Exception {\n TokenPattern[] temp = patterns;\n\n patterns = new TokenPattern[temp.length + 1];\n System.arraycopy(temp, 0, patterns, 0, temp.length);\n patterns[temp.length] = pattern;\n }", "public void createTestPattern()\n {\n int i;\n int j;\n RGBPixel p = new RGBPixel();\n\n for ( i = 0; i < getXSize(); i++ ) {\n for ( j = 0; j < getYSize(); j++ ) {\n if ( ((i % 2 != 0) && (j % 2 == 0)) || \n ((j % 2 != 0) && (i % 2 == 0)) ) {\n p.r = (byte)255;\n p.g = (byte)255;\n p.b = (byte)255;\n }\n else {\n p.r = 0;\n p.g = 0;\n p.b = 0;\n }\n if ( j == getYSize()/2 ) {\n p.r = (byte)255;\n p.g = 0;\n p.b = 0;\n }\n if ( i == getXSize()/2) {\n p.r = 0;\n p.g = (byte)255;\n p.b = 0;\n }\n putPixelRgb(i, j, p);\n }\n }\n }", "private void setUpNote() {\n _noteHead = new Ellipse(Constants.NOTE_HEAD_WIDTH, Constants.NOTE_HEAD_HEIGHT);\n _noteHead.setFill(Color.WHITE);\n _noteHead.setStroke(Color.BLACK);\n _noteHead.setStrokeWidth(Constants.STROKE_WIDTH);\n _noteHead.setCenterX(Constants.NOTE_X_LOC);\n // switch statement for the note value that was passed in\n switch (_note) {\n case 0:\n _noteHead.setCenterY(Constants.C4_LOCATION);\n _ledgerLine.setStartX(Constants.NOTE_X_LOC - Constants.LEDGER_LINE_WIDTH/2);\n _ledgerLine.setEndX(Constants.NOTE_X_LOC + Constants.LEDGER_LINE_WIDTH/2);\n _ledgerLine.setStartY(Constants.C4_LOCATION);\n _ledgerLine.setEndY(Constants.C4_LOCATION);\n break;\n case 1:\n if (_accidental == 's') {\n _noteHead.setCenterY(Constants.C4_LOCATION);\n _ledgerLine.setStartX(Constants.NOTE_X_LOC - Constants.LEDGER_LINE_WIDTH/2);\n _ledgerLine.setEndX(Constants.NOTE_X_LOC + Constants.LEDGER_LINE_WIDTH/2);\n _ledgerLine.setStartY(Constants.C4_LOCATION);\n _ledgerLine.setEndY(Constants.C4_LOCATION);\n this.setUpSharp();\n break;\n }\n else {\n _noteHead.setCenterY(Constants.D4_LOCATION); \n this.setUpFlat();\n break;\n }\n case 2:\n _noteHead.setCenterY(Constants.D4_LOCATION);\n break;\n case 3: \n if (_accidental == 's') {\n _noteHead.setCenterY(Constants.D4_LOCATION);\n this.setUpSharp();\n break;\n }\n else {\n _noteHead.setCenterY(Constants.E4_LOCATION);\n _staffLine.setStartX(Constants.NOTE_X_LOC - Constants.STAFF_LINE_WIDTH/2);\n _staffLine.setEndX(Constants.NOTE_X_LOC + Constants.STAFF_LINE_WIDTH/2); \n _staffLine.setStartY(Constants.E4_LOCATION);\n _staffLine.setEndY(Constants.E4_LOCATION);\n this.setUpFlat();\n break;\n }\n case 4:\n _noteHead.setCenterY(Constants.E4_LOCATION);\n _staffLine.setStartX(Constants.NOTE_X_LOC - Constants.STAFF_LINE_WIDTH/2);\n _staffLine.setEndX(Constants.NOTE_X_LOC + Constants.STAFF_LINE_WIDTH/2); \n _staffLine.setStartY(Constants.E4_LOCATION);\n _staffLine.setEndY(Constants.E4_LOCATION);\n break;\n case 5:\n _noteHead.setCenterY(Constants.F4_LOCATION);\n break;\n case 6:\n if (_accidental == 's') {\n _noteHead.setCenterY(Constants.F4_LOCATION);\n this.setUpSharp();\n break;\n }\n else {\n _noteHead.setCenterY(Constants.G4_LOCATION);\n _staffLine.setStartX(Constants.NOTE_X_LOC - Constants.STAFF_LINE_WIDTH/2);\n _staffLine.setEndX(Constants.NOTE_X_LOC + Constants.STAFF_LINE_WIDTH/2); \n _staffLine.setStartY(Constants.G4_LOCATION);\n _staffLine.setEndY(Constants.G4_LOCATION);\n this.setUpFlat();\n break;\n }\n case 7:\n _noteHead.setCenterY(Constants.G4_LOCATION);\n _staffLine.setStartX(Constants.NOTE_X_LOC - Constants.STAFF_LINE_WIDTH/2);\n _staffLine.setEndX(Constants.NOTE_X_LOC + Constants.STAFF_LINE_WIDTH/2); \n _staffLine.setStartY(Constants.G4_LOCATION);\n _staffLine.setEndY(Constants.G4_LOCATION);\n break;\n case 8:\n if (_accidental == 's') {\n _noteHead.setCenterY(Constants.G4_LOCATION);\n this.setUpSharp();\n break;\n }\n else {\n _noteHead.setCenterY(Constants.A4_LOCATION);\n this.setUpFlat();\n break;\n } \n case 9:\n _noteHead.setCenterY(Constants.A4_LOCATION);\n break;\n case 10:\n if (_accidental == 's') {\n _noteHead.setCenterY(Constants.A4_LOCATION);\n this.setUpSharp();\n break;\n }\n else {\n _noteHead.setCenterY(Constants.B4_LOCATION);\n _staffLine.setStartX(Constants.NOTE_X_LOC - Constants.STAFF_LINE_WIDTH/2);\n _staffLine.setEndX(Constants.NOTE_X_LOC + Constants.STAFF_LINE_WIDTH/2); \n _staffLine.setStartY(Constants.B4_LOCATION);\n _staffLine.setEndY(Constants.B4_LOCATION);\n this.setUpFlat();\n break;\n } \n case 11:\n _noteHead.setCenterY(Constants.B4_LOCATION);\n _staffLine.setStartX(Constants.NOTE_X_LOC - Constants.STAFF_LINE_WIDTH/2);\n _staffLine.setEndX(Constants.NOTE_X_LOC + Constants.STAFF_LINE_WIDTH/2); \n _staffLine.setStartY(Constants.B4_LOCATION);\n _staffLine.setEndY(Constants.B4_LOCATION);\n break;\n \n }\n }", "private ParticleMesh createAstroidTrail(final Spatial asteroidmodel) {\r\n ParticleMesh pMesh = ParticleFactory.buildParticles(\"tail\", 180,\r\n ParticleType.Quad);\r\n pMesh.setEmissionDirection(new Vector3f(1, 1, 1));\r\n pMesh.setOriginOffset(new Vector3f(0, 0, 0));\r\n pMesh.setInitialVelocity(0.005f);\r\n pMesh.setStartSize(50);\r\n pMesh.setEndSize(1);\r\n pMesh.setMinimumLifeTime(5000f);\r\n pMesh.setMaximumLifeTime(7000f);\r\n pMesh.setStartColor(new ColorRGBA(0.5f, 0.5f, 1, 0.5f));\r\n pMesh.setParticleSpinSpeed(180 * FastMath.DEG_TO_RAD);\r\n pMesh.setGeometry((Geometry)asteroidmodel);\r\n pMesh.getParticleController().setControlFlow(false);\r\n \r\n pMesh.forceRespawn();\r\n \r\n pMesh.setModelBound(new BoundingBox());\r\n pMesh.updateModelBound();\r\n pMesh.setCullHint(Spatial.CullHint.Never);\r\n\r\n // removes the asteroid from the scene after the particle trail has died\r\n pMesh.getParticleController().addListener(new OnDeadListener());\r\n \r\n pMesh.setRenderState(ts);\r\n pMesh.setRenderState(bs);\r\n pMesh.setRenderState(zs);\r\n \r\n asteroidTrails.add(pMesh);\r\n \r\n return pMesh;\r\n }", "public static Note createNote(int value, int startBeat, int endBeat, int instrument, int\n volume) {\n return createNote((value / 12) - 1, Pitch.getPitch(value % 12), startBeat, endBeat, instrument,\n volume);\n }", "public static TriplePattern createTriplePatternFromJSON(final JSONObject triplePatternJson) throws JSONException {\n\t\tfinal JSONArray itemsJson = (JSONArray) triplePatternJson.get(\"triple_pattern\");\n\t\tfinal Item[] items = new Item[3];\n\t\tfor (int h = 0; h < 3; h++) {\n\t\t\titems[h] = Helper.createItemFromJSON(itemsJson.getJSONObject(h));\n\t\t}\n\t\treturn new TriplePattern(items[0], items[1], items[2]);\n\t}", "AngleResource inclination();", "public Pattern( PatternAnalyser patternAnalyser ) {\n this.patternAnalyser = patternAnalyser;\n }", "@Override\n\tpublic AbstractOriental createOrientale() {\n\t\treturn new OrientalSN();\n\t}", "public Note addNote(String title, String text) {\n Note newNote = new Note(title, text);\n notes.add(newNote); //add to ArrayList\n return newNote;\n }", "@Override\n public Drawable mutate() {\n return patternDrawable.mutate();\n }", "public WellFormTemplate(){\n \tpatternIndex = 0;\n }", "private Entry createEntry(String pattern) {\n\t\tEntry entry = null;\n\n\t\tif (pattern != null) {\n\t\t\tString item = pattern.trim();\n\t\t\tif (item.length() > 0) {\n\t\t\t\tentry = new Entry();\n\t\t\t\tentry.result = !item.startsWith(\"-\");\n\t\t\t\tentry.partial = item.endsWith(\".\");\n\t\t\t\tentry.classpath = entry.result ? item : item.substring(1).trim();\n\t\t\t}\n\t\t}\n\t\treturn entry;\n\t}", "public void InsertPattern( Pattern aPattern ){\r\n\t\t\tPattern newPattern = new Pattern(this.csv);\r\n\t\t\tnewPattern.CopyPattern(aPattern);\r\n\t\t\tif( this.isEmpty() ) {\r\n\t\t\t\tFirst = newPattern;\r\n\t\t\t\tLast = newPattern; \r\n\t\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tLast.Next = newPattern;\r\n\t\t\t\tLast = newPattern; \r\n\t\t\t\t}\r\n\t\t\t}", "private Pitch(String note)\n {\n this.note = note;\n }", "public WeekPattern() {}", "protected static Pattern newPattern(\n String pattern\n ){\n return pattern == null ? null : Pattern.compile(\n \"^\" + pattern.replaceAll(\"\\\\*\\\\*\", \".\\t\").replaceAll(\"\\\\*\", \"[^/]*\").replace('\\t', '*') + \"$\"\n );\n }", "@Override\n public JSLFrame editPatch(Patch p) {\n return new RolandMT32RhythmSetupTempEditor(p);\n }", "public void addPattern(TokenPattern pattern) throws Exception {\n automaton.addMatch(pattern.getPattern(), ignoreCase, pattern);\n super.addPattern(pattern);\n }", "void crear(Tonelaje tonelaje);", "@Test\n\tpublic void aPatternCanEndWithAComma() {\n\t\tfinal Tokenizable line = line(\"(Cons { head: 0, })\");\n\t\tcontext.checking(new Expectations() {{\n\t\t\toneOf(builder).accept(with(CtorPatternMatcher.ctor(\"Cons\").field(\"head\", ConstPatternMatcher.number(0))));\n\t\t}});\n\t\tTDAPatternParser parser = new TDAPatternParser(errors, vnamer, builder, topLevel);\n\t\tTDAParsing canContinue = parser.tryParsing(line);\n\t\tassertNotNull(canContinue);\n\t\tassertNull(parser.tryParsing(line));\n\t}", "public FormatInteger asteriskFill(){\n fillCharacter = ASTERISK_CHAR;\n return this;\n }", "public Note() {\n }", "@Override\n\tpublic synchronized Arc addArc(Transition t, Place p, int weight) {\n\t\treturn this.addArcPrivate(t, p, weight);\n\t}", "protected AnchorPane makeAnchorPane() {\n return new AnchorPane();\n }", "public GeneralPath createArrowHeads() {\n return OMArrowHead.createArrowHeads(OMArrowHead.ARROWHEAD_DIRECTION_FORWARD,\n 100,\n this,\n OMArrowHead.DEFAULT_WINGTIP,\n OMArrowHead.DEFAULT_WINGLENGTH);\n }", "public Asteroid() {\n setShape(new Polygon(astx, asty, astx.length));\n setAlive(true);\n setColor(new Color(160, 82, 45));\n }", "public S create() {\n\t\tS style = createDefault();\n\t\tint id = nextID();\n\t\tstyle.setId(id);\n\t\taddStyle(style);\n\t\treturn style;\n\t}", "public static Note add(final Note noteToAdd) {\n try {\r\n // Simulate time for network request.\r\n Thread.sleep(5000);\r\n } catch (Exception e) {\r\n // Just for test purposes so handling error doesn't matter.\r\n }\r\n noteToAdd.setId(4);\r\n return noteToAdd;\r\n }", "public Pattern(Collection<Delta> pattern)\n {\n assert(! pattern.isEmpty());\n\n _pattern = (Delta[]) pattern.toArray();\n _index = 0;\n }", "@Override\n public void addNote(Note n) {\n if (this.sheet.size() < n.getDuration() + n.getStartMeasure()) {\n for (int i = this.sheet.size(); i < n.getDuration() + n.getStartMeasure(); i++) {\n sheet.add(new HashSet<>());\n }\n }\n for (int i = 0; i < n.getDuration(); i++) {\n for (Note t : this.sheet.get(i + n.getStartMeasure())) {\n if (t.equals(n)) {\n throw new IllegalArgumentException(\"Already placed a note.\");\n }\n }\n }\n this.sheet.get(n.getStartMeasure()).add(n);\n int currentMeasure = n.getStartMeasure() + 1;\n for (int i = 1; i < n.getDuration(); i++) {\n Note hold = new Note(1, n.getOctave(), currentMeasure,\n n.getPitch(), false, n.getInstrument(), n.getVolume());\n this.sheet.get(currentMeasure).add(hold);\n currentMeasure++;\n }\n\n this.high = this.getHighest();\n this.low = this.getLowest();\n }", "public Pattern getPattern() {\n return pattern;\n }", "public Path2D asAwtShape() {\n\t\t// creates the awt path\n\t\tPath2D.Double path = new Path2D.Double();\n\t\t\n\t\t// iterate on the path segments\n\t\tfor (Segment seg : this.segments) {\n\t\t\tseg.updatePath(path);\n\t\t}\n\t\t\n\t\t// returns the updated path\n\t\treturn path;\n\t}", "WithCreate withNotes(String notes);", "public Pattern getHorizPattern() {\n\t\treturn horizPattern;\n\t}", "Turtle createTurtle();", "public referential.store.v2.WeekPattern.Builder clearPatternId() {\n patternId = null;\n fieldSetFlags()[0] = false;\n return this;\n }", "public MovePattern(ChessPiece owner){\n\t\tthis.owner= owner;\n\t\tcommandSequences = new ArrayList< MoveSequence>();\n\t\tdependentSpaces= new Stack<ChessSpace>();\n\t\tif(owner != null)\n\t\t\towner.addMoves(this);\n\t}", "@Override\n public void highlightPattern(Optional<Pattern> newPattern) {\n update();\n }", "public Pattern getPattern(){\n\t\treturn pattern;\n\t}", "@Override\r\n\tprotected void initShape() {\n\t\tgetPositions().putAll(createSymmetricLines(0, 1.5, .5, 1.1, WingPart.OUTER_LEFT, WingPart.OUTER_RIGHT));\r\n\t\t//->upper corner\r\n\t\tgetPositions().putAll(createSymmetricLines(.5, 1.1, 1, .7, WingPart.OUTER_LEFT, WingPart.OUTER_RIGHT));\r\n\t\t//-> lower outer corner\r\n\t\tgetPositions().putAll(createSymmetricLines(1, .7, 1.1, .3, WingPart.OUTER_LEFT, WingPart.OUTER_RIGHT));\r\n\t\t//-> lower inner corner\r\n\t\tgetPositions().putAll(createSymmetricLines(1.1, .3, .7, .25, WingPart.OUTER_LEFT, WingPart.OUTER_RIGHT));\r\n\t\t//-> middle\r\n\t\tgetPositions().putAll(createSymmetricLines(.7, .25, .2, 1.35, WingPart.OUTER_LEFT, WingPart.OUTER_RIGHT));\r\n\t\t//inner\r\n\t\tgetPositions().putAll(createSymmetricLines(1, .5, .55, 0.95, WingPart.INNER_LEFT, WingPart.INNER_RIGHT));\r\n\t\tgetPositions().putAll(createSymmetricLines(0.8, .4, .55, 0.95, WingPart.INNER_LEFT, WingPart.INNER_RIGHT));\r\n\t\tgetPositions().putAll(createSymmetricPoints(0.9, .5, WingPart.INNER_LEFT, WingPart.INNER_RIGHT));\r\n\r\n//\t\tgetPositions().putAll(fill(WingPart.OUTER_RIGHT, WingPart.INNER_RIGHT));\r\n//\t\tgetPositions().putAll(fill(WingPart.OUTER_LEFT, WingPart.INNER_LEFT));\r\n\t}", "public static OngoingReadingWithoutWhere optionalMatch(PatternElement... pattern) {\n\n\t\treturn Statement.builder().optionalMatch(pattern);\n\t}", "@Override\n public Shape getShape() {\n myPencil.moveTo(getStartPoint().getX(), getStartPoint().getY());\n myPencil.lineTo(getEndPoint().getX(), getEndPoint().getY());\n setStartPoint(getEndPoint());\n \n return myPencil;\n }", "Border createBorder();", "public Note(char n, int dur) {\n\t\tnote = n;\n\t\tduration = dur;\n\t}", "@Override\n\tpublic AbstractReine createReine() {\n\t\treturn new ReineSN();\n\t}", "Appearance lineApp() {\n\t\tAppearance app = new Appearance();\n\t\tapp.setPolygonAttributes(\n\t\t\tnew PolygonAttributes(\n\t\t\t\tPolygonAttributes.POLYGON_LINE,\n\t\t\t\tPolygonAttributes.CULL_NONE,\n\t\t\t\t0f));\n\t\treturn app;\n\t}", "public Note(int noteNumber, int instrument) {\n this.octave = (noteNumber / 12) - 1;\n this.pitch = Pitch.pitchFromNumber(noteNumber - (this.octave * 12));\n this.instrument = instrument;\n }", "AnalogPin createAnalogPin();", "@Override\n public Region getTransparentRegion() {\n return patternDrawable.getTransparentRegion();\n }", "Shape createShape(BorderType borderType);", "AngleSubtract createAngleSubtract();", "public static synchronized void createPatternImage(String... args) {\n if(args.length < 1) {\n return;\n }\n\n reset();\n currentPattern = PatternReader.readPattern(args);\n createPatternImage(currentPattern, null);\n }", "@Override\r\n\tpublic Wall createWall() throws UnsupportedOperationException\r\n\t{\r\n\t\treturn new Wall();\r\n\t}", "public static Paint newSurroundingAreaOverlayPaint() {\n\n final Paint paint = new Paint();\n paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));\n paint.setAntiAlias(true);\n\n return paint;\n }", "public static Fragment newInstance(NacAlarm alarm)\n\t{\n\t\tFragment fragment = new NacRingtoneFragment();\n\t\tBundle bundle = NacBundle.toBundle(alarm);\n\n\t\tfragment.setArguments(bundle);\n\n\t\treturn fragment;\n\t}" ]
[ "0.6695361", "0.61042947", "0.56789476", "0.54556763", "0.51744455", "0.51133275", "0.5104194", "0.5011627", "0.49582702", "0.48621926", "0.48491773", "0.4820446", "0.47904932", "0.47825298", "0.47185174", "0.46557957", "0.46556324", "0.46104047", "0.45643976", "0.45626938", "0.45261672", "0.45023894", "0.44422767", "0.44347337", "0.4388405", "0.43784535", "0.43604237", "0.4358246", "0.43305585", "0.43276384", "0.43250343", "0.4307821", "0.4305866", "0.4303555", "0.4286694", "0.42760414", "0.42687994", "0.42560095", "0.4251144", "0.42371643", "0.42360935", "0.4232085", "0.42258728", "0.4225084", "0.4222287", "0.42096165", "0.4204297", "0.4201827", "0.4189592", "0.4184088", "0.4166663", "0.4156697", "0.41510096", "0.4142862", "0.41390076", "0.41373172", "0.41241932", "0.41211092", "0.40996778", "0.4096028", "0.40829283", "0.40753105", "0.40633747", "0.4063265", "0.40583307", "0.40544793", "0.40541255", "0.40540385", "0.40531778", "0.40370774", "0.40308285", "0.40246582", "0.4023686", "0.40230066", "0.40190393", "0.4017189", "0.40164116", "0.40160468", "0.4015417", "0.40033987", "0.4002296", "0.39953235", "0.3993964", "0.39929292", "0.39887118", "0.39856094", "0.39836717", "0.39708006", "0.39650849", "0.39616203", "0.39571568", "0.3954876", "0.394686", "0.39427194", "0.39356214", "0.3930815", "0.39227718", "0.39174852", "0.39171472", "0.39154005" ]
0.60518426
2
Returns a Pattern that plays a trill given a note, trill direction, and duration of each individual sound. Example: trill(Note.createNote("C"), MusicalEffects.EFFECT_DIRECTION_UP, 0.03125d); will produce this Pattern: [60]/0.03125 [61]/0.03125 [60]/0.03125 [61]/0.03125 [60]/0.03125 [61]/0.03125 [60]/0.03125 [60]/0.03125
public static PatternInterface trill(Note baseNote, char trillDirection, double singleSoundDuration){ StringBuilder musicStringBuilder = new StringBuilder(); double totalDuration = baseNote.getDecimalDuration(); double actualDuration = 0.0d; byte secondNote = baseNote.getValue(); if(trillDirection == EFFECT_DIRECTION_UP){ secondNote++; } else if(trillDirection == EFFECT_DIRECTION_DOWN){ secondNote--; } double remainingDuration = totalDuration - (2*singleSoundDuration); if(remainingDuration > 0.0d){ appendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration); actualDuration+=singleSoundDuration; while(actualDuration < totalDuration){ if(actualDuration + (2*singleSoundDuration) < totalDuration){ appendNoteValueAndDuration(musicStringBuilder, secondNote, singleSoundDuration); actualDuration += singleSoundDuration; appendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration); actualDuration += singleSoundDuration; } else if(actualDuration + singleSoundDuration > totalDuration){ double gapDuration = totalDuration - actualDuration; appendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), gapDuration); actualDuration+=gapDuration; } else { appendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration); actualDuration+=singleSoundDuration; } } return new Pattern(musicStringBuilder.toString().trim()); } else { return new Pattern(baseNote.getMusicString()); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static PatternInterface trill(Note baseNote, char trillDirection){\r\n \treturn trill(baseNote, trillDirection, THIRTY_SECOND);\r\n }", "public static PatternInterface trill(Note baseNote){\r\n \treturn trill(baseNote, EFFECT_DIRECTION_UP);\r\n }", "public static PatternInterface trill(Note note1, Note note2, double duration, int numSteps)\r\n {\r\n return hammerOn(note1, note2, duration, numSteps);\r\n }", "public List<Tone> getTones() {\n return new ArrayList<>(this.notes.keySet());\n }", "TRule createTRule();", "String getDelayPattern();", "Turtle createTurtle();", "public static PatternInterface slide(Note note1, Note note2, double duration, int numSteps)\r\n {\r\n StringBuilder buddy = new StringBuilder();\r\n double durationPerStep = duration / numSteps;\r\n double freq1 = Note.getFrequencyForNote(note1.getValue());\r\n double freq2 = Note.getFrequencyForNote(note2.getValue());\r\n double differencePerStep = (freq2-freq1) / numSteps;\r\n\r\n for (int i=0; i < numSteps; i++)\r\n {\r\n buddy.append(MicrotoneNotation.convertFrequencyToMusicString(freq1));\r\n buddy.append(\"/\");\r\n buddy.append(durationPerStep);\r\n buddy.append(MicrotoneNotation.getResetPitchWheelString());\r\n buddy.append(\" \");\r\n freq1 += differencePerStep;\r\n }\r\n\r\n PatternInterface pattern = new Pattern(buddy.toString());\r\n return pattern;\r\n }", "public abstract Tone getTone();", "public Note noteAt(int interval) {\n\t\tint newMidiNote = getMidiNumber() + interval;\n\t\t\n\t\treturn new Note(newMidiNote);\n\t}", "public ParticleMesh getMissileTrail() {\r\n for (int x = 0, tSize = missileTrails.size(); x < tSize; x++) {\r\n ParticleMesh e = missileTrails.get(x);\r\n if (!e.isActive()) {\r\n e.getParticleController().setRepeatType(Controller.RT_WRAP);\r\n e.forceRespawn();\r\n return e;\r\n }\r\n }\r\n return createMissileTrail();\r\n }", "public String transposeChords() {\n\n\t\t//Tools from parent class\n\t\tArrayList<Integer> transposedChords = new ArrayList<>();\n\t\tChordList chords = new ChordList();\n\t\tString[] chordList = chords.getNotes();\n\t\tint[] scaleMajor = chords.getMajor();\n\t\tint[] scaleMinor = chords.getMinor();\n\n\t\t//custom ASCII table conversion\n\t\tint[] fixedNotes = new int[m_notes.length()];\n\t\tString[] userNotes = m_notes.split(\" \");\n\n\t\tfor(int i = 0; i < m_notes.length(); i++) {\n\t\t\tfixedNotes[i] = chords.noteIndex(userNotes[i]);\n\t\t}\n\n\t\t//Cycle each note in notes passed in by user\n\t\tint cycle = 0;\n\n\t\tfor(int note = 0; note < fixedNotes.length; note++) {\n\n\t\t\tif(cycle >= scaleMajor.length)\n\t\t\t\tcycle = 0;\n\n\t\t\t//Check for type of scale\n\t\t\t//If the scaletype is major\n\t\t\tif(m_scaleType.equals(\"major\")) {\n\n\t\t\t\ttransposedChords.add(fixedNotes[note] + scaleMajor[cycle] - OFFSET);\n\n\t\t\t} else if(m_scaleType.equals(\"minor\")) {\n\n\t\t\t}\n\n\t\t\tcycle++;\n\t\t}\n\n\t\treturn \"Transposed chords in \" + m_scale + \" \" + m_scaleType + \": \" + transposedChords;\n\t}", "public int durationToTime(NoteDuration dur)\n\t{\n\t\tint eighth = quarternote / 2;\n\t\tint sixteenth = eighth / 2;\n\n\t\tswitch (dur)\n\t\t{\n\t\t\tcase Whole:\n\t\t\t\treturn quarternote * 4;\n\t\t\tcase DottedHalf:\n\t\t\t\treturn quarternote * 3;\n\t\t\tcase Half:\n\t\t\t\treturn quarternote * 2;\n\t\t\tcase DottedQuarter:\n\t\t\t\treturn 3 * eighth;\n\t\t\tcase Quarter:\n\t\t\t\treturn quarternote;\n\t\t\tcase DottedEighth:\n\t\t\t\treturn 3 * sixteenth;\n\t\t\tcase Eighth:\n\t\t\t\treturn eighth;\n\t\t\tcase Triplet:\n\t\t\t\treturn quarternote / 3;\n\t\t\tcase Sixteenth:\n\t\t\t\treturn sixteenth;\n\t\t\tcase ThirtySecond:\n\t\t\t\treturn sixteenth / 2;\n\t\t\tcase HundredTwentyEight:\n\t\t\t\treturn quarternote / 32;\n\t\t\tdefault:\n\t\t\t\treturn 0;\n\t\t}//end switch\n\t}", "public static PatternInterface graceNote(Note graceNote, Note baseNote, double graceNoteDuration){\r\n \tPattern gracePattern = new Pattern(graceNote.getMusicString());\r\n \treturn addOrnament(gracePattern, baseNote, graceNoteDuration);\r\n }", "private ParticleMesh createMissileTrail() {\r\n ParticleMesh pMesh = ParticleFactory.buildParticles(\"tail\", 200,\r\n ParticleType.Quad);\r\n pMesh.setEmissionDirection(new Vector3f(1, 1, 1));\r\n pMesh.setInitialVelocity(0);\r\n pMesh.setStartSize(1f);\r\n pMesh.setEndSize(3.45f);\r\n pMesh.setMinimumLifeTime(500);\r\n pMesh.setMaximumLifeTime(500);\r\n pMesh.setStartColor(ColorRGBA.lightGray.clone());\r\n pMesh.setEndColor(ColorRGBA.black.clone());\r\n pMesh.setParticleSpinSpeed(180 * FastMath.DEG_TO_RAD);\r\n pMesh.getParticleController().setControlFlow(true);\r\n// pMesh.setReleaseRate(500);\r\n pMesh.forceRespawn();\r\n \r\n pMesh.setModelBound(new BoundingBox());\r\n pMesh.updateModelBound();\r\n pMesh.setCullHint(Spatial.CullHint.Never);\r\n\r\n // removes the missile from the scene after the particle trail has died\r\n pMesh.getParticleController().addListener(new OnDeadListener());\r\n pMesh.setRenderState(ts);\r\n pMesh.setRenderState(bs);\r\n pMesh.setRenderState(zs);\r\n \r\n missileTrails.add(pMesh);\r\n \r\n return pMesh;\r\n }", "@Override\n public double getMaterialTraversedInRL(Hep3Vector dir) {\n double cth = Math.abs(VecOp.dot(dir, _w));\n double t = _materials.getThicknessInRL();\n return t / cth;\n }", "public void generateTone()\n throws LineUnavailableException {\n if ( clip!=null ) {\n clip.stop();\n clip.close();\n } else {\n clip = AudioSystem.getClip();\n }\n boolean addHarmonic = harmonic.isSelected();\n\n int intSR = ((Integer)sampleRate.getSelectedItem()).intValue();\n int intFPW = framesPerWavelength.getValue();\n\n float sampleRate = (float)intSR;\n\n // oddly, the sound does not loop well for less than\n // around 5 or so, wavelengths\n int wavelengths = 20;\n byte[] buf = new byte[2*intFPW*wavelengths];\n AudioFormat af = new AudioFormat(\n sampleRate,\n 8, // sample size in bits\n 2, // channels\n true, // signed\n false // bigendian\n );\n\n int maxVol = 127;\n for(int i=0; i<intFPW*wavelengths; i++){\n double angle = ((float)(i*2)/((float)intFPW))*(Math.PI);\n buf[i*2]=getByteValue(angle);\n if(addHarmonic) {\n buf[(i*2)+1]=getByteValue(2*angle);\n } else {\n buf[(i*2)+1] = buf[i*2];\n }\n }\n\n try {\n byte[] b = buf;\n AudioInputStream ais = new AudioInputStream(\n new ByteArrayInputStream(b),\n af,\n buf.length/2 );\n\n clip.open( ais );\n } catch(Exception e) {\n e.printStackTrace();\n }\n }", "public Note(int duration, int offset, int pitch, int channel, int velocity) {\n this.duration = duration;\n this.offset = offset;\n this.pitch = pitch;\n this.channel = channel;\n this.velocity = velocity;\n }", "public TrianglePatternToy(int number){ \n this.number = number;\n }", "public static float[] trilaterate(float[] p1, float r1, float[] p2, float r2, float[] p3, float r3) {\r\n float[] pos = new float[2];\r\n pos[0] = calcX(r1, r2, p2[0]);\r\n pos[1] = calcY(r1, r3, p3[0], p3[1], pos[0]);\r\n return pos;\r\n }", "Tulip getType() { return new Tulip(); }", "public Rational getRawDuration ()\r\n {\r\n Rational rawDuration = null;\r\n\r\n if (!getNotes().isEmpty()) {\r\n // All note heads are assumed to be the same within one chord\r\n Note note = (Note) getNotes().get(0);\r\n\r\n if (!note.getShape().isMeasureRest()) {\r\n // Duration (with flags/beams applied for non-rests)\r\n rawDuration = note.getNoteDuration();\r\n\r\n // Apply augmentation (applies to rests as well)\r\n if (dotsNumber == 1) {\r\n rawDuration = rawDuration.times(new Rational(3, 2));\r\n } else if (dotsNumber == 2) {\r\n rawDuration = rawDuration.times(new Rational(7, 4));\r\n }\r\n }\r\n }\r\n\r\n return rawDuration;\r\n }", "void crear(Tonelaje tonelaje);", "public RolandMT32RhythmSetupTempDriver() {\n super(\"Rhythm Setup Temp\", \"Fred Jan Kraan\");\n sysexID = \"F041**16\";\n patchSize = HSIZE + SSIZE + 1;\n patchNameStart = 0;\n patchNameSize = 0;\n deviceIDoffset = 0;\n checksumStart = 5;\n checksumEnd = 10;\n checksumOffset = 0;\n bankNumbers = new String[] {\n \"\" };\n patchNumbers = new String[] {\n \"\" };\n }", "static Tour sequence() {\r\n\t\tTour tr = new Tour();\r\n\t\tfor (int i = 0; i < tr.length(); i++) {\r\n\t\t\ttr.index[i] = i;\r\n\t\t}\r\n\t\ttr.distance = tr.distance();\r\n\t\treturn tr;\r\n\t}", "public Piano(int numNotes){\n pStrings = new InstString[numNotes][3];\n for(int a = 0; a < numNotes; a++){\n double freq = 440 * Math.pow(2, (double)(a-24)/(double)12);\n pStrings[a][0] = new GuitarString(freq);\n pStrings[a][1] = new GuitarString(freq + .45);\n pStrings[a][2] = new GuitarString(freq - .45);\n }\n }", "CompositionBuilder<T> addNote(int start, int end, int instrument, int pitch, int volume);", "public abstract void tilt(long ms);", "public static TriplePattern createTriplePatternFromJSON(final JSONObject triplePatternJson) throws JSONException {\n\t\tfinal JSONArray itemsJson = (JSONArray) triplePatternJson.get(\"triple_pattern\");\n\t\tfinal Item[] items = new Item[3];\n\t\tfor (int h = 0; h < 3; h++) {\n\t\t\titems[h] = Helper.createItemFromJSON(itemsJson.getJSONObject(h));\n\t\t}\n\t\treturn new TriplePattern(items[0], items[1], items[2]);\n\t}", "public Note(char n, int dur) {\n\t\tnote = n;\n\t\tduration = dur;\n\t}", "public NoteDuration getNoteDuration(int duration)\n\t{\n\t\tint whole = quarternote * 4;\n\t\t//\t\t 1 = 32/32\n\t\t//\t\t 3/4 = 24/32\n\t\t//\t\t 1/2 = 16/32\n\t\t//\t\t 3/8 = 12/32\n\t\t//\t\t 1/4 = 8/32\n\t\t//\t\t 3/16 = 6/32\n\t\t//\t\t 1/8 = 4/32 = 8/64\n\t\t//\t\t triplet = 5.33/64\n\t\t//\t\t 1/16 = 2/32 = 4/64\n\t\t//\t\t 1/32 = 1/32 = 2/64\n\n\t\tif (duration >= 28 * whole / 32)\n\t\t return NoteDuration.Whole;\n\t\telse if (duration >= 20 * whole / 32)\n\t\t return NoteDuration.DottedHalf;\n\t\telse if (duration >= 14 * whole / 32)\n\t\t return NoteDuration.Half;\n\t\telse if (duration >= 10 * whole / 32)\n\t\t return NoteDuration.DottedQuarter;\n\t\telse if (duration >= 7 * whole / 32)\n\t\t return NoteDuration.Quarter;\n\t\telse if (duration >= 5 * whole / 32)\n\t\t return NoteDuration.DottedEighth;\n\t\telse if (duration >= 6 * whole / 64)\n\t\t return NoteDuration.Eighth;\n\t\telse if (duration >= 5 * whole / 64)\n\t\t return NoteDuration.Triplet;\n\t\telse if (duration >= 3 * whole / 64)\n\t\t return NoteDuration.Sixteenth;\n\t\telse if (duration >= 2 * whole / 64)\n\t\t return NoteDuration.ThirtySecond;\n\t\telse if (duration >= whole / 64)\n\t\t return NoteDuration.SixtyFour; // TODO : EXTEND UNTIL 1/128 to be able to extract the onset in SYMBOLIC representation\n\t\telse if (duration >= whole / 128)\n\t\t return NoteDuration.HundredTwentyEight;\n\t\telse\n\t\t return NoteDuration.ZERO;\n\t}", "public double getTempoManipulator(int time) {\n if (time < duration * ((double) pStart / 100)) // BEFORE INCREASE\n return roundWithPrecision(pOffset, 3);\n else if (time > duration * (((double) pStart + (double) pDuration) / 100)) // AFTER INCREASE\n return roundWithPrecision(pOffset * pManipulation, 3);\n else // DURING INCREASE\n {\n double startOfIncrease = (((double) pStart) / 100 * duration);\n double lengthOfIncrease = (((double) pDuration) / 100 * duration);\n\n double at = time - startOfIncrease;\n double atModifier = at / lengthOfIncrease;\n return roundWithPrecision(((1 + ((pManipulation - 1) * atModifier)) * pOffset), 3);\n }\n }", "public static PatternInterface graceNote(Note graceNote, Note baseNote){\r\n \treturn graceNote(graceNote, baseNote, THIRTY_SECOND);\r\n }", "private Rotor readRotor() {\n try {\n String currCycle = _config.next();\n String permutation = \"\";\n while (currCycle.contains(\"(\")) {\n if (!currCycle.contains(\")\") || currCycle.contains(\"*\")) {\n throw error(\"Wrong cycle format\");\n }\n if (_config.hasNext()) {\n permutation = permutation + currCycle;\n currCycle = _config.next();\n } else if (!_config.hasNext()) {\n permutation = permutation + currCycle;\n break;\n }\n }\n String tempname = _name.toUpperCase();\n if (_config.hasNext()) {\n _name = currCycle;\n }\n if (notches.charAt(0) == 'M') {\n return new MovingRotor(tempname,\n new Permutation(permutation, _alphabet),\n notches.substring(1));\n } else if (notches.charAt(0) == 'N') {\n return new FixedRotor(tempname,\n new Permutation(permutation, _alphabet));\n } else {\n return new Reflector(tempname,\n new Permutation(permutation, _alphabet));\n }\n } catch (NoSuchElementException excp) {\n throw error(\"bad rotor description\");\n }\n }", "private void playNotes()\n\t{\n\t\t//Update tracks when we can shift chords.\n\t\tChord curChord = ClearComposer.cc.getChord();\n\t\tif (index % ClearComposer.cc.getChordInterval() == 0 && (prevChord == null || prevChord != curChord))\n\t\t{\n\t\t\tprevChord = curChord;\n\t\t\ttracks.forEach(GraphicTrack::updateChord);\n\t\t\tClearComposer.cc.updateChordOutlines();\n\t\t}\n\n\t\tfor (GraphicTrack track : tracks)\n\t\t{\n\t\t\tint temp = track.playNote(index);\n\t\t\tif (temp != -1)\n\t\t\t\tMusicPlayer.playNote(temp);\n\t\t}\n\n\t\tindex++;\n\t\twhile (index >= ClearComposer.cc.getNumNotes())\n\t\t\tindex -= ClearComposer.cc.getNumNotes();\n\t}", "public Tulip(){\n super(CropName.TULIP, CropType.FLOWER, CropStatus.WAITING, 90, 2, 2, 3, 0, 1, 1, 1, 7);\n }", "public Turtle(String name) {\n this.name = name;\n }", "public List<PatternItem> pattern() {\n List<PatternItem> out = new ArrayList<>();\n int level = 0;\n int n = 0;\n String c;\n\n boolean done = false;\n while (!done) {\n DNAToken token = parser.step();\n\n switch (token) {\n case CONT:\n break;\n case C:\n out.add(new PatternItem(PatternItem.Type.BASE, 'I'));\n break;\n case F:\n out.add(new PatternItem(PatternItem.Type.BASE, 'C'));\n break;\n case P:\n out.add(new PatternItem(PatternItem.Type.BASE, 'F'));\n break;\n case IC:\n out.add(new PatternItem(PatternItem.Type.BASE, 'P'));\n break;\n case IP:\n n = parser.nat();\n out.add(new PatternItem(PatternItem.Type.JUMP, n));\n break;\n case IF:\n parser.next(); // Consume one more character for no good reason\n c = parser.consts();\n out.add(new PatternItem(PatternItem.Type.SEARCH, c));\n break;\n case IIP:\n level += 1;\n out.add(new PatternItem(PatternItem.Type.OPEN));\n break;\n case IIF:\n case IIC:\n if (level == 0) {\n done = true;\n } else {\n level -= 1;\n out.add(new PatternItem(PatternItem.Type.CLOSE));\n }\n break;\n case III:\n rna.concat(dna.substring(0, 7));\n dna.trunc(7);\n break;\n default:\n finish();\n }\n }\n\n return out;\n }", "List<TransmissionNote> getTransmissionNotes(Long transmissionId);", "private void getNotes(MusicCircle circle){\n\t\tif(! circle.isMuted()){\n\t\t\tfor(int i=0; i<circle.getNumNotes(); i++){\n\t\t\t\tif( circle.getS(i) != SILENCE) note(circle.getT(i) + loopOffset, circle.getD(i), Fofs(circle.getS(i) + circle.getBaseSemitone()));\n\t\t\t}\n\t\t}\n\t}", "@Test\n\t\tpublic void testTrilateration() {\n\t\t\t// Initialize 3 points\n\t\t\tPoint2D p1 = new Point2D.Double(1,1);\n\t\t\tPoint2D p2 = new Point2D.Double(6,3);\n\t\t\tPoint2D p3 = new Point2D.Double(0,9);\n\t\t\t\n\t\t\t// Initialize 3 radius. r1 associated with p1 and so on.\n\t\t\tdouble r1 = 7.2111;\n\t\t\tdouble r2 = 4.1231;\n\t\t\tdouble r3 = 5.3852;\n\t\t\t\n\t\t\t// Initialized the Triangulate object and load points and radii\n\t\t\tTriangulate test = new Triangulate();\n\t\t\ttest.setPoints(p1, p2, p3);\n\t\t\ttest.setRadius(r1, r2, r3);\n\t\t\t\n\t\t\t// Set the given and actual location with the error we have\n\t\t\tPoint2D loc = test.trilaterate();\n\t\t\tPoint2D actual = new Point2D.Double(5, 7);\n\t\t\tdouble err = 1e-4; \n\t\t\t\n\t\t\t// Test x and y coordinates within a certain error\n\t\t\tassertEquals(actual.getX(), loc.getX(), err);\n\t\t\tassertEquals(actual.getY(), loc.getY(), err);\n\n\t\t}", "abstract public TurtleModel getTurtle();", "public List<TemplItem> template() {\n List<TemplItem> items = new ArrayList<>();\n int l;\n int n;\n\n boolean done = false;\n while (!done) {\n DNAToken token = parser.step();\n\n switch (token) {\n case CONT:\n break;\n case C:\n items.add(new TemplItem(TemplItem.Type.BASE, 'I'));\n break;\n case F:\n items.add(new TemplItem(TemplItem.Type.BASE, 'C'));\n break;\n case P:\n items.add(new TemplItem(TemplItem.Type.BASE, 'F'));\n break;\n case IC:\n items.add(new TemplItem(TemplItem.Type.BASE, 'P'));\n break;\n case IP:\n case IF:\n l = parser.nat();\n n = parser.nat();\n items.add(new TemplItem(TemplItem.Type.PROT, n, l));\n break;\n case IIP:\n n = parser.nat();\n items.add(new TemplItem(TemplItem.Type.LEN, n));\n break;\n case IIF:\n case IIC:\n done = true;\n break;\n case III:\n rna.concat(dna.substring(0, 7));\n dna.trunc(7);\n break;\n case DONE:\n done = true;\n break;\n default:\n finish();\n }\n }\n\n return items;\n }", "public void playSong() {\n\t\t// Initialize\n\t\tint num = 1;\n\n\t\t// Get the notes to be played from the entryBox\n\t\tString notesString = \"V0 \" + instrumentType + \" \" + entryBox.getText();\n\n\t\t// Create a new rhythm object\n\t\tRhythm rhythm = new Rhythm();\n\n\t\t// Get the rhythm strings from the rhythm entry boxes\n\t\tString rhythmLayer1 = \"V1 \" + rhythm1.getText();\n\t\tString rhythmLayer2 = \"V2 \" + rhythm2.getText();\n\n\t\t// Set the strings to layers\n\t\trhythm.setLayer(1, rhythmLayer1);\n\t\trhythm.setLayer(2, rhythmLayer2);\n\n\t\t// Add the appropriate substitutions\n\t\trhythm.addSubstitution('O', \"[BASS_DRUM]i\");\n\t\trhythm.addSubstitution('o', \"Rs [BASS_DRUM]s\");\n\t\trhythm.addSubstitution('*', \"[ACOUSTIC_SNARE]i\");\n\t\trhythm.addSubstitution('^', \"[PEDAL_HI_HAT]s Rs\");\n\t\trhythm.addSubstitution('!', \"[CRASH_CYMBAL_1]s Rs\");\n\t\trhythm.addSubstitution('.', \"Ri\");\n\n\t\t// Get the rhythm pattern\n\t\tPattern rhythmPattern = rhythm.getPattern();\n\n\t\t// Get how many times the song should repeat\n\t\tString repeatNum = repeatNumber.getText();\n\t\tnum = Integer.parseInt(repeatNum);\n\n\t\t// Get the playback tempo\n\t\tString playTempo = \"T[\" + tempo.getText() + \"] \";\n\n\t\t// Create the song\n\t\tPattern song = new Pattern();\n\t\tsong.add(rhythmPattern);\n\t\tsong.add(notesString);\n\t\tsong.repeat(num);\n\n\t\t// Play the song\n\t\tplayer.play(playTempo + song);\n\n\t}", "public void copiedMeasureDecoder(Integer chordNote,Integer[]previousChord, Integer[] playedChord){\n /* int c=0;\n int a=0;\n int b=0;\n int x0=0;\n int x1=0;*/\n int d1=0;\n int d2=0;\n\n\n\n for (int i=0;i<melodyNotes.length;i++){\n if(melodyNotes[i]==chordNote)\n d1=i;\n }\n for (int i=0;i<melodyNotes.length;i++){\n if(melodyNotes[i]==melody.get(melodyCounter))\n d2=i;\n /* if(melodyNotes[i]==playedChord[1])\n a=i;\n if(melodyNotes[i]==previousChord[1])\n b=i;*/\n }\n /*if(a<b){\n x0=a-b;\n x1=7+x1;\n }else{\n x0=a-b;\n x1=x0-7;\n }*/\n if(d1>d2) {\n binaryOutput += \"0\";\n }else {\n binaryOutput += \"1\";\n }\n for(int i = 0;i<4;i++){\n for(int j =0; j < rhytm.get(beatCounter).length;j++){\n if(rhytm.get(beatCounter)[j]!=null)\n if ((!rhytm.get(beatCounter)[j].equals(\"Ri\")) && (!rhytm.get(beatCounter)[j].equals(\"Rs\"))) {\n melodyCounter++;\n }\n }\n beatCounter++;\n }\n\n\n}", "public int liftStepper() {\n if(robot.wrist.getPosition()> .25)\n {\n if(robot.jaw.getPosition()> .25)\n {\n telemetry.addLine(\"I could self damage.\");\n }\n }\n else{\n if (this.improvedGamepad1.y.isInitialPress()) {\n step = step + 1;\n if (step > 5) {\n step = 5;\n }\n power = .5;\n //up by one\n }\n if (this.improvedGamepad1.a.isInitialPress()) {\n step = step - 1;\n if (step < 0) {\n step = 0;\n }\n power = .5;\n //down by one\n }\n\n if (this.improvedGamepad1.b.isInitialPress()) {\n topStep = step;\n step = 0;\n power = .7;\n //to bottom\n }\n\n if (this.improvedGamepad1.x.isInitialPress()) {\n step = topStep;\n power = .7;\n //to top\n }\n\n }\n\n telemetry.addData(\"Step\", step);\n telemetry.addData(\"Top Step\", topStep);\n telemetry.update();\n\n\n //DcMotor lift = this.hardwareMap.dcMotor.get(\"lift\");\n int targetPosition = step * 750;\n\n robot.lift.setTargetPosition(targetPosition);\n robot.lift.setMode(DcMotor.RunMode.RUN_TO_POSITION);\n robot.lift.setPower(power);\n\n telemetry.update();\n return step;\n\n }", "private Line getTrajectory() {\n Point target = this.topLeft.add(this.velocity).asPoint();\n return new Line(this.topLeft.asPoint(), target);\n }", "public Trips(String alias) {\n this(alias, TRIPS);\n }", "public static LineQueue<Passenger> makeCommuter() {\r\n\t\tLineQueue<Passenger> commuters = new LineQueue<Passenger>();\r\n\t\tdouble t = 0;\r\n\t\tdouble a;\r\n\t\twhile (t < 3600) {\r\n\t\t\ta = genExp(90);\r\n\t\t\tif (a < 1) {\r\n\t\t\t\ta = 1;\r\n\t\t\t}\r\n\t\t\tt += a;\r\n\t\t\tif (t < 3600) {\r\n\t\t\t\tnumberCommutersMade++;\r\n\t\t\t\tPassenger passenger = new Passenger(false, false, t);\r\n\t\t\t\tcommuters.enqueue(passenger);\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn commuters;\r\n\t}", "public Trap(FloorTile where, StairTile trap, CharacterModifier effect) {\n super(where, FLOOR, effect);\n this.trapDoor = trap; // todo: stairtile ensure same room? ensure from of stair?\n if (trap != null) {\n trap.trap = this;\n if (trap.stair != null && trap.stair.toTile != null) trap.stair.toTile.trap = this; // todo have a function for that\n }\n }", "@Override\r\n\t\t\t\t\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\t\t\t\t\tNoteInJson[] pattern=gpt.getPattern();\r\n\t\t\t\t\t\t\t\t\t\tif(change_tempo){\r\n\t\t\t\t\t\t\t\t\t\t\tPatternMaker.changeSpeed(pattern, ratio);\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\tgotoPractice(pattern);\r\n\t\t\t\t\t\t\t\t\t}", "public void createTurtle (TurtleView tView) {\n myController.createTurtle(tView);\n }", "public String playGuitar(){\n\t\t String notes = \"[A(0.25), G(2), E(0.5), C(1), C(2), D(0.25), E(2), C(2), B(0.25), C(4), C(1), G(0.25),A(1), C(2), D(1),C(4)]\";\n\t\treturn notes;\n\t}", "void rotateTurtle(int turtleIndex, double degrees);", "public void decodeMelody(){\n //this.adder=new Adder(/*this.getTonicNote(),new int[]{0,1,2,3}*/);\n\n melodyNotes= adder.getKeyNotes(); //todo debug\n ArrayList<Integer[]> framenotes=adder.getFrameNotes();\n ArrayList<Integer[]> chordnotes=adder.getKeyChords();\n firstChord=chordnotes.get(0);\n secondChord=chordnotes.get(1);\n thirdChord=chordnotes.get(2);\n fourthChord=chordnotes.get(3);\n MiddleNote=framenotes.get(0);\n LastNote=framenotes.get(1);\n this.tokenizeAndParse();\n //01000101000000011100100100100110011101101110101110001010010101100101100101110\n //todo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n this.mainDecoder(8,firstChord);\n //todo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n this.copiedMeasureDecoder(firstChordNote,firstChord,secondChord);\n //todo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n this.mainDecoder(14,secondChord);\n //todo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n this.frameNoteDecoder(MiddleNote);\n //todo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n this.mainDecoder(24,thirdChord);\n //todo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n this.copiedMeasureDecoder(secondChordNote ,thirdChord,fourthChord);\n //todo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n this.mainDecoder(30,fourthChord);\n //todo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n this.frameNoteDecoder(LastNote);\n }", "private static double[] note(double hz, double duration, double amplitude) {\n int N = (int) (StdAudio.SAMPLE_RATE * duration);\n double[] a = new double[N + 1];\n for (int i = 0; i <= N; i++)\n a[i] = amplitude * Math.sin(2 * Math.PI * i * hz / StdAudio.SAMPLE_RATE);\n return a;\n }", "void note(float start, float duration, float freq){\n\t out.playNote(start,duration,freq); \n\t }", "public Rumbler() {\n // Just a default rumble of 1 second 1 time on both joysticks.\n this(1.0, 0, 1, JoystickSelection.BOTH_JOYSTICKS, 1);\n }", "public static String generaTemp(){\n return \"t$\"+temp++;\n }", "public static String generaTemp(){\n return \"t$\"+temp++;\n }", "public static String generaTemp(){\n return \"t$\"+temp++;\n }", "public static String generaTemp(){\n return \"t$\"+temp++;\n }", "public static PatternInterface addOrnament(Pattern ornament, Note baseNote, double longestOrnamentDuration){\r\n \tPatternInvestigator investigator = new PatternInvestigator();\r\n \tMusicStringParser stringParser = new MusicStringParser();\r\n \t\r\n \tstringParser.addParserListener(investigator);\r\n \tstringParser.parse(ornament);\r\n \t\r\n \tdouble longestDuration = investigator.getLongestDecimalDuration();\r\n \tdouble durationChange = longestOrnamentDuration / longestDuration;\r\n \t\r\n \tDurationPatternTransformer transformer = new DurationPatternTransformer(durationChange);\r\n \t\r\n \tPatternInterface result = transformer.transform(ornament);\r\n \t\r\n \tstringParser.removeParserListener(investigator);\r\n \tinvestigator = new PatternInvestigator();\r\n \tstringParser.addParserListener(investigator);\r\n \tstringParser.parse(result);\r\n \t\r\n \tif(investigator.getTotalDecimalDuration() < baseNote.getDecimalDuration()){\r\n \t\tdouble remainingDuration = baseNote.getDecimalDuration() - investigator.getTotalDecimalDuration();\r\n \t\tbaseNote.setDecimalDuration(remainingDuration);\r\n \t\tresult.add(baseNote.getMusicString());\r\n \t\treturn result;\r\n \t} else {\r\n \t\treturn new Pattern(baseNote.getMusicString());\r\n \t}\r\n }", "public Triangle getTridroit() {\r\n return tridroit;\r\n }", "public TFRule createTFRuleFromLine(String line) {\n\n line = removeTailComment(line);\n\n //skip blank lines or comments\n line = line.trim();\n\n try (Scanner rowScanner = new Scanner(line)) {\n rowScanner.useDelimiter(\",\");\n\n SensorData lhsExt = null;\n SensorData rhsExt = null;\n\n int[] lhsInt = null;\n String action = \"\\0\";\n\n double conf = -1.0;\n\n String lhsIntData = rowScanner.next().trim();\n\n try {\n lhsInt = getLHSIntFromString(lhsIntData);\n lhsExt = getSDFromString(rowScanner.next().trim());\n action = rowScanner.next().trim();\n rhsExt = getSDFromString(rowScanner.next().trim());\n String dblStr = rowScanner.next().trim();\n conf = Double.parseDouble(dblStr);\n } catch(InputMismatchException ime) {\n System.err.println(\"oh no!\");\n }\n\n return new TFRule(this.agent, action.charAt(0), lhsInt, lhsExt, rhsExt, conf);\n }\n }", "TrafficTreatment treatment();", "public Stimulus toTCUMLStimulus();", "public NewTransitionRecord(int from, int to, double r, int t, boolean isFTan) {\r\n fromstate = from;\r\n tostate = to;\r\n rate = r;\r\n transition = t;\r\n if (isFTan) {\r\n isFromTangible = 'T';\r\n } else {\r\n isFromTangible = 'V';\r\n }\r\n }", "void playTone(){\n t = new Thread() {\n public void run(){\n isRunning = true;\n setPriority(Thread.MAX_PRIORITY);\n\n\n\n audioTrack.play();\n\n for (int i = 0; i < message.length(); i++) {\n\n ASCIIBreaker breaker = new ASCIIBreaker((int)message.charAt(i));\n\n int frequencies[] = breaker.ASCIIToFrequency();\n\n //Generate waves for all different frequencies\n for(int fre : frequencies) {\n audioTrack.write(generateSineInTimeDomain(fre),0,sample_size);\n }\n\n audioTrack.write(generateSineInTimeDomain(7000),0,sample_size);\n }\n\n audioTrack.stop();\n audioTrack.release();\n }\n };\n t.start();\n }", "public NewTransitionRecord(int from, int to, double r, int t) {\r\n fromstate = from;\r\n tostate = to;\r\n rate = r;\r\n transition = t;\r\n }", "private ModelImpl(int tempo, List<Note> notes) {\n if (tempo < 50000 || tempo > 250000) {\n throw new IllegalArgumentException(\"Invalid tempo.\");\n }\n if (notes.isEmpty()) {\n throw new IllegalArgumentException(\"This shouldn't happen.\");\n }\n this.tempo = tempo;\n this.currentMeasure = DEFAULT_START;\n this.status = Status.Playing;\n this.low = new Note(1, 8, 0, Note.Pitches.C, true, 0, 1);\n this.high = new Note(1, 0, 0, Note.Pitches.A, true, 0, 1);\n this.sheet = new ArrayList<Set<Note>>();\n this.addAll(notes);\n }", "public Note(int _pitch, int _duration, int _dynamic) {\n pitch = _pitch;\n duration = _duration;\n dynamic = _dynamic;\n tiedIn = false;\n tiedOut = false;\n displayDynamic = false;\n }", "public static Truck nextTruck(){\n Truck truck = null;\n Random r = new Random();\n switch (r.nextInt(2)){\n case 0: {\n truck = new Pickup(4000 + r.nextInt(2000), 10 + r.nextInt(10),\n 150 + r.nextInt(50), 4 + r.nextInt(4));\n break;\n }\n case 1: {\n truck = new Van(5000 + r.nextInt(2000), 12 + r.nextInt(10),\n 180 + r.nextInt(50), 3 + r.nextInt(2));\n break;\n }\n }\n return truck;\n }", "public static Note createNote(int value, int startBeat, int endBeat, int instrument, int\n volume) {\n return createNote((value / 12) - 1, Pitch.getPitch(value % 12), startBeat, endBeat, instrument,\n volume);\n }", "private StringBuilder listAllPitches(int length) {\n StringBuilder builder = new StringBuilder();\n\n int padding = Integer.toString(length).length();\n String spaces = \"\";\n spaces = String.format(\"%\" + (padding) + \"s\", spaces);\n builder.append(spaces);\n\n Note highest = this.getHighestNote();\n Note lowest = this.getLowestNote();\n int ordinalHighestOctave = highest.getOctave().ordinal();\n int ordinalHighestPitch = highest.getPitch().ordinal();\n int ordinalLowOctave = lowest.getOctave().ordinal();\n int ordinalLowPitch = lowest.getPitch().ordinal();\n int from = ordinalLowOctave * 12 + ordinalLowPitch;\n int to = ordinalHighestOctave * 12 + ordinalHighestPitch;\n List<String> allNotes = this.allnotes.subList(from, to + 1);\n\n for (int i = 0; i < allNotes.size(); i++) {\n String current = allNotes.get(i);\n\n if (current.length() == 2) {\n builder.append(\" \" + current + \" \");\n } else if (current.length() == 3) {\n builder.append(\" \" + current + \" \");\n } else if (current.length() == 4) {\n builder.append(\" \" + current);\n } else {\n builder.append(current);\n }\n }\n return builder;\n }", "public void playChord(float[] pitches, double dynamic, double duration) {\n\t\tthis.soundCipher.playChord(pitches, dynamic, duration);\n\t}", "public GuitarLite() {\n // double[] frequencies = new double[totalNotes];\n double A2 = 110.0;\n // frequencies[0] = A2;\n for (int i = 0; i < totalNotes; i++){\n double frequency = A2 * Math.pow(2, i/12.0);\n // frequencies[i] = frequency;\n strings[i] = new GuitarString(frequency);\n }\n }", "public Voice transpose(int semitonesUp){\n List<Bar> temp= new ArrayList<>();\n for(Bar bar:voices){\n temp.add(bar.transpose(semitonesUp));\n }\n checkRep();\n return new Voice(temp);\n }", "static int[] createRhythmLevelMessage(int part, byte level){\r\n\t\tif(part < 0) part = 0;\r\n\t\tif(part > 15) part = 15;\r\n\t\t\r\n\t\tint[] data = new int[5];\r\n\t\tdata[0] = 0x11 + part / 4;\r\n\t\tdata[1] = 0x10 + (part % 4) * 0x20;\r\n\t\tdata[2] = 0x00;\r\n\t\tdata[3] = 0x0C;\r\n\t\tdata[4] = level;\r\n\t\treturn createMessage(data);\r\n\t}", "Trip(String filePath, Double wheelDiameter) {\n this.filePath_ = filePath;\n this.wheelDiameter_ = wheelDiameter;\n }", "String notes();", "public Rumbler(double timeOn, double timeOff, int repeatCount, JoystickSelection controllerToRumble) {\n this(timeOn, timeOff, repeatCount, controllerToRumble, 1);\n }", "public static String getTrail() {\n\t\treturn trail.toString();\n\t}", "public void NewTrail(float[] positions, float trailLength)\n {\n float distanceBetweenEffects = trailLength / instantiateNumber;\n Log.d(\"--WTF--\",\"tl \" + trailLength + \"dbe \" + distanceBetweenEffects);\n //trail.clear();\n trail.get(0).Set(getWorldCoords(new Vec2(positions[0], positions[1]))); // początek\n\n float currUnusedLength = 0f;\n int effects = 1;\n for (int i = 2; i < positions.length; i=i+2)\n {\n // reszta odl. z poprzednich punktow + dystans miedzy tym pkt a poprzednim\n Vec2 A = new Vec2(positions[i-2],positions[i-1]);\n Vec2 B = new Vec2(positions[i],positions[i+1]);\n float distanceBetweenPoints = GetPointsDistance(A,B);\n currUnusedLength = currUnusedLength + distanceBetweenPoints;\n if(currUnusedLength > distanceBetweenEffects)\n {\n // jest wiekszy od odleglosci miedzy kolejnymi efektami, oznacza to ze\n // juz nie czas na umieszczenie kolejnego efektu\n float d = distanceBetweenPoints - (currUnusedLength-distanceBetweenEffects);\n float Xac = d * (B.X()-A.X())/distanceBetweenPoints;\n float Yac = d * (B.Y()-A.Y())/distanceBetweenPoints;\n\n if(effects < instantiateNumber)trail.get(effects).Set(getWorldCoords(new Vec2(A.X()+Xac, A.Y()+Yac)));\n else break;\n\n effects++;\n currUnusedLength = (currUnusedLength-distanceBetweenEffects);\n }\n }\n if(effects <= instantiateNumber)sqNumber = effects;\n else sqNumber = instantiateNumber;\n showThem = true;\n showBigStar = false;\n }", "public IPlay getTape(boolean flag) {\n if (flag) {\n class Record implements IPlay { // область видимости scope {flag = true}\n @Override\n public void play() {\n System.out.println(\"Record.play\");\n }\n } // eof class\n return new Record();\n\n }else{\n class MidiBoard implements IPlay { // область видимости scope {flag = false}\n @Override\n public void play() {\n System.out.println(\"MidiBoard.play\");\n }\n } // eof class\n return new MidiBoard();\n }\n }", "private Timeline setupFluctuationTimeline(int interval) {\n Timeline timeline = new Timeline(\n new KeyFrame(Duration.millis(interval),\n event -> {\n fluctuateLine();\n }\n ));\n timeline.setCycleCount(Animation.INDEFINITE);\n return timeline;\n }", "@Override\n public JSLFrame editPatch(Patch p) {\n return new RolandMT32RhythmSetupTempEditor(p);\n }", "public static Texture getTut(){\n //set a linear filter to clean image\n tuts.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);\n //return image\n return tuts;\n }", "public static int getNormalizedPitch(Note note) {\n try {\n String pitch = note.getPitch().toString();\n String octave = new Integer(note.getOctave()).toString();\n\n String target = null;\n\n if (note.getPitch().equals(Pitch.R)) {\n target = \"REST\";\n } else {\n if(note.getAlteration().equals(Alteration.N))\n target = pitch.concat(octave);\n else if(note.getAlteration().equals(Alteration.F))\n target = pitch.concat(\"F\").concat(octave);\n else\n target = pitch.concat(\"S\").concat(octave);\n }\n\n \n\n Class cClass = ConverterUtil.class;\n Field field = cClass.getField(target);\n Integer value = (Integer) field.get(null);\n\n return value.intValue()%12;\n } catch (Exception e) {\n e.printStackTrace();\n }\n return 0;\n }", "IPatternSequencer getSequencer();", "public float getTaille() {\r\n return taille;\r\n }", "@Override\n\tpublic String toString() {\n\t\treturn note + \" \" + duration + (duration == 1 ? \" Quaver\" : \" Crotchet\");\n\t}", "public List<Tailor> read();", "public int getTone(){\n\t\tint keyAsTone = (int) (Math.pow(2.0, (((double)key)-49.0)/12)*440);\n\t\treturn keyAsTone;\n\t}", "public final StepPattern getStepPattern() {\n/* 176 */ return this.m_stepPattern;\n/* */ }", "@Override\n public double getMaterialTraversed(Hep3Vector dir) {\n double cth = Math.abs(VecOp.dot(dir, _w));\n double t = _materials.getThickness();\n return t / cth;\n }", "public ParticleMesh getAsteroidTrail(final Spatial asteroidmodel) {\r\n for (int x = 0, tSize = asteroidTrails.size(); x < tSize; x++) {\r\n ParticleMesh e = asteroidTrails.get(x);\r\n if (!e.isActive()) {\r\n Logger.getLogger(this.getClass().getName()).warning(\"re-using asteroid trail, parent:\" +e.getParent());\r\n e.removeFromParent();\r\n e.getParticleController().setRepeatType(Controller.RT_WRAP);\r\n e.forceRespawn();\r\n return e;\r\n }\r\n }\r\n return createAstroidTrail(asteroidmodel);\r\n }", "public Rational getDuration ()\r\n {\r\n if (this.isWholeDuration()) {\r\n return null;\r\n } else {\r\n Rational raw = getRawDuration();\r\n\r\n if (tupletFactor == null) {\r\n return raw;\r\n } else {\r\n return raw.times(tupletFactor);\r\n }\r\n }\r\n }", "public static PatternInterface addOrnament(Pattern ornament, Note baseNote){\r\n \treturn addOrnament(ornament, baseNote, THIRTY_SECOND);\r\n }", "public Strand getReverseStrand() throws BaseException\n {\n Type newType;\n \n //TODO: determine the value of newType\n // If the current type is RNA, keep the new type as RNA\n // If the current type is 3', change it to 5'\n // If the current type if 5', change it to 3'\n //Remove the following line -- it is for default compilation\n newType = Type.RNA;\n \n Base[] rev;\n //TODO: create a new array of Bases that is the reverse of the current\n // sequence. Store the result in rev.\n //Remove the following line -- it is for default compilation\n rev = new Base[]{};\n \n return new Strand(newType, rev);\n }" ]
[ "0.7099334", "0.61985874", "0.57838225", "0.47408995", "0.47376448", "0.46521783", "0.45961753", "0.4559771", "0.44705874", "0.44639462", "0.44542965", "0.44339454", "0.441948", "0.4343933", "0.43389422", "0.43135235", "0.4303912", "0.42964804", "0.42909053", "0.42706716", "0.4258243", "0.42445254", "0.42442954", "0.4227286", "0.42045653", "0.4202757", "0.41978323", "0.41520864", "0.4146109", "0.4131995", "0.41148314", "0.41129217", "0.41057703", "0.40819627", "0.4071812", "0.40604633", "0.40578592", "0.40572572", "0.40570176", "0.4025092", "0.40176782", "0.40091503", "0.39880896", "0.39868504", "0.39593792", "0.3949054", "0.3947422", "0.39423364", "0.39359695", "0.3932451", "0.39314157", "0.39294505", "0.39290774", "0.3927795", "0.39245233", "0.39103195", "0.39095828", "0.38817352", "0.38770056", "0.38770056", "0.38770056", "0.38770056", "0.38681996", "0.3867098", "0.38640285", "0.38502884", "0.38420245", "0.38351697", "0.3832404", "0.38313544", "0.38151094", "0.38122067", "0.38109803", "0.37887007", "0.37798446", "0.3774113", "0.37677476", "0.37563503", "0.3754428", "0.37516534", "0.37485677", "0.37483817", "0.37424982", "0.37404117", "0.37393957", "0.37393093", "0.3737797", "0.37365216", "0.37358373", "0.37337714", "0.3732145", "0.37310037", "0.3727772", "0.37230217", "0.3713068", "0.37091976", "0.36981025", "0.3690971", "0.36842042", "0.36830908" ]
0.7323087
0
Returns a Pattern that plays a trill given a note, and trill direction. Example: trill(Note.createNote("C6h"), MusicalEffects.EFFECT_DIRECTION_UP) will produce this Pattern: [72]/0.03125 [73]/0.03125 [72]/0.03125 [73]/0.03125 [72]/0.03125 [73]/0.03125 [72]/0.03125 [73]/0.03125 [72]/0.03125 [73]/0.03125 [72]/0.03125 [73]/0.03125 [72]/0.03125 [73]/0.03125 [72]/0.03125 [72]/0.03125
public static PatternInterface trill(Note baseNote, char trillDirection){ return trill(baseNote, trillDirection, THIRTY_SECOND); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static PatternInterface trill(Note baseNote, char trillDirection, double singleSoundDuration){\r\n \r\n \tStringBuilder musicStringBuilder = new StringBuilder();\r\n \r\n \tdouble totalDuration = baseNote.getDecimalDuration();\r\n double actualDuration = 0.0d;\r\n \r\n byte secondNote = baseNote.getValue();\r\n \r\n if(trillDirection == EFFECT_DIRECTION_UP){\r\n \tsecondNote++;\r\n } else if(trillDirection == EFFECT_DIRECTION_DOWN){\r\n \tsecondNote--;\r\n }\r\n \r\n double remainingDuration = totalDuration - (2*singleSoundDuration);\r\n if(remainingDuration > 0.0d){\r\n \t\r\n \tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \tactualDuration+=singleSoundDuration;\r\n \t\r\n \twhile(actualDuration < totalDuration){\r\n \t\tif(actualDuration + (2*singleSoundDuration) < totalDuration){\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, secondNote, singleSoundDuration);\r\n \t\t\tactualDuration += singleSoundDuration;\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \t\t\tactualDuration += singleSoundDuration;\r\n \t\t} else if(actualDuration + singleSoundDuration > totalDuration){\r\n \t\t\tdouble gapDuration = totalDuration - actualDuration;\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), gapDuration);\r\n \t\t\tactualDuration+=gapDuration;\r\n \t\t} else {\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \t\t\tactualDuration+=singleSoundDuration;\r\n \t\t}\r\n \t}\r\n \treturn new Pattern(musicStringBuilder.toString().trim());\r\n } else {\r\n \treturn new Pattern(baseNote.getMusicString());\r\n }\r\n }", "public static PatternInterface trill(Note baseNote){\r\n \treturn trill(baseNote, EFFECT_DIRECTION_UP);\r\n }", "public static PatternInterface trill(Note note1, Note note2, double duration, int numSteps)\r\n {\r\n return hammerOn(note1, note2, duration, numSteps);\r\n }", "Turtle createTurtle();", "TRule createTRule();", "public TrianglePatternToy(int number){ \n this.number = number;\n }", "public List<Tone> getTones() {\n return new ArrayList<>(this.notes.keySet());\n }", "public Triangle getTridroit() {\r\n return tridroit;\r\n }", "public static float[] trilaterate(float[] p1, float r1, float[] p2, float r2, float[] p3, float r3) {\r\n float[] pos = new float[2];\r\n pos[0] = calcX(r1, r2, p2[0]);\r\n pos[1] = calcY(r1, r3, p3[0], p3[1], pos[0]);\r\n return pos;\r\n }", "public String transposeChords() {\n\n\t\t//Tools from parent class\n\t\tArrayList<Integer> transposedChords = new ArrayList<>();\n\t\tChordList chords = new ChordList();\n\t\tString[] chordList = chords.getNotes();\n\t\tint[] scaleMajor = chords.getMajor();\n\t\tint[] scaleMinor = chords.getMinor();\n\n\t\t//custom ASCII table conversion\n\t\tint[] fixedNotes = new int[m_notes.length()];\n\t\tString[] userNotes = m_notes.split(\" \");\n\n\t\tfor(int i = 0; i < m_notes.length(); i++) {\n\t\t\tfixedNotes[i] = chords.noteIndex(userNotes[i]);\n\t\t}\n\n\t\t//Cycle each note in notes passed in by user\n\t\tint cycle = 0;\n\n\t\tfor(int note = 0; note < fixedNotes.length; note++) {\n\n\t\t\tif(cycle >= scaleMajor.length)\n\t\t\t\tcycle = 0;\n\n\t\t\t//Check for type of scale\n\t\t\t//If the scaletype is major\n\t\t\tif(m_scaleType.equals(\"major\")) {\n\n\t\t\t\ttransposedChords.add(fixedNotes[note] + scaleMajor[cycle] - OFFSET);\n\n\t\t\t} else if(m_scaleType.equals(\"minor\")) {\n\n\t\t\t}\n\n\t\t\tcycle++;\n\t\t}\n\n\t\treturn \"Transposed chords in \" + m_scale + \" \" + m_scaleType + \": \" + transposedChords;\n\t}", "@Override\n public double getMaterialTraversedInRL(Hep3Vector dir) {\n double cth = Math.abs(VecOp.dot(dir, _w));\n double t = _materials.getThicknessInRL();\n return t / cth;\n }", "public static TriplePattern createTriplePatternFromJSON(final JSONObject triplePatternJson) throws JSONException {\n\t\tfinal JSONArray itemsJson = (JSONArray) triplePatternJson.get(\"triple_pattern\");\n\t\tfinal Item[] items = new Item[3];\n\t\tfor (int h = 0; h < 3; h++) {\n\t\t\titems[h] = Helper.createItemFromJSON(itemsJson.getJSONObject(h));\n\t\t}\n\t\treturn new TriplePattern(items[0], items[1], items[2]);\n\t}", "public ParticleMesh getMissileTrail() {\r\n for (int x = 0, tSize = missileTrails.size(); x < tSize; x++) {\r\n ParticleMesh e = missileTrails.get(x);\r\n if (!e.isActive()) {\r\n e.getParticleController().setRepeatType(Controller.RT_WRAP);\r\n e.forceRespawn();\r\n return e;\r\n }\r\n }\r\n return createMissileTrail();\r\n }", "public Note noteAt(int interval) {\n\t\tint newMidiNote = getMidiNumber() + interval;\n\t\t\n\t\treturn new Note(newMidiNote);\n\t}", "Tulip getType() { return new Tulip(); }", "abstract public TurtleModel getTurtle();", "@Test\n\t\tpublic void testTrilateration() {\n\t\t\t// Initialize 3 points\n\t\t\tPoint2D p1 = new Point2D.Double(1,1);\n\t\t\tPoint2D p2 = new Point2D.Double(6,3);\n\t\t\tPoint2D p3 = new Point2D.Double(0,9);\n\t\t\t\n\t\t\t// Initialize 3 radius. r1 associated with p1 and so on.\n\t\t\tdouble r1 = 7.2111;\n\t\t\tdouble r2 = 4.1231;\n\t\t\tdouble r3 = 5.3852;\n\t\t\t\n\t\t\t// Initialized the Triangulate object and load points and radii\n\t\t\tTriangulate test = new Triangulate();\n\t\t\ttest.setPoints(p1, p2, p3);\n\t\t\ttest.setRadius(r1, r2, r3);\n\t\t\t\n\t\t\t// Set the given and actual location with the error we have\n\t\t\tPoint2D loc = test.trilaterate();\n\t\t\tPoint2D actual = new Point2D.Double(5, 7);\n\t\t\tdouble err = 1e-4; \n\t\t\t\n\t\t\t// Test x and y coordinates within a certain error\n\t\t\tassertEquals(actual.getX(), loc.getX(), err);\n\t\t\tassertEquals(actual.getY(), loc.getY(), err);\n\n\t\t}", "String getDelayPattern();", "public Trap(FloorTile where, StairTile trap, CharacterModifier effect) {\n super(where, FLOOR, effect);\n this.trapDoor = trap; // todo: stairtile ensure same room? ensure from of stair?\n if (trap != null) {\n trap.trap = this;\n if (trap.stair != null && trap.stair.toTile != null) trap.stair.toTile.trap = this; // todo have a function for that\n }\n }", "public static PatternInterface slide(Note note1, Note note2, double duration, int numSteps)\r\n {\r\n StringBuilder buddy = new StringBuilder();\r\n double durationPerStep = duration / numSteps;\r\n double freq1 = Note.getFrequencyForNote(note1.getValue());\r\n double freq2 = Note.getFrequencyForNote(note2.getValue());\r\n double differencePerStep = (freq2-freq1) / numSteps;\r\n\r\n for (int i=0; i < numSteps; i++)\r\n {\r\n buddy.append(MicrotoneNotation.convertFrequencyToMusicString(freq1));\r\n buddy.append(\"/\");\r\n buddy.append(durationPerStep);\r\n buddy.append(MicrotoneNotation.getResetPitchWheelString());\r\n buddy.append(\" \");\r\n freq1 += differencePerStep;\r\n }\r\n\r\n PatternInterface pattern = new Pattern(buddy.toString());\r\n return pattern;\r\n }", "private Line getTrajectory() {\n Point target = this.topLeft.add(this.velocity).asPoint();\n return new Line(this.topLeft.asPoint(), target);\n }", "static Tour sequence() {\r\n\t\tTour tr = new Tour();\r\n\t\tfor (int i = 0; i < tr.length(); i++) {\r\n\t\t\ttr.index[i] = i;\r\n\t\t}\r\n\t\ttr.distance = tr.distance();\r\n\t\treturn tr;\r\n\t}", "public abstract Tone getTone();", "public static PatternInterface graceNote(Note graceNote, Note baseNote, double graceNoteDuration){\r\n \tPattern gracePattern = new Pattern(graceNote.getMusicString());\r\n \treturn addOrnament(gracePattern, baseNote, graceNoteDuration);\r\n }", "public Trips(String alias) {\n this(alias, TRIPS);\n }", "private ParticleMesh createMissileTrail() {\r\n ParticleMesh pMesh = ParticleFactory.buildParticles(\"tail\", 200,\r\n ParticleType.Quad);\r\n pMesh.setEmissionDirection(new Vector3f(1, 1, 1));\r\n pMesh.setInitialVelocity(0);\r\n pMesh.setStartSize(1f);\r\n pMesh.setEndSize(3.45f);\r\n pMesh.setMinimumLifeTime(500);\r\n pMesh.setMaximumLifeTime(500);\r\n pMesh.setStartColor(ColorRGBA.lightGray.clone());\r\n pMesh.setEndColor(ColorRGBA.black.clone());\r\n pMesh.setParticleSpinSpeed(180 * FastMath.DEG_TO_RAD);\r\n pMesh.getParticleController().setControlFlow(true);\r\n// pMesh.setReleaseRate(500);\r\n pMesh.forceRespawn();\r\n \r\n pMesh.setModelBound(new BoundingBox());\r\n pMesh.updateModelBound();\r\n pMesh.setCullHint(Spatial.CullHint.Never);\r\n\r\n // removes the missile from the scene after the particle trail has died\r\n pMesh.getParticleController().addListener(new OnDeadListener());\r\n pMesh.setRenderState(ts);\r\n pMesh.setRenderState(bs);\r\n pMesh.setRenderState(zs);\r\n \r\n missileTrails.add(pMesh);\r\n \r\n return pMesh;\r\n }", "private Rotor readRotor() {\n try {\n String currCycle = _config.next();\n String permutation = \"\";\n while (currCycle.contains(\"(\")) {\n if (!currCycle.contains(\")\") || currCycle.contains(\"*\")) {\n throw error(\"Wrong cycle format\");\n }\n if (_config.hasNext()) {\n permutation = permutation + currCycle;\n currCycle = _config.next();\n } else if (!_config.hasNext()) {\n permutation = permutation + currCycle;\n break;\n }\n }\n String tempname = _name.toUpperCase();\n if (_config.hasNext()) {\n _name = currCycle;\n }\n if (notches.charAt(0) == 'M') {\n return new MovingRotor(tempname,\n new Permutation(permutation, _alphabet),\n notches.substring(1));\n } else if (notches.charAt(0) == 'N') {\n return new FixedRotor(tempname,\n new Permutation(permutation, _alphabet));\n } else {\n return new Reflector(tempname,\n new Permutation(permutation, _alphabet));\n }\n } catch (NoSuchElementException excp) {\n throw error(\"bad rotor description\");\n }\n }", "public static int getNormalizedPitch(Note note) {\n try {\n String pitch = note.getPitch().toString();\n String octave = new Integer(note.getOctave()).toString();\n\n String target = null;\n\n if (note.getPitch().equals(Pitch.R)) {\n target = \"REST\";\n } else {\n if(note.getAlteration().equals(Alteration.N))\n target = pitch.concat(octave);\n else if(note.getAlteration().equals(Alteration.F))\n target = pitch.concat(\"F\").concat(octave);\n else\n target = pitch.concat(\"S\").concat(octave);\n }\n\n \n\n Class cClass = ConverterUtil.class;\n Field field = cClass.getField(target);\n Integer value = (Integer) field.get(null);\n\n return value.intValue()%12;\n } catch (Exception e) {\n e.printStackTrace();\n }\n return 0;\n }", "void rotateTurtle(int turtleIndex, double degrees);", "public TFRule createTFRuleFromLine(String line) {\n\n line = removeTailComment(line);\n\n //skip blank lines or comments\n line = line.trim();\n\n try (Scanner rowScanner = new Scanner(line)) {\n rowScanner.useDelimiter(\",\");\n\n SensorData lhsExt = null;\n SensorData rhsExt = null;\n\n int[] lhsInt = null;\n String action = \"\\0\";\n\n double conf = -1.0;\n\n String lhsIntData = rowScanner.next().trim();\n\n try {\n lhsInt = getLHSIntFromString(lhsIntData);\n lhsExt = getSDFromString(rowScanner.next().trim());\n action = rowScanner.next().trim();\n rhsExt = getSDFromString(rowScanner.next().trim());\n String dblStr = rowScanner.next().trim();\n conf = Double.parseDouble(dblStr);\n } catch(InputMismatchException ime) {\n System.err.println(\"oh no!\");\n }\n\n return new TFRule(this.agent, action.charAt(0), lhsInt, lhsExt, rhsExt, conf);\n }\n }", "public static PatternInterface graceNote(Note graceNote, Note baseNote){\r\n \treturn graceNote(graceNote, baseNote, THIRTY_SECOND);\r\n }", "public void createTurtle (TurtleView tView) {\n myController.createTurtle(tView);\n }", "public List<PatternItem> pattern() {\n List<PatternItem> out = new ArrayList<>();\n int level = 0;\n int n = 0;\n String c;\n\n boolean done = false;\n while (!done) {\n DNAToken token = parser.step();\n\n switch (token) {\n case CONT:\n break;\n case C:\n out.add(new PatternItem(PatternItem.Type.BASE, 'I'));\n break;\n case F:\n out.add(new PatternItem(PatternItem.Type.BASE, 'C'));\n break;\n case P:\n out.add(new PatternItem(PatternItem.Type.BASE, 'F'));\n break;\n case IC:\n out.add(new PatternItem(PatternItem.Type.BASE, 'P'));\n break;\n case IP:\n n = parser.nat();\n out.add(new PatternItem(PatternItem.Type.JUMP, n));\n break;\n case IF:\n parser.next(); // Consume one more character for no good reason\n c = parser.consts();\n out.add(new PatternItem(PatternItem.Type.SEARCH, c));\n break;\n case IIP:\n level += 1;\n out.add(new PatternItem(PatternItem.Type.OPEN));\n break;\n case IIF:\n case IIC:\n if (level == 0) {\n done = true;\n } else {\n level -= 1;\n out.add(new PatternItem(PatternItem.Type.CLOSE));\n }\n break;\n case III:\n rna.concat(dna.substring(0, 7));\n dna.trunc(7);\n break;\n default:\n finish();\n }\n }\n\n return out;\n }", "public static Truck nextTruck(){\n Truck truck = null;\n Random r = new Random();\n switch (r.nextInt(2)){\n case 0: {\n truck = new Pickup(4000 + r.nextInt(2000), 10 + r.nextInt(10),\n 150 + r.nextInt(50), 4 + r.nextInt(4));\n break;\n }\n case 1: {\n truck = new Van(5000 + r.nextInt(2000), 12 + r.nextInt(10),\n 180 + r.nextInt(50), 3 + r.nextInt(2));\n break;\n }\n }\n return truck;\n }", "public int liftStepper() {\n if(robot.wrist.getPosition()> .25)\n {\n if(robot.jaw.getPosition()> .25)\n {\n telemetry.addLine(\"I could self damage.\");\n }\n }\n else{\n if (this.improvedGamepad1.y.isInitialPress()) {\n step = step + 1;\n if (step > 5) {\n step = 5;\n }\n power = .5;\n //up by one\n }\n if (this.improvedGamepad1.a.isInitialPress()) {\n step = step - 1;\n if (step < 0) {\n step = 0;\n }\n power = .5;\n //down by one\n }\n\n if (this.improvedGamepad1.b.isInitialPress()) {\n topStep = step;\n step = 0;\n power = .7;\n //to bottom\n }\n\n if (this.improvedGamepad1.x.isInitialPress()) {\n step = topStep;\n power = .7;\n //to top\n }\n\n }\n\n telemetry.addData(\"Step\", step);\n telemetry.addData(\"Top Step\", topStep);\n telemetry.update();\n\n\n //DcMotor lift = this.hardwareMap.dcMotor.get(\"lift\");\n int targetPosition = step * 750;\n\n robot.lift.setTargetPosition(targetPosition);\n robot.lift.setMode(DcMotor.RunMode.RUN_TO_POSITION);\n robot.lift.setPower(power);\n\n telemetry.update();\n return step;\n\n }", "public Strand getReverseStrand() throws BaseException\n {\n Type newType;\n \n //TODO: determine the value of newType\n // If the current type is RNA, keep the new type as RNA\n // If the current type is 3', change it to 5'\n // If the current type if 5', change it to 3'\n //Remove the following line -- it is for default compilation\n newType = Type.RNA;\n \n Base[] rev;\n //TODO: create a new array of Bases that is the reverse of the current\n // sequence. Store the result in rev.\n //Remove the following line -- it is for default compilation\n rev = new Base[]{};\n \n return new Strand(newType, rev);\n }", "void crear(Tonelaje tonelaje);", "public static String getTrail() {\n\t\treturn trail.toString();\n\t}", "public RolandMT32RhythmSetupTempDriver() {\n super(\"Rhythm Setup Temp\", \"Fred Jan Kraan\");\n sysexID = \"F041**16\";\n patchSize = HSIZE + SSIZE + 1;\n patchNameStart = 0;\n patchNameSize = 0;\n deviceIDoffset = 0;\n checksumStart = 5;\n checksumEnd = 10;\n checksumOffset = 0;\n bankNumbers = new String[] {\n \"\" };\n patchNumbers = new String[] {\n \"\" };\n }", "public int durationToTime(NoteDuration dur)\n\t{\n\t\tint eighth = quarternote / 2;\n\t\tint sixteenth = eighth / 2;\n\n\t\tswitch (dur)\n\t\t{\n\t\t\tcase Whole:\n\t\t\t\treturn quarternote * 4;\n\t\t\tcase DottedHalf:\n\t\t\t\treturn quarternote * 3;\n\t\t\tcase Half:\n\t\t\t\treturn quarternote * 2;\n\t\t\tcase DottedQuarter:\n\t\t\t\treturn 3 * eighth;\n\t\t\tcase Quarter:\n\t\t\t\treturn quarternote;\n\t\t\tcase DottedEighth:\n\t\t\t\treturn 3 * sixteenth;\n\t\t\tcase Eighth:\n\t\t\t\treturn eighth;\n\t\t\tcase Triplet:\n\t\t\t\treturn quarternote / 3;\n\t\t\tcase Sixteenth:\n\t\t\t\treturn sixteenth;\n\t\t\tcase ThirtySecond:\n\t\t\t\treturn sixteenth / 2;\n\t\t\tcase HundredTwentyEight:\n\t\t\t\treturn quarternote / 32;\n\t\t\tdefault:\n\t\t\t\treturn 0;\n\t\t}//end switch\n\t}", "public Pattern getHorizPattern() {\n\t\treturn horizPattern;\n\t}", "public Turtle(String name) {\n this.name = name;\n }", "public final StepPattern getStepPattern() {\n/* 176 */ return this.m_stepPattern;\n/* */ }", "public static String generaTemp(){\n return \"t$\"+temp++;\n }", "public static String generaTemp(){\n return \"t$\"+temp++;\n }", "public static String generaTemp(){\n return \"t$\"+temp++;\n }", "public static String generaTemp(){\n return \"t$\"+temp++;\n }", "List<TransmissionNote> getTransmissionNotes(Long transmissionId);", "@Override\n public JSLFrame editPatch(Patch p) {\n return new RolandMT32RhythmSetupTempEditor(p);\n }", "public Note(int note, char accidental, Pane notePane) {\n _note = note;\n _accidental = accidental;\n _accidentalImage = new ImageView();\n this.setUpLedger();\n this.setUpNote();\n }", "static MoveStepType turnForLateralShift(final MoveStepType shift) {\n switch (shift) {\n case LATERAL_LEFT:\n return MoveStepType.TURN_LEFT;\n case LATERAL_RIGHT:\n return MoveStepType.TURN_RIGHT;\n case LATERAL_LEFT_BACKWARDS:\n return MoveStepType.TURN_LEFT;\n case LATERAL_RIGHT_BACKWARDS:\n return MoveStepType.TURN_RIGHT;\n default:\n return shift;\n }\n }", "public ArrowHead(Point2D tip, Point2D origin, double length, double flair) {\n\n _pts = new Point2D[4];\n\n // Calculate horizontal and vertical components of slope\n double edx = tip.getX() - origin.getX();\n double edy = tip.getY() - origin.getY();\n\n double len = Math.sqrt(edx * edx + edy * edy);\n\n edx /= len;\n edy /= len;\n\n Point2D arrowHeadLeftBasePt =\n new Point2D.Double(tip.getX() - (length * edx),\n tip.getY() - (length * edy));\n Point2D a1pt4 =\n new Point2D.Double(tip.getX() - ((length - 3) * edx),\n tip.getY() - ((length - 3) * edy));\n\n\n // Calculate the points of arrowhead 1\n Point2D a1pt1 =\n new Point2D.Double((arrowHeadLeftBasePt.getX() + (2 * edy * flair)),\n (arrowHeadLeftBasePt.getY() - (2 * edx * flair)));\n\n Point2D a1pt3 =\n new Point2D.Double((arrowHeadLeftBasePt.getX() - (2 * edy * flair)),\n (arrowHeadLeftBasePt.getY() + (2 * edx * flair)));\n\n _pts[0] = a1pt1;\n _pts[1] = new Point2D.Double(tip.getX(), tip.getY());\n _pts[2] = a1pt3;\n _pts[3] = a1pt4;\n }", "public List<TemplItem> template() {\n List<TemplItem> items = new ArrayList<>();\n int l;\n int n;\n\n boolean done = false;\n while (!done) {\n DNAToken token = parser.step();\n\n switch (token) {\n case CONT:\n break;\n case C:\n items.add(new TemplItem(TemplItem.Type.BASE, 'I'));\n break;\n case F:\n items.add(new TemplItem(TemplItem.Type.BASE, 'C'));\n break;\n case P:\n items.add(new TemplItem(TemplItem.Type.BASE, 'F'));\n break;\n case IC:\n items.add(new TemplItem(TemplItem.Type.BASE, 'P'));\n break;\n case IP:\n case IF:\n l = parser.nat();\n n = parser.nat();\n items.add(new TemplItem(TemplItem.Type.PROT, n, l));\n break;\n case IIP:\n n = parser.nat();\n items.add(new TemplItem(TemplItem.Type.LEN, n));\n break;\n case IIF:\n case IIC:\n done = true;\n break;\n case III:\n rna.concat(dna.substring(0, 7));\n dna.trunc(7);\n break;\n case DONE:\n done = true;\n break;\n default:\n finish();\n }\n }\n\n return items;\n }", "private void playNotes()\n\t{\n\t\t//Update tracks when we can shift chords.\n\t\tChord curChord = ClearComposer.cc.getChord();\n\t\tif (index % ClearComposer.cc.getChordInterval() == 0 && (prevChord == null || prevChord != curChord))\n\t\t{\n\t\t\tprevChord = curChord;\n\t\t\ttracks.forEach(GraphicTrack::updateChord);\n\t\t\tClearComposer.cc.updateChordOutlines();\n\t\t}\n\n\t\tfor (GraphicTrack track : tracks)\n\t\t{\n\t\t\tint temp = track.playNote(index);\n\t\t\tif (temp != -1)\n\t\t\t\tMusicPlayer.playNote(temp);\n\t\t}\n\n\t\tindex++;\n\t\twhile (index >= ClearComposer.cc.getNumNotes())\n\t\t\tindex -= ClearComposer.cc.getNumNotes();\n\t}", "public TriplePattern getPredicateBasedTriplePattern( String pred ) ;", "private Pitch(String note)\n {\n this.note = note;\n }", "public Tulip(){\n super(CropName.TULIP, CropType.FLOWER, CropStatus.WAITING, 90, 2, 2, 3, 0, 1, 1, 1, 7);\n }", "public String playGuitar(){\n\t\t String notes = \"[A(0.25), G(2), E(0.5), C(1), C(2), D(0.25), E(2), C(2), B(0.25), C(4), C(1), G(0.25),A(1), C(2), D(1),C(4)]\";\n\t\treturn notes;\n\t}", "public static PatternInterface addOrnament(Pattern ornament, Note baseNote){\r\n \treturn addOrnament(ornament, baseNote, THIRTY_SECOND);\r\n }", "@Override\n\tprotected Trunk makeNew(final TwilioTrunkingClient client, final Map<String, Object> params) {\n\t\treturn new Trunk(client, params);\n\t}", "public Piano(int numNotes){\n pStrings = new InstString[numNotes][3];\n for(int a = 0; a < numNotes; a++){\n double freq = 440 * Math.pow(2, (double)(a-24)/(double)12);\n pStrings[a][0] = new GuitarString(freq);\n pStrings[a][1] = new GuitarString(freq + .45);\n pStrings[a][2] = new GuitarString(freq - .45);\n }\n }", "CompositionBuilder<T> addNote(int start, int end, int instrument, int pitch, int volume);", "public List<Triple> nextTriples(TriplePattern[] patterns) throws TrippiException {\n Map<String, Node> map = next();\n if ( map == null ) return null;\n List<Triple> triples = new ArrayList<Triple>();\n for (int i = 0; i < patterns.length; i++) {\n Triple triple = patterns[i].match(map);\n if (triple != null) {\n triples.add(triple);\n }\n }\n return triples;\n }", "public String getTribe() {\n\t\treturn tribeField.getText();\n\t}", "public IPlay getTape(boolean flag) {\n if (flag) {\n class Record implements IPlay { // область видимости scope {flag = true}\n @Override\n public void play() {\n System.out.println(\"Record.play\");\n }\n } // eof class\n return new Record();\n\n }else{\n class MidiBoard implements IPlay { // область видимости scope {flag = false}\n @Override\n public void play() {\n System.out.println(\"MidiBoard.play\");\n }\n } // eof class\n return new MidiBoard();\n }\n }", "public Trip create(final Manager manager) {\n\t\tthis.managerService.checkPrincipal();\n\n\t\tCollection<ApplicationFor> applicationsFor;\n\t\tCollection<AuditRecord> auditRecords;\n\t\tCollection<Note> notes;\n\t\tCollection<Stage> stages;\n\t\tCollection<Tag> tags;\n\t\tTrip trip;\n\n\t\ttrip = new Trip();\n\t\tapplicationsFor = new ArrayList<ApplicationFor>();\n\t\tauditRecords = new ArrayList<AuditRecord>();\n\t\tnotes = new ArrayList<Note>();\n\t\tstages = new ArrayList<Stage>();\n\t\ttags = new ArrayList<Tag>();\n\n\t\ttrip.setManager(manager);\n\t\ttrip.setApplicationsFor(applicationsFor);\n\t\ttrip.setAuditRecords(auditRecords);\n\t\ttrip.setNotes(notes);\n\t\ttrip.setStages(stages);\n\t\ttrip.setTags(tags);\n\t\ttrip.setTicker(this.generatedTicker());\n\n\t\treturn trip;\n\t}", "public static Texture getTut(){\n //set a linear filter to clean image\n tuts.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);\n //return image\n return tuts;\n }", "@Override\n public double getMaterialTraversed(Hep3Vector dir) {\n double cth = Math.abs(VecOp.dot(dir, _w));\n double t = _materials.getThickness();\n return t / cth;\n }", "TR createTR();", "private boolean[][] rotatePattern(int steps, boolean[][] pattern) {\n if (steps < 1)\n return pattern;\n boolean[][] rotated = new boolean[4][4];\n if (steps == 1) {\n for (int i = 0; i < pattern.length; i++)\n for (int j = 0; j < pattern[i].length; j++)\n rotated[i][j] = pattern[j][pattern.length - 1 - i];\n } else if (steps == 2) {\n for (int i = 0; i < pattern.length; i++)\n for (int j = 0; j < pattern[i].length; j++)\n rotated[i][j] = pattern[pattern.length - 1 - i][pattern\n .length - 1 - j];\n } else {\n for (int i = 0; i < pattern.length; i++)\n for (int j = 0; j < pattern[i].length; j++)\n rotated[i][j] = pattern[pattern.length - 1 - j][i];\n }\n return rotated;\n }", "@Override\n\tpublic String toString() {\n\t\treturn \"Triangulo [b_=\" + b_ + \", h_=\" + h_ + \", Area=\" + Area() +\n\t\t\", Diameter=\" + super.Perimeter() + \", Diagonals=\" + super.Diagonals() +\"]\";\n\t}", "public Chord getPreviousChordInVoice ()\r\n {\r\n return voice.getPreviousChord(this);\r\n }", "Trip(String filePath, Double wheelDiameter) {\n this.filePath_ = filePath;\n this.wheelDiameter_ = wheelDiameter;\n }", "TrafficTreatment treatment();", "public static MotorEncoderFixture<Talon> getTalonPair() {\n return new MotorEncoderFixture<Talon>() {\n @Override\n protected Talon giveMotorController() {\n return new Talon(kTalonChannel);\n }\n\n @Override\n protected DigitalInput giveDigitalInputA() {\n return new DigitalInput(0);\n }\n\n @Override\n protected DigitalInput giveDigitalInputB() {\n return new DigitalInput(1);\n }\n\n @Override\n public int getPDPChannel() {\n return kTalonPDPChannel;\n }\n };\n }", "public NewTransitionRecord(int from, int to, double r, int t, boolean isFTan) {\r\n fromstate = from;\r\n tostate = to;\r\n rate = r;\r\n transition = t;\r\n if (isFTan) {\r\n isFromTangible = 'T';\r\n } else {\r\n isFromTangible = 'V';\r\n }\r\n }", "public static Track generateTrack() {\n List<Position> positions = new ArrayList<>();\n DirectionsRoute dr = DirectionsRoute.fromJson(getJsonFromAssets(GlobalContext.getContext(),\"testDirections.json\"));\n positions.add(new Position(48.408880, 9.997507,1587652587));\n positions.add(new Position(48.408980, 9.997807,1587652597));\n Track track = new Track(\"nullacht15\", new Rating(), \"Heimweg\", \"Das ist meine super tolle Strecke\", 1585773516, 25,\n dr, new ArrayList<>(), positions.get(0),positions.get(1),true);\n return track;\n }", "public TextRotation getRotationRelativity();", "String notes();", "public Note(int duration, int offset, int pitch, int channel, int velocity) {\n this.duration = duration;\n this.offset = offset;\n this.pitch = pitch;\n this.channel = channel;\n this.velocity = velocity;\n }", "public Trips() {\n this(\"trips\", null);\n }", "public Voice transpose(int semitonesUp){\n List<Bar> temp= new ArrayList<>();\n for(Bar bar:voices){\n temp.add(bar.transpose(semitonesUp));\n }\n checkRep();\n return new Voice(temp);\n }", "public float getTaille() {\r\n return taille;\r\n }", "ReferenceTreatment createReferenceTreatment();", "int getTonicNote(){\n String lastnote=\"\";\n int result;\n lastnote += Strinput.toCharArray()[Strinput.length()-4];\n lastnote += Strinput.toCharArray()[Strinput.length()-3];\n result = Integer.parseInt(lastnote);\n if(result<72){\n return result-60;\n }else{\n return result-12-60;\n }\n }", "public Turret toTurret(GameLogic gameLogic) {\n return new Turret(gameLogic,range,fireRate,type,power,position);\n }", "@Override\n public Pattern createPattern(Image image, String repeat) {\n return new Pattern(image, repeat);\n }", "public Polygon getTriangle() {\n\n Matrix4 normalProjection = new Matrix4().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\n\n spriteDebugger.setProjectionMatrix(normalProjection);\n spriteDebugger.begin(ShapeRenderer.ShapeType.Line);\n spriteDebugger.polygon(getLine().getVertices());\n spriteDebugger.setColor(Color.PURPLE);\n spriteDebugger.end();\n\n spriteDebugger.end();\n return getLine();\n }", "public static Note createNote(int octave, Pitch pitch, int startBeat, int endBeat) {\n return new NoteImpl(octave, pitch, startBeat, endBeat);\n }", "public static PatternInterface addOrnament(Pattern ornament, Note baseNote, double longestOrnamentDuration){\r\n \tPatternInvestigator investigator = new PatternInvestigator();\r\n \tMusicStringParser stringParser = new MusicStringParser();\r\n \t\r\n \tstringParser.addParserListener(investigator);\r\n \tstringParser.parse(ornament);\r\n \t\r\n \tdouble longestDuration = investigator.getLongestDecimalDuration();\r\n \tdouble durationChange = longestOrnamentDuration / longestDuration;\r\n \t\r\n \tDurationPatternTransformer transformer = new DurationPatternTransformer(durationChange);\r\n \t\r\n \tPatternInterface result = transformer.transform(ornament);\r\n \t\r\n \tstringParser.removeParserListener(investigator);\r\n \tinvestigator = new PatternInvestigator();\r\n \tstringParser.addParserListener(investigator);\r\n \tstringParser.parse(result);\r\n \t\r\n \tif(investigator.getTotalDecimalDuration() < baseNote.getDecimalDuration()){\r\n \t\tdouble remainingDuration = baseNote.getDecimalDuration() - investigator.getTotalDecimalDuration();\r\n \t\tbaseNote.setDecimalDuration(remainingDuration);\r\n \t\tresult.add(baseNote.getMusicString());\r\n \t\treturn result;\r\n \t} else {\r\n \t\treturn new Pattern(baseNote.getMusicString());\r\n \t}\r\n }", "public List<Chord> getFollowingTiedChords ()\r\n {\r\n List<Chord> tied = new ArrayList<>();\r\n\r\n for (TreeNode node : children) {\r\n Note note = (Note) node;\r\n\r\n for (Slur slur : note.getSlurs()) {\r\n if (slur.isTie()\r\n && (slur.getLeftNote() == note)\r\n && (slur.getRightNote() != null)) {\r\n tied.add(slur.getRightNote().getChord());\r\n }\r\n }\r\n }\r\n\r\n Collections.sort(tied, Chord.byAbscissa);\r\n return tied;\r\n }", "static int[] createRhythmLevelMessage(int part, byte level){\r\n\t\tif(part < 0) part = 0;\r\n\t\tif(part > 15) part = 15;\r\n\t\t\r\n\t\tint[] data = new int[5];\r\n\t\tdata[0] = 0x11 + part / 4;\r\n\t\tdata[1] = 0x10 + (part % 4) * 0x20;\r\n\t\tdata[2] = 0x00;\r\n\t\tdata[3] = 0x0C;\r\n\t\tdata[4] = level;\r\n\t\treturn createMessage(data);\r\n\t}", "public abstract void tilt(long ms);", "public Stimulus toTCUMLStimulus();", "public static Note createNote(int value, int startBeat, int endBeat, int instrument, int\n volume) {\n return createNote((value / 12) - 1, Pitch.getPitch(value % 12), startBeat, endBeat, instrument,\n volume);\n }", "public int getTaillePoule (){\n\t\treturn 3;\n\t}", "@Override\r\n\t\t\t\t\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\t\t\t\t\tNoteInJson[] pattern=gpt.getPattern();\r\n\t\t\t\t\t\t\t\t\t\tif(change_tempo){\r\n\t\t\t\t\t\t\t\t\t\t\tPatternMaker.changeSpeed(pattern, ratio);\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\tgotoPractice(pattern);\r\n\t\t\t\t\t\t\t\t\t}", "public static Note getNoteFromID(int id, Shift prefShift) {\n\t\tint shiftNum = prefShift.getShiftID();\n\n\t\tint octave = (id / 12) - 1;\n\t\tint toneMod = (id - shiftNum + 12) % 12;\n\n\t\tTone tone = Tone.notes.get(toneMod);\n\t\tint shiftID = shiftNum + 2;\n\n\t\tif (tone == null) {\n\t\t\tif (shiftNum <= 0) {\n\t\t\t\ttone = Tone.notes.get((toneMod + 11) % 12);\n\t\t\t\tshiftID++;\n\t\t\t} else {\n\t\t\t\ttone = Tone.notes.get((toneMod + 1) % 12);\n\t\t\t\tshiftID--;\n\t\t\t}\n\t\t}\n\n\t\tNote note = new Note(tone, Shift.shifts.get(shiftID), octave);\n\t\treturn note;\n\t}", "public double getTempoManipulator(int time) {\n if (time < duration * ((double) pStart / 100)) // BEFORE INCREASE\n return roundWithPrecision(pOffset, 3);\n else if (time > duration * (((double) pStart + (double) pDuration) / 100)) // AFTER INCREASE\n return roundWithPrecision(pOffset * pManipulation, 3);\n else // DURING INCREASE\n {\n double startOfIncrease = (((double) pStart) / 100 * duration);\n double lengthOfIncrease = (((double) pDuration) / 100 * duration);\n\n double at = time - startOfIncrease;\n double atModifier = at / lengthOfIncrease;\n return roundWithPrecision(((1 + ((pManipulation - 1) * atModifier)) * pOffset), 3);\n }\n }", "public static Note createNote(int octave, Pitch pitch, int startBeat, int endBeat, int\n instrument, int volume) {\n return new NoteImpl(octave, pitch, startBeat, endBeat, instrument, volume);\n }" ]
[ "0.68590736", "0.6606886", "0.554866", "0.4834209", "0.47879755", "0.47189727", "0.46204257", "0.45300588", "0.45186576", "0.4478301", "0.4475216", "0.4348912", "0.4337248", "0.43232042", "0.4305469", "0.43010896", "0.42876664", "0.4264", "0.42635745", "0.42360157", "0.423526", "0.42329717", "0.42145878", "0.42140043", "0.4187173", "0.41795805", "0.41776717", "0.41736743", "0.4151416", "0.4148468", "0.41484007", "0.41413668", "0.4089391", "0.40789518", "0.40776992", "0.40761045", "0.4061926", "0.40551957", "0.40480053", "0.4043499", "0.40420833", "0.4011443", "0.40092498", "0.39969853", "0.39969853", "0.39969853", "0.39969853", "0.39747062", "0.39291993", "0.39274913", "0.3922923", "0.39136574", "0.39041123", "0.38981733", "0.38976476", "0.38819396", "0.38779187", "0.3876433", "0.38744715", "0.38663146", "0.3857938", "0.38577533", "0.38530204", "0.38480586", "0.38464913", "0.38296834", "0.38259697", "0.38234788", "0.3822229", "0.38203424", "0.38161036", "0.38075742", "0.38057184", "0.3801087", "0.37973836", "0.3784723", "0.37781006", "0.37730154", "0.37647203", "0.37605482", "0.3756419", "0.37561107", "0.37544638", "0.37529492", "0.3747208", "0.37463403", "0.3742505", "0.3740334", "0.37392917", "0.37385404", "0.37368634", "0.37332657", "0.37320027", "0.3730813", "0.37304538", "0.37265202", "0.37246513", "0.37244266", "0.3721803", "0.37191486" ]
0.7370563
0
Returns a Pattern that plays a trill given a note, and trill direction. Example: trill(Note.createNote("C6h")) will produce this Pattern: [72]/0.03125 [73]/0.03125 [72]/0.03125 [73]/0.03125 [72]/0.03125 [73]/0.03125 [72]/0.03125 [73]/0.03125 [72]/0.03125 [73]/0.03125 [72]/0.03125 [73]/0.03125 [72]/0.03125 [73]/0.03125 [72]/0.03125 [72]/0.03125
public static PatternInterface trill(Note baseNote){ return trill(baseNote, EFFECT_DIRECTION_UP); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static PatternInterface trill(Note baseNote, char trillDirection){\r\n \treturn trill(baseNote, trillDirection, THIRTY_SECOND);\r\n }", "public static PatternInterface trill(Note baseNote, char trillDirection, double singleSoundDuration){\r\n \r\n \tStringBuilder musicStringBuilder = new StringBuilder();\r\n \r\n \tdouble totalDuration = baseNote.getDecimalDuration();\r\n double actualDuration = 0.0d;\r\n \r\n byte secondNote = baseNote.getValue();\r\n \r\n if(trillDirection == EFFECT_DIRECTION_UP){\r\n \tsecondNote++;\r\n } else if(trillDirection == EFFECT_DIRECTION_DOWN){\r\n \tsecondNote--;\r\n }\r\n \r\n double remainingDuration = totalDuration - (2*singleSoundDuration);\r\n if(remainingDuration > 0.0d){\r\n \t\r\n \tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \tactualDuration+=singleSoundDuration;\r\n \t\r\n \twhile(actualDuration < totalDuration){\r\n \t\tif(actualDuration + (2*singleSoundDuration) < totalDuration){\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, secondNote, singleSoundDuration);\r\n \t\t\tactualDuration += singleSoundDuration;\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \t\t\tactualDuration += singleSoundDuration;\r\n \t\t} else if(actualDuration + singleSoundDuration > totalDuration){\r\n \t\t\tdouble gapDuration = totalDuration - actualDuration;\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), gapDuration);\r\n \t\t\tactualDuration+=gapDuration;\r\n \t\t} else {\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \t\t\tactualDuration+=singleSoundDuration;\r\n \t\t}\r\n \t}\r\n \treturn new Pattern(musicStringBuilder.toString().trim());\r\n } else {\r\n \treturn new Pattern(baseNote.getMusicString());\r\n }\r\n }", "public static PatternInterface trill(Note note1, Note note2, double duration, int numSteps)\r\n {\r\n return hammerOn(note1, note2, duration, numSteps);\r\n }", "TRule createTRule();", "public TrianglePatternToy(int number){ \n this.number = number;\n }", "Turtle createTurtle();", "public List<Tone> getTones() {\n return new ArrayList<>(this.notes.keySet());\n }", "public Note noteAt(int interval) {\n\t\tint newMidiNote = getMidiNumber() + interval;\n\t\t\n\t\treturn new Note(newMidiNote);\n\t}", "public String transposeChords() {\n\n\t\t//Tools from parent class\n\t\tArrayList<Integer> transposedChords = new ArrayList<>();\n\t\tChordList chords = new ChordList();\n\t\tString[] chordList = chords.getNotes();\n\t\tint[] scaleMajor = chords.getMajor();\n\t\tint[] scaleMinor = chords.getMinor();\n\n\t\t//custom ASCII table conversion\n\t\tint[] fixedNotes = new int[m_notes.length()];\n\t\tString[] userNotes = m_notes.split(\" \");\n\n\t\tfor(int i = 0; i < m_notes.length(); i++) {\n\t\t\tfixedNotes[i] = chords.noteIndex(userNotes[i]);\n\t\t}\n\n\t\t//Cycle each note in notes passed in by user\n\t\tint cycle = 0;\n\n\t\tfor(int note = 0; note < fixedNotes.length; note++) {\n\n\t\t\tif(cycle >= scaleMajor.length)\n\t\t\t\tcycle = 0;\n\n\t\t\t//Check for type of scale\n\t\t\t//If the scaletype is major\n\t\t\tif(m_scaleType.equals(\"major\")) {\n\n\t\t\t\ttransposedChords.add(fixedNotes[note] + scaleMajor[cycle] - OFFSET);\n\n\t\t\t} else if(m_scaleType.equals(\"minor\")) {\n\n\t\t\t}\n\n\t\t\tcycle++;\n\t\t}\n\n\t\treturn \"Transposed chords in \" + m_scale + \" \" + m_scaleType + \": \" + transposedChords;\n\t}", "static Tour sequence() {\r\n\t\tTour tr = new Tour();\r\n\t\tfor (int i = 0; i < tr.length(); i++) {\r\n\t\t\ttr.index[i] = i;\r\n\t\t}\r\n\t\ttr.distance = tr.distance();\r\n\t\treturn tr;\r\n\t}", "public static PatternInterface slide(Note note1, Note note2, double duration, int numSteps)\r\n {\r\n StringBuilder buddy = new StringBuilder();\r\n double durationPerStep = duration / numSteps;\r\n double freq1 = Note.getFrequencyForNote(note1.getValue());\r\n double freq2 = Note.getFrequencyForNote(note2.getValue());\r\n double differencePerStep = (freq2-freq1) / numSteps;\r\n\r\n for (int i=0; i < numSteps; i++)\r\n {\r\n buddy.append(MicrotoneNotation.convertFrequencyToMusicString(freq1));\r\n buddy.append(\"/\");\r\n buddy.append(durationPerStep);\r\n buddy.append(MicrotoneNotation.getResetPitchWheelString());\r\n buddy.append(\" \");\r\n freq1 += differencePerStep;\r\n }\r\n\r\n PatternInterface pattern = new Pattern(buddy.toString());\r\n return pattern;\r\n }", "public Triangle getTridroit() {\r\n return tridroit;\r\n }", "public static TriplePattern createTriplePatternFromJSON(final JSONObject triplePatternJson) throws JSONException {\n\t\tfinal JSONArray itemsJson = (JSONArray) triplePatternJson.get(\"triple_pattern\");\n\t\tfinal Item[] items = new Item[3];\n\t\tfor (int h = 0; h < 3; h++) {\n\t\t\titems[h] = Helper.createItemFromJSON(itemsJson.getJSONObject(h));\n\t\t}\n\t\treturn new TriplePattern(items[0], items[1], items[2]);\n\t}", "public static PatternInterface graceNote(Note graceNote, Note baseNote, double graceNoteDuration){\r\n \tPattern gracePattern = new Pattern(graceNote.getMusicString());\r\n \treturn addOrnament(gracePattern, baseNote, graceNoteDuration);\r\n }", "String getDelayPattern();", "public Trips(String alias) {\n this(alias, TRIPS);\n }", "Tulip getType() { return new Tulip(); }", "public List<PatternItem> pattern() {\n List<PatternItem> out = new ArrayList<>();\n int level = 0;\n int n = 0;\n String c;\n\n boolean done = false;\n while (!done) {\n DNAToken token = parser.step();\n\n switch (token) {\n case CONT:\n break;\n case C:\n out.add(new PatternItem(PatternItem.Type.BASE, 'I'));\n break;\n case F:\n out.add(new PatternItem(PatternItem.Type.BASE, 'C'));\n break;\n case P:\n out.add(new PatternItem(PatternItem.Type.BASE, 'F'));\n break;\n case IC:\n out.add(new PatternItem(PatternItem.Type.BASE, 'P'));\n break;\n case IP:\n n = parser.nat();\n out.add(new PatternItem(PatternItem.Type.JUMP, n));\n break;\n case IF:\n parser.next(); // Consume one more character for no good reason\n c = parser.consts();\n out.add(new PatternItem(PatternItem.Type.SEARCH, c));\n break;\n case IIP:\n level += 1;\n out.add(new PatternItem(PatternItem.Type.OPEN));\n break;\n case IIF:\n case IIC:\n if (level == 0) {\n done = true;\n } else {\n level -= 1;\n out.add(new PatternItem(PatternItem.Type.CLOSE));\n }\n break;\n case III:\n rna.concat(dna.substring(0, 7));\n dna.trunc(7);\n break;\n default:\n finish();\n }\n }\n\n return out;\n }", "public IPlay getTape(boolean flag) {\n if (flag) {\n class Record implements IPlay { // область видимости scope {flag = true}\n @Override\n public void play() {\n System.out.println(\"Record.play\");\n }\n } // eof class\n return new Record();\n\n }else{\n class MidiBoard implements IPlay { // область видимости scope {flag = false}\n @Override\n public void play() {\n System.out.println(\"MidiBoard.play\");\n }\n } // eof class\n return new MidiBoard();\n }\n }", "private Rotor readRotor() {\n try {\n String currCycle = _config.next();\n String permutation = \"\";\n while (currCycle.contains(\"(\")) {\n if (!currCycle.contains(\")\") || currCycle.contains(\"*\")) {\n throw error(\"Wrong cycle format\");\n }\n if (_config.hasNext()) {\n permutation = permutation + currCycle;\n currCycle = _config.next();\n } else if (!_config.hasNext()) {\n permutation = permutation + currCycle;\n break;\n }\n }\n String tempname = _name.toUpperCase();\n if (_config.hasNext()) {\n _name = currCycle;\n }\n if (notches.charAt(0) == 'M') {\n return new MovingRotor(tempname,\n new Permutation(permutation, _alphabet),\n notches.substring(1));\n } else if (notches.charAt(0) == 'N') {\n return new FixedRotor(tempname,\n new Permutation(permutation, _alphabet));\n } else {\n return new Reflector(tempname,\n new Permutation(permutation, _alphabet));\n }\n } catch (NoSuchElementException excp) {\n throw error(\"bad rotor description\");\n }\n }", "public static PatternInterface graceNote(Note graceNote, Note baseNote){\r\n \treturn graceNote(graceNote, baseNote, THIRTY_SECOND);\r\n }", "abstract public TurtleModel getTurtle();", "public Pattern getHorizPattern() {\n\t\treturn horizPattern;\n\t}", "public void createTurtle (TurtleView tView) {\n myController.createTurtle(tView);\n }", "void crear(Tonelaje tonelaje);", "void rotateTurtle(int turtleIndex, double degrees);", "public RolandMT32RhythmSetupTempDriver() {\n super(\"Rhythm Setup Temp\", \"Fred Jan Kraan\");\n sysexID = \"F041**16\";\n patchSize = HSIZE + SSIZE + 1;\n patchNameStart = 0;\n patchNameSize = 0;\n deviceIDoffset = 0;\n checksumStart = 5;\n checksumEnd = 10;\n checksumOffset = 0;\n bankNumbers = new String[] {\n \"\" };\n patchNumbers = new String[] {\n \"\" };\n }", "QuoteNote createQuoteNote();", "public static Truck nextTruck(){\n Truck truck = null;\n Random r = new Random();\n switch (r.nextInt(2)){\n case 0: {\n truck = new Pickup(4000 + r.nextInt(2000), 10 + r.nextInt(10),\n 150 + r.nextInt(50), 4 + r.nextInt(4));\n break;\n }\n case 1: {\n truck = new Van(5000 + r.nextInt(2000), 12 + r.nextInt(10),\n 180 + r.nextInt(50), 3 + r.nextInt(2));\n break;\n }\n }\n return truck;\n }", "public TFRule createTFRuleFromLine(String line) {\n\n line = removeTailComment(line);\n\n //skip blank lines or comments\n line = line.trim();\n\n try (Scanner rowScanner = new Scanner(line)) {\n rowScanner.useDelimiter(\",\");\n\n SensorData lhsExt = null;\n SensorData rhsExt = null;\n\n int[] lhsInt = null;\n String action = \"\\0\";\n\n double conf = -1.0;\n\n String lhsIntData = rowScanner.next().trim();\n\n try {\n lhsInt = getLHSIntFromString(lhsIntData);\n lhsExt = getSDFromString(rowScanner.next().trim());\n action = rowScanner.next().trim();\n rhsExt = getSDFromString(rowScanner.next().trim());\n String dblStr = rowScanner.next().trim();\n conf = Double.parseDouble(dblStr);\n } catch(InputMismatchException ime) {\n System.err.println(\"oh no!\");\n }\n\n return new TFRule(this.agent, action.charAt(0), lhsInt, lhsExt, rhsExt, conf);\n }\n }", "public ArrowHead(Point2D tip, Point2D origin, double length, double flair) {\n\n _pts = new Point2D[4];\n\n // Calculate horizontal and vertical components of slope\n double edx = tip.getX() - origin.getX();\n double edy = tip.getY() - origin.getY();\n\n double len = Math.sqrt(edx * edx + edy * edy);\n\n edx /= len;\n edy /= len;\n\n Point2D arrowHeadLeftBasePt =\n new Point2D.Double(tip.getX() - (length * edx),\n tip.getY() - (length * edy));\n Point2D a1pt4 =\n new Point2D.Double(tip.getX() - ((length - 3) * edx),\n tip.getY() - ((length - 3) * edy));\n\n\n // Calculate the points of arrowhead 1\n Point2D a1pt1 =\n new Point2D.Double((arrowHeadLeftBasePt.getX() + (2 * edy * flair)),\n (arrowHeadLeftBasePt.getY() - (2 * edx * flair)));\n\n Point2D a1pt3 =\n new Point2D.Double((arrowHeadLeftBasePt.getX() - (2 * edy * flair)),\n (arrowHeadLeftBasePt.getY() + (2 * edx * flair)));\n\n _pts[0] = a1pt1;\n _pts[1] = new Point2D.Double(tip.getX(), tip.getY());\n _pts[2] = a1pt3;\n _pts[3] = a1pt4;\n }", "private Line getTrajectory() {\n Point target = this.topLeft.add(this.velocity).asPoint();\n return new Line(this.topLeft.asPoint(), target);\n }", "private Pitch(String note)\n {\n this.note = note;\n }", "public List<Triple> nextTriples(TriplePattern[] patterns) throws TrippiException {\n Map<String, Node> map = next();\n if ( map == null ) return null;\n List<Triple> triples = new ArrayList<Triple>();\n for (int i = 0; i < patterns.length; i++) {\n Triple triple = patterns[i].match(map);\n if (triple != null) {\n triples.add(triple);\n }\n }\n return triples;\n }", "public final StepPattern getStepPattern() {\n/* 176 */ return this.m_stepPattern;\n/* */ }", "public static float[] trilaterate(float[] p1, float r1, float[] p2, float r2, float[] p3, float r3) {\r\n float[] pos = new float[2];\r\n pos[0] = calcX(r1, r2, p2[0]);\r\n pos[1] = calcY(r1, r3, p3[0], p3[1], pos[0]);\r\n return pos;\r\n }", "@Override\n public JSLFrame editPatch(Patch p) {\n return new RolandMT32RhythmSetupTempEditor(p);\n }", "public Piano(int numNotes){\n pStrings = new InstString[numNotes][3];\n for(int a = 0; a < numNotes; a++){\n double freq = 440 * Math.pow(2, (double)(a-24)/(double)12);\n pStrings[a][0] = new GuitarString(freq);\n pStrings[a][1] = new GuitarString(freq + .45);\n pStrings[a][2] = new GuitarString(freq - .45);\n }\n }", "@Test\n\t\tpublic void testTrilateration() {\n\t\t\t// Initialize 3 points\n\t\t\tPoint2D p1 = new Point2D.Double(1,1);\n\t\t\tPoint2D p2 = new Point2D.Double(6,3);\n\t\t\tPoint2D p3 = new Point2D.Double(0,9);\n\t\t\t\n\t\t\t// Initialize 3 radius. r1 associated with p1 and so on.\n\t\t\tdouble r1 = 7.2111;\n\t\t\tdouble r2 = 4.1231;\n\t\t\tdouble r3 = 5.3852;\n\t\t\t\n\t\t\t// Initialized the Triangulate object and load points and radii\n\t\t\tTriangulate test = new Triangulate();\n\t\t\ttest.setPoints(p1, p2, p3);\n\t\t\ttest.setRadius(r1, r2, r3);\n\t\t\t\n\t\t\t// Set the given and actual location with the error we have\n\t\t\tPoint2D loc = test.trilaterate();\n\t\t\tPoint2D actual = new Point2D.Double(5, 7);\n\t\t\tdouble err = 1e-4; \n\t\t\t\n\t\t\t// Test x and y coordinates within a certain error\n\t\t\tassertEquals(actual.getX(), loc.getX(), err);\n\t\t\tassertEquals(actual.getY(), loc.getY(), err);\n\n\t\t}", "public Turtle(String name) {\n this.name = name;\n }", "public Trip() {}", "TR createTR();", "public static Note createNote(int octave, Pitch pitch, int startBeat, int endBeat) {\n return new NoteImpl(octave, pitch, startBeat, endBeat);\n }", "@Override\n public double getMaterialTraversedInRL(Hep3Vector dir) {\n double cth = Math.abs(VecOp.dot(dir, _w));\n double t = _materials.getThicknessInRL();\n return t / cth;\n }", "public Trips() {\n this(\"trips\", null);\n }", "List<TransmissionNote> getTransmissionNotes(Long transmissionId);", "Trip(String filePath, Double wheelDiameter) {\n this.filePath_ = filePath;\n this.wheelDiameter_ = wheelDiameter;\n }", "public ParticleMesh getMissileTrail() {\r\n for (int x = 0, tSize = missileTrails.size(); x < tSize; x++) {\r\n ParticleMesh e = missileTrails.get(x);\r\n if (!e.isActive()) {\r\n e.getParticleController().setRepeatType(Controller.RT_WRAP);\r\n e.forceRespawn();\r\n return e;\r\n }\r\n }\r\n return createMissileTrail();\r\n }", "public TriplePattern getPredicateBasedTriplePattern( String pred ) ;", "TT createTT();", "private void playNotes()\n\t{\n\t\t//Update tracks when we can shift chords.\n\t\tChord curChord = ClearComposer.cc.getChord();\n\t\tif (index % ClearComposer.cc.getChordInterval() == 0 && (prevChord == null || prevChord != curChord))\n\t\t{\n\t\t\tprevChord = curChord;\n\t\t\ttracks.forEach(GraphicTrack::updateChord);\n\t\t\tClearComposer.cc.updateChordOutlines();\n\t\t}\n\n\t\tfor (GraphicTrack track : tracks)\n\t\t{\n\t\t\tint temp = track.playNote(index);\n\t\t\tif (temp != -1)\n\t\t\t\tMusicPlayer.playNote(temp);\n\t\t}\n\n\t\tindex++;\n\t\twhile (index >= ClearComposer.cc.getNumNotes())\n\t\t\tindex -= ClearComposer.cc.getNumNotes();\n\t}", "public static String generaTemp(){\n return \"t$\"+temp++;\n }", "public static String generaTemp(){\n return \"t$\"+temp++;\n }", "public static String generaTemp(){\n return \"t$\"+temp++;\n }", "public static String generaTemp(){\n return \"t$\"+temp++;\n }", "public static Track generateTrack() {\n List<Position> positions = new ArrayList<>();\n DirectionsRoute dr = DirectionsRoute.fromJson(getJsonFromAssets(GlobalContext.getContext(),\"testDirections.json\"));\n positions.add(new Position(48.408880, 9.997507,1587652587));\n positions.add(new Position(48.408980, 9.997807,1587652597));\n Track track = new Track(\"nullacht15\", new Rating(), \"Heimweg\", \"Das ist meine super tolle Strecke\", 1585773516, 25,\n dr, new ArrayList<>(), positions.get(0),positions.get(1),true);\n return track;\n }", "@Override\n\tprotected Trunk makeNew(final TwilioTrunkingClient client, final Map<String, Object> params) {\n\t\treturn new Trunk(client, params);\n\t}", "public Trap(FloorTile where, StairTile trap, CharacterModifier effect) {\n super(where, FLOOR, effect);\n this.trapDoor = trap; // todo: stairtile ensure same room? ensure from of stair?\n if (trap != null) {\n trap.trap = this;\n if (trap.stair != null && trap.stair.toTile != null) trap.stair.toTile.trap = this; // todo have a function for that\n }\n }", "@Override\r\n\t\t\t\t\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\t\t\t\t\tNoteInJson[] pattern=gpt.getPattern();\r\n\t\t\t\t\t\t\t\t\t\tif(change_tempo){\r\n\t\t\t\t\t\t\t\t\t\t\tPatternMaker.changeSpeed(pattern, ratio);\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\tgotoPractice(pattern);\r\n\t\t\t\t\t\t\t\t\t}", "public static int getNormalizedPitch(Note note) {\n try {\n String pitch = note.getPitch().toString();\n String octave = new Integer(note.getOctave()).toString();\n\n String target = null;\n\n if (note.getPitch().equals(Pitch.R)) {\n target = \"REST\";\n } else {\n if(note.getAlteration().equals(Alteration.N))\n target = pitch.concat(octave);\n else if(note.getAlteration().equals(Alteration.F))\n target = pitch.concat(\"F\").concat(octave);\n else\n target = pitch.concat(\"S\").concat(octave);\n }\n\n \n\n Class cClass = ConverterUtil.class;\n Field field = cClass.getField(target);\n Integer value = (Integer) field.get(null);\n\n return value.intValue()%12;\n } catch (Exception e) {\n e.printStackTrace();\n }\n return 0;\n }", "public static PatternInterface addOrnament(Pattern ornament, Note baseNote){\r\n \treturn addOrnament(ornament, baseNote, THIRTY_SECOND);\r\n }", "String notes();", "public int durationToTime(NoteDuration dur)\n\t{\n\t\tint eighth = quarternote / 2;\n\t\tint sixteenth = eighth / 2;\n\n\t\tswitch (dur)\n\t\t{\n\t\t\tcase Whole:\n\t\t\t\treturn quarternote * 4;\n\t\t\tcase DottedHalf:\n\t\t\t\treturn quarternote * 3;\n\t\t\tcase Half:\n\t\t\t\treturn quarternote * 2;\n\t\t\tcase DottedQuarter:\n\t\t\t\treturn 3 * eighth;\n\t\t\tcase Quarter:\n\t\t\t\treturn quarternote;\n\t\t\tcase DottedEighth:\n\t\t\t\treturn 3 * sixteenth;\n\t\t\tcase Eighth:\n\t\t\t\treturn eighth;\n\t\t\tcase Triplet:\n\t\t\t\treturn quarternote / 3;\n\t\t\tcase Sixteenth:\n\t\t\t\treturn sixteenth;\n\t\t\tcase ThirtySecond:\n\t\t\t\treturn sixteenth / 2;\n\t\t\tcase HundredTwentyEight:\n\t\t\t\treturn quarternote / 32;\n\t\t\tdefault:\n\t\t\t\treturn 0;\n\t\t}//end switch\n\t}", "public String playGuitar(){\n\t\t String notes = \"[A(0.25), G(2), E(0.5), C(1), C(2), D(0.25), E(2), C(2), B(0.25), C(4), C(1), G(0.25),A(1), C(2), D(1),C(4)]\";\n\t\treturn notes;\n\t}", "public abstract Tone getTone();", "public static Note createNote(int octave, Pitch pitch, int startBeat, int endBeat, int\n instrument, int volume) {\n return new NoteImpl(octave, pitch, startBeat, endBeat, instrument, volume);\n }", "public static String[][] createPattern()\n {\n //the game is more like a table of 6 columns and 6 rows\n\t\n\t//we're going to have to make a 2D array of 7 rows \n\n String[][] f = new String[7][15];\n\n //Time to loop over each row from up to down\n\n for (int i = 0; i < f.length; i++)\n { \n for (int j = 0; j < f[i].length; j++)\n {\n if (j % 2 == 0) f[i][j] =\"|\";\n\n else f[i][j] = \" \";\n \n if (i==6) f[i][j]= \"-\";\n } \n }\n return f;\n }", "@Override\n public Pattern createPattern(Image image, String repeat) {\n return new Pattern(image, repeat);\n }", "public static LineQueue<Passenger> makeCommuter() {\r\n\t\tLineQueue<Passenger> commuters = new LineQueue<Passenger>();\r\n\t\tdouble t = 0;\r\n\t\tdouble a;\r\n\t\twhile (t < 3600) {\r\n\t\t\ta = genExp(90);\r\n\t\t\tif (a < 1) {\r\n\t\t\t\ta = 1;\r\n\t\t\t}\r\n\t\t\tt += a;\r\n\t\t\tif (t < 3600) {\r\n\t\t\t\tnumberCommutersMade++;\r\n\t\t\t\tPassenger passenger = new Passenger(false, false, t);\r\n\t\t\t\tcommuters.enqueue(passenger);\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn commuters;\r\n\t}", "public TranscribedNote()\r\n {\r\n\r\n }", "CompositionBuilder<T> addNote(int start, int end, int instrument, int pitch, int volume);", "public String tri4(int h){\n\t\tString S = \"\";\n\t\tint H = h;\n\t\tint HH = H;\n\t\tint Counter = 0;\n\t\tint UsingCounter = Counter;\n\n\t\twhile (H > 0){\n\t\t\tHH = H;\n\t\t\twhile (UsingCounter > 0){\n\t\t\t\tS = S + \" \";\n\t\t\t\tUsingCounter = UsingCounter - 1;}\n\t\t\twhile (HH > 0) {\n\t\t\t\tS = S + \"*\";\n\t\t\t\tHH = HH - 1;}\n\t\t\tCounter = Counter + 1;\n\t\t\tUsingCounter = Counter;\n\t\t\tS = S + \"\\n\";\n\t\t\tH = H - 1;}\n\n\t\treturn S; }", "public Strand getReverseStrand() throws BaseException\n {\n Type newType;\n \n //TODO: determine the value of newType\n // If the current type is RNA, keep the new type as RNA\n // If the current type is 3', change it to 5'\n // If the current type if 5', change it to 3'\n //Remove the following line -- it is for default compilation\n newType = Type.RNA;\n \n Base[] rev;\n //TODO: create a new array of Bases that is the reverse of the current\n // sequence. Store the result in rev.\n //Remove the following line -- it is for default compilation\n rev = new Base[]{};\n \n return new Strand(newType, rev);\n }", "public List<TemplItem> template() {\n List<TemplItem> items = new ArrayList<>();\n int l;\n int n;\n\n boolean done = false;\n while (!done) {\n DNAToken token = parser.step();\n\n switch (token) {\n case CONT:\n break;\n case C:\n items.add(new TemplItem(TemplItem.Type.BASE, 'I'));\n break;\n case F:\n items.add(new TemplItem(TemplItem.Type.BASE, 'C'));\n break;\n case P:\n items.add(new TemplItem(TemplItem.Type.BASE, 'F'));\n break;\n case IC:\n items.add(new TemplItem(TemplItem.Type.BASE, 'P'));\n break;\n case IP:\n case IF:\n l = parser.nat();\n n = parser.nat();\n items.add(new TemplItem(TemplItem.Type.PROT, n, l));\n break;\n case IIP:\n n = parser.nat();\n items.add(new TemplItem(TemplItem.Type.LEN, n));\n break;\n case IIF:\n case IIC:\n done = true;\n break;\n case III:\n rna.concat(dna.substring(0, 7));\n dna.trunc(7);\n break;\n case DONE:\n done = true;\n break;\n default:\n finish();\n }\n }\n\n return items;\n }", "private ParticleMesh createMissileTrail() {\r\n ParticleMesh pMesh = ParticleFactory.buildParticles(\"tail\", 200,\r\n ParticleType.Quad);\r\n pMesh.setEmissionDirection(new Vector3f(1, 1, 1));\r\n pMesh.setInitialVelocity(0);\r\n pMesh.setStartSize(1f);\r\n pMesh.setEndSize(3.45f);\r\n pMesh.setMinimumLifeTime(500);\r\n pMesh.setMaximumLifeTime(500);\r\n pMesh.setStartColor(ColorRGBA.lightGray.clone());\r\n pMesh.setEndColor(ColorRGBA.black.clone());\r\n pMesh.setParticleSpinSpeed(180 * FastMath.DEG_TO_RAD);\r\n pMesh.getParticleController().setControlFlow(true);\r\n// pMesh.setReleaseRate(500);\r\n pMesh.forceRespawn();\r\n \r\n pMesh.setModelBound(new BoundingBox());\r\n pMesh.updateModelBound();\r\n pMesh.setCullHint(Spatial.CullHint.Never);\r\n\r\n // removes the missile from the scene after the particle trail has died\r\n pMesh.getParticleController().addListener(new OnDeadListener());\r\n pMesh.setRenderState(ts);\r\n pMesh.setRenderState(bs);\r\n pMesh.setRenderState(zs);\r\n \r\n missileTrails.add(pMesh);\r\n \r\n return pMesh;\r\n }", "public List<Chord> getFollowingTiedChords ()\r\n {\r\n List<Chord> tied = new ArrayList<>();\r\n\r\n for (TreeNode node : children) {\r\n Note note = (Note) node;\r\n\r\n for (Slur slur : note.getSlurs()) {\r\n if (slur.isTie()\r\n && (slur.getLeftNote() == note)\r\n && (slur.getRightNote() != null)) {\r\n tied.add(slur.getRightNote().getChord());\r\n }\r\n }\r\n }\r\n\r\n Collections.sort(tied, Chord.byAbscissa);\r\n return tied;\r\n }", "static int[] createRhythmLevelMessage(int part, byte level){\r\n\t\tif(part < 0) part = 0;\r\n\t\tif(part > 15) part = 15;\r\n\t\t\r\n\t\tint[] data = new int[5];\r\n\t\tdata[0] = 0x11 + part / 4;\r\n\t\tdata[1] = 0x10 + (part % 4) * 0x20;\r\n\t\tdata[2] = 0x00;\r\n\t\tdata[3] = 0x0C;\r\n\t\tdata[4] = level;\r\n\t\treturn createMessage(data);\r\n\t}", "public static PatternInterface addOrnament(Pattern ornament, Note baseNote, double longestOrnamentDuration){\r\n \tPatternInvestigator investigator = new PatternInvestigator();\r\n \tMusicStringParser stringParser = new MusicStringParser();\r\n \t\r\n \tstringParser.addParserListener(investigator);\r\n \tstringParser.parse(ornament);\r\n \t\r\n \tdouble longestDuration = investigator.getLongestDecimalDuration();\r\n \tdouble durationChange = longestOrnamentDuration / longestDuration;\r\n \t\r\n \tDurationPatternTransformer transformer = new DurationPatternTransformer(durationChange);\r\n \t\r\n \tPatternInterface result = transformer.transform(ornament);\r\n \t\r\n \tstringParser.removeParserListener(investigator);\r\n \tinvestigator = new PatternInvestigator();\r\n \tstringParser.addParserListener(investigator);\r\n \tstringParser.parse(result);\r\n \t\r\n \tif(investigator.getTotalDecimalDuration() < baseNote.getDecimalDuration()){\r\n \t\tdouble remainingDuration = baseNote.getDecimalDuration() - investigator.getTotalDecimalDuration();\r\n \t\tbaseNote.setDecimalDuration(remainingDuration);\r\n \t\tresult.add(baseNote.getMusicString());\r\n \t\treturn result;\r\n \t} else {\r\n \t\treturn new Pattern(baseNote.getMusicString());\r\n \t}\r\n }", "private StringBuilder listAllPitches(int length) {\n StringBuilder builder = new StringBuilder();\n\n int padding = Integer.toString(length).length();\n String spaces = \"\";\n spaces = String.format(\"%\" + (padding) + \"s\", spaces);\n builder.append(spaces);\n\n Note highest = this.getHighestNote();\n Note lowest = this.getLowestNote();\n int ordinalHighestOctave = highest.getOctave().ordinal();\n int ordinalHighestPitch = highest.getPitch().ordinal();\n int ordinalLowOctave = lowest.getOctave().ordinal();\n int ordinalLowPitch = lowest.getPitch().ordinal();\n int from = ordinalLowOctave * 12 + ordinalLowPitch;\n int to = ordinalHighestOctave * 12 + ordinalHighestPitch;\n List<String> allNotes = this.allnotes.subList(from, to + 1);\n\n for (int i = 0; i < allNotes.size(); i++) {\n String current = allNotes.get(i);\n\n if (current.length() == 2) {\n builder.append(\" \" + current + \" \");\n } else if (current.length() == 3) {\n builder.append(\" \" + current + \" \");\n } else if (current.length() == 4) {\n builder.append(\" \" + current);\n } else {\n builder.append(current);\n }\n }\n return builder;\n }", "public static Note createNote(int value, int startBeat, int endBeat) {\n return createNote((value / 12) - 1, Pitch.getPitch(value % 12), startBeat, endBeat);\n }", "public Trip create(final Manager manager) {\n\t\tthis.managerService.checkPrincipal();\n\n\t\tCollection<ApplicationFor> applicationsFor;\n\t\tCollection<AuditRecord> auditRecords;\n\t\tCollection<Note> notes;\n\t\tCollection<Stage> stages;\n\t\tCollection<Tag> tags;\n\t\tTrip trip;\n\n\t\ttrip = new Trip();\n\t\tapplicationsFor = new ArrayList<ApplicationFor>();\n\t\tauditRecords = new ArrayList<AuditRecord>();\n\t\tnotes = new ArrayList<Note>();\n\t\tstages = new ArrayList<Stage>();\n\t\ttags = new ArrayList<Tag>();\n\n\t\ttrip.setManager(manager);\n\t\ttrip.setApplicationsFor(applicationsFor);\n\t\ttrip.setAuditRecords(auditRecords);\n\t\ttrip.setNotes(notes);\n\t\ttrip.setStages(stages);\n\t\ttrip.setTags(tags);\n\t\ttrip.setTicker(this.generatedTicker());\n\n\t\treturn trip;\n\t}", "static public Tour makeTour() {\r\n Tour t = new Tour();\r\n t.index = null;\r\n return t;\r\n }", "public Pattern(Delta... pattern)\n {\n assert(pattern.length > 0);\n\n _pattern = pattern;\n _index = 0;\n }", "private static TriNode buildTri(String[] str) {\r\n TriNode n = new TriNode();\r\n for (String s : str) {\r\n n.append(s);\r\n }\r\n return n;\r\n }", "private boolean[][] rotatePattern(int steps, boolean[][] pattern) {\n if (steps < 1)\n return pattern;\n boolean[][] rotated = new boolean[4][4];\n if (steps == 1) {\n for (int i = 0; i < pattern.length; i++)\n for (int j = 0; j < pattern[i].length; j++)\n rotated[i][j] = pattern[j][pattern.length - 1 - i];\n } else if (steps == 2) {\n for (int i = 0; i < pattern.length; i++)\n for (int j = 0; j < pattern[i].length; j++)\n rotated[i][j] = pattern[pattern.length - 1 - i][pattern\n .length - 1 - j];\n } else {\n for (int i = 0; i < pattern.length; i++)\n for (int j = 0; j < pattern[i].length; j++)\n rotated[i][j] = pattern[pattern.length - 1 - j][i];\n }\n return rotated;\n }", "public static Note makeNote(int pitch, int octave) {\n if (octave < 0) {\n throw new IllegalArgumentException(\"Invalid octave parameter!\");\n }\n return new Note(Pitch.makePitch(pitch),octave,0);\n }", "@Override\n\tpublic String toString() {\n\t\treturn \"Triangulo [b_=\" + b_ + \", h_=\" + h_ + \", Area=\" + Area() +\n\t\t\", Diameter=\" + super.Perimeter() + \", Diagonals=\" + super.Diagonals() +\"]\";\n\t}", "public Note(int note, char accidental, Pane notePane) {\n _note = note;\n _accidental = accidental;\n _accidentalImage = new ImageView();\n this.setUpLedger();\n this.setUpNote();\n }", "static Trimmer makeTrimmer(FixedWidthSchemaCell schemaCell) {\n final Trimmer trimmer = schemaCell.isTrimPadCharacter() ? makeTrimmerByAlignment(schemaCell) : new NothingTrimmer();\n if (schemaCell.isTrimLeadingSpaces() && schemaCell.getPadCharacter()!=' ')\n return new LeadingSpacesTrimmer(trimmer);\n return trimmer;\n }", "String note();", "int getTonicNote(){\n String lastnote=\"\";\n int result;\n lastnote += Strinput.toCharArray()[Strinput.length()-4];\n lastnote += Strinput.toCharArray()[Strinput.length()-3];\n result = Integer.parseInt(lastnote);\n if(result<72){\n return result-60;\n }else{\n return result-12-60;\n }\n }", "public Note(int duration, int offset, int pitch, int channel, int velocity) {\n this.duration = duration;\n this.offset = offset;\n this.pitch = pitch;\n this.channel = channel;\n this.velocity = velocity;\n }", "public static String getTrail() {\n\t\treturn trail.toString();\n\t}", "public static Note getNoteFromID(int id, Shift prefShift) {\n\t\tint shiftNum = prefShift.getShiftID();\n\n\t\tint octave = (id / 12) - 1;\n\t\tint toneMod = (id - shiftNum + 12) % 12;\n\n\t\tTone tone = Tone.notes.get(toneMod);\n\t\tint shiftID = shiftNum + 2;\n\n\t\tif (tone == null) {\n\t\t\tif (shiftNum <= 0) {\n\t\t\t\ttone = Tone.notes.get((toneMod + 11) % 12);\n\t\t\t\tshiftID++;\n\t\t\t} else {\n\t\t\t\ttone = Tone.notes.get((toneMod + 1) % 12);\n\t\t\t\tshiftID--;\n\t\t\t}\n\t\t}\n\n\t\tNote note = new Note(tone, Shift.shifts.get(shiftID), octave);\n\t\treturn note;\n\t}", "public Tulip(){\n super(CropName.TULIP, CropType.FLOWER, CropStatus.WAITING, 90, 2, 2, 3, 0, 1, 1, 1, 7);\n }", "public String getTribe() {\n\t\treturn tribeField.getText();\n\t}", "private Point getHeadLocation (Note note)\r\n {\r\n return new Point(tailLocation.x, note.getReferencePoint().y);\r\n }", "public static Note createNote(int value, int startBeat, int endBeat, int instrument, int\n volume) {\n return createNote((value / 12) - 1, Pitch.getPitch(value % 12), startBeat, endBeat, instrument,\n volume);\n }", "public void testfindNote() {\n System.out.println(\"findNote\");\n net.sharedmemory.tuner.Note instance = new net.sharedmemory.tuner.Note();\n\n double frequency = 441.123;\n java.lang.String expectedResult = \"A4\";\n java.lang.String result = instance.findNote(frequency);\n assertEquals(expectedResult, result);\n \n frequency = 523.25;\n expectedResult = \"C5\";\n result = instance.findNote(frequency);\n assertEquals(expectedResult, result);\n \n frequency = 417.96875;\n expectedResult = \"G#4\";\n result = instance.findNote(frequency);\n assertEquals(expectedResult, result);\n \n frequency = 1316.40625;\n expectedResult = \"B5\";\n result = instance.findNote(frequency);\n assertEquals(expectedResult, result);\n }", "@Override\n public CreateLogPatternResult createLogPattern(CreateLogPatternRequest request) {\n request = beforeClientExecution(request);\n return executeCreateLogPattern(request);\n }" ]
[ "0.7603041", "0.6841103", "0.5738038", "0.5192083", "0.5066672", "0.49899256", "0.46398", "0.45936114", "0.4525691", "0.44964638", "0.44931903", "0.44492027", "0.44133314", "0.44090754", "0.4389376", "0.43853018", "0.4372547", "0.43618917", "0.43449152", "0.4344207", "0.43318865", "0.4303641", "0.429753", "0.4274437", "0.42374143", "0.42278814", "0.42249385", "0.4219837", "0.41949067", "0.41899163", "0.41809735", "0.41807526", "0.41794917", "0.41540748", "0.41434577", "0.4139739", "0.4116342", "0.4116086", "0.41143078", "0.4113495", "0.41115326", "0.41086093", "0.40998143", "0.40962267", "0.40777314", "0.40753004", "0.4073407", "0.40647078", "0.40557316", "0.40543368", "0.4053801", "0.40536305", "0.40536305", "0.40536305", "0.40536305", "0.40495807", "0.4043098", "0.40418044", "0.40413257", "0.40394777", "0.40394443", "0.40366626", "0.40276313", "0.40220279", "0.40162104", "0.4012688", "0.4007576", "0.39979714", "0.39893788", "0.39825785", "0.3979881", "0.39766508", "0.39687064", "0.39561084", "0.39509076", "0.39457917", "0.39300597", "0.3929665", "0.39274704", "0.3927445", "0.39267358", "0.39229906", "0.3917615", "0.39137504", "0.39098945", "0.390662", "0.3899238", "0.3893233", "0.38889903", "0.3884403", "0.38817266", "0.3875512", "0.38725603", "0.38691172", "0.38683096", "0.38633096", "0.38599363", "0.3852248", "0.38485628", "0.38413465" ]
0.65936255
2
Takes care of redundant music string building for adding notes/durations.
private static StringBuilder appendNoteValueAndDuration(StringBuilder inputBuilder, byte noteValue, double noteDuration){ inputBuilder.append("["); inputBuilder.append(noteValue); inputBuilder.append("]/"); inputBuilder.append(noteDuration); inputBuilder.append(" "); return inputBuilder; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private String addMusic() {\n\t\t// One Parameter: MusicName\n\t\tStringBuilder tag = new StringBuilder();\n\t\ttag.append(\"|music:\" + parameters[0]);\n\t\treturn tag.toString();\n\n\t}", "@Override\n\tpublic String toString() {\n\t\treturn note + \" \" + duration + (duration == 1 ? \" Quaver\" : \" Crotchet\");\n\t}", "public String toString() { \r\n\t return \"{Song = Title: \" + title + \", Artist: \" + artist + \", Song length: \" + minutes + \":\" + seconds + \"}\";\r\n\t}", "public String printSongInOneLine(){\n\t\tString str = aTitle +\n\t\t\t\t\" - \" +\n\t\t\t\taArtist +\n\t\t\t\t\" - \" +\n\t\t\t\taTime;\n\t\tSet<String> customTagKeys = aCustomTags.keySet();\n\t\tif(customTagKeys.size()!=0){\n\t\t\tfor(String key:customTagKeys){\n\t\t\t\tstr += \" - \" + key + \":\"+ aCustomTags.get(key);\n\t\t\t}\n\t\t}\n\t\treturn str;\n\t}", "private void fillMusicList()\n\t{\n\t\tmusicList.add(\"violin\");\n\t\tmusicList.add(\"viola\");\n\t\tmusicList.add(\"cello\");\n\t\tmusicList.add(\"bass\");\n\t\tmusicList.add(\"guitar\");\n\t\tmusicList.add(\"drums\");\n\t\tmusicList.add(\"tuba\");\n\t\tmusicList.add(\"flute\");\n\t\tmusicList.add(\"harp\");\n\t}", "public void playSong() {\n\t\t// Initialize\n\t\tint num = 1;\n\n\t\t// Get the notes to be played from the entryBox\n\t\tString notesString = \"V0 \" + instrumentType + \" \" + entryBox.getText();\n\n\t\t// Create a new rhythm object\n\t\tRhythm rhythm = new Rhythm();\n\n\t\t// Get the rhythm strings from the rhythm entry boxes\n\t\tString rhythmLayer1 = \"V1 \" + rhythm1.getText();\n\t\tString rhythmLayer2 = \"V2 \" + rhythm2.getText();\n\n\t\t// Set the strings to layers\n\t\trhythm.setLayer(1, rhythmLayer1);\n\t\trhythm.setLayer(2, rhythmLayer2);\n\n\t\t// Add the appropriate substitutions\n\t\trhythm.addSubstitution('O', \"[BASS_DRUM]i\");\n\t\trhythm.addSubstitution('o', \"Rs [BASS_DRUM]s\");\n\t\trhythm.addSubstitution('*', \"[ACOUSTIC_SNARE]i\");\n\t\trhythm.addSubstitution('^', \"[PEDAL_HI_HAT]s Rs\");\n\t\trhythm.addSubstitution('!', \"[CRASH_CYMBAL_1]s Rs\");\n\t\trhythm.addSubstitution('.', \"Ri\");\n\n\t\t// Get the rhythm pattern\n\t\tPattern rhythmPattern = rhythm.getPattern();\n\n\t\t// Get how many times the song should repeat\n\t\tString repeatNum = repeatNumber.getText();\n\t\tnum = Integer.parseInt(repeatNum);\n\n\t\t// Get the playback tempo\n\t\tString playTempo = \"T[\" + tempo.getText() + \"] \";\n\n\t\t// Create the song\n\t\tPattern song = new Pattern();\n\t\tsong.add(rhythmPattern);\n\t\tsong.add(notesString);\n\t\tsong.repeat(num);\n\n\t\t// Play the song\n\t\tplayer.play(playTempo + song);\n\n\t}", "@Override\n public String toString() {\n return this.title + \": \" + this.duration;\n //next step 6 create an album class\n }", "public String playlistToString(){\n String out = \"\";\n out =\"********** Playlist **********\\n\"+\n \"** Title: \"+name+\"\\n\"+\n \"** Duration: \"+timeToFormat(updateDuration())+\"\\n\"+\n \"** Genre: \"+changeGendersOfPlaylist(playlistAllGenders())+\"\\n\";\n\n return out;\n }", "private String convertToDuration(Long songDuration){\n long seconds = songDuration/1000;\n long minutes = seconds / 60;\n seconds = seconds % 60;\n return minutes +\":\"+seconds;\n }", "@Override\n\tpublic String toString() {\n\t\tStringBuilder builder = new StringBuilder();\n\t\treturn builder.append(title)\n\t\t\t.append(\"(\")\n\t\t\t.append(year)\n\t\t\t.append(\", \")\n\t\t\t.append(duration)\n\t\t\t.append(\" mn)#\")\n\t\t\t.append(id)\n\t\t\t.toString(); // finalize String result\n\t}", "@Override\n public MusicOperation build() {\n MusicOperation m = new MusicModel(this.tempo);\n listNotes.forEach(n -> m.addNote(n));\n return m;\n }", "private String notesToString(List<Note> notesPlayingAtBeat, int beat) {\n if (notesPlayingAtBeat.size() == 0) {\n return \"\";\n }\n String padding = \" \";\n String onBeat = \" x \";\n String onDuration = \" | \";\n\n Note highest = this.getHighestNote();\n Note lowest = this.getLowestNote();\n int ordinalHighestOctave = highest.getOctave().ordinal();\n int ordinalHighestPitch = highest.getPitch().ordinal();\n int ordinalLowOctave = lowest.getOctave().ordinal();\n int ordinalLowPitch = lowest.getPitch().ordinal();\n int from = ordinalLowOctave * 12 + ordinalLowPitch;\n int to = ordinalHighestOctave * 12 + ordinalHighestPitch;\n\n List<String> listOfNotes = this.allnotes.subList(from, to + 1);\n int allNotesSize = listOfNotes.size();\n\n StringBuilder builder = new StringBuilder();\n List<String> newList = new ArrayList<>();\n\n for (int x = 0; x < allNotesSize; x++) {\n String currentNote = listOfNotes.get(x);\n\n for (int i = 0; i < notesPlayingAtBeat.size(); i++) {\n Note playingNote = notesPlayingAtBeat.get(i);\n String playingString =\n playingNote.getPitch().getValue() + playingNote.getOctave().getValue();\n\n if (playingString.equals(currentNote) && playingNote.getBeat() == beat) {\n newList.add(onBeat);\n break;\n } else if (playingString.equals(currentNote)) {\n newList.add(onDuration);\n break;\n } else if (i == notesPlayingAtBeat.size() - 1) {\n newList.add(padding);\n }\n }\n }\n\n for (int c = 0; c < newList.size(); c++) {\n builder.append(newList.get(c).toString());\n }\n\n return builder.toString();\n\n }", "public String sounds(){\n return (\"Moooooo :o\");\n }", "@Override\n\tpublic long addMusicRadioGarbage(String paramString1, String paramString2)\n\t{\n\t\treturn 0;\n\t}", "private void makeNewMusic() {\n File f = music.getFile();\n boolean playing = music.isPlaying();\n music.stop();\n music = new MP3(f);\n if (playing) {\n music.play(nextStartTime);\n }\n }", "@Override\n public void appendModels(MusicOperation model) {\n int length = this.getFinalBeat();\n\n List<Note> currentNotes = model.getNotes();\n\n for (int x = 0; x < currentNotes.size(); x++) {\n Note current = currentNotes.get(x);\n Note newNote = new SimpleNote(current.getPitch(), current.getOctave(),\n current.getBeat() + length, current.getDuration());\n this.addNote(newNote);\n }\n }", "public Music createMusic(String file);", "public String showSongName(){\n String nameSong = \"\";\n for (int i = 0; i<MAX_SONG; i++){\n if(poolSong[i] != null){\n nameSong += \"[\"+(i+1)+\"]\"+poolSong[i].getTittleSong()+\"\\n\";\n }\n }\n return nameSong;\n }", "@Override\n\tpublic String toString() {\n\t\treturn \"MusicalPiece [title=\" + title + \", composer=\" + composer\n\t\t\t\t+ \", meterNumerator=\" + meterNumerator + \", meterDenominator=\"\n\t\t\t\t+ meterDenominator + \", tempoSpeed=\" + tempoSpeed\n\t\t\t\t+ \", tempoNumerator=\" + tempoNumerator + \", tempoDenominator=\"\n\t\t\t\t+ tempoDenominator + \", phrases=\" + phrases + \"]\";\n\t}", "@Override\n public Song getSongRepresentation() {\n\n try {\n final Track track = en.uploadTrack(mp3File, true);\n\n // Wait for a predefined period of time in which the track is analyzed\n track.waitForAnalysis(30000);\n\n if (track.getStatus() == Track.AnalysisStatus.COMPLETE) {\n\n final double tempo = track.getTempo();\n final String title = Modulo7Utils.stringAssign(track.getTitle());\n final String artistName = Modulo7Utils.stringAssign(track.getArtistName());\n\n // Gets the time signature\n final int timeSignatureRatio = track.getTimeSignature();\n TimeSignature timeSignature = guessTimeSigntureRatio(timeSignatureRatio);\n\n // Getting the key signature information from the echo nest meta data analysis in integer format\n final int key = track.getKey();\n final int mode = track.getMode();\n\n try {\n keySignature = EchoNestKeySignatureEstimator.estimateKeySignature(key, mode);\n } catch (Modulo7BadKeyException e) {\n logger.error(e.getMessage());\n }\n\n // Gets the duration of the track\n final double duration = track.getDuration();\n\n TrackAnalysis analysis = track.getAnalysis();\n\n Voice voiceOfSong = new Voice();\n\n /**\n * There is no clear distinguishing way of acquiring timbral approximations\n * Hence the only possible approximation I can think of it call the a part of a\n * single voice\n */\n for (final Segment segment : analysis.getSegments()) {\n VoiceInstant songInstant = ChromaAnalysis.getLineInstantFromVector(segment.getPitches(), segment.getDuration());\n voiceOfSong.addVoiceInstant(songInstant);\n }\n if (keySignature == null) {\n return new Song(voiceOfSong, new SongMetadata(artistName, title, (int) tempo), MusicSources.MP3, duration);\n } else {\n if (timeSignature == null) {\n return new Song(voiceOfSong, new SongMetadata(keySignature, artistName, title, (int) tempo),\n MusicSources.MP3, duration);\n } else {\n return new Song(voiceOfSong, new SongMetadata(keySignature, timeSignature, artistName, title,\n (int) tempo), MusicSources.MP3, duration);\n }\n }\n\n } else {\n logger.error(\"Trouble analysing track \" + track.getStatus());\n return null;\n }\n } catch (IOException e) {\n logger.error(\"Trouble uploading file to track analyzer\" + e.getMessage());\n } catch (Modulo7InvalidVoiceInstantSizeException | EchoNestException | Modulo7BadIntervalException | Modulo7BadNoteException e) {\n logger.error(e.getMessage());\n }\n\n // Return null if no song is inferred\n return null;\n }", "public CD(String song1, String song2, String song3, String song4, String song5) {\n songs = new ArrayList<>();\n songs.add(song1);\n songs.add(song2);\n songs.add(song3);\n songs.add(song4);\n songs.add(song5);\n currentindex = songs.size();\n }", "public Piano(int numNotes){\n pStrings = new InstString[numNotes][3];\n for(int a = 0; a < numNotes; a++){\n double freq = 440 * Math.pow(2, (double)(a-24)/(double)12);\n pStrings[a][0] = new GuitarString(freq);\n pStrings[a][1] = new GuitarString(freq + .45);\n pStrings[a][2] = new GuitarString(freq - .45);\n }\n }", "void stringConstruction()\t{\n\n\t\tString symbol = \"#\";\n\t\t\n\t\tfor (int i = 1; i < q - 1; i++)\tsymbol = symbol + \"#\";\n\t\ts1 = symbol + s1 + symbol;\n\t\ts2 = symbol + s2 + symbol;\n\t\tlength1 += (q-1) * 2;\t\t\n\t\tlength2 += (q-1) * 2;\t\t\n\t}", "private String buildDuration(CalendarEntry entry)\r\n {\r\n StringBuffer duration = new StringBuffer();\r\n duration.append(\"P\");\r\n \r\n long timeDiff = entry.getEnd().getTime() - entry.getStart().getTime();\r\n \r\n int weeks = (int)Math.floor(timeDiff / DURATION_WEEK);\r\n if (weeks > 0)\r\n {\r\n duration.append(weeks);\r\n duration.append(\"W\");\r\n timeDiff -= weeks * DURATION_WEEK;\r\n }\r\n \r\n int days = (int)Math.floor(timeDiff / DURATION_DAY);\r\n if (days > 0)\r\n {\r\n duration.append(days);\r\n duration.append(\"D\");\r\n timeDiff -= days * DURATION_DAY;\r\n }\r\n \r\n duration.append(\"T\");\r\n \r\n int hours = (int)Math.floor(timeDiff / DURATION_HOUR);\r\n if (hours > 0)\r\n {\r\n duration.append(hours);\r\n duration.append(\"H\");\r\n timeDiff -= hours * DURATION_HOUR;\r\n }\r\n \r\n int minutes = (int)Math.floor(timeDiff / DURATION_MINUTE);\r\n if (minutes > 0)\r\n {\r\n duration.append(minutes);\r\n duration.append(\"M\");\r\n timeDiff -= minutes * DURATION_MINUTE;\r\n }\r\n \r\n int seconds = (int)Math.floor(timeDiff / DURATION_SECOND);\r\n if (seconds > 0)\r\n {\r\n duration.append(seconds);\r\n timeDiff -= minutes * DURATION_MINUTE;\r\n }\r\n \r\n return duration.toString();\r\n }", "Builder addAudio(String value);", "@Override\n public CompositionBuilder<MusicOperation> addNote(int start, int end, int instrument,\n int pitch, int volume) {\n this.listNotes.add(new SimpleNote(Pitch.values()[(pitch) % 12],\n Octave.values()[(pitch / 12) - 2 ], start, end - start, instrument, volume));\n return this;\n }", "public String playGuitar(){\n\t\t String notes = \"[A(0.25), G(2), E(0.5), C(1), C(2), D(0.25), E(2), C(2), B(0.25), C(4), C(1), G(0.25),A(1), C(2), D(1),C(4)]\";\n\t\treturn notes;\n\t}", "public String toString() {\n return songLine;\n }", "public Art() {\n this.artist = \"Michelangelo\";\n this.timePeriod = 1510;\n this.aesthetic = \"High Renaissance\";\n this.size = \"Enormous\";\n }", "public GuitarLite() {\n // double[] frequencies = new double[totalNotes];\n double A2 = 110.0;\n // frequencies[0] = A2;\n for (int i = 0; i < totalNotes; i++){\n double frequency = A2 * Math.pow(2, i/12.0);\n // frequencies[i] = frequency;\n strings[i] = new GuitarString(frequency);\n }\n }", "public String toShortString ()\r\n {\r\n StringBuilder sb = new StringBuilder();\r\n sb.append(\"[\");\r\n\r\n if (getVoice() != null) {\r\n sb.append(\"Voice#\").append(getVoice().getId());\r\n }\r\n\r\n sb.append(\" Chord#\").append(getId());\r\n\r\n sb.append(\" dur:\");\r\n\r\n if (isWholeDuration()) {\r\n sb.append(\"W\");\r\n } else {\r\n Rational chordDur = getDuration();\r\n\r\n if (chordDur != null) {\r\n sb.append(chordDur);\r\n } else {\r\n sb.append(\"none\");\r\n }\r\n }\r\n\r\n sb.append(\"]\");\r\n\r\n return sb.toString();\r\n }", "public ArrayList<ArrayList<String>> readthePathOfMusicFiles()\n {\n File file = new File(path);\n String[] names = file.list();// all directories inside dataset1 direcory\n ArrayList<ArrayList<String>> pathOfMusicFiles = new ArrayList<>();\n String artistName = \"\";\n String trackName = \"\";\n Mp3File song = null;\n for (int i = 0; i < names.length; i++) \n {\n File file1 = new File(path + '/' + names[i]);\n if (file1.isDirectory())\n {\n String[] fileNames = file1.list();\n for (String fileName : fileNames)// all files in directory\n {\n if (fileName.contains(\".mp3\") && !(fileName.charAt(0) == '.'))\n {\n try\n {\n song = new Mp3File(path + '/' + names[i] + '/' + fileName);\n }\n catch (UnsupportedTagException | InvalidDataException | IOException e)\n {\n e.printStackTrace();\n }\n if(song!=null && song.hasId3v1Tag())\n {\n ID3v1 id3v1Tag = song.getId3v1Tag();\n artistName = id3v1Tag.getArtist();\n trackName = id3v1Tag.getTitle();\n }\n if(song!=null && song.hasId3v2Tag())\n {\n ID3v2 id3v2tag = song.getId3v2Tag();\n artistName = id3v2tag.getArtist();\n trackName = id3v2tag.getTitle();\n }\n if(artistName != null && artistName.length() >= 1 && trackName != null && artistName.length() >= 1)\n {\n if(artistName.charAt(0) >= startChar && artistName.charAt(0) <= endChar)\n {\n ArrayList<String> songAttributes = new ArrayList<>();\n songAttributes.add(path + '/' + names[i] + '/' + fileName);\n songAttributes.add(artistName);\n songAttributes.add(trackName);\n pathOfMusicFiles.add(songAttributes);\n }\n }\n }\n }\n }\n }\n return pathOfMusicFiles;\n }", "public String build() {\n List<String> fishes = new ArrayList<String>();\n int fishTypeCount = random.nextInt(Chars.FISH_TYPES.size()) + 1;\n if (fishTypeCount == Chars.FISH_TYPES.size()) {\n fishes.addAll(Chars.FISH_TYPES);\n } else {\n while (fishes.size() < fishTypeCount) {\n String fishType = random.oneOf(Chars.FISH_TYPES);\n if (!fishes.contains(fishType)) {\n fishes.add(fishType);\n }\n }\n }\n\n // A rare swimmer should show up about once every 8 tweets.\n if (random.nextInt(8) == 5) {\n fishes.add(random.oneOf(Chars.RARE_SWIMMER_TYPES));\n }\n\n // There will be about 8 tweets a day. Something should be special about\n // many of them but not all of them. Only once a week should something\n // exceedingly rare show up. 8 tweets * 7 days = 56 tweets per week\n boolean exceedinglyRareBottomTime = (random.nextInt(56) == 37);\n\n // A rare bottom dweller should show up about once every 8 tweets.\n boolean rareBottomDwellerTime = (random.nextInt(8) == 2);\n\n int maxLineLength = 10;\n List<String> bottom = new ArrayList<String>();\n if (rareBottomDwellerTime) {\n bottom.add(random.oneOf(Chars.RARE_BOTTOM_DWELLERS));\n }\n if (exceedinglyRareBottomTime) {\n bottom.add(random.oneOf(Chars.EXCEEDINGLY_RARE_JUNK));\n }\n int plantCount = midFavoringRandom(maxLineLength - bottom.size() - 1);\n if (plantCount < 1) {\n plantCount = 1;\n }\n for (int i = 0; i < plantCount; i++) {\n bottom.add(random.oneOf(Chars.PLANT_TYPES));\n }\n while (bottom.size() < maxLineLength) {\n bottom.add(Chars.IDEOGRAPHIC_SPACE);\n }\n random.shuffle(bottom);\n String bottomLine = String.join(\"\", bottom);\n\n // For each swimmer line, choose a random number of fish, then random small whitespace\n // in front of some.\n int swimLineCount = 5;\n List<List<String>> swimLines = new ArrayList<List<String>>();\n int previousSwimmerCount = 0;\n for (int s = 0; s < swimLineCount; s++) {\n List<String> swimLine = new ArrayList<String>();\n\n // Lines should tend to have similar swimmer densities. How crowded in general is\n // this aquarium?\n int maxPerLine = random.nextInt((int) Math.round((maxLineLength * 0.6))) + 1;\n int swimmerCount = midFavoringRandom(maxPerLine);\n\n // At least one swimmer on first line so first lines aren't trimmed.\n if (previousSwimmerCount == 0 && swimmerCount == 0) {\n swimmerCount++;\n }\n\n for (int i = 0; i < swimmerCount; i++) {\n swimLine.add(getSmallPersonalSpace() + random.oneOf(fishes));\n }\n while (swimLine.size() < maxLineLength) {\n swimLine.add(Chars.IDEOGRAPHIC_SPACE);\n }\n random.shuffle(swimLine);\n swimLines.add(swimLine);\n previousSwimmerCount = swimmerCount;\n }\n\n StringBuilder stringBuilder = new StringBuilder();\n for (int i = 0; i < swimLines.size(); i++) {\n List<String> swimLine = swimLines.get(i);\n stringBuilder.append(String.join(\"\", swimLine)).append(\"\\n\");\n }\n stringBuilder.append(bottomLine);\n\n return stringBuilder.toString();\n }", "public NoteDuration getNoteDuration(int duration)\n\t{\n\t\tint whole = quarternote * 4;\n\t\t//\t\t 1 = 32/32\n\t\t//\t\t 3/4 = 24/32\n\t\t//\t\t 1/2 = 16/32\n\t\t//\t\t 3/8 = 12/32\n\t\t//\t\t 1/4 = 8/32\n\t\t//\t\t 3/16 = 6/32\n\t\t//\t\t 1/8 = 4/32 = 8/64\n\t\t//\t\t triplet = 5.33/64\n\t\t//\t\t 1/16 = 2/32 = 4/64\n\t\t//\t\t 1/32 = 1/32 = 2/64\n\n\t\tif (duration >= 28 * whole / 32)\n\t\t return NoteDuration.Whole;\n\t\telse if (duration >= 20 * whole / 32)\n\t\t return NoteDuration.DottedHalf;\n\t\telse if (duration >= 14 * whole / 32)\n\t\t return NoteDuration.Half;\n\t\telse if (duration >= 10 * whole / 32)\n\t\t return NoteDuration.DottedQuarter;\n\t\telse if (duration >= 7 * whole / 32)\n\t\t return NoteDuration.Quarter;\n\t\telse if (duration >= 5 * whole / 32)\n\t\t return NoteDuration.DottedEighth;\n\t\telse if (duration >= 6 * whole / 64)\n\t\t return NoteDuration.Eighth;\n\t\telse if (duration >= 5 * whole / 64)\n\t\t return NoteDuration.Triplet;\n\t\telse if (duration >= 3 * whole / 64)\n\t\t return NoteDuration.Sixteenth;\n\t\telse if (duration >= 2 * whole / 64)\n\t\t return NoteDuration.ThirtySecond;\n\t\telse if (duration >= whole / 64)\n\t\t return NoteDuration.SixtyFour; // TODO : EXTEND UNTIL 1/128 to be able to extract the onset in SYMBOLIC representation\n\t\telse if (duration >= whole / 128)\n\t\t return NoteDuration.HundredTwentyEight;\n\t\telse\n\t\t return NoteDuration.ZERO;\n\t}", "public void animal_Name(View view) {\n mediaplayeriscreated2 = true;\n\n if (animal_count[count] == 1) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.alligator_1);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.alligator_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 2) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.bear_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.bear_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 3) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.bird_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.bird_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 4) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.bull_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.bull_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 5) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.cat_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.cat_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 6) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.cheetah_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.cheetah_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 7) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.cow_1);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.cow_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 8) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.deer_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.deer_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 9) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.dog_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.dog_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 10) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.dolphin_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.dolphin_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 11) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.donkey_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.donkey_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 12) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.duck_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.duck_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 13) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.eagle_1);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.eagle_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 14) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.elephant_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.elephant_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 15) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.frog_1);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.frog_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 16) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.goats_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.goat_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 17) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.hen_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.hen_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 18) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.horse_1);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.horse_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 19) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.lion_1);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.lion_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 20) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.monkey_1);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.monkey_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 21) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.mouse_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.mouse_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 22) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.owl_1);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.owl_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 23) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.parrot_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.parrot_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 24) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.pig_1);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.pig_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 25) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.rabbit_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.rabbit_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 26) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.raccoon_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.raccoon_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 27) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.rooster_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.rooster_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 28) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.sheep_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.sheep_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 29) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.skunk_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.skunk_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 30) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.snake_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.snake_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 31) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.squirrel_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.squirrel_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n else if (animal_count[count] == 32) {\n try {\n mp3.reset();\n mp4.reset();\n }\n catch (Exception ex) {\n }\n if (key.equals(\"sound\")) {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.whale_);\n mp4.seekTo(0);\n mp4.start();\n key = \"word\";\n }\n else {\n mp4 = MediaPlayer.create(animal_quiz.this, R.raw.whale_name);\n mp4.seekTo(0);\n mp4.start();\n key = \"sound\";\n }\n }\n// count += 1;\n }", "@Override\r\n public String speak() {\r\n String word = \"\";\r\n Time.getInstance().time += 1;\r\n if (Time.getInstance().time == 1) {\r\n word = \"One day Neznaika decided to become an artist.\";\r\n }\r\n if (Time.getInstance().time == 101) {\r\n word = \"This story happened once day with Neznaika.\";\r\n }\r\n if (Time.getInstance().time == 201) {\r\n word = \"One day Neznaika wanted to become a musician.\";\r\n }\r\n if (Time.getInstance().time == 401) {\r\n word = \"One day Neznaika wanted to become a poet.\";\r\n }\r\n System.out.println(word);\r\n return word;\r\n }", "private void getLyrics() {\n getLyricsOneStep(String.format(\"%s %s %s\", spotifyBroadcastReceiver.getAlbumName(),\n spotifyBroadcastReceiver.getTrackName(),\n spotifyBroadcastReceiver.getArtistName()));\n }", "public void ReproduceAudio() { \r\n\t\ttry {\r\n\t\t\t//en caso de que como nombre pongas \"undertale\" la musica sera diferente.\r\n\t\t\tif (Menu.jugador.equals(\"undertale\") || Menu.jugador.equals(\"Undertale\")) {\r\n\t\t\t\trepro.AbrirFichero(\"C:\\\\Temp\\\\Sonidos\\\\undertale.wav\");\r\n\t\t\t\t//emppieza la musica\r\n\t\t\t\trepro.Play();\r\n\t\t\t//musica por defecto\r\n\t\t\t} else {\r\n\t\t\t\trepro.AbrirFichero(\"C:\\\\Temp\\\\Sonidos\\\\tetris.mp3\");\r\n\t\t\t\trepro.Play();\r\n\t\t\t}\t\r\n\t\t} catch (Exception ex) {\r\n\t\t\tSystem.out.println(\"Error: \" + ex.getMessage());\r\n\t\t}\r\n\t}", "public String toString(){\n\t\tString s1 = \"\\n======= \" + title + \" =========\";\n\t\tString s3 = \"\\n========================================\\n\";\n\t\treturn s1 + \"\\nTitle: \" + title + \"\\nArtist Name: \" + artistName + \"\\nGenre: \" + genre + \n\t\t\t\t\"\\nRating: \" + rating + \"\\nLength: \" + time + s3;\n\t}", "public String toString() {\n String songOutput =\n \"Song name: \" + name + \"; Artist: \" + artist.getName() + \"; Time played: \" +\n timesPlayed + \"; Running time: \" + runningTime;\n return songOutput;\n }", "public String toString()\n {\n String output = \"--------------My Playlist---------------\\n\";\n for (int s = 0; s< countSong; s++)\n {\n output+= playlist[s].toString() + \"\\n\";\n output+=\"--------------------------------\\n\";\n\n }\n return output;\n }", "public String showSong(){\n String dataSong =\"\";\n for(int i = 0; i<MAX_SONG; i++){\n if(poolSong[i] != null){\n dataSong += poolSong[i].showDataSong();\n }\n }\n return dataSong;\n }", "public static PatternInterface trill(Note baseNote, char trillDirection, double singleSoundDuration){\r\n \r\n \tStringBuilder musicStringBuilder = new StringBuilder();\r\n \r\n \tdouble totalDuration = baseNote.getDecimalDuration();\r\n double actualDuration = 0.0d;\r\n \r\n byte secondNote = baseNote.getValue();\r\n \r\n if(trillDirection == EFFECT_DIRECTION_UP){\r\n \tsecondNote++;\r\n } else if(trillDirection == EFFECT_DIRECTION_DOWN){\r\n \tsecondNote--;\r\n }\r\n \r\n double remainingDuration = totalDuration - (2*singleSoundDuration);\r\n if(remainingDuration > 0.0d){\r\n \t\r\n \tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \tactualDuration+=singleSoundDuration;\r\n \t\r\n \twhile(actualDuration < totalDuration){\r\n \t\tif(actualDuration + (2*singleSoundDuration) < totalDuration){\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, secondNote, singleSoundDuration);\r\n \t\t\tactualDuration += singleSoundDuration;\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \t\t\tactualDuration += singleSoundDuration;\r\n \t\t} else if(actualDuration + singleSoundDuration > totalDuration){\r\n \t\t\tdouble gapDuration = totalDuration - actualDuration;\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), gapDuration);\r\n \t\t\tactualDuration+=gapDuration;\r\n \t\t} else {\r\n \t\t\tappendNoteValueAndDuration(musicStringBuilder, baseNote.getValue(), singleSoundDuration);\r\n \t\t\tactualDuration+=singleSoundDuration;\r\n \t\t}\r\n \t}\r\n \treturn new Pattern(musicStringBuilder.toString().trim());\r\n } else {\r\n \treturn new Pattern(baseNote.getMusicString());\r\n }\r\n }", "private void buildMetadataLine(SuggestedPodcast addPodcastFormData) {\n\n\t\tStringBuffer metadataLine = new StringBuffer();\n\t\tmetadataLine.append(addPodcastFormData.getFeedUrl());\n\t\tmetadataLine.append(\"; \");\n\n\t\tmetadataLine.append(addPodcastFormData.getIdentifier());\n\t\tmetadataLine.append(\"; \");\n\n\t\tif (addPodcastFormData.getCategories() != null) {\n\t\t\t// build categories String\n\t\t\tString categoriesStr = \"\";\n\t\t\tfor (String s : addPodcastFormData.getCategories()) {\n\t\t\t\tcategoriesStr += s + \", \";\n\t\t\t}\n\t\t\t// we add the categories separated by comma, and remove the last\n\t\t\t// comma and space\n\t\t\tmetadataLine.append(categoriesStr.subSequence(0,\n\t\t\t\t\tcategoriesStr.length() - 2));\n\t\t\tmetadataLine.append(\"; \");\n\t\t}\n\n\t\t// add language code\n\t\tmetadataLine.append(addPodcastFormData.getLanguageCode().toString());\n\t\tmetadataLine.append(\"; \");\n\n\t\t// add media type\n\t\tmetadataLine.append(addPodcastFormData.getMediaType().toString());\n\t\tmetadataLine.append(\"; \");\n\n\t\t// add frequency type\n\t\tmetadataLine.append(addPodcastFormData.getUpdateFrequency().toString());\n\t\tmetadataLine.append(\"; \");\n\n\t\t// add tags/keywords\n\n String suggestedTags = addPodcastFormData.getSuggestedTags();\n metadataLine.append(suggestedTags);\n\t\tmetadataLine.append(\"; \");\n\n\t\t// add facebook fan page\n\t\tmetadataLine.append(addPodcastFormData.getFacebookPage());\n\t\tmetadataLine.append(\"; \");\n\n\t\t// add twitter fan page\n\t\tmetadataLine.append(addPodcastFormData.getTwitterPage());\n\t\tmetadataLine.append(\"; \");\n\n\t\t// add twitter fan page\n\t\tmetadataLine.append(addPodcastFormData.getGplusPage());\n\t\tmetadataLine.append(\"; \");\n\n\t\t// add name of the visitor that submitted the podcast\n\t\tmetadataLine.append(addPodcastFormData.getName());\n\t\tmetadataLine.append(\"; \");\n\n\t\t// add email of the visitor who suggested the podcast, so that we sent\n\t\t// him a thank you email if added - ahaaa\n\t\tmetadataLine.append(addPodcastFormData.getEmail());\n\n\t\t// set the metadataLine\n\t\taddPodcastFormData.setMetadataLine(metadataLine.toString());\n\n\t}", "public void addMusic(String musicname)\r\n\t{\r\n\t\tmyMusics.add(musicname);\r\n\t}", "CompositionBuilder<T> addNote(int start, int end, int instrument, int pitch, int volume);", "public String getMusic(int index){\r\n\t\treturn myMusics.get(index);\r\n\t}", "public void buildPartyAudio(int quantity){\r\n if(quantity != 0){\r\n eventRoomItems.addItem(itemFactory.constructPartyAudio());\r\n }\r\n else{\r\n eventRoomItems.addItem(null);\r\n }\r\n }", "public String addSongX(String[] songInfo, int[] length){\r\n\t\tString message=\"\";\r\n\t\tboolean ctrl=false; //to evaluate if there is a null space in the song arraylist\r\n\r\n\t\tGenre genre = Genre.valueOf(songInfo[3].toUpperCase().replaceFirst(\" \",\"_\"));\r\n\r\n\t\tif(sharedPool[(sharedPool.length -1)]!=null){\r\n\t\t\tmessage = \" *Lo sentimos. Se ha alcanzado nuestro MAXIMO numero de CANCIONES*\";\r\n\t\t\tctrl=true; //As the entire songs' arraylist is full, it is unnecessary to run the for\r\n\t\t}\r\n\t\tfor(int i=0; i< sharedPool.length && !ctrl; i++){\r\n\t\t\tif(sharedPool[i]==null){\r\n\t\t\t\tsharedPool[i]= new Song(songInfo[0], songInfo[1], songInfo[2], genre, length);\r\n\t\t\t\tctrl=true;\r\n\t\t\t\tmessage = \" *Se ha agregado la cancion*\";\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn message;\r\n\t}", "public String toString() {\n\t\treturn \"Song [title=\" + title + \", artist=\" + artist + \", genre=\" + genre + \"]\";\n\t}", "private String soundConversion() {\n int reading = (record[18] & 255) + ((record[21] & 0x0C) << 6);\n return (reading * 100) / 1024 + \"\";\n }", "public static void main(String[] args) {\n double[] weighs1 = {90,10,0,0,0,0}; \r\n Song S1 = new Song(\"Wonderwall\", \"Oasis\", weighs1); \r\n \r\n double[] weighs2 = {80,10,10,0,0,0}; \r\n Song S2 = new Song(\"Don't look back in anger\", \"Oasis\", weighs2); \r\n \r\n double[] weighs3 = {50,20,10,0,20,0}; \r\n Song S3 = new Song(\"Money\", \"Pink Floyd\", weighs3); \r\n \r\n double[] weighs4 = {30,10,30,30,0,0}; \r\n Song S4 = new Song(\"Catholic girls\", \"Frank Zappa\", weighs4); \r\n \r\n double[] weighs5 = {80,0,20,0,0,0}; \r\n Song S5 = new Song(\"Stairway to heaven\", \"Led Zeppelin\", weighs5); \r\n \r\n double[] weighs6 = {100,0,0,0,0,0}; \r\n Song S6 = new Song(\"Perfect strangers\", \"Deep Purple\", weighs6); \r\n \r\n double[] weighs7 = {10,80,10,0,0,0}; \r\n Song S7 = new Song(\"Purple rain\", \"Prince\", weighs7); \r\n \r\n double[] weighs8 = {100,0,0,0,0,0}; \r\n Song S8 = new Song(\"Back in black\", \"AC DC\", weighs8); \r\n \r\n double[] weighs9 = {0,0,100,0,0,0}; \r\n Song S9 = new Song(\"The thrill is gone\", \"BB King\", weighs9); \r\n \r\n double[] weighs10 = {0,0,60,40,0,0}; \r\n Song S10 = new Song(\"I'd rather go blind\", \"Etta James\", weighs10); \r\n \r\n double[] weighs11 = {40,20,40,0,0,0}; \r\n Song S11 = new Song(\"With or without you\", \"U2\", weighs11); \r\n \r\n double[] weighs12 = {40,10,30,10,10,0}; \r\n Song S12 = new Song(\"Heroes\", \"David Bowie\", weighs12); \r\n \r\n double[] weighs13 = {90,0,10,0,0,0}; \r\n Song S13 = new Song(\"Free bird\", \"Lynyrd Skynyrd\", weighs13); \r\n \r\n double[] weighs14 = {50,30,20,0,0,0}; \r\n Song S14 = new Song(\"Always\", \"Bon Jovi\",weighs14); \r\n \r\n double[] weighs15 = {40,60,0,0,0,0}; \r\n Song S15 = new Song(\"Happy when it rains\", \"The Jesus and Mary Chain\", weighs15); \r\n \r\n Song[] songsadded = {S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12,S13,S14,S15}; //table with songs created\r\n \r\n RadioStation radiostation1 = new RadioStation(songsadded); //create InternetRadio station that includes all songs \r\n System.out.println(\"RadioStation playlist\");\r\n radiostation1.getSimilar(\"Heroes\"); //create song playlist according to Eukleidia distance\r\n \r\n\r\n \r\n \r\n Song[] songsadded1 = {S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12,S13,S14,S15}; //table with songs created\r\n ManhattanRadioStation manhattanradiostation1 = new ManhattanRadioStation(songsadded1); //create ManhattanRadio station that includes all songs\r\n System.out.println(\"Manhattan RadioStation playlist\");\r\n manhattanradiostation1.getSimilar(\"Heroes\"); //create song playlist according to Manhattan distance\r\n\r\n \r\n \r\n \r\n }", "public interface MusicOperations {\n\n\n /**\n * Adds a note to the piece at a given beat number with generic instrument and volume.\n *\n * <p>the String needed for the pitch is the letter of the note, followed by \"SHARP\" if\n * the note is a sharp. Everything must be in all caps.\n * (i.e a C would be given as \"C\", and a C# would be \"CSHARP\" </p>\n *\n * @param pitch pitch of the note to be added as a String\n * @param octave octave of the note to be added.\n * @param duration duration of the note to be added.\n * @param beatNum beat number to add the note at.\n * @throws IllegalArgumentException if note is invalid.\n */\n void addNote(int duration, int octave, int beatNum, String pitch)\n throws IllegalArgumentException;\n\n\n /**\n * Adds a given Repeat at given beat.\n * @param beatNum beatNumber to be placed at.\n * @param repeatType type of repeat to add.\n */\n void addRepeat(int beatNum, RepeatType repeatType);\n\n /**\n * Adds a note to model with given parameters.\n * @param duration duration of Note added.\n * @param octave octave of Note added.\n * @param beatNum beat number to place note at.\n * @param instrument instrument of the note.\n * @param volume the volume of the note added.\n * @param pitch the pitch of the note added as a String. (see prior method for details)\n * @throws IllegalArgumentException if it is an illegal note.\n */\n void addNote(int duration, int octave, int beatNum, int instrument, int volume, String pitch)\n throws IllegalArgumentException;\n\n /**\n * Removes a note from the song.\n * @param beatNum beat number to remove note from.\n * @param pitch pitch of the note.\n * @param octave octave of the note.\n * @return the note that was deleted.\n * @throws IllegalArgumentException if note cannot be found.\n */\n INote removeNote(int beatNum, String pitch, int octave) throws IllegalArgumentException;\n\n /**\n * Edits the given note according to editor.\n * @param editor contains directions to edit note.\n * @param beatNum the beat number the note is at.\n * @param pitch the pitch of the note.\n * @param octave the octave of the note.\n * @throws IllegalArgumentException if note cannot be found.\n */\n void editNote(String editor, int beatNum, String pitch, int octave)\n throws IllegalArgumentException;\n\n /**\n * Merges the given piece with the one in the model.\n * @param piece piece to merge.\n */\n void mergePiece(Piece piece);\n\n /**\n * Adds the given piece at the end of the current one.\n * @param piece piece to be added to current one.\n */\n void addPiece(Piece piece);\n\n\n /**\n * Gets the song in MIDI notation as a String.\n * @return the string.\n */\n String getMIDINotation();\n\n\n /**\n * NEW METHOD to aid view play notes at given beat without parsing.\n * Gets a copy of the Notes that start at given beat number.\n * @param beatNum number to get notes from.\n * @return the list of notes.\n */\n ArrayList<INote> getNotesAt(int beatNum);\n\n /**\n * Gets the minimum note value.\n * @return returns the min.\n */\n int minNoteValue();\n\n /**\n * gets the max note value.\n * @return the value.\n */\n int maxNoteValue();\n\n /**\n * Gets the last beat of the song.\n * @return the last beat number.\n */\n int maxBeatNum();\n\n /**\n * Gets the Tempo of the song.\n * @return the tempo of the song.\n */\n int getTempo();\n\n /**\n * Sets the tempo of the song.\n * @param tempo tempo to be set.\n */\n void setTempo(int tempo);\n\n Repeat getRepeatAt(int beat);\n\n boolean hasRepeatAt(int beat);\n\n List<BeginRepeat> getBeginRepeats();\n\n Map<Integer, Repeat> getRepeats();\n}", "public String showPlayList(){\n String dataPlayList = \"\";\n for(int i = 0; i<MAX_PLAYLIST; i++){\n if(thePlayLists[i] != null){\n thePlayLists[i].uptadeDurationFormat(thePlayLists[i].uptadeDuration());\n thePlayLists[i].changeGender(thePlayLists[i].uptadeGender());\n dataPlayList += thePlayLists[i].showDatePlayList();\n }\n }\n return dataPlayList;\n }", "@Test\n public void advancedRepeatTest(){\n \n testMaterialConstructor();\n ArrayList<String> voiceNames = new ArrayList<String>();\n voiceNames.add(\"Aziz\");\n \n ArrayList<BarLineObject> objs = new ArrayList<BarLineObject>();\n objs.add(C);\n objs.add(E);\n objs.add(C);\n objs.add(G);\n objs.add(plainBar);\n objs.add(C);\n objs.add(E);\n objs.add(C);\n objs.add(G);\n objs.add(endBar);\n objs.add(G);\n objs.add(G);\n objs.add(G);\n objs.add(C);\n objs.add(r1Bar);\n objs.add(C);\n objs.add(G);\n objs.add(G);\n objs.add(G);\n objs.add(r2Bar);\n objs.add(C);\n objs.add(E);\n objs.add(E);\n objs.add(E);\n objs.add(repeatBar);\n \n objs.add(C);\n objs.add(E);\n objs.add(C);\n objs.add(G);\n objs.add(repeatStart);\n objs.add(G);\n objs.add(C);\n objs.add(C);\n objs.add(G);\n objs.add(repeatBar);\n \n \n \n Parser2 myParser2 = new Parser2(voiceNames,1,1);\n myParser2.parse(objs);\n ArrayList<Voice> voices = myParser2.getVoices();\n\n Song lalala = new Song(voices);\n \n SequencePlayer sqPlayer;\n try {\n sqPlayer = new SequencePlayer(140, lalala.getMinTicksPerQuarter());\n myPlayer MrAhmed = new myPlayer(\"C\", sqPlayer);\n lalala.addToPlayer(MrAhmed);\n sqPlayer.play();\n \n } catch (MidiUnavailableException e) {\n e.printStackTrace();\n } catch (InvalidMidiDataException e) {\n e.printStackTrace();\n }\n \n }", "public void m6621a(String str) {\n int i;\n ArrayList<C0937a> arrayList;\n C0938a.m5002a(\"SR/SoundRecorder\", \"<addMarksToDB> filePath: \" + str);\n boolean z = true;\n Cursor cursor = null;\n try {\n Cursor query = getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, new String[]{\"_id\"}, \"_data=?\", new String[]{str}, (String) null);\n if (query == null || query.getCount() != 1) {\n i = -1;\n } else {\n query.moveToFirst();\n i = query.getInt(0);\n }\n if (query != null) {\n try {\n query.close();\n } catch (Exception e) {\n C0938a.m5004b(\"SR/SoundRecorder\", \"<addMarksToDB> Exception: \" + e.toString());\n }\n }\n } catch (Exception e2) {\n C0938a.m5004b(\"SR/SoundRecorder\", \"<addMarksToDB> cannot open meida database: \" + e2.toString());\n if (cursor != null) {\n try {\n cursor.close();\n } catch (Exception e3) {\n C0938a.m5004b(\"SR/SoundRecorder\", \"<addMarksToDB> Exception: \" + e3.toString());\n }\n }\n i = -1;\n } catch (Throwable th) {\n if (cursor != null) {\n try {\n cursor.close();\n } catch (Exception e4) {\n C0938a.m5004b(\"SR/SoundRecorder\", \"<addMarksToDB> Exception: \" + e4.toString());\n }\n }\n throw th;\n }\n C0938a.m5002a(\"SR/SoundRecorder\", \"<addMarksToDB> recFileId: \" + i);\n C0938a.m5002a(\"SR/SoundRecorder\", \"<addMarksToDB> insert start -------- \");\n StringBuilder sb = new StringBuilder();\n sb.append(\"<addMarksToDB> mDB is null ?\");\n if (this.f5404X != null) {\n z = false;\n }\n sb.append(z);\n C0938a.m5002a(\"SR/SoundRecorder\", sb.toString());\n if (!(this.f5404X == null || (arrayList = this.f5382B) == null || arrayList.size() < 0)) {\n int size = this.f5382B.size();\n this.f5418ga = size;\n C0938a.m5002a(\"SR/SoundRecorder\", \"<addMarksToDB> mMarksList size: \" + size);\n ContentValues contentValues = new ContentValues();\n for (int i2 = 0; i2 < size; i2++) {\n C0938a.m5002a(\"SR/SoundRecorder\", \"<addMarksToDB>insert : \" + i2);\n if (i != -1) {\n contentValues.put(\"_mark_recfile_id\", Integer.valueOf(i));\n contentValues.put(\"_mark_path\", str);\n contentValues.put(\"_mark_time_length\", Long.valueOf(this.f5382B.get(i2).mo5064b()));\n contentValues.put(\"_mark_name\", this.f5382B.get(i2).mo5061a());\n }\n try {\n if (this.f5404X != null) {\n this.f5404X.mo5341a(\"recordermarks\", contentValues);\n }\n } catch (Exception e5) {\n C0938a.m5004b(\"SR/SoundRecorder\", \"<addMarksToDB>,Exception = \" + e5);\n }\n contentValues.clear();\n }\n }\n C0938a.m5002a(\"SR/SoundRecorder\", \"<addMarksToDB> insert end ------- \");\n ArrayList<C0937a> arrayList2 = this.f5382B;\n if (arrayList2 != null && arrayList2.size() > 0) {\n C0938a.m5002a(\"SR/SoundRecorder\", \"<addMarksToDB>, mMarksList.clear()!\");\n this.f5382B.clear();\n this.f5394N.post(new C1308a(this));\n }\n }", "public boolean loadSongs(String fileName) throws FileNotFoundException {\n\t\tFile x = new File(fileName);\n\t\tthis.name = fileName;\n\t\tScanner reader = new Scanner(x);\n\t\tArrayList<String> line = new ArrayList<String>();\n\t\tArrayList<String> title = new ArrayList<String>();\n\t\tArrayList<String> artist = new ArrayList<String>();\n\t\tArrayList<String> time = new ArrayList<String>();\n\t\tboolean output = false;\n\t\twhile (reader.hasNextLine()) {\n\t\t\tString l = reader.nextLine().trim();\n\t\t\tline.add(l);\n\t\t}\n\t\tfor (int i = 3; i < line.size() - 1; i += 3) {\n\t\t\tif (!line.isEmpty() && line.get(i).contains(\"\")) {\n\t\t\t\tSong s = new Song(line.get(1), line.get(0));\n\t\t\t\tthis.songList.add(s);\n\t\t\t\toutput = true;\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < line.size() - 1; i += 4) {\n\t\t\ttitle.add(line.get(i));\n\t\t}\n\t\tfor (int i = 1; i < line.size() - 1; i += 4) {\n\t\t\tartist.add(line.get(i));\n\t\t}\n\t\tfor (int i = 2; i < line.size() - 1; i += 4) {\n\t\t\ttime.add((line.get(i)));\n\t\t}\n\n\t\tfor (int i = 0; i < songList.size() - 1; i++) {\n\t\t\tsongList.get(i).setArtist(artist.get(i));\n\t\t\tsongList.get(i).setTitle(title.get(i));\n\t\t\tsongList.get(i).setMinutes(Character.getNumericValue((time.get(i).charAt(0))));\n\t\t}\n\n\t\t/** add minutes to the last song on playlist **/\n\t\t/**\n\t\t * the loop keeps giving 0 so this is a precaution to ensure that the\n\t\t * correct numbers get picked\n\t\t **/\n\t\tsongList.get(songList.size() - 1).setMinutes(Character.getNumericValue((time.get(time.size() - 1).charAt(0))));\n\n\t\tfor (int i = 0; i < songList.size() - 1; i++) {\n\t\t\tif (time.get(i).substring(2).length() <= 2) {\n\t\t\t\tsongList.get(i).setSeconds(Integer.parseInt(time.get(i).substring(2)));\n\t\t\t} else {\n\t\t\t\tint sec = Integer.parseInt(time.get(i).substring(2));\n\t\t\t\tsongList.get(i).setSeconds(sec % 60);\n\t\t\t\tsongList.get(i).setMinutes(songList.get(i).getMinutes() + sec / 60);\n\t\t\t}\n\t\t}\n\n\t\t/** add proper minutes and second to the last song on playlist **/\n\t\t/**\n\t\t * the loop keeps giving 0 so this is a precaution to ensure that the\n\t\t * correct numbers get picked\n\t\t **/\n\t\tif (time.get(time.size() - 1).substring(2).length() <= 2) {\n\t\t\tsongList.get(songList.size() - 1).setSeconds(Integer.parseInt(time.get(time.size() - 1).substring(2)));\n\t\t} else {\n\t\t\tint sec = Integer.parseInt(time.get(time.size() - 1).substring(2));\n\t\t\tsongList.get(songList.size() - 1).setSeconds(sec % 60);\n\t\t\tsongList.get(songList.size() - 1).setMinutes(songList.get(songList.size() - 1).getMinutes() + sec / 60);\n\t\t}\n\t\treturn output;\n\n\t}", "public String scoreTo8BitsStringNotes(){\n\t\tString str = \"\", placeholder = \"00\",seperator = \" \";\n\t\tfor(StdNote tNote : musicTrack.get(0).noteTrack){\n\n\t\t\tstr += String.format(\"%03d\",tNote.absolutePosition)\n\t\t\t\t+ tNote.downFlatSharp\n\t\t\t\t+ tNote.octave\n\t\t\t\t+ tNote.dot\n\t\t\t\t+ placeholder\n\t\t\t\t+ seperator;\n\t\t\t//这里要这样写么??\n\t\t\tif(tNote.barPoint == 1) str += ',';\n\t\t}\n\t\treturn str.trim();//去掉前后空格\n\t}", "public String toString() {\n\t\tString strMusica = \"\";\n\t\tfor (int i = 0; i < musicas.length; i++) {\n\t\t\tstrMusica += musicas[i] + \" \";\n\t\t}\n\n\t\treturn \"Autor: \" + autor + \", Nome: \" + nome + \", Preferida: \"\n\t\t\t\t+ preferida + \", Musicas: \" + strMusica;\n\t}", "private static void loadMusic()\n\t{\n\t\t// TODO: update this with the correct file names.\n\t\tmusic = new ArrayList<Music>();\n\t\t\n\t\ttry\n\t\t{\n\t\t\tmusic.add(Gdx.audio.newMusic(new FileHandle(new File(MUSIC_PATH + \"Lessons-8bit.mp3\"))));\n\t\t\tmusic.add(Gdx.audio.newMusic(new FileHandle(new File(MUSIC_PATH + \"bolo_menu.mp3\"))));\n\t\t\t//music.add(Gdx.audio.newMusic(new FileHandle(new File(MUSIC_PATH + \"song2.ogg\"))));\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\t\n\t\t\tSystem.out.println(e);\n\t\t\te.printStackTrace();\n\t\t\tthrow e;\n\t\t}\n\t}", "private static void playAudio(String musicFile) {\n }", "private boolean musicChecker(String currentInput)\n\t{\n\t\tboolean hasMusic = false;\n\t\t// loop, look for music.\n\n\t\tfor (String currentPhrase : musicList)\n\t\t{\n\t\t\tif (currentPhrase.equals(currentInput))\n\t\t\t{\n\t\t\t\thasMusic = true;\n\t\t\t}\n\t\t}\n\t\treturn hasMusic;\n\t}", "private String getShortWaveFile() {\n return \"whatstheweatherlike.wav\";\n }", "public String allSongs (String artist)\n\t{\n\t\tArrayList <String> songs = new ArrayList <String>();\n\t\tfor (Song e: music)\n\t\t\tif(e.getArtist().equals(artist))\n\t\t\t\tsongs.add(e.getName());\n\t\tString results = \"\";\n\t\tfor (int i = 0; i < songs.size(); i++)\n\t\t{\n\t\t\tif (music.size()-1 == i)\n\t\t\t{\n\t\t\t\tresults += music.get(i) +\".\";\n\t\t\t}\n\t\t\t\t\n\t\t\telse\n\t\t\t{\n\t\t\t\tresults += music.get(i) + \", \";\n\t\t\t}\n\t\t}\n\t\treturn results; \n\t}", "private void generateAudio() {\n soundHandler.generateTone();\n }", "void addNote(int duration, int octave, int beatNum, int instrument, int volume, String pitch)\n throws IllegalArgumentException;", "private void initialMusic(){\n\n }", "@Override\n public void mergeModels(MusicOperation model) {\n int thisLength = this.getFinalBeat();\n int otherLength = model.getFinalBeat();\n int length;\n\n if (thisLength >= otherLength) {\n length = thisLength;\n } else {\n length = otherLength;\n }\n\n for (int i = 0; i < length; i++) {\n List<Note> currentNotes = model.getNotesAtBeat(i);\n\n for (int x = 0; x < currentNotes.size(); x++) {\n Note currentNote = currentNotes.get(x);\n this.addNote(currentNote);\n\n }\n\n }\n\n }", "public void onCreateActivity(){\n\t\tlist_v = (ListView) findViewById(R.id.list_v);\n\t\tappInst = (App) getApplicationContext();\n// File dir = new File(appInst.MUSIC_PATH);\n// String[] files = dir.list();\n\t\tString textSt = \"\";\n// for(String file : files){\n// \ttextSt += (file+\"\\r\\n\");\n// }\n// text.setText(textSt);\n// text.setText(appInst.MUSIC_PATH);\n// text.setText(FileUtils.walk(appInst.MUSIC_PATH));\n// getContentResolver().query(appInst.MUSIC_PATH, projection, selection, selectionArgs, sortOrder)\n\t\tString[] proj = new String[] {\n\t\t\t\tMediaStore.Audio.Media._ID,\n\t\t\t\tMediaStore.Audio.Media.DATA,\n\t\t\t\tMediaStore.Audio.Media.DISPLAY_NAME,\n\t\t\t\tMediaStore.Audio.Media.DURATION,\n\t\t\t\tMediaStore.Audio.Media.ALBUM_ID\n\n\t\t};\n// Log.i(\">>uri\",Uri.fromParts(\"content\", appInst.MUSIC_PATH, null).toString());\n// Log.i(\">>uri\",Uri.parse(appInst.MUSIC_PATH).toString());\n// String where = MediaStore.Audio.Media.MIME_TYPE + \"= 'audio/mpeg'\" + \" AND \"+\n// \t\tMediaStore.Audio.Artists._ID +\" IN (\" +\n// \t\t\t\t\"SELECT \"+MediaStore.Audio.Media.ARTIST_ID+\" FROM AUDIO \"+\n// \t\t\t\t\"WHERE \"+MediaStore.Audio.Media.DATA +\" LIKE ?\" +\n// \t\t\")\";\n\t\tString where = MediaStore.Audio.Media.MIME_TYPE + \"= 'audio/mpeg'\" + \" AND \" +\n\t\t\t\tMediaStore.Audio.Media.DATA + \" LIKE ?\";\n\t\tString[] whereArgs = new String[]{appInst.MUSIC_PATH + \"%\"};\n\t\tCursor curs = appInst.getContentResolver().query(\n\t\t\t\tMediaStore.Audio.Media.EXTERNAL_CONTENT_URI,\n// \t\tMediaStore.Audio.Artists.EXTERNAL_CONTENT_URI,\n// \t\tUri.parse(appInst.MUSIC_PATH),\n// \t\tUri.fromParts(\"content\", appInst.MUSIC_PATH, null),\n\t\t\t\tproj,\n// \t\tnull,\n// MediaStore.Audio.Media.MIME_TYPE + \"= 'audio/mpeg'\",\n\t\t\t\twhere,\n\t\t\t\twhereArgs,\n\t\t\t\tMediaStore.Audio.Media._ID);\n\t\tfinal List<Song> songs = new ArrayList<>();\n\t\tif (curs == null) {\n\t\t\tToast.makeText(getApplicationContext(), \"query failed, handle error\", Toast.LENGTH_LONG).show();\n// Log.e(\"Cursor\", \"query failed, handle error\");\n\t\t} else if (!curs.moveToFirst()) {\n\t\t\tToast.makeText(getApplicationContext(), \"no media on the device\", Toast.LENGTH_LONG).show();\n// \tLog.e(\"Cursor\", \"no media on the device\");\n\t\t} else {\n\t\t\tdo {\n// \t\tlong id = curs.getLong(0);\n// \t\tString data = curs.getString(1);\n// \t\tString name = curs.getString(2);\n// \t\tString duration = curs.getString(3);\n// \t\ttextSt += Long.toString(id)+\";\"+data+\";\"+name+\";\"+duration+\"\\r\\n\\r\\n\";\n\t\t\t\tSong s = new Song(curs.getLong(0),curs.getString(1),curs.getString(2),curs.getString(3),curs.getLong(4));\n\t\t\t\tsongs.add(s);\n\t\t\t\tLog.i(\"song\"+s.getId(),\"data:\"+s.getData()+\";name:\"+s.getName()+\";duration:\"+s.getDuration());\n\t\t\t}while(curs.moveToNext());\n\t\t}\n\n\t\tLog.i(\"info\",\"size:\"+songs.size());\n\n\n// text.setText(textSt);\n// final AdapterPlaylistItem adapter = new AdapterPlaylistItem(this, R.layout.adapter_song, songs);\n\t\tfinal AdapterPlaylistItem adapter = new AdapterPlaylistItem(this, R.layout.adapter_song, songs);\n\t\tlist_v.setAdapter(adapter);\n\t\tlist_v.setOnItemClickListener(new OnItemClickListener() {\n\n\t\t\t@Override\n\t\t\tpublic void onItemClick(AdapterView<?> parent, final View view, final int position, long id) {\n//\t\t\t\tSong s = songs.get(position);\n//\t\t\t\tToast.makeText(appInst,\n//\t\t\t\t\t \"Click ListItem path \" + s.getData()+\"; duration:\"+s.getDuration(), Toast.LENGTH_LONG)\n//\t\t\t\t\t .show();\n\t\t\t\tfinal Song item = (Song)parent.getItemAtPosition(position);\n\t\t\t\tview.animate()\n\t\t\t\t\t\t.setDuration(2000)\n\t\t\t\t\t\t.alpha(0)\n\t\t\t\t\t\t.withEndAction(new Runnable() {\n\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\t\t\tsongs.remove(position);\n\t\t\t\t\t\t\t\tadapter.notifyDataSetChanged();\n\t\t\t\t\t\t\t\tview.setAlpha(1);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\tInteger.parseInt(\"adb\");\n\t\t\t}\n\n\t\t});\n\t}", "void startMusic(AudioTrack newSong);", "void addNote(int duration, int octave, int beatNum, String pitch)\n throws IllegalArgumentException;", "private void loveYourz()\n {\n Song loveYourz = new Song();\n loveYourz.add(new Note(noteD4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteG3, 0));\n loveYourz.add(new Note(noteDS3, 0));\n loveYourz.add(new Note(noteC2, 0));\n loveYourz.add(new Note(noteC1, WHOLE_NOTE/2));\n\n loveYourz.add(new Note(noteD4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteG3, 0));\n loveYourz.add(new Note(noteDS3, 0));\n loveYourz.add(new Note(noteC2, 0));\n loveYourz.add(new Note(noteC1, WHOLE_NOTE/4));\n\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteG3, 0));\n loveYourz.add(new Note(noteDS2, 0));\n loveYourz.add(new Note(noteDS1, WHOLE_NOTE/4));\n\n\n loveYourz.add(new Note(noteG4, 0));\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteC4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/2));\n\n loveYourz.add(new Note(noteG4, 0));\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteC4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/8));\n\n loveYourz.add(new Note(noteF4, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/8));\n\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/8));\n\n loveYourz.add(new Note(noteD4, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/8));\n\n\n loveYourz.add(new Note(noteD4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteG3, 0));\n loveYourz.add(new Note(noteDS3, 0));\n loveYourz.add(new Note(noteC2, 0));\n loveYourz.add(new Note(noteC1, WHOLE_NOTE/2));\n\n loveYourz.add(new Note(noteD4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteG3, 0));\n loveYourz.add(new Note(noteDS3, 0));\n loveYourz.add(new Note(noteC2, 0));\n loveYourz.add(new Note(noteC1, WHOLE_NOTE/4));\n\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteG3, 0));\n loveYourz.add(new Note(noteDS2, 0));\n loveYourz.add(new Note(noteDS1, WHOLE_NOTE/4));\n\n\n loveYourz.add(new Note(noteG4, 0));\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteC4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/2));\n\n loveYourz.add(new Note(noteG4, 0));\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteC4, 0));\n loveYourz.add(new Note(noteBB3, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/4));\n\n loveYourz.add(new Note(noteDS4, 0));\n loveYourz.add(new Note(noteGS2, 0));\n loveYourz.add(new Note(noteGS1, WHOLE_NOTE/4));\n playSong(loveYourz);\n playSong(loveYourz);\n }", "public static void createSoundsArrList() {\r\n\t\t//Clears the sounds array list.\r\n\t\tsounds.clear();\r\n\t\t\r\n\t\t//Adds all the sound files to the sounds array list.\r\n\t\tsounds.add(\"Start=\" + Main.soundGameStart);\r\n\t\tsounds.add(\"Bags=\" + Main.soundBags);\r\n\t\tsounds.add(\"Set=\" + Main.soundSet);\r\n\t\tsounds.add(\"Win=\" + Main.soundWin);\r\n\t\tsounds.add(\"Lose=\" + Main.soundLose);\r\n\t}", "@AutoGenerated\r\n\tprivate Panel buildAudioPanel() {\n\t\taudioPanel = new Panel();\r\n\t\taudioPanel.setWidth(\"100.0%\");\r\n\t\taudioPanel.setHeight(\"100.0%\");\r\n\t\taudioPanel.setImmediate(false);\r\n\t\t\r\n\t\t// verticalLayout_4\r\n\t\tverticalLayout_4 = buildVerticalLayout_4();\r\n\t\taudioPanel.setContent(verticalLayout_4);\r\n\t\t\r\n\t\treturn audioPanel;\r\n\t}", "public static void main(String[] args) {\n\t\t\n\t\tString m = \"ABCDEFG\";\t\t\n\t\tString[] musicinfos = new String[2];\n\t\tmusicinfos[0] = \"12:00,12:14,HELLO,CDEFGAB\";\n\t\tmusicinfos[1] = \"13:00,13:05,WORLD,ABCDEF\";\n\t\t\n\t\tSystem.out.println(solution(m,musicinfos));\n\t\t\n\t}", "private void Scale()\n {\n Song scale = new Song();\n scale.add(new Note(noteA1,WHOLE_NOTE/2));\n scale.add(new Note(noteBB1,WHOLE_NOTE/2));\n scale.add(new Note(noteB1,WHOLE_NOTE/2));\n scale.add(new Note(noteC1,WHOLE_NOTE/2));\n scale.add(new Note(noteCS1,WHOLE_NOTE/2));\n scale.add(new Note(noteD1,WHOLE_NOTE/2));\n scale.add(new Note(noteDS1,WHOLE_NOTE/2));\n scale.add(new Note(noteE1,WHOLE_NOTE/2));\n scale.add(new Note(noteF1,WHOLE_NOTE/2));\n scale.add(new Note(noteFS1,WHOLE_NOTE/2));\n scale.add(new Note(noteG1,WHOLE_NOTE/2));\n scale.add(new Note(noteGS1,WHOLE_NOTE/2));\n\n\n playSong(scale);\n }", "public Song(String artist, String title) { \r\n\t\tthis.artist = artist;\r\n\t\tthis.title = title;\r\n\t\tthis.minutes = 0;\r\n\t\tthis.seconds = 0;\r\n\t}", "public String sing(){\r\n\t\tlinesOfSong = new ArrayList<String>();\r\n\t\tString line;\r\n String fileName = \"OompaLoompaSong.txt\";\r\n\t\t\r\n\t\ttry{\r\n BufferedReader br = new BufferedReader(new FileReader(fileName));\r\n\t\t\tStringBuilder sb = new StringBuilder();\r\n\t\t\t//line = br.readLine();\t\r\n\t\t\t\r\n\t\t\twhile ((line = br.readLine()) != null) {\r\n linesOfSong.add(line);\r\n\t\t\t}\r\n\t\t\tbr.close(); \r\n\t\t}\r\n\t\tcatch(IOException e){\r\n\t\t\tSystem.out.println(\"Sorry, we couldn't make this song! \");\r\n\t\t}\r\n\t\tRandomSong();\r\n\t\treturn song;\r\n\t}", "public String buildingString() {\r\n\t\twhichBuild = 1 - whichBuild;\r\n\t\tif (whichBuild == 1) {\r\n\r\n\t\t}\r\n\t\treturn \"420 400;10 10 140 60 60 60 10;140 10 240 60 180 60 10;240 10 400 60 320 60 20 ;10 90 120 180 40 90 15;120 90 280 180 160 90 10;280 90 400 180 340 90 10\";\r\n\t}", "GuitarString(double frequency)\n\t{\n\t\tint qLen = (int) Math.round( SAMPLE_RATE / frequency );\n\t\trb = new RingBuffer(qLen);\n\t\ttotalTick = 0;\n\t\t\n\t\tfor(int i = 0; i < qLen; i++)\n\t\t\trb.enqueue(0);\n\t\t\t\n\t}", "String notes();", "void setTitleUnitSound(List<String> listTitle);", "public void resetInfo() {\n\t\ttry {\n\t\t\tMp3File mp3 = new Mp3File(currSong.getUrl());\n\t\t\tlong tduration = mp3.getLengthInSeconds();\n\t\t\ttotalDuration.setText(secToMin((long) tduration));\n\t\t\tcurrentDuration.setText(\"0:00\");\n\t\t\tplayedTime = 0;\n\t\t}catch(Exception e) {}\n\t}", "public void InsertInfo(String Name) throws IOException{\r\n test.songMatch();\r\n test.sourceMatch();\r\n test.WordTable();\r\n test.doword2();\r\n \r\n String value=\"\";\r\n String Performer=\"\";// will hold either arrangers, vocalists, or circles\r\n int counter=0;\r\n List<String> ListLines=new ArrayList<>();\r\n List<String> ListInserts=new ArrayList<>();\r\n List<String> PerformerLinesList=new ArrayList<>();\r\n Map <Integer,String> Map=new HashMap<>();\r\n Map <Integer,String> TempMap=new HashMap<>();\r\n Map <Integer,Integer> LinesMap=new HashMap<>();\r\n for(String object:FileNames){\r\n try{\r\n \r\n MP3 mp3 = new MP3(object); \r\n Title=mp3.getTitle(); \r\n switch(Name){\r\n case \"Vocal\": value= \"Vocalists\";\r\n Performer=mp3.getComments().trim();//get comments AKA THE VOCALISTS \r\n break;\r\n case \"Arranger\": value= \"Arrangers\";\r\n Performer=mp3.getMusicBy().trim();//get comments AKA THE ARRANFERS \r\n break;\r\n case \"Circle\": value= \"Circles\";\r\n Performer=mp3.getBand().trim();//get comments AKA THE CIRCLES \r\n break;\r\n } \r\n String []perform; \r\n perform=Performer.split(\"/\"); \r\n for (String perform1 : perform) {\r\n perform1=perform1.trim();\r\n boolean check=true; \r\n TempMap.put(counter, perform1.toLowerCase()); \r\n for(int id:Map.keySet()){\r\n if(perform1.toLowerCase().hashCode()==Map.get(id).toLowerCase().hashCode()){\r\n // System.out.println(\"check is false\"+counter);\r\n check=false;\r\n break;\r\n }\r\n }\r\n if(!Map.containsValue(perform1)){\r\n if(check)\r\n Map.put(counter, perform1);\r\n counter++;\r\n }\r\n \r\n int id=0;\r\n for(int a:Map.keySet()){\r\n if(Map.get(a).toLowerCase().equals(perform1.toLowerCase())){ \r\n id=a;\r\n break;\r\n } \r\n }\r\n String nos=\"\";\r\n nos= value;\r\n nos= value.substring(0,nos.length()-1);\r\n \r\n //vocalist inserts for table \r\n ListInserts.add(\"Insert Into \" +value+ \" (\"+nos+\"_id,\"+nos+\"_Name) values(\"+id+\",\"+perform1+\");\");\r\n //System.out.println(\"Insert Into \" +value+ \" (\"+nos+\"_id,\"+nos+\"_Name) values(\"+id+\",\"+perform1+\");\");\r\n \r\n //vocalist lines inserts for vocalist lines table\r\n //System.out.println(\"Insert Into VocalistLines (Song_id,Vocalist_Id) values(\"+Title+perform1);//+Title.hashCode()+\",\"+id+\");\"); \r\n // System.out.println(\"Insert Into VocalistLines (Song_id,Vocalist_Id) values(\"+Title.hashCode()+\",\"+id+\");\");\r\n ListLines.add(\"Insert Into \" +value+\"Lines (Song_id,Vocalist_Id) values(\"+Title.hashCode()+\",\"+id+\");\");\r\n int songid=test.getsongid(test.getMap(\"T\"), Title);\r\n LinesMap.put(songid, id);\r\n PerformerLinesList.add(+songid+\"/\"+id);\r\n } \r\n \r\n }\r\n catch(IOException e){\r\n System.out.println(\"An error occurred while reading/saving the mp3 file.\");\r\n } \r\n }\r\n switch(Name){\r\n case\"Vocal\":\r\n VocalistsMap.putAll(Map);\r\n VocalistsLines.addAll(ListLines);\r\n VocalistsInsert.addAll(ListInserts); \r\n VocalLinesList.addAll(PerformerLinesList);\r\n break;\r\n case \"Arranger\":\r\n ArrangersMap.putAll(Map);\r\n ArrangersLines.addAll(ListLines);\r\n ArrangersInsert.addAll(ListInserts);\r\n ArrangerLinesList.addAll(PerformerLinesList);\r\n break;\r\n case\"Circle\":\r\n CirclesMap.putAll(Map); \r\n CirclesLines.addAll(ListLines);\r\n CirclesInsert.addAll(ListInserts);\r\n CircleLinesList.addAll(PerformerLinesList);\r\n break;\r\n }\r\n}", "@Override\n public String toString() {\n return \"Art{\" +\n \"artist='\" + artist + '\\'' +\n \", timePeriod=\" + timePeriod +\n \", aesthetic='\" + aesthetic + '\\'' +\n \", size='\" + size + '\\'' +\n '}';\n }", "void note(float start, float duration, float freq){\n\t out.playNote(start,duration,freq); \n\t }", "public void decodeMelody(){\n //this.adder=new Adder(/*this.getTonicNote(),new int[]{0,1,2,3}*/);\n\n melodyNotes= adder.getKeyNotes(); //todo debug\n ArrayList<Integer[]> framenotes=adder.getFrameNotes();\n ArrayList<Integer[]> chordnotes=adder.getKeyChords();\n firstChord=chordnotes.get(0);\n secondChord=chordnotes.get(1);\n thirdChord=chordnotes.get(2);\n fourthChord=chordnotes.get(3);\n MiddleNote=framenotes.get(0);\n LastNote=framenotes.get(1);\n this.tokenizeAndParse();\n //01000101000000011100100100100110011101101110101110001010010101100101100101110\n //todo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n this.mainDecoder(8,firstChord);\n //todo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n this.copiedMeasureDecoder(firstChordNote,firstChord,secondChord);\n //todo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n this.mainDecoder(14,secondChord);\n //todo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n this.frameNoteDecoder(MiddleNote);\n //todo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n this.mainDecoder(24,thirdChord);\n //todo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n this.copiedMeasureDecoder(secondChordNote ,thirdChord,fourthChord);\n //todo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n this.mainDecoder(30,fourthChord);\n //todo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n this.frameNoteDecoder(LastNote);\n }", "public void addSong(String id, int album_id, String title, double length, int track) {\n SQLiteDatabase db = this.getWritableDatabase();\n\n ContentValues values = new ContentValues();\n values.put(KEY_ID, id);\n values.put(KEY_HOST, host);\n values.put(KEY_ALBUM_ID, album_id);\n values.put(KEY_TITLE, title);\n values.put(KEY_LENGTH, length);\n values.put(KEY_TRACK, track);\n\n long insertedId = db.insert(TABLE_SONG, null, values);\n db.close(); // Closing database connection\n }", "public MusicLibrary() {\n\t\tthis.idMap = new HashMap<String, Song>();\n\t\tthis.titleMap = new TreeMap<String, TreeSet<Song>>(new StringComparator());\n\t\tthis.artistMap = new TreeMap<String, TreeSet<Song>>(new StringComparator());\n\t\tthis.tagMap = new TreeMap<String, TreeSet<String>>(new StringComparator());\n\t\t//this.artistList = new ArrayList<>();\n\t}", "@Override\n public int getDuration() {\n if (this.music.size() == 0) {\n return 0;\n }\n else {\n int highestDuration = 0;\n ArrayList<Note> allNotes = this.getAllNotes();\n // find the note that has the longest length in the last arrayList\n for (Note note : allNotes) {\n if (note.getEndBeat() > highestDuration) {\n highestDuration = note.getEndBeat();\n }\n }\n return highestDuration;\n }\n }", "@Override\r\n\tpublic String toString(){\r\n\t\treturn String.format(\"%s, %s, %s\", getSongName(), getArtist(), getAlbum());\r\n\t}", "public static void updateMusic()\r\n\t{\r\n\t\tif ( Settings.isMusicOn() && !musicPlaying() )\r\n\t\t\tstartMusic();\r\n\t\telse if ( !Settings.isMusicOn() && musicPlaying() )\r\n\t\t\tstopMusic();\r\n\t}", "public void addSong(Song s) \r\n {\r\n \tSong mySong = s;\r\n \t\r\n \t//Adding to the first HashTable - the Title One\r\n \tmusicLibraryTitleKey.put(mySong.getTitle(), mySong);\r\n \t \r\n \t// Checking if we already have the artist\r\n \t if(musicLibraryArtistKey.get(mySong.getArtist()) != null)\r\n \t {\r\n \t\t //Basically saying that get the key (get Artist) and add mySong to it (i.e. the arraylist)\r\n \t\t musicLibraryArtistKey.get(mySong.getArtist()).add(mySong);\r\n \t }\r\n \t \r\n \t // If artist is not present, we add the artist and the song\r\n \t else\r\n \t {\r\n \t\t ArrayList<Song> arrayListOfSongs = new ArrayList<>();\r\n \t\t arrayListOfSongs.add(mySong);\r\n \t\t \r\n \t\t musicLibraryArtistKey.put(mySong.getArtist(), arrayListOfSongs);\r\n \t }\r\n \t \r\n \t// Checking if we already have the year\r\n \t if (musicLibraryYearKey.get(mySong.getYear()) != null)\r\n \t {\r\n \t \t musicLibraryYearKey.get(mySong.getYear()).add(mySong);\r\n \t }\r\n \t \r\n \t// If year is not present, we add the year and the song\r\n \t else\r\n \t {\r\n \t\t ArrayList<Song> arrayListOfSongs = new ArrayList<>();\r\n \t\t arrayListOfSongs.add(mySong);\r\n \t\t \r\n \t\t musicLibraryYearKey.put(mySong.getYear(), arrayListOfSongs);\r\n \t }\r\n\t\r\n }", "String sound();", "public String getSound()\r\n\t{\r\n\t\treturn \"Squeak Squeak Squeak\";\r\n\t}", "private void setDefaultSongNameAndArtist(){\r\n\t\tString[] songLocation = getLocation().split(\"/\");\r\n\t\tString[] songFragment = songLocation[songLocation.length - 1].split(\"[.]\");\r\n\t\tsetSongName(songFragment[0]);\r\n\t\t\r\n\t\tsetAlbum(songLocation[songLocation.length - 2] + \"?\");\r\n\t\tsetArtist(songLocation[songLocation.length - 3] + \"?\");\r\n\t\t\r\n\t}", "@Override\n\tpublic void measures() {\n\t\t\n\t\tsetTempo(240);\n\t\t\n\t\tkey = \"G\";\n\t\t\n\t\tmeasure(0);\n\t\t\n\t\taddNote(\"D5q\",A,T);\n\t\t\n\t\taddRest(\"q\",B);\n\t\t\n\t\tmeasure(1);\n\t\t\n\t\taddNotes(\"G5q G5i A5i G5i F5i\",T);\n\t\t\n\t\taddRest(\"q\",B);\n\t\taddNotes(\"B3q G4q\",B);\n\t\t\n\t\tmeasure(2);\n\t\t\n\t\taddNotes(\"E5q E5q E5q\",T);\n\t\t\n\t\taddNotes(\"C4h+E4h\",B);\n\t\taddRest(\"q\",B);\n\t\t\n\t\tmeasure(3);\n\t\t\n\t\taddNotes(\"A5q A5i B5i A5i G5i\",T);\n\t\t\n\t\taddRest(\"q\",B);\n\t\taddNotes(\"C#4q A4q\",B);\n\t\t\n\t\tmeasure(4);\n\t\t\n\t\taddNotes(\"F5q D5q D5q\",T);\n\t\t\n\t\taddNotes(\"D4h+F4h\",B);\n\t\taddRest(\"q\",B);\n\t\t\n\t\tmeasure(5);\n\t\t\n\t\taddNotes(\"B5q B5i C6i B5i A5i\",T);\n\t\t\n\t\taddRest(\"q\",B);\n\t\taddNotes(\"G4q D5q\",B);\n\t\t\n\t\tmeasure(6);\n\t\t\n\t\taddNotes(\"G5q E5q D5i D5i\",T);\n\t\t\n\t\taddNotes(\"C5h+E5h\",B);\n\t\taddRest(\"q\",B);\n\t\t\n\t\tmeasure(7);\n\t\t\n\t\taddNotes(\"E5q A5q F5q\",T);\n\t\t\n\t\taddNotes(\"C5h D5q\",B);\n\t\t\n\t\tmeasure(8);\n\t\t\n\t\taddNotes(\"G5h D5q\",T);\n\t\t\n\t\taddNotes(\"G4h+B4h\",B);\n\t\taddRest(\"q\",B);\n\t\t\n\t\tmeasure(9);\n\t\t\n\t\taddNotes(\"G5q G5q G5q\",T);\n\t\t\n\t\taddNote(\"B4h.\",A,B);\n\t\t\n\t\tmeasure(10);\n\t\t\n\t\taddNotes(\"F5h F5q\",T);\n\t\t\n\t\taddNotes(\"A4h A4q\",B);\n\t\t\n\t\tmeasure(11);\n\t\t\n\t\taddNotes(\"G5q F5q E5q\",T);\n\t\t\n\t\taddNotes(\"B4q A4q G4q\",B);\n\t\t\n\t\tmeasure(12);\n\t\t\n\t\taddNotes(\"D5h A5q\",T);\n\t\t\n\t\taddNotes(\"F4h A4q\",B);\n\t\t\n\t\tmeasure(13);\n\t\t\n\t\taddNotes(\"B5q A5q G5q\",T);\n\t\t\n\t\taddNotes(\"B4q A4q G4q\",B);\n\t\t\n\t\tmeasure(14);\n\t\t\n\t\taddNotes(\"D6q D5q D5i D5i\",T);\n\t\t\n\t\taddNotes(\"D5q D4q\",B);\n\t\taddRest(\"q\",B);\n\t\t\n\t\tmeasure(15);\n\t\t\n\t\taddNotes(\"E5q A5q F5q\",T);\n\t\t\n\t\taddNotes(\"C5h D5q\",B);\n\t\t\n\t\tmeasure(16);\n\t\t\n\t\taddNote(\"G5h\",A,T);\n\t\taddRest(\"q\",T);\n\t\t\n\t\taddNotes(\"G4h+B4h\",B);\n\t\taddRest(\"q\",B);\n\t\t\n\t\tmeasure(17);\n\t}", "public ArrayList<String> getMusicName_ () {\n\n /*\n ArrayList<String> musicList = new ArrayList<>();\n Collections.sort(musicName);\n\n for (String item : musicName) {\n musicList.add(item);\n }\n return musicList;\n * */\n\n return musicName;\n\n }", "public String toString() {\n StringBuilder builder = new StringBuilder();\n builder.append(title + \" \");\n builder.append(artist + \" \");\n builder.append(year + \" \");\n builder.append(genre + \" \");\n // majors\n builder.append(\"CS Heard \" + heardPercentCS);\n builder.append(\" CS Like \" + likePercentCS);\n builder.append(\" Math Heard \" + heardPercentMath);\n builder.append(\" Math Like \" + likePercentMath);\n builder.append(\" Eng Heard \" + heardPercentEng);\n builder.append(\" Eng Like \" + likePercentEng);\n builder.append(\" Other Heard \" + heardPercentOther);\n builder.append(\" Other Like \" + likePercentOther);\n // regions\n builder.append(\" SE Heard \" + heardPercentSE);\n builder.append(\" SE Like \" + likePercentSE);\n builder.append(\" NE Heard \" + heardPercentNE);\n builder.append(\" NE Like \" + likePercentNE);\n builder.append(\" US Heard \" + heardPercentUS);\n builder.append(\" US Like \" + likePercentUS);\n builder.append(\" Out Heard \" + heardPercentOut);\n builder.append(\" Out Like \" + likePercentOut);\n // hobbies\n builder.append(\" Music Heard \" + heardPercentMusic);\n builder.append(\" Music Like \" + likePercentMusic);\n builder.append(\" Sports Heard \" + heardPercentSports);\n builder.append(\" Sports Like \" + likePercentSports);\n builder.append(\" Art Heard \" + heardPercentArt);\n builder.append(\" Art Like \" + likePercentArt);\n builder.append(\" Reading Heard \" + heardPercentReading);\n builder.append(\" Reading Like \" + likePercentReading + \"\\n\");\n return builder.toString();\n }", "@Ignore(\"Function written without GUI for JUnit Testing\")\r\n public Song AddSongTest(String SongTitle, String SongArtist, String SongDuration, String SongFile,HashST<String,Song> songs) {\r\n String empty = \"\";\r\n String fileformat = \"([a-zA-Z0-9\\\\s_\\\\\\\\.\\\\-\\\\(\\\\):])+(.avi|.mp4|.mkv|.mov)$\";\r\n\r\n if (SongTitle.equalsIgnoreCase(empty)) {\r\n return null;\r\n } else if (SongArtist.equalsIgnoreCase(empty)) {\r\n return null;\r\n } else if (SongDuration.equalsIgnoreCase(empty)) {\r\n return null;\r\n\r\n } else if ((!intCheck(SongDuration)) || (SongDuration.equalsIgnoreCase(\"0\"))) {\r\n return null;\r\n\r\n } else if (SongFile.equalsIgnoreCase(empty)) {\r\n return null;\r\n } else if (!SongFile.matches(fileformat)) {\r\n return null;\r\n }\r\n\r\n int b = Integer.parseInt(SongDuration);\r\n\r\n if(songs.get(SongTitle.toLowerCase())==null) {\r\n Song addsong = new Song(SongTitle, SongArtist, b, SongFile);\r\n return addsong;\r\n }\r\n else {\r\n return null;\r\n }\r\n\r\n\r\n }" ]
[ "0.7103998", "0.6233354", "0.61736053", "0.6044134", "0.5892713", "0.5826427", "0.58076906", "0.57536757", "0.56933326", "0.5637673", "0.55944914", "0.5587427", "0.5493792", "0.5477519", "0.54618627", "0.54401416", "0.54339993", "0.5389549", "0.5372779", "0.5340179", "0.53107834", "0.5300933", "0.52809346", "0.52731794", "0.5267693", "0.5256267", "0.5254547", "0.5239003", "0.5213878", "0.52132875", "0.5204218", "0.51979494", "0.5171862", "0.51656985", "0.51574814", "0.5157425", "0.515175", "0.5137644", "0.513377", "0.5133231", "0.513115", "0.51146454", "0.5106078", "0.5086003", "0.5072736", "0.5067438", "0.506685", "0.50574136", "0.5055752", "0.5046607", "0.50396365", "0.5038888", "0.50235456", "0.50147176", "0.5008998", "0.5006465", "0.50057316", "0.49908975", "0.49617565", "0.49565735", "0.4954449", "0.49398795", "0.49395767", "0.49329844", "0.49329337", "0.4918151", "0.49152353", "0.491501", "0.4903615", "0.48994943", "0.48936996", "0.48928928", "0.48896775", "0.48804435", "0.48780882", "0.4876734", "0.48754612", "0.48696706", "0.4862939", "0.4860512", "0.4856605", "0.48551285", "0.48371422", "0.48365617", "0.48362884", "0.48359787", "0.48227045", "0.4819723", "0.4808576", "0.48003307", "0.4792428", "0.47852337", "0.47851238", "0.47819236", "0.4759996", "0.47545975", "0.47494447", "0.47491428", "0.47460595", "0.47423753" ]
0.52305627
28
TODO Autogenerated method stub
@Override protected Bitmap doInBackground(String... urls) { try { URL myFileUrl = new URL(urls[0]); HttpURLConnection conn = (HttpURLConnection) myFileUrl.openConnection(); conn.setDoInput(true); conn.connect(); InputStream is = conn.getInputStream(); bmImg = BitmapFactory.decodeStream(is); } catch (IOException e) { e.printStackTrace(); } return bmImg; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Override\r\n\tpublic void comer() \r\n\t{\n\t\t\r\n\t}", "@Override\n\tpublic void comer() {\n\t\t\n\t}", "@Override\n public void perish() {\n \n }", "@Override\r\n\t\t\tpublic void annadir() {\n\r\n\t\t\t}", "@Override\n\tpublic void anular() {\n\n\t}", "@Override\n\tprotected void getExras() {\n\n\t}", "@Override\r\n\tpublic void anularFact() {\n\t\t\r\n\t}", "@Override\n\tpublic void entrenar() {\n\t\t\n\t}", "@Override\n\tpublic void nadar() {\n\t\t\n\t}", "@Override\r\n\tpublic void tires() {\n\t\t\r\n\t}", "@Override\r\n\t\t\tpublic void ayuda() {\n\r\n\t\t\t}", "@Override\n\tprotected void interr() {\n\t}", "@Override\n\tpublic void emprestimo() {\n\n\t}", "@Override\r\n\tpublic void bicar() {\n\t\t\r\n\t}", "@Override\r\n\tpublic void bicar() {\n\t\t\r\n\t}", "@Override\n\tpublic void grabar() {\n\t\t\n\t}", "@Override\n\tpublic void gravarBd() {\n\t\t\n\t}", "@Override\r\n\tpublic void rozmnozovat() {\n\t}", "@Override\r\n\tpublic void dormir() {\n\t\t\r\n\t}", "@Override\n protected void getExras() {\n }", "@Override\r\n\tpublic void publierEnchere() {\n\t\t\r\n\t}", "@Override\n\tpublic void nefesAl() {\n\n\t}", "@Override\n\tpublic void ligar() {\n\t\t\n\t}", "@Override\n public void func_104112_b() {\n \n }", "@Override\n\tprotected void initdata() {\n\n\t}", "@Override\n\tpublic void nghe() {\n\n\t}", "@Override\n public void function()\n {\n }", "@Override\n public void function()\n {\n }", "public final void mo51373a() {\n }", "@Override\r\n\tpublic void stehReagieren() {\r\n\t\t//\r\n\t}", "@Override\n public void inizializza() {\n\n super.inizializza();\n }", "@Override\n\tprotected void initData() {\n\t\t\n\t}", "@Override\r\n\t\tpublic void init() {\n\t\t\t\r\n\t\t}", "@Override\n\tpublic void sacrifier() {\n\t\t\n\t}", "@Override\r\n\tprotected void InitData() {\n\t\t\r\n\t}", "public void designBasement() {\n\t\t\r\n\t}", "@Override\r\n\tprotected void initialize() {\r\n\t\t\r\n\t\t\r\n\t}", "public void gored() {\n\t\t\n\t}", "@Override\r\n\tprotected void initData() {\n\r\n\t}", "@Override\n\tpublic void einkaufen() {\n\t}", "@Override\n protected void initialize() {\n\n \n }", "public void mo38117a() {\n }", "@Override\n\tprotected void getData() {\n\t\t\n\t}", "Constructor() {\r\n\t\t \r\n\t }", "@Override\r\n\tpublic void dibujar() {\n\t\t\r\n\t}", "@Override\r\n\tpublic void dibujar() {\n\t\t\r\n\t}", "@Override\n\tpublic void one() {\n\t\t\n\t}", "@Override\r\n\tprotected void initData() {\n\t\t\r\n\t}", "@Override\r\n\tprotected void initData() {\n\t\t\r\n\t}", "@Override\r\n\tprotected void initData() {\n\t\t\r\n\t}", "@Override\r\n\tprotected void initData() {\n\t\t\r\n\t}", "@Override\r\n\tprotected void initData() {\n\t\t\r\n\t}", "@Override\r\n\tprotected void initData() {\n\t\t\r\n\t}", "private stendhal() {\n\t}", "@Override\n\tprotected void update() {\n\t\t\n\t}", "@Override\n\t\t\tpublic void ic() {\n\t\t\t\t\n\t\t\t}", "@Override\n\tprotected void initData() {\n\n\t}", "@Override\n\tprotected void initData() {\n\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n public void init() {\n\n }", "@Override\n\tprotected void initialize() {\n\t\t\n\t}", "@Override\n\tprotected void initialize() {\n\t\t\n\t}", "@Override\r\n\tpublic void init() {\n\t\t\r\n\t}", "@Override\r\n\tpublic void init() {\n\t\t\r\n\t}", "@Override\r\n\tpublic void init() {\n\t\t\r\n\t}", "@Override\n\tpublic void debite() {\n\t\t\n\t}", "@Override\r\n\tpublic void init() {\n\r\n\t}", "@Override\r\n\tpublic void init() {\n\r\n\t}", "@Override\r\n\tpublic void init() {\n\r\n\t}", "public contrustor(){\r\n\t}", "@Override\n\tprotected void initialize() {\n\n\t}", "@Override\r\n\tpublic void dispase() {\n\r\n\t}", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "@Override\n\tpublic void dtd() {\n\t\t\n\t}", "@Override\n\tprotected void logic() {\n\n\t}", "@Override\n\tprotected void lazyLoad() {\n\t\t\n\t}", "public void mo4359a() {\n }", "@Override\r\n\tprotected void initialize() {\n\r\n\t}", "@Override\n public void memoria() {\n \n }", "@Override\n\t\tpublic void method() {\n\t\t\t\n\t\t}", "private RepositorioAtendimentoPublicoHBM() {\r\t}", "@Override\n protected void initialize() \n {\n \n }", "@Override\r\n\tpublic void getProposition() {\n\r\n\t}", "@Override\n\tpublic void particular1() {\n\t\t\n\t}", "@Override\n\tpublic void init() {\n\n\t}", "@Override\n\tpublic void init() {\n\n\t}", "@Override\n\tpublic void init() {\n\n\t}", "@Override\n protected void prot() {\n }", "@Override\r\n\tpublic void init()\r\n\t{\n\t}", "@Override\n\tprotected void initValue()\n\t{\n\n\t}", "public void mo55254a() {\n }" ]
[ "0.6671074", "0.6567672", "0.6523024", "0.6481211", "0.6477082", "0.64591026", "0.64127725", "0.63762105", "0.6276059", "0.6254286", "0.623686", "0.6223679", "0.6201336", "0.61950207", "0.61950207", "0.61922914", "0.6186996", "0.6173591", "0.61327106", "0.61285484", "0.6080161", "0.6077022", "0.6041561", "0.6024072", "0.6020252", "0.59984857", "0.59672105", "0.59672105", "0.5965777", "0.59485507", "0.5940904", "0.59239364", "0.5910017", "0.5902906", "0.58946234", "0.5886006", "0.58839184", "0.58691067", "0.5857751", "0.58503544", "0.5847024", "0.58239377", "0.5810564", "0.5810089", "0.5806823", "0.5806823", "0.5800025", "0.5792378", "0.5792378", "0.5792378", "0.5792378", "0.5792378", "0.5792378", "0.5790187", "0.5789414", "0.5787092", "0.57844025", "0.57844025", "0.5774479", "0.5774479", "0.5774479", "0.5774479", "0.5774479", "0.5761362", "0.57596046", "0.57596046", "0.575025", "0.575025", "0.575025", "0.5747959", "0.57337177", "0.57337177", "0.57337177", "0.5721452", "0.5715831", "0.57142824", "0.57140535", "0.57140535", "0.57140535", "0.57140535", "0.57140535", "0.57140535", "0.57140535", "0.5711723", "0.57041645", "0.56991017", "0.5696783", "0.56881124", "0.56774884", "0.56734604", "0.56728", "0.56696945", "0.5661323", "0.5657007", "0.5655942", "0.5655942", "0.5655942", "0.56549734", "0.5654792", "0.5652974", "0.5650185" ]
0.0
-1
convert byte data to hex
private static String convertToHex(byte[] data) throws IOException { //create new instance of string buffer StringBuffer stringBuffer = new StringBuffer(); String hex = ""; //encode byte data with base64 hex = Base64.getEncoder().encodeToString(data); stringBuffer.append(hex); //return string return stringBuffer.toString(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private String toHex(byte[] data) {\r\n char[] chars = new char[data.length * 2];\r\n for (int i = 0; i < data.length; i++) {\r\n chars[i * 2] = HEX_DIGITS[(data[i] >> 4) & 0xf];\r\n chars[i * 2 + 1] = HEX_DIGITS[data[i] & 0xf];\r\n }\r\n return new String(chars);\r\n}", "public static String toHex(byte[] data) {\n\t\tStringBuilder builder = new StringBuilder(data.length * 3);\n\t\tfor (byte b : data) {\n\t\t\tint v = b & 0xFF;\n\t\t\t// Get the first then second character\n\t\t\tbuilder.append(HEX_ARRAY[v >>> 4]);\n\t\t\tbuilder.append(HEX_ARRAY[v & 0x0F]);\n\t\t\tbuilder.append(' ');\n\t\t}\n\t\treturn builder.toString().trim();\n\t}", "private static String convertToHex(byte[] data) {\r\n StringBuffer buf = new StringBuffer();\r\n for (int i = 0; i < data.length; i++) {\r\n int halfbyte = (data[i] >>> 4) & 0x0F;\r\n int two_halfs = 0;\r\n do {\r\n if ((0 <= halfbyte) && (halfbyte <= 9)) {\r\n buf.append((char) ('0' + halfbyte));\r\n }\r\n else {\r\n buf.append((char) ('a' + (halfbyte - 10)));\r\n }\r\n halfbyte = data[i] & 0x0F;\r\n } while(two_halfs++ < 1);\r\n }\r\n return buf.toString();\r\n }", "public static String hex(final byte[] data) {\n return hex(data, 0, data.length);\n }", "public static String byteArrayToHexStr(byte[] data)\r\n {\r\n\tString output = new String();\r\n\tString tempStr = new String();\r\n\tint tempInt = 0;\r\n\r\n\tfor(int a = 0; a < data.length; a++)\r\n\t {\r\n\t\ttempInt = data[a]&0xFF;\r\n\t\ttempStr = Integer.toHexString(tempInt);\r\n\r\n\t\tif(tempStr.length() == 1)\r\n\t\t tempStr = \"0\" + tempStr;\r\n\r\n\t\toutput += tempStr;\r\n\t }\r\n\treturn output;\r\n }", "public String byte2hex(byte[] b) {\n String hs = \"\";\n String stmp = \"\";\n for (int n = 0; n < b.length; n++) {\n stmp = (java.lang.Integer.toHexString(b[n] & 0XFF));\n if (stmp.length() == 1) {\n hs = hs + \"0\" + stmp;\n } else {\n hs = hs + stmp;\n }\n\n if (n < b.length - 1) {\n hs = hs + \"\";\n }\n }\n\n return hs;\n }", "public static String binToHexString(byte[] data) {\r\n return binToHexString(data, data.length);\r\n }", "public static String hex(final byte[] data, final int offset, final int length) {\n Validate.notInBounds(data, offset, length);\n if (length == 0) {\n return \"\";\n }\n int endIndex = offset + length;\n char[] buf = new char[length << 1];\n\n int srcIdx = offset;\n int dstIdx = 0;\n for (; srcIdx < endIndex; srcIdx++, dstIdx += 2) {\n System.arraycopy(Hexs.HEXDUMP_TABLE, (data[srcIdx] & 0xFF) << 1, buf, dstIdx, 2);\n }\n return new String(buf);\n }", "public static String prettyHex(final byte[] data) {\n return prettyHex(data, 0, data.length);\n }", "private String hexify(byte bytes[]) {\n\n char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7',\n '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};\n\n StringBuilder buf = new StringBuilder(bytes.length * 2);\n\n for (byte aByte : bytes) {\n buf.append(hexDigits[(aByte & 0xf0) >> 4]);\n buf.append(hexDigits[aByte & 0x0f]);\n }\n\n return buf.toString();\n }", "public static String formatByteAsHex(byte a)\n {\n char guarismos[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};\n int i = signedByte2unsignedInteger(a);\n byte nibbleH = (byte)(i >> 4), nibbleL = (byte)(i & 0x0F);\n\n return \"\" + guarismos[nibbleH] + guarismos[nibbleL];\n }", "private static String toHex(byte[] hash) {\n StringBuilder hashedInput = new StringBuilder(\"\");\n for (int i = 0; i < hash.length; i++) {\n String hex = Integer.toHexString(0xff & hash[i]);\n if (hex.length() == 1) {\n hashedInput.append('0');\n }\n hashedInput.append(hex);\n }\n return hashedInput.toString();\n }", "public static String byteArrayToHexString(byte[] in) {\n\t\tint ch = 0x00;\n\t\tString pseudo[] = {\"0\", \"1\", \"2\",\n\t\t\t\t\"3\", \"4\", \"5\", \"6\", \"7\", \"8\",\n\t\t\t\t\"9\", \"A\", \"B\", \"C\", \"D\", \"E\", \"F\"};\n\n\t\tStringBuffer out = new StringBuffer(in.length*2);\n\t\tfor (int i = 0; i < in.length; i++) {\n\t\t\tch = ((in[i] & 0xF0) >> 4);\n\t\t\tch = (ch & 0x0F);\n\t\t\tout.append(pseudo[ch]);\n\t\t\tch = (in[i] & 0x0F);\n\t\t\tout.append(pseudo[ch]);\n\t\t}\n\t\treturn new String(out);\n\t}", "public static String byte2hex(byte[] b) {\n String hs = \"\";\n String stmp = \"\";\n\n for (int n = 0; n < b.length; n++) {\n stmp = Integer.toHexString(b[n] & 0xFF);\n if (stmp.length() == 1)\n hs += (\"0\" + stmp);\n else\n hs += stmp;\n }\n return hs.toUpperCase();\n }", "private static String hexify(byte bytes[]) {\n\n char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7',\n '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};\n\n StringBuilder buf = new StringBuilder(bytes.length * 2);\n for (byte aByte : bytes) {\n buf.append(hexDigits[(aByte & 0xf0) >> 4]);\n buf.append(hexDigits[aByte & 0x0f]);\n }\n return buf.toString();\n }", "private String convertToHex(byte[] raw) {\n StringBuffer sb = new StringBuffer();\n for (int i = 0; i < raw.length; i++) {\n sb.append(Integer.toString((raw[i] & 0xff) + 0x100, 16).substring(1));\n }\n return sb.toString();\n }", "public static String asHex(byte[] buf) {\n \t char[] HEX_CHARS = \"0123456789abcdef\".toCharArray();\n \t char[] chars = new char[2 * buf.length];\n \t for (int i = 0; i < buf.length; ++i) {\n \t chars[2 * i] = HEX_CHARS[(buf[i] & 0xF0) >>> 4];\n \t chars[2 * i + 1] = HEX_CHARS[buf[i] & 0x0F];\n \t }\n \t return new String(chars);\n \t}", "private static String byteToHex(byte b) {\n\t\tchar hexDigit[] = {\n\t\t\t\t'0', '1', '2', '3', '4', '5', '6', '7',\n\t\t\t\t'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'\n\t\t};\n\t\tchar[] array = {hexDigit[(b >> 4) & 0x0f], hexDigit[b & 0x0f]};\n\t\treturn new String(array);\n\t}", "public static String bytetohex(byte[] byteArray) {\n\t\tStringBuilder sb = new StringBuilder();\n\t\tfor (int i = 0; i < byteArray.length; i++) {\n\t\t\tsb.append(String.format(\"%02x\", 0xFF & (int) byteArray[i]));\n\t\t}\n\t\treturn sb.toString().toLowerCase();\n\t}", "public String toHex(String arg) throws UnsupportedEncodingException {\n\t return String.format(\"%064x\", new BigInteger(1, arg.getBytes(\"UTF8\")));\n\t}", "public static String toHex(byte[] b) {\r\n\tStringBuffer buf;\r\n\tint i;\r\n\r\n\tbuf = new StringBuffer(b.length * 2);\r\n\r\n\tfor (i = 0; i < b.length; i++) {\r\n\t buf.append(HEX.charAt((b[i] >> 4) & 15));\r\n\t buf.append(HEX.charAt(b[i] & 15));\r\n\t}\r\n\treturn buf.toString();\r\n }", "static public String byteToHex(byte b) {\n\t\tchar hexDigit[] = {\n\t\t\t\t'0', '1', '2', '3', '4', '5', '6', '7',\n\t\t\t\t'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'\n\t\t};\n\t\tchar[] array = { hexDigit[(b >> 4) & 0x0f], hexDigit[b & 0x0f] };\n\t\treturn new String(array);\n\t}", "static public String byteToHex(byte b) {\n\t\tchar hexDigit[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A',\n\t\t\t\t'B', 'C', 'D', 'E', 'F' };\n\t\tchar[] array = { hexDigit[(b >> 4) & 0x0f], hexDigit[b & 0x0f] };\n\t\treturn new String(array);\n\t}", "private String ByteArrayToHexString(byte [] inarray) {\n int i, j, in;\n String [] hex = {\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"};\n String out= \"\";\n\n for(j = 0 ; j < inarray.length ; ++j)\n {\n in = (int) inarray[j] & 0xff;\n i = (in >> 4) & 0x0f;\n out += hex[i];\n i = in & 0x0f;\n out += hex[i];\n }\n return out;\n }", "public static void byte2hex(byte b, StringBuffer buf) {\n char[] hexChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8',\n '9', 'A', 'B', 'C', 'D', 'E', 'F' };\n int high = ((b & 0xf0) >> 4);\n int low = (b & 0x0f);\n buf.append(hexChars[high]);\n buf.append(hexChars[low]);\n }", "public static String byteArrayToHexString(byte[] a) \r\n{\r\n\tStringBuilder sb = new StringBuilder(a.length * 2);\r\n\tfor(byte b: a)\r\n\tsb.append(String.format(\"%02x\", b));\r\n\treturn sb.toString();\r\n}", "public static String toHexString(BigInteger data) {\n StringBuilder sb = new StringBuilder();\n sb.append(\"0x\").append(data.toString(16));\n return sb.toString();\n }", "private String makeHex(byte[] buffer) {\n byte current;\n int length = buffer.length;\n String blank = \"\"; // it's easier to change\n StringBuffer ret = new StringBuffer(2*length);\n\n // do for each half byte\n for(int i=0;i<(2*length);i++)\n {\n\t// mask half byte and move it to the right\n\tcurrent = i%2==1 ? (byte) (buffer[(i/2)] & 0x0F)\n\t : (byte) ((buffer[(i/2)] >> 4) & 0x0F);\n\t\n\t// convert half byte to ASCII char\t\t \n\tret.append((char) (current < 0x0A ? current+0x30 : current+0x37) + (i%2==1 ? blank : \"\"));\n }\n return ret.toString();\n }", "public static String bytetohex(byte[] bytearray) {\n\t\tStringBuffer sb = new StringBuffer();\n\t\tfor (byte b : bytearray) {\n\t\t\tString x = Integer.toHexString((int) (b & 0xFF));\n\t\t\tif (x.length() == 1) {\n\t\t\t\tsb.append(String.valueOf(0));\n\t\t\t}\n\t\t\tsb.append(x);\n\t\t}\n\t\tif (sb.length() % 2 != 0) {\n\t\t\tsb.insert(0, 0);\n\t\t}\n\t\treturn sb.toString();\n\t}", "private static String toHex(byte buffer[]) {\n\t\tStringBuffer sb = new StringBuffer(buffer.length * 2);\n\t\tfor (int i = 0; i < buffer.length; i++) {\n\t\t\tsb.append(Character.forDigit((buffer[i] & 0xf0) >> 4, 16));\n\t\t\tsb.append(Character.forDigit(buffer[i] & 0x0f, 16));\n\t\t}\n\t\treturn sb.toString();\n\t}", "private String toHex(byte[] bytes) {\n StringBuilder s = new StringBuilder(bytes.length * 2);\n for (byte b : bytes) {\n s.append(String.format(\"%02x\", b));\n }\n return s.toString();\n }", "public static String bytesToHex(byte[] txtInByte) {\n\t\t StringBuilder sb = new StringBuilder(txtInByte.length * 2);\n\t\t for(byte b: txtInByte)\n\t\t sb.append(String.format(\"%02x\", b & 0xff));\n\t\t return sb.toString();\n\t\t}", "public String toHexString()\n\t{\n\t\t// holds the string builder object to return\n\t\tStringBuilder sb = new StringBuilder();\n\t\t\n\t\t// for every byte\n\t\tfor (int i = 0; i < bytes.length; i++)\n\t\t{\n\t\t\tint intCurrent = bytes[i] & 0xFF;\n\t\t\t\n\t\t\t// check to see if a leading 0 is needed\n\t\t\tif (intCurrent < 0x10)\n\t\t\t{\n\t\t\t\t// append a 0\n\t\t\t\tsb.append(0);\n\t\t\t}\n\t\t\t\n\t\t\tString s = Integer.toHexString(intCurrent).toUpperCase();\n\t\t\t\n\t\t\t// append the character\n\t\t\tsb.append(s);\n\t\t}\n\t\t\n\t\t// return the string\n\t\treturn sb.toString();\n\t}", "public static String toHex(byte[] bytes){\r\n\t\treturn hexEncode(bytes);\r\n\t}", "public static final String toHex(byte hash[]) {\r\n StringBuffer buf = new StringBuffer(hash.length * 2);\r\n int i;\r\n\r\n for (i = 0; i < hash.length; i++) {\r\n if (((int) hash[i] & 0xff) < 0x10) {\r\n buf.append(\"0\");\r\n }\r\n buf.append(Long.toString((int) hash[i] & 0xff, 16));\r\n }\r\n return buf.toString();\r\n }", "private static String byteToHexString(final byte hash) {\n\t\tint n = hash;\n\t\tif (n < 0) {\n\t\t\tn = 256 + n;\n\t\t}\n\t\tint d1 = n / 16;\n\t\tint d2 = n % 16;\n\t\treturn FileHashingUtils.hexDigits[d1] + FileHashingUtils.hexDigits[d2];\n\t}", "private String toHex(byte[] array)\n {\n BigInteger bi = new BigInteger(1, array);\n String hex = bi.toString(16);\n int paddingLength = (array.length * 2) - hex.length();\n if(paddingLength > 0) \n return String.format(\"%0\" + paddingLength + \"d\", 0) + hex;\n else\n return hex;\n }", "public static String bytesToHex(byte[] in) {\n final StringBuilder builder = new StringBuilder();\n for (byte b : in) {\n builder.append(String.format(\"%02x\", b));\n }\n return builder.toString();\n }", "protected static String convertHex( String base )\r\n\t{\r\n\t\treturn \"H\" + HexConvertor.convertHex( base.getBytes() ); \r\n\t}", "public static String byteToHex(final byte[] hash) {\n if (Objects.isNull(hash)) {\n return null;\n }\n\n Formatter formatter = new Formatter();\n for (byte b : hash) {\n formatter.format(\"%02x\", b);\n }\n String result = formatter.toString();\n formatter.close();\n return result;\n }", "public static String toHex(byte[] bytes)\n {\n\n if (bytes == null)\n {\n return null;\n }\n\n StringBuilder builder = new StringBuilder();\n for (int i = 0; i < bytes.length; i++)\n {\n int value = (int) bytes[i];\n\n builder.append(HEX_CHARS.charAt((value >> 4) & 0x0F));\n builder.append(HEX_CHARS.charAt(value & 0x0F));\n }\n\n return builder.toString();\n }", "private static String byteArrayToHexString(byte[] byteArray) {\n\t\t\n\t\t//Initialize the string buffer\n\t\tStringBuffer stringBuffer = new StringBuffer(byteArray.length * 2);\n\t\t\n\t\t//Start constructing the byte array\n\t\tstringBuffer.append(\"[ \");\n\t\t\n\t\t//For all the bytes in the array\n\t\tfor (int i = 0; i < byteArray.length; i++) {\n\t\t\t\n\t\t\t//Convert the byte to an integer\n\t\t\tint v = byteArray[i] & 0xff;\n\t\t\t\n\t\t\t//Left shift\n\t\t\tif (v < 16) {\n\t\t\t\tstringBuffer.append('0');\n\t\t\t}\n\t\t\t\n\t\t\t//Add the hex string representation of the byte \n\t\t\tstringBuffer.append(\"0x\" + Integer.toHexString(v).toUpperCase() + \" \");\n\t\t}\n\t\t\n\t\t//Close the byte array string\n\t\tstringBuffer.append(\"]\");\n\t\t\n\t\t//Convert the string buffer to a string a return it\n\t\treturn stringBuffer.toString();\n\t}", "private static String toHex(byte[] array)\n\t {\n\t BigInteger bi = new BigInteger(1, array);\n\t String hex = bi.toString(16);\n\t int paddingLength = (array.length * 2) - hex.length();\n\t if(paddingLength > 0)\n\t return String.format(\"%0\" + paddingLength + \"d\", 0) + hex;\n\t else\n\t return hex;\n\t }", "public static String formatHexBytes(byte[] raw) {\n StringBuffer buffer;\n final char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };\n int i;\n int value;\n buffer = new StringBuffer(raw.length * 2);\n for (i = 0; i < raw.length; i++) {\n value = raw[i];\n buffer.append(hexDigits[(value >> 4) & 0x0F]);\n buffer.append(hexDigits[value & 0x0F]);\n }\n return (buffer.toString());\n }", "private String toHexString(byte[] bytes) {\n StringBuilder hexString = new StringBuilder();\n for (int i = 0; i < bytes.length; i++) {\n String hex = Integer.toHexString(0xFF & bytes[i]);\n if (hex.length() == 1) {\n hexString.append('0');\n }\n hexString.append(hex);\n }\n\n return hexString.toString().toUpperCase();\n }", "@NotNull\n public static String convertBytesToHex(@NotNull byte[] value) {\n checkNotNull(value);\n int len = value.length;\n char[] buff = new char[len + len];\n char[] hex = HEX;\n for (int i = 0; i < len; i++) {\n int c = value[i] & 0xff;\n buff[i + i] = hex[c >> 4];\n buff[i + i + 1] = hex[c & 0xf];\n }\n return new String(buff);\n }", "public String encodeHex(String hexa) {\n if (!hexa.matches(\"^[0-9a-fA-F]+$\")) {\n return \"\";\n }\n\n final List<Long> matched = new ArrayList<Long>();\n final Matcher matcher = WORD_PATTERN.matcher(hexa);\n\n while (matcher.find()) {\n matched.add(Long.parseLong('1' + matcher.group(), 16));\n }\n\n // conversion\n final long[] result = new long[matched.size()];\n for (int i = 0; i < matched.size(); i++) {\n result[i] = matched.get(i);\n }\n\n return this.encode(result);\n }", "public static String byteArrayToHex(byte[] a) {\n StringBuilder sb = new StringBuilder(a.length * 2);\n for(byte b: a)\n sb.append(String.format(\"%02x\", b & 0xff));\n return sb.toString();\n }", "public static String bytesToHex(byte[] array) {\n StringBuffer hexString = new StringBuffer();\n for (int i = 0; i < array.length; i++) {\n String hex = Integer.toHexString(0xff & array[i]);\n if(hex.length() == 1) hexString.append('0');\n hexString.append(hex);\n }\n return hexString.toString();\n }", "private static String bytesToHex(byte[] bytes) {\n StringBuilder result = new StringBuilder();\n\n for (byte byt : bytes) {\n result.append(Integer.toString((byt & 0xff) + 0x100, 16).substring(1));\n }\n\n return result.toString();\n }", "public static String bytetohex(byte[] bytearray) {\n\t\tStringBuilder build = new StringBuilder();\n\t\tfor (var bte : bytearray) {\n\t\t\tbuild.append(nibbleToChar((byte) ((bte & 240) >>> 4)));\n\t\t\tbuild.append(nibbleToChar((byte) (bte & 15)));\n\t\t}\n\t\treturn build.toString();\n\t}", "private static String _bytesToHex( ByteBuffer buf )\n {\n final int offset = buf.position();\n final int size = buf.remaining();\n final char[] hexChars = new char[size * 2];\n\n for (int j = 0; j < size; j++) {\n int v = buf.get(j + offset) & 0xFF;\n hexChars[j * 2] = hexArray[v >>> 4];\n hexChars[j * 2 + 1] = hexArray[v & 0x0F];\n }\n\n return new String(hexChars);\n }", "protected byte[] binaryToHex(byte[] digest) throws UnsupportedEncodingException {\n StringBuffer digestString = new StringBuffer();\n for (int i = 0; i < digest.length; i++) {\n if ((digest[i] & 0x000000ff) < 0x10) {\n digestString.append(\"0\" + Integer.toHexString(digest[i] & 0x000000ff));\n } else {\n digestString.append(Integer.toHexString(digest[i] & 0x000000ff));\n }\n }\n return digestString.toString().getBytes(encoding);\n }", "private static int transformHexCharToInt(byte val) throws HyracksDataException {\n switch (val) {\n case '0':\n return 0;\n case '1':\n return 1;\n case '2':\n return 2;\n case '3':\n return 3;\n case '4':\n return 4;\n case '5':\n return 5;\n case '6':\n return 6;\n case '7':\n return 7;\n case '8':\n return 8;\n case '9':\n return 9;\n case 'a':\n case 'A':\n return 10;\n case 'b':\n case 'B':\n return 11;\n case 'c':\n case 'C':\n return 12;\n case 'd':\n case 'D':\n return 13;\n case 'e':\n case 'E':\n return 14;\n case 'f':\n case 'F':\n return 15;\n default:\n throw new RuntimeDataException(ErrorCode.INVALID_FORMAT);\n }\n }", "public static final String toHexString(byte b) {\n return Integer.toString((b & 0xff) + 0x100, 16).substring(1);\n }", "public static String unHex(String arg) { \r\n\t String str = \"\";\r\n\t for(int i=0;i<arg.length();i+=2)\r\n\t {\r\n\t String s = arg.substring(i, (i + 2));\r\n\t int decimal = Integer.parseInt(s, 16);\r\n\t str = str + (char) decimal;\r\n\t } \r\n\t return str;\r\n\t}", "private static String toHex(final byte[] array) {\n final BigInteger bi = new BigInteger(1, array);\n final String hex = bi.toString(16);\n final int paddingLength = (array.length * 2) - hex.length();\n if (paddingLength > 0) {\n return String.format(\"%0\" + paddingLength + \"d\", 0) + hex;\n } else {\n return hex;\n }\n }", "private void toHex(){\n\t\tStringBuilder sb = new StringBuilder();\n\t\tStringBuilder tempsb = new StringBuilder(binary);\n\t\t\n\t\t\tfor (int i = 0;i<binary.length();i+=4){//maps each nibble to its binary value\n\t\t\t\tif (tempsb.substring(i,i+4).equals(\"0000\")) \n\t\t\t\t\tsb.append('0');\n\t\t\t\telse if (tempsb.substring(i,i+4).equals(\"0001\"))\n\t\t\t\t\tsb.append('1');\n\t\t\t\telse if (tempsb.substring(i,i+4).equals(\"0010\"))\n\t\t\t\t\tsb.append('2');\n\t\t\t\telse if (tempsb.substring(i,i+4).equals(\"0011\"))\n\t\t\t\t\tsb.append('3');\n\t\t\t\telse if (tempsb.substring(i,i+4).equals(\"0100\"))\n\t\t\t\t\tsb.append('4');\n\t\t\t\telse if (tempsb.substring(i,i+4).equals(\"0101\"))\n\t\t\t\t\tsb.append('5');\n\t\t\t\telse if (tempsb.substring(i,i+4).equals(\"0110\"))\n\t\t\t\t\tsb.append('6');\n\t\t\t\telse if (tempsb.substring(i,i+4).equals(\"0111\"))\n\t\t\t\t\tsb.append('7');\n\t\t\t\telse if (tempsb.substring(i,i+4).equals(\"1000\"))\n\t\t\t\t\tsb.append('8');\n\t\t\t\telse if (tempsb.substring(i,i+4).equals(\"1001\"))\n\t\t\t\t\tsb.append('9');\n\t\t\t\telse if (tempsb.substring(i,i+4).equals(\"1010\"))\n\t\t\t\t\tsb.append('A');\n\t\t\t\telse if (tempsb.substring(i,i+4).equals(\"1011\"))\n\t\t\t\t\tsb.append('B');\n\t\t\t\telse if (tempsb.substring(i,i+4).equals(\"1100\"))\n\t\t\t\t\tsb.append('C');\n\t\t\t\telse if (tempsb.substring(i,i+4).equals(\"1101\"))\n\t\t\t\t\tsb.append('D');\n\t\t\t\telse if (tempsb.substring(i,i+4).equals(\"1110\"))\n\t\t\t\t\tsb.append('E');\n\t\t\t\telse if (tempsb.substring(i,i+4).equals(\"1111\"))\n\t\t\t\t\tsb.append('F');\n\t\t\t}\n\t\t\tsb.insert(0,\"0x\");\n\t\t\tbinary = sb.toString();\n\t}", "public static String prettyHex(final byte value) {\n return prettyHex(new byte[] {value});\n }", "private static String pasarAHexadecimal(byte[] digest){\n String hash = \"\";\n for(byte aux : digest) {\n int b = aux & 0xff;\n if (Integer.toHexString(b).length() == 1) hash += \"0\";\n hash += Integer.toHexString(b);\n }\n return hash;\n }", "private static String toHex(byte[] array) throws NoSuchAlgorithmException {\n\n BigInteger bi = new BigInteger(1, array);\n String hex = bi.toString(16);\n int paddingLength = (array.length * 2) - hex.length();\n if (paddingLength > 0) {\n return String.format(\"%0\" + paddingLength + \"d\", 0) + hex;\n } else {\n return hex;\n }\n }", "private static String byteArrayToHexString(byte[] b) {\n StringBuffer sb = new StringBuffer(b.length * 2);\n for (byte element : b) {\n int v = element & 0xff;\n if(v < 16) {\n sb.append('0');\n }\n sb.append(Integer.toHexString(v));\n }\n return sb.toString().toUpperCase();\n }", "private static String toHex(byte[] array) {\r\n\t\tBigInteger bi = new BigInteger(1, array);\r\n\t\tString hex = bi.toString(16);\r\n\t\tint paddingLength = (array.length * 2) - hex.length();\r\n\t\tif (paddingLength > 0)\r\n\t\t\treturn String.format(\"%0\" + paddingLength + \"d\", 0) + hex;\r\n\t\telse\r\n\t\t\treturn hex;\r\n\t}", "private static String getHex(byte[] raw) {\n if (raw == null) {\n return null;\n }\n final StringBuilder hex = new StringBuilder(2 * raw.length);\n for (final byte b : raw) {\n hex.append(HEXES.charAt((b & 0xF0) >> 4)).append(\n HEXES.charAt((b & 0x0F)));\n }\n return hex.toString();\n }", "private static String hexDigit(byte x) {\n StringBuffer sb = new StringBuffer();\n char c;\n c = (char) ((x >> 4) & 0xf);\n if (c > 9) {\n c = (char) ((c - 10) + 'a');\n } else {\n c = (char) (c + '0');\n }\n sb.append(c);\n c = (char) (x & 0xf);\n if (c > 9) {\n c = (char) ((c - 10) + 'a');\n } else {\n c = (char) (c + '0');\n }\n sb.append(c);\n return sb.toString();\n }", "public static String toHexString(byte[] byteArray) {\n final StringBuilder hexString = new StringBuilder(\"\");\n if (byteArray == null || byteArray.length <= 0)\n return null;\n for (int i = 0; i < byteArray.length; i++) {\n int v = byteArray[i] & 0xFF;\n String hv = Integer.toHexString(v);\n if (hv.length() < 2) {\n hexString.append(0);\n }\n hexString.append(hv);\n }\n return hexString.toString().toLowerCase();\n }", "private static String toHex(byte[] array) {\r\n BigInteger bi = new BigInteger(1, array);\r\n String hex = bi.toString(16);\r\n int paddingLength = (array.length * 2) - hex.length();\r\n if (paddingLength > 0) {\r\n return String.format(\"%0\" + paddingLength + \"d\", 0) + hex;\r\n } else {\r\n return hex;\r\n }\r\n }", "public static String toHexadecimal(final byte[] bytes) {\n\t\treturn new String(toHexadecimalChars(bytes));\n\t}", "private static String byteToHexString(byte b) {\n int n = b;\n if (n < 0) {\n n += 256;\n }\n int d1 = n >> 4;\n int d2 = n % 16;\n return hexDigits[d1] + hexDigits[d2];\n }", "public String binToHex(String input) {\r\n int decimal = Integer.parseInt(input,2);\t\r\n\t\treturn Integer.toString(decimal,16);\t\r\n\t}", "private static char toHex(int nibble)\n\t{\n\t\treturn hexDigit[(nibble & 0xF)];\n\t}", "public static String bytesToHex(byte[] raw) {\n if (raw == null) {\n return null;\n }\n final StringBuilder hex = new StringBuilder(2 * raw.length);\n for (final byte b : raw) {\n hex.append(Character.forDigit((b & 0xF0) >> 4, 16))\n .append(Character.forDigit((b & 0x0F), 16));\n }\n return hex.toString();\n }", "public static String prettyHex(final byte[] data, final int offset, final int length) {\n Validate.notInBounds(data, offset, length);\n StringBuilder result = new StringBuilder();\n StringBuilder builder = new StringBuilder();\n int pos = offset;\n int max = length;\n int lineNumber = 0;\n builder.append(Hexs.HEXDUMP_PRETTY_HEADER);\n while (pos < max) {\n builder.append(String.format(\"%08d | \", lineNumber++));\n int lineMax = Math.min(max - pos, 16);\n for (int i = 0; i < lineMax; i++) {\n int index = (data[pos + i] & 0xFF) << 1;\n builder.append(\n new String(new char[] {Hexs.HEXDUMP_TABLE[index], Hexs.HEXDUMP_TABLE[++index]}));\n builder.append(\" \");\n }\n builder.append(\"| \");\n for (int i = 0; i < lineMax; i++) {\n char c = (char) data[pos + i];\n if (c < 32 || c > 127) {\n c = '.';\n }\n builder.append(c);\n }\n builder.append(\"\\n\");\n result.append(builder);\n builder.setLength(0);\n pos += 16;\n }\n result.append(Hexs.HEXDUMP_PRETTY_FOOTER);\n return result.toString();\n }", "private static char toHex(int nibble) {\n\t\treturn hexDigit[(nibble & 0xF)];\n\t}", "public static String convertToHex(byte[] otp) {\n return ByteIterator.ofBytes(otp).hexEncode().drainToString();\n }", "private static String bytesToHex(byte[] bytes) {\n char[] hexChars = new char[bytes.length * 2];\n for (int j = 0; j < bytes.length; j++) {\n int v = bytes[j] & 0xFF;\n hexChars[j * 2] = hexArray[v >>> 4];\n hexChars[j * 2 + 1] = hexArray[v & 0x0F];\n }\n return new String(hexChars);\n }", "public static String toHex(byte[] array) {\n BigInteger bi = new BigInteger(1, array);\n String hex = bi.toString(16);\n int paddingLength = (array.length * 2) - hex.length();\n if (paddingLength > 0)\n return String.format(\"%0\" + paddingLength + \"d\", 0) + hex;\n else\n return hex;\n }", "static String hexEncode(byte[] b, int off, int len, int max) {\n char[] r;\n int v;\n int i;\n int j;\n \n if ((b == null) || (len == 0)) {\n return \"\";\n }\n\n if ((off < 0) || (len < 0)) {\n throw new ArrayIndexOutOfBoundsException();\n }\n\n r = new char[len * 3];\n\n for (i = 0, j = 0; ; ) {\n v = b[off + i] & 0xff;\n r[j++] = hc[v >>> 4];\n r[j++] = hc[v & 0x0f];\n\n i++;\n if (i >= len) {\n break;\n }\n\n if (i == max) {\n r[j++] = ' ';\n r[j++] = '+';\n break;\n }\n \n r[j++] = ':';\n }\n\n return (new String(r, 0, j));\n }", "public static String byteToHex(byte b) {\n return new String(new char[] {HEX_CHARS[(b & 0xFF) >>> 4], HEX_CHARS[b & 0xF]});\n }", "public static char[] toHexadecimalChars(final byte[] bytes) {\n\t\tfinal char[] chars = new char[bytes.length * 2];\n\t\tfor (int i = 0, j = 0; i < bytes.length; i++, j += 2) {\n\t\t\tfinal int v = bytes[i] & 0xFF;\n\t\t\tchars[j] = toHexChar(v >>> 4);\n\t\t\tchars[j + 1] = toHexChar(v & 0x0F);\n\t\t}\n\t\treturn chars;\n\t}", "public void binToHex(){\n\t\tthis.inputBin();\n\t\tif(checkValue()==true){\n\t\t\tthis.toHex();\n\t\t\tthis.outHex();\n\t\t}\n\t}", "private static String toHex(byte[] digest) {\n\t\tchar[] result = new char[digest.length * 2];\n\t\tint pos = 0;\n\t\tfor (int i = 0; i < digest.length; i++) {\n\t\t\tresult[pos++] = hexChar((digest[i] & 0xf0) >> 4);\n\t\t\tresult[pos++] = hexChar(digest[i] & 0x0f);\n\t\t}\n\t\treturn new String(result);\n\t}", "private static String binToHex(String bin) {\n\t\tString hex = \"\";\n\t\twhile (bin.length() % 4 != 0) { // comprueba si la cadena tiene longitud multiplo de 4\n\t\t\tbin = \"0\" + bin; // si no, le aņado un cero y vuelvo a comprobar si es multiplo de 4\n\t\t}\n\t\t// este while va cogiendo cachitos de 4, los pasa a hexadecimal y acumula en la variable hex\n\t\twhile (bin.length() != 0) { // el while continua hasta que la cadena tenga longitud cero\n\t\t\tString four = bin.substring(bin.length()-4); // cojo los 4 ultimos\n\t\t\thex = byteToHex(four) + hex; // paso 4 bits a hexadecimal y acumulo en hex\n\t\t\tbin = bin.substring(0, bin.length() - 4); // al string original le quito los cuatro bits que ya he procesado\n\t\t}\n\t\treturn hex; // cuando ha terminado el while, en hex tengo el hexadecimal completo\n\t\t\n\t}", "private static String convertStringToHex(String input){\n\t\tchar[] chars = input.toCharArray();\n\t\tStringBuffer hexOutput = new StringBuffer();\n\t\t\n\t\tfor(int i = 0; i < chars.length; i++){\n\t\t\thexOutput.append(Integer.toHexString((int)chars[i]));\n\t\t}\n\n\t\treturn hexOutput.toString();\n\t}", "public static String toHexString(byte b) {\n return Integer.toHexString(toInt(b));\n }", "private int[] charToHexa(char c){\n int[] hex = new int[2];\n String h = Integer.toHexString((int) c);\n if (h.length() == 1){\n h = \"0\" + h;\n }\n hex[0] = Integer.parseInt(h.substring(0,1), 16);\n hex[1] = Integer.parseInt(h.substring(1), 16);\n return hex;\n }", "private static String bytesToHex(byte[] bytes) {\n final char[] hexArray = {'0', '1', '2', '3', '4', '5', '6', '7', '8',\n '9', 'A', 'B', 'C', 'D', 'E', 'F'};\n char[] hexChars = new char[bytes.length * 2];\n int v;\n for (int j = 0; j < bytes.length; j++) {\n v = bytes[j] & 0xFF;\n hexChars[j * 2] = hexArray[v >>> 4];\n hexChars[j * 2 + 1] = hexArray[v & 0x0F];\n }\n return new String(hexChars);\n }", "private static char toHexDigit(int h) {\n char out;\n if (h <= 9) out = (char) (h + 0x30);\n else out = (char) (h + 0x37);\n //System.err.println(h + \": \" + out);\n return out;\n }", "public static String toHex(byte[] array) {\n\t\tBigInteger bi = new BigInteger(1, array);\n\t\tString hex = bi.toString(16);\n\t\tint paddingLength = (array.length * 2) - hex.length();\n\t\tif (paddingLength > 0) {\n\t\t\tString format = \"%0\" + paddingLength + \"d\";\n\t\t\treturn String.format(format, 0) + hex;\n\t\t} else {\n\t\t\treturn hex;\n\t\t}\n\t}", "public static String byteArrayToHexString(byte[] value) {\r\n String ret = \"\";\r\n\r\n for (int i = value.length - 1; i >= 0; i--) {\r\n ret = ret.concat(Integer.toHexString((value[i] & 0xFF) | 0x100).substring(1, 3));\r\n }\r\n\r\n return ret;\r\n }", "public static String bytesToHex(byte[] bytes) {\n StringBuffer result = new StringBuffer();\n for (byte byt : bytes) {\n result.append(Integer.toString((byt & 0xff) + 0x100, 16).substring(1));\n }\n return result.toString();\n }", "public static final String toHexString(byte[] b) {\n return toHexString(b, 0, b.length);\n }", "public static byte[] convert(String hex) {\n/* 51 */ ByteArrayOutputStream baos = new ByteArrayOutputStream();\n/* 52 */ for (int i = 0; i < hex.length(); i += 2) {\n/* 53 */ char c1 = hex.charAt(i);\n/* 54 */ if (i + 1 >= hex.length())\n/* 55 */ throw new IllegalArgumentException(); \n/* 56 */ char c2 = hex.charAt(i + 1);\n/* 57 */ byte b = 0;\n/* 58 */ if (c1 >= '0' && c1 <= '9') {\n/* 59 */ b = (byte)(b + (c1 - 48) * 16);\n/* 60 */ } else if (c1 >= 'a' && c1 <= 'f') {\n/* 61 */ b = (byte)(b + (c1 - 97 + 10) * 16);\n/* 62 */ } else if (c1 >= 'A' && c1 <= 'F') {\n/* 63 */ b = (byte)(b + (c1 - 65 + 10) * 16);\n/* */ } else {\n/* 65 */ throw new IllegalArgumentException();\n/* 66 */ } if (c2 >= '0' && c2 <= '9') {\n/* 67 */ b = (byte)(b + c2 - 48);\n/* 68 */ } else if (c2 >= 'a' && c2 <= 'f') {\n/* 69 */ b = (byte)(b + c2 - 97 + 10);\n/* 70 */ } else if (c2 >= 'A' && c2 <= 'F') {\n/* 71 */ b = (byte)(b + c2 - 65 + 10);\n/* */ } else {\n/* 73 */ throw new IllegalArgumentException();\n/* 74 */ } baos.write(b);\n/* */ } \n/* 76 */ return baos.toByteArray();\n/* */ }", "public static String toHexString(byte[] b) {\r\n\t\tStringBuffer sb = new StringBuffer();\r\n\t\tfor (int i = 0; i < b.length; i++) {\r\n\t\t\tsb.append(hexCharsLowerCase[ (int)(((int)b[i] >> 4) & 0x0f)]);\r\n\t\t\tsb.append(hexCharsLowerCase[ (int)(((int)b[i]) & 0x0f)]);\r\n\t\t}\r\n\t return sb.toString(); \r\n\t}", "static private String hexEncode(byte[] bytes) {\n StringBuffer result = new StringBuffer();\n for (int i = 0; i < bytes.length; i++) {\n byte b = bytes[i];\n result.append(DIGITS[(b & 0xf0) >> 4]);\n result.append(DIGITS[b & 0x0f]);\n }\n return result.toString();\n }", "public static String toHexString(byte[] array) {\n StringBuilder sb = new StringBuilder();\n sb.append(\"0x\").append(DatatypeConverter.printHexBinary(array));\n return sb.toString();\n }", "public static String convert(byte[] bytes) {\n/* 34 */ StringBuffer sb = new StringBuffer(bytes.length * 2);\n/* 35 */ for (int i = 0; i < bytes.length; i++) {\n/* 36 */ sb.append(hexs[bytes[i] >> 4 & 0xF]);\n/* 37 */ sb.append(hexs[bytes[i] & 0xF]);\n/* */ } \n/* 39 */ return sb.toString();\n/* */ }", "public static String\n bytesToHexString(byte[] bytes) {\n if (bytes == null) return null;\n\n StringBuilder ret = new StringBuilder(2*bytes.length);\n\n for (int i = 0 ; i < bytes.length ; i++) {\n int b;\n\n b = 0x0f & (bytes[i] >> 4);\n\n ret.append(HEX_CHARS[b]);\n\n b = 0x0f & bytes[i];\n\n ret.append(HEX_CHARS[b]);\n }\n\n return ret.toString();\n }", "public static String encodeSHA256(byte[] data) {\n byte[] digest = MD_SHA_256.digest(data);\n return new HexBinaryAdapter().marshal(digest);\n }", "static public String byteArrayToHexString(byte[] bytes) {\n\t\tStringBuilder sb = new StringBuilder(bytes.length * 2);\n\t\tfor (byte element : bytes) {\n\t\t\tint v = element & 0xff;\n\t\t\tif (v < 16) {\n\t\t\t\tsb.append('0');\n\t\t\t}\n\t\t\tsb.append(Integer.toHexString(v));\n\t\t}\n\t\treturn sb.toString().toUpperCase(Locale.US);\n\t}" ]
[ "0.79837507", "0.74001664", "0.7385993", "0.7251069", "0.6853335", "0.68521243", "0.67275864", "0.67014176", "0.66965014", "0.6615888", "0.66095275", "0.65633523", "0.6543037", "0.6542609", "0.6524662", "0.65196043", "0.6469207", "0.64544135", "0.64267224", "0.64196694", "0.64179885", "0.64079136", "0.6394609", "0.6388327", "0.63452905", "0.6315023", "0.6311208", "0.63094926", "0.6303614", "0.6280087", "0.6267996", "0.6221044", "0.6214087", "0.6183735", "0.61773056", "0.6173732", "0.6162779", "0.6139748", "0.6110598", "0.6094102", "0.60895884", "0.60875916", "0.608586", "0.60801816", "0.60614944", "0.6051398", "0.60436755", "0.6043316", "0.60226506", "0.60213697", "0.5995974", "0.5988555", "0.59881717", "0.59835964", "0.5983157", "0.5965066", "0.5960907", "0.5948664", "0.59407663", "0.59383863", "0.59293586", "0.592765", "0.5927461", "0.59229916", "0.5900168", "0.5897909", "0.5894645", "0.58944196", "0.58926535", "0.5885476", "0.58834225", "0.58708227", "0.5870618", "0.58658683", "0.58602124", "0.58561885", "0.58511007", "0.58505636", "0.5834001", "0.58325547", "0.58221656", "0.5816021", "0.5812276", "0.5802963", "0.57944536", "0.57853556", "0.57723117", "0.57689744", "0.5749807", "0.57406545", "0.5735625", "0.57312745", "0.5716695", "0.5710518", "0.5706776", "0.5705126", "0.56966865", "0.5691043", "0.5687801", "0.5685714" ]
0.73729026
3
generates SHA512 Hash for passwords
public static String computePasswordSHAHash(String password) { MessageDigest mdSha1 = null; String SHAHash = ""; try { mdSha1 = MessageDigest.getInstance("SHA-512"); } catch (NoSuchAlgorithmException e1) { e1.printStackTrace(); } try { mdSha1.update(password.getBytes("ASCII")); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } byte[] data = mdSha1.digest(); try { SHAHash = convertToHex(data); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return SHAHash; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public String generateHash(String password) {\n MessageDigest md = null;\n byte[] hash = null;\n try {\n md = MessageDigest.getInstance(\"SHA-512\");\n hash = md.digest(password.getBytes(\"UTF-8\"));\n } catch (NoSuchAlgorithmException e) {\n e.printStackTrace();\n } catch (UnsupportedEncodingException e) {\n e.printStackTrace();\n }\n return convertToHex(hash);\n }", "private String hash(){\r\n return Utility.SHA512(this.simplify());\r\n }", "public void hashPassword() throws NoSuchAlgorithmException{\n try {\n byte[] newSalt = (salt == null) ? new byte[128] : salt;\n\n if(salt == null){\n new Random().nextBytes(newSalt);\n }\n\n MessageDigest md = MessageDigest.getInstance(\"SHA-512\");\n md.update(newSalt);\n byte[] passwordBytes = md.digest(password.getBytes(StandardCharsets.UTF_8));\n StringBuilder sb = new StringBuilder();\n\n for(int i=0; i< passwordBytes.length ;i++){\n sb.append(Integer.toString((passwordBytes[i] & 0xff) + 0x100, 16).substring(1));\n }\n\n this.password = sb.toString();\n setSalt(newSalt);\n }\n catch (NoSuchAlgorithmException e){\n e.printStackTrace();\n }\n }", "public static String getSha512(String saltedPassword) {\n\t\tsha512MessageDigest.get().update(saltedPassword.getBytes());\n\t\treturn toHex(sha512MessageDigest.get().digest());\n\t}", "public static String getHash(String password, String salt) throws NoSuchAlgorithmException {\n MessageDigest md = MessageDigest.getInstance(\"SHA-512\");\n\n String topSecret = salt + password + salt;\n\n byte[] bytes = md.digest(topSecret.getBytes());\n\n return getHex(bytes);\n }", "String generateHashFromPassword(String password, byte[] salt);", "public static MessageDigest getSha512MessageDigestInstance() {\n try {\n return MessageDigest.getInstance(\"SHA-512\");\n } catch (NoSuchAlgorithmException e) {\n throw new IllegalStateException(\"SHA-512 is not supported\");\n }\n }", "private String sha512(String message) throws java.security.NoSuchAlgorithmException\n\t{\n\t\tMessageDigest sha512 = null;\n\t\ttry {\n\t\t\tsha512 = MessageDigest.getInstance(\"SHA-512\");\n\t\t}\n\t\tcatch (java.security.NoSuchAlgorithmException ex) {\n\t\t\tex.printStackTrace();\n\t\t\tthrow ex;\n\t\t}\n\t\tbyte[] dig = sha512.digest((byte[]) message.getBytes());\n\t\tStringBuffer code = new StringBuffer();\n\t\tfor (int i = 0; i < dig.length; ++i)\n\t\t{\n\t\t\tcode.append(Integer.toHexString(0x0100 + (dig[i] & 0x00FF)).substring(1));\n\t\t}\n\t\treturn code.toString();\n\t}", "protected String hashPassword(String passwordToHash, String salt) {\n\t\tString hash = null;\n\t try {\n\t MessageDigest md = MessageDigest.getInstance(\"SHA-512\");\n\t md.update(salt.getBytes(\"UTF-8\"));\n\t byte[] bytes = md.digest(passwordToHash.getBytes(\"UTF-8\"));\n\t StringBuilder sb = new StringBuilder();\n\t for (int i = 0; i < bytes.length ; ++i){\n\t sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));\n\t }\n\t hash = sb.toString();\n\t } \n\t catch (NoSuchAlgorithmException e){\n\t e.printStackTrace();\n\t } catch (UnsupportedEncodingException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t return hash;\n\t}", "public static byte[] encryptSHA512(final byte[] data) {\n return hashTemplate(data, \"SHA-512\");\n }", "String getUserPasswordHash();", "public static String getPasswordHash(String username, String password) {\n\t\t// Setup the password encoding arguments\n\t\tfinal String salt = \"09234j234kj!@#213lk$#$)(*)DFSDFL##$\";\n\t\tfinal String passwordAndSalt = username + password + salt;\n\n\t\t// Encode the password with base64 and salt\n\t\tString encodedPassword = null;\n\t\ttry {\n\n\t\t\t// Choose SHA-512\n\t\t\tMessageDigest md = MessageDigest.getInstance(\"SHA-512\");\n\n\t\t\t// Prepare the digest\n\t\t\tmd.update(passwordAndSalt.getBytes(\"UTF-8\"));\n\n\t\t\t// Retrieve the encoded password string\n\t\t\tencodedPassword = new String(Hex.encodeHex(md.digest()));\n\t\t} catch (Exception e) {\n\t\t\tLog.e(\"LoginHistory\", e.getMessage());\n\t\t}\n\n\t\treturn encodedPassword;\n\t}", "public String hashSale(String pwd){\n char[] password = pwd.toCharArray();\n byte[] sel = SALT.getBytes();\n //String Hex = Hex.encodeHexString(res);\n\n try{\n SecretKeyFactory skf = SecretKeyFactory.getInstance(\"PBKDF2WithHmacSHA512\");\n PBEKeySpec spec = new PBEKeySpec(password, sel, 3567, 512);\n SecretKey key = skf.generateSecret(spec);\n byte[] res = key.getEncoded();\n return res.toString();\n } catch (NoSuchAlgorithmException e) {\n e.printStackTrace();\n throw new RuntimeException(e);\n } catch (InvalidKeySpecException e) {\n e.printStackTrace();\n throw new RuntimeException(e);\n }\n }", "private String getOldPasswordHash(String password) {\n\t\tWhirlpool hasher = new Whirlpool();\n hasher.NESSIEinit();\n\n // add the plaintext password to it\n hasher.NESSIEadd(password);\n\n // create an array to hold the hashed bytes\n byte[] hashed = new byte[64];\n\n // run the hash\n hasher.NESSIEfinalize(hashed);\n\n // this stuff basically turns the byte array into a hexstring\n java.math.BigInteger bi = new java.math.BigInteger(hashed);\n String hashedStr = bi.toString(16); // 120ff0\n if (hashedStr.length() % 2 != 0) {\n // Pad with 0\n hashedStr = \"0\"+hashedStr;\n }\n return hashedStr;\n\t}", "protected static String hashGenerator(String userName, String senderId, String content, String secureKey) {\n\t\tStringBuffer finalString=new StringBuffer();\n\t\tfinalString.append(userName.trim()).append(senderId.trim()).append(content.trim()).append(secureKey.trim());\n\t\t//\t\tlogger.info(\"Parameters for SHA-512 : \"+finalString);\n\t\tString hashGen=finalString.toString();\n\t\tStringBuffer sb = null;\n\t\tMessageDigest md;\n\t\ttry {\n\t\t\tmd = MessageDigest.getInstance(\"SHA-512\");\n\t\t\tmd.update(hashGen.getBytes());\n\t\t\tbyte byteData[] = md.digest();\n\t\t\t//convert the byte to hex format method 1\n\t\t\tsb = new StringBuffer();\n\t\t\tfor (int i = 0; i < byteData.length; i++) {\n\t\t\t\tsb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));\n\t\t\t}\n\n\t\t} catch (NoSuchAlgorithmException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn sb.toString();\n\t}", "String hashPassword(String password);", "private void setPassword(String password) throws NoSuchAlgorithmException\n {\n MessageDigest hash = MessageDigest\n .getInstance(\"SHA-512\");\n\n hash.update(password.getBytes());\n passwordHash = Base64.getEncoder().encodeToString(hash.digest());\n }", "String hashPassword(String salt, String password);", "@Override\r\n\tpublic String hashFunction(String saltedPass) throws NoSuchAlgorithmException\r\n\t{\r\n\t\tMessageDigest digest = MessageDigest.getInstance(\"SHA-256\");\r\n\t\tbyte[] byteHash = digest.digest(saltedPass.getBytes(StandardCharsets.UTF_8));\r\n\t\thash = DatatypeConverter.printBase64Binary(byteHash);\r\n\t\treturn hash;\r\n\t}", "public static String hashPassword(String password) {\n byte salt[] = DeriveKey.getRandomByte(Crypt.KEY_BITS);\n\n // generate Hash\n PBEKeySpec spec = new PBEKeySpec(password.toCharArray(), salt, PASSWORD_ITERATIONS, PASSWORD_BITS);\n // we would like this to be \"PBKDF2WithHmacSHA512\" instead? which version of Android\n // Provider implements it?\n SecretKeyFactory skf;\n try {\n skf = SecretKeyFactory.getInstance(\"PBKDF2WithHmacSHA1\");\n } catch (NoSuchAlgorithmException e) {\n e.printStackTrace();\n throw new RuntimeException(\"impossible\", e);\n }\n byte[] hash;\n try {\n hash = skf.generateSecret(spec).getEncoded();\n } catch (InvalidKeySpecException e) {\n e.printStackTrace();\n throw new RuntimeException(\"wrong key\", e);\n }\n return Crypt.toBase64(salt) + Crypt.CHAR_NOT_BASE64 + Crypt.toBase64(hash);\n }", "public static String encryptSHA512ToString(final byte[] data) {\n return bytes2HexString(encryptSHA512(data));\n }", "int getPasswordHashLength();", "public static String Sha512(String str) {\n if (StringUtils.isBlank(str)) {\n return null;\n }\n\n String sha = null;\n try {\n MessageDigest crypt = MessageDigest.getInstance(\"SHA-512\");\n crypt.reset();\n crypt.update(str.getBytes(StandardCharsets.UTF_8));\n sha = byteToHex(crypt.digest());\n } catch (NullPointerException e) {\n LOGGER.error(\"Error in get SHA-512: encoded string is null!\", e);\n } catch (NoSuchAlgorithmException e) {\n LOGGER.error(MessageFormat.format(\"Error in get SHA-512 from [{0}]\", str), e);\n }\n\n return StringUtils.upperCase(sha);\n }", "public static byte[] SaltHashPwd(String username, String password) throws Exception\n\t{\n\t\tbyte[] user;\n\t\tbyte[] salt = new byte[16];\n\t\t\n\t\tbyte[] passwordHash;\n\t\tbyte[] fixedLengthPasswordHash = new byte[30];\n\t\t\n\t\t//assign value to all the parameters\n\t\tByteBuffer userBytes = ByteBuffer.allocate(100);\n\t\tuserBytes.put(username.getBytes());\n\t\tuser = userBytes.array();\n\t\trd.nextBytes(salt);\n\t\n\t\t\n\t\t\n\t\tAes aes = new Aes(Utility.pwdEncryptKey);\n\t\tbyte[] saltedPwd = Utility.concat2byte(salt, password.getBytes());\t\t\n\t\tpasswordHash = aes.hmac.getmac(saltedPwd);\n\t\tfixedLengthPasswordHash = Arrays.copyOf(passwordHash, fixedLengthPasswordHash.length);\n\t\t\n//\t\tSystem.out.println(\"truncate hashpassword= \" +fixedLengthPasswordHash+ \", length= \"+ fixedLengthPasswordHash.length);\n\t\t\n\t\tbyte[] entryByte = Utility.concat3byte(user, salt, fixedLengthPasswordHash);\n\t\t\t\n\t\n//\t\tSystem.out.println(\"Before encrypt length: \"+entryByte.length);\n\t\t//System.out.println(\"Before encrypt: \"+ Utility.ByteToString(entryByte));\n\t\treturn entryByte;\n\t\t//return aes.encrypt(entryByte);\n\t\t\n\t}", "public HASH512 getHash2(){return hash2;}", "protected String hashBuffer(Buffer buffer) {\n\t\treturn FileUtils.generateSha512Sum(buffer);\n\t}", "protected static String hashPassword(String password)\n throws NoSuchAlgorithmException {\n MessageDigest md = MessageDigest.getInstance(\"SHA-256\");\n md.reset();\n md.update(password.getBytes());\n byte[] mdArray = md.digest();\n StringBuilder sb = new StringBuilder(mdArray.length *2);\n for(byte b: mdArray) {\n int v = b & 0xff;\n if(v < 16) {\n sb.append('0');\n }\n sb.append(Integer.toHexString(v));\n }\n return sb.toString();\n }", "public static String hashPassword(String password) {\n\n MessageDigest md;\n StringBuffer sb = new StringBuffer();\n String hexString = null;\n try {\n md = MessageDigest.getInstance(\"MD5\");\n\n md.update(password.getBytes());\n byte[] digest = md.digest();\n\n for (byte b : digest) {\n sb.append(String.format(\"%02x\", b & 0xff));\n }\n } catch (NoSuchAlgorithmException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n\n Logger.debug(\"Hash For Password - \" + sb.toString());\n return sb.toString();\n }", "public String hashPassword(String plainTextPassword);", "private String getPasswordHash(String user, String password) {\n\t\tString salt = \"M0z3ah4SKieNwBboZ94URhIdDbgTNT\";\n\t\tString user_lowercase = user.toLowerCase();\n\t\t\n\t\t// mix the user with the salt to create a unique salt\n\t\tString uniqueSalt = \"\";\n\t\tfor (int i = 0; i < user_lowercase.length(); i++) {\n\t\t\tuniqueSalt = uniqueSalt + user_lowercase.substring(i, i+1) + salt.substring(i, i+1);\n\t\t\t// last iteration, add remaining salt to the end\n\t\t\tif (i == user_lowercase.length() - 1)\n\t\t\t\tuniqueSalt = uniqueSalt + salt.substring(i+1);\n\t\t}\n\t\t\n\t\tWhirlpool hasher = new Whirlpool();\n\t\thasher.NESSIEinit();\n\t\t\n\t\t//add plaintext password with salt to hasher\n\t\thasher.NESSIEadd(password + uniqueSalt);\n\t\t\n\t\t// create array to hold the hashed bytes\n\t\tbyte[] hashed = new byte[64];\n\t\t\n\t\t// run the hash\n\t\thasher.NESSIEfinalize(hashed);\n\t\t\n\t\t// turn the byte array into a hexstring\n char[] val = new char[2*hashed.length];\n String hex = \"0123456789ABCDEF\";\n for (int i = 0; i < hashed.length; i++) {\n int b = hashed[i] & 0xff;\n val[2*i] = hex.charAt(b >>> 4);\n val[2*i + 1] = hex.charAt(b & 15);\n }\n return String.valueOf(val);\n\t}", "public static String hash(String password){\r\n\t\t try {\r\n\t MessageDigest md = MessageDigest.getInstance(\"SHA-256\");\r\n\t md.update(password.getBytes(\"UTF-8\")); \r\n\t byte[] digest = md.digest();\r\n\t \r\n\t BigInteger bigInt = new BigInteger(1, digest);\r\n\t StringBuffer sb = new StringBuffer();\r\n\t for (int i = 0; i < digest.length; i++) {\r\n\t String hex = Integer.toHexString(0xff & digest[i]);\r\n\t if (hex.length() == 1) sb.append('0');\r\n\t sb.append(hex);\r\n\t }\r\n\t System.out.println(sb.toString());\r\n\t return sb.toString();\r\n\t \r\n\t } catch (Exception ex) {\r\n\t System.out.println(ex.getMessage());\r\n\t \r\n\t }\r\n\t\t return null;\r\n\t}", "public static String getHashed_pw(String password) {\r\n\t\tbyte[] plainText = password.getBytes();\r\n MessageDigest md = null;\r\n try {\r\n md = MessageDigest.getInstance(\"MD5\");\r\n } \r\n catch (Exception e) {\r\n System.err.println(e.toString());\r\n }\r\n \tmd.reset();\r\n\t\tmd.update(plainText);\r\n\t\tbyte[] encodedPassword = md.digest();\r\n\r\n\t\tStringBuilder sb = new StringBuilder();\r\n\t\tfor (int i = 0; i < encodedPassword.length; i++) {\r\n\t\t\tif ((encodedPassword[i] & 0xff) < 0x10) {\r\n\t\t\t\tsb.append(\"0\");\r\n\t\t\t}\r\n\t\t\tsb.append(Long.toString(encodedPassword[i] & 0xff, 16));\r\n\t\t}\r\n\t\treturn sb.toString();\r\n\t}", "public String hashfunction(String password)\r\n\t{\r\n\t\t\r\n\t\tMessageDigest md=null;\r\n\t\ttry {\r\n\t\t\tmd = MessageDigest.getInstance(\"SHA-1\");\r\n\t\t} catch (NoSuchAlgorithmException e) {\r\n\t\t\te.printStackTrace();\r\n\t\t}\r\n\t\tmd.update(password.getBytes());\r\n\t\tbyte[] hash=md.digest();\r\n\t\tchar[] hexArray = \"0123456789ABCDEF\".toCharArray();\r\n\t\tchar[] hexChars = new char[hash.length * 2];\r\n\t for ( int j = 0; j < hash.length; j++ ) \r\n\t {\r\n\t int v = hash[j] & 0xFF;\r\n\t hexChars[j * 2] = hexArray[v >>> 4];\r\n\t hexChars[j * 2 + 1] = hexArray[v & 0x0F];\r\n\t }\r\n\t String hash_password=new String(hexChars);\r\n\t hash_password=hash_password.toLowerCase();\r\n\t return hash_password;\r\n\t}", "String getSaltedHash();", "public static String encryptSHA512ToString(final String data) {\n if (data == null || data.length() == 0) return \"\";\n return encryptSHA512ToString(data.getBytes());\n }", "private static String hash(String password, byte[] salt) throws Exception {\n if (password == null || password.length() == 0) {\n throw new IllegalArgumentException(\"Empty passwords are not supported.\");\n }\n SecretKeyFactory f = SecretKeyFactory.getInstance(\"PBKDF2WithHmacSHA1\");\n SecretKey key = f.generateSecret(new PBEKeySpec(password.toCharArray(), salt, iterations, desiredKeyLen)\n );\n return Base64.encodeToString(key.getEncoded(), Base64.NO_WRAP);\n }", "private String hashPassword(String password) {\n \t\tif (StringUtils.isNotBlank(password)) {\n \t\t\treturn new ShaPasswordEncoder().encodePassword(password, null);\n \t\t}\n \t\treturn null;\n \t}", "public static String getHash(String password) {\n String hashedPassword = null;\n try {\n MessageDigest md = MessageDigest.getInstance(\"SHA-256\");\n byte[] digest = md.digest(password.getBytes());\n hashedPassword = org.apache.commons.codec.binary.Base64.encodeBase64String(digest);\n } catch (NoSuchAlgorithmException e) {\n e.printStackTrace();\n }\n\n return hashedPassword;\n }", "private static String hash(String password, byte[] salt) throws Exception {\n if (password == null || password.length() == 0)\n throw new IllegalArgumentException(\"Empty passwords are not supported.\");\n SecretKeyFactory f = SecretKeyFactory.getInstance(\"PBKDF2WithHmacSHA1\");\n SecretKey key = f.generateSecret(new PBEKeySpec(\n password.toCharArray(), salt, iterations, desiredKeyLen));\n return Base64.encodeBase64String(key.getEncoded());\n }", "private String hashPass(String password, String salt)\r\n {\r\n String oldpass = (password + salt);\r\n String hashedPass = null;\r\n StringBuilder sb = new StringBuilder();\r\n\r\n try\r\n {\r\n MessageDigest md = MessageDigest.getInstance(\"SHA-256\");\r\n md.update(oldpass.getBytes(\"UTF-8\"));\r\n\r\n byte[] hash = md.digest();\r\n\r\n for (int i = 0; i < hash.length; i++)\r\n {\r\n sb.append(Integer.toString((hash[i] & 0xff) + 0x100, 16).substring(1));\r\n }\r\n\r\n hashedPass = sb.toString();\r\n }\r\n catch (NoSuchAlgorithmException | UnsupportedEncodingException ex)\r\n {\r\n Logger.getLogger(AuthModel.class.getName()).log(Level.SEVERE, null, ex);\r\n }\r\n\r\n return hashedPass;\r\n }", "public static String hash_password(String password) throws Exception\r\n\t{\r\n\t\t// Digest the password with MD5 algorithm\r\n\t\tMessageDigest md = MessageDigest.getInstance(\"MD5\");\r\n\t\tmd.update(password.getBytes());\r\n\t\t \r\n\t\tbyte byte_data[] = md.digest();\r\n\t\t \r\n\t\t//convert the bytes to hex format \r\n\t\tStringBuffer sb = new StringBuffer();\r\n\t\t \r\n\t\tfor (int i = 0; i < byte_data.length; i++) \r\n\t\t{\r\n\t\t\tsb.append(Integer.toString((byte_data[i] & 0xff) + 0x100, 16).substring(1));\r\n\t\t}\r\n\t\t \r\n\t\t//System.out.println(\"Hashed password: \" + sb.toString());\r\n\t\treturn sb.toString();\r\n\t}", "public String getHash(String password) {\n return DigestUtils.sha256Hex(password);\n }", "private static String CalHash(byte[] passSalt) throws NoSuchAlgorithmException, UnsupportedEncodingException {\n //get the instance value corresponding to Algorithm selected\n MessageDigest key = MessageDigest.getInstance(\"SHA-256\");\n //Reference:https://stackoverflow.com/questions/415953/how-can-i-generate-an-md5-hash\n //update the digest using specified array of bytes\n key.update(passSalt);\n String PassSaltHash = javax.xml.bind.DatatypeConverter.printHexBinary(key.digest());\n return PassSaltHash;\n }", "private String hashPassword(String toHash) {\r\n PasswordEncoder passwordEncoder = new Sha256PasswordEncoder(salt);\r\n return passwordEncoder.encode(toHash);\r\n }", "public static String encryptHmacSHA512ToString(final byte[] data, final byte[] key) {\n return bytes2HexString(encryptHmacSHA512(data, key));\n }", "public static String generatePass(){\r\n \r\n String password = new Random().ints(10, 33, 122).collect(StringBuilder::new,\r\n StringBuilder::appendCodePoint, StringBuilder::append)\r\n .toString();\r\n return password;\r\n\r\n }", "public byte[] makeDigest(String user, String pwd) throws NoSuchAlgorithmException {\n MessageDigest md = MessageDigest.getInstance(\"SHA\");\n md.update(user.getBytes());\n md.update(pwd.getBytes());\n return md.digest();\n }", "private String encrypt_password(String password)\r\n\t{\r\n\t\tString generated_password = null;\r\n try\r\n {\r\n\r\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\r\n md.update(password.getBytes());\r\n byte[] bytes = md.digest();\r\n StringBuilder sb = new StringBuilder();\r\n for(int i=0; i< bytes.length ;i++)\r\n {\r\n sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));\r\n }\r\n generated_password=sb.toString();\r\n }\r\n catch (NoSuchAlgorithmException e)\r\n {\r\n \r\n }\r\n return generated_password;\r\n\t}", "public static String generatSecurePassword(String emailId, String password) {\n\t\treturn getSha512(emailId + \"#\" + getmd5(emailId + \"#\" + password));\n\t}", "public static String hashPassword(String input) {\n\t\tStringBuilder hash = new StringBuilder();\n\n\t\ttry {\n\t\t\tMessageDigest sha = MessageDigest.getInstance(\"SHA-1\");\n\t\t\tbyte[] hashedBytes = sha.digest(input.getBytes());\n\t\t\tchar[] digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',\n\t\t\t\t\t'a', 'b', 'c', 'd', 'e', 'f' };\n\t\t\tfor (int idx = 0; idx < hashedBytes.length;idx++) {\n\t\t\t\tbyte b = hashedBytes[idx];\n\t\t\t\thash.append(digits[(b & 0xf0) >> 4]);\n\t\t\t\thash.append(digits[b & 0x0f]);\n\t\t\t}\n\t\t} catch (NoSuchAlgorithmException e) {\n\t\t\t// handle error here.\n\t\t}\n\n\t\treturn hash.toString();\n\n\t\t\n\t}", "public static byte[] encryptHmacSHA512(final byte[] data, final byte[] key) {\n return hmacTemplate(data, key, \"HmacSHA512\");\n }", "private byte[] generateNewHash() { \n\t\t// Build the final hash to be compared with the one on the database.\n\t\tbyte[] firstHash = getGeneratedHash();\n\t\tbyte[] randomSalt = getRandomSalt();\n\t\tbyte[] finalHash = new byte[TOTAL_LENGTH];\n\n\t\t// initial index where the salt will start\n\t\tint j = getSaltStartIndex(); \n\n\t\tfor( int i = 0; i < TOTAL_LENGTH; i++ ) {\n\t\t\t// First index for the salt is not yet here\n\t\t\tif ( j > i ) finalHash[i] = firstHash[i];\n\t\t\telse {\n\t\t\t\tif ( (i - j) < SALT_LENGTH ) finalHash[i] = randomSalt[i-j];\n\t\t\t\telse finalHash[i] = firstHash[i-SALT_LENGTH];\n\t\t\t}\n\t\t}\n\t\treturn finalHash;\n\t}", "public String createHash(char[] password)\n throws NoSuchAlgorithmException, InvalidKeySpecException\n {\n // Generate a random salt\n SecureRandom random = new SecureRandom();\n byte[] salt = new byte[SALT_BYTES];\n random.nextBytes(salt);\n\n // Hash the password\n byte[] hash = pbkdf2(password, salt, PBKDF2_ITERATIONS, HASH_BYTES);\n // format iterations:salt:hash\n return toHex(salt) + \":\" + toHex(hash);\n }", "private static byte[] hashPassword(String password, byte[] salt) throws Exception\n {\n byte[] hash = null;\n \n try {\n MessageDigest md = MessageDigest.getInstance(\"SHA-256\");\n md.update(salt);\n hash = md.digest(password.getBytes(\"UTF-8\"));\n }\n catch (NoSuchAlgorithmException e)\n {\n e.printStackTrace();\n }\n return hash;\n }", "public static String getPassHash(String password, String salt) {\n String algorithm = \"PBKDF2WithHmacSHA1\";\n int derivedKeyLength = 160; // for SHA1\n int iterations = 20000; // NIST specifies 10000\n\n byte[] saltBytes = Base64.getDecoder().decode(salt);\n KeySpec spec = new PBEKeySpec(password.toCharArray(), saltBytes, iterations, derivedKeyLength);\n\n SecretKeyFactory f = null;\n try {\n f = SecretKeyFactory.getInstance(algorithm);\n } catch (NoSuchAlgorithmException e) {\n e.printStackTrace();\n }\n\n byte[] encBytes = null;\n try {\n encBytes = f.generateSecret(spec).getEncoded();\n } catch (InvalidKeySpecException e) {\n e.printStackTrace();\n }\n return Base64.getEncoder().encodeToString(encBytes);\n }", "private static String hashPassword(String password) throws NoSuchAlgorithmException, InvalidKeySpecException {\n\n char[] passwordChar = password.toCharArray();\n byte[] salt = getSalt();\n PBEKeySpec spec = new PBEKeySpec(passwordChar, salt, 1000, 64 * 8);\n SecretKeyFactory skf = SecretKeyFactory.getInstance(\"PBKDF2WithHmacSHA1\");\n byte[] hash = skf.generateSecret(spec).getEncoded();\n return toHex(salt) + \":\" + toHex(hash);\n }", "public String hashing(String password) {\n\n\t\tString hashedPassword = null;\n\n\t\tMessageDigest md;\n\t\ttry {\n\t\t\tmd = MessageDigest.getInstance(\"MD5\");\n\t\t\tmd.update(password.getBytes());\n\t\t\tbyte[] digest = md.digest();\n\t\t\tStringBuffer sb = new StringBuffer();\n\t\t\tfor (byte b : digest) {\n\t\t\t\tsb.append(String.format(\"%02x\", b & 0xff));\n\t\t\t}\n\t\t\thashedPassword = sb.toString();\n\t\t} catch (NoSuchAlgorithmException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\n\t\treturn hashedPassword;\n\t}", "public static String hashPassword(String password){\n String salt = BCrypt.gensalt(12);\n String hashed_password = BCrypt.hashpw(password,salt);\n return hashed_password;\n }", "public String convertirSHA256(String password) {\r\n MessageDigest md;\r\n try {\r\n md = MessageDigest.getInstance(\"SHA-256\");\r\n } catch (NoSuchAlgorithmException e) {\r\n Logger.getLogger(Contador.class.getName()).log(Level.SEVERE, null, e);\r\n return null;\r\n }\r\n\r\n byte[] hash = md.digest(password.getBytes());\r\n StringBuilder sb = new StringBuilder();\r\n\r\n for (byte b : hash) {\r\n sb.append(String.format(\"%02x\", b));\r\n }\r\n\r\n return sb.toString();\r\n }", "static String hash(String motDePasse) {\n\t\tString encoded = null;\n\t\ttry {\n\t MessageDigest md = MessageDigest.getInstance(\"SHA-256\");\n\t byte[] hashInBytes = md.digest(motDePasse.getBytes(StandardCharsets.UTF_8));\n\n\t\t\t// bytes to hex\n\t StringBuilder sb = new StringBuilder();\n\t for (byte b : hashInBytes) {\n\t sb.append(String.format(\"%02x\", b));\n\t }\n\t encoded = sb.toString();\n\t\t} catch (NoSuchAlgorithmException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn encoded;\n\n\t\t\n\t}", "private static String HashIt(String token) {\n\t\tStringBuffer hexString = new StringBuffer();\n\t\ttry {\n\t\t\tMessageDigest digest = MessageDigest.getInstance(\"SHA-256\");\n\t\t\tbyte[] hash = digest.digest(token.getBytes(StandardCharsets.UTF_8));\n\t\t\t\n\t\t\t// Convert to hex\n\t\t for (int i = 0; i < hash.length; i++) {\n\t\t\t String hex = Integer.toHexString(0xff & hash[i]);\n\t\t\t if(hex.length() == 1) {\n\t\t\t \thexString.append('0');\n\t\t\t }\n\t\t\t hexString.append(hex);\n\t\t }\n\t\t} catch (NoSuchAlgorithmException e) {\n\t\t\tSystem.err.println(e.getStackTrace());\n\t\t\thexString.setLength(0);\n\t\t}\n\t return hexString.toString();\t\t\n\t}", "public String generatePassword(Node node);", "public static String hashPass(String value) throws NoSuchAlgorithmException\n\t{\n\t\t//There are many algos are available for hashing i)MD5(message digest) ii)SHA(Secured hash algo)\n\t\tMessageDigest md=MessageDigest.getInstance(\"MD5\");\n\t md.update(value.getBytes());\n\t \n\t byte[] hashedpass=md.digest();\n\t StringBuilder hashpass=new StringBuilder();\n\t for(byte b:hashedpass)\n\t {\n\t \t//Convert to hexadecimal format\n\t hashpass.append(String.format(\"%02x\",b));\n\t }\n\t return hashpass.toString();\n\t}", "public static String encodePassword(String password) {\r\n\t\t\r\n\t\tbyte[] uniqueKey = password.getBytes();\r\n\t\tbyte[] hash = null;\r\n\t\ttry {\r\n\t\t\thash = MessageDigest.getInstance(\"MD5\").digest(uniqueKey);\r\n\t\t} catch (NoSuchAlgorithmException e) {\r\n\t\t\te.printStackTrace();\r\n\t\t}\r\n\t\tStringBuffer hashString = new StringBuffer();\r\n\t\tfor ( int i = 0; i < hash.length; ++i ) {\r\n\t\t\tString hex = Integer.toHexString(hash[i]);\r\n\t\t\tif ( hex.length() == 1 ) {\r\n\t\t\t hashString.append('0');\r\n\t\t\t hashString.append(hex.charAt(hex.length()-1));\r\n\t\t\t} else {\r\n\t\t\t hashString.append(hex.substring(hex.length()-2));\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\treturn hashString.toString();\r\n\t}", "@Override\r\n public String getMD4HashedPassword(String userName) {\r\n final SambaSamAccount sam = getSambaSamAccount(userName);\r\n if (sam == null) {\r\n logger.error(\"SambaSamAccount was null for user \" + userName + \", please set it up in LDAP directory.\");\r\n return null;\r\n } else {\r\n return sam.getSambaNtPassword();\r\n }\r\n }", "public byte[] getHash(String password) {\n MessageDigest digest = null;\n try {\n digest = MessageDigest.getInstance(\"SHA-256\");\n } catch (NoSuchAlgorithmException e1) {\n e1.printStackTrace();\n }\n digest.reset();\n return digest.digest(password.getBytes());\n }", "public static String hashPassword( String hashMe ) {\n final byte[] unhashedBytes = hashMe.getBytes();\n try {\n final MessageDigest algorithm = MessageDigest.getInstance( \"MD5\" );\n algorithm.reset();\n algorithm.update( unhashedBytes );\n final byte[] hashedBytes = algorithm.digest();\n \n final StringBuffer hexString = new StringBuffer();\n for ( final byte element : hashedBytes ) {\n final String hex = Integer.toHexString( 0xFF & element );\n if ( hex.length() == 1 ) {\n hexString.append( 0 );\n }\n hexString.append( hex );\n }\n return hexString.toString();\n } catch ( final NoSuchAlgorithmException e ) {\n e.printStackTrace();\n return null;\n }\n }", "private String generatePass(int passwdLength, int minDigits, List<Boolean> options)\n {\n PasswordGenerator pg = new PasswordGenerator(passwdLength, minDigits, options);\n\n return pg.generatePasswd();\n }", "public static String hashPassword(char[] password) {\n if(config.experimental.useBCryptLibrary)\n return HasherBCrypt.hash(password);\n else\n return HasherArgon2.hash(password);\n }", "public static String hashPassword(String userPassword, String salt) {\n String result = null;\n try {\n MessageDigest md = MessageDigest.getInstance(\"SHA-256\");\n md.update((userPassword + salt).getBytes());\n byte[] bytesResult = md.digest();\n result = String.format(\"%064x\", new BigInteger(1, bytesResult));\n } catch (NoSuchAlgorithmException ex) {\n\n }\n return result;\n }", "public static String hashPassword(String password) {\n String passwordHash = null;\n try {\n // Calculate hash on the given password.\n MessageDigest sha256 = MessageDigest.getInstance(\"SHA-256\");\n byte[] hash = sha256.digest(password.getBytes());\n\n // Transform the bytes (8 bit signed) into a hexadecimal format.\n StringBuilder hashString = new StringBuilder();\n for (int i = 0; i < hash.length; i++) {\n /*\n Format parameters: %[flags][width][conversion]\n Flag '0' - The result will be zero padded.\n Width '2' - The width is 2 as 1 byte is represented by two hex characters.\n Conversion 'x' - Result is formatted as hexadecimal integer, uppercase.\n */\n hashString.append(String.format(\"%02x\", hash[i]));\n }\n passwordHash = hashString.toString();\n Log.d(TAG, \"Password hashed to \" + passwordHash);\n } catch (NoSuchAlgorithmException e) {\n Log.d(TAG, \"Couldn't hash password. The expected digest algorithm is not available.\");\n }\n return passwordHash;\n }", "public static void main(String[] args) {\n\t\tString privateSalt = \"iam-serverdev\";\r\n\t\tByteSource publicSalt = Util.bytes(\"admin\");\r\n\t\tByteSource salt = Util.bytes(crossCombined(Util.bytes(privateSalt).getBytes(), publicSalt.getBytes()));\r\n\r\n\t\tString[] hashAlgorithms = new String[] { \"MD5\", \"SHA-256\", \"SHA-384\", \"SHA-512\" };\r\n\t\tint size = hashAlgorithms.length;\r\n\t\tlong index = crc32(salt.getBytes()) % size & (size - 1);\r\n\t\tString algorithm = hashAlgorithms[(int) index];\r\n\t\tint hashIterations = (int) (Integer.MAX_VALUE % (index + 1)) + 1;\r\n\t\tSystem.out.println(\">>>>>>>>>>\");\r\n\t\tSystem.out.print(new SimpleHash(algorithm, Util.bytes(\"123456\"), salt, hashIterations).toHex());\r\n\t\tSystem.out.print(\"\\n<<<<<<<<<<\");\r\n\t}", "public static final String hashing(String password) throws NoSuchAlgorithmException, NoSuchProviderException {\n String hpassword = password;\n MessageDigest mDigest = MessageDigest.getInstance(\"SHA1\");\n byte[] result = mDigest.digest(hpassword.getBytes());\n StringBuffer sb = new StringBuffer();\n for (int i = 0; i < result.length; i++) {\n sb.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1));\n }\n return sb.toString();\n }", "String password();", "public static String hash(String password) {\n\t MessageDigest sha256;\n\t\ttry {\n\t\t\tsha256 = MessageDigest.getInstance(\"SHA-256\");\n\t\t byte[] passBytes = password.getBytes();\n\t\t byte[] passHash = sha256.digest(passBytes);\n\t\t return new String(passHash, \"UTF-8\");\n\t\t} catch (NoSuchAlgorithmException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (UnsupportedEncodingException e) {\n\t\t\te.printStackTrace();\n\t\t} \n\t\treturn null;\n\t}", "public byte[] getHash(int iterationNb, String password, byte[] salt) throws NoSuchAlgorithmException, UnsupportedEncodingException {\n MessageDigest digest = MessageDigest.getInstance(\"SHA-1\");\n digest.reset();\n digest.update(salt);\n byte[] input = digest.digest(password.getBytes(\"UTF-8\"));\n for (int i = 0; i < iterationNb; i++) {\n digest.reset();\n input = digest.digest(input);\n }\n return input;\n }", "public static String encryptPassword(String input) {\n\t\tStringBuilder hexadecimalString = null;\n\t\tbyte[] byteArray;\n\t\t\n\t\ttry {\n\t\t\t//convert input string into a SHA encrypted byte array\n\t\t\tMessageDigest messageDigest = MessageDigest.getInstance(\"SHA-256\");\n\t\t\tbyteArray = messageDigest.digest(input.getBytes(StandardCharsets.UTF_8));\n\t\t\t\n\t\t\t//Now convert that byte array into hexadecimal\n\t\t\thexadecimalString = new StringBuilder(2 * byteArray.length);\n\t\t\tfor(byte i : byteArray) {\n\t\t\t\t//Hex value of a byte\n\t\t\t\tString hexValue = Integer.toHexString(0xff & i);\n\t\t\t\t\n\t\t\t\t//If the hex value is only a single digit, add a 0\n\t\t\t\tif(hexValue.length() == 1) \n\t\t\t\t\thexadecimalString.append('0');\n\t\t\t\t\n\t\t\t\t//Add the hex value to the entire string of hex values\n\t\t\t\thexadecimalString.append(hexValue);\n\t\t\t}\n\t\t} catch (NoSuchAlgorithmException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t\t\n\t\treturn hexadecimalString.toString();\n\t}", "private String encryptPassword(String password) {\n\t\tbyte[] defaultBytes = password.getBytes();\r\n StringBuffer hexString = new StringBuffer();\r\n try{\r\n MessageDigest algorithm = MessageDigest.getInstance(\"MD5\");\r\n algorithm.reset();\r\n algorithm.update(defaultBytes);\r\n byte messageDigest[] = algorithm.digest();\r\n for (int i=0;i<messageDigest.length;i++) {\r\n String hex = Integer.toHexString(0xFF & messageDigest[i]);\r\n if(hex.length()==1)\r\n hexString.append('0');\r\n hexString.append(hex);\r\n }\r\n }catch (Exception e){e.printStackTrace();}\r\n\t\tpassword = hexString.toString();\r\n\t\t//System.out.println(password);\r\n\t\treturn password;\r\n\t}", "boolean comparePasswordHash(String password, String salt, String destinationHash);", "private static String hashSHA256(String input) throws TokenManagementException {\n\t\t\n\t\tMessageDigest md;\n\t\ttry {\n\t\t\tmd = MessageDigest.getInstance(\"SHA-256\");\n\t\t} catch (NoSuchAlgorithmException e) {\n\t\t\tthrow new TokenManagementException(ErrorMessage.sha256AlgorithmNotFound);\n\t\t}\n\t\t\n\t\t\n\t\tmd.update(input.getBytes(StandardCharsets.UTF_8));\n\t\tbyte[] digest = md.digest();\n\n\t\t// Beware the hex length. If MD5 -> 32:\"%032x\", but for instance, in SHA-256 it should be \"%064x\" \n\t\tString result = String.format(\"%64x\", new BigInteger(1, digest));\n\t\t\n\t\treturn result;\n\t\t\n\t}", "public static String randomPassword(int len) {\n System.out.println(\"IN AUTO HASH\");\n String chars = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijk\"\n +\"lmnopqrstuvwxyz!@#$%&\";\n Random rnd = new Random();\n StringBuilder sb = new StringBuilder(len);\n for (int i = 0; i < len; i++)\n sb.append(chars.charAt(rnd.nextInt(chars.length())));\n return sb.toString();\n }", "public void makePassword() {\n String str = \"\";\r\n StringBuilder strBuilder = new StringBuilder(str);\r\n Random generator = new Random();\r\n int[] senha = new int[6];\r\n for (int i = 0; i < 6; i++) {\r\n senha[i] = generator.nextInt(10);\r\n strBuilder.append(Integer.toString(senha[i]));\r\n }\r\n str = strBuilder.toString();\r\n this.setPassword(str);\r\n //passwordList.add(l);\r\n }", "public static String encryptHmacSHA512ToString(final String data, final String key) {\n if (data == null || data.length() == 0 || key == null || key.length() == 0) return \"\";\n return encryptHmacSHA512ToString(data.getBytes(), key.getBytes());\n }", "public String securePassword(String pwd) {\r\n\r\n byte[] securePassword = hash(pwd.toCharArray(), pwd.getBytes());\r\n \r\n String returnValue = Base64.getEncoder().encodeToString(securePassword);\r\n return returnValue;\r\n\t}", "private static String saltedSha256(String password, String salt) throws Exception {\n\t\treturn sha256(password + salt);\n\t}", "public String createHash(String password)\n throws NoSuchAlgorithmException, InvalidKeySpecException\n {\n return createHash(password.toCharArray());\n }", "public void setPassword(String passwordStr) {\n this.password = get_SHA_512_SecurePassword(passwordStr);\n }", "public static String hash(String st) {\r\n MessageDigest messageDigest = null;\r\n byte[] digest = new byte[0];\r\n\r\n try {\r\n messageDigest = MessageDigest.getInstance(\"SHA-256\");\r\n messageDigest.reset();\r\n messageDigest.update(st.getBytes());\r\n digest = messageDigest.digest();\r\n } catch (NoSuchAlgorithmException e) {\r\n e.printStackTrace();\r\n }\r\n\r\n BigInteger bigInt = new BigInteger(1, digest);\r\n StringBuilder hex = new StringBuilder(bigInt.toString(16));\r\n\r\n while (hex.length() < 32) {\r\n hex.insert(0, \"0\");\r\n }\r\n\r\n return hex.toString();\r\n }", "private String getPasswordHash(String password) {\n String hashString = null;\n\n if (password != null && password.length() > 0) {\n try {\n MessageDigest md = MessageDigest.getInstance(\"SHA-256\");\n md.update(password.getBytes(\"UTF-8\"));\n byte[] hash = md.digest();\n\n // Ticket #410 - Fix password encyption. Ensure 0 is prepended\n // if the hex length is == 1 \n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < hash.length; i++) {\n String hex = Integer.toHexString(0xff & hash[i]);\n if (hex.length() == 1) {\n sb.append('0');\n }\n sb.append(hex);\n }\n\n hashString = sb.toString();\n\n } catch (Exception e) {\n e.printStackTrace(System.err);\n return null;\n }\n }\n\n return hashString;\n }", "private static String MD5Password(String password) {\n String md = org.apache.commons.codec.digest.DigestUtils.md5Hex(password);\n return md;\n }", "void mo33731Pw();", "public static String generateTOTP512(String key, int returnDigits) throws GeneralSecurityException {\n Calendar currentDateTime = getCalendar();\n long timeInMilis = currentDateTime.getTimeInMillis();\n\n String steps = \"0\";\n long T = (timeInMilis - TIME_ZERO) / TIME_SLICE_X;\n steps = Long.toHexString(T).toUpperCase();\n\n // Just get a 16 digit string\n while (steps.length() < 16)\n steps = \"0\" + steps;\n return TOTP.generateTOTP512(key, steps, returnDigits);\n }", "public static String createHash(String pass) throws NoSuchAlgorithmException, InvalidKeySpecException {\n\t\t\n\t\tchar[] pwArr = pass.toCharArray();\n\t\t\n\t\tSecureRandom rando = new SecureRandom();\n\t\tbyte[] salt = new byte[SALT_SIZE];\n\t\trando.nextBytes(salt);\n\t\t\n\t\tbyte[] hash = secretStuff(pwArr, salt, PW_ITERS, HASH_SIZE);\n\n\t\treturn PW_ITERS + \":\" + toHex(salt) + \":\" + toHex(hash);\n\t}", "public String generatePassword(){\n\t\treturn \"a\" + super.generatePassword() + \"1\";\n\t}", "public static String createPassword()\r\n\t{\r\n\t\treturn getRandomPwd(4);\r\n\t}", "private byte[] pullSaltAndHashFromDatabase(String username) {\n byte[] saltAndHashCombined = new byte[32];\n byte[] saltTakenFromTable = stringToBytes(database.returnSalt(username));\n byte[] hashTakenFromTable = stringToBytes(database.returnHash(username));\n System.arraycopy(saltTakenFromTable, 0, saltAndHashCombined, 0, 16);\n System.arraycopy(hashTakenFromTable, 0, saltAndHashCombined, 16, 16);\n return saltAndHashCombined;\n }", "public static String generatePasswort(String passwort) {\n Validator.check(!passwort.isEmpty(), ERR_MSG_PASSWORD_EMPTY);\n\n StringBuilder sb = new StringBuilder();\n\n byte[] mdbytes = verschlüsselePasswort(passwort);\n Validator.check(mdbytes != null, ERR_MSG_PASSWORT);\n\n for (byte mdbyte : mdbytes) {\n sb.append(Integer.toString((mdbyte & 0xff) + 0x100, 16).substring(1));\n }\n\n return sb.toString();\n }", "void setUserPasswordHash(String passwordHash);", "public static String createHash(char[] password)\r\n throws NoSuchAlgorithmException, InvalidKeySpecException {\r\n // Generate a random salt\r\n SecureRandom random = new SecureRandom();\r\n byte[] salt = new byte[SALT_BYTE_SIZE];\r\n random.nextBytes(salt);\r\n\r\n // Hash the password\r\n byte[] hash = pbkdf2(password, salt, PBKDF2_ITERATIONS, HASH_BYTE_SIZE);\r\n // format iterations:salt:hash\r\n return PBKDF2_ITERATIONS + \":\" + toHex(salt) + \":\" + toHex(hash);\r\n }", "private static String pasarAHexadecimal(byte[] digest){\n String hash = \"\";\n for(byte aux : digest) {\n int b = aux & 0xff;\n if (Integer.toHexString(b).length() == 1) hash += \"0\";\n hash += Integer.toHexString(b);\n }\n return hash;\n }" ]
[ "0.79890543", "0.76998746", "0.75060165", "0.7108459", "0.7070521", "0.6946682", "0.6936653", "0.6932263", "0.6892532", "0.68852234", "0.686524", "0.67733115", "0.6675661", "0.66512585", "0.65833455", "0.6565636", "0.6561411", "0.6538345", "0.65219766", "0.64631414", "0.6410259", "0.64061135", "0.6405447", "0.64028096", "0.6367734", "0.6343661", "0.63060755", "0.6288557", "0.6287703", "0.62601584", "0.6236071", "0.6229239", "0.622598", "0.61873704", "0.61627644", "0.61328024", "0.61286736", "0.61237806", "0.6088804", "0.6082947", "0.6067369", "0.60539764", "0.60486275", "0.6042456", "0.60420656", "0.60420173", "0.5968187", "0.59552526", "0.5949401", "0.59292716", "0.59205556", "0.5918995", "0.5901227", "0.58881986", "0.5865131", "0.5858868", "0.58470935", "0.5838333", "0.58348674", "0.5833429", "0.58289635", "0.5818192", "0.58114386", "0.57994455", "0.5783994", "0.577592", "0.57716644", "0.5761664", "0.5759181", "0.57455397", "0.57449543", "0.57444793", "0.5742879", "0.5725929", "0.57144755", "0.5707107", "0.5706315", "0.5691575", "0.5690577", "0.5662225", "0.5654512", "0.56452394", "0.5635075", "0.5623895", "0.5612357", "0.56075215", "0.55963236", "0.55868876", "0.5576695", "0.55758315", "0.5570801", "0.55689794", "0.5567606", "0.55675626", "0.5561267", "0.55592585", "0.555216", "0.5551535", "0.5547561", "0.5537158" ]
0.7317963
3
generates MD5 hash This method is compatible to PHP 5 and Java 8.
public static String computeMD5Hash(String password) { StringBuffer MD5Hash = new StringBuffer(); try { // Create MD5 Hash MessageDigest digest = MessageDigest.getInstance("MD5"); digest.update(password.getBytes()); byte messageDigest[] = digest.digest(); for (int i = 0; i < messageDigest.length; i++) { String h = Integer.toHexString(0xFF & messageDigest[i]); while (h.length() < 2) h = "0" + h; MD5Hash.append(h); } } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return MD5Hash.toString(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static String createMd5(String value)\r\n\t{ \r\n\t\ttry \r\n\t\t{\r\n\t\t\tMessageDigest md = MessageDigest.getInstance(\"MD5\");\t\t\t\r\n\t\t\tbyte[] hashInBytes = md.digest(value.getBytes(StandardCharsets.UTF_8));\r\n\t\t\tStringBuilder sb = new StringBuilder();\r\n\t for (byte b : hashInBytes) \r\n\t {\r\n\t sb.append(String.format(\"%02x\", b));\r\n\t }\r\n\t return sb.toString();\r\n\t\t}\r\n\t\tcatch(Exception ex)\r\n\t\t{\r\n\t\t\t\r\n\t\t}\r\n\t\treturn \"\";\r\n\t}", "public static String md5(String pass)\n {\n try{\n MessageDigest md=MessageDigest.getInstance(\"MD5\");\n byte[] messageDigest=md.digest(pass.getBytes());\n BigInteger num=new BigInteger(1,messageDigest);\n String hashText=num.toString(16);\n while(hashText.length()<32)\n {\n hashText=\"0\"+hashText;\n } \n return hashText; \n }\n catch(Exception e)\n { \n throw new RuntimeException(e);\n } \n }", "private static String md5(final String s) {\n final String MD5 = \"MD5\";\n try {\n // Create MD5 Hash\n MessageDigest digest = java.security.MessageDigest\n .getInstance(MD5);\n digest.update(s.getBytes());\n byte messageDigest[] = digest.digest();\n\n // Create Hex String\n StringBuilder hexString = new StringBuilder();\n for (byte aMessageDigest : messageDigest) {\n String h = Integer.toHexString(0xFF & aMessageDigest);\n while (h.length() < 2)\n h = \"0\" + h;\n hexString.append(h);\n }\n return hexString.toString();\n\n } catch (NoSuchAlgorithmException e) {\n e.printStackTrace();\n }\n return \"\";\n }", "public String getMD5() {\n return hash;\n }", "private String toMD5(String password)\n {\n try {\n MessageDigest m = MessageDigest.getInstance(\"MD5\");\n \n m.update(password.getBytes(),0,password.length());\n \n return new BigInteger(1, m.digest()).toString(16);\n } catch (NoSuchAlgorithmException ex) {\n Logger.getLogger(User.class.getName()).log(Level.SEVERE, null, ex);\n }\n return \"\";\n }", "public static byte[] computeMD5Hash(byte[] data) throws NoSuchAlgorithmException, IOException {\n return computeMD5Hash(new ByteArrayInputStream(data));\n }", "private String md5(final String s)\n\t{\n\t\ttry {\n\t\t\t// Create MD5 Hash\n\t\t\tMessageDigest digest = MessageDigest.getInstance(\"MD5\");\n\t\t\tdigest.update(s.getBytes());\n\t\t\tbyte messageDigest[] = digest.digest();\n\n\t\t\t// Create Hex String\n\t\t\tStringBuffer hexString = new StringBuffer();\n\t\t\tfor (int i=0; i<messageDigest.length; i++) {\n\t\t\t\tString h = Integer.toHexString(0xFF & messageDigest[i]);\n\t\t\t\twhile (h.length() < 2) h = \"0\" + h;\n\t\t\t\thexString.append(h);\n\t\t\t}\n\t\t\treturn hexString.toString();\n\t\t} catch(NoSuchAlgorithmException e) {\n\t\t\t//Logger.logStackTrace(TAG,e);\n\t\t}\n\t\treturn \"\";\n\t}", "public String md5(String s) {\n try {\n // Create MD5 Hash\n MessageDigest digest = java.security.MessageDigest.getInstance(\"MD5\");\n digest.update(s.getBytes());\n byte messageDigest[] = digest.digest();\n\n // Create Hex String\n StringBuffer hexString = new StringBuffer();\n for (int i = 0; i < messageDigest.length; i++)\n hexString.append(Integer.toHexString(0xFF & messageDigest[i]));\n return hexString.toString();\n\n } catch (NoSuchAlgorithmException e) {\n e.printStackTrace();\n }\n return \"\";\n }", "protected String getMd5Hash(String token) {\n\n MessageDigest m;\n\t\ttry {\n\t\t\tm = MessageDigest.getInstance(\"MD5\");\n\t\t} catch (NoSuchAlgorithmException e) {\n\t\t\tthrow new IllegalStateException(e);\n\t\t}\n m.update(token.getBytes());\n \n byte[] digest = m.digest();\n BigInteger bigInt = new BigInteger(1,digest);\n String hashtext = bigInt.toString(16);\n \n // Now we need to zero pad it if you actually want the full 32 chars.\n while(hashtext.length() < 32 ){\n hashtext = \"0\"+hashtext;\n }\n \n return hashtext;\n\t}", "public static MessageDigest getMessageDigest ()\n {\n try {\n return MessageDigest.getInstance(\"MD5\");\n } catch (NoSuchAlgorithmException nsae) {\n throw new RuntimeException(\"JVM does not support MD5. Gurp!\");\n }\n }", "public static String getMd5(String input) {\n try {\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n\n byte[] messageDigest = md.digest(input.getBytes());\n\n BigInteger no = new BigInteger(1, messageDigest);\n\n String hashtext = no.toString(16);\n while (hashtext.length() < 32) {\n hashtext = \"0\" + hashtext;\n }\n return hashtext;\n } catch (NoSuchAlgorithmException e) {\n throw new RuntimeException(e);\n }\n }", "private String md5(String input) {\r\n\t\tString md5 = null;\r\n\t\tif (null == input)\r\n\t\t\treturn null;\r\n\r\n\t\ttry {\r\n\t\t\tMessageDigest digest = MessageDigest.getInstance(\"MD5\");\r\n\t\t\tdigest.update(input.getBytes(), 0, input.length());\r\n\t\t\tmd5 = new BigInteger(1, digest.digest()).toString(16);\r\n\t\t} catch (NoSuchAlgorithmException e) {\r\n\r\n\t\t\te.printStackTrace();\r\n\t\t}\r\n\t\treturn md5;\r\n\t}", "public static String md5(String message) {\n String digest = null;\n try {\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n byte[] hash = md.digest(message.getBytes(\"UTF-8\"));\n\n //converting byte array to HexadecimalString\n StringBuilder sb = new StringBuilder(2 * hash.length);\n for (byte b : hash) {\n sb.append(String.format(\"%02x\", b & 0xff));\n }\n digest = sb.toString();\n } catch (UnsupportedEncodingException ex) {\n log.error(\"UnsupportedEncodingException\",ex);\n } catch (NoSuchAlgorithmException ex) {\n log.error(\"NoSuchAlgorithmException\",ex);\n }\n\n return digest;\n }", "private static byte[] generateMD5(String info) throws\n UnsupportedEncodingException, NoSuchAlgorithmException {\n byte[] inputData = info.getBytes(\"UTF-8\");\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n md.update(inputData);\n byte[] digest= md.digest();\n return digest;\n }", "private static String md5(byte[] b) {\n try {\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n md.reset();\n md.update(b);\n byte[] digest = md.digest();\n StringBuffer sb = new StringBuffer();\n for (int i=0; i<digest.length; i++) {\n String a = Integer.toHexString(0xff & digest[i]);\n if (a.length() == 1) a = \"0\" + a;\n sb.append(a);\n }\n return sb.toString();\n }\n catch (NoSuchAlgorithmException e) { writeLog(e); }\n return null;\n }", "@Test\n public void md5Checksum() throws NoSuchAlgorithmException {\n String string = Utils.md5Checksum(\"abcde fghijk lmn op\");\n Assert.assertEquals(\"1580420c86bbc3b356f6c40d46b53fc8\", string);\n }", "public static String getMD5(String s) {\n try {\n MessageDigest m = MessageDigest.getInstance(\"MD5\");\n m.update(s.getBytes(), 0, s.length());\n return \"\" + new BigInteger(1, m.digest()).toString(16);\n } catch (NoSuchAlgorithmException e) {\n logger.error(\"MD5 is not supported !!!\");\n }\n return s;\n }", "public static String getMD5Hash(String string) {\r\n\t\tMessageDigest digest;\r\n\t\ttry {\r\n\t\t\tdigest = java.security.MessageDigest.getInstance(\"MD5\");\r\n\t\t\tdigest.update(string.getBytes());\r\n\t\t\tfinal byte[] hash = digest.digest();\r\n\t\t\tfinal StringBuilder result = new StringBuilder(hash.length);\r\n\t\t\tfor (int i = 0; i < hash.length; i++) {\r\n\t\t\t\tresult.append(Integer.toString((hash[i] & 0xff) + 0x100, 16)\r\n\t\t\t\t\t\t.substring(1));\r\n\t\t\t}\r\n\t\t\treturn result.toString();\r\n\t\t} catch (final NoSuchAlgorithmException e) {\r\n\t\t\te.printStackTrace();\r\n\t\t\treturn \"error\";\r\n\t\t}\r\n\t}", "public String MD5(String md5) {\n try {\n java.security.MessageDigest md = java.security.MessageDigest.getInstance(\"MD5\");\n byte[] array = md.digest(md5.getBytes());\n StringBuffer sb = new StringBuffer();\n for (int i = 0; i < array.length; ++i) {\n sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3));\n }\n return sb.toString();\n } catch (java.security.NoSuchAlgorithmException e) {\n }\n return null;\n }", "public static String encryptMD5(String st) {\n MessageDigest messageDigest;\n byte[] digest = new byte[0];\n try {\n messageDigest = MessageDigest.getInstance(DefaultValueConstants.DEFAULT_ENCRYPTING_ALGORITHM);\n messageDigest.reset();\n messageDigest.update(st.getBytes());\n digest = messageDigest.digest();\n } catch (NoSuchAlgorithmException e) {\n log.error(e);\n }\n BigInteger bigInt = new BigInteger(1, digest);\n String md5Hex = bigInt.toString(16);\n while (md5Hex.length() < 32) {\n md5Hex = \"0\" + md5Hex;\n }\n return md5Hex;\n }", "public static String calcHash(String input) {\n try {\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n md.update(input.toLowerCase().getBytes(\"UTF8\"));\n byte[] digest = md.digest();\n StringBuilder sb = new StringBuilder();\n for (byte b : digest) {\n sb.append(hexDigit(b>>4));\n sb.append(hexDigit(b));\n }\n return sb.toString();\n } catch (Exception ex) {\n throw new RuntimeException(ex.getMessage(), ex);\n }\n }", "public static String md5(String password){\n byte[] data = messageDigest.digest(password.getBytes());\n return byteToHex(data);\n }", "private String md5(String message) throws java.security.NoSuchAlgorithmException\n\t{\n\t\tMessageDigest md5 = null;\n\t\ttry {\n\t\t\tmd5 = MessageDigest.getInstance(\"MD5\");\n\t\t}\n\t\tcatch (java.security.NoSuchAlgorithmException ex) {\n\t\t\tex.printStackTrace();\n\t\t\tthrow ex;\n\t\t}\n\t\tbyte[] dig = md5.digest((byte[]) message.getBytes());\n\t\tStringBuffer code = new StringBuffer();\n\t\tfor (int i = 0; i < dig.length; ++i)\n\t\t{\n\t\t\tcode.append(Integer.toHexString(0x0100 + (dig[i] & 0x00FF)).substring(1));\n\t\t}\n\t\treturn code.toString();\n\t}", "protected static String md5(final String string) {\n try {\n final MessageDigest m = MessageDigest.getInstance(\"MD5\");\n m.update(string.getBytes(), 0, string.length());\n return new BigInteger(1, m.digest()).toString(16);\n } catch (NoSuchAlgorithmException e) {\n return \"\";\n }\n }", "private static String getMD5Checksum(String filename) throws Exception {\r\n\t\tbyte[] b = createChecksum(filename);\r\n\t\tStringBuilder result = new StringBuilder();\r\n\t\tfor (byte v : b) {\r\n\t\t\tresult.append(Integer.toString((v & 0xff) + 0x100, 16).substring(1));\r\n\t\t}\r\n\t\treturn result.toString();\r\n\t}", "private static String MD5Password(String password) {\n String md = org.apache.commons.codec.digest.DigestUtils.md5Hex(password);\n return md;\n }", "public String md5(String md5StringInput) {\n try {\n java.security.MessageDigest md = java.security.MessageDigest.getInstance(\"MD5\");\n byte[] array = md.digest(md5StringInput.getBytes());\n StringBuffer sb = new StringBuffer();\n for (int i = 0; i < array.length; ++i) {\n sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3));\n }\n return sb.toString();\n } catch (java.security.NoSuchAlgorithmException e) {\n }\n return null;\n }", "public static String md5(String str) {\n MessageDigest messageDigest = null;\n try {\n messageDigest = MessageDigest.getInstance(\"MD5\");\n messageDigest.reset();\n messageDigest.update(str.getBytes(\"UTF-8\"));\n } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {\n // do nothing\n }\n byte[] byteArray = messageDigest.digest();\n StringBuffer md5StrBuff = new StringBuffer();\n for (int i = 0; i < byteArray.length; i++) {\n if (Integer.toHexString(0xFF & byteArray[i]).length() == 1)\n md5StrBuff.append(\"0\").append(Integer.toHexString(0xFF & byteArray[i]));\n else\n md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i]));\n }\n return md5StrBuff.toString();\n }", "public static String computeMD5FileHash (File file) throws Exception {\n byte[] b = createFileChecksum(file);\n String result = \"\";\n\n for (int i=0; i < b.length; i++) {\n result += Integer.toString( ( b[i] & 0xff ) + 0x100, 16).substring( 1 );\n }\n return result;\n }", "public static byte[] computeMD5Hash(InputStream is) throws NoSuchAlgorithmException, IOException {\n BufferedInputStream bis = new BufferedInputStream(is);\n try {\n MessageDigest messageDigest = MessageDigest.getInstance(\"MD5\");\n byte[] buffer = new byte[16384];\n int bytesRead = -1;\n while ((bytesRead = bis.read(buffer, 0, buffer.length)) != -1) {\n messageDigest.update(buffer, 0, bytesRead);\n }\n return messageDigest.digest();\n } finally {\n try {\n bis.close();\n } catch (Exception e) {\n System.err.println(\"Unable to close input stream of hash candidate: \" + e);\n }\n }\n }", "public static byte[] encryptMD5(final byte[] data) {\n return hashTemplate(data, \"MD5\");\n }", "public static String computeMD5(String filename) throws Exception {\r\n byte[] b = createGenericChecksum(filename, 0);\r\n String result = \"\";\r\n for (int i = 0; i < b.length; i++) {\r\n result += Integer.toString((b[i] & 0xff) + 0x100, 16).substring(1);\r\n }\r\n return result;\r\n }", "public String encodeByMD5(String string) {\n\t\t\tif (string == null) {\r\n\t\t\t\treturn null;\r\n\t\t\t}\r\n\t\t\ttry {\r\n\t\t\t\tMessageDigest messageDigest = MessageDigest.getInstance(\"MD5\");\r\n\t\t\t\t\r\n\t\t\t\t//使用平台的默认字符集将此 String 编码为 byte 序列,并将结果存储到一个新的 byte 数组中。\r\n\t\t\t\t//将byte数组给摘要\r\n\t\t\t\tmessageDigest.update(string.getBytes());\r\n\t\t\t\t//通过执行诸如填充之类的最终操作完成哈希计算。在调用此方法之后,摘要被重置。 \r\n\t\t\t\t//返回:\r\n\t\t\t\t//存放哈希值结果的 byte 数组。\r\n\t\t\t\t\r\n\t\t\t\treturn getFormattedText(messageDigest.digest());\r\n\t\t\t} catch (Exception e) {\r\n\t\t\t\tthrow new RuntimeException(e);\r\n\t\t\t}\r\n\t\t}", "public static String md5(final String data) {\n return ByteString.encodeUtf8(data).md5().hex().toLowerCase();\n }", "public String getMd5Hash() {\n return md5Hash;\n }", "public static String hash(String in) {\r\n\t\treturn DigestUtils.md5Hex(in.getBytes());\r\n\t}", "private static String md5(String str) {\n\n if (str == null) {\n return null;\n }\n\n MessageDigest messageDigest = null;\n\n try {\n messageDigest = MessageDigest.getInstance(HttpConf.signType);\n messageDigest.reset();\n messageDigest.update(str.getBytes(HttpConf.charset));\n } catch (NoSuchAlgorithmException e) {\n\n return str;\n } catch (UnsupportedEncodingException e) {\n return str;\n }\n\n byte[] byteArray = messageDigest.digest();\n\n StringBuffer md5StrBuff = new StringBuffer();\n\n for (int i = 0; i < byteArray.length; i++) {\n if (Integer.toHexString(0xFF & byteArray[i]).length() == 1) {\n md5StrBuff.append(\"0\").append(Integer.toHexString(0xFF & byteArray[i]));\n } else {\n md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i]));\n }\n }\n\n return md5StrBuff.toString();\n }", "public static String getMobileAdminPasswordMD5(){\n\t\treturn \"e3e6c68051fdfdf177c8933bfd76de48\";\n\t}", "public static String getMD5Sum(String variable) throws NoSuchAlgorithmException{\t\n\t\tMessageDigest md=MessageDigest.getInstance(\"MD5\");\n\t\tmd.update(variable.getBytes());\n\t\treturn new BigInteger(1,md.digest()).toString(16);\n\t}", "public String getHash(final String password) throws NoSuchAlgorithmException, UnsupportedEncodingException {\n final MessageDigest digest = MessageDigest.getInstance(\"MD5\");\n byte[] md5hash;\n digest.update(password.getBytes(\"utf-8\"), 0, password.length());\n md5hash = digest.digest();\n return convertToHex(md5hash);\n }", "public static String getmd5(String saltedPassword) {\n\t\tmd5MessageDigest.get().update(saltedPassword.getBytes());\n\t\treturn toHex(md5MessageDigest.get().digest());\n\t}", "private static byte[] m14295fl(String str) {\n try {\n MessageDigest instance = MessageDigest.getInstance(\"MD5\");\n if (instance == null) {\n return str.getBytes();\n }\n instance.update(str.getBytes());\n return instance.digest();\n } catch (NoSuchAlgorithmException e) {\n e.printStackTrace();\n return str.getBytes();\n }\n }", "public String get_Md5_Hash(String sStringToEncode) throws Exception {\n String sRetval = \"\";\n StringBuffer sb = new StringBuffer();\n\n try {\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n byte[] messageDigest = md.digest(sStringToEncode.getBytes(\"UTF-8\"));\n BigInteger number = new BigInteger(1, messageDigest);\n String hashtext = number.toString(16);\n sRetval = hashtext;\n } catch (Exception e) {\n throw new Exception(\"get_Md5_Hash : \" + e);\n }\n return sRetval;\n }", "public byte[] getMD5() {\n return MD5;\n }", "public static String md5(String inputFile) {\r\n String md5 = null;\r\n logger.debug(\"Start to calculate hashcode (SHA1) for {}\", inputFile);\r\n try (DigestInputStream digestIn = new DigestInputStream(new FileInputStream(inputFile),\r\n MessageDigest.getInstance(\"SHA1\"))) {\r\n byte[] buffer = new byte[1024 * 1024];\r\n while (digestIn.read(buffer) > 0) {\r\n // do nothing\r\n }\r\n md5 = toHexString(digestIn.getMessageDigest().digest());\r\n } catch (NoSuchAlgorithmException | IOException e) {\r\n logger.warn(\"Fail to md5 for {} ({})\", inputFile, e.getMessage());\r\n }\r\n logger.debug(\"End to calculate hashcode (SHA1) for {}, {}\", inputFile, md5);\r\n return md5;\r\n }", "public MD5Hash(String s) {\n\t\tif(s.length() != 32) throw new IllegalArgumentException(\"Hash must have 32 characters\");\n\t\thashString = s;\n\t}", "private static java.security.MessageDigest f() {\n /*\n r0 = \"MD5\";\n r1 = j;\n r0 = r0.equals(r1);\n if (r0 == 0) goto L_0x003a;\n L_0x000a:\n r0 = java.security.Security.getProviders();\n r1 = r0.length;\n r2 = 0;\n L_0x0010:\n if (r2 >= r1) goto L_0x003a;\n L_0x0012:\n r3 = r0[r2];\n r3 = r3.getServices();\n r3 = r3.iterator();\n L_0x001c:\n r4 = r3.hasNext();\n if (r4 == 0) goto L_0x0037;\n L_0x0022:\n r4 = r3.next();\n r4 = (java.security.Provider.Service) r4;\n r4 = r4.getAlgorithm();\n j = r4;\n r4 = j;\t Catch:{ NoSuchAlgorithmException -> 0x001c }\n r4 = java.security.MessageDigest.getInstance(r4);\t Catch:{ NoSuchAlgorithmException -> 0x001c }\n if (r4 == 0) goto L_0x001c;\n L_0x0036:\n return r4;\n L_0x0037:\n r2 = r2 + 1;\n goto L_0x0010;\n L_0x003a:\n r0 = 0;\n return r0;\n */\n throw new UnsupportedOperationException(\"Method not decompiled: com.koushikdutta.async.util.FileCache.f():java.security.MessageDigest\");\n }", "public String getMD5ForGame(String gameId) {\n return \"TODO\";\n }", "public static String hash(String data) {\n\t MessageDigest md;\n\t\ttry {\n\t\t\tmd = MessageDigest.getInstance(\"MD5\");\n\t\t md.update(data.getBytes());\n\t\t byte[] digest = md.digest();\n\t\t char[] HEX_ARRAY = \"0123456789ABCDEF\".toCharArray();\n\t char[] hexChars = new char[digest.length * 2];\n\t for (int j = 0; j < digest.length; j++) {\n\t int v = digest[j] & 0xFF;\n\t hexChars[j * 2] = HEX_ARRAY[v >>> 4];\n\t hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];\n\t }\n\t return new String(hexChars);\n\t\t} catch (NoSuchAlgorithmException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\n return null;\n\t}", "private String getFileMd5Checksum(String filename){\n\t\ttry {\n\t\t\tbyte[] fileBytes = Files.readAllBytes(Paths.get(FILES_ROOT + filename));\n\t\t\tbyte[] fileHash = MessageDigest.getInstance(\"MD5\").digest(fileBytes);\n\n\t\t\treturn DatatypeConverter.printHexBinary(fileHash);\n\t\t} catch (IOException e) {\n\t\t\t// TODO: Handle file doesn't exist\n\t\t\treturn \"\";\n\t\t} catch (Exception e) {\n\t\t\treturn \"\";\n\t\t}\n\t}", "private String computeDigest(boolean paramBoolean, String paramString1, char[] paramArrayOfchar, String paramString2, String paramString3, String paramString4, String paramString5, String paramString6, String paramString7) throws NoSuchAlgorithmException {\n/* 470 */ String str1, str3, str5, str2 = this.params.getAlgorithm();\n/* 471 */ boolean bool = str2.equalsIgnoreCase(\"MD5-sess\");\n/* */ \n/* 473 */ MessageDigest messageDigest = MessageDigest.getInstance(bool ? \"MD5\" : str2);\n/* */ \n/* 475 */ if (bool) {\n/* 476 */ if ((str1 = this.params.getCachedHA1()) == null) {\n/* 477 */ str3 = paramString1 + \":\" + paramString2 + \":\";\n/* 478 */ String str7 = encode(str3, paramArrayOfchar, messageDigest);\n/* 479 */ String str6 = str7 + \":\" + paramString5 + \":\" + paramString6;\n/* 480 */ str1 = encode(str6, (char[])null, messageDigest);\n/* 481 */ this.params.setCachedHA1(str1);\n/* */ } \n/* */ } else {\n/* 484 */ String str = paramString1 + \":\" + paramString2 + \":\";\n/* 485 */ str1 = encode(str, paramArrayOfchar, messageDigest);\n/* */ } \n/* */ \n/* */ \n/* 489 */ if (paramBoolean) {\n/* 490 */ str3 = paramString3 + \":\" + paramString4;\n/* */ } else {\n/* 492 */ str3 = \":\" + paramString4;\n/* */ } \n/* 494 */ String str4 = encode(str3, (char[])null, messageDigest);\n/* */ \n/* */ \n/* 497 */ if (this.params.authQop()) {\n/* 498 */ str5 = str1 + \":\" + paramString5 + \":\" + paramString7 + \":\" + paramString6 + \":auth:\" + str4;\n/* */ }\n/* */ else {\n/* */ \n/* 502 */ str5 = str1 + \":\" + paramString5 + \":\" + str4;\n/* */ } \n/* */ \n/* */ \n/* 506 */ return encode(str5, (char[])null, messageDigest);\n/* */ }", "public MD5Util() {\n }", "public String getHashString()\n\t{\n\t\treturn md5.getHashString();\n\t}", "public String getHash(String str) throws Exception{\n\t\t\n\t\tMessageDigest md = MessageDigest.getInstance(\"MD5\");\n md.update(str.getBytes());\n \n byte byteData[] = md.digest();\n \n //convert the byte to hex format method 1\n StringBuffer sb = new StringBuffer();\n for (int i = 0; i < byteData.length; i++) {\n sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));\n }\n \n String hex = sb.toString();\n System.out.println(hex);\n return hex; \n}", "public static String getStringMD5(String src) {\n\t\tMessageDigest messageDigest = null;\n\t\tbyte[] srcBytes = src.getBytes();\n\t\ttry {\n\t\t\tmessageDigest = MessageDigest.getInstance(\"MD5\");\n\t\t} catch (NoSuchAlgorithmException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tmessageDigest.update(srcBytes, 0, srcBytes.length);\n\t\tBigInteger bigInt = new BigInteger(1, messageDigest.digest());\n\t\treturn bigInt.toString(16);\n\t}", "public String getMD5(String txt){\n String md5output;\n md5output = txt;\n try {\n MessageDigest m = MessageDigest.getInstance(\"MD5\");\n m.reset();\n m.update(md5output.getBytes());\n byte[] digest = m.digest();\n BigInteger bigInt = new BigInteger(1,digest);\n md5output = bigInt.toString(16);\n } catch (Exception e) {\n md5output = null;\n } finally{\n return md5output;\n }\n \n }", "public static String encryptedByMD5(String password) {\n StringBuilder result = new StringBuilder();\n try {\n byte[] pass = MessageDigest\n .getInstance(\"MD5\")\n .digest(password.getBytes());\n\n for (byte b : pass) {\n int salt = b & 0xCA; //Salt\n String saltString = Integer.toHexString(salt);\n if (1 == saltString.length()) {\n result.append(\"0\");\n }\n result.append(saltString);\n }\n return result.toString();\n } catch (NoSuchAlgorithmException e) {\n LOG.error(\"No MD5 Algorithm in this System! \", e);\n throw new RuntimeException(\"Could not encrypt the user password in this system!\", e);\n }\n }", "public static String toMD5(final String str) {\n\t\treturn MD5.toMD5(str);\n\n\t\t//linux下常有不同结果故弃之\n\t\t//return CryptTool.md5Digest(str);\n\t}", "public static String md5PasswordCrypt(String password) throws AutoDeployException {\n try {\n byte[] hash = MessageDigest.getInstance(\"MD5\").digest(password.getBytes());\n StringBuffer hashString = new StringBuffer();\n for (int i = 0; i < hash.length; i++) {\n String hex = Integer.toHexString(hash[i]);\n if (hex.length() == 1) {\n hashString.append('0');\n hashString.append(hex.charAt(hex.length() - 1));\n } else {\n hashString.append(hex.substring(hex.length() - 2));\n }\n }\n return hashString.toString();\n } catch (Exception e) {\n log.error(\"Can't crypt the password due to an unexpected error : \" + e.getMessage());\n throw new AutoDeployException(\"Cant' crypt the password due to an unexpected error : \" + e.getMessage());\n }\n }", "public static String EncoderByMd5(String source){\n String sCode = null;\n try{\n MessageDigest md5=MessageDigest.getInstance(\"MD5\"); \n sCode = Base64.encode(md5.digest(source.getBytes(\"UTF-8\"))); \n }\n catch(UnsupportedEncodingException e1){}\n catch(NoSuchAlgorithmException e2){}\n \n return sCode;\n }", "static String generateChecksum(String filename) {\n\n try {\n // Instantiating file and Hashing Algorithm.\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n FileInputStream file = new FileInputStream(filename);\n\n // Generation of checksum.\n byte[] dataBytes = new byte[1024];\n int nread;\n\n while ((nread = file.read(dataBytes)) != -1) {\n md.update(dataBytes, 0, nread);\n }\n\n byte[] mdbytes = md.digest();\n\n // Convert byte to hex.\n StringBuilder hexString = new StringBuilder();\n\n for (byte mdbyte : mdbytes) {\n String hex = Integer.toHexString(0xff & mdbyte);\n if (hex.length() == 1) hexString.append('0');\n hexString.append(hex);\n }\n\n // Return checksum as completed string.\n return hexString.toString();\n\n } catch (NoSuchAlgorithmException | IOException e) {\n e.printStackTrace();\n }\n return null;\n }", "public static String getMD5(String string) throws NoSuchAlgorithmException, IOException {\n MessageDigest md5;\n md5 = MessageDigest.getInstance(\"MD5\");\n\n try (DigestInputStream stream = new DigestInputStream(new ByteArrayInputStream(string.getBytes()), md5)) {\n byte[] buffer = new byte[8192];\n while (true) {\n if ((stream.read(buffer) == -1)) break;\n }\n StringBuilder sb = new StringBuilder();\n for (byte b : md5.digest()) {\n sb.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));\n }\n return sb.toString();\n }\n }", "static String md5test(String text,String returnType) {\n String result=null;\n if (returnType.equals(\"str\")){\n result = DigestUtils.md5Hex(text);\n System.out.println(result); // 5d41402abc4b2a76b9719d911017c592\n }else if(returnType.equals(\"byteArray\")){\n byte[] res = DigestUtils.md5(text);\n System.out.println(byteToHex(res));// 5d41402abc4b2a76b9719d911017c592\n }\n //new String((byte[]) res)\n return result;\n}", "public byte[] getHash()\n\t{\n\t\treturn md5.getHash();\n\t}", "public static String hash_password(String password) throws Exception\r\n\t{\r\n\t\t// Digest the password with MD5 algorithm\r\n\t\tMessageDigest md = MessageDigest.getInstance(\"MD5\");\r\n\t\tmd.update(password.getBytes());\r\n\t\t \r\n\t\tbyte byte_data[] = md.digest();\r\n\t\t \r\n\t\t//convert the bytes to hex format \r\n\t\tStringBuffer sb = new StringBuffer();\r\n\t\t \r\n\t\tfor (int i = 0; i < byte_data.length; i++) \r\n\t\t{\r\n\t\t\tsb.append(Integer.toString((byte_data[i] & 0xff) + 0x100, 16).substring(1));\r\n\t\t}\r\n\t\t \r\n\t\t//System.out.println(\"Hashed password: \" + sb.toString());\r\n\t\treturn sb.toString();\r\n\t}", "private String getHash(String text) {\n\t\ttry {\n\t\t\tString salt = new StringBuffer(this.email).reverse().toString();\n\t\t\ttext += salt;\n\t\t\tMessageDigest m = MessageDigest.getInstance(\"MD5\");\n\t\t\tm.reset();\n\t\t\tm.update(text.getBytes());\n\t\t\tbyte[] digest = m.digest();\n\t\t\tBigInteger bigInt = new BigInteger(1, digest);\n\t\t\tString hashedText = bigInt.toString(16);\n\t\t\twhile (hashedText.length() < 32) {\n\t\t\t\thashedText = \"0\" + hashedText;\n\t\t\t}\n\t\t\treturn hashedText;\n\t\t} catch (Exception e) {\n\t\t\te.getStackTrace();\n\t\t\treturn text;\n\t\t}\n\t}", "private String hashKey(String key) throws NoSuchAlgorithmException {\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n byte[] hashInBytes = md.digest(key.getBytes(StandardCharsets.UTF_8));\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < hashInBytes.length; i++) {\n sb.append(Integer.toString((hashInBytes[i] & 0xff) + 0x100, 16).substring(1));\n }\n String s = sb.toString();\n return s;\n }", "public MD5(String texto) throws Exception {\n this.md5 = MessageDigest.getInstance(\"MD5\");\n this.texto = texto;\n this.byTexto = texto.getBytes();\n calcMD5();\n }", "public String getMD5() {\n return m_module.getConfiguration().getMD5();\n }", "public static String getMD5(File file) throws IOException, NoSuchAlgorithmException {\n return getChecksum(file, MessageDigest.getInstance(\"MD5\"));\n }", "private static String getKeyByMd5(String url) {\n String key;\n try {\n MessageDigest messageDigest = MessageDigest.getInstance(\"MD5\");\n messageDigest.update(url.getBytes());\n key = md5Encryption(messageDigest.digest());\n return key;\n } catch (NoSuchAlgorithmException e) {\n e.printStackTrace();\n key = String.valueOf(url.hashCode());\n }\n return key;\n }", "public static String computeOnce(String str) {\n str = (str == null) ? \"\" : str;\n MessageDigest md5 = null;\n try {\n md5 = MessageDigest.getInstance(\"MD5\");\n } catch (Exception e) {\n throw new ExternalException();\n }\n // convert input String to a char[]\n // convert that char[] to byte[]\n // get the md5 digest as byte[]\n // bit-wise AND that byte[] with 0xff\n // prepend \"0\" to the output StringBuffer to make sure that we don't end\n // up with\n // something like \"e21ff\" instead of \"e201ff\"\n\n char[] charArray = str.toCharArray();\n\n byte[] byteArray = new byte[charArray.length];\n\n for (int i = 0; i < charArray.length; i++)\n byteArray[i] = (byte) charArray[i];\n\n byte[] md5Bytes = md5.digest(byteArray);\n\n StringBuffer hexValue = new StringBuffer();\n\n for (int i = 0; i < md5Bytes.length; i++) {\n int val = (md5Bytes[i]) & 0xff;\n if (val < 16)\n hexValue.append(\"0\");\n hexValue.append(Integer.toHexString(val));\n }\n\n return hexValue.toString();\n }", "byte[] digest();", "public String getMechanismName() {\n return \"DIGEST-MD5\";\n }", "public static String getFileMD5(File file) {\n\t\tMessageDigest messageDigest = null;\n\t\tFileInputStream fileInStream = null;\n\t\tbyte buffer[] = new byte[1024];\n\t\tint length = -1;\n\t\ttry {\n\t\t\tmessageDigest = MessageDigest.getInstance(\"MD5\");\n\t\t\tfileInStream = new FileInputStream(file);\n\t\t\twhile ((length = fileInStream.read(buffer, 0, 1024)) != -1) {\n\t\t\t\tmessageDigest.update(buffer, 0, length);\n\t\t\t}\n\t\t\tfileInStream.close();\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t\treturn null;\n\t\t}\n\t\tBigInteger bigInt = new BigInteger(1, messageDigest.digest());\n\t\treturn bigInt.toString(16);\n\t}", "public static String hashPassword(String password) {\n\n MessageDigest md;\n StringBuffer sb = new StringBuffer();\n String hexString = null;\n try {\n md = MessageDigest.getInstance(\"MD5\");\n\n md.update(password.getBytes());\n byte[] digest = md.digest();\n\n for (byte b : digest) {\n sb.append(String.format(\"%02x\", b & 0xff));\n }\n } catch (NoSuchAlgorithmException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n\n Logger.debug(\"Hash For Password - \" + sb.toString());\n return sb.toString();\n }", "public static String encriptar(String input){\n try {\n\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n\n byte[] messageDigest = md.digest(input.getBytes());\n\n BigInteger no = new BigInteger(1, messageDigest);\n\n String hashtext = no.toString(16);\n while (hashtext.length() < 32) {\n hashtext = \"0\" + hashtext;\n }\n return hashtext;\n }\n\n catch (NoSuchAlgorithmException e) {\n throw new RuntimeException(e);\n }\n }", "public static String getFileMD5(String path) {\n\t\treturn getFileMD5(new File(path));\n\t}", "public static String hashPass(String value) throws NoSuchAlgorithmException\n\t{\n\t\t//There are many algos are available for hashing i)MD5(message digest) ii)SHA(Secured hash algo)\n\t\tMessageDigest md=MessageDigest.getInstance(\"MD5\");\n\t md.update(value.getBytes());\n\t \n\t byte[] hashedpass=md.digest();\n\t StringBuilder hashpass=new StringBuilder();\n\t for(byte b:hashedpass)\n\t {\n\t \t//Convert to hexadecimal format\n\t hashpass.append(String.format(\"%02x\",b));\n\t }\n\t return hashpass.toString();\n\t}", "protected byte[] getHMAC(byte[] Ki, byte[] seqnum, byte[] msg, int start, int len) throws SaslException {\n byte[] seqAndMsg = new byte[4 + len];\n System.arraycopy(seqnum, 0, seqAndMsg, 0, 4);\n System.arraycopy(msg, start, seqAndMsg, 4, len);\n try {\n SecretKey keyKi = new SecretKeySpec(Ki, \"HmacMD5\");\n Mac m = Mac.getInstance(\"HmacMD5\");\n m.init(keyKi);\n m.update(seqAndMsg);\n byte[] hMAC_MD5 = m.doFinal();\n byte macBuffer[] = new byte[10];\n System.arraycopy(hMAC_MD5, 0, macBuffer, 0, 10);\n return macBuffer;\n } catch (InvalidKeyException e) {\n throw new SaslException(\"DIGEST-MD5: Invalid bytes used for \" + \"key of HMAC-MD5 hash.\", e);\n } catch (NoSuchAlgorithmException e) {\n throw new SaslException(\"DIGEST-MD5: Error creating \" + \"instance of MD5 digest algorithm\", e);\n }\n }", "public String getHmacMD5(String privateKey, String input) throws Exception{\n String algorithm = \"HmacSHA256\";\n String Ret=\"\";\n byte[] keyBytes = Base64.decode(privateKey, Base64.NO_WRAP);\n Key key = new SecretKeySpec(keyBytes, 0, keyBytes.length, algorithm);\n Mac mac = Mac.getInstance(algorithm);\n mac.init(key);\n\n\n\n try {\n\n\n byte[] bytes = mac.doFinal(input.getBytes(\"UTF-8\"));\n\n Ret=Base64.encodeToString(bytes,Base64.URL_SAFE|Base64.NO_WRAP).replace('-','+').replace('_', '/');;\n\n }\n catch(Exception e)\n {\n\n }\n return Ret;\n }", "public String hashing(String password) {\n\n\t\tString hashedPassword = null;\n\n\t\tMessageDigest md;\n\t\ttry {\n\t\t\tmd = MessageDigest.getInstance(\"MD5\");\n\t\t\tmd.update(password.getBytes());\n\t\t\tbyte[] digest = md.digest();\n\t\t\tStringBuffer sb = new StringBuffer();\n\t\t\tfor (byte b : digest) {\n\t\t\t\tsb.append(String.format(\"%02x\", b & 0xff));\n\t\t\t}\n\t\t\thashedPassword = sb.toString();\n\t\t} catch (NoSuchAlgorithmException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\n\t\treturn hashedPassword;\n\t}", "public static byte[] MD5(String ran, String strKey){\n \n \tString clientSecretKey = ran + strKey;\n MessageDigest m = null;\n \n try {\n \t\n m = MessageDigest.getInstance(\"MD5\");\n \n } \n catch (NoSuchAlgorithmException ex) {\n \t\n ex.printStackTrace();\n \n }\n \n m.reset();\n m.update(clientSecretKey.getBytes());\n byte[] digest = m.digest();\n \n return digest;\n \n }", "public String getHmacMD5(String privateKey, String input) throws Exception {\n String algorithm = \"HmacSHA256\";\n String Ret=\"\";\n byte[] keyBytes = Base64.decode(privateKey, Base64.NO_WRAP);\n Key key = new SecretKeySpec(keyBytes, 0, keyBytes.length, algorithm);\n Mac mac = Mac.getInstance(algorithm);\n mac.init(key);\n\n\n\n try {\n\n\n byte[] bytes = mac.doFinal(input.getBytes(\"UTF-8\"));\n\n Ret= Base64.encodeToString(bytes, Base64.URL_SAFE| Base64.NO_WRAP).replace('-','+').replace('_', '/');;\n\n }\n catch(Exception e)\n {\n\n }\n return Ret;\n }", "public static String getHashString(String inputString) {\n MessageDigest md;\n byte[] hash;\n try {\n md = MessageDigest.getInstance(\"MD5\");\n } catch (java.security.NoSuchAlgorithmException e) {\n throw new RuntimeException(e);\n }\n try {\n hash = md.digest(inputString.getBytes(\"UTF-8\"));\n } catch (java.io.UnsupportedEncodingException e) {\n throw new RuntimeException(e);\n }\n StringBuilder sb = new StringBuilder();\n for(byte b : hash){\n sb.append(String.format(\"%02x\", b & 0xff));\n }\n return sb.toString();\n }", "private static String CalHash(byte[] passSalt) throws NoSuchAlgorithmException, UnsupportedEncodingException {\n //get the instance value corresponding to Algorithm selected\n MessageDigest key = MessageDigest.getInstance(\"SHA-256\");\n //Reference:https://stackoverflow.com/questions/415953/how-can-i-generate-an-md5-hash\n //update the digest using specified array of bytes\n key.update(passSalt);\n String PassSaltHash = javax.xml.bind.DatatypeConverter.printHexBinary(key.digest());\n return PassSaltHash;\n }", "public static String str2MD5(String strs) {\n StringBuffer sb = new StringBuffer();\n try {\n MessageDigest digest = MessageDigest.getInstance(\"MD5\");\n byte[] bs = digest.digest(strs.getBytes());\n /*\n * after encryption is -128 to 127 ,is not safe\n * use it to binary operation,get new encryption result\n *\n * 0000 0011 0000 0100 0010 0000 0110 0001\n * &0000 0000 0000 0000 0000 0000 1111 1111\n * ---------------------------------------------\n * 0000 0000 0000 0000 0000 0000 0110 0001\n *\n * change to 16 bit\n */\n for (byte b : bs) {\n int x = b & 255;\n String s = Integer.toHexString(x);\n if (x < 16) {\n sb.append(\"0\");\n }\n sb.append(s);\n }\n\n } catch (Exception e) {\n System.out.println(\"encryption lose\");\n }\n return sb.toString();\n }", "public static String fileMD5(File file) {\n\t\tFileInputStream fis = null;\n\t\tString md5 = null;\n\t\ttry {\n\t\t\tfis = new FileInputStream(file);\n\t\t\tmd5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);\n\t\t} catch (Exception e) {\n\t\t\tlogger.error(\"!!!\", e);\n\t\t} finally {\n\t\t\tCloseUtils.close(fis);\n\t\t}\n\t\treturn md5;\n\t}", "public static void main(String[] args) {\n Scanner in=new Scanner(System.in);\n String str=in.next();\n try\n {\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n byte[] bytes=md.digest(str.getBytes());\n \n for(byte b:bytes)\n System.out.format(\"%02x\",b);\n }\n catch(Exception e)\n {\n System.out.print(e);\n }\n }", "private String m34493b(String str) {\n MessageDigest a = m34492a(\"MD5\");\n a.update(str.getBytes(\"UTF-8\"));\n return m34494b(a.digest());\n }", "public HashCode getInstallMD5() {\n return installMD5;\n }", "String getMessageDigestAlgorithm();", "byte[] getDigest();", "public static String getFileMD5(File file) {\n if (!file.isFile()) {\n return null;\n }\n MessageDigest digest = null;\n FileInputStream in = null;\n byte buffer[] = new byte[1024];\n int len;\n try {\n digest = MessageDigest.getInstance(\"MD5\");\n in = new FileInputStream(file);\n while ((len = in.read(buffer, 0, 1024)) != -1) {\n digest.update(buffer, 0, len);\n }\n in.close();\n } catch (Exception e) {\n e.printStackTrace();\n return null;\n }\n BigInteger bigInt = new BigInteger(1, digest.digest());\n String md5 = bigInt.toString(16);\n while (md5.length() < 32)\n md5 = \"0\" + md5;\n return md5;\n }", "public static String fileMD5(String filePath) {\n\t\tFileInputStream fis = null;\n\t\tString md5 = null;\n\t\ttry {\n\t\t\tfis = new FileInputStream(new File(filePath));\n\t\t\tmd5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);\n\t\t} catch (Exception e) {\n\t\t\tlogger.error(\"!!!\", e);\n\t\t} finally {\n\t\t\tCloseUtils.close(fis);\n\t\t}\n\t\treturn md5;\n\t}", "String getDigestAlgorithm();", "public static String encode(String mdp)\n\t {\n\t byte[] uniqueKey = mdp.getBytes();\n\t byte[] hash = null;\n\n\t try\n\t {\n\t hash = MessageDigest.getInstance(\"MD5\").digest(uniqueKey);\n\t }\n\t catch (NoSuchAlgorithmException e)\n\t {\n\t throw new Error(\"No MD5 support in this VM.\");\n\t }\n\n\t StringBuilder hashString = new StringBuilder();\n\t for (int i = 0; i < hash.length; i++)\n\t {\n\t String hex = Integer.toHexString(hash[i]);\n\t if (hex.length() == 1)\n\t {\n\t hashString.append('0');\n\t hashString.append(hex.charAt(hex.length() - 1));\n\t }\n\t else\n\t hashString.append(hex.substring(hex.length() - 2));\n\t }\n\t return hashString.toString();\n\t }", "String getHashAlgorithm();", "public static byte[] createCheckSum(String filename) throws Exception {\n InputStream fis = new FileInputStream(filename);\n\n byte[] buffer = new byte[1024];\n MessageDigest complete = MessageDigest.getInstance(\"MD5\");\n int numRead;\n\n do {\n numRead = fis.read(buffer);\n if (numRead > 0) {\n complete.update(buffer, 0, numRead);\n }\n } while (numRead != -1);\n\n fis.close();\n // Return MD5 Hash\n return complete.digest();\n }", "private String hash(){\r\n return Utility.SHA512(this.simplify());\r\n }" ]
[ "0.72823936", "0.7183827", "0.71283203", "0.7111088", "0.7109806", "0.7102342", "0.70842934", "0.7045143", "0.7041112", "0.7037299", "0.7009485", "0.7000036", "0.69935995", "0.69681096", "0.6952754", "0.69463855", "0.6944541", "0.68718237", "0.686376", "0.68367064", "0.6782048", "0.6734538", "0.67273295", "0.6721291", "0.6712122", "0.67013025", "0.6632169", "0.6628786", "0.662349", "0.66216594", "0.6621442", "0.660651", "0.659823", "0.6573534", "0.6551102", "0.65331644", "0.64918745", "0.6485947", "0.64636683", "0.6462896", "0.6461542", "0.6423822", "0.6420434", "0.6399891", "0.63855326", "0.6374092", "0.6353992", "0.6348888", "0.6341772", "0.63331544", "0.6326416", "0.6321778", "0.6288471", "0.6250392", "0.6237735", "0.6227559", "0.62074846", "0.62071085", "0.61988145", "0.61695683", "0.6142659", "0.6137107", "0.61138", "0.61007047", "0.6099671", "0.60911405", "0.60853136", "0.60721993", "0.60701627", "0.6068818", "0.60268605", "0.6018146", "0.5989705", "0.5977175", "0.5955067", "0.59523517", "0.5946286", "0.59147865", "0.59030104", "0.58968645", "0.5893296", "0.587676", "0.5870816", "0.58570856", "0.58539367", "0.58522564", "0.58405817", "0.5836493", "0.58314335", "0.5828039", "0.58238745", "0.57886815", "0.57794833", "0.577932", "0.57574147", "0.57466084", "0.57358253", "0.57245237", "0.5708956", "0.5693793" ]
0.7276599
1
generates an MD5 file hash, like an file checksum
public static String computeMD5FileHash (File file) throws Exception { byte[] b = createFileChecksum(file); String result = ""; for (int i=0; i < b.length; i++) { result += Integer.toString( ( b[i] & 0xff ) + 0x100, 16).substring( 1 ); } return result; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private String getFileMd5Checksum(String filename){\n\t\ttry {\n\t\t\tbyte[] fileBytes = Files.readAllBytes(Paths.get(FILES_ROOT + filename));\n\t\t\tbyte[] fileHash = MessageDigest.getInstance(\"MD5\").digest(fileBytes);\n\n\t\t\treturn DatatypeConverter.printHexBinary(fileHash);\n\t\t} catch (IOException e) {\n\t\t\t// TODO: Handle file doesn't exist\n\t\t\treturn \"\";\n\t\t} catch (Exception e) {\n\t\t\treturn \"\";\n\t\t}\n\t}", "private static String getMD5Checksum(String filename) throws Exception {\r\n\t\tbyte[] b = createChecksum(filename);\r\n\t\tStringBuilder result = new StringBuilder();\r\n\t\tfor (byte v : b) {\r\n\t\t\tresult.append(Integer.toString((v & 0xff) + 0x100, 16).substring(1));\r\n\t\t}\r\n\t\treturn result.toString();\r\n\t}", "static String generateChecksum(String filename) {\n\n try {\n // Instantiating file and Hashing Algorithm.\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n FileInputStream file = new FileInputStream(filename);\n\n // Generation of checksum.\n byte[] dataBytes = new byte[1024];\n int nread;\n\n while ((nread = file.read(dataBytes)) != -1) {\n md.update(dataBytes, 0, nread);\n }\n\n byte[] mdbytes = md.digest();\n\n // Convert byte to hex.\n StringBuilder hexString = new StringBuilder();\n\n for (byte mdbyte : mdbytes) {\n String hex = Integer.toHexString(0xff & mdbyte);\n if (hex.length() == 1) hexString.append('0');\n hexString.append(hex);\n }\n\n // Return checksum as completed string.\n return hexString.toString();\n\n } catch (NoSuchAlgorithmException | IOException e) {\n e.printStackTrace();\n }\n return null;\n }", "public static String computeMD5(String filename) throws Exception {\r\n byte[] b = createGenericChecksum(filename, 0);\r\n String result = \"\";\r\n for (int i = 0; i < b.length; i++) {\r\n result += Integer.toString((b[i] & 0xff) + 0x100, 16).substring(1);\r\n }\r\n return result;\r\n }", "private static String getFileChecksum(File file) throws IOException, NoSuchAlgorithmException {\n FileInputStream fis = new FileInputStream(file);\n\n // Use MD5 algorithm\n MessageDigest digest = MessageDigest.getInstance(\"MD5\");\n\n // Create byte array to read data in chunks\n byte[] byteArray = new byte[1024];\n int bytesCount = 0;\n\n // Read file data and update in message digest\n while ((bytesCount = fis.read(byteArray)) != -1) {\n digest.update(byteArray, 0, bytesCount);\n }\n ;\n\n // close the stream; We don't need it now.\n fis.close();\n\n // Get the hash's bytes\n byte[] bytes = digest.digest();\n\n // This bytes[] has bytes in decimal format;\n // Convert it to hexadecimal format\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < bytes.length; i++) {\n sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));\n }\n\n // return complete hash\n return sb.toString();\n }", "protected void md5file(File file) throws IOException {\n if (file.isDirectory()) {\n throw new IllegalArgumentException(\"Only files can be check summed !\");\n }\n\n // calculating the output\n byte[] md5 = DigestUtils.md5(new FileInputStream(file));\n\n // getting the output file\n File outputFile = new File(file.getAbsolutePath() + \".md5\");\n Files.write(Paths.get(outputFile.getAbsolutePath()), md5);\n\n }", "public static String getFileMD5(File file) {\n\t\tMessageDigest messageDigest = null;\n\t\tFileInputStream fileInStream = null;\n\t\tbyte buffer[] = new byte[1024];\n\t\tint length = -1;\n\t\ttry {\n\t\t\tmessageDigest = MessageDigest.getInstance(\"MD5\");\n\t\t\tfileInStream = new FileInputStream(file);\n\t\t\twhile ((length = fileInStream.read(buffer, 0, 1024)) != -1) {\n\t\t\t\tmessageDigest.update(buffer, 0, length);\n\t\t\t}\n\t\t\tfileInStream.close();\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t\treturn null;\n\t\t}\n\t\tBigInteger bigInt = new BigInteger(1, messageDigest.digest());\n\t\treturn bigInt.toString(16);\n\t}", "public static byte[] createCheckSum(String filename) throws Exception {\n InputStream fis = new FileInputStream(filename);\n\n byte[] buffer = new byte[1024];\n MessageDigest complete = MessageDigest.getInstance(\"MD5\");\n int numRead;\n\n do {\n numRead = fis.read(buffer);\n if (numRead > 0) {\n complete.update(buffer, 0, numRead);\n }\n } while (numRead != -1);\n\n fis.close();\n // Return MD5 Hash\n return complete.digest();\n }", "public static String createMd5(String value)\r\n\t{ \r\n\t\ttry \r\n\t\t{\r\n\t\t\tMessageDigest md = MessageDigest.getInstance(\"MD5\");\t\t\t\r\n\t\t\tbyte[] hashInBytes = md.digest(value.getBytes(StandardCharsets.UTF_8));\r\n\t\t\tStringBuilder sb = new StringBuilder();\r\n\t for (byte b : hashInBytes) \r\n\t {\r\n\t sb.append(String.format(\"%02x\", b));\r\n\t }\r\n\t return sb.toString();\r\n\t\t}\r\n\t\tcatch(Exception ex)\r\n\t\t{\r\n\t\t\t\r\n\t\t}\r\n\t\treturn \"\";\r\n\t}", "public static String md5(String inputFile) {\r\n String md5 = null;\r\n logger.debug(\"Start to calculate hashcode (SHA1) for {}\", inputFile);\r\n try (DigestInputStream digestIn = new DigestInputStream(new FileInputStream(inputFile),\r\n MessageDigest.getInstance(\"SHA1\"))) {\r\n byte[] buffer = new byte[1024 * 1024];\r\n while (digestIn.read(buffer) > 0) {\r\n // do nothing\r\n }\r\n md5 = toHexString(digestIn.getMessageDigest().digest());\r\n } catch (NoSuchAlgorithmException | IOException e) {\r\n logger.warn(\"Fail to md5 for {} ({})\", inputFile, e.getMessage());\r\n }\r\n logger.debug(\"End to calculate hashcode (SHA1) for {}, {}\", inputFile, md5);\r\n return md5;\r\n }", "public static String fileMD5(File file) {\n\t\tFileInputStream fis = null;\n\t\tString md5 = null;\n\t\ttry {\n\t\t\tfis = new FileInputStream(file);\n\t\t\tmd5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);\n\t\t} catch (Exception e) {\n\t\t\tlogger.error(\"!!!\", e);\n\t\t} finally {\n\t\t\tCloseUtils.close(fis);\n\t\t}\n\t\treturn md5;\n\t}", "public static String getMD5(File file) throws IOException, NoSuchAlgorithmException {\n return getChecksum(file, MessageDigest.getInstance(\"MD5\"));\n }", "public static String getFileMD5(File file) {\n if (!file.isFile()) {\n return null;\n }\n MessageDigest digest = null;\n FileInputStream in = null;\n byte buffer[] = new byte[1024];\n int len;\n try {\n digest = MessageDigest.getInstance(\"MD5\");\n in = new FileInputStream(file);\n while ((len = in.read(buffer, 0, 1024)) != -1) {\n digest.update(buffer, 0, len);\n }\n in.close();\n } catch (Exception e) {\n e.printStackTrace();\n return null;\n }\n BigInteger bigInt = new BigInteger(1, digest.digest());\n String md5 = bigInt.toString(16);\n while (md5.length() < 32)\n md5 = \"0\" + md5;\n return md5;\n }", "public String getMD5() {\n return hash;\n }", "public static String getFileMD5(String path) {\n\t\treturn getFileMD5(new File(path));\n\t}", "public static String md5(String pass)\n {\n try{\n MessageDigest md=MessageDigest.getInstance(\"MD5\");\n byte[] messageDigest=md.digest(pass.getBytes());\n BigInteger num=new BigInteger(1,messageDigest);\n String hashText=num.toString(16);\n while(hashText.length()<32)\n {\n hashText=\"0\"+hashText;\n } \n return hashText; \n }\n catch(Exception e)\n { \n throw new RuntimeException(e);\n } \n }", "@Test\n public void md5Checksum() throws NoSuchAlgorithmException {\n String string = Utils.md5Checksum(\"abcde fghijk lmn op\");\n Assert.assertEquals(\"1580420c86bbc3b356f6c40d46b53fc8\", string);\n }", "public static String getMd5(String input) {\n try {\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n\n byte[] messageDigest = md.digest(input.getBytes());\n\n BigInteger no = new BigInteger(1, messageDigest);\n\n String hashtext = no.toString(16);\n while (hashtext.length() < 32) {\n hashtext = \"0\" + hashtext;\n }\n return hashtext;\n } catch (NoSuchAlgorithmException e) {\n throw new RuntimeException(e);\n }\n }", "public static String fileMD5(String filePath) {\n\t\tFileInputStream fis = null;\n\t\tString md5 = null;\n\t\ttry {\n\t\t\tfis = new FileInputStream(new File(filePath));\n\t\t\tmd5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);\n\t\t} catch (Exception e) {\n\t\t\tlogger.error(\"!!!\", e);\n\t\t} finally {\n\t\t\tCloseUtils.close(fis);\n\t\t}\n\t\treturn md5;\n\t}", "public static void md5(File outputFile) throws ConverterException {\r\n\t\ttry {\r\n\t\t\tFileInputStream fileInputStream = new FileInputStream(outputFile);\r\n\t\t\tBufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);\r\n\t\t\t\r\n\t\t\tbyte[] datei = bufferedInputStream.readAllBytes();\r\n\t\t\tMessageDigest md = MessageDigest.getInstance(\"MD5\");\r\n\t\t\tbyte[] md5 = md.digest(datei);\r\n\t\t\tfor (int i = 0; i < md5.length; i++) {\r\n\t\t\t\tSystem.out.print(String.format(\"%02X\", md5[i]));\r\n\t\t\t}\r\n\t\t\tSystem.out.println(\" File Length: \" + outputFile.length());\r\n\t\t\tSystem.out.println();\r\n\t\t\t\r\n\t\t\tbufferedInputStream.close();\r\n\t\t\tfileInputStream.close();\r\n\t\t} catch (FileNotFoundException e) {\r\n\t\t\tthrow new ConverterException(\"Datei kann nicht gefunden werden\");\r\n\t\t} catch (IOException e) {\r\n\t\t\tthrow new ConverterException(\"Beim Lesen der Datei ist ein Fehler aufgetreten\");\r\n\t\t} catch (NoSuchAlgorithmException e) {\r\n\t\t\t// TODO Auto-generated catch block\r\n\t\t\te.printStackTrace();\r\n\t\t}\r\n\t}", "private static String md5(final String s) {\n final String MD5 = \"MD5\";\n try {\n // Create MD5 Hash\n MessageDigest digest = java.security.MessageDigest\n .getInstance(MD5);\n digest.update(s.getBytes());\n byte messageDigest[] = digest.digest();\n\n // Create Hex String\n StringBuilder hexString = new StringBuilder();\n for (byte aMessageDigest : messageDigest) {\n String h = Integer.toHexString(0xFF & aMessageDigest);\n while (h.length() < 2)\n h = \"0\" + h;\n hexString.append(h);\n }\n return hexString.toString();\n\n } catch (NoSuchAlgorithmException e) {\n e.printStackTrace();\n }\n return \"\";\n }", "public static byte[] computeMD5Hash(byte[] data) throws NoSuchAlgorithmException, IOException {\n return computeMD5Hash(new ByteArrayInputStream(data));\n }", "protected String getMd5Hash(String token) {\n\n MessageDigest m;\n\t\ttry {\n\t\t\tm = MessageDigest.getInstance(\"MD5\");\n\t\t} catch (NoSuchAlgorithmException e) {\n\t\t\tthrow new IllegalStateException(e);\n\t\t}\n m.update(token.getBytes());\n \n byte[] digest = m.digest();\n BigInteger bigInt = new BigInteger(1,digest);\n String hashtext = bigInt.toString(16);\n \n // Now we need to zero pad it if you actually want the full 32 chars.\n while(hashtext.length() < 32 ){\n hashtext = \"0\"+hashtext;\n }\n \n return hashtext;\n\t}", "public String md5(String s) {\n try {\n // Create MD5 Hash\n MessageDigest digest = java.security.MessageDigest.getInstance(\"MD5\");\n digest.update(s.getBytes());\n byte messageDigest[] = digest.digest();\n\n // Create Hex String\n StringBuffer hexString = new StringBuffer();\n for (int i = 0; i < messageDigest.length; i++)\n hexString.append(Integer.toHexString(0xFF & messageDigest[i]));\n return hexString.toString();\n\n } catch (NoSuchAlgorithmException e) {\n e.printStackTrace();\n }\n return \"\";\n }", "public static String md5(String message) {\n String digest = null;\n try {\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n byte[] hash = md.digest(message.getBytes(\"UTF-8\"));\n\n //converting byte array to HexadecimalString\n StringBuilder sb = new StringBuilder(2 * hash.length);\n for (byte b : hash) {\n sb.append(String.format(\"%02x\", b & 0xff));\n }\n digest = sb.toString();\n } catch (UnsupportedEncodingException ex) {\n log.error(\"UnsupportedEncodingException\",ex);\n } catch (NoSuchAlgorithmException ex) {\n log.error(\"NoSuchAlgorithmException\",ex);\n }\n\n return digest;\n }", "private String md5(final String s)\n\t{\n\t\ttry {\n\t\t\t// Create MD5 Hash\n\t\t\tMessageDigest digest = MessageDigest.getInstance(\"MD5\");\n\t\t\tdigest.update(s.getBytes());\n\t\t\tbyte messageDigest[] = digest.digest();\n\n\t\t\t// Create Hex String\n\t\t\tStringBuffer hexString = new StringBuffer();\n\t\t\tfor (int i=0; i<messageDigest.length; i++) {\n\t\t\t\tString h = Integer.toHexString(0xFF & messageDigest[i]);\n\t\t\t\twhile (h.length() < 2) h = \"0\" + h;\n\t\t\t\thexString.append(h);\n\t\t\t}\n\t\t\treturn hexString.toString();\n\t\t} catch(NoSuchAlgorithmException e) {\n\t\t\t//Logger.logStackTrace(TAG,e);\n\t\t}\n\t\treturn \"\";\n\t}", "public static byte[] computeMD5Hash(InputStream is) throws NoSuchAlgorithmException, IOException {\n BufferedInputStream bis = new BufferedInputStream(is);\n try {\n MessageDigest messageDigest = MessageDigest.getInstance(\"MD5\");\n byte[] buffer = new byte[16384];\n int bytesRead = -1;\n while ((bytesRead = bis.read(buffer, 0, buffer.length)) != -1) {\n messageDigest.update(buffer, 0, bytesRead);\n }\n return messageDigest.digest();\n } finally {\n try {\n bis.close();\n } catch (Exception e) {\n System.err.println(\"Unable to close input stream of hash candidate: \" + e);\n }\n }\n }", "public static String computeMD5Hash(String password) {\n StringBuffer MD5Hash = new StringBuffer();\n\n try {\n // Create MD5 Hash\n MessageDigest digest = MessageDigest.getInstance(\"MD5\");\n digest.update(password.getBytes());\n byte messageDigest[] = digest.digest();\n\n for (int i = 0; i < messageDigest.length; i++)\n {\n String h = Integer.toHexString(0xFF & messageDigest[i]);\n while (h.length() < 2)\n h = \"0\" + h;\n MD5Hash.append(h);\n }\n\n }\n catch (NoSuchAlgorithmException e)\n {\n e.printStackTrace();\n }\n\n return MD5Hash.toString();\n }", "private static String md5(byte[] b) {\n try {\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n md.reset();\n md.update(b);\n byte[] digest = md.digest();\n StringBuffer sb = new StringBuffer();\n for (int i=0; i<digest.length; i++) {\n String a = Integer.toHexString(0xff & digest[i]);\n if (a.length() == 1) a = \"0\" + a;\n sb.append(a);\n }\n return sb.toString();\n }\n catch (NoSuchAlgorithmException e) { writeLog(e); }\n return null;\n }", "private static String getFileChecksum(MessageDigest digest, File file) throws IOException\n\t {\n\t FileInputStream fis = new FileInputStream(file);\n\t \n\t //Create byte array to read data in chunks\n\t byte[] byteArray = new byte[1024];\n\t int bytesCount = 0;\n\t \n\t //Read file data and update in message digest\n\t while ((bytesCount = fis.read(byteArray)) != -1) {\n\t digest.update(byteArray, 0, bytesCount);\n\t };\n\t \n\t //close the stream; We don't need it now.\n\t fis.close();\n\t \n\t //Get the hash's bytes\n\t byte[] bytes = digest.digest();\n\t \n\t //This bytes[] has bytes in decimal format;\n\t //Convert it to hexadecimal format\n\t StringBuilder sb = new StringBuilder();\n\t for(int i=0; i< bytes.length ;i++)\n\t {\n\t sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));\n\t }\n\t \n\t //return complete hash\n\t return sb.toString();\n\t }", "public static String getMD5(String s) {\n try {\n MessageDigest m = MessageDigest.getInstance(\"MD5\");\n m.update(s.getBytes(), 0, s.length());\n return \"\" + new BigInteger(1, m.digest()).toString(16);\n } catch (NoSuchAlgorithmException e) {\n logger.error(\"MD5 is not supported !!!\");\n }\n return s;\n }", "private static byte[] generateMD5(String info) throws\n UnsupportedEncodingException, NoSuchAlgorithmException {\n byte[] inputData = info.getBytes(\"UTF-8\");\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n md.update(inputData);\n byte[] digest= md.digest();\n return digest;\n }", "private String md5(String input) {\r\n\t\tString md5 = null;\r\n\t\tif (null == input)\r\n\t\t\treturn null;\r\n\r\n\t\ttry {\r\n\t\t\tMessageDigest digest = MessageDigest.getInstance(\"MD5\");\r\n\t\t\tdigest.update(input.getBytes(), 0, input.length());\r\n\t\t\tmd5 = new BigInteger(1, digest.digest()).toString(16);\r\n\t\t} catch (NoSuchAlgorithmException e) {\r\n\r\n\t\t\te.printStackTrace();\r\n\t\t}\r\n\t\treturn md5;\r\n\t}", "public static String getMD5Hash(String string) {\r\n\t\tMessageDigest digest;\r\n\t\ttry {\r\n\t\t\tdigest = java.security.MessageDigest.getInstance(\"MD5\");\r\n\t\t\tdigest.update(string.getBytes());\r\n\t\t\tfinal byte[] hash = digest.digest();\r\n\t\t\tfinal StringBuilder result = new StringBuilder(hash.length);\r\n\t\t\tfor (int i = 0; i < hash.length; i++) {\r\n\t\t\t\tresult.append(Integer.toString((hash[i] & 0xff) + 0x100, 16)\r\n\t\t\t\t\t\t.substring(1));\r\n\t\t\t}\r\n\t\t\treturn result.toString();\r\n\t\t} catch (final NoSuchAlgorithmException e) {\r\n\t\t\te.printStackTrace();\r\n\t\t\treturn \"error\";\r\n\t\t}\r\n\t}", "private static String getFileChecksum(MessageDigest digest, File file) throws IOException {\n FileInputStream fis = new FileInputStream(file);\n\n //Create byte array to read data in chunks\n byte[] byteArray = new byte[1024];\n int bytesCount = 0;\n\n //Read file data and update in message digest\n while ((bytesCount = fis.read(byteArray)) != -1) {\n digest.update(byteArray, 0, bytesCount);\n }\n\n //close the stream; We don't need it now.\n fis.close();\n\n //Get the hash's bytes\n byte[] bytes = digest.digest();\n\n //This bytes[] has bytes in decimal format;\n //Convert it to hexadecimal format\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < bytes.length; i++) {\n sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));\n }\n\n //return complete hash\n return sb.toString();\n }", "private String toMD5(String password)\n {\n try {\n MessageDigest m = MessageDigest.getInstance(\"MD5\");\n \n m.update(password.getBytes(),0,password.length());\n \n return new BigInteger(1, m.digest()).toString(16);\n } catch (NoSuchAlgorithmException ex) {\n Logger.getLogger(User.class.getName()).log(Level.SEVERE, null, ex);\n }\n return \"\";\n }", "public static String getMD5Sum(String variable) throws NoSuchAlgorithmException{\t\n\t\tMessageDigest md=MessageDigest.getInstance(\"MD5\");\n\t\tmd.update(variable.getBytes());\n\t\treturn new BigInteger(1,md.digest()).toString(16);\n\t}", "public String MD5(String md5) {\n try {\n java.security.MessageDigest md = java.security.MessageDigest.getInstance(\"MD5\");\n byte[] array = md.digest(md5.getBytes());\n StringBuffer sb = new StringBuffer();\n for (int i = 0; i < array.length; ++i) {\n sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3));\n }\n return sb.toString();\n } catch (java.security.NoSuchAlgorithmException e) {\n }\n return null;\n }", "public String getMD5() {\n return m_module.getConfiguration().getMD5();\n }", "public static String calcHash(String input) {\n try {\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n md.update(input.toLowerCase().getBytes(\"UTF8\"));\n byte[] digest = md.digest();\n StringBuilder sb = new StringBuilder();\n for (byte b : digest) {\n sb.append(hexDigit(b>>4));\n sb.append(hexDigit(b));\n }\n return sb.toString();\n } catch (Exception ex) {\n throw new RuntimeException(ex.getMessage(), ex);\n }\n }", "@Test\n public void fileMd5Test() {\n // TODO: test fileMd5\n }", "protected static String md5(final String string) {\n try {\n final MessageDigest m = MessageDigest.getInstance(\"MD5\");\n m.update(string.getBytes(), 0, string.length());\n return new BigInteger(1, m.digest()).toString(16);\n } catch (NoSuchAlgorithmException e) {\n return \"\";\n }\n }", "private String md5(String message) throws java.security.NoSuchAlgorithmException\n\t{\n\t\tMessageDigest md5 = null;\n\t\ttry {\n\t\t\tmd5 = MessageDigest.getInstance(\"MD5\");\n\t\t}\n\t\tcatch (java.security.NoSuchAlgorithmException ex) {\n\t\t\tex.printStackTrace();\n\t\t\tthrow ex;\n\t\t}\n\t\tbyte[] dig = md5.digest((byte[]) message.getBytes());\n\t\tStringBuffer code = new StringBuffer();\n\t\tfor (int i = 0; i < dig.length; ++i)\n\t\t{\n\t\t\tcode.append(Integer.toHexString(0x0100 + (dig[i] & 0x00FF)).substring(1));\n\t\t}\n\t\treturn code.toString();\n\t}", "public String getMd5Hash() {\n return md5Hash;\n }", "public String getMD5ForGame(String gameId) {\n return \"TODO\";\n }", "com.google.protobuf.ByteString getFileHash();", "com.google.protobuf.ByteString getFileHash();", "public String getMD5(String txt){\n String md5output;\n md5output = txt;\n try {\n MessageDigest m = MessageDigest.getInstance(\"MD5\");\n m.reset();\n m.update(md5output.getBytes());\n byte[] digest = m.digest();\n BigInteger bigInt = new BigInteger(1,digest);\n md5output = bigInt.toString(16);\n } catch (Exception e) {\n md5output = null;\n } finally{\n return md5output;\n }\n \n }", "java.lang.String getChecksum();", "public static String md5(String str) {\n MessageDigest messageDigest = null;\n try {\n messageDigest = MessageDigest.getInstance(\"MD5\");\n messageDigest.reset();\n messageDigest.update(str.getBytes(\"UTF-8\"));\n } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {\n // do nothing\n }\n byte[] byteArray = messageDigest.digest();\n StringBuffer md5StrBuff = new StringBuffer();\n for (int i = 0; i < byteArray.length; i++) {\n if (Integer.toHexString(0xFF & byteArray[i]).length() == 1)\n md5StrBuff.append(\"0\").append(Integer.toHexString(0xFF & byteArray[i]));\n else\n md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i]));\n }\n return md5StrBuff.toString();\n }", "public static String hash(String in) {\r\n\t\treturn DigestUtils.md5Hex(in.getBytes());\r\n\t}", "public byte[] MD5(File archivo) throws OpenSSL_Exception {\n\t\tString[] comando = new String[]{ \"openssl\" , \"dgst\" , \"-md5\" , archivo.getAbsolutePath()};\n\t\tProcess terminal = null;\n\t\ttry { terminal = Runtime.getRuntime().exec(comando); } catch (IOException e) { \n\t\t\tthrow new OpenSSL_Exception(\"No se puede ejecutar el comando en el terminal\");\n\t\t}\n\t\t// --- > Leemos la salida error del comando\n\t\tBufferedReader errors = new BufferedReader(new InputStreamReader(terminal.getErrorStream()));\n\t\tString linea = \"\" , error = \"\" ;\n\t\ttry { while( (linea = errors.readLine()) != null) error += linea + \"\\n\"; } catch (IOException e) {\n\t\t\tthrow new OpenSSL_Exception(\"No se puede leer el error que ha producido el comando\");\n\t\t}\n\t\t// --- > Si hubo salida error lanzamos al excepcion con el error\n\t\tif(!error.equals(\"\"))throw new OpenSSL_Exception(\"Error al ejecutar el comando:\\n\" + error );\n\t\t// --- > Leemos el resultado obtenido\n\t\tBufferedReader in = new BufferedReader(new InputStreamReader(terminal.getInputStream()));\n\t\tString res = \"\";\n\t\ttry { while((linea = in.readLine()) != null) res += linea; } catch (IOException e) {\n\t\t\tthrow new OpenSSL_Exception(\"No se puede leer el resultado que ha producido el comando\");\n\t\t}\n\t\treturn res.substring(res.lastIndexOf(\" \") + 1 ).getBytes();\n\t}", "public String md5(String md5StringInput) {\n try {\n java.security.MessageDigest md = java.security.MessageDigest.getInstance(\"MD5\");\n byte[] array = md.digest(md5StringInput.getBytes());\n StringBuffer sb = new StringBuffer();\n for (int i = 0; i < array.length; ++i) {\n sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3));\n }\n return sb.toString();\n } catch (java.security.NoSuchAlgorithmException e) {\n }\n return null;\n }", "public static String md5(final String data) {\n return ByteString.encodeUtf8(data).md5().hex().toLowerCase();\n }", "public static byte[] encryptMD5(final byte[] data) {\n return hashTemplate(data, \"MD5\");\n }", "public byte[] getMD5() {\n return MD5;\n }", "public static String encryptMD5(String st) {\n MessageDigest messageDigest;\n byte[] digest = new byte[0];\n try {\n messageDigest = MessageDigest.getInstance(DefaultValueConstants.DEFAULT_ENCRYPTING_ALGORITHM);\n messageDigest.reset();\n messageDigest.update(st.getBytes());\n digest = messageDigest.digest();\n } catch (NoSuchAlgorithmException e) {\n log.error(e);\n }\n BigInteger bigInt = new BigInteger(1, digest);\n String md5Hex = bigInt.toString(16);\n while (md5Hex.length() < 32) {\n md5Hex = \"0\" + md5Hex;\n }\n return md5Hex;\n }", "public static String md5(String password){\n byte[] data = messageDigest.digest(password.getBytes());\n return byteToHex(data);\n }", "public static String CreateMD5(File file) {\n String base64Image = \"\";\n try (FileInputStream imageInFile = new FileInputStream(file)) {\n // Reading a Image file from file system\n byte imageData[] = new byte[(int) file.length()];\n imageInFile.read(imageData);\n base64Image = Base64.getEncoder().encodeToString(imageData);\n } catch (FileNotFoundException e) {\n DialogWindow.ShowErrorPane(\"Image could not be found.\", \"Error Image Missing\");\n// System.out.println(\"Image not found\" + e);\n } catch (IOException ioe) {\n DialogWindow.ShowErrorPane(\"Error while the image was being converted.\", \"Error Converting Image\");\n// System.out.println(\"Exception while reading the Image \" + ioe);\n }\n return base64Image;\n }", "public MD5Hash(String s) {\n\t\tif(s.length() != 32) throw new IllegalArgumentException(\"Hash must have 32 characters\");\n\t\thashString = s;\n\t}", "public String getMD5Checksum(String pid, String dsName) throws FedoraException, IOException {\r\n try {\r\n return getDatastreamProperty(pid, dsName, DatastreamProfile.DatastreamProperty.DS_CHECKSUM);\r\n } catch (XPathExpressionException ex) {\r\n throw new FedoraException(ex);\r\n } catch (SAXException ex) {\r\n throw new FedoraException(ex);\r\n } catch (ParserConfigurationException ex) {\r\n throw new FedoraException(ex);\r\n }\r\n }", "private static String MD5Password(String password) {\n String md = org.apache.commons.codec.digest.DigestUtils.md5Hex(password);\n return md;\n }", "public static MessageDigest getMessageDigest ()\n {\n try {\n return MessageDigest.getInstance(\"MD5\");\n } catch (NoSuchAlgorithmException nsae) {\n throw new RuntimeException(\"JVM does not support MD5. Gurp!\");\n }\n }", "public static String getStringMD5(String src) {\n\t\tMessageDigest messageDigest = null;\n\t\tbyte[] srcBytes = src.getBytes();\n\t\ttry {\n\t\t\tmessageDigest = MessageDigest.getInstance(\"MD5\");\n\t\t} catch (NoSuchAlgorithmException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tmessageDigest.update(srcBytes, 0, srcBytes.length);\n\t\tBigInteger bigInt = new BigInteger(1, messageDigest.digest());\n\t\treturn bigInt.toString(16);\n\t}", "public static String getMD5(String string) throws NoSuchAlgorithmException, IOException {\n MessageDigest md5;\n md5 = MessageDigest.getInstance(\"MD5\");\n\n try (DigestInputStream stream = new DigestInputStream(new ByteArrayInputStream(string.getBytes()), md5)) {\n byte[] buffer = new byte[8192];\n while (true) {\n if ((stream.read(buffer) == -1)) break;\n }\n StringBuilder sb = new StringBuilder();\n for (byte b : md5.digest()) {\n sb.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));\n }\n return sb.toString();\n }\n }", "private static java.security.MessageDigest f() {\n /*\n r0 = \"MD5\";\n r1 = j;\n r0 = r0.equals(r1);\n if (r0 == 0) goto L_0x003a;\n L_0x000a:\n r0 = java.security.Security.getProviders();\n r1 = r0.length;\n r2 = 0;\n L_0x0010:\n if (r2 >= r1) goto L_0x003a;\n L_0x0012:\n r3 = r0[r2];\n r3 = r3.getServices();\n r3 = r3.iterator();\n L_0x001c:\n r4 = r3.hasNext();\n if (r4 == 0) goto L_0x0037;\n L_0x0022:\n r4 = r3.next();\n r4 = (java.security.Provider.Service) r4;\n r4 = r4.getAlgorithm();\n j = r4;\n r4 = j;\t Catch:{ NoSuchAlgorithmException -> 0x001c }\n r4 = java.security.MessageDigest.getInstance(r4);\t Catch:{ NoSuchAlgorithmException -> 0x001c }\n if (r4 == 0) goto L_0x001c;\n L_0x0036:\n return r4;\n L_0x0037:\n r2 = r2 + 1;\n goto L_0x0010;\n L_0x003a:\n r0 = 0;\n return r0;\n */\n throw new UnsupportedOperationException(\"Method not decompiled: com.koushikdutta.async.util.FileCache.f():java.security.MessageDigest\");\n }", "public String getHashString()\n\t{\n\t\treturn md5.getHashString();\n\t}", "public MD5Util() {\n }", "private String fileChecksum(File tmpFile, ITaskMonitor monitor) {\n InputStream is = null;\n try {\n is = new FileInputStream(tmpFile);\n MessageDigest digester = getChecksumType().getMessageDigest();\n byte[] buf = new byte[65536];\n int n;\n while ((n = is.read(buf)) >= 0) {\n if (n > 0) {\n digester.update(buf, 0, n);\n }\n }\n return getDigestChecksum(digester);\n } catch (FileNotFoundException e) {\n monitor.setResult(\"File not found: %1$s\", e.getMessage());\n } catch (Exception e) {\n monitor.setResult(e.getMessage());\n } finally {\n if (is != null) {\n try {\n is.close();\n } catch (IOException e) {\n }\n }\n }\n return \"\";\n }", "byte[] digest();", "public MD5(String texto) throws Exception {\n this.md5 = MessageDigest.getInstance(\"MD5\");\n this.texto = texto;\n this.byTexto = texto.getBytes();\n calcMD5();\n }", "public static byte[] encryptMD5File(final File file) {\n if (file == null) return null;\n FileInputStream fis = null;\n DigestInputStream digestInputStream;\n try {\n fis = new FileInputStream(file);\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n digestInputStream = new DigestInputStream(fis, md);\n byte[] buffer = new byte[256 * 1024];\n while (true) {\n if (!(digestInputStream.read(buffer) > 0)) break;\n }\n md = digestInputStream.getMessageDigest();\n return md.digest();\n } catch (NoSuchAlgorithmException | IOException e) {\n e.printStackTrace();\n return null;\n } finally {\n try {\n if (fis != null) {\n fis.close();\n }\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n }", "private static String getKeyByMd5(String url) {\n String key;\n try {\n MessageDigest messageDigest = MessageDigest.getInstance(\"MD5\");\n messageDigest.update(url.getBytes());\n key = md5Encryption(messageDigest.digest());\n return key;\n } catch (NoSuchAlgorithmException e) {\n e.printStackTrace();\n key = String.valueOf(url.hashCode());\n }\n return key;\n }", "public HashCode getInstallMD5() {\n return installMD5;\n }", "public static String getFileChecksum(MessageDigest digest, String filePath) throws IOException {\n\t\tFileInputStream fis = new FileInputStream(filePath);\n\n\t\t// Create byte array to read data in chunks\n\t\tbyte[] byteArray = new byte[1024];\n\t\tint bytesCount = 0;\n\n\t\t// Read file data and update in message digest\n\t\twhile ((bytesCount = fis.read(byteArray)) != -1) {\n\t\t\tdigest.update(byteArray, 0, bytesCount);\n\t\t}\n\t\t;\n\n\t\t// close the stream; We don't need it now.\n\t\tfis.close();\n\n\t\t// Get the hash's bytes\n\t\tbyte[] bytes = digest.digest();\n\n\t\t// This bytes[] has bytes in decimal format;\n\t\t// Convert it to hexadecimal format\n\t\tStringBuilder sb = new StringBuilder();\n\t\tfor (int i = 0; i < bytes.length; i++) {\n\t\t\tsb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));\n\t\t}\n\n\t\t// return complete hash\n\t\treturn sb.toString();\n\t}", "public static String getmd5(String saltedPassword) {\n\t\tmd5MessageDigest.get().update(saltedPassword.getBytes());\n\t\treturn toHex(md5MessageDigest.get().digest());\n\t}", "public byte[] getHash()\n\t{\n\t\treturn md5.getHash();\n\t}", "String saveData(MultipartFile md5File) throws IOException;", "public Digest (File appdir)\n throws IOException\n {\n // parse and validate our digest file contents\n StringBuffer data = new StringBuffer();\n File dfile = new File(appdir, DIGEST_FILE);\n List pairs = ConfigUtil.parsePairs(dfile, false);\n for (Iterator iter = pairs.iterator(); iter.hasNext(); ) {\n String[] pair = (String[])iter.next();\n if (pair[0].equals(DIGEST_FILE)) {\n _metaDigest = pair[1];\n break;\n }\n _digests.put(pair[0], pair[1]);\n note(data, pair[0], pair[1]);\n }\n \n // we've reached the end, validate our contents\n MessageDigest md = getMessageDigest();\n byte[] contents = data.toString().getBytes(\"UTF-8\");\n String md5 = StringUtil.hexlate(md.digest(contents));\n if (!md5.equals(_metaDigest)) {\n String err = MessageUtil.tcompose(\n \"m.invalid_digest_file\", _metaDigest, md5);\n throw new IOException(err);\n }\n }", "private String hashKey(String key) throws NoSuchAlgorithmException {\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n byte[] hashInBytes = md.digest(key.getBytes(StandardCharsets.UTF_8));\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < hashInBytes.length; i++) {\n sb.append(Integer.toString((hashInBytes[i] & 0xff) + 0x100, 16).substring(1));\n }\n String s = sb.toString();\n return s;\n }", "public String getHash(String str) throws Exception{\n\t\t\n\t\tMessageDigest md = MessageDigest.getInstance(\"MD5\");\n md.update(str.getBytes());\n \n byte byteData[] = md.digest();\n \n //convert the byte to hex format method 1\n StringBuffer sb = new StringBuffer();\n for (int i = 0; i < byteData.length; i++) {\n sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));\n }\n \n String hex = sb.toString();\n System.out.println(hex);\n return hex; \n}", "public static void main(String[] args) throws NoSuchAlgorithmException, FileNotFoundException, IOException {\n \r\n String hash = \"F5D080D4F4E185DECA8A8B24F72408D9\";\r\n String [] keys = {\"9A1BA7F38A3E8D8F9DDD55972868CB3F\",\"17185CEF199E1C89804EDEE9DCDD1B90\",\"F5D080D4F4E185DECA8A8B24F72408D9\"};\r\n String password = \"NoSuchPassword\";\r\n File file = null;\r\n JFileChooser ff = new JFileChooser();\r\n int a = ff.showOpenDialog(null);\r\n if(a == JFileChooser.APPROVE_OPTION){\r\n try {\r\n file = ff.getSelectedFile();\r\n JOptionPane.showMessageDialog(ff, a);\r\n \r\n } catch (Exception ex) {\r\n ex.printStackTrace();\r\n } finally {\r\n System.out.println(file.getPath());\r\n }\r\n } \r\n BufferedReader fr = null;\r\n fr = new BufferedReader(new FileReader(file.getPath()));\r\n String line = null;\r\n int i = 0; \r\n //This is the funtion that Java implement in java.security.MessageDigest\r\n MessageDigest md5 = MessageDigest.getInstance(\"MD5\");\r\n while((line = fr.readLine()) != null){\r\n System.out.println(line);\r\n md5.update(line.getBytes());\r\n byte [] digests = md5.digest();\r\n String hashs = DatatypeConverter.printHexBinary(digests).toUpperCase();\r\n if(keys[i].equals(hashs)){\r\n System.out.println(\"CORRECT!\\nThe hash created is the same as the hash saved \");\r\n }\r\n else{\r\n System.out.println(\"ERROR!\\nThere was a mistake, the hash create doesn't mach the hash saved\");\r\n }\r\n i++;\r\n } \r\n fr.close();\r\n /**In conclusion we can use the MD5 for digest a words and then same them\r\n * is a DataBase, this with the function that if the DB is committed the\r\n * passwords will not be there\r\n */\r\n }", "private String calculateCheckSum(File file2) {\n\t\tStringBuffer sb = new StringBuffer(\"\");\n\t\ttry {\n\t\t\tMessageDigest messageDigest = MessageDigest.getInstance(\"SHA1\");\n\n\t\t\tFileInputStream finput = new FileInputStream(file2);\n\t\t\tbyte[] dataBytes = new byte[1024];\n\n\t\t\tint bytesRead = 0;\n\n\t\t\twhile ((bytesRead = finput.read(dataBytes)) != -1) {\n\t\t\t\tmessageDigest.update(dataBytes, 0, bytesRead);\n\t\t\t}\n\n\t\t\tbyte[] digestBytes = messageDigest.digest();\n\n\t\t\tfor (int i = 0; i < digestBytes.length; i++) {\n\t\t\t\tsb.append(Integer.toString((digestBytes[i] & 0xff) + 0x100, 16).substring(1));\n\t\t\t}\n\t\t\tSystem.out.println(\"file check sum value is \" + sb.toString());\n\t\t\tfinput.close();\n\t\t} catch (Exception ex) {\n\t\t\t// TODO: handle exception\n\t\t\tLogger.getLogger(FileTransferClient.class.getName()).log(Level.SEVERE, null, ex);\n\t\t}\n\n\t\treturn sb.toString();\n\t}", "public static String hash(File remoteFsRoot) {\n logger.config(\"hash() invoked\");\n\n StringBuilder buf = new StringBuilder();\n try {\n buf.append(remoteFsRoot.getCanonicalPath()).append('\\n');\n } catch (IOException e) {\n logger.log(Level.FINER, \"hash() IOException - may be normal?\", e);\n buf.append(remoteFsRoot.getAbsolutePath()).append('\\n');\n }\n try {\n for (NetworkInterface ni : Collections.list(NetworkInterface.getNetworkInterfaces())) {\n for (InetAddress ia : Collections.list(ni.getInetAddresses())) {\n if (ia instanceof Inet4Address) {\n buf.append(ia.getHostAddress()).append('\\n');\n } else if (ia instanceof Inet6Address) {\n buf.append(ia.getHostAddress()).append('\\n');\n }\n }\n byte[] hardwareAddress = ni.getHardwareAddress();\n if (hardwareAddress != null) {\n buf.append(Arrays.toString(hardwareAddress));\n }\n }\n } catch (SocketException e) {\n // oh well we tried\n logger.log(Level.FINEST, \"hash() SocketException - 'oh well we tried'\", e);\n }\n return DigestUtils.md5Hex(buf.toString()).substring(0, 8);\n }", "private static String md5(String str) {\n\n if (str == null) {\n return null;\n }\n\n MessageDigest messageDigest = null;\n\n try {\n messageDigest = MessageDigest.getInstance(HttpConf.signType);\n messageDigest.reset();\n messageDigest.update(str.getBytes(HttpConf.charset));\n } catch (NoSuchAlgorithmException e) {\n\n return str;\n } catch (UnsupportedEncodingException e) {\n return str;\n }\n\n byte[] byteArray = messageDigest.digest();\n\n StringBuffer md5StrBuff = new StringBuffer();\n\n for (int i = 0; i < byteArray.length; i++) {\n if (Integer.toHexString(0xFF & byteArray[i]).length() == 1) {\n md5StrBuff.append(\"0\").append(Integer.toHexString(0xFF & byteArray[i]));\n } else {\n md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i]));\n }\n }\n\n return md5StrBuff.toString();\n }", "public static String encryptMD5File2String(final File file) {\n return bytes2HexString(encryptMD5File(file));\n }", "byte[] getDigest();", "public static String hash(String data) {\n\t MessageDigest md;\n\t\ttry {\n\t\t\tmd = MessageDigest.getInstance(\"MD5\");\n\t\t md.update(data.getBytes());\n\t\t byte[] digest = md.digest();\n\t\t char[] HEX_ARRAY = \"0123456789ABCDEF\".toCharArray();\n\t char[] hexChars = new char[digest.length * 2];\n\t for (int j = 0; j < digest.length; j++) {\n\t int v = digest[j] & 0xFF;\n\t hexChars[j * 2] = HEX_ARRAY[v >>> 4];\n\t hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];\n\t }\n\t return new String(hexChars);\n\t\t} catch (NoSuchAlgorithmException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\n return null;\n\t}", "public static String getMobileAdminPasswordMD5(){\n\t\treturn \"e3e6c68051fdfdf177c8933bfd76de48\";\n\t}", "public static String computeOnce(String str) {\n str = (str == null) ? \"\" : str;\n MessageDigest md5 = null;\n try {\n md5 = MessageDigest.getInstance(\"MD5\");\n } catch (Exception e) {\n throw new ExternalException();\n }\n // convert input String to a char[]\n // convert that char[] to byte[]\n // get the md5 digest as byte[]\n // bit-wise AND that byte[] with 0xff\n // prepend \"0\" to the output StringBuffer to make sure that we don't end\n // up with\n // something like \"e21ff\" instead of \"e201ff\"\n\n char[] charArray = str.toCharArray();\n\n byte[] byteArray = new byte[charArray.length];\n\n for (int i = 0; i < charArray.length; i++)\n byteArray[i] = (byte) charArray[i];\n\n byte[] md5Bytes = md5.digest(byteArray);\n\n StringBuffer hexValue = new StringBuffer();\n\n for (int i = 0; i < md5Bytes.length; i++) {\n int val = (md5Bytes[i]) & 0xff;\n if (val < 16)\n hexValue.append(\"0\");\n hexValue.append(Integer.toHexString(val));\n }\n\n return hexValue.toString();\n }", "private static byte[] m14295fl(String str) {\n try {\n MessageDigest instance = MessageDigest.getInstance(\"MD5\");\n if (instance == null) {\n return str.getBytes();\n }\n instance.update(str.getBytes());\n return instance.digest();\n } catch (NoSuchAlgorithmException e) {\n e.printStackTrace();\n return str.getBytes();\n }\n }", "public static byte[] MD5(String ran, String strKey){\n \n \tString clientSecretKey = ran + strKey;\n MessageDigest m = null;\n \n try {\n \t\n m = MessageDigest.getInstance(\"MD5\");\n \n } \n catch (NoSuchAlgorithmException ex) {\n \t\n ex.printStackTrace();\n \n }\n \n m.reset();\n m.update(clientSecretKey.getBytes());\n byte[] digest = m.digest();\n \n return digest;\n \n }", "public Md5HashFileSystemResolver() {\n\t\tsuper();\n\t}", "private String getHash(String text) {\n\t\ttry {\n\t\t\tString salt = new StringBuffer(this.email).reverse().toString();\n\t\t\ttext += salt;\n\t\t\tMessageDigest m = MessageDigest.getInstance(\"MD5\");\n\t\t\tm.reset();\n\t\t\tm.update(text.getBytes());\n\t\t\tbyte[] digest = m.digest();\n\t\t\tBigInteger bigInt = new BigInteger(1, digest);\n\t\t\tString hashedText = bigInt.toString(16);\n\t\t\twhile (hashedText.length() < 32) {\n\t\t\t\thashedText = \"0\" + hashedText;\n\t\t\t}\n\t\t\treturn hashedText;\n\t\t} catch (Exception e) {\n\t\t\te.getStackTrace();\n\t\t\treturn text;\n\t\t}\n\t}", "public static void createDigest (List resources, File output)\n throws IOException\n {\n MessageDigest md = getMessageDigest();\n StringBuffer data = new StringBuffer();\n PrintWriter pout = new PrintWriter(\n new OutputStreamWriter(new FileOutputStream(output), \"UTF-8\"));\n \n // compute and append the MD5 digest of each resource in the list\n for (Iterator iter = resources.iterator(); iter.hasNext(); ) {\n Resource rsrc = (Resource)iter.next();\n String path = rsrc.getPath();\n try {\n String digest = rsrc.computeDigest(md, null);\n note(data, path, digest);\n pout.println(path + \" = \" + digest);\n } catch (IOException ioe) {\n throw new NestableIOException(\n \"Error computing digest for: \" + rsrc, ioe);\n }\n }\n \n // finally compute and append the digest for the file contents\n md.reset();\n byte[] contents = data.toString().getBytes(\"UTF-8\");\n pout.println(DIGEST_FILE + \" = \" +\n StringUtil.hexlate(md.digest(contents)));\n \n pout.close();\n }", "public static void main(String[] args) {\n Scanner in=new Scanner(System.in);\n String str=in.next();\n try\n {\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n byte[] bytes=md.digest(str.getBytes());\n \n for(byte b:bytes)\n System.out.format(\"%02x\",b);\n }\n catch(Exception e)\n {\n System.out.print(e);\n }\n }", "static String md5test(String text,String returnType) {\n String result=null;\n if (returnType.equals(\"str\")){\n result = DigestUtils.md5Hex(text);\n System.out.println(result); // 5d41402abc4b2a76b9719d911017c592\n }else if(returnType.equals(\"byteArray\")){\n byte[] res = DigestUtils.md5(text);\n System.out.println(byteToHex(res));// 5d41402abc4b2a76b9719d911017c592\n }\n //new String((byte[]) res)\n return result;\n}", "public static String md5PasswordCrypt(String password) throws AutoDeployException {\n try {\n byte[] hash = MessageDigest.getInstance(\"MD5\").digest(password.getBytes());\n StringBuffer hashString = new StringBuffer();\n for (int i = 0; i < hash.length; i++) {\n String hex = Integer.toHexString(hash[i]);\n if (hex.length() == 1) {\n hashString.append('0');\n hashString.append(hex.charAt(hex.length() - 1));\n } else {\n hashString.append(hex.substring(hex.length() - 2));\n }\n }\n return hashString.toString();\n } catch (Exception e) {\n log.error(\"Can't crypt the password due to an unexpected error : \" + e.getMessage());\n throw new AutoDeployException(\"Cant' crypt the password due to an unexpected error : \" + e.getMessage());\n }\n }", "public String get_Md5_Hash(String sStringToEncode) throws Exception {\n String sRetval = \"\";\n StringBuffer sb = new StringBuffer();\n\n try {\n MessageDigest md = MessageDigest.getInstance(\"MD5\");\n byte[] messageDigest = md.digest(sStringToEncode.getBytes(\"UTF-8\"));\n BigInteger number = new BigInteger(1, messageDigest);\n String hashtext = number.toString(16);\n sRetval = hashtext;\n } catch (Exception e) {\n throw new Exception(\"get_Md5_Hash : \" + e);\n }\n return sRetval;\n }", "public String getHash(final String password) throws NoSuchAlgorithmException, UnsupportedEncodingException {\n final MessageDigest digest = MessageDigest.getInstance(\"MD5\");\n byte[] md5hash;\n digest.update(password.getBytes(\"utf-8\"), 0, password.length());\n md5hash = digest.digest();\n return convertToHex(md5hash);\n }" ]
[ "0.78522515", "0.7785525", "0.7613727", "0.7399484", "0.7187603", "0.71864074", "0.70419335", "0.69951296", "0.69856435", "0.69225526", "0.69064134", "0.68959796", "0.6827546", "0.680656", "0.67714965", "0.66428113", "0.6641831", "0.6610119", "0.65951395", "0.65380496", "0.64990854", "0.64982593", "0.6464773", "0.6464173", "0.6462834", "0.6431761", "0.6421776", "0.6419537", "0.63861036", "0.63819265", "0.63779527", "0.63271475", "0.6307735", "0.62946534", "0.62779754", "0.6267465", "0.62445134", "0.62343335", "0.62306595", "0.6225506", "0.62017447", "0.6194323", "0.61882496", "0.61799645", "0.61777693", "0.6154541", "0.6154541", "0.61293054", "0.6105824", "0.610313", "0.6102012", "0.6094246", "0.608832", "0.60875845", "0.6071204", "0.6049617", "0.6031005", "0.6011395", "0.6006164", "0.5985916", "0.59857386", "0.59733164", "0.59346277", "0.5925456", "0.5874841", "0.58663356", "0.58656996", "0.5838617", "0.5838537", "0.5789898", "0.5780993", "0.57674134", "0.5736986", "0.5732626", "0.5715964", "0.5715336", "0.5710671", "0.570407", "0.5683938", "0.5655639", "0.5653337", "0.5644992", "0.5643873", "0.56278694", "0.56198394", "0.5619517", "0.56117356", "0.56101024", "0.56082255", "0.56043583", "0.5588087", "0.5587458", "0.55817425", "0.5570399", "0.5555938", "0.55552536", "0.55527025", "0.55521154", "0.55419225", "0.5541042" ]
0.76631325
2
Test the behavior of setObject for timestamp columns.
@Test public void testSetLocalDateTime() throws SQLException { List<String> zoneIdsToTest = getZoneIdsToTest(); List<String> datesToTest = getDatesToTest(); for (String zoneId : zoneIdsToTest) { ZoneId zone = ZoneId.of(zoneId); for (String date : datesToTest) { LocalDateTime localDateTime = LocalDateTime.parse(date); String expected = localDateTime.atZone(zone) .format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) .replace('T', ' '); localTimestamps(zone, localDateTime, expected); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Test\n public void testDateTimeType() throws Exception {\n if(util.isHiveCatalogStoreRunning()) return;\n\n ResultSet res = null;\n TajoClient client = util.newTajoClient();\n try {\n String tableName = \"datetimetable\";\n String query = \"select col1, col2, col3 from \" + tableName;\n\n String [] table = new String[] {tableName};\n Schema schema = new Schema();\n schema.addColumn(\"col1\", Type.DATE);\n schema.addColumn(\"col2\", Type.TIME);\n schema.addColumn(\"col3\", Type.TIMESTAMP);\n Schema [] schemas = new Schema[] {schema};\n String [] data = {\n \"2014-01-01|01:00:00|2014-01-01 01:00:00\"\n };\n KeyValueSet tableOptions = new KeyValueSet();\n tableOptions.set(StorageConstants.TEXT_DELIMITER, StorageConstants.DEFAULT_FIELD_DELIMITER);\n\n res = TajoTestingCluster\n .run(table, schemas, tableOptions, new String[][]{data}, query, client);\n\n assertTrue(res.next());\n\n Date date = res.getDate(1);\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n date = res.getDate(\"col1\");\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n Time time = res.getTime(2);\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n time = res.getTime(\"col2\");\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n Timestamp timestamp = res.getTimestamp(3);\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n timestamp = res.getTimestamp(\"col3\");\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n // assert with timezone\n Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(\"GMT+9\"));\n date = res.getDate(1, cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n date = res.getDate(\"col1\", cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n time = res.getTime(2, cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n time = res.getTime(\"col2\", cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n timestamp = res.getTimestamp(3, cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n\n timestamp = res.getTimestamp(\"col3\", cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n } finally {\n if (res != null) {\n res.close();\n }\n\n client.close();\n }\n }", "@Test\n public void test_column_type_detection_datetimes_01() throws SQLException {\n Model m = ModelFactory.createDefaultModel();\n testColumnTypeDetection(\"x\", m.createTypedLiteral(Calendar.getInstance()).asNode(), true, Types.TIMESTAMP, Timestamp.class.getCanonicalName());\n }", "@Test\n public void test_column_type_detection_datetimes_04() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"13:15:00.123\", XSDDatatype.XSDtime), true, Types.TIME, Time.class.getCanonicalName());\n }", "@Test\n public void test_column_type_detection_datetimes_03() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"13:15:00\", XSDDatatype.XSDtime), true, Types.TIME, Time.class.getCanonicalName());\n }", "public void setDateTrx (Timestamp DateTrx)\n{\nif (DateTrx == null) throw new IllegalArgumentException (\"DateTrx is mandatory\");\nset_Value (\"DateTrx\", DateTrx);\n}", "boolean hasTimestamp();", "boolean hasTimestamp();", "boolean hasTimestamp();", "boolean hasTimestamp();", "boolean hasTimestamp();", "boolean hasTimestamp();", "boolean hasTimestamp();", "public abstract void setDate(Timestamp uneDate);", "void setTimestamp(int index, Timestamp value)\n throws SQLException;", "@Test\n public void testTimestampColumnOptional() {\n Schema schema = Schema.newBuilder()\n .setTimestampColumn(\"timestamp\").build();\n\n Map<String, Value> map = new HashMap<>();\n map.put(\"timestamp\", Values.asTimestamp(Values.ofString(\"2019-01-30T19:30:12Z\")));\n\n PCollection<FeatureRow> output = pipeline\n .apply(Create.of(Lists.newArrayList(map)).withCoder(VALUE_MAP_CODER))\n .apply(new ValueMapToFeatureRowTransform(\"entity\", schema));\n\n PAssert.that(output).satisfies(maps -> {\n FeatureRow row = maps.iterator().next();\n assertEquals(\"entity\", row.getEntityName());\n assertEquals(map.get(\"timestamp\").getTimestampVal(), row.getEventTimestamp());\n return null;\n });\n pipeline.run();\n }", "@Test\n public void test_column_type_detection_datetimes_02() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"2013-04-08\", XSDDatatype.XSDdate), true, Types.DATE, Date.class.getCanonicalName());\n }", "public final void testSetTimeStamp() {\n Notification n = new Notification(\"type\", \"src\", 1);\n n.setTimeStamp(123);\n assertEquals(123, n.getTimeStamp());\n }", "public boolean set(long timestamp, T e) {\n return set(timestamp, e, false);\n }", "public boolean hasTimestamp() {\n return fieldSetFlags()[6];\n }", "@Test\n public void testHiveParquetTimestampAsInt96_basic() throws Exception {\n BaseTestQuery.testBuilder().unOrdered().sqlQuery((\"SELECT convert_from(timestamp_field, 'TIMESTAMP_IMPALA') as timestamp_field \" + \"from cp.`parquet/part1/hive_all_types.parquet` \")).baselineColumns(\"timestamp_field\").baselineValues(TestBuilder.convertToLocalDateTime(\"2013-07-06 00:01:00\")).baselineValues(((Object) (null))).go();\n }", "@Test\n public void testSetOffsetTimeWithoutType() throws SQLException {\n OffsetTime data = OffsetTime.parse(\"16:21:51+12:34\");\n insertThenReadWithoutType(data, \"time_with_time_zone_column\", Time.class);\n }", "public void setTimestamp(Date timestamp) {\r\n this.timestamp = timestamp;\r\n }", "@Test\r\n public void testApplyChanges()\r\n {\r\n EasyMockSupport support = new EasyMockSupport();\r\n\r\n PreferencesRegistry registry = createPreferencesRegistry(support);\r\n CellSampler sampler = createSampler(support);\r\n ColumnDefinitionModel model = createModel();\r\n\r\n support.replayAll();\r\n\r\n @SuppressWarnings(\"unused\")\r\n ColumnDefinitionController controller = new ColumnDefinitionController(registry, model, sampler);\r\n\r\n ColumnDefinitionTableModel definitionTable = model.getDefinitionTableModel();\r\n\r\n CSVParseParameters parameters = model.getSelectedParameters();\r\n\r\n ColumnDefinitionRow timeRow = definitionTable.getRow(0);\r\n model.setSelectedDefinition(timeRow);\r\n timeRow.setFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\");\r\n\r\n SpecialColumn timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n ColumnDefinitionRow latRow = definitionTable.getRow(1);\r\n model.setSelectedDefinition(latRow);\r\n latRow.setDataType(null);\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n ColumnDefinitionRow lonRow = definitionTable.getRow(2);\r\n model.setSelectedDefinition(lonRow);\r\n lonRow.setColumnName(\"Longitude\");\r\n\r\n List<? extends String> columnNames = parameters.getColumnNames();\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n\r\n ColumnDefinitionRow name2 = definitionTable.getRow(4);\r\n model.setSelectedDefinition(name2);\r\n name2.setIsImport(true);\r\n\r\n columnNames = parameters.getColumnNames();\r\n assertEquals(ColumnHeaders.TIME.toString(), columnNames.get(0));\r\n assertEquals(ColumnHeaders.LAT.toString(), columnNames.get(1));\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n assertEquals(ColumnHeaders.NAME.toString(), columnNames.get(3));\r\n assertEquals(ColumnHeaders.NAME2.toString(), columnNames.get(4));\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n SpecialColumn lonColumn = parameters.getSpecialColumn(ColumnType.LON);\r\n assertEquals(2, lonColumn.getColumnIndex());\r\n assertEquals(\"Decimal\", lonColumn.getFormat());\r\n\r\n assertTrue(parameters.getColumnsToIgnore().isEmpty());\r\n\r\n support.verifyAll();\r\n }", "@Test\n public void testSetOffsetDateTime() throws SQLException {\n List<String> zoneIdsToTest = getZoneIdsToTest();\n List<TimeZone> storeZones = new ArrayList<TimeZone>();\n for (String zoneId : zoneIdsToTest) {\n storeZones.add(TimeZone.getTimeZone(zoneId));\n }\n List<String> datesToTest = getDatesToTest();\n\n for (TimeZone timeZone : storeZones) {\n ZoneId zoneId = timeZone.toZoneId();\n for (String date : datesToTest) {\n LocalDateTime localDateTime = LocalDateTime.parse(date);\n String expected = date.replace('T', ' ');\n offsetTimestamps(zoneId, localDateTime, expected, storeZones);\n }\n }\n }", "public void setDateTrx (Timestamp DateTrx);", "public void setDateTrx (Timestamp DateTrx);", "public boolean hasTimestamp() {\n return fieldSetFlags()[2];\n }", "@Test\n public void testSetLocalTimeWithType() throws SQLException {\n LocalTime data = LocalTime.parse(\"16:21:51\");\n Time actual = insertThenReadWithType(data, Types.TIME, \"time_without_time_zone_column\", Time.class);\n Time expected = Time.valueOf(\"16:21:51\");\n assertEquals(expected, actual);\n }", "public void setTimestamp(Date timestamp) {\n this.timestamp = timestamp;\n }", "@Override\n\tpublic void visit(TimestampValue arg0) {\n\n\t}", "@Test\n public void testSetOffsetTimeWithType() throws SQLException {\n OffsetTime data = OffsetTime.parse(\"16:21:51+12:34\");\n insertThenReadWithType(data, Types.TIME, \"time_with_time_zone_column\", Time.class);\n }", "@Override\n\tpublic void visit(TimestampValue arg0) {\n\t\t\n\t}", "public boolean hasTimestamp() {\n return fieldSetFlags()[0];\n }", "void setTimestamp(int index, Timestamp value, Calendar cal)\n throws SQLException;", "public void setTimestamp(Timestamp timestamp) {\n\t\tthis.timestamp = timestamp;\n\t}", "@Test\n public void testSetLocalTimeWithoutType() throws SQLException {\n LocalTime data = LocalTime.parse(\"16:21:51\");\n Time actual = insertThenReadWithoutType(data, \"time_without_time_zone_column\", Time.class);\n Time expected = Time.valueOf(\"16:21:51\");\n assertEquals(expected, actual);\n }", "public void setValidTo (Timestamp ValidTo);", "@OfMethod({\"setTimestamp(java.lang.String,java.sql.Timeastamp)\",\n \"setTimestamp(java.lang.String,java.sql.Timestamp,java.util.Calendar)\",\n \"setTimestamp(int,java.sql.Timestamp)\",\n \"setTimestamp(int,java.sql.Timestamp,java.util.Calendar)\"})\n public void testSetTimestamp() throws Exception {\n CallableStatement instance = newClosedCall();\n\n try {\n instance.setTimestamp(getParameterName(), Timestamp.valueOf(\"2007-05-02 04:48:01\"));\n fail(\"Allowed set timestamp by parameter name after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTimestamp(getParameterName(), Timestamp.valueOf(\"2007-05-02 04:48:01\"), Calendar.getInstance());\n fail(\"Allowed set timestamp by parameter name and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTimestamp(getParameterIndex(), Timestamp.valueOf(\"2007-05-02 04:48:01\"));\n fail(\"Allowed set time by parameter index after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTimestamp(getParameterIndex(), Timestamp.valueOf(\"2007-05-02 04:48:01\"), Calendar.getInstance());\n fail(\"Allowed set timestamp by parameter index and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n }", "@Test\r\n public void testTimestampDuration() throws Exception\r\n {\r\n Timestamp ts = new Timestamp(100110L).applyTimeOrigin(0L);\r\n\r\n GCEvent e = getGCEventToTest(ts, 7L);\r\n\r\n // time (dedicated accessor and generic field)\r\n assertEquals(100110L, e.getTime().longValue());\r\n assertEquals(100110L, ((Long)e.get(FieldType.TIME).getValue()).longValue());\r\n\r\n // offset (dedicated accessor and generic field)\r\n assertEquals(100110L, e.getOffset().longValue());\r\n assertEquals(\"100.110\", e.get(FieldType.OFFSET).getValue());\r\n\r\n // duration (dedicated accessor and generic field)\r\n assertEquals(7L, e.getDuration());\r\n assertEquals(7L, ((Long) e.get(FieldType.DURATION).getValue()).longValue());\r\n }", "public abstract void setFecha_ingreso(java.sql.Timestamp newFecha_ingreso);", "@Test\n public void testImpalaParquetBinaryAsTimeStamp_DictChange() throws Exception {\n try {\n BaseTestQuery.testBuilder().sqlQuery(\"select min(int96_ts) date_value from dfs.`parquet/int96_dict_change`\").optionSettingQueriesForTestQuery(\"alter session set `%s` = true\", PARQUET_READER_INT96_AS_TIMESTAMP).ordered().baselineColumns(\"date_value\").baselineValues(TestBuilder.convertToLocalDateTime(\"1970-01-01 00:00:01.000\")).build().run();\n } finally {\n BaseTestQuery.resetSessionOption(PARQUET_READER_INT96_AS_TIMESTAMP);\n }\n }", "public void set(final Timestamp timestamp) {\n stamp = timestamp.get();\n }", "public void setTimestamp(Integer timestamp) {\n this.timestamp = timestamp;\n }", "public void setSOHTimestamp(Date SOHTimestamp) {\r\n/* 482 */ this._SOHTimestamp = SOHTimestamp;\r\n/* */ }", "public void setTimestamp(@NonNull Date timestamp) {\n this.timestamp = timestamp;\n }", "public void setTimestamp(Long timestamp) {\n this.timestamp = timestamp;\n }", "public interface Timestampable {\r\n \r\n /**\r\n * Property which represents createdDate.\r\n */\r\n static final String PROP_CREATED_DATE = \"createdDate\";\r\n \r\n /**\r\n * Property which represents modifiedDate.\r\n */\r\n static final String PROP_MODIFIED_DATE = \"modifiedDate\";\r\n \r\n\r\n \r\n Date getCreatedDate();\r\n \r\n void setCreatedDate(Date createdDate);\r\n \r\n Date getModifiedDate();\r\n \r\n void setModifiedDate(Date modifiedDate);\r\n\r\n}", "public boolean hasTimestamp() {\n return timestamp_ != null;\n }", "public void setModified(java.sql.Timestamp tmp) {\n this.modified = tmp;\n }", "@Test\n public void testSetLocalTimeAndReadBack() throws SQLException {\n // TODO: fix for binary mode.\n // Avoid micros truncation in org.postgresql.jdbc.PgResultSet#internalGetObject\n assumeBinaryModeRegular();\n LocalTime data = LocalTime.parse(\"16:21:51.123456\");\n\n insertWithoutType(data, \"time_without_time_zone_column\");\n\n String readBack = readString(\"time_without_time_zone_column\");\n assertEquals(\"16:21:51.123456\", readBack);\n }", "public boolean hasTimestamp() {\n return result.hasTimestamp();\n }", "public boolean hasTimestamp() {\n return timestampBuilder_ != null || timestamp_ != null;\n }", "public void setDia_especifico(java.sql.Timestamp newDia_especifico);", "public void setStatementDate (Timestamp StatementDate);", "@Test\n public void testTimeStampRounding() throws SQLException {\n assumeBinaryModeRegular();\n LocalTime time = LocalTime.parse(\"23:59:59.999999500\");\n Time actual = insertThenReadWithoutType(time, \"time_without_time_zone_column\", Time.class, false/*no roundtrip*/);\n assertEquals(Time.valueOf(\"24:00:00\"), actual);\n }", "@JsProperty(name = \"timestamp\")\n public native void setTimestamp(@DoNotAutobox Number value);", "@Test\n public void testTimeStampRoundingWithType() throws SQLException {\n assumeBinaryModeRegular();\n LocalTime time = LocalTime.parse(\"23:59:59.999999500\");\n Time actual =\n insertThenReadWithType(time, Types.TIME, \"time_without_time_zone_column\", Time.class, false/*no roundtrip*/);\n assertEquals(Time.valueOf(\"24:00:00\"), actual);\n }", "@Override\r\n public void setTimeStamp(long parseLong) throws IOException {\n\r\n }", "public void setFecha(java.sql.Timestamp newFecha);", "public void setTimestamp(final Date timestamp) {\r\n mTimestamp = timestamp;\r\n }", "@JsonSetter(\"product_timestamps\")\n public void setProductTimestamps (ProductTimestamps value) { \n this.productTimestamps = value;\n }", "@Test\n public void updatedAtTest() {\n // TODO: test updatedAt\n }", "@Test\r\n\tpublic void testSetDate() {\n\t\tfail(\"Not yet implemented\");\r\n\t}", "protected void setTimestamp(long time) \n {\n\t\tlTimestamp = time;\n\t}", "public void setTimestamp(long value) {\r\n this.timestamp = value;\r\n }", "public abstract void setFecha_fin(java.sql.Timestamp newFecha_fin);", "public boolean hasTimestamp() {\r\n return ((bitField0_ & 0x00000001) == 0x00000001);\r\n }", "public boolean hasTimestamp() {\r\n return ((bitField0_ & 0x00000001) == 0x00000001);\r\n }", "public void setDateOrdered (Timestamp DateOrdered);", "public void setTimestamp() {\n timestamp = System.nanoTime();\n }", "public void setValidFrom (Timestamp ValidFrom);", "public void setMovementDate (Timestamp MovementDate);", "public final void testGetTimeStamp() {\n assertEquals(hello.timeStamp, n.getTimeStamp());\n }", "public Timestamp getDateTrx() \n{\nreturn (Timestamp)get_Value(\"DateTrx\");\n}", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000001) == 0x00000001);\n }", "public void setFecha_envio(java.sql.Timestamp newFecha_envio);", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000001) == 0x00000001);\n }", "public boolean hasTimestamp() {\r\n return ((bitField0_ & 0x00000001) == 0x00000001);\r\n }", "public boolean hasTimestamp() {\r\n return ((bitField0_ & 0x00000001) == 0x00000001);\r\n }", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000008) == 0x00000008);\n }", "@NoProxy\n public void setDtstamps(final Timestamp val) {\n DateTime dt = new DateTime(val);\n setDtstamp(new DtStamp(dt).getValue());\n setLastmod(new LastModified(dt).getValue());\n setCtoken(getLastmod() + \"-\" + hex4FromNanos(val.getNanos()));\n\n if (getCreated() == null) {\n setCreated(new Created(dt).getValue());\n }\n }", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000008) == 0x00000008);\n }", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000002) == 0x00000002);\n }", "public TimeSeriesPoint setTimestamp(OffsetDateTime timestamp) {\n this.timestamp = timestamp;\n return this;\n }", "@Test\n public void testImpalaParquetTimestampInt96AsTimeStamp() throws Exception {\n try {\n BaseTestQuery.alterSession(PARQUET_NEW_RECORD_READER, false);\n compareParquetInt96Converters(\"field_impala_ts\", \"cp.`parquet/int96_impala_1.parquet`\");\n BaseTestQuery.alterSession(PARQUET_NEW_RECORD_READER, true);\n compareParquetInt96Converters(\"field_impala_ts\", \"cp.`parquet/int96_impala_1.parquet`\");\n } finally {\n BaseTestQuery.resetSessionOption(PARQUET_NEW_RECORD_READER);\n }\n }", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000002) == 0x00000002);\n }", "@Test\n public void testColumnFlatValueTimestampExpression() {\n final KijiRowExpression kijiRowExpression =\n new KijiRowExpression(\"family:qual0[0].ts\", TypeInfos.COLUMN_FLAT_VALUE);\n\n // Test that the KijiDataRequest was constructed correctly\n final KijiDataRequest kijiDataRequest = kijiRowExpression.getDataRequest();\n assertEquals(1, kijiDataRequest.getColumns().size());\n assertNotNull(kijiDataRequest.getColumn(\"family\", \"qual0\"));\n for (KijiDataRequest.Column column : kijiDataRequest.getColumns()) {\n assertTrue(column.getColumnName().isFullyQualified());\n assertEquals(1,\n kijiDataRequest.getColumn(column.getFamily(), column.getQualifier()).getMaxVersions());\n }\n }", "public void setDateDoc (Timestamp DateDoc);", "public void setDateDoc (Timestamp DateDoc);", "public void setDateDoc (Timestamp DateDoc);", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000040) == 0x00000040);\n }", "public void test_DATE_HHmmss_conditionBean() { // *Important!\r\n // ## Arrange ##\r\n Calendar cal = Calendar.getInstance();\r\n cal.set(2008, 5, 15, 12, 34, 56);\r\n cal.set(Calendar.MILLISECOND, 123);\r\n Member member = new Member();\r\n member.setMemberId(3);\r\n LocalDate targetDate = toLocalDate(cal);\r\n member.setBirthdate(targetDate);\r\n memberBhv.updateNonstrict(member);\r\n\r\n // ## Act ##\r\n cal.set(2008, 5, 15, 12, 34, 57); // plus one second\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because java.sql.Date is converted to java.util.Date in ConditionBean. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n cal.set(2008, 5, 15, 12, 34, 56); // just time\r\n cal.set(Calendar.MILLISECOND, 0); // Don't format!\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = DfTypeUtil.toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n }", "@Test\n public void shouldSerializeToTimestampWhenSerializingDateWithJackson() throws ParseException, JsonProcessingException {\n SimpleDateFormat df = new SimpleDateFormat(\"dd-MM-yyyy hh:mm\");\n df.setTimeZone(TimeZone.getTimeZone(\"UTC\"));\n\n Date date = df.parse(\"01-01-1970 01:00\");\n Event event = new Event(\"party\", date);\n\n ObjectMapper objectMapper = new ObjectMapper();\n String result = objectMapper.writeValueAsString(event);\n\n assertThat(result, containsString(\"party\"));\n assertThat(result, containsString(\"3600000\"));\n }", "@Test\n public void testImpalaParquetBinaryAsTimeStamp_DictChange() throws Exception {\n final String WORKING_PATH = TestTools.getWorkingPath();\n final String TEST_RES_PATH = WORKING_PATH + \"/src/test/resources\";\n testBuilder()\n .sqlQuery(\"select int96_ts from dfs.\\\"%s/parquet/int96_dict_change\\\" order by int96_ts\", TEST_RES_PATH)\n .ordered()\n .csvBaselineFile(\"testframework/testParquetReader/testInt96DictChange/q1.tsv\")\n .baselineTypes(TypeProtos.MinorType.TIMESTAMP)\n .baselineColumns(\"int96_ts\")\n .build().run();\n }", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000040) == 0x00000040);\n }", "private TimestampUtils(){}", "public void setTimestamp(java.lang.Long value) {\n this.timestamp = value;\n }", "public void setTimestamp(java.lang.Long value) {\n this.timestamp = value;\n }", "@JsonProperty(\"timestamp\")\n public void setTimestamp(Double timestamp) {\n this.timestamp = timestamp;\n }", "public void setDateAcct (Timestamp DateAcct);" ]
[ "0.6882056", "0.6726877", "0.64846486", "0.64817333", "0.63776785", "0.6333653", "0.6333653", "0.6333653", "0.6333653", "0.6333653", "0.6333653", "0.6333653", "0.6272805", "0.6259626", "0.61703455", "0.61352193", "0.6129139", "0.6119334", "0.6089663", "0.60614973", "0.60504264", "0.60491043", "0.60465723", "0.60395414", "0.6035357", "0.6035357", "0.60326964", "0.60241014", "0.60212415", "0.6019549", "0.6018986", "0.6007818", "0.59854805", "0.5969364", "0.5956896", "0.5940227", "0.5940166", "0.58686334", "0.5867526", "0.58618987", "0.583692", "0.5836", "0.5835691", "0.58301604", "0.5827618", "0.5824383", "0.58200467", "0.58157283", "0.57890683", "0.57823986", "0.57416344", "0.5731745", "0.57149696", "0.56826985", "0.5680923", "0.56772155", "0.5673435", "0.56696236", "0.5665917", "0.56591606", "0.56586725", "0.5647882", "0.56413704", "0.5632674", "0.5630108", "0.56291366", "0.56056476", "0.56056476", "0.56046784", "0.5597146", "0.5575892", "0.556878", "0.55671763", "0.55637735", "0.5555495", "0.55410844", "0.5540903", "0.5535931", "0.5535931", "0.5535314", "0.55318356", "0.5529222", "0.55271906", "0.5522397", "0.5515649", "0.55143803", "0.55088645", "0.550614", "0.550614", "0.550614", "0.5495423", "0.5493068", "0.54912263", "0.54836935", "0.54749763", "0.54578406", "0.54446554", "0.54446554", "0.54389274", "0.5435578" ]
0.6081879
19
Test the behavior of setObject for timestamp columns.
@Test public void testSetOffsetDateTime() throws SQLException { List<String> zoneIdsToTest = getZoneIdsToTest(); List<TimeZone> storeZones = new ArrayList<TimeZone>(); for (String zoneId : zoneIdsToTest) { storeZones.add(TimeZone.getTimeZone(zoneId)); } List<String> datesToTest = getDatesToTest(); for (TimeZone timeZone : storeZones) { ZoneId zoneId = timeZone.toZoneId(); for (String date : datesToTest) { LocalDateTime localDateTime = LocalDateTime.parse(date); String expected = date.replace('T', ' '); offsetTimestamps(zoneId, localDateTime, expected, storeZones); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Test\n public void testDateTimeType() throws Exception {\n if(util.isHiveCatalogStoreRunning()) return;\n\n ResultSet res = null;\n TajoClient client = util.newTajoClient();\n try {\n String tableName = \"datetimetable\";\n String query = \"select col1, col2, col3 from \" + tableName;\n\n String [] table = new String[] {tableName};\n Schema schema = new Schema();\n schema.addColumn(\"col1\", Type.DATE);\n schema.addColumn(\"col2\", Type.TIME);\n schema.addColumn(\"col3\", Type.TIMESTAMP);\n Schema [] schemas = new Schema[] {schema};\n String [] data = {\n \"2014-01-01|01:00:00|2014-01-01 01:00:00\"\n };\n KeyValueSet tableOptions = new KeyValueSet();\n tableOptions.set(StorageConstants.TEXT_DELIMITER, StorageConstants.DEFAULT_FIELD_DELIMITER);\n\n res = TajoTestingCluster\n .run(table, schemas, tableOptions, new String[][]{data}, query, client);\n\n assertTrue(res.next());\n\n Date date = res.getDate(1);\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n date = res.getDate(\"col1\");\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n Time time = res.getTime(2);\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n time = res.getTime(\"col2\");\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n Timestamp timestamp = res.getTimestamp(3);\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n timestamp = res.getTimestamp(\"col3\");\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n // assert with timezone\n Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(\"GMT+9\"));\n date = res.getDate(1, cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n date = res.getDate(\"col1\", cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n time = res.getTime(2, cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n time = res.getTime(\"col2\", cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n timestamp = res.getTimestamp(3, cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n\n timestamp = res.getTimestamp(\"col3\", cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n } finally {\n if (res != null) {\n res.close();\n }\n\n client.close();\n }\n }", "@Test\n public void test_column_type_detection_datetimes_01() throws SQLException {\n Model m = ModelFactory.createDefaultModel();\n testColumnTypeDetection(\"x\", m.createTypedLiteral(Calendar.getInstance()).asNode(), true, Types.TIMESTAMP, Timestamp.class.getCanonicalName());\n }", "@Test\n public void test_column_type_detection_datetimes_04() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"13:15:00.123\", XSDDatatype.XSDtime), true, Types.TIME, Time.class.getCanonicalName());\n }", "@Test\n public void test_column_type_detection_datetimes_03() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"13:15:00\", XSDDatatype.XSDtime), true, Types.TIME, Time.class.getCanonicalName());\n }", "public void setDateTrx (Timestamp DateTrx)\n{\nif (DateTrx == null) throw new IllegalArgumentException (\"DateTrx is mandatory\");\nset_Value (\"DateTrx\", DateTrx);\n}", "boolean hasTimestamp();", "boolean hasTimestamp();", "boolean hasTimestamp();", "boolean hasTimestamp();", "boolean hasTimestamp();", "boolean hasTimestamp();", "boolean hasTimestamp();", "public abstract void setDate(Timestamp uneDate);", "void setTimestamp(int index, Timestamp value)\n throws SQLException;", "@Test\n public void testTimestampColumnOptional() {\n Schema schema = Schema.newBuilder()\n .setTimestampColumn(\"timestamp\").build();\n\n Map<String, Value> map = new HashMap<>();\n map.put(\"timestamp\", Values.asTimestamp(Values.ofString(\"2019-01-30T19:30:12Z\")));\n\n PCollection<FeatureRow> output = pipeline\n .apply(Create.of(Lists.newArrayList(map)).withCoder(VALUE_MAP_CODER))\n .apply(new ValueMapToFeatureRowTransform(\"entity\", schema));\n\n PAssert.that(output).satisfies(maps -> {\n FeatureRow row = maps.iterator().next();\n assertEquals(\"entity\", row.getEntityName());\n assertEquals(map.get(\"timestamp\").getTimestampVal(), row.getEventTimestamp());\n return null;\n });\n pipeline.run();\n }", "@Test\n public void test_column_type_detection_datetimes_02() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"2013-04-08\", XSDDatatype.XSDdate), true, Types.DATE, Date.class.getCanonicalName());\n }", "public final void testSetTimeStamp() {\n Notification n = new Notification(\"type\", \"src\", 1);\n n.setTimeStamp(123);\n assertEquals(123, n.getTimeStamp());\n }", "public boolean set(long timestamp, T e) {\n return set(timestamp, e, false);\n }", "public boolean hasTimestamp() {\n return fieldSetFlags()[6];\n }", "@Test\n public void testSetLocalDateTime() throws SQLException {\n List<String> zoneIdsToTest = getZoneIdsToTest();\n List<String> datesToTest = getDatesToTest();\n\n for (String zoneId : zoneIdsToTest) {\n ZoneId zone = ZoneId.of(zoneId);\n for (String date : datesToTest) {\n LocalDateTime localDateTime = LocalDateTime.parse(date);\n String expected = localDateTime.atZone(zone)\n .format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)\n .replace('T', ' ');\n localTimestamps(zone, localDateTime, expected);\n }\n }\n }", "@Test\n public void testHiveParquetTimestampAsInt96_basic() throws Exception {\n BaseTestQuery.testBuilder().unOrdered().sqlQuery((\"SELECT convert_from(timestamp_field, 'TIMESTAMP_IMPALA') as timestamp_field \" + \"from cp.`parquet/part1/hive_all_types.parquet` \")).baselineColumns(\"timestamp_field\").baselineValues(TestBuilder.convertToLocalDateTime(\"2013-07-06 00:01:00\")).baselineValues(((Object) (null))).go();\n }", "@Test\n public void testSetOffsetTimeWithoutType() throws SQLException {\n OffsetTime data = OffsetTime.parse(\"16:21:51+12:34\");\n insertThenReadWithoutType(data, \"time_with_time_zone_column\", Time.class);\n }", "public void setTimestamp(Date timestamp) {\r\n this.timestamp = timestamp;\r\n }", "@Test\r\n public void testApplyChanges()\r\n {\r\n EasyMockSupport support = new EasyMockSupport();\r\n\r\n PreferencesRegistry registry = createPreferencesRegistry(support);\r\n CellSampler sampler = createSampler(support);\r\n ColumnDefinitionModel model = createModel();\r\n\r\n support.replayAll();\r\n\r\n @SuppressWarnings(\"unused\")\r\n ColumnDefinitionController controller = new ColumnDefinitionController(registry, model, sampler);\r\n\r\n ColumnDefinitionTableModel definitionTable = model.getDefinitionTableModel();\r\n\r\n CSVParseParameters parameters = model.getSelectedParameters();\r\n\r\n ColumnDefinitionRow timeRow = definitionTable.getRow(0);\r\n model.setSelectedDefinition(timeRow);\r\n timeRow.setFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\");\r\n\r\n SpecialColumn timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n ColumnDefinitionRow latRow = definitionTable.getRow(1);\r\n model.setSelectedDefinition(latRow);\r\n latRow.setDataType(null);\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n ColumnDefinitionRow lonRow = definitionTable.getRow(2);\r\n model.setSelectedDefinition(lonRow);\r\n lonRow.setColumnName(\"Longitude\");\r\n\r\n List<? extends String> columnNames = parameters.getColumnNames();\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n\r\n ColumnDefinitionRow name2 = definitionTable.getRow(4);\r\n model.setSelectedDefinition(name2);\r\n name2.setIsImport(true);\r\n\r\n columnNames = parameters.getColumnNames();\r\n assertEquals(ColumnHeaders.TIME.toString(), columnNames.get(0));\r\n assertEquals(ColumnHeaders.LAT.toString(), columnNames.get(1));\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n assertEquals(ColumnHeaders.NAME.toString(), columnNames.get(3));\r\n assertEquals(ColumnHeaders.NAME2.toString(), columnNames.get(4));\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n SpecialColumn lonColumn = parameters.getSpecialColumn(ColumnType.LON);\r\n assertEquals(2, lonColumn.getColumnIndex());\r\n assertEquals(\"Decimal\", lonColumn.getFormat());\r\n\r\n assertTrue(parameters.getColumnsToIgnore().isEmpty());\r\n\r\n support.verifyAll();\r\n }", "public void setDateTrx (Timestamp DateTrx);", "public void setDateTrx (Timestamp DateTrx);", "public boolean hasTimestamp() {\n return fieldSetFlags()[2];\n }", "@Test\n public void testSetLocalTimeWithType() throws SQLException {\n LocalTime data = LocalTime.parse(\"16:21:51\");\n Time actual = insertThenReadWithType(data, Types.TIME, \"time_without_time_zone_column\", Time.class);\n Time expected = Time.valueOf(\"16:21:51\");\n assertEquals(expected, actual);\n }", "public void setTimestamp(Date timestamp) {\n this.timestamp = timestamp;\n }", "@Override\n\tpublic void visit(TimestampValue arg0) {\n\n\t}", "@Test\n public void testSetOffsetTimeWithType() throws SQLException {\n OffsetTime data = OffsetTime.parse(\"16:21:51+12:34\");\n insertThenReadWithType(data, Types.TIME, \"time_with_time_zone_column\", Time.class);\n }", "@Override\n\tpublic void visit(TimestampValue arg0) {\n\t\t\n\t}", "public boolean hasTimestamp() {\n return fieldSetFlags()[0];\n }", "void setTimestamp(int index, Timestamp value, Calendar cal)\n throws SQLException;", "public void setTimestamp(Timestamp timestamp) {\n\t\tthis.timestamp = timestamp;\n\t}", "@Test\n public void testSetLocalTimeWithoutType() throws SQLException {\n LocalTime data = LocalTime.parse(\"16:21:51\");\n Time actual = insertThenReadWithoutType(data, \"time_without_time_zone_column\", Time.class);\n Time expected = Time.valueOf(\"16:21:51\");\n assertEquals(expected, actual);\n }", "public void setValidTo (Timestamp ValidTo);", "@OfMethod({\"setTimestamp(java.lang.String,java.sql.Timeastamp)\",\n \"setTimestamp(java.lang.String,java.sql.Timestamp,java.util.Calendar)\",\n \"setTimestamp(int,java.sql.Timestamp)\",\n \"setTimestamp(int,java.sql.Timestamp,java.util.Calendar)\"})\n public void testSetTimestamp() throws Exception {\n CallableStatement instance = newClosedCall();\n\n try {\n instance.setTimestamp(getParameterName(), Timestamp.valueOf(\"2007-05-02 04:48:01\"));\n fail(\"Allowed set timestamp by parameter name after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTimestamp(getParameterName(), Timestamp.valueOf(\"2007-05-02 04:48:01\"), Calendar.getInstance());\n fail(\"Allowed set timestamp by parameter name and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTimestamp(getParameterIndex(), Timestamp.valueOf(\"2007-05-02 04:48:01\"));\n fail(\"Allowed set time by parameter index after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTimestamp(getParameterIndex(), Timestamp.valueOf(\"2007-05-02 04:48:01\"), Calendar.getInstance());\n fail(\"Allowed set timestamp by parameter index and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n }", "@Test\r\n public void testTimestampDuration() throws Exception\r\n {\r\n Timestamp ts = new Timestamp(100110L).applyTimeOrigin(0L);\r\n\r\n GCEvent e = getGCEventToTest(ts, 7L);\r\n\r\n // time (dedicated accessor and generic field)\r\n assertEquals(100110L, e.getTime().longValue());\r\n assertEquals(100110L, ((Long)e.get(FieldType.TIME).getValue()).longValue());\r\n\r\n // offset (dedicated accessor and generic field)\r\n assertEquals(100110L, e.getOffset().longValue());\r\n assertEquals(\"100.110\", e.get(FieldType.OFFSET).getValue());\r\n\r\n // duration (dedicated accessor and generic field)\r\n assertEquals(7L, e.getDuration());\r\n assertEquals(7L, ((Long) e.get(FieldType.DURATION).getValue()).longValue());\r\n }", "public abstract void setFecha_ingreso(java.sql.Timestamp newFecha_ingreso);", "@Test\n public void testImpalaParquetBinaryAsTimeStamp_DictChange() throws Exception {\n try {\n BaseTestQuery.testBuilder().sqlQuery(\"select min(int96_ts) date_value from dfs.`parquet/int96_dict_change`\").optionSettingQueriesForTestQuery(\"alter session set `%s` = true\", PARQUET_READER_INT96_AS_TIMESTAMP).ordered().baselineColumns(\"date_value\").baselineValues(TestBuilder.convertToLocalDateTime(\"1970-01-01 00:00:01.000\")).build().run();\n } finally {\n BaseTestQuery.resetSessionOption(PARQUET_READER_INT96_AS_TIMESTAMP);\n }\n }", "public void set(final Timestamp timestamp) {\n stamp = timestamp.get();\n }", "public void setTimestamp(Integer timestamp) {\n this.timestamp = timestamp;\n }", "public void setSOHTimestamp(Date SOHTimestamp) {\r\n/* 482 */ this._SOHTimestamp = SOHTimestamp;\r\n/* */ }", "public void setTimestamp(@NonNull Date timestamp) {\n this.timestamp = timestamp;\n }", "public void setTimestamp(Long timestamp) {\n this.timestamp = timestamp;\n }", "public interface Timestampable {\r\n \r\n /**\r\n * Property which represents createdDate.\r\n */\r\n static final String PROP_CREATED_DATE = \"createdDate\";\r\n \r\n /**\r\n * Property which represents modifiedDate.\r\n */\r\n static final String PROP_MODIFIED_DATE = \"modifiedDate\";\r\n \r\n\r\n \r\n Date getCreatedDate();\r\n \r\n void setCreatedDate(Date createdDate);\r\n \r\n Date getModifiedDate();\r\n \r\n void setModifiedDate(Date modifiedDate);\r\n\r\n}", "public boolean hasTimestamp() {\n return timestamp_ != null;\n }", "public void setModified(java.sql.Timestamp tmp) {\n this.modified = tmp;\n }", "@Test\n public void testSetLocalTimeAndReadBack() throws SQLException {\n // TODO: fix for binary mode.\n // Avoid micros truncation in org.postgresql.jdbc.PgResultSet#internalGetObject\n assumeBinaryModeRegular();\n LocalTime data = LocalTime.parse(\"16:21:51.123456\");\n\n insertWithoutType(data, \"time_without_time_zone_column\");\n\n String readBack = readString(\"time_without_time_zone_column\");\n assertEquals(\"16:21:51.123456\", readBack);\n }", "public boolean hasTimestamp() {\n return result.hasTimestamp();\n }", "public boolean hasTimestamp() {\n return timestampBuilder_ != null || timestamp_ != null;\n }", "public void setDia_especifico(java.sql.Timestamp newDia_especifico);", "public void setStatementDate (Timestamp StatementDate);", "@Test\n public void testTimeStampRounding() throws SQLException {\n assumeBinaryModeRegular();\n LocalTime time = LocalTime.parse(\"23:59:59.999999500\");\n Time actual = insertThenReadWithoutType(time, \"time_without_time_zone_column\", Time.class, false/*no roundtrip*/);\n assertEquals(Time.valueOf(\"24:00:00\"), actual);\n }", "@JsProperty(name = \"timestamp\")\n public native void setTimestamp(@DoNotAutobox Number value);", "@Test\n public void testTimeStampRoundingWithType() throws SQLException {\n assumeBinaryModeRegular();\n LocalTime time = LocalTime.parse(\"23:59:59.999999500\");\n Time actual =\n insertThenReadWithType(time, Types.TIME, \"time_without_time_zone_column\", Time.class, false/*no roundtrip*/);\n assertEquals(Time.valueOf(\"24:00:00\"), actual);\n }", "@Override\r\n public void setTimeStamp(long parseLong) throws IOException {\n\r\n }", "public void setFecha(java.sql.Timestamp newFecha);", "public void setTimestamp(final Date timestamp) {\r\n mTimestamp = timestamp;\r\n }", "@JsonSetter(\"product_timestamps\")\n public void setProductTimestamps (ProductTimestamps value) { \n this.productTimestamps = value;\n }", "@Test\n public void updatedAtTest() {\n // TODO: test updatedAt\n }", "@Test\r\n\tpublic void testSetDate() {\n\t\tfail(\"Not yet implemented\");\r\n\t}", "protected void setTimestamp(long time) \n {\n\t\tlTimestamp = time;\n\t}", "public void setTimestamp(long value) {\r\n this.timestamp = value;\r\n }", "public abstract void setFecha_fin(java.sql.Timestamp newFecha_fin);", "public boolean hasTimestamp() {\r\n return ((bitField0_ & 0x00000001) == 0x00000001);\r\n }", "public boolean hasTimestamp() {\r\n return ((bitField0_ & 0x00000001) == 0x00000001);\r\n }", "public void setDateOrdered (Timestamp DateOrdered);", "public void setTimestamp() {\n timestamp = System.nanoTime();\n }", "public void setValidFrom (Timestamp ValidFrom);", "public void setMovementDate (Timestamp MovementDate);", "public final void testGetTimeStamp() {\n assertEquals(hello.timeStamp, n.getTimeStamp());\n }", "public Timestamp getDateTrx() \n{\nreturn (Timestamp)get_Value(\"DateTrx\");\n}", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000001) == 0x00000001);\n }", "public void setFecha_envio(java.sql.Timestamp newFecha_envio);", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000001) == 0x00000001);\n }", "public boolean hasTimestamp() {\r\n return ((bitField0_ & 0x00000001) == 0x00000001);\r\n }", "public boolean hasTimestamp() {\r\n return ((bitField0_ & 0x00000001) == 0x00000001);\r\n }", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000008) == 0x00000008);\n }", "@NoProxy\n public void setDtstamps(final Timestamp val) {\n DateTime dt = new DateTime(val);\n setDtstamp(new DtStamp(dt).getValue());\n setLastmod(new LastModified(dt).getValue());\n setCtoken(getLastmod() + \"-\" + hex4FromNanos(val.getNanos()));\n\n if (getCreated() == null) {\n setCreated(new Created(dt).getValue());\n }\n }", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000008) == 0x00000008);\n }", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000002) == 0x00000002);\n }", "public TimeSeriesPoint setTimestamp(OffsetDateTime timestamp) {\n this.timestamp = timestamp;\n return this;\n }", "@Test\n public void testImpalaParquetTimestampInt96AsTimeStamp() throws Exception {\n try {\n BaseTestQuery.alterSession(PARQUET_NEW_RECORD_READER, false);\n compareParquetInt96Converters(\"field_impala_ts\", \"cp.`parquet/int96_impala_1.parquet`\");\n BaseTestQuery.alterSession(PARQUET_NEW_RECORD_READER, true);\n compareParquetInt96Converters(\"field_impala_ts\", \"cp.`parquet/int96_impala_1.parquet`\");\n } finally {\n BaseTestQuery.resetSessionOption(PARQUET_NEW_RECORD_READER);\n }\n }", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000002) == 0x00000002);\n }", "@Test\n public void testColumnFlatValueTimestampExpression() {\n final KijiRowExpression kijiRowExpression =\n new KijiRowExpression(\"family:qual0[0].ts\", TypeInfos.COLUMN_FLAT_VALUE);\n\n // Test that the KijiDataRequest was constructed correctly\n final KijiDataRequest kijiDataRequest = kijiRowExpression.getDataRequest();\n assertEquals(1, kijiDataRequest.getColumns().size());\n assertNotNull(kijiDataRequest.getColumn(\"family\", \"qual0\"));\n for (KijiDataRequest.Column column : kijiDataRequest.getColumns()) {\n assertTrue(column.getColumnName().isFullyQualified());\n assertEquals(1,\n kijiDataRequest.getColumn(column.getFamily(), column.getQualifier()).getMaxVersions());\n }\n }", "public void setDateDoc (Timestamp DateDoc);", "public void setDateDoc (Timestamp DateDoc);", "public void setDateDoc (Timestamp DateDoc);", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000040) == 0x00000040);\n }", "public void test_DATE_HHmmss_conditionBean() { // *Important!\r\n // ## Arrange ##\r\n Calendar cal = Calendar.getInstance();\r\n cal.set(2008, 5, 15, 12, 34, 56);\r\n cal.set(Calendar.MILLISECOND, 123);\r\n Member member = new Member();\r\n member.setMemberId(3);\r\n LocalDate targetDate = toLocalDate(cal);\r\n member.setBirthdate(targetDate);\r\n memberBhv.updateNonstrict(member);\r\n\r\n // ## Act ##\r\n cal.set(2008, 5, 15, 12, 34, 57); // plus one second\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because java.sql.Date is converted to java.util.Date in ConditionBean. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n cal.set(2008, 5, 15, 12, 34, 56); // just time\r\n cal.set(Calendar.MILLISECOND, 0); // Don't format!\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = DfTypeUtil.toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n }", "@Test\n public void shouldSerializeToTimestampWhenSerializingDateWithJackson() throws ParseException, JsonProcessingException {\n SimpleDateFormat df = new SimpleDateFormat(\"dd-MM-yyyy hh:mm\");\n df.setTimeZone(TimeZone.getTimeZone(\"UTC\"));\n\n Date date = df.parse(\"01-01-1970 01:00\");\n Event event = new Event(\"party\", date);\n\n ObjectMapper objectMapper = new ObjectMapper();\n String result = objectMapper.writeValueAsString(event);\n\n assertThat(result, containsString(\"party\"));\n assertThat(result, containsString(\"3600000\"));\n }", "@Test\n public void testImpalaParquetBinaryAsTimeStamp_DictChange() throws Exception {\n final String WORKING_PATH = TestTools.getWorkingPath();\n final String TEST_RES_PATH = WORKING_PATH + \"/src/test/resources\";\n testBuilder()\n .sqlQuery(\"select int96_ts from dfs.\\\"%s/parquet/int96_dict_change\\\" order by int96_ts\", TEST_RES_PATH)\n .ordered()\n .csvBaselineFile(\"testframework/testParquetReader/testInt96DictChange/q1.tsv\")\n .baselineTypes(TypeProtos.MinorType.TIMESTAMP)\n .baselineColumns(\"int96_ts\")\n .build().run();\n }", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000040) == 0x00000040);\n }", "private TimestampUtils(){}", "public void setTimestamp(java.lang.Long value) {\n this.timestamp = value;\n }", "public void setTimestamp(java.lang.Long value) {\n this.timestamp = value;\n }", "@JsonProperty(\"timestamp\")\n public void setTimestamp(Double timestamp) {\n this.timestamp = timestamp;\n }", "public void setDateAcct (Timestamp DateAcct);" ]
[ "0.6882056", "0.6726877", "0.64846486", "0.64817333", "0.63776785", "0.6333653", "0.6333653", "0.6333653", "0.6333653", "0.6333653", "0.6333653", "0.6333653", "0.6272805", "0.6259626", "0.61703455", "0.61352193", "0.6129139", "0.6119334", "0.6089663", "0.6081879", "0.60614973", "0.60504264", "0.60491043", "0.60465723", "0.6035357", "0.6035357", "0.60326964", "0.60241014", "0.60212415", "0.6019549", "0.6018986", "0.6007818", "0.59854805", "0.5969364", "0.5956896", "0.5940227", "0.5940166", "0.58686334", "0.5867526", "0.58618987", "0.583692", "0.5836", "0.5835691", "0.58301604", "0.5827618", "0.5824383", "0.58200467", "0.58157283", "0.57890683", "0.57823986", "0.57416344", "0.5731745", "0.57149696", "0.56826985", "0.5680923", "0.56772155", "0.5673435", "0.56696236", "0.5665917", "0.56591606", "0.56586725", "0.5647882", "0.56413704", "0.5632674", "0.5630108", "0.56291366", "0.56056476", "0.56056476", "0.56046784", "0.5597146", "0.5575892", "0.556878", "0.55671763", "0.55637735", "0.5555495", "0.55410844", "0.5540903", "0.5535931", "0.5535931", "0.5535314", "0.55318356", "0.5529222", "0.55271906", "0.5522397", "0.5515649", "0.55143803", "0.55088645", "0.550614", "0.550614", "0.550614", "0.5495423", "0.5493068", "0.54912263", "0.54836935", "0.54749763", "0.54578406", "0.54446554", "0.54446554", "0.54389274", "0.5435578" ]
0.60395414
24
TODO: fix for binary
@Test public void testTimeStampRounding() throws SQLException { assumeBinaryModeRegular(); LocalTime time = LocalTime.parse("23:59:59.999999500"); Time actual = insertThenReadWithoutType(time, "time_without_time_zone_column", Time.class, false/*no roundtrip*/); assertEquals(Time.valueOf("24:00:00"), actual); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Override\n\tpublic void interpretBytes() {\n\t\t\n\t}", "boolean supportsBinaryInProc();", "private String toBinary( byte[] bytes )\n\t{\n \t\tStringBuilder sb = new StringBuilder(bytes.length * Byte.SIZE);\n\t\tfor( int i = 0; i < Byte.SIZE * bytes.length; i++ )\n\t\t\tsb.append((bytes[i / Byte.SIZE] << i % Byte.SIZE & 0x80) == 0 ? '0' : '1');\n\t\treturn sb.toString();\n\t}", "public void setBinmode() {\n }", "public boolean isBinary()\n {\n return false;\n }", "FedoraBinary asBinary(Node node);", "public boolean canHandleBinaryNatively()\n/* */ {\n/* 391 */ return false;\n/* */ }", "boolean isBinary();", "void mo30633b(int i, String str, byte[] bArr);", "public abstract byte[] mo32305a(String str);", "static StringBuilder convert_to_binary(String msg) {\n byte[] bytes = msg.getBytes();\r\n StringBuilder binary = new StringBuilder();\r\n for (byte b : bytes) {\r\n int val = b;\r\n for (int i = 0; i < 8; i++) {\r\n binary.append((val & 128) == 0 ? 0 : 1);\r\n val <<= 1;\r\n }\r\n binary.append(\"\");\r\n }\r\n return binary;\r\n }", "@Test\n\tpublic void testBytesToHexStringForSrcMode() throws Exception {\n//TODO: Test goes here... \n\t}", "private ByteTools(){}", "default String getFileExtension() {\n return \"bin\";\n }", "public /*byte[]*/String BinaryCaster(Object item){\n String Sitem = Integer.toBinaryString((int)item);\n //byte[] b = new byte[Sitem.length()];\n //for(int i=0;i<Sitem.length();i++){\n // b[i] = (byte)Sitem.charAt(i);\n //}\n //return b;\n return Sitem;\n }", "SQLBinary()\n\t{\n\t}", "boolean isBinary(String str)\n\t{\n\t if(str.length() < 1) return false;\n\t \n\t for(int i=0; i<str.length(); i++){\n\t char t = str.charAt(i);\n\t if(t=='1' || t=='0') continue;\n\t else return false;\n\t }\n\t \n\t return true;\n\t}", "public static void main(String[] args) {\n\n byte b1 = 0b1010; //door 0b eerst te noteren maken we er een 'binary literal' van\n byte b2 = 0b0100;\n byte b3 = (byte) (b1 + b2); //het resultaat is zonder een typecasting een int (door het plusje)\n //dus we typecasten het eerst naar een byte\n\n //bij het printen converteren we b3 naar een binary literal in String vorm om de daadwerkelijke binaire som te krijgen\n System.out.println(\"b3: \" + Integer.toBinaryString(b3));\n }", "void mo8445a(int i, String str, int i2, byte[] bArr);", "byte[] mo38566a();", "public static void main(String[] args) {\n\t\tint a = 103217;\n\t\tSystem.out.println(AssortedMethods.toFullBinaryString(a));\n\t\tint b = 13;\n\t\tSystem.out.println(AssortedMethods.toFullBinaryString(b));\t\t\n\t\tint c = updateBits(a, b, 4, 12);\n\t\tSystem.out.println(AssortedMethods.toFullBinaryString(c));\n\t\t\t\n\t}", "@Override\n public Binary getBinary() throws ValueFormatException, RepositoryException {\n return null;\n }", "private static int batoi(byte[] inp) {\n int len = inp.length>4?4:inp.length;\n int total = 0;\n for (int i = 0; i < len; i++) {\n total += (inp[i]<0?256+inp[i]:(int)inp[i]) << (((len - 1) - i) * 8);\n }\n return total;\n }", "public String convertToAssemblyBin(String bin)\n {\n if(bin.equals(\"01101001010000000000000100000000\"))\n {\n return \"MOVEZ X0 data\";\n } else if(bin.equals(\"01111100001000000000000000000001\"))\n {\n return \"LDUR X1, X0, #0\";\n } else if(bin.equals(\"01011010000000000000001000000010\"))\n {\n return \"CBZ X2, #32\";\n } else if(bin.equals(\"00000000101000000000000000001100\"))\n {\n return \"B #12\";\n } else if(bin.equals(\"00000100100010000001010000100010\"))\n {\n return \"ADDI X2, X2, #20\";\n }else if(bin.equals(\"00000110010110000001000000100010\"))\n {\n return \"SUB X2, X1, X2\";\n }else if(bin.equals(\"00000010001000100000000000000010\"))\n {\n return \"PUSH X2\";\n }else if(bin.equals(\"00000000000000000000000000000000\"))\n {\n return \"NOP\";\n }else if(bin.equals(\"00000011001100110000000000000011\"))\n {\n return \"POP X3\";\n }else if(bin.equals(\"01111100000000000000000000000011\"))\n {\n return \"STUR X3, X0, #0\";\n }else if(bin.equals(\"00000110010100000010000000110011\"))\n {\n return \"EOR X3, X2, X3\";\n }else if(bin.equals(\"01011010000000000000000001000011\"))\n {\n return \"CBZ X3, #4\";\n }else if(bin.equals(\"00010001000100010001000100010001\"))\n {\n return \"HALT\";\n } else if(bin.equals(\"00000000101010111010101100000000\") || bin.equals(\"00000000000000001010101100000000\"))\n {\n return \"DATA VALUE: \" + Integer.parseInt(\"ab\", 16);\n } else if(bin.equals(\"00000000000000000000110111101111\"))\n {\n return \"STACK VALUE: \" + Integer.parseInt(\"def\", 16);\n }\n return \"\";\n }", "public java.lang.String getBin() {\r\n return bin;\r\n }", "@Test\n public void test2(){\n\n String s =\"1000000000000001\";\n //s = BinaryCalculate.BinaryArithmeticalRightShift(s,1);\n s = BinaryCalculate.BinaryLogicRightShift(s,1);\n int a = BitConversion.fromBinaryStringToInt(s);\n System.out.println(a);\n }", "public abstract String toString(String bin);", "private String removeBinFirstAndLast(String runtimeBin) {\n if (StringUtils.isBlank(runtimeBin)) {\n return null;\n }\n if (runtimeBin.startsWith(\"0x\")) {\n runtimeBin = StringUtils.removeStart(runtimeBin, \"0x\");\n }\n if (runtimeBin.length() > 68) {\n runtimeBin = runtimeBin.substring(0, runtimeBin.length() - 68);\n }\n return runtimeBin;\n }", "static int beautifulBinaryString(String b) {\n int index = b.indexOf(\"010\", 0) ;\n int change = 0;\n while (index != -1) {\n change++;\n index = b.indexOf(\"010\", index + 3) ;\n }\n return change;\n }", "private byte[] fromHex(String hex)\n {\n byte[] binary = new byte[hex.length() / 2];\n for(int i = 0; i < binary.length; i++)\n {\n binary[i] = (byte)Integer.parseInt(hex.substring(2*i, 2*i+2), 16);\n }\n return binary;\n }", "byte mo30283c();", "public Binary() { \n\t_decNum = 0;\n\t_binNum = \"0\";\n }", "ByteOrder byteOrder();", "private String toBinary(byte caracter){\n byte byteDeCaracter = (byte)caracter;\n String binario=\"\";\n for( int i = 7; i>=0; i--){\n binario += ( ( ( byteDeCaracter & ( 1<<i ) ) > 0 ) ? \"1\" : \"0\" ) ;\n }\n return binario;\n }", "private static void spacesToBinary() {\n\t\tString stringBinary = \"\"; \n\t\tfor(int i = 0; i < spaces.length; i++) {\n\t\t\tif(spaces[i].length() % 2 == 0) { stringBinary += \"1\"; }\n\t\t\telse if(spaces[i].length() % 2 == 1) { stringBinary += \"0\"; }\n\n\t\t\tif(i != 0 && (i+1) % 5 == 0) {\n\t\t\t\tbinary.add(stringBinary);\n\t\t\t\tstringBinary = \"\";\n\t\t\t} \n\t\t\telse if(i+1 == spaces.length) {\n\t\t\t\tfor(int k = (i+1)%5; k < 5; k++) {\n\t\t\t\t\tstringBinary += \"0\";\n\t\t\t\t}\n\t\t\t\tbinary.add(stringBinary);\n\t\t\t\tstringBinary = \"\";\n\t\t\t}\n\t\t}\n\t}", "@Test\n public void testToBinary() {\n Object[][] datas = new Object[][]{\n {0, \"0\"},\n {5, \"101\"},\n {10, \"1010\"},\n {11, \"1011\"}\n };\n for (Object[] data : datas) {\n String result = Tools.toBinary((int) data[0]); //Actual\n String expResult = (String) data[1]; //Expected\n assertEquals(result, expResult);\n System.out.println(\"testToBinary()\");\n }\n }", "public boolean isHexBinary() {\n return false;\n }", "boolean hasBinaryData();", "@Override\n\tpublic String convert2Binary(int num) {\n\t\treturn null;\n\t}", "public static void main(String[] args) {\n\t\tint x = ~0;\r\n\t\tSystem.out.println(Integer.toBinaryString(x));\r\n\t\tint y = x>>>8;\r\n\t\tSystem.out.println(Integer.toBinaryString(y));\r\n\t\tSystem.out.println(x+\" \"+y);\r\n\t\t\r\n\t\tint N = 1<<31;\r\n\t\tint M = 0b11;\r\n\t\tint j=2;\r\n\t\tint i=1;\r\n\t\tSystem.out.println(Integer.toBinaryString(N));\r\n\t\tSystem.out.println(Integer.toBinaryString(M));\r\n\t\tSystem.out.println(Integer.toBinaryString(insertMIntoNFromJtoI(M, N, j, i)));\r\n\t\t\r\n\t}", "public String getBinaryMnemonic(){\n\t\tswitch(this) {\n\t\tcase STOP -> \t{return \t\"00000000\";}\n\t\tcase RETTR -> \t{return \t\"00000001\";}\n\t\tcase MOVSPA -> \t{return \t\"00000010\";}\n\t\tcase MOVFLGA -> {return \t\"00000011\";}\n\t\t\n\t\tcase BR -> \t\t{return \t\"0000010\";}\n\t\tcase BRLE -> \t{return \t\"0000011\";}\n\t\tcase BRLT -> \t{return \t\"0000100\";}\n\t\tcase BREQ -> \t{return \t\"0000101\";}\n\t\tcase BRNE -> \t{return \t\"0000110\";}\n\t\tcase BRGE -> \t{return \t\"0000111\";}\n\t\tcase BRGT -> \t{return \t\"0001000\";}\n\t\tcase BRV -> \t{return \t\"0001001\";}\n\t\tcase BRC -> \t{return \t\"0001010\";}\n\t\tcase CALL -> \t{return \t\"0001011\";}\n\t\t\n\t\tcase NOTA -> \t{return \t\"00011000\";}\n\t\tcase NOTX -> \t{return \t\"00011001\";}\n\t\tcase NEGA -> \t{return \t\"00011010\";}\n\t\tcase NEGX -> \t{return \t\"00011011\";}\n\t\tcase ASLA -> \t{return \t\"00011100\";}\n\t\tcase ASLX -> \t{return \t\"00011101\";}\n\t\tcase ASRA -> \t{return \t\"00011110\";}\n\t\tcase ASRX -> \t{return \t\"00011111\";}\n\t\tcase ROLA -> \t{return \t\"00100000\";}\n\t\tcase ROLX -> \t{return \t\"00100001\";}\n\t\tcase RORA -> \t{return \t\"00100010\";}\n\t\tcase RORX -> \t{return \t\"00100011\";}\n\t\t\n\t\tcase NOP -> \t{return \t\"00101\";}\n\t\tcase DECI -> \t{return \t\"00110\";}\n\t\tcase DECO -> \t{return \t\"00111\";}\n\t\tcase STRO -> \t{return \t\"01000\";}\n\t\tcase CHARI -> \t{return \t\"01001\";}\n\t\tcase CHARO -> \t{return \t\"01010\";}\n\t\t\n//\t\tcase RETn\n\t\t\n\t\tcase ADDSP -> \t{return \t\"01100\";}\n\t\tcase SUBSP -> \t{return \t\"01101\";}\n\t\t\n\t\tcase ADDA -> \t{return \t\"0111\";}\n\t\tcase SUBA -> \t{return \t\"1000\";}\n\t\tcase ANDA -> \t{return \t\"1001\";}\n\t\tcase ORA -> \t{return \t\"1010\";}\n\t\tcase CPA -> \t{return \t\"1011\";}\n\t\tcase LDA -> \t{return \t\"1100\";}\n\t\tcase LDBYTEA -> {return \t\"1101\";}\n\t\tcase STA -> \t{return \t\"1110\";}\n\t\tcase STBYTEA -> {return \t\"1111\";}\n\t\t\n\t\tcase i -> \t{return \t\"000\";}\n\t\tcase d -> \t{return \t\"001\";}\n\t\tcase n -> \t{return \t\"010\";}\n\t\tcase s -> \t{return \t\"011\";}\n\t\tcase sf -> \t{return \t\"100\";}\n\t\tcase x -> \t{return \t\"101\";}\n\t\tcase sx -> \t{return \t\"110\";}\n\t\tcase sfx -> {return \t\"111\";}\n\t\t\n\t\tcase A -> {return \"0\";}\n\t\tcase X -> {return \"1\";}\n\t\t\n\t\tcase ADDRSS -> \t{return \"\";}\n\t\tcase ASCII -> \t{return \"\";}\n\t\tcase BLOCK -> \t{return \"\";}\n\t\tcase BURN -> \t{return \"\";}\n\t\tcase BYTE -> \t{return \"\";}\n\t\tcase END -> \t{return \"\";}\n\t\tcase EQUATE -> {return \"\";}\n\t\tcase WORD -> \t{return \"\";}\n\t\t\n\t\tdefault -> throw new IllegalArgumentException(\"This is an illegal mnemonic. \\nPlease double check your code.\");\n\t\t\n\t\t}\n\t\t\n\t}", "private static String validateBinaryStr(String binStr) throws UnsignedBigIntUtilsException {\n String tmpStr = RegExp.replaceAll(\"[ \\\\|\\\\t\\\\n]+\", binStr, \"\");\n tmpStr = RegExp.replaceFirst(\"0b\", tmpStr, \"\");\n if (tmpStr.matches(\"[0-1]+\") == false) {\n String msg = \"ERROR: Invalid BINARY characters in input => \" + tmpStr + \"\\n\";\n throw new UnsignedBigIntUtilsException(msg);\n }\n return (tmpStr);\n }", "public void setBin(java.lang.String bin) {\r\n this.bin = bin;\r\n }", "void mo1751a(byte[] bArr);", "void mo12206a(byte[] bArr);", "public boolean isBinary() {\n return this.isHexBinary() || this.isBase64Binary();\n }", "private void computeEncoding()\n{\n source_encoding = IvyFile.digestString(current_node.getKeyText());\n}", "byte[] mo12209b(int i);", "private void outDec(){\n\t\tSystem.out.println(binary);\n\t\tpw.println(binary);\n\t\t\n\t}", "public ByteArray getBin() {\n return bin;\n }", "byte[] getBytes();", "byte[] getBytes();", "private static java.io.File c(java.lang.String r8, java.lang.String r9) {\n /*\n r0 = 0;\n r1 = 0;\n r2 = new java.io.File;\t Catch:{ Exception -> 0x00e8, all -> 0x00e4 }\n r2.<init>(r8);\t Catch:{ Exception -> 0x00e8, all -> 0x00e4 }\n r8 = r2.exists();\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n if (r8 != 0) goto L_0x001d;\n L_0x000d:\n r8 = \"DecryptUtils\";\n r9 = \"unZipSingleFile file don't exist\";\n r3 = new java.lang.Object[r0];\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n com.taobao.sophix.e.d.e(r8, r9, r3);\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n com.taobao.sophix.e.b.a(r1);\n r2.delete();\n return r1;\n L_0x001d:\n r8 = new java.lang.StringBuilder;\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r8.<init>();\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r8.append(r9);\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r9 = java.io.File.separator;\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r8.append(r9);\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r9 = \"unzip\";\n r8.append(r9);\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r8 = r8.toString();\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r9 = new java.io.File;\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r9.<init>(r8);\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n com.taobao.sophix.e.b.a(r9);\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r3 = r9.exists();\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n if (r3 != 0) goto L_0x0044;\n L_0x0041:\n r9.mkdirs();\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n L_0x0044:\n r9 = new java.util.zip.ZipInputStream;\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r3 = new java.io.FileInputStream;\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r3.<init>(r2);\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r9.<init>(r3);\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n L_0x004e:\n r3 = r9.getNextEntry();\t Catch:{ Exception -> 0x00dc }\n if (r3 == 0) goto L_0x00f4;\n L_0x0054:\n r4 = r3.getName();\t Catch:{ Exception -> 0x00dc }\n r3 = r3.isDirectory();\t Catch:{ Exception -> 0x00dc }\n if (r3 == 0) goto L_0x0085;\n L_0x005e:\n r3 = r4.length();\t Catch:{ Exception -> 0x00dc }\n r3 = r3 + -1;\n r3 = r4.substring(r0, r3);\t Catch:{ Exception -> 0x00dc }\n r4 = new java.io.File;\t Catch:{ Exception -> 0x00dc }\n r5 = new java.lang.StringBuilder;\t Catch:{ Exception -> 0x00dc }\n r5.<init>();\t Catch:{ Exception -> 0x00dc }\n r5.append(r8);\t Catch:{ Exception -> 0x00dc }\n r6 = java.io.File.separator;\t Catch:{ Exception -> 0x00dc }\n r5.append(r6);\t Catch:{ Exception -> 0x00dc }\n r5.append(r3);\t Catch:{ Exception -> 0x00dc }\n r3 = r5.toString();\t Catch:{ Exception -> 0x00dc }\n r4.<init>(r3);\t Catch:{ Exception -> 0x00dc }\n r4.mkdirs();\t Catch:{ Exception -> 0x00dc }\n goto L_0x004e;\n L_0x0085:\n r3 = new java.io.File;\t Catch:{ Exception -> 0x00dc }\n r5 = new java.lang.StringBuilder;\t Catch:{ Exception -> 0x00dc }\n r5.<init>();\t Catch:{ Exception -> 0x00dc }\n r5.append(r8);\t Catch:{ Exception -> 0x00dc }\n r6 = java.io.File.separator;\t Catch:{ Exception -> 0x00dc }\n r5.append(r6);\t Catch:{ Exception -> 0x00dc }\n r5.append(r4);\t Catch:{ Exception -> 0x00dc }\n r4 = r5.toString();\t Catch:{ Exception -> 0x00dc }\n r3.<init>(r4);\t Catch:{ Exception -> 0x00dc }\n r3.createNewFile();\t Catch:{ Exception -> 0x00dc }\n r4 = new java.io.FileOutputStream;\t Catch:{ Exception -> 0x00c7, all -> 0x00c4 }\n r4.<init>(r3);\t Catch:{ Exception -> 0x00c7, all -> 0x00c4 }\n r5 = 1024; // 0x400 float:1.435E-42 double:5.06E-321;\n r5 = new byte[r5];\t Catch:{ Exception -> 0x00c2 }\n L_0x00aa:\n r6 = r9.read(r5);\t Catch:{ Exception -> 0x00c2 }\n r7 = -1;\n if (r6 == r7) goto L_0x00b8;\n L_0x00b1:\n r4.write(r5, r0, r6);\t Catch:{ Exception -> 0x00c2 }\n r4.flush();\t Catch:{ Exception -> 0x00c2 }\n goto L_0x00aa;\n L_0x00b8:\n com.taobao.sophix.e.b.a(r4);\t Catch:{ Exception -> 0x00dc }\n com.taobao.sophix.e.b.a(r9);\n r2.delete();\n return r3;\n L_0x00c2:\n r3 = move-exception;\n goto L_0x00c9;\n L_0x00c4:\n r8 = move-exception;\n r4 = r1;\n goto L_0x00d8;\n L_0x00c7:\n r3 = move-exception;\n r4 = r1;\n L_0x00c9:\n r5 = \"DecryptUtils\";\n r6 = \"unZipSingleFile unZip hotfix patch file error\";\n r7 = new java.lang.Object[r0];\t Catch:{ all -> 0x00d7 }\n com.taobao.sophix.e.d.a(r5, r6, r3, r7);\t Catch:{ all -> 0x00d7 }\n com.taobao.sophix.e.b.a(r4);\t Catch:{ Exception -> 0x00dc }\n goto L_0x004e;\n L_0x00d7:\n r8 = move-exception;\n L_0x00d8:\n com.taobao.sophix.e.b.a(r4);\t Catch:{ Exception -> 0x00dc }\n throw r8;\t Catch:{ Exception -> 0x00dc }\n L_0x00dc:\n r8 = move-exception;\n goto L_0x00eb;\n L_0x00de:\n r8 = move-exception;\n r9 = r1;\n goto L_0x00fc;\n L_0x00e1:\n r8 = move-exception;\n r9 = r1;\n goto L_0x00eb;\n L_0x00e4:\n r8 = move-exception;\n r9 = r1;\n r2 = r9;\n goto L_0x00fc;\n L_0x00e8:\n r8 = move-exception;\n r9 = r1;\n r2 = r9;\n L_0x00eb:\n r3 = \"DecryptUtils\";\n r4 = \"unZipSingleFile unZip hotfix patch file error\";\n r0 = new java.lang.Object[r0];\t Catch:{ all -> 0x00fb }\n com.taobao.sophix.e.d.a(r3, r4, r8, r0);\t Catch:{ all -> 0x00fb }\n L_0x00f4:\n com.taobao.sophix.e.b.a(r9);\n r2.delete();\n return r1;\n L_0x00fb:\n r8 = move-exception;\n L_0x00fc:\n com.taobao.sophix.e.b.a(r9);\n r2.delete();\n throw r8;\n */\n throw new UnsupportedOperationException(\"Method not decompiled: com.taobao.sophix.e.a.c(java.lang.String, java.lang.String):java.io.File\");\n }", "public abstract void mo9798a(byte b);", "byte[] getResult();", "public static String getBinaryFile(){\r\n return Input.getString(\"What is the name of the binary file? Please add .dat file extension: \");\r\n }", "public static void main(String[] args) {\n String a = \"101\", b = \"101\";\n System.out.print(addBinary(a, b));\n }", "void mo4520a(byte[] bArr);", "private void inputBin(){\n\t\tSystem.out.println(\"Enter a binary number (32 bit or less/multiple of 4):\");\n\t\tpw.println(\"Enter a binary number (32 bit or less/multiple of 4):\");\n\t\tScanner sc = new Scanner(System.in);\n\t\tbinary = sc.next();\n\t\tpw.println(binary);\n\t\t\n\t}", "@Test\n public void testByte() {\n assertEquals(\"127\", hiveTypeToJson(new MyHiveType(new ByteWritable(Byte.MAX_VALUE), byteTypeInfo)));\n }", "byte[] readBytes();", "public abstract void mo4360a(byte b);", "public abstract String mo11611b();", "private byte[] toByteArray(String s)\r\n\t\t{\n\t\t\tlong l = 0;\r\n\t\t\tif (s.startsWith(\"0x\") || s.startsWith(\"0X\")) {\r\n\t\t\t\tfinal byte[] d = new byte[(s.length() - 1) / 2];\r\n\t\t\t\tint k = (s.length() & 0x01) != 0 ? 3 : 4;\r\n\t\t\t\tfor (int i = 2; i < s.length(); i = k, k += 2)\r\n\t\t\t\t\td[(i - 1) / 2] = (byte) Short.parseShort(s.substring(i, k), 16);\r\n\t\t\t\treturn d;\r\n\t\t\t}\r\n\t\t\telse if (s.length() > 1 && s.startsWith(\"0\"))\r\n\t\t\t\tl = Long.parseLong(s, 8);\r\n\t\t\telse if (s.startsWith(\"b\"))\r\n\t\t\t\tl = Long.parseLong(s.substring(1), 2);\r\n\t\t\telse\r\n\t\t\t\tl = Long.parseLong(s);\r\n\t\t\tint i = 0;\r\n\t\t\tfor (long test = l; test != 0; test /= 0x100)\r\n\t\t\t\t++i;\r\n\t\t\tfinal byte[] d = new byte[i == 0 ? 1 : i];\r\n\t\t\tfor (; i-- > 0; l /= 0x100)\r\n\t\t\t\td[i] = (byte) (l & 0xff);\r\n\t\t\treturn d;\r\n\t\t}", "public void encodeBinary(Buf out)\n {\n out.u2(val.length()+1);\n for (int i=0; i<val.length(); ++i)\n out.u1(val.charAt(i));\n out.u1(0);\n }", "private void createBin(int size) \n\t{\n\t// create an array of the appropriate type\n\tfBin = (Object[]) Array.newInstance(fClass, size);\t\n\t}", "public static String TextToBinary(String input){\n\t\tString output = \"\";\n\t\tfor(int i = 0; i < input.length(); i++){\n\t\t\toutput += Integer.toBinaryString(0x100 | input.charAt(i)).substring(1);\n\t\t}\n\t\treturn output;\n\t}", "static void inputBin(int [] binToInt)\n {\n InputStreamReader instr = new InputStreamReader(System.in);\n BufferedReader stdin = new BufferedReader(instr);\n StringTokenizer stok;\n int num;\n String value;\n try\n {\n System.out.println(\"Input a 32 digit binary code. \");\n System.out.println();\n value = stdin.readLine();\n System.out.println();\n stok = new StringTokenizer(value);\n while (stok.hasMoreTokens())\n {\n for(int i = 0; i < 32; i++)\n {\n num = Integer.parseInt(stok.nextToken());\n int z = num;\n if (z == 0 || z == 1)\n {\n binToInt[i] = z;\n if(z == 1)\n {\n if(i == 0 || i == 8 || i == 16 || i == 24)\n {\n binToInt[i] = 128;\n }\n if(i == 1 || i == 9 || i == 17 || i == 25)\n {\n binToInt[i] = 64;\n }\n if(i == 2 || i == 10 || i == 18 || i == 26)\n {\n binToInt[i] = 32;\n }\n if(i == 3 || i == 11 || i == 19 || i == 27)\n {\n binToInt[i] = 16;\n }\n if(i == 4 || i == 12 || i == 20 || i == 28)\n {\n binToInt[i] = 8;\n }\n if(i == 5 || i == 13 || i == 21 || i == 29)\n {\n binToInt[i] = 4;\n }\n if(i == 6 || i == 14 || i == 22 || i == 30)\n {\n binToInt[i] = 2;\n }\n if(i == 7 || i == 15 || i == 23 || i == 31)\n {\n binToInt[i] = 1;\n }\n }\n if(z == 0)\n {\n binToInt[i] = 0;\n }\n }\n if(z > 1)\n {\n System.out.println(\"*Error only input 1's and 0's* Restart Program.\");\n }\n }\n } \n }catch (IOException ioe)\n {\n System.exit(-1);\n }\n }", "private int calculateBinSize(int r15) throws java.io.IOException {\n /*\n r14 = this;\n r1 = 0\n java.io.InputStream r2 = r14.in\n int r12 = r2.available()\n r2.mark(r12)\n r4 = 0\n int r0 = r2.read() // Catch:{ all -> 0x0052 }\n L_0x000f:\n r14.checkComma(r0) // Catch:{ all -> 0x0052 }\n int r5 = r14.readByte(r2) // Catch:{ all -> 0x0052 }\n int r8 = r14.readAddress(r2) // Catch:{ all -> 0x0052 }\n int r9 = r14.readByte(r2) // Catch:{ all -> 0x0052 }\n switch(r9) {\n case 0: goto L_0x0072;\n case 1: goto L_0x0036;\n case 2: goto L_0x0057;\n case 3: goto L_0x0021;\n case 4: goto L_0x003a;\n default: goto L_0x0021;\n } // Catch:{ all -> 0x0052 }\n L_0x0021:\n int r12 = r5 * 2\n int r12 = r12 + 2\n long r10 = (long) r12 // Catch:{ all -> 0x0052 }\n r14.skip(r2, r10) // Catch:{ all -> 0x0052 }\n L_0x0029:\n int r0 = r2.read() // Catch:{ all -> 0x0052 }\n r12 = 10\n if (r0 == r12) goto L_0x0029\n r12 = 13\n if (r0 == r12) goto L_0x0029\n goto L_0x000f\n L_0x0036:\n r2.reset()\n L_0x0039:\n return r1\n L_0x003a:\n int r7 = r14.readAddress(r2) // Catch:{ all -> 0x0052 }\n if (r1 <= 0) goto L_0x004a\n int r12 = r4 >> 16\n int r12 = r12 + 1\n if (r7 == r12) goto L_0x004a\n r2.reset()\n goto L_0x0039\n L_0x004a:\n int r4 = r7 << 16\n r12 = 2\n r14.skip(r2, r12) // Catch:{ all -> 0x0052 }\n goto L_0x0029\n L_0x0052:\n r12 = move-exception\n r2.reset()\n throw r12\n L_0x0057:\n int r12 = r14.readAddress(r2) // Catch:{ all -> 0x0052 }\n int r6 = r12 << 4\n if (r1 <= 0) goto L_0x006b\n int r12 = r6 >> 16\n int r13 = r4 >> 16\n int r13 = r13 + 1\n if (r12 == r13) goto L_0x006b\n r2.reset()\n goto L_0x0039\n L_0x006b:\n r4 = r6\n r12 = 2\n r14.skip(r2, r12) // Catch:{ all -> 0x0052 }\n goto L_0x0029\n L_0x0072:\n int r3 = r4 + r8\n if (r3 < r15) goto L_0x0021\n int r1 = r1 + r5\n goto L_0x0021\n */\n throw new UnsupportedOperationException(\"Method not decompiled: no.nordicsemi.android.dfu.internal.HexInputStream.calculateBinSize(int):int\");\n }", "@Override\n\tpublic String setBinContents(ByteBuffer fileBytes, byte[] container) {\n\t\tfileBytes.get(container);\n\t\treturn Arrays.toString(container);\n\t}", "private static byte[] m2539e(Context context) {\n Throwable th;\n int i = 0;\n ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();\n byte[] bArr = new byte[0];\n String a = Log.m2547a(context, Log.f1857e);\n DiskLruCache diskLruCache = null;\n try {\n diskLruCache = DiskLruCache.m2767a(new File(a), 1, 1, 10240);\n File file = new File(a);\n if (file != null && file.exists()) {\n String[] list = file.list();\n int length = list.length;\n while (i < length) {\n String str = list[i];\n if (str.contains(\".0\")) {\n byteArrayOutputStream.write(StatisticsManager.m2535a(diskLruCache, str.split(\"\\\\.\")[0]));\n }\n i++;\n }\n }\n bArr = byteArrayOutputStream.toByteArray();\n if (byteArrayOutputStream != null) {\n try {\n byteArrayOutputStream.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n if (diskLruCache != null) {\n try {\n diskLruCache.close();\n } catch (Throwable th2) {\n th = th2;\n }\n }\n } catch (IOException th3) {\n BasicLogHandler.m2542a(th3, \"StatisticsManager\", \"getContent\");\n if (byteArrayOutputStream != null) {\n try {\n byteArrayOutputStream.close();\n } catch (IOException e2) {\n e2.printStackTrace();\n }\n }\n if (diskLruCache != null) {\n diskLruCache.close();\n }\n } catch (Throwable th4) {\n th3 = th4;\n }\n return bArr;\n th3.printStackTrace();\n return bArr;\n }", "private boolean readBin(String filePath) throws FileNotFoundException, IOException {\n try {\n BufferedReader dataIn = new BufferedReader(new FileReader(filePath + \".bin\"));\n\n String next = dataIn.readLine();\n int length = Integer.parseInt(next);\n next = dataIn.readLine();\n start = Integer.parseInt(next);\n for (int i = 0; i < memory.length; i++) {\n next = dataIn.readLine();\n if (next == null) {\n break;\n }\n memory[i] = Integer.parseInt(next);\n }\n dataIn.close();\n } catch (IOException ex) {\n print(\"File error: \" + ex.toString());\n return true;\n }\n return false;\n\n }", "private int readFdocaOneByte() {\n checkForSplitRowAndComplete(1);\n //return dataBuffer_[position_++] & 0xff;\n return dataBuffer_.readUnsignedByte();\n }", "public static void main(String args[]) throws IOException {\n\t\t\n\t\tString v=\"1001100000010001\";\n\t\t\t\n\t\tString value=Base64.encodeBase64String(v.getBytes());\n\t\tSystem.out.println(\"hiiiiii===\"+value);\n\t\t\n\t\tString v1=v.substring(0,3);\n\t\tSystem.out.println(\"hiiiiii\"+value);\n\n //System.out.println(\"hiiiiii\"+da);\n //encoding byte array into base 64\n //byte[] encoded = Base64.encodeBase64(orig.getBytes()); \n //byte[] data = SerializationUtils.serialize(yourObject);\n //System.out.println(\"Original String: \" + orig );\n // System.out.println(\"Base64 Encoded String : \" + new String(encoded));\n \n //decoding byte array into base64\n //byte[] decoded = Base64.decodeBase64(encoded);\n\t\ttry{\n byte[] decoded=Base64.decodeBase64(\"AAUMBAAAAP8AAAEAAAABAQAAAQIAAAEDAAABBAAAAQUAAAEGAAABBwAAAQgAAAEJAAABCg==\");\n //System.out.println(\"decoded val : \" +decoded[0]);\n \n //System.out.println(\"Base 64 Decoded String : \" + new String(decoded));\n for(Byte b: decoded){\n \tSystem.out.println(\"decoded val : \" + b);\n }\n // byte[] bb=new byte[decoded.length];\n \tif(decoded!=null && decoded.length>0){\n \t\t//System.out.println(\"decoded val 2: \" +String.valueOf(decoded[3]));\n \t\t//System.arraycopy(decoded, 10, bb, 4 , 4);\n \t\t//System.out.println(\"decoded val 2: \" +String.valueOf(decoded[3]));\n \t\t\n \t\t//String hex = \"ff\"\n \t\t//int value = Integer.parseInt(hex, 16);\n \t\t\n \t\t//String hex = hexToString(decoded[10]);\n \t\t //BigInteger bi = new BigInteger(hex, 16);\n \t\t//bi.intValue();\n \t\t//(String.format(\"%.7f\", f));\n \t\t\n \t\t//String hex = Integer.toHexString(decoded[10]);\n \t\t// Integer.parseInt(hex);\n \t\t\n \t\t//System.out.println(\"Lora \" +hex);\n \t\tint n=0;\n \t\ttry{\n \t\t\t//n=Byte.valueOf(hex);\n \t\t\t//System.out.println(\"Loraa \" +n);\n \t\t}catch(Exception e){\n \t\t\te.printStackTrace();\n \t\t}\n \t\tSystem.out.println(\"Lora1 \" +n);\n \t\t\n \t\tSystem.out.println(\"decoded 10 \" +decoded[10]);\n \t\tSystem.out.println(\"decoded 11 \" +decoded[11]);\n \t\tSystem.out.println(\"decoded 12 \" +decoded[12]);\t\n \t\tSystem.out.println(\"decoded 13 \" +decoded[13]);\n \t\t\n \t\t/*ByteBuffer bb = ByteBuffer.wrap(d);\n bb.order(ByteOrder.LITTLE_ENDIAN);\n System.out.println( bb.getInt());*/\n \t\t\n\t\t //int b=(int) Integer.toUnsignedLong((int)decoded[10]);\n\t\t// String b=String.format(\"%x\", decoded[10]);\n\t\t //int p1=Integer.valueOf(b);\n\t\t //System.out.println(\"Pppppp \" +b);\n\t\t// n=Integer.parseInt(hex);\n\t\t//long h=(long) (decoded[10] & 0x00000000ffffffffL);\n\t\t// System.out.println(\"nnnn \" +Integer.toHexString(decoded[10]));\n\t\t// System.out.println(b);\n\t\t int w=112;\n\t\t// Integer.toBinaryString(w)\n\t\t System.out.println(\"dfdfdfdf\"+Integer.toBinaryString(w));\n\t\t \n\t\t String p=Integer.toBinaryString(w);\n\t\t System.out.println(\"hiiddddd\"+p);\n\t\t int p1=decoded[10] & 0xFF;\n \t\t//int c=decoded[11];\n\t\t int c=0x5f;\n \t\tSystem.out.println(\"p1\"+p1);\n \t\tSystem.out.println(c);\n \t\tint d=decoded[12];\n \t\tSystem.out.println(d);\n \t\tint e=decoded[13] & 0xFF ;\n \t\t int a= (p1 | (c << 8) | (d << 16) | (e << 24));\n \t\t\n \t\t\n \t\tSystem.out.println(a);\n \t\t\n \t}\n \t\n \t//System.out.println(\"bb : \" + bb[4]);\n \n //char character = '2'; \n // int ascii = (int) character;\n // String a= new String(decoded);\n //.out.println(String.format(\"0x%08X\", a));\n //String str=String.format(\"0x%08X\", a);\n //String str = String.format(\"0x\", args)\n //System.out.println(\"String : \" + str);\n /* \n \tSystem.out.println(\"Base 64 Decoded String : \" + Integer.toHexString(50));*/\n }catch(Exception e){\n \te.printStackTrace();\n }\n }", "private void outHex(){\n\t\tSystem.out.println(binary);\n\t\tpw.println(binary);\n\t\t\n\t}", "public static void main(String[] args) {\n\t\tSystem.out.println(\"out :\" + addBinary(\"1101\", \"111\"));\n\t}", "public String memoryDisplayBin()\n {\n int pos = startingPos;\n String ret = \"\";\n while(pos <= endingPos)\n {\n String instruction = mem.getFourBytes(pos);\n String bin = BinaryFormater.format(Integer.toBinaryString(Integer.parseInt(instruction, 16)),32);\n ret += \"0x\"+Integer.toHexString(pos) + \": \" + bin.substring(0,16) + \" \" + bin.substring(16,32)+\"\\n\";\n pos += 4;\n }\n return ret;\n }", "public static void main(String[]args){\n \r\n print_binary(15);//Print the integer in binary form using interations\r\n }", "private byte[] decode(ByteBuffer bytes) {\n \treturn bytes.array();\r\n }", "public static void main(String[] args) {\n byte b1=125;\n System.out.println(b1);\n byte b2=(byte)129;\n System.out.println(b2);\t\t\n\t}", "private boolean isBinaryMessage(Object anObject) {\n\t\tif(anObject.getClass() == this.getClass()) {\n\t\t\treturn true;\n\t\t}\n\t\telse {\n\t\t\treturn false;\n\t\t}\n\t}", "public abstract byte[] parse(String input);", "byte[] token();", "@Test\n public void decodeStringDelta()\n {\n {\n final BinaryEncoder encoder = new BinaryEncoder(0, 16, 1.0);\n assertEquals(3.0, encoder.decode(\"0011\"), 0.0);\n }\n\n {\n final BinaryEncoder encoder = new BinaryEncoder(0, 16, 2.0);\n assertEquals(0.0, encoder.decode(\"0001\"), 2.0);\n }\n\n {\n final BinaryEncoder encoder = new BinaryEncoder(0, 16, 0.5);\n assertEquals(3.0, encoder.decode(\"00110\"), 0.0);\n }\n }", "public static void main(String[] args) {\n\t\tBinaryNumber a = new BinaryNumber(\"11\");\n \tSystem.out.println(a.toDecimal()); \n \tSystem.out.println(a.getLength());\n \tSystem.out.println(a.toString());\n \tSystem.out.println(a.shiftR(3));\n\t\t\t\t\n\t\t}", "public abstract byte[] getEncoded();", "public static void main(String[] args) {\n\t\t short s = 1;\n\t\t byte c = 1;\n\t\t int i = 1;\n\t\t printIntBinary(i);\n\t\t \n\t}", "public AnnisBinary getBinary(Long id)\r\n \t{\r\n \t\tlogger.debug(\"Looking for binary file with id = \" + id);\r\n \t\t\r\n \t\ttry\r\n \t\t{\r\n \t\t\tExtFileObjectCom extFile= this.getExtFileObj(id);\r\n \t\t\tAnnisBinary aBin= new AnnisBinaryImpl(); \r\n \t\t\t\r\n \t\t\t//Bytes setzen\r\n \t\t\tFile file = extFile.getFile();\r\n \t\t\tlong length = file.length();\r\n \t\t\tFileInputStream fis = new FileInputStream(file);\r\n \t\t\tbyte[] bytes = new byte[(int)length];\r\n \t\t int offset = 0;\r\n \t\t int numRead = 0;\r\n \t\t while (offset < bytes.length\r\n \t\t && (numRead=fis.read(bytes, offset, bytes.length-offset)) >= 0) \r\n \t\t {\r\n \t\t \toffset += numRead;\r\n \t\t }\r\n \t\r\n \t\t \r\n \t\t // Ensure all the bytes have been read in\r\n \t\t if (offset < bytes.length) {\r\n \t\t \tthrow new IOException(\"Could not completely read file \"+file.getName());\r\n \t\t }\r\n \t\t\tfis.close();\r\n \t\t\taBin.setBytes(bytes);\r\n \t\t\taBin.setId(extFile.getID());\r\n \t\t\taBin.setFileName(extFile.getFileName());\r\n \t\t\taBin.setMimeType(extFile.getMime());\r\n \t\t\t\r\n \t\t\treturn(aBin);\r\n \t\t}\r\n \t\tcatch (Exception e)\r\n \t\t{\r\n \t\t\tlogger.error(\"Could not read binary file\", e);\r\n \t\t\tthrow new ExternalFileMgrException(e);\r\n \t\t}\r\n \t}", "private static byte[] hexStr2Bytes(String hex) {\n // Adding one byte to get the right conversion\n // values starting with \"0\" can be converted\n byte[] bArray = new BigInteger(\"10\" + hex, 16).toByteArray();\n\n // Copy all the REAL bytes, not the \"first\"\n byte[] ret = new byte[bArray.length - 1];\n for (int i = 0; i < ret.length; i++)\n ret[i] = bArray[i + 1];\n return ret;\n }", "public static void main(String[] args) {\n int x = 7;\n System.out.println(new BinaryNumberOfOnes().convert(x));\n }", "public boolean isBinaryEncoding()\r\n\t{\r\n\t\treturn binary != null;\r\n\t}", "public static byte [] toBytesBinary(String in) {\n byte [] b = new byte[in.length()];\n int size = 0;\n for (int i = 0; i < in.length(); ++i) {\n char ch = in.charAt(i);\n if (ch == '\\\\' && in.length() > i+1 && in.charAt(i+1) == 'x') {\n // ok, take next 2 hex digits.\n char hd1 = in.charAt(i+2);\n char hd2 = in.charAt(i+3);\n\n // they need to be A-F0-9:\n if (!isHexDigit(hd1) ||\n !isHexDigit(hd2)) {\n // bogus escape code, ignore:\n continue;\n }\n // turn hex ASCII digit -> number\n byte d = (byte) ((toBinaryFromHex((byte)hd1) << 4) + toBinaryFromHex((byte)hd2));\n\n b[size++] = d;\n i += 3; // skip 3\n } else {\n b[size++] = (byte) ch;\n }\n }\n // resize:\n byte [] b2 = new byte[size];\n System.arraycopy(b, 0, b2, 0, size);\n return b2;\n }", "public static void main(String[] args) {\n Huffman huffman=new Huffman(\"Shevchenko Vladimir Vladimirovich\");\n System.out.println(huffman.getCodeText());//\n //answer:110100001001101011000001001110111110110101100110110001001110101111100011101000011011000100111010111110001110100101110101111100000\n\n huffman.getSizeBits();//размер в битах\n ;//кол-во символов\n System.out.println((double) huffman.getSizeBits()/(huffman.getValueOfCharactersOfText()*8)); //коэффициент сжатия относительно aski кодов\n System.out.println((double) huffman.getSizeBits()/(huffman.getValueOfCharactersOfText()*\n (Math.pow(huffman.getValueOfCharactersOfText(),0.5)))); //коэффициент сжатия относительно равномерного кода. Не учитывается размер таблицы\n System.out.println(huffman.getMediumLenght());//средняя длина кодового слова\n System.out.println(huffman.getDisper());//дисперсия\n\n\n }", "public static void main(String[] args) {\n\t\tSystem.out.println(\"2:\"+Integer.toBinaryString(2));\n\t\tSystem.out.println(\"3:\"+Integer.toBinaryString(3));\n\t\t\n\t\tSystem.out.println(\"2&3: \"+(2 &3));\n\t\tSystem.out.println(\"2|3: \"+(2 |3));\n\t\tSystem.out.println(\"2^3: \"+(2^3));\n\t\tSystem.out.println(\"~3: \"+(+~3));\n\t\t\n\t\tSystem.out.println(\"~3 to binary:\"+Integer.toBinaryString(~3));\n\t\t\n\t\tSystem.out.println(Integer.toBinaryString(~3).length());\n\t\tSystem.out.println(Integer.MAX_VALUE);\n\t\t\t}", "private static boolean isBinaryType(int jdbcType) {\r\n switch (jdbcType) {\r\n case Types.BINARY:\r\n case Types.VARBINARY:\r\n case Types.LONGVARBINARY:\r\n return true;\r\n default:\r\n return false;\r\n }\r\n }", "@Override\n public void calculateChecksum(byte[] sysex, int start, int end, int offset) {\n }", "@Test\n public void binDescriptionTest() {\n assertEquals(\"bin_desc\", authResponse.getBinDescription());\n }", "public boolean isBase64Binary() {\n return false;\n }", "public abstract String b(byte[] bArr, int i, int i2);", "byte[] getBinaryVDBResource(String resourcePath) throws Exception;", "private static byte[] fromHex(String hex)\n\t {\n\t byte[] binary = new byte[hex.length() / 2];\n\t for(int i = 0; i < binary.length; i++)\n\t {\n\t binary[i] = (byte)Integer.parseInt(hex.substring(2*i, 2*i+2), 16);\n\t }\n\t return binary;\n\t }" ]
[ "0.6279643", "0.6234065", "0.60475445", "0.59203017", "0.5908096", "0.5869546", "0.5848938", "0.5847707", "0.5824533", "0.57888985", "0.57614243", "0.5664256", "0.56623274", "0.5623767", "0.56116456", "0.5599982", "0.55809176", "0.5557122", "0.5544718", "0.5542046", "0.5513071", "0.5476924", "0.54748243", "0.54641545", "0.5459156", "0.5457278", "0.5450331", "0.54498845", "0.54324", "0.5421646", "0.5388489", "0.5379044", "0.53761977", "0.5375218", "0.5374902", "0.53625214", "0.53498805", "0.5337495", "0.5329552", "0.53176874", "0.53166986", "0.53131294", "0.53061384", "0.53052807", "0.5278025", "0.5276218", "0.5271525", "0.52509075", "0.52474684", "0.5236703", "0.5235797", "0.5235797", "0.52348924", "0.52277035", "0.5223493", "0.5217167", "0.52156305", "0.5197635", "0.5195234", "0.51935124", "0.519111", "0.51851034", "0.518337", "0.518291", "0.5182011", "0.5174968", "0.5169932", "0.516587", "0.5162912", "0.51599735", "0.515954", "0.51522714", "0.5151963", "0.51478004", "0.51327676", "0.5130541", "0.51302546", "0.5125161", "0.5109379", "0.5097051", "0.5095916", "0.5090461", "0.50882465", "0.5084342", "0.50794965", "0.50741816", "0.5071401", "0.5066371", "0.506289", "0.5059537", "0.50577825", "0.50550586", "0.5054666", "0.50500196", "0.5048737", "0.50472236", "0.50464654", "0.50444996", "0.50348824", "0.5032535", "0.503144" ]
0.0
-1
TODO: fix for binary
@Test public void testTimeStampRoundingWithType() throws SQLException { assumeBinaryModeRegular(); LocalTime time = LocalTime.parse("23:59:59.999999500"); Time actual = insertThenReadWithType(time, Types.TIME, "time_without_time_zone_column", Time.class, false/*no roundtrip*/); assertEquals(Time.valueOf("24:00:00"), actual); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Override\n\tpublic void interpretBytes() {\n\t\t\n\t}", "boolean supportsBinaryInProc();", "private String toBinary( byte[] bytes )\n\t{\n \t\tStringBuilder sb = new StringBuilder(bytes.length * Byte.SIZE);\n\t\tfor( int i = 0; i < Byte.SIZE * bytes.length; i++ )\n\t\t\tsb.append((bytes[i / Byte.SIZE] << i % Byte.SIZE & 0x80) == 0 ? '0' : '1');\n\t\treturn sb.toString();\n\t}", "public void setBinmode() {\n }", "public boolean isBinary()\n {\n return false;\n }", "FedoraBinary asBinary(Node node);", "public boolean canHandleBinaryNatively()\n/* */ {\n/* 391 */ return false;\n/* */ }", "boolean isBinary();", "void mo30633b(int i, String str, byte[] bArr);", "public abstract byte[] mo32305a(String str);", "static StringBuilder convert_to_binary(String msg) {\n byte[] bytes = msg.getBytes();\r\n StringBuilder binary = new StringBuilder();\r\n for (byte b : bytes) {\r\n int val = b;\r\n for (int i = 0; i < 8; i++) {\r\n binary.append((val & 128) == 0 ? 0 : 1);\r\n val <<= 1;\r\n }\r\n binary.append(\"\");\r\n }\r\n return binary;\r\n }", "@Test\n\tpublic void testBytesToHexStringForSrcMode() throws Exception {\n//TODO: Test goes here... \n\t}", "private ByteTools(){}", "default String getFileExtension() {\n return \"bin\";\n }", "public /*byte[]*/String BinaryCaster(Object item){\n String Sitem = Integer.toBinaryString((int)item);\n //byte[] b = new byte[Sitem.length()];\n //for(int i=0;i<Sitem.length();i++){\n // b[i] = (byte)Sitem.charAt(i);\n //}\n //return b;\n return Sitem;\n }", "SQLBinary()\n\t{\n\t}", "boolean isBinary(String str)\n\t{\n\t if(str.length() < 1) return false;\n\t \n\t for(int i=0; i<str.length(); i++){\n\t char t = str.charAt(i);\n\t if(t=='1' || t=='0') continue;\n\t else return false;\n\t }\n\t \n\t return true;\n\t}", "public static void main(String[] args) {\n\n byte b1 = 0b1010; //door 0b eerst te noteren maken we er een 'binary literal' van\n byte b2 = 0b0100;\n byte b3 = (byte) (b1 + b2); //het resultaat is zonder een typecasting een int (door het plusje)\n //dus we typecasten het eerst naar een byte\n\n //bij het printen converteren we b3 naar een binary literal in String vorm om de daadwerkelijke binaire som te krijgen\n System.out.println(\"b3: \" + Integer.toBinaryString(b3));\n }", "void mo8445a(int i, String str, int i2, byte[] bArr);", "byte[] mo38566a();", "public static void main(String[] args) {\n\t\tint a = 103217;\n\t\tSystem.out.println(AssortedMethods.toFullBinaryString(a));\n\t\tint b = 13;\n\t\tSystem.out.println(AssortedMethods.toFullBinaryString(b));\t\t\n\t\tint c = updateBits(a, b, 4, 12);\n\t\tSystem.out.println(AssortedMethods.toFullBinaryString(c));\n\t\t\t\n\t}", "@Override\n public Binary getBinary() throws ValueFormatException, RepositoryException {\n return null;\n }", "private static int batoi(byte[] inp) {\n int len = inp.length>4?4:inp.length;\n int total = 0;\n for (int i = 0; i < len; i++) {\n total += (inp[i]<0?256+inp[i]:(int)inp[i]) << (((len - 1) - i) * 8);\n }\n return total;\n }", "public String convertToAssemblyBin(String bin)\n {\n if(bin.equals(\"01101001010000000000000100000000\"))\n {\n return \"MOVEZ X0 data\";\n } else if(bin.equals(\"01111100001000000000000000000001\"))\n {\n return \"LDUR X1, X0, #0\";\n } else if(bin.equals(\"01011010000000000000001000000010\"))\n {\n return \"CBZ X2, #32\";\n } else if(bin.equals(\"00000000101000000000000000001100\"))\n {\n return \"B #12\";\n } else if(bin.equals(\"00000100100010000001010000100010\"))\n {\n return \"ADDI X2, X2, #20\";\n }else if(bin.equals(\"00000110010110000001000000100010\"))\n {\n return \"SUB X2, X1, X2\";\n }else if(bin.equals(\"00000010001000100000000000000010\"))\n {\n return \"PUSH X2\";\n }else if(bin.equals(\"00000000000000000000000000000000\"))\n {\n return \"NOP\";\n }else if(bin.equals(\"00000011001100110000000000000011\"))\n {\n return \"POP X3\";\n }else if(bin.equals(\"01111100000000000000000000000011\"))\n {\n return \"STUR X3, X0, #0\";\n }else if(bin.equals(\"00000110010100000010000000110011\"))\n {\n return \"EOR X3, X2, X3\";\n }else if(bin.equals(\"01011010000000000000000001000011\"))\n {\n return \"CBZ X3, #4\";\n }else if(bin.equals(\"00010001000100010001000100010001\"))\n {\n return \"HALT\";\n } else if(bin.equals(\"00000000101010111010101100000000\") || bin.equals(\"00000000000000001010101100000000\"))\n {\n return \"DATA VALUE: \" + Integer.parseInt(\"ab\", 16);\n } else if(bin.equals(\"00000000000000000000110111101111\"))\n {\n return \"STACK VALUE: \" + Integer.parseInt(\"def\", 16);\n }\n return \"\";\n }", "public java.lang.String getBin() {\r\n return bin;\r\n }", "@Test\n public void test2(){\n\n String s =\"1000000000000001\";\n //s = BinaryCalculate.BinaryArithmeticalRightShift(s,1);\n s = BinaryCalculate.BinaryLogicRightShift(s,1);\n int a = BitConversion.fromBinaryStringToInt(s);\n System.out.println(a);\n }", "public abstract String toString(String bin);", "private String removeBinFirstAndLast(String runtimeBin) {\n if (StringUtils.isBlank(runtimeBin)) {\n return null;\n }\n if (runtimeBin.startsWith(\"0x\")) {\n runtimeBin = StringUtils.removeStart(runtimeBin, \"0x\");\n }\n if (runtimeBin.length() > 68) {\n runtimeBin = runtimeBin.substring(0, runtimeBin.length() - 68);\n }\n return runtimeBin;\n }", "static int beautifulBinaryString(String b) {\n int index = b.indexOf(\"010\", 0) ;\n int change = 0;\n while (index != -1) {\n change++;\n index = b.indexOf(\"010\", index + 3) ;\n }\n return change;\n }", "private byte[] fromHex(String hex)\n {\n byte[] binary = new byte[hex.length() / 2];\n for(int i = 0; i < binary.length; i++)\n {\n binary[i] = (byte)Integer.parseInt(hex.substring(2*i, 2*i+2), 16);\n }\n return binary;\n }", "byte mo30283c();", "public Binary() { \n\t_decNum = 0;\n\t_binNum = \"0\";\n }", "ByteOrder byteOrder();", "private String toBinary(byte caracter){\n byte byteDeCaracter = (byte)caracter;\n String binario=\"\";\n for( int i = 7; i>=0; i--){\n binario += ( ( ( byteDeCaracter & ( 1<<i ) ) > 0 ) ? \"1\" : \"0\" ) ;\n }\n return binario;\n }", "private static void spacesToBinary() {\n\t\tString stringBinary = \"\"; \n\t\tfor(int i = 0; i < spaces.length; i++) {\n\t\t\tif(spaces[i].length() % 2 == 0) { stringBinary += \"1\"; }\n\t\t\telse if(spaces[i].length() % 2 == 1) { stringBinary += \"0\"; }\n\n\t\t\tif(i != 0 && (i+1) % 5 == 0) {\n\t\t\t\tbinary.add(stringBinary);\n\t\t\t\tstringBinary = \"\";\n\t\t\t} \n\t\t\telse if(i+1 == spaces.length) {\n\t\t\t\tfor(int k = (i+1)%5; k < 5; k++) {\n\t\t\t\t\tstringBinary += \"0\";\n\t\t\t\t}\n\t\t\t\tbinary.add(stringBinary);\n\t\t\t\tstringBinary = \"\";\n\t\t\t}\n\t\t}\n\t}", "@Test\n public void testToBinary() {\n Object[][] datas = new Object[][]{\n {0, \"0\"},\n {5, \"101\"},\n {10, \"1010\"},\n {11, \"1011\"}\n };\n for (Object[] data : datas) {\n String result = Tools.toBinary((int) data[0]); //Actual\n String expResult = (String) data[1]; //Expected\n assertEquals(result, expResult);\n System.out.println(\"testToBinary()\");\n }\n }", "public boolean isHexBinary() {\n return false;\n }", "boolean hasBinaryData();", "@Override\n\tpublic String convert2Binary(int num) {\n\t\treturn null;\n\t}", "public static void main(String[] args) {\n\t\tint x = ~0;\r\n\t\tSystem.out.println(Integer.toBinaryString(x));\r\n\t\tint y = x>>>8;\r\n\t\tSystem.out.println(Integer.toBinaryString(y));\r\n\t\tSystem.out.println(x+\" \"+y);\r\n\t\t\r\n\t\tint N = 1<<31;\r\n\t\tint M = 0b11;\r\n\t\tint j=2;\r\n\t\tint i=1;\r\n\t\tSystem.out.println(Integer.toBinaryString(N));\r\n\t\tSystem.out.println(Integer.toBinaryString(M));\r\n\t\tSystem.out.println(Integer.toBinaryString(insertMIntoNFromJtoI(M, N, j, i)));\r\n\t\t\r\n\t}", "public String getBinaryMnemonic(){\n\t\tswitch(this) {\n\t\tcase STOP -> \t{return \t\"00000000\";}\n\t\tcase RETTR -> \t{return \t\"00000001\";}\n\t\tcase MOVSPA -> \t{return \t\"00000010\";}\n\t\tcase MOVFLGA -> {return \t\"00000011\";}\n\t\t\n\t\tcase BR -> \t\t{return \t\"0000010\";}\n\t\tcase BRLE -> \t{return \t\"0000011\";}\n\t\tcase BRLT -> \t{return \t\"0000100\";}\n\t\tcase BREQ -> \t{return \t\"0000101\";}\n\t\tcase BRNE -> \t{return \t\"0000110\";}\n\t\tcase BRGE -> \t{return \t\"0000111\";}\n\t\tcase BRGT -> \t{return \t\"0001000\";}\n\t\tcase BRV -> \t{return \t\"0001001\";}\n\t\tcase BRC -> \t{return \t\"0001010\";}\n\t\tcase CALL -> \t{return \t\"0001011\";}\n\t\t\n\t\tcase NOTA -> \t{return \t\"00011000\";}\n\t\tcase NOTX -> \t{return \t\"00011001\";}\n\t\tcase NEGA -> \t{return \t\"00011010\";}\n\t\tcase NEGX -> \t{return \t\"00011011\";}\n\t\tcase ASLA -> \t{return \t\"00011100\";}\n\t\tcase ASLX -> \t{return \t\"00011101\";}\n\t\tcase ASRA -> \t{return \t\"00011110\";}\n\t\tcase ASRX -> \t{return \t\"00011111\";}\n\t\tcase ROLA -> \t{return \t\"00100000\";}\n\t\tcase ROLX -> \t{return \t\"00100001\";}\n\t\tcase RORA -> \t{return \t\"00100010\";}\n\t\tcase RORX -> \t{return \t\"00100011\";}\n\t\t\n\t\tcase NOP -> \t{return \t\"00101\";}\n\t\tcase DECI -> \t{return \t\"00110\";}\n\t\tcase DECO -> \t{return \t\"00111\";}\n\t\tcase STRO -> \t{return \t\"01000\";}\n\t\tcase CHARI -> \t{return \t\"01001\";}\n\t\tcase CHARO -> \t{return \t\"01010\";}\n\t\t\n//\t\tcase RETn\n\t\t\n\t\tcase ADDSP -> \t{return \t\"01100\";}\n\t\tcase SUBSP -> \t{return \t\"01101\";}\n\t\t\n\t\tcase ADDA -> \t{return \t\"0111\";}\n\t\tcase SUBA -> \t{return \t\"1000\";}\n\t\tcase ANDA -> \t{return \t\"1001\";}\n\t\tcase ORA -> \t{return \t\"1010\";}\n\t\tcase CPA -> \t{return \t\"1011\";}\n\t\tcase LDA -> \t{return \t\"1100\";}\n\t\tcase LDBYTEA -> {return \t\"1101\";}\n\t\tcase STA -> \t{return \t\"1110\";}\n\t\tcase STBYTEA -> {return \t\"1111\";}\n\t\t\n\t\tcase i -> \t{return \t\"000\";}\n\t\tcase d -> \t{return \t\"001\";}\n\t\tcase n -> \t{return \t\"010\";}\n\t\tcase s -> \t{return \t\"011\";}\n\t\tcase sf -> \t{return \t\"100\";}\n\t\tcase x -> \t{return \t\"101\";}\n\t\tcase sx -> \t{return \t\"110\";}\n\t\tcase sfx -> {return \t\"111\";}\n\t\t\n\t\tcase A -> {return \"0\";}\n\t\tcase X -> {return \"1\";}\n\t\t\n\t\tcase ADDRSS -> \t{return \"\";}\n\t\tcase ASCII -> \t{return \"\";}\n\t\tcase BLOCK -> \t{return \"\";}\n\t\tcase BURN -> \t{return \"\";}\n\t\tcase BYTE -> \t{return \"\";}\n\t\tcase END -> \t{return \"\";}\n\t\tcase EQUATE -> {return \"\";}\n\t\tcase WORD -> \t{return \"\";}\n\t\t\n\t\tdefault -> throw new IllegalArgumentException(\"This is an illegal mnemonic. \\nPlease double check your code.\");\n\t\t\n\t\t}\n\t\t\n\t}", "private static String validateBinaryStr(String binStr) throws UnsignedBigIntUtilsException {\n String tmpStr = RegExp.replaceAll(\"[ \\\\|\\\\t\\\\n]+\", binStr, \"\");\n tmpStr = RegExp.replaceFirst(\"0b\", tmpStr, \"\");\n if (tmpStr.matches(\"[0-1]+\") == false) {\n String msg = \"ERROR: Invalid BINARY characters in input => \" + tmpStr + \"\\n\";\n throw new UnsignedBigIntUtilsException(msg);\n }\n return (tmpStr);\n }", "public void setBin(java.lang.String bin) {\r\n this.bin = bin;\r\n }", "void mo1751a(byte[] bArr);", "void mo12206a(byte[] bArr);", "public boolean isBinary() {\n return this.isHexBinary() || this.isBase64Binary();\n }", "private void computeEncoding()\n{\n source_encoding = IvyFile.digestString(current_node.getKeyText());\n}", "byte[] mo12209b(int i);", "private void outDec(){\n\t\tSystem.out.println(binary);\n\t\tpw.println(binary);\n\t\t\n\t}", "public ByteArray getBin() {\n return bin;\n }", "byte[] getBytes();", "byte[] getBytes();", "private static java.io.File c(java.lang.String r8, java.lang.String r9) {\n /*\n r0 = 0;\n r1 = 0;\n r2 = new java.io.File;\t Catch:{ Exception -> 0x00e8, all -> 0x00e4 }\n r2.<init>(r8);\t Catch:{ Exception -> 0x00e8, all -> 0x00e4 }\n r8 = r2.exists();\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n if (r8 != 0) goto L_0x001d;\n L_0x000d:\n r8 = \"DecryptUtils\";\n r9 = \"unZipSingleFile file don't exist\";\n r3 = new java.lang.Object[r0];\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n com.taobao.sophix.e.d.e(r8, r9, r3);\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n com.taobao.sophix.e.b.a(r1);\n r2.delete();\n return r1;\n L_0x001d:\n r8 = new java.lang.StringBuilder;\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r8.<init>();\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r8.append(r9);\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r9 = java.io.File.separator;\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r8.append(r9);\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r9 = \"unzip\";\n r8.append(r9);\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r8 = r8.toString();\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r9 = new java.io.File;\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r9.<init>(r8);\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n com.taobao.sophix.e.b.a(r9);\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r3 = r9.exists();\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n if (r3 != 0) goto L_0x0044;\n L_0x0041:\n r9.mkdirs();\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n L_0x0044:\n r9 = new java.util.zip.ZipInputStream;\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r3 = new java.io.FileInputStream;\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r3.<init>(r2);\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n r9.<init>(r3);\t Catch:{ Exception -> 0x00e1, all -> 0x00de }\n L_0x004e:\n r3 = r9.getNextEntry();\t Catch:{ Exception -> 0x00dc }\n if (r3 == 0) goto L_0x00f4;\n L_0x0054:\n r4 = r3.getName();\t Catch:{ Exception -> 0x00dc }\n r3 = r3.isDirectory();\t Catch:{ Exception -> 0x00dc }\n if (r3 == 0) goto L_0x0085;\n L_0x005e:\n r3 = r4.length();\t Catch:{ Exception -> 0x00dc }\n r3 = r3 + -1;\n r3 = r4.substring(r0, r3);\t Catch:{ Exception -> 0x00dc }\n r4 = new java.io.File;\t Catch:{ Exception -> 0x00dc }\n r5 = new java.lang.StringBuilder;\t Catch:{ Exception -> 0x00dc }\n r5.<init>();\t Catch:{ Exception -> 0x00dc }\n r5.append(r8);\t Catch:{ Exception -> 0x00dc }\n r6 = java.io.File.separator;\t Catch:{ Exception -> 0x00dc }\n r5.append(r6);\t Catch:{ Exception -> 0x00dc }\n r5.append(r3);\t Catch:{ Exception -> 0x00dc }\n r3 = r5.toString();\t Catch:{ Exception -> 0x00dc }\n r4.<init>(r3);\t Catch:{ Exception -> 0x00dc }\n r4.mkdirs();\t Catch:{ Exception -> 0x00dc }\n goto L_0x004e;\n L_0x0085:\n r3 = new java.io.File;\t Catch:{ Exception -> 0x00dc }\n r5 = new java.lang.StringBuilder;\t Catch:{ Exception -> 0x00dc }\n r5.<init>();\t Catch:{ Exception -> 0x00dc }\n r5.append(r8);\t Catch:{ Exception -> 0x00dc }\n r6 = java.io.File.separator;\t Catch:{ Exception -> 0x00dc }\n r5.append(r6);\t Catch:{ Exception -> 0x00dc }\n r5.append(r4);\t Catch:{ Exception -> 0x00dc }\n r4 = r5.toString();\t Catch:{ Exception -> 0x00dc }\n r3.<init>(r4);\t Catch:{ Exception -> 0x00dc }\n r3.createNewFile();\t Catch:{ Exception -> 0x00dc }\n r4 = new java.io.FileOutputStream;\t Catch:{ Exception -> 0x00c7, all -> 0x00c4 }\n r4.<init>(r3);\t Catch:{ Exception -> 0x00c7, all -> 0x00c4 }\n r5 = 1024; // 0x400 float:1.435E-42 double:5.06E-321;\n r5 = new byte[r5];\t Catch:{ Exception -> 0x00c2 }\n L_0x00aa:\n r6 = r9.read(r5);\t Catch:{ Exception -> 0x00c2 }\n r7 = -1;\n if (r6 == r7) goto L_0x00b8;\n L_0x00b1:\n r4.write(r5, r0, r6);\t Catch:{ Exception -> 0x00c2 }\n r4.flush();\t Catch:{ Exception -> 0x00c2 }\n goto L_0x00aa;\n L_0x00b8:\n com.taobao.sophix.e.b.a(r4);\t Catch:{ Exception -> 0x00dc }\n com.taobao.sophix.e.b.a(r9);\n r2.delete();\n return r3;\n L_0x00c2:\n r3 = move-exception;\n goto L_0x00c9;\n L_0x00c4:\n r8 = move-exception;\n r4 = r1;\n goto L_0x00d8;\n L_0x00c7:\n r3 = move-exception;\n r4 = r1;\n L_0x00c9:\n r5 = \"DecryptUtils\";\n r6 = \"unZipSingleFile unZip hotfix patch file error\";\n r7 = new java.lang.Object[r0];\t Catch:{ all -> 0x00d7 }\n com.taobao.sophix.e.d.a(r5, r6, r3, r7);\t Catch:{ all -> 0x00d7 }\n com.taobao.sophix.e.b.a(r4);\t Catch:{ Exception -> 0x00dc }\n goto L_0x004e;\n L_0x00d7:\n r8 = move-exception;\n L_0x00d8:\n com.taobao.sophix.e.b.a(r4);\t Catch:{ Exception -> 0x00dc }\n throw r8;\t Catch:{ Exception -> 0x00dc }\n L_0x00dc:\n r8 = move-exception;\n goto L_0x00eb;\n L_0x00de:\n r8 = move-exception;\n r9 = r1;\n goto L_0x00fc;\n L_0x00e1:\n r8 = move-exception;\n r9 = r1;\n goto L_0x00eb;\n L_0x00e4:\n r8 = move-exception;\n r9 = r1;\n r2 = r9;\n goto L_0x00fc;\n L_0x00e8:\n r8 = move-exception;\n r9 = r1;\n r2 = r9;\n L_0x00eb:\n r3 = \"DecryptUtils\";\n r4 = \"unZipSingleFile unZip hotfix patch file error\";\n r0 = new java.lang.Object[r0];\t Catch:{ all -> 0x00fb }\n com.taobao.sophix.e.d.a(r3, r4, r8, r0);\t Catch:{ all -> 0x00fb }\n L_0x00f4:\n com.taobao.sophix.e.b.a(r9);\n r2.delete();\n return r1;\n L_0x00fb:\n r8 = move-exception;\n L_0x00fc:\n com.taobao.sophix.e.b.a(r9);\n r2.delete();\n throw r8;\n */\n throw new UnsupportedOperationException(\"Method not decompiled: com.taobao.sophix.e.a.c(java.lang.String, java.lang.String):java.io.File\");\n }", "public abstract void mo9798a(byte b);", "byte[] getResult();", "public static String getBinaryFile(){\r\n return Input.getString(\"What is the name of the binary file? Please add .dat file extension: \");\r\n }", "public static void main(String[] args) {\n String a = \"101\", b = \"101\";\n System.out.print(addBinary(a, b));\n }", "void mo4520a(byte[] bArr);", "private void inputBin(){\n\t\tSystem.out.println(\"Enter a binary number (32 bit or less/multiple of 4):\");\n\t\tpw.println(\"Enter a binary number (32 bit or less/multiple of 4):\");\n\t\tScanner sc = new Scanner(System.in);\n\t\tbinary = sc.next();\n\t\tpw.println(binary);\n\t\t\n\t}", "@Test\n public void testByte() {\n assertEquals(\"127\", hiveTypeToJson(new MyHiveType(new ByteWritable(Byte.MAX_VALUE), byteTypeInfo)));\n }", "byte[] readBytes();", "public abstract void mo4360a(byte b);", "public abstract String mo11611b();", "private byte[] toByteArray(String s)\r\n\t\t{\n\t\t\tlong l = 0;\r\n\t\t\tif (s.startsWith(\"0x\") || s.startsWith(\"0X\")) {\r\n\t\t\t\tfinal byte[] d = new byte[(s.length() - 1) / 2];\r\n\t\t\t\tint k = (s.length() & 0x01) != 0 ? 3 : 4;\r\n\t\t\t\tfor (int i = 2; i < s.length(); i = k, k += 2)\r\n\t\t\t\t\td[(i - 1) / 2] = (byte) Short.parseShort(s.substring(i, k), 16);\r\n\t\t\t\treturn d;\r\n\t\t\t}\r\n\t\t\telse if (s.length() > 1 && s.startsWith(\"0\"))\r\n\t\t\t\tl = Long.parseLong(s, 8);\r\n\t\t\telse if (s.startsWith(\"b\"))\r\n\t\t\t\tl = Long.parseLong(s.substring(1), 2);\r\n\t\t\telse\r\n\t\t\t\tl = Long.parseLong(s);\r\n\t\t\tint i = 0;\r\n\t\t\tfor (long test = l; test != 0; test /= 0x100)\r\n\t\t\t\t++i;\r\n\t\t\tfinal byte[] d = new byte[i == 0 ? 1 : i];\r\n\t\t\tfor (; i-- > 0; l /= 0x100)\r\n\t\t\t\td[i] = (byte) (l & 0xff);\r\n\t\t\treturn d;\r\n\t\t}", "public void encodeBinary(Buf out)\n {\n out.u2(val.length()+1);\n for (int i=0; i<val.length(); ++i)\n out.u1(val.charAt(i));\n out.u1(0);\n }", "private void createBin(int size) \n\t{\n\t// create an array of the appropriate type\n\tfBin = (Object[]) Array.newInstance(fClass, size);\t\n\t}", "public static String TextToBinary(String input){\n\t\tString output = \"\";\n\t\tfor(int i = 0; i < input.length(); i++){\n\t\t\toutput += Integer.toBinaryString(0x100 | input.charAt(i)).substring(1);\n\t\t}\n\t\treturn output;\n\t}", "static void inputBin(int [] binToInt)\n {\n InputStreamReader instr = new InputStreamReader(System.in);\n BufferedReader stdin = new BufferedReader(instr);\n StringTokenizer stok;\n int num;\n String value;\n try\n {\n System.out.println(\"Input a 32 digit binary code. \");\n System.out.println();\n value = stdin.readLine();\n System.out.println();\n stok = new StringTokenizer(value);\n while (stok.hasMoreTokens())\n {\n for(int i = 0; i < 32; i++)\n {\n num = Integer.parseInt(stok.nextToken());\n int z = num;\n if (z == 0 || z == 1)\n {\n binToInt[i] = z;\n if(z == 1)\n {\n if(i == 0 || i == 8 || i == 16 || i == 24)\n {\n binToInt[i] = 128;\n }\n if(i == 1 || i == 9 || i == 17 || i == 25)\n {\n binToInt[i] = 64;\n }\n if(i == 2 || i == 10 || i == 18 || i == 26)\n {\n binToInt[i] = 32;\n }\n if(i == 3 || i == 11 || i == 19 || i == 27)\n {\n binToInt[i] = 16;\n }\n if(i == 4 || i == 12 || i == 20 || i == 28)\n {\n binToInt[i] = 8;\n }\n if(i == 5 || i == 13 || i == 21 || i == 29)\n {\n binToInt[i] = 4;\n }\n if(i == 6 || i == 14 || i == 22 || i == 30)\n {\n binToInt[i] = 2;\n }\n if(i == 7 || i == 15 || i == 23 || i == 31)\n {\n binToInt[i] = 1;\n }\n }\n if(z == 0)\n {\n binToInt[i] = 0;\n }\n }\n if(z > 1)\n {\n System.out.println(\"*Error only input 1's and 0's* Restart Program.\");\n }\n }\n } \n }catch (IOException ioe)\n {\n System.exit(-1);\n }\n }", "private int calculateBinSize(int r15) throws java.io.IOException {\n /*\n r14 = this;\n r1 = 0\n java.io.InputStream r2 = r14.in\n int r12 = r2.available()\n r2.mark(r12)\n r4 = 0\n int r0 = r2.read() // Catch:{ all -> 0x0052 }\n L_0x000f:\n r14.checkComma(r0) // Catch:{ all -> 0x0052 }\n int r5 = r14.readByte(r2) // Catch:{ all -> 0x0052 }\n int r8 = r14.readAddress(r2) // Catch:{ all -> 0x0052 }\n int r9 = r14.readByte(r2) // Catch:{ all -> 0x0052 }\n switch(r9) {\n case 0: goto L_0x0072;\n case 1: goto L_0x0036;\n case 2: goto L_0x0057;\n case 3: goto L_0x0021;\n case 4: goto L_0x003a;\n default: goto L_0x0021;\n } // Catch:{ all -> 0x0052 }\n L_0x0021:\n int r12 = r5 * 2\n int r12 = r12 + 2\n long r10 = (long) r12 // Catch:{ all -> 0x0052 }\n r14.skip(r2, r10) // Catch:{ all -> 0x0052 }\n L_0x0029:\n int r0 = r2.read() // Catch:{ all -> 0x0052 }\n r12 = 10\n if (r0 == r12) goto L_0x0029\n r12 = 13\n if (r0 == r12) goto L_0x0029\n goto L_0x000f\n L_0x0036:\n r2.reset()\n L_0x0039:\n return r1\n L_0x003a:\n int r7 = r14.readAddress(r2) // Catch:{ all -> 0x0052 }\n if (r1 <= 0) goto L_0x004a\n int r12 = r4 >> 16\n int r12 = r12 + 1\n if (r7 == r12) goto L_0x004a\n r2.reset()\n goto L_0x0039\n L_0x004a:\n int r4 = r7 << 16\n r12 = 2\n r14.skip(r2, r12) // Catch:{ all -> 0x0052 }\n goto L_0x0029\n L_0x0052:\n r12 = move-exception\n r2.reset()\n throw r12\n L_0x0057:\n int r12 = r14.readAddress(r2) // Catch:{ all -> 0x0052 }\n int r6 = r12 << 4\n if (r1 <= 0) goto L_0x006b\n int r12 = r6 >> 16\n int r13 = r4 >> 16\n int r13 = r13 + 1\n if (r12 == r13) goto L_0x006b\n r2.reset()\n goto L_0x0039\n L_0x006b:\n r4 = r6\n r12 = 2\n r14.skip(r2, r12) // Catch:{ all -> 0x0052 }\n goto L_0x0029\n L_0x0072:\n int r3 = r4 + r8\n if (r3 < r15) goto L_0x0021\n int r1 = r1 + r5\n goto L_0x0021\n */\n throw new UnsupportedOperationException(\"Method not decompiled: no.nordicsemi.android.dfu.internal.HexInputStream.calculateBinSize(int):int\");\n }", "@Override\n\tpublic String setBinContents(ByteBuffer fileBytes, byte[] container) {\n\t\tfileBytes.get(container);\n\t\treturn Arrays.toString(container);\n\t}", "private static byte[] m2539e(Context context) {\n Throwable th;\n int i = 0;\n ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();\n byte[] bArr = new byte[0];\n String a = Log.m2547a(context, Log.f1857e);\n DiskLruCache diskLruCache = null;\n try {\n diskLruCache = DiskLruCache.m2767a(new File(a), 1, 1, 10240);\n File file = new File(a);\n if (file != null && file.exists()) {\n String[] list = file.list();\n int length = list.length;\n while (i < length) {\n String str = list[i];\n if (str.contains(\".0\")) {\n byteArrayOutputStream.write(StatisticsManager.m2535a(diskLruCache, str.split(\"\\\\.\")[0]));\n }\n i++;\n }\n }\n bArr = byteArrayOutputStream.toByteArray();\n if (byteArrayOutputStream != null) {\n try {\n byteArrayOutputStream.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n if (diskLruCache != null) {\n try {\n diskLruCache.close();\n } catch (Throwable th2) {\n th = th2;\n }\n }\n } catch (IOException th3) {\n BasicLogHandler.m2542a(th3, \"StatisticsManager\", \"getContent\");\n if (byteArrayOutputStream != null) {\n try {\n byteArrayOutputStream.close();\n } catch (IOException e2) {\n e2.printStackTrace();\n }\n }\n if (diskLruCache != null) {\n diskLruCache.close();\n }\n } catch (Throwable th4) {\n th3 = th4;\n }\n return bArr;\n th3.printStackTrace();\n return bArr;\n }", "private boolean readBin(String filePath) throws FileNotFoundException, IOException {\n try {\n BufferedReader dataIn = new BufferedReader(new FileReader(filePath + \".bin\"));\n\n String next = dataIn.readLine();\n int length = Integer.parseInt(next);\n next = dataIn.readLine();\n start = Integer.parseInt(next);\n for (int i = 0; i < memory.length; i++) {\n next = dataIn.readLine();\n if (next == null) {\n break;\n }\n memory[i] = Integer.parseInt(next);\n }\n dataIn.close();\n } catch (IOException ex) {\n print(\"File error: \" + ex.toString());\n return true;\n }\n return false;\n\n }", "private int readFdocaOneByte() {\n checkForSplitRowAndComplete(1);\n //return dataBuffer_[position_++] & 0xff;\n return dataBuffer_.readUnsignedByte();\n }", "public static void main(String args[]) throws IOException {\n\t\t\n\t\tString v=\"1001100000010001\";\n\t\t\t\n\t\tString value=Base64.encodeBase64String(v.getBytes());\n\t\tSystem.out.println(\"hiiiiii===\"+value);\n\t\t\n\t\tString v1=v.substring(0,3);\n\t\tSystem.out.println(\"hiiiiii\"+value);\n\n //System.out.println(\"hiiiiii\"+da);\n //encoding byte array into base 64\n //byte[] encoded = Base64.encodeBase64(orig.getBytes()); \n //byte[] data = SerializationUtils.serialize(yourObject);\n //System.out.println(\"Original String: \" + orig );\n // System.out.println(\"Base64 Encoded String : \" + new String(encoded));\n \n //decoding byte array into base64\n //byte[] decoded = Base64.decodeBase64(encoded);\n\t\ttry{\n byte[] decoded=Base64.decodeBase64(\"AAUMBAAAAP8AAAEAAAABAQAAAQIAAAEDAAABBAAAAQUAAAEGAAABBwAAAQgAAAEJAAABCg==\");\n //System.out.println(\"decoded val : \" +decoded[0]);\n \n //System.out.println(\"Base 64 Decoded String : \" + new String(decoded));\n for(Byte b: decoded){\n \tSystem.out.println(\"decoded val : \" + b);\n }\n // byte[] bb=new byte[decoded.length];\n \tif(decoded!=null && decoded.length>0){\n \t\t//System.out.println(\"decoded val 2: \" +String.valueOf(decoded[3]));\n \t\t//System.arraycopy(decoded, 10, bb, 4 , 4);\n \t\t//System.out.println(\"decoded val 2: \" +String.valueOf(decoded[3]));\n \t\t\n \t\t//String hex = \"ff\"\n \t\t//int value = Integer.parseInt(hex, 16);\n \t\t\n \t\t//String hex = hexToString(decoded[10]);\n \t\t //BigInteger bi = new BigInteger(hex, 16);\n \t\t//bi.intValue();\n \t\t//(String.format(\"%.7f\", f));\n \t\t\n \t\t//String hex = Integer.toHexString(decoded[10]);\n \t\t// Integer.parseInt(hex);\n \t\t\n \t\t//System.out.println(\"Lora \" +hex);\n \t\tint n=0;\n \t\ttry{\n \t\t\t//n=Byte.valueOf(hex);\n \t\t\t//System.out.println(\"Loraa \" +n);\n \t\t}catch(Exception e){\n \t\t\te.printStackTrace();\n \t\t}\n \t\tSystem.out.println(\"Lora1 \" +n);\n \t\t\n \t\tSystem.out.println(\"decoded 10 \" +decoded[10]);\n \t\tSystem.out.println(\"decoded 11 \" +decoded[11]);\n \t\tSystem.out.println(\"decoded 12 \" +decoded[12]);\t\n \t\tSystem.out.println(\"decoded 13 \" +decoded[13]);\n \t\t\n \t\t/*ByteBuffer bb = ByteBuffer.wrap(d);\n bb.order(ByteOrder.LITTLE_ENDIAN);\n System.out.println( bb.getInt());*/\n \t\t\n\t\t //int b=(int) Integer.toUnsignedLong((int)decoded[10]);\n\t\t// String b=String.format(\"%x\", decoded[10]);\n\t\t //int p1=Integer.valueOf(b);\n\t\t //System.out.println(\"Pppppp \" +b);\n\t\t// n=Integer.parseInt(hex);\n\t\t//long h=(long) (decoded[10] & 0x00000000ffffffffL);\n\t\t// System.out.println(\"nnnn \" +Integer.toHexString(decoded[10]));\n\t\t// System.out.println(b);\n\t\t int w=112;\n\t\t// Integer.toBinaryString(w)\n\t\t System.out.println(\"dfdfdfdf\"+Integer.toBinaryString(w));\n\t\t \n\t\t String p=Integer.toBinaryString(w);\n\t\t System.out.println(\"hiiddddd\"+p);\n\t\t int p1=decoded[10] & 0xFF;\n \t\t//int c=decoded[11];\n\t\t int c=0x5f;\n \t\tSystem.out.println(\"p1\"+p1);\n \t\tSystem.out.println(c);\n \t\tint d=decoded[12];\n \t\tSystem.out.println(d);\n \t\tint e=decoded[13] & 0xFF ;\n \t\t int a= (p1 | (c << 8) | (d << 16) | (e << 24));\n \t\t\n \t\t\n \t\tSystem.out.println(a);\n \t\t\n \t}\n \t\n \t//System.out.println(\"bb : \" + bb[4]);\n \n //char character = '2'; \n // int ascii = (int) character;\n // String a= new String(decoded);\n //.out.println(String.format(\"0x%08X\", a));\n //String str=String.format(\"0x%08X\", a);\n //String str = String.format(\"0x\", args)\n //System.out.println(\"String : \" + str);\n /* \n \tSystem.out.println(\"Base 64 Decoded String : \" + Integer.toHexString(50));*/\n }catch(Exception e){\n \te.printStackTrace();\n }\n }", "private void outHex(){\n\t\tSystem.out.println(binary);\n\t\tpw.println(binary);\n\t\t\n\t}", "public static void main(String[] args) {\n\t\tSystem.out.println(\"out :\" + addBinary(\"1101\", \"111\"));\n\t}", "public String memoryDisplayBin()\n {\n int pos = startingPos;\n String ret = \"\";\n while(pos <= endingPos)\n {\n String instruction = mem.getFourBytes(pos);\n String bin = BinaryFormater.format(Integer.toBinaryString(Integer.parseInt(instruction, 16)),32);\n ret += \"0x\"+Integer.toHexString(pos) + \": \" + bin.substring(0,16) + \" \" + bin.substring(16,32)+\"\\n\";\n pos += 4;\n }\n return ret;\n }", "public static void main(String[]args){\n \r\n print_binary(15);//Print the integer in binary form using interations\r\n }", "private byte[] decode(ByteBuffer bytes) {\n \treturn bytes.array();\r\n }", "public static void main(String[] args) {\n byte b1=125;\n System.out.println(b1);\n byte b2=(byte)129;\n System.out.println(b2);\t\t\n\t}", "private boolean isBinaryMessage(Object anObject) {\n\t\tif(anObject.getClass() == this.getClass()) {\n\t\t\treturn true;\n\t\t}\n\t\telse {\n\t\t\treturn false;\n\t\t}\n\t}", "public abstract byte[] parse(String input);", "byte[] token();", "@Test\n public void decodeStringDelta()\n {\n {\n final BinaryEncoder encoder = new BinaryEncoder(0, 16, 1.0);\n assertEquals(3.0, encoder.decode(\"0011\"), 0.0);\n }\n\n {\n final BinaryEncoder encoder = new BinaryEncoder(0, 16, 2.0);\n assertEquals(0.0, encoder.decode(\"0001\"), 2.0);\n }\n\n {\n final BinaryEncoder encoder = new BinaryEncoder(0, 16, 0.5);\n assertEquals(3.0, encoder.decode(\"00110\"), 0.0);\n }\n }", "public static void main(String[] args) {\n\t\tBinaryNumber a = new BinaryNumber(\"11\");\n \tSystem.out.println(a.toDecimal()); \n \tSystem.out.println(a.getLength());\n \tSystem.out.println(a.toString());\n \tSystem.out.println(a.shiftR(3));\n\t\t\t\t\n\t\t}", "public abstract byte[] getEncoded();", "public static void main(String[] args) {\n\t\t short s = 1;\n\t\t byte c = 1;\n\t\t int i = 1;\n\t\t printIntBinary(i);\n\t\t \n\t}", "public AnnisBinary getBinary(Long id)\r\n \t{\r\n \t\tlogger.debug(\"Looking for binary file with id = \" + id);\r\n \t\t\r\n \t\ttry\r\n \t\t{\r\n \t\t\tExtFileObjectCom extFile= this.getExtFileObj(id);\r\n \t\t\tAnnisBinary aBin= new AnnisBinaryImpl(); \r\n \t\t\t\r\n \t\t\t//Bytes setzen\r\n \t\t\tFile file = extFile.getFile();\r\n \t\t\tlong length = file.length();\r\n \t\t\tFileInputStream fis = new FileInputStream(file);\r\n \t\t\tbyte[] bytes = new byte[(int)length];\r\n \t\t int offset = 0;\r\n \t\t int numRead = 0;\r\n \t\t while (offset < bytes.length\r\n \t\t && (numRead=fis.read(bytes, offset, bytes.length-offset)) >= 0) \r\n \t\t {\r\n \t\t \toffset += numRead;\r\n \t\t }\r\n \t\r\n \t\t \r\n \t\t // Ensure all the bytes have been read in\r\n \t\t if (offset < bytes.length) {\r\n \t\t \tthrow new IOException(\"Could not completely read file \"+file.getName());\r\n \t\t }\r\n \t\t\tfis.close();\r\n \t\t\taBin.setBytes(bytes);\r\n \t\t\taBin.setId(extFile.getID());\r\n \t\t\taBin.setFileName(extFile.getFileName());\r\n \t\t\taBin.setMimeType(extFile.getMime());\r\n \t\t\t\r\n \t\t\treturn(aBin);\r\n \t\t}\r\n \t\tcatch (Exception e)\r\n \t\t{\r\n \t\t\tlogger.error(\"Could not read binary file\", e);\r\n \t\t\tthrow new ExternalFileMgrException(e);\r\n \t\t}\r\n \t}", "private static byte[] hexStr2Bytes(String hex) {\n // Adding one byte to get the right conversion\n // values starting with \"0\" can be converted\n byte[] bArray = new BigInteger(\"10\" + hex, 16).toByteArray();\n\n // Copy all the REAL bytes, not the \"first\"\n byte[] ret = new byte[bArray.length - 1];\n for (int i = 0; i < ret.length; i++)\n ret[i] = bArray[i + 1];\n return ret;\n }", "public static void main(String[] args) {\n int x = 7;\n System.out.println(new BinaryNumberOfOnes().convert(x));\n }", "public boolean isBinaryEncoding()\r\n\t{\r\n\t\treturn binary != null;\r\n\t}", "public static byte [] toBytesBinary(String in) {\n byte [] b = new byte[in.length()];\n int size = 0;\n for (int i = 0; i < in.length(); ++i) {\n char ch = in.charAt(i);\n if (ch == '\\\\' && in.length() > i+1 && in.charAt(i+1) == 'x') {\n // ok, take next 2 hex digits.\n char hd1 = in.charAt(i+2);\n char hd2 = in.charAt(i+3);\n\n // they need to be A-F0-9:\n if (!isHexDigit(hd1) ||\n !isHexDigit(hd2)) {\n // bogus escape code, ignore:\n continue;\n }\n // turn hex ASCII digit -> number\n byte d = (byte) ((toBinaryFromHex((byte)hd1) << 4) + toBinaryFromHex((byte)hd2));\n\n b[size++] = d;\n i += 3; // skip 3\n } else {\n b[size++] = (byte) ch;\n }\n }\n // resize:\n byte [] b2 = new byte[size];\n System.arraycopy(b, 0, b2, 0, size);\n return b2;\n }", "public static void main(String[] args) {\n Huffman huffman=new Huffman(\"Shevchenko Vladimir Vladimirovich\");\n System.out.println(huffman.getCodeText());//\n //answer:110100001001101011000001001110111110110101100110110001001110101111100011101000011011000100111010111110001110100101110101111100000\n\n huffman.getSizeBits();//размер в битах\n ;//кол-во символов\n System.out.println((double) huffman.getSizeBits()/(huffman.getValueOfCharactersOfText()*8)); //коэффициент сжатия относительно aski кодов\n System.out.println((double) huffman.getSizeBits()/(huffman.getValueOfCharactersOfText()*\n (Math.pow(huffman.getValueOfCharactersOfText(),0.5)))); //коэффициент сжатия относительно равномерного кода. Не учитывается размер таблицы\n System.out.println(huffman.getMediumLenght());//средняя длина кодового слова\n System.out.println(huffman.getDisper());//дисперсия\n\n\n }", "public static void main(String[] args) {\n\t\tSystem.out.println(\"2:\"+Integer.toBinaryString(2));\n\t\tSystem.out.println(\"3:\"+Integer.toBinaryString(3));\n\t\t\n\t\tSystem.out.println(\"2&3: \"+(2 &3));\n\t\tSystem.out.println(\"2|3: \"+(2 |3));\n\t\tSystem.out.println(\"2^3: \"+(2^3));\n\t\tSystem.out.println(\"~3: \"+(+~3));\n\t\t\n\t\tSystem.out.println(\"~3 to binary:\"+Integer.toBinaryString(~3));\n\t\t\n\t\tSystem.out.println(Integer.toBinaryString(~3).length());\n\t\tSystem.out.println(Integer.MAX_VALUE);\n\t\t\t}", "private static boolean isBinaryType(int jdbcType) {\r\n switch (jdbcType) {\r\n case Types.BINARY:\r\n case Types.VARBINARY:\r\n case Types.LONGVARBINARY:\r\n return true;\r\n default:\r\n return false;\r\n }\r\n }", "@Override\n public void calculateChecksum(byte[] sysex, int start, int end, int offset) {\n }", "@Test\n public void binDescriptionTest() {\n assertEquals(\"bin_desc\", authResponse.getBinDescription());\n }", "public boolean isBase64Binary() {\n return false;\n }", "public abstract String b(byte[] bArr, int i, int i2);", "byte[] getBinaryVDBResource(String resourcePath) throws Exception;", "private static byte[] fromHex(String hex)\n\t {\n\t byte[] binary = new byte[hex.length() / 2];\n\t for(int i = 0; i < binary.length; i++)\n\t {\n\t binary[i] = (byte)Integer.parseInt(hex.substring(2*i, 2*i+2), 16);\n\t }\n\t return binary;\n\t }" ]
[ "0.6279643", "0.6234065", "0.60475445", "0.59203017", "0.5908096", "0.5869546", "0.5848938", "0.5847707", "0.5824533", "0.57888985", "0.57614243", "0.5664256", "0.56623274", "0.5623767", "0.56116456", "0.5599982", "0.55809176", "0.5557122", "0.5544718", "0.5542046", "0.5513071", "0.5476924", "0.54748243", "0.54641545", "0.5459156", "0.5457278", "0.5450331", "0.54498845", "0.54324", "0.5421646", "0.5388489", "0.5379044", "0.53761977", "0.5375218", "0.5374902", "0.53625214", "0.53498805", "0.5337495", "0.5329552", "0.53176874", "0.53166986", "0.53131294", "0.53061384", "0.53052807", "0.5278025", "0.5276218", "0.5271525", "0.52509075", "0.52474684", "0.5236703", "0.5235797", "0.5235797", "0.52348924", "0.52277035", "0.5223493", "0.5217167", "0.52156305", "0.5197635", "0.5195234", "0.51935124", "0.519111", "0.51851034", "0.518337", "0.518291", "0.5182011", "0.5174968", "0.5169932", "0.516587", "0.5162912", "0.51599735", "0.515954", "0.51522714", "0.5151963", "0.51478004", "0.51327676", "0.5130541", "0.51302546", "0.5125161", "0.5109379", "0.5097051", "0.5095916", "0.5090461", "0.50882465", "0.5084342", "0.50794965", "0.50741816", "0.5071401", "0.5066371", "0.506289", "0.5059537", "0.50577825", "0.50550586", "0.5054666", "0.50500196", "0.5048737", "0.50472236", "0.50464654", "0.50444996", "0.50348824", "0.5032535", "0.503144" ]
0.0
-1
Test the behavior of setObject for timestamp columns.
@Test public void testSetLocalDateTimeBc() throws SQLException { assumeTrue(TestUtil.haveIntegerDateTimes(con)); // use BC for funsies List<LocalDateTime> bcDates = new ArrayList<LocalDateTime>(); bcDates.add(LocalDateTime.parse("1997-06-30T23:59:59.999999").with(ChronoField.ERA, IsoEra.BCE.getValue())); bcDates.add(LocalDateTime.parse("0997-06-30T23:59:59.999999").with(ChronoField.ERA, IsoEra.BCE.getValue())); for (LocalDateTime bcDate : bcDates) { String expected = LOCAL_TIME_FORMATTER.format(bcDate); localTimestamps(ZoneOffset.UTC, bcDate, expected); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Test\n public void testDateTimeType() throws Exception {\n if(util.isHiveCatalogStoreRunning()) return;\n\n ResultSet res = null;\n TajoClient client = util.newTajoClient();\n try {\n String tableName = \"datetimetable\";\n String query = \"select col1, col2, col3 from \" + tableName;\n\n String [] table = new String[] {tableName};\n Schema schema = new Schema();\n schema.addColumn(\"col1\", Type.DATE);\n schema.addColumn(\"col2\", Type.TIME);\n schema.addColumn(\"col3\", Type.TIMESTAMP);\n Schema [] schemas = new Schema[] {schema};\n String [] data = {\n \"2014-01-01|01:00:00|2014-01-01 01:00:00\"\n };\n KeyValueSet tableOptions = new KeyValueSet();\n tableOptions.set(StorageConstants.TEXT_DELIMITER, StorageConstants.DEFAULT_FIELD_DELIMITER);\n\n res = TajoTestingCluster\n .run(table, schemas, tableOptions, new String[][]{data}, query, client);\n\n assertTrue(res.next());\n\n Date date = res.getDate(1);\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n date = res.getDate(\"col1\");\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n Time time = res.getTime(2);\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n time = res.getTime(\"col2\");\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n Timestamp timestamp = res.getTimestamp(3);\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n timestamp = res.getTimestamp(\"col3\");\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n // assert with timezone\n Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(\"GMT+9\"));\n date = res.getDate(1, cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n date = res.getDate(\"col1\", cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n time = res.getTime(2, cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n time = res.getTime(\"col2\", cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n timestamp = res.getTimestamp(3, cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n\n timestamp = res.getTimestamp(\"col3\", cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n } finally {\n if (res != null) {\n res.close();\n }\n\n client.close();\n }\n }", "@Test\n public void test_column_type_detection_datetimes_01() throws SQLException {\n Model m = ModelFactory.createDefaultModel();\n testColumnTypeDetection(\"x\", m.createTypedLiteral(Calendar.getInstance()).asNode(), true, Types.TIMESTAMP, Timestamp.class.getCanonicalName());\n }", "@Test\n public void test_column_type_detection_datetimes_04() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"13:15:00.123\", XSDDatatype.XSDtime), true, Types.TIME, Time.class.getCanonicalName());\n }", "@Test\n public void test_column_type_detection_datetimes_03() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"13:15:00\", XSDDatatype.XSDtime), true, Types.TIME, Time.class.getCanonicalName());\n }", "public void setDateTrx (Timestamp DateTrx)\n{\nif (DateTrx == null) throw new IllegalArgumentException (\"DateTrx is mandatory\");\nset_Value (\"DateTrx\", DateTrx);\n}", "boolean hasTimestamp();", "boolean hasTimestamp();", "boolean hasTimestamp();", "boolean hasTimestamp();", "boolean hasTimestamp();", "boolean hasTimestamp();", "boolean hasTimestamp();", "public abstract void setDate(Timestamp uneDate);", "void setTimestamp(int index, Timestamp value)\n throws SQLException;", "@Test\n public void testTimestampColumnOptional() {\n Schema schema = Schema.newBuilder()\n .setTimestampColumn(\"timestamp\").build();\n\n Map<String, Value> map = new HashMap<>();\n map.put(\"timestamp\", Values.asTimestamp(Values.ofString(\"2019-01-30T19:30:12Z\")));\n\n PCollection<FeatureRow> output = pipeline\n .apply(Create.of(Lists.newArrayList(map)).withCoder(VALUE_MAP_CODER))\n .apply(new ValueMapToFeatureRowTransform(\"entity\", schema));\n\n PAssert.that(output).satisfies(maps -> {\n FeatureRow row = maps.iterator().next();\n assertEquals(\"entity\", row.getEntityName());\n assertEquals(map.get(\"timestamp\").getTimestampVal(), row.getEventTimestamp());\n return null;\n });\n pipeline.run();\n }", "@Test\n public void test_column_type_detection_datetimes_02() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"2013-04-08\", XSDDatatype.XSDdate), true, Types.DATE, Date.class.getCanonicalName());\n }", "public final void testSetTimeStamp() {\n Notification n = new Notification(\"type\", \"src\", 1);\n n.setTimeStamp(123);\n assertEquals(123, n.getTimeStamp());\n }", "public boolean set(long timestamp, T e) {\n return set(timestamp, e, false);\n }", "public boolean hasTimestamp() {\n return fieldSetFlags()[6];\n }", "@Test\n public void testSetLocalDateTime() throws SQLException {\n List<String> zoneIdsToTest = getZoneIdsToTest();\n List<String> datesToTest = getDatesToTest();\n\n for (String zoneId : zoneIdsToTest) {\n ZoneId zone = ZoneId.of(zoneId);\n for (String date : datesToTest) {\n LocalDateTime localDateTime = LocalDateTime.parse(date);\n String expected = localDateTime.atZone(zone)\n .format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)\n .replace('T', ' ');\n localTimestamps(zone, localDateTime, expected);\n }\n }\n }", "@Test\n public void testHiveParquetTimestampAsInt96_basic() throws Exception {\n BaseTestQuery.testBuilder().unOrdered().sqlQuery((\"SELECT convert_from(timestamp_field, 'TIMESTAMP_IMPALA') as timestamp_field \" + \"from cp.`parquet/part1/hive_all_types.parquet` \")).baselineColumns(\"timestamp_field\").baselineValues(TestBuilder.convertToLocalDateTime(\"2013-07-06 00:01:00\")).baselineValues(((Object) (null))).go();\n }", "@Test\n public void testSetOffsetTimeWithoutType() throws SQLException {\n OffsetTime data = OffsetTime.parse(\"16:21:51+12:34\");\n insertThenReadWithoutType(data, \"time_with_time_zone_column\", Time.class);\n }", "public void setTimestamp(Date timestamp) {\r\n this.timestamp = timestamp;\r\n }", "@Test\r\n public void testApplyChanges()\r\n {\r\n EasyMockSupport support = new EasyMockSupport();\r\n\r\n PreferencesRegistry registry = createPreferencesRegistry(support);\r\n CellSampler sampler = createSampler(support);\r\n ColumnDefinitionModel model = createModel();\r\n\r\n support.replayAll();\r\n\r\n @SuppressWarnings(\"unused\")\r\n ColumnDefinitionController controller = new ColumnDefinitionController(registry, model, sampler);\r\n\r\n ColumnDefinitionTableModel definitionTable = model.getDefinitionTableModel();\r\n\r\n CSVParseParameters parameters = model.getSelectedParameters();\r\n\r\n ColumnDefinitionRow timeRow = definitionTable.getRow(0);\r\n model.setSelectedDefinition(timeRow);\r\n timeRow.setFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\");\r\n\r\n SpecialColumn timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n ColumnDefinitionRow latRow = definitionTable.getRow(1);\r\n model.setSelectedDefinition(latRow);\r\n latRow.setDataType(null);\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n ColumnDefinitionRow lonRow = definitionTable.getRow(2);\r\n model.setSelectedDefinition(lonRow);\r\n lonRow.setColumnName(\"Longitude\");\r\n\r\n List<? extends String> columnNames = parameters.getColumnNames();\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n\r\n ColumnDefinitionRow name2 = definitionTable.getRow(4);\r\n model.setSelectedDefinition(name2);\r\n name2.setIsImport(true);\r\n\r\n columnNames = parameters.getColumnNames();\r\n assertEquals(ColumnHeaders.TIME.toString(), columnNames.get(0));\r\n assertEquals(ColumnHeaders.LAT.toString(), columnNames.get(1));\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n assertEquals(ColumnHeaders.NAME.toString(), columnNames.get(3));\r\n assertEquals(ColumnHeaders.NAME2.toString(), columnNames.get(4));\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n SpecialColumn lonColumn = parameters.getSpecialColumn(ColumnType.LON);\r\n assertEquals(2, lonColumn.getColumnIndex());\r\n assertEquals(\"Decimal\", lonColumn.getFormat());\r\n\r\n assertTrue(parameters.getColumnsToIgnore().isEmpty());\r\n\r\n support.verifyAll();\r\n }", "@Test\n public void testSetOffsetDateTime() throws SQLException {\n List<String> zoneIdsToTest = getZoneIdsToTest();\n List<TimeZone> storeZones = new ArrayList<TimeZone>();\n for (String zoneId : zoneIdsToTest) {\n storeZones.add(TimeZone.getTimeZone(zoneId));\n }\n List<String> datesToTest = getDatesToTest();\n\n for (TimeZone timeZone : storeZones) {\n ZoneId zoneId = timeZone.toZoneId();\n for (String date : datesToTest) {\n LocalDateTime localDateTime = LocalDateTime.parse(date);\n String expected = date.replace('T', ' ');\n offsetTimestamps(zoneId, localDateTime, expected, storeZones);\n }\n }\n }", "public void setDateTrx (Timestamp DateTrx);", "public void setDateTrx (Timestamp DateTrx);", "public boolean hasTimestamp() {\n return fieldSetFlags()[2];\n }", "@Test\n public void testSetLocalTimeWithType() throws SQLException {\n LocalTime data = LocalTime.parse(\"16:21:51\");\n Time actual = insertThenReadWithType(data, Types.TIME, \"time_without_time_zone_column\", Time.class);\n Time expected = Time.valueOf(\"16:21:51\");\n assertEquals(expected, actual);\n }", "public void setTimestamp(Date timestamp) {\n this.timestamp = timestamp;\n }", "@Override\n\tpublic void visit(TimestampValue arg0) {\n\n\t}", "@Test\n public void testSetOffsetTimeWithType() throws SQLException {\n OffsetTime data = OffsetTime.parse(\"16:21:51+12:34\");\n insertThenReadWithType(data, Types.TIME, \"time_with_time_zone_column\", Time.class);\n }", "@Override\n\tpublic void visit(TimestampValue arg0) {\n\t\t\n\t}", "public boolean hasTimestamp() {\n return fieldSetFlags()[0];\n }", "void setTimestamp(int index, Timestamp value, Calendar cal)\n throws SQLException;", "public void setTimestamp(Timestamp timestamp) {\n\t\tthis.timestamp = timestamp;\n\t}", "@Test\n public void testSetLocalTimeWithoutType() throws SQLException {\n LocalTime data = LocalTime.parse(\"16:21:51\");\n Time actual = insertThenReadWithoutType(data, \"time_without_time_zone_column\", Time.class);\n Time expected = Time.valueOf(\"16:21:51\");\n assertEquals(expected, actual);\n }", "public void setValidTo (Timestamp ValidTo);", "@OfMethod({\"setTimestamp(java.lang.String,java.sql.Timeastamp)\",\n \"setTimestamp(java.lang.String,java.sql.Timestamp,java.util.Calendar)\",\n \"setTimestamp(int,java.sql.Timestamp)\",\n \"setTimestamp(int,java.sql.Timestamp,java.util.Calendar)\"})\n public void testSetTimestamp() throws Exception {\n CallableStatement instance = newClosedCall();\n\n try {\n instance.setTimestamp(getParameterName(), Timestamp.valueOf(\"2007-05-02 04:48:01\"));\n fail(\"Allowed set timestamp by parameter name after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTimestamp(getParameterName(), Timestamp.valueOf(\"2007-05-02 04:48:01\"), Calendar.getInstance());\n fail(\"Allowed set timestamp by parameter name and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTimestamp(getParameterIndex(), Timestamp.valueOf(\"2007-05-02 04:48:01\"));\n fail(\"Allowed set time by parameter index after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTimestamp(getParameterIndex(), Timestamp.valueOf(\"2007-05-02 04:48:01\"), Calendar.getInstance());\n fail(\"Allowed set timestamp by parameter index and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n }", "@Test\r\n public void testTimestampDuration() throws Exception\r\n {\r\n Timestamp ts = new Timestamp(100110L).applyTimeOrigin(0L);\r\n\r\n GCEvent e = getGCEventToTest(ts, 7L);\r\n\r\n // time (dedicated accessor and generic field)\r\n assertEquals(100110L, e.getTime().longValue());\r\n assertEquals(100110L, ((Long)e.get(FieldType.TIME).getValue()).longValue());\r\n\r\n // offset (dedicated accessor and generic field)\r\n assertEquals(100110L, e.getOffset().longValue());\r\n assertEquals(\"100.110\", e.get(FieldType.OFFSET).getValue());\r\n\r\n // duration (dedicated accessor and generic field)\r\n assertEquals(7L, e.getDuration());\r\n assertEquals(7L, ((Long) e.get(FieldType.DURATION).getValue()).longValue());\r\n }", "public abstract void setFecha_ingreso(java.sql.Timestamp newFecha_ingreso);", "@Test\n public void testImpalaParquetBinaryAsTimeStamp_DictChange() throws Exception {\n try {\n BaseTestQuery.testBuilder().sqlQuery(\"select min(int96_ts) date_value from dfs.`parquet/int96_dict_change`\").optionSettingQueriesForTestQuery(\"alter session set `%s` = true\", PARQUET_READER_INT96_AS_TIMESTAMP).ordered().baselineColumns(\"date_value\").baselineValues(TestBuilder.convertToLocalDateTime(\"1970-01-01 00:00:01.000\")).build().run();\n } finally {\n BaseTestQuery.resetSessionOption(PARQUET_READER_INT96_AS_TIMESTAMP);\n }\n }", "public void set(final Timestamp timestamp) {\n stamp = timestamp.get();\n }", "public void setTimestamp(Integer timestamp) {\n this.timestamp = timestamp;\n }", "public void setSOHTimestamp(Date SOHTimestamp) {\r\n/* 482 */ this._SOHTimestamp = SOHTimestamp;\r\n/* */ }", "public void setTimestamp(@NonNull Date timestamp) {\n this.timestamp = timestamp;\n }", "public void setTimestamp(Long timestamp) {\n this.timestamp = timestamp;\n }", "public interface Timestampable {\r\n \r\n /**\r\n * Property which represents createdDate.\r\n */\r\n static final String PROP_CREATED_DATE = \"createdDate\";\r\n \r\n /**\r\n * Property which represents modifiedDate.\r\n */\r\n static final String PROP_MODIFIED_DATE = \"modifiedDate\";\r\n \r\n\r\n \r\n Date getCreatedDate();\r\n \r\n void setCreatedDate(Date createdDate);\r\n \r\n Date getModifiedDate();\r\n \r\n void setModifiedDate(Date modifiedDate);\r\n\r\n}", "public boolean hasTimestamp() {\n return timestamp_ != null;\n }", "public void setModified(java.sql.Timestamp tmp) {\n this.modified = tmp;\n }", "@Test\n public void testSetLocalTimeAndReadBack() throws SQLException {\n // TODO: fix for binary mode.\n // Avoid micros truncation in org.postgresql.jdbc.PgResultSet#internalGetObject\n assumeBinaryModeRegular();\n LocalTime data = LocalTime.parse(\"16:21:51.123456\");\n\n insertWithoutType(data, \"time_without_time_zone_column\");\n\n String readBack = readString(\"time_without_time_zone_column\");\n assertEquals(\"16:21:51.123456\", readBack);\n }", "public boolean hasTimestamp() {\n return result.hasTimestamp();\n }", "public boolean hasTimestamp() {\n return timestampBuilder_ != null || timestamp_ != null;\n }", "public void setDia_especifico(java.sql.Timestamp newDia_especifico);", "public void setStatementDate (Timestamp StatementDate);", "@Test\n public void testTimeStampRounding() throws SQLException {\n assumeBinaryModeRegular();\n LocalTime time = LocalTime.parse(\"23:59:59.999999500\");\n Time actual = insertThenReadWithoutType(time, \"time_without_time_zone_column\", Time.class, false/*no roundtrip*/);\n assertEquals(Time.valueOf(\"24:00:00\"), actual);\n }", "@JsProperty(name = \"timestamp\")\n public native void setTimestamp(@DoNotAutobox Number value);", "@Test\n public void testTimeStampRoundingWithType() throws SQLException {\n assumeBinaryModeRegular();\n LocalTime time = LocalTime.parse(\"23:59:59.999999500\");\n Time actual =\n insertThenReadWithType(time, Types.TIME, \"time_without_time_zone_column\", Time.class, false/*no roundtrip*/);\n assertEquals(Time.valueOf(\"24:00:00\"), actual);\n }", "@Override\r\n public void setTimeStamp(long parseLong) throws IOException {\n\r\n }", "public void setFecha(java.sql.Timestamp newFecha);", "public void setTimestamp(final Date timestamp) {\r\n mTimestamp = timestamp;\r\n }", "@JsonSetter(\"product_timestamps\")\n public void setProductTimestamps (ProductTimestamps value) { \n this.productTimestamps = value;\n }", "@Test\n public void updatedAtTest() {\n // TODO: test updatedAt\n }", "@Test\r\n\tpublic void testSetDate() {\n\t\tfail(\"Not yet implemented\");\r\n\t}", "protected void setTimestamp(long time) \n {\n\t\tlTimestamp = time;\n\t}", "public void setTimestamp(long value) {\r\n this.timestamp = value;\r\n }", "public abstract void setFecha_fin(java.sql.Timestamp newFecha_fin);", "public boolean hasTimestamp() {\r\n return ((bitField0_ & 0x00000001) == 0x00000001);\r\n }", "public boolean hasTimestamp() {\r\n return ((bitField0_ & 0x00000001) == 0x00000001);\r\n }", "public void setDateOrdered (Timestamp DateOrdered);", "public void setTimestamp() {\n timestamp = System.nanoTime();\n }", "public void setValidFrom (Timestamp ValidFrom);", "public void setMovementDate (Timestamp MovementDate);", "public final void testGetTimeStamp() {\n assertEquals(hello.timeStamp, n.getTimeStamp());\n }", "public Timestamp getDateTrx() \n{\nreturn (Timestamp)get_Value(\"DateTrx\");\n}", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000001) == 0x00000001);\n }", "public void setFecha_envio(java.sql.Timestamp newFecha_envio);", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000001) == 0x00000001);\n }", "public boolean hasTimestamp() {\r\n return ((bitField0_ & 0x00000001) == 0x00000001);\r\n }", "public boolean hasTimestamp() {\r\n return ((bitField0_ & 0x00000001) == 0x00000001);\r\n }", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000008) == 0x00000008);\n }", "@NoProxy\n public void setDtstamps(final Timestamp val) {\n DateTime dt = new DateTime(val);\n setDtstamp(new DtStamp(dt).getValue());\n setLastmod(new LastModified(dt).getValue());\n setCtoken(getLastmod() + \"-\" + hex4FromNanos(val.getNanos()));\n\n if (getCreated() == null) {\n setCreated(new Created(dt).getValue());\n }\n }", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000008) == 0x00000008);\n }", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000002) == 0x00000002);\n }", "public TimeSeriesPoint setTimestamp(OffsetDateTime timestamp) {\n this.timestamp = timestamp;\n return this;\n }", "@Test\n public void testImpalaParquetTimestampInt96AsTimeStamp() throws Exception {\n try {\n BaseTestQuery.alterSession(PARQUET_NEW_RECORD_READER, false);\n compareParquetInt96Converters(\"field_impala_ts\", \"cp.`parquet/int96_impala_1.parquet`\");\n BaseTestQuery.alterSession(PARQUET_NEW_RECORD_READER, true);\n compareParquetInt96Converters(\"field_impala_ts\", \"cp.`parquet/int96_impala_1.parquet`\");\n } finally {\n BaseTestQuery.resetSessionOption(PARQUET_NEW_RECORD_READER);\n }\n }", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000002) == 0x00000002);\n }", "@Test\n public void testColumnFlatValueTimestampExpression() {\n final KijiRowExpression kijiRowExpression =\n new KijiRowExpression(\"family:qual0[0].ts\", TypeInfos.COLUMN_FLAT_VALUE);\n\n // Test that the KijiDataRequest was constructed correctly\n final KijiDataRequest kijiDataRequest = kijiRowExpression.getDataRequest();\n assertEquals(1, kijiDataRequest.getColumns().size());\n assertNotNull(kijiDataRequest.getColumn(\"family\", \"qual0\"));\n for (KijiDataRequest.Column column : kijiDataRequest.getColumns()) {\n assertTrue(column.getColumnName().isFullyQualified());\n assertEquals(1,\n kijiDataRequest.getColumn(column.getFamily(), column.getQualifier()).getMaxVersions());\n }\n }", "public void setDateDoc (Timestamp DateDoc);", "public void setDateDoc (Timestamp DateDoc);", "public void setDateDoc (Timestamp DateDoc);", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000040) == 0x00000040);\n }", "public void test_DATE_HHmmss_conditionBean() { // *Important!\r\n // ## Arrange ##\r\n Calendar cal = Calendar.getInstance();\r\n cal.set(2008, 5, 15, 12, 34, 56);\r\n cal.set(Calendar.MILLISECOND, 123);\r\n Member member = new Member();\r\n member.setMemberId(3);\r\n LocalDate targetDate = toLocalDate(cal);\r\n member.setBirthdate(targetDate);\r\n memberBhv.updateNonstrict(member);\r\n\r\n // ## Act ##\r\n cal.set(2008, 5, 15, 12, 34, 57); // plus one second\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because java.sql.Date is converted to java.util.Date in ConditionBean. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n cal.set(2008, 5, 15, 12, 34, 56); // just time\r\n cal.set(Calendar.MILLISECOND, 0); // Don't format!\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = DfTypeUtil.toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n }", "@Test\n public void shouldSerializeToTimestampWhenSerializingDateWithJackson() throws ParseException, JsonProcessingException {\n SimpleDateFormat df = new SimpleDateFormat(\"dd-MM-yyyy hh:mm\");\n df.setTimeZone(TimeZone.getTimeZone(\"UTC\"));\n\n Date date = df.parse(\"01-01-1970 01:00\");\n Event event = new Event(\"party\", date);\n\n ObjectMapper objectMapper = new ObjectMapper();\n String result = objectMapper.writeValueAsString(event);\n\n assertThat(result, containsString(\"party\"));\n assertThat(result, containsString(\"3600000\"));\n }", "@Test\n public void testImpalaParquetBinaryAsTimeStamp_DictChange() throws Exception {\n final String WORKING_PATH = TestTools.getWorkingPath();\n final String TEST_RES_PATH = WORKING_PATH + \"/src/test/resources\";\n testBuilder()\n .sqlQuery(\"select int96_ts from dfs.\\\"%s/parquet/int96_dict_change\\\" order by int96_ts\", TEST_RES_PATH)\n .ordered()\n .csvBaselineFile(\"testframework/testParquetReader/testInt96DictChange/q1.tsv\")\n .baselineTypes(TypeProtos.MinorType.TIMESTAMP)\n .baselineColumns(\"int96_ts\")\n .build().run();\n }", "public boolean hasTimestamp() {\n return ((bitField0_ & 0x00000040) == 0x00000040);\n }", "private TimestampUtils(){}", "public void setTimestamp(java.lang.Long value) {\n this.timestamp = value;\n }", "public void setTimestamp(java.lang.Long value) {\n this.timestamp = value;\n }", "@JsonProperty(\"timestamp\")\n public void setTimestamp(Double timestamp) {\n this.timestamp = timestamp;\n }", "public void setDateAcct (Timestamp DateAcct);" ]
[ "0.6882056", "0.6726877", "0.64846486", "0.64817333", "0.63776785", "0.6333653", "0.6333653", "0.6333653", "0.6333653", "0.6333653", "0.6333653", "0.6333653", "0.6272805", "0.6259626", "0.61703455", "0.61352193", "0.6129139", "0.6119334", "0.6089663", "0.6081879", "0.60614973", "0.60504264", "0.60491043", "0.60465723", "0.60395414", "0.6035357", "0.6035357", "0.60326964", "0.60241014", "0.60212415", "0.6019549", "0.6018986", "0.6007818", "0.59854805", "0.5969364", "0.5956896", "0.5940227", "0.5940166", "0.58686334", "0.5867526", "0.58618987", "0.583692", "0.5836", "0.5835691", "0.58301604", "0.5827618", "0.5824383", "0.58200467", "0.58157283", "0.57890683", "0.57823986", "0.57416344", "0.5731745", "0.57149696", "0.56826985", "0.5680923", "0.56772155", "0.5673435", "0.56696236", "0.5665917", "0.56591606", "0.56586725", "0.5647882", "0.56413704", "0.5632674", "0.5630108", "0.56291366", "0.56056476", "0.56056476", "0.56046784", "0.5597146", "0.5575892", "0.556878", "0.55671763", "0.55637735", "0.5555495", "0.55410844", "0.5540903", "0.5535931", "0.5535931", "0.5535314", "0.55318356", "0.5529222", "0.55271906", "0.5522397", "0.5515649", "0.55143803", "0.55088645", "0.550614", "0.550614", "0.550614", "0.5495423", "0.5493068", "0.54912263", "0.54836935", "0.54749763", "0.54578406", "0.54446554", "0.54446554", "0.54389274", "0.5435578" ]
0.0
-1
Test the behavior setObject for date columns.
@Test public void testSetLocalDateWithType() throws SQLException { LocalDate data = LocalDate.parse("1971-12-15"); java.sql.Date actual = insertThenReadWithType(data, Types.DATE, "date_column", java.sql.Date.class); java.sql.Date expected = java.sql.Date.valueOf("1971-12-15"); assertEquals(expected, actual); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Test\r\n\tpublic void testSetDate() {\n\t\tfail(\"Not yet implemented\");\r\n\t}", "@Test(dataProvider = \"date\")\r\n\tpublic void setDate(Date in, Date out) {\n\t\ttoTest.setDate(in);\r\n\t\t// reflect private field name\r\n\t\tField f = getPrivateField(toTest, \"date\");\r\n\t\ttry {\r\n\t\t\tif (in == null) {\r\n\t\t\t\tassertEquals(f.get(toTest), in, \"field should be set to null\");\r\n\t\t\t} else {\r\n\t\t\t\tassertNotSame(f.get(toTest), in, \"field should be a new object\");\r\n\t\t\t}\r\n\r\n\t\t} catch (IllegalArgumentException | IllegalAccessException e) {\r\n\t\t\t// TODO Auto-generated catch block\r\n\t\t\te.printStackTrace();\r\n\t\t}\r\n\r\n\t}", "@Test\r\n public void testSetDateEaten()\r\n {\r\n System.out.println(\"setDateEaten\");\r\n Date dateEaten = Date.valueOf(\"1982-04-08\");\r\n FoodBean instance = new FoodBean(5, \"Beans on toast\", \r\n Date.valueOf(\"2014-04-01\"), Time.valueOf(\"10:00:00\"), \r\n 100, 120, 5, 7, 500, 0, 3);\r\n instance.setDateEaten(dateEaten);\r\n assertEquals(dateEaten, instance.getDateEaten());\r\n }", "public void testGetSetDate() {\n exp = new Experiment(\"10\");\n Date date = new Date();\n exp.setDate(date);\n assertEquals(\"get/setDate does not work\", date, exp.getDate());\n }", "public void _Date() {\n testProperty(\"Date\", new PropertyTester() {\n protected Object getNewValue(String prop, Object old) {\n return utils.isVoid(old) ? new Integer(6543) :\n super.getNewValue(prop, old) ;\n }\n }) ;\n }", "void setDate(Date data);", "@Override\n\tprotected void setDate() {\n\n\t}", "public void SetDate(Date date);", "@Test\n public void testSetLocalDateWithoutType() throws SQLException {\n LocalDate data = LocalDate.parse(\"1971-12-15\");\n java.sql.Date actual = insertThenReadWithoutType(data, \"date_column\", java.sql.Date.class);\n java.sql.Date expected = java.sql.Date.valueOf(\"1971-12-15\");\n assertEquals(expected, actual);\n }", "@Test\n void setDate() {\n }", "@Override\n\tpublic boolean update(Dates obj) {\n\t\treturn false;\n\t}", "public void test_DATE_HHmmss_conditionBean() { // *Important!\r\n // ## Arrange ##\r\n Calendar cal = Calendar.getInstance();\r\n cal.set(2008, 5, 15, 12, 34, 56);\r\n cal.set(Calendar.MILLISECOND, 123);\r\n Member member = new Member();\r\n member.setMemberId(3);\r\n LocalDate targetDate = toLocalDate(cal);\r\n member.setBirthdate(targetDate);\r\n memberBhv.updateNonstrict(member);\r\n\r\n // ## Act ##\r\n cal.set(2008, 5, 15, 12, 34, 57); // plus one second\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because java.sql.Date is converted to java.util.Date in ConditionBean. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n cal.set(2008, 5, 15, 12, 34, 56); // just time\r\n cal.set(Calendar.MILLISECOND, 0); // Don't format!\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = DfTypeUtil.toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n }", "public void setDate(DateTime \n date) {\n this.date = date;\n }", "void setDate(int index, Date value) throws SQLException;", "@Test\n public void test_column_type_detection_datetimes_02() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"2013-04-08\", XSDDatatype.XSDdate), true, Types.DATE, Date.class.getCanonicalName());\n }", "void testDateSetDate(java.util.Date date, boolean validate) {\n if (date instanceof java.sql.Time) { return; } // java.sql.Time throws IllegalArgumentException in setDate().\n \n if (validate) {\n assertEqualDate(createDate(\"Feb 03, 2006\"), date);\n } else {\n synchronized (date) {\n date.setDate(3);\n }\n }\n }", "@Test\n public void testSetFecha() {\n System.out.println(\"setFecha\");\n Date fecha = null;\n Reserva instance = new Reserva();\n instance.setFecha(fecha);\n \n }", "@Override\n\tpublic boolean create(Dates obj) {\n\t\treturn false;\n\t}", "@OfMethod({\"setDate(java.lang.String,java.sql.Date)\",\n \"setDate(java.lang.String,java.sql.Date,java.util.Calendar)\",\n \"setDate(int,java.sql.Date)\",\n \"setDate(int,java.sql.Date,java.util.Calendar)\"})\n public void testSetDate() throws Exception {\n CallableStatement instance = newClosedCall();\n\n try {\n instance.setDate(getParameterName(), Date.valueOf(\"2007-05-02\"));\n fail(\"Allowed set date by parameter name after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setDate(getParameterName(), Date.valueOf(\"2007-05-02\"), Calendar.getInstance());\n fail(\"Allowed set date by parameter name and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setDate(getParameterIndex(), Date.valueOf(\"2007-05-02\"));\n fail(\"Allowed set date by parameter index after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setDate(getParameterIndex(), Date.valueOf(\"2007-05-02\"), Calendar.getInstance());\n fail(\"Allowed set date by parameter index and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n }", "public void testCompareDateAndString() {\n\t\tString value = \"2012-05-08\";\r\n FormatDateField dateField = new FormatDateField();\r\n\t\tdateField.setPropertyEditor(new DateTimePropertyEditor(DateUtil.datePattern));\r\n\t\tDate date = DateUtil.convertStringToDate(value.toString());\r\n\t\tassertEquals(false, compareDateAndString(dateField.getPropertyEditor(), date, value));\r\n\t\t\r\n\t\t// 2. Date (value = \"2012-05-09\", date = 2012-05-08)\r\n\t\tvalue = \"2012-05-09\";\r\n\t\tassertEquals(true, compareDateAndString(dateField.getPropertyEditor(), date, value));\r\n\t\t\r\n\t\t// 3. DateTime (value = \"2012-05-08T00:00:00\", date = 2012-05-08T00:00:00)\r\n\t\tvalue = \"2012-05-08T00:00:00\";\r\n\t\tdateField.setPropertyEditor(new DateTimePropertyEditor(DateUtil.formatDateTimePattern));\r\n\t\tdate = DateUtil.convertStringToDate(DateUtil.dateTimePattern,value.toString());\r\n dateField.setValue(date);\r\n\t\tassertEquals(false, compareDateAndString(dateField.getPropertyEditor(), date, value));\r\n\t\t\r\n\t\t// 4. DateTime (value = \"2012-05-09T00:00:00\", date = 2012-05-08T00:00:00)\r\n\t\tvalue = \"2012-05-09T00:00:00\";\r\n\t\tassertEquals(true, compareDateAndString(dateField.getPropertyEditor(), date, value));\r\n\t\t\r\n\t\t// 5. value = date = null;\r\n\t\tassertEquals(false, compareDateAndString(dateField.getPropertyEditor(), null, null));\r\n\t\t\r\n\t\t// 6. value = null, date != null\r\n\t\tassertEquals(true, compareDateAndString(dateField.getPropertyEditor(), date, null));\r\n\t\t\r\n\t\t// 7. value != null, date = null\r\n\t\tassertEquals(true, compareDateAndString(dateField.getPropertyEditor(), null, value));\r\n\t\t\r\n\t}", "public void setDate(Date newDate) {\r\n int oldMonthValue = getMonth();\r\n int oldYearValue = getYear();\r\n Date oldDate = getDate();\r\n calendarTable.getCalendarModel().setDate(newDate);\r\n updateControlsFromTable();\r\n // fire property change\r\n int newMonthValue = getMonth();\r\n if (oldMonthValue != newMonthValue) {\r\n firePropertyChange(MONTH_PROPERTY, oldMonthValue, newMonthValue);\r\n }\r\n int newYearValue = getYear();\r\n if (oldYearValue != newYearValue) {\r\n firePropertyChange(YEAR_PROPERTY, oldYearValue, newYearValue);\r\n }\r\n if (oldDate.getTime() != newDate.getTime()) {\r\n firePropertyChange(DATE_PROPERTY, oldDate, newDate);\r\n }\r\n \r\n // clear selection when changing the month in view\r\n if (oldMonthValue != newMonthValue && oldYearValue != newYearValue) {\r\n calendarTable.getSelectionModel().clearSelection();\r\n }\r\n int rowCount = calendarTable.getRowCount();\r\n int columnCount= calendarTable.getColumnCount();\r\n \tCalendar cal = Calendar.getInstance();\r\n \tcal.setTime(newDate);\r\n \t\r\n for(int contOne = 0; contOne < rowCount; contOne++)\r\n {\r\n for(int contTwo = 0; contTwo < columnCount; contTwo++)\r\n {\r\n \tif( (\"\" + calendarTable.getModel().getValueAt(contOne, contTwo)).equals(\"\" + cal.get(Calendar.DAY_OF_MONTH) ))\r\n \t{\r\n \t\tcalendarTable.setRowSelectionInterval(contOne, contOne);\r\n \t\tcalendarTable.setColumnSelectionInterval(contTwo, contTwo);\r\n \t\tcontOne = rowCount;\r\n \t\tcontTwo = columnCount;\r\n \t}\r\n }\r\n }\r\n \r\n }", "public void setDate(Date date) {\r\n this.date = date;\r\n }", "void setCreateDate(Date date);", "boolean isSetDate();", "public void setFechaInclusion(Date fechaInclusion)\r\n/* 155: */ {\r\n/* 156:174 */ this.fechaInclusion = fechaInclusion;\r\n/* 157: */ }", "public void setDatetest( java.sql.Date newValue ) {\n __setCache(\"datetest\", newValue);\n }", "@Test\n public void testSetStartDate() {\n System.out.println(\"setStartDate\");\n Calendar newStart = new GregorianCalendar(2000, 01, 01);\n String startDate = newStart.toString();\n DTO_Ride instance = dtoRide;\n instance.setStartDate(startDate);\n \n String result = instance.getStartDate();\n assertEquals(newStart, newStart);\n }", "public void setDate(Date date) {\n this.date = date;\n }", "public void setDate(Date date) {\n this.date = date;\n }", "public void setDate(Date date) {\n this.date = date;\n }", "public void setDate(Date date) {\n this.date = date;\n }", "public void setDate(Date date) {\n this.date = date;\n }", "public void setDate(Date date) {\n this.date = date;\n }", "public void setDate(Date date) {\n this.date = date;\n }", "public void setDate(Date date) {\n this.date = date;\n }", "public void setDate(Date date) {\n this.date = date;\n }", "public void test_Date_utilDateColumn_selects_sqlDate_Tx() throws Exception {\n // ## Arrange ##\n final Integer memberId = 1;\n\n // ## Act ##\n final Member member = jdbcManager.from(Member.class).where(\"memberId = ?\", memberId).getSingleResult();\n\n // ## Assert ##\n assertNotNull(member);\n log(member.toString());\n assertEquals(memberId, member.memberId);\n assertEquals(java.sql.Date.class, member.birthdate.getClass());\n }", "public void setBirthDate(Date birthDate);", "public void setCreateDate(Date createDate);", "public void setCreateDate(Date createDate);", "public void setCreateDate(Date createDate);", "@Test\n void getAndSetDate() {\n }", "@Test\n public void teste_setdtFundacao_e_getDtFundacao_correto() {\n String data = fixtureData;\n emp.setDtFundacao(data);\n assertThat(\"Os valores deveriam ser iguais\", DataJoda.cadastraData(data), equalTo(emp.getDtFundacao()));\n }", "public void setEditDate(Date editDate)\r\n/* */ {\r\n/* 193 */ this.editDate = editDate;\r\n/* */ }", "Employee setBirthdate(Date birthdate);", "@Test\r\n public void getDateValue() throws Exception {\r\n assertEquals(dt1,point1.getDateValue());\r\n assertEquals(dt2,point2.getDateValue());\r\n assertEquals(dt3,point3.getDateValue());\r\n assertEquals(dt4,point4.getDateValue());\r\n }", "@Test\n\tpublic void testBUpdate() {\n\t\tDynamicSqlDemoEntity demoEntity = em.find(DynamicSqlDemoEntity.class, id);\n\t\tdemoEntity.setCol1(\"dummyValue\" + UUID.randomUUID().toString());\n\t}", "public T caseDate(Date object) {\n\t\treturn null;\n\t}", "@Test\n public void testSetFechaFin() {\n System.out.println(\"setFechaFin\");\n Date fechaFin = null;\n Reserva instance = new Reserva();\n instance.setFechaFin(fechaFin);\n \n }", "private static boolean isDate(final Object obj) {\n return dateClass != null && dateClass.isAssignableFrom(obj.getClass());\n }", "public void setData (Date date) {\r\n\t\tthis.data=date;\r\n\t\t\r\n\t}", "public void setDate() {\n this.date = new Date();\n }", "public void setDateCreated(Date dateCreated);", "public void testDateConversion() throws Exception {\n Calendar calendar = Calendar.getInstance();\n TimeDetails details = new TimeDetails(\n calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND));\n DateMetadataDefinition def = new DateMetadataDefinition(\"date\", \"\",\n calendar.get(Calendar.YEAR),\n calendar.get(Calendar.MONTH),\n calendar.get(Calendar.DAY_OF_MONTH),\n details,\n false);\n List<AbstractMetadataDefinition> list = new LinkedList<AbstractMetadataDefinition>();\n list.add(def);\n PluginImpl.getInstance().setDefinitions(list);\n FreeStyleProject freeStyleProject = createFreeStyleProject();\n configRoundtrip(freeStyleProject);\n MetadataJobProperty property = freeStyleProject.getProperty(MetadataJobProperty.class);\n assertNotNull(\"No MetadataJobProperty\", property);\n DateMetadataValue dateValue = (DateMetadataValue)TreeStructureUtil.getLeaf(property, \"date\");\n assertNotNull(dateValue);\n assertEquals(def.getHour(), dateValue.getHour());\n assertEquals(def.getMinute(), dateValue.getMinute());\n assertEquals(def.getSecond(), dateValue.getSecond());\n assertEquals(def.getDay(), dateValue.getDay());\n assertEquals(def.getMonth(), dateValue.getMonth());\n assertEquals(def.getYear(), dateValue.getYear());\n }", "@Test\r\n public void testGetDateEaten()\r\n {\r\n System.out.println(\"getDateEaten\");\r\n FoodBean instance = new FoodBean(5, \"Beans on toast\", \r\n Date.valueOf(\"2014-04-01\"), Time.valueOf(\"10:00:00\"), \r\n 100, 120, 5, 7, 500, 0, 3);\r\n Date expResult = Date.valueOf(\"2014-04-01\");\r\n Date result = instance.getDateEaten();\r\n assertEquals(expResult, result);\r\n \r\n }", "public abstract void setDate(Timestamp uneDate);", "public void testSetDate() throws ParseException {\n ValueString vs = new ValueString();\n SimpleDateFormat format = new SimpleDateFormat(\"yyyy/MM/dd HH:mm:ss.SSS\", Locale.US);\n\n try {\n vs.setDate(null);\n // assertNull(vs.getString());\n fail(\"expected NullPointerException\");\n } catch (NullPointerException ex) {\n // This is the original behaviour\n }\n vs.setDate(format.parse(\"2006/06/07 01:02:03.004\"));\n assertEquals(\"2006/06/07 01:02:03.004\", vs.getString());\n }", "public void setDate(String ymd) throws RelationException;", "public void testConvertDate() throws Exception {\n String[] message= {\n \"from Date\",\n \"from Calendar\",\n \"from SQL Date\",\n \"from SQL Time\",\n \"from SQL Timestamp\"\n };\n \n long now = System.currentTimeMillis();\n \n Object[] date = {\n new Date(now),\n new java.util.GregorianCalendar(),\n new java.sql.Date(now),\n new java.sql.Time(now),\n new java.sql.Timestamp(now)\n };\n \n // Initialize calendar also with same ms to avoid a failing test in a new time slice\n ((GregorianCalendar)date[1]).setTimeInMillis(now);\n \n for (int i = 0; i < date.length; i++) {\n Object val = makeConverter().convert(getExpectedType(), date[i]);\n assertNotNull(\"Convert \" + message[i] + \" should not be null\", val);\n assertTrue(\"Convert \" + message[i] + \" should return a \" + getExpectedType().getName(),\n getExpectedType().isInstance(val));\n assertEquals(\"Convert \" + message[i] + \" should return a \" + date[0],\n now, ((Date) val).getTime());\n }\n }", "void testDateSetMonth(java.util.Date date, boolean validate) {\n if (date instanceof java.sql.Time) { return; } // java.sql.Time throws IllegalArgumentException in setMonth().\n \n if (validate) {\n assertEqualDate(createDate(\"Apr 20, 2006\"), date);\n } else {\n synchronized (date) {\n date.setMonth(3);\n }\n }\n }", "public void setCreateDate(Date createDate)\r\n/* */ {\r\n/* 165 */ this.createDate = createDate;\r\n/* */ }", "public void testGetDate() {\r\n assertEquals(test1.getDate(), 20200818);\r\n }", "public void setDate(int date){\n this.date = date;\n }", "@Test\n public void testSetFechaPago() {\n System.out.println(\"setFechaPago\");\n Date fechaPago = null;\n DetalleAhorro instance = new DetalleAhorro();\n instance.setFechaPago(fechaPago);\n // TODO review the generated test code and remove the default call to fail.\n //fail(\"The test case is a prototype.\");\n }", "@Test\n\tpublic void t1_date_main() {\n\t\tDate in = Date.from(K_ZDT.toInstant());\n\t\t\n\t\t_TestEntityWithDate toDb = new _TestEntityWithDate();\n\t\ttoDb.setId(new Random().nextLong());\n\t\ttoDb.setUserEntered(in);\n\t\t\n\t\tmongo.save(toDb);\n\t\t\n\t\t_TestEntityWithDate fromDb = mongo.findById(toDb.getId(), _TestEntityWithDate.class);\n\t\tassertNotNull(fromDb);\n\t\t\n\t\tassertEquals(in, fromDb.getUserEntered());\n\t}", "public void setStartDate(Date s);", "public final void testNoDate() {\n testTransaction1.setDate(null);\n assertFalse(testTransaction1.isValidTransaction());\n }", "public void setDate(Date date) {\n\t\n\t\tthis.date = date;\n\t\n\t}", "void setBirthDate(Date birthDate);", "@Test\n\tpublic void testDate1() {\n\t\ttry {\n\t\t\tfinal Date date = ParadoxDate.getDateFromParadoxDate(0);\n\t\t\tfinal Calendar calendar = Calendar.getInstance();\n\t\t\tcalendar.setTime(date);\n\t\t\tAssert.assertTrue(calendar.get(Calendar.DATE) == 1);\n\t\t\tAssert.assertTrue(calendar.get(Calendar.MONTH) == 0);\n\t\t\tAssert.assertTrue(calendar.get(Calendar.YEAR) == 1900);\n\t\t} catch (final Exception e) {\n\t\t\te.printStackTrace();\n\t\t\tAssert.fail();\n\t\t}\n\t}", "public void setDate(Date date) {\r\n\t\tthis.date = date;\r\n\t}", "public void setDate(Date date) {\r\n\t\tthis.date = date;\r\n\t}", "public void setDate(Date date) {\r\n\t\tthis.date = date;\r\n\t}", "@Test\n public void testDateTimeType() throws Exception {\n if(util.isHiveCatalogStoreRunning()) return;\n\n ResultSet res = null;\n TajoClient client = util.newTajoClient();\n try {\n String tableName = \"datetimetable\";\n String query = \"select col1, col2, col3 from \" + tableName;\n\n String [] table = new String[] {tableName};\n Schema schema = new Schema();\n schema.addColumn(\"col1\", Type.DATE);\n schema.addColumn(\"col2\", Type.TIME);\n schema.addColumn(\"col3\", Type.TIMESTAMP);\n Schema [] schemas = new Schema[] {schema};\n String [] data = {\n \"2014-01-01|01:00:00|2014-01-01 01:00:00\"\n };\n KeyValueSet tableOptions = new KeyValueSet();\n tableOptions.set(StorageConstants.TEXT_DELIMITER, StorageConstants.DEFAULT_FIELD_DELIMITER);\n\n res = TajoTestingCluster\n .run(table, schemas, tableOptions, new String[][]{data}, query, client);\n\n assertTrue(res.next());\n\n Date date = res.getDate(1);\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n date = res.getDate(\"col1\");\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n Time time = res.getTime(2);\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n time = res.getTime(\"col2\");\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n Timestamp timestamp = res.getTimestamp(3);\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n timestamp = res.getTimestamp(\"col3\");\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n // assert with timezone\n Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(\"GMT+9\"));\n date = res.getDate(1, cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n date = res.getDate(\"col1\", cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n time = res.getTime(2, cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n time = res.getTime(\"col2\", cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n timestamp = res.getTimestamp(3, cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n\n timestamp = res.getTimestamp(\"col3\", cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n } finally {\n if (res != null) {\n res.close();\n }\n\n client.close();\n }\n }", "@Test\n public void testSetDateLine() {\n System.out.println(\"setDateLine\");\n String dateLine = \"01-01-1970\";\n Assignment instance = new Assignment(\"Research Languages\");\n instance.setDateLine(dateLine);\n // TODO review the generated test code and remove the default call to fail.\n }", "public void setDate(String date){\n this.date = date;\n }", "public void testIndexCostForDate() {\n final Date dateIndexing = new Date();\n this.classHandler.applyIndexesForDate(dateIndexing);\n }", "@Override\n\tpublic void visit(DateValue arg0) {\n\t\t\n\t}", "void setDate(int index, Date value, Calendar cal)\n throws SQLException;", "public void setDate(Date date) {\r\n \t\tthis.startDate = date;\r\n \t}", "@Override\n\tpublic void visit(DateValue arg0) {\n\n\t}", "public void setDate(String date){\n this.date = date;\n }", "@Override\n public void setDateHeader(String arg0, long arg1) {\n\n }", "@Test\n\tpublic void testSetFecha2(){\n\t\tPlataforma.logout();\n\t\tPlataforma.login(Plataforma.alumnos.get(0).getNia(), Plataforma.alumnos.get(0).getPassword());\n\t\tLocalDate fin = Plataforma.fechaActual.plusDays(10);\n\t\tLocalDate ini = Plataforma.fechaActual.plusDays(2);\n\t\tassertFalse(ej1.setFechaFin(fin));\n\t\tassertFalse(ej1.setFechaIni(ini));\n\t}", "@Test\n\tpublic void testSetStartDate() {\n\t\tassertNotEquals(calTest, initialJob.getStartDate());\n\t\tinitialJob.setStartDate(calTest.get(Calendar.YEAR), calTest.get(Calendar.MONTH), \n\t\t\t\tcalTest.get(Calendar.DATE), calTest.get(Calendar.HOUR), \n\t\t\t\tcalTest.get(Calendar.MINUTE));\n\t\tassertEquals(calTest, initialJob.getStartDate());\n\t\t\n\t\t// check different dates are not equivalent\n\t\tinitialJob.setStartDate(calTest.get(Calendar.YEAR) + 1, calTest.get(Calendar.MONTH), \n\t\t\t\tcalTest.get(Calendar.DATE), calTest.get(Calendar.HOUR), \n\t\t\t\tcalTest.get(Calendar.MINUTE));\n\t\tassertNotEquals(calTest, initialJob.getStartDate());\n\t}", "@Test\n public void testSetEndDate() {\n System.out.println(\"setEndDate\");\n Calendar newEnd = new GregorianCalendar(2000, 01, 01);\n String endDate = newEnd.toString();\n DTO_Ride instance = dtoRide;\n instance.setEndDate(endDate);\n \n String result = endDate.toString();\n assertEquals(newEnd, newEnd);\n }", "void setCreatedDate(Date createdDate);", "@Test\r\n public void testSetDataSprzedazy() {\r\n System.out.println(\"setDataSprzedazy\");\r\n Date dataSprzedazy = null;\r\n Faktura instance = new Faktura();\r\n instance.setDataSprzedazy(dataSprzedazy);\r\n // TODO review the generated test code and remove the default call to fail.\r\n fail(\"The test case is a prototype.\");\r\n }", "abstract public void setServiceAppointment(Date serviceAppointment);", "public void setDate(long date)\r\n/* 199: */ {\r\n/* 200:299 */ setDate(\"Date\", date);\r\n/* 201: */ }", "public IDataExporter<CRBBase> setInvoiceDate(LocalDate invoiceDate);", "public void setCreatedDate(Date createdDate);", "void setDateOfBirth(LocalDate dateOfBirth);", "protected void addStartDatePropertyDescriptor(Object object) {\n\t\titemPropertyDescriptors.add\n\t\t\t(createItemPropertyDescriptor\n\t\t\t\t(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),\n\t\t\t\t getResourceLocator(),\n\t\t\t\t getString(\"_UI_Cell_startDate_feature\"),\n\t\t\t\t getString(\"_UI_PropertyDescriptor_description\", \"_UI_Cell_startDate_feature\", \"_UI_Cell_type\"),\n\t\t\t\t LDEExperimentsPackage.Literals.CELL__START_DATE,\n\t\t\t\t true,\n\t\t\t\t false,\n\t\t\t\t false,\n\t\t\t\t ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,\n\t\t\t\t null,\n\t\t\t\t null));\n\t}", "public void setDate(java.util.Date param){\n \n this.localDate=param;\n \n\n }", "public void setDate(int dt) {\n date = dt;\n }", "public void setColumn(String column, java.util.Date d)\n {\n if (! hasColumn(column))\n throw new IllegalArgumentException(\"No such column \" + column);\n \n if (d == null)\n {\n setColumnNull(canonicalize(column));\n return;\n }\n \n \n data.put(canonicalize(column), d);\n }", "@Override\n\tpublic void setValue(T obj, Map<String,String> map, Method method) throws ExcelException{\n\t\ttry {\n\t\t\tString value=map.get(VALUE_NAME_KEY);\n\t\t\tif(value==null||value.trim().equals(\"\")) return;\n\t\t\tDate dt=null;\n\t\t\ttry\n\t\t\t{//非正规日期格式\n\t\t\t\tdt=HSSFDateUtil.getJavaDate(Double.parseDouble(value));\n\t\t\t}catch(Exception ex)\n\t\t\t{//正日期格式\n\t\t\t\tSimpleDateFormat sdf=new SimpleDateFormat(\"yyyy-MM-dd\");\n\t\t\t\tdt=sdf.parse(value);\n\t\t\t}\n\t\t\t\n\t\t\tmethod.invoke(obj, dt);\n\t\t} catch (Exception e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t\tthrow new ExcelException(e);\n\t\t}\n\t\t\n\t}", "public void setTodayDate() {\r\n int oldMonthValue = getMonth();\r\n int oldYearValue = getYear();\r\n calendarTable.getCalendarModel().setTodayDate();\r\n updateControlsFromTable();\r\n // fire property change\r\n int newMonthValue = getMonth();\r\n if (oldMonthValue != newMonthValue) {\r\n firePropertyChange(MONTH_PROPERTY, oldMonthValue, newMonthValue);\r\n }\r\n int newYearValue = getYear();\r\n if (oldYearValue != newYearValue) {\r\n firePropertyChange(YEAR_PROPERTY, oldYearValue, newYearValue);\r\n }\r\n // clear selection when changing the month in view\r\n if (oldMonthValue != newMonthValue && oldYearValue != newYearValue) {\r\n calendarTable.getSelectionModel().clearSelection();\r\n }\r\n }", "@Test\r\n public void testApplyChanges()\r\n {\r\n EasyMockSupport support = new EasyMockSupport();\r\n\r\n PreferencesRegistry registry = createPreferencesRegistry(support);\r\n CellSampler sampler = createSampler(support);\r\n ColumnDefinitionModel model = createModel();\r\n\r\n support.replayAll();\r\n\r\n @SuppressWarnings(\"unused\")\r\n ColumnDefinitionController controller = new ColumnDefinitionController(registry, model, sampler);\r\n\r\n ColumnDefinitionTableModel definitionTable = model.getDefinitionTableModel();\r\n\r\n CSVParseParameters parameters = model.getSelectedParameters();\r\n\r\n ColumnDefinitionRow timeRow = definitionTable.getRow(0);\r\n model.setSelectedDefinition(timeRow);\r\n timeRow.setFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\");\r\n\r\n SpecialColumn timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n ColumnDefinitionRow latRow = definitionTable.getRow(1);\r\n model.setSelectedDefinition(latRow);\r\n latRow.setDataType(null);\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n ColumnDefinitionRow lonRow = definitionTable.getRow(2);\r\n model.setSelectedDefinition(lonRow);\r\n lonRow.setColumnName(\"Longitude\");\r\n\r\n List<? extends String> columnNames = parameters.getColumnNames();\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n\r\n ColumnDefinitionRow name2 = definitionTable.getRow(4);\r\n model.setSelectedDefinition(name2);\r\n name2.setIsImport(true);\r\n\r\n columnNames = parameters.getColumnNames();\r\n assertEquals(ColumnHeaders.TIME.toString(), columnNames.get(0));\r\n assertEquals(ColumnHeaders.LAT.toString(), columnNames.get(1));\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n assertEquals(ColumnHeaders.NAME.toString(), columnNames.get(3));\r\n assertEquals(ColumnHeaders.NAME2.toString(), columnNames.get(4));\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n SpecialColumn lonColumn = parameters.getSpecialColumn(ColumnType.LON);\r\n assertEquals(2, lonColumn.getColumnIndex());\r\n assertEquals(\"Decimal\", lonColumn.getFormat());\r\n\r\n assertTrue(parameters.getColumnsToIgnore().isEmpty());\r\n\r\n support.verifyAll();\r\n }" ]
[ "0.72088534", "0.6945885", "0.67868644", "0.6761132", "0.6633157", "0.6559653", "0.6417059", "0.64154106", "0.63613486", "0.6349729", "0.6288675", "0.62766004", "0.6269622", "0.6206175", "0.6154703", "0.6129991", "0.60722893", "0.6039803", "0.6036126", "0.5954938", "0.5952103", "0.5931866", "0.5918047", "0.59161896", "0.59129477", "0.5905757", "0.58984107", "0.5890962", "0.5890962", "0.5890962", "0.5890962", "0.5890962", "0.5890962", "0.5890962", "0.5890962", "0.5890962", "0.58902144", "0.58729035", "0.58725876", "0.58725876", "0.58725876", "0.5857616", "0.58559823", "0.58442265", "0.5843333", "0.58237255", "0.58069026", "0.5802577", "0.580134", "0.57968414", "0.579306", "0.5792969", "0.57886064", "0.5788354", "0.57834494", "0.5768197", "0.5755201", "0.5753693", "0.5749685", "0.5742711", "0.57389635", "0.5734196", "0.57273567", "0.572436", "0.5717131", "0.57126373", "0.5710323", "0.57054216", "0.57031107", "0.5696703", "0.5692845", "0.5692845", "0.5692845", "0.568526", "0.5679266", "0.56775665", "0.56662554", "0.5665236", "0.5648523", "0.56390184", "0.56337845", "0.56301415", "0.56291586", "0.5626852", "0.56201345", "0.5618267", "0.5617776", "0.56157154", "0.56073546", "0.560425", "0.5602056", "0.55984026", "0.5590526", "0.5589864", "0.55881125", "0.5586526", "0.5585819", "0.55848", "0.5579406", "0.5568757" ]
0.6430262
6
Test the behavior setObject for date columns.
@Test public void testSetLocalDateWithoutType() throws SQLException { LocalDate data = LocalDate.parse("1971-12-15"); java.sql.Date actual = insertThenReadWithoutType(data, "date_column", java.sql.Date.class); java.sql.Date expected = java.sql.Date.valueOf("1971-12-15"); assertEquals(expected, actual); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Test\r\n\tpublic void testSetDate() {\n\t\tfail(\"Not yet implemented\");\r\n\t}", "@Test(dataProvider = \"date\")\r\n\tpublic void setDate(Date in, Date out) {\n\t\ttoTest.setDate(in);\r\n\t\t// reflect private field name\r\n\t\tField f = getPrivateField(toTest, \"date\");\r\n\t\ttry {\r\n\t\t\tif (in == null) {\r\n\t\t\t\tassertEquals(f.get(toTest), in, \"field should be set to null\");\r\n\t\t\t} else {\r\n\t\t\t\tassertNotSame(f.get(toTest), in, \"field should be a new object\");\r\n\t\t\t}\r\n\r\n\t\t} catch (IllegalArgumentException | IllegalAccessException e) {\r\n\t\t\t// TODO Auto-generated catch block\r\n\t\t\te.printStackTrace();\r\n\t\t}\r\n\r\n\t}", "@Test\r\n public void testSetDateEaten()\r\n {\r\n System.out.println(\"setDateEaten\");\r\n Date dateEaten = Date.valueOf(\"1982-04-08\");\r\n FoodBean instance = new FoodBean(5, \"Beans on toast\", \r\n Date.valueOf(\"2014-04-01\"), Time.valueOf(\"10:00:00\"), \r\n 100, 120, 5, 7, 500, 0, 3);\r\n instance.setDateEaten(dateEaten);\r\n assertEquals(dateEaten, instance.getDateEaten());\r\n }", "public void testGetSetDate() {\n exp = new Experiment(\"10\");\n Date date = new Date();\n exp.setDate(date);\n assertEquals(\"get/setDate does not work\", date, exp.getDate());\n }", "public void _Date() {\n testProperty(\"Date\", new PropertyTester() {\n protected Object getNewValue(String prop, Object old) {\n return utils.isVoid(old) ? new Integer(6543) :\n super.getNewValue(prop, old) ;\n }\n }) ;\n }", "void setDate(Date data);", "@Test\n public void testSetLocalDateWithType() throws SQLException {\n LocalDate data = LocalDate.parse(\"1971-12-15\");\n java.sql.Date actual = insertThenReadWithType(data, Types.DATE, \"date_column\", java.sql.Date.class);\n java.sql.Date expected = java.sql.Date.valueOf(\"1971-12-15\");\n assertEquals(expected, actual);\n }", "@Override\n\tprotected void setDate() {\n\n\t}", "public void SetDate(Date date);", "@Test\n void setDate() {\n }", "@Override\n\tpublic boolean update(Dates obj) {\n\t\treturn false;\n\t}", "public void test_DATE_HHmmss_conditionBean() { // *Important!\r\n // ## Arrange ##\r\n Calendar cal = Calendar.getInstance();\r\n cal.set(2008, 5, 15, 12, 34, 56);\r\n cal.set(Calendar.MILLISECOND, 123);\r\n Member member = new Member();\r\n member.setMemberId(3);\r\n LocalDate targetDate = toLocalDate(cal);\r\n member.setBirthdate(targetDate);\r\n memberBhv.updateNonstrict(member);\r\n\r\n // ## Act ##\r\n cal.set(2008, 5, 15, 12, 34, 57); // plus one second\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because java.sql.Date is converted to java.util.Date in ConditionBean. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n cal.set(2008, 5, 15, 12, 34, 56); // just time\r\n cal.set(Calendar.MILLISECOND, 0); // Don't format!\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = DfTypeUtil.toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n }", "public void setDate(DateTime \n date) {\n this.date = date;\n }", "void setDate(int index, Date value) throws SQLException;", "@Test\n public void test_column_type_detection_datetimes_02() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"2013-04-08\", XSDDatatype.XSDdate), true, Types.DATE, Date.class.getCanonicalName());\n }", "void testDateSetDate(java.util.Date date, boolean validate) {\n if (date instanceof java.sql.Time) { return; } // java.sql.Time throws IllegalArgumentException in setDate().\n \n if (validate) {\n assertEqualDate(createDate(\"Feb 03, 2006\"), date);\n } else {\n synchronized (date) {\n date.setDate(3);\n }\n }\n }", "@Test\n public void testSetFecha() {\n System.out.println(\"setFecha\");\n Date fecha = null;\n Reserva instance = new Reserva();\n instance.setFecha(fecha);\n \n }", "@Override\n\tpublic boolean create(Dates obj) {\n\t\treturn false;\n\t}", "@OfMethod({\"setDate(java.lang.String,java.sql.Date)\",\n \"setDate(java.lang.String,java.sql.Date,java.util.Calendar)\",\n \"setDate(int,java.sql.Date)\",\n \"setDate(int,java.sql.Date,java.util.Calendar)\"})\n public void testSetDate() throws Exception {\n CallableStatement instance = newClosedCall();\n\n try {\n instance.setDate(getParameterName(), Date.valueOf(\"2007-05-02\"));\n fail(\"Allowed set date by parameter name after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setDate(getParameterName(), Date.valueOf(\"2007-05-02\"), Calendar.getInstance());\n fail(\"Allowed set date by parameter name and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setDate(getParameterIndex(), Date.valueOf(\"2007-05-02\"));\n fail(\"Allowed set date by parameter index after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setDate(getParameterIndex(), Date.valueOf(\"2007-05-02\"), Calendar.getInstance());\n fail(\"Allowed set date by parameter index and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n }", "public void testCompareDateAndString() {\n\t\tString value = \"2012-05-08\";\r\n FormatDateField dateField = new FormatDateField();\r\n\t\tdateField.setPropertyEditor(new DateTimePropertyEditor(DateUtil.datePattern));\r\n\t\tDate date = DateUtil.convertStringToDate(value.toString());\r\n\t\tassertEquals(false, compareDateAndString(dateField.getPropertyEditor(), date, value));\r\n\t\t\r\n\t\t// 2. Date (value = \"2012-05-09\", date = 2012-05-08)\r\n\t\tvalue = \"2012-05-09\";\r\n\t\tassertEquals(true, compareDateAndString(dateField.getPropertyEditor(), date, value));\r\n\t\t\r\n\t\t// 3. DateTime (value = \"2012-05-08T00:00:00\", date = 2012-05-08T00:00:00)\r\n\t\tvalue = \"2012-05-08T00:00:00\";\r\n\t\tdateField.setPropertyEditor(new DateTimePropertyEditor(DateUtil.formatDateTimePattern));\r\n\t\tdate = DateUtil.convertStringToDate(DateUtil.dateTimePattern,value.toString());\r\n dateField.setValue(date);\r\n\t\tassertEquals(false, compareDateAndString(dateField.getPropertyEditor(), date, value));\r\n\t\t\r\n\t\t// 4. DateTime (value = \"2012-05-09T00:00:00\", date = 2012-05-08T00:00:00)\r\n\t\tvalue = \"2012-05-09T00:00:00\";\r\n\t\tassertEquals(true, compareDateAndString(dateField.getPropertyEditor(), date, value));\r\n\t\t\r\n\t\t// 5. value = date = null;\r\n\t\tassertEquals(false, compareDateAndString(dateField.getPropertyEditor(), null, null));\r\n\t\t\r\n\t\t// 6. value = null, date != null\r\n\t\tassertEquals(true, compareDateAndString(dateField.getPropertyEditor(), date, null));\r\n\t\t\r\n\t\t// 7. value != null, date = null\r\n\t\tassertEquals(true, compareDateAndString(dateField.getPropertyEditor(), null, value));\r\n\t\t\r\n\t}", "public void setDate(Date newDate) {\r\n int oldMonthValue = getMonth();\r\n int oldYearValue = getYear();\r\n Date oldDate = getDate();\r\n calendarTable.getCalendarModel().setDate(newDate);\r\n updateControlsFromTable();\r\n // fire property change\r\n int newMonthValue = getMonth();\r\n if (oldMonthValue != newMonthValue) {\r\n firePropertyChange(MONTH_PROPERTY, oldMonthValue, newMonthValue);\r\n }\r\n int newYearValue = getYear();\r\n if (oldYearValue != newYearValue) {\r\n firePropertyChange(YEAR_PROPERTY, oldYearValue, newYearValue);\r\n }\r\n if (oldDate.getTime() != newDate.getTime()) {\r\n firePropertyChange(DATE_PROPERTY, oldDate, newDate);\r\n }\r\n \r\n // clear selection when changing the month in view\r\n if (oldMonthValue != newMonthValue && oldYearValue != newYearValue) {\r\n calendarTable.getSelectionModel().clearSelection();\r\n }\r\n int rowCount = calendarTable.getRowCount();\r\n int columnCount= calendarTable.getColumnCount();\r\n \tCalendar cal = Calendar.getInstance();\r\n \tcal.setTime(newDate);\r\n \t\r\n for(int contOne = 0; contOne < rowCount; contOne++)\r\n {\r\n for(int contTwo = 0; contTwo < columnCount; contTwo++)\r\n {\r\n \tif( (\"\" + calendarTable.getModel().getValueAt(contOne, contTwo)).equals(\"\" + cal.get(Calendar.DAY_OF_MONTH) ))\r\n \t{\r\n \t\tcalendarTable.setRowSelectionInterval(contOne, contOne);\r\n \t\tcalendarTable.setColumnSelectionInterval(contTwo, contTwo);\r\n \t\tcontOne = rowCount;\r\n \t\tcontTwo = columnCount;\r\n \t}\r\n }\r\n }\r\n \r\n }", "public void setDate(Date date) {\r\n this.date = date;\r\n }", "void setCreateDate(Date date);", "boolean isSetDate();", "public void setFechaInclusion(Date fechaInclusion)\r\n/* 155: */ {\r\n/* 156:174 */ this.fechaInclusion = fechaInclusion;\r\n/* 157: */ }", "public void setDatetest( java.sql.Date newValue ) {\n __setCache(\"datetest\", newValue);\n }", "@Test\n public void testSetStartDate() {\n System.out.println(\"setStartDate\");\n Calendar newStart = new GregorianCalendar(2000, 01, 01);\n String startDate = newStart.toString();\n DTO_Ride instance = dtoRide;\n instance.setStartDate(startDate);\n \n String result = instance.getStartDate();\n assertEquals(newStart, newStart);\n }", "public void setDate(Date date) {\n this.date = date;\n }", "public void setDate(Date date) {\n this.date = date;\n }", "public void setDate(Date date) {\n this.date = date;\n }", "public void setDate(Date date) {\n this.date = date;\n }", "public void setDate(Date date) {\n this.date = date;\n }", "public void setDate(Date date) {\n this.date = date;\n }", "public void setDate(Date date) {\n this.date = date;\n }", "public void setDate(Date date) {\n this.date = date;\n }", "public void setDate(Date date) {\n this.date = date;\n }", "public void test_Date_utilDateColumn_selects_sqlDate_Tx() throws Exception {\n // ## Arrange ##\n final Integer memberId = 1;\n\n // ## Act ##\n final Member member = jdbcManager.from(Member.class).where(\"memberId = ?\", memberId).getSingleResult();\n\n // ## Assert ##\n assertNotNull(member);\n log(member.toString());\n assertEquals(memberId, member.memberId);\n assertEquals(java.sql.Date.class, member.birthdate.getClass());\n }", "public void setBirthDate(Date birthDate);", "public void setCreateDate(Date createDate);", "public void setCreateDate(Date createDate);", "public void setCreateDate(Date createDate);", "@Test\n void getAndSetDate() {\n }", "@Test\n public void teste_setdtFundacao_e_getDtFundacao_correto() {\n String data = fixtureData;\n emp.setDtFundacao(data);\n assertThat(\"Os valores deveriam ser iguais\", DataJoda.cadastraData(data), equalTo(emp.getDtFundacao()));\n }", "public void setEditDate(Date editDate)\r\n/* */ {\r\n/* 193 */ this.editDate = editDate;\r\n/* */ }", "Employee setBirthdate(Date birthdate);", "@Test\r\n public void getDateValue() throws Exception {\r\n assertEquals(dt1,point1.getDateValue());\r\n assertEquals(dt2,point2.getDateValue());\r\n assertEquals(dt3,point3.getDateValue());\r\n assertEquals(dt4,point4.getDateValue());\r\n }", "@Test\n\tpublic void testBUpdate() {\n\t\tDynamicSqlDemoEntity demoEntity = em.find(DynamicSqlDemoEntity.class, id);\n\t\tdemoEntity.setCol1(\"dummyValue\" + UUID.randomUUID().toString());\n\t}", "public T caseDate(Date object) {\n\t\treturn null;\n\t}", "@Test\n public void testSetFechaFin() {\n System.out.println(\"setFechaFin\");\n Date fechaFin = null;\n Reserva instance = new Reserva();\n instance.setFechaFin(fechaFin);\n \n }", "private static boolean isDate(final Object obj) {\n return dateClass != null && dateClass.isAssignableFrom(obj.getClass());\n }", "public void setData (Date date) {\r\n\t\tthis.data=date;\r\n\t\t\r\n\t}", "public void setDate() {\n this.date = new Date();\n }", "public void setDateCreated(Date dateCreated);", "public void testDateConversion() throws Exception {\n Calendar calendar = Calendar.getInstance();\n TimeDetails details = new TimeDetails(\n calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND));\n DateMetadataDefinition def = new DateMetadataDefinition(\"date\", \"\",\n calendar.get(Calendar.YEAR),\n calendar.get(Calendar.MONTH),\n calendar.get(Calendar.DAY_OF_MONTH),\n details,\n false);\n List<AbstractMetadataDefinition> list = new LinkedList<AbstractMetadataDefinition>();\n list.add(def);\n PluginImpl.getInstance().setDefinitions(list);\n FreeStyleProject freeStyleProject = createFreeStyleProject();\n configRoundtrip(freeStyleProject);\n MetadataJobProperty property = freeStyleProject.getProperty(MetadataJobProperty.class);\n assertNotNull(\"No MetadataJobProperty\", property);\n DateMetadataValue dateValue = (DateMetadataValue)TreeStructureUtil.getLeaf(property, \"date\");\n assertNotNull(dateValue);\n assertEquals(def.getHour(), dateValue.getHour());\n assertEquals(def.getMinute(), dateValue.getMinute());\n assertEquals(def.getSecond(), dateValue.getSecond());\n assertEquals(def.getDay(), dateValue.getDay());\n assertEquals(def.getMonth(), dateValue.getMonth());\n assertEquals(def.getYear(), dateValue.getYear());\n }", "@Test\r\n public void testGetDateEaten()\r\n {\r\n System.out.println(\"getDateEaten\");\r\n FoodBean instance = new FoodBean(5, \"Beans on toast\", \r\n Date.valueOf(\"2014-04-01\"), Time.valueOf(\"10:00:00\"), \r\n 100, 120, 5, 7, 500, 0, 3);\r\n Date expResult = Date.valueOf(\"2014-04-01\");\r\n Date result = instance.getDateEaten();\r\n assertEquals(expResult, result);\r\n \r\n }", "public abstract void setDate(Timestamp uneDate);", "public void testSetDate() throws ParseException {\n ValueString vs = new ValueString();\n SimpleDateFormat format = new SimpleDateFormat(\"yyyy/MM/dd HH:mm:ss.SSS\", Locale.US);\n\n try {\n vs.setDate(null);\n // assertNull(vs.getString());\n fail(\"expected NullPointerException\");\n } catch (NullPointerException ex) {\n // This is the original behaviour\n }\n vs.setDate(format.parse(\"2006/06/07 01:02:03.004\"));\n assertEquals(\"2006/06/07 01:02:03.004\", vs.getString());\n }", "public void setDate(String ymd) throws RelationException;", "public void testConvertDate() throws Exception {\n String[] message= {\n \"from Date\",\n \"from Calendar\",\n \"from SQL Date\",\n \"from SQL Time\",\n \"from SQL Timestamp\"\n };\n \n long now = System.currentTimeMillis();\n \n Object[] date = {\n new Date(now),\n new java.util.GregorianCalendar(),\n new java.sql.Date(now),\n new java.sql.Time(now),\n new java.sql.Timestamp(now)\n };\n \n // Initialize calendar also with same ms to avoid a failing test in a new time slice\n ((GregorianCalendar)date[1]).setTimeInMillis(now);\n \n for (int i = 0; i < date.length; i++) {\n Object val = makeConverter().convert(getExpectedType(), date[i]);\n assertNotNull(\"Convert \" + message[i] + \" should not be null\", val);\n assertTrue(\"Convert \" + message[i] + \" should return a \" + getExpectedType().getName(),\n getExpectedType().isInstance(val));\n assertEquals(\"Convert \" + message[i] + \" should return a \" + date[0],\n now, ((Date) val).getTime());\n }\n }", "void testDateSetMonth(java.util.Date date, boolean validate) {\n if (date instanceof java.sql.Time) { return; } // java.sql.Time throws IllegalArgumentException in setMonth().\n \n if (validate) {\n assertEqualDate(createDate(\"Apr 20, 2006\"), date);\n } else {\n synchronized (date) {\n date.setMonth(3);\n }\n }\n }", "public void setCreateDate(Date createDate)\r\n/* */ {\r\n/* 165 */ this.createDate = createDate;\r\n/* */ }", "public void testGetDate() {\r\n assertEquals(test1.getDate(), 20200818);\r\n }", "public void setDate(int date){\n this.date = date;\n }", "@Test\n public void testSetFechaPago() {\n System.out.println(\"setFechaPago\");\n Date fechaPago = null;\n DetalleAhorro instance = new DetalleAhorro();\n instance.setFechaPago(fechaPago);\n // TODO review the generated test code and remove the default call to fail.\n //fail(\"The test case is a prototype.\");\n }", "@Test\n\tpublic void t1_date_main() {\n\t\tDate in = Date.from(K_ZDT.toInstant());\n\t\t\n\t\t_TestEntityWithDate toDb = new _TestEntityWithDate();\n\t\ttoDb.setId(new Random().nextLong());\n\t\ttoDb.setUserEntered(in);\n\t\t\n\t\tmongo.save(toDb);\n\t\t\n\t\t_TestEntityWithDate fromDb = mongo.findById(toDb.getId(), _TestEntityWithDate.class);\n\t\tassertNotNull(fromDb);\n\t\t\n\t\tassertEquals(in, fromDb.getUserEntered());\n\t}", "public void setStartDate(Date s);", "public final void testNoDate() {\n testTransaction1.setDate(null);\n assertFalse(testTransaction1.isValidTransaction());\n }", "public void setDate(Date date) {\n\t\n\t\tthis.date = date;\n\t\n\t}", "void setBirthDate(Date birthDate);", "@Test\n\tpublic void testDate1() {\n\t\ttry {\n\t\t\tfinal Date date = ParadoxDate.getDateFromParadoxDate(0);\n\t\t\tfinal Calendar calendar = Calendar.getInstance();\n\t\t\tcalendar.setTime(date);\n\t\t\tAssert.assertTrue(calendar.get(Calendar.DATE) == 1);\n\t\t\tAssert.assertTrue(calendar.get(Calendar.MONTH) == 0);\n\t\t\tAssert.assertTrue(calendar.get(Calendar.YEAR) == 1900);\n\t\t} catch (final Exception e) {\n\t\t\te.printStackTrace();\n\t\t\tAssert.fail();\n\t\t}\n\t}", "public void setDate(Date date) {\r\n\t\tthis.date = date;\r\n\t}", "public void setDate(Date date) {\r\n\t\tthis.date = date;\r\n\t}", "public void setDate(Date date) {\r\n\t\tthis.date = date;\r\n\t}", "@Test\n public void testDateTimeType() throws Exception {\n if(util.isHiveCatalogStoreRunning()) return;\n\n ResultSet res = null;\n TajoClient client = util.newTajoClient();\n try {\n String tableName = \"datetimetable\";\n String query = \"select col1, col2, col3 from \" + tableName;\n\n String [] table = new String[] {tableName};\n Schema schema = new Schema();\n schema.addColumn(\"col1\", Type.DATE);\n schema.addColumn(\"col2\", Type.TIME);\n schema.addColumn(\"col3\", Type.TIMESTAMP);\n Schema [] schemas = new Schema[] {schema};\n String [] data = {\n \"2014-01-01|01:00:00|2014-01-01 01:00:00\"\n };\n KeyValueSet tableOptions = new KeyValueSet();\n tableOptions.set(StorageConstants.TEXT_DELIMITER, StorageConstants.DEFAULT_FIELD_DELIMITER);\n\n res = TajoTestingCluster\n .run(table, schemas, tableOptions, new String[][]{data}, query, client);\n\n assertTrue(res.next());\n\n Date date = res.getDate(1);\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n date = res.getDate(\"col1\");\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n Time time = res.getTime(2);\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n time = res.getTime(\"col2\");\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n Timestamp timestamp = res.getTimestamp(3);\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n timestamp = res.getTimestamp(\"col3\");\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n // assert with timezone\n Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(\"GMT+9\"));\n date = res.getDate(1, cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n date = res.getDate(\"col1\", cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n time = res.getTime(2, cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n time = res.getTime(\"col2\", cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n timestamp = res.getTimestamp(3, cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n\n timestamp = res.getTimestamp(\"col3\", cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n } finally {\n if (res != null) {\n res.close();\n }\n\n client.close();\n }\n }", "@Test\n public void testSetDateLine() {\n System.out.println(\"setDateLine\");\n String dateLine = \"01-01-1970\";\n Assignment instance = new Assignment(\"Research Languages\");\n instance.setDateLine(dateLine);\n // TODO review the generated test code and remove the default call to fail.\n }", "public void setDate(String date){\n this.date = date;\n }", "public void testIndexCostForDate() {\n final Date dateIndexing = new Date();\n this.classHandler.applyIndexesForDate(dateIndexing);\n }", "@Override\n\tpublic void visit(DateValue arg0) {\n\t\t\n\t}", "void setDate(int index, Date value, Calendar cal)\n throws SQLException;", "public void setDate(Date date) {\r\n \t\tthis.startDate = date;\r\n \t}", "@Override\n\tpublic void visit(DateValue arg0) {\n\n\t}", "public void setDate(String date){\n this.date = date;\n }", "@Override\n public void setDateHeader(String arg0, long arg1) {\n\n }", "@Test\n\tpublic void testSetFecha2(){\n\t\tPlataforma.logout();\n\t\tPlataforma.login(Plataforma.alumnos.get(0).getNia(), Plataforma.alumnos.get(0).getPassword());\n\t\tLocalDate fin = Plataforma.fechaActual.plusDays(10);\n\t\tLocalDate ini = Plataforma.fechaActual.plusDays(2);\n\t\tassertFalse(ej1.setFechaFin(fin));\n\t\tassertFalse(ej1.setFechaIni(ini));\n\t}", "@Test\n\tpublic void testSetStartDate() {\n\t\tassertNotEquals(calTest, initialJob.getStartDate());\n\t\tinitialJob.setStartDate(calTest.get(Calendar.YEAR), calTest.get(Calendar.MONTH), \n\t\t\t\tcalTest.get(Calendar.DATE), calTest.get(Calendar.HOUR), \n\t\t\t\tcalTest.get(Calendar.MINUTE));\n\t\tassertEquals(calTest, initialJob.getStartDate());\n\t\t\n\t\t// check different dates are not equivalent\n\t\tinitialJob.setStartDate(calTest.get(Calendar.YEAR) + 1, calTest.get(Calendar.MONTH), \n\t\t\t\tcalTest.get(Calendar.DATE), calTest.get(Calendar.HOUR), \n\t\t\t\tcalTest.get(Calendar.MINUTE));\n\t\tassertNotEquals(calTest, initialJob.getStartDate());\n\t}", "@Test\n public void testSetEndDate() {\n System.out.println(\"setEndDate\");\n Calendar newEnd = new GregorianCalendar(2000, 01, 01);\n String endDate = newEnd.toString();\n DTO_Ride instance = dtoRide;\n instance.setEndDate(endDate);\n \n String result = endDate.toString();\n assertEquals(newEnd, newEnd);\n }", "void setCreatedDate(Date createdDate);", "@Test\r\n public void testSetDataSprzedazy() {\r\n System.out.println(\"setDataSprzedazy\");\r\n Date dataSprzedazy = null;\r\n Faktura instance = new Faktura();\r\n instance.setDataSprzedazy(dataSprzedazy);\r\n // TODO review the generated test code and remove the default call to fail.\r\n fail(\"The test case is a prototype.\");\r\n }", "abstract public void setServiceAppointment(Date serviceAppointment);", "public void setDate(long date)\r\n/* 199: */ {\r\n/* 200:299 */ setDate(\"Date\", date);\r\n/* 201: */ }", "public IDataExporter<CRBBase> setInvoiceDate(LocalDate invoiceDate);", "public void setCreatedDate(Date createdDate);", "void setDateOfBirth(LocalDate dateOfBirth);", "protected void addStartDatePropertyDescriptor(Object object) {\n\t\titemPropertyDescriptors.add\n\t\t\t(createItemPropertyDescriptor\n\t\t\t\t(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),\n\t\t\t\t getResourceLocator(),\n\t\t\t\t getString(\"_UI_Cell_startDate_feature\"),\n\t\t\t\t getString(\"_UI_PropertyDescriptor_description\", \"_UI_Cell_startDate_feature\", \"_UI_Cell_type\"),\n\t\t\t\t LDEExperimentsPackage.Literals.CELL__START_DATE,\n\t\t\t\t true,\n\t\t\t\t false,\n\t\t\t\t false,\n\t\t\t\t ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,\n\t\t\t\t null,\n\t\t\t\t null));\n\t}", "public void setDate(java.util.Date param){\n \n this.localDate=param;\n \n\n }", "public void setDate(int dt) {\n date = dt;\n }", "public void setColumn(String column, java.util.Date d)\n {\n if (! hasColumn(column))\n throw new IllegalArgumentException(\"No such column \" + column);\n \n if (d == null)\n {\n setColumnNull(canonicalize(column));\n return;\n }\n \n \n data.put(canonicalize(column), d);\n }", "@Override\n\tpublic void setValue(T obj, Map<String,String> map, Method method) throws ExcelException{\n\t\ttry {\n\t\t\tString value=map.get(VALUE_NAME_KEY);\n\t\t\tif(value==null||value.trim().equals(\"\")) return;\n\t\t\tDate dt=null;\n\t\t\ttry\n\t\t\t{//非正规日期格式\n\t\t\t\tdt=HSSFDateUtil.getJavaDate(Double.parseDouble(value));\n\t\t\t}catch(Exception ex)\n\t\t\t{//正日期格式\n\t\t\t\tSimpleDateFormat sdf=new SimpleDateFormat(\"yyyy-MM-dd\");\n\t\t\t\tdt=sdf.parse(value);\n\t\t\t}\n\t\t\t\n\t\t\tmethod.invoke(obj, dt);\n\t\t} catch (Exception e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t\tthrow new ExcelException(e);\n\t\t}\n\t\t\n\t}", "public void setTodayDate() {\r\n int oldMonthValue = getMonth();\r\n int oldYearValue = getYear();\r\n calendarTable.getCalendarModel().setTodayDate();\r\n updateControlsFromTable();\r\n // fire property change\r\n int newMonthValue = getMonth();\r\n if (oldMonthValue != newMonthValue) {\r\n firePropertyChange(MONTH_PROPERTY, oldMonthValue, newMonthValue);\r\n }\r\n int newYearValue = getYear();\r\n if (oldYearValue != newYearValue) {\r\n firePropertyChange(YEAR_PROPERTY, oldYearValue, newYearValue);\r\n }\r\n // clear selection when changing the month in view\r\n if (oldMonthValue != newMonthValue && oldYearValue != newYearValue) {\r\n calendarTable.getSelectionModel().clearSelection();\r\n }\r\n }", "@Test\r\n public void testApplyChanges()\r\n {\r\n EasyMockSupport support = new EasyMockSupport();\r\n\r\n PreferencesRegistry registry = createPreferencesRegistry(support);\r\n CellSampler sampler = createSampler(support);\r\n ColumnDefinitionModel model = createModel();\r\n\r\n support.replayAll();\r\n\r\n @SuppressWarnings(\"unused\")\r\n ColumnDefinitionController controller = new ColumnDefinitionController(registry, model, sampler);\r\n\r\n ColumnDefinitionTableModel definitionTable = model.getDefinitionTableModel();\r\n\r\n CSVParseParameters parameters = model.getSelectedParameters();\r\n\r\n ColumnDefinitionRow timeRow = definitionTable.getRow(0);\r\n model.setSelectedDefinition(timeRow);\r\n timeRow.setFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\");\r\n\r\n SpecialColumn timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n ColumnDefinitionRow latRow = definitionTable.getRow(1);\r\n model.setSelectedDefinition(latRow);\r\n latRow.setDataType(null);\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n ColumnDefinitionRow lonRow = definitionTable.getRow(2);\r\n model.setSelectedDefinition(lonRow);\r\n lonRow.setColumnName(\"Longitude\");\r\n\r\n List<? extends String> columnNames = parameters.getColumnNames();\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n\r\n ColumnDefinitionRow name2 = definitionTable.getRow(4);\r\n model.setSelectedDefinition(name2);\r\n name2.setIsImport(true);\r\n\r\n columnNames = parameters.getColumnNames();\r\n assertEquals(ColumnHeaders.TIME.toString(), columnNames.get(0));\r\n assertEquals(ColumnHeaders.LAT.toString(), columnNames.get(1));\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n assertEquals(ColumnHeaders.NAME.toString(), columnNames.get(3));\r\n assertEquals(ColumnHeaders.NAME2.toString(), columnNames.get(4));\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n SpecialColumn lonColumn = parameters.getSpecialColumn(ColumnType.LON);\r\n assertEquals(2, lonColumn.getColumnIndex());\r\n assertEquals(\"Decimal\", lonColumn.getFormat());\r\n\r\n assertTrue(parameters.getColumnsToIgnore().isEmpty());\r\n\r\n support.verifyAll();\r\n }" ]
[ "0.72088534", "0.6945885", "0.67868644", "0.6761132", "0.6633157", "0.6559653", "0.6430262", "0.6417059", "0.64154106", "0.6349729", "0.6288675", "0.62766004", "0.6269622", "0.6206175", "0.6154703", "0.6129991", "0.60722893", "0.6039803", "0.6036126", "0.5954938", "0.5952103", "0.5931866", "0.5918047", "0.59161896", "0.59129477", "0.5905757", "0.58984107", "0.5890962", "0.5890962", "0.5890962", "0.5890962", "0.5890962", "0.5890962", "0.5890962", "0.5890962", "0.5890962", "0.58902144", "0.58729035", "0.58725876", "0.58725876", "0.58725876", "0.5857616", "0.58559823", "0.58442265", "0.5843333", "0.58237255", "0.58069026", "0.5802577", "0.580134", "0.57968414", "0.579306", "0.5792969", "0.57886064", "0.5788354", "0.57834494", "0.5768197", "0.5755201", "0.5753693", "0.5749685", "0.5742711", "0.57389635", "0.5734196", "0.57273567", "0.572436", "0.5717131", "0.57126373", "0.5710323", "0.57054216", "0.57031107", "0.5696703", "0.5692845", "0.5692845", "0.5692845", "0.568526", "0.5679266", "0.56775665", "0.56662554", "0.5665236", "0.5648523", "0.56390184", "0.56337845", "0.56301415", "0.56291586", "0.5626852", "0.56201345", "0.5618267", "0.5617776", "0.56157154", "0.56073546", "0.560425", "0.5602056", "0.55984026", "0.5590526", "0.5589864", "0.55881125", "0.5586526", "0.5585819", "0.55848", "0.5579406", "0.5568757" ]
0.63613486
9
Test the behavior setObject for time columns.
@Test public void testSetLocalTimeAndReadBack() throws SQLException { // TODO: fix for binary mode. // Avoid micros truncation in org.postgresql.jdbc.PgResultSet#internalGetObject assumeBinaryModeRegular(); LocalTime data = LocalTime.parse("16:21:51.123456"); insertWithoutType(data, "time_without_time_zone_column"); String readBack = readString("time_without_time_zone_column"); assertEquals("16:21:51.123456", readBack); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "void setTime(int index, Time value) throws SQLException;", "@Test\r\n public void testSetTimeEaten()\r\n {\r\n System.out.println(\"setTimeEaten\");\r\n Time timeEaten = Time.valueOf(\"12:34:56\");\r\n FoodBean instance = new FoodBean(5, \"Beans on toast\", \r\n Date.valueOf(\"2014-04-01\"), Time.valueOf(\"10:00:00\"), \r\n 100, 120, 5, 7, 500, 0, 3);\r\n instance.setTimeEaten(timeEaten);\r\n assertEquals(timeEaten, instance.getTimeEaten());\r\n }", "public void setTime(){\r\n \r\n }", "@Test\n public void test_column_type_detection_datetimes_03() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"13:15:00\", XSDDatatype.XSDtime), true, Types.TIME, Time.class.getCanonicalName());\n }", "@Test\n public void testSetLocalTimeWithType() throws SQLException {\n LocalTime data = LocalTime.parse(\"16:21:51\");\n Time actual = insertThenReadWithType(data, Types.TIME, \"time_without_time_zone_column\", Time.class);\n Time expected = Time.valueOf(\"16:21:51\");\n assertEquals(expected, actual);\n }", "@Test\r\n public void testApplyChanges()\r\n {\r\n EasyMockSupport support = new EasyMockSupport();\r\n\r\n PreferencesRegistry registry = createPreferencesRegistry(support);\r\n CellSampler sampler = createSampler(support);\r\n ColumnDefinitionModel model = createModel();\r\n\r\n support.replayAll();\r\n\r\n @SuppressWarnings(\"unused\")\r\n ColumnDefinitionController controller = new ColumnDefinitionController(registry, model, sampler);\r\n\r\n ColumnDefinitionTableModel definitionTable = model.getDefinitionTableModel();\r\n\r\n CSVParseParameters parameters = model.getSelectedParameters();\r\n\r\n ColumnDefinitionRow timeRow = definitionTable.getRow(0);\r\n model.setSelectedDefinition(timeRow);\r\n timeRow.setFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\");\r\n\r\n SpecialColumn timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n ColumnDefinitionRow latRow = definitionTable.getRow(1);\r\n model.setSelectedDefinition(latRow);\r\n latRow.setDataType(null);\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n ColumnDefinitionRow lonRow = definitionTable.getRow(2);\r\n model.setSelectedDefinition(lonRow);\r\n lonRow.setColumnName(\"Longitude\");\r\n\r\n List<? extends String> columnNames = parameters.getColumnNames();\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n\r\n ColumnDefinitionRow name2 = definitionTable.getRow(4);\r\n model.setSelectedDefinition(name2);\r\n name2.setIsImport(true);\r\n\r\n columnNames = parameters.getColumnNames();\r\n assertEquals(ColumnHeaders.TIME.toString(), columnNames.get(0));\r\n assertEquals(ColumnHeaders.LAT.toString(), columnNames.get(1));\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n assertEquals(ColumnHeaders.NAME.toString(), columnNames.get(3));\r\n assertEquals(ColumnHeaders.NAME2.toString(), columnNames.get(4));\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n SpecialColumn lonColumn = parameters.getSpecialColumn(ColumnType.LON);\r\n assertEquals(2, lonColumn.getColumnIndex());\r\n assertEquals(\"Decimal\", lonColumn.getFormat());\r\n\r\n assertTrue(parameters.getColumnsToIgnore().isEmpty());\r\n\r\n support.verifyAll();\r\n }", "@Test\n public void test_column_type_detection_datetimes_04() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"13:15:00.123\", XSDDatatype.XSDtime), true, Types.TIME, Time.class.getCanonicalName());\n }", "@Test\n public void testDateTimeType() throws Exception {\n if(util.isHiveCatalogStoreRunning()) return;\n\n ResultSet res = null;\n TajoClient client = util.newTajoClient();\n try {\n String tableName = \"datetimetable\";\n String query = \"select col1, col2, col3 from \" + tableName;\n\n String [] table = new String[] {tableName};\n Schema schema = new Schema();\n schema.addColumn(\"col1\", Type.DATE);\n schema.addColumn(\"col2\", Type.TIME);\n schema.addColumn(\"col3\", Type.TIMESTAMP);\n Schema [] schemas = new Schema[] {schema};\n String [] data = {\n \"2014-01-01|01:00:00|2014-01-01 01:00:00\"\n };\n KeyValueSet tableOptions = new KeyValueSet();\n tableOptions.set(StorageConstants.TEXT_DELIMITER, StorageConstants.DEFAULT_FIELD_DELIMITER);\n\n res = TajoTestingCluster\n .run(table, schemas, tableOptions, new String[][]{data}, query, client);\n\n assertTrue(res.next());\n\n Date date = res.getDate(1);\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n date = res.getDate(\"col1\");\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n Time time = res.getTime(2);\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n time = res.getTime(\"col2\");\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n Timestamp timestamp = res.getTimestamp(3);\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n timestamp = res.getTimestamp(\"col3\");\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n // assert with timezone\n Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(\"GMT+9\"));\n date = res.getDate(1, cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n date = res.getDate(\"col1\", cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n time = res.getTime(2, cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n time = res.getTime(\"col2\", cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n timestamp = res.getTimestamp(3, cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n\n timestamp = res.getTimestamp(\"col3\", cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n } finally {\n if (res != null) {\n res.close();\n }\n\n client.close();\n }\n }", "void setTime(int index, Time value, Calendar cal)\n throws SQLException;", "public void setTime(long time,int ento){ \r\n\t}", "public void setTime(Date time) {\r\n this.time = time;\r\n }", "public void setTime(Date time) {\r\n this.time = time;\r\n }", "public void setTime(Date time) {\r\n this.time = time;\r\n }", "@OfMethod({\"setTime(java.lang.String,java.sql.Time)\",\n \"setTime(java.lang.String,java.sql.Time,java.util.Calendar)\",\n \"setTime(int,java.sql.Time)\",\n \"setTime(int,java.sql.Time,java.util.Calendar)\"})\n public void testSetTime() throws Exception {\n CallableStatement instance = newClosedCall();\n\n try {\n instance.setTime(getParameterName(), Time.valueOf(\"04:48:01\"));\n fail(\"Allowed set time by parameter name after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTime(getParameterName(), Time.valueOf(\"04:48:01\"), Calendar.getInstance());\n fail(\"Allowed set time by parameter name and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTime(getParameterIndex(), Time.valueOf(\"04:48:01\"));\n fail(\"Allowed set time by parameter index after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTime(getParameterIndex(), Time.valueOf(\"04:48:01\"), Calendar.getInstance());\n fail(\"Allowed set date by parameter index and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n }", "public void setTime(String time) {\n }", "public void setTime(Time time) {\n this.time = time; // assigns the time argument value to the time attribute\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(double time) {_time = time;}", "public T caseTimeOfExpr(TimeOfExpr object) {\n\t\treturn null;\n\t}", "@Test\n public void testSetLocalTimeWithoutType() throws SQLException {\n LocalTime data = LocalTime.parse(\"16:21:51\");\n Time actual = insertThenReadWithoutType(data, \"time_without_time_zone_column\", Time.class);\n Time expected = Time.valueOf(\"16:21:51\");\n assertEquals(expected, actual);\n }", "@Test\r\n\tpublic void testSetTimeslot() {\r\n\t\tTimeslot t = new Timeslot(20, WEEKDAYS.MONDAY, \"09\", \"00\");\r\n\t\tbreaku1.setTimeslot(t);\r\n\t\texternu1.setTimeslot(t);\r\n\t\tmeetingu1.setTimeslot(t);\r\n\t\tteachu1.setTimeslot(t);\r\n\r\n\t\tassertEquals(t, breaku1.getTimeslot());\r\n\t\tassertEquals(t, externu1.getTimeslot());\r\n\t\tassertEquals(t, meetingu1.getTimeslot());\r\n\t\tassertEquals(t, teachu1.getTimeslot());\r\n\t}", "public void setTime( Date time ) {\n this.time = time;\n }", "@Override\n public void setBean(TimeSheet t)\n {\n \n }", "public T caseTimeExpr(TimeExpr object) {\n\t\treturn null;\n\t}", "@Test\r\n\tpublic void testSetPersonTime() {\r\n\t\tteachu1.setPersonTime(newPersonTime);\r\n\r\n\t\tassertTrue(teachu1.getPersons().contains(person2));\r\n\t\tassertFalse(teachu1.getPersons().contains(person1));\r\n\t}", "@Test\n public void testSetOffsetTimeWithType() throws SQLException {\n OffsetTime data = OffsetTime.parse(\"16:21:51+12:34\");\n insertThenReadWithType(data, Types.TIME, \"time_with_time_zone_column\", Time.class);\n }", "@Override\r\n\tpublic void setMyTime(MyTime myTime) {\n\t\t\r\n\t}", "private static boolean isTime(final Object obj) {\n return timeClass != null && timeClass.isAssignableFrom(obj.getClass());\n }", "public void setTimeBounds(TimeBounds timeBounds) throws java.beans.PropertyVetoException {\n\t\tif (!Matchable.areEqual(fieldTimeBounds,timeBounds) ) {\n\t\t\t// Only here to ensure it is being used correctly.\n\t\t\t// cbit.util.Assertion.assertNotNull(timeBounds);\n\t\t\tTimeBounds oldValue = fieldTimeBounds;\n\t\t\tfireVetoableChange(PROPERTY_TIME_BOUNDS, oldValue, timeBounds);\n\t\t\tfieldTimeBounds = timeBounds;\n\t\t\tfirePropertyChange(PROPERTY_TIME_BOUNDS, oldValue, timeBounds);\n\t\t}\n\t}", "public void setTime(Date time) {\r\n\t\tthis.time = time;\r\n\t}", "@Test\r\n public void testSetStartTime() {\r\n System.out.println(\"setStartTime\");\r\n String startTime = \"\";\r\n \r\n instance.setStartTime(startTime);\r\n assertEquals(startTime, instance.getStartTime());\r\n \r\n }", "public void setTime(Date time) {\n\t\tthis.time = time;\n\t}", "public void setARRIVAL_AT_LOC_TIME(java.sql.Time value)\n {\n if ((__ARRIVAL_AT_LOC_TIME == null) != (value == null) || (value != null && ! value.equals(__ARRIVAL_AT_LOC_TIME)))\n {\n _isDirty = true;\n }\n __ARRIVAL_AT_LOC_TIME = value;\n }", "public abstract void setStartTime(Date startTime);", "@Test\r\n public void testSetEndTime() {\r\n System.out.println(\"setEndTime\");\r\n String endTime = \"\";\r\n \r\n instance.setEndTime(endTime);\r\n assertEquals(endTime, instance.getEndTime());\r\n \r\n }", "public T caseTimeEventSpec(TimeEventSpec object) {\r\n\t\treturn null;\r\n\t}", "@Then(\"^I choose an interval time$\")\n public void i_choose_an_interval_time() {\n onViewWithId(R.id.startHour).type(\"12:00\");\n onViewWithId(R.id.endHour).type(\"23:59\");\n }", "@Test\n public void testSetOffsetTimeWithoutType() throws SQLException {\n OffsetTime data = OffsetTime.parse(\"16:21:51+12:34\");\n insertThenReadWithoutType(data, \"time_with_time_zone_column\", Time.class);\n }", "public void setTime(int hour, int minute, int second){\r\n this.hour = hour ; /*when it was hour,minutes,second it was a new variable for this function bt as we used this.It gained access to the global ones. */\r\n this.minute = minute; \r\n this.second = second;\r\n }", "public void setTime(long time)\n {\n this.time = time;\n\n }", "public void setTime(String time) {\n this.time = time;\n }", "@Override\n\tpublic void setStartTime(int t) {\n\t\t\n\t}", "public void setTime(Date time) {\n this.time = new Date(time.getTime());\n }", "public void setTime(){\n \tDatabaseManager.getDBM().setLockedTime(cal); \n }", "@Test\n public void test_column_type_detection_datetimes_01() throws SQLException {\n Model m = ModelFactory.createDefaultModel();\n testColumnTypeDetection(\"x\", m.createTypedLiteral(Calendar.getInstance()).asNode(), true, Types.TIMESTAMP, Timestamp.class.getCanonicalName());\n }", "void setTime(final int time);", "@Override\n\tpublic void setTime(String time) {\n\t\tthis.time = time;\n\t}", "@java.lang.Override\n public boolean hasTime() {\n return instance.hasTime();\n }", "public void setTime(int time)\n {\n this.time = time;\n start = time;\n end = time;\n }", "public void test_DATE_HHmmss_conditionBean() { // *Important!\r\n // ## Arrange ##\r\n Calendar cal = Calendar.getInstance();\r\n cal.set(2008, 5, 15, 12, 34, 56);\r\n cal.set(Calendar.MILLISECOND, 123);\r\n Member member = new Member();\r\n member.setMemberId(3);\r\n LocalDate targetDate = toLocalDate(cal);\r\n member.setBirthdate(targetDate);\r\n memberBhv.updateNonstrict(member);\r\n\r\n // ## Act ##\r\n cal.set(2008, 5, 15, 12, 34, 57); // plus one second\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because java.sql.Date is converted to java.util.Date in ConditionBean. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n cal.set(2008, 5, 15, 12, 34, 56); // just time\r\n cal.set(Calendar.MILLISECOND, 0); // Don't format!\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = DfTypeUtil.toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n }", "public void setTime(long time) {\n this.time = time;\n }", "public void setTimeUnit(TimeUnit timeUnit);", "public void setTime(String time) {\r\n\t\tthis.time = time;\r\n\t}", "public void setTime(long time) {\r\n this.time = time;\r\n }", "private void setTime(int hour, int minute){\n Calendar calendar = Calendar.getInstance();\n calendar.set(Calendar.HOUR_OF_DAY, hour);\n calendar.set(Calendar.MINUTE, minute);\n\n persistLong(calendar.getTimeInMillis());\n\n notifyChanged();\n notifyDependencyChange(shouldDisableDependents());\n }", "public final native void setTime(String time) /*-{\n this.setTime(time);\n }-*/;", "public void setTime(gov.ucore.ucore._2_0.TimeType time)\n {\n synchronized (monitor())\n {\n check_orphaned();\n gov.ucore.ucore._2_0.TimeType target = null;\n target = (gov.ucore.ucore._2_0.TimeType)get_store().find_element_user(TIME$2, 0);\n if (target == null)\n {\n target = (gov.ucore.ucore._2_0.TimeType)get_store().add_element_user(TIME$2);\n }\n target.set(time);\n }\n }", "public void setTestTime(Integer testTime) {\n this.testTime = testTime;\n }", "@JsonSetter(\"time\")\r\n public void setTime(String time) {\r\n this.time = time;\r\n }", "public void setTime(DateTime inputTime){\n time = inputTime.getMillis();\n timeZone = inputTime.getZone();\n }", "public void setAtTime(Date atTime) {\r\n this.atTime = atTime;\r\n }", "public void setTime(AbsoluteDate date)\r\n {\r\n CoreModel coreModel = CoreModel.getDefault();\r\n coreModel.changeTimepoint(getUnderlyingElement(), date, true);\r\n }", "private void populateMinMaxTime()\n {\n final ColumnHolder columnHolder = index.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME);\n try (final NumericColumn column = (NumericColumn) columnHolder.getColumn()) {\n this.minTime = DateTimes.utc(column.getLongSingleValueRow(0));\n this.maxTime = DateTimes.utc(column.getLongSingleValueRow(column.length() - 1));\n }\n }", "public void testCmdUpdate_time_field() {\n\t\t// Initialize test variables\n\t\tCommandAction expectedCA;\n\t\tTask expectedTask;\n\t\tList<Task> expectedTaskList;\n\n\t\t/*\n\t\t * Test 3: Testing time field (all ID are valid)\n\t\t */\n\t\tctf.initialize();\n\t\texpectedTaskList = null;\n\t\taddNewTask(TASK_NAME_1);\n\n\t\t// Test 3a: start time and end time are both null\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, null, null, null);\n\t\texpectedCA = new CommandAction(MSG_TASKNOUPDATE, false, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\n\t\t// Test 3b: valid start time without end time\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, VALID_START_TIME + \"\", null, null);\n\t\texpectedCA = new CommandAction(MSG_INVALIDTIME, false, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\n\t\t// Test 3c: start time after end time\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, INVALID_START_TIME + \"\", VALID_END_TIME + \"\", null);\n\t\texpectedCA = new CommandAction(MSG_INVALIDTIME, false, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\n\t\texpectedTaskList = new ArrayList<Task>();\n\t\t// Test 3d: start time before end time\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, VALID_START_TIME + \"\", VALID_END_TIME + \"\", null);\n\t\texpectedTask = ctf.createExpectedTask(TASK_NAME_1, VALID_START_TIME, VALID_END_TIME, PRIORITY_TYPE.NORMAL);\n\t\texpectedTaskList.add(expectedTask);\n\t\texpectedCA = new CommandAction(String.format(MSG_TASKUPDATED, VALID_TASKID), true, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\t}", "public void setCreateTime(Date createTime)\n/* */ {\n/* 184 */ this.createTime = createTime;\n/* */ }", "public void setTime(java.lang.Integer value) {\n this.time = value;\n }", "@DSSafe(DSCat.UTIL_FUNCTION)\n \n @DSGenerator(tool_name = \"Doppelganger\", tool_version = \"2.0\", generated_on = \"2013-12-30 12:56:11.275 -0500\", hash_original_method = \"58DD96CFC8DDA00016DEC24CC6519017\", hash_generated_method = \"1F810C618BA62488684578EB05C3C6A1\")\n \n@Override\n public void setTime(long theTime) {\n /*\n * Store the Date based on the supplied time after removing any time\n * elements finer than the day based on zero GMT\n */\n super.setTime(normalizeTime(theTime));\n }", "public void updateTime(String columnName, Time x) throws SQLException {\n\n try {\n if (isDebugEnabled()) {\n debugCode(\"updateTime(\" + quote(columnName) + \", x);\");\n }\n update(columnName, x == null ? (Value) ValueNull.INSTANCE : ValueTime.get(x));\n }\n catch (Exception e) {\n throw logAndConvert(e);\n }\n }", "public void setTime(double minutes) {\n\t\t// implement this method.\n\n\t}", "public void setTime(int t){\r\n\t\t\t\ttime = t;\r\n\t\t\t}", "public boolean isTime() {\n return false;\n }", "@Test\n @Override\n public void testTime(TestContext ctx) {\n testDecodeGeneric(ctx, \"test_time\", Duration.class, Duration.ofHours(18).plusMinutes(45).plusSeconds(2));\n }", "@Test\r\n\tpublic void testGetTimeslot() {\r\n\t\tassertEquals(time1, breaku1.getTimeslot());\r\n\t\tassertEquals(time1, externu1.getTimeslot());\r\n\t\tassertEquals(time1, meetingu1.getTimeslot());\r\n\t\tassertEquals(time1, teachu1.getTimeslot());\r\n\t}", "public void setWorldTime(long time)\n {\n worldTime = time;\n }", "public void setTime(String time) {\n\t\tthis.time = time;\n\t}", "@Test\r\n public void testLoadExisting()\r\n {\r\n EasyMockSupport support = new EasyMockSupport();\r\n\r\n PreferencesRegistry registry = createPreferencesRegistry(support);\r\n CellSampler sampler = createSampler(support);\r\n ColumnDefinitionModel model = createModel();\r\n\r\n // Add a bad special column.\r\n SpecialColumn specialColumn = new SpecialColumn();\r\n specialColumn.setColumnIndex(3);\r\n model.getSelectedParameters().getSpecialColumns().add(specialColumn);\r\n\r\n support.replayAll();\r\n\r\n @SuppressWarnings(\"unused\")\r\n ColumnDefinitionController controller = new ColumnDefinitionController(registry, model, sampler);\r\n\r\n assertFalse(model.getAvailableDataTypes().isEmpty());\r\n assertFalse(model.getAvailableFormats().isEmpty());\r\n assertFalse(model.getBeforeAfterTableModel().getRowCount() == 0);\r\n\r\n ColumnDefinitionTableModel definitionTable = model.getDefinitionTableModel();\r\n assertEquals(5, definitionTable.getRowCount());\r\n\r\n ColumnDefinitionRow timeRow = definitionTable.getRow(0);\r\n assertTrue(timeRow.isImport());\r\n assertEquals(0, timeRow.getColumnId());\r\n assertEquals(ColumnHeaders.TIME.toString(), timeRow.getColumnName());\r\n assertEquals(ColumnType.TIMESTAMP.toString(), timeRow.getDataType());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss'Z'\", timeRow.getFormat());\r\n\r\n ColumnDefinitionRow latRow = definitionTable.getRow(1);\r\n assertTrue(latRow.isImport());\r\n assertEquals(1, latRow.getColumnId());\r\n assertEquals(ColumnHeaders.LAT.toString(), latRow.getColumnName());\r\n assertEquals(ColumnType.LAT.toString(), latRow.getDataType());\r\n assertEquals(\"Decimal\", latRow.getFormat());\r\n\r\n ColumnDefinitionRow lonRow = definitionTable.getRow(2);\r\n assertTrue(lonRow.isImport());\r\n assertEquals(2, lonRow.getColumnId());\r\n assertEquals(ColumnHeaders.LON.toString(), lonRow.getColumnName());\r\n assertEquals(ColumnType.LON.toString(), lonRow.getDataType());\r\n assertEquals(\"Decimal\", lonRow.getFormat());\r\n\r\n ColumnDefinitionRow nameRow = definitionTable.getRow(3);\r\n assertTrue(nameRow.isImport());\r\n assertEquals(3, nameRow.getColumnId());\r\n assertEquals(ColumnHeaders.NAME.toString(), nameRow.getColumnName());\r\n assertNull(nameRow.getDataType());\r\n assertNull(nameRow.getFormat());\r\n\r\n ColumnDefinitionRow name2Row = definitionTable.getRow(4);\r\n assertTrue(name2Row.isImport());\r\n assertEquals(4, name2Row.getColumnId());\r\n assertEquals(ColumnHeaders.NAME2.toString(), name2Row.getColumnName());\r\n assertNull(name2Row.getDataType());\r\n assertNull(name2Row.getFormat());\r\n\r\n support.verifyAll();\r\n }", "private void setTime(Instant time) {\n this.time = time;\n }", "public void setTime(long time) {\r\n\t\tthis.time = time;\r\n\t}", "public void setTime(Long time) {\n this.time = time;\n }", "@Test\n public void testSetHoldingTime() throws Exception {\n isisNeighbor.setHoldingTime(1);\n result = isisNeighbor.holdingTime();\n assertThat(result, is(1));\n }", "@Test\r\n public void testGetTimeEaten()\r\n {\r\n System.out.println(\"getTimeEaten\");\r\n FoodBean instance = new FoodBean(5, \"Beans on toast\", \r\n Date.valueOf(\"2014-04-01\"), Time.valueOf(\"10:00:00\"), \r\n 100, 120, 5, 7, 500, 0, 3);\r\n Time expResult = Time.valueOf(\"10:00:00\");\r\n Time result = instance.getTimeEaten();\r\n assertEquals(expResult, result);\r\n }", "public void setTime(int time) {\n\t\tthis.time = time;\n\t}", "@Override\n\tpublic void setTime(long time)\n\t{\n\t\tsource.setTime(time);\n\t}", "public void setaTime(Date aTime) {\r\n this.aTime = aTime;\r\n }", "private void setEditedTime(int value) {\n \n editedTime_ = value;\n }", "public abstract void setEndTime(Date endTime);", "public void setTimeRange(Range range) {\r\n\t\ttimeRange = new Range(range);\r\n\t}", "native void nativeSetMetricsTime(boolean is_enable);", "public void testGetAllTimeEntries() throws Exception {\r\n assertEquals(\"The time_entry table should be empty.\", 0, instance.getAllTimeEntries().length);\r\n }", "public void setBeginTime(String time){beginTime = time;}", "@Test //ExSkip\n public void fieldTime() throws Exception {\n Document doc = new Document();\n DocumentBuilder builder = new DocumentBuilder(doc);\n\n // By default, time is displayed in the \"h:mm am/pm\" format.\n FieldTime field = insertFieldTime(builder, \"\");\n\n Assert.assertEquals(\" TIME \", field.getFieldCode());\n\n // We can use the \\@ flag to change the format of our displayed time.\n field = insertFieldTime(builder, \"\\\\@ HHmm\");\n\n Assert.assertEquals(\" TIME \\\\@ HHmm\", field.getFieldCode());\n\n // We can adjust the format to get TIME field to also display the date, according to the Gregorian calendar.\n field = insertFieldTime(builder, \"\\\\@ \\\"M/d/yyyy h mm:ss am/pm\\\"\");\n Assert.assertEquals(field.getFieldCode(), \" TIME \\\\@ \\\"M/d/yyyy h mm:ss am/pm\\\"\");\n\n doc.save(getArtifactsDir() + \"Field.TIME.docx\");\n testFieldTime(new Document(getArtifactsDir() + \"Field.TIME.docx\")); //ExSkip\n }", "public void setEndTime(String time){endTime = time;}", "@Test\n public void addTimeTest() {\n // TODO: test addTime\n }", "public void setCreatedTime(LocalDateTime value) {\n set(5, value);\n }", "public boolean isTimeSet() {\n return timeSet;\n }", "public static void setTime(){\n\t\tCalendar cal = Calendar.getInstance();\n\t\tif (!JsonUtils.RUNNING_LOCALLY){\n\t\t\tcal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 4); //account for UTC offset because of lambda\n\t\t}\n\t\tCURRENT_TIME = formatTime(cal.getTime().toString());\n\t}", "private MadisRecord setTimeObs(String obsDate, String obsTime,\n MadisRecord rec, String[] headerType) {\n\n if ((obsDate != null) && (obsTime != null)) {\n\n StringBuilder sb = new StringBuilder();\n sb.append(obsDate);\n sb.append(\" \");\n sb.append(obsTime);\n sb.append(\":01\");\n\n try {\n Date time = getDateFormatter().get().parse(sb.toString());\n Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(\"GMT\"));\n cal.setTime(time);\n rec.setTimeObs(cal);\n\n } catch (ParseException e) {\n statusHandler.handle(Priority.PROBLEM,\n \"Can't parse Madis date format!\", e);\n }\n }\n\n return rec;\n }" ]
[ "0.63997006", "0.63304937", "0.63219506", "0.6208006", "0.61979187", "0.6197244", "0.611223", "0.6092948", "0.6028525", "0.60253805", "0.6024769", "0.6024769", "0.6024769", "0.6023629", "0.600772", "0.6007432", "0.59931487", "0.59931487", "0.59931487", "0.59931487", "0.5950016", "0.59358776", "0.5935379", "0.5932247", "0.59088755", "0.5905547", "0.589087", "0.5879993", "0.58501863", "0.5840125", "0.5835748", "0.58330137", "0.5804564", "0.5748742", "0.5713875", "0.5710501", "0.5695689", "0.56724674", "0.5652233", "0.5638819", "0.562789", "0.5593804", "0.5580585", "0.55641234", "0.5543596", "0.553814", "0.55288744", "0.5518666", "0.5515064", "0.5512414", "0.5505135", "0.55039024", "0.54805994", "0.54680765", "0.5465179", "0.54539716", "0.54510343", "0.54446495", "0.5442719", "0.5431859", "0.5425976", "0.54259384", "0.54131234", "0.54090303", "0.54073346", "0.54073006", "0.5399621", "0.5394863", "0.5393281", "0.5383162", "0.53715533", "0.5366737", "0.53589696", "0.5358898", "0.5352614", "0.53434765", "0.5333833", "0.53326964", "0.5326602", "0.53231263", "0.5317116", "0.5314203", "0.531391", "0.53069925", "0.5304485", "0.5298842", "0.5296674", "0.52816284", "0.5279291", "0.5270999", "0.52685046", "0.52676636", "0.52668846", "0.5263604", "0.5259605", "0.5250867", "0.52476686", "0.52473885", "0.5246356", "0.52441657" ]
0.5337438
76
Test the behavior setObject for time columns.
@Test public void testSetLocalTimeWithType() throws SQLException { LocalTime data = LocalTime.parse("16:21:51"); Time actual = insertThenReadWithType(data, Types.TIME, "time_without_time_zone_column", Time.class); Time expected = Time.valueOf("16:21:51"); assertEquals(expected, actual); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "void setTime(int index, Time value) throws SQLException;", "@Test\r\n public void testSetTimeEaten()\r\n {\r\n System.out.println(\"setTimeEaten\");\r\n Time timeEaten = Time.valueOf(\"12:34:56\");\r\n FoodBean instance = new FoodBean(5, \"Beans on toast\", \r\n Date.valueOf(\"2014-04-01\"), Time.valueOf(\"10:00:00\"), \r\n 100, 120, 5, 7, 500, 0, 3);\r\n instance.setTimeEaten(timeEaten);\r\n assertEquals(timeEaten, instance.getTimeEaten());\r\n }", "public void setTime(){\r\n \r\n }", "@Test\n public void test_column_type_detection_datetimes_03() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"13:15:00\", XSDDatatype.XSDtime), true, Types.TIME, Time.class.getCanonicalName());\n }", "@Test\r\n public void testApplyChanges()\r\n {\r\n EasyMockSupport support = new EasyMockSupport();\r\n\r\n PreferencesRegistry registry = createPreferencesRegistry(support);\r\n CellSampler sampler = createSampler(support);\r\n ColumnDefinitionModel model = createModel();\r\n\r\n support.replayAll();\r\n\r\n @SuppressWarnings(\"unused\")\r\n ColumnDefinitionController controller = new ColumnDefinitionController(registry, model, sampler);\r\n\r\n ColumnDefinitionTableModel definitionTable = model.getDefinitionTableModel();\r\n\r\n CSVParseParameters parameters = model.getSelectedParameters();\r\n\r\n ColumnDefinitionRow timeRow = definitionTable.getRow(0);\r\n model.setSelectedDefinition(timeRow);\r\n timeRow.setFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\");\r\n\r\n SpecialColumn timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n ColumnDefinitionRow latRow = definitionTable.getRow(1);\r\n model.setSelectedDefinition(latRow);\r\n latRow.setDataType(null);\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n ColumnDefinitionRow lonRow = definitionTable.getRow(2);\r\n model.setSelectedDefinition(lonRow);\r\n lonRow.setColumnName(\"Longitude\");\r\n\r\n List<? extends String> columnNames = parameters.getColumnNames();\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n\r\n ColumnDefinitionRow name2 = definitionTable.getRow(4);\r\n model.setSelectedDefinition(name2);\r\n name2.setIsImport(true);\r\n\r\n columnNames = parameters.getColumnNames();\r\n assertEquals(ColumnHeaders.TIME.toString(), columnNames.get(0));\r\n assertEquals(ColumnHeaders.LAT.toString(), columnNames.get(1));\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n assertEquals(ColumnHeaders.NAME.toString(), columnNames.get(3));\r\n assertEquals(ColumnHeaders.NAME2.toString(), columnNames.get(4));\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n SpecialColumn lonColumn = parameters.getSpecialColumn(ColumnType.LON);\r\n assertEquals(2, lonColumn.getColumnIndex());\r\n assertEquals(\"Decimal\", lonColumn.getFormat());\r\n\r\n assertTrue(parameters.getColumnsToIgnore().isEmpty());\r\n\r\n support.verifyAll();\r\n }", "@Test\n public void test_column_type_detection_datetimes_04() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"13:15:00.123\", XSDDatatype.XSDtime), true, Types.TIME, Time.class.getCanonicalName());\n }", "@Test\n public void testDateTimeType() throws Exception {\n if(util.isHiveCatalogStoreRunning()) return;\n\n ResultSet res = null;\n TajoClient client = util.newTajoClient();\n try {\n String tableName = \"datetimetable\";\n String query = \"select col1, col2, col3 from \" + tableName;\n\n String [] table = new String[] {tableName};\n Schema schema = new Schema();\n schema.addColumn(\"col1\", Type.DATE);\n schema.addColumn(\"col2\", Type.TIME);\n schema.addColumn(\"col3\", Type.TIMESTAMP);\n Schema [] schemas = new Schema[] {schema};\n String [] data = {\n \"2014-01-01|01:00:00|2014-01-01 01:00:00\"\n };\n KeyValueSet tableOptions = new KeyValueSet();\n tableOptions.set(StorageConstants.TEXT_DELIMITER, StorageConstants.DEFAULT_FIELD_DELIMITER);\n\n res = TajoTestingCluster\n .run(table, schemas, tableOptions, new String[][]{data}, query, client);\n\n assertTrue(res.next());\n\n Date date = res.getDate(1);\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n date = res.getDate(\"col1\");\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n Time time = res.getTime(2);\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n time = res.getTime(\"col2\");\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n Timestamp timestamp = res.getTimestamp(3);\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n timestamp = res.getTimestamp(\"col3\");\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n // assert with timezone\n Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(\"GMT+9\"));\n date = res.getDate(1, cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n date = res.getDate(\"col1\", cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n time = res.getTime(2, cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n time = res.getTime(\"col2\", cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n timestamp = res.getTimestamp(3, cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n\n timestamp = res.getTimestamp(\"col3\", cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n } finally {\n if (res != null) {\n res.close();\n }\n\n client.close();\n }\n }", "void setTime(int index, Time value, Calendar cal)\n throws SQLException;", "public void setTime(long time,int ento){ \r\n\t}", "public void setTime(Date time) {\r\n this.time = time;\r\n }", "public void setTime(Date time) {\r\n this.time = time;\r\n }", "public void setTime(Date time) {\r\n this.time = time;\r\n }", "@OfMethod({\"setTime(java.lang.String,java.sql.Time)\",\n \"setTime(java.lang.String,java.sql.Time,java.util.Calendar)\",\n \"setTime(int,java.sql.Time)\",\n \"setTime(int,java.sql.Time,java.util.Calendar)\"})\n public void testSetTime() throws Exception {\n CallableStatement instance = newClosedCall();\n\n try {\n instance.setTime(getParameterName(), Time.valueOf(\"04:48:01\"));\n fail(\"Allowed set time by parameter name after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTime(getParameterName(), Time.valueOf(\"04:48:01\"), Calendar.getInstance());\n fail(\"Allowed set time by parameter name and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTime(getParameterIndex(), Time.valueOf(\"04:48:01\"));\n fail(\"Allowed set time by parameter index after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTime(getParameterIndex(), Time.valueOf(\"04:48:01\"), Calendar.getInstance());\n fail(\"Allowed set date by parameter index and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n }", "public void setTime(String time) {\n }", "public void setTime(Time time) {\n this.time = time; // assigns the time argument value to the time attribute\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(double time) {_time = time;}", "public T caseTimeOfExpr(TimeOfExpr object) {\n\t\treturn null;\n\t}", "@Test\n public void testSetLocalTimeWithoutType() throws SQLException {\n LocalTime data = LocalTime.parse(\"16:21:51\");\n Time actual = insertThenReadWithoutType(data, \"time_without_time_zone_column\", Time.class);\n Time expected = Time.valueOf(\"16:21:51\");\n assertEquals(expected, actual);\n }", "@Test\r\n\tpublic void testSetTimeslot() {\r\n\t\tTimeslot t = new Timeslot(20, WEEKDAYS.MONDAY, \"09\", \"00\");\r\n\t\tbreaku1.setTimeslot(t);\r\n\t\texternu1.setTimeslot(t);\r\n\t\tmeetingu1.setTimeslot(t);\r\n\t\tteachu1.setTimeslot(t);\r\n\r\n\t\tassertEquals(t, breaku1.getTimeslot());\r\n\t\tassertEquals(t, externu1.getTimeslot());\r\n\t\tassertEquals(t, meetingu1.getTimeslot());\r\n\t\tassertEquals(t, teachu1.getTimeslot());\r\n\t}", "public void setTime( Date time ) {\n this.time = time;\n }", "@Override\n public void setBean(TimeSheet t)\n {\n \n }", "public T caseTimeExpr(TimeExpr object) {\n\t\treturn null;\n\t}", "@Test\r\n\tpublic void testSetPersonTime() {\r\n\t\tteachu1.setPersonTime(newPersonTime);\r\n\r\n\t\tassertTrue(teachu1.getPersons().contains(person2));\r\n\t\tassertFalse(teachu1.getPersons().contains(person1));\r\n\t}", "@Test\n public void testSetOffsetTimeWithType() throws SQLException {\n OffsetTime data = OffsetTime.parse(\"16:21:51+12:34\");\n insertThenReadWithType(data, Types.TIME, \"time_with_time_zone_column\", Time.class);\n }", "@Override\r\n\tpublic void setMyTime(MyTime myTime) {\n\t\t\r\n\t}", "private static boolean isTime(final Object obj) {\n return timeClass != null && timeClass.isAssignableFrom(obj.getClass());\n }", "public void setTimeBounds(TimeBounds timeBounds) throws java.beans.PropertyVetoException {\n\t\tif (!Matchable.areEqual(fieldTimeBounds,timeBounds) ) {\n\t\t\t// Only here to ensure it is being used correctly.\n\t\t\t// cbit.util.Assertion.assertNotNull(timeBounds);\n\t\t\tTimeBounds oldValue = fieldTimeBounds;\n\t\t\tfireVetoableChange(PROPERTY_TIME_BOUNDS, oldValue, timeBounds);\n\t\t\tfieldTimeBounds = timeBounds;\n\t\t\tfirePropertyChange(PROPERTY_TIME_BOUNDS, oldValue, timeBounds);\n\t\t}\n\t}", "public void setTime(Date time) {\r\n\t\tthis.time = time;\r\n\t}", "@Test\r\n public void testSetStartTime() {\r\n System.out.println(\"setStartTime\");\r\n String startTime = \"\";\r\n \r\n instance.setStartTime(startTime);\r\n assertEquals(startTime, instance.getStartTime());\r\n \r\n }", "public void setTime(Date time) {\n\t\tthis.time = time;\n\t}", "public void setARRIVAL_AT_LOC_TIME(java.sql.Time value)\n {\n if ((__ARRIVAL_AT_LOC_TIME == null) != (value == null) || (value != null && ! value.equals(__ARRIVAL_AT_LOC_TIME)))\n {\n _isDirty = true;\n }\n __ARRIVAL_AT_LOC_TIME = value;\n }", "public abstract void setStartTime(Date startTime);", "@Test\r\n public void testSetEndTime() {\r\n System.out.println(\"setEndTime\");\r\n String endTime = \"\";\r\n \r\n instance.setEndTime(endTime);\r\n assertEquals(endTime, instance.getEndTime());\r\n \r\n }", "public T caseTimeEventSpec(TimeEventSpec object) {\r\n\t\treturn null;\r\n\t}", "@Then(\"^I choose an interval time$\")\n public void i_choose_an_interval_time() {\n onViewWithId(R.id.startHour).type(\"12:00\");\n onViewWithId(R.id.endHour).type(\"23:59\");\n }", "@Test\n public void testSetOffsetTimeWithoutType() throws SQLException {\n OffsetTime data = OffsetTime.parse(\"16:21:51+12:34\");\n insertThenReadWithoutType(data, \"time_with_time_zone_column\", Time.class);\n }", "public void setTime(int hour, int minute, int second){\r\n this.hour = hour ; /*when it was hour,minutes,second it was a new variable for this function bt as we used this.It gained access to the global ones. */\r\n this.minute = minute; \r\n this.second = second;\r\n }", "public void setTime(long time)\n {\n this.time = time;\n\n }", "public void setTime(String time) {\n this.time = time;\n }", "@Override\n\tpublic void setStartTime(int t) {\n\t\t\n\t}", "public void setTime(Date time) {\n this.time = new Date(time.getTime());\n }", "public void setTime(){\n \tDatabaseManager.getDBM().setLockedTime(cal); \n }", "@Test\n public void test_column_type_detection_datetimes_01() throws SQLException {\n Model m = ModelFactory.createDefaultModel();\n testColumnTypeDetection(\"x\", m.createTypedLiteral(Calendar.getInstance()).asNode(), true, Types.TIMESTAMP, Timestamp.class.getCanonicalName());\n }", "void setTime(final int time);", "@Override\n\tpublic void setTime(String time) {\n\t\tthis.time = time;\n\t}", "@java.lang.Override\n public boolean hasTime() {\n return instance.hasTime();\n }", "public void setTime(int time)\n {\n this.time = time;\n start = time;\n end = time;\n }", "public void test_DATE_HHmmss_conditionBean() { // *Important!\r\n // ## Arrange ##\r\n Calendar cal = Calendar.getInstance();\r\n cal.set(2008, 5, 15, 12, 34, 56);\r\n cal.set(Calendar.MILLISECOND, 123);\r\n Member member = new Member();\r\n member.setMemberId(3);\r\n LocalDate targetDate = toLocalDate(cal);\r\n member.setBirthdate(targetDate);\r\n memberBhv.updateNonstrict(member);\r\n\r\n // ## Act ##\r\n cal.set(2008, 5, 15, 12, 34, 57); // plus one second\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because java.sql.Date is converted to java.util.Date in ConditionBean. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n cal.set(2008, 5, 15, 12, 34, 56); // just time\r\n cal.set(Calendar.MILLISECOND, 0); // Don't format!\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = DfTypeUtil.toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n }", "public void setTime(long time) {\n this.time = time;\n }", "public void setTimeUnit(TimeUnit timeUnit);", "public void setTime(String time) {\r\n\t\tthis.time = time;\r\n\t}", "public void setTime(long time) {\r\n this.time = time;\r\n }", "private void setTime(int hour, int minute){\n Calendar calendar = Calendar.getInstance();\n calendar.set(Calendar.HOUR_OF_DAY, hour);\n calendar.set(Calendar.MINUTE, minute);\n\n persistLong(calendar.getTimeInMillis());\n\n notifyChanged();\n notifyDependencyChange(shouldDisableDependents());\n }", "public final native void setTime(String time) /*-{\n this.setTime(time);\n }-*/;", "public void setTime(gov.ucore.ucore._2_0.TimeType time)\n {\n synchronized (monitor())\n {\n check_orphaned();\n gov.ucore.ucore._2_0.TimeType target = null;\n target = (gov.ucore.ucore._2_0.TimeType)get_store().find_element_user(TIME$2, 0);\n if (target == null)\n {\n target = (gov.ucore.ucore._2_0.TimeType)get_store().add_element_user(TIME$2);\n }\n target.set(time);\n }\n }", "public void setTestTime(Integer testTime) {\n this.testTime = testTime;\n }", "@JsonSetter(\"time\")\r\n public void setTime(String time) {\r\n this.time = time;\r\n }", "public void setTime(DateTime inputTime){\n time = inputTime.getMillis();\n timeZone = inputTime.getZone();\n }", "public void setAtTime(Date atTime) {\r\n this.atTime = atTime;\r\n }", "public void setTime(AbsoluteDate date)\r\n {\r\n CoreModel coreModel = CoreModel.getDefault();\r\n coreModel.changeTimepoint(getUnderlyingElement(), date, true);\r\n }", "private void populateMinMaxTime()\n {\n final ColumnHolder columnHolder = index.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME);\n try (final NumericColumn column = (NumericColumn) columnHolder.getColumn()) {\n this.minTime = DateTimes.utc(column.getLongSingleValueRow(0));\n this.maxTime = DateTimes.utc(column.getLongSingleValueRow(column.length() - 1));\n }\n }", "public void testCmdUpdate_time_field() {\n\t\t// Initialize test variables\n\t\tCommandAction expectedCA;\n\t\tTask expectedTask;\n\t\tList<Task> expectedTaskList;\n\n\t\t/*\n\t\t * Test 3: Testing time field (all ID are valid)\n\t\t */\n\t\tctf.initialize();\n\t\texpectedTaskList = null;\n\t\taddNewTask(TASK_NAME_1);\n\n\t\t// Test 3a: start time and end time are both null\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, null, null, null);\n\t\texpectedCA = new CommandAction(MSG_TASKNOUPDATE, false, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\n\t\t// Test 3b: valid start time without end time\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, VALID_START_TIME + \"\", null, null);\n\t\texpectedCA = new CommandAction(MSG_INVALIDTIME, false, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\n\t\t// Test 3c: start time after end time\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, INVALID_START_TIME + \"\", VALID_END_TIME + \"\", null);\n\t\texpectedCA = new CommandAction(MSG_INVALIDTIME, false, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\n\t\texpectedTaskList = new ArrayList<Task>();\n\t\t// Test 3d: start time before end time\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, VALID_START_TIME + \"\", VALID_END_TIME + \"\", null);\n\t\texpectedTask = ctf.createExpectedTask(TASK_NAME_1, VALID_START_TIME, VALID_END_TIME, PRIORITY_TYPE.NORMAL);\n\t\texpectedTaskList.add(expectedTask);\n\t\texpectedCA = new CommandAction(String.format(MSG_TASKUPDATED, VALID_TASKID), true, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\t}", "public void setCreateTime(Date createTime)\n/* */ {\n/* 184 */ this.createTime = createTime;\n/* */ }", "public void setTime(java.lang.Integer value) {\n this.time = value;\n }", "@DSSafe(DSCat.UTIL_FUNCTION)\n \n @DSGenerator(tool_name = \"Doppelganger\", tool_version = \"2.0\", generated_on = \"2013-12-30 12:56:11.275 -0500\", hash_original_method = \"58DD96CFC8DDA00016DEC24CC6519017\", hash_generated_method = \"1F810C618BA62488684578EB05C3C6A1\")\n \n@Override\n public void setTime(long theTime) {\n /*\n * Store the Date based on the supplied time after removing any time\n * elements finer than the day based on zero GMT\n */\n super.setTime(normalizeTime(theTime));\n }", "public void updateTime(String columnName, Time x) throws SQLException {\n\n try {\n if (isDebugEnabled()) {\n debugCode(\"updateTime(\" + quote(columnName) + \", x);\");\n }\n update(columnName, x == null ? (Value) ValueNull.INSTANCE : ValueTime.get(x));\n }\n catch (Exception e) {\n throw logAndConvert(e);\n }\n }", "public void setTime(double minutes) {\n\t\t// implement this method.\n\n\t}", "public void setTime(int t){\r\n\t\t\t\ttime = t;\r\n\t\t\t}", "public boolean isTime() {\n return false;\n }", "@Test\n @Override\n public void testTime(TestContext ctx) {\n testDecodeGeneric(ctx, \"test_time\", Duration.class, Duration.ofHours(18).plusMinutes(45).plusSeconds(2));\n }", "@Test\r\n\tpublic void testGetTimeslot() {\r\n\t\tassertEquals(time1, breaku1.getTimeslot());\r\n\t\tassertEquals(time1, externu1.getTimeslot());\r\n\t\tassertEquals(time1, meetingu1.getTimeslot());\r\n\t\tassertEquals(time1, teachu1.getTimeslot());\r\n\t}", "@Test\n public void testSetLocalTimeAndReadBack() throws SQLException {\n // TODO: fix for binary mode.\n // Avoid micros truncation in org.postgresql.jdbc.PgResultSet#internalGetObject\n assumeBinaryModeRegular();\n LocalTime data = LocalTime.parse(\"16:21:51.123456\");\n\n insertWithoutType(data, \"time_without_time_zone_column\");\n\n String readBack = readString(\"time_without_time_zone_column\");\n assertEquals(\"16:21:51.123456\", readBack);\n }", "public void setWorldTime(long time)\n {\n worldTime = time;\n }", "public void setTime(String time) {\n\t\tthis.time = time;\n\t}", "@Test\r\n public void testLoadExisting()\r\n {\r\n EasyMockSupport support = new EasyMockSupport();\r\n\r\n PreferencesRegistry registry = createPreferencesRegistry(support);\r\n CellSampler sampler = createSampler(support);\r\n ColumnDefinitionModel model = createModel();\r\n\r\n // Add a bad special column.\r\n SpecialColumn specialColumn = new SpecialColumn();\r\n specialColumn.setColumnIndex(3);\r\n model.getSelectedParameters().getSpecialColumns().add(specialColumn);\r\n\r\n support.replayAll();\r\n\r\n @SuppressWarnings(\"unused\")\r\n ColumnDefinitionController controller = new ColumnDefinitionController(registry, model, sampler);\r\n\r\n assertFalse(model.getAvailableDataTypes().isEmpty());\r\n assertFalse(model.getAvailableFormats().isEmpty());\r\n assertFalse(model.getBeforeAfterTableModel().getRowCount() == 0);\r\n\r\n ColumnDefinitionTableModel definitionTable = model.getDefinitionTableModel();\r\n assertEquals(5, definitionTable.getRowCount());\r\n\r\n ColumnDefinitionRow timeRow = definitionTable.getRow(0);\r\n assertTrue(timeRow.isImport());\r\n assertEquals(0, timeRow.getColumnId());\r\n assertEquals(ColumnHeaders.TIME.toString(), timeRow.getColumnName());\r\n assertEquals(ColumnType.TIMESTAMP.toString(), timeRow.getDataType());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss'Z'\", timeRow.getFormat());\r\n\r\n ColumnDefinitionRow latRow = definitionTable.getRow(1);\r\n assertTrue(latRow.isImport());\r\n assertEquals(1, latRow.getColumnId());\r\n assertEquals(ColumnHeaders.LAT.toString(), latRow.getColumnName());\r\n assertEquals(ColumnType.LAT.toString(), latRow.getDataType());\r\n assertEquals(\"Decimal\", latRow.getFormat());\r\n\r\n ColumnDefinitionRow lonRow = definitionTable.getRow(2);\r\n assertTrue(lonRow.isImport());\r\n assertEquals(2, lonRow.getColumnId());\r\n assertEquals(ColumnHeaders.LON.toString(), lonRow.getColumnName());\r\n assertEquals(ColumnType.LON.toString(), lonRow.getDataType());\r\n assertEquals(\"Decimal\", lonRow.getFormat());\r\n\r\n ColumnDefinitionRow nameRow = definitionTable.getRow(3);\r\n assertTrue(nameRow.isImport());\r\n assertEquals(3, nameRow.getColumnId());\r\n assertEquals(ColumnHeaders.NAME.toString(), nameRow.getColumnName());\r\n assertNull(nameRow.getDataType());\r\n assertNull(nameRow.getFormat());\r\n\r\n ColumnDefinitionRow name2Row = definitionTable.getRow(4);\r\n assertTrue(name2Row.isImport());\r\n assertEquals(4, name2Row.getColumnId());\r\n assertEquals(ColumnHeaders.NAME2.toString(), name2Row.getColumnName());\r\n assertNull(name2Row.getDataType());\r\n assertNull(name2Row.getFormat());\r\n\r\n support.verifyAll();\r\n }", "private void setTime(Instant time) {\n this.time = time;\n }", "public void setTime(long time) {\r\n\t\tthis.time = time;\r\n\t}", "public void setTime(Long time) {\n this.time = time;\n }", "@Test\n public void testSetHoldingTime() throws Exception {\n isisNeighbor.setHoldingTime(1);\n result = isisNeighbor.holdingTime();\n assertThat(result, is(1));\n }", "@Test\r\n public void testGetTimeEaten()\r\n {\r\n System.out.println(\"getTimeEaten\");\r\n FoodBean instance = new FoodBean(5, \"Beans on toast\", \r\n Date.valueOf(\"2014-04-01\"), Time.valueOf(\"10:00:00\"), \r\n 100, 120, 5, 7, 500, 0, 3);\r\n Time expResult = Time.valueOf(\"10:00:00\");\r\n Time result = instance.getTimeEaten();\r\n assertEquals(expResult, result);\r\n }", "public void setTime(int time) {\n\t\tthis.time = time;\n\t}", "@Override\n\tpublic void setTime(long time)\n\t{\n\t\tsource.setTime(time);\n\t}", "public void setaTime(Date aTime) {\r\n this.aTime = aTime;\r\n }", "private void setEditedTime(int value) {\n \n editedTime_ = value;\n }", "public abstract void setEndTime(Date endTime);", "public void setTimeRange(Range range) {\r\n\t\ttimeRange = new Range(range);\r\n\t}", "native void nativeSetMetricsTime(boolean is_enable);", "public void testGetAllTimeEntries() throws Exception {\r\n assertEquals(\"The time_entry table should be empty.\", 0, instance.getAllTimeEntries().length);\r\n }", "public void setBeginTime(String time){beginTime = time;}", "@Test //ExSkip\n public void fieldTime() throws Exception {\n Document doc = new Document();\n DocumentBuilder builder = new DocumentBuilder(doc);\n\n // By default, time is displayed in the \"h:mm am/pm\" format.\n FieldTime field = insertFieldTime(builder, \"\");\n\n Assert.assertEquals(\" TIME \", field.getFieldCode());\n\n // We can use the \\@ flag to change the format of our displayed time.\n field = insertFieldTime(builder, \"\\\\@ HHmm\");\n\n Assert.assertEquals(\" TIME \\\\@ HHmm\", field.getFieldCode());\n\n // We can adjust the format to get TIME field to also display the date, according to the Gregorian calendar.\n field = insertFieldTime(builder, \"\\\\@ \\\"M/d/yyyy h mm:ss am/pm\\\"\");\n Assert.assertEquals(field.getFieldCode(), \" TIME \\\\@ \\\"M/d/yyyy h mm:ss am/pm\\\"\");\n\n doc.save(getArtifactsDir() + \"Field.TIME.docx\");\n testFieldTime(new Document(getArtifactsDir() + \"Field.TIME.docx\")); //ExSkip\n }", "public void setEndTime(String time){endTime = time;}", "@Test\n public void addTimeTest() {\n // TODO: test addTime\n }", "public void setCreatedTime(LocalDateTime value) {\n set(5, value);\n }", "public boolean isTimeSet() {\n return timeSet;\n }", "public static void setTime(){\n\t\tCalendar cal = Calendar.getInstance();\n\t\tif (!JsonUtils.RUNNING_LOCALLY){\n\t\t\tcal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 4); //account for UTC offset because of lambda\n\t\t}\n\t\tCURRENT_TIME = formatTime(cal.getTime().toString());\n\t}", "private MadisRecord setTimeObs(String obsDate, String obsTime,\n MadisRecord rec, String[] headerType) {\n\n if ((obsDate != null) && (obsTime != null)) {\n\n StringBuilder sb = new StringBuilder();\n sb.append(obsDate);\n sb.append(\" \");\n sb.append(obsTime);\n sb.append(\":01\");\n\n try {\n Date time = getDateFormatter().get().parse(sb.toString());\n Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(\"GMT\"));\n cal.setTime(time);\n rec.setTimeObs(cal);\n\n } catch (ParseException e) {\n statusHandler.handle(Priority.PROBLEM,\n \"Can't parse Madis date format!\", e);\n }\n }\n\n return rec;\n }" ]
[ "0.63997006", "0.63304937", "0.63219506", "0.6208006", "0.6197244", "0.611223", "0.6092948", "0.6028525", "0.60253805", "0.6024769", "0.6024769", "0.6024769", "0.6023629", "0.600772", "0.6007432", "0.59931487", "0.59931487", "0.59931487", "0.59931487", "0.5950016", "0.59358776", "0.5935379", "0.5932247", "0.59088755", "0.5905547", "0.589087", "0.5879993", "0.58501863", "0.5840125", "0.5835748", "0.58330137", "0.5804564", "0.5748742", "0.5713875", "0.5710501", "0.5695689", "0.56724674", "0.5652233", "0.5638819", "0.562789", "0.5593804", "0.5580585", "0.55641234", "0.5543596", "0.553814", "0.55288744", "0.5518666", "0.5515064", "0.5512414", "0.5505135", "0.55039024", "0.54805994", "0.54680765", "0.5465179", "0.54539716", "0.54510343", "0.54446495", "0.5442719", "0.5431859", "0.5425976", "0.54259384", "0.54131234", "0.54090303", "0.54073346", "0.54073006", "0.5399621", "0.5394863", "0.5393281", "0.5383162", "0.53715533", "0.5366737", "0.53589696", "0.5358898", "0.5352614", "0.53434765", "0.5337438", "0.5333833", "0.53326964", "0.5326602", "0.53231263", "0.5317116", "0.5314203", "0.531391", "0.53069925", "0.5304485", "0.5298842", "0.5296674", "0.52816284", "0.5279291", "0.5270999", "0.52685046", "0.52676636", "0.52668846", "0.5263604", "0.5259605", "0.5250867", "0.52476686", "0.52473885", "0.5246356", "0.52441657" ]
0.61979187
4
Test the behavior setObject for time columns.
@Test public void testSetLocalTimeWithoutType() throws SQLException { LocalTime data = LocalTime.parse("16:21:51"); Time actual = insertThenReadWithoutType(data, "time_without_time_zone_column", Time.class); Time expected = Time.valueOf("16:21:51"); assertEquals(expected, actual); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "void setTime(int index, Time value) throws SQLException;", "@Test\r\n public void testSetTimeEaten()\r\n {\r\n System.out.println(\"setTimeEaten\");\r\n Time timeEaten = Time.valueOf(\"12:34:56\");\r\n FoodBean instance = new FoodBean(5, \"Beans on toast\", \r\n Date.valueOf(\"2014-04-01\"), Time.valueOf(\"10:00:00\"), \r\n 100, 120, 5, 7, 500, 0, 3);\r\n instance.setTimeEaten(timeEaten);\r\n assertEquals(timeEaten, instance.getTimeEaten());\r\n }", "public void setTime(){\r\n \r\n }", "@Test\n public void test_column_type_detection_datetimes_03() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"13:15:00\", XSDDatatype.XSDtime), true, Types.TIME, Time.class.getCanonicalName());\n }", "@Test\n public void testSetLocalTimeWithType() throws SQLException {\n LocalTime data = LocalTime.parse(\"16:21:51\");\n Time actual = insertThenReadWithType(data, Types.TIME, \"time_without_time_zone_column\", Time.class);\n Time expected = Time.valueOf(\"16:21:51\");\n assertEquals(expected, actual);\n }", "@Test\r\n public void testApplyChanges()\r\n {\r\n EasyMockSupport support = new EasyMockSupport();\r\n\r\n PreferencesRegistry registry = createPreferencesRegistry(support);\r\n CellSampler sampler = createSampler(support);\r\n ColumnDefinitionModel model = createModel();\r\n\r\n support.replayAll();\r\n\r\n @SuppressWarnings(\"unused\")\r\n ColumnDefinitionController controller = new ColumnDefinitionController(registry, model, sampler);\r\n\r\n ColumnDefinitionTableModel definitionTable = model.getDefinitionTableModel();\r\n\r\n CSVParseParameters parameters = model.getSelectedParameters();\r\n\r\n ColumnDefinitionRow timeRow = definitionTable.getRow(0);\r\n model.setSelectedDefinition(timeRow);\r\n timeRow.setFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\");\r\n\r\n SpecialColumn timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n ColumnDefinitionRow latRow = definitionTable.getRow(1);\r\n model.setSelectedDefinition(latRow);\r\n latRow.setDataType(null);\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n ColumnDefinitionRow lonRow = definitionTable.getRow(2);\r\n model.setSelectedDefinition(lonRow);\r\n lonRow.setColumnName(\"Longitude\");\r\n\r\n List<? extends String> columnNames = parameters.getColumnNames();\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n\r\n ColumnDefinitionRow name2 = definitionTable.getRow(4);\r\n model.setSelectedDefinition(name2);\r\n name2.setIsImport(true);\r\n\r\n columnNames = parameters.getColumnNames();\r\n assertEquals(ColumnHeaders.TIME.toString(), columnNames.get(0));\r\n assertEquals(ColumnHeaders.LAT.toString(), columnNames.get(1));\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n assertEquals(ColumnHeaders.NAME.toString(), columnNames.get(3));\r\n assertEquals(ColumnHeaders.NAME2.toString(), columnNames.get(4));\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n SpecialColumn lonColumn = parameters.getSpecialColumn(ColumnType.LON);\r\n assertEquals(2, lonColumn.getColumnIndex());\r\n assertEquals(\"Decimal\", lonColumn.getFormat());\r\n\r\n assertTrue(parameters.getColumnsToIgnore().isEmpty());\r\n\r\n support.verifyAll();\r\n }", "@Test\n public void test_column_type_detection_datetimes_04() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"13:15:00.123\", XSDDatatype.XSDtime), true, Types.TIME, Time.class.getCanonicalName());\n }", "@Test\n public void testDateTimeType() throws Exception {\n if(util.isHiveCatalogStoreRunning()) return;\n\n ResultSet res = null;\n TajoClient client = util.newTajoClient();\n try {\n String tableName = \"datetimetable\";\n String query = \"select col1, col2, col3 from \" + tableName;\n\n String [] table = new String[] {tableName};\n Schema schema = new Schema();\n schema.addColumn(\"col1\", Type.DATE);\n schema.addColumn(\"col2\", Type.TIME);\n schema.addColumn(\"col3\", Type.TIMESTAMP);\n Schema [] schemas = new Schema[] {schema};\n String [] data = {\n \"2014-01-01|01:00:00|2014-01-01 01:00:00\"\n };\n KeyValueSet tableOptions = new KeyValueSet();\n tableOptions.set(StorageConstants.TEXT_DELIMITER, StorageConstants.DEFAULT_FIELD_DELIMITER);\n\n res = TajoTestingCluster\n .run(table, schemas, tableOptions, new String[][]{data}, query, client);\n\n assertTrue(res.next());\n\n Date date = res.getDate(1);\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n date = res.getDate(\"col1\");\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n Time time = res.getTime(2);\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n time = res.getTime(\"col2\");\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n Timestamp timestamp = res.getTimestamp(3);\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n timestamp = res.getTimestamp(\"col3\");\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n // assert with timezone\n Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(\"GMT+9\"));\n date = res.getDate(1, cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n date = res.getDate(\"col1\", cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n time = res.getTime(2, cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n time = res.getTime(\"col2\", cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n timestamp = res.getTimestamp(3, cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n\n timestamp = res.getTimestamp(\"col3\", cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n } finally {\n if (res != null) {\n res.close();\n }\n\n client.close();\n }\n }", "void setTime(int index, Time value, Calendar cal)\n throws SQLException;", "public void setTime(long time,int ento){ \r\n\t}", "public void setTime(Date time) {\r\n this.time = time;\r\n }", "public void setTime(Date time) {\r\n this.time = time;\r\n }", "public void setTime(Date time) {\r\n this.time = time;\r\n }", "@OfMethod({\"setTime(java.lang.String,java.sql.Time)\",\n \"setTime(java.lang.String,java.sql.Time,java.util.Calendar)\",\n \"setTime(int,java.sql.Time)\",\n \"setTime(int,java.sql.Time,java.util.Calendar)\"})\n public void testSetTime() throws Exception {\n CallableStatement instance = newClosedCall();\n\n try {\n instance.setTime(getParameterName(), Time.valueOf(\"04:48:01\"));\n fail(\"Allowed set time by parameter name after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTime(getParameterName(), Time.valueOf(\"04:48:01\"), Calendar.getInstance());\n fail(\"Allowed set time by parameter name and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTime(getParameterIndex(), Time.valueOf(\"04:48:01\"));\n fail(\"Allowed set time by parameter index after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTime(getParameterIndex(), Time.valueOf(\"04:48:01\"), Calendar.getInstance());\n fail(\"Allowed set date by parameter index and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n }", "public void setTime(String time) {\n }", "public void setTime(Time time) {\n this.time = time; // assigns the time argument value to the time attribute\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(double time) {_time = time;}", "public T caseTimeOfExpr(TimeOfExpr object) {\n\t\treturn null;\n\t}", "@Test\r\n\tpublic void testSetTimeslot() {\r\n\t\tTimeslot t = new Timeslot(20, WEEKDAYS.MONDAY, \"09\", \"00\");\r\n\t\tbreaku1.setTimeslot(t);\r\n\t\texternu1.setTimeslot(t);\r\n\t\tmeetingu1.setTimeslot(t);\r\n\t\tteachu1.setTimeslot(t);\r\n\r\n\t\tassertEquals(t, breaku1.getTimeslot());\r\n\t\tassertEquals(t, externu1.getTimeslot());\r\n\t\tassertEquals(t, meetingu1.getTimeslot());\r\n\t\tassertEquals(t, teachu1.getTimeslot());\r\n\t}", "public void setTime( Date time ) {\n this.time = time;\n }", "@Override\n public void setBean(TimeSheet t)\n {\n \n }", "public T caseTimeExpr(TimeExpr object) {\n\t\treturn null;\n\t}", "@Test\r\n\tpublic void testSetPersonTime() {\r\n\t\tteachu1.setPersonTime(newPersonTime);\r\n\r\n\t\tassertTrue(teachu1.getPersons().contains(person2));\r\n\t\tassertFalse(teachu1.getPersons().contains(person1));\r\n\t}", "@Test\n public void testSetOffsetTimeWithType() throws SQLException {\n OffsetTime data = OffsetTime.parse(\"16:21:51+12:34\");\n insertThenReadWithType(data, Types.TIME, \"time_with_time_zone_column\", Time.class);\n }", "@Override\r\n\tpublic void setMyTime(MyTime myTime) {\n\t\t\r\n\t}", "private static boolean isTime(final Object obj) {\n return timeClass != null && timeClass.isAssignableFrom(obj.getClass());\n }", "public void setTimeBounds(TimeBounds timeBounds) throws java.beans.PropertyVetoException {\n\t\tif (!Matchable.areEqual(fieldTimeBounds,timeBounds) ) {\n\t\t\t// Only here to ensure it is being used correctly.\n\t\t\t// cbit.util.Assertion.assertNotNull(timeBounds);\n\t\t\tTimeBounds oldValue = fieldTimeBounds;\n\t\t\tfireVetoableChange(PROPERTY_TIME_BOUNDS, oldValue, timeBounds);\n\t\t\tfieldTimeBounds = timeBounds;\n\t\t\tfirePropertyChange(PROPERTY_TIME_BOUNDS, oldValue, timeBounds);\n\t\t}\n\t}", "public void setTime(Date time) {\r\n\t\tthis.time = time;\r\n\t}", "@Test\r\n public void testSetStartTime() {\r\n System.out.println(\"setStartTime\");\r\n String startTime = \"\";\r\n \r\n instance.setStartTime(startTime);\r\n assertEquals(startTime, instance.getStartTime());\r\n \r\n }", "public void setTime(Date time) {\n\t\tthis.time = time;\n\t}", "public void setARRIVAL_AT_LOC_TIME(java.sql.Time value)\n {\n if ((__ARRIVAL_AT_LOC_TIME == null) != (value == null) || (value != null && ! value.equals(__ARRIVAL_AT_LOC_TIME)))\n {\n _isDirty = true;\n }\n __ARRIVAL_AT_LOC_TIME = value;\n }", "public abstract void setStartTime(Date startTime);", "@Test\r\n public void testSetEndTime() {\r\n System.out.println(\"setEndTime\");\r\n String endTime = \"\";\r\n \r\n instance.setEndTime(endTime);\r\n assertEquals(endTime, instance.getEndTime());\r\n \r\n }", "public T caseTimeEventSpec(TimeEventSpec object) {\r\n\t\treturn null;\r\n\t}", "@Then(\"^I choose an interval time$\")\n public void i_choose_an_interval_time() {\n onViewWithId(R.id.startHour).type(\"12:00\");\n onViewWithId(R.id.endHour).type(\"23:59\");\n }", "@Test\n public void testSetOffsetTimeWithoutType() throws SQLException {\n OffsetTime data = OffsetTime.parse(\"16:21:51+12:34\");\n insertThenReadWithoutType(data, \"time_with_time_zone_column\", Time.class);\n }", "public void setTime(int hour, int minute, int second){\r\n this.hour = hour ; /*when it was hour,minutes,second it was a new variable for this function bt as we used this.It gained access to the global ones. */\r\n this.minute = minute; \r\n this.second = second;\r\n }", "public void setTime(long time)\n {\n this.time = time;\n\n }", "public void setTime(String time) {\n this.time = time;\n }", "@Override\n\tpublic void setStartTime(int t) {\n\t\t\n\t}", "public void setTime(Date time) {\n this.time = new Date(time.getTime());\n }", "public void setTime(){\n \tDatabaseManager.getDBM().setLockedTime(cal); \n }", "@Test\n public void test_column_type_detection_datetimes_01() throws SQLException {\n Model m = ModelFactory.createDefaultModel();\n testColumnTypeDetection(\"x\", m.createTypedLiteral(Calendar.getInstance()).asNode(), true, Types.TIMESTAMP, Timestamp.class.getCanonicalName());\n }", "void setTime(final int time);", "@Override\n\tpublic void setTime(String time) {\n\t\tthis.time = time;\n\t}", "@java.lang.Override\n public boolean hasTime() {\n return instance.hasTime();\n }", "public void setTime(int time)\n {\n this.time = time;\n start = time;\n end = time;\n }", "public void test_DATE_HHmmss_conditionBean() { // *Important!\r\n // ## Arrange ##\r\n Calendar cal = Calendar.getInstance();\r\n cal.set(2008, 5, 15, 12, 34, 56);\r\n cal.set(Calendar.MILLISECOND, 123);\r\n Member member = new Member();\r\n member.setMemberId(3);\r\n LocalDate targetDate = toLocalDate(cal);\r\n member.setBirthdate(targetDate);\r\n memberBhv.updateNonstrict(member);\r\n\r\n // ## Act ##\r\n cal.set(2008, 5, 15, 12, 34, 57); // plus one second\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because java.sql.Date is converted to java.util.Date in ConditionBean. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n cal.set(2008, 5, 15, 12, 34, 56); // just time\r\n cal.set(Calendar.MILLISECOND, 0); // Don't format!\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = DfTypeUtil.toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n }", "public void setTime(long time) {\n this.time = time;\n }", "public void setTimeUnit(TimeUnit timeUnit);", "public void setTime(String time) {\r\n\t\tthis.time = time;\r\n\t}", "public void setTime(long time) {\r\n this.time = time;\r\n }", "private void setTime(int hour, int minute){\n Calendar calendar = Calendar.getInstance();\n calendar.set(Calendar.HOUR_OF_DAY, hour);\n calendar.set(Calendar.MINUTE, minute);\n\n persistLong(calendar.getTimeInMillis());\n\n notifyChanged();\n notifyDependencyChange(shouldDisableDependents());\n }", "public final native void setTime(String time) /*-{\n this.setTime(time);\n }-*/;", "public void setTime(gov.ucore.ucore._2_0.TimeType time)\n {\n synchronized (monitor())\n {\n check_orphaned();\n gov.ucore.ucore._2_0.TimeType target = null;\n target = (gov.ucore.ucore._2_0.TimeType)get_store().find_element_user(TIME$2, 0);\n if (target == null)\n {\n target = (gov.ucore.ucore._2_0.TimeType)get_store().add_element_user(TIME$2);\n }\n target.set(time);\n }\n }", "public void setTestTime(Integer testTime) {\n this.testTime = testTime;\n }", "@JsonSetter(\"time\")\r\n public void setTime(String time) {\r\n this.time = time;\r\n }", "public void setTime(DateTime inputTime){\n time = inputTime.getMillis();\n timeZone = inputTime.getZone();\n }", "public void setAtTime(Date atTime) {\r\n this.atTime = atTime;\r\n }", "public void setTime(AbsoluteDate date)\r\n {\r\n CoreModel coreModel = CoreModel.getDefault();\r\n coreModel.changeTimepoint(getUnderlyingElement(), date, true);\r\n }", "private void populateMinMaxTime()\n {\n final ColumnHolder columnHolder = index.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME);\n try (final NumericColumn column = (NumericColumn) columnHolder.getColumn()) {\n this.minTime = DateTimes.utc(column.getLongSingleValueRow(0));\n this.maxTime = DateTimes.utc(column.getLongSingleValueRow(column.length() - 1));\n }\n }", "public void testCmdUpdate_time_field() {\n\t\t// Initialize test variables\n\t\tCommandAction expectedCA;\n\t\tTask expectedTask;\n\t\tList<Task> expectedTaskList;\n\n\t\t/*\n\t\t * Test 3: Testing time field (all ID are valid)\n\t\t */\n\t\tctf.initialize();\n\t\texpectedTaskList = null;\n\t\taddNewTask(TASK_NAME_1);\n\n\t\t// Test 3a: start time and end time are both null\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, null, null, null);\n\t\texpectedCA = new CommandAction(MSG_TASKNOUPDATE, false, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\n\t\t// Test 3b: valid start time without end time\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, VALID_START_TIME + \"\", null, null);\n\t\texpectedCA = new CommandAction(MSG_INVALIDTIME, false, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\n\t\t// Test 3c: start time after end time\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, INVALID_START_TIME + \"\", VALID_END_TIME + \"\", null);\n\t\texpectedCA = new CommandAction(MSG_INVALIDTIME, false, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\n\t\texpectedTaskList = new ArrayList<Task>();\n\t\t// Test 3d: start time before end time\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, VALID_START_TIME + \"\", VALID_END_TIME + \"\", null);\n\t\texpectedTask = ctf.createExpectedTask(TASK_NAME_1, VALID_START_TIME, VALID_END_TIME, PRIORITY_TYPE.NORMAL);\n\t\texpectedTaskList.add(expectedTask);\n\t\texpectedCA = new CommandAction(String.format(MSG_TASKUPDATED, VALID_TASKID), true, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\t}", "public void setCreateTime(Date createTime)\n/* */ {\n/* 184 */ this.createTime = createTime;\n/* */ }", "public void setTime(java.lang.Integer value) {\n this.time = value;\n }", "@DSSafe(DSCat.UTIL_FUNCTION)\n \n @DSGenerator(tool_name = \"Doppelganger\", tool_version = \"2.0\", generated_on = \"2013-12-30 12:56:11.275 -0500\", hash_original_method = \"58DD96CFC8DDA00016DEC24CC6519017\", hash_generated_method = \"1F810C618BA62488684578EB05C3C6A1\")\n \n@Override\n public void setTime(long theTime) {\n /*\n * Store the Date based on the supplied time after removing any time\n * elements finer than the day based on zero GMT\n */\n super.setTime(normalizeTime(theTime));\n }", "public void updateTime(String columnName, Time x) throws SQLException {\n\n try {\n if (isDebugEnabled()) {\n debugCode(\"updateTime(\" + quote(columnName) + \", x);\");\n }\n update(columnName, x == null ? (Value) ValueNull.INSTANCE : ValueTime.get(x));\n }\n catch (Exception e) {\n throw logAndConvert(e);\n }\n }", "public void setTime(double minutes) {\n\t\t// implement this method.\n\n\t}", "public void setTime(int t){\r\n\t\t\t\ttime = t;\r\n\t\t\t}", "public boolean isTime() {\n return false;\n }", "@Test\n @Override\n public void testTime(TestContext ctx) {\n testDecodeGeneric(ctx, \"test_time\", Duration.class, Duration.ofHours(18).plusMinutes(45).plusSeconds(2));\n }", "@Test\r\n\tpublic void testGetTimeslot() {\r\n\t\tassertEquals(time1, breaku1.getTimeslot());\r\n\t\tassertEquals(time1, externu1.getTimeslot());\r\n\t\tassertEquals(time1, meetingu1.getTimeslot());\r\n\t\tassertEquals(time1, teachu1.getTimeslot());\r\n\t}", "@Test\n public void testSetLocalTimeAndReadBack() throws SQLException {\n // TODO: fix for binary mode.\n // Avoid micros truncation in org.postgresql.jdbc.PgResultSet#internalGetObject\n assumeBinaryModeRegular();\n LocalTime data = LocalTime.parse(\"16:21:51.123456\");\n\n insertWithoutType(data, \"time_without_time_zone_column\");\n\n String readBack = readString(\"time_without_time_zone_column\");\n assertEquals(\"16:21:51.123456\", readBack);\n }", "public void setWorldTime(long time)\n {\n worldTime = time;\n }", "public void setTime(String time) {\n\t\tthis.time = time;\n\t}", "@Test\r\n public void testLoadExisting()\r\n {\r\n EasyMockSupport support = new EasyMockSupport();\r\n\r\n PreferencesRegistry registry = createPreferencesRegistry(support);\r\n CellSampler sampler = createSampler(support);\r\n ColumnDefinitionModel model = createModel();\r\n\r\n // Add a bad special column.\r\n SpecialColumn specialColumn = new SpecialColumn();\r\n specialColumn.setColumnIndex(3);\r\n model.getSelectedParameters().getSpecialColumns().add(specialColumn);\r\n\r\n support.replayAll();\r\n\r\n @SuppressWarnings(\"unused\")\r\n ColumnDefinitionController controller = new ColumnDefinitionController(registry, model, sampler);\r\n\r\n assertFalse(model.getAvailableDataTypes().isEmpty());\r\n assertFalse(model.getAvailableFormats().isEmpty());\r\n assertFalse(model.getBeforeAfterTableModel().getRowCount() == 0);\r\n\r\n ColumnDefinitionTableModel definitionTable = model.getDefinitionTableModel();\r\n assertEquals(5, definitionTable.getRowCount());\r\n\r\n ColumnDefinitionRow timeRow = definitionTable.getRow(0);\r\n assertTrue(timeRow.isImport());\r\n assertEquals(0, timeRow.getColumnId());\r\n assertEquals(ColumnHeaders.TIME.toString(), timeRow.getColumnName());\r\n assertEquals(ColumnType.TIMESTAMP.toString(), timeRow.getDataType());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss'Z'\", timeRow.getFormat());\r\n\r\n ColumnDefinitionRow latRow = definitionTable.getRow(1);\r\n assertTrue(latRow.isImport());\r\n assertEquals(1, latRow.getColumnId());\r\n assertEquals(ColumnHeaders.LAT.toString(), latRow.getColumnName());\r\n assertEquals(ColumnType.LAT.toString(), latRow.getDataType());\r\n assertEquals(\"Decimal\", latRow.getFormat());\r\n\r\n ColumnDefinitionRow lonRow = definitionTable.getRow(2);\r\n assertTrue(lonRow.isImport());\r\n assertEquals(2, lonRow.getColumnId());\r\n assertEquals(ColumnHeaders.LON.toString(), lonRow.getColumnName());\r\n assertEquals(ColumnType.LON.toString(), lonRow.getDataType());\r\n assertEquals(\"Decimal\", lonRow.getFormat());\r\n\r\n ColumnDefinitionRow nameRow = definitionTable.getRow(3);\r\n assertTrue(nameRow.isImport());\r\n assertEquals(3, nameRow.getColumnId());\r\n assertEquals(ColumnHeaders.NAME.toString(), nameRow.getColumnName());\r\n assertNull(nameRow.getDataType());\r\n assertNull(nameRow.getFormat());\r\n\r\n ColumnDefinitionRow name2Row = definitionTable.getRow(4);\r\n assertTrue(name2Row.isImport());\r\n assertEquals(4, name2Row.getColumnId());\r\n assertEquals(ColumnHeaders.NAME2.toString(), name2Row.getColumnName());\r\n assertNull(name2Row.getDataType());\r\n assertNull(name2Row.getFormat());\r\n\r\n support.verifyAll();\r\n }", "private void setTime(Instant time) {\n this.time = time;\n }", "public void setTime(long time) {\r\n\t\tthis.time = time;\r\n\t}", "public void setTime(Long time) {\n this.time = time;\n }", "@Test\n public void testSetHoldingTime() throws Exception {\n isisNeighbor.setHoldingTime(1);\n result = isisNeighbor.holdingTime();\n assertThat(result, is(1));\n }", "@Test\r\n public void testGetTimeEaten()\r\n {\r\n System.out.println(\"getTimeEaten\");\r\n FoodBean instance = new FoodBean(5, \"Beans on toast\", \r\n Date.valueOf(\"2014-04-01\"), Time.valueOf(\"10:00:00\"), \r\n 100, 120, 5, 7, 500, 0, 3);\r\n Time expResult = Time.valueOf(\"10:00:00\");\r\n Time result = instance.getTimeEaten();\r\n assertEquals(expResult, result);\r\n }", "public void setTime(int time) {\n\t\tthis.time = time;\n\t}", "@Override\n\tpublic void setTime(long time)\n\t{\n\t\tsource.setTime(time);\n\t}", "public void setaTime(Date aTime) {\r\n this.aTime = aTime;\r\n }", "private void setEditedTime(int value) {\n \n editedTime_ = value;\n }", "public abstract void setEndTime(Date endTime);", "public void setTimeRange(Range range) {\r\n\t\ttimeRange = new Range(range);\r\n\t}", "native void nativeSetMetricsTime(boolean is_enable);", "public void testGetAllTimeEntries() throws Exception {\r\n assertEquals(\"The time_entry table should be empty.\", 0, instance.getAllTimeEntries().length);\r\n }", "public void setBeginTime(String time){beginTime = time;}", "@Test //ExSkip\n public void fieldTime() throws Exception {\n Document doc = new Document();\n DocumentBuilder builder = new DocumentBuilder(doc);\n\n // By default, time is displayed in the \"h:mm am/pm\" format.\n FieldTime field = insertFieldTime(builder, \"\");\n\n Assert.assertEquals(\" TIME \", field.getFieldCode());\n\n // We can use the \\@ flag to change the format of our displayed time.\n field = insertFieldTime(builder, \"\\\\@ HHmm\");\n\n Assert.assertEquals(\" TIME \\\\@ HHmm\", field.getFieldCode());\n\n // We can adjust the format to get TIME field to also display the date, according to the Gregorian calendar.\n field = insertFieldTime(builder, \"\\\\@ \\\"M/d/yyyy h mm:ss am/pm\\\"\");\n Assert.assertEquals(field.getFieldCode(), \" TIME \\\\@ \\\"M/d/yyyy h mm:ss am/pm\\\"\");\n\n doc.save(getArtifactsDir() + \"Field.TIME.docx\");\n testFieldTime(new Document(getArtifactsDir() + \"Field.TIME.docx\")); //ExSkip\n }", "public void setEndTime(String time){endTime = time;}", "@Test\n public void addTimeTest() {\n // TODO: test addTime\n }", "public void setCreatedTime(LocalDateTime value) {\n set(5, value);\n }", "public boolean isTimeSet() {\n return timeSet;\n }", "public static void setTime(){\n\t\tCalendar cal = Calendar.getInstance();\n\t\tif (!JsonUtils.RUNNING_LOCALLY){\n\t\t\tcal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 4); //account for UTC offset because of lambda\n\t\t}\n\t\tCURRENT_TIME = formatTime(cal.getTime().toString());\n\t}", "private MadisRecord setTimeObs(String obsDate, String obsTime,\n MadisRecord rec, String[] headerType) {\n\n if ((obsDate != null) && (obsTime != null)) {\n\n StringBuilder sb = new StringBuilder();\n sb.append(obsDate);\n sb.append(\" \");\n sb.append(obsTime);\n sb.append(\":01\");\n\n try {\n Date time = getDateFormatter().get().parse(sb.toString());\n Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(\"GMT\"));\n cal.setTime(time);\n rec.setTimeObs(cal);\n\n } catch (ParseException e) {\n statusHandler.handle(Priority.PROBLEM,\n \"Can't parse Madis date format!\", e);\n }\n }\n\n return rec;\n }" ]
[ "0.63997006", "0.63304937", "0.63219506", "0.6208006", "0.61979187", "0.6197244", "0.611223", "0.6092948", "0.6028525", "0.60253805", "0.6024769", "0.6024769", "0.6024769", "0.6023629", "0.600772", "0.6007432", "0.59931487", "0.59931487", "0.59931487", "0.59931487", "0.5950016", "0.59358776", "0.5932247", "0.59088755", "0.5905547", "0.589087", "0.5879993", "0.58501863", "0.5840125", "0.5835748", "0.58330137", "0.5804564", "0.5748742", "0.5713875", "0.5710501", "0.5695689", "0.56724674", "0.5652233", "0.5638819", "0.562789", "0.5593804", "0.5580585", "0.55641234", "0.5543596", "0.553814", "0.55288744", "0.5518666", "0.5515064", "0.5512414", "0.5505135", "0.55039024", "0.54805994", "0.54680765", "0.5465179", "0.54539716", "0.54510343", "0.54446495", "0.5442719", "0.5431859", "0.5425976", "0.54259384", "0.54131234", "0.54090303", "0.54073346", "0.54073006", "0.5399621", "0.5394863", "0.5393281", "0.5383162", "0.53715533", "0.5366737", "0.53589696", "0.5358898", "0.5352614", "0.53434765", "0.5337438", "0.5333833", "0.53326964", "0.5326602", "0.53231263", "0.5317116", "0.5314203", "0.531391", "0.53069925", "0.5304485", "0.5298842", "0.5296674", "0.52816284", "0.5279291", "0.5270999", "0.52685046", "0.52676636", "0.52668846", "0.5263604", "0.5259605", "0.5250867", "0.52476686", "0.52473885", "0.5246356", "0.52441657" ]
0.5935379
22
Test the behavior setObject for time columns.
@Test public void testSetOffsetTimeWithType() throws SQLException { OffsetTime data = OffsetTime.parse("16:21:51+12:34"); insertThenReadWithType(data, Types.TIME, "time_with_time_zone_column", Time.class); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "void setTime(int index, Time value) throws SQLException;", "@Test\r\n public void testSetTimeEaten()\r\n {\r\n System.out.println(\"setTimeEaten\");\r\n Time timeEaten = Time.valueOf(\"12:34:56\");\r\n FoodBean instance = new FoodBean(5, \"Beans on toast\", \r\n Date.valueOf(\"2014-04-01\"), Time.valueOf(\"10:00:00\"), \r\n 100, 120, 5, 7, 500, 0, 3);\r\n instance.setTimeEaten(timeEaten);\r\n assertEquals(timeEaten, instance.getTimeEaten());\r\n }", "public void setTime(){\r\n \r\n }", "@Test\n public void test_column_type_detection_datetimes_03() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"13:15:00\", XSDDatatype.XSDtime), true, Types.TIME, Time.class.getCanonicalName());\n }", "@Test\n public void testSetLocalTimeWithType() throws SQLException {\n LocalTime data = LocalTime.parse(\"16:21:51\");\n Time actual = insertThenReadWithType(data, Types.TIME, \"time_without_time_zone_column\", Time.class);\n Time expected = Time.valueOf(\"16:21:51\");\n assertEquals(expected, actual);\n }", "@Test\r\n public void testApplyChanges()\r\n {\r\n EasyMockSupport support = new EasyMockSupport();\r\n\r\n PreferencesRegistry registry = createPreferencesRegistry(support);\r\n CellSampler sampler = createSampler(support);\r\n ColumnDefinitionModel model = createModel();\r\n\r\n support.replayAll();\r\n\r\n @SuppressWarnings(\"unused\")\r\n ColumnDefinitionController controller = new ColumnDefinitionController(registry, model, sampler);\r\n\r\n ColumnDefinitionTableModel definitionTable = model.getDefinitionTableModel();\r\n\r\n CSVParseParameters parameters = model.getSelectedParameters();\r\n\r\n ColumnDefinitionRow timeRow = definitionTable.getRow(0);\r\n model.setSelectedDefinition(timeRow);\r\n timeRow.setFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\");\r\n\r\n SpecialColumn timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n ColumnDefinitionRow latRow = definitionTable.getRow(1);\r\n model.setSelectedDefinition(latRow);\r\n latRow.setDataType(null);\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n ColumnDefinitionRow lonRow = definitionTable.getRow(2);\r\n model.setSelectedDefinition(lonRow);\r\n lonRow.setColumnName(\"Longitude\");\r\n\r\n List<? extends String> columnNames = parameters.getColumnNames();\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n\r\n ColumnDefinitionRow name2 = definitionTable.getRow(4);\r\n model.setSelectedDefinition(name2);\r\n name2.setIsImport(true);\r\n\r\n columnNames = parameters.getColumnNames();\r\n assertEquals(ColumnHeaders.TIME.toString(), columnNames.get(0));\r\n assertEquals(ColumnHeaders.LAT.toString(), columnNames.get(1));\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n assertEquals(ColumnHeaders.NAME.toString(), columnNames.get(3));\r\n assertEquals(ColumnHeaders.NAME2.toString(), columnNames.get(4));\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n SpecialColumn lonColumn = parameters.getSpecialColumn(ColumnType.LON);\r\n assertEquals(2, lonColumn.getColumnIndex());\r\n assertEquals(\"Decimal\", lonColumn.getFormat());\r\n\r\n assertTrue(parameters.getColumnsToIgnore().isEmpty());\r\n\r\n support.verifyAll();\r\n }", "@Test\n public void test_column_type_detection_datetimes_04() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"13:15:00.123\", XSDDatatype.XSDtime), true, Types.TIME, Time.class.getCanonicalName());\n }", "@Test\n public void testDateTimeType() throws Exception {\n if(util.isHiveCatalogStoreRunning()) return;\n\n ResultSet res = null;\n TajoClient client = util.newTajoClient();\n try {\n String tableName = \"datetimetable\";\n String query = \"select col1, col2, col3 from \" + tableName;\n\n String [] table = new String[] {tableName};\n Schema schema = new Schema();\n schema.addColumn(\"col1\", Type.DATE);\n schema.addColumn(\"col2\", Type.TIME);\n schema.addColumn(\"col3\", Type.TIMESTAMP);\n Schema [] schemas = new Schema[] {schema};\n String [] data = {\n \"2014-01-01|01:00:00|2014-01-01 01:00:00\"\n };\n KeyValueSet tableOptions = new KeyValueSet();\n tableOptions.set(StorageConstants.TEXT_DELIMITER, StorageConstants.DEFAULT_FIELD_DELIMITER);\n\n res = TajoTestingCluster\n .run(table, schemas, tableOptions, new String[][]{data}, query, client);\n\n assertTrue(res.next());\n\n Date date = res.getDate(1);\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n date = res.getDate(\"col1\");\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n Time time = res.getTime(2);\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n time = res.getTime(\"col2\");\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n Timestamp timestamp = res.getTimestamp(3);\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n timestamp = res.getTimestamp(\"col3\");\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n // assert with timezone\n Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(\"GMT+9\"));\n date = res.getDate(1, cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n date = res.getDate(\"col1\", cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n time = res.getTime(2, cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n time = res.getTime(\"col2\", cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n timestamp = res.getTimestamp(3, cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n\n timestamp = res.getTimestamp(\"col3\", cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n } finally {\n if (res != null) {\n res.close();\n }\n\n client.close();\n }\n }", "void setTime(int index, Time value, Calendar cal)\n throws SQLException;", "public void setTime(long time,int ento){ \r\n\t}", "public void setTime(Date time) {\r\n this.time = time;\r\n }", "public void setTime(Date time) {\r\n this.time = time;\r\n }", "public void setTime(Date time) {\r\n this.time = time;\r\n }", "@OfMethod({\"setTime(java.lang.String,java.sql.Time)\",\n \"setTime(java.lang.String,java.sql.Time,java.util.Calendar)\",\n \"setTime(int,java.sql.Time)\",\n \"setTime(int,java.sql.Time,java.util.Calendar)\"})\n public void testSetTime() throws Exception {\n CallableStatement instance = newClosedCall();\n\n try {\n instance.setTime(getParameterName(), Time.valueOf(\"04:48:01\"));\n fail(\"Allowed set time by parameter name after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTime(getParameterName(), Time.valueOf(\"04:48:01\"), Calendar.getInstance());\n fail(\"Allowed set time by parameter name and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTime(getParameterIndex(), Time.valueOf(\"04:48:01\"));\n fail(\"Allowed set time by parameter index after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTime(getParameterIndex(), Time.valueOf(\"04:48:01\"), Calendar.getInstance());\n fail(\"Allowed set date by parameter index and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n }", "public void setTime(String time) {\n }", "public void setTime(Time time) {\n this.time = time; // assigns the time argument value to the time attribute\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(double time) {_time = time;}", "public T caseTimeOfExpr(TimeOfExpr object) {\n\t\treturn null;\n\t}", "@Test\n public void testSetLocalTimeWithoutType() throws SQLException {\n LocalTime data = LocalTime.parse(\"16:21:51\");\n Time actual = insertThenReadWithoutType(data, \"time_without_time_zone_column\", Time.class);\n Time expected = Time.valueOf(\"16:21:51\");\n assertEquals(expected, actual);\n }", "@Test\r\n\tpublic void testSetTimeslot() {\r\n\t\tTimeslot t = new Timeslot(20, WEEKDAYS.MONDAY, \"09\", \"00\");\r\n\t\tbreaku1.setTimeslot(t);\r\n\t\texternu1.setTimeslot(t);\r\n\t\tmeetingu1.setTimeslot(t);\r\n\t\tteachu1.setTimeslot(t);\r\n\r\n\t\tassertEquals(t, breaku1.getTimeslot());\r\n\t\tassertEquals(t, externu1.getTimeslot());\r\n\t\tassertEquals(t, meetingu1.getTimeslot());\r\n\t\tassertEquals(t, teachu1.getTimeslot());\r\n\t}", "public void setTime( Date time ) {\n this.time = time;\n }", "@Override\n public void setBean(TimeSheet t)\n {\n \n }", "public T caseTimeExpr(TimeExpr object) {\n\t\treturn null;\n\t}", "@Test\r\n\tpublic void testSetPersonTime() {\r\n\t\tteachu1.setPersonTime(newPersonTime);\r\n\r\n\t\tassertTrue(teachu1.getPersons().contains(person2));\r\n\t\tassertFalse(teachu1.getPersons().contains(person1));\r\n\t}", "@Override\r\n\tpublic void setMyTime(MyTime myTime) {\n\t\t\r\n\t}", "private static boolean isTime(final Object obj) {\n return timeClass != null && timeClass.isAssignableFrom(obj.getClass());\n }", "public void setTimeBounds(TimeBounds timeBounds) throws java.beans.PropertyVetoException {\n\t\tif (!Matchable.areEqual(fieldTimeBounds,timeBounds) ) {\n\t\t\t// Only here to ensure it is being used correctly.\n\t\t\t// cbit.util.Assertion.assertNotNull(timeBounds);\n\t\t\tTimeBounds oldValue = fieldTimeBounds;\n\t\t\tfireVetoableChange(PROPERTY_TIME_BOUNDS, oldValue, timeBounds);\n\t\t\tfieldTimeBounds = timeBounds;\n\t\t\tfirePropertyChange(PROPERTY_TIME_BOUNDS, oldValue, timeBounds);\n\t\t}\n\t}", "public void setTime(Date time) {\r\n\t\tthis.time = time;\r\n\t}", "@Test\r\n public void testSetStartTime() {\r\n System.out.println(\"setStartTime\");\r\n String startTime = \"\";\r\n \r\n instance.setStartTime(startTime);\r\n assertEquals(startTime, instance.getStartTime());\r\n \r\n }", "public void setTime(Date time) {\n\t\tthis.time = time;\n\t}", "public void setARRIVAL_AT_LOC_TIME(java.sql.Time value)\n {\n if ((__ARRIVAL_AT_LOC_TIME == null) != (value == null) || (value != null && ! value.equals(__ARRIVAL_AT_LOC_TIME)))\n {\n _isDirty = true;\n }\n __ARRIVAL_AT_LOC_TIME = value;\n }", "public abstract void setStartTime(Date startTime);", "@Test\r\n public void testSetEndTime() {\r\n System.out.println(\"setEndTime\");\r\n String endTime = \"\";\r\n \r\n instance.setEndTime(endTime);\r\n assertEquals(endTime, instance.getEndTime());\r\n \r\n }", "public T caseTimeEventSpec(TimeEventSpec object) {\r\n\t\treturn null;\r\n\t}", "@Then(\"^I choose an interval time$\")\n public void i_choose_an_interval_time() {\n onViewWithId(R.id.startHour).type(\"12:00\");\n onViewWithId(R.id.endHour).type(\"23:59\");\n }", "@Test\n public void testSetOffsetTimeWithoutType() throws SQLException {\n OffsetTime data = OffsetTime.parse(\"16:21:51+12:34\");\n insertThenReadWithoutType(data, \"time_with_time_zone_column\", Time.class);\n }", "public void setTime(int hour, int minute, int second){\r\n this.hour = hour ; /*when it was hour,minutes,second it was a new variable for this function bt as we used this.It gained access to the global ones. */\r\n this.minute = minute; \r\n this.second = second;\r\n }", "public void setTime(long time)\n {\n this.time = time;\n\n }", "public void setTime(String time) {\n this.time = time;\n }", "@Override\n\tpublic void setStartTime(int t) {\n\t\t\n\t}", "public void setTime(Date time) {\n this.time = new Date(time.getTime());\n }", "public void setTime(){\n \tDatabaseManager.getDBM().setLockedTime(cal); \n }", "@Test\n public void test_column_type_detection_datetimes_01() throws SQLException {\n Model m = ModelFactory.createDefaultModel();\n testColumnTypeDetection(\"x\", m.createTypedLiteral(Calendar.getInstance()).asNode(), true, Types.TIMESTAMP, Timestamp.class.getCanonicalName());\n }", "void setTime(final int time);", "@Override\n\tpublic void setTime(String time) {\n\t\tthis.time = time;\n\t}", "@java.lang.Override\n public boolean hasTime() {\n return instance.hasTime();\n }", "public void setTime(int time)\n {\n this.time = time;\n start = time;\n end = time;\n }", "public void test_DATE_HHmmss_conditionBean() { // *Important!\r\n // ## Arrange ##\r\n Calendar cal = Calendar.getInstance();\r\n cal.set(2008, 5, 15, 12, 34, 56);\r\n cal.set(Calendar.MILLISECOND, 123);\r\n Member member = new Member();\r\n member.setMemberId(3);\r\n LocalDate targetDate = toLocalDate(cal);\r\n member.setBirthdate(targetDate);\r\n memberBhv.updateNonstrict(member);\r\n\r\n // ## Act ##\r\n cal.set(2008, 5, 15, 12, 34, 57); // plus one second\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because java.sql.Date is converted to java.util.Date in ConditionBean. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n cal.set(2008, 5, 15, 12, 34, 56); // just time\r\n cal.set(Calendar.MILLISECOND, 0); // Don't format!\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = DfTypeUtil.toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n }", "public void setTime(long time) {\n this.time = time;\n }", "public void setTimeUnit(TimeUnit timeUnit);", "public void setTime(String time) {\r\n\t\tthis.time = time;\r\n\t}", "public void setTime(long time) {\r\n this.time = time;\r\n }", "private void setTime(int hour, int minute){\n Calendar calendar = Calendar.getInstance();\n calendar.set(Calendar.HOUR_OF_DAY, hour);\n calendar.set(Calendar.MINUTE, minute);\n\n persistLong(calendar.getTimeInMillis());\n\n notifyChanged();\n notifyDependencyChange(shouldDisableDependents());\n }", "public final native void setTime(String time) /*-{\n this.setTime(time);\n }-*/;", "public void setTime(gov.ucore.ucore._2_0.TimeType time)\n {\n synchronized (monitor())\n {\n check_orphaned();\n gov.ucore.ucore._2_0.TimeType target = null;\n target = (gov.ucore.ucore._2_0.TimeType)get_store().find_element_user(TIME$2, 0);\n if (target == null)\n {\n target = (gov.ucore.ucore._2_0.TimeType)get_store().add_element_user(TIME$2);\n }\n target.set(time);\n }\n }", "public void setTestTime(Integer testTime) {\n this.testTime = testTime;\n }", "@JsonSetter(\"time\")\r\n public void setTime(String time) {\r\n this.time = time;\r\n }", "public void setTime(DateTime inputTime){\n time = inputTime.getMillis();\n timeZone = inputTime.getZone();\n }", "public void setAtTime(Date atTime) {\r\n this.atTime = atTime;\r\n }", "public void setTime(AbsoluteDate date)\r\n {\r\n CoreModel coreModel = CoreModel.getDefault();\r\n coreModel.changeTimepoint(getUnderlyingElement(), date, true);\r\n }", "private void populateMinMaxTime()\n {\n final ColumnHolder columnHolder = index.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME);\n try (final NumericColumn column = (NumericColumn) columnHolder.getColumn()) {\n this.minTime = DateTimes.utc(column.getLongSingleValueRow(0));\n this.maxTime = DateTimes.utc(column.getLongSingleValueRow(column.length() - 1));\n }\n }", "public void testCmdUpdate_time_field() {\n\t\t// Initialize test variables\n\t\tCommandAction expectedCA;\n\t\tTask expectedTask;\n\t\tList<Task> expectedTaskList;\n\n\t\t/*\n\t\t * Test 3: Testing time field (all ID are valid)\n\t\t */\n\t\tctf.initialize();\n\t\texpectedTaskList = null;\n\t\taddNewTask(TASK_NAME_1);\n\n\t\t// Test 3a: start time and end time are both null\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, null, null, null);\n\t\texpectedCA = new CommandAction(MSG_TASKNOUPDATE, false, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\n\t\t// Test 3b: valid start time without end time\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, VALID_START_TIME + \"\", null, null);\n\t\texpectedCA = new CommandAction(MSG_INVALIDTIME, false, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\n\t\t// Test 3c: start time after end time\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, INVALID_START_TIME + \"\", VALID_END_TIME + \"\", null);\n\t\texpectedCA = new CommandAction(MSG_INVALIDTIME, false, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\n\t\texpectedTaskList = new ArrayList<Task>();\n\t\t// Test 3d: start time before end time\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, VALID_START_TIME + \"\", VALID_END_TIME + \"\", null);\n\t\texpectedTask = ctf.createExpectedTask(TASK_NAME_1, VALID_START_TIME, VALID_END_TIME, PRIORITY_TYPE.NORMAL);\n\t\texpectedTaskList.add(expectedTask);\n\t\texpectedCA = new CommandAction(String.format(MSG_TASKUPDATED, VALID_TASKID), true, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\t}", "public void setCreateTime(Date createTime)\n/* */ {\n/* 184 */ this.createTime = createTime;\n/* */ }", "public void setTime(java.lang.Integer value) {\n this.time = value;\n }", "@DSSafe(DSCat.UTIL_FUNCTION)\n \n @DSGenerator(tool_name = \"Doppelganger\", tool_version = \"2.0\", generated_on = \"2013-12-30 12:56:11.275 -0500\", hash_original_method = \"58DD96CFC8DDA00016DEC24CC6519017\", hash_generated_method = \"1F810C618BA62488684578EB05C3C6A1\")\n \n@Override\n public void setTime(long theTime) {\n /*\n * Store the Date based on the supplied time after removing any time\n * elements finer than the day based on zero GMT\n */\n super.setTime(normalizeTime(theTime));\n }", "public void updateTime(String columnName, Time x) throws SQLException {\n\n try {\n if (isDebugEnabled()) {\n debugCode(\"updateTime(\" + quote(columnName) + \", x);\");\n }\n update(columnName, x == null ? (Value) ValueNull.INSTANCE : ValueTime.get(x));\n }\n catch (Exception e) {\n throw logAndConvert(e);\n }\n }", "public void setTime(double minutes) {\n\t\t// implement this method.\n\n\t}", "public void setTime(int t){\r\n\t\t\t\ttime = t;\r\n\t\t\t}", "public boolean isTime() {\n return false;\n }", "@Test\n @Override\n public void testTime(TestContext ctx) {\n testDecodeGeneric(ctx, \"test_time\", Duration.class, Duration.ofHours(18).plusMinutes(45).plusSeconds(2));\n }", "@Test\r\n\tpublic void testGetTimeslot() {\r\n\t\tassertEquals(time1, breaku1.getTimeslot());\r\n\t\tassertEquals(time1, externu1.getTimeslot());\r\n\t\tassertEquals(time1, meetingu1.getTimeslot());\r\n\t\tassertEquals(time1, teachu1.getTimeslot());\r\n\t}", "@Test\n public void testSetLocalTimeAndReadBack() throws SQLException {\n // TODO: fix for binary mode.\n // Avoid micros truncation in org.postgresql.jdbc.PgResultSet#internalGetObject\n assumeBinaryModeRegular();\n LocalTime data = LocalTime.parse(\"16:21:51.123456\");\n\n insertWithoutType(data, \"time_without_time_zone_column\");\n\n String readBack = readString(\"time_without_time_zone_column\");\n assertEquals(\"16:21:51.123456\", readBack);\n }", "public void setWorldTime(long time)\n {\n worldTime = time;\n }", "public void setTime(String time) {\n\t\tthis.time = time;\n\t}", "@Test\r\n public void testLoadExisting()\r\n {\r\n EasyMockSupport support = new EasyMockSupport();\r\n\r\n PreferencesRegistry registry = createPreferencesRegistry(support);\r\n CellSampler sampler = createSampler(support);\r\n ColumnDefinitionModel model = createModel();\r\n\r\n // Add a bad special column.\r\n SpecialColumn specialColumn = new SpecialColumn();\r\n specialColumn.setColumnIndex(3);\r\n model.getSelectedParameters().getSpecialColumns().add(specialColumn);\r\n\r\n support.replayAll();\r\n\r\n @SuppressWarnings(\"unused\")\r\n ColumnDefinitionController controller = new ColumnDefinitionController(registry, model, sampler);\r\n\r\n assertFalse(model.getAvailableDataTypes().isEmpty());\r\n assertFalse(model.getAvailableFormats().isEmpty());\r\n assertFalse(model.getBeforeAfterTableModel().getRowCount() == 0);\r\n\r\n ColumnDefinitionTableModel definitionTable = model.getDefinitionTableModel();\r\n assertEquals(5, definitionTable.getRowCount());\r\n\r\n ColumnDefinitionRow timeRow = definitionTable.getRow(0);\r\n assertTrue(timeRow.isImport());\r\n assertEquals(0, timeRow.getColumnId());\r\n assertEquals(ColumnHeaders.TIME.toString(), timeRow.getColumnName());\r\n assertEquals(ColumnType.TIMESTAMP.toString(), timeRow.getDataType());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss'Z'\", timeRow.getFormat());\r\n\r\n ColumnDefinitionRow latRow = definitionTable.getRow(1);\r\n assertTrue(latRow.isImport());\r\n assertEquals(1, latRow.getColumnId());\r\n assertEquals(ColumnHeaders.LAT.toString(), latRow.getColumnName());\r\n assertEquals(ColumnType.LAT.toString(), latRow.getDataType());\r\n assertEquals(\"Decimal\", latRow.getFormat());\r\n\r\n ColumnDefinitionRow lonRow = definitionTable.getRow(2);\r\n assertTrue(lonRow.isImport());\r\n assertEquals(2, lonRow.getColumnId());\r\n assertEquals(ColumnHeaders.LON.toString(), lonRow.getColumnName());\r\n assertEquals(ColumnType.LON.toString(), lonRow.getDataType());\r\n assertEquals(\"Decimal\", lonRow.getFormat());\r\n\r\n ColumnDefinitionRow nameRow = definitionTable.getRow(3);\r\n assertTrue(nameRow.isImport());\r\n assertEquals(3, nameRow.getColumnId());\r\n assertEquals(ColumnHeaders.NAME.toString(), nameRow.getColumnName());\r\n assertNull(nameRow.getDataType());\r\n assertNull(nameRow.getFormat());\r\n\r\n ColumnDefinitionRow name2Row = definitionTable.getRow(4);\r\n assertTrue(name2Row.isImport());\r\n assertEquals(4, name2Row.getColumnId());\r\n assertEquals(ColumnHeaders.NAME2.toString(), name2Row.getColumnName());\r\n assertNull(name2Row.getDataType());\r\n assertNull(name2Row.getFormat());\r\n\r\n support.verifyAll();\r\n }", "private void setTime(Instant time) {\n this.time = time;\n }", "public void setTime(long time) {\r\n\t\tthis.time = time;\r\n\t}", "public void setTime(Long time) {\n this.time = time;\n }", "@Test\n public void testSetHoldingTime() throws Exception {\n isisNeighbor.setHoldingTime(1);\n result = isisNeighbor.holdingTime();\n assertThat(result, is(1));\n }", "@Test\r\n public void testGetTimeEaten()\r\n {\r\n System.out.println(\"getTimeEaten\");\r\n FoodBean instance = new FoodBean(5, \"Beans on toast\", \r\n Date.valueOf(\"2014-04-01\"), Time.valueOf(\"10:00:00\"), \r\n 100, 120, 5, 7, 500, 0, 3);\r\n Time expResult = Time.valueOf(\"10:00:00\");\r\n Time result = instance.getTimeEaten();\r\n assertEquals(expResult, result);\r\n }", "public void setTime(int time) {\n\t\tthis.time = time;\n\t}", "@Override\n\tpublic void setTime(long time)\n\t{\n\t\tsource.setTime(time);\n\t}", "public void setaTime(Date aTime) {\r\n this.aTime = aTime;\r\n }", "private void setEditedTime(int value) {\n \n editedTime_ = value;\n }", "public abstract void setEndTime(Date endTime);", "public void setTimeRange(Range range) {\r\n\t\ttimeRange = new Range(range);\r\n\t}", "native void nativeSetMetricsTime(boolean is_enable);", "public void testGetAllTimeEntries() throws Exception {\r\n assertEquals(\"The time_entry table should be empty.\", 0, instance.getAllTimeEntries().length);\r\n }", "public void setBeginTime(String time){beginTime = time;}", "@Test //ExSkip\n public void fieldTime() throws Exception {\n Document doc = new Document();\n DocumentBuilder builder = new DocumentBuilder(doc);\n\n // By default, time is displayed in the \"h:mm am/pm\" format.\n FieldTime field = insertFieldTime(builder, \"\");\n\n Assert.assertEquals(\" TIME \", field.getFieldCode());\n\n // We can use the \\@ flag to change the format of our displayed time.\n field = insertFieldTime(builder, \"\\\\@ HHmm\");\n\n Assert.assertEquals(\" TIME \\\\@ HHmm\", field.getFieldCode());\n\n // We can adjust the format to get TIME field to also display the date, according to the Gregorian calendar.\n field = insertFieldTime(builder, \"\\\\@ \\\"M/d/yyyy h mm:ss am/pm\\\"\");\n Assert.assertEquals(field.getFieldCode(), \" TIME \\\\@ \\\"M/d/yyyy h mm:ss am/pm\\\"\");\n\n doc.save(getArtifactsDir() + \"Field.TIME.docx\");\n testFieldTime(new Document(getArtifactsDir() + \"Field.TIME.docx\")); //ExSkip\n }", "public void setEndTime(String time){endTime = time;}", "@Test\n public void addTimeTest() {\n // TODO: test addTime\n }", "public void setCreatedTime(LocalDateTime value) {\n set(5, value);\n }", "public boolean isTimeSet() {\n return timeSet;\n }", "public static void setTime(){\n\t\tCalendar cal = Calendar.getInstance();\n\t\tif (!JsonUtils.RUNNING_LOCALLY){\n\t\t\tcal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 4); //account for UTC offset because of lambda\n\t\t}\n\t\tCURRENT_TIME = formatTime(cal.getTime().toString());\n\t}", "private MadisRecord setTimeObs(String obsDate, String obsTime,\n MadisRecord rec, String[] headerType) {\n\n if ((obsDate != null) && (obsTime != null)) {\n\n StringBuilder sb = new StringBuilder();\n sb.append(obsDate);\n sb.append(\" \");\n sb.append(obsTime);\n sb.append(\":01\");\n\n try {\n Date time = getDateFormatter().get().parse(sb.toString());\n Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(\"GMT\"));\n cal.setTime(time);\n rec.setTimeObs(cal);\n\n } catch (ParseException e) {\n statusHandler.handle(Priority.PROBLEM,\n \"Can't parse Madis date format!\", e);\n }\n }\n\n return rec;\n }" ]
[ "0.63997006", "0.63304937", "0.63219506", "0.6208006", "0.61979187", "0.6197244", "0.611223", "0.6092948", "0.6028525", "0.60253805", "0.6024769", "0.6024769", "0.6024769", "0.6023629", "0.600772", "0.6007432", "0.59931487", "0.59931487", "0.59931487", "0.59931487", "0.5950016", "0.59358776", "0.5935379", "0.5932247", "0.59088755", "0.5905547", "0.589087", "0.5879993", "0.5840125", "0.5835748", "0.58330137", "0.5804564", "0.5748742", "0.5713875", "0.5710501", "0.5695689", "0.56724674", "0.5652233", "0.5638819", "0.562789", "0.5593804", "0.5580585", "0.55641234", "0.5543596", "0.553814", "0.55288744", "0.5518666", "0.5515064", "0.5512414", "0.5505135", "0.55039024", "0.54805994", "0.54680765", "0.5465179", "0.54539716", "0.54510343", "0.54446495", "0.5442719", "0.5431859", "0.5425976", "0.54259384", "0.54131234", "0.54090303", "0.54073346", "0.54073006", "0.5399621", "0.5394863", "0.5393281", "0.5383162", "0.53715533", "0.5366737", "0.53589696", "0.5358898", "0.5352614", "0.53434765", "0.5337438", "0.5333833", "0.53326964", "0.5326602", "0.53231263", "0.5317116", "0.5314203", "0.531391", "0.53069925", "0.5304485", "0.5298842", "0.5296674", "0.52816284", "0.5279291", "0.5270999", "0.52685046", "0.52676636", "0.52668846", "0.5263604", "0.5259605", "0.5250867", "0.52476686", "0.52473885", "0.5246356", "0.52441657" ]
0.58501863
28
Test the behavior setObject for time columns.
@Test public void testSetOffsetTimeWithoutType() throws SQLException { OffsetTime data = OffsetTime.parse("16:21:51+12:34"); insertThenReadWithoutType(data, "time_with_time_zone_column", Time.class); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "void setTime(int index, Time value) throws SQLException;", "@Test\r\n public void testSetTimeEaten()\r\n {\r\n System.out.println(\"setTimeEaten\");\r\n Time timeEaten = Time.valueOf(\"12:34:56\");\r\n FoodBean instance = new FoodBean(5, \"Beans on toast\", \r\n Date.valueOf(\"2014-04-01\"), Time.valueOf(\"10:00:00\"), \r\n 100, 120, 5, 7, 500, 0, 3);\r\n instance.setTimeEaten(timeEaten);\r\n assertEquals(timeEaten, instance.getTimeEaten());\r\n }", "public void setTime(){\r\n \r\n }", "@Test\n public void test_column_type_detection_datetimes_03() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"13:15:00\", XSDDatatype.XSDtime), true, Types.TIME, Time.class.getCanonicalName());\n }", "@Test\n public void testSetLocalTimeWithType() throws SQLException {\n LocalTime data = LocalTime.parse(\"16:21:51\");\n Time actual = insertThenReadWithType(data, Types.TIME, \"time_without_time_zone_column\", Time.class);\n Time expected = Time.valueOf(\"16:21:51\");\n assertEquals(expected, actual);\n }", "@Test\r\n public void testApplyChanges()\r\n {\r\n EasyMockSupport support = new EasyMockSupport();\r\n\r\n PreferencesRegistry registry = createPreferencesRegistry(support);\r\n CellSampler sampler = createSampler(support);\r\n ColumnDefinitionModel model = createModel();\r\n\r\n support.replayAll();\r\n\r\n @SuppressWarnings(\"unused\")\r\n ColumnDefinitionController controller = new ColumnDefinitionController(registry, model, sampler);\r\n\r\n ColumnDefinitionTableModel definitionTable = model.getDefinitionTableModel();\r\n\r\n CSVParseParameters parameters = model.getSelectedParameters();\r\n\r\n ColumnDefinitionRow timeRow = definitionTable.getRow(0);\r\n model.setSelectedDefinition(timeRow);\r\n timeRow.setFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\");\r\n\r\n SpecialColumn timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n ColumnDefinitionRow latRow = definitionTable.getRow(1);\r\n model.setSelectedDefinition(latRow);\r\n latRow.setDataType(null);\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n ColumnDefinitionRow lonRow = definitionTable.getRow(2);\r\n model.setSelectedDefinition(lonRow);\r\n lonRow.setColumnName(\"Longitude\");\r\n\r\n List<? extends String> columnNames = parameters.getColumnNames();\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n\r\n ColumnDefinitionRow name2 = definitionTable.getRow(4);\r\n model.setSelectedDefinition(name2);\r\n name2.setIsImport(true);\r\n\r\n columnNames = parameters.getColumnNames();\r\n assertEquals(ColumnHeaders.TIME.toString(), columnNames.get(0));\r\n assertEquals(ColumnHeaders.LAT.toString(), columnNames.get(1));\r\n assertEquals(\"Longitude\", columnNames.get(2));\r\n assertEquals(ColumnHeaders.NAME.toString(), columnNames.get(3));\r\n assertEquals(ColumnHeaders.NAME2.toString(), columnNames.get(4));\r\n\r\n assertEquals(2, parameters.getSpecialColumns().size());\r\n\r\n timeColumn = parameters.getSpecialColumn(ColumnType.TIMESTAMP);\r\n assertEquals(0, timeColumn.getColumnIndex());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\", timeColumn.getFormat());\r\n\r\n SpecialColumn lonColumn = parameters.getSpecialColumn(ColumnType.LON);\r\n assertEquals(2, lonColumn.getColumnIndex());\r\n assertEquals(\"Decimal\", lonColumn.getFormat());\r\n\r\n assertTrue(parameters.getColumnsToIgnore().isEmpty());\r\n\r\n support.verifyAll();\r\n }", "@Test\n public void test_column_type_detection_datetimes_04() throws SQLException {\n testColumnTypeDetection(\"x\", NodeFactory.createLiteral(\"13:15:00.123\", XSDDatatype.XSDtime), true, Types.TIME, Time.class.getCanonicalName());\n }", "@Test\n public void testDateTimeType() throws Exception {\n if(util.isHiveCatalogStoreRunning()) return;\n\n ResultSet res = null;\n TajoClient client = util.newTajoClient();\n try {\n String tableName = \"datetimetable\";\n String query = \"select col1, col2, col3 from \" + tableName;\n\n String [] table = new String[] {tableName};\n Schema schema = new Schema();\n schema.addColumn(\"col1\", Type.DATE);\n schema.addColumn(\"col2\", Type.TIME);\n schema.addColumn(\"col3\", Type.TIMESTAMP);\n Schema [] schemas = new Schema[] {schema};\n String [] data = {\n \"2014-01-01|01:00:00|2014-01-01 01:00:00\"\n };\n KeyValueSet tableOptions = new KeyValueSet();\n tableOptions.set(StorageConstants.TEXT_DELIMITER, StorageConstants.DEFAULT_FIELD_DELIMITER);\n\n res = TajoTestingCluster\n .run(table, schemas, tableOptions, new String[][]{data}, query, client);\n\n assertTrue(res.next());\n\n Date date = res.getDate(1);\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n date = res.getDate(\"col1\");\n assertNotNull(date);\n assertEquals(Date.valueOf(\"2014-01-01\"), date);\n\n Time time = res.getTime(2);\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n time = res.getTime(\"col2\");\n assertNotNull(time);\n assertEquals(Time.valueOf(\"01:00:00\"), time);\n\n Timestamp timestamp = res.getTimestamp(3);\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n timestamp = res.getTimestamp(\"col3\");\n assertNotNull(timestamp);\n assertEquals(Timestamp.valueOf(\"2014-01-01 01:00:00\"), timestamp);\n\n // assert with timezone\n Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(\"GMT+9\"));\n date = res.getDate(1, cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n date = res.getDate(\"col1\", cal);\n assertNotNull(date);\n assertEquals(\"2014-01-01\", date.toString());\n\n time = res.getTime(2, cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n time = res.getTime(\"col2\", cal);\n assertNotNull(time);\n assertEquals(\"10:00:00\", time.toString());\n\n timestamp = res.getTimestamp(3, cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n\n timestamp = res.getTimestamp(\"col3\", cal);\n assertNotNull(timestamp);\n assertEquals(\"2014-01-01 10:00:00.0\", timestamp.toString());\n } finally {\n if (res != null) {\n res.close();\n }\n\n client.close();\n }\n }", "void setTime(int index, Time value, Calendar cal)\n throws SQLException;", "public void setTime(long time,int ento){ \r\n\t}", "public void setTime(Date time) {\r\n this.time = time;\r\n }", "public void setTime(Date time) {\r\n this.time = time;\r\n }", "public void setTime(Date time) {\r\n this.time = time;\r\n }", "@OfMethod({\"setTime(java.lang.String,java.sql.Time)\",\n \"setTime(java.lang.String,java.sql.Time,java.util.Calendar)\",\n \"setTime(int,java.sql.Time)\",\n \"setTime(int,java.sql.Time,java.util.Calendar)\"})\n public void testSetTime() throws Exception {\n CallableStatement instance = newClosedCall();\n\n try {\n instance.setTime(getParameterName(), Time.valueOf(\"04:48:01\"));\n fail(\"Allowed set time by parameter name after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTime(getParameterName(), Time.valueOf(\"04:48:01\"), Calendar.getInstance());\n fail(\"Allowed set time by parameter name and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTime(getParameterIndex(), Time.valueOf(\"04:48:01\"));\n fail(\"Allowed set time by parameter index after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n\n try {\n instance.setTime(getParameterIndex(), Time.valueOf(\"04:48:01\"), Calendar.getInstance());\n fail(\"Allowed set date by parameter index and calendar after close.\");\n } catch (SQLException ex) {\n checkException(ex);\n }\n }", "public void setTime(String time) {\n }", "public void setTime(Time time) {\n this.time = time; // assigns the time argument value to the time attribute\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(Date time) {\n this.time = time;\n }", "public void setTime(double time) {_time = time;}", "public T caseTimeOfExpr(TimeOfExpr object) {\n\t\treturn null;\n\t}", "@Test\n public void testSetLocalTimeWithoutType() throws SQLException {\n LocalTime data = LocalTime.parse(\"16:21:51\");\n Time actual = insertThenReadWithoutType(data, \"time_without_time_zone_column\", Time.class);\n Time expected = Time.valueOf(\"16:21:51\");\n assertEquals(expected, actual);\n }", "@Test\r\n\tpublic void testSetTimeslot() {\r\n\t\tTimeslot t = new Timeslot(20, WEEKDAYS.MONDAY, \"09\", \"00\");\r\n\t\tbreaku1.setTimeslot(t);\r\n\t\texternu1.setTimeslot(t);\r\n\t\tmeetingu1.setTimeslot(t);\r\n\t\tteachu1.setTimeslot(t);\r\n\r\n\t\tassertEquals(t, breaku1.getTimeslot());\r\n\t\tassertEquals(t, externu1.getTimeslot());\r\n\t\tassertEquals(t, meetingu1.getTimeslot());\r\n\t\tassertEquals(t, teachu1.getTimeslot());\r\n\t}", "public void setTime( Date time ) {\n this.time = time;\n }", "@Override\n public void setBean(TimeSheet t)\n {\n \n }", "public T caseTimeExpr(TimeExpr object) {\n\t\treturn null;\n\t}", "@Test\r\n\tpublic void testSetPersonTime() {\r\n\t\tteachu1.setPersonTime(newPersonTime);\r\n\r\n\t\tassertTrue(teachu1.getPersons().contains(person2));\r\n\t\tassertFalse(teachu1.getPersons().contains(person1));\r\n\t}", "@Test\n public void testSetOffsetTimeWithType() throws SQLException {\n OffsetTime data = OffsetTime.parse(\"16:21:51+12:34\");\n insertThenReadWithType(data, Types.TIME, \"time_with_time_zone_column\", Time.class);\n }", "@Override\r\n\tpublic void setMyTime(MyTime myTime) {\n\t\t\r\n\t}", "private static boolean isTime(final Object obj) {\n return timeClass != null && timeClass.isAssignableFrom(obj.getClass());\n }", "public void setTimeBounds(TimeBounds timeBounds) throws java.beans.PropertyVetoException {\n\t\tif (!Matchable.areEqual(fieldTimeBounds,timeBounds) ) {\n\t\t\t// Only here to ensure it is being used correctly.\n\t\t\t// cbit.util.Assertion.assertNotNull(timeBounds);\n\t\t\tTimeBounds oldValue = fieldTimeBounds;\n\t\t\tfireVetoableChange(PROPERTY_TIME_BOUNDS, oldValue, timeBounds);\n\t\t\tfieldTimeBounds = timeBounds;\n\t\t\tfirePropertyChange(PROPERTY_TIME_BOUNDS, oldValue, timeBounds);\n\t\t}\n\t}", "public void setTime(Date time) {\r\n\t\tthis.time = time;\r\n\t}", "@Test\r\n public void testSetStartTime() {\r\n System.out.println(\"setStartTime\");\r\n String startTime = \"\";\r\n \r\n instance.setStartTime(startTime);\r\n assertEquals(startTime, instance.getStartTime());\r\n \r\n }", "public void setTime(Date time) {\n\t\tthis.time = time;\n\t}", "public void setARRIVAL_AT_LOC_TIME(java.sql.Time value)\n {\n if ((__ARRIVAL_AT_LOC_TIME == null) != (value == null) || (value != null && ! value.equals(__ARRIVAL_AT_LOC_TIME)))\n {\n _isDirty = true;\n }\n __ARRIVAL_AT_LOC_TIME = value;\n }", "public abstract void setStartTime(Date startTime);", "@Test\r\n public void testSetEndTime() {\r\n System.out.println(\"setEndTime\");\r\n String endTime = \"\";\r\n \r\n instance.setEndTime(endTime);\r\n assertEquals(endTime, instance.getEndTime());\r\n \r\n }", "public T caseTimeEventSpec(TimeEventSpec object) {\r\n\t\treturn null;\r\n\t}", "@Then(\"^I choose an interval time$\")\n public void i_choose_an_interval_time() {\n onViewWithId(R.id.startHour).type(\"12:00\");\n onViewWithId(R.id.endHour).type(\"23:59\");\n }", "public void setTime(int hour, int minute, int second){\r\n this.hour = hour ; /*when it was hour,minutes,second it was a new variable for this function bt as we used this.It gained access to the global ones. */\r\n this.minute = minute; \r\n this.second = second;\r\n }", "public void setTime(long time)\n {\n this.time = time;\n\n }", "public void setTime(String time) {\n this.time = time;\n }", "@Override\n\tpublic void setStartTime(int t) {\n\t\t\n\t}", "public void setTime(Date time) {\n this.time = new Date(time.getTime());\n }", "public void setTime(){\n \tDatabaseManager.getDBM().setLockedTime(cal); \n }", "@Test\n public void test_column_type_detection_datetimes_01() throws SQLException {\n Model m = ModelFactory.createDefaultModel();\n testColumnTypeDetection(\"x\", m.createTypedLiteral(Calendar.getInstance()).asNode(), true, Types.TIMESTAMP, Timestamp.class.getCanonicalName());\n }", "void setTime(final int time);", "@Override\n\tpublic void setTime(String time) {\n\t\tthis.time = time;\n\t}", "@java.lang.Override\n public boolean hasTime() {\n return instance.hasTime();\n }", "public void setTime(int time)\n {\n this.time = time;\n start = time;\n end = time;\n }", "public void test_DATE_HHmmss_conditionBean() { // *Important!\r\n // ## Arrange ##\r\n Calendar cal = Calendar.getInstance();\r\n cal.set(2008, 5, 15, 12, 34, 56);\r\n cal.set(Calendar.MILLISECOND, 123);\r\n Member member = new Member();\r\n member.setMemberId(3);\r\n LocalDate targetDate = toLocalDate(cal);\r\n member.setBirthdate(targetDate);\r\n memberBhv.updateNonstrict(member);\r\n\r\n // ## Act ##\r\n cal.set(2008, 5, 15, 12, 34, 57); // plus one second\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because java.sql.Date is converted to java.util.Date in ConditionBean. \r\n //}\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n assertEquals(targetDate, actual.getBirthdate());\r\n // treated as date\r\n //try {\r\n // memberBhv.selectEntityWithDeletedCheck(cb);\r\n // // ## Assert ##\r\n // fail();\r\n //} catch (EntityAlreadyDeletedException e) {\r\n // // OK\r\n // // Because Oracle Date type have time parts. \r\n //}\r\n }\r\n cal.set(2008, 5, 15, 12, 34, 56); // just time\r\n cal.set(Calendar.MILLISECOND, 0); // Don't format!\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n {\r\n MemberCB cb = new MemberCB();\r\n cb.query().setMemberId_Equal(3);\r\n cb.query().setBirthdate_GreaterEqual(targetDate);\r\n\r\n // ## Act ##\r\n Member actual = memberBhv.selectEntityWithDeletedCheck(cb);\r\n\r\n // ## Assert ##\r\n LocalDate actualValue = actual.getBirthdate();\r\n String formatted = DfTypeUtil.toString(actualValue, \"yyyy/MM/dd\");\r\n log(\"actualValue = \" + formatted);\r\n assertEquals(\"2008/06/15\", formatted);\r\n }\r\n }", "public void setTime(long time) {\n this.time = time;\n }", "public void setTimeUnit(TimeUnit timeUnit);", "public void setTime(String time) {\r\n\t\tthis.time = time;\r\n\t}", "public void setTime(long time) {\r\n this.time = time;\r\n }", "private void setTime(int hour, int minute){\n Calendar calendar = Calendar.getInstance();\n calendar.set(Calendar.HOUR_OF_DAY, hour);\n calendar.set(Calendar.MINUTE, minute);\n\n persistLong(calendar.getTimeInMillis());\n\n notifyChanged();\n notifyDependencyChange(shouldDisableDependents());\n }", "public final native void setTime(String time) /*-{\n this.setTime(time);\n }-*/;", "public void setTime(gov.ucore.ucore._2_0.TimeType time)\n {\n synchronized (monitor())\n {\n check_orphaned();\n gov.ucore.ucore._2_0.TimeType target = null;\n target = (gov.ucore.ucore._2_0.TimeType)get_store().find_element_user(TIME$2, 0);\n if (target == null)\n {\n target = (gov.ucore.ucore._2_0.TimeType)get_store().add_element_user(TIME$2);\n }\n target.set(time);\n }\n }", "public void setTestTime(Integer testTime) {\n this.testTime = testTime;\n }", "@JsonSetter(\"time\")\r\n public void setTime(String time) {\r\n this.time = time;\r\n }", "public void setTime(DateTime inputTime){\n time = inputTime.getMillis();\n timeZone = inputTime.getZone();\n }", "public void setAtTime(Date atTime) {\r\n this.atTime = atTime;\r\n }", "public void setTime(AbsoluteDate date)\r\n {\r\n CoreModel coreModel = CoreModel.getDefault();\r\n coreModel.changeTimepoint(getUnderlyingElement(), date, true);\r\n }", "private void populateMinMaxTime()\n {\n final ColumnHolder columnHolder = index.getColumnHolder(ColumnHolder.TIME_COLUMN_NAME);\n try (final NumericColumn column = (NumericColumn) columnHolder.getColumn()) {\n this.minTime = DateTimes.utc(column.getLongSingleValueRow(0));\n this.maxTime = DateTimes.utc(column.getLongSingleValueRow(column.length() - 1));\n }\n }", "public void testCmdUpdate_time_field() {\n\t\t// Initialize test variables\n\t\tCommandAction expectedCA;\n\t\tTask expectedTask;\n\t\tList<Task> expectedTaskList;\n\n\t\t/*\n\t\t * Test 3: Testing time field (all ID are valid)\n\t\t */\n\t\tctf.initialize();\n\t\texpectedTaskList = null;\n\t\taddNewTask(TASK_NAME_1);\n\n\t\t// Test 3a: start time and end time are both null\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, null, null, null);\n\t\texpectedCA = new CommandAction(MSG_TASKNOUPDATE, false, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\n\t\t// Test 3b: valid start time without end time\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, VALID_START_TIME + \"\", null, null);\n\t\texpectedCA = new CommandAction(MSG_INVALIDTIME, false, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\n\t\t// Test 3c: start time after end time\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, INVALID_START_TIME + \"\", VALID_END_TIME + \"\", null);\n\t\texpectedCA = new CommandAction(MSG_INVALIDTIME, false, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\n\t\texpectedTaskList = new ArrayList<Task>();\n\t\t// Test 3d: start time before end time\n\t\t_testCmdUpdate = new CmdUpdate();\n\t\tsetParameters(VALID_TASKID + \"\", TASK_NAME_1, VALID_START_TIME + \"\", VALID_END_TIME + \"\", null);\n\t\texpectedTask = ctf.createExpectedTask(TASK_NAME_1, VALID_START_TIME, VALID_END_TIME, PRIORITY_TYPE.NORMAL);\n\t\texpectedTaskList.add(expectedTask);\n\t\texpectedCA = new CommandAction(String.format(MSG_TASKUPDATED, VALID_TASKID), true, expectedTaskList);\n\t\tctf.assertCommandAction(expectedCA, _testCmdUpdate.execute());\n\t}", "public void setCreateTime(Date createTime)\n/* */ {\n/* 184 */ this.createTime = createTime;\n/* */ }", "public void setTime(java.lang.Integer value) {\n this.time = value;\n }", "@DSSafe(DSCat.UTIL_FUNCTION)\n \n @DSGenerator(tool_name = \"Doppelganger\", tool_version = \"2.0\", generated_on = \"2013-12-30 12:56:11.275 -0500\", hash_original_method = \"58DD96CFC8DDA00016DEC24CC6519017\", hash_generated_method = \"1F810C618BA62488684578EB05C3C6A1\")\n \n@Override\n public void setTime(long theTime) {\n /*\n * Store the Date based on the supplied time after removing any time\n * elements finer than the day based on zero GMT\n */\n super.setTime(normalizeTime(theTime));\n }", "public void updateTime(String columnName, Time x) throws SQLException {\n\n try {\n if (isDebugEnabled()) {\n debugCode(\"updateTime(\" + quote(columnName) + \", x);\");\n }\n update(columnName, x == null ? (Value) ValueNull.INSTANCE : ValueTime.get(x));\n }\n catch (Exception e) {\n throw logAndConvert(e);\n }\n }", "public void setTime(double minutes) {\n\t\t// implement this method.\n\n\t}", "public void setTime(int t){\r\n\t\t\t\ttime = t;\r\n\t\t\t}", "public boolean isTime() {\n return false;\n }", "@Test\n @Override\n public void testTime(TestContext ctx) {\n testDecodeGeneric(ctx, \"test_time\", Duration.class, Duration.ofHours(18).plusMinutes(45).plusSeconds(2));\n }", "@Test\r\n\tpublic void testGetTimeslot() {\r\n\t\tassertEquals(time1, breaku1.getTimeslot());\r\n\t\tassertEquals(time1, externu1.getTimeslot());\r\n\t\tassertEquals(time1, meetingu1.getTimeslot());\r\n\t\tassertEquals(time1, teachu1.getTimeslot());\r\n\t}", "@Test\n public void testSetLocalTimeAndReadBack() throws SQLException {\n // TODO: fix for binary mode.\n // Avoid micros truncation in org.postgresql.jdbc.PgResultSet#internalGetObject\n assumeBinaryModeRegular();\n LocalTime data = LocalTime.parse(\"16:21:51.123456\");\n\n insertWithoutType(data, \"time_without_time_zone_column\");\n\n String readBack = readString(\"time_without_time_zone_column\");\n assertEquals(\"16:21:51.123456\", readBack);\n }", "public void setWorldTime(long time)\n {\n worldTime = time;\n }", "public void setTime(String time) {\n\t\tthis.time = time;\n\t}", "@Test\r\n public void testLoadExisting()\r\n {\r\n EasyMockSupport support = new EasyMockSupport();\r\n\r\n PreferencesRegistry registry = createPreferencesRegistry(support);\r\n CellSampler sampler = createSampler(support);\r\n ColumnDefinitionModel model = createModel();\r\n\r\n // Add a bad special column.\r\n SpecialColumn specialColumn = new SpecialColumn();\r\n specialColumn.setColumnIndex(3);\r\n model.getSelectedParameters().getSpecialColumns().add(specialColumn);\r\n\r\n support.replayAll();\r\n\r\n @SuppressWarnings(\"unused\")\r\n ColumnDefinitionController controller = new ColumnDefinitionController(registry, model, sampler);\r\n\r\n assertFalse(model.getAvailableDataTypes().isEmpty());\r\n assertFalse(model.getAvailableFormats().isEmpty());\r\n assertFalse(model.getBeforeAfterTableModel().getRowCount() == 0);\r\n\r\n ColumnDefinitionTableModel definitionTable = model.getDefinitionTableModel();\r\n assertEquals(5, definitionTable.getRowCount());\r\n\r\n ColumnDefinitionRow timeRow = definitionTable.getRow(0);\r\n assertTrue(timeRow.isImport());\r\n assertEquals(0, timeRow.getColumnId());\r\n assertEquals(ColumnHeaders.TIME.toString(), timeRow.getColumnName());\r\n assertEquals(ColumnType.TIMESTAMP.toString(), timeRow.getDataType());\r\n assertEquals(\"yyyy-MM-dd'T'HH:mm:ss'Z'\", timeRow.getFormat());\r\n\r\n ColumnDefinitionRow latRow = definitionTable.getRow(1);\r\n assertTrue(latRow.isImport());\r\n assertEquals(1, latRow.getColumnId());\r\n assertEquals(ColumnHeaders.LAT.toString(), latRow.getColumnName());\r\n assertEquals(ColumnType.LAT.toString(), latRow.getDataType());\r\n assertEquals(\"Decimal\", latRow.getFormat());\r\n\r\n ColumnDefinitionRow lonRow = definitionTable.getRow(2);\r\n assertTrue(lonRow.isImport());\r\n assertEquals(2, lonRow.getColumnId());\r\n assertEquals(ColumnHeaders.LON.toString(), lonRow.getColumnName());\r\n assertEquals(ColumnType.LON.toString(), lonRow.getDataType());\r\n assertEquals(\"Decimal\", lonRow.getFormat());\r\n\r\n ColumnDefinitionRow nameRow = definitionTable.getRow(3);\r\n assertTrue(nameRow.isImport());\r\n assertEquals(3, nameRow.getColumnId());\r\n assertEquals(ColumnHeaders.NAME.toString(), nameRow.getColumnName());\r\n assertNull(nameRow.getDataType());\r\n assertNull(nameRow.getFormat());\r\n\r\n ColumnDefinitionRow name2Row = definitionTable.getRow(4);\r\n assertTrue(name2Row.isImport());\r\n assertEquals(4, name2Row.getColumnId());\r\n assertEquals(ColumnHeaders.NAME2.toString(), name2Row.getColumnName());\r\n assertNull(name2Row.getDataType());\r\n assertNull(name2Row.getFormat());\r\n\r\n support.verifyAll();\r\n }", "private void setTime(Instant time) {\n this.time = time;\n }", "public void setTime(long time) {\r\n\t\tthis.time = time;\r\n\t}", "public void setTime(Long time) {\n this.time = time;\n }", "@Test\n public void testSetHoldingTime() throws Exception {\n isisNeighbor.setHoldingTime(1);\n result = isisNeighbor.holdingTime();\n assertThat(result, is(1));\n }", "@Test\r\n public void testGetTimeEaten()\r\n {\r\n System.out.println(\"getTimeEaten\");\r\n FoodBean instance = new FoodBean(5, \"Beans on toast\", \r\n Date.valueOf(\"2014-04-01\"), Time.valueOf(\"10:00:00\"), \r\n 100, 120, 5, 7, 500, 0, 3);\r\n Time expResult = Time.valueOf(\"10:00:00\");\r\n Time result = instance.getTimeEaten();\r\n assertEquals(expResult, result);\r\n }", "public void setTime(int time) {\n\t\tthis.time = time;\n\t}", "@Override\n\tpublic void setTime(long time)\n\t{\n\t\tsource.setTime(time);\n\t}", "public void setaTime(Date aTime) {\r\n this.aTime = aTime;\r\n }", "private void setEditedTime(int value) {\n \n editedTime_ = value;\n }", "public abstract void setEndTime(Date endTime);", "public void setTimeRange(Range range) {\r\n\t\ttimeRange = new Range(range);\r\n\t}", "native void nativeSetMetricsTime(boolean is_enable);", "public void testGetAllTimeEntries() throws Exception {\r\n assertEquals(\"The time_entry table should be empty.\", 0, instance.getAllTimeEntries().length);\r\n }", "public void setBeginTime(String time){beginTime = time;}", "@Test //ExSkip\n public void fieldTime() throws Exception {\n Document doc = new Document();\n DocumentBuilder builder = new DocumentBuilder(doc);\n\n // By default, time is displayed in the \"h:mm am/pm\" format.\n FieldTime field = insertFieldTime(builder, \"\");\n\n Assert.assertEquals(\" TIME \", field.getFieldCode());\n\n // We can use the \\@ flag to change the format of our displayed time.\n field = insertFieldTime(builder, \"\\\\@ HHmm\");\n\n Assert.assertEquals(\" TIME \\\\@ HHmm\", field.getFieldCode());\n\n // We can adjust the format to get TIME field to also display the date, according to the Gregorian calendar.\n field = insertFieldTime(builder, \"\\\\@ \\\"M/d/yyyy h mm:ss am/pm\\\"\");\n Assert.assertEquals(field.getFieldCode(), \" TIME \\\\@ \\\"M/d/yyyy h mm:ss am/pm\\\"\");\n\n doc.save(getArtifactsDir() + \"Field.TIME.docx\");\n testFieldTime(new Document(getArtifactsDir() + \"Field.TIME.docx\")); //ExSkip\n }", "public void setEndTime(String time){endTime = time;}", "@Test\n public void addTimeTest() {\n // TODO: test addTime\n }", "public void setCreatedTime(LocalDateTime value) {\n set(5, value);\n }", "public boolean isTimeSet() {\n return timeSet;\n }", "public static void setTime(){\n\t\tCalendar cal = Calendar.getInstance();\n\t\tif (!JsonUtils.RUNNING_LOCALLY){\n\t\t\tcal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 4); //account for UTC offset because of lambda\n\t\t}\n\t\tCURRENT_TIME = formatTime(cal.getTime().toString());\n\t}", "private MadisRecord setTimeObs(String obsDate, String obsTime,\n MadisRecord rec, String[] headerType) {\n\n if ((obsDate != null) && (obsTime != null)) {\n\n StringBuilder sb = new StringBuilder();\n sb.append(obsDate);\n sb.append(\" \");\n sb.append(obsTime);\n sb.append(\":01\");\n\n try {\n Date time = getDateFormatter().get().parse(sb.toString());\n Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(\"GMT\"));\n cal.setTime(time);\n rec.setTimeObs(cal);\n\n } catch (ParseException e) {\n statusHandler.handle(Priority.PROBLEM,\n \"Can't parse Madis date format!\", e);\n }\n }\n\n return rec;\n }" ]
[ "0.63997006", "0.63304937", "0.63219506", "0.6208006", "0.61979187", "0.6197244", "0.611223", "0.6092948", "0.6028525", "0.60253805", "0.6024769", "0.6024769", "0.6024769", "0.6023629", "0.600772", "0.6007432", "0.59931487", "0.59931487", "0.59931487", "0.59931487", "0.5950016", "0.59358776", "0.5935379", "0.5932247", "0.59088755", "0.5905547", "0.589087", "0.5879993", "0.58501863", "0.5840125", "0.5835748", "0.58330137", "0.5804564", "0.5748742", "0.5713875", "0.5710501", "0.5695689", "0.56724674", "0.5652233", "0.5638819", "0.5593804", "0.5580585", "0.55641234", "0.5543596", "0.553814", "0.55288744", "0.5518666", "0.5515064", "0.5512414", "0.5505135", "0.55039024", "0.54805994", "0.54680765", "0.5465179", "0.54539716", "0.54510343", "0.54446495", "0.5442719", "0.5431859", "0.5425976", "0.54259384", "0.54131234", "0.54090303", "0.54073346", "0.54073006", "0.5399621", "0.5394863", "0.5393281", "0.5383162", "0.53715533", "0.5366737", "0.53589696", "0.5358898", "0.5352614", "0.53434765", "0.5337438", "0.5333833", "0.53326964", "0.5326602", "0.53231263", "0.5317116", "0.5314203", "0.531391", "0.53069925", "0.5304485", "0.5298842", "0.5296674", "0.52816284", "0.5279291", "0.5270999", "0.52685046", "0.52676636", "0.52668846", "0.5263604", "0.5259605", "0.5250867", "0.52476686", "0.52473885", "0.5246356", "0.52441657" ]
0.562789
40
Created by Jason on 2017/7/11.
public interface MessageCommentService { /** * 添加评论信息 * * @param messageCommentDTO * @return */ ApiResult addMessageComment(MessageCommentDTO messageCommentDTO); /** * 获取评论信息 * * @return */ ApiResult getMessageCommentList(); /** * 分页获取留言评论 * * @param messageCommentDTO * @param webPage * @param userPropertystaff * @return */ List<MessageCommentDTO> getMessageCommentInfoList(MessageCommentDTO messageCommentDTO, WebPage webPage, UserPropertyStaffEntity userPropertystaff); /** * 根据ID获取信息 * * @param mcId * @return */ MessageCommentDTO getMessageCommentInfoById(String mcId); /** * 编辑信息 * * @param messageCommentDTO */ void updateInfo(MessageCommentDTO messageCommentDTO); /** * 删除信息 * * @param mcId */ void deleteInfoById(String mcId); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Override\n public void perish() {\n \n }", "private stendhal() {\n\t}", "@Override\n\tpublic void comer() {\n\t\t\n\t}", "@Override\n\tpublic void grabar() {\n\t\t\n\t}", "@Override\r\n\tpublic void bicar() {\n\t\t\r\n\t}", "@Override\r\n\tpublic void bicar() {\n\t\t\r\n\t}", "@Override\n public void func_104112_b() {\n \n }", "@Override\r\n\tpublic void comer() \r\n\t{\n\t\t\r\n\t}", "private void poetries() {\n\n\t}", "@Override\r\n\tpublic void tires() {\n\t\t\r\n\t}", "@Override\n\tprotected void getExras() {\n\n\t}", "@Override\n\tpublic void sacrifier() {\n\t\t\n\t}", "private static void cajas() {\n\t\t\n\t}", "@Override\n\tprotected void interr() {\n\t}", "public final void mo51373a() {\n }", "@Override\n\tpublic void anular() {\n\n\t}", "@Override\n\tpublic void entrenar() {\n\t\t\n\t}", "@Override\n\tpublic void nadar() {\n\t\t\n\t}", "@Override\n public void init() {\n\n }", "@Override\r\n\tpublic void dormir() {\n\t\t\r\n\t}", "@Override\r\n\tpublic void rozmnozovat() {\n\t}", "@Override\n public int describeContents() { return 0; }", "@Override\n protected void getExras() {\n }", "@Override\n\tpublic void jugar() {\n\t\t\n\t}", "@Override\n protected void initialize() {\n\n \n }", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "public void mo38117a() {\n }", "@Override\n public void init() {\n }", "protected boolean func_70814_o() { return true; }", "@Override\n void init() {\n }", "@Override\r\n\t\t\tpublic void annadir() {\n\r\n\t\t\t}", "private void m50366E() {\n }", "private void kk12() {\n\n\t}", "@Override\n\tpublic void gravarBd() {\n\t\t\n\t}", "@Override\r\n\t\tpublic void init() {\n\t\t\t\r\n\t\t}", "@Override\r\n\tpublic void anularFact() {\n\t\t\r\n\t}", "public void gored() {\n\t\t\n\t}", "private void init() {\n\n\t}", "@Override\n protected void initialize() {\n }", "@Override\n protected void initialize() {\n }", "@Override\n protected void initialize() {\n }", "@Override\n protected void initialize() {\n }", "@Override\n protected void initialize() {\n }", "@Override\n protected void initialize() {\n }", "private void strin() {\n\n\t}", "@Override\n protected void initialize() \n {\n \n }", "@Override\n public void init() {\n\n }", "@Override\n public void init() {\n\n }", "public void mo4359a() {\n }", "@Override\n\tprotected void initialize() {\n\t\t\n\t}", "@Override\n\tprotected void initialize() {\n\t\t\n\t}", "@Override\r\n\tpublic void dibujar() {\n\t\t\r\n\t}", "@Override\r\n\tpublic void dibujar() {\n\t\t\r\n\t}", "@Override\r\n\t\t\tpublic void ayuda() {\n\r\n\t\t\t}", "@Override\n\tpublic void init() {\n\n\t}", "@Override\n\tpublic void init() {\n\n\t}", "@Override\n\tpublic void init() {\n\n\t}", "@Override\n public void init() {}", "@Override\r\n\tpublic void init() {\n\r\n\t}", "@Override\r\n\tpublic void init() {\n\r\n\t}", "@Override\r\n\tpublic void init() {\n\r\n\t}", "@Override\n\tpublic void einkaufen() {\n\t}", "@Override\n\tpublic void one() {\n\t\t\n\t}", "@Override\n\tpublic void nghe() {\n\n\t}", "@Override\n\tpublic void ligar() {\n\t\t\n\t}", "@Override\n protected void init() {\n }", "@Override\r\n\tpublic void init() {}", "@Override\r\n\tpublic void init() {\n\t\t\r\n\t}", "@Override\r\n\tpublic void init() {\n\t\t\r\n\t}", "@Override\r\n\tpublic void init() {\n\t\t\r\n\t}", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "@Override\n public int retroceder() {\n return 0;\n }", "@Override\n public void memoria() {\n \n }", "@Override\r\n\tprotected void doF4() {\n\t\t\r\n\t}", "@Override\n\tprotected void initialize() {\n\n\t}", "private Rekenhulp()\n\t{\n\t}", "@Override\n\tpublic void init() {\n\t}", "@Override\r\n\tprotected void initialize() {\r\n\t\t\r\n\t\t\r\n\t}", "@Override\r\n\tpublic void init()\r\n\t{\n\t}", "@Override\n\tpublic void init()\n\t{\n\n\t}", "@Override\n public void initialize() { \n }", "@Override\n\tpublic void debite() {\n\t\t\n\t}", "@Override\n\tpublic int mettreAJour() {\n\t\treturn 0;\n\t}", "@Override\r\n\tprotected void doF8() {\n\t\t\r\n\t}", "public void method_4270() {}", "@Override\n public int getOrder() {\n return 4;\n }", "public void mo6081a() {\n }", "public void mo21877s() {\n }", "private void getStatus() {\n\t\t\n\t}", "private void init() {\n\n\n\n }", "@Override\r\n\tprotected void initialize() {\n\r\n\t}" ]
[ "0.60466635", "0.58493066", "0.58344245", "0.5789199", "0.5720012", "0.5720012", "0.568361", "0.56801444", "0.56746227", "0.5668034", "0.56599855", "0.5606272", "0.55965334", "0.5592558", "0.55894625", "0.55725455", "0.5568903", "0.5546393", "0.55461246", "0.5521616", "0.54932123", "0.54919225", "0.54815435", "0.5479908", "0.546708", "0.5462244", "0.5462244", "0.5462244", "0.5462244", "0.5462244", "0.54501384", "0.5447385", "0.5445588", "0.54374397", "0.5434899", "0.5433587", "0.5426026", "0.542012", "0.5417292", "0.5412536", "0.5411604", "0.5399822", "0.5384452", "0.5384452", "0.5384452", "0.5384452", "0.5384452", "0.5384452", "0.53680784", "0.53556496", "0.5353684", "0.5353684", "0.5353504", "0.5352238", "0.5352238", "0.53518707", "0.53518707", "0.53455776", "0.53451604", "0.53451604", "0.53451604", "0.53362596", "0.5334746", "0.5334746", "0.5334746", "0.53334516", "0.5330703", "0.53289706", "0.5327308", "0.5323285", "0.5316343", "0.5312635", "0.5312635", "0.5312635", "0.5290059", "0.5290059", "0.5290059", "0.5290059", "0.5290059", "0.5290059", "0.5290059", "0.528976", "0.5280583", "0.527586", "0.5273334", "0.5265891", "0.52615285", "0.52558434", "0.525462", "0.5252187", "0.5251544", "0.5232111", "0.52283484", "0.52160394", "0.5210972", "0.5198365", "0.51952386", "0.51901907", "0.51866114", "0.5185763", "0.5182053" ]
0.0
-1
These next methods will compute various fees for a ticket
public double ComputeDistance(){ double lat1 = this.depAirportCity.getLatDegs() + (double)(this.depAirportCity.getLatMins())/60; double lon1 = this.depAirportCity.getLongDegs() + (double)(this.depAirportCity.getLongMins())/60; double lat2 = this.arrAirportCity.getLatDegs() + (double)(this.arrAirportCity.getLatMins())/60; double lon2 = this.arrAirportCity.getLongDegs() + (double)(this.arrAirportCity.getLongMins())/60; double distance = Haversine.getMiles(lat1, lon1, lat2, lon2); return distance; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Override\n\tpublic int fees() {\n\t\treturn 25000;\n\t\t\n\t}", "public float calculate(Ticket t) {\n\t}", "public double calFee() {\n return weight * FEE + GiftBox.this.price;\n }", "public double getFees(){\n\t\treturn (this.getPassengerFacilityFee() + this.get911SecurityFee());\n\t}", "public abstract double calculateQuarterlyFees();", "private void calcTotalAmount(){\n\t totalAmount = 0;\n\t\tfor(FlightTicket ft : tickets)\n\t\t{\n\t\t\ttotalAmount += ft.getClassType().getFee() * getFlight().getFlightCost();\n\t\t}\n\t\tsetTotalAmount(totalAmount);\n\t}", "public void payFees(int fees) {\n feesPaid += fees;\n School.updateTotalMoneyEarned(feesPaid);\n }", "public void payFees(int fees) {\n feesPaid += fees;\n feesRemaining -= fees;\n School.updateTotalMoneyEarned(fees);\n }", "public BigDecimal getEstimatedFees() {\n return estimatedFees;\n }", "public BigDecimal getFee() {\r\n return fee;\r\n }", "public BigDecimal getFee() {\n return fee;\n }", "public double totalFee(){\n return (this.creditHours*this.feePerCreditHour)-this.scholarshipAmount+((this.healthInsurancePerAnnum*4)/12);\n }", "public void updateStudentFees(double fees){\n feesPaid+=fees;\n school.updateMoneyEarned(feesPaid);\n }", "public abstract double getComplianceFee();", "public BigDecimal getFee() {\n return fee;\n }", "private double getFee(int ISBN) {\r\n\t\t/* Query to get the fee */\r\n\t\tdouble price = db.findPrice(ISBN);\r\n\t\tSystem.out.println(\"price that you're charging: \" + price / 2);\r\n\t\treturn (price / 2);\r\n\t}", "public double tuitionFee(){\n return this.creditHours*this.feePerCreditHour;\n }", "public abstract double getLateFee(int daysLate);", "public int getFee()\n {\n return fee;\n }", "@Override\r\n public double purchaseFee(){\r\n return fee;\r\n }", "public BigDecimal\tgetOrderFee();", "public double getFee() {\n\t\treturn fee;\n\t}", "public int remainingFees()\r\n\t{\r\n\t\treturn feesTotal-feesPaid;\t\t\r\n\t}", "private double calculateTotalFeesEarned(ArrayList<Pair<Fees, Time>> timeslots) {\n double sumOfFees = 0.00;\n for (DayOfWeek day : DayOfWeek.values()) {\n sumOfFees += calculateFeesEarnedEachDayOfWeek(timeslots, day);\n }\n return sumOfFees;\n }", "public long getFee() {\n return fee_;\n }", "public FeeCalculation calculateFee(SendRequest req, Coin value, List<TransactionInput> originalInputs,\n boolean needAtLeastReferenceFee, List<TransactionOutput> candidates) throws InsufficientMoneyException {\n FeeCalculation result;\n Coin fee = Coin.ZERO;\n while (true) {\n result = new FeeCalculation();\n UldTransaction tx = new UldTransaction(params);\n addSuppliedInputs(tx, req.tx.getInputs());\n\n Coin valueNeeded = value;\n if (!req.recipientsPayFees) {\n valueNeeded = valueNeeded.add(fee);\n }\n if (req.recipientsPayFees) {\n result.updatedOutputValues = new ArrayList<Coin>();\n }\n for (int i = 0; i < req.tx.getOutputs().size(); i++) {\n TransactionOutput output = new TransactionOutput(params, tx,\n req.tx.getOutputs().get(i).ulordSerialize(), 0);\n if (req.recipientsPayFees) {\n // Subtract fee equally from each selected recipient\n output.setValue(output.getValue().subtract(fee.divide(req.tx.getOutputs().size())));\n // first receiver pays the remainder not divisible by output count\n if (i == 0) {\n output.setValue(\n output.getValue().subtract(fee.divideAndRemainder(req.tx.getOutputs().size())[1])); // Subtract fee equally from each selected recipient\n }\n result.updatedOutputValues.add(output.getValue());\n if (output.getMinNonDustValue().isGreaterThan(output.getValue())) {\n throw new CouldNotAdjustDownwards();\n }\n }\n tx.addOutput(output);\n }\n CoinSelector selector = req.coinSelector == null ? coinSelector : req.coinSelector;\n // selector is allowed to modify candidates list.\n CoinSelection selection = selector.select(valueNeeded, new LinkedList<TransactionOutput>(candidates));\n result.bestCoinSelection = selection;\n // Can we afford this?\n if (selection.valueGathered.compareTo(valueNeeded) < 0) {\n Coin valueMissing = valueNeeded.subtract(selection.valueGathered);\n throw new InsufficientMoneyException(valueMissing);\n }\n Coin change = selection.valueGathered.subtract(valueNeeded);\n if (change.isGreaterThan(Coin.ZERO)) {\n // The value of the inputs is greater than what we want to send. Just like in real life then,\n // we need to take back some coins ... this is called \"change\". Add another output that sends the change\n // back to us. The address comes either from the request or currentChangeAddress() as a default.\n Address changeAddress = req.changeAddress;\n TransactionOutput changeOutput = new TransactionOutput(params, tx, change, changeAddress);\n if (req.recipientsPayFees && changeOutput.isDust()) {\n // We do not move dust-change to fees, because the sender would end up paying more than requested.\n // This would be against the purpose of the all-inclusive feature.\n // So instead we raise the change and deduct from the first recipient.\n Coin missingToNotBeDust = changeOutput.getMinNonDustValue().subtract(changeOutput.getValue());\n changeOutput.setValue(changeOutput.getValue().add(missingToNotBeDust));\n TransactionOutput firstOutput = tx.getOutputs().get(0);\n firstOutput.setValue(firstOutput.getValue().subtract(missingToNotBeDust));\n result.updatedOutputValues.set(0, firstOutput.getValue());\n if (firstOutput.isDust()) {\n throw new CouldNotAdjustDownwards();\n }\n }\n if (changeOutput.isDust()) {\n // Never create dust outputs; if we would, just\n // add the dust to the fee.\n // Oscar comment: This seems like a way to make the condition below \"if\n // (!fee.isLessThan(feeNeeded))\" to become true.\n // This is a non-easy to understand way to do that.\n // Maybe there are other effects I am missing\n fee = fee.add(changeOutput.getValue());\n } else {\n tx.addOutput(changeOutput);\n result.bestChangeOutput = changeOutput;\n }\n }\n\n for (TransactionOutput selectedOutput : selection.gathered) {\n TransactionInput input = tx.addInput(selectedOutput);\n // If the scriptBytes don't default to none, our size calculations will be thrown off.\n checkState(input.getScriptBytes().length == 0);\n }\n\n int size = tx.unsafeUlordSerialize().length;\n size += estimateBytesForSigning(selection);\n\n Coin feePerKb = req.feePerKb;\n if (needAtLeastReferenceFee && feePerKb.compareTo(UldTransaction.REFERENCE_DEFAULT_MIN_TX_FEE) < 0) {\n feePerKb = UldTransaction.REFERENCE_DEFAULT_MIN_TX_FEE;\n }\n Coin feeNeeded = feePerKb.multiply(size).divide(1000);\n\n if (!fee.isLessThan(feeNeeded)) {\n // Done, enough fee included.\n break;\n }\n\n // Include more fee and try again.\n fee = feeNeeded;\n }\n return result;\n\n }", "@Override\n public double calcSalesFee() {\n return getCost() + getSalesPurchase();\n }", "@Override\n public void getFee(ParkingBill parkingBill)\n {\n double hoursParked = parkingBill.getHoursParked();\n\n if(hoursParked <= 3)\n {\n parkingBill.setAmountDue(5.00);\n }\n else if(hoursParked > 3 && hoursParked <= 13)\n {\n parkingBill.setAmountDue(5.00 + (Math.ceil(hoursParked) - 3));\n }\n else\n {\n parkingBill.setAmountDue(15.00);\n }\n }", "public long getFee() {\n return fee_;\n }", "public float calculateTotalFee(){\n int endD = parseInt(endDay);\n int startD = parseInt(startDay);\n int endM = parseInt(convertMonthToDigit(endMonth));\n int startM = parseInt(convertMonthToDigit(startMonth));\n int monthDiff = 0;\n float totalFee = 0;\n //get the stay duration in months\n monthDiff = endM - startM;\n \n System.out.println(\"CALCULATING TOTAL FEE:\");\n \n stayDuration = 1;\n if(monthDiff == 0){ //on the same month\n if(startD == endD){\n stayDuration = 1;\n }else if(startD < endD){ //Same month, diff days\n stayDuration = 1 + (parseInt(endDay) - parseInt(startDay));\n }\n }else if(monthDiff > 0){ //1 month difference\n \n if(startD > endD){ // End day is next month\n switch(startMonth){\n case \"January\": case \"March\": case \"May\": case \"July\": case \"August\": \n case \"October\": case \"December\":\n stayDuration = 1 + ( (31+ parseInt(endDay)) - parseInt(startDay));\n break;\n\n case \"April\": case \"June\": case \"September\": case \"November\":\n stayDuration = 1 + ((30+ parseInt(endDay)) - parseInt(startDay));\n break; \n \n case \"February\": \n stayDuration = 1 + ((29+ parseInt(endDay)) - parseInt(startDay));\n break; \n default:\n break;\n }\n }else if(startD <= endD){ //if end day is greater than start day\n switch(startMonth){\n case \"January\": case \"March\": case \"May\": case \"July\": case \"August\": \n case \"October\": case \"December\":\n stayDuration = 1 + ((parseInt(endDay)) - parseInt(startDay));\n stayDuration += 31;\n break;\n\n case \"April\": case \"June\": case \"September\": case \"November\":\n stayDuration = 1 + ( (parseInt(endDay)) - parseInt(startDay));\n stayDuration += 30;\n break; \n \n case \"February\": \n stayDuration = 1 + ( (parseInt(endDay)) - parseInt(startDay));\n stayDuration += 29;\n break; \n \n default:\n break;\n }\n }\n }else if(monthDiff < 0){\n if(startMonth == \"December\" && endMonth == \"January\"){\n if(startD > endD){ // End day is next month\n switch(startMonth){\n case \"January\": case \"March\": case \"May\": case \"July\": case \"August\": \n case \"October\": case \"December\":\n stayDuration = 1 + ( (31+ parseInt(endDay)) - parseInt(startDay));\n break;\n\n case \"April\": case \"June\": case \"September\": case \"November\":\n stayDuration = 1 + ((30+ parseInt(endDay)) - parseInt(startDay));\n break; \n\n case \"February\": \n stayDuration = 1 + ((29+ parseInt(endDay)) - parseInt(startDay));\n break; \n default:\n break;\n }\n }else{\n stayDuration = 1 + ((parseInt(endDay)) - parseInt(startDay));\n stayDuration += 31;\n }\n }\n }\n \n totalFee = (int) (getSelectedRoomsCounter() * getSelectedRoomPrice());\n totalFee *= stayDuration;\n \n //console log\n System.out.println(\"stayDuration: \"+ stayDuration);\n System.out.println(\"Total Fee: \" + totalFee +\"php\");\n return totalFee;\n }", "public abstract double calculateFee(int aWidth);", "@Override\r\n\tpublic long[] getTicketMoney() {\n\t\tlong[] result = new long[2];\r\n\t\tList<FeeRecord> card = feeRecordDao.getCardRecords();\r\n\t\tList<FeeRecord> cash = feeRecordDao.getCashRecords();\r\n\t\tfor(FeeRecord feeRecord:card){\r\n\t\t\tresult[0] += feeRecord.getMoney();\r\n\t\t}\r\n\t\tfor(FeeRecord feeRecord:cash){\r\n\t\t\tresult[1] += feeRecord.getMoney();\r\n\t\t}\r\n\t\treturn result;\r\n\t}", "public void setFee(BigDecimal fee) {\r\n this.fee = fee;\r\n }", "public void setFee(int fee)\n {\n this.fee = fee;\n }", "public int getFee(){return 0;}", "public void setFee(BigDecimal fee) {\n this.fee = fee;\n }", "public PriceToEstimateFees getPriceToEstimateFees() {\n return priceToEstimateFees;\n }", "public double calculateFee(int width)\t\t{\n\t\tdouble fee;\n\n\t\tswitch(width)\t{\n\t\t\tcase 10:\n\t\t\t\tfee = 800;\n\t\t\t\tbreak;\n\t\t\tcase 12:\n\t\t\t\tfee = 900;\n\t\t\t\tbreak;\n\t\t\tcase 14:\n\t\t\t\tfee = 1100;\n\t\t\t\tbreak;\n\t\t\tcase 16:\n\t\t\t\tfee = 1500;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tfee = 0;\n\t\t}\n\n\t\treturn fee;\n\t}", "private BigDecimal addServiceFee(final SubmittedBill[] submittedBills) {\n BigDecimal serviceFee = new BigDecimal(0);\n for (final SubmittedBill submittedBill : submittedBills) {\n if (!getStatusForRejected(submittedBill.getStatus().name())) {\n serviceFee = serviceFee.add(submittedBill.getServiceFee());\n }\n\n }\n return serviceFee;\n }", "public synchronized void applyFee() {\r\n balance -= FEE;\r\n }", "@Override\n\tpublic double getPremiumFee(FDRuleContextI ctx) {\n\t\treturn 0;\n\t}", "public TableModel cacualateFixPriceFee(EbCandidateItem item) {\n EbFeeCaculaterFactory factory = EbFeeCaculaterFactory.getInstance();\r\n EbUtil ebu = new EbUtil();\r\n fixInserts.put(ZcSettingConstants.FIX, \"上架费\");\r\n fixInserts.put(\r\n ZcSettingConstants.US,\r\n factory.getFixInsertFees(ZcSettingConstants.US, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.US)));\r\n fixInserts.put(\r\n ZcSettingConstants.UK,\r\n factory.getFixInsertFees(ZcSettingConstants.UK, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.UK)));\r\n fixInserts.put(\r\n ZcSettingConstants.DE,\r\n factory.getFixInsertFees(ZcSettingConstants.DE, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.DE)));\r\n fixInserts.put(\r\n ZcSettingConstants.FR,\r\n factory.getFixInsertFees(ZcSettingConstants.FR, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.FR)));\r\n fixInserts.put(\r\n ZcSettingConstants.CA,\r\n factory.getFixInsertFees(ZcSettingConstants.CA, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.CA)));\r\n fixInserts.put(\r\n ZcSettingConstants.AU,\r\n factory.getFixInsertFees(ZcSettingConstants.AU, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.AU)));\r\n\r\n fixFVLs.put(ZcSettingConstants.FIX, \"成交费\");\r\n fixFVLs.put(\r\n ZcSettingConstants.US,\r\n factory.getFixFVLs(ZcSettingConstants.US, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.US), item.getCategoryType()));\r\n fixFVLs.put(\r\n ZcSettingConstants.UK,\r\n factory.getFixFVLs(ZcSettingConstants.UK, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.UK), item.getCategoryType()));\r\n fixFVLs.put(\r\n ZcSettingConstants.DE,\r\n factory.getFixFVLs(ZcSettingConstants.DE, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.DE), item.getCategoryType()));\r\n fixFVLs.put(\r\n ZcSettingConstants.FR,\r\n factory.getFixFVLs(ZcSettingConstants.FR, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.FR), item.getCategoryType()));\r\n fixFVLs.put(\r\n ZcSettingConstants.CA,\r\n factory.getFixFVLs(ZcSettingConstants.CA, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.CA), item.getCategoryType()));\r\n fixFVLs.put(\r\n ZcSettingConstants.AU,\r\n factory.getFixFVLs(ZcSettingConstants.AU, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.AU), item.getCategoryType()));\r\n\r\n fixPayPalFees.put(ZcSettingConstants.FIX, \"paypal费\");\r\n fixPayPalFees.put(\r\n ZcSettingConstants.US,\r\n factory.getFixPayPalFees(ZcSettingConstants.US, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.US),\r\n ebu.getCurencyValue(item.getEbShippingFee(), item.getCurrencyId(), ZcSettingConstants.US)));\r\n fixPayPalFees.put(\r\n ZcSettingConstants.UK,\r\n factory.getFixPayPalFees(ZcSettingConstants.UK, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.UK),\r\n ebu.getCurencyValue(item.getEbShippingFee(), item.getCurrencyId(), ZcSettingConstants.UK)));\r\n fixPayPalFees.put(\r\n ZcSettingConstants.DE,\r\n factory.getFixPayPalFees(ZcSettingConstants.DE, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.DE),\r\n ebu.getCurencyValue(item.getEbShippingFee(), item.getCurrencyId(), ZcSettingConstants.DE)));\r\n fixPayPalFees.put(\r\n ZcSettingConstants.FR,\r\n factory.getFixPayPalFees(ZcSettingConstants.FR, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.FR),\r\n ebu.getCurencyValue(item.getEbShippingFee(), item.getCurrencyId(), ZcSettingConstants.FR)));\r\n fixPayPalFees.put(\r\n ZcSettingConstants.CA,\r\n factory.getFixPayPalFees(ZcSettingConstants.CA, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.CA),\r\n ebu.getCurencyValue(item.getEbShippingFee(), item.getCurrencyId(), ZcSettingConstants.CA)));\r\n fixPayPalFees.put(\r\n ZcSettingConstants.AU,\r\n factory.getFixPayPalFees(ZcSettingConstants.AU, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.AU),\r\n ebu.getCurencyValue(item.getEbShippingFee(), item.getCurrencyId(), ZcSettingConstants.AU)));\r\n\r\n fixProfits.put(ZcSettingConstants.FIX, \"利润\");\r\n fixProfitRates.put(ZcSettingConstants.FIX, \"利润率\");\r\n\r\n if (item.getCost() != null && item.getTransportFee() != null) {\r\n\r\n EbProfit profit = getProfit(ebu.getRMBValue(item.getEbPrice(), item.getCurrencyId()),\r\n ebu.getRMBValue(item.getEbShippingFee(), item.getCurrencyId()), item.getCost(), item.getTransportFee(),\r\n ebu.getRMBValue((BigDecimal) fixInserts.get(ZcSettingConstants.US), ZcSettingConstants.CURENCY_USD),\r\n ebu.getRMBValue((BigDecimal) fixFVLs.get(ZcSettingConstants.US), ZcSettingConstants.CURENCY_USD),\r\n ebu.getRMBValue((BigDecimal) fixPayPalFees.get(ZcSettingConstants.US), ZcSettingConstants.CURENCY_USD));\r\n fixProfits.put(ZcSettingConstants.US, profit.getProfit());\r\n fixProfitRates.put(ZcSettingConstants.US, profit.getProfitRate());\r\n\r\n profit = getProfit(ebu.getRMBValue(item.getEbPrice(), item.getCurrencyId()), ebu.getRMBValue(item.getEbShippingFee(), item.getCurrencyId()),\r\n item.getCost(), item.getTransportFee(), ebu.getRMBValue((BigDecimal) fixInserts.get(ZcSettingConstants.UK), ZcSettingConstants.CURENCY_GBP),\r\n ebu.getRMBValue((BigDecimal) fixFVLs.get(ZcSettingConstants.UK), ZcSettingConstants.CURENCY_GBP),\r\n ebu.getRMBValue((BigDecimal) fixPayPalFees.get(ZcSettingConstants.UK), ZcSettingConstants.CURENCY_GBP));\r\n fixProfits.put(ZcSettingConstants.UK, profit.getProfit());\r\n fixProfitRates.put(ZcSettingConstants.UK, profit.getProfitRate());\r\n\r\n profit = getProfit(ebu.getRMBValue(item.getEbPrice(), item.getCurrencyId()), ebu.getRMBValue(item.getEbShippingFee(), item.getCurrencyId()),\r\n item.getCost(), item.getTransportFee(), ebu.getRMBValue((BigDecimal) fixInserts.get(ZcSettingConstants.DE), ZcSettingConstants.CURENCY_EUR),\r\n ebu.getRMBValue((BigDecimal) fixFVLs.get(ZcSettingConstants.DE), ZcSettingConstants.CURENCY_EUR),\r\n ebu.getRMBValue((BigDecimal) fixPayPalFees.get(ZcSettingConstants.DE), ZcSettingConstants.CURENCY_EUR));\r\n fixProfits.put(ZcSettingConstants.DE, profit.getProfit());\r\n fixProfitRates.put(ZcSettingConstants.DE, profit.getProfitRate());\r\n\r\n profit = getProfit(ebu.getRMBValue(item.getEbPrice(), item.getCurrencyId()), ebu.getRMBValue(item.getEbShippingFee(), item.getCurrencyId()),\r\n item.getCost(), item.getTransportFee(), ebu.getRMBValue((BigDecimal) fixInserts.get(ZcSettingConstants.FR), ZcSettingConstants.CURENCY_EUR),\r\n ebu.getRMBValue((BigDecimal) fixFVLs.get(ZcSettingConstants.FR), ZcSettingConstants.CURENCY_EUR),\r\n ebu.getRMBValue((BigDecimal) fixPayPalFees.get(ZcSettingConstants.FR), ZcSettingConstants.CURENCY_EUR));\r\n fixProfits.put(ZcSettingConstants.FR, profit.getProfit());\r\n fixProfitRates.put(ZcSettingConstants.FR, profit.getProfitRate());\r\n\r\n profit = getProfit(ebu.getRMBValue(item.getEbPrice(), item.getCurrencyId()), ebu.getRMBValue(item.getEbShippingFee(), item.getCurrencyId()),\r\n item.getCost(), item.getTransportFee(), ebu.getRMBValue((BigDecimal) fixInserts.get(ZcSettingConstants.CA), ZcSettingConstants.CURENCY_CAD),\r\n ebu.getRMBValue((BigDecimal) fixFVLs.get(ZcSettingConstants.CA), ZcSettingConstants.CURENCY_CAD),\r\n ebu.getRMBValue((BigDecimal) fixPayPalFees.get(ZcSettingConstants.CA), ZcSettingConstants.CURENCY_CAD));\r\n fixProfits.put(ZcSettingConstants.CA, profit.getProfit());\r\n fixProfitRates.put(ZcSettingConstants.CA, profit.getProfitRate());\r\n\r\n profit = getProfit(ebu.getRMBValue(item.getEbPrice(), item.getCurrencyId()), ebu.getRMBValue(item.getEbShippingFee(), item.getCurrencyId()),\r\n item.getCost(), item.getTransportFee(), ebu.getRMBValue((BigDecimal) fixInserts.get(ZcSettingConstants.AU), ZcSettingConstants.CURENCY_AUD),\r\n ebu.getRMBValue((BigDecimal) fixFVLs.get(ZcSettingConstants.AU), ZcSettingConstants.CURENCY_AUD),\r\n ebu.getRMBValue((BigDecimal) fixPayPalFees.get(ZcSettingConstants.AU), ZcSettingConstants.CURENCY_AUD));\r\n fixProfits.put(ZcSettingConstants.AU, profit.getProfit());\r\n fixProfitRates.put(ZcSettingConstants.AU, profit.getProfitRate());\r\n }\r\n return getFixTableModel();\r\n }", "public BigDecimal getTotalFee() {\n return totalFee;\n }", "public double FullfagetPrice()\n {\n double futlfaget = totalpris + fragt;\n return futlfaget;\n\n }", "@Override\n public double calcCost() {\n return calcSalesFee()+calcTaxes();\n }", "private void getOrderServiceFee(Long id) {\n new FetchOrderServiceFee(id, new FetchOrderServiceFee.InvokeOnCompleteAsync() {\n @Override\n public void onComplete(String orderServiceFee) {\n updateServiceFee(Float.valueOf(orderServiceFee));\n }\n\n @Override\n public void onError(Throwable e) {\n LoggerHelper.showErrorLog(\"Error: \", e);\n }\n });\n }", "public AmountType getFee() {\n\t return this.fee;\n\t}", "public double getTotalFactoringFee() {\n return totalFactoringFee;\n }", "public List<Fee> getCostsFor(Base base) throws IOException {\n\t\treturn Core.costsFor(base, getHttpMethodExecutor());\n\t}", "@Override\n\tpublic List<Fee_Entity> get_all_fee() {\n\t\treturn fee.get_all_fee();\n\t}", "public String getFee() {\n\t\treturn fee;\n\t}", "public void setEstimatedFees(BigDecimal aEstimatedFees) {\n estimatedFees = aEstimatedFees;\n }", "private BigDecimal getCardServiceFeeAmount(final CartReceiptResponse receiptResponse\n , final PdfPTable paymentSectionTable, final PdfPCell blankSpaceCell, final Locale locale) {\n\n \t/* Get funding source from the CART_RECEIPT_REPRINT response */\n final FundingSourceResponse[] fundingSource = receiptResponse.getFundingSources();\n final SubmittedBill[] submittedBills = receiptResponse.getSubmittedBills();\n /* Initializing serviceFee */\n final BigDecimal serviceFee = addServiceFee(submittedBills);\n for (final FundingSourceResponse aFundingSource : fundingSource) {\n /* Check for the DEBIT/CREDIT card instance */\n if (aFundingSource instanceof VestaFundingSourceResponse) {\n /* ServiceFeePercentRate is null treating it as ZERO other wise get the value */\n BigDecimal cardServiceFeePercent = aFundingSource.getServiceFeePercentRate() == null\n ? new BigDecimal(0) : aFundingSource.getServiceFeePercentRate();\n /* In case seviceFee amount is > ZERO then execute the below block of code to display the line above the total bills */\n if (serviceFee.compareTo(BigDecimal.ZERO) > 0 && cardServiceFeePercent.compareTo(BigDecimal.ZERO) > 0) {\n /* Cell for the card service percent label */\n Font font = getFont(null, FONT_SIZE_12, Font.NORMAL);\n String message = getMessage(locale, \"pdf.receipt.serviceFee\", cardServiceFeePercent);\n PdfPCell serviceFeeLabel = new PdfPCell(new Phrase(message, font));\n /* Cell for the card service fee amount */\n PdfPCell serviceFeeTotal = new PdfPCell(\n new Phrase(getFormattedAmount(serviceFee), font));\n /* Adding above cells to table */\n cellAlignment(serviceFeeLabel, Element.ALIGN_LEFT, WHITE_COLOR, 0);\n cellAddingToTable(paymentSectionTable, serviceFeeLabel, Rectangle.NO_BORDER, 2, 15);\n\n cellAlignment(serviceFeeTotal, Element.ALIGN_RIGHT, WHITE_COLOR, 0);\n cellAddingToTable(paymentSectionTable, serviceFeeTotal, Rectangle.NO_BORDER, 0, 0);\n\t\t\t\t\t/* Adding blank space to table */\n cellAlignment(blankSpaceCell, Element.ALIGN_LEFT, GRAY_COLOR, 0);\n cellAddingToTable(paymentSectionTable, blankSpaceCell, Rectangle.NO_BORDER, 3, 0);\n }\n }\n }\n return serviceFee;\n }", "void calculateReceivableByUIComponent() throws Exception{\t\t\n\t\tdouble receivableAmt = ConvertUtil.convertCTextToNumber(txtDueAmount).doubleValue();\t\n\t\tdouble receiveAmt = chkPayall.isSelected()?ConvertUtil.convertCTextToNumber(txtDueAmount).doubleValue()\n\t\t\t\t:ConvertUtil.convertCTextToNumber(txtReceiptAmount).doubleValue();\n\t\tdouble bfAmt = ConvertUtil.convertCTextToNumber(txtCustomerBF).doubleValue();\n\t\tdouble paidAmt = ConvertUtil.convertCTextToNumber(txtPaidAmount).doubleValue(); \n\t\tdouble cfAmt = bfAmt + receivableAmt - receiveAmt - paidAmt;\t\t\n\t\ttxtReceiptAmount.setText(SystemConfiguration.decfm.format(receiveAmt));\n\t\ttxtCustomerCfAmount.setText(SystemConfiguration.decfm.format(cfAmt));\t\n\t\ttxtReceiptAmount.selectAll();\n\t}", "private double calcuFcost() {\n\t\treturn num * configMap.get('r') + (num-1) * configMap.get('l') + num * configMap.get('f') + configMap.get('t');\n\t}", "private double computeFine(Transaction transaction){\n //initialize the totalFine as 0\n double totalFine = 0;\n //if the transactions status is true meaning it is still issued\n if (transaction.isStatus()==true) {\n //make a new LocalDate current and set it to now() (the current date)\n LocalDate current = LocalDate.now();\n //using the period class and its methods for manipulating LocalDates, make two new period objects\n //the first uses the .between method which returns the period between the transaction issueDate and the current time\n Period p1 = Period.between(transaction.getIssueDate(), current);\n //the second returns the period between the due date (use getDueDate method with the transaction issue date passed in) and current time\n Period p2 = Period.between(getDueDate(transaction.getIssueDate()), current);\n //use .getDays method to get the number of days from the first period and if that is greater than\n //the max amount of loan days then the book is overdue and a fine needs to be calculated since its been more\n //than 14 days since the issue date\n if (p1.getDays() > MAX_LOAN_DAYS) {\n //set the totalFine equal to $1 times each day past the due date, which we get from p2.getDays()\n //since p2 is the period between the due date and now (it will be positive since we know its past the due date because of the if condition)\n totalFine = 1 * p2.getDays();\n }\n }\n //return totalFine, if the status was false meaning it was returned it should still be 0\n return totalFine;\n }", "public void calculateFee(Map<TransactionEntry, List<Transaction>> transactionsMap, PrintStream out) {\n int nWorkerThreads = 8;\n ExecutorService pool = Executors.newFixedThreadPool(nWorkerThreads);\n Set<Future<String>> futures = new HashSet<>();\n try {\n CountDownLatch countDownLatch = new CountDownLatch(nWorkerThreads);\n Queue<TransactionEntry> transactionEntryQueue = new ConcurrentLinkedQueue<>(transactionsMap.keySet());\n for (int i = 0; i < nWorkerThreads; i++) {\n Callable<String> task = new FeeCalculatorWorker(transactionEntryQueue, transactionsMap, countDownLatch);\n Future<String> future = pool.submit(task);\n futures.add(future);\n }\n countDownLatch.await();\n // Just to ensure that we have result in future object. Result is returned after we decrement the countDownLatch\n Thread.sleep(100);\n } catch (InterruptedException e) {\n out.println(\"Exception occurred, while waiting for worker threads to finish! \" + e.getMessage());\n } finally {\n pool.shutdown();\n }\n out.println(\"Printing Future results!\");\n for (Future<String> future : futures) {\n try {\n String result = future.get();\n if (result != null) {\n out.println(result);\n } else {\n out.println(\"Future should not be NULL.\");\n }\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n }", "public void payFees(int feesPayed) {\n\t\tthis.feesPayed += feesPayed;\n\t\tSchool.addTotalMoneyEarned(feesPayed);\n\t}", "@Test\n public void computeFactor_SummerTimeDay() {\n long startTimeUsage = DateTimeHandling\n .calculateMillis(\"2012-03-22 00:00:00\");\n long endTimeUsage = DateTimeHandling\n .calculateMillis(\"2012-03-31 23:59:59\");\n BillingInput billingInput = BillingInputFactory.newBillingInput(\n \"2012-03-01 00:00:00\", \"2012-04-01 00:00:00\");\n\n // when\n double factor = calculator.computeFactor(PricingPeriod.DAY,\n billingInput, startTimeUsage, endTimeUsage, true, true);\n\n // then\n assertEquals(10, factor, 0);\n }", "public int calculateShippingFee(Order order) {\n\t\tRandom rand = new Random();\n\t\tint fees = (int) (((rand.nextFloat() * 10) / 100) * order.getAmount());\n\t\tLOGGER.info(\"Order Amount: \" + order.getAmount() + \" -- Shipping Fees: \" + fees);\n\t\treturn fees;\n\t}", "public int getRemainingFees() {\n\t\treturn totalFees - feesPayed;\n\t}", "@Override\n\tpublic Optional<EquityOrder> entryTick(\n\t final BrokerageTransactionFee fees,\n\t final CashAccount cashAccount,\n\t final TradingDayPrices data ) {\n\t\ttradingData.add(data);\n\n\t\tif (tradingData.size() == entry.requiredTradingPrices()) {\n\n\t\t\t// TODO change to avoid converting to a list\n\t\t\t// Create signals from the available trading data\n\t\t\tfinal List<DatedSignal> signals = entry.analyse(tradingData.toArray());\n\n\t\t\tif (hasDatedSignal(signals, data)) {\n\n\t\t\t\t// TODO do some better encapsulation / refactor\n\t\t\t\tfinal BigDecimal amount = entryPositionSizing.entryPositionSize(cashAccount);\n\t\t\t\tfinal LocalDate tradingDate = data.date();\n\t\t\t\tfinal BigDecimal maximumTransactionCost = fees.cost(amount, tradingDate);\n\t\t\t\tfinal BigDecimal closingPrice = data.closingPrice().price();\n\t\t\t\tfinal BigDecimal numberOfEquities = amount.subtract(maximumTransactionCost, MATH_CONTEXT)\n\t\t\t\t .divide(closingPrice, MATH_CONTEXT).setScale(scale, RoundingMode.DOWN);\n\n\t\t\t\tif (numberOfEquities.compareTo(BigDecimal.ZERO) > 0) {\n\t\t\t\t\treturn Optional\n\t\t\t\t\t .of(new BuyTotalCostTomorrowAtOpeningPriceOrder(amount, scale, tradingDate, MATH_CONTEXT));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn noOrder();\n\t}", "public void setFee(AmountType fee) {\n\t this.fee = fee;\n\t}", "public void setFee(String fee) {\n\t\tthis.fee = fee;\n\t}", "public lnrpc.Rpc.FeeReportResponse feeReport(lnrpc.Rpc.FeeReportRequest request) {\n return blockingUnaryCall(\n getChannel(), getFeeReportMethod(), getCallOptions(), request);\n }", "public void calc() {\n /*\n * Creates BigDecimals for each Tab.\n */\n BigDecimal registerSum = new BigDecimal(\"0.00\");\n BigDecimal rouleauSum = new BigDecimal(\"0.00\");\n BigDecimal coinageSum = new BigDecimal(\"0.00\");\n BigDecimal billSum = new BigDecimal(\"0.00\");\n /*\n * Iterates over all TextFields, where the User might have entered values into.\n */\n for (int i = 0; i <= 7; i++) {\n /*\n * If i <= 1 is true, we still have registerFields to add to their BigDecimal.\n */\n if (i <= 1) {\n try {\n /*\n * Stores the Text of the RegisterField at the index i with all non-digit characters.\n */\n String str = registerFields.get(i).getText().replaceAll(\"\\\\D\", \"\");\n /*\n * Creates a new BigDecimal, that is created by getting the Factor of the current \n * RegisterField and multiplying this with the input.\n */\n BigDecimal result = getFactor(i, FactorType.REGISTER).multiply(new BigDecimal(str));\n /*\n * Displays the result of the multiplication above in the associated Label.\n */\n registerLabels.get(i).setText(result.toString().replace('.', ',') + \"€\");\n /*\n * Adds the result of the multiplication to the BigDecimal for the RegisterTab.\n */\n registerSum = registerSum.add(result);\n } catch (NumberFormatException nfe) {\n //If the Input doesn't contain any numbers at all, a NumberFormatException is thrown, \n //but we don't have to do anything in this case\n }\n }\n /*\n * If i <= 4 is true, we still have rouleauFields to add to their BigDecimal.\n */\n if (i <= 4) {\n try {\n /*\n * See Documentation for the registerFields for Information.\n */\n String str = rouleauFields.get(i).getText().replaceAll(\"\\\\D\", \"\");\n BigDecimal sum = getFactor(i, FactorType.ROULEAU).multiply(new BigDecimal(str));\n rouleauLabels.get(i).setText(sum.toString().replace('.', ',') + \"€\");\n rouleauSum = rouleauSum.add(sum);\n } catch (NumberFormatException nfe) {\n //See above.\n }\n }\n /*\n * If i <= 6 is true, we still have billFields to add to their BigDecimal.\n */\n if (i <= 6) {\n try {\n /*\n * See Documentation for the registerFields for Information.\n */\n String str = billFields.get(i).getText().replaceAll(\"\\\\D\", \"\");\n BigDecimal sum = getFactor(i, FactorType.BILL).multiply(new BigDecimal(str));\n billLabels.get(i).setText(sum.toString().replace('.', ',') + \"€\");\n billSum = billSum.add(sum);\n } catch (NumberFormatException nfe) {\n //See above.\n }\n }\n /*\n * We have 8 coinageFields, so since the for-condition is 0 <= i <=7, we don't have to check \n * if i is in range and can simply calculate it's sum.\n */\n try {\n /*\n * See Documentation for the registerFields for Information.\n */\n String str = coinageFields.get(i).getText().replaceAll(\"\\\\D\", \"\");\n BigDecimal sum = getFactor(i, FactorType.COINAGE).multiply(new BigDecimal(str));\n coinageLabels.get(i).setText(sum.toString().replace('.', ',') + \"€\");\n coinageSum = coinageSum.add(sum);\n } catch (NumberFormatException nfe) {\n //See above.\n }\n }\n /*\n * Displays all results in the associated Labels.\n */\n sumLabels.get(0).setText(registerSum.toString().replace('.', ',') + \"€\");\n sumLabels.get(1).setText(rouleauSum.toString().replace('.', ',') + \"€\");\n sumLabels.get(2).setText(coinageSum.toString().replace('.', ',') + \"€\");\n sumLabels.get(3).setText(billSum.toString().replace('.', ',') + \"€\");\n sumLabels.get(4).setText(billSum.add(coinageSum).add(rouleauSum).add(registerSum).toString()\n .replace('.', ',') + \"€\");\n }", "public Double calculateTotal(String type, Double price, Double numberOfCoins, Double fees) {\n\t\tif (type == \"Kauf\") {\n\t\t\treturn (price * numberOfCoins) + fees;\n\t\t} else {\n\t\t\treturn ((price * numberOfCoins) + fees) * -1;\n\t\t}\n\t}", "private double calculateFeesEarnedEachDayOfWeek(ArrayList<Pair<Fees, Time>> timeslots, DayOfWeek day) {\n return daysOfWeek[day.ordinal()] * timeslots.stream()\n .filter(p -> convertDayOfWeek(p.getValue().getDay()).equals(day))\n .mapToDouble(p -> p.getValue().getTuitionHours() * p.getKey().getFeesValue())\n .sum();\n }", "BigDecimal getFare();", "public com.google.common.util.concurrent.ListenableFuture<lnrpc.Rpc.FeeReportResponse> feeReport(\n lnrpc.Rpc.FeeReportRequest request) {\n return futureUnaryCall(\n getChannel().newCall(getFeeReportMethod(), getCallOptions()), request);\n }", "public BigDecimal getGuaranteeFee() {\r\n return guaranteeFee;\r\n }", "private void checkPlan(TripResponse plan, Person[] people) {\n\n // count the debts and amounts\n ExpenseAnalytics analytics = new ExpenseAnalytics(people);\n List<Person> allDebtors = analytics.getDebtors();\n List<Person> allRecipients = analytics.getRecipients();\n\n // turn arrays into maps\n Map<String, Person> debtorsMap = allDebtors.stream()\n .collect(Collectors.toMap(Person::getName, p -> p));\n Map<String, Person> recipientsMap = allRecipients.stream()\n .collect(Collectors.toMap(Person::getName, p -> p));\n\n // run through all reimbursements\n for (Reimbursement reimbursement : plan.getReimbursements()) {\n assertThat(debtorsMap).containsKey(reimbursement.getName());\n\n Person debtor = debtorsMap.get(reimbursement.getName());\n double debt = debtor.getAmount();\n\n // perform all transactions\n for (Transaction transaction : reimbursement.getPayments()) {\n String recipientName = transaction.getRecipient();\n assertThat(recipientsMap).containsKey(recipientName);\n Person recipient = recipientsMap.get(recipientName);\n assertThat(debt).isGreaterThanOrEqualTo(transaction.getAmount());\n debt -= transaction.getAmount();\n recipient.setAmount(recipient.getAmount() - transaction.getAmount());\n\n // separately track how much they actually paid\n debtor.setTotal(debtor.getTotal() + transaction.getAmount());\n recipient.setTotal(recipient.getTotal() - transaction.getAmount());\n }\n\n debtor.setAmount(debt);\n }\n\n // check for all FRESHMAN debtors and recipients that the amounts have equalized\n Optional<Person> extremePerson;\n extremePerson = Stream.of(people).filter(p -> p.isFreshman())\n .max( (a, b) -> Double.compare(a.getTotal(), b.getTotal()) );\n double maxFreshmanTotal = extremePerson.isPresent() ? extremePerson.get().getTotal() : 0.0;\n extremePerson = Stream.of(people).filter(p -> p.isFreshman())\n .min( (a, b) -> Double.compare(a.getTotal(), b.getTotal()) );\n double minFreshmanTotal = extremePerson.isPresent() ? extremePerson.get().getTotal() : 0.0;\n logger.info(\"maximum FRESHMAN discrepancy = {}\", Math.abs(maxFreshmanTotal - minFreshmanTotal));\n\n // test maximum tolerance\n assertThat(Math.round(Math.abs(maxFreshmanTotal - minFreshmanTotal) * 100) / 100.0).isLessThanOrEqualTo(0.05);\n\n // check for all NON-freshman debtors and recipients that the amounts have equalized\n extremePerson = Stream.of(people).filter(p -> !p.isFreshman())\n .max( (a, b) -> Double.compare(a.getTotal(), b.getTotal()) );\n double maxNonFreshmanTotal = extremePerson.isPresent() ? extremePerson.get().getTotal() : 0.0;\n extremePerson = Stream.of(people).filter(p -> !p.isFreshman())\n .min( (a, b) -> Double.compare(a.getTotal(), b.getTotal()) );\n double minNonFreshmanTotal = extremePerson.isPresent() ? extremePerson.get().getTotal() : 0.0;\n logger.info(\"maximum non-FRESHMAN discrepancy = {}\", Math.abs(maxNonFreshmanTotal - minNonFreshmanTotal));\n\n // test maximum tolerance\n assertThat(Math.round(Math.abs(maxNonFreshmanTotal - minNonFreshmanTotal) * 100) / 100.0).isLessThanOrEqualTo(0.05);\n }", "public double getServiceFee() {\r\n\t\treturn 0.00;\r\n\t}", "@Override\n\tpublic double getRentalFee() {\n\t\treturn 10;\n\t}", "public double ticketPrice() {\n return ticketsCalculator.calculateTicketPrice();\n }", "public Number getFee() {\n return (Number) getAttributeInternal(FEE);\n }", "public double getContestFee() {\r\n return contestFee;\r\n }", "public double fineAsToHours(int numOfDays,int h1,int h2,int m1, int m2){\n double fine=0.0;\n int y=0;\n\n //if overdue is minus there is no need to calculate a fine\n if(numOfDays<0){\n fine=0.0;\n }\n\n //if it is 0 if the reader returns book on or before the due hour, again no fine\n //if reader returns book after due hour minutes will be taken in to count\n else if(numOfDays==0){\n if(h2<=h1){\n fine=0.0;\n }\n else{\n //ex:if due=10.30, returnTime=12.20, fine will be charged only for 10.30 to 11.30 period\n //which is returnTime-1-due\n if(m2<m1){\n y=(h2-h1)-1;\n fine=y*0.2;\n }\n //if returnTime=12.45 fine will be charged for 10.30 to 12.45 period\n //which is returnTime-due\n else if(m2>=m1){\n y=h2-h1;\n fine=y*0.2;\n }\n }\n }\n\n //if over due is 3days or less\n else if(numOfDays<=3){\n //ex: due=7th 10.30, returned=9th 9.30\n //finr will be charged for 24h and the extra hours from 8th, and extra hours from 9th\n if(h2<=h1){\n y=((numOfDays-1)*24)+((24-h1)+h2);\n fine=y*0.2;\n }\n else{\n //ex: due=7th 10.30, returned= 9th 12.15\n //total 2*24h will be added. plus, time period frm 9th 10.30 to 11.30\n if(m2<m1){\n y=(numOfDays*24)+((h2-h1)-1);\n fine=y*0.2;\n }\n else if(m2>=m1){\n //returned=9th 12.45\n //total 2*24h, plus 2hours difference from 10.30 to 12.30\n y=(numOfDays*24)+(h2-h1);\n fine=y*0.2;\n }\n }\n\n }\n\n\n //same logic and will multiply the 1st 3 days form 0.2 as to the requirement\n\n else if(numOfDays>3){\n if(h2<=h1){\n y=((numOfDays-4)*24)+((24-h1)+h2);\n fine=(y*0.5)+(24*3*0.2);\n }\n\n else{\n if(m2<m1){\n y=((numOfDays-3)*24)+((h2-h1)-1);\n fine=(y*0.5)+(3*24*0.2);\n }\n\n else if(m2>m1){\n y=((numOfDays-3)*24)+(h2-h1);\n fine=(y*0.5)+(3*24*0.2);\n }\n }\n\n\n }\n\n return fine;\n\n }", "public ArrayList<Fact> createFacts (MAcctSchema as)\n\t{\n\t\t// create Fact Header\n\t\tFact fact = new Fact(this, as, Fact.POST_Actual);\n\t\t//\tCash Transfer or Manual Deposit\n\t\tif ((\"X\".equals(m_TenderType) && !MSysConfig.getBooleanValue(\"CASH_AS_PAYMENT\", true, getAD_Client_ID()))\n\t\t\t\t|| \"G\".equals(m_TenderType))\n\t\t{\n\t\t\tArrayList<Fact> facts = new ArrayList<Fact>();\n\t\t\tfacts.add(fact);\n\t\t\treturn facts;\n\t\t}\n\n\t\tint AD_Org_ID = getBank_Org_ID();\t\t//\tBank Account Org\t\n\t\tif (getDocumentType().equals(DOCTYPE_ARReceipt))\n\t\t{\n\t\t\t//\tAsset\n\t\t\tFactLine fl = fact.createLine(null, getAccount(Doc.ACCTTYPE_BankInTransit, as),\n\t\t\t\tgetC_Currency_ID(), getAmount(), null);\n\t\t\tif (fl != null && AD_Org_ID != 0)\n\t\t\t\tfl.setAD_Org_ID(AD_Org_ID);\n\t\t\t//\t\n\t\t\tMAccount acct = null;\n\t\t\tif (getC_Charge_ID() != 0)\n\t\t\t\tacct = MCharge.getAccount(getC_Charge_ID(), as, getAmount());\n\t\t\telse if (m_Prepayment)\n\t\t\t\tacct = getAccount(Doc.ACCTTYPE_C_Prepayment, as);\n\t\t\telse\n\t\t\t\tacct = getAccount(Doc.ACCTTYPE_UnallocatedCash, as);\n\t\t\tfl = fact.createLine(null, acct,\n\t\t\t\tgetC_Currency_ID(), null, getAmount());\n\t\t\tif (fl != null && AD_Org_ID != 0\n\t\t\t\t&& getC_Charge_ID() == 0)\t\t//\tdon't overwrite charge\n\t\t\t\tfl.setAD_Org_ID(AD_Org_ID);\n\t\t}\n\t\t// APP\n\t\telse if (getDocumentType().equals(DOCTYPE_APPayment))\n\t\t{\n\t\t\tMAccount acct = null;\n\t\t\tif (getC_Charge_ID() != 0)\n\t\t\t\tacct = MCharge.getAccount(getC_Charge_ID(), as, getAmount());\n\t\t\telse if (m_Prepayment)\n\t\t\t\tacct = getAccount(Doc.ACCTTYPE_V_Prepayment, as);\n\t\t\telse\n\t\t\t\tacct = getAccount(Doc.ACCTTYPE_PaymentSelect, as);\n\t\t\tFactLine fl = fact.createLine(null, acct,\n\t\t\t\tgetC_Currency_ID(), getAmount(), null);\n\t\t\tif (fl != null && AD_Org_ID != 0\n\t\t\t\t&& getC_Charge_ID() == 0)\t\t//\tdon't overwrite charge\n\t\t\t\tfl.setAD_Org_ID(AD_Org_ID);\n\t\t\t\n\t\t\t//\tAsset\n\t\t\tfl = fact.createLine(null, getAccount(Doc.ACCTTYPE_BankInTransit, as),\n\t\t\t\tgetC_Currency_ID(), null, getAmount());\n\t\t\tif (fl != null && AD_Org_ID != 0)\n\t\t\t\tfl.setAD_Org_ID(AD_Org_ID);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tp_Error = \"DocumentType unknown: \" + getDocumentType();\n\t\t\tlog.log(Level.SEVERE, p_Error);\n\t\t\tfact = null;\n\t\t}\n\t\t//\n\t\tArrayList<Fact> facts = new ArrayList<Fact>();\n\t\tfacts.add(fact);\n\t\treturn facts;\n\t}", "public BigDecimal getMonthFee() {\r\n return monthFee;\r\n }", "public int mpesaFee(int numb){\n int numbFee = 0;\n\n if(numb <= 1){\n numbFee = 0;\n\n } else if (numb <= 100){\n numbFee = 1;\n\n } else if (numb <= 500){\n numbFee = 11;\n\n } else if (numb <= 1000){\n numbFee = 15;\n\n } else if (numb <= 1500){\n numbFee = 25;\n\n } else if (numb <= 2500){\n numbFee = 20;\n\n } else if (numb <= 3500){\n numbFee = 55;\n\n } else if (numb <= 5000){\n numbFee = 60;\n\n } else if (numb <= 7500){\n numbFee = 75;\n\n } else if (numb <= 10000){\n numbFee = 85;\n\n } else if (numb <= 15000){\n numbFee = 95;\n\n } else if (numb <= 20000){\n numbFee = 100;\n\n } else {\n numbFee = 110;\n\n }\n\n return numbFee;\n }", "public String getTotalAmountOfTicketFlight()\n\t{\n\t\tint sum;\n\n\t\tint departurePriceAtbottom = Integer.parseInt(getDepartureFlightPriceAtBottom().replaceAll(\"[Rs ,]\", \"\"));\n\t\tint returnPriceAtbottom = Integer.parseInt(getReturnFlightPriceAtBottom().replaceAll(\"[Rs ,]\", \"\"));\n\t\t\n\t\twaitForSeconds(5);\n\n\t\tif(driver.getPageSource().contains(\"Return trip discount\")) {\n\t\t\tint dAmount = Integer.parseInt(discountTagAmount.getText().replaceAll(\"[Rs ]\", \"\"));\n\t\t\tsum = (departurePriceAtbottom + returnPriceAtbottom)- dAmount;\n\n\t\t}\n\t\telse \n\t\t{\n\n\t\t\tsum = departurePriceAtbottom + returnPriceAtbottom;\n\t\t}\n\n\n\t\treturn String.valueOf(sum);\n\t}", "public double f(double t) {\r\n // For e = 0 (special case), the bids will drop linearly.\r\n if (e == 0)\r\n return k;\r\n\r\n double ft = 0;\r\n if(negotiationSession.getTime() > 0.7) {\r\n ft = k + (1 - k) * Math.pow(Math.min(t, deadLine.getValue())\r\n / deadLine.getValue(), 1.0 / e);\r\n }else{\r\n ft = k + (1 - k) * Math.pow(Math.min(t, getPseudoDeadline() )\r\n / getPseudoDeadline() , 1.0 / e);\r\n }\r\n return ft;\r\n }", "public void setContestFee(double contestFee) {\r\n this.contestFee = contestFee;\r\n }", "public MaintenanceRequestTask createVehicleRentalFeeLine(MaintenanceRequest mrq, String username){\n\t\tBigDecimal vehicleRentalFee = new BigDecimal(0.00); \n\t\tMaintenanceRequestTask task;\n\t\tMaintenanceRequestTask newFeeTask = new MaintenanceRequestTask();\n\t\tString defaultVehicleRentalFeeCategoryCode = willowConfigService.getConfigValue(\"MAINT_RENTAL_CAT_CODE\");\n\t\tString defaultVehicleRentalFeeRechargeCode = willowConfigService.getConfigValue(\"MAINT_RENTAL_RECH_CODE\");\n\t\tString defaultVehicleRentalFeeCode = willowConfigService.getConfigValue(\"MAINT_RENTAL_FEE_CODE\");\n\t\t\n\t\tLong maxLineNumber = nextMRTLineNumber(mrq);\n\t\n\t\tfor(Iterator<MaintenanceRequestTask> iter = mrq.getMaintenanceRequestTasks().iterator(); iter.hasNext();){\n\t\t\ttask = (MaintenanceRequestTask)iter.next();\n\t\t\tif(!MALUtilities.isEmpty(task.getMaintCatCode()) && task.getMaintCatCode().equals(defaultVehicleRentalFeeCategoryCode) &&\n\t\t\t\t\ttask.getMaintenanceCode().getCode().equals(defaultVehicleRentalFeeCode)){\t\t\t\t\n\t\t\t\titer.remove();\n\t\t\t}\n\t\t}\t\n\t\t\n\t\tvehicleRentalFee = calculateVehicleRentalFee(mrq);\n\t\t\n \tif(vehicleRentalFee.compareTo(new BigDecimal(0.00)) != 0){\t\n \t\tnewFeeTask.setMaintenanceRequest(mrq);\n \t\tnewFeeTask.setMaintCatCode(defaultVehicleRentalFeeCategoryCode);\n \t\tnewFeeTask.setMaintenanceCode(convertMaintenanceCode(defaultVehicleRentalFeeCode));\n \t\tnewFeeTask.setMaintenanceCodeDesc(convertMaintenanceCode(defaultVehicleRentalFeeCode).getDescription()); \n \t\tnewFeeTask.setWorkToBeDone(newFeeTask.getMaintenanceCodeDesc());\n \t\tnewFeeTask.setTaskQty(new BigDecimal(1));\n \t\tnewFeeTask.setUnitCost(new BigDecimal(0.00));\n \t\tnewFeeTask.setTotalCost(new BigDecimal(0.00));\n \t\tnewFeeTask.setRechargeFlag(MalConstants.FLAG_Y);\n \t\tnewFeeTask.setRechargeCode(defaultVehicleRentalFeeRechargeCode);\n \t\tnewFeeTask.setRechargeQty(new BigDecimal(1));\n \t\tnewFeeTask.setRechargeUnitCost(vehicleRentalFee);\n \t\tnewFeeTask.setRechargeTotalCost(newFeeTask.getRechargeUnitCost().multiply(newFeeTask.getRechargeQty()));\n \t\tnewFeeTask.setActualRechargeCost(newFeeTask.getRechargeTotalCost());\n \t\tnewFeeTask.setDiscountFlag(MalConstants.FLAG_N);\n \t\tnewFeeTask.setOutstanding(DataConstants.DEFAULT_N);\n \t\tnewFeeTask.setWasOutstanding(DataConstants.DEFAULT_N); \n \t\tnewFeeTask.setAuthorizePerson(username);\n \t\tnewFeeTask.setAuthorizeDate(Calendar.getInstance().getTime());\n \t\tnewFeeTask.setLineNumber(maxLineNumber+=1);\n \t}\t\n\n\t\treturn newFeeTask;\n \n\t}", "public float calculatePrice(Airline flight, String type, int baggage);", "public void setTotalFactoringFee(double totalFactoringFee) {\n this.totalFactoringFee = totalFactoringFee;\n }", "public static double getErf(int credits){\r\n double erf = 0;\r\n if(credits >= 7){\r\n erf = 100;\r\n }\r\n else{\r\n erf = 60;\r\n }\r\n return erf;\r\n }", "public static void main(String[] args) {\n\n\t\tBigDecimal bigDec=new BigDecimal(0.01119);\n\t\tfloat ff=bigDec.setScale(2 , BigDecimal.ROUND_UP).floatValue();\n\t\tint myInt = (int) (ff * 100);\n\t\tSystem.out.println(\"ff is \" + ff + \" int myInt is: \" + myInt);\n\t\t\n\t\tBigDecimal amount = new BigDecimal(0.01119);\n\t\tBigDecimal refund_amount = new BigDecimal(0.01119);\t\t\n\t\tBigDecimal tmpBig = new BigDecimal(amount.doubleValue());\n\t\tfloat tmpFloat = tmpBig.setScale(2 , BigDecimal.ROUND_UP).floatValue();\n\t\tString total_fee = \"\" + (int) (tmpFloat * 100);\n\n\t\ttmpBig = new BigDecimal(refund_amount.doubleValue());\n\t\ttmpFloat = tmpBig.setScale(2 , BigDecimal.ROUND_DOWN).floatValue();\n\t\tString refunds_fee = \"\" + (int) (tmpFloat * 100);\n\t\tSystem.out.println(\"total_fee is \" + total_fee + \" refunds_fee is: \" + refunds_fee);\n\t\t\n\t\t\n\t}", "public void updateFeesPaid(int feesPaid) {\r\n\t\tthis.feesPaid += feesPaid;\r\n\t\tSchool.updateTotalMoneyEarned(feesPaid);\r\n\t}", "void chargeTf(double amount);", "public int getEntryFee() {\n\t\treturn entryFee;\n\t}", "@Override\n\tpublic BigDecimal queryTotalFeeByDelevyCode(String code, Date recevieDate) {\n\t\treturn null;\n\t}", "public BigDecimal getwPrFee() {\n return wPrFee;\n }", "public ArrayList<Fact> createFacts (MAcctSchema as)\r\n\t{\r\n\t\t// create Fact Header\r\n\t\tFact fact = new Fact(this, as, Fact.POST_Actual);\r\n\t\tsetC_Currency_ID (as.getC_Currency_ID());\r\n\r\n\t\t// Line pointer\r\n\t\tFactLine fl = null;\r\n\t\tX_M_Production prod = (X_M_Production)getPO();\r\n\t\tHashMap<String, BigDecimal> costMap = new HashMap<String, BigDecimal>();\r\n\r\n\t\tfor (int i = 0; i < p_lines.length; i++)\r\n\t\t{\r\n\t\t\tDocLine line = p_lines[i];\r\n\t\t\t//\tCalculate Costs\r\n\t\t\tBigDecimal costs = BigDecimal.ZERO;\r\n\t\t\t\r\n\t\t\tX_M_ProductionLine prodline = (X_M_ProductionLine)line.getPO();\r\n\t\t\tMProductionLineMA mas[] = MProductionLineMA.get(getCtx(), prodline.get_ID(), getTrxName());\r\n\t\t\tMProduct product = (MProduct) prodline.getM_Product();\r\n\t\t\tString CostingLevel = product.getCostingLevel(as);\r\n\r\n\t\t\tif (MAcctSchema.COSTINGLEVEL_BatchLot.equals(CostingLevel) ) \r\n\t\t\t{\r\n\t\t\t\tif (line.getM_AttributeSetInstance_ID() == 0 && (mas!=null && mas.length> 0 )) \r\n\t\t\t\t{\r\n\t\t\t\t\tfor (int j = 0; j < mas.length; j++)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tMProductionLineMA ma = mas[j];\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\tMCostDetail cd = MCostDetail.get (as.getCtx(), \"M_ProductionLine_ID=?\",\r\n\t\t\t\t\t\t\t\tline.get_ID(), ma.getM_AttributeSetInstance_ID(), as.getC_AcctSchema_ID(), getTrxName());\t\r\n\t\t\t\t\t\tif (cd != null)\r\n\t\t\t\t\t\t\tcosts = costs.add(cd.getAmt());\t\r\n\t\t\t\t\t\telse \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tProductCost pc = line.getProductCost();\r\n\t\t\t\t\t\t\tpc.setQty(ma.getMovementQty());\r\n\t\t\t\t\t\t\tpc.setM_M_AttributeSetInstance_ID(ma.getM_AttributeSetInstance_ID());\r\n\t\t\t\t\t\t\tcosts = costs.add(line.getProductCosts(as, line.getAD_Org_ID(), false));\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcostMap.put(line.get_ID()+ \"_\"+ ma.getM_AttributeSetInstance_ID(), costs);\r\n\t\t\t\t\t}\r\n\t\t\t\t} \r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tMCostDetail cd = MCostDetail.get (as.getCtx(), \"M_ProductionLine_ID=?\",\r\n\t\t\t\t\t\t\tline.get_ID(), line.getM_AttributeSetInstance_ID(), as.getC_AcctSchema_ID(), getTrxName());\r\n\t\t\t\t\tif (cd != null) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcosts = cd.getAmt();\r\n\t\t\t\t\t} \r\n\t\t\t\t\telse \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcosts = line.getProductCosts(as, line.getAD_Org_ID(), false);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcostMap.put(line.get_ID()+ \"_\"+ line.getM_AttributeSetInstance_ID(), costs);\r\n\t\t\t\t}\r\n\t\t\t\r\n\t\t\t} \r\n\t\t\telse \r\n\t\t\t{\r\n\t\t\t\r\n\t\t\t\t// MZ Goodwill\r\n\t\t\t\t// if Production CostDetail exist then get Cost from Cost Detail\r\n\t\t\t\tMCostDetail cd = MCostDetail.get (as.getCtx(), \"M_ProductionLine_ID=?\",\r\n\t\t\t\t\t\tline.get_ID(), line.getM_AttributeSetInstance_ID(), as.getC_AcctSchema_ID(), getTrxName());\r\n\t\t\t\tif (cd != null) \r\n\t\t\t\t{\r\n\t\t\t\t\tcosts = cd.getAmt();\r\n\t\t\t\t} \r\n\t\t\t\telse \r\n\t\t\t\t{\r\n\t\t\t\t\tint ProductLabor_ID = MSysConfig.getIntValue(\"PRODUCT_LABOR\", -1, prod.getAD_Client_ID());\r\n\t\t\t\t\tBigDecimal laborPrice = (BigDecimal) prod.get_Value (\"PriceEntered\");\r\n\t\t\t\t\t//\r\n\t\t\t\t\tif (ProductLabor_ID > 0 \r\n\t\t\t\t\t\t\t&& line.getM_Product_ID() == ProductLabor_ID\r\n\t\t\t\t\t\t\t&& laborPrice != null && laborPrice.signum() == 1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcosts = laborPrice.multiply(prod.getProductionQty().negate());\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcosts = line.getProductCosts(as, line.getAD_Org_ID(), false);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tcostMap.put(line.get_ID()+ \"_\"+ line.getM_AttributeSetInstance_ID(), costs);\r\n\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tBigDecimal bomCost = Env.ZERO;\t\r\n\t\t\tBigDecimal qtyProduced = null;\r\n\t\t\tif (line.isProductionBOM())\r\n\t\t\t{\r\n\t\t\t\tX_M_ProductionLine endProLine = (X_M_ProductionLine)line.getPO();\r\n\t\t\t\tObject parentEndPro = prod.isUseProductionPlan()?endProLine.getM_ProductionPlan_ID():endProLine.getM_Production_ID();\r\n\t\t\t\t\r\n\t\t\t\t//\tGet BOM Cost - Sum of individual lines\t\t\t\t\r\n\t\t\t\tfor (int ii = 0; ii < p_lines.length; ii++)\r\n\t\t\t\t{\r\n\t\t\t\t\tDocLine line0 = p_lines[ii];\r\n\t\t\t\t\tX_M_ProductionLine bomProLine = (X_M_ProductionLine)line0.getPO();\r\n\t\t\t\t\tObject parentBomPro = prod.isUseProductionPlan()?bomProLine.getM_ProductionPlan_ID():bomProLine.getM_Production_ID();\r\n\t\t\t\t\t\r\n\t\t\t\t\tif (!parentBomPro.equals(parentEndPro))\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\tif (!line0.isProductionBOM()) {\r\n\t\t\t\t\t\tMProduct product0 = (MProduct) bomProLine.getM_Product();\r\n\t\t\t\t\t\tString CostingLevel0 = product0.getCostingLevel(as);\r\n\t\t\t\t\t\tif (MAcctSchema.COSTINGLEVEL_BatchLot.equals(CostingLevel0) )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (bomProLine.getM_AttributeSetInstance_ID() == 0 ) \r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tMProductionLineMA bomLineMA[] = MProductionLineMA.get(getCtx(), line0.get_ID(), getTrxName());\r\n\t\t\t\t\t\t\t\tif (bomLineMA!=null && bomLineMA.length> 0 )\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t // get cost of children for batch costing level (auto generate)\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\tBigDecimal costs0 = BigDecimal.ZERO ;\r\n\t\t\t\t\t\t\t\t\tfor (int j = 0; j < bomLineMA.length; j++)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tBigDecimal maCost = BigDecimal.ZERO ;\r\n\t\t\t\t\t\t\t\t\t\tMProductionLineMA ma = bomLineMA[j];\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t// get cost of children\r\n\t\t\t\t\t\t\t\t\t\tMCostDetail cd0 = MCostDetail.get (as.getCtx(), \"M_ProductionLine_ID=?\",\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\tline0.get_ID(), ma.getM_AttributeSetInstance_ID(), as.getC_AcctSchema_ID(), getTrxName());\r\n\t\t\t\t\t\t\t\t\t\tif (cd0 != null) \r\n\t\t\t\t\t\t\t\t\t\t\tmaCost = cd0.getAmt();\r\n\t\t\t\t\t\t\t\t\t\telse \r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tProductCost pc = line0.getProductCost();\r\n\t\t\t\t\t\t\t\t\t\t\tpc.setQty(ma.getMovementQty());\r\n\t\t\t\t\t\t\t\t\t\t\tpc.setM_M_AttributeSetInstance_ID(ma.getM_AttributeSetInstance_ID());\r\n\t\t\t\t\t\t\t\t\t\t\tmaCost = line0.getProductCosts(as, line0.getAD_Org_ID(), false);\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\tcostMap.put(line0.get_ID()+ \"_\"+ ma.getM_AttributeSetInstance_ID(),maCost);\r\n\t\t\t\t\t\t\t\t\t\tcosts0 = costs0.add(maCost);\r\n\t\t\t\t\t\t\t\t\t}\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\tbomCost = bomCost.add(costs0.setScale(2,RoundingMode.HALF_UP));\r\n\t\t\t\t\t\t\t\t} \r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\tp_Error = \"Failed to post - No Attribute Set for line\";\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t} \r\n\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t// get cost of children for batch costing level \r\n\t\t\t\t\t\t\t\tMCostDetail cd0 = MCostDetail.get (as.getCtx(), \"M_ProductionLine_ID=?\",\r\n\t\t\t\t\t\t\t\t\t\tline0.get_ID(), line0.getM_AttributeSetInstance_ID(), as.getC_AcctSchema_ID(), getTrxName());\r\n\t\t\t\t\t\t\t\tBigDecimal costs0;\r\n\t\t\t\t\t\t\t\tif (cd0 != null) \r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tcosts0 = cd0.getAmt();\r\n\t\t\t\t\t\t\t\t} \r\n\t\t\t\t\t\t\t\telse \r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tcosts0 = line0.getProductCosts(as, line0.getAD_Org_ID(), false);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tcostMap.put(line0.get_ID()+ \"_\"+ line0.getM_AttributeSetInstance_ID(),costs0);\r\n\t\t\t\t\t\t\t\tbomCost = bomCost.add(costs0.setScale(2,RoundingMode.HALF_UP));\t\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t} \r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t// get cost of children\r\n\t\t\t\t\t\t\tMCostDetail cd0 = MCostDetail.get (as.getCtx(), \"M_ProductionLine_ID=?\",\r\n\t\t\t\t\t\t\t\t\tline0.get_ID(), line0.getM_AttributeSetInstance_ID(), as.getC_AcctSchema_ID(), getTrxName());\r\n\t\t\t\t\t\t\tBigDecimal costs0;\r\n\t\t\t\t\t\t\tif (cd0 != null) \r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tcosts0 = cd0.getAmt();\r\n\t\t\t\t\t\t\t} \r\n\t\t\t\t\t\t\telse \r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tint ProductLabor_ID = MSysConfig.getIntValue(\"PRODUCT_LABOR\", -1, prod.getAD_Client_ID());\r\n\t\t\t\t\t\t\t\tBigDecimal laborPrice = (BigDecimal) prod.get_Value (\"PriceEntered\");\r\n\t\t\t\t\t\t\t\t//\r\n\t\t\t\t\t\t\t\tif (ProductLabor_ID > 0 \r\n\t\t\t\t\t\t\t\t\t\t&& line0.getM_Product_ID() == ProductLabor_ID\r\n\t\t\t\t\t\t\t\t\t\t&& laborPrice != null && laborPrice.signum() == 1)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tcosts0 = laborPrice.multiply(prod.getProductionQty().negate());\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tcosts0 = line.getProductCosts(as, line0.getAD_Org_ID(), false);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tcostMap.put(line0.get_ID()+ \"_\"+ line0.getM_AttributeSetInstance_ID(),costs0);\r\n\t\t\t\t\t\t\tbomCost = bomCost.add(costs0.setScale(2,RoundingMode.HALF_UP));\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tqtyProduced = manipulateQtyProduced (mQtyProduced, endProLine, prod.isUseProductionPlan(), null);\r\n\t\t\t\tif (line.getQty().compareTo(qtyProduced) != 0) \r\n\t\t\t\t{\r\n\t\t\t\t\tBigDecimal factor = line.getQty().divide(qtyProduced, 12, RoundingMode.HALF_UP);\r\n\t\t\t\t\tbomCost = bomCost.multiply(factor).setScale(2,RoundingMode.HALF_UP);\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tif (MAcctSchema.COSTINGLEVEL_BatchLot.equals(CostingLevel))\r\n\t\t\t\t{\r\n\t\t\t\t\t//post roll-up \r\n\t\t\t\t\tfl = fact.createLine(line, \r\n\t\t\t\t\t\t\tline.getAccount(ProductCost.ACCTTYPE_P_Asset, as),\r\n\t\t\t\t\t\t\tas.getC_Currency_ID(), bomCost.negate()); \r\n\t\t\t\t\tif (fl == null) \r\n\t\t\t\t\t{ \r\n\t\t\t\t\t\tp_Error = \"Couldn't post roll-up \" + line.getLine() + \" - \" + line; \r\n\t\t\t\t\t\treturn null; \r\n\t\t\t\t\t}\r\n\t\t\t\t\tfl.setQty(qtyProduced);\t\t\t\t\r\n\t\t\t\t} \r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tint precision = as.getStdPrecision();\r\n\t\t\t\t\tBigDecimal variance = (costs.setScale(precision, RoundingMode.HALF_UP)).subtract(bomCost.negate());\r\n\t\t\t\t\t// only post variance if it's not zero \r\n\t\t\t\t\tif (variance.signum() != 0) \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t//post variance \r\n//\t\t\t\t\t\tfl = fact.createLine(line, \r\n//\t\t\t\t\t\t\t\tline.getAccount(ProductCost.ACCTTYPE_P_RateVariance, as),\r\n//\t\t\t\t\t\t\t\tas.getC_Currency_ID(), variance.negate()); \r\n//\t\t\t\t\t\tif (fl == null) \r\n//\t\t\t\t\t\t{ \r\n//\t\t\t\t\t\t\tp_Error = \"Couldn't post variance \" + line.getLine() + \" - \" + line; \r\n//\t\t\t\t\t\t\treturn null; \r\n//\t\t\t\t\t\t}\r\n//\t\t\t\t\t\tfl.setQty(Env.ZERO);\r\n\t\t\t\t\t\tcosts = costs.add(variance.negate());\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// end MZ\r\n\r\n\t\t\t// Inventory DR CR\r\n\t\t\tif (!(line.isProductionBOM() && MAcctSchema.COSTINGLEVEL_BatchLot.equals(CostingLevel)))\r\n\t\t\t{\r\n\t\t\t\tfl = fact.createLine(line,\r\n\t\t\t\t\tline.getAccount(ProductCost.ACCTTYPE_P_Asset, as),\r\n\t\t\t\t\tas.getC_Currency_ID(), costs);\r\n\t\t\t\tif (fl == null)\r\n\t\t\t\t{\r\n\t\t\t\t\tp_Error = \"No Costs for Line \" + line.getLine() + \" - \" + line;\r\n\t\t\t\t\treturn null;\r\n\t\t\t\t}\r\n\t\t\t\tfl.setM_Locator_ID(line.getM_Locator_ID());\r\n\t\t\t\tfl.setQty(line.getQty());\r\n\t\t\t}\r\n\r\n\t\t\t//\tCost Detail\r\n\t\t\tString description = line.getDescription();\r\n\t\t\tif (description == null)\r\n\t\t\t\tdescription = \"\";\r\n\t\t\tif (line.isProductionBOM())\r\n\t\t\t\tdescription += \"(*)\";\r\n\t\t\tif (MAcctSchema.COSTINGLEVEL_BatchLot.equals(CostingLevel)) \r\n\t\t\t{\r\n\t\t\t\tif (line.isProductionBOM())\r\n\t\t\t\t{\r\n\t\t\t\t\tif (!MCostDetail.createProduction(as, line.getAD_Org_ID(),\r\n\t\t\t\t\t\t\tline.getM_Product_ID(), line.getM_AttributeSetInstance_ID(),\r\n\t\t\t\t\t\t\tline.get_ID(), 0,\r\n\t\t\t\t\t\t\tbomCost.negate(), qtyProduced,\r\n\t\t\t\t\t\t\tdescription, getTrxName()))\r\n\t\t\t\t\t {\r\n\t\t\t\t\t\t p_Error = \"Failed to create cost detail record\";\r\n\t\t\t\t\t\t return null;\r\n\t\t\t\t\t }\r\n\t\t\t\t}\r\n\t\t\t\telse if (line.getM_AttributeSetInstance_ID() == 0 && (mas!=null && mas.length> 0 ))\r\n\t\t\t\t{\r\n\t\t\t\t\t for (int j = 0; j < mas.length; j++)\r\n\t\t\t\t\t {\r\n\t\t\t\t\t\tMProductionLineMA ma = mas[j];\r\n\t\t\t\t\t\tBigDecimal maCost = costMap.get(line.get_ID()+ \"_\"+ ma.getM_AttributeSetInstance_ID());\t\t\r\n\t\t\t\t\t\tif (!MCostDetail.createProduction(as, line.getAD_Org_ID(),\r\n\t\t\t\t\t\t\t\tline.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(),\r\n\t\t\t\t\t\t\t\tline.get_ID(), 0,\r\n\t\t\t\t\t\t\t\tmaCost, ma.getMovementQty(),\r\n\t\t\t\t\t\t\t\tdescription, getTrxName()))\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tp_Error = \"Failed to create cost detail record\";\r\n\t\t\t\t\t\t\treturn null;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t }\r\n\t\t\t\t } \r\n\t\t\t\t else\r\n\t\t\t\t {\r\n\t\t\t\t\t \r\n\t\t\t\t\t if (!MCostDetail.createProduction(as, line.getAD_Org_ID(),\r\n\t\t\t\t\t\t\tline.getM_Product_ID(), line.getM_AttributeSetInstance_ID(),\r\n\t\t\t\t\t\t\tline.get_ID(), 0,\r\n\t\t\t\t\t\t\tcosts, line.getQty(),\r\n\t\t\t\t\t\t\tdescription, getTrxName()))\r\n\t\t\t\t\t {\r\n\t\t\t\t\t\t p_Error = \"Failed to create cost detail record\";\r\n\t\t\t\t\t\t return null;\r\n\t\t\t\t\t } \r\n\t\t\t\t }\r\n\t\t\t} \r\n\t\t\telse\r\n\t\t\t{\t\t\t \r\n\t\t\t\tif (!MCostDetail.createProduction(as, line.getAD_Org_ID(),\r\n\t\t\t\t\tline.getM_Product_ID(), line.getM_AttributeSetInstance_ID(),\r\n\t\t\t\t\tline.get_ID(), 0,\r\n\t\t\t\t\tcosts, line.getQty(),\r\n\t\t\t\t\tdescription, getTrxName()))\r\n\t\t\t\t{\r\n\t\t\t\t\tp_Error = \"Failed to create cost detail record\";\r\n\t\t\t\t\treturn null;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t//\r\n\t\tArrayList<Fact> facts = new ArrayList<Fact>();\r\n\t\tfacts.add(fact);\r\n\t\treturn facts;\r\n\t}", "public TableModel cacualateChineseFee(EbCandidateItem item) {\n EbFeeCaculaterFactory factory = EbFeeCaculaterFactory.getInstance();\r\n EbUtil ebu = new EbUtil();\r\n chineseInserts.put(ZcSettingConstants.CHINESE, \"上架费\");\r\n chineseInserts.put(\r\n ZcSettingConstants.US,\r\n factory.getChineseInsertFees(ZcSettingConstants.US, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.US)));\r\n chineseInserts.put(\r\n ZcSettingConstants.UK,\r\n factory.getChineseInsertFees(ZcSettingConstants.UK, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.UK)));\r\n chineseInserts.put(\r\n ZcSettingConstants.DE,\r\n factory.getChineseInsertFees(ZcSettingConstants.DE, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.DE)));\r\n chineseInserts.put(\r\n ZcSettingConstants.FR,\r\n factory.getChineseInsertFees(ZcSettingConstants.FR, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.FR)));\r\n chineseInserts.put(\r\n ZcSettingConstants.CA,\r\n factory.getChineseInsertFees(ZcSettingConstants.CA, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.CA)));\r\n chineseInserts.put(\r\n ZcSettingConstants.AU,\r\n factory.getChineseInsertFees(ZcSettingConstants.AU, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.AU)));\r\n\r\n chineseFVLs.put(ZcSettingConstants.CHINESE, \"成交费\");\r\n chineseFVLs.put(\r\n ZcSettingConstants.US,\r\n factory.getChineseFVLs(ZcSettingConstants.US, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.US), item.getCategoryType()));\r\n chineseFVLs.put(\r\n ZcSettingConstants.UK,\r\n factory.getChineseFVLs(ZcSettingConstants.UK, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.UK), item.getCategoryType()));\r\n chineseFVLs.put(\r\n ZcSettingConstants.DE,\r\n factory.getChineseFVLs(ZcSettingConstants.DE, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.DE), item.getCategoryType()));\r\n chineseFVLs.put(\r\n ZcSettingConstants.FR,\r\n factory.getChineseFVLs(ZcSettingConstants.FR, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.FR), item.getCategoryType()));\r\n chineseFVLs.put(\r\n ZcSettingConstants.CA,\r\n factory.getChineseFVLs(ZcSettingConstants.CA, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.CA), item.getCategoryType()));\r\n chineseFVLs.put(\r\n ZcSettingConstants.AU,\r\n factory.getChineseFVLs(ZcSettingConstants.AU, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.AU), item.getCategoryType()));\r\n\r\n chinesePayPalFees.put(ZcSettingConstants.CHINESE, \"paypal费\");\r\n chinesePayPalFees.put(\r\n ZcSettingConstants.US,\r\n factory.getChinesePayPalFees(ZcSettingConstants.US, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.US),\r\n ebu.getCurencyValue(item.getEbShippingFee(), item.getCurrencyId(), ZcSettingConstants.US)));\r\n chinesePayPalFees.put(\r\n ZcSettingConstants.UK,\r\n factory.getChinesePayPalFees(ZcSettingConstants.UK, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.UK),\r\n ebu.getCurencyValue(item.getEbShippingFee(), item.getCurrencyId(), ZcSettingConstants.UK)));\r\n chinesePayPalFees.put(\r\n ZcSettingConstants.DE,\r\n factory.getChinesePayPalFees(ZcSettingConstants.DE, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.DE),\r\n ebu.getCurencyValue(item.getEbShippingFee(), item.getCurrencyId(), ZcSettingConstants.DE)));\r\n chinesePayPalFees.put(\r\n ZcSettingConstants.FR,\r\n factory.getChinesePayPalFees(ZcSettingConstants.FR, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.FR),\r\n ebu.getCurencyValue(item.getEbShippingFee(), item.getCurrencyId(), ZcSettingConstants.FR)));\r\n chinesePayPalFees.put(\r\n ZcSettingConstants.CA,\r\n factory.getChinesePayPalFees(ZcSettingConstants.CA, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.CA),\r\n ebu.getCurencyValue(item.getEbShippingFee(), item.getCurrencyId(), ZcSettingConstants.CA)));\r\n chinesePayPalFees.put(\r\n ZcSettingConstants.AU,\r\n factory.getChinesePayPalFees(ZcSettingConstants.AU, ZcSettingConstants.STORE_TYPE_BASIC,\r\n ebu.getCurencyValue(item.getEbPrice(), item.getCurrencyId(), ZcSettingConstants.AU),\r\n ebu.getCurencyValue(item.getEbShippingFee(), item.getCurrencyId(), ZcSettingConstants.AU)));\r\n\r\n chineseProfits.put(ZcSettingConstants.CHINESE, \"利润\");\r\n chineseProfitRates.put(ZcSettingConstants.CHINESE, \"利润率\");\r\n if (item.getCost() != null && item.getTransportFee() != null) {\r\n\r\n EbProfit profit = getProfit(ebu.getRMBValue(item.getEbPrice(), item.getCurrencyId()),\r\n ebu.getRMBValue(item.getEbShippingFee(), item.getCurrencyId()), item.getCost(), item.getTransportFee(),\r\n ebu.getRMBValue((BigDecimal) chineseInserts.get(ZcSettingConstants.US), ZcSettingConstants.CURENCY_USD),\r\n ebu.getRMBValue((BigDecimal) chineseFVLs.get(ZcSettingConstants.US), ZcSettingConstants.CURENCY_USD),\r\n ebu.getRMBValue((BigDecimal) chinesePayPalFees.get(ZcSettingConstants.US), ZcSettingConstants.CURENCY_USD));\r\n chineseProfits.put(ZcSettingConstants.US, profit.getProfit());\r\n chineseProfitRates.put(ZcSettingConstants.US, profit.getProfitRate());\r\n\r\n profit = getProfit(ebu.getRMBValue(item.getEbPrice(), item.getCurrencyId()), ebu.getRMBValue(item.getEbShippingFee(), item.getCurrencyId()),\r\n item.getCost(), item.getTransportFee(),\r\n ebu.getRMBValue((BigDecimal) chineseInserts.get(ZcSettingConstants.UK), ZcSettingConstants.CURENCY_GBP),\r\n ebu.getRMBValue((BigDecimal) chineseFVLs.get(ZcSettingConstants.UK), ZcSettingConstants.CURENCY_GBP),\r\n ebu.getRMBValue((BigDecimal) chinesePayPalFees.get(ZcSettingConstants.UK), ZcSettingConstants.CURENCY_GBP));\r\n chineseProfits.put(ZcSettingConstants.UK, profit.getProfit());\r\n chineseProfitRates.put(ZcSettingConstants.UK, profit.getProfitRate());\r\n\r\n profit = getProfit(ebu.getRMBValue(item.getEbPrice(), item.getCurrencyId()), ebu.getRMBValue(item.getEbShippingFee(), item.getCurrencyId()),\r\n item.getCost(), item.getTransportFee(),\r\n ebu.getRMBValue((BigDecimal) chineseInserts.get(ZcSettingConstants.DE), ZcSettingConstants.CURENCY_EUR),\r\n ebu.getRMBValue((BigDecimal) chineseFVLs.get(ZcSettingConstants.DE), ZcSettingConstants.CURENCY_EUR),\r\n ebu.getRMBValue((BigDecimal) chinesePayPalFees.get(ZcSettingConstants.DE), ZcSettingConstants.CURENCY_EUR));\r\n chineseProfits.put(ZcSettingConstants.DE, profit.getProfit());\r\n chineseProfitRates.put(ZcSettingConstants.DE, profit.getProfitRate());\r\n\r\n profit = getProfit(ebu.getRMBValue(item.getEbPrice(), item.getCurrencyId()), ebu.getRMBValue(item.getEbShippingFee(), item.getCurrencyId()),\r\n item.getCost(), item.getTransportFee(),\r\n ebu.getRMBValue((BigDecimal) chineseInserts.get(ZcSettingConstants.FR), ZcSettingConstants.CURENCY_EUR),\r\n ebu.getRMBValue((BigDecimal) chineseFVLs.get(ZcSettingConstants.FR), ZcSettingConstants.CURENCY_EUR),\r\n ebu.getRMBValue((BigDecimal) chinesePayPalFees.get(ZcSettingConstants.FR), ZcSettingConstants.CURENCY_EUR));\r\n chineseProfits.put(ZcSettingConstants.FR, profit.getProfit());\r\n chineseProfitRates.put(ZcSettingConstants.FR, profit.getProfitRate());\r\n\r\n profit = getProfit(ebu.getRMBValue(item.getEbPrice(), item.getCurrencyId()), ebu.getRMBValue(item.getEbShippingFee(), item.getCurrencyId()),\r\n item.getCost(), item.getTransportFee(),\r\n ebu.getRMBValue((BigDecimal) chineseInserts.get(ZcSettingConstants.CA), ZcSettingConstants.CURENCY_CAD),\r\n ebu.getRMBValue((BigDecimal) chineseFVLs.get(ZcSettingConstants.CA), ZcSettingConstants.CURENCY_CAD),\r\n ebu.getRMBValue((BigDecimal) chinesePayPalFees.get(ZcSettingConstants.CA), ZcSettingConstants.CURENCY_CAD));\r\n chineseProfits.put(ZcSettingConstants.CA, profit.getProfit());\r\n chineseProfitRates.put(ZcSettingConstants.CA, profit.getProfitRate());\r\n\r\n profit = getProfit(ebu.getRMBValue(item.getEbPrice(), item.getCurrencyId()), ebu.getRMBValue(item.getEbShippingFee(), item.getCurrencyId()),\r\n item.getCost(), item.getTransportFee(),\r\n ebu.getRMBValue((BigDecimal) chineseInserts.get(ZcSettingConstants.AU), ZcSettingConstants.CURENCY_AUD),\r\n ebu.getRMBValue((BigDecimal) chineseFVLs.get(ZcSettingConstants.AU), ZcSettingConstants.CURENCY_AUD),\r\n ebu.getRMBValue((BigDecimal) chinesePayPalFees.get(ZcSettingConstants.AU), ZcSettingConstants.CURENCY_AUD));\r\n chineseProfits.put(ZcSettingConstants.AU, profit.getProfit());\r\n chineseProfitRates.put(ZcSettingConstants.AU, profit.getProfitRate());\r\n }\r\n return getChineseTableModel();\r\n }", "public double buyTickets(int knr, int aid, int anzTickets) throws Exception {\r\n \t// TODO Write your code here\r\n\r\n // 1. check if there are enough tickets available\r\n Statement checkAvailabilityStmt = connection.createStatement();\r\n ResultSet availabilityResult = checkAvailabilityStmt.executeQuery(\"SELECT COUNT(*) AS availableTickets FROM ticket WHERE kunde IS NULL and auffuehrung = \" + aid);\r\n\r\n int availableTickets;\r\n if (availabilityResult.next()) {\r\n availableTickets = availabilityResult.getInt(\"availableTickets\");\r\n } else {\r\n throw new SQLDataException(\"Could not estimate available ticket count from tickets table\");\r\n }\r\n\r\n availabilityResult.close();\r\n checkAvailabilityStmt.close();\r\n\r\n if (availableTickets >= anzTickets) {\r\n pstmt_updateTicket.setInt(1, knr);\r\n pstmt_updateTicket.setInt(2, aid);\r\n pstmt_updateTicket.setInt(3, anzTickets);\r\n\r\n pstmt_updateTicket.execute();\r\n\r\n ResultSet affectedRows = pstmt_updateTicket.getResultSet();\r\n\r\n double summe = 0;\r\n int numTicketsSold = 0;\r\n\r\n while (affectedRows.next()) {\r\n numTicketsSold++;\r\n summe += affectedRows.getDouble(\"preis\");\r\n }\r\n\r\n if (numTicketsSold != anzTickets) {\r\n connection.rollback();\r\n\r\n throw new SQLDataException(\"Update failed, only \" + numTicketsSold + \" tickets would've been changed, rolling back..\");\r\n }\r\n\r\n pstmt_updateTicket.close();\r\n affectedRows.close();\r\n connection.commit();\r\n\r\n return summe;\r\n } else {\r\n throw new SQLDataException(\"Not enough tickets are currently available\");\r\n }\r\n }", "public double runPrice(int age) {\n\t\t// PriceCRUD for calculating price later\n\t\tPriceCRUD<CinemaClassPrice> cinemaClassCRUD = new PriceCRUD<>(CinemaClassPrice.class);\n\t\tPriceCRUD<MovieTypePrice> movieTypeCRUD = new PriceCRUD<>(MovieTypePrice.class);\n\t\tPriceCRUD<DayPrice> dayCRUD = new PriceCRUD<>(DayPrice.class);\n\t\tPriceCRUD<AgePrice> ageCRUD = new PriceCRUD<>(AgePrice.class);\n\t\t\n\t\t// Get cinema class price\n\t\tCinemaCRUD<Cinema> cinemaCRUD = new CinemaCRUD<Cinema>(Cinema.class, Showtimes.getCineplexId());\n\t\tCinemaClass cinemaClass = cinemaCRUD.getCinemaType(this.showtimes.getCinemaId());\n\t\tCinemaClassPrice cinemaClassPrice = cinemaClassCRUD.getElementPrice(cinemaClass);\n\t\t\n\t\t// Get movie type price\n\t\tMovieCRUD<Movie> movieCRUD = new MovieCRUD<>(Movie.class);\n\t\tMovieType movieType = movieCRUD.getMovieById(this.showtimes.getMovieId()).getType();\n\t\tMovieTypePrice movieTypePrice = movieTypeCRUD.getElementPrice(movieType);\n\t\t\n\t\t// Get Day type price\n\t\tDayType dayType = DateTimeHelper.getDayType(this.showtimes.getDate());\n\t\tDayPrice dayTypePrice = dayCRUD.getElementPrice(dayType);\n\t\t\n\t\t// Get Age Range Price\n\t\tAgePrice agePrice = ageCRUD.getElementPrice(age);\n\t\t\n\t\t// Print receipt for 1 ticket\n\t\tSystem.out.println(cinemaClassPrice.toString());\n\t\tSystem.out.println(movieTypePrice.toString());\n\t\tSystem.out.println(dayTypePrice.toString());\n\t\tSystem.out.println(agePrice.toString());\n\t\tdouble ticketPrice = cinemaClassPrice.getPrice()+movieTypePrice.getPrice()+dayTypePrice.getPrice()+agePrice.getPrice();\n\t\tSystem.out.println(\"Ticket price: \"+ticketPrice);\n\t\t\n\t\treturn ticketPrice;\n\t}", "public void anualTasks(){\n List<Unit> units = unitService.getUnits();\n for(Unit unit: units){\n double amount = 10000; //@TODO calculate amount based on unit type\n Payment payment = new Payment();\n payment.setPaymentMethod(PaymentMethod.Cash);\n Calendar calendar = Calendar.getInstance();\n calendar.set(Calendar.MONTH, 1);\n calendar.set(Calendar.DATE, 30);\n payment.setDate(LocalDate.now());\n TimeZone tz = calendar.getTimeZone();\n ZoneId zid = tz == null ? ZoneId.systemDefault() : tz.toZoneId();\n payment.setAmount(amount);\n payment.setDueDate(LocalDateTime.ofInstant(calendar.toInstant(), zid).toLocalDate());\n payment.setClient(unit.getOwner());\n payment.setUnit(unit);\n payment.setRecurringInterval(365L);\n payment.setStatus(PaymentStatus.Pending);\n paymentService.savePayment(payment);\n }\n }", "public void setFee(Number value) {\n setAttributeInternal(FEE, value);\n }", "public double calculatePayment (int hours);" ]
[ "0.71208215", "0.683597", "0.6794066", "0.6766312", "0.6707628", "0.66470927", "0.6620461", "0.6499835", "0.6439513", "0.63899344", "0.63689184", "0.63510346", "0.63411385", "0.6332162", "0.63069904", "0.6285187", "0.6263162", "0.6236702", "0.62161756", "0.6214212", "0.6201238", "0.617049", "0.616181", "0.6153655", "0.61530477", "0.61388266", "0.6105654", "0.60786164", "0.6078386", "0.6062522", "0.6017444", "0.60092014", "0.6007175", "0.5983797", "0.5969215", "0.5961144", "0.59457964", "0.5934667", "0.5873225", "0.5872805", "0.5861678", "0.58435434", "0.5824549", "0.582174", "0.5794682", "0.57623905", "0.57241213", "0.56835103", "0.5662716", "0.5660027", "0.565352", "0.56532663", "0.56428564", "0.5631475", "0.5551652", "0.5541548", "0.5516608", "0.5491757", "0.54898596", "0.5486319", "0.54741466", "0.5468856", "0.5467447", "0.54649234", "0.5426743", "0.542159", "0.54214364", "0.5418092", "0.5414754", "0.54109454", "0.5404276", "0.5397358", "0.53965575", "0.53917867", "0.5375757", "0.5365539", "0.5339166", "0.533517", "0.53277797", "0.53099626", "0.53081965", "0.5298691", "0.5291924", "0.5284867", "0.52681184", "0.52586955", "0.52584845", "0.5249252", "0.524673", "0.5244208", "0.52427757", "0.52400166", "0.5237045", "0.5233156", "0.5225891", "0.5221283", "0.5219389", "0.5218691", "0.5217247", "0.5216075", "0.5202379" ]
0.0
-1
Cost without taxes or fees
public double ComputeBaseFare(){ if(this.getFlightClass().equalsIgnoreCase("BC")){ return this.ComputeDistance() * 0.5; } else if(this.getFlightClass().equalsIgnoreCase("EP")){ return this.ComputeDistance() * 0.2; } else{ return this.ComputeDistance() * 0.15; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Override\n public double calcCost() {\n return calcSalesFee()+calcTaxes();\n }", "@Override\n public Double getCost() {\n return new Double(0);\n }", "@Override\r\n\tpublic double getCost() {\n\t\treturn 0;\r\n\t}", "public BigDecimal getCost() \n{\nBigDecimal bd = (BigDecimal)get_Value(\"Cost\");\nif (bd == null) return Env.ZERO;\nreturn bd;\n}", "@Override\n public double calcTaxes() {\n return getCost() * 0.07;\n }", "@Override\n\tpublic Money costToCompany() {\n\t\treturn null;\n\t}", "public double calculateCost() {\n double output = price * (1 + taxRate);\n return output;\n }", "protected abstract double getDefaultCost();", "@Override\n public int getCost() {\n\treturn 0;\n }", "@Override\r\n\tpublic double getNettoPrice() {\n\t\treturn 0;\r\n\t}", "double getCost();", "double getCost();", "public double calculateCost(Purchase purchase);", "abstract protected BigDecimal getBasicTaxRate();", "BigDecimal getTax();", "public abstract double getCost();", "double getTotalCost();", "@Override\r\n\tpublic void minusFromCost() {\n\t\t\r\n\t}", "public double getFixedCost(FieldContext fieldContext) {\n\t\treturn 0;\n\t}", "@NotNull\n public BigDecimal getCost() {\n return cost;\n }", "@Override\t\n\tpublic double getTax() {\n\t\treturn 0;\n\t}", "public BigDecimal getCost() {\r\n return cost;\r\n }", "@Override public double getCosto(){\n double d = 190.00;\n return d;\n }", "public java.math.BigDecimal getTotalCost () {\n\t\treturn totalCost;\n\t}", "@Override\n public double getCost() {\n\t return 13;\n }", "@Override\n public double calcSalesFee() {\n return getCost() + getSalesPurchase();\n }", "@Pure\n\tdouble getCost();", "public BigDecimal getPriceListWTax();", "public BigDecimal getCost() {\n return this.cost;\n }", "public BigDecimal getPriceLimitWTax();", "public BigDecimal getPriceStdWTax();", "@Override\n\tvoid get_cost_per_sqarefeet() {\n\t\tcost=1800;\n\t}", "@Override\r\n\tpublic double getTaxValue() {\n\t\treturn 0;\r\n\t}", "public double netPrice () {\n return discountedPrice() + taxCharged();\n }", "@Override\n public double cost()\n {\n return this.price * this.number;\n }", "public int getCreditCost() {\n\t\treturn 0;\n\t}", "@Override\r\n public double getBaseCost() { return type.getCost(); }", "@Override\r\n\tpublic double getGrossPrice() {\n\t\treturn 0;\r\n\t}", "double calculateDeliveryCost(Cart cart);", "public void setCost(BigDecimal cost) {\r\n this.cost = cost;\r\n }", "public double getCost()\n\t{\n\t\treturn 0.9;\n\t}", "@Override\n\tpublic double cost() {\n\t\treturn Double.parseDouble(rateOfLatte);\n\t}", "public String getCost() {\n\t\tString t = doc.get(\"cost\");\n\n\t\tif (t == null) {\n\t\t\treturn \"\";\n\t\t} else {\n\t\t\treturn t;\n\t\t}\n\t}", "public double getMonthlyCost() {\n\t\treturn 0;\n\t}", "public float getCost() {\r\n return defaultCost;\r\n }", "public double getCost() {\n double price = 0;\n price += this.numPizzas * this.pizzaType.getCost();\n if(this.numPizzas >= 20) // Discount if >=20 pizzas\n return price * 0.9;\n else if(this.numPizzas >= 10) // Discount if between 10 and 20 pizzas\n return price * 0.95;\n return price; // No discount\n }", "@Override\n\tpublic double cost() {\n\t\tdouble price = good.cost();\n\t\treturn price+price/2;\n\t}", "public Double getTax();", "int getCost();", "int getCost();", "int getCost();", "public double getCost() \n { \n return super.getCost() +22;\n }", "public double getCost() {\n return price;\n }", "public BigDecimal getTaxAmtPriceStd();", "public void setCost(double value) {\n this.cost = value;\n }", "@Override\n\tpublic double getAdditionalFee() {\n\t\treturn 0.0;\n\t}", "public void setMaxTotalCost(int amount);", "public double getCosts();", "public BigDecimal getLBR_TaxRateCredit();", "BigDecimal getDiscount();", "@Override\n public double getCost() {\n return cost;\n }", "public boolean fieldHideCost(FieldContext fieldContext) {\n\t\treturn false;\n\t}", "@Override\r\n\tpublic double CalculatePrice() {\n\t\treturn 0;\r\n\t}", "public Money getCost(){\r\n return this.cost;\r\n }", "public BigDecimal sumCostAvoidanceTotal(MaintenanceRequest po){\n\t\tBigDecimal total = new BigDecimal(0.00).setScale(2);\n\t\t\n\t\tfor(MaintenanceRequestTask task : po.getMaintenanceRequestTasks()){\n\t\t\ttotal = total.add(MALUtilities.isEmpty(task.getCostAvoidanceAmount()) ? new BigDecimal(0) : task.getCostAvoidanceAmount());\n\t\t}\n\t\t\n\t\treturn total;\t\t\n\t}", "public abstract double getComplianceFee();", "CleanPrice getCleanPrice();", "double getTax();", "public BigDecimal getCostPrice() {\n return costPrice;\n }", "double applyTax(double price);", "String getTotalCost() {\n return Double.toString(totalCost);\n }", "public double getCost() {\n\t\treturn 1.25;\n\t}", "public String getRealTotalCost() {\n return this.RealTotalCost;\n }", "public double getActualFixedCost(FieldContext fieldContext) {\n\t\treturn 0;\n\t}", "double getTaxAmount();", "@Override\n\tprotected void setCost(double cst) {\n\t\t\n\t}", "@Override\n\tpublic double getPremiumFee(FDRuleContextI ctx) {\n\t\treturn 0;\n\t}", "public double getRemainingCost(FieldContext fieldContext) {\n\t\treturn 0;\n\t}", "@Override\r\n\tprotected void processCost() {\n\r\n\t}", "public BigDecimal getTaxAmtPriceLimit();", "public abstract int getCost();", "public abstract int getCost();", "public abstract int getCost();", "public double calculateNetPay() {\r\n return net_pay = grosspay - Statetax - Fedtax; }", "@Override\n\tpublic double cost() {\n\t\treturn 2.19;\n\t}", "public int getFee(){return 0;}", "public double getCost() {\r\n\t \treturn(cost);\r\n\t}", "@Override\n\tpublic double getAdditionalFee() {\n\t\t\n\t\treturn 0;\n\t}", "public double getTotalCost() {\r\n return totalCost;\r\n }", "public BigDecimal getLineNetAmt();", "public double getCost(){\n return cost;\n }", "double getUnpaidAmount();", "public void getCosts() {\n\t}", "public boolean fieldHideActualFixedCost(FieldContext fieldContext) {\n\t\treturn false;\n\t}", "public BigDecimal getLBR_TaxAmtCredit();", "@Override\r\n public double purchaseFee(){\r\n return fee;\r\n }", "public void setCost (BigDecimal Cost)\n{\nif (Cost == null) throw new IllegalArgumentException (\"Cost is mandatory\");\nset_Value (\"Cost\", Cost);\n}", "public double taxPaying() {\r\n double tax;\r\n if (profit == true) {\r\n tax = revenue / 10.00;\r\n }\r\n\r\n else\r\n tax = revenue / 2.00;\r\n return tax;\r\n }", "public float getTotalCost() {\n return this.totalCost;\n }", "public boolean fieldHideActualCost(FieldContext fieldContext) {\n\t\treturn false;\n\t}", "Money getDiscountValue();" ]
[ "0.7024211", "0.6825308", "0.67968035", "0.66222084", "0.6621178", "0.6612165", "0.6602175", "0.65306747", "0.6530486", "0.6515321", "0.64699686", "0.64699686", "0.64544904", "0.6442722", "0.6418203", "0.6417855", "0.64045805", "0.6384744", "0.6335591", "0.63168746", "0.629196", "0.62351596", "0.62031406", "0.61922956", "0.6187918", "0.618423", "0.6149482", "0.614543", "0.6143793", "0.61352", "0.6116163", "0.6112113", "0.61068845", "0.60884905", "0.6080563", "0.6080164", "0.607974", "0.60675085", "0.60652786", "0.60572344", "0.60552955", "0.6051963", "0.6048822", "0.60428786", "0.60366607", "0.6036243", "0.6029259", "0.6015554", "0.6002992", "0.6002992", "0.6002992", "0.5999349", "0.5996984", "0.59968317", "0.5979505", "0.5979408", "0.5978852", "0.5975021", "0.59744436", "0.59617364", "0.5959387", "0.5957131", "0.59542257", "0.59398854", "0.5936399", "0.593449", "0.59343565", "0.5934214", "0.59196657", "0.5918902", "0.5917865", "0.59084016", "0.59065825", "0.58987534", "0.58878475", "0.588708", "0.5884456", "0.5873776", "0.58708274", "0.5864017", "0.58632123", "0.58632123", "0.58632123", "0.5861442", "0.5856688", "0.5854145", "0.5848462", "0.58433586", "0.5842018", "0.5839994", "0.58376896", "0.583189", "0.58300364", "0.5829217", "0.58267176", "0.5822195", "0.5818516", "0.5815705", "0.58139086", "0.5809851", "0.5807462" ]
0.0
-1
Returns total taxes for a ticket
public double getTaxes(){ return this.getExciseTax() + this.getFlightSegmentTax() + this.get911SecurityFee() + this.getPassengerFacilityFee(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "double getTaxAmount();", "public int totalTax()\n {\n double tax = taxRate / 100;\n return (int)Math.round(totalCost() * tax);\n }", "public String getTotalTaxes(){\n String tax = driver.findElement(oTotalTaxes).getText();\n logger.debug(\"total taxes is\" + tax);\n return tax;\n }", "public double getTax() {\r\n\r\n return getSubtotal() * 0.06;\r\n\r\n }", "@Override\n public double calcTaxes() {\n return getCost() * 0.07;\n }", "public double getTaxes() {\n return getArea() * TAX_RATE_PER_M2;\n }", "double getTax();", "BigDecimal getTax();", "public double calculateTax() {\n taxSubtotal = (saleAmount * SALESTAXRATE);\n\n return taxSubtotal;\n }", "public static double calculateTotalAmountWithTax(DetailRow[] rows) {\r\n\r\n\t\tint maxDecimals = 0;\r\n\t\t\r\n\t\tdouble result = 0.0;\r\n\t\tfor (int i=0; i<rows.length; i++) {\r\n\t\t\tresult += rows[i].getLineTotalWithTax();\r\n\t\t\tmaxDecimals = Math.max(maxDecimals, rows[i].getRoundingDecimals());\r\n\t\t}\r\n\r\n\t\tlong integervalue = Math.round(result * Math.pow(10, maxDecimals));\r\n\t\tresult = (double)integervalue/Math.pow(10, maxDecimals);\r\n\r\n\t\t\r\n\t\treturn result;\r\n\t\t\r\n\t}", "public BigDecimal getTotalTaxAmt() {\n\t\treturn totalTaxAmt;\n\t}", "public int calculateTax() {\n int premium = calculateCost();\n return (int) Math.round(premium * vehicle.getType().getTax(surety.getSuretyType()));\n }", "public BigDecimal getTax() {\n return tax;\n }", "public double getTotal() {\r\n\r\n return getSubtotal() + getTax();\r\n }", "public double calcTax() {\n\t\treturn 0.2 * calcGrossWage() ;\n\t}", "public double getTaxAmount() {\n return taxAmount;\n }", "public Double getTax();", "public double taxPaying() {\r\n double tax;\r\n if (profit == true) {\r\n tax = revenue / 10.00;\r\n }\r\n\r\n else\r\n tax = revenue / 2.00;\r\n return tax;\r\n }", "public double getTax() {\n return tax_;\n }", "private void calcTotalAmount(){\n\t totalAmount = 0;\n\t\tfor(FlightTicket ft : tickets)\n\t\t{\n\t\t\ttotalAmount += ft.getClassType().getFee() * getFlight().getFlightCost();\n\t\t}\n\t\tsetTotalAmount(totalAmount);\n\t}", "public double getTax() {\n return tax_;\n }", "public double calculateTax(double amount){\n return (amount*TAX_4_1000)/1000;\n }", "public MMDecimal getTaxAmount() {\r\n return this.taxAmount;\r\n }", "public Collection<TaxValueDTO> getTotalTaxValues()\n\t{\n\t\treturn totalTaxValues;\n\t}", "public double useTax() {\n \n return super.useTax() + getValue()\n * PER_AXLE_TAX_RATE * getAxles();\n }", "public double getTax(){\n\n return this.tax;\n }", "public BigDecimal getTaxAmtPriceStd();", "@Override\t\n\tpublic double getTax() {\n\t\treturn 0;\n\t}", "@Override\n\tpublic double getTax() {\n\t\treturn 0.04;\n\t}", "public BigDecimal getTaxRate() {\n\n\t\tBigDecimal totalTaxRate = getBasicTaxRate().add(getImportTaxRate());\n\n\t\treturn totalTaxRate;\n\t}", "public BigDecimal getTaxAmt() {\n\t\treturn taxAmt;\n\t}", "public double taxRate () {\n return taxRate;\n }", "@Override\r\n\tpublic double taxAmount(long itemSold, double price) {\n\t\treturn 100.230;\r\n\t}", "public static double calculateTotalAmountWithTax(DetailRow[] rows, int roundingDecimals) {\r\n\r\n\t\tdouble result = 0.0;\r\n\t\tfor (int i=0; i<rows.length; i++) {\r\n\t\t\trows[i].setRoundingDecimals(roundingDecimals);\r\n\t\t\tresult += rows[i].getLineTotalWithTax();\r\n\t\t}\r\n\t\t\r\n\t\tlong integervalue = Math.round(result * Math.pow(10, roundingDecimals));\r\n\t\tresult = (double)integervalue/Math.pow(10, roundingDecimals);\r\n\t\t\r\n\t\treturn result;\r\n\t\t\r\n\t}", "public static Tax[] getTaxes() {\n Tax[] taxes = new Tax[DeclarationFiller.getDeclaration().size()];\n int count = 0;\n if (taxes != null ) {\n for (Map.Entry<String, Integer> incomePoint : DeclarationFiller.getDeclaration().entrySet()) {\n String taxName = \"Tax of \" + incomePoint.getKey();\n int incomValue = incomePoint.getValue();\n taxes[count] = new Tax(count+1001 ,taxName, incomValue, 0.18);\n count++;\n }\n }\n return taxes;\n }", "public String getTotalAmountOfTicketFlight()\n\t{\n\t\tint sum;\n\n\t\tint departurePriceAtbottom = Integer.parseInt(getDepartureFlightPriceAtBottom().replaceAll(\"[Rs ,]\", \"\"));\n\t\tint returnPriceAtbottom = Integer.parseInt(getReturnFlightPriceAtBottom().replaceAll(\"[Rs ,]\", \"\"));\n\t\t\n\t\twaitForSeconds(5);\n\n\t\tif(driver.getPageSource().contains(\"Return trip discount\")) {\n\t\t\tint dAmount = Integer.parseInt(discountTagAmount.getText().replaceAll(\"[Rs ]\", \"\"));\n\t\t\tsum = (departurePriceAtbottom + returnPriceAtbottom)- dAmount;\n\n\t\t}\n\t\telse \n\t\t{\n\n\t\t\tsum = departurePriceAtbottom + returnPriceAtbottom;\n\t\t}\n\n\n\t\treturn String.valueOf(sum);\n\t}", "public void tpsTax() {\n TextView tpsView = findViewById(R.id.checkoutPage_TPStaxValue);\n tpsTaxTotal = beforeTaxTotal * 0.05;\n tpsView.setText(String.format(\"$%.2f\", tpsTaxTotal));\n }", "double taxReturn() {\n\t\tdouble ddv = 0;\n\t\tif (d == 'A') {\n\t\t\tddv = 18;\n\t\t} else if (d == 'B') {\n\t\t\tddv = 5;\n\t\t}\n\t\t\n\t\tif (ddv = 0) {\n\t\t\treturn 0;\n\t\t}\n\t\t\n\t\tdouble percent = price / 100.0;\n\t\tdouble tax = ddv * percent;\n\t\treturn tax / 100.0 * 15.0;\n\t}", "public int getTax(){\n int tax=0;\n if(this.salary<this.LOWER_LIMIT){\n tax=this.taxableSalary/100*10;\n }else if(this.salary<this.UPPER_LIMIT){\n tax=this.taxableSalary/100*22;\n }else{\n tax=this.UPPER_LIMIT/100*22 + (this.taxableSalary-this.UPPER_LIMIT)/100*40;\n }\n return tax;\n }", "public BigDecimal getPriceStdWTax();", "public void totalBill(){\r\n\t\tint numOfItems = ItemsList.size();\r\n\t\t\r\n\t\tBigDecimal runningSum = new BigDecimal(\"0\");\r\n\t\tBigDecimal runningTaxSum = new BigDecimal(\"0\");\r\n\t\t\r\n\t\tfor(int i = 0;i<numOfItems;i++){\r\n\t\t\t\r\n\t\t\trunningTaxSum = BigDecimal.valueOf(0);\r\n\t\t\t\r\n\t\t\tBigDecimal totalBeforeTax = new BigDecimal(String.valueOf(this.ItemsList.get(i).getPrice()));\r\n\t\t\t\r\n\t\t\trunningSum = runningSum.add(totalBeforeTax);\r\n\t\t\t\r\n\t\t\tif(ItemsList.get(i).isSalesTaxable()){\r\n\t\t\t\r\n\t\t\t BigDecimal salesTaxPercent = new BigDecimal(\".10\");\r\n\t\t\t BigDecimal salesTax = salesTaxPercent.multiply(totalBeforeTax);\r\n\t\t\t \r\n\t\t\t salesTax = round(salesTax, BigDecimal.valueOf(0.05), RoundingMode.UP);\r\n\t\t\t runningTaxSum = runningTaxSum.add(salesTax);\r\n\t\t\t \r\n \r\n\t\t\t} \r\n\t\t\t\r\n\t\t\tif(ItemsList.get(i).isImportedTaxable()){\r\n\r\n\t\t\t BigDecimal importTaxPercent = new BigDecimal(\".05\");\r\n\t\t\t BigDecimal importTax = importTaxPercent.multiply(totalBeforeTax);\r\n\t\t\t \r\n\t\t\t importTax = round(importTax, BigDecimal.valueOf(0.05), RoundingMode.UP);\r\n\t\t\t runningTaxSum = runningTaxSum.add(importTax);\r\n\t\t\t \r\n\t\t\t}\r\n\r\n\t\t\t\r\n\t\t\tItemsList.get(i).setPrice(runningTaxSum.floatValue() + ItemsList.get(i).getPrice());\r\n\t\t\r\n\t\t\ttaxTotal += runningTaxSum.doubleValue();\r\n\t\t\t\r\n\t\t\trunningSum = runningSum.add(runningTaxSum);\r\n\t\t}\r\n\t\t\ttaxTotal = roundTwoDecimals(taxTotal);\r\n\t\t\ttotal = runningSum.doubleValue();\r\n\t}", "private int addTax(Iterable<TransactionItem> items) {\r\n\t\tint tax = 0;\r\n\r\n\t\tfor (TransactionItem item : items) {\r\n\t\t\tint newTax = (int) Math.round(item.getPriceInCents()\r\n\t\t\t\t\t* (this.tax.getPercentage() / 100.0));\r\n\t\t\ttax += newTax;\r\n\t\t}\r\n\t\treturn tax;\r\n\t}", "private Vehicle calculationTaxes(Vehicle vehicle) {\n double exchangeRateCurrencyOfContract = serviceForCurrencyExchangeRate.getCurrencyExchangeRateNBU(vehicle.getCurrencyOfContract().name());\n double exchangeRateEUR = serviceForCurrencyExchangeRate.getCurrencyExchangeRateNBU(\"EUR\");\n\n // Calculation Impost\n vehicle.setImpostBasis(serviceForNumber.roundingNumber(\n vehicle.getPriceInCurrency() * exchangeRateCurrencyOfContract,\n 2));\n determinationImpostRate(vehicle);\n vehicle.setImpost(serviceForNumber.roundingNumber(\n vehicle.getImpostBasis() * vehicle.getImpostRate() / 100,\n 2));\n\n // Calculation Excise\n vehicle.setExciseBasis(vehicle.getCapacity());\n determinationExciseRate(vehicle);\n vehicle.setExcise(serviceForNumber.roundingNumber(\n vehicle.getExciseBasis() * vehicle.getExciseRate() * exchangeRateEUR,\n 2));\n\n // Calculation VAT\n vehicle.setVATBasis(serviceForNumber.roundingNumber(\n vehicle.getImpostBasis() + vehicle.getImpost() + vehicle.getExcise(),\n 2));\n determinationVATRate(vehicle);\n vehicle.setVAT(serviceForNumber.roundingNumber(\n vehicle.getVATBasis() * vehicle.getVATRate() / 100,\n 2));\n\n return vehicle;\n }", "private final void taxCalculations(){\n\r\n hraDeduction = totalHRA - 0.1*basicIncome;\r\n ltaDeduction = totalLTA - 0.7*totalLTA;\r\n\r\n //exemptions\r\n fundsExemption = fundsIncome - 150000; //upto 1.5 lakhs are exempted under IT Regulation 80C\r\n\r\n grossIncome = basicIncome + totalHRA + totalLTA + totalSpecialAl + fundsIncome ;\r\n\r\n totalDeduction = hraDeduction + ltaDeduction;\r\n\r\n totalTaxableIncome = grossIncome - (totalDeduction + fundsExemption);\r\n\r\n taxLiability = 0.05 * (totalTaxableIncome - 250000) + 0.2*(totalTaxableIncome - 500000);\r\n\r\n taxToPay = (cessPercent*taxLiability)/100 + taxLiability;\r\n }", "public abstract double calculateTax();", "double applyTax(double price);", "public double taxCharged (){\n return discountedPrice() * taxRate;\n }", "public double getSalesTax() {\r\n return salesTax;\r\n }", "public BigDecimal getPriceListWTax();", "public BigDecimal getIncludedTax()\r\n\t{\r\n\t\treturn m_includedTax;\r\n\t}", "public double getTaxa() {\n\t\treturn taxa;\n\t}", "public BigDecimal getTaxRate() {\n return taxRate;\n }", "public double getTaxRate() {\n return taxRate;\n }", "public BigDecimal getTaxscore() {\n return taxscore;\n }", "public double getTaxedCost()\n\t{\n\t\treturn taxedCost;\n\t}", "public static double calculateTax(double price) {\r\n\tfinal double TAX = 0.05;\r\n\tdouble taxAmount = price*TAX;\r\n\treturn taxAmount;\r\n\t}", "public BigDecimal getTaxAmtPriceLimit();", "abstract protected BigDecimal getBasicTaxRate();", "public double getMarketValueTaxRate(){\r\n taxlist.add(new Tax(this.estValue,this.PPR,this.yearsowned,this.locationCategory));\r\n count++;\r\n return taxlist.get(count-1).MarketValueTax();\r\n }", "public float getServiceTax() {\n\t\treturn serviceTax;\n\t}", "public BigDecimal getTaxAmtPriceList();", "@Override\r\n\tpublic double getTaxValue() {\n\t\treturn 0;\r\n\t}", "public void tvqTax() {\n TextView tvqView = findViewById(R.id.checkoutPage_TVQtaxValue);\n tvqTaxTotal = beforeTaxTotal * 0.09975;\n tvqView.setText(String.format(\"$%.2f\", tvqTaxTotal));\n }", "private void CalculateTotalAmount()\n {\n double dSubTotal = 0,dTaxTotal = 0, dModifierAmt = 0, dServiceTaxAmt = 0, dOtherCharges = 0, dTaxAmt = 0, dSerTaxAmt = 0;\n float dTaxPercent = 0, dSerTaxPercent = 0;\n double dTotalBillAmount_for_reverseTax =0;\n double dIGSTAmt =0, dcessAmt =0;\n // Item wise tax calculation ----------------------------\n for (int iRow = 0; iRow < tblOrderItems.getChildCount(); iRow++)\n {\n TableRow RowItem = (TableRow) tblOrderItems.getChildAt(iRow);\n if (RowItem.getChildAt(0) != null)\n {\n TextView ColQuantity = (TextView) RowItem.getChildAt(3);\n TextView ColRate = (TextView) RowItem.getChildAt(4);\n TextView ColTaxType = (TextView) RowItem.getChildAt(13);\n TextView ColAmount = (TextView) RowItem.getChildAt(5);\n TextView ColDisc = (TextView) RowItem.getChildAt(9);\n TextView ColTax = (TextView) RowItem.getChildAt(7);\n TextView ColModifierAmount = (TextView) RowItem.getChildAt(14);\n TextView ColServiceTaxAmount = (TextView) RowItem.getChildAt(16);\n TextView ColIGSTAmount = (TextView) RowItem.getChildAt(24);\n TextView ColcessAmount = (TextView) RowItem.getChildAt(26);\n TextView ColTaxValue = (TextView) RowItem.getChildAt(28);\n dTaxTotal += Double.parseDouble(ColTax.getText().toString());\n dServiceTaxAmt += Double.parseDouble(ColServiceTaxAmount.getText().toString());\n dIGSTAmt += Double.parseDouble(ColIGSTAmount.getText().toString());\n dcessAmt += Double.parseDouble(ColcessAmount.getText().toString());\n if (crsrSettings!=null && crsrSettings.getString(crsrSettings.getColumnIndex(\"Tax\")).equalsIgnoreCase(\"1\")) // forward tax\n {\n dSubTotal += Double.parseDouble(ColAmount.getText().toString());\n }\n else // reverse tax\n {\n double qty = ColQuantity.getText().toString().equals(\"\")?0.00 : Double.parseDouble(ColQuantity.getText().toString());\n double baseRate = ColRate.getText().toString().equals(\"\")?0.00 : Double.parseDouble(ColRate.getText().toString());\n dSubTotal += (qty*baseRate);\n dTotalBillAmount_for_reverseTax += Double.parseDouble(ColAmount.getText().toString());\n }\n\n }\n }\n // ------------------------------------------\n // Bill wise tax Calculation -------------------------------\n Cursor crsrtax = db.getTaxConfigs(1);\n if (crsrtax.moveToFirst()) {\n dTaxPercent = crsrtax.getFloat(crsrtax.getColumnIndex(\"TotalPercentage\"));\n dTaxAmt += dSubTotal * (dTaxPercent / 100);\n }\n Cursor crsrtax1 = db.getTaxConfigs(2);\n if (crsrtax1.moveToFirst()) {\n dSerTaxPercent = crsrtax1.getFloat(crsrtax1.getColumnIndex(\"TotalPercentage\"));\n dSerTaxAmt += dSubTotal * (dSerTaxPercent / 100);\n }\n // -------------------------------------------------\n\n dOtherCharges = Double.valueOf(textViewOtherCharges.getText().toString());\n //String strTax = crsrSettings.getString(crsrSettings.getColumnIndex(\"Tax\"));\n if (crsrSettings.moveToFirst()) {\n if (crsrSettings.getString(crsrSettings.getColumnIndex(\"Tax\")).equalsIgnoreCase(\"1\")) // forward tax\n {\n if (crsrSettings.getString(crsrSettings.getColumnIndex(\"TaxType\")).equalsIgnoreCase(\"1\"))\n {\n tvIGSTValue.setText(String.format(\"%.2f\", dIGSTAmt));\n tvTaxTotal.setText(String.format(\"%.2f\", dTaxTotal));\n tvServiceTaxTotal.setText(String.format(\"%.2f\", dServiceTaxAmt));\n tvcessValue.setText(String.format(\"%.2f\",dcessAmt));\n\n if (chk_interstate.isChecked()) // interstate\n {\n tvIGSTValue.setTextColor(Color.WHITE);\n tvTaxTotal.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\n tvServiceTaxTotal.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\n } else {\n tvIGSTValue.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\n tvTaxTotal.setTextColor(Color.WHITE);\n tvServiceTaxTotal.setTextColor(Color.WHITE);\n }\n\n tvSubTotal.setText(String.format(\"%.2f\", dSubTotal));\n tvBillAmount.setText(String.format(\"%.2f\", dSubTotal + dTaxTotal + dServiceTaxAmt + dOtherCharges+dcessAmt));\n }\n else\n {\n tvIGSTValue.setText(String.format(\"%.2f\", dIGSTAmt));\n tvTaxTotal.setText(String.format(\"%.2f\", dTaxTotal));\n tvServiceTaxTotal.setText(String.format(\"%.2f\", dServiceTaxAmt));\n tvcessValue.setText(String.format(\"%.2f\",dcessAmt));\n\n if (chk_interstate.isChecked()) // interstate\n {\n tvIGSTValue.setTextColor(Color.WHITE);\n tvTaxTotal.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\n tvServiceTaxTotal.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\n } else {\n tvIGSTValue.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\n tvTaxTotal.setTextColor(Color.WHITE);\n tvServiceTaxTotal.setTextColor(Color.WHITE);\n }\n tvSubTotal.setText(String.format(\"%.2f\", dSubTotal));\n tvBillAmount.setText(String.format(\"%.2f\", dSubTotal + dTaxAmt + dSerTaxAmt + dOtherCharges+dcessAmt));\n }\n }\n else // reverse tax\n {\n if (crsrSettings.getString(crsrSettings.getColumnIndex(\"TaxType\")).equalsIgnoreCase(\"1\")) // item wise\n {\n tvIGSTValue.setText(String.format(\"%.2f\", dIGSTAmt));\n tvTaxTotal.setText(String.format(\"%.2f\", dTaxTotal));\n tvServiceTaxTotal.setText(String.format(\"%.2f\", dServiceTaxAmt));\n tvcessValue.setText(String.format(\"%.2f\",dcessAmt));\n\n if (chk_interstate.isChecked()) // interstate\n {\n tvIGSTValue.setTextColor(Color.WHITE);\n tvTaxTotal.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\n tvServiceTaxTotal.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\n } else {\n tvIGSTValue.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\n tvTaxTotal.setTextColor(Color.WHITE);\n tvServiceTaxTotal.setTextColor(Color.WHITE);\n }\n tvSubTotal.setText(String.format(\"%.2f\", dSubTotal));\n tvBillAmount.setText(String.format(\"%.2f\", dTotalBillAmount_for_reverseTax + dOtherCharges));\n\n }\n else\n {\n tvSubTotal.setText(String.format(\"%.2f\", dSubTotal));\n tvIGSTValue.setText(String.format(\"%.2f\", dIGSTAmt));\n tvTaxTotal.setText(String.format(\"%.2f\", dTaxTotal));\n tvServiceTaxTotal.setText(String.format(\"%.2f\", dServiceTaxAmt));\n tvcessValue.setText(String.format(\"%.2f\",dcessAmt));\n\n if (chk_interstate.isChecked()) // interstate\n {\n tvIGSTValue.setTextColor(Color.WHITE);\n tvTaxTotal.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\n tvServiceTaxTotal.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\n } else {\n tvIGSTValue.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\n tvTaxTotal.setTextColor(Color.WHITE);\n tvServiceTaxTotal.setTextColor(Color.WHITE);\n }\n tvBillAmount.setText(String.format(\"%.2f\", dTotalBillAmount_for_reverseTax + dOtherCharges));\n }\n }\n }\n }", "private void CalculateTotalAmount() {\r\n\r\n double dSubTotal = 0, dTaxTotal = 0, dModifierAmt = 0, dServiceTaxAmt = 0, dOtherCharges = 0, dTaxAmt = 0, dSerTaxAmt = 0, dIGSTAmt=0, dcessAmt=0, dblDiscount = 0;\r\n float dTaxPercent = 0, dSerTaxPercent = 0;\r\n\r\n // Item wise tax calculation ----------------------------\r\n for (int iRow = 0; iRow < tblOrderItems.getChildCount(); iRow++) {\r\n\r\n TableRow RowItem = (TableRow) tblOrderItems.getChildAt(iRow);\r\n\r\n if (RowItem.getChildAt(0) != null) {\r\n\r\n TextView ColTaxType = (TextView) RowItem.getChildAt(13);\r\n TextView ColAmount = (TextView) RowItem.getChildAt(5);\r\n TextView ColDisc = (TextView) RowItem.getChildAt(9);\r\n TextView ColTax = (TextView) RowItem.getChildAt(7);\r\n TextView ColModifierAmount = (TextView) RowItem.getChildAt(14);\r\n TextView ColServiceTaxAmount = (TextView) RowItem.getChildAt(16);\r\n TextView ColIGSTAmount = (TextView) RowItem.getChildAt(24);\r\n TextView ColcessAmount = (TextView) RowItem.getChildAt(26);\r\n TextView ColAdditionalCessAmt = (TextView) RowItem.getChildAt(29);\r\n TextView ColTotalCessAmount = (TextView) RowItem.getChildAt(30);\r\n dblDiscount += Double.parseDouble(ColDisc.getText().toString());\r\n dTaxTotal += Double.parseDouble(ColTax.getText().toString());\r\n dServiceTaxAmt += Double.parseDouble(ColServiceTaxAmount.getText().toString());\r\n dIGSTAmt += Double.parseDouble(ColIGSTAmount.getText().toString());\r\n// dcessAmt += Double.parseDouble(ColcessAmount.getText().toString()) + Double.parseDouble(ColAdditionalCessAmt.getText().toString());\r\n dcessAmt += Double.parseDouble(ColTotalCessAmount.getText().toString());\r\n dSubTotal += Double.parseDouble(ColAmount.getText().toString());\r\n\r\n }\r\n }\r\n // ------------------------------------------\r\n\r\n // Bill wise tax Calculation -------------------------------\r\n Cursor crsrtax = dbBillScreen.getTaxConfig(1);\r\n if (crsrtax.moveToFirst()) {\r\n dTaxPercent = crsrtax.getFloat(crsrtax.getColumnIndex(\"TotalPercentage\"));\r\n dTaxAmt += dSubTotal * (dTaxPercent / 100);\r\n }\r\n Cursor crsrtax1 = dbBillScreen.getTaxConfig(2);\r\n if (crsrtax1.moveToFirst()) {\r\n dSerTaxPercent = crsrtax1.getFloat(crsrtax1.getColumnIndex(\"TotalPercentage\"));\r\n dSerTaxAmt += dSubTotal * (dSerTaxPercent / 100);\r\n }\r\n // -------------------------------------------------\r\n\r\n dOtherCharges = Double.valueOf(tvOthercharges.getText().toString());\r\n //String strTax = crsrSettings.getString(crsrSettings.getColumnIndex(\"Tax\"));\r\n if (crsrSettings.moveToFirst()) {\r\n if (crsrSettings.getString(crsrSettings.getColumnIndex(\"Tax\")).equalsIgnoreCase(\"1\")) {\r\n if (crsrSettings.getString(crsrSettings.getColumnIndex(\"TaxType\")).equalsIgnoreCase(\"1\")) {\r\n\r\n tvIGSTValue.setText(String.format(\"%.2f\", dIGSTAmt));\r\n tvCGSTValue.setText(String.format(\"%.2f\", dTaxTotal));\r\n tvSGSTValue.setText(String.format(\"%.2f\", dServiceTaxAmt));\r\n tvcessValue.setText(String.format(\"%.2f\",dcessAmt));\r\n\r\n if (chk_interstate.isChecked()) // interstate\r\n {\r\n tvIGSTValue.setTextColor(Color.WHITE);\r\n tvCGSTValue.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\r\n tvSGSTValue.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\r\n } else {\r\n tvIGSTValue.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\r\n tvCGSTValue.setTextColor(Color.WHITE);\r\n tvSGSTValue.setTextColor(Color.WHITE);\r\n }\r\n\r\n tvSubTotal.setText(String.format(\"%.2f\", dSubTotal));\r\n tvBillAmount.setText(String.format(\"%.2f\", dSubTotal + dTaxTotal + dServiceTaxAmt + dOtherCharges+dcessAmt));\r\n } else {\r\n\r\n tvIGSTValue.setText(String.format(\"%.2f\", dIGSTAmt));\r\n tvCGSTValue.setText(String.format(\"%.2f\", dTaxTotal));\r\n tvSGSTValue.setText(String.format(\"%.2f\", dServiceTaxAmt));\r\n tvcessValue.setText(String.format(\"%.2f\",dcessAmt));\r\n\r\n if (chk_interstate.isChecked()) // interstate\r\n {\r\n tvIGSTValue.setTextColor(Color.WHITE);\r\n tvCGSTValue.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\r\n tvSGSTValue.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\r\n } else {\r\n tvIGSTValue.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\r\n tvCGSTValue.setTextColor(Color.WHITE);\r\n tvSGSTValue.setTextColor(Color.WHITE);\r\n }\r\n tvSubTotal.setText(String.format(\"%.2f\", dSubTotal));\r\n tvBillAmount.setText(String.format(\"%.2f\", dSubTotal + dTaxAmt + dSerTaxAmt + dOtherCharges+dcessAmt));\r\n }\r\n } else {\r\n if (crsrSettings.getString(crsrSettings.getColumnIndex(\"TaxType\")).equalsIgnoreCase(\"1\")) {\r\n tvIGSTValue.setText(String.format(\"%.2f\", dIGSTAmt));\r\n tvCGSTValue.setText(String.format(\"%.2f\", dTaxTotal));\r\n tvSGSTValue.setText(String.format(\"%.2f\", dServiceTaxAmt));\r\n tvcessValue.setText(String.format(\"%.2f\",dcessAmt));\r\n\r\n if (chk_interstate.isChecked()) // interstate\r\n {\r\n tvIGSTValue.setTextColor(Color.WHITE);\r\n tvCGSTValue.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\r\n tvSGSTValue.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\r\n } else {\r\n tvIGSTValue.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\r\n tvCGSTValue.setTextColor(Color.WHITE);\r\n tvSGSTValue.setTextColor(Color.WHITE);\r\n }\r\n tvSubTotal.setText(String.format(\"%.2f\", dSubTotal));\r\n tvBillAmount.setText(String.format(\"%.2f\", dSubTotal + dOtherCharges));\r\n\r\n } else {\r\n tvSubTotal.setText(String.format(\"%.2f\", dSubTotal));\r\n tvIGSTValue.setText(String.format(\"%.2f\", dIGSTAmt));\r\n tvCGSTValue.setText(String.format(\"%.2f\", dTaxTotal));\r\n tvSGSTValue.setText(String.format(\"%.2f\", dServiceTaxAmt));\r\n tvcessValue.setText(String.format(\"%.2f\",dcessAmt));\r\n\r\n\r\n if (chk_interstate.isChecked()) // interstate\r\n {\r\n tvIGSTValue.setTextColor(Color.WHITE);\r\n tvCGSTValue.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\r\n tvSGSTValue.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\r\n } else {\r\n tvIGSTValue.setTextColor(getResources().getColor(R.color.colorPrimaryLight));\r\n tvCGSTValue.setTextColor(Color.WHITE);\r\n tvSGSTValue.setTextColor(Color.WHITE);\r\n }\r\n tvBillAmount.setText(String.format(\"%.2f\", dSubTotal + dOtherCharges));\r\n }\r\n }\r\n tvDiscountAmount.setText(String.format(\"%.2f\", dblDiscount));\r\n }\r\n }", "public double getTaxRate() {\r\n\t\treturn .07;\r\n\t}", "public BigDecimal getLBR_TaxAmt();", "public CoreComponentTypes.apis.ebay.BasicAmountType getTaxAmount() {\r\n return taxAmount;\r\n }", "public float calculateTax(String state, Integer flatRate);", "public BigDecimal getPriceLimitWTax();", "@ApiModelProperty(value = \"Total amount of TAX paid(or should be paid)\")\n @JsonProperty(\"tax\")\n public String getTax() {\n return tax;\n }", "@Test\n public void testGetTotalTax() {\n double expResult = 4.0;\n double result = receipt.getTotalTax();\n assertEquals(expResult, result, 0.0);\n }", "private static void updateTotals()\r\n\t{\r\n\t\ttaxAmount = Math.round(subtotalAmount * salesTax / 100.0);\r\n\t\ttotalAmount = subtotalAmount + taxAmount;\r\n\t}", "TotalInvoiceAmountType getTotalInvoiceAmount();", "public int getLocationTax(){\r\n taxlist.add(new Tax(this.estValue,this.PPR,this.yearsowned,this.locationCategory));\r\n count++;\r\n return taxlist.get(count-1).LocationTax();\r\n }", "public double taxCalc(int income1, int income2, int income3, int income4, int income5) {\n int[] arr = {income1, income2, income3, income4, income5};\n double taxTotal = 0.0;\n for (int i = 0; i < arr.length; i++) {\n taxTotal += (double) (arr[i] * 7 / 100);\n }\n return taxTotal;\n }", "@Override\n public double calcCost() {\n return calcSalesFee()+calcTaxes();\n }", "public double roundedTax(double tax) {\n\t\tdouble totalTax = ((double)Math.round(tax*10*2))/20;\n\t\treturn totalTax;\n\t}", "static double tax( double salary ){\n\n return salary*10/100;\n\n }", "public Double darTiempoTotal(){\n\t\treturn tiempoComputacionalGrasp+tiempoComputacionalSetCovering;\n\t}", "public Float getPrixHorsTaxes() {\n return prixHorsTaxes;\n }", "public double getTaxValue() {\n\t\treturn TaxCalculatorUtil.getTaxValue(getConfiguredPrice(),getPromotionValue(), getCouponDiscountValue(), getTaxRate(), getTaxationType());\n\t}", "@Override\r\n\tpublic double calculateTaxes(int year) {\n\t\tdouble taxe1 = 2.0; // public double section1 = minimum;\r\n\t\tdouble taxe2 = 4.0;\r\n\t\tdouble taxe3 = 10.0;\r\n\t\tdouble taxe4 = 25.0;\r\n\t\tdouble totalSalary = monthSalary * 14; // 14 son pagas en año\r\n\r\n\t\tif (totalSalary <= 12600) {\r\n\t\t\ttotalSalary = (totalSalary * (100 - taxe1));\r\n\r\n\t\t} else if (totalSalary <= 15000) {\r\n\t\t\ttotalSalary = (totalSalary * (100 - taxe2));\r\n\r\n\t\t} else if (totalSalary <= 21000) {\r\n\t\t\ttotalSalary = (totalSalary * (100 - taxe3));\r\n\r\n\t\t} else if (totalSalary > 21000) {\r\n\t\t\ttotalSalary = (totalSalary * (100 - taxe4));\r\n\r\n\t\t} else\r\n\t\t\ttotalSalary = -1;\r\n\r\n\t\treturn totalSalary;\r\n\t}", "Object getTaxes(Address shippingAddress, String itemReferenceId, int quantity, Float price,\n String userId, Boolean submitTax);", "public BigDecimal getLBR_ICMSST_TaxAdded();", "public BigDecimal getLBR_ICMSST_TaxAmt();", "public Double calculateTax(Employee employee) {\n\n Double tax = 0.0;\n\n if ( employee != null ) {\n\n Double salary = employee.getSalary();\n if ( salary > 0 ) {\n\n if ( salary < 500000 ) {\n\n tax = salary * 0.05;\n } else if ( salary > 500000 && salary < 1000000 ) {\n\n tax = salary * 0.1;\n } else {\n\n tax = salary * 0.2;\n }\n }\n }\n\n return tax;\n }", "public double getTotale() {\n\t\t\treturn totale;\n\t\t}", "public Tax getTax() {\n if (tax == null) {\n tax = new Tax();\n }\n return tax;\n }", "@Override\n protected void chooseTax(){\n // Lets impose a tax rate that is inversely proportional to the number of subordinates I have:\n // That is, the more subordinates I have, the lower the tax rate.\n if(myTerritory.getSubordinates().isEmpty()){\n tax = 0;\n }\n else tax = 0.5;\n\n // Of course, if there are tax rates higher than .5, the system will set it to zero, so you should check on that\n }", "public BigDecimal getTrxAmt();", "public void setTax(Double tax);", "@Override\n\tpublic double calculateTax(double sal, double inv) {\n\t\tdouble tax;\n\t\tdouble taxIncom = sal-inv;\n\t\tif(taxIncom<500000) {\n\t\t\ttax = taxIncom*0.10;\n\t\t}else if(taxIncom<2000000){\n\t\t\ttax = 500000*0.10;\n\t\t\ttax += (taxIncom-500000)*0.20;\n\t\t}else{\n\t\t\ttax = 500000*0.10;\n\t\t\ttax += 1500000*0.20;\n\t\t\ttax += (taxIncom-2000000)*0.30;\n\t\t}\n\t\t\n\t\treturn tax;\n\t}", "public BigDecimal getLBR_TaxBaseAmt();", "public abstract void calcuteTax(Transfer aTransfer);", "public void caltotalprice(){\n \tthis.mTotalPrice = 0;\n \tif (this.isCoachSeat) {\n \t\tfor (Flight f: this.mLegs) {\n \t\t\tthis.mTotalPrice += f.coachprice();\n \t\t}\n \t}else {\n \t\tfor (Flight f: this.mLegs) {\n \t\t\tthis.mTotalPrice += f.firstclassprice();\n \t\t}\n \t}\n }", "public double calculateCost() {\n double output = price * (1 + taxRate);\n return output;\n }", "public String getTaxCalculated()\n\t{\n\t\twaitForVisibility(taxCalculated);\n\t\treturn taxCalculated.getText();\n\t}", "public double calculateTax(double planFee, double overageCost) {\n double tax = (planFee + overageCost) * 0.15;\n return tax;\n }", "public BigDecimal getLBR_DIFAL_TaxAmtFCPUFDest();" ]
[ "0.7447785", "0.7435607", "0.7334814", "0.7259545", "0.7213223", "0.7052852", "0.70457363", "0.7033349", "0.700859", "0.6965866", "0.69190216", "0.6814045", "0.6804652", "0.67858565", "0.67635626", "0.67282605", "0.6723675", "0.6704191", "0.6690043", "0.6671107", "0.66557246", "0.66520983", "0.6646979", "0.66431284", "0.66417384", "0.6612459", "0.6555063", "0.6525516", "0.652003", "0.6514093", "0.65106875", "0.6506249", "0.6496303", "0.6494019", "0.64611393", "0.6459746", "0.6450362", "0.6440386", "0.6440101", "0.6430027", "0.64104784", "0.64047915", "0.63706416", "0.63491315", "0.6348759", "0.6341945", "0.63369966", "0.6327419", "0.6271916", "0.62718415", "0.6266692", "0.6248889", "0.623057", "0.6224533", "0.61857915", "0.61601377", "0.6146609", "0.61264676", "0.6124517", "0.6103672", "0.60925364", "0.60792494", "0.60787904", "0.6076644", "0.60568595", "0.60552657", "0.6044516", "0.60387844", "0.6037684", "0.60320216", "0.6019303", "0.59871745", "0.5986158", "0.59856695", "0.5970789", "0.59699994", "0.5967032", "0.5927988", "0.5913701", "0.59036773", "0.58927435", "0.58839196", "0.587449", "0.5866179", "0.5865348", "0.5848856", "0.5838188", "0.5810073", "0.5780853", "0.57797647", "0.5774995", "0.576245", "0.57535523", "0.57400477", "0.5729818", "0.57264155", "0.5726182", "0.5725646", "0.57178146", "0.5701676" ]
0.7228071
4
Returns total fees for a ticket
public double getFees(){ return (this.getPassengerFacilityFee() + this.get911SecurityFee()); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private void calcTotalAmount(){\n\t totalAmount = 0;\n\t\tfor(FlightTicket ft : tickets)\n\t\t{\n\t\t\ttotalAmount += ft.getClassType().getFee() * getFlight().getFlightCost();\n\t\t}\n\t\tsetTotalAmount(totalAmount);\n\t}", "public BigDecimal getTotalFee() {\n return totalFee;\n }", "@Override\n\tpublic int fees() {\n\t\treturn 25000;\n\t\t\n\t}", "public String getTotalAmountOfTicketFlight()\n\t{\n\t\tint sum;\n\n\t\tint departurePriceAtbottom = Integer.parseInt(getDepartureFlightPriceAtBottom().replaceAll(\"[Rs ,]\", \"\"));\n\t\tint returnPriceAtbottom = Integer.parseInt(getReturnFlightPriceAtBottom().replaceAll(\"[Rs ,]\", \"\"));\n\t\t\n\t\twaitForSeconds(5);\n\n\t\tif(driver.getPageSource().contains(\"Return trip discount\")) {\n\t\t\tint dAmount = Integer.parseInt(discountTagAmount.getText().replaceAll(\"[Rs ]\", \"\"));\n\t\t\tsum = (departurePriceAtbottom + returnPriceAtbottom)- dAmount;\n\n\t\t}\n\t\telse \n\t\t{\n\n\t\t\tsum = departurePriceAtbottom + returnPriceAtbottom;\n\t\t}\n\n\n\t\treturn String.valueOf(sum);\n\t}", "public BigDecimal getFee() {\r\n return fee;\r\n }", "public double getTotalFactoringFee() {\n return totalFactoringFee;\n }", "public int remainingFees()\r\n\t{\r\n\t\treturn feesTotal-feesPaid;\t\t\r\n\t}", "public BigDecimal getFee() {\n return fee;\n }", "public double calFee() {\n return weight * FEE + GiftBox.this.price;\n }", "@Override\r\n\tpublic long[] getTicketMoney() {\n\t\tlong[] result = new long[2];\r\n\t\tList<FeeRecord> card = feeRecordDao.getCardRecords();\r\n\t\tList<FeeRecord> cash = feeRecordDao.getCashRecords();\r\n\t\tfor(FeeRecord feeRecord:card){\r\n\t\t\tresult[0] += feeRecord.getMoney();\r\n\t\t}\r\n\t\tfor(FeeRecord feeRecord:cash){\r\n\t\t\tresult[1] += feeRecord.getMoney();\r\n\t\t}\r\n\t\treturn result;\r\n\t}", "public BigDecimal getFee() {\n return fee;\n }", "public double totalFee(){\n return (this.creditHours*this.feePerCreditHour)-this.scholarshipAmount+((this.healthInsurancePerAnnum*4)/12);\n }", "public int getFee()\n {\n return fee;\n }", "public double getFee() {\n\t\treturn fee;\n\t}", "public long getFee() {\n return fee_;\n }", "public long getFee() {\n return fee_;\n }", "public BigDecimal getEstimatedFees() {\n return estimatedFees;\n }", "public String getFee() {\n\t\treturn fee;\n\t}", "public int getRemainingFees() {\n\t\treturn totalFees - feesPayed;\n\t}", "public BigDecimal\tgetOrderFee();", "public AmountType getFee() {\n\t return this.fee;\n\t}", "private double calculateTotalFeesEarned(ArrayList<Pair<Fees, Time>> timeslots) {\n double sumOfFees = 0.00;\n for (DayOfWeek day : DayOfWeek.values()) {\n sumOfFees += calculateFeesEarnedEachDayOfWeek(timeslots, day);\n }\n return sumOfFees;\n }", "public double FullfagetPrice()\n {\n double futlfaget = totalpris + fragt;\n return futlfaget;\n\n }", "public PriceToEstimateFees getPriceToEstimateFees() {\n return priceToEstimateFees;\n }", "public double tuitionFee(){\n return this.creditHours*this.feePerCreditHour;\n }", "public float calculate(Ticket t) {\n\t}", "@Override\n\tpublic List<Fee_Entity> get_all_fee() {\n\t\treturn fee.get_all_fee();\n\t}", "public int getEntryFee() {\n\t\treturn entryFee;\n\t}", "private double getFee(int ISBN) {\r\n\t\t/* Query to get the fee */\r\n\t\tdouble price = db.findPrice(ISBN);\r\n\t\tSystem.out.println(\"price that you're charging: \" + price / 2);\r\n\t\treturn (price / 2);\r\n\t}", "public Number getFee() {\n return (Number) getAttributeInternal(FEE);\n }", "public void totalFacturaVenta(){\n BigDecimal totalVentaFactura = new BigDecimal(0);\n \n try{\n //Recorremos la lista de detalle y calculamos la Venta total de la factura\n for(Detallefactura det: listDetalle){\n //Sumamos a la variable 'totalVentaFactura'\n totalVentaFactura = totalVentaFactura.add(det.getTotal());\n } \n }catch(Exception e){\n e.printStackTrace();\n }\n \n //Setemos al objeto Factura el valor de la variable 'totalFacturaVenta'\n factura.setTotalVenta(totalVentaFactura);\n \n }", "public int getFee(){return 0;}", "public void setTotalFactoringFee(double totalFactoringFee) {\n this.totalFactoringFee = totalFactoringFee;\n }", "public int getFeesPayed() {\n\t\treturn feesPayed;\n\t}", "@Override\n public double calcSalesFee() {\n return getCost() + getSalesPurchase();\n }", "private void getOrderServiceFee(Long id) {\n new FetchOrderServiceFee(id, new FetchOrderServiceFee.InvokeOnCompleteAsync() {\n @Override\n public void onComplete(String orderServiceFee) {\n updateServiceFee(Float.valueOf(orderServiceFee));\n }\n\n @Override\n public void onError(Throwable e) {\n LoggerHelper.showErrorLog(\"Error: \", e);\n }\n });\n }", "public void payFees(int fees) {\n feesPaid += fees;\n School.updateTotalMoneyEarned(feesPaid);\n }", "public double getExpensesTotal(){\n\t\tdouble expensesTotal = (((Number)(rentFTF.getValue())).doubleValue()\n\t\t\t\t+ ((Number)(lightBillFTF.getValue())).doubleValue()\n\t\t\t\t+ ((Number)(phoneBillFTF.getValue())).doubleValue()\n\t\t\t\t+ ((Number)(cableBillFTF.getValue())).doubleValue()\n\t\t\t\t+ ((Number)(carPaymentFTF.getValue())).doubleValue()\n\t\t\t\t+ ((Number)(doctorFTF.getValue())).doubleValue()\n\t\t\t\t+ ((Number)(gasFTF.getValue())).doubleValue()\n\t\t\t\t+ ((Number)(furnFTF.getValue())).doubleValue()\n\t\t\t\t+ ((Number)(expensesOtherFTF.getValue())).doubleValue());\n\t\t\n\t\treturn expensesTotal;\n\t}", "public void setFee(int fee)\n {\n this.fee = fee;\n }", "public double ticketPrice() {\n return ticketsCalculator.calculateTicketPrice();\n }", "@Override\r\n public double purchaseFee(){\r\n return fee;\r\n }", "public BigDecimal getMonthFee() {\r\n return monthFee;\r\n }", "TotalInvoiceAmountType getTotalInvoiceAmount();", "@Override\r\n\tpublic int[] getTicketCount() {\n\t\tint[] result = new int[2];\r\n\t\tList<FeeRecord> card = feeRecordDao.getCardRecords();\r\n\t\tList<FeeRecord> cash = feeRecordDao.getCashRecords();\r\n\t\tresult[0] = card.size();\r\n\t\tresult[1] = cash.size();\r\n\t\treturn result;\r\n\t}", "public void setFee(BigDecimal fee) {\r\n this.fee = fee;\r\n }", "public double getServiceFee() {\r\n\t\treturn 0.00;\r\n\t}", "public int calculateShippingFee(Order order) {\n\t\tRandom rand = new Random();\n\t\tint fees = (int) (((rand.nextFloat() * 10) / 100) * order.getAmount());\n\t\tLOGGER.info(\"Order Amount: \" + order.getAmount() + \" -- Shipping Fees: \" + fees);\n\t\treturn fees;\n\t}", "public double getContestFee() {\r\n return contestFee;\r\n }", "public void updateStudentFees(double fees){\n feesPaid+=fees;\n school.updateMoneyEarned(feesPaid);\n }", "public void setFee(BigDecimal fee) {\n this.fee = fee;\n }", "public void setTotalFee(BigDecimal totalFee) {\n this.totalFee = totalFee;\n }", "public Double getTotalBuyFee() {\r\n return totalBuyFee;\r\n }", "@Override\n\tpublic Integer getPayTotalFee() {\n\t\treturn getRealRegFee() + getRealTreatFee();\n\t}", "private BigDecimal getCardServiceFeeAmount(final CartReceiptResponse receiptResponse\n , final PdfPTable paymentSectionTable, final PdfPCell blankSpaceCell, final Locale locale) {\n\n \t/* Get funding source from the CART_RECEIPT_REPRINT response */\n final FundingSourceResponse[] fundingSource = receiptResponse.getFundingSources();\n final SubmittedBill[] submittedBills = receiptResponse.getSubmittedBills();\n /* Initializing serviceFee */\n final BigDecimal serviceFee = addServiceFee(submittedBills);\n for (final FundingSourceResponse aFundingSource : fundingSource) {\n /* Check for the DEBIT/CREDIT card instance */\n if (aFundingSource instanceof VestaFundingSourceResponse) {\n /* ServiceFeePercentRate is null treating it as ZERO other wise get the value */\n BigDecimal cardServiceFeePercent = aFundingSource.getServiceFeePercentRate() == null\n ? new BigDecimal(0) : aFundingSource.getServiceFeePercentRate();\n /* In case seviceFee amount is > ZERO then execute the below block of code to display the line above the total bills */\n if (serviceFee.compareTo(BigDecimal.ZERO) > 0 && cardServiceFeePercent.compareTo(BigDecimal.ZERO) > 0) {\n /* Cell for the card service percent label */\n Font font = getFont(null, FONT_SIZE_12, Font.NORMAL);\n String message = getMessage(locale, \"pdf.receipt.serviceFee\", cardServiceFeePercent);\n PdfPCell serviceFeeLabel = new PdfPCell(new Phrase(message, font));\n /* Cell for the card service fee amount */\n PdfPCell serviceFeeTotal = new PdfPCell(\n new Phrase(getFormattedAmount(serviceFee), font));\n /* Adding above cells to table */\n cellAlignment(serviceFeeLabel, Element.ALIGN_LEFT, WHITE_COLOR, 0);\n cellAddingToTable(paymentSectionTable, serviceFeeLabel, Rectangle.NO_BORDER, 2, 15);\n\n cellAlignment(serviceFeeTotal, Element.ALIGN_RIGHT, WHITE_COLOR, 0);\n cellAddingToTable(paymentSectionTable, serviceFeeTotal, Rectangle.NO_BORDER, 0, 0);\n\t\t\t\t\t/* Adding blank space to table */\n cellAlignment(blankSpaceCell, Element.ALIGN_LEFT, GRAY_COLOR, 0);\n cellAddingToTable(paymentSectionTable, blankSpaceCell, Rectangle.NO_BORDER, 3, 0);\n }\n }\n }\n return serviceFee;\n }", "public List<FeeComponent> getFeeList() {\r\n if (feeList==null) {\r\n feeList = new ArrayList<FeeComponent>();\r\n }\r\n return feeList;\r\n }", "public void setFee(String fee) {\n\t\tthis.fee = fee;\n\t}", "public float calculateTotalFee(){\n int endD = parseInt(endDay);\n int startD = parseInt(startDay);\n int endM = parseInt(convertMonthToDigit(endMonth));\n int startM = parseInt(convertMonthToDigit(startMonth));\n int monthDiff = 0;\n float totalFee = 0;\n //get the stay duration in months\n monthDiff = endM - startM;\n \n System.out.println(\"CALCULATING TOTAL FEE:\");\n \n stayDuration = 1;\n if(monthDiff == 0){ //on the same month\n if(startD == endD){\n stayDuration = 1;\n }else if(startD < endD){ //Same month, diff days\n stayDuration = 1 + (parseInt(endDay) - parseInt(startDay));\n }\n }else if(monthDiff > 0){ //1 month difference\n \n if(startD > endD){ // End day is next month\n switch(startMonth){\n case \"January\": case \"March\": case \"May\": case \"July\": case \"August\": \n case \"October\": case \"December\":\n stayDuration = 1 + ( (31+ parseInt(endDay)) - parseInt(startDay));\n break;\n\n case \"April\": case \"June\": case \"September\": case \"November\":\n stayDuration = 1 + ((30+ parseInt(endDay)) - parseInt(startDay));\n break; \n \n case \"February\": \n stayDuration = 1 + ((29+ parseInt(endDay)) - parseInt(startDay));\n break; \n default:\n break;\n }\n }else if(startD <= endD){ //if end day is greater than start day\n switch(startMonth){\n case \"January\": case \"March\": case \"May\": case \"July\": case \"August\": \n case \"October\": case \"December\":\n stayDuration = 1 + ((parseInt(endDay)) - parseInt(startDay));\n stayDuration += 31;\n break;\n\n case \"April\": case \"June\": case \"September\": case \"November\":\n stayDuration = 1 + ( (parseInt(endDay)) - parseInt(startDay));\n stayDuration += 30;\n break; \n \n case \"February\": \n stayDuration = 1 + ( (parseInt(endDay)) - parseInt(startDay));\n stayDuration += 29;\n break; \n \n default:\n break;\n }\n }\n }else if(monthDiff < 0){\n if(startMonth == \"December\" && endMonth == \"January\"){\n if(startD > endD){ // End day is next month\n switch(startMonth){\n case \"January\": case \"March\": case \"May\": case \"July\": case \"August\": \n case \"October\": case \"December\":\n stayDuration = 1 + ( (31+ parseInt(endDay)) - parseInt(startDay));\n break;\n\n case \"April\": case \"June\": case \"September\": case \"November\":\n stayDuration = 1 + ((30+ parseInt(endDay)) - parseInt(startDay));\n break; \n\n case \"February\": \n stayDuration = 1 + ((29+ parseInt(endDay)) - parseInt(startDay));\n break; \n default:\n break;\n }\n }else{\n stayDuration = 1 + ((parseInt(endDay)) - parseInt(startDay));\n stayDuration += 31;\n }\n }\n }\n \n totalFee = (int) (getSelectedRoomsCounter() * getSelectedRoomPrice());\n totalFee *= stayDuration;\n \n //console log\n System.out.println(\"stayDuration: \"+ stayDuration);\n System.out.println(\"Total Fee: \" + totalFee +\"php\");\n return totalFee;\n }", "BigDecimal getTotal();", "BigDecimal getTotal();", "public Float getDeliveryfee() {\n return deliveryfee;\n }", "public String add(Ticket ticket){\n Receipt receipt = new Receipt(ticket);\n receipts.put(receipt.getReceiptId(), receipt);\n return receipt.getAmountDueString();\n }", "public void payFees(int fees) {\n feesPaid += fees;\n feesRemaining -= fees;\n School.updateTotalMoneyEarned(fees);\n }", "public int getDeliveryFee()\n {\n return deliveryFee;\n }", "public static double getTotal(double tuition, double gnsf, double erf){\r\n double total = 0;\r\n total = tuition + gnsf + erf;\r\n return total;\r\n }", "public float getTotal(){\r\n\t\treturn Total;\r\n\t}", "private BigDecimal addServiceFee(final SubmittedBill[] submittedBills) {\n BigDecimal serviceFee = new BigDecimal(0);\n for (final SubmittedBill submittedBill : submittedBills) {\n if (!getStatusForRejected(submittedBill.getStatus().name())) {\n serviceFee = serviceFee.add(submittedBill.getServiceFee());\n }\n\n }\n return serviceFee;\n }", "public static float getTotal() {\n return total;\r\n }", "@Override\n\tpublic Integer getRefundTotalFee() {\n\t\treturn getRealRegFee() + getRealTreatFee();\n\t}", "public BigDecimal getRevenueFee() {\r\n return revenueFee;\r\n }", "public String getTotalDeposits(){\n double sum = 0;\n for(Customer record : bank.getName2CustomersMapping().values()){\n for(Account acc: record.getAccounts()){\n sum += acc.getOpeningBalance();\n }\n }\n return \"Total deposits: \"+sum;\n }", "public FeeComponentList getFeeList() {\n return feeList;\n }", "public abstract double getLateFee(int daysLate);", "@Override\n\tpublic double getRentalFee() {\n\t\treturn 10;\n\t}", "public double calculateFee(int width)\t\t{\n\t\tdouble fee;\n\n\t\tswitch(width)\t{\n\t\t\tcase 10:\n\t\t\t\tfee = 800;\n\t\t\t\tbreak;\n\t\t\tcase 12:\n\t\t\t\tfee = 900;\n\t\t\t\tbreak;\n\t\t\tcase 14:\n\t\t\t\tfee = 1100;\n\t\t\t\tbreak;\n\t\t\tcase 16:\n\t\t\t\tfee = 1500;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tfee = 0;\n\t\t}\n\n\t\treturn fee;\n\t}", "public abstract double getComplianceFee();", "public void setFee(AmountType fee) {\n\t this.fee = fee;\n\t}", "public double getTotalFasjabtel() {\n return this.totalFasjabtel;\n }", "public double calTotalAmount(){\n\t\tdouble result=0;\n\t\tfor (int i = 0; i < this.cd.size(); i++) {\n\t\t\tresult += this.cd.get(i).getPrice();\n\t\t}\n\t\treturn result;\n\t}", "public Float getFreemintotalprice() {\n return freemintotalprice;\n }", "public String RevenueDerniere(){\n List<Ticket> tickets=ticketRepository.findAll();\n double revenueJours=0,revenueSemaine=0,revenuemois=0;\n for (Ticket ticket:tickets){\n if (ticket.getDate().isAfter(Instant.now().minus(Period.ofDays(30)))){\n revenuemois=revenuemois+ticket.getAddition();\n }\n if (ticket.getDate().isAfter(Instant.now().minus(Period.ofDays(7)))){\n revenueSemaine=revenueSemaine+ticket.getAddition();\n }\n if (ticket.getDate().isAfter(Instant.now().minus(Period.ofDays(1)))){\n revenueJours=revenueJours+ticket.getAddition();\n }\n }\n\n return \"Revenue moins derniere :\"+revenuemois+\"\\n Revenue semaine derniere :\"+revenueSemaine+\"\\n \"\n\t\t+ \"Revenue jour derniere :\"+revenueJours;\n }", "@Override\n\tpublic List<ServiceFee> findAll() {\n\t\treturn servicefeerepo.findAll();\n\t}", "public float calcularTotalPagosFactura(FacturaIngreso factura){\n float total = (float) 0.00;\n if(factura != null){\n if(!factura.getPagoCompraCollection().isEmpty()){\n BigDecimal suma = BigDecimal.ZERO;\n for(PagoCompra actual : factura.getPagoCompraCollection()){\n suma = suma.add(actual.getTotalPagoCompra());\n }\n total = new funciones().redondearMas(suma.floatValue(), 2);\n }\n }\n return total;\n }", "public Double calculateTotal(String type, Double price, Double numberOfCoins, Double fees) {\n\t\tif (type == \"Kauf\") {\n\t\t\treturn (price * numberOfCoins) + fees;\n\t\t} else {\n\t\t\treturn ((price * numberOfCoins) + fees) * -1;\n\t\t}\n\t}", "public String getAdmissionFees() {\n return mAdmissionFees;\n }", "public void caltotalprice(){\n \tthis.mTotalPrice = 0;\n \tif (this.isCoachSeat) {\n \t\tfor (Flight f: this.mLegs) {\n \t\t\tthis.mTotalPrice += f.coachprice();\n \t\t}\n \t}else {\n \t\tfor (Flight f: this.mLegs) {\n \t\t\tthis.mTotalPrice += f.firstclassprice();\n \t\t}\n \t}\n }", "public BigDecimal getTixianFee() {\r\n return tixianFee;\r\n }", "double getTodaysExpenditureAmount() {\n Long time = new Date().getTime();\n Date date = new Date(time - time % (DAY_DURATION));\n return getExpenditureAmount(date.getTime(), date.getTime() + (DAY_DURATION));\n }", "public double obtener_total(){\r\n double total_ventas = precio*unidades;\r\n return total_ventas;\r\n }", "public int getTotalAmount();", "@Override\n\tpublic double getPremiumFee(FDRuleContextI ctx) {\n\t\treturn 0;\n\t}", "public String getFeeDescription() {\n return feeDescription;\n }", "public BigDecimal getFC_AMOUNT() {\r\n return FC_AMOUNT;\r\n }", "public HashMap<String, Double> getTagsFees(Tag tag) throws IOException {\n\t\treturn Core.getTagFee(tag, getHttpMethodExecutor());\n\t}", "public BigDecimal getTotal() {\n return total;\n }", "public BigDecimal getTotal() {\n return total;\n }", "public BigDecimal getAdvisorFee() {\r\n return advisorFee;\r\n }", "public int getTotalEarnings() {\r\n\t\tint total = 0;\r\n\t\tfor (int i = 0; i < this.receiptissued.size(); i++) {\r\n\t\t\ttotal = total + this.receiptissued.get(i).getPrice();\r\n\t\t}\r\n\t\treturn total;\r\n\r\n\t}", "@Test(enabled = false)\n @JIRATestKey(key = \"TEST-4\")\n public void checkMultipleFlightsTotalSum() {\n SearchResultPage searchResultPage = new WelcomePage()\n .getHomePage()\n .addMultipleDestinations()\n .setOutboundInformation(\"Bologna, Italy\", \"Eindhoven, Netherlands\", \"24 Nov 2017\")\n .setInboundInformation(\"Amsterdam (Schiphol), Netherlands\", \"Casablanca, Morocco\", \"30 Nov 2017\")\n .search()\n .selectFirstOutbound()\n .selectFirstInbound();\n\n Assert.assertEquals(searchResultPage.getTotalPrice(), \"102.00\");\n }", "public String getTotalFareAmt()\n\t{\n\n\t\tString totalamt = totalFareAmount.getText().replaceAll(\"[Rs ,]\", \"\");\n\n\t\treturn String.valueOf(totalamt);\n\t}", "public float getTcintmtotal()\r\n {\r\n return _tcintmtotal;\r\n }" ]
[ "0.7251223", "0.68894714", "0.6847359", "0.66682285", "0.66643524", "0.6658479", "0.6645743", "0.66407347", "0.6616467", "0.66145295", "0.66038376", "0.6599374", "0.65652233", "0.65433466", "0.65432316", "0.6535658", "0.65012205", "0.6350106", "0.63200444", "0.61810666", "0.6172374", "0.61625373", "0.6084824", "0.60794616", "0.6075344", "0.6065324", "0.60374063", "0.6024657", "0.60137576", "0.5994324", "0.59090626", "0.5862296", "0.5837577", "0.57982266", "0.578076", "0.57624656", "0.574083", "0.57382154", "0.5736554", "0.5699279", "0.56917894", "0.56706107", "0.5669245", "0.566252", "0.5662384", "0.56509894", "0.5650693", "0.5623526", "0.56212795", "0.56160814", "0.56127906", "0.5591647", "0.5587285", "0.55805486", "0.55685467", "0.5565138", "0.55553734", "0.55546814", "0.55546814", "0.55361205", "0.55257034", "0.5522648", "0.5498604", "0.54614073", "0.54528004", "0.54441214", "0.54282516", "0.5414743", "0.5413202", "0.5405902", "0.5400651", "0.53937376", "0.53899413", "0.53842634", "0.53838545", "0.5383296", "0.5383212", "0.53799266", "0.5376995", "0.5366715", "0.5356231", "0.53560704", "0.53513885", "0.5346148", "0.53141654", "0.5303636", "0.52794707", "0.5275035", "0.52680427", "0.52639085", "0.52494437", "0.5246423", "0.5244444", "0.523796", "0.523796", "0.5235127", "0.5235069", "0.5234405", "0.52251726", "0.52248776" ]
0.69839835
1
Returns departurute and arrival times in standard (rather than military format)
public String getRegDepTime(){ String[] regularTime = this.depTime.split(":"); int hours = Integer.parseInt(regularTime[0]); int depTimeHours; if(hours<12){ depTimeHours = hours; return regularTime[0] + ":" + regularTime[1] + "AM"; } else if(hours == 12){ depTimeHours = hours; return regularTime[0] + ":" + regularTime[1] + "PM"; } else{ depTimeHours = hours-12; regularTime[0] = String.valueOf(depTimeHours); return regularTime[0] + ":" + regularTime[1] + "PM"; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "java.lang.String getDepartureTime();", "java.lang.String getDepartureTime();", "java.lang.String getArrivalTime();", "java.lang.String getArrivalTime();", "public String getDepartureTime() {\n return departTime;\n }", "public String TI()\n\t{\n\t\tDateTimeFormatter f = DateTimeFormatter.ofPattern(\"hh:mm a\");\n\t\tString ti = f.format(st);\n\t\tString ti2 = f.format(et);\n\t\treturn ti + \" - \" + ti2;\n \t}", "private String timeConversion() {\n Calendar local = Calendar.getInstance();\n Calendar GMT = Calendar.getInstance(TimeZone.getTimeZone(\"GMT\"));\n\n //Time from the PINPoint\n int hours, minutes, seconds, day, month, year;\n hours = (record[10] & 0xF8) >> 3;\n minutes = ((record[10] & 0x07) << 3) + ((record[11] & 0xE0) >> 5);\n seconds = ((record[11] & 0x1F) << 1) + ((record[12] & 0x80) >> 7);\n seconds += (record[12] & 0x7F) / 100;\n day = (record[13] & 0xF8) >> 3;\n month = ((record[13] & 0x07) << 1) + ((record[14] & 0x80) >> 7);\n year = (record[14] & 0x7F) + 2000;\n \n month--; //Months in java are 0-11, PINPoint = 1-12;\n\n //Set GMTs time to be the time from the PINPoint\n GMT.set(Calendar.DAY_OF_MONTH, day);\n GMT.set(Calendar.MONTH, month);\n GMT.set(Calendar.YEAR, year);\n GMT.set(Calendar.HOUR_OF_DAY, hours);\n GMT.set(Calendar.MINUTE, minutes);\n GMT.set(Calendar.SECOND, seconds);\n\n //Local is set to GMTs time but with the correct timezone\n local.setTimeInMillis(GMT.getTimeInMillis());\n\n //Set Local time to be the time converted from GMT\n int lHours, lMinutes, lSeconds, lDay, lMonth, lYear;\n lHours = local.get(Calendar.HOUR_OF_DAY);\n lMinutes = local.get(Calendar.MINUTE);\n lSeconds = local.get(Calendar.SECOND);\n lDay = local.get(Calendar.DAY_OF_MONTH);\n lMonth = local.get(Calendar.MONTH);\n\n lMonth++; //Months in java are 0-11, humans read 1-12\n\n lYear = local.get(Calendar.YEAR);\n\n return hR(lMonth) + \"/\" + hR(lDay) + \"/\" + lYear + \" \" + hR(lHours) + \":\" + hR(lMinutes) + \":\" + hR(lSeconds);\n }", "java.lang.String getTransitFlightDuration();", "public String getDepartureTime (){\n\t\treturn mDeparture;\n\t}", "public String getFormattedDepartureTime() {\n return getDepartureTime().getFormattedDateTime();\n }", "java.lang.String getTransitAirportDuration();", "private String prettyTime() {\n String[] dt = time.split(\"T\");\n String[] ymd = dt[0].split(\"-\");\n String[] hms = dt[1].split(\":\");\n\n int hour = Integer.parseInt(hms[0]);\n\n String date = getMonth(Integer.parseInt(ymd[1])) + \" \" + ymd[2] + \", \" + ymd[0];\n String time = (hour > 12 ? hour - 12 : hour) + \":\" + hms[1] + \":\" + hms[2].substring(0, hms[2].indexOf(\".\"));\n return date + \" at \" + time;\n }", "public static String TimeFormate() {\n\t\tString time;\n\t\tSimpleDateFormat dateFormat1 = new SimpleDateFormat();\n\t dateFormat1.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t Calendar cal = Calendar.getInstance();\n\t cal.add(Calendar.MINUTE, 3);\n String n=dateFormat1.format(cal.getTime());\n //n=\"03/09/20 8:30 AM\";\n System.out.println(\"Full Date = \" +n);\n int colonindex=n.indexOf(\":\");\n //System.out.println(\": placed= \" +colonindex);\n //String tt =n.substring(colonindex, n.length());\n //System.out.println(\"tt= \" +tt);\n String tt1 =n.substring(colonindex-2,colonindex-1);\n System.out.println(\"tt1= \" +tt1);\n if(tt1.equals(\"1\")) {\n \t time=n.substring(colonindex-2, n.length());\n \t System.out.println(\"Time with two digits in hours= \" +time);\n }\n else {\n \t time=n.substring(colonindex-1, n.length());\n \t System.out.println(\"Time with one digit in hours= \" +time);\n }\n return time;\n\t}", "public String getAvailableTime() {\n String output = \"\";\n for (int i = 0; i < 24; ++i) {\n if (availableTime[i] == true) {\n output += i;\n break;\n }\n }\n output += \" to \";\n for (int i = 23; i >= 0; --i) {\n if (availableTime[i] == true) {\n output += i;\n break;\n }\n }\n return output;\n }", "public String getFormatedTime() {\n DateFormat displayFormat = new SimpleDateFormat(\"HH:mm\", Locale.GERMAN);\n return displayFormat.format(mEvent.getTime());\n }", "public String getPrintFormattedTime() {\n return this.optionalTime.map(x -> x.format(DateTimeFormatter.ofPattern(\"HHmma\"))).orElse(\"\");\n }", "private static String timeLine()\n {\n return String.format(STR_FORMAT_1 + STR_FORMAT_2, TIME_STR, TIME);\n }", "@Override\n public String getDepartureString() {\n return this.departDate + \" \" + this.departTime;\n }", "public java.lang.String getDepartureTime() {\n java.lang.Object ref = departureTime_;\n if (!(ref instanceof java.lang.String)) {\n com.google.protobuf.ByteString bs =\n (com.google.protobuf.ByteString) ref;\n java.lang.String s = bs.toStringUtf8();\n departureTime_ = s;\n return s;\n } else {\n return (java.lang.String) ref;\n }\n }", "public java.lang.String getDepartureTime() {\n java.lang.Object ref = departureTime_;\n if (!(ref instanceof java.lang.String)) {\n com.google.protobuf.ByteString bs =\n (com.google.protobuf.ByteString) ref;\n java.lang.String s = bs.toStringUtf8();\n departureTime_ = s;\n return s;\n } else {\n return (java.lang.String) ref;\n }\n }", "java.lang.String getDepartureAirport();", "public String toString() {\n\t\tthis.setDepartureTime(System.currentTimeMillis());\n\t\tfloat waittime = (float)(departureTime - arrivalTime) / 1000 ;\n\n\t\treturn \"[Time \" + departureTime + \"] Omnibus #\" + vehicleNumber + \" (\" + getBound() + \"). Tiempo total de espera \" + waittime + \" segundos.\";\n\t}", "public java.lang.String getDepartureTime() {\n java.lang.Object ref = departureTime_;\n if (ref instanceof java.lang.String) {\n return (java.lang.String) ref;\n } else {\n com.google.protobuf.ByteString bs = \n (com.google.protobuf.ByteString) ref;\n java.lang.String s = bs.toStringUtf8();\n departureTime_ = s;\n return s;\n }\n }", "public java.lang.String getDepartureTime() {\n java.lang.Object ref = departureTime_;\n if (ref instanceof java.lang.String) {\n return (java.lang.String) ref;\n } else {\n com.google.protobuf.ByteString bs = \n (com.google.protobuf.ByteString) ref;\n java.lang.String s = bs.toStringUtf8();\n departureTime_ = s;\n return s;\n }\n }", "private String TimeConversion() {\n\n int hours, minutes, seconds, dayOfWeek, date, month, year;\n\n seconds = ((raw[27] & 0xF0) >> 4) + ((raw[28] & 0x03) << 4);\n minutes = ((raw[28] & 0xFC) >> 2);\n hours = (raw[29] & 0x1F);\n dayOfWeek = ((raw[29] & 0xE0) >> 5);\n date = (raw[30]) & 0x1F;\n month = ((raw[30] & 0xE0) >> 5) + ((raw[31] & 0x01) << 3);\n year = (((raw[31] & 0xFE) >> 1) & 255) + 2000;\n\n\n\n return hR(month) + \"/\" + hR(date) + \"/\" + year + \" \" + hR(hours) + \":\" + hR(minutes) + \":\" + hR(seconds) + \":00\";\n }", "private static String getTime() {\n\t\tDate getDate = new Date();\n\t\tString timeFormat = \"M/d/yy hh:mma\";\n\t\tSimpleDateFormat sdf = new SimpleDateFormat(timeFormat);\n\t\treturn \"[\" + sdf.format(getDate) + \"]\\t\";\n\t}", "public String getTimeString() {\n int hour = date.get(Calendar.HOUR);\n int minute = date.get(Calendar.MINUTE);\n\n String AM_PM = \"PM\";\n if (date.get(Calendar.AM_PM) == Calendar.AM) AM_PM = \"AM\";\n\n String hour_fixed = String.valueOf(hour);\n if (hour == 0) hour_fixed = \"12\";\n\n String minute_fixed = String.valueOf(minute);\n while (minute_fixed.length() < 2) {\n minute_fixed = \"0\" + minute_fixed;\n }\n\n return hour_fixed + \":\" + minute_fixed + ' ' + AM_PM;\n }", "java.lang.String getArrivalAirport();", "com.google.protobuf.ByteString\n getDepartureTimeBytes();", "com.google.protobuf.ByteString\n getDepartureTimeBytes();", "@Test\n public void getterDepartureTime(){\n ScheduleEntry entry = new ScheduleEntry();\n entry.setCalendar(calendar);\n entry.setDepartureTime(DepartureTime);\n Assert.assertEquals(\"9:00AM\",entry.getDepartureTime());\n }", "public String getTime(){\n String mt=\"\";\n String hr=\"\";\n if(minute<10){\n mt=0+(String.valueOf(minute));\n }\n\n else{\n mt=String.valueOf(minute);\n }\n\n if(hour<10){\n hr=0+(String.valueOf(hour));\n }\n else{\n hr=String.valueOf(hour);\n }\n //return hour:minute\n return (hr+\":\"+mt);\n }", "@Override\n public String getArrivalString() {\n return this.arriveDate + \" \" + this.arriveTime;\n }", "java.lang.String getFlightLegDuration();", "@Override\r\n\tpublic int connectingTime() {\r\n\t\tint totalTime = 0;\r\n\t\tfor (int i = 0; i < flights.size()-1; i++) {\r\n\t\t\tString time1 = \"\" + flights.get(i).getData().getArrivalTime();\r\n\t\t\tif (time1.length() < 3)\r\n\t\t\t\ttime1 = \"00\" + time1;\r\n\t\t\tif (time1.length() < 4)\r\n\t\t\t\ttime1 = \"0\" + time1;\r\n\t\t\t\r\n\t\t\tString time2 = \"\" + flights.get(i+1).getData().getDepartureTime();\r\n\t\t\tif (time1.length() < 3)\r\n\t\t\t\ttime1 = \"00\" + time1;\r\n\t\t\tif (time2.length() < 4)\r\n\t\t\t\ttime2 = \"0\" + time2;\r\n\t\t\tSimpleDateFormat format = new SimpleDateFormat(\"HHmm\");\r\n\t\t\tDate date1 = null;\r\n\t\t\tDate date2 = null;\r\n\r\n\t\t\ttry {\r\n\t\t\t\tdate1 = format.parse(time1);\r\n\t\t\t} catch (ParseException e) {\r\n\t\t\t\t// TODO Auto-generated catch block\r\n\t\t\t\te.printStackTrace();\r\n\t\t\t}\r\n\t\t\ttry {\r\n\t\t\t\tdate2 = format.parse(time2);\r\n\t\t\t} catch (ParseException e) {\r\n\t\t\t\t// TODO Auto-generated catch block\r\n\t\t\t\te.printStackTrace();\r\n\t\t\t}\r\n\t\t\tlong difference = 0;\r\n\t\t\tdifference = date2.getTime() - date1.getTime();\r\n\t\t\tif(difference < 0) {\r\n\t\t\t\tdifference += 24*60*60*1000;\r\n\t\t\t}\r\n\t\t\ttotalTime += difference;\r\n\t\t}\r\n\t\treturn totalTime;\r\n\t}", "Calendar getDepartureDateAndTime();", "public static void main(String[] args) {\n\t\tString s = \"12:45:54PM\";\r\n\t\tString temp=\":\";\r\n\t\tString Result=\"\";\r\n\t\t\r\n\t\tif(s.charAt(8)=='P' || s.charAt(8)=='p')\r\n\t\t {\r\n\t\t\tString s1[] = s.split(\":\");\r\n\t int Hour = Integer.parseInt(s1[0]);\r\n\t String Actual_Hour = \"\";\r\n\t if(Hour == 12)\r\n\t {\r\n\t \tActual_Hour = \"12\";\r\n\t }\r\n\t else\r\n\t {\r\n\t \tint data = 12 + Hour;\r\n\t \tActual_Hour = String.valueOf(data);\r\n\t }\r\n\t \r\n\t \r\n\t Result = Actual_Hour +temp+s1[1]+temp+s1[2].substring(0, 2);\r\n\t\t }\r\n\t\t else\r\n\t\t {\r\n\t\t \tString s1[] = s.split(\":\");\r\n\t\t \tint Hour = Integer.parseInt(s1[0]);\r\n\t\t String Actual_Hour = \"\";\r\n\t\t if(Hour == 12)\r\n\t\t {\r\n\t\t \tActual_Hour = \"00\";\r\n\t\t \tResult = Actual_Hour +temp+s1[1]+temp+s1[2].substring(0, 2); \r\n\t\t }\r\n\t\t else {\r\n\t\t \tString s2[] = s.split(\"AM\");\r\n\t\t\t for(int i=0; i<s2.length; i++)\r\n\t\t\t {\r\n\t\t\t \tResult = s2[i];\r\n\t\t\t }\t\r\n\t\t }\r\n\t\t \t\r\n\t\t }\r\n\t\t\r\n\t\t\t\tSystem.out.println(Result);\r\n}", "public List<flight> timeSwich(List<flight> FlightInfo, List<airportInformation> airport){\n\t flight ThisInfo = new flight();\n\t airportInformation ai = new airportInformation();\n\t Iterator AllInfo = FlightInfo.iterator();\n\t \n\t SimpleDateFormat OTime = new SimpleDateFormat(\"yyyy_MM_dd HH:mm\");\n\t OTime.setTimeZone(TimeZone.getTimeZone(\"GMT\"));\n\t SimpleDateFormat NTime = new SimpleDateFormat(\"yyyy_MM_dd HH:mm\");\n\t String[] parts;\n\t String ThisTime;\n\t String[] airportName = ai.sortAirportName(airport);\n\t \n\t while (AllInfo.hasNext())\n\t { \n\t ThisInfo= (flight)AllInfo.next();//From this we can get the arriving airport and departing airport\n\t String date = ThisInfo.getDepartingDate()+\" \"+ThisInfo.getDepartingTime();\n\t Date FTime = null;\n\t switch (ai.getAirportRank(airportName, ThisInfo.getDepartingAirport())){\n\t case 0:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/Anchorage\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 1:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/New_York\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 2:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Central\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 3:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 4:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 5:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 6:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/Chicago\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 7:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/Chicago\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 8:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 9:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 10:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 11:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Central\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 12:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/Denver\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 13:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/Detroit\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 14:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 15:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 16:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 17:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"Pacific/Honolulu\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 18:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 19:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 20:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/Indiana/Indianapolis\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 21:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Central\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 22:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Pacific\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 23:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/Los_Angeles\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 24:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Central\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 25:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 26:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Central\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 27:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Central\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 28:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Central\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 29:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/New_York\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 30:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/New_York\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 31:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Pacific\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 32:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Pacific\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 33:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 34:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Pacific\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 35:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 36:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/Phoenix\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 37:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 38:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 39:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Pacific\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 40:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Mountain\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 41:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Central\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 42:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Pacific\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 43:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Pacific\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 44:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Pacific\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 45:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Paciifc\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 46:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Pacific\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 47:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Central\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 48:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 49:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t case 50:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTime= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTime);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setDepartingDate(parts[0]);\n\t ThisInfo.setDepartingTime(parts[1]);\n\t break;\n\t \n\t }\n\t }\n\t Iterator AllInf = FlightInfo.iterator(); \n\t while (AllInf.hasNext())\n\t { ThisInfo=(flight)AllInf.next();\n\t String date = ThisInfo.getArrivingDate()+\" \"+ThisInfo.getArrivingTime();\n\t Date FTim = null;\n\t switch (ai.getAirportRank(airportName, ThisInfo.getArrivingAirport())){\n\t case 0:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/Anchorage\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 1:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/New_York\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 2:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Central\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 3:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 4:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 5:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 6:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/Chicago\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 7:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/Chicago\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 8:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 9:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 10:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 11:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Central\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 12:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/Denver\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 13:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/Detroit\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 14:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 15:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 16:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 17:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"Pacific/Honolulu\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 18:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 19:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 20:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/Indiana/Indianapolis\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 21:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Central\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 22:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Pacific\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 23:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/Los_Angeles\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 24:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Central\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 25:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 26:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Central\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 27:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Central\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 28:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Central\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 29:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/New_York\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 30:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/New_York\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 31:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Pacific\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 32:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Pacific\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 33:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 34:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Pacific\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 35:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 36:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"America/Phoenix\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 37:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 38:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 39:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Pacific\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 40:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Mountain\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 41:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Central\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 42:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Pacific\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 43:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Pacific\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 44:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Pacific\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 45:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Paciifc\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 46:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Pacific\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 47:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Central\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 48:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 49:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t case 50:\n\t NTime.setTimeZone(TimeZone.getTimeZone(\"US/Eastern\"));\n\t try{\n\t FTim= OTime.parse(date);\n\t } catch (ParseException e) {\n\t e.printStackTrace();\n\t }\n\t ThisTime = NTime.format(FTim);\n\t parts = ThisTime.split(\" \");\n\t ThisInfo.setArrivingDate(parts[0]);\n\t ThisInfo.setArrivingTime(parts[1]);\n\t break;\n\t \n\t }\n\t }\n\t \n\t return FlightInfo;\n\t }", "public String[] getTimeAMPMZone(String webinarTime) {\r\n\t\tString[] webinarTimeDetails = new String[4];\r\n\t\tString pattern = \"(^[0-9]+:[0-9][0-9])(\\\\s)([A-Z]M)(\\\\s-\\\\s)([0-9]+:[0-9][0-9])(\\\\s)([A-Z]M)\";\r\n\t\t// Create a Pattern object\r\n\t\tPattern r = Pattern.compile(pattern);\r\n\r\n\t\t// Now create matcher object.\r\n\t\tMatcher m = r.matcher(webinarTime);\r\n\t\twhile (m.find()) {\r\n\t\t\twebinarTimeDetails[0] = m.group(1);\r\n\t\t\twebinarTimeDetails[1] = m.group(3);\r\n\t\t\twebinarTimeDetails[2] = m.group(5);\r\n\t\t\twebinarTimeDetails[3] = m.group(7);\r\n\t\t}\r\n\t\tLog.info(\"Start Time: \" + webinarTimeDetails[0]);\r\n\t\tLog.info(\"Start AMPM: \" + webinarTimeDetails[1]);\r\n\t\tLog.info(\"End Time: \" + webinarTimeDetails[2]);\r\n\t\tLog.info(\"End AMPM: \" + webinarTimeDetails[3]);\r\n\t\treturn webinarTimeDetails;\r\n\t}", "public String getTimeString() {\n // Converts slot to the minute it starts in the day\n int slotTimeMins =\n SlopeManagerApplication.OPENING_TIME * 60 + SESSION_LENGTHS_MINS * getSlot();\n\n Calendar cal = Calendar.getInstance();\n cal.set(Calendar.HOUR_OF_DAY, slotTimeMins/60);\n cal.set(Calendar.MINUTE, slotTimeMins % 60);\n cal.set(Calendar.SECOND, 0);\n cal.set(Calendar.MILLISECOND, 0);\n @SuppressLint(\"SimpleDateFormat\") SimpleDateFormat sdf = new SimpleDateFormat(\"HH:mm\");\n return sdf.format(cal.getTime());\n }", "public int getDepartureTime()\n {\n return departureTime;\n }", "public static double getAttHour(String time1, String time2)\r\n/* 178: */ throws ParseException\r\n/* 179: */ {\r\n/* 180:258 */ double hour = 0.0D;\r\n/* 181:259 */ DateFormat fulDate = new SimpleDateFormat(\"HH:mm\");\r\n/* 182:260 */ long t12 = fulDate.parse(\"12:00\").getTime();\r\n/* 183:261 */ long t13 = fulDate.parse(\"13:00\").getTime();\r\n/* 184:262 */ long t1 = fulDate.parse(time1).getTime();\r\n/* 185:263 */ long PERHOUR = 3600000L;\r\n/* 186:264 */ if (time2 == null)\r\n/* 187: */ {\r\n/* 188:265 */ if (t12 - t1 > 0L) {\r\n/* 189:266 */ hour = (t12 - t1) / PERHOUR;\r\n/* 190: */ }\r\n/* 191: */ }\r\n/* 192: */ else\r\n/* 193: */ {\r\n/* 194:269 */ long t2 = fulDate.parse(time2).getTime();\r\n/* 195:270 */ if ((t1 <= t12) && (t2 >= t12) && (t2 <= t13)) {\r\n/* 196:271 */ hour = (t12 - t1) / PERHOUR;\r\n/* 197:272 */ } else if ((t1 <= t12) && (t2 >= t13)) {\r\n/* 198:273 */ hour = (t2 - t1) / PERHOUR - 1.0D;\r\n/* 199:274 */ } else if ((t1 >= t12) && (t1 <= t13) && (t2 >= t12) && (t2 <= t13)) {\r\n/* 200:275 */ hour = 0.0D;\r\n/* 201:276 */ } else if ((t1 >= t12) && (t1 <= t13) && (t2 >= t13)) {\r\n/* 202:277 */ hour = (t2 - t13) / PERHOUR;\r\n/* 203: */ } else {\r\n/* 204:279 */ hour = (t2 - t1) / PERHOUR;\r\n/* 205: */ }\r\n/* 206: */ }\r\n/* 207:282 */ DecimalFormat df = new DecimalFormat(\"#.0\");\r\n/* 208:283 */ return Double.parseDouble(df.format(hour));\r\n/* 209: */ }", "public String toString () {\n String dayTime;\n\n if (isPM == true)\n dayTime = \"PM\";\n\n else\n dayTime = \"AM\";\n\n String hourString = String.format(\"%02d\", hour);\n String minString = String.format(\"%02d\", minute);\n return (hourString + \":\" + minString + \" \" + dayTime);\n }", "static String getTime(int time) {\r\n\t\tint hours = time / 60;\r\n\t\tint minutes = time % 60;\r\n\r\n\t\tString ampm;\r\n\t\tif (time >= 720) ampm = \"PM\";\r\n\t\telse ampm = \"AM\";\r\n\r\n\t\treturn (String.format(\"%d:%02d%s\", hours, minutes, ampm));\r\n\t}", "static String timeConversion1(String s) {\n String[] timeSplit = s.split(\":\");\n String hours = timeSplit[0];\n String minutes = timeSplit[1];\n String seconds = timeSplit[2].substring(0, 2);\n String ampm = timeSplit[2].substring(2);\n\n int hour = Integer.parseInt(hours);\n\n int differential = 0;\n if (\"PM\".equals(ampm) && hour != 12) {\n differential = 12;\n }\n\n\n hour += differential;\n hour = hour % 24;\n\n hours = String.format(\"%02d\", hour);\n\n return hours + \":\" + minutes + \":\" + seconds;\n\n }", "public static void main(String argv[])\n {\n Calendar cal = Calendar.getInstance();\n\n //Sets TimeZone variable time to our default time zone (America/New_York)\n TimeZone time = TimeZone.getDefault();\n\n //Sets table format for output\n System.out.println(\"Time zone: City: Time:\");\n System.out.println();\n\n //Sets a time format for the output\n SimpleDateFormat sdf = new SimpleDateFormat(\"hh:mm:ss\");\n \n //Prints out the time and timezone in Washington DC\n \n //If cal.get(Calendar.AM_PM returns a value of 0 than AM is printed, \n //otherwise PM is printed\n if (cal.get(Calendar.AM_PM) == 0)\n System.out.println(time.getID() + \" \" + \"Washington DC \" + sdf.format(cal.getTime()) + \" AM\");\n else\n System.out.println(time.getID() + \" \" + \"Washington DC \" + sdf.format(cal.getTime()) + \" PM\");\n\n //Prints out the time in Los Angeles\n time = TimeZone.getTimeZone(\"America/Los_Angeles\");\n \n //Sets the SimpleDateFormat variable to the time zone given by the time variable\n //to display the time\n sdf.setTimeZone(time);\n \n //Sets the calendar to the time zone given by the time variable to display AM/PM\n cal.setTimeZone(time);\n\n if (cal.get(Calendar.AM_PM) == 0)\n System.out.println(time.getID() + \" \" + \"Los Angeles \" + sdf.format(cal.getTime()) + \" AM\");\n else\n System.out.println(time.getID() + \" \" + \"Los Angeles \" + sdf.format(cal.getTime()) + \" PM\");\n\n //Prints out the time in Amsterdam\n time = TimeZone.getTimeZone(\"Europe/Amsterdam\");\n sdf.setTimeZone(time);\n cal.setTimeZone(time);\n\n if (cal.get(Calendar.AM_PM) == 0)\n System.out.println(time.getID() + \" \" + \" Amsterdam \" + sdf.format(cal.getTime()) + \" AM\");\n else\n System.out.println(time.getID() + \" \" + \" Amsterdam \" + sdf.format(cal.getTime()) + \" PM\");\n\n //Prints out the time in Jerusalem\n time = TimeZone.getTimeZone(\"Asia/Jerusalem\");\n sdf.setTimeZone(time);\n cal.setTimeZone(time);\n\n if (cal.get(Calendar.AM_PM) == 0)\n System.out.println(time.getID() + \" \" + \" Jerusalem \" + sdf.format(cal.getTime()) + \" AM\");\n else\n System.out.println(time.getID() + \" \" + \" Jerusalem \" + sdf.format(cal.getTime()) + \" PM\");\n\n //Prints out the time in Hong Kong\n time = TimeZone.getTimeZone(\"Asia/Hong_Kong\");\n sdf.setTimeZone(time);\n cal.setTimeZone(time);\n\n if (cal.get(Calendar.AM_PM) == 0)\n System.out.println(time.getID() + \" \" + \" Hong Kong \" + sdf.format(cal.getTime()) + \" AM\");\n else\n System.out.println(time.getID() + \" \" + \" Hong Kong \" + sdf.format(cal.getTime()) + \" PM\");\n\n }", "public int totalTime()\n {\n return departureTime - arrivalTime;\n }", "java.lang.String getTransitAirport();", "static String timeConversion(String s) {\n String[] sTime = s.split(\":\");\n\n int x = 0;\n\n // if PM and hours >12, add additional 12 to hours\n // for AM and hour = 12, set hour to 00\n if(sTime[sTime.length - 1].contains(\"PM\") && !sTime[0].equals(\"12\"))\n x = 12;\n\n String val1 = \"\";\n if(x == 12)\n val1 = (Integer.parseInt(sTime[0]) + x) + \"\";\n else {\n if(sTime[0].equals(\"12\") && sTime[sTime.length - 1].contains(\"AM\"))\n val1 = \"00\";\n else\n val1 = sTime[0];\n }\n\n // merge the string and return the result\n String result = val1 + \":\" + sTime[1] + \":\" + sTime[2].substring(0,2);\n return result;\n }", "@Override\n\tpublic String toString() {\n\t\tLocalTime lT = LocalTime.of(hour, minute);\n\t\tDateTimeFormatter.ofPattern(\"hh:mm\").format(lT);\n\t\treturn lT.toString() + \" \" + timeType;\n\t}", "public String toString()\r\n {\r\n DecimalFormat twoDigits = new DecimalFormat( \"00\" );\r\n\r\n return ( this.getHour() == 12 || this.getHour() == 0 ?\r\n 12 : this.getHour() % 12 ) + \":\" +\r\n twoDigits.format( this.getMinute() ) + \":\" +\r\n twoDigits.format( this.getSecond() ) +\r\n ( this.getHour() < 12 ? \" AM\" : \" PM\" );\r\n }", "public String getFormattedArrivalTime() {\n return arrivalTime == null ? null : arrivalTime.getFormattedDateTime();\n }", "public String toString() {\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t // 4\n\t\tString hours = String.format(\"%02d\", this.hours);\n\t\tString minutes = String.format(\"%02d\", this.minutes);\n\t\tString seconds = String.format(\"%05.2f\", this.seconds);\n\n\t\tString time = hours + \":\" + minutes + \":\" + seconds;\n\t\treturn time;\n\t}", "public String ArrDepTime() {\n\t\treturn null;\n}", "public String toString() {\n return String.format(\"%d: %02d: %02d %s\",\n ((hour == 0 || hour == 12) ? 12 :hour % 12 ),\n minutes, seconds, (hour < 12 ? \"AM\" : \"PM\"));\n\n }", "public String gameTimeToText()\n {\n // CALCULATE GAME TIME USING HOURS : MINUTES : SECONDS\n if ((startTime == null) || (endTime == null))\n return \"\";\n long timeInMillis = endTime.getTimeInMillis() - startTime.getTimeInMillis();\n return timeToText(timeInMillis);\n }", "public com.google.protobuf.ByteString\n getDepartureTimeBytes() {\n java.lang.Object ref = departureTime_;\n if (ref instanceof String) {\n com.google.protobuf.ByteString b = \n com.google.protobuf.ByteString.copyFromUtf8(\n (java.lang.String) ref);\n departureTime_ = b;\n return b;\n } else {\n return (com.google.protobuf.ByteString) ref;\n }\n }", "public com.google.protobuf.ByteString\n getDepartureTimeBytes() {\n java.lang.Object ref = departureTime_;\n if (ref instanceof String) {\n com.google.protobuf.ByteString b = \n com.google.protobuf.ByteString.copyFromUtf8(\n (java.lang.String) ref);\n departureTime_ = b;\n return b;\n } else {\n return (com.google.protobuf.ByteString) ref;\n }\n }", "static String timeConversion(String s) {\n if(s.indexOf('P') >= 0 && s.substring(0, 2).equals(\"12\")){\n }\n else if(s.indexOf('P') >= 0){\n Integer n = Integer.parseInt(s.substring(0, 2));\n s = removeHour(s);\n n += 12;\n String hour = Integer.toString(n);\n s = hour + s;\n }\n else if (s.indexOf('A') >= 0 && s.substring(0, 2).equals(\"12\")){\n s = \"00\" + s.substring(2);\n }\n return removeHourFormat(s);\n }", "public String getTimeString(){\n StringBuilder sBuilder = new StringBuilder();\n sBuilder.append(hourPicker.getValue())\n .append(':')\n .append(minutePicker.getValue())\n .append(':')\n .append(secondsPicker.getValue())\n .append('.')\n .append(decimalPicker.getValue());\n return sBuilder.toString();\n }", "public void caltotaltraveltime()\n {\n \t\n \t switch(this.mLegs.size())\n \t {\n \t case 0:\n \t {\n \t\t this.mTravelTime=0;\n \t\t break;\n \t }\n \t case 1:\n \t { \n \t\t this.mTravelTime=this.mLegs.get(0).flighttime();\n \t\t break;\n \t }\n \t case 2:\n \t {\n \t\t Date arrivalt = this.mLegs.get(1).arrivaldate();\n \t\t Date departt = this.mLegs.get(0).departuredate();\n \t\t long diff = (arrivalt.getTime() - departt.getTime())/60000;\n \t\t this.mTravelTime=diff;\n \t\t break;\n \t }\n \t case 3:\n \t {\n \t Date arrivalt = this.mLegs.get(2).arrivaldate();\n \t Date departt = this.mLegs.get(0).departuredate();\n \t long diff = (arrivalt.getTime() - departt.getTime())/60000;\n \t this.mTravelTime=diff;\n \t break;\n \t }\n \t }\n }", "public String getDisplayValue()\n {\n\t\t\t\tString time_str;\n\t\t\t\tif (hours.getValue()<12&&minutes.getValue()<10) {\n time_str = \"0\" + hours.getValue()+ \": 0\" + minutes.getValue();\n }\n\t\t\t\tif (hours.getValue()<12) {\n time_str = \"0\" + hours.getValue()+ \": \" + minutes.getValue();\n } else if (minutes.getValue()<10) {\n time_str = hours.getValue()+\": 0\"+ minutes.getValue();\n } else {\n time_str = hours.getValue()+\":\"+ minutes.getValue();\n }\n\t\t\t\treturn time_str;\n }", "private void PrintTimeToET() {\n\t\tfinal Calendar c = Calendar.getInstance();\n\t\tjetztStdTxt.setText(Integer.toString(c.get(Calendar.HOUR_OF_DAY)));\n\t\tjetztMinTxt.setText(Integer.toString(c.get(Calendar.MINUTE)));\n\n\t}", "public java.lang.String getArrivalTime() {\n java.lang.Object ref = arrivalTime_;\n if (!(ref instanceof java.lang.String)) {\n com.google.protobuf.ByteString bs =\n (com.google.protobuf.ByteString) ref;\n java.lang.String s = bs.toStringUtf8();\n arrivalTime_ = s;\n return s;\n } else {\n return (java.lang.String) ref;\n }\n }", "public java.lang.String getArrivalTime() {\n java.lang.Object ref = arrivalTime_;\n if (!(ref instanceof java.lang.String)) {\n com.google.protobuf.ByteString bs =\n (com.google.protobuf.ByteString) ref;\n java.lang.String s = bs.toStringUtf8();\n arrivalTime_ = s;\n return s;\n } else {\n return (java.lang.String) ref;\n }\n }", "static String timeConversion(String s) {\n String[] timeSplit = s.split(\":\");\n String hours = timeSplit[0];\n String minutes = timeSplit[1];\n String seconds = timeSplit[2].substring(0, 2);\n String ampm = timeSplit[2].substring(2, 4);\n\n String newHours;\n if (ampm.equals(\"AM\")) {\n newHours = hours.equals(\"12\") ? \"00\" : hours;\n\n } else {\n newHours = hours.equals(\"12\") ? hours : String.valueOf(Integer.parseInt(hours) + 12);\n }\n\n return newHours + \":\" + minutes + \":\" + seconds;\n\n }", "public String getTime() {\n boolean pastNoon = hour >= 12;\n if(pastNoon && hour == 12) {\n return hour + \"pm\";\n }\n else if(pastNoon) {\n return (hour - 12) + \"pm\";\n }\n else if(hour == 0) {\n return \"12am\";\n }\n else {\n return hour + \"am\";\n }\n }", "public String getDepartureAirport();", "public double getDepartureTime(int index){\n\t\treturn departureTimes.get(index);\n\t}", "public static String[] retornaDias(String time){\n String[] split = time.split(\"T\");\n dataAux = split[0];\n split = split[1].split(\"Z\");\n data = dataAux.split(\"-\");\n return data;\n }", "static String timeCount_1(List<String> Arr){\n int timeHH = 0;\n int timeMI = 0;\n int timeSS = 0;\n \n String r_hh = \"\";\n String r_mi = \"\";\n String r_ss = \"\";\n\n for(int i = 0; i < Arr.size(); i++ ){\n \n if (Pattern.matches(\"\\\\d{2}:\\\\d{2}:\\\\d{2}\", Arr.get(i))){\n \n String[] s = Arr.get(i).split(\":\");\n int hh = Integer.parseInt(s[0]);\n int mi = Integer.parseInt(s[1]);\n int ss = Integer.parseInt(s[2]);\n \n timeHH += hh;\n timeMI += mi;\n timeSS += ss;\n \n }\n else{\n continue;\n }\n }\n \n timeMI += timeSS / 60;\n timeSS %= 60;\n \n timeHH += timeMI / 60;\n timeMI %= 60; \n\n \n if (timeHH < 10){\n r_hh = \"0\" + timeHH;\n }\n else{\n r_hh = Integer.toString(timeHH);\n }\n \n if (timeMI < 10){\n r_mi = \"0\" + timeMI;\n }\n else{\n r_mi = Integer.toString(timeMI);\n }\n \n if (timeSS < 10){\n r_ss = \"0\" + timeSS;\n }\n else{\n r_ss = Integer.toString(timeSS);\n }\n \n \n \n String result = r_hh + \":\" + r_mi + \":\" + r_ss;\n //String result = timeHH + \":\" + timeMI + \":\" + timeSS;\n \n return result;\n }", "static String timeConversion(String s) {\n\n\t\tStringBuilder sb = new StringBuilder();\n\t\tboolean isAm = s.contains(\"AM\");\n\t\t\n\t\ts = s.replace(\"AM\", \"\");\n\t\ts = s.replace(\"PM\", \"\");\n\t\t\n\t\tString str[] = s.split(\":\");\n\t\tint time = Integer.parseInt(str[0]);\n\t\t\n\t\t\n\t\tif(time < 12 && !isAm) {\n\t\t\ttime = time + 12;\n\t\t\tsb.append(time).append(\":\");\n\t\t}else if(time == 12 && isAm) {\n\t\t\tsb.append(\"00:\");\n\t\t}else {\n\t\t\tif (time < 10) sb.append(\"0\").append(time).append(\":\");\n\t\t\telse sb.append(time).append(\":\");\n\t\t}\n\n\t\tsb.append(str[1]).append(\":\").append(str[2]);\n\t\treturn sb.toString();\n\t}", "java.lang.String getField1724();", "static String timeConversion(String s) {\n /*\n * Write your code here.\n */\n String res = \"\";\n String hrs = s.substring(0, 2);\n String min = s.substring(3, 5);\n String sec = s.substring(6, 8);\n String ampm = s.substring(8);\n int hr = Integer.parseInt(hrs);\n if((ampm.equalsIgnoreCase(\"PM\")) && (hr != 12)) {\n hr += 12;\n if(hr >= 24) {\n hr = 24 - hr;\n }\n }\n else if(ampm.equalsIgnoreCase(\"AM\")) {\n if(hr == 12) {\n hr = 0;\n }\n }\n if(hr < 10) {\n res = res + \"0\" + Integer.toString(hr);\n }\n else {\n res += Integer.toString(hr);\n }\n res = res +\":\" +min +\":\" + sec;\n return res;\n }", "public String toString() {\n\t\treturn hours + \"h\" + minutes + \"m\";\n\t}", "@Override\n public String toString() {\n return this.START_TIME.toString() + \" \" + this.TYPE + this.NUMBER + \": \" + viewListOfStops() +\n \" COST: \"\n + this.deducted + \" \" ;\n }", "public com.google.protobuf.ByteString\n getDepartureTimeBytes() {\n java.lang.Object ref = departureTime_;\n if (ref instanceof java.lang.String) {\n com.google.protobuf.ByteString b = \n com.google.protobuf.ByteString.copyFromUtf8(\n (java.lang.String) ref);\n departureTime_ = b;\n return b;\n } else {\n return (com.google.protobuf.ByteString) ref;\n }\n }", "public com.google.protobuf.ByteString\n getDepartureTimeBytes() {\n java.lang.Object ref = departureTime_;\n if (ref instanceof java.lang.String) {\n com.google.protobuf.ByteString b = \n com.google.protobuf.ByteString.copyFromUtf8(\n (java.lang.String) ref);\n departureTime_ = b;\n return b;\n } else {\n return (com.google.protobuf.ByteString) ref;\n }\n }", "public Duration getTravelTime() {\n return Duration.between(flights.get(0).getDepartureTime(), flights.get(flights.size()-1).getArrivalTime());\n }", "@Override\n public String toString() {\n StringBuilder elapsedTime = new StringBuilder();\n\n if(days > 0) {\n elapsedTime.append(getDays()).append(\" day\");\n if(days > 1) {\n elapsedTime.append(\"s\");\n }\n \n int remainingElements = 0;\n if(hours> 0) remainingElements++;\n if(minutes> 0) remainingElements++;\n if(seconds> 0) remainingElements++;\n \n if(remainingElements > 0) {\n if(remainingElements == 1) {\n elapsedTime.append(\" and \");\n }\n else elapsedTime.append(\", \");\n }\n }\n \n if (hours > 0) {\n elapsedTime.append(getHours()).append(\" hour\");\n if (hours > 1) {\n elapsedTime.append(\"s\");\n }\n\n int remainingElements = 0;\n if (minutes > 0) remainingElements++;\n if (seconds > 0) remainingElements++;\n\n if (remainingElements > 0) {\n if (remainingElements == 1) {\n elapsedTime.append(\" and \");\n } else {\n elapsedTime.append(\", \");\n }\n }\n \n }\n \n if (minutes > 0) {\n elapsedTime.append(getMinutes()).append(\" minute\");\n if (minutes > 1) {\n elapsedTime.append(\"s\");\n }\n if (seconds > 0) {\n elapsedTime.append(\" and \");\n }\n }\n \n if (seconds > 0) {\n elapsedTime.append(getSeconds()).append(\" second\");\n if (seconds > 1) {\n elapsedTime.append(\"s\");\n }\n }\n \n return elapsedTime.toString();\n }", "public int getArrivalTime()\n {\n return arrivalTime;\n }", "public String toUniversalString()\r\n {\r\n DecimalFormat twoDigits = new DecimalFormat( \"00\" );\r\n\r\n return twoDigits.format( this.getHour() ) + \":\" +\r\n twoDigits.format( this.getMinute() ) + \":\" +\r\n twoDigits.format( this.getSecond() );\r\n }", "public int getDepartureTime() {\r\n\t\treturn departureTime;\r\n\t}", "public String getTimeInString() {\n int minutes = (time % 3600) / 60;\n int seconds = time % 60;\n String timeString = String.format(\"%02d:%02d\", minutes, seconds);\n\n return timeString;\n }", "public static String calculateArrivalTime(String arrivalTime){ \n\t\tlog.info(\"currentTime: {}, arrivalTime: {}\", CURRENT_TIME, arrivalTime);\n\t\t\n\t\t//create two arrays of Strings that contain the hour, minutes, and seconds in each index\n\t\tString[]currentTimeSplit = CURRENT_TIME.split(\":\");\n\t\tString[]arrivalTimeSplit = arrivalTime.split(\":\");\n\t\n\t\tint[]estimation = new int[currentTimeSplit.length];\n\t\t//TODO: add some exception handling somewhere\n\t\tfor (int i = currentTimeSplit.length - 1; i >= 0; i--){ \n\t\t\t//convert the Strings into integers and find the difference between them\n\t\t\tint cur = Integer.parseInt(currentTimeSplit[i]);\n\t\t\tint arr = Integer.parseInt(arrivalTimeSplit[i]);\n\t\t\t\n\t\t\tif (i == 0 && cur > arr){\n\t\t\t\tarr += 24;\n\t\t\t}\n\t\t\tint dif = arr - cur;\n\t\t\t//if this results in a negative number, we need to \"borrow\" from the next index\n\t\t\tif (dif < 0){\n\t\t\t\tint next = Integer.parseInt(arrivalTimeSplit[i - 1]) - 1;\n\t\t\t\tarrivalTimeSplit[i - 1] = next+\"\";\n\t\t\t\tdif = 60 + dif;\n\t\t\t}\n\t\t\testimation[i] = dif;\n\t\t}\n\t\t\n\t\tString theTime = \"\";\n\t\tif (estimation[0] > 0){ //if arrival time is over an hour\n\t\t\ttheTime = \"\";\n\t\t} else { //otherwise, format a String from the minutes and seconds\n\t\t\tint minutes = estimation[1];\n\t\t\tif (minutes > 30){\n\t\t\t\ttheTime = \"\"; //ignore anything above 30 minutes\n\t\t\t} else if (minutes < 1){\n\t\t\t\ttheTime = \"now\";\n\t\t\t} else if (minutes < 2){\n\t\t\t\ttheTime = \"under 2 minutes\";\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttheTime += minutes + \" minutes\";\n\t\t\t}\n\t\t}\n\t\treturn theTime;\n\t}", "public static String time_str(double t) {\n int hours = (int) t/3600;\n int rem = (int) t - hours*3600;\n int mins = rem / 60;\n int secs = rem - mins*60;\n return String.format(\"%02d:%02d:%02d\", hours, mins, secs);\n //return hoursMinutesSeconds(t);\n }", "private String parseTime(TimePicker start){\n String time = \"\";\n if (start.getHour() < 10){\n time += \"0\" + start.getHour() + \":\";\n } else {\n time += start.getHour() + \":\";\n }\n if (start.getMinute() < 10){\n time += \"0\" + start.getMinute();\n } else {\n time += start.getMinute();\n }\n return time;\n }", "public java.lang.String getArrivalTime() {\n java.lang.Object ref = arrivalTime_;\n if (ref instanceof java.lang.String) {\n return (java.lang.String) ref;\n } else {\n com.google.protobuf.ByteString bs = \n (com.google.protobuf.ByteString) ref;\n java.lang.String s = bs.toStringUtf8();\n arrivalTime_ = s;\n return s;\n }\n }", "public java.lang.String getArrivalTime() {\n java.lang.Object ref = arrivalTime_;\n if (ref instanceof java.lang.String) {\n return (java.lang.String) ref;\n } else {\n com.google.protobuf.ByteString bs = \n (com.google.protobuf.ByteString) ref;\n java.lang.String s = bs.toStringUtf8();\n arrivalTime_ = s;\n return s;\n }\n }", "public int getTT()\n {\n return toTime;\n }", "private String multipleStartTimes() {\n\t\tStringBuilder sb = new StringBuilder();\n\t\tif (startTimes.size() > 1) {\n\t\t\tsb.append(\"Flera starttider? \");\n\t\t\tfor (int i = 1; i < startTimes.size(); i++) {\n\t\t\t\tsb.append(startTimes.get(i) + \" \");\n\t\t\t}\n\t\t\tsb.append(\"; \");\n\t\t}\n\t\treturn sb.toString();\n\t}", "public java.lang.String getActDeptTime () {\n\t\treturn actDeptTime;\n\t}", "public int getArrivalTime(){return arrivalTime;}", "public String morningMeeting(){\n return \"accountants have meetings beginning at 9:15 AM and run until 8:45 AM\";\n }", "public String getSystemTime() {\n\t\tSimpleDateFormat dateTimeInGMT = new SimpleDateFormat(\"dd-MMM-yyyy hh\");\n\t\t// Setting the time zoneS\n\t\tdateTimeInGMT.setTimeZone(TimeZone.getTimeZone(\"America/New_York\"));\n\t\tString timeZone = dateTimeInGMT.format(new Date());\n\t\treturn timeZone;\n\n\t}", "public String dimeTuTiempo()\n {\n String cadResultado=\"\";\n if (horas<10)\n {\n cadResultado=cadResultado+\"0\";\n }\n cadResultado=cadResultado+horas;\n cadResultado=cadResultado+\":\";\n if(minutos<10)\n {\n cadResultado=cadResultado+\"0\";\n }\n cadResultado=cadResultado+minutos;\n \n return cadResultado;\n }", "public String getWorkinghours() {\n int seconds = workinghours % 60;\n int minutes = (workinghours / 60) % 60;\n int hours = (workinghours / 60) / 60;\n String secs;\n String mins;\n String hourse;\n\n if (seconds < 10) {\n secs = \":0\" + seconds;\n } else {\n secs = \":\" + seconds;\n }\n if (minutes < 10) {\n mins = \":0\" + minutes;\n } else {\n mins = \":\" + minutes;\n }\n if (hours < 10) {\n hourse = \"0\" + hours;\n } else {\n hourse = \"\" + hours;\n }\n return hourse + mins + secs;\n }", "public String formatTime() {\n if ((myGameTicks / 16) + 1 != myOldGameTicks) {\n myTimeString = \"\";\n myOldGameTicks = (myGameTicks / 16) + 1;\n int smallPart = myOldGameTicks % 60;\n int bigPart = myOldGameTicks / 60;\n myTimeString += bigPart + \":\";\n if (smallPart / 10 < 1) {\n myTimeString += \"0\";\n }\n myTimeString += smallPart;\n }\n return (myTimeString);\n }", "public void setTime() {\r\n\t\tArrayList<String> slots = new ArrayList<String>();\r\n\t\tString inSched = getWorkHours();\r\n\t\tswitch(inSched) {\r\n\t\tcase \"6AM-3PM\":\r\n\t\t\tArrayList<String> sched1 = new ArrayList<String>(Arrays.asList(\"06AM\",\"07AM\",\"08AM\",\"09AM\",\"10AM\",\"12PM\",\"1PM\",\"2PM\"));\r\n\t\t\tslots = sched1;\r\n\t\t\tbreak;\r\n\t\tcase \"7AM-4PM\":\r\n\t\t\tArrayList<String> sched2 = new ArrayList<String>(Arrays.asList(\"07AM\",\"08AM\",\"09AM\",\"10AM\",\"11AM\",\"1PM\",\"2PM\",\"3PM\"));\r\n\t\t\tslots = sched2;\r\n\t\t\tbreak;\r\n\t\tcase \"8AM-5PM\":\r\n\t\t\tArrayList<String> sched3 = new ArrayList<String>(Arrays.asList(\"08AM\",\"09AM\",\"10AM\",\"11AM\",\"12PM\",\"2PM\",\"3PM\",\"4PM\"));\r\n\t\t\tslots = sched3;\r\n\t\t\tbreak;\r\n\t\tcase \"9AM-6PM\":\r\n\t\t\tArrayList<String> sched4 = new ArrayList<String>(Arrays.asList(\"09AM\",\"10AM\",\"11AM\",\"12PM\",\"1PM\",\"3PM\",\"4PM\",\"5PM\"));\r\n\t\t\tslots = sched4;\r\n\t\t\tbreak;\r\n\t\tcase \"10AM-7PM\":\r\n\t\t\tArrayList<String> sched5 = new ArrayList<String>(Arrays.asList(\"10AM\",\"11AM\",\"12PM\",\"1PM\",\"2PM\",\"4PM\",\"5PM\",\"6PM\"));\r\n\t\t\tslots = sched5;\r\n\t\t\tbreak;\r\n\t\tdefault:\r\n\t\t\tslots.add(\"No appointments available for this date.\");\r\n\t\t}\r\n\t\tthis.timeAvailable = slots;\r\n\t}", "public String duration(){\n long duration =beginTime.getTime()-endTime.getTime();\n long diffMinutes = duration / (60 * 1000) % 60;\n long diffHours = duration / (60 * 60 * 1000);\n if(diffHours ==0)\n return -1*diffMinutes + \" minutes\";\n else\n return \" \"+-1*diffHours+\":\"+ -1*diffMinutes +\"min\";\n }" ]
[ "0.7465667", "0.7465667", "0.712636", "0.712636", "0.6392617", "0.6359916", "0.63176346", "0.6313561", "0.6296906", "0.6285322", "0.62851804", "0.6279936", "0.62747633", "0.6251938", "0.6218166", "0.61465514", "0.6133306", "0.6101772", "0.6085483", "0.6085483", "0.60495424", "0.60303116", "0.60164917", "0.60164917", "0.59889203", "0.5981299", "0.5963651", "0.592763", "0.5926781", "0.5926781", "0.59064746", "0.5906238", "0.5896331", "0.5888406", "0.5885278", "0.58815485", "0.5877354", "0.5872722", "0.5854653", "0.5847565", "0.58265465", "0.5823424", "0.5823177", "0.5821483", "0.5803473", "0.57908", "0.57875824", "0.5785367", "0.57807845", "0.5777165", "0.5775462", "0.57681936", "0.5754942", "0.57481337", "0.5744408", "0.5743382", "0.5715936", "0.5715936", "0.5705309", "0.5699208", "0.568819", "0.5677083", "0.5662286", "0.5660513", "0.5660513", "0.56577986", "0.56506276", "0.5638102", "0.5626647", "0.56230295", "0.56126475", "0.56109697", "0.5609004", "0.5603545", "0.5602492", "0.5592153", "0.5589006", "0.5589006", "0.5575805", "0.55755824", "0.5571469", "0.55680096", "0.55644554", "0.5550229", "0.5545501", "0.55438185", "0.55405754", "0.55297434", "0.55297434", "0.55283386", "0.55220616", "0.55108064", "0.5506544", "0.5501711", "0.54990613", "0.54950666", "0.54883647", "0.5487227", "0.54811513", "0.548056" ]
0.67871964
4
TODO Autogenerated method stub
public String ArrDepTime() { return null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "@Override\r\n\tpublic void comer() \r\n\t{\n\t\t\r\n\t}", "@Override\n\tpublic void comer() {\n\t\t\n\t}", "@Override\n public void perish() {\n \n }", "@Override\r\n\t\t\tpublic void annadir() {\n\r\n\t\t\t}", "@Override\n\tpublic void anular() {\n\n\t}", "@Override\n\tprotected void getExras() {\n\n\t}", "@Override\r\n\tpublic void anularFact() {\n\t\t\r\n\t}", "@Override\n\tpublic void entrenar() {\n\t\t\n\t}", "@Override\n\tpublic void nadar() {\n\t\t\n\t}", "@Override\r\n\tpublic void tires() {\n\t\t\r\n\t}", "@Override\r\n\t\t\tpublic void ayuda() {\n\r\n\t\t\t}", "@Override\n\tprotected void interr() {\n\t}", "@Override\n\tpublic void emprestimo() {\n\n\t}", "@Override\r\n\tpublic void bicar() {\n\t\t\r\n\t}", "@Override\r\n\tpublic void bicar() {\n\t\t\r\n\t}", "@Override\n\tpublic void grabar() {\n\t\t\n\t}", "@Override\n\tpublic void gravarBd() {\n\t\t\n\t}", "@Override\r\n\tpublic void rozmnozovat() {\n\t}", "@Override\r\n\tpublic void dormir() {\n\t\t\r\n\t}", "@Override\n protected void getExras() {\n }", "@Override\r\n\tpublic void publierEnchere() {\n\t\t\r\n\t}", "@Override\n\tpublic void nefesAl() {\n\n\t}", "@Override\n\tpublic void ligar() {\n\t\t\n\t}", "@Override\n public void func_104112_b() {\n \n }", "@Override\n\tprotected void initdata() {\n\n\t}", "@Override\n\tpublic void nghe() {\n\n\t}", "@Override\n public void function()\n {\n }", "@Override\n public void function()\n {\n }", "public final void mo51373a() {\n }", "@Override\r\n\tpublic void stehReagieren() {\r\n\t\t//\r\n\t}", "@Override\n public void inizializza() {\n\n super.inizializza();\n }", "@Override\n\tprotected void initData() {\n\t\t\n\t}", "@Override\r\n\t\tpublic void init() {\n\t\t\t\r\n\t\t}", "@Override\n\tpublic void sacrifier() {\n\t\t\n\t}", "@Override\r\n\tprotected void InitData() {\n\t\t\r\n\t}", "public void designBasement() {\n\t\t\r\n\t}", "@Override\r\n\tprotected void initialize() {\r\n\t\t\r\n\t\t\r\n\t}", "public void gored() {\n\t\t\n\t}", "@Override\r\n\tprotected void initData() {\n\r\n\t}", "@Override\n\tpublic void einkaufen() {\n\t}", "@Override\n protected void initialize() {\n\n \n }", "public void mo38117a() {\n }", "@Override\n\tprotected void getData() {\n\t\t\n\t}", "Constructor() {\r\n\t\t \r\n\t }", "@Override\r\n\tpublic void dibujar() {\n\t\t\r\n\t}", "@Override\r\n\tpublic void dibujar() {\n\t\t\r\n\t}", "@Override\n\tpublic void one() {\n\t\t\n\t}", "@Override\r\n\tprotected void initData() {\n\t\t\r\n\t}", "@Override\r\n\tprotected void initData() {\n\t\t\r\n\t}", "@Override\r\n\tprotected void initData() {\n\t\t\r\n\t}", "@Override\r\n\tprotected void initData() {\n\t\t\r\n\t}", "@Override\r\n\tprotected void initData() {\n\t\t\r\n\t}", "@Override\r\n\tprotected void initData() {\n\t\t\r\n\t}", "private stendhal() {\n\t}", "@Override\n\tprotected void update() {\n\t\t\n\t}", "@Override\n\t\t\tpublic void ic() {\n\t\t\t\t\n\t\t\t}", "@Override\n\tprotected void initData() {\n\n\t}", "@Override\n\tprotected void initData() {\n\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n\tpublic void init() {\n\t\t\n\t}", "@Override\n public void init() {\n\n }", "@Override\n\tprotected void initialize() {\n\t\t\n\t}", "@Override\n\tprotected void initialize() {\n\t\t\n\t}", "@Override\r\n\tpublic void init() {\n\t\t\r\n\t}", "@Override\r\n\tpublic void init() {\n\t\t\r\n\t}", "@Override\r\n\tpublic void init() {\n\t\t\r\n\t}", "@Override\n\tpublic void debite() {\n\t\t\n\t}", "@Override\r\n\tpublic void init() {\n\r\n\t}", "@Override\r\n\tpublic void init() {\n\r\n\t}", "@Override\r\n\tpublic void init() {\n\r\n\t}", "public contrustor(){\r\n\t}", "@Override\n\tprotected void initialize() {\n\n\t}", "@Override\r\n\tpublic void dispase() {\n\r\n\t}", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "public void mo55254a() {\n }", "@Override\n\tpublic void dtd() {\n\t\t\n\t}", "@Override\n\tprotected void logic() {\n\n\t}", "@Override\n\tprotected void lazyLoad() {\n\t\t\n\t}", "public void mo4359a() {\n }", "@Override\r\n\tprotected void initialize() {\n\r\n\t}", "@Override\n public void memoria() {\n \n }", "@Override\n\t\tpublic void method() {\n\t\t\t\n\t\t}", "private RepositorioAtendimentoPublicoHBM() {\r\t}", "@Override\n protected void initialize() \n {\n \n }", "@Override\r\n\tpublic void getProposition() {\n\r\n\t}", "@Override\n\tpublic void particular1() {\n\t\t\n\t}", "@Override\n\tpublic void init() {\n\n\t}", "@Override\n\tpublic void init() {\n\n\t}", "@Override\n\tpublic void init() {\n\n\t}", "@Override\n protected void prot() {\n }", "@Override\r\n\tpublic void init()\r\n\t{\n\t}", "@Override\n\tprotected void initValue()\n\t{\n\n\t}", "public void mo55254a() {\n }" ]
[ "0.6671074", "0.6567672", "0.6523024", "0.6481211", "0.6477082", "0.64591026", "0.64127725", "0.63762105", "0.6276059", "0.6254286", "0.623686", "0.6223679", "0.6201336", "0.61950207", "0.61950207", "0.61922914", "0.6186996", "0.6173591", "0.61327106", "0.61285484", "0.6080161", "0.6077022", "0.6041561", "0.6024072", "0.6020252", "0.59984857", "0.59672105", "0.59672105", "0.5965777", "0.59485507", "0.5940904", "0.59239364", "0.5910017", "0.5902906", "0.58946234", "0.5886006", "0.58839184", "0.58691067", "0.5857751", "0.58503544", "0.5847024", "0.58239377", "0.5810564", "0.5810089", "0.5806823", "0.5806823", "0.5800025", "0.5792378", "0.5792378", "0.5792378", "0.5792378", "0.5792378", "0.5792378", "0.5790187", "0.5789414", "0.5787092", "0.57844025", "0.57844025", "0.5774479", "0.5774479", "0.5774479", "0.5774479", "0.5774479", "0.5761362", "0.57596046", "0.57596046", "0.575025", "0.575025", "0.575025", "0.5747959", "0.57337177", "0.57337177", "0.57337177", "0.5721452", "0.5715831", "0.57142824", "0.57140535", "0.57140535", "0.57140535", "0.57140535", "0.57140535", "0.57140535", "0.57140535", "0.5711723", "0.57041645", "0.56991017", "0.5696783", "0.56881124", "0.56774884", "0.56734604", "0.56728", "0.56696945", "0.5661323", "0.5657007", "0.5655942", "0.5655942", "0.5655942", "0.56549734", "0.5654792", "0.5652974", "0.5650185" ]
0.0
-1
The constructor for cloning a Building
public Building(Building building){ type = building.type; cost = building.cost; image = building.image; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public Clone() {}", "public Building() {\n\t}", "public Cbuilding() { }", "Component deepClone();", "public MossClone() {\n super();\n }", "@Override \n public Door clone()\n {\n try\n {\n Door copy = (Door)super.clone();\n \n //a copy of the location class\n copy.room = room.clone(); \n \n return copy;\n }\n catch(CloneNotSupportedException e)\n {\n throw new InternalError();\n }\n }", "public abstract State clone();", "public static void copyConstructor(){\n\t}", "private Construct(Builder builder) {\n super(builder);\n }", "private CloneFactory() {\n }", "public abstract Pessoa clone();", "@Override\n public Board clone() {\n return new Board(copyOf(this.board));\n }", "@Override\n public AbstractRelic makeCopy() {\n return new Compendium();\n }", "public CopyBuilder copy() {\n return new CopyBuilder(this);\n }", "@Override\r\n\tpublic AI_Domain clone() {\r\n\t\treturn new Board2048model(this);\r\n\t}", "public Object clone(){ \r\n\t\tBaseballCard cloned = new BaseballCard();\r\n\t\tcloned.name = this.getName();\r\n\t\tcloned.manufacturer=this.getManufacturer();\r\n\t\tcloned.year = this.getYear();\r\n\t\tcloned.price = this.getPrice();\r\n\t\tcloned.size[0]= this.getSizeX();\r\n\t\tcloned.size[1]= this.getSizeY();\r\n\t\treturn cloned;\r\n\t}", "public Function clone();", "public /*@ non_null @*/ Object clone() {\n return this;\n }", "Object clone();", "Object clone();", "public abstract Object clone() ;", "protected final Object clone() {\n\t\tBitBoardImpl clone = new BitBoardImpl();\n\t\tfor( int i = 0; i < 5; i++) {\n\t\t clone._boardLayer[i] = _boardLayer[i];\n\t\t}\n\t\treturn clone;\n }", "public MovableObject lightClone()\n\t\t{\n\t\t\tfinal MovableObject clone = new MovableObject();\n\t\t\tclone.assCount = this.assCount;\n\t\t\tclone.associatable = this.associatable;\n\t\t\tclone.bound = this.bound;\n\t\t\tclone.coords = new int[this.coords.length];\n\t\t\tfor(int i=0; i < this.coords.length; i++)\n\t\t\t\tclone.coords[i] = this.coords[i];\n\t\t\tclone.highlighted = this.highlighted;\n\t\t\tclone.hotSpotLabel = this.hotSpotLabel;\n\t\t\tclone.keyCode = this.keyCode;\n\t\t\tclone.label = this.label;\n\t\t\tclone.maxAssociations = this.maxAssociations;\n\t\t\tif(shape.equals(\"rect\"))\n\t\t\t{\n\t\t\t\tclone.obj = new Rectangle(coords[0]-3,coords[1]-3,coords[2]+6,coords[3]+6);\n\t\t\t}\n\t\t\tif(shape.equals(\"circle\"))\n\t\t\t{\n\t\t\t\tclone.obj = new Ellipse2D.Double((coords[0]-coords[2])-4,(coords[1]-coords[2])-4,(coords[2]+2)*2,(coords[2]+2)*2);\n\t\t\t}\n\t\t\tif(shape.equals(\"ellipse\"))\n\t\t\t{\n\t\t\t\tclone.obj = new Ellipse2D.Double((coords[0]-coords[2])-4,(coords[1]-coords[2])-4,(coords[2]+2)*2,(coords[3]+2)*2);\n\t\t\t}\n\t\t\tif(shape.equals(\"poly\"))\n\t\t\t{\n\t\t\t\tfinal int xArr[] = new int[coords.length/2];\n\t\t\t\tfinal int yArr[] = new int[coords.length/2];\n\t\t\t\tint xCount = 0;\n\t\t\t\tint yCount = 0;\n\t\t\t\tfor(int i=0; i < coords.length; i++)\n\t\t\t\t{\n\t\t\t\t\tif((i%2) == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\txArr[xCount] = coords[i];\n\t\t\t\t\t\txCount++;\n\t\t\t\t\t}else\n\t\t\t\t\t{\n\t\t\t\t\t\tyArr[yCount] = coords[i];\n\t\t\t\t\t\tyCount++;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t//TODO calculate the centre of mass\n\n\t\t\t\tclone.obj = new Polygon(xArr,yArr,xArr.length);\n\t\t\t}\n\t\t\tclone.pos = new Point(this.pos.x,this.pos.y);\n\t\t\tclone.shape = this.shape;\n\t\t\tclone.startPos = this.startPos;\n\t\t\tclone.value = this.value;\n\n\t\t\treturn clone;\n\t\t}", "public Clone(String name) {\n this(name, null);\n }", "public GameBoard clone(){\r\n\t\tGameBoard result = new GameBoard();\r\n\t\ttry{\r\n\t\t\tresult = (GameBoard) super.clone();\r\n\t\t}catch(CloneNotSupportedException e){\r\n\t\t\tthrow new RuntimeException();\r\n\t\t}\r\n\t\tresult.board = (Box[]) board.clone();\r\n\t\treturn result;\r\n\t}", "public static GoldenCopy.Builder builder() {\n return new GoldenCopy.Builder();\n }", "public Object clone(){\n \t\n \treturn this;\n \t\n }", "public Binaire clone(){\n\t\treturn new Binaire(this.symbole, this.gauche.clone(), this.droit.clone());\n\t}", "Object build();", "public Building() throws ConstructionException {\n\t\tthrow new ConstructionException();\n\t}", "public Object clone() {\r\n\t\tNetwork net = new Network();\r\n\t\tfor (Variable v : variables) {\r\n\t\t\tVariable v1 = v.copy(net);\r\n\t\t\tif (v.getIndex() != v1.getIndex())\r\n\t\t\t\tthrow new IllegalArgumentException();\r\n\t\t}\r\n\t\tfor (Constraint c: constraints) { \r\n\t\t\tConstraint c1 = c.copy(net);\r\n\t\t\tif (c.getIndex() != c1.getIndex())\r\n\t\t\t\tthrow new IllegalArgumentException();\r\n\t\t}\r\n\t\tif (objective != null) {\r\n\t\t\tnet.setObjective(net.getVariable(objective.getIndex()));\r\n\t\t}\r\n\t\treturn net;\r\n\t}", "public Building() {\n mElevators = new ArrayList<>();\n mFloors = new ArrayList<>();\n }", "public DescriptiveFramework clone();", "public Object clone() {\n // No problems cloning here since private variables are immutable\n return super.clone();\n }", "public Sudoku clone() {\n\t\tSudoku s = new Sudoku(this.B);\n\t\ts.fileName = this.getFileName();\n\t\t// clone the puzzle\n\t\tfor (int i = 1; i <= N; i++) {\n\t\t\tfor (int j = 1; j <= N; j++) {\n\t\t\t\ts.puzzle[i][j] = puzzle[i][j];\n\t\t\t}\n\t\t}\n\t\t// clone the constraints table\n\t\tfor (int i = 0; i <= N + 1; i++) {\n\t\t\tfor (int j = 0; j <= N; j++) {\n\t\t\t\ts.constraints[i][j] = (BitSet) constraints[i][j].clone();\n\t\t\t}\n\t\t}\n\t\t// clone the nonAssignedCells\n\t\ts.nonAssignedCells.addAll(this.nonAssignedCells);\n\t\treturn s;\n\t}", "public abstract Object clone();", "public Paper clone() \r\n\t{\r\n\t\tPaper copy = null;\r\n\t\ttry\r\n\t\t{ \r\n\t\t\tcopy = new Paper(this.getId(), new String(this.getTitle()), new String(this.getURI()),\r\n\t\t\t\tthis.year, new String(this.biblio_info), \r\n\t\t\t\tnew String(this.authors), new String(this.url) ); \r\n\t\t}\r\n\t\tcatch (Exception e) { e.printStackTrace(System.out); }\r\n\t\treturn copy;\r\n\t}", "public Object clone();", "public Object clone();", "public Object clone();", "public Object clone();", "abstract Object build();", "public IVenda clone ();", "public Person build(){\n return new Person(this);\n }", "@Override\r\n @GwtIncompatible\r\n public Object clone() {\r\n try {\r\n @SuppressWarnings(\"unchecked\")\r\n PairBuilder<L, R> result = (PairBuilder<L, R>)super.clone();\r\n result.self = result;\r\n return result;\r\n } catch (CloneNotSupportedException e) {\r\n throw new InternalError(e.getMessage());\r\n }\r\n }", "public /*@ non_null @*/ Object clone() { \n //@ assume owner == null;\n return this;\n }", "@Override \n public Object clone() {\n try {\n Resource2Builder result = (Resource2Builder)super.clone();\n result.self = result;\n return result;\n } catch (CloneNotSupportedException e) {\n throw new InternalError(e.getMessage());\n }\n }", "IGLProperty clone();", "Prototype makeCopy();", "@Override\r\n\tpublic Dog Clone() throws CloneNotSupportedException {\r\n\t\treturn new Poodle(this.getName(), this.getWeight(), this.getColor(), this.getGender(), this.getInfo()); \r\n\t}", "public Building(String[] line){\n setId(Integer.parseInt(line[0]));\n setRank(Integer.parseInt(line[1]));\n setName(line[2]);\n setCity(line[3]);\n setCountry(line[4]);\n setHeight_m(Double.parseDouble(line[5]));\n setHeight_ft(Double.parseDouble(line[6]));\n setFloors(line[7]);\n setBuild(line[8]);\n setArchitect(line[9]);\n setArchitectual_style(line[10]);\n setCost(line[11]);\n setMaterial(line[12]);\n setLongitude(line[13]);\n setLatitude(line[14]);\n // setImage(line[15]);\n\n }", "@Override\n public BoardFramework copyBoard() {\n List<List<GamePiece>> pieceCopies= new ArrayList<>();\n for(List<GamePiece> row: myGamePieces){\n List<GamePiece> rowOfPieceCopies = new ArrayList<>();\n for(GamePiece piece: row){\n rowOfPieceCopies.add(piece.copy());\n }\n pieceCopies.add(rowOfPieceCopies);\n }\n return new Board(pieceCopies,new ArrayList<>(myNeighborhoods),myEmptyState);\n }", "public Builder() {}", "public Builder() {}", "public Builder() {}", "public CopyBook buildCopyBookFromGroup() {\n\t\tCopyBook builtCopyBook = new CopyBook();\n\t\t\n\t\tbuiltCopyBook.setName( name );\n\t\tbuiltCopyBook.addChildElements( childElements );\n\t\t\n\t\treturn builtCopyBook;\n\t}", "default PropertyBox cloneBox() {\n\t\treturn builder(this).invalidAllowed(this.isInvalidAllowed()).copyValues(this).build();\n\t}", "@Override\n public Object clone() {\n return super.clone();\n }", "public Building(int yearOfCreation, double cost, double landSpace, String material) {\n super(yearOfCreation, cost);\n this.landSpace = landSpace;\n this.material = material;\n }", "public d clone() {\n ArrayList arrayList = this.e;\n int size = this.e.size();\n c[] cVarArr = new c[size];\n for (int i = 0; i < size; i++) {\n cVarArr[i] = ((c) arrayList.get(i)).clone();\n }\n return new d(cVarArr);\n }", "@Override\n\tpublic Automaton clone() {\n\t\tAutomaton a;\n\t\t// Try to create a new object.\n\t\ttry {\n\t\t\ta = getClass().newInstance();\n\t\t} catch (final Throwable e) {\n\t\t\t// Well golly, we're sure screwed now!\n\t\t\tlogger.error(\"Warning: clone of automaton failed: {}\", e.getMessage());\n\t\t\treturn null;\n\t\t}\n\t\ta.setEnvironmentFrame(getEnvironmentFrame());\n\n\t\t// Copy over the states.\n\t\tfinal HashMap<State, State> map = new HashMap<>(); // Old states to new\n\t\t// states.\n\t\tstates.forEach(state -> {\n\t\t\tfinal State newState = new State(state.getID(), new Point(state.getPoint()), a);\n\t\t\tnewState.setLabel(state.getLabel());\n\t\t\tnewState.setName(state.getName());\n\t\t\tmap.put(state, newState);\n\t\t\ta.addState(newState);\n\t\t\tif (this instanceof MooreMachine) {\n\t\t\t\t((MooreMachine) a).setOutput(newState, ((MooreMachine) this).getOutput(state));\n\t\t\t}\n\t\t});\n\n\t\tfinalStates.forEach(state -> {\n\t\t\ta.addFinalState(map.get(state));\n\t\t});\n\n\t\ta.setInitialState(map.get(getInitialState()));\n\n\t\t// Copy over the transitions.\n\n\t\tstates.forEach(state -> {\n\t\t\tfinal State from = map.get(state);\n\t\t\tgetTransitionsFromState(state).forEach(transition -> {\n\t\t\t\tfinal State to = map.get(transition.getToState());\n\t\t\t\tSystem.err.println(\"Transition name: \" + transition.toString());\n\t\t\t\tfinal Transition toBeAdded = transition.clone();\n\t\t\t\ttoBeAdded.setFromState(from);\n\t\t\t\ttoBeAdded.setToState(to);\n\t\t\t\tSystem.err.println(\"toBeAdded is null: \" + (toBeAdded == null));\n\t\t\t\tSystem.err.println(\"toBeAdded.from is null: \" + (toBeAdded.getFromState() == null));\n\t\t\t\tSystem.err.println(\"toBeAdded.to is null: \" + (toBeAdded.getToState() == null));\n\t\t\t\ta.addTransition(toBeAdded);\n\t\t\t});\n\t\t});\n\n\t\tfinal List<Note> notes = getNotes();\n\t\tfinal List<Note> copyNotes = a.getNotes();\n\t\tcheckArgument(notes.size() == copyNotes.size());\n\n\t\tIntStream.range(0, notes.size()).forEach(i -> {\n\t\t\ta.addNote(new Note(notes.get(i).getAutoPoint(), notes.get(i).getText()));\n\t\t\tcopyNotes.get(i).setView(notes.get(i).getView());\n\t\t});\n\t\t// Should be done now!\n\t\treturn a;\n\t}", "@Override\n public SearchBasedAgentState clone() {\n \n\t\t//TODO: Complete Method\n\t\t\n return null;\n }", "public Object clone()\n/* */ {\n/* 835 */ return super.clone();\n/* */ }", "public Object clone()\n\t{\n\t\treturn new Tree();\n\t}", "public abstract Object build();", "@Override\n\tpublic ConditionConnective clone() {\n\t\tfinal ConditionConnective clone = new ConditionConnective(type);\n\t\tfor (final Condition c : conditions) {\n\t\t\tclone.conditions.add(c.clone());\n\t\t}\n\t\treturn clone;\n\t}", "public Object clone() {\n return new RelevantObjectsCommand(name, \n relevantStateVariables, \n relevantObjects,\n relevancyRelationship);\n }", "public Population(Graph graph)\r\n/* 13: */ {\r\n/* 14:36 */ g = graph.cloneGraph();\r\n/* 15: */ }", "private Builder() {}", "@Override\n public AggregationBuilder clone() {\n try {\n AggregationBuilder clone = (AggregationBuilder) super.clone();\n clone.root = root.clone();\n clone.current = clone.root;\n return clone;\n } catch(CloneNotSupportedException ex){\n return null;\n }\n }", "public LibraryElement cloneElement();", "@Override\n public JokerVehicle clone(){\n return new JokerVehicle();\n }", "@Override\n\tpublic Object clone() \n\t{\n\t\ttry{\n\t\t// Note all state is primitive so no need to deep copy reference types.\n\t\treturn (Tile) super.clone();\n\t\t} catch (CloneNotSupportedException e) \n\t\t{\n\t\t\t// We should not ever be here as we implement Cloneable.\n\t\t\t// It is better to deal with the exception here rather than letting\n\t\t\t// clone throw it as we would have to catch it in more places then.\n\t\t\treturn null;\n\t\t}\n\t}", "public Carta clone(){\n\t\treturn new Carta(palo, numero);\n\t}", "final public Attr clone() {\r\n\t\t\tif(Vector == null)\r\n\t\t\t\treturn new Attr(Name, Value, null);\r\n\t\t\telse if(Object == null)\r\n\t\t\t\treturn new Attr(Name, Value, Vector.clone());\r\n\t\t\telse\r\n\t\t\t\treturn new Attr(Name, Value, Vector.clone(), Object);\r\n\t\t}", "public Object clone() {\n return this.copy();\n }", "@Override\r\n\tpublic ComputerPart clone() {\n\t\treturn null;\r\n\t}", "@Override\n\tpublic Nota buildObject() {\n\t\treturn new Nota(emitente, destinatario, chave, numero, serie, emissao, total, isIncomplete);\n\t}", "public CMObject copyOf();", "public abstract Piece clone();", "public abstract Piece clone();", "@Override\n public GraphicsState clone(\n )\n {\n GraphicsState clone;\n {\n // Shallow copy.\n try\n {clone = (GraphicsState)super.clone();}\n catch(CloneNotSupportedException e)\n {throw new RuntimeException(e);} // NOTE: It should never happen.\n\n // Deep copy.\n /* NOTE: Mutable objects are to be cloned. */\n clone.ctm = (AffineTransform)ctm.clone();\n clone.tlm = (AffineTransform)tlm.clone();\n clone.tm = (AffineTransform)tm.clone();\n }\n return clone;\n }", "public BasketItemBuilder(BasketItem copyFrom) {\n this.id = copyFrom.getId();\n this.quantity = copyFrom.getQuantity();\n this.label = copyFrom.getLabel();\n this.category = copyFrom.getCategory();\n this.amount = copyFrom.getIndividualAmount();\n this.baseAmount = copyFrom.getIndividualBaseAmount();\n this.measurement = copyFrom.getMeasurement();\n if (copyFrom.hasReferences()) {\n this.references = copyFrom.getReferences();\n }\n if (copyFrom.hasItemData()) {\n this.itemData = copyFrom.getItemData();\n }\n if (copyFrom.hasModifiers()) {\n this.modifiers = copyFrom.getModifiers();\n }\n }", "public BuildingList() {\n Building temp = new Building(1);\n temp.createSubAreas(6);\n temp.setSystemPass(\"0000\");\n URL url = this.getClass().getClassLoader()\n .getResource(\"singleHouse.jpg\");\n temp.setImage(url);\n\n buildings.add(temp);\n temp = new Building(2);\n url = this.getClass().getClassLoader()\n .getResource(\"commercial.jpg\");\n temp.setImage(url);\n buildings.add(temp);\n }", "public GantBuilder ( ) { }", "private Cloudlet cloneCloudlet(final Cloudlet source, final long length) {\n final Cloudlet clone\n = new CloudletSimple(length, (int) source.getNumberOfPes());\n /*It' not required to set an ID for the clone.\n It is being set here just to make it easy to\n relate the ID of the cloudlet to its clone,\n since the clone ID will be 10 times the id of its\n source cloudlet.*/\n clone.setId(source.getId() * 10);\n clone\n .setUtilizationModelBw(source.getUtilizationModelBw())\n .setUtilizationModelCpu(source.getUtilizationModelCpu())\n .setUtilizationModelRam(source.getUtilizationModelRam());\n return clone;\n }", "public Object clone ()\n\t{\n\t\ttry \n\t\t{\n\t\t\treturn super.clone();\n\t\t}\n\t\tcatch (CloneNotSupportedException e) \n\t\t{\n throw new InternalError(e.toString());\n\t\t}\n\t}", "@Override\n public Game cloneGame(){\n GridGame clone = new pegsolitaire();\n clone.pieces = new LinkedList<Piece>();\n for(Piece pc : pieces){\n clone.pieces.add(pc.clonePiece());\n }\n clone.current_player = current_player;\n clone.size_x = size_x;\n clone.size_y = size_y;\n return clone;\n }", "@Override\r\n public Object clone() {\r\n\r\n Coordinate c = new Coordinate( this );\r\n return c;\r\n }", "public ImmutableByHavingOnlyAPrivateConstructorUsingTheBuilderPattern build() {\n return new ImmutableByHavingOnlyAPrivateConstructorUsingTheBuilderPattern(\"hi\");\n }", "public Object clone() throws CloneNotSupportedException { return super.clone(); }", "public Instance cloneShallow() {\n Instance copy;\n try {\n copy = new Instance(getNameValue().toString());\n } catch (JNCException e) {\n copy = null;\n }\n return (Instance)cloneShallowContent(copy);\n }", "public SceneLabelObjectState copy(){\n\n\t\t//get a copy of the generic data from the supertype\n\t\tSceneDivObjectState genericCopy = super.copy(); \n\n\t\t//then generate a copy of this specific data using it (which is easier then specifying all the fields\n\t\t//Separately like we used too)\n\t\tSceneLabelObjectState newObject = new SceneLabelObjectState(\n\t\t\t\tgenericCopy,\n\t\t\t\tObjectsCurrentText,\t\t\n\t\t\t\tCSSname,\n\t\t\t\tcursorVisible,\n\t\t\t\tTypedText,\n\t\t\t\tCustom_Key_Beep,\n\t\t\t\tCustom_Space_Beep);\n\n\t\treturn newObject;\n\n\n\t}", "Composite() {\n\n\t}", "public Classroom(ClassroomBuilder builder) {\n name = builder.name;\n capacity = builder.capacity;\n orientation = builder.orientation;\n plugs = builder.plugs;\n allocations = new ArrayList<>();\n }", "public SquareIF clone();", "public Complex makeDeepCopy() {\r\n Complex complex2 = new Complex(this.getReal(), this.getImaginary());\r\n return complex2;\r\n }", "private DataObject(Builder builder) {\n super(builder);\n }", "public Object clone() {\n AggregateSymbol copy = new AggregateSymbol(getName(), getAggregateFunction(), isDistinct(), LanguageObject.Util.deepClone(getArgs()));\n if (orderBy != null) {\n copy.setOrderBy(orderBy.clone());\n }\n if (condition != null) {\n copy.setCondition((Expression) condition.clone());\n }\n copy.isWindowed = this.isWindowed;\n copy.type = this.type;\n copy.setFunctionDescriptor(getFunctionDescriptor());\n return copy;\n }", "public abstract Shape clone() throws CloneNotSupportedException;" ]
[ "0.7160811", "0.69064575", "0.6718222", "0.6414179", "0.6388179", "0.6272421", "0.6269057", "0.62182534", "0.6115923", "0.61116153", "0.610112", "0.60818654", "0.606824", "0.6065374", "0.6058153", "0.60444915", "0.60409725", "0.60365635", "0.6032516", "0.6032516", "0.6030848", "0.59978205", "0.5992629", "0.5991732", "0.59739196", "0.5944571", "0.59432733", "0.5939778", "0.59253705", "0.5918627", "0.5895609", "0.58709216", "0.58697987", "0.58693373", "0.5862162", "0.5860336", "0.585196", "0.5813949", "0.5813949", "0.5813949", "0.5813949", "0.5800049", "0.57979906", "0.5769542", "0.5765592", "0.5760165", "0.57517093", "0.57490927", "0.5748281", "0.57433915", "0.573743", "0.57266635", "0.5726589", "0.5726589", "0.5726589", "0.57236874", "0.57194376", "0.57069653", "0.5705698", "0.5699751", "0.56996477", "0.56967217", "0.5692976", "0.5690232", "0.56787854", "0.56676835", "0.56642276", "0.5662478", "0.5661385", "0.5659319", "0.5655682", "0.5654695", "0.5647164", "0.56470525", "0.56465065", "0.56442755", "0.56412", "0.5638683", "0.56375694", "0.5628928", "0.5628928", "0.5623281", "0.56216586", "0.5615928", "0.5614539", "0.5610598", "0.5609835", "0.5608191", "0.5601204", "0.5599349", "0.5599099", "0.55984586", "0.5597407", "0.5596278", "0.5595598", "0.559155", "0.5590821", "0.5580339", "0.55797", "0.5574266" ]
0.6870088
2