[−][src]Function tilecoding::tiles
pub fn tiles(
size: usize,
num_tilings: usize,
floats: &[f64],
ints: Option<&[isize]>
) -> Vec<usize>
This function takes a series of floating point and integer values, and encodes them as tile indices using a provided size. This function is generally reserved for when you have extraordinarily large sizes that are too large for the IHT.
Arguments
size
—the upper bounds of all returned indicesnum_tilings
—indicates the number of tile indices to be generated (i.e. the length of the returnedVec
). This value hould be a power of two greater or equal to four times the number of floats according to the original implementation.floats
—a list of floating-point numbers to be tiledints
—an optional list of integers that will also be tiled; all distinct integers will result in different tilings. In reinforcement learning, discrete actions are often provided here.
Return Value
The returned Vec<usize>
is a vector containing exactly num_tilings
elements, with each member being an index of a tile encoded by the function. Each member will always be >= 0 and <= size - 1.
Example
// find the indices of tiles for the point (x, y) = (3.6, 7.21) using 8 tilings and a maximum size of 1024: let indices = tiles(1024, 8, &[3.6, 7.21], None); // we get tiles all over the 1024 space as a direct result of the hashing // instead of the more ordered indices provided by an IHT assert_eq!(indices, vec![511, 978, 632, 867, 634, 563, 779, 737]); // a nearby point: let indices = tiles(1024, 8, &[3.7, 7.21], None); // differs by one tile: assert_eq!(indices, vec![511, 978, 632, 987, 634, 563, 779, 737]); // and a point more than one away in any dim let indices = tiles(1024, 8, &[-37.2, 7.0], None); // will have all different tiles assert_eq!(indices, vec![638, 453, 557, 465, 306, 526, 281, 863]);