int main(int argc, char** argv) { GoStone stone(GoPosition(1,1), GoColor::White) ; GoBoard board(9,9) ; assert(board.canPlaceStone(GoPosition(0,0), GoColor::Black)) ; board.placeStone(GoPosition(0,0), GoColor::Black) ; board.placeStone(GoPosition(0,1), GoColor::White) ; board.placeStone(GoPosition(0,2), GoColor::Black) ; board.placeStone(GoPosition(1,0), GoColor::White) ; board.placeStone(GoPosition(3,3), GoColor::Black) ; board.placeStone(GoPosition(1,1), GoColor::White) ; board.placeStone(GoPosition(4,4), GoColor::Black) ; board.placeStone(GoPosition(2,3), GoColor::White) ; board.placeStone(GoPosition(3,5), GoColor::Black) ; board.placeStone(GoPosition(2,5), GoColor::White) ; board.placeStone(GoPosition(2,4), GoColor::Black) ; board.placeStone(GoPosition(1,4), GoColor::White) ; board.placeStone(GoPosition(5,5), GoColor::Black) ; board.placeStone(GoPosition(3,4), GoColor::White) ; assert(!board.canPlaceStone(GoPosition(2,4), GoColor::Black)) ; assert(board.canTakeBack()) ; board.takeBackOneHand() ; board.debugPrintCurrentBoard() ; return 0 ; }
//----------------------------------------------------------------- bool Landslip::stoneModel(const Cube *model) { bool change = false; if (!isStoned(model)) { if (isFixed(model) || isOnPad(model)) { stone(model); change = true; } } return change; }
bool gib::get(go::data& data) const{ data.clear(); int hcapx1[] = {15, 3, 15, 3, 9}; int hcapx2[] = {15, 3, 15, 3, 15, 3, 9}; int hcapx3[] = {15, 3, 15, 3, 15, 3, 9, 9, 9}; int hcapy1[] = {3, 15, 15, 3, 9}; int hcapy2[] = {3, 15, 15, 3, 9, 9, 9}; int hcapy3[] = {3, 15, 15, 3, 9, 9, 15, 3, 9}; data.root->xsize = 19; data.root->ysize = 19; data.root->whitePlayer = whitePlayer; data.root->whiteRank = whiteRank; data.root->blackPlayer = blackPlayer; data.root->blackRank = blackRank; data.root->comment = comment; data.root->place = place; data.root->date = gameDate; data.root->gameName = gameName; data.root->result = result; data.root->annotation = condition; data.root->time = gameTime; if (handicap) data.root->komi = 0; data.root->handicap = handicap; for (int i=0; i<handicap; ++i){ if (handicap < 6) data.root->blackStones.push_back( stone(hcapx1[i], hcapy1[i], go::black) ); else if (handicap < 8) data.root->blackStones.push_back( stone(hcapx2[i], hcapy2[i], go::black) ); else data.root->blackStones.push_back( stone(hcapx3[i], hcapy3[i], go::black) ); } get(dataList_.begin(), dataList_.end(), go::nodePtr(data.root)); return true; }
bool ngf::get(go::data& data) const { data.clear(); int left = size > 9 ? 3 : 2; int right = size > 9 ? size-4 : size-3; int center = size / 2; int hcapx1[] = {right, left, right, left, center}; int hcapx2[] = {right, left, right, left, right, left, center}; int hcapx3[] = {right, left, right, left, right, left, center, center, center}; int hcapy1[] = {left, right, right, left, center}; int hcapy2[] = {left, right, right, left, center, center, center}; int hcapy3[] = {left, right, right, left, center, center, right, left, center}; data.root->xsize = size; data.root->ysize = size; data.root->whitePlayer = whitePlayer; data.root->blackPlayer = blackPlayer; data.root->date = gameDate; data.root->gameName = gameName; data.root->result = result; data.root->time = gameTime; if (handicap) data.root->komi = 0; data.root->handicap = handicap; int hcap = (size % 2 == 0 && handicap > 4) ? 4 : handicap; for (int i=0; i<hcap; ++i) { if (hcap < 6) data.root->blackStones.push_back( stone(hcapx1[i], hcapy1[i], go::black) ); else if (hcap < 8) data.root->blackStones.push_back( stone(hcapx2[i], hcapy2[i], go::black) ); else data.root->blackStones.push_back( stone(hcapx3[i], hcapy3[i], go::black) ); } get(dataList_.begin(), dataList_.end(), go::nodePtr(data.root)); return true; }
Stone AI::helpMe(Stone::E_COLOR color) { _color = color; Stone stone(-1, -1, color); initOpenTiles(); try { _playBeginTime = (float)clock(); stone = calc(2); } catch (const Exceptions& e) { } if (stone.x() == -1) throw Exceptions("AI CAN'T PLAY :(");//TODO : catch + haut std::cout << "AI help depth " << 2 << std::endl; return stone; }
Stone AI::plays() { Stone stone(-1, -1, _color); int depth = 1; initOpenTiles(); try { _playBeginTime = (float)clock(); while (true) { stone = calc(depth++); } } catch (const Exceptions& e) { depth -= 1; } if (stone.x() == -1) throw Exceptions("AI CAN'T PLAY :(");//TODO : catch + haut std::cout << "AI depth " << depth-1 << std::endl; return stone; }
int main(int argc, char** argv){ //ShowWindow(GetForegroundWindow(), SW_HIDE); Display display(WIDTH, HEIGHT, "OpenGL"); if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0){ std::cout << "ERROR: MixOpenAudio: " << Mix_GetError() << std::endl; } World world; Shader* shader = world.GetShader(); Brush br(24, 6, 24, &world, "./res/tex/pxl_cuboid.jpg"); br.Move(-2, 0, -2); Brush c1(1, 0.5, 3, &world, "./res/tex/pxl_cuboid.jpg"); c1.Move(2, 0, 2); Brush c2(1, 1.0, 3, &world, "./res/tex/pxl_cuboid.jpg"); c2.Move(3, 0, 2); Brush c3(1, 0.2, 1.5, &world, "./res/tex/pxl_cuboid.jpg"); c3.Move(6, 0.9, 2); Brush c4(1, 0.2, 1.5, &world, "./res/tex/pxl_cuboid.jpg"); c4.Move(6, 1.1, 3.5); Brush box(1, 1, 1, &world, "./res/tex/pxl_cuboid.jpg"); box.Move(6, 0.5, 6); Player player(shader); display.SetPlayer(player); Camera cammy; cammy.Init(glm::vec3(0, 0, 0), 70.0f, 1600 / 900, 0.01f, 1000.0f); Ambient amb1; shader->AddAmbient(&amb1); amb1.m_range = 3; amb1.m_intensity = 0.2; Ambient amb2; shader->AddAmbient(&amb2); amb2.SetPosition(1, 1, 1); Ambient amb3; shader->AddAmbient(&amb3); amb3.SetPosition(15, 1, 10); amb3.SetColor(0.2, 0.5, 0.7); Prop prop(world.GetMesh("./res/models/cucco.obj"), world.GetTexture("./res/models/cucco.jpg"), shader); world.AddProp(&prop); Prop stone(world.GetMesh("./res/models/salesman.obj"), world.GetTexture("./res/models/salesman.jpg"), shader); world.AddProp(&stone); stone.Scale(0.01); stone.Teleport(0, -10, 0); Sound laugh; laugh.Init("./res/sounds/sale_laugh.wav", 0.7); laugh.Load(); player.SetListener(Player_OnClick, OnClick); float count = 0.0f; while (!display.IsClosed()){ display.Clear(0.1f, 0.3f, 0.8f, 1.0f); world.Draw(&player.GetCamera()); player.DrawHUD(); display.Update(); laugh.Update(player.GetCamera().GetPos()); if (count >= 2 * PI){ count = 0; } count += 0.05f; c4.Rotate(0, 1, 0); if (glm::distance(prop.position, player.GetCamera().GetPos()) >= 2){ prop.velocity = (player.GetCamera().GetPos() - prop.position) / 64.0f; prop.velocity.y = 0; prop.SetRotate(0, PI / 2 - GetAngleRad(glm::vec2(0, 0), GetXZ(prop.velocity)), 0); } else{ prop.velocity *= 0; } prop.Rotate(0, sin(count) * PI / 360, 0); amb1.m_position = player.GetCamera().GetPos(); if (player.mouse_buttons[0]){//Left Clicking player.mouse_buttons[0] = false; stone.Teleport(world.GetAimPoint(&player)); stone.SetRotate(0, PI / 2 - GetAngleRad(glm::vec2(0, 0), GetXZ(player.GetCamera().GetPos() - stone.position)), 0); laugh.pos = stone.position; laugh.Emit(player.GetCamera().GetPos()); } world.Update(); player.Update(); world.IsCollide(&player); player.CommenceVelocity(); } Mix_CloseAudio(); Mix_Quit(); return 0; }
void LibOpenGL::init(int x, int y) { this->_x = x; this->_y = y; SDL_Init(SDL_INIT_VIDEO); SDL_WM_SetCaption("Nibbler", NULL); SDL_SetVideoMode(720, 520, 32, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_OPENGL); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60, 1.3, 1, 10000); glEnable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); Texture stone("Textures/stonebrick.bmp", 64, 64); Texture planks("Textures/planks_oak.bmp", 64, 64); Texture cake_top("Textures/cake_top.bmp", 64, 64); Texture cake_bottom("Textures/cake_bottom.bmp", 64, 64); Texture cake_side("Textures/cake_side.bmp", 64, 32); Texture body1("Textures/body1.bmp", 64, 64); Texture body2("Textures/stonebrick.bmp", 32, 64); Texture grass("Textures/grass.bmp", 64, 64); _tex["stone"]["top"].set(stone); _tex["stone"]["bottom"].set(stone); _tex["stone"]["front"].set(stone); _tex["stone"]["back"].set(stone); _tex["stone"]["left"].set(stone); _tex["stone"]["right"].set(stone); _tex["wood"]["top"].set(planks); _tex["wood"]["bottom"].set(planks); _tex["wood"]["front"].set(planks); _tex["wood"]["back"].set(planks); _tex["wood"]["left"].set(planks); _tex["wood"]["right"].set(planks); _tex["cake"]["top"].set(cake_top); _tex["cake"]["bottom"].set(cake_bottom); _tex["cake"]["front"].set(cake_side); _tex["cake"]["back"].set(cake_side); _tex["cake"]["left"].set(cake_side); _tex["cake"]["right"].set(cake_side); _tex["body1"]["top"].set(body1); _tex["body1"]["bottom"].set(body1); _tex["body1"]["front"].set(body1); _tex["body1"]["back"].set(body1); _tex["body1"]["left"].set(body1); _tex["body1"]["right"].set(body1); _tex["body2"]["top"].set(body2); _tex["body2"]["bottom"].set(body2); _tex["body2"]["front"].set(body2); _tex["body2"]["back"].set(body2); _tex["body2"]["left"].set(body2); _tex["body2"]["right"].set(body2); _tex["grass"]["top"].set(grass); _bg = glGenLists(1); glNewList(_bg, GL_COMPILE); this->draw_background(); glEndList(); }