Coder Social home page Coder Social logo

henesy / tictactoefs-limbo Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 4 KB

Tic-Tac-Toe game expressed as a filesystem in Limbo. Shows off styx(2) and styxservers(2).

Makefile 4.28% Limbo 95.72%
inferno limbo purgatorio dis plan9 styx 9p 9p2000 tic-tac-toe

tictactoefs-limbo's Introduction

Tic-Tac-Toe FS

Requirements

This filesystem is written in the Limbo programming language for the Inferno operating system.

The purgatorio fork of Inferno is recommended.

No other dependencies are required if Inferno is installed.

Building

mk

Demo

mk demo

Usage

Arguments

usage: tttfs [-Dr] [-u user] [-w width]

-D enables debug logging and tracing via styx(2).

-r sets raw mode to on by default.

-u sets user as the owner of the fs tree.

-w sets the width of the game board, which is a square.

Command format

Commands are written to the /ctl file in the fs.

Moves

x|o X Y

x or o is exclusive and indicates whether to place an x piece or an o piece.

X indicates the X-coordinate on the board.

Y indicates the Y-coordinate on the board.

Auxiliary

new

Starts a new game, keeping score if the current game has ended naturally.

rawon

Sets the board to raw mode, that is, the printing will not include the visual grid as to allow easier automated parsing.

rawoff

Unsets the raw mode for the board. Non-raw mode is the default behavior of the board file.

Filesystem structure

/ctl -- command input, or, control, file

/board -- the current board state

/no -- current game number, the first game is 1

/score -- current game score

Examples

If you're used to how Plan 9 provides file servers as per postmountsrv(2) and friends, the operation of Inferno file servers may be unintuitive.

In Inferno, a styx(2) file server listens on stdin and if run from the shell directly, will seem to just hang. There are several approaches to making the server accessible, in this case, we use mount(1) to place our file server in an intuitive location.

From inside Inferno:

; mount {mntgen} /n	# Not necessary under purgatorio
; mount {tttfs} /n/ttt
; lc /n/ttt
board	ctl		no		score
; cat /n/ttt/board
 │ │ 
─────
 │ │ 
─────
 │ │ 
; echo x 0 0 > /n/ttt/ctl
; cat /n/ttt/board
x│ │ 
─────
 │ │ 
─────
 │ │ 
; echo o 1 1 > /n/ttt/ctl
; cat /n/ttt/board
x│ │ 
─────
 │o│ 
─────
 │ │ 
; 

To host the service over the network and use from plan9port:

; mount {mntgen} /n	# Not necessary under purgatorio
; mount {ttfs} /n/ttt
; listen -A 'tcp!*!1337' { export /n/ttt & }

$ 9p -a 'tcp!localhost!1337' read board
 │ │ 
─────
 │ │ 
─────
 │ │ 
$ echo x 0 0 | 9p -a 'tcp!localhost!1337' write
$ 9p -a 'tcp!localhost!1337' read board
x│ │ 
─────
 │ │ 
─────
 │ │ 

You could also easily connect to the server from Linux, etc. with:

  • 9pfuse
  • 9mount
  • mount
  • wmiir

tictactoefs-limbo's People

Contributors

henesy avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.