GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Games::Sequential::Position(3) User Contributed Perl Documentation Games::Sequential::Position(3)

Games::Sequential::Position - base Position class for use with Games::Sequential

    package My::GamePos;
    use base Games::Sequential::Position;

    sub init { ... }   # setup initial state
    sub apply { ... }

    package main;
    my $pos = My::GamePos->new;
    my $game = Games::Sequential->new($pos);

Games::Sequential::Position is a base class for position-classes that can be used with Games::Sequential. This class is provided for convenience; you don't need this class to use "Games::Sequential". It is also possible to use this class on its own.

Modules inheriting this class must implement at least the "apply()" method. If you chose to not use this class, you must also implement a "copy()" method which makes a deep copy of the object.
apply($move)
Accept a move and apply it to the current state producing the next state. Return a reference to itself. Note that this method is responsible for also advancing the state's perception of which player's turn it is.

Something like this (sans error checking):

    sub apply {
        my ($self, $move) = @_;

        ... apply $move, creating next position ...

        return $self;
    }
    

The following methods are provided by this class.
new [@list]
Create and return an object. Any arguments is passed on to the "init()" method. Return a blessed hash reference.
init [@list]
Initialize an object. By default, this only means setting player 1 to be the current player.

This method is called by "new()". You You probably want to override this method and initialise your position there.

copy
Clone a position.
player [$player]
Read and/or set the current player. If argument is given, that will be set to the current player.

The author's website, describing this and other projects: <http://brautaset.org/software/>

Stig Brautaset, <stig@brautaset.org>

Copyright (C) 2004, 2005 by Stig Brautaset

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.

2022-04-09 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.