components
- class rbgame.game.components.Cell(y, x, color='w', target=0, robot=None, mail=None, *, front=None, back=None, left=None, right=None)[source]
Bases:
objectA cell in the board.
Note
All attributes except
mailafter initialization shouldn’t be changed.- Parameters:
x (
int) – The abscissa on the game board. The coordinate origin is at the top left point, positive direction from left to right.y (
int) – The ordinate on the game board. The coordinate origin is at the top left point, positive direction from top to bottom.color (
str) – The color of the cell. Possible colors are'w'- white,'b'- blue,'r'- red,'y'- yellow,'gr'- green,'g'- gray.target (
int) – Number of the mail that robot have to delivery to this cell. 0 if cell isn’t receiving station.
- draw(surface)[source]
Draw this cell in a surface.
- Parameters:
surface (
Surface) – Surface to draw this cell in.- Return type:
- class rbgame.game.components.Board(colors_map, targets_map)[source]
Bases:
objectA object representing game board. It is set of
Cell.- Parameters:
- class rbgame.game.components.Robot(pos, index, color, sprites_group, clock, mail=None, count_mail=0, battery=10, with_battery=True, render_mode=None, log_to_file=False)[source]
Bases:
SpriteRobot in the board.
Note
Attributes
indexandcolorafter initialization shouldn’t be changed.- Parameters:
pos (
Cell) – Current position of the robot.index (
int) – The index of the robot.color (
str) – The color of the robot.sprites_group (
Group) – Group of mails. We need to add new mail to this group when robot pick up a mail and leaves green cell.clock (
Clock) – The game clock. For each step of the robot, time increases by \(\Delta t\).count_mail (
int) – Number of deliveried mails by robot.battery (
int) – The battery.with_battery (
bool) – Battery is considered or not.render_mode (
Optional[str]) – The render mode. It can beNoneor'human'._to_file (log) – Log game process to file or not.
- property next_rect: Rect
Next rectangle, where we should draw it after its movement.
- property observation: ndarray
Observation of the single robot. Each of attributes x, y, mail, battery is normalized to forward in neural network.
- class rbgame.game.components.Mail(mail_number, pos, render_mode=None)[source]
Bases:
SpriteA object representing a mail.