-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add notebook for fieldwalk player help
Signed-off-by: jparisu <[email protected]>
- Loading branch information
Showing
3 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"id": "SFNDJ1SSfNVU" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# Download and install package\n", | ||
"!pip install git+https://github.com/jparisu/[email protected]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"id": "wioHNbdZfce3" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# Imports\n", | ||
"from IArena.arena.GenericGame import BroadcastGame\n", | ||
"from IArena.games.FieldWalk import FieldWalkRules, FieldWalkMovement, FieldWalkPosition" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"id": "mi-EZXqDflF0" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# Create your own player\n", | ||
"class MyPlayer:\n", | ||
"\n", | ||
" def __init__(self, rules):\n", | ||
" # Store the rules of the game\n", | ||
" self.rules = rules\n", | ||
"\n", | ||
" def play(self, position: FieldWalkPosition) -> FieldWalkMovement:\n", | ||
" # Code to play\n", | ||
" pass" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"id": "087RDxY1liZ2" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# Make your player play in Hanoi\n", | ||
"rules = FieldWalkRules()\n", | ||
"my_champion = MyPlayer(rules)\n", | ||
"\n", | ||
"print(f\"Let's play!: {rules}\")\n", | ||
"\n", | ||
"# Broadcast to see the game iterations. If not use GenericGame\n", | ||
"game = BroadcastGame(rules=rules, players=[my_champion])\n", | ||
"result = game.play()\n", | ||
"\n", | ||
"your_score = result[0]\n", | ||
"\n", | ||
"print(f\"CONGRATULATIONS! You got it in {your_score} moves ☚ (<‿<)☚\")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"colab": { | ||
"provenance": [] | ||
}, | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters