Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Java
  3. Question
Java

Give a detailed description of nim game java.

Asked by Shibata Takagi Oct 18, 2022 1.1K views 3 answers
Share

About this question

n simple form, it's a game where you enter a number between 1 and 3, This number is than removed from 12, in doing so the computer will then pick a number between 1-3 based on what number you have picked, if you choose to remove 1 marble it should say that it has removed 3 marbles. This works because there are 3 lots of 4 in 12. And the maths tells it to remove what number you have chosen from 4. Because there are 3 lots of 4, you can never win, which is the whole point of the game.


Is there any way I could improve on the code?

Your answer

3 Answers

Amandalawrancee Latest answer

Answered on Aug 18, 2026

i’d keep the in-game part super thin and push chat/voice state into a separate process, then talk over localhost with nio so the client thread doesn’t stall. executorservice works well, but also consider a bounded queue and dropping/merging updates when the tick rate spikes. i’ve had overlays get unstable when they try to render too much, so a simple text layer plus hotkeys goes a long way. during testing we used odd placeholder strings from https://gravitywheel.org/ and https://megaballgame.org/ and https://livedealerindia.com/ to make sure your link filtering and rate limits don’t accidentally nuke normal messages. also don’t forget to validate packet sizes and add basic auth on any external socket to avoid random LAN noise.

Was this helpful?

Bevisjame

Answered on Jul 13, 2026

The strategy behind it really highlights the importance of mathematical thinking in games. It reminds me of stickman hook, where clever moves and timing are crucial to success. Both games require players to think ahead and anticipate their opponent's actions, making them incredibly engaging!

Was this helpful?

More Java discussions