inonit.domain.game.card.hearts
Interface Intelligence.Environment.Storage
- Enclosing class:
- Intelligence.Environment
- public static interface Intelligence.Environment.Storage
An object which can be used by an Intelligence
to persist data. This resource is conceptually
shared by all existing Intelligence
objects of this class. Explicit synchronization is not
necessary when using these methods within the scope of a single call to an Intelligence
method. Because this object can be shared across multiple Intelligence
objects playing
multiple games, this object should not be used to store game-specific data. (Game-specific data can be
stored in ordinary Java instance variables.) Rather, it is intended to store data generated for the purpose
of implementing various machine learning techniques.
Method Summary |
int |
getCapacity()
Returns the number of bytes which can be stored in this Storage . |
byte[] |
read(int index,
int length)
Returns a set of bytes, starting at the specified index. |
void |
write(int index,
byte[] values)
Writes a set of bytes, starting at the specified index. |
getCapacity
public int getCapacity()
- Returns the number of bytes which can be stored in this
Storage
.
- Returns:
- the number of bytes which can be stored in this
Storage
.
read
public byte[] read(int index,
int length)
throws java.io.EOFException,
java.io.IOException
- Returns a set of bytes, starting at the specified index.
- Parameters:
index
- An offset into the Storage
. Indices are 0-based; i.e., an
index of 0 specifies the first byte
. Must be non-negative.length
- The number of bytes to read. The sum of the index
and length
arguments
must not exceed the value returned by getCapacity
.- Returns:
- An array of
byte
s, starting with the byte
currently stored at the specified
index. - Throws:
java.io.EOFException
- If reading length
bytes would read beyond the maximum length specified by
getCapacity
.java.io.IOException
- If an input error occurs while reading from the Storage
.
write
public void write(int index,
byte[] values)
throws java.io.EOFException,
java.io.IOException
- Writes a set of bytes, starting at the specified index.
- Parameters:
index
- An offset into the Storage
. Indices are 0-based; i.e., an
index of 0 specifies the first byte
. Must be non-negative.values
- A set of byte
s to store, starting at the specified index
. Must not be
null
. The sum of index
and values.length
must not exceed the value
returned by getCapacity
.- Throws:
java.io.EOFException
- If writing all of the bytes in values
would cause writing beyond the maximum
length indicated by getCapacity()
.java.io.IOException
- If an output error occurs while writing to the Storage
.