Skip to content

Commit

Permalink
Add skeleton for crystal version
Browse files Browse the repository at this point in the history
  • Loading branch information
JanEricNitschke committed Jul 3, 2024
1 parent 5b4bd7f commit 1c994f6
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/crystal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This workflow will run the tests on the crystal version of tictactoe

name: crystal

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./tictactoe_java
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
- name: Check formatting
run: crystal tool format --check
- name: Build
run: crystal build src/tictactoe_crystal.cr
- name: Run tests
run: crystal spec
- name: Run
run: crystal run src/tictactoe_crystal.cr -- --X-Strength=4 --O-Strength=4
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,16 @@ Run with:
coffee tictactoe.coffee
```

## TicTacToe-Crystal

Version using [Crystal]().

Test and run with:
```bash
crystal spec
crystal run src/tictactoe_crystal.cr -- --X-Strength=4 --O-Strength=4
```

## TicTacToe-scratch
Very simple two player tictactoe game with Scratch.

Expand Down
9 changes: 9 additions & 0 deletions tictactoe_crystal/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*.cr]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
5 changes: 5 additions & 0 deletions tictactoe_crystal/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/docs/
/lib/
/bin/
/.shards/
*.dwarf
21 changes: 21 additions & 0 deletions tictactoe_crystal/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Jan-Eric Nitschke <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
27 changes: 27 additions & 0 deletions tictactoe_crystal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# tictactoe_crystal

TODO: Write a description here

## Installation

TODO: Write installation instructions here

## Usage

TODO: Write usage instructions here

## Development

TODO: Write development instructions here

## Contributing

1. Fork it (<https://github.com/your-github-user/tictactoe_crystal/fork>)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

## Contributors

- [Jan-Eric Nitschke](https://github.com/your-github-user) - creator and maintainer
13 changes: 13 additions & 0 deletions tictactoe_crystal/shard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: tictactoe_crystal
version: 0.1.0

authors:
- Jan-Eric Nitschke <[email protected]>

targets:
tictactoe_crystal:
main: src/tictactoe_crystal.cr

crystal: '>= 1.12.2'

license: MIT
2 changes: 2 additions & 0 deletions tictactoe_crystal/spec/spec_helper.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require "spec"
require "../src/tictactoe_crystal"
9 changes: 9 additions & 0 deletions tictactoe_crystal/spec/tictactoe_crystal_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require "./spec_helper"

describe TictactoeCrystal do
# TODO: Write tests

it "works" do
false.should eq(false)
end
end
23 changes: 23 additions & 0 deletions tictactoe_crystal/src/tictactoe_crystal.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# TODO: Write documentation for `TictactoeCrystal`
#
require "option_parser"

module TictactoeCrystal
VERSION = "0.1.0"

x_strength = nil
o_strength = nil
OptionParser.parse do |parser|
parser.banner = "Welcome to The Beatles App!"

parser.on "-x X", "--X-strength=X", "Strength of AI playing as X" do |x|
x_strength = x.to_i
end
parser.on "-o=O", "--O-strength=O", "Strength of AI playing as O" do |o|
o_strength = o.to_i
end
end
puts "Hello World"
puts typeof(x_strength), x_strength
puts typeof(o_strength), o_strength
end
Binary file added tictactoe_crystal/tictactoe_crystal.pdb
Binary file not shown.

0 comments on commit 1c994f6

Please sign in to comment.