Advertisement
KeRya

Thor

Feb 23rd, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.10 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.         int charX = initialTx;
  24.         int charY = initialTy;
  25.         string direction = "";
  26.         // game loop
  27.         while (true)
  28.         {
  29.             int remainingTurns = int.Parse(Console.ReadLine()); // The remaining amount of turns Thor can move. Do not remove this line.
  30.             if (charX > lightX)
  31.             {
  32.                if (charY > lightY)
  33.                {
  34.                    direction = "NW";
  35.                    charX--;
  36.                    charY--;
  37.                }
  38.                     else
  39.                 if (charY < lightY)
  40.                 {
  41.                     direction = "SW";
  42.                     charX--;
  43.                     charY++;
  44.                 }
  45.                     else
  46.                 if (charY == lightY)
  47.                 {
  48.                     direction= "W";
  49.                     charX--;
  50.                 }
  51.                
  52.             }
  53.                 else
  54.                 if (charX < lightX)
  55.                 {
  56.                     if(charY < lightY)
  57.                     {
  58.                         direction = "SE";
  59.                         charX++;
  60.                         charY++;
  61.                     }
  62.                         else
  63.                     if(charY > lightY)
  64.                     {
  65.                         direction = "NE";
  66.                         charX++;
  67.                         charY--;
  68.                     }
  69.                         else
  70.                     if (charY == lightY)
  71.                     {
  72.                         direction= "E";
  73.                         charX++;
  74.                     }
  75.                 }
  76.                     else
  77.                 if(charX == charX)
  78.                 {
  79.                     if (charY > lightY)
  80.                     {
  81.                         direction = "N";
  82.                         charY--;
  83.                     }
  84.                         else
  85.                         {  
  86.                             direction="S";
  87.                             charY++;
  88.                         }
  89.                 }
  90.                    
  91.             // Write an action using Console.WriteLine()
  92.             // To debug: Console.Error.WriteLine("Debug messages...");
  93.  
  94.  
  95.             // A single line providing the move to be made: N NE E SE S SW W or NW
  96.             Console.WriteLine(direction);
  97.         }
  98.     }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement