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 d2ca1a6
Show file tree
Hide file tree
Showing 13 changed files with 166 additions and 7 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_crystal
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
4 changes: 2 additions & 2 deletions .github/workflows/python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ jobs:
- name: Lint with ruff
uses: chartboost/ruff-action@v1
with:
version: 0.4.8
version: 0.5.0
- name: Typecheck with pyright
uses: jakebailey/pyright-action@v2
with:
version: 1.1.366
version: 1.1.370
working-directory: ./tictactoe_python
- name: Thorough check with pylint
run: pylint tictactoe/
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repos:
- id: check-builtin-literals
language: python
- repo: https://github.com/crate-ci/typos
rev: v1.22.0
rev: v1.22.9
hooks:
- id: typos
args: []
Expand All @@ -40,7 +40,7 @@ repos:
language: python
args: ["--write", "--check", "--output-style=google"]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.4.8
rev: v0.5.0
hooks:
- id: ruff
args:
Expand Down Expand Up @@ -70,7 +70,7 @@ repos:

# golang specific
- repo: https://github.com/golangci/golangci-lint
rev: v1.59.0
rev: v1.59.1
hooks:
- id: golangci-lint
entry: bash -c 'cd tictactoe_go && golangci-lint run --new-from-rev HEAD --fix'
Expand Down Expand Up @@ -171,7 +171,7 @@ repos:

# javascript specific
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v9.3.0
rev: v9.6.0
hooks:
- id: eslint
files: ^tictactoe_javascript/
Expand Down Expand Up @@ -233,7 +233,7 @@ repos:

# Perl specific
- repo: https://github.com/perltidy/perltidy
rev: "20240511.03"
rev: "20240511.04"
hooks:
- id: perltidy
files: ^tictactoe_perl/
Expand Down
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 <47750513+JanEricNitschke@users.noreply.github.com>

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 <47750513+JanEricNitschke@users.noreply.github.com>

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
34 changes: 34 additions & 0 deletions tictactoe_crystal/src/tictactoe_crystal.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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
parser.missing_option do |option_flag|
STDERR.puts "ERROR: #{option_flag} is missing something."
STDERR.puts ""
STDERR.puts parser
exit(1)
end
parser.invalid_option do |option_flag|
STDERR.puts "ERROR: #{option_flag} is not a valid option."
STDERR.puts parser
exit(1)
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 d2ca1a6

Please sign in to comment.