Skip to content

Commit

Permalink
Make friendly to JS backend
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnAD committed May 30, 2018
1 parent 2654b7a commit 6b80b0c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ Greater documentation is being built at the wiki on this repository.

Visit <https://github.com/JohnAD/turn_based_game/wiki>

# 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 <https://github.com/Zulko/easyAI>. 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.
9 changes: 7 additions & 2 deletions src/turn_based_game.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion turn_based_game.nimble
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 6b80b0c

Please sign in to comment.