I need help reviewing my mini-max algorithm

Hi,
I've created a game of chess bottom up - I've been working on it for about one year now. This is a for fun project that I'm working on for pleasure, not a homework assignment or some.
I have reached the point where I'm interested in making a computer player who makes 'smart' decisions. I read chapter 5 of the AI (Modern Approach) book, and learned how to implement the minimax algorithm. I understand conceptually how it works, and I translated the pseudo code in the book into the following listed at the bottom of the post. I made several observations:
1) with depth of 1, the algorithm seems to choose the best 'Move' with simple end game scenarios ( i.e. mate in 1 ) when i select depth 1
2) with a simple mate in 2 scenario, the algorithm doesn't seem to pick the best move with depth of 4 ( look two full moves ahead ).
Can someone who is perhaps more familiar with minimax take a peek at my code and perhaps offer some suggestions as to why this may be the case? I know my implementation right now is not optimal, since I use a copy constructore to keep track of game states, as opposed to performing a move undo - however, I'm not looking to optimize the algorithm just yet. Any help is appreciated.
    public Move miniMax(Board chess_board, Player opponent, int depth) {
          long time = System.currentTimeMillis();
          examinedNodesCount = 0;
         // calculate a decision using the minimax
        ArrayList legalMoves = getPlayerLegalMoves();
        int highest_seen_value = Integer.MIN_VALUE;
        int lowest_seen_value  = Integer.MAX_VALUE;
        Move best_move = null;
        examinedNodesCount += legalMoves.size();
        for (int i = 0; i < legalMoves.size(); i++ ) {
            int value = 0;
            try {
                 Board b = new Board(chess_board);
                 Player c = new Player(this);
                 Player o = new Player(opponent);
                 Move move = new Move((Move)legalMoves.get(i));
                 c.makeMove(b, o, move);
                 System.out.print("mp: " +move);
                 value = minimaxValue(b, o, c, depth - 1, move);
                 if ( c.playerIdentity == "White") {
                      if (value > highest_seen_value) {
                           highest_seen_value = value;
                           best_move = move;
                 } else {
                    if (value < lowest_seen_value) {
                         lowest_seen_value = value;
                         best_move = move;
            } catch(Exception e){}
            System.out.println();
          time = System.currentTimeMillis() - time;
          Table.ChatPanel p = Table.getChatPanel();
          float time_per_board = (float)time /(float)examinedNodesCount;
          float boards_per_second =  (float)1000 / (float)time_per_board;
          p.writeToDisplay("INFO:\nsearch depth = " +depth+
                    "\n# examined boards: " + examinedNodesCount +
                    "\ntotal time: " +time+ " ms " +
                    "\navg time per board: " + time_per_board + " ms " +
                    "\n# boards per second: " + boards_per_second +
                    "\n move chosen: " +best_move);
        return best_move;
    private static int minimaxValue(
              Board chess_board,
              Player current_player,
              Player opponent_player,
              int depth,
              Move m ) {
        int ret_val = 0;
         if (depth == 0 ||
              current_player.isInCheckMate() ||
              opponent_player.isInCheckMate()) {
              ret_val =  Board.evaluateBoard(chess_board, current_player, opponent_player);
              System.out.print(" with eval of: " +ret_val+ ", ");
         } else if (current_player.getIdentity() == "White") {
            ArrayList legalMoves = current_player.getPlayerLegalMoves();
            int highest_seen_value = Integer.MIN_VALUE;
            examinedNodesCount += legalMoves.size();
            for (int i = 0; i < legalMoves.size(); i++ ) {
                int value = 0;
                try {
                     Board b = new Board(chess_board);
                     Player c = new Player(current_player);
                     Player o = new Player(opponent_player);
                     Move move = new Move((Move)legalMoves.get(i));
                     System.out.print("\t=> " +move);
                     c.makeMove(b, o, move);
                     value = minimaxValue(b, o, c, depth - 1, move);
                    if (value > highest_seen_value) {
                        highest_seen_value = value;
                } catch(Exception e){}
            ret_val = highest_seen_value;
        else {
            ArrayList legalMoves = current_player.getPlayerLegalMoves();
            int lowest_seen_value = Integer.MAX_VALUE;
            examinedNodesCount += legalMoves.size();
            for (int i = 0; i < legalMoves.size(); i++ ) {
                int value = 0;
                try {
                     Board b = new Board(chess_board);
                     Player c = new Player(current_player);
                     Player o = new Player(opponent_player);
                     Move move = new Move((Move)legalMoves.get(i));
                     System.out.print("\t=> " +move);
                     c.makeMove(b, o, move);
                     value = minimaxValue(b, o, c, depth - 1, move);
                } catch(Exception e){}
                if (value < lowest_seen_value) {
                     lowest_seen_value = value;     
            ret_val = lowest_seen_value;
        return ret_val;
    }

Eek,
I found one bug in my program, where i initialize value to 0 instead of the appropriate min or max. That might have done the trick. I'll explore with simple end game scenarios and give an update.

Similar Messages

  • I need help please-ipod mini/itunes help

    Hi,I have a computer and a laptop. I would like to add my computer itunes libary to my laptop intunes libary.Both liberies are itunes7. I just cant do it. I need help please. Simple steps or someone on the phone or someone who lives in Wimbledon and could come by and help me,cheers.Conny

    Check these out:
    Getting Music from your iPod to your Computer 3rd party options
    Using One iPod With Multiple Computers
    I hope this helps!

  • Min-Max Algorithm - StackOverFlowError ???

    Having trouble with my minmax algorithm for my game. Keep getting StackOverFlowError - possible due to too much recursion???
    If it is too much recusion - ie the game tree is too vast what should I do?
    This is just for a Dominoes game - so I didnt think it would be that complicated :S
    Any help / suggestions / insight will be greatly appreciated!!!
    NB. It is the tacticExtreme method that is the recursive one
    // Strategy MinMax
        public void tacticMinMaxAlpha(Domino player[]) {
                Domino probDomino = new Domino(7,7);
                int score = 0;
                int highestScore = 0;
                // Create array of possible opponent dominoes
                possiblePlays();
                // Create ArrayList of possible moves from current situation
                ArrayList possMoves = new ArrayList(possibleMoves(player, moveLeft, moveRight));
                if(possMoves.size() == 0) {
                     // If there are no plays do nothing!
                } else {
                     // For each of my dominoes that are playable...
                  for(int i = 0; i < possMoves.size(); i++){
                      Domino tempDomino[] = new Domino[7];
                      int newLeft = moveLeft;
                         int newRight = moveRight;
                     Domino domino = (Domino)possMoves.get(i);
                     if (domino.x == moveLeft && domino.x != moveRight) {
                         newLeft = domino.y;
                     } else if (domino.x == moveRight){
                         newRight = domino.y;
                     } else if (domino.y == moveLeft && domino.y != moveRight) {
                         newLeft = domino.x;
                     } else if (domino.y == moveRight) {
                         newRight = domino.x;
                     // Mark the domino used
                     for(int j = 0; j < 7; j++){
                          tempDomino[j] = new Domino(player[j].x, player[j].y);
                          //if(!player[j].available) tempDomino[j].available = false;
                            if(domino.x == tempDomino[j].x){
                                 if(domino.y == player[j].y){
                                      tempDomino[j].available = false;
                     // Calculate the number of possible moves at most the opponent may have
                        ArrayList other = new ArrayList(possibleMoves(possible, newLeft, newRight));
                       if(other.size() > 0){
                            score = tacticExtreme(tempDomino, possible, newLeft, newRight, false);     
                     if (score > highestScore) {
                         highestScore = score;
                         probDomino = new Domino(domino.x, domino.y);
                     } else if(score == highestScore){
                          if((domino.x + domino.y) > (probDomino.x + probDomino.y)){
                               probDomino = new Domino(domino.x, domino.y);
             if((probDomino.x != 7)){
                  for(int i = 0; i < 7; i++){
                       if(probDomino.x == player.x){
                        if(probDomino.y == player[i].y){
                             play = i + 1;
    } else {
         play = 0;
    } // end tacticProbability()
    // Tactic tacticProbability
    public int tacticExtreme(Domino player1[], Domino player2[], int left, int right, boolean flag) {
              int score = 0;
              boolean player1First = flag;
              // Check not greater than 3 recursion calls by this method
              if( DepthLimitReached() ){
                   depth = 0;
              } else {
                   if(player1First){
                   Domino tempDomino[] = new Domino[player1.length];
                   ArrayList possMoves = new ArrayList(possibleMoves(player1, moveLeft, moveRight));
                   // For each playable domino
              for(int i = 0; i < possMoves.size(); i++){
              int newLeft = left;
              int newRight = right;
         Domino domino = (Domino)possMoves.get(i);
         if (domino.x == moveLeft && domino.x != moveRight) {
         newLeft = domino.y;
         } else if (domino.x == moveRight){
         newRight = domino.y;
         } else if (domino.y == moveLeft && domino.y != moveRight) {
         newLeft = domino.x;
         } else if (domino.y == moveRight) {
         newRight = domino.x;
              // Mark the current domino as used to pass to the next recursion call
         for(int j = 0; j < player1.length; j++){
              tempDomino[j] = new Domino(player1[j].x, player1[j].y);
                        if(domino.x == tempDomino[j].x){
                             if(domino.y == player1[j].y){
                                  tempDomino[j].available = false;
                        // Check if that was the last Domino in hand. If it wasn't then continue on search tree.
                        if(outOfDominoes(tempDomino)){
                             score = 100; // Played all the Dominoes - WIN!!!
                        } else {
                             ArrayList x = new ArrayList(player2.length);
                             x = possibleMoves(player2, newLeft, newRight);
                   ArrayList y = new ArrayList(tempDomino.length);
                             y = possibleMoves(tempDomino, newLeft, newRight);
                   if(x.size() > 0) { // If player2 has a move it is their turn
                        score = tacticExtreme(tempDomino, player2, newLeft, newRight, !player1First);
                   } else if (y.size() > 0){ // If player2 has no move. Have I got a move?
                        score = tacticExtreme(tempDomino, player2, newLeft, newRight, player1First);
                   } else { // If no one can make a move then it is a draw.
                        score = 50;
              } else {
                   Domino tempDomino[] = new Domino[player2.length];
                   ArrayList possMoves = new ArrayList(possibleMoves(player2, moveLeft, moveRight));
                   // For each playable domino
              for(int i = 0; i < possMoves.size(); i++){
              int newLeft = left;
              int newRight = right;
         Domino domino = (Domino)possMoves.get(i);
         if (domino.x == moveLeft && domino.x != moveRight) {
         newLeft = domino.y;
         } else if (domino.x == moveRight){
         newRight = domino.y;
         } else if (domino.y == moveLeft && domino.y != moveRight) {
         newLeft = domino.x;
         } else if (domino.y == moveRight) {
         newRight = domino.x;
              // Mark the domino used     
         for(int j = 0; j < player2.length; j++){
              tempDomino[j] = new Domino(player2[j].x, player2[j].y);
                        if(domino.x == tempDomino[j].x){
                             if(domino.y == player2[j].y){
                                  tempDomino[j].available = false;
                        if(outOfDominoes(tempDomino)){
                             score = -100;
                        } else {
                             ArrayList other = new ArrayList(player1.length);
                             other = possibleMoves(player1, newLeft, newRight);
                   ArrayList myPlayable = new ArrayList(tempDomino.length);
                             myPlayable = possibleMoves(tempDomino, newLeft, newRight);
                   if(other.size() > 0) {
                        score = tacticExtreme(player1, tempDomino, newLeft, newRight, player1First);
                   } else if (myPlayable.size() > 0){
                        score = tacticExtreme(player1, tempDomino, newLeft, newRight, !player1First);
                   } else {
                        score = 50;
         return score;
    } // end tacticExtreme()

    You are so wrong!
    The recursion depth of MinMax is limited to the number of moves into the future you want the computer to think.
    If you have a complex game with 100 different possible moves, and you want the computer to think 4 moves into the future, then the recursion depth will be 4.
    If you have a simple game with just 2 different possible moves, and you want the computer to think 4 moves into the future, then the recursion depth will still be 4.
    In both cases you need a stack that can handle the depth of 4.
    The stack might be small, yes, but the stack size needed is extremely small.
    The time it takes to complete the algorithm will be dependent of the complexity of the game.
    A complex game as mentioned above would run the recursive method 100^4 = 100000000 times, and the simple game as mentioned above would run the recursive method 2^4 = 16 times.
    In addition, one single run trough the method would normally be faster in a more simple game.
    In order to make an AI that is as smart as possible without being slow, you would normally increase the recursion depth of the simple game, and decrease the recursion depth of the complex game.
    To summarize:
    The stack size needed for the complex game is smaller than the stack size needed for the simple game.
    The stack size needed (both for the complex and the simple game) is very small.
    The time needed to complete the algorithm grows exponentially, so it is unfeasible to increase the recursion depth (potentially risking a stack overflow) without causing the calculation to be too slow (assuming the computer never should use more than 1 year to calculate its next move).

  • Need help with Hp mini remote

    Hi, I bought a new hp Dv3 laptop (dv3-2165ee) few days ago, and I did a clean windows 7 ultimate install, downloaded drivers from hp support site, however the laptop wont detect anything from the remote, the remote is working perfect on my other hp notebook, so the problem is from the IR reciver, i tried installing the ICRdriver many times but no use,
    could i get help with this please,
    thanks in advance

    In SwitchRes X, try building a custom timing using the following values:
    Pixel clock: 134.86 MHz
    Horizontal Active: 1680 pixels
    Horizontal Front porch: 104 pixels
    Horizontal Sync width: 128 pixels
    Horizontal Back porch: 152 pixels
    Vertical Active: 1050 lines
    Vertical Front porch: 3 lines
    Vertical Sync width: 6 lines
    Vertical Back porch: 30 lines
    Put a check mark on the "Positive sync." option for Horizontal but leave it unchecked for Vertical. And you have to have the "Use simplified settings:" box unchecked to be able to enter the above data because otherwise several of the boxes will be greyed out and uneditable.
    The whole trick is to get the pixel clock under 135 MHz. In the standard configuration, the pixel clock is 146.25 MHz as can be seen in the data you posted under "Descriptor #0". That's too high for the mini in some circumstances.
    One more thing; you need to make the above custom addition to SwitchRes X while the HP is hooked up to the mini via the HP's DVI input, not the VGA input. Since you aren't getting a picture when connected by DVI, that presents a bit of a problem. You can try to start in Safe Mode (hold down the shift key during a restart) which should give you a useable screen to work with under DVI, albeit at a pretty low resolution. Good luck.

  • I NEED HELP WITH THE MINI VGA TO TV CONNECTOR!! HELP PLEASE

    When I plug the Mini VGA into my TV the picture shows up but it is very small and blurry. What can I do to fix this? Thanks for an Help!
    12 inch iBook   Mac OS X (10.4)  

    Okay, take a look at Knowledge Base Article #88396. It does sound like you are actually using the "Apple Video Adapter" and not the "VGA Adapter". The VGA adapter has a single connector with several rows of pins. The "Apple Video Adapter" has two connectors, one for s-video and one for composite video. The composite video cable is usually yellow (this would go with the red & white connectors for the audio).
    Have you tried Jon's suggestion to open the Displays System Preferences and try the "Detect Displays" button? The Displays pane should give you options to choose between NTSC and PAL. Do you see these options? Is the connector plugged in securely? What do you see? Is the picture small in the middle of the screen with a black border around it? Or does the picture fill up the screen but everything is oversized? What size is the TV?
    You do know that regular TVs make really, really bad computer displays, right? The iBook will only be displaying a 600 x 800 image so the Desktop will look pretty blurry if you have a TV bigger than about 12". But a DVD or the iTunes visualizations should display well.
    -Doug

  • Need help using ipod mini for disc space

    When I try to click the box to use my mini as disc space the box is grayed out. Can't be clicked. I am using the gold mini. Is the ipod too old to be used as disc space. why is the box grayed out. I have all the allowances to do everything. Can anyone help? Thanks, oldmankent.
    G5    

    The usual reason for the enable disk use box to be "greyed out" and not selectable is because the iPod is set to manually transfer songs.
    If this is the case, then disk use is automatically enabled. With manual transfer disk use is the default setting and cannot be changed.

  • Need help to find a CRC16 algorithm (according to ISO14443-A)

    Hello,
    Could anyone help me find a description or implementation of the crc algorithm according to ISO-14443-A or ITU-T V.41)
    Regards LnP

    I stumbled on this month-old discussion of using Corel Draw to make fonts, and thought of Adobe Illustrator's little-known ability to behave similarly via the evolving technology of SING glyphlets. Like Corel's Save-As-TTF feature, this only works for one glyph at a time -- not surprising as the idea behind SING glyphlets is to add a few characters to an existing font. The fly in the ointment is that for now this only works for recent East Asian versions. The process is the subject of a demonstration (in English and Chinese) over on the CCJK Type blog
    where I commented that non-CCJK folks would also like to try this out.
    David

  • Need Help With Mac Mini Networking

    I sure could use some Apple Expert advise:
    I am having quite a problem getting my mac mini to see my Windows (Vista-XP) network. I am only able to see one of my systems when I use the smb://command. First I used this command from the address bar of Firefox, it connected and mounted the drive on my mac desktop.....would not see any of the others. I have (2) Leopard books and have followed the steps correctly.
    Went back to the store-local and we did the same functions and without fail the systems showed up quickly in the finder as shared.
    I have the WINS: NETBIOS name and Workgroup name correct. I have file sharing, screen sharing turned on.
    Can anyone give me some thoughts as to what I am missing here. Again unless I use the smb://command nothing shows up. I have the Finder set to show shared.
    Connection to the wireless net, perfect-less than a minute to complete.
    Thanks in advance

    Windows PCs aren't visible from the shared area.
    Here's a tip: write an Automator application to mount the computer's C drives (you will need 1 app per PC). Then, run that app and open a Finder window and then the PC's IP address will be visible in the shared area. Make sure you know the PC's IP address. Then for convenience, give your new apps their own snazzily named folder and drag that to the dock and make a stack.
    Another thing: if you don't already have one, setup a password for your desktop because if there isn't one, serious problems will occur.
    <Edited by Moderator>

  • Min Max Planning Error-Unable to generate requisition

    when we run min max planning in test instance for certain items we get the the below error:
    “Unable to generate requisition”
    Checked the source type for the items which had this error.There is no Source type set for those items even then we get this error.Any help.
    Thanks

    Check
    Min/Max Planning Message: "Unable to Generate Requisition" [ID 113224.1]
    Getting Message "Unable to generate requisition" in the Output of the Min-Max Planning Report (INVISMMX) [ID 1265297.1]
    Hope this helps,
    Sandeep Gandhi

  • Urgent: Chart Axis with Min, Max, Help needed.

    Hi guys,
    I am rushing on a report submodule in our application, which will go on live in a short time. We need to have charts which use min and max value from the table and calculate the appropriate interval as the scale of the axis, instead of the default interval.
    I also tried to put page items into the Min&Max in the chart attributes, but always got the error message that asks for a number.
    I have searched the forum and the conclusion I can made now, is that HTMLDB does not support parameterized value for chart axis.
    So, my question is: if I have to do it manually, how should I do it? I don't have much experiences in pl/sql, so really need some help here.
    Any input is appreciated.

    Does anybody know whether a chart can be built on a collection? I've tried but didn't succeed.
    If somebody has experiences on this, please let me know, so I won't waste more time on trying it if the answer is no. Thanks.

  • Need some help with the DOF Min Max Planning Logic

    Hello All,
    Morning...could someone please help us with this issue which we are facing in our production system.
    We are running the Dof Min Max Planning Report at the Subinventory level and for a given item.
    This item setup in this sub inventory has the Min qty : 2 , Max qty :2.
    --We don't see any open orders/ requisitions in the system for this item.
    --We also don't see any expected receipts for this item coming to this org/subinventory.. All the shipment lines are in Fully Received status.
    --We dont see any stuck supply records in mtl_supply table as well..and also checked for the Inv Transactions interface tables as well ( MTI , mtl_material_transactions_temp)..we dont find any stuck transactions for this item, subinventory & org.
    Now when we are running the Dof Min Max report is is showing the Supply Quantity as 2 and Available Quantity as 2.
    Hence the Reorder quantity is coming as Zero..basically it is not re stocking the item again for this subinventory level.
    Could someone please assist as to what could be reason why this Supply Quantity is showing some value when we dont see any stuck supply / expected open receipts..
    What else we need to check here to get this issue resolved and to know the source of the Supply Quantity.
    thanks

    In the report run, what parameters are considered as Supply?, Also did you check the supply data considering your cutoff dates offset?, the item what you are talking about is a buy item? check if there were requisitions already created.

  • Need help with min max sql

    hi all, forgot i had a user name and password and haven't needed help for quite a bit since i didn't do sql for a while but now i'm back at reporting again...
    Here is a sample table as i remember it:
    Item     Date     Time     Time Frame     Duration     Duration Frame
    A     20100926     0     5     500     10
    A     20100926     600     10     500     30
    A     20100926     1500     12     100     30
    B     20100926     1800     28     200     40
    B     20100926     2200     6     150     70
    B     20100926     2600     15     600     60
    B     20100926     3600     30     200     70
    Results Set (expected):                         
    Item     Date     Time     Total Duration          
    A     20100926     0     1600:20     --basically max (time+duration) - min(time+duration)     
    B     20100926     1800     2000:00
    Sorry, but. I didnt put my sql statement as I wasn't planning on posting and left it at work, but, i've been looking on internet and people say to use min/max function and i've attenpted it with it works with just this table (without grouping). But as soon as i group it the values seem to mess up.
    Last i remembered it gave me:
    Item     Date     Time     Total Duration          
    A     20100926     0     1600:30     --basically max(time+duration) - min(time+duration)     
    B     20100926     1800     2000:70
    I think it's looking at max duration which is 30&70 and hence it retrurns those values in the result set. Is it because of the max function hence it's returning this value? any help is appreciated. thanks
    Edited by: stanleyho on Sep 30, 2010 4:44 PM

    Okay, here we go again, repost, hopefully okay this time:
    Hi Madhu, okay, just got to work: I am using TOAD and working in Oracle 10g. Here is my table structure and the query i use to try and get what I am looking for:
    There is one extra table but that is only used to link these two tables listed below so i didn't bother posting it.
    TABLE: TX_RECON_INSTANCE_VIEW
    ColumnName ColID DataType Null
    CHANNEL_CODE 3 VARCHAR2 (4 Char) N
    DURATION 8 NUMBER (10) N
    DURATION_FRAME 9 NUMBER (2) N
    REAL_TIME 6 NUMBER (10) N
    REAL_TIME_FRAME 7 NUMBER (2) N
    ITEM_ID 4 NUMBER Y
    TX_DATE 2 CHAR (8 Byte) N
    TX_ID 1 NUMBER (9) N
    TX_TYPE 13 VARCHAR2 (4 Char) N
    TABLE: TX_SCHEDULE
    ColumnName ColID PK Null DataType
    TX_TYPE 22 N VARCHAR2 (4 Char)
    TX_ID 1 1 N NUMBER (9)
    TX_DATE 2 N CHAR (8 Byte)
    SCHEDULE_TIME_FRAME 9 N NUMBER (2)
    SCHEDULE_TIME 8 N NUMBER (10)
    REAL_TIME 10 N NUMBER (10)
    DURATION_FRAME 13 N NUMBER (2)
    DURATION 12 N NUMBER (10)________________________________________
    And the data and results:
    TX_ID TX_DATE REAL_TIME REAL_TIME_FRAME DURATION DURATION_FRAME ITEM_ID AS RUN TIME AS RUN DURATION SCHEDULED TIME SCHEDULED DURATION SCHEDULE_TIME SCHEDULE_TIME_FRAME DURATION_1 DURATION_FRAME_1
    1651000 20100710 0 0 545 20 1234 00:00:00:00 00:09:05:20 00:00:00:00 00:09:05:20 0 0 545 20
    1752223 20100710 667 12 281 7 1234 00:11:07:12 00:04:41:07 00:11:07:10 00:04:41:07 667 10 281 7
    1846501 20100710 1071 13 335 9 1234 00:17:51:13 00:05:35:09 00:17:50:09 00:05:35:09 1070 9 335 9
    2001102 20100710 1525 6 249 14 1234 00:25:25:06 00:04:09:14 00:25:22:08 00:04:09:14 1522 8 249 14
    3246669 20100710 1800 0 586 2 1235 00:30:00:00 00:09:46:02 00:30:00:00 00:09:46:02 1800 0 586 2
    4456822 20100710 2492 16 276 5 1235 00:41:32:16 00:04:36:05 00:41:32:16 00:04:36:05 2492 16 276 5
    1253168 20100710 2890 15 222 17 1235 00:48:10:15 00:03:42:17 00:48:10:15 00:03:42:17 2890 15 222 17
    1112456 20100710 3277 18 297 0 1235 00:54:37:18 00:04:57:00 00:54:35:10 00:04:57:00 3275 10 297 0
    Grouped results set:
    TX_DATE ITEM_ID AS RUN TIME AS RUN DURATION SCHEDULED TIME SCHEDULED DURATION
    20100710 1234 00:00:00:00 00:29:34:20 00:00:00:00 00:29:31:20
    20100710 1235 00:30:00:00 00:29:34:17 00:30:00:00 00:29:32:17
    --> SCHEDULED DURATION "00:29:31:20" is not correct as it should be (00:25:22:08+00:04:09:14)-(00:00:00:00)=00:29:31:22
    --> see expected results below
    Expected results:
    TX_DATE ITEM_ID AS RUN TIME AS RUN DURATION SCHEDULED TIME SCHEDULED DURATION
    20100710 1234 00:00:00:00 00:29:34:20 00:00:00:00 00:29:31:22
    20100710 1235 00:30:00:00 00:29:34:18 00:30:00:00 00:29:34:10________________________________________
    And the query I am using:
    SELECT --TXR.TX_ID,
    TXR.TX_DATE, TXR.ITEM_ID,
    TO_CHAR(TRUNC((MIN(TXR.REAL_TIME) KEEP (DENSE_RANK FIRST ORDER BY TXR.REAL_TIME) )/3600),'FM00')||':'||TO_CHAR(TRUNC(MOD(MIN(TXR.REAL_TIME) KEEP (DENSE_RANK FIRST ORDER BY TXR.REAL_TIME) ,3600)/60),'FM00')||':'||TO_CHAR(MOD(MIN(TXR.REAL_TIME) KEEP (DENSE_RANK FIRST ORDER BY TXR.REAL_TIME) ,60),'FM00')||':'||TO_CHAR(MOD(MIN(TXR.REAL_TIME_FRAME) KEEP (DENSE_RANK FIRST ORDER BY TXR.REAL_TIME) ,60),'FM00') "AS RUN TIME",
    to_char(trunc((MAX(TXR.REAL_TIME+TXR.DURATION)-MIN(TXR.REAL_TIME))/3600),'FM00')||':'||to_char(trunc(mod(MAX(TXR.REAL_TIME+TXR.DURATION)-MIN(TXR.REAL_TIME),3600)/60),'FM00')||':'||to_char(mod(MAX(TXR.REAL_TIME+TXR.DURATION)-MIN(TXR.REAL_TIME),60),'FM00')||':'||to_char(mod(MAX(TXR.REAL_TIME_FRAME+TXR.DURATION_FRAME)-MIN(TXR.REAL_TIME),60),'FM00') "AS RUN DURATION",
    TO_CHAR(TRUNC((MIN(TXS.SCHEDULE_TIME) KEEP (DENSE_RANK FIRST ORDER BY TXR.REAL_TIME) )/3600),'FM00')||':'||TO_CHAR(TRUNC(MOD(MIN(TXS.SCHEDULE_TIME) KEEP (DENSE_RANK FIRST ORDER BY TXR.REAL_TIME) ,3600)/60),'FM00')||':'||TO_CHAR(MOD(MIN(TXS.SCHEDULE_TIME) KEEP (DENSE_RANK FIRST ORDER BY TXR.REAL_TIME) ,60),'FM00')||':'||TO_CHAR(MOD(MIN(TXS.SCHEDULE_TIME_FRAME) KEEP (DENSE_RANK FIRST ORDER BY TXR.REAL_TIME) ,60),'FM00') "SCHEDULED TIME",
    to_char(trunc((MAX(TXS.SCHEDULE_TIME+TXS.DURATION)-MIN(TXS.SCHEDULE_TIME))/3600),'FM00')||':'||to_char(trunc(mod(MAX(TXS.SCHEDULE_TIME+TXS.DURATION)-MIN(TXS.SCHEDULE_TIME),3600)/60),'FM00')||':'||to_char(mod(MAX(TXS.SCHEDULE_TIME+TXS.DURATION)-MIN(TXS.SCHEDULE_TIME),60),'FM00')||':'||to_char(mod(MAX(TXS.DURATION_FRAME),60),'FM00') "SCHEDULED DURATION"
    FROM TX_RECON_INSTANCE_VIEW TXR, TX_SCHEDULE TXS, TX_SCHEDULE_RECON TXREC
    WHERE TXR.TX_DATE=20100926 AND TXR.TX_TYPE='P'
    AND TXR.TX_ID=TXREC.RECON_TX_ID(+)
    AND TXREC.BASE_TX_ID=TXS.TX_ID(+)
    GROUP BY TXR.TX_DATE, TXR.ITEM_ID
    ORDER BY TXR.TX_DATE, TXR.ITEM_ID, MAX(TXR.REAL_TIME)--does this work for everyone now? let me know...thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Help to find the max, min and the averages wages

    ok i did sum programming i got half of my program to work but i need help with the other half the program is suppose to find the highest and lowest wages and also give the average wages. here is my code
    import java.util.*;
        public class WorkerwagesQueues
          static Scanner console = new Scanner(System.in);
           public static void main (String[] args)
             Queue<String> nameQ = new LinkedList<String>();
             Queue<String> nameQ2 = new LinkedList<String>();
             Queue<Double> num = new LinkedList<Double>();
             int searchCnt = 0;
             int max, min;
             String toSearch, var;
             System.out.println("Welcome, how are you Doing today\n");
             System.out.println("Please enter the five workers names\n");
             for (int i = 0; i < 5; i++)
                nameQ.offer(console.next());
             System.out.println("Please enter the five workers salaries\n");
             for (int i = 0; i < 5; i++)
                num.offer(console.nextDouble());
            // starting right here is my problem
            /*min = num.next(0);
             max = num.get(0);
             for (int i = 0; i < num.size(); i++)
                System.out.println(num.get(i));
                if (i > 0)
                   if (min > num.get(i))
                      min = num.get(i);
                   if (max < num.get(i))
                      max = num.get(i);
             System.out.println("\nthe Lowest wage is " + num );
             System.out.println("\nthe Largest wage is " + num );
             System.out.println("please enter a name to serach the queue:");
             toSearch = console.next();      
             while (nameQ.size() > 0)
                var = nameQ.remove();
                if (var.equals(toSearch))
                {searchCnt++;}
                else
                {nameQ2.offer(var);}               
             System.out.println("This queue contains " + toSearch + " " + searchCnt + " time(s).");
             System.out.println("The second queue is:");
       }

    ok sorry if i am annoying you guys but i really want to get this working
    this is the part i am having problems with. I am trying to find the max and min of the wages the user input and i am not usre how to do it. my question is how do i do that?
    // starting right here is my problem
            /*min = num.next(0);
             max = num.get(0);
             for (int i = 0; i < num.size(); i++)
                System.out.println(num.get(i));
                if (i > 0)
                   if (min > num.get(i))
                      min = num.get(i);
                   if (max < num.get(i))
                      max = num.get(i);
             System.out.println("\nthe Lowest wage is " + num );
             System.out.println("\nthe Largest wage is " + num );
         

  • HOW TO?: Need help setting up 3 different iCloud accounts for my kids (so each has own iMessanger)using same Apple ID (mine) ....they don't have their own separate email addresses to work from...how do I do this?

    Need help setting up 3 different iCloud accounts for my kids (so each has own iMessanger)using same Apple ID (mine) ....they don't have their own separate email addresses to work from...how do I do this?

    Any devices connected to the same icloud account can sync all the data on that account.  For this reason an icloud account is really for a single user.
    On a mac, if each user has their own account, then the itunes for that mac account should be set up to connect to that user's icloud account (System preferences>icloud).

  • My D420 is not working on my new Mac Mini I need help

    I have a new Canon Printer D420 . I love the machine works great
    the price was great. It worked good on my old Imac for a few weeks then
    I bought a new Mac Mini and now I can't get it to work. I reloaded my
    solfware taht came with it..... need help
    thanks 
    Ray Land 

    Hi Ray Land,
    We can help narrow down the cause.  What operating system are you using on your new Mac Mini? 
    If you are running the Mountain Lion OS, you can download the latest driver here.  An important note is that the current print queue must be deleted before installing the new driver.  This will ensure proper communication.
    If this doesn't work or you need further assistance, please contact us here.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

Maybe you are looking for