A certain children's game, often called "Huckle Buckle Beanstalk", is played with two players. Here is a brief description of how the game is played:
- One player is designated the "hider", and the other the "seeker".
- The seeker goes out of the room while the hider hides a small, pre-selected object, the "treasure".
- The hider then attempts to look for the object while the seeker gives them helpful hints:
- If the seeker is approaching the treasure, the hider will call out "warmer!"
- If the seeker is moving away from the treasure, the hider will call out "cooler!"
- Once the seeker finds the treasure, they announce that they have found it.
Your children want you to play this game with them, however, you are very busy answering questions on codegolf.SE instead. So, you decide to write a program to play the game with them. However, you want to use as little time as possible typing, so you try to make the program as little characters as possible.
We can define the room in which the game is played as a two dimensional toroidal square field. The coordinate 0,0
is the bottom left corner, and the coordinate 99,99
is the top right corner. The treasure is placed at some position n,m
where n
and m
are both positive integers between 0 and 99 inclusive.
Your program will obtain input from the player using its inbuilt user input function (e.g. prompt()
, raw_input()
, etc.) If your chosen language does not have a user input function, take input from STDIN instead. The game will work as follows:
- The program "hides" the treasure at a position
n,m
. - The program prompts the seeker to input an initial searching position. The input will come in the form
x y
wherex
andy
are positive integers. - The program outputs "correct" if the initial searching position
x,y
is equal to the treasure's positionn,m
and terminates. Otherwise: - The program will prompt the seeker to move. The input comes in the form
a b
wherea
andb
are integers that may be negative. This represents the direction vector that the seeker is moving in (a
is the x direction andb
is the y direction). - If the resultant position of the seeker is at the treasure, the program outputs "correct" and terminates. Otherwise:
- The program outputs "cooler" if the seeker is moving away from the treasure, or "hotter" if they are moving towards the treasure.
- Go to step 4.
The words "moving away" and "moving towards" may be ambigious. For this challenge, if the resultant position of the seeker after moving is closer to the treasure than their position before they were moving, they are moving towards the treasure. Otherwise, they are moving away. (Yes, this does mean that if the resultant and previous position are the same distance away, the program should output "cooler").
This is code golf, so shortest code wins. Ask questions if the specification is not clear.