-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from banan314/smart-view
dolar 1.2
- Loading branch information
Showing
69 changed files
with
2,824 additions
and
432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ src/test/scala/ | |
src/main/other/* | ||
|
||
/laughing-engine.iml | ||
/word count.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/out | ||
/.vscode | ||
.vstags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[role] | ||
player1 = white | ||
player2 = black | ||
|
||
[game] | ||
maxIndex = 9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
perl count.pl white > out/count/white | ||
perl count.pl black > out/count/black | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use warnings; | ||
|
||
use feature 'say'; | ||
|
||
my $player = shift; | ||
|
||
my $min; | ||
my $max; | ||
|
||
if ($player eq "black") { | ||
$min = 1; $max = 4; | ||
} elsif ($player eq "white") { | ||
$min = 6; $max=9; | ||
} else { | ||
die "wrong input! white or black"; | ||
} | ||
|
||
sub nextSquare { | ||
my ($x, $y) = @_; | ||
if ($x == $max) { | ||
$x = $min; | ||
$y++; | ||
} else { | ||
$x++; | ||
} | ||
return ($x, $y); | ||
} | ||
|
||
sub lastSquare { | ||
($x, $y) = @_; | ||
return $x==$max && $y==$max; | ||
} | ||
|
||
sub buildCount { | ||
($x, $y) = @_; | ||
my @nextCoordinates = nextSquare($x, $y); | ||
|
||
my $def = "<= (count $x $y ?num)"; | ||
my $checkCell = "(true (cell $x $y $player))"; | ||
my $succ = "\t(succ ?prevnum ?num)"; | ||
my $next = "\t(count $nextCoordinates[0] $nextCoordinates[1] ?prevnum)"; | ||
|
||
if (lastSquare($x, $y)) { | ||
return join "\n", ("("."<= (count $x $y 1)", "\t(true (cell $max $max $player))".")", "", | ||
"("."<= (count $x $y 0)", "\t(not (true (cell $max $max $player)))".")"); | ||
} else { | ||
my $pieceProp = join "\n", ("(".$def, "\t$checkCell", $succ, $next.")"); | ||
$next =~ s/prevnum/num/; #replace prevnum with num, cause we don't increment | ||
my $emptyProp = join "\n", ("(".$def, "\t(not ". $checkCell . ")", $next.")"); | ||
return join "\n", ($pieceProp, $emptyProp); | ||
} | ||
} | ||
|
||
my ($x, $y) = ($min, $min); | ||
do { | ||
say buildCount($x, $y) . "\n"; | ||
($x, $y) = nextSquare($x, $y); | ||
}until lastSquare($x, $y); | ||
say buildCount($x, $y) . "\n"; |
Oops, something went wrong.