Search Results

Search found 90 results on 4 pages for 'tic'.

Page 1/4 | 1 2 3 4  | Next Page >

  • La búsqueda de la eficiencia como Santo Grial de las TIC sanitarias

    - by Eloy M. Rodríguez
    Las XVIII Jornadas de Informática Sanitaria en Andalucía se han cerrado el pasado viernes con 11.500 horas de inteligencia colectiva. Aunque el cálculo supongo que resulta de multiplicar las horas de sesiones y talleres por el número de inscritos, lo que no sería del todo real ya que la asistencia media calculo que andaría por las noventa personas, supongo que refleja el global si incluimos el montante de interacciones informales que el formato y lugar de celebración favorecen. Mi resumen subjetivo es que todos somos conscientes de que debemos conseguir más eficiencia en y gracias a las TIC y que para ello hemos señalado algunas pautas, que los asistentes, en sus diferentes roles debiéramos aplicar y ayudar a difundir. En esa línea creo que destaca la necesidad de tener muy claro de dónde se parte y qué se quiere conseguir, para lo que es imprescindible medir y que las medidas ayuden a retroalimentar al sistema en orden de conseguir sus objetivos. Y en este sentido, a nivel anecdótico, quisiera dejar una paradoja que se presentó sobre la eficiencia: partiendo de que el coste/día de hospitalización es mayor al principio que los últimos días de la estancia, si se consigue ser más eficiente y reducir la estancia media, se liberarán últimos días de estancia que se utilizarán para nuevos ingresos, lo que hará que el número de primeros días de estancia aumente el coste económico total. En este caso mejoraríamos el servicio a los ciudadanos pero aumentaríamos el coste, salvo que se tomasen acciones para redimensionar la oferta hospitalaria bajando el coste y sin mejorer la calidad. También fue tema destacado la posibilidad/necesidad de aprovechar las capacidades de las TIC para realizar cambios estructurales y hacer que la medicina pase de ser reactiva a proactiva mediante alarmas que facilitasen que se actuase antes de ocurra el problema grave. Otro tema que se trató fue la necesidad real de corresponsabilizar de verdad al ciudadano, gracias a las enormes posibilidades a bajo coste que ofrecen las TIC, asumiendo un proceso hacia la salud colaborativa que tiene muchos retos por delante pero también muchas más oportunidades. Y la carpeta del ciudadano, emergente en varios proyectos e ideas, es un paso en ese aspecto. Un tema que levantó pasiones fue cuando la Directora Gerente del Sergas se quejó de que los proyectos TIC eran lentísimos. Desgraciadamente su agenda no le permitió quedarse al debate que fue bastante intenso en el que salieron temas como el larguísimo proceso administrativo, las especificaciones cambiantes, los diseños a medida, etc como factores más allá de la eficiencia especifica de los profesionales TIC involucrados en los proyectos. Y por último quiero citar un tema muy interesante en línea con lo hablado en las jornadas sobre la necesidad de medir: el Índice SEIS. La idea es definir una serie de criterios agrupados en grandes líneas y con un desglose fino que monitorice la aportación de las TIC en la mejora de la salud y la sanidad. Nos presentaron unas versiones previas con debate aún abierto entre dos grandes enfoques, partiendo desde los grandes objetivos hasta los procesos o partiendo desde los procesos hasta los objetivos. La discusión no es sólo académica, ya que influye en los parámetros a establecer. La buena noticia es que está bastante avanzado el trabajo y que pronto los servicios de salud podrán tener una herramienta de comparación basada en la realidad nacional. Para los interesados, varios asistentes hemos ido tuiteando las jornadas, por lo que el que quiera conocer un poco más detalles puede ir a Twitter y buscar la etiqueta #jisa18 y empezando del más antiguo al más moderno se puede hacer un seguimiento con puntos de vista subjetivos sobre lo allí ocurrido. No puedo dejar de hacer un par de autocríticas, ya que soy miembro de la SEIS. La primera es sobre el portal de la SEIS que no ha tenido la interactividad que unas jornadas como estas necesitaban. Pronto empezará a tener documentos y análisis de lo allí ocurrido y luego vendrán las crónicas y análisis más cocinados en la revista I+S. Pero en la segunda década del siglo XXI se necesita bastante más. La otra es sobre la no deseada poca presencia de usuarios de las TIC sanitarias en los roles de profesionales sanitarios y ciudadanos usuarios de los sistemas de información sanitarios. Tenemos que ser proactivos para que acudan en número significativo, ya que si no estamos en riesgo de ser unos TIC-sanitarios absolutistas: todo para los usuarios pero sin los usuarios. Tweet

    Read the article

  • Code Golf: Tic Tac Toe

    - by Aistina
    Post your shortest code, by character count, to check if a player has won, and if so, which. Assume you have an integer array in a variable b (board), which holds the Tic Tac Toe board, and the moves of the players where: 0 = nothing set 1 = player 1 (X) 2 = player 2 (O) So, given the array b = [ 1, 2, 1, 0, 1, 2, 1, 0, 2 ] would represent the board X|O|X -+-+- |X|O -+-+- X| |O For that situation, your code should output 1 to indicate player 1 has won. If no-one has won you can output 0 or false. My own (Ruby) solution will be up soon. Edit: Sorry, forgot to mark it as community wiki. You can assume the input is well formed and does not have to be error checked. Update: Please post your solution in the form of a function. Most people have done this already, but some haven't, which isn't entirely fair. The board is supplied to your function as the parameter. The result should be returned by the function. The function can have a name of your choosing.

    Read the article

  • Ideas for extending tic-tac-toe game?

    - by pimvdb
    I'm building a 3D tic-tac-toe game and this is what I've implemented so far: 3D renderer with texture mapping Playing against the computer Playing online (multiplayer) Now I'm a little lost what I could add. Obviously, tic-tac-toe isn't that exciting or advanced, but I just miss something to salt it a little bit. Therefore, could anyone please suggest some ideas that would be worth implementing? Thanks!

    Read the article

  • tic tac toe in pascal --> a problem occurred

    - by Emese
    I don't know why my program doesn't run. I would really appreciate your help. Here's my program: USES graph,crt; type tegla=record x,y:integer; ertek:0..2; end; var gd,gm:integer; i,j:integer; c:char; jatekos:integer; a:array[1..3,1..3]of tegla; lx,ly:integer; procedure tabla; var x,y,i,j:integer; begin lx:=getmaxx div 3; ly:=getmaxy div 3; for i:=1 to 3 do begin y:=(i-1)*ly; for j:=1 to 3 do begin x:=(j-1)*lx; a[i,j].x:=x; a[i,j].y:=y; a[i,j].ertek:=0; setbkcolor(10); setcolor(9); rectangle(a[i,j].x,a[i,j].y,a[i,j].x+lx,a[i,j].y+ly); end; end; end; procedure aktival(i,j:integer); begin setcolor(red); rectangle(a[i,j].x,a[i,j].y,a[i,j].x+lx,a[i,j].y+ly); end; procedure visszaallit(i,j:integer); begin setcolor(9); rectangle(a[i,j].x,a[i,j].y,a[i,j].x+lx,a[i,j].y+ly); end; procedure rajzolx(i,j:integer); begin setcolor(5); line(a[i,j].x,a[i,j].y,a[i,j].x+lx,a[i,j].y+ly); line(a[i,j].x+lx,a[i,j].y,a[i,j].x,a[i,j].y+ly); end; procedure rajzol_0(i,j:integer); begin setcolor(13); circle(a[i,j].x+lx div 2, a[i,j].y+ly div 2, 50); end; procedure kinyer(i,j:integer); begin jatekos:=1; if a[1,1]=a[2,2] and a[3,3]=a[1,1] and a[2,2]=a[3,3] or a[3,1]=a[2,2] and a[1,3]=a[3,1] and a[1,3]=a[2,2] then if jatekos then begin cleardevice; writeln('x nyert!'); end else if jatekos+1 then begin cleardevice; writeln('O nyert!'); end else for i:=1 to 3 do begin if a[i,1]=a[i,2] and a[i,1]=a[i,3] and a[i,2]=a[i,3] or a[1,i]=a[2,i] and a[1,i]=a[3,i] and a[2,i]=a[3,i] then if jatekos then begin cleardevice; writeln('x nyert'); end else if jatekos+1 then begin cleardevice; writeln('O nyert!'); end; end; Begin initgraph(gd,gm,' '); tabla; jatekos:=1; i:=2; j:=2; aktival(i,j); repeat c:=readkey; if ord(c)=0 then begin c:=readkey; case ord(c)of 72: if i>1 then begin visszaallit(i,j); dec(i); aktival(i,j);end; 77:if j<3 then begin visszaallit(i,j); inc(j); aktival(i,j); end; 80:if i<3 then begin visszaallit(i,j); inc(i); aktival(i,j); end; 75:if j>1 then begin visszaallit(i,j); dec(j); aktival(i,j); end; end; end; if ord(c)=13 then begin if a[i,j].ertek=0 then if jatekos=1 then begin rajzolx(i,j); a[i,j].ertek:=1; jatekos:=2; end else begin rajzol_0(i,j); a[i,j].ertek:=2; jatekos:=1; end; end; until ord(c)=27; kinyer(i,j); end; end. I hope you can help me. Thank you a lot!

    Read the article

  • tic tac toe in pascal --> a problem occured

    - by Emese
    I don't know why my program doesn't run. I would really appreciate your help. here's my program: USES graph,crt; type tegla=record x,y:integer; ertek:0..2; end; var gd,gm:integer; i,j:integer; c:char; jatekos:integer; a:array[1..3,1..3]of tegla; lx,ly:integer; procedure tabla; var x,y,i,j:integer; begin lx:=getmaxx div 3; ly:=getmaxy div 3; for i:=1 to 3 do begin y:=(i-1)*ly; for j:=1 to 3 do begin x:=(j-1)*lx; a[i,j].x:=x; a[i,j].y:=y; a[i,j].ertek:=0; setbkcolor(10); setcolor(9); rectangle(a[i,j].x,a[i,j].y,a[i,j].x+lx,a[i,j].y+ly); end; end; end; procedure aktival(i,j:integer); begin setcolor(red); rectangle(a[i,j].x,a[i,j].y,a[i,j].x+lx,a[i,j].y+ly); end; procedure visszaallit(i,j:integer); begin setcolor(9); rectangle(a[i,j].x,a[i,j].y,a[i,j].x+lx,a[i,j].y+ly); end; procedure rajzolx(i,j:integer); begin setcolor(5); line(a[i,j].x,a[i,j].y,a[i,j].x+lx,a[i,j].y+ly); line(a[i,j].x+lx,a[i,j].y,a[i,j].x,a[i,j].y+ly); end; procedure rajzol_0(i,j:integer); begin setcolor(13); circle(a[i,j].x+lx div 2, a[i,j].y+ly div 2, 50); end; procedure kinyer(i,j:integer); begin jatekos:=1; if a[1,1]=a[2,2] and a[3,3]=a[1,1] and a[2,2]=a[3,3] or a[3,1]=a[2,2] and a[1,3]=a[3,1] and a[1,3]=a[2,2] then if jatekos then begin cleardevice; writeln('x nyert!'); end else if jatekos+1 then begin cleardevice; writeln('O nyert!'); end else for i:=1 to 3 do begin if a[i,1]=a[i,2] and a[i,1]=a[i,3] and a[i,2]=a[i,3] or a[1,i]=a[2,i] and a[1,i]=a[3,i] and a[2,i]=a[3,i] then if jatekos then begin cleardevice; writeln('x nyert'); end else if jatekos+1 then begin cleardevice; writeln('O nyert!'); end; end; Begin initgraph(gd,gm,' '); tabla; jatekos:=1; i:=2; j:=2; aktival(i,j); repeat c:=readkey; if ord(c)=0 then begin c:=readkey; case ord(c)of 72: if i>1 then begin visszaallit(i,j); dec(i); aktival(i,j);end; 77:if j<3 then begin visszaallit(i,j); inc(j); aktival(i,j); end; 80:if i<3 then begin visszaallit(i,j); inc(i); aktival(i,j); end; 75:if j>1 then begin visszaallit(i,j); dec(j); aktival(i,j); end; end; end; if ord(c)=13 then begin if a[i,j].ertek=0 then if jatekos=1 then begin rajzolx(i,j); a[i,j].ertek:=1; jatekos:=2; end else begin rajzol_0(i,j); a[i,j].ertek:=2; jatekos:=1; end; end; until ord(c)=27; kinyer(i,j); end; end. I hope you can help me. Thank you a lot!

    Read the article

  • tic tac toe game ai as3

    - by David Jones
    I'm looking into creating a simple tic tac toe/noughts and crosses game in actionscript3 and am trying to understand the ideas behind the ai used in a game like this. I've seen some simplistic examples online but from what I've read a game tree or something like minimax is the best way to go about this. Can anyone help explain or reference any good examples of this? I've seen that there is a library called as3ds - data structures for game developers which has a number of classes that might help tie this together? Any info/examples or help is much appreciated

    Read the article

  • Tic-Tac-Toe game AI

    - by David Jones
    I'm looking into creating a simple tic tac toe/noughts and crosses game in Actionscript3 and am trying to understand the ideas behind the AI used in a game like this. I've seen some simplistic examples online but from what I've read a game tree or something like minimax is the best way to go about this. Can anyone help explain or reference any good examples of this? I've seen that there is a library called as3ds - data structures for game developers which has a number of classes that might help tie this together? Any info/examples or help is much appreciated.

    Read the article

  • Ruby: implementing alpha-beta pruning for tic-tac-toe

    - by DerNalia
    So, alpha-beta pruning seems to be the most efficient algorithm out there aside from hard coding (for tic tac toe). However, I'm having problems converting the algorithm from the C++ example given in the link: http://www.webkinesia.com/games/gametree.php #based off http://www.webkinesia.com/games/gametree.php # (converted from C++ code from the alpha - beta pruning section) # returns 0 if draw LOSS = -1 DRAW = 0 WIN = 1 @next_move = 0 def calculate_ai_next_move score = self.get_best_move(COMPUTER, WIN, LOSS) return @next_move end def get_best_move(player, alpha, beta) best_score = nil score = nil if not self.has_available_moves? return false elsif self.has_this_player_won?(player) return WIN elsif self.has_this_player_won?(1 - player) return LOSS else best_score = alpha NUM_SQUARES.times do |square| if best_score >= beta break end if self.state[square].nil? self.make_move_with_index(square, player) # set to negative of opponent's best move; we only need the returned score; # the returned move is irrelevant. score = -get_best_move(1-player, -beta, -alpha) if (score > bestScore) @next_move = square best_score = score end undo_move(square) end end end return best_score end the problem is that this is returning nil. some support methods that are used above: WAYS_TO_WIN = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8],[0, 4, 8], [2, 4, 6]] def has_this_player_won?(player) result = false WAYS_TO_WIN.each {|solution| result = self.state[solution[0]] if contains_win?(solution) } return (result == player) end def contains_win?(ttt_win_state) ttt_win_state.each do |pos| return false if self.state[pos] != self.state[ttt_win_state[0]] or self.state[pos].nil? end return true end def make_move(x, y, player) self.set_square(x,y, player) end

    Read the article

  • Having to check collisions twice per game tic

    - by user22241
    I have vertically moving elevators (3 solid tiles wide) and static solid tiles. Each are separate entities and therefore have their own respective collision routines (to check for, and resolve, collisions with the main character) I check my vertical collisions after characters vertical movements and then horizontal collisions after horizontal movements. The problem is that I want my platform to kill the player if it squashes him from the top, and also if he's on a moving platform (that is moving up) that squashes him into a solid block. Correct behaviour, player on solid blocks being squashed from above by decending elevator Here is what happens. Gravity pushes character into solid block, solid block collision routine corrects characters position and sits him on the solid block which pushes him into the moving elevator, elevator routine then checks for collision and kills player. This assumes I am checking solid blocks first, then elevator collisions. However, if it's the other way around, this happens.... Incorrect behaviour, player on accending elevator gets pushed into solid blocks above Player is on an elevator moving up, gravity pushes him into the elevator, solid block CD routine detects no collision, no action taken. Elevator CD routine detects character has been pushed into elevator by gravity, corrects this by moving character up and sitting him on the elevator and pushes him into the solid blocks above, however the solid block vertical routine has now already run for this tic, so the game continues and the next solid block collision that is encountered is the horizontal routine. This detects a collision and moves the character out of the collision to the left or right of the block which looks odd to say the least (character should get killed here). The only way I've managed to get this working correctly is by running the solid block CD, then the elevator CD, then the solid block CD again straight after. This is clearly wasteful but I can't figure out how else to do this. Any help would be appreciated.

    Read the article

  • Making the domain-model of tic tac toe

    - by devoured elysium
    I am trying to make the domain model of a Tic Tac Toe game. I'll try then to go on through the various steps of the Unified Process and later implement it in some language (C# or Java). I'd like to have some feedback if I'm going on the right path: I've defined the game with two actors, Player O and Player X. I'm not sure about defining both a Tile and a Tile State. Maybe I should only define a Tile and have the 3 possible states specialize from it? I'm not sure what is best: to have both Player O and Player X be associations with Tic Tac Toe or have them inherit from Player that is associated with Tic Tac Toe. Following the design shown on the pic, in theory we could have a Tic Tac Toe concept with 2 Player O's, which wouldn't be correct. What is your opinion on this? Also, am I missing something in the diagram? Although I can't see any other actors for Tic Tac Toe, should I have any other? Thanks

    Read the article

  • Tic Tac Toe Winner in Javascript and html [closed]

    - by Yehuda G
    I am writing a tic tac toe game using html, css, and JavaScript. I have my JavaScript in an external .js file being referenced into the .html file. Within the .js file, I have a function called playerMove, which allows the player to make his/her move and switches between player 'x' and 'o'. What I am trying to do is determine the winner. Here is what I have: each square, when onclick(this), references playerMove(piece). After each move is made, I want to run an if statement to check for the winner, but am unsure if the parameters would include a reference to 'piece' or a,b, and c. Any suggestions would be greatly appreciated. Javascript: var turn = 0; a = document.getElementById("topLeftSquare").innerHTML; b = document.getElementById("topMiddleSquare").innerHTML; c = document.getElementById("topRightSquare").innerHTML; function playerMove(piece) { var win; if(piece.innerHTML != 'X' && piece.innerHTML != 'O'){ if(turn % 2 == 0){ document.getElementById('playerDisplay').innerHTML= "X Plays " + printEquation(1); piece.innerHTML = 'X'; window.setInterval("X", 10000) piece.style.color = "red"; if(piece.innerHTML == 'X') window.alert("X WINS!"); } else { document.getElementById('playerDisplay').innerHTML= "O Plays " + printEquation(1); piece.innerHTML = 'O'; piece.style.color = "brown"; } turn+=1; } html: <div id="board"> <div class="topLeftSquare" onclick="playerMove(this)"> </div> <div class="topMiddleSquare" onclick="playerMove(this)"> </div> <div class="topRightSquare" onclick="playerMove(this)"> </div> <div class="middleLeftSquare" onclick="playerMove(this)"> </div> <div class="middleSquare" onclick="playerMove(this)"> </div> <div class="middleRightSquare" onclick="playerMove(this)"> </div> <div class="bottomLeftSquare" onclick="playerMove(this)"> </div> <div class="bottomMiddleSquare" onclick="playerMove(this)"> </div> <div class="bottomRightSquare" onclick="playerMove(this)"> </div> </div>

    Read the article

  • Negamax implementation doesn't appear to work with tic-tac-toe

    - by George Jiglau
    I've implemented Negamax as it can be found on wikipedia, which includes alpha/beta pruning. However, it seems to favor a losing move, which should be an invalid result. The game is Tic-Tac-Toe, I've abstracted most of the game play so it should be rather easy to spot an error within the algorithm. Here is the code, nextMove, negamax or evaluate are probably the functions that contain the fault: #include <list> #include <climits> #include <iostream> //#define DEBUG 1 using namespace std; struct Move { int row, col; Move(int row, int col) : row(row), col(col) { } Move(const Move& m) { row = m.row; col = m.col; } }; struct Board { char player; char opponent; char board[3][3]; Board() { } void read(istream& stream) { stream >> player; opponent = player == 'X' ? 'O' : 'X'; for(int row = 0; row < 3; row++) { for(int col = 0; col < 3; col++) { char playa; stream >> playa; board[row][col] = playa == '_' ? 0 : playa == player ? 1 : -1; } } } void print(ostream& stream) { for(int row = 0; row < 3; row++) { for(int col = 0; col < 3; col++) { switch(board[row][col]) { case -1: stream << opponent; break; case 0: stream << '_'; break; case 1: stream << player; break; } } stream << endl; } } void do_move(const Move& move, int player) { board[move.row][move.col] = player; } void undo_move(const Move& move) { board[move.row][move.col] = 0; } bool isWon() { if (board[0][0] != 0) { if (board[0][0] == board[0][1] && board[0][1] == board[0][2]) return true; if (board[0][0] == board[1][0] && board[1][0] == board[2][0]) return true; } if (board[2][2] != 0) { if (board[2][0] == board[2][1] && board[2][1] == board[2][2]) return true; if (board[0][2] == board[1][2] && board[1][2] == board[2][2]) return true; } if (board[1][1] != 0) { if (board[0][1] == board[1][1] && board[1][1] == board[2][1]) return true; if (board[1][0] == board[1][1] && board[1][1] == board[1][2]) return true; if (board[0][0] == board[1][1] && board[1][1] == board[2][2]) return true; if (board[0][2] == board [1][1] && board[1][1] == board[2][0]) return true; } return false; } list<Move> getMoves() { list<Move> moveList; for(int row = 0; row < 3; row++) for(int col = 0; col < 3; col++) if (board[row][col] == 0) moveList.push_back(Move(row, col)); return moveList; } }; ostream& operator<< (ostream& stream, Board& board) { board.print(stream); return stream; } istream& operator>> (istream& stream, Board& board) { board.read(stream); return stream; } int evaluate(Board& board) { int score = board.isWon() ? 100 : 0; for(int row = 0; row < 3; row++) for(int col = 0; col < 3; col++) if (board.board[row][col] == 0) score += 1; return score; } int negamax(Board& board, int depth, int player, int alpha, int beta) { if (board.isWon() || depth <= 0) { #if DEBUG > 1 cout << "Found winner board at depth " << depth << endl; cout << board << endl; #endif return player * evaluate(board); } list<Move> allMoves = board.getMoves(); if (allMoves.size() == 0) return player * evaluate(board); for(list<Move>::iterator it = allMoves.begin(); it != allMoves.end(); it++) { board.do_move(*it, -player); int val = -negamax(board, depth - 1, -player, -beta, -alpha); board.undo_move(*it); if (val >= beta) return val; if (val > alpha) alpha = val; } return alpha; } void nextMove(Board& board) { list<Move> allMoves = board.getMoves(); Move* bestMove = NULL; int bestScore = INT_MIN; for(list<Move>::iterator it = allMoves.begin(); it != allMoves.end(); it++) { board.do_move(*it, 1); int score = -negamax(board, 100, 1, INT_MIN + 1, INT_MAX); board.undo_move(*it); #if DEBUG cout << it->row << ' ' << it->col << " = " << score << endl; #endif if (score > bestScore) { bestMove = &*it; bestScore = score; } } if (!bestMove) return; cout << bestMove->row << ' ' << bestMove->col << endl; #if DEBUG board.do_move(*bestMove, 1); cout << board; #endif } int main() { Board board; cin >> board; #if DEBUG cout << "Starting board:" << endl; cout << board; #endif nextMove(board); return 0; } Giving this input: O X__ ___ ___ The algorithm chooses to place a piece at 0, 1, causing a guaranteed loss, do to this trap(nothing can be done to win or end in a draw): XO_ X__ ___ Perhaps it has something to do with the evaluation function? If so, how could I fix it?

    Read the article

  • Zedgraph - determine length of tic on an axis ?

    - by southof40
    In Zedgraph building a line chart. I have some requirements for axes labels which can't be produced automatically so inspired by this other Stackoverflow answer I'm building a custom axis. I can draw the Axis OK and I can place the labels but I want to draw my own tics. To do this I'd like to know the colour/pen width/size etc of the tics on the other axes. Determining the colour and pen width are no problem but finding out the length of a tic is difficult (I mean how long is it drawn away from the axis). I'm using a LineObj to draw the custom tics but I can't figure out how to long to draw them to match other non-custom tics . Does anyone know where this is defined (or have a smarter way of drawing your own tics than using LineObjs ?)

    Read the article

  • Representing game states in Tic Tac Toe

    - by dacman
    The goal of the assignment that I'm currently working on for my Data Structures class is to create a of Quantum Tic Tac Toe with an AI that plays to win. Currently, I'm having a bit of trouble finding the most efficient way to represent states. Overview of current Structure: AbstractGame Has and manages AbstractPlayers (game.nextPlayer() returns next player by int ID) Has and intializes AbstractBoard at the beginning of the game Has a GameTree (Complete if called in initialization, incomplete otherwise) AbstractBoard Has a State, a Dimension, and a Parent Game Is a mediator between Player and State, (Translates States from collections of rows to a Point representation Is a StateConsumer AbstractPlayer Is a State Producer Has a ConcreteEvaluationStrategy to evaluate the current board StateTransveralPool Precomputes possible transversals of "3-states". Stores them in a HashMap, where the Set contains nextStates for a given "3-state" State Contains 3 Sets -- a Set of X-Moves, O-Moves, and the Board Each Integer in the set is a Row. These Integer values can be used to get the next row-state from the StateTransversalPool SO, the principle is Each row can be represented by the binary numbers 000-111, where 0 implies an open space and 1 implies a closed space. So, for an incomplete TTT board: From the Set<Integer> board perspective: X_X R1 might be: 101 OO_ R2 might be: 110 X_X R3 might be: 101, where 1 is an open space, and 0 is a closed space From the Set<Integer> xMoves perspective: X_X R1 might be: 101 OO_ R2 might be: 000 X_X R3 might be: 101, where 1 is an X and 0 is not From the Set<Integer> oMoves perspective: X_X R1 might be: 000 OO_ R2 might be: 110 X_X R3 might be: 000, where 1 is an O and 0 is not Then we see that x{R1,R2,R3} & o{R1,R2,R3} = board{R1,R2,R3} The problem is quickly generating next states for the GameTree. If I have player Max (x) with board{R1,R2,R3}, then getting the next row-states for R1, R2, and R3 is simple.. Set<Integer> R1nextStates = StateTransversalPool.get(R1); The problem is that I have to combine each one of those states with R1 and R2. Is there a better data structure besides Set that I could use? Is there a more efficient approach in general? I've also found Point<-State mediation cumbersome. Is there another approach that I could try there? Thanks! Here is the code for my ConcretePlayer class. It might help explain how players produce new states via moves, using the StateProducer (which might need to become StateFactory or StateBuilder). public class ConcretePlayerGeneric extends AbstractPlayer { @Override public BinaryState makeMove() { // Given a move and the current state, produce a new state Point playerMove = super.strategy.evaluate(this); BinaryState currentState = super.getInGame().getBoard().getState(); return StateProducer.getState(this, playerMove, currentState); } } EDIT: I'm starting with normal TTT and moving to Quantum TTT. Given the framework, it should be as simple as creating several new Concrete classes and tweaking some things.

    Read the article

  • What's the best/most efficent way to create a semi-intelligent AI for a tic tac toe game?

    - by Link
    basically I am attempting to make a a efficient/smallish C game of Tic-Tac-Toe. I have implemented everything other then the AI for the computer so far. my squares are basically structs in an array with an assigned value based on the square. For example s[1].value = 1; therefore it's a x, and then a value of 3 would be a o. My question is whats the best way to create a semi-decent game playing AI for my tic-tac-toe game? I don't really want to use minimax, since It's not what I need. So how do I avoid a a lot of if statments and make it more efficient. Here is the rest of my code: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> struct state{ // defined int state; // 0 is tie, 1 is user loss, 2 is user win, 3 is ongoing game int moves; }; struct square{ // one square of the board int value; // 1 is x, 3 is o char sign; // no space used }; struct square s[9]; //set up the struct struct state gamestate = {0,0}; //nothing void setUpGame(){ // setup the game int i = 0; for(i = 0; i < 9; i++){ s[i].value = 0; s[i].sign = ' '; } gamestate.moves=0; printf("\nHi user! You're \"x\"! I'm \"o\"! Good Luck :)\n"); } void displayBoard(){// displays the game board printf("\n %c | %c | %c\n", s[6].sign, s[7].sign, s[8].sign); printf("-----------\n"); printf(" %c | %c | %c\n", s[3].sign, s[4].sign, s[5].sign); printf("-----------\n"); printf(" %c | %c | %c\n\n", s[0].sign, s[1].sign, s[2].sign); } void getHumanMove(){ // get move from human int i; while(1){ printf(">>:"); char line[255]; // input the move to play fgets(line, sizeof(line), stdin); while(sscanf(line, "%d", &i) != 1) { //1 match of defined specifier on input line printf("Sorry, that's not a valid move!\n"); fgets(line, sizeof(line), stdin); } if(s[i-1].value != 0){printf("Sorry, That moves already been taken!\n\n");continue;} break; } s[i-1].value = 1; s[i-1].sign = 'x'; gamestate.moves++; } int sum(int x, int y, int z){return(x*y*z);} void getCompMove(){ // get the move from the computer } void checkWinner(){ // check the winner int i; for(i = 6; i < 9; i++){ // check cols if((sum(s[i].value,s[i-3].value,s[i-6].value)) == 8){printf("The Winner is o!\n");gamestate.state=1;} if((sum(s[i].value,s[i-3].value,s[i-6].value)) == 1){printf("The Winner is x!\n");gamestate.state=2;} } for(i = 0; i < 7; i+=3){ // check rows if((sum(s[i].value,s[i+1].value,s[i+2].value)) == 8){printf("The Winner is o!\n");gamestate.state=1;} if((sum(s[i].value,s[i+1].value,s[i+2].value)) == 1){printf("The Winner is x!\n");gamestate.state=2;} } if((sum(s[0].value,s[4].value,s[8].value)) == 8){printf("The Winner is o!\n");gamestate.state=1;} if((sum(s[0].value,s[4].value,s[8].value)) == 1){printf("The Winner is x!\n");gamestate.state=2;} if((sum(s[2].value,s[4].value,s[6].value)) == 8){printf("The Winner is o!\n");gamestate.state=1;} if((sum(s[2].value,s[4].value,s[6].value)) == 1){printf("The Winner is x!\n");gamestate.state=2;} } void playGame(){ // start playing the game gamestate.state = 3; //set-up the gamestate srand(time(NULL)); int temp = (rand()%2) + 1; if(temp == 2){ // if two comp goes first temp = (rand()%2) + 1; if(temp == 2){ s[4].value = 2; s[4].sign = 'o'; gamestate.moves++; }else{ s[2].value = 2; s[2].sign = 'o'; gamestate.moves++; } } displayBoard(); while(gamestate.state == 3){ if(gamestate.moves<10); getHumanMove(); if(gamestate.moves<10); getCompMove(); checkWinner(); if(gamestate.state == 3 && gamestate.moves==9){ printf("The game is a tie :p\n"); break; } displayBoard(); } } int main(int argc, const char *argv[]){ printf("Welcome to Tic Tac Toe\nby The Elite Noob\nEnter 1-9 To play a move, standard numpad\n1 is bottom-left, 9 is top-right\n"); while(1){ // while game is being played printf("\nPress 1 to play a new game, or any other number to exit;\n>>:"); char line[255]; // input whether or not to play the game fgets(line, sizeof(line), stdin); int choice; // user's choice about playing or not while(sscanf(line, "%d", &choice) != 1) { //1 match of defined specifier on input line printf("Sorry, that's not a valid option!\n"); fgets(line, sizeof(line), stdin); } if(choice == 1){ setUpGame(); // set's up the game playGame(); // Play a Game }else {break;} // exit the application } printf("\nThank's For playing!\nHave a good Day!\n"); return 0; }

    Read the article

  • Python: does it make sense to refactor this check into it's own method?

    - by Jeff Fry
    I'm still learning python. I just wrote this method to determine if a player has won a game of tic-tac-toe yet, given a board state like:'[['o','x','x'],['x','o','-'],['x','o','o']]' def hasWon(board): players = ['x', 'o'] for player in players: for row in board: if row.count(player) == 3: return player top, mid, low = board for i in range(3): if [ top[i],mid[i],low[i] ].count(player) == 3: return player if [top[0],mid[1],low[2]].count(player) == 3: return player if [top[2],mid[1],low[0]].count(player) == 3: return player return None It occurred to me that I check lists of 3 chars several times and could refactor the checking to its own method like so: def check(list, player): if list.count(player) == 3: return player ...but then realized that all that really does is change lines like: if [ top[i],mid[i],low[i] ].count(player) == 3: return player to: if check( [top[i],mid[i],low[i]], player ): return player ...which frankly doesn't seem like much of an improvement. Do you see a better way to refactor this? Or in general a more Pythonic option? I'd love to hear it!

    Read the article

  • How do I go from a simple html5 tic tac toe game to an online 2 player game?

    - by phi1o
    I've been working on an online 2 player Tic Tac Toe solution for blackberries. both old and new. And so far I have html5 code that has a 3 x 3 layout that switches between x and o for the game mechanics. I believe I'm still missing a check for win function but my question is about the server side of this game. I'm not sure how to go about learning what exactly I want. how do you take what I have now, and make this into a functioning online game? I've been told WAMP is a good solution, as well as IIS. and its all really over my head, so i'm hoping to get a little more clarity as far as what I should focus on to bring this game to life.

    Read the article

  • TicTacToe AI Making Incorrect Decisions

    - by Chris Douglass
    A little background: as a way to learn multinode trees in C++, I decided to generate all possible TicTacToe boards and store them in a tree such that the branch beginning at a node are all boards that can follow from that node, and the children of a node are boards that follow in one move. After that, I thought it would be fun to write an AI to play TicTacToe using that tree as a decision tree. TTT is a solvable problem where a perfect player will never lose, so it seemed an easy AI to code for my first time trying an AI. Now when I first implemented the AI, I went back and added two fields to each node upon generation: the # of times X will win & the # of times O will win in all children below that node. I figured the best solution was to simply have my AI on each move choose and go down the subtree where it wins the most times. Then I discovered that while it plays perfect most of the time, I found ways where I could beat it. It wasn't a problem with my code, simply a problem with the way I had the AI choose it's path. Then I decided to have it choose the tree with either the maximum wins for the computer or the maximum losses for the human, whichever was more. This made it perform BETTER, but still not perfect. I could still beat it. So I have two ideas and I'm hoping for input on which is better: 1) Instead of maximizing the wins or losses, instead I could assign values of 1 for a win, 0 for a draw, and -1 for a loss. Then choosing the tree with the highest value will be the best move because that next node can't be a move that results in a loss. It's an easy change in the board generation, but it retains the same search space and memory usage. Or... 2) During board generation, if there is a board such that either X or O will win in their next move, only the child that prevents that win will be generated. No other child nodes will be considered, and then generation will proceed as normal after that. It shrinks the size of the tree, but then I have to implement an algorithm to determine if there is a one move win and I think that can only be done in linear time (making board generation a lot slower I think?) Which is better, or is there an even better solution?

    Read the article

  • Tic-Tac-Toe AI: How to Make the Tree?

    - by cam
    I'm having a huge block trying to understand "trees" while making a Tic-Tac-Toe bot. I understand the concept, but I can't figure out to implement them. Can someone show me an example of how a tree should be generated for such a case? Or a good tutorial on generating trees? I guess the hard part is generating partial trees. I know how to implement generating a whole tree, but not parts of it.

    Read the article

  • Is it possible that we override global variables?

    - by Ram Moj
    I have this function: function example(y) global TICTOC; tic TICTOC=5; toc end and I expect TICTOC=5 change the result of toc, since TICTOC is a global variable in tic and toc functions; but this is not the case; Does anyone know the reason? I like to know the answer, because I 'm worried to declare a global variable, which it's name has been declared global in some other functions, I'm not aware of. I saw this function in matlab 2008b help function tic % TIC Start a stopwatch timer. % TIC; any stuff; TOC % prints the time required. % See also: TOC, CLOCK. global TICTOC TICTOC = clock; function t = toc % TOC Read the stopwatch timer. % TOC prints the elapsed time since TIC was used. % t = TOC; saves elapsed time in t, does not print. % See also: TIC, ETIME. global TICTOC if nargout < 1 elapsed_time = etime(clock, TICTOC) else t = etime(clock, TICTOC); end thanks.

    Read the article

  • alternative to visibility:collapse not working on IE and Chrome

    - by tic
    The following page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <STYLE type="text/css"> tr.cccc { visibility: collapse; } </STYLE> <BODY> <TABLE border="1"> <TR class="cccc"> <TD>one</TD> </TR> </TABLE> </BODY> </HTML> works only in Firefox. IE always displays the row, and Chrome hides the row but showing its vertical space. So, how can I hide completely a row using only CSS? Thanks.

    Read the article

  • simple onmouseover to call javascript not working

    - by tic
    In a simple html page I have: <SCRIPT> function Clicker(number){ if (number == 1) document.write ('<style type="text/css">body {background-color: #cccccc;}</style>'); } </SCRIPT> and in the html body: <a onmouseclick="Clicker(1)" href="#">clic</a> But when I click on the link nothing happens. Where am I wrong?

    Read the article

  • grep_replace: unknown modifier

    - by tic
    Let assume that $body is equal to something that does not interest me <!-- start --> some html code <!-- end --> something that does not interest me If I use $body=preg_replace("(.*)<!-- start -->(.*)<!-- end -->(.*)","$2",$body); I obtain: Warning: preg_replace() [function.preg-replace]: Unknown modifier '<' How have I to correct?

    Read the article

  • changing css properties via javascript

    - by tic
    I need a function to change the appearance of some elements in my html page "on the fly", but I am not able to do. The problem is that I cannot use a command like document.write ('body {background-color: #cccccc;}'); because I need to make the changes effective when the page is already loaded, using a link like <a onmouseclick="Clicker(1)" href="#">clic</a> and I cannot use a command like document.body.style.background='#cccccc'; because I do not know if it can be applied to other not so easy cases, because I need to change the appearance of elements such as td.myclass or sibling elements such as th[scope=col]+th[scope=col]+th[scope=col]. How can I do it? Thanks!

    Read the article

1 2 3 4  | Next Page >