Modify A* Algorithm

Hi All! I have this A* Algorithm (pathfinding in games) and I'm trying to modify it to return the path closest to the destination if a path the the destination is unavailable....! I have a 2D grid as the map....
Here's the code
package kodekombat_bot;
import java.util.Comparator;
import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
public final class AStar {
     private static class CostComparator implements Comparator<Node> {
          public int compare(Node nodeA, Node nodeB) {
               return (nodeA.gcost + nodeA.hcost) - (nodeB.gcost + nodeB.hcost);
     class Node {
          final int x;
          final int y;
          Node parent;
          int gcost;
          int hcost;
          public Node(int x, int y) {
               assert x >= 0 && x < map.width : "x = " + x;
               assert y >= 0 && y < map.height : "y = " + x;
               this.x = x;
               this.y = y;
          public void calculateHeuristic() {
               hcost = (Math.abs(x - destination.x) + Math.abs(y - destination.y)) * (VERTICAL_COST + HORIZONTAL_COST) / 2;
          public void setParent(Node parent) {
               this.parent = parent;
               if (parent.x == x) {
                    gcost = parent.gcost + HORIZONTAL_COST;
               } else if (parent.y == y) {
                    gcost = parent.gcost + VERTICAL_COST;
               } else {
                    gcost = parent.gcost + DIAGONAL_COST;
          @Override
          public String toString() {
               return "(" + x + ", " + y + " : " + super.toString() + ')';
     private static final CostComparator COST_CMP = new CostComparator();
     private final int VERTICAL_COST = 10;
     private final int HORIZONTAL_COST = 10;
     private final int DIAGONAL_COST = (int) Math.rint(Math.sqrt(VERTICAL_COST * VERTICAL_COST + HORIZONTAL_COST
         * HORIZONTAL_COST));
     private final Map map;
     private final Node origin;
     private final Node destination;
     private final Queue<Node> open;
     private final int[] closed;
     public AStar(Map map, int originX, int originY, int destinationX, int destinationY) {
          assert map != null : "map = " + map;
          this.map = map;
          destination = new Node(destinationX, destinationY);
          origin = new Node(originX, originY);
          open = new PriorityQueue<Node>(Math.max(map.width, map.height) * 2, COST_CMP);
          closed = new int[(map.width * map.height >> 5) + 1];
      * Adds the node at {@code x}, {@code y} to the open list, using {@code parent} as the parent.
      * <p>
      * If the node was already added to the open list, the old value is either kept or replaced,
      * depending on whether the old one is closer to the origin or not.
      * </p>
      * @param x
      * @param y
      * @param parent
     private void addToOpen(int x, int y, Node parent) {
          Node openNode = new Node(x, y);
          openNode.setParent(parent);
          replacing: for (Iterator<Node> i = open.iterator(); i.hasNext();) {
               Node existing = i.next();
               if (existing.x == x && existing.y == y) {
                    if (existing.gcost > openNode.gcost) {
                         i.remove();
                         break replacing;
                    } else {
                         return;
          openNode.calculateHeuristic();
          open.add(openNode);
      * Starts the algorithm and returns true if a valid path was found.
      * @return
     public boolean findPath() {
          Node current = origin;
          while (current != null && (current.x != destination.x || current.y != destination.y)) {
               process(current);
               current = open.poll();
          if (current != null) {
               destination.setParent(current.parent);
          return current != null;
     public Deque<Integer> getPath() {
          assert destination.parent != null || (destination.x == origin.x && destination.y == origin.y);
          Deque<Integer> path = new LinkedList<Integer>();
          Node current = destination;
          while (current != null) {
               path.addFirst(current.y);
               path.addFirst(current.x);
               current = current.parent;
          return path;
      * Checks whether a node was already processed.
      * @param x
      * @param y
      * @return
     private boolean isClosed(int x, int y) {
          int i = map.width * y + x;
          return (closed[i >> 5] & (1 << (i & 31))) != 0;
      * Processes the passed node.
      * <ul>
      * <li>Adds it to the closed list.</li>
      * <li>Adds all adjacent nodes to the open list, if it was not processed yet and is walkable.</li>
      * </ul>
      * @param node
     private void process(Node node) {
          // no need to process it twice
          setClosed(node.x, node.y);
          // respect the array bounds
          int lX = node.x == 0 ? 0 : node.x - 1;
          int uX = node.x >= map.width - 1 ? map.width - 1 : node.x + 1;
          int lY = node.y == 0 ? 0 : node.y - 1;
          int uY = node.y >= map.height - 1 ? map.height - 1 : node.y + 1;
          // check all the neighbors
          for (int x = lX; x <= uX; ++x) {
               for (int y = lY; y <= uY; ++y) {
                    if (!isClosed(x, y) && map.isWalkable(x, y)) {
                         addToOpen(x, y, node);
      * Sets the node at {@code x}, {@code y} to "already been processed".
      * @param x
      * @param y
     private void setClosed(int x, int y) {
          int i = map.width * y + x;
          closed[i >> 5] |= (1 << (i & 31));
}Note: The function "isWalkable" returns true or false if the path is walkable or not...
This is for a bomberman game AI...thanks a lot for all your help!

+[removed previous post]+
Edited by: prometheuzz on Feb 13, 2008 3:30 PM
Cross posted in the Games-section of the forum.
@OP: please don't post the same questions in multiple forums without mentioning this. That way, people might advise you something that has already been suggested in another thread, thus wasting people's time!

Similar Messages

  • Modifying existing recursive algorithm to an iterative version

    Hi,
    I find myself wanting to modify the algorithm below to an iterative version or possibly one thats tail recursive because I'm getting stack overflow errors with the input i present my program. Can someone help me break this down? I've tried several approaches, and I seem to get stuck each time, not being able to express what I want appropriately without using recursion.
            public void visitAll(HeapItem hi) {
                HeapItem refs[] = hi.getReferences();
                HeapItem item;
                int i;
                hi.visited = true;
                for (i = 0; i < refs.length; ++i) {
                    item = refs;
    if (item != null && !item.visited)
    visitAll(item);

    You should do something like this...
    public void visitAll(HeapItem hi) {
                HeapItem refs[] = hi.getReferences();
                HeapItem item;
                int i;
                if(refs.length == 0) return;
                hi.visited = true;
                for (i = 0; i < refs.length; ++i) {
                    item = refs;
    if (item != null && !item.visited)
    visitAll(item);

  • Constraining the algorithm for assignment of multiple plot colors

    I would like to know if there is some way to modify the algorithm that
    LabVIEW uses to automatically assign different colors when a graph
    displays multiple plots. In particular, given the default background
    color (black), it appears that black is never used for a plot color.
    However, if I programmatically change the background color to white,
    for example, I would like the plot color assignment to not use white. I
    would also like to know if it is possible to constrain the plot color
    assignment to a single color a priori, without having to go back and
    explicitly assign the colors of each plot via the property node in a
    loop.
    Thanks.
    Lyle

    I think you will have to create your own plot color assignment function to do this.
    You can set the color of each plot by using the active plot property (index of the plot you want to change) and then set the plot color property (just expand one and the same property ndoe to set both at the same time).
    You can then make that function check the background color and choose a color table that fits. If this is in a built application you would run this function when a color change is detected, if it's in the development environment you need this feature make the function ask for a VI and plot name (so that it can get a reference to the plot) and put it in your projects folder. That way whenever you need to set the plot colors differently you just select this function from the Tools menu of LabVIEW. An easier alternative though would be to just create the different graphs you need (with the colors for all plots already defined correctly for that background etc.) and save them as custom indicators...
    MTO

  • Please help C++ into java.

    Hello,
    I am working one small swing program. And want to know about c++ code. Can any one tell me that can we convert the c++ code into java code. My c++ code is:
    void Activity::computeInternalStructure(Rules& r)
         //the internal subgroups list must be computed before entering here.
         //teachers
         //this->nTeachers=0;
         this->iTeachersList.clear();
         for(QStringList::Iterator it=this->teachersNames.begin(); it!=this->teachersNames.end(); it++){
              int tmp;
              for(tmp=0; tmp<r.nInternalTeachers; tmp++){
                   if(r.internalTeachersList[tmp]->name == (*it))
                        break;
              assert(tmp < r.nInternalTeachers);
              //assert(this->nTeachers<MAX_TEACHERS_PER_ACTIVITY);
              //this->teachers[this->nTeachers++]=tmp;
              this->iTeachersList.append(tmp);
         //subjects
         this->subjectIndex = r.searchSubject(this->subjectName);
         assert(this->subjectIndex>=0);
         //activity tags
         this->iActivityTagsSet.clear();
         foreach(QString tag, this->activityTagsNames)
              assert(tag!="");
              int index=r.searchActivityTag(tag);
              assert(index>=0);
              this->iActivityTagsSet.insert(index);
         //this->activityTagIndex = r.searchActivityTag(this->activityTagName);
         //students     
         //this->nSubgroups=0;
         this->iSubgroupsList.clear();
         for(QStringList::Iterator it=this->studentsNames.begin(); it!=this->studentsNames.end(); it++){
              StudentsSet* ss=r.searchAugmentedStudentsSet(*it);
              assert(ss);
              if(ss->type==STUDENTS_SUBGROUP){
                   int tmp;
                   /*for(tmp=0; tmp<r.nInternalSubgroups; tmp++)
                        if(r.internalSubgroupsList[tmp]->name == ss->name)
                             break;*/
                   tmp=((StudentsSubgroup*)ss)->indexInInternalSubgroupsList;
                   assert(tmp>=0);
                   assert(tmp<r.nInternalSubgroups);
                   //assert(this->nSubgroups<MAX_SUBGROUPS_PER_ACTIVITY);
                   bool duplicate=false;
                   if(this->iSubgroupsList.contains(tmp))
                   //for(int j=0; j<this->nSubgroups; j++)
                   //     if(this->subgroups[j]==tmp)
                             duplicate=true;
                   if(duplicate){
                        QString s;
                        s=QObject::tr(QString("Warning: activity with id=%1\ncontains duplicated subgroups. Automatically correcting..."))
                             .arg(this->id);               
                        cout<<qPrintable(s)<<endl;
                   else
                        this->iSubgroupsList.append(tmp);
                        //this->subgroups[this->nSubgroups++]=tmp;
              else if(ss->type==STUDENTS_GROUP){
                   StudentsGroup* stg=(StudentsGroup*)ss;
                   for(int k=0; k<stg->subgroupsList.size(); k++){
                        StudentsSubgroup* sts=stg->subgroupsList[k];
                        int tmp;
                        /*for(tmp=0; tmp<r.nInternalSubgroups; tmp++)
                             if(r.internalSubgroupsList[tmp]->name == sts->name)
                                  break;*/
                        tmp=sts->indexInInternalSubgroupsList;
                        assert(tmp>=0);
                        assert(tmp<r.nInternalSubgroups);
                        //assert(this->nSubgroups<MAX_SUBGROUPS_PER_ACTIVITY);
                        bool duplicate=false;
                        if(this->iSubgroupsList.contains(tmp))
                        //for(int j=0; j<this->nSubgroups; j++)
                        //     if(this->subgroups[j]==tmp)
                                  duplicate=true;
                        if(duplicate){
                             QString s;
                             s=QObject::tr(QString("Warning: activity with id=%1\ncontains duplicated subgroups. Automatically correcting..."))
                                  .arg(this->id);
                             cout<<qPrintable(s)<<endl;
                        else
                             //this->subgroups[this->nSubgroups++]=tmp;
                             this->iSubgroupsList.append(tmp);
              else if(ss->type==STUDENTS_YEAR){
                   StudentsYear* sty=(StudentsYear*)ss;
                   for(int k=0; k<sty->groupsList.size(); k++){
                        StudentsGroup* stg=sty->groupsList[k];
                        for(int l=0; l<stg->subgroupsList.size(); l++){
                             StudentsSubgroup* sts=stg->subgroupsList[l];
                             int tmp;
                             /*for(tmp=0; tmp<r.nInternalSubgroups; tmp++)
                                  if(r.internalSubgroupsList[tmp]->name == sts->name)
                                       break;*/
                             tmp=sts->indexInInternalSubgroupsList;
                             assert(tmp>=0);
                             assert(tmp<r.nInternalSubgroups);
                             //assert(this->nSubgroups<MAX_SUBGROUPS_PER_ACTIVITY);
                             bool duplicate=false;
                             if(this->iSubgroupsList.contains(tmp))
                             //for(int j=0; j<this->nSubgroups; j++)
                             //     if(this->subgroups[j]==tmp)
                                       duplicate=true;
                             if(duplicate){
                                  QString s;
                                  s=QObject::tr(QString("Warning: activity with id=%1\ncontains duplicated subgroups. Automatically correcting..."))
                                       .arg(this->id);
                                  QObject::tr("&Ok"));
                                  cout<<qPrintable(s)<<endl;
                             else{
                                  //this->subgroups[this->nSubgroups++]=tmp;
                                  this->iSubgroupsList.append(tmp);
              else
                   assert(0);
    }Please help me. In this code we are using some variables. with QT GUI in c++.
    Thanks in advance.
    Manveer.

    Manveer-Singh wrote:
    Hello,
    I am working one small swing program. And want to know about c++ code. Can any one tell me that can we convert the c++ code into java code. My c++ code is:
    void Activity::computeInternalStructure(Rules& r)
         //the internal subgroups list must be computed before entering here.
         //teachers
         //this->nTeachers=0;
         this->iTeachersList.clear();
         for(QStringList::Iterator it=this->teachersNames.begin(); it!=this->teachersNames.end(); it++){
              int tmp;
              for(tmp=0; tmp<r.nInternalTeachers; tmp++){
                   if(r.internalTeachersList[tmp]->name == (*it))
                        break;
              assert(tmp < r.nInternalTeachers);
              //assert(this->nTeachers<MAX_TEACHERS_PER_ACTIVITY);
              //this->teachers[this->nTeachers++]=tmp;
              this->iTeachersList.append(tmp);
         //subjects
         this->subjectIndex = r.searchSubject(this->subjectName);
         assert(this->subjectIndex>=0);
         //activity tags
         this->iActivityTagsSet.clear();
         foreach(QString tag, this->activityTagsNames)
              assert(tag!="");
              int index=r.searchActivityTag(tag);
              assert(index>=0);
              this->iActivityTagsSet.insert(index);
         //this->activityTagIndex = r.searchActivityTag(this->activityTagName);
         //students     
         //this->nSubgroups=0;
         this->iSubgroupsList.clear();
         for(QStringList::Iterator it=this->studentsNames.begin(); it!=this->studentsNames.end(); it++){
              StudentsSet* ss=r.searchAugmentedStudentsSet(*it);
              assert(ss);
              if(ss->type==STUDENTS_SUBGROUP){
                   int tmp;
                   /*for(tmp=0; tmp<r.nInternalSubgroups; tmp++)
                        if(r.internalSubgroupsList[tmp]->name == ss->name)
                             break;*/
                   tmp=((StudentsSubgroup*)ss)->indexInInternalSubgroupsList;
                   assert(tmp>=0);
                   assert(tmp<r.nInternalSubgroups);
                   //assert(this->nSubgroups<MAX_SUBGROUPS_PER_ACTIVITY);
                   bool duplicate=false;
                   if(this->iSubgroupsList.contains(tmp))
                   //for(int j=0; j<this->nSubgroups; j++)
                   //     if(this->subgroups[j]==tmp)
                             duplicate=true;
                   if(duplicate){
                        QString s;
                        s=QObject::tr(QString("Warning: activity with id=%1\ncontains duplicated subgroups. Automatically correcting..."))
                             .arg(this->id);               
                        cout<<qPrintable(s)<<endl;
                   else
                        this->iSubgroupsList.append(tmp);
                        //this->subgroups[this->nSubgroups++]=tmp;
              else if(ss->type==STUDENTS_GROUP){
                   StudentsGroup* stg=(StudentsGroup*)ss;
                   for(int k=0; k<stg->subgroupsList.size(); k++){
                        StudentsSubgroup* sts=stg->subgroupsList[k];
                        int tmp;
                        /*for(tmp=0; tmp<r.nInternalSubgroups; tmp++)
                             if(r.internalSubgroupsList[tmp]->name == sts->name)
                                  break;*/
                        tmp=sts->indexInInternalSubgroupsList;
                        assert(tmp>=0);
                        assert(tmp<r.nInternalSubgroups);
                        //assert(this->nSubgroups<MAX_SUBGROUPS_PER_ACTIVITY);
                        bool duplicate=false;
                        if(this->iSubgroupsList.contains(tmp))
                        //for(int j=0; j<this->nSubgroups; j++)
                        //     if(this->subgroups[j]==tmp)
                                  duplicate=true;
                        if(duplicate){
                             QString s;
                             s=QObject::tr(QString("Warning: activity with id=%1\ncontains duplicated subgroups. Automatically correcting..."))
                                  .arg(this->id);
                             cout<<qPrintable(s)<<endl;
                        else
                             //this->subgroups[this->nSubgroups++]=tmp;
                             this->iSubgroupsList.append(tmp);
              else if(ss->type==STUDENTS_YEAR){
                   StudentsYear* sty=(StudentsYear*)ss;
                   for(int k=0; k<sty->groupsList.size(); k++){
                        StudentsGroup* stg=sty->groupsList[k];
                        for(int l=0; l<stg->subgroupsList.size(); l++){
                             StudentsSubgroup* sts=stg->subgroupsList[l];
                             int tmp;
                             /*for(tmp=0; tmp<r.nInternalSubgroups; tmp++)
                                  if(r.internalSubgroupsList[tmp]->name == sts->name)
                                       break;*/
                             tmp=sts->indexInInternalSubgroupsList;
                             assert(tmp>=0);
                             assert(tmp<r.nInternalSubgroups);
                             //assert(this->nSubgroups<MAX_SUBGROUPS_PER_ACTIVITY);
                             bool duplicate=false;
                             if(this->iSubgroupsList.contains(tmp))
                             //for(int j=0; j<this->nSubgroups; j++)
                             //     if(this->subgroups[j]==tmp)
                                       duplicate=true;
                             if(duplicate){
                                  QString s;
                                  s=QObject::tr(QString("Warning: activity with id=%1\ncontains duplicated subgroups. Automatically correcting..."))
                                       .arg(this->id);
                                  QObject::tr("&Ok"));
                                  cout<<qPrintable(s)<<endl;
                             else{
                                  //this->subgroups[this->nSubgroups++]=tmp;
                                  this->iSubgroupsList.append(tmp);
              else
                   assert(0);
    }Please help me. In this code we are using some variables. with QT GUI in c++.
    Thanks in advance.
    Manveer.why do you say this?
    My c++ code is:and
    In this code we are using some variables. with QT GUI in c++. You didn't code that. Liviu Lalescu code that, not you.
    He has rights on that code and he published it under gpl.
    So you must say that it is from him, not from you.
    Also if you "translate" (modify) his algorithm you must still care about the gpl. Please read whole gpl and care about that.
    Regards,
    Volker Dirr
    PS:
    compare original code from Liviu at sourceforge or at his homepage:
    http://lalescu.ro/liviu/fet/
    you can see the copied copy in /src/engine/activity.cpp line 167 and following.

  • Buffer_pool & db_keep_cache_size

    Our database is 10.2.0.3 with 2 nodes RAC. The database servers are window 2003.
    I ran the query “select * from dba_tables where buffer_pool = 'KEEP'” and get 6 records come back. Some tables are pretty big.
    I ran “select sum(blocks) * 8192 from dba_tables where buffer_pool = 'KEEP'” and get:
    5489451008
    The parameter for db_keep_cache_size is 1073741824 for both instances.
    My question is: How Oracle handles this if Oracle allocated memory is smaller than the requested space? What are the impacts on the performance?
    Thanks,
    Shirley

    Yes, a buffer pool is a buffer pool and is managed as such. Each type of pool may have has some unique logic especially for how data is selected to go into the pool (keep, recycle, 16K block size, 2K block size) but when all else is said and done the end product is a buffer cache that has to be managed.
    Personally, I am not a fan of using multiple buffer pools. For most situations Oracle can probably do a better job of deciding what blocks to keep and purge from one large buffer cache than most DBA's can do by using the normal buffer cache, a keep, and a recycle pool. Over time the application data and usage changes. The pool configuration probably is not checked regularly enough to keep it properly aligned.
    Besides Oracle really uses a modified for touch count algorithm to manage the buffer cache instead of the documented LRU. Call it a modified LRU algorithm so the need to use a keep and/or recycle really isn’t there for most shops.
    IMHO -- Mark D Powell --

  • Aligning tabs in Tab navigator

    I'm aware that you can align the tabs either left, center or
    right - but what if I have an application which requires some of
    the tabs to be left justified with others being right justified
    within the same component. I tried using CSS with the float left
    and right properties which did not appear to work with Flex.
    Perhaps this is not possible or I'm just doing something wrong
    being new to Flex.
    Thanks.

    Hi,
    This IS possible but hard in the incarnation of the halo tab navigator.
    Check out:
    http://blog.teotigraphix.com/2010/03/08/spark-navigators-viewstack-tabnavigator-accordion
    Within a week I will be releasing that framework opensource (alpha) and it will allow you to easily do this since in Spark, your just creating custom layouts.
    In Halo, the TabBar is like concrete, there is not a lot you can change about it's characteristics without rewritting the whole thing.
    The reason you are getting the ... is that a TabBar is an HBox in disguise. I does have a modified alyout algorithm but is lays out children using the HBox algorithm.
    Mike

  • Three tier PKI - support both SHA-1 and SHA-2

    Hey guys,
    We're about to implement a new three tier PKI - root, intermediate and Issuing CA's... is it possible to have the root and intermediate configured as SHA-1, and have multiple Issuing CA's - some SHA-1 and some SHA-2, or do the SHA-2 Issuing CA's need to
    be signed by SHA-2 certificate chain?
    Thanks in advance

    I agree with Vadims - if you can start from scratch now I would recommend setting up different hierarchies with consistent algorithms.
    The mixed scenario you propose would be sort of trade-off for existing PKIs - I had related discussions with some clients of mine:
    If you have to meet SHA-2 as per compliance / security guidelines but your Root CA processes are complicated, expensive, you use HSMs at the Root level (but there is no budget / time to install another one) etc., then adding a SHA-2-capable issuing CA to
    an existing hierarchy is a first step and might meet your different requirements.
    Then you can start moving over all existing templates (and related apps.) to the new CA. If you are 100% sure that all your apps would support SHA-2 you could probably "upgrade" the Root CA by renewing it with a modified hash algorithm.
    But you never know if you will have to support another PKI-enabled application or device in the future (some embedded system for example) that does not understand SHA-2 so you might want to keep the alternative SHA-1 hierarchy.

  • Multi-Layered Tabs in Tab Navigator

    I was trying to create a Tab Navigator, where there are about 16 Tabs. Placing all these viewstacks into a Tab, and setting the width of the TabNavigator to a Fixed Width, would unfortunately add "..." to my labels. lining all my tab buttons horizontally.
    Is there a way to put tabs in more than one layer? like having so...
    | view 1 || view 2 || view 3 || view 4 ||   |
    |      view 5 ||  view 6 || view 7            |
    |                                                      |
    |                                                      |

    Hi,
    This IS possible but hard in the incarnation of the halo tab navigator.
    Check out:
    http://blog.teotigraphix.com/2010/03/08/spark-navigators-viewstack-tabnavigator-accordion
    Within a week I will be releasing that framework opensource (alpha) and it will allow you to easily do this since in Spark, your just creating custom layouts.
    In Halo, the TabBar is like concrete, there is not a lot you can change about it's characteristics without rewritting the whole thing.
    The reason you are getting the ... is that a TabBar is an HBox in disguise. I does have a modified alyout algorithm but is lays out children using the HBox algorithm.
    Mike

  • Battery Health issues - software or hardware?

    The battery on my late-2008 unibody Macbook (OSX 10.6.4) is reporting 25% battery health after 134 cycles with the "service battery" message showing.
    It's been showing this for about a fortnight now. A 100% charge usually lasts around half an hour.
    I've reset the SMC and the PRAM more than once, and the battery is calibrated every few months, and was calibrated last week.
    Here's the thing - I was looking for a replacement battery this morning, and the charge jumped from 50-odd percent, to 78%, and when I looked, it was reporting 93% battery health (I use iStat and coconut battery to get battery health). After my initial Joy at not having to splash out £100 for a new battery, the display suddenly jumped from 60% to 2%, and back to 25% battery health.
    Has anyone else had this sort of issue? I've booked into the genius bar later this week but I'd like to avoid paying for a new battery if at all possible. Anyone have any advice?

    I use Coconut and iBatt2 as well and they both report that the State of Health of my 2 'new' NewerTech 71W NuPower batteries as being about 93 - 95 percent. Their State of Charge is 100 percent after about 3 hours on charge.
    I have tried all the usual SMC/PMU resets, Magsafe pin checks, power adapter checks, etc., and still no improvement. I even installed Battery Update 1.2 and apart from a modified charging algorithm I have detected no change. I cannot get the SoH near 100 percent, consequently I am losing something like 30 minutes running time. At present each battery gives me around 90 - 120 minutes operation.
    However, I do take the point that maybe there is a software issue involved and the fault, if there is one, does not lay with the batteries. I have been wondering what the Battery Updates do? I have 1.2 installed where previously I had none but there has been no change. The 5 - 7 percent extra capacity NewerTech promised still eludes me. Why?
    Regards
    Phil

  • Remove inactive tabs border in Tab navigator

    Hi
    How can i remove the border of inactive tabs in in tab navigator
    Plz help

    Hi,
    This IS possible but hard in the incarnation of the halo tab navigator.
    Check out:
    http://blog.teotigraphix.com/2010/03/08/spark-navigators-viewstack-tabnavigator-accordion
    Within a week I will be releasing that framework opensource (alpha) and it will allow you to easily do this since in Spark, your just creating custom layouts.
    In Halo, the TabBar is like concrete, there is not a lot you can change about it's characteristics without rewritting the whole thing.
    The reason you are getting the ... is that a TabBar is an HBox in disguise. I does have a modified alyout algorithm but is lays out children using the HBox algorithm.
    Mike

  • Count a Charapter in a string

    Hi All,
    There is a oracle function that count a specific character in a string?
    Thank's in advance
    Fabio

    You need to modify the algorithm slighty in order to work correctly when the string consists only of the search pattern.
    SQL> var a varchar2(40)
    SQL> exec :a := 'xxx';
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select length(:a) - length(replace(:a,'x','')) count_of_g from dual;
    COUNT_OF_G
    SQL>
    SQL> select length(:a) - nvl(length(replace(:a,'x','')), 0) count_of_g from dual;
    COUNT_OF_G
             3
    SQL>

  • I want to add your local cryptographic algorithms to firefox. What I must modify except NSS?

    I want to add some local cryptographic algorithms to Firefox. I know, that I must modify NSS. I can, for example, modify only NSS and use this libraries in browser, or I must do something else with Firefox?

    Duplicate: https://support.mozilla.org/en-US/questions/1013323
    I will lock this thread.

  • I want to add local cryptographic algorithms to firefox. What I must modify except NSS?

    I want to add some local cryptographic algorithms to Firefox. I know, that I must modify NSS. I can, for example, modify only NSS and use this libraries in browser, or I must do something else with Firefox?

    You can try to ask advice in the news group
    mozilla.dev.tech.crypto - Google Groups:
    * https://groups.google.com/forum/#!forum/mozilla.dev.tech.crypto

  • Algorithm or pseudo code sought for getting the latest last modified time..

    Hi I need to write a program in java that lists the latest last modified time among the files in folders and its subfolder and also gets the size of the folder. In my case, average folder size is 9 GB. Could you please suggest any algorithm to achieve this?? I tried to implement it by gathering last modified times from folders and its subfolders recursively and storing the info in Vector and finally
    getting the max of the last modified times but it was horribly slow and memory hogging.

    Remove the part that stores the data in a Vector. You don't need to store any data to add up a series of numbers. And you don't need to store any data to find the largest of a series of numbers either. Just scan the directory recursively as you are already doing and keep track of the sum of the sizes and the max of the last-modified dates.

  • Where to store the password data for  exiting user in Elgamal Algorithm

    hi,
    i am doing a project in Intelligent security in java using Elagamal algorithm. The feature of Elgamal is that the password is not stored in database . Then where is the password is stored to check for a existing user .
    If i am an existing user then when i type the username and password then it should check or compare and tell that password is right or wrong . so where is the password is stored to compare ?? please give me the coding in java .
    i need the coding immediately , of how to get the password and to store and then to compare where the user is correct else message should display "type the correct password".
    Given below is my Main window coding plz help me where to include the coding,
         This simple extension of the java.awt.Frame class
         contains all the elements necessary to act as the
         main window of an application.
    // LOGIN WINDOW ( FIRST WINDOW ) FOR LOGIN AND EXISTING USER
    import java.awt.*;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.sql.*;
    import java.math.*;
    import java.security.*;
    import java.io.IOException;
    import javax.crypto.Cipher;
    import javax.crypto.IllegalBlockSizeException;
    import javax.crypto.KeyGenerator;
    import javax.crypto.SecretKey;
    public class Smart extends Frame
         public Smart()
              // This code is automatically generated by Visual Cafe when you add
              // components to the visual environment. It instantiates and initializes
              // the components. To modify the code, only use code syntax that matches
              // what Visual Cafe can generate, or Visual Cafe may be unable to back
              // parse your Java file into its visual environment.
              //{{INIT_CONTROLS
              setLayout(null);
              setBackground(new java.awt.Color(255,247,192));
              setSize(1200,900);
    // 157,135,178
              setVisible(false);
              label1.setText("USERID");
              add(label1);
              label1.setFont(new Font("Dialog", Font.PLAIN, 14));
              label1.setBounds(315,180,84,48);
              label2.setText("PASSWORD");
              add(label2);
              label2.setFont(new Font("Dialog", Font.PLAIN, 14));
              label2.setBounds(315,260,100,40);
              textField1.setBounds(430,180,216,36);
              //textField1.setBackground(new java.awt.Color(196,197,233));//textfieldcolor
              add(textField1);
              textField2.setEchoChar('*');
              //textField2.setBackground(new java.awt.Color(196,197,233));
              add(textField2);
              textField2.setBounds(430,260,213,36);
              button1.setLabel("SUBMIT");
              add(button1);
              button1.setBackground(new java.awt.Color(196,197,233));
              button1.setBounds(320,360,120,40);
              button2.setLabel("CLEAR");
              add(button2);
              button2.setBackground(new java.awt.Color(196,197,233));
              button2.setBounds(520,360,120,40);
              label3.setText("REGISTRATION FORM");
              add(label3);
              label3.setFont(new Font("Dialog", Font.BOLD, 20));
              label3.setBounds(324,54,550,80);
              button3.setLabel("NEW USER REGISTRATION");
              add(button3);
              button3.setBackground(new java.awt.Color(196,197,233));
              button3.setBounds(369,450,232,40);
              //add(textArea1);
              //textArea1.setBounds(0,360,576,52);
              setTitle("LOGIN PHASE Application");
              /*int mStrength = 16;
              SecureRandom mSecureRandom = new SecureRandom();
              p = new BigInteger(mStrength, 16, mSecureRandom);*/
              //{{INIT_MENUS
              //{{REGISTER_LISTENERS
              SymWindow aSymWindow = new SymWindow();
              this.addWindowListener(aSymWindow);
              SymAction lSymAction = new SymAction();
              button1.addActionListener(lSymAction);
              button2.addActionListener(lSymAction);
              button3.addActionListener(lSymAction);
         public Smart(String title)
              this();
              setTitle(title);
    * Shows or hides the component depending on the boolean flag b.
    * @param b if true, show the component; otherwise, hide the component.
    * @see java.awt.Component#isVisible
    public void setVisible(boolean b)
              if(b)
              setLocation(50, 50);
              super.setVisible(b);
         public static void main(String args[])
         try
                   //Create a new instance of our application's frame, and make it visible.
              (new Smart()).setVisible(true);
              catch (Throwable t)
                   System.err.println(t);
                   t.printStackTrace();
                   // Ensure the application exits with an error condition.
                   System.exit(1);
              public void addNotify()
              // Record the size of the window prior to calling parents addNotify.
              Dimension d = getSize();
              super.addNotify();
              if (fComponentsAdjusted)
                   return;
              // Adjust components according to the insets
              setSize(getInsets().left + getInsets().right + d.width, getInsets().top + getInsets().bottom + d.height);
              Component components[] = getComponents();
              for (int i = 0; i < components.length; i++)
                   Point p = components.getLocation();
                   p.translate(getInsets().left, getInsets().top);
                   components[i].setLocation(p);
              fComponentsAdjusted = true;
         // Used for addNotify check.
         boolean fComponentsAdjusted = false;
         //{{DECLARE_CONTROLS
         java.awt.Button button1 = new java.awt.Button();
         java.awt.Button button2 = new java.awt.Button();
         java.awt.Label label1 = new java.awt.Label();
         java.awt.Label label2 = new java.awt.Label();
         java.awt.Label label3 = new java.awt.Label();
         java.awt.Button button3 = new java.awt.Button();
         java.awt.TextField textField1 = new java.awt.TextField();
         java.awt.TextField textField2 = new java.awt.TextField();
         java.awt.TextArea textArea1 = new java.awt.TextArea();
         //BigInteger p;
         //{{DECLARE_MENUS
         class SymWindow extends java.awt.event.WindowAdapter
              public void windowClosing(java.awt.event.WindowEvent event)
                   Object object = event.getSource();
                   if (object == Smart.this)
                        Smart_WindowClosing(event);
         void Smart_WindowClosing(java.awt.event.WindowEvent event)
              System.exit(0);
         class SymAction implements java.awt.event.ActionListener
              public void actionPerformed(java.awt.event.ActionEvent event)
                   Object object = event.getSource();
                   if (object == button1)
                        button1_ActionPerformed(event);
                   else if (object == button2)
                        button2_ActionPerformed(event);
                   else if (object == button3)
                        button3_ActionPerformed(event);
         void button1_ActionPerformed(java.awt.event.ActionEvent event)
              //try{
              String ids = textField1.getText();
              String pss = textField2.getText();
              byte [] bt = ids.getBytes();
              BigInteger id = new BigInteger(bt);
              //by samy byte [] bts = pss.getBytes();
              //BigInteger ps = new BigInteger(bts);
         int mStrength = 16;
         SecureRandom mSecureRandom = new SecureRandom();
         BigInteger p = new BigInteger(mStrength, 16, mSecureRandom);
         System.out.println("p = "+p.toString(16));
         BigInteger g = new BigInteger(mStrength - 1, mSecureRandom);
         System.out.println("g= "+g.toString(16));
         BigInteger x = new BigInteger(mStrength - 1, mSecureRandom);
         System.out.println("x="+x.toString(16));
         //byte[] bt = id.getBytes();
         BigInteger idb = new BigInteger(bt);
         //System.out.println("id= "+idb.toString(16));
         BigInteger ps = idb.modPow(x, p);
         //String pw = new String("pass = "+ps.toByteArray());
         System.out.println("ps ="+ps.toString(16));
         BigInteger r =null;
    BigInteger ONE = BigInteger.valueOf(1L);
    BigInteger p_1 = p.subtract(ONE);
    SecureRandom sr = new SecureRandom();
    do {
    r = new BigInteger(p.bitLength(), sr);
    } while (r.compareTo(ONE) <= 0 || r.compareTo(p_1) >= 0);
         System.out.println("r= "+r.toString(16));
         BigInteger c1 =idb.modPow(r,p);
         System.out.println("c1= "+c1.toString(16));
         long time = System.currentTimeMillis();
         System.out.println("TIME ="+time);
         BigInteger one = new BigInteger( new Integer(1).toString());
         BigInteger T = new BigInteger( new Long(time).toString());
         BigInteger t =T.xor(ps);
         BigInteger t1 = t.mod(p.subtract(one));
         System.out.println("t="+t1.toString(16));
         BigInteger M = idb.modPow(t1, p);
         System.out.println("M="+M.toString(16));
         int rnd = r.intValue();
         BigInteger c2 =ps.modPow(r,p).multiply(M).mod(p);
         System.out.println("c2 ="+c2.toString(16));
         //(bia[0].modPow(a, p).modInverse(p)).multiply(bia[1]).mod(p);
         BigInteger val1 = (c1.modPow(x,p).modInverse(p)).multiply(c2).mod(p);
         BigInteger val2 = id.modPow(t1,p);
         System.out.println(val1.toString(16));
         System.out.println(val2.toString(16));
    send s=new send();
    // }catch( IOException e){
    //System.out.println("Exception caught ") ; }     
    //     catch( Exception e){
    //System.out.println("Exception caught ") ; }               
         void button2_ActionPerformed(java.awt.event.ActionEvent event)
              textField1.setText("");
              textField2.setText("");
         void button3_ActionPerformed(java.awt.event.ActionEvent event)
         {   Security s1 = null;
              try
    System.out.println("this is in Smart ");
         //Create a new instance of our application's frame, and make it visible.
              s1 = new Security();
              s1.setVisible(true);
              catch (Throwable t)
                   System.err.println(t);
                   t.printStackTrace();
                   //Ensure the application exits with an error condition.
                   System.exit(1);
              //s1.dispose();     

    Hi SaMolPP,
    You should try to use the existing ULS logging, following article is for 2010 but should also work in 2013 :
    http://geekswithblogs.net/venkatx5/archive/2010/12/09/how-to-use-uls-in-sharepoint-2010-for-custom-code.aspx
    No additional lists or databases needed.
    Hope this helps

Maybe you are looking for

  • Issue w.r.t  custom implementation of iterator

    We are facing some issue w.r.t valuechange events of some tags like inputfile,selectbooleancheckbox... In our application, We have used a panel tabbed component, the left side has a tree which has some link nodes and on the right we have tabs opened

  • Error while transporting FIPP subtype : ZFIPP

    Generation of programs and screens Transport request___: LH3K906965 System______________: LH4 tp path             : tp Version and Release: 340.16.39 640 Generation of programs and screens for transport request LH3K906965 Only generates programs with

  • Sending text in different language

    I tried sending a text in Korean, to a friend(iphone 3gs user). And all she recieved is gibberish. Anybody know how to fix this problem?

  • Flex and ColdFusion web services

    I have a simple CFC created that encompasses a function that has a query. I want to be able to use the web service in my Flex app, but I am having issues with getting the information from the CFC. My function is simple: <cffunction name="listBySubjec

  • Kernal Upgrade

    Dear All Can anyone please tell me what Other location we can put the kernal file while upgrading the kernal apart from usr\sap\sys\exe?? Regards, Manmohan