From e2cfe7d89a649ac44c840b747804a818895373be Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Fri, 25 Aug 2017 00:39:09 +0200
Subject: [PATCH] Add basic movement AI test, extend move command directions.

---
 server.py | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/server.py b/server.py
index e8bca6a..aa8b1c3 100755
--- a/server.py
+++ b/server.py
@@ -103,9 +103,18 @@ class Thing:
             self.position[0] -= 1
         elif direction == 'DOWN':
             self.position[0] += 1
+        elif direction == 'RIGHT':
+            self.position[1] += 1
+        elif direction == 'LEFT':
+            self.position[1] -= 1
 
     def decide_task(self):
-        self.set_task('wait')
+        if self.position[1] > 1:
+            self.set_task('move', 'LEFT')
+        elif self.position[1] < 3:
+            self.set_task('move', 'RIGHT')
+        else:
+            self.set_task('wait')
 
     def set_task(self, task, *args, **kwargs):
         self.task = Task(task, args, kwargs)
@@ -258,8 +267,9 @@ class CommandHandler:
 
     def cmd_move(self, direction, connection_id):
         """Set player task to 'move' with direction arg, finish player turn."""
-        if not direction in {'UP', 'DOWN'}:
-            raise ArgumentError('MOVE ARGUMENT MUST BE "UP" or "DOWN"')
+        if not direction in {'UP', 'DOWN', 'RIGHT', 'LEFT'}:
+            raise ArgumentError('MOVE ARGUMENT MUST BE ONE OF: '
+                                'UP, DOWN, RIGHT, LEFT')
         self.world.player.set_task('move', direction=direction)
         self.proceed_to_next_player_turn(connection_id)
 
-- 
2.30.2