This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Notes: | |
| -- you must enable the INTERNET permission in the app's manifest. | |
| -- you must enable "Google Maps Distance Matrix API" for the project in the Google Developers Console | |
| -- example URL: | |
| https://maps.googleapis.com/maps/api/distancematrix/json?origins=ESTG Leiria, Leiria, Portugal&destinations=Praça Rodrigues Lobo, Leiria, Portugal&mode=walking&key=YOUR_API_KEY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Notes: | |
| -- you must enable the "Google Places API for Android" for the project in | |
| the Google Developers Console: | |
| https://developers.google.com/places/android-api/signup#api-console | |
| -- you must connect to the to the Places API using the Google Play services API client: | |
| https://developers.google.com/places/android-api/start#connect-client | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // add the features we want | |
| annotateImageRequest.setFeatures(new ArrayList<Feature>() {{ | |
| Feature labelDetection = new Feature(); | |
| labelDetection.setType("LABEL_DETECTION"); | |
| labelDetection.setMaxResults(10); | |
| add(labelDetection); | |
| Feature textDetection = new Feature(); | |
| textDetection.setType("TEXT_DETECTION"); | |
| textDetection.setMaxResults(10); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private String convertResponseToString(BatchAnnotateImagesResponse response) { | |
| String message = ""; | |
| List<EntityAnnotation> annotations; | |
| AnnotateImageResponse annotateImageResponse = response.getResponses().get(0); | |
| message += "\n___\n Web Detection:\n\n"; | |
| Object webDetection = annotateImageResponse.get("webDetection"); | |
| if (webDetection != null) { | |
| ArrayMap webDetectionAnnotations = (ArrayMap) webDetection; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public double computeTilesOutOfPlace(EightPuzzleState finalState) { | |
| double h = 0; | |
| for (int i = 0; i < matrix.length; i++) { | |
| for (int j = 0; j < matrix.length; j++) { | |
| // Blank is ignored so that the heuristic is admissible | |
| if (this.matrix[i][j] != 0 && this.matrix[i][j] | |
| != finalState.matrix[i][j]) { | |
| h++; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public double evaluate() { | |
| return isEndOfGameState() // se of jogo acabou (alguém ganhou ou o tabuleiro está cheio) | |
| ? utility() // então devolver pontuação 0, +infinito ou -infinito (consoante seja empate, o agente a ganhar ou o oponente a ganhar) | |
| : getWinningPossibilities(agentPiece) - getWinningPossibilities(opponentPiece); // senão devolver uma pontuação de acordo com a heurística definida | |
| } | |
| // devolve o número de possibilidades que determinado jogador tem de ganhar a partir deste estado | |
| private int getWinningPossibilities(char player) { | |
| char other = player == X ? O : X; | |
| int possibilities = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class IDAStarSearch extends InformedSearch { | |
| /* | |
| * Note that, on each iteration, the search is done in a depth first search way. | |
| */ | |
| private double limit; | |
| private double newLimit; | |
| @Override | |
| public Solution search(Problem problem) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private String placeTypesToString(List<Integer> placeTypes) { | |
| String res = ""; | |
| for (int placeType : | |
| placeTypes) { | |
| res += placeTypeToString(placeType) + " "; | |
| } | |
| return res; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <LinearLayout | |
| xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:orientation="vertical" | |
| tools:context="pt.ipleiria.contacts.SearchActivity"> | |
| <EditText |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <LinearLayout | |
| xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:orientation="vertical" | |
| tools:context="pt.ipleiria.contacts.AddActivity"> | |
| <EditText |
OlderNewer