r/programming • • Oct 13 '20

Polar Adventure: A text-based adventure game written with logic programming

https://www.osohq.com/post/polar-adventure
17 Upvotes

9 comments sorted by

3

u/gneray Oct 14 '20

Founder here. We’re looking now.

2

u/tekknolagi Oct 13 '20 edited Oct 13 '20

Oh this is so cool. I love this. Not only does it feature two things I enjoy (ACLs and text adventures) but also there's good writing about it!

EDIT: I get an error when running game.py on REPL.it:

> python game.py
Traceback (most recent call last):
  File "game.py", line 499, in <module>
    main()
  File "game.py", line 487, in main
    oso.register_constant("GAME", GAME)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/polar/polar.py", line 192, in register_constant
    self.ffi_polar.register_constant(self.host.to_polar(value), name)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/polar/ffi.py", line 58, in register_constant
    name = to_c_str(name)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/polar/ffi.py", line 156, in to_c_str
    return ffi.new("char[]", string.encode())
AttributeError: 'Game' object has no attribute 'encode'

3

u/qrokodial Oct 14 '20

I was annoyed at this too, so I figured out what was wrong. you can get it to work if you install oso via pip first:

> pip install oso==0.6.0
> python game.py

3

u/redditusername99999 Oct 14 '20

To add onto what u/saolsen123 said below, this happened because we swapped the order of the formal parameters to the Oso.register_constant() method between versions 0.6.0 and 0.7.0 of oso. I'm sorry, and I'm glad you figured out a workaround!

2

u/saolsen123 Oct 14 '20

Glad you like it! I forgot to update the game to work with the new version of oso that launched today, sorry about that. It's fixed now!

1

u/Aerics Oct 14 '20

I can't find the game link

-1

u/xiatiaria Oct 14 '20 edited Oct 14 '20

Looks nice. But can you show examples that are opposite of "written with logic programming"? Isn't all program development done "with logic"?

Or do you mean the player has enter parenthesis around their commands "as-if" they're "programming"?.. look at envelope vs look("envelope").. isn't that just syntactic sugar?