Message Boards Message Boards

Find The Monk

Intro

Find The Monk is a game of skill, where you must find the only individual who is a monk among many others.

-First download the people.nb attached to the post.

Code

Then execute this code below, inserting the location where people.nb is on your machine. In this attached .nb, there are the pre-selected images for the game code, but after executing that code, the game fetches the images automatically. For example:

ReleaseHold[
  NotebookImport[
   "C:\\Users\\quimi\\OneDrive\\Desktop\\communityMonk\\people.nb", 
   "Input"]];

You are now ready to run the main code of the game:

Options[FindTheMonk] = {"Solution" -> "No", "Difficulty" -> "Easy", 
   "Seed" -> "No", "Mode" -> "Normal"};
FindTheMonk[OptionsPattern[]] := 
 Module[{mo, mo2, d1, d2, a1, a2, c1, c2, a, d, c, monks, f, g, ym}, 
  mo = ImageAdjust[
    ImageResize[image1, 
     ImageDimensions[
       image1]*0.25*(OptionValue["Difficulty"] /. {"Easy" -> 2.5, 
         "Medium" -> 1.5, "Hard" -> 0.9, "ExtraHard" -> 0.7})], -0.1];
   d1 = ImageDimensions[mo]; 
  mo2 = ImageAdjust[
    ColorBalance[
     ImageAdjust[
      ImageResize[image2, 
       ImageDimensions[
         image2]*0.21*(OptionValue["Difficulty"] /. {"Easy" -> 3.5, 
           "Medium" -> 2.2, "Hard" -> 1.6, "ExtraHard" -> 1.1})]], 
     RGBColor[1., 0.85, 0.85] -> RGBColor[0.82, 0.54, 0.33]], -0.3]; 
  d2 = ImageDimensions[mo2]; monks = Table[image1, 500]; 
  f[r_] := (SeedRandom[r]; 
    Table[Scaled[{RandomReal[], RandomReal[]}], 
     OptionValue["Mode"] /. {"Normal" -> 285, "Inverted" -> 500}]); 
  g[r_] := (SeedRandom[r]; Scaled[a2 = {RandomReal[], RandomReal[]}]);
   ym = ImageCompose[
    ImageCompose[
     OptionValue[
       "Mode"] /. {"Normal" -> 
        Graphics[{Texture[image3], 
          Polygon[{{0, 0}, {0, 10}, {10, 10}, {10, 0}}, 
           VertexTextureCoordinates -> Automatic]}, 
         ImageSize -> Large], "Inverted" -> image4}, 
     Map[ImageAdjust[
        ImageResize[#, 
         Round[ImageDimensions[#]*RandomReal[{0.5, 1}]] + 1]] &, 
      OptionValue["Mode"] /. {"Normal" -> people, 
        "Inverted" -> monks}], 
     If[OptionValue["Seed"] == "No", 
      Table[Scaled[{RandomReal[], RandomReal[]}], 
       OptionValue["Mode"] /. {"Normal" -> 285, "Inverted" -> 500}], 
      f[OptionValue["Seed"]]]], (OptionValue[
       "Solution"] /. {"No" -> OptionValue["Mode"] /. {"Normal" -> mo,
          "Inverted" -> mo2}, 
       "Yes" -> 
        ImageResize[
         HighlightImage[
          OptionValue["Mode"] /. {"Normal" -> mo, 
            "Inverted" -> mo2}, {RGBColor[0, 1, 0, 1], EdgeForm[], 
           Binarize[
            OptionValue["Mode"] /. {"Normal" -> mo, 
              "Inverted" -> mo2}]}], (OptionValue[
             "Mode"] /. {"Normal" -> (OptionValue[
                 "Difficulty"] /. {"Easy" -> 2.5, "Medium" -> 1.5, 
                 "Hard" -> 0.9, "ExtraHard" -> 0.7}), 
             "Inverted" -> (OptionValue[
                 "Difficulty"] /. {"Easy" -> 3.5, "Medium" -> 2.2, 
                 "Hard" -> 1.6, "ExtraHard" -> 1.1})})*{13, 16}]}), 
    If[OptionValue["Seed"] == "No", 
     Scaled[a1 = {RandomReal[], RandomReal[]}], 
     g[OptionValue["Seed"]]]]; c = ImageDimensions[ym]; 
  a = If[OptionValue["Seed"] == "No", a1, a2]; 
  d = If[OptionValue["Mode"] == "Normal", d1, d2]; 
  DynamicModule[{b = {Transparent, 
      Disk[{0.5*c[[1]], 0.5*c[[2]]}, 1]}}, 
   Show[{ym, Graphics@Dynamic[b], 
     Graphics[{Transparent, 
       EventHandler[
        Button[Rectangle[{a[[1]]*c[[1]] - d[[1]]/2, 
           a[[2]]*c[[2]] - d[[2]]/2}, {a[[1]]*c[[1]] + d[[1]]/2, 
           a[[2]]*c[[2]] + d[[2]]/2}], Dynamic[b], 
         Appearance -> 
          "Frameless"], {"MouseClicked" :> (b = 
            Text[Style["Congratulations!", Bold, 
              Lighter[Hue[RandomReal[]], 0.2], 
              FontSize -> 50], {0.5*c[[1]], 0.5*c[[2]]}, 
             Background -> 
              Directive[Opacity[0.5], 
               Darker[Hue[RandomReal[]], 0.7]]])}]}]}, 
    ImageSize -> 600]]]

Game

  • In the simplest form, without arguments, a quick and easy game is created randomly:

    FindTheMonk[]
    

im1

  • When the monk is found, click with the mouse cursor on his image to display the victory message:

im2

  • Change the difficulty of the game with the optional “Difficulty”. The difficulty can be: "Easy" (default), "Medium", "Hard" and "ExtraHard":

    FindTheMonk["Difficulty" -> "Hard"]
    

im3

  • Change the game mode with the “Mode” option and the “Inverted” argument. In this style of play, the roles are reversed, where it is necessary to find out who is not the monk. All allowed options are the same for this style of play:

    FindTheMonk["Mode" -> "Inverted"]
    

im4

  • The “Seed” option makes it possible to play the same game multiple times and, together with the “Solution” option, it can be a good way out if you can’t find the answer to the game or if you want to play it for someone else:

    FindTheMonk["Mode" -> "Inverted", "Difficulty" -> "Medium", 
     "Seed" -> 347, "Solution" -> "Yes"]
    

im5

Have fun!

Thanks.

Attachments:
POSTED BY: Claudio Chaib
3 Replies

The FindTheMonk function is now in the Wolfram Function Repository!

  • To use it: ResourceFunction["FindTheMonk"]

  • To see the page in W.F.R., with options, examples and improvements, access this link:

https://resources.wolframcloud.com/FunctionRepository/resources/FindTheMonk

Thank you very much Wolfram Function Repository Team, for approving the function!

Thanks.

POSTED BY: Claudio Chaib

enter image description here -- you have earned Featured Contributor Badge enter image description here

Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!

POSTED BY: EDITORIAL BOARD

Thanks for the demonstration Claudio! Very well presented.

-Eleazar

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract