AI-Pathfinding-SMAstar

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

	- original version; created by h2xs 1.23 with options
		-XAn AI::Pathfinding::SMAstar

0.02  Fri Feb 25 11:17:01 2010
	- updated pod documentation

0.03  Sun Feb 28 12:26:58 2010
	- updated pod documentation

0.04  Tue Mar  2 13:17:53 2010
      	- updated error handling in add_start_state method
	- perldoc edits 

0.05  Thu Mar  4 11:06:10 2010
      	- fixed an issue where search did not terminate when max_cost
	  is reached.

0.06  Thu Mar  4 11:06:10 2010
      	- fixed an issue with successor iterator in Path class.

lib/AI/Pathfinding/SMAstar.pm  view on Meta::CPAN

     
	_priority_queue => AI::Pathfinding::SMAstar::PriorityQueue->new(),
	_state_eval_func => undef,	
	_state_goal_p_func => undef,
	_state_num_successors_func => undef,
	_state_successors_iterator => undef,
	_show_prog_func => undef,
	_state_get_data_func => undef,


	@_, # attribute override
    };
    return bless $self, $class;
}


sub state_eval_func {
    my $self = shift;
    if (@_) { $self->{_state_eval_func} = shift }
    return $self->{_state_eval_func};
}

lib/AI/Pathfinding/SMAstar/AVLQueue.pm  view on Meta::CPAN

	_avltree         => Tree::AVL->new(fcompare => \&AI::Pathfinding::SMAstar::AVLQueue::compare_obj_counters,
					   fget_key => \&AI::Pathfinding::SMAstar::AVLQueue::obj_counter,
					   fget_data => \&AI::Pathfinding::SMAstar::AVLQueue::obj_value),
	
	_counter     => 0,
	
	_obj_counts_tree => Tree::AVL->new(fcompare => \&AI::Pathfinding::SMAstar::PairObj::compare_keys_numeric,
					   fget_key => \&AI::Pathfinding::SMAstar::PairObj::key,
					   fget_data => \&AI::Pathfinding::SMAstar::PairObj::val),
		
        @_,    # Override previous attributes
    };
    return bless $self, $class;
}



##############################################
# accessor
##############################################

lib/AI/Pathfinding/SMAstar/AVLQueue.pm  view on Meta::CPAN

	    return(-1);
	}
	elsif($arg_key == $key){
	    return(0);
	}
	elsif($arg_key < $key){
	    return(1);
	}	
    }
    else{
	croak "AVLQueue::compare_obj_counters: error: null argument object\n";
    }
}


sub obj_counter{
    my ($obj) = @_;
    return $obj->{_queue_counter};
}

sub obj_value{

lib/AI/Pathfinding/SMAstar/AVLQueue.pm  view on Meta::CPAN

	    return(-1);
	}
	elsif($arg_key == $key){
	    return(0);
	}
	elsif($arg_key < $key){
	    return(1);
	}	
    }
    else{
	croak "AVLQueue::compare error: null argument object\n";
    }
}

sub lookup {    
    my ($self, $obj) = @_;        
    my $found_obj = $self->{_avltree}->lookup_obj($obj);

    if(!$found_obj){
	croak "AVLQueue::lookup:  did not find obj in queue\n";
	return;

lib/AI/Pathfinding/SMAstar/Examples/Phrase.pm  view on Meta::CPAN

	_match_remainder_right   => undef,
	_letters_seen            => undef,  # letters seen, up to/including antecedent
	_cost                    => undef,  # cost used for heuristic search
	_cost_so_far             => undef,
	_num_chars_so_far        => undef,  # cummulative cost used for heuristic
	_num_new_chars           => undef,
	_no_match_remainder      => undef,  # flag specifying whether there was a remainder
	_phrase                  => undef,
	_depth                   => 0,
	_f_cost                  => undef,
	@_,    # Override previous attributes
    };

    return bless $self, $class;
 
}

##############################################
## methods to access per-object data        
##                                    
## With args, they set the value.  Without  

lib/AI/Pathfinding/SMAstar/Examples/WordObj.pm  view on Meta::CPAN

use strict;

##################################################
## the object constructor (simplistic version)  ##
##################################################
sub new {
    my $invocant = shift;
    my $class   = ref($invocant) || $invocant;
    my $self = {
        _word  => undef,      
        @_,                 # Override previous attributes
    };
    return bless $self, $class;
}

##############################################
## methods to access per-object data        ##
##                                          ##
## With args, they set the value.  Without  ##
## any, they only retrieve it/them.         ##
##############################################

lib/AI/Pathfinding/SMAstar/PairObj.pm  view on Meta::CPAN


##################################################
# PairObj constructor
##################################################
sub new {
    my $invocant = shift;
    my $class   = ref($invocant) || $invocant;
    my $self = {
	_key    => undef,
        _value  => undef,      
        @_,  # Override previous attributes
    };
    return bless $self, $class;
}

##############################################
# accessors
##############################################
sub value {
    my $self = shift;
    if (@_) { $self->{_value} = shift }

lib/AI/Pathfinding/SMAstar/Path.pm  view on Meta::CPAN

	_descendants_on_queue    => 0,

	_descendands_deleted     => 0,
	_is_completed            => 0,
	_num_successors          => undef,
	_num_successors_in_mem   => 0,
	_is_on_queue             => 0,
	_iterator_index          => 0,      # to remember index of iterator for descendants
	_need_fcost_change       => 0,      # boolean

	@_,    # attribute override
    };

    return bless $self, $class;
        
}

##############################################
# accessors
##############################################

lib/AI/Pathfinding/SMAstar/PriorityQueue.pm  view on Meta::CPAN

						fget_data => sub { $_[0] },),

	f_depth        => \&AI::Pathfinding::SMAstar::Path::depth,
	f_fcost        => \&AI::Pathfinding::SMAstar::Path::fcost,
	f_avl_compare  => \&AI::Pathfinding::SMAstar::Path::compare_by_depth,
	f_avl_get_key  => \&AI::Pathfinding::SMAstar::Path::depth,
	f_avl_get_data => \&AI::Pathfinding::SMAstar::Path::get_data,

	_size                 => 0,

	@_,    # attribute override
    };
    return bless $self, $class;
}

################################################
# accessors
################################################

sub hash_of_trees {
    my $self = shift;

lib/AI/Pathfinding/SMAstar/TreeOfQueues.pm  view on Meta::CPAN

sub new {
    my $invocant = shift;
    my $class   = ref($invocant) || $invocant;
    my $self = {
	f_avl_compare => undef,
	f_obj_get_key  => undef,
	f_obj_get_data => undef,
	_avl_tree   => Tree::AVL->new(fcompare => \&AI::Pathfinding::SMAstar::AVLQueue::compare,
				      fget_key => \&AI::Pathfinding::SMAstar::AVLQueue::key,
				      fget_data => \&AI::Pathfinding::SMAstar::AVLQueue::key),
        @_, # attribute override
    };

    return bless $self, $class;
}


sub insert{
    my ($self, $obj) = @_;

    # check to see if there is a Queue in the tree with the key of obj.



( run in 1.322 second using v1.01-cache-2.11-cpan-49f99fa48dc )