{"id":19637114,"url":"https://github.com/nilusche/gologgym","last_synced_at":"2026-06-06T20:31:06.667Z","repository":{"id":241413904,"uuid":"806765005","full_name":"Nilusche/GologGym","owner":"Nilusche","description":"Open AI Gym Environment for GOLOG like programs","archived":false,"fork":false,"pushed_at":"2024-05-27T22:46:01.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-28T07:57:32.974Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nilusche.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-27T21:20:00.000Z","updated_at":"2024-05-28T07:57:44.373Z","dependencies_parsed_at":"2024-05-28T07:57:41.473Z","dependency_job_id":"25abed61-a409-4bbb-81d9-fbf4e5a9c042","html_url":"https://github.com/Nilusche/GologGym","commit_stats":null,"previous_names":["nilusche/gologgym"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nilusche%2FGologGym","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nilusche%2FGologGym/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nilusche%2FGologGym/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nilusche%2FGologGym/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nilusche","download_url":"https://codeload.github.com/Nilusche/GologGym/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240941503,"owners_count":19882062,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T12:33:13.976Z","updated_at":"2026-06-06T20:31:05.945Z","avatar_url":"https://github.com/Nilusche.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GologGym\nGologGym is an OpenAI Gym environment tailored for Golog programs. It provides a platform for testing, training, and benchmarking Golog-based decision-making algorithms within the Gym framework.\n\n## Table of Contents\n1. [Introduction](#introduction)\n2. [Features](#features)\n3. [Installation](#installation)\n4. [Folders](#folders)\n4. [Start](#start)\n5. [Examples](#examples)\n\n# Introduction\nGologGym integrates the powerful decision-making capabilities of Golog with the versatile and widely-used OpenAI Gym environment. This allows developers and researchers to leverage Golog’s high-level programming constructs in the context of reinforcement learning and other AI research areas.\n\n# Features\n**Seamless Integration**: Combine the high-level action languages of Golog with the robust reinforcement learning environment of OpenAI Gym.\n**Flexible Environment**: Easily define and manipulate Golog programs within a Gym-compatible framework. \u003cbr\u003e\n**Extensible**: Add new Golog operators and predicates to suit the needs of the specific domain. \u003cbr\u003e\n\n# Installation\nRun `pip install -e golog` to register the golog environment \u003cbr\u003e\nUse the classes `GologAction`, `GologState` from `utils.golog_utils` to define golog state and actions for the program initiation \u003cbr\u003e\nUse `utils.mcts` to utilize custom mcts implementation \u003cbr\u003e\n\n# Folders\n* `/examples`: Contains example environment for the Blocksworld and Pacman in Prolog Environment\n* `/files`: Contains the pseudo language files to define the Blocksworld and Pacman Environment\n* `/golog`: Contains the Golog Environment implementation\n* `/utils`: Contains utility functions for Golog Environment\n\n\n# Start\n## Define your Golog Program\nTo define your golog program as env follow these steps:\n1. **Define your domain**: The domain includes all the objects, fluents (variables that describe the state of the world), and initial state of the environment\n2. **Define your actions**: Actions are defined by their preconditions and effects. Preconditions are conditions that must be true for the action to be executed, and effects describe how the state changes after the action is executed.\n3. **Create the Environment**: Now create the Golog environment using the initial state, actions, goal and reward function.\n\nA sample environment in pseudocode could look like this:\n```\nsymbol domain block = {a, b, c}\nsymbol domain location = block | {table}\n\nlocation fluent loc(block x) {\ninitially:\n    (a) = c;\n    (b) = table;\n    (c) = b;\n}\n\naction stack(block x, location y) {\nprecondition:\n      x != y // Can't stack x on x\n    \u0026 x != table // Can't stack table\n    \u0026 loc(x) != y // Can't stack the same thing twice\n    \u0026 (!exists(block z) loc(z) == x) // Nothing is on x\n    \u0026 (\n        y == table // either y is the table...\n        | !exists(block z) loc(z) == y // or nothing is on y\n    )\n\neffect:\n    loc(x) = y;\n}\n\nbool function goal() =\n    loc(a) == table \u0026 loc(b) == a \u0026 loc(c) == b\n\nnumber function reward() =\n    if (goal())\n        100\n    else\n        -1\n```\n\nExample Environment Implementation:\n```python\ndef stack_precondition(state, x, y):\n    return x != y and x != 'table' and state.fluents[f'loc({x})'].value != y and not any(state.fluents[f'loc({z})'].value == x for z in state.symbols['block'])\n\ndef stack_effect(state, x, y):\n    state.fluents[f'loc({x})'].set_value(y)\n\ndef blocksworld_goal(state):\n    return state.fluents['loc(a)'].value == 'table' and state.fluents['loc(b)'].value == 'a' and state.fluents['loc(c)'].value == 'b'\n\ninitial_state = GologState()\n#name, values\ninitial_state.add_symbol('block', ['a', 'b', 'c'])\ninitial_state.add_symbol('location', ['a', 'b', 'c', 'table'])\n#name, possible values, initial val\ninitial_state.add_fluent('loc(a)', ['a', 'b', 'c', 'table'], 'c')\ninitial_state.add_fluent('loc(b)', ['a', 'b', 'c', 'table'], 'table')\ninitial_state.add_fluent('loc(c)', ['a', 'b', 'c', 'table'], 'b')\n\nstack_action = GologAction('stack', stack_precondition, stack_effect, [initial_state.symbols['block'], initial_state.symbols['location']])\ninitial_state.add_action(stack_action)\n\n#can be passed as array or created with the add_action() function.\nactions = [\n    GologAction('stack', stack_precondition, stack_effect, ['block', 'location']),\n]\n\n#Notice the reward function has not been redefined here as it uses a default reward function (the one mentioned in the pseudocode)\n\n#Create the Environment\nenv = gym.make('Golog-v0', initial_state=initial_state, goal_function=blocksworld_goal, actions=actions)\n```\n\n\n## Creating Your Own Golog Environment / Extending the GologEnv\nTo create a custom Golog environment, follow these steps:\n1. **Define Your Golog Program**: Create a Golog program that specifies the behavior and logic of your environment.\n2. **Implement the Environment**: Instantiate the Golog Environment with the GologState and GologActions\n3. **Register the Environment**: Register the environment using the `register` function\nExample:\n```python\nfrom golog_gym.envs import GologGymEnv\nfrom gym.envs.registration import register\n\nclass MyGologEnv(GologGymEnv):\n    def __init__(self):\n        super(MyGologEnv, self).__init__()\n\n    def reset(self):\n        # Your reset logic\n        pass\n\n    def step(self, action):\n        # Your step logic\n        pass\n\n    def render(self, mode='human'):\n        # Your render logic\n        pass\n\nregister(\n    id='MyGologEnv-v0',\n    entry_point='my_module:MyGologEnv',\n)\n```\n\n\n# Examples\nCheck out the examples folder for various sample Golog programs and environments. These examples demonstrate how to create and interact with different Golog-based environments.\n* **Blocksworld Example**: Environment Implementation can be found in blocksworld_golog.py \n* **Pacman Example**: Environment Implementation can be found in pacman_golog.py\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnilusche%2Fgologgym","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnilusche%2Fgologgym","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnilusche%2Fgologgym/lists"}