Created
June 16, 2019 19:36
-
-
Save Debilski/f938eb6a7b5ccf7d858a76f862a19add to your computer and use it in GitHub Desktop.
Bot.eaten behaviour
This file contains hidden or 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
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "from pelita.game import run_game\n", | |
| "from pelita.layout import parse_layout\n", | |
| "from pelita.player import stepping_player" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 2, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "layout = parse_layout(\"\"\"\n", | |
| "########\n", | |
| "# 01##\n", | |
| "#23..###\n", | |
| "########\n", | |
| "\"\"\")" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "team 0 does not move but we print `bot.eaten` for each bot" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 3, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "def move0(bot, state):\n", | |
| " print(f\"round: {bot.round}, turn: {bot.turn}\")\n", | |
| " print(f\"We are bot {bot.turn}. Have we been eaten? {bot.eaten}\")\n", | |
| " print(f\"The other bot is bot {bot.other.turn}. Has it been eaten? {bot.other.eaten}\")\n", | |
| " return bot.position, state" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "team 1 moves its first bot to eat bot 0" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 4, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "move1 = stepping_player('<-', '--')" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 5, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "round: 1, turn: 0\n", | |
| "We are bot 0. Have we been eaten? False\n", | |
| "The other bot is bot 1. Has it been eaten? False\n", | |
| "round: 1, turn: 1\n", | |
| "We are bot 1. Have we been eaten? False\n", | |
| "The other bot is bot 0. Has it been eaten? True\n", | |
| "round: 2, turn: 0\n", | |
| "We are bot 0. Have we been eaten? False\n", | |
| "The other bot is bot 1. Has it been eaten? False\n", | |
| "round: 2, turn: 1\n", | |
| "We are bot 1. Have we been eaten? False\n", | |
| "The other bot is bot 0. Has it been eaten? False\n", | |
| "Finished. 'local-team (move)' won over 'local-team (move0)'. (5:0)\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "res = run_game([move0, move1], layout_dict=layout, max_rounds=2)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python (pelita)", | |
| "language": "python", | |
| "name": "pelita" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 3 | |
| }, | |
| "file_extension": ".py", | |
| "mimetype": "text/x-python", | |
| "name": "python", | |
| "nbconvert_exporter": "python", | |
| "pygments_lexer": "ipython3", | |
| "version": "3.7.3" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 2 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment