Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public State getNextState(State s, Action a) {
- State succState = s.clone();
- // TODO: fill out this function
- switch(a) {
- case TURN_ON:
- succState.turned_on = true;
- break;
- case TURN_OFF:
- succState.turned_on = false;
- break;
- case TURN_RIGHT:
- succState.orientation += 1;
- succState.orientation %= 4;
- break;
- case TURN_LEFT:
- succState.orientation -= 1;
- if(succState.orientation < 0) {
- succState.orientation += 4;
- }
- succState.orientation %= 4;
- break;
- case GO:
- switch (succState.orientation) {
- case 0:
- succState.position.y++;
- break;
- case 1:
- succState.position.x++;
- break;
- case 2:
- succState.position.y--;
- break;
- case 3:
- succState.position.x--;
- break;
- }
- break;
- case SUCK:
- succState.dirt.remove(succState.position.clone());
- break;
- }
- //System.out.println("move: " + a + " -> next state: " + succState);
- return succState;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement