This is our solution for solving the Rasende Roboter game. This project serves as an introduction to AI game-solving techniques.
We selected Rasende Roboter for its challenging gameplay mechanics, particularly the strategic movement of multiple pawns required to solve each challenge.
We started this project by exploring differents paths. You will find our individual attempts bellow. This repository is the final version that merge each of our implementations.
- Tina : https://github.com/hsin0002/RasendeRoboter
- Uella : https://github.com/UellaAdjoyi/Projet_Rasende_Roboter
- Rémi : https://github.com/remib18/IA41-project
- Entry point
- Create and initialize Game object
- Board object created and initialized
- Execute run function in Game
- initialize pygame
- initialize parameters
- running loop to listen to the user actions (event handlers)
- draw objects: board objects, buttons, timer
- quit pygame when done
- generate robots and targets
- transform walls and targets from generated map
- draw board objects: grid, robots, targets
- move robot
- define AI auto moving method
- define robot object with necessary informations: coordinates, color, attempts, target, reach target or not
- method to generate random map from the 8 defined maps
- define Game class
- parameters:
- Board
- screen: to save the initializes pygame screen
- clock: to save the initialized pygame clock
- robot_list: list of robot names
- general_font: font to be used in the pygame program
- colors: color list for the robots
- running: flag for controling the running loop
- button_rects: control button rectangle information
- end_screen_button_rects: end screen button rectangle information
- start_time: time records
- estimated_move: for saving the move sequence generated by the algorithm
- ai_player: AIPlayer object for the AI auto control
- game_over: flag for controling the event handler
- methods:
- create_buttons
- handle_events: handle mouse click and keyboard input
- handle_button_click: handle click action, trigger actions according to the clicked position
- trigger_action: triggered action when a button is clicked
- ai_play_turn: move the robots according to the move sequences
- change_selected_robot: change the selected robot
- handle_keyboard_input: handle keyboard input, trigger corresponding action
- draw_buttons: a draw function
- draw_timer: a draw function
- draw: call draw method from Board object, draw_button, draw_timer, for easier redraw the window objects
- run: running loop, controled by running flag and game_over flag
- define Robot class
- parameters:
- coordination x
- coordination y
- attempts (default=0)
- target (default=None)
- reached_target (default=False)
- methods:
- move: move the robot to another coordinates
- increment_attempt: increase the attempt number by 1
- define Board class
- parameters:
- grid_size: grid number for a side
- cell_size: size(width/height)) for a grid
- control_panel_width: width for the control panel
- robots: list to store created Robot object
- selected_robot
- targets: list for the targets of each robot
- target_shape: to save the random generated target
- target_color: to save the random generated target color
- robot_images: list to store loaded robot images
- shape_images:list to store loaded target shape images
- walls: list to store the position of the walls
- ai_move: for storing the AI moving sequence in the format [[direction, color], [direction, color], ...]
- ai_error: flag to tell whether there's an error occurs when AI auto moving the robots
- move_history: for storing user manipulation of the robots
- methods:
- initialize_board: initialize board by calling generate_robots_and_target and transform_walls_and_targets
- reset_parameters: reset the parameters
- load_images: load images of the robots and targets
- generate_robots_and_targets: randomly generate robot position and target shape and color, set the selected robot
- transform_walls_and_targets: translate the loaded map information, save the data into corresponding parameters
- draw: draw grid, walls, targets, robot and information
- target_reached_result: show the attempts when reaches the target
- move_robot: define rules of moving the robots
- target color and shapre list and the abbreviation
- list of the abbreviation for robot targets (each robot have a list of target shape: ["circle", "square", "triangle", "hexagon", "Rain"]):
- RC: red circle
- RS: red square
- RT: red triangle
- RH: red hexagon
- YC: yellow circle
- YS: yellow square
- YT: yellow triangle
- YH: yellow hexagon
- GC: green circle
- GS: green square
- GT: green triangle
- GH: green hexagon
- BC: blue circle
- BS: blue square
- BT: blue triangle
- BH: blue hexagon
- Rain: rainbow target
- Others:
- 1: grid line
- 2: walls
- X: centered grid
- list of the abbreviation for robot targets (each robot have a list of target shape: ["circle", "square", "triangle", "hexagon", "Rain"]):
- define Map class
- parameters:
- map_import: load the map from .txt file
- map_input: generate final map from the loaded map
- methods:
- rotate_map_90_right: rotate a map by 90 degrees clockwise
- rotate_map_180_right: rotate a map by 180 degrees clockwise
- rotate_map_270_right: rotate a map by 270 degrees clockwise
- load_maps: load maps from the .txt file
- generate_gameboard: create the 16x16 gameboard by combining rotated maps
- Find trigger_action function in Game class in game.py (line 67)
- At the
button_name == "AI play"
part of the if statement, following the steps listed- Pass the board situation (robot_list, target_list, wall_list, ... into the algorithm)
- Get the AI move steps from the algorithm
- Make sure the AI move step is in the format: [[direction, color], [direction, color], ...]
- Pass the AI move steps into the auto-move function
- remove the fake data (line 79)
- run the program and click AI play to check accuracy