From 6b80b0c33d7c1f452435399a20fca2c232256cab Mon Sep 17 00:00:00 2001 From: John Dupuy Date: Wed, 30 May 2018 17:06:16 -0500 Subject: [PATCH] Make friendly to JS backend --- README.md | 7 +++++++ src/turn_based_game.nim | 9 +++++++-- turn_based_game.nimble | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5ebd7fb..75a3e6b 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,13 @@ Greater documentation is being built at the wiki on this repository. Visit +# Videos + +The following two videos (to be watched in order), demonstrate how to use this library and the 'turn_based_game' library: + +1. Using "turn_based_game": https://www.youtube.com/watch?v=u6w8vT-oBjE +2. Using "negamax": https://www.youtube.com/watch?v=op4Mcgszshk + # Credit The code for this engine mimics that written in Python at the EasyAI library located at . That library contains both the game rule engine (called TwoPlayerGame) as well as a variety of AI algorithms to play as game players, such as Negamax. diff --git a/src/turn_based_game.nim b/src/turn_based_game.nim index a21e7c5..de450f2 100644 --- a/src/turn_based_game.nim +++ b/src/turn_based_game.nim @@ -70,8 +70,13 @@ method get_move*(self: Player, game: Game): string {.base.} = else: for key, value in descriptive_move_list.pairs(): echo TAB & TAB & "[$key]: $value".format("key", key, "value", value) - stdout.write TAB & "Enter move (or 'quit'): " - var response = readLine(stdin) + echo TAB & "Enter move (or 'quit'): " + var response: string + when defined(js): + # for some reason, generating a raise does not work. + response = "When compiling for Javascript, you cannot use this procedure." + else: + response = readLine(stdin) if response in move_list: return response if response == "quit": diff --git a/turn_based_game.nimble b/turn_based_game.nimble index fcb7cad..b019038 100644 --- a/turn_based_game.nimble +++ b/turn_based_game.nimble @@ -1,6 +1,6 @@ # Package -version = "1.1.1" +version = "1.1.2" author = "John Dupuy" description = "Game rules framework for turn-based games" license = "MIT"