Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 9ebceb46abe063c3cacff299e0750b608358b216 @iamjwc committed Oct 21, 2011
Showing with 974,786 additions and 0 deletions.
  1. BIN .DS_Store
  2. +127 −0 Archive.tar/2
  3. +344 −0 Archive.tar/AI.cpp
  4. +476 −0 Archive.tar/AI.scm
  5. +58 −0 Archive.tar/AI.scm~
  6. +200 −0 Archive.tar/AI2.scm
  7. BIN Archive.tar/a.out
  8. +7 −0 Archive.tar/plus.in
  9. BIN CalulatorLanguage/172.exe
  10. +3 −0 CalulatorLanguage/172.in
  11. BIN CalulatorLanguage/CalulatorLanguage.exe
  12. BIN CalulatorLanguage/CalulatorLanguage.ncb
  13. +20 −0 CalulatorLanguage/CalulatorLanguage.sln
  14. BIN CalulatorLanguage/CalulatorLanguage.suo
  15. +4 −0 CalulatorLanguage/CalulatorLanguage/172.in
  16. +4 −0 CalulatorLanguage/CalulatorLanguage/172.in~
  17. +197 −0 CalulatorLanguage/CalulatorLanguage/CalulatorLanguage.vcproj
  18. +65 −0 CalulatorLanguage/CalulatorLanguage/CalulatorLanguage.vcproj.COMPY.iamjwc.user
  19. BIN CalulatorLanguage/CalulatorLanguage/Debug/BuildLog.htm
  20. +8 −0 CalulatorLanguage/CalulatorLanguage/Debug/CalulatorLanguage.exe.embed.manifest
  21. BIN CalulatorLanguage/CalulatorLanguage/Debug/CalulatorLanguage.exe.embed.manifest.res
  22. +8 −0 CalulatorLanguage/CalulatorLanguage/Debug/CalulatorLanguage.exe.intermediate.manifest
  23. BIN CalulatorLanguage/CalulatorLanguage/Debug/main.obj
  24. +1 −0 CalulatorLanguage/CalulatorLanguage/Debug/mt.dep
  25. BIN CalulatorLanguage/CalulatorLanguage/Debug/vc80.idb
  26. BIN CalulatorLanguage/CalulatorLanguage/Debug/vc80.pdb
  27. BIN CalulatorLanguage/CalulatorLanguage/Release/BuildLog.htm
  28. +8 −0 CalulatorLanguage/CalulatorLanguage/Release/CalulatorLanguage.exe.intermediate.manifest
  29. BIN CalulatorLanguage/CalulatorLanguage/Release/main.obj
  30. +1 −0 CalulatorLanguage/CalulatorLanguage/Release/mt.dep
  31. BIN CalulatorLanguage/CalulatorLanguage/Release/vc80.idb
  32. BIN CalulatorLanguage/CalulatorLanguage/Release/vc80.pdb
  33. +217 −0 CalulatorLanguage/CalulatorLanguage/main.cpp
  34. BIN CalulatorLanguage/debug/CalulatorLanguage.exe
  35. BIN CalulatorLanguage/debug/CalulatorLanguage.ilk
  36. BIN CalulatorLanguage/debug/CalulatorLanguage.pdb
  37. BIN CalulatorLanguage/release/CalulatorLanguage.exe
  38. BIN CalulatorLanguage/release/CalulatorLanguage.pdb
  39. BIN NQueens/NQueens.ncb
  40. +20 −0 NQueens/NQueens.sln
  41. BIN NQueens/NQueens.suo
  42. BIN NQueens/NQueens/Debug/BuildLog.htm
  43. +8 −0 NQueens/NQueens/Debug/NQueens.exe.embed.manifest
  44. BIN NQueens/NQueens/Debug/NQueens.exe.embed.manifest.res
  45. +8 −0 NQueens/NQueens/Debug/NQueens.exe.intermediate.manifest
  46. BIN NQueens/NQueens/Debug/NQueens.obj
  47. +1 −0 NQueens/NQueens/Debug/mt.dep
  48. BIN NQueens/NQueens/Debug/vc80.idb
  49. BIN NQueens/NQueens/Debug/vc80.pdb
  50. +209 −0 NQueens/NQueens/NQueens.vcproj
  51. +65 −0 NQueens/NQueens/NQueens.vcproj.COMPY.iamjwc.user
  52. +159 −0 NQueens/NQueens/Nqueens.out
  53. BIN NQueens/debug/NQueens.exe
  54. BIN NQueens/debug/NQueens.ilk
  55. BIN NQueens/debug/NQueens.pdb
  56. +159 −0 NQueens/debug/Nqueens.out
  57. BIN PegGame1/PegGame1.ncb
  58. +20 −0 PegGame1/PegGame1.sln
  59. BIN PegGame1/PegGame1.suo
  60. +347 −0 PegGame1/PegGame1/AI.cpp
  61. BIN PegGame1/PegGame1/Debug/AI.obj
  62. BIN PegGame1/PegGame1/Debug/AI1.obj
  63. BIN PegGame1/PegGame1/Debug/BuildLog.htm
  64. +8 −0 PegGame1/PegGame1/Debug/PegGame1.exe.embed.manifest
  65. BIN PegGame1/PegGame1/Debug/PegGame1.exe.embed.manifest.res
  66. +8 −0 PegGame1/PegGame1/Debug/PegGame1.exe.intermediate.manifest
  67. +1 −0 PegGame1/PegGame1/Debug/mt.dep
  68. BIN PegGame1/PegGame1/Debug/vc80.idb
  69. BIN PegGame1/PegGame1/Debug/vc80.pdb
  70. BIN PegGame1/PegGame1/Peg.exe
  71. +215 −0 PegGame1/PegGame1/PegGame1.vcproj
  72. +65 −0 PegGame1/PegGame1/PegGame1.vcproj.COMPY.iamjwc.user
  73. +7 −0 PegGame1/PegGame1/cross.in
  74. +7 −0 PegGame1/PegGame1/diamond.in
  75. +969,992 −0 PegGame1/PegGame1/hey.txt
  76. +7 −0 PegGame1/PegGame1/no.in
  77. +7 −0 PegGame1/PegGame1/plus.in
  78. +7 −0 PegGame1/PegGame1/pyramid.in
  79. +7 −0 PegGame1/PegGame1/solitaire.in
  80. +7 −0 PegGame1/PegGame1/uparrow.in
  81. BIN PegGame1/debug/PegGame1.exe
  82. BIN PegGame1/debug/PegGame1.ilk
  83. BIN PegGame1/debug/PegGame1.pdb
  84. BIN PegGame2.zip
  85. +199 −0 PegGame2/PegGame1/AI.cpp
  86. +173 −0 PegGame2/PegGame1/Board.h
  87. +47 −0 PegGame2/PegGame1/BoardPtr.h
  88. +6 −0 PegGame2/PegGame1/Direction.h
  89. +235 −0 PegGame2/PegGame1/PegGame1.vcproj
  90. +65 −0 PegGame2/PegGame1/PegGame1.vcproj.COMPY.iamjwc.user
  91. +49 −0 PegGame2/PegGame1/Position.h
  92. +9 −0 PegGame2/PegGame1/bigDiamond.in
  93. +9 −0 PegGame2/PegGame1/bigFireplace.in
  94. +9 −0 PegGame2/PegGame1/bigPlus.in
  95. +9 −0 PegGame2/PegGame1/bigSolitaire.in
  96. +9 −0 PegGame2/PegGame1/bigUpArrow.in
  97. +9 −0 PegGame2/PegGame1/diamond.in
  98. +83 −0 PegGame2/PegGame1/iamjwc/IO.h
  99. +9 −0 PegGame2/PegGame1/solitaire.in
  100. +9 −0 PegGame2/PegGame1/uparrow.in
  101. +20 −0 PegGame2/PegGame2.sln
  102. BIN PegGame2/PegGame2.suo
  103. BIN Reversi/Interface/Back.bmp
  104. BIN Reversi/Interface/Black.bmp
  105. BIN Reversi/Interface/GrantB.exe
  106. BIN Reversi/Interface/Reversi.exe
  107. BIN Reversi/Interface/ReversiInterface.exe
  108. BIN Reversi/Interface/Thumbs.db
  109. BIN Reversi/Interface/White.bmp
  110. +1 −0 Reversi/Interface/board.txt
  111. BIN Reversi/Interface/dumb.exe
  112. BIN Reversi/Interface/dumber.exe
  113. BIN Reversi/Interface/grimw.exe
  114. BIN Reversi/Interface/guthriec.exe
  115. BIN Reversi/Interface/harringd.exe
  116. BIN Reversi/Interface/lamonica.exe
  117. +1 −0 Reversi/Interface/move.txt
  118. BIN Reversi/Interface/reversi.doc
  119. BIN Reversi/Interface/sample.exe
  120. BIN Reversi/Interface/yu.exe
  121. BIN Reversi/Reversi.ncb
  122. +20 −0 Reversi/Reversi.sln
  123. BIN Reversi/Reversi.suo
  124. +11 −0 Reversi/Reversi/Constants.h
  125. BIN Reversi/Reversi/Debug/BuildLog.htm
  126. +8 −0 Reversi/Reversi/Debug/Reversi.exe.embed.manifest
  127. BIN Reversi/Reversi/Debug/Reversi.exe.embed.manifest.res
  128. +8 −0 Reversi/Reversi/Debug/Reversi.exe.intermediate.manifest
  129. BIN Reversi/Reversi/Debug/main.obj
  130. +1 −0 Reversi/Reversi/Debug/mt.dep
  131. BIN Reversi/Reversi/Debug/vc80.idb
  132. BIN Reversi/Reversi/Debug/vc80.pdb
  133. +9 −0 Reversi/Reversi/Makefile
  134. +83 −0 Reversi/Reversi/Position.h
  135. +213 −0 Reversi/Reversi/Reversi.vcproj
  136. +65 −0 Reversi/Reversi/Reversi.vcproj.COMPY.iamjwc.user
  137. BIN Reversi/Reversi/Reversi.zip
  138. +178 −0 Reversi/Reversi/ReversiBoard.h
  139. BIN Reversi/Reversi/ReversiGame
  140. +1 −0 Reversi/Reversi/board.txt
  141. +62 −0 Reversi/Reversi/gamecomm.h
  142. +82 −0 Reversi/Reversi/main.cpp
  143. BIN Reversi/Reversi/main.o
  144. +1 −0 Reversi/Reversi/move.txt
  145. BIN Reversi/debug/Reversi.exe
  146. BIN Reversi/debug/Reversi.ilk
  147. BIN Reversi/debug/Reversi.pdb
  148. +11 −0 get_times.sh
Binary file not shown.
@@ -0,0 +1,127 @@
+#include <iostream>
+#include <list>
+
+using namespace std;
+
+enum Direction { UP, DOWN, LEFT, RIGHT };
+
+struct Board
+{
+ Board( bool init = true )
+ {
+ if( init )
+ for( int i = 0; i < 7; ++i )
+ for( int j = 0; j < 7; ++j )
+ this->board[i][j] = 0;
+ }
+
+ void copy( Board& b )
+ {
+ for( int i = 0; i < 7; ++i )
+ for( int j = 0; j < 7; ++j )
+ b.board[i][j] = this->board[i][j];
+ }
+
+ bool board[7][7];
+};
+
+ostream& operator<<( ostream& o, Board& b )
+{
+ for( int i = 0; i < 7; ++i )
+ {
+ for( int j = 0; j < 7; ++j )
+ o << b.board[i][j] << " ";
+
+ o << endl;
+ }
+}
+
+
+bool is_on_board( char row, char col )
+{
+ return
+ (
+ ((row >= 0 and row <= 1) and (col >= 2 and col <= 4))
+ or ((row >= 2 and row <= 4) and (col >= 0 and col <= 6))
+ or ((row >= 5 and row <= 6) and (col >= 2 and col <= 4))
+ );
+}
+
+bool is_open( char row, char col, const Board& b )
+{
+ return is_on_board( row, col ) && !b.board[row][col];
+}
+
+bool is_closed( char row, char col, const Board& b )
+{
+ return is_on_board( row, col ) && b.board[row][col];
+}
+
+void x_to_the( char x, Direction d, char& row, char& col )
+{
+ if( UP == d ) row -= x;
+ if( DOWN == d ) row += x;
+ if( LEFT == d ) col -= x;
+ if( RIGHT == d ) col += x;
+}
+
+bool can_jump( Direction d, char row, char col, const Board& board )
+{
+ char r = row, r2 = row, c = col, c2 = col;
+ x_to_the( 1, d, r, c );
+ x_to_the( 2, d, r2, c2 );
+
+ return( is_closed( row, col, board )
+ and is_closed( r, c, board )
+ and is_open( r2, c2, board ));
+}
+
+Board* jump( Direction d, char row, char col, const Board& b )
+{
+ Board* new_board = NULL;
+
+ if( can_jump( d, row, col, b ) )
+ {
+ char r = row, r2 = row, c = col, c2 = col;
+ x_to_the( 1, d, r, c );
+ x_to_the( 2, d, r2, c2 );
+
+ new_board = new Board(false);
+ b.copy(*new_board);
+
+ new_board->board[row][col] = 0;
+ new_board->board[r][c] = 0;
+ new_board->board[r2][c2] = 1;
+
+ }
+
+ return new_board;
+}
+
+Board** all_jumps_from_pos( char row, char col, const Board& b )
+{
+ Board** boards = new Board*[4];
+ boards[0] = jump( UP, row, col, b );
+ boards[1] = jump( DOWN, row, col, b );
+ b[2] = jump( LEFT, row, col, b );
+ b[3] = jump( RIGHT, row, col, b );
+
+ return boards;
+}
+
+int main()
+{
+ Board b;
+ b.board[3][3] = 1;
+ b.board[2][3] = 1;
+
+ Board* new_board = jump( UP, 3, 3, b );
+
+ cout << b;
+ cout << endl;
+ cout << *new_board;
+
+ delete new_board;
+
+ return 0;
+}
Oops, something went wrong.

0 comments on commit 9ebceb4

Please sign in to comment.