Advertisement
Guest User

Code for Game

a guest
Feb 8th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.04 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.IO;
  4. using System.Text;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7.  
  8. /**
  9.  * Auto-generated code below aims at helping you parse
  10.  * the standard input according to the problem statement.
  11.  * ---
  12.  * Hint: You can use the debug stream to print initialTX and initialTY, if Thor seems not follow your orders.
  13.  **/
  14. class Player
  15. {
  16.     static void Main(string[] args)
  17.     {
  18.         string[] inputs = Console.ReadLine().Split(' ');
  19.         int lightX = int.Parse(inputs[0]); // the X position of the light of power
  20.         int lightY = int.Parse(inputs[1]); // the Y position of the light of power
  21.         int initialTX = int.Parse(inputs[2]); // Thor's starting X position
  22.         int initialTY = int.Parse(inputs[3]); // Thor's starting Y position
  23.  
  24.         // game loop
  25.         while (true)
  26.         {
  27.             int remainingTurns = int.Parse(Console.ReadLine()); // The remaining amount of turns Thor can move. Do not remove this line.
  28.  
  29.             // Write an action using Console.WriteLine()
  30.             // To debug: Console.Error.WriteLine("Debug messages...");
  31.             Console.Error.WriteLine(initialTX);
  32.             Console.Error.WriteLine(initialTY);
  33.            
  34.             if(initialTY > lightY){
  35.                 Console.WriteLine("N");
  36.                 initialTY--;
  37.             }else if(initialTX < lightX){
  38.                 Console.WriteLine("E");
  39.                 initialTX++;
  40.             }else if(initialTY < lightY){
  41.                 Console.WriteLine("S");
  42.                 initialTY++;
  43.             }else if(initialTX > lightX){
  44.                 Console.WriteLine("W");
  45.                 initialTX--;
  46.             }else if(initialTX > lightX || initialTY < lightY){
  47.                 Console.WriteLine("SE");
  48.                 initialTX++;
  49.                 initialTY++;
  50.             }else if(initialTX > lightX || initialTY > lightY){
  51.                 Console.WriteLine("NW");
  52.                 initialTX--;
  53.                 initialTY--;
  54.             }
  55.            
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement