public boolean setState( long id )
    {
        for(int i=0; i<cars.size(); ++i)
        {
            GridPos org = cars_original.get(i);
            int change = (int)((id >> (i * 3))&7);

            // Changes in column position only if vertical
            if( cars.get(i).getOrientation() == RushHourCar.Orientation.VERTICAL )
            {
                if( change < org.getRow() ) {
                    cars.get(i).getHead().setRow(org.getRow() - change);
                }
                else if( change > org.getRow() ) {
                    cars.get(i).getHead().setRow(org.getRow() + (change - org.getRow()));
                }
                else if( change == org.getRow() ) {
                    cars.get(i).getHead().setRow(org.getRow());
                }
             }
             // Changes only in row position if horizontal
             else if( cars.get(i).getOrientation() == RushHourCar.Orientation.HORIZONTAL )
             {
                 if( change < org.getCol() )
                     cars.get(i).getHead().setCol(org.getCol() - change);
                 else if( change > org.getCol() )
                     cars.get(i).getHead().setCol(org.getCol() + (change - org.getCol()));
                 else if( change == org.getCol() )
                     cars.get(i).getHead().setCol(org.getCol());
             }
         }
         return true;
    }