tic_tac_toe 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -5
- data/Gemfile.lock +2 -6
- data/Rakefile +4 -15
- data/bin/tic_tac_toe +9 -9
- data/lib/tic_tac_toe/version.rb +3 -0
- data/lib/tic_tac_toe.rb +2 -13
- data/spec/tic_tac_toe_spec.rb +1 -1
- data/tic_tac_toe.gemspec +10 -42
- metadata +11 -14
- data/VERSION +0 -1
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
bump (0.3.6)
|
4
5
|
diff-lcs (1.1.2)
|
5
|
-
git (1.2.5)
|
6
|
-
jeweler (1.5.2)
|
7
|
-
bundler (~> 1.0.0)
|
8
|
-
git (>= 1.2.5)
|
9
|
-
rake
|
10
6
|
rake (0.8.7)
|
11
7
|
rspec (2.3.0)
|
12
8
|
rspec-core (~> 2.3.0)
|
@@ -21,6 +17,6 @@ PLATFORMS
|
|
21
17
|
ruby
|
22
18
|
|
23
19
|
DEPENDENCIES
|
24
|
-
|
20
|
+
bump
|
25
21
|
rake
|
26
22
|
rspec (~> 2)
|
data/Rakefile
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require "bump/tasks"
|
4
|
+
|
1
5
|
task :default => :spec
|
2
6
|
require "rspec/core/rake_task"
|
3
7
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
@@ -7,18 +11,3 @@ end
|
|
7
11
|
task :run do
|
8
12
|
exec "./bin/tic_tac_toe"
|
9
13
|
end
|
10
|
-
|
11
|
-
begin
|
12
|
-
require 'jeweler'
|
13
|
-
Jeweler::Tasks.new do |gem|
|
14
|
-
gem.name = 'tic_tac_toe'
|
15
|
-
gem.summary = "Play Tic-Tac-Toe using Curses"
|
16
|
-
gem.email = "michael@grosser.it"
|
17
|
-
gem.homepage = "http://github.com/grosser/#{gem.name}"
|
18
|
-
gem.authors = ["Michael Grosser"]
|
19
|
-
end
|
20
|
-
|
21
|
-
Jeweler::GemcutterTasks.new
|
22
|
-
rescue LoadError
|
23
|
-
puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
|
24
|
-
end
|
data/bin/tic_tac_toe
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
require 'curses'
|
3
3
|
require File.expand_path('../../lib/tic_tac_toe', __FILE__)
|
4
4
|
|
5
|
-
|
5
|
+
STATUS_LINE = 10
|
6
6
|
|
7
|
-
def write(
|
8
|
-
Curses.setpos(
|
7
|
+
def write(line, column, text)
|
8
|
+
Curses.setpos(line, column)
|
9
9
|
Curses.addstr(text);
|
10
10
|
end
|
11
11
|
|
12
12
|
def init_screen
|
13
|
-
Curses.noecho
|
13
|
+
Curses.noecho # do not show typed keys
|
14
14
|
Curses.init_screen
|
15
|
-
Curses.stdscr.keypad(true)
|
15
|
+
Curses.stdscr.keypad(true) # enable arrow keys
|
16
16
|
begin
|
17
17
|
yield
|
18
18
|
ensure
|
@@ -23,16 +23,16 @@ end
|
|
23
23
|
def display(ttt)
|
24
24
|
write 0,0,ttt.board
|
25
25
|
if winner = ttt.winner
|
26
|
-
write(
|
26
|
+
write(STATUS_LINE, 0, "Player #{winner} has won!!!!")
|
27
27
|
elsif ttt.draw?
|
28
|
-
write(
|
28
|
+
write(STATUS_LINE, 0, "It is a draw...")
|
29
29
|
else
|
30
|
-
write(
|
30
|
+
write(STATUS_LINE, 0, "It is #{ttt.player}`s turn...")
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
init_screen do
|
35
|
-
write(
|
35
|
+
write(STATUS_LINE+1, 0, "q=Quit r=Reset a=AI-move")
|
36
36
|
|
37
37
|
ttt = TicTacToe.new
|
38
38
|
|
data/lib/tic_tac_toe.rb
CHANGED
@@ -1,17 +1,6 @@
|
|
1
|
-
|
2
|
-
def indexes(needle)
|
3
|
-
found = []
|
4
|
-
current_index = -1
|
5
|
-
while current_index = index(needle, current_index+1)
|
6
|
-
found << current_index
|
7
|
-
end
|
8
|
-
found
|
9
|
-
end
|
10
|
-
end
|
1
|
+
require 'tic_tac_toe/version'
|
11
2
|
|
12
3
|
class TicTacToe
|
13
|
-
VERSION = File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
|
14
|
-
|
15
4
|
BOARD = <<BOARD
|
16
5
|
-------------
|
17
6
|
| X | X | X |
|
@@ -119,4 +108,4 @@ BOARD
|
|
119
108
|
next_index = (current_index + 1) % PLAYERS.size
|
120
109
|
PLAYERS[next_index]
|
121
110
|
end
|
122
|
-
end
|
111
|
+
end
|
data/spec/tic_tac_toe_spec.rb
CHANGED
data/tic_tac_toe.gemspec
CHANGED
@@ -1,47 +1,15 @@
|
|
1
|
-
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
s.version = "0.2.0"
|
3
|
+
name = "tic_tac_toe"
|
4
|
+
require "#{name}/version"
|
9
5
|
|
10
|
-
|
6
|
+
Gem::Specification.new name, TicTacToe::VERSION do |s|
|
7
|
+
s.summary = "Play Tic-Tac-Toe using Curses"
|
8
|
+
s.email = "michael@grosser.it"
|
9
|
+
s.homepage = "http://github.com/grosser/#{name}"
|
11
10
|
s.authors = ["Michael Grosser"]
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
s.
|
15
|
-
s.executables = ["tic_tac_toe"]
|
16
|
-
s.files = [
|
17
|
-
"Gemfile",
|
18
|
-
"Gemfile.lock",
|
19
|
-
"Rakefile",
|
20
|
-
"Readme.md",
|
21
|
-
"VERSION",
|
22
|
-
"bin/tic_tac_toe",
|
23
|
-
"lib/tic_tac_toe.rb",
|
24
|
-
"spec/spec_helper.rb",
|
25
|
-
"spec/tic_tac_toe_spec.rb",
|
26
|
-
"tic_tac_toe.gemspec"
|
27
|
-
]
|
28
|
-
s.homepage = %q{http://github.com/grosser/tic_tac_toe}
|
29
|
-
s.require_paths = ["lib"]
|
30
|
-
s.rubygems_version = %q{1.3.7}
|
31
|
-
s.summary = %q{Play Tic-Tac-Toe using Curses}
|
32
|
-
s.test_files = [
|
33
|
-
"spec/spec_helper.rb",
|
34
|
-
"spec/tic_tac_toe_spec.rb"
|
35
|
-
]
|
36
|
-
|
37
|
-
if s.respond_to? :specification_version then
|
38
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
39
|
-
s.specification_version = 3
|
40
|
-
|
41
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
42
|
-
else
|
43
|
-
end
|
44
|
-
else
|
45
|
-
end
|
11
|
+
s.executables = [name]
|
12
|
+
s.files = `git ls-files`.split("\n")
|
13
|
+
s.license = "MIT"
|
46
14
|
end
|
47
15
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tic_tac_toe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 21
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Grosser
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
default_executable: tic_tac_toe
|
18
|
+
date: 2012-12-10 00:00:00 Z
|
20
19
|
dependencies: []
|
21
20
|
|
22
21
|
description:
|
@@ -32,16 +31,15 @@ files:
|
|
32
31
|
- Gemfile.lock
|
33
32
|
- Rakefile
|
34
33
|
- Readme.md
|
35
|
-
- VERSION
|
36
34
|
- bin/tic_tac_toe
|
37
35
|
- lib/tic_tac_toe.rb
|
36
|
+
- lib/tic_tac_toe/version.rb
|
38
37
|
- spec/spec_helper.rb
|
39
38
|
- spec/tic_tac_toe_spec.rb
|
40
39
|
- tic_tac_toe.gemspec
|
41
|
-
has_rdoc: true
|
42
40
|
homepage: http://github.com/grosser/tic_tac_toe
|
43
|
-
licenses:
|
44
|
-
|
41
|
+
licenses:
|
42
|
+
- MIT
|
45
43
|
post_install_message:
|
46
44
|
rdoc_options: []
|
47
45
|
|
@@ -68,10 +66,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
66
|
requirements: []
|
69
67
|
|
70
68
|
rubyforge_project:
|
71
|
-
rubygems_version: 1.
|
69
|
+
rubygems_version: 1.8.24
|
72
70
|
signing_key:
|
73
71
|
specification_version: 3
|
74
72
|
summary: Play Tic-Tac-Toe using Curses
|
75
|
-
test_files:
|
76
|
-
|
77
|
-
- spec/tic_tac_toe_spec.rb
|
73
|
+
test_files: []
|
74
|
+
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.2.0
|