src/tasks/Task.js
// Resets the robot position on the field to the original position
Resets the robot position on the field to the original position
Resets the robot position on the field to the original position
function resetGameState () {
        dispatch(InterfaceActions.setVisibility(props.task_properties.visibility))
        dispatch(InterfaceActions.setAim(props.task_properties.aim))
        dispatch(InterfaceActions.setVisionField(props.task_properties.visionField))
        let ball_x = -1;
        let ball_y = -1;
        if (props.task_properties.ball.random) {
            ball_x = getRandomArbitrary(props.task_properties.ball.random.x.min,props.task_properties.ball.random.x.max);
            ball_y = getRandomArbitrary(props.task_properties.ball.random.y.min,props.task_properties.ball.random.y.max);
        }
        else {
            ball_x = props.task_properties.ball.position.x;
            ball_y = props.task_properties.ball.position.y;
        }
        dispatch(BallActions.addBall(ball_x,ball_y));
        let robot_x = -1;
        let robot_y = -1;
        let robot_rotation = 0;
        if (props.task_properties.own_robot.random) {
            robot_x = getRandomArbitrary(props.task_properties.own_robot.random.x.min,props.task_properties.own_robot.random.x.max);
            robot_y = getRandomArbitrary(props.task_properties.own_robot.random.y.min,props.task_properties.own_robot.random.y.max);
            robot_rotation = getRandomRotation() * 2*Math.PI/360;
        }
        else if (props.task_properties.own_robot.rel_ball) {
            robot_x = ball_x + props.task_properties.own_robot.rel_ball.x;
            robot_y = ball_y + props.task_properties.own_robot.rel_ball.y;
            robot_rotation = props.task_properties.own_robot.rel_ball.rotation * 2*Math.PI/360;
        }
        else {
            robot_x = props.task_properties.own_robot.position.x;
            robot_y = props.task_properties.own_robot.position.y;
            robot_rotation = props.task_properties.own_robot.position.rotation * 2*Math.PI/360;
        }
        dispatch(RobotActions.addRobot(
            robot_x,
            robot_y,
            robot_rotation,
            "left"
        ));
        if(props.task_properties.opponent_robot) {
            let opponent_x = -1;
            let opponent_y = -1;
            let opponent_rotation = 0;
            if (props.task_properties.opponent_robot.random) {
                opponent_x = getRandomArbitrary(props.task_properties.opponent_robot.random.x.min,props.task_properties.opponent_robot.random.x.max);
                opponent_y = getRandomArbitrary(props.task_properties.opponent_robot.random.y.min,props.task_properties.opponent_robot.random.y.max);
                opponent_rotation = getRandomRotation() * 2*Math.PI/360;
            }
            else {
                opponent_x = props.task_properties.opponent_robot.position.x;
                opponent_y = props.task_properties.opponent_robot.position.y;
                opponent_rotation = props.task_properties.opponent_robot.position.rotation * 2*Math.PI/360;
            }
            dispatch(RobotActions.addRobot(
                opponent_x,
                opponent_y,
                opponent_rotation,
                "right"
            ));
            if (props.task_properties.opponent_robot.movement) {
                dispatch(RobotActions.setFixedMovement(0, "right", props.task_properties.opponent_robot.movement));
            }
        }
    }
function resetGameState ( ) { dispatch ( InterfaceActions . setVisibility ( props . task_properties . visibility ) ) dispatch ( InterfaceActions . setAim ( props . task_properties . aim ) ) dispatch ( InterfaceActions . setVisionField ( props . task_properties . visionField ) ) let ball_x = - 1 ; let ball_y = - 1 ; if ( props . task_properties . ball . random ) { ball_x = getRandomArbitrary ( props . task_properties . ball . random . x . min , props . task_properties . ball . random . x . max ) ; ball_y = getRandomArbitrary ( props . task_properties . ball . random . y . min , props . task_properties . ball . random . y . max ) ; } else { ball_x = props . task_properties . ball . position . x ; ball_y = props . task_properties . ball . position . y ; } dispatch ( BallActions . addBall ( ball_x , ball_y ) ) ; let robot_x = - 1 ; let robot_y = - 1 ; let robot_rotation = 0 ; if ( props . task_properties . own_robot . random ) { robot_x = getRandomArbitrary ( props . task_properties . own_robot . random . x . min , props . task_properties . own_robot . random . x . max ) ; robot_y = getRandomArbitrary ( props . task_properties . own_robot . random . y . min , props . task_properties . own_robot . random . y . max ) ; robot_rotation = getRandomRotation ( ) * 2 * Math . PI / 360 ; } else if ( props . task_properties . own_robot . rel_ball ) { robot_x = ball_x + props . task_properties . own_robot . rel_ball . x ; robot_y = ball_y + props . task_properties . own_robot . rel_ball . y ; robot_rotation = props . task_properties . own_robot . rel_ball . rotation * 2 * Math . PI / 360 ; } else { robot_x = props . task_properties . own_robot . position . x ; robot_y = props . task_properties . own_robot . position . y ; robot_rotation = props . task_properties . own_robot . position . rotation * 2 * Math . PI / 360 ; } dispatch ( RobotActions . addRobot ( robot_x , robot_y , robot_rotation , "left" ) ) ; if ( props . task_properties . opponent_robot ) { let opponent_x = - 1 ; let opponent_y = - 1 ; let opponent_rotation = 0 ; if ( props . task_properties . opponent_robot . random ) { opponent_x = getRandomArbitrary ( props . task_properties . opponent_robot . random . x . min , props . task_properties . opponent_robot . random . x . max ) ; opponent_y = getRandomArbitrary ( props . task_properties . opponent_robot . random . y . min , props . task_properties . opponent_robot . random . y . max ) ; opponent_rotation = getRandomRotation ( ) * 2 * Math . PI / 360 ; } else { opponent_x = props . task_properties . opponent_robot . position . x ; opponent_y = props . task_properties . opponent_robot . position . y ; opponent_rotation = props . task_properties . opponent_robot . position . rotation * 2 * Math . PI / 360 ; } dispatch ( RobotActions . addRobot ( opponent_x , opponent_y , opponent_rotation , "right" ) ) ; if ( props . task_properties . opponent_robot . movement ) { dispatch ( RobotActions . setFixedMovement ( 0 , "right" , props . task_properties . opponent_robot . movement ) ) ; } } }
Resets the robot position on the field to the original position
Resets the robot position on the field to the original position
//Determines whether the ball should be placed random or at a fixed position